From: Ralph Corderoy Date: Sat, 11 Nov 2017 17:45:25 +0000 (+0000) Subject: credentials.c: Move interface to own file. X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/db8011d59fd72ef03d9866a345f4a017f2cb11e0?ds=inline;hp=8baf8cfdcc7058e7132bc8bcf4b1ae6e281d9034 credentials.c: Move interface to own file. --- diff --git a/Makefile.am b/Makefile.am index 5b2c6f01..93a1ca8b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -379,6 +379,7 @@ noinst_HEADERS = \ sbr/copyip.h \ sbr/cpydata.h \ sbr/cpydgst.h \ + sbr/credentials.h \ sbr/ctype-checked.h \ sbr/discard.h \ sbr/encode_rfc2047.h \ diff --git a/h/prototypes.h b/h/prototypes.h index ddaad4a8..b04fbcfd 100644 --- a/h/prototypes.h +++ b/h/prototypes.h @@ -161,48 +161,3 @@ int sendsbr (char **, int, char *, char *, struct stat *, int, const char *); int what_now (char *, int, int, char *, char *, int, struct msgs *, char *, int, char *, int); int WhatNow(int, char **) NORETURN; - -/* - * credentials management - */ -void init_credentials_file(void); - -/* - * Allocate and return a credentials structure. The credentials structure - * is now opaque; you need to use accessors to get inside of it. The - * accessors will only prompt the user for missing fields if they are - * needed. - * - * Arguments: - * - * host - Hostname we're connecting to (used to search credentials file) - * user - Username we are logging in as; can be NULL. - * - * Returns NULL on error, otherwise an allocated nmh_creds structure. - */ -nmh_creds_t nmh_get_credentials (const char *host, const char *user); - -/* - * Retrieve the user from a nmh_creds structure. May prompt the user - * if one is not defined. - * - * Arguments: - * - * creds - Structure from previous nmh_get_credentials() call - * - * Returns NULL on error, otherwise a NUL-terminated string containing - * the username. Points to allocated memory in the credentials structure - * that is free()d by nmh_free_credentials(). - */ -const char *nmh_cred_get_user(nmh_creds_t creds); - -/* - * Retrieve the password from an nmh_creds structure. Otherwise identical - * to nmh_cred_get_user(). - */ -const char *nmh_cred_get_password(nmh_creds_t creds); - -/* - * Free an allocated nmh_creds structure. - */ -void nmh_credentials_free(nmh_creds_t creds); diff --git a/sbr/credentials.c b/sbr/credentials.c index b4907c90..bf2ab603 100644 --- a/sbr/credentials.c +++ b/sbr/credentials.c @@ -6,6 +6,7 @@ */ #include "h/mh.h" +#include "credentials.h" #include "context_find.h" #include "error.h" #include "h/utils.h" diff --git a/sbr/credentials.h b/sbr/credentials.h new file mode 100644 index 00000000..537de10f --- /dev/null +++ b/sbr/credentials.h @@ -0,0 +1,50 @@ +/* credentials.h -- wrap configurable access to .netrc or similar files. + * + * This code is Copyright (c) 2017, by the authors of nmh. See the + * COPYRIGHT file in the root directory of the nmh distribution for + * complete copyright information. */ + +/* + * credentials management + */ +void init_credentials_file(void); + +/* + * Allocate and return a credentials structure. The credentials structure + * is now opaque; you need to use accessors to get inside of it. The + * accessors will only prompt the user for missing fields if they are + * needed. + * + * Arguments: + * + * host - Hostname we're connecting to (used to search credentials file) + * user - Username we are logging in as; can be NULL. + * + * Returns NULL on error, otherwise an allocated nmh_creds structure. + */ +nmh_creds_t nmh_get_credentials(const char *, const char *); + +/* + * Retrieve the user from a nmh_creds structure. May prompt the user + * if one is not defined. + * + * Arguments: + * + * creds - Structure from previous nmh_get_credentials() call + * + * Returns NULL on error, otherwise a NUL-terminated string containing + * the username. Points to allocated memory in the credentials structure + * that is free()d by nmh_free_credentials(). + */ +const char *nmh_cred_get_user(nmh_creds_t); + +/* + * Retrieve the password from an nmh_creds structure. Otherwise identical + * to nmh_cred_get_user(). + */ +const char *nmh_cred_get_password(nmh_creds_t); + +/* + * Free an allocated nmh_creds structure. + */ +void nmh_credentials_free(nmh_creds_t); diff --git a/sbr/netsec.c b/sbr/netsec.c index 98a221a2..3f0ea221 100644 --- a/sbr/netsec.c +++ b/sbr/netsec.c @@ -7,6 +7,7 @@ */ #include "h/mh.h" +#include "credentials.h" #include "getcpy.h" #include "brkstring.h" #include "h/utils.h" diff --git a/sbr/ruserpass.c b/sbr/ruserpass.c index 3c0b7179..cbdab4b9 100644 --- a/sbr/ruserpass.c +++ b/sbr/ruserpass.c @@ -22,6 +22,7 @@ */ #include "h/mh.h" +#include "credentials.h" #include "error.h" #include "h/utils.h" #include diff --git a/uip/popsbr.c b/uip/popsbr.c index c17d9993..02e10e6e 100644 --- a/uip/popsbr.c +++ b/uip/popsbr.c @@ -6,6 +6,7 @@ */ #include "h/mh.h" +#include "sbr/credentials.h" #include "sbr/client.h" #include "sbr/error.h" #include "h/utils.h"