#include <string.h>
#include <h/mh.h>
+#include <h/utils.h>
#include <h/oauth.h>
#define 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;
+ trim_suffix_c(line, '\n');
+
return line;
}
mh_oauth_log_to(stderr, ctx);
}
- fn = getcpy(mh_oauth_cred_fn(ctx));
+ 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));
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();
}