1 /* -*- mode: fundamental; indent-tabs-mode: t; -*- */
5 * Copyright (c) 2021 Omar Polo <op@omarpolo.com>
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
30 struct vhost *host = &hosts[0];
33 extern void yyerror(const char*);
38 /* %define parse.error verbose */
45 %token TDAEMON TIPV6 TPORT TPROTOCOLS TMIME TDEFAULT TTYPE TSERVER
46 %token TCERT TKEY TROOT TCGI
55 conf : options vhosts ;
61 option : TDAEMON TBOOL { conf.foreground = !$2; }
62 | TIPV6 TBOOL { conf.ipv6 = $2; }
63 | TPORT TNUM { conf.port = $2; }
64 | TPROTOCOLS TSTRING {
65 if (tls_config_parse_protocols(&conf.protos, $2) == -1)
66 errx(1, "invalid protocols string \"%s\"", $2);
68 | TMIME TSTRING TSTRING { add_mime($2, $3); }
69 | TDEFAULT TTYPE TSTRING { set_default_mime($3); }
76 vhost : TSERVER TSTRING '{' servopts '}' {
79 if (host->cert == NULL || host->key == NULL ||
81 errx(1, "invalid vhost definition: %s", $2);
82 if (++ihost == HOSTSLEN)
83 errx(1, "too much vhosts defined");
86 | error '}' { yyerror("error in server directive"); }
89 servopts : /* empty */
93 servopt : TCERT TSTRING { host->cert = $2; }
94 | TKEY TSTRING { host->key = $2; }
95 | TROOT TSTRING { host->dir = $2; }
98 /* drop the starting '/', if any */
99 if (*host->cgi == '/')