3 * Copyright (c) 2011 James Gritton
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 #include <sys/cdefs.h>
29 __FBSDID("$FreeBSD$");
51 %token <cs> STR STR1 VAR VAR1
62 * A config file is a series of jails (containing parameters) and jail-less
63 * parameters which realy belong to a global pseudo-jail.
73 j = TAILQ_LAST(&cfjails, cfjails);
74 if (!j || strcmp(j->name, "*")) {
76 j->name = estrdup("*");
78 TAILQ_INSERT_TAIL(&j->params, $2, tq);
82 jail : STR '{' param_l '}'
86 TAILQ_CONCAT(&$$->params, $3, tq);
93 $$ = emalloc(sizeof(struct cfparams));
99 TAILQ_INSERT_TAIL($$, $2, tq);
105 * Parameters have a name and an optional list of value strings,
106 * which may have "+=" or "=" preceeding them.
115 TAILQ_CONCAT(&$$->val, $3, tq);
121 TAILQ_CONCAT(&$$->val, $3, tq);
122 $$->flags |= PF_APPEND;
128 TAILQ_CONCAT(&$$->val, $2, tq);
137 * A parameter has a fixed name. A variable definition looks just like a
138 * parameter except that the name is a variable.
142 $$ = emalloc(sizeof(struct cfparam));
144 TAILQ_INIT(&$$->val);
149 $$ = emalloc(sizeof(struct cfparam));
151 TAILQ_INIT(&$$->val);
158 $$ = emalloc(sizeof(struct cfstrings));
160 TAILQ_INSERT_TAIL($$, $1, tq);
165 TAILQ_INSERT_TAIL($$, $3, tq);
170 * Strings may be passed in pieces, because of quoting and/or variable
171 * interpolation. Reassemble them into a single string.
175 $$ = emalloc(sizeof(struct cfstring));
177 $$->len = strlen($1);
178 STAILQ_INIT(&$$->vars);
184 $$ = emalloc(sizeof(struct cfstring));
187 STAILQ_INIT(&$$->vars);
188 v = emalloc(sizeof(struct cfvar));
191 STAILQ_INSERT_TAIL(&$$->vars, v, tq);
199 $$->s = erealloc($$->s, $$->len + len1 + 1);
200 strcpy($$->s + $$->len, $2);
209 v = emalloc(sizeof(struct cfvar));
212 STAILQ_INSERT_TAIL(&$$->vars, v, tq);