diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1997-08-07 10:37:00 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1997-08-07 10:37:00 +0000 |
commit | db54ea3a6e1aaa39cd0e5e7878f0e8c9f2c4bdf4 (patch) | |
tree | e6960df298698456c42d666a4e72528f908f424c /usr.sbin | |
parent | 4aad226b61f90c6086a462a1994ce60a259aeee2 (diff) |
jason is tired. this is not needed. our locator table stuff uses less
memory too.
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/config/config.h | 8 | ||||
-rw-r--r-- | usr.sbin/config/hash.c | 28 | ||||
-rw-r--r-- | usr.sbin/config/mkheaders.c | 132 | ||||
-rw-r--r-- | usr.sbin/config/mkioconf.c | 46 | ||||
-rw-r--r-- | usr.sbin/config/sem.c | 5 |
5 files changed, 15 insertions, 204 deletions
diff --git a/usr.sbin/config/config.h b/usr.sbin/config/config.h index 36e5a1ff488..5212203fc13 100644 --- a/usr.sbin/config/config.h +++ b/usr.sbin/config/config.h @@ -1,5 +1,5 @@ -/* $OpenBSD: config.h,v 1.10 1997/08/07 10:22:24 downsj Exp $ */ -/* $NetBSD: config.h,v 1.31 1997/03/14 00:14:09 jtk Exp $ */ +/* $OpenBSD: config.h,v 1.11 1997/08/07 10:36:57 deraadt Exp $ */ +/* $NetBSD: config.h,v 1.30 1997/02/02 21:12:30 thorpej Exp $ */ /* * Copyright (c) 1992, 1993 @@ -285,8 +285,6 @@ struct hashtab *selecttab; /* selects things that are "optional foo" */ struct hashtab *needcnttab; /* retains names marked "needs-count" */ struct hashtab *opttab; /* table of configured options */ struct hashtab *defopttab; /* options that have been "defopt"'d */ -struct hashtab *attrtab; /* attributes (locators, etc.) */ - struct devbase *allbases; /* list of all devbase structures */ struct deva *alldevas; /* list of all devbase attachment structures */ struct config *allcf; /* list of configured kernels */ @@ -323,8 +321,6 @@ int ht_insrep __P((struct hashtab *, const char *, void *, int)); void *ht_lookup __P((struct hashtab *, const char *)); void initintern __P((void)); const char *intern __P((const char *)); -typedef int (*ht_callback) __P((const char *, void *, void *)); -int ht_enumerate __P((struct hashtab *, ht_callback, void *)); /* main.c */ void addoption __P((const char *name, const char *value)); diff --git a/usr.sbin/config/hash.c b/usr.sbin/config/hash.c index 661cfea2d92..9110386046d 100644 --- a/usr.sbin/config/hash.c +++ b/usr.sbin/config/hash.c @@ -1,5 +1,5 @@ -/* $OpenBSD: hash.c,v 1.5 1997/08/07 10:22:25 downsj Exp $ */ -/* $NetBSD: hash.c,v 1.5 1997/03/14 00:14:12 jtk Exp $ */ +/* $OpenBSD: hash.c,v 1.6 1997/08/07 10:36:57 deraadt Exp $ */ +/* $NetBSD: hash.c,v 1.4 1996/11/07 22:59:43 gwr Exp $ */ /* * Copyright (c) 1992, 1993 @@ -293,27 +293,3 @@ ht_lookup(ht, nam) return (hp->h_value); return (NULL); } - -/* - * first parameter to callback is the entry name from the hash table - * second parameter is the value from the hash table - * third argument is passed through from the "arg" parameter to ht_enumerate() - */ - -int -ht_enumerate(ht, cbfunc, arg) - struct hashtab *ht; - ht_callback cbfunc; - void *arg; -{ - struct hashent *hp, **hpp; - register u_int i; - int rval = 0; - - for (i = 0; i < ht->ht_size; i++) { - hpp = &ht->ht_tab[i]; - for (; (hp = *hpp) != NULL; hpp = &hp->h_next) - rval += (*cbfunc)(hp->h_name, hp->h_value, arg); - } - return rval; -} diff --git a/usr.sbin/config/mkheaders.c b/usr.sbin/config/mkheaders.c index 902c17ca79d..583c2556418 100644 --- a/usr.sbin/config/mkheaders.c +++ b/usr.sbin/config/mkheaders.c @@ -1,5 +1,5 @@ -/* $OpenBSD: mkheaders.c,v 1.7 1997/08/07 10:22:26 downsj Exp $ */ -/* $NetBSD: mkheaders.c,v 1.15 1997/07/18 11:27:37 jtk Exp $ */ +/* $OpenBSD: mkheaders.c,v 1.8 1997/08/07 10:36:58 deraadt Exp $ */ +/* $NetBSD: mkheaders.c,v 1.12 1997/02/02 21:12:34 thorpej Exp $ */ /* * Copyright (c) 1992, 1993 @@ -54,13 +54,10 @@ #include "config.h" static int emitcnt __P((struct nvlist *)); -static int emitlocs __P((void)); static int emitopt __P((struct nvlist *)); static int err __P((const char *, char *, FILE *)); -static int locators_print __P((const char *, void *, void *)); static char *cntname __P((const char *)); - /* * Make headers containing counts, as needed. */ @@ -82,9 +79,6 @@ mkheaders() if (emitopt(nv)) return (1); - if (emitlocs()) - return (1); - return (0); } @@ -189,128 +183,6 @@ writeit: return (0); } -/* - * A callback function for walking the attribute hash table. - * Emit CPP definitions of manifest constants for the locators on the - * "name" attribute node (passed as the "value" parameter). - */ -static int -locators_print(name, value, arg) - const char *name; - void *value; - void *arg; -{ - struct attr *a; - register struct nvlist *nv; - register int i; - char *locdup, *namedup; - register char *cp; - FILE *fp = arg; - - a = value; - if (a->a_locs) { - if (strchr(name, ' ') != NULL || strchr(name, '\t') != NULL) - /* - * name contains a space; we can't generate - * usable defines, so ignore it. - */ - return 0; - locdup = strdup(name); - for (cp = locdup; *cp; cp++) - if (islower(*cp)) - *cp = toupper(*cp); - if (fprintf(fp, "extern const char *%scf_locnames[];\n", - name) < 0) - return 1; - for (i = 0, nv = a->a_locs; nv; nv = nv->nv_next, i++) { - if (strchr(nv->nv_name, ' ') != NULL || - strchr(nv->nv_name, '\t') != NULL) - /* - * name contains a space; we can't generate - * usable defines, so ignore it. - */ - continue; - namedup = strdup(nv->nv_name); - for (cp = namedup; *cp; cp++) - if (islower(*cp)) - *cp = toupper(*cp); - if (fprintf(fp, "#define %sCF_%s %d\n", - locdup, namedup, i) < 0) - return 1; - if (nv->nv_str && - fprintf(fp, - "#define %sCF_%s_DEFAULT %s\n", - locdup, namedup, nv->nv_str) < 0) - return 1; - free(namedup); - } - free(locdup); - } - return 0; -} - -/* - * Build the "locators.h" file with manifest constants for all potential - * locators in the configuration. Do this by enumerating the attribute - * hash table and emitting all the locators for each attribute. - */ -static int -emitlocs() -{ - struct nvlist *option; - char nbuf[BUFSIZ], obuf[BUFSIZ]; - char *tfname, *nfname; - const char *n; - int count, rval; - FILE *tfp = NULL, *nfp = NULL; - - tfname = "tmp_locators.h"; - if ((tfp = fopen(tfname, "w")) == NULL) { - (void)fprintf(stderr, "config: cannot write %s: %s\n", - tfname, strerror(errno)); - return (1); - } - - rval = ht_enumerate(attrtab, locators_print, tfp); - if (fclose(tfp) == EOF) - return(err("clos", tfname, NULL)); - - if ((tfp = fopen(tfname, "r")) == NULL) - goto moveit; - - /* - * Compare the new file to the old. - */ - nfname = "locators.h"; - if ((nfp = fopen(nfname, "r")) == NULL) - goto moveit; - - while (fgets(obuf, sizeof(obuf), tfp) != NULL) { - if (fgets(nbuf, sizeof(nbuf), nfp) == NULL) - goto moveit; - - if (strcmp(obuf, nbuf) != 0) - goto moveit; - } - (void) fclose(nfp); - (void) fclose(tfp); - if (remove(tfname) == -1) - return(err("remov", tfname, NULL)); - return (0); - -moveit: - /* - * They're different, or the file doesn't exist. - */ - if (nfp) - (void) fclose(nfp); - if (tfp) - (void) fclose(tfp); - if (rename(tfname, nfname) == -1) - return(err("renam", tfname, NULL)); - return (0); -} - static int err(what, fname, fp) const char *what; diff --git a/usr.sbin/config/mkioconf.c b/usr.sbin/config/mkioconf.c index 8913ff725f8..6403a9307d5 100644 --- a/usr.sbin/config/mkioconf.c +++ b/usr.sbin/config/mkioconf.c @@ -1,5 +1,5 @@ -/* $OpenBSD: mkioconf.c,v 1.11 1997/08/07 10:22:26 downsj Exp $ */ -/* $NetBSD: mkioconf.c,v 1.43 1997/03/14 22:54:08 jtk Exp $ */ +/* $OpenBSD: mkioconf.c,v 1.12 1997/08/07 10:36:58 deraadt Exp $ */ +/* $NetBSD: mkioconf.c,v 1.41 1996/11/11 14:18:49 mycroft Exp $ */ /* * Copyright (c) 1992, 1993 @@ -55,7 +55,6 @@ /* * Make ioconf.c. */ -static int cf_locnames_print __P((const char *, void *, void *)); static int cforder __P((const void *, const void *)); static int emitcfdata __P((FILE *)); static int emitexterns __P((FILE *)); @@ -176,34 +175,6 @@ emitexterns(fp) return (0); } -/* - * Emit an initialized array of character strings describing this - * attribute's locators. - */ -static int -cf_locnames_print(name, value, arg) - const char *name; - void *value; - void *arg; -{ - struct attr *a; - register struct nvlist *nv; - FILE *fp = arg; - - a = value; - if (a->a_locs) { - if (fprintf(fp, "const char *%scf_locnames[] = { ", name) < 0) - return (1); - for (nv = a->a_locs; nv; nv = nv->nv_next) { - if (fprintf(fp, "\"%s\", ", nv->nv_name) < 0) - return (1); - } - if (fprintf(fp, "NULL};\n") < 0) - return (1); - } - return 0; -} - static int emitloc(fp) register FILE *fp; @@ -216,10 +187,7 @@ static int loc[%d] = {", locators.used) < 0) for (i = 0; i < locators.used; i++) if (fprintf(fp, "%s%s,", SEP(i, 8), locators.vec[i]) < 0) return (1); - if (fprintf(fp, - "\n};\n\nconst char *nullcf_locnames[] = {NULL};\n") < 0) - return (1); - return ht_enumerate(attrtab, cf_locnames_print, fp); + return (fprintf(fp, "\n};\n") < 0); } static int nlocnames, maxlocnames = 8; @@ -387,8 +355,7 @@ emitcfdata(fp) #define DSTR FSTATE_DSTAR\n\ \n\ struct cfdata cfdata[] = {\n\ - /* attachment driver unit state loc flags parents nm ivstubs\n\ - locnames */\n") < 0) + /* attachment driver unit state loc flags parents nm ivstubs */\n") < 0) return (1); for (p = packed; (i = *p) != NULL; p++) { /* the description */ @@ -436,12 +403,11 @@ struct cfdata cfdata[] = {\n\ } else loc = "loc"; if (fprintf(fp, "\ - {&%s_ca,%s&%s_cd,%s%2d, %s, %7s, %#4x, pv+%2d, %d, %s%d,\n\ - %scf_locnames},\n", + {&%s_ca,%s&%s_cd,%s%2d, %s, %7s, %#4x, pv+%2d, %d, %s%d},\n", attachment, strlen(attachment) < 6 ? "\t\t" : "\t", basename, strlen(basename) < 3 ? "\t\t" : "\t", unit, state, loc, i->i_cfflags, i->i_pvoff, i->i_locnami, - vs, v, a->a_locs ? a->a_name : "null") < 0) + vs, v) < 0) return (1); } if (fprintf(fp, " {0},\n {0},\n {0},\n {0},\n") < 0) diff --git a/usr.sbin/config/sem.c b/usr.sbin/config/sem.c index 9f958f45b92..6bd7f02df1c 100644 --- a/usr.sbin/config/sem.c +++ b/usr.sbin/config/sem.c @@ -1,5 +1,5 @@ -/* $OpenBSD: sem.c,v 1.10 1997/08/07 10:22:27 downsj Exp $ */ -/* $NetBSD: sem.c,v 1.14 1997/03/14 20:43:05 leo Exp $ */ +/* $OpenBSD: sem.c,v 1.11 1997/08/07 10:36:59 deraadt Exp $ */ +/* $NetBSD: sem.c,v 1.10 1996/11/11 23:40:11 gwr Exp $ */ /* * Copyright (c) 1992, 1993 @@ -63,6 +63,7 @@ const char *s_generic; const char *s_nfs; static const char *s_qmark; +static struct hashtab *attrtab; /* for attribute lookup */ static struct hashtab *cfhashtab; /* for config lookup */ static struct hashtab *devitab; /* etc */ |