]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
imap: remove duplicated function
authorDaniel Stenberg <daniel@haxx.se>
Thu, 31 Mar 2016 13:12:22 +0000 (15:12 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 31 Mar 2016 13:12:22 +0000 (15:12 +0200)
The list and search response functions were identical! Merged into one
now. Detected by PVS Studio.

Reported-by: Alexis La Goutte
lib/imap.c

index 236a8c64f8724bbb37e84a88608dc48117b06b1b..934532de350ef00bd4c1296caa5bcf46c14413cc 100644 (file)
@@ -1020,9 +1020,10 @@ static CURLcode imap_state_login_resp(struct connectdata *conn,
   return result;
 }
 
-/* For LIST responses */
-static CURLcode imap_state_list_resp(struct connectdata *conn, int imapcode,
-                                     imapstate instate)
+/* For LIST and SEARCH responses */
+static CURLcode imap_state_listsearch_resp(struct connectdata *conn,
+                                           int imapcode,
+                                           imapstate instate)
 {
   CURLcode result = CURLE_OK;
   char *line = conn->data->state.buffer;
@@ -1249,31 +1250,6 @@ static CURLcode imap_state_append_final_resp(struct connectdata *conn,
   return result;
 }
 
-/* For SEARCH responses */
-static CURLcode imap_state_search_resp(struct connectdata *conn, int imapcode,
-                                       imapstate instate)
-{
-  CURLcode result = CURLE_OK;
-  char *line = conn->data->state.buffer;
-  size_t len = strlen(line);
-
-  (void)instate; /* No use for this yet */
-
-  if(imapcode == '*') {
-    /* Temporarily add the LF character back and send as body to the client */
-    line[len] = '\n';
-    result = Curl_client_write(conn, CLIENTWRITE_BODY, line, len + 1);
-    line[len] = '\0';
-  }
-  else if(imapcode != 'O')
-    result = CURLE_QUOTE_ERROR; /* TODO: Fix error code */
-  else
-    /* End of DO phase */
-    state(conn, IMAP_STOP);
-
-  return result;
-}
-
 static CURLcode imap_statemach_act(struct connectdata *conn)
 {
   CURLcode result = CURLE_OK;
@@ -1327,7 +1303,7 @@ static CURLcode imap_statemach_act(struct connectdata *conn)
       break;
 
     case IMAP_LIST:
-      result = imap_state_list_resp(conn, imapcode, imapc->state);
+      result = imap_state_listsearch_resp(conn, imapcode, imapc->state);
       break;
 
     case IMAP_SELECT:
@@ -1351,7 +1327,7 @@ static CURLcode imap_statemach_act(struct connectdata *conn)
       break;
 
     case IMAP_SEARCH:
-      result = imap_state_search_resp(conn, imapcode, imapc->state);
+      result = imap_state_listsearch_resp(conn, imapcode, imapc->state);
       break;
 
     case IMAP_LOGOUT: