diff --git a/core/emperor.c b/core/emperor.c index c34b6879..019dc03a 100644 --- a/core/emperor.c +++ b/core/emperor.c @@ -6,7 +6,6 @@ a supervisor for multiple uWSGI instances */ #include "uwsgi.h" -#include extern struct uwsgi_server uwsgi; diff --git a/core/utils.c b/core/utils.c index b2147d76..61e5976a 100644 --- a/core/utils.c +++ b/core/utils.c @@ -1455,6 +1455,25 @@ int uwsgi_logic_opt_for(char *key, char *value) { return 1; } +int uwsgi_logic_opt_for_glob(char *key, char *value) { + + glob_t g; + int i; + if (glob(uwsgi.logic_opt_data, GLOB_MARK | GLOB_NOCHECK, NULL, &g)) { + uwsgi_error("uwsgi_logic_opt_for_glob()"); + return 0; + } + + for (i = 0; i < (int) g.gl_pathc; i++) { + add_exported_option(key, uwsgi_substitute(value, "%(_)", g.gl_pathv[i]), 0); + } + + globfree(&g); + + return 1; +} + + void add_exported_option(char *key, char *value, int configured) { struct uwsgi_string_list *blacklist = uwsgi.blacklist; diff --git a/core/uwsgi.c b/core/uwsgi.c index 55cfbfb8..d69f926d 100644 --- a/core/uwsgi.c +++ b/core/uwsgi.c @@ -78,6 +78,7 @@ static struct uwsgi_option uwsgi_base_options[] = { {"declare-option", required_argument, 0, "declare a new uWSGI custom option", uwsgi_opt_add_custom_option, NULL, UWSGI_OPT_IMMEDIATE}, {"for", required_argument, 0, "(opt logic) for cycle", uwsgi_opt_logic, (void *) uwsgi_logic_opt_for, UWSGI_OPT_IMMEDIATE}, + {"for-glob", required_argument, 0, "(opt logic) for cycle (expand glob)", uwsgi_opt_logic, (void *) uwsgi_logic_opt_for_glob, UWSGI_OPT_IMMEDIATE}, {"endfor", optional_argument, 0, "(opt logic) end for cycle", uwsgi_opt_noop, NULL, UWSGI_OPT_IMMEDIATE}, {"if-opt", required_argument, 0, "(opt logic) check for option", uwsgi_opt_logic, (void *) uwsgi_logic_opt_if_opt, UWSGI_OPT_IMMEDIATE}, diff --git a/uwsgi.h b/uwsgi.h index a95dad57..541007df 100644 --- a/uwsgi.h +++ b/uwsgi.h @@ -324,6 +324,9 @@ extern "C" { #include #endif +#include + + struct uwsgi_buffer { char *buf; @@ -3258,19 +3261,20 @@ socklen_t socket_to_in_addr6(char *, char *, int, struct sockaddr_in6 *); void uwsgi_opt_noop(char *, char *, void *); void uwsgi_opt_logic(char *, char *, void *); - int uwsgi_logic_opt_for(char *, char *); - int uwsgi_logic_opt_if_env(char *, char *); - int uwsgi_logic_opt_if_not_env(char *, char *); - int uwsgi_logic_opt_if_opt(char *, char *); - int uwsgi_logic_opt_if_not_opt(char *, char *); - int uwsgi_logic_opt_if_exists(char *, char *); - int uwsgi_logic_opt_if_not_exists(char *, char *); - int uwsgi_logic_opt_if_file(char *, char *); - int uwsgi_logic_opt_if_not_file(char *, char *); - int uwsgi_logic_opt_if_dir(char *, char *); - int uwsgi_logic_opt_if_not_dir(char *, char *); - int uwsgi_logic_opt_if_reload(char *, char *); - int uwsgi_logic_opt_if_not_reload(char *, char *); +int uwsgi_logic_opt_for(char *, char *); +int uwsgi_logic_opt_for_glob(char *, char *); +int uwsgi_logic_opt_if_env(char *, char *); +int uwsgi_logic_opt_if_not_env(char *, char *); +int uwsgi_logic_opt_if_opt(char *, char *); +int uwsgi_logic_opt_if_not_opt(char *, char *); +int uwsgi_logic_opt_if_exists(char *, char *); +int uwsgi_logic_opt_if_not_exists(char *, char *); +int uwsgi_logic_opt_if_file(char *, char *); +int uwsgi_logic_opt_if_not_file(char *, char *); +int uwsgi_logic_opt_if_dir(char *, char *); +int uwsgi_logic_opt_if_not_dir(char *, char *); +int uwsgi_logic_opt_if_reload(char *, char *); +int uwsgi_logic_opt_if_not_reload(char *, char *); #ifdef UWSGI_CAP