pop3: Removed the need for the single message LIST command handler
Simplified the code to remove the need for a separate "LIST <msg id>" command handler and state machine and instead use the LIST command handler for both operations.
This commit is contained in:
Родитель
2da89708ec
Коммит
01690ed2bc
37
lib/pop3.c
37
lib/pop3.c
|
@ -447,26 +447,6 @@ 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;
|
||||
}
|
||||
|
||||
/* for the retr response */
|
||||
static CURLcode pop3_state_retr_resp(struct connectdata *conn,
|
||||
int pop3code,
|
||||
|
@ -518,17 +498,20 @@ static CURLcode pop3_list(struct connectdata *conn)
|
|||
CURLcode result = CURLE_OK;
|
||||
struct pop3_conn *pop3c = &conn->proto.pop3c;
|
||||
|
||||
if(pop3c->mailbox[0] != '\0')
|
||||
if(pop3c->mailbox[0] != '\0') {
|
||||
/* Message specific LIST means no transfer */
|
||||
struct FTP *pop3 = conn->data->state.proto.pop3;
|
||||
pop3->transfer = FTPTRANSFER_INFO;
|
||||
|
||||
result = Curl_pp_sendf(&conn->proto.pop3c.pp, "LIST %s", pop3c->mailbox);
|
||||
}
|
||||
else
|
||||
result = Curl_pp_sendf(&conn->proto.pop3c.pp, "LIST");
|
||||
|
||||
if(result)
|
||||
return result;
|
||||
|
||||
if(pop3c->mailbox[0] != '\0')
|
||||
state(conn, POP3_LIST_SINGLE);
|
||||
else
|
||||
state(conn, POP3_LIST);
|
||||
state(conn, POP3_LIST);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -588,10 +571,6 @@ 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_RETR:
|
||||
result = pop3_state_retr_resp(conn, pop3code, pop3c->state);
|
||||
break;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 2009 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 2009 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
|
@ -33,7 +33,6 @@ typedef enum {
|
|||
POP3_PASS,
|
||||
POP3_STARTTLS,
|
||||
POP3_LIST,
|
||||
POP3_LIST_SINGLE,
|
||||
POP3_RETR,
|
||||
POP3_QUIT,
|
||||
POP3_LAST /* never used */
|
||||
|
@ -47,7 +46,7 @@ struct pop3_conn {
|
|||
size_t eob; /* number of bytes of the EOB (End Of Body) that has been
|
||||
received thus far */
|
||||
size_t strip; /* number of bytes from the start to ignore as non-body */
|
||||
pop3state state; /* always use pop3.c:state() to change state! */
|
||||
pop3state state; /* always use pop3.c:state() to change state! */
|
||||
};
|
||||
|
||||
extern const struct Curl_handler Curl_handler_pop3;
|
||||
|
|
Загрузка…
Ссылка в новой задаче