X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/d253d4786c1712e9015474fae318e4e0a239ba88..2d033e9c995d385fcd69cb604bf8814de4d1ccec:/sbr/oauth.c diff --git a/sbr/oauth.c b/sbr/oauth.c index 00e5ba21..21035ac2 100755 --- a/sbr/oauth.c +++ b/sbr/oauth.c @@ -166,7 +166,7 @@ mh_oauth_do_xoauth(const char *user, const char *svc, unsigned char **oauth_res, if (mh_oauth_get_err_code(ctx) == MH_OAUTH_BAD_GRANT) { adios(NULL, "credentials rejected -- run mhlogin -saslmech xoauth2 -authservice %s", svc); } - advise(NULL, "error refreshing OAuth2 token"); + inform("error refreshing OAuth2 token"); adios(NULL, mh_oauth_get_err_string(ctx)); } @@ -196,7 +196,7 @@ static boolean is_json(const char *content_type) { return content_type != NULL - && strncasecmp(content_type, JSON_TYPE, sizeof JSON_TYPE - 1) == 0; + && strncasecmp(content_type, JSON_TYPE, LEN(JSON_TYPE)) == 0; } static void @@ -628,17 +628,17 @@ load_creds(struct user_creds **result, FILE *fp, mh_oauth_ctx *ctx) case FLDPLUS: { char **save, *expire; time_t *expires_at = NULL; - if (strncmp(name, "access-", 7) == 0) { + if (has_prefix(name, "access-")) { const char *user = name + 7; mh_oauth_cred *creds = find_or_alloc_user_creds(user_creds, user); save = &creds->access_token; - } else if (strncmp(name, "refresh-", 8) == 0) { + } else if (has_prefix(name, "refresh-")) { const char *user = name + 8; mh_oauth_cred *creds = find_or_alloc_user_creds(user_creds, user); save = &creds->refresh_token; - } else if (strncmp(name, "expire-", 7) == 0) { + } else if (has_prefix(name, "expire-")) { const char *user = name + 7; mh_oauth_cred *creds = find_or_alloc_user_creds(user_creds, user); @@ -897,7 +897,7 @@ debug_callback(const CURL *handle, curl_infotype type, const char *data, } fwrite(data, 1, size, fp); if (data[size - 1] != '\n') { - fputs("\n", fp); + putc('\n', fp); } fflush(fp); return 0; @@ -949,7 +949,7 @@ post(struct curl_ctx *ctx, const char *url, const char *req_body) curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback); curl_easy_setopt(curl, CURLOPT_WRITEDATA, ctx); - if (strncmp(url, "http://127.0.0.1:", 17) == 0) { + if (has_prefix(url, "http://127.0.0.1:")) { /* Hack: on Cygwin, curl doesn't fail to connect with ECONNREFUSED. Instead, it waits to timeout. So set a really short timeout, but just on localhost (for convenience of the user, and the test