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 TBOOL TSTRING TNUM
46 %token TDAEMON TIPV6 TPORT TSERVER
47 %token TCERT TKEY TROOT TCGI
56 conf : options vhosts ;
62 option : TDAEMON TBOOL { conf.foreground = !$2; }
63 | TIPV6 TBOOL { conf.ipv6 = $2; }
64 | TPORT TNUM { conf.port = $2; }
71 vhost : TSERVER TSTRING '{' servopts '}' {
74 if (host->cert == NULL || host->key == NULL ||
76 errx(1, "invalid vhost definition: %s", $2);
77 if (++ihost == HOSTSLEN)
78 errx(1, "too much vhosts defined");
81 | error '}' { yyerror("error in server directive"); }
84 servopts : /* empty */
88 servopt : TCERT TSTRING { host->cert = $2; }
89 | TKEY TSTRING { host->key = $2; }
90 | TROOT TSTRING { host->dir = $2; }
93 /* drop the starting '/', if any */
94 if (*host->cgi == '/')