email: Moved starttls code in separate functions

To help maintain the readability of the code in imap.c, pop3.c and
smtp.c moved the starttls code into state_starttls() functions.
This commit is contained in:
Steve Holme
2013-02-06 20:02:36 +00:00
parent 12dbb8aedc
commit de0410fe9a
3 changed files with 43 additions and 11 deletions

View File

@@ -459,6 +459,20 @@ static void state(struct connectdata *conn, imapstate newstate)
imapc->state = newstate;
}
static CURLcode imap_state_starttls(struct connectdata *conn)
{
CURLcode result = CURLE_OK;
const char *str = getcmdid(conn);
/* Send the STARTTLS command */
result = imap_sendf(conn, str, "%s STARTTLS", str);
if(!result)
state(conn, IMAP_STARTTLS);
return result;
}
static CURLcode imap_state_capability(struct connectdata *conn)
{
CURLcode result = CURLE_OK;
@@ -608,10 +622,7 @@ static CURLcode imap_state_servergreet_resp(struct connectdata *conn,
if(data->set.use_ssl && !conn->ssl[FIRSTSOCKET].use) {
/* We don't have a SSL/TLS connection yet, but SSL is requested. Switch
to TLS connection now */
const char *str = getcmdid(conn);
result = imap_sendf(conn, str, "%s STARTTLS", str);
if(!result)
state(conn, IMAP_STARTTLS);
result = imap_state_starttls(conn);
}
else
result = imap_state_capability(conn);