From e2201dc849e7d5ba3104021559630030f6a8eec0 Mon Sep 17 00:00:00 2001 From: Steve Holme Date: Sat, 23 Feb 2013 16:06:54 +0000 Subject: [PATCH] pop3: Introduced a custom POP3 structure for per-request data Created a new POP3 structure and changed the type of the pop3 proto variable in connectdata from FTP* to POP*. --- lib/pop3.c | 18 +++++++++--------- lib/pop3.h | 13 +++++++++++++ lib/urldata.h | 2 +- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/lib/pop3.c b/lib/pop3.c index cba4cbd2e..08b8a8709 100644 --- a/lib/pop3.c +++ b/lib/pop3.c @@ -434,7 +434,7 @@ static CURLcode pop3_state_upgrade_tls(struct connectdata *conn) static CURLcode pop3_state_user(struct connectdata *conn) { CURLcode result = CURLE_OK; - struct FTP *pop3 = conn->data->state.proto.pop3; + struct POP3 *pop3 = conn->data->state.proto.pop3; /* Check we have a username and password to authenticate with and end the connect phase if we don't */ @@ -1011,7 +1011,7 @@ static CURLcode pop3_state_user_resp(struct connectdata *conn, int pop3code, { CURLcode result = CURLE_OK; struct SessionHandle *data = conn->data; - struct FTP *pop3 = data->state.proto.pop3; + struct POP3 *pop3 = data->state.proto.pop3; (void)instate; /* no use for this yet */ @@ -1064,7 +1064,7 @@ static CURLcode pop3_command(struct connectdata *conn) if(pop3c->mailbox[0] != '\0') { /* Message specific LIST so skip the BODY transfer */ - struct FTP *pop3 = conn->data->state.proto.pop3; + struct POP3 *pop3 = conn->data->state.proto.pop3; pop3->transfer = FTPTRANSFER_INFO; } } @@ -1096,7 +1096,7 @@ static CURLcode pop3_state_command_resp(struct connectdata *conn, { CURLcode result = CURLE_OK; struct SessionHandle *data = conn->data; - struct FTP *pop3 = data->state.proto.pop3; + struct POP3 *pop3 = data->state.proto.pop3; struct pop3_conn *pop3c = &conn->proto.pop3c; struct pingpong *pp = &pop3c->pp; @@ -1289,10 +1289,10 @@ static CURLcode pop3_block_statemach(struct connectdata *conn) static CURLcode pop3_init(struct connectdata *conn) { struct SessionHandle *data = conn->data; - struct FTP *pop3 = data->state.proto.pop3; + struct POP3 *pop3 = data->state.proto.pop3; if(!pop3) { - pop3 = data->state.proto.pop3 = calloc(sizeof(struct FTP), 1); + pop3 = data->state.proto.pop3 = calloc(sizeof(struct POP3), 1); if(!pop3) return CURLE_OUT_OF_MEMORY; } @@ -1379,7 +1379,7 @@ static CURLcode pop3_done(struct connectdata *conn, CURLcode status, { CURLcode result = CURLE_OK; struct SessionHandle *data = conn->data; - struct FTP *pop3 = data->state.proto.pop3; + struct POP3 *pop3 = data->state.proto.pop3; struct pop3_conn *pop3c = &conn->proto.pop3c; (void)premature; @@ -1424,7 +1424,7 @@ static CURLcode pop3_perform(struct connectdata *conn, bool *connected, if(conn->data->set.opt_no_body) { /* Requested no body means no transfer */ - struct FTP *pop3 = conn->data->state.proto.pop3; + struct POP3 *pop3 = conn->data->state.proto.pop3; pop3->transfer = FTPTRANSFER_INFO; } @@ -1577,7 +1577,7 @@ static CURLcode pop3_parse_custom_request(struct connectdata *conn) /* Call this when the DO phase has completed */ static CURLcode pop3_dophase_done(struct connectdata *conn, bool connected) { - struct FTP *pop3 = conn->data->state.proto.pop3; + struct POP3 *pop3 = conn->data->state.proto.pop3; (void)connected; diff --git a/lib/pop3.h b/lib/pop3.h index 6ef408e49..ca9e84b1b 100644 --- a/lib/pop3.h +++ b/lib/pop3.h @@ -22,6 +22,8 @@ * ***************************************************************************/ +#include "pingpong.h" + /**************************************************************************** * POP3 unique setup ***************************************************************************/ @@ -50,6 +52,17 @@ typedef enum { POP3_LAST /* never used */ } pop3state; +/* This POP3 struct is used in the SessionHandle. All POP3 data that is + connection-oriented must be in pop3_conn to properly deal with the fact that + perhaps the SessionHandle is changed between the times the connection is + used. */ +struct POP3 { + curl_off_t *bytecountp; + char *user; /* User name string */ + char *passwd; /* Password string */ + curl_ftptransfer transfer; +}; + /* pop3_conn is used for struct connection-oriented data in the connectdata struct */ struct pop3_conn { diff --git a/lib/urldata.h b/lib/urldata.h index 3e668badd..5c4458f71 100644 --- a/lib/urldata.h +++ b/lib/urldata.h @@ -1293,7 +1293,7 @@ struct UrlState { void *generic; struct SSHPROTO *ssh; struct IMAP *imap; - struct FTP *pop3; + struct POP3 *pop3; struct FTP *smtp; } proto; /* current user of this SessionHandle instance, or NULL */