diff --git a/includes/http.h b/includes/http.h index 416c0df..47d95ec 100644 --- a/includes/http.h +++ b/includes/http.h @@ -79,8 +79,11 @@ int http_generic_404(struct http_request *); int http_header_recv(struct netbuf *); char *http_post_data_text(struct http_request *); int http_populate_arguments(struct http_request *); +void http_argument_multiple_free(struct http_arg *); int http_argument_lookup(struct http_request *, const char *, char **); +int http_argument_multiple_lookup(struct http_request *, + struct http_arg *); void kore_accesslog(struct http_request *); diff --git a/includes/kore.h b/includes/kore.h index d250a4d..b0928ca 100644 --- a/includes/kore.h +++ b/includes/kore.h @@ -47,6 +47,8 @@ #define KORE_PIDFILE_DEFAULT "/var/run/kore.pid" #define KORE_DEFAULT_CIPHER_LIST "HIGH:!aNULL:!MD5;" +#define KORE_DEBUG 1 + #if defined(KORE_DEBUG) #define kore_debug(fmt, ...) \ if (kore_debug) \ diff --git a/src/http.c b/src/http.c index 63fc701..76fdf7d 100644 --- a/src/http.c +++ b/src/http.c @@ -485,6 +485,33 @@ http_argument_lookup(struct http_request *req, const char *name, char **out) return (KORE_RESULT_ERROR); } +int +http_argument_multiple_lookup(struct http_request *req, struct http_arg *args) +{ + int i; + + for (i = 0; args[i].name != NULL; i++) { + if (!http_argument_lookup(req, + args[i].name, &(args[i].value))) { + args[i].value = NULL; + return (i); + } + } + + return (i); +} + +void +http_argument_multiple_free(struct http_arg *args) +{ + int i; + + for (i = 0; args[i].name != NULL; i++) { + if (args[i].value != NULL) + kore_mem_free(args[i].value); + } +} + char * http_post_data_text(struct http_request *req) {