From 7163d8ddd4e27d9e573b361cdd61f4558c8bdc2e Mon Sep 17 00:00:00 2001 From: Unbit Date: Tue, 1 Oct 2013 15:30:39 +0200 Subject: [PATCH] fixed #406 --- core/uwsgi.c | 52 ++++++++++++++++++++++------------------------------ uwsgi.h | 1 + 2 files changed, 23 insertions(+), 30 deletions(-) diff --git a/core/uwsgi.c b/core/uwsgi.c index ff73508d..8e826e4f 100644 --- a/core/uwsgi.c +++ b/core/uwsgi.c @@ -886,7 +886,8 @@ void show_config(void) { } -int uwsgi_manage_custom_option(struct uwsgi_custom_option *uco, char *key, char *value) { +void uwsgi_opt_custom(char *key, char *value, void *data ) { + struct uwsgi_custom_option *uco = (struct uwsgi_custom_option *)data; int configured; size_t i, count = 1; size_t value_len = 0; @@ -896,10 +897,6 @@ int uwsgi_manage_custom_option(struct uwsgi_custom_option *uco, char *key, char char **opt_argv; char *tmp_val = NULL, *p = NULL; - if (strcmp(uco->name, key)) { - return 0; - } - // now count the number of args for (i = 0; i < value_len; i++) { if (value[i] == ' ') { @@ -974,7 +971,6 @@ clear: free(tmp_val); free(tmp_opt); free(opt_argv); - return 1; } @@ -988,14 +984,6 @@ int uwsgi_manage_opt(char *key, char *value) { } op++; } - - struct uwsgi_custom_option *uco = uwsgi.custom_options; - while (uco) { - if (uwsgi_manage_custom_option(uco, key, value)) { - return 1; - } - uco = uco->next; - } return 0; } @@ -3457,7 +3445,26 @@ void build_options() { pos += c; } } - // custom_options are not added to uwsgi.options + + uco = uwsgi.custom_options; + while (uco) { + uwsgi.options[pos].name = uco->name; + if (uco->has_args) { + uwsgi.options[pos].type = required_argument; + } + else { + uwsgi.options[pos].type = no_argument; + } + // custom options should be immediate + uwsgi.options[pos].flags = UWSGI_OPT_IMMEDIATE; + // help shows the option definition + uwsgi.options[pos].help = uco->value; + uwsgi.options[pos].data = uco; + uwsgi.options[pos].func = uwsgi_opt_custom; + + pos++; + uco = uco->next; + } pos = 0; @@ -3496,21 +3503,6 @@ void build_options() { op++; pos++; } - uco = uwsgi.custom_options; - while (uco) { - uwsgi.long_options[pos].name = uco->name; - if (uco->has_args) { - uwsgi.long_options[pos].has_arg = required_argument; - } - else { - uwsgi.long_options[pos].has_arg = no_argument; - } - uwsgi.long_options[pos].flag = 0; - // add 1000 to avoid short_options collision - uwsgi.long_options[pos].val = 1000 + pos; - pos++; - uco = uco->next; - } } /* diff --git a/uwsgi.h b/uwsgi.h index bd00cc51..aa5cf019 100644 --- a/uwsgi.h +++ b/uwsgi.h @@ -3474,6 +3474,7 @@ int uwsgi_manage_opt(char *, char *); void uwsgi_opt_print(char *, char *, void *); void uwsgi_opt_true(char *, char *, void *); void uwsgi_opt_set_str(char *, char *, void *); +void uwsgi_opt_custom(char *, char *, void *); void uwsgi_opt_set_null(char *, char *, void *); void uwsgi_opt_set_logger(char *, char *, void *); void uwsgi_opt_set_req_logger(char *, char *, void *);