Changeset 786 in openpam for trunk/lib/liboath/oath_key.c


Ignore:
Timestamp:
Mar 10, 2014, 3:37:55 PM (7 years ago)
Author:
Dag-Erling Smørgrav
Message:

Move oath_key_from_file() into a separate source file and document it.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/liboath/oath_key.c

    r772 r786  
    3737
    3838#include <inttypes.h>
    39 #include <stdio.h>
    4039#include <stdlib.h>
    4140
     
    4645
    4746#include <security/oath.h>
    48 
    49 struct oath_key *
    50 oath_key_from_file(const char *filename)
    51 {
    52         struct oath_key *key;
    53         FILE *f;
    54         char *line;
    55         size_t len;
    56 
    57         if ((f = fopen(filename, "r")) == NULL)
    58                 return (NULL);
    59         /* get first non-empty non-comment line */
    60         line = openpam_readline(f, NULL, &len);
    61         if (strlcmp("otpauth://", line, len) == 0) {
    62                 key = oath_key_from_uri(line);
    63         } else {
    64                 openpam_log(PAM_LOG_ERROR,
    65                     "unrecognized key file format: %s", filename);
    66                 key = NULL;
    67         }
    68         fclose(f);
    69         return (key);
    70 }
    7147
    7248char *
Note: See TracChangeset for help on using the changeset viewer.