* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: namedconf.c,v 1.2 2002/01/21 11:00:25 bwelling Exp $ */
+/* $Id: namedconf.c,v 1.3 2002/01/22 19:31:56 gson Exp $ */
#include <config.h>
#include <isccfg/grammar.h>
#include <isccfg/log.h>
+#define TOKEN_STRING(pctx) (pctx->token.value.as_textregion.base)
+
/* Check a return value. */
#define CHECK(op) \
do { result = (op); \
isc_result_t result;
CHECK(cfg_gettoken(pctx, CFG_LEXOPT_QSTRING));
if (pctx->token.type == isc_tokentype_string &&
- strcasecmp(pctx->token.value.as_pointer, "none") == 0)
+ strcasecmp(TOKEN_STRING(pctx), "none") == 0)
return (cfg_create_obj(pctx, &cfg_type_none, ret));
cfg_ungettoken(pctx);
return (cfg_parse_qstring(pctx, type, ret));
UNUSED(type);
CHECK(cfg_gettoken(pctx, 0));
- CHECK(parse_unitstring(pctx->token.value.as_pointer, &val));
+ CHECK(parse_unitstring(TOKEN_STRING(pctx), &val));
CHECK(cfg_create_obj(pctx, &cfg_type_uint64, &obj));
obj->value.uint64 = val;
CHECK(cfg_peektoken(pctx, 0));
if (pctx->token.type == isc_tokentype_string &&
- strcasecmp(pctx->token.value.as_pointer, kw->name) == 0) {
+ strcasecmp(TOKEN_STRING(pctx), kw->name) == 0) {
CHECK(cfg_gettoken(pctx, 0));
CHECK(kw->type->parse(pctx, kw->type, &obj));
obj->type = type; /* XXX kludge */
isc_result_t result;
CHECK(cfg_peektoken(pctx, 0));
if (pctx->token.type == isc_tokentype_string &&
- cfg_is_enum(pctx->token.value.as_pointer, enumtype->of)) {
+ cfg_is_enum(TOKEN_STRING(pctx), enumtype->of)) {
CHECK(cfg_parse_enum(pctx, enumtype, ret));
} else {
CHECK(cfg_parse_obj(pctx, othertype, ret));
for (;;) {
CHECK(cfg_peektoken(pctx, 0));
if (pctx->token.type == isc_tokentype_string) {
- if (strcasecmp(pctx->token.value.as_pointer,
+ if (strcasecmp(TOKEN_STRING(pctx),
"address") == 0)
{
/* read "address" */
CHECK(cfg_gettoken(pctx, 0));
- CHECK(cfg_parse_rawaddr(pctx, flags|CFG_ADDR_WILDOK, &netaddr));
+ CHECK(cfg_parse_rawaddr(pctx,
+ flags | CFG_ADDR_WILDOK,
+ &netaddr));
have_address++;
- } else if (strcasecmp(pctx->token.value.as_pointer,
- "port") == 0)
+ } else if (strcasecmp(TOKEN_STRING(pctx), "port") == 0)
{
/* read "port" */
CHECK(cfg_gettoken(pctx, 0));
- CHECK(cfg_parse_rawport(pctx, CFG_ADDR_WILDOK, &port));
+ CHECK(cfg_parse_rawport(pctx,
+ CFG_ADDR_WILDOK,
+ &port));
have_port++;
} else {
cfg_parser_error(pctx, CFG_LOG_NEAR,
if (pctx->token.type == isc_tokentype_string ||
pctx->token.type == isc_tokentype_qstring) {
if (pctx->token.type == isc_tokentype_string &&
- (strcasecmp(pctx->token.value.as_pointer, "key") == 0)) {
+ (strcasecmp(TOKEN_STRING(pctx), "key") == 0)) {
CHECK(cfg_parse_obj(pctx, &cfg_type_keyref, ret));
} else {
if (cfg_lookingat_netaddr(pctx, CFG_ADDR_V4OK |
CHECK(cfg_peektoken(pctx, 0));
if (pctx->token.type == isc_tokentype_string &&
- strcasecmp(pctx->token.value.as_pointer, "debug") == 0) {
+ strcasecmp(TOKEN_STRING(pctx), "debug") == 0) {
CHECK(cfg_gettoken(pctx, 0)); /* read "debug" */
CHECK(cfg_peektoken(pctx, ISC_LEXOPT_NUMBER));
if (pctx->token.type == isc_tokentype_number) {
CHECK(cfg_peektoken(pctx, 0));
if (pctx->token.type == isc_tokentype_string) {
CHECK(cfg_gettoken(pctx, 0));
- if (strcasecmp(pctx->token.value.as_pointer,
+ if (strcasecmp(TOKEN_STRING(pctx),
"versions") == 0 &&
obj->value.tuple[1] == NULL) {
CHECK(cfg_parse_obj(pctx, fields[1].type,
&obj->value.tuple[1]));
- } else if (strcasecmp(pctx->token.value.as_pointer,
+ } else if (strcasecmp(TOKEN_STRING(pctx),
"size") == 0 &&
obj->value.tuple[2] == NULL) {
CHECK(cfg_parse_obj(pctx, fields[2].type,
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: parser.c,v 1.98 2002/01/04 06:19:20 marka Exp $ */
+/* $Id: parser.c,v 1.99 2002/01/22 19:31:57 gson Exp $ */
#include <config.h>
#define MAP_SYM 1 /* Unique type for isc_symtab */
+#define TOKEN_STRING(pctx) (pctx->token.value.as_textregion.base)
+
/* Check a return value. */
#define CHECK(op) \
do { result = (op); \
return (ISC_R_UNEXPECTEDTOKEN);
}
return (create_string(pctx,
- pctx->token.value.as_pointer,
+ TOKEN_STRING(pctx),
&cfg_type_qstring,
ret));
cleanup:
return (ISC_R_UNEXPECTEDTOKEN);
}
return (create_string(pctx,
- pctx->token.value.as_pointer,
+ TOKEN_STRING(pctx),
&cfg_type_ustring,
ret));
cleanup:
CHECK(cfg_getstringtoken(pctx));
return (create_string(pctx,
- pctx->token.value.as_pointer,
+ TOKEN_STRING(pctx),
&cfg_type_qstring,
ret));
cleanup:
if (pctx->token.type != isc_tokentype_string)
goto bad_boolean;
- if ((strcasecmp(pctx->token.value.as_pointer, "true") == 0) ||
- (strcasecmp(pctx->token.value.as_pointer, "yes") == 0) ||
- (strcmp(pctx->token.value.as_pointer, "1") == 0)) {
+ if ((strcasecmp(TOKEN_STRING(pctx), "true") == 0) ||
+ (strcasecmp(TOKEN_STRING(pctx), "yes") == 0) ||
+ (strcmp(TOKEN_STRING(pctx), "1") == 0)) {
value = ISC_TRUE;
- } else if ((strcasecmp(pctx->token.value.as_pointer, "false") == 0) ||
- (strcasecmp(pctx->token.value.as_pointer, "no") == 0) ||
- (strcmp(pctx->token.value.as_pointer, "0") == 0)) {
+ } else if ((strcasecmp(TOKEN_STRING(pctx), "false") == 0) ||
+ (strcasecmp(TOKEN_STRING(pctx), "no") == 0) ||
+ (strcmp(TOKEN_STRING(pctx), "0") == 0)) {
value = ISC_FALSE;
} else {
goto bad_boolean;
* We accept "include" statements wherever a map body
* clause can occur.
*/
- if (strcasecmp(pctx->token.value.as_pointer, "include") == 0) {
+ if (strcasecmp(TOKEN_STRING(pctx), "include") == 0) {
/*
* Turn the file name into a temporary configuration
* object just so that it is not overwritten by the
for (clause = *clauseset;
clause->name != NULL;
clause++) {
- if (strcasecmp(pctx->token.value.as_pointer,
+ if (strcasecmp(TOKEN_STRING(pctx),
clause->name) == 0)
goto done;
}
if (pctx->token.type != isc_tokentype_string)
return (ISC_R_UNEXPECTEDTOKEN);
- s = pctx->token.value.as_pointer;
+ s = TOKEN_STRING(pctx);
if ((flags & CFG_ADDR_WILDOK) != 0 && strcmp(s, "*") == 0) {
if ((flags & CFG_ADDR_V4OK) != 0) {
isc_netaddr_any(na);
if ((flags & CFG_ADDR_WILDOK) != 0 &&
pctx->token.type == isc_tokentype_string &&
- strcmp(pctx->token.value.as_pointer, "*") == 0) {
+ strcmp(TOKEN_STRING(pctx), "*") == 0) {
*port = 0;
return (ISC_R_SUCCESS);
}
/* netprefix */
isc_result_t
-cfg_parse_netprefix(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
+cfg_parse_netprefix(cfg_parser_t *pctx, const cfg_type_t *type,
+ cfg_obj_t **ret)
+{
cfg_obj_t *obj = NULL;
isc_result_t result;
isc_netaddr_t netaddr;
unsigned int addrlen, prefixlen;
UNUSED(type);
- CHECK(cfg_parse_rawaddr(pctx, CFG_ADDR_V4OK | CFG_ADDR_V4PREFIXOK | CFG_ADDR_V6OK, &netaddr));
+ CHECK(cfg_parse_rawaddr(pctx, CFG_ADDR_V4OK | CFG_ADDR_V4PREFIXOK |
+ CFG_ADDR_V6OK, &netaddr));
switch (netaddr.family) {
case AF_INET:
addrlen = 32;
CHECK(cfg_parse_rawaddr(pctx, flags, &netaddr));
CHECK(cfg_peektoken(pctx, 0));
if (pctx->token.type == isc_tokentype_string &&
- strcasecmp(pctx->token.value.as_pointer, "port") == 0) {
+ strcasecmp(TOKEN_STRING(pctx), "port") == 0) {
CHECK(cfg_gettoken(pctx, 0)); /* read "port" */
CHECK(cfg_parse_rawport(pctx, flags, &port));
}