diff options
author | 2000-01-04 14:23:43 +0000 | |
---|---|---|
committer | 2000-01-04 14:23:43 +0000 | |
commit | b23a0a289966d70b0330f0bb27d3507d0d103618 (patch) | |
tree | cd907124de35cb317cacfd59d15362a624e4256c | |
parent | more hints (hints.ai_socktype=SOCK_STREAM) for getaddrinfo, from itojun@ (diff) | |
download | wireguard-openbsd-b23a0a289966d70b0330f0bb27d3507d0d103618.tar.xz wireguard-openbsd-b23a0a289966d70b0330f0bb27d3507d0d103618.zip |
Add rmoption/rmoptions; useful for people who want a slightly
modified version of GENERIC.
-rw-r--r-- | usr.sbin/config/config.h | 4 | ||||
-rw-r--r-- | usr.sbin/config/gram.y | 9 | ||||
-rw-r--r-- | usr.sbin/config/hash.c | 35 | ||||
-rw-r--r-- | usr.sbin/config/main.c | 43 | ||||
-rw-r--r-- | usr.sbin/config/scan.l | 4 |
5 files changed, 89 insertions, 6 deletions
diff --git a/usr.sbin/config/config.h b/usr.sbin/config/config.h index 6544d6822ea..45ef2683104 100644 --- a/usr.sbin/config/config.h +++ b/usr.sbin/config/config.h @@ -1,4 +1,4 @@ -/* $OpenBSD: config.h,v 1.13 1999/10/04 20:00:50 deraadt Exp $ */ +/* $OpenBSD: config.h,v 1.14 2000/01/04 14:23:43 angelos Exp $ */ /* $NetBSD: config.h,v 1.30 1997/02/02 21:12:30 thorpej Exp $ */ /* @@ -338,6 +338,7 @@ void addobject __P((const char *, struct nvlist *, int)); /* hash.c */ struct hashtab *ht_new __P((void)); int ht_insrep __P((struct hashtab *, const char *, void *, int)); +int ht_remove __P((struct hashtab *, const char *)); #define ht_insert(ht, nam, val) ht_insrep(ht, nam, val, 0) #define ht_replace(ht, nam, val) ht_insrep(ht, nam, val, 1) void *ht_lookup __P((struct hashtab *, const char *)); @@ -346,6 +347,7 @@ const char *intern __P((const char *)); /* main.c */ void addoption __P((const char *name, const char *value)); +void removeoption __P((const char *name)); void addmkoption __P((const char *name, const char *value)); void defoption __P((const char *name)); int devbase_has_instances __P((struct devbase *, int)); diff --git a/usr.sbin/config/gram.y b/usr.sbin/config/gram.y index 6d91c4baa60..adffaaacc53 100644 --- a/usr.sbin/config/gram.y +++ b/usr.sbin/config/gram.y @@ -1,5 +1,5 @@ %{ -/* $OpenBSD: gram.y,v 1.9 1997/11/13 08:21:54 deraadt Exp $ */ +/* $OpenBSD: gram.y,v 1.10 2000/01/04 14:23:43 angelos Exp $ */ /* $NetBSD: gram.y,v 1.14 1997/02/02 21:12:32 thorpej Exp $ */ /* @@ -103,7 +103,7 @@ static void check_maxpart __P((void)); %token AND AT ATTACH BUILD COMPILE_WITH CONFIG DEFINE DEFOPT DEVICE DISABLE %token DUMPS ENDFILE XFILE XOBJECT FLAGS INCLUDE XMACHINE MAJOR MAKEOPTIONS %token MAXUSERS MAXPARTITIONS MINOR ON OPTIONS PSEUDO_DEVICE ROOT SOURCE SWAP -%token WITH NEEDS_COUNT NEEDS_FLAG +%token WITH NEEDS_COUNT NEEDS_FLAG RMOPTIONS %token <val> NUMBER %token <str> PATHNAME WORD EMPTY @@ -331,6 +331,7 @@ config_spec: object | include | OPTIONS opt_list | + RMOPTIONS ropt_list | MAKEOPTIONS mkopt_list | MAXUSERS NUMBER { setmaxusers($2); } | CONFIG conf sysparam_list { addconf(&conf); } | @@ -349,6 +350,10 @@ opt_list: opt_list ',' option | option; +ropt_list: + ropt_list ',' WORD { removeoption($3); } | + WORD { removeoption($1); }; + option: WORD { addoption($1, NULL); } | WORD '=' value { addoption($1, $3); }; diff --git a/usr.sbin/config/hash.c b/usr.sbin/config/hash.c index 9110386046d..735213d0dc8 100644 --- a/usr.sbin/config/hash.c +++ b/usr.sbin/config/hash.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hash.c,v 1.6 1997/08/07 10:36:57 deraadt Exp $ */ +/* $OpenBSD: hash.c,v 1.7 2000/01/04 14:23:43 angelos Exp $ */ /* $NetBSD: hash.c,v 1.4 1996/11/07 22:59:43 gwr Exp $ */ /* @@ -250,6 +250,39 @@ ht_new() } /* + * Remove. + */ +int +ht_remove(ht, nam) + register struct hashtab *ht; + register const char *nam; +{ + register struct hashent *hp, *thp; + register u_int h; + + h = hash(nam); + hp = ht->ht_tab[h & ht->ht_mask]; + while (hp && hp->h_name == nam) { + ht->ht_tab[h & ht->ht_mask] = hp->h_next; + /* XXX Free hp ? */ + hp = ht->ht_tab[h & ht->ht_mask]; + } + + if ((hp = ht->ht_tab[h & ht->ht_mask]) == NULL) + return (0); + + for (thp = hp->h_next; thp != NULL; thp = hp->h_next) { + if (thp->h_name == nam) { + hp->h_next = thp->h_next; + /* XXX Free hp ? */ + } else + hp = thp; + } + + return (0); +} + +/* * Insert and/or replace. */ int diff --git a/usr.sbin/config/main.c b/usr.sbin/config/main.c index 9555d2e68f9..bdbd6a75975 100644 --- a/usr.sbin/config/main.c +++ b/usr.sbin/config/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.19 1999/11/27 03:49:13 d Exp $ */ +/* $OpenBSD: main.c,v 1.20 2000/01/04 14:23:43 angelos Exp $ */ /* $NetBSD: main.c,v 1.22 1997/02/02 21:12:33 thorpej Exp $ */ /* @@ -346,6 +346,47 @@ defoption(name) } /* + * Remove an option. + */ +void +removeoption(name) + const char *name; +{ + register struct nvlist *nv, *nvt; + register const char *n; + register char *p, c; + char low[500]; + + if ((nv = ht_lookup(opttab, name)) != NULL) { + if (options == nv) + { + options = nv->nv_next; + nvfree(nv); + } else { + nvt = options; + while (nvt->nv_next != NULL) { + if (nvt->nv_next == nv) { + nvt->nv_next = nvt->nv_next->nv_next; + nvfree(nv); + break; + } + else + nvt = nvt->nv_next; + } + } + } + + (void)ht_remove(opttab, name); + + /* make lowercase, then add to select table */ + for (n = name, p = low; (c = *n) != '\0'; n++) + *p++ = isupper(c) ? tolower(c) : c; + *p = 0; + n = intern(low); + (void)ht_remove(selecttab, n); +} + +/* * Add an option from "options FOO". Note that this selects things that * are "optional foo". */ diff --git a/usr.sbin/config/scan.l b/usr.sbin/config/scan.l index 71724810bc4..e0065b45c01 100644 --- a/usr.sbin/config/scan.l +++ b/usr.sbin/config/scan.l @@ -1,5 +1,5 @@ %{ -/* $OpenBSD: scan.l,v 1.12 1998/06/27 01:45:47 deraadt Exp $ */ +/* $OpenBSD: scan.l,v 1.13 2000/01/04 14:23:43 angelos Exp $ */ /* $NetBSD: scan.l,v 1.13 1997/02/02 21:12:37 thorpej Exp $ */ /* @@ -115,6 +115,8 @@ root return ROOT; source return SOURCE; swap return SWAP; with return WITH; +rmoption return RMOPTIONS; +rmoptions return RMOPTIONS; {PATH} { yylval.str = intern(yytext); |