From 6d4b6f9d4bbb35d68e5424a14c2fcdf65385530a Mon Sep 17 00:00:00 2001 From: David Lawrence Date: Mon, 24 Apr 2000 22:53:41 +0000 Subject: [PATCH] added dns_c_ndcctx_getserver, minor style lint --- lib/dns/config/confndc.c | 35 ++++++++++++++++++++++++++++------- lib/dns/include/dns/confndc.h | 17 ++++++----------- 2 files changed, 34 insertions(+), 18 deletions(-) diff --git a/lib/dns/config/confndc.c b/lib/dns/config/confndc.c index 98cdaca264..912033160f 100644 --- a/lib/dns/config/confndc.c +++ b/lib/dns/config/confndc.c @@ -15,11 +15,11 @@ * SOFTWARE. */ -/* $Id: confndc.c,v 1.10 2000/04/18 00:18:37 gson Exp $ */ +/* $Id: confndc.c,v 1.11 2000/04/24 22:53:40 tale Exp $ */ /* ** options { -** [ default-server server_name; ] +** [ default-server server_name; ] ** [ default-key key_name; ] ** }; ** @@ -393,6 +393,30 @@ dns_c_ndcctx_addserver(dns_c_ndcctx_t *ctx, dns_c_ndcserver_t **server) { return (ISC_R_SUCCESS); } +isc_result_t +dns_c_ndcctx_getserver(dns_c_ndcctx_t *ctx, const char *name, + dns_c_ndcserver_t **server) +{ + dns_c_ndcserver_t *s; + + REQUIRE(DNS_C_NDCCTX_VALID(ctx)); + REQUIRE(name != NULL); + REQUIRE(server != NULL && *server == NULL); + + if (ctx->servers != NULL) { + for (s = ISC_LIST_HEAD(ctx->servers->list); s != NULL; + s = ISC_LIST_NEXT(s, next)) { + INSIST(s->name != NULL); + if (strcasecmp(s->name, name) == 0) { + *server = s; + return (ISC_R_SUCCESS); + } + } + } + + return (ISC_R_NOTFOUND); +} + isc_result_t dns_c_ndcctx_getkeys(dns_c_ndcctx_t *ctx, dns_c_kdeflist_t **keys) { REQUIRE(DNS_C_NDCCTX_VALID(ctx)); @@ -843,8 +867,7 @@ parse_file(ndcpcontext *pctx, dns_c_ndcctx_t **context) { } static isc_result_t -parse_statement(ndcpcontext *pctx) -{ +parse_statement(ndcpcontext *pctx) { isc_result_t result; dns_c_ndcctx_t *ctx = pctx->thecontext; dns_c_ndcopts_t *opts = NULL; @@ -1351,10 +1374,8 @@ eat_eos(ndcpcontext *pctx) { /* ************* PRIVATE STUFF ************ */ /* ************************************************** */ - static isc_result_t -parser_setup(ndcpcontext *pctx, isc_mem_t *mem, const char *filename) -{ +parser_setup(ndcpcontext *pctx, isc_mem_t *mem, const char *filename) { isc_result_t result; isc_lexspecials_t specials; struct keywordtoken *tok; diff --git a/lib/dns/include/dns/confndc.h b/lib/dns/include/dns/confndc.h index ffad87e87e..0351a83bbd 100644 --- a/lib/dns/include/dns/confndc.h +++ b/lib/dns/include/dns/confndc.h @@ -42,8 +42,7 @@ typedef struct dns_c_ndcserver dns_c_ndcserver_t; typedef struct dns_c_ndcserverlist dns_c_ndcserverlist_t; typedef struct dns_c_ndckey dnc_c_ndckey_t; -struct dns_c_ndcctx -{ +struct dns_c_ndcctx { isc_mem_t *mem; isc_uint32_t magic; @@ -52,8 +51,7 @@ struct dns_c_ndcctx dns_c_kdeflist_t *keys; }; -struct dns_c_ndcopts -{ +struct dns_c_ndcopts { isc_mem_t *mem; isc_uint32_t magic; @@ -61,18 +59,14 @@ struct dns_c_ndcopts char *defkey; }; -struct dns_c_ndcserverlist -{ +struct dns_c_ndcserverlist { isc_mem_t *mem; isc_uint32_t magic; ISC_LIST(dns_c_ndcserver_t) list; }; - - -struct dns_c_ndcserver -{ +struct dns_c_ndcserver { isc_mem_t *mem; isc_uint32_t magic; @@ -82,7 +76,6 @@ struct dns_c_ndcserver ISC_LINK(dns_c_ndcserver_t) next; }; - /* All the 'set' functions do not delete the replaced value if one exists, * so if setting a value for a second time, be sure to 'get' the original * value first and do something with it @@ -100,6 +93,8 @@ isc_result_t dns_c_ndcctx_getservers(dns_c_ndcctx_t *ctx, dns_c_ndcserverlist_t **servers); isc_result_t dns_c_ndcctx_addserver(dns_c_ndcctx_t *ctx, dns_c_ndcserver_t **server); +isc_result_t dns_c_ndcctx_getserver(dns_c_ndcctx_t *ctx, const char *name, + dns_c_ndcserver_t **server); isc_result_t dns_c_ndcctx_getkeys(dns_c_ndcctx_t *ctx, dns_c_kdeflist_t **list); isc_result_t dns_c_ndcctx_setkeys(dns_c_ndcctx_t *ctx,