Commit 47af71b5 authored by Andreas Gustafsson's avatar Andreas Gustafsson

use token.value.as_textregion.base, not token.value.pointer

parent 15033eed
......@@ -15,7 +15,7 @@
* 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>
......@@ -30,6 +30,8 @@
#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); \
......@@ -420,7 +422,7 @@ parse_qstringornone(cfg_parser_t *pctx, const cfg_type_t *type,
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));
......@@ -825,7 +827,7 @@ parse_sizeval(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **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;
......@@ -881,7 +883,7 @@ parse_maybe_optional_keyvalue(cfg_parser_t *pctx, const cfg_type_t *type,
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 */
......@@ -907,7 +909,7 @@ parse_enum_or_other(cfg_parser_t *pctx, const cfg_type_t *enumtype,
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));
......@@ -1086,19 +1088,22 @@ parse_querysource(cfg_parser_t *pctx, int flags, cfg_obj_t **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,
......@@ -1169,7 +1174,7 @@ parse_addrmatchelt(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret)
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 |
......@@ -1334,7 +1339,7 @@ parse_logseverity(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
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) {
......@@ -1398,12 +1403,12 @@ parse_logfile(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
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,
......
......@@ -15,7 +15,7 @@
* 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>
......@@ -43,6 +43,8 @@
#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); \
......@@ -692,7 +694,7 @@ cfg_parse_qstring(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
return (ISC_R_UNEXPECTEDTOKEN);
}
return (create_string(pctx,
pctx->token.value.as_pointer,
TOKEN_STRING(pctx),
&cfg_type_qstring,
ret));
cleanup:
......@@ -710,7 +712,7 @@ parse_ustring(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
return (ISC_R_UNEXPECTEDTOKEN);
}
return (create_string(pctx,
pctx->token.value.as_pointer,
TOKEN_STRING(pctx),
&cfg_type_ustring,
ret));
cleanup:
......@@ -724,7 +726,7 @@ cfg_parse_astring(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
CHECK(cfg_getstringtoken(pctx));
return (create_string(pctx,
pctx->token.value.as_pointer,
TOKEN_STRING(pctx),
&cfg_type_qstring,
ret));
cleanup:
......@@ -854,13 +856,13 @@ parse_boolean(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret)
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;
......@@ -1155,7 +1157,7 @@ cfg_parse_mapbody(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret)
* 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
......@@ -1174,7 +1176,7 @@ cfg_parse_mapbody(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret)
for (clause = *clauseset;
clause->name != NULL;
clause++) {
if (strcasecmp(pctx->token.value.as_pointer,
if (strcasecmp(TOKEN_STRING(pctx),
clause->name) == 0)
goto done;
}
......@@ -1628,7 +1630,7 @@ token_addr(cfg_parser_t *pctx, unsigned int flags, isc_netaddr_t *na) {
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);
......@@ -1697,7 +1699,7 @@ cfg_parse_rawport(cfg_parser_t *pctx, unsigned int flags, in_port_t *port) {
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);
}
......@@ -1755,14 +1757,17 @@ cfg_type_t cfg_type_netaddr = {
/* 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;
......@@ -1844,7 +1849,7 @@ parse_sockaddrsub(cfg_parser_t *pctx, const cfg_type_t *type,
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));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment