]> diplodocus.org Git - nmh/commitdiff
credentials.c: Move interface to own file.
authorRalph Corderoy <ralph@inputplus.co.uk>
Sat, 11 Nov 2017 17:45:25 +0000 (17:45 +0000)
committerRalph Corderoy <ralph@inputplus.co.uk>
Sun, 12 Nov 2017 12:25:32 +0000 (12:25 +0000)
Makefile.am
h/prototypes.h
sbr/credentials.c
sbr/credentials.h [new file with mode: 0644]
sbr/netsec.c
sbr/ruserpass.c
uip/popsbr.c

index 5b2c6f01813a97c78a9fddc1b96b81d1131105d1..93a1ca8b9f9aba05e174cc3dd88db6a0703ed02a 100644 (file)
@@ -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 \
index ddaad4a863ac1e51616fd8196483e13149d8848e..b04fbcfd1a76a0d26780fbeffb8034171a57d461 100644 (file)
@@ -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);
index b4907c90b29323635a84725d9478a3014fcc4a04..bf2ab6035c7b0f4c6a0bf6ecbaa7e599986e5e4f 100644 (file)
@@ -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 (file)
index 0000000..537de10
--- /dev/null
@@ -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);
index 98a221a249ec1b02f641ea0c2b76d1953c21bdea..3f0ea221356480ee70cd5ff389c0ea7d07c679ea 100644 (file)
@@ -7,6 +7,7 @@
  */
 
 #include "h/mh.h"
+#include "credentials.h"
 #include "getcpy.h"
 #include "brkstring.h"
 #include "h/utils.h"
index 3c0b7179b34207c3a886c5f823b3c8f942668a3d..cbdab4b9af6582a20459a7dfb0cab300aca6543f 100644 (file)
@@ -22,6 +22,7 @@
  */
 
 #include "h/mh.h"
+#include "credentials.h"
 #include "error.h"
 #include "h/utils.h"
 #include <pwd.h>
index c17d9993345b7488c1e715ea3bb1d21c98172e9d..02e10e6e6a3776b12bf67d81d3b94896c1ba0164 100644 (file)
@@ -6,6 +6,7 @@
  */
 
 #include "h/mh.h"
+#include "sbr/credentials.h"
 #include "sbr/client.h"
 #include "sbr/error.h"
 #include "h/utils.h"