X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=pop%2Fpop_auth.c;h=d715d7e5bfa16a8940ae1cb3a03270dda4897f00;hb=a11eb994c38b1ef41ea05b56736f70cc396e0ff8;hp=2583e1832f40545efcd05c38493ba6794498c66b;hpb=36d6553c2d1a80b38e961b95ebbfe0290dd5b002;p=apps%2Fmadmutt.git diff --git a/pop/pop_auth.c b/pop/pop_auth.c index 2583e18..d715d7e 100644 --- a/pop/pop_auth.c +++ b/pop/pop_auth.c @@ -161,7 +161,7 @@ bail: /* terminate SASL sessoin if the last responce is not +OK nor -ERR */ if (!mutt_strncmp (inbuf, "+ ", 2)) { snprintf (buf, sizeof (buf), "*\r\n"); - if (pop_query (pop_data, buf, sizeof (buf)) == -1) + if (pop_query (pop_data, buf, sizeof (buf)) == PQ_NOT_CONNECTED) return POP_A_SOCKET; } @@ -216,9 +216,9 @@ static pop_auth_res_t pop_auth_apop (POP_DATA * pop_data, const char *method) hash); switch (pop_query (pop_data, buf, sizeof (buf))) { - case 0: + case PQ_OK: return POP_A_SUCCESS; - case -1: + case PQ_NOT_CONNECTED: return POP_A_SOCKET; } @@ -233,9 +233,9 @@ static pop_auth_res_t pop_auth_apop (POP_DATA * pop_data, const char *method) static pop_auth_res_t pop_auth_user (POP_DATA * pop_data, const char *method) { char buf[LONG_STRING]; - int ret; + pop_query_status ret; - if (!pop_data->cmd_user) + if (pop_data->cmd_user == CMD_NOT_AVAILABLE) return POP_A_UNAVAIL; mutt_message _("Logging in..."); @@ -243,15 +243,15 @@ static pop_auth_res_t pop_auth_user (POP_DATA * pop_data, const char *method) snprintf (buf, sizeof (buf), "USER %s\r\n", pop_data->conn->account.user); ret = pop_query (pop_data, buf, sizeof (buf)); - if (pop_data->cmd_user == 2) { - if (ret == 0) { - pop_data->cmd_user = 1; + if (pop_data->cmd_user == CMD_UNKNOWN) { + if (ret == PQ_OK) { + pop_data->cmd_user = CMD_AVAILABLE; dprint (1, (debugfile, "pop_auth_user: set USER capability\n")); } - if (ret == -2) { - pop_data->cmd_user = 0; + if (ret == PQ_ERR) { + pop_data->cmd_user = CMD_NOT_AVAILABLE; dprint (1, (debugfile, "pop_auth_user: unset USER capability\n")); snprintf (pop_data->err_msg, sizeof (pop_data->err_msg), @@ -259,7 +259,7 @@ static pop_auth_res_t pop_auth_user (POP_DATA * pop_data, const char *method) } } - if (ret == 0) { + if (ret == PQ_OK) { snprintf (buf, sizeof (buf), "PASS %s\r\n", pop_data->conn->account.pass); ret = pop_query_d (pop_data, buf, sizeof (buf), #ifdef DEBUG @@ -270,9 +270,9 @@ static pop_auth_res_t pop_auth_user (POP_DATA * pop_data, const char *method) } switch (ret) { - case 0: + case PQ_OK: return POP_A_SUCCESS; - case -1: + case PQ_NOT_CONNECTED: return POP_A_SOCKET; } @@ -298,7 +298,7 @@ static pop_auth_t pop_authenticators[] = { * -2 - login failed, * -3 - authentication canceled. */ -int pop_authenticate (POP_DATA * pop_data) +pop_query_status pop_authenticate (POP_DATA * pop_data) { ACCOUNT *acct = &pop_data->conn->account; pop_auth_t *authenticator; @@ -310,7 +310,7 @@ int pop_authenticate (POP_DATA * pop_data) if (mutt_account_getuser (acct) || !acct->user[0] || mutt_account_getpass (acct) || !acct->pass[0]) - return -3; + return PFD_FUNCT_ERROR; if (PopAuthenticators && *PopAuthenticators) { /* Try user-specified list of authentication methods */ @@ -330,12 +330,12 @@ int pop_authenticate (POP_DATA * pop_data) ret = authenticator->authenticate (pop_data, method); if (ret == POP_A_SOCKET) switch (pop_connect (pop_data)) { - case 0: + case PQ_OK: { ret = authenticator->authenticate (pop_data, method); break; } - case -2: + case PQ_ERR: ret = POP_A_FAILURE; } @@ -365,13 +365,13 @@ int pop_authenticate (POP_DATA * pop_data) ret = authenticator->authenticate (pop_data, authenticator->method); if (ret == POP_A_SOCKET) switch (pop_connect (pop_data)) { - case 0: + case PQ_OK: { ret = authenticator->authenticate (pop_data, authenticator->method); break; } - case -2: + case PQ_ERR: ret = POP_A_FAILURE; } @@ -387,13 +387,13 @@ int pop_authenticate (POP_DATA * pop_data) switch (ret) { case POP_A_SUCCESS: - return 0; + return PQ_OK; case POP_A_SOCKET: - return -1; + return PQ_NOT_CONNECTED; case POP_A_UNAVAIL: if (!attempts) mutt_error (_("No authenticators available")); } - return -2; + return PQ_ERR; }