From 3d194cd8cc42e40c6a0928f010faa3b805975ea3 Mon Sep 17 00:00:00 2001 From: "roberto@precise64" Date: Sat, 19 May 2012 10:59:40 +0200 Subject: [PATCH] added --declare-option --- uwsgi.c | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ uwsgi.h | 3 ++ 2 files changed, 96 insertions(+) diff --git a/uwsgi.c b/uwsgi.c index a04e4b2c..1a487154 100644 --- a/uwsgi.c +++ b/uwsgi.c @@ -63,6 +63,7 @@ static struct uwsgi_option uwsgi_base_options[] = { {"skip-zero", no_argument, 0, "skip check of file descriptor 0", uwsgi_opt_true, &uwsgi.skip_zero,0}, {"set", required_argument, 'S', "set a custom placeholder", uwsgi_opt_set_placeholder, NULL, UWSGI_OPT_IMMEDIATE}, + {"declare-option", required_argument, 0, "declare a new uWSGI custom option", uwsgi_opt_add_string_list, &uwsgi.custom_options, UWSGI_OPT_IMMEDIATE}, {"for", required_argument, 0, "(opt logic) for cycle", uwsgi_opt_logic, (void *) uwsgi_logic_opt_for, UWSGI_OPT_IMMEDIATE}, {"endfor", optional_argument, 0, "(opt logic) end for cycle", uwsgi_opt_noop, NULL, UWSGI_OPT_IMMEDIATE}, @@ -451,6 +452,89 @@ void show_config(void) { } +int uwsgi_manage_custom_option(struct uwsgi_string_list *usl, char *key, char *value) { + size_t i,count = 1; + size_t value_len = strlen(value); + off_t pos = 0; + char **opt_argv; + char *equal = memchr(usl->value, '=', usl->len); + if (!equal) { + return 0; + } + + if (uwsgi_strncmp(usl->value, equal-usl->value, key, strlen(key))) { + return 0; + } + + // now count the number of args + for(i=0;ilen - (equal-usl->value), "", 0); + // split it + p = strtok(tmp_opt, ";"); + while(p) { + equal = strchr(p, '='); + if (!equal) goto clear; + *equal = '\0'; + + // build the key + char *new_key = uwsgi_str(p); + for(i=0;inext; + } return 0; } @@ -3725,6 +3817,7 @@ void uwsgi_opt_set_placeholder(char *opt, char *value, void *none) { } + void uwsgi_opt_set_umask(char *opt, char *value, void *mode) { mode_t umask_mode = 0; diff --git a/uwsgi.h b/uwsgi.h index 6dc19d51..a7cab032 100644 --- a/uwsgi.h +++ b/uwsgi.h @@ -1173,6 +1173,7 @@ struct uwsgi_server { char *short_options; struct uwsgi_opt **exported_opts; int exported_opts_cnt; + struct uwsgi_string_list *custom_options; // dump the whole set of options int dump_options; @@ -2877,6 +2878,8 @@ int uwsgi_stats_keylong(struct uwsgi_stats *, char *, unsigned long long); int uwsgi_stats_keylong_comma(struct uwsgi_stats *, char *, unsigned long long); int uwsgi_stats_str(struct uwsgi_stats *, char *); +char *uwsgi_substitute(char *, char *, char *); + #ifdef UWSGI_SSL #include "openssl/conf.h" #include "openssl/ssl.h"