Lines Matching refs:pctx

30 #define TOKEN_STRING(pctx) (pctx->token.value.as_textregion.base)
40 do { if ((obj) != NULL) cfg_obj_destroy(pctx, &(obj)); } while (0)
48 parse_enum_or_other(cfg_parser_t *pctx, const cfg_type_t *enumtype,
52 doc_enum_or_other(cfg_printer_t *pctx, const cfg_type_t *enumtype,
56 parse_keyvalue(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret);
59 parse_optional_keyvalue(cfg_parser_t *pctx, const cfg_type_t *type,
63 parse_updatepolicy(cfg_parser_t *pctx, const cfg_type_t *type,
66 print_updatepolicy(cfg_printer_t *pctx, const cfg_obj_t *obj);
69 doc_updatepolicy(cfg_printer_t *pctx, const cfg_type_t *type);
72 print_keyvalue(cfg_printer_t *pctx, const cfg_obj_t *obj);
75 doc_keyvalue(cfg_printer_t *pctx, const cfg_type_t *type);
78 doc_optional_keyvalue(cfg_printer_t *pctx, const cfg_type_t *type);
82 parse_geoip(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret);
85 print_geoip(cfg_printer_t *pctx, const cfg_obj_t *obj);
88 doc_geoip(cfg_printer_t *pctx, const cfg_type_t *type);
280 parse_matchtype(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
283 CHECK(cfg_peektoken(pctx, 0));
284 if (pctx->token.type == isc_tokentype_string &&
285 strcasecmp(TOKEN_STRING(pctx), "zonesub") == 0) {
286 pctx->flags |= CFG_PCTX_SKIP;
288 return (cfg_parse_enum(pctx, type, ret));
295 parse_matchname(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
299 if ((pctx->flags & CFG_PCTX_SKIP) != 0) {
300 pctx->flags &= ~CFG_PCTX_SKIP;
301 CHECK(cfg_parse_void(pctx, NULL, &obj));
303 result = cfg_parse_astring(pctx, type, &obj);
311 doc_matchname(cfg_printer_t *pctx, const cfg_type_t *type) {
312 cfg_print_cstr(pctx, "[ ");
313 cfg_doc_obj(pctx, type->of);
314 cfg_print_cstr(pctx, " ]");
355 parse_updatepolicy(cfg_parser_t *pctx, const cfg_type_t *type,
359 CHECK(cfg_gettoken(pctx, 0));
360 if (pctx->token.type == isc_tokentype_special &&
361 pctx->token.value.as_char == '{') {
362 cfg_ungettoken(pctx);
363 return (cfg_parse_bracketed_list(pctx, type, ret));
366 if (pctx->token.type == isc_tokentype_string &&
367 strcasecmp(TOKEN_STRING(pctx), "local") == 0) {
369 CHECK(cfg_create_obj(pctx, &cfg_type_ustring, &obj));
371 obj->value.string.base = isc_mem_get(pctx->mctx,
374 isc_mem_put(pctx->mctx, obj, sizeof(*obj));
383 cfg_ungettoken(pctx);
391 print_updatepolicy(cfg_printer_t *pctx, const cfg_obj_t *obj) {
393 cfg_print_ustring(pctx, obj);
395 cfg_print_bracketed_list(pctx, obj);
399 doc_updatepolicy(cfg_printer_t *pctx, const cfg_type_t *type) {
400 cfg_print_cstr(pctx, "( local | { ");
401 cfg_doc_obj(pctx, type->of);
402 cfg_print_cstr(pctx, "; ... }");
597 parse_zonestat(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
598 return (parse_enum_or_other(pctx, type, &cfg_type_boolean, ret));
601 doc_zonestat(cfg_printer_t *pctx, const cfg_type_t *type) {
602 doc_enum_or_other(pctx, type, &cfg_type_boolean);
689 print_none(cfg_printer_t *pctx, const cfg_obj_t *obj) {
691 cfg_print_cstr(pctx, "none");
702 parse_qstringornone(cfg_parser_t *pctx, const cfg_type_t *type,
707 CHECK(cfg_gettoken(pctx, CFG_LEXOPT_QSTRING));
708 if (pctx->token.type == isc_tokentype_string &&
709 strcasecmp(TOKEN_STRING(pctx), "none") == 0)
710 return (cfg_create_obj(pctx, &cfg_type_none, ret));
711 cfg_ungettoken(pctx);
712 return (cfg_parse_qstring(pctx, type, ret));
718 doc_qstringornone(cfg_printer_t *pctx, const cfg_type_t *type) {
720 cfg_print_cstr(pctx, "( <quoted_string> | none )");
733 print_auto(cfg_printer_t *pctx, const cfg_obj_t *obj) {
735 cfg_print_cstr(pctx, "auto");
743 parse_boolorauto(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
746 CHECK(cfg_gettoken(pctx, CFG_LEXOPT_QSTRING));
747 if (pctx->token.type == isc_tokentype_string &&
748 strcasecmp(TOKEN_STRING(pctx), "auto") == 0)
749 return (cfg_create_obj(pctx, &cfg_type_auto, ret));
750 cfg_ungettoken(pctx);
751 return (cfg_parse_boolean(pctx, type, ret));
757 print_boolorauto(cfg_printer_t *pctx, const cfg_obj_t *obj) {
759 cfg_print_cstr(pctx, "auto");
761 cfg_print_cstr(pctx, "yes");
763 cfg_print_cstr(pctx, "no");
767 doc_boolorauto(cfg_printer_t *pctx, const cfg_type_t *type) {
769 cfg_print_cstr(pctx, "( yes | no | auto )");
781 print_hostname(cfg_printer_t *pctx, const cfg_obj_t *obj) {
783 cfg_print_cstr(pctx, "hostname");
795 parse_serverid(cfg_parser_t *pctx, const cfg_type_t *type,
799 CHECK(cfg_gettoken(pctx, CFG_LEXOPT_QSTRING));
800 if (pctx->token.type == isc_tokentype_string &&
801 strcasecmp(TOKEN_STRING(pctx), "none") == 0)
802 return (cfg_create_obj(pctx, &cfg_type_none, ret));
803 if (pctx->token.type == isc_tokentype_string &&
804 strcasecmp(TOKEN_STRING(pctx), "hostname") == 0) {
805 result = cfg_create_obj(pctx, &cfg_type_hostname, ret);
810 cfg_ungettoken(pctx);
811 return (cfg_parse_qstring(pctx, type, ret));
817 doc_serverid(cfg_printer_t *pctx, const cfg_type_t *type) {
819 cfg_print_cstr(pctx, "( <quoted_string> | none | hostname )");
829 print_porttuple(cfg_printer_t *pctx, const cfg_obj_t *obj) {
830 cfg_print_cstr(pctx, "range ");
831 cfg_print_tuple(pctx, obj);
844 parse_port(cfg_parser_t *pctx, cfg_obj_t **ret) {
847 CHECK(cfg_parse_uint32(pctx, NULL, ret));
849 cfg_parser_error(pctx, CFG_LOG_NEAR, "invalid port");
850 cfg_obj_destroy(pctx, ret);
859 parse_portrange(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
865 CHECK(cfg_peektoken(pctx, ISC_LEXOPT_NUMBER | ISC_LEXOPT_CNUMBER));
866 if (pctx->token.type == isc_tokentype_number)
867 CHECK(parse_port(pctx, ret));
869 CHECK(cfg_gettoken(pctx, 0));
870 if (pctx->token.type != isc_tokentype_string ||
871 strcasecmp(TOKEN_STRING(pctx), "range") != 0) {
872 cfg_parser_error(pctx, CFG_LOG_NEAR,
876 CHECK(cfg_create_tuple(pctx, &cfg_type_porttuple, &obj));
877 CHECK(parse_port(pctx, &obj->value.tuple[0]));
878 CHECK(parse_port(pctx, &obj->value.tuple[1]));
881 cfg_parser_error(pctx, CFG_LOG_NOPREP,
894 cfg_obj_destroy(pctx, &obj);
939 parse_optional_enum(cfg_parser_t *pctx, const cfg_type_t *type,
942 return (parse_enum_or_other(pctx, type, &cfg_type_void, ret));
946 doc_optional_enum(cfg_printer_t *pctx, const cfg_type_t *type) {
948 cfg_print_cstr(pctx, "[ ");
949 cfg_doc_enum(pctx, type);
950 cfg_print_cstr(pctx, " ]");
1310 doc_rpz_policy(cfg_printer_t *pctx, const cfg_type_t *type) {
1315 cfg_print_cstr(pctx, "( ");
1317 cfg_print_cstr(pctx, *p);
1319 cfg_print_cstr(pctx, " | ");
1324 doc_rpz_cname(cfg_printer_t *pctx, const cfg_type_t *type) {
1325 cfg_doc_terminal(pctx, type);
1326 cfg_print_cstr(pctx, " )");
1334 cfg_parse_rpz_policy(cfg_parser_t *pctx, const cfg_type_t *type,
1341 CHECK(cfg_create_tuple(pctx, type, &obj));
1344 CHECK(cfg_parse_obj(pctx, fields[0].type, &obj->value.tuple[0]));
1349 CHECK(cfg_parse_void(pctx, NULL, &obj->value.tuple[1]));
1351 CHECK(cfg_parse_obj(pctx, fields[1].type,
1368 cfg_parse_kv_tuple(cfg_parser_t *pctx, const cfg_type_t *type,
1376 CHECK(cfg_create_tuple(pctx, type, &obj));
1382 CHECK(cfg_parse_obj(pctx, fields[0].type, &obj->value.tuple[0]));
1385 CHECK(cfg_peektoken(pctx, CFG_LEXOPT_QSTRING));
1386 if (pctx->token.type != isc_tokentype_string)
1391 cfg_parser_error(pctx, 0, "unexpected '%s'",
1392 TOKEN_STRING(pctx));
1397 strcasecmp(f->name, TOKEN_STRING(pctx)) == 0)
1401 CHECK(cfg_gettoken(pctx, 0));
1402 CHECK(cfg_parse_obj(pctx, f->type, &obj->value.tuple[fn]));
1407 CHECK(cfg_parse_void(pctx, NULL,
1420 cfg_print_kv_tuple(cfg_printer_t *pctx, const cfg_obj_t *obj) {
1431 cfg_print_cstr(pctx, " ");
1432 cfg_print_cstr(pctx, f->name);
1433 cfg_print_cstr(pctx, " ");
1435 cfg_print_obj(pctx, fieldobj);
1440 cfg_doc_kv_tuple(cfg_printer_t *pctx, const cfg_type_t *type) {
1446 cfg_print_cstr(pctx, " [ ");
1447 cfg_print_cstr(pctx, f->name);
1449 cfg_print_cstr(pctx, " ");
1451 cfg_doc_obj(pctx, f->type);
1453 cfg_print_cstr(pctx, " ]");
1596 print_lookaside(cfg_printer_t *pctx, const cfg_obj_t *obj) {
1601 cfg_print_cstr(pctx, "auto");
1603 cfg_print_tuple(pctx, obj);
1607 doc_lookaside(cfg_printer_t *pctx, const cfg_type_t *type) {
1609 cfg_print_cstr(pctx, "( <string> trust-anchor <string> | auto | no )");
1631 parse_optional_uint32(cfg_parser_t *pctx, const cfg_type_t *type,
1637 CHECK(cfg_peektoken(pctx, ISC_LEXOPT_NUMBER | ISC_LEXOPT_CNUMBER));
1638 if (pctx->token.type == isc_tokentype_number) {
1639 CHECK(cfg_parse_obj(pctx, &cfg_type_uint32, ret));
1641 CHECK(cfg_parse_obj(pctx, &cfg_type_void, ret));
1648 doc_optional_uint32(cfg_printer_t *pctx, const cfg_type_t *type) {
1650 cfg_print_cstr(pctx, "[ <integer> ]");
2413 parse_sizeval(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
2420 CHECK(cfg_gettoken(pctx, 0));
2421 if (pctx->token.type != isc_tokentype_string) {
2425 CHECK(parse_unitstring(TOKEN_STRING(pctx), &val));
2427 CHECK(cfg_create_obj(pctx, &cfg_type_uint64, &obj));
2433 cfg_parser_error(pctx, CFG_LOG_NEAR,
2439 parse_sizeval_percent(cfg_parser_t *pctx, const cfg_type_t *type,
2450 CHECK(cfg_gettoken(pctx, 0));
2451 if (pctx->token.type != isc_tokentype_string) {
2456 percent = isc_string_touint64(TOKEN_STRING(pctx), &endp, 10);
2459 CHECK(cfg_create_obj(pctx, &cfg_type_percentage, &obj));
2464 CHECK(parse_unitstring(TOKEN_STRING(pctx), &val));
2465 CHECK(cfg_create_obj(pctx, &cfg_type_uint64, &obj));
2472 cfg_parser_error(pctx, CFG_LOG_NEAR,
2478 doc_sizeval_percent(cfg_printer_t *pctx, const cfg_type_t *type) {
2482 cfg_print_cstr(pctx, "( ");
2483 cfg_doc_terminal(pctx, &cfg_type_size);
2484 cfg_print_cstr(pctx, " | ");
2485 cfg_doc_terminal(pctx, &cfg_type_percentage);
2486 cfg_print_cstr(pctx, " )");
2502 parse_size(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
2503 return (parse_enum_or_other(pctx, type, &cfg_type_sizeval, ret));
2507 doc_size(cfg_printer_t *pctx, const cfg_type_t *type) {
2508 doc_enum_or_other(pctx, type, &cfg_type_sizeval);
2540 parse_size_or_percent(cfg_parser_t *pctx, const cfg_type_t *type,
2543 return (parse_enum_or_other(pctx, type, &cfg_type_sizeval_percent,
2548 doc_parse_size_or_percent(cfg_printer_t *pctx, const cfg_type_t *type) {
2549 doc_enum_or_other(pctx, type, &cfg_type_sizeval_percent);
2562 parse_maybe_optional_keyvalue(cfg_parser_t *pctx, const cfg_type_t *type,
2569 CHECK(cfg_peektoken(pctx, 0));
2570 if (pctx->token.type == isc_tokentype_string &&
2571 strcasecmp(TOKEN_STRING(pctx), kw->name) == 0) {
2572 CHECK(cfg_gettoken(pctx, 0));
2573 CHECK(kw->type->parse(pctx, kw->type, &obj));
2577 CHECK(cfg_parse_void(pctx, NULL, &obj));
2579 cfg_parser_error(pctx, CFG_LOG_NEAR, "expected '%s'",
2591 parse_enum_or_other(cfg_parser_t *pctx, const cfg_type_t *enumtype,
2595 CHECK(cfg_peektoken(pctx, 0));
2596 if (pctx->token.type == isc_tokentype_string &&
2597 cfg_is_enum(TOKEN_STRING(pctx), enumtype->of)) {
2598 CHECK(cfg_parse_enum(pctx, enumtype, ret));
2600 CHECK(cfg_parse_obj(pctx, othertype, ret));
2607 doc_enum_or_other(cfg_printer_t *pctx, const cfg_type_t *enumtype,
2619 cfg_print_cstr(pctx, "[ ");
2620 cfg_print_cstr(pctx, "( ");
2623 cfg_print_cstr(pctx, " | ");
2625 cfg_print_cstr(pctx, *p);
2629 cfg_print_cstr(pctx, " | ");
2630 cfg_doc_terminal(pctx, &cfg_type_sizeval);
2631 cfg_print_cstr(pctx, " | ");
2632 cfg_doc_terminal(pctx, &cfg_type_percentage);
2635 cfg_print_cstr(pctx, " | ");
2636 cfg_doc_terminal(pctx, othertype);
2638 cfg_print_cstr(pctx, " )");
2640 cfg_print_cstr(pctx, " ]");
2644 parse_keyvalue(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
2645 return (parse_maybe_optional_keyvalue(pctx, type, ISC_FALSE, ret));
2649 parse_optional_keyvalue(cfg_parser_t *pctx, const cfg_type_t *type,
2652 return (parse_maybe_optional_keyvalue(pctx, type, ISC_TRUE, ret));
2656 print_keyvalue(cfg_printer_t *pctx, const cfg_obj_t *obj) {
2658 cfg_print_cstr(pctx, kw->name);
2659 cfg_print_cstr(pctx, " ");
2660 kw->type->print(pctx, obj);
2664 doc_keyvalue(cfg_printer_t *pctx, const cfg_type_t *type) {
2666 cfg_print_cstr(pctx, kw->name);
2667 cfg_print_cstr(pctx, " ");
2668 cfg_doc_obj(pctx, kw->type);
2672 doc_optional_keyvalue(cfg_printer_t *pctx, const cfg_type_t *type) {
2674 cfg_print_cstr(pctx, "[ ");
2675 cfg_print_cstr(pctx, kw->name);
2676 cfg_print_cstr(pctx, " ");
2677 cfg_doc_obj(pctx, kw->type);
2678 cfg_print_cstr(pctx, " ]");
2685 parse_dialup_type(cfg_parser_t *pctx, const cfg_type_t *type,
2688 return (parse_enum_or_other(pctx, type, &cfg_type_boolean, ret));
2691 doc_dialup_type(cfg_printer_t *pctx, const cfg_type_t *type) {
2692 doc_enum_or_other(pctx, type, &cfg_type_boolean);
2701 parse_notify_type(cfg_parser_t *pctx, const cfg_type_t *type,
2704 return (parse_enum_or_other(pctx, type, &cfg_type_boolean, ret));
2707 doc_notify_type(cfg_printer_t *pctx, const cfg_type_t *type) {
2708 doc_enum_or_other(pctx, type, &cfg_type_boolean);
2717 parse_minimal(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
2718 return (parse_enum_or_other(pctx, type, &cfg_type_boolean, ret));
2721 doc_minimal(cfg_printer_t *pctx, const cfg_type_t *type) {
2722 doc_enum_or_other(pctx, type, &cfg_type_boolean);
2731 parse_ixfrdiff_type(cfg_parser_t *pctx, const cfg_type_t *type,
2734 return (parse_enum_or_other(pctx, type, &cfg_type_boolean, ret));
2737 doc_ixfrdiff_type(cfg_printer_t *pctx, const cfg_type_t *type) {
2738 doc_enum_or_other(pctx, type, &cfg_type_boolean);
2747 parse_filter_aaaa(cfg_parser_t *pctx, const cfg_type_t *type,
2749 return (parse_enum_or_other(pctx, type, &cfg_type_boolean, ret));
2752 doc_filter_aaaa(cfg_printer_t *pctx, const cfg_type_t *type) {
2753 doc_enum_or_other(pctx, type, &cfg_type_boolean);
2811 parse_geoip(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
2816 CHECK(cfg_create_tuple(pctx, type, &obj));
2817 CHECK(cfg_parse_void(pctx, NULL, &obj->value.tuple[0]));
2820 CHECK(cfg_peektoken(pctx, 0));
2821 if (pctx->token.type == isc_tokentype_string) {
2822 CHECK(cfg_gettoken(pctx, 0));
2823 if (strcasecmp(TOKEN_STRING(pctx), "db") == 0 &&
2825 CHECK(cfg_parse_obj(pctx, fields[1].type,
2828 CHECK(cfg_parse_void(pctx, NULL,
2830 cfg_ungettoken(pctx);
2834 CHECK(cfg_parse_obj(pctx, fields[2].type, &obj->value.tuple[2]));
2835 CHECK(cfg_parse_obj(pctx, fields[3].type, &obj->value.tuple[3]));
2846 print_geoip(cfg_printer_t *pctx, const cfg_obj_t *obj) {
2848 cfg_print_cstr(pctx, " db ");
2849 cfg_print_obj(pctx, obj->value.tuple[1]);
2851 cfg_print_obj(pctx, obj->value.tuple[2]);
2852 cfg_print_obj(pctx, obj->value.tuple[3]);
2856 doc_geoip(cfg_printer_t *pctx, const cfg_type_t *type) {
2858 cfg_print_cstr(pctx, "[ db ");
2859 cfg_doc_enum(pctx, &cfg_type_geoipdb);
2860 cfg_print_cstr(pctx, " ]");
2861 cfg_print_cstr(pctx, " ");
2862 cfg_doc_enum(pctx, &cfg_type_geoiptype);
2863 cfg_print_cstr(pctx, " ");
2864 cfg_print_cstr(pctx, "<quoted_string>");
2992 doc_optional_bracketed_list(cfg_printer_t *pctx, const cfg_type_t *type) {
2994 cfg_print_cstr(pctx, "[ ");
2995 cfg_print_cstr(pctx, kw->name);
2996 cfg_print_cstr(pctx, " ");
2997 cfg_doc_obj(pctx, kw->type);
2998 cfg_print_cstr(pctx, " ]");
3038 parse_optional_class(cfg_parser_t *pctx, const cfg_type_t *type,
3043 CHECK(cfg_peektoken(pctx, 0));
3044 if (pctx->token.type == isc_tokentype_string)
3045 CHECK(cfg_parse_obj(pctx, &cfg_type_ustring, ret));
3047 CHECK(cfg_parse_obj(pctx, &cfg_type_void, ret));
3053 doc_optional_class(cfg_printer_t *pctx, const cfg_type_t *type) {
3055 cfg_print_cstr(pctx, "[ <class> ]");
3064 parse_querysource(cfg_parser_t *pctx, const cfg_type_t *type,
3085 CHECK(cfg_peektoken(pctx, 0));
3086 if (pctx->token.type == isc_tokentype_string) {
3087 if (strcasecmp(TOKEN_STRING(pctx),
3091 CHECK(cfg_gettoken(pctx, 0));
3092 CHECK(cfg_parse_rawaddr(pctx, *flagp,
3095 } else if (strcasecmp(TOKEN_STRING(pctx), "port") == 0)
3098 CHECK(cfg_gettoken(pctx, 0));
3099 CHECK(cfg_parse_rawport(pctx,
3103 } else if (strcasecmp(TOKEN_STRING(pctx), "dscp") == 0)
3106 CHECK(cfg_gettoken(pctx, 0));
3107 CHECK(cfg_parse_dscp(pctx, &dscp));
3112 return (cfg_parse_sockaddr(pctx, type, ret));
3114 cfg_parser_error(pctx, CFG_LOG_NEAR,
3124 cfg_parser_error(pctx, 0, "expected one address and/or port");
3129 cfg_parser_error(pctx, 0, "expected at most one dscp");
3133 CHECK(cfg_create_obj(pctx, &cfg_type_querysource, &obj));
3140 cfg_parser_error(pctx, CFG_LOG_NEAR, "invalid query source");
3146 print_querysource(cfg_printer_t *pctx, const cfg_obj_t *obj) {
3149 cfg_print_cstr(pctx, "address ");
3150 cfg_print_rawaddr(pctx, &na);
3151 cfg_print_cstr(pctx, " port ");
3152 cfg_print_rawuint(pctx, isc_sockaddr_getport(&obj->value.sockaddr));
3154 cfg_print_cstr(pctx, " dscp ");
3155 cfg_print_rawuint(pctx, obj->value.sockaddrdscp.dscp);
3160 doc_querysource(cfg_printer_t *pctx, const cfg_type_t *type) {
3163 cfg_print_cstr(pctx, "( ( [ address ] ( ");
3165 cfg_print_cstr(pctx, "<ipv4_address>");
3167 cfg_print_cstr(pctx, "<ipv6_address>");
3170 cfg_print_cstr(pctx, " | * ) [ port ( <integer> | * ) ] ) | "
3173 cfg_print_cstr(pctx, "<ipv4_address>");
3175 cfg_print_cstr(pctx, "<ipv6_address>");
3178 cfg_print_cstr(pctx, " | * ) ] port ( <integer> | * ) ) )"
3204 parse_addrmatchelt(cfg_parser_t *pctx, const cfg_type_t *type,
3210 CHECK(cfg_peektoken(pctx, CFG_LEXOPT_QSTRING));
3212 if (pctx->token.type == isc_tokentype_string ||
3213 pctx->token.type == isc_tokentype_qstring) {
3214 if (pctx->token.type == isc_tokentype_string &&
3215 (strcasecmp(TOKEN_STRING(pctx), "key") == 0)) {
3216 CHECK(cfg_parse_obj(pctx, &cfg_type_keyref, ret));
3217 } else if (pctx->token.type == isc_tokentype_string &&
3218 (strcasecmp(TOKEN_STRING(pctx), "ecs") == 0)) {
3219 CHECK(cfg_parse_obj(pctx, &cfg_type_ecsprefix, ret));
3220 } else if (pctx->token.type == isc_tokentype_string &&
3221 (strcasecmp(TOKEN_STRING(pctx), "geoip") == 0)) {
3223 CHECK(cfg_gettoken(pctx, 0));
3224 CHECK(cfg_parse_obj(pctx, &cfg_type_geoip, ret));
3226 cfg_parser_error(pctx, CFG_LOG_NEAR, "'geoip' "
3231 if (cfg_lookingat_netaddr(pctx, CFG_ADDR_V4OK |
3235 CHECK(cfg_parse_netprefix(pctx, NULL, ret));
3237 CHECK(cfg_parse_astring(pctx, NULL, ret));
3240 } else if (pctx->token.type == isc_tokentype_special) {
3241 if (pctx->token.value.as_char == '{') {
3243 CHECK(cfg_parse_obj(pctx,
3245 } else if (pctx->token.value.as_char == '!') {
3246 CHECK(cfg_gettoken(pctx, 0)); /* read "!" */
3247 CHECK(cfg_parse_obj(pctx, &cfg_type_negated, ret));
3253 cfg_parser_error(pctx, CFG_LOG_NEAR,
3273 print_negated(cfg_printer_t *pctx, const cfg_obj_t *obj) {
3274 cfg_print_cstr(pctx, "!");
3275 cfg_print_tuple(pctx, obj);
3314 parse_server_key_kludge(cfg_parser_t *pctx, const cfg_type_t *type,
3322 CHECK(cfg_peektoken(pctx, 0));
3323 if (pctx->token.type == isc_tokentype_special &&
3324 pctx->token.value.as_char == '{') {
3325 CHECK(cfg_gettoken(pctx, 0));
3329 CHECK(cfg_parse_obj(pctx, &cfg_type_astring, ret));
3333 CHECK(cfg_peektoken(pctx, 0));
3334 if (pctx->token.type == isc_tokentype_special &&
3335 pctx->token.value.as_char == ';')
3336 CHECK(cfg_gettoken(pctx, 0));
3338 CHECK(cfg_parse_special(pctx, '}'));
3354 parse_optional_facility(cfg_parser_t *pctx, const cfg_type_t *type,
3360 CHECK(cfg_peektoken(pctx, CFG_LEXOPT_QSTRING));
3361 if (pctx->token.type == isc_tokentype_string ||
3362 pctx->token.type == isc_tokentype_qstring) {
3363 CHECK(cfg_parse_obj(pctx, &cfg_type_astring, ret));
3365 CHECK(cfg_parse_obj(pctx, &cfg_type_void, ret));
3372 doc_optional_facility(cfg_printer_t *pctx, const cfg_type_t *type) {
3374 cfg_print_cstr(pctx, "[ <syslog_facility> ]");
3396 parse_logseverity(cfg_parser_t *pctx, const cfg_type_t *type,
3402 CHECK(cfg_peektoken(pctx, 0));
3403 if (pctx->token.type == isc_tokentype_string &&
3404 strcasecmp(TOKEN_STRING(pctx), "debug") == 0) {
3405 CHECK(cfg_gettoken(pctx, 0)); /* read "debug" */
3406 CHECK(cfg_peektoken(pctx, ISC_LEXOPT_NUMBER));
3407 if (pctx->token.type == isc_tokentype_number) {
3408 CHECK(cfg_parse_uint32(pctx, NULL, ret));
3415 CHECK(cfg_create_obj(pctx, &cfg_type_uint32, ret));
3420 CHECK(cfg_parse_obj(pctx, &cfg_type_loglevel, ret));
3438 parse_logversions(cfg_parser_t *pctx, const cfg_type_t *type,
3441 return (parse_enum_or_other(pctx, type, &cfg_type_uint32, ret));
3445 doc_logversions(cfg_printer_t *pctx, const cfg_type_t *type) {
3446 doc_enum_or_other(pctx, type, &cfg_type_uint32);
3462 parse_logfile(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
3467 CHECK(cfg_create_tuple(pctx, type, &obj));
3470 CHECK(cfg_parse_obj(pctx, fields[0].type, &obj->value.tuple[0]));
3474 CHECK(cfg_peektoken(pctx, 0));
3475 if (pctx->token.type == isc_tokentype_string) {
3476 CHECK(cfg_gettoken(pctx, 0));
3477 if (strcasecmp(TOKEN_STRING(pctx),
3480 CHECK(cfg_parse_obj(pctx, fields[1].type,
3482 } else if (strcasecmp(TOKEN_STRING(pctx),
3485 CHECK(cfg_parse_obj(pctx, fields[2].type,
3497 CHECK(cfg_parse_void(pctx, NULL, &obj->value.tuple[1]));
3499 CHECK(cfg_parse_void(pctx, NULL, &obj->value.tuple[2]));
3510 print_logfile(cfg_printer_t *pctx, const cfg_obj_t *obj) {
3511 cfg_print_obj(pctx, obj->value.tuple[0]); /* file */
3513 cfg_print_cstr(pctx, " versions ");
3514 cfg_print_obj(pctx, obj->value.tuple[1]);
3517 cfg_print_cstr(pctx, " size ");
3518 cfg_print_obj(pctx, obj->value.tuple[2]);
3524 doc_logfile(cfg_printer_t *pctx, const cfg_type_t *type) {
3526 cfg_print_cstr(pctx, "<quoted_string>");
3527 cfg_print_cstr(pctx, " ");
3528 cfg_print_cstr(pctx, "[ versions ( \"unlimited\" | <integer> ) ]");
3529 cfg_print_cstr(pctx, " ");
3530 cfg_print_cstr(pctx, "[ size <size> ]");
3694 doc_sockaddrnameport(cfg_printer_t *pctx, const cfg_type_t *type) {
3696 cfg_print_cstr(pctx, "( ");
3697 cfg_print_cstr(pctx, "<quoted_string>");
3698 cfg_print_cstr(pctx, " ");
3699 cfg_print_cstr(pctx, "[ port <integer> ]");
3700 cfg_print_cstr(pctx, " ");
3701 cfg_print_cstr(pctx, "[ dscp <integer> ]");
3702 cfg_print_cstr(pctx, " | ");
3703 cfg_print_cstr(pctx, "<ipv4_address>");
3704 cfg_print_cstr(pctx, " ");
3705 cfg_print_cstr(pctx, "[ port <integer> ]");
3706 cfg_print_cstr(pctx, " ");
3707 cfg_print_cstr(pctx, "[ dscp <integer> ]");
3708 cfg_print_cstr(pctx, " | ");
3709 cfg_print_cstr(pctx, "<ipv6_address>");
3710 cfg_print_cstr(pctx, " ");
3711 cfg_print_cstr(pctx, "[ port <integer> ]");
3712 cfg_print_cstr(pctx, " ");
3713 cfg_print_cstr(pctx, "[ dscp <integer> ]");
3714 cfg_print_cstr(pctx, " )");
3718 parse_sockaddrnameport(cfg_parser_t *pctx, const cfg_type_t *type,
3725 CHECK(cfg_peektoken(pctx, CFG_LEXOPT_QSTRING));
3726 if (pctx->token.type == isc_tokentype_string ||
3727 pctx->token.type == isc_tokentype_qstring) {
3728 if (cfg_lookingat_netaddr(pctx, CFG_ADDR_V4OK | CFG_ADDR_V6OK))
3729 CHECK(cfg_parse_sockaddr(pctx, &cfg_type_sockaddr,
3734 CHECK(cfg_create_tuple(pctx, &cfg_type_nameport,
3736 CHECK(cfg_parse_obj(pctx, fields[0].type,
3738 CHECK(cfg_parse_obj(pctx, fields[1].type,
3740 CHECK(cfg_parse_obj(pctx, fields[2].type,
3746 cfg_parser_error(pctx, CFG_LOG_NEAR,
3787 doc_masterselement(cfg_printer_t *pctx, const cfg_type_t *type) {
3789 cfg_print_cstr(pctx, "( ");
3790 cfg_print_cstr(pctx, "<masters>");
3791 cfg_print_cstr(pctx, " | ");
3792 cfg_print_cstr(pctx, "<ipv4_address>");
3793 cfg_print_cstr(pctx, " ");
3794 cfg_print_cstr(pctx, "[ port <integer> ]");
3795 cfg_print_cstr(pctx, " | ");
3796 cfg_print_cstr(pctx, "<ipv6_address>");
3797 cfg_print_cstr(pctx, " ");
3798 cfg_print_cstr(pctx, "[ port <integer> ]");
3799 cfg_print_cstr(pctx, " )");
3803 parse_masterselement(cfg_parser_t *pctx, const cfg_type_t *type,
3810 CHECK(cfg_peektoken(pctx, CFG_LEXOPT_QSTRING));
3811 if (pctx->token.type == isc_tokentype_string ||
3812 pctx->token.type == isc_tokentype_qstring) {
3813 if (cfg_lookingat_netaddr(pctx, CFG_ADDR_V4OK | CFG_ADDR_V6OK))
3814 CHECK(cfg_parse_sockaddr(pctx, &cfg_type_sockaddr,
3817 CHECK(cfg_parse_astring(pctx, &cfg_type_astring, ret));
3819 cfg_parser_error(pctx, CFG_LOG_NEAR,
3834 parse_ttlval(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
3841 CHECK(cfg_gettoken(pctx, 0));
3842 if (pctx->token.type != isc_tokentype_string) {
3847 result = dns_ttl_fromtext(&pctx->token.value.as_textregion, &ttl);
3849 cfg_parser_error(pctx, CFG_LOG_NEAR, "TTL out of range ");
3854 CHECK(cfg_create_obj(pctx, &cfg_type_uint32, &obj));
3860 cfg_parser_error(pctx, CFG_LOG_NEAR,
3874 parse_maxttl(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
3875 return (parse_enum_or_other(pctx, type, &cfg_type_ttlval, ret));
3879 doc_maxttl(cfg_printer_t *pctx, const cfg_type_t *type) {
3880 doc_enum_or_other(pctx, type, &cfg_type_ttlval);
3932 cfg_printer_t pctx;
3936 pctx.f = f;
3937 pctx.closure = closure;
3938 pctx.indent = 0;
3939 pctx.flags = 0;
3946 cfg_print_cstr(&pctx, "zone <string> [ <class> ] {\n");
3947 pctx.indent++;
3951 cfg_print_indent(&pctx);
3952 cfg_print_cstr(&pctx, "type ( master | primary );\n");
3955 cfg_print_indent(&pctx);
3956 cfg_print_cstr(&pctx, "type ( slave | secondary );\n");
3959 cfg_print_indent(&pctx);
3960 cfg_print_cstr(&pctx, "type stub;\n");
3963 cfg_print_indent(&pctx);
3964 cfg_print_cstr(&pctx, "type hint;\n");
3967 cfg_print_indent(&pctx);
3968 cfg_print_cstr(&pctx, "type forward;\n");
3971 cfg_print_indent(&pctx);
3972 cfg_print_cstr(&pctx, "type static-stub;\n");
3975 cfg_print_indent(&pctx);
3976 cfg_print_cstr(&pctx, "type redirect;\n");
3979 cfg_print_indent(&pctx);
3980 cfg_print_cstr(&pctx, "type delegation-only;\n");
3994 cfg_print_indent(&pctx);
3995 cfg_print_cstr(&pctx, clause->name);
3996 cfg_print_cstr(&pctx, " ");
3997 cfg_doc_obj(&pctx, clause->type);
3998 cfg_print_cstr(&pctx, ";");
3999 cfg_print_clauseflags(&pctx, clause->flags);
4000 cfg_print_cstr(&pctx, "\n");
4003 pctx.indent--;
4004 cfg_print_cstr(&pctx, "};\n");