protocol handler: added flags field
The protocol handler struct got a 'flags' field for special information and characteristics of the given protocol. This now enables us to move away central protocol information such as CLOSEACTION and DUALCHANNEL from single defines in a central place, out to each protocol's definition. It also made us stop abusing the protocol field for other info than the protocol, and we could start cleaning up other protocol-specific things by adding flags bits to set in the handler struct. The "protocol" field connectdata struct was removed as well and the code now refers directly to the conn->handler->protocol field instead. To make things work properly, the code now always store a conn->given pointer that points out the original handler struct so that the code can learn details from the original protocol even if conn->handler is modified along the way - for example when switching to go over a HTTP proxy.
This commit is contained in:
21
lib/imap.c
21
lib/imap.c
@@ -128,7 +128,8 @@ const struct Curl_handler Curl_handler_imap = {
|
||||
ZERO_NULL, /* perform_getsock */
|
||||
imap_disconnect, /* disconnect */
|
||||
PORT_IMAP, /* defport */
|
||||
PROT_IMAP /* protocol */
|
||||
PROT_IMAP, /* protocol */
|
||||
PROTOPT_CLOSEACTION /* flags */
|
||||
};
|
||||
|
||||
|
||||
@@ -151,7 +152,8 @@ const struct Curl_handler Curl_handler_imaps = {
|
||||
ZERO_NULL, /* perform_getsock */
|
||||
imap_disconnect, /* disconnect */
|
||||
PORT_IMAPS, /* defport */
|
||||
PROT_IMAP | PROT_IMAPS | PROT_SSL /* protocol */
|
||||
PROT_IMAP | PROT_IMAPS, /* protocol */
|
||||
PROTOPT_CLOSEACTION | PROTOPT_SSL /* flags */
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -174,7 +176,8 @@ static const struct Curl_handler Curl_handler_imap_proxy = {
|
||||
ZERO_NULL, /* perform_getsock */
|
||||
ZERO_NULL, /* disconnect */
|
||||
PORT_IMAP, /* defport */
|
||||
PROT_HTTP /* protocol */
|
||||
PROT_HTTP, /* protocol */
|
||||
PROTOPT_NONE /* flags */
|
||||
};
|
||||
|
||||
|
||||
@@ -197,7 +200,8 @@ static const struct Curl_handler Curl_handler_imaps_proxy = {
|
||||
ZERO_NULL, /* perform_getsock */
|
||||
ZERO_NULL, /* disconnect */
|
||||
PORT_IMAPS, /* defport */
|
||||
PROT_HTTP /* protocol */
|
||||
PROT_HTTP, /* protocol */
|
||||
PROTOPT_NONE /* flags */
|
||||
};
|
||||
#endif
|
||||
#endif
|
||||
@@ -351,7 +355,7 @@ static CURLcode imap_state_starttls_resp(struct connectdata *conn,
|
||||
else {
|
||||
result = Curl_ssl_connect(conn, FIRSTSOCKET);
|
||||
if(CURLE_OK == result) {
|
||||
conn->protocol |= PROT_IMAPS;
|
||||
conn->handler = &Curl_handler_imaps;
|
||||
result = imap_state_login(conn);
|
||||
}
|
||||
}
|
||||
@@ -368,7 +372,7 @@ static CURLcode imap_state_upgrade_tls(struct connectdata *conn)
|
||||
result = Curl_ssl_connect_nonblocking(conn, FIRSTSOCKET, &imapc->ssldone);
|
||||
|
||||
if(imapc->ssldone) {
|
||||
conn->protocol |= PROT_IMAPS;
|
||||
conn->handler = &Curl_handler_imaps;
|
||||
result = imap_state_login(conn);
|
||||
state(conn, IMAP_STOP);
|
||||
}
|
||||
@@ -617,7 +621,7 @@ static CURLcode imap_multi_statemach(struct connectdata *conn,
|
||||
struct imap_conn *imapc = &conn->proto.imapc;
|
||||
CURLcode result;
|
||||
|
||||
if((conn->protocol & PROT_IMAPS) && !imapc->ssldone) {
|
||||
if((conn->handler->protocol & PROT_IMAPS) && !imapc->ssldone) {
|
||||
result = Curl_ssl_connect_nonblocking(conn, FIRSTSOCKET, &imapc->ssldone);
|
||||
}
|
||||
else {
|
||||
@@ -734,7 +738,8 @@ static CURLcode imap_connect(struct connectdata *conn,
|
||||
}
|
||||
#endif /* !CURL_DISABLE_HTTP && !CURL_DISABLE_PROXY */
|
||||
|
||||
if((conn->protocol & PROT_IMAPS) && data->state.used_interface != Curl_if_multi) {
|
||||
if((conn->handler->protocol & PROT_IMAPS) &&
|
||||
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 */
|
||||
|
Reference in New Issue
Block a user