summaryrefslogtreecommitdiff
path: root/lib/pop3.c
diff options
context:
space:
mode:
authorDan Fandrich <dan@coneharvesters.com>2011-03-17 16:59:30 -0700
committerDan Fandrich <dan@coneharvesters.com>2011-03-17 16:59:30 -0700
commitef1c18b952de0763037b7c940cc6960bbf990912 (patch)
treeffa970c9b44bdf94c3480529c52b50ad2d60137c /lib/pop3.c
parent409867e62bf1b12e0fa0d39007256b5807a60cea (diff)
downloadcurl-ef1c18b952de0763037b7c940cc6960bbf990912.tar.gz
Added support for LISTing a single POP3 message
Added tests for a number of POP3 LIST operations, including one that shows a curl problem when listing no messages, so is disabled.
Diffstat (limited to 'lib/pop3.c')
-rw-r--r--lib/pop3.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/lib/pop3.c b/lib/pop3.c
index 65169cff5..e48c9b4f8 100644
--- a/lib/pop3.c
+++ b/lib/pop3.c
@@ -436,6 +436,24 @@ static CURLcode pop3_state_list_resp(struct connectdata *conn,
return result;
}
+/* for LIST response with a given message */
+static CURLcode pop3_state_list_single_resp(struct connectdata *conn,
+ int pop3code,
+ pop3state instate)
+{
+ CURLcode result = CURLE_OK;
+ struct SessionHandle *data = conn->data;
+ (void)instate; /* no use for this yet */
+
+ if(pop3code != 'O') {
+ failf(data, "Invalid message. %c", pop3code);
+ result = CURLE_REMOTE_FILE_NOT_FOUND;
+ }
+
+ state(conn, POP3_STOP);
+ return result;
+}
+
/* start the DO phase for RETR */
static CURLcode pop3_retr(struct connectdata *conn)
{
@@ -460,7 +478,10 @@ static CURLcode pop3_list(struct connectdata *conn)
if(result)
return result;
- state(conn, POP3_LIST);
+ if (strlen(pop3c->mailbox))
+ state(conn, POP3_LIST_SINGLE);
+ else
+ state(conn, POP3_LIST);
return result;
}
@@ -523,6 +544,10 @@ static CURLcode pop3_statemach_act(struct connectdata *conn)
result = pop3_state_list_resp(conn, pop3code, pop3c->state);
break;
+ case POP3_LIST_SINGLE:
+ result = pop3_state_list_single_resp(conn, pop3code, pop3c->state);
+ break;
+
case POP3_QUIT:
/* fallthrough, just stop! */
default:
@@ -747,7 +772,7 @@ CURLcode pop3_perform(struct connectdata *conn,
/* If mailbox is empty, then assume user wants listing for mail IDs,
* otherwise, attempt to retrieve the mail-id stored in mailbox
*/
- if (strlen(pop3c->mailbox))
+ if (strlen(pop3c->mailbox) && !conn->data->set.ftp_list_only)
result = pop3_retr(conn);
else
result = pop3_list(conn);