]> granicus.if.org Git - curl/commitdiff
protocol handler cleanup: SSL awareness
authorDaniel Stenberg <daniel@haxx.se>
Tue, 15 Mar 2011 09:02:05 +0000 (10:02 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 15 Mar 2011 09:02:05 +0000 (10:02 +0100)
As a follow-up to commit 8831000bc0: don't assume that the SSL powered
protocol alternatives are available.

lib/imap.c
lib/pop3.c
lib/smtp.c

index 6ba66577032b2ca1bc2f42825098b2507eb572f5..c0406ea42c78e1afa54b61c9cda1b12b9fd6e587 100644 (file)
@@ -334,6 +334,15 @@ static CURLcode imap_state_login(struct connectdata *conn)
   return CURLE_OK;
 }
 
+#ifdef USE_SSL
+static void imap_to_imaps(struct connectdata *conn)
+{
+  conn->handler = &Curl_handler_imaps;
+}
+#else
+#define imap_to_imaps(x)
+#endif
+
 /* for STARTTLS responses */
 static CURLcode imap_state_starttls_resp(struct connectdata *conn,
                                          int imapcode,
@@ -355,7 +364,7 @@ static CURLcode imap_state_starttls_resp(struct connectdata *conn,
     else {
       result = Curl_ssl_connect(conn, FIRSTSOCKET);
       if(CURLE_OK == result) {
-        conn->handler = &Curl_handler_imaps;
+        imap_to_imaps(conn);
         result = imap_state_login(conn);
       }
     }
@@ -372,7 +381,7 @@ static CURLcode imap_state_upgrade_tls(struct connectdata *conn)
   result = Curl_ssl_connect_nonblocking(conn, FIRSTSOCKET, &imapc->ssldone);
 
   if(imapc->ssldone) {
-    conn->handler = &Curl_handler_imaps;
+    imap_to_imaps(conn);
     result = imap_state_login(conn);
     state(conn, IMAP_STOP);
   }
index a5447e4f3db96e1dca3217dc75db2c21246417a1..d6e63035be351a1d5c35a728fbdb51d819a4a104 100644 (file)
@@ -275,6 +275,15 @@ static int pop3_getsock(struct connectdata *conn,
   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)
+#endif
+
 /* for STARTTLS responses */
 static CURLcode pop3_state_starttls_resp(struct connectdata *conn,
                                          int pop3code,
@@ -292,7 +301,7 @@ static CURLcode pop3_state_starttls_resp(struct connectdata *conn,
     /* Curl_ssl_connect is BLOCKING */
     result = Curl_ssl_connect(conn, FIRSTSOCKET);
     if(CURLE_OK == result) {
-      conn->handler = &Curl_handler_pop3s;
+      pop3_to_pop3s(conn);
       result = pop3_state_user(conn);
     }
   }
index ff0d288c7d63001857ec8f4ab45fdc955ef0bbce..71a9c6e8a8962da0233339249a0183850018134f 100644 (file)
@@ -454,6 +454,15 @@ static int smtp_getsock(struct connectdata *conn,
   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)
+#endif
+
 /* for STARTTLS responses */
 static CURLcode smtp_state_starttls_resp(struct connectdata *conn,
                                          int smtpcode,
@@ -475,7 +484,7 @@ static CURLcode smtp_state_starttls_resp(struct connectdata *conn,
     /* Curl_ssl_connect is BLOCKING */
     result = Curl_ssl_connect(conn, FIRSTSOCKET);
     if(CURLE_OK == result) {
-      conn->handler = &Curl_handler_smtps;
+      smtp_to_smtps(conn);
       result = smtp_state_ehlo(conn);
     }
   }