mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 23:58:49 -05:00
imap: Moved mailbox check from the imap_do() function
In preparation for the addition of the LIST command, moved the mailbox check from imap_do() to imap_select() and imap_append().
This commit is contained in:
parent
172e6378f8
commit
c29346613d
21
lib/imap.c
21
lib/imap.c
@ -692,6 +692,12 @@ static CURLcode imap_select(struct connectdata *conn)
|
|||||||
Curl_safefree(imapc->mailbox);
|
Curl_safefree(imapc->mailbox);
|
||||||
Curl_safefree(imapc->mailbox_uidvalidity);
|
Curl_safefree(imapc->mailbox_uidvalidity);
|
||||||
|
|
||||||
|
/* Check we have a mailbox */
|
||||||
|
if(!imap->mailbox) {
|
||||||
|
failf(conn->data, "Cannot SELECT without a mailbox.");
|
||||||
|
return CURLE_URL_MALFORMAT;
|
||||||
|
}
|
||||||
|
|
||||||
/* Make sure the mailbox is in the correct atom format */
|
/* Make sure the mailbox is in the correct atom format */
|
||||||
mailbox = imap_atom(imap->mailbox);
|
mailbox = imap_atom(imap->mailbox);
|
||||||
if(!mailbox)
|
if(!mailbox)
|
||||||
@ -730,6 +736,12 @@ static CURLcode imap_append(struct connectdata *conn)
|
|||||||
struct IMAP *imap = conn->data->state.proto.imap;
|
struct IMAP *imap = conn->data->state.proto.imap;
|
||||||
char *mailbox;
|
char *mailbox;
|
||||||
|
|
||||||
|
/* Check we have a mailbox */
|
||||||
|
if(!imap->mailbox) {
|
||||||
|
failf(conn->data, "Cannot APPEND without a mailbox.");
|
||||||
|
return CURLE_URL_MALFORMAT;
|
||||||
|
}
|
||||||
|
|
||||||
/* Check we know the size of the upload */
|
/* Check we know the size of the upload */
|
||||||
if(conn->data->set.infilesize < 0) {
|
if(conn->data->set.infilesize < 0) {
|
||||||
failf(conn->data, "Cannot APPEND with unknown input file size\n");
|
failf(conn->data, "Cannot APPEND with unknown input file size\n");
|
||||||
@ -1869,7 +1881,6 @@ static CURLcode imap_perform(struct connectdata *conn, bool *connected,
|
|||||||
static CURLcode imap_do(struct connectdata *conn, bool *done)
|
static CURLcode imap_do(struct connectdata *conn, bool *done)
|
||||||
{
|
{
|
||||||
CURLcode result = CURLE_OK;
|
CURLcode result = CURLE_OK;
|
||||||
struct IMAP *imap;
|
|
||||||
|
|
||||||
*done = FALSE; /* default to false */
|
*done = FALSE; /* default to false */
|
||||||
|
|
||||||
@ -1882,8 +1893,6 @@ static CURLcode imap_do(struct connectdata *conn, bool *done)
|
|||||||
if(result)
|
if(result)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
imap = conn->data->state.proto.imap;
|
|
||||||
|
|
||||||
/* Parse the URL path */
|
/* Parse the URL path */
|
||||||
result = imap_parse_url_path(conn);
|
result = imap_parse_url_path(conn);
|
||||||
if(result)
|
if(result)
|
||||||
@ -1894,12 +1903,6 @@ static CURLcode imap_do(struct connectdata *conn, bool *done)
|
|||||||
if(result)
|
if(result)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
/* Check we have a mailbox for FETCH and APPEND commands */
|
|
||||||
if(!imap->custom && !imap->mailbox) {
|
|
||||||
failf(conn->data, "FETCH and APPEND require a mailbox.");
|
|
||||||
return CURLE_URL_MALFORMAT;
|
|
||||||
}
|
|
||||||
|
|
||||||
result = imap_regular_transfer(conn, done);
|
result = imap_regular_transfer(conn, done);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
Loading…
Reference in New Issue
Block a user