aboutsummaryrefslogtreecommitdiff
path: root/lib/imap.c
diff options
context:
space:
mode:
authorJiri Hruska <jirka@fud.cz>2013-03-03 10:49:37 +0100
committerSteve Holme <steve_holme@hotmail.com>2013-03-03 11:06:55 +0000
commitee7034800d24edece0623e94d79bdb66e3067c86 (patch)
tree830a21c93de548011acbbf0de87b6957939a4d5a /lib/imap.c
parent1d3ccf27ec8b1551e8c6e8bb914db39f8bfd2b4d (diff)
imap: Added custom request parsing
Added imap_parse_custom_request() for parsing the CURLOPT_CUSTOMREQUEST parameter which URL decodes the value and separates the request from any parameters - This makes it easier to filter untagged responses by the request command.
Diffstat (limited to 'lib/imap.c')
-rw-r--r--lib/imap.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/lib/imap.c b/lib/imap.c
index 3a1d135f3..69ec3524e 100644
--- a/lib/imap.c
+++ b/lib/imap.c
@@ -87,6 +87,7 @@
/* Local API functions */
static CURLcode imap_parse_url_path(struct connectdata *conn);
+static CURLcode imap_parse_custom_request(struct connectdata *conn);
static CURLcode imap_regular_transfer(struct connectdata *conn, bool *done);
static CURLcode imap_do(struct connectdata *conn, bool *done);
static CURLcode imap_done(struct connectdata *conn, CURLcode status,
@@ -1806,6 +1807,11 @@ static CURLcode imap_do(struct connectdata *conn, bool *done)
if(result)
return result;
+ /* Parse the custom request */
+ result = imap_parse_custom_request(conn);
+ if(result)
+ return result;
+
result = imap_regular_transfer(conn, done);
return result;
@@ -2017,6 +2023,37 @@ static CURLcode imap_parse_url_path(struct connectdata *conn)
return CURLE_OK;
}
+static CURLcode imap_parse_custom_request(struct connectdata *conn)
+{
+ CURLcode result = CURLE_OK;
+ struct SessionHandle *data = conn->data;
+ struct IMAP *imap = data->state.proto.imap;
+ const char *custom = data->set.str[STRING_CUSTOMREQUEST];
+
+ if(custom) {
+ /* URL decode the custom request */
+ result = Curl_urldecode(data, custom, 0, &imap->custom, NULL, TRUE);
+
+ /* Extract the parameters if specified */
+ if(!result) {
+ const char *params = imap->custom;
+
+ while(*params && *params != ' ')
+ params++;
+
+ if(*params) {
+ imap->custom_params = strdup(params);
+ imap->custom[params - imap->custom] = '\0';
+
+ if(!imap->custom_params)
+ result = CURLE_OUT_OF_MEMORY;
+ }
+ }
+ }
+
+ return result;
+}
+
/* Call this when the DO phase has completed */
static CURLcode imap_dophase_done(struct connectdata *conn, bool connected)
{