aboutsummaryrefslogtreecommitdiff
path: root/lib/imap.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/imap.c')
-rw-r--r--lib/imap.c71
1 files changed, 35 insertions, 36 deletions
diff --git a/lib/imap.c b/lib/imap.c
index 793596e25..9a5894755 100644
--- a/lib/imap.c
+++ b/lib/imap.c
@@ -204,6 +204,15 @@ static const struct Curl_handler Curl_handler_imaps_proxy = {
#endif
#endif
+#ifdef USE_SSL
+static void imap_to_imaps(struct connectdata *conn)
+{
+ conn->handler = &Curl_handler_imaps;
+}
+#else
+#define imap_to_imaps(x) Curl_nop_stmt
+#endif
+
/***********************************************************************
*
* imap_sendf()
@@ -493,6 +502,25 @@ static CURLcode imap_state_starttls(struct connectdata *conn)
return result;
}
+static CURLcode imap_state_upgrade_tls(struct connectdata *conn)
+{
+ struct imap_conn *imapc = &conn->proto.imapc;
+ CURLcode result;
+
+ result = Curl_ssl_connect_nonblocking(conn, FIRSTSOCKET, &imapc->ssldone);
+
+ if(!result) {
+ if(imapc->state != IMAP_UPGRADETLS)
+ state(conn, IMAP_UPGRADETLS);
+
+ if(imapc->ssldone) {
+ imap_to_imaps(conn);
+ result = imap_state_capability(conn);
+ }
+ }
+
+ return result;
+}
static CURLcode imap_state_login(struct connectdata *conn)
{
@@ -627,22 +655,6 @@ static CURLcode imap_authenticate(struct connectdata *conn)
return result;
}
-/* For the IMAP "protocol connect" and "doing" phases only */
-static int imap_getsock(struct connectdata *conn, curl_socket_t *socks,
- int numsocks)
-{
- return Curl_pp_getsock(&conn->proto.imapc.pp, socks, numsocks);
-}
-
-#ifdef USE_SSL
-static void imap_to_imaps(struct connectdata *conn)
-{
- conn->handler = &Curl_handler_imaps;
-}
-#else
-#define imap_to_imaps(x) Curl_nop_stmt
-#endif
-
/* For the initial server greeting */
static CURLcode imap_state_servergreet_resp(struct connectdata *conn,
int imapcode,
@@ -719,26 +731,6 @@ static CURLcode imap_state_starttls_resp(struct connectdata *conn,
return result;
}
-static CURLcode imap_state_upgrade_tls(struct connectdata *conn)
-{
- struct imap_conn *imapc = &conn->proto.imapc;
- CURLcode result;
-
- result = Curl_ssl_connect_nonblocking(conn, FIRSTSOCKET, &imapc->ssldone);
-
- if(!result) {
- if(imapc->state != IMAP_UPGRADETLS)
- state(conn, IMAP_UPGRADETLS);
-
- if(imapc->ssldone) {
- imap_to_imaps(conn);
- result = imap_state_capability(conn);
- }
- }
-
- return result;
-}
-
/* For AUTHENTICATE PLAIN (without initial response) responses */
static CURLcode imap_state_auth_plain_resp(struct connectdata *conn,
int imapcode,
@@ -1397,6 +1389,13 @@ static CURLcode imap_init(struct connectdata *conn)
return CURLE_OK;
}
+/* For the IMAP "protocol connect" and "doing" phases only */
+static int imap_getsock(struct connectdata *conn, curl_socket_t *socks,
+ int numsocks)
+{
+ return Curl_pp_getsock(&conn->proto.imapc.pp, socks, numsocks);
+}
+
/***********************************************************************
*
* imap_connect() should do everything that is to be considered a part of