mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-03 08:05:21 +00:00
use token.value.as_textregion.base, not token.value.pointer
This commit is contained in:
@@ -15,7 +15,7 @@
|
|||||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* 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 <config.h>
|
||||||
|
|
||||||
@@ -30,6 +30,8 @@
|
|||||||
#include <isccfg/grammar.h>
|
#include <isccfg/grammar.h>
|
||||||
#include <isccfg/log.h>
|
#include <isccfg/log.h>
|
||||||
|
|
||||||
|
#define TOKEN_STRING(pctx) (pctx->token.value.as_textregion.base)
|
||||||
|
|
||||||
/* Check a return value. */
|
/* Check a return value. */
|
||||||
#define CHECK(op) \
|
#define CHECK(op) \
|
||||||
do { result = (op); \
|
do { result = (op); \
|
||||||
@@ -420,7 +422,7 @@ parse_qstringornone(cfg_parser_t *pctx, const cfg_type_t *type,
|
|||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
CHECK(cfg_gettoken(pctx, CFG_LEXOPT_QSTRING));
|
CHECK(cfg_gettoken(pctx, CFG_LEXOPT_QSTRING));
|
||||||
if (pctx->token.type == isc_tokentype_string &&
|
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));
|
return (cfg_create_obj(pctx, &cfg_type_none, ret));
|
||||||
cfg_ungettoken(pctx);
|
cfg_ungettoken(pctx);
|
||||||
return (cfg_parse_qstring(pctx, type, ret));
|
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);
|
UNUSED(type);
|
||||||
|
|
||||||
CHECK(cfg_gettoken(pctx, 0));
|
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));
|
CHECK(cfg_create_obj(pctx, &cfg_type_uint64, &obj));
|
||||||
obj->value.uint64 = val;
|
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));
|
CHECK(cfg_peektoken(pctx, 0));
|
||||||
if (pctx->token.type == isc_tokentype_string &&
|
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(cfg_gettoken(pctx, 0));
|
||||||
CHECK(kw->type->parse(pctx, kw->type, &obj));
|
CHECK(kw->type->parse(pctx, kw->type, &obj));
|
||||||
obj->type = type; /* XXX kludge */
|
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;
|
isc_result_t result;
|
||||||
CHECK(cfg_peektoken(pctx, 0));
|
CHECK(cfg_peektoken(pctx, 0));
|
||||||
if (pctx->token.type == isc_tokentype_string &&
|
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));
|
CHECK(cfg_parse_enum(pctx, enumtype, ret));
|
||||||
} else {
|
} else {
|
||||||
CHECK(cfg_parse_obj(pctx, othertype, ret));
|
CHECK(cfg_parse_obj(pctx, othertype, ret));
|
||||||
@@ -1086,19 +1088,22 @@ parse_querysource(cfg_parser_t *pctx, int flags, cfg_obj_t **ret) {
|
|||||||
for (;;) {
|
for (;;) {
|
||||||
CHECK(cfg_peektoken(pctx, 0));
|
CHECK(cfg_peektoken(pctx, 0));
|
||||||
if (pctx->token.type == isc_tokentype_string) {
|
if (pctx->token.type == isc_tokentype_string) {
|
||||||
if (strcasecmp(pctx->token.value.as_pointer,
|
if (strcasecmp(TOKEN_STRING(pctx),
|
||||||
"address") == 0)
|
"address") == 0)
|
||||||
{
|
{
|
||||||
/* read "address" */
|
/* read "address" */
|
||||||
CHECK(cfg_gettoken(pctx, 0));
|
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++;
|
have_address++;
|
||||||
} else if (strcasecmp(pctx->token.value.as_pointer,
|
} else if (strcasecmp(TOKEN_STRING(pctx), "port") == 0)
|
||||||
"port") == 0)
|
|
||||||
{
|
{
|
||||||
/* read "port" */
|
/* read "port" */
|
||||||
CHECK(cfg_gettoken(pctx, 0));
|
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++;
|
have_port++;
|
||||||
} else {
|
} else {
|
||||||
cfg_parser_error(pctx, CFG_LOG_NEAR,
|
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 ||
|
if (pctx->token.type == isc_tokentype_string ||
|
||||||
pctx->token.type == isc_tokentype_qstring) {
|
pctx->token.type == isc_tokentype_qstring) {
|
||||||
if (pctx->token.type == isc_tokentype_string &&
|
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));
|
CHECK(cfg_parse_obj(pctx, &cfg_type_keyref, ret));
|
||||||
} else {
|
} else {
|
||||||
if (cfg_lookingat_netaddr(pctx, CFG_ADDR_V4OK |
|
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));
|
CHECK(cfg_peektoken(pctx, 0));
|
||||||
if (pctx->token.type == isc_tokentype_string &&
|
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_gettoken(pctx, 0)); /* read "debug" */
|
||||||
CHECK(cfg_peektoken(pctx, ISC_LEXOPT_NUMBER));
|
CHECK(cfg_peektoken(pctx, ISC_LEXOPT_NUMBER));
|
||||||
if (pctx->token.type == isc_tokentype_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));
|
CHECK(cfg_peektoken(pctx, 0));
|
||||||
if (pctx->token.type == isc_tokentype_string) {
|
if (pctx->token.type == isc_tokentype_string) {
|
||||||
CHECK(cfg_gettoken(pctx, 0));
|
CHECK(cfg_gettoken(pctx, 0));
|
||||||
if (strcasecmp(pctx->token.value.as_pointer,
|
if (strcasecmp(TOKEN_STRING(pctx),
|
||||||
"versions") == 0 &&
|
"versions") == 0 &&
|
||||||
obj->value.tuple[1] == NULL) {
|
obj->value.tuple[1] == NULL) {
|
||||||
CHECK(cfg_parse_obj(pctx, fields[1].type,
|
CHECK(cfg_parse_obj(pctx, fields[1].type,
|
||||||
&obj->value.tuple[1]));
|
&obj->value.tuple[1]));
|
||||||
} else if (strcasecmp(pctx->token.value.as_pointer,
|
} else if (strcasecmp(TOKEN_STRING(pctx),
|
||||||
"size") == 0 &&
|
"size") == 0 &&
|
||||||
obj->value.tuple[2] == NULL) {
|
obj->value.tuple[2] == NULL) {
|
||||||
CHECK(cfg_parse_obj(pctx, fields[2].type,
|
CHECK(cfg_parse_obj(pctx, fields[2].type,
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* 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>
|
#include <config.h>
|
||||||
|
|
||||||
@@ -43,6 +43,8 @@
|
|||||||
|
|
||||||
#define MAP_SYM 1 /* Unique type for isc_symtab */
|
#define MAP_SYM 1 /* Unique type for isc_symtab */
|
||||||
|
|
||||||
|
#define TOKEN_STRING(pctx) (pctx->token.value.as_textregion.base)
|
||||||
|
|
||||||
/* Check a return value. */
|
/* Check a return value. */
|
||||||
#define CHECK(op) \
|
#define CHECK(op) \
|
||||||
do { result = (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 (ISC_R_UNEXPECTEDTOKEN);
|
||||||
}
|
}
|
||||||
return (create_string(pctx,
|
return (create_string(pctx,
|
||||||
pctx->token.value.as_pointer,
|
TOKEN_STRING(pctx),
|
||||||
&cfg_type_qstring,
|
&cfg_type_qstring,
|
||||||
ret));
|
ret));
|
||||||
cleanup:
|
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 (ISC_R_UNEXPECTEDTOKEN);
|
||||||
}
|
}
|
||||||
return (create_string(pctx,
|
return (create_string(pctx,
|
||||||
pctx->token.value.as_pointer,
|
TOKEN_STRING(pctx),
|
||||||
&cfg_type_ustring,
|
&cfg_type_ustring,
|
||||||
ret));
|
ret));
|
||||||
cleanup:
|
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));
|
CHECK(cfg_getstringtoken(pctx));
|
||||||
return (create_string(pctx,
|
return (create_string(pctx,
|
||||||
pctx->token.value.as_pointer,
|
TOKEN_STRING(pctx),
|
||||||
&cfg_type_qstring,
|
&cfg_type_qstring,
|
||||||
ret));
|
ret));
|
||||||
cleanup:
|
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)
|
if (pctx->token.type != isc_tokentype_string)
|
||||||
goto bad_boolean;
|
goto bad_boolean;
|
||||||
|
|
||||||
if ((strcasecmp(pctx->token.value.as_pointer, "true") == 0) ||
|
if ((strcasecmp(TOKEN_STRING(pctx), "true") == 0) ||
|
||||||
(strcasecmp(pctx->token.value.as_pointer, "yes") == 0) ||
|
(strcasecmp(TOKEN_STRING(pctx), "yes") == 0) ||
|
||||||
(strcmp(pctx->token.value.as_pointer, "1") == 0)) {
|
(strcmp(TOKEN_STRING(pctx), "1") == 0)) {
|
||||||
value = ISC_TRUE;
|
value = ISC_TRUE;
|
||||||
} else if ((strcasecmp(pctx->token.value.as_pointer, "false") == 0) ||
|
} else if ((strcasecmp(TOKEN_STRING(pctx), "false") == 0) ||
|
||||||
(strcasecmp(pctx->token.value.as_pointer, "no") == 0) ||
|
(strcasecmp(TOKEN_STRING(pctx), "no") == 0) ||
|
||||||
(strcmp(pctx->token.value.as_pointer, "0") == 0)) {
|
(strcmp(TOKEN_STRING(pctx), "0") == 0)) {
|
||||||
value = ISC_FALSE;
|
value = ISC_FALSE;
|
||||||
} else {
|
} else {
|
||||||
goto bad_boolean;
|
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
|
* We accept "include" statements wherever a map body
|
||||||
* clause can occur.
|
* 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
|
* Turn the file name into a temporary configuration
|
||||||
* object just so that it is not overwritten by the
|
* 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;
|
for (clause = *clauseset;
|
||||||
clause->name != NULL;
|
clause->name != NULL;
|
||||||
clause++) {
|
clause++) {
|
||||||
if (strcasecmp(pctx->token.value.as_pointer,
|
if (strcasecmp(TOKEN_STRING(pctx),
|
||||||
clause->name) == 0)
|
clause->name) == 0)
|
||||||
goto done;
|
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)
|
if (pctx->token.type != isc_tokentype_string)
|
||||||
return (ISC_R_UNEXPECTEDTOKEN);
|
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_WILDOK) != 0 && strcmp(s, "*") == 0) {
|
||||||
if ((flags & CFG_ADDR_V4OK) != 0) {
|
if ((flags & CFG_ADDR_V4OK) != 0) {
|
||||||
isc_netaddr_any(na);
|
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 &&
|
if ((flags & CFG_ADDR_WILDOK) != 0 &&
|
||||||
pctx->token.type == isc_tokentype_string &&
|
pctx->token.type == isc_tokentype_string &&
|
||||||
strcmp(pctx->token.value.as_pointer, "*") == 0) {
|
strcmp(TOKEN_STRING(pctx), "*") == 0) {
|
||||||
*port = 0;
|
*port = 0;
|
||||||
return (ISC_R_SUCCESS);
|
return (ISC_R_SUCCESS);
|
||||||
}
|
}
|
||||||
@@ -1755,14 +1757,17 @@ cfg_type_t cfg_type_netaddr = {
|
|||||||
/* netprefix */
|
/* netprefix */
|
||||||
|
|
||||||
isc_result_t
|
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;
|
cfg_obj_t *obj = NULL;
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
isc_netaddr_t netaddr;
|
isc_netaddr_t netaddr;
|
||||||
unsigned int addrlen, prefixlen;
|
unsigned int addrlen, prefixlen;
|
||||||
UNUSED(type);
|
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) {
|
switch (netaddr.family) {
|
||||||
case AF_INET:
|
case AF_INET:
|
||||||
addrlen = 32;
|
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_parse_rawaddr(pctx, flags, &netaddr));
|
||||||
CHECK(cfg_peektoken(pctx, 0));
|
CHECK(cfg_peektoken(pctx, 0));
|
||||||
if (pctx->token.type == isc_tokentype_string &&
|
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_gettoken(pctx, 0)); /* read "port" */
|
||||||
CHECK(cfg_parse_rawport(pctx, flags, &port));
|
CHECK(cfg_parse_rawport(pctx, flags, &port));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user