]> diplodocus.org Git - nmh/blobdiff - h/oauth.h
lock_file.c: close(2) file descriptor on failure, avoiding leak.
[nmh] / h / oauth.h
index ad6bd94054c981d92431f2d27b8fb2e52527262b..e6873df4edb30e686d8c5f94c3c838e7701d3dbe 100644 (file)
--- a/h/oauth.h
+++ b/h/oauth.h
@@ -1,13 +1,12 @@
-/*
- * Implementation of OAuth 2.0 [1] for XOAUTH2 in SMTP [2] and POP3 [3].
+/* oauth.h -- OAuth 2.0 implementation for XOAUTH2 in SMTP and POP3.
  *
  * Google defined XOAUTH2 for SMTP, and that's what we use here.  If other
  * providers implement XOAUTH2 or some similar OAuth-based SMTP authentication
  * protocol, it should be simple to extend this.
  *
  *
  * Google defined XOAUTH2 for SMTP, and that's what we use here.  If other
  * providers implement XOAUTH2 or some similar OAuth-based SMTP authentication
  * protocol, it should be simple to extend this.
  *
- * [1] https://tools.ietf.org/html/rfc6749
- * [2] https://developers.google.com/gmail/xoauth2_protocol
- * [3] http://googleappsdeveloper.blogspot.com/2014/10/updates-on-authentication-for-gmail.html
+ * OAuth  https://tools.ietf.org/html/rfc6749
+ * SMTP   https://developers.google.com/gmail/xoauth2_protocol
+ * POP3   http://googleappsdeveloper.blogspot.com/2014/10/updates-on-authentication-for-gmail.html
  *
  * Presumably [2] should document POP3 and that is an over-sight.  As it stands,
  * that blog post is the closest we have to documentation.
  *
  * Presumably [2] should document POP3 and that is an over-sight.  As it stands,
  * that blog post is the closest we have to documentation.
@@ -20,7 +19,7 @@
  * 1. User runs mhlogin which prints a URL the user must visit, and prompts for
  *    a code retrieved from that page.
  *
  * 1. User runs mhlogin which prints a URL the user must visit, and prompts for
  *    a code retrieved from that page.
  *
- * 2. User vists this URL in browser, signs in with some Google account, and
+ * 2. User visits this URL in browser, signs in with some Google account, and
  *    copies and pastes the resulting code back to mhlogin.
  *
  * 3. mhlogin does HTTP POST to Google to exchange the user-provided code for a
  *    copies and pastes the resulting code back to mhlogin.
  *
  * 3. mhlogin does HTTP POST to Google to exchange the user-provided code for a
@@ -129,9 +128,9 @@ mh_oauth_do_xoauth(const char *user, const char *svc, unsigned char **oauth_res,
  *
  * Accesses global m_defs via context_find.
  *
  *
  * Accesses global m_defs via context_find.
  *
- * On error, return FALSE and set an error in ctx; ctx is always allocated.
+ * On error, return false and set an error in ctx; ctx is always allocated.
  */
  */
-boolean
+bool
 mh_oauth_new(mh_oauth_ctx **ctx, const char *svc_name);
 
 /*
 mh_oauth_new(mh_oauth_ctx **ctx, const char *svc_name);
 
 /*
@@ -146,7 +145,7 @@ mh_oauth_free(mh_oauth_ctx *ctx);
  * Never returns NULL.
  */
 const char *
  * Never returns NULL.
  */
 const char *
-mh_oauth_svc_display_name(const mh_oauth_ctx *ctx);
+mh_oauth_svc_display_name(const mh_oauth_ctx *ctx) PURE;
 
 /*
  * Enable logging for subsequent operations on ctx.
 
 /*
  * Enable logging for subsequent operations on ctx.
@@ -165,7 +164,7 @@ mh_oauth_log_to(FILE *log, mh_oauth_ctx *ctx);
  * Must not be called if an error was not indicated.
  */
 mh_oauth_err_code
  * Must not be called if an error was not indicated.
  */
 mh_oauth_err_code
-mh_oauth_get_err_code(const mh_oauth_ctx *ctx);
+mh_oauth_get_err_code(const mh_oauth_ctx *ctx) PURE;
 
 /*
  * Return null-terminated error message after some function indicated an error.
 
 /*
  * Return null-terminated error message after some function indicated an error.
@@ -197,16 +196,16 @@ mh_oauth_authorize(const char *code, mh_oauth_ctx *ctx);
 /*
  * Refresh access (and maybe refresh) token if refresh token present.
  *
 /*
  * Refresh access (and maybe refresh) token if refresh token present.
  *
- * On error, return FALSE and leave cred untouched.
+ * On error, return false and leave cred untouched.
  */
  */
-boolean
+bool
 mh_oauth_refresh(mh_oauth_cred *cred);
 
 /*
  * Return whether access token is present and not expired at time T.
  */
 mh_oauth_refresh(mh_oauth_cred *cred);
 
 /*
  * Return whether access token is present and not expired at time T.
  */
-boolean
-mh_oauth_access_token_valid(time_t t, const mh_oauth_cred *cred);
+bool
+mh_oauth_access_token_valid(time_t t, const mh_oauth_cred *cred) PURE;
 
 /*
  * Free all resources associated with cred.
 
 /*
  * Free all resources associated with cred.
@@ -227,15 +226,15 @@ mh_oauth_cred_fn(const char *svc_name);
 /*
  * Serialize OAuth tokens to file.
  *
 /*
  * Serialize OAuth tokens to file.
  *
- * On error, return FALSE.
+ * On error, return false.
  */
  */
-boolean
+bool
 mh_oauth_cred_save(FILE *fp, mh_oauth_cred *cred, const char *user);
 
 /*
  * Load OAuth tokens from file.
  *
 mh_oauth_cred_save(FILE *fp, mh_oauth_cred *cred, const char *user);
 
 /*
  * Load OAuth tokens from file.
  *
- * Calls m_getfld(), which writes to stderr with advise().
+ * Calls m_getfld2(), which writes to stderr with advise().
  *
  * On error, return NULL.
  */
  *
  * On error, return NULL.
  */
@@ -258,6 +257,6 @@ mh_oauth_sasl_client_response(size_t *res_len,
  * Retrieve the various entries for the OAuth mechanism
  */
 
  * Retrieve the various entries for the OAuth mechanism
  */
 
-boolean
+bool
 mh_oauth_get_service_info(const char *svc_name, mh_oauth_service_info *svcinfo,
                          char *errbuf, size_t errbuflen);
 mh_oauth_get_service_info(const char *svc_name, mh_oauth_service_info *svcinfo,
                          char *errbuf, size_t errbuflen);