]> granicus.if.org Git - curl/commitdiff
pop3: Small code tidy up following authentication work so far
authorSteve Holme <steve_holme@hotmail.com>
Mon, 28 May 2012 19:21:52 +0000 (20:21 +0100)
committerSteve Holme <steve_holme@hotmail.com>
Mon, 28 May 2012 19:21:52 +0000 (20:21 +0100)
Changed the order of the state machine to match the order of actual
events.

Reworked some comments and function parameter positioning that I missed
the other day.

lib/pop3.c
lib/pop3.h

index 12d6040435a821f8ac2b7a5aed9fe66ec16668f4..a9898e2182d9c93cf1754814123787bfb2410848 100644 (file)
@@ -276,10 +276,10 @@ static void state(struct connectdata *conn, pop3state newstate)
   static const char * const names[]={
     "STOP",
     "SERVERGREET",
+    "STARTTLS",
     "AUTH",
     "USER",
     "PASS",
-    "STARTTLS",
     "COMMAND",
     "QUIT",
     /* LAST */
@@ -581,6 +581,10 @@ static CURLcode pop3_statemach_act(struct connectdata *conn)
       result = pop3_state_servergreet_resp(conn, pop3code, pop3c->state);
       break;
 
+    case POP3_STARTTLS:
+      result = pop3_state_starttls_resp(conn, pop3code, pop3c->state);
+      break;
+
     case POP3_AUTH:
       result = pop3_state_auth_resp(conn);
       break;
@@ -593,10 +597,6 @@ static CURLcode pop3_statemach_act(struct connectdata *conn)
       result = pop3_state_pass_resp(conn, pop3code, pop3c->state);
       break;
 
-    case POP3_STARTTLS:
-      result = pop3_state_starttls_resp(conn, pop3code, pop3c->state);
-      break;
-
     case POP3_COMMAND:
       result = pop3_state_command_resp(conn, pop3code, pop3c->state);
       break;
@@ -905,7 +905,6 @@ static CURLcode pop3_disconnect(struct connectdata *conn, bool dead_connection)
  * pop3_parse_url_path()
  *
  * Parse the URL path into separate path components.
- *
  */
 static CURLcode pop3_parse_url_path(struct connectdata *conn)
 {
@@ -983,9 +982,7 @@ static CURLcode pop3_regular_transfer(struct connectdata *conn,
   Curl_pgrsSetUploadSize(data, 0);
   Curl_pgrsSetDownloadSize(data, 0);
 
-  result = pop3_perform(conn,
-                        &connected,    /* have we connected after PASV/PORT */
-                        dophase_done); /* all commands in the DO-phase done? */
+  result = pop3_perform(conn, &connected, dophase_done);
 
   if(CURLE_OK == result) {
 
@@ -1035,13 +1032,9 @@ static CURLcode pop3_setup_connection(struct connectdata * conn)
   return CURLE_OK;
 }
 
-/*
- * This function scans the body after the end-of-body and writes everything
- * until the end is found.
- */
-CURLcode Curl_pop3_write(struct connectdata *conn,
-                         char *str,
-                         size_t nread)
+/* This function scans the body after the end-of-body and writes everything
+   until the end is found */
+CURLcode Curl_pop3_write(struct connectdata *conn, char *str, size_t nread)
 {
   /* This code could be made into a special function in the handler struct */
   CURLcode result = CURLE_OK;
@@ -1142,7 +1135,7 @@ CURLcode Curl_pop3_write(struct connectdata *conn,
     /* We have a full match so the transfer is done, however we must transfer
     the CRLF at the start of the EOB as this is considered to be part of the
     message as per RFC-1939, sect. 3 */
-    result = Curl_client_write(conn, CLIENTWRITE_BODY, (char*)POP3_EOB, 2);
+    result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)POP3_EOB, 2);
 
     k->keepon &= ~KEEP_RECV;
     pop3c->eob = 0;
index 01701e4d7bbf994ede20c37c77957ed64d80ec96..000284d62b3ee90b9d45ed440fc1d4fac00bf336 100644 (file)
@@ -29,10 +29,10 @@ typedef enum {
   POP3_STOP,         /* do nothing state, stops the state machine */
   POP3_SERVERGREET,  /* waiting for the initial greeting immediately after
                         a connect */
+  POP3_STARTTLS,
   POP3_AUTH,
   POP3_USER,
   POP3_PASS,
-  POP3_STARTTLS,
   POP3_COMMAND,
   POP3_QUIT,
   POP3_LAST          /* never used */