diff options
author | Aleksey Veresov <aleksey@veresov.pro> | 2019-11-29 18:50:04 +0300 |
---|---|---|
committer | Aleksey Veresov <aleksey@veresov.pro> | 2019-11-29 18:50:04 +0300 |
commit | b08db17162fddda97e6ee1ac625eae1430d22b64 (patch) | |
tree | 2c332f2db57a15c72f58704b9175cfece0ae9698 /src/request.c | |
parent | ea25abb295d9b4fbaf0ac23af8ffe71247970f1b (diff) | |
download | magi-b08db17162fddda97e6ee1ac625eae1430d22b64.tar magi-b08db17162fddda97e6ee1ac625eae1430d22b64.tar.xz magi-b08db17162fddda97e6ee1ac625eae1430d22b64.zip |
[magi] Almost done!
Diffstat (limited to 'src/request.c')
-rw-r--r-- | src/request.c | 40 |
1 files changed, 33 insertions, 7 deletions
diff --git a/src/request.c b/src/request.c index 4a1464a..99f3a2a 100644 --- a/src/request.c +++ b/src/request.c @@ -21,13 +21,39 @@ void magi_request_setup(struct magi_request * request) } } -static void tempfiles(struct magi_file * file, - char * addon, - int addon_len, - int is_addon_last, - struct magi_tempfiles * table) +void magi_tempfiles_add(struct magi_tempfiles * tmps, + const char * name, + const char * path, + int max) { - int pos; + if (!tmps) { + return; + } + if (tmps->count++) { + tmps->param_names = realloc(tmps->param_names, + sizeof(*tmps->param_names) * tmps->count); + tmps->locations = + realloc(tmps->locations, sizeof(*tmps->locations) * tmps->count); + tmps->maximums = + realloc(tmps->maximums, sizeof(*tmps->maximums) * tmps->count); + } else { + tmps->param_names = malloc(sizeof(*tmps->param_names)); + tmps->locations = malloc(sizeof(*tmps->locations)); + tmps->maximums = malloc(sizeof(*tmps->maximums)); + } + tmps->param_names[tmps->count] = name; + tmps->locations[tmps->count] = path; + tmps->maximums[tmps->count] = max; +} + +static void tempfiles(struct magi_file * file, + char * addon, + int addon_len, + int is_addon_last, + void * userdata) +{ + struct magi_tempfiles * table = userdata; + int pos; for (pos = 0; pos != table->count; ++pos) { if (!strcmp(table->param_names[pos], file->param_name)) { static FILE * f = 0; @@ -81,7 +107,7 @@ static void request_free(struct magi_request * request) free(request->path_info); } -void magi_request_annul(struct magi_request * request) +static void request_annul(struct magi_request * request) { request->cookies = 0; request->http_params = 0; |