aboutsummaryrefslogtreecommitdiff
path: root/lib/imap.c
diff options
context:
space:
mode:
authorSteve Holme <steve_holme@hotmail.com>2012-12-30 12:44:09 +0000
committerSteve Holme <steve_holme@hotmail.com>2012-12-30 12:44:09 +0000
commitbd8ae6800674411b10482a5253428abbc83bf308 (patch)
tree0640aafccb5a0232f87b9b7df32779d48f661c30 /lib/imap.c
parentc02449ca532b67dfc0b48217538f788213b9d8c1 (diff)
imap: Code tidy up prior to adding support for the CAPABILITY command
* Changing the order of the state machine to represent the order in which commands are sent to the server. * Reworking the imap_endofresp() function as the FETCH response doesn't include the command id and shouldn't be part of the length comparison that takes into account the id string.
Diffstat (limited to 'lib/imap.c')
-rw-r--r--lib/imap.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/lib/imap.c b/lib/imap.c
index eefdaf278..684c821a3 100644
--- a/lib/imap.c
+++ b/lib/imap.c
@@ -329,15 +329,18 @@ static int imap_endofresp(struct pingpong *pp, int *resp)
const char *id = imapc->idstr;
size_t id_len = strlen(id);
+ /* Do we have a generic command response? */
if(len >= id_len + 3) {
if(!memcmp(id, line, id_len) && (line[id_len] == ' ') ) {
- /* end of response */
*resp = line[id_len+1]; /* O, N or B */
return TRUE;
}
- else if((imapc->state == IMAP_FETCH) &&
- !memcmp("* ", line, 2) ) {
- /* FETCH response we're interested in */
+ }
+
+ /* Are we processing FETCH command responses? */
+ if(imapc->state == IMAP_FETCH) {
+ /* Do we have a valid response? */
+ if(len >= 2 && !memcmp("* ", line, 2)) {
*resp = '*';
return TRUE;
}
@@ -356,9 +359,9 @@ static void state(struct connectdata *conn,
static const char * const names[]={
"STOP",
"SERVERGREET",
- "LOGIN",
"STARTTLS",
"UPGRADETLS",
+ "LOGIN",
"SELECT",
"FETCH",
"LOGOUT",
@@ -687,14 +690,14 @@ static CURLcode imap_statemach_act(struct connectdata *conn)
result = imap_state_servergreet_resp(conn, imapcode, imapc->state);
break;
- case IMAP_LOGIN:
- result = imap_state_login_resp(conn, imapcode, imapc->state);
- break;
-
case IMAP_STARTTLS:
result = imap_state_starttls_resp(conn, imapcode, imapc->state);
break;
+ case IMAP_LOGIN:
+ result = imap_state_login_resp(conn, imapcode, imapc->state);
+ break;
+
case IMAP_FETCH:
result = imap_state_fetch_resp(conn, imapcode, imapc->state);
break;