From 00c243bcce1377ee73ad7240ec0674fa4c8e04bf Mon Sep 17 00:00:00 2001 From: Unbit Date: Fri, 1 Mar 2013 15:23:38 +0100 Subject: [PATCH] backported --for-glob --- core/emperor.c | 1 - core/utils.c | 18 ++++++++++++++++++ core/uwsgi.c | 1 + uwsgi.h | 3 +++ 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/core/emperor.c b/core/emperor.c index 0a8d2b49..150ef141 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 dbf6be38..c4c9b0da 100644 --- a/core/utils.c +++ b/core/utils.c @@ -2032,6 +2032,24 @@ 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 95637213..74f3745c 100644 --- a/core/uwsgi.c +++ b/core/uwsgi.c @@ -64,6 +64,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 90cc7160..e0acd36c 100644 --- a/uwsgi.h +++ b/uwsgi.h @@ -310,6 +310,8 @@ extern int pivot_root(const char *new_root, const char *put_old); #include #endif +#include + struct uwsgi_buffer { char *buf; @@ -3054,6 +3056,7 @@ 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_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 *);