1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-21 23:58:49 -05:00

email: Tidy up before additional IMAP work

Replaced two explicit comparisons of CURLE_OK with boolean alternatives.

General tidy up of comments.
This commit is contained in:
Steve Holme 2013-02-13 20:12:21 +00:00
parent 0c6fa0dd64
commit d09d08dc1f
3 changed files with 35 additions and 25 deletions

View File

@ -505,6 +505,7 @@ static CURLcode imap_state_upgrade_tls(struct connectdata *conn)
struct imap_conn *imapc = &conn->proto.imapc; struct imap_conn *imapc = &conn->proto.imapc;
CURLcode result; CURLcode result;
/* Start the SSL connection */
result = Curl_ssl_connect_nonblocking(conn, FIRSTSOCKET, &imapc->ssldone); result = Curl_ssl_connect_nonblocking(conn, FIRSTSOCKET, &imapc->ssldone);
if(!result) { if(!result) {
@ -1415,19 +1416,22 @@ static CURLcode imap_connect(struct connectdata *conn, bool *done)
sessionhandle, deal with it */ sessionhandle, deal with it */
Curl_reset_reqproto(conn); Curl_reset_reqproto(conn);
/* Initialise the IMAP layer */
result = imap_init(conn); result = imap_init(conn);
if(CURLE_OK != result) if(result)
return result; return result;
/* We always support persistent connections on imap */ /* We always support persistent connections in IMAP */
conn->bits.close = FALSE; conn->bits.close = FALSE;
pp->response_time = RESP_TIMEOUT; /* set default response time-out */ /* Set the default response time-out */
pp->response_time = RESP_TIMEOUT;
pp->statemach_act = imap_statemach_act; pp->statemach_act = imap_statemach_act;
pp->endofresp = imap_endofresp; pp->endofresp = imap_endofresp;
pp->conn = conn; pp->conn = conn;
Curl_pp_init(pp); /* init generic pingpong data */ /* Initialise the pingpong layer */
Curl_pp_init(pp);
/* Start off waiting for the server greeting response */ /* Start off waiting for the server greeting response */
state(conn, IMAP_SERVERGREET); state(conn, IMAP_SERVERGREET);
@ -1460,9 +1464,9 @@ static CURLcode imap_done(struct connectdata *conn, CURLcode status,
if(!imap) if(!imap)
/* When the easy handle is removed from the multi while libcurl is still /* When the easy handle is removed from the multi while libcurl is still
* trying to resolve the host name, it seems that the imap struct is not * trying to resolve the host name, it seems that the IMAP struct is not
* yet initialized, but the removal action calls Curl_done() which calls * yet initialized, but the removal action calls Curl_done() which calls
* this function. So we simply return success if no imap pointer is set. * this function. So we simply return success if no IMAP pointer is set.
*/ */
return CURLE_OK; return CURLE_OK;
@ -1687,7 +1691,7 @@ static CURLcode imap_regular_transfer(struct connectdata *conn,
result = imap_perform(conn, &connected, dophase_done); result = imap_perform(conn, &connected, dophase_done);
if(CURLE_OK == result) { if(!result) {
if(!*dophase_done) if(!*dophase_done)
/* The DO phase has not completed yet */ /* The DO phase has not completed yet */
return CURLE_OK; return CURLE_OK;
@ -1703,7 +1707,7 @@ static CURLcode imap_setup_connection(struct connectdata * conn)
struct SessionHandle *data = conn->data; struct SessionHandle *data = conn->data;
if(conn->bits.httpproxy && !data->set.tunnel_thru_httpproxy) { if(conn->bits.httpproxy && !data->set.tunnel_thru_httpproxy) {
/* Unless we have asked to tunnel imap operations through the proxy, we /* Unless we have asked to tunnel IMAP operations through the proxy, we
switch and use HTTP operations only */ switch and use HTTP operations only */
#ifndef CURL_DISABLE_HTTP #ifndef CURL_DISABLE_HTTP
if(conn->handler == &Curl_handler_imap) if(conn->handler == &Curl_handler_imap)

View File

@ -415,6 +415,7 @@ static CURLcode pop3_state_upgrade_tls(struct connectdata *conn)
struct pop3_conn *pop3c = &conn->proto.pop3c; struct pop3_conn *pop3c = &conn->proto.pop3c;
CURLcode result; CURLcode result;
/* Start the SSL connection */
result = Curl_ssl_connect_nonblocking(conn, FIRSTSOCKET, &pop3c->ssldone); result = Curl_ssl_connect_nonblocking(conn, FIRSTSOCKET, &pop3c->ssldone);
if(!result) { if(!result) {
@ -1340,27 +1341,29 @@ static CURLcode pop3_connect(struct connectdata *conn, bool *done)
sessionhandle, deal with it */ sessionhandle, deal with it */
Curl_reset_reqproto(conn); Curl_reset_reqproto(conn);
/* Initialise the POP3 layer */
result = pop3_init(conn); result = pop3_init(conn);
if(CURLE_OK != result) if(result)
return result; return result;
/* We always support persistent connections on pop3 */ /* We always support persistent connections in POP3 */
conn->bits.close = FALSE; conn->bits.close = FALSE;
pp->response_time = RESP_TIMEOUT; /* set default response time-out */ /* Set the default response time-out */
pp->response_time = RESP_TIMEOUT;
pp->statemach_act = pop3_statemach_act; pp->statemach_act = pop3_statemach_act;
pp->endofresp = pop3_endofresp; pp->endofresp = pop3_endofresp;
pp->conn = conn; pp->conn = conn;
if(conn->handler->flags & PROTOPT_SSL) { if(conn->handler->flags & PROTOPT_SSL) {
/* POP3S is simply pop3 with SSL for the control channel */ /* POP3S is simply POP3 with SSL for the control channel */
/* so perform the SSL initialization for this socket */ /* so perform the SSL initialization for this socket */
result = Curl_ssl_connect(conn, FIRSTSOCKET); result = Curl_ssl_connect(conn, FIRSTSOCKET);
if(result) if(result)
return result; return result;
} }
/* Initialise the response reader stuff */ /* Initialise the pingpong layer */
Curl_pp_init(pp); Curl_pp_init(pp);
/* Start off waiting for the server greeting response */ /* Start off waiting for the server greeting response */
@ -1392,9 +1395,9 @@ static CURLcode pop3_done(struct connectdata *conn, CURLcode status,
if(!pop3) if(!pop3)
/* When the easy handle is removed from the multi while libcurl is still /* When the easy handle is removed from the multi while libcurl is still
* trying to resolve the host name, it seems that the pop3 struct is not * trying to resolve the host name, it seems that the POP3 struct is not
* yet initialized, but the removal action calls Curl_done() which calls * yet initialized, but the removal action calls Curl_done() which calls
* this function. So we simply return success if no pop3 pointer is set. * this function. So we simply return success if no POP3 pointer is set.
*/ */
return CURLE_OK; return CURLE_OK;
@ -1638,7 +1641,7 @@ static CURLcode pop3_regular_transfer(struct connectdata *conn,
result = pop3_perform(conn, &connected, dophase_done); result = pop3_perform(conn, &connected, dophase_done);
if(CURLE_OK == result) { if(!result) {
if(!*dophase_done) if(!*dophase_done)
/* The DO phase has not completed yet */ /* The DO phase has not completed yet */
return CURLE_OK; return CURLE_OK;
@ -1654,7 +1657,7 @@ static CURLcode pop3_setup_connection(struct connectdata * conn)
struct SessionHandle *data = conn->data; struct SessionHandle *data = conn->data;
if(conn->bits.httpproxy && !data->set.tunnel_thru_httpproxy) { if(conn->bits.httpproxy && !data->set.tunnel_thru_httpproxy) {
/* Unless we have asked to tunnel pop3 operations through the proxy, we /* Unless we have asked to tunnel POP3 operations through the proxy, we
switch and use HTTP operations only */ switch and use HTTP operations only */
#ifndef CURL_DISABLE_HTTP #ifndef CURL_DISABLE_HTTP
if(conn->handler == &Curl_handler_pop3) if(conn->handler == &Curl_handler_pop3)

View File

@ -388,6 +388,7 @@ static CURLcode smtp_state_upgrade_tls(struct connectdata *conn)
struct smtp_conn *smtpc = &conn->proto.smtpc; struct smtp_conn *smtpc = &conn->proto.smtpc;
CURLcode result; CURLcode result;
/* Start the SSL connection */
result = Curl_ssl_connect_nonblocking(conn, FIRSTSOCKET, &smtpc->ssldone); result = Curl_ssl_connect_nonblocking(conn, FIRSTSOCKET, &smtpc->ssldone);
if(!result) { if(!result) {
@ -1332,19 +1333,21 @@ static CURLcode smtp_connect(struct connectdata *conn, bool *done)
sessionhandle, deal with it */ sessionhandle, deal with it */
Curl_reset_reqproto(conn); Curl_reset_reqproto(conn);
/* Initialise the SMTP layer */
result = smtp_init(conn); result = smtp_init(conn);
if(CURLE_OK != result) if(result)
return result; return result;
/* We always support persistent connections on smtp */ /* We always support persistent connections in SMTP */
conn->bits.close = FALSE; conn->bits.close = FALSE;
pp->response_time = RESP_TIMEOUT; /* set default response time-out */ /* Set the default response time-out */
pp->response_time = RESP_TIMEOUT;
pp->statemach_act = smtp_statemach_act; pp->statemach_act = smtp_statemach_act;
pp->endofresp = smtp_endofresp; pp->endofresp = smtp_endofresp;
pp->conn = conn; pp->conn = conn;
/* Initialise the response reader stuff */ /* Initialise the pingpong layer */
Curl_pp_init(pp); Curl_pp_init(pp);
/* Calculate the path if necessary */ /* Calculate the path if necessary */
@ -1389,9 +1392,9 @@ static CURLcode smtp_done(struct connectdata *conn, CURLcode status,
if(!smtp) if(!smtp)
/* When the easy handle is removed from the multi while libcurl is still /* When the easy handle is removed from the multi while libcurl is still
* trying to resolve the host name, it seems that the smtp struct is not * trying to resolve the host name, it seems that the SMTP struct is not
* yet initialized, but the removal action calls Curl_done() which calls * yet initialized, but the removal action calls Curl_done() which calls
* this function. So we simply return success if no smtp pointer is set. * this function. So we simply return success if no SMTP pointer is set.
*/ */
return CURLE_OK; return CURLE_OK;
@ -1626,7 +1629,7 @@ static CURLcode smtp_regular_transfer(struct connectdata *conn,
result = smtp_perform(conn, &connected, dophase_done); result = smtp_perform(conn, &connected, dophase_done);
if(CURLE_OK == result) { if(!result) {
if(!*dophase_done) if(!*dophase_done)
/* The DO phase has not completed yet */ /* The DO phase has not completed yet */
return CURLE_OK; return CURLE_OK;
@ -1642,7 +1645,7 @@ static CURLcode smtp_setup_connection(struct connectdata *conn)
struct SessionHandle *data = conn->data; struct SessionHandle *data = conn->data;
if(conn->bits.httpproxy && !data->set.tunnel_thru_httpproxy) { if(conn->bits.httpproxy && !data->set.tunnel_thru_httpproxy) {
/* Unless we have asked to tunnel smtp operations through the proxy, we /* Unless we have asked to tunnel SMTP operations through the proxy, we
switch and use HTTP operations only */ switch and use HTTP operations only */
#ifndef CURL_DISABLE_HTTP #ifndef CURL_DISABLE_HTTP
if(conn->handler == &Curl_handler_smtp) if(conn->handler == &Curl_handler_smtp)