aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cookie.c5
-rw-r--r--src/cookie.h3
-rw-r--r--src/request.c11
-rw-r--r--src/request.h6
4 files changed, 20 insertions, 5 deletions
diff --git a/src/cookie.c b/src/cookie.c
index eaa221f..9d2a5ce 100644
--- a/src/cookie.c
+++ b/src/cookie.c
@@ -16,13 +16,12 @@ int magi_cookie_list_add(struct magi_cookie_list ** list,
return !!node;
}
-struct magi_cookie * magi_cookie_list_get(struct magi_cookie_list * list,
- const char * name)
+char * magi_cookie_list_get(struct magi_cookie_list * list, const char * name)
{
if (!list || !name) {
return 0;
} else if (!strcmp(list->item.name, name)) {
- return &list->item;
+ return list->item.data;
} else {
return magi_cookie_list_get(list->next, name);
}
diff --git a/src/cookie.h b/src/cookie.h
index 82c914e..764eb53 100644
--- a/src/cookie.h
+++ b/src/cookie.h
@@ -22,8 +22,7 @@ int magi_cookie_list_add(struct magi_cookie_list ** list,
struct magi_cookie * item);
/* First node in list: node.name == name; else null. */
-struct magi_cookie * magi_cookie_list_get(struct magi_cookie_list * list,
- const char * name);
+char * magi_cookie_list_get(struct magi_cookie_list * list, const char * name);
/* Freeing and invalidation of list. */
void magi_cookie_list_destroy(struct magi_cookie_list * list);
diff --git a/src/request.c b/src/request.c
index e905e53..0db1e70 100644
--- a/src/request.c
+++ b/src/request.c
@@ -21,6 +21,7 @@ void magi_request_setup(struct magi_request * request)
}
}
+
void magi_tempfiles_add(struct magi_tempfiles * tmps,
const char * name,
const char * path,
@@ -46,6 +47,16 @@ void magi_tempfiles_add(struct magi_tempfiles * tmps,
tmps->maximums[tmps->count - 1] = max;
}
+void magi_tempfiles_destroy(struct magi_tempfiles * tmps)
+{
+ if (!tmps) {
+ return;
+ }
+ free(tmps->param_names);
+ free(tmps->locations);
+ free(tmps->maximums);
+}
+
static void tempfiles(struct magi_file * file,
char * addon,
int addon_len,
diff --git a/src/request.h b/src/request.h
index be92370..0ac7bac 100644
--- a/src/request.h
+++ b/src/request.h
@@ -82,21 +82,27 @@ struct magi_request {
/* Setup request with default settings. */
void magi_request_setup(struct magi_request * request);
+
struct magi_tempfiles {
int count;
const char ** param_names;
const char ** locations;
int * maximums; /* Null maximums[i] <=> unlimited tempfiles[i]. */
};
+
void magi_tempfiles_add(struct magi_tempfiles * tmps,
const char * name,
const char * path,
int max);
+
+void magi_tempfiles_destroy(struct magi_tempfiles * tmps);
+
/* Setup request callback with files loaded into corresponding to their
* parameter names locations; paths are in magi_tempfiles struct. */
void magi_request_setup_tempfiles(struct magi_request * request,
struct magi_tempfiles * table);
+
/* Destroys request. */
void magi_request_destroy(struct magi_request * request);