X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/6b6847272dc5d21ca6fcd23bf20e16193b226c0a..ef1ba39e8dae81091b6c3e73e72825ef6edea3c6:/uip/mhlogin.c?ds=inline diff --git a/uip/mhlogin.c b/uip/mhlogin.c index aabe9a3d..ffa44f3f 100644 --- a/uip/mhlogin.c +++ b/uip/mhlogin.c @@ -11,6 +11,7 @@ #include #include +#include #include #define MHLOGIN_SWITCHES \ @@ -35,13 +36,12 @@ DEFINE_SWITCH_ARRAY(MHLOGIN, switches); static char * geta (void) { - char *cp; static char line[BUFSIZ]; if (fgets(line, sizeof(line), stdin) == NULL) done (1); - if ((cp = strchr(line, '\n'))) - *cp = 0; + TrimSuffixC(line, '\n'); + return line; } @@ -71,7 +71,7 @@ do_login(const char *svc, const char *user, const char *browser, int snoop) mh_oauth_log_to(stderr, ctx); } - fn = getcpy(mh_oauth_cred_fn(svc)); + fn = mh_xstrdup(mh_oauth_cred_fn(svc)); if ((url = mh_oauth_get_authorize_url(ctx)) == NULL) { adios(NULL, mh_oauth_get_err_string(ctx)); @@ -101,10 +101,10 @@ do_login(const char *svc, const char *user, const char *browser, int snoop) fflush(stdout); code = geta(); - while (strlen(code) == 0 || + while (!*code || ((cred = mh_oauth_authorize(code, ctx)) == NULL && mh_oauth_get_err_code(ctx) == MH_OAUTH_BAD_GRANT)) { - printf(strlen(code) == 0 ? "Empty code; try again? " : "Code rejected; try again? "); + printf(!*code ? "Empty code; try again? " : "Code rejected; try again? "); fflush(stdout); code = geta(); }