email: Post STARTLS capability code tidy up (Part Three)

Corrected the order of the upgrade_tls() functions and moved the handler
upgrade and getsock() functions out from the middle of the state related
functions.
This commit is contained in:
Steve Holme 2013-02-11 23:13:50 +00:00
Родитель de492b31c5
Коммит 586f5d3614
3 изменённых файлов: 106 добавлений и 108 удалений

Просмотреть файл

@ -204,6 +204,15 @@ static const struct Curl_handler Curl_handler_imaps_proxy = {
#endif
#endif
#ifdef USE_SSL
static void imap_to_imaps(struct connectdata *conn)
{
conn->handler = &Curl_handler_imaps;
}
#else
#define imap_to_imaps(x) Curl_nop_stmt
#endif
/***********************************************************************
*
* imap_sendf()
@ -493,6 +502,25 @@ static CURLcode imap_state_starttls(struct connectdata *conn)
return result;
}
static CURLcode imap_state_upgrade_tls(struct connectdata *conn)
{
struct imap_conn *imapc = &conn->proto.imapc;
CURLcode result;
result = Curl_ssl_connect_nonblocking(conn, FIRSTSOCKET, &imapc->ssldone);
if(!result) {
if(imapc->state != IMAP_UPGRADETLS)
state(conn, IMAP_UPGRADETLS);
if(imapc->ssldone) {
imap_to_imaps(conn);
result = imap_state_capability(conn);
}
}
return result;
}
static CURLcode imap_state_login(struct connectdata *conn)
{
@ -627,22 +655,6 @@ static CURLcode imap_authenticate(struct connectdata *conn)
return result;
}
/* For the IMAP "protocol connect" and "doing" phases only */
static int imap_getsock(struct connectdata *conn, curl_socket_t *socks,
int numsocks)
{
return Curl_pp_getsock(&conn->proto.imapc.pp, socks, numsocks);
}
#ifdef USE_SSL
static void imap_to_imaps(struct connectdata *conn)
{
conn->handler = &Curl_handler_imaps;
}
#else
#define imap_to_imaps(x) Curl_nop_stmt
#endif
/* For the initial server greeting */
static CURLcode imap_state_servergreet_resp(struct connectdata *conn,
int imapcode,
@ -719,26 +731,6 @@ static CURLcode imap_state_starttls_resp(struct connectdata *conn,
return result;
}
static CURLcode imap_state_upgrade_tls(struct connectdata *conn)
{
struct imap_conn *imapc = &conn->proto.imapc;
CURLcode result;
result = Curl_ssl_connect_nonblocking(conn, FIRSTSOCKET, &imapc->ssldone);
if(!result) {
if(imapc->state != IMAP_UPGRADETLS)
state(conn, IMAP_UPGRADETLS);
if(imapc->ssldone) {
imap_to_imaps(conn);
result = imap_state_capability(conn);
}
}
return result;
}
/* For AUTHENTICATE PLAIN (without initial response) responses */
static CURLcode imap_state_auth_plain_resp(struct connectdata *conn,
int imapcode,
@ -1397,6 +1389,13 @@ static CURLcode imap_init(struct connectdata *conn)
return CURLE_OK;
}
/* For the IMAP "protocol connect" and "doing" phases only */
static int imap_getsock(struct connectdata *conn, curl_socket_t *socks,
int numsocks)
{
return Curl_pp_getsock(&conn->proto.imapc.pp, socks, numsocks);
}
/***********************************************************************
*
* imap_connect() should do everything that is to be considered a part of

Просмотреть файл

@ -207,6 +207,15 @@ static const struct Curl_handler Curl_handler_pop3s_proxy = {
#endif
#endif
#ifdef USE_SSL
static void pop3_to_pop3s(struct connectdata *conn)
{
conn->handler = &Curl_handler_pop3s;
}
#else
#define pop3_to_pop3s(x) Curl_nop_stmt
#endif
/* Function that checks for an ending pop3 status code at the start of the
given string, but also detects the APOP timestamp from the server greeting
as well as the supported authentication types and allowed SASL mechanisms
@ -406,6 +415,25 @@ static CURLcode pop3_state_starttls(struct connectdata *conn)
return result;
}
static CURLcode pop3_state_upgrade_tls(struct connectdata *conn)
{
struct pop3_conn *pop3c = &conn->proto.pop3c;
CURLcode result;
result = Curl_ssl_connect_nonblocking(conn, FIRSTSOCKET, &pop3c->ssldone);
if(!result) {
if(pop3c->state != POP3_UPGRADETLS)
state(conn, POP3_UPGRADETLS);
if(pop3c->ssldone) {
pop3_to_pop3s(conn);
result = pop3_state_capa(conn);
}
}
return result;
}
static CURLcode pop3_state_user(struct connectdata *conn)
{
@ -551,22 +579,6 @@ static CURLcode pop3_authenticate(struct connectdata *conn)
return result;
}
/* For the POP3 "protocol connect" and "doing" phases only */
static int pop3_getsock(struct connectdata *conn, curl_socket_t *socks,
int numsocks)
{
return Curl_pp_getsock(&conn->proto.pop3c.pp, socks, numsocks);
}
#ifdef USE_SSL
static void pop3_to_pop3s(struct connectdata *conn)
{
conn->handler = &Curl_handler_pop3s;
}
#else
#define pop3_to_pop3s(x) Curl_nop_stmt
#endif
/* For the initial server greeting */
static CURLcode pop3_state_servergreet_resp(struct connectdata *conn,
int pop3code,
@ -642,26 +654,6 @@ static CURLcode pop3_state_starttls_resp(struct connectdata *conn,
return result;
}
static CURLcode pop3_state_upgrade_tls(struct connectdata *conn)
{
struct pop3_conn *pop3c = &conn->proto.pop3c;
CURLcode result;
result = Curl_ssl_connect_nonblocking(conn, FIRSTSOCKET, &pop3c->ssldone);
if(!result) {
if(pop3c->state != POP3_UPGRADETLS)
state(conn, POP3_UPGRADETLS);
if(pop3c->ssldone) {
pop3_to_pop3s(conn);
result = pop3_state_capa(conn);
}
}
return result;
}
/* For AUTH PLAIN responses */
static CURLcode pop3_state_auth_plain_resp(struct connectdata *conn,
int pop3code,
@ -1323,6 +1315,13 @@ static CURLcode pop3_init(struct connectdata *conn)
return CURLE_OK;
}
/* For the POP3 "protocol connect" and "doing" phases only */
static int pop3_getsock(struct connectdata *conn, curl_socket_t *socks,
int numsocks)
{
return Curl_pp_getsock(&conn->proto.pop3c.pp, socks, numsocks);
}
/***********************************************************************
*
* pop3_connect()

Просмотреть файл

@ -204,6 +204,15 @@ static const struct Curl_handler Curl_handler_smtps_proxy = {
#endif
#endif
#ifdef USE_SSL
static void smtp_to_smtps(struct connectdata *conn)
{
conn->handler = &Curl_handler_smtps;
}
#else
#define smtp_to_smtps(x) Curl_nop_stmt
#endif
/* Function that checks for an ending SMTP status code at the start of the
given string, but also detects various capabilities from the EHLO response
including the supported authentication mechanisms. */
@ -379,6 +388,26 @@ static CURLcode smtp_state_starttls(struct connectdata *conn)
return result;
}
static CURLcode smtp_state_upgrade_tls(struct connectdata *conn)
{
struct smtp_conn *smtpc = &conn->proto.smtpc;
CURLcode result;
result = Curl_ssl_connect_nonblocking(conn, FIRSTSOCKET, &smtpc->ssldone);
if(!result) {
if(smtpc->state != SMTP_UPGRADETLS)
state(conn, SMTP_UPGRADETLS);
if(smtpc->ssldone) {
smtp_to_smtps(conn);
result = smtp_state_ehlo(conn);
}
}
return result;
}
static CURLcode smtp_authenticate(struct connectdata *conn)
{
CURLcode result = CURLE_OK;
@ -468,22 +497,6 @@ static CURLcode smtp_authenticate(struct connectdata *conn)
return result;
}
/* For the SMTP "protocol connect" and "doing" phases only */
static int smtp_getsock(struct connectdata *conn, curl_socket_t *socks,
int numsocks)
{
return Curl_pp_getsock(&conn->proto.smtpc.pp, socks, numsocks);
}
#ifdef USE_SSL
static void smtp_to_smtps(struct connectdata *conn)
{
conn->handler = &Curl_handler_smtps;
}
#else
#define smtp_to_smtps(x) Curl_nop_stmt
#endif
/* For the initial server greeting */
static CURLcode smtp_state_servergreet_resp(struct connectdata *conn,
int smtpcode,
@ -528,26 +541,6 @@ static CURLcode smtp_state_starttls_resp(struct connectdata *conn,
return result;
}
static CURLcode smtp_state_upgrade_tls(struct connectdata *conn)
{
struct smtp_conn *smtpc = &conn->proto.smtpc;
CURLcode result;
result = Curl_ssl_connect_nonblocking(conn, FIRSTSOCKET, &smtpc->ssldone);
if(!result) {
if(smtpc->state != SMTP_UPGRADETLS)
state(conn, SMTP_UPGRADETLS);
if(smtpc->ssldone) {
smtp_to_smtps(conn);
result = smtp_state_ehlo(conn);
}
}
return result;
}
/* For EHLO responses */
static CURLcode smtp_state_ehlo_resp(struct connectdata *conn, int smtpcode,
smtpstate instate)
@ -1312,6 +1305,13 @@ static CURLcode smtp_init(struct connectdata *conn)
return CURLE_OK;
}
/* For the SMTP "protocol connect" and "doing" phases only */
static int smtp_getsock(struct connectdata *conn, curl_socket_t *socks,
int numsocks)
{
return Curl_pp_getsock(&conn->proto.smtpc.pp, socks, numsocks);
}
/***********************************************************************
*
* smtp_connect()