diff options
author | Jiri Hruska <jirka@fud.cz> | 2013-02-26 21:56:14 +0100 |
---|---|---|
committer | Steve Holme <steve_holme@hotmail.com> | 2013-02-26 22:09:19 +0000 |
commit | 59c71c7fc7b75cb7f6680e2ef269477831c215e6 (patch) | |
tree | e911f55783eca510be1f11b5c8173bcec2703705 | |
parent | 58efa46a5d7b5300480acfc29d301a94053a6dab (diff) |
imap: Added support for parsing the UIDVALIDITY property
Added support for parsing the UIDVALIDITY property from the SELECT
response and storing it in the per-connection structure.
-rw-r--r-- | lib/imap.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/imap.c b/lib/imap.c index 101f2bec5..b7c92ef58 100644 --- a/lib/imap.c +++ b/lib/imap.c @@ -395,6 +395,11 @@ static bool imap_endofresp(struct connectdata *conn, char *line, size_t len, return FALSE; break; + case IMAP_SELECT: + /* SELECT is special in that its untagged responses does not have a + common prefix so accept anything! */ + break; + case IMAP_FETCH: if(!imap_matchresp(line, len, "FETCH")) return FALSE; @@ -666,8 +671,12 @@ static CURLcode imap_select(struct connectdata *conn) CURLcode result = CURLE_OK; struct SessionHandle *data = conn->data; struct IMAP *imap = data->state.proto.imap; + struct imap_conn *imapc = &conn->proto.imapc; char *mailbox; + /* Invalidate old information in case we are switching mailboxes */ + Curl_safefree(imapc->mailbox_uidvalidity); + mailbox = imap_atom(imap->mailbox ? imap->mailbox : ""); if(!mailbox) result = CURLE_OUT_OF_MEMORY; @@ -1207,10 +1216,20 @@ static CURLcode imap_state_select_resp(struct connectdata *conn, { CURLcode result = CURLE_OK; struct SessionHandle *data = conn->data; + struct imap_conn *imapc = &conn->proto.imapc; + const char *line = data->state.buffer; + char tmp[20]; (void)instate; /* no use for this yet */ - if(imapcode != 'O') { + if(imapcode == '*') { + /* See if this is an UIDVALIDITY response */ + if(sscanf(line + 2, "OK [UIDVALIDITY %19[0123456789]]", tmp) == 1) { + Curl_safefree(imapc->mailbox_uidvalidity); + imapc->mailbox_uidvalidity = strdup(tmp); + } + } + else if(imapcode != 'O') { failf(data, "Select failed"); result = CURLE_LOGIN_DENIED; } |