diff options
author | Steve Holme <steve_holme@hotmail.com> | 2013-12-18 07:00:00 +0000 |
---|---|---|
committer | Steve Holme <steve_holme@hotmail.com> | 2013-12-18 00:10:39 +0000 |
commit | bd3a59ad415b9d370cf1273b91be2c49e9d236d5 (patch) | |
tree | 3d1cefa46af52cea905d81000e737fd49789cbf4 | |
parent | c0245cc59180e9330f80a8043005f91795c73981 (diff) |
imap: Moved the sending of the AUTHENICATE command into a separate function
-rw-r--r-- | lib/imap.c | 45 |
1 files changed, 33 insertions, 12 deletions
diff --git a/lib/imap.c b/lib/imap.c index 547b7904f..23b020be4 100644 --- a/lib/imap.c +++ b/lib/imap.c @@ -557,6 +557,38 @@ static CURLcode imap_perform_login(struct connectdata *conn) /*********************************************************************** * + * imap_perform_authenticate() + * + * Sends an AUTHENTICATE command allowing the client to login with the given + * SASL authentication mechanism. + */ +static CURLcode imap_perform_authenticate(struct connectdata *conn, + const char *mech, + const char *initresp, + imapstate state1, imapstate state2) +{ + CURLcode result = CURLE_OK; + + if(initresp) { + /* Send the AUTHENTICATE command with the initial response */ + result = imap_sendf(conn, "AUTHENTICATE %s %s", mech, initresp); + + if(!result) + state(conn, state2); + } + else { + /* Send the AUTHENTICATE command */ + result = imap_sendf(conn, "AUTHENTICATE %s", mech); + + if(!result) + state(conn, state1); + } + + return result; +} + +/*********************************************************************** + * * imap_perform_authentication() * * Initiates the authentication sequence, with the appropriate SASL @@ -653,18 +685,7 @@ static CURLcode imap_perform_authentication(struct connectdata *conn) if(!result) { if(mech && (imapc->preftype & IMAP_TYPE_SASL)) { /* Perform SASL based authentication */ - if(initresp) { - result = imap_sendf(conn, "AUTHENTICATE %s %s", mech, initresp); - - if(!result) - state(conn, state2); - } - else { - result = imap_sendf(conn, "AUTHENTICATE %s", mech); - - if(!result) - state(conn, state1); - } + result = imap_perform_authenticate(conn, mech, initresp, state1, state2); Curl_safefree(initresp); } |