aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSteve Holme <steve_holme@hotmail.com>2013-12-18 07:10:22 +0000
committerSteve Holme <steve_holme@hotmail.com>2013-12-18 00:11:25 +0000
commitda24fbbc00ce1edd3215f843061ad949b7ea9608 (patch)
treee2cfdcd9047d89ff598056c300eafb1bdc5abfd7 /lib
parent367648d24a0e92080322a3f2cdd4948a473a0335 (diff)
smtp: Moved the sending of the AUTH command into a separate function
Diffstat (limited to 'lib')
-rw-r--r--lib/smtp.c47
1 files changed, 34 insertions, 13 deletions
diff --git a/lib/smtp.c b/lib/smtp.c
index d4097c567..4c12a102b 100644
--- a/lib/smtp.c
+++ b/lib/smtp.c
@@ -430,6 +430,39 @@ static CURLcode smtp_perform_upgrade_tls(struct connectdata *conn)
/***********************************************************************
*
+ * smtp_perform_auth()
+ *
+ * Sends an AUTH command allowing the client to login with the given SASL
+ * authentication mechanism.
+ */
+static CURLcode smtp_perform_auth(struct connectdata *conn,
+ const char *mech,
+ const char *initresp, size_t len,
+ smtpstate state1, smtpstate state2)
+{
+ CURLcode result = CURLE_OK;
+ struct smtp_conn *smtpc = &conn->proto.smtpc;
+
+ if(initresp && 8 + strlen(mech) + len <= 512) { /* AUTH <mech> ...<crlf> */
+ /* Send the AUTH command with the initial response */
+ result = Curl_pp_sendf(&smtpc->pp, "AUTH %s %s", mech, initresp);
+
+ if(!result)
+ state(conn, state2);
+ }
+ else {
+ /* Send the AUTH command */
+ result = Curl_pp_sendf(&smtpc->pp, "AUTH %s", mech);
+
+ if(!result)
+ state(conn, state1);
+ }
+
+ return result;
+}
+
+/***********************************************************************
+ *
* smtp_perform_authentication()
*
* Initiates the authentication sequence, with the appropriate SASL
@@ -525,19 +558,7 @@ static CURLcode smtp_perform_authentication(struct connectdata *conn)
if(!result) {
if(mech) {
/* Perform SASL based authentication */
- if(initresp &&
- 8 + strlen(mech) + len <= 512) { /* AUTH <mech> ...<crlf> */
- result = Curl_pp_sendf(&smtpc->pp, "AUTH %s %s", mech, initresp);
-
- if(!result)
- state(conn, state2);
- }
- else {
- result = Curl_pp_sendf(&smtpc->pp, "AUTH %s", mech);
-
- if(!result)
- state(conn, state1);
- }
+ result = smtp_perform_auth(conn, mech, initresp, len, state1, state2);
Curl_safefree(initresp);
}