const correctness [RT #1011]

This commit is contained in:
Andreas Gustafsson 2001-07-23 00:23:30 +00:00
parent 75b3a86c57
commit 33654a83db
2 changed files with 121 additions and 119 deletions

View file

@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: cfg.h,v 1.25 2001/06/29 18:36:12 gson Exp $ */
/* $Id: cfg.h,v 1.26 2001/07/23 00:23:30 gson Exp $ */
#ifndef ISCCFG_CFG_H
#define ISCCFG_CFG_H 1
@ -110,10 +110,10 @@ cfg_parser_setcallback(cfg_parser_t *pctx,
isc_result_t
cfg_parse_file(cfg_parser_t *pctx, const char *filename,
cfg_type_t *type, cfg_obj_t **ret);
const cfg_type_t *type, cfg_obj_t **ret);
isc_result_t
cfg_parse_buffer(cfg_parser_t *pctx, isc_buffer_t *buffer,
cfg_type_t *type, cfg_obj_t **ret);
const cfg_type_t *type, cfg_obj_t **ret);
/*
* Read a configuration containing data of type 'type'
* and make '*ret' point to its parse tree.
@ -371,7 +371,7 @@ cfg_print(cfg_obj_t *obj,
*/
void
cfg_print_grammar(cfg_type_t *type,
cfg_print_grammar(const cfg_type_t *type,
void (*f)(void *closure, const char *text, int textlen),
void *closure);
/*
@ -379,7 +379,7 @@ cfg_print_grammar(cfg_type_t *type,
*/
isc_boolean_t
cfg_obj_istype(cfg_obj_t *obj, cfg_type_t *type);
cfg_obj_istype(cfg_obj_t *obj, const cfg_type_t *type);
/*
* Return true iff 'obj' is of type 'type'.
*/

View file

@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: parser.c,v 1.62 2001/07/06 20:34:12 gson Exp $ */
/* $Id: parser.c,v 1.63 2001/07/23 00:23:29 gson Exp $ */
#include <config.h>
@ -99,7 +99,7 @@ typedef struct cfg_rep cfg_rep_t;
* Function types for configuration object methods
*/
typedef isc_result_t (*cfg_parsefunc_t)(cfg_parser_t *, cfg_type_t *type,
typedef isc_result_t (*cfg_parsefunc_t)(cfg_parser_t *, const cfg_type_t *type,
cfg_obj_t **);
typedef void (*cfg_printfunc_t)(cfg_printer_t *, cfg_obj_t *);
typedef void (*cfg_freefunc_t)(cfg_parser_t *, cfg_obj_t *);
@ -188,20 +188,21 @@ struct cfg_type {
cfg_parsefunc_t parse;
cfg_printfunc_t print;
cfg_rep_t * rep; /* Data representation */
void * of; /* For meta-types */
const void * of; /* For meta-types */
};
/* A keyword-type definition, for things like "port <integer>". */
typedef struct {
const char *name;
cfg_type_t *type;
const cfg_type_t *type;
} keyword_type_t;
struct cfg_map {
cfg_obj_t *id; /* Used for 'named maps' like keys, zones, &c */
cfg_clausedef_t **clausesets; /* The clauses that can occur in
this map; used for printing */
const cfg_clausedef_t * const *clausesets; /* The clauses that
can occur in this map;
used for printing */
isc_symtab_t *symtab;
};
@ -226,7 +227,7 @@ struct cfg_rep {
*/
struct cfg_obj {
cfg_type_t * type;
const cfg_type_t *type;
union {
isc_uint32_t uint32;
isc_uint64_t uint64;
@ -255,10 +256,10 @@ struct cfg_listelt {
*/
static isc_result_t
create_cfgobj(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **objp);
create_cfgobj(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **objp);
static isc_result_t
create_list(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **objp);
create_list(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **objp);
static isc_result_t
create_listelt(cfg_parser_t *pctx, cfg_listelt_t **eltp);
@ -267,17 +268,17 @@ static void
free_list(cfg_parser_t *pctx, cfg_obj_t *obj);
static isc_result_t
create_string(cfg_parser_t *pctx, const char *contents, cfg_type_t *type,
create_string(cfg_parser_t *pctx, const char *contents, const cfg_type_t *type,
cfg_obj_t **ret);
static void
free_string(cfg_parser_t *pctx, cfg_obj_t *obj);
static isc_result_t
create_map(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **objp);
create_map(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **objp);
static isc_result_t
create_tuple(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **objp);
create_tuple(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **objp);
static void
free_map(cfg_parser_t *pctx, cfg_obj_t *obj);
@ -292,35 +293,35 @@ static void
print_void(cfg_printer_t *pctx, cfg_obj_t *obj);
static isc_result_t
parse_enum_or_other(cfg_parser_t *pctx, cfg_type_t *enumtype,
cfg_type_t *othertype, cfg_obj_t **ret);
parse_enum_or_other(cfg_parser_t *pctx, const cfg_type_t *enumtype,
const cfg_type_t *othertype, cfg_obj_t **ret);
static isc_result_t
parse_mapbody(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret);
parse_mapbody(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret);
static void
print_mapbody(cfg_printer_t *pctx, cfg_obj_t *obj);
static isc_result_t
parse_map(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret);
parse_map(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret);
static void
print_map(cfg_printer_t *pctx, cfg_obj_t *obj);
static isc_result_t
parse_named_map(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret);
parse_named_map(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret);
static isc_result_t
parse_addressed_map(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret);
parse_addressed_map(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret);
static isc_result_t
parse_list(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret);
parse_list(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret);
static void
print_list(cfg_printer_t *pctx, cfg_obj_t *obj);
static isc_result_t
parse_tuple(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret);
parse_tuple(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret);
static void
print_tuple(cfg_printer_t *pctx, cfg_obj_t *obj);
@ -329,7 +330,7 @@ static void
free_tuple(cfg_parser_t *pctx, cfg_obj_t *obj);
static isc_result_t
parse_spacelist(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret);
parse_spacelist(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret);
static void
print_spacelist(cfg_printer_t *pctx, cfg_obj_t *obj);
@ -338,19 +339,19 @@ static void
print_sockaddr(cfg_printer_t *pctx, cfg_obj_t *obj);
static isc_result_t
parse_addrmatchelt(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret);
parse_addrmatchelt(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret);
static isc_result_t
parse_bracketed_list(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret);
parse_bracketed_list(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret);
static void
print_bracketed_list(cfg_printer_t *pctx, cfg_obj_t *obj);
static isc_result_t
parse_keyvalue(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret);
parse_keyvalue(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret);
static isc_result_t
parse_optional_keyvalue(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret);
parse_optional_keyvalue(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret);
static void
print_keyvalue(cfg_printer_t *pctx, cfg_obj_t *obj);
@ -394,7 +395,7 @@ static void
print_ustring(cfg_printer_t *pctx, cfg_obj_t *obj);
static isc_result_t
parse_enum(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret);
parse_enum(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret);
/*
* Data representations. These correspond to members of the
@ -1146,7 +1147,7 @@ print_close(cfg_printer_t *pctx) {
}
static isc_result_t
parse(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret) {
parse(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
isc_result_t result;
INSIST(ret != NULL && *ret == NULL);
result = type->parse(pctx, type, ret);
@ -1172,10 +1173,10 @@ cfg_print(cfg_obj_t *obj,
/* Tuples. */
static isc_result_t
create_tuple(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret) {
create_tuple(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
isc_result_t result;
cfg_tuplefielddef_t *fields = type->of;
cfg_tuplefielddef_t *f;
const cfg_tuplefielddef_t *fields = type->of;
const cfg_tuplefielddef_t *f;
cfg_obj_t *obj = NULL;
unsigned int nfields = 0;
int i;
@ -1201,11 +1202,11 @@ create_tuple(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret) {
}
static isc_result_t
parse_tuple(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret)
parse_tuple(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret)
{
isc_result_t result;
cfg_tuplefielddef_t *fields = type->of;
cfg_tuplefielddef_t *f;
const cfg_tuplefielddef_t *fields = type->of;
const cfg_tuplefielddef_t *f;
cfg_obj_t *obj = NULL;
unsigned int i;
@ -1224,8 +1225,8 @@ parse_tuple(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret)
static void
print_tuple(cfg_printer_t *pctx, cfg_obj_t *obj) {
unsigned int i;
cfg_tuplefielddef_t *fields = obj->type->of;
cfg_tuplefielddef_t *f;
const cfg_tuplefielddef_t *fields = obj->type->of;
const cfg_tuplefielddef_t *f;
isc_boolean_t need_space = ISC_FALSE;
for (f = fields, i = 0; f->name != NULL; f++, i++) {
@ -1240,8 +1241,8 @@ print_tuple(cfg_printer_t *pctx, cfg_obj_t *obj) {
static void
free_tuple(cfg_parser_t *pctx, cfg_obj_t *obj) {
unsigned int i;
cfg_tuplefielddef_t *fields = obj->type->of;
cfg_tuplefielddef_t *f;
const cfg_tuplefielddef_t *fields = obj->type->of;
const cfg_tuplefielddef_t *f;
unsigned int nfields = 0;
if (obj->value.tuple == NULL)
@ -1264,8 +1265,8 @@ cfg_obj_istuple(cfg_obj_t *obj) {
cfg_obj_t *
cfg_tuple_get(cfg_obj_t *tupleobj, const char* name) {
unsigned int i;
cfg_tuplefielddef_t *fields;
cfg_tuplefielddef_t *f;
const cfg_tuplefielddef_t *fields;
const cfg_tuplefielddef_t *f;
REQUIRE(tupleobj != NULL && tupleobj->type->rep == &cfg_rep_tuple);
@ -1434,7 +1435,7 @@ cfg_parser_setcallback(cfg_parser_t *pctx,
* been set up with a source.
*/
static isc_result_t
parse2(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret) {
parse2(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
isc_result_t result;
cfg_obj_t *obj = NULL;
@ -1465,7 +1466,7 @@ parse2(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret) {
isc_result_t
cfg_parse_file(cfg_parser_t *pctx, const char *filename,
cfg_type_t *type, cfg_obj_t **ret)
const cfg_type_t *type, cfg_obj_t **ret)
{
isc_result_t result;
@ -1480,7 +1481,7 @@ cfg_parse_file(cfg_parser_t *pctx, const char *filename,
isc_result_t
cfg_parse_buffer(cfg_parser_t *pctx, isc_buffer_t *buffer,
cfg_type_t *type, cfg_obj_t **ret)
const cfg_type_t *type, cfg_obj_t **ret)
{
isc_result_t result;
REQUIRE(buffer != NULL);
@ -1509,7 +1510,7 @@ cfg_parser_destroy(cfg_parser_t **pctxp) {
* void
*/
static isc_result_t
parse_void(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret) {
parse_void(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
UNUSED(type);
return (create_cfgobj(pctx, &cfg_type_void, ret));
}
@ -1534,7 +1535,7 @@ static cfg_type_t cfg_type_void = {
* uint32
*/
static isc_result_t
parse_uint32(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret) {
parse_uint32(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
isc_result_t result;
cfg_obj_t *obj = NULL;
UNUSED(type);
@ -1646,7 +1647,7 @@ static cfg_type_t cfg_type_uint64 = {
"64_bit_integer", NULL, print_uint64, &cfg_rep_uint64, NULL };
static isc_result_t
parse_sizeval(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret) {
parse_sizeval(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
isc_result_t result;
cfg_obj_t *obj = NULL;
isc_uint64_t val;
@ -1678,7 +1679,7 @@ static cfg_type_t cfg_type_sizeval = {
static const char *size_enums[] = { "unlimited", "default", NULL };
static isc_result_t
parse_size(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret) {
parse_size(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
return (parse_enum_or_other(pctx, type, &cfg_type_sizeval, ret));
}
static cfg_type_t cfg_type_size = {
@ -1689,12 +1690,12 @@ static cfg_type_t cfg_type_size = {
* optional_keyvalue
*/
static isc_result_t
parse_maybe_optional_keyvalue(cfg_parser_t *pctx, cfg_type_t *type,
parse_maybe_optional_keyvalue(cfg_parser_t *pctx, const cfg_type_t *type,
isc_boolean_t optional, cfg_obj_t **ret)
{
isc_result_t result;
cfg_obj_t *obj = NULL;
keyword_type_t *kw = type->of;
const keyword_type_t *kw = type->of;
CHECK(cfg_peektoken(pctx, 0));
if (pctx->token.type == isc_tokentype_string &&
@ -1718,18 +1719,18 @@ parse_maybe_optional_keyvalue(cfg_parser_t *pctx, cfg_type_t *type,
}
static isc_result_t
parse_keyvalue(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret) {
parse_keyvalue(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
return (parse_maybe_optional_keyvalue(pctx, type, ISC_FALSE, ret));
}
static isc_result_t
parse_optional_keyvalue(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret) {
parse_optional_keyvalue(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
return (parse_maybe_optional_keyvalue(pctx, type, ISC_TRUE, ret));
}
static void
print_keyvalue(cfg_printer_t *pctx, cfg_obj_t *obj) {
keyword_type_t *kw = obj->type->of;
const keyword_type_t *kw = obj->type->of;
print(pctx, kw->name, strlen(kw->name));
print(pctx, " ", 1);
kw->type->print(pctx, obj);
@ -1741,7 +1742,7 @@ print_keyvalue(cfg_printer_t *pctx, cfg_obj_t *obj) {
/* Create a string object from a null-terminated C string. */
static isc_result_t
create_string(cfg_parser_t *pctx, const char *contents, cfg_type_t *type,
create_string(cfg_parser_t *pctx, const char *contents, const cfg_type_t *type,
cfg_obj_t **ret)
{
isc_result_t result;
@ -1765,7 +1766,7 @@ create_string(cfg_parser_t *pctx, const char *contents, cfg_type_t *type,
}
static isc_result_t
parse_qstring(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret) {
parse_qstring(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
isc_result_t result;
UNUSED(type);
@ -1783,7 +1784,7 @@ parse_qstring(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret) {
}
static isc_result_t
parse_ustring(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret) {
parse_ustring(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
isc_result_t result;
UNUSED(type);
@ -1801,7 +1802,7 @@ parse_ustring(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret) {
}
static isc_result_t
parse_astring(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret) {
parse_astring(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
isc_result_t result;
UNUSED(type);
@ -1815,8 +1816,8 @@ parse_astring(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret) {
}
static isc_boolean_t
is_enum(const char *s, const char **enums) {
const char **p;
is_enum(const char *s, const char *const *enums) {
const char * const *p;
for (p = enums; *p != NULL; p++) {
if (strcasecmp(*p, s) == 0)
return (ISC_TRUE);
@ -1825,7 +1826,7 @@ is_enum(const char *s, const char **enums) {
}
static isc_result_t
check_enum(cfg_parser_t *pctx, cfg_obj_t *obj, const char **enums) {
check_enum(cfg_parser_t *pctx, cfg_obj_t *obj, const char *const *enums) {
const char *s = obj->value.string.base;
if (is_enum(s, enums))
return (ISC_R_SUCCESS);
@ -1834,7 +1835,7 @@ check_enum(cfg_parser_t *pctx, cfg_obj_t *obj, const char **enums) {
}
static isc_result_t
parse_enum(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret) {
parse_enum(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
isc_result_t result;
cfg_obj_t *obj = NULL;
CHECK(parse_ustring(pctx, NULL, &obj));
@ -1847,8 +1848,8 @@ parse_enum(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret) {
}
static isc_result_t
parse_enum_or_other(cfg_parser_t *pctx, cfg_type_t *enumtype,
cfg_type_t *othertype, cfg_obj_t **ret)
parse_enum_or_other(cfg_parser_t *pctx, const cfg_type_t *enumtype,
const cfg_type_t *othertype, cfg_obj_t **ret)
{
isc_result_t result;
CHECK(cfg_peektoken(pctx, 0));
@ -1925,7 +1926,7 @@ static cfg_type_t cfg_type_astring = {
* boolean
*/
static isc_result_t
parse_boolean(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret)
parse_boolean(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret)
{
isc_result_t result;
isc_boolean_t value;
@ -1978,7 +1979,7 @@ static cfg_type_t cfg_type_boolean = {
static const char *dialup_enums[] = {
"notify", "notify-passive", "refresh", "passive", NULL };
static isc_result_t
parse_dialup_type(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret) {
parse_dialup_type(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
return (parse_enum_or_other(pctx, type, &cfg_type_boolean, ret));
}
static cfg_type_t cfg_type_dialuptype = {
@ -1988,7 +1989,7 @@ static cfg_type_t cfg_type_dialuptype = {
static const char *notify_enums[] = { "explicit", NULL };
static isc_result_t
parse_notify_type(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret) {
parse_notify_type(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
return (parse_enum_or_other(pctx, type, &cfg_type_boolean, ret));
}
static cfg_type_t cfg_type_notifytype = {
@ -2014,7 +2015,7 @@ static cfg_type_t cfg_type_optional_keyref = {
*/
static isc_result_t
create_list(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **obj) {
create_list(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **obj) {
isc_result_t result;
CHECK(create_cfgobj(pctx, type, obj));
ISC_LIST_INIT((*obj)->value.list);
@ -2053,7 +2054,8 @@ free_list(cfg_parser_t *pctx, cfg_obj_t *obj) {
}
static isc_result_t
parse_list_elt(cfg_parser_t *pctx, cfg_type_t *elttype, cfg_listelt_t **ret)
parse_list_elt(cfg_parser_t *pctx, const cfg_type_t *elttype,
cfg_listelt_t **ret)
{
isc_result_t result;
cfg_listelt_t *elt = NULL;
@ -2080,10 +2082,10 @@ parse_list_elt(cfg_parser_t *pctx, cfg_type_t *elttype, cfg_listelt_t **ret)
* and where each element is terminated by a semicolon.
*/
static isc_result_t
parse_list(cfg_parser_t *pctx, cfg_type_t *listtype, cfg_obj_t **ret)
parse_list(cfg_parser_t *pctx, const cfg_type_t *listtype, cfg_obj_t **ret)
{
cfg_obj_t *listobj = NULL;
cfg_type_t *listof = listtype->of;
const cfg_type_t *listof = listtype->of;
isc_result_t result;
CHECK(create_list(pctx, listtype, &listobj));
@ -2122,7 +2124,7 @@ print_list(cfg_printer_t *pctx, cfg_obj_t *obj) {
}
static isc_result_t
parse_bracketed_list(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret)
parse_bracketed_list(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret)
{
isc_result_t result;
CHECK(parse_special(pctx, '{'));
@ -2145,10 +2147,10 @@ print_bracketed_list(cfg_printer_t *pctx, cfg_obj_t *obj) {
* before the first semicolon.
*/
static isc_result_t
parse_spacelist(cfg_parser_t *pctx, cfg_type_t *listtype, cfg_obj_t **ret)
parse_spacelist(cfg_parser_t *pctx, const cfg_type_t *listtype, cfg_obj_t **ret)
{
cfg_obj_t *listobj = NULL;
cfg_type_t *listof = listtype->of;
const cfg_type_t *listof = listtype->of;
isc_result_t result;
CHECK(create_list(pctx, listtype, &listobj));
@ -2226,12 +2228,12 @@ cfg_listelt_value(cfg_listelt_t *elt) {
* options, view, zone, and other statements.
*/
static isc_result_t
parse_mapbody(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret)
parse_mapbody(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret)
{
cfg_clausedef_t **clausesets = type->of;
const cfg_clausedef_t * const *clausesets = type->of;
isc_result_t result;
cfg_clausedef_t **clauseset;
cfg_clausedef_t *clause;
const cfg_clausedef_t * const *clauseset;
const cfg_clausedef_t *clause;
cfg_obj_t *value = NULL;
cfg_obj_t *obj = NULL;
cfg_obj_t *eltobj = NULL;
@ -2418,7 +2420,7 @@ parse_symtab_elt(cfg_parser_t *pctx, const char *name,
* Parse a map; e.g., "{ foo 1; bar { glub; }; zap true; zap false; }"
*/
static isc_result_t
parse_map(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret)
parse_map(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret)
{
isc_result_t result;
CHECK(parse_special(pctx, '{'));
@ -2432,7 +2434,7 @@ parse_map(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret)
* Subroutine for parse_named_map() and parse_addressed_map().
*/
static isc_result_t
parse_any_named_map(cfg_parser_t *pctx, cfg_type_t *nametype, cfg_type_t *type,
parse_any_named_map(cfg_parser_t *pctx, cfg_type_t *nametype, const cfg_type_t *type,
cfg_obj_t **ret)
{
isc_result_t result;
@ -2454,7 +2456,7 @@ parse_any_named_map(cfg_parser_t *pctx, cfg_type_t *nametype, cfg_type_t *type,
* Used for the "key" and "channel" statements.
*/
static isc_result_t
parse_named_map(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret) {
parse_named_map(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
return (parse_any_named_map(pctx, &cfg_type_astring, type, ret));
}
@ -2463,7 +2465,7 @@ parse_named_map(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret) {
* Used for the "server" statement.
*/
static isc_result_t
parse_addressed_map(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret) {
parse_addressed_map(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
return (parse_any_named_map(pctx, &cfg_type_netaddr, type, ret));
}
@ -2471,14 +2473,14 @@ static void
print_mapbody(cfg_printer_t *pctx, cfg_obj_t *obj) {
isc_result_t result = ISC_R_SUCCESS;
cfg_clausedef_t **clauseset;
const cfg_clausedef_t * const *clauseset;
for (clauseset = obj->value.map.clausesets;
*clauseset != NULL;
clauseset++)
{
isc_symvalue_t symval;
cfg_clausedef_t *clause;
const cfg_clausedef_t *clause;
for (clause = *clauseset;
clause->name != NULL;
@ -2564,7 +2566,7 @@ cfg_map_getname(cfg_obj_t *mapobj) {
/* Parse an arbitrary token, storing its raw text representation. */
static isc_result_t
parse_token(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret) {
parse_token(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
cfg_obj_t *obj = NULL;
isc_result_t result;
isc_region_t r;
@ -2600,7 +2602,7 @@ static cfg_type_t cfg_type_token = {
*/
static isc_result_t
parse_unsupported(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret) {
parse_unsupported(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
cfg_obj_t *listobj = NULL;
isc_result_t result;
int braces = 0;
@ -2694,7 +2696,7 @@ static cfg_type_t cfg_type_controls = {
* An optional class, as used in view and zone statements.
*/
static isc_result_t
parse_optional_class(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret) {
parse_optional_class(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
isc_result_t result;
UNUSED(type);
CHECK(cfg_peektoken(pctx, 0));
@ -2876,13 +2878,13 @@ parse_querysource(cfg_parser_t *pctx, int flags, cfg_obj_t **ret) {
}
static isc_result_t
parse_querysource4(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret) {
parse_querysource4(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
UNUSED(type);
return (parse_querysource(pctx, V4OK, ret));
}
static isc_result_t
parse_querysource6(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret) {
parse_querysource6(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
UNUSED(type);
return (parse_querysource(pctx, V6OK, ret));
}
@ -2919,7 +2921,7 @@ static cfg_type_t cfg_type_querysource = {
/* netaddr */
static isc_result_t
parse_netaddr(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret) {
parse_netaddr(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
isc_result_t result;
cfg_obj_t *obj = NULL;
isc_netaddr_t netaddr;
@ -2941,7 +2943,7 @@ static cfg_type_t cfg_type_netaddr = {
/* netprefix */
static isc_result_t
parse_netprefix(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret) {
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;
@ -3012,7 +3014,7 @@ static cfg_type_t cfg_type_netprefix = {
/* addrmatchelt */
static isc_result_t
parse_addrmatchelt(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret) {
parse_addrmatchelt(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
isc_result_t result;
UNUSED(type);
@ -3082,7 +3084,7 @@ static cfg_type_t cfg_type_bracketed_aml = {
};
static isc_result_t
parse_sockaddrsub(cfg_parser_t *pctx, cfg_type_t *type,
parse_sockaddrsub(cfg_parser_t *pctx, const cfg_type_t *type,
int flags, cfg_obj_t **ret)
{
isc_result_t result;
@ -3108,21 +3110,21 @@ parse_sockaddrsub(cfg_parser_t *pctx, cfg_type_t *type,
}
static isc_result_t
parse_sockaddr4wild(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret) {
parse_sockaddr4wild(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
UNUSED(type);
return (parse_sockaddrsub(pctx, &cfg_type_sockaddr4wild,
WILDOK|V4OK, ret));
}
static isc_result_t
parse_sockaddr6wild(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret) {
parse_sockaddr6wild(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
UNUSED(type);
return (parse_sockaddrsub(pctx, &cfg_type_sockaddr6wild,
WILDOK|V6OK, ret));
}
static isc_result_t
parse_sockaddr(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret) {
parse_sockaddr(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
UNUSED(type);
return (parse_sockaddrsub(pctx, &cfg_type_sockaddr,
V4OK|V6OK, ret));
@ -3134,7 +3136,7 @@ parse_sockaddr(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret) {
* whis is gratuitously interpreted as the IPv4 wildcard address.
*/
static isc_result_t
parse_controls_sockaddr(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret) {
parse_controls_sockaddr(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
UNUSED(type);
return (parse_sockaddrsub(pctx, &cfg_type_sockaddr,
V4OK|V6OK|WILDOK, ret));
@ -3190,7 +3192,7 @@ static cfg_type_t cfg_type_controls_sockaddr = {
* statement, which takes a single key with our without braces and semicolon.
*/
static isc_result_t
parse_server_key_kludge(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret)
parse_server_key_kludge(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret)
{
isc_result_t result;
isc_boolean_t braces = ISC_FALSE;
@ -3227,7 +3229,7 @@ static cfg_type_t cfg_type_server_key_kludge = {
*/
static isc_result_t
parse_optional_facility(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret)
parse_optional_facility(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret)
{
isc_result_t result;
UNUSED(type);
@ -3259,7 +3261,7 @@ static cfg_type_t cfg_type_debuglevel = {
};
static isc_result_t
parse_logseverity(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret) {
parse_logseverity(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
isc_result_t result;
UNUSED(type);
@ -3297,7 +3299,7 @@ static cfg_type_t cfg_type_logseverity = {
static const char *logversions_enums[] = { "unlimited", NULL };
static isc_result_t
parse_logversions(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret) {
parse_logversions(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
return (parse_enum_or_other(pctx, type, &cfg_type_uint32, ret));
}
static cfg_type_t cfg_type_logversions = {
@ -3313,10 +3315,10 @@ static cfg_tuplefielddef_t logfile_fields[] = {
};
static isc_result_t
parse_logfile(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret) {
parse_logfile(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
isc_result_t result;
cfg_obj_t *obj = NULL;
cfg_tuplefielddef_t *fields = type->of;
const cfg_tuplefielddef_t *fields = type->of;
CHECK(create_tuple(pctx, type, &obj));
@ -3674,7 +3676,7 @@ cfg_obj_log(cfg_obj_t *obj, isc_log_t *lctx, int level, const char *fmt, ...) {
}
static isc_result_t
create_cfgobj(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret) {
create_cfgobj(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
cfg_obj_t *obj;
obj = isc_mem_get(pctx->mctx, sizeof(cfg_obj_t));
@ -3702,7 +3704,7 @@ map_symtabitem_destroy(char *key, unsigned int type,
static isc_result_t
create_map(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret) {
create_map(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
isc_result_t result;
isc_symtab_t *symtab = NULL;
cfg_obj_t *obj = NULL;
@ -3730,7 +3732,7 @@ free_map(cfg_parser_t *pctx, cfg_obj_t *obj) {
}
isc_boolean_t
cfg_obj_istype(cfg_obj_t *obj, cfg_type_t *type) {
cfg_obj_istype(cfg_obj_t *obj, const cfg_type_t *type) {
return (ISC_TF(obj->type == type));
}
@ -3781,10 +3783,10 @@ print_clause_flags(cfg_printer_t *pctx, unsigned int flags) {
}
static void
print_grammar(cfg_printer_t *pctx, cfg_type_t *type) {
print_grammar(cfg_printer_t *pctx, const cfg_type_t *type) {
if (type->print == print_mapbody) {
cfg_clausedef_t **clauseset;
cfg_clausedef_t *clause;
const cfg_clausedef_t * const *clauseset;
const cfg_clausedef_t *clause;
for (clauseset = type->of; *clauseset != NULL; clauseset++) {
for (clause = *clauseset;
@ -3799,8 +3801,8 @@ print_grammar(cfg_printer_t *pctx, cfg_type_t *type) {
}
}
} else if (type->print == print_map) {
cfg_clausedef_t **clauseset;
cfg_clausedef_t *clause;
const cfg_clausedef_t * const *clauseset;
const cfg_clausedef_t *clause;
print_open(pctx);
@ -3820,8 +3822,8 @@ print_grammar(cfg_printer_t *pctx, cfg_type_t *type) {
}
print_close(pctx);
} else if (type->print == print_tuple) {
cfg_tuplefielddef_t *fields = type->of;
cfg_tuplefielddef_t *f;
const cfg_tuplefielddef_t *fields = type->of;
const cfg_tuplefielddef_t *f;
isc_boolean_t need_space = ISC_FALSE;
for (f = fields; f->name != NULL; f++) {
@ -3831,7 +3833,7 @@ print_grammar(cfg_printer_t *pctx, cfg_type_t *type) {
need_space = ISC_TF(f->type->print != print_void);
}
} else if (type->parse == parse_enum) {
const char **p;
const char * const *p;
print(pctx, "( ", 2);
for (p = type->of; *p != NULL; p++) {
print(pctx, *p, strlen(*p));
@ -3844,12 +3846,12 @@ print_grammar(cfg_printer_t *pctx, cfg_type_t *type) {
print_grammar(pctx, type->of);
print(pctx, "; ... }", 7);
} else if (type->parse == parse_keyvalue) {
keyword_type_t *kw = type->of;
const keyword_type_t *kw = type->of;
print(pctx, kw->name, strlen(kw->name));
print(pctx, " ", 1);
print_grammar(pctx, kw->type);
} else if (type->parse == parse_optional_keyvalue) {
keyword_type_t *kw = type->of;
const keyword_type_t *kw = type->of;
print(pctx, "[ ", 2);
print(pctx, kw->name, strlen(kw->name));
print(pctx, " ", 1);
@ -3865,7 +3867,7 @@ print_grammar(cfg_printer_t *pctx, cfg_type_t *type) {
}
void
cfg_print_grammar(cfg_type_t *type,
cfg_print_grammar(const cfg_type_t *type,
void (*f)(void *closure, const char *text, int textlen),
void *closure)
{