diff --git a/lib/isccfg/include/isccfg/cfg.h b/lib/isccfg/include/isccfg/cfg.h index f0a0a8e090..bdea2e7517 100644 --- a/lib/isccfg/include/isccfg/cfg.h +++ b/lib/isccfg/include/isccfg/cfg.h @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: cfg.h,v 1.8 2001/02/22 01:40:53 bwelling Exp $ */ +/* $Id: cfg.h,v 1.9 2001/02/22 04:17:37 gson Exp $ */ #ifndef DNS_CFG_H #define DNS_CFG_H 1 @@ -167,6 +167,18 @@ cfg_map_getname(cfg_obj_t *mapobj); * or NULL if the map object does not have a name. */ +cfg_obj_t * +cfg_tuple_get(cfg_obj_t *tupleobj, const char* name); +/* + * Extract an element from a configuration object, which + * must be of a tuple type. + * + * Requires: + * 'tupleobj' ponts to a valid configuraration object of a tuple type. + * 'name' points to a null-terminated string naming one of the + * fields of said tuple type. + */ + isc_uint32_t cfg_obj_asuint32(cfg_obj_t *obj); /* diff --git a/lib/isccfg/parser.c b/lib/isccfg/parser.c index b12ac48c4a..84c85d7ab4 100644 --- a/lib/isccfg/parser.c +++ b/lib/isccfg/parser.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: parser.c,v 1.15 2001/02/22 03:13:08 gson Exp $ */ +/* $Id: parser.c,v 1.16 2001/02/22 04:17:36 gson Exp $ */ #include @@ -1133,6 +1133,26 @@ free_tuple(cfg_parser_t *pctx, cfg_obj_t *obj) { nfields * sizeof(cfg_obj_t *)); } +cfg_obj_t * +cfg_tuple_get(cfg_obj_t *tupleobj, const char* name) { + unsigned int i; + cfg_tuplefielddef_t *fields; + cfg_tuplefielddef_t *f; + + REQUIRE(tupleobj != NULL && tupleobj->type->rep == &cfg_rep_tuple); + + fields = tupleobj->type->of; + for (f = fields, i = 0; f->name != NULL; f++, i++) { + if (strcmp(f->name, name) == 0) + return (tupleobj->value.tuple[i]); + } + INSIST(0); + return (NULL); +} + +/* + * Parse a required special character. + */ static isc_result_t parse_special(cfg_parser_t *pctx, int special) { isc_result_t result;