mirror of
https://github.com/clearlinux/uwsgi.git
synced 2026-08-27 17:05:49 +00:00
backported --for-glob
This commit is contained in:
@@ -6,7 +6,6 @@ a supervisor for multiple uWSGI instances
|
||||
|
||||
*/
|
||||
#include "uwsgi.h"
|
||||
#include <glob.h>
|
||||
|
||||
|
||||
extern struct uwsgi_server uwsgi;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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},
|
||||
|
||||
@@ -310,6 +310,8 @@ extern int pivot_root(const char *new_root, const char *put_old);
|
||||
#include <openssl/err.h>
|
||||
#endif
|
||||
|
||||
#include <glob.h>
|
||||
|
||||
|
||||
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 *);
|
||||
|
||||
Reference in New Issue
Block a user