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

📄 api.tsy

📁 bind 9.3结合mysql数据库
💻 TSY
📖 第 1 页 / 共 2 页
字号:
#ifndef lintstatic char *rcsid = "$Id: api.tsy,v 1.1.1.1 2003/06/04 00:26:50 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 <idn/api.h>#include <idn/log.h>#include "codeset.h"#include "setenv.h"#ifndef EUCJP_ENCODING_NAME#define EUCJP_ENCODING_NAME	"eucJP"#endif/* * U+304B: hiragana letter KA * U+3099: combining katakana-hiragana voiced sound mark * * 	map("U+304B U+3099") -> "U+304C" * * U+304C: hiragana letter GA */#define UTF8_NAME		"A<U+304B><U+3099>"#define UTF8_REVNAME		"a<U+304C>"/* * A4AC: hiragana letter GA (in EUC-JP) */#define EUCJP_NAME	"\xa4\xac"#define EUCJP_REVNAME	"\xa4\xac"/* * Conversion result of "U+304B U+3099 A" */#define PUNYCODE_NAME	"xn--a-i8t"/* * Conversion result of "A U+304B U+3099" (in EUC-JP). */#define AUX_EUCJP_NAME	"xn--a-i\xa3\xb8t"//--------------------------------------------------------------------// Setups and Teardowns.//--------------------------------------------------------------------//# SETUP//	group: generic-conversion//--//	Initialize the `api' module.//	Set local encoding to `UTF-8'.{	char to[256];	idn_result_t r;	setenv("IDN_LOCAL_CODESET", "UTF-8", 1);	unsetenv("IDN_DISABLE");	idn_nameinit(0);}//# SETUP//	group: quiet//--//	Set log level to `fatal' to supress log messages.{	int saved_log_level;	saved_log_level = idn_log_getlevel();	idn_log_setlevel(idn_log_level_fatal);}//# TEARDOWN//	group: quiet//--//	Restore log level.{	idn_log_setlevel(saved_log_level);}//--------------------------------------------------------------------// Testcases.//--------------------------------------------------------------------//# TESTCASE//	title: basic conversion by encodename()//	group: generic-conversion{	r = idn_encodename(IDN_ENCODE_APP, UTF8_NAME, to, sizeof(to));	ASSERT_RESULT(r, idn_success);	ASSERT_STRING(to, PUNYCODE_NAME);}//# TESTCASE//	title: basic conversion by decodename()//	group: generic-conversion{	r = idn_decodename(IDN_DECODE_APP, PUNYCODE_NAME, to, sizeof(to));	ASSERT_RESULT(r, idn_success);	ASSERT_STRING(to, UTF8_REVNAME);}//# TESTCASE//	title: basic conversion by decodename2()//	group: generic-conversion{	r = idn_decodename2(IDN_DECODE_APP, AUX_EUCJP_NAME, to, sizeof(to),			    EUCJP_ENCODING_NAME);#ifdef WITHOUT_ICONV	ASSERT_RESULT(r, idn_failure);#else	ASSERT_RESULT(r, idn_success);	ASSERT_STRING(to, UTF8_REVNAME);#endif}//# TESTCASE//	title: call decodename2() with auxencoding=NULL//	group: generic-conversion{#ifdef WITHOUT_ICONV	SKIP_TESTCASE;#else	r = idn_decodename2(IDN_DECODE_APP, PUNYCODE_NAME, to, sizeof(to),			    NULL);	ASSERT_RESULT(r, idn_success);	ASSERT_STRING(to, UTF8_REVNAME);#endif}//# TESTCASE//	title: call encodename() with actions=0//	group: generic-conversion{	r = idn_encodename(0, UTF8_NAME, to, sizeof(to));	ASSERT_RESULT(r, idn_success);	ASSERT_STRING(to, UTF8_NAME);}//# TESTCASE//	title: call decodename() with actions=0//	group: generic-conversion{	r = idn_decodename(0, PUNYCODE_NAME, to, sizeof(to));	ASSERT_RESULT(r, idn_success);	ASSERT_STRING(to, PUNYCODE_NAME);}//# TESTCASE//	title: call decodename2() with actions=0//	group: generic-conversion{#ifdef WITHOUT_ICONV	SKIP_TESTCASE;#else	r = idn_decodename2(0, AUX_EUCJP_NAME, to, sizeof(to),			    EUCJP_ENCODING_NAME);	ASSERT_RESULT(r, idn_success);	ASSERT_STRING(to, AUX_EUCJP_NAME);#endif}//# TESTCASE//	title: call encodename() with actions=rtcheck//	group: generic-conversion quiet{	r = idn_encodename(IDN_RTCHECK, EUCJP_NAME, to, sizeof(to));	ASSERT_RESULT(r, idn_invalid_action);}//# TESTCASE//	title: call encodename() with actions=decode-query//	group: generic-conversion quiet{	r = idn_encodename(IDN_DECODE_QUERY, EUCJP_NAME, to, sizeof(to));	ASSERT_RESULT(r, idn_invalid_action);}//# TESTCASE//	title: call encodename() with actions=decode-app//	group: generic-conversion quiet{	r = idn_encodename(IDN_DECODE_APP, EUCJP_NAME, to, sizeof(to));	ASSERT_RESULT(r, idn_invalid_action);}//# TESTCASE//	title: call encodename() with actions=decode-stored//	group: generic-conversion quiet{	r = idn_encodename(IDN_DECODE_STORED, EUCJP_NAME, to, sizeof(to));	ASSERT_RESULT(r, idn_invalid_action);}//# TESTCASE//	title: call encodename() with actions=(1<<31)//	group: generic-conversion quiet{	r = idn_encodename(1 << 31, EUCJP_NAME, to, sizeof(to));	ASSERT_RESULT(r, idn_invalid_action);}//# TESTCASE//	title: call decodename() with actions=localmap//	group: generic-conversion quiet{	r = idn_decodename(IDN_LOCALMAP, PUNYCODE_NAME, to, sizeof(to));	ASSERT_RESULT(r, idn_invalid_action);}//# TESTCASE//	title: call decodename2() with actions=localmap//	group: generic-conversion quiet{#ifdef WITHOUT_ICONV	SKIP_TESTCASE;#else	r = idn_decodename2(IDN_LOCALMAP, AUX_EUCJP_NAME, to, sizeof(to),			    EUCJP_ENCODING_NAME);	ASSERT_RESULT(r, idn_invalid_action);#endif}//# TESTCASE//	title: call decodename() with actions=lencheck//	group: generic-conversion quiet{	r = idn_decodename(IDN_LENCHECK, PUNYCODE_NAME, to, sizeof(to));	ASSERT_RESULT(r, idn_invalid_action);}//# TESTCASE//	title: call decodename2() with actions=lencheck//	group: generic-conversion quiet{#ifdef WITHOUT_ICONV	SKIP_TESTCASE;#else	r = idn_decodename2(IDN_LENCHECK, AUX_EUCJP_NAME, to, sizeof(to),			    EUCJP_ENCODING_NAME);	ASSERT_RESULT(r, idn_invalid_action);#endif}//# TESTCASE//	title: call decodename() with actions=encode-query//	group: generic-conversion quiet{	r = idn_decodename(IDN_ENCODE_QUERY, PUNYCODE_NAME, to, sizeof(to));	ASSERT_RESULT(r, idn_invalid_action);}//# TESTCASE//	title: call decodename2() with actions=encode-query//	group: generic-conversion quiet{#ifdef WITHOUT_ICONV	SKIP_TESTCASE;#else	r = idn_decodename2(IDN_ENCODE_QUERY, AUX_EUCJP_NAME, to, sizeof(to),			    EUCJP_ENCODING_NAME);	ASSERT_RESULT(r, idn_invalid_action);#endif}//# TESTCASE//	title: call decodename() with actions=encode-app//	group: generic-conversion quiet{	r = idn_decodename(IDN_ENCODE_APP, PUNYCODE_NAME, to, sizeof(to));	ASSERT_RESULT(r, idn_invalid_action);}//# TESTCASE//	title: call decodename2() with actions=encode-app//	group: generic-conversion quiet{#ifdef WITHOUT_ICONV	SKIP_TESTCASE;#else	r = idn_decodename2(IDN_ENCODE_APP, AUX_EUCJP_NAME, to, sizeof(to),			    EUCJP_ENCODING_NAME);	ASSERT_RESULT(r, idn_invalid_action);#endif}//# TESTCASE//	title: call decodename() with actions=encode-stored//	group: generic-conversion quiet{	r = idn_decodename(IDN_ENCODE_STORED, PUNYCODE_NAME, to, sizeof(to));	ASSERT_RESULT(r, idn_invalid_action);}//# TESTCASE//	title: call decodename2() with actions=encode-stored//	group: generic-conversion quiet{#ifdef WITHOUT_ICONV	SKIP_TESTCASE;#else	r = idn_decodename2(IDN_ENCODE_STORED, AUX_EUCJP_NAME, to, sizeof(to),			    EUCJP_ENCODING_NAME);	ASSERT_RESULT(r, idn_invalid_action);#endif}//# TESTCASE//	title: call decodename() with actions=(1<<31)//	group: generic-conversion quiet{	r = idn_decodename(1 << 31, PUNYCODE_NAME, to, sizeof(to));	ASSERT_RESULT(r, idn_invalid_action);}//# TESTCASE//	title: call decodename2() with actions=(1<<31)//	group: generic-conversion quiet{#ifdef WITHOUT_ICONV	SKIP_TESTCASE;#else	r = idn_decodename2(1 << 31, AUX_EUCJP_NAME, to, sizeof(to),			    EUCJP_ENCODING_NAME);	ASSERT_RESULT(r, idn_invalid_action);#endif}//# TESTCASE//	title: call encodename() with actions=localconv//	group: generic-conversion quiet{#ifndef WITHOUT_ICONV	SKIP_TESTCASE;#else	r = idn_encodename(IDN_LOCALCONV, UTF8_NAME, to, sizeof(to));	ASSERT_RESULT(r, idn_invalid_action);#endif}//# TESTCASE//	title: call decodename() with actions=localconv//	group: generic-conversion quiet{#ifndef WITHOUT_ICONV	SKIP_TESTCASE;#else	r = idn_decodename(IDN_LOCALCONV, PUNYCODE_NAME, to, sizeof(to));	ASSERT_RESULT(r, idn_invalid_action);#endif}//# TESTCASE//	title: call decodename2() with actions=localconv//	group: generic-conversion{#ifndef WITHOUT_ICONV	SKIP_TESTCASE;#else	r = idn_decodename2(IDN_LOCALCONV, AUX_EUCJP_NAME, to, sizeof(to),			    EUCJP_ENCODING_NAME);	ASSERT_RESULT(r, idn_failure);#endif}//# TESTCASE//	title: call enable(0) and then encodename()//	group: generic-conversion{	idn_enable(0);	r = idn_encodename(IDN_ENCODE_APP, UTF8_NAME, to, sizeof(to));	ASSERT_RESULT(r, idn_success);	ASSERT_STRING(to, UTF8_NAME);}//# TESTCASE//	title: call decodename() when IDN_DISABLE is defined//	group: generic-conversion{	idn_enable(0);	r = idn_decodename(IDN_DECODE_APP, PUNYCODE_NAME, to, sizeof(to));	ASSERT_RESULT(r, idn_success);	ASSERT_STRING(to, PUNYCODE_NAME);}//# TESTCASE//	title: call decodename() when IDN_DISABLE is defined//	group: generic-conversion{#ifdef WITHOUT_ICONV	SKIP_TESTCASE;#else	idn_enable(0);	r = idn_decodename2(IDN_DECODE_APP, AUX_EUCJP_NAME, to, sizeof(to),			    EUCJP_ENCODING_NAME);	ASSERT_RESULT(r, idn_success);	ASSERT_STRING(to, AUX_EUCJP_NAME);#endif}//# TESTCASE//	title: call enable(0) and then encodename()//	group: generic-conversion{	idn_enable(0);	r = idn_encodename(IDN_ENCODE_APP, UTF8_NAME, to, sizeof(to));	ASSERT_RESULT(r, idn_success);	ASSERT_STRING(to, UTF8_NAME);}//# TESTCASE//	title: call enable(0) and then decodename()//	group: generic-conversion{	idn_enable(0);	r = idn_decodename(IDN_DECODE_APP, PUNYCODE_NAME, to, sizeof(to));	ASSERT_RESULT(r, idn_success);	ASSERT_STRING(to, PUNYCODE_NAME);}//# TESTCASE//	title: call enable(0) and then decodename2()//	group: generic-conversion{#ifdef WITHOUT_ICONV	SKIP_TESTCASE;#else	idn_enable(0);	r = idn_decodename2(IDN_DECODE_APP, AUX_EUCJP_NAME, to, sizeof(to),			    EUCJP_ENCODING_NAME);	ASSERT_RESULT(r, idn_success);	ASSERT_STRING(to, AUX_EUCJP_NAME);#endif}//# TESTCASE//	title: set IDN_DISABLE and call encodename()//	group: generic-conversion{	setenv("IDN_DISABLE", "1", 1);	r = idn_encodename(IDN_ENCODE_APP, UTF8_NAME, to, sizeof(to));	ASSERT_RESULT(r, idn_success);	ASSERT_STRING(to, UTF8_NAME);}//# TESTCASE//	title: set IDN_DISABLE and call decodename()//	group: generic-conversion{	setenv("IDN_DISABLE", "1", 1);	r = idn_decodename(IDN_DECODE_APP, PUNYCODE_NAME, to, sizeof(to));	ASSERT_RESULT(r, idn_success);	ASSERT_STRING(to, PUNYCODE_NAME);}//# TESTCASE//	title: set IDN_DISABLE and call decodename2()//	group: generic-conversion{

⌨️ 快捷键说明

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