4 struct file_list *file;
40 * Copyright (c) 1988, 1993
41 * The Regents of the University of California. All rights reserved.
43 * Redistribution and use in source and binary forms, with or without
44 * modification, are permitted provided that the following conditions
46 * 1. Redistributions of source code must retain the above copyright
47 * notice, this list of conditions and the following disclaimer.
48 * 2. Redistributions in binary form must reproduce the above copyright
49 * notice, this list of conditions and the following disclaimer in the
50 * documentation and/or other materials provided with the distribution.
51 * 3. All advertising materials mentioning features or use of this software
52 * must display the following acknowledgement:
53 * This product includes software developed by the University of
54 * California, Berkeley and its contributors.
55 * 4. Neither the name of the University nor the names of its contributors
56 * may be used to endorse or promote products derived from this software
57 * without specific prior written permission.
59 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
60 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
61 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
62 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
63 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
64 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
65 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
66 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
67 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
68 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
71 * @(#)config.y 8.1 (Berkeley) 6/6/93
83 struct device_head dtab;
90 struct file_list_head ftab;
91 struct files_name_head fntab;
95 #define ns(s) strdup(s)
96 int include(const char *, int);
97 void yyerror(const char *s);
103 char *ret = malloc(strlen(dev) + 5);
105 sprintf(ret, "DEV_%s", dev);
123 Device_spec SEMICOLON
125 Config_spec SEMICOLON
127 INCLUDE PATH SEMICOLON
150 if (machinename != NULL && !eq($2, machinename))
151 errx(1, "%s:%d: only one machine directive is allowed",
158 if (machinename != NULL &&
159 !(eq($2, machinename) && eq($3, machinearch)))
160 errx(1, "%s:%d: only one machine directive is allowed",
168 (struct cputype *)calloc(1, sizeof (struct cputype));
170 SLIST_INSERT_HEAD(&cputype, cp, cpu_next);
174 struct cputype *cp, *cp2;
175 SLIST_FOREACH_SAFE(cp, &cputype, cpu_next, cp2) {
176 if (eq(cp->cpu_name, $2)) {
177 SLIST_REMOVE(&cputype, cp, cputype, cpu_next);
185 = { rmopt_schedule(&opt, $2); } |
186 MAKEOPTIONS Mkopt_list
189 = { rmopt_schedule(&mkopt, $2); } |
195 = { maxusers = $2; } |
197 = { profiling = $2; } |
207 hint = (struct hint *)calloc(1, sizeof (struct hint));
208 hint->hint_name = $2;
209 STAILQ_INSERT_TAIL(&hints, hint, hint_next);
214 CONFIG System_id System_parameter_list
215 = { errx(1, "%s:%d: root/dump/swap specifications obsolete",
223 = { newopt(&mkopt, ns("KERNEL"), $1, 0); };
225 System_parameter_list:
226 System_parameter_list ID
231 Opt_list COMMA Option
239 newopt(&opt, $1, NULL, 0);
240 if (strchr($1, '=') != NULL)
241 errx(1, "%s:%d: The `=' in options should not be "
242 "quoted", yyfile, yyline);
244 Save_id EQUALS Opt_value
246 newopt(&opt, $1, $3, 0);
256 (void) snprintf(buf, sizeof(buf), "%d", $1);
266 Mkopt_list COMMA Mkoption
273 = { newopt(&mkopt, $1, ns(""), 0); } |
274 Save_id EQUALS Opt_value
275 = { newopt(&mkopt, $1, $3, 0); } |
276 Save_id PLUSEQUALS Opt_value
277 = { newopt(&mkopt, $1, $3, 1); } ;
291 Dev_list COMMA Device
297 NoDev_list COMMA NoDevice
305 newopt(&opt, devopt($1), ns("1"), 0);
306 /* and the device part */
313 char *s = devopt($1);
315 rmopt_schedule(&opt, s);
317 /* and the device part */
318 rmdev_schedule(&dtab, $1);
324 yyerror(const char *s)
327 errx(1, "%s:%d: %s", yyfile, yyline + 1, s);
333 if (found_defaults) {
334 if (freopen(PREFIX, "r", stdin) == NULL)
335 err(2, "%s", PREFIX);
345 * Add a new file to the list of files.
350 struct files_name *nl;
352 nl = (struct files_name *) calloc(1, sizeof *nl);
354 STAILQ_INSERT_TAIL(&fntab, nl, f_next);
358 * Find a device in the list of devices.
360 static struct device *
361 finddev(struct device_head *dlist, char *name)
365 STAILQ_FOREACH(dp, dlist, d_next)
366 if (eq(dp->d_name, name))
373 * Add a device to the list of devices.
380 if (finddev(&dtab, name)) {
381 printf("WARNING: duplicate device `%s' encountered.\n", name);
385 np = (struct device *) calloc(1, sizeof *np);
387 STAILQ_INSERT_TAIL(&dtab, np, d_next);
391 * Schedule a device to removal.
394 rmdev_schedule(struct device_head *dh, char *name)
398 dp = finddev(dh, name);
400 STAILQ_REMOVE(dh, dp, device, d_next);
407 * Find an option in the list of options.
410 findopt(struct opt_head *list, char *name)
414 SLIST_FOREACH(op, list, op_next)
415 if (eq(op->op_name, name))
422 * Add an option to the list of options.
425 newopt(struct opt_head *list, char *name, char *value, int append)
427 struct opt *op, *op2;
430 * Ignore inclusions listed explicitly for configuration files.
432 if (eq(name, OPT_AUTOGEN)) {
437 op2 = findopt(list, name);
438 if (op2 != NULL && !append) {
439 printf("WARNING: duplicate option `%s' encountered.\n", name);
443 op = (struct opt *)calloc(1, sizeof (struct opt));
446 op->op_value = value;
448 while (SLIST_NEXT(op2, op_append) != NULL)
449 op2 = SLIST_NEXT(op2, op_append);
450 SLIST_NEXT(op2, op_append) = op;
452 SLIST_INSERT_HEAD(list, op, op_next);
456 * Remove an option from the list of options.
459 rmopt_schedule(struct opt_head *list, char *name)
463 op = findopt(list, name);
465 SLIST_REMOVE(list, op, opt, op_next);