aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Holme <steve_holme@hotmail.com>2013-12-18 07:05:11 +0000
committerSteve Holme <steve_holme@hotmail.com>2013-12-18 00:11:13 +0000
commit367648d24a0e92080322a3f2cdd4948a473a0335 (patch)
tree620dd661f97bf27b4152afbc4741f974cbca6014
parentbd3a59ad415b9d370cf1273b91be2c49e9d236d5 (diff)
pop3: Moved the sending of the AUTH command into a separate function
-rw-r--r--lib/pop3.c47
1 files changed, 34 insertions, 13 deletions
diff --git a/lib/pop3.c b/lib/pop3.c
index c2c6bc734..b0bf7f179 100644
--- a/lib/pop3.c
+++ b/lib/pop3.c
@@ -574,6 +574,39 @@ static CURLcode pop3_perform_apop(struct connectdata *conn)
/***********************************************************************
*
+ * pop3_perform_auth()
+ *
+ * Sends an AUTH command allowing the client to login with the given SASL
+ * authentication mechanism.
+ */
+static CURLcode pop3_perform_auth(struct connectdata *conn,
+ const char *mech,
+ const char *initresp, size_t len,
+ pop3state state1, pop3state state2)
+{
+ CURLcode result = CURLE_OK;
+ struct pop3_conn *pop3c = &conn->proto.pop3c;
+
+ if(initresp && 8 + strlen(mech) + len <= 255) { /* AUTH <mech> ...<crlf> */
+ /* Send the AUTH command with the initial response */
+ result = Curl_pp_sendf(&pop3c->pp, "AUTH %s %s", mech, initresp);
+
+ if(!result)
+ state(conn, state2);
+ }
+ else {
+ /* Send the AUTH command */
+ result = Curl_pp_sendf(&pop3c->pp, "AUTH %s", mech);
+
+ if(!result)
+ state(conn, state1);
+ }
+
+ return result;
+}
+
+/***********************************************************************
+ *
* pop3_perform_authentication()
*
* Initiates the authentication sequence, with the appropriate SASL
@@ -673,19 +706,7 @@ static CURLcode pop3_perform_authentication(struct connectdata *conn)
if(!result) {
if(mech && (pop3c->preftype & POP3_TYPE_SASL)) {
/* Perform SASL based authentication */
- if(initresp &&
- 8 + strlen(mech) + len <= 255) { /* AUTH <mech> ...<crlf> */
- result = Curl_pp_sendf(&pop3c->pp, "AUTH %s %s", mech, initresp);
-
- if(!result)
- state(conn, state2);
- }
- else {
- result = Curl_pp_sendf(&pop3c->pp, "AUTH %s", mech);
-
- if(!result)
- state(conn, state1);
- }
+ result = pop3_perform_auth(conn, mech, initresp, len, state1, state2);
Curl_safefree(initresp);
}