From 60eae2d69f71dd23efcd98298a47e08dbb2ef891 Mon Sep 17 00:00:00 2001 From: Roberto De Ioris Date: Tue, 1 Jul 2014 06:58:14 +0200 Subject: [PATCH] added if-hostname --- core/config.c | 20 ++++++++++++++++++++ core/uwsgi.c | 3 +++ uwsgi.h | 2 ++ 3 files changed, 25 insertions(+) diff --git a/core/config.c b/core/config.c index d75b4279..18693675 100644 --- a/core/config.c +++ b/core/config.c @@ -294,6 +294,26 @@ int uwsgi_logic_opt_if_not_plugin(char *key, char *value) { return 0; } +int uwsgi_logic_opt_if_hostname(char *key, char *value) { + + if (!strcmp(uwsgi.hostname, uwsgi.logic_opt_data)) { + add_exported_option(key, uwsgi_substitute(value, "%(_)", uwsgi.logic_opt_data), 0); + return 1; + } + + return 0; +} + +int uwsgi_logic_opt_if_not_hostname(char *key, char *value) { + + if (strcmp(uwsgi.hostname, uwsgi.logic_opt_data)) { + add_exported_option(key, uwsgi_substitute(value, "%(_)", uwsgi.logic_opt_data), 0); + return 1; + } + + return 0; +} + int uwsgi_count_options(struct uwsgi_option *uopt) { struct uwsgi_option *aopt; diff --git a/core/uwsgi.c b/core/uwsgi.c index ecf04c6a..394dfa5c 100644 --- a/core/uwsgi.c +++ b/core/uwsgi.c @@ -120,6 +120,9 @@ static struct uwsgi_option uwsgi_base_options[] = { {"if-reload", no_argument, 0, "(opt logic) check for reload", uwsgi_opt_logic, (void *) uwsgi_logic_opt_if_reload, UWSGI_OPT_IMMEDIATE}, {"if-not-reload", no_argument, 0, "(opt logic) check for reload", uwsgi_opt_logic, (void *) uwsgi_logic_opt_if_not_reload, UWSGI_OPT_IMMEDIATE}, + {"if-hostname", required_argument, 0, "(opt logic) check for hostname", uwsgi_opt_logic, (void *) uwsgi_logic_opt_if_hostname, UWSGI_OPT_IMMEDIATE}, + {"if-not-hostname", required_argument, 0, "(opt logic) check for hostname", uwsgi_opt_logic, (void *) uwsgi_logic_opt_if_not_hostname, UWSGI_OPT_IMMEDIATE}, + {"if-exists", required_argument, 0, "(opt logic) check for file/directory existance", uwsgi_opt_logic, (void *) uwsgi_logic_opt_if_exists, UWSGI_OPT_IMMEDIATE}, {"if-not-exists", required_argument, 0, "(opt logic) check for file/directory existance", uwsgi_opt_logic, (void *) uwsgi_logic_opt_if_not_exists, UWSGI_OPT_IMMEDIATE}, {"ifexists", required_argument, 0, "(opt logic) check for file/directory existance", uwsgi_opt_logic, (void *) uwsgi_logic_opt_if_exists, UWSGI_OPT_IMMEDIATE}, diff --git a/uwsgi.h b/uwsgi.h index e0b630ca..d7f01793 100644 --- a/uwsgi.h +++ b/uwsgi.h @@ -3810,6 +3810,8 @@ int uwsgi_logic_opt_if_reload(char *, char *); int uwsgi_logic_opt_if_not_reload(char *, char *); int uwsgi_logic_opt_if_plugin(char *, char *); int uwsgi_logic_opt_if_not_plugin(char *, char *); +int uwsgi_logic_opt_if_hostname(char *, char *); +int uwsgi_logic_opt_if_not_hostname(char *, char *); void uwsgi_opt_resolve(char *, char *, void *);