diff options
author | Omar Polo <op@omarpolo.com> | 2023-06-09 10:42:36 +0000 |
---|---|---|
committer | Omar Polo <op@omarpolo.com> | 2023-06-09 10:42:36 +0000 |
commit | 5d22294a59e7e9cbe6457b9e6244fff2ede09956 (patch) | |
tree | 376d096309b8fe559dc330d3b3be18a7c201b1e3 /parse.y | |
parent | 1962764c6292e845cec17393e1c46c1473ca1eeb (diff) |
move fastcgi from global var to the config struct
while here also make them a list rather than a fixed-size array.
Diffstat (limited to 'parse.y')
-rw-r--r-- | parse.y | 25 |
1 files changed, 11 insertions, 14 deletions
@@ -1124,27 +1124,24 @@ int fastcgi_conf(const char *path, const char *port) { struct fcgi *f; - int i; - - for (i = 0; i < FCGI_MAX; ++i) { - f = &fcgi[i]; - - if (*f->path == '\0') { - f->id = i; - (void) strlcpy(f->path, path, sizeof(f->path)); - if (port != NULL) - (void) strlcpy(f->port, port, sizeof(f->port)); - return i; - } + int i = 0; + TAILQ_FOREACH(f, &conf.fcgi, fcgi) { if (!strcmp(f->path, path) && ((port == NULL && *f->port == '\0') || !strcmp(f->port, port))) return i; + ++i; } - yyerror("too much `fastcgi' rules defined."); - return -1; + f = xcalloc(1, sizeof(*f)); + f->id = i; + (void)strlcpy(f->path, path, sizeof(f->path)); + if (port != NULL) + (void)strlcpy(f->port, port, sizeof(f->port)); + TAILQ_INSERT_TAIL(&conf.fcgi, f, fcgi); + + return f->id; } void |