SSL: check for SSL, not specific protocols
authorDaniel Stenberg <daniel@haxx.se>
Thu, 5 May 2011 13:49:43 +0000 (15:49 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 5 May 2011 13:49:43 +0000 (15:49 +0200)
Code cleanup to check less for protocols and more for the specific
relevant feature. Like if SSL is required.

lib/ftp.c
lib/http.c
lib/imap.c
lib/ldap.c
lib/pop3.c
lib/smtp.c

index 203afe6ba98177e12078d7efb62a06976352a7c4..ec8d9f11d4fea4de9c17021969a59eef83cd44ad 100644 (file)
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -2946,10 +2946,8 @@ static CURLcode ftp_connect(struct connectdata *conn,
       return result;
   }
 
-  if(conn->handler->protocol & CURLPROTO_FTPS) {
+  if(conn->handler->flags & PROTOPT_SSL) {
     /* BLOCKING */
-    /* FTPS is simply ftp with SSL for the control channel */
-    /* now, perform the SSL initialization for this socket */
     result = Curl_ssl_connect(conn, FIRSTSOCKET);
     if(result)
       return result;
index f6b6a3e14044eda7a6f78258be5cfb994444b277..5759a7ff234d68d82a484032eab4fc95c80a8cd8 100644 (file)
@@ -1013,7 +1013,7 @@ CURLcode Curl_add_buffer_send(Curl_send_buffer *in,
     return res;
   }
 
-  if(conn->handler->protocol & CURLPROTO_HTTPS) {
+  if(conn->handler->flags & PROTOPT_SSL) {
     /* We never send more than CURL_MAX_WRITE_SIZE bytes in one single chunk
        when we speak HTTPS, as if only a fraction of it is sent now, this data
        needs to fit into the normal read-callback buffer later on and that
@@ -1292,7 +1292,7 @@ CURLcode Curl_http_connect(struct connectdata *conn, bool *done)
   }
 #endif /* CURL_DISABLE_PROXY */
 
-  if(conn->given->protocol & CURLPROTO_HTTPS) {
+  if(conn->given->flags & PROTOPT_SSL) {
     /* perform SSL initialization */
     if(data->state.used_interface == Curl_if_multi) {
       result = https_connecting(conn, done);
@@ -1331,7 +1331,7 @@ static int http_getsock_do(struct connectdata *conn,
 static CURLcode https_connecting(struct connectdata *conn, bool *done)
 {
   CURLcode result;
-  DEBUGASSERT((conn) && (conn->handler->protocol & CURLPROTO_HTTPS));
+  DEBUGASSERT((conn) && (conn->handler->flags & PROTOPT_SSL));
 
   /* perform SSL initialization for this socket */
   result = Curl_ssl_connect_nonblocking(conn, FIRSTSOCKET, done);
@@ -1349,7 +1349,7 @@ static int https_getsock(struct connectdata *conn,
                          curl_socket_t *socks,
                          int numsocks)
 {
-  if(conn->handler->protocol & CURLPROTO_HTTPS) {
+  if(conn->handler->flags & PROTOPT_SSL) {
     struct ssl_connect_data *connssl = &conn->ssl[FIRSTSOCKET];
 
     if(!numsocks)
index 06135a309255d1b40f6a80be42314dfd32145e05..a01da3eece7203d436923ae03d2b10462afc802e 100644 (file)
@@ -629,12 +629,10 @@ static CURLcode imap_multi_statemach(struct connectdata *conn,
   struct imap_conn *imapc = &conn->proto.imapc;
   CURLcode result;
 
-  if((conn->handler->protocol & CURLPROTO_IMAPS) && !imapc->ssldone) {
+  if((conn->handler->flags & PROTOPT_SSL) && !imapc->ssldone)
     result = Curl_ssl_connect_nonblocking(conn, FIRSTSOCKET, &imapc->ssldone);
-  }
-  else {
+  else
     result = Curl_pp_multi_statemach(&imapc->pp);
-  }
 
   *done = (bool)(imapc->state == IMAP_STOP);
 
@@ -744,11 +742,9 @@ static CURLcode imap_connect(struct connectdata *conn,
       return result;
   }
 
-  if((conn->handler->protocol & CURLPROTO_IMAPS) &&
+  if((conn->handler->flags & PROTOPT_SSL) &&
      data->state.used_interface != Curl_if_multi) {
     /* BLOCKING */
-    /* IMAPS is simply imap with SSL for the control channel */
-    /* now, perform the SSL initialization for this socket */
     result = Curl_ssl_connect(conn, FIRSTSOCKET);
     if(result)
       return result;
index 69667fdf87a4af716ed50a8e8321369a9ff35d6f..6733ef46b38b7e74f52b8f995594eb72902344de 100644 (file)
@@ -206,7 +206,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
   }
 
   /* Get the URL scheme ( either ldap or ldaps ) */
-  if(conn->given->protocol & CURLPROTO_LDAPS)
+  if(conn->given->flags & PROTOPT_SSL)
     ldap_ssl = 1;
   infof(data, "LDAP local: trying to establish %s connection\n",
           ldap_ssl ? "encrypted" : "cleartext");
index 6d5afa876281855d8b1a0886edc07aa0c0ea0e21..f53661285775a49f8c50ca7ada860a6746f4f732 100644 (file)
@@ -676,10 +676,8 @@ static CURLcode pop3_connect(struct connectdata *conn,
       return result;
   }
 
-  if(conn->handler->protocol & CURLPROTO_POP3S) {
+  if(conn->handler->flags & PROTOPT_SSL) {
     /* BLOCKING */
-    /* POP3S is simply pop3 with SSL for the control channel */
-    /* now, perform the SSL initialization for this socket */
     result = Curl_ssl_connect(conn, FIRSTSOCKET);
     if(result)
       return result;
index 170c32dbb0f4c96cd572af7b8a0053928dbfd1a7..e0e4216d3ad322b539e3e7cb903b6e3c8d217db4 100644 (file)
@@ -1027,12 +1027,10 @@ static CURLcode smtp_multi_statemach(struct connectdata *conn,
   struct smtp_conn *smtpc = &conn->proto.smtpc;
   CURLcode result;
 
-  if((conn->handler->protocol & CURLPROTO_SMTPS) && !smtpc->ssldone) {
+  if((conn->handler->flags & PROTOPT_SSL) && !smtpc->ssldone)
     result = Curl_ssl_connect_nonblocking(conn, FIRSTSOCKET, &smtpc->ssldone);
-  }
-  else {
+  else
     result = Curl_pp_multi_statemach(&smtpc->pp);
-  }
 
   *done = (bool)(smtpc->state == SMTP_STOP);