Lines Matching defs:pctx

80 #define TOKEN_STRING(pctx) (pctx->token.value.as_textregion.base)
94 cfg_obj_destroy(pctx, &(obj)); \
102 free_tuple(cfg_parser_t *pctx, cfg_obj_t *obj);
105 parse_list(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret);
108 print_list(cfg_printer_t *pctx, const cfg_obj_t *obj);
111 free_list(cfg_parser_t *pctx, cfg_obj_t *obj);
114 create_listelt(cfg_parser_t *pctx, cfg_listelt_t **eltp);
117 create_string(cfg_parser_t *pctx, const char *contents, const cfg_type_t *type,
121 free_string(cfg_parser_t *pctx, cfg_obj_t *obj);
124 copy_string(cfg_parser_t *pctx, const cfg_obj_t *obj, isc_textregion_t *dst);
127 free_sockaddrtls(cfg_parser_t *pctx, cfg_obj_t *obj);
130 create_map(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **objp);
133 free_map(cfg_parser_t *pctx, cfg_obj_t *obj);
136 parse_symtab_elt(cfg_parser_t *pctx, const char *name, cfg_type_t *elttype,
140 free_noop(cfg_parser_t *pctx, cfg_obj_t *obj);
143 cfg_getstringtoken(cfg_parser_t *pctx);
146 parser_complain(cfg_parser_t *pctx, bool is_warning, unsigned int flags,
151 parse_geoip(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret);
154 print_geoip(cfg_printer_t *pctx, const cfg_obj_t *obj);
157 doc_geoip(cfg_printer_t *pctx, const cfg_type_t *type);
195 cfg_print_obj(cfg_printer_t *pctx, const cfg_obj_t *obj) {
196 REQUIRE(pctx != NULL);
199 obj->type->print(pctx, obj);
203 cfg_print_chars(cfg_printer_t *pctx, const char *text, int len) {
204 REQUIRE(pctx != NULL);
207 pctx->f(pctx->closure, text, len);
211 print_open(cfg_printer_t *pctx) {
212 if ((pctx->flags & CFG_PRINTER_ONELINE) != 0) {
213 cfg_print_cstr(pctx, "{ ");
215 cfg_print_cstr(pctx, "{\n");
216 pctx->indent++;
221 cfg_print_indent(cfg_printer_t *pctx) {
222 int indent = pctx->indent;
223 if ((pctx->flags & CFG_PRINTER_ONELINE) != 0) {
224 cfg_print_cstr(pctx, " ");
228 cfg_print_cstr(pctx, "\t");
234 print_close(cfg_printer_t *pctx) {
235 if ((pctx->flags & CFG_PRINTER_ONELINE) == 0) {
236 pctx->indent--;
237 cfg_print_indent(pctx);
239 cfg_print_cstr(pctx, "}");
243 cfg_parse_obj(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
246 REQUIRE(pctx != NULL);
250 result = type->parse(pctx, type, ret);
272 cfg_printer_t pctx;
277 pctx.f = f;
278 pctx.closure = closure;
279 pctx.indent = 0;
280 pctx.flags = flags;
281 obj->type->print(&pctx, obj);
287 cfg_create_tuple(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
295 REQUIRE(pctx != NULL);
305 CHECK(cfg_create_obj(pctx, type, &obj));
306 obj->value.tuple = isc_mem_cget(pctx->mctx, nfields,
316 isc_mem_put(pctx->mctx, obj, sizeof(*obj));
322 cfg_parse_tuple(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
329 REQUIRE(pctx != NULL);
335 CHECK(cfg_create_tuple(pctx, type, &obj));
337 CHECK(cfg_parse_obj(pctx, f->type, &obj->value.tuple[i]));
349 cfg_print_tuple(cfg_printer_t *pctx, const cfg_obj_t *obj) {
355 REQUIRE(pctx != NULL);
363 cfg_print_cstr(pctx, " ");
365 cfg_print_obj(pctx, fieldobj);
372 cfg_doc_tuple(cfg_printer_t *pctx, const cfg_type_t *type) {
377 REQUIRE(pctx != NULL);
384 cfg_print_cstr(pctx, " ");
386 cfg_doc_obj(pctx, f->type);
392 free_tuple(cfg_parser_t *pctx, cfg_obj_t *obj) {
406 isc_mem_cput(pctx->mctx, obj->value.tuple, nfields,
435 cfg_parse_special(cfg_parser_t *pctx, int special) {
438 REQUIRE(pctx != NULL);
440 CHECK(cfg_gettoken(pctx, 0));
441 if (pctx->token.type == isc_tokentype_special &&
442 pctx->token.value.as_char == special)
447 cfg_parser_error(pctx, CFG_LOG_NEAR, "'%c' expected", special);
461 parse_semicolon(cfg_parser_t *pctx) {
464 CHECK(cfg_gettoken(pctx, 0));
465 if (pctx->token.type == isc_tokentype_special &&
466 pctx->token.value.as_char == ';')
471 cfg_parser_error(pctx, CFG_LOG_BEFORE, "missing ';'");
472 cfg_ungettoken(pctx);
481 parse_eof(cfg_parser_t *pctx) {
484 CHECK(cfg_gettoken(pctx, 0));
486 if (pctx->token.type == isc_tokentype_eof) {
490 cfg_parser_error(pctx, CFG_LOG_NEAR, "syntax error");
496 /* A list of files, used internally for pctx->files. */
505 cfg_parser_t *pctx;
511 pctx = isc_mem_get(mctx, sizeof(*pctx));
513 pctx->mctx = NULL;
514 isc_mem_attach(mctx, &pctx->mctx);
516 isc_refcount_init(&pctx->references, 1);
518 pctx->lctx = lctx;
519 pctx->lexer = NULL;
520 pctx->seen_eof = false;
521 pctx->ungotten = false;
522 pctx->errors = 0;
523 pctx->warnings = 0;
524 pctx->open_files = NULL;
525 pctx->closed_files = NULL;
526 pctx->line = 0;
527 pctx->callback = NULL;
528 pctx->callbackarg = NULL;
529 pctx->token.type = isc_tokentype_unknown;
530 pctx->flags = 0;
531 pctx->buf_name = NULL;
541 isc_lex_create(pctx->mctx, 1024, &pctx->lexer);
543 isc_lex_setspecials(pctx->lexer, specials);
544 isc_lex_setcomments(pctx->lexer,
548 CHECK(cfg_create_list(pctx, &cfg_type_filelist, &pctx->open_files));
549 CHECK(cfg_create_list(pctx, &cfg_type_filelist, &pctx->closed_files));
551 *ret = pctx;
555 if (pctx->lexer != NULL) {
556 isc_lex_destroy(&pctx->lexer);
558 CLEANUP_OBJ(pctx->open_files);
559 CLEANUP_OBJ(pctx->closed_files);
560 isc_mem_putanddetach(&pctx->mctx, pctx, sizeof(*pctx));
565 cfg_parser_setflags(cfg_parser_t *pctx, unsigned int flags, bool turn_on) {
566 REQUIRE(pctx != NULL);
569 pctx->flags |= flags;
571 pctx->flags &= ~flags;
576 parser_openfile(cfg_parser_t *pctx, const char *filename) {
581 result = isc_lex_openfile(pctx->lexer, filename);
583 cfg_parser_error(pctx, 0, "open: %s: %s", filename,
588 CHECK(create_string(pctx, filename, &cfg_type_qstring, &stringobj));
589 CHECK(create_listelt(pctx, &elt));
591 ISC_LIST_APPEND(pctx->open_files->value.list, elt, link);
600 cfg_parser_setcallback(cfg_parser_t *pctx, cfg_parsecallback_t callback,
602 REQUIRE(pctx != NULL);
604 pctx->callback = callback;
605 pctx->callbackarg = arg;
609 cfg_parser_reset(cfg_parser_t *pctx) {
610 REQUIRE(pctx != NULL);
612 if (pctx->lexer != NULL) {
613 isc_lex_close(pctx->lexer);
616 pctx->seen_eof = false;
617 pctx->ungotten = false;
618 pctx->errors = 0;
619 pctx->warnings = 0;
620 pctx->line = 0;
624 * Parse a configuration using a pctx where a lexer has already
628 parse2(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
632 result = cfg_parse_obj(pctx, type, &obj);
634 if (pctx->errors != 0) {
644 cfg_parser_error(pctx, 0, "parsing failed: %s",
649 CHECK(parse_eof(pctx));
660 cfg_parse_file(cfg_parser_t *pctx, const char *filename, const cfg_type_t *type,
665 REQUIRE(pctx != NULL);
670 CHECK(parser_openfile(pctx, filename));
672 result = parse2(pctx, type, ret);
675 elt = ISC_LIST_TAIL(pctx->open_files->value.list);
677 ISC_LIST_UNLINK(pctx->open_files->value.list, elt, link);
678 ISC_LIST_APPEND(pctx->closed_files->value.list, elt, link);
685 cfg_parse_buffer(cfg_parser_t *pctx, isc_buffer_t *buffer, const char *file,
690 REQUIRE(pctx != NULL);
697 CHECK(isc_lex_openbuffer(pctx->lexer, buffer));
699 pctx->buf_name = file;
700 pctx->flags = flags;
703 CHECK(isc_lex_setsourceline(pctx->lexer, line));
706 CHECK(parse2(pctx, type, ret));
707 pctx->buf_name = NULL;
724 cfg_parser_t *pctx;
727 pctx = *pctxp;
730 if (isc_refcount_decrement(&pctx->references) == 1) {
731 isc_lex_destroy(&pctx->lexer);
737 CLEANUP_OBJ(pctx->open_files);
738 CLEANUP_OBJ(pctx->closed_files);
739 isc_mem_putanddetach(&pctx->mctx, pctx, sizeof(*pctx));
747 cfg_parse_void(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
748 REQUIRE(pctx != NULL);
753 return cfg_create_obj(pctx, &cfg_type_void, ret);
757 cfg_print_void(cfg_printer_t *pctx, const cfg_obj_t *obj) {
758 REQUIRE(pctx != NULL);
761 UNUSED(pctx);
766 cfg_doc_void(cfg_printer_t *pctx, const cfg_type_t *type) {
767 REQUIRE(pctx != NULL);
770 UNUSED(pctx);
787 cfg_parse_percentage(cfg_parser_t *pctx, const cfg_type_t *type,
794 REQUIRE(pctx != NULL);
799 CHECK(cfg_gettoken(pctx, 0));
800 if (pctx->token.type != isc_tokentype_string) {
801 cfg_parser_error(pctx, CFG_LOG_NEAR, "expected percentage");
805 percent = strtoull(TOKEN_STRING(pctx), &endp, 10);
807 cfg_parser_error(pctx, CFG_LOG_NEAR, "expected percentage");
811 CHECK(cfg_create_obj(pctx, &cfg_type_percentage, &obj));
820 cfg_print_percentage(cfg_printer_t *pctx, const cfg_obj_t *obj) {
824 REQUIRE(pctx != NULL);
829 cfg_print_chars(pctx, buf, strlen(buf));
852 cfg_parse_fixedpoint(cfg_parser_t *pctx, const cfg_type_t *type,
859 REQUIRE(pctx != NULL);
864 CHECK(cfg_gettoken(pctx, 0));
865 if (pctx->token.type != isc_tokentype_string) {
866 cfg_parser_error(pctx, CFG_LOG_NEAR,
871 p = TOKEN_STRING(pctx);
879 cfg_parser_error(pctx, CFG_LOG_NEAR,
884 CHECK(cfg_create_obj(pctx, &cfg_type_fixedpoint, &obj));
902 cfg_print_fixedpoint(cfg_printer_t *pctx, const cfg_obj_t *obj) {
906 REQUIRE(pctx != NULL);
912 cfg_print_chars(pctx, buf, strlen(buf));
935 cfg_parse_uint32(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
939 REQUIRE(pctx != NULL);
944 CHECK(cfg_gettoken(pctx, ISC_LEXOPT_NUMBER | ISC_LEXOPT_CNUMBER));
945 if (pctx->token.type != isc_tokentype_number) {
946 cfg_parser_error(pctx, CFG_LOG_NEAR, "expected number");
950 CHECK(cfg_create_obj(pctx, &cfg_type_uint32, &obj));
952 obj->value.uint32 = pctx->token.value.as_ulong;
959 cfg_print_cstr(cfg_printer_t *pctx, const char *s) {
960 cfg_print_chars(pctx, s, strlen(s));
964 cfg_print_rawuint(cfg_printer_t *pctx, unsigned int u) {
968 cfg_print_cstr(pctx, buf);
972 cfg_print_uint32(cfg_printer_t *pctx, const cfg_obj_t *obj) {
973 cfg_print_rawuint(pctx, obj->value.uint32);
1008 cfg_print_uint64(cfg_printer_t *pctx, const cfg_obj_t *obj) {
1012 cfg_print_cstr(pctx, buf);
1041 cfg_print_duration(cfg_printer_t *pctx, const cfg_obj_t *obj) {
1054 REQUIRE(pctx != NULL);
1061 cfg_print_rawuint(pctx, duration.parts[6]);
1123 cfg_print_chars(pctx, buf, strlen(buf));
1127 cfg_print_duration_or_unlimited(cfg_printer_t *pctx, const cfg_obj_t *obj) {
1130 REQUIRE(pctx != NULL);
1136 cfg_print_cstr(pctx, "unlimited");
1138 cfg_print_duration(pctx, obj);
1155 parse_duration(cfg_parser_t *pctx, cfg_obj_t **ret) {
1160 result = isccfg_parse_duration(&pctx->token.value.as_textregion,
1164 cfg_parser_error(pctx, CFG_LOG_NEAR,
1171 CHECK(cfg_create_obj(pctx, &cfg_type_duration, &obj));
1178 cfg_parser_error(pctx, CFG_LOG_NEAR,
1184 cfg_parse_duration(cfg_parser_t *pctx, const cfg_type_t *type,
1190 CHECK(cfg_gettoken(pctx, 0));
1191 if (pctx->token.type != isc_tokentype_string) {
1196 return parse_duration(pctx, ret);
1199 cfg_parser_error(pctx, CFG_LOG_NEAR,
1205 cfg_parse_duration_or_unlimited(cfg_parser_t *pctx, const cfg_type_t *type,
1213 CHECK(cfg_gettoken(pctx, 0));
1214 if (pctx->token.type != isc_tokentype_string) {
1219 if (strcmp(TOKEN_STRING(pctx), "unlimited") == 0) {
1226 CHECK(cfg_create_obj(pctx, &cfg_type_duration, &obj));
1232 return parse_duration(pctx, ret);
1235 cfg_parser_error(pctx, CFG_LOG_NEAR,
1272 create_string(cfg_parser_t *pctx, const char *contents, const cfg_type_t *type,
1278 CHECK(cfg_create_obj(pctx, type, &obj));
1281 obj->value.string.base = isc_mem_get(pctx->mctx, len + 1);
1283 isc_mem_put(pctx->mctx, obj, sizeof(*obj));
1295 cfg_parse_qstring(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
1298 REQUIRE(pctx != NULL);
1303 CHECK(cfg_gettoken(pctx, CFG_LEXOPT_QSTRING));
1304 if (pctx->token.type != isc_tokentype_qstring) {
1305 cfg_parser_error(pctx, CFG_LOG_NEAR, "expected quoted string");
1308 return create_string(pctx, TOKEN_STRING(pctx), &cfg_type_qstring, ret);
1314 parse_ustring(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
1319 CHECK(cfg_gettoken(pctx, 0));
1320 if (pctx->token.type != isc_tokentype_string) {
1321 cfg_parser_error(pctx, CFG_LOG_NEAR,
1325 return create_string(pctx, TOKEN_STRING(pctx), &cfg_type_ustring, ret);
1331 cfg_parse_astring(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
1334 REQUIRE(pctx != NULL);
1339 CHECK(cfg_getstringtoken(pctx));
1340 return create_string(pctx, TOKEN_STRING(pctx), &cfg_type_qstring, ret);
1346 cfg_parse_sstring(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
1349 REQUIRE(pctx != NULL);
1354 CHECK(cfg_getstringtoken(pctx));
1355 return create_string(pctx, TOKEN_STRING(pctx), &cfg_type_sstring, ret);
1361 parse_btext(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
1366 CHECK(cfg_gettoken(pctx, ISC_LEXOPT_BTEXT));
1367 if (pctx->token.type != isc_tokentype_btext) {
1368 cfg_parser_error(pctx, CFG_LOG_NEAR, "expected bracketed text");
1371 return create_string(pctx, TOKEN_STRING(pctx), &cfg_type_bracketed_text,
1378 print_btext(cfg_printer_t *pctx, const cfg_obj_t *obj) {
1386 pctx->indent++;
1387 cfg_print_cstr(pctx, "{");
1388 cfg_print_chars(pctx, obj->value.string.base, obj->value.string.length);
1389 print_close(pctx);
1393 doc_btext(cfg_printer_t *pctx, const cfg_type_t *type) {
1396 cfg_print_cstr(pctx, "{ <unspecified-text> }");
1415 check_enum(cfg_parser_t *pctx, cfg_obj_t *obj, const char *const *enums) {
1421 cfg_parser_error(pctx, 0, "'%s' unexpected", s);
1426 cfg_parse_enum(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
1430 REQUIRE(pctx != NULL);
1434 CHECK(parse_ustring(pctx, NULL, &obj));
1435 CHECK(check_enum(pctx, obj, type->of));
1444 cfg_doc_enum(cfg_printer_t *pctx, const cfg_type_t *type) {
1447 REQUIRE(pctx != NULL);
1450 cfg_print_cstr(pctx, "( ");
1452 cfg_print_cstr(pctx, *p);
1454 cfg_print_cstr(pctx, " | ");
1457 cfg_print_cstr(pctx, " )");
1461 cfg_parse_enum_or_other(cfg_parser_t *pctx, const cfg_type_t *enumtype,
1464 CHECK(cfg_peektoken(pctx, 0));
1465 if (pctx->token.type == isc_tokentype_string &&
1466 cfg_is_enum(TOKEN_STRING(pctx), enumtype->of))
1468 CHECK(cfg_parse_enum(pctx, enumtype, ret));
1470 CHECK(cfg_parse_obj(pctx, othertype, ret));
1477 cfg_doc_enum_or_other(cfg_printer_t *pctx, const cfg_type_t *enumtype,
1488 cfg_print_cstr(pctx, "[ ");
1490 cfg_print_cstr(pctx, "( ");
1493 cfg_print_cstr(pctx, " | ");
1496 cfg_print_cstr(pctx, *p);
1500 cfg_print_cstr(pctx, " | ");
1502 cfg_doc_terminal(pctx, othertype);
1504 cfg_print_cstr(pctx, " )");
1506 cfg_print_cstr(pctx, " ]");
1511 cfg_print_ustring(cfg_printer_t *pctx, const cfg_obj_t *obj) {
1512 REQUIRE(pctx != NULL);
1515 cfg_print_chars(pctx, obj->value.string.base, obj->value.string.length);
1519 print_rawqstring(cfg_printer_t *pctx, const isc_textregion_t string) {
1520 cfg_print_cstr(pctx, "\"");
1523 cfg_print_cstr(pctx, "\\");
1525 cfg_print_chars(pctx, (const char *)&string.base[i], 1);
1527 cfg_print_cstr(pctx, "\"");
1531 print_qstring(cfg_printer_t *pctx, const cfg_obj_t *obj) {
1532 print_rawqstring(pctx, obj->value.string);
1536 print_sstring(cfg_printer_t *pctx, const cfg_obj_t *obj) {
1537 cfg_print_cstr(pctx, "\"");
1538 if ((pctx->flags & CFG_PRINTER_XKEY) != 0) {
1541 cfg_print_cstr(pctx, "?");
1544 cfg_print_ustring(pctx, obj);
1546 cfg_print_cstr(pctx, "\"");
1550 free_string(cfg_parser_t *pctx, cfg_obj_t *obj) {
1551 isc_mem_put(pctx->mctx, obj->value.string.base,
1556 copy_string(cfg_parser_t *pctx, const cfg_obj_t *obj, isc_textregion_t *dst) {
1559 isc_mem_put(pctx->mctx, dst->base, dst->length + 1);
1562 dst->base = isc_mem_get(pctx->mctx, dst->length + 1);
1568 free_sockaddrtls(cfg_parser_t *pctx, cfg_obj_t *obj) {
1571 isc_mem_put(pctx->mctx, obj->value.sockaddrtls.tls.base,
1648 parse_geoip(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
1653 CHECK(cfg_create_tuple(pctx, type, &obj));
1654 CHECK(cfg_parse_void(pctx, NULL, &obj->value.tuple[0]));
1657 CHECK(cfg_peektoken(pctx, 0));
1658 if (pctx->token.type == isc_tokentype_string) {
1659 CHECK(cfg_gettoken(pctx, 0));
1660 if (strcasecmp(TOKEN_STRING(pctx), "db") == 0 &&
1663 CHECK(cfg_parse_obj(pctx, fields[1].type,
1666 CHECK(cfg_parse_void(pctx, NULL, &obj->value.tuple[1]));
1667 cfg_ungettoken(pctx);
1671 CHECK(cfg_parse_obj(pctx, fields[2].type, &obj->value.tuple[2]));
1672 CHECK(cfg_parse_obj(pctx, fields[3].type, &obj->value.tuple[3]));
1683 print_geoip(cfg_printer_t *pctx, const cfg_obj_t *obj) {
1685 cfg_print_cstr(pctx, " db ");
1686 cfg_print_obj(pctx, obj->value.tuple[1]);
1688 cfg_print_obj(pctx, obj->value.tuple[2]);
1689 cfg_print_obj(pctx, obj->value.tuple[3]);
1693 doc_geoip(cfg_printer_t *pctx, const cfg_type_t *type) {
1695 cfg_print_cstr(pctx, "[ db ");
1696 cfg_doc_obj(pctx, &cfg_type_astring);
1697 cfg_print_cstr(pctx, " ]");
1698 cfg_print_cstr(pctx, " ");
1699 cfg_doc_enum(pctx, &cfg_type_geoiptype);
1700 cfg_print_cstr(pctx, " ");
1701 cfg_doc_obj(pctx, &cfg_type_astring);
1709 parse_addrmatchelt(cfg_parser_t *pctx, const cfg_type_t *type,
1714 CHECK(cfg_peektoken(pctx, CFG_LEXOPT_QSTRING));
1716 if (pctx->token.type == isc_tokentype_string ||
1717 pctx->token.type == isc_tokentype_qstring)
1719 if (pctx->token.type == isc_tokentype_string &&
1720 (strcasecmp(TOKEN_STRING(pctx), "key") == 0))
1722 CHECK(cfg_parse_obj(pctx, &cfg_type_keyref, ret));
1723 } else if (pctx->token.type == isc_tokentype_string &&
1724 (strcasecmp(TOKEN_STRING(pctx), "geoip") == 0))
1727 CHECK(cfg_gettoken(pctx, 0));
1728 CHECK(cfg_parse_obj(pctx, &cfg_type_geoip, ret));
1730 cfg_parser_error(pctx, CFG_LOG_NEAR,
1737 pctx, CFG_ADDR_V4OK | CFG_ADDR_V4PREFIXOK |
1740 CHECK(cfg_parse_netprefix(pctx, NULL, ret));
1742 CHECK(cfg_parse_astring(pctx, NULL, ret));
1745 } else if (pctx->token.type == isc_tokentype_special) {
1746 if (pctx->token.value.as_char == '{') {
1748 CHECK(cfg_parse_obj(pctx, &cfg_type_bracketed_aml,
1750 } else if (pctx->token.value.as_char == '!') {
1751 CHECK(cfg_gettoken(pctx, 0)); /* read "!" */
1752 CHECK(cfg_parse_obj(pctx, &cfg_type_negated, ret));
1758 cfg_parser_error(pctx, CFG_LOG_NEAR,
1776 print_negated(cfg_printer_t *pctx, const cfg_obj_t *obj) {
1777 cfg_print_cstr(pctx, "!");
1778 cfg_print_tuple(pctx, obj);
1808 parse_optional_btext(cfg_parser_t *pctx, const cfg_type_t *type,
1814 CHECK(cfg_peektoken(pctx, ISC_LEXOPT_BTEXT));
1815 if (pctx->token.type == isc_tokentype_btext) {
1816 CHECK(cfg_parse_obj(pctx, &cfg_type_bracketed_text, ret));
1818 CHECK(cfg_parse_obj(pctx, &cfg_type_void, ret));
1825 print_optional_btext(cfg_printer_t *pctx, const cfg_obj_t *obj) {
1830 pctx->indent++;
1831 cfg_print_cstr(pctx, "{");
1832 cfg_print_chars(pctx, obj->value.string.base, obj->value.string.length);
1833 print_close(pctx);
1837 doc_optional_btext(cfg_printer_t *pctx, const cfg_type_t *type) {
1840 cfg_print_cstr(pctx, "[ { <unspecified-text> } ]");
1867 cfg_parse_boolean(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
1872 REQUIRE(pctx != NULL);
1877 result = cfg_gettoken(pctx, 0);
1882 if (pctx->token.type != isc_tokentype_string) {
1886 if ((strcasecmp(TOKEN_STRING(pctx), "true") == 0) ||
1887 (strcasecmp(TOKEN_STRING(pctx), "yes") == 0) ||
1888 (strcmp(TOKEN_STRING(pctx), "1") == 0))
1891 } else if ((strcasecmp(TOKEN_STRING(pctx), "false") == 0) ||
1892 (strcasecmp(TOKEN_STRING(pctx), "no") == 0) ||
1893 (strcmp(TOKEN_STRING(pctx), "0") == 0))
1900 CHECK(cfg_create_obj(pctx, &cfg_type_boolean, &obj));
1906 cfg_parser_error(pctx, CFG_LOG_NEAR, "boolean expected");
1914 cfg_print_boolean(cfg_printer_t *pctx, const cfg_obj_t *obj) {
1915 REQUIRE(pctx != NULL);
1919 cfg_print_cstr(pctx, "yes");
1921 cfg_print_cstr(pctx, "no");
1934 cfg_create_list(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **obj) {
1937 REQUIRE(pctx != NULL);
1941 CHECK(cfg_create_obj(pctx, type, obj));
1948 create_listelt(cfg_parser_t *pctx, cfg_listelt_t **eltp) {
1951 elt = isc_mem_get(pctx->mctx, sizeof(*elt));
1959 free_listelt(cfg_parser_t *pctx, cfg_listelt_t *elt) {
1961 cfg_obj_destroy(pctx, &elt->obj);
1963 isc_mem_put(pctx->mctx, elt, sizeof(*elt));
1967 free_list(cfg_parser_t *pctx, cfg_obj_t *obj) {
1971 free_listelt(pctx, elt);
1976 cfg_parse_listelt(cfg_parser_t *pctx, const cfg_type_t *elttype,
1982 REQUIRE(pctx != NULL);
1986 CHECK(create_listelt(pctx, &elt));
1988 result = cfg_parse_obj(pctx, elttype, &value);
1999 isc_mem_put(pctx->mctx, elt, sizeof(*elt));
2008 parse_list(cfg_parser_t *pctx, const cfg_type_t *listtype, cfg_obj_t **ret) {
2014 CHECK(cfg_create_list(pctx, listtype, &listobj));
2017 CHECK(cfg_peektoken(pctx, 0));
2018 if (pctx->token.type == isc_tokentype_special &&
2019 pctx->token.value.as_char == /*{*/ '}')
2023 CHECK(cfg_parse_listelt(pctx, listof, &elt));
2024 CHECK(parse_semicolon(pctx));
2033 free_listelt(pctx, elt);
2040 print_list(cfg_printer_t *pctx, const cfg_obj_t *obj) {
2047 if ((pctx->flags & CFG_PRINTER_ONELINE) != 0) {
2048 cfg_print_obj(pctx, elt->obj);
2049 cfg_print_cstr(pctx, "; ");
2051 cfg_print_indent(pctx);
2052 cfg_print_obj(pctx, elt->obj);
2053 cfg_print_cstr(pctx, ";\n");
2059 cfg_parse_bracketed_list(cfg_parser_t *pctx, const cfg_type_t *type,
2063 REQUIRE(pctx != NULL);
2067 CHECK(cfg_parse_special(pctx, '{'));
2068 CHECK(parse_list(pctx, type, ret));
2069 CHECK(cfg_parse_special(pctx, '}'));
2075 cfg_print_bracketed_list(cfg_printer_t *pctx, const cfg_obj_t *obj) {
2076 REQUIRE(pctx != NULL);
2079 print_open(pctx);
2080 print_list(pctx, obj);
2081 print_close(pctx);
2085 cfg_doc_bracketed_list(cfg_printer_t *pctx, const cfg_type_t *type) {
2086 REQUIRE(pctx != NULL);
2089 cfg_print_cstr(pctx, "{ ");
2090 cfg_doc_obj(pctx, type->of);
2091 cfg_print_cstr(pctx, "; ... }");
2100 cfg_parse_spacelist(cfg_parser_t *pctx, const cfg_type_t *listtype,
2106 REQUIRE(pctx != NULL);
2112 CHECK(cfg_create_list(pctx, listtype, &listobj));
2117 CHECK(cfg_peektoken(pctx, 0));
2118 if (pctx->token.type == isc_tokentype_special &&
2119 pctx->token.value.as_char == ';')
2123 CHECK(cfg_parse_listelt(pctx, listof, &elt));
2135 cfg_print_spacelist(cfg_printer_t *pctx, const cfg_obj_t *obj) {
2139 REQUIRE(pctx != NULL);
2147 cfg_print_obj(pctx, elt->obj);
2149 cfg_print_cstr(pctx, " ");
2218 cfg_parse_mapbody(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
2230 REQUIRE(pctx != NULL);
2236 CHECK(create_map(pctx, type, &obj));
2247 CHECK(cfg_gettoken(pctx, 0));
2249 if (pctx->token.type != isc_tokentype_string) {
2250 cfg_ungettoken(pctx);
2258 if (strcasecmp(TOKEN_STRING(pctx), "include") == 0) {
2267 CHECK(cfg_parse_obj(pctx, &cfg_type_qstring,
2269 CHECK(parse_semicolon(pctx));
2299 CHECK(parser_openfile(pctx, g.gl_pathv[i]));
2302 cfg_obj_destroy(pctx, &includename);
2313 if (strcasecmp(TOKEN_STRING(pctx),
2322 cfg_parser_error(pctx, CFG_LOG_NOPREP,
2328 CHECK(cfg_parse_obj(pctx, &cfg_type_unsupported,
2330 cfg_obj_destroy(pctx, &eltobj);
2331 CHECK(parse_semicolon(pctx));
2339 cfg_parser_error(pctx, 0,
2345 cfg_parser_error(pctx, 0,
2353 if ((pctx->flags & CFG_PCTX_NODEPRECATED) == 0 &&
2356 cfg_parser_warning(pctx, 0, "option '%s' is deprecated",
2359 if ((pctx->flags & CFG_PCTX_NOOBSOLETE) == 0 &&
2362 cfg_parser_warning(pctx, 0,
2367 if ((pctx->flags & CFG_PCTX_NOEXPERIMENTAL) == 0 &&
2370 cfg_parser_warning(pctx, 0,
2384 CHECK(cfg_create_list(pctx,
2392 cfg_parser_error(pctx, CFG_LOG_NEAR,
2397 isc_mem_put(pctx->mctx, list,
2407 CHECK(cfg_parse_listelt(pctx, clause->type, &elt));
2408 CHECK(parse_semicolon(pctx));
2418 pctx, clause->name, clause->type,
2420 CHECK(parse_semicolon(pctx));
2422 cfg_parser_error(pctx, CFG_LOG_NEAR,
2428 cfg_parser_error(pctx, CFG_LOG_NEAR,
2447 parse_symtab_elt(cfg_parser_t *pctx, const char *name, cfg_type_t *elttype,
2453 CHECK(cfg_parse_obj(pctx, elttype, &obj));
2455 if (callback && pctx->callback != NULL) {
2456 CHECK(pctx->callback(name, obj, pctx->callbackarg));
2472 cfg_parse_map(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
2475 REQUIRE(pctx != NULL);
2479 CHECK(cfg_parse_special(pctx, '{'));
2480 CHECK(cfg_parse_mapbody(pctx, type, ret));
2481 CHECK(cfg_parse_special(pctx, '}'));
2490 parse_any_named_map(cfg_parser_t *pctx, cfg_type_t *nametype,
2496 REQUIRE(pctx != NULL);
2501 CHECK(cfg_parse_obj(pctx, nametype, &idobj));
2502 CHECK(cfg_parse_map(pctx, type, &mapobj));
2517 cfg_parse_named_map(cfg_parser_t *pctx, const cfg_type_t *type,
2519 return parse_any_named_map(pctx, &cfg_type_astring, type, ret);
2527 cfg_parse_addressed_map(cfg_parser_t *pctx, const cfg_type_t *type,
2529 return parse_any_named_map(pctx, &cfg_type_netaddr, type, ret);
2537 cfg_parse_netprefix_map(cfg_parser_t *pctx, const cfg_type_t *type,
2539 return parse_any_named_map(pctx, &cfg_type_netprefix, type, ret);
2543 print_symval(cfg_printer_t *pctx, const char *name, cfg_obj_t *obj) {
2544 if ((pctx->flags & CFG_PRINTER_ONELINE) == 0) {
2545 cfg_print_indent(pctx);
2548 cfg_print_cstr(pctx, name);
2549 cfg_print_cstr(pctx, " ");
2550 cfg_print_obj(pctx, obj);
2552 if ((pctx->flags & CFG_PRINTER_ONELINE) == 0) {
2553 cfg_print_cstr(pctx, ";\n");
2555 cfg_print_cstr(pctx, "; ");
2560 cfg_print_mapbody(cfg_printer_t *pctx, const cfg_obj_t *obj) {
2563 REQUIRE(pctx != NULL);
2586 print_symval(pctx, clause->name,
2591 print_symval(pctx, clause->name,
2616 cfg_print_clauseflags(cfg_printer_t *pctx, unsigned int flags) {
2622 cfg_print_cstr(pctx, " // ");
2624 cfg_print_cstr(pctx, ", ");
2626 cfg_print_cstr(pctx, p->text);
2633 cfg_doc_mapbody(cfg_printer_t *pctx, const cfg_type_t *type) {
2637 REQUIRE(pctx != NULL);
2642 if (((pctx->flags & CFG_PRINTER_ACTIVEONLY) != 0) &&
2653 cfg_print_cstr(pctx, clause->name);
2654 cfg_print_cstr(pctx, " ");
2655 cfg_doc_obj(pctx, clause->type);
2656 cfg_print_cstr(pctx, ";");
2657 cfg_print_clauseflags(pctx, clause->flags);
2658 cfg_print_cstr(pctx, "\n\n");
2664 cfg_print_map(cfg_printer_t *pctx, const cfg_obj_t *obj) {
2665 REQUIRE(pctx != NULL);
2669 cfg_print_obj(pctx, obj->value.map.id);
2670 cfg_print_cstr(pctx, " ");
2672 print_open(pctx);
2673 cfg_print_mapbody(pctx, obj);
2674 print_close(pctx);
2678 cfg_doc_map(cfg_printer_t *pctx, const cfg_type_t *type) {
2682 REQUIRE(pctx != NULL);
2686 cfg_doc_obj(pctx, &cfg_type_astring);
2687 cfg_print_cstr(pctx, " ");
2689 cfg_doc_obj(pctx, &cfg_type_netaddr);
2690 cfg_print_cstr(pctx, " ");
2692 cfg_doc_obj(pctx, &cfg_type_netprefix);
2693 cfg_print_cstr(pctx, " ");
2696 print_open(pctx);
2700 if (((pctx->flags & CFG_PRINTER_ACTIVEONLY) != 0) &&
2711 cfg_print_indent(pctx);
2712 cfg_print_cstr(pctx, clause->name);
2714 cfg_print_cstr(pctx, " ");
2716 cfg_doc_obj(pctx, clause->type);
2717 cfg_print_cstr(pctx, ";");
2718 cfg_print_clauseflags(pctx, clause->flags);
2719 cfg_print_cstr(pctx, "\n");
2722 print_close(pctx);
2818 parse_token(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
2825 CHECK(cfg_create_obj(pctx, &cfg_type_token, &obj));
2826 CHECK(cfg_gettoken(pctx, CFG_LEXOPT_QSTRING));
2827 if (pctx->token.type == isc_tokentype_eof) {
2828 cfg_ungettoken(pctx);
2833 isc_lex_getlasttokentext(pctx->lexer, &pctx->token, &r);
2835 obj->value.string.base = isc_mem_get(pctx->mctx, r.length + 1);
2844 isc_mem_put(pctx->mctx, obj, sizeof(*obj));
2859 parse_unsupported(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
2864 CHECK(cfg_create_list(pctx, type, &listobj));
2869 CHECK(cfg_peektoken(pctx, 0));
2870 if (pctx->token.type == isc_tokentype_special) {
2871 if (pctx->token.value.as_char == '{') {
2873 } else if (pctx->token.value.as_char == '}') {
2875 } else if (pctx->token.value.as_char == ';') {
2881 if (pctx->token.type == isc_tokentype_eof || braces < 0) {
2882 cfg_parser_error(pctx, CFG_LOG_NEAR,
2888 CHECK(cfg_parse_listelt(pctx, &cfg_type_token, &elt));
2914 token_addr(cfg_parser_t *pctx, unsigned int flags, isc_netaddr_t *na) {
2919 if (pctx->token.type != isc_tokentype_string) {
2923 s = TOKEN_STRING(pctx);
2986 cfg_parse_rawaddr(cfg_parser_t *pctx, unsigned int flags, isc_netaddr_t *na) {
2991 REQUIRE(pctx != NULL);
2994 CHECK(cfg_gettoken(pctx, 0));
2995 result = token_addr(pctx, flags, na);
3004 cfg_parser_error(pctx, CFG_LOG_NEAR,
3008 cfg_parser_error(pctx, CFG_LOG_NEAR,
3012 cfg_parser_error(pctx, CFG_LOG_NEAR,
3022 cfg_lookingat_netaddr(cfg_parser_t *pctx, unsigned int flags) {
3026 REQUIRE(pctx != NULL);
3028 result = token_addr(pctx, flags, &na_dummy);
3033 cfg_parse_rawport(cfg_parser_t *pctx, unsigned int flags, in_port_t *port) {
3036 REQUIRE(pctx != NULL);
3039 CHECK(cfg_gettoken(pctx, ISC_LEXOPT_NUMBER));
3042 pctx->token.type == isc_tokentype_string &&
3043 strcmp(TOKEN_STRING(pctx), "*") == 0)
3048 if (pctx->token.type != isc_tokentype_number) {
3049 cfg_parser_error(pctx, CFG_LOG_NEAR,
3053 if (pctx->token.value.as_ulong >= 65536U) {
3054 cfg_parser_error(pctx, CFG_LOG_NEAR,
3058 *port = (in_port_t)(pctx->token.value.as_ulong);
3065 cfg_print_rawaddr(cfg_printer_t *pctx, const isc_netaddr_t *na) {
3070 REQUIRE(pctx != NULL);
3076 cfg_print_chars(pctx, isc_buffer_base(&buf),
3089 parse_netaddr(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
3095 CHECK(cfg_create_obj(pctx, type, &obj));
3096 CHECK(cfg_parse_rawaddr(pctx, flags, &netaddr));
3106 cfg_doc_netaddr(cfg_printer_t *pctx, const cfg_type_t *type) {
3110 cfg_print_cstr(pctx, "( ");
3113 cfg_print_cstr(pctx, "<ipv4_address>");
3118 cfg_print_cstr(pctx, " | ");
3120 cfg_print_cstr(pctx, "<ipv6_address>");
3125 cfg_print_cstr(pctx, " | ");
3127 cfg_print_cstr(pctx, "*");
3132 cfg_print_cstr(pctx, " )");
3159 cfg_parse_netprefix(cfg_parser_t *pctx, const cfg_type_t *type,
3167 REQUIRE(pctx != NULL);
3173 pctx, CFG_ADDR_V4OK | CFG_ADDR_V4PREFIXOK | CFG_ADDR_V6OK,
3189 CHECK(cfg_peektoken(pctx, 0));
3190 if (pctx->token.type == isc_tokentype_special &&
3191 pctx->token.value.as_char == '/')
3193 CHECK(cfg_gettoken(pctx, 0)); /* read "/" */
3194 CHECK(cfg_gettoken(pctx, ISC_LEXOPT_NUMBER));
3195 if (pctx->token.type != isc_tokentype_number) {
3196 cfg_parser_error(pctx, CFG_LOG_NEAR,
3200 prefixlen = pctx->token.value.as_ulong;
3202 cfg_parser_error(pctx, CFG_LOG_NOPREP,
3210 cfg_parser_error(pctx, CFG_LOG_NOPREP,
3218 cfg_parser_error(pctx, CFG_LOG_NEAR,
3224 CHECK(cfg_create_obj(pctx, &cfg_type_netprefix, &obj));
3230 cfg_parser_error(pctx, CFG_LOG_NEAR, "expected network prefix");
3235 print_netprefix(cfg_printer_t *pctx, const cfg_obj_t *obj) {
3238 cfg_print_rawaddr(pctx, &p->address);
3239 cfg_print_cstr(pctx, "/");
3240 cfg_print_rawuint(pctx, p->prefixlen);
3265 parse_sockaddrsub(cfg_parser_t *pctx, const cfg_type_t *type, int flags,
3274 CHECK(cfg_create_obj(pctx, type, &obj));
3275 CHECK(cfg_parse_rawaddr(pctx, flags, &netaddr));
3278 CHECK(cfg_peektoken(pctx, 0));
3279 if (pctx->token.type == isc_tokentype_string) {
3280 if (strcasecmp(TOKEN_STRING(pctx), "port") == 0) {
3281 if ((pctx->flags & CFG_PCTX_NODEPRECATED) ==
3286 pctx, 0,
3289 CHECK(cfg_gettoken(pctx, 0)); /* read "port" */
3290 CHECK(cfg_parse_rawport(pctx, flags, &port));
3293 strcasecmp(TOKEN_STRING(pctx), "tls") == 0)
3297 CHECK(cfg_gettoken(pctx, 0)); /* read "tls" */
3298 CHECK(cfg_parse_astring(pctx, NULL, &tls));
3299 copy_string(pctx, tls,
3312 cfg_parser_error(pctx, 0, "expected at most one port");
3317 cfg_parser_error(pctx, 0, "expected at most one tls");
3344 cfg_parse_sockaddr(cfg_parser_t *pctx, const cfg_type_t *type,
3348 REQUIRE(pctx != NULL);
3354 return parse_sockaddrsub(pctx, &cfg_type_sockaddr, *flagp, ret);
3358 cfg_parse_sockaddrtls(cfg_parser_t *pctx, const cfg_type_t *type,
3362 REQUIRE(pctx != NULL);
3368 return parse_sockaddrsub(pctx, &cfg_type_sockaddrtls, *flagp, ret);
3372 cfg_print_sockaddr(cfg_printer_t *pctx, const cfg_obj_t *obj) {
3377 REQUIRE(pctx != NULL);
3382 cfg_print_cstr(pctx, buf);
3385 cfg_print_cstr(pctx, " port ");
3386 cfg_print_rawuint(pctx, port);
3389 cfg_print_cstr(pctx, " tls ");
3390 print_rawqstring(pctx, obj->value.sockaddrtls.tls);
3395 cfg_doc_sockaddr(cfg_printer_t *pctx, const cfg_type_t *type) {
3399 REQUIRE(pctx != NULL);
3404 cfg_print_cstr(pctx, "( ");
3406 cfg_print_cstr(pctx, "<ipv4_address>");
3411 cfg_print_cstr(pctx, " | ");
3413 cfg_print_cstr(pctx, "<ipv6_address>");
3418 cfg_print_cstr(pctx, " | ");
3420 cfg_print_cstr(pctx, "*");
3424 cfg_print_cstr(pctx, " )");
3427 cfg_print_cstr(pctx, " [ port ( <integer> | * ) ]");
3429 cfg_print_cstr(pctx, " [ port <integer> ]");
3433 cfg_print_cstr(pctx, " [ tls <string> ]");
3464 cfg_gettoken(cfg_parser_t *pctx, int options) {
3467 REQUIRE(pctx != NULL);
3469 if (pctx->seen_eof) {
3476 pctx->token.type = isc_tokentype_unknown;
3477 result = isc_lex_gettoken(pctx->lexer, options, &pctx->token);
3478 pctx->ungotten = false;
3479 pctx->line = isc_lex_getsourceline(pctx->lexer);
3483 if (pctx->token.type == isc_tokentype_eof) {
3484 result = isc_lex_close(pctx->lexer);
3488 if (isc_lex_getsourcename(pctx->lexer) != NULL) {
3494 pctx->open_files->value.list);
3496 ISC_LIST_UNLINK(pctx->open_files->value.list,
3498 ISC_LIST_APPEND(pctx->closed_files->value.list,
3502 pctx->seen_eof = true;
3508 cfg_parser_error(pctx, CFG_LOG_NEAR, "token too big");
3512 cfg_parser_error(pctx, 0, "%s", isc_result_totext(result));
3516 cfg_parser_error(pctx, CFG_LOG_NEAR, "%s",
3524 cfg_ungettoken(cfg_parser_t *pctx) {
3525 REQUIRE(pctx != NULL);
3527 if (pctx->seen_eof) {
3530 isc_lex_ungettoken(pctx->lexer, &pctx->token);
3531 pctx->ungotten = true;
3535 cfg_peektoken(cfg_parser_t *pctx, int options) {
3538 REQUIRE(pctx != NULL);
3540 CHECK(cfg_gettoken(pctx, options));
3541 cfg_ungettoken(pctx);
3551 cfg_getstringtoken(cfg_parser_t *pctx) {
3554 result = cfg_gettoken(pctx, CFG_LEXOPT_QSTRING);
3559 if (pctx->token.type != isc_tokentype_string &&
3560 pctx->token.type != isc_tokentype_qstring)
3562 cfg_parser_error(pctx, CFG_LOG_NEAR, "expected string");
3569 cfg_parser_error(cfg_parser_t *pctx, unsigned int flags, const char *fmt, ...) {
3572 REQUIRE(pctx != NULL);
3576 parser_complain(pctx, false, flags, fmt, args);
3578 pctx->errors++;
3582 cfg_parser_warning(cfg_parser_t *pctx, unsigned int flags, const char *fmt,
3586 REQUIRE(pctx != NULL);
3590 parser_complain(pctx, true, flags, fmt, args);
3592 pctx->warnings++;
3598 have_current_file(cfg_parser_t *pctx) {
3600 if (pctx->open_files == NULL) {
3604 elt = ISC_LIST_TAIL(pctx->open_files->value.list);
3613 current_file(cfg_parser_t *pctx) {
3618 if (!have_current_file(pctx)) {
3622 elt = ISC_LIST_TAIL(pctx->open_files->value.list);
3633 parser_complain(cfg_parser_t *pctx, bool is_warning, unsigned int flags,
3647 if (have_current_file(pctx)) {
3648 snprintf(where, sizeof(where), "%s:%u: ", current_file(pctx),
3649 pctx->line);
3650 } else if (pctx->buf_name != NULL) {
3651 snprintf(where, sizeof(where), "%s: ", pctx->buf_name);
3664 if (pctx->ungotten) {
3665 (void)cfg_gettoken(pctx, 0);
3668 if (pctx->token.type == isc_tokentype_eof) {
3670 } else if (pctx->token.type == isc_tokentype_unknown) {
3674 isc_lex_getlasttokentext(pctx->lexer, &pctx->token, &r);
3695 isc_log_write(pctx->lctx, CAT, MOD, level, "%s%s%s%s", where, message,
3739 cfg_create_obj(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
3742 REQUIRE(pctx != NULL);
3746 obj = isc_mem_get(pctx->mctx, sizeof(cfg_obj_t));
3748 .file = current_file(pctx),
3749 .line = pctx->line,
3750 .pctx = pctx };
3762 cfg_parser_t *pctx = (cfg_parser_t *)userarg;
3767 cfg_obj_destroy(pctx, &obj);
3771 create_map(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
3776 CHECK(cfg_create_obj(pctx, type, &obj));
3777 CHECK(isc_symtab_create(pctx->mctx, 5, /* XXX */
3778 map_symtabitem_destroy, pctx, false, &symtab));
3787 isc_mem_put(pctx->mctx, obj, sizeof(*obj));
3793 free_map(cfg_parser_t *pctx, cfg_obj_t *obj) {
3807 * Destroy 'obj', a configuration object created in 'pctx'.
3810 cfg_obj_destroy(cfg_parser_t *pctx, cfg_obj_t **objp) {
3812 REQUIRE(pctx != NULL);
3818 obj->type->rep->free(pctx, obj);
3820 isc_mem_put(pctx->mctx, obj, sizeof(cfg_obj_t));
3834 free_noop(cfg_parser_t *pctx, cfg_obj_t *obj) {
3835 UNUSED(pctx);
3840 cfg_doc_obj(cfg_printer_t *pctx, const cfg_type_t *type) {
3841 REQUIRE(pctx != NULL);
3844 type->doc(pctx, type);
3848 cfg_doc_terminal(cfg_printer_t *pctx, const cfg_type_t *type) {
3849 REQUIRE(pctx != NULL);
3852 cfg_print_cstr(pctx, "<");
3853 cfg_print_cstr(pctx, type->name);
3854 cfg_print_cstr(pctx, ">");
3861 cfg_printer_t pctx;
3863 pctx.f = f;
3864 pctx.closure = closure;
3865 pctx.indent = 0;
3866 pctx.flags = flags;
3867 cfg_doc_obj(&pctx, type);
3871 cfg_parser_mapadd(cfg_parser_t *pctx, cfg_obj_t *mapobj, cfg_obj_t *obj,
3881 REQUIRE(pctx != NULL);
3905 CHECK(cfg_create_list(pctx, &cfg_type_implicitlist,
3907 CHECK(create_listelt(pctx, &elt));
3923 CHECK(create_listelt(pctx, &elt));
3936 free_listelt(pctx, elt);