aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReyk Floeter <reyk@esdenera.com>2014-07-12 19:29:57 +0200
committerReyk Floeter <reyk@esdenera.com>2014-07-12 19:29:57 +0200
commit281824d5faf0354c2c0d6912c10494b9b014f12b (patch)
treeb7d021bea5ff6163453b5ad01b2e91513dd87572
parent703416e3aa51f7b68108b4c726e78972fbfbf8d4 (diff)
downloadhttpd-281824d5faf0354c2c0d6912c10494b9b014f12b.tar.gz
httpd-281824d5faf0354c2c0d6912c10494b9b014f12b.zip
Initial server configuration
-rw-r--r--config.c10
-rw-r--r--parse.y52
2 files changed, 53 insertions, 9 deletions
diff --git a/config.c b/config.c
index 8a64c4b..bc26f7d 100644
--- a/config.c
+++ b/config.c
@@ -64,16 +64,10 @@ config_init(struct httpd *env)
what = ps->ps_what[privsep_process];
if (what & CONFIG_SERVERS) {
-#if 0
if ((env->sc_servers =
- calloc(1, sizeof(*env->sc_relays))) == NULL)
+ calloc(1, sizeof(*env->sc_servers))) == NULL)
return (-1);
- TAILQ_INIT(env->sc_relays);
- if ((env->sc_pkeys =
- calloc(1, sizeof(*env->sc_pkeys))) == NULL)
- return (-1);
- TAILQ_INIT(env->sc_pkeys);
-#endif
+ TAILQ_INIT(env->sc_servers);
}
return (0);
diff --git a/parse.y b/parse.y
index 7c2dfa5..f6b9669 100644
--- a/parse.y
+++ b/parse.y
@@ -125,7 +125,7 @@ typedef struct {
%}
-%token ALL PORT LISTEN PREFORK SERVER ERROR INCLUDE LOG VERBOSE
+%token ALL PORT LISTEN PREFORK SERVER ERROR INCLUDE LOG VERBOSE ON
%token UPDATES INCLUDE
%token <v.string> STRING
%token <v.number> NUMBER
@@ -183,7 +183,56 @@ main : LOG loglevel {
;
server : SERVER STRING {
+ struct server *s;
+
+ if (!loadcfg) {
+ free($2);
+ YYACCEPT;
+ }
+
+ TAILQ_FOREACH(s, conf->sc_servers, srv_entry)
+ if (!strcmp(s->srv_conf.name, $2))
+ break;
+ if (s != NULL) {
+ yyerror("server %s defined twice", $2);
+ free($2);
+ YYERROR;
+ }
+
+ if ((s = calloc(1, sizeof (*s))) == NULL)
+ fatal("out of memory");
+
+ if (strlcpy(s->srv_conf.name, $2,
+ sizeof(s->srv_conf.name)) >=
+ sizeof(s->srv_conf.name)) {
+ yyerror("server name truncated");
+ free($2);
+ free(s);
+ YYERROR;
+ }
free($2);
+
+ s->srv_conf.id = ++last_server_id;
+ s->srv_conf.timeout.tv_sec = SERVER_TIMEOUT;
+
+ if (last_server_id == INT_MAX) {
+ yyerror("too many servers defined");
+ free(s);
+ YYERROR;
+ }
+ srv = s;
+ } '{' optnl serveropts_l '}' {
+ SPLAY_INIT(&srv->srv_clients);
+ TAILQ_INSERT_TAIL(conf->sc_servers, srv, srv_entry);
+ }
+ ;
+
+serveropts_l : serveropts_l serveroptsl nl
+ | serveroptsl optnl
+ ;
+
+serveroptsl : LISTEN ON STRING PORT NUMBER {
+ free($3);
}
;
@@ -241,6 +290,7 @@ lookup(char *s)
{ "include", INCLUDE },
{ "listen", LISTEN },
{ "log", LOG },
+ { "on", ON },
{ "port", PORT },
{ "prefork", PREFORK },
{ "server", SERVER },