Skip to content

Commit

Permalink
fix env configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
roberto@voldemort committed May 18, 2010
1 parent 4106931 commit f1316ef
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 41 deletions.
15 changes: 12 additions & 3 deletions utils.c
Expand Up @@ -408,11 +408,20 @@ void sanitize_args(struct uwsgi_server *uwsgi) {

void env_to_arg(char *src, char *dst) {
int i;
int val = 0 ;

for(i=0;i<strlen(src);i++) {
dst[i] = tolower(src[i]);
if (dst[i] == '_') {
dst[i] = '-';
if (src[i] == '=') {
val = 1 ;
}
if (val) {
dst[i] = src[i];
}
else {
dst[i] = tolower(src[i]);
if (dst[i] == '_') {
dst[i] = '-';
}
}
}

Expand Down
38 changes: 0 additions & 38 deletions uwsgi.c
Expand Up @@ -453,44 +453,6 @@ int main(int argc, char *argv[], char *envp[]) {
//parse environ

parse_sys_envs(environ, long_options);
char **uenvs = environ;
while(*uenvs) {
if (!strncmp(*uenvs, "UWSGI_", 6)) {
char *earg = malloc(strlen(*uenvs+6)+1);
if (!earg) {
uwsgi_error("malloc()");
exit(1);
}
env_to_arg(*uenvs+6, earg);
char *eq_pos = strchr(earg, '=');
if (!eq_pos) {
break;
}
eq_pos[0] = 0 ;
struct option *lopt = long_options, *aopt;
while ((aopt = lopt)) {
if (!aopt->name)
break;
if (!strcmp(earg, aopt->name)) {
if (aopt->flag) {
*aopt->flag = aopt->val;
}
else {
if (eq_pos[1] != 0) {
manage_opt(aopt->val, eq_pos+1);
}
else {
manage_opt(aopt->val, NULL);
}
}
}
lopt++;
}

}
uenvs++;
}


if (uwsgi.binary_path == argv[0]) {
cwd = uwsgi_get_cwd();
Expand Down

0 comments on commit f1316ef

Please sign in to comment.