pop3: Introduced a custom POP3 structure for per-request data
authorSteve Holme <steve_holme@hotmail.com>
Sat, 23 Feb 2013 16:06:54 +0000 (16:06 +0000)
committerSteve Holme <steve_holme@hotmail.com>
Sat, 23 Feb 2013 16:06:54 +0000 (16:06 +0000)
Created a new POP3 structure and changed the type of the pop3 proto
variable in connectdata from FTP* to POP*.

lib/pop3.c
lib/pop3.h
lib/urldata.h

index cba4cbd..08b8a87 100644 (file)
@@ -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;
 
index 6ef408e..ca9e84b 100644 (file)
@@ -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 {
index 3e668ba..5c4458f 100644 (file)
@@ -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 */