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

📄 resconf.tsy

📁 bind 9.3结合mysql数据库
💻 TSY
📖 第 1 页 / 共 2 页
字号:
#ifndef lintstatic char *rcsid = "$Id: resconf.tsy,v 1.1.1.1 2003/06/04 00:27:00 marka Exp $";#endif/* * Copyright (c) 2002 Japan Network Information Center. * All rights reserved. *   * By using this file, you agree to the terms and conditions set forth bellow. *  * 			LICENSE TERMS AND CONDITIONS  *  * The following License Terms and Conditions apply, unless a different * license is obtained from Japan Network Information Center ("JPNIC"), * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda, * Chiyoda-ku, Tokyo 101-0047, Japan. *  * 1. Use, Modification and Redistribution (including distribution of any *    modified or derived work) in source and/or binary forms is permitted *    under this License Terms and Conditions. *  * 2. Redistribution of source code must retain the copyright notices as they *    appear in each source code file, this License Terms and Conditions. *  * 3. Redistribution in binary form must reproduce the Copyright Notice, *    this License Terms and Conditions, in the documentation and/or other *    materials provided with the distribution.  For the purposes of binary *    distribution the "Copyright Notice" refers to the following language: *    "Copyright (c) 2000-2002 Japan Network Information Center.  All rights reserved." *  * 4. The name of JPNIC may not be used to endorse or promote products *    derived from this Software without specific prior written approval of *    JPNIC. *  * 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC *    "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *    PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL JPNIC BE LIABLE *    FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR *    CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF *    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR *    BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, *    WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR *    OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF *    ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. */#include <stddef.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <stdarg.h>#include <idn/resconf.h>#include <idn/converter.h>#include <idn/log.h>#include "setenv.h"#include "testutil.h"#define CONF_FILENAME		"test.conf"#define MAP_FILENAME		"test.map"//--------------------------------------------------------------------// Setups and Teardowns.//--------------------------------------------------------------------//# SETUP//      group: generic-init{	idn_result_t r;	idn_resconf_t ctx = NULL;	setenv("IDN_LOCAL_CODESET", "UTF-8", 1);	r = idn_resconf_initialize();	ASSERT_RESULT(r, idn_success);	r = idn_resconf_create(&ctx);	ASSERT_RESULT(r, idn_success);}//# TEARDOWN//      group: generic-init{	if (ctx != NULL)		idn_resconf_destroy(ctx);	remove(CONF_FILENAME);	remove(MAP_FILENAME);}//# SETUP//	group: set-defaults{	r = idn_resconf_setdefaults(ctx);	ASSERT_RESULT(r, idn_success);}//# TEARDOWN//	group: set-defaults{}//# SETUP//	group: quiet{	int saved_log_level;	saved_log_level = idn_log_getlevel();	idn_log_setlevel(idn_log_level_fatal);}//# TEARDOWN//	group: quiet{	idn_log_setlevel(saved_log_level);}//# SETUP//	group: delimitermap_ctx{	idn_delimitermap_t delimitermap_ctx1 = NULL;	idn_delimitermap_t delimitermap_ctx2 = NULL;}//# TEARDOWN//	group: delimitermap_ctx{	if (delimitermap_ctx1 != NULL) 		idn_delimitermap_destroy(delimitermap_ctx1);	if (delimitermap_ctx2 != NULL) 		idn_delimitermap_destroy(delimitermap_ctx2);}//# SETUP//	group: idnconverter_ctx{	idn_converter_t idnconverter_ctx1 = NULL;	idn_converter_t idnconverter_ctx2 = NULL;}//# TEARDOWN//	group: idnconverter_ctx{	if (idnconverter_ctx1 != NULL) 		idn_converter_destroy(idnconverter_ctx1);	if (idnconverter_ctx2 != NULL) 		idn_converter_destroy(idnconverter_ctx2);}//# SETUP//	group: localconverter_ctx{	idn_converter_t localconverter_ctx1 = NULL;	idn_converter_t localconverter_ctx2 = NULL;}//# TEARDOWN//	group: localconverter_ctx{	if (localconverter_ctx1 != NULL) 		idn_converter_destroy(localconverter_ctx1);	if (localconverter_ctx2 != NULL) 		idn_converter_destroy(localconverter_ctx2);}//# SETUP//	group: auxidnconverter_ctx{	idn_converter_t auxidnconverter_ctx1 = NULL;	idn_converter_t auxidnconverter_ctx2 = NULL;}//# TEARDOWN//	group: auxidnconverter_ctx{	if (auxidnconverter_ctx1 != NULL) 		idn_converter_destroy(auxidnconverter_ctx1);	if (auxidnconverter_ctx2 != NULL) 		idn_converter_destroy(auxidnconverter_ctx2);}//# SETUP//	group: mapselector_ctx{	idn_mapselector_t mapselector_ctx1 = NULL;	idn_mapselector_t mapselector_ctx2 = NULL;}//# TEARDOWN//	group: mapselector_ctx{	if (mapselector_ctx1 != NULL) 		idn_mapselector_destroy(mapselector_ctx1);	if (mapselector_ctx2 != NULL) 		idn_mapselector_destroy(mapselector_ctx2);}//# SETUP//	group: mapper_ctx{	idn_mapper_t mapper_ctx1 = NULL;	idn_mapper_t mapper_ctx2 = NULL;}//# TEARDOWN//	group: mapper_ctx{	if (mapper_ctx1 != NULL) 		idn_mapper_destroy(mapper_ctx1);	if (mapper_ctx2 != NULL) 		idn_mapper_destroy(mapper_ctx2);}//# SETUP//	group: normalizer_ctx{	idn_normalizer_t normalizer_ctx1 = NULL;	idn_normalizer_t normalizer_ctx2 = NULL;}//# TEARDOWN//	group: normalizer_ctx{	if (normalizer_ctx1 != NULL) 		idn_normalizer_destroy(normalizer_ctx1);	if (normalizer_ctx2 != NULL) 		idn_normalizer_destroy(normalizer_ctx2);}//# SETUP//	group: prohibitchecker_ctx{	idn_checker_t prohibitchecker_ctx1 = NULL;	idn_checker_t prohibitchecker_ctx2 = NULL;}//# TEARDOWN//	group: prohibitchecker_ctx{	if (prohibitchecker_ctx1 != NULL) 		idn_checker_destroy(prohibitchecker_ctx1);	if (prohibitchecker_ctx2 != NULL) 		idn_checker_destroy(prohibitchecker_ctx2);}//# SETUP//	group: unassignedchecker_ctx{	idn_checker_t unassignedchecker_ctx1 = NULL;	idn_checker_t unassignedchecker_ctx2 = NULL;}//# TEARDOWN//	group: unassignedchecker_ctx{	if (unassignedchecker_ctx1 != NULL) 		idn_checker_destroy(unassignedchecker_ctx1);	if (unassignedchecker_ctx2 != NULL) 		idn_checker_destroy(unassignedchecker_ctx2);}//# SETUP//	group: bidichecker_ctx{	idn_checker_t bidichecker_ctx1 = NULL;	idn_checker_t bidichecker_ctx2 = NULL;}//# TEARDOWN//	group: bidichecker_ctx{	if (bidichecker_ctx1 != NULL) 		idn_checker_destroy(bidichecker_ctx1);	if (bidichecker_ctx2 != NULL) 		idn_checker_destroy(bidichecker_ctx2);}//--------------------------------------------------------------------// Testcases.//--------------------------------------------------------------------//# TESTCASE//	title: call create() without initialization.//--//	This must be the first test case.{	idn_result_t r;	idn_resconf_t ctx = NULL;	r = idn_resconf_create(&ctx);	ASSERT_RESULT(r, idn_failure);	if (ctx != NULL)		idn_resconf_destroy(ctx);}//# TESTCASE//	title: call initialize() twice.//{	idn_result_t r;	r = idn_resconf_initialize();	ASSERT_RESULT(r, idn_success);	r = idn_resconf_initialize();	ASSERT_RESULT(r, idn_success);}//# TESTCASE//	title: call create(){	idn_result_t r;	idn_resconf_t ctx;	r = idn_resconf_initialize();	ASSERT_RESULT(r, idn_success);	r = idn_resconf_create(&ctx);	ASSERT_RESULT(r, idn_success);	if (ctx != NULL)		idn_resconf_destroy(ctx);}//# TESTCASE//	title: load file (idn-encoding)//	group: generic-init{	const char *idn_encoding;	create_conf_file(CONF_FILENAME, 0,			 "idn-encoding	Punycode",			 NULL);	r = idn_resconf_loadfile(ctx, CONF_FILENAME);	ASSERT_RESULT(r, idn_success);}//# TESTCASE//	title: load file (nameprep)//	group: generic-init{	const char *idn_encoding;	create_conf_file(CONF_FILENAME, 0,			 "nameprep	" IDN_NAMEPREP_CURRENT,			 NULL);	r = idn_resconf_loadfile(ctx, CONF_FILENAME);	ASSERT_RESULT(r, idn_success);}//# TESTCASE//	title: load file (idn-encoding & nameprep)//	group: generic-init{	const char *idn_encoding;	create_conf_file(CONF_FILENAME, 0,			 "idn-encoding	Punycode",			 "nameprep	" IDN_NAMEPREP_CURRENT,			 NULL);	r = idn_resconf_loadfile(ctx, CONF_FILENAME);	ASSERT_RESULT(r, idn_success);}//# TESTCASE//	title: load file (empty)//	group: generic-init{	const char *idn_encoding;	create_conf_file(CONF_FILENAME, 0,			 NULL);	r = idn_resconf_loadfile(ctx, CONF_FILENAME);	ASSERT_RESULT(r, idn_success);}//# TESTCASE//	title: load file (local-map filemap)//	group: generic-init{	const char *idn_encoding;	create_conf_file(CONF_FILENAME, 0,			 "local-map	.jp	filemap:" MAP_FILENAME,			 NULL);	create_conf_file(MAP_FILENAME, 0,			 "2212; FF0D",			 NULL);	r = idn_resconf_loadfile(ctx, CONF_FILENAME);	ASSERT_RESULT(r, idn_success);}//# TESTCASE//	title: load file (local-map nameprep)//	group: generic-init{	const char *idn_encoding;	create_conf_file(CONF_FILENAME, 0,			 "local-map	.jp	" IDN_NAMEPREP_CURRENT,			 NULL);	r = idn_resconf_loadfile(ctx, CONF_FILENAME);	ASSERT_RESULT(r, idn_success);}//# TESTCASE//	title: set defaults//	group: generic-init set-defaults{}//# TESTCASE//	title: load file (no file)//	group: generic-init{	r = idn_resconf_loadfile(ctx, "no-such-file");	ASSERT_RESULT(r, idn_nofile);}//# TESTCASE//	title: load file (empty file name)//	group: generic-init{	r = idn_resconf_loadfile(ctx, "");	ASSERT_RESULT(r, idn_nofile);}//# TESTCASE//	title: load file (unknown command)//	group: generic-init quiet{	create_conf_file(CONF_FILENAME, 0,			 "unknown-command	" IDN_NAMEPREP_CURRENT,			 NULL);	r = idn_resconf_loadfile(ctx, CONF_FILENAME);	ASSERT_RESULT(r, idn_invalid_syntax);}//# TESTCASE//	title: load file (no newline at the end of file)//	group: generic-init quiet{	create_conf_file(CONF_FILENAME, CONF_NO_EOF_NEWLINE,			 "nameprep	" IDN_NAMEPREP_CURRENT,			 NULL);	r = idn_resconf_loadfile(ctx, CONF_FILENAME);	ASSERT_RESULT(r, idn_success);}//# TESTCASE//	title: load file (too long line)//	group: generic-init quiet{	char arg[1024];	char *line;	/* arg = "local-map . ////..." */	memset(arg, '/', sizeof(arg));	arg[sizeof(arg) - 1] = '\0';	line = "local-map	.	";	memcpy(arg, line, strlen(line));	create_conf_file(CONF_FILENAME, 0, arg, NULL);	r = idn_resconf_loadfile(ctx, CONF_FILENAME);	ASSERT_RESULT(r, idn_invalid_syntax);}//# TESTCASE//	title: load file (empty file)//	group: generic-init{	create_conf_file(CONF_FILENAME, 0, "", NULL);	r = idn_resconf_loadfile(ctx, CONF_FILENAME);	ASSERT_RESULT(r, idn_success);}//# TESTCASE//	title: load file (invalid parameter for idn-encoding)//	group: generic-init quiet{#ifndef WITHOUT_ICONV	SKIP_TESTCASE;#else	create_conf_file(CONF_FILENAME, 0,			 "idn-encoding	invalid-encoding-name",			 NULL);	r = idn_resconf_loadfile(ctx, CONF_FILENAME);	ASSERT_RESULT(r, idn_invalid_name);#endif}//# TESTCASE//	title: load file (define idn-encoding twice)//	group: generic-init quiet{#ifndef WITHOUT_ICONV	SKIP_TESTCASE;#else	create_conf_file(CONF_FILENAME, CONF_NO_EOF_NEWLINE,			 "idn-encoding	Punycode", 			 "idn-encoding	Punycode", 			 NULL);	r = idn_resconf_loadfile(ctx, CONF_FILENAME);	ASSERT_RESULT(r, idn_invalid_syntax);#endif}//# TESTCASE//	title: load file (invalid parameter for nameprep)//	group: generic-init quiet{

⌨️ 快捷键说明

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