diff options
Diffstat (limited to 'usr.sbin/config/main.c')
-rw-r--r-- | usr.sbin/config/main.c | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/usr.sbin/config/main.c b/usr.sbin/config/main.c index ada1a03ce6c..dbc9c7ae811 100644 --- a/usr.sbin/config/main.c +++ b/usr.sbin/config/main.c @@ -1,5 +1,5 @@ -/* $OpenBSD: main.c,v 1.13 1997/04/14 02:24:04 deraadt Exp $ */ -/* $NetBSD: main.c,v 1.18 1996/08/31 20:58:20 mycroft Exp $ */ +/* $OpenBSD: main.c,v 1.14 1997/07/06 03:54:05 downsj Exp $ */ +/* $NetBSD: main.c,v 1.22 1997/02/02 21:12:33 thorpej Exp $ */ /* * Copyright (c) 1992, 1993 @@ -68,9 +68,9 @@ int yyparse __P((void)); extern char *optarg; extern int optind; -static struct hashtab *opttab; static struct hashtab *mkopttab; static struct nvlist **nextopt; +static struct nvlist **nextdefopt; static struct nvlist **nextmkopt; static __dead void stop __P((void)); @@ -166,8 +166,10 @@ usage: needcnttab = ht_new(); opttab = ht_new(); mkopttab = ht_new(); + defopttab = ht_new(); nextopt = &options; nextmkopt = &mkoptions; + nextdefopt = &defoptions; /* * Handle profiling (must do this before we try to create any @@ -279,6 +281,38 @@ stop() } /* + * Define a standard option, for which a header file will be generated. + */ +void +defoption(name) + const char *name; +{ + register const char *n; + register char *p, c; + char low[500]; + + /* + * Convert to lower case. The header file name will be + * in lower case, so we store the lower case version in + * the hash table to detect option name collisions. The + * original string will be stored in the nvlist for use + * in the header file. + */ + for (n = name, p = low; (c = *n) != '\0'; n++) + *p++ = isupper(c) ? tolower(c) : c; + *p = 0; + + n = intern(low); + (void)do_option(defopttab, &nextdefopt, n, name, "defopt"); + + /* + * Insert a verbatum copy of the option name, as well, + * to speed lookups when creating the Makefile. + */ + (void)ht_insert(defopttab, name, (void *)name); +} + +/* * Add an option from "options FOO". Note that this selects things that * are "optional foo". */ |