⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 namedconf.c

📁 bind 9.3结合mysql数据库
💻 C
📖 第 1 页 / 共 4 页
字号:
/* * Copyright (C) 2004  Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2002, 2003  Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. *//* $Id: namedconf.c,v 1.21.44.28 2004/06/04 02:33:01 marka Exp $ */#include <config.h>#include <string.h>#include <isc/lex.h>#include <isc/result.h>#include <isc/string.h>#include <isc/util.h>#include <isccfg/cfg.h>#include <isccfg/grammar.h>#include <isccfg/log.h>#define TOKEN_STRING(pctx) (pctx->token.value.as_textregion.base)/* Check a return value. */#define CHECK(op) 						\     	do { result = (op); 					\		if (result != ISC_R_SUCCESS) goto cleanup; 	\	} while (0)/* Clean up a configuration object if non-NULL. */#define CLEANUP_OBJ(obj) \	do { if ((obj) != NULL) cfg_obj_destroy(pctx, &(obj)); } while (0)/* * Forward declarations of static functions. */static isc_result_tparse_enum_or_other(cfg_parser_t *pctx, const cfg_type_t *enumtype,		    const cfg_type_t *othertype, cfg_obj_t **ret);static isc_result_tparse_keyvalue(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret);static isc_result_tparse_optional_keyvalue(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret);static voidprint_keyvalue(cfg_printer_t *pctx, cfg_obj_t *obj);static voiddoc_keyvalue(cfg_printer_t *pctx, const cfg_type_t *type);static voiddoc_optional_keyvalue(cfg_printer_t *pctx, const cfg_type_t *type);static cfg_type_t cfg_type_acl;static cfg_type_t cfg_type_addrmatchelt;static cfg_type_t cfg_type_bracketed_aml;static cfg_type_t cfg_type_bracketed_namesockaddrkeylist;static cfg_type_t cfg_type_bracketed_sockaddrlist;static cfg_type_t cfg_type_controls;static cfg_type_t cfg_type_controls_sockaddr;static cfg_type_t cfg_type_destinationlist;static cfg_type_t cfg_type_dialuptype;static cfg_type_t cfg_type_key;static cfg_type_t cfg_type_logfile;static cfg_type_t cfg_type_logging;static cfg_type_t cfg_type_logseverity;static cfg_type_t cfg_type_lwres;static cfg_type_t cfg_type_masterselement;static cfg_type_t cfg_type_nameportiplist;static cfg_type_t cfg_type_negated;static cfg_type_t cfg_type_notifytype;static cfg_type_t cfg_type_optional_class;static cfg_type_t cfg_type_optional_facility;static cfg_type_t cfg_type_optional_facility;static cfg_type_t cfg_type_optional_keyref;static cfg_type_t cfg_type_optional_port;static cfg_type_t cfg_type_options;static cfg_type_t cfg_type_portiplist;static cfg_type_t cfg_type_querysource4;static cfg_type_t cfg_type_querysource6;static cfg_type_t cfg_type_querysource;static cfg_type_t cfg_type_server;static cfg_type_t cfg_type_server_key_kludge;static cfg_type_t cfg_type_size;static cfg_type_t cfg_type_sizenodefault;static cfg_type_t cfg_type_sockaddr4wild;static cfg_type_t cfg_type_sockaddr6wild;static cfg_type_t cfg_type_view;static cfg_type_t cfg_type_viewopts;static cfg_type_t cfg_type_zone;static cfg_type_t cfg_type_zoneopts;/* tkey-dhkey */static cfg_tuplefielddef_t tkey_dhkey_fields[] = {	{ "name", &cfg_type_qstring, 0 },	{ "keyid", &cfg_type_uint32, 0 },	{ NULL, NULL, 0 }};static cfg_type_t cfg_type_tkey_dhkey = {	"tkey-dhkey", cfg_parse_tuple, cfg_print_tuple, cfg_doc_tuple, &cfg_rep_tuple,	tkey_dhkey_fields};/* listen-on */static cfg_tuplefielddef_t listenon_fields[] = {	{ "port", &cfg_type_optional_port, 0 },	{ "acl", &cfg_type_bracketed_aml, 0 },	{ NULL, NULL, 0 }};static cfg_type_t cfg_type_listenon = {	"listenon", cfg_parse_tuple, cfg_print_tuple, cfg_doc_tuple, &cfg_rep_tuple, listenon_fields };/* acl */static cfg_tuplefielddef_t acl_fields[] = {	{ "name", &cfg_type_astring, 0 },	{ "value", &cfg_type_bracketed_aml, 0 },	{ NULL, NULL, 0 }};static cfg_type_t cfg_type_acl = {	"acl", cfg_parse_tuple, cfg_print_tuple, cfg_doc_tuple, &cfg_rep_tuple, acl_fields };/* masters */static cfg_tuplefielddef_t masters_fields[] = {	{ "name", &cfg_type_astring, 0 },	{ "port", &cfg_type_optional_port, 0 },	{ "addresses", &cfg_type_bracketed_namesockaddrkeylist, 0 },	{ NULL, NULL, 0 }};static cfg_type_t cfg_type_masters = {	"masters", cfg_parse_tuple, cfg_print_tuple, cfg_doc_tuple, &cfg_rep_tuple, masters_fields };/* * "sockaddrkeylist", a list of socket addresses with optional keys * and an optional default port, as used in the masters option. * E.g., *   "port 1234 { mymasters; 10.0.0.1 key foo; 1::2 port 69; }" */static cfg_tuplefielddef_t namesockaddrkey_fields[] = {	{ "masterselement", &cfg_type_masterselement, 0 },	{ "key", &cfg_type_optional_keyref, 0 },	{ NULL, NULL, 0 },};static cfg_type_t cfg_type_namesockaddrkey = {	"namesockaddrkey", cfg_parse_tuple, cfg_print_tuple, cfg_doc_tuple, &cfg_rep_tuple,	namesockaddrkey_fields};static cfg_type_t cfg_type_bracketed_namesockaddrkeylist = {	"bracketed_namesockaddrkeylist", cfg_parse_bracketed_list,	cfg_print_bracketed_list, cfg_doc_bracketed_list, &cfg_rep_list, &cfg_type_namesockaddrkey};static cfg_tuplefielddef_t namesockaddrkeylist_fields[] = {	{ "port", &cfg_type_optional_port, 0 },	{ "addresses", &cfg_type_bracketed_namesockaddrkeylist, 0 },	{ NULL, NULL, 0 }};static cfg_type_t cfg_type_namesockaddrkeylist = {	"sockaddrkeylist", cfg_parse_tuple, cfg_print_tuple, cfg_doc_tuple, &cfg_rep_tuple,	namesockaddrkeylist_fields};/* * A list of socket addresses with an optional default port, * as used in the also-notify option.  E.g., * "port 1234 { 10.0.0.1; 1::2 port 69; }" */static cfg_tuplefielddef_t portiplist_fields[] = {	{ "port", &cfg_type_optional_port, 0 },	{ "addresses", &cfg_type_bracketed_sockaddrlist, 0 },	{ NULL, NULL, 0 }};static cfg_type_t cfg_type_portiplist = {	"portiplist", cfg_parse_tuple, cfg_print_tuple, cfg_doc_tuple, &cfg_rep_tuple,	portiplist_fields};/* * A public key, as in the "pubkey" statement. */static cfg_tuplefielddef_t pubkey_fields[] = {	{ "flags", &cfg_type_uint32, 0 },	{ "protocol", &cfg_type_uint32, 0 },	{ "algorithm", &cfg_type_uint32, 0 },	{ "key", &cfg_type_qstring, 0 },	{ NULL, NULL, 0 }};static cfg_type_t cfg_type_pubkey = {	"pubkey", cfg_parse_tuple, cfg_print_tuple, cfg_doc_tuple, &cfg_rep_tuple, pubkey_fields };/* * A list of RR types, used in grant statements. * Note that the old parser allows quotes around the RR type names. */static cfg_type_t cfg_type_rrtypelist = { 	"rrtypelist", cfg_parse_spacelist, cfg_print_spacelist, cfg_doc_terminal,	&cfg_rep_list, &cfg_type_astring};static const char *mode_enums[] = { "grant", "deny", NULL };static cfg_type_t cfg_type_mode = {	"mode", cfg_parse_enum, cfg_print_ustring, cfg_doc_enum, &cfg_rep_string,	&mode_enums};static const char *matchtype_enums[] = {	"name", "subdomain", "wildcard", "self", NULL };static cfg_type_t cfg_type_matchtype = {	"matchtype", cfg_parse_enum, cfg_print_ustring, cfg_doc_enum, &cfg_rep_string,	&matchtype_enums};/* * A grant statement, used in the update policy. */static cfg_tuplefielddef_t grant_fields[] = {	{ "mode", &cfg_type_mode, 0 },	{ "identity", &cfg_type_astring, 0 }, /* domain name */ 	{ "matchtype", &cfg_type_matchtype, 0 },	{ "name", &cfg_type_astring, 0 }, /* domain name */	{ "types", &cfg_type_rrtypelist, 0 },	{ NULL, NULL, 0 }};static cfg_type_t cfg_type_grant = {	"grant", cfg_parse_tuple, cfg_print_tuple, cfg_doc_tuple, &cfg_rep_tuple, grant_fields };static cfg_type_t cfg_type_updatepolicy = {	"update_policy", cfg_parse_bracketed_list, cfg_print_bracketed_list, cfg_doc_bracketed_list,	&cfg_rep_list, &cfg_type_grant};/* * A view statement. */static cfg_tuplefielddef_t view_fields[] = {	{ "name", &cfg_type_astring, 0 },	{ "class", &cfg_type_optional_class, 0 },	{ "options", &cfg_type_viewopts, 0 },	{ NULL, NULL, 0 }};static cfg_type_t cfg_type_view = {	"view", cfg_parse_tuple, cfg_print_tuple, cfg_doc_tuple, &cfg_rep_tuple, view_fields };/* * A zone statement. */static cfg_tuplefielddef_t zone_fields[] = {	{ "name", &cfg_type_astring, 0 },	{ "class", &cfg_type_optional_class, 0 },	{ "options", &cfg_type_zoneopts, 0 },	{ NULL, NULL, 0 }};static cfg_type_t cfg_type_zone = {	"zone", cfg_parse_tuple, cfg_print_tuple, cfg_doc_tuple, &cfg_rep_tuple, zone_fields };/* * A "category" clause in the "logging" statement. */static cfg_tuplefielddef_t category_fields[] = {	{ "name", &cfg_type_astring, 0 },	{ "destinations", &cfg_type_destinationlist,0 },	{ NULL, NULL, 0 }};static cfg_type_t cfg_type_category = {	"category", cfg_parse_tuple, cfg_print_tuple, cfg_doc_tuple, &cfg_rep_tuple, category_fields };/* * A trusted key, as used in the "trusted-keys" statement. */static cfg_tuplefielddef_t trustedkey_fields[] = {	{ "name", &cfg_type_astring, 0 },	{ "flags", &cfg_type_uint32, 0 },	{ "protocol", &cfg_type_uint32, 0 },	{ "algorithm", &cfg_type_uint32, 0 },	{ "key", &cfg_type_qstring, 0 },	{ NULL, NULL, 0 }};static cfg_type_t cfg_type_trustedkey = {	"trustedkey", cfg_parse_tuple, cfg_print_tuple, cfg_doc_tuple, &cfg_rep_tuple,	trustedkey_fields};static keyword_type_t wild_class_kw = { "class", &cfg_type_ustring };static cfg_type_t cfg_type_optional_wild_class = {	"optional_wild_class", parse_optional_keyvalue, print_keyvalue,	doc_optional_keyvalue, &cfg_rep_string, &wild_class_kw};static keyword_type_t wild_type_kw = { "type", &cfg_type_ustring };static cfg_type_t cfg_type_optional_wild_type = {	"optional_wild_type", parse_optional_keyvalue,	print_keyvalue, doc_optional_keyvalue, &cfg_rep_string, &wild_type_kw};static keyword_type_t wild_name_kw = { "name", &cfg_type_qstring };static cfg_type_t cfg_type_optional_wild_name = {	"optional_wild_name", parse_optional_keyvalue,	print_keyvalue, doc_optional_keyvalue, &cfg_rep_string, &wild_name_kw};/* * An rrset ordering element. */static cfg_tuplefielddef_t rrsetorderingelement_fields[] = {	{ "class", &cfg_type_optional_wild_class, 0 },	{ "type", &cfg_type_optional_wild_type, 0 },	{ "name", &cfg_type_optional_wild_name, 0 },	{ "order", &cfg_type_ustring, 0 }, /* must be literal "order" */ 	{ "ordering", &cfg_type_ustring, 0 },	{ NULL, NULL, 0 }};static cfg_type_t cfg_type_rrsetorderingelement = {	"rrsetorderingelement", cfg_parse_tuple, cfg_print_tuple, cfg_doc_tuple, &cfg_rep_tuple,	rrsetorderingelement_fields};/* * A global or view "check-names" option.  Note that the zone * "check-names" option has a different syntax. */static const char *checktype_enums[] = { "master", "slave", "response", NULL };static cfg_type_t cfg_type_checktype = {	"checktype", cfg_parse_enum, cfg_print_ustring, cfg_doc_enum,	&cfg_rep_string, &checktype_enums};static const char *checkmode_enums[] = { "fail", "warn", "ignore", NULL };static cfg_type_t cfg_type_checkmode = {	"checkmode", cfg_parse_enum, cfg_print_ustring, cfg_doc_enum,	&cfg_rep_string, &checkmode_enums};static cfg_tuplefielddef_t checknames_fields[] = {	{ "type", &cfg_type_checktype, 0 },	{ "mode", &cfg_type_checkmode, 0 },	{ NULL, NULL, 0 }};static cfg_type_t cfg_type_checknames = {	"checknames", cfg_parse_tuple, cfg_print_tuple, cfg_doc_tuple, &cfg_rep_tuple,	checknames_fields};static cfg_type_t cfg_type_bracketed_sockaddrlist = {	"bracketed_sockaddrlist", cfg_parse_bracketed_list, cfg_print_bracketed_list, cfg_doc_bracketed_list,	&cfg_rep_list, &cfg_type_sockaddr};static cfg_type_t cfg_type_rrsetorder = {	"rrsetorder", cfg_parse_bracketed_list, cfg_print_bracketed_list, cfg_doc_bracketed_list,	&cfg_rep_list, &cfg_type_rrsetorderingelement};static keyword_type_t port_kw = { "port", &cfg_type_uint32 };static cfg_type_t cfg_type_optional_port = {	"optional_port", parse_optional_keyvalue, print_keyvalue,	doc_optional_keyvalue, &cfg_rep_uint32, &port_kw};/* A list of keys, as in the "key" clause of the controls statement. */static cfg_type_t cfg_type_keylist = {	"keylist", cfg_parse_bracketed_list, cfg_print_bracketed_list, cfg_doc_bracketed_list, &cfg_rep_list,	&cfg_type_astring};static cfg_type_t cfg_type_trustedkeys = {	"trusted-keys", cfg_parse_bracketed_list, cfg_print_bracketed_list, cfg_doc_bracketed_list, &cfg_rep_list,	&cfg_type_trustedkey};static const char *forwardtype_enums[] = { "first", "only", NULL };static cfg_type_t cfg_type_forwardtype = {	"forwardtype", cfg_parse_enum, cfg_print_ustring, cfg_doc_enum, &cfg_rep_string,	&forwardtype_enums};static const char *zonetype_enums[] = {	"master", "slave", "stub", "hint", "forward", "delegation-only", NULL };static cfg_type_t cfg_type_zonetype = {	"zonetype", cfg_parse_enum, cfg_print_ustring, cfg_doc_enum, &cfg_rep_string,	&zonetype_enums};static const char *loglevel_enums[] = {	"critical", "error", "warning", "notice", "info", "dynamic", NULL };static cfg_type_t cfg_type_loglevel = {	"loglevel", cfg_parse_enum, cfg_print_ustring, cfg_doc_enum, &cfg_rep_string,	&loglevel_enums};static const char *transferformat_enums[] = {	"many-answers", "one-answer", NULL };static cfg_type_t cfg_type_transferformat = {	"transferformat", cfg_parse_enum, cfg_print_ustring, cfg_doc_enum, &cfg_rep_string,	&transferformat_enums};/* * The special keyword "none", as used in the pid-file option. */static voidprint_none(cfg_printer_t *pctx, cfg_obj_t *obj) {	UNUSED(obj);	cfg_print_chars(pctx, "none", 4);}static cfg_type_t cfg_type_none = {	"none", NULL, print_none, NULL, &cfg_rep_void, NULL};/* * A quoted string or the special keyword "none".  Used in the pid-file option. */static isc_result_tparse_qstringornone(cfg_parser_t *pctx, const cfg_type_t *type,		    cfg_obj_t **ret){	isc_result_t result;	CHECK(cfg_gettoken(pctx, CFG_LEXOPT_QSTRING));	if (pctx->token.type == isc_tokentype_string &&	    strcasecmp(TOKEN_STRING(pctx), "none") == 0)		return (cfg_create_obj(pctx, &cfg_type_none, ret));	cfg_ungettoken(pctx);	return (cfg_parse_qstring(pctx, type, ret)); cleanup:	return (result);}static voiddoc_qstringornone(cfg_printer_t *pctx, const cfg_type_t *type) {	UNUSED(type);	cfg_print_chars(pctx, "( <quoted_string> | none )", 26);}static cfg_type_t cfg_type_qstringornone = {	"qstringornone", parse_qstringornone, NULL, doc_qstringornone, NULL, NULL };/* * keyword hostname */static voidprint_hostname(cfg_printer_t *pctx, cfg_obj_t *obj) {	UNUSED(obj);	cfg_print_chars(pctx, "hostname", 4);}static cfg_type_t cfg_type_hostname = {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -