aboutsummaryrefslogtreecommitdiff
path: root/lib/smtp.c
diff options
context:
space:
mode:
authorSteve Holme <steve_holme@hotmail.com>2013-02-11 23:13:50 +0000
committerSteve Holme <steve_holme@hotmail.com>2013-02-11 23:13:50 +0000
commit586f5d36147478d58ea6204bfe8368364663d926 (patch)
tree3d7d4a80f03fbbef43042a19cb727644c781e4bc /lib/smtp.c
parentde492b31c5403c238e6b4a44a1f2ee1bff7fa921 (diff)
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.
Diffstat (limited to 'lib/smtp.c')
-rw-r--r--lib/smtp.c72
1 files changed, 36 insertions, 36 deletions
diff --git a/lib/smtp.c b/lib/smtp.c
index 3fed5c2ea..3c82a4f19 100644
--- a/lib/smtp.c
+++ b/lib/smtp.c
@@ -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()