diff options
Diffstat (limited to 'content/fetch.c')
-rw-r--r-- | content/fetch.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/content/fetch.c b/content/fetch.c index 766502941..2ac86a812 100644 --- a/content/fetch.c +++ b/content/fetch.c @@ -712,6 +712,23 @@ fetch_multipart_data_clone(const struct fetch_multipart_data *list) return result; } + +/* exported interface documented in content/fetch.h */ +const char * +fetch_multipart_data_find(const struct fetch_multipart_data *list, + const char *name) +{ + while (list != NULL) { + if (strcmp(list->name, name) == 0) { + return list->value; + } + list = list->next; + } + + return NULL; +} + + /* exported interface documented in content/fetch.h */ void fetch_multipart_data_destroy(struct fetch_multipart_data *list) { @@ -730,6 +747,43 @@ void fetch_multipart_data_destroy(struct fetch_multipart_data *list) } } + +/* exported interface documented in content/fetch.h */ +nserror +fetch_multipart_data_new_kv(struct fetch_multipart_data **list, + const char *name, + const char *value) +{ + struct fetch_multipart_data *newdata; + + assert(list); + + newdata = calloc(sizeof(*newdata), 1); + + if (newdata == NULL) { + return NSERROR_NOMEM; + } + + newdata->name = strdup(name); + if (newdata->name == NULL) { + free(newdata); + return NSERROR_NOMEM; + } + + newdata->value = strdup(value); + if (newdata->value == NULL) { + free(newdata->name); + free(newdata); + return NSERROR_NOMEM; + } + + newdata->next = *list; + *list = newdata; + + return NSERROR_OK; +} + + /* exported interface documented in content/fetch.h */ void fetch_send_callback(const fetch_msg *msg, struct fetch *fetch) |