Commit d09d08dc authored by Steve Holme's avatar Steve Holme
Browse files

email: Tidy up before additional IMAP work

Replaced two explicit comparisons of CURLE_OK with boolean alternatives.

General tidy up of comments.
parent 0c6fa0dd
Loading
Loading
Loading
Loading
+12 −8
Original line number Diff line number Diff line
@@ -505,6 +505,7 @@ static CURLcode imap_state_upgrade_tls(struct connectdata *conn)
  struct imap_conn *imapc = &conn->proto.imapc;
  CURLcode result;

  /* Start the SSL connection */
  result = Curl_ssl_connect_nonblocking(conn, FIRSTSOCKET, &imapc->ssldone);

  if(!result) {
@@ -1415,19 +1416,22 @@ static CURLcode imap_connect(struct connectdata *conn, bool *done)
     sessionhandle, deal with it */
  Curl_reset_reqproto(conn);

  /* Initialise the IMAP layer */
  result = imap_init(conn);
  if(CURLE_OK != result)
  if(result)
    return result;

  /* We always support persistent connections on imap */
  /* We always support persistent connections in IMAP */
  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->endofresp = imap_endofresp;
  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 */
  state(conn, IMAP_SERVERGREET);
@@ -1460,9 +1464,9 @@ static CURLcode imap_done(struct connectdata *conn, CURLcode status,

  if(!imap)
    /* 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
     * 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;

@@ -1687,7 +1691,7 @@ static CURLcode imap_regular_transfer(struct connectdata *conn,

  result = imap_perform(conn, &connected, dophase_done);

  if(CURLE_OK == result) {
  if(!result) {
    if(!*dophase_done)
      /* The DO phase has not completed yet */
      return CURLE_OK;
@@ -1703,7 +1707,7 @@ static CURLcode imap_setup_connection(struct connectdata * conn)
  struct SessionHandle *data = conn->data;

  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 */
#ifndef CURL_DISABLE_HTTP
    if(conn->handler == &Curl_handler_imap)
+12 −9
Original line number Diff line number Diff line
@@ -415,6 +415,7 @@ static CURLcode pop3_state_upgrade_tls(struct connectdata *conn)
  struct pop3_conn *pop3c = &conn->proto.pop3c;
  CURLcode result;

  /* Start the SSL connection */
  result = Curl_ssl_connect_nonblocking(conn, FIRSTSOCKET, &pop3c->ssldone);

  if(!result) {
@@ -1340,27 +1341,29 @@ static CURLcode pop3_connect(struct connectdata *conn, bool *done)
     sessionhandle, deal with it */
  Curl_reset_reqproto(conn);

  /* Initialise the POP3 layer */
  result = pop3_init(conn);
  if(CURLE_OK != result)
  if(result)
    return result;

  /* We always support persistent connections on pop3 */
  /* We always support persistent connections in POP3 */
  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->endofresp = pop3_endofresp;
  pp->conn = conn;

  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 */
    result = Curl_ssl_connect(conn, FIRSTSOCKET);
    if(result)
      return result;
  }

  /* Initialise the response reader stuff */
  /* Initialise the pingpong layer */
  Curl_pp_init(pp);

  /* Start off waiting for the server greeting response */
@@ -1392,9 +1395,9 @@ static CURLcode pop3_done(struct connectdata *conn, CURLcode status,

  if(!pop3)
    /* 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
     * 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;

@@ -1638,7 +1641,7 @@ static CURLcode pop3_regular_transfer(struct connectdata *conn,

  result = pop3_perform(conn, &connected, dophase_done);

  if(CURLE_OK == result) {
  if(!result) {
    if(!*dophase_done)
      /* The DO phase has not completed yet */
      return CURLE_OK;
@@ -1654,7 +1657,7 @@ static CURLcode pop3_setup_connection(struct connectdata * conn)
  struct SessionHandle *data = conn->data;

  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 */
#ifndef CURL_DISABLE_HTTP
    if(conn->handler == &Curl_handler_pop3)
+11 −8
Original line number Diff line number Diff line
@@ -388,6 +388,7 @@ static CURLcode smtp_state_upgrade_tls(struct connectdata *conn)
  struct smtp_conn *smtpc = &conn->proto.smtpc;
  CURLcode result;

  /* Start the SSL connection */
  result = Curl_ssl_connect_nonblocking(conn, FIRSTSOCKET, &smtpc->ssldone);

  if(!result) {
@@ -1332,19 +1333,21 @@ static CURLcode smtp_connect(struct connectdata *conn, bool *done)
     sessionhandle, deal with it */
  Curl_reset_reqproto(conn);

  /* Initialise the SMTP layer */
  result = smtp_init(conn);
  if(CURLE_OK != result)
  if(result)
    return result;

  /* We always support persistent connections on smtp */
  /* We always support persistent connections in SMTP */
  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->endofresp = smtp_endofresp;
  pp->conn = conn;

  /* Initialise the response reader stuff */
  /* Initialise the pingpong layer */
  Curl_pp_init(pp);

  /* Calculate the path if necessary */
@@ -1389,9 +1392,9 @@ static CURLcode smtp_done(struct connectdata *conn, CURLcode status,

  if(!smtp)
    /* 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
     * 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;

@@ -1626,7 +1629,7 @@ static CURLcode smtp_regular_transfer(struct connectdata *conn,

  result = smtp_perform(conn, &connected, dophase_done);

  if(CURLE_OK == result) {
  if(!result) {
    if(!*dophase_done)
      /* The DO phase has not completed yet */
      return CURLE_OK;
@@ -1642,7 +1645,7 @@ static CURLcode smtp_setup_connection(struct connectdata *conn)
  struct SessionHandle *data = conn->data;

  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 */
#ifndef CURL_DISABLE_HTTP
    if(conn->handler == &Curl_handler_smtp)