diff options
author | Martin Nagy <mnagy@redhat.com> | 2009-02-11 20:37:59 +0100 |
---|---|---|
committer | Martin Nagy <mnagy@redhat.com> | 2009-02-11 20:37:59 +0100 |
commit | f50ae72ec3417cae55dd4e085991c01af9fdc5f1 (patch) | |
tree | 0e36c9a3320f6d068df93d3ff6d84b821d23db40 /contrib/idn/idnkit-1.0-src/lib | |
download | bind_dynamic-f50ae72ec3417cae55dd4e085991c01af9fdc5f1.tar.gz bind_dynamic-f50ae72ec3417cae55dd4e085991c01af9fdc5f1.tar.xz bind_dynamic-f50ae72ec3417cae55dd4e085991c01af9fdc5f1.zip |
Initial commitstart
Diffstat (limited to 'contrib/idn/idnkit-1.0-src/lib')
67 files changed, 33747 insertions, 0 deletions
diff --git a/contrib/idn/idnkit-1.0-src/lib/Makefile.in b/contrib/idn/idnkit-1.0-src/lib/Makefile.in new file mode 100644 index 0000000..e768730 --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/Makefile.in @@ -0,0 +1,309 @@ +# $Id: Makefile.in,v 1.2 2004/07/20 07:13:39 marka Exp $ +# Copyright (c) 2000, 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. + +build = @build@ + +LIB_CURRENT = 1 +LIB_REVISION = 2 +LIB_AGE = 0 + +.SUFFIXES: +.SUFFIXES: .c .lo .to + +top_builddir = .. + +srcdir = @srcdir@ +VPATH = @srcdir@ + +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +libdir = @libdir@ +sysconfdir = @sysconfdir@ +datadir = @datadir@ +mapdir = $(datadir)/idnkit +utf8_name = @UTF8_NAME@ + +SUBDIRS = tests + +SHELL = @SHELL@ +CC = @CC@ +RANLIB = @RANLIB@ +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +MKINSTALLDIRS = @top_srcdir@/mkinstalldirs +LIBTOOL = @LIBTOOL@ + +ICONVINC = @ICONVINC@ +ICONVLIB = @ICONVLIB@ + +INCS = -I$(srcdir)/../include -I../include $(ICONVINC) +DEFS = -DIDN_RESCONF_DIR="\"$(sysconfdir)\"" + +CFLAGS = $(OPTS) $(INCS) $(DEFS) @CPPFLAGS@ @CFLAGS@ +LDFLAGS = @LDFLAGS@ + +SRCS = \ + aliaslist.c \ + api.c \ + checker.c \ + converter.c \ + debug.c \ + delimitermap.c \ + filechecker.c \ + filemapper.c \ + localencoding.c \ + log.c \ + mapper.c \ + mapselector.c \ + nameprep.c \ + nameprep_template.c \ + nameprepdata.c \ + normalizer.c \ + punycode.c \ + race.c \ + res.c \ + resconf.c \ + result.c \ + strhash.c \ + ucs4.c \ + ucsmap.c \ + ucsset.c \ + unicode.c \ + unicode_template.c \ + unicodedata_320.c \ + unormalize.c \ + util.c \ + utf8.c \ + version.c + +OBJS = \ + aliaslist.lo \ + api.lo \ + checker.lo \ + converter.lo \ + debug.lo \ + delimitermap.lo \ + filechecker.lo \ + filemapper.lo \ + localencoding.lo \ + log.lo \ + mapper.lo \ + mapselector.lo \ + nameprep.lo \ + normalizer.lo \ + punycode.lo \ + race.lo \ + res.lo \ + resconf.lo \ + result.lo \ + strhash.lo \ + ucs4.lo \ + ucsmap.lo \ + ucsset.lo \ + unicode.lo \ + unormalize.lo \ + utf8.lo \ + util.lo \ + version.lo + +LIB = libidnkit +TESTLIB = libidntest + +LITELIBCFLAGS = $(CFLAGS) -DWITHOUT_ICONV +LITELIB_OBJS = \ + apilite.lo \ + converterlite.lo \ + reslite.lo \ + resconflite.lo \ + aliaslist.lo \ + checker.lo \ + debug.lo \ + delimitermap.lo \ + filechecker.lo \ + filemapper.lo \ + log.lo \ + mapper.lo \ + mapselector.lo \ + nameprep.lo \ + normalizer.lo \ + punycode.lo \ + race.lo \ + result.lo \ + strhash.lo \ + ucsmap.lo \ + ucsset.lo \ + unicode.lo \ + unormalize.lo \ + ucs4.lo \ + utf8.lo \ + util.lo \ + version.lo + +LITELIB = libidnkitlite +TESTLITELIB = libidntestlite + +SAMPLES = idn.conf.sample idnalias.conf.sample + +.c.lo: + $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c $< + +.c.to: + $(CC) -o $@ -DTEST $(CFLAGS) $(LDFLAGS) -c $< + +all: all-localdir all-subdirs +@LITEONLY_TRUE@all-localdir: $(LITELIB).la $(SAMPLES) +@LITEONLY_FALSE@all-localdir: $(LIB).la $(LITELIB).la $(SAMPLES) + +$(LIB).la: $(OBJS) + $(LIBTOOL) --mode=link $(LD) $(LDFLAGS) -o $@ \ + -version-info $(LIB_CURRENT):$(LIB_REVISION):$(LIB_AGE) \ + -rpath $(libdir) $(OBJS) + +$(TESTLIB).la: $(OBJS) + $(LIBTOOL) --mode=link $(LD) $(LDFLAGS) -o $@ \ + -version-info $(LIB_CURRENT):$(LIB_REVISION):$(LIB_AGE) \ + -rpath $(libdir) $(OBJS) + +apilite.lo: api.c + $(LIBTOOL) --mode=compile $(CC) $(LITELIBCFLAGS) -o $@ \ + -c $(srcdir)/api.c +converterlite.lo: converter.c + $(LIBTOOL) --mode=compile $(CC) $(LITELIBCFLAGS) -o $@ \ + -c $(srcdir)/converter.c +reslite.lo: res.c + $(LIBTOOL) --mode=compile $(CC) $(LITELIBCFLAGS) -o $@ \ + -c $(srcdir)/res.c +resconflite.lo: resconf.c + $(LIBTOOL) --mode=compile $(CC) $(LITELIBCFLAGS) -o $@ \ + -c $(srcdir)/resconf.c + +$(LITELIB).la: $(LITELIB_OBJS) + $(LIBTOOL) --mode=link $(LD) $(LDFLAGS) -o $@ \ + -version-info $(LIB_CURRENT):$(LIB_REVISION):$(LIB_AGE) \ + -rpath $(libdir) $(LITELIB_OBJS) + +$(TESTLITELIB).la: $(LITELIB_OBJS) + $(LIBTOOL) --mode=link $(LD) $(LDFLAGS) -o $@ \ + -version-info $(LIB_CURRENT):$(LIB_REVISION):$(LIB_AGE) \ + -rpath $(libdir) $(LITELIB_OBJS) + +idn.conf.sample: idn.conf.sample.in + sed -e 's%[@]mapdir[@]%$(mapdir)%' \ + < $(srcdir)/idn.conf.sample.in > $@ + +idnalias.conf.sample: Makefile + $(SHELL) $(srcdir)/aliaslist.sh $(build) $(utf8_name) > $@ + +install: install-localdir install-subdirs +@LITEONLY_TRUE@install-localdir: all install-common +@LITEONLY_FALSE@install-localdir: all install-common install-nolite + +install-common: + $(MKINSTALLDIRS) $(DESTDIR)$(libdir) + $(LIBTOOL) $(INSTALL_DATA) $(LITELIB).la \ + $(DESTDIR)$(libdir)/$(LITELIB).la + -[ -f $(DESTDIR)$(libdir)/$(LITELIB).a ] \ + && $(RANLIB) $(DESTDIR)$(libdir)/$(LITELIB).a + $(MKINSTALLDIRS) $(DESTDIR)$(sysconfdir) + $(INSTALL_DATA) idn.conf.sample \ + $(DESTDIR)$(sysconfdir)/idn.conf.sample + $(INSTALL_DATA) idnalias.conf.sample \ + $(DESTDIR)$(sysconfdir)/idnalias.conf.sample + @if [ ! -f $(DESTDIR)$(sysconfdir)/idn.conf ]; then \ + echo "** installing default idn.conf"; \ + $(INSTALL_DATA) idn.conf.sample $(DESTDIR)$(sysconfdir)/idn.conf; \ + fi + @if [ ! -f $(DESTDIR)$(sysconfdir)/idnalias.conf ]; then \ + echo "** installing default idnalias.conf"; \ + $(INSTALL_DATA) idnalias.conf.sample \ + $(DESTDIR)$(sysconfdir)/idnalias.conf; \ + fi + +install-nolite: + $(MKINSTALLDIRS) $(DESTDIR)$(libdir) + $(LIBTOOL) $(INSTALL_DATA) $(LIB).la \ + $(DESTDIR)$(libdir)/$(LIB).la + -[ -f $(DESTDIR)$(libdir)/$(LIB).a ] \ + && $(RANLIB) $(DESTDIR)$(libdir)/$(LIB).a + +install-config: + @if [ -f $(DESTDIR)$(sysconfdir)/idn.conf ]; then \ + echo "** backing up old idn.conf as idn.conf.old"; \ + mv -f $(DESTDIR)$(sysconfdir)/idn.conf \ + $(DESTDIR)$(sysconfdir)/idn.conf.old; \ + fi + @echo "** installing default idn.conf forcibly" + $(INSTALL_DATA) idn.conf.sample $(DESTDIR)$(sysconfdir)/idn.conf + @if [ -f $(DESTDIR)$(sysconfdir)/idnalias.conf ]; then \ + echo "** backing up old idnalias.conf as idnalias.conf.old"; \ + mv -f $(DESTDIR)$(sysconfdir)/idnalias.conf \ + $(DESTDIR)$(sysconfdir)/idnalias.conf.old; \ + fi + @echo "** installing default idnalias.conf forcibly" + $(INSTALL_DATA) idnalias.conf.sample \ + $(DESTDIR)$(sysconfdir)/idnalias.conf + +clean: clean-localdir clean-subdirs +clean-localdir: force + rm -f *.o *.lo *.la *.a core *.core *~ + rm -f *.to *_test.c *_test + rm -f idn.conf.sample idnalias.conf.sample + rm -fr .libs/ + +distclean: distclean-localdir distclean-subdirs +distclean-localdir: force clean-localdir + rm -f Makefile + +test check: test-localdir test-subdirs + +@LITEONLY_TRUE@test-localdir: $(TESTLITELIB).la $(SAMPLES) +@LITEONLY_FALSE@test-localdir: $(TESTLIB).la $(TESTLITELIB).la $(SAMPLES) + +all-subdirs install-subdirs clean-subdirs distclean-subdirs test-subdirs: + @target=`echo $@ | sed 's/-subdirs$$//'`; \ + for d in $(SUBDIRS) ; do \ + (cd $$d; $(MAKE) DESTDIR=$(DESTDIR) $$target); \ + done + +force: diff --git a/contrib/idn/idnkit-1.0-src/lib/aliaslist.c b/contrib/idn/idnkit-1.0-src/lib/aliaslist.c new file mode 100644 index 0000000..2b5dca0 --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/aliaslist.c @@ -0,0 +1,355 @@ +#ifndef lint +static char *rcsid = "$Id: aliaslist.c,v 1.1.1.1 2003/06/04 00:25:47 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 <config.h> + +#include <stddef.h> +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <ctype.h> + +#include <idn/aliaslist.h> +#include <idn/assert.h> +#include <idn/logmacro.h> +#include <idn/result.h> + +struct aliasitem { + char *pattern; /* name pattern */ + char *encoding; /* MIME-preferred charset name */ + struct aliasitem *next; +}; +typedef struct aliasitem *aliasitem_t; + +struct idn__aliaslist { + aliasitem_t first_item; /* first item of the list */ +}; + +static idn_result_t +additem_to_top(idn__aliaslist_t list, + const char *pattern, const char *encoding); + +static idn_result_t +additem_to_bottom(idn__aliaslist_t list, + const char *pattern, const char *encoding); + +static int match(const char *pattern, const char *str); + +static idn_result_t create_item(const char *pattern, const char *encoding, + aliasitem_t *itemp); + +#ifdef DEBUG +static void dump_list(idn__aliaslist_t list); +#endif + +idn_result_t +idn__aliaslist_create(idn__aliaslist_t *listp) { + static int size = sizeof(struct idn__aliaslist); + + TRACE(("idn__aliaslist_create()\n")); + + assert(listp != NULL); + + if ((*listp = malloc(size)) == NULL) { + return (idn_nomemory); + } + (*listp)->first_item = NULL; + + return (idn_success); +} + +void +idn__aliaslist_destroy(idn__aliaslist_t list) { + aliasitem_t current; + aliasitem_t next; + + TRACE(("idn__aliaslist_destroy()\n")); + + assert(list != NULL); + + current = list->first_item; + while (current != NULL) { + if (current->pattern != NULL) { + free(current->pattern); + } + if (current->encoding != NULL) { + free(current->encoding); + } + next = current->next; + free(current); + current = next; + } + free(list); +} + +idn_result_t +idn__aliaslist_aliasfile(idn__aliaslist_t list, const char *path) { + FILE *fp; + int line_no; + idn_result_t r = idn_success; + char line[200], alias[200], real[200]; + + assert(path != NULL); + + TRACE(("idn__aliaslist_aliasfile(path=%s)\n", path)); + + if ((fp = fopen(path, "r")) == NULL) { + return (idn_nofile); + } + for (line_no = 1; fgets(line, sizeof(line), fp) != NULL; line_no++) { + unsigned char *p = (unsigned char *)line; + + while (isascii(*p) && isspace(*p)) + p++; + if (*p == '#' || *p == '\n') + continue; + if (sscanf((char *)p, "%s %s", alias, real) == 2) { + r = additem_to_bottom(list, alias, real); + if (r != idn_success) + break; + } else { + INFO(("idn__aliaslist_aliasfile: file %s has " + "invalid contents at line %d\n", + path, line_no)); + r = idn_invalid_syntax; + break; + } + } + fclose(fp); + +#ifdef DEBUG + dump_list(list); +#endif + + return (r); +} + +idn_result_t +idn__aliaslist_additem(idn__aliaslist_t list, + const char *pattern, const char *encoding, + int first_item) { + if (first_item) { + return additem_to_top(list, pattern, encoding); + } else { + return additem_to_bottom(list, pattern, encoding); + } +} + +static idn_result_t +additem_to_top(idn__aliaslist_t list, + const char *pattern, const char *encoding) { + aliasitem_t new_item; + idn_result_t r; + + TRACE(("additem_to_top()\n")); + + assert(list != NULL); + assert(pattern != NULL); + assert(encoding != NULL); + + if ((r = create_item(pattern, encoding, &new_item)) + != idn_success) { + WARNING(("additem_to_top: malloc failed\n")); + return (r); + } + + new_item->next = list->first_item; + list->first_item = new_item; + +#ifdef DEBUG + dump_list(list); +#endif + + return (idn_success); +} + +static idn_result_t +additem_to_bottom(idn__aliaslist_t list, + const char *pattern, const char *encoding) { + aliasitem_t new_item; + idn_result_t r; + + TRACE(("additem_to_bottom()\n")); + + assert(list != NULL); + assert(pattern != NULL); + assert(encoding != NULL); + + r = create_item(pattern, encoding, &new_item); + if (r != idn_success) { + WARNING(("additem_to_bottom: malloc failed\n")); + return r; + } + + if (list->first_item == NULL) { + list->first_item = new_item; + } else { + aliasitem_t cur_item = list->first_item; + for (;;) { + if (cur_item->next == NULL) { + break; + } + cur_item = cur_item->next; + } + cur_item->next = new_item; + } + + return (idn_success); +} + +idn_result_t +idn__aliaslist_find(idn__aliaslist_t list, + const char *pattern, char **encodingp) { + aliasitem_t current; + + TRACE(("idn__aliaslist_find()\n")); + + assert(list != NULL); + assert(pattern != NULL); + +#ifdef DEBUG + DUMP(("target pattern: %s\n", pattern)); +#endif + current = list->first_item; + while (current != NULL) { +#ifdef DEBUG + DUMP(("current pattern: %s, encoding: %s\n", + current->pattern, current->encoding)); +#endif + if (match(current->pattern, pattern)) { + *encodingp = current->encoding; + return (idn_success); + } + current = current->next; + } + + TRACE(("idn__aliaslist_find(): not found\n")); + *encodingp = (char *)pattern; + return (idn_notfound); +} + +/* + * Wild card matching function that supports only '*'. + */ +static int +match(const char *pattern, const char *str) { + for (;;) { + int c; + + switch (c = *pattern++) { + case '\0': + return (*str == '\0'); + case '*': + while (!match(pattern, str)) { + if (*str == '\0') + return (0); + str++; + } + return (1); + break; + default: + if (*str++ != c) + return (0); + break; + } + } +} + +/* + * List item creation. + * pattern and encoding must not be NULL. + */ +static idn_result_t +create_item(const char *pattern, const char *encoding, + aliasitem_t *itemp) { + static size_t size = sizeof(struct aliasitem); + + assert(pattern != NULL); + assert(encoding != NULL); + + if ((*itemp = malloc(size)) == NULL) + return (idn_nomemory); + + if (((*itemp)->pattern = malloc(strlen(pattern) + 1)) == NULL) { + free(*itemp); + *itemp = NULL; + return (idn_nomemory); + } + + if (((*itemp)->encoding = malloc(strlen(encoding) + 1)) == NULL) { + free((*itemp)->pattern); + free(*itemp); + *itemp = NULL; + return (idn_nomemory); + } + + (void)strcpy((*itemp)->pattern, pattern); + (void)strcpy((*itemp)->encoding, encoding); + (*itemp)->next = NULL; + + return (idn_success); +} + +#ifdef DEBUG +static void +dump_list(idn__aliaslist_t list) { + aliasitem_t item; + int i; + + TRACE(("dump_list()\n")); + if (list == NULL) { + TRACE(("list is NULL\n")); + return; + } + item = list->first_item; + i = 0; + while (item != NULL) { + DUMP(("%d: %s\t%s\n", i, item->pattern, item->encoding)); + item = item->next; + i++; + } +} +#endif diff --git a/contrib/idn/idnkit-1.0-src/lib/aliaslist.sh b/contrib/idn/idnkit-1.0-src/lib/aliaslist.sh new file mode 100644 index 0000000..47c3d4f --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/aliaslist.sh @@ -0,0 +1,35 @@ +#!/bin/sh +# +# aliaslist.sh -- Generate `idnalias.conf.sample' file. +# + +cpu_company_system="$1" +utf8_name="$2" + +cat <<EOF +*.ISO_8859-1 ISO-8859-1 +*.ISO_8859-2 ISO-8859-1 +*.SJIS Shift_JIS +*.Shift_JIS Shift_JIS +ja_JP.EUC EUC-JP +ko_KR.EUC EUC-KR +*.big5 Big5 +*.Big5 Big5 +*.KOI8-R KOI8-R +*.GB2312 GB2312 +ja EUC-JP +EOF + +case "$cpu_company_system" in +*-*-hpux*) + echo "japanese Shift_JIS" + ;; +*) + echo "japanese EUC-JP" +esac + +if [ "x$utf8_name" != xUTF-8 ] ; then + echo "UTF-8 $utf8_name" +fi + +exit 0 diff --git a/contrib/idn/idnkit-1.0-src/lib/api.c b/contrib/idn/idnkit-1.0-src/lib/api.c new file mode 100644 index 0000000..ab1b6e0 --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/api.c @@ -0,0 +1,257 @@ +#ifndef lint +static char *rcsid = "$Id: api.c,v 1.1.1.1 2003/06/04 00:25:48 marka Exp $"; +#endif + +/* + * Copyright (c) 2001,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 <config.h> + +#include <string.h> +#include <stdlib.h> + +#include <idn/result.h> +#include <idn/assert.h> +#include <idn/log.h> +#include <idn/logmacro.h> +#include <idn/resconf.h> +#include <idn/api.h> +#include <idn/debug.h> +#include <idn/res.h> + +static int initialized; +static idn_resconf_t default_conf; + +static char *conf_file; + +void +idn_enable(int on_off) { + idn_res_enable(on_off); +} + +idn_result_t +idn__setconffile(const char *file) { + idn_result_t r; + char *s; + + TRACE(("idn__setconffile(%s)\n", (file == NULL) ? "<null>" : file)); + + if (initialized) { + r = idn_failure; + goto ret; + } + + if (file == NULL) + s = NULL; + else { + s = (char *)malloc(strlen(file) + 1); + if (s == NULL) { + r = idn_nomemory; + goto ret; + } + strcpy(s, file); + } + free(conf_file); + conf_file = s; + + r = idn_success; +ret: + TRACE(("idn__setconffile(): %s\n", idn_result_tostring(r))); + return (r); +} + +idn_result_t +idn_nameinit(int load_file) { + idn_result_t r; + + TRACE(("idn_nameinit()\n")); + + if (initialized) { + r = idn_success; + goto ret; + } + + idn_resconf_initialize(); + + r = idn_resconf_create(&default_conf); + if (r != idn_success) + goto ret; + + if (load_file) + r = idn_resconf_loadfile(default_conf, conf_file); + else + r = idn_resconf_setdefaults(default_conf); + if (r != idn_success) + goto ret; + + initialized = 1; + +ret: + if (r != idn_success && default_conf != NULL) { + idn_resconf_destroy(default_conf); + default_conf = NULL; + } + TRACE(("idn_nameinit(): %s\n", idn_result_tostring(r))); + return (r); +} + +idn_result_t +idn_encodename(idn_action_t actions, const char *from, char *to, size_t tolen) { + idn_result_t r; + + assert(from != NULL && to != NULL); + + TRACE(("idn_encodename(actions=%s, from=\"%s\")\n", + idn__res_actionstostring(actions), + idn__debug_xstring(from, 50))); + + if (!initialized && ((r = idn_nameinit(0)) != idn_success)) + goto ret; + + r = idn_res_encodename(default_conf, actions, from, to, tolen); + +ret: + if (r == idn_success) { + TRACE(("idn_encodename(): success (to=\"%s\")\n", + idn__debug_xstring(to, 50))); + } else { + TRACE(("idn_encodename(): %s\n", idn_result_tostring(r))); + } + return (r); +} + +idn_result_t +idn_decodename(idn_action_t actions, const char *from, char *to, size_t tolen) { + idn_result_t r; + + assert(from != NULL && to != NULL); + + TRACE(("idn_decodename(actions=%s, from=\"%s\", tolen=%d)\n", + idn__res_actionstostring(actions), + idn__debug_xstring(from, 50), (int)tolen)); + + if (!initialized && ((r = idn_nameinit(0)) != idn_success)) + goto ret; + + r = idn_res_decodename(default_conf, actions, from, to, tolen); + +ret: + if (r == idn_success) { + TRACE(("idn_decodename(): success (to=\"%s\")\n", + idn__debug_xstring(to, 50))); + } else { + TRACE(("idn_decodename(): %s\n", idn_result_tostring(r))); + } + return (r); +} + +idn_result_t +idn_decodename2(idn_action_t actions, const char *from, char *to, size_t tolen, + const char *auxencoding) { + idn_result_t r; + + assert(from != NULL && to != NULL); + + TRACE(("idn_decodename2(actions=%s, from=\"%s\", tolen=%d)\n", + idn__res_actionstostring(actions), + idn__debug_xstring(from, 50), (int)tolen)); + + if (!initialized && ((r = idn_nameinit(0)) != idn_success)) + goto ret; + + r = idn_res_decodename2(default_conf, actions, from, to, tolen, + auxencoding); + +ret: + if (r == idn_success) { + TRACE(("idn_decodename2(): success (to=\"%s\")\n", + idn__debug_xstring(to, 50))); + } else { + TRACE(("idn_decodename2(): %s\n", idn_result_tostring(r))); + } + return (r); +} + +/* + * These functions are for backward compatibility. + */ +#ifdef ENABLE_MDNKIT_COMPAT + +idn_result_t +mdn_nameinit(void) { + return idn_nameinit(1); +} + +idn_result_t +mdn_encodename(int actions, const char *from, char *to, size_t tolen) { + idn_result_t r; + + assert(from != NULL && to != NULL); + + TRACE(("mdn_encodename(actions=%s, from=\"%s\")\n", + idn__res_actionstostring(actions), + idn__debug_xstring(from, 50))); + + if (!initialized && ((r = idn_nameinit(1)) != idn_success)) + return (r); + + return (idn_res_encodename(default_conf, actions, from, to, tolen)); +} + +idn_result_t +mdn_decodename(int actions, const char *from, char *to, size_t tolen) { + idn_result_t r; + + assert(from != NULL && to != NULL); + + TRACE(("idn_decodename(actions=%s, from=\"%s\", tolen=%d)\n", + idn__res_actionstostring(actions), + idn__debug_xstring(from, 50), (int)tolen)); + + if (!initialized && ((r = idn_nameinit(1)) != idn_success)) + return (r); + + return (idn_res_decodename(default_conf, actions, from, to, tolen)); +} + +#endif /* ENABLE_MDNKIT_COMPAT */ diff --git a/contrib/idn/idnkit-1.0-src/lib/checker.c b/contrib/idn/idnkit-1.0-src/lib/checker.c new file mode 100644 index 0000000..c1e8fdf --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/checker.c @@ -0,0 +1,446 @@ +#ifndef lint +static char *rcsid = "$Id: checker.c,v 1.1.1.1 2003/06/04 00:25:49 marka Exp $"; +#endif + +/* + * Copyright (c) 2001,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 <config.h> + +#include <stddef.h> +#include <stdlib.h> +#include <string.h> + +#include <idn/result.h> +#include <idn/assert.h> +#include <idn/logmacro.h> +#include <idn/checker.h> +#include <idn/strhash.h> +#include <idn/debug.h> + +/* + * Type for checking scheme. + */ +typedef struct { + char *prefix; + char *parameter; + idn_checker_createproc_t create; + idn_checker_destroyproc_t destroy; + idn_checker_lookupproc_t lookup; + void *context; +} check_scheme_t; + +/* + * Standard checking schemes. + */ +static const check_scheme_t rfc3491_prohibit_scheme = { + "prohibit#RFC3491", + "RFC3491", + idn_nameprep_createproc, + idn_nameprep_destroyproc, + idn_nameprep_prohibitproc, + NULL, +}; + +static const check_scheme_t rfc3491_unasigned_scheme = { + "unassigned#RFC3491", + "RFC3491", + idn_nameprep_createproc, + idn_nameprep_destroyproc, + idn_nameprep_unassignedproc, + NULL, +}; + +static const check_scheme_t rfc3491_bidi_scheme = { + "bidi#RFC3491", + "RFC3491", + idn_nameprep_createproc, + idn_nameprep_destroyproc, + idn_nameprep_bidiproc, + NULL, +}; + +static const check_scheme_t filecheck_prohibit_scheme = { + "prohibit#fileset", + NULL, + idn__filechecker_createproc, + idn__filechecker_destroyproc, + idn__filechecker_lookupproc, + NULL, +}; + +static const check_scheme_t filecheck_unassigned_scheme = { + "unassigned#fileset", + NULL, + idn__filechecker_createproc, + idn__filechecker_destroyproc, + idn__filechecker_lookupproc, + NULL, +}; + +static const check_scheme_t *standard_check_schemes[] = { + &rfc3491_unasigned_scheme, + &rfc3491_prohibit_scheme, + &rfc3491_bidi_scheme, + &filecheck_prohibit_scheme, + &filecheck_unassigned_scheme, + NULL, +}; + +/* + * Hash table for checking schemes. + */ +static idn__strhash_t scheme_hash = NULL; + +/* + * Mapper object type. + */ +struct idn_checker { + int nschemes; + int scheme_size; + check_scheme_t *schemes; + int reference_count; +}; + +#define MAPPER_INITIAL_SCHEME_SIZE 1 + +idn_result_t +idn_checker_initialize(void) { + idn_result_t r; + check_scheme_t **scheme; + + TRACE(("idn_checker_initialize()\n")); + + if (scheme_hash != NULL) { + r = idn_success; /* already initialized */ + goto ret; + } + + r = idn__strhash_create(&scheme_hash); + if (r != idn_success) { + goto ret; + } + + for (scheme = (check_scheme_t **)standard_check_schemes; + *scheme != NULL; scheme++) { + r = idn__strhash_put(scheme_hash, (*scheme)->prefix, *scheme); + if (r != idn_success) + goto ret; + } + + r = idn_success; +ret: + if (r != idn_success) { + if (scheme_hash != NULL) { + idn__strhash_destroy(scheme_hash, NULL); + scheme_hash = NULL; + } + } + TRACE(("idn_checker_initialize(): %s\n", idn_result_tostring(r))); + return (r); +} + +idn_result_t +idn_checker_create(idn_checker_t *ctxp) { + idn_checker_t ctx = NULL; + idn_result_t r; + + assert(scheme_hash != NULL); + assert(ctxp != NULL); + + TRACE(("idn_checker_create()\n")); + + ctx = (idn_checker_t) malloc(sizeof(struct idn_checker)); + if (ctx == NULL) { + r = idn_nomemory; + goto ret; + } + + ctx->schemes = (check_scheme_t *) malloc(sizeof(check_scheme_t) + * MAPPER_INITIAL_SCHEME_SIZE); + if (ctx->schemes == NULL) { + r = idn_nomemory; + goto ret; + } + + ctx->nschemes = 0; + ctx->scheme_size = MAPPER_INITIAL_SCHEME_SIZE; + ctx->reference_count = 1; + *ctxp = ctx; + r = idn_success; +ret: + if (r != idn_success) { + if (ctx != NULL) + free(ctx->schemes); + free(ctx); + } + TRACE(("idn_checker_create(): %s\n", idn_result_tostring(r))); + return (r); +} + +void +idn_checker_destroy(idn_checker_t ctx) { + int i; + + assert(scheme_hash != NULL); + assert(ctx != NULL); + + TRACE(("idn_checker_destroy()\n")); + + ctx->reference_count--; + if (ctx->reference_count <= 0) { + TRACE(("idn_checker_destroy(): the object is destroyed\n")); + for (i = 0; i < ctx->nschemes; i++) + ctx->schemes[i].destroy(ctx->schemes[i].context); + free(ctx->schemes); + free(ctx); + } else { + TRACE(("idn_checker_destroy(): " + "update reference count (%d->%d)\n", + ctx->reference_count + 1, ctx->reference_count)); + } +} + +void +idn_checker_incrref(idn_checker_t ctx) { + assert(ctx != NULL && scheme_hash != NULL); + + TRACE(("idn_checker_incrref()\n")); + TRACE(("idn_checker_incrref: update reference count (%d->%d)\n", + ctx->reference_count, ctx->reference_count + 1)); + + ctx->reference_count++; +} + +idn_result_t +idn_checker_add(idn_checker_t ctx, const char *scheme_name) { + idn_result_t r; + check_scheme_t *scheme; + const char *scheme_prefix; + const char *scheme_parameter; + void *scheme_context = NULL; + char *buffer = NULL; + + assert(scheme_hash != NULL); + assert(ctx != NULL); + + TRACE(("idn_checker_add(scheme_name=%s)\n", + idn__debug_xstring(scheme_name, 50))); + + /* + * Split `scheme_name' into `scheme_prefix' and `scheme_parameter'. + */ + scheme_parameter = strchr(scheme_name, ':'); + if (scheme_parameter == NULL) { + scheme_prefix = scheme_name; + scheme_parameter = NULL; + } else { + ptrdiff_t scheme_prefixlen; + + scheme_prefixlen = scheme_parameter - scheme_name; + buffer = (char *) malloc(scheme_prefixlen + 1); + if (buffer == NULL) { + r = idn_nomemory; + goto ret; + } + memcpy(buffer, scheme_name, scheme_prefixlen); + *(buffer + scheme_prefixlen) = '\0'; + scheme_prefix = buffer; + scheme_parameter++; + } + + /* + * Find a scheme. + */ + if (idn__strhash_get(scheme_hash, scheme_prefix, (void **)&scheme) + != idn_success) { + ERROR(("idn_checker_add(): invalid scheme \"%-.30s\"\n", + scheme_name)); + r = idn_invalid_name; + goto ret; + } + if (scheme_parameter == NULL && scheme->parameter != NULL) + scheme_parameter = scheme->parameter; + + /* + * Add the scheme. + */ + assert(ctx->nschemes <= ctx->scheme_size); + + if (ctx->nschemes == ctx->scheme_size) { + check_scheme_t *new_schemes; + + new_schemes = (check_scheme_t *) realloc(ctx->schemes, + sizeof(check_scheme_t) * ctx->scheme_size * 2); + if (new_schemes == NULL) { + r = idn_nomemory; + goto ret; + } + ctx->schemes = new_schemes; + ctx->scheme_size *= 2; + } + + r = scheme->create(scheme_parameter, &scheme_context); + if (r != idn_success) + goto ret; + + memcpy(ctx->schemes + ctx->nschemes, scheme, sizeof(check_scheme_t)); + ctx->schemes[ctx->nschemes].context = scheme_context; + ctx->nschemes++; + r = idn_success; + +ret: + free(buffer); + if (r != idn_success) + free(scheme_context); + TRACE(("idn_checker_add(): %s\n", idn_result_tostring(r))); + return (r); +} + +idn_result_t +idn_checker_addall(idn_checker_t ctx, const char **scheme_names, + int nschemes) { + idn_result_t r; + int i; + + assert(scheme_hash != NULL); + assert(ctx != NULL && scheme_names != NULL); + + TRACE(("idn_checker_addall(nschemes=%d)\n", nschemes)); + + for (i = 0; i < nschemes; i++) { + r = idn_checker_add(ctx, (const char *)*scheme_names); + if (r != idn_success) + goto ret; + scheme_names++; + } + + r = idn_success; +ret: + TRACE(("idn_checker_addall(): %s\n", idn_result_tostring(r))); + return (r); +} + +idn_result_t +idn_checker_lookup(idn_checker_t ctx, const unsigned long *ucs4, + const unsigned long **found) { + idn_result_t r; + int i; + + assert(scheme_hash != NULL); + assert(ctx != NULL && ucs4 != NULL && found != NULL); + + TRACE(("idn_checker_lookup(ucs4=\"%s\")\n", + idn__debug_ucs4xstring(ucs4, 50))); + + /* + * Lookup. + */ + *found = NULL; + + for (i = 0; i < ctx->nschemes; i++) { + TRACE(("idn_checker_lookup(): lookup %s\n", + ctx->schemes[i].prefix)); + + r = (ctx->schemes[i].lookup)(ctx->schemes[i].context, ucs4, + found); + if (r != idn_success) + goto ret; + if (*found != NULL) + break; + } + + r = idn_success; +ret: + if (*found == NULL) { + TRACE(("idn_checker_lookup(): %s (not found)\n", + idn_result_tostring(r))); + } else { + TRACE(("idn_checker_lookup(): %s (found \\x%04lx)\n", + idn_result_tostring(r), **found)); + } + return (r); +} + +idn_result_t +idn_checker_register(const char *prefix, + idn_checker_createproc_t create, + idn_checker_destroyproc_t destroy, + idn_checker_lookupproc_t lookup) { + idn_result_t r; + check_scheme_t *scheme = NULL; + + assert(scheme_hash != NULL); + assert(prefix != NULL && create != NULL && destroy != NULL && + lookup != NULL); + + TRACE(("idn_checker_register(prefix=%s)\n", prefix)); + + scheme = (check_scheme_t *) malloc(sizeof(check_scheme_t)); + if (scheme == NULL) { + r = idn_nomemory; + goto ret; + } + + scheme->prefix = (char *) malloc(strlen(prefix) + 1); + if (scheme->prefix == NULL) { + r = idn_nomemory; + goto ret; + } + + strcpy(scheme->prefix, prefix); + scheme->parameter = NULL; + scheme->create = create; + scheme->destroy = destroy; + scheme->lookup = lookup; + + r = idn__strhash_put(scheme_hash, prefix, scheme); +ret: + if (r != idn_success) { + if (scheme != NULL) + free(scheme->prefix); + free(scheme); + } + TRACE(("idn_checker_register(): %s\n", idn_result_tostring(r))); + return (r); +} diff --git a/contrib/idn/idnkit-1.0-src/lib/converter.c b/contrib/idn/idnkit-1.0-src/lib/converter.c new file mode 100644 index 0000000..faed44f --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/converter.c @@ -0,0 +1,1244 @@ +#ifndef lint +static char *rcsid = "$Id: converter.c,v 1.1.1.1 2003/06/04 00:25:51 marka Exp $"; +#endif + +/* + * Copyright (c) 2000,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 <config.h> + +#include <stddef.h> +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <ctype.h> +#include <errno.h> +#ifndef WITHOUT_ICONV +#include <iconv.h> +#endif + +#include <idn/result.h> +#include <idn/assert.h> +#include <idn/logmacro.h> +#include <idn/converter.h> +#include <idn/aliaslist.h> +#include <idn/strhash.h> +#include <idn/debug.h> +#include <idn/ucs4.h> +#include <idn/punycode.h> +#include <idn/race.h> +#include <idn/util.h> + +#ifndef IDN_UTF8_ENCODING_NAME +#define IDN_UTF8_ENCODING_NAME "UTF-8" /* by IANA */ +#endif +#ifndef IDN_RACE_ENCODING_NAME +#define IDN_RACE_ENCODING_NAME "RACE" +#endif +#ifndef IDN_AMCACEZ_ENCODING_NAME +#define IDN_AMCACEZ_ENCODING_NAME "AMC-ACE-Z" +#endif +#ifndef IDN_PUNYCODE_ENCODING_NAME +#define IDN_PUNYCODE_ENCODING_NAME "Punycode" +#endif + +#define MAX_RECURSE 20 + +#ifdef WIN32 + +#define IDNKEY_IDNKIT "Software\\JPNIC\\IDN" +#define IDNVAL_ALIASFILE "AliasFile" + +#else /* WIN32 */ + +#ifndef IDN_RESCONF_DIR +#define IDN_RESCONF_DIR "/etc" +#endif +#define IDN_ALIAS_FILE IDN_RESCONF_DIR "/idnalias.conf" + +#endif /* WIN32 */ + +typedef struct { + idn_converter_openproc_t openfromucs4; + idn_converter_openproc_t opentoucs4; + idn_converter_convfromucs4proc_t convfromucs4; + idn_converter_convtoucs4proc_t convtoucs4; + idn_converter_closeproc_t close; + int encoding_type; +} converter_ops_t; + +struct idn_converter { + char *local_encoding_name; + converter_ops_t *ops; + int flags; + int opened_convfromucs4; + int opened_convtoucs4; + int reference_count; + void *private_data; +}; + +static idn__strhash_t encoding_name_hash; +static idn__aliaslist_t encoding_alias_list; + +static idn_result_t register_standard_encoding(void); +static idn_result_t roundtrip_check(idn_converter_t ctx, + const unsigned long *from, + const char *to); + +static idn_result_t + converter_none_open(idn_converter_t ctx, void **privdata); +static idn_result_t + converter_none_close(idn_converter_t ctx, void *privdata); +static idn_result_t + converter_none_convfromucs4(idn_converter_t ctx, + void *privdata, + const unsigned long *from, + char *to, size_t tolen); +static idn_result_t + converter_none_convtoucs4(idn_converter_t ctx, + void *privdata, const char *from, + unsigned long *to, size_t tolen); + +#ifndef WITHOUT_ICONV +static idn_result_t + converter_iconv_openfromucs4(idn_converter_t ctx, void **privdata); +static idn_result_t + converter_iconv_opentoucs4(idn_converter_t ctx, void **privdata); +static idn_result_t + converter_iconv_close(idn_converter_t ctx, void *privdata); +static idn_result_t + converter_iconv_convfromucs4(idn_converter_t ctx, + void *privdata, + const unsigned long *from, + char *to, size_t tolen); +static idn_result_t + converter_iconv_convtoucs4(idn_converter_t ctx, + void *privdata, + const char *from, + unsigned long *to, size_t tolen); + +static idn_result_t +iconv_initialize_privdata(void **privdata); +static void +iconv_finalize_privdata(void *privdata); + +static char * get_system_aliasfile(void); +static int file_exist(const char *filename); + +#endif /* !WITHOUT_ICONV */ + +#ifdef DEBUG +static idn_result_t + converter_uescape_convfromucs4(idn_converter_t ctx, + void *privdata, + const unsigned long *from, + char *to, size_t tolen); +static idn_result_t + converter_uescape_convtoucs4(idn_converter_t ctx, + void *privdata, + const char *from, + unsigned long *to, + size_t tolen); +#endif /* DEBUG */ + +static converter_ops_t none_converter_ops = { + converter_none_open, + converter_none_open, + converter_none_convfromucs4, + converter_none_convtoucs4, + converter_none_close, + IDN_NONACE, +}; + +#ifndef WITHOUT_ICONV +static converter_ops_t iconv_converter_ops = { + converter_iconv_openfromucs4, + converter_iconv_opentoucs4, + converter_iconv_convfromucs4, + converter_iconv_convtoucs4, + converter_iconv_close, + IDN_NONACE, +}; +#endif + +/* + * Initialize. + */ + +idn_result_t +idn_converter_initialize(void) { + idn_result_t r; + idn__strhash_t hash; + idn__aliaslist_t list; +#ifndef WITHOUT_ICONV + const char *fname; +#endif + + TRACE(("idn_converter_initialize()\n")); + + if (encoding_name_hash == NULL) { + if ((r = idn__strhash_create(&hash)) != idn_success) + goto ret; + encoding_name_hash = hash; + r = register_standard_encoding(); + } + if (encoding_alias_list == NULL) { + if ((r = idn__aliaslist_create(&list)) != idn_success) + goto ret; + encoding_alias_list = list; +#ifndef WITHOUT_ICONV + fname = get_system_aliasfile(); + if (fname != NULL && file_exist(fname)) + idn_converter_aliasfile(fname); +#endif + } + + r = idn_success; +ret: + TRACE(("idn_converter_initialize(): %s\n", idn_result_tostring(r))); + return (r); +} + +#ifndef WITHOUT_ICONV +static char * +get_system_aliasfile() { +#ifdef WIN32 + static char alias_path[500]; /* a good longer than MAX_PATH */ + + if (idn__util_getregistrystring(idn__util_hkey_localmachine, + IDNVAL_ALIASFILE, + alias_path, sizeof(alias_path))) { + return (alias_path); + } else { + return (NULL); + } +#else + return (IDN_ALIAS_FILE); +#endif +} + +static int +file_exist(const char *filename) { + FILE *fp; + + if ((fp = fopen(filename, "r")) == NULL) + return (0); + fclose(fp); + return (1); +} +#endif + +idn_result_t +idn_converter_create(const char *name, idn_converter_t *ctxp, int flags) { + const char *realname; + idn_converter_t ctx; + idn_result_t r; + void *v; + + assert(name != NULL && ctxp != NULL); + + TRACE(("idn_converter_create(%s)\n", name)); + + realname = idn_converter_getrealname(name); +#ifdef DEBUG + if (strcmp(name, realname) != 0) { + TRACE(("idn_converter_create: realname=%s\n", realname)); + } +#endif + + *ctxp = NULL; + + /* Allocate memory for a converter context and the name. */ + ctx = malloc(sizeof(struct idn_converter) + strlen(realname) + 1); + if (ctx == NULL) { + r = idn_nomemory; + goto ret; + } + + ctx->local_encoding_name = (char *)(ctx + 1); + (void)strcpy(ctx->local_encoding_name, realname); + ctx->flags = flags; + ctx->reference_count = 1; + ctx->opened_convfromucs4 = 0; + ctx->opened_convtoucs4 = 0; + ctx->private_data = NULL; + + assert(encoding_name_hash != NULL); + + if (strcmp(realname, IDN_UTF8_ENCODING_NAME) == 0) { + /* No conversion needed */ + ctx->ops = &none_converter_ops; + } else if ((r = idn__strhash_get(encoding_name_hash, realname, &v)) + == idn_success) { + /* Special converter found */ + ctx->ops = (converter_ops_t *)v; + } else { + /* General case */ +#ifdef WITHOUT_ICONV + free(ctx); + *ctxp = NULL; + r = idn_invalid_name; + goto ret; +#else + ctx->ops = &iconv_converter_ops; +#endif + } + + if ((flags & IDN_CONVERTER_DELAYEDOPEN) == 0) { + r = (ctx->ops->openfromucs4)(ctx, &(ctx->private_data)); + if (r != idn_success) { + WARNING(("idn_converter_create(): open failed " + "(ucs4->local)\n")); + free(ctx); + *ctxp = NULL; + goto ret; + } + ctx->opened_convfromucs4 = 1; + + r = (*ctx->ops->opentoucs4)(ctx, &(ctx->private_data)); + if (r != idn_success) { + WARNING(("idn_converter_create(): open failed " + "(local->ucs4)\n")); + free(ctx); + *ctxp = NULL; + goto ret; + } + ctx->opened_convtoucs4 = 1; + } + + *ctxp = ctx; + r = idn_success; +ret: + TRACE(("idn_converter_create(): %s\n", idn_result_tostring(r))); + return (r); +} + +void +idn_converter_destroy(idn_converter_t ctx) { + assert(ctx != NULL); + + TRACE(("idn_converter_destroy(ctx=%s)\n", ctx->local_encoding_name)); + + ctx->reference_count--; + if (ctx->reference_count <= 0) { + TRACE(("idn_converter_destroy(): the object is destroyed\n")); + (void)(*ctx->ops->close)(ctx, ctx->private_data); + free(ctx); + } else { + TRACE(("idn_converter_destroy(): " + "update reference count (%d->%d)\n", + ctx->reference_count + 1, ctx->reference_count)); + } +} + +void +idn_converter_incrref(idn_converter_t ctx) { + assert(ctx != NULL); + + TRACE(("idn_converter_incrref(ctx=%s)\n", ctx->local_encoding_name)); + TRACE(("idn_converter_incrref: update reference count (%d->%d)\n", + ctx->reference_count, ctx->reference_count + 1)); + + ctx->reference_count++; +} + +char * +idn_converter_localencoding(idn_converter_t ctx) { + assert(ctx != NULL); + TRACE(("idn_converter_localencoding(ctx=%s)\n", + ctx->local_encoding_name)); + return (ctx->local_encoding_name); +} + +int +idn_converter_encodingtype(idn_converter_t ctx) { + int encoding_type; + + assert(ctx != NULL); + TRACE(("idn_converter_encodingtype(ctx=%s)\n", + ctx->local_encoding_name)); + + encoding_type = ctx->ops->encoding_type; + TRACE(("idn_converter_encodingtype(): %d\n", encoding_type)); + return (encoding_type); +} + +int +idn_converter_isasciicompatible(idn_converter_t ctx) { + int iscompat; + + assert(ctx != NULL); + TRACE(("idn_converter_isasciicompatible(ctx=%s)\n", + ctx->local_encoding_name)); + + iscompat = (ctx->ops->encoding_type != IDN_NONACE); + TRACE(("idn_converter_isasciicompatible(): %d\n", iscompat)); + return (iscompat); +} + +idn_result_t +idn_converter_convfromucs4(idn_converter_t ctx, const unsigned long *from, + char *to, size_t tolen) { + idn_result_t r; + + assert(ctx != NULL && from != NULL && to != NULL); + + TRACE(("idn_converter_convfromucs4(ctx=%s, from=\"%s\", tolen=%d)\n", + ctx->local_encoding_name, idn__debug_ucs4xstring(from, 50), + (int)tolen)); + + if (!ctx->opened_convfromucs4) { + r = (*ctx->ops->openfromucs4)(ctx, &(ctx->private_data)); + if (r != idn_success) + goto ret; + ctx->opened_convfromucs4 = 1; + } + + r = (*ctx->ops->convfromucs4)(ctx, ctx->private_data, from, to, tolen); + if (r != idn_success) + goto ret; + if ((ctx->flags & IDN_CONVERTER_RTCHECK) != 0) { + r = roundtrip_check(ctx, from, to); + if (r != idn_success) + goto ret; + } + + r = idn_success; +ret: + if (r == idn_success) { + TRACE(("idn_converter_convfromucs4(): success (to=\"%s\")\n", + idn__debug_xstring(to, 50))); + } else { + TRACE(("idn_converter_convfromucs4(): %s\n", + idn_result_tostring(r))); + } + return (r); +} + +idn_result_t +idn_converter_convtoucs4(idn_converter_t ctx, const char *from, + unsigned long *to, size_t tolen) { + idn_result_t r; + + assert(ctx != NULL && from != NULL && to != NULL); + + TRACE(("idn_converter_convtoucs4(ctx=%s, from=\"%s\", tolen=%d)\n", + ctx->local_encoding_name, idn__debug_xstring(from, 50), + (int)tolen)); + + if (!ctx->opened_convtoucs4) { + r = (*ctx->ops->opentoucs4)(ctx, &(ctx->private_data)); + if (r != idn_success) + goto ret; + ctx->opened_convtoucs4 = 1; + } + + r = (*ctx->ops->convtoucs4)(ctx, ctx->private_data, from, to, tolen); +ret: + if (r == idn_success) { + TRACE(("idn_converter_convtoucs4(): success (to=\"%s\")\n", + idn__debug_ucs4xstring(to, 50))); + } else { + TRACE(("idn_converter_convtoucs4(): %s\n", + idn_result_tostring(r))); + } + return (r); +} + +/* + * Encoding registration. + */ + +idn_result_t +idn_converter_register(const char *name, + idn_converter_openproc_t openfromucs4, + idn_converter_openproc_t opentoucs4, + idn_converter_convfromucs4proc_t convfromucs4, + idn_converter_convtoucs4proc_t convtoucs4, + idn_converter_closeproc_t close, + int encoding_type) { + converter_ops_t *ops; + idn_result_t r; + + assert(name != NULL && convfromucs4 != NULL && convtoucs4 != NULL); + + TRACE(("idn_converter_register(name=%s)\n", name)); + + if ((ops = malloc(sizeof(*ops))) == NULL) { + r = idn_nomemory; + goto ret; + } + + if (openfromucs4 == NULL) + openfromucs4 = converter_none_open; + if (opentoucs4 == NULL) + opentoucs4 = converter_none_open; + if (close == NULL) + close = converter_none_close; + + ops->openfromucs4 = openfromucs4; + ops->opentoucs4 = opentoucs4; + ops->convfromucs4 = convfromucs4; + ops->convtoucs4 = convtoucs4; + ops->close = close; + ops->encoding_type = encoding_type; + + r = idn__strhash_put(encoding_name_hash, name, ops); + if (r != idn_success) { + free(ops); + goto ret; + } + + r = idn_success; +ret: + TRACE(("idn_converter_register(): %s\n", idn_result_tostring(r))); + return (r); +} + +static idn_result_t +register_standard_encoding(void) { + idn_result_t r; + + r = idn_converter_register(IDN_PUNYCODE_ENCODING_NAME, + NULL, + NULL, + idn__punycode_encode, + idn__punycode_decode, + converter_none_close, + IDN_ACE_STRICTCASE); + if (r != idn_success) + return (r); + +#ifdef IDN_EXTRA_ACE + r = idn_converter_register(IDN_AMCACEZ_ENCODING_NAME, + NULL, + NULL, + idn__punycode_encode, + idn__punycode_decode, + converter_none_close, + IDN_ACE_STRICTCASE); + if (r != idn_success) + return (r); + + r = idn_converter_register(IDN_RACE_ENCODING_NAME, + NULL, + NULL, + idn__race_encode, + idn__race_decode, + converter_none_close, + IDN_ACE_LOOSECASE); + if (r != idn_success) + return (r); +#endif /* IDN_EXTRA_ACE */ + +#ifdef DEBUG + /* This is convenient for debug. Not useful for other purposes. */ + r = idn_converter_register("U-escape", + NULL, + NULL, + converter_uescape_convfromucs4, + converter_uescape_convtoucs4, + NULL, + IDN_NONACE); + if (r != idn_success) + return (r); +#endif /* DEBUG */ + + return (r); +} + +/* + * Encoding alias support. + */ +idn_result_t +idn_converter_addalias(const char *alias_name, const char *real_name, + int first_item) { + idn_result_t r; + + assert(alias_name != NULL && real_name != NULL); + + TRACE(("idn_converter_addalias(alias_name=%s,real_name=%s)\n", + alias_name, real_name)); + + if (strlen(alias_name) == 0 || strlen(real_name) == 0) { + return idn_invalid_syntax; + } + + if (strcmp(alias_name, real_name) == 0) { + r = idn_success; + goto ret; + } + + if (encoding_alias_list == NULL) { + WARNING(("idn_converter_addalias(): the module is not " + "initialized\n")); + r = idn_failure; + goto ret; + } + + r = idn__aliaslist_additem(encoding_alias_list, alias_name, real_name, + first_item); +ret: + TRACE(("idn_converter_addalias(): %s\n", idn_result_tostring(r))); + return (r); +} + +idn_result_t +idn_converter_aliasfile(const char *path) { + idn_result_t r; + + assert(path != NULL); + + TRACE(("idn_converter_aliasfile(path=%s)\n", path)); + + if (encoding_alias_list == NULL) { + WARNING(("idn_converter_aliasfile(): the module is not " + "initialized\n")); + return (idn_failure); + } + + r = idn__aliaslist_aliasfile(encoding_alias_list, path); + + TRACE(("idn_converter_aliasfile(): %s\n", idn_result_tostring(r))); + return (r); +} + +idn_result_t +idn_converter_resetalias(void) { + idn__aliaslist_t list; + idn_result_t r; + + TRACE(("idn_converter_resetalias()\n")); + + if (encoding_alias_list == NULL) { + WARNING(("idn_converter_resetalias(): the module is not " + "initialized\n")); + return (idn_failure); + } + + list = encoding_alias_list; + encoding_alias_list = NULL; + idn__aliaslist_destroy(list); + list = NULL; + r = idn__aliaslist_create(&list); + encoding_alias_list = list; + + TRACE(("idn_converter_resetalias(): %s\n", idn_result_tostring(r))); + return (r); +} + +const char * +idn_converter_getrealname(const char *name) { + char *realname; + idn_result_t r; + + TRACE(("idn_converter_getrealname()\n")); + + assert(name != NULL); + + if (encoding_alias_list == NULL) { + WARNING(("idn_converter_getrealname(): the module is not " + "initialized\n")); + return (name); + } + + r = idn__aliaslist_find(encoding_alias_list, name, &realname); + if (r != idn_success) { + return (name); + } + return (realname); +} + +/* + * Round trip check. + */ + +static idn_result_t +roundtrip_check(idn_converter_t ctx, const unsigned long *from, const char *to) +{ + /* + * One problem with iconv() convertion is that + * iconv() doesn't signal an error if the input + * string contains characters which are valid but + * do not have mapping to the output codeset. + * (the behavior of iconv() for that case is defined as + * `implementation dependent') + * One way to check this case is to perform round-trip + * conversion and see if it is same as the original string. + */ + idn_result_t r; + unsigned long *back; + unsigned long backbuf[256]; + size_t fromlen; + size_t backlen; + + TRACE(("idn_converter_convert: round-trip checking (from=\"%s\")\n", + idn__debug_ucs4xstring(from, 50))); + + /* Allocate enough buffer. */ + fromlen = idn_ucs4_strlen(from) + 1; + if (fromlen * sizeof(*back) <= sizeof(backbuf)) { + backlen = sizeof(backbuf); + back = backbuf; + } else { + backlen = fromlen; + back = (unsigned long *)malloc(backlen * sizeof(*back)); + if (back == NULL) + return (idn_nomemory); + } + + /* + * Perform backward conversion. + */ + r = idn_converter_convtoucs4(ctx, to, back, backlen); + switch (r) { + case idn_success: + if (memcmp(back, from, sizeof(*from) * fromlen) != 0) + r = idn_nomapping; + break; + case idn_invalid_encoding: + case idn_buffer_overflow: + r = idn_nomapping; + break; + default: + break; + } + + if (back != backbuf) + free(back); + + if (r != idn_success) { + TRACE(("round-trip check failed: %s\n", + idn_result_tostring(r))); + } + + return (r); +} + +/* + * Identity conversion (or, no conversion at all). + */ + +static idn_result_t +converter_none_open(idn_converter_t ctx, void **privdata) { + assert(ctx != NULL); + + return (idn_success); +} + +static idn_result_t +converter_none_close(idn_converter_t ctx, void *privdata) { + assert(ctx != NULL); + + return (idn_success); +} + +static idn_result_t +converter_none_convfromucs4(idn_converter_t ctx, void *privdata, + const unsigned long *from, char *to, size_t tolen) { + assert(ctx != NULL && from != NULL && to != NULL); + + return idn_ucs4_ucs4toutf8(from, to, tolen); +} + +static idn_result_t +converter_none_convtoucs4(idn_converter_t ctx, void *privdata, + const char *from, unsigned long *to, size_t tolen) { + assert(ctx != NULL && from != NULL && to != NULL); + + return idn_ucs4_utf8toucs4(from, to, tolen); +} + +#ifndef WITHOUT_ICONV + +/* + * Conversion using iconv() interface. + */ + +static idn_result_t +converter_iconv_openfromucs4(idn_converter_t ctx, void **privdata) { + iconv_t *ictxp; + idn_result_t r; + + assert(ctx != NULL); + + r = iconv_initialize_privdata(privdata); + if (r != idn_success) + return (r); + + ictxp = (iconv_t *)*privdata; + *ictxp = iconv_open(ctx->local_encoding_name, IDN_UTF8_ENCODING_NAME); + if (*ictxp == (iconv_t)(-1)) { + free(*privdata); + *privdata = NULL; + switch (errno) { + case ENOMEM: + return (idn_nomemory); + case EINVAL: + return (idn_invalid_name); + default: + WARNING(("iconv_open failed with errno %d\n", errno)); + return (idn_failure); + } + } + + return (idn_success); +} + +static idn_result_t +converter_iconv_opentoucs4(idn_converter_t ctx, void **privdata) { + iconv_t *ictxp; + idn_result_t r; + + assert(ctx != NULL); + + r = iconv_initialize_privdata(privdata); + if (r != idn_success) + return (r); + + ictxp = (iconv_t *)*privdata + 1; + *ictxp = iconv_open(IDN_UTF8_ENCODING_NAME, ctx->local_encoding_name); + if (*ictxp == (iconv_t)(-1)) { + free(*privdata); + *privdata = NULL; + switch (errno) { + case ENOMEM: + return (idn_nomemory); + case EINVAL: + return (idn_invalid_name); + default: + WARNING(("iconv_open failed with errno %d\n", errno)); + return (idn_failure); + } + } + + return (idn_success); +} + +static idn_result_t +iconv_initialize_privdata(void **privdata) { + if (*privdata == NULL) { + *privdata = malloc(sizeof(iconv_t) * 2); + if (*privdata == NULL) + return (idn_nomemory); + *((iconv_t *)*privdata) = (iconv_t)(-1); + *((iconv_t *)*privdata + 1) = (iconv_t)(-1); + } + + return (idn_success); +} + +static void +iconv_finalize_privdata(void *privdata) { + iconv_t *ictxp; + + if (privdata != NULL) { + ictxp = (iconv_t *)privdata; + if (*ictxp != (iconv_t)(-1)) + iconv_close(*ictxp); + + ictxp++; + if (*ictxp != (iconv_t)(-1)) + iconv_close(*ictxp); + free(privdata); + } +} + +static idn_result_t +converter_iconv_close(idn_converter_t ctx, void *privdata) { + assert(ctx != NULL); + + iconv_finalize_privdata(privdata); + + return (idn_success); +} + +static idn_result_t +converter_iconv_convfromucs4(idn_converter_t ctx, void *privdata, + const unsigned long *from, char *to, + size_t tolen) { + iconv_t ictx; + char *utf8 = NULL; + size_t utf8size = 256; /* large enough */ + idn_result_t r; + size_t sz; + size_t inleft; + size_t outleft; + char *inbuf, *outbuf; + + assert(ctx != NULL && from != NULL && to != NULL); + + if (tolen <= 0) { + r = idn_buffer_overflow; /* need space for NUL */ + goto ret; + } + + /* + * UCS4 -> UTF-8 conversion. + */ + utf8 = (char *)malloc(utf8size); + if (utf8 == NULL) { + r = idn_nomemory; + goto ret; + } + +try_again: + r = idn_ucs4_ucs4toutf8(from, utf8, utf8size); + if (r == idn_buffer_overflow) { + char *new_utf8; + + utf8size *= 2; + new_utf8 = (char *)realloc(utf8, utf8size); + if (new_utf8 == NULL) { + r = idn_nomemory; + goto ret; + } + utf8 = new_utf8; + goto try_again; + } else if (r != idn_success) { + goto ret; + } + + ictx = ((iconv_t *)privdata)[0]; + + /* + * Reset internal state. + * + * The following code should work according to the SUSv2 spec, + * but causes segmentation fault with Solaris 2.6. + * So.. a work-around. + * + * (void)iconv(ictx, (const char **)NULL, (size_t *)NULL, + * (char **)NULL, (size_t *)NULL); + */ + inleft = 0; + outbuf = NULL; + outleft = 0; + (void)iconv(ictx, (const char **)NULL, &inleft, &outbuf, &outleft); + + inleft = strlen(utf8); + inbuf = utf8; + outleft = tolen - 1; /* reserve space for terminating NUL */ + sz = iconv(ictx, (const char **)&inbuf, &inleft, &to, &outleft); + + if (sz == (size_t)(-1) || inleft > 0) { + switch (errno) { + case EILSEQ: + case EINVAL: + /* + * We already checked the validity of the input + * string. So we assume a mapping error. + */ + r = idn_nomapping; + goto ret; + case E2BIG: + r = idn_buffer_overflow; + goto ret; + default: + WARNING(("iconv failed with errno %d\n", errno)); + r = idn_failure; + goto ret; + } + } + + /* + * For UTF-8 -> local conversion, append a sequence of + * state reset. + */ + inleft = 0; + sz = iconv(ictx, (const char **)NULL, &inleft, &to, &outleft); + if (sz == (size_t)(-1)) { + switch (errno) { + case EILSEQ: + case EINVAL: + r = idn_invalid_encoding; + goto ret; + case E2BIG: + r = idn_buffer_overflow; + goto ret; + default: + WARNING(("iconv failed with errno %d\n", errno)); + r = idn_failure; + goto ret; + } + } + *to = '\0'; + r = idn_success; + +ret: + free(utf8); + return (r); + +} + +static idn_result_t +converter_iconv_convtoucs4(idn_converter_t ctx, void *privdata, + const char *from, unsigned long *to, size_t tolen) { + iconv_t ictx; + char *utf8 = NULL; + size_t utf8size = 256; /* large enough */ + idn_result_t r; + size_t sz; + size_t inleft; + size_t outleft; + const char *from_ptr; + char *outbuf; + + assert(ctx != NULL && from != NULL && to != NULL); + + if (tolen <= 0) { + r = idn_buffer_overflow; /* need space for NUL */ + goto ret; + } + ictx = ((iconv_t *)privdata)[1]; + utf8 = (char *)malloc(utf8size); + if (utf8 == NULL) { + r = idn_nomemory; + goto ret; + } + +try_again: + /* + * Reset internal state. + */ + inleft = 0; + outbuf = NULL; + outleft = 0; + (void)iconv(ictx, (const char **)NULL, &inleft, &outbuf, &outleft); + + from_ptr = from; + inleft = strlen(from); + outbuf = utf8; + outleft = utf8size - 1; /* reserve space for terminating NUL */ + sz = iconv(ictx, (const char **)&from_ptr, &inleft, &outbuf, &outleft); + + if (sz == (size_t)(-1) || inleft > 0) { + char *new_utf8; + + switch (errno) { + case EILSEQ: + case EINVAL: + /* + * We assume all the characters in the local + * codeset are included in UCS. This means mapping + * error is not possible, so the input string must + * have some problem. + */ + r = idn_invalid_encoding; + goto ret; + case E2BIG: + utf8size *= 2; + new_utf8 = (char *)realloc(utf8, utf8size); + if (new_utf8 == NULL) { + r = idn_nomemory; + goto ret; + } + utf8 = new_utf8; + goto try_again; + default: + WARNING(("iconv failed with errno %d\n", errno)); + r = idn_failure; + goto ret; + } + } + *outbuf = '\0'; + + /* + * UTF-8 -> UCS4 conversion. + */ + r = idn_ucs4_utf8toucs4(utf8, to, tolen); + +ret: + free(utf8); + return (r); +} + +#endif /* !WITHOUT_ICONV */ + +#ifdef DEBUG +/* + * Conversion to/from unicode escape string. + * Arbitrary UCS-4 character can be specified by a special sequence + * \u{XXXXXX} + * where XXXXX denotes any hexadecimal string up to FFFFFFFF. + * This is designed for debugging. + */ + +static idn_result_t +converter_uescape_convfromucs4(idn_converter_t ctx, void *privdata, + const unsigned long *from, char *to, + size_t tolen) { + idn_result_t r; + unsigned long v; + + while (*from != '\0') { + v = *from++; + + if (v <= 0x7f) { + if (tolen < 1) { + r = idn_buffer_overflow; + goto failure; + } + *to++ = v; + tolen--; + } else if (v <= 0xffffffff) { + char tmp[20]; + int len; + + (void)sprintf(tmp, "\\u{%lx}", v); + len = strlen(tmp); + if (tolen < len) { + r = idn_buffer_overflow; + goto failure; + } + (void)memcpy(to, tmp, len); + to += len; + tolen -= len; + } else { + r = idn_invalid_encoding; + goto failure; + } + } + + if (tolen <= 0) { + r = idn_buffer_overflow; + goto failure; + } + *to = '\0'; + + return (idn_success); + +failure: + if (r != idn_buffer_overflow) { + WARNING(("idn_uescape_convfromucs4(): %s\n", + idn_result_tostring(r))); + } + return (r); +} + +static idn_result_t +converter_uescape_convtoucs4(idn_converter_t ctx, void *privdata, + const char *from, unsigned long *to, size_t tolen) +{ + idn_result_t r; + size_t fromlen = strlen(from); + + while (*from != '\0') { + if (tolen <= 0) { + r = idn_buffer_overflow; + goto failure; + } + if (strncmp(from, "\\u{", 3) == 0 || + strncmp(from, "\\U{", 3) == 0) { + size_t ullen; + unsigned long v; + char *end; + + v = strtoul(from + 3, &end, 16); + ullen = end - (from + 3); + if (*end == '}' && ullen > 1 && ullen < 8) { + *to = v; + from = end + 1; + fromlen -= ullen; + } else { + *to = '\\'; + from++; + fromlen--; + } + } else { + int c = *(unsigned char *)from; + size_t width; + char buf[8]; + + if (c < 0x80) + width = 1; + else if (c < 0xc0) + width = 0; + else if (c < 0xe0) + width = 2; + else if (c < 0xf0) + width = 3; + else if (c < 0xf8) + width = 4; + else if (c < 0xfc) + width = 5; + else if (c < 0xfe) + width = 6; + else + width = 0; + if (width == 0 || width > fromlen) { + r = idn_invalid_encoding; + goto failure; + } + + memcpy(buf, from, width); + buf[width] = '\0'; + r = idn_ucs4_utf8toucs4(buf, to, tolen); + if (r != idn_success) { + r = idn_invalid_encoding; + goto failure; + } + from += width; + fromlen -= width; + } + to++; + tolen--; + } + + if (tolen <= 0) { + r = idn_buffer_overflow; + goto failure; + } + *to = '\0'; + + return (idn_success); + +failure: + if (r != idn_buffer_overflow) { + WARNING(("idn_uescape_convtoucs4(): %s\n", + idn_result_tostring(r))); + } + return (r); +} + +#endif diff --git a/contrib/idn/idnkit-1.0-src/lib/debug.c b/contrib/idn/idnkit-1.0-src/lib/debug.c new file mode 100644 index 0000000..07eba0a --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/debug.c @@ -0,0 +1,267 @@ +#ifndef lint +static char *rcsid = "$Id: debug.c,v 1.1.1.1 2003/06/04 00:25:51 marka Exp $"; +#endif + +/* + * Copyright (c) 2000,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 <config.h> + +#include <stdio.h> +#include <stdarg.h> +#include <stdlib.h> +#include <string.h> + +#include <idn/debug.h> + +static char *hex = "0123456789abcdef"; + +#define STRING_MAXBYTES 200 +#define STRING_NBUFS 4 +static char bufs[STRING_NBUFS][STRING_MAXBYTES + 16]; /* +16 for margin */ +static int bufno = 0; + +char * +idn__debug_hexstring(const char *s, int maxbytes) { + char *buf = bufs[bufno]; + char *p; + int i; + + if (maxbytes > STRING_MAXBYTES) + maxbytes = STRING_MAXBYTES; + + for (i = 0, p = buf; i < maxbytes; i += 3, s++) { + int c = *(unsigned char *)s; + + if (c == '\0') + break; + *p++ = hex[c >> 4]; + *p++ = hex[c & 15]; + *p++ = ' '; + } + + if (i >= maxbytes) + strcpy(p, "..."); + else + *p = '\0'; + + bufno = (bufno + 1) % STRING_NBUFS; + return (buf); +} + +char * +idn__debug_xstring(const char *s, int maxbytes) { + char *buf = bufs[bufno]; + char *p; + int i; + + if (maxbytes > STRING_MAXBYTES) + maxbytes = STRING_MAXBYTES; + + i = 0; + p = buf; + while (i < maxbytes) { + int c = *(unsigned char *)s; + + if (c == '\0') { + break; + } else if (0x20 <= c && c <= 0x7e) { + *p++ = c; + i++; + } else { + *p++ = '\\'; + *p++ = 'x'; + *p++ = hex[c >> 4]; + *p++ = hex[c & 15]; + i += 4; + } + s++; + } + + if (i >= maxbytes) + strcpy(p, "..."); + else + *p = '\0'; + + bufno = (bufno + 1) % STRING_NBUFS; + return (buf); +} + +char * +idn__debug_ucs4xstring(const unsigned long *s, int maxbytes) { + char *buf = bufs[bufno]; + char *p; + int i; + + if (maxbytes > STRING_MAXBYTES) + maxbytes = STRING_MAXBYTES; + + i = 0; + p = buf; + while (i < maxbytes) { + if (*s == '\0') { + break; + } else if (0x20 <= *s && *s <= 0x7e) { + *p++ = *s; + i++; + } else { + *p++ = '\\'; + *p++ = 'x'; + i += 2; + if (*s >= 0x1000000UL) { + *p++ = hex[(*s >> 28) & 0x0f]; + *p++ = hex[(*s >> 24) & 0x0f]; + i += 2; + } + if (*s >= 0x10000UL) { + *p++ = hex[(*s >> 20) & 0x0f]; + *p++ = hex[(*s >> 16) & 0x0f]; + i += 2; + } + if (*s >= 0x100UL) { + *p++ = hex[(*s >> 12) & 0x0f]; + *p++ = hex[(*s >> 8) & 0x0f]; + i += 2; + } + *p++ = hex[(*s >> 4) & 0x0f]; + *p++ = hex[ *s & 0x0f]; + i += 2; + } + s++; + } + + if (i >= maxbytes) + strcpy(p, "..."); + else + *p = '\0'; + + bufno = (bufno + 1) % STRING_NBUFS; + return (buf); +} + +char * +idn__debug_utf16xstring(const unsigned short *s, int maxbytes) { + char *buf = bufs[bufno]; + char *p; + int i; + + if (maxbytes > STRING_MAXBYTES) + maxbytes = STRING_MAXBYTES; + + i = 0; + p = buf; + while (i < maxbytes) { + if (*s == '\0') { + break; + } else if (0x20 <= *s && *s <= 0x7e) { + *p++ = *s; + i++; + } else { + *p++ = '\\'; + *p++ = 'x'; + *p++ = hex[(*s >> 12) & 0x0f]; + *p++ = hex[(*s >> 8) & 0x0f]; + *p++ = hex[(*s >> 4) & 0x0f]; + *p++ = hex[ *s & 0x0f]; + i += 6; + } + s++; + } + + if (i >= maxbytes) + strcpy(p, "..."); + else + *p = '\0'; + + bufno = (bufno + 1) % STRING_NBUFS; + return (buf); +} + +char * +idn__debug_hexdata(const char *s, int length, int maxbytes) { + char *buf = bufs[bufno]; + char *p; + int i; + + if (maxbytes > STRING_MAXBYTES) + maxbytes = STRING_MAXBYTES; + + i = 0; + p = buf; + while (length > 0 && i < maxbytes) { + int c = *(const unsigned char *)s; + + *p++ = hex[c >> 4]; + *p++ = hex[c & 15]; + *p++ = ' '; + i += 3; + length--; + s++; + } + + if (i >= maxbytes) + strcpy(p, "..."); + else + *p = '\0'; + + bufno = (bufno + 1) % STRING_NBUFS; + return (buf); +} + +void +idn__debug_hexdump(const char *s, int length) { + int i; + const unsigned char *p = (const unsigned char *)s; + + i = 0; + while (length-- > 0) { + if (i % 16 == 0) { + if (i > 0) + fprintf(stderr, "\n"); + fprintf(stderr, "%4x:", i); + } + fprintf(stderr, " %02x", p[i]); + i++; + } + fprintf(stderr, "\n"); +} diff --git a/contrib/idn/idnkit-1.0-src/lib/delimitermap.c b/contrib/idn/idnkit-1.0-src/lib/delimitermap.c new file mode 100644 index 0000000..6f470a8 --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/delimitermap.c @@ -0,0 +1,268 @@ +#ifndef lint +static char *rcsid = "$Id: delimitermap.c,v 1.1.1.1 2003/06/04 00:25:52 marka Exp $"; +#endif + +/* + * Copyright (c) 2001,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 <config.h> + +#include <stddef.h> +#include <stdlib.h> +#include <string.h> + +#include <idn/result.h> +#include <idn/assert.h> +#include <idn/logmacro.h> +#include <idn/delimitermap.h> +#include <idn/util.h> +#include <idn/debug.h> +#include <idn/ucs4.h> + +/* + * Mapper object type. + */ +struct idn_delimitermap { + int ndelimiters; + int delimiter_size; + unsigned long *delimiters; + int reference_count; +}; + +#define DELIMITERMAP_INITIAL_DELIMITER_SIZE 4 +#define UNICODE_MAX 0x10ffff +#define IS_SURROGATE_HIGH(v) (0xd800 <= (v) && (v) <= 0xdbff) +#define IS_SURROGATE_LOW(v) (0xdc00 <= (v) && (v) <= 0xdfff) + +idn_result_t +idn_delimitermap_create(idn_delimitermap_t *ctxp) { + idn_delimitermap_t ctx = NULL; + idn_result_t r; + + assert(ctxp != NULL); + TRACE(("idn_delimitermap_create()\n")); + + ctx = (idn_delimitermap_t) malloc(sizeof(struct idn_delimitermap)); + if (ctx == NULL) { + WARNING(("idn_mapper_create: malloc failed\n")); + r = idn_nomemory; + goto ret; + } + + ctx->delimiters = (unsigned long *) malloc(sizeof(unsigned long) + * DELIMITERMAP_INITIAL_DELIMITER_SIZE); + if (ctx->delimiters == NULL) { + r = idn_nomemory; + goto ret; + } + ctx->ndelimiters = 0; + ctx->delimiter_size = DELIMITERMAP_INITIAL_DELIMITER_SIZE; + ctx->reference_count = 1; + *ctxp = ctx; + r = idn_success; + +ret: + if (r != idn_success) + free(ctx); + TRACE(("idn_delimitermap_create(): %s\n", idn_result_tostring(r))); + return (r); +} + +void +idn_delimitermap_destroy(idn_delimitermap_t ctx) { + assert(ctx != NULL); + + TRACE(("idn_delimitermap_destroy()\n")); + + ctx->reference_count--; + if (ctx->reference_count <= 0) { + TRACE(("idn_mapper_destroy(): the object is destroyed\n")); + free(ctx->delimiters); + free(ctx); + } else { + TRACE(("idn_delimitermap_destroy(): " + "update reference count (%d->%d)\n", + ctx->reference_count + 1, ctx->reference_count)); + } +} + +void +idn_delimitermap_incrref(idn_delimitermap_t ctx) { + assert(ctx != NULL); + + TRACE(("idn_delimitermap_incrref()\n")); + TRACE(("idn_delimitermap_incrref: update reference count (%d->%d)\n", + ctx->reference_count, ctx->reference_count + 1)); + + ctx->reference_count++; +} + +idn_result_t +idn_delimitermap_add(idn_delimitermap_t ctx, unsigned long delimiter) { + idn_result_t r; + + assert(ctx != NULL && ctx->ndelimiters <= ctx->delimiter_size); + TRACE(("idn_delimitermap_add(delimiter=\\x%04lx)\n", delimiter)); + + if (delimiter == 0 || delimiter > UNICODE_MAX || + IS_SURROGATE_HIGH(delimiter) || IS_SURROGATE_LOW(delimiter)) { + r = idn_invalid_codepoint; + goto ret; + } + + if (ctx->ndelimiters == ctx->delimiter_size) { + unsigned long *new_delimiters; + + new_delimiters = (unsigned long *) realloc(ctx->delimiters, + sizeof(unsigned long) * ctx->delimiter_size * 2); + if (new_delimiters == NULL) { + r = idn_nomemory; + goto ret; + } + ctx->delimiters = new_delimiters; + ctx->delimiter_size *= 2; + } + + ctx->delimiters[ctx->ndelimiters] = delimiter; + ctx->ndelimiters++; + r = idn_success; + +ret: + TRACE(("idn_delimitermap_add(): %s\n", idn_result_tostring(r))); + return (r); +} + +idn_result_t +idn_delimitermap_addall(idn_delimitermap_t ctx, unsigned long *delimiters, + int ndelimiters) { + idn_result_t r; + int i; + + assert(ctx != NULL && delimiters != NULL); + + TRACE(("idn_delimitermap_addall(ndelimiters=%d)\n", ndelimiters)); + + for (i = 0; i < ndelimiters; i++) { + r = idn_delimitermap_add(ctx, *delimiters); + if (r != idn_success) + goto ret; + delimiters++; + } + + r = idn_success; +ret: + TRACE(("idn_delimitermap_addall(): %s\n", idn_result_tostring(r))); + return (r); +} + +idn_result_t +idn_delimitermap_map(idn_delimitermap_t ctx, const unsigned long *from, + unsigned long *to, size_t tolen) { + + /* default delimiters (label separators) from IDNA specification */ + static const unsigned long default_delimiters[] = + { 0x002e, /* full stop */ + 0x3002, /* ideographic full stop */ + 0xff0e, /* fullwidth full stop */ + 0xff61, /* halfwidth ideographic full stop */ + 0x0000 }; + + unsigned long *to_org = to; + idn_result_t r; + int i, j; + int found; + + assert(ctx != NULL && from != NULL && to != NULL); + + TRACE(("idn_delimitermap_map(from=\"%s\", tolen=%d)\n", + idn__debug_ucs4xstring(from, 50), (int)tolen)); + + /* + * Map. + */ + while (*from != '\0') { + found = 0; + if (tolen < 1) { + r = idn_buffer_overflow; + goto ret; + } + for (j = 0; default_delimiters[j] != 0x0000; j++) { + if (default_delimiters[j] == *from) { + found = 1; + break; + } + } + if (!found) { + for (i = 0; i < ctx->ndelimiters; i++) { + if (ctx->delimiters[i] == *from) { + found = 1; + break; + } + } + } + if (found) + *to = '.'; + else + *to = *from; + from++; + to++; + tolen--; + } + + if (tolen < 1) { + r = idn_buffer_overflow; + goto ret; + } + *to = '\0'; + r = idn_success; + +ret: + if (r == idn_success) { + TRACE(("idn_delimitermap_map(): success (to=\"%s\")\n", + idn__debug_ucs4xstring(to_org, 50))); + } else { + TRACE(("idn_delimitermap_map(): %s\n", + idn_result_tostring(r))); + } + return (r); +} diff --git a/contrib/idn/idnkit-1.0-src/lib/filechecker.c b/contrib/idn/idnkit-1.0-src/lib/filechecker.c new file mode 100644 index 0000000..64330bb --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/filechecker.c @@ -0,0 +1,261 @@ +#ifndef lint +static char *rcsid = "$Id: filechecker.c,v 1.1.1.1 2003/06/04 00:25:52 marka Exp $"; +#endif + +/* + * Copyright (c) 2001,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 <config.h> + +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <ctype.h> + +#include <idn/result.h> +#include <idn/assert.h> +#include <idn/log.h> +#include <idn/logmacro.h> +#include <idn/ucsset.h> +#include <idn/filechecker.h> +#include <idn/debug.h> + +#define SUPPORT_VERSIONING + +struct idn__filechecker { + idn_ucsset_t set; +}; + +static idn_result_t read_file(const char *file, FILE *fp, + idn_ucsset_t set); +static int get_range(char *s, unsigned long *ucs1, + unsigned long *ucs2); +static char *get_ucs(char *p, unsigned long *vp); + + +idn_result_t +idn__filechecker_create(const char *file, idn__filechecker_t *ctxp) { + FILE *fp; + idn__filechecker_t ctx; + idn_result_t r; + + assert(file != NULL && ctxp != NULL); + + TRACE(("idn__filechecker_create(file=\"%-.100s\")\n", file)); + + if ((fp = fopen(file, "r")) == NULL) { + WARNING(("idn__filechecker_create: cannot open %-.100s\n", + file)); + return (idn_nofile); + } + + if ((ctx = malloc(sizeof(struct idn__filechecker))) == NULL) + return (idn_nomemory); + + if ((r = idn_ucsset_create(&ctx->set)) != idn_success) { + free(ctx); + return (r); + } + + r = read_file(file, fp, ctx->set); + fclose(fp); + + if (r == idn_success) { + idn_ucsset_fix(ctx->set); + *ctxp = ctx; + } else { + idn_ucsset_destroy(ctx->set); + free(ctx); + } + return (r); +} + +void +idn__filechecker_destroy(idn__filechecker_t ctx) { + assert(ctx != NULL); + + TRACE(("idn__filechecker_destroy()\n")); + + idn_ucsset_destroy(ctx->set); + free(ctx); +} + +idn_result_t +idn__filechecker_lookup(idn__filechecker_t ctx, const unsigned long *str, + const unsigned long **found) { + idn_result_t r = idn_success; + + assert(ctx != NULL && str != NULL); + + TRACE(("idn__filechecker_lookup(str=\"%s\")\n", + idn__debug_ucs4xstring(str, 50))); + + while (*str != '\0') { + int exists; + + r = idn_ucsset_lookup(ctx->set, *str, &exists); + + if (r != idn_success) { + return (r); + } else if (exists) { + /* Found. */ + *found = str; + return (idn_success); + } + str++; + } + *found = NULL; + return (idn_success); +} + +static idn_result_t +read_file(const char *file, FILE *fp, idn_ucsset_t set) { + char line[256]; + idn_result_t r; + int lineno = 0; + + while (fgets(line, sizeof(line), fp) != NULL) { + char *p = line; + unsigned long ucs1, ucs2; + + lineno++; + while (isspace((unsigned char)*p)) + p++; + if (*p == '\0' || *p == '#') + continue; + +#ifdef SUPPORT_VERSIONING + /* Skip version tag. */ + if (lineno == 1 && strncmp("version=", line, 8) == 0) + continue; +#endif + if (!get_range(p, &ucs1, &ucs2)) { + WARNING(("syntax error in file \"%-.100s\" line %d: " + "%-.100s", file, lineno, line)); + return (idn_invalid_syntax); + } + if ((r = idn_ucsset_addrange(set, ucs1, ucs2)) != idn_success) + return (r); + } + return (idn_success); +} + +static int +get_range(char *s, unsigned long *ucs1, unsigned long *ucs2) { + if ((s = get_ucs(s, ucs1)) == NULL) + return (0); + *ucs2 = *ucs1; + + switch (s[0]) { + case '\0': + case '\n': + case '#': + case ';': + return (1); + case '-': + break; + default: + return (0); + } + + if ((s = get_ucs(s + 1, ucs2)) == NULL) + return (0); + + if (*ucs1 > *ucs2) { + INFO(("idn__filechecker_create: invalid range spec " + "U+%X-U+%X\n", *ucs1, *ucs2)); + return (0); + } + + switch (s[0]) { + case '\0': + case '\n': + case '#': + case ';': + return (1); + default: + return (0); + } +} + + +static char * +get_ucs(char *p, unsigned long *vp) { + char *end; + + /* Skip leading space */ + while (isspace((unsigned char)*p)) + p++; + + /* Skip optional 'U+' */ + if (strncmp(p, "U+", 2) == 0) + p += 2; + + *vp = strtoul(p, &end, 16); + if (end == p) { + INFO(("idn__filechecker_create: UCS code point expected\n")); + return (NULL); + } + p = end; + + /* Skip trailing space */ + while (isspace((unsigned char)*p)) + p++; + return p; +} + +idn_result_t +idn__filechecker_createproc(const char *parameter, void **ctxp) { + return idn__filechecker_create(parameter, (idn__filechecker_t *)ctxp); +} + +void +idn__filechecker_destroyproc(void *ctxp) { + idn__filechecker_destroy((idn__filechecker_t)ctxp); +} + +idn_result_t +idn__filechecker_lookupproc(void *ctx, const unsigned long *str, + const unsigned long **found) { + return idn__filechecker_lookup((idn__filechecker_t)ctx, str, found); +} diff --git a/contrib/idn/idnkit-1.0-src/lib/filemapper.c b/contrib/idn/idnkit-1.0-src/lib/filemapper.c new file mode 100644 index 0000000..970b942 --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/filemapper.c @@ -0,0 +1,347 @@ +#ifndef lint +static char *rcsid = "$Id: filemapper.c,v 1.1.1.1 2003/06/04 00:25:53 marka Exp $"; +#endif + +/* + * Copyright (c) 2001,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 <config.h> + +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <ctype.h> + +#include <idn/result.h> +#include <idn/assert.h> +#include <idn/log.h> +#include <idn/logmacro.h> +#include <idn/debug.h> +#include <idn/ucs4.h> +#include <idn/ucsmap.h> +#include <idn/filemapper.h> + +#define SUPPORT_VERSIONING + +#define UCSBUF_LOCAL_SIZE 20 + +typedef struct ucsbuf { + unsigned long *ucs; + size_t size; + size_t len; + unsigned long local[UCSBUF_LOCAL_SIZE]; +} ucsbuf_t; + +struct idn__filemapper { + idn_ucsmap_t map; +}; + +static void ucsbuf_init(ucsbuf_t *b); +static idn_result_t ucsbuf_grow(ucsbuf_t *b); +static idn_result_t ucsbuf_append(ucsbuf_t *b, unsigned long v); +static void ucsbuf_free(ucsbuf_t *b); +static idn_result_t read_file(const char *file, FILE *fp, + idn_ucsmap_t map); +static idn_result_t get_map(char *p, ucsbuf_t *b); +static char *get_ucs(char *p, unsigned long *vp); + + +idn_result_t +idn__filemapper_create(const char *file, idn__filemapper_t *ctxp) { + FILE *fp; + idn__filemapper_t ctx; + idn_result_t r; + + assert(file != NULL && ctxp != NULL); + + TRACE(("idn__filemapper_create(file=\"%-.100s\")\n", file)); + + if ((fp = fopen(file, "r")) == NULL) { + WARNING(("idn__filemapper_create: cannot open %-.100s\n", + file)); + return (idn_nofile); + } + if ((ctx = malloc(sizeof(struct idn__filemapper))) == NULL) + return (idn_nomemory); + + if ((r = idn_ucsmap_create(&ctx->map)) != idn_success) { + free(ctx); + return (r); + } + + r = read_file(file, fp, ctx->map); + fclose(fp); + + if (r == idn_success) { + idn_ucsmap_fix(ctx->map); + *ctxp = ctx; + } else { + idn_ucsmap_destroy(ctx->map); + free(ctx); + } + return (r); +} + +void +idn__filemapper_destroy(idn__filemapper_t ctx) { + + assert(ctx != NULL); + + TRACE(("idn__filemapper_destroy()\n")); + + idn_ucsmap_destroy(ctx->map); + free(ctx); +} + +idn_result_t +idn__filemapper_map(idn__filemapper_t ctx, const unsigned long *from, + unsigned long *to, size_t tolen) +{ + idn_result_t r = idn_success; + ucsbuf_t ub; + + assert(ctx != NULL && from != NULL && to != NULL); + + TRACE(("idn__filemapper_map(from=\"%s\")\n", + idn__debug_ucs4xstring(from, 50))); + + /* Initialize temporary buffer. */ + ucsbuf_init(&ub); + + while (*from != '\0') { + /* Try mapping. */ + r = idn_ucsmap_map(ctx->map, *from, ub.ucs, ub.size, &ub.len); + switch (r) { + case idn_buffer_overflow: + /* Temporary buffer too small. Enlarge and retry. */ + if ((r = ucsbuf_grow(&ub)) != idn_success) + break; + continue; + case idn_nomapping: + /* There is no mapping. */ + r = idn_success; + /* fallthrough */ + case idn_success: + if (tolen < ub.len) { + r = idn_buffer_overflow; + goto ret; + } + memcpy(to, ub.ucs, sizeof(*to) * ub.len); + to += ub.len; + tolen -= ub.len; + break; + default: + goto ret; + } + from++; + } + + ret: + ucsbuf_free(&ub); + + if (r == idn_success) { + /* Terminate with NUL. */ + if (tolen == 0) + return (idn_buffer_overflow); + *to = '\0'; + } + + return (r); +} + +static void +ucsbuf_init(ucsbuf_t *b) { + b->ucs = b->local; + b->size = UCSBUF_LOCAL_SIZE; + b->len = 0; +} + +static idn_result_t +ucsbuf_grow(ucsbuf_t *b) { + unsigned long *newbuf; + + b->size *= 2; + if (b->ucs == b->local) { + b->ucs = malloc(sizeof(unsigned long) * b->size); + if (b->ucs == NULL) + return (idn_nomemory); + memcpy(b->ucs, b->local, sizeof(b->local)); + } else { + newbuf = realloc(b->ucs, sizeof(unsigned long) * b->size); + if (newbuf == NULL) + return (idn_nomemory); + b->ucs = newbuf; + } + return (idn_success); +} + +static idn_result_t +ucsbuf_append(ucsbuf_t *b, unsigned long v) { + idn_result_t r; + + if (b->len + 1 > b->size) { + r = ucsbuf_grow(b); + if (r != idn_success) + return (r); + } + b->ucs[b->len++] = v; + return (idn_success); +} + +static void +ucsbuf_free(ucsbuf_t *b) { + if (b->ucs != b->local && b->ucs != NULL) + free(b->ucs); +} + +static idn_result_t +read_file(const char *file, FILE *fp, idn_ucsmap_t map) { + char line[1024]; + ucsbuf_t ub; + idn_result_t r = idn_success; + int lineno = 0; + + ucsbuf_init(&ub); + + while (fgets(line, sizeof(line), fp) != NULL) { + char *p = line; + + lineno++; + while (isspace((unsigned char)*p)) + p++; + if (*p == '\0' || *p == '#') + continue; +#ifdef SUPPORT_VERSIONING + /* Skip version tag. */ + if (lineno == 1 && strncmp("version=", line, 8) == 0) + continue; +#endif + again: + ub.len = 0; + r = get_map(p, &ub); + switch (r) { + case idn_success: + r = idn_ucsmap_add(map, ub.ucs[0], + &ub.ucs[1], ub.len - 1); + break; + case idn_buffer_overflow: + if ((r = ucsbuf_grow(&ub)) != idn_success) + break; + goto again; + case idn_invalid_syntax: + WARNING(("syntax error in file \"%-.100s\" line %d: " + "%-.100s", file, lineno, line)); + /* fall through */ + default: + ucsbuf_free(&ub); + return (r); + } + } + ucsbuf_free(&ub); + return (r); +} + +static idn_result_t +get_map(char *p, ucsbuf_t *b) { + unsigned long v; + idn_result_t r = idn_success; + + for (;;) { + if ((p = get_ucs(p, &v)) == NULL) + return (idn_invalid_syntax); + if ((r = ucsbuf_append(b, v)) != idn_success) + return (r); + if (b->len == 1) { + if (*p != ';') + return (idn_invalid_syntax); + p++; + while (isspace((unsigned char)*p)) + p++; + } + + if (*p == ';' || *p == '#' || *p == '\0') + return (r); + } + return (r); +} + +static char * +get_ucs(char *p, unsigned long *vp) { + char *end; + + /* Skip leading space */ + while (isspace((unsigned char)*p)) + p++; + + /* Skip optional 'U+' */ + if (strncmp(p, "U+", 2) == 0) + p += 2; + + *vp = strtoul(p, &end, 16); + if (end == p) { + INFO(("idn__filemapper_create: UCS code point expected\n")); + return (NULL); + } + p = end; + + /* Skip trailing space */ + while (isspace((unsigned char)*p)) + p++; + return p; +} + +idn_result_t +idn__filemapper_createproc(const char *parameter, void **ctxp) { + return idn__filemapper_create(parameter, (idn__filemapper_t *)ctxp); +} + +void +idn__filemapper_destroyproc(void *ctxp) { + idn__filemapper_destroy((idn__filemapper_t)ctxp); +} + +idn_result_t +idn__filemapper_mapproc(void *ctx, const unsigned long *from, + unsigned long *to, size_t tolen) { + return idn__filemapper_map((idn__filemapper_t)ctx, from, to, tolen); +} diff --git a/contrib/idn/idnkit-1.0-src/lib/idn.conf.sample.in b/contrib/idn/idnkit-1.0-src/lib/idn.conf.sample.in new file mode 100644 index 0000000..ac771a8 --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/idn.conf.sample.in @@ -0,0 +1,61 @@ +# $Id: idn.conf.sample.in,v 1.1.1.1 2003/06/04 00:26:45 marka Exp $ +# +# Sample file for idnkit configuration file (idn.conf). +# + +# +# `idn-encoding' entry specifies the encoding name used as the encoding +# of multilingualized names by resolvers and DNS servers. Currently, the +# following encodings are available: +# +# Punycode +# UTF-8 +# <codeset names your iconv_open() accepts> +# +# If you enabled extra ace feature, following IDN encoding can be used. +# +# AMC-ACE-Z (old name of Punycode) +# RACE +# +# syntax) +# idn-encoding <encoding> +# +idn-encoding Punycode + +# +# `nameprep' entry specifies the version of NAMEPREP. +# idnkit currently supports the following version: +# +# RFC3491 -- name preparation scheme described in the +# RFC3491 +# +# syntax) +# nameprep <nameprep version> +# +nameprep RFC3491 + +# +# `local-map' entry specifies TLD (top level domain) based local mapping +# schemes, which is performed before NAMEPREP. Available schemes are: +# +# <nameprep version> -- nameprep version +# filemap:<pathname> -- read mapping rules from a file +# +# syntax) +# local-map <tld> <scheme> ... +# +# If the TLD of the domain name matches <tld>, local mapping specified +# by <scheme> is performed on the name. Otherwise no mapping are +# performed. Multiple schemes can be specified; they are applied in +# turn. +# +# There are two special <tld>s for specifying a default mapping rule +# and a mapping rule for local names (domain names containing no +# dots). If <tld> is `.', its schemes are applied to domain names +# whose TLD does not match any TLDs specified in local-map entries. +# If <tld> is `-', its schemes are applied to domain names which +# contain no dots. +# +#local-map - filemap:/some/where/local.map +#local-map . filemap:/some/where/default.map +local-map .jp filemap:@mapdir@/jp.map diff --git a/contrib/idn/idnkit-1.0-src/lib/localencoding.c b/contrib/idn/idnkit-1.0-src/lib/localencoding.c new file mode 100644 index 0000000..ae937ea --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/localencoding.c @@ -0,0 +1,123 @@ +#ifndef lint +static char *rcsid = "$Id: localencoding.c,v 1.1.1.1 2003/06/04 00:25:53 marka Exp $"; +#endif + +/* + * Copyright (c) 2000 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 <config.h> + +#ifdef WIN32 +#include <windows.h> +#endif +#include <stddef.h> +#include <stdlib.h> +#include <stdio.h> +#include <string.h> + +#ifdef HAVE_LOCALE_H +#include <locale.h> +#endif +#ifdef HAVE_LANGINFO_H +#include <langinfo.h> +#endif + +#include <idn/logmacro.h> +#include <idn/localencoding.h> +#include <idn/debug.h> + +#ifdef ENABLE_MDNKIT_COMPAT +#include <mdn/localencoding.h> +#endif + +const char * +idn_localencoding_name(void) { + char *name; + + TRACE(("idn_localencoding_name()\n")); + + if ((name = getenv(IDN_LOCALCS_ENV)) != NULL) { + TRACE(("local encoding=\"%-.30s\"\n", + name == NULL ? "<null>" : name)); + return (name); + } +#ifdef ENABLE_MDNKIT_COMPAT + if ((name = getenv(MDN_LOCALCS_ENV)) != NULL) { + TRACE(("local encoding=\"%-.30s\"\n", + name == NULL ? "<null>" : name)); + return (name); + } +#endif + +#ifdef WIN32 + { + static char cp_str[40]; /* enough */ + (void)sprintf(cp_str, "CP%u", GetACP()); + TRACE(("local encoding(codepage)=\"%-.30s\"\n", cp_str)); + return (cp_str); + } +#else /* WIN32 */ +#ifdef HAVE_LIBCHARSET + name = locale_charset(); + TRACE(("local encoding=\"%-.30s\"\n", + name == NULL ? "<null>" : name)); + return (name); +#endif + +#if defined(HAVE_NL_LANGINFO) && defined(CODESET) + if ((name = nl_langinfo(CODESET)) != NULL) { + TRACE(("local encoding=\"%-.30s\"\n", + name == NULL ? "<null>" : name)); + return (name); + } +#endif + (void)( +#ifdef HAVE_SETLOCALE + (name = setlocale(LC_CTYPE, NULL)) || +#endif + (name = getenv("LC_ALL")) || + (name = getenv("LC_CTYPE")) || + (name = getenv("LANG"))); + TRACE(("local encoding=\"%-.30s\"\n", name == NULL ? "<null>" : name)); + return (name); +#endif /* WIN32 */ +} diff --git a/contrib/idn/idnkit-1.0-src/lib/log.c b/contrib/idn/idnkit-1.0-src/lib/log.c new file mode 100644 index 0000000..92ba9c9 --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/log.c @@ -0,0 +1,215 @@ +#ifndef lint +static char *rcsid = "$Id: log.c,v 1.1.1.1 2003/06/04 00:25:53 marka Exp $"; +#endif + +/* + * Copyright (c) 2000 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 <config.h> + +#include <stdio.h> +#include <stdarg.h> +#include <stdlib.h> +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif + +#include <idn/log.h> + +#define LOGLEVEL_ENV "IDN_LOG_LEVEL" + +#ifdef DEBUG +#define DEFAULT_LOG_LEVEL idn_log_level_info +#else +#define DEFAULT_LOG_LEVEL idn_log_level_error +#endif + +static int log_level = -1; +static idn_log_proc_t log_proc; + +static void initialize(void); +static void log(int level, const char *fmt, va_list args); +static void log_to_stderr(int level, const char *buf); + +void +idn_log_fatal(const char *fmt, ...) { + va_list args; + + va_start(args, fmt); + log(idn_log_level_fatal, fmt, args); + va_end(args); + exit(1); +} + +void +idn_log_error(const char *fmt, ...) { + va_list args; + + va_start(args, fmt); + log(idn_log_level_error, fmt, args); + va_end(args); +} + +void +idn_log_warning(const char *fmt, ...) { + va_list args; + + va_start(args, fmt); + log(idn_log_level_warning, fmt, args); + va_end(args); +} + +void +idn_log_info(const char *fmt, ...) { + va_list args; + + va_start(args, fmt); + log(idn_log_level_info, fmt, args); + va_end(args); +} + +void +idn_log_trace(const char *fmt, ...) { + va_list args; + + va_start(args, fmt); + log(idn_log_level_trace, fmt, args); + va_end(args); +} + +void +idn_log_dump(const char *fmt, ...) { + va_list args; + + va_start(args, fmt); + log(idn_log_level_dump, fmt, args); + va_end(args); +} + +void +idn_log_setlevel(int level) { + if (level >= 0) + log_level = level; +} + +int +idn_log_getlevel(void) { + if (log_level < 0) + initialize(); + return log_level; +} + +void +idn_log_setproc(idn_log_proc_t proc) { + if (proc == NULL) + log_proc = log_to_stderr; + else + log_proc = proc; +} + +static void +initialize(void) { + char *s; + + if (log_level < 0) { + if ((s = getenv(LOGLEVEL_ENV)) != NULL) { + int level = atoi(s); + if (level >= 0) + log_level = level; + } + if (log_level < 0) + log_level = DEFAULT_LOG_LEVEL; + } + + if (log_proc == NULL) + log_proc = log_to_stderr; +} + +static void +log(int level, const char *fmt, va_list args) { + char buf[1024]; + + initialize(); + + if (log_level < level) + return; + +#if HAVE_VSNPRINTF + (void)vsnprintf(buf, sizeof(buf), fmt, args); +#else + /* Let's hope 1024 is enough.. */ + (void)vsprintf(buf, fmt, args); +#endif + (*log_proc)(level, buf); +} + +static void +log_to_stderr(int level, const char *buf) { + char *title; + char tmp[20]; + + switch (level) { + case idn_log_level_fatal: + title = "FATAL"; + break; + case idn_log_level_error: + title = "ERROR"; + break; + case idn_log_level_warning: + title = "WARNING"; + break; + case idn_log_level_info: + title = "INFO"; + break; + case idn_log_level_trace: + title = "TRACE"; + break; + case idn_log_level_dump: + title = "DUMP"; + break; + default: + (void)sprintf(tmp, "LEVEL%d", level); + title = tmp; + break; + } + fprintf(stderr, "%u: [%s] %s", (unsigned int)getpid(), title, buf); +} diff --git a/contrib/idn/idnkit-1.0-src/lib/make.wnt b/contrib/idn/idnkit-1.0-src/lib/make.wnt new file mode 100644 index 0000000..9d80dcf --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/make.wnt @@ -0,0 +1,279 @@ +# $Id: make.wnt,v 1.1.1.1 2003/06/04 00:25:54 marka Exp $ +# Makefile for MDN library, manually configured for WIN-NT (VC5.0) +# +# Copyright (c) 2000,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 <ntwin32.mak> + +INCDIR = ..\include +ICONVDIR = ..\win +LIBS = $(ICONVDIR)\iconv.lib +LIBS_LITE = +SYSLIBS = $(conlibsdll) + +# +# Files to build MDN library +# + +HDRS_LITE = \ + $(INCDIR)\config.h \ + $(INCDIR)\idn\aliaslist.h \ + $(INCDIR)\idn\api.h \ + $(INCDIR)\idn\assert.h \ + $(INCDIR)\idn\checker.h \ + $(INCDIR)\idn\converter.h \ + $(INCDIR)\idn\debug.h \ + $(INCDIR)\idn\delimitermap.h \ + $(INCDIR)\idn\export.h \ + $(INCDIR)\idn\filechecker.h \ + $(INCDIR)\idn\filemapper.h \ + $(INCDIR)\idn\localencoding.h \ + $(INCDIR)\idn\log.h \ + $(INCDIR)\idn\logmacro.h \ + $(INCDIR)\idn\mapper.h \ + $(INCDIR)\idn\mapselector.h \ + $(INCDIR)\idn\nameprep.h \ + $(INCDIR)\idn\normalizer.h \ + $(INCDIR)\idn\punycode.h \ + $(INCDIR)\idn\race.h \ + $(INCDIR)\idn\res.h \ + $(INCDIR)\idn\resconf.h \ + $(INCDIR)\idn\result.h \ + $(INCDIR)\idn\strhash.h \ + $(INCDIR)\idn\ucs4.h \ + $(INCDIR)\idn\ucsmap.h \ + $(INCDIR)\idn\ucsset.h \ + $(INCDIR)\idn\unicode.h \ + $(INCDIR)\idn\unormalize.h \ + $(INCDIR)\idn\utf8.h \ + $(INCDIR)\idn\util.h \ + $(INCDIR)\idn\version.h + +HDRS = $(ICONVDIR)\iconv.h \ + $(HDRS_LITE) + +SRCS = aliaslist.c api.c checker.c \ + converter.c debug.c delimitermap.c \ + filechecker.c filemapper.c \ + localencoding.c log.c mapper.c \ + mapselector.c nameprep.c nameprep_template.c \ + nameprepdata.c normalizer.c punycode.c race.c \ + res.c resconf.c result.c \ + strhash.c ucs4.c ucsmap.c \ + ucsset.c unicode.c unicode_template.c \ + unicodedata_320.c unormalize.c \ + utf8.c util.c version.c + +OBJS = aliaslist.obj api.obj checker.obj \ + converter.obj debug.obj delimitermap.obj \ + filechecker.obj filemapper.obj \ + localencoding.obj log.obj mapper.obj \ + mapselector.obj nameprep.obj \ + normalizer.obj punycode.obj race.obj \ + res.obj resconf.obj result.obj \ + strhash.obj ucs4.obj ucsmap.obj \ + ucsset.obj unicode.obj \ + unormalize.obj \ + utf8.obj util.obj version.obj + +OBJS_LITE = \ + aliaslist_l.obj api_l.obj checker_l.obj \ + converter_l.obj debug_l.obj delimitermap_l.obj \ + filechecker_l.obj filemapper_l.obj \ + localencoding_l.obj log_l.obj mapper_l.obj \ + mapselector_l.obj nameprep_l.obj \ + normalizer_l.obj punycode_l.obj race_l.obj \ + res_l.obj resconf_l.obj result_l.obj \ + strhash_l.obj ucs4_l.obj ucsmap_l.obj \ + ucsset_l.obj unicode_l.obj \ + unormalize_l.obj \ + utf8_l.obj util_l.obj version_l.obj + + +#DBG = -DDEBUG + +# +# Target to build +# + +TARGETS = idnkit.dll idnkitlite.dll + +all: $(TARGETS) + +idnkit.dll: $(OBJS) + -del idnkit.dll + $(link) /out:"idnkit.dll" /implib:"idnkit.lib" $(dlllflags) $(OBJS) $(LIBS) $(SYSLIBS) + +idnkitlite.dll: $(OBJS_LITE) + -del idnkitlite.dll + $(link) /out:"idnkitlite.dll" /implib:"idnkitlite.lib" $(dlllflags) $(OBJS_LITE) $(LIBS_LITE) $(SYSLIBS) + +install: + +clean: + -del *.obj + -del *.lib + -del *.dll + -del *.exp + +# +# Dependencies +# + +EXP = -DIDN_EXPORT="extern __declspec(dllexport)" +CCARGS = $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) $(EXP) $(DBG) +CCARGS_LITE = $(cflags) $(cvarsdll) -I$(INCDIR) -DWITHOUT_ICONV $(EXP) $(DBG) + +aliaslist.obj: aliaslist.c $(HDRS) + $(cc) $(CCARGS) /Foaliaslist.obj aliaslist.c +api.obj: api.c $(HDRS) + $(cc) $(CCARGS) /Foapi.obj api.c +checker.obj: checker.c $(HDRS) + $(cc) $(CCARGS) /Fochecker.obj checker.c +converter.obj: converter.c $(HDRS) + $(cc) $(CCARGS) /Foconverter.obj converter.c +debug.obj: debug.c $(HDRS) + $(cc) $(CCARGS) /Fodebug.obj debug.c +delimitermap.obj: delimitermap.c $(HDRS) + $(cc) $(CCARGS) /Fodelimitermap.obj delimitermap.c +filechecker.obj: filechecker.c $(HDRS) + $(cc) $(CCARGS) /Fofilechecker.obj filechecker.c +filemapper.obj: filemapper.c $(HDRS) + $(cc) $(CCARGS) /Fofilemapper.obj filemapper.c +localencoding.obj: localencoding.c $(HDRS) + $(cc) $(CCARGS) /Folocalencoding.obj localencoding.c +log.obj: log.c $(HDRS) + $(cc) $(CCARGS) /Folog.obj log.c +mapper.obj: mapper.c $(HDRS) + $(cc) $(CCARGS) /Fomapper.obj mapper.c +mapselector.obj: mapselector.c $(HDRS) + $(cc) $(CCARGS) /Fomapselector.obj mapselector.c +nameprep.obj: nameprep.c nameprepdata.c nameprep_template.c $(HDRS) + $(cc) $(CCARGS) /Fonameprep.obj nameprep.c +normalizer.obj: normalizer.c $(HDRS) + $(cc) $(CCARGS) /Fonormalizer.obj normalizer.c +punycode.obj: punycode.c $(HDRS) + $(cc) $(CCARGS) /Fopunycode.obj punycode.c +race.obj: race.c $(HDRS) + $(cc) $(CCARGS) /Forace.obj race.c +res.obj: res.c $(HDRS) + $(cc) $(CCARGS) /Fores.obj res.c +resconf.obj: resconf.c $(HDRS) + $(cc) $(CCARGS) /Foresconf.obj resconf.c +result.obj: result.c $(HDRS) + $(cc) $(CCARGS) /Foresult.obj result.c +strhash.obj: strhash.c $(HDRS) + $(cc) $(CCARGS) /Fostrhash.obj strhash.c +ucs4.obj: ucs4.c $(HDRS) + $(cc) $(CCARGS) /Foucs4.obj ucs4.c +ucsmap.obj: ucsmap.c $(HDRS) + $(cc) $(CCARGS) /Foucsmap.obj ucsmap.c +ucsset.obj: ucsset.c $(HDRS) + $(cc) $(CCARGS) /Foucsset.obj ucsset.c +unicode.obj: unicode.c unicodedata_320.c unicode_template.c $(HDRS) + $(cc) $(CCARGS) /Founicode.obj unicode.c +unormalize.obj: unormalize.c $(HDRS) + $(cc) $(CCARGS) /Founormalize.obj unormalize.c +utf8.obj: utf8.c $(HDRS) + $(cc) $(CCARGS) /Foutf8.obj utf8.c +util.obj: util.c $(HDRS) + $(cc) $(CCARGS) /Foutil.obj util.c +version.obj: version.c $(HDRS) + $(cc) $(CCARGS) /Foversion.obj version.c + +aliaslist_l.obj: aliaslist.c $(HDRS_LITE) + $(cc) $(CCARGS_LITE) /Foaliaslist_l.obj aliaslist.c +api_l.obj: api.c $(HDRS_LITE) + $(cc) $(CCARGS_LITE) /Foapi_l.obj api.c +checker_l.obj: checker.c $(HDRS_LITE) + $(cc) $(CCARGS_LITE) /Fochecker_l.obj checker.c +converter_l.obj: converter.c $(HDRS_LITE) + $(cc) $(CCARGS_LITE) /Foconverter_l.obj converter.c +debug_l.obj: debug.c $(HDRS_LITE) + $(cc) $(CCARGS_LITE) /Fodebug_l.obj debug.c +delimitermap_l.obj: delimitermap.c $(HDRS_LITE) + $(cc) $(CCARGS_LITE) /Fodelimitermap_l.obj delimitermap.c +dude_l.obj: dude.c $(HDRS_LITE) + $(cc) $(CCARGS_LITE) /Fodude_l.obj dude.c +filechecker_l.obj: filechecker.c $(HDRS_LITE) + $(cc) $(CCARGS_LITE) /Fofilechecker_l.obj filechecker.c +filemapper_l.obj: filemapper.c $(HDRS_LITE) + $(cc) $(CCARGS_LITE) /Fofilemapper_l.obj filemapper.c +localencoding_l.obj: localencoding.c $(HDRS_LITE) + $(cc) $(CCARGS_LITE) /Folocalencoding_l.obj localencoding.c +log_l.obj: log.c $(HDRS_LITE) + $(cc) $(CCARGS_LITE) /Folog_l.obj log.c +mapper_l.obj: mapper.c $(HDRS_LITE) + $(cc) $(CCARGS_LITE) /Fomapper_l.obj mapper.c +mapselector_l.obj: mapselector.c $(HDRS_LITE) + $(cc) $(CCARGS_LITE) /Fomapselector_l.obj mapselector.c +nameprep_l.obj: nameprep.c nameprepdata.c nameprep_template.c $(HDRS_LITE) + $(cc) $(CCARGS_LITE) /Fonameprep_l.obj nameprep.c +normalizer_l.obj: normalizer.c $(HDRS_LITE) + $(cc) $(CCARGS_LITE) /Fonormalizer_l.obj normalizer.c +punycode_l.obj: punycode.c $(HDRS_LITE) + $(cc) $(CCARGS_LITE) /Fopunycode_l.obj punycode.c +race_l.obj: race.c $(HDRS_LITE) + $(cc) $(CCARGS_LITE) /Forace_l.obj race.c +res_l.obj: res.c $(HDRS_LITE) + $(cc) $(CCARGS_LITE) /Fores_l.obj res.c +resconf_l.obj: resconf.c $(HDRS_LITE) + $(cc) $(CCARGS_LITE) /Foresconf_l.obj resconf.c +result_l.obj: result.c $(HDRS_LITE) + $(cc) $(CCARGS_LITE) /Foresult_l.obj result.c +strhash_l.obj: strhash.c $(HDRS_LITE) + $(cc) $(CCARGS_LITE) /Fostrhash_l.obj strhash.c +ucs4_l.obj: ucs4.c $(HDRS_LITE) + $(cc) $(CCARGS_LITE) /Foucs4_l.obj ucs4.c +ucsmap_l.obj: ucsmap.c $(HDRS_LITE) + $(cc) $(CCARGS_LITE) /Foucsmap_l.obj ucsmap.c +ucsset_l.obj: ucsset.c $(HDRS_LITE) + $(cc) $(CCARGS_LITE) /Foucsset_l.obj ucsset.c +unicode_l.obj: unicode.c unicodedata_320.c unicode_template.c $(HDRS_LITE) + $(cc) $(CCARGS_LITE) /Founicode_l.obj unicode.c +unormalize_l.obj: unormalize.c $(HDRS_LITE) + $(cc) $(CCARGS_LITE) /Founormalize_l.obj unormalize.c +utf8_l.obj: utf8.c $(HDRS_LITE) + $(cc) $(CCARGS_LITE) /Foutf8_l.obj utf8.c +util_l.obj: util.c $(HDRS_LITE) + $(cc) $(CCARGS_LITE) /Foutil_l.obj util.c +version_l.obj: version.c $(HDRS_LITE) + $(cc) $(CCARGS_LITE) /Foversion_l.obj version.c diff --git a/contrib/idn/idnkit-1.0-src/lib/mapper.c b/contrib/idn/idnkit-1.0-src/lib/mapper.c new file mode 100644 index 0000000..008f027 --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/mapper.c @@ -0,0 +1,482 @@ +#ifndef lint +static char *rcsid = "$Id: mapper.c,v 1.1.1.1 2003/06/04 00:25:55 marka Exp $"; +#endif + +/* + * Copyright (c) 2001,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 <config.h> + +#include <stddef.h> +#include <stdlib.h> +#include <string.h> + +#include <idn/result.h> +#include <idn/assert.h> +#include <idn/logmacro.h> +#include <idn/mapper.h> +#include <idn/strhash.h> +#include <idn/debug.h> +#include <idn/util.h> +#include <idn/ucs4.h> + +/* + * Type for mapping scheme. + */ +typedef struct { + char *prefix; + char *parameter; + idn_mapper_createproc_t create; + idn_mapper_destroyproc_t destroy; + idn_mapper_mapproc_t map; + void *context; +} map_scheme_t; + +/* + * Standard mapping schemes. + */ +static const map_scheme_t nameprep_scheme = { + "RFC3491", + NULL, + idn_nameprep_createproc, + idn_nameprep_destroyproc, + idn_nameprep_mapproc, + NULL, +}; + +static const map_scheme_t filemap_scheme = { + "filemap", + "", + idn__filemapper_createproc, + idn__filemapper_destroyproc, + idn__filemapper_mapproc, + NULL, +}; + +static const map_scheme_t *standard_map_schemes[] = { + &nameprep_scheme, + &filemap_scheme, + NULL, +}; + +/* + * Hash table for mapping schemes. + */ +static idn__strhash_t scheme_hash = NULL; + +/* + * Mapper object type. + */ +struct idn_mapper { + int nschemes; + int scheme_size; + map_scheme_t *schemes; + int reference_count; +}; + +#define MAPPER_INITIAL_SCHEME_SIZE 1 + +idn_result_t +idn_mapper_initialize(void) { + idn_result_t r; + map_scheme_t **scheme; + + TRACE(("idn_mapper_initialize()\n")); + + if (scheme_hash != NULL) { + r = idn_success; /* already initialized */ + goto ret; + } + + r = idn__strhash_create(&scheme_hash); + if (r != idn_success) + goto ret; + + for (scheme = (map_scheme_t **)standard_map_schemes; + *scheme != NULL; scheme++) { + r = idn__strhash_put(scheme_hash, (*scheme)->prefix, *scheme); + if (r != idn_success) + goto ret; + } + + r = idn_success; +ret: + if (r != idn_success && scheme_hash != NULL) { + idn__strhash_destroy(scheme_hash, NULL); + scheme_hash = NULL; + } + TRACE(("idn_mapper_initialize(): %s\n", idn_result_tostring(r))); + return (r); +} + +idn_result_t +idn_mapper_create(idn_mapper_t *ctxp) { + idn_mapper_t ctx = NULL; + idn_result_t r; + + assert(scheme_hash != NULL); + assert(ctxp != NULL); + + TRACE(("idn_mapper_create()\n")); + + ctx = (idn_mapper_t) malloc(sizeof(struct idn_mapper)); + if (ctx == NULL) { + r = idn_nomemory; + goto ret; + } + + ctx->schemes = (map_scheme_t *) malloc(sizeof(map_scheme_t) + * MAPPER_INITIAL_SCHEME_SIZE); + if (ctx->schemes == NULL) { + r = idn_nomemory; + goto ret; + } + + ctx->nschemes = 0; + ctx->scheme_size = MAPPER_INITIAL_SCHEME_SIZE; + ctx->reference_count = 1; + *ctxp = ctx; + r = idn_success; + +ret: + if (r != idn_success) { + if (ctx != NULL) + free(ctx->schemes); + free(ctx); + } + TRACE(("idn_mapper_create(): %s\n", idn_result_tostring(r))); + return (r); +} + +void +idn_mapper_destroy(idn_mapper_t ctx) { + int i; + + assert(scheme_hash != NULL); + assert(ctx != NULL); + + TRACE(("idn_mapper_destroy()\n")); + + ctx->reference_count--; + if (ctx->reference_count <= 0) { + TRACE(("idn_mapper_destroy(): the object is destroyed\n")); + for (i = 0; i < ctx->nschemes; i++) + ctx->schemes[i].destroy(ctx->schemes[i].context); + free(ctx->schemes); + free(ctx); + } else { + TRACE(("idn_mapper_destroy(): " + "update reference count (%d->%d)\n", + ctx->reference_count + 1, ctx->reference_count)); + } +} + +void +idn_mapper_incrref(idn_mapper_t ctx) { + assert(ctx != NULL && scheme_hash != NULL); + + TRACE(("idn_mapper_incrref()\n")); + TRACE(("idn_mapper_incrref: update reference count (%d->%d)\n", + ctx->reference_count, ctx->reference_count + 1)); + + ctx->reference_count++; +} + +idn_result_t +idn_mapper_add(idn_mapper_t ctx, const char *scheme_name) { + idn_result_t r; + map_scheme_t *scheme; + const char *scheme_prefix; + const char *scheme_parameter; + void *scheme_context = NULL; + char static_buffer[128]; /* large enough */ + char *buffer = static_buffer; + + assert(scheme_hash != NULL); + assert(ctx != NULL); + + TRACE(("idn_mapper_add(scheme_name=%s)\n", + idn__debug_xstring(scheme_name, 50))); + + /* + * Split `scheme_name' into `scheme_prefix' and `scheme_parameter'. + */ + scheme_parameter = strchr(scheme_name, ':'); + if (scheme_parameter == NULL) { + scheme_prefix = scheme_name; + } else { + ptrdiff_t scheme_prefixlen; + + scheme_prefixlen = scheme_parameter - scheme_name; + if (scheme_prefixlen + 1 > sizeof(static_buffer)) { + buffer = (char *) malloc(scheme_prefixlen + 1); + if (buffer == NULL) { + r = idn_nomemory; + goto ret; + } + } + memcpy(buffer, scheme_name, scheme_prefixlen); + *(buffer + scheme_prefixlen) = '\0'; + scheme_prefix = buffer; + scheme_parameter++; + } + + /* + * Find a scheme. + */ + if (idn__strhash_get(scheme_hash, scheme_prefix, (void **)&scheme) + != idn_success) { + ERROR(("idn_mapper_add(): invalid scheme name \"%-.30s\"\n", + scheme_prefix)); + r = idn_invalid_name; + goto ret; + } + if (scheme_parameter == NULL) { + if (scheme->parameter != NULL) + scheme_parameter = scheme->parameter; + else + scheme_parameter = scheme->prefix; + } + + /* + * Add the scheme. + */ + assert(ctx->nschemes <= ctx->scheme_size); + + if (ctx->nschemes == ctx->scheme_size) { + map_scheme_t *new_schemes; + + new_schemes = (map_scheme_t *) realloc(ctx->schemes, + sizeof(map_scheme_t) * ctx->scheme_size * 2); + if (new_schemes == NULL) { + r = idn_nomemory; + goto ret; + } + ctx->schemes = new_schemes; + ctx->scheme_size *= 2; + } + + r = scheme->create(scheme_parameter, &scheme_context); + if (r != idn_success) + goto ret; + + memcpy(ctx->schemes + ctx->nschemes, scheme, sizeof(map_scheme_t)); + ctx->schemes[ctx->nschemes].context = scheme_context; + ctx->nschemes++; + r = idn_success; +ret: + if (r != idn_success) + free(scheme_context); + if (buffer != static_buffer) + free(buffer); + TRACE(("idn_mapper_add(): %s\n", idn_result_tostring(r))); + return (r); +} + +idn_result_t +idn_mapper_addall(idn_mapper_t ctx, const char **scheme_names, int nschemes) { + idn_result_t r; + int i; + + assert(scheme_hash != NULL); + assert(ctx != NULL && scheme_names != NULL); + + TRACE(("idn_mapper_addall(nschemes=%d)\n", nschemes)); + + for (i = 0; i < nschemes; i++) { + r = idn_mapper_add(ctx, (const char *)*scheme_names); + if (r != idn_success) + goto ret; + scheme_names++; + } + + r = idn_success; +ret: + TRACE(("idn_mapper_addall(): %s\n", idn_result_tostring(r))); + return (r); +} + +idn_result_t +idn_mapper_map(idn_mapper_t ctx, const unsigned long *from, + unsigned long *to, size_t tolen) { + idn_result_t r; + unsigned long *src, *dst; + unsigned long *buffers[2] = {NULL, NULL}; + size_t buflen[2] = {0, 0}; + size_t dstlen; + int idx; + int i; + + assert(scheme_hash != NULL); + assert(ctx != NULL && from != NULL && to != NULL); + + TRACE(("idn_mapper_map(from=\"%s\", tolen=%d)\n", + idn__debug_ucs4xstring(from, 50), (int)tolen)); + + if (ctx->nschemes <= 0) { + if (tolen < idn_ucs4_strlen(from) + 1) { + r = idn_buffer_overflow; + goto ret; + } + idn_ucs4_strcpy(to, from); + r = idn_success; + goto ret; + } + + /* + * Map. + */ + src = (void *)from; + dstlen = idn_ucs4_strlen(from) + 1; + + i = 0; + while (i < ctx->nschemes) { + TRACE(("idn_mapper_map(): map %s\n", ctx->schemes[i].prefix)); + + /* + * Choose destination area to restore the result of a mapping. + */ + if (i + 1 == ctx->nschemes) { + dst = to; + dstlen = tolen; + + } else { + if (src == buffers[0]) + idx = 1; + else + idx = 0; + + if (buflen[idx] < dstlen) { + void *newbuf; + + newbuf = realloc(buffers[idx], + sizeof(long) * dstlen); + if (newbuf == NULL) { + r = idn_nomemory; + goto ret; + } + buffers[idx] = (unsigned long *)newbuf; + buflen[idx] = dstlen; + } + + dst = buffers[idx]; + dstlen = buflen[idx]; + } + + /* + * Perform i-th map scheme. + * If buffer size is not enough, we double it and try again. + */ + r = (ctx->schemes[i].map)(ctx->schemes[i].context, src, dst, + dstlen); + if (r == idn_buffer_overflow && dst != to) { + dstlen *= 2; + continue; + } + if (r != idn_success) + goto ret; + + src = dst; + i++; + } + + r = idn_success; +ret: + free(buffers[0]); + free(buffers[1]); + if (r == idn_success) { + TRACE(("idn_mapper_map(): success (to=\"%s\")\n", + idn__debug_ucs4xstring(to, 50))); + } else { + TRACE(("idn_mapper_map(): %s\n", idn_result_tostring(r))); + } + return (r); +} + +idn_result_t +idn_mapper_register(const char *prefix, + idn_mapper_createproc_t create, + idn_mapper_destroyproc_t destroy, + idn_mapper_mapproc_t map) { + idn_result_t r; + map_scheme_t *scheme = NULL; + + assert(scheme_hash != NULL); + assert(prefix != NULL && create != NULL && destroy != NULL && + map != NULL); + + TRACE(("idn_mapper_register(prefix=%s)\n", prefix)); + + scheme = (map_scheme_t *) malloc(sizeof(map_scheme_t)); + if (scheme == NULL) { + r = idn_nomemory; + goto ret; + } + + scheme->prefix = (char *) malloc(strlen(prefix) + 1); + if (scheme->prefix == NULL) { + r = idn_nomemory; + goto ret; + } + + strcpy(scheme->prefix, prefix); + scheme->parameter = NULL; + scheme->create = create; + scheme->destroy = destroy; + scheme->map = map; + + r = idn__strhash_put(scheme_hash, prefix, scheme); + if (r != idn_success) + goto ret; + + r = idn_success; +ret: + if (r != idn_success) { + if (scheme != NULL) + free(scheme->prefix); + free(scheme); + } + + TRACE(("idn_mapper_register(): %s\n", idn_result_tostring(r))); + return (r); +} diff --git a/contrib/idn/idnkit-1.0-src/lib/mapselector.c b/contrib/idn/idnkit-1.0-src/lib/mapselector.c new file mode 100644 index 0000000..0101b98 --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/mapselector.c @@ -0,0 +1,375 @@ +#ifndef lint +static char *rcsid = "$Id: mapselector.c,v 1.1.1.1 2003/06/04 00:25:56 marka Exp $"; +#endif + +/* + * Copyright (c) 2001,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 <config.h> + +#include <stddef.h> +#include <stdlib.h> +#include <string.h> + +#include <idn/assert.h> +#include <idn/logmacro.h> +#include <idn/result.h> +#include <idn/mapselector.h> +#include <idn/strhash.h> +#include <idn/debug.h> +#include <idn/util.h> +#include <idn/ucs4.h> + +struct idn_mapselector { + idn__strhash_t maphash; + int reference_count; +}; + +/* + * Maximum length of a top level domain name. (e.g. `com', `jp', ...) + */ +#define MAPSELECTOR_MAX_TLD_LENGTH 63 + +static void string_ascii_tolower(char *string); + + +const unsigned long * +idn_mapselector_getnotld(void) { + static const unsigned long notld[] = {0x002d, 0x0000}; /* "-" */ + return (notld); +} + +const unsigned long * +idn_mapselector_getdefaulttld(void) { + const static unsigned long defaulttld[] = {0x002e, 0x0000}; /* "." */ + return (defaulttld); +} + +idn_result_t +idn_mapselector_initialize(void) { + idn_result_t r; + + TRACE(("idn_mapselector_initialize()\n")); + + r = idn_mapper_initialize(); + + TRACE(("idn_mapselector_initialize(): %s\n", idn_result_tostring(r))); + return (r); +} + +idn_result_t +idn_mapselector_create(idn_mapselector_t *ctxp) { + idn_mapselector_t ctx = NULL; + idn_result_t r; + + assert(ctxp != NULL); + TRACE(("idn_mapselector_create()\n")); + + ctx = (idn_mapselector_t)malloc(sizeof(struct idn_mapselector)); + if (ctx == NULL) { + r = idn_nomemory; + goto ret; + } + + ctx->maphash = NULL; + ctx->reference_count = 1; + + r = idn__strhash_create(&(ctx->maphash)); + if (r != idn_success) + goto ret; + + *ctxp = ctx; + r = idn_success; + +ret: + if (r != idn_success) { + if (ctx != NULL) + free(ctx->maphash); + free(ctx); + } + TRACE(("idn_mapselector_create(): %s\n", idn_result_tostring(r))); + return (r); +} + +void +idn_mapselector_destroy(idn_mapselector_t ctx) { + assert(ctx != NULL); + + TRACE(("idn_mapselector_destroy()\n")); + + ctx->reference_count--; + if (ctx->reference_count <= 0) { + TRACE(("idn_mapselector_destroy(): " + "the object is destroyed\n")); + idn__strhash_destroy(ctx->maphash, + (idn__strhash_freeproc_t)&idn_mapper_destroy); + free(ctx); + } else { + TRACE(("idn_mapselector_destroy(): " + "update reference count (%d->%d)\n", + ctx->reference_count + 1, ctx->reference_count)); + } +} + +void +idn_mapselector_incrref(idn_mapselector_t ctx) { + assert(ctx != NULL); + + TRACE(("idn_mapselector_incrref()\n")); + TRACE(("idn_mapselector_incrref: update reference count (%d->%d)\n", + ctx->reference_count, ctx->reference_count + 1)); + + ctx->reference_count++; +} + +idn_result_t +idn_mapselector_add(idn_mapselector_t ctx, const char *tld, const char *name) { + idn_result_t r; + idn_mapper_t mapper; + char hash_key[MAPSELECTOR_MAX_TLD_LENGTH + 1]; + + assert(ctx != NULL && tld != NULL); + + TRACE(("idn_mapselector_add(tld=%s, name=%s)\n", tld, name)); + + if (!(tld[0] == '.' && tld[1] == '\0')) { + if (tld[0] == '.') + tld++; + if (strchr(tld, '.') != NULL) { + ERROR(("idn_mapselector_add: " + "invalid TLD \"%-.100s\"\n", tld)); + r = idn_invalid_name; + goto ret; + } + } + if (strlen(tld) > MAPSELECTOR_MAX_TLD_LENGTH) { + ERROR(("idn_mapselector_add: " + "too long TLD \"%-.100s\"\n", tld)); + r = idn_invalid_name; + goto ret; + } + strcpy(hash_key, tld); + string_ascii_tolower(hash_key); + + if (idn__strhash_get(ctx->maphash, hash_key, (void **)&mapper) + != idn_success) { + r = idn_mapper_create(&mapper); + if (r != idn_success) + goto ret; + + r = idn__strhash_put(ctx->maphash, hash_key, mapper); + if (r != idn_success) + goto ret; + } + + r = idn_mapper_add(mapper, name); +ret: + TRACE(("idn_mapselector_add(): %s\n", idn_result_tostring(r))); + return (r); +} + +idn_result_t +idn_mapselector_addall(idn_mapselector_t ctx, const char *tld, + const char **scheme_names, int nschemes) { + idn_result_t r; + int i; + + assert(ctx != NULL && tld != NULL && scheme_names != NULL); + + TRACE(("idn_mapselector_addall(tld=%s, nschemes=%d)\n", + tld, nschemes)); + + for (i = 0; i < nschemes; i++) { + r = idn_mapselector_add(ctx, tld, (const char *)*scheme_names); + if (r != idn_success) + goto ret; + scheme_names++; + } + + r = idn_success; +ret: + TRACE(("idn_mapselector_addall(): %s\n", idn_result_tostring(r))); + return (r); +} + +idn_mapper_t +idn_mapselector_mapper(idn_mapselector_t ctx, const char *tld) { + idn_result_t r; + idn_mapper_t mapper; + char hash_key[MAPSELECTOR_MAX_TLD_LENGTH + 1]; + + assert(ctx != NULL && tld != NULL); + + TRACE(("idn_mapselector_mapper(tld=%s)\n", tld)); + + if (!(tld[0] == '.' && tld[1] == '\0')) { + if (tld[0] == '.') + tld++; + if (strchr(tld, '.') != NULL) + return (NULL); + } + if (strlen(tld) > MAPSELECTOR_MAX_TLD_LENGTH) + return (NULL); + strcpy(hash_key, tld); + string_ascii_tolower(hash_key); + + mapper = NULL; + r = idn__strhash_get(ctx->maphash, hash_key, (void **)&mapper); + if (r != idn_success) + return (NULL); + + idn_mapper_incrref(mapper); + + return (mapper); +} + +idn_result_t +idn_mapselector_map(idn_mapselector_t ctx, const unsigned long *from, + const char *tld, unsigned long *to, size_t tolen) { + idn_result_t r; + idn_mapper_t mapper = NULL; + char hash_key[MAPSELECTOR_MAX_TLD_LENGTH + 1]; + size_t fromlen; + + assert(ctx != NULL && from != NULL && to != NULL); + + TRACE(("idn_mapselector_map(from=\"%s\", tld=\"%s\", tolen=%d)\n", + idn__debug_ucs4xstring(from, 50), idn__debug_xstring(tld, 50), + (int)tolen)); + + if (!(tld[0] == '.' && tld[1] == '\0')) { + if (tld[0] == '.') + tld++; + if (strchr(tld, '.') != NULL) { + r = idn_invalid_name; + goto ret; + } + } + if (strlen(tld) > MAPSELECTOR_MAX_TLD_LENGTH) { + r = idn_invalid_name; + goto ret; + } + strcpy(hash_key, tld); + string_ascii_tolower(hash_key); + + fromlen = idn_ucs4_strlen(from); + + /* + * Get mapper for the TLD. + */ + if (idn__strhash_get(ctx->maphash, hash_key, (void **)&mapper) + != idn_success) { + strcpy(hash_key, IDN_MAPSELECTOR_DEFAULTTLD); + idn__strhash_get(ctx->maphash, hash_key, (void **)&mapper); + } + + /* + * Map. + * If default mapper has not been registered, copy the string. + */ + if (mapper == NULL) { + TRACE(("idn_mapselector_map(): no mapper\n")); + if (fromlen + 1 > tolen) { + r = idn_buffer_overflow; + goto ret; + } + memcpy(to, from, (fromlen + 1) * sizeof(*from)); + } else { + TRACE(("idn_mapselector_map(): tld=%s\n", tld)); + r = idn_mapper_map(mapper, from, to, tolen); + if (r != idn_success) + goto ret; + } + + r = idn_success; +ret: + if (r == idn_success) { + TRACE(("idn_mapselector_map(): succcess (to=\"%s\")\n", + idn__debug_ucs4xstring(to, 50))); + } else { + TRACE(("idn_mapselector_map(): %s\n", idn_result_tostring(r))); + } + return (r); +} + +idn_result_t +idn_mapselector_map2(idn_mapselector_t ctx, const unsigned long *from, + const unsigned long *tld, unsigned long *to, + size_t tolen) { + char tld_utf8[MAPSELECTOR_MAX_TLD_LENGTH + 1]; + idn_result_t r; + + assert(ctx != NULL && from != NULL && to != NULL); + + TRACE(("idn_mapselector_map2(from=\"%s\", tld=\"%s\")\n", + idn__debug_ucs4xstring(from, 50), + idn__debug_ucs4xstring(tld, 50))); + + r = idn_ucs4_ucs4toutf8(tld, tld_utf8, sizeof(tld_utf8)); + if (r == idn_buffer_overflow) { + r = idn_invalid_name; + goto ret; + } else if (r != idn_success) { + goto ret; + } + + r = idn_mapselector_map(ctx, from, tld_utf8, to, tolen); +ret: + if (r == idn_success) { + TRACE(("idn_mapselector_map2(): success (to=\"%s\")\n", + idn__debug_ucs4xstring(to, 50))); + } else { + TRACE(("idn_mapselector_map2(): %s\n", idn_result_tostring(r))); + } + return (r); +} + +static void +string_ascii_tolower(char *string) { + unsigned char *p; + + for (p = (unsigned char *) string; *p != '\0'; p++) { + if ('A' <= *p && *p <= 'Z') + *p = *p - 'A' + 'a'; + } +} diff --git a/contrib/idn/idnkit-1.0-src/lib/nameprep.c b/contrib/idn/idnkit-1.0-src/lib/nameprep.c new file mode 100644 index 0000000..bf08a0d --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/nameprep.c @@ -0,0 +1,357 @@ +#ifndef lint +static char *rcsid = "$Id: nameprep.c,v 1.1.1.1 2003/06/04 00:25:56 marka Exp $"; +#endif + +/* + * Copyright (c) 2001,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 <config.h> + +#include <stdlib.h> +#include <string.h> + +#include <idn/result.h> +#include <idn/assert.h> +#include <idn/log.h> +#include <idn/logmacro.h> +#include <idn/debug.h> +#include <idn/nameprep.h> + +#define UCS_MAX 0x7fffffff +#define UNICODE_MAX 0x10ffff + + +/* + * Load NAMEPREP compiled tables. + */ +#include "nameprepdata.c" + +/* + * Define mapping/checking functions for each version of the draft. + */ + +#define VERSION rfc3491 +#include "nameprep_template.c" +#undef VERSION + +typedef const char *(*nameprep_mapproc)(unsigned long v); +typedef int (*nameprep_checkproc)(unsigned long v); +typedef idn_biditype_t (*nameprep_biditypeproc)(unsigned long v); + +static struct idn_nameprep { + char *version; + nameprep_mapproc map_proc; + nameprep_checkproc prohibited_proc; + nameprep_checkproc unassigned_proc; + nameprep_biditypeproc biditype_proc; +} nameprep_versions[] = { +#define MAKE_NAMEPREP_HANDLE(version, id) \ + { version, \ + compose_sym2(nameprep_map_, id), \ + compose_sym2(nameprep_prohibited_, id), \ + compose_sym2(nameprep_unassigned_, id), \ + compose_sym2(nameprep_biditype_, id), } + MAKE_NAMEPREP_HANDLE("RFC3491", rfc3491), + { NULL, NULL, NULL }, +}; + +static idn_result_t idn_nameprep_check(nameprep_checkproc proc, + const unsigned long *str, + const unsigned long **found); + +idn_result_t +idn_nameprep_create(const char *version, idn_nameprep_t *handlep) { + idn_nameprep_t handle; + + assert(handlep != NULL); + + TRACE(("idn_nameprep_create(version=%-.50s)\n", + version == NULL ? "<NULL>" : version)); + + if (version == NULL) + version = IDN_NAMEPREP_CURRENT; + + /* + * Lookup table for the specified version. Since the number of + * versions won't be large (I don't want see draft-23 or such :-), + * simple linear search is OK. + */ + for (handle = nameprep_versions; handle->version != NULL; handle++) { + if (strcmp(handle->version, version) == 0) { + *handlep = handle; + return (idn_success); + } + } + return (idn_notfound); +} + +void +idn_nameprep_destroy(idn_nameprep_t handle) { + assert(handle != NULL); + + TRACE(("idn_nameprep_destroy()\n")); + + /* Nothing to do. */ +} + +idn_result_t +idn_nameprep_map(idn_nameprep_t handle, const unsigned long *from, + unsigned long *to, size_t tolen) { + assert(handle != NULL && from != NULL && to != NULL); + + TRACE(("idn_nameprep_map(ctx=%s, from=\"%s\")\n", + handle->version, idn__debug_ucs4xstring(from, 50))); + + while (*from != '\0') { + unsigned long v = *from; + const char *mapped; + + if (v > UCS_MAX) { + /* This cannot happen, but just in case.. */ + return (idn_invalid_codepoint); + } else if (v > UNICODE_MAX) { + /* No mapping is possible. */ + mapped = NULL; + } else { + /* Try mapping. */ + mapped = (*handle->map_proc)(v); + } + + if (mapped == NULL) { + /* No mapping. Just copy verbatim. */ + if (tolen < 1) + return (idn_buffer_overflow); + *to++ = v; + tolen--; + } else { + const unsigned char *mappeddata; + size_t mappedlen; + + mappeddata = (const unsigned char *)mapped + 1; + mappedlen = *mapped; + + if (tolen < (mappedlen + 3) / 4) + return (idn_buffer_overflow); + tolen -= (mappedlen + 3) / 4; + while (mappedlen >= 4) { + *to = *mappeddata++; + *to |= *mappeddata++ << 8; + *to |= *mappeddata++ << 16; + *to |= *mappeddata++ << 24; + mappedlen -= 4; + to++; + } + if (mappedlen > 0) { + *to = *mappeddata++; + *to |= (mappedlen >= 2) ? + *mappeddata++ << 8: 0; + *to |= (mappedlen >= 3) ? + *mappeddata++ << 16: 0; + to++; + } + } + from++; + } + if (tolen == 0) + return (idn_buffer_overflow); + *to = '\0'; + return (idn_success); +} + +idn_result_t +idn_nameprep_isprohibited(idn_nameprep_t handle, const unsigned long *str, + const unsigned long **found) { + assert(handle != NULL && str != NULL && found != NULL); + + TRACE(("idn_nameprep_isprohibited(ctx=%s, str=\"%s\")\n", + handle->version, idn__debug_ucs4xstring(str, 50))); + + return (idn_nameprep_check(handle->prohibited_proc, str, found)); +} + +idn_result_t +idn_nameprep_isunassigned(idn_nameprep_t handle, const unsigned long *str, + const unsigned long **found) { + assert(handle != NULL && str != NULL && found != NULL); + + TRACE(("idn_nameprep_isunassigned(handle->version, str=\"%s\")\n", + handle->version, idn__debug_ucs4xstring(str, 50))); + + return (idn_nameprep_check(handle->unassigned_proc, str, found)); +} + +static idn_result_t +idn_nameprep_check(nameprep_checkproc proc, const unsigned long *str, + const unsigned long **found) { + unsigned long v; + + while (*str != '\0') { + v = *str; + + if (v > UCS_MAX) { + /* This cannot happen, but just in case.. */ + return (idn_invalid_codepoint); + } else if (v > UNICODE_MAX) { + /* It is invalid.. */ + *found = str; + return (idn_success); + } else if ((*proc)(v)) { + *found = str; + return (idn_success); + } + str++; + } + *found = NULL; + return (idn_success); +} + +idn_result_t +idn_nameprep_isvalidbidi(idn_nameprep_t handle, const unsigned long *str, + const unsigned long **found) { + unsigned long v; + idn_biditype_t first_char; + idn_biditype_t last_char; + int found_r_al; + + assert(handle != NULL && str != NULL && found != NULL); + + TRACE(("idn_nameprep_isvalidbidi(ctx=%s, str=\"%s\")\n", + handle->version, idn__debug_ucs4xstring(str, 50))); + + if (*str == '\0') { + *found = NULL; + return (idn_success); + } + + /* + * check first character's type and initialize variables. + */ + found_r_al = 0; + if (*str > UCS_MAX) { + /* This cannot happen, but just in case.. */ + return (idn_invalid_codepoint); + } else if (*str > UNICODE_MAX) { + /* It is invalid.. */ + *found = str; + return (idn_success); + } + first_char = last_char = (*(handle->biditype_proc))(*str); + if (first_char == idn_biditype_r_al) { + found_r_al = 1; + } + str++; + + /* + * see whether string is valid or not. + */ + while (*str != '\0') { + v = *str; + + if (v > UCS_MAX) { + /* This cannot happen, but just in case.. */ + return (idn_invalid_codepoint); + } else if (v > UNICODE_MAX) { + /* It is invalid.. */ + *found = str; + return (idn_success); + } else { + last_char = (*(handle->biditype_proc))(v); + if (found_r_al && last_char == idn_biditype_l) { + *found = str; + return (idn_success); + } + if (first_char != idn_biditype_r_al && last_char == idn_biditype_r_al) { + *found = str; + return (idn_success); + } + if (last_char == idn_biditype_r_al) { + found_r_al = 1; + } + } + str++; + } + + if (found_r_al) { + if (last_char != idn_biditype_r_al) { + *found = str - 1; + return (idn_success); + } + } + + *found = NULL; + return (idn_success); +} + +idn_result_t +idn_nameprep_createproc(const char *parameter, void **handlep) { + return idn_nameprep_create(parameter, (idn_nameprep_t *)handlep); +} + +void +idn_nameprep_destroyproc(void *handle) { + idn_nameprep_destroy((idn_nameprep_t)handle); +} + +idn_result_t +idn_nameprep_mapproc(void *handle, const unsigned long *from, + unsigned long *to, size_t tolen) { + return idn_nameprep_map((idn_nameprep_t)handle, from, to, tolen); +} + +idn_result_t +idn_nameprep_prohibitproc(void *handle, const unsigned long *str, + const unsigned long **found) { + return idn_nameprep_isprohibited((idn_nameprep_t)handle, str, found); +} + +idn_result_t +idn_nameprep_unassignedproc(void *handle, const unsigned long *str, + const unsigned long **found) { + return idn_nameprep_isunassigned((idn_nameprep_t)handle, str, found); +} + +idn_result_t +idn_nameprep_bidiproc(void *handle, const unsigned long *str, + const unsigned long **found) { + return idn_nameprep_isvalidbidi((idn_nameprep_t)handle, str, found); +} diff --git a/contrib/idn/idnkit-1.0-src/lib/nameprep_template.c b/contrib/idn/idnkit-1.0-src/lib/nameprep_template.c new file mode 100644 index 0000000..4003b16 --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/nameprep_template.c @@ -0,0 +1,137 @@ +/* $Id: nameprep_template.c,v 1.1.1.1 2003/06/04 00:25:57 marka Exp $ */ + +/* + * Copyright (c) 2001 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 this file once for each version of NAMEPREP. + * VERSION should be defined to appropriate value before inclusion. + */ + +#ifndef NAMEPREP_TEMPLATE_INIT +#define NAMEPREP_TEMPLATE_INIT + +/* Symbol composition. */ +#define compose_sym2(a, b) compose_sym2X(a, b) +#define compose_sym2X(a, b) a ## b +#define compose_sym3(a, b, c) compose_sym3X(a, b, c) +#define compose_sym3X(a, b, c) a ## b ## c + +/* Index calculation for multi-level index tables. */ +#define IDX0(type, v) IDX_0(v, BITS1(type), BITS2(type)) +#define IDX1(type, v) IDX_1(v, BITS1(type), BITS2(type)) +#define IDX2(type, v) IDX_2(v, BITS1(type), BITS2(type)) + +#define IDX_0(v, bits1, bits2) ((v) >> ((bits1) + (bits2))) +#define IDX_1(v, bits1, bits2) (((v) >> (bits2)) & ((1 << (bits1)) - 1)) +#define IDX_2(v, bits1, bits2) ((v) & ((1 << (bits2)) - 1)) + +#define BITS1(type) type ## _BITS_1 +#define BITS2(type) type ## _BITS_2 + +#endif /* NAMEPREP_TEMPLATE_INIT */ + +static const char * +compose_sym2(nameprep_map_, VERSION) (unsigned long v) { + int idx0 = IDX0(MAP, v); + int idx1 = IDX1(MAP, v); + int idx2 = IDX2(MAP, v); + int offset; + +#define IMAP compose_sym3(nameprep_, VERSION, _map_imap) +#define TABLE compose_sym3(nameprep_, VERSION, _map_table) +#define DATA compose_sym3(nameprep_, VERSION, _map_data) + offset = TABLE[IMAP[IMAP[idx0] + idx1]].tbl[idx2]; + if (offset == 0) + return (NULL); /* no mapping */ + return (const char *)(DATA + offset); +#undef IMAP +#undef TABLE +#undef DATA +} + +static int +compose_sym2(nameprep_prohibited_, VERSION) (unsigned long v) { + int idx0 = IDX0(PROH, v); + int idx1 = IDX1(PROH, v); + int idx2 = IDX2(PROH, v); + const unsigned char *bm; + +#define IMAP compose_sym3(nameprep_, VERSION, _prohibited_imap) +#define BITMAP compose_sym3(nameprep_, VERSION, _prohibited_bitmap) + bm = BITMAP[IMAP[IMAP[idx0] + idx1]].bm; + return (bm[idx2 / 8] & (1 << (idx2 % 8))); +#undef IMAP +#undef BITMAP +} + +static int +compose_sym2(nameprep_unassigned_, VERSION) (unsigned long v) { + int idx0 = IDX0(UNAS, v); + int idx1 = IDX1(UNAS, v); + int idx2 = IDX2(UNAS, v); + const unsigned char *bm; + +#define IMAP compose_sym3(nameprep_, VERSION, _unassigned_imap) +#define BITMAP compose_sym3(nameprep_, VERSION, _unassigned_bitmap) + bm = BITMAP[IMAP[IMAP[idx0] + idx1]].bm; + return (bm[idx2 / 8] & (1 << (idx2 % 8))); +#undef IMAP +#undef BITMAP +} + +static idn_biditype_t +compose_sym2(nameprep_biditype_, VERSION) (unsigned long v) { + int idx0 = IDX0(BIDI, v); + int idx1 = IDX1(BIDI, v); + int idx2 = IDX2(BIDI, v); + int offset; + +#define IMAP compose_sym3(nameprep_, VERSION, _bidi_imap) +#define TABLE compose_sym3(nameprep_, VERSION, _bidi_table) +#define DATA compose_sym3(nameprep_, VERSION, _bidi_data) + offset = TABLE[IMAP[IMAP[idx0] + idx1]].tbl[idx2]; + return DATA[offset]; +#undef IMAP +#undef TABLE +#undef DATA +} diff --git a/contrib/idn/idnkit-1.0-src/lib/nameprepdata.c b/contrib/idn/idnkit-1.0-src/lib/nameprepdata.c new file mode 100644 index 0000000..35adb05 --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/nameprepdata.c @@ -0,0 +1,2546 @@ +/* $Id: nameprepdata.c,v 1.1.1.1 2003/06/04 00:26:05 marka Exp $ */ +/* $-Id: generate_nameprep_data.pl,v 1.9 2002/11/29 09:08:13 ishisone Exp -$ */ +/* + * Do not edit this file! + * This file is generated from NAMEPREP specification. + */ + +#define MAP_BITS_0 9 +#define MAP_BITS_1 7 +#define MAP_BITS_2 5 + +#define PROH_BITS_0 7 +#define PROH_BITS_1 7 +#define PROH_BITS_2 7 + +#define UNAS_BITS_0 7 +#define UNAS_BITS_1 7 +#define UNAS_BITS_2 7 + +#define BIDI_BITS_0 9 +#define BIDI_BITS_1 7 +#define BIDI_BITS_2 5 + +static const unsigned short nameprep_rfc3491_map_imap[] = { + 272, 400, 528, 656, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 912, + 1040, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 1168, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 0, 0, 1, 0, 0, 2, 3, 0, + 4, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 0, 0, 0, 0, 0, 0, + 0, 0, 14, 15, 16, 17, 18, 19, + 20, 21, 0, 22, 23, 24, 25, 26, + 27, 28, 29, 0, 30, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 31, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, + 48, 0, 0, 49, 0, 50, 0, 0, + 51, 52, 53, 54, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 55, 56, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 57, 58, 59, 60, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 61, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 62, 0, 0, 0, 0, 0, 0, 63, + 0, 64, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 65, 66, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 67, 68, 69, 70, 71, 72, 73, 74, + 75, 76, 77, 78, 79, 67, 68, 69, + 70, 80, 81, 73, 74, 82, 83, 84, + 85, 86, 87, 88, 89, 90, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, +}; + +static const struct { + unsigned short tbl[32]; +} nameprep_rfc3491_map_table[] = { + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, + 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, + 44, 46, 48, 50, 52, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 54, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, + 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99, + 101, 0, 103, 105, 107, 109, 111, 113, 115, 117, + }}, + {{ + 123, 0, 126, 0, 129, 0, 132, 0, 135, 0, 138, + 0, 141, 0, 144, 0, 147, 0, 150, 0, 153, 0, + 156, 0, 159, 0, 162, 0, 165, 0, 168, 0, + }}, + {{ + 171, 0, 174, 0, 177, 0, 180, 0, 183, 0, 186, + 0, 189, 0, 192, 0, 195, 0, 202, 0, 205, 0, + 208, 0, 0, 211, 0, 214, 0, 217, 0, 220, + }}, + {{ + 0, 223, 0, 226, 0, 229, 0, 232, 0, 235, 241, + 0, 244, 0, 247, 0, 250, 0, 253, 0, 256, 0, + 259, 0, 262, 0, 265, 0, 268, 0, 271, 0, + }}, + {{ + 274, 0, 277, 0, 280, 0, 283, 0, 286, 0, 289, + 0, 292, 0, 295, 0, 298, 0, 301, 0, 304, 0, + 307, 0, 310, 312, 0, 315, 0, 318, 0, 38, + }}, + {{ + 0, 321, 324, 0, 327, 0, 330, 333, 0, 336, 339, + 342, 0, 0, 345, 348, 351, 354, 0, 357, 360, 0, + 363, 366, 369, 0, 0, 0, 372, 375, 0, 378, + }}, + {{ + 381, 0, 384, 0, 387, 0, 390, 393, 0, 396, 0, + 0, 399, 0, 402, 405, 0, 408, 411, 414, 0, 417, + 0, 420, 423, 0, 0, 0, 426, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 429, 429, 0, 432, 432, 0, 435, + 435, 0, 438, 0, 441, 0, 444, 0, 447, 0, 450, + 0, 453, 0, 456, 0, 459, 0, 0, 462, 0, + }}, + {{ + 465, 0, 468, 0, 471, 0, 474, 0, 477, 0, 480, + 0, 483, 0, 486, 0, 489, 496, 496, 0, 499, 0, + 502, 505, 508, 0, 511, 0, 514, 0, 517, 0, + }}, + {{ + 520, 0, 523, 0, 526, 0, 529, 0, 532, 0, 535, + 0, 538, 0, 541, 0, 544, 0, 547, 0, 550, 0, + 553, 0, 556, 0, 559, 0, 562, 0, 565, 0, + }}, + {{ + 568, 0, 571, 0, 574, 0, 577, 0, 580, 0, 583, + 0, 586, 0, 589, 0, 592, 0, 595, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 598, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 601, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 608, 0, 611, 614, 617, + 0, 620, 0, 623, 626, 629, 640, 643, 646, 649, 652, + 655, 658, 661, 598, 664, 667, 54, 670, 673, 676, + }}, + {{ + 679, 682, 0, 685, 688, 691, 694, 697, 700, 703, 706, + 709, 0, 0, 0, 0, 712, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 685, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 643, 661, 691, 623, 709, 694, + 679, 0, 723, 0, 726, 0, 729, 0, 732, 0, + }}, + {{ + 735, 0, 738, 0, 741, 0, 744, 0, 747, 0, 750, + 0, 753, 0, 756, 0, 664, 682, 685, 0, 661, 652, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 759, 762, 765, 768, 771, 774, 777, 780, 783, 786, 789, + 792, 795, 798, 801, 804, 807, 810, 813, 816, 819, 822, + 825, 828, 831, 834, 837, 840, 843, 846, 849, 852, + }}, + {{ + 855, 858, 861, 864, 867, 870, 873, 876, 879, 882, 885, + 888, 891, 894, 897, 900, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 903, 0, 906, 0, 909, 0, 912, 0, 915, 0, 918, + 0, 921, 0, 924, 0, 927, 0, 930, 0, 933, 0, + 936, 0, 939, 0, 942, 0, 945, 0, 948, 0, + }}, + {{ + 951, 0, 0, 0, 0, 0, 0, 0, 0, 0, 954, + 0, 957, 0, 960, 0, 963, 0, 966, 0, 969, 0, + 972, 0, 975, 0, 978, 0, 981, 0, 984, 0, + }}, + {{ + 987, 0, 990, 0, 993, 0, 996, 0, 999, 0, 1002, + 0, 1005, 0, 1008, 0, 1011, 0, 1014, 0, 1017, 0, + 1020, 0, 1023, 0, 1026, 0, 1029, 0, 1032, 0, + }}, + {{ + 0, 1035, 0, 1038, 0, 1041, 0, 1044, 0, 1047, 0, + 1050, 0, 1053, 0, 0, 1056, 0, 1059, 0, 1062, 0, + 1065, 0, 1068, 0, 1071, 0, 1074, 0, 1077, 0, + }}, + {{ + 1080, 0, 1083, 0, 1086, 0, 1089, 0, 1092, 0, 1095, + 0, 1098, 0, 1101, 0, 1104, 0, 1107, 0, 1110, 0, + 0, 0, 1113, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 1116, 0, 1119, 0, 1122, 0, 1125, 0, 1128, 0, 1131, + 0, 1134, 0, 1137, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1140, 1143, 1146, 1149, 1152, + 1155, 1158, 1161, 1164, 1167, 1170, 1173, 1176, 1179, 1182, + }}, + {{ + 1185, 1188, 1191, 1194, 1197, 1200, 1203, 1206, 1209, 1212, 1215, + 1218, 1221, 1224, 1227, 1230, 1233, 1236, 1239, 1242, 1245, 1248, + 1251, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 1254, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, + 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 1261, 0, 1264, 0, 1267, 0, 1270, 0, 1273, 0, 1276, + 0, 1279, 0, 1282, 0, 1285, 0, 1288, 0, 1291, 0, + 1294, 0, 1297, 0, 1300, 0, 1303, 0, 1306, 0, + }}, + {{ + 1309, 0, 1312, 0, 1315, 0, 1318, 0, 1321, 0, 1324, + 0, 1327, 0, 1330, 0, 1333, 0, 1336, 0, 1339, 0, + 1342, 0, 1345, 0, 1348, 0, 1351, 0, 1354, 0, + }}, + {{ + 1357, 0, 1360, 0, 1363, 0, 1366, 0, 1369, 0, 1372, + 0, 1375, 0, 1378, 0, 1381, 0, 1384, 0, 1387, 0, + 1390, 0, 1393, 0, 1396, 0, 1399, 0, 1402, 0, + }}, + {{ + 1405, 0, 1408, 0, 1411, 0, 1414, 0, 1417, 0, 1420, + 0, 1423, 0, 1426, 0, 1429, 0, 1432, 0, 1435, 0, + 1438, 0, 1441, 0, 1444, 0, 1447, 0, 1450, 0, + }}, + {{ + 1453, 0, 1456, 0, 1459, 0, 1462, 0, 1465, 0, 1468, + 0, 1471, 0, 1474, 0, 1477, 0, 1480, 0, 1483, 0, + 1486, 1493, 1500, 1507, 1514, 1405, 0, 0, 0, 0, + }}, + {{ + 1521, 0, 1524, 0, 1527, 0, 1530, 0, 1533, 0, 1536, + 0, 1539, 0, 1542, 0, 1545, 0, 1548, 0, 1551, 0, + 1554, 0, 1557, 0, 1560, 0, 1563, 0, 1566, 0, + }}, + {{ + 1569, 0, 1572, 0, 1575, 0, 1578, 0, 1581, 0, 1584, + 0, 1587, 0, 1590, 0, 1593, 0, 1596, 0, 1599, 0, + 1602, 0, 1605, 0, 1608, 0, 1611, 0, 1614, 0, + }}, + {{ + 1617, 0, 1620, 0, 1623, 0, 1626, 0, 1629, 0, 1632, + 0, 1635, 0, 1638, 0, 1641, 0, 1644, 0, 1647, 0, + 1650, 0, 1653, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 1656, 1659, 1662, + 1665, 1668, 1671, 1674, 1677, 0, 0, 0, 0, 0, 0, + 0, 0, 1680, 1683, 1686, 1689, 1692, 1695, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 1698, 1701, 1704, + 1707, 1710, 1713, 1716, 1719, 0, 0, 0, 0, 0, 0, + 0, 0, 1722, 1725, 1728, 1731, 1734, 1737, 1740, 1743, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 1746, 1749, 1752, + 1755, 1758, 1761, 0, 0, 1764, 0, 1771, 0, 1782, 0, + 1793, 0, 0, 1804, 0, 1807, 0, 1810, 0, 1813, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 1816, 1819, 1822, + 1825, 1828, 1831, 1834, 1837, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 1840, 1847, 1854, 1861, 1868, 1875, 1882, 1889, 1840, 1847, 1854, + 1861, 1868, 1875, 1882, 1889, 1896, 1903, 1910, 1917, 1924, 1931, + 1938, 1945, 1896, 1903, 1910, 1917, 1924, 1931, 1938, 1945, + }}, + {{ + 1952, 1959, 1966, 1973, 1980, 1987, 1994, 2001, 1952, 1959, 1966, + 1973, 1980, 1987, 1994, 2001, 0, 0, 2008, 2015, 2022, 0, + 2029, 2036, 2047, 2050, 2053, 2056, 2015, 0, 598, 0, + }}, + {{ + 0, 0, 2059, 2066, 2073, 0, 2080, 2087, 2098, 2101, 2104, + 2107, 2066, 0, 0, 0, 0, 0, 2110, 629, 0, 0, + 2121, 2128, 2139, 2142, 2145, 2148, 0, 0, 0, 0, + }}, + {{ + 0, 0, 2151, 712, 2162, 0, 2169, 2176, 2187, 2190, 2193, + 2196, 2199, 0, 0, 0, 0, 0, 2202, 2209, 2216, 0, + 2223, 2230, 2241, 2244, 2247, 2250, 2209, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 2253, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 6, 2259, 0, 0, 0, 351, 0, 2265, 0, + 16, 16, 16, 0, 0, 18, 18, 24, 0, 0, 28, + 2271, 0, 0, 32, 34, 36, 36, 36, 0, 0, + }}, + {{ + 2277, 2283, 2293, 0, 52, 0, 703, 0, 52, 0, 22, + 67, 4, 6, 0, 0, 10, 12, 0, 26, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 646, 679, + }}, + {{ + 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 2299, 2302, 2305, 2308, 2311, 2314, 2317, 2320, 2323, 2326, 2329, + 2332, 2335, 2338, 2341, 2344, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 2347, 2350, 2353, 2356, 2359, 2362, 2365, 2368, 2371, 2374, + }}, + {{ + 2377, 2380, 2383, 2386, 2389, 2392, 2395, 2398, 2401, 2404, 2407, + 2410, 2413, 2416, 2419, 2422, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 2425, 0, 2435, 0, 2441, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 2447, 2453, 2459, 2465, 2471, 2477, 2483, 2489, 0, 0, 2495, + 2501, 2507, 0, 0, 0, 2513, 2519, 2529, 2539, 2549, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 2447, 2559, + 2569, 2579, 0, 0, 0, 0, 0, 0, 0, 2589, 2595, + 2601, 2607, 2613, 2607, 2619, 2625, 2631, 2637, 2643, 2637, + }}, + {{ + 2649, 2656, 0, 2663, 0, 0, 2669, 2683, 2693, 2699, 0, + 2705, 0, 2711, 2717, 0, 0, 0, 0, 0, 0, 0, + 0, 2723, 0, 2729, 2739, 0, 2745, 2751, 0, 0, + }}, + {{ + 2757, 2763, 2769, 2775, 2785, 2795, 2795, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 2801, 2808, 2815, + 2822, 2829, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + }}, + {{ + 0, 2836, 2839, 2842, 2845, 2848, 2851, 2854, 2857, 2860, 2863, + 2866, 2869, 2872, 2875, 2878, 2881, 2884, 2887, 2890, 2893, 2896, + 2899, 2902, 2905, 2908, 2911, 0, 0, 0, 0, 0, + }}, + {{ + 2914, 2918, 2922, 2926, 2930, 2934, 2938, 2942, 2946, 2950, 2954, + 2958, 2962, 2966, 2970, 2974, 2978, 2982, 2986, 2990, 2994, 2998, + 3002, 3006, 3010, 3014, 3018, 3022, 3026, 3030, 3034, 3038, + }}, + {{ + 3042, 3046, 3050, 3054, 3058, 3062, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, + 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, + 46, 48, 50, 52, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 4, + 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, + }}, + {{ + 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, + 48, 50, 52, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 2, 4, 6, + 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, + 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, + }}, + {{ + 50, 52, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 2, 0, 6, 8, + }}, + {{ + 0, 0, 14, 0, 0, 20, 22, 0, 0, 28, 30, + 32, 34, 0, 38, 40, 42, 44, 46, 48, 50, 52, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 2, 4, 6, 8, 10, 12, + 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, + }}, + {{ + 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 2, 4, 0, 8, 10, 12, 14, + 0, 0, 20, 22, 24, 26, 28, 30, 32, 34, 0, + 38, 40, 42, 44, 46, 48, 50, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 2, 4, 0, 8, 10, 12, 14, 0, + }}, + {{ + 18, 20, 22, 24, 26, 0, 30, 0, 0, 0, 38, + 40, 42, 44, 46, 48, 50, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, + 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, + }}, + {{ + 42, 44, 46, 48, 50, 52, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 50, 52, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 2, 4, 6, 8, + }}, + {{ + 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, + 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 640, 643, 646, + 649, 652, 655, 658, 661, 598, 664, 667, 54, 670, 673, + 676, 679, 682, 661, 685, 688, 691, 694, 697, 700, + }}, + {{ + 703, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 685, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 640, 643, 646, 649, 652, 655, 658, 661, 598, + 664, 667, 54, 670, 673, 676, 679, 682, 661, 685, 688, + 691, 694, 697, 700, 703, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 685, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 640, 643, 646, 649, + }}, + {{ + 652, 655, 658, 661, 598, 664, 667, 54, 670, 673, 676, + 679, 682, 661, 685, 688, 691, 694, 697, 700, 703, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 685, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 640, 643, 646, 649, 652, 655, 658, 661, 598, 664, + }}, + {{ + 667, 54, 670, 673, 676, 679, 682, 661, 685, 688, 691, + 694, 697, 700, 703, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 685, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 640, 643, 646, 649, 652, 655, + 658, 661, 598, 664, 667, 54, 670, 673, 676, 679, + }}, + {{ + 682, 661, 685, 688, 691, 694, 697, 700, 703, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 685, 0, 0, 0, 0, + }}, +}; + +static const unsigned char nameprep_rfc3491_map_data[] = { + 0, 0, 1, 97, 1, 98, 1, 99, 1, 100, 1, 101, + 1, 102, 1, 103, 1, 104, 1, 105, 1, 106, 1, 107, + 1, 108, 1, 109, 1, 110, 1, 111, 1, 112, 1, 113, + 1, 114, 1, 115, 1, 116, 1, 117, 1, 118, 1, 119, + 1, 120, 1, 121, 1, 122, 2, 188, 3, 1, 224, 1, + 225, 1, 226, 1, 227, 1, 228, 1, 229, 1, 230, 1, + 231, 1, 232, 1, 233, 1, 234, 1, 235, 1, 236, 1, + 237, 1, 238, 1, 239, 1, 240, 1, 241, 1, 242, 1, + 243, 1, 244, 1, 245, 1, 246, 1, 248, 1, 249, 1, + 250, 1, 251, 1, 252, 1, 253, 1, 254, 5, 115, 0, + 0, 0, 115, 2, 1, 1, 2, 3, 1, 2, 5, 1, + 2, 7, 1, 2, 9, 1, 2, 11, 1, 2, 13, 1, + 2, 15, 1, 2, 17, 1, 2, 19, 1, 2, 21, 1, + 2, 23, 1, 2, 25, 1, 2, 27, 1, 2, 29, 1, + 2, 31, 1, 2, 33, 1, 2, 35, 1, 2, 37, 1, + 2, 39, 1, 2, 41, 1, 2, 43, 1, 2, 45, 1, + 2, 47, 1, 6, 105, 0, 0, 0, 7, 3, 2, 51, + 1, 2, 53, 1, 2, 55, 1, 2, 58, 1, 2, 60, + 1, 2, 62, 1, 2, 64, 1, 2, 66, 1, 2, 68, + 1, 2, 70, 1, 2, 72, 1, 5, 188, 2, 0, 0, + 110, 2, 75, 1, 2, 77, 1, 2, 79, 1, 2, 81, + 1, 2, 83, 1, 2, 85, 1, 2, 87, 1, 2, 89, + 1, 2, 91, 1, 2, 93, 1, 2, 95, 1, 2, 97, + 1, 2, 99, 1, 2, 101, 1, 2, 103, 1, 2, 105, + 1, 2, 107, 1, 2, 109, 1, 2, 111, 1, 2, 113, + 1, 2, 115, 1, 2, 117, 1, 2, 119, 1, 1, 255, + 2, 122, 1, 2, 124, 1, 2, 126, 1, 2, 83, 2, + 2, 131, 1, 2, 133, 1, 2, 84, 2, 2, 136, 1, + 2, 86, 2, 2, 87, 2, 2, 140, 1, 2, 221, 1, + 2, 89, 2, 2, 91, 2, 2, 146, 1, 2, 96, 2, + 2, 99, 2, 2, 105, 2, 2, 104, 2, 2, 153, 1, + 2, 111, 2, 2, 114, 2, 2, 117, 2, 2, 161, 1, + 2, 163, 1, 2, 165, 1, 2, 128, 2, 2, 168, 1, + 2, 131, 2, 2, 173, 1, 2, 136, 2, 2, 176, 1, + 2, 138, 2, 2, 139, 2, 2, 180, 1, 2, 182, 1, + 2, 146, 2, 2, 185, 1, 2, 189, 1, 2, 198, 1, + 2, 201, 1, 2, 204, 1, 2, 206, 1, 2, 208, 1, + 2, 210, 1, 2, 212, 1, 2, 214, 1, 2, 216, 1, + 2, 218, 1, 2, 220, 1, 2, 223, 1, 2, 225, 1, + 2, 227, 1, 2, 229, 1, 2, 231, 1, 2, 233, 1, + 2, 235, 1, 2, 237, 1, 2, 239, 1, 6, 106, 0, + 0, 0, 12, 3, 2, 243, 1, 2, 245, 1, 2, 149, + 1, 2, 191, 1, 2, 249, 1, 2, 251, 1, 2, 253, + 1, 2, 255, 1, 2, 1, 2, 2, 3, 2, 2, 5, + 2, 2, 7, 2, 2, 9, 2, 2, 11, 2, 2, 13, + 2, 2, 15, 2, 2, 17, 2, 2, 19, 2, 2, 21, + 2, 2, 23, 2, 2, 25, 2, 2, 27, 2, 2, 29, + 2, 2, 31, 2, 2, 158, 1, 2, 35, 2, 2, 37, + 2, 2, 39, 2, 2, 41, 2, 2, 43, 2, 2, 45, + 2, 2, 47, 2, 2, 49, 2, 2, 51, 2, 2, 185, + 3, 6, 32, 0, 0, 0, 185, 3, 2, 172, 3, 2, + 173, 3, 2, 174, 3, 2, 175, 3, 2, 204, 3, 2, + 205, 3, 2, 206, 3, 10, 185, 3, 0, 0, 8, 3, + 0, 0, 1, 3, 2, 177, 3, 2, 178, 3, 2, 179, + 3, 2, 180, 3, 2, 181, 3, 2, 182, 3, 2, 183, + 3, 2, 184, 3, 2, 186, 3, 2, 187, 3, 2, 189, + 3, 2, 190, 3, 2, 191, 3, 2, 192, 3, 2, 193, + 3, 2, 195, 3, 2, 196, 3, 2, 197, 3, 2, 198, + 3, 2, 199, 3, 2, 200, 3, 2, 201, 3, 2, 202, + 3, 2, 203, 3, 10, 197, 3, 0, 0, 8, 3, 0, + 0, 1, 3, 2, 217, 3, 2, 219, 3, 2, 221, 3, + 2, 223, 3, 2, 225, 3, 2, 227, 3, 2, 229, 3, + 2, 231, 3, 2, 233, 3, 2, 235, 3, 2, 237, 3, + 2, 239, 3, 2, 80, 4, 2, 81, 4, 2, 82, 4, + 2, 83, 4, 2, 84, 4, 2, 85, 4, 2, 86, 4, + 2, 87, 4, 2, 88, 4, 2, 89, 4, 2, 90, 4, + 2, 91, 4, 2, 92, 4, 2, 93, 4, 2, 94, 4, + 2, 95, 4, 2, 48, 4, 2, 49, 4, 2, 50, 4, + 2, 51, 4, 2, 52, 4, 2, 53, 4, 2, 54, 4, + 2, 55, 4, 2, 56, 4, 2, 57, 4, 2, 58, 4, + 2, 59, 4, 2, 60, 4, 2, 61, 4, 2, 62, 4, + 2, 63, 4, 2, 64, 4, 2, 65, 4, 2, 66, 4, + 2, 67, 4, 2, 68, 4, 2, 69, 4, 2, 70, 4, + 2, 71, 4, 2, 72, 4, 2, 73, 4, 2, 74, 4, + 2, 75, 4, 2, 76, 4, 2, 77, 4, 2, 78, 4, + 2, 79, 4, 2, 97, 4, 2, 99, 4, 2, 101, 4, + 2, 103, 4, 2, 105, 4, 2, 107, 4, 2, 109, 4, + 2, 111, 4, 2, 113, 4, 2, 115, 4, 2, 117, 4, + 2, 119, 4, 2, 121, 4, 2, 123, 4, 2, 125, 4, + 2, 127, 4, 2, 129, 4, 2, 139, 4, 2, 141, 4, + 2, 143, 4, 2, 145, 4, 2, 147, 4, 2, 149, 4, + 2, 151, 4, 2, 153, 4, 2, 155, 4, 2, 157, 4, + 2, 159, 4, 2, 161, 4, 2, 163, 4, 2, 165, 4, + 2, 167, 4, 2, 169, 4, 2, 171, 4, 2, 173, 4, + 2, 175, 4, 2, 177, 4, 2, 179, 4, 2, 181, 4, + 2, 183, 4, 2, 185, 4, 2, 187, 4, 2, 189, 4, + 2, 191, 4, 2, 194, 4, 2, 196, 4, 2, 198, 4, + 2, 200, 4, 2, 202, 4, 2, 204, 4, 2, 206, 4, + 2, 209, 4, 2, 211, 4, 2, 213, 4, 2, 215, 4, + 2, 217, 4, 2, 219, 4, 2, 221, 4, 2, 223, 4, + 2, 225, 4, 2, 227, 4, 2, 229, 4, 2, 231, 4, + 2, 233, 4, 2, 235, 4, 2, 237, 4, 2, 239, 4, + 2, 241, 4, 2, 243, 4, 2, 245, 4, 2, 249, 4, + 2, 1, 5, 2, 3, 5, 2, 5, 5, 2, 7, 5, + 2, 9, 5, 2, 11, 5, 2, 13, 5, 2, 15, 5, + 2, 97, 5, 2, 98, 5, 2, 99, 5, 2, 100, 5, + 2, 101, 5, 2, 102, 5, 2, 103, 5, 2, 104, 5, + 2, 105, 5, 2, 106, 5, 2, 107, 5, 2, 108, 5, + 2, 109, 5, 2, 110, 5, 2, 111, 5, 2, 112, 5, + 2, 113, 5, 2, 114, 5, 2, 115, 5, 2, 116, 5, + 2, 117, 5, 2, 118, 5, 2, 119, 5, 2, 120, 5, + 2, 121, 5, 2, 122, 5, 2, 123, 5, 2, 124, 5, + 2, 125, 5, 2, 126, 5, 2, 127, 5, 2, 128, 5, + 2, 129, 5, 2, 130, 5, 2, 131, 5, 2, 132, 5, + 2, 133, 5, 2, 134, 5, 6, 101, 5, 0, 0, 130, + 5, 2, 1, 30, 2, 3, 30, 2, 5, 30, 2, 7, + 30, 2, 9, 30, 2, 11, 30, 2, 13, 30, 2, 15, + 30, 2, 17, 30, 2, 19, 30, 2, 21, 30, 2, 23, + 30, 2, 25, 30, 2, 27, 30, 2, 29, 30, 2, 31, + 30, 2, 33, 30, 2, 35, 30, 2, 37, 30, 2, 39, + 30, 2, 41, 30, 2, 43, 30, 2, 45, 30, 2, 47, + 30, 2, 49, 30, 2, 51, 30, 2, 53, 30, 2, 55, + 30, 2, 57, 30, 2, 59, 30, 2, 61, 30, 2, 63, + 30, 2, 65, 30, 2, 67, 30, 2, 69, 30, 2, 71, + 30, 2, 73, 30, 2, 75, 30, 2, 77, 30, 2, 79, + 30, 2, 81, 30, 2, 83, 30, 2, 85, 30, 2, 87, + 30, 2, 89, 30, 2, 91, 30, 2, 93, 30, 2, 95, + 30, 2, 97, 30, 2, 99, 30, 2, 101, 30, 2, 103, + 30, 2, 105, 30, 2, 107, 30, 2, 109, 30, 2, 111, + 30, 2, 113, 30, 2, 115, 30, 2, 117, 30, 2, 119, + 30, 2, 121, 30, 2, 123, 30, 2, 125, 30, 2, 127, + 30, 2, 129, 30, 2, 131, 30, 2, 133, 30, 2, 135, + 30, 2, 137, 30, 2, 139, 30, 2, 141, 30, 2, 143, + 30, 2, 145, 30, 2, 147, 30, 2, 149, 30, 6, 104, + 0, 0, 0, 49, 3, 6, 116, 0, 0, 0, 8, 3, + 6, 119, 0, 0, 0, 10, 3, 6, 121, 0, 0, 0, + 10, 3, 6, 97, 0, 0, 0, 190, 2, 2, 161, 30, + 2, 163, 30, 2, 165, 30, 2, 167, 30, 2, 169, 30, + 2, 171, 30, 2, 173, 30, 2, 175, 30, 2, 177, 30, + 2, 179, 30, 2, 181, 30, 2, 183, 30, 2, 185, 30, + 2, 187, 30, 2, 189, 30, 2, 191, 30, 2, 193, 30, + 2, 195, 30, 2, 197, 30, 2, 199, 30, 2, 201, 30, + 2, 203, 30, 2, 205, 30, 2, 207, 30, 2, 209, 30, + 2, 211, 30, 2, 213, 30, 2, 215, 30, 2, 217, 30, + 2, 219, 30, 2, 221, 30, 2, 223, 30, 2, 225, 30, + 2, 227, 30, 2, 229, 30, 2, 231, 30, 2, 233, 30, + 2, 235, 30, 2, 237, 30, 2, 239, 30, 2, 241, 30, + 2, 243, 30, 2, 245, 30, 2, 247, 30, 2, 249, 30, + 2, 0, 31, 2, 1, 31, 2, 2, 31, 2, 3, 31, + 2, 4, 31, 2, 5, 31, 2, 6, 31, 2, 7, 31, + 2, 16, 31, 2, 17, 31, 2, 18, 31, 2, 19, 31, + 2, 20, 31, 2, 21, 31, 2, 32, 31, 2, 33, 31, + 2, 34, 31, 2, 35, 31, 2, 36, 31, 2, 37, 31, + 2, 38, 31, 2, 39, 31, 2, 48, 31, 2, 49, 31, + 2, 50, 31, 2, 51, 31, 2, 52, 31, 2, 53, 31, + 2, 54, 31, 2, 55, 31, 2, 64, 31, 2, 65, 31, + 2, 66, 31, 2, 67, 31, 2, 68, 31, 2, 69, 31, + 6, 197, 3, 0, 0, 19, 3, 10, 197, 3, 0, 0, + 19, 3, 0, 0, 0, 3, 10, 197, 3, 0, 0, 19, + 3, 0, 0, 1, 3, 10, 197, 3, 0, 0, 19, 3, + 0, 0, 66, 3, 2, 81, 31, 2, 83, 31, 2, 85, + 31, 2, 87, 31, 2, 96, 31, 2, 97, 31, 2, 98, + 31, 2, 99, 31, 2, 100, 31, 2, 101, 31, 2, 102, + 31, 2, 103, 31, 6, 0, 31, 0, 0, 185, 3, 6, + 1, 31, 0, 0, 185, 3, 6, 2, 31, 0, 0, 185, + 3, 6, 3, 31, 0, 0, 185, 3, 6, 4, 31, 0, + 0, 185, 3, 6, 5, 31, 0, 0, 185, 3, 6, 6, + 31, 0, 0, 185, 3, 6, 7, 31, 0, 0, 185, 3, + 6, 32, 31, 0, 0, 185, 3, 6, 33, 31, 0, 0, + 185, 3, 6, 34, 31, 0, 0, 185, 3, 6, 35, 31, + 0, 0, 185, 3, 6, 36, 31, 0, 0, 185, 3, 6, + 37, 31, 0, 0, 185, 3, 6, 38, 31, 0, 0, 185, + 3, 6, 39, 31, 0, 0, 185, 3, 6, 96, 31, 0, + 0, 185, 3, 6, 97, 31, 0, 0, 185, 3, 6, 98, + 31, 0, 0, 185, 3, 6, 99, 31, 0, 0, 185, 3, + 6, 100, 31, 0, 0, 185, 3, 6, 101, 31, 0, 0, + 185, 3, 6, 102, 31, 0, 0, 185, 3, 6, 103, 31, + 0, 0, 185, 3, 6, 112, 31, 0, 0, 185, 3, 6, + 177, 3, 0, 0, 185, 3, 6, 172, 3, 0, 0, 185, + 3, 6, 177, 3, 0, 0, 66, 3, 10, 177, 3, 0, + 0, 66, 3, 0, 0, 185, 3, 2, 176, 31, 2, 177, + 31, 2, 112, 31, 2, 113, 31, 6, 116, 31, 0, 0, + 185, 3, 6, 183, 3, 0, 0, 185, 3, 6, 174, 3, + 0, 0, 185, 3, 6, 183, 3, 0, 0, 66, 3, 10, + 183, 3, 0, 0, 66, 3, 0, 0, 185, 3, 2, 114, + 31, 2, 115, 31, 2, 116, 31, 2, 117, 31, 10, 185, + 3, 0, 0, 8, 3, 0, 0, 0, 3, 6, 185, 3, + 0, 0, 66, 3, 10, 185, 3, 0, 0, 8, 3, 0, + 0, 66, 3, 2, 208, 31, 2, 209, 31, 2, 118, 31, + 2, 119, 31, 10, 197, 3, 0, 0, 8, 3, 0, 0, + 0, 3, 6, 193, 3, 0, 0, 19, 3, 6, 197, 3, + 0, 0, 66, 3, 10, 197, 3, 0, 0, 8, 3, 0, + 0, 66, 3, 2, 224, 31, 2, 225, 31, 2, 122, 31, + 2, 123, 31, 2, 229, 31, 6, 124, 31, 0, 0, 185, + 3, 6, 201, 3, 0, 0, 185, 3, 6, 206, 3, 0, + 0, 185, 3, 6, 201, 3, 0, 0, 66, 3, 10, 201, + 3, 0, 0, 66, 3, 0, 0, 185, 3, 2, 120, 31, + 2, 121, 31, 2, 124, 31, 2, 125, 31, 5, 114, 0, + 0, 0, 115, 5, 176, 0, 0, 0, 99, 5, 176, 0, + 0, 0, 102, 5, 110, 0, 0, 0, 111, 5, 115, 0, + 0, 0, 109, 9, 116, 0, 0, 0, 101, 0, 0, 0, + 108, 5, 116, 0, 0, 0, 109, 2, 112, 33, 2, 113, + 33, 2, 114, 33, 2, 115, 33, 2, 116, 33, 2, 117, + 33, 2, 118, 33, 2, 119, 33, 2, 120, 33, 2, 121, + 33, 2, 122, 33, 2, 123, 33, 2, 124, 33, 2, 125, + 33, 2, 126, 33, 2, 127, 33, 2, 208, 36, 2, 209, + 36, 2, 210, 36, 2, 211, 36, 2, 212, 36, 2, 213, + 36, 2, 214, 36, 2, 215, 36, 2, 216, 36, 2, 217, + 36, 2, 218, 36, 2, 219, 36, 2, 220, 36, 2, 221, + 36, 2, 222, 36, 2, 223, 36, 2, 224, 36, 2, 225, + 36, 2, 226, 36, 2, 227, 36, 2, 228, 36, 2, 229, + 36, 2, 230, 36, 2, 231, 36, 2, 232, 36, 2, 233, + 36, 9, 104, 0, 0, 0, 112, 0, 0, 0, 97, 5, + 97, 0, 0, 0, 117, 5, 111, 0, 0, 0, 118, 5, + 112, 0, 0, 0, 97, 5, 110, 0, 0, 0, 97, 5, + 188, 3, 0, 0, 97, 5, 109, 0, 0, 0, 97, 5, + 107, 0, 0, 0, 97, 5, 107, 0, 0, 0, 98, 5, + 109, 0, 0, 0, 98, 5, 103, 0, 0, 0, 98, 5, + 112, 0, 0, 0, 102, 5, 110, 0, 0, 0, 102, 5, + 188, 3, 0, 0, 102, 5, 104, 0, 0, 0, 122, 9, + 107, 0, 0, 0, 104, 0, 0, 0, 122, 9, 109, 0, + 0, 0, 104, 0, 0, 0, 122, 9, 103, 0, 0, 0, + 104, 0, 0, 0, 122, 9, 116, 0, 0, 0, 104, 0, + 0, 0, 122, 9, 107, 0, 0, 0, 112, 0, 0, 0, + 97, 9, 109, 0, 0, 0, 112, 0, 0, 0, 97, 9, + 103, 0, 0, 0, 112, 0, 0, 0, 97, 5, 112, 0, + 0, 0, 118, 5, 110, 0, 0, 0, 118, 5, 188, 3, + 0, 0, 118, 5, 109, 0, 0, 0, 118, 5, 107, 0, + 0, 0, 118, 5, 112, 0, 0, 0, 119, 5, 110, 0, + 0, 0, 119, 5, 188, 3, 0, 0, 119, 5, 109, 0, + 0, 0, 119, 5, 107, 0, 0, 0, 119, 6, 107, 0, + 0, 0, 201, 3, 6, 109, 0, 0, 0, 201, 3, 5, + 98, 0, 0, 0, 113, 13, 99, 0, 0, 0, 21, 34, + 0, 0, 107, 0, 0, 0, 103, 9, 99, 0, 0, 0, + 111, 0, 0, 0, 46, 5, 100, 0, 0, 0, 98, 5, + 103, 0, 0, 0, 121, 5, 104, 0, 0, 0, 112, 5, + 107, 0, 0, 0, 107, 5, 107, 0, 0, 0, 109, 5, + 112, 0, 0, 0, 104, 9, 112, 0, 0, 0, 112, 0, + 0, 0, 109, 5, 112, 0, 0, 0, 114, 5, 115, 0, + 0, 0, 118, 5, 119, 0, 0, 0, 98, 5, 102, 0, + 0, 0, 102, 5, 102, 0, 0, 0, 105, 5, 102, 0, + 0, 0, 108, 9, 102, 0, 0, 0, 102, 0, 0, 0, + 105, 9, 102, 0, 0, 0, 102, 0, 0, 0, 108, 5, + 115, 0, 0, 0, 116, 6, 116, 5, 0, 0, 118, 5, + 6, 116, 5, 0, 0, 101, 5, 6, 116, 5, 0, 0, + 107, 5, 6, 126, 5, 0, 0, 118, 5, 6, 116, 5, + 0, 0, 109, 5, 2, 65, 255, 2, 66, 255, 2, 67, + 255, 2, 68, 255, 2, 69, 255, 2, 70, 255, 2, 71, + 255, 2, 72, 255, 2, 73, 255, 2, 74, 255, 2, 75, + 255, 2, 76, 255, 2, 77, 255, 2, 78, 255, 2, 79, + 255, 2, 80, 255, 2, 81, 255, 2, 82, 255, 2, 83, + 255, 2, 84, 255, 2, 85, 255, 2, 86, 255, 2, 87, + 255, 2, 88, 255, 2, 89, 255, 2, 90, 255, 3, 40, + 4, 1, 3, 41, 4, 1, 3, 42, 4, 1, 3, 43, + 4, 1, 3, 44, 4, 1, 3, 45, 4, 1, 3, 46, + 4, 1, 3, 47, 4, 1, 3, 48, 4, 1, 3, 49, + 4, 1, 3, 50, 4, 1, 3, 51, 4, 1, 3, 52, + 4, 1, 3, 53, 4, 1, 3, 54, 4, 1, 3, 55, + 4, 1, 3, 56, 4, 1, 3, 57, 4, 1, 3, 58, + 4, 1, 3, 59, 4, 1, 3, 60, 4, 1, 3, 61, + 4, 1, 3, 62, 4, 1, 3, 63, 4, 1, 3, 64, + 4, 1, 3, 65, 4, 1, 3, 66, 4, 1, 3, 67, + 4, 1, 3, 68, 4, 1, 3, 69, 4, 1, 3, 70, + 4, 1, 3, 71, 4, 1, 3, 72, 4, 1, 3, 73, + 4, 1, 3, 74, 4, 1, 3, 75, 4, 1, 3, 76, + 4, 1, 3, 77, 4, 1, +}; + +static const unsigned short nameprep_rfc3491_prohibited_imap[] = { + 68, 196, 196, 324, 196, 196, 196, 452, + 196, 196, 196, 580, 196, 196, 196, 580, + 196, 196, 196, 580, 196, 196, 196, 580, + 196, 196, 196, 580, 196, 196, 196, 580, + 196, 196, 196, 580, 196, 196, 196, 580, + 196, 196, 196, 580, 196, 196, 196, 580, + 196, 196, 196, 580, 196, 196, 196, 580, + 708, 196, 196, 580, 836, 836, 836, 836, + 836, 836, 836, 836, 0, 1, 0, 0, + 0, 0, 2, 0, 0, 0, 0, 0, + 0, 3, 4, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 5, 0, 0, 6, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 7, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 8, 5, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 10, + 0, 0, 0, 11, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 12, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 13, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 13, 14, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, +}; + +static const struct { + unsigned char bm[16]; +} nameprep_rfc3491_prohibited_bitmap[] = { + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 255,255,255,255, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, + }}, + {{ + 0,128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 255,199, 0, 0, 0,255, 0, 0, 0, 0, 0,128, 14,252, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,255, 15, + }}, + {{ + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,255,255,255,255, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,254, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,248, 7, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,192, + }}, + {{ + 2, 0, 0, 0,255,255,255,255,255,255,255,255,255,255,255,255, + }}, +}; + +static const unsigned short nameprep_rfc3491_unassigned_imap[] = { + 68, 196, 324, 452, 580, 708, 708, 836, + 964, 964, 1092, 1220, 708, 708, 708, 1348, + 708, 708, 708, 1348, 708, 708, 708, 1348, + 708, 708, 708, 1348, 708, 708, 708, 1348, + 708, 708, 708, 1348, 708, 708, 708, 1348, + 708, 708, 708, 1348, 708, 708, 708, 1348, + 708, 708, 708, 1348, 708, 708, 708, 1348, + 1476, 708, 708, 1348, 964, 964, 964, 964, + 964, 964, 964, 964, 0, 0, 0, 0, + 1, 2, 3, 4, 0, 5, 6, 7, + 8, 9, 10, 11, 12, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 34, 35, 0, 0, 0, + 36, 37, 38, 39, 40, 41, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 0, 42, 43, 44, 45, 46, 47, 48, + 0, 0, 0, 49, 50, 51, 0, 0, + 52, 53, 54, 55, 0, 0, 0, 0, + 0, 0, 12, 12, 12, 12, 12, 12, + 12, 56, 0, 57, 58, 59, 60, 61, + 62, 63, 64, 65, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 66, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 67, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 68, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 69, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 70, 12, 71, 72, 0, 0, 73, 74, + 75, 76, 35, 77, 12, 12, 12, 12, + 12, 12, 78, 12, 79, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 0, 80, 81, 82, + 12, 12, 12, 12, 83, 84, 85, 0, + 0, 86, 0, 87, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 88, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 89, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 0, 0, 0, 0, + 90, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 88, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 88, 91, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, +}; + +static const struct { + unsigned char bm[16]; +} nameprep_rfc3491_unassigned_bitmap[] = { + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 2, 0,240,255,255,255, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0,192, 0, 0, 0, 0, 0, 0, 0,128,255,255, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,255,255, 0, 0,207,187, + }}, + {{ + 15, 40, 0, 0, 4, 0, 0, 0, 0,128, 0, 0, 0, 0,128,255, + }}, + {{ + 128, 0, 0, 0, 0, 0, 0, 0, 0,128, 0, 0, 0, 0,192,252, + }}, + {{ + 0, 0,255,255,255,255, 1, 0, 0, 0,128, 1, 1, 0, 0, 0, + }}, + {{ + 0,249, 1, 0, 4, 0, 0, 4,224,255, 0, 0, 0,248,224,255, + }}, + {{ + 255,239,255,119, 1, 0, 0,248, 0, 0,192,255, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,192, 0,128, + }}, + {{ + 0, 64, 0, 0, 0,224, 0, 0, 0,248,255,255,255,255,255,255, + }}, + {{ + 0, 0, 0, 0, 0, 0,252,255,255,255,255,255,255,255,255,255, + }}, + {{ + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + }}, + {{ + 17, 0, 0, 0, 0, 0, 0, 12, 0,192,224, 0, 0, 0,254,255, + }}, + {{ + 17, 96, 6, 0, 0, 2, 58, 44, 96,198,127, 79, 48, 0, 0,248, + }}, + {{ + 27,120, 6, 0, 0, 2,146, 44,120,198,255,161, 63, 0,224,255, + }}, + {{ + 17, 80, 4, 0, 0, 2, 18, 12, 64,196,254,255, 62, 0,255,255, + }}, + {{ + 17, 96, 6, 0, 0, 2, 50, 12,112,198, 63, 79, 60, 0,254,255, + }}, + {{ + 19, 56,194, 41,231, 56, 64, 60, 56,194,127,255,127, 0,248,255, + }}, + {{ + 17, 32, 2, 0, 0, 2, 16, 60, 32,194,159,255, 60, 0,255,255, + }}, + {{ + 19, 32, 2, 0, 0, 2, 16, 60, 32,194,159,191, 60, 0,255,255, + }}, + {{ + 19, 32, 2, 0, 0, 2, 0, 60, 48,194,127,255, 60, 0,255,255, + }}, + {{ + 19, 0,128, 3, 0, 0, 4,208,128,123,160, 0,255,255,227,255, + }}, + {{ + 1, 0, 0, 0, 0, 0, 0,120, 0, 0, 0,240,255,255,255,255, + }}, + {{ + 105,218, 15, 1, 81, 19, 0,196,160,192, 0,204,255,255,255,255, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,248, 1, 0, + }}, + {{ + 0,240, 0, 1, 0, 0, 0, 32, 0, 96,255,255,255,255,255,255, + }}, + {{ + 0, 0, 0, 0, 4, 9, 56,252, 0, 0, 0,252,255,255,255,255, + }}, + {{ + 255,255,255,255, 0, 0, 0, 0,192,255, 0, 0, 0, 0, 0,246, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,124, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0,248, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,252, + }}, + {{ + 128, 0, 0, 0, 0, 0, 0, 0,128,194,128,194, 0, 0, 0, 0, + }}, + {{ + 128,194, 0, 0, 0,128,194,128,194,128,128, 0, 0,128, 0, 0, + }}, + {{ + 0,128,194,128, 0, 0, 0, 0,128, 0, 0,248, 1, 0, 0,224, + }}, + {{ + 255,255,255,255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,224,255, + }}, + {{ + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,128,255, + }}, + {{ + 0, 0, 0,224, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,254,255, + }}, + {{ + 0, 32,224,255, 0, 0,128,255, 0, 0,240,255, 0, 32,242,255, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,224, 0,252,255,255, + }}, + {{ + 0,128, 0,252, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,255, + }}, + {{ + 0, 0, 0, 0, 0,252,255,255,255,255,255,255,255,255,255,255, + }}, + {{ + 0, 0, 0,240, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,252, + }}, + {{ + 0, 0,192,192, 0, 0, 0, 0,192,192, 0, 85, 0, 0, 0,192, + }}, + {{ + 0, 0, 0, 0, 0, 0, 32, 0, 32, 0, 48, 16, 0, 0, 35,128, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,120,127,240, 3, 12, 0, + }}, + {{ + 0,128,255,255, 0, 0,252,255,255,255, 0, 0, 0,248,255,255, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 24, 0,240, 7, 0, 0, 0, 0, 0, + }}, + {{ + 240,255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0,128,255,255,255,255,255,255, + }}, + {{ + 0, 0, 0, 0,128,255,255,255, 0,248,255,255, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,128, + }}, + {{ + 0, 0, 48, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,192, + }}, + {{ + 0,252,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + }}, + {{ + 33, 12, 0, 0, 0, 1, 0, 0, 0, 80,184,128, 1, 0, 0, 0, + }}, + {{ + 0, 0,224, 0, 0, 0, 1,128,255,255, 0, 0, 0,240, 0, 0, + }}, + {{ + 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,240,255, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,192,255,255,255, 0,240, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0,128, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 31, 0, 0, 0, 0,224, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0,128, 0, 0, 0, 0, 0,255,255,255,255,255,255,255, 0, 0, + }}, + {{ + 0, 0, 0,224, 0, 0, 0, 0,240,255, 1, 0, 0, 0, 0,112, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0,240, 0, 0, 0, 0, 0,128, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,128, 7, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,192, 0, 0, 0,128, + }}, + {{ + 0, 0, 0, 0, 0, 0,192,255,255,255,255,255,255,255,255,255, + }}, + {{ + 0, 0, 0, 0,192,255,255,255,255,255,255,255,255,255,255,255, + }}, + {{ + 0,224, 0, 0, 0, 0, 0, 0,128,255,255,255,255,255,255,255, + }}, + {{ + 0, 0, 0, 0,240,255,255,255,255,255,255,255,255,255,255,255, + }}, + {{ + 0, 0, 0, 0, 0,192, 0, 0, 0, 0, 0, 0, 0,248,255,255, + }}, + {{ + 128,255, 7, 31, 0, 0,128,160, 36, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0,252,255,255,255, 7, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0,255,255, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 3, 0, 0, 0, 0, 0, 0,255, 0, 0, 0, 0, 0,224, + }}, + {{ + 0, 0,255,255,240,255, 0, 0,128, 1, 8, 0,128,240, 32, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 96, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0,128, 3, 3, 3,227,128,128,255, 1, + }}, + {{ + 0, 0, 0,128,240,255, 0, 0, 0,248,255,255,255,255,255,255, + }}, + {{ + 0, 0, 0, 0,192, 0, 0, 0, 0,192,255,255,255,255,255,255, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,192,255, + }}, + {{ + 0, 0, 0, 0,128, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,192,255,255,255,255, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 32,155, 33, 0, 20, 18, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 64, 24, 32, 32, 0, 0, 0,132,160, 3, 2, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0,240, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 60, 0, 0, 0, 0, 0, 0, + }}, + {{ + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, 63, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,128,255,255,255,255,255, + }}, + {{ + 0, 0, 0,192,255,255,255,255,255,255,255,255,255,255,255,255, + }}, + {{ + 253,255,255,255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, +}; + +static const unsigned short nameprep_rfc3491_bidi_imap[] = { + 272, 400, 528, 656, 784, 912, 912, 912, + 912, 1040, 1168, 912, 912, 1296, 912, 1424, + 1552, 1680, 1680, 1680, 1680, 1680, 1680, 1680, + 1680, 1680, 1680, 1680, 1680, 1808, 1680, 1680, + 912, 912, 912, 912, 912, 912, 912, 912, + 912, 912, 1936, 1680, 1680, 1680, 1680, 2064, + 1680, 1680, 1680, 1680, 1680, 1680, 1680, 1680, + 1680, 1680, 1680, 1680, 1680, 1680, 1680, 1680, + 1680, 1680, 1680, 1680, 1680, 1680, 1680, 1680, + 1680, 1680, 1680, 1680, 1680, 1680, 1680, 1680, + 1680, 1680, 1680, 1680, 1680, 1680, 1680, 1680, + 1680, 1680, 1680, 1680, 1680, 1680, 1680, 1680, + 1680, 1680, 1680, 1680, 1680, 1680, 1680, 1680, + 1680, 1680, 1680, 1680, 1680, 1680, 1680, 1680, + 1680, 1680, 1680, 1680, 1680, 1680, 1680, 1680, + 1680, 1680, 1680, 1680, 1680, 1680, 1680, 1680, + 1680, 1680, 1680, 1680, 1680, 1680, 1680, 1680, + 1680, 1680, 1680, 1680, 1680, 1680, 1680, 1680, + 1680, 1680, 1680, 1680, 1680, 1680, 1680, 1680, + 1680, 1680, 1680, 1680, 1680, 1680, 1680, 1680, + 1680, 1680, 1680, 1680, 1680, 1680, 1680, 1680, + 1680, 1680, 1680, 1680, 1680, 1680, 1680, 1680, + 1680, 1680, 1680, 1680, 1680, 1680, 1680, 1680, + 1680, 1680, 1680, 1680, 1680, 1680, 1680, 1680, + 1680, 1680, 1680, 1680, 1680, 1680, 1680, 1680, + 1680, 1680, 1680, 1680, 1680, 1680, 1680, 1680, + 1680, 1680, 1680, 1680, 1680, 1680, 1680, 1680, + 1680, 1680, 1680, 1680, 1680, 1680, 1680, 1680, + 1680, 1680, 1680, 1680, 1680, 1680, 1680, 1680, + 1680, 1680, 1680, 1680, 1680, 1680, 1680, 1680, + 912, 912, 912, 912, 912, 912, 912, 912, + 912, 912, 912, 912, 912, 912, 912, 2192, + 912, 912, 912, 912, 912, 912, 912, 912, + 912, 912, 912, 912, 912, 912, 912, 2192, + 0, 0, 1, 1, 0, 2, 3, 3, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 5, 6, 4, 4, 7, 8, 9, + 0, 0, 0, 10, 11, 12, 13, 14, + 4, 4, 4, 4, 15, 4, 13, 16, + 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 29, 30, 31, + 32, 33, 0, 0, 29, 34, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 35, 36, 37, 38, 39, 40, 41, 42, + 43, 44, 45, 46, 47, 48, 49, 50, + 39, 51, 41, 52, 53, 54, 55, 56, + 57, 58, 59, 60, 61, 62, 63, 60, + 61, 64, 65, 60, 66, 67, 68, 69, + 20, 70, 71, 0, 72, 73, 74, 0, + 75, 76, 77, 78, 79, 80, 81, 0, + 4, 82, 83, 0, 0, 4, 84, 85, + 4, 4, 86, 4, 4, 87, 4, 88, + 89, 4, 90, 4, 91, 92, 93, 13, + 92, 4, 94, 95, 0, 4, 4, 96, + 20, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 97, 1, 4, 4, 98, + 99, 100, 101, 102, 4, 103, 104, 105, + 106, 4, 4, 83, 4, 107, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 4, 4, 4, 4, 108, 4, 4, 88, + 109, 4, 110, 111, 4, 112, 113, 114, + 115, 0, 0, 116, 0, 0, 0, 0, + 117, 118, 119, 4, 120, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 121, 4, 122, 123, 0, 0, 0, + 0, 0, 0, 0, 124, 4, 4, 105, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 125, 126, 20, 4, 127, 20, 4, 128, + 129, 130, 4, 4, 13, 83, 0, 6, + 131, 4, 120, 132, 4, 98, 133, 134, + 4, 4, 4, 135, 4, 4, 111, 134, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 14, 0, 0, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 136, 0, 0, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 137, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 120, 0, 0, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 138, 4, 139, 0, 0, 0, 0, + 140, 141, 142, 29, 29, 143, 144, 29, + 29, 29, 29, 29, 29, 29, 29, 29, + 29, 145, 146, 29, 147, 29, 148, 149, + 0, 0, 0, 150, 29, 29, 29, 151, + 0, 1, 1, 152, 4, 134, 153, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 134, 154, 139, 0, 0, 0, 0, 0, + 4, 155, 156, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 4, 4, 4, 4, 4, 4, 4, 14, + 4, 157, 4, 158, 159, 160, 111, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 4, 4, 161, 4, 162, 163, 164, 4, + 165, 166, 167, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 168, 4, 4, + 4, 4, 4, 4, 4, 4, 105, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 97, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 111, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 111, +}; + +static const struct { + unsigned char tbl[32]; +} nameprep_rfc3491_bidi_table[] = { + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + }}, + {{ + 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 2, 2, 2, 2, 2, + }}, + {{ + 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, + 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 2, 0, 2, 2, 2, 0, 2, 0, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + }}, + {{ + 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 2, + }}, + {{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, + }}, + {{ + 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + }}, + {{ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, + 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, + }}, + {{ + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, + }}, + {{ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + }}, + {{ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + }}, + {{ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, + }}, + {{ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + }}, + {{ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 2, 2, 2, + }}, + {{ + 2, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, + }}, + {{ + 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 2, 2, + 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, + 0, 2, 0, 0, 0, 2, 2, 2, 2, 0, 0, 0, 0, 2, 2, + }}, + {{ + 2, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 2, 2, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 2, 0, 2, + }}, + {{ + 2, 2, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 0, 0, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 2, 2, + 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, + 0, 2, 2, 0, 2, 2, 0, 2, 2, 0, 0, 0, 0, 2, 2, + }}, + {{ + 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 0, 2, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, + 0, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 2, 0, 2, 2, 2, 2, 2, 2, 2, 0, 2, 0, 2, 2, + 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, + 0, 2, 2, 0, 2, 2, 2, 2, 2, 0, 0, 0, 2, 2, 2, + }}, + {{ + 2, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 2, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 2, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, + 0, 2, 2, 0, 0, 2, 2, 2, 2, 0, 0, 0, 2, 2, 0, + }}, + {{ + 2, 2, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 2, 0, 2, 2, 2, 2, 2, 2, 0, 0, 0, 2, 2, 2, + 0, 2, 2, 2, 2, 0, 0, 0, 2, 2, 0, 2, 0, 2, 2, + }}, + {{ + 0, 0, 0, 2, 2, 0, 0, 0, 2, 2, 2, 0, 0, 0, 2, 2, 2, + 2, 2, 2, 2, 2, 0, 2, 2, 2, 0, 0, 0, 0, 2, 2, + }}, + {{ + 0, 2, 2, 0, 0, 0, 2, 2, 2, 0, 2, 2, 2, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 0, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 2, 2, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 0, 2, 2, 2, 2, 2, 0, 0, 0, 0, 2, 0, + }}, + {{ + 2, 2, 2, 2, 2, 0, 0, 2, 2, 0, 2, 2, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 2, 0, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 2, 2, + }}, + {{ + 2, 0, 0, 0, 0, 0, 2, 2, 2, 0, 2, 2, 2, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 0, 0, 0, 2, 2, 2, 2, 2, 2, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 0, 0, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, + 2, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, + }}, + {{ + 0, 2, 2, 0, 2, 0, 0, 2, 2, 0, 2, 0, 0, 2, 0, 0, 0, + 0, 0, 0, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, + }}, + {{ + 0, 2, 2, 2, 0, 2, 0, 2, 0, 0, 2, 2, 0, 2, 2, 2, 2, + 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, + }}, + {{ + 2, 2, 2, 2, 2, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 2, 2, 0, 0, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 0, 2, 0, 2, 0, 0, 0, 0, 0, 2, 2, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, + }}, + {{ + 0, 0, 0, 0, 0, 2, 0, 0, 2, 2, 2, 2, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, + }}, + {{ + 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 0, 0, 2, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 2, 2, 0, 2, 2, 2, 2, 2, 0, 2, 2, 0, 2, 0, 0, 0, 0, + 2, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 2, 0, 0, 0, 0, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 2, + }}, + {{ + 2, 2, 2, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 0, 2, 0, 2, 2, 2, 2, 0, 0, 2, + 2, 2, 2, 2, 2, 2, 0, 2, 0, 2, 2, 2, 2, 0, 0, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 0, 2, 0, 2, 2, 2, 2, 0, 0, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, + 0, 2, 2, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 2, 0, + }}, + {{ + 2, 0, 2, 2, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 2, 0, 2, + 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, + }}, + {{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, + 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 2, 2, + }}, + {{ + 2, 2, 2, 2, 2, 2, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 0, 2, 0, 0, 0, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 0, 0, + }}, + {{ + 2, 2, 2, 2, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 0, 0, 2, + 2, 2, 2, 2, 2, 2, 2, 0, 2, 0, 2, 0, 2, 0, 2, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 0, 2, 0, + }}, + {{ + 0, 0, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 2, + 2, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, + 0, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, + }}, + {{ + 0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 0, 2, 0, 0, 0, 2, 2, 2, 2, 2, 0, 0, + }}, + {{ + 0, 0, 0, 0, 2, 0, 2, 0, 2, 0, 2, 2, 2, 2, 0, 2, 2, + 2, 0, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 2, 2, 2, + }}, + {{ + 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, + }}, + {{ + 0, 0, 0, 0, 0, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, + 2, 2, 2, 2, 2, 0, 0, 2, 2, 2, 2, 2, 0, 0, 0, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 2, 2, 2, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, + }}, + {{ + 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 2, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 2, 2, 2, 2, 2, + }}, + {{ + 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 1, 0, 1, + }}, + {{ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, + }}, + {{ + 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + }}, + {{ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + }}, + {{ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + }}, + {{ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + }}, + {{ + 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + }}, + {{ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + }}, + {{ + 0, 0, 2, 2, 2, 2, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 0, + 0, 2, 2, 2, 2, 2, 2, 0, 0, 2, 2, 2, 0, 0, 0, + }}, + {{ + 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + }}, + {{ + 2, 2, 2, 2, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, + }}, + {{ + 0, 0, 2, 0, 0, 2, 2, 0, 0, 2, 2, 2, 2, 0, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 0, 2, 2, 2, + }}, + {{ + 2, 0, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + }}, + {{ + 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 0, 0, 2, 2, 2, 2, + 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 0, + }}, + {{ + 2, 2, 2, 2, 2, 0, 2, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + }}, + {{ + 2, 2, 2, 2, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + }}, +}; + +static const unsigned char nameprep_rfc3491_bidi_data[] = { + idn_biditype_others, + idn_biditype_r_al, + idn_biditype_l, +}; + diff --git a/contrib/idn/idnkit-1.0-src/lib/normalizer.c b/contrib/idn/idnkit-1.0-src/lib/normalizer.c new file mode 100644 index 0000000..604a1e5 --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/normalizer.c @@ -0,0 +1,439 @@ +#ifndef lint +static char *rcsid = "$Id: normalizer.c,v 1.1.1.1 2003/06/04 00:26:05 marka Exp $"; +#endif + +/* + * Copyright (c) 2000,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 <config.h> + +#include <stddef.h> +#include <stdlib.h> +#include <string.h> +#include <ctype.h> + +#include <idn/assert.h> +#include <idn/logmacro.h> +#include <idn/result.h> +#include <idn/normalizer.h> +#include <idn/strhash.h> +#include <idn/unormalize.h> +#include <idn/unicode.h> +#include <idn/ucs4.h> +#include <idn/debug.h> +#include <idn/util.h> + +#define MAX_LOCAL_SCHEME 3 + +#define INITIALIZED (scheme_hash != NULL) + +typedef struct { + char *name; + idn_normalizer_proc_t proc; +} normalize_scheme_t; + +struct idn_normalizer { + int nschemes; + int scheme_size; + normalize_scheme_t **schemes; + normalize_scheme_t *local_buf[MAX_LOCAL_SCHEME]; + int reference_count; +}; + +static idn__strhash_t scheme_hash; + +static idn__unicode_version_t vcur = NULL; +static idn__unicode_version_t v320 = NULL; +#define INIT_VERSION(version, var) \ + if (var == NULL) { \ + idn_result_t r = idn__unicode_create(version, &var); \ + if (r != idn_success) \ + return (r); \ + } + +static idn_result_t expand_schemes(idn_normalizer_t ctx); +static idn_result_t register_standard_normalizers(void); +static idn_result_t normalizer_formkc(const unsigned long *from, + unsigned long *to, size_t tolen); +static idn_result_t normalizer_formkc_v320(const unsigned long *from, + unsigned long *to, + size_t tolen); + +static struct standard_normalizer { + char *name; + idn_normalizer_proc_t proc; +} standard_normalizer[] = { + { "unicode-form-kc", normalizer_formkc }, + { "unicode-form-kc/3.2.0", normalizer_formkc_v320 }, + { "RFC3491", normalizer_formkc_v320 }, + { NULL, NULL }, +}; + +idn_result_t +idn_normalizer_initialize(void) { + idn__strhash_t hash; + idn_result_t r; + + TRACE(("idn_normalizer_initialize()\n")); + + if (scheme_hash != NULL) { + r = idn_success; /* already initialized */ + goto ret; + } + + if ((r = idn__strhash_create(&hash)) != idn_success) + goto ret; + scheme_hash = hash; + + /* Register standard normalizers */ + r = register_standard_normalizers(); +ret: + TRACE(("idn_normalizer_initialize(): %s\n", idn_result_tostring(r))); + return (r); +} + +idn_result_t +idn_normalizer_create(idn_normalizer_t *ctxp) { + idn_normalizer_t ctx; + idn_result_t r; + + assert(ctxp != NULL); + TRACE(("idn_normalizer_create()\n")); + + if ((ctx = malloc(sizeof(struct idn_normalizer))) == NULL) { + r = idn_nomemory; + goto ret; + } + + ctx->nschemes = 0; + ctx->scheme_size = MAX_LOCAL_SCHEME; + ctx->schemes = ctx->local_buf; + ctx->reference_count = 1; + *ctxp = ctx; + + r = idn_success; +ret: + TRACE(("idn_normalizer_create(): %s\n", idn_result_tostring(r))); + return (r); +} + +void +idn_normalizer_destroy(idn_normalizer_t ctx) { + assert(ctx != NULL); + + TRACE(("idn_normalizer_destroy()\n")); + + ctx->reference_count--; + if (ctx->reference_count <= 0) { + TRACE(("idn_normalizer_destroy(): the object is destroyed\n")); + if (ctx->schemes != ctx->local_buf) + free(ctx->schemes); + free(ctx); + } else { + TRACE(("idn_normalizer_destroy(): " + "update reference count (%d->%d)\n", + ctx->reference_count + 1, ctx->reference_count)); + } +} + +void +idn_normalizer_incrref(idn_normalizer_t ctx) { + assert(ctx != NULL); + + TRACE(("idn_normalizer_incrref()\n")); + TRACE(("idn_normalizer_incrref: update reference count (%d->%d)\n", + ctx->reference_count, ctx->reference_count + 1)); + + ctx->reference_count++; +} + +idn_result_t +idn_normalizer_add(idn_normalizer_t ctx, const char *scheme_name) { + idn_result_t r; + void *v; + normalize_scheme_t *scheme; + + assert(ctx != NULL && scheme_name != NULL); + + TRACE(("idn_normalizer_add(scheme_name=%s)\n", scheme_name)); + + assert(INITIALIZED); + + if (idn__strhash_get(scheme_hash, scheme_name, &v) != idn_success) { + ERROR(("idn_normalizer_add(): invalid scheme \"%-.30s\"\n", + scheme_name)); + r = idn_invalid_name; + goto ret; + } + + scheme = v; + + assert(ctx->nschemes <= ctx->scheme_size); + + if (ctx->nschemes == ctx->scheme_size && + (r = expand_schemes(ctx)) != idn_success) { + goto ret; + } + + ctx->schemes[ctx->nschemes++] = scheme; + r = idn_success; +ret: + TRACE(("idn_normalizer_add(): %s\n", idn_result_tostring(r))); + return (r); +} + +idn_result_t +idn_normalizer_addall(idn_normalizer_t ctx, const char **scheme_names, + int nschemes) { + idn_result_t r; + int i; + + assert(ctx != NULL && scheme_names != NULL); + + TRACE(("idn_normalizer_addall(nschemes=%d)\n", nschemes)); + + for (i = 0; i < nschemes; i++) { + r = idn_normalizer_add(ctx, (const char *)*scheme_names); + if (r != idn_success) + goto ret; + scheme_names++; + } + + r = idn_success; +ret: + TRACE(("idn_normalizer_addall(): %s\n", idn_result_tostring(r))); + return (r); +} + +idn_result_t +idn_normalizer_normalize(idn_normalizer_t ctx, const unsigned long *from, + unsigned long *to, size_t tolen) { + idn_result_t r; + unsigned long *src, *dst; + unsigned long *buffers[2] = {NULL, NULL}; + size_t buflen[2] = {0, 0}; + size_t dstlen; + int idx; + int i; + + assert(scheme_hash != NULL); + assert(ctx != NULL && from != NULL && to != NULL); + + TRACE(("idn_normalizer_normalize(from=\"%s\", tolen=%d)\n", + idn__debug_ucs4xstring(from, 50), (int)tolen)); + + if (ctx->nschemes <= 0) { + if (tolen < idn_ucs4_strlen(from) + 1) { + r = idn_buffer_overflow; + goto ret; + } + idn_ucs4_strcpy(to, from); + r = idn_success; + goto ret; + } + + /* + * Normalize. + */ + src = (void *)from; + dstlen = idn_ucs4_strlen(from) + 1; + + i = 0; + while (i < ctx->nschemes) { + TRACE(("idn_normalizer_normalize(): normalize %s\n", + ctx->schemes[i]->name)); + + /* + * Choose destination area to restore the result of a mapping. + */ + if (i + 1 == ctx->nschemes) { + dst = to; + dstlen = tolen; + } else { + if (src == buffers[0]) + idx = 1; + else + idx = 0; + + if (buflen[idx] < dstlen) { + void *newbuf; + + newbuf = realloc(buffers[idx], + sizeof(long) * dstlen); + if (newbuf == NULL) { + r = idn_nomemory; + goto ret; + } + buffers[idx] = (unsigned long *)newbuf; + buflen[idx] = dstlen; + } + + dst = buffers[idx]; + dstlen = buflen[idx]; + } + + /* + * Perform i-th normalization scheme. + * If buffer size is not enough, we double it and try again. + */ + r = (ctx->schemes[i]->proc)(src, dst, dstlen); + if (r == idn_buffer_overflow && dst != to) { + dstlen *= 2; + continue; + } + if (r != idn_success) + goto ret; + + src = dst; + i++; + } + + r = idn_success; +ret: + free(buffers[0]); + free(buffers[1]); + if (r == idn_success) { + TRACE(("idn_normalizer_normalize(): success (to=\"%s\")\n", + idn__debug_ucs4xstring(to, 50))); + } else { + TRACE(("idn_normalizer_normalize(): %s\n", + idn_result_tostring(r))); + } + return (r); +} + +idn_result_t +idn_normalizer_register(const char *scheme_name, idn_normalizer_proc_t proc) { + idn_result_t r; + normalize_scheme_t *scheme; + + assert(scheme_name != NULL && proc != NULL); + + TRACE(("idn_normalizer_register(scheme_name=%s)\n", scheme_name)); + + assert(INITIALIZED); + + scheme = malloc(sizeof(*scheme) + strlen(scheme_name) + 1); + if (scheme == NULL) { + r = idn_nomemory; + goto ret; + } + scheme->name = (char *)(scheme + 1); + (void)strcpy(scheme->name, scheme_name); + scheme->proc = proc; + + r = idn__strhash_put(scheme_hash, scheme_name, scheme); + if (r != idn_success) + goto ret; + + r = idn_success; +ret: + TRACE(("idn_normalizer_register(): %s\n", idn_result_tostring(r))); + return (r); +} + +static idn_result_t +expand_schemes(idn_normalizer_t ctx) { + normalize_scheme_t **new_schemes; + int new_size = ctx->scheme_size * 2; + + if (ctx->schemes == ctx->local_buf) { + new_schemes = malloc(sizeof(normalize_scheme_t) * new_size); + } else { + new_schemes = realloc(ctx->schemes, + sizeof(normalize_scheme_t) * new_size); + } + if (new_schemes == NULL) + return (idn_nomemory); + + if (ctx->schemes == ctx->local_buf) + memcpy(new_schemes, ctx->local_buf, sizeof(ctx->local_buf)); + + ctx->schemes = new_schemes; + ctx->scheme_size = new_size; + + return (idn_success); +} + +static idn_result_t +register_standard_normalizers(void) { + int i; + int failed = 0; + + for (i = 0; standard_normalizer[i].name != NULL; i++) { + idn_result_t r; + r = idn_normalizer_register(standard_normalizer[i].name, + standard_normalizer[i].proc); + if (r != idn_success) { + WARNING(("idn_normalizer_initialize(): " + "failed to register \"%-.100s\"\n", + standard_normalizer[i].name)); + failed++; + } + } + if (failed > 0) + return (idn_failure); + else + return (idn_success); +} + +/* + * Unicode Normalization Forms -- latest version + */ + +static idn_result_t +normalizer_formkc(const unsigned long *from, unsigned long *to, size_t tolen) { + INIT_VERSION(NULL, vcur); + return (idn__unormalize_formkc(vcur, from, to, tolen)); +} + +/* + * Unicode Normalization Forms -- version 3.2.0 + */ + +static idn_result_t +normalizer_formkc_v320(const unsigned long *from, unsigned long *to, + size_t tolen) { + INIT_VERSION("3.2.0", v320); + return (idn__unormalize_formkc(v320, from, to, tolen)); +} diff --git a/contrib/idn/idnkit-1.0-src/lib/punycode.c b/contrib/idn/idnkit-1.0-src/lib/punycode.c new file mode 100644 index 0000000..d803af5 --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/punycode.c @@ -0,0 +1,434 @@ +#ifndef lint +static char *rcsid = "$Id: punycode.c,v 1.1.1.1 2003/06/04 00:26:06 marka Exp $"; +#endif + +/* + * Copyright (c) 2001,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 <config.h> + +#include <stddef.h> +#include <stdlib.h> +#include <string.h> + +#include <idn/result.h> +#include <idn/assert.h> +#include <idn/logmacro.h> +#include <idn/converter.h> +#include <idn/ucs4.h> +#include <idn/debug.h> +#include <idn/punycode.h> +#include <idn/util.h> + +/* + * Although draft-ietf-idn-punycode-00.txt doesn't specify the ACE + * signature, we have to choose one. In order to prevent the converted + * name from beginning with a hyphen, we should choose a prefix rather + * than a suffix. + */ +#ifndef IDN_PUNYCODE_PREFIX +#define IDN_PUNYCODE_PREFIX "xn--" +#endif + +#define INVALID_UCS 0x80000000 +#define MAX_UCS 0x10FFFF + +/* + * As the draft states, it is possible that `delta' may overflow during + * the encoding. The upper bound of 'delta' is: + * <# of chars. of input string> + <max. difference in code point> * + * <# of chars. of input string + 1> + * For this value not to be greater than 0xffffffff (since the calculation + * is done using unsigned long, which is at least 32bit long), the maxmum + * input string size is about 3850 characters, which is long enough for + * a domain label... + */ +#define PUNYCODE_MAXINPUT 3800 + +/* + * Parameters. + */ +#define PUNYCODE_BASE 36 +#define PUNYCODE_TMIN 1 +#define PUNYCODE_TMAX 26 +#define PUNYCODE_SKEW 38 +#define PUNYCODE_DAMP 700 +#define PUNYCODE_INITIAL_BIAS 72 +#define PUNYCODE_INITIAL_N 0x80 + +static int punycode_getwc(const char *s, size_t len, + int bias, unsigned long *vp); +static int punycode_putwc(char *s, size_t len, + unsigned long delta, int bias); +static int punycode_update_bias(unsigned long delta, + size_t npoints, int first); + +idn_result_t +idn__punycode_decode(idn_converter_t ctx, void *privdata, + const char *from, unsigned long *to, size_t tolen) { + unsigned long *to_org = to; + unsigned long c, idx; + size_t prefixlen = strlen(IDN_PUNYCODE_PREFIX); + size_t fromlen; + size_t uidx, fidx, ucslen; + int first, bias; + idn_result_t r; + + assert(ctx != NULL); + + TRACE(("idn__punycode_decode(from=\"%s\", tolen=%d)\n", + idn__debug_xstring(from, 50), (int)tolen)); + + if (!idn__util_asciihaveaceprefix(from, IDN_PUNYCODE_PREFIX)) { + if (*from == '\0') { + r = idn_ucs4_utf8toucs4(from, to, tolen); + goto ret; + } + r = idn_invalid_encoding; + goto ret; + } + from += prefixlen; + fromlen = strlen(from); + + /* + * Find the last delimiter, and copy the characters + * before it verbatim. + */ + ucslen = 0; + for (fidx = fromlen; fidx > 0; fidx--) { + if (from[fidx - 1] == '-') { + if (tolen < fidx) { + r = idn_buffer_overflow; + goto ret; + } + for (uidx = 0; uidx < fidx - 1; uidx++) { + to[uidx] = from[uidx]; + } + ucslen = uidx; + break; + } + } + + first = 1; + bias = PUNYCODE_INITIAL_BIAS; + c = PUNYCODE_INITIAL_N; + idx = 0; + while (fidx < fromlen) { + int len; + unsigned long delta; + int i; + + len = punycode_getwc(from + fidx, fromlen - fidx, bias, &delta); + if (len == 0) { + r = idn_invalid_encoding; + goto ret; + } + fidx += len; + + bias = punycode_update_bias(delta, ucslen + 1, first); + first = 0; + idx += delta; + c += idx / (ucslen + 1); + uidx = idx % (ucslen + 1); + + /* Insert 'c' at uidx. */ + if (tolen-- <= 0) { + r = idn_buffer_overflow; + goto ret; + } + for (i = ucslen; i > uidx; i--) + to[i] = to[i - 1]; + to[uidx] = c; + + ucslen++; + idx = uidx + 1; + } + + /* Terminate with NUL. */ + if (tolen <= 0) { + r = idn_buffer_overflow; + goto ret; + } + to[ucslen] = '\0'; + r = idn_success; + +ret: + if (r == idn_success) { + TRACE(("idn__punycode_decode(): succcess (to=\"%s\")\n", + idn__debug_ucs4xstring(to_org, 50))); + } else { + TRACE(("idn__punycode_decode(): %s\n", idn_result_tostring(r))); + } + return (r); +} + +idn_result_t +idn__punycode_encode(idn_converter_t ctx, void *privdata, + const unsigned long *from, char *to, size_t tolen) { + char *to_org = to; + unsigned long cur_code, next_code, delta; + size_t prefixlen = strlen(IDN_PUNYCODE_PREFIX); + size_t fromlen; + size_t ucsdone; + size_t toidx; + int uidx, bias, first; + idn_result_t r; + + assert(ctx != NULL); + + TRACE(("idn__punycode_encode(from=\"%s\", tolen=%d)\n", + idn__debug_ucs4xstring(from, 50), (int)tolen)); + + if (*from == '\0') { + r = idn_ucs4_ucs4toutf8(from, to, tolen); + goto ret; + } else if (idn__util_ucs4haveaceprefix(from, IDN_PUNYCODE_PREFIX)) { + r = idn_prohibited; + goto ret; + } + + if (tolen < prefixlen) { + r = idn_buffer_overflow; + goto ret; + } + memcpy(to, IDN_PUNYCODE_PREFIX, prefixlen); + to += prefixlen; + tolen -= prefixlen; + + fromlen = idn_ucs4_strlen(from); + + /* + * If the input string is too long (actually too long to be sane), + * return failure in order to prevent possible overflow. + */ + if (fromlen > PUNYCODE_MAXINPUT) { + ERROR(("idn__punycode_encode(): " + "the input string is too long to convert Punycode\n", + idn__debug_ucs4xstring(from, 50))); + r = idn_failure; + goto ret; + } + + ucsdone = 0; /* number of characters processed */ + toidx = 0; + + /* + * First, pick up basic code points and copy them to 'to'. + */ + for (uidx = 0; uidx < fromlen; uidx++) { + if (from[uidx] < 0x80) { + if (toidx >= tolen) { + r = idn_buffer_overflow; + goto ret; + } + to[toidx++] = from[uidx]; + ucsdone++; + } + } + + /* + * If there are any basic code points, output a delimiter + * (hyphen-minus). + */ + if (toidx > 0) { + if (toidx >= tolen) { + r = idn_buffer_overflow; + goto ret; + } + to[toidx++] = '-'; + to += toidx; + tolen -= toidx; + } + + /* + * Then encode non-basic characters. + */ + first = 1; + cur_code = PUNYCODE_INITIAL_N; + bias = PUNYCODE_INITIAL_BIAS; + delta = 0; + while (ucsdone < fromlen) { + int limit = -1, rest; + + /* + * Find the smallest code point equal to or greater + * than 'cur_code'. Also remember the index of the + * last occurence of the code point. + */ + for (next_code = MAX_UCS, uidx = fromlen - 1; + uidx >= 0; uidx--) { + if (from[uidx] >= cur_code && from[uidx] < next_code) { + next_code = from[uidx]; + limit = uidx; + } + } + /* There must be such code point. */ + assert(limit >= 0); + + delta += (next_code - cur_code) * (ucsdone + 1); + cur_code = next_code; + + /* + * Scan the input string again, and encode characters + * whose code point is 'cur_code'. Use 'limit' to avoid + * unnecessary scan. + */ + for (uidx = 0, rest = ucsdone; uidx <= limit; uidx++) { + if (from[uidx] < cur_code) { + delta++; + rest--; + } else if (from[uidx] == cur_code) { + int sz = punycode_putwc(to, tolen, delta, bias); + if (sz == 0) { + r = idn_buffer_overflow; + goto ret; + } + to += sz; + tolen -= sz; + ucsdone++; + bias = punycode_update_bias(delta, ucsdone, + first); + delta = 0; + first = 0; + } + } + delta += rest + 1; + cur_code++; + } + + /* + * Terminate with NUL. + */ + if (tolen <= 0) { + r = idn_buffer_overflow; + goto ret; + } + *to = '\0'; + r = idn_success; + +ret: + if (r == idn_success) { + TRACE(("idn__punycode_encode(): succcess (to=\"%s\")\n", + idn__debug_xstring(to_org, 50))); + } else { + TRACE(("idn__punycode_encode(): %s\n", idn_result_tostring(r))); + } + return (r); +} + +static int +punycode_getwc(const char *s, size_t len, int bias, unsigned long *vp) { + size_t orglen = len; + unsigned long v = 0, w = 1; + int k; + + for (k = PUNYCODE_BASE - bias; len > 0; k += PUNYCODE_BASE) { + int c = *s++; + int t = (k < PUNYCODE_TMIN) ? PUNYCODE_TMIN : + (k > PUNYCODE_TMAX) ? PUNYCODE_TMAX : k; + + len--; + if ('a' <= c && c <= 'z') + c = c - 'a'; + else if ('A' <= c && c <= 'Z') + c = c - 'A'; + else if ('0' <= c && c <= '9') + c = c - '0' + 26; + else + c = -1; + + if (c < 0) + return (0); /* invalid character */ + + v += c * w; + + if (c < t) { + *vp = v; + return (orglen - len); + } + + w *= (PUNYCODE_BASE - t); + } + + return (0); /* final character missing */ +} + +static int +punycode_putwc(char *s, size_t len, unsigned long delta, int bias) { + const char *punycode_base36 = "abcdefghijklmnopqrstuvwxyz0123456789"; + int k; + char *sorg = s; + + for (k = PUNYCODE_BASE - bias; 1; k += PUNYCODE_BASE) { + int t = (k < PUNYCODE_TMIN) ? PUNYCODE_TMIN : + (k > PUNYCODE_TMAX) ? PUNYCODE_TMAX : k; + + if (delta < t) + break; + if (len < 1) + return (0); + *s++ = punycode_base36[t + ((delta - t) % (PUNYCODE_BASE - t))]; + len--; + delta = (delta - t) / (PUNYCODE_BASE - t); + } + if (len < 1) + return (0); + *s++ = punycode_base36[delta]; + return (s - sorg); +} + +static int +punycode_update_bias(unsigned long delta, size_t npoints, int first) { + int k = 0; + + delta /= first ? PUNYCODE_DAMP : 2; + delta += delta / npoints; + + while (delta > ((PUNYCODE_BASE - PUNYCODE_TMIN) * PUNYCODE_TMAX) / 2) { + delta /= PUNYCODE_BASE - PUNYCODE_TMIN; + k++; + } + return (PUNYCODE_BASE * k + + (((PUNYCODE_BASE - PUNYCODE_TMIN + 1) * delta) / + (delta + PUNYCODE_SKEW))); +} diff --git a/contrib/idn/idnkit-1.0-src/lib/race.c b/contrib/idn/idnkit-1.0-src/lib/race.c new file mode 100644 index 0000000..1b44a98 --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/race.c @@ -0,0 +1,427 @@ +#ifndef lint +static char *rcsid = "$Id: race.c,v 1.1.1.1 2003/06/04 00:26:07 marka Exp $"; +#endif + +/* + * Copyright (c) 2000,2001,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 <config.h> + +#include <stddef.h> +#include <stdlib.h> +#include <string.h> + +#include <idn/result.h> +#include <idn/assert.h> +#include <idn/logmacro.h> +#include <idn/converter.h> +#include <idn/ucs4.h> +#include <idn/debug.h> +#include <idn/race.h> +#include <idn/util.h> + +#ifndef IDN_RACE_PREFIX +#define IDN_RACE_PREFIX "bq--" +#endif +#define RACE_2OCTET_MODE 0xd8 +#define RACE_ESCAPE 0xff +#define RACE_ESCAPE_2ND 0x99 + +#define RACE_BUF_SIZE 128 /* more than enough */ + +/* + * Unicode surrogate pair. + */ +#define IS_SURROGATE_HIGH(v) (0xd800 <= (v) && (v) <= 0xdbff) +#define IS_SURROGATE_LOW(v) (0xdc00 <= (v) && (v) <= 0xdfff) +#define SURROGATE_HIGH(v) (SURROGATE_H_OFF + (((v) - 0x10000) >> 10)) +#define SURROGATE_LOW(v) (SURROGATE_L_OFF + ((v) & 0x3ff)) +#define SURROGATE_BASE 0x10000 +#define SURROGATE_H_OFF 0xd800 +#define SURROGATE_L_OFF 0xdc00 +#define COMBINE_SURROGATE(h, l) \ + (SURROGATE_BASE + (((h)-SURROGATE_H_OFF)<<10) + ((l)-SURROGATE_L_OFF)) + +/* + * Compression type. + */ +enum { + compress_one, /* all characters are in a single row */ + compress_two, /* row 0 and another row */ + compress_none /* nope */ +}; + +static idn_result_t race_decode_decompress(const char *from, + unsigned short *buf, + size_t buflen); +static idn_result_t race_compress_encode(const unsigned short *p, + int compress_mode, + char *to, size_t tolen); +static int get_compress_mode(unsigned short *p); + +idn_result_t +idn__race_decode(idn_converter_t ctx, void *privdata, + const char *from, unsigned long *to, size_t tolen) { + unsigned short *buf = NULL; + size_t prefixlen = strlen(IDN_RACE_PREFIX); + size_t fromlen; + size_t buflen; + idn_result_t r; + + assert(ctx != NULL); + + TRACE(("idn__race_decode(from=\"%s\", tolen=%d)\n", + idn__debug_xstring(from, 50), (int)tolen)); + + if (!idn__util_asciihaveaceprefix(from, IDN_RACE_PREFIX)) { + if (*from == '\0') { + r = idn_ucs4_utf8toucs4(from, to, tolen); + goto ret; + } + r = idn_invalid_encoding; + goto ret; + } + from += prefixlen; + fromlen = strlen(from); + + /* + * Allocate sufficient buffer. + */ + buflen = fromlen + 1; + buf = malloc(sizeof(*buf) * buflen); + if (buf == NULL) { + r = idn_nomemory; + goto ret; + } + + /* + * Decode base32 and decompress. + */ + r = race_decode_decompress(from, buf, buflen); + if (r != idn_success) + goto ret; + + /* + * Now 'buf' points the decompressed string, which must contain + * UTF-16 characters. + */ + + /* + * Convert to UCS4. + */ + r = idn_ucs4_utf16toucs4(buf, to, tolen); + if (r != idn_success) + goto ret; + +ret: + free(buf); + if (r == idn_success) { + TRACE(("idn__race_decode(): succcess (to=\"%s\")\n", + idn__debug_ucs4xstring(to, 50))); + } else { + TRACE(("idn__race_decode(): %s\n", idn_result_tostring(r))); + } + return (r); +} + +static idn_result_t +race_decode_decompress(const char *from, unsigned short *buf, size_t buflen) +{ + unsigned short *p = buf; + unsigned int bitbuf = 0; + int bitlen = 0; + int i, j; + size_t len; + + while (*from != '\0') { + int c = *from++; + int x; + + if ('a' <= c && c <= 'z') + x = c - 'a'; + else if ('A' <= c && c <= 'Z') + x = c - 'A'; + else if ('2' <= c && c <= '7') + x = c - '2' + 26; + else + return (idn_invalid_encoding); + + bitbuf = (bitbuf << 5) + x; + bitlen += 5; + if (bitlen >= 8) { + *p++ = (bitbuf >> (bitlen - 8)) & 0xff; + bitlen -= 8; + } + } + len = p - buf; + + /* + * Now 'buf' holds the decoded string. + */ + + /* + * Decompress. + */ + if (buf[0] == RACE_2OCTET_MODE) { + if ((len - 1) % 2 != 0) + return (idn_invalid_encoding); + for (i = 1, j = 0; i < len; i += 2, j++) + buf[j] = (buf[i] << 8) + buf[i + 1]; + len = j; + } else { + unsigned short c = buf[0] << 8; /* higher octet */ + + for (i = 1, j = 0; i < len; j++) { + if (buf[i] == RACE_ESCAPE) { + if (i + 1 >= len) + return (idn_invalid_encoding); + else if (buf[i + 1] == RACE_ESCAPE_2ND) + buf[j] = c | 0xff; + else + buf[j] = buf[i + 1]; + i += 2; + + } else if (buf[i] == 0x99 && c == 0x00) { + /* + * The RACE specification says this is error. + */ + return (idn_invalid_encoding); + + } else { + buf[j] = c | buf[i++]; + } + } + len = j; + } + buf[len] = '\0'; + + return (idn_success); +} + +idn_result_t +idn__race_encode(idn_converter_t ctx, void *privdata, + const unsigned long *from, char *to, size_t tolen) { + char *to_org = to; + unsigned short *p, *buf = NULL; + size_t prefixlen = strlen(IDN_RACE_PREFIX); + size_t buflen; + size_t fromlen; + idn_result_t r; + int compress_mode; + + assert(ctx != NULL); + + TRACE(("idn__race_encode(from=\"%s\", tolen=%d)\n", + idn__debug_ucs4xstring(from, 50), (int)tolen)); + + if (*from == '\0') { + r = idn_ucs4_ucs4toutf8(from, to, tolen); + goto ret; + } else if (idn__util_ucs4haveaceprefix(from, IDN_RACE_PREFIX)) { + r = idn_prohibited; + goto ret; + } + + if (tolen < prefixlen) { + r = idn_buffer_overflow; + goto ret; + } + memcpy(to, IDN_RACE_PREFIX, prefixlen); + to += prefixlen; + tolen -= prefixlen; + + fromlen = idn_ucs4_strlen(from); + buflen = fromlen * 2 + 2; + + /* + * Convert to UTF-16. + * Preserve space for a character at the top of the buffer. + */ + for (;;) { + unsigned short *new_buf; + + new_buf = realloc(buf, sizeof(*buf) * buflen); + if (new_buf == NULL) { + r = idn_nomemory; + goto ret; + } + buf = new_buf; + + r = idn_ucs4_ucs4toutf16(from, buf + 1, buflen - 1); + if (r == idn_success) + break; + else if (r != idn_buffer_overflow) + goto ret; + + buflen = fromlen * 2 + 2; + } + p = buf + 1; + + /* + * Now 'p' contains UTF-16 encoded string. + */ + + /* + * Check U+0099. + * RACE doesn't permit U+0099 in an input string. + */ + for (p = buf + 1; *p != '\0'; p++) { + if (*p == 0x0099) { + r = idn_invalid_encoding; + goto ret; + } + } + + /* + * Compress, encode in base-32 and output. + */ + compress_mode = get_compress_mode(buf + 1); + r = race_compress_encode(buf, compress_mode, to, tolen); + +ret: + free(buf); + if (r == idn_success) { + TRACE(("idn__race_encode(): succcess (to=\"%s\")\n", + idn__debug_xstring(to_org, 50))); + } else { + TRACE(("idn__race_encode(): %s\n", idn_result_tostring(r))); + } + return (r); +} + +static idn_result_t +race_compress_encode(const unsigned short *p, int compress_mode, + char *to, size_t tolen) +{ + unsigned long bitbuf = *p++; /* bit stream buffer */ + int bitlen = 8; /* # of bits in 'bitbuf' */ + + while (*p != '\0' || bitlen > 0) { + unsigned int c = *p; + + if (c == '\0') { + /* End of data. Flush. */ + bitbuf <<= (5 - bitlen); + bitlen = 5; + } else if (compress_mode == compress_none) { + /* Push 16 bit data. */ + bitbuf = (bitbuf << 16) | c; + bitlen += 16; + p++; + } else {/* compress_mode == compress_one/compress_two */ + /* Push 8 or 16 bit data. */ + if (compress_mode == compress_two && + (c & 0xff00) == 0) { + /* Upper octet is zero (and not U1). */ + bitbuf = (bitbuf << 16) | 0xff00 | c; + bitlen += 16; + } else if ((c & 0xff) == 0xff) { + /* Lower octet is 0xff. */ + bitbuf = (bitbuf << 16) | + (RACE_ESCAPE << 8) | RACE_ESCAPE_2ND; + bitlen += 16; + } else { + /* Just output lower octet. */ + bitbuf = (bitbuf << 8) | (c & 0xff); + bitlen += 8; + } + p++; + } + + /* + * Output bits in 'bitbuf' in 5-bit unit. + */ + while (bitlen >= 5) { + int x; + + /* Get top 5 bits. */ + x = (bitbuf >> (bitlen - 5)) & 0x1f; + bitlen -= 5; + + /* Encode. */ + if (x < 26) + x += 'a'; + else + x = (x - 26) + '2'; + + if (tolen < 1) + return (idn_buffer_overflow); + + *to++ = x; + tolen--; + } + } + + if (tolen <= 0) + return (idn_buffer_overflow); + + *to = '\0'; + return (idn_success); +} + +static int +get_compress_mode(unsigned short *p) { + int zero = 0; + unsigned int upper = 0; + unsigned short *modepos = p - 1; + + while (*p != '\0') { + unsigned int hi = *p++ & 0xff00; + + if (hi == 0) { + zero++; + } else if (hi == upper) { + ; + } else if (upper == 0) { + upper = hi; + } else { + *modepos = RACE_2OCTET_MODE; + return (compress_none); + } + } + *modepos = upper >> 8; + if (upper > 0 && zero > 0) + return (compress_two); + else + return (compress_one); +} diff --git a/contrib/idn/idnkit-1.0-src/lib/res.c b/contrib/idn/idnkit-1.0-src/lib/res.c new file mode 100644 index 0000000..cefd0c3 --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/res.c @@ -0,0 +1,1726 @@ +#ifndef lint +static char *rcsid = "$Id: res.c,v 1.1.1.1 2003/06/04 00:26:10 marka Exp $"; +#endif + +/* + * Copyright (c) 2000,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 <config.h> + +#include <stddef.h> +#include <stdlib.h> +#include <string.h> + +#include <idn/result.h> +#include <idn/assert.h> +#include <idn/logmacro.h> +#include <idn/converter.h> +#include <idn/normalizer.h> +#include <idn/checker.h> +#include <idn/mapper.h> +#include <idn/mapselector.h> +#include <idn/delimitermap.h> +#include <idn/resconf.h> +#include <idn/res.h> +#include <idn/util.h> +#include <idn/debug.h> +#include <idn/ucs4.h> + +#ifndef IDN_UTF8_ENCODING_NAME +#define IDN_UTF8_ENCODING_NAME "UTF-8" /* by IANA */ +#endif + +#ifndef WITHOUT_ICONV +#define ENCODE_MASK \ + (IDN_LOCALCONV | IDN_DELIMMAP | IDN_LOCALMAP | IDN_MAP | \ + IDN_NORMALIZE | IDN_PROHCHECK | IDN_UNASCHECK | IDN_BIDICHECK | \ + IDN_ASCCHECK | IDN_IDNCONV | IDN_LENCHECK | IDN_ENCODE_QUERY | \ + IDN_UNDOIFERR) +#define DECODE_MASK \ + (IDN_DELIMMAP | IDN_MAP | IDN_NORMALIZE | IDN_PROHCHECK | \ + IDN_UNASCHECK | IDN_BIDICHECK | IDN_IDNCONV | IDN_ASCCHECK | \ + IDN_RTCHECK | IDN_LOCALCONV | IDN_DECODE_QUERY) +#else +#define ENCODE_MASK \ + (IDN_DELIMMAP | IDN_LOCALMAP | IDN_MAP | IDN_NORMALIZE | \ + IDN_PROHCHECK | IDN_UNASCHECK | IDN_BIDICHECK | IDN_ASCCHECK | \ + IDN_IDNCONV | IDN_LENCHECK | IDN_ENCODE_QUERY | IDN_UNDOIFERR) +#define DECODE_MASK \ + (IDN_DELIMMAP | IDN_MAP | IDN_NORMALIZE | IDN_PROHCHECK | \ + IDN_UNASCHECK | IDN_BIDICHECK | IDN_IDNCONV | IDN_ASCCHECK | \ + IDN_RTCHECK | IDN_DECODE_QUERY) +#endif + +#define MAX_LABEL_LENGTH 63 + +/* + * label to convert. + */ +typedef struct labellist * labellist_t; +struct labellist { + unsigned long *name; + size_t name_length; + unsigned long *undo_name; + labellist_t next; + labellist_t previous; + int dot_followed; +}; + +typedef idn_result_t (*res_insnproc_t)(idn_resconf_t ctx, + labellist_t label); + +static void idn_res_initialize(void); +static idn_result_t copy_verbatim(const char *from, char *to, + size_t tolen); +static idn_result_t labellist_create(const unsigned long *name, + labellist_t *labelp); +static void labellist_destroy(labellist_t label); +static idn_result_t labellist_setname(labellist_t label, + const unsigned long *name); +static const unsigned long * + labellist_getname(labellist_t label); +static const unsigned long * + labellist_gettldname(labellist_t label); +static idn_result_t labellist_getnamelist(labellist_t label, + unsigned long *name, + size_t label_length); +static void labellist_undo(labellist_t label); +static labellist_t labellist_tail(labellist_t label); +static labellist_t labellist_previous(labellist_t label); + +#ifndef WITHOUT_ICONV +static idn_result_t label_localdecodecheck(idn_resconf_t ctx, + labellist_t label); +#endif +static idn_result_t label_idnencode_ace(idn_resconf_t ctx, + labellist_t label); +static idn_result_t label_idndecode(idn_resconf_t ctx, labellist_t label); +static idn_result_t label_localmap(idn_resconf_t ctx, labellist_t label); +static idn_result_t label_map(idn_resconf_t ctx, labellist_t label); +static idn_result_t label_normalize(idn_resconf_t ctx, labellist_t label); +static idn_result_t label_prohcheck(idn_resconf_t ctx, labellist_t label); +static idn_result_t label_unascheck(idn_resconf_t ctx, labellist_t label); +static idn_result_t label_bidicheck(idn_resconf_t ctx, labellist_t label); +static idn_result_t label_asccheck(idn_resconf_t ctx, labellist_t label); +static idn_result_t label_lencheck_ace(idn_resconf_t ctx, + labellist_t label); +static idn_result_t label_lencheck_nonace(idn_resconf_t ctx, + labellist_t label); +static idn_result_t label_rtcheck(idn_resconf_t ctx, idn_action_t actions, + labellist_t label, + const unsigned long *original_name); + +static int initialized; +static int enabled; + +void +idn_res_enable(int on_off) { + if (!initialized) { + idn_res_initialize(); + } + + if (on_off == 0) { + enabled = 0; + } else { + enabled = 1; + } +} + +static void +idn_res_initialize(void) { + if (!initialized) { + char *value = getenv("IDN_DISABLE"); + + if (value == NULL) { + enabled = 1; + } else { + enabled = 0; + } + initialized = 1; + } +} + +idn_result_t +idn_res_encodename(idn_resconf_t ctx, idn_action_t actions, const char *from, + char *to, size_t tolen) { + idn_converter_t local_converter = NULL; + idn_converter_t idn_converter = NULL; + idn_delimitermap_t delimiter_mapper; + idn_result_t r; + labellist_t labels = NULL, l; + unsigned long *buffer = NULL; + size_t buffer_length; + int from_is_root; + int idn_is_ace; + + assert(ctx != NULL && from != NULL && to != NULL); + + TRACE(("idn_res_encodename(actions=%s, from=\"%s\", tolen=%d)\n", + idn__res_actionstostring(actions), + idn__debug_xstring(from, 50), (int)tolen)); + + if (actions & ~ENCODE_MASK) { + WARNING(("idn_res_encodename: invalid actions 0x%x\n", + actions)); + r = idn_invalid_action; + goto ret; + } + + if (!initialized) + idn_res_initialize(); + if (!enabled || actions == 0) { + r = copy_verbatim(from, to, tolen); + goto ret; + } else if (tolen <= 0) { + r = idn_buffer_overflow; + goto ret; + } + + if (actions & IDN_ENCODE_QUERY) { +#ifndef WITHOUT_ICONV + actions |= (IDN_LOCALCONV | IDN_DELIMMAP | IDN_LOCALMAP | \ + IDN_MAP | IDN_NORMALIZE | IDN_PROHCHECK | \ + IDN_BIDICHECK | IDN_IDNCONV | IDN_LENCHECK); +#else + actions |= (IDN_DELIMMAP | IDN_LOCALMAP | IDN_MAP | \ + IDN_NORMALIZE | IDN_PROHCHECK | IDN_BIDICHECK | \ + IDN_IDNCONV | IDN_LENCHECK); +#endif + } + + /* + * Convert `from' to UCS4. + */ + local_converter = idn_resconf_getlocalconverter(ctx); +#ifndef WITHOUT_ICONV + if (local_converter == NULL) { + r = idn_invalid_name; + goto ret; + } +#endif + + idn_converter = idn_resconf_getidnconverter(ctx); + if (idn_converter != NULL && + idn_converter_isasciicompatible(idn_converter)) + idn_is_ace = 1; + else + idn_is_ace = 0; + + buffer_length = tolen * 2; + + for (;;) { + void *new_buffer; + + new_buffer = realloc(buffer, sizeof(*buffer) * buffer_length); + if (new_buffer == NULL) { + r = idn_nomemory; + goto ret; + } + buffer = (unsigned long *)new_buffer; + + if (actions & IDN_LOCALCONV) { + r = idn_converter_convtoucs4(local_converter, from, + buffer, buffer_length); + } else { + r = idn_ucs4_utf8toucs4(from, buffer, buffer_length); + } + if (r == idn_success) + break; + else if (r != idn_buffer_overflow) + goto ret; + + buffer_length *= 2; + } + + if (*buffer == '\0') { + if (tolen <= 0) { + r = idn_buffer_overflow; + goto ret; + } + *to = '\0'; + r = idn_success; + goto ret; + } + + /* + * Delimiter map. + */ + if (actions & IDN_DELIMMAP) { + TRACE(("res delimitermap(name=\"%s\")\n", + idn__debug_ucs4xstring(buffer, 50))); + + delimiter_mapper = idn_resconf_getdelimitermap(ctx); + if (delimiter_mapper != NULL) { + r = idn_delimitermap_map(delimiter_mapper, buffer, + buffer, buffer_length); + idn_delimitermap_destroy(delimiter_mapper); + if (r != idn_success) + goto ret; + } + TRACE(("res delimitermap(): success (name=\"%s\")\n", + idn__debug_ucs4xstring(buffer, 50))); + } + + from_is_root = (buffer[0] == '.' && buffer[1] == '\0'); + + /* + * Split the name into a list of labels. + */ + r = labellist_create(buffer, &labels); + if (r != idn_success) + goto ret; + + /* + * Perform conversions and tests. + */ + for (l = labellist_tail(labels); l != NULL; + l = labellist_previous(l)) { + + if (!idn__util_ucs4isasciirange(labellist_getname(l))) { + if (actions & IDN_LOCALMAP) { + r = label_localmap(ctx, l); + if (r != idn_success) + goto ret; + } + } + + if (!idn__util_ucs4isasciirange(labellist_getname(l))) { + if (actions & IDN_MAP) { + r = label_map(ctx, l); + if (r != idn_success) + goto ret; + } + if (actions & IDN_NORMALIZE) { + r = label_normalize(ctx, l); + if (r != idn_success) + goto ret; + } + if (actions & IDN_PROHCHECK) { + r = label_prohcheck(ctx, l); + if (r == idn_prohibited && + (actions & IDN_UNDOIFERR)) { + labellist_undo(l); + continue; + } else if (r != idn_success) { + goto ret; + } + } + if (actions & IDN_UNASCHECK) { + r = label_unascheck(ctx, l); + if (r == idn_prohibited && + (actions & IDN_UNDOIFERR)) { + labellist_undo(l); + continue; + } else if (r != idn_success) { + goto ret; + } + } + if (actions & IDN_BIDICHECK) { + r = label_bidicheck(ctx, l); + if (r == idn_prohibited && + (actions & IDN_UNDOIFERR)) { + labellist_undo(l); + continue; + } else if (r != idn_success) { + goto ret; + } + } + } + + if (actions & IDN_ASCCHECK) { + r = label_asccheck(ctx, l); + if (r == idn_prohibited && (actions & IDN_UNDOIFERR)) { + labellist_undo(l); + continue; + } else if (r != idn_success) { + goto ret; + } + } + + if (!idn__util_ucs4isasciirange(labellist_getname(l))) { + if ((actions & IDN_IDNCONV) && idn_is_ace) { + r = label_idnencode_ace(ctx, l); + if (r != idn_success) + goto ret; + } + } + + if (!from_is_root && (actions & IDN_LENCHECK)) { + if (idn_is_ace) + r = label_lencheck_ace(ctx, l); + else + r = label_lencheck_nonace(ctx, l); + if (r == idn_invalid_length && + (actions & IDN_UNDOIFERR)) { + labellist_undo(l); + continue; + } else if (r != idn_success) { + goto ret; + } + } + } + + /* + * Concat a list of labels to a name. + */ + for (;;) { + void *new_buffer; + + new_buffer = realloc(buffer, sizeof(*buffer) * buffer_length); + if (new_buffer == NULL) { + r = idn_nomemory; + goto ret; + } + buffer = (unsigned long *)new_buffer; + + r = labellist_getnamelist(labels, buffer, buffer_length); + if (r == idn_success) + break; + else if (r != idn_buffer_overflow) + goto ret; + + buffer_length *= 2; + } + + if ((actions & IDN_IDNCONV) && idn_converter != NULL && !idn_is_ace) { + r = idn_converter_convfromucs4(idn_converter, buffer, to, + tolen); + } else { + r = idn_ucs4_ucs4toutf8(buffer, to, tolen); + } + +ret: + if (r == idn_success) { + TRACE(("idn_res_encodename(): success (to=\"%s\")\n", + idn__debug_xstring(to, 50))); + } else { + TRACE(("idn_res_encodename(): %s\n", idn_result_tostring(r))); + } + free(buffer); + if (local_converter != NULL) + idn_converter_destroy(local_converter); + if (idn_converter != NULL) + idn_converter_destroy(idn_converter); + if (labels != NULL) + labellist_destroy(labels); + return (r); +} + +idn_result_t +idn_res_decodename(idn_resconf_t ctx, idn_action_t actions, const char *from, + char *to, size_t tolen) { + idn_converter_t local_converter = NULL; + idn_converter_t idn_converter = NULL; + idn_delimitermap_t delimiter_mapper; + idn_result_t r; + labellist_t labels = NULL, l; + unsigned long *buffer = NULL; + unsigned long *saved_name = NULL; + size_t buffer_length; + int idn_is_ace; + + assert(ctx != NULL && from != NULL && to != NULL); + + TRACE(("idn_res_decodename(actions=%s, from=\"%s\", tolen=%d)\n", + idn__res_actionstostring(actions), + idn__debug_xstring(from, 50), (int)tolen)); + + if (actions & ~DECODE_MASK) { + WARNING(("idn_res_decodename: invalid actions 0x%x\n", + actions)); + r = idn_invalid_action; + goto ret; + } + + if (!initialized) + idn_res_initialize(); + if (!enabled || actions == 0) { + r = copy_verbatim(from, to, tolen); + goto ret; + } else if (tolen <= 0) { + r = idn_buffer_overflow; + goto ret; + } + + if (actions & IDN_DECODE_QUERY) { +#ifndef WITHOUT_ICONV + actions |= (IDN_DELIMMAP | IDN_MAP | IDN_NORMALIZE | \ + IDN_PROHCHECK | IDN_BIDICHECK | IDN_IDNCONV | \ + IDN_RTCHECK | IDN_LOCALCONV); +#else + actions |= (IDN_DELIMMAP | IDN_MAP | IDN_NORMALIZE | \ + IDN_PROHCHECK | IDN_BIDICHECK | IDN_IDNCONV | \ + IDN_RTCHECK); +#endif + } + + /* + * Convert `from' to UCS4. + */ + local_converter = idn_resconf_getlocalconverter(ctx); +#ifndef WITHOUT_ICONV + if (local_converter == NULL) { + r = idn_invalid_name; + goto ret; + } +#endif + + idn_converter = idn_resconf_getidnconverter(ctx); + if (idn_converter != NULL && + idn_converter_isasciicompatible(idn_converter)) + idn_is_ace = 1; + else + idn_is_ace = 0; + + buffer_length = tolen * 2; + + TRACE(("res idndecode(name=\"%s\")\n", idn__debug_xstring(from, 50))); + + for (;;) { + void *new_buffer; + + new_buffer = realloc(buffer, sizeof(*buffer) * buffer_length); + if (new_buffer == NULL) { + r = idn_nomemory; + goto ret; + } + buffer = (unsigned long *)new_buffer; + + if ((actions & IDN_IDNCONV) && + idn_converter != NULL && !idn_is_ace) { + r = idn_converter_convtoucs4(idn_converter, from, + buffer, buffer_length); + } else { + r = idn_ucs4_utf8toucs4(from, buffer, buffer_length); + } + if (r == idn_success) + break; + else if (r != idn_buffer_overflow) + goto ret; + + buffer_length *= 2; + } + + if (*buffer == '\0') { + if (tolen <= 0) { + r = idn_buffer_overflow; + goto ret; + } + *to = '\0'; + r = idn_success; + goto ret; + } + + /* + * Delimiter map. + */ + if (actions & IDN_DELIMMAP) { + TRACE(("res delimitermap(name=\"%s\")\n", + idn__debug_ucs4xstring(buffer, 50))); + + delimiter_mapper = idn_resconf_getdelimitermap(ctx); + if (delimiter_mapper != NULL) { + r = idn_delimitermap_map(delimiter_mapper, buffer, + buffer, buffer_length); + idn_delimitermap_destroy(delimiter_mapper); + if (r != idn_success) + goto ret; + } + TRACE(("res delimitermap(): success (name=\"%s\")\n", + idn__debug_ucs4xstring(buffer, 50))); + } + + /* + * Split the name into a list of labels. + */ + r = labellist_create(buffer, &labels); + if (r != idn_success) + goto ret; + + /* + * Perform conversions and tests. + */ + for (l = labellist_tail(labels); l != NULL; + l = labellist_previous(l)) { + + free(saved_name); + saved_name = NULL; + + if (!idn__util_ucs4isasciirange(labellist_getname(l))) { + if (actions & IDN_MAP) { + r = label_map(ctx, l); + if (r != idn_success) + goto ret; + } + if (actions & IDN_NORMALIZE) { + r = label_normalize(ctx, l); + if (r != idn_success) + goto ret; + } + if (actions & IDN_PROHCHECK) { + r = label_prohcheck(ctx, l); + if (r == idn_prohibited) { + labellist_undo(l); + continue; + } else if (r != idn_success) { + goto ret; + } + } + if (actions & IDN_UNASCHECK) { + r = label_unascheck(ctx, l); + if (r == idn_prohibited) { + labellist_undo(l); + continue; + } else if (r != idn_success) { + goto ret; + } + } + if (actions & IDN_BIDICHECK) { + r = label_bidicheck(ctx, l); + if (r == idn_prohibited) { + labellist_undo(l); + continue; + } else if (r != idn_success) { + goto ret; + } + } + } + + if ((actions & IDN_IDNCONV) && idn_is_ace) { + saved_name = idn_ucs4_strdup(labellist_getname(l)); + if (saved_name == NULL) { + r = idn_nomemory; + goto ret; + } + r = label_idndecode(ctx, l); + if (r == idn_invalid_encoding) { + labellist_undo(l); + continue; + } else if (r != idn_success) { + goto ret; + } + } + if ((actions & IDN_RTCHECK) && saved_name != NULL) { + r = label_rtcheck(ctx, actions, l, saved_name); + if (r == idn_invalid_encoding) { + labellist_undo(l); + continue; + } else if (r != idn_success) { + goto ret; + } + } + +#ifndef WITHOUT_ICONV + if (actions & IDN_LOCALCONV) { + r = label_localdecodecheck(ctx, l); + if (r != idn_success) + goto ret; + } +#endif + } + + /* + * Concat a list of labels to a name. + */ + for (;;) { + void *new_buffer; + + new_buffer = realloc(buffer, sizeof(*buffer) * buffer_length); + if (new_buffer == NULL) { + r = idn_nomemory; + goto ret; + } + buffer = (unsigned long *)new_buffer; + + r = labellist_getnamelist(labels, buffer, buffer_length); + if (r == idn_success) + break; + else if (r != idn_buffer_overflow) + goto ret; + + buffer_length *= 2; + } + + if (actions & IDN_LOCALCONV) { + r = idn_converter_convfromucs4(local_converter, buffer, to, + tolen); + } else { + r = idn_ucs4_ucs4toutf8(buffer, to, tolen); + } + +ret: + if (r == idn_success) { + TRACE(("idn_res_decodename(): success (to=\"%s\")\n", + idn__debug_xstring(to, 50))); + } else { + TRACE(("idn_res_decodename(): %s\n", idn_result_tostring(r))); + } + free(saved_name); + free(buffer); + if (local_converter != NULL) + idn_converter_destroy(local_converter); + if (idn_converter != NULL) + idn_converter_destroy(idn_converter); + if (labels != NULL) + labellist_destroy(labels); + return (r); +} + +idn_result_t +idn_res_decodename2(idn_resconf_t ctx, idn_action_t actions, const char *from, + char *to, size_t tolen, const char *auxencoding) { +#ifdef WITHOUT_ICONV + return idn_failure; + +#else /* WITHOUT_ICONV */ + idn_result_t r; + idn_converter_t aux_converter = NULL; + unsigned long *buffer_ucs4 = NULL; + char *buffer_utf8 = NULL; + size_t buffer_length; + + assert(ctx != NULL && from != NULL && to != NULL); + + TRACE(("idn_res_decodename2(actions=%s, from=\"%s\", tolen=%d, " + "auxencoding=\"%s\")\n", + idn__res_actionstostring(actions), + idn__debug_xstring(from, 50), (int)tolen, + (auxencoding != NULL) ? auxencoding : "<null>")); + + if (!initialized) + idn_res_initialize(); + if (!enabled || actions == 0) { + r = copy_verbatim(from, to, tolen); + goto ret; + } else if (tolen <= 0) { + r = idn_buffer_overflow; + goto ret; + } + + if (auxencoding == NULL || + strcmp(auxencoding, IDN_UTF8_ENCODING_NAME) == 0 || + strcmp(auxencoding, "UTF-8") == 0) { + return idn_res_decodename(ctx, actions, from, to, tolen); + } + + /* + * Convert `from' to UCS4. + */ + r = idn_resconf_setauxidnconvertername(ctx, auxencoding, + IDN_CONVERTER_DELAYEDOPEN); + if (r != idn_success) { + goto ret; + } + + aux_converter = idn_resconf_getauxidnconverter(ctx); + if (aux_converter == NULL) { + r = idn_failure; + goto ret; + } + + buffer_length = tolen * 2; + for (;;) { + void *new_buffer; + + new_buffer = realloc(buffer_ucs4, + sizeof(*buffer_ucs4) * buffer_length); + if (new_buffer == NULL) { + r = idn_nomemory; + goto ret; + } + buffer_ucs4 = (unsigned long *)new_buffer; + + r = idn_converter_convtoucs4(aux_converter, from, + buffer_ucs4, + buffer_length); + if (r == idn_success) + break; + else if (r != idn_buffer_overflow) + goto ret; + + buffer_length *= 2; + } + + if (*buffer_ucs4 == '\0') { + if (tolen <= 0) { + r = idn_buffer_overflow; + goto ret; + } + *to = '\0'; + r = idn_success; + goto ret; + } + + /* + * Convert `buffer_ucs4' to UTF-8. + */ + buffer_length = tolen * 2; + for (;;) { + void *new_buffer; + + new_buffer = realloc(buffer_utf8, + sizeof(*buffer_utf8) * buffer_length); + if (new_buffer == NULL) { + r = idn_nomemory; + goto ret; + } + buffer_utf8 = (char *)new_buffer; + r = idn_ucs4_ucs4toutf8(buffer_ucs4, buffer_utf8, + buffer_length); + + if (r == idn_success) + break; + else if (r != idn_buffer_overflow) + goto ret; + + buffer_length *= 2; + } + + if (*buffer_utf8 == '\0') { + if (tolen <= 0) { + r = idn_buffer_overflow; + goto ret; + } + *to = '\0'; + r = idn_success; + goto ret; + } + + r = idn_res_decodename(ctx, actions, buffer_utf8, to, tolen); + +ret: + if (r == idn_success) { + TRACE(("idn_res_decodename2(): success (to=\"%s\")\n", + idn__debug_xstring(to, 50))); + } else { + TRACE(("idn_res_decodename2(): %s\n", idn_result_tostring(r))); + } + free(buffer_ucs4); + free(buffer_utf8); + if (aux_converter != NULL) + idn_converter_destroy(aux_converter); + + return (r); + +#endif /* WITHOUT_ICONV */ +} + +static idn_result_t +copy_verbatim(const char *from, char *to, size_t tolen) { + size_t fromlen = strlen(from); + + if (fromlen + 1 > tolen) + return (idn_buffer_overflow); + (void)memcpy(to, from, fromlen + 1); + return (idn_success); +} + +static idn_result_t +labellist_create(const unsigned long *name, labellist_t *labelp) { + size_t length, malloc_length; + labellist_t head_label = NULL; + labellist_t tail_label = NULL; + labellist_t new_label = NULL; + const unsigned long *endp = NULL; + idn_result_t r; + + while (*name != '\0') { + for (endp = name; *endp != '.' && *endp != '\0'; endp++) + ; /* nothing to be done */ + length = (endp - name) + 1; + malloc_length = length + 15; /* add 15 for margin */ + + new_label = (labellist_t) + malloc(sizeof(struct labellist)); + if (new_label == NULL) { + r = idn_nomemory; + goto ret; + } + if (head_label == NULL) + head_label = new_label; + + new_label->name = NULL; + new_label->undo_name = NULL; + new_label->name_length = malloc_length; + new_label->next = NULL; + new_label->previous = NULL; + new_label->dot_followed = (*endp == '.'); + + new_label->name = (unsigned long *) + malloc(sizeof(long) * malloc_length); + if (new_label->name == NULL) { + r = idn_nomemory; + goto ret; + } + memcpy(new_label->name, name, sizeof(long) * length); + *(new_label->name + length - 1) = '\0'; + + new_label->undo_name = (unsigned long *) + malloc(sizeof(long) * malloc_length); + if (new_label->undo_name == NULL) { + r = idn_nomemory; + goto ret; + } + memcpy(new_label->undo_name, name, sizeof(long) * length); + *(new_label->undo_name + length - 1) = '\0'; + + if (tail_label != NULL) { + tail_label->next = new_label; + new_label->previous = tail_label; + } + tail_label = new_label; + + if (*endp == '.') + name = endp + 1; + else + name = endp; + } + + *labelp = head_label; + r = idn_success; + +ret: + if (r != idn_success) { + if (new_label != NULL) { + free(new_label->name); + free(new_label->undo_name); + free(new_label); + } + if (head_label != NULL) + labellist_destroy(head_label); + } + return (r); +} + + +static void +labellist_destroy(labellist_t label) { + labellist_t l, l_next; + + for (l = label; l != NULL; l = l_next) { + l_next = l->next; + free(l->name); + free(l->undo_name); + free(l); + } +} + +static idn_result_t +labellist_setname(labellist_t label, const unsigned long *name) { + unsigned long *new_name; + size_t length, new_length; + + length = idn_ucs4_strlen(name) + 1; + new_length = length + 15; /* add 15 for margin */ + + if (label->name_length < new_length) { + new_name = (unsigned long *) + realloc(label->name, sizeof(long) * new_length); + if (new_name == NULL) + return (idn_nomemory); + label->name = new_name; + label->name_length = new_length; + } + memcpy(label->name, name, sizeof(long) * length); + + return (idn_success); +} + +static const unsigned long * +labellist_getname(labellist_t label) { + return (label->name); +} + +static const unsigned long * +labellist_gettldname(labellist_t label) { + labellist_t l; + + if (label->previous == NULL && label->next == NULL && + !label->dot_followed) + return (idn_mapselector_getnotld()); + + for (l = label; l->next != NULL; l = l->next) + ; /* nothing to be done */ + + return (l->name); +} + +static idn_result_t +labellist_getnamelist(labellist_t label, unsigned long *name, + size_t name_length) { + static const unsigned long dot_string[] = {0x002e, 0x0000}; /* "." */ + size_t length; + labellist_t l; + + for (l = label, length = 0; l != NULL; l = l->next) + length += idn_ucs4_strlen(l->name) + 1; /* name + `.' */ + length++; /* for NUL */ + + if (name_length < length) + return (idn_buffer_overflow); + + *name = '\0'; + for (l = label; l != NULL; l = l->next) { + idn_ucs4_strcat(name, l->name); + name += idn_ucs4_strlen(name); + if (l->dot_followed) + idn_ucs4_strcat(name, dot_string); + } + return (idn_success); +} + +static void +labellist_undo(labellist_t label) { + size_t length; + + length = idn_ucs4_strlen(label->undo_name) + 1; + memcpy(label->name, label->undo_name, sizeof(long) * length); +} + +static labellist_t +labellist_tail(labellist_t label) { + labellist_t l; + + if (label == NULL) + return (NULL); + for (l = label; l->next != NULL; l = l->next) + ; /* nothing to be done */ + return (l); +} + +static labellist_t +labellist_previous(labellist_t label) { + return (label->previous); +} + +#ifndef WITHOUT_ICONV + +static idn_result_t +label_localdecodecheck(idn_resconf_t ctx, labellist_t label) { + idn_converter_t local_converter = NULL; + const unsigned long *from; + char *to = NULL; + size_t to_length; + idn_result_t r; + + from = labellist_getname(label); + to_length = idn_ucs4_strlen(from) + 1 + 15; /* 15 for margin */ + TRACE(("res ucs4tolocal_check(label=\"%s\")\n", + idn__debug_ucs4xstring(from, 50))); + + local_converter = idn_resconf_getlocalconverter(ctx); + if (local_converter == NULL) { + r = idn_success; + goto ret; + } + + for (;;) { + char *new_buffer; + + new_buffer = (char *)realloc(to, to_length); + if (new_buffer == NULL) { + r = idn_nomemory; + goto ret; + } + to = new_buffer; + r = idn_converter_convfromucs4(local_converter, from, to, + to_length); + if (r == idn_success) + break; + else if (r == idn_nomapping) { + r = label_idnencode_ace(ctx, label); + if (r != idn_success) + goto ret; + break; + } else if (r != idn_buffer_overflow) { + goto ret; + } + to_length *= 2; + } + + r = idn_success; +ret: + TRACE(("res ucs4tolocal_check(): %s\n", idn_result_tostring(r))); + if (local_converter != NULL) + idn_converter_destroy(local_converter); + free(to); + return (r); +} + +#endif /* !WITHOUT_ICONV */ + +static idn_result_t +label_idndecode(idn_resconf_t ctx, labellist_t label) { + idn_converter_t idn_converter = NULL; + const unsigned long *from; + char *ascii_from = NULL; + unsigned long *to = NULL; + size_t from_length, to_length; + idn_result_t r; + + from = labellist_getname(label); + from_length = idn_ucs4_strlen(from) + 1; + TRACE(("res idntoucs4(label=\"%s\")\n", + idn__debug_ucs4xstring(from, 50))); + + idn_converter = idn_resconf_getidnconverter(ctx); + if (idn_converter == NULL) { + r = idn_success; + goto ret; + } + + for (;;) { + char *new_buffer; + + new_buffer = (char *) realloc(ascii_from, from_length); + if (new_buffer == NULL) { + r = idn_nomemory; + goto ret; + } + ascii_from = new_buffer; + r = idn_ucs4_ucs4toutf8(from, ascii_from, from_length); + if (r == idn_success) + break; + else if (r != idn_buffer_overflow) + goto ret; + from_length *= 2; + } + + to = NULL; + to_length = from_length; + + for (;;) { + unsigned long *new_buffer; + + new_buffer = (unsigned long *) + realloc(to, sizeof(long) * to_length); + if (new_buffer == NULL) { + r = idn_nomemory; + goto ret; + } + to = new_buffer; + r = idn_converter_convtoucs4(idn_converter, ascii_from, to, + to_length); + if (r == idn_success) + break; + else if (r != idn_buffer_overflow) + goto ret; + to_length *= 2; + } + + r = labellist_setname(label, to); +ret: + if (r == idn_success) { + TRACE(("res idntoucs4(): success (label=\"%s\")\n", + idn__debug_ucs4xstring(labellist_getname(label), + 50))); + } else { + TRACE(("res idntoucs4(): %s\n", idn_result_tostring(r))); + } + if (idn_converter != NULL) + idn_converter_destroy(idn_converter); + free(to); + free(ascii_from); + return (r); +} + +static idn_result_t +label_idnencode_ace(idn_resconf_t ctx, labellist_t label) { + idn_converter_t idn_converter = NULL; + const unsigned long *from; + char *ascii_to = NULL; + unsigned long *to = NULL; + size_t to_length; + idn_result_t r; + + from = labellist_getname(label); + TRACE(("res ucs4toidn(label=\"%s\")\n", + idn__debug_ucs4xstring(from, 50))); + + idn_converter = idn_resconf_getidnconverter(ctx); + if (idn_converter == NULL) { + r = idn_success; + goto ret; + } + + ascii_to = NULL; + to_length = idn_ucs4_strlen(from) * 4 + 16; /* add mergin */ + + for (;;) { + char *new_buffer; + + new_buffer = (char *) realloc(ascii_to, to_length); + if (new_buffer == NULL) { + r = idn_nomemory; + goto ret; + } + ascii_to = new_buffer; + r = idn_converter_convfromucs4(idn_converter, from, ascii_to, + to_length); + if (r == idn_success) + break; + else if (r != idn_buffer_overflow) + goto ret; + to_length *= 2; + } + + for (;;) { + unsigned long *new_buffer; + + new_buffer = (unsigned long *) + realloc(to, sizeof(long) * to_length); + if (new_buffer == NULL) { + r = idn_nomemory; + goto ret; + } + to = new_buffer; + r = idn_ucs4_utf8toucs4(ascii_to, to, to_length); + if (r == idn_success) + break; + else if (r != idn_buffer_overflow) + goto ret; + to_length *= 2; + } + + if (r != idn_success) + goto ret; + + r = labellist_setname(label, to); +ret: + if (r == idn_success) { + TRACE(("res ucs4toidn(): success (label=\"%s\")\n", + idn__debug_ucs4xstring(labellist_getname(label), + 50))); + } else { + TRACE(("res ucs4toidn(): %s\n", idn_result_tostring(r))); + } + if (idn_converter != NULL) + idn_converter_destroy(idn_converter); + free(to); + free(ascii_to); + return (r); +} + +static idn_result_t +label_localmap(idn_resconf_t ctx, labellist_t label) { + const unsigned long *from; + const unsigned long *tld; + unsigned long *to = NULL; + size_t to_length; + idn_mapselector_t local_mapper; + idn_result_t r; + + from = labellist_getname(label); + tld = labellist_gettldname(label); + TRACE(("res localmap(label=\"%s\", tld=\"%s\")\n", + idn__debug_ucs4xstring(from, 50), + idn__debug_ucs4xstring(tld, 50))); + + local_mapper = idn_resconf_getlocalmapselector(ctx); + if (local_mapper == NULL) { + r = idn_success; + goto ret; + } + + if (tld == from) + tld = idn_mapselector_getdefaulttld(); + to_length = idn_ucs4_strlen(from) + 1 + 15; /* 15 for margin */ + + for (;;) { + unsigned long *new_buffer; + + new_buffer = (unsigned long *) + realloc(to, sizeof(long) * to_length); + if (new_buffer == NULL) { + r = idn_nomemory; + goto ret; + } + to = new_buffer; + r = idn_mapselector_map2(local_mapper, from, tld, to, + to_length); + if (r == idn_success) + break; + else if (r != idn_buffer_overflow) + goto ret; + to_length *= 2; + } + + r = labellist_setname(label, to); +ret: + if (r == idn_success) { + TRACE(("res localmap(): success (label=\"%s\")\n", + idn__debug_ucs4xstring(labellist_getname(label), + 50))); + } else { + TRACE(("res localmap(): %s\n", idn_result_tostring(r))); + } + if (local_mapper != NULL) + idn_mapselector_destroy(local_mapper); + free(to); + return (r); +} + +static idn_result_t +label_map(idn_resconf_t ctx, labellist_t label) { + const unsigned long *from; + unsigned long *to = NULL; + size_t to_length; + idn_mapper_t mapper; + idn_result_t r; + + from = labellist_getname(label); + TRACE(("res map(label=\"%s\")\n", idn__debug_ucs4xstring(from, 50))); + + mapper = idn_resconf_getmapper(ctx); + if (mapper == NULL) { + r = idn_success; + goto ret; + } + to_length = idn_ucs4_strlen(from) + 1 + 15; /* 15 for margin */ + + for (;;) { + unsigned long *new_buffer; + + new_buffer = (unsigned long *) + realloc(to, sizeof(long) * to_length); + if (new_buffer == NULL) { + r = idn_nomemory; + goto ret; + } + to = new_buffer; + r = idn_mapper_map(mapper, from, to, to_length); + if (r == idn_success) + break; + else if (r != idn_buffer_overflow) + goto ret; + to_length *= 2; + } + + r = labellist_setname(label, to); +ret: + if (r == idn_success) { + TRACE(("res map(): success (label=\"%s\")\n", + idn__debug_ucs4xstring(labellist_getname(label), + 50))); + } else { + TRACE(("res map(): %s\n", idn_result_tostring(r))); + } + if (mapper != NULL) + idn_mapper_destroy(mapper); + free(to); + return (r); +} + +static idn_result_t +label_normalize(idn_resconf_t ctx, labellist_t label) { + const unsigned long *from; + unsigned long *to = NULL; + size_t to_length; + idn_normalizer_t normalizer; + idn_result_t r; + + from = labellist_getname(label); + TRACE(("res normalzie(label=\"%s\")\n", + idn__debug_ucs4xstring(from, 50))); + + normalizer = idn_resconf_getnormalizer(ctx); + if (normalizer == NULL) { + r = idn_success; + goto ret; + } + to_length = idn_ucs4_strlen(from) + 1 + 15; /* 15 for margin */ + + for (;;) { + unsigned long *new_buffer; + + new_buffer = (unsigned long *) + realloc(to, sizeof(long) * to_length); + if (new_buffer == NULL) { + r = idn_nomemory; + goto ret; + } + to = new_buffer; + r = idn_normalizer_normalize(normalizer, from, to, to_length); + if (r == idn_success) + break; + else if (r != idn_buffer_overflow) + goto ret; + to_length *= 2; + } + + r = labellist_setname(label, to); +ret: + if (r == idn_success) { + TRACE(("res normalize(): success (label=\"%s\")\n", + idn__debug_ucs4xstring(labellist_getname(label), + 50))); + } else { + TRACE(("res normalize(): %s\n", idn_result_tostring(r))); + } + if (normalizer != NULL) + idn_normalizer_destroy(normalizer); + free(to); + return (r); +} + +static idn_result_t +label_prohcheck(idn_resconf_t ctx, labellist_t label) { + const unsigned long *name, *found; + idn_checker_t prohibit_checker; + idn_result_t r; + + name = labellist_getname(label); + TRACE(("res prohcheck(label=\"%s\")\n", + idn__debug_ucs4xstring(name, 50))); + + prohibit_checker = idn_resconf_getprohibitchecker(ctx); + if (prohibit_checker == NULL) { + r = idn_success; + goto ret; + } + + r = idn_checker_lookup(prohibit_checker, name, &found); + idn_checker_destroy(prohibit_checker); + if (r == idn_success && found != NULL) + r = idn_prohibited; + +ret: + TRACE(("res prohcheck(): %s\n", idn_result_tostring(r))); + return (r); +} + +static idn_result_t +label_unascheck(idn_resconf_t ctx, labellist_t label) { + const unsigned long *name, *found; + idn_checker_t unassigned_checker; + idn_result_t r; + + name = labellist_getname(label); + TRACE(("res unascheck(label=\"%s\")\n", + idn__debug_ucs4xstring(name, 50))); + + unassigned_checker = idn_resconf_getunassignedchecker(ctx); + if (unassigned_checker == NULL) { + r = idn_success; + goto ret; + } + + r = idn_checker_lookup(unassigned_checker, name, &found); + idn_checker_destroy(unassigned_checker); + if (r == idn_success && found != NULL) + r = idn_prohibited; + +ret: + TRACE(("res unascheck(): %s\n", idn_result_tostring(r))); + return (r); +} + +static idn_result_t +label_bidicheck(idn_resconf_t ctx, labellist_t label) { + const unsigned long *name, *found; + idn_checker_t bidi_checker; + idn_result_t r; + + name = labellist_getname(label); + TRACE(("res bidicheck(label=\"%s\")\n", + idn__debug_ucs4xstring(name, 50))); + + bidi_checker = idn_resconf_getbidichecker(ctx); + if (bidi_checker == NULL) { + r = idn_success; + goto ret; + } + + r = idn_checker_lookup(bidi_checker, name, &found); + idn_checker_destroy(bidi_checker); + if (r == idn_success && found != NULL) + r = idn_prohibited; + +ret: + TRACE(("res bidicheck(): %s\n", idn_result_tostring(r))); + return (r); +} + +static idn_result_t +label_asccheck(idn_resconf_t ctx, labellist_t label) { + const unsigned long *name, *n; + idn_result_t r; + + name = labellist_getname(label); + TRACE(("res asccheck(label=\"%s\")\n", + idn__debug_ucs4xstring(name, 50))); + + if (*name == '-') { + r = idn_prohibited; + goto ret; + } + + for (n = name; *n != '\0'; n++) { + if (*n <= '\177') { + if ((*n < '0' || *n > '9') && + (*n < 'A' || *n > 'Z') && + (*n < 'a' || *n > 'z') && + *n != '-') { + r = idn_prohibited; + goto ret; + } + } + } + + if (n > name && *(n - 1) == '-') { + r = idn_prohibited; + goto ret; + } + + r = idn_success; +ret: + TRACE(("res asccheck(): %s\n", idn_result_tostring(r))); + return (r); +} + +static idn_result_t +label_lencheck_ace(idn_resconf_t ctx, labellist_t label) { + const unsigned long *name; + size_t name_length; + idn_result_t r; + + name = labellist_getname(label); + name_length = idn_ucs4_strlen(name); + TRACE(("res lencheck(label=\"%s\")\n", + idn__debug_ucs4xstring(name, 50))); + + if (name_length == 0 || name_length > MAX_LABEL_LENGTH) { + r = idn_invalid_length; + goto ret; + } + + r = idn_success; +ret: + TRACE(("res lencheck(): %s\n", idn_result_tostring(r))); + return (r); +} + +static idn_result_t +label_lencheck_nonace(idn_resconf_t ctx, labellist_t label) { + idn_converter_t idn_converter; + const unsigned long *from; + size_t to_length; + idn_result_t r; + char *buffer = NULL; + size_t buffer_length; + + from = labellist_getname(label); + TRACE(("res lencheck(label=\"%s\")\n", + idn__debug_ucs4xstring(from, 50))); + + buffer_length = idn_ucs4_strlen(from) * 4 + 16; /* 16 for margin */ + idn_converter = idn_resconf_getidnconverter(ctx); + + for (;;) { + void *new_buffer; + + new_buffer = realloc(buffer, sizeof(*buffer) * buffer_length); + if (new_buffer == NULL) { + r = idn_nomemory; + goto ret; + } + buffer = (char *)new_buffer; + + if (idn_converter != NULL) { + r = idn_converter_convfromucs4(idn_converter, from, + buffer, buffer_length); + } else { + r = idn_ucs4_ucs4toutf8(from, buffer, buffer_length); + } + if (r == idn_success) + break; + else if (r != idn_buffer_overflow) + goto ret; + + buffer_length *= 2; + } + + to_length = strlen(buffer); + if (to_length == 0 || to_length > MAX_LABEL_LENGTH) { + r = idn_invalid_length; + goto ret; + } + + r = idn_success; +ret: + TRACE(("res lencheck(): %s\n", idn_result_tostring(r))); + if (idn_converter != NULL) + idn_converter_destroy(idn_converter); + free(buffer); + return (r); +} + +static idn_result_t +label_rtcheck(idn_resconf_t ctx, idn_action_t actions, labellist_t label, + const unsigned long *original_name) { + labellist_t rt_label = NULL; + const unsigned long *rt_name; + const unsigned long *cur_name; + idn_result_t r; + + cur_name = labellist_getname(label); + TRACE(("res rtcheck(label=\"%s\", org_label=\"%s\")\n", + idn__debug_ucs4xstring(cur_name, 50), + idn__debug_ucs4xstring(original_name, 50))); + + r = labellist_create(cur_name, &rt_label); + if (r != idn_success) + goto ret; + if (rt_label == NULL) { + if (*original_name == '\0') + r = idn_success; + else + r = idn_invalid_encoding; + goto ret; + } + + if (!idn__util_ucs4isasciirange(labellist_getname(rt_label))) { + r = label_map(ctx, rt_label); + if (r != idn_success) + goto ret; + r = label_normalize(ctx, rt_label); + if (r != idn_success) + goto ret; + r = label_prohcheck(ctx, rt_label); + if (r != idn_success) + goto ret; + if (actions & IDN_UNASCHECK) { + r = label_unascheck(ctx, rt_label); + if (r != idn_success) + goto ret; + } + r = label_bidicheck(ctx, rt_label); + if (r != idn_success) + goto ret; + } + + if (actions & IDN_ASCCHECK) { + r = label_asccheck(ctx, rt_label); + if (r != idn_success) + goto ret; + } + if (!idn__util_ucs4isasciirange(labellist_getname(rt_label))) { + r = label_idnencode_ace(ctx, rt_label); + if (r != idn_success) + goto ret; + } + r = label_lencheck_ace(ctx, rt_label); + if (r != idn_success) + goto ret; + rt_name = labellist_getname(rt_label); + + if (idn_ucs4_strcasecmp(rt_name, original_name) != 0) { + TRACE(("res rtcheck(): round trip failed, org =\"%s\", rt=\"%s\"\n", + idn__debug_ucs4xstring(original_name, 50), + idn__debug_ucs4xstring(rt_name, 50))); + r = idn_invalid_encoding; + goto ret; + } + + r = idn_success; +ret: + if (r != idn_nomemory && r != idn_success) + r = idn_invalid_encoding; + TRACE(("res rtcheck(): %s\n", idn_result_tostring(r))); + if (rt_label != NULL) + labellist_destroy(rt_label); + return (r); +} + +const char * +idn__res_actionstostring(idn_action_t actions) { + static char buf[100]; + + buf[0] = '\0'; + + if (actions == IDN_ENCODE_QUERY) + strcpy(buf, "encode-query"); + else if (actions == IDN_DECODE_QUERY) + strcpy(buf, "decode-query"); + else if (actions == IDN_ENCODE_APP) + strcpy(buf, "encode-app"); + else if (actions == IDN_DECODE_APP) + strcpy(buf, "decode-app"); + else if (actions == IDN_ENCODE_STORED) + strcpy(buf, "encode-stored"); + else if (actions == IDN_DECODE_STORED) + strcpy(buf, "decode-stored"); + else { + if (actions & IDN_LOCALCONV) + strcat(buf, "|localconv"); + if (actions & IDN_DELIMMAP) + strcat(buf, "|delimmap"); + if (actions & IDN_LOCALMAP) + strcat(buf, "|localmap"); + + if (actions & IDN_MAP) + strcat(buf, "|map"); + if (actions & IDN_NORMALIZE) + strcat(buf, "|normalize"); + if (actions & IDN_PROHCHECK) + strcat(buf, "|prohcheck"); + if (actions & IDN_UNASCHECK) + strcat(buf, "|unascheck"); + if (actions & IDN_BIDICHECK) + strcat(buf, "|bidicheck"); + + if (actions & IDN_IDNCONV) + strcat(buf, "|idnconv"); + if (actions & IDN_ASCCHECK) + strcat(buf, "|asccheck"); + if (actions & IDN_LENCHECK) + strcat(buf, "|lencheck"); + if (actions & IDN_RTCHECK) + strcat(buf, "|rtcheck"); + } + + if (buf[0] == '|') + return (buf + 1); + else + return (buf); +} diff --git a/contrib/idn/idnkit-1.0-src/lib/resconf.c b/contrib/idn/idnkit-1.0-src/lib/resconf.c new file mode 100644 index 0000000..29bbeea --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/resconf.c @@ -0,0 +1,1477 @@ +#ifndef lint +static char *rcsid = "$Id: resconf.c,v 1.1.1.1 2003/06/04 00:26:12 marka Exp $"; +#endif + +/* + * Copyright (c) 2000 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 <config.h> + +#include <stddef.h> +#include <stdarg.h> +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <ctype.h> +#include <errno.h> +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif +#ifdef HAVE_PWD_H +#include <pwd.h> +#endif + +#include <idn/result.h> +#include <idn/assert.h> +#include <idn/logmacro.h> +#include <idn/converter.h> +#include <idn/nameprep.h> +#include <idn/normalizer.h> +#include <idn/checker.h> +#include <idn/mapper.h> +#include <idn/mapselector.h> +#include <idn/delimitermap.h> +#include <idn/localencoding.h> +#include <idn/resconf.h> +#include <idn/debug.h> +#include <idn/util.h> + +#ifdef WIN32 +#define MAX_PATH_SIZE 500 /* a good longer than MAX_PATH */ +#define IDNVAL_CONFFILE "ConfFile" +#else /* WIN32 */ + +#ifndef IDN_RESCONF_DIR +#define IDN_RESCONF_DIR "/etc" +#endif +#define IDN_RESCONF_FILE IDN_RESCONF_DIR "/idn.conf" +#define IDN_USER_RESCONF_FILE "/.idnrc" + +#endif /* WIN32 */ + +#define MAX_CONF_LINE_LENGTH 255 +#define MAX_CONF_LINE_ARGS 63 + +#define DEFAULT_CONF_NAMEPREP 0x0001 +#define DEFAULT_CONF_IDN_ENCODING 0x0010 +#define DEFAULT_CONF_ALL (DEFAULT_CONF_NAMEPREP | \ + DEFAULT_CONF_IDN_ENCODING) + +#define IDN_ENCODING_CURRENT "Punycode" + +#ifdef ENABLE_MDNKIT_COMPAT +#define MDN_RESCONF_FILE IDN_RESCONF_DIR "/mdn.conf" +#endif + +struct idn_resconf { + int local_converter_is_static; + idn_converter_t local_converter; + idn_converter_t idn_converter; + idn_converter_t aux_idn_converter; + idn_normalizer_t normalizer; + idn_checker_t prohibit_checker; + idn_checker_t unassigned_checker; + idn_checker_t bidi_checker; + idn_mapper_t mapper; + idn_mapselector_t local_mapper; + idn_delimitermap_t delimiter_mapper; + int reference_count; +}; + +static int initialized; + +#ifndef WIN32 +static const char * userhomedir(void); +#endif +static idn_result_t open_userdefaultfile(FILE **fpp); +static idn_result_t open_defaultfile(FILE **fpp); +static idn_result_t parse_conf(idn_resconf_t ctx, FILE *fp); +static idn_result_t parse_idn_encoding(idn_resconf_t ctx, char *args, + int lineno); +static idn_result_t parse_local_map(idn_resconf_t ctx, char *args, + int lineno); +static idn_result_t parse_nameprep(idn_resconf_t ctx, char *args, + int lineno); +static int split_args(char *s, char **av, int max_ac); +static void resetconf(idn_resconf_t ctx); +#ifndef WITHOUT_ICONV +static idn_result_t update_local_converter(idn_resconf_t ctx); +#endif +static idn_result_t setdefaults_body(idn_resconf_t ctx, int conf_mask); + +idn_result_t +idn_resconf_initialize(void) { + idn_result_t r; + + TRACE(("idn_resconf_initialize()\n")); + + if (initialized) { + r = idn_success; + goto ret; + } + + /* + * Initialize sub modules. + */ + if ((r = idn_converter_initialize()) != idn_success) + goto ret; + if ((r = idn_normalizer_initialize()) != idn_success) + goto ret; + if ((r = idn_checker_initialize()) != idn_success) + goto ret; + if ((r = idn_mapselector_initialize()) != idn_success) + goto ret; + if ((r = idn_mapper_initialize()) != idn_success) + goto ret; + + r = idn_success; + initialized = 1; +ret: + TRACE(("idn_resconf_initialize(): %s\n", idn_result_tostring(r))); + return (r); +} + +idn_result_t +idn_resconf_create(idn_resconf_t *ctxp) { + idn_resconf_t ctx = NULL; + idn_result_t r; + + assert(ctxp != NULL); + + TRACE(("idn_resconf_create()\n")); + + if (!initialized) { + r = idn_failure; + goto ret; + } + if ((ctx = malloc(sizeof(*ctx))) == NULL) { + r = idn_nomemory; + goto ret; + } + + ctx->local_converter_is_static = 0; + ctx->local_converter = NULL; + ctx->idn_converter = NULL; + ctx->aux_idn_converter = NULL; + ctx->normalizer = NULL; + ctx->prohibit_checker = NULL; + ctx->unassigned_checker = NULL; + ctx->bidi_checker = NULL; + ctx->mapper = NULL; + ctx->local_mapper = NULL; + ctx->reference_count = 1; + + r = idn_delimitermap_create(&ctx->delimiter_mapper); + if (r != idn_success) + goto ret; + + *ctxp = ctx; + r = idn_success; +ret: + TRACE(("idn_resconf_create(): %s\n", idn_result_tostring(r))); + return (r); +} + +char * +idn_resconf_defaultfile() { +#ifdef WIN32 + static char default_path[MAX_PATH_SIZE]; + + if (idn__util_getregistrystring(idn__util_hkey_localmachine, + IDNVAL_CONFFILE, default_path, + sizeof(default_path))) { + return (default_path); + } else { + return (NULL); + } +#else + return (IDN_RESCONF_FILE); +#endif +} + +#ifndef WIN32 +static const char * +userhomedir() { + uid_t uid; + struct passwd *pwd; + + uid = getuid(); + pwd = getpwuid(uid); + if (pwd == NULL) { + return (NULL); + } + + return (pwd->pw_dir); +} +#endif + +static idn_result_t +open_userdefaultfile(FILE **fpp) { +#ifdef WIN32 + char user_path[MAX_PATH_SIZE]; + + TRACE(("open_userdefaultfile()\n")); + + if (idn__util_getregistrystring(idn__util_hkey_currentuser, + IDNVAL_CONFFILE, user_path, + sizeof(user_path)) == 0) { + return (idn_nofile); + } + *fpp = fopen(user_path, "r"); + if (*fpp == NULL) { + return (idn_nofile); + } + return (idn_success); +#else /* WIN32 */ + const char *homedir; + char *file; + int len; + + TRACE(("open_userdefaultfile()\n")); + + homedir = userhomedir(); + len = strlen(IDN_USER_RESCONF_FILE) + 1; + if (homedir != NULL) { + len += strlen(homedir); + } else { + return (idn_notfound); + } + + file = (char *)malloc(sizeof(char) * len); + if (file == NULL) { + WARNING(("open_userdefaultfile(): malloc failed\n")); + return (idn_nomemory); + } + + (void)strcpy(file, homedir); + strcat(file, IDN_USER_RESCONF_FILE); + + *fpp = fopen(file, "r"); + free(file); + if (*fpp == NULL) { + return (idn_nofile); + } + + return (idn_success); +#endif /* WIN32 */ +} + +static idn_result_t +open_defaultfile(FILE **fpp) { + idn_result_t r; + const char *file; + + r = open_userdefaultfile(fpp); + if (r == idn_nofile || r == idn_notfound) { + TRACE(("open_defaultfile: " + "cannot open user configuration file\n")); + file = idn_resconf_defaultfile(); + *fpp = fopen(file, "r"); +#ifdef ENABLE_MDNKIT_COMPAT + if (*fpp == NULL) + *fpp = fopen(MDN_RESCONF_FILE, "r"); +#endif + if (*fpp == NULL) { + TRACE(("open_defaultfile: " + "cannot open system configuration file\n")); + return (idn_nofile); + } + } else if (r != idn_success) { + return (r); + } + + return (idn_success); +} + +idn_result_t +idn_resconf_loadfile(idn_resconf_t ctx, const char *file) { + FILE *fp = NULL; + idn_result_t r; + + assert(ctx != NULL); + + TRACE(("idn_resconf_loadfile(file=%s)\n", + file == NULL ? "<null>" : file)); + + resetconf(ctx); + r = idn_delimitermap_create(&ctx->delimiter_mapper); + if (r != idn_success) { + goto ret; + } + + if (file == NULL) { + r = open_defaultfile(&fp); + if (r == idn_nofile || r == idn_notfound) { + r = setdefaults_body(ctx, 0); + goto ret; + } else if (r != idn_success) { + goto ret; + } + } else { + fp = fopen(file, "r"); + if (fp == NULL) { + TRACE(("idn_resconf_loadfile: cannot open %-.40s\n", + file)); + r = idn_nofile; + goto ret; + } + } + + r = parse_conf(ctx, fp); + fclose(fp); + +ret: + TRACE(("idn_resconf_loadfile(): %s\n", idn_result_tostring(r))); + return (r); +} + +void +idn_resconf_destroy(idn_resconf_t ctx) { + assert(ctx != NULL); + + TRACE(("idn_resconf_destroy()\n")); + + ctx->reference_count--; + if (ctx->reference_count <= 0) { + resetconf(ctx); + free(ctx); + TRACE(("idn_resconf_destroy: the object is destroyed\n")); + } else { + TRACE(("idn_resconf_destroy(): " + "update reference count (%d->%d)\n", + ctx->reference_count + 1, ctx->reference_count)); + } +} + +void +idn_resconf_incrref(idn_resconf_t ctx) { + assert(ctx != NULL); + + TRACE(("idn_resconf_incrref()\n")); + TRACE(("idn_resconf_incrref: update reference count (%d->%d)\n", + ctx->reference_count, ctx->reference_count + 1)); + + ctx->reference_count++; +} + +idn_converter_t +idn_resconf_getalternateconverter(idn_resconf_t ctx) { + assert(ctx != NULL); + + TRACE(("idn_resconf_getalternateconverter()\n")); + + return (idn_resconf_getidnconverter(ctx)); +} + +idn_delimitermap_t +idn_resconf_getdelimitermap(idn_resconf_t ctx) { + assert(ctx != NULL); + + TRACE(("idn_resconf_getdelimitermap()\n")); + + if (ctx->delimiter_mapper != NULL) + idn_delimitermap_incrref(ctx->delimiter_mapper); + return (ctx->delimiter_mapper); +} + +idn_converter_t +idn_resconf_getidnconverter(idn_resconf_t ctx) { + assert(ctx != NULL); + + TRACE(("idn_resconf_getidnconverter()\n")); + + if (ctx->idn_converter != NULL) + idn_converter_incrref(ctx->idn_converter); + return (ctx->idn_converter); +} + +idn_converter_t +idn_resconf_getauxidnconverter(idn_resconf_t ctx) { + assert(ctx != NULL); + + TRACE(("idn_resconf_getauxidnconverter()\n")); + + if (ctx->aux_idn_converter != NULL) + idn_converter_incrref(ctx->aux_idn_converter); + return (ctx->aux_idn_converter); +} + +idn_converter_t +idn_resconf_getlocalconverter(idn_resconf_t ctx) { + assert(ctx != NULL); + + TRACE(("idn_resconf_getlocalconverter()\n")); + +#ifdef WITHOUT_ICONV + return NULL; + +#else /* WITHOUT_ICONV */ + if (update_local_converter(ctx) != idn_success) + return (NULL); + + idn_converter_incrref(ctx->local_converter); + return (ctx->local_converter); + +#endif /* WITHOUT_ICONV */ +} + +idn_mapselector_t +idn_resconf_getlocalmapselector(idn_resconf_t ctx) { + assert(ctx != NULL); + + TRACE(("idn_resconf_getlocalmapselector()\n")); + + if (ctx->local_mapper != NULL) + idn_mapselector_incrref(ctx->local_mapper); + return (ctx->local_mapper); +} + +idn_mapper_t +idn_resconf_getmapper(idn_resconf_t ctx) { + assert(ctx != NULL); + + TRACE(("idn_resconf_getmapper()\n")); + + if (ctx->mapper != NULL) + idn_mapper_incrref(ctx->mapper); + return (ctx->mapper); +} + +idn_normalizer_t +idn_resconf_getnormalizer(idn_resconf_t ctx) { + assert(ctx != NULL); + + TRACE(("idn_resconf_getnormalizer()\n")); + + if (ctx->normalizer != NULL) + idn_normalizer_incrref(ctx->normalizer); + return (ctx->normalizer); +} + +idn_checker_t +idn_resconf_getprohibitchecker(idn_resconf_t ctx) { + assert(ctx != NULL); + + TRACE(("idn_resconf_getprohibitchecker()\n")); + + if (ctx->prohibit_checker != NULL) + idn_checker_incrref(ctx->prohibit_checker); + return (ctx->prohibit_checker); +} + +idn_checker_t +idn_resconf_getunassignedchecker(idn_resconf_t ctx) { + assert(ctx != NULL); + + TRACE(("idn_resconf_getunassignedchecker()\n")); + + if (ctx->unassigned_checker != NULL) + idn_checker_incrref(ctx->unassigned_checker); + return (ctx->unassigned_checker); +} + +idn_checker_t +idn_resconf_getbidichecker(idn_resconf_t ctx) { + assert(ctx != NULL); + + TRACE(("idn_resconf_getbidichecker()\n")); + + if (ctx->bidi_checker != NULL) + idn_checker_incrref(ctx->bidi_checker); + return (ctx->bidi_checker); +} + +void +idn_resconf_setalternateconverter(idn_resconf_t ctx, + idn_converter_t alternate_converter) { + assert(ctx != NULL); + + TRACE(("idn_resconf_setalternateconverter()\n")); +} + +void +idn_resconf_setdelimitermap(idn_resconf_t ctx, + idn_delimitermap_t delimiter_mapper) { + assert(ctx != NULL); + + TRACE(("idn_resconf_setdelimitermap()\n")); + + if (ctx->delimiter_mapper != NULL) + idn_delimitermap_destroy(ctx->delimiter_mapper); + ctx->delimiter_mapper = delimiter_mapper; + if (delimiter_mapper != NULL) + idn_delimitermap_incrref(ctx->delimiter_mapper); +} + +void +idn_resconf_setidnconverter(idn_resconf_t ctx, + idn_converter_t idn_converter) { + assert(ctx != NULL); + + TRACE(("idn_resconf_setidnconverter()\n")); + + if (ctx->idn_converter != NULL) + idn_converter_destroy(ctx->idn_converter); + ctx->idn_converter = idn_converter; + if (idn_converter != NULL) + idn_converter_incrref(ctx->idn_converter); +} + +void +idn_resconf_setauxidnconverter(idn_resconf_t ctx, + idn_converter_t aux_idn_converter) { + assert(ctx != NULL); + + TRACE(("idn_resconf_setauxidnconverter()\n")); + + if (ctx->aux_idn_converter != NULL) + idn_converter_destroy(ctx->aux_idn_converter); + ctx->aux_idn_converter = aux_idn_converter; + if (aux_idn_converter != NULL) + idn_converter_incrref(ctx->aux_idn_converter); +} + +void +idn_resconf_setlocalconverter(idn_resconf_t ctx, + idn_converter_t local_converter) { +#ifndef WITHOUT_ICONV + assert(ctx != NULL); + + TRACE(("idn_resconf_setlocalconverter()\n")); + + if (ctx->local_converter != NULL) { + idn_converter_destroy(ctx->local_converter); + ctx->local_converter = NULL; + } + + if (local_converter == NULL) + ctx->local_converter_is_static = 0; + else { + ctx->local_converter = local_converter; + idn_converter_incrref(local_converter); + ctx->local_converter_is_static = 1; + } +#endif /* WITHOUT_ICONV */ +} + +void +idn_resconf_setlocalmapselector(idn_resconf_t ctx, + idn_mapselector_t local_mapper) { + assert(ctx != NULL); + + TRACE(("idn_resconf_setlocalmapselector()\n")); + + if (ctx->local_mapper != NULL) + idn_mapselector_destroy(ctx->local_mapper); + ctx->local_mapper = local_mapper; + if (local_mapper != NULL) + idn_mapselector_incrref(ctx->local_mapper); +} + +void +idn_resconf_setmapper(idn_resconf_t ctx, idn_mapper_t mapper) { + assert(ctx != NULL); + + TRACE(("idn_resconf_setmapper()\n")); + + if (ctx->mapper != NULL) + idn_mapper_destroy(ctx->mapper); + ctx->mapper = mapper; + if (mapper != NULL) + idn_mapper_incrref(ctx->mapper); +} + +void +idn_resconf_setnormalizer(idn_resconf_t ctx, idn_normalizer_t normalizer) { + assert(ctx != NULL); + + TRACE(("idn_resconf_setnormalizer()\n")); + + if (ctx->normalizer != NULL) + idn_normalizer_destroy(ctx->normalizer); + ctx->normalizer = normalizer; + if (normalizer != NULL) + idn_normalizer_incrref(ctx->normalizer); +} + +void +idn_resconf_setprohibitchecker(idn_resconf_t ctx, + idn_checker_t prohibit_checker) { + assert(ctx != NULL); + + TRACE(("idn_resconf_setprohibitchecker()\n")); + + if (ctx->prohibit_checker != NULL) + idn_checker_destroy(ctx->prohibit_checker); + ctx->prohibit_checker = prohibit_checker; + if (prohibit_checker != NULL) + idn_checker_incrref(ctx->prohibit_checker); +} + +void +idn_resconf_setunassignedchecker(idn_resconf_t ctx, + idn_checker_t unassigned_checker) { + assert(ctx != NULL); + + TRACE(("idn_resconf_setunassignedchecker()\n")); + + if (ctx->unassigned_checker != NULL) + idn_checker_destroy(ctx->unassigned_checker); + ctx->unassigned_checker = unassigned_checker; + if (unassigned_checker != NULL) + idn_checker_incrref(ctx->unassigned_checker); +} + +void +idn_resconf_setbidichecker(idn_resconf_t ctx, + idn_checker_t bidi_checker) { + assert(ctx != NULL); + + TRACE(("idn_resconf_setbidichecker()\n")); + + if (ctx->bidi_checker != NULL) + idn_checker_destroy(ctx->bidi_checker); + ctx->bidi_checker = bidi_checker; + if (bidi_checker != NULL) + idn_checker_incrref(ctx->bidi_checker); +} + +idn_result_t +idn_resconf_setnameprepversion(idn_resconf_t ctx, const char *version) +{ + char prohibit_scheme_name[MAX_CONF_LINE_LENGTH + 1]; + char unassigned_scheme_name[MAX_CONF_LINE_LENGTH + 1]; + char bidi_scheme_name[MAX_CONF_LINE_LENGTH + 1]; + idn_mapper_t mapper = NULL; + idn_normalizer_t normalizer = NULL; + idn_checker_t prohibit_checker = NULL; + idn_checker_t unassigned_checker = NULL; + idn_checker_t bidi_checker = NULL; + idn_result_t r; + + assert(ctx != NULL && version != NULL); + + TRACE(("idn_resconf_setnameprepversion()\n")); + + /* + * Set canonical scheme names. + */ + if (strlen(version) + strlen(IDN_CHECKER_PROHIBIT_PREFIX) + > MAX_CONF_LINE_LENGTH) { + r = idn_invalid_name; + goto failure; + } + sprintf(prohibit_scheme_name, "%s%s", + IDN_CHECKER_PROHIBIT_PREFIX, version); + + if (strlen(version) + strlen(IDN_CHECKER_UNASSIGNED_PREFIX) + > MAX_CONF_LINE_LENGTH) { + r = idn_invalid_name; + goto failure; + } + sprintf(unassigned_scheme_name, "%s%s", + IDN_CHECKER_UNASSIGNED_PREFIX, version); + + if (strlen(version) + strlen(IDN_CHECKER_BIDI_PREFIX) + > MAX_CONF_LINE_LENGTH) { + r = idn_invalid_name; + goto failure; + } + sprintf(bidi_scheme_name, "%s%s", + IDN_CHECKER_BIDI_PREFIX, version); + + /* + * Create objects. + */ + r = idn_mapper_create(&mapper); + if (r != idn_success) + goto failure; + r = idn_normalizer_create(&normalizer); + if (r != idn_success) + goto failure; + r = idn_checker_create(&prohibit_checker); + if (r != idn_success) + goto failure; + r = idn_checker_create(&unassigned_checker); + if (r != idn_success) + goto failure; + r = idn_checker_create(&bidi_checker); + if (r != idn_success) + goto failure; + + r = idn_mapper_add(mapper, version); + if (r != idn_success) + goto failure; + r = idn_normalizer_add(normalizer, version); + if (r != idn_success) + goto failure; + r = idn_checker_add(prohibit_checker, prohibit_scheme_name); + if (r != idn_success) + goto failure; + r = idn_checker_add(unassigned_checker, unassigned_scheme_name); + if (r != idn_success) + goto failure; + r = idn_checker_add(bidi_checker, bidi_scheme_name); + if (r != idn_success) + goto failure; + + /* + * Set the objects. + */ + idn_resconf_setmapper(ctx, mapper); + idn_resconf_setnormalizer(ctx, normalizer); + idn_resconf_setprohibitchecker(ctx, prohibit_checker); + idn_resconf_setunassignedchecker(ctx, unassigned_checker); + idn_resconf_setbidichecker(ctx, bidi_checker); + + /* + * Destroy the objects. + */ + idn_mapper_destroy(mapper); + idn_normalizer_destroy(normalizer); + idn_checker_destroy(prohibit_checker); + idn_checker_destroy(unassigned_checker); + idn_checker_destroy(bidi_checker); + + return (idn_success); + +failure: + if (mapper != NULL) + idn_mapper_destroy(mapper); + if (normalizer != NULL) + idn_normalizer_destroy(normalizer); + if (prohibit_checker != NULL) + idn_checker_destroy(prohibit_checker); + if (unassigned_checker != NULL) + idn_checker_destroy(unassigned_checker); + if (bidi_checker != NULL) + idn_checker_destroy(bidi_checker); + + return (r); +} + +idn_result_t +idn_resconf_setalternateconvertername(idn_resconf_t ctx, const char *name, + int flags) { + assert(ctx != NULL && name != NULL); + + TRACE(("idn_resconf_setalternateconvertername(name=%s, flags=%d)\n", + name, flags)); + + return (idn_success); +} + +idn_result_t +idn_resconf_setidnconvertername(idn_resconf_t ctx, const char *name, + int flags) { + idn_converter_t idn_converter; + idn_result_t r; + + assert(ctx != NULL && name != NULL); + + TRACE(("idn_resconf_setidnconvertername(name=%s, flags=%d)\n", + name, flags)); + + r = idn_converter_create(name, &idn_converter, flags); + if (r != idn_success) + return (r); + + if (ctx->idn_converter != NULL) + idn_converter_destroy(ctx->idn_converter); + ctx->idn_converter = idn_converter; + + return (idn_success); +} + +idn_result_t +idn_resconf_setauxidnconvertername(idn_resconf_t ctx, const char *name, + int flags) { + idn_converter_t aux_idn_converter; + const char *old_name; + idn_result_t r; + + assert(ctx != NULL && name != NULL); + + TRACE(("idn_resconf_setauxidnconvertername(name=%s, flags=%d)\n", + name, flags)); + + if (ctx->aux_idn_converter != NULL) { + old_name = idn_converter_localencoding(ctx->aux_idn_converter); + if (old_name != NULL && strcmp(old_name, name) == 0) + return (idn_success); + } + + r = idn_converter_create(name, &aux_idn_converter, flags); + if (r != idn_success) + return (r); + + if (ctx->aux_idn_converter != NULL) + idn_converter_destroy(ctx->aux_idn_converter); + ctx->aux_idn_converter = aux_idn_converter; + + return (idn_success); +} + +idn_result_t +idn_resconf_setlocalconvertername(idn_resconf_t ctx, const char *name, + int flags) { +#ifdef WITHOUT_ICONV + return idn_failure; + +#else /* WITHOUT_ICONV */ + idn_converter_t local_converter; + idn_result_t r; + + assert(ctx != NULL); + + TRACE(("idn_resconf_setlocalconvertername(name=%s, flags=%d)\n", + name == NULL ? "<null>" : name, flags)); + + if (ctx->local_converter != NULL) { + idn_converter_destroy(ctx->local_converter); + ctx->local_converter = NULL; + } + ctx->local_converter_is_static = 0; + + if (name != NULL) { + r = idn_converter_create(name, &local_converter, flags); + if (r != idn_success) + return (r); + ctx->local_converter = local_converter; + ctx->local_converter_is_static = 1; + } + + return (idn_success); + +#endif /* WITHOUT_ICONV */ +} + +idn_result_t +idn_resconf_addalldelimitermapucs(idn_resconf_t ctx, unsigned long *v, + int nv) { + idn_result_t r; + + TRACE(("idn_resconf_addalldelimitermapucs(nv=%d)\n", nv)); + + if (ctx->delimiter_mapper == NULL) { + r = idn_delimitermap_create(&(ctx->delimiter_mapper)); + if (r != idn_success) + return (r); + } + + r = idn_delimitermap_addall(ctx->delimiter_mapper, v, nv); + return (r); +} + +idn_result_t +idn_resconf_addalllocalmapselectornames(idn_resconf_t ctx, const char *tld, + const char **names, int nnames) { + idn_result_t r; + + assert(ctx != NULL && names != NULL && tld != NULL); + + TRACE(("idn_resconf_addalllocalmapselectorname(tld=%s, nnames=%d)\n", + tld, nnames)); + + if (ctx->local_mapper == NULL) { + r = idn_mapselector_create(&(ctx->local_mapper)); + if (r != idn_success) + return (r); + } + + r = idn_mapselector_addall(ctx->local_mapper, tld, names, nnames); + return (r); +} + +idn_result_t +idn_resconf_addallmappernames(idn_resconf_t ctx, const char **names, + int nnames) { + idn_result_t r; + + assert(ctx != NULL && names != NULL); + + TRACE(("idn_resconf_addallmappername()\n")); + + if (ctx->mapper == NULL) { + r = idn_mapper_create(&(ctx->mapper)); + if (r != idn_success) + return (r); + } + + r = idn_mapper_addall(ctx->mapper, names, nnames); + return (r); +} + +idn_result_t +idn_resconf_addallnormalizernames(idn_resconf_t ctx, const char **names, + int nnames) { + idn_result_t r; + + assert(ctx != NULL && names != NULL); + + TRACE(("idn_resconf_addallnormalizername(nnames=%d)\n", nnames)); + + if (ctx->normalizer == NULL) { + r = idn_normalizer_create(&(ctx->normalizer)); + if (r != idn_success) + return (r); + } + + r = idn_normalizer_addall(ctx->normalizer, names, nnames); + return (r); +} + +idn_result_t +idn_resconf_addallprohibitcheckernames(idn_resconf_t ctx, const char **names, + int nnames) { + char long_name[MAX_CONF_LINE_LENGTH + 1]; + idn_result_t r; + int i; + + assert(ctx != NULL && names != NULL); + + TRACE(("idn_resconf_addallprohibitcheckername(nnames=%d)\n", nnames)); + + if (ctx->prohibit_checker == NULL) { + r = idn_checker_create(&(ctx->prohibit_checker)); + if (r != idn_success) + return (r); + } + + for (i = 0; i < nnames; i++, names++) { + if (strlen(*names) + strlen(IDN_CHECKER_PROHIBIT_PREFIX) + > MAX_CONF_LINE_LENGTH) { + return (idn_invalid_name); + } + strcpy(long_name, IDN_CHECKER_PROHIBIT_PREFIX); + strcat(long_name, *names); + + r = idn_checker_add(ctx->prohibit_checker, long_name); + if (r != idn_success) + return (r); + } + + return (idn_success); +} + +idn_result_t +idn_resconf_addallunassignedcheckernames(idn_resconf_t ctx, const char **names, + int nnames) { + char long_name[MAX_CONF_LINE_LENGTH + 1]; + idn_result_t r; + int i; + + assert(ctx != NULL && names != NULL); + + TRACE(("idn_resconf_addallunassignedcheckername(nnames=%d)\n", + nnames)); + + if (ctx->unassigned_checker == NULL) { + r = idn_checker_create(&(ctx->unassigned_checker)); + if (r != idn_success) + return (r); + } + + for (i = 0; i < nnames; i++, names++) { + if (strlen(*names) + strlen(IDN_CHECKER_UNASSIGNED_PREFIX) + > MAX_CONF_LINE_LENGTH) { + return (idn_invalid_name); + } + strcpy(long_name, IDN_CHECKER_UNASSIGNED_PREFIX); + strcat(long_name, *names); + + r = idn_checker_add(ctx->unassigned_checker, long_name); + if (r != idn_success) + return (r); + } + + return (idn_success); +} + +idn_result_t +idn_resconf_addallbidicheckernames(idn_resconf_t ctx, const char **names, + int nnames) { + char long_name[MAX_CONF_LINE_LENGTH + 1]; + idn_result_t r; + int i; + + assert(ctx != NULL && names != NULL); + + TRACE(("idn_resconf_addallbidicheckername(nnames=%d)\n", nnames)); + + if (ctx->bidi_checker == NULL) { + r = idn_checker_create(&(ctx->bidi_checker)); + if (r != idn_success) + return (r); + } + + for (i = 0; i < nnames; i++, names++) { + if (strlen(*names) + strlen(IDN_CHECKER_BIDI_PREFIX) + > MAX_CONF_LINE_LENGTH) { + return (idn_invalid_name); + } + strcpy(long_name, IDN_CHECKER_BIDI_PREFIX); + strcat(long_name, *names); + + r = idn_checker_add(ctx->bidi_checker, long_name); + if (r != idn_success) + return (r); + } + + return (idn_success); +} + +static idn_result_t +parse_conf(idn_resconf_t ctx, FILE *fp) { + char line[MAX_CONF_LINE_LENGTH + 1]; + int lineno = 0; + char *argv[3]; + int argc; + idn_result_t r; + int conf_mask = 0; + + TRACE(("parse_conf()\n")); + + /* + * Parse config file. parsing of 'idn-encoding' line is + * postponed because 'alias-file' line must be processed + * before them. + */ + while (fgets(line, sizeof(line), fp) != NULL) { + char *newline; + + lineno++; + newline = strpbrk(line, "\r\n"); + if (newline != NULL) + *newline = '\0'; + else if (fgetc(fp) != EOF) { + ERROR(("libidnkit: too long line \"%-.30s\", " + "line %d\n", line, lineno)); + return (idn_invalid_syntax); + } + + argc = split_args(line, argv, 2); + if (argc == -1) { + ERROR(("libidnkit: syntax error, line %d\n", lineno)); + return (idn_invalid_syntax); + } else if (argc == 0 || argv[0][0] == '#') { + continue; + } else if (argc == 1) { + ERROR(("libidnkit: syntax error, line %d\n", lineno)); + return (idn_invalid_syntax); + } + + if (strcmp(argv[0], "idn-encoding") == 0) { + if (conf_mask & DEFAULT_CONF_IDN_ENCODING) { + ERROR(("libidnkit: \"%s\" redefined, " + "line %d\n", argv[0], lineno)); + r = idn_invalid_syntax; + } else { + conf_mask |= DEFAULT_CONF_IDN_ENCODING; + r = parse_idn_encoding(ctx, argv[1], lineno); + } + } else if (strcmp(argv[0], "local-map") == 0) { + r = parse_local_map(ctx, argv[1], lineno); + + } else if (strcmp(argv[0], "nameprep") == 0) { + if (conf_mask & DEFAULT_CONF_NAMEPREP) { + ERROR(("libidnkit: \"%s\" redefined, " + "line %d\n", argv[0], lineno)); + r = idn_invalid_syntax; + } else { + conf_mask |= DEFAULT_CONF_NAMEPREP; + r = parse_nameprep(ctx, argv[1], lineno); + } + } else if (strcmp(argv[0], "nameprep-map") == 0 || + strcmp(argv[0], "nameprep-normalize") == 0 || + strcmp(argv[0], "nameprep-prohibit") == 0 || + strcmp(argv[0], "nameprep-unassigned") == 0 || + strcmp(argv[0], "alias-file") == 0 || + strcmp(argv[0], "encoding-alias-file") == 0 || + strcmp(argv[0], "normalize") == 0 || + strcmp(argv[0], "server-encoding") == 0 || + strcmp(argv[0], "alternate-encoding") == 0 || + strcmp(argv[0], "delimiter-map") == 0) { + WARNING(("libidnkit: obsolete command \"%s\", line %d " + "(ignored)\n", argv[0], lineno)); + r = idn_success; + } else { + ERROR(("libidnkit: unknown command \"%-.30s\", " + "line %d\n", argv[0], lineno)); + r = idn_invalid_syntax; + } + if (r != idn_success) + return (r); + } + + lineno++; + + if (conf_mask != DEFAULT_CONF_ALL) { + return setdefaults_body(ctx, conf_mask); + } + + return (idn_success); +} + +static idn_result_t +parse_idn_encoding(idn_resconf_t ctx, char *args, int lineno) { + idn_result_t r; + char *argv[MAX_CONF_LINE_ARGS + 1]; + int argc; + + argc = split_args(args, argv, MAX_CONF_LINE_ARGS + 1); + + if (argc != 1) { + ERROR(("libidnkit: wrong # of args for idn-encoding, " + "line %d\n", lineno)); + return (idn_invalid_syntax); + } + + r = idn_converter_create(argv[0], &ctx->idn_converter, + IDN_CONVERTER_DELAYEDOPEN | + IDN_CONVERTER_RTCHECK); + if (r != idn_success) { + ERROR(("libidnkit: cannot create idn converter, %s, " + "line %d\n", idn_result_tostring(r), lineno)); + } + + return (r); +} + +static idn_result_t +parse_local_map(idn_resconf_t ctx, char *args, int lineno) { + idn_result_t r; + char *argv[MAX_CONF_LINE_ARGS + 1]; + int argc; + int i; + + argc = split_args(args, argv, MAX_CONF_LINE_ARGS + 1); + + if (argc < 2 || argc > MAX_CONF_LINE_ARGS) { + ERROR(("libidnkit: wrong # of args for local-map, line %d\n", + lineno)); + return (idn_invalid_syntax); + } + + if (ctx->local_mapper == NULL) { + r = idn_mapselector_create(&ctx->local_mapper); + if (r != idn_success) { + ERROR(("libidnkit: cannot create local mapper, %s, " + "line %d\n", idn_result_tostring(r), lineno)); + return (r); + } + } + + for (i = 1; i < argc; i++) { + r = idn_mapselector_add(ctx->local_mapper, argv[0], argv[i]); + if (r == idn_invalid_name) { + ERROR(("libidnkit: map scheme unavailable \"%-.30s\"" + " or invalid TLD \"%-.30s\", line %d\n", + argv[i], argv[0], lineno)); + return (r); + } else if (r != idn_success) { + return (r); + } + } + + return (idn_success); +} + +static idn_result_t +parse_nameprep(idn_resconf_t ctx, char *args, int lineno) { + idn_result_t r; + char *argv[MAX_CONF_LINE_ARGS + 1]; + char scheme_name[MAX_CONF_LINE_LENGTH + 1]; + int argc; + + argc = split_args(args, argv, MAX_CONF_LINE_ARGS + 1); + + if (argc != 1) { + ERROR(("libidnkit: wrong # of args for nameprep, line %d\n", + lineno)); + return (idn_invalid_syntax); + } + + /* + * Set mapper. + */ + r = idn_mapper_create(&ctx->mapper); + if (r != idn_success) { + ERROR(("libidnkit: cannot create mapper, %s, line %d\n", + idn_result_tostring(r), lineno)); + return (r); + } + + r = idn_mapper_add(ctx->mapper, argv[0]); + if (r == idn_invalid_name) { + ERROR(("libidnkit: map scheme unavailable \"%-.30s\", " + "line %d\n", argv[0], lineno)); + return (r); + } else if (r != idn_success) { + return (r); + } + + /* + * Set normalizer. + */ + r = idn_normalizer_create(&ctx->normalizer); + if (r != idn_success) { + ERROR(("libidnkit: cannot create normalizer, %s, line %d\n", + idn_result_tostring(r), lineno)); + return (r); + } + + r = idn_normalizer_add(ctx->normalizer, argv[0]); + if (r == idn_invalid_name) { + ERROR(("libidnkit: unknown normalization scheme \"%-.30s\", " + "line %d\n", argv[0], lineno)); + return (r); + } else if (r != idn_success) { + return (r); + } + + /* + * Set prohibit checker. + */ + r = idn_checker_create(&ctx->prohibit_checker); + if (r != idn_success) { + ERROR(("libidnkit: cannot create prohibit checker, %s, " + "line %d\n", idn_result_tostring(r), lineno)); + return (r); + } + + sprintf(scheme_name, "%s%s", IDN_CHECKER_PROHIBIT_PREFIX, argv[0]); + r = idn_checker_add(ctx->prohibit_checker, scheme_name); + if (r == idn_invalid_name) { + ERROR(("libidnkit: unknown prohibit scheme \"%-.30s\", " + "line %d\n", argv[0], lineno)); + return (r); + } else if (r != idn_success) { + return (r); + } + + /* + * Set unassigned checker. + */ + r = idn_checker_create(&ctx->unassigned_checker); + if (r != idn_success) { + ERROR(("libidnkit: cannot create unassigned checker, %s, " + "line %d\n", idn_result_tostring(r), lineno)); + return (r); + } + + sprintf(scheme_name, "%s%s", IDN_CHECKER_UNASSIGNED_PREFIX, argv[0]); + r = idn_checker_add(ctx->unassigned_checker, scheme_name); + if (r == idn_invalid_name) { + ERROR(("libidnkit: unknown unassigned scheme \"%-.30s\", " + "line %d\n", argv[0], lineno)); + return (r); + } else if (r != idn_success) { + return (r); + } + + /* + * Set bidi checker. + */ + r = idn_checker_create(&ctx->bidi_checker); + if (r != idn_success) { + ERROR(("libidnkit: cannot create bidi checker, %s, line %d\n", + idn_result_tostring(r), lineno)); + return (r); + } + + sprintf(scheme_name, "%s%s", IDN_CHECKER_BIDI_PREFIX, argv[0]); + r = idn_checker_add(ctx->bidi_checker, scheme_name); + if (r == idn_invalid_name) { + ERROR(("libidnkit: unknown bidi scheme \"%-.30s\", " + "line %d\n", argv[0], lineno)); + return (r); + } else if (r != idn_success) { + return (r); + } + + return (idn_success); +} + +static int +split_args(char *s, char **av, int max_ac) { + int ac; + int i; + + for (ac = 0; *s != '\0' && ac < max_ac; ac++) { + if (ac > 0) + *s++ = '\0'; + while (isspace((unsigned char)*s)) + s++; + if (*s == '\0') + break; + if (*s == '"' || *s == '\'') { + int qc = *s++; + av[ac] = s; + while (*s != qc) { + if (*s == '\0') + return (-1); + s++; + } + } else { + av[ac] = s; + while (*s != '\0' && !isspace((unsigned char)*s)) + s++; + } + } + + for (i = ac; i < max_ac; i++) + av[i] = NULL; + + return (ac); +} + +static void +resetconf(idn_resconf_t ctx) { +#ifndef WITHOUT_ICONV + idn_resconf_setlocalconverter(ctx, NULL); +#endif + idn_resconf_setidnconverter(ctx, NULL); + idn_resconf_setauxidnconverter(ctx, NULL); + idn_resconf_setdelimitermap(ctx, NULL); + idn_resconf_setlocalmapselector(ctx, NULL); + idn_resconf_setmapper(ctx, NULL); + idn_resconf_setnormalizer(ctx, NULL); + idn_resconf_setprohibitchecker(ctx, NULL); + idn_resconf_setunassignedchecker(ctx, NULL); + idn_resconf_setbidichecker(ctx, NULL); +} + +#ifndef WITHOUT_ICONV +static idn_result_t +update_local_converter(idn_resconf_t ctx) { + idn_result_t r; + const char *old_encoding; + const char *new_encoding; + + /* + * We don't update local converter, if the converter is set + * by idn_resconf_setlocalconverter() or + * idn_resconf_setlocalconvertername(). + */ + if (ctx->local_converter_is_static) + return (idn_success); + + /* + * Update the local converter if the local encoding is changed. + */ + old_encoding = (ctx->local_converter != NULL) ? + idn_converter_localencoding(ctx->local_converter) : + NULL; + new_encoding = idn_localencoding_name(); + if (new_encoding == NULL) { + ERROR(("cannot determine local codeset name\n")); + return (idn_notfound); + } + + if (old_encoding != NULL && + new_encoding != NULL && + strcmp(old_encoding, new_encoding) == 0) { + return (idn_success); + } + + if (ctx->local_converter != NULL) { + idn_converter_destroy(ctx->local_converter); + ctx->local_converter = NULL; + } + + r = idn_converter_create(new_encoding, + &ctx->local_converter, + IDN_CONVERTER_RTCHECK); + return (r); +} +#endif + +idn_result_t +idn_resconf_setdefaults(idn_resconf_t ctx) +{ + idn_result_t r; + + assert(ctx != NULL); + + TRACE(("idn_resconf_setdefaults()\n")); + + resetconf(ctx); + r = idn_delimitermap_create(&ctx->delimiter_mapper); + if (r != idn_success) { + ERROR(("libidnkit: cannot create delimiter mapper, %s\n", + idn_result_tostring(r))); + return (r); + } + + return setdefaults_body(ctx, 0); +} + +static idn_result_t +setdefaults_body(idn_resconf_t ctx, int conf_mask) { + idn_result_t r; + + TRACE(("setdefaults_body()\n")); + assert(ctx != NULL); + + if (!(conf_mask & DEFAULT_CONF_NAMEPREP)) { + TRACE(("set default nameprep\n")); + r = idn_resconf_setnameprepversion(ctx, IDN_NAMEPREP_CURRENT); + if (r != idn_success) { + return (r); + } + } + if (!(conf_mask & DEFAULT_CONF_IDN_ENCODING)) { + TRACE(("set default idn encoding\n")); + r = idn_converter_create(IDN_ENCODING_CURRENT, + &ctx->idn_converter, + IDN_CONVERTER_DELAYEDOPEN | + IDN_CONVERTER_RTCHECK); + if (r != idn_success) { + ERROR(("libidnkit: cannot create idn converter, %s\n", + idn_result_tostring(r))); + return (r); + } + } + + return (idn_success); +} diff --git a/contrib/idn/idnkit-1.0-src/lib/result.c b/contrib/idn/idnkit-1.0-src/lib/result.c new file mode 100644 index 0000000..c5745a2 --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/result.c @@ -0,0 +1,76 @@ +#ifndef lint +static char *rcsid = "$Id: result.c,v 1.1.1.1 2003/06/04 00:26:12 marka Exp $"; +#endif + +/* + * Copyright (c) 2000 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 <config.h> +#include <idn/result.h> + +static char *result_string[] = { + "success", + "not found", + "invalid encoding found", + "syntax error", + "invalid name", + "invalid message", + "invalid action", + "invalid code point", + "label length reduced to 0 or exceeded 63 bytes", + "buffer overflow", + "no such entry", + "out of memory", + "no such file", + "no mapping to output codeset", + "context information required", + "prohibited character found", + "generic failure", +}; + +char * +idn_result_tostring(idn_result_t result) { + if (result < 0 || result > idn_failure) + return ("unknown result code"); + + return (result_string[result]); +} diff --git a/contrib/idn/idnkit-1.0-src/lib/strhash.c b/contrib/idn/idnkit-1.0-src/lib/strhash.c new file mode 100644 index 0000000..1d2d03a --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/strhash.c @@ -0,0 +1,283 @@ +#ifndef lint +static char *rcsid = "$Id: strhash.c,v 1.1.1.1 2003/06/04 00:26:13 marka Exp $"; +#endif + +/* + * Copyright (c) 2000 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 <config.h> + +#include <stddef.h> +#include <stdlib.h> +#include <string.h> + +#include <idn/assert.h> +#include <idn/logmacro.h> +#include <idn/result.h> +#include <idn/strhash.h> + +/* + * Initially, the number of hash buckets is INITIAL_HASH_SIZE. + * As the more elements are put in the hash, the number of elements + * per bucket will exceed THRESHOLD eventually. When it happens, + * the number of buckets will be multiplied by FACTOR. + */ +#define INITIAL_HASH_SIZE 67 +#define FACTOR 7 +#define THRESHOLD 5 + +#define HASH_MULT 31 + +typedef struct strhash_entry { + struct strhash_entry *next; + unsigned long hash_value; + char *key; + void *value; +} strhash_entry_t; + +struct idn__strhash { + int nbins; + int nelements; + strhash_entry_t **bins; +}; + +static unsigned long hash_value(const char *key); +static strhash_entry_t *find_entry(strhash_entry_t *entry, const char *key, + unsigned long hash); +static strhash_entry_t *new_entry(const char *key, void *value); +static idn_result_t expand_bins(idn__strhash_t hash, int new_size); + +idn_result_t +idn__strhash_create(idn__strhash_t *hashp) { + idn__strhash_t hash; + idn_result_t r; + + TRACE(("idn__strhash_create()\n")); + + assert(hashp != NULL); + + *hashp = NULL; + + if ((hash = malloc(sizeof(struct idn__strhash))) == NULL) { + WARNING(("idn__strhash_create: malloc failed (hash)\n")); + return (idn_nomemory); + } + hash->nbins = 0; + hash->nelements = 0; + hash->bins = NULL; + if ((r = expand_bins(hash, INITIAL_HASH_SIZE)) != idn_success) { + WARNING(("idn__strhash_create: malloc failed (bins)\n")); + free(hash); + return (r); + } + + *hashp = hash; + + return (idn_success); +} + +void +idn__strhash_destroy(idn__strhash_t hash, idn__strhash_freeproc_t proc) { + int i; + + assert(hash != NULL && hash->bins != NULL); + + for (i = 0; i < hash->nbins; i++) { + strhash_entry_t *bin = hash->bins[i]; + strhash_entry_t *next; + + while (bin != NULL) { + next = bin->next; + if (proc != NULL) + (*proc)(bin->value); + free(bin); + bin = next; + } + } + free(hash->bins); + free(hash); +} + +idn_result_t +idn__strhash_put(idn__strhash_t hash, const char *key, void *value) { + unsigned long h, h_index; + strhash_entry_t *entry; + + assert(hash != NULL && key != NULL); + + h = hash_value(key); + h_index = h % hash->nbins; + + if ((entry = find_entry(hash->bins[h_index], key, h)) != NULL) { + /* Entry exists. Replace the value. */ + entry->value = value; + } else { + /* Create new entry. */ + if ((entry = new_entry(key, value)) == NULL) { + return (idn_nomemory); + } + /* Insert it to the list. */ + entry->next = hash->bins[h_index]; + hash->bins[h_index] = entry; + hash->nelements++; + + if (hash->nelements > hash->nbins * THRESHOLD) { + idn_result_t r; + r = expand_bins(hash, hash->nbins * FACTOR); + if (r != idn_success) { + TRACE(("idn__strhash_put: hash table " + "expansion failed\n")); + } + } + } + + return (idn_success); +} + +idn_result_t +idn__strhash_get(idn__strhash_t hash, const char *key, void **valuep) { + unsigned long h; + strhash_entry_t *entry; + + assert(hash != NULL && key != NULL && valuep != NULL); + + h = hash_value(key); + entry = find_entry(hash->bins[h % hash->nbins], key, h); + if (entry == NULL) + return (idn_noentry); + + *valuep = entry->value; + return (idn_success); +} + +int +idn__strhash_exists(idn__strhash_t hash, const char *key) { + unsigned long h; + + assert(hash != NULL && key != NULL); + + h = hash_value(key); + return (find_entry(hash->bins[h % hash->nbins], key, h) != NULL); +} + +static unsigned long +hash_value(const char *key) { + unsigned long h = 0; + unsigned char *p = (unsigned char *)key; + int c; + + while ((c = *p++) != '\0') { + h = h * HASH_MULT + c; + } + return (h); +} + +static strhash_entry_t * +find_entry(strhash_entry_t *entry, const char *key, unsigned long hash) { + assert(key != NULL); + + while (entry != NULL) { + if (entry->hash_value == hash && strcmp(key, entry->key) == 0) + return (entry); + entry = entry->next; + } + return (NULL); +} + +static strhash_entry_t * +new_entry(const char *key, void *value) { + strhash_entry_t *entry; + int len; + + assert(key != NULL); + + len = strlen(key) + 1; + if ((entry = malloc(sizeof(strhash_entry_t) + len)) == NULL) { + return (NULL); + } + entry->next = NULL; + entry->hash_value = hash_value(key); + entry->key = (char *)(entry + 1); + (void)strcpy(entry->key, key); + entry->value = value; + + return (entry); +} + +static idn_result_t +expand_bins(idn__strhash_t hash, int new_size) { + strhash_entry_t **old_bins, **new_bins; + int old_size; + int old_index, new_index; + + new_bins = malloc(sizeof(strhash_entry_t *) * new_size); + if (new_bins == NULL) + return (idn_nomemory); + + memset(new_bins, 0, sizeof(strhash_entry_t *) * new_size); + + old_bins = hash->bins; + old_size = hash->nbins; + for (old_index = 0; old_index < old_size; old_index++) { + strhash_entry_t *entries = old_bins[old_index]; + + while (entries != NULL) { + strhash_entry_t *e = entries; + + /* Remove the top element from the linked list. */ + entries = entries->next; + + /* ..and move to the new hash. */ + new_index = e->hash_value % new_size; + e->next = new_bins[new_index]; + new_bins[new_index] = e; + } + } + + hash->nbins = new_size; + hash->bins = new_bins; + + if (old_bins != NULL) + free(old_bins); + + return (idn_success); +} diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/Makefile.in b/contrib/idn/idnkit-1.0-src/lib/tests/Makefile.in new file mode 100644 index 0000000..124ccec --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/tests/Makefile.in @@ -0,0 +1,304 @@ +# $Id: Makefile.in,v 1.2 2004/07/20 07:13:39 marka Exp $ +# Copyright (c) 2000, 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. + +.SUFFIXES: +.SUFFIXES: .tsy .c + +top_builddir = ../.. + +srcdir = @srcdir@ +VPATH = @srcdir@ + +CC = @CC@ +SHELL = @SHELL@ +LIBTOOL = @LIBTOOL@ + +ICONVINC = @ICONVINC@ +ICONVLIB = @ICONVLIB@ +IDNLIB = ../libidntest.la +IDNLITELIB = ../libidntestlite.la + +INCS = -I. -I$(srcdir) -I$(srcdir)/../../include -I../../include $(ICONVINC) +DEFS = + +CFLAGS = $(INCS) $(DEFS) @CPPFLAGS@ @CFLAGS@ +LDFLAGS = @LDFLAGS@ +TSYFLAGS = + +PERL = @PERL@ + +COMMONSRCS = testsuite.c testutil.c setenv.c +COMMONOBJS = testsuite.lo testutil.lo setenv.lo +BUILTSRCS = api.c api-init1.c api-init2.c api-init3.c \ + api-init4-1.c api-init4-2.c api-init4-3.c \ + api-init5-1.c api-init5-2.c api-init5-3.c \ + res.c resconf.c mapselector.c checker.c converter.c mapper.c \ + normalizer.c delimitermap.c ucs4.c nameprep.c \ + testconfig.h + +TESTS = api-test \ + api-init1-test \ + api-init2-test \ + api-init3-test \ + api-init4-1-test \ + api-init4-2-test \ + api-init4-3-test \ + api-init5-1-test \ + api-init5-2-test \ + api-init5-3-test \ + res-test \ + resconf-test \ + mapselector-test \ + converter-test \ + checker-test \ + mapper-test \ + normalizer-test \ + delimitermap-test \ + ucs4-test \ + nameprep-test + +LITETESTS = apilite-test \ + reslite-test \ + resconflite-test \ + converterlite-test + +.tsy.c: + rm -f $@ $@.tmp + $(PERL) $(srcdir)/testygen -o $@ $(TSYFLAGS) $< + $(PERL) $(srcdir)/utffilter $@ > $@.tmp + mv -f $@.tmp $@ + +all: + +install: + +clean: + rm -f *.o *.lo *.tmp core *.core *~ + rm -f $(TESTS) $(LITETESTS) $(BUILTSRCS) + rm -f test.conf testalias.conf test.map + rm -f iconvchk + rm -fr .libs/ + +distclean: clean + rm -f Makefile + +@LITEONLY_TRUE@test check: test-lite +@LITEONLY_FALSE@test check: test-nolite + +test-lite: $(LITETESTS) + @for i in $(LITETESTS); do \ + echo "Run test program: $$i"; \ + ./$$i; \ + echo; \ + done + +test-nolite: $(TESTS) $(LITETESTS) iconvchk + @./iconvchk + @for i in $(TESTS) $(LITETESTS); do \ + echo "Run test program: $$i"; \ + ./$$i; \ + echo; \ + done + +api-test: api.lo $(IDNLIB) $(COMMONOBJS) + $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ \ + api.lo $(COMMONOBJS) $(IDNLIB) $(ICONVLIB) +api.lo: api.c testconfig.h + $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c api.c + +apilite-test: apilite.lo $(IDNLITELIB) $(COMMONOBJS) + $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ \ + apilite.lo $(COMMONOBJS) $(IDNLITELIB) +apilite.lo: api.c testconfig.h + $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -DWITHOUT_ICONV -o $@ \ + -c api.c + +api-init1-test: api-init1.lo $(IDNLIB) $(COMMONOBJS) + $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ \ + api-init1.lo $(COMMONOBJS) $(IDNLIB) $(ICONVLIB) +api-init1.lo: api-init1.c testconfig.h + $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c api-init1.c + +api-init2-test: api-init2.lo $(IDNLIB) $(COMMONOBJS) + $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ \ + api-init2.lo $(COMMONOBJS) $(IDNLIB) $(ICONVLIB) +api-init2.lo: api-init2.c testconfig.h + $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c api-init2.c + +api-init3-test: api-init3.lo $(IDNLIB) $(COMMONOBJS) + $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ \ + api-init3.lo $(COMMONOBJS) $(IDNLIB) $(ICONVLIB) +api-init3.lo: api-init3.c testconfig.h + $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c api-init3.c + +api-init4-1-test: api-init4-1.lo $(IDNLIB) $(COMMONOBJS) + $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ \ + api-init4-1.lo $(COMMONOBJS) $(IDNLIB) $(ICONVLIB) +api-init4-1.lo: api-init4-1.c testconfig.h + $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c api-init4-1.c + +api-init4-2-test: api-init4-2.lo $(IDNLIB) $(COMMONOBJS) + $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ \ + api-init4-2.lo $(COMMONOBJS) $(IDNLIB) $(ICONVLIB) +api-init4-2.lo: api-init4-2.c testconfig.h + $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c api-init4-2.c + +api-init4-3-test: api-init4-3.lo $(IDNLIB) $(COMMONOBJS) + $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ \ + api-init4-3.lo $(COMMONOBJS) $(IDNLIB) $(ICONVLIB) +api-init4-3.lo: api-init4-3.c testconfig.h + $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c api-init4-3.c + +api-init5-1-test: api-init5-1.lo $(IDNLIB) $(COMMONOBJS) + $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ \ + api-init5-1.lo $(COMMONOBJS) $(IDNLIB) $(ICONVLIB) +api-init5-1.lo: api-init5-1.c testconfig.h + $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c api-init5-1.c + +api-init5-2-test: api-init5-2.lo $(IDNLIB) $(COMMONOBJS) + $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ \ + api-init5-2.lo $(COMMONOBJS) $(IDNLIB) $(ICONVLIB) +api-init5-2.lo: api-init5-2.c testconfig.h + $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c api-init5-2.c + +api-init5-3-test: api-init5-3.lo $(IDNLIB) $(COMMONOBJS) + $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ \ + api-init5-3.lo $(COMMONOBJS) $(IDNLIB) $(ICONVLIB) +api-init5-3.lo: api-init5-3.c testconfig.h + $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c api-init5-3.c + +res-test: res.lo $(IDNLIB) $(COMMONOBJS) + $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ \ + res.lo $(COMMONOBJS) $(IDNLIB) $(ICONVLIB) +res.lo: res.c testconfig.h + $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c res.c + +reslite-test: reslite.lo $(IDNLITELIB) $(COMMONOBJS) + $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ \ + reslite.lo $(COMMONOBJS) $(IDNLITELIB) +reslite.lo: res.c testconfig.h + $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -DWITHOUT_ICONV -o $@ \ + -c res.c + +resconf-test: resconf.lo $(IDNLIB) $(COMMONOBJS) + $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ \ + resconf.lo $(COMMONOBJS) $(IDNLIB) $(ICONVLIB) +resconf.lo: resconf.c testconfig.h + $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c resconf.c + +resconflite-test: resconflite.lo $(IDNLITELIB) $(COMMONOBJS) + $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ \ + resconflite.lo $(COMMONOBJS) $(IDNLITELIB) +resconflite.lo: resconf.c testconfig.h + $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -DWITHOUT_ICONV -o $@ \ + -c resconf.c + +mapselector-test: mapselector.lo $(IDNLIB) $(COMMONOBJS) + $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ \ + mapselector.lo $(COMMONOBJS) $(IDNLIB) $(ICONVLIB) +mapselector.lo: mapselector.c + $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c mapselector.c + +converter-test: converter.lo $(IDNLIB) $(COMMONOBJS) + $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ \ + converter.lo $(COMMONOBJS) $(IDNLIB) $(ICONVLIB) +converter.lo: converter.c + $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c converter.c + +converterlite-test: converterlite.lo $(IDNLITELIB) $(COMMONOBJS) + $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ \ + converterlite.lo $(COMMONOBJS) $(IDNLITELIB) +converterlite.lo: converter.c + $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -DWITHOUT_ICONV -o $@ \ + -c converter.c + +checker-test: checker.lo $(IDNLIB) $(COMMONOBJS) + $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ \ + checker.lo $(COMMONOBJS) $(IDNLIB) $(ICONVLIB) +checker.lo: checker.c + $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c checker.c + +mapper-test: mapper.lo $(IDNLIB) $(COMMONOBJS) + $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ \ + mapper.lo $(COMMONOBJS) $(IDNLIB) $(ICONVLIB) +mapper.lo: mapper.c + $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c mapper.c + +normalizer-test: normalizer.lo $(IDNLIB) $(COMMONOBJS) + $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ \ + normalizer.lo $(COMMONOBJS) $(IDNLIB) $(ICONVLIB) +normalizer.lo: normalizer.c + $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c normalizer.c + +delimitermap-test: delimitermap.lo $(IDNLIB) $(COMMONOBJS) + $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ \ + delimitermap.lo $(COMMONOBJS) $(IDNLIB) $(ICONVLIB) +delimitermap.lo: delimitermap.c + $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c delimitermap.c + +ucs4-test: ucs4.lo $(IDNLIB) $(COMMONOBJS) + $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ \ + ucs4.lo $(COMMONOBJS) $(IDNLIB) $(ICONVLIB) +ucs4.lo: ucs4.c + $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c ucs4.c + +nameprep-test: nameprep.lo $(IDNLIB) $(COMMONOBJS) + $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ \ + nameprep.lo $(COMMONOBJS) $(IDNLIB) $(ICONVLIB) +nameprep.lo: nameprep.c + $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c nameprep.c + +testsuite.lo: testsuite.c testsuite.h + $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -o $@ -c $(srcdir)/testsuite.c +testutil.lo: testutil.c testutil.h + $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -o $@ -c $(srcdir)/testutil.c +setenv.lo: setenv.c + $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -o $@ -c $(srcdir)/setenv.c + +testconfig.h: ../../include/config.h + rm -f testconfig.h + sed -n -e '/HAVE_SETENV/p' -e '/HAVE_UNSETENV/p' \ + ../../include/config.h > testconfig.h + +iconvchk: iconvchk.c codeset.h + $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ \ + $(srcdir)/iconvchk.c $(IDNLIB) $(ICONVLIB) diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/api-init1.tsy b/contrib/idn/idnkit-1.0-src/lib/tests/api-init1.tsy new file mode 100644 index 0000000..202db15 --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/tests/api-init1.tsy @@ -0,0 +1,113 @@ +#ifndef lint +static char *rcsid = "$Id: api-init1.tsy,v 1.1.1.1 2003/06/04 00:26:46 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 <idn/api.h> +#include <idn/log.h> + +#include "codeset.h" +#include "setenv.h" +#include "testutil.h" + +#ifndef EUCJP_ENCODING_NAME +#define EUCJP_ENCODING_NAME "eucJP" +#endif + +#define CONF_FILENAME "test.conf" + +//-------------------------------------------------------------------- +// Setups and Teardowns. +//-------------------------------------------------------------------- + +//# SETUP +// group: init +{ + char to[256]; + idn_result_t r; + + setenv("IDN_LOCAL_CODESET", "UTF-8", 1); + unsetenv("IDN_DISABLE"); + create_conf_file(CONF_FILENAME, 0, + "idn-encoding UTF-8", + NULL); +} + +//# TEARDOWN +// group: init +{ + remove(CONF_FILENAME); +} + +//-------------------------------------------------------------------- +// Testcases. +//-------------------------------------------------------------------- + +//# TESTCASE +// title: nameinit(0) +// group: init +{ + r = idn__setconffile(CONF_FILENAME); + ASSERT_RESULT(r, idn_success); + + r = idn_nameinit(0); + ASSERT_RESULT(r, idn_success); + + r = idn_encodename(IDN_ENCODE_APP, "<U+3042>", to, sizeof(to)); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, "xn--l8j"); + + r = idn_decodename(IDN_DECODE_APP, "xn--l8j", to, sizeof(to)); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, "<U+3042>"); + + r = idn_decodename2(IDN_DECODE_APP, "xn--l8j", to, sizeof(to), + EUCJP_ENCODING_NAME); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, "<U+3042>"); +} diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/api-init2.tsy b/contrib/idn/idnkit-1.0-src/lib/tests/api-init2.tsy new file mode 100644 index 0000000..e1561a4 --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/tests/api-init2.tsy @@ -0,0 +1,113 @@ +#ifndef lint +static char *rcsid = "$Id: api-init2.tsy,v 1.1.1.1 2003/06/04 00:26:47 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 <idn/api.h> +#include <idn/log.h> + +#include "codeset.h" +#include "setenv.h" +#include "testutil.h" + +#ifndef EUCJP_ENCODING_NAME +#define EUCJP_ENCODING_NAME "eucJP" +#endif + +#define CONF_FILENAME "test.conf" + +//-------------------------------------------------------------------- +// Setups and Teardowns. +//-------------------------------------------------------------------- + +//# SETUP +// group: init +{ + char to[256]; + idn_result_t r; + + setenv("IDN_LOCAL_CODESET", "UTF-8", 1); + unsetenv("IDN_DISABLE"); + create_conf_file(CONF_FILENAME, 0, + "idn-encoding UTF-8", + NULL); +} + +//# TEARDOWN +// group: init +{ + remove(CONF_FILENAME); +} + +//-------------------------------------------------------------------- +// Testcases. +//-------------------------------------------------------------------- + +//# TESTCASE +// title: nameinit(1) +// group: init +{ + r = idn__setconffile(CONF_FILENAME); + ASSERT_RESULT(r, idn_success); + + r = idn_nameinit(1); + ASSERT_RESULT(r, idn_success); + + r = idn_encodename(IDN_ENCODE_APP, "<U+3042>", to, sizeof(to)); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, "<U+3042>"); + + r = idn_decodename(IDN_DECODE_APP, "xn--l8j", to, sizeof(to)); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, "xn--l8j"); + + r = idn_decodename2(IDN_DECODE_APP, "xn--l8j", to, sizeof(to), + EUCJP_ENCODING_NAME); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, "xn--l8j"); +} diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/api-init3.tsy b/contrib/idn/idnkit-1.0-src/lib/tests/api-init3.tsy new file mode 100644 index 0000000..9035cab --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/tests/api-init3.tsy @@ -0,0 +1,117 @@ +#ifndef lint +static char *rcsid = "$Id: api-init3.tsy,v 1.1.1.1 2003/06/04 00:26:47 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 <idn/api.h> +#include <idn/log.h> + +#include "codeset.h" +#include "setenv.h" +#include "testutil.h" + +#ifndef EUCJP_ENCODING_NAME +#define EUCJP_ENCODING_NAME "eucJP" +#endif + +#define CONF_FILENAME "test.conf" + +//-------------------------------------------------------------------- +// Setups and Teardowns. +//-------------------------------------------------------------------- + +//# SETUP +// group: init +{ + char to[256]; + idn_result_t r; + + setenv("IDN_LOCAL_CODESET", "UTF-8", 1); + unsetenv("IDN_DISABLE"); + create_conf_file(CONF_FILENAME, 0, + "idn-encoding UTF-8", + NULL); +} + +//# TEARDOWN +// group: init +{ + remove(CONF_FILENAME); +} + +//-------------------------------------------------------------------- +// Testcases. +//-------------------------------------------------------------------- + +//# TESTCASE +// title: call nameinit() twice +// group: init +{ + r = idn__setconffile(CONF_FILENAME); + ASSERT_RESULT(r, idn_success); + + r = idn_nameinit(1); + ASSERT_RESULT(r, idn_success); + r = idn_nameinit(0); + ASSERT_RESULT(r, idn_success); + + r = idn_encodename(IDN_ENCODE_APP, "<U+3042>", to, sizeof(to)); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, "<U+3042>"); + + r = idn_decodename(IDN_DECODE_APP, "xn--l8j", to, sizeof(to)); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, "xn--l8j"); + + r = idn_decodename2(IDN_DECODE_APP, "xn--l8j", to, sizeof(to), + EUCJP_ENCODING_NAME); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, "xn--l8j"); + + remove(CONF_FILENAME); +} diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/api-init4-1.tsy b/contrib/idn/idnkit-1.0-src/lib/tests/api-init4-1.tsy new file mode 100644 index 0000000..585b581 --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/tests/api-init4-1.tsy @@ -0,0 +1,96 @@ +#ifndef lint +static char *rcsid = "$Id: api-init4-1.tsy,v 1.1.1.1 2003/06/04 00:26:47 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 <idn/api.h> +#include <idn/log.h> + +#include "setenv.h" +#include "testutil.h" + +#define CONF_FILENAME "test.conf" + +//-------------------------------------------------------------------- +// Setups and Teardowns. +//-------------------------------------------------------------------- + +//# SETUP +// group: init +{ + char to[256]; + idn_result_t r; + + setenv("IDN_LOCAL_CODESET", "UTF-8", 1); + unsetenv("IDN_DISABLE"); + create_conf_file(CONF_FILENAME, 0, + "idn-encoding UTF-8", + NULL); +} + +//# TEARDOWN +// group: init +{ + remove(CONF_FILENAME); +} + +//-------------------------------------------------------------------- +// Testcases. +//-------------------------------------------------------------------- + +//# TESTCASE +// title: call encodename() without initialization +// group: init +{ + r = idn__setconffile(CONF_FILENAME); + ASSERT_RESULT(r, idn_success); + + r = idn_encodename(IDN_ENCODE_APP, "<U+3042>", to, sizeof(to)); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, "xn--l8j"); +} diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/api-init4-2.tsy b/contrib/idn/idnkit-1.0-src/lib/tests/api-init4-2.tsy new file mode 100644 index 0000000..fd0150b --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/tests/api-init4-2.tsy @@ -0,0 +1,96 @@ +#ifndef lint +static char *rcsid = "$Id: api-init4-2.tsy,v 1.1.1.1 2003/06/04 00:26:47 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 <idn/api.h> +#include <idn/log.h> + +#include "setenv.h" +#include "testutil.h" + +#define CONF_FILENAME "test.conf" + +//-------------------------------------------------------------------- +// Setups and Teardowns. +//-------------------------------------------------------------------- + +//# SETUP +// group: init +{ + char to[256]; + idn_result_t r; + + setenv("IDN_LOCAL_CODESET", "UTF-8", 1); + unsetenv("IDN_DISABLE"); + create_conf_file(CONF_FILENAME, 0, + "idn-encoding UTF-8", + NULL); +} + +//# TEARDOWN +// group: init +{ + remove(CONF_FILENAME); +} + +//-------------------------------------------------------------------- +// Testcases. +//-------------------------------------------------------------------- + +//# TESTCASE +// title: call decodename() without initialization +// group: init +{ + r = idn__setconffile(CONF_FILENAME); + ASSERT_RESULT(r, idn_success); + + r = idn_decodename(IDN_DECODE_APP, "xn--l8j", to, sizeof(to)); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, "<U+3042>"); +} diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/api-init4-3.tsy b/contrib/idn/idnkit-1.0-src/lib/tests/api-init4-3.tsy new file mode 100644 index 0000000..7da74b9 --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/tests/api-init4-3.tsy @@ -0,0 +1,102 @@ +#ifndef lint +static char *rcsid = "$Id: api-init4-3.tsy,v 1.1.1.1 2003/06/04 00:26:47 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 <idn/api.h> +#include <idn/log.h> + +#include "codeset.h" +#include "setenv.h" +#include "testutil.h" + +#ifndef EUCJP_ENCODING_NAME +#define EUCJP_ENCODING_NAME "eucJP" +#endif + +#define CONF_FILENAME "test.conf" + +//-------------------------------------------------------------------- +// Setups and Teardowns. +//-------------------------------------------------------------------- + +//# SETUP +// group: init +{ + char to[256]; + idn_result_t r; + + setenv("IDN_LOCAL_CODESET", "UTF-8", 1); + unsetenv("IDN_DISABLE"); + create_conf_file(CONF_FILENAME, 0, + "idn-encoding UTF-8", + NULL); +} + +//# TEARDOWN +// group: init +{ + remove(CONF_FILENAME); +} + +//-------------------------------------------------------------------- +// Testcases. +//-------------------------------------------------------------------- + +//# TESTCASE +// title: call decodename2() without initialization +// group: init +{ + r = idn__setconffile(CONF_FILENAME); + ASSERT_RESULT(r, idn_success); + + r = idn_decodename2(IDN_DECODE_APP, "xn--l8j", to, sizeof(to), + EUCJP_ENCODING_NAME); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, "<U+3042>"); +} diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/api-init5-1.tsy b/contrib/idn/idnkit-1.0-src/lib/tests/api-init5-1.tsy new file mode 100644 index 0000000..5669502 --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/tests/api-init5-1.tsy @@ -0,0 +1,102 @@ +#ifndef lint +static char *rcsid = "$Id: api-init5-1.tsy,v 1.1.1.1 2003/06/04 00:26:48 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 <idn/api.h> +#include <idn/log.h> + +#include "setenv.h" +#include "testutil.h" + +#define CONF_FILENAME "test.conf" + +//-------------------------------------------------------------------- +// Setups and Teardowns. +//-------------------------------------------------------------------- + +//# SETUP +// group: init +{ + char to[256]; + idn_result_t r; + + setenv("IDN_LOCAL_CODESET", "UTF-8", 1); + unsetenv("IDN_DISABLE"); + create_conf_file(CONF_FILENAME, 0, + "idn-encoding UTF-8", + NULL); +} + +//# TEARDOWN +// group: init +{ + remove(CONF_FILENAME); +} + +//-------------------------------------------------------------------- +// Testcases. +//-------------------------------------------------------------------- + +//# TESTCASE +// title: call encodename() and nameinit() +// group: init +{ + r = idn__setconffile(CONF_FILENAME); + ASSERT_RESULT(r, idn_success); + + r = idn_encodename(IDN_ENCODE_APP, "aaa", to, sizeof(to)); + ASSERT_RESULT(r, idn_success); + + r = idn_nameinit(1); + ASSERT_RESULT(r, idn_success); + + r = idn_encodename(IDN_ENCODE_APP, "<U+3042>", to, sizeof(to)); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, "xn--l8j"); +} diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/api-init5-2.tsy b/contrib/idn/idnkit-1.0-src/lib/tests/api-init5-2.tsy new file mode 100644 index 0000000..bf08862 --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/tests/api-init5-2.tsy @@ -0,0 +1,102 @@ +#ifndef lint +static char *rcsid = "$Id: api-init5-2.tsy,v 1.1.1.1 2003/06/04 00:26:48 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 <idn/api.h> +#include <idn/log.h> + +#include "setenv.h" +#include "testutil.h" + +#define CONF_FILENAME "test.conf" + +//-------------------------------------------------------------------- +// Setups and Teardowns. +//-------------------------------------------------------------------- + +//# SETUP +// group: init +{ + char to[256]; + idn_result_t r; + + setenv("IDN_LOCAL_CODESET", "UTF-8", 1); + unsetenv("IDN_DISABLE"); + create_conf_file(CONF_FILENAME, 0, + "idn-encoding UTF-8", + NULL); +} + +//# TEARDOWN +// group: init +{ + remove(CONF_FILENAME); +} + +//-------------------------------------------------------------------- +// Testcases. +//-------------------------------------------------------------------- + +//# TESTCASE +// title: call decodename() and nameinit() +// group: init +{ + r = idn__setconffile(CONF_FILENAME); + ASSERT_RESULT(r, idn_success); + + r = idn_decodename(IDN_DECODE_APP, "aaa", to, sizeof(to)); + ASSERT_RESULT(r, idn_success); + + r = idn_nameinit(1); + ASSERT_RESULT(r, idn_success); + + r = idn_decodename(IDN_DECODE_APP, "xn--l8j", to, sizeof(to)); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, "<U+3042>"); +} diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/api-init5-3.tsy b/contrib/idn/idnkit-1.0-src/lib/tests/api-init5-3.tsy new file mode 100644 index 0000000..fae1942 --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/tests/api-init5-3.tsy @@ -0,0 +1,109 @@ +#ifndef lint +static char *rcsid = "$Id: api-init5-3.tsy,v 1.1.1.1 2003/06/04 00:26:48 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 <idn/api.h> +#include <idn/log.h> + +#include "codeset.h" +#include "setenv.h" +#include "testutil.h" + +#ifndef EUCJP_ENCODING_NAME +#define EUCJP_ENCODING_NAME "eucJP" +#endif + +#define CONF_FILENAME "test.conf" + +//-------------------------------------------------------------------- +// Setups and Teardowns. +//-------------------------------------------------------------------- + +//# SETUP +// group: init +{ + char to[256]; + idn_result_t r; + + setenv("IDN_LOCAL_CODESET", "UTF-8", 1); + unsetenv("IDN_DISABLE"); + create_conf_file(CONF_FILENAME, 0, + "idn-encoding UTF-8", + NULL); +} + +//# TEARDOWN +// group: init +{ + remove(CONF_FILENAME); +} + +//-------------------------------------------------------------------- +// Testcases. +//-------------------------------------------------------------------- + +//# TESTCASE +// title: call decodename2() and nameinit() +// group: init +{ + r = idn__setconffile(CONF_FILENAME); + ASSERT_RESULT(r, idn_success); + + r = idn_decodename2(IDN_DECODE_APP, "aaa", to, sizeof(to), + EUCJP_ENCODING_NAME); + ASSERT_RESULT(r, idn_success); + + r = idn_nameinit(1); + ASSERT_RESULT(r, idn_success); + + r = idn_decodename2(IDN_DECODE_APP, "xn--l8j", to, sizeof(to), + EUCJP_ENCODING_NAME); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, "<U+3042>"); +} diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/api.tsy b/contrib/idn/idnkit-1.0-src/lib/tests/api.tsy new file mode 100644 index 0000000..3ecfb20 --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/tests/api.tsy @@ -0,0 +1,1009 @@ +#ifndef lint +static 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 +{ +#ifdef WITHOUT_ICONV + SKIP_TESTCASE; +#else + setenv("IDN_DISABLE", "1", 1); + 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 then call enable(1) and encodename() +// group: generic-conversion +{ + setenv("IDN_DISABLE", "1", 1); + idn_enable(1); + r = idn_encodename(IDN_ENCODE_APP, UTF8_NAME, to, sizeof(to)); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, PUNYCODE_NAME); +} + +//# TESTCASE +// title: set IDN_DISABLE, and then call enable(1) and decodename() +// group: generic-conversion +{ + setenv("IDN_DISABLE", "1", 1); + idn_enable(1); + r = idn_decodename(IDN_DECODE_APP, PUNYCODE_NAME, to, sizeof(to)); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, UTF8_REVNAME); +} + +//# TESTCASE +// title: set IDN_DISABLE, and then call enable(1) and decodename2() +// group: generic-conversion +{ +#ifdef WITHOUT_ICONV + SKIP_TESTCASE; +#else + setenv("IDN_DISABLE", "1", 1); + idn_enable(1); + r = idn_decodename2(IDN_DECODE_APP, AUX_EUCJP_NAME, to, sizeof(to), + EUCJP_ENCODING_NAME); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, UTF8_REVNAME); +#endif +} + +//# TESTCASE +// title: overrun test for arg `to' of encodename() +// group: generic-conversion +{ + /* Normal case */ + r = idn_encodename(IDN_ENCODE_APP, UTF8_NAME, to, + strlen(PUNYCODE_NAME) + 1); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, PUNYCODE_NAME); + + r = idn_encodename(IDN_ENCODE_APP, UTF8_NAME, to, + strlen(PUNYCODE_NAME)); + ASSERT_RESULT(r, idn_buffer_overflow); + + /* enable(0) case */ + idn_enable(0); + r = idn_encodename(IDN_ENCODE_APP, UTF8_NAME, to, + strlen(UTF8_NAME) + 1); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, UTF8_NAME); + + r = idn_encodename(IDN_ENCODE_APP, UTF8_NAME, to, + strlen(UTF8_NAME)); + ASSERT_RESULT(r, idn_buffer_overflow); + + /* actions=0 case */ + idn_enable(1); + r = idn_encodename(0, UTF8_NAME, to, strlen(UTF8_NAME) + 1); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, UTF8_NAME); + + r = idn_encodename(0, UTF8_NAME, to, strlen(UTF8_NAME)); + ASSERT_RESULT(r, idn_buffer_overflow); +} + +//# TESTCASE +// title: overrun test for arg `to' of decodename() +// group: generic-conversion +{ + /* Normal case */ + r = idn_decodename(IDN_DECODE_APP, PUNYCODE_NAME, to, + strlen(UTF8_REVNAME) + 1); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, UTF8_REVNAME); + + r = idn_decodename(IDN_DECODE_APP, PUNYCODE_NAME, to, + strlen(UTF8_REVNAME)); + ASSERT_RESULT(r, idn_buffer_overflow); + + /* idn_enable(0) case */ + idn_enable(0); + r = idn_decodename(IDN_DECODE_APP, PUNYCODE_NAME, to, + strlen(PUNYCODE_NAME) + 1); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, PUNYCODE_NAME); + + r = idn_decodename(IDN_DECODE_APP, PUNYCODE_NAME, to, + strlen(PUNYCODE_NAME)); + ASSERT_RESULT(r, idn_buffer_overflow); + + /* actions=0 case */ + idn_enable(1); + r = idn_decodename(0, PUNYCODE_NAME, to, strlen(PUNYCODE_NAME) + 1); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, PUNYCODE_NAME); + + r = idn_decodename(0, PUNYCODE_NAME, to, strlen(PUNYCODE_NAME)); + ASSERT_RESULT(r, idn_buffer_overflow); +} + +//# TESTCASE +// title: overrun test for arg `to' of decodename2() +// group: generic-conversion +{ +#ifdef WITHOUT_ICONV + SKIP_TESTCASE; +#else + /* Normal case */ + r = idn_decodename2(IDN_DECODE_APP, AUX_EUCJP_NAME, to, + strlen(UTF8_REVNAME) + 1, EUCJP_ENCODING_NAME); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, UTF8_REVNAME); + + r = idn_decodename2(IDN_DECODE_APP, AUX_EUCJP_NAME, to, + strlen(UTF8_REVNAME), EUCJP_ENCODING_NAME); + ASSERT_RESULT(r, idn_buffer_overflow); + + /* idn_enable(0) case */ + idn_enable(0); + r = idn_decodename2(IDN_DECODE_APP, AUX_EUCJP_NAME, to, + strlen(AUX_EUCJP_NAME) + 1, EUCJP_ENCODING_NAME); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, AUX_EUCJP_NAME); + + r = idn_decodename2(IDN_DECODE_APP, AUX_EUCJP_NAME, to, + strlen(AUX_EUCJP_NAME), EUCJP_ENCODING_NAME); + ASSERT_RESULT(r, idn_buffer_overflow); + + /* actions=0 case */ + idn_enable(1); + r = idn_decodename2(0, AUX_EUCJP_NAME, to, strlen(AUX_EUCJP_NAME) + 1, + EUCJP_ENCODING_NAME); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, AUX_EUCJP_NAME); + + r = idn_decodename2(0, AUX_EUCJP_NAME, to, strlen(AUX_EUCJP_NAME), + EUCJP_ENCODING_NAME); + ASSERT_RESULT(r, idn_buffer_overflow); + +#endif +} + +//# TESTCASE +// title: call encodename() with tolen=0 +// group: generic-conversion +{ + r = idn_encodename(IDN_ENCODE_APP, UTF8_NAME, to, 0); + ASSERT_RESULT(r, idn_buffer_overflow); +} + +//# TESTCASE +// title: call decodename() with tolen=0 +// group: generic-conversion +{ + r = idn_decodename(IDN_DECODE_APP, PUNYCODE_NAME, to, 0); + ASSERT_RESULT(r, idn_buffer_overflow); +} + +//# TESTCASE +// title: call decodename2() with tolen=0 +// group: generic-conversion +{ +#ifdef WITHOUT_ICONV + SKIP_TESTCASE; +#else + r = idn_decodename2(IDN_DECODE_APP, AUX_EUCJP_NAME, to, 0, + EUCJP_ENCODING_NAME); + ASSERT_RESULT(r, idn_buffer_overflow); +#endif +} + +//# TESTCASE +// title: convert an empty string using encodename() +// group: generic-conversion +{ + r = idn_encodename(IDN_ENCODE_APP, "", to, sizeof(to)); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, ""); +} + +//# TESTCASE +// title: convert an empty string using decodename() +// group: generic-conversion +{ + r = idn_decodename(IDN_DECODE_APP, "", to, sizeof(to)); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, ""); +} + +//# TESTCASE +// title: convert an empty string using decodename2() +// group: generic-conversion +{ +#ifdef WITHOUT_ICONV + SKIP_TESTCASE; +#else + r = idn_decodename2(IDN_DECODE_APP, "", to, sizeof(to), + EUCJP_ENCODING_NAME); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, ""); +#endif +} + +//# TESTCASE +// title: prohcheck by encodename() +// group: generic-conversion +{ + /* U+1680: prohibited character */ + r = idn_encodename(IDN_PROHCHECK, "<U+1680>", to, sizeof(to)); + ASSERT_RESULT(r, idn_prohibited); +} + +//# TESTCASE +// title: unascheck by encodename() +// group: generic-conversion +{ + /* U+0221: unassigned codepoint */ + r = idn_encodename(IDN_UNASCHECK, "<U+0221>", to, sizeof(to)); + ASSERT_RESULT(r, idn_prohibited); +} + +//# TESTCASE +// title: bidicheck by encodename() +// group: generic-conversion +{ + /* U+05D0: bidirectional property is "R" */ + /* `a': bidirectional property is "L" */ + /* `0', `-': bidirectional property is "N" */ + r = idn_encodename(IDN_BIDICHECK, "<U+05D0>", to, sizeof(to)); + ASSERT_RESULT(r, idn_success); + + r = idn_encodename(IDN_BIDICHECK, "<U+05D0><U+05D0>", + to, sizeof(to)); + ASSERT_RESULT(r, idn_success); + + r = idn_encodename(IDN_BIDICHECK, "<U+05D0><U+05D0>-a", + to, sizeof(to)); + ASSERT_RESULT(r, idn_prohibited); + + r = idn_encodename(IDN_BIDICHECK, "<U+05D0>-a-<U+05D0>", + to, sizeof(to)); + ASSERT_RESULT(r, idn_prohibited); + + r = idn_encodename(IDN_BIDICHECK, "a-<U+05D0><U+05D0>", + to, sizeof(to)); + ASSERT_RESULT(r, idn_prohibited); + + r = idn_encodename(IDN_BIDICHECK, "<U+05D0><U+05D0>-0", + to, sizeof(to)); + ASSERT_RESULT(r, idn_prohibited); + + r = idn_encodename(IDN_BIDICHECK, "<U+05D0>-0-<U+05D0>", + to, sizeof(to)); + ASSERT_RESULT(r, idn_success); + + r = idn_encodename(IDN_BIDICHECK, "0-<U+05D0><U+05D0>", + to, sizeof(to)); + ASSERT_RESULT(r, idn_prohibited); +} + +//# TESTCASE +// title: asccheck by encodename() +// group: generic-conversion +{ + r = idn_encodename(IDN_ASCCHECK, "-name", to, sizeof(to)); + ASSERT_RESULT(r, idn_prohibited); + + r = idn_encodename(IDN_ASCCHECK, "name-", to, sizeof(to)); + ASSERT_RESULT(r, idn_prohibited); + + r = idn_encodename(IDN_ASCCHECK, "n ame", to, sizeof(to)); + ASSERT_RESULT(r, idn_prohibited); +} + +//# TESTCASE +// title: lencheck by encodename() +// group: generic-conversion +{ + r = idn_encodename(IDN_LENCHECK, + "123456789-123456789-123456789-123456789-" + "123456789-123456789-123", to, sizeof(to)); + ASSERT_RESULT(r, idn_success); + + r = idn_encodename(IDN_LENCHECK, + "123456789-123456789-123456789-123456789-" + "123456789-123456789-1234", to, sizeof(to)); + ASSERT_RESULT(r, idn_invalid_length); + + r = idn_encodename(IDN_LENCHECK, "a..b", to, sizeof(to)); + ASSERT_RESULT(r, idn_invalid_length); +} + +//# TESTCASE +// title: rtcheck non-prohchecked label by decodename() +// group: generic-conversion +{ + /* "xn--6ue" -> "U+1680" (prohibited character) */ + r = idn_decodename(IDN_RTCHECK, "xn--6ue", to, sizeof(to)); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, "xn--6ue"); +} + +//# TESTCASE +// title: rtcheck non-unaschecked label by decodename() +// group: generic-conversion +{ + /* "xn--6la" -> "U+0221" (unassigned codepoint) */ + r = idn_decodename(IDN_IDNCONV | IDN_RTCHECK | IDN_UNASCHECK, + "xn--6la", to, sizeof(to)); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, "xn--6la"); +} + +//# TESTCASE +// title: rtcheck non-ascchecked label by decodename() +// group: generic-conversion +{ + /* "xn----x7t" -> "- U+3042" */ + r = idn_decodename(IDN_IDNCONV | IDN_RTCHECK | IDN_ASCCHECK, + "xn----x7t", to, sizeof(to)); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, "xn----x7t"); + + /* "xn----w7t" -> "U+3042 -" */ + r = idn_decodename(IDN_IDNCONV | IDN_RTCHECK | IDN_ASCCHECK, + "xn----w7t", to, sizeof(to)); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, "xn----w7t"); +} + +//# TESTCASE +// title: rtcheck non-lenchecked label by decodename() +// group: generic-conversion +{ + /* `s1' has 63 characters */ + const char *s1 = + "xn--l8jaa5522a8sj38bzugvvblo3y90fjzgvxlmxscifws3d43odzaq6aj340b"; + + const char *s1rev = + "<U+9752><U+68EE><U+5CA9><U+624B><U+5BAE><U+57CE><U+79CB><U+7530>" + "<U+5C71><U+5F62><U+798F><U+5CF6><U+6771><U+4EAC><U+795E><U+5948>" + "<U+5DDD><U+3042><U+3042><U+3042>"; + + /* `s2' has 64 characters */ + const char *s2 = + "xn--a-w7ta6522a8sj38bzugvvblo3y90fjzgvxlmxscifws3d43odzaq6aj340b"; + + /* `s3' has an empty label */ + const char *s3 = "a..b"; + + r = idn_decodename(IDN_IDNCONV | IDN_RTCHECK, s1, to, sizeof(to)); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, s1rev); + + r = idn_decodename(IDN_IDNCONV | IDN_RTCHECK, s2, to, sizeof(to)); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, s2); + + r = idn_decodename(IDN_IDNCONV | IDN_RTCHECK, s3, to, sizeof(to)); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, s3); +} + +//# TESTCASE +// title: rtcheck non-prohchecked label by decodename2() +// group: generic-conversion +{ +#ifdef WITHOUT_ICONV + SKIP_TESTCASE; +#else + /* "xn--6ue" -> "U+1680" (prohibited character) */ + r = idn_decodename2(IDN_RTCHECK, "xn--6ue", to, sizeof(to), + EUCJP_ENCODING_NAME); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, "xn--6ue"); +#endif +} + +//# TESTCASE +// title: rtcheck non-unaschecked label by decodename2() +// group: generic-conversion +{ +#ifdef WITHOUT_ICONV + SKIP_TESTCASE; +#else + /* "xn--6la" -> "U+0221" (unassigned codepoint) */ + r = idn_decodename2(IDN_IDNCONV | IDN_RTCHECK | IDN_UNASCHECK, + "xn--6la", to, sizeof(to), EUCJP_ENCODING_NAME); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, "xn--6la"); +#endif +} + +//# TESTCASE +// title: rtcheck non-ascchecked label by decodename2() +// group: generic-conversion +{ +#ifdef WITHOUT_ICONV + SKIP_TESTCASE; +#else + /* "xn----x7t" -> "- U+3042" */ + r = idn_decodename2(IDN_IDNCONV | IDN_RTCHECK | IDN_ASCCHECK, + "xn----x7t", to, sizeof(to), EUCJP_ENCODING_NAME); + + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, "xn----x7t"); + + /* "xn----w7t" -> "U+3042 -" */ + r = idn_decodename2(IDN_IDNCONV | IDN_RTCHECK | IDN_ASCCHECK, + "xn----w7t", to, sizeof(to), EUCJP_ENCODING_NAME); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, "xn----w7t"); +#endif +} + +//# TESTCASE +// title: rtcheck non-lenchecked label by decodename2() +// group: generic-conversion +{ +#ifdef WITHOUT_ICONV + SKIP_TESTCASE; +#else + /* `s1' has 63 characters */ + const char *s1 = + "xn--l8jaa5522a8sj38bzugvvblo3y90fjzgvxlmxscifws3d43odzaq6aj340b"; + + const char *s1rev = + "<U+9752><U+68EE><U+5CA9><U+624B><U+5BAE><U+57CE><U+79CB><U+7530>" + "<U+5C71><U+5F62><U+798F><U+5CF6><U+6771><U+4EAC><U+795E><U+5948>" + "<U+5DDD><U+3042><U+3042><U+3042>"; + + /* `s2' has 64 characters */ + const char *s2 = + "xn--a-w7ta6522a8sj38bzugvvblo3y90fjzgvxlmxscifws3d43odzaq6aj340b"; + + /* `s3' has an empty label */ + const char *s3 = "a..b"; + + r = idn_decodename2(IDN_IDNCONV | IDN_RTCHECK, s1, to, sizeof(to), + EUCJP_ENCODING_NAME); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, s1rev); + + r = idn_decodename2(IDN_IDNCONV | IDN_RTCHECK, s2, to, sizeof(to), + EUCJP_ENCODING_NAME); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, s2); + + r = idn_decodename(IDN_IDNCONV | IDN_RTCHECK, s3, to, sizeof(to)); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, s3); +#endif +} + +//# TESTCASE +// title: pass broken string as `from' to encodename() +// group: generic-conversion quiet +{ + /* "\xe3\x21" is not valid UTF-8 string */ + r = idn_encodename(IDN_ENCODE_APP, "\xe3\x21", to, sizeof(to)); + ASSERT_RESULT(r, idn_invalid_encoding); +} + +//# TESTCASE +// title: pass broken string as `from' to decodename() +// group: generic-conversion quiet +{ + /* "\xe3\x21" is not valid UTF-8 string */ + r = idn_decodename(IDN_DECODE_APP, "\xe3\x21", to, sizeof(to)); + ASSERT_RESULT(r, idn_invalid_encoding); +} + +//# TESTCASE +// title: pass broken string as `from' to decodename2() +// group: generic-conversion quiet +{ +#ifdef WITHOUT_ICONV + SKIP_TESTCASE; +#else + /* "\xa4\x21" is not valid EUC-JP string */ + r = idn_decodename2(IDN_DECODE_APP, "\xa4\x21", to, sizeof(to), + EUCJP_ENCODING_NAME); + ASSERT_RESULT(r, idn_invalid_encoding); +#endif +} diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/checker.tsy b/contrib/idn/idnkit-1.0-src/lib/tests/checker.tsy new file mode 100644 index 0000000..54f8ea0 --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/tests/checker.tsy @@ -0,0 +1,610 @@ +#ifndef lint +static char *rcsid = "$Id: checker.tsy,v 1.1.1.1 2003/06/04 00:26:51 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/checker.h> +#include <idn/log.h> +#include <idn/ucs4.h> +#include "testutil.h" + +#define SIZEOFUCS4(x) (sizeof(x) / sizeof(unsigned long)) + +#define UCS4_NAME_STR "U+304C" /* hiragana letter ga */ +#define UCS4_NAME 0x304C + +#define BUF_SIZE 128 +#define ARRAY_SIZE 9 + +#define CONF_FILENAME "test.map" + +#define LINEBUF_SIZE 2001 + +/* + * Sample strings for `from' argument of normalize(), + * and its expected outputs. + */ +const unsigned long from[4] = { + UCS4_NAME, + 0x00A0, /* no-break space: prohibited character */ + 0x0221, /* unassigned character */ + 0x0000 +}; + + +#define FROM_UCS4NAME_OFFSET 0 +#define FROM_PROH_OFFSET 1 +#define FROM_UNAS_OFFSET 2 + +const unsigned long from2[4] = { + UCS4_NAME, + 0x0221, /* unassigned character */ + 0x00A0, /* no-break space: prohibited character */ + 0x0000 +}; + +#define FROM2_UCS4NAME_OFFSET 0 +#define FROM2_PROH_OFFSET 2 +#define FROM2_UNAS_OFFSET 1 + +static const unsigned long bidi_from[4] = { + 0x05BE, /* hebrew punctuation maqaf */ + 0x0041, /* latin capital letter a */ + 0xFEFC, /* arabic ligature lam with alef final form */ + 0x0000 +}; +#define BIDIFROM_OFFSET 1 + +idn_result_t +test_createproc(const char *parameter, void **ctxp) +{ + return (idn_success); +} + +void +test_destroyproc(void *ctx) +{ +} + +#define FOUNDPTR_OFFSET 2 +idn_result_t +test_lookupproc(void *ctx, const unsigned long *ucs4, + const unsigned long **found) +{ + *found = ucs4 + FOUNDPTR_OFFSET; + return (idn_success); +} + +//-------------------------------------------------------------------- +// Setups and Teardowns. +//-------------------------------------------------------------------- + +//# SETUP +// group: generic +//-- +// Initialize the module and create context. +{ + idn_result_t r; + idn_checker_t ctx = NULL; + char name[BUF_SIZE]; + + r = idn_checker_initialize(); + ASSERT_RESULT(r, idn_success); + r = idn_checker_create(&ctx); + ASSERT_RESULT(r, idn_success); +} + +//# TEARDOWN +// group: generic +//-- +// Destroy context. +{ + if (ctx != NULL) + idn_checker_destroy(ctx); +} + +//# SETUP +// group: lookup +//-- +// Initialize the module and create context. +{ + idn_result_t r; + idn_checker_t ctx = NULL; + char name[BUF_SIZE]; + const unsigned long *ptr; + + r = idn_checker_initialize(); + ASSERT_RESULT(r, idn_success); + r = idn_checker_create(&ctx); + ASSERT_RESULT(r, idn_success); +} + +//# TEARDOWN +// group: lookup +//-- +// Destroy context. +{ + if (ctx != NULL) + idn_checker_destroy(ctx); +} + +//# SETUP +// group: addall +//-- +// Initialize the module and create context. +{ + idn_result_t r; + idn_checker_t ctx = NULL; + char *names[ARRAY_SIZE]; + int i; + const unsigned long *ptr; + + for (i = 0; i < ARRAY_SIZE; i++) { + names[i] = malloc(BUF_SIZE); + if (names[i] == NULL) { + ASSERT("malloc failed\n"); + } + } + + r = idn_checker_initialize(); + ASSERT_RESULT(r, idn_success); + r = idn_checker_create(&ctx); + ASSERT_RESULT(r, idn_success); +} + +//# TEARDOWN +// group: addall +//-- +// Destroy context and free some blocks. +{ + if (ctx != NULL) + idn_checker_destroy(ctx); + for (i = 0; i < ARRAY_SIZE; i++) { + free(names[i]); + } +} + +//# 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: idn_checker_add() - boundary condition +// group: generic quiet +{ + r = idn_checker_add(ctx, ""); + ASSERT_RESULT(r, idn_invalid_name); +} + +//# TESTCASE +// title: idn_checker_add() - builtin schemes, prohibit +// group: generic quiet +{ + sprintf(name, "%s%s", IDN_CHECKER_PROHIBIT_PREFIX, "RFC3491"); + r = idn_checker_add(ctx, name); + ASSERT_RESULT(r, idn_success); + + sprintf(name, "%s%s", IDN_CHECKER_PROHIBIT_PREFIX, "nameprep-01"); + r = idn_checker_add(ctx, name); + ASSERT_RESULT(r, idn_invalid_name); +} + +//# TESTCASE +// title: idn_checker_add() - builtin schemes, unassigned +// group: generic quiet +{ + sprintf(name, "%s%s", IDN_CHECKER_UNASSIGNED_PREFIX, "RFC3491"); + r = idn_checker_add(ctx, name); + ASSERT_RESULT(r, idn_success); + + sprintf(name, "%s%s", IDN_CHECKER_UNASSIGNED_PREFIX, "nameprep-01"); + r = idn_checker_add(ctx, name); + ASSERT_RESULT(r, idn_invalid_name); +} + +//# TESTCASE +// title: idn_checker_add() - builtin schemes, bidi +// group: generic quiet +{ + sprintf(name, "%s%s", IDN_CHECKER_BIDI_PREFIX, "RFC3491"); + r = idn_checker_add(ctx, name); + ASSERT_RESULT(r, idn_success); + + sprintf(name, "%s%s", IDN_CHECKER_BIDI_PREFIX, "nameprep-01"); + r = idn_checker_add(ctx, name); + ASSERT_RESULT(r, idn_invalid_name); +} + +//# TESTCASE +// title: idn_checker_add() - file - boundary condition +// group: generic quiet +{ + sprintf(name, "%sfileset:%s", IDN_CHECKER_UNASSIGNED_PREFIX, ""); + r = idn_checker_add(ctx, name); + ASSERT_RESULT(r, idn_nofile); + sprintf(name, "%sfileset:%s", IDN_CHECKER_PROHIBIT_PREFIX, ""); + r = idn_checker_add(ctx, name); + ASSERT_RESULT(r, idn_nofile); + sprintf(name, "%sfileset:%s", IDN_CHECKER_BIDI_PREFIX, ""); + r = idn_checker_add(ctx, name); + ASSERT_RESULT(r, idn_invalid_name); +} + +//# TESTCASE +// title: idn_checker_add() - file - long line +// group: generic quiet +{ + char line[LINEBUF_SIZE]; + const char *first_entry = "304C;"; + const char *other_entry = " 304D"; + int i; + int len; + + memcpy(line, first_entry, strlen(first_entry)); + len = strlen(other_entry); + for (i = len; i < LINEBUF_SIZE - len; i += len) { + memcpy(line + i, other_entry, len); + } + *(line + i) = '\0'; + + create_conf_file(CONF_FILENAME, 0, line, NULL); + sprintf(name, "%sfileset:%s", IDN_CHECKER_UNASSIGNED_PREFIX, + CONF_FILENAME); + r = idn_checker_add(ctx, name); + ASSERT_RESULT(r, idn_invalid_syntax); + sprintf(name, "%sfileset:%s", IDN_CHECKER_PROHIBIT_PREFIX, + CONF_FILENAME); + r = idn_checker_add(ctx, name); + ASSERT_RESULT(r, idn_invalid_syntax); +} + +//# TESTCASE +// title: idn_checker_add() - file, prohibit +// group: lookup +{ + create_conf_file(CONF_FILENAME, 0, + UCS4_NAME_STR, + NULL); + sprintf(name, "%sfileset:%s", IDN_CHECKER_PROHIBIT_PREFIX, + CONF_FILENAME); + r = idn_checker_add(ctx, name); + ASSERT_RESULT(r, idn_success); + r = idn_checker_lookup(ctx, from, &ptr); + ASSERT_RESULT(r, idn_success); + ASSERT_PTR(ptr, from + FROM_UCS4NAME_OFFSET); + r = idn_checker_lookup(ctx, from2, &ptr); + ASSERT_RESULT(r, idn_success); + ASSERT_PTR(ptr, from2 + FROM2_UCS4NAME_OFFSET); +} + +//# TESTCASE +// title: idn_checker_add() - file, unassigned +// group: lookup +{ + create_conf_file(CONF_FILENAME, 0, + UCS4_NAME_STR, + NULL); + sprintf(name, "%sfileset:%s", IDN_CHECKER_UNASSIGNED_PREFIX, + CONF_FILENAME); + r = idn_checker_add(ctx, name); + ASSERT_RESULT(r, idn_success); + r = idn_checker_lookup(ctx, from, &ptr); + ASSERT_RESULT(r, idn_success); + ASSERT_PTR(ptr, from + FROM_UCS4NAME_OFFSET); + r = idn_checker_lookup(ctx, from2, &ptr); + ASSERT_RESULT(r, idn_success); + ASSERT_PTR(ptr, from2 + FROM2_UCS4NAME_OFFSET); +} + +//# TESTCASE +// title: idn_checker_add() - file, bidi +// group: lookup quiet +{ + create_conf_file(CONF_FILENAME, 0, + UCS4_NAME_STR, + NULL); + sprintf(name, "%sfileset:%s", IDN_CHECKER_BIDI_PREFIX, + CONF_FILENAME); + r = idn_checker_add(ctx, name); + ASSERT_RESULT(r, idn_invalid_name); +} + +//# TESTCASE +// title: idn_checker_addall() - boundary condition - scheme name +// group: addall quiet +{ + sprintf(names[0], "%s%s", IDN_CHECKER_PROHIBIT_PREFIX, "RFC3491"); + sprintf(names[1], "%s%s", IDN_CHECKER_UNASSIGNED_PREFIX, "RFC3491"); + sprintf(names[2], "%s%s", IDN_CHECKER_BIDI_PREFIX, "RFC3491"); + sprintf(names[3], "%s%s", IDN_CHECKER_BIDI_PREFIX, ""); + r = idn_checker_addall(ctx, (const char **)names, 4); + ASSERT_RESULT(r, idn_invalid_name); +} + +//# TESTCASE +// title: idn_checker_addall() - boundary condition - nschemes = 0 +// group: addall quiet +{ + sprintf(names[0], "%s%s", IDN_CHECKER_PROHIBIT_PREFIX, "nameprep-01"); + sprintf(names[1], "%s%s", IDN_CHECKER_UNASSIGNED_PREFIX, "nameprep-01"); + sprintf(names[2], "%s%s", IDN_CHECKER_BIDI_PREFIX, ""); + sprintf(names[3], "%s%s", IDN_CHECKER_BIDI_PREFIX, "nameprep-01"); + r = idn_checker_addall(ctx, (const char **)names, 0); + ASSERT_RESULT(r, idn_success); + r = idn_checker_lookup(ctx, from, &ptr); + ASSERT_RESULT(r, idn_success); + ASSERT_PTR(ptr, NULL); +} + +//# TESTCASE +// title: idn_checker_addall() - add a lot of schemes #1 +// group: addall +{ + sprintf(names[0], "%s%s", IDN_CHECKER_PROHIBIT_PREFIX, "RFC3491"); + sprintf(names[1], "%s%s", IDN_CHECKER_UNASSIGNED_PREFIX, "RFC3491"); + sprintf(names[2], "%s%s", IDN_CHECKER_BIDI_PREFIX, "RFC3491"); + sprintf(names[3], "%s%s", IDN_CHECKER_PROHIBIT_PREFIX, "RFC3491"); + sprintf(names[4], "%s%s", IDN_CHECKER_UNASSIGNED_PREFIX, "RFC3491"); + sprintf(names[5], "%s%s", IDN_CHECKER_BIDI_PREFIX, "RFC3491"); + sprintf(names[6], "%s%s", IDN_CHECKER_PROHIBIT_PREFIX, "RFC3491"); + sprintf(names[7], "%s%s", IDN_CHECKER_UNASSIGNED_PREFIX, "RFC3491"); + sprintf(names[8], "%s%s", IDN_CHECKER_BIDI_PREFIX, "RFC3491"); + + r = idn_checker_addall(ctx, (const char **)names, 9); + ASSERT_RESULT(r, idn_success); + + r = idn_checker_lookup(ctx, from, &ptr); + ASSERT_RESULT(r, idn_success); + ASSERT_PTR(ptr, from + FROM_PROH_OFFSET); + + r = idn_checker_lookup(ctx, from2, &ptr); + ASSERT_RESULT(r, idn_success); + ASSERT_PTR(ptr, from2 + FROM2_PROH_OFFSET); + + r = idn_checker_lookup(ctx, bidi_from, &ptr); + ASSERT_RESULT(r, idn_success); + ASSERT_PTR(ptr, bidi_from + BIDIFROM_OFFSET); +} + +//# TESTCASE +// title: idn_checker_addall() - add a lot of schemes #2 +// group: addall +{ + sprintf(names[0], "%s%s", IDN_CHECKER_BIDI_PREFIX, "RFC3491"); + sprintf(names[1], "%s%s", IDN_CHECKER_UNASSIGNED_PREFIX, "RFC3491"); + sprintf(names[2], "%s%s", IDN_CHECKER_PROHIBIT_PREFIX, "RFC3491"); + sprintf(names[3], "%s%s", IDN_CHECKER_BIDI_PREFIX, "RFC3491"); + sprintf(names[4], "%s%s", IDN_CHECKER_UNASSIGNED_PREFIX, "RFC3491"); + sprintf(names[5], "%s%s", IDN_CHECKER_PROHIBIT_PREFIX, "RFC3491"); + sprintf(names[6], "%s%s", IDN_CHECKER_BIDI_PREFIX, "RFC3491"); + sprintf(names[7], "%s%s", IDN_CHECKER_UNASSIGNED_PREFIX, "RFC3491"); + sprintf(names[8], "%s%s", IDN_CHECKER_PROHIBIT_PREFIX, "RFC3491"); + + r = idn_checker_addall(ctx, (const char **)names, 9); + ASSERT_RESULT(r, idn_success); + + r = idn_checker_lookup(ctx, from, &ptr); + ASSERT_RESULT(r, idn_success); + ASSERT_PTR(ptr, from + FROM_UNAS_OFFSET); + + r = idn_checker_lookup(ctx, from2, &ptr); + ASSERT_RESULT(r, idn_success); + ASSERT_PTR(ptr, from2 + FROM2_UNAS_OFFSET); + + r = idn_checker_lookup(ctx, bidi_from, &ptr); + ASSERT_RESULT(r, idn_success); + ASSERT_PTR(ptr, bidi_from + BIDIFROM_OFFSET); +} + +//# TESTCASE +// title: idn_checker_addall() - add same scheme repetedly +// group: addall +{ + int i; + + sprintf(names[0], "%s%s", IDN_CHECKER_PROHIBIT_PREFIX, "RFC3491"); + for (i = 1; i < ARRAY_SIZE; i++) { + strcpy(names[i], names[0]); + } + r = idn_checker_addall(ctx, (const char **)names, ARRAY_SIZE); + ASSERT_RESULT(r, idn_success); + + r = idn_checker_lookup(ctx, from, &ptr); + ASSERT_RESULT(r, idn_success); + ASSERT_PTR(ptr, from + FROM_PROH_OFFSET); + + r = idn_checker_lookup(ctx, from2, &ptr); + ASSERT_RESULT(r, idn_success); + ASSERT_PTR(ptr, from2 + FROM2_PROH_OFFSET); +} + +//# TESTCASE +// title: idn_checker_lookup() - builtin schemes - RFC3491 prohibit +// group: lookup +{ + sprintf(name, "%s%s", IDN_CHECKER_PROHIBIT_PREFIX, "RFC3491"); + + r = idn_checker_add(ctx, name); + ASSERT_RESULT(r, idn_success); + + r = idn_checker_lookup(ctx, from, &ptr); + ASSERT_RESULT(r, idn_success); + ASSERT_PTR(ptr, from + FROM_PROH_OFFSET); + + r = idn_checker_lookup(ctx, from2, &ptr); + ASSERT_RESULT(r, idn_success); + ASSERT_PTR(ptr, from2 + FROM2_PROH_OFFSET); +} + +//# TESTCASE +// title: idn_checker_lookup() - builtin schemes - RFC3491 unassigned +// group: lookup +{ + sprintf(name, "%s%s", IDN_CHECKER_UNASSIGNED_PREFIX, "RFC3491"); + + r = idn_checker_add(ctx, name); + ASSERT_RESULT(r, idn_success); + + r = idn_checker_lookup(ctx, from, &ptr); + ASSERT_RESULT(r, idn_success); + ASSERT_PTR(ptr, from + FROM_UNAS_OFFSET); + + r = idn_checker_lookup(ctx, from2, &ptr); + ASSERT_RESULT(r, idn_success); + ASSERT_PTR(ptr, from2 + FROM2_UNAS_OFFSET); +} + +//# TESTCASE +// title: idn_checker_lookup() - builtin schemes - RFC3491 bidi +// group: lookup +{ + sprintf(name, "%s%s", IDN_CHECKER_BIDI_PREFIX, "RFC3491"); + + r = idn_checker_add(ctx, name); + ASSERT_RESULT(r, idn_success); + + r = idn_checker_lookup(ctx, bidi_from, &ptr); + ASSERT_RESULT(r, idn_success); + ASSERT_PTR(ptr, bidi_from + BIDIFROM_OFFSET); + + r = idn_checker_lookup(ctx, from, &ptr); + ASSERT_RESULT(r, idn_success); + ASSERT_PTR(ptr, NULL); + + r = idn_checker_lookup(ctx, from2, &ptr); + ASSERT_RESULT(r, idn_success); + ASSERT_PTR(ptr, NULL); +} + +//# TESTCASE +// title: idn_checker_lookup() - context without procedure +// group: lookup +{ + r = idn_checker_lookup(ctx, from, &ptr); + ASSERT_RESULT(r, idn_success); + ASSERT_PTR(ptr, NULL); +} + +//# TESTCASE +// title: idn_checker_lookup() - string in ascii +// group: lookup +{ + char *ascii_str = "test"; + unsigned long ucs4_str[5]; + + r = idn_ucs4_utf8toucs4(ascii_str, ucs4_str, SIZEOFUCS4(ucs4_str)); + + sprintf(name, "%s%s", IDN_CHECKER_PROHIBIT_PREFIX, "RFC3491"); + r = idn_checker_add(ctx, name); + ASSERT_RESULT(r, idn_success); + sprintf(name, "%s%s", IDN_CHECKER_UNASSIGNED_PREFIX, "RFC3491"); + r = idn_checker_add(ctx, name); + ASSERT_RESULT(r, idn_success); + sprintf(name, "%s%s", IDN_CHECKER_BIDI_PREFIX, "RFC3491"); + r = idn_checker_add(ctx, name); + ASSERT_RESULT(r, idn_success); + r = idn_checker_lookup(ctx, ucs4_str, &ptr); + ASSERT_RESULT(r, idn_success); + ASSERT_PTR(ptr, NULL); +} + +//# TESTCASE +// title: idn_checker_destroy(), idn_checker_incrref() +// group: +{ + idn_result_t r; + idn_checker_t ctx = NULL; + + r = idn_checker_initialize(); + ASSERT_RESULT(r, idn_success); + r = idn_checker_create(&ctx); + ASSERT_RESULT(r, idn_success); + idn_checker_incrref(ctx); + idn_checker_destroy(ctx); + idn_checker_destroy(ctx); +} + +//# TESTCASE +// title: idn_checker_register() +// group: generic +{ + const unsigned long *ptr = NULL; + + r = idn_checker_register("test", + test_createproc, + test_destroyproc, + test_lookupproc); + ASSERT_RESULT(r, idn_success); + + r = idn_checker_add(ctx, "test"); + ASSERT_RESULT(r, idn_success); + + r = idn_checker_lookup(ctx, from, &ptr); + ASSERT_RESULT(r, idn_success); + ASSERT_PTR(ptr, from + FOUNDPTR_OFFSET); +} diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/codeset.h b/contrib/idn/idnkit-1.0-src/lib/tests/codeset.h new file mode 100644 index 0000000..735a023 --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/tests/codeset.h @@ -0,0 +1,71 @@ +/* $Id: codeset.h,v 1.1.1.1 2003/06/04 00:26:51 marka Exp $ */ +/* + * 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. + */ + +#ifndef CODESET_H +#define CODESET_H + +/* + * Character encoding name that iconv() recognizes as Japanese EUC. + * + * Please edit the cpp macro definition if iconv() on the system doesn't + * recognize "EUC-JP". + * + * NOTE: + * Konstantin Chuguev's iconv-2.0 doesn't accept "eucJP", but "euc-jp". + */ +#define EUCJP_ENCODING_NAME "eucJP" + + +/* + * Character encoding name that iconv() recognizes as Japanese Shift JIS. + * + * Please edit the cpp macro definition if iconv() on the system doesn't + * recognize "SJIS". + * + * NOTE: + * Konstantin Chuguev's iconv-2.0 doesn't accept "SJIS", but "Shift_JIS". + */ +#define SJIS_ENCODING_NAME "SJIS" + +#endif /* CODESET_H */ diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/converter.tsy b/contrib/idn/idnkit-1.0-src/lib/tests/converter.tsy new file mode 100644 index 0000000..94c865e --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/tests/converter.tsy @@ -0,0 +1,822 @@ +#ifndef lint +static char *rcsid = "$Id: converter.tsy,v 1.1.1.1 2003/06/04 00:26:53 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/converter.h> +#include <idn/log.h> + +#include "codeset.h" +#include "testutil.h" + + +#ifndef IDN_PUNYCODE_ENCODING_NAME +#define IDN_PUNYCODE_ENCODING_NAME "Punycode" +#endif + +#ifndef IDN_UTF8_ENCODING_NAME +#define IDN_UTF8_ENCODING_NAME "UTF-8" /* by IANA */ +#endif + +#ifndef EUCJP_ENCODING_NAME +#define EUCJP_ENCODING_NAME "eucJP" +#endif + +#ifndef SJIS_ENCODING_NAME +#define SJIS_ENCODING_NAME "SJIS" +#endif + +#define CONF_FILENAME "testalias.conf" +#define LINEBUF_SIZE 2001 + +#define SIZEOFUCS4(x) (sizeof(x) / sizeof(unsigned long)) + +/* + * U+1820: mongorian letter a + */ +#define UCS4_INVALID_NAME_FOR_EUCJP 0x1820 + +/* + * A4AC: hiragana letter GA (in EUC-JP) + */ +#define EUCJP_NAME "\xa4\xac" +#define EUCJP_NAME_SIZE 3 + +/* + * U+304C: hiragana letter GA + */ +#define UCS4_NAME 0x304C + +/* + * Conversion result of "U+304C" + */ +#define PUNYCODE_NAME "xn--v8j" +#define PUNYCODE_NAME_SIZE 8 + +#define BUF_SIZE 128 + +idn_result_t +idn_test_encode(idn_converter_t ctx, void *privdata, + const unsigned long *from, char *to, size_t tolen) +{ + idn_result_t r; + + if (tolen >= EUCJP_NAME_SIZE) { + strcpy(to, EUCJP_NAME); + r = idn_success; + } else { + r = idn_buffer_overflow; + } + return (r); + +} + +idn_result_t +idn_test_decode(idn_converter_t ctx, void *privdata, + const char *from, unsigned long *to, size_t tolen) +{ + idn_result_t r; + + if (tolen >= 2) { + to[0] = UCS4_NAME; + to[1] = 0x0000; + r = idn_success; + } else { + r = idn_buffer_overflow; + } + return (r); +} + + +//-------------------------------------------------------------------- +// Setups and Teardowns. +//-------------------------------------------------------------------- + +//# SETUP +// group: noinit +//-- +// Do nothing +{ + idn_result_t r; +} + +//# SETUP +// group: generic +//-- +// Initialize the module. +{ + idn_result_t r; + idn_converter_t ctx = NULL; + const char *name; + + r = idn_converter_initialize(); + ASSERT_RESULT(r, idn_success); + r = idn_converter_resetalias(); + ASSERT_RESULT(r, idn_success); +} + +//# SETUP +// group: localencoding +//-- +// Initialize the module and load alias file. +{ + idn_result_t r; + idn_converter_t ctx = NULL; + const char *name; + + r = idn_converter_initialize(); + ASSERT_RESULT(r, idn_success); + r = idn_converter_resetalias(); + ASSERT_RESULT(r, idn_success); + create_conf_file(CONF_FILENAME, 0, + "*.KOI8-R KOI8-R", + "*.ISO_8859-1 ISO-8859-1", + "*.ISO_8859-2 ISO-8859-1", + "*.UTF-8 UTF-8", + "ja_JP.EUC eucJP", + "japanese eucJP", + NULL); + r = idn_converter_aliasfile(CONF_FILENAME); + ASSERT_RESULT(r, idn_success); +} + +//# TEARDOWN +// group: localencoding +//-- +// reset alias information. +{ + idn_converter_resetalias(); +} + +//# SETUP +// group: conversion +//-- +// Initialize the module and create contexts. +{ + idn_result_t r; + idn_converter_t punycode_ctx = NULL; + idn_converter_t utf8_ctx = NULL; +#ifndef WITHOUT_ICONV + idn_converter_t eucjp_ctx = NULL; +#endif + + r = idn_converter_initialize(); + ASSERT_RESULT(r, idn_success); + r = idn_converter_create(IDN_PUNYCODE_ENCODING_NAME, &punycode_ctx, + 0); + ASSERT_RESULT(r, idn_success); + r = idn_converter_create(IDN_UTF8_ENCODING_NAME, &utf8_ctx, + IDN_CONVERTER_DELAYEDOPEN); + ASSERT_RESULT(r, idn_success); +#ifndef WITHOUT_ICONV + r = idn_converter_create(EUCJP_ENCODING_NAME, &eucjp_ctx, + IDN_CONVERTER_DELAYEDOPEN); + ASSERT_RESULT(r, idn_success); +#endif +} + +//# TEARDOWN +// group: conversion +//-- +// Destroy contexts. +{ + if (punycode_ctx != NULL) { + idn_converter_destroy(punycode_ctx); + } + if (utf8_ctx != NULL) { + idn_converter_destroy(utf8_ctx); + } +#ifndef WITHOUT_ICONV + if (eucjp_ctx != NULL) { + idn_converter_destroy(eucjp_ctx); + } +#endif +} + +//# 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: idn_converter_addalias() test - without initialization +// group: noinit quiet +{ + r = idn_converter_addalias("a", "b", 0); + ASSERT_RESULT(r, idn_failure); +} + +//# TESTCASE +// title: idn_converter_aliasfile() - without initialization +// group: noinit quiet +{ + r = idn_converter_aliasfile("a"); + ASSERT_RESULT(r, idn_failure); +} + +//# TESTCASE +// title: idn_converter_resetalias() - without initialization +// group: noinit quiet +{ + r = idn_converter_resetalias(); + ASSERT_RESULT(r, idn_failure); +} + +//# TESTCASE +// title: idn_converter_getrealname() - without initialization +// group: noinit quiet +{ + const char *name; + + name = idn_converter_getrealname("test"); + ASSERT_STRING(name, "test"); +} + +//# TESTCASE +// title: idn_converter_create() +// group: generic quiet +{ +#ifdef WITHOUT_ICONV + r = idn_converter_addalias("*pc", "Punycode", 0); + ASSERT_RESULT(r, idn_success); + r = idn_converter_addalias("*ej", EUCJP_ENCODING_NAME, 0); + ASSERT_RESULT(r, idn_success); + r = idn_converter_addalias("*sj", SJIS_ENCODING_NAME, 0); + ASSERT_RESULT(r, idn_success); + + r = idn_converter_create("abcsj", &ctx, 0); + ASSERT_RESULT(r, idn_invalid_name); + + r = idn_converter_create("notresolved", &ctx, 0); + ASSERT_RESULT(r, idn_invalid_name); + r = idn_converter_create("notresolved", &ctx, + IDN_CONVERTER_DELAYEDOPEN); + ASSERT_RESULT(r, idn_invalid_name); +#else + r = idn_converter_addalias("*pc", IDN_PUNYCODE_ENCODING_NAME, 0); + ASSERT_RESULT(r, idn_success); + r = idn_converter_addalias("*ej", EUCJP_ENCODING_NAME, 0); + ASSERT_RESULT(r, idn_success); + r = idn_converter_addalias("*sj", SJIS_ENCODING_NAME, 0); + ASSERT_RESULT(r, idn_success); + + r = idn_converter_create("abcsj", &ctx, 0); + ASSERT_RESULT(r, idn_success); + idn_converter_destroy(ctx); + + r = idn_converter_create("notresolved", &ctx, 0); + ASSERT_RESULT(r, idn_invalid_name); + r = idn_converter_create("notresolved", &ctx, + IDN_CONVERTER_DELAYEDOPEN); + ASSERT_RESULT(r, idn_success); + { + unsigned long ucs4_to[BUF_SIZE]; + + r = idn_converter_convtoucs4(ctx, "a", ucs4_to, BUF_SIZE); + ASSERT_RESULT(r, idn_invalid_name); + idn_converter_destroy(ctx); + } +#endif /* WITHOUT_ICONV */ +} + +//# TESTCASE +// title: idn_converter_addalias() - #1 +// group: generic +{ + r = idn_converter_addalias("test", "result-a", 0); + ASSERT_RESULT(r, idn_success); + name = idn_converter_getrealname("test"); + ASSERT_STRING(name, "result-a"); +} + +//# TESTCASE +// title: idn_converter_addalias() - #2 +// group: generic +{ + r = idn_converter_addalias("test", "result-b", 1); + ASSERT_RESULT(r, idn_success); + name = idn_converter_getrealname("test"); + ASSERT_STRING(name, "result-b"); +} + +//# TESTCASE +// title: idn_converter_addalias() - #3 +// group: generic +{ + r = idn_converter_addalias("test", "result-a", 0); + ASSERT_RESULT(r, idn_success); + r = idn_converter_addalias("test", "result-b", 0); + ASSERT_RESULT(r, idn_success); + name = idn_converter_getrealname("test"); + ASSERT_STRING(name, "result-a"); +} + +//# TESTCASE +// title: idn_converter_addalias() - #4 +// group: generic +{ + r = idn_converter_addalias("test", "result-a", 0); + ASSERT_RESULT(r, idn_success); + r = idn_converter_addalias("test", "result-b", 1); + ASSERT_RESULT(r, idn_success); + name = idn_converter_getrealname("test"); + ASSERT_STRING(name, "result-b"); +} + +//# TESTCASE +// title: idn_converter_addalias() - #5 +// group: generic +{ + r = idn_converter_addalias("test", "result-a", 0); + ASSERT_RESULT(r, idn_success); + r = idn_converter_addalias("test", "result-b", 0); + ASSERT_RESULT(r, idn_success); + r = idn_converter_addalias("test", "result-c", 0); + ASSERT_RESULT(r, idn_success); + r = idn_converter_addalias("test", "result-d", 0); + ASSERT_RESULT(r, idn_success); + r = idn_converter_addalias("test", "result-e", 0); + ASSERT_RESULT(r, idn_success); + r = idn_converter_addalias("test", "result-f", 0); + ASSERT_RESULT(r, idn_success); + r = idn_converter_addalias("test", "result-g", 0); + ASSERT_RESULT(r, idn_success); + r = idn_converter_addalias("test", "result-h", 0); + ASSERT_RESULT(r, idn_success); + r = idn_converter_addalias("test", "result-i", 0); + ASSERT_RESULT(r, idn_success); + name = idn_converter_getrealname("test"); + ASSERT_STRING(name, "result-a"); +} + +//# TESTCASE +// title: idn_converter_addalias() - #6 +// group: generic +{ + r = idn_converter_addalias("test", "result-a", 0); + ASSERT_RESULT(r, idn_success); + r = idn_converter_addalias("test", "result-b", 0); + ASSERT_RESULT(r, idn_success); + r = idn_converter_addalias("test", "result-c", 0); + ASSERT_RESULT(r, idn_success); + r = idn_converter_addalias("test", "result-d", 0); + ASSERT_RESULT(r, idn_success); + r = idn_converter_addalias("test", "result-e", 0); + ASSERT_RESULT(r, idn_success); + r = idn_converter_addalias("test", "result-f", 0); + ASSERT_RESULT(r, idn_success); + r = idn_converter_addalias("test", "result-g", 0); + ASSERT_RESULT(r, idn_success); + r = idn_converter_addalias("test", "result-h", 0); + ASSERT_RESULT(r, idn_success); + r = idn_converter_addalias("test", "result-i", 1); + ASSERT_RESULT(r, idn_success); + name = idn_converter_getrealname("test"); + ASSERT_STRING(name, "result-i"); +} + +//# TESTCASE +// title: idn_converter_addalias() - null character +// group: generic +{ + r = idn_converter_addalias("", "result", 0); + ASSERT_RESULT(r, idn_invalid_syntax); + r = idn_converter_addalias("test", "", 0); + ASSERT_RESULT(r, idn_invalid_syntax); + r = idn_converter_addalias("", "", 0); + ASSERT_RESULT(r, idn_invalid_syntax); +} + +//# TESTCASE +// title: idn_converter_resetalias() - no alias added +// group: generic +{ + r = idn_converter_resetalias(); + ASSERT_RESULT(r, idn_success); + name = idn_converter_getrealname("test"); + ASSERT_STRING(name, "test"); + +} + +//# TESTCASE +// title: idn_converter_resetalias() - one alias added +// group: generic +{ + r = idn_converter_addalias("test", "result-a", 0); + ASSERT_RESULT(r, idn_success); + r = idn_converter_resetalias(); + ASSERT_RESULT(r, idn_success); + name = idn_converter_getrealname("test"); + ASSERT_STRING(name, "test"); + +} + +//# TESTCASE +// title: idn_converter_resetalias() - many aliases added +// group: generic +{ + r = idn_converter_addalias("test", "result-a", 1); + ASSERT_RESULT(r, idn_success); + r = idn_converter_addalias("test", "result-b", 1); + ASSERT_RESULT(r, idn_success); + r = idn_converter_addalias("test", "result-c", 0); + ASSERT_RESULT(r, idn_success); + r = idn_converter_addalias("test", "result-d", 1); + ASSERT_RESULT(r, idn_success); + r = idn_converter_addalias("test", "result-e", 1); + ASSERT_RESULT(r, idn_success); + r = idn_converter_addalias("test", "result-f", 1); + ASSERT_RESULT(r, idn_success); + r = idn_converter_addalias("test", "result-g", 0); + ASSERT_RESULT(r, idn_success); + r = idn_converter_addalias("test", "result-h", 0); + ASSERT_RESULT(r, idn_success); + r = idn_converter_addalias("test", "result-i", 1); + ASSERT_RESULT(r, idn_success); + r = idn_converter_resetalias(); + ASSERT_RESULT(r, idn_success); + name = idn_converter_getrealname("test"); + ASSERT_STRING(name, "test"); +} + +//# TESTCASE +// title: idn_converter_aliasfile() - boundary condition +// group: generic quiet +{ + r = idn_converter_aliasfile(""); + ASSERT_RESULT(r, idn_nofile); + + r = idn_converter_aliasfile("idnalias-not-found.conf"); + ASSERT_RESULT(r, idn_nofile); +} + +//# TESTCASE +// title: idn_converter_aliasfile() - long line +// group: generic quiet +{ + char line[LINEBUF_SIZE]; + const char *entry = "aaaaaaaaaa"; + int i; + int len; + + len = strlen(entry); + for (i = 0; i < LINEBUF_SIZE - len; i += len) { + memcpy(line + i, entry, len); + } + *(line + (LINEBUF_SIZE / 2)) = ' '; + *(line + i) = '\0'; + create_conf_file(CONF_FILENAME, 0, line, NULL); + r = idn_converter_aliasfile(CONF_FILENAME); + ASSERT_RESULT(r, idn_invalid_syntax); +} + +//# TESTCASE +// title: idn_converter_aliasfile() - no new line at end of file +// group: generic quiet +{ + create_conf_file(CONF_FILENAME, CONF_NO_EOF_NEWLINE, + "*.ISO_8859-1 ISO-8859-1", + "*.ISO_8859-2 ISO-8859-1", + "*.SJIS Shift_JIS", + "*.Shift_JIS Shift_JIS", + "ja_JP.EUC eucJP", + "japanese eucJP", + NULL); + r = idn_converter_aliasfile(CONF_FILENAME); + ASSERT_RESULT(r, idn_success); + name = idn_converter_getrealname("japanese"); + ASSERT_STRING(name, "eucJP"); + +} + +//# TESTCASE +// title: idn_converter_aliasfile() - invalid entries +// group: generic quiet +{ + create_conf_file(CONF_FILENAME, 0, + "*.ISO_8859-1 ISO-8859-1", + "*.ISO_8859-2 ISO-8859-1", + "*.SJIS", + "*.Shift_JIS", + "ja_JP.EUC eucJP", + "japanese eucJP", + NULL); + r = idn_converter_aliasfile(CONF_FILENAME); + ASSERT_RESULT(r, idn_invalid_syntax); +} + +//# TESTCASE +// title: idn_converter_aliasfile() - more then two items in one line +// group: generic quiet +{ + create_conf_file(CONF_FILENAME, 0, + "*.ISO_8859-1 ISO-8859-1", + "*.ISO_8859-2 ISO-8859-1", + "*.SJIS Shift_JIS ko_KR.EUC", + "*.Shift_JIS Shift_JIS", + "*.big5 Big5 *.big5 *.big5", + "ja_JP.EUC eucJP", + "japanese eucJP", + NULL); + r = idn_converter_aliasfile(CONF_FILENAME); + ASSERT_RESULT(r, idn_success); + name = idn_converter_getrealname("japanese"); + ASSERT_STRING(name, "eucJP"); +} + +//# TESTCASE +// title: idn_converter_localencoding() - #1 +// group: localencoding +{ + r = idn_converter_create("test.UTF-8", &ctx, + IDN_CONVERTER_DELAYEDOPEN); + ASSERT_RESULT(r, idn_success); + name = idn_converter_localencoding(ctx); + ASSERT_STRING(name, "UTF-8"); + idn_converter_destroy(ctx); +} + +//# TESTCASE +// title: idn_converter_localencoding() - #2 +// group: localencoding +{ + r = idn_converter_create("test.KOI8-R", &ctx, + IDN_CONVERTER_DELAYEDOPEN); +#ifdef WITHOUT_ICONV + ASSERT_RESULT(r, idn_invalid_name); +#else + ASSERT_RESULT(r, idn_success); + name = idn_converter_localencoding(ctx); + ASSERT_STRING(name, "KOI8-R"); + idn_converter_destroy(ctx); +#endif +} + +//# TESTCASE +// title: idn_converter_localencoding() - #3 +// group: localencoding +{ + r = idn_converter_create("unresolvedname", &ctx, + IDN_CONVERTER_DELAYEDOPEN); +#ifdef WITHOUT_ICONV + ASSERT_RESULT(r, idn_invalid_name); +#else + ASSERT_RESULT(r, idn_success); + name = idn_converter_localencoding(ctx); + ASSERT_STRING(name, "unresolvedname"); + idn_converter_destroy(ctx); +#endif +} + +//# TESTCASE +// title: idn_converter_encodingtype() +// group: conversion +{ + ASSERT_INT(idn_converter_encodingtype(punycode_ctx), + IDN_ACE_STRICTCASE); + ASSERT_INT(idn_converter_encodingtype(utf8_ctx), + IDN_NONACE); +#ifndef WITHOUT_ICONV + ASSERT_INT(idn_converter_encodingtype(eucjp_ctx), + IDN_NONACE); +#endif +} + +//# TESTCASE +// title: idn_converter_isasciicompatible() +// group: conversion +{ + ASSERT_INT(idn_converter_isasciicompatible(punycode_ctx), 1); + ASSERT_INT(idn_converter_isasciicompatible(utf8_ctx), 0); +#ifndef WITHOUT_ICONV + ASSERT_INT(idn_converter_isasciicompatible(eucjp_ctx), 0); +#endif +} + +//# TESTCASE +// title: idn_converter_convfromucs4() +// group: conversion quiet +{ + unsigned long from_nullchar = 0x0000; + unsigned long from[2] = { UCS4_NAME, 0x0000 }; + char to[1]; + char to_punycode[PUNYCODE_NAME_SIZE]; +#ifndef WITHOUT_ICONV + char to_eucjp[EUCJP_NAME_SIZE]; +#endif + + r = idn_converter_convfromucs4(punycode_ctx, &from_nullchar, to, 0); + ASSERT_RESULT(r, idn_buffer_overflow); + + r = idn_converter_convfromucs4(punycode_ctx, &from_nullchar, to, 1); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, ""); + + r = idn_converter_convfromucs4(punycode_ctx, from, to_punycode, 0); + ASSERT_RESULT(r, idn_buffer_overflow); + + r = idn_converter_convfromucs4(punycode_ctx, from, to_punycode, + PUNYCODE_NAME_SIZE - 1); + ASSERT_RESULT(r, idn_buffer_overflow); + r = idn_converter_convfromucs4(punycode_ctx, from, to_punycode, + PUNYCODE_NAME_SIZE); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to_punycode, PUNYCODE_NAME); + +#ifndef WITHOUT_ICONV + r = idn_converter_convfromucs4(eucjp_ctx, &from_nullchar, to, 0); + ASSERT_RESULT(r, idn_buffer_overflow); + + r = idn_converter_convfromucs4(eucjp_ctx, &from_nullchar, to, 1); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, ""); + + r = idn_converter_convfromucs4(eucjp_ctx, from, to_eucjp, 0); + ASSERT_RESULT(r, idn_buffer_overflow); + + r = idn_converter_convfromucs4(eucjp_ctx, from, to_eucjp, + EUCJP_NAME_SIZE - 1); + ASSERT_RESULT(r, idn_buffer_overflow); + + r = idn_converter_convfromucs4(eucjp_ctx, from, to_eucjp, + EUCJP_NAME_SIZE); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to_eucjp, EUCJP_NAME); + + from[0] = 0x80000000; + r = idn_converter_convfromucs4(eucjp_ctx, from, to_eucjp, + EUCJP_NAME_SIZE); + ASSERT_RESULT(r, idn_invalid_encoding); + + from[0] = UCS4_INVALID_NAME_FOR_EUCJP; + r = idn_converter_convfromucs4(eucjp_ctx, from, to_eucjp, + EUCJP_NAME_SIZE); + ASSERT_RESULT(r, idn_nomapping); +#endif +} + +//# TESTCASE +// title: idn_converter_convtoucs4() +// group: conversion +{ + unsigned long to_nullchar = 0x0000; + unsigned long to[1]; + unsigned long punycode_to[2]; +#ifndef WITHOUT_ICONV + unsigned long eucjp_to[2]; +#endif + unsigned long ucs4_name[2] = { UCS4_NAME, 0x0000 }; + + r = idn_converter_convtoucs4(punycode_ctx, "", to, 0); + ASSERT_RESULT(r, idn_buffer_overflow); + + r = idn_converter_convtoucs4(punycode_ctx, "", to, 1); + ASSERT_RESULT(r, idn_success); + ASSERT_UCS4STRING(to, &to_nullchar); + + r = idn_converter_convtoucs4(punycode_ctx, PUNYCODE_NAME, + punycode_to, 0); + ASSERT_RESULT(r, idn_buffer_overflow); + + r = idn_converter_convtoucs4(punycode_ctx, PUNYCODE_NAME, + punycode_to, 1); + ASSERT_RESULT(r, idn_buffer_overflow); + r = idn_converter_convtoucs4(punycode_ctx, PUNYCODE_NAME, punycode_to, + 2); + ASSERT_RESULT(r, idn_success); + ASSERT_UCS4STRING_THRU(punycode_to, ucs4_name); + +#ifndef WITHOUT_ICONV + r = idn_converter_convtoucs4(eucjp_ctx, "", to, 0); + ASSERT_RESULT(r, idn_buffer_overflow); + + r = idn_converter_convtoucs4(eucjp_ctx, "", to, 1); + ASSERT_RESULT(r, idn_success); + ASSERT_UCS4STRING(to, &to_nullchar); + + r = idn_converter_convtoucs4(eucjp_ctx, EUCJP_NAME, eucjp_to, 0); + ASSERT_RESULT(r, idn_buffer_overflow); + + r = idn_converter_convtoucs4(eucjp_ctx, EUCJP_NAME, eucjp_to, 1); + ASSERT_RESULT(r, idn_buffer_overflow); + + r = idn_converter_convtoucs4(eucjp_ctx, EUCJP_NAME, eucjp_to, 2); + ASSERT_RESULT(r, idn_success); + ASSERT_UCS4STRING(to, &to_nullchar); + + r = idn_converter_convtoucs4(eucjp_ctx, "\xFF\xFF", eucjp_to, 2); + ASSERT_RESULT(r, idn_invalid_encoding); +#endif +} + +//# TESTCASE +// title: idn_converter_destroy(), idn_converter_incrref() +// group: generic +{ + idn_converter_t ctx2; + + r = idn_converter_create(IDN_UTF8_ENCODING_NAME, &ctx, 0); + ASSERT_RESULT(r, idn_success); + idn_converter_destroy(ctx); + + r = idn_converter_create(IDN_UTF8_ENCODING_NAME, &ctx2, 0); + ASSERT_RESULT(r, idn_success); + idn_converter_incrref(ctx2); + ASSERT_RESULT(r, idn_success); + idn_converter_destroy(ctx2); + idn_converter_destroy(ctx2); +} + +//# TESTCASE +// title: idn_converter_register() +// group: generic +{ + char eucjp_to[3]; + unsigned long ucs4_to[2]; + unsigned long ucs4_name[2] = { UCS4_NAME, 0x0000 }; + + r = idn_converter_register("test", + NULL, + NULL, + idn_test_encode, + idn_test_decode, + NULL, + IDN_ACE_STRICTCASE); + ASSERT_RESULT(r, idn_success); + r = idn_converter_create("test", &ctx, 0); + ASSERT_RESULT(r, idn_success); + + r = idn_converter_convfromucs4(ctx, ucs4_name, eucjp_to, sizeof(eucjp_to)); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(eucjp_to, EUCJP_NAME); + + r = idn_converter_convtoucs4(ctx, "", ucs4_to, SIZEOFUCS4(ucs4_to)); + ASSERT_RESULT(r, idn_success); + ASSERT_UCS4STRING(ucs4_to, ucs4_name); + + idn_converter_destroy(ctx); +} diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/delimitermap.tsy b/contrib/idn/idnkit-1.0-src/lib/tests/delimitermap.tsy new file mode 100644 index 0000000..aeaa46c --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/tests/delimitermap.tsy @@ -0,0 +1,257 @@ +#ifndef lint +static char *rcsid = "$Id: delimitermap.tsy,v 1.1.1.1 2003/06/04 00:26:53 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 <stdarg.h> +#include <idn/delimitermap.h> +#include <idn/ucs4.h> +#include <idn/log.h> +#include "testutil.h" + +/* + * Codepoions to test the add() function. + */ +#define ADDITIONAL_DELIMITER0 0xe0 +#define ADDITIONAL_DELIMITER1 0xe1 + +/* + * Sample string for `from' argument of map(), + * and its expected outputs. + */ +static const unsigned long from[] = { + 0x002e, /* full stop */ + 0x3002, /* ideographic full stop */ + 0xff0e, /* fullwidth full stop */ + 0xff61, /* halfwidth ideographic full stop */ + ADDITIONAL_DELIMITER0, + ADDITIONAL_DELIMITER1, + 0x0000 +}; + +static const unsigned long expected_default[] = { + 0x002e, /* full stop */ + 0x002e, /* full stop */ + 0x002e, /* full stop */ + 0x002e, /* full stop */ + ADDITIONAL_DELIMITER0, + ADDITIONAL_DELIMITER1, + 0x0000 +}; + +static const unsigned long expected_add[] = { + 0x002e, /* full stop */ + 0x002e, /* full stop */ + 0x002e, /* full stop */ + 0x002e, /* full stop */ + 0x002e, /* full stop */ + ADDITIONAL_DELIMITER1, + 0x0000 +}; + +static const unsigned long expected_addall[] = { + 0x002e, /* full stop */ + 0x002e, /* full stop */ + 0x002e, /* full stop */ + 0x002e, /* full stop */ + 0x002e, /* full stop */ + 0x002e, /* full stop */ + 0x0000 +}; + +//-------------------------------------------------------------------- +// Setups and Teardowns. +//-------------------------------------------------------------------- + +//# SETUP +// group: generic-init +{ + idn_result_t r; + idn_delimitermap_t ctx; + unsigned long to[256]; + + r = idn_delimitermap_create(&ctx); + ASSERT_RESULT(r, idn_success); +} + +//# TEARDOWN +// group: generic-init +{ + if (ctx != NULL) + idn_delimitermap_destroy(ctx); +} + +//# 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); +} + +//-------------------------------------------------------------------- +// Testcases. +//-------------------------------------------------------------------- + +//# TESTCASE +// title: call create() +// group: generic-init +{ +} + +//# TESTCASE +// title: call map() without additional delimiters +// group: generic-init +{ + r = idn_delimitermap_map(ctx, from, to, sizeof(to) / sizeof(*to)); + ASSERT_RESULT(r, idn_success); + ASSERT_UCS4STRING(to, expected_default); +} + +//# TESTCASE +// title: call add() and map() +// group: generic-init +{ + r = idn_delimitermap_add(ctx, ADDITIONAL_DELIMITER0); + ASSERT_RESULT(r, idn_success); + + r = idn_delimitermap_map(ctx, from, to, sizeof(to) / sizeof(*to)); + ASSERT_RESULT(r, idn_success); + ASSERT_UCS4STRING(to, expected_add); +} + +//# TESTCASE +// title: call addall() +// group: generic-init +{ + unsigned long delimiters[2]; + + delimiters[0] = ADDITIONAL_DELIMITER0; + delimiters[1] = ADDITIONAL_DELIMITER1; + r = idn_delimitermap_addall(ctx, delimiters, 2); + ASSERT_RESULT(r, idn_success); + + r = idn_delimitermap_map(ctx, from, to, sizeof(to) / sizeof(*to)); + ASSERT_RESULT(r, idn_success); + ASSERT_UCS4STRING(to, expected_addall); +} + +//# TESTCASE +// title: call addall() with nnames=0 +// group: generic-init +{ + unsigned long delimiters[2]; + + r = idn_delimitermap_addall(ctx, delimiters, 0); + ASSERT_RESULT(r, idn_success); + + r = idn_delimitermap_map(ctx, from, to, sizeof(to) / sizeof(*to)); + ASSERT_RESULT(r, idn_success); + ASSERT_UCS4STRING(to, expected_default); +} + +//# TESTCASE +// title: call add() with invalid codepoint +// group: generic-init quiet +{ + r = idn_delimitermap_add(ctx, 0x0000); /* NUL */ + ASSERT_RESULT(r, idn_invalid_codepoint); + + r = idn_delimitermap_add(ctx, 0xd800); /* surrogate */ + ASSERT_RESULT(r, idn_invalid_codepoint); + + r = idn_delimitermap_add(ctx, 0x110000); /* out of range */ + ASSERT_RESULT(r, idn_invalid_codepoint); +} + +//# TESTCASE +// title: call addall() with invalid codepoint +// group: generic-init quiet +{ + unsigned long delimiters[1]; + + delimiters[0] = 0x0000; /* NUL */ + r = idn_delimitermap_addall(ctx, delimiters, 1); + ASSERT_RESULT(r, idn_invalid_codepoint); + + delimiters[0] = 0xd800; /* surrogate */ + r = idn_delimitermap_addall(ctx, delimiters, 1); + ASSERT_RESULT(r, idn_invalid_codepoint); + + delimiters[0] = 0x110000; /* out of range */ + r = idn_delimitermap_addall(ctx, delimiters, 1); + ASSERT_RESULT(r, idn_invalid_codepoint); +} + +//# TESTCASE +// title: overrun test for arg `to' of map() +// group: generic-init +{ + r = idn_delimitermap_map(ctx, from, to, + idn_ucs4_strlen(expected_default) + 1); + ASSERT_RESULT(r, idn_success); + ASSERT_UCS4STRING(to, expected_default); + r = idn_delimitermap_map(ctx, from, to, + idn_ucs4_strlen(expected_default)); + ASSERT_RESULT(r, idn_buffer_overflow); +} + +//# TESTCASE +// title: call map() with tolen=0 +// group: generic-init +{ + r = idn_delimitermap_map(ctx, from, to, 0); + ASSERT_RESULT(r, idn_buffer_overflow); +} diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/iconvchk.c b/contrib/idn/idnkit-1.0-src/lib/tests/iconvchk.c new file mode 100644 index 0000000..895b197 --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/tests/iconvchk.c @@ -0,0 +1,132 @@ +#ifndef lint +static char *rcsid = "$Id: iconvchk.c,v 1.1.1.1 2003/06/04 00:26:54 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 <stdio.h> +#include <stdlib.h> + +#include <idn/api.h> +#include <idn/converter.h> +#include <idn/result.h> + +#include "codeset.h" + +#define IDN_UTF8_ENCODING_NAME "UTF-8" + +void +eucjp_check(void) +{ + idn_result_t r; + idn_converter_t eucjp_ctx = NULL; + + r = idn_nameinit(0); + if (r != idn_success) { + fprintf(stderr, "idn_nameinit(): failed\n"); + exit (1); + } + + r = idn_converter_create(EUCJP_ENCODING_NAME, &eucjp_ctx, 0); + + if (eucjp_ctx != NULL) { + idn_converter_destroy(eucjp_ctx); + } + + if (r != idn_success) { + if (r == idn_invalid_name) { + fprintf(stderr, \ + "\"%s\" is invalid codeset name, edit codeset.h\n", \ + EUCJP_ENCODING_NAME); + exit (1); + } else { + fprintf(stderr, \ + "idn_converter_create() failed with error \"%s\"\n", \ + idn_result_tostring(r)); + exit (1); + } + } +} + +void +sjis_check(void) +{ + idn_result_t r; + idn_converter_t sjis_ctx = NULL; + + r = idn_nameinit(0); + if (r != idn_success) { + fprintf(stderr, "idn_nameinit(): failed\n"); + exit (1); + } + + r = idn_converter_create(SJIS_ENCODING_NAME, &sjis_ctx, 0); + + if (sjis_ctx != NULL) { + idn_converter_destroy(sjis_ctx); + } + + if (r != idn_success) { + if (r == idn_invalid_name) { + fprintf(stderr, \ + "\"%s\" is invalid codeset name, edit codeset.h\n", \ + SJIS_ENCODING_NAME); + exit (1); + } else { + fprintf(stderr, \ + "idn_converter_create() failed with error \"%s\"\n", \ + idn_result_tostring(r)); + exit (1); + } + } +} + +int +main (int ac, char **av) +{ + eucjp_check(); + sjis_check(); + + exit (0); +} diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/mapper.tsy b/contrib/idn/idnkit-1.0-src/lib/tests/mapper.tsy new file mode 100644 index 0000000..5db6c65 --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/tests/mapper.tsy @@ -0,0 +1,497 @@ +#ifndef lint +static char *rcsid = "$Id: mapper.tsy,v 1.1.1.1 2003/06/04 00:26:54 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/mapper.h> +#include <idn/log.h> +#include <idn/ucs4.h> +#include "testutil.h" + +#define SIZEOFUCS4(x) (sizeof(x) / sizeof(unsigned long)) + +#define UCS4_NAME_STR "U+304C" /* hiragana letter ga */ +#define UCS4_NAME 0x304C + +#define BUF_SIZE 128 +#define ARRAY_SIZE 9 +#define CONF_FILENAME "test.map" + +#define LINEBUF_SIZE 2001 + +/* + * Sample string for `from' argument of map(), + * and its expected outputs. + */ +static const unsigned long from[] = { + 0x0041, /* latin capital letter a */ + 0x0042, /* latin capital letter b */ + UCS4_NAME, + 0x0000 +}; + +static const unsigned long expected_default[] = { + 0x0061, /* latin small letter a */ + 0x0062, /* latin small letter b */ + UCS4_NAME, + 0x0000 +}; + +idn_result_t +test_create(const char *parameter, void **ctxp) +{ + return (idn_success); +} + +void +test_destroy(void *ctxp) +{ +} + +idn_result_t +test_map(void *ctx, const unsigned long *from, unsigned long *to, + size_t tolen) +{ + if (tolen > idn_ucs4_strlen(from)) { + idn_ucs4_strcpy(to, from); + } else { + return (idn_buffer_overflow); + } + + return (idn_success); +} + +//-------------------------------------------------------------------- +// Setups and Teardowns. +//-------------------------------------------------------------------- + +//# SETUP +// group: noinit +//-- +// Do nothing +{ + idn_result_t r; + const char *name; +} + +//# SETUP +// group: generic +//-- +// Initialize the module and create context. +{ + idn_result_t r; + idn_mapper_t ctx = NULL; + + r = idn_mapper_initialize(); + ASSERT_RESULT(r, idn_success); + r = idn_mapper_create(&ctx); + ASSERT_RESULT(r, idn_success); +} + +//# TEARDOWN +// group: generic +//-- +// Destroy context. +{ + idn_mapper_destroy(ctx); +} + +//# SETUP +// group: addall +//-- +// Initialize the module and create context. +{ + idn_result_t r; + idn_mapper_t ctx = NULL; + char *names[ARRAY_SIZE]; + int i; + unsigned long to[4]; + + for (i = 0; i < ARRAY_SIZE; i++) { + names[i] = malloc(BUF_SIZE); + if (names[i] == NULL) { + ASSERT("malloc failed\n"); + } + } + + r = idn_mapper_initialize(); + ASSERT_RESULT(r, idn_success); + r = idn_mapper_create(&ctx); + ASSERT_RESULT(r, idn_success); +} + +//# TEARDOWN +// group: addall +//-- +// Destroy context and free some blocks. +{ + idn_mapper_destroy(ctx); + for (i = 0; i < ARRAY_SIZE; i++) { + free(names[i]); + } +} + +//# 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: idn_mapper_add() - boundary condition +// group: generic quiet +{ + r = idn_mapper_add(ctx, ""); + ASSERT_RESULT(r, idn_invalid_name); +} + +//# TESTCASE +// title: idn_mapper_add() - builtin schemes +// group: generic quiet +{ + r = idn_mapper_add(ctx, "RFC3491"); + ASSERT_RESULT(r, idn_success); + + r = idn_mapper_add(ctx, "nameprep-01"); + ASSERT_RESULT(r, idn_invalid_name); +} + +//# TESTCASE +// title: idn_mapper_add() - boundary condition +// group: generic quiet +{ + r = idn_mapper_add(ctx, ""); + ASSERT_RESULT(r, idn_invalid_name); + r = idn_mapper_add(ctx, "filemap:"); + ASSERT_RESULT(r, idn_nofile); + r = idn_mapper_add(ctx, "filemap:notfound.map"); + ASSERT_RESULT(r, idn_nofile); +} + +//# TESTCASE +// title: idn_mapper_add() - file +// group: generic quiet +{ + char name[BUF_SIZE]; + unsigned long to[4]; + + create_conf_file(CONF_FILENAME, 0, + "0041; 0061;", + "0042; 0062;", + NULL); + sprintf(name, "filemap:%s", CONF_FILENAME); + + r = idn_mapper_add(ctx, name); + ASSERT_RESULT(r, idn_success); + r = idn_mapper_map(ctx, from, to, SIZEOFUCS4(to)); + ASSERT_RESULT(r, idn_success); + ASSERT_UCS4STRING(to, expected_default); +} + +//# TESTCASE +// title: idn_mapper_add() - file - long line +// group: generic quiet +{ + char line[LINEBUF_SIZE]; + char name[BUF_SIZE]; + const char *first_entry = "0041;"; + const char *other_entry = " 0061"; + int i; + int len; + + memcpy(line, first_entry, strlen(first_entry)); + len = strlen(other_entry); + for (i = len; i < LINEBUF_SIZE - len; i += len) { + memcpy(line + i, other_entry, len); + } + *(line + i) = '\0'; + + create_conf_file(CONF_FILENAME, 0, line, NULL); + sprintf(name, "filemap:%s", CONF_FILENAME); + r = idn_mapper_add(ctx, name); + ASSERT_RESULT(r, idn_invalid_syntax); +} + +//# TESTCASE +// title: idn_mapper_add() - file - no new line at end of file +// group: generic quiet +{ + char name[BUF_SIZE]; + unsigned long to[4]; + + create_conf_file(CONF_FILENAME, CONF_NO_EOF_NEWLINE, + "0041; 0061;", + "0042; 0062;", + NULL); + sprintf(name, "filemap:%s", CONF_FILENAME); + r = idn_mapper_add(ctx, name); + ASSERT_RESULT(r, idn_success); + r = idn_mapper_map(ctx, from, to, SIZEOFUCS4(to)); + ASSERT_RESULT(r, idn_success); + ASSERT_UCS4STRING(to, expected_default); +} + +//# TESTCASE +// title: idn_mapper_add() - file - one item in one line #1 +// group: generic quiet +{ + char name[BUF_SIZE]; + unsigned long to[3]; + unsigned long expected[] = { + 0x0061, + UCS4_NAME, + 0x0000 + }; + + create_conf_file(CONF_FILENAME, 0, + "0041; 0061;", + "0042;", + NULL); + sprintf(name, "filemap:%s", CONF_FILENAME); + r = idn_mapper_add(ctx, name); + ASSERT_RESULT(r, idn_success); + r = idn_mapper_map(ctx, from, to, SIZEOFUCS4(to)); + ASSERT_RESULT(r, idn_success); + ASSERT_UCS4STRING(to, expected); +} + +//# TESTCASE +// title: idn_mapper_add() - file - one item in one line #2 +// group: generic quiet +{ + char name[BUF_SIZE]; + unsigned long to[3]; + unsigned long expected[] = { + 0x0061, + UCS4_NAME, + 0x0000 + }; + + create_conf_file(CONF_FILENAME, 0, + "0041; 0061;", + "0042; ;", + NULL); + sprintf(name, "filemap:%s", CONF_FILENAME); + r = idn_mapper_add(ctx, name); + ASSERT_RESULT(r, idn_success); + r = idn_mapper_map(ctx, from, to, SIZEOFUCS4(to)); + ASSERT_RESULT(r, idn_success); + ASSERT_UCS4STRING(to, expected); +} + +//# TESTCASE +// title: idn_mapper_add() - file - more then two items in one line #1 +// group: generic quiet +{ + char name[BUF_SIZE]; + unsigned long to[4]; + + create_conf_file(CONF_FILENAME, 0, + "0041; 0061; 0062;", + "0042; 0062; 0063;", + NULL); + sprintf(name, "filemap:%s", CONF_FILENAME); + r = idn_mapper_add(ctx, name); + ASSERT_RESULT(r, idn_success); + + r = idn_mapper_map(ctx, from, to, SIZEOFUCS4(to)); + ASSERT_RESULT(r, idn_success); + ASSERT_UCS4STRING(to, expected_default); +} + +//# TESTCASE +// title: idn_mapper_add() - file - more then two items in one line #2 +// group: generic quiet +{ + char name[BUF_SIZE]; + unsigned long to[6]; + unsigned long expected_to[] = { + 0x0061, + 0x0062, + 0x0062, + 0x0063, + UCS4_NAME, + 0x0000 + }; + + create_conf_file(CONF_FILENAME, 0, + "0041; 0061 0062;", + "0042; 0062 0063;", + NULL); + sprintf(name, "filemap:%s", CONF_FILENAME); + r = idn_mapper_add(ctx, name); + ASSERT_RESULT(r, idn_success); + + r = idn_mapper_map(ctx, from, to, SIZEOFUCS4(to)); + ASSERT_RESULT(r, idn_success); + ASSERT_UCS4STRING(to, expected_to); +} + +//# TESTCASE +// title: idn_mapper_add() - file - more then two items in one line #3 +// group: generic quiet +{ + char name[BUF_SIZE]; + unsigned long to[3]; + + create_conf_file(CONF_FILENAME, 0, + "0041 0042; 0063;", + NULL); + sprintf(name, "filemap:%s", CONF_FILENAME); + r = idn_mapper_add(ctx, name); + ASSERT_RESULT(r, idn_invalid_syntax); +} + +//# TESTCASE +// title: idn_mapper_addall() - add all builtin schemes +// group: addall quiet +{ + strcpy(names[0], "RFC3491"); + strcpy(names[1], "RFC3491"); + strcpy(names[2], "RFC3491"); + strcpy(names[3], "RFC3491"); + strcpy(names[4], "RFC3491"); + strcpy(names[5], "RFC3491"); + strcpy(names[6], "RFC3491"); + strcpy(names[7], "RFC3491"); + strcpy(names[8], "RFC3491"); + + r = idn_mapper_addall(ctx, (const char **)names, 9); + ASSERT_RESULT(r, idn_success); + r = idn_mapper_map(ctx, from, to, SIZEOFUCS4(to)); + ASSERT_RESULT(r, idn_success); + ASSERT_UCS4STRING(to, expected_default); +} + +//# TESTCASE +// title: idn_mapper_addall() - add same scheme repetedly +// group: addall quiet +{ + for (i = 0; i < ARRAY_SIZE; i++) { + strcpy(names[i], "RFC3491"); + } + r = idn_mapper_addall(ctx, (const char **)names, 3); + ASSERT_RESULT(r, idn_success); + r = idn_mapper_map(ctx, from, to, SIZEOFUCS4(to)); + ASSERT_RESULT(r, idn_success); + ASSERT_UCS4STRING(to, expected_default); +} + +//# TESTCASE +// title: idn_mapper_map() - builtin schemes check - RFC3491 +// group: generic quiet +{ + unsigned long to[4]; + + r = idn_mapper_add(ctx, "RFC3491"); + ASSERT_RESULT(r, idn_success); + r = idn_mapper_map(ctx, from, to, SIZEOFUCS4(to)); + ASSERT_RESULT(r, idn_success); + ASSERT_UCS4STRING(to, expected_default); +} + +//# TESTCASE +// title: idn_mapper_map() - context without procedure +// group: generic +{ + unsigned long to[4]; + + r = idn_mapper_map(ctx, from, to, SIZEOFUCS4(to)); + ASSERT_RESULT(r, idn_success); + ASSERT_UCS4STRING(to, from); +} + +//# TESTCASE +// title: idn_mapper_destroy(), idn_mapper_incrref() +// group: +{ + idn_result_t r; + idn_mapper_t ctx = NULL; + + r = idn_mapper_initialize(); + ASSERT_RESULT(r, idn_success); + r = idn_mapper_create(&ctx); + ASSERT_RESULT(r, idn_success); + idn_mapper_incrref(ctx); + idn_mapper_destroy(ctx); + idn_mapper_destroy(ctx); +} + +//# TESTCASE +// title: idn_mapper_register() +// group: generic quiet +{ + unsigned long to[10]; + + r = idn_mapper_register("test", test_create, test_destroy, test_map); + ASSERT_RESULT(r, idn_success); + r = idn_mapper_add(ctx, "test"); + ASSERT_RESULT(r, idn_success); + + r = idn_mapper_map(ctx, from, to, SIZEOFUCS4(to)); + ASSERT_RESULT(r, idn_success); + ASSERT_UCS4STRING(to, from); +} diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/mapselector.tsy b/contrib/idn/idnkit-1.0-src/lib/tests/mapselector.tsy new file mode 100644 index 0000000..1484f6c --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/tests/mapselector.tsy @@ -0,0 +1,592 @@ +#ifndef lint +static char *rcsid = "$Id: mapselector.tsy,v 1.1.1.1 2003/06/04 00:26:55 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 <stdarg.h> +#include <idn/mapselector.h> +#include <idn/ucs4.h> +#include <idn/log.h> + +#include "testutil.h" + +#define CONF_FILENAME "test.conf" +#define MAP_FILENAME "test.map" + +/* + * Sample TLDs. + */ +static const char *utf8_tlds_jp[] = {"jp", ".jp", "JP", ".JP"}; +static const char *utf8_tlds_tw[] = {"tw", ".tw", "TW", ".TW"}; + +static const unsigned long ucs4_tlds_jp[][4] = {{'j', 'p', '\0', '\0'}, + {'.', 'j', 'p', '\0'}, + {'J', 'P', '\0', '\0'}, + {'.', 'J', 'P', '\0'}}; + +static const unsigned long ucs4_tlds_tw[][4] = {{'t', 'w', '\0', '\0'}, + {'.', 't', 'w', '\0'}, + {'T', 'W', '\0', '\0'}, + {'.', 'T', 'W', '\0'}}; + +/* How many elements in `utf8_tlds_{jp|tw}[]' and `ucs4_tlds_{jp|tw}[]'. */ +#define TLD_NVARIANTS 4 + +/* + * Sample input string for mapping. (UCS4) + */ +static const unsigned long in_string[] = {0x00C0, 0x2212, 0}; + +/* + * Sample mapping results of IN_STRING. + * + * OUT_STRING_FILEMAP is the result of file-mapping (U+2212 -> U+002D). + * OUT_STRING_NAMEPREP is the result of the latest nameprep + * OUT_STRING_BOTH is the result of both file-mapping and nameprep. + */ +static const unsigned long out_string_filemap[] = {0x00C0, 0x002D, 0}; +static const unsigned long out_string_nameprep[] = {0x00E0, 0x2212, 0}; +static const unsigned long out_string_both[] = {0x00E0, 0x002D, 0}; + +#define MAP_FILENAME "test.map" + +//-------------------------------------------------------------------- +// Setups and Teardowns. +//-------------------------------------------------------------------- + +//# SETUP +// group: generic-init +{ + idn_result_t r; + idn_mapselector_t ctxs[TLD_NVARIANTS]; + unsigned long to[256]; + + { + int i; + for (i = 0; i < TLD_NVARIANTS; i++) + ctxs[i] = NULL; + } + + r = idn_mapselector_initialize(); + ASSERT_RESULT(r, idn_success); + + { + int i; + for (i = 0; i < TLD_NVARIANTS; i++) { + r = idn_mapselector_create(&ctxs[i]); + ASSERT_RESULT(r, idn_success); + } + } +} + +//# TEARDOWN +// group: generic-init +{ + { + int i; + + for (i = 0; i < TLD_NVARIANTS; i++) { + if (ctxs[i] != NULL) + idn_mapselector_destroy(ctxs[i]); + remove(CONF_FILENAME); + } + } +} + +//# 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: generic-filemap +{ + create_conf_file(MAP_FILENAME, 0, + "U+2212; U+002D", + NULL); +} + +//# TEARDOWN +// group: generic-filemap +{ + remove(MAP_FILENAME); +} + +//-------------------------------------------------------------------- +// Testcases. +//-------------------------------------------------------------------- + +//# TESTCASE +// title: call initialize() twice. +// +{ + idn_result_t r; + + r = idn_mapselector_initialize(); + ASSERT_RESULT(r, idn_success); + + r = idn_mapselector_initialize(); + ASSERT_RESULT(r, idn_success); +} + +//# TESTCASE +// title: call create() +{ + idn_result_t r; + idn_mapselector_t ctx; + + r = idn_mapselector_initialize(); + ASSERT_RESULT(r, idn_success); + + r = idn_mapselector_create(&ctx); + ASSERT_RESULT(r, idn_success); + + idn_mapselector_destroy(ctx); +} + +//# TESTCASE +// title: call add(filemap) and map() +// group: generic-init generic-filemap +{ + int i, j; + + for (i = 0; i < TLD_NVARIANTS; i++) { + r = idn_mapselector_add(ctxs[i], utf8_tlds_jp[i], + "filemap:" MAP_FILENAME); + ASSERT_RESULT(r, idn_success); + } + + for (i = 0; i < TLD_NVARIANTS; i++) { + for (j = 0; j < TLD_NVARIANTS; j++) { + r = idn_mapselector_map(ctxs[i], in_string, + utf8_tlds_jp[j], to, + sizeof(to) / sizeof(*to)); + ASSERT_RESULT(r, idn_success); + ASSERT_UCS4STRING(to, out_string_filemap); + + r = idn_mapselector_map(ctxs[i], in_string, + utf8_tlds_tw[j], to, + sizeof(to) / sizeof(*to)); + ASSERT_RESULT(r, idn_success); + ASSERT_UCS4STRING(to, in_string); + } + } +} + +//# TESTCASE +// title: call add(nameprep) and map() +// group: generic-init generic-filemap +{ + int i, j; + + for (i = 0; i < TLD_NVARIANTS; i++) { + r = idn_mapselector_add(ctxs[i], utf8_tlds_jp[i], + IDN_NAMEPREP_CURRENT); + ASSERT_RESULT(r, idn_success); + } + + for (i = 0; i < TLD_NVARIANTS; i++) { + for (j = 0; j < TLD_NVARIANTS; j++) { + r = idn_mapselector_map(ctxs[i], in_string, + utf8_tlds_jp[j], to, + sizeof(to) / sizeof(*to)); + ASSERT_RESULT(r, idn_success); + ASSERT_UCS4STRING(to, out_string_nameprep); + + r = idn_mapselector_map(ctxs[i], in_string, + utf8_tlds_tw[j], to, + sizeof(to) / sizeof(*to)); + ASSERT_RESULT(r, idn_success); + ASSERT_UCS4STRING(to, in_string); + } + } +} + +//# TESTCASE +// title: call add(filemap) and map2() +// group: generic-init generic-filemap +{ + int i, j; + + for (i = 0; i < TLD_NVARIANTS; i++) { + r = idn_mapselector_add(ctxs[i], utf8_tlds_jp[i], + "filemap:" MAP_FILENAME); + ASSERT_RESULT(r, idn_success); + } + + for (i = 0; i < TLD_NVARIANTS; i++) { + for (j = 0; j < TLD_NVARIANTS; j++) { + r = idn_mapselector_map2(ctxs[i], in_string, + ucs4_tlds_jp[j], to, + sizeof(to) / sizeof(*to)); + ASSERT_RESULT(r, idn_success); + ASSERT_UCS4STRING(to, out_string_filemap); + + r = idn_mapselector_map2(ctxs[i], in_string, + ucs4_tlds_tw[j], to, + sizeof(to) / sizeof(*to)); + ASSERT_RESULT(r, idn_success); + ASSERT_UCS4STRING(to, in_string); + } + } +} + +//# TESTCASE +// title: call add(nameprep) and map2() +// group: generic-init generic-filemap +{ + int i, j; + + for (i = 0; i < TLD_NVARIANTS; i++) { + r = idn_mapselector_add(ctxs[i], utf8_tlds_jp[i], + IDN_NAMEPREP_CURRENT); + ASSERT_RESULT(r, idn_success); + } + + for (i = 0; i < TLD_NVARIANTS; i++) { + for (j = 0; j < TLD_NVARIANTS; j++) { + r = idn_mapselector_map2(ctxs[i], in_string, + ucs4_tlds_jp[j], to, + sizeof(to) / sizeof(*to)); + ASSERT_RESULT(r, idn_success); + ASSERT_UCS4STRING(to, out_string_nameprep); + + r = idn_mapselector_map2(ctxs[i], in_string, + ucs4_tlds_tw[j], to, + sizeof(to) / sizeof(*to)); + ASSERT_RESULT(r, idn_success); + ASSERT_UCS4STRING(to, in_string); + } + } +} + +//# TESTCASE +// title: call add(filemap) and map() +// group: generic-init generic-filemap +{ + int i, j; + + for (i = 0; i < TLD_NVARIANTS; i++) { + r = idn_mapselector_add(ctxs[i], utf8_tlds_jp[i], + "filemap:" MAP_FILENAME); + ASSERT_RESULT(r, idn_success); + } + + for (i = 0; i < TLD_NVARIANTS; i++) { + for (j = 0; j < TLD_NVARIANTS; j++) { + r = idn_mapselector_map(ctxs[i], in_string, + utf8_tlds_jp[j], to, + sizeof(to) / sizeof(*to)); + ASSERT_RESULT(r, idn_success); + ASSERT_UCS4STRING(to, out_string_filemap); + + r = idn_mapselector_map(ctxs[i], in_string, + utf8_tlds_tw[j], to, + sizeof(to) / sizeof(*to)); + ASSERT_RESULT(r, idn_success); + ASSERT_UCS4STRING(to, in_string); + } + } +} + +//# TESTCASE +// title: call add(nameprep) and map() +// group: generic-init generic-filemap +{ + int i, j; + + for (i = 0; i < TLD_NVARIANTS; i++) { + r = idn_mapselector_add(ctxs[i], utf8_tlds_jp[i], + IDN_NAMEPREP_CURRENT); + ASSERT_RESULT(r, idn_success); + } + + for (i = 0; i < TLD_NVARIANTS; i++) { + for (j = 0; j < TLD_NVARIANTS; j++) { + r = idn_mapselector_map(ctxs[i], in_string, + utf8_tlds_jp[j], to, + sizeof(to) / sizeof(*to)); + ASSERT_RESULT(r, idn_success); + ASSERT_UCS4STRING(to, out_string_nameprep); + + r = idn_mapselector_map(ctxs[i], in_string, + utf8_tlds_tw[j], to, + sizeof(to) / sizeof(*to)); + ASSERT_RESULT(r, idn_success); + ASSERT_UCS4STRING(to, in_string); + } + } +} + +//# TESTCASE +// title: call addall() +// group: generic-init generic-filemap +{ + static const char *names[] = { + "filemap:" MAP_FILENAME, + IDN_NAMEPREP_CURRENT + }; + int i, j; + + for (i = 0; i < TLD_NVARIANTS; i++) { + r = idn_mapselector_addall(ctxs[i], utf8_tlds_jp[i], names, + sizeof(names) / sizeof(*names)); + ASSERT_RESULT(r, idn_success); + } + + for (i = 0; i < TLD_NVARIANTS; i++) { + for (j = 0; j < TLD_NVARIANTS; j++) { + r = idn_mapselector_map2(ctxs[i], in_string, + ucs4_tlds_jp[j], to, + sizeof(to) / sizeof(*to)); + ASSERT_RESULT(r, idn_success); + ASSERT_UCS4STRING(to, out_string_both); + + r = idn_mapselector_map2(ctxs[i], in_string, + ucs4_tlds_tw[j], to, + sizeof(to) / sizeof(*to)); + ASSERT_RESULT(r, idn_success); + ASSERT_UCS4STRING(to, in_string); + } + } +} + +//# TESTCASE +// title: call addall() with nnames=0 +// group: generic-init +{ + static const char *names[] = {IDN_NAMEPREP_CURRENT}; + + r = idn_mapselector_addall(ctxs[0], ".", names, 0); + ASSERT_RESULT(r, idn_success); +} + +//# TESTCASE +// title: call add() with empty tld +// group: generic-init +{ + r = idn_mapselector_add(ctxs[0], "", IDN_NAMEPREP_CURRENT); + ASSERT_RESULT(r, idn_success); +} + +//# TESTCASE +// title: call addall() with empty tld +// group: generic-init +{ + static const char *names[] = {IDN_NAMEPREP_CURRENT}; + + r = idn_mapselector_addall(ctxs[0], "", names, 1); + ASSERT_RESULT(r, idn_success); +} + +//# TESTCASE +// title: call add() with too long tld +// group: generic-init quiet +{ + r = idn_mapselector_add(ctxs[0], + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "ABCDEFGHIJK", + IDN_NAMEPREP_CURRENT); + ASSERT_RESULT(r, idn_success); + + r = idn_mapselector_add(ctxs[0], + "." + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "ABCDEFGHIJK", + IDN_NAMEPREP_CURRENT); + ASSERT_RESULT(r, idn_success); + + r = idn_mapselector_add(ctxs[0], + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "ABCDEFGHIJKL", + IDN_NAMEPREP_CURRENT); + ASSERT_RESULT(r, idn_invalid_name); + + r = idn_mapselector_add(ctxs[0], + "." + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "ABCDEFGHIJKL", + IDN_NAMEPREP_CURRENT); + ASSERT_RESULT(r, idn_invalid_name); +} + +//# TESTCASE +// title: call addall() with too long tld +// group: generic-init quiet +{ + static const char *names[] = {IDN_NAMEPREP_CURRENT}; + + r = idn_mapselector_addall(ctxs[0], + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "ABCDEFGHIJK", + names, 1); + ASSERT_RESULT(r, idn_success); + + r = idn_mapselector_addall(ctxs[0], + "." + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "ABCDEFGHIJK", + names, 1); + ASSERT_RESULT(r, idn_success); + + r = idn_mapselector_addall(ctxs[0], + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "ABCDEFGHIJKL", + names, 1); + ASSERT_RESULT(r, idn_invalid_name); + + r = idn_mapselector_addall(ctxs[0], + "." + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "ABCDEFGHIJKL", + names, 1); + ASSERT_RESULT(r, idn_invalid_name); +} + +//# TESTCASE +// title: overrun test for arg `to' of map() +// group: generic-init +{ + r = idn_mapselector_add(ctxs[0], utf8_tlds_jp[0], + IDN_NAMEPREP_CURRENT); + ASSERT_RESULT(r, idn_success); + + r = idn_mapselector_map(ctxs[0], in_string, utf8_tlds_jp[0], to, + idn_ucs4_strlen(out_string_nameprep) + 1); + ASSERT_RESULT(r, idn_success); + ASSERT_UCS4STRING(to, out_string_nameprep); + + r = idn_mapselector_map(ctxs[0], in_string, utf8_tlds_tw[0], to, + idn_ucs4_strlen(in_string) + 1); + ASSERT_RESULT(r, idn_success); + ASSERT_UCS4STRING(to, in_string); + + r = idn_mapselector_map(ctxs[0], in_string, utf8_tlds_jp[0], to, + idn_ucs4_strlen(out_string_nameprep)); + ASSERT_RESULT(r, idn_buffer_overflow); + + r = idn_mapselector_map(ctxs[0], in_string, utf8_tlds_tw[0], to, + idn_ucs4_strlen(in_string)); + ASSERT_RESULT(r, idn_buffer_overflow); +} + +//# TESTCASE +// title: overrun test for arg `to' of map2() +// group: generic-init +{ + r = idn_mapselector_add(ctxs[0], utf8_tlds_jp[0], + IDN_NAMEPREP_CURRENT); + ASSERT_RESULT(r, idn_success); + + r = idn_mapselector_map2(ctxs[0], in_string, ucs4_tlds_jp[0], to, + idn_ucs4_strlen(out_string_nameprep) + 1); + ASSERT_RESULT(r, idn_success); + ASSERT_UCS4STRING(to, out_string_nameprep); + + r = idn_mapselector_map2(ctxs[0], in_string, ucs4_tlds_tw[0], to, + idn_ucs4_strlen(in_string) + 1); + ASSERT_RESULT(r, idn_success); + ASSERT_UCS4STRING(to, in_string); + + r = idn_mapselector_map2(ctxs[0], in_string, ucs4_tlds_jp[0], to, + idn_ucs4_strlen(out_string_nameprep)); + ASSERT_RESULT(r, idn_buffer_overflow); + + r = idn_mapselector_map2(ctxs[0], in_string, ucs4_tlds_tw[0], to, + idn_ucs4_strlen(in_string)); + ASSERT_RESULT(r, idn_buffer_overflow); +} + +//# TESTCASE +// title: call map() with tolen=0 +// group: generic-init +{ + r = idn_mapselector_add(ctxs[0], utf8_tlds_jp[0], + IDN_NAMEPREP_CURRENT); + ASSERT_RESULT(r, idn_success); + + r = idn_mapselector_map(ctxs[0], in_string, utf8_tlds_jp[0], to, 0); + ASSERT_RESULT(r, idn_buffer_overflow); + + r = idn_mapselector_map(ctxs[0], in_string, utf8_tlds_tw[0], to, 0); + ASSERT_RESULT(r, idn_buffer_overflow); +} + +//# TESTCASE +// title: call map2() with tolen=0 +// group: generic-init +{ + r = idn_mapselector_add(ctxs[0], utf8_tlds_jp[0], + IDN_NAMEPREP_CURRENT); + ASSERT_RESULT(r, idn_success); + + r = idn_mapselector_map2(ctxs[0], in_string, ucs4_tlds_jp[0], to, 0); + ASSERT_RESULT(r, idn_buffer_overflow); + + r = idn_mapselector_map2(ctxs[0], in_string, ucs4_tlds_tw[0], to, 0); + ASSERT_RESULT(r, idn_buffer_overflow); +} + diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/nameprep.tsy b/contrib/idn/idnkit-1.0-src/lib/tests/nameprep.tsy new file mode 100644 index 0000000..bba49c7 --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/tests/nameprep.tsy @@ -0,0 +1,340 @@ +#ifndef lint +static char *rcsid = "$Id: nameprep.tsy,v 1.1.1.1 2003/06/04 00:26:56 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/nameprep.h> +#include <idn/log.h> +#include "testutil.h" + +#define UCS4_NAME 0x304C /* hiragana letter ga */ +#define BUF_SIZE 4 +/* + * Sample string for `from' argument for map(), + * and its expected outputs. + */ +static const unsigned long map_from[] = { + 0x0041, /* latin capital letter a */ + 0x0042, /* latin capital letter b */ + UCS4_NAME, + 0x0000 +}; + +static const unsigned long map_expected[] = { + 0x0061, /* latin small letter a */ + 0x0062, /* latin small letter b */ + UCS4_NAME, + 0x0000 +}; + +/* + * Sample string for `from' argument for isprohibited(). + */ +static const unsigned long check_from[4] = { + UCS4_NAME, + 0x00A0, /* no-break space: prohibited character */ + 0x0221, /* unassigned character */ + 0x0000 +}; + +#define FROM_UCS4NAME_OFFSET 0 +#define FROM_PROH_OFFSET 1 +#define FROM_UNAS_OFFSET 2 + +/* + * Sample string for `from' argument for isunassigned(). + */ +static const unsigned long check_from2[4] = { + UCS4_NAME, + 0x0221, /* unassigned character */ + 0x00A0, /* no-break space: prohibited character */ + 0x0000 +}; + +#define FROM2_UCS4NAME_OFFSET 0 +#define FROM2_PROH_OFFSET 2 +#define FROM2_UNAS_OFFSET 1 + +/* + * Sample string for `from' argument for isvalidbidi(). + * (It is not a valid bidi label.) + */ +static const unsigned long bidi_from[4] = { + 0x05BE, /* hebrew punctuation maqaf */ + 0x0041, /* latin capital letter a */ + 0xFEFC, /* arabic ligature lam with alef final form */ + 0x0000 +}; +#define BIDIFROM_OFFSET 1 + +/* + * Empty string. + */ +static const unsigned long ucs4_nullstr[] = { + 0x0000 +}; + +//-------------------------------------------------------------------- +// Setups and Teardowns. +//-------------------------------------------------------------------- + +//# SETUP +// group: generic +//-- +// Nothing happens. +{ + idn_result_t r; + idn_nameprep_t handle = NULL; + +} + +//# SETUP +// group: check +//-- +// Initialize the module and create contexts. +{ + idn_result_t r; + idn_nameprep_t handle11 = NULL; + + r = idn_nameprep_create("RFC3491", &handle11); + ASSERT_RESULT(r, idn_success); +} + +//# TEARDOWN +// group: check +//-- +// Destroy contexts. +{ + if (handle11 != NULL) { + idn_nameprep_destroy(handle11); + } +} + +//# 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: idn_nameprep_create() - boundary condition +// group: generic quiet +{ + r = idn_nameprep_create("", &handle); + ASSERT_RESULT(r, idn_notfound); +} + +//# TESTCASE +// title: idn_nameprep_create() - version is NULL (current nameprep) +// group: generic quiet +{ + unsigned long to[BUF_SIZE]; + const unsigned long *found; + + r = idn_nameprep_create(NULL, &handle); + ASSERT_RESULT(r, idn_success); + + r = idn_nameprep_map(handle, map_from, to, BUF_SIZE); + ASSERT_RESULT(r, idn_success); + ASSERT_UCS4STRING(to, map_expected); + + r = idn_nameprep_isunassigned(handle, check_from, &found); + ASSERT_RESULT(r, idn_success); + ASSERT_PTR(found, check_from + FROM_UNAS_OFFSET); + + r = idn_nameprep_isprohibited(handle, check_from, &found); + ASSERT_RESULT(r, idn_success); + ASSERT_PTR(found, check_from + FROM_PROH_OFFSET); + + r = idn_nameprep_isvalidbidi(handle, bidi_from, &found); + ASSERT_RESULT(r, idn_success); + ASSERT_PTR(found, bidi_from + BIDIFROM_OFFSET); + + idn_nameprep_destroy(handle); +} + +//# TESTCASE +// title: idn_nameprep_create() - nameprep-01 +// group: generic quiet +{ + r = idn_nameprep_create("nameprep-01", &handle); + ASSERT_RESULT(r, idn_notfound); +} + +//# TESTCASE +// title: idn_nameprep_create() - RFC3491 +// group: generic +{ + r = idn_nameprep_create("RFC3491", &handle); + ASSERT_RESULT(r, idn_success); + idn_nameprep_destroy(handle); +} + +//# TESTCASE +// title: idn_nameprep_map() - boundary condition +// group: check +{ + unsigned long to[BUF_SIZE]; + + r = idn_nameprep_map(handle11, ucs4_nullstr, to, 0); + ASSERT_RESULT(r, idn_buffer_overflow); + r = idn_nameprep_map(handle11, ucs4_nullstr, to, 1); + ASSERT_RESULT(r, idn_success); + ASSERT_UCS4STRING(to, ucs4_nullstr); +} + +//# TESTCASE +// title: idn_nameprep_map() - RFC3491 +// group: check +{ + unsigned long to[BUF_SIZE]; + + r = idn_nameprep_map(handle11, map_from, to, 0); + ASSERT_RESULT(r, idn_buffer_overflow); + r = idn_nameprep_map(handle11, map_from, to, BUF_SIZE - 1); + ASSERT_RESULT(r, idn_buffer_overflow); + r = idn_nameprep_map(handle11, map_from, to, BUF_SIZE); + ASSERT_RESULT(r, idn_success); + ASSERT_UCS4STRING(to, map_expected); +} + +//# TESTCASE +// title: idn_nameprep_isunassigned() - boundary condition +// group: check +{ + const unsigned long *found; + + r = idn_nameprep_isunassigned(handle11, ucs4_nullstr, &found); + ASSERT_RESULT(r, idn_success); + ASSERT_PTR(found, NULL); +} + +//# TESTCASE +// title: idn_nameprep_isunassigned() - RFC3491 +// group: check +{ + const unsigned long *found; + + r = idn_nameprep_isunassigned(handle11, check_from, &found); + ASSERT_RESULT(r, idn_success); + ASSERT_PTR(found, check_from + FROM_UNAS_OFFSET); + + r = idn_nameprep_isunassigned(handle11, check_from2, &found); + ASSERT_RESULT(r, idn_success); + ASSERT_PTR(found, check_from2 + FROM2_UNAS_OFFSET); +} + +//# TESTCASE +// title: idn_nameprep_isprohibited() - boundary condition +// group: check +{ + const unsigned long *found; + + r = idn_nameprep_isprohibited(handle11, ucs4_nullstr, &found); + ASSERT_RESULT(r, idn_success); + ASSERT_PTR(found, NULL); +} + +//# TESTCASE +// title: idn_nameprep_isprohibited() - RFC3491 +// group: check +{ + const unsigned long *found; + + r = idn_nameprep_isprohibited(handle11, check_from, &found); + ASSERT_RESULT(r, idn_success); + ASSERT_PTR(found, check_from + FROM_PROH_OFFSET); + + r = idn_nameprep_isprohibited(handle11, check_from2, &found); + ASSERT_RESULT(r, idn_success); + ASSERT_PTR(found, check_from2 + FROM2_PROH_OFFSET); +} + +//# TESTCASE +// title: idn_nameprep_isvalidbidi() - boundary condition +// group: check +{ + const unsigned long *found; + + r = idn_nameprep_isvalidbidi(handle11, ucs4_nullstr, &found); + ASSERT_RESULT(r, idn_success); + ASSERT_PTR(found, NULL); +} + +//# TESTCASE +// title: idn_nameprep_isvalidbidi() - RFC3491 +// group: check +{ + const unsigned long *found; + + r = idn_nameprep_isvalidbidi(handle11, bidi_from, &found); + ASSERT_RESULT(r, idn_success); + ASSERT_PTR(found, bidi_from + BIDIFROM_OFFSET); + + r = idn_nameprep_isvalidbidi(handle11, check_from2, &found); + ASSERT_RESULT(r, idn_success); + ASSERT_PTR(found, NULL); +} diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/normalizer.tsy b/contrib/idn/idnkit-1.0-src/lib/tests/normalizer.tsy new file mode 100644 index 0000000..dc9906d --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/tests/normalizer.tsy @@ -0,0 +1,346 @@ +#ifndef lint +static char *rcsid = "$Id: normalizer.tsy,v 1.1.1.1 2003/06/04 00:26:57 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/normalizer.h> +#include <idn/log.h> +#include <idn/ucs4.h> + +#define BUF_SIZE 64 +#define TOBUF_SIZE 4 +#define ARRAY_SIZE 20 +#define CONF_FILENAME "test.map" + +/* + * Sample string for `from' argument of normalize(), + * and its expected outputs. + */ +static const unsigned long from[4] = { + 0x304B, /* hiragana letter ka */ + 0x3099, /* combining katakana-hiragana voiced sound mark */ + 0x32D0, /* circled katakana a */ + 0x0000 +}; + +static const unsigned long normalized_kc_str[3] = { + 0x304C, /* hiragana letter ga */ + 0x30A2, /* katakana letter a */ + 0x0000 +}; + +static const unsigned long normalized_c_str[3] = { + 0x304C, /* hiragana letter ga */ + 0x32D0, /* circled katakana a */ + 0x0000 +}; + +idn_result_t +test_proc(const unsigned long *from, unsigned long *to, size_t tolen) +{ + if (tolen > idn_ucs4_strlen(from)) { + idn_ucs4_strcpy(to, from); + } else { + return (idn_buffer_overflow); + } + + return (idn_success); +} + +//-------------------------------------------------------------------- +// Setups and Teardowns. +//-------------------------------------------------------------------- + +//# SETUP +// group: noinit +//-- +// Do nothing +{ + idn_result_t r; + const char *name; +} + +//# SETUP +// group: generic +//-- +// Initialize the module and create context. +{ + idn_result_t r; + idn_normalizer_t ctx = NULL; + + r = idn_normalizer_initialize(); + ASSERT_RESULT(r, idn_success); + r = idn_normalizer_create(&ctx); + ASSERT_RESULT(r, idn_success); +} + +//# TEARDOWN +// group: generic +//-- +// Destroy context. +{ + idn_normalizer_destroy(ctx); +} + +//# SETUP +// group: addall +//-- +// Initialize the module and create context. +{ + idn_result_t r; + idn_normalizer_t ctx = NULL; + char *names[ARRAY_SIZE]; + int i; + + for (i = 0; i < ARRAY_SIZE; i++) { + names[i] = malloc(BUF_SIZE); + if (names[i] == NULL) { + ASSERT("malloc failed\n"); + } + } + + strcpy(names[0], "RFC3491"); + strcpy(names[1], "unicode-form-kc"); + strcpy(names[2], "unicode-form-kc/3.2.0"); + strcpy(names[3], "RFC3491"); + strcpy(names[4], "unicode-form-kc"); + strcpy(names[5], "unicode-form-kc/3.2.0"); + strcpy(names[6], "RFC3491"); + strcpy(names[7], "unicode-form-kc"); + strcpy(names[8], "unicode-form-kc/3.2.0"); + strcpy(names[9], "RFC3491"); + strcpy(names[10], "unicode-form-kc"); + strcpy(names[11], "unicode-form-kc/3.2.0"); + strcpy(names[12], "RFC3491"); + strcpy(names[13], "unicode-form-kc"); + strcpy(names[14], "unicode-form-kc/3.2.0"); + strcpy(names[15], "RFC3491"); + strcpy(names[16], "unicode-form-kc"); + strcpy(names[17], "unicode-form-kc/3.2.0"); + strcpy(names[18], "RFC3491"); + strcpy(names[19], "unicode-form-kc"); + + r = idn_normalizer_initialize(); + ASSERT_RESULT(r, idn_success); + r = idn_normalizer_create(&ctx); + ASSERT_RESULT(r, idn_success); +} + +//# TEARDOWN +// group: addall +//-- +// Destroy context. +{ + idn_normalizer_destroy(ctx); + for (i = 0; i < ARRAY_SIZE; i++) { + free(names[i]); + } +} + +//# 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: idn_normalizer_add() - boundary condition +// group: generic quiet +{ + r = idn_normalizer_add(ctx, ""); + ASSERT_RESULT(r, idn_invalid_name); +} + +//# TESTCASE +// title: idn_normalizer_add() - builtin schemes +// group: generic quiet +{ + r = idn_normalizer_add(ctx, "RFC3491"); + ASSERT_RESULT(r, idn_success); + r = idn_normalizer_add(ctx, "unicode-form-kc"); + ASSERT_RESULT(r, idn_success); + r = idn_normalizer_add(ctx, "unicode-form-kc/3.2.0"); + ASSERT_RESULT(r, idn_success); + + r = idn_normalizer_add(ctx, "nameprep-01"); + ASSERT_RESULT(r, idn_invalid_name); +} + +//# TESTCASE +// title: idn_normalizer_addall() - boundary condition +// group: addall quiet +{ + strcpy(names[3], ""); + r = idn_normalizer_addall(ctx, (const char **)names, ARRAY_SIZE); + ASSERT_RESULT(r, idn_invalid_name); +} + +//# TESTCASE +// title: idn_normalizer_addall() - nschemes is 0 +// group: addall quiet +{ + r = idn_normalizer_addall(ctx, (const char **)names, 0); + ASSERT_RESULT(r, idn_success); +} + +//# TESTCASE +// title: idn_normalizer_addall() - add a lot of schemes +// group: addall quiet +{ + unsigned long to[TOBUF_SIZE]; + + r = idn_normalizer_addall(ctx, (const char **)names, ARRAY_SIZE); + ASSERT_RESULT(r, idn_success); + r = idn_normalizer_normalize(ctx, from, to, TOBUF_SIZE); + ASSERT_RESULT(r, idn_success); + ASSERT_UCS4STRING(to, normalized_kc_str); +} + +//# TESTCASE +// title: idn_normalizer_addall() - add same scheme repetedly +// group: addall quiet +{ + int i; + unsigned long to[TOBUF_SIZE]; + + for (i = 0; i < ARRAY_SIZE; i++) { + strcpy(names[i], "RFC3491"); + } + r = idn_normalizer_addall(ctx, (const char **)names, ARRAY_SIZE); + ASSERT_RESULT(r, idn_success); + r = idn_normalizer_normalize(ctx, from, to, TOBUF_SIZE); + ASSERT_RESULT(r, idn_success); + ASSERT_UCS4STRING(to, normalized_kc_str); +} + +//# TESTCASE +// title: idn_normalizer_normalize() - schemes check - RFC3491 +// group: generic quiet +{ + unsigned long to[TOBUF_SIZE]; + + r = idn_normalizer_add(ctx, "RFC3491"); + ASSERT_RESULT(r, idn_success); + r = idn_normalizer_normalize(ctx, from, to, TOBUF_SIZE); + ASSERT_RESULT(r, idn_success); + ASSERT_UCS4STRING(to, normalized_kc_str); +} + +//# TESTCASE +// title: idn_normalizer_normalize() - schemes check - unicode-form-kc/3.2.0 +// group: generic quiet +{ + unsigned long to[TOBUF_SIZE]; + + r = idn_normalizer_add(ctx, "unicode-form-kc/3.2.0"); + ASSERT_RESULT(r, idn_success); + r = idn_normalizer_normalize(ctx, from, to, TOBUF_SIZE); + ASSERT_RESULT(r, idn_success); + ASSERT_UCS4STRING(to, normalized_kc_str); +} + +//# TESTCASE +// title: idn_normalizer_normalize() - context without procedure +// group: generic quiet +{ + unsigned long to[TOBUF_SIZE]; + + r = idn_normalizer_normalize(ctx, from, to, TOBUF_SIZE); + ASSERT_RESULT(r, idn_success); + ASSERT_UCS4STRING(to, from); +} + +//# TESTCASE +// title: idn_normalizer_destroy(), idn_normalizer_incrref() +// group: +{ + idn_result_t r; + idn_normalizer_t ctx = NULL; + + r = idn_normalizer_initialize(); + ASSERT_RESULT(r, idn_success); + r = idn_normalizer_create(&ctx); + ASSERT_RESULT(r, idn_success); + idn_normalizer_incrref(ctx); + idn_normalizer_destroy(ctx); + idn_normalizer_destroy(ctx); +} + +//# TESTCASE +// title: idn_normalizer_register() +// group: generic quiet +{ + unsigned long to[TOBUF_SIZE]; + + r = idn_normalizer_register("test", test_proc); + ASSERT_RESULT(r, idn_success); + r = idn_normalizer_add(ctx, "test"); + ASSERT_RESULT(r, idn_success); + + r = idn_normalizer_normalize(ctx, from, to, TOBUF_SIZE); + ASSERT_RESULT(r, idn_success); + ASSERT_UCS4STRING(to, from); +} diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/res.tsy b/contrib/idn/idnkit-1.0-src/lib/tests/res.tsy new file mode 100644 index 0000000..39c3895 --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/tests/res.tsy @@ -0,0 +1,1026 @@ +#ifndef lint +static char *rcsid = "$Id: res.tsy,v 1.1.1.1 2003/06/04 00:26:59 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/res.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 `resconf' context. +// Set local encoding to `UTF-8'. +{ + char to[256]; + idn_result_t r; + idn_resconf_t ctx; + + setenv("IDN_LOCAL_CODESET", "UTF-8", 1); + unsetenv("IDN_DISABLE"); + + r = idn_resconf_initialize(); + ASSERT_RESULT(r, idn_success); + + r = idn_resconf_create(&ctx); + ASSERT_RESULT(r, idn_success); + + r = idn_resconf_setdefaults(ctx); + ASSERT_RESULT(r, idn_success); +} + +//# TEARDOWN +// group: generic-conversion +{ + idn_resconf_destroy(ctx); +} + +//# 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_res_encodename(ctx, 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_res_decodename(ctx, 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_res_decodename2(ctx, 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_res_decodename2(ctx, 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_res_encodename(ctx, 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_res_decodename(ctx, 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_res_decodename2(ctx, 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_res_encodename(ctx, 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_res_encodename(ctx, 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_res_encodename(ctx, 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_res_encodename(ctx, 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_res_encodename(ctx, 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_res_decodename(ctx, 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_res_decodename2(ctx, 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_res_decodename(ctx, 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_res_decodename2(ctx, 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_res_decodename(ctx, 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_res_decodename2(ctx, 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_res_decodename(ctx, 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_res_decodename2(ctx, 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_res_decodename(ctx, 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_res_decodename2(ctx, 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_res_decodename(ctx, 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_res_decodename2(ctx, 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_res_encodename(ctx, 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_res_decodename(ctx, 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_res_decodename2(ctx, 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_res_enable(0); + r = idn_res_encodename(ctx, 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_res_enable(0); + r = idn_res_decodename(ctx, 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_res_enable(0); + r = idn_res_decodename2(ctx, 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_res_enable(0); + r = idn_res_encodename(ctx, 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_res_enable(0); + r = idn_res_decodename(ctx, 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_res_enable(0); + r = idn_res_decodename2(ctx, 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_res_encodename(ctx, 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_res_decodename(ctx, 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 +{ +#ifdef WITHOUT_ICONV + SKIP_TESTCASE; +#else + setenv("IDN_DISABLE", "1", 1); + r = idn_res_decodename2(ctx, 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 then call enable(1) and encodename() +// group: generic-conversion +{ + setenv("IDN_DISABLE", "1", 1); + idn_res_enable(1); + r = idn_res_encodename(ctx, IDN_ENCODE_APP, UTF8_NAME, to, sizeof(to)); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, PUNYCODE_NAME); +} + +//# TESTCASE +// title: set IDN_DISABLE, and then call enable(1) and decodename() +// group: generic-conversion +{ + setenv("IDN_DISABLE", "1", 1); + idn_res_enable(1); + r = idn_res_decodename(ctx, IDN_DECODE_APP, PUNYCODE_NAME, to, sizeof(to)); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, UTF8_REVNAME); +} + +//# TESTCASE +// title: set IDN_DISABLE, and then call enable(1) and decodename2() +// group: generic-conversion +{ +#ifdef WITHOUT_ICONV + SKIP_TESTCASE; +#else + setenv("IDN_DISABLE", "1", 1); + idn_res_enable(1); + r = idn_res_decodename2(ctx, IDN_DECODE_APP, AUX_EUCJP_NAME, to, sizeof(to), + EUCJP_ENCODING_NAME); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, UTF8_REVNAME); +#endif +} + +//# TESTCASE +// title: overrun test for arg `to' of encodename() +// group: generic-conversion +{ + /* Normal case */ + r = idn_res_encodename(ctx, IDN_ENCODE_APP, UTF8_NAME, to, + strlen(PUNYCODE_NAME) + 1); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, PUNYCODE_NAME); + + r = idn_res_encodename(ctx, IDN_ENCODE_APP, UTF8_NAME, to, + strlen(PUNYCODE_NAME)); + ASSERT_RESULT(r, idn_buffer_overflow); + + /* enable(0) case */ + idn_res_enable(0); + r = idn_res_encodename(ctx, IDN_ENCODE_APP, UTF8_NAME, to, + strlen(UTF8_NAME) + 1); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, UTF8_NAME); + + r = idn_res_encodename(ctx, IDN_ENCODE_APP, UTF8_NAME, to, + strlen(UTF8_NAME)); + ASSERT_RESULT(r, idn_buffer_overflow); + + /* actions=0 case */ + idn_res_enable(1); + r = idn_res_encodename(ctx, 0, UTF8_NAME, to, strlen(UTF8_NAME) + 1); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, UTF8_NAME); + + r = idn_res_encodename(ctx, 0, UTF8_NAME, to, strlen(UTF8_NAME)); + ASSERT_RESULT(r, idn_buffer_overflow); +} + +//# TESTCASE +// title: overrun test for arg `to' of decodename() +// group: generic-conversion +{ + /* Normal case */ + r = idn_res_decodename(ctx, IDN_DECODE_APP, PUNYCODE_NAME, to, + strlen(UTF8_REVNAME) + 1); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, UTF8_REVNAME); + + r = idn_res_decodename(ctx, IDN_DECODE_APP, PUNYCODE_NAME, to, + strlen(UTF8_REVNAME)); + ASSERT_RESULT(r, idn_buffer_overflow); + + /* idn_res_enable(0) case */ + idn_res_enable(0); + r = idn_res_decodename(ctx, IDN_DECODE_APP, PUNYCODE_NAME, to, + strlen(PUNYCODE_NAME) + 1); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, PUNYCODE_NAME); + + r = idn_res_decodename(ctx, IDN_DECODE_APP, PUNYCODE_NAME, to, + strlen(PUNYCODE_NAME)); + ASSERT_RESULT(r, idn_buffer_overflow); + + /* actions=0 case */ + idn_res_enable(1); + r = idn_res_decodename(ctx, 0, PUNYCODE_NAME, to, + strlen(PUNYCODE_NAME) + 1); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, PUNYCODE_NAME); + + r = idn_res_decodename(ctx, 0, PUNYCODE_NAME, to, + strlen(PUNYCODE_NAME)); + ASSERT_RESULT(r, idn_buffer_overflow); +} + +//# TESTCASE +// title: overrun test for arg `to' of decodename2() +// group: generic-conversion +{ +#ifdef WITHOUT_ICONV + SKIP_TESTCASE; +#else + /* Normal case */ + r = idn_res_decodename2(ctx, IDN_DECODE_APP, AUX_EUCJP_NAME, to, + strlen(UTF8_REVNAME) + 1, EUCJP_ENCODING_NAME); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, UTF8_REVNAME); + + r = idn_res_decodename2(ctx, IDN_DECODE_APP, AUX_EUCJP_NAME, to, + strlen(UTF8_REVNAME), EUCJP_ENCODING_NAME); + ASSERT_RESULT(r, idn_buffer_overflow); + + /* idn_res_enable(0) case */ + idn_res_enable(0); + r = idn_res_decodename2(ctx, IDN_DECODE_APP, AUX_EUCJP_NAME, to, + strlen(AUX_EUCJP_NAME) + 1, EUCJP_ENCODING_NAME); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, AUX_EUCJP_NAME); + + r = idn_res_decodename2(ctx, IDN_DECODE_APP, AUX_EUCJP_NAME, to, + strlen(AUX_EUCJP_NAME), EUCJP_ENCODING_NAME); + ASSERT_RESULT(r, idn_buffer_overflow); + + /* actions=0 case */ + idn_res_enable(1); + r = idn_res_decodename2(ctx, 0, AUX_EUCJP_NAME, to, + strlen(AUX_EUCJP_NAME) + 1, EUCJP_ENCODING_NAME); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, AUX_EUCJP_NAME); + + r = idn_res_decodename2(ctx, 0, AUX_EUCJP_NAME, to, + strlen(AUX_EUCJP_NAME), EUCJP_ENCODING_NAME); + ASSERT_RESULT(r, idn_buffer_overflow); + +#endif +} + +//# TESTCASE +// title: call encodename() with tolen=0 +// group: generic-conversion +{ + r = idn_res_encodename(ctx, IDN_ENCODE_APP, UTF8_NAME, to, 0); + ASSERT_RESULT(r, idn_buffer_overflow); +} + +//# TESTCASE +// title: call decodename() with tolen=0 +// group: generic-conversion +{ + r = idn_res_decodename(ctx, IDN_DECODE_APP, PUNYCODE_NAME, to, 0); + ASSERT_RESULT(r, idn_buffer_overflow); +} + +//# TESTCASE +// title: call decodename2() with tolen=0 +// group: generic-conversion +{ +#ifdef WITHOUT_ICONV + SKIP_TESTCASE; +#else + r = idn_res_decodename2(ctx, IDN_DECODE_APP, AUX_EUCJP_NAME, to, 0, + EUCJP_ENCODING_NAME); + ASSERT_RESULT(r, idn_buffer_overflow); +#endif +} + +//# TESTCASE +// title: convert an empty string using encodename() +// group: generic-conversion +{ + r = idn_res_encodename(ctx, IDN_ENCODE_APP, "", to, sizeof(to)); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, ""); +} + +//# TESTCASE +// title: convert an empty string using decodename() +// group: generic-conversion +{ + r = idn_res_decodename(ctx, IDN_DECODE_APP, "", to, sizeof(to)); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, ""); +} + +//# TESTCASE +// title: convert an empty string using decodename2() +// group: generic-conversion +{ +#ifdef WITHOUT_ICONV + SKIP_TESTCASE; +#else + r = idn_res_decodename2(ctx, IDN_DECODE_APP, "", to, sizeof(to), + EUCJP_ENCODING_NAME); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, ""); +#endif +} + +//# TESTCASE +// title: prohcheck by encodename() +// group: generic-conversion +{ + /* U+1680: prohibited character */ + r = idn_res_encodename(ctx, IDN_PROHCHECK, "<U+1680>", to, sizeof(to)); + ASSERT_RESULT(r, idn_prohibited); +} + +//# TESTCASE +// title: unascheck by encodename() +// group: generic-conversion +{ + /* U+0221: unassigned codepoint */ + r = idn_res_encodename(ctx, IDN_UNASCHECK, "<U+0221>", to, sizeof(to)); + ASSERT_RESULT(r, idn_prohibited); +} + +//# TESTCASE +// title: bidicheck by encodename() +// group: generic-conversion +{ + /* U+05D0: bidirectional property is "R" */ + /* `a': bidirectional property is "L" */ + /* `0', `-': bidirectional property is "N" */ + r = idn_res_encodename(ctx, IDN_BIDICHECK, "<U+05D0>", to, sizeof(to)); + ASSERT_RESULT(r, idn_success); + + r = idn_res_encodename(ctx, IDN_BIDICHECK, "<U+05D0><U+05D0>", + to, sizeof(to)); + ASSERT_RESULT(r, idn_success); + + r = idn_res_encodename(ctx, IDN_BIDICHECK, "<U+05D0><U+05D0>-a", + to, sizeof(to)); + ASSERT_RESULT(r, idn_prohibited); + + r = idn_res_encodename(ctx, IDN_BIDICHECK, "<U+05D0>-a-<U+05D0>", + to, sizeof(to)); + ASSERT_RESULT(r, idn_prohibited); + + r = idn_res_encodename(ctx, IDN_BIDICHECK, "a-<U+05D0><U+05D0>", + to, sizeof(to)); + ASSERT_RESULT(r, idn_prohibited); + + r = idn_res_encodename(ctx, IDN_BIDICHECK, "<U+05D0><U+05D0>-0", + to, sizeof(to)); + ASSERT_RESULT(r, idn_prohibited); + + r = idn_res_encodename(ctx, IDN_BIDICHECK, "<U+05D0>-0-<U+05D0>", + to, sizeof(to)); + ASSERT_RESULT(r, idn_success); + + r = idn_res_encodename(ctx, IDN_BIDICHECK, "0-<U+05D0><U+05D0>", + to, sizeof(to)); + ASSERT_RESULT(r, idn_prohibited); +} + +//# TESTCASE +// title: asccheck by encodename() +// group: generic-conversion +{ + r = idn_res_encodename(ctx, IDN_ASCCHECK, "-name", to, sizeof(to)); + ASSERT_RESULT(r, idn_prohibited); + + r = idn_res_encodename(ctx, IDN_ASCCHECK, "name-", to, sizeof(to)); + ASSERT_RESULT(r, idn_prohibited); + + r = idn_res_encodename(ctx, IDN_ASCCHECK, "n ame", to, sizeof(to)); + ASSERT_RESULT(r, idn_prohibited); +} + +//# TESTCASE +// title: lencheck by encodename() +// group: generic-conversion +{ + r = idn_res_encodename(ctx, IDN_LENCHECK, + "123456789-123456789-123456789-123456789-" + "123456789-123456789-123", to, sizeof(to)); + ASSERT_RESULT(r, idn_success); + + r = idn_res_encodename(ctx, IDN_LENCHECK, + "123456789-123456789-123456789-123456789-" + "123456789-123456789-1234", to, sizeof(to)); + ASSERT_RESULT(r, idn_invalid_length); + + r = idn_res_encodename(ctx, IDN_LENCHECK, "a..b", to, sizeof(to)); + ASSERT_RESULT(r, idn_invalid_length); +} + +//# TESTCASE +// title: rtcheck non-prohchecked label by decodename() +// group: generic-conversion +{ + /* "xn--6ue" -> "U+1680" (prohibited character) */ + r = idn_res_decodename(ctx, IDN_RTCHECK, "xn--6ue", to, sizeof(to)); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, "xn--6ue"); +} + +//# TESTCASE +// title: rtcheck non-unaschecked label by decodename() +// group: generic-conversion +{ + /* "xn--6la" -> "U+0221" (unassigned codepoint) */ + r = idn_res_decodename(ctx, IDN_IDNCONV | IDN_RTCHECK | IDN_UNASCHECK, + "xn--6la", to, sizeof(to)); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, "xn--6la"); +} + +//# TESTCASE +// title: rtcheck non-ascchecked label by decodename() +// group: generic-conversion +{ + /* "xn----x7t" -> "- U+3042" */ + r = idn_res_decodename(ctx, IDN_IDNCONV | IDN_RTCHECK | IDN_ASCCHECK, + "xn----x7t", to, sizeof(to)); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, "xn----x7t"); + + /* "xn----w7t" -> "U+3042 -" */ + r = idn_res_decodename(ctx, IDN_IDNCONV | IDN_RTCHECK | IDN_ASCCHECK, + "xn----w7t", to, sizeof(to)); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, "xn----w7t"); +} + +//# TESTCASE +// title: rtcheck non-lenchecked label by decodename() +// group: generic-conversion +{ + /* `s1' has 63 characters */ + const char *s1 = + "xn--l8jaa5522a8sj38bzugvvblo3y90fjzgvxlmxscifws3d43odzaq6aj340b"; + + const char *s1rev = + "<U+9752><U+68EE><U+5CA9><U+624B><U+5BAE><U+57CE><U+79CB><U+7530>" + "<U+5C71><U+5F62><U+798F><U+5CF6><U+6771><U+4EAC><U+795E><U+5948>" + "<U+5DDD><U+3042><U+3042><U+3042>"; + + /* `s2' has 64 characters */ + const char *s2 = + "xn--a-w7ta6522a8sj38bzugvvblo3y90fjzgvxlmxscifws3d43odzaq6aj340b"; + + /* `s3' has an empty label */ + const char *s3 = "a..b"; + + r = idn_res_decodename(ctx, IDN_IDNCONV | IDN_RTCHECK, s1, to, sizeof(to)); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, s1rev); + + r = idn_res_decodename(ctx, IDN_IDNCONV | IDN_RTCHECK, s2, to, sizeof(to)); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, s2); + + r = idn_res_decodename(ctx, IDN_IDNCONV | IDN_RTCHECK, s3, to, sizeof(to)); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, s3); +} + +//# TESTCASE +// title: rtcheck non-prohchecked label by decodename2() +// group: generic-conversion +{ +#ifdef WITHOUT_ICONV + SKIP_TESTCASE; +#else + /* "xn--6ue" -> "U+1680" (prohibited character) */ + r = idn_res_decodename2(ctx, IDN_RTCHECK, "xn--6ue", to, sizeof(to), + EUCJP_ENCODING_NAME); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, "xn--6ue"); +#endif +} + +//# TESTCASE +// title: rtcheck non-unaschecked label by decodename2() +// group: generic-conversion +{ +#ifdef WITHOUT_ICONV + SKIP_TESTCASE; +#else + /* "xn--6la" -> "U+0221" (unassigned codepoint) */ + r = idn_res_decodename2(ctx, IDN_IDNCONV | IDN_RTCHECK | IDN_UNASCHECK, + "xn--6la", to, sizeof(to), EUCJP_ENCODING_NAME); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, "xn--6la"); +#endif +} + +//# TESTCASE +// title: rtcheck non-ascchecked label by decodename2() +// group: generic-conversion +{ +#ifdef WITHOUT_ICONV + SKIP_TESTCASE; +#else + /* "xn----x7t" -> "- U+3042" */ + r = idn_res_decodename2(ctx, IDN_IDNCONV | IDN_RTCHECK | IDN_ASCCHECK, + "xn----x7t", to, sizeof(to), EUCJP_ENCODING_NAME); + + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, "xn----x7t"); + + /* "xn----w7t" -> "U+3042 -" */ + r = idn_res_decodename2(ctx, IDN_IDNCONV | IDN_RTCHECK | IDN_ASCCHECK, + "xn----w7t", to, sizeof(to), EUCJP_ENCODING_NAME); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, "xn----w7t"); +#endif +} + +//# TESTCASE +// title: rtcheck non-lenchecked label by decodename2() +// group: generic-conversion +{ +#ifdef WITHOUT_ICONV + SKIP_TESTCASE; +#else + /* `s1' has 63 characters */ + const char *s1 = + "xn--l8jaa5522a8sj38bzugvvblo3y90fjzgvxlmxscifws3d43odzaq6aj340b"; + + const char *s1rev = + "<U+9752><U+68EE><U+5CA9><U+624B><U+5BAE><U+57CE><U+79CB><U+7530>" + "<U+5C71><U+5F62><U+798F><U+5CF6><U+6771><U+4EAC><U+795E><U+5948>" + "<U+5DDD><U+3042><U+3042><U+3042>"; + + /* `s2' has 64 characters */ + const char *s2 = + "xn--a-w7ta6522a8sj38bzugvvblo3y90fjzgvxlmxscifws3d43odzaq6aj340b"; + + /* `s3' has an empty label */ + const char *s3 = "a..b"; + + r = idn_res_decodename2(ctx, IDN_IDNCONV | IDN_RTCHECK, s1, to, sizeof(to), + EUCJP_ENCODING_NAME); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, s1rev); + + r = idn_res_decodename2(ctx, IDN_IDNCONV | IDN_RTCHECK, s2, to, sizeof(to), + EUCJP_ENCODING_NAME); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, s2); + + r = idn_res_decodename(ctx, IDN_IDNCONV | IDN_RTCHECK, s3, to, sizeof(to)); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, s3); +#endif +} + +//# TESTCASE +// title: pass broken string as `from' to encodename() +// group: generic-conversion quiet +{ + /* "\xe3\x21" is not valid UTF-8 string */ + r = idn_res_encodename(ctx, IDN_ENCODE_APP, "\xe3\x21", to, sizeof(to)); + ASSERT_RESULT(r, idn_invalid_encoding); +} + +//# TESTCASE +// title: pass broken string as `from' to decodename() +// group: generic-conversion quiet +{ + /* "\xe3\x21" is not valid UTF-8 string */ + r = idn_res_decodename(ctx, IDN_DECODE_APP, "\xe3\x21", to, sizeof(to)); + ASSERT_RESULT(r, idn_invalid_encoding); +} + +//# TESTCASE +// title: pass broken string as `from' to decodename2() +// group: generic-conversion quiet +{ +#ifdef WITHOUT_ICONV + SKIP_TESTCASE; +#else + /* "\xa4\x21" is not valid EUC-JP string */ + r = idn_res_decodename2(ctx, IDN_DECODE_APP, "\xa4\x21", to, sizeof(to), + EUCJP_ENCODING_NAME); + ASSERT_RESULT(r, idn_invalid_encoding); +#endif +} + diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/resconf.tsy b/contrib/idn/idnkit-1.0-src/lib/tests/resconf.tsy new file mode 100644 index 0000000..a4c2f35 --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/tests/resconf.tsy @@ -0,0 +1,1026 @@ +#ifndef lint +static 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 +{ + create_conf_file(CONF_FILENAME, 0, + "nameprep invalid-version", + NULL); + r = idn_resconf_loadfile(ctx, CONF_FILENAME); + ASSERT_RESULT(r, idn_invalid_name); +} + +//# TESTCASE +// title: load file (define nameprep twice) +// group: generic-init quiet +{ +#ifndef WITHOUT_ICONV + SKIP_TESTCASE; +#else + create_conf_file(CONF_FILENAME, CONF_NO_EOF_NEWLINE, + "nameprep " IDN_NAMEPREP_CURRENT, + "nameprep " IDN_NAMEPREP_CURRENT, + NULL); + r = idn_resconf_loadfile(ctx, CONF_FILENAME); + ASSERT_RESULT(r, idn_invalid_syntax); +#endif +} + +//# TESTCASE +// title: load file (invalid parameter for local-map) +// group: generic-init quiet +{ + create_conf_file(CONF_FILENAME, 0, + "local-map .jp :", + NULL); + r = idn_resconf_loadfile(ctx, CONF_FILENAME); + ASSERT_RESULT(r, idn_invalid_name); + + create_conf_file(CONF_FILENAME, 0, + "local-map .jp invalid:/dev/null", + NULL); + r = idn_resconf_loadfile(ctx, CONF_FILENAME); + ASSERT_RESULT(r, idn_invalid_name); + + create_conf_file(CONF_FILENAME, 0, + "local-map .jp filemap", + NULL); + r = idn_resconf_loadfile(ctx, CONF_FILENAME); + ASSERT_RESULT(r, idn_nofile); + + create_conf_file(CONF_FILENAME, 0, + "local-map .jp filemap:", + NULL); + r = idn_resconf_loadfile(ctx, CONF_FILENAME); + ASSERT_RESULT(r, idn_nofile); + + create_conf_file(CONF_FILENAME, 0, + "local-map .jp filemap:no-such-file", + NULL); + r = idn_resconf_loadfile(ctx, CONF_FILENAME); + ASSERT_RESULT(r, idn_nofile); + + create_conf_file(CONF_FILENAME, 0, + "local-map " + "abcdefghijklmnopqrstuvwxyz0123" + "abcdefghijklmnopqrstuvwxyz0123" + "4567 " + IDN_NAMEPREP_CURRENT, + NULL); + r = idn_resconf_loadfile(ctx, CONF_FILENAME); + ASSERT_RESULT(r, idn_invalid_name); +} + +//# TESTCASE +// title: load file (pass wrong number of parameters to idn-encoding) +// group: generic-init quiet +{ + create_conf_file(CONF_FILENAME, 0, + "idn-encoding ", + NULL); + r = idn_resconf_loadfile(ctx, CONF_FILENAME); + ASSERT_RESULT(r, idn_invalid_syntax); + + create_conf_file(CONF_FILENAME, 0, + "idn-encoding Punycode ?", + NULL); + r = idn_resconf_loadfile(ctx, CONF_FILENAME); + ASSERT_RESULT(r, idn_invalid_syntax); +} + +//# TESTCASE +// title: load file (pass wrong number of parameters to nameprep) +// group: generic-init quiet +{ + create_conf_file(CONF_FILENAME, 0, + "nameprep ", + NULL); + r = idn_resconf_loadfile(ctx, CONF_FILENAME); + ASSERT_RESULT(r, idn_invalid_syntax); + + create_conf_file(CONF_FILENAME, 0, + "nameprep " IDN_NAMEPREP_CURRENT " ?", + NULL); + r = idn_resconf_loadfile(ctx, CONF_FILENAME); + ASSERT_RESULT(r, idn_invalid_syntax); +} + +//# TESTCASE +// title: load file (pass wrong number of parameters to local-map) +// group: generic-init quiet +{ + create_conf_file(CONF_FILENAME, 0, + "local-map ", + NULL); + r = idn_resconf_loadfile(ctx, CONF_FILENAME); + ASSERT_RESULT(r, idn_invalid_syntax); + + create_conf_file(CONF_FILENAME, 0, + "local-map .jp ", + NULL); + r = idn_resconf_loadfile(ctx, CONF_FILENAME); + ASSERT_RESULT(r, idn_invalid_syntax); +} + +//# TESTCASE +// title: getdelimitermap +// group: generic-init set-defaults delimitermap_ctx +{ + delimitermap_ctx1 = idn_resconf_getdelimitermap(ctx); + ASSERT_PTR_NE(delimitermap_ctx1, NULL); +} + +//# TESTCASE +// title: setdelimitermap +// group: generic-init set-defaults delimitermap_ctx +{ + r = idn_delimitermap_create(&delimitermap_ctx1); + ASSERT_RESULT(r, idn_success); + + /* set delimitermap context. */ + idn_resconf_setdelimitermap(ctx, delimitermap_ctx1); + delimitermap_ctx2 = idn_resconf_getdelimitermap(ctx); + ASSERT_PTR(delimitermap_ctx2, delimitermap_ctx1); + idn_delimitermap_destroy(delimitermap_ctx2); + + /* set NULL as delimitermap context */ + idn_resconf_setdelimitermap(ctx, NULL); + delimitermap_ctx2 = idn_resconf_getdelimitermap(ctx); + ASSERT_PTR(delimitermap_ctx2, NULL); +} + +//# TESTCASE +// title: addalldelimitermapucs +// group: generic-init set-defaults +{ + static unsigned long v[] = {0x002C, 0x3001, 0xFF0C}; + int nv = sizeof(v) / sizeof(*v); + + r = idn_resconf_addalldelimitermapucs(ctx, v, nv); + ASSERT_RESULT(r, idn_success); +} + +//# TESTCASE +// title: getidnconverter +// group: generic-init set-defaults idnconverter_ctx +{ + idnconverter_ctx1 = idn_resconf_getidnconverter(ctx); + ASSERT_PTR_NE(idnconverter_ctx1, NULL); +} + +//# TESTCASE +// title: setidnconverter +// group: generic-init set-defaults idnconverter_ctx +{ + r = idn_converter_create("Punycode", &idnconverter_ctx1, 0); + ASSERT_RESULT(r, idn_success); + + /* set idnconverter context. */ + idn_resconf_setidnconverter(ctx, idnconverter_ctx1); + idnconverter_ctx2 = idn_resconf_getidnconverter(ctx); + ASSERT_PTR(idnconverter_ctx2, idnconverter_ctx1); + idn_converter_destroy(idnconverter_ctx2); + + /* set NULL as idnconverter context */ + idn_resconf_setidnconverter(ctx, NULL); + idnconverter_ctx2 = idn_resconf_getidnconverter(ctx); + ASSERT_PTR(idnconverter_ctx2, NULL); +} + +//# TESTCASE +// title: getlocalconverter +// group: generic-init set-defaults localconverter_ctx +{ + localconverter_ctx1 = idn_resconf_getlocalconverter(ctx); +#ifdef WITHOUT_ICONV + ASSERT_PTR(localconverter_ctx1, NULL); +#else + ASSERT_PTR_NE(localconverter_ctx1, NULL); +#endif +} + +//# TESTCASE +// title: setlocalconverter +// group: generic-init set-defaults localconverter_ctx +{ + r = idn_converter_create("UTF-8", &localconverter_ctx1, 0); + ASSERT_RESULT(r, idn_success); + + /* set localconverter context. */ + idn_resconf_setlocalconverter(ctx, localconverter_ctx1); + localconverter_ctx2 = idn_resconf_getlocalconverter(ctx); +#ifdef WITHOUT_ICONV + ASSERT_PTR(localconverter_ctx2, NULL); +#else + ASSERT_PTR(localconverter_ctx2, localconverter_ctx1); + idn_converter_destroy(localconverter_ctx2); +#endif + + /* set NULL as localconverter context */ + idn_resconf_setlocalconverter(ctx, NULL); + localconverter_ctx2 = idn_resconf_getlocalconverter(ctx); +#ifdef WITHOUT_ICONV + ASSERT_PTR(localconverter_ctx2, NULL); +#else + ASSERT_PTR_NE(localconverter_ctx2, NULL); +#endif +} + +//# TESTCASE +// title: getauxidnconverter +// group: generic-init set-defaults auxidnconverter_ctx +{ + auxidnconverter_ctx1 = idn_resconf_getauxidnconverter(ctx); + ASSERT_PTR(auxidnconverter_ctx1, NULL); +} + +//# TESTCASE +// title: setauxidnconverter +// group: generic-init set-defaults auxidnconverter_ctx +{ + r = idn_converter_create("Punycode", &auxidnconverter_ctx1, 0); + ASSERT_RESULT(r, idn_success); + + /* set auxidnconverter context. */ + idn_resconf_setauxidnconverter(ctx, auxidnconverter_ctx1); + auxidnconverter_ctx2 = idn_resconf_getauxidnconverter(ctx); + ASSERT_PTR(auxidnconverter_ctx2, auxidnconverter_ctx1); + idn_converter_destroy(auxidnconverter_ctx2); + + /* set NULL as auxidnconverter context */ + idn_resconf_setauxidnconverter(ctx, NULL); + auxidnconverter_ctx2 = idn_resconf_getauxidnconverter(ctx); + ASSERT_PTR(auxidnconverter_ctx2, NULL); +} + +//# TESTCASE +// title: getlocalmapselector +// group: generic-init set-defaults mapselector_ctx +{ + mapselector_ctx1 = idn_resconf_getlocalmapselector(ctx); + ASSERT_PTR(mapselector_ctx1, NULL); +} + +//# TESTCASE +// title: setlocalmapselector +// group: generic-init set-defaults mapselector_ctx +{ + r = idn_mapselector_create(&mapselector_ctx1); + ASSERT_RESULT(r, idn_success); + + /* set localmapselector context. */ + idn_resconf_setlocalmapselector(ctx, mapselector_ctx1); + mapselector_ctx2 = idn_resconf_getlocalmapselector(ctx); + ASSERT_PTR(mapselector_ctx2, mapselector_ctx1); + idn_mapselector_destroy(mapselector_ctx2); + + /* set NULL as localmapselector context */ + idn_resconf_setlocalmapselector(ctx, NULL); + mapselector_ctx2 = idn_resconf_getlocalmapselector(ctx); + ASSERT_PTR(mapselector_ctx2, NULL); +} + +//# TESTCASE +// title: addalllocalmapselectornames +// group: generic-init set-defaults +{ + static const char *names[] = { + "filemap:" MAP_FILENAME, + "filemap:" MAP_FILENAME, + "filemap:" MAP_FILENAME + }; + int nnames = sizeof(names) / sizeof(*names); + + create_conf_file(MAP_FILENAME, 0, + "2212; FF0D", + NULL); + r = idn_resconf_addalllocalmapselectornames(ctx, ".jp", names, nnames); + ASSERT_RESULT(r, idn_success); +} + +//# TESTCASE +// title: getmapper +// group: generic-init set-defaults mapper_ctx +{ + mapper_ctx1 = idn_resconf_getmapper(ctx); + ASSERT_PTR_NE(mapper_ctx1, NULL); +} + +//# TESTCASE +// title: setmapper +// group: generic-init set-defaults mapper_ctx +{ + r = idn_mapper_create(&mapper_ctx1); + ASSERT_RESULT(r, idn_success); + + /* set mapper context. */ + idn_resconf_setmapper(ctx, mapper_ctx1); + mapper_ctx2 = idn_resconf_getmapper(ctx); + ASSERT_PTR(mapper_ctx2, mapper_ctx1); + idn_mapper_destroy(mapper_ctx2); + + /* set NULL as mapper context */ + idn_resconf_setmapper(ctx, NULL); + mapper_ctx2 = idn_resconf_getmapper(ctx); + ASSERT_PTR(mapper_ctx2, NULL); +} + +//# TESTCASE +// title: addallmappernames +// group: generic-init set-defaults +{ + static const char *names[] = { + IDN_NAMEPREP_CURRENT, + IDN_NAMEPREP_CURRENT, + IDN_NAMEPREP_CURRENT + }; + int nnames = sizeof(names) / sizeof(*names); + + r = idn_resconf_addallmappernames(ctx, names, nnames); + ASSERT_RESULT(r, idn_success); +} + +//# TESTCASE +// title: getnormalizer +// group: generic-init set-defaults normalizer_ctx +{ + normalizer_ctx1 = idn_resconf_getnormalizer(ctx); + ASSERT_PTR_NE(normalizer_ctx1, NULL); +} + +//# TESTCASE +// title: setnormalizer +// group: generic-init set-defaults normalizer_ctx +{ + r = idn_normalizer_create(&normalizer_ctx1); + ASSERT_RESULT(r, idn_success); + + /* set normalizer context. */ + idn_resconf_setnormalizer(ctx, normalizer_ctx1); + normalizer_ctx2 = idn_resconf_getnormalizer(ctx); + ASSERT_PTR(normalizer_ctx2, normalizer_ctx1); + idn_normalizer_destroy(normalizer_ctx2); + + /* set NULL as normalizer context */ + idn_resconf_setnormalizer(ctx, NULL); + normalizer_ctx2 = idn_resconf_getnormalizer(ctx); + ASSERT_PTR(normalizer_ctx2, NULL); +} + +//# TESTCASE +// title: addallnormalizernames +// group: generic-init set-defaults +{ + static const char *names[] = { + IDN_NAMEPREP_CURRENT, + IDN_NAMEPREP_CURRENT, + IDN_NAMEPREP_CURRENT + }; + int nnames = sizeof(names) / sizeof(*names); + + r = idn_resconf_addallnormalizernames(ctx, names, nnames); + ASSERT_RESULT(r, idn_success); +} + +//# TESTCASE +// title: getprohibitchecker +// group: generic-init set-defaults prohibitchecker_ctx +{ + prohibitchecker_ctx1 = idn_resconf_getprohibitchecker(ctx); + ASSERT_PTR_NE(prohibitchecker_ctx1, NULL); +} + +//# TESTCASE +// title: setprohibitchecker +// group: generic-init set-defaults prohibitchecker_ctx +{ + r = idn_checker_create(&prohibitchecker_ctx1); + ASSERT_RESULT(r, idn_success); + + /* set checker context. */ + idn_resconf_setprohibitchecker(ctx, prohibitchecker_ctx1); + prohibitchecker_ctx2 = idn_resconf_getprohibitchecker(ctx); + ASSERT_PTR(prohibitchecker_ctx2, prohibitchecker_ctx1); + idn_checker_destroy(prohibitchecker_ctx2); + + /* set NULL as checker context */ + idn_resconf_setprohibitchecker(ctx, NULL); + prohibitchecker_ctx2 = idn_resconf_getprohibitchecker(ctx); + ASSERT_PTR(prohibitchecker_ctx2, NULL); +} + +//# TESTCASE +// title: addallprohibitcheckernames +// group: generic-init set-defaults +{ + static const char *names[] = { + IDN_NAMEPREP_CURRENT, + IDN_NAMEPREP_CURRENT, + IDN_NAMEPREP_CURRENT + }; + int nnames = sizeof(names) / sizeof(*names); + + r = idn_resconf_addallprohibitcheckernames(ctx, names, nnames); + ASSERT_RESULT(r, idn_success); +} + +//# TESTCASE +// title: getunassignedchecker +// group: generic-init set-defaults unassignedchecker_ctx +{ + unassignedchecker_ctx1 = idn_resconf_getunassignedchecker(ctx); + ASSERT_PTR_NE(unassignedchecker_ctx1, NULL); +} + +//# TESTCASE +// title: setunassignedchecker +// group: generic-init set-defaults unassignedchecker_ctx +{ + r = idn_checker_create(&unassignedchecker_ctx1); + ASSERT_RESULT(r, idn_success); + + /* set checker context. */ + idn_resconf_setunassignedchecker(ctx, unassignedchecker_ctx1); + unassignedchecker_ctx2 = idn_resconf_getunassignedchecker(ctx); + ASSERT_PTR(unassignedchecker_ctx2, unassignedchecker_ctx1); + idn_checker_destroy(unassignedchecker_ctx2); + + /* set NULL as checker context */ + idn_resconf_setunassignedchecker(ctx, NULL); + unassignedchecker_ctx2 = idn_resconf_getunassignedchecker(ctx); + ASSERT_PTR(unassignedchecker_ctx2, NULL); +} + +//# TESTCASE +// title: addallunassignedcheckernames +// group: generic-init set-defaults +{ + static const char *names[] = { + IDN_NAMEPREP_CURRENT, + IDN_NAMEPREP_CURRENT, + IDN_NAMEPREP_CURRENT + }; + int nnames = sizeof(names) / sizeof(*names); + + r = idn_resconf_addallunassignedcheckernames(ctx, names, nnames); + ASSERT_RESULT(r, idn_success); +} + +//# TESTCASE +// title: getbidichecker +// group: generic-init set-defaults bidichecker_ctx +{ + bidichecker_ctx1 = idn_resconf_getbidichecker(ctx); + ASSERT_PTR_NE(bidichecker_ctx1, NULL); +} + +//# TESTCASE +// title: setbidichecker +// group: generic-init set-defaults bidichecker_ctx +{ + r = idn_checker_create(&bidichecker_ctx1); + ASSERT_RESULT(r, idn_success); + + /* set checker context. */ + idn_resconf_setbidichecker(ctx, bidichecker_ctx1); + bidichecker_ctx2 = idn_resconf_getbidichecker(ctx); + ASSERT_PTR(bidichecker_ctx2, bidichecker_ctx1); + idn_checker_destroy(bidichecker_ctx2); + + /* set NULL as checker context */ + idn_resconf_setbidichecker(ctx, NULL); + bidichecker_ctx2 = idn_resconf_getbidichecker(ctx); + ASSERT_PTR(bidichecker_ctx2, NULL); +} + +//# TESTCASE +// title: addallbidicheckernames +// group: generic-init set-defaults +{ + static const char *names[] = { + IDN_NAMEPREP_CURRENT, + IDN_NAMEPREP_CURRENT, + IDN_NAMEPREP_CURRENT + }; + int nnames = sizeof(names) / sizeof(*names); + + r = idn_resconf_addallbidicheckernames(ctx, names, nnames); + ASSERT_RESULT(r, idn_success); +} + +//# TESTCASE +// title: setnameprepversion +// group: generic-init set-defaults +{ + idn_resconf_setnameprepversion(ctx, IDN_NAMEPREP_CURRENT); + ASSERT_RESULT(r, idn_success); +} diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/setenv.c b/contrib/idn/idnkit-1.0-src/lib/tests/setenv.c new file mode 100644 index 0000000..9c12bf1 --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/tests/setenv.c @@ -0,0 +1,134 @@ +#ifndef lint +static char *rcsid = "$Id: setenv.c,v 1.1.1.1 2003/06/04 00:27:01 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 <string.h> + +/* + * We don't include <stdlib.h> here. + * Also <stdlib.h> may declare `environ' and its type might be different + * from ours. + */ +extern char **environ; + +typedef struct myenv myenv_t; + +struct myenv { + char *pointer; + myenv_t *next; + myenv_t *prev; +}; + +static myenv_t *myenvs = NULL; + +void +myunsetenv(const char *name) { + char **e; + myenv_t *mye; + size_t namelen; + extern void free(void *); + + namelen = strlen(name); + for (e = environ; *e != NULL; e++) { + if (strncmp(*e, name, namelen) == 0 && (*e)[namelen] == '=') + break; + } + if (*e == NULL) + return; + + for (mye = myenvs; mye != NULL; mye = mye->next) { + if (mye->pointer == *e) { + if (mye->next != NULL) + mye->next->prev = mye->prev; + if (mye->prev != NULL) + mye->prev->next = mye->next; + if (mye->next == NULL && mye->prev == NULL) + myenvs = NULL; + free(mye); + free(*e); + break; + } + } + + for ( ; *e != NULL; e++) + *e = *(e + 1); +} + +#include <stdlib.h> + +int +mysetenv(const char *name, const char *value, int overwrite) { + myenv_t *mye; + char *buffer; + int result; + + if (getenv(name) != NULL && !overwrite) + return 0; + + buffer = (char *) malloc(strlen(name) + strlen(value) + 2); + if (buffer == NULL) + return -1; + strcpy(buffer, name); + strcat(buffer, "="); + strcat(buffer, value); + + myunsetenv(name); + + mye = (myenv_t *) malloc(sizeof(myenv_t)); + if (mye == NULL) + return -1; + mye->pointer = buffer; + mye->next = myenvs; + mye->prev = NULL; + if (myenvs != NULL) + myenvs->prev = mye; + myenvs = mye; + + result = putenv(buffer); + + return result; +} diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/setenv.h b/contrib/idn/idnkit-1.0-src/lib/tests/setenv.h new file mode 100644 index 0000000..704c179 --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/tests/setenv.h @@ -0,0 +1,61 @@ +/* $Id: setenv.h,v 1.1.1.1 2003/06/04 00:27:01 marka Exp $ */ +/* + * 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. + */ + +#ifndef IDN_SETENV_H +#define IDN_SETENV_H + +#include "testconfig.h" + +#ifndef HAVE_SETENV +#define unsetenv(a1) myunsetenv(a1) +#endif + +#ifndef HAVE_SETENV +#define setenv(a1, a2, a3) mysetenv(a1, a2, a3) +#endif + +void myunsetenv(const char *name); +int mysetenv(const char *name, const char *value, int overwrite); + +#endif /* IDN_SETENV_H */ diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/testsuite.c b/contrib/idn/idnkit-1.0-src/lib/tests/testsuite.c new file mode 100644 index 0000000..14b202f --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/tests/testsuite.c @@ -0,0 +1,578 @@ +#ifndef lint +static char *rcsid = "$Id"; +#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 <assert.h> + +#include <idn/result.h> +#include <idn/ucs4.h> +#include <testsuite.h> + +typedef struct idn_testcase *idn_testcase_t; + +struct idn_testcase { + char *title; + idn_testsuite_testproc_t proc; +}; + +struct idn_testsuite { + idn_testcase_t testcases; + int ntestcases; + int testcase_size; + + int npassed; + int nfailed; + int nskipped; + idn_testcase_t current_testcase; + idn_teststatus_t current_status; + + idn_testsuite_msgproc_t msgproc; + int verbose; +}; + +#define INITIAL_TESTCASE_SIZE 16 +#define INITIAL_SETUP_SIZE 4 +#define INITIAL_TEARDOWN_SIZE 4 + +static void run_internal(idn_testsuite_t ctx, char *titles[]); +static char *make_hex_string(const char *string); +static char *make_hex_ucs4string(const unsigned long *string); +static void put_failure_message(idn_testsuite_t ctx, const char *msg, + const char *file, int lineno); +static void idn_testsuite_msgtostderr(const char *msg); + +int +idn_testsuite_create(idn_testsuite_t *ctxp) { + idn_testsuite_t ctx = NULL; + + assert(ctxp != NULL); + + ctx = (idn_testsuite_t) malloc(sizeof(struct idn_testsuite)); + if (ctx == NULL) + goto error; + + ctx->testcases = NULL; + ctx->ntestcases = 0; + ctx->testcase_size = 0; + ctx->npassed = 0; + ctx->nfailed = 0; + ctx->nskipped = 0; + ctx->current_testcase = NULL; + ctx->current_status = idn_teststatus_pass; + ctx->msgproc = NULL; + ctx->verbose = 0; + + ctx->testcases = (idn_testcase_t) malloc(sizeof(struct idn_testcase) + * INITIAL_TESTCASE_SIZE); + if (ctx->testcases == NULL) + goto error; + ctx->testcase_size = INITIAL_TESTCASE_SIZE; + + *ctxp = ctx; + return (1); + +error: + if (ctx != NULL) + free(ctx->testcases); + free(ctx); + return (0); +} + +void +idn_testsuite_destroy(idn_testsuite_t ctx) { + int i; + + assert(ctx != NULL); + + for (i = 0; i < ctx->ntestcases; i++) + free(ctx->testcases[i].title); + + free(ctx->testcases); + free(ctx); +} + +int +idn_testsuite_addtestcase(idn_testsuite_t ctx, const char *title, + idn_testsuite_testproc_t proc) { + char *dup_title = NULL; + idn_testcase_t new_buffer = NULL; + idn_testcase_t new_testcase; + int new_size; + + assert(ctx != NULL && title != NULL && proc != NULL); + + dup_title = (char *)malloc(strlen(title) + 1); + if (dup_title == NULL) + goto error; + strcpy(dup_title, title); + + if (ctx->ntestcases == ctx->testcase_size) { + new_size = ctx->testcase_size + INITIAL_TESTCASE_SIZE; + new_buffer = (idn_testcase_t) + realloc(ctx->testcases, + sizeof(struct idn_testcase) * new_size); + if (new_buffer == NULL) + goto error; + ctx->testcases = new_buffer; + ctx->testcase_size = new_size; + } + + new_testcase = ctx->testcases + ctx->ntestcases; + new_testcase->title = dup_title; + new_testcase->proc = proc; + ctx->ntestcases++; + return (1); + +error: + free(dup_title); + free(new_buffer); + return (0); +} + +int +idn_testsuite_ntestcases(idn_testsuite_t ctx) { + assert(ctx != NULL); + return (ctx->ntestcases); +} + +void +idn_testsuite_setverbose(idn_testsuite_t ctx) { + assert(ctx != NULL); + ctx->verbose = 1; +} + +void +idn_testsuite_unsetverbose(idn_testsuite_t ctx) { + assert(ctx != NULL); + ctx->verbose = 0; +} + +static void +run_internal(idn_testsuite_t ctx, char *titles[]) { + int i, j; + int run_testcase; + const char *status; + + assert(ctx != NULL); + + ctx->npassed = 0; + ctx->nfailed = 0; + ctx->nskipped = 0; + + for (i = 0; i < ctx->ntestcases; i++) { + ctx->current_testcase = ctx->testcases + i; + ctx->current_status = idn_teststatus_pass; + + if (titles == NULL) + run_testcase = 1; + else { + run_testcase = 0; + for (j = 0; titles[j] != NULL; j++) { + if (strcmp(ctx->current_testcase->title, + titles[j]) == 0) { + run_testcase = 1; + break; + } + } + } + + if (!run_testcase) { + ctx->nskipped++; + continue; + } + if (ctx->verbose) { + fprintf(stderr, "start testcase %d: %s\n", i + 1, + ctx->testcases[i].title); + } + (ctx->testcases[i].proc)(ctx); + status = idn_teststatus_tostring(ctx->current_status); + if (ctx->verbose) { + fprintf(stderr, "end testcase %d: %s\n", i + 1, + status); + } + + switch (ctx->current_status) { + case idn_teststatus_pass: + ctx->npassed++; + break; + case idn_teststatus_fail: + ctx->nfailed++; + break; + case idn_teststatus_skip: + ctx->nskipped++; + break; + } + } +} + +void +idn_testsuite_runall(idn_testsuite_t ctx) { + assert(ctx != NULL); + run_internal(ctx, NULL); +} + +void +idn_testsuite_run(idn_testsuite_t ctx, char *titles[]) { + assert(ctx != NULL && titles != NULL); + run_internal(ctx, titles); +} + +int +idn_testsuite_npassed(idn_testsuite_t ctx) { + assert(ctx != NULL); + return (ctx->npassed); +} + +int +idn_testsuite_nfailed(idn_testsuite_t ctx) { + assert(ctx != NULL); + return (ctx->nfailed); +} + +int +idn_testsuite_nskipped(idn_testsuite_t ctx) { + assert(ctx != NULL); + return (ctx->nskipped); +} + +idn_teststatus_t +idn_testsuite_getstatus(idn_testsuite_t ctx) { + assert(ctx != NULL); + return (ctx->current_status); +} + +void +idn_testsuite_setstatus(idn_testsuite_t ctx, idn_teststatus_t status) { + assert(ctx != NULL); + assert(status == idn_teststatus_pass || + status == idn_teststatus_fail || + status == idn_teststatus_skip); + + ctx->current_status = status; +} + +const char * +idn_teststatus_tostring(idn_teststatus_t status) { + assert(status == idn_teststatus_pass || + status == idn_teststatus_fail || + status == idn_teststatus_skip); + + switch (status) { + case idn_teststatus_pass: + return "pass"; + break; + case idn_teststatus_fail: + return "failed"; + break; + case idn_teststatus_skip: + return "skipped"; + break; + } + + return "unknown"; +} + +void +idn_testsuite_assert(idn_testsuite_t ctx, const char *msg, + const char *file, int lineno) { + assert(ctx != NULL && msg != NULL && file != NULL); + + if (idn_testsuite_getstatus(ctx) != idn_teststatus_pass) + return; + idn_testsuite_setstatus(ctx, idn_teststatus_fail); + put_failure_message(ctx, msg, file, lineno); +} + +void +idn_testsuite_assertint(idn_testsuite_t ctx, int gotten, int expected, + const char *file, int lineno) { + char msg[256]; /* large enough */ + + assert(ctx != NULL && file != NULL); + + if (idn_testsuite_getstatus(ctx) != idn_teststatus_pass) + return; + if (expected == gotten) + return; + idn_testsuite_setstatus(ctx, idn_teststatus_fail); + + sprintf(msg, "`%d' expected, but got `%d'", expected, gotten); + put_failure_message(ctx, msg, file, lineno); +} + +void +idn_testsuite_assertstring(idn_testsuite_t ctx, + const char *gotten, const char *expected, + const char *file, int lineno) { + char *expected_hex = NULL; + char *gotten_hex = NULL; + char *msg; + + assert(ctx != NULL && gotten != NULL && expected != NULL && + file != NULL); + + if (idn_testsuite_getstatus(ctx) != idn_teststatus_pass) + return; + if (strcmp(expected, gotten) == 0) + return; + idn_testsuite_setstatus(ctx, idn_teststatus_fail); + + msg = (char *)malloc(strlen(expected) * 4 + strlen(gotten) * 4 + 32); + expected_hex = make_hex_string(expected); + gotten_hex = make_hex_string(gotten); + if (msg == NULL || expected_hex == NULL || gotten_hex == NULL) { + msg = ""; + } else { + sprintf(msg, "`%s' expected, but got `%s'", + expected_hex, gotten_hex); + } + + put_failure_message(ctx, msg, file, lineno); + + free(msg); + free(expected_hex); + free(gotten_hex); +} + +void +idn_testsuite_assertptr(idn_testsuite_t ctx, const void *gotten, + const void *expected, const char *file, int lineno) { + char *msg; + + assert(ctx != NULL && file != NULL); + + if (idn_testsuite_getstatus(ctx) != idn_teststatus_pass) + return; + if (expected == gotten) + return; + idn_testsuite_setstatus(ctx, idn_teststatus_fail); + + if (expected == NULL) + msg = "NULL expected, but got non-NULL"; + else if (gotten == NULL) + msg = "non-NULL expected, but got NULL"; + else + msg = "expected pointer != gotten pointer"; + put_failure_message(ctx, msg, file, lineno); +} + +void +idn_testsuite_assertptrne(idn_testsuite_t ctx, + const void *gotten, const void *unexpected, + const char *file, int lineno) { + char *msg; + + assert(ctx != NULL && file != NULL); + + if (idn_testsuite_getstatus(ctx) != idn_teststatus_pass) + return; + if (unexpected != gotten) + return; + idn_testsuite_setstatus(ctx, idn_teststatus_fail); + + if (unexpected == NULL) + msg = "non-NULL unexpected, but got NULL"; + else if (gotten == NULL) + msg = "non-NULL expected, but got NULL"; + else + msg = "expected pointer == gotten pointer"; + put_failure_message(ctx, msg, file, lineno); +} + +void +idn_testsuite_assertresult(idn_testsuite_t ctx, + idn_result_t gotten, idn_result_t expected, + const char *file, int lineno) { + char msg[256]; /* large enough */ + + assert(ctx != NULL && file != NULL); + + if (idn_testsuite_getstatus(ctx) != idn_teststatus_pass) + return; + if (expected == gotten) + return; + idn_testsuite_setstatus(ctx, idn_teststatus_fail); + + sprintf(msg, "`%s' expected, but got `%s'", + idn_result_tostring(expected), idn_result_tostring(gotten)); + put_failure_message(ctx, msg, file, lineno); +} + +void +idn_testsuite_assertucs4string(idn_testsuite_t ctx, + const unsigned long *gotten, + const unsigned long *expected, + const char *file, int lineno) { + char *expected_hex = NULL; + char *gotten_hex = NULL; + char *msg; + + assert(ctx != NULL && gotten != NULL && expected != NULL && + file != NULL); + + if (idn_testsuite_getstatus(ctx) != idn_teststatus_pass) + return; + if (idn_ucs4_strcmp(expected, gotten) == 0) + return; + idn_testsuite_setstatus(ctx, idn_teststatus_fail); + + msg = (char *)malloc(idn_ucs4_strlen(expected) * 8 + + idn_ucs4_strlen(gotten) * 8 + 32); + expected_hex = make_hex_ucs4string(expected); + gotten_hex = make_hex_ucs4string(gotten); + if (msg == NULL || expected_hex == NULL || gotten_hex == NULL) { + msg = ""; + } else { + sprintf(msg, "`%s' expected, but got `%s'", + expected_hex, gotten_hex); + } + + put_failure_message(ctx, msg, file, lineno); + + free(msg); + free(expected_hex); + free(gotten_hex); +} + +static char * +make_hex_string(const char *string) { + static const char hex[] = {"0123456789abcdef"}; + char *hex_string; + const char *src; + char *dst; + + hex_string = (char *)malloc((strlen(string)) * 4 + 1); + if (hex_string == NULL) + return NULL; + + for (src = string, dst = hex_string; *src != '\0'; src++) { + if (0x20 <= *src && *src <= 0x7e && *src != '\\') { + *dst++ = *src; + } else { + *dst++ = '\\'; + *dst++ = 'x'; + *dst++ = hex[*(const unsigned char *)src >> 4]; + *dst++ = hex[*src & 0x0f]; + } + } + *dst = '\0'; + + return hex_string; +} + +#define UCS4_MAX 0x10fffffUL + +static char * +make_hex_ucs4string(const unsigned long *string) { + static const char hex[] = {"0123456789abcdef"}; + char *hex_string; + const unsigned long *src; + char *dst; + + hex_string = (char *)malloc((idn_ucs4_strlen(string)) * 8 + 1); + if (hex_string == NULL) + return NULL; + + for (src = string, dst = hex_string; *src != '\0'; src++) { + if (0x20 <= *src && *src <= 0x7e && *src != '\\') { + *dst++ = *src; + } else if (*src <= UCS4_MAX) { + *dst++ = '\\'; + *dst++ = 'u'; + if (*src >= 0x100000) { + *dst++ = hex[(*src >> 20) & 0x0f]; + } + if (*src >= 0x10000) { + *dst++ = hex[(*src >> 16) & 0x0f]; + } + *dst++ = hex[(*src >> 12) & 0x0f]; + *dst++ = hex[(*src >> 8) & 0x0f]; + *dst++ = hex[(*src >> 4) & 0x0f]; + *dst++ = hex[*src & 0x0f]; + } else { + *dst++ = '\\'; + *dst++ = 'u'; + *dst++ = '?'; + *dst++ = '?'; + *dst++ = '?'; + *dst++ = '?'; + } + } + *dst = '\0'; + + return hex_string; +} + +static void +put_failure_message(idn_testsuite_t ctx, const char *msg, const char *file, + int lineno) { + idn_testsuite_msgproc_t proc; + char buffer[256]; + const char *title; + + proc = (ctx->msgproc == NULL) ? + idn_testsuite_msgtostderr : ctx->msgproc; + title = (ctx->current_testcase != NULL && + ctx->current_testcase->title != NULL) ? + ctx->current_testcase->title : "anonymous"; + + sprintf(buffer, "%.100s: In test `%.100s':", file, title); + (*proc)(buffer); + + sprintf(buffer, "%.100s:%d: failed (%.100s)", file, lineno, msg); + (*proc)(buffer); +} + + +static void +idn_testsuite_msgtostderr(const char *msg) { + fputs(msg, stderr); + fputc('\n', stderr); +} diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/testsuite.h b/contrib/idn/idnkit-1.0-src/lib/tests/testsuite.h new file mode 100644 index 0000000..a5e4774 --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/tests/testsuite.h @@ -0,0 +1,276 @@ +/* $Id: testsuite.h,v 1.1.1.1 2003/06/04 00:27:03 marka Exp $ */ +/* + * 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. + */ + +#ifndef IDN_TESTSUITE_H +#define IDN_TESTSUITE_H 1 + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Result codes for test case. + */ +typedef enum { + idn_teststatus_pass, + idn_teststatus_fail, + idn_teststatus_skip +} idn_teststatus_t; + +/* + * Testsuite manager type (opaque). + */ +typedef struct idn_testsuite *idn_testsuite_t; + +/* + * Testcase function type. + */ +typedef void (*idn_testsuite_testproc_t)(idn_testsuite_t ctx); + +/* + * Message handler type. + */ +typedef void (*idn_testsuite_msgproc_t)(const char *msg); + +/* + * Create a testsuite manager context. + * + * Create an empty context and store it in '*ctxp'. + * Return 1 on success. Return 0 if memory is exhausted. + */ +extern int +idn_testsuite_create(idn_testsuite_t *ctxp); + +/* + * Destory the testsuite manager context. + * + * Destroy the context created by idn_testsuite_create(), and release + * memory allocated to the context. + */ +extern void +idn_testsuite_destroy(idn_testsuite_t ctx); + +/* + * Add a test case to the `group' test group. + * Return 1 on success. Return 0 if memory is exhausted. + */ +extern int +idn_testsuite_addtestcase(idn_testsuite_t ctx, const char *title, + idn_testsuite_testproc_t proc); + +/* + * Return the number of test cases registered in the context. + */ +extern int +idn_testsuite_ntestcases(idn_testsuite_t ctx); + +/* + * Run test cases registered in the context. + */ +extern void +idn_testsuite_runall(idn_testsuite_t ctx); +extern void +idn_testsuite_run(idn_testsuite_t ctx, char *titles[]); + +/* + * Return the string description of `status'. + */ +extern const char * +idn_teststatus_tostring(idn_teststatus_t status); + +/* + * Return the number of passed/failed/skipped test cases. + */ +extern int +idn_testsuite_npassed(idn_testsuite_t ctx); +extern int +idn_testsuite_nfailed(idn_testsuite_t ctx); +extern int +idn_testsuite_nskipped(idn_testsuite_t ctx); + +/* + * Set/Get status of the test case running currently. + * + * These functions must be called by test case function. + */ +extern idn_teststatus_t +idn_testsuite_getstatus(idn_testsuite_t ctx); +extern void +idn_testsuite_setstatus(idn_testsuite_t ctx, idn_teststatus_t status); + +/* + * Enable/Disable verbose mode. + */ +extern void +idn_testsuite_setverbose(idn_testsuite_t ctx); +extern void +idn_testsuite_unsetverbose(idn_testsuite_t ctx); + +/* + * Generic assertion with message + */ +extern void +idn_testsuite_assert(idn_testsuite_t ctx, const char *msg, + const char *file, int lineno); + +#define ASSERT_THRU(msg) \ + idn_testsuite_assert(ctx__, msg, __FILE__, __LINE__) +#define ASSERT(msg) \ + do { \ + ASSERT_THRU(msg); \ + if (idn_testsuite_getstatus(ctx__) != idn_teststatus_pass) \ + goto EXIT__; \ + } while (0) + +/* + * Assertion function and macro to compare two `int' values. + * The assertion passes if `gotten' is equal to `expected'. + */ +extern void +idn_testsuite_assertint(idn_testsuite_t ctx, int gotten, int expected, + const char *file, int lineno); + +#define ASSERT_INT(gotten, expected) \ + do { \ + idn_testsuite_assertint(ctx__, gotten, expected, __FILE__, __LINE__); \ + if (idn_testsuite_getstatus(ctx__) != idn_teststatus_pass) \ + goto EXIT__; \ + } while (0) + +/* + * Assertion function and macro to compare two strings. + * The assertion passes if `gotten' is lexically equal to `expected'. + */ +extern void +idn_testsuite_assertstring(idn_testsuite_t ctx, const char *gotten, + const char *expected, const char *file, int lineno); + +#define ASSERT_STRING(gotten, expected) \ + do { \ + idn_testsuite_assertstring(ctx__, gotten, expected, __FILE__, __LINE__); \ + if (idn_testsuite_getstatus(ctx__) != idn_teststatus_pass) \ + goto EXIT__; \ + } while (0) + +/* + * Assertion function and macro to compare two pointers. + * The assertion passes if `gotten' is equal to `expected'. + */ +extern void +idn_testsuite_assertptr(idn_testsuite_t ctx, const void *gotten, + const void *expected, const char *file, int lineno); + +#define ASSERT_PTR(gotten, expected) \ + do { \ + idn_testsuite_assertptr(ctx__, gotten, expected, __FILE__, __LINE__); \ + if (idn_testsuite_getstatus(ctx__) != idn_teststatus_pass) \ + goto EXIT__; \ + } while (0) + +/* + * Assertion function and macro to compare two pointers. + * The assertion passes if `gotten' is NOT equal to `expected'. + */ +extern void +idn_testsuite_assertptrne(idn_testsuite_t ctx, + const void *gotten, const void *unexpected, + const char *file, int lineno); + +#define ASSERT_PTR_NE(gotten, unexpected) \ + do { \ + idn_testsuite_assertptrne(ctx__, gotten, unexpected, __FILE__, __LINE__); \ + if (idn_testsuite_getstatus(ctx__) != idn_teststatus_pass) \ + goto EXIT__; \ + } while (0) + +/* + * Assertion function and macro to compare two `idn_result_t' values. + * The assertion passes if `gotten' is equal to `expected'. + */ +extern void +idn_testsuite_assertresult(idn_testsuite_t ctx, + idn_result_t gotten, idn_result_t expected, + const char *file, int lineno); + +#define ASSERT_RESULT(gotten, expected) \ + do { \ + idn_testsuite_assertresult(ctx__, gotten, expected, __FILE__, __LINE__); \ + if (idn_testsuite_getstatus(ctx__) != idn_teststatus_pass) \ + goto EXIT__; \ + } while (0) + +/* + * Assertion function and macro to compare two UCS4 strings. + * The assertion passes if `gotten' is lexically equal to `expected'. + */ +extern void +idn_testsuite_assertucs4string(idn_testsuite_t ctx, + const unsigned long *gotten, + const unsigned long *expected, + const char *file, + int lineno); + +#define ASSERT_UCS4STRING_THRU(gotten, expected) \ + idn_testsuite_assertucs4string(ctx__, gotten, expected, __FILE__, __LINE__) +#define ASSERT_UCS4STRING(gotten, expected) \ + do { \ + ASSERT_UCS4STRING_THRU(gotten, expected); \ + if (idn_testsuite_getstatus(ctx__) != idn_teststatus_pass) \ + goto EXIT__; \ + } while (0) + +/* + * Shorthands. + */ +#define SKIP_TESTCASE \ + do { \ + idn_testsuite_setstatus(ctx__, idn_teststatus_skip); \ + goto EXIT__; \ + } while (0) + +#ifdef __cplusplus +} +#endif + +#endif /* IDN_TESTSUITE_H */ diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/testutil.c b/contrib/idn/idnkit-1.0-src/lib/tests/testutil.c new file mode 100644 index 0000000..c1872fd --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/tests/testutil.c @@ -0,0 +1,83 @@ +#ifndef lint +static char *rcsid = "$Id: testutil.c,v 1.1.1.1 2003/06/04 00:27:03 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 <stdarg.h> +#include "testutil.h" + +int +create_conf_file(const char *filename, unsigned int flags, ...) { + FILE *file; + va_list ap; + const char *arg; + int arg_index; + + file = fopen(filename, "w"); + if (file == NULL) { + fprintf(stderr, "failed to create config file `%s'\n", + filename); + return 0; + } + + arg_index = 0; + va_start(ap, flags); + for (;;) { + arg = va_arg(ap, const char *); + if (arg == NULL) + break; + if (arg_index++ > 0) + fputc('\n', file); + fputs(arg, file); + } + if (!(flags & CONF_NO_EOF_NEWLINE) && arg_index > 0) + fputc('\n', file); + + fclose(file); + return 1; +} diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/testutil.h b/contrib/idn/idnkit-1.0-src/lib/tests/testutil.h new file mode 100644 index 0000000..0e6405d --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/tests/testutil.h @@ -0,0 +1,71 @@ +/* $Id: testutil.h,v 1.1.1.1 2003/06/04 00:27:03 marka Exp $ */ +/* + * 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. + */ + +#ifndef IDN_TESTUTIL_H +#define IDN_TESTUTIL_H 1 + +/* + * Option flags for create_conf_file(). + * + * CONF_NO_EOF_NEWLINE -- Don't put newline character + * at the end of file. + */ +#define CONF_NO_EOF_NEWLINE 0x0001 + +/* + * Create a configuration file. + * + * Write strings specified as variable length arguments (`...') to + * `filename'. Note that the arguments must be terminated with `NULL'. + * + * In the created config file, each string in the variable length + * arguments becomes a line. In other words, newline characters are + * added automatically. + * + * This function returns 1 upon success, 0 otherwise. + */ +int +create_conf_file(const char *filename, unsigned int flags, ...); + +#endif /* IDN_TESTUTIL_H */ diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/testygen b/contrib/idn/idnkit-1.0-src/lib/tests/testygen new file mode 100755 index 0000000..5d2f9ca --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/tests/testygen @@ -0,0 +1,557 @@ +#! /usr/bin/perl -w +# +# 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. +# +use FileHandle; +use Getopt::Std; + +# +# Parsing status. +# +my $STATUS_HEADER = 0; +my $STATUS_HEADER_COMMENT = 1; +my $STATUS_SEPARATOR = 2; +my $STATUS_BODY = 3; +my $STATUS_GLOBAL = 4; +my $STATUS_GLOBAL_COMMENT = 5; +my $STATUS_PREAMBLE = 6; + +my $LINENO_MARK = "<LINENO>"; + +# +# Create a new testsuite context. +# +sub new_testsuite { + return {'ntests' => 0, + 'setups' => {}, + 'teardowns' => {}, + 'tests' => [], + 'titles' => [], + 'preambles' => ''}; +} + +# +# Read `$file' and put the result into `$testsutie'. +# +sub parse_file { + my ($testsuite, $file, $lineinfo) = @_; + my $parser = {'type' => '', + 'group' => '', + 'title' => '', + 'status' => $STATUS_PREAMBLE, + 'error' => '', + 'file' => $file, + 'lineno' => 0, + 'lineinfo' => $lineinfo}; + + my $handle = FileHandle->new($file, 'r'); + if (!defined($handle)) { + die "failed to open the file, $!: $file\n"; + } + + my ($result, $line); + for (;;) { + $line = $handle->getline(); + last if (!defined($line)); + + chomp($line); + $line .= "\n"; + $parser->{lineno}++; + $result = parse_line($testsuite, $parser, $line); + if (!$result) { + die sprintf("%s, at line %d\n", + $parser->{error}, $parser->{lineno}); + } + } + + if ($parser->{status} != $STATUS_GLOBAL) { + die "unexpected EOF, at line $.\n"; + } + + $handle->close(); +} + +sub parse_line { + my ($testsuite, $parser, $line) = @_; + my $result = 1; + + if ($parser->{status} == $STATUS_HEADER) { + if ($line =~ /^\/\/--/) { + $parser->{status} = $STATUS_HEADER_COMMENT; + } elsif ($line =~ /^\/\//) { + $result = parse_header($testsuite, $parser, $line); + } elsif ($line =~ /^\s*$/) { + $parser->{status} = $STATUS_SEPARATOR; + $result = parse_endheader($testsuite, $parser, $line); + } elsif ($line =~ /^\{\s*$/) { + $parser->{status} = $STATUS_BODY; + $result = parse_endheader($testsuite, $parser, $line) + && parse_startbody($testsuite, $parser, $line); + } else { + $parser->{error} = 'syntax error'; + $result = 0; + } + + } elsif ($parser->{status} == $STATUS_HEADER_COMMENT) { + if ($line =~ /^\/\//) { + # nothing to be done. + } elsif ($line =~ /^\s*$/) { + $parser->{status} = $STATUS_SEPARATOR; + $result = parse_endheader($testsuite, $parser, $line); + } elsif ($line =~ /^\{\s*$/) { + $parser->{status} = $STATUS_BODY; + $result = parse_endheader($testsuite, $parser, $line) + && parse_startbody($testsuite, $parser, $line); + } else { + $parser->{error} = 'syntax error'; + $result = 0; + } + + } elsif ($parser->{status} == $STATUS_SEPARATOR) { + if ($line =~ /^\s*$/) { + # nothing to be done. + } elsif ($line =~ /^\{\s*$/) { + $parser->{status} = $STATUS_BODY; + $result = parse_startbody($testsuite, $parser, $line); + } else { + $parser->{error} = 'syntax error'; + $result = 0; + } + + } elsif ($parser->{status} == $STATUS_BODY) { + if ($line =~ /^\}\s*$/) { + $parser->{status} = $STATUS_GLOBAL; + $result = parse_endbody($testsuite, $parser, $line); + } else { + $result = parse_body($testsuite, $parser, $line); + } + + } elsif ($parser->{status} == $STATUS_GLOBAL) { + if ($line =~ /^\/\/\#/) { + $parser->{status} = $STATUS_HEADER; + $result = parse_startheader($testsuite, $parser, $line); + } elsif ($line =~ /^\/\/--/) { + $parser->{status} = $STATUS_GLOBAL_COMMENT; + } elsif ($line =~ /^\s*$/) { + # nothing to be done. + } else { + $parser->{error} = 'syntax error'; + $result = 0; + } + + } elsif ($parser->{status} == $STATUS_GLOBAL_COMMENT) { + if ($line =~ /^\/\//) { + # nothing to be done. + } elsif ($line =~ /^\s*$/) { + $parser->{status} = $STATUS_GLOBAL; + } else { + $parser->{error} = 'syntax error'; + $result = 0; + } + + } elsif ($parser->{status} == $STATUS_PREAMBLE) { + if ($line =~ /^\/\/\#/) { + $parser->{status} = $STATUS_HEADER; + $result = parse_startheader($testsuite, $parser, $line); + } elsif ($line =~ /^\/\/--/) { + $parser->{status} = $STATUS_GLOBAL_COMMENT; + } else { + $result = parse_preamble($testsuite, $parser, $line); + } + + } else { + $parser->{error} = 'syntax error'; + $result = 0; + } + + return $result; +} + +sub parse_startheader { + my ($testsuite, $parser, $line) = @_; + + if ($line =~ /^\/\/\#\s*(SETUP|TEARDOWN|TESTCASE)\s*$/) { + $parser->{type} = $1; + $parser->{group} = ''; + $parser->{title} = ''; + } else { + $parser->{error} = 'invalid test-header format'; + return 0; + } + + + return 1; +} + +sub parse_header { + my ($testsuite, $parser, $line) = @_; + + my $field = $line; + $field =~ s/^\/\/\s*//; + $field =~ s/^(\S+):\s*/$1:/; + $field =~ s/\s+$//; + + return 1 if ($field eq ''); + + if ($field =~ /^group:(.*)$/) { + my $group = $1; + + if ($parser->{group} ne '') { + $parser->{error} = "group defined twice in a header"; + return 0; + } + if ($parser->{type} eq 'SETUP') { + if ($group !~ /^[0-9A-Za-z_\-]+$/) { + $parser->{error} = "invalid group name"; + return 0; + } + if (defined($testsuite->{setups}->{$group})) { + $parser->{error} = sprintf("SETUP \`%s' redefined", $group); + return 0; + } + } elsif ($parser->{type} eq 'TEARDOWN') { + if ($group !~ /^[0-9A-Za-z_\-]+$/) { + $parser->{error} = "invalid group name"; + return 0; + } + if (defined($testsuite->{teardowns}->{$group})) { + $parser->{error} = sprintf("TEARDOWN \`%s' redefined", $group); + return 0; + } + } else { + foreach my $i (split(/[ \t]+/, $group)) { + if ($i !~ /^[0-9A-Za-z_\-]+$/) { + $parser->{error} = "invalid group name \`$i'"; + return 0; + } + if (!defined($testsuite->{setups}->{$i}) + && !defined($testsuite->{teardowns}->{$i})) { + $parser->{error} = sprintf("group \'%s' not defined", $i); + return 0; + } + } + } + $parser->{group} = $group; + + } elsif ($field =~ /^title:(.*)$/) { + my $title = $1; + + if ($parser->{title} ne '') { + $parser->{error} = "title defined twice in a header"; + return 0; + } + if ($title =~ /[\x00-\x1f\x7f-\xff\"\\]/ || $title eq '') { + $parser->{error} = "invalid title"; + return 0; + } + if ($parser->{type} ne 'TESTCASE') { + $parser->{error} = sprintf("title for %s is not permitted", + $parser->{type}); + return 0; + } + $parser->{title} = $title; + + } else { + $parser->{error} = "invalid test-header field"; + return 0; + } + + return 1; +} + +sub parse_endheader { + my ($testsuite, $parser, $line) = @_; + + if ($parser->{type} ne 'TESTCASE' && $parser->{group} eq '') { + $parser->{error} = "missing \`group' in the header"; + return 0; + } + + if ($parser->{type} eq 'TESTCASE' && $parser->{title} eq '') { + $parser->{error} = "missing \`title' in the header"; + return 0; + } + + return 1; +} + +sub parse_startbody { + my ($testsuite, $parser, $line) = @_; + my $group = $parser->{group}; + + if ($parser->{type} eq 'SETUP') { + if ($parser->{lineinfo}) { + $testsuite->{setups}->{$group} = + generate_line_info($parser->{lineno} + 1, $parser->{file}); + } + } elsif ($parser->{type} eq 'TEARDOWN') { + if ($parser->{lineinfo}) { + $testsuite->{teardowns}->{$group} = + generate_line_info($parser->{lineno} + 1, $parser->{file}); + } + } else { + $testsuite->{ntests}++; + push(@{$testsuite->{tests}}, ''); + push(@{$testsuite->{titles}}, $parser->{title}); + + $testsuite->{tests}->[-1] .= "\n"; + $testsuite->{tests}->[-1] .= "$LINENO_MARK\n"; + $testsuite->{tests}->[-1] .= + sprintf("static void\ntestcase\%d(idn_testsuite_t ctx__) {\n", + $testsuite->{ntests}); + + my (@group_names) = split(/[ \t]+/, $group); + for (my $i = 0; $i < @group_names; $i++) { + if (defined($testsuite->{setups}->{$group_names[$i]})) { + $testsuite->{tests}->[-1] .= "\t\{\n"; + $testsuite->{tests}->[-1] .= "#undef EXIT__\n"; + $testsuite->{tests}->[-1] .= "#define EXIT__ exit${i}__\n"; + $testsuite->{tests}->[-1] .= + $testsuite->{setups}->{$group_names[$i]}; + } + } + $testsuite->{tests}->[-1] .= "$LINENO_MARK\n"; + $testsuite->{tests}->[-1] .= "\t\{\n"; + $testsuite->{tests}->[-1] .= "#undef EXIT__\n"; + $testsuite->{tests}->[-1] .= "#define EXIT__ exit__\n"; + if ($parser->{lineinfo}) { + $testsuite->{tests}->[-1] .= + generate_line_info($parser->{lineno} + 1, $parser->{file}); + } + } + + return 1; +} + +sub parse_body { + my ($testsuite, $parser, $line) = @_; + my ($group) = $parser->{group}; + + if ($parser->{type} eq 'SETUP') { + $testsuite->{setups}->{$group} .= $line; + } elsif ($parser->{type} eq 'TEARDOWN') { + $testsuite->{teardowns}->{$group} .= $line; + } else { + $testsuite->{tests}->[-1] .= $line; + } + + return 1; +} + +sub parse_endbody { + my ($testsuite, $parser, $line) = @_; + my ($group) = $parser->{group}; + + if ($parser->{type} eq 'TESTCASE') { + $testsuite->{tests}->[-1] .= "$LINENO_MARK\n"; + $testsuite->{tests}->[-1] .= "\t\}\n"; + $testsuite->{tests}->[-1] .= " exit__:\n"; + $testsuite->{tests}->[-1] .= "\t;\n"; + + my (@group_names) = split(/[ \t]+/, $group); + for (my $i = @group_names - 1; $i >= 0; $i--) { + $testsuite->{tests}->[-1] .= " exit${i}__:\n"; + $testsuite->{tests}->[-1] .= "\t;\n"; + if (defined($testsuite->{teardowns}->{$group_names[$i]})) { + $testsuite->{tests}->[-1] .= + $testsuite->{teardowns}->{$group_names[$i]}; + } + $testsuite->{tests}->[-1] .= "$LINENO_MARK\n"; + $testsuite->{tests}->[-1] .= "\t\}\n"; + } + + $testsuite->{tests}->[-1] .= "}\n"; + } + + return 1; +} + +sub parse_preamble { + my ($testsuite, $parser, $line) = @_; + + if ($parser->{lineinfo} && $parser->{lineno} == 1) { + $testsuite->{preambles} .= generate_line_info(1, $parser->{file}); + } + $testsuite->{preambles} .= $line; + return 1; +} + +sub generate_line_info { + my ($lineno, $file) = @_; + return "#line $lineno \"$file\"\n"; +} + +# +# Output `$testsuite' as source codes of C. +# +sub output_tests { + my ($testsuite, $file, $lineinfo) = @_; + + my $generator = { + 'file' => $file, + 'lineno' => 0 + }; + + my $handle = FileHandle->new($file, 'w'); + if (!defined($handle)) { + die "failed to open the file, $!: $file\n"; + } + + my $preamble_header = + "/* This file is automatically generated by testygen. */\n\n" + . "#define TESTYGEN 1\n" + . "\n"; + output_lines($preamble_header, $generator, $handle, $lineinfo); + + output_lines($testsuite->{preambles}, $generator, $handle, $lineinfo); + + my $preamble_footer = + "\n" + . "$LINENO_MARK\n" + . "#include \"testsuite.h\"\n" + . "\n"; + output_lines($preamble_footer, $generator, $handle, $lineinfo); + + + for (my $i = 0; $i < $testsuite->{ntests}; $i++) { + output_lines($testsuite->{tests}->[$i], $generator, $handle, + $lineinfo); + } + + my $main_header = + "\n" + . "$LINENO_MARK\n" + . "int\n" + . "main(int argc, char *argv[]) {\n" + . "\tidn_testsuite_t ctx;\n" + . "\tconst char *title;\n" + . "\n" + . "\tidn_testsuite_create(&ctx);\n"; + output_lines($main_header, $generator, $handle, $lineinfo); + + for (my $i = 0; $i < $testsuite->{ntests}; $i++) { + my $title = $testsuite->{titles}->[$i]; + my $proc = sprintf("testcase%d", $i + 1); + output_lines("\tidn_testsuite_addtestcase(ctx, \"$title\", $proc);\n", + $generator, $handle, $lineinfo); + } + + my $main_footer = + "\n" + . "\tif (argc > 1 && strcmp(argv[1], \"-v\") == 0) {\n" + . "\t idn_testsuite_setverbose(ctx);\n" + . "\t argc--;\n" + . "\t argv++;\n" + . "\t}\n" + . "\tif (argc == 1)\n" + . "\t idn_testsuite_runall(ctx);\n" + . "\telse\n" + . "\t idn_testsuite_run(ctx, argv + 1);\n" + . "\n" + . "\tprintf(\"passed=%d, failed=%d, total=%d\\n\",\n" + . "\t idn_testsuite_npassed(ctx),\n" + . "\t idn_testsuite_nfailed(ctx),\n" + . "\t idn_testsuite_ntestcases(ctx) - idn_testsuite_nskipped(ctx));\n" + . "\n" + . "\tidn_testsuite_destroy(ctx);\n" + . "\treturn (0);\n" + . "\}\n"; + output_lines($main_footer, $generator, $handle, $lineinfo); + + $handle->close(); +} + +sub output_lines { + my ($lines, $generator, $handle, $lineinfo) = @_; + my ($line); + + chomp($lines); + $lines .= "\n"; + + while ($lines ne '') { + $lines =~ s/^([^\n]*)\n//; + $line = $1; + $generator->{lineno}++; + if ($line eq $LINENO_MARK) { + if ($lineinfo) { + $handle->printf("#line %d \"%s\"\n", $generator->{lineno} + 1, + $generator->{file}); + } + } else { + $handle->print("$line\n"); + } + } +} + +sub output_usage { + warn "$0: [-o output-file] input-file\n"; +} + +# +# main. +# +my (%options); + +if (!getopts('Lo:', \%options)) { + output_usage; + exit(1); +} +if (@ARGV != 1) { + output_usage; + exit(1); +} + +my ($in_file) = $ARGV[0]; +my ($out_file); +if (!defined($options{o})) { + $out_file = $in_file; + $out_file .= '\.tsy' if ($out_file !~ /\.tsy$/); + $out_file =~ s/\.tsy$/\.c/; +} else { + $out_file = $options{o}; +} + +my $testsuite = new_testsuite(); +parse_file($testsuite, $in_file, !$options{L}); +output_tests($testsuite, $out_file, !$options{L}); + +exit(0); diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/ucs4.tsy b/contrib/idn/idnkit-1.0-src/lib/tests/ucs4.tsy new file mode 100644 index 0000000..205edae --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/tests/ucs4.tsy @@ -0,0 +1,257 @@ +#ifndef lint +static char *rcsid = "$Id: ucs4.tsy,v 1.1.1.1 2003/06/04 00:27:04 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/ucs4.h> +#include <idn/log.h> +#include "testutil.h" + +/* + * Sample UTF8 and UCS4 strings. + */ +static const char *utf8_string = + "\x7f" /* 0x0000007f */ + "\xdf\xbf" /* 0x000007ff */ + "\xef\xbf\xbf" /* 0x0000ffff */ + "\xf7\xbf\xbf\xbf" /* 0x001fffff */ + "\xfb\xbf\xbf\xbf\xbf" /* 0x03ffffff */ + "\xfd\xbf\xbf\xbf\xbf\xbf"; /* 0x7fffffff */ + +static const unsigned long ucs4_string[] = { + 0x0000007f, + 0x000007ff, + 0x0000ffff, + 0x001fffff, + 0x03ffffff, + 0x7fffffff, + 0x00000000 +}; + +//-------------------------------------------------------------------- +// Setups and Teardowns. +//-------------------------------------------------------------------- + +//# SETUP +// group: utf8-init +{ + unsigned long to[256]; + size_t tolen = 256; + idn_result_t r; +} + +//# SETUP +// group: ucs4-init +{ + char to[256]; + size_t tolen = 256; + idn_result_t r; +} + +//# 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); +} + +//-------------------------------------------------------------------- +// Testcases. +//-------------------------------------------------------------------- + +//# TESTCASE +// title: call utf8toucs4() +// group: utf8-init +{ + r = idn_ucs4_utf8toucs4(utf8_string, to, tolen); + ASSERT_RESULT(r, idn_success); + ASSERT_UCS4STRING(to, ucs4_string); +} + +//# TESTCASE +// title: call ucs4toutf8() +// group: ucs4-init +{ + r = idn_ucs4_ucs4toutf8(ucs4_string, to, tolen); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, utf8_string); +} + +//# TESTCASE +// title: call utf8toucs4() with empty from +// group: utf8-init +{ + static unsigned long empty_ucs4_string[] = {0}; + + r = idn_ucs4_utf8toucs4("", to, tolen); + ASSERT_RESULT(r, idn_success); + ASSERT_UCS4STRING(to, empty_ucs4_string); +} + +//# TESTCASE +// title: call ucs4toutf8() with empty from +// group: ucs4-init +{ + static unsigned long empty_ucs4_string[] = {0}; + + r = idn_ucs4_ucs4toutf8(empty_ucs4_string, to, tolen); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, ""); +} + +//# TESTCASE +// title: call utf8toucs4() with broken string +// group: utf8-init quiet +{ + /* "\xfe" as the 1st byte is out of range. */ + r = idn_ucs4_utf8toucs4("\xfe\xbf\xbf\xbf\xbf\xbf\xbf", to, tolen); + ASSERT_RESULT(r, idn_invalid_encoding); + + /* "\x7f" as the 2nd byte is out of range. */ + r = idn_ucs4_utf8toucs4("\xdf\x7f", to, tolen); + ASSERT_RESULT(r, idn_invalid_encoding); + + /* "\xc0" as the 2nd byte is out of range. */ + r = idn_ucs4_utf8toucs4("\xdf\xc0", to, tolen); + ASSERT_RESULT(r, idn_invalid_encoding); + + /* "\x7f" as the 3rd byte is out of range. */ + r = idn_ucs4_utf8toucs4("\xef\xbf\x7f", to, tolen); + ASSERT_RESULT(r, idn_invalid_encoding); + + /* "\xc0" as the 3rd byte is out of range. */ + r = idn_ucs4_utf8toucs4("\xef\xbf\xc0", to, tolen); + ASSERT_RESULT(r, idn_invalid_encoding); + + /* "\x7f" as the 4th byte is out of range. */ + r = idn_ucs4_utf8toucs4("\xf7\xbf\xbf\x7f", to, tolen); + ASSERT_RESULT(r, idn_invalid_encoding); + + /* "\xc0" as the 4th byte is out of range. */ + r = idn_ucs4_utf8toucs4("\xf7\xbf\xbf\xc0", to, tolen); + ASSERT_RESULT(r, idn_invalid_encoding); + + /* "\x7f" as the 5th byte is out of range. */ + r = idn_ucs4_utf8toucs4("\xfb\xbf\xbf\xbf\x7f", to, tolen); + ASSERT_RESULT(r, idn_invalid_encoding); + + /* "\xc0" as the 5th byte is out of range. */ + r = idn_ucs4_utf8toucs4("\xfb\xbf\xbf\xbf\xc0", to, tolen); + ASSERT_RESULT(r, idn_invalid_encoding); + + /* "\x7f" as the 6th byte is out of range. */ + r = idn_ucs4_utf8toucs4("\xfd\xbf\xbf\xbf\xbf\x7f", to, tolen); + ASSERT_RESULT(r, idn_invalid_encoding); + + /* "\xc0" as the 6th byte is out of range. */ + r = idn_ucs4_utf8toucs4("\xfd\xbf\xbf\xbf\xbf\xc0", to, tolen); + ASSERT_RESULT(r, idn_invalid_encoding); + + /* `from' contains surrogate pair */ + r = idn_ucs4_utf8toucs4("\xed\xa0\x80\xed\xbf\xbf", to, tolen); + ASSERT_RESULT(r, idn_invalid_encoding); +} + +//# TESTCASE +// title: call ucs4toutf8() with broken string +// group: ucs4-init quiet +{ + static unsigned long invalid_ucs4_string0[] = {0x80000000, 0}; + static unsigned long invalid_ucs4_string1[] = {0xd800, 0xdfff, 0}; + + /* 0x80000000 is out of range */ + r = idn_ucs4_ucs4toutf8(invalid_ucs4_string0, to, tolen); + ASSERT_RESULT(r, idn_invalid_encoding); + + /* `from' contains surrogate pair */ + r = idn_ucs4_ucs4toutf8(invalid_ucs4_string1, to, tolen); + ASSERT_RESULT(r, idn_invalid_encoding); +} + +//# TESTCASE +// title: buffer overrun test for utf8toucs4() +// group: utf8-init +{ + r = idn_ucs4_utf8toucs4(utf8_string, to, + idn_ucs4_strlen(ucs4_string) + 1); + ASSERT_RESULT(r, idn_success); + ASSERT_UCS4STRING(to, ucs4_string); + + r = idn_ucs4_utf8toucs4(utf8_string, to, + idn_ucs4_strlen(ucs4_string)); + ASSERT_RESULT(r, idn_buffer_overflow); + + r = idn_ucs4_utf8toucs4(utf8_string, to, 0); + ASSERT_RESULT(r, idn_buffer_overflow); +} + +//# TESTCASE +// title: buffer overrun test for ucs4toutf8() +// group: ucs4-init +{ + r = idn_ucs4_ucs4toutf8(ucs4_string, to, strlen(utf8_string) + 1); + ASSERT_RESULT(r, idn_success); + ASSERT_STRING(to, utf8_string); + + r = idn_ucs4_ucs4toutf8(ucs4_string, to, strlen(utf8_string)); + ASSERT_RESULT(r, idn_buffer_overflow); + + r = idn_ucs4_ucs4toutf8(ucs4_string, to, 0); + ASSERT_RESULT(r, idn_buffer_overflow); +} + diff --git a/contrib/idn/idnkit-1.0-src/lib/tests/utffilter b/contrib/idn/idnkit-1.0-src/lib/tests/utffilter new file mode 100755 index 0000000..cebd4dc --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/tests/utffilter @@ -0,0 +1,82 @@ +#! /usr/bin/perl -wp +# +# 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. +# + +sub to_utf8 ($) { + my ($utf32) = hex($_[0]); + my ($mask, $length); + + if ($utf32 < 0x80) { + $mask = 0; + $length = 1; + } elsif ($utf32 < 0x800) { + $mask = 0xc0; + $length = 2; + } elsif ($utf32 < 0x10000) { + $mask = 0xe0; + $length = 3; + } elsif ($utf32 < 0x200000) { + $mask = 0xf0; + $length = 4; + } elsif ($utf32 < 0x4000000) { + $mask = 0xf8; + $length = 5; + } elsif ($utf32 < 0x80000000) { + $mask = 0xfc; + $length = 6; + } else { + return ''; + } + + my ($result, $offset); + $offset = 6 * ($length - 1); + $result .= sprintf('\\x%02x', ($utf32 >> $offset) | $mask); + while ($offset > 0) { + $offset -= 6; + $result .= sprintf('\\x%02x', (($utf32 >> $offset) & 0x3f) | 0x80); + } + + return $result; +} + +s/<U\+([0-9A-Fa-f]+)>/&to_utf8($1)/eg; diff --git a/contrib/idn/idnkit-1.0-src/lib/ucs4.c b/contrib/idn/idnkit-1.0-src/lib/ucs4.c new file mode 100644 index 0000000..a5f4e8c --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/ucs4.c @@ -0,0 +1,461 @@ +#ifndef lint +static char *rcsid = "$Id: ucs4.c,v 1.1.1.1 2003/06/04 00:26:14 marka Exp $"; +#endif + +/* + * Copyright (c) 2001 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 <config.h> + +#include <stddef.h> +#include <stdlib.h> +#include <string.h> + +#include <idn/assert.h> +#include <idn/result.h> +#include <idn/logmacro.h> +#include <idn/util.h> +#include <idn/ucs4.h> +#include <idn/debug.h> + +/* + * Unicode surrogate pair. + */ +#define IS_SURROGATE_HIGH(v) (0xd800 <= (v) && (v) <= 0xdbff) +#define IS_SURROGATE_LOW(v) (0xdc00 <= (v) && (v) <= 0xdfff) +#define SURROGATE_HIGH(v) (SURROGATE_H_OFF + (((v) - 0x10000) >> 10)) +#define SURROGATE_LOW(v) (SURROGATE_L_OFF + ((v) & 0x3ff)) +#define SURROGATE_BASE 0x10000 +#define SURROGATE_H_OFF 0xd800 +#define SURROGATE_L_OFF 0xdc00 +#define COMBINE_SURROGATE(h, l) \ + (SURROGATE_BASE + (((h)-SURROGATE_H_OFF)<<10) + ((l)-SURROGATE_L_OFF)) + +/* + * ASCII ctype macros. + * Note that these macros evaluate the argument multiple times. Be careful. + */ +#define ASCII_TOUPPER(c) \ + (('a' <= (c) && (c) <= 'z') ? ((c) - 'a' + 'A') : (c)) +#define ASCII_TOLOWER(c) \ + (('A' <= (c) && (c) <= 'Z') ? ((c) - 'A' + 'a') : (c)) + +idn_result_t +idn_ucs4_ucs4toutf16(const unsigned long *ucs4, unsigned short *utf16, + size_t tolen) { + unsigned short *utf16p = utf16; + unsigned long v; + idn_result_t r; + + TRACE(("idn_ucs4_ucs4toutf16(ucs4=\"%s\", tolen=%d)\n", + idn__debug_ucs4xstring(ucs4, 50), (int)tolen)); + + while (*ucs4 != '\0') { + v = *ucs4++; + + if (IS_SURROGATE_LOW(v) || IS_SURROGATE_HIGH(v)) { + WARNING(("idn_ucs4_ucs4toutf16: UCS4 string contains " + "surrogate pair\n")); + r = idn_invalid_encoding; + goto ret; + } else if (v > 0xffff) { + /* Convert to surrogate pair */ + if (v >= 0x110000) { + r = idn_invalid_encoding; + goto ret; + } + if (tolen < 2) { + r = idn_buffer_overflow; + goto ret; + } + *utf16p++ = SURROGATE_HIGH(v); + *utf16p++ = SURROGATE_LOW(v); + tolen -= 2; + } else { + if (tolen < 1) { + r = idn_buffer_overflow; + goto ret; + } + *utf16p++ = v; + tolen--; + } + } + + if (tolen < 1) { + r = idn_buffer_overflow; + goto ret; + } + *utf16p = '\0'; + + r = idn_success; +ret: + if (r == idn_success) { + TRACE(("idn_ucs4_ucs4toutf16(): success (utf16=\"%s\")\n", + idn__debug_utf16xstring(utf16, 50))); + } else { + TRACE(("idn_ucs4_ucs4toutf16(): %s\n", + idn_result_tostring(r))); + } + return (r); +} + +idn_result_t +idn_ucs4_utf16toucs4(const unsigned short *utf16, unsigned long *ucs4, + size_t tolen) { + unsigned long *ucs4p = ucs4; + unsigned short v0, v1; + idn_result_t r; + + TRACE(("idn_ucs4_utf16toucs4(utf16=\"%s\", tolen=%d)\n", + idn__debug_utf16xstring(utf16, 50), (int)tolen)); + + while (*utf16 != '\0') { + v0 = *utf16; + + if (tolen < 1) { + r = idn_buffer_overflow; + goto ret; + } + + if (IS_SURROGATE_HIGH(v0)) { + v1 = *(utf16 + 1); + if (!IS_SURROGATE_LOW(v1)) { + WARNING(("idn_ucs4_utf16toucs4: " + "corrupted surrogate pair\n")); + r = idn_invalid_encoding; + goto ret; + } + *ucs4p++ = COMBINE_SURROGATE(v0, v1); + tolen--; + utf16 += 2; + + } else { + *ucs4p++ = v0; + tolen--; + utf16++; + + } + } + + if (tolen < 1) { + r = idn_buffer_overflow; + goto ret; + } + *ucs4p = '\0'; + + r = idn_success; +ret: + if (r == idn_success) { + TRACE(("idn_ucs4_utf16toucs4(): success (ucs4=\"%s\")\n", + idn__debug_ucs4xstring(ucs4, 50))); + } else { + TRACE(("idn_ucs4_utf16toucs4(): %s\n", + idn_result_tostring(r))); + } + return (r); +} + +idn_result_t +idn_ucs4_utf8toucs4(const char *utf8, unsigned long *ucs4, size_t tolen) { + const unsigned char *utf8p = (const unsigned char *)utf8; + unsigned long *ucs4p = ucs4; + unsigned long v, min; + unsigned char c; + int width; + int i; + idn_result_t r; + + TRACE(("idn_ucs4_utf8toucs4(utf8=\"%s\", tolen=%d)\n", + idn__debug_xstring(utf8, 50), (int)tolen)); + + while(*utf8p != '\0') { + c = *utf8p++; + if (c < 0x80) { + v = c; + min = 0; + width = 1; + } else if (c < 0xc0) { + WARNING(("idn_ucs4_utf8toucs4: invalid character\n")); + r = idn_invalid_encoding; + goto ret; + } else if (c < 0xe0) { + v = c & 0x1f; + min = 0x80; + width = 2; + } else if (c < 0xf0) { + v = c & 0x0f; + min = 0x800; + width = 3; + } else if (c < 0xf8) { + v = c & 0x07; + min = 0x10000; + width = 4; + } else if (c < 0xfc) { + v = c & 0x03; + min = 0x200000; + width = 5; + } else if (c < 0xfe) { + v = c & 0x01; + min = 0x4000000; + width = 6; + } else { + WARNING(("idn_ucs4_utf8toucs4: invalid character\n")); + r = idn_invalid_encoding; + goto ret; + } + + for (i = width - 1; i > 0; i--) { + c = *utf8p++; + if (c < 0x80 || 0xc0 <= c) { + WARNING(("idn_ucs4_utf8toucs4: " + "invalid character\n")); + r = idn_invalid_encoding; + goto ret; + } + v = (v << 6) | (c & 0x3f); + } + + if (v < min) { + WARNING(("idn_ucs4_utf8toucs4: invalid character\n")); + r = idn_invalid_encoding; + goto ret; + } + if (IS_SURROGATE_LOW(v) || IS_SURROGATE_HIGH(v)) { + WARNING(("idn_ucs4_utf8toucs4: UTF-8 string contains " + "surrogate pair\n")); + r = idn_invalid_encoding; + goto ret; + } + if (tolen < 1) { + r = idn_buffer_overflow; + goto ret; + } + tolen--; + *ucs4p++ = v; + } + + if (tolen < 1) { + r = idn_buffer_overflow; + goto ret; + } + *ucs4p = '\0'; + + r = idn_success; +ret: + if (r == idn_success) { + TRACE(("idn_ucs4_utf8toucs4(): success (ucs4=\"%s\")\n", + idn__debug_ucs4xstring(ucs4, 50))); + } else { + TRACE(("idn_ucs4_utf8toucs4(): %s\n", + idn_result_tostring(r))); + } + return (r); +} + +idn_result_t +idn_ucs4_ucs4toutf8(const unsigned long *ucs4, char *utf8, size_t tolen) { + unsigned char *utf8p = (unsigned char *)utf8; + unsigned long v; + int width; + int mask; + int offset; + idn_result_t r; + + TRACE(("idn_ucs4_ucs4toutf8(ucs4=\"%s\", tolen=%d)\n", + idn__debug_ucs4xstring(ucs4, 50), (int)tolen)); + + while (*ucs4 != '\0') { + v = *ucs4++; + if (IS_SURROGATE_LOW(v) || IS_SURROGATE_HIGH(v)) { + WARNING(("idn_ucs4_ucs4toutf8: UCS4 string contains " + "surrogate pair\n")); + r = idn_invalid_encoding; + goto ret; + } + if (v < 0x80) { + mask = 0; + width = 1; + } else if (v < 0x800) { + mask = 0xc0; + width = 2; + } else if (v < 0x10000) { + mask = 0xe0; + width = 3; + } else if (v < 0x200000) { + mask = 0xf0; + width = 4; + } else if (v < 0x4000000) { + mask = 0xf8; + width = 5; + } else if (v < 0x80000000) { + mask = 0xfc; + width = 6; + } else { + WARNING(("idn_ucs4_ucs4toutf8: invalid character\n")); + r = idn_invalid_encoding; + goto ret; + } + + if (tolen < width) { + r = idn_buffer_overflow; + goto ret; + } + offset = 6 * (width - 1); + *utf8p++ = (v >> offset) | mask; + mask = 0x80; + while (offset > 0) { + offset -= 6; + *utf8p++ = ((v >> offset) & 0x3f) | mask; + } + tolen -= width; + } + + if (tolen < 1) { + r = idn_buffer_overflow; + goto ret; + } + *utf8p = '\0'; + + r = idn_success; +ret: + if (r == idn_success) { + TRACE(("idn_ucs4_ucs4toutf8(): success (utf8=\"%s\")\n", + idn__debug_xstring(utf8, 50))); + } else { + TRACE(("idn_ucs4_ucs4toutf8(): %s\n", + idn_result_tostring(r))); + } + return (r); +} + +size_t +idn_ucs4_strlen(const unsigned long *ucs4) { + size_t len; + + for (len = 0; *ucs4 != '\0'; ucs4++, len++) + /* nothing to do */ ; + + return (len); +} + +unsigned long * +idn_ucs4_strcpy(unsigned long *to, const unsigned long *from) { + unsigned long *result = to; + + while (*from != '\0') + *to++ = *from++; + *to = '\0'; + + return (result); +} + +unsigned long * +idn_ucs4_strcat(unsigned long *to, const unsigned long *from) { + unsigned long *result = to; + + while (*to != '\0') + to++; + + while (*from != '\0') + *to++ = *from++; + *to = '\0'; + + return (result); +} + +int +idn_ucs4_strcmp(const unsigned long *str1, const unsigned long *str2) { + while (*str1 != '\0') { + if (*str1 > *str2) + return (1); + else if (*str1 < *str2) + return (-1); + str1++; + str2++; + } + + if (*str1 > *str2) + return (1); + else if (*str1 < *str2) + return (-1); + + return (0); +} + +int +idn_ucs4_strcasecmp(const unsigned long *str1, const unsigned long *str2) { + unsigned long c1, c2; + + while (*str1 != '\0') { + c1 = ASCII_TOLOWER(*str1); + c2 = ASCII_TOLOWER(*str2); + if (c1 > c2) + return (1); + else if (c1 < c2) + return (-1); + str1++; + str2++; + } + + c1 = ASCII_TOLOWER(*str1); + c2 = ASCII_TOLOWER(*str2); + if (c1 > c2) + return (1); + else if (c1 < c2) + return (-1); + + return (0); +} + + +unsigned long * +idn_ucs4_strdup(const unsigned long *str) { + size_t length = idn_ucs4_strlen(str); + unsigned long *dupstr; + + dupstr = (unsigned long *)malloc(sizeof(*str) * (length + 1)); + if (dupstr == NULL) + return NULL; + memcpy(dupstr, str, sizeof(*str) * (length + 1)); + + return dupstr; +} diff --git a/contrib/idn/idnkit-1.0-src/lib/ucsmap.c b/contrib/idn/idnkit-1.0-src/lib/ucsmap.c new file mode 100644 index 0000000..633456d --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/ucsmap.c @@ -0,0 +1,380 @@ +#ifndef lint +static char *rcsid = "$Id: ucsmap.c,v 1.1.1.1 2003/06/04 00:26:14 marka Exp $"; +#endif + +/* + * Copyright (c) 2001 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 <config.h> + +#include <stdlib.h> +#include <string.h> + +#include <idn/result.h> +#include <idn/assert.h> +#include <idn/log.h> +#include <idn/logmacro.h> +#include <idn/ucsmap.h> + +#define INIT_SIZE 50 +#define DEFAULT_BUF_SIZE 500 +#define UCSMAP_HASH_SIZE 103 +#define MAX_MAPLEN 0xffff + +/* + * This module implements UCS 1-to-N mapping. + * To speed up mapping table lookup, a combination of hash and + * binary search is used. + */ + +/* + * Mapping entry. + * Entries are sorted by its hash index and code point. + */ +typedef struct { + short hidx; /* hash index */ + unsigned short len; /* length of mapped sequence */ + unsigned long ucs; /* code point to be mapped */ + unsigned long *map; /* mapped sequence of code points */ +} ucsmap_entry_t; + +/* + * Hash table entry. + * Since the entries pointed by ucsmap_hash_t.entry are sorted, + * binary search can be used. + */ +typedef struct { + ucsmap_entry_t *entry; /* sorted by code point */ + int n; /* length of 'entry' */ +} ucsmap_hash_t; + +/* + * UCS character buffer for storing target character sequence. + */ +typedef struct ucsmap_buf { + struct ucsmap_buf *next; + unsigned long buf[1]; /* actually a variable length array */ +} ucsmap_buf_t; + +/* + * Mapping object. + */ +typedef struct idn_ucsmap { + ucsmap_hash_t hash[UCSMAP_HASH_SIZE]; + ucsmap_entry_t *entries; /* array of entries */ + size_t entry_size; /* allocated size */ + size_t nentries; /* # of entries in use */ + ucsmap_buf_t *mapdata; /* list of character buffers */ + size_t mapdata_size; /* allocated size of current buffer */ + size_t mapdata_used; /* # of chars in use */ + int fixed; /* already fixed? */ + int refcnt; /* reference count */ +} ucsmap_t; + +static int ucsmap_hash(unsigned long v); +static unsigned long *save_mapped_sequence(idn_ucsmap_t ctx, + unsigned long *map, + size_t maplen); +static void free_mapbuf(ucsmap_buf_t *buf); +static int comp_entry(const void *v1, const void *v2); + +idn_result_t +idn_ucsmap_create(idn_ucsmap_t *ctxp) { + idn_ucsmap_t ctx; + + assert(ctxp != NULL); + + TRACE(("idn_ucsmap_create()\n")); + + if ((ctx = malloc(sizeof(*ctx))) == NULL) { + WARNING(("idn_ucsmap_create: malloc failed\n")); + return (idn_nomemory); + } + + ctx->entry_size = 0; + ctx->nentries = 0; + ctx->entries = NULL; + ctx->mapdata = NULL; + ctx->mapdata_size = 0; + ctx->mapdata_used = 0; + ctx->fixed = 0; + ctx->refcnt = 1; + *ctxp = ctx; + return (idn_success); +} + +void +idn_ucsmap_destroy(idn_ucsmap_t ctx) { + assert(ctx != NULL && ctx->refcnt > 0); + + TRACE(("idn_ucsmap_destroy()\n")); + + if (--ctx->refcnt == 0) { + if (ctx->entries != NULL) + free(ctx->entries); + if (ctx->mapdata != NULL) + free_mapbuf(ctx->mapdata); + free(ctx); + } +} + +void +idn_ucsmap_incrref(idn_ucsmap_t ctx) { + assert(ctx != NULL && ctx->refcnt > 0); + + ctx->refcnt++; +} + +idn_result_t +idn_ucsmap_add(idn_ucsmap_t ctx, unsigned long ucs, + unsigned long *map, size_t maplen) +{ + ucsmap_entry_t *e; + ucsmap_entry_t *newbuf; + + assert(ctx != NULL && ctx->refcnt > 0); + + TRACE(("idn_ucsmap_add(ucs=U+%lX, maplen=%u)\n", ucs, maplen)); + + /* Make sure it is not fixed yet. */ + if (ctx->fixed) { + WARNING(("idn_ucsmap_add: attempt to add to fixed map\n")); + return (idn_failure); + } + + if (maplen > MAX_MAPLEN) { + WARNING(("idn_ucsmap_add: maplen too large (> %d)\n", + MAX_MAPLEN)); + return (idn_failure); + } + + /* Append an entry. */ + if (ctx->nentries >= ctx->entry_size) { + if (ctx->entry_size == 0) + ctx->entry_size = INIT_SIZE; + else + ctx->entry_size *= 2; + newbuf = realloc(ctx->entries, sizeof(*e) * ctx->entry_size); + if (newbuf == NULL) + return (idn_nomemory); + ctx->entries = newbuf; + } + e = &ctx->entries[ctx->nentries]; + e->hidx = ucsmap_hash(ucs); + e->len = maplen; + e->ucs = ucs; + if (maplen > 0) { + /* Save mapped sequence in the buffer. */ + e->map = save_mapped_sequence(ctx, map, maplen); + if (e->map == NULL) + return (idn_nomemory); + } else { + /* + * Zero 'maplen' is perfectly valid meaning one-to-zero + * mapping. + */ + e->map = NULL; + } + ctx->nentries++; + + return (idn_success); +} + +void +idn_ucsmap_fix(idn_ucsmap_t ctx) { + ucsmap_entry_t *e; + int last_hidx; + int i; + + assert(ctx != NULL && ctx->refcnt > 0); + + TRACE(("idn_ucsmap_fix()\n")); + + if (ctx->fixed) + return; + + ctx->fixed = 1; + + /* Initialize hash. */ + for (i = 0; i < UCSMAP_HASH_SIZE; i++) { + ctx->hash[i].entry = NULL; + ctx->hash[i].n = 0; + } + + if (ctx->nentries == 0) + return; + + /* Sort entries by the hash value and code point. */ + qsort(ctx->entries, ctx->nentries, sizeof(ucsmap_entry_t), comp_entry); + + /* + * Now the entries are sorted by their hash value, and + * sorted by its code point among the ones with the same hash value. + */ + + /* Build hash table. */ + last_hidx = -1; + for (i = 0, e = ctx->entries; i < ctx->nentries; i++, e++) { + if (e->hidx != last_hidx) { + ctx->hash[e->hidx].entry = e; + last_hidx = e->hidx; + } + ctx->hash[last_hidx].n++; + } +} + +idn_result_t +idn_ucsmap_map(idn_ucsmap_t ctx, unsigned long v, unsigned long *to, + size_t tolen, size_t *maplenp) { + int hash; + ucsmap_entry_t *e; + int n; + int hi, lo, mid; + + assert(ctx != NULL && ctx->refcnt > 0 && to != NULL && + maplenp != NULL); + + TRACE(("idn_ucsmap_map(v=U+%lX)\n", v)); + + if (!ctx->fixed) { + WARNING(("idn_ucsmap_map: not fixed yet\n")); + return (idn_failure); + } + + /* First, look up hash table. */ + hash = ucsmap_hash(v); + if ((n = ctx->hash[hash].n) == 0) + goto nomap; + + /* Then do binary search. */ + e = ctx->hash[hash].entry; + lo = 0; + hi = n - 1; + while (lo <= hi) { + mid = (lo + hi) / 2; + if (v < e[mid].ucs) + hi = mid - 1; + else if (v > e[mid].ucs) + lo = mid + 1; + else { + /* Found. */ + if (tolen < e[mid].len) + return (idn_buffer_overflow); + memcpy(to, e[mid].map, sizeof(*to) * e[mid].len); + *maplenp = e[mid].len; + return (idn_success); + } + } + + /* + * Not found. Put the original character to 'to' + * just for convenience. + */ + nomap: + if (tolen < 1) + return (idn_buffer_overflow); + *to = v; + *maplenp = 1; + return (idn_nomapping); +} + +static int +ucsmap_hash(unsigned long v) { + return (v % UCSMAP_HASH_SIZE); +} + +static unsigned long * +save_mapped_sequence(idn_ucsmap_t ctx, unsigned long *map, size_t maplen) { + ucsmap_buf_t *buf; + unsigned long *p; + size_t allocsize; + + /* + * If the current buffer (the first one in the ctx->mapdata list) + * has enough space, use it. Otherwise, allocate a new buffer and + * insert it at the beginning of the list. + */ + if (ctx->mapdata_used + maplen > ctx->mapdata_size) { + if (maplen > DEFAULT_BUF_SIZE) + allocsize = maplen * 2; + else + allocsize = DEFAULT_BUF_SIZE; + buf = malloc(sizeof(ucsmap_hash_t) + + sizeof(unsigned long) * allocsize); + if (buf == NULL) + return (NULL); + buf->next = ctx->mapdata; + ctx->mapdata = buf; + ctx->mapdata_size = allocsize; + ctx->mapdata_used = 0; + } + p = ctx->mapdata->buf + ctx->mapdata_used; + memcpy(p, map, sizeof(unsigned long) * maplen); + ctx->mapdata_used += maplen; + return (p); +} + +static void +free_mapbuf(ucsmap_buf_t *buf) { + while (buf != NULL) { + ucsmap_buf_t *next = buf->next; + free(buf); + buf = next; + } +} + +static int +comp_entry(const void *v1, const void *v2) { + const ucsmap_entry_t *e1 = v1; + const ucsmap_entry_t *e2 = v2; + + if (e1->hidx < e2->hidx) + return (-1); + else if (e1->hidx > e2->hidx) + return (1); + else if (e1->ucs < e2->ucs) + return (-1); + else if (e1->ucs > e2->ucs) + return (1); + else + return (0); +} diff --git a/contrib/idn/idnkit-1.0-src/lib/ucsset.c b/contrib/idn/idnkit-1.0-src/lib/ucsset.c new file mode 100644 index 0000000..76e2970 --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/ucsset.c @@ -0,0 +1,368 @@ +#ifndef lint +static char *rcsid = "$Id: ucsset.c,v 1.1.1.1 2003/06/04 00:26:15 marka Exp $"; +#endif + +/* + * Copyright (c) 2001 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 <config.h> + +#include <stdlib.h> +#include <stdio.h> +#include <string.h> + +#include <idn/result.h> +#include <idn/assert.h> +#include <idn/logmacro.h> +#include <idn/ucsset.h> + +#define UCS_MAX 0x80000000UL + +#define INIT_SIZE 50 + +/* + * Code point range. + * + * The set of code points is represented by an array of code point ranges. + * In the building phase, specified ranges by 'idn_ucsset_add' or + * 'idn_ucsset_addrange' are simply appended to the array. + * And 'idn_ucsset_fix' sorts the array by the code point value, and also + * merges any intersecting ranges. Since the array is sorted, a binary + * search can be used for looking up. + */ +typedef struct { + unsigned long from; + unsigned long to; +} range_t; + +/* + * Code point segment. + * + * To speed up searching further, the entire region of UCS-4 code points + * (U+0000 - U+7FFFFFFF) are divided into segments. For each segment, + * the first and last element of the range array corresponding to the + * segment are computed by 'idn_ucsset_fix'. This narrows down the + * (initial) search range. + */ +typedef struct { + int range_start; /* index of ucsset.ranges */ + int range_end; /* ditto */ +} segment_t; + +/* + * Code point to segment index conversion. + * + * Below is the function that maps a code point to the corresponding segment. + * The mapping is non-uniform, so that BMP, the following 16 planes that + * comprise Unicode code points together with BMP, and other planes + * have different granularity. + */ +#define SEG_THLD1 0x10000 /* BMP */ +#define SEG_THLD2 0x110000 /* Unicode (BMP+16planes) */ +#define SEG_SFT1 10 /* BMP: 1K code points/segment */ +#define SEG_SFT2 14 /* following 16 planes: 16K cp/seg */ +#define SEG_SFT3 24 /* rest: 16M cp/seg */ +#define SEG_OFF1 (SEG_THLD1 >> SEG_SFT1) +#define SEG_OFF2 (((SEG_THLD2 - SEG_THLD1) >> SEG_SFT2) + SEG_OFF1) +#define SEG_INDEX(v) \ + (((v) < SEG_THLD1) ? ((v) >> SEG_SFT1) : \ + ((v) < SEG_THLD2) ? ((((v) - SEG_THLD1) >> SEG_SFT2) + SEG_OFF1) : \ + ((((v) - SEG_THLD2) >> SEG_SFT3) + SEG_OFF2)) +#define SEG_LEN (SEG_INDEX(UCS_MAX - 1) + 1) + +/* + * Representation of set of UCS code points. + */ +typedef struct idn_ucsset { + segment_t segments[SEG_LEN]; + int fixed; + int size; /* allocated size of 'ranges' */ + int nranges; /* num of ranges */ + range_t *ranges; + int refcnt; /* reference count */ +} ucsset; + +static idn_result_t addrange(idn_ucsset_t ctx, unsigned long from, + unsigned long to, char *func_name); +static int comp_range(const void *v1, const void *v2); + +idn_result_t +idn_ucsset_create(idn_ucsset_t *ctx) { + idn_ucsset_t bm; + + assert(ctx != NULL); + + TRACE(("idn_ucsset_create()\n")); + + if ((bm = malloc(sizeof(ucsset))) == NULL) { + WARNING(("idn_ucsset_create: malloc failed\n")); + return idn_nomemory; + } + bm->size = bm->nranges = 0; + bm->ranges = NULL; + bm->fixed = 0; + bm->refcnt = 1; + *ctx = bm; + return (idn_success); +} + +void +idn_ucsset_destroy(idn_ucsset_t ctx) { + assert(ctx != NULL && ctx->refcnt > 0); + + TRACE(("idn_ucsset_destroy()\n")); + + if (--ctx->refcnt == 0) { + if (ctx->ranges != NULL) + free(ctx->ranges); + free(ctx); + } +} + +void +idn_ucsset_incrref(idn_ucsset_t ctx) { + assert(ctx != NULL && ctx->refcnt > 0); + + TRACE(("idn_ucsset_incrref()\n")); + + ctx->refcnt++; +} + +idn_result_t +idn_ucsset_add(idn_ucsset_t ctx, unsigned long v) { + assert(ctx != NULL && ctx->refcnt > 0); + + TRACE(("idn_ucsset_add(v=U+%lX)\n", v)); + + return (addrange(ctx, v, v, "idn_ucsset_add")); +} + +idn_result_t +idn_ucsset_addrange(idn_ucsset_t ctx, unsigned long from, + unsigned long to) +{ + assert(ctx != NULL && ctx->refcnt > 0); + + TRACE(("idn_ucsset_addrange(from=U+%lX, to=U+%lX)\n", + from, to)); + + return (addrange(ctx, from, to, "idn_ucsset_addrange")); +} + +void +idn_ucsset_fix(idn_ucsset_t ctx) { + int nranges; + range_t *ranges; + segment_t *segments; + int i, j; + + assert(ctx != NULL && ctx->refcnt > 0); + + TRACE(("idn_ucsset_fix()\n")); + + nranges = ctx->nranges; + ranges = ctx->ranges; + segments = ctx->segments; + + if (ctx->fixed) + return; + + ctx->fixed = 1; + + /* Initialize segment array */ + for (i = 0; i < SEG_LEN; i++) { + segments[i].range_start = -1; + segments[i].range_end = -1; + } + + /* If the set is empty, there's nothing to be done. */ + if (nranges == 0) + return; + + /* Sort ranges. */ + qsort(ranges, nranges, sizeof(range_t), comp_range); + + /* Merge overlapped/continuous ranges. */ + for (i = 0, j = 1; j < nranges; j++) { + if (ranges[i].to + 1 >= ranges[j].from) { + /* can be merged */ + if (ranges[i].to < ranges[j].to) { + ranges[i].to = ranges[j].to; + } + } else { + i++; + if (i < j) + ranges[i] = ranges[j]; + } + } + /* 'i' points the last range in the array. */ + ctx->nranges = nranges = ++i; + + /* Create segment array. */ + for (i = 0; i < nranges; i++) { + int fidx = SEG_INDEX(ranges[i].from); + int tidx = SEG_INDEX(ranges[i].to); + + for (j = fidx; j <= tidx; j++) { + if (segments[j].range_start < 0) + segments[j].range_start = i; + segments[j].range_end = i; + } + } + +#if 0 + /* + * Does the standard guarantee realloc() always succeeds + * when shrinking? + */ + /* Shrink malloc'ed space if possible. */ + ctx->ranges = realloc(ctx->ranges, ctx->nranges * sizeof(range_t)); +#endif +} + +idn_result_t +idn_ucsset_lookup(idn_ucsset_t ctx, unsigned long v, int *found) { + int idx; + segment_t *segments; + + assert(ctx != NULL && ctx->refcnt > 0 && found != NULL); + + TRACE(("idn_ucsset_lookup(v=U+%lX)\n", v)); + + /* Make sure it is fixed. */ + if (!ctx->fixed) { + WARNING(("idn_ucsset_lookup: not fixed yet\n")); + return (idn_failure); + } + + /* Check the given code point. */ + if (v >= UCS_MAX) + return (idn_invalid_codepoint); + + /* Get the segment 'v' belongs to. */ + segments = ctx->segments; + idx = SEG_INDEX(v); + + /* Do binary search. */ + *found = 0; + if (segments[idx].range_start >= 0) { + int lo = segments[idx].range_start; + int hi = segments[idx].range_end; + range_t *ranges = ctx->ranges; + + while (lo <= hi) { + int mid = (lo + hi) / 2; + if (v < ranges[mid].from) { + hi = mid - 1; + } else if (v > ranges[mid].to) { + lo = mid + 1; + } else { + *found = 1; + break; + } + } + } + return (idn_success); +} + +static idn_result_t +addrange(idn_ucsset_t ctx, unsigned long from, unsigned long to, + char *func_name) +{ + range_t *newbuf; + + /* Check the given code points. */ + if (from > UCS_MAX) { + WARNING(("%s: code point out of range (U+%lX)\n", + func_name, from)); + return (idn_invalid_codepoint); + } else if (to > UCS_MAX) { + WARNING(("%s: code point out of range (U+%lX)\n", + func_name, to)); + return (idn_invalid_codepoint); + } else if (from > to) { + WARNING(("%s: invalid range spec (U+%lX-U+%lX)\n", + func_name, from, to)); + return (idn_invalid_codepoint); + } + + /* Make sure it is not fixed yet. */ + if (ctx->fixed) { + WARNING(("%s: attempt to add to already fixed object\n", + func_name)); + return (idn_failure); + } + + /* Append the specified range to the 'ranges' array. */ + if (ctx->nranges >= ctx->size) { + /* Make it bigger. */ + if (ctx->size == 0) + ctx->size = INIT_SIZE; + else + ctx->size *= 2; + newbuf = realloc(ctx->ranges, ctx->size * sizeof(range_t)); + if (newbuf == NULL) + return (idn_nomemory); + ctx->ranges = newbuf; + } + ctx->ranges[ctx->nranges].from = from; + ctx->ranges[ctx->nranges].to = to; + ctx->nranges++; + + return (idn_success); +} + +static int +comp_range(const void *v1, const void *v2) { + /* + * Range comparation function suitable for qsort(). + */ + const range_t *r1 = v1; + const range_t *r2 = v2; + + if (r1->from < r2->from) + return (-1); + else if (r1->from > r2->from) + return (1); + else + return (0); +} diff --git a/contrib/idn/idnkit-1.0-src/lib/unicode.c b/contrib/idn/idnkit-1.0-src/lib/unicode.c new file mode 100644 index 0000000..b584b8f --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/unicode.c @@ -0,0 +1,309 @@ +#ifndef lint +static char *rcsid = "$Id: unicode.c,v 1.1.1.1 2003/06/04 00:26:16 marka Exp $"; +#endif + +/* + * Copyright (c) 2000,2001,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 <config.h> + +#include <stddef.h> +#include <stdlib.h> +#include <string.h> + +#include <idn/result.h> +#include <idn/logmacro.h> +#include <idn/assert.h> +#include <idn/unicode.h> + +#define UNICODE_CURRENT "3.2.0" + +#define UCS_MAX 0x10ffff +#define END_BIT 0x80000000 + +/* + * Some constants for Hangul decomposition/composition. + */ +#define SBase 0xac00 +#define LBase 0x1100 +#define VBase 0x1161 +#define TBase 0x11a7 +#define LCount 19 +#define VCount 21 +#define TCount 28 +#define SLast (SBase + LCount * VCount * TCount) + +/* + * Symbol composition macro. + */ +#define compose_sym(a, b) compose_symX(a, b) +#define compose_symX(a, b) a ## b + +struct composition { + unsigned long c2; /* 2nd character */ + unsigned long comp; /* composed character */ +}; + +#include "unicodedata_320.c" +#define VERSION v320 +#include "unicode_template.c" +#undef VERSION + +typedef int (*unicode_canonclassproc)(unsigned long v); +typedef int (*unicode_decomposeproc)(unsigned long c, + const unsigned long **seqp); +typedef int (*unicode_composeproc)(unsigned long c, + const struct composition **compp); + +static struct idn__unicode_ops { + char *version; + unicode_canonclassproc canonclass_proc; + unicode_decomposeproc decompose_proc; + unicode_composeproc compose_proc; +} unicode_versions[] = { +#define MAKE_UNICODE_HANDLE(version, suffix) \ + { version, \ + compose_sym(canonclass_, suffix), \ + compose_sym(decompose_, suffix), \ + compose_sym(compose_, suffix) } + MAKE_UNICODE_HANDLE("3.2.0", v320), + { NULL }, +#undef MAKE_UNICODE_HANDLE +}; + +idn_result_t +idn__unicode_create(const char *version, + idn__unicode_version_t *versionp) { + idn__unicode_version_t v; + + assert(versionp != NULL); + TRACE(("idn__unicode_create(version=%-.50s)\n", + version == NULL ? "<NULL>" : version)); + + if (version == NULL) + version = UNICODE_CURRENT; + + for (v = unicode_versions; v->version != NULL; v++) { + if (strcmp(v->version, version) == 0) { + *versionp = v; + return (idn_success); + } + } + return (idn_notfound); +} + +void +idn__unicode_destroy(idn__unicode_version_t version) { + assert(version != NULL); + TRACE(("idn__unicode_destroy()\n")); + /* Nothing to do */ +} + +int +idn__unicode_canonicalclass(idn__unicode_version_t version, unsigned long c) { + if (c > UCS_MAX) + return (0); + + return (*version->canonclass_proc)(c); +} + +idn_result_t +idn__unicode_decompose(idn__unicode_version_t version, + int compat, unsigned long *v, size_t vlen, + unsigned long c, int *decomp_lenp) { + unsigned long *vorg = v; + int seqidx; + const unsigned long *seq; + + assert(v != NULL && vlen >= 0 && decomp_lenp != NULL); + + if (c > UCS_MAX) + return (idn_notfound); + + /* + * First, check for Hangul. + */ + if (SBase <= c && c < SLast) { + int idx, t_offset, v_offset, l_offset; + + idx = c - SBase; + t_offset = idx % TCount; + idx /= TCount; + v_offset = idx % VCount; + l_offset = idx / VCount; + if ((t_offset == 0 && vlen < 2) || (t_offset > 0 && vlen < 3)) + return (idn_buffer_overflow); + *v++ = LBase + l_offset; + *v++ = VBase + v_offset; + if (t_offset > 0) + *v++ = TBase + t_offset; + *decomp_lenp = v - vorg; + return (idn_success); + } + + /* + * Look up decomposition table. If no decomposition is defined + * or if it is a compatibility decomosition when canonical + * decomposition requested, return 'idn_notfound'. + */ + seqidx = (*version->decompose_proc)(c, &seq); + if (seqidx == 0 || (compat == 0 && (seqidx & DECOMP_COMPAT) != 0)) + return (idn_notfound); + + /* + * Copy the decomposed sequence. The end of the sequence are + * marked with END_BIT. + */ + do { + unsigned long c; + int dlen; + idn_result_t r; + + c = *seq & ~END_BIT; + + /* Decompose recursively. */ + r = idn__unicode_decompose(version, compat, v, vlen, c, &dlen); + if (r == idn_success) { + v += dlen; + vlen -= dlen; + } else if (r == idn_notfound) { + if (vlen < 1) + return (idn_buffer_overflow); + *v++ = c; + vlen--; + } else { + return (r); + } + + } while ((*seq++ & END_BIT) == 0); + + *decomp_lenp = v - vorg; + + return (idn_success); +} + +int +idn__unicode_iscompositecandidate(idn__unicode_version_t version, + unsigned long c) { + const struct composition *dummy; + + if (c > UCS_MAX) + return (0); + + /* Check for Hangul */ + if ((LBase <= c && c < LBase + LCount) || (SBase <= c && c < SLast)) + return (1); + + /* + * Look up composition table. If there are no composition + * that begins with the given character, it is not a + * composition candidate. + */ + if ((*version->compose_proc)(c, &dummy) == 0) + return (0); + else + return (1); +} + +idn_result_t +idn__unicode_compose(idn__unicode_version_t version, unsigned long c1, + unsigned long c2, unsigned long *compp) { + int n; + int lo, hi; + const struct composition *cseq; + + assert(compp != NULL); + + if (c1 > UCS_MAX || c2 > UCS_MAX) + return (idn_notfound); + + /* + * Check for Hangul. + */ + if (LBase <= c1 && c1 < LBase + LCount && + VBase <= c2 && c2 < VBase + VCount) { + /* + * Hangul L and V. + */ + *compp = SBase + + ((c1 - LBase) * VCount + (c2 - VBase)) * TCount; + return (idn_success); + } else if (SBase <= c1 && c1 < SLast && + TBase <= c2 && c2 < TBase + TCount && + (c1 - SBase) % TCount == 0) { + /* + * Hangul LV and T. + */ + *compp = c1 + (c2 - TBase); + return (idn_success); + } + + /* + * Look up composition table. If the result is 0, no composition + * is defined. Otherwise, upper 16bits of the result contains + * the number of composition that begins with 'c1', and the lower + * 16bits is the offset in 'compose_seq'. + */ + if ((n = (*version->compose_proc)(c1, &cseq)) == 0) + return (idn_notfound); + + /* + * The composite sequences are sorted by the 2nd character 'c2'. + * So we can use binary search. + */ + lo = 0; + hi = n - 1; + while (lo <= hi) { + int mid = (lo + hi) / 2; + + if (cseq[mid].c2 < c2) { + lo = mid + 1; + } else if (cseq[mid].c2 > c2) { + hi = mid - 1; + } else { + *compp = cseq[mid].comp; + return (idn_success); + } + } + return (idn_notfound); +} diff --git a/contrib/idn/idnkit-1.0-src/lib/unicode_template.c b/contrib/idn/idnkit-1.0-src/lib/unicode_template.c new file mode 100644 index 0000000..12ce571 --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/unicode_template.c @@ -0,0 +1,101 @@ +/* $Id: unicode_template.c,v 1.1.1.1 2003/06/04 00:26:16 marka Exp $ */ + +/* + * Copyright (c) 2000,2001 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. + */ + +#ifndef UNICODE_TEMPLATE_INIT +#define UNICODE_TEMPLATE_INIT + +/* + * Macro for multi-level index table. + */ +#define LOOKUPTBL(vprefix, mprefix, v) \ + DMAP(vprefix)[\ + IMAP(vprefix)[\ + IMAP(vprefix)[IDX0(mprefix, v)] + IDX1(mprefix, v)\ + ]\ + ].tbl[IDX2(mprefix, v)] + +#define IDX0(mprefix, v) IDX_0(v, BITS1(mprefix), BITS2(mprefix)) +#define IDX1(mprefix, v) IDX_1(v, BITS1(mprefix), BITS2(mprefix)) +#define IDX2(mprefix, v) IDX_2(v, BITS1(mprefix), BITS2(mprefix)) + +#define IDX_0(v, bits1, bits2) ((v) >> ((bits1) + (bits2))) +#define IDX_1(v, bits1, bits2) (((v) >> (bits2)) & ((1 << (bits1)) - 1)) +#define IDX_2(v, bits1, bits2) ((v) & ((1 << (bits2)) - 1)) + +#define BITS1(mprefix) mprefix ## _BITS_1 +#define BITS2(mprefix) mprefix ## _BITS_2 + +#define IMAP(vprefix) concat4(VERSION, _, vprefix, _imap) +#define DMAP(vprefix) concat4(VERSION, _, vprefix, _table) +#define SEQ(vprefix) concat4(VERSION, _, vprefix, _seq) +#define concat4(a,b,c,d) concat4X(a, b, c, d) +#define concat4X(a,b,c,d) a ## b ## c ## d + +#endif /* UNICODE_TEMPLATE_INIT */ + +static int +compose_sym(canonclass_, VERSION) (unsigned long c) { + /* Look up canonicalclass table. */ + return (LOOKUPTBL(canon_class, CANON_CLASS, c)); +} + +static int +compose_sym(decompose_, VERSION) (unsigned long c, const unsigned long **seqp) +{ + /* Look up decomposition table. */ + int seqidx = LOOKUPTBL(decompose, DECOMP, c); + *seqp = SEQ(decompose) + (seqidx & ~DECOMP_COMPAT); + return (seqidx); +} + +static int +compose_sym(compose_, VERSION) (unsigned long c, + const struct composition **compp) +{ + /* Look up composition table. */ + int seqidx = LOOKUPTBL(compose, CANON_COMPOSE, c); + *compp = SEQ(compose) + (seqidx & 0xffff); + return (seqidx >> 16); +} diff --git a/contrib/idn/idnkit-1.0-src/lib/unicodedata_320.c b/contrib/idn/idnkit-1.0-src/lib/unicodedata_320.c new file mode 100644 index 0000000..64370e8 --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/unicodedata_320.c @@ -0,0 +1,7916 @@ +/* $Id: unicodedata_320.c,v 1.1.1.1 2003/06/04 00:26:43 marka Exp $ */ +/* $-Id: generate_normalize_data.pl,v 1.8 2001/10/31 08:51:30 m-kasahr Exp -$ */ +/* + * Do not edit this file! + * This file is generated from UnicodeData.txt, CompositionExclusions-1.txt, + * SpecialCasing.txt and CaseFolding.txt. + */ + + +/* + * Canonical Class + */ + +#define CANON_CLASS_BITS_0 9 +#define CANON_CLASS_BITS_1 7 +#define CANON_CLASS_BITS_2 5 + +static const unsigned short v320_canon_class_imap[] = { + 272, 400, 528, 656, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 912, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 1040, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 1, 2, 3, 4, 0, 0, 0, 0, + 0, 0, 0, 0, 5, 0, 0, 0, + 0, 0, 0, 0, 6, 7, 8, 0, + 0, 0, 9, 10, 0, 0, 11, 12, + 13, 14, 15, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 16, 17, 0, 0, 16, 18, 0, + 0, 16, 18, 0, 0, 16, 18, 0, + 0, 16, 18, 0, 0, 0, 18, 0, + 0, 0, 19, 0, 0, 0, 18, 0, + 0, 0, 18, 0, 0, 0, 20, 0, + 0, 21, 22, 0, 0, 23, 24, 0, + 25, 26, 0, 27, 28, 0, 29, 0, + 0, 30, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 31, 31, 0, 0, 0, 0, 32, 0, + 0, 0, 0, 0, 0, 33, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 34, 35, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 36, 0, 0, 37, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 38, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 39, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 40, 41, 42, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, +}; + +static const struct { + unsigned char tbl[32]; +} v320_canon_class_table[] = { + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, + 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 232, + 220, 220, 220, 220, 232, 216, 220, 220, 220, 220, + }}, + {{ + 220, 202, 202, 220, 220, 220, 220, 202, 202, 220, 220, + 220, 220, 220, 220, 220, 220, 220, 220, 220, 1, 1, + 1, 1, 1, 220, 220, 220, 220, 230, 230, 230, + }}, + {{ + 230, 230, 230, 230, 230, 240, 230, 220, 220, 220, 230, + 230, 230, 220, 220, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 234, 234, 233, 230, 230, 230, 230, 230, 230, 230, 230, + 230, 230, 230, 230, 230, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 230, 230, 230, 230, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 220, 230, 230, 230, 230, + 220, 230, 230, 230, 222, 220, 230, 230, 230, 230, + }}, + {{ + 230, 230, 0, 220, 220, 220, 220, 220, 230, 230, 220, + 230, 230, 222, 228, 230, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 0, 20, 21, 22, 0, 23, + }}, + {{ + 0, 24, 25, 0, 230, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 27, 28, 29, 30, 31, 32, 33, 34, 230, 230, 220, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 35, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 230, 230, 230, 230, 230, 230, 230, 0, 0, 230, + }}, + {{ + 230, 230, 230, 220, 230, 0, 0, 230, 230, 0, 220, + 230, 230, 220, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 36, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 230, 220, 230, 230, 220, 230, + 230, 220, 220, 220, 230, 220, 220, 230, 220, 230, + }}, + {{ + 230, 230, 220, 230, 220, 230, 220, 230, 220, 230, 230, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 9, 0, 0, 0, 230, 220, 230, 230, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 84, + 91, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 103, 103, 9, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 107, 107, 107, + 107, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 118, 118, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 122, 122, 122, + 122, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 220, 220, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 220, + 0, 220, 0, 216, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 129, 130, 0, 132, 0, + 0, 0, 0, 0, 130, 130, 130, 130, 0, 0, + }}, + {{ + 130, 0, 230, 230, 9, 0, 230, 230, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 220, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 7, 0, 9, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 228, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 230, 230, 1, 1, 230, 230, + 230, 230, 1, 1, 1, 230, 230, 0, 0, 0, + }}, + {{ + 0, 230, 0, 0, 0, 1, 1, 230, 220, 230, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 218, + 228, 232, 222, 224, 224, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 8, 8, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 26, 0, + }}, + {{ + 230, 230, 230, 230, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 216, 216, 1, 1, 1, 0, + 0, 0, 226, 216, 216, 216, 216, 216, 0, 0, 0, + 0, 0, 0, 0, 0, 220, 220, 220, 220, 220, + }}, + {{ + 220, 220, 220, 0, 0, 230, 230, 230, 230, 230, 220, + 220, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 230, + 230, 230, 230, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, +}; + +/* + * Canonical Composition + */ + +#define CANON_COMPOSE_BITS_0 9 +#define CANON_COMPOSE_BITS_1 7 +#define CANON_COMPOSE_BITS_2 5 + +static const unsigned short v320_compose_imap[] = { + 272, 400, 528, 656, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 0, 1, 2, 3, 0, 4, 5, 6, + 7, 0, 8, 9, 0, 10, 0, 11, + 0, 12, 0, 0, 13, 0, 0, 0, + 0, 0, 0, 0, 14, 15, 16, 0, + 17, 18, 19, 20, 0, 0, 21, 22, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 23, 24, 0, 0, 0, 25, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 26, 0, 0, 0, 0, 27, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 28, 0, 29, 0, 30, 0, + 0, 0, 31, 0, 0, 32, 33, 0, + 0, 0, 34, 0, 0, 0, 35, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 36, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 37, 38, 39, 0, 40, 41, 0, + 42, 43, 44, 45, 0, 46, 47, 48, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 49, 0, 50, 0, + 51, 52, 53, 54, 55, 56, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 57, 58, 59, 60, 61, 62, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, +}; + +static const struct { + unsigned long tbl[32]; +} v320_compose_table[] = { + {{ + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 65537, 65538, 65539, 0, + }}, + {{ + 0, 1048580, 196628, 327703, 393244, 1114146, 65587, + 458804, 458811, 983106, 65617, 327762, 393303, 196701, + 589920, 1048681, 131193, 0, 524411, 458883, 458890, + 1245329, 131236, 393382, 131244, 589998, 393399, 0, + 0, 0, 0, 0, + }}, + {{ + 0, 1048765, 196813, 327888, 393429, 1114331, 65772, + 458989, 524532, 917756, 131338, 327948, 393489, 196887, + 590106, 1048867, 131379, 0, 524597, 459069, 524612, + 1245516, 131423, 459105, 131432, 655722, 393588, 0, + 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, + 0, 196986, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, + }}, + {{ + 0, 0, 262525, 0, 65921, 65922, 131459, + 65925, 0, 0, 262534, 0, 0, 0, + 0, 65930, 0, 0, 0, 0, 262539, + 197007, 65938, 0, 65939, 0, 0, 0, + 262548, 0, 0, 0, + }}, + {{ + 0, 0, 262552, 0, 65948, 65949, 131486, + 65952, 0, 0, 262561, 0, 0, 0, + 0, 65957, 0, 0, 0, 0, 262566, + 197034, 65965, 0, 65966, 0, 0, 0, + 262575, 0, 0, 0, + }}, + {{ + 0, 0, 262579, 262583, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 131515, 131517, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 131519, 131521, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 65987, 65988, + 0, 0, 0, 0, + }}, + {{ + 65989, 65990, 0, 0, 0, 0, 0, + 0, 65991, 65992, 65993, 65994, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 65995, + }}, + {{ + 328140, 328145, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 328150, 328155, 0, 0, 0, 0, + 0, 0, 66016, 0, 0, 0, 0, + 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 66017, 66018, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 66019, + 66020, 66021, 66022, 0, 0, 0, 0, + 66023, 66024, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 66025, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 459242, 0, 0, 0, + 262641, 0, 328181, 0, 459258, 0, 0, + 0, 0, 0, 262657, + }}, + {{ + 0, 66053, 0, 0, 0, 393734, 0, + 0, 0, 328204, 0, 0, 66065, 0, + 66066, 0, 0, 524819, 0, 0, 0, + 262683, 0, 393759, 0, 524837, 0, 0, + 0, 0, 0, 262701, + }}, + {{ + 0, 131633, 0, 0, 0, 524851, 0, + 0, 0, 393787, 197185, 197188, 0, 0, + 66119, 0, 0, 0, 131656, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 66122, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 131659, 0, 0, 66125, 0, + 197198, 131665, 66131, 262740, 0, 66136, 0, + 0, 0, 66137, 0, + }}, + {{ + 0, 0, 0, 262746, 0, 0, 0, + 66142, 0, 0, 0, 66143, 0, 66144, + 0, 0, 131681, 0, 0, 66147, 0, + 197220, 131687, 66153, 262762, 0, 66158, 0, + 0, 0, 66159, 0, + }}, + {{ + 0, 0, 0, 262768, 0, 0, 0, + 66164, 0, 0, 0, 66165, 0, 66166, + 0, 0, 0, 0, 0, 0, 0, + 0, 66167, 0, 0, 0, 0, 0, + 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 66168, + 66169, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 66170, 66171, 0, 0, + 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, + 0, 66172, 66173, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, + 197246, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, + 0, 66177, 0, 66178, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, + }}, + {{ + 0, 66179, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 66180, 0, 0, + 66181, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, + 0, 66182, 0, 0, 0, 0, 0, + 0, 0, 66183, 0, 0, 66184, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, + 131721, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, + 197259, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 66190, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 131727, + 66193, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 66194, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 66195, + }}, + {{ + 0, 0, 0, 0, 0, 0, 197268, + 0, 0, 0, 66199, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 131736, + 66202, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 197275, 0, 0, + 66206, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 66207, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 66208, 66209, 0, 0, 0, 0, + 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 66210, 66211, + 0, 0, 0, 0, + }}, + {{ + 0, 0, 66212, 66213, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, + }}, + {{ + 131750, 131752, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 66218, 66219, 0, 0, + 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 66220, 66221, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, + }}, + {{ + 262830, 262834, 66230, 66231, 66232, 66233, 66234, + 66235, 262844, 262848, 66244, 66245, 66246, 66247, + 66248, 66249, 131786, 131788, 0, 0, 0, + 0, 0, 0, 131790, 131792, 0, 0, + 0, 0, 0, 0, + }}, + {{ + 262866, 262870, 66266, 66267, 66268, 66269, 66270, + 66271, 262880, 262884, 66280, 66281, 66282, 66283, + 66284, 66285, 197358, 197361, 0, 0, 0, + 0, 0, 0, 197364, 197367, 0, 0, + 0, 0, 0, 0, + }}, + {{ + 131834, 131836, 0, 0, 0, 0, 0, + 0, 131838, 131840, 0, 0, 0, 0, + 0, 0, 197378, 197381, 0, 0, 0, + 0, 0, 0, 0, 197384, 0, 0, + 0, 0, 0, 0, + }}, + {{ + 262923, 262927, 66323, 66324, 66325, 66326, 66327, + 66328, 262937, 262941, 66337, 66338, 66339, 66340, + 66341, 66342, 66343, 0, 0, 0, 66344, + 0, 0, 0, 0, 0, 0, 0, + 66345, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 66346, 0, 0, 0, 0, 0, + 0, 0, 0, 197419, + }}, + {{ + 0, 0, 0, 0, 0, 0, 66350, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 66351, 0, 0, 0, 0, 0, + 0, 0, 197424, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 66355, 0, 66356, 0, 66357, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 66358, 0, 66359, 0, 66360, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 66361, 0, 0, 0, + 0, 66362, 0, 0, 66363, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 66364, 0, 66365, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 66366, 0, 0, 0, + }}, + {{ + 0, 0, 0, 66367, 0, 66368, 0, + 0, 66369, 0, 0, 0, 0, 66370, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, + }}, + {{ + 0, 66371, 0, 0, 66372, 66373, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 66374, 66375, 0, + 0, 66376, 66377, 0, 0, 66378, 66379, + 66380, 66381, 0, 0, + }}, + {{ + 0, 0, 66382, 66383, 0, 0, 66384, + 66385, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 66386, 66387, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, + }}, + {{ + 0, 0, 66388, 0, 0, 0, 0, + 0, 66389, 66390, 0, 66391, 0, 0, + 0, 0, 0, 0, 66392, 66393, 66394, + 66395, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 66396, + 0, 0, 0, 0, 66397, 0, 66398, + 0, 66399, 0, 66400, 0, 66401, 0, + 66402, 0, 66403, 0, 66404, 0, 66405, + 0, 66406, 0, 66407, + }}, + {{ + 0, 66408, 0, 0, 66409, 0, 66410, + 0, 66411, 0, 0, 0, 0, 0, + 0, 131948, 0, 0, 131950, 0, 0, + 131952, 0, 0, 131954, 0, 0, 131956, + 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 66422, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 66423, + 0, 0, 0, 0, 66424, 0, 66425, + 0, 66426, 0, 66427, 0, 66428, 0, + 66429, 0, 66430, 0, 66431, 0, 66432, + 0, 66433, 0, 66434, + }}, + {{ + 0, 66435, 0, 0, 66436, 0, 66437, + 0, 66438, 0, 0, 0, 0, 0, + 0, 131975, 0, 0, 131977, 0, 0, + 131979, 0, 0, 131981, 0, 0, 131983, + 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 66449, 66450, 66451, 66452, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + 0, 66453, 0, 0, + }}, +}; + +static const struct composition v320_compose_seq[] = { + { 0x00000000, 0x00000000 }, { 0x00000338, 0x0000226e }, + { 0x00000338, 0x00002260 }, { 0x00000338, 0x0000226f }, + { 0x00000300, 0x000000c0 }, { 0x00000301, 0x000000c1 }, + { 0x00000302, 0x000000c2 }, { 0x00000303, 0x000000c3 }, + { 0x00000304, 0x00000100 }, { 0x00000306, 0x00000102 }, + { 0x00000307, 0x00000226 }, { 0x00000308, 0x000000c4 }, + { 0x00000309, 0x00001ea2 }, { 0x0000030a, 0x000000c5 }, + { 0x0000030c, 0x000001cd }, { 0x0000030f, 0x00000200 }, + { 0x00000311, 0x00000202 }, { 0x00000323, 0x00001ea0 }, + { 0x00000325, 0x00001e00 }, { 0x00000328, 0x00000104 }, + { 0x00000307, 0x00001e02 }, { 0x00000323, 0x00001e04 }, + { 0x00000331, 0x00001e06 }, { 0x00000301, 0x00000106 }, + { 0x00000302, 0x00000108 }, { 0x00000307, 0x0000010a }, + { 0x0000030c, 0x0000010c }, { 0x00000327, 0x000000c7 }, + { 0x00000307, 0x00001e0a }, { 0x0000030c, 0x0000010e }, + { 0x00000323, 0x00001e0c }, { 0x00000327, 0x00001e10 }, + { 0x0000032d, 0x00001e12 }, { 0x00000331, 0x00001e0e }, + { 0x00000300, 0x000000c8 }, { 0x00000301, 0x000000c9 }, + { 0x00000302, 0x000000ca }, { 0x00000303, 0x00001ebc }, + { 0x00000304, 0x00000112 }, { 0x00000306, 0x00000114 }, + { 0x00000307, 0x00000116 }, { 0x00000308, 0x000000cb }, + { 0x00000309, 0x00001eba }, { 0x0000030c, 0x0000011a }, + { 0x0000030f, 0x00000204 }, { 0x00000311, 0x00000206 }, + { 0x00000323, 0x00001eb8 }, { 0x00000327, 0x00000228 }, + { 0x00000328, 0x00000118 }, { 0x0000032d, 0x00001e18 }, + { 0x00000330, 0x00001e1a }, { 0x00000307, 0x00001e1e }, + { 0x00000301, 0x000001f4 }, { 0x00000302, 0x0000011c }, + { 0x00000304, 0x00001e20 }, { 0x00000306, 0x0000011e }, + { 0x00000307, 0x00000120 }, { 0x0000030c, 0x000001e6 }, + { 0x00000327, 0x00000122 }, { 0x00000302, 0x00000124 }, + { 0x00000307, 0x00001e22 }, { 0x00000308, 0x00001e26 }, + { 0x0000030c, 0x0000021e }, { 0x00000323, 0x00001e24 }, + { 0x00000327, 0x00001e28 }, { 0x0000032e, 0x00001e2a }, + { 0x00000300, 0x000000cc }, { 0x00000301, 0x000000cd }, + { 0x00000302, 0x000000ce }, { 0x00000303, 0x00000128 }, + { 0x00000304, 0x0000012a }, { 0x00000306, 0x0000012c }, + { 0x00000307, 0x00000130 }, { 0x00000308, 0x000000cf }, + { 0x00000309, 0x00001ec8 }, { 0x0000030c, 0x000001cf }, + { 0x0000030f, 0x00000208 }, { 0x00000311, 0x0000020a }, + { 0x00000323, 0x00001eca }, { 0x00000328, 0x0000012e }, + { 0x00000330, 0x00001e2c }, { 0x00000302, 0x00000134 }, + { 0x00000301, 0x00001e30 }, { 0x0000030c, 0x000001e8 }, + { 0x00000323, 0x00001e32 }, { 0x00000327, 0x00000136 }, + { 0x00000331, 0x00001e34 }, { 0x00000301, 0x00000139 }, + { 0x0000030c, 0x0000013d }, { 0x00000323, 0x00001e36 }, + { 0x00000327, 0x0000013b }, { 0x0000032d, 0x00001e3c }, + { 0x00000331, 0x00001e3a }, { 0x00000301, 0x00001e3e }, + { 0x00000307, 0x00001e40 }, { 0x00000323, 0x00001e42 }, + { 0x00000300, 0x000001f8 }, { 0x00000301, 0x00000143 }, + { 0x00000303, 0x000000d1 }, { 0x00000307, 0x00001e44 }, + { 0x0000030c, 0x00000147 }, { 0x00000323, 0x00001e46 }, + { 0x00000327, 0x00000145 }, { 0x0000032d, 0x00001e4a }, + { 0x00000331, 0x00001e48 }, { 0x00000300, 0x000000d2 }, + { 0x00000301, 0x000000d3 }, { 0x00000302, 0x000000d4 }, + { 0x00000303, 0x000000d5 }, { 0x00000304, 0x0000014c }, + { 0x00000306, 0x0000014e }, { 0x00000307, 0x0000022e }, + { 0x00000308, 0x000000d6 }, { 0x00000309, 0x00001ece }, + { 0x0000030b, 0x00000150 }, { 0x0000030c, 0x000001d1 }, + { 0x0000030f, 0x0000020c }, { 0x00000311, 0x0000020e }, + { 0x0000031b, 0x000001a0 }, { 0x00000323, 0x00001ecc }, + { 0x00000328, 0x000001ea }, { 0x00000301, 0x00001e54 }, + { 0x00000307, 0x00001e56 }, { 0x00000301, 0x00000154 }, + { 0x00000307, 0x00001e58 }, { 0x0000030c, 0x00000158 }, + { 0x0000030f, 0x00000210 }, { 0x00000311, 0x00000212 }, + { 0x00000323, 0x00001e5a }, { 0x00000327, 0x00000156 }, + { 0x00000331, 0x00001e5e }, { 0x00000301, 0x0000015a }, + { 0x00000302, 0x0000015c }, { 0x00000307, 0x00001e60 }, + { 0x0000030c, 0x00000160 }, { 0x00000323, 0x00001e62 }, + { 0x00000326, 0x00000218 }, { 0x00000327, 0x0000015e }, + { 0x00000307, 0x00001e6a }, { 0x0000030c, 0x00000164 }, + { 0x00000323, 0x00001e6c }, { 0x00000326, 0x0000021a }, + { 0x00000327, 0x00000162 }, { 0x0000032d, 0x00001e70 }, + { 0x00000331, 0x00001e6e }, { 0x00000300, 0x000000d9 }, + { 0x00000301, 0x000000da }, { 0x00000302, 0x000000db }, + { 0x00000303, 0x00000168 }, { 0x00000304, 0x0000016a }, + { 0x00000306, 0x0000016c }, { 0x00000308, 0x000000dc }, + { 0x00000309, 0x00001ee6 }, { 0x0000030a, 0x0000016e }, + { 0x0000030b, 0x00000170 }, { 0x0000030c, 0x000001d3 }, + { 0x0000030f, 0x00000214 }, { 0x00000311, 0x00000216 }, + { 0x0000031b, 0x000001af }, { 0x00000323, 0x00001ee4 }, + { 0x00000324, 0x00001e72 }, { 0x00000328, 0x00000172 }, + { 0x0000032d, 0x00001e76 }, { 0x00000330, 0x00001e74 }, + { 0x00000303, 0x00001e7c }, { 0x00000323, 0x00001e7e }, + { 0x00000300, 0x00001e80 }, { 0x00000301, 0x00001e82 }, + { 0x00000302, 0x00000174 }, { 0x00000307, 0x00001e86 }, + { 0x00000308, 0x00001e84 }, { 0x00000323, 0x00001e88 }, + { 0x00000307, 0x00001e8a }, { 0x00000308, 0x00001e8c }, + { 0x00000300, 0x00001ef2 }, { 0x00000301, 0x000000dd }, + { 0x00000302, 0x00000176 }, { 0x00000303, 0x00001ef8 }, + { 0x00000304, 0x00000232 }, { 0x00000307, 0x00001e8e }, + { 0x00000308, 0x00000178 }, { 0x00000309, 0x00001ef6 }, + { 0x00000323, 0x00001ef4 }, { 0x00000301, 0x00000179 }, + { 0x00000302, 0x00001e90 }, { 0x00000307, 0x0000017b }, + { 0x0000030c, 0x0000017d }, { 0x00000323, 0x00001e92 }, + { 0x00000331, 0x00001e94 }, { 0x00000300, 0x000000e0 }, + { 0x00000301, 0x000000e1 }, { 0x00000302, 0x000000e2 }, + { 0x00000303, 0x000000e3 }, { 0x00000304, 0x00000101 }, + { 0x00000306, 0x00000103 }, { 0x00000307, 0x00000227 }, + { 0x00000308, 0x000000e4 }, { 0x00000309, 0x00001ea3 }, + { 0x0000030a, 0x000000e5 }, { 0x0000030c, 0x000001ce }, + { 0x0000030f, 0x00000201 }, { 0x00000311, 0x00000203 }, + { 0x00000323, 0x00001ea1 }, { 0x00000325, 0x00001e01 }, + { 0x00000328, 0x00000105 }, { 0x00000307, 0x00001e03 }, + { 0x00000323, 0x00001e05 }, { 0x00000331, 0x00001e07 }, + { 0x00000301, 0x00000107 }, { 0x00000302, 0x00000109 }, + { 0x00000307, 0x0000010b }, { 0x0000030c, 0x0000010d }, + { 0x00000327, 0x000000e7 }, { 0x00000307, 0x00001e0b }, + { 0x0000030c, 0x0000010f }, { 0x00000323, 0x00001e0d }, + { 0x00000327, 0x00001e11 }, { 0x0000032d, 0x00001e13 }, + { 0x00000331, 0x00001e0f }, { 0x00000300, 0x000000e8 }, + { 0x00000301, 0x000000e9 }, { 0x00000302, 0x000000ea }, + { 0x00000303, 0x00001ebd }, { 0x00000304, 0x00000113 }, + { 0x00000306, 0x00000115 }, { 0x00000307, 0x00000117 }, + { 0x00000308, 0x000000eb }, { 0x00000309, 0x00001ebb }, + { 0x0000030c, 0x0000011b }, { 0x0000030f, 0x00000205 }, + { 0x00000311, 0x00000207 }, { 0x00000323, 0x00001eb9 }, + { 0x00000327, 0x00000229 }, { 0x00000328, 0x00000119 }, + { 0x0000032d, 0x00001e19 }, { 0x00000330, 0x00001e1b }, + { 0x00000307, 0x00001e1f }, { 0x00000301, 0x000001f5 }, + { 0x00000302, 0x0000011d }, { 0x00000304, 0x00001e21 }, + { 0x00000306, 0x0000011f }, { 0x00000307, 0x00000121 }, + { 0x0000030c, 0x000001e7 }, { 0x00000327, 0x00000123 }, + { 0x00000302, 0x00000125 }, { 0x00000307, 0x00001e23 }, + { 0x00000308, 0x00001e27 }, { 0x0000030c, 0x0000021f }, + { 0x00000323, 0x00001e25 }, { 0x00000327, 0x00001e29 }, + { 0x0000032e, 0x00001e2b }, { 0x00000331, 0x00001e96 }, + { 0x00000300, 0x000000ec }, { 0x00000301, 0x000000ed }, + { 0x00000302, 0x000000ee }, { 0x00000303, 0x00000129 }, + { 0x00000304, 0x0000012b }, { 0x00000306, 0x0000012d }, + { 0x00000308, 0x000000ef }, { 0x00000309, 0x00001ec9 }, + { 0x0000030c, 0x000001d0 }, { 0x0000030f, 0x00000209 }, + { 0x00000311, 0x0000020b }, { 0x00000323, 0x00001ecb }, + { 0x00000328, 0x0000012f }, { 0x00000330, 0x00001e2d }, + { 0x00000302, 0x00000135 }, { 0x0000030c, 0x000001f0 }, + { 0x00000301, 0x00001e31 }, { 0x0000030c, 0x000001e9 }, + { 0x00000323, 0x00001e33 }, { 0x00000327, 0x00000137 }, + { 0x00000331, 0x00001e35 }, { 0x00000301, 0x0000013a }, + { 0x0000030c, 0x0000013e }, { 0x00000323, 0x00001e37 }, + { 0x00000327, 0x0000013c }, { 0x0000032d, 0x00001e3d }, + { 0x00000331, 0x00001e3b }, { 0x00000301, 0x00001e3f }, + { 0x00000307, 0x00001e41 }, { 0x00000323, 0x00001e43 }, + { 0x00000300, 0x000001f9 }, { 0x00000301, 0x00000144 }, + { 0x00000303, 0x000000f1 }, { 0x00000307, 0x00001e45 }, + { 0x0000030c, 0x00000148 }, { 0x00000323, 0x00001e47 }, + { 0x00000327, 0x00000146 }, { 0x0000032d, 0x00001e4b }, + { 0x00000331, 0x00001e49 }, { 0x00000300, 0x000000f2 }, + { 0x00000301, 0x000000f3 }, { 0x00000302, 0x000000f4 }, + { 0x00000303, 0x000000f5 }, { 0x00000304, 0x0000014d }, + { 0x00000306, 0x0000014f }, { 0x00000307, 0x0000022f }, + { 0x00000308, 0x000000f6 }, { 0x00000309, 0x00001ecf }, + { 0x0000030b, 0x00000151 }, { 0x0000030c, 0x000001d2 }, + { 0x0000030f, 0x0000020d }, { 0x00000311, 0x0000020f }, + { 0x0000031b, 0x000001a1 }, { 0x00000323, 0x00001ecd }, + { 0x00000328, 0x000001eb }, { 0x00000301, 0x00001e55 }, + { 0x00000307, 0x00001e57 }, { 0x00000301, 0x00000155 }, + { 0x00000307, 0x00001e59 }, { 0x0000030c, 0x00000159 }, + { 0x0000030f, 0x00000211 }, { 0x00000311, 0x00000213 }, + { 0x00000323, 0x00001e5b }, { 0x00000327, 0x00000157 }, + { 0x00000331, 0x00001e5f }, { 0x00000301, 0x0000015b }, + { 0x00000302, 0x0000015d }, { 0x00000307, 0x00001e61 }, + { 0x0000030c, 0x00000161 }, { 0x00000323, 0x00001e63 }, + { 0x00000326, 0x00000219 }, { 0x00000327, 0x0000015f }, + { 0x00000307, 0x00001e6b }, { 0x00000308, 0x00001e97 }, + { 0x0000030c, 0x00000165 }, { 0x00000323, 0x00001e6d }, + { 0x00000326, 0x0000021b }, { 0x00000327, 0x00000163 }, + { 0x0000032d, 0x00001e71 }, { 0x00000331, 0x00001e6f }, + { 0x00000300, 0x000000f9 }, { 0x00000301, 0x000000fa }, + { 0x00000302, 0x000000fb }, { 0x00000303, 0x00000169 }, + { 0x00000304, 0x0000016b }, { 0x00000306, 0x0000016d }, + { 0x00000308, 0x000000fc }, { 0x00000309, 0x00001ee7 }, + { 0x0000030a, 0x0000016f }, { 0x0000030b, 0x00000171 }, + { 0x0000030c, 0x000001d4 }, { 0x0000030f, 0x00000215 }, + { 0x00000311, 0x00000217 }, { 0x0000031b, 0x000001b0 }, + { 0x00000323, 0x00001ee5 }, { 0x00000324, 0x00001e73 }, + { 0x00000328, 0x00000173 }, { 0x0000032d, 0x00001e77 }, + { 0x00000330, 0x00001e75 }, { 0x00000303, 0x00001e7d }, + { 0x00000323, 0x00001e7f }, { 0x00000300, 0x00001e81 }, + { 0x00000301, 0x00001e83 }, { 0x00000302, 0x00000175 }, + { 0x00000307, 0x00001e87 }, { 0x00000308, 0x00001e85 }, + { 0x0000030a, 0x00001e98 }, { 0x00000323, 0x00001e89 }, + { 0x00000307, 0x00001e8b }, { 0x00000308, 0x00001e8d }, + { 0x00000300, 0x00001ef3 }, { 0x00000301, 0x000000fd }, + { 0x00000302, 0x00000177 }, { 0x00000303, 0x00001ef9 }, + { 0x00000304, 0x00000233 }, { 0x00000307, 0x00001e8f }, + { 0x00000308, 0x000000ff }, { 0x00000309, 0x00001ef7 }, + { 0x0000030a, 0x00001e99 }, { 0x00000323, 0x00001ef5 }, + { 0x00000301, 0x0000017a }, { 0x00000302, 0x00001e91 }, + { 0x00000307, 0x0000017c }, { 0x0000030c, 0x0000017e }, + { 0x00000323, 0x00001e93 }, { 0x00000331, 0x00001e95 }, + { 0x00000300, 0x00001fed }, { 0x00000301, 0x00000385 }, + { 0x00000342, 0x00001fc1 }, { 0x00000300, 0x00001ea6 }, + { 0x00000301, 0x00001ea4 }, { 0x00000303, 0x00001eaa }, + { 0x00000309, 0x00001ea8 }, { 0x00000304, 0x000001de }, + { 0x00000301, 0x000001fa }, { 0x00000301, 0x000001fc }, + { 0x00000304, 0x000001e2 }, { 0x00000301, 0x00001e08 }, + { 0x00000300, 0x00001ec0 }, { 0x00000301, 0x00001ebe }, + { 0x00000303, 0x00001ec4 }, { 0x00000309, 0x00001ec2 }, + { 0x00000301, 0x00001e2e }, { 0x00000300, 0x00001ed2 }, + { 0x00000301, 0x00001ed0 }, { 0x00000303, 0x00001ed6 }, + { 0x00000309, 0x00001ed4 }, { 0x00000301, 0x00001e4c }, + { 0x00000304, 0x0000022c }, { 0x00000308, 0x00001e4e }, + { 0x00000304, 0x0000022a }, { 0x00000301, 0x000001fe }, + { 0x00000300, 0x000001db }, { 0x00000301, 0x000001d7 }, + { 0x00000304, 0x000001d5 }, { 0x0000030c, 0x000001d9 }, + { 0x00000300, 0x00001ea7 }, { 0x00000301, 0x00001ea5 }, + { 0x00000303, 0x00001eab }, { 0x00000309, 0x00001ea9 }, + { 0x00000304, 0x000001df }, { 0x00000301, 0x000001fb }, + { 0x00000301, 0x000001fd }, { 0x00000304, 0x000001e3 }, + { 0x00000301, 0x00001e09 }, { 0x00000300, 0x00001ec1 }, + { 0x00000301, 0x00001ebf }, { 0x00000303, 0x00001ec5 }, + { 0x00000309, 0x00001ec3 }, { 0x00000301, 0x00001e2f }, + { 0x00000300, 0x00001ed3 }, { 0x00000301, 0x00001ed1 }, + { 0x00000303, 0x00001ed7 }, { 0x00000309, 0x00001ed5 }, + { 0x00000301, 0x00001e4d }, { 0x00000304, 0x0000022d }, + { 0x00000308, 0x00001e4f }, { 0x00000304, 0x0000022b }, + { 0x00000301, 0x000001ff }, { 0x00000300, 0x000001dc }, + { 0x00000301, 0x000001d8 }, { 0x00000304, 0x000001d6 }, + { 0x0000030c, 0x000001da }, { 0x00000300, 0x00001eb0 }, + { 0x00000301, 0x00001eae }, { 0x00000303, 0x00001eb4 }, + { 0x00000309, 0x00001eb2 }, { 0x00000300, 0x00001eb1 }, + { 0x00000301, 0x00001eaf }, { 0x00000303, 0x00001eb5 }, + { 0x00000309, 0x00001eb3 }, { 0x00000300, 0x00001e14 }, + { 0x00000301, 0x00001e16 }, { 0x00000300, 0x00001e15 }, + { 0x00000301, 0x00001e17 }, { 0x00000300, 0x00001e50 }, + { 0x00000301, 0x00001e52 }, { 0x00000300, 0x00001e51 }, + { 0x00000301, 0x00001e53 }, { 0x00000307, 0x00001e64 }, + { 0x00000307, 0x00001e65 }, { 0x00000307, 0x00001e66 }, + { 0x00000307, 0x00001e67 }, { 0x00000301, 0x00001e78 }, + { 0x00000301, 0x00001e79 }, { 0x00000308, 0x00001e7a }, + { 0x00000308, 0x00001e7b }, { 0x00000307, 0x00001e9b }, + { 0x00000300, 0x00001edc }, { 0x00000301, 0x00001eda }, + { 0x00000303, 0x00001ee0 }, { 0x00000309, 0x00001ede }, + { 0x00000323, 0x00001ee2 }, { 0x00000300, 0x00001edd }, + { 0x00000301, 0x00001edb }, { 0x00000303, 0x00001ee1 }, + { 0x00000309, 0x00001edf }, { 0x00000323, 0x00001ee3 }, + { 0x00000300, 0x00001eea }, { 0x00000301, 0x00001ee8 }, + { 0x00000303, 0x00001eee }, { 0x00000309, 0x00001eec }, + { 0x00000323, 0x00001ef0 }, { 0x00000300, 0x00001eeb }, + { 0x00000301, 0x00001ee9 }, { 0x00000303, 0x00001eef }, + { 0x00000309, 0x00001eed }, { 0x00000323, 0x00001ef1 }, + { 0x0000030c, 0x000001ee }, { 0x00000304, 0x000001ec }, + { 0x00000304, 0x000001ed }, { 0x00000304, 0x000001e0 }, + { 0x00000304, 0x000001e1 }, { 0x00000306, 0x00001e1c }, + { 0x00000306, 0x00001e1d }, { 0x00000304, 0x00000230 }, + { 0x00000304, 0x00000231 }, { 0x0000030c, 0x000001ef }, + { 0x00000300, 0x00001fba }, { 0x00000301, 0x00000386 }, + { 0x00000304, 0x00001fb9 }, { 0x00000306, 0x00001fb8 }, + { 0x00000313, 0x00001f08 }, { 0x00000314, 0x00001f09 }, + { 0x00000345, 0x00001fbc }, { 0x00000300, 0x00001fc8 }, + { 0x00000301, 0x00000388 }, { 0x00000313, 0x00001f18 }, + { 0x00000314, 0x00001f19 }, { 0x00000300, 0x00001fca }, + { 0x00000301, 0x00000389 }, { 0x00000313, 0x00001f28 }, + { 0x00000314, 0x00001f29 }, { 0x00000345, 0x00001fcc }, + { 0x00000300, 0x00001fda }, { 0x00000301, 0x0000038a }, + { 0x00000304, 0x00001fd9 }, { 0x00000306, 0x00001fd8 }, + { 0x00000308, 0x000003aa }, { 0x00000313, 0x00001f38 }, + { 0x00000314, 0x00001f39 }, { 0x00000300, 0x00001ff8 }, + { 0x00000301, 0x0000038c }, { 0x00000313, 0x00001f48 }, + { 0x00000314, 0x00001f49 }, { 0x00000314, 0x00001fec }, + { 0x00000300, 0x00001fea }, { 0x00000301, 0x0000038e }, + { 0x00000304, 0x00001fe9 }, { 0x00000306, 0x00001fe8 }, + { 0x00000308, 0x000003ab }, { 0x00000314, 0x00001f59 }, + { 0x00000300, 0x00001ffa }, { 0x00000301, 0x0000038f }, + { 0x00000313, 0x00001f68 }, { 0x00000314, 0x00001f69 }, + { 0x00000345, 0x00001ffc }, { 0x00000345, 0x00001fb4 }, + { 0x00000345, 0x00001fc4 }, { 0x00000300, 0x00001f70 }, + { 0x00000301, 0x000003ac }, { 0x00000304, 0x00001fb1 }, + { 0x00000306, 0x00001fb0 }, { 0x00000313, 0x00001f00 }, + { 0x00000314, 0x00001f01 }, { 0x00000342, 0x00001fb6 }, + { 0x00000345, 0x00001fb3 }, { 0x00000300, 0x00001f72 }, + { 0x00000301, 0x000003ad }, { 0x00000313, 0x00001f10 }, + { 0x00000314, 0x00001f11 }, { 0x00000300, 0x00001f74 }, + { 0x00000301, 0x000003ae }, { 0x00000313, 0x00001f20 }, + { 0x00000314, 0x00001f21 }, { 0x00000342, 0x00001fc6 }, + { 0x00000345, 0x00001fc3 }, { 0x00000300, 0x00001f76 }, + { 0x00000301, 0x000003af }, { 0x00000304, 0x00001fd1 }, + { 0x00000306, 0x00001fd0 }, { 0x00000308, 0x000003ca }, + { 0x00000313, 0x00001f30 }, { 0x00000314, 0x00001f31 }, + { 0x00000342, 0x00001fd6 }, { 0x00000300, 0x00001f78 }, + { 0x00000301, 0x000003cc }, { 0x00000313, 0x00001f40 }, + { 0x00000314, 0x00001f41 }, { 0x00000313, 0x00001fe4 }, + { 0x00000314, 0x00001fe5 }, { 0x00000300, 0x00001f7a }, + { 0x00000301, 0x000003cd }, { 0x00000304, 0x00001fe1 }, + { 0x00000306, 0x00001fe0 }, { 0x00000308, 0x000003cb }, + { 0x00000313, 0x00001f50 }, { 0x00000314, 0x00001f51 }, + { 0x00000342, 0x00001fe6 }, { 0x00000300, 0x00001f7c }, + { 0x00000301, 0x000003ce }, { 0x00000313, 0x00001f60 }, + { 0x00000314, 0x00001f61 }, { 0x00000342, 0x00001ff6 }, + { 0x00000345, 0x00001ff3 }, { 0x00000300, 0x00001fd2 }, + { 0x00000301, 0x00000390 }, { 0x00000342, 0x00001fd7 }, + { 0x00000300, 0x00001fe2 }, { 0x00000301, 0x000003b0 }, + { 0x00000342, 0x00001fe7 }, { 0x00000345, 0x00001ff4 }, + { 0x00000301, 0x000003d3 }, { 0x00000308, 0x000003d4 }, + { 0x00000308, 0x00000407 }, { 0x00000306, 0x000004d0 }, + { 0x00000308, 0x000004d2 }, { 0x00000301, 0x00000403 }, + { 0x00000300, 0x00000400 }, { 0x00000306, 0x000004d6 }, + { 0x00000308, 0x00000401 }, { 0x00000306, 0x000004c1 }, + { 0x00000308, 0x000004dc }, { 0x00000308, 0x000004de }, + { 0x00000300, 0x0000040d }, { 0x00000304, 0x000004e2 }, + { 0x00000306, 0x00000419 }, { 0x00000308, 0x000004e4 }, + { 0x00000301, 0x0000040c }, { 0x00000308, 0x000004e6 }, + { 0x00000304, 0x000004ee }, { 0x00000306, 0x0000040e }, + { 0x00000308, 0x000004f0 }, { 0x0000030b, 0x000004f2 }, + { 0x00000308, 0x000004f4 }, { 0x00000308, 0x000004f8 }, + { 0x00000308, 0x000004ec }, { 0x00000306, 0x000004d1 }, + { 0x00000308, 0x000004d3 }, { 0x00000301, 0x00000453 }, + { 0x00000300, 0x00000450 }, { 0x00000306, 0x000004d7 }, + { 0x00000308, 0x00000451 }, { 0x00000306, 0x000004c2 }, + { 0x00000308, 0x000004dd }, { 0x00000308, 0x000004df }, + { 0x00000300, 0x0000045d }, { 0x00000304, 0x000004e3 }, + { 0x00000306, 0x00000439 }, { 0x00000308, 0x000004e5 }, + { 0x00000301, 0x0000045c }, { 0x00000308, 0x000004e7 }, + { 0x00000304, 0x000004ef }, { 0x00000306, 0x0000045e }, + { 0x00000308, 0x000004f1 }, { 0x0000030b, 0x000004f3 }, + { 0x00000308, 0x000004f5 }, { 0x00000308, 0x000004f9 }, + { 0x00000308, 0x000004ed }, { 0x00000308, 0x00000457 }, + { 0x0000030f, 0x00000476 }, { 0x0000030f, 0x00000477 }, + { 0x00000308, 0x000004da }, { 0x00000308, 0x000004db }, + { 0x00000308, 0x000004ea }, { 0x00000308, 0x000004eb }, + { 0x00000653, 0x00000622 }, { 0x00000654, 0x00000623 }, + { 0x00000655, 0x00000625 }, { 0x00000654, 0x00000624 }, + { 0x00000654, 0x00000626 }, { 0x00000654, 0x000006c2 }, + { 0x00000654, 0x000006d3 }, { 0x00000654, 0x000006c0 }, + { 0x0000093c, 0x00000929 }, { 0x0000093c, 0x00000931 }, + { 0x0000093c, 0x00000934 }, { 0x000009be, 0x000009cb }, + { 0x000009d7, 0x000009cc }, { 0x00000b3e, 0x00000b4b }, + { 0x00000b56, 0x00000b48 }, { 0x00000b57, 0x00000b4c }, + { 0x00000bd7, 0x00000b94 }, { 0x00000bbe, 0x00000bca }, + { 0x00000bd7, 0x00000bcc }, { 0x00000bbe, 0x00000bcb }, + { 0x00000c56, 0x00000c48 }, { 0x00000cd5, 0x00000cc0 }, + { 0x00000cc2, 0x00000cca }, { 0x00000cd5, 0x00000cc7 }, + { 0x00000cd6, 0x00000cc8 }, { 0x00000cd5, 0x00000ccb }, + { 0x00000d3e, 0x00000d4a }, { 0x00000d57, 0x00000d4c }, + { 0x00000d3e, 0x00000d4b }, { 0x00000dca, 0x00000dda }, + { 0x00000dcf, 0x00000ddc }, { 0x00000ddf, 0x00000dde }, + { 0x00000dca, 0x00000ddd }, { 0x0000102e, 0x00001026 }, + { 0x00000304, 0x00001e38 }, { 0x00000304, 0x00001e39 }, + { 0x00000304, 0x00001e5c }, { 0x00000304, 0x00001e5d }, + { 0x00000307, 0x00001e68 }, { 0x00000307, 0x00001e69 }, + { 0x00000302, 0x00001eac }, { 0x00000306, 0x00001eb6 }, + { 0x00000302, 0x00001ead }, { 0x00000306, 0x00001eb7 }, + { 0x00000302, 0x00001ec6 }, { 0x00000302, 0x00001ec7 }, + { 0x00000302, 0x00001ed8 }, { 0x00000302, 0x00001ed9 }, + { 0x00000300, 0x00001f02 }, { 0x00000301, 0x00001f04 }, + { 0x00000342, 0x00001f06 }, { 0x00000345, 0x00001f80 }, + { 0x00000300, 0x00001f03 }, { 0x00000301, 0x00001f05 }, + { 0x00000342, 0x00001f07 }, { 0x00000345, 0x00001f81 }, + { 0x00000345, 0x00001f82 }, { 0x00000345, 0x00001f83 }, + { 0x00000345, 0x00001f84 }, { 0x00000345, 0x00001f85 }, + { 0x00000345, 0x00001f86 }, { 0x00000345, 0x00001f87 }, + { 0x00000300, 0x00001f0a }, { 0x00000301, 0x00001f0c }, + { 0x00000342, 0x00001f0e }, { 0x00000345, 0x00001f88 }, + { 0x00000300, 0x00001f0b }, { 0x00000301, 0x00001f0d }, + { 0x00000342, 0x00001f0f }, { 0x00000345, 0x00001f89 }, + { 0x00000345, 0x00001f8a }, { 0x00000345, 0x00001f8b }, + { 0x00000345, 0x00001f8c }, { 0x00000345, 0x00001f8d }, + { 0x00000345, 0x00001f8e }, { 0x00000345, 0x00001f8f }, + { 0x00000300, 0x00001f12 }, { 0x00000301, 0x00001f14 }, + { 0x00000300, 0x00001f13 }, { 0x00000301, 0x00001f15 }, + { 0x00000300, 0x00001f1a }, { 0x00000301, 0x00001f1c }, + { 0x00000300, 0x00001f1b }, { 0x00000301, 0x00001f1d }, + { 0x00000300, 0x00001f22 }, { 0x00000301, 0x00001f24 }, + { 0x00000342, 0x00001f26 }, { 0x00000345, 0x00001f90 }, + { 0x00000300, 0x00001f23 }, { 0x00000301, 0x00001f25 }, + { 0x00000342, 0x00001f27 }, { 0x00000345, 0x00001f91 }, + { 0x00000345, 0x00001f92 }, { 0x00000345, 0x00001f93 }, + { 0x00000345, 0x00001f94 }, { 0x00000345, 0x00001f95 }, + { 0x00000345, 0x00001f96 }, { 0x00000345, 0x00001f97 }, + { 0x00000300, 0x00001f2a }, { 0x00000301, 0x00001f2c }, + { 0x00000342, 0x00001f2e }, { 0x00000345, 0x00001f98 }, + { 0x00000300, 0x00001f2b }, { 0x00000301, 0x00001f2d }, + { 0x00000342, 0x00001f2f }, { 0x00000345, 0x00001f99 }, + { 0x00000345, 0x00001f9a }, { 0x00000345, 0x00001f9b }, + { 0x00000345, 0x00001f9c }, { 0x00000345, 0x00001f9d }, + { 0x00000345, 0x00001f9e }, { 0x00000345, 0x00001f9f }, + { 0x00000300, 0x00001f32 }, { 0x00000301, 0x00001f34 }, + { 0x00000342, 0x00001f36 }, { 0x00000300, 0x00001f33 }, + { 0x00000301, 0x00001f35 }, { 0x00000342, 0x00001f37 }, + { 0x00000300, 0x00001f3a }, { 0x00000301, 0x00001f3c }, + { 0x00000342, 0x00001f3e }, { 0x00000300, 0x00001f3b }, + { 0x00000301, 0x00001f3d }, { 0x00000342, 0x00001f3f }, + { 0x00000300, 0x00001f42 }, { 0x00000301, 0x00001f44 }, + { 0x00000300, 0x00001f43 }, { 0x00000301, 0x00001f45 }, + { 0x00000300, 0x00001f4a }, { 0x00000301, 0x00001f4c }, + { 0x00000300, 0x00001f4b }, { 0x00000301, 0x00001f4d }, + { 0x00000300, 0x00001f52 }, { 0x00000301, 0x00001f54 }, + { 0x00000342, 0x00001f56 }, { 0x00000300, 0x00001f53 }, + { 0x00000301, 0x00001f55 }, { 0x00000342, 0x00001f57 }, + { 0x00000300, 0x00001f5b }, { 0x00000301, 0x00001f5d }, + { 0x00000342, 0x00001f5f }, { 0x00000300, 0x00001f62 }, + { 0x00000301, 0x00001f64 }, { 0x00000342, 0x00001f66 }, + { 0x00000345, 0x00001fa0 }, { 0x00000300, 0x00001f63 }, + { 0x00000301, 0x00001f65 }, { 0x00000342, 0x00001f67 }, + { 0x00000345, 0x00001fa1 }, { 0x00000345, 0x00001fa2 }, + { 0x00000345, 0x00001fa3 }, { 0x00000345, 0x00001fa4 }, + { 0x00000345, 0x00001fa5 }, { 0x00000345, 0x00001fa6 }, + { 0x00000345, 0x00001fa7 }, { 0x00000300, 0x00001f6a }, + { 0x00000301, 0x00001f6c }, { 0x00000342, 0x00001f6e }, + { 0x00000345, 0x00001fa8 }, { 0x00000300, 0x00001f6b }, + { 0x00000301, 0x00001f6d }, { 0x00000342, 0x00001f6f }, + { 0x00000345, 0x00001fa9 }, { 0x00000345, 0x00001faa }, + { 0x00000345, 0x00001fab }, { 0x00000345, 0x00001fac }, + { 0x00000345, 0x00001fad }, { 0x00000345, 0x00001fae }, + { 0x00000345, 0x00001faf }, { 0x00000345, 0x00001fb2 }, + { 0x00000345, 0x00001fc2 }, { 0x00000345, 0x00001ff2 }, + { 0x00000345, 0x00001fb7 }, { 0x00000300, 0x00001fcd }, + { 0x00000301, 0x00001fce }, { 0x00000342, 0x00001fcf }, + { 0x00000345, 0x00001fc7 }, { 0x00000345, 0x00001ff7 }, + { 0x00000300, 0x00001fdd }, { 0x00000301, 0x00001fde }, + { 0x00000342, 0x00001fdf }, { 0x00000338, 0x0000219a }, + { 0x00000338, 0x0000219b }, { 0x00000338, 0x000021ae }, + { 0x00000338, 0x000021cd }, { 0x00000338, 0x000021cf }, + { 0x00000338, 0x000021ce }, { 0x00000338, 0x00002204 }, + { 0x00000338, 0x00002209 }, { 0x00000338, 0x0000220c }, + { 0x00000338, 0x00002224 }, { 0x00000338, 0x00002226 }, + { 0x00000338, 0x00002241 }, { 0x00000338, 0x00002244 }, + { 0x00000338, 0x00002247 }, { 0x00000338, 0x00002249 }, + { 0x00000338, 0x0000226d }, { 0x00000338, 0x00002262 }, + { 0x00000338, 0x00002270 }, { 0x00000338, 0x00002271 }, + { 0x00000338, 0x00002274 }, { 0x00000338, 0x00002275 }, + { 0x00000338, 0x00002278 }, { 0x00000338, 0x00002279 }, + { 0x00000338, 0x00002280 }, { 0x00000338, 0x00002281 }, + { 0x00000338, 0x000022e0 }, { 0x00000338, 0x000022e1 }, + { 0x00000338, 0x00002284 }, { 0x00000338, 0x00002285 }, + { 0x00000338, 0x00002288 }, { 0x00000338, 0x00002289 }, + { 0x00000338, 0x000022e2 }, { 0x00000338, 0x000022e3 }, + { 0x00000338, 0x000022ac }, { 0x00000338, 0x000022ad }, + { 0x00000338, 0x000022ae }, { 0x00000338, 0x000022af }, + { 0x00000338, 0x000022ea }, { 0x00000338, 0x000022eb }, + { 0x00000338, 0x000022ec }, { 0x00000338, 0x000022ed }, + { 0x00003099, 0x00003094 }, { 0x00003099, 0x0000304c }, + { 0x00003099, 0x0000304e }, { 0x00003099, 0x00003050 }, + { 0x00003099, 0x00003052 }, { 0x00003099, 0x00003054 }, + { 0x00003099, 0x00003056 }, { 0x00003099, 0x00003058 }, + { 0x00003099, 0x0000305a }, { 0x00003099, 0x0000305c }, + { 0x00003099, 0x0000305e }, { 0x00003099, 0x00003060 }, + { 0x00003099, 0x00003062 }, { 0x00003099, 0x00003065 }, + { 0x00003099, 0x00003067 }, { 0x00003099, 0x00003069 }, + { 0x00003099, 0x00003070 }, { 0x0000309a, 0x00003071 }, + { 0x00003099, 0x00003073 }, { 0x0000309a, 0x00003074 }, + { 0x00003099, 0x00003076 }, { 0x0000309a, 0x00003077 }, + { 0x00003099, 0x00003079 }, { 0x0000309a, 0x0000307a }, + { 0x00003099, 0x0000307c }, { 0x0000309a, 0x0000307d }, + { 0x00003099, 0x0000309e }, { 0x00003099, 0x000030f4 }, + { 0x00003099, 0x000030ac }, { 0x00003099, 0x000030ae }, + { 0x00003099, 0x000030b0 }, { 0x00003099, 0x000030b2 }, + { 0x00003099, 0x000030b4 }, { 0x00003099, 0x000030b6 }, + { 0x00003099, 0x000030b8 }, { 0x00003099, 0x000030ba }, + { 0x00003099, 0x000030bc }, { 0x00003099, 0x000030be }, + { 0x00003099, 0x000030c0 }, { 0x00003099, 0x000030c2 }, + { 0x00003099, 0x000030c5 }, { 0x00003099, 0x000030c7 }, + { 0x00003099, 0x000030c9 }, { 0x00003099, 0x000030d0 }, + { 0x0000309a, 0x000030d1 }, { 0x00003099, 0x000030d3 }, + { 0x0000309a, 0x000030d4 }, { 0x00003099, 0x000030d6 }, + { 0x0000309a, 0x000030d7 }, { 0x00003099, 0x000030d9 }, + { 0x0000309a, 0x000030da }, { 0x00003099, 0x000030dc }, + { 0x0000309a, 0x000030dd }, { 0x00003099, 0x000030f7 }, + { 0x00003099, 0x000030f8 }, { 0x00003099, 0x000030f9 }, + { 0x00003099, 0x000030fa }, { 0x00003099, 0x000030fe }, +}; + + +/* + * Canonical/Compatibility Decomposition + */ + +#define DECOMP_BITS_0 9 +#define DECOMP_BITS_1 7 +#define DECOMP_BITS_2 5 +#define DECOMP_COMPAT 32768 + +static const unsigned short v320_decompose_imap[] = { + 272, 400, 528, 656, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 912, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 1040, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 1168, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 0, 0, 0, 0, 0, 1, 2, 3, + 4, 5, 6, 7, 0, 8, 9, 10, + 11, 12, 0, 0, 0, 13, 14, 15, + 0, 0, 16, 17, 18, 19, 20, 21, + 22, 23, 24, 25, 0, 0, 26, 27, + 0, 0, 0, 0, 28, 0, 0, 0, + 0, 29, 0, 30, 0, 0, 31, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 32, 33, 0, 0, 0, 34, 0, + 0, 35, 36, 0, 0, 0, 0, 0, + 0, 0, 37, 0, 38, 0, 39, 0, + 0, 0, 40, 0, 0, 0, 41, 0, + 0, 0, 42, 0, 0, 0, 43, 0, + 0, 44, 0, 0, 0, 45, 46, 0, + 47, 0, 48, 49, 50, 51, 0, 0, + 0, 52, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 53, 54, 55, 56, 57, 58, 59, 60, + 61, 62, 63, 64, 65, 66, 67, 68, + 69, 70, 71, 72, 73, 74, 0, 0, + 75, 76, 77, 78, 79, 80, 81, 0, + 82, 83, 84, 85, 86, 87, 0, 88, + 0, 89, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 90, 91, 92, 93, 94, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 95, 0, 0, 96, 0, 0, 97, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 98, 0, 0, 99, + 100, 101, 102, 103, 104, 105, 106, 0, + 107, 108, 109, 110, 111, 112, 113, 114, + 0, 115, 116, 117, 118, 0, 0, 0, + 119, 120, 121, 122, 123, 124, 125, 126, + 127, 128, 129, 130, 131, 132, 133, 134, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 135, 136, 137, 138, 139, 140, 141, 142, + 143, 144, 145, 146, 0, 0, 0, 0, + 147, 148, 149, 150, 151, 152, 153, 154, + 155, 156, 157, 158, 159, 160, 161, 162, + 163, 164, 165, 166, 167, 168, 169, 170, + 0, 171, 172, 173, 174, 175, 176, 177, + 178, 179, 180, 181, 182, 183, 184, 185, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 186, 187, 0, 188, 189, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 190, 191, 192, 193, 194, 195, 196, 197, + 198, 199, 200, 201, 202, 203, 204, 205, + 206, 207, 208, 209, 210, 211, 212, 213, + 214, 215, 216, 217, 218, 219, 220, 221, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 222, 223, 224, 225, 226, 227, 228, 229, + 230, 231, 232, 233, 234, 235, 236, 237, + 238, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, +}; + +static const struct { + unsigned short tbl[32]; +} v320_decompose_table[] = { + {{ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 32769, 0, 0, 0, 0, 0, 0, 0, + 32770, 0, 32772, 0, 0, 0, 0, 32773, + 0, 0, 32775, 32776, 32777, 32779, 0, 0, + 32780, 32782, 32783, 0, 32784, 32787, 32790, 0, + }}, + {{ + 25, 27, 29, 31, 33, 35, 0, 37, + 39, 41, 43, 45, 47, 49, 51, 53, + 0, 55, 57, 59, 61, 63, 65, 0, + 0, 67, 69, 71, 73, 75, 0, 0, + }}, + {{ + 77, 79, 81, 83, 85, 87, 0, 89, + 91, 93, 95, 97, 99, 101, 103, 105, + 0, 107, 109, 111, 113, 115, 117, 0, + 0, 119, 121, 123, 125, 127, 0, 129, + }}, + {{ + 131, 133, 135, 137, 139, 141, 143, 145, + 147, 149, 151, 153, 155, 157, 159, 161, + 0, 0, 163, 165, 167, 169, 171, 173, + 175, 177, 179, 181, 183, 185, 187, 189, + }}, + {{ + 191, 193, 195, 197, 199, 201, 0, 0, + 203, 205, 207, 209, 211, 213, 215, 217, + 219, 0, 32989, 32991, 225, 227, 229, 231, + 0, 233, 235, 237, 239, 241, 243, 33013, + }}, + {{ + 33015, 0, 0, 249, 251, 253, 255, 257, + 259, 33029, 0, 0, 263, 265, 267, 269, + 271, 273, 0, 0, 275, 277, 279, 281, + 283, 285, 287, 289, 291, 293, 295, 297, + }}, + {{ + 299, 301, 303, 305, 307, 309, 0, 0, + 311, 313, 315, 317, 319, 321, 323, 325, + 327, 329, 331, 333, 335, 337, 339, 341, + 343, 345, 347, 349, 351, 353, 355, 33125, + }}, + {{ + 358, 360, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 362, + 364, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 33134, 33136, 33138, 33140, + 33142, 33144, 33146, 33148, 33150, 384, 386, 388, + 390, 392, 394, 396, 398, 400, 402, 404, + 406, 408, 410, 412, 414, 0, 416, 418, + }}, + {{ + 420, 422, 424, 426, 0, 0, 428, 430, + 432, 434, 436, 438, 440, 442, 444, 446, + 448, 33218, 33220, 33222, 456, 458, 0, 0, + 460, 462, 464, 466, 468, 470, 472, 474, + }}, + {{ + 476, 478, 480, 482, 484, 486, 488, 490, + 492, 494, 496, 498, 500, 502, 504, 506, + 508, 510, 512, 514, 516, 518, 520, 522, + 524, 526, 528, 530, 0, 0, 532, 534, + }}, + {{ + 0, 0, 0, 0, 0, 0, 536, 538, + 540, 542, 544, 546, 548, 550, 552, 554, + 556, 558, 560, 562, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 33332, 33333, 33334, 33335, 33336, 33337, 33338, 33339, + 33340, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 33341, 33343, 33345, 33347, 33349, 33351, 0, 0, + }}, + {{ + 33353, 33354, 33355, 33356, 33357, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 590, 591, 0, 592, 593, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 595, 0, 0, 0, + 0, 0, 33364, 0, 0, 0, 598, 0, + }}, + {{ + 0, 0, 0, 0, 33367, 601, 603, 605, + 606, 608, 610, 0, 612, 0, 614, 616, + 618, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 620, 622, 624, 626, 628, 630, + 632, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 634, 636, 638, 640, 642, 0, + 33412, 33413, 33414, 647, 649, 33419, 33420, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 33421, 33422, 33423, 0, 33424, 33425, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 658, 660, 0, 662, 0, 0, 0, 664, + 0, 0, 0, 0, 666, 668, 670, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 672, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 674, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 676, 678, 0, 680, 0, 0, 0, 682, + 0, 0, 0, 0, 684, 686, 688, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 690, 692, + 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 694, 696, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 698, 700, 702, 704, 0, 0, 706, 708, + 0, 0, 710, 712, 714, 716, 718, 720, + }}, + {{ + 0, 0, 722, 724, 726, 728, 730, 732, + 0, 0, 734, 736, 738, 740, 742, 744, + 746, 748, 750, 752, 754, 756, 0, 0, + 758, 760, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 33530, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 764, 766, 768, 770, 772, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 33542, 33544, 33546, + 33548, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 782, 0, 784, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 786, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 788, 0, 0, 0, 0, 0, 0, + 0, 790, 0, 0, 792, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 794, 796, 798, 800, 802, 804, 806, 808, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 810, 812, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 814, 816, 0, 818, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 820, 0, 0, 822, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 824, 826, 828, 0, 0, 830, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, + 832, 0, 0, 834, 836, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 838, 840, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 842, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 844, 846, 848, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, + 850, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 852, 0, 0, 0, 0, 0, 0, 854, + 856, 0, 858, 860, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 862, 864, 866, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 868, 0, 870, 872, 874, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 33644, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 33646, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 33648, 33650, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 33652, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 885, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 887, 0, 0, + 0, 0, 889, 0, 0, 0, 0, 891, + 0, 0, 0, 0, 893, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 895, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 897, 0, 899, 901, 33671, + 905, 33675, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 909, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 911, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 913, 0, 0, + }}, + {{ + 0, 0, 915, 0, 0, 0, 0, 917, + 0, 0, 0, 0, 919, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 921, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 923, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 925, 927, 929, 931, 933, 935, 937, 939, + 941, 943, 945, 947, 949, 951, 953, 955, + 957, 959, 961, 963, 965, 967, 969, 971, + 973, 975, 977, 979, 981, 983, 985, 987, + }}, + {{ + 989, 991, 993, 995, 997, 999, 1001, 1003, + 1005, 1007, 1009, 1011, 1013, 1015, 1017, 1019, + 1021, 1023, 1025, 1027, 1029, 1031, 1033, 1035, + 1037, 1039, 1041, 1043, 1045, 1047, 1049, 1051, + }}, + {{ + 1053, 1055, 1057, 1059, 1061, 1063, 1065, 1067, + 1069, 1071, 1073, 1075, 1077, 1079, 1081, 1083, + 1085, 1087, 1089, 1091, 1093, 1095, 1097, 1099, + 1101, 1103, 1105, 1107, 1109, 1111, 1113, 1115, + }}, + {{ + 1117, 1119, 1121, 1123, 1125, 1127, 1129, 1131, + 1133, 1135, 1137, 1139, 1141, 1143, 1145, 1147, + 1149, 1151, 1153, 1155, 1157, 1159, 1161, 1163, + 1165, 1167, 1169, 1171, 1173, 1175, 1177, 1179, + }}, + {{ + 1181, 1183, 1185, 1187, 1189, 1191, 1193, 1195, + 1197, 1199, 1201, 1203, 1205, 1207, 1209, 1211, + 1213, 1215, 1217, 1219, 1221, 1223, 1225, 1227, + 1229, 1231, 34001, 1235, 0, 0, 0, 0, + }}, + {{ + 1237, 1239, 1241, 1243, 1245, 1247, 1249, 1251, + 1253, 1255, 1257, 1259, 1261, 1263, 1265, 1267, + 1269, 1271, 1273, 1275, 1277, 1279, 1281, 1283, + 1285, 1287, 1289, 1291, 1293, 1295, 1297, 1299, + }}, + {{ + 1301, 1303, 1305, 1307, 1309, 1311, 1313, 1315, + 1317, 1319, 1321, 1323, 1325, 1327, 1329, 1331, + 1333, 1335, 1337, 1339, 1341, 1343, 1345, 1347, + 1349, 1351, 1353, 1355, 1357, 1359, 1361, 1363, + }}, + {{ + 1365, 1367, 1369, 1371, 1373, 1375, 1377, 1379, + 1381, 1383, 1385, 1387, 1389, 1391, 1393, 1395, + 1397, 1399, 1401, 1403, 1405, 1407, 1409, 1411, + 1413, 1415, 0, 0, 0, 0, 0, 0, + }}, + {{ + 1417, 1419, 1421, 1423, 1425, 1427, 1429, 1431, + 1433, 1435, 1437, 1439, 1441, 1443, 1445, 1447, + 1449, 1451, 1453, 1455, 1457, 1459, 0, 0, + 1461, 1463, 1465, 1467, 1469, 1471, 0, 0, + }}, + {{ + 1473, 1475, 1477, 1479, 1481, 1483, 1485, 1487, + 1489, 1491, 1493, 1495, 1497, 1499, 1501, 1503, + 1505, 1507, 1509, 1511, 1513, 1515, 1517, 1519, + 1521, 1523, 1525, 1527, 1529, 1531, 1533, 1535, + }}, + {{ + 1537, 1539, 1541, 1543, 1545, 1547, 0, 0, + 1549, 1551, 1553, 1555, 1557, 1559, 0, 0, + 1561, 1563, 1565, 1567, 1569, 1571, 1573, 1575, + 0, 1577, 0, 1579, 0, 1581, 0, 1583, + }}, + {{ + 1585, 1587, 1589, 1591, 1593, 1595, 1597, 1599, + 1601, 1603, 1605, 1607, 1609, 1611, 1613, 1615, + 1617, 1619, 1620, 1622, 1623, 1625, 1626, 1628, + 1629, 1631, 1632, 1634, 1635, 1637, 0, 0, + }}, + {{ + 1638, 1640, 1642, 1644, 1646, 1648, 1650, 1652, + 1654, 1656, 1658, 1660, 1662, 1664, 1666, 1668, + 1670, 1672, 1674, 1676, 1678, 1680, 1682, 1684, + 1686, 1688, 1690, 1692, 1694, 1696, 1698, 1700, + }}, + {{ + 1702, 1704, 1706, 1708, 1710, 1712, 1714, 1716, + 1718, 1720, 1722, 1724, 1726, 1728, 1730, 1732, + 1734, 1736, 1738, 1740, 1742, 0, 1744, 1746, + 1748, 1750, 1752, 1754, 1755, 34525, 1759, 34528, + }}, + {{ + 34530, 1764, 1766, 1768, 1770, 0, 1772, 1774, + 1776, 1778, 1779, 1781, 1782, 1784, 1786, 1788, + 1790, 1792, 1794, 1796, 0, 0, 1797, 1799, + 1801, 1803, 1805, 1807, 0, 1808, 1810, 1812, + }}, + {{ + 1814, 1816, 1818, 1820, 1821, 1823, 1825, 1827, + 1829, 1831, 1833, 1835, 1836, 1838, 1840, 1841, + 0, 0, 1842, 1844, 1846, 0, 1848, 1850, + 1852, 1854, 1855, 1857, 1858, 1860, 34629, 0, + }}, + {{ + 1863, 1864, 34633, 34634, 34635, 34636, 34637, 34638, + 34639, 34640, 34641, 0, 0, 0, 0, 0, + 0, 34642, 0, 0, 0, 0, 0, 34643, + 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 34645, 34646, 34648, 0, + 0, 0, 0, 0, 0, 0, 0, 34651, + 0, 0, 0, 34652, 34654, 0, 34657, 34659, + 0, 0, 0, 0, 34662, 0, 34664, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 34666, + 34668, 34670, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 34672, + 0, 0, 0, 0, 0, 0, 0, 34676, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 34677, 34678, 0, 0, 34679, 34680, 34681, 34682, + 34683, 34684, 34685, 34686, 34687, 34688, 34689, 34690, + }}, + {{ + 34691, 34692, 34693, 34694, 34695, 34696, 34697, 34698, + 34699, 34700, 34701, 34702, 34703, 34704, 34705, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, + 34706, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 34708, 34711, 34714, 34715, 0, 34717, 34720, 34723, + 0, 34724, 34726, 34727, 34728, 34729, 34730, 34731, + 34732, 34733, 34734, 34735, 0, 34736, 34737, 0, + 0, 34739, 34740, 34741, 34742, 34743, 0, 0, + }}, + {{ + 34744, 34746, 34749, 0, 34751, 0, 1984, 0, + 34753, 0, 1986, 1987, 34756, 34757, 0, 34758, + 34759, 34760, 0, 34761, 34762, 34763, 34764, 34765, + 34766, 34767, 0, 0, 0, 34768, 34769, 34770, + }}, + {{ + 34771, 0, 0, 0, 0, 34772, 34773, 34774, + 34775, 34776, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 34777, 34780, 34783, 34786, 34789, + 34792, 34795, 34798, 34801, 34804, 34807, 34810, 34813, + }}, + {{ + 34815, 34816, 34818, 34821, 34823, 34824, 34826, 34829, + 34833, 34835, 34836, 34838, 34841, 34842, 34843, 34844, + 34845, 34846, 34848, 34851, 34853, 34854, 34856, 34859, + 34863, 34865, 34866, 34868, 34871, 34872, 34873, 34874, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 2107, 2109, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 2111, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 2113, 2115, 2117, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 2119, 0, 0, 0, + 0, 2121, 0, 0, 2123, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 2125, 0, 2127, 0, + 0, 0, 0, 0, 34897, 34899, 0, 34902, + 34904, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 2139, 0, 0, 2141, 0, 0, 2143, + 0, 2145, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 2147, 0, 2149, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 2151, 2153, 2155, + 2157, 2159, 0, 0, 2161, 2163, 0, 0, + 2165, 2167, 0, 0, 0, 0, 0, 0, + }}, + {{ + 2169, 2171, 0, 0, 2173, 2175, 0, 0, + 2177, 2179, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 2181, 2183, 2185, 2187, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 2189, 2191, 2193, 2195, 0, 0, 0, 0, + 0, 0, 2197, 2199, 2201, 2203, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 2205, 2206, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 34975, 34976, 34977, 34978, 34979, 34980, 34981, 34982, + 34983, 34984, 34986, 34988, 34990, 34992, 34994, 34996, + 34998, 35000, 35002, 35004, 35006, 35009, 35012, 35015, + 35018, 35021, 35024, 35027, 35030, 35033, 35037, 35041, + }}, + {{ + 35045, 35049, 35053, 35057, 35061, 35065, 35069, 35073, + 35077, 35079, 35081, 35083, 35085, 35087, 35089, 35091, + 35093, 35095, 35098, 35101, 35104, 35107, 35110, 35113, + 35116, 35119, 35122, 35125, 35128, 35131, 35134, 35137, + }}, + {{ + 35140, 35143, 35146, 35149, 35152, 35155, 35158, 35161, + 35164, 35167, 35170, 35173, 35176, 35179, 35182, 35185, + 35188, 35191, 35194, 35197, 35200, 35203, 35206, 35207, + 35208, 35209, 35210, 35211, 35212, 35213, 35214, 35215, + }}, + {{ + 35216, 35217, 35218, 35219, 35220, 35221, 35222, 35223, + 35224, 35225, 35226, 35227, 35228, 35229, 35230, 35231, + 35232, 35233, 35234, 35235, 35236, 35237, 35238, 35239, + 35240, 35241, 35242, 35243, 35244, 35245, 35246, 35247, + }}, + {{ + 35248, 35249, 35250, 35251, 35252, 35253, 35254, 35255, + 35256, 35257, 35258, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 35259, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 35263, 35266, 35268, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 2503, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 35273, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 35274, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 35275, 35276, 35277, 35278, 35279, 35280, 35281, 35282, + 35283, 35284, 35285, 35286, 35287, 35288, 35289, 35290, + 35291, 35292, 35293, 35294, 35295, 35296, 35297, 35298, + 35299, 35300, 35301, 35302, 35303, 35304, 35305, 35306, + }}, + {{ + 35307, 35308, 35309, 35310, 35311, 35312, 35313, 35314, + 35315, 35316, 35317, 35318, 35319, 35320, 35321, 35322, + 35323, 35324, 35325, 35326, 35327, 35328, 35329, 35330, + 35331, 35332, 35333, 35334, 35335, 35336, 35337, 35338, + }}, + {{ + 35339, 35340, 35341, 35342, 35343, 35344, 35345, 35346, + 35347, 35348, 35349, 35350, 35351, 35352, 35353, 35354, + 35355, 35356, 35357, 35358, 35359, 35360, 35361, 35362, + 35363, 35364, 35365, 35366, 35367, 35368, 35369, 35370, + }}, + {{ + 35371, 35372, 35373, 35374, 35375, 35376, 35377, 35378, + 35379, 35380, 35381, 35382, 35383, 35384, 35385, 35386, + 35387, 35388, 35389, 35390, 35391, 35392, 35393, 35394, + 35395, 35396, 35397, 35398, 35399, 35400, 35401, 35402, + }}, + {{ + 35403, 35404, 35405, 35406, 35407, 35408, 35409, 35410, + 35411, 35412, 35413, 35414, 35415, 35416, 35417, 35418, + 35419, 35420, 35421, 35422, 35423, 35424, 35425, 35426, + 35427, 35428, 35429, 35430, 35431, 35432, 35433, 35434, + }}, + {{ + 35435, 35436, 35437, 35438, 35439, 35440, 35441, 35442, + 35443, 35444, 35445, 35446, 35447, 35448, 35449, 35450, + 35451, 35452, 35453, 35454, 35455, 35456, 35457, 35458, + 35459, 35460, 35461, 35462, 35463, 35464, 35465, 35466, + }}, + {{ + 35467, 35468, 35469, 35470, 35471, 35472, 35473, 35474, + 35475, 35476, 35477, 35478, 35479, 35480, 35481, 35482, + 35483, 35484, 35485, 35486, 35487, 35488, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 35489, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 35490, 0, + 35491, 35492, 35493, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 2726, 0, 2728, 0, + 2730, 0, 2732, 0, 2734, 0, 2736, 0, + 2738, 0, 2740, 0, 2742, 0, 2744, 0, + }}, + {{ + 2746, 0, 2748, 0, 0, 2750, 0, 2752, + 0, 2754, 0, 0, 0, 0, 0, 0, + 2756, 2758, 0, 2760, 2762, 0, 2764, 2766, + 0, 2768, 2770, 0, 2772, 2774, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 2776, 0, 0, 0, + 0, 0, 0, 35546, 35548, 0, 2782, 35552, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 2786, 0, 2788, 0, + 2790, 0, 2792, 0, 2794, 0, 2796, 0, + 2798, 0, 2800, 0, 2802, 0, 2804, 0, + }}, + {{ + 2806, 0, 2808, 0, 0, 2810, 0, 2812, + 0, 2814, 0, 0, 0, 0, 0, 0, + 2816, 2818, 0, 2820, 2822, 0, 2824, 2826, + 0, 2828, 2830, 0, 2832, 2834, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 2836, 0, 0, 2838, + 2840, 2842, 2844, 0, 0, 0, 2846, 35616, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 35618, 35619, 35620, 35621, 35622, 35623, 35624, + 35625, 35626, 35627, 35628, 35629, 35630, 35631, 35632, + }}, + {{ + 35633, 35634, 35635, 35636, 35637, 35638, 35639, 35640, + 35641, 35642, 35643, 35644, 35645, 35646, 35647, 35648, + 35649, 35650, 35651, 35652, 35653, 35654, 35655, 35656, + 35657, 35658, 35659, 35660, 35661, 35662, 35663, 35664, + }}, + {{ + 35665, 35666, 35667, 35668, 35669, 35670, 35671, 35672, + 35673, 35674, 35675, 35676, 35677, 35678, 35679, 35680, + 35681, 35682, 35683, 35684, 35685, 35686, 35687, 35688, + 35689, 35690, 35691, 35692, 35693, 35694, 35695, 35696, + }}, + {{ + 35697, 35698, 35699, 35700, 35701, 35702, 35703, 35704, + 35705, 35706, 35707, 35708, 35709, 35710, 35711, 0, + 0, 0, 35712, 35713, 35714, 35715, 35716, 35717, + 35718, 35719, 35720, 35721, 35722, 35723, 35724, 35725, + }}, + {{ + 35726, 35729, 35732, 35735, 35738, 35741, 35744, 35747, + 35750, 35753, 35756, 35759, 35762, 35765, 35768, 35772, + 35776, 35780, 35784, 35788, 35792, 35796, 35800, 35804, + 35808, 35812, 35816, 35820, 35824, 0, 0, 0, + }}, + {{ + 35828, 35831, 35834, 35837, 35840, 35843, 35846, 35849, + 35852, 35855, 35858, 35861, 35864, 35867, 35870, 35873, + 35876, 35879, 35882, 35885, 35888, 35891, 35894, 35897, + 35900, 35903, 35906, 35909, 35912, 35915, 35918, 35921, + }}, + {{ + 35924, 35927, 35930, 35933, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 35936, 35938, 35940, 35942, 35944, 35946, 35948, + 35950, 35952, 35954, 35956, 35958, 35960, 35962, 35964, + }}, + {{ + 35966, 35967, 35968, 35969, 35970, 35971, 35972, 35973, + 35974, 35975, 35976, 35977, 35978, 35979, 35980, 35982, + 35984, 35986, 35988, 35990, 35992, 35994, 35996, 35998, + 36000, 36002, 36004, 36006, 0, 0, 0, 0, + }}, + {{ + 36008, 36009, 36010, 36011, 36012, 36013, 36014, 36015, + 36016, 36017, 36018, 36019, 36020, 36021, 36022, 36023, + 36024, 36025, 36026, 36027, 36028, 36029, 36030, 36031, + 36032, 36033, 36034, 36035, 36036, 36037, 36038, 36039, + }}, + {{ + 36040, 36041, 36042, 36043, 36044, 36045, 36046, 36047, + 36048, 36049, 36050, 36051, 36052, 36053, 36054, 36055, + 36056, 36057, 36059, 36061, 36063, 36065, 36067, 36069, + 36071, 36073, 36075, 36077, 36079, 36081, 36083, 36085, + }}, + {{ + 36087, 36089, 36091, 36093, 36095, 36097, 36099, 36101, + 36103, 36105, 36108, 36111, 0, 0, 0, 0, + 36114, 36115, 36116, 36117, 36118, 36119, 36120, 36121, + 36122, 36123, 36124, 36125, 36126, 36127, 36128, 36129, + }}, + {{ + 36130, 36131, 36132, 36133, 36134, 36135, 36136, 36137, + 36138, 36139, 36140, 36141, 36142, 36143, 36144, 36145, + 36146, 36147, 36148, 36149, 36150, 36151, 36152, 36153, + 36154, 36155, 36156, 36157, 36158, 36159, 36160, 0, + }}, + {{ + 36161, 36165, 36169, 36173, 36176, 36180, 36183, 36186, + 36191, 36195, 36198, 36201, 36204, 36208, 36212, 36215, + 36218, 36220, 36223, 36227, 36231, 36233, 36238, 36244, + 36249, 36252, 36257, 36262, 36266, 36269, 36272, 36275, + }}, + {{ + 36279, 36284, 36288, 36291, 36294, 36297, 36299, 36301, + 36303, 36305, 36308, 36311, 36316, 36319, 36323, 36328, + 36331, 36333, 36335, 36340, 36344, 36349, 36352, 36357, + 36359, 36362, 36365, 36368, 36371, 36374, 36378, 36381, + }}, + {{ + 36383, 36386, 36389, 36392, 36396, 36399, 36402, 36405, + 36410, 36414, 36416, 36421, 36423, 36427, 36431, 36434, + 36437, 36440, 36444, 36446, 36449, 36453, 36455, 36460, + 36463, 36465, 36467, 36469, 36471, 36473, 36475, 36477, + }}, + {{ + 36479, 36481, 36483, 36486, 36489, 36492, 36495, 36498, + 36501, 36504, 36507, 36510, 36513, 36516, 36519, 36522, + 36525, 36528, 36531, 36533, 36535, 36538, 36540, 0, + 0, 0, 0, 36542, 36544, 36546, 36548, 36550, + }}, + {{ + 36554, 36556, 36558, 36560, 36562, 36564, 36566, 36568, + 36570, 36573, 36577, 36579, 36581, 36583, 36585, 36587, + 36589, 36591, 36594, 36597, 36600, 36603, 36605, 36607, + 36609, 36611, 36613, 36615, 36617, 36619, 36621, 36623, + }}, + {{ + 36626, 36629, 36631, 36634, 36637, 36640, 36642, 36645, + 36648, 36652, 36654, 36657, 36660, 36663, 36666, 36671, + 36677, 36679, 36681, 36683, 36685, 36687, 36689, 36691, + 36693, 36695, 36697, 36699, 36701, 36703, 36705, 36707, + }}, + {{ + 36709, 36711, 36713, 36717, 36719, 36721, 36723, 36727, + 36730, 36732, 36734, 36736, 36738, 36740, 36742, 36744, + 36746, 36748, 36750, 36753, 36755, 36757, 36760, 36763, + 36765, 36769, 36772, 36774, 36776, 36778, 0, 0, + }}, + {{ + 36780, 36782, 36784, 36786, 36788, 36790, 36792, 36794, + 36796, 36798, 36801, 36804, 36807, 36810, 36813, 36816, + 36819, 36822, 36825, 36828, 36831, 36834, 36837, 36840, + 36843, 36846, 36849, 36852, 36855, 36858, 36861, 0, + }}, + {{ + 4096, 4097, 4098, 4099, 4100, 4101, 4102, 4103, + 4104, 4105, 4106, 4107, 4108, 4109, 4110, 4111, + 4112, 4113, 4114, 4115, 4116, 4117, 4118, 4119, + 4120, 4121, 4122, 4123, 4124, 4125, 4126, 4127, + }}, + {{ + 4128, 4129, 4130, 4131, 4132, 4133, 4134, 4135, + 4136, 4137, 4138, 4139, 4140, 4141, 4142, 4143, + 4144, 4145, 4146, 4147, 4148, 4149, 4150, 4151, + 4152, 4153, 4154, 4155, 4156, 4157, 4158, 4159, + }}, + {{ + 4160, 4161, 4162, 4163, 4164, 4165, 4166, 4167, + 4168, 4169, 4170, 4171, 4172, 4173, 4174, 4175, + 4176, 4177, 4178, 4179, 4180, 4181, 4182, 4183, + 4184, 4185, 4186, 4187, 4188, 4189, 4190, 4191, + }}, + {{ + 4192, 4193, 4194, 4195, 4196, 4197, 4198, 4199, + 4200, 4201, 4202, 4203, 4204, 4205, 4206, 4207, + 4208, 4209, 4210, 4211, 4212, 4213, 4214, 4215, + 4216, 4217, 4218, 4219, 4220, 4221, 4222, 4223, + }}, + {{ + 4224, 4225, 4226, 4227, 4228, 4229, 4230, 4231, + 4232, 4233, 4234, 4235, 4236, 4237, 4238, 4239, + 4240, 4241, 4242, 4243, 4244, 4245, 4246, 4247, + 4248, 4249, 4250, 4251, 4252, 4253, 4254, 4255, + }}, + {{ + 4256, 4257, 4258, 4259, 4260, 4261, 4262, 4263, + 4264, 4265, 4266, 4267, 4268, 4269, 4270, 4271, + 4272, 4273, 4274, 4275, 4276, 4277, 4278, 4279, + 4280, 4281, 4282, 4283, 4284, 4285, 4286, 4287, + }}, + {{ + 4288, 4289, 4290, 4291, 4292, 4293, 4294, 4295, + 4296, 4297, 4298, 4299, 4300, 4301, 4302, 4303, + 4304, 4305, 4306, 4307, 4308, 4309, 4310, 4311, + 4312, 4313, 4314, 4315, 4316, 4317, 4318, 4319, + }}, + {{ + 4320, 4321, 4322, 4323, 4324, 4325, 4326, 4327, + 4328, 4329, 4330, 4331, 4332, 4333, 4334, 4335, + 4336, 4337, 4338, 4339, 4340, 4341, 4342, 4343, + 4344, 4345, 4346, 4347, 4348, 4349, 4350, 4351, + }}, + {{ + 4352, 4353, 4354, 4355, 4356, 4357, 4358, 4359, + 4360, 4361, 4362, 4363, 4364, 4365, 0, 0, + 4366, 0, 4367, 0, 0, 4368, 4369, 4370, + 4371, 4372, 4373, 4374, 4375, 4376, 4377, 0, + }}, + {{ + 4378, 0, 4379, 0, 0, 4380, 4381, 0, + 0, 0, 4382, 4383, 4384, 4385, 0, 0, + 4386, 4387, 4388, 4389, 4390, 4391, 4392, 4393, + 4394, 4395, 4396, 4397, 4398, 4399, 4400, 4401, + }}, + {{ + 4402, 4403, 4404, 4405, 4406, 4407, 4408, 4409, + 4410, 4411, 4412, 4413, 4414, 4415, 4416, 4417, + 4418, 4419, 4420, 4421, 4422, 4423, 4424, 4425, + 4426, 4427, 4428, 4429, 4430, 4431, 4432, 4433, + }}, + {{ + 4434, 4435, 4436, 4437, 4438, 4439, 4440, 4441, + 4442, 4443, 4444, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 37213, 37215, 37217, 37219, 37222, 37225, 37227, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 37229, 37231, 37233, 37235, 37237, + 0, 0, 0, 0, 0, 4471, 0, 4473, + }}, + {{ + 37243, 37244, 37245, 37246, 37247, 37248, 37249, 37250, + 37251, 37252, 4485, 4487, 4489, 4491, 4493, 4495, + 4497, 4499, 4501, 4503, 4505, 4507, 4509, 0, + 4511, 4513, 4515, 4517, 4519, 0, 4521, 0, + }}, + {{ + 4523, 4525, 0, 4527, 4529, 0, 4531, 4533, + 4535, 4537, 4539, 4541, 4543, 4545, 4547, 37317, + 37319, 37320, 37321, 37322, 37323, 37324, 37325, 37326, + 37327, 37328, 37329, 37330, 37331, 37332, 37333, 37334, + }}, + {{ + 37335, 37336, 37337, 37338, 37339, 37340, 37341, 37342, + 37343, 37344, 37345, 37346, 37347, 37348, 37349, 37350, + 37351, 37352, 37353, 37354, 37355, 37356, 37357, 37358, + 37359, 37360, 37361, 37362, 37363, 37364, 37365, 37366, + }}, + {{ + 37367, 37368, 37369, 37370, 37371, 37372, 37373, 37374, + 37375, 37376, 37377, 37378, 37379, 37380, 37381, 37382, + 37383, 37384, 37385, 37386, 37387, 37388, 37389, 37390, + 37391, 37392, 37393, 37394, 37395, 37396, 37397, 37398, + }}, + {{ + 37399, 37400, 37401, 37402, 37403, 37404, 37405, 37406, + 37407, 37408, 37409, 37410, 37411, 37412, 37413, 37414, + 37415, 37416, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 37417, 37418, 37419, 37420, 37421, + 37422, 37423, 37424, 37425, 37426, 37427, 37428, 37429, + }}, + {{ + 37430, 37431, 37432, 37433, 37434, 37435, 37436, 37437, + 37438, 37439, 37440, 37442, 37444, 37446, 37448, 37450, + 37452, 37454, 37456, 37458, 37460, 37462, 37464, 37466, + 37468, 37470, 37472, 37474, 37476, 37477, 37478, 37479, + }}, + {{ + 37480, 37482, 37484, 37486, 37488, 37490, 37492, 37494, + 37496, 37498, 37500, 37502, 37504, 37506, 37508, 37510, + 37512, 37514, 37516, 37518, 37520, 37522, 37524, 37526, + 37528, 37530, 37532, 37534, 37536, 37538, 37540, 37542, + }}, + {{ + 37544, 37546, 37548, 37550, 37552, 37554, 37556, 37558, + 37560, 37562, 37564, 37566, 37568, 37570, 37572, 37574, + 37576, 37578, 37580, 37582, 37584, 37586, 37588, 37590, + 37592, 37594, 37596, 37598, 37600, 37602, 37604, 37606, + }}, + {{ + 37608, 37610, 37612, 37614, 37616, 37618, 37620, 37622, + 37624, 37626, 37628, 37630, 37632, 37634, 37636, 37638, + 37640, 37642, 37644, 37646, 37648, 37650, 37652, 37654, + 37656, 37658, 37660, 37662, 37664, 37666, 37668, 37671, + }}, + {{ + 37674, 37677, 37680, 37683, 37686, 37688, 37690, 37692, + 37694, 37696, 37698, 37700, 37702, 37704, 37706, 37708, + 37710, 37712, 37714, 37716, 37718, 37720, 37722, 37724, + 37726, 37728, 37730, 37732, 37734, 37736, 37738, 37740, + }}, + {{ + 37742, 37744, 37746, 37748, 37750, 37752, 37754, 37756, + 37758, 37760, 37762, 37764, 37766, 37768, 37770, 37772, + 37774, 37776, 37778, 37780, 37782, 37784, 37786, 37788, + 37790, 37792, 37794, 37796, 37798, 37800, 37802, 37804, + }}, + {{ + 37806, 37808, 37810, 37812, 37814, 37816, 37818, 37820, + 37822, 37824, 37826, 37828, 37830, 37832, 37834, 37836, + 37838, 37840, 37842, 37844, 37846, 37848, 37850, 37852, + 37854, 37856, 37858, 37860, 37862, 37864, 37866, 37868, + }}, + {{ + 37870, 37872, 37874, 37876, 37878, 37880, 37882, 37884, + 37886, 37888, 37890, 37892, 37894, 37896, 37898, 37900, + 37902, 37904, 37906, 37908, 37910, 37912, 37914, 37916, + 37918, 37920, 37922, 37924, 37926, 37928, 37930, 37932, + }}, + {{ + 37934, 37936, 37938, 37940, 37942, 37944, 37946, 37948, + 37950, 37952, 37954, 37956, 37958, 37960, 37962, 37964, + 37966, 37968, 37970, 37973, 37976, 37979, 37981, 37983, + 37985, 37987, 37989, 37991, 37993, 37995, 37997, 37999, + }}, + {{ + 38001, 38003, 38005, 38007, 38009, 38011, 38013, 38015, + 38017, 38019, 38021, 38023, 38025, 38027, 38029, 38031, + 38033, 38035, 38037, 38039, 38041, 38043, 38045, 38047, + 38049, 38051, 38053, 38055, 38057, 38059, 38061, 38063, + }}, + {{ + 38065, 38067, 38069, 38071, 38073, 38075, 38077, 38079, + 38081, 38083, 38085, 38087, 38089, 38091, 38093, 38095, + 38097, 38099, 38101, 38103, 38105, 38107, 38109, 38111, + 38113, 38115, 38117, 38119, 38121, 38123, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 38125, 38128, 38131, 38134, 38137, 38140, 38143, 38146, + 38149, 38152, 38155, 38158, 38161, 38164, 38167, 38170, + }}, + {{ + 38173, 38176, 38179, 38182, 38185, 38188, 38191, 38194, + 38197, 38200, 38203, 38206, 38209, 38212, 38215, 38218, + 38221, 38224, 38227, 38230, 38233, 38236, 38239, 38242, + 38245, 38248, 38251, 38254, 38257, 38260, 38263, 38266, + }}, + {{ + 38269, 38272, 38275, 38278, 38281, 38284, 38287, 38290, + 38293, 38296, 38299, 38302, 38305, 38308, 38311, 38314, + 0, 0, 38317, 38320, 38323, 38326, 38329, 38332, + 38335, 38338, 38341, 38344, 38347, 38350, 38353, 38356, + }}, + {{ + 38359, 38362, 38365, 38368, 38371, 38374, 38377, 38380, + 38383, 38386, 38389, 38392, 38395, 38398, 38401, 38404, + 38407, 38410, 38413, 38416, 38419, 38422, 38425, 38428, + 38431, 38434, 38437, 38440, 38443, 38446, 38449, 38452, + }}, + {{ + 38455, 38458, 38461, 38464, 38467, 38470, 38473, 38476, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 38479, 38482, 38485, 38489, 38493, 38497, 38501, 38505, + 38509, 38513, 38516, 38534, 38542, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 38546, 38547, 38548, 38549, 38550, 38551, 38552, 38553, + 38554, 38555, 38556, 38557, 38558, 38559, 38560, 38561, + }}, + {{ + 38562, 38563, 38564, 38565, 38566, 0, 0, 0, + 0, 38567, 38568, 38569, 38570, 38571, 38572, 38573, + 38574, 38575, 38576, 0, 38577, 38578, 38579, 38580, + 38581, 38582, 38583, 38584, 38585, 38586, 38587, 38588, + }}, + {{ + 38589, 38590, 38591, 38592, 38593, 38594, 38595, 0, + 38596, 38597, 38598, 38599, 0, 0, 0, 0, + 38600, 38602, 38604, 0, 38606, 0, 38608, 38610, + 38612, 38614, 38616, 38618, 38620, 38622, 38624, 38626, + }}, + {{ + 38628, 38629, 38630, 38631, 38632, 38633, 38634, 38635, + 38636, 38637, 38638, 38639, 38640, 38641, 38642, 38643, + 38644, 38645, 38646, 38647, 38648, 38649, 38650, 38651, + 38652, 38653, 38654, 38655, 38656, 38657, 38658, 38659, + }}, + {{ + 38660, 38661, 38662, 38663, 38664, 38665, 38666, 38667, + 38668, 38669, 38670, 38671, 38672, 38673, 38674, 38675, + 38676, 38677, 38678, 38679, 38680, 38681, 38682, 38683, + 38684, 38685, 38686, 38687, 38688, 38689, 38690, 38691, + }}, + {{ + 38692, 38693, 38694, 38695, 38696, 38697, 38698, 38699, + 38700, 38701, 38702, 38703, 38704, 38705, 38706, 38707, + 38708, 38709, 38710, 38711, 38712, 38713, 38714, 38715, + 38716, 38717, 38718, 38719, 38720, 38721, 38722, 38723, + }}, + {{ + 38724, 38725, 38726, 38727, 38728, 38729, 38730, 38731, + 38732, 38733, 38734, 38735, 38736, 38737, 38738, 38739, + 38740, 38741, 38742, 38743, 38744, 38745, 38747, 38749, + 38751, 38753, 38755, 38757, 38759, 0, 0, 0, + }}, + {{ + 0, 38761, 38762, 38763, 38764, 38765, 38766, 38767, + 38768, 38769, 38770, 38771, 38772, 38773, 38774, 38775, + 38776, 38777, 38778, 38779, 38780, 38781, 38782, 38783, + 38784, 38785, 38786, 38787, 38788, 38789, 38790, 38791, + }}, + {{ + 38792, 38793, 38794, 38795, 38796, 38797, 38798, 38799, + 38800, 38801, 38802, 38803, 38804, 38805, 38806, 38807, + 38808, 38809, 38810, 38811, 38812, 38813, 38814, 38815, + 38816, 38817, 38818, 38819, 38820, 38821, 38822, 38823, + }}, + {{ + 38824, 38825, 38826, 38827, 38828, 38829, 38830, 38831, + 38832, 38833, 38834, 38835, 38836, 38837, 38838, 38839, + 38840, 38841, 38842, 38843, 38844, 38845, 38846, 38847, + 38848, 38849, 38850, 38851, 38852, 38853, 38854, 38855, + }}, + {{ + 38856, 38857, 38858, 38859, 38860, 38861, 38862, 38863, + 38864, 38865, 38866, 38867, 38868, 38869, 38870, 38871, + 38872, 38873, 38874, 38875, 38876, 38877, 38878, 38879, + 38880, 38881, 38882, 38883, 38884, 38885, 38886, 38887, + }}, + {{ + 38888, 38889, 38890, 38891, 38892, 38893, 38894, 38895, + 38896, 38897, 38898, 38899, 38900, 38901, 38902, 38903, + 38904, 38905, 38906, 38907, 38908, 38909, 38910, 38911, + 38912, 38913, 38914, 38915, 38916, 38917, 38918, 38919, + }}, + {{ + 38920, 38921, 38922, 38923, 38924, 38925, 38926, 38927, + 38928, 38929, 38930, 38931, 38932, 38933, 38934, 38935, + 38936, 38937, 38938, 38939, 38940, 38941, 38942, 38943, + 38944, 38945, 38946, 38947, 38948, 38949, 38950, 0, + }}, + {{ + 0, 0, 38951, 38952, 38953, 38954, 38955, 38956, + 0, 0, 38957, 38958, 38959, 38960, 38961, 38962, + 0, 0, 38963, 38964, 38965, 38966, 38967, 38968, + 0, 0, 38969, 38970, 38971, 0, 0, 0, + }}, + {{ + 38972, 38973, 38974, 38975, 38976, 38977, 38978, 0, + 38979, 38980, 38981, 38982, 38983, 38984, 38985, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 6218, 6220, + }}, + {{ + 6222, 6224, 6226, 6228, 6230, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 6232, 6234, 6236, 6238, 6240, + }}, + {{ + 6242, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 39012, 39013, 39014, 39015, 39016, 39017, 39018, 39019, + 39020, 39021, 39022, 39023, 39024, 39025, 39026, 39027, + 39028, 39029, 39030, 39031, 39032, 39033, 39034, 39035, + 39036, 39037, 39038, 39039, 39040, 39041, 39042, 39043, + }}, + {{ + 39044, 39045, 39046, 39047, 39048, 39049, 39050, 39051, + 39052, 39053, 39054, 39055, 39056, 39057, 39058, 39059, + 39060, 39061, 39062, 39063, 39064, 39065, 39066, 39067, + 39068, 39069, 39070, 39071, 39072, 39073, 39074, 39075, + }}, + {{ + 39076, 39077, 39078, 39079, 39080, 39081, 39082, 39083, + 39084, 39085, 39086, 39087, 39088, 39089, 39090, 39091, + 39092, 39093, 39094, 39095, 39096, 0, 39097, 39098, + 39099, 39100, 39101, 39102, 39103, 39104, 39105, 39106, + }}, + {{ + 39107, 39108, 39109, 39110, 39111, 39112, 39113, 39114, + 39115, 39116, 39117, 39118, 39119, 39120, 39121, 39122, + 39123, 39124, 39125, 39126, 39127, 39128, 39129, 39130, + 39131, 39132, 39133, 39134, 39135, 39136, 39137, 39138, + }}, + {{ + 39139, 39140, 39141, 39142, 39143, 39144, 39145, 39146, + 39147, 39148, 39149, 39150, 39151, 39152, 39153, 39154, + 39155, 39156, 39157, 39158, 39159, 39160, 39161, 39162, + 39163, 39164, 39165, 39166, 39167, 0, 39168, 39169, + }}, + {{ + 0, 0, 39170, 0, 0, 39171, 39172, 0, + 0, 39173, 39174, 39175, 39176, 0, 39177, 39178, + 39179, 39180, 39181, 39182, 39183, 39184, 39185, 39186, + 39187, 39188, 0, 39189, 0, 39190, 39191, 39192, + }}, + {{ + 39193, 0, 39194, 39195, 0, 39196, 39197, 39198, + 39199, 39200, 39201, 39202, 39203, 39204, 39205, 39206, + 39207, 39208, 39209, 39210, 39211, 39212, 39213, 39214, + 39215, 39216, 39217, 39218, 39219, 39220, 39221, 39222, + }}, + {{ + 39223, 39224, 39225, 39226, 39227, 39228, 39229, 39230, + 39231, 39232, 39233, 39234, 39235, 39236, 39237, 39238, + 39239, 39240, 39241, 39242, 39243, 39244, 39245, 39246, + 39247, 39248, 39249, 39250, 39251, 39252, 39253, 39254, + }}, + {{ + 39255, 39256, 39257, 39258, 39259, 39260, 0, 39261, + 39262, 39263, 39264, 0, 0, 39265, 39266, 39267, + 39268, 39269, 39270, 39271, 39272, 0, 39273, 39274, + 39275, 39276, 39277, 39278, 39279, 0, 39280, 39281, + }}, + {{ + 39282, 39283, 39284, 39285, 39286, 39287, 39288, 39289, + 39290, 39291, 39292, 39293, 39294, 39295, 39296, 39297, + 39298, 39299, 39300, 39301, 39302, 39303, 39304, 39305, + 39306, 39307, 0, 39308, 39309, 39310, 39311, 0, + }}, + {{ + 39312, 39313, 39314, 39315, 39316, 0, 39317, 0, + 0, 0, 39318, 39319, 39320, 39321, 39322, 39323, + 39324, 0, 39325, 39326, 39327, 39328, 39329, 39330, + 39331, 39332, 39333, 39334, 39335, 39336, 39337, 39338, + }}, + {{ + 39339, 39340, 39341, 39342, 39343, 39344, 39345, 39346, + 39347, 39348, 39349, 39350, 39351, 39352, 39353, 39354, + 39355, 39356, 39357, 39358, 39359, 39360, 39361, 39362, + 39363, 39364, 39365, 39366, 39367, 39368, 39369, 39370, + }}, + {{ + 39371, 39372, 39373, 39374, 39375, 39376, 39377, 39378, + 39379, 39380, 39381, 39382, 39383, 39384, 39385, 39386, + 39387, 39388, 39389, 39390, 39391, 39392, 39393, 39394, + 39395, 39396, 39397, 39398, 39399, 39400, 39401, 39402, + }}, + {{ + 39403, 39404, 39405, 39406, 39407, 39408, 39409, 39410, + 39411, 39412, 39413, 39414, 39415, 39416, 39417, 39418, + 39419, 39420, 39421, 39422, 39423, 39424, 39425, 39426, + 39427, 39428, 39429, 39430, 39431, 39432, 39433, 39434, + }}, + {{ + 39435, 39436, 39437, 39438, 39439, 39440, 39441, 39442, + 39443, 39444, 39445, 39446, 39447, 39448, 39449, 39450, + 39451, 39452, 39453, 39454, 39455, 39456, 39457, 39458, + 39459, 39460, 39461, 39462, 39463, 39464, 39465, 39466, + }}, + {{ + 39467, 39468, 39469, 39470, 39471, 39472, 39473, 39474, + 39475, 39476, 39477, 39478, 39479, 39480, 39481, 39482, + 39483, 39484, 39485, 39486, 39487, 39488, 39489, 39490, + 39491, 39492, 39493, 39494, 39495, 39496, 39497, 39498, + }}, + {{ + 39499, 39500, 39501, 39502, 39503, 39504, 39505, 39506, + 39507, 39508, 39509, 39510, 39511, 39512, 39513, 39514, + 39515, 39516, 39517, 39518, 39519, 39520, 39521, 39522, + 39523, 39524, 39525, 39526, 39527, 39528, 39529, 39530, + }}, + {{ + 39531, 39532, 39533, 39534, 39535, 39536, 39537, 39538, + 39539, 39540, 39541, 39542, 39543, 39544, 39545, 39546, + 39547, 39548, 39549, 39550, 39551, 39552, 39553, 39554, + 39555, 39556, 39557, 39558, 39559, 39560, 39561, 39562, + }}, + {{ + 39563, 39564, 39565, 39566, 39567, 39568, 39569, 39570, + 39571, 39572, 39573, 39574, 39575, 39576, 39577, 39578, + 39579, 39580, 39581, 39582, 39583, 39584, 39585, 39586, + 39587, 39588, 39589, 39590, 39591, 39592, 39593, 39594, + }}, + {{ + 39595, 39596, 39597, 39598, 39599, 39600, 39601, 39602, + 39603, 39604, 39605, 39606, 39607, 39608, 39609, 39610, + 39611, 39612, 39613, 39614, 39615, 39616, 39617, 39618, + 39619, 39620, 39621, 39622, 39623, 39624, 39625, 39626, + }}, + {{ + 39627, 39628, 39629, 39630, 39631, 39632, 39633, 39634, + 39635, 39636, 39637, 39638, 39639, 39640, 39641, 39642, + 39643, 39644, 39645, 39646, 39647, 39648, 39649, 39650, + 39651, 39652, 39653, 39654, 39655, 39656, 39657, 39658, + }}, + {{ + 39659, 39660, 39661, 39662, 0, 0, 0, 0, + 39663, 39664, 39665, 39666, 39667, 39668, 39669, 39670, + 39671, 39672, 39673, 39674, 39675, 39676, 39677, 39678, + 39679, 39680, 39681, 39682, 39683, 39684, 39685, 39686, + }}, + {{ + 39687, 39688, 39689, 39690, 39691, 39692, 39693, 39694, + 39695, 39696, 39697, 39698, 39699, 39700, 39701, 39702, + 39703, 39704, 39705, 39706, 39707, 39708, 39709, 39710, + 39711, 39712, 39713, 39714, 39715, 39716, 39717, 39718, + }}, + {{ + 39719, 39720, 39721, 39722, 39723, 39724, 39725, 39726, + 39727, 39728, 39729, 39730, 39731, 39732, 39733, 39734, + 39735, 39736, 39737, 39738, 39739, 39740, 39741, 39742, + 39743, 39744, 39745, 39746, 39747, 39748, 39749, 39750, + }}, + {{ + 39751, 39752, 39753, 39754, 39755, 39756, 39757, 39758, + 39759, 39760, 39761, 39762, 39763, 39764, 39765, 39766, + 39767, 39768, 39769, 39770, 39771, 39772, 39773, 39774, + 39775, 39776, 39777, 39778, 39779, 39780, 39781, 39782, + }}, + {{ + 39783, 39784, 39785, 39786, 39787, 39788, 39789, 39790, + 39791, 39792, 39793, 39794, 39795, 39796, 39797, 39798, + 39799, 39800, 39801, 39802, 39803, 39804, 39805, 39806, + 39807, 39808, 39809, 39810, 39811, 39812, 39813, 39814, + }}, + {{ + 39815, 39816, 39817, 39818, 39819, 39820, 39821, 39822, + 39823, 39824, 39825, 39826, 39827, 39828, 39829, 39830, + 39831, 39832, 39833, 39834, 39835, 39836, 39837, 39838, + 39839, 39840, 39841, 39842, 39843, 39844, 39845, 39846, + }}, + {{ + 39847, 39848, 39849, 39850, 39851, 39852, 39853, 39854, + 39855, 39856, 39857, 39858, 39859, 39860, 39861, 39862, + 39863, 39864, 39865, 39866, 39867, 39868, 39869, 39870, + 39871, 39872, 39873, 39874, 39875, 39876, 39877, 39878, + }}, + {{ + 39879, 39880, 39881, 39882, 39883, 39884, 39885, 39886, + 39887, 39888, 39889, 39890, 39891, 39892, 39893, 39894, + 39895, 39896, 39897, 39898, 39899, 39900, 39901, 39902, + 39903, 39904, 39905, 39906, 39907, 39908, 39909, 39910, + }}, + {{ + 39911, 39912, 39913, 39914, 39915, 39916, 39917, 39918, + 39919, 39920, 39921, 39922, 39923, 39924, 39925, 39926, + 39927, 39928, 39929, 39930, 39931, 39932, 39933, 39934, + 39935, 39936, 39937, 39938, 39939, 39940, 39941, 39942, + }}, + {{ + 39943, 39944, 39945, 39946, 39947, 39948, 39949, 39950, + 39951, 39952, 0, 0, 0, 0, 39953, 39954, + 39955, 39956, 39957, 39958, 39959, 39960, 39961, 39962, + 39963, 39964, 39965, 39966, 39967, 39968, 39969, 39970, + }}, + {{ + 39971, 39972, 39973, 39974, 39975, 39976, 39977, 39978, + 39979, 39980, 39981, 39982, 39983, 39984, 39985, 39986, + 39987, 39988, 39989, 39990, 39991, 39992, 39993, 39994, + 39995, 39996, 39997, 39998, 39999, 40000, 40001, 40002, + }}, + {{ + 7235, 7236, 7237, 7238, 7239, 7240, 7241, 7242, + 7243, 7244, 7245, 7246, 7247, 7248, 7249, 7250, + 7251, 7252, 7253, 7254, 7255, 7256, 7257, 7258, + 7259, 7260, 7261, 7262, 7263, 7264, 7265, 7266, + }}, + {{ + 7267, 7268, 7269, 7270, 7271, 7272, 7273, 7274, + 7275, 7276, 7277, 7278, 7279, 7280, 7281, 7282, + 7283, 7284, 7285, 7286, 7287, 7288, 7289, 7290, + 7291, 7292, 7293, 7294, 7295, 7296, 7297, 7298, + }}, + {{ + 7299, 7300, 7301, 7302, 7303, 7304, 7305, 7306, + 7307, 7308, 7309, 7310, 7311, 7312, 7313, 7314, + 7315, 7316, 7317, 7318, 7319, 7320, 7321, 7322, + 7323, 7324, 7325, 7326, 7327, 7328, 7329, 7330, + }}, + {{ + 7331, 7332, 7333, 7334, 7335, 7336, 7337, 7338, + 7339, 7340, 7341, 7342, 7343, 7344, 7345, 7346, + 7347, 7348, 7349, 7350, 7351, 7352, 7353, 7354, + 7355, 7356, 7357, 7358, 7359, 7360, 7361, 7362, + }}, + {{ + 7363, 7364, 7365, 7366, 7367, 7368, 7369, 7370, + 7371, 7372, 7373, 7374, 7375, 7376, 7377, 7378, + 7379, 7380, 7381, 7382, 7383, 7384, 7385, 7386, + 7387, 7388, 7389, 7390, 7391, 7392, 7393, 7394, + }}, + {{ + 7395, 7396, 7397, 7398, 7399, 7400, 7401, 7402, + 7403, 7404, 7405, 7406, 7407, 7408, 7409, 7410, + 7411, 7412, 7413, 7414, 7415, 7416, 7417, 7418, + 7419, 7420, 7421, 7422, 7423, 7424, 7425, 7426, + }}, + {{ + 7427, 7428, 7429, 7430, 7431, 7432, 7433, 7434, + 7435, 7436, 7437, 7438, 7439, 7440, 7441, 7442, + 7443, 7444, 7445, 7446, 7447, 7448, 7449, 7450, + 7451, 7452, 7453, 7454, 7455, 7456, 7457, 7458, + }}, + {{ + 7459, 7460, 7461, 7462, 7463, 7464, 7465, 7466, + 7467, 7468, 7469, 7470, 7471, 7472, 7473, 7474, + 7475, 7476, 7477, 7478, 7479, 7480, 7481, 7482, + 7483, 7484, 7485, 7486, 7487, 7488, 7489, 7490, + }}, + {{ + 7491, 7492, 7493, 7494, 7495, 7496, 7497, 7498, + 7499, 7500, 7501, 7502, 7503, 7504, 7505, 7506, + 7507, 7508, 7509, 7510, 7511, 7512, 7513, 7514, + 7515, 7516, 7517, 7518, 7519, 7520, 7521, 7522, + }}, + {{ + 7523, 7524, 7525, 7526, 7527, 7528, 7529, 7530, + 7531, 7532, 7533, 7534, 7535, 7536, 7537, 7538, + 7539, 7540, 7541, 7542, 7543, 7544, 7545, 7546, + 7547, 7548, 7549, 7550, 7551, 7552, 7553, 7554, + }}, + {{ + 7555, 7556, 7557, 7558, 7559, 7560, 7561, 7562, + 7563, 7564, 7565, 7566, 7567, 7568, 7569, 7570, + 7571, 7572, 7573, 7574, 7575, 7576, 7577, 7578, + 7579, 7580, 7581, 7582, 7583, 7584, 7585, 7586, + }}, + {{ + 7587, 7588, 7589, 7590, 7591, 7592, 7593, 7594, + 7595, 7596, 7597, 7598, 7599, 7600, 7601, 7602, + 7603, 7604, 7605, 7606, 7607, 7608, 7609, 7610, + 7611, 7612, 7613, 7614, 7615, 7616, 7617, 7618, + }}, + {{ + 7619, 7620, 7621, 7622, 7623, 7624, 7625, 7626, + 7627, 7628, 7629, 7630, 7631, 7632, 7633, 7634, + 7635, 7636, 7637, 7638, 7639, 7640, 7641, 7642, + 7643, 7644, 7645, 7646, 7647, 7648, 7649, 7650, + }}, + {{ + 7651, 7652, 7653, 7654, 7655, 7656, 7657, 7658, + 7659, 7660, 7661, 7662, 7663, 7664, 7665, 7666, + 7667, 7668, 7669, 7670, 7671, 7672, 7673, 7674, + 7675, 7676, 7677, 7678, 7679, 7680, 7681, 7682, + }}, + {{ + 7683, 7684, 7685, 7686, 7687, 7688, 7689, 7690, + 7691, 7692, 7693, 7694, 7695, 7696, 7697, 7698, + 7699, 7700, 7701, 7702, 7703, 7704, 7705, 7706, + 7707, 7708, 7709, 7710, 7711, 7712, 7713, 7714, + }}, + {{ + 7715, 7716, 7717, 7718, 7719, 7720, 7721, 7722, + 7723, 7724, 7725, 7726, 7727, 7728, 7729, 7730, + 7731, 7732, 7733, 7734, 7735, 7736, 7737, 7738, + 7739, 7740, 7741, 7742, 7743, 7744, 7745, 7746, + }}, + {{ + 7747, 7748, 7749, 7750, 7751, 7752, 7753, 7754, + 7755, 7756, 7757, 7758, 7759, 7760, 7761, 7762, + 7763, 7764, 7765, 7766, 7767, 7768, 7769, 7770, + 7771, 7772, 7773, 7774, 7775, 7776, 0, 0, + }}, +}; +static const unsigned long v320_decompose_seq[] = { + 0x00000000, 0x80000020, 0x00000020, 0x80000308, + 0x80000061, 0x00000020, 0x80000304, 0x80000032, + 0x80000033, 0x00000020, 0x80000301, 0x800003bc, + 0x00000020, 0x80000327, 0x80000031, 0x8000006f, + 0x00000031, 0x00002044, 0x80000034, 0x00000031, + 0x00002044, 0x80000032, 0x00000033, 0x00002044, + 0x80000034, 0x00000041, 0x80000300, 0x00000041, + 0x80000301, 0x00000041, 0x80000302, 0x00000041, + 0x80000303, 0x00000041, 0x80000308, 0x00000041, + 0x8000030a, 0x00000043, 0x80000327, 0x00000045, + 0x80000300, 0x00000045, 0x80000301, 0x00000045, + 0x80000302, 0x00000045, 0x80000308, 0x00000049, + 0x80000300, 0x00000049, 0x80000301, 0x00000049, + 0x80000302, 0x00000049, 0x80000308, 0x0000004e, + 0x80000303, 0x0000004f, 0x80000300, 0x0000004f, + 0x80000301, 0x0000004f, 0x80000302, 0x0000004f, + 0x80000303, 0x0000004f, 0x80000308, 0x00000055, + 0x80000300, 0x00000055, 0x80000301, 0x00000055, + 0x80000302, 0x00000055, 0x80000308, 0x00000059, + 0x80000301, 0x00000061, 0x80000300, 0x00000061, + 0x80000301, 0x00000061, 0x80000302, 0x00000061, + 0x80000303, 0x00000061, 0x80000308, 0x00000061, + 0x8000030a, 0x00000063, 0x80000327, 0x00000065, + 0x80000300, 0x00000065, 0x80000301, 0x00000065, + 0x80000302, 0x00000065, 0x80000308, 0x00000069, + 0x80000300, 0x00000069, 0x80000301, 0x00000069, + 0x80000302, 0x00000069, 0x80000308, 0x0000006e, + 0x80000303, 0x0000006f, 0x80000300, 0x0000006f, + 0x80000301, 0x0000006f, 0x80000302, 0x0000006f, + 0x80000303, 0x0000006f, 0x80000308, 0x00000075, + 0x80000300, 0x00000075, 0x80000301, 0x00000075, + 0x80000302, 0x00000075, 0x80000308, 0x00000079, + 0x80000301, 0x00000079, 0x80000308, 0x00000041, + 0x80000304, 0x00000061, 0x80000304, 0x00000041, + 0x80000306, 0x00000061, 0x80000306, 0x00000041, + 0x80000328, 0x00000061, 0x80000328, 0x00000043, + 0x80000301, 0x00000063, 0x80000301, 0x00000043, + 0x80000302, 0x00000063, 0x80000302, 0x00000043, + 0x80000307, 0x00000063, 0x80000307, 0x00000043, + 0x8000030c, 0x00000063, 0x8000030c, 0x00000044, + 0x8000030c, 0x00000064, 0x8000030c, 0x00000045, + 0x80000304, 0x00000065, 0x80000304, 0x00000045, + 0x80000306, 0x00000065, 0x80000306, 0x00000045, + 0x80000307, 0x00000065, 0x80000307, 0x00000045, + 0x80000328, 0x00000065, 0x80000328, 0x00000045, + 0x8000030c, 0x00000065, 0x8000030c, 0x00000047, + 0x80000302, 0x00000067, 0x80000302, 0x00000047, + 0x80000306, 0x00000067, 0x80000306, 0x00000047, + 0x80000307, 0x00000067, 0x80000307, 0x00000047, + 0x80000327, 0x00000067, 0x80000327, 0x00000048, + 0x80000302, 0x00000068, 0x80000302, 0x00000049, + 0x80000303, 0x00000069, 0x80000303, 0x00000049, + 0x80000304, 0x00000069, 0x80000304, 0x00000049, + 0x80000306, 0x00000069, 0x80000306, 0x00000049, + 0x80000328, 0x00000069, 0x80000328, 0x00000049, + 0x80000307, 0x00000049, 0x8000004a, 0x00000069, + 0x8000006a, 0x0000004a, 0x80000302, 0x0000006a, + 0x80000302, 0x0000004b, 0x80000327, 0x0000006b, + 0x80000327, 0x0000004c, 0x80000301, 0x0000006c, + 0x80000301, 0x0000004c, 0x80000327, 0x0000006c, + 0x80000327, 0x0000004c, 0x8000030c, 0x0000006c, + 0x8000030c, 0x0000004c, 0x800000b7, 0x0000006c, + 0x800000b7, 0x0000004e, 0x80000301, 0x0000006e, + 0x80000301, 0x0000004e, 0x80000327, 0x0000006e, + 0x80000327, 0x0000004e, 0x8000030c, 0x0000006e, + 0x8000030c, 0x000002bc, 0x8000006e, 0x0000004f, + 0x80000304, 0x0000006f, 0x80000304, 0x0000004f, + 0x80000306, 0x0000006f, 0x80000306, 0x0000004f, + 0x8000030b, 0x0000006f, 0x8000030b, 0x00000052, + 0x80000301, 0x00000072, 0x80000301, 0x00000052, + 0x80000327, 0x00000072, 0x80000327, 0x00000052, + 0x8000030c, 0x00000072, 0x8000030c, 0x00000053, + 0x80000301, 0x00000073, 0x80000301, 0x00000053, + 0x80000302, 0x00000073, 0x80000302, 0x00000053, + 0x80000327, 0x00000073, 0x80000327, 0x00000053, + 0x8000030c, 0x00000073, 0x8000030c, 0x00000054, + 0x80000327, 0x00000074, 0x80000327, 0x00000054, + 0x8000030c, 0x00000074, 0x8000030c, 0x00000055, + 0x80000303, 0x00000075, 0x80000303, 0x00000055, + 0x80000304, 0x00000075, 0x80000304, 0x00000055, + 0x80000306, 0x00000075, 0x80000306, 0x00000055, + 0x8000030a, 0x00000075, 0x8000030a, 0x00000055, + 0x8000030b, 0x00000075, 0x8000030b, 0x00000055, + 0x80000328, 0x00000075, 0x80000328, 0x00000057, + 0x80000302, 0x00000077, 0x80000302, 0x00000059, + 0x80000302, 0x00000079, 0x80000302, 0x00000059, + 0x80000308, 0x0000005a, 0x80000301, 0x0000007a, + 0x80000301, 0x0000005a, 0x80000307, 0x0000007a, + 0x80000307, 0x0000005a, 0x8000030c, 0x0000007a, + 0x8000030c, 0x80000073, 0x0000004f, 0x8000031b, + 0x0000006f, 0x8000031b, 0x00000055, 0x8000031b, + 0x00000075, 0x8000031b, 0x00000044, 0x8000017d, + 0x00000044, 0x8000017e, 0x00000064, 0x8000017e, + 0x0000004c, 0x8000004a, 0x0000004c, 0x8000006a, + 0x0000006c, 0x8000006a, 0x0000004e, 0x8000004a, + 0x0000004e, 0x8000006a, 0x0000006e, 0x8000006a, + 0x00000041, 0x8000030c, 0x00000061, 0x8000030c, + 0x00000049, 0x8000030c, 0x00000069, 0x8000030c, + 0x0000004f, 0x8000030c, 0x0000006f, 0x8000030c, + 0x00000055, 0x8000030c, 0x00000075, 0x8000030c, + 0x000000dc, 0x80000304, 0x000000fc, 0x80000304, + 0x000000dc, 0x80000301, 0x000000fc, 0x80000301, + 0x000000dc, 0x8000030c, 0x000000fc, 0x8000030c, + 0x000000dc, 0x80000300, 0x000000fc, 0x80000300, + 0x000000c4, 0x80000304, 0x000000e4, 0x80000304, + 0x00000226, 0x80000304, 0x00000227, 0x80000304, + 0x000000c6, 0x80000304, 0x000000e6, 0x80000304, + 0x00000047, 0x8000030c, 0x00000067, 0x8000030c, + 0x0000004b, 0x8000030c, 0x0000006b, 0x8000030c, + 0x0000004f, 0x80000328, 0x0000006f, 0x80000328, + 0x000001ea, 0x80000304, 0x000001eb, 0x80000304, + 0x000001b7, 0x8000030c, 0x00000292, 0x8000030c, + 0x0000006a, 0x8000030c, 0x00000044, 0x8000005a, + 0x00000044, 0x8000007a, 0x00000064, 0x8000007a, + 0x00000047, 0x80000301, 0x00000067, 0x80000301, + 0x0000004e, 0x80000300, 0x0000006e, 0x80000300, + 0x000000c5, 0x80000301, 0x000000e5, 0x80000301, + 0x000000c6, 0x80000301, 0x000000e6, 0x80000301, + 0x000000d8, 0x80000301, 0x000000f8, 0x80000301, + 0x00000041, 0x8000030f, 0x00000061, 0x8000030f, + 0x00000041, 0x80000311, 0x00000061, 0x80000311, + 0x00000045, 0x8000030f, 0x00000065, 0x8000030f, + 0x00000045, 0x80000311, 0x00000065, 0x80000311, + 0x00000049, 0x8000030f, 0x00000069, 0x8000030f, + 0x00000049, 0x80000311, 0x00000069, 0x80000311, + 0x0000004f, 0x8000030f, 0x0000006f, 0x8000030f, + 0x0000004f, 0x80000311, 0x0000006f, 0x80000311, + 0x00000052, 0x8000030f, 0x00000072, 0x8000030f, + 0x00000052, 0x80000311, 0x00000072, 0x80000311, + 0x00000055, 0x8000030f, 0x00000075, 0x8000030f, + 0x00000055, 0x80000311, 0x00000075, 0x80000311, + 0x00000053, 0x80000326, 0x00000073, 0x80000326, + 0x00000054, 0x80000326, 0x00000074, 0x80000326, + 0x00000048, 0x8000030c, 0x00000068, 0x8000030c, + 0x00000041, 0x80000307, 0x00000061, 0x80000307, + 0x00000045, 0x80000327, 0x00000065, 0x80000327, + 0x000000d6, 0x80000304, 0x000000f6, 0x80000304, + 0x000000d5, 0x80000304, 0x000000f5, 0x80000304, + 0x0000004f, 0x80000307, 0x0000006f, 0x80000307, + 0x0000022e, 0x80000304, 0x0000022f, 0x80000304, + 0x00000059, 0x80000304, 0x00000079, 0x80000304, + 0x80000068, 0x80000266, 0x8000006a, 0x80000072, + 0x80000279, 0x8000027b, 0x80000281, 0x80000077, + 0x80000079, 0x00000020, 0x80000306, 0x00000020, + 0x80000307, 0x00000020, 0x8000030a, 0x00000020, + 0x80000328, 0x00000020, 0x80000303, 0x00000020, + 0x8000030b, 0x80000263, 0x8000006c, 0x80000073, + 0x80000078, 0x80000295, 0x80000300, 0x80000301, + 0x80000313, 0x00000308, 0x80000301, 0x800002b9, + 0x00000020, 0x80000345, 0x8000003b, 0x00000020, + 0x80000301, 0x000000a8, 0x80000301, 0x00000391, + 0x80000301, 0x800000b7, 0x00000395, 0x80000301, + 0x00000397, 0x80000301, 0x00000399, 0x80000301, + 0x0000039f, 0x80000301, 0x000003a5, 0x80000301, + 0x000003a9, 0x80000301, 0x000003ca, 0x80000301, + 0x00000399, 0x80000308, 0x000003a5, 0x80000308, + 0x000003b1, 0x80000301, 0x000003b5, 0x80000301, + 0x000003b7, 0x80000301, 0x000003b9, 0x80000301, + 0x000003cb, 0x80000301, 0x000003b9, 0x80000308, + 0x000003c5, 0x80000308, 0x000003bf, 0x80000301, + 0x000003c5, 0x80000301, 0x000003c9, 0x80000301, + 0x800003b2, 0x800003b8, 0x800003a5, 0x000003d2, + 0x80000301, 0x000003d2, 0x80000308, 0x800003c6, + 0x800003c0, 0x800003ba, 0x800003c1, 0x800003c2, + 0x80000398, 0x800003b5, 0x00000415, 0x80000300, + 0x00000415, 0x80000308, 0x00000413, 0x80000301, + 0x00000406, 0x80000308, 0x0000041a, 0x80000301, + 0x00000418, 0x80000300, 0x00000423, 0x80000306, + 0x00000418, 0x80000306, 0x00000438, 0x80000306, + 0x00000435, 0x80000300, 0x00000435, 0x80000308, + 0x00000433, 0x80000301, 0x00000456, 0x80000308, + 0x0000043a, 0x80000301, 0x00000438, 0x80000300, + 0x00000443, 0x80000306, 0x00000474, 0x8000030f, + 0x00000475, 0x8000030f, 0x00000416, 0x80000306, + 0x00000436, 0x80000306, 0x00000410, 0x80000306, + 0x00000430, 0x80000306, 0x00000410, 0x80000308, + 0x00000430, 0x80000308, 0x00000415, 0x80000306, + 0x00000435, 0x80000306, 0x000004d8, 0x80000308, + 0x000004d9, 0x80000308, 0x00000416, 0x80000308, + 0x00000436, 0x80000308, 0x00000417, 0x80000308, + 0x00000437, 0x80000308, 0x00000418, 0x80000304, + 0x00000438, 0x80000304, 0x00000418, 0x80000308, + 0x00000438, 0x80000308, 0x0000041e, 0x80000308, + 0x0000043e, 0x80000308, 0x000004e8, 0x80000308, + 0x000004e9, 0x80000308, 0x0000042d, 0x80000308, + 0x0000044d, 0x80000308, 0x00000423, 0x80000304, + 0x00000443, 0x80000304, 0x00000423, 0x80000308, + 0x00000443, 0x80000308, 0x00000423, 0x8000030b, + 0x00000443, 0x8000030b, 0x00000427, 0x80000308, + 0x00000447, 0x80000308, 0x0000042b, 0x80000308, + 0x0000044b, 0x80000308, 0x00000565, 0x80000582, + 0x00000627, 0x80000653, 0x00000627, 0x80000654, + 0x00000648, 0x80000654, 0x00000627, 0x80000655, + 0x0000064a, 0x80000654, 0x00000627, 0x80000674, + 0x00000648, 0x80000674, 0x000006c7, 0x80000674, + 0x0000064a, 0x80000674, 0x000006d5, 0x80000654, + 0x000006c1, 0x80000654, 0x000006d2, 0x80000654, + 0x00000928, 0x8000093c, 0x00000930, 0x8000093c, + 0x00000933, 0x8000093c, 0x00000915, 0x8000093c, + 0x00000916, 0x8000093c, 0x00000917, 0x8000093c, + 0x0000091c, 0x8000093c, 0x00000921, 0x8000093c, + 0x00000922, 0x8000093c, 0x0000092b, 0x8000093c, + 0x0000092f, 0x8000093c, 0x000009c7, 0x800009be, + 0x000009c7, 0x800009d7, 0x000009a1, 0x800009bc, + 0x000009a2, 0x800009bc, 0x000009af, 0x800009bc, + 0x00000a32, 0x80000a3c, 0x00000a38, 0x80000a3c, + 0x00000a16, 0x80000a3c, 0x00000a17, 0x80000a3c, + 0x00000a1c, 0x80000a3c, 0x00000a2b, 0x80000a3c, + 0x00000b47, 0x80000b56, 0x00000b47, 0x80000b3e, + 0x00000b47, 0x80000b57, 0x00000b21, 0x80000b3c, + 0x00000b22, 0x80000b3c, 0x00000b92, 0x80000bd7, + 0x00000bc6, 0x80000bbe, 0x00000bc7, 0x80000bbe, + 0x00000bc6, 0x80000bd7, 0x00000c46, 0x80000c56, + 0x00000cbf, 0x80000cd5, 0x00000cc6, 0x80000cd5, + 0x00000cc6, 0x80000cd6, 0x00000cc6, 0x80000cc2, + 0x00000cca, 0x80000cd5, 0x00000d46, 0x80000d3e, + 0x00000d47, 0x80000d3e, 0x00000d46, 0x80000d57, + 0x00000dd9, 0x80000dca, 0x00000dd9, 0x80000dcf, + 0x00000ddc, 0x80000dca, 0x00000dd9, 0x80000ddf, + 0x00000e4d, 0x80000e32, 0x00000ecd, 0x80000eb2, + 0x00000eab, 0x80000e99, 0x00000eab, 0x80000ea1, + 0x80000f0b, 0x00000f42, 0x80000fb7, 0x00000f4c, + 0x80000fb7, 0x00000f51, 0x80000fb7, 0x00000f56, + 0x80000fb7, 0x00000f5b, 0x80000fb7, 0x00000f40, + 0x80000fb5, 0x00000f71, 0x80000f72, 0x00000f71, + 0x80000f74, 0x00000fb2, 0x80000f80, 0x00000fb2, + 0x80000f81, 0x00000fb3, 0x80000f80, 0x00000fb3, + 0x80000f81, 0x00000f71, 0x80000f80, 0x00000f92, + 0x80000fb7, 0x00000f9c, 0x80000fb7, 0x00000fa1, + 0x80000fb7, 0x00000fa6, 0x80000fb7, 0x00000fab, + 0x80000fb7, 0x00000f90, 0x80000fb5, 0x00001025, + 0x8000102e, 0x00000041, 0x80000325, 0x00000061, + 0x80000325, 0x00000042, 0x80000307, 0x00000062, + 0x80000307, 0x00000042, 0x80000323, 0x00000062, + 0x80000323, 0x00000042, 0x80000331, 0x00000062, + 0x80000331, 0x000000c7, 0x80000301, 0x000000e7, + 0x80000301, 0x00000044, 0x80000307, 0x00000064, + 0x80000307, 0x00000044, 0x80000323, 0x00000064, + 0x80000323, 0x00000044, 0x80000331, 0x00000064, + 0x80000331, 0x00000044, 0x80000327, 0x00000064, + 0x80000327, 0x00000044, 0x8000032d, 0x00000064, + 0x8000032d, 0x00000112, 0x80000300, 0x00000113, + 0x80000300, 0x00000112, 0x80000301, 0x00000113, + 0x80000301, 0x00000045, 0x8000032d, 0x00000065, + 0x8000032d, 0x00000045, 0x80000330, 0x00000065, + 0x80000330, 0x00000228, 0x80000306, 0x00000229, + 0x80000306, 0x00000046, 0x80000307, 0x00000066, + 0x80000307, 0x00000047, 0x80000304, 0x00000067, + 0x80000304, 0x00000048, 0x80000307, 0x00000068, + 0x80000307, 0x00000048, 0x80000323, 0x00000068, + 0x80000323, 0x00000048, 0x80000308, 0x00000068, + 0x80000308, 0x00000048, 0x80000327, 0x00000068, + 0x80000327, 0x00000048, 0x8000032e, 0x00000068, + 0x8000032e, 0x00000049, 0x80000330, 0x00000069, + 0x80000330, 0x000000cf, 0x80000301, 0x000000ef, + 0x80000301, 0x0000004b, 0x80000301, 0x0000006b, + 0x80000301, 0x0000004b, 0x80000323, 0x0000006b, + 0x80000323, 0x0000004b, 0x80000331, 0x0000006b, + 0x80000331, 0x0000004c, 0x80000323, 0x0000006c, + 0x80000323, 0x00001e36, 0x80000304, 0x00001e37, + 0x80000304, 0x0000004c, 0x80000331, 0x0000006c, + 0x80000331, 0x0000004c, 0x8000032d, 0x0000006c, + 0x8000032d, 0x0000004d, 0x80000301, 0x0000006d, + 0x80000301, 0x0000004d, 0x80000307, 0x0000006d, + 0x80000307, 0x0000004d, 0x80000323, 0x0000006d, + 0x80000323, 0x0000004e, 0x80000307, 0x0000006e, + 0x80000307, 0x0000004e, 0x80000323, 0x0000006e, + 0x80000323, 0x0000004e, 0x80000331, 0x0000006e, + 0x80000331, 0x0000004e, 0x8000032d, 0x0000006e, + 0x8000032d, 0x000000d5, 0x80000301, 0x000000f5, + 0x80000301, 0x000000d5, 0x80000308, 0x000000f5, + 0x80000308, 0x0000014c, 0x80000300, 0x0000014d, + 0x80000300, 0x0000014c, 0x80000301, 0x0000014d, + 0x80000301, 0x00000050, 0x80000301, 0x00000070, + 0x80000301, 0x00000050, 0x80000307, 0x00000070, + 0x80000307, 0x00000052, 0x80000307, 0x00000072, + 0x80000307, 0x00000052, 0x80000323, 0x00000072, + 0x80000323, 0x00001e5a, 0x80000304, 0x00001e5b, + 0x80000304, 0x00000052, 0x80000331, 0x00000072, + 0x80000331, 0x00000053, 0x80000307, 0x00000073, + 0x80000307, 0x00000053, 0x80000323, 0x00000073, + 0x80000323, 0x0000015a, 0x80000307, 0x0000015b, + 0x80000307, 0x00000160, 0x80000307, 0x00000161, + 0x80000307, 0x00001e62, 0x80000307, 0x00001e63, + 0x80000307, 0x00000054, 0x80000307, 0x00000074, + 0x80000307, 0x00000054, 0x80000323, 0x00000074, + 0x80000323, 0x00000054, 0x80000331, 0x00000074, + 0x80000331, 0x00000054, 0x8000032d, 0x00000074, + 0x8000032d, 0x00000055, 0x80000324, 0x00000075, + 0x80000324, 0x00000055, 0x80000330, 0x00000075, + 0x80000330, 0x00000055, 0x8000032d, 0x00000075, + 0x8000032d, 0x00000168, 0x80000301, 0x00000169, + 0x80000301, 0x0000016a, 0x80000308, 0x0000016b, + 0x80000308, 0x00000056, 0x80000303, 0x00000076, + 0x80000303, 0x00000056, 0x80000323, 0x00000076, + 0x80000323, 0x00000057, 0x80000300, 0x00000077, + 0x80000300, 0x00000057, 0x80000301, 0x00000077, + 0x80000301, 0x00000057, 0x80000308, 0x00000077, + 0x80000308, 0x00000057, 0x80000307, 0x00000077, + 0x80000307, 0x00000057, 0x80000323, 0x00000077, + 0x80000323, 0x00000058, 0x80000307, 0x00000078, + 0x80000307, 0x00000058, 0x80000308, 0x00000078, + 0x80000308, 0x00000059, 0x80000307, 0x00000079, + 0x80000307, 0x0000005a, 0x80000302, 0x0000007a, + 0x80000302, 0x0000005a, 0x80000323, 0x0000007a, + 0x80000323, 0x0000005a, 0x80000331, 0x0000007a, + 0x80000331, 0x00000068, 0x80000331, 0x00000074, + 0x80000308, 0x00000077, 0x8000030a, 0x00000079, + 0x8000030a, 0x00000061, 0x800002be, 0x0000017f, + 0x80000307, 0x00000041, 0x80000323, 0x00000061, + 0x80000323, 0x00000041, 0x80000309, 0x00000061, + 0x80000309, 0x000000c2, 0x80000301, 0x000000e2, + 0x80000301, 0x000000c2, 0x80000300, 0x000000e2, + 0x80000300, 0x000000c2, 0x80000309, 0x000000e2, + 0x80000309, 0x000000c2, 0x80000303, 0x000000e2, + 0x80000303, 0x00001ea0, 0x80000302, 0x00001ea1, + 0x80000302, 0x00000102, 0x80000301, 0x00000103, + 0x80000301, 0x00000102, 0x80000300, 0x00000103, + 0x80000300, 0x00000102, 0x80000309, 0x00000103, + 0x80000309, 0x00000102, 0x80000303, 0x00000103, + 0x80000303, 0x00001ea0, 0x80000306, 0x00001ea1, + 0x80000306, 0x00000045, 0x80000323, 0x00000065, + 0x80000323, 0x00000045, 0x80000309, 0x00000065, + 0x80000309, 0x00000045, 0x80000303, 0x00000065, + 0x80000303, 0x000000ca, 0x80000301, 0x000000ea, + 0x80000301, 0x000000ca, 0x80000300, 0x000000ea, + 0x80000300, 0x000000ca, 0x80000309, 0x000000ea, + 0x80000309, 0x000000ca, 0x80000303, 0x000000ea, + 0x80000303, 0x00001eb8, 0x80000302, 0x00001eb9, + 0x80000302, 0x00000049, 0x80000309, 0x00000069, + 0x80000309, 0x00000049, 0x80000323, 0x00000069, + 0x80000323, 0x0000004f, 0x80000323, 0x0000006f, + 0x80000323, 0x0000004f, 0x80000309, 0x0000006f, + 0x80000309, 0x000000d4, 0x80000301, 0x000000f4, + 0x80000301, 0x000000d4, 0x80000300, 0x000000f4, + 0x80000300, 0x000000d4, 0x80000309, 0x000000f4, + 0x80000309, 0x000000d4, 0x80000303, 0x000000f4, + 0x80000303, 0x00001ecc, 0x80000302, 0x00001ecd, + 0x80000302, 0x000001a0, 0x80000301, 0x000001a1, + 0x80000301, 0x000001a0, 0x80000300, 0x000001a1, + 0x80000300, 0x000001a0, 0x80000309, 0x000001a1, + 0x80000309, 0x000001a0, 0x80000303, 0x000001a1, + 0x80000303, 0x000001a0, 0x80000323, 0x000001a1, + 0x80000323, 0x00000055, 0x80000323, 0x00000075, + 0x80000323, 0x00000055, 0x80000309, 0x00000075, + 0x80000309, 0x000001af, 0x80000301, 0x000001b0, + 0x80000301, 0x000001af, 0x80000300, 0x000001b0, + 0x80000300, 0x000001af, 0x80000309, 0x000001b0, + 0x80000309, 0x000001af, 0x80000303, 0x000001b0, + 0x80000303, 0x000001af, 0x80000323, 0x000001b0, + 0x80000323, 0x00000059, 0x80000300, 0x00000079, + 0x80000300, 0x00000059, 0x80000323, 0x00000079, + 0x80000323, 0x00000059, 0x80000309, 0x00000079, + 0x80000309, 0x00000059, 0x80000303, 0x00000079, + 0x80000303, 0x000003b1, 0x80000313, 0x000003b1, + 0x80000314, 0x00001f00, 0x80000300, 0x00001f01, + 0x80000300, 0x00001f00, 0x80000301, 0x00001f01, + 0x80000301, 0x00001f00, 0x80000342, 0x00001f01, + 0x80000342, 0x00000391, 0x80000313, 0x00000391, + 0x80000314, 0x00001f08, 0x80000300, 0x00001f09, + 0x80000300, 0x00001f08, 0x80000301, 0x00001f09, + 0x80000301, 0x00001f08, 0x80000342, 0x00001f09, + 0x80000342, 0x000003b5, 0x80000313, 0x000003b5, + 0x80000314, 0x00001f10, 0x80000300, 0x00001f11, + 0x80000300, 0x00001f10, 0x80000301, 0x00001f11, + 0x80000301, 0x00000395, 0x80000313, 0x00000395, + 0x80000314, 0x00001f18, 0x80000300, 0x00001f19, + 0x80000300, 0x00001f18, 0x80000301, 0x00001f19, + 0x80000301, 0x000003b7, 0x80000313, 0x000003b7, + 0x80000314, 0x00001f20, 0x80000300, 0x00001f21, + 0x80000300, 0x00001f20, 0x80000301, 0x00001f21, + 0x80000301, 0x00001f20, 0x80000342, 0x00001f21, + 0x80000342, 0x00000397, 0x80000313, 0x00000397, + 0x80000314, 0x00001f28, 0x80000300, 0x00001f29, + 0x80000300, 0x00001f28, 0x80000301, 0x00001f29, + 0x80000301, 0x00001f28, 0x80000342, 0x00001f29, + 0x80000342, 0x000003b9, 0x80000313, 0x000003b9, + 0x80000314, 0x00001f30, 0x80000300, 0x00001f31, + 0x80000300, 0x00001f30, 0x80000301, 0x00001f31, + 0x80000301, 0x00001f30, 0x80000342, 0x00001f31, + 0x80000342, 0x00000399, 0x80000313, 0x00000399, + 0x80000314, 0x00001f38, 0x80000300, 0x00001f39, + 0x80000300, 0x00001f38, 0x80000301, 0x00001f39, + 0x80000301, 0x00001f38, 0x80000342, 0x00001f39, + 0x80000342, 0x000003bf, 0x80000313, 0x000003bf, + 0x80000314, 0x00001f40, 0x80000300, 0x00001f41, + 0x80000300, 0x00001f40, 0x80000301, 0x00001f41, + 0x80000301, 0x0000039f, 0x80000313, 0x0000039f, + 0x80000314, 0x00001f48, 0x80000300, 0x00001f49, + 0x80000300, 0x00001f48, 0x80000301, 0x00001f49, + 0x80000301, 0x000003c5, 0x80000313, 0x000003c5, + 0x80000314, 0x00001f50, 0x80000300, 0x00001f51, + 0x80000300, 0x00001f50, 0x80000301, 0x00001f51, + 0x80000301, 0x00001f50, 0x80000342, 0x00001f51, + 0x80000342, 0x000003a5, 0x80000314, 0x00001f59, + 0x80000300, 0x00001f59, 0x80000301, 0x00001f59, + 0x80000342, 0x000003c9, 0x80000313, 0x000003c9, + 0x80000314, 0x00001f60, 0x80000300, 0x00001f61, + 0x80000300, 0x00001f60, 0x80000301, 0x00001f61, + 0x80000301, 0x00001f60, 0x80000342, 0x00001f61, + 0x80000342, 0x000003a9, 0x80000313, 0x000003a9, + 0x80000314, 0x00001f68, 0x80000300, 0x00001f69, + 0x80000300, 0x00001f68, 0x80000301, 0x00001f69, + 0x80000301, 0x00001f68, 0x80000342, 0x00001f69, + 0x80000342, 0x000003b1, 0x80000300, 0x800003ac, + 0x000003b5, 0x80000300, 0x800003ad, 0x000003b7, + 0x80000300, 0x800003ae, 0x000003b9, 0x80000300, + 0x800003af, 0x000003bf, 0x80000300, 0x800003cc, + 0x000003c5, 0x80000300, 0x800003cd, 0x000003c9, + 0x80000300, 0x800003ce, 0x00001f00, 0x80000345, + 0x00001f01, 0x80000345, 0x00001f02, 0x80000345, + 0x00001f03, 0x80000345, 0x00001f04, 0x80000345, + 0x00001f05, 0x80000345, 0x00001f06, 0x80000345, + 0x00001f07, 0x80000345, 0x00001f08, 0x80000345, + 0x00001f09, 0x80000345, 0x00001f0a, 0x80000345, + 0x00001f0b, 0x80000345, 0x00001f0c, 0x80000345, + 0x00001f0d, 0x80000345, 0x00001f0e, 0x80000345, + 0x00001f0f, 0x80000345, 0x00001f20, 0x80000345, + 0x00001f21, 0x80000345, 0x00001f22, 0x80000345, + 0x00001f23, 0x80000345, 0x00001f24, 0x80000345, + 0x00001f25, 0x80000345, 0x00001f26, 0x80000345, + 0x00001f27, 0x80000345, 0x00001f28, 0x80000345, + 0x00001f29, 0x80000345, 0x00001f2a, 0x80000345, + 0x00001f2b, 0x80000345, 0x00001f2c, 0x80000345, + 0x00001f2d, 0x80000345, 0x00001f2e, 0x80000345, + 0x00001f2f, 0x80000345, 0x00001f60, 0x80000345, + 0x00001f61, 0x80000345, 0x00001f62, 0x80000345, + 0x00001f63, 0x80000345, 0x00001f64, 0x80000345, + 0x00001f65, 0x80000345, 0x00001f66, 0x80000345, + 0x00001f67, 0x80000345, 0x00001f68, 0x80000345, + 0x00001f69, 0x80000345, 0x00001f6a, 0x80000345, + 0x00001f6b, 0x80000345, 0x00001f6c, 0x80000345, + 0x00001f6d, 0x80000345, 0x00001f6e, 0x80000345, + 0x00001f6f, 0x80000345, 0x000003b1, 0x80000306, + 0x000003b1, 0x80000304, 0x00001f70, 0x80000345, + 0x000003b1, 0x80000345, 0x000003ac, 0x80000345, + 0x000003b1, 0x80000342, 0x00001fb6, 0x80000345, + 0x00000391, 0x80000306, 0x00000391, 0x80000304, + 0x00000391, 0x80000300, 0x80000386, 0x00000391, + 0x80000345, 0x00000020, 0x80000313, 0x800003b9, + 0x00000020, 0x80000313, 0x00000020, 0x80000342, + 0x000000a8, 0x80000342, 0x00001f74, 0x80000345, + 0x000003b7, 0x80000345, 0x000003ae, 0x80000345, + 0x000003b7, 0x80000342, 0x00001fc6, 0x80000345, + 0x00000395, 0x80000300, 0x80000388, 0x00000397, + 0x80000300, 0x80000389, 0x00000397, 0x80000345, + 0x00001fbf, 0x80000300, 0x00001fbf, 0x80000301, + 0x00001fbf, 0x80000342, 0x000003b9, 0x80000306, + 0x000003b9, 0x80000304, 0x000003ca, 0x80000300, + 0x80000390, 0x000003b9, 0x80000342, 0x000003ca, + 0x80000342, 0x00000399, 0x80000306, 0x00000399, + 0x80000304, 0x00000399, 0x80000300, 0x8000038a, + 0x00001ffe, 0x80000300, 0x00001ffe, 0x80000301, + 0x00001ffe, 0x80000342, 0x000003c5, 0x80000306, + 0x000003c5, 0x80000304, 0x000003cb, 0x80000300, + 0x800003b0, 0x000003c1, 0x80000313, 0x000003c1, + 0x80000314, 0x000003c5, 0x80000342, 0x000003cb, + 0x80000342, 0x000003a5, 0x80000306, 0x000003a5, + 0x80000304, 0x000003a5, 0x80000300, 0x8000038e, + 0x000003a1, 0x80000314, 0x000000a8, 0x80000300, + 0x80000385, 0x80000060, 0x00001f7c, 0x80000345, + 0x000003c9, 0x80000345, 0x000003ce, 0x80000345, + 0x000003c9, 0x80000342, 0x00001ff6, 0x80000345, + 0x0000039f, 0x80000300, 0x8000038c, 0x000003a9, + 0x80000300, 0x8000038f, 0x000003a9, 0x80000345, + 0x800000b4, 0x00000020, 0x80000314, 0x80002002, + 0x80002003, 0x80000020, 0x80000020, 0x80000020, + 0x80000020, 0x80000020, 0x80000020, 0x80000020, + 0x80000020, 0x80000020, 0x80002010, 0x00000020, + 0x80000333, 0x8000002e, 0x0000002e, 0x8000002e, + 0x0000002e, 0x0000002e, 0x8000002e, 0x80000020, + 0x00002032, 0x80002032, 0x00002032, 0x00002032, + 0x80002032, 0x00002035, 0x80002035, 0x00002035, + 0x00002035, 0x80002035, 0x00000021, 0x80000021, + 0x00000020, 0x80000305, 0x0000003f, 0x8000003f, + 0x0000003f, 0x80000021, 0x00000021, 0x8000003f, + 0x00002032, 0x00002032, 0x00002032, 0x80002032, + 0x80000020, 0x80000030, 0x80000069, 0x80000034, + 0x80000035, 0x80000036, 0x80000037, 0x80000038, + 0x80000039, 0x8000002b, 0x80002212, 0x8000003d, + 0x80000028, 0x80000029, 0x8000006e, 0x80000030, + 0x80000031, 0x80000032, 0x80000033, 0x80000034, + 0x80000035, 0x80000036, 0x80000037, 0x80000038, + 0x80000039, 0x8000002b, 0x80002212, 0x8000003d, + 0x80000028, 0x80000029, 0x00000052, 0x80000073, + 0x00000061, 0x0000002f, 0x80000063, 0x00000061, + 0x0000002f, 0x80000073, 0x80000043, 0x000000b0, + 0x80000043, 0x00000063, 0x0000002f, 0x8000006f, + 0x00000063, 0x0000002f, 0x80000075, 0x80000190, + 0x000000b0, 0x80000046, 0x80000067, 0x80000048, + 0x80000048, 0x80000048, 0x80000068, 0x80000127, + 0x80000049, 0x80000049, 0x8000004c, 0x8000006c, + 0x8000004e, 0x0000004e, 0x8000006f, 0x80000050, + 0x80000051, 0x80000052, 0x80000052, 0x80000052, + 0x00000053, 0x8000004d, 0x00000054, 0x00000045, + 0x8000004c, 0x00000054, 0x8000004d, 0x8000005a, + 0x800003a9, 0x8000005a, 0x8000004b, 0x800000c5, + 0x80000042, 0x80000043, 0x80000065, 0x80000045, + 0x80000046, 0x8000004d, 0x8000006f, 0x800005d0, + 0x800005d1, 0x800005d2, 0x800005d3, 0x80000069, + 0x800003b3, 0x80000393, 0x800003a0, 0x80002211, + 0x80000044, 0x80000064, 0x80000065, 0x80000069, + 0x8000006a, 0x00000031, 0x00002044, 0x80000033, + 0x00000032, 0x00002044, 0x80000033, 0x00000031, + 0x00002044, 0x80000035, 0x00000032, 0x00002044, + 0x80000035, 0x00000033, 0x00002044, 0x80000035, + 0x00000034, 0x00002044, 0x80000035, 0x00000031, + 0x00002044, 0x80000036, 0x00000035, 0x00002044, + 0x80000036, 0x00000031, 0x00002044, 0x80000038, + 0x00000033, 0x00002044, 0x80000038, 0x00000035, + 0x00002044, 0x80000038, 0x00000037, 0x00002044, + 0x80000038, 0x00000031, 0x80002044, 0x80000049, + 0x00000049, 0x80000049, 0x00000049, 0x00000049, + 0x80000049, 0x00000049, 0x80000056, 0x80000056, + 0x00000056, 0x80000049, 0x00000056, 0x00000049, + 0x80000049, 0x00000056, 0x00000049, 0x00000049, + 0x80000049, 0x00000049, 0x80000058, 0x80000058, + 0x00000058, 0x80000049, 0x00000058, 0x00000049, + 0x80000049, 0x8000004c, 0x80000043, 0x80000044, + 0x8000004d, 0x80000069, 0x00000069, 0x80000069, + 0x00000069, 0x00000069, 0x80000069, 0x00000069, + 0x80000076, 0x80000076, 0x00000076, 0x80000069, + 0x00000076, 0x00000069, 0x80000069, 0x00000076, + 0x00000069, 0x00000069, 0x80000069, 0x00000069, + 0x80000078, 0x80000078, 0x00000078, 0x80000069, + 0x00000078, 0x00000069, 0x80000069, 0x8000006c, + 0x80000063, 0x80000064, 0x8000006d, 0x00002190, + 0x80000338, 0x00002192, 0x80000338, 0x00002194, + 0x80000338, 0x000021d0, 0x80000338, 0x000021d4, + 0x80000338, 0x000021d2, 0x80000338, 0x00002203, + 0x80000338, 0x00002208, 0x80000338, 0x0000220b, + 0x80000338, 0x00002223, 0x80000338, 0x00002225, + 0x80000338, 0x0000222b, 0x8000222b, 0x0000222b, + 0x0000222b, 0x8000222b, 0x0000222e, 0x8000222e, + 0x0000222e, 0x0000222e, 0x8000222e, 0x0000223c, + 0x80000338, 0x00002243, 0x80000338, 0x00002245, + 0x80000338, 0x00002248, 0x80000338, 0x0000003d, + 0x80000338, 0x00002261, 0x80000338, 0x0000224d, + 0x80000338, 0x0000003c, 0x80000338, 0x0000003e, + 0x80000338, 0x00002264, 0x80000338, 0x00002265, + 0x80000338, 0x00002272, 0x80000338, 0x00002273, + 0x80000338, 0x00002276, 0x80000338, 0x00002277, + 0x80000338, 0x0000227a, 0x80000338, 0x0000227b, + 0x80000338, 0x00002282, 0x80000338, 0x00002283, + 0x80000338, 0x00002286, 0x80000338, 0x00002287, + 0x80000338, 0x000022a2, 0x80000338, 0x000022a8, + 0x80000338, 0x000022a9, 0x80000338, 0x000022ab, + 0x80000338, 0x0000227c, 0x80000338, 0x0000227d, + 0x80000338, 0x00002291, 0x80000338, 0x00002292, + 0x80000338, 0x000022b2, 0x80000338, 0x000022b3, + 0x80000338, 0x000022b4, 0x80000338, 0x000022b5, + 0x80000338, 0x80003008, 0x80003009, 0x80000031, + 0x80000032, 0x80000033, 0x80000034, 0x80000035, + 0x80000036, 0x80000037, 0x80000038, 0x80000039, + 0x00000031, 0x80000030, 0x00000031, 0x80000031, + 0x00000031, 0x80000032, 0x00000031, 0x80000033, + 0x00000031, 0x80000034, 0x00000031, 0x80000035, + 0x00000031, 0x80000036, 0x00000031, 0x80000037, + 0x00000031, 0x80000038, 0x00000031, 0x80000039, + 0x00000032, 0x80000030, 0x00000028, 0x00000031, + 0x80000029, 0x00000028, 0x00000032, 0x80000029, + 0x00000028, 0x00000033, 0x80000029, 0x00000028, + 0x00000034, 0x80000029, 0x00000028, 0x00000035, + 0x80000029, 0x00000028, 0x00000036, 0x80000029, + 0x00000028, 0x00000037, 0x80000029, 0x00000028, + 0x00000038, 0x80000029, 0x00000028, 0x00000039, + 0x80000029, 0x00000028, 0x00000031, 0x00000030, + 0x80000029, 0x00000028, 0x00000031, 0x00000031, + 0x80000029, 0x00000028, 0x00000031, 0x00000032, + 0x80000029, 0x00000028, 0x00000031, 0x00000033, + 0x80000029, 0x00000028, 0x00000031, 0x00000034, + 0x80000029, 0x00000028, 0x00000031, 0x00000035, + 0x80000029, 0x00000028, 0x00000031, 0x00000036, + 0x80000029, 0x00000028, 0x00000031, 0x00000037, + 0x80000029, 0x00000028, 0x00000031, 0x00000038, + 0x80000029, 0x00000028, 0x00000031, 0x00000039, + 0x80000029, 0x00000028, 0x00000032, 0x00000030, + 0x80000029, 0x00000031, 0x8000002e, 0x00000032, + 0x8000002e, 0x00000033, 0x8000002e, 0x00000034, + 0x8000002e, 0x00000035, 0x8000002e, 0x00000036, + 0x8000002e, 0x00000037, 0x8000002e, 0x00000038, + 0x8000002e, 0x00000039, 0x8000002e, 0x00000031, + 0x00000030, 0x8000002e, 0x00000031, 0x00000031, + 0x8000002e, 0x00000031, 0x00000032, 0x8000002e, + 0x00000031, 0x00000033, 0x8000002e, 0x00000031, + 0x00000034, 0x8000002e, 0x00000031, 0x00000035, + 0x8000002e, 0x00000031, 0x00000036, 0x8000002e, + 0x00000031, 0x00000037, 0x8000002e, 0x00000031, + 0x00000038, 0x8000002e, 0x00000031, 0x00000039, + 0x8000002e, 0x00000032, 0x00000030, 0x8000002e, + 0x00000028, 0x00000061, 0x80000029, 0x00000028, + 0x00000062, 0x80000029, 0x00000028, 0x00000063, + 0x80000029, 0x00000028, 0x00000064, 0x80000029, + 0x00000028, 0x00000065, 0x80000029, 0x00000028, + 0x00000066, 0x80000029, 0x00000028, 0x00000067, + 0x80000029, 0x00000028, 0x00000068, 0x80000029, + 0x00000028, 0x00000069, 0x80000029, 0x00000028, + 0x0000006a, 0x80000029, 0x00000028, 0x0000006b, + 0x80000029, 0x00000028, 0x0000006c, 0x80000029, + 0x00000028, 0x0000006d, 0x80000029, 0x00000028, + 0x0000006e, 0x80000029, 0x00000028, 0x0000006f, + 0x80000029, 0x00000028, 0x00000070, 0x80000029, + 0x00000028, 0x00000071, 0x80000029, 0x00000028, + 0x00000072, 0x80000029, 0x00000028, 0x00000073, + 0x80000029, 0x00000028, 0x00000074, 0x80000029, + 0x00000028, 0x00000075, 0x80000029, 0x00000028, + 0x00000076, 0x80000029, 0x00000028, 0x00000077, + 0x80000029, 0x00000028, 0x00000078, 0x80000029, + 0x00000028, 0x00000079, 0x80000029, 0x00000028, + 0x0000007a, 0x80000029, 0x80000041, 0x80000042, + 0x80000043, 0x80000044, 0x80000045, 0x80000046, + 0x80000047, 0x80000048, 0x80000049, 0x8000004a, + 0x8000004b, 0x8000004c, 0x8000004d, 0x8000004e, + 0x8000004f, 0x80000050, 0x80000051, 0x80000052, + 0x80000053, 0x80000054, 0x80000055, 0x80000056, + 0x80000057, 0x80000058, 0x80000059, 0x8000005a, + 0x80000061, 0x80000062, 0x80000063, 0x80000064, + 0x80000065, 0x80000066, 0x80000067, 0x80000068, + 0x80000069, 0x8000006a, 0x8000006b, 0x8000006c, + 0x8000006d, 0x8000006e, 0x8000006f, 0x80000070, + 0x80000071, 0x80000072, 0x80000073, 0x80000074, + 0x80000075, 0x80000076, 0x80000077, 0x80000078, + 0x80000079, 0x8000007a, 0x80000030, 0x0000222b, + 0x0000222b, 0x0000222b, 0x8000222b, 0x0000003a, + 0x0000003a, 0x8000003d, 0x0000003d, 0x8000003d, + 0x0000003d, 0x0000003d, 0x8000003d, 0x00002add, + 0x80000338, 0x80006bcd, 0x80009f9f, 0x80004e00, + 0x80004e28, 0x80004e36, 0x80004e3f, 0x80004e59, + 0x80004e85, 0x80004e8c, 0x80004ea0, 0x80004eba, + 0x8000513f, 0x80005165, 0x8000516b, 0x80005182, + 0x80005196, 0x800051ab, 0x800051e0, 0x800051f5, + 0x80005200, 0x8000529b, 0x800052f9, 0x80005315, + 0x8000531a, 0x80005338, 0x80005341, 0x8000535c, + 0x80005369, 0x80005382, 0x800053b6, 0x800053c8, + 0x800053e3, 0x800056d7, 0x8000571f, 0x800058eb, + 0x80005902, 0x8000590a, 0x80005915, 0x80005927, + 0x80005973, 0x80005b50, 0x80005b80, 0x80005bf8, + 0x80005c0f, 0x80005c22, 0x80005c38, 0x80005c6e, + 0x80005c71, 0x80005ddb, 0x80005de5, 0x80005df1, + 0x80005dfe, 0x80005e72, 0x80005e7a, 0x80005e7f, + 0x80005ef4, 0x80005efe, 0x80005f0b, 0x80005f13, + 0x80005f50, 0x80005f61, 0x80005f73, 0x80005fc3, + 0x80006208, 0x80006236, 0x8000624b, 0x8000652f, + 0x80006534, 0x80006587, 0x80006597, 0x800065a4, + 0x800065b9, 0x800065e0, 0x800065e5, 0x800066f0, + 0x80006708, 0x80006728, 0x80006b20, 0x80006b62, + 0x80006b79, 0x80006bb3, 0x80006bcb, 0x80006bd4, + 0x80006bdb, 0x80006c0f, 0x80006c14, 0x80006c34, + 0x8000706b, 0x8000722a, 0x80007236, 0x8000723b, + 0x8000723f, 0x80007247, 0x80007259, 0x8000725b, + 0x800072ac, 0x80007384, 0x80007389, 0x800074dc, + 0x800074e6, 0x80007518, 0x8000751f, 0x80007528, + 0x80007530, 0x8000758b, 0x80007592, 0x80007676, + 0x8000767d, 0x800076ae, 0x800076bf, 0x800076ee, + 0x800077db, 0x800077e2, 0x800077f3, 0x8000793a, + 0x800079b8, 0x800079be, 0x80007a74, 0x80007acb, + 0x80007af9, 0x80007c73, 0x80007cf8, 0x80007f36, + 0x80007f51, 0x80007f8a, 0x80007fbd, 0x80008001, + 0x8000800c, 0x80008012, 0x80008033, 0x8000807f, + 0x80008089, 0x800081e3, 0x800081ea, 0x800081f3, + 0x800081fc, 0x8000820c, 0x8000821b, 0x8000821f, + 0x8000826e, 0x80008272, 0x80008278, 0x8000864d, + 0x8000866b, 0x80008840, 0x8000884c, 0x80008863, + 0x8000897e, 0x8000898b, 0x800089d2, 0x80008a00, + 0x80008c37, 0x80008c46, 0x80008c55, 0x80008c78, + 0x80008c9d, 0x80008d64, 0x80008d70, 0x80008db3, + 0x80008eab, 0x80008eca, 0x80008f9b, 0x80008fb0, + 0x80008fb5, 0x80009091, 0x80009149, 0x800091c6, + 0x800091cc, 0x800091d1, 0x80009577, 0x80009580, + 0x8000961c, 0x800096b6, 0x800096b9, 0x800096e8, + 0x80009751, 0x8000975e, 0x80009762, 0x80009769, + 0x800097cb, 0x800097ed, 0x800097f3, 0x80009801, + 0x800098a8, 0x800098db, 0x800098df, 0x80009996, + 0x80009999, 0x800099ac, 0x80009aa8, 0x80009ad8, + 0x80009adf, 0x80009b25, 0x80009b2f, 0x80009b32, + 0x80009b3c, 0x80009b5a, 0x80009ce5, 0x80009e75, + 0x80009e7f, 0x80009ea5, 0x80009ebb, 0x80009ec3, + 0x80009ecd, 0x80009ed1, 0x80009ef9, 0x80009efd, + 0x80009f0e, 0x80009f13, 0x80009f20, 0x80009f3b, + 0x80009f4a, 0x80009f52, 0x80009f8d, 0x80009f9c, + 0x80009fa0, 0x80000020, 0x80003012, 0x80005341, + 0x80005344, 0x80005345, 0x0000304b, 0x80003099, + 0x0000304d, 0x80003099, 0x0000304f, 0x80003099, + 0x00003051, 0x80003099, 0x00003053, 0x80003099, + 0x00003055, 0x80003099, 0x00003057, 0x80003099, + 0x00003059, 0x80003099, 0x0000305b, 0x80003099, + 0x0000305d, 0x80003099, 0x0000305f, 0x80003099, + 0x00003061, 0x80003099, 0x00003064, 0x80003099, + 0x00003066, 0x80003099, 0x00003068, 0x80003099, + 0x0000306f, 0x80003099, 0x0000306f, 0x8000309a, + 0x00003072, 0x80003099, 0x00003072, 0x8000309a, + 0x00003075, 0x80003099, 0x00003075, 0x8000309a, + 0x00003078, 0x80003099, 0x00003078, 0x8000309a, + 0x0000307b, 0x80003099, 0x0000307b, 0x8000309a, + 0x00003046, 0x80003099, 0x00000020, 0x80003099, + 0x00000020, 0x8000309a, 0x0000309d, 0x80003099, + 0x00003088, 0x8000308a, 0x000030ab, 0x80003099, + 0x000030ad, 0x80003099, 0x000030af, 0x80003099, + 0x000030b1, 0x80003099, 0x000030b3, 0x80003099, + 0x000030b5, 0x80003099, 0x000030b7, 0x80003099, + 0x000030b9, 0x80003099, 0x000030bb, 0x80003099, + 0x000030bd, 0x80003099, 0x000030bf, 0x80003099, + 0x000030c1, 0x80003099, 0x000030c4, 0x80003099, + 0x000030c6, 0x80003099, 0x000030c8, 0x80003099, + 0x000030cf, 0x80003099, 0x000030cf, 0x8000309a, + 0x000030d2, 0x80003099, 0x000030d2, 0x8000309a, + 0x000030d5, 0x80003099, 0x000030d5, 0x8000309a, + 0x000030d8, 0x80003099, 0x000030d8, 0x8000309a, + 0x000030db, 0x80003099, 0x000030db, 0x8000309a, + 0x000030a6, 0x80003099, 0x000030ef, 0x80003099, + 0x000030f0, 0x80003099, 0x000030f1, 0x80003099, + 0x000030f2, 0x80003099, 0x000030fd, 0x80003099, + 0x000030b3, 0x800030c8, 0x80001100, 0x80001101, + 0x800011aa, 0x80001102, 0x800011ac, 0x800011ad, + 0x80001103, 0x80001104, 0x80001105, 0x800011b0, + 0x800011b1, 0x800011b2, 0x800011b3, 0x800011b4, + 0x800011b5, 0x8000111a, 0x80001106, 0x80001107, + 0x80001108, 0x80001121, 0x80001109, 0x8000110a, + 0x8000110b, 0x8000110c, 0x8000110d, 0x8000110e, + 0x8000110f, 0x80001110, 0x80001111, 0x80001112, + 0x80001161, 0x80001162, 0x80001163, 0x80001164, + 0x80001165, 0x80001166, 0x80001167, 0x80001168, + 0x80001169, 0x8000116a, 0x8000116b, 0x8000116c, + 0x8000116d, 0x8000116e, 0x8000116f, 0x80001170, + 0x80001171, 0x80001172, 0x80001173, 0x80001174, + 0x80001175, 0x80001160, 0x80001114, 0x80001115, + 0x800011c7, 0x800011c8, 0x800011cc, 0x800011ce, + 0x800011d3, 0x800011d7, 0x800011d9, 0x8000111c, + 0x800011dd, 0x800011df, 0x8000111d, 0x8000111e, + 0x80001120, 0x80001122, 0x80001123, 0x80001127, + 0x80001129, 0x8000112b, 0x8000112c, 0x8000112d, + 0x8000112e, 0x8000112f, 0x80001132, 0x80001136, + 0x80001140, 0x80001147, 0x8000114c, 0x800011f1, + 0x800011f2, 0x80001157, 0x80001158, 0x80001159, + 0x80001184, 0x80001185, 0x80001188, 0x80001191, + 0x80001192, 0x80001194, 0x8000119e, 0x800011a1, + 0x80004e00, 0x80004e8c, 0x80004e09, 0x800056db, + 0x80004e0a, 0x80004e2d, 0x80004e0b, 0x80007532, + 0x80004e59, 0x80004e19, 0x80004e01, 0x80005929, + 0x80005730, 0x80004eba, 0x00000028, 0x00001100, + 0x80000029, 0x00000028, 0x00001102, 0x80000029, + 0x00000028, 0x00001103, 0x80000029, 0x00000028, + 0x00001105, 0x80000029, 0x00000028, 0x00001106, + 0x80000029, 0x00000028, 0x00001107, 0x80000029, + 0x00000028, 0x00001109, 0x80000029, 0x00000028, + 0x0000110b, 0x80000029, 0x00000028, 0x0000110c, + 0x80000029, 0x00000028, 0x0000110e, 0x80000029, + 0x00000028, 0x0000110f, 0x80000029, 0x00000028, + 0x00001110, 0x80000029, 0x00000028, 0x00001111, + 0x80000029, 0x00000028, 0x00001112, 0x80000029, + 0x00000028, 0x00001100, 0x00001161, 0x80000029, + 0x00000028, 0x00001102, 0x00001161, 0x80000029, + 0x00000028, 0x00001103, 0x00001161, 0x80000029, + 0x00000028, 0x00001105, 0x00001161, 0x80000029, + 0x00000028, 0x00001106, 0x00001161, 0x80000029, + 0x00000028, 0x00001107, 0x00001161, 0x80000029, + 0x00000028, 0x00001109, 0x00001161, 0x80000029, + 0x00000028, 0x0000110b, 0x00001161, 0x80000029, + 0x00000028, 0x0000110c, 0x00001161, 0x80000029, + 0x00000028, 0x0000110e, 0x00001161, 0x80000029, + 0x00000028, 0x0000110f, 0x00001161, 0x80000029, + 0x00000028, 0x00001110, 0x00001161, 0x80000029, + 0x00000028, 0x00001111, 0x00001161, 0x80000029, + 0x00000028, 0x00001112, 0x00001161, 0x80000029, + 0x00000028, 0x0000110c, 0x0000116e, 0x80000029, + 0x00000028, 0x00004e00, 0x80000029, 0x00000028, + 0x00004e8c, 0x80000029, 0x00000028, 0x00004e09, + 0x80000029, 0x00000028, 0x000056db, 0x80000029, + 0x00000028, 0x00004e94, 0x80000029, 0x00000028, + 0x0000516d, 0x80000029, 0x00000028, 0x00004e03, + 0x80000029, 0x00000028, 0x0000516b, 0x80000029, + 0x00000028, 0x00004e5d, 0x80000029, 0x00000028, + 0x00005341, 0x80000029, 0x00000028, 0x00006708, + 0x80000029, 0x00000028, 0x0000706b, 0x80000029, + 0x00000028, 0x00006c34, 0x80000029, 0x00000028, + 0x00006728, 0x80000029, 0x00000028, 0x000091d1, + 0x80000029, 0x00000028, 0x0000571f, 0x80000029, + 0x00000028, 0x000065e5, 0x80000029, 0x00000028, + 0x0000682a, 0x80000029, 0x00000028, 0x00006709, + 0x80000029, 0x00000028, 0x0000793e, 0x80000029, + 0x00000028, 0x0000540d, 0x80000029, 0x00000028, + 0x00007279, 0x80000029, 0x00000028, 0x00008ca1, + 0x80000029, 0x00000028, 0x0000795d, 0x80000029, + 0x00000028, 0x000052b4, 0x80000029, 0x00000028, + 0x00004ee3, 0x80000029, 0x00000028, 0x0000547c, + 0x80000029, 0x00000028, 0x00005b66, 0x80000029, + 0x00000028, 0x000076e3, 0x80000029, 0x00000028, + 0x00004f01, 0x80000029, 0x00000028, 0x00008cc7, + 0x80000029, 0x00000028, 0x00005354, 0x80000029, + 0x00000028, 0x0000796d, 0x80000029, 0x00000028, + 0x00004f11, 0x80000029, 0x00000028, 0x000081ea, + 0x80000029, 0x00000028, 0x000081f3, 0x80000029, + 0x00000032, 0x80000031, 0x00000032, 0x80000032, + 0x00000032, 0x80000033, 0x00000032, 0x80000034, + 0x00000032, 0x80000035, 0x00000032, 0x80000036, + 0x00000032, 0x80000037, 0x00000032, 0x80000038, + 0x00000032, 0x80000039, 0x00000033, 0x80000030, + 0x00000033, 0x80000031, 0x00000033, 0x80000032, + 0x00000033, 0x80000033, 0x00000033, 0x80000034, + 0x00000033, 0x80000035, 0x80001100, 0x80001102, + 0x80001103, 0x80001105, 0x80001106, 0x80001107, + 0x80001109, 0x8000110b, 0x8000110c, 0x8000110e, + 0x8000110f, 0x80001110, 0x80001111, 0x80001112, + 0x00001100, 0x80001161, 0x00001102, 0x80001161, + 0x00001103, 0x80001161, 0x00001105, 0x80001161, + 0x00001106, 0x80001161, 0x00001107, 0x80001161, + 0x00001109, 0x80001161, 0x0000110b, 0x80001161, + 0x0000110c, 0x80001161, 0x0000110e, 0x80001161, + 0x0000110f, 0x80001161, 0x00001110, 0x80001161, + 0x00001111, 0x80001161, 0x00001112, 0x80001161, + 0x80004e00, 0x80004e8c, 0x80004e09, 0x800056db, + 0x80004e94, 0x8000516d, 0x80004e03, 0x8000516b, + 0x80004e5d, 0x80005341, 0x80006708, 0x8000706b, + 0x80006c34, 0x80006728, 0x800091d1, 0x8000571f, + 0x800065e5, 0x8000682a, 0x80006709, 0x8000793e, + 0x8000540d, 0x80007279, 0x80008ca1, 0x8000795d, + 0x800052b4, 0x800079d8, 0x80007537, 0x80005973, + 0x80009069, 0x8000512a, 0x80005370, 0x80006ce8, + 0x80009805, 0x80004f11, 0x80005199, 0x80006b63, + 0x80004e0a, 0x80004e2d, 0x80004e0b, 0x80005de6, + 0x800053f3, 0x8000533b, 0x80005b97, 0x80005b66, + 0x800076e3, 0x80004f01, 0x80008cc7, 0x80005354, + 0x8000591c, 0x00000033, 0x80000036, 0x00000033, + 0x80000037, 0x00000033, 0x80000038, 0x00000033, + 0x80000039, 0x00000034, 0x80000030, 0x00000034, + 0x80000031, 0x00000034, 0x80000032, 0x00000034, + 0x80000033, 0x00000034, 0x80000034, 0x00000034, + 0x80000035, 0x00000034, 0x80000036, 0x00000034, + 0x80000037, 0x00000034, 0x80000038, 0x00000034, + 0x80000039, 0x00000035, 0x80000030, 0x00000031, + 0x80006708, 0x00000032, 0x80006708, 0x00000033, + 0x80006708, 0x00000034, 0x80006708, 0x00000035, + 0x80006708, 0x00000036, 0x80006708, 0x00000037, + 0x80006708, 0x00000038, 0x80006708, 0x00000039, + 0x80006708, 0x00000031, 0x00000030, 0x80006708, + 0x00000031, 0x00000031, 0x80006708, 0x00000031, + 0x00000032, 0x80006708, 0x800030a2, 0x800030a4, + 0x800030a6, 0x800030a8, 0x800030aa, 0x800030ab, + 0x800030ad, 0x800030af, 0x800030b1, 0x800030b3, + 0x800030b5, 0x800030b7, 0x800030b9, 0x800030bb, + 0x800030bd, 0x800030bf, 0x800030c1, 0x800030c4, + 0x800030c6, 0x800030c8, 0x800030ca, 0x800030cb, + 0x800030cc, 0x800030cd, 0x800030ce, 0x800030cf, + 0x800030d2, 0x800030d5, 0x800030d8, 0x800030db, + 0x800030de, 0x800030df, 0x800030e0, 0x800030e1, + 0x800030e2, 0x800030e4, 0x800030e6, 0x800030e8, + 0x800030e9, 0x800030ea, 0x800030eb, 0x800030ec, + 0x800030ed, 0x800030ef, 0x800030f0, 0x800030f1, + 0x800030f2, 0x000030a2, 0x000030d1, 0x000030fc, + 0x800030c8, 0x000030a2, 0x000030eb, 0x000030d5, + 0x800030a1, 0x000030a2, 0x000030f3, 0x000030da, + 0x800030a2, 0x000030a2, 0x000030fc, 0x800030eb, + 0x000030a4, 0x000030cb, 0x000030f3, 0x800030b0, + 0x000030a4, 0x000030f3, 0x800030c1, 0x000030a6, + 0x000030a9, 0x800030f3, 0x000030a8, 0x000030b9, + 0x000030af, 0x000030fc, 0x800030c9, 0x000030a8, + 0x000030fc, 0x000030ab, 0x800030fc, 0x000030aa, + 0x000030f3, 0x800030b9, 0x000030aa, 0x000030fc, + 0x800030e0, 0x000030ab, 0x000030a4, 0x800030ea, + 0x000030ab, 0x000030e9, 0x000030c3, 0x800030c8, + 0x000030ab, 0x000030ed, 0x000030ea, 0x800030fc, + 0x000030ac, 0x000030ed, 0x800030f3, 0x000030ac, + 0x000030f3, 0x800030de, 0x000030ae, 0x800030ac, + 0x000030ae, 0x000030cb, 0x800030fc, 0x000030ad, + 0x000030e5, 0x000030ea, 0x800030fc, 0x000030ae, + 0x000030eb, 0x000030c0, 0x800030fc, 0x000030ad, + 0x800030ed, 0x000030ad, 0x000030ed, 0x000030b0, + 0x000030e9, 0x800030e0, 0x000030ad, 0x000030ed, + 0x000030e1, 0x000030fc, 0x000030c8, 0x800030eb, + 0x000030ad, 0x000030ed, 0x000030ef, 0x000030c3, + 0x800030c8, 0x000030b0, 0x000030e9, 0x800030e0, + 0x000030b0, 0x000030e9, 0x000030e0, 0x000030c8, + 0x800030f3, 0x000030af, 0x000030eb, 0x000030bc, + 0x000030a4, 0x800030ed, 0x000030af, 0x000030ed, + 0x000030fc, 0x800030cd, 0x000030b1, 0x000030fc, + 0x800030b9, 0x000030b3, 0x000030eb, 0x800030ca, + 0x000030b3, 0x000030fc, 0x800030dd, 0x000030b5, + 0x000030a4, 0x000030af, 0x800030eb, 0x000030b5, + 0x000030f3, 0x000030c1, 0x000030fc, 0x800030e0, + 0x000030b7, 0x000030ea, 0x000030f3, 0x800030b0, + 0x000030bb, 0x000030f3, 0x800030c1, 0x000030bb, + 0x000030f3, 0x800030c8, 0x000030c0, 0x000030fc, + 0x800030b9, 0x000030c7, 0x800030b7, 0x000030c9, + 0x800030eb, 0x000030c8, 0x800030f3, 0x000030ca, + 0x800030ce, 0x000030ce, 0x000030c3, 0x800030c8, + 0x000030cf, 0x000030a4, 0x800030c4, 0x000030d1, + 0x000030fc, 0x000030bb, 0x000030f3, 0x800030c8, + 0x000030d1, 0x000030fc, 0x800030c4, 0x000030d0, + 0x000030fc, 0x000030ec, 0x800030eb, 0x000030d4, + 0x000030a2, 0x000030b9, 0x000030c8, 0x800030eb, + 0x000030d4, 0x000030af, 0x800030eb, 0x000030d4, + 0x800030b3, 0x000030d3, 0x800030eb, 0x000030d5, + 0x000030a1, 0x000030e9, 0x000030c3, 0x800030c9, + 0x000030d5, 0x000030a3, 0x000030fc, 0x800030c8, + 0x000030d6, 0x000030c3, 0x000030b7, 0x000030a7, + 0x800030eb, 0x000030d5, 0x000030e9, 0x800030f3, + 0x000030d8, 0x000030af, 0x000030bf, 0x000030fc, + 0x800030eb, 0x000030da, 0x800030bd, 0x000030da, + 0x000030cb, 0x800030d2, 0x000030d8, 0x000030eb, + 0x800030c4, 0x000030da, 0x000030f3, 0x800030b9, + 0x000030da, 0x000030fc, 0x800030b8, 0x000030d9, + 0x000030fc, 0x800030bf, 0x000030dd, 0x000030a4, + 0x000030f3, 0x800030c8, 0x000030dc, 0x000030eb, + 0x800030c8, 0x000030db, 0x800030f3, 0x000030dd, + 0x000030f3, 0x800030c9, 0x000030db, 0x000030fc, + 0x800030eb, 0x000030db, 0x000030fc, 0x800030f3, + 0x000030de, 0x000030a4, 0x000030af, 0x800030ed, + 0x000030de, 0x000030a4, 0x800030eb, 0x000030de, + 0x000030c3, 0x800030cf, 0x000030de, 0x000030eb, + 0x800030af, 0x000030de, 0x000030f3, 0x000030b7, + 0x000030e7, 0x800030f3, 0x000030df, 0x000030af, + 0x000030ed, 0x800030f3, 0x000030df, 0x800030ea, + 0x000030df, 0x000030ea, 0x000030d0, 0x000030fc, + 0x800030eb, 0x000030e1, 0x800030ac, 0x000030e1, + 0x000030ac, 0x000030c8, 0x800030f3, 0x000030e1, + 0x000030fc, 0x000030c8, 0x800030eb, 0x000030e4, + 0x000030fc, 0x800030c9, 0x000030e4, 0x000030fc, + 0x800030eb, 0x000030e6, 0x000030a2, 0x800030f3, + 0x000030ea, 0x000030c3, 0x000030c8, 0x800030eb, + 0x000030ea, 0x800030e9, 0x000030eb, 0x000030d4, + 0x800030fc, 0x000030eb, 0x000030fc, 0x000030d6, + 0x800030eb, 0x000030ec, 0x800030e0, 0x000030ec, + 0x000030f3, 0x000030c8, 0x000030b2, 0x800030f3, + 0x000030ef, 0x000030c3, 0x800030c8, 0x00000030, + 0x800070b9, 0x00000031, 0x800070b9, 0x00000032, + 0x800070b9, 0x00000033, 0x800070b9, 0x00000034, + 0x800070b9, 0x00000035, 0x800070b9, 0x00000036, + 0x800070b9, 0x00000037, 0x800070b9, 0x00000038, + 0x800070b9, 0x00000039, 0x800070b9, 0x00000031, + 0x00000030, 0x800070b9, 0x00000031, 0x00000031, + 0x800070b9, 0x00000031, 0x00000032, 0x800070b9, + 0x00000031, 0x00000033, 0x800070b9, 0x00000031, + 0x00000034, 0x800070b9, 0x00000031, 0x00000035, + 0x800070b9, 0x00000031, 0x00000036, 0x800070b9, + 0x00000031, 0x00000037, 0x800070b9, 0x00000031, + 0x00000038, 0x800070b9, 0x00000031, 0x00000039, + 0x800070b9, 0x00000032, 0x00000030, 0x800070b9, + 0x00000032, 0x00000031, 0x800070b9, 0x00000032, + 0x00000032, 0x800070b9, 0x00000032, 0x00000033, + 0x800070b9, 0x00000032, 0x00000034, 0x800070b9, + 0x00000068, 0x00000050, 0x80000061, 0x00000064, + 0x80000061, 0x00000041, 0x80000055, 0x00000062, + 0x00000061, 0x80000072, 0x0000006f, 0x80000056, + 0x00000070, 0x80000063, 0x00005e73, 0x80006210, + 0x0000662d, 0x8000548c, 0x00005927, 0x80006b63, + 0x0000660e, 0x80006cbb, 0x0000682a, 0x00005f0f, + 0x00004f1a, 0x8000793e, 0x00000070, 0x80000041, + 0x0000006e, 0x80000041, 0x000003bc, 0x80000041, + 0x0000006d, 0x80000041, 0x0000006b, 0x80000041, + 0x0000004b, 0x80000042, 0x0000004d, 0x80000042, + 0x00000047, 0x80000042, 0x00000063, 0x00000061, + 0x8000006c, 0x0000006b, 0x00000063, 0x00000061, + 0x8000006c, 0x00000070, 0x80000046, 0x0000006e, + 0x80000046, 0x000003bc, 0x80000046, 0x000003bc, + 0x80000067, 0x0000006d, 0x80000067, 0x0000006b, + 0x80000067, 0x00000048, 0x8000007a, 0x0000006b, + 0x00000048, 0x8000007a, 0x0000004d, 0x00000048, + 0x8000007a, 0x00000047, 0x00000048, 0x8000007a, + 0x00000054, 0x00000048, 0x8000007a, 0x000003bc, + 0x80002113, 0x0000006d, 0x80002113, 0x00000064, + 0x80002113, 0x0000006b, 0x80002113, 0x00000066, + 0x8000006d, 0x0000006e, 0x8000006d, 0x000003bc, + 0x8000006d, 0x0000006d, 0x8000006d, 0x00000063, + 0x8000006d, 0x0000006b, 0x8000006d, 0x0000006d, + 0x0000006d, 0x800000b2, 0x00000063, 0x0000006d, + 0x800000b2, 0x0000006d, 0x800000b2, 0x0000006b, + 0x0000006d, 0x800000b2, 0x0000006d, 0x0000006d, + 0x800000b3, 0x00000063, 0x0000006d, 0x800000b3, + 0x0000006d, 0x800000b3, 0x0000006b, 0x0000006d, + 0x800000b3, 0x0000006d, 0x00002215, 0x80000073, + 0x0000006d, 0x00002215, 0x00000073, 0x800000b2, + 0x00000050, 0x80000061, 0x0000006b, 0x00000050, + 0x80000061, 0x0000004d, 0x00000050, 0x80000061, + 0x00000047, 0x00000050, 0x80000061, 0x00000072, + 0x00000061, 0x80000064, 0x00000072, 0x00000061, + 0x00000064, 0x00002215, 0x80000073, 0x00000072, + 0x00000061, 0x00000064, 0x00002215, 0x00000073, + 0x800000b2, 0x00000070, 0x80000073, 0x0000006e, + 0x80000073, 0x000003bc, 0x80000073, 0x0000006d, + 0x80000073, 0x00000070, 0x80000056, 0x0000006e, + 0x80000056, 0x000003bc, 0x80000056, 0x0000006d, + 0x80000056, 0x0000006b, 0x80000056, 0x0000004d, + 0x80000056, 0x00000070, 0x80000057, 0x0000006e, + 0x80000057, 0x000003bc, 0x80000057, 0x0000006d, + 0x80000057, 0x0000006b, 0x80000057, 0x0000004d, + 0x80000057, 0x0000006b, 0x800003a9, 0x0000004d, + 0x800003a9, 0x00000061, 0x0000002e, 0x0000006d, + 0x8000002e, 0x00000042, 0x80000071, 0x00000063, + 0x80000063, 0x00000063, 0x80000064, 0x00000043, + 0x00002215, 0x0000006b, 0x80000067, 0x00000043, + 0x0000006f, 0x8000002e, 0x00000064, 0x80000042, + 0x00000047, 0x80000079, 0x00000068, 0x80000061, + 0x00000048, 0x80000050, 0x00000069, 0x8000006e, + 0x0000004b, 0x8000004b, 0x0000004b, 0x8000004d, + 0x0000006b, 0x80000074, 0x0000006c, 0x8000006d, + 0x0000006c, 0x8000006e, 0x0000006c, 0x0000006f, + 0x80000067, 0x0000006c, 0x80000078, 0x0000006d, + 0x80000062, 0x0000006d, 0x00000069, 0x8000006c, + 0x0000006d, 0x0000006f, 0x8000006c, 0x00000050, + 0x80000048, 0x00000070, 0x0000002e, 0x0000006d, + 0x8000002e, 0x00000050, 0x00000050, 0x8000004d, + 0x00000050, 0x80000052, 0x00000073, 0x80000072, + 0x00000053, 0x80000076, 0x00000057, 0x80000062, + 0x00000031, 0x800065e5, 0x00000032, 0x800065e5, + 0x00000033, 0x800065e5, 0x00000034, 0x800065e5, + 0x00000035, 0x800065e5, 0x00000036, 0x800065e5, + 0x00000037, 0x800065e5, 0x00000038, 0x800065e5, + 0x00000039, 0x800065e5, 0x00000031, 0x00000030, + 0x800065e5, 0x00000031, 0x00000031, 0x800065e5, + 0x00000031, 0x00000032, 0x800065e5, 0x00000031, + 0x00000033, 0x800065e5, 0x00000031, 0x00000034, + 0x800065e5, 0x00000031, 0x00000035, 0x800065e5, + 0x00000031, 0x00000036, 0x800065e5, 0x00000031, + 0x00000037, 0x800065e5, 0x00000031, 0x00000038, + 0x800065e5, 0x00000031, 0x00000039, 0x800065e5, + 0x00000032, 0x00000030, 0x800065e5, 0x00000032, + 0x00000031, 0x800065e5, 0x00000032, 0x00000032, + 0x800065e5, 0x00000032, 0x00000033, 0x800065e5, + 0x00000032, 0x00000034, 0x800065e5, 0x00000032, + 0x00000035, 0x800065e5, 0x00000032, 0x00000036, + 0x800065e5, 0x00000032, 0x00000037, 0x800065e5, + 0x00000032, 0x00000038, 0x800065e5, 0x00000032, + 0x00000039, 0x800065e5, 0x00000033, 0x00000030, + 0x800065e5, 0x00000033, 0x00000031, 0x800065e5, + 0x80008c48, 0x800066f4, 0x80008eca, 0x80008cc8, + 0x80006ed1, 0x80004e32, 0x800053e5, 0x80009f9c, + 0x80009f9c, 0x80005951, 0x800091d1, 0x80005587, + 0x80005948, 0x800061f6, 0x80007669, 0x80007f85, + 0x8000863f, 0x800087ba, 0x800088f8, 0x8000908f, + 0x80006a02, 0x80006d1b, 0x800070d9, 0x800073de, + 0x8000843d, 0x8000916a, 0x800099f1, 0x80004e82, + 0x80005375, 0x80006b04, 0x8000721b, 0x8000862d, + 0x80009e1e, 0x80005d50, 0x80006feb, 0x800085cd, + 0x80008964, 0x800062c9, 0x800081d8, 0x8000881f, + 0x80005eca, 0x80006717, 0x80006d6a, 0x800072fc, + 0x800090ce, 0x80004f86, 0x800051b7, 0x800052de, + 0x800064c4, 0x80006ad3, 0x80007210, 0x800076e7, + 0x80008001, 0x80008606, 0x8000865c, 0x80008def, + 0x80009732, 0x80009b6f, 0x80009dfa, 0x8000788c, + 0x8000797f, 0x80007da0, 0x800083c9, 0x80009304, + 0x80009e7f, 0x80008ad6, 0x800058df, 0x80005f04, + 0x80007c60, 0x8000807e, 0x80007262, 0x800078ca, + 0x80008cc2, 0x800096f7, 0x800058d8, 0x80005c62, + 0x80006a13, 0x80006dda, 0x80006f0f, 0x80007d2f, + 0x80007e37, 0x8000964b, 0x800052d2, 0x8000808b, + 0x800051dc, 0x800051cc, 0x80007a1c, 0x80007dbe, + 0x800083f1, 0x80009675, 0x80008b80, 0x800062cf, + 0x80006a02, 0x80008afe, 0x80004e39, 0x80005be7, + 0x80006012, 0x80007387, 0x80007570, 0x80005317, + 0x800078fb, 0x80004fbf, 0x80005fa9, 0x80004e0d, + 0x80006ccc, 0x80006578, 0x80007d22, 0x800053c3, + 0x8000585e, 0x80007701, 0x80008449, 0x80008aaa, + 0x80006bba, 0x80008fb0, 0x80006c88, 0x800062fe, + 0x800082e5, 0x800063a0, 0x80007565, 0x80004eae, + 0x80005169, 0x800051c9, 0x80006881, 0x80007ce7, + 0x8000826f, 0x80008ad2, 0x800091cf, 0x800052f5, + 0x80005442, 0x80005973, 0x80005eec, 0x800065c5, + 0x80006ffe, 0x8000792a, 0x800095ad, 0x80009a6a, + 0x80009e97, 0x80009ece, 0x8000529b, 0x800066c6, + 0x80006b77, 0x80008f62, 0x80005e74, 0x80006190, + 0x80006200, 0x8000649a, 0x80006f23, 0x80007149, + 0x80007489, 0x800079ca, 0x80007df4, 0x8000806f, + 0x80008f26, 0x800084ee, 0x80009023, 0x8000934a, + 0x80005217, 0x800052a3, 0x800054bd, 0x800070c8, + 0x800088c2, 0x80008aaa, 0x80005ec9, 0x80005ff5, + 0x8000637b, 0x80006bae, 0x80007c3e, 0x80007375, + 0x80004ee4, 0x800056f9, 0x80005be7, 0x80005dba, + 0x8000601c, 0x800073b2, 0x80007469, 0x80007f9a, + 0x80008046, 0x80009234, 0x800096f6, 0x80009748, + 0x80009818, 0x80004f8b, 0x800079ae, 0x800091b4, + 0x800096b8, 0x800060e1, 0x80004e86, 0x800050da, + 0x80005bee, 0x80005c3f, 0x80006599, 0x80006a02, + 0x800071ce, 0x80007642, 0x800084fc, 0x8000907c, + 0x80009f8d, 0x80006688, 0x8000962e, 0x80005289, + 0x8000677b, 0x800067f3, 0x80006d41, 0x80006e9c, + 0x80007409, 0x80007559, 0x8000786b, 0x80007d10, + 0x8000985e, 0x8000516d, 0x8000622e, 0x80009678, + 0x8000502b, 0x80005d19, 0x80006dea, 0x80008f2a, + 0x80005f8b, 0x80006144, 0x80006817, 0x80007387, + 0x80009686, 0x80005229, 0x8000540f, 0x80005c65, + 0x80006613, 0x8000674e, 0x800068a8, 0x80006ce5, + 0x80007406, 0x800075e2, 0x80007f79, 0x800088cf, + 0x800088e1, 0x800091cc, 0x800096e2, 0x8000533f, + 0x80006eba, 0x8000541d, 0x800071d0, 0x80007498, + 0x800085fa, 0x800096a3, 0x80009c57, 0x80009e9f, + 0x80006797, 0x80006dcb, 0x800081e8, 0x80007acb, + 0x80007b20, 0x80007c92, 0x800072c0, 0x80007099, + 0x80008b58, 0x80004ec0, 0x80008336, 0x8000523a, + 0x80005207, 0x80005ea6, 0x800062d3, 0x80007cd6, + 0x80005b85, 0x80006d1e, 0x800066b4, 0x80008f3b, + 0x8000884c, 0x8000964d, 0x8000898b, 0x80005ed3, + 0x80005140, 0x800055c0, 0x8000585a, 0x80006674, + 0x800051de, 0x8000732a, 0x800076ca, 0x8000793c, + 0x8000795e, 0x80007965, 0x8000798f, 0x80009756, + 0x80007cbe, 0x80007fbd, 0x80008612, 0x80008af8, + 0x80009038, 0x800090fd, 0x800098ef, 0x800098fc, + 0x80009928, 0x80009db4, 0x80004fae, 0x800050e7, + 0x8000514d, 0x800052c9, 0x800052e4, 0x80005351, + 0x8000559d, 0x80005606, 0x80005668, 0x80005840, + 0x800058a8, 0x80005c64, 0x80005c6e, 0x80006094, + 0x80006168, 0x8000618e, 0x800061f2, 0x8000654f, + 0x800065e2, 0x80006691, 0x80006885, 0x80006d77, + 0x80006e1a, 0x80006f22, 0x8000716e, 0x8000722b, + 0x80007422, 0x80007891, 0x8000793e, 0x80007949, + 0x80007948, 0x80007950, 0x80007956, 0x8000795d, + 0x8000798d, 0x8000798e, 0x80007a40, 0x80007a81, + 0x80007bc0, 0x80007df4, 0x80007e09, 0x80007e41, + 0x80007f72, 0x80008005, 0x800081ed, 0x80008279, + 0x80008279, 0x80008457, 0x80008910, 0x80008996, + 0x80008b01, 0x80008b39, 0x80008cd3, 0x80008d08, + 0x80008fb6, 0x80009038, 0x800096e3, 0x800097ff, + 0x8000983b, 0x00000066, 0x80000066, 0x00000066, + 0x80000069, 0x00000066, 0x8000006c, 0x00000066, + 0x00000066, 0x80000069, 0x00000066, 0x00000066, + 0x8000006c, 0x0000017f, 0x80000074, 0x00000073, + 0x80000074, 0x00000574, 0x80000576, 0x00000574, + 0x80000565, 0x00000574, 0x8000056b, 0x0000057e, + 0x80000576, 0x00000574, 0x8000056d, 0x000005d9, + 0x800005b4, 0x000005f2, 0x800005b7, 0x800005e2, + 0x800005d0, 0x800005d3, 0x800005d4, 0x800005db, + 0x800005dc, 0x800005dd, 0x800005e8, 0x800005ea, + 0x8000002b, 0x000005e9, 0x800005c1, 0x000005e9, + 0x800005c2, 0x0000fb49, 0x800005c1, 0x0000fb49, + 0x800005c2, 0x000005d0, 0x800005b7, 0x000005d0, + 0x800005b8, 0x000005d0, 0x800005bc, 0x000005d1, + 0x800005bc, 0x000005d2, 0x800005bc, 0x000005d3, + 0x800005bc, 0x000005d4, 0x800005bc, 0x000005d5, + 0x800005bc, 0x000005d6, 0x800005bc, 0x000005d8, + 0x800005bc, 0x000005d9, 0x800005bc, 0x000005da, + 0x800005bc, 0x000005db, 0x800005bc, 0x000005dc, + 0x800005bc, 0x000005de, 0x800005bc, 0x000005e0, + 0x800005bc, 0x000005e1, 0x800005bc, 0x000005e3, + 0x800005bc, 0x000005e4, 0x800005bc, 0x000005e6, + 0x800005bc, 0x000005e7, 0x800005bc, 0x000005e8, + 0x800005bc, 0x000005e9, 0x800005bc, 0x000005ea, + 0x800005bc, 0x000005d5, 0x800005b9, 0x000005d1, + 0x800005bf, 0x000005db, 0x800005bf, 0x000005e4, + 0x800005bf, 0x000005d0, 0x800005dc, 0x80000671, + 0x80000671, 0x8000067b, 0x8000067b, 0x8000067b, + 0x8000067b, 0x8000067e, 0x8000067e, 0x8000067e, + 0x8000067e, 0x80000680, 0x80000680, 0x80000680, + 0x80000680, 0x8000067a, 0x8000067a, 0x8000067a, + 0x8000067a, 0x8000067f, 0x8000067f, 0x8000067f, + 0x8000067f, 0x80000679, 0x80000679, 0x80000679, + 0x80000679, 0x800006a4, 0x800006a4, 0x800006a4, + 0x800006a4, 0x800006a6, 0x800006a6, 0x800006a6, + 0x800006a6, 0x80000684, 0x80000684, 0x80000684, + 0x80000684, 0x80000683, 0x80000683, 0x80000683, + 0x80000683, 0x80000686, 0x80000686, 0x80000686, + 0x80000686, 0x80000687, 0x80000687, 0x80000687, + 0x80000687, 0x8000068d, 0x8000068d, 0x8000068c, + 0x8000068c, 0x8000068e, 0x8000068e, 0x80000688, + 0x80000688, 0x80000698, 0x80000698, 0x80000691, + 0x80000691, 0x800006a9, 0x800006a9, 0x800006a9, + 0x800006a9, 0x800006af, 0x800006af, 0x800006af, + 0x800006af, 0x800006b3, 0x800006b3, 0x800006b3, + 0x800006b3, 0x800006b1, 0x800006b1, 0x800006b1, + 0x800006b1, 0x800006ba, 0x800006ba, 0x800006bb, + 0x800006bb, 0x800006bb, 0x800006bb, 0x800006c0, + 0x800006c0, 0x800006c1, 0x800006c1, 0x800006c1, + 0x800006c1, 0x800006be, 0x800006be, 0x800006be, + 0x800006be, 0x800006d2, 0x800006d2, 0x800006d3, + 0x800006d3, 0x800006ad, 0x800006ad, 0x800006ad, + 0x800006ad, 0x800006c7, 0x800006c7, 0x800006c6, + 0x800006c6, 0x800006c8, 0x800006c8, 0x80000677, + 0x800006cb, 0x800006cb, 0x800006c5, 0x800006c5, + 0x800006c9, 0x800006c9, 0x800006d0, 0x800006d0, + 0x800006d0, 0x800006d0, 0x80000649, 0x80000649, + 0x00000626, 0x80000627, 0x00000626, 0x80000627, + 0x00000626, 0x800006d5, 0x00000626, 0x800006d5, + 0x00000626, 0x80000648, 0x00000626, 0x80000648, + 0x00000626, 0x800006c7, 0x00000626, 0x800006c7, + 0x00000626, 0x800006c6, 0x00000626, 0x800006c6, + 0x00000626, 0x800006c8, 0x00000626, 0x800006c8, + 0x00000626, 0x800006d0, 0x00000626, 0x800006d0, + 0x00000626, 0x800006d0, 0x00000626, 0x80000649, + 0x00000626, 0x80000649, 0x00000626, 0x80000649, + 0x800006cc, 0x800006cc, 0x800006cc, 0x800006cc, + 0x00000626, 0x8000062c, 0x00000626, 0x8000062d, + 0x00000626, 0x80000645, 0x00000626, 0x80000649, + 0x00000626, 0x8000064a, 0x00000628, 0x8000062c, + 0x00000628, 0x8000062d, 0x00000628, 0x8000062e, + 0x00000628, 0x80000645, 0x00000628, 0x80000649, + 0x00000628, 0x8000064a, 0x0000062a, 0x8000062c, + 0x0000062a, 0x8000062d, 0x0000062a, 0x8000062e, + 0x0000062a, 0x80000645, 0x0000062a, 0x80000649, + 0x0000062a, 0x8000064a, 0x0000062b, 0x8000062c, + 0x0000062b, 0x80000645, 0x0000062b, 0x80000649, + 0x0000062b, 0x8000064a, 0x0000062c, 0x8000062d, + 0x0000062c, 0x80000645, 0x0000062d, 0x8000062c, + 0x0000062d, 0x80000645, 0x0000062e, 0x8000062c, + 0x0000062e, 0x8000062d, 0x0000062e, 0x80000645, + 0x00000633, 0x8000062c, 0x00000633, 0x8000062d, + 0x00000633, 0x8000062e, 0x00000633, 0x80000645, + 0x00000635, 0x8000062d, 0x00000635, 0x80000645, + 0x00000636, 0x8000062c, 0x00000636, 0x8000062d, + 0x00000636, 0x8000062e, 0x00000636, 0x80000645, + 0x00000637, 0x8000062d, 0x00000637, 0x80000645, + 0x00000638, 0x80000645, 0x00000639, 0x8000062c, + 0x00000639, 0x80000645, 0x0000063a, 0x8000062c, + 0x0000063a, 0x80000645, 0x00000641, 0x8000062c, + 0x00000641, 0x8000062d, 0x00000641, 0x8000062e, + 0x00000641, 0x80000645, 0x00000641, 0x80000649, + 0x00000641, 0x8000064a, 0x00000642, 0x8000062d, + 0x00000642, 0x80000645, 0x00000642, 0x80000649, + 0x00000642, 0x8000064a, 0x00000643, 0x80000627, + 0x00000643, 0x8000062c, 0x00000643, 0x8000062d, + 0x00000643, 0x8000062e, 0x00000643, 0x80000644, + 0x00000643, 0x80000645, 0x00000643, 0x80000649, + 0x00000643, 0x8000064a, 0x00000644, 0x8000062c, + 0x00000644, 0x8000062d, 0x00000644, 0x8000062e, + 0x00000644, 0x80000645, 0x00000644, 0x80000649, + 0x00000644, 0x8000064a, 0x00000645, 0x8000062c, + 0x00000645, 0x8000062d, 0x00000645, 0x8000062e, + 0x00000645, 0x80000645, 0x00000645, 0x80000649, + 0x00000645, 0x8000064a, 0x00000646, 0x8000062c, + 0x00000646, 0x8000062d, 0x00000646, 0x8000062e, + 0x00000646, 0x80000645, 0x00000646, 0x80000649, + 0x00000646, 0x8000064a, 0x00000647, 0x8000062c, + 0x00000647, 0x80000645, 0x00000647, 0x80000649, + 0x00000647, 0x8000064a, 0x0000064a, 0x8000062c, + 0x0000064a, 0x8000062d, 0x0000064a, 0x8000062e, + 0x0000064a, 0x80000645, 0x0000064a, 0x80000649, + 0x0000064a, 0x8000064a, 0x00000630, 0x80000670, + 0x00000631, 0x80000670, 0x00000649, 0x80000670, + 0x00000020, 0x0000064c, 0x80000651, 0x00000020, + 0x0000064d, 0x80000651, 0x00000020, 0x0000064e, + 0x80000651, 0x00000020, 0x0000064f, 0x80000651, + 0x00000020, 0x00000650, 0x80000651, 0x00000020, + 0x00000651, 0x80000670, 0x00000626, 0x80000631, + 0x00000626, 0x80000632, 0x00000626, 0x80000645, + 0x00000626, 0x80000646, 0x00000626, 0x80000649, + 0x00000626, 0x8000064a, 0x00000628, 0x80000631, + 0x00000628, 0x80000632, 0x00000628, 0x80000645, + 0x00000628, 0x80000646, 0x00000628, 0x80000649, + 0x00000628, 0x8000064a, 0x0000062a, 0x80000631, + 0x0000062a, 0x80000632, 0x0000062a, 0x80000645, + 0x0000062a, 0x80000646, 0x0000062a, 0x80000649, + 0x0000062a, 0x8000064a, 0x0000062b, 0x80000631, + 0x0000062b, 0x80000632, 0x0000062b, 0x80000645, + 0x0000062b, 0x80000646, 0x0000062b, 0x80000649, + 0x0000062b, 0x8000064a, 0x00000641, 0x80000649, + 0x00000641, 0x8000064a, 0x00000642, 0x80000649, + 0x00000642, 0x8000064a, 0x00000643, 0x80000627, + 0x00000643, 0x80000644, 0x00000643, 0x80000645, + 0x00000643, 0x80000649, 0x00000643, 0x8000064a, + 0x00000644, 0x80000645, 0x00000644, 0x80000649, + 0x00000644, 0x8000064a, 0x00000645, 0x80000627, + 0x00000645, 0x80000645, 0x00000646, 0x80000631, + 0x00000646, 0x80000632, 0x00000646, 0x80000645, + 0x00000646, 0x80000646, 0x00000646, 0x80000649, + 0x00000646, 0x8000064a, 0x00000649, 0x80000670, + 0x0000064a, 0x80000631, 0x0000064a, 0x80000632, + 0x0000064a, 0x80000645, 0x0000064a, 0x80000646, + 0x0000064a, 0x80000649, 0x0000064a, 0x8000064a, + 0x00000626, 0x8000062c, 0x00000626, 0x8000062d, + 0x00000626, 0x8000062e, 0x00000626, 0x80000645, + 0x00000626, 0x80000647, 0x00000628, 0x8000062c, + 0x00000628, 0x8000062d, 0x00000628, 0x8000062e, + 0x00000628, 0x80000645, 0x00000628, 0x80000647, + 0x0000062a, 0x8000062c, 0x0000062a, 0x8000062d, + 0x0000062a, 0x8000062e, 0x0000062a, 0x80000645, + 0x0000062a, 0x80000647, 0x0000062b, 0x80000645, + 0x0000062c, 0x8000062d, 0x0000062c, 0x80000645, + 0x0000062d, 0x8000062c, 0x0000062d, 0x80000645, + 0x0000062e, 0x8000062c, 0x0000062e, 0x80000645, + 0x00000633, 0x8000062c, 0x00000633, 0x8000062d, + 0x00000633, 0x8000062e, 0x00000633, 0x80000645, + 0x00000635, 0x8000062d, 0x00000635, 0x8000062e, + 0x00000635, 0x80000645, 0x00000636, 0x8000062c, + 0x00000636, 0x8000062d, 0x00000636, 0x8000062e, + 0x00000636, 0x80000645, 0x00000637, 0x8000062d, + 0x00000638, 0x80000645, 0x00000639, 0x8000062c, + 0x00000639, 0x80000645, 0x0000063a, 0x8000062c, + 0x0000063a, 0x80000645, 0x00000641, 0x8000062c, + 0x00000641, 0x8000062d, 0x00000641, 0x8000062e, + 0x00000641, 0x80000645, 0x00000642, 0x8000062d, + 0x00000642, 0x80000645, 0x00000643, 0x8000062c, + 0x00000643, 0x8000062d, 0x00000643, 0x8000062e, + 0x00000643, 0x80000644, 0x00000643, 0x80000645, + 0x00000644, 0x8000062c, 0x00000644, 0x8000062d, + 0x00000644, 0x8000062e, 0x00000644, 0x80000645, + 0x00000644, 0x80000647, 0x00000645, 0x8000062c, + 0x00000645, 0x8000062d, 0x00000645, 0x8000062e, + 0x00000645, 0x80000645, 0x00000646, 0x8000062c, + 0x00000646, 0x8000062d, 0x00000646, 0x8000062e, + 0x00000646, 0x80000645, 0x00000646, 0x80000647, + 0x00000647, 0x8000062c, 0x00000647, 0x80000645, + 0x00000647, 0x80000670, 0x0000064a, 0x8000062c, + 0x0000064a, 0x8000062d, 0x0000064a, 0x8000062e, + 0x0000064a, 0x80000645, 0x0000064a, 0x80000647, + 0x00000626, 0x80000645, 0x00000626, 0x80000647, + 0x00000628, 0x80000645, 0x00000628, 0x80000647, + 0x0000062a, 0x80000645, 0x0000062a, 0x80000647, + 0x0000062b, 0x80000645, 0x0000062b, 0x80000647, + 0x00000633, 0x80000645, 0x00000633, 0x80000647, + 0x00000634, 0x80000645, 0x00000634, 0x80000647, + 0x00000643, 0x80000644, 0x00000643, 0x80000645, + 0x00000644, 0x80000645, 0x00000646, 0x80000645, + 0x00000646, 0x80000647, 0x0000064a, 0x80000645, + 0x0000064a, 0x80000647, 0x00000640, 0x0000064e, + 0x80000651, 0x00000640, 0x0000064f, 0x80000651, + 0x00000640, 0x00000650, 0x80000651, 0x00000637, + 0x80000649, 0x00000637, 0x8000064a, 0x00000639, + 0x80000649, 0x00000639, 0x8000064a, 0x0000063a, + 0x80000649, 0x0000063a, 0x8000064a, 0x00000633, + 0x80000649, 0x00000633, 0x8000064a, 0x00000634, + 0x80000649, 0x00000634, 0x8000064a, 0x0000062d, + 0x80000649, 0x0000062d, 0x8000064a, 0x0000062c, + 0x80000649, 0x0000062c, 0x8000064a, 0x0000062e, + 0x80000649, 0x0000062e, 0x8000064a, 0x00000635, + 0x80000649, 0x00000635, 0x8000064a, 0x00000636, + 0x80000649, 0x00000636, 0x8000064a, 0x00000634, + 0x8000062c, 0x00000634, 0x8000062d, 0x00000634, + 0x8000062e, 0x00000634, 0x80000645, 0x00000634, + 0x80000631, 0x00000633, 0x80000631, 0x00000635, + 0x80000631, 0x00000636, 0x80000631, 0x00000637, + 0x80000649, 0x00000637, 0x8000064a, 0x00000639, + 0x80000649, 0x00000639, 0x8000064a, 0x0000063a, + 0x80000649, 0x0000063a, 0x8000064a, 0x00000633, + 0x80000649, 0x00000633, 0x8000064a, 0x00000634, + 0x80000649, 0x00000634, 0x8000064a, 0x0000062d, + 0x80000649, 0x0000062d, 0x8000064a, 0x0000062c, + 0x80000649, 0x0000062c, 0x8000064a, 0x0000062e, + 0x80000649, 0x0000062e, 0x8000064a, 0x00000635, + 0x80000649, 0x00000635, 0x8000064a, 0x00000636, + 0x80000649, 0x00000636, 0x8000064a, 0x00000634, + 0x8000062c, 0x00000634, 0x8000062d, 0x00000634, + 0x8000062e, 0x00000634, 0x80000645, 0x00000634, + 0x80000631, 0x00000633, 0x80000631, 0x00000635, + 0x80000631, 0x00000636, 0x80000631, 0x00000634, + 0x8000062c, 0x00000634, 0x8000062d, 0x00000634, + 0x8000062e, 0x00000634, 0x80000645, 0x00000633, + 0x80000647, 0x00000634, 0x80000647, 0x00000637, + 0x80000645, 0x00000633, 0x8000062c, 0x00000633, + 0x8000062d, 0x00000633, 0x8000062e, 0x00000634, + 0x8000062c, 0x00000634, 0x8000062d, 0x00000634, + 0x8000062e, 0x00000637, 0x80000645, 0x00000638, + 0x80000645, 0x00000627, 0x8000064b, 0x00000627, + 0x8000064b, 0x0000062a, 0x0000062c, 0x80000645, + 0x0000062a, 0x0000062d, 0x8000062c, 0x0000062a, + 0x0000062d, 0x8000062c, 0x0000062a, 0x0000062d, + 0x80000645, 0x0000062a, 0x0000062e, 0x80000645, + 0x0000062a, 0x00000645, 0x8000062c, 0x0000062a, + 0x00000645, 0x8000062d, 0x0000062a, 0x00000645, + 0x8000062e, 0x0000062c, 0x00000645, 0x8000062d, + 0x0000062c, 0x00000645, 0x8000062d, 0x0000062d, + 0x00000645, 0x8000064a, 0x0000062d, 0x00000645, + 0x80000649, 0x00000633, 0x0000062d, 0x8000062c, + 0x00000633, 0x0000062c, 0x8000062d, 0x00000633, + 0x0000062c, 0x80000649, 0x00000633, 0x00000645, + 0x8000062d, 0x00000633, 0x00000645, 0x8000062d, + 0x00000633, 0x00000645, 0x8000062c, 0x00000633, + 0x00000645, 0x80000645, 0x00000633, 0x00000645, + 0x80000645, 0x00000635, 0x0000062d, 0x8000062d, + 0x00000635, 0x0000062d, 0x8000062d, 0x00000635, + 0x00000645, 0x80000645, 0x00000634, 0x0000062d, + 0x80000645, 0x00000634, 0x0000062d, 0x80000645, + 0x00000634, 0x0000062c, 0x8000064a, 0x00000634, + 0x00000645, 0x8000062e, 0x00000634, 0x00000645, + 0x8000062e, 0x00000634, 0x00000645, 0x80000645, + 0x00000634, 0x00000645, 0x80000645, 0x00000636, + 0x0000062d, 0x80000649, 0x00000636, 0x0000062e, + 0x80000645, 0x00000636, 0x0000062e, 0x80000645, + 0x00000637, 0x00000645, 0x8000062d, 0x00000637, + 0x00000645, 0x8000062d, 0x00000637, 0x00000645, + 0x80000645, 0x00000637, 0x00000645, 0x8000064a, + 0x00000639, 0x0000062c, 0x80000645, 0x00000639, + 0x00000645, 0x80000645, 0x00000639, 0x00000645, + 0x80000645, 0x00000639, 0x00000645, 0x80000649, + 0x0000063a, 0x00000645, 0x80000645, 0x0000063a, + 0x00000645, 0x8000064a, 0x0000063a, 0x00000645, + 0x80000649, 0x00000641, 0x0000062e, 0x80000645, + 0x00000641, 0x0000062e, 0x80000645, 0x00000642, + 0x00000645, 0x8000062d, 0x00000642, 0x00000645, + 0x80000645, 0x00000644, 0x0000062d, 0x80000645, + 0x00000644, 0x0000062d, 0x8000064a, 0x00000644, + 0x0000062d, 0x80000649, 0x00000644, 0x0000062c, + 0x8000062c, 0x00000644, 0x0000062c, 0x8000062c, + 0x00000644, 0x0000062e, 0x80000645, 0x00000644, + 0x0000062e, 0x80000645, 0x00000644, 0x00000645, + 0x8000062d, 0x00000644, 0x00000645, 0x8000062d, + 0x00000645, 0x0000062d, 0x8000062c, 0x00000645, + 0x0000062d, 0x80000645, 0x00000645, 0x0000062d, + 0x8000064a, 0x00000645, 0x0000062c, 0x8000062d, + 0x00000645, 0x0000062c, 0x80000645, 0x00000645, + 0x0000062e, 0x8000062c, 0x00000645, 0x0000062e, + 0x80000645, 0x00000645, 0x0000062c, 0x8000062e, + 0x00000647, 0x00000645, 0x8000062c, 0x00000647, + 0x00000645, 0x80000645, 0x00000646, 0x0000062d, + 0x80000645, 0x00000646, 0x0000062d, 0x80000649, + 0x00000646, 0x0000062c, 0x80000645, 0x00000646, + 0x0000062c, 0x80000645, 0x00000646, 0x0000062c, + 0x80000649, 0x00000646, 0x00000645, 0x8000064a, + 0x00000646, 0x00000645, 0x80000649, 0x0000064a, + 0x00000645, 0x80000645, 0x0000064a, 0x00000645, + 0x80000645, 0x00000628, 0x0000062e, 0x8000064a, + 0x0000062a, 0x0000062c, 0x8000064a, 0x0000062a, + 0x0000062c, 0x80000649, 0x0000062a, 0x0000062e, + 0x8000064a, 0x0000062a, 0x0000062e, 0x80000649, + 0x0000062a, 0x00000645, 0x8000064a, 0x0000062a, + 0x00000645, 0x80000649, 0x0000062c, 0x00000645, + 0x8000064a, 0x0000062c, 0x0000062d, 0x80000649, + 0x0000062c, 0x00000645, 0x80000649, 0x00000633, + 0x0000062e, 0x80000649, 0x00000635, 0x0000062d, + 0x8000064a, 0x00000634, 0x0000062d, 0x8000064a, + 0x00000636, 0x0000062d, 0x8000064a, 0x00000644, + 0x0000062c, 0x8000064a, 0x00000644, 0x00000645, + 0x8000064a, 0x0000064a, 0x0000062d, 0x8000064a, + 0x0000064a, 0x0000062c, 0x8000064a, 0x0000064a, + 0x00000645, 0x8000064a, 0x00000645, 0x00000645, + 0x8000064a, 0x00000642, 0x00000645, 0x8000064a, + 0x00000646, 0x0000062d, 0x8000064a, 0x00000642, + 0x00000645, 0x8000062d, 0x00000644, 0x0000062d, + 0x80000645, 0x00000639, 0x00000645, 0x8000064a, + 0x00000643, 0x00000645, 0x8000064a, 0x00000646, + 0x0000062c, 0x8000062d, 0x00000645, 0x0000062e, + 0x8000064a, 0x00000644, 0x0000062c, 0x80000645, + 0x00000643, 0x00000645, 0x80000645, 0x00000644, + 0x0000062c, 0x80000645, 0x00000646, 0x0000062c, + 0x8000062d, 0x0000062c, 0x0000062d, 0x8000064a, + 0x0000062d, 0x0000062c, 0x8000064a, 0x00000645, + 0x0000062c, 0x8000064a, 0x00000641, 0x00000645, + 0x8000064a, 0x00000628, 0x0000062d, 0x8000064a, + 0x00000643, 0x00000645, 0x80000645, 0x00000639, + 0x0000062c, 0x80000645, 0x00000635, 0x00000645, + 0x80000645, 0x00000633, 0x0000062e, 0x8000064a, + 0x00000646, 0x0000062c, 0x8000064a, 0x00000635, + 0x00000644, 0x800006d2, 0x00000642, 0x00000644, + 0x800006d2, 0x00000627, 0x00000644, 0x00000644, + 0x80000647, 0x00000627, 0x00000643, 0x00000628, + 0x80000631, 0x00000645, 0x0000062d, 0x00000645, + 0x8000062f, 0x00000635, 0x00000644, 0x00000639, + 0x80000645, 0x00000631, 0x00000633, 0x00000648, + 0x80000644, 0x00000639, 0x00000644, 0x0000064a, + 0x80000647, 0x00000648, 0x00000633, 0x00000644, + 0x80000645, 0x00000635, 0x00000644, 0x80000649, + 0x00000635, 0x00000644, 0x00000649, 0x00000020, + 0x00000627, 0x00000644, 0x00000644, 0x00000647, + 0x00000020, 0x00000639, 0x00000644, 0x0000064a, + 0x00000647, 0x00000020, 0x00000648, 0x00000633, + 0x00000644, 0x80000645, 0x0000062c, 0x00000644, + 0x00000020, 0x0000062c, 0x00000644, 0x00000627, + 0x00000644, 0x80000647, 0x00000631, 0x000006cc, + 0x00000627, 0x80000644, 0x80002025, 0x80002014, + 0x80002013, 0x8000005f, 0x8000005f, 0x80000028, + 0x80000029, 0x8000007b, 0x8000007d, 0x80003014, + 0x80003015, 0x80003010, 0x80003011, 0x8000300a, + 0x8000300b, 0x80003008, 0x80003009, 0x8000300c, + 0x8000300d, 0x8000300e, 0x8000300f, 0x8000203e, + 0x8000203e, 0x8000203e, 0x8000203e, 0x8000005f, + 0x8000005f, 0x8000005f, 0x8000002c, 0x80003001, + 0x8000002e, 0x8000003b, 0x8000003a, 0x8000003f, + 0x80000021, 0x80002014, 0x80000028, 0x80000029, + 0x8000007b, 0x8000007d, 0x80003014, 0x80003015, + 0x80000023, 0x80000026, 0x8000002a, 0x8000002b, + 0x8000002d, 0x8000003c, 0x8000003e, 0x8000003d, + 0x8000005c, 0x80000024, 0x80000025, 0x80000040, + 0x00000020, 0x8000064b, 0x00000640, 0x8000064b, + 0x00000020, 0x8000064c, 0x00000020, 0x8000064d, + 0x00000020, 0x8000064e, 0x00000640, 0x8000064e, + 0x00000020, 0x8000064f, 0x00000640, 0x8000064f, + 0x00000020, 0x80000650, 0x00000640, 0x80000650, + 0x00000020, 0x80000651, 0x00000640, 0x80000651, + 0x00000020, 0x80000652, 0x00000640, 0x80000652, + 0x80000621, 0x80000622, 0x80000622, 0x80000623, + 0x80000623, 0x80000624, 0x80000624, 0x80000625, + 0x80000625, 0x80000626, 0x80000626, 0x80000626, + 0x80000626, 0x80000627, 0x80000627, 0x80000628, + 0x80000628, 0x80000628, 0x80000628, 0x80000629, + 0x80000629, 0x8000062a, 0x8000062a, 0x8000062a, + 0x8000062a, 0x8000062b, 0x8000062b, 0x8000062b, + 0x8000062b, 0x8000062c, 0x8000062c, 0x8000062c, + 0x8000062c, 0x8000062d, 0x8000062d, 0x8000062d, + 0x8000062d, 0x8000062e, 0x8000062e, 0x8000062e, + 0x8000062e, 0x8000062f, 0x8000062f, 0x80000630, + 0x80000630, 0x80000631, 0x80000631, 0x80000632, + 0x80000632, 0x80000633, 0x80000633, 0x80000633, + 0x80000633, 0x80000634, 0x80000634, 0x80000634, + 0x80000634, 0x80000635, 0x80000635, 0x80000635, + 0x80000635, 0x80000636, 0x80000636, 0x80000636, + 0x80000636, 0x80000637, 0x80000637, 0x80000637, + 0x80000637, 0x80000638, 0x80000638, 0x80000638, + 0x80000638, 0x80000639, 0x80000639, 0x80000639, + 0x80000639, 0x8000063a, 0x8000063a, 0x8000063a, + 0x8000063a, 0x80000641, 0x80000641, 0x80000641, + 0x80000641, 0x80000642, 0x80000642, 0x80000642, + 0x80000642, 0x80000643, 0x80000643, 0x80000643, + 0x80000643, 0x80000644, 0x80000644, 0x80000644, + 0x80000644, 0x80000645, 0x80000645, 0x80000645, + 0x80000645, 0x80000646, 0x80000646, 0x80000646, + 0x80000646, 0x80000647, 0x80000647, 0x80000647, + 0x80000647, 0x80000648, 0x80000648, 0x80000649, + 0x80000649, 0x8000064a, 0x8000064a, 0x8000064a, + 0x8000064a, 0x00000644, 0x80000622, 0x00000644, + 0x80000622, 0x00000644, 0x80000623, 0x00000644, + 0x80000623, 0x00000644, 0x80000625, 0x00000644, + 0x80000625, 0x00000644, 0x80000627, 0x00000644, + 0x80000627, 0x80000021, 0x80000022, 0x80000023, + 0x80000024, 0x80000025, 0x80000026, 0x80000027, + 0x80000028, 0x80000029, 0x8000002a, 0x8000002b, + 0x8000002c, 0x8000002d, 0x8000002e, 0x8000002f, + 0x80000030, 0x80000031, 0x80000032, 0x80000033, + 0x80000034, 0x80000035, 0x80000036, 0x80000037, + 0x80000038, 0x80000039, 0x8000003a, 0x8000003b, + 0x8000003c, 0x8000003d, 0x8000003e, 0x8000003f, + 0x80000040, 0x80000041, 0x80000042, 0x80000043, + 0x80000044, 0x80000045, 0x80000046, 0x80000047, + 0x80000048, 0x80000049, 0x8000004a, 0x8000004b, + 0x8000004c, 0x8000004d, 0x8000004e, 0x8000004f, + 0x80000050, 0x80000051, 0x80000052, 0x80000053, + 0x80000054, 0x80000055, 0x80000056, 0x80000057, + 0x80000058, 0x80000059, 0x8000005a, 0x8000005b, + 0x8000005c, 0x8000005d, 0x8000005e, 0x8000005f, + 0x80000060, 0x80000061, 0x80000062, 0x80000063, + 0x80000064, 0x80000065, 0x80000066, 0x80000067, + 0x80000068, 0x80000069, 0x8000006a, 0x8000006b, + 0x8000006c, 0x8000006d, 0x8000006e, 0x8000006f, + 0x80000070, 0x80000071, 0x80000072, 0x80000073, + 0x80000074, 0x80000075, 0x80000076, 0x80000077, + 0x80000078, 0x80000079, 0x8000007a, 0x8000007b, + 0x8000007c, 0x8000007d, 0x8000007e, 0x80002985, + 0x80002986, 0x80003002, 0x8000300c, 0x8000300d, + 0x80003001, 0x800030fb, 0x800030f2, 0x800030a1, + 0x800030a3, 0x800030a5, 0x800030a7, 0x800030a9, + 0x800030e3, 0x800030e5, 0x800030e7, 0x800030c3, + 0x800030fc, 0x800030a2, 0x800030a4, 0x800030a6, + 0x800030a8, 0x800030aa, 0x800030ab, 0x800030ad, + 0x800030af, 0x800030b1, 0x800030b3, 0x800030b5, + 0x800030b7, 0x800030b9, 0x800030bb, 0x800030bd, + 0x800030bf, 0x800030c1, 0x800030c4, 0x800030c6, + 0x800030c8, 0x800030ca, 0x800030cb, 0x800030cc, + 0x800030cd, 0x800030ce, 0x800030cf, 0x800030d2, + 0x800030d5, 0x800030d8, 0x800030db, 0x800030de, + 0x800030df, 0x800030e0, 0x800030e1, 0x800030e2, + 0x800030e4, 0x800030e6, 0x800030e8, 0x800030e9, + 0x800030ea, 0x800030eb, 0x800030ec, 0x800030ed, + 0x800030ef, 0x800030f3, 0x80003099, 0x8000309a, + 0x80003164, 0x80003131, 0x80003132, 0x80003133, + 0x80003134, 0x80003135, 0x80003136, 0x80003137, + 0x80003138, 0x80003139, 0x8000313a, 0x8000313b, + 0x8000313c, 0x8000313d, 0x8000313e, 0x8000313f, + 0x80003140, 0x80003141, 0x80003142, 0x80003143, + 0x80003144, 0x80003145, 0x80003146, 0x80003147, + 0x80003148, 0x80003149, 0x8000314a, 0x8000314b, + 0x8000314c, 0x8000314d, 0x8000314e, 0x8000314f, + 0x80003150, 0x80003151, 0x80003152, 0x80003153, + 0x80003154, 0x80003155, 0x80003156, 0x80003157, + 0x80003158, 0x80003159, 0x8000315a, 0x8000315b, + 0x8000315c, 0x8000315d, 0x8000315e, 0x8000315f, + 0x80003160, 0x80003161, 0x80003162, 0x80003163, + 0x800000a2, 0x800000a3, 0x800000ac, 0x800000af, + 0x800000a6, 0x800000a5, 0x800020a9, 0x80002502, + 0x80002190, 0x80002191, 0x80002192, 0x80002193, + 0x800025a0, 0x800025cb, 0x0001d157, 0x8001d165, + 0x0001d158, 0x8001d165, 0x0001d15f, 0x8001d16e, + 0x0001d15f, 0x8001d16f, 0x0001d15f, 0x8001d170, + 0x0001d15f, 0x8001d171, 0x0001d15f, 0x8001d172, + 0x0001d1b9, 0x8001d165, 0x0001d1ba, 0x8001d165, + 0x0001d1bb, 0x8001d16e, 0x0001d1bc, 0x8001d16e, + 0x0001d1bb, 0x8001d16f, 0x0001d1bc, 0x8001d16f, + 0x80000041, 0x80000042, 0x80000043, 0x80000044, + 0x80000045, 0x80000046, 0x80000047, 0x80000048, + 0x80000049, 0x8000004a, 0x8000004b, 0x8000004c, + 0x8000004d, 0x8000004e, 0x8000004f, 0x80000050, + 0x80000051, 0x80000052, 0x80000053, 0x80000054, + 0x80000055, 0x80000056, 0x80000057, 0x80000058, + 0x80000059, 0x8000005a, 0x80000061, 0x80000062, + 0x80000063, 0x80000064, 0x80000065, 0x80000066, + 0x80000067, 0x80000068, 0x80000069, 0x8000006a, + 0x8000006b, 0x8000006c, 0x8000006d, 0x8000006e, + 0x8000006f, 0x80000070, 0x80000071, 0x80000072, + 0x80000073, 0x80000074, 0x80000075, 0x80000076, + 0x80000077, 0x80000078, 0x80000079, 0x8000007a, + 0x80000041, 0x80000042, 0x80000043, 0x80000044, + 0x80000045, 0x80000046, 0x80000047, 0x80000048, + 0x80000049, 0x8000004a, 0x8000004b, 0x8000004c, + 0x8000004d, 0x8000004e, 0x8000004f, 0x80000050, + 0x80000051, 0x80000052, 0x80000053, 0x80000054, + 0x80000055, 0x80000056, 0x80000057, 0x80000058, + 0x80000059, 0x8000005a, 0x80000061, 0x80000062, + 0x80000063, 0x80000064, 0x80000065, 0x80000066, + 0x80000067, 0x80000069, 0x8000006a, 0x8000006b, + 0x8000006c, 0x8000006d, 0x8000006e, 0x8000006f, + 0x80000070, 0x80000071, 0x80000072, 0x80000073, + 0x80000074, 0x80000075, 0x80000076, 0x80000077, + 0x80000078, 0x80000079, 0x8000007a, 0x80000041, + 0x80000042, 0x80000043, 0x80000044, 0x80000045, + 0x80000046, 0x80000047, 0x80000048, 0x80000049, + 0x8000004a, 0x8000004b, 0x8000004c, 0x8000004d, + 0x8000004e, 0x8000004f, 0x80000050, 0x80000051, + 0x80000052, 0x80000053, 0x80000054, 0x80000055, + 0x80000056, 0x80000057, 0x80000058, 0x80000059, + 0x8000005a, 0x80000061, 0x80000062, 0x80000063, + 0x80000064, 0x80000065, 0x80000066, 0x80000067, + 0x80000068, 0x80000069, 0x8000006a, 0x8000006b, + 0x8000006c, 0x8000006d, 0x8000006e, 0x8000006f, + 0x80000070, 0x80000071, 0x80000072, 0x80000073, + 0x80000074, 0x80000075, 0x80000076, 0x80000077, + 0x80000078, 0x80000079, 0x8000007a, 0x80000041, + 0x80000043, 0x80000044, 0x80000047, 0x8000004a, + 0x8000004b, 0x8000004e, 0x8000004f, 0x80000050, + 0x80000051, 0x80000053, 0x80000054, 0x80000055, + 0x80000056, 0x80000057, 0x80000058, 0x80000059, + 0x8000005a, 0x80000061, 0x80000062, 0x80000063, + 0x80000064, 0x80000066, 0x80000068, 0x80000069, + 0x8000006a, 0x8000006b, 0x8000006d, 0x8000006e, + 0x80000070, 0x80000071, 0x80000072, 0x80000073, + 0x80000074, 0x80000075, 0x80000076, 0x80000077, + 0x80000078, 0x80000079, 0x8000007a, 0x80000041, + 0x80000042, 0x80000043, 0x80000044, 0x80000045, + 0x80000046, 0x80000047, 0x80000048, 0x80000049, + 0x8000004a, 0x8000004b, 0x8000004c, 0x8000004d, + 0x8000004e, 0x8000004f, 0x80000050, 0x80000051, + 0x80000052, 0x80000053, 0x80000054, 0x80000055, + 0x80000056, 0x80000057, 0x80000058, 0x80000059, + 0x8000005a, 0x80000061, 0x80000062, 0x80000063, + 0x80000064, 0x80000065, 0x80000066, 0x80000067, + 0x80000068, 0x80000069, 0x8000006a, 0x8000006b, + 0x8000006c, 0x8000006d, 0x8000006e, 0x8000006f, + 0x80000070, 0x80000071, 0x80000072, 0x80000073, + 0x80000074, 0x80000075, 0x80000076, 0x80000077, + 0x80000078, 0x80000079, 0x8000007a, 0x80000041, + 0x80000042, 0x80000044, 0x80000045, 0x80000046, + 0x80000047, 0x8000004a, 0x8000004b, 0x8000004c, + 0x8000004d, 0x8000004e, 0x8000004f, 0x80000050, + 0x80000051, 0x80000053, 0x80000054, 0x80000055, + 0x80000056, 0x80000057, 0x80000058, 0x80000059, + 0x80000061, 0x80000062, 0x80000063, 0x80000064, + 0x80000065, 0x80000066, 0x80000067, 0x80000068, + 0x80000069, 0x8000006a, 0x8000006b, 0x8000006c, + 0x8000006d, 0x8000006e, 0x8000006f, 0x80000070, + 0x80000071, 0x80000072, 0x80000073, 0x80000074, + 0x80000075, 0x80000076, 0x80000077, 0x80000078, + 0x80000079, 0x8000007a, 0x80000041, 0x80000042, + 0x80000044, 0x80000045, 0x80000046, 0x80000047, + 0x80000049, 0x8000004a, 0x8000004b, 0x8000004c, + 0x8000004d, 0x8000004f, 0x80000053, 0x80000054, + 0x80000055, 0x80000056, 0x80000057, 0x80000058, + 0x80000059, 0x80000061, 0x80000062, 0x80000063, + 0x80000064, 0x80000065, 0x80000066, 0x80000067, + 0x80000068, 0x80000069, 0x8000006a, 0x8000006b, + 0x8000006c, 0x8000006d, 0x8000006e, 0x8000006f, + 0x80000070, 0x80000071, 0x80000072, 0x80000073, + 0x80000074, 0x80000075, 0x80000076, 0x80000077, + 0x80000078, 0x80000079, 0x8000007a, 0x80000041, + 0x80000042, 0x80000043, 0x80000044, 0x80000045, + 0x80000046, 0x80000047, 0x80000048, 0x80000049, + 0x8000004a, 0x8000004b, 0x8000004c, 0x8000004d, + 0x8000004e, 0x8000004f, 0x80000050, 0x80000051, + 0x80000052, 0x80000053, 0x80000054, 0x80000055, + 0x80000056, 0x80000057, 0x80000058, 0x80000059, + 0x8000005a, 0x80000061, 0x80000062, 0x80000063, + 0x80000064, 0x80000065, 0x80000066, 0x80000067, + 0x80000068, 0x80000069, 0x8000006a, 0x8000006b, + 0x8000006c, 0x8000006d, 0x8000006e, 0x8000006f, + 0x80000070, 0x80000071, 0x80000072, 0x80000073, + 0x80000074, 0x80000075, 0x80000076, 0x80000077, + 0x80000078, 0x80000079, 0x8000007a, 0x80000041, + 0x80000042, 0x80000043, 0x80000044, 0x80000045, + 0x80000046, 0x80000047, 0x80000048, 0x80000049, + 0x8000004a, 0x8000004b, 0x8000004c, 0x8000004d, + 0x8000004e, 0x8000004f, 0x80000050, 0x80000051, + 0x80000052, 0x80000053, 0x80000054, 0x80000055, + 0x80000056, 0x80000057, 0x80000058, 0x80000059, + 0x8000005a, 0x80000061, 0x80000062, 0x80000063, + 0x80000064, 0x80000065, 0x80000066, 0x80000067, + 0x80000068, 0x80000069, 0x8000006a, 0x8000006b, + 0x8000006c, 0x8000006d, 0x8000006e, 0x8000006f, + 0x80000070, 0x80000071, 0x80000072, 0x80000073, + 0x80000074, 0x80000075, 0x80000076, 0x80000077, + 0x80000078, 0x80000079, 0x8000007a, 0x80000041, + 0x80000042, 0x80000043, 0x80000044, 0x80000045, + 0x80000046, 0x80000047, 0x80000048, 0x80000049, + 0x8000004a, 0x8000004b, 0x8000004c, 0x8000004d, + 0x8000004e, 0x8000004f, 0x80000050, 0x80000051, + 0x80000052, 0x80000053, 0x80000054, 0x80000055, + 0x80000056, 0x80000057, 0x80000058, 0x80000059, + 0x8000005a, 0x80000061, 0x80000062, 0x80000063, + 0x80000064, 0x80000065, 0x80000066, 0x80000067, + 0x80000068, 0x80000069, 0x8000006a, 0x8000006b, + 0x8000006c, 0x8000006d, 0x8000006e, 0x8000006f, + 0x80000070, 0x80000071, 0x80000072, 0x80000073, + 0x80000074, 0x80000075, 0x80000076, 0x80000077, + 0x80000078, 0x80000079, 0x8000007a, 0x80000041, + 0x80000042, 0x80000043, 0x80000044, 0x80000045, + 0x80000046, 0x80000047, 0x80000048, 0x80000049, + 0x8000004a, 0x8000004b, 0x8000004c, 0x8000004d, + 0x8000004e, 0x8000004f, 0x80000050, 0x80000051, + 0x80000052, 0x80000053, 0x80000054, 0x80000055, + 0x80000056, 0x80000057, 0x80000058, 0x80000059, + 0x8000005a, 0x80000061, 0x80000062, 0x80000063, + 0x80000064, 0x80000065, 0x80000066, 0x80000067, + 0x80000068, 0x80000069, 0x8000006a, 0x8000006b, + 0x8000006c, 0x8000006d, 0x8000006e, 0x8000006f, + 0x80000070, 0x80000071, 0x80000072, 0x80000073, + 0x80000074, 0x80000075, 0x80000076, 0x80000077, + 0x80000078, 0x80000079, 0x8000007a, 0x80000041, + 0x80000042, 0x80000043, 0x80000044, 0x80000045, + 0x80000046, 0x80000047, 0x80000048, 0x80000049, + 0x8000004a, 0x8000004b, 0x8000004c, 0x8000004d, + 0x8000004e, 0x8000004f, 0x80000050, 0x80000051, + 0x80000052, 0x80000053, 0x80000054, 0x80000055, + 0x80000056, 0x80000057, 0x80000058, 0x80000059, + 0x8000005a, 0x80000061, 0x80000062, 0x80000063, + 0x80000064, 0x80000065, 0x80000066, 0x80000067, + 0x80000068, 0x80000069, 0x8000006a, 0x8000006b, + 0x8000006c, 0x8000006d, 0x8000006e, 0x8000006f, + 0x80000070, 0x80000071, 0x80000072, 0x80000073, + 0x80000074, 0x80000075, 0x80000076, 0x80000077, + 0x80000078, 0x80000079, 0x8000007a, 0x80000041, + 0x80000042, 0x80000043, 0x80000044, 0x80000045, + 0x80000046, 0x80000047, 0x80000048, 0x80000049, + 0x8000004a, 0x8000004b, 0x8000004c, 0x8000004d, + 0x8000004e, 0x8000004f, 0x80000050, 0x80000051, + 0x80000052, 0x80000053, 0x80000054, 0x80000055, + 0x80000056, 0x80000057, 0x80000058, 0x80000059, + 0x8000005a, 0x80000061, 0x80000062, 0x80000063, + 0x80000064, 0x80000065, 0x80000066, 0x80000067, + 0x80000068, 0x80000069, 0x8000006a, 0x8000006b, + 0x8000006c, 0x8000006d, 0x8000006e, 0x8000006f, + 0x80000070, 0x80000071, 0x80000072, 0x80000073, + 0x80000074, 0x80000075, 0x80000076, 0x80000077, + 0x80000078, 0x80000079, 0x8000007a, 0x80000391, + 0x80000392, 0x80000393, 0x80000394, 0x80000395, + 0x80000396, 0x80000397, 0x80000398, 0x80000399, + 0x8000039a, 0x8000039b, 0x8000039c, 0x8000039d, + 0x8000039e, 0x8000039f, 0x800003a0, 0x800003a1, + 0x800003f4, 0x800003a3, 0x800003a4, 0x800003a5, + 0x800003a6, 0x800003a7, 0x800003a8, 0x800003a9, + 0x80002207, 0x800003b1, 0x800003b2, 0x800003b3, + 0x800003b4, 0x800003b5, 0x800003b6, 0x800003b7, + 0x800003b8, 0x800003b9, 0x800003ba, 0x800003bb, + 0x800003bc, 0x800003bd, 0x800003be, 0x800003bf, + 0x800003c0, 0x800003c1, 0x800003c2, 0x800003c3, + 0x800003c4, 0x800003c5, 0x800003c6, 0x800003c7, + 0x800003c8, 0x800003c9, 0x80002202, 0x800003f5, + 0x800003d1, 0x800003f0, 0x800003d5, 0x800003f1, + 0x800003d6, 0x80000391, 0x80000392, 0x80000393, + 0x80000394, 0x80000395, 0x80000396, 0x80000397, + 0x80000398, 0x80000399, 0x8000039a, 0x8000039b, + 0x8000039c, 0x8000039d, 0x8000039e, 0x8000039f, + 0x800003a0, 0x800003a1, 0x800003f4, 0x800003a3, + 0x800003a4, 0x800003a5, 0x800003a6, 0x800003a7, + 0x800003a8, 0x800003a9, 0x80002207, 0x800003b1, + 0x800003b2, 0x800003b3, 0x800003b4, 0x800003b5, + 0x800003b6, 0x800003b7, 0x800003b8, 0x800003b9, + 0x800003ba, 0x800003bb, 0x800003bc, 0x800003bd, + 0x800003be, 0x800003bf, 0x800003c0, 0x800003c1, + 0x800003c2, 0x800003c3, 0x800003c4, 0x800003c5, + 0x800003c6, 0x800003c7, 0x800003c8, 0x800003c9, + 0x80002202, 0x800003f5, 0x800003d1, 0x800003f0, + 0x800003d5, 0x800003f1, 0x800003d6, 0x80000391, + 0x80000392, 0x80000393, 0x80000394, 0x80000395, + 0x80000396, 0x80000397, 0x80000398, 0x80000399, + 0x8000039a, 0x8000039b, 0x8000039c, 0x8000039d, + 0x8000039e, 0x8000039f, 0x800003a0, 0x800003a1, + 0x800003f4, 0x800003a3, 0x800003a4, 0x800003a5, + 0x800003a6, 0x800003a7, 0x800003a8, 0x800003a9, + 0x80002207, 0x800003b1, 0x800003b2, 0x800003b3, + 0x800003b4, 0x800003b5, 0x800003b6, 0x800003b7, + 0x800003b8, 0x800003b9, 0x800003ba, 0x800003bb, + 0x800003bc, 0x800003bd, 0x800003be, 0x800003bf, + 0x800003c0, 0x800003c1, 0x800003c2, 0x800003c3, + 0x800003c4, 0x800003c5, 0x800003c6, 0x800003c7, + 0x800003c8, 0x800003c9, 0x80002202, 0x800003f5, + 0x800003d1, 0x800003f0, 0x800003d5, 0x800003f1, + 0x800003d6, 0x80000391, 0x80000392, 0x80000393, + 0x80000394, 0x80000395, 0x80000396, 0x80000397, + 0x80000398, 0x80000399, 0x8000039a, 0x8000039b, + 0x8000039c, 0x8000039d, 0x8000039e, 0x8000039f, + 0x800003a0, 0x800003a1, 0x800003f4, 0x800003a3, + 0x800003a4, 0x800003a5, 0x800003a6, 0x800003a7, + 0x800003a8, 0x800003a9, 0x80002207, 0x800003b1, + 0x800003b2, 0x800003b3, 0x800003b4, 0x800003b5, + 0x800003b6, 0x800003b7, 0x800003b8, 0x800003b9, + 0x800003ba, 0x800003bb, 0x800003bc, 0x800003bd, + 0x800003be, 0x800003bf, 0x800003c0, 0x800003c1, + 0x800003c2, 0x800003c3, 0x800003c4, 0x800003c5, + 0x800003c6, 0x800003c7, 0x800003c8, 0x800003c9, + 0x80002202, 0x800003f5, 0x800003d1, 0x800003f0, + 0x800003d5, 0x800003f1, 0x800003d6, 0x80000391, + 0x80000392, 0x80000393, 0x80000394, 0x80000395, + 0x80000396, 0x80000397, 0x80000398, 0x80000399, + 0x8000039a, 0x8000039b, 0x8000039c, 0x8000039d, + 0x8000039e, 0x8000039f, 0x800003a0, 0x800003a1, + 0x800003f4, 0x800003a3, 0x800003a4, 0x800003a5, + 0x800003a6, 0x800003a7, 0x800003a8, 0x800003a9, + 0x80002207, 0x800003b1, 0x800003b2, 0x800003b3, + 0x800003b4, 0x800003b5, 0x800003b6, 0x800003b7, + 0x800003b8, 0x800003b9, 0x800003ba, 0x800003bb, + 0x800003bc, 0x800003bd, 0x800003be, 0x800003bf, + 0x800003c0, 0x800003c1, 0x800003c2, 0x800003c3, + 0x800003c4, 0x800003c5, 0x800003c6, 0x800003c7, + 0x800003c8, 0x800003c9, 0x80002202, 0x800003f5, + 0x800003d1, 0x800003f0, 0x800003d5, 0x800003f1, + 0x800003d6, 0x80000030, 0x80000031, 0x80000032, + 0x80000033, 0x80000034, 0x80000035, 0x80000036, + 0x80000037, 0x80000038, 0x80000039, 0x80000030, + 0x80000031, 0x80000032, 0x80000033, 0x80000034, + 0x80000035, 0x80000036, 0x80000037, 0x80000038, + 0x80000039, 0x80000030, 0x80000031, 0x80000032, + 0x80000033, 0x80000034, 0x80000035, 0x80000036, + 0x80000037, 0x80000038, 0x80000039, 0x80000030, + 0x80000031, 0x80000032, 0x80000033, 0x80000034, + 0x80000035, 0x80000036, 0x80000037, 0x80000038, + 0x80000039, 0x80000030, 0x80000031, 0x80000032, + 0x80000033, 0x80000034, 0x80000035, 0x80000036, + 0x80000037, 0x80000038, 0x80000039, 0x80004e3d, + 0x80004e38, 0x80004e41, 0x80020122, 0x80004f60, + 0x80004fae, 0x80004fbb, 0x80005002, 0x8000507a, + 0x80005099, 0x800050e7, 0x800050cf, 0x8000349e, + 0x8002063a, 0x8000514d, 0x80005154, 0x80005164, + 0x80005177, 0x8002051c, 0x800034b9, 0x80005167, + 0x8000518d, 0x8002054b, 0x80005197, 0x800051a4, + 0x80004ecc, 0x800051ac, 0x800051b5, 0x800291df, + 0x800051f5, 0x80005203, 0x800034df, 0x8000523b, + 0x80005246, 0x80005272, 0x80005277, 0x80003515, + 0x800052c7, 0x800052c9, 0x800052e4, 0x800052fa, + 0x80005305, 0x80005306, 0x80005317, 0x80005349, + 0x80005351, 0x8000535a, 0x80005373, 0x8000537d, + 0x8000537f, 0x8000537f, 0x8000537f, 0x80020a2c, + 0x80007070, 0x800053ca, 0x800053df, 0x80020b63, + 0x800053eb, 0x800053f1, 0x80005406, 0x8000549e, + 0x80005438, 0x80005448, 0x80005468, 0x800054a2, + 0x800054f6, 0x80005510, 0x80005553, 0x80005563, + 0x80005584, 0x80005584, 0x80005599, 0x800055ab, + 0x800055b3, 0x800055c2, 0x80005716, 0x80005606, + 0x80005717, 0x80005651, 0x80005674, 0x80005207, + 0x800058ee, 0x800057ce, 0x800057f4, 0x8000580d, + 0x8000578b, 0x80005832, 0x80005831, 0x800058ac, + 0x800214e4, 0x800058f2, 0x800058f7, 0x80005906, + 0x8000591a, 0x80005922, 0x80005962, 0x800216a8, + 0x800216ea, 0x800059ec, 0x80005a1b, 0x80005a27, + 0x800059d8, 0x80005a66, 0x800036ee, 0x8002136a, + 0x80005b08, 0x80005b3e, 0x80005b3e, 0x800219c8, + 0x80005bc3, 0x80005bd8, 0x80005be7, 0x80005bf3, + 0x80021b18, 0x80005bff, 0x80005c06, 0x80005f33, + 0x80005c22, 0x80003781, 0x80005c60, 0x80005c6e, + 0x80005cc0, 0x80005c8d, 0x80021de4, 0x80005d43, + 0x80021de6, 0x80005d6e, 0x80005d6b, 0x80005d7c, + 0x80005de1, 0x80005de2, 0x8000382f, 0x80005dfd, + 0x80005e28, 0x80005e3d, 0x80005e69, 0x80003862, + 0x80022183, 0x8000387c, 0x80005eb0, 0x80005eb3, + 0x80005eb6, 0x80005eca, 0x8002a392, 0x80005efe, + 0x80022331, 0x80022331, 0x80008201, 0x80005f22, + 0x80005f22, 0x800038c7, 0x800232b8, 0x800261da, + 0x80005f62, 0x80005f6b, 0x800038e3, 0x80005f9a, + 0x80005fcd, 0x80005fd7, 0x80005ff9, 0x80006081, + 0x8000393a, 0x8000391c, 0x80006094, 0x800226d4, + 0x800060c7, 0x80006148, 0x8000614c, 0x8000614e, + 0x8000614c, 0x8000617a, 0x8000618e, 0x800061b2, + 0x800061a4, 0x800061af, 0x800061de, 0x800061f2, + 0x800061f6, 0x80006210, 0x8000621b, 0x8000625d, + 0x800062b1, 0x800062d4, 0x80006350, 0x80022b0c, + 0x8000633d, 0x800062fc, 0x80006368, 0x80006383, + 0x800063e4, 0x80022bf1, 0x80006422, 0x800063c5, + 0x800063a9, 0x80003a2e, 0x80006469, 0x8000647e, + 0x8000649d, 0x80006477, 0x80003a6c, 0x8000654f, + 0x8000656c, 0x8002300a, 0x800065e3, 0x800066f8, + 0x80006649, 0x80003b19, 0x80006691, 0x80003b08, + 0x80003ae4, 0x80005192, 0x80005195, 0x80006700, + 0x8000669c, 0x800080ad, 0x800043d9, 0x80006717, + 0x8000671b, 0x80006721, 0x8000675e, 0x80006753, + 0x800233c3, 0x80003b49, 0x800067fa, 0x80006785, + 0x80006852, 0x80006885, 0x8002346d, 0x8000688e, + 0x8000681f, 0x80006914, 0x80003b9d, 0x80006942, + 0x800069a3, 0x800069ea, 0x80006aa8, 0x800236a3, + 0x80006adb, 0x80003c18, 0x80006b21, 0x800238a7, + 0x80006b54, 0x80003c4e, 0x80006b72, 0x80006b9f, + 0x80006bba, 0x80006bbb, 0x80023a8d, 0x80021d0b, + 0x80023afa, 0x80006c4e, 0x80023cbc, 0x80006cbf, + 0x80006ccd, 0x80006c67, 0x80006d16, 0x80006d3e, + 0x80006d77, 0x80006d41, 0x80006d69, 0x80006d78, + 0x80006d85, 0x80023d1e, 0x80006d34, 0x80006e2f, + 0x80006e6e, 0x80003d33, 0x80006ecb, 0x80006ec7, + 0x80023ed1, 0x80006df9, 0x80006f6e, 0x80023f5e, + 0x80023f8e, 0x80006fc6, 0x80007039, 0x8000701e, + 0x8000701b, 0x80003d96, 0x8000704a, 0x8000707d, + 0x80007077, 0x800070ad, 0x80020525, 0x80007145, + 0x80024263, 0x8000719c, 0x800043ab, 0x80007228, + 0x80007235, 0x80007250, 0x80024608, 0x80007280, + 0x80007295, 0x80024735, 0x80024814, 0x8000737a, + 0x8000738b, 0x80003eac, 0x800073a5, 0x80003eb8, + 0x80003eb8, 0x80007447, 0x8000745c, 0x80007471, + 0x80007485, 0x800074ca, 0x80003f1b, 0x80007524, + 0x80024c36, 0x8000753e, 0x80024c92, 0x80007570, + 0x8002219f, 0x80007610, 0x80024fa1, 0x80024fb8, + 0x80025044, 0x80003ffc, 0x80004008, 0x800076f4, + 0x800250f3, 0x800250f2, 0x80025119, 0x80025133, + 0x8000771e, 0x8000771f, 0x8000771f, 0x8000774a, + 0x80004039, 0x8000778b, 0x80004046, 0x80004096, + 0x8002541d, 0x8000784e, 0x8000788c, 0x800078cc, + 0x800040e3, 0x80025626, 0x80007956, 0x8002569a, + 0x800256c5, 0x8000798f, 0x800079eb, 0x8000412f, + 0x80007a40, 0x80007a4a, 0x80007a4f, 0x8002597c, + 0x80025aa7, 0x80025aa7, 0x80007aae, 0x80004202, + 0x80025bab, 0x80007bc6, 0x80007bc9, 0x80004227, + 0x80025c80, 0x80007cd2, 0x800042a0, 0x80007ce8, + 0x80007ce3, 0x80007d00, 0x80025f86, 0x80007d63, + 0x80004301, 0x80007dc7, 0x80007e02, 0x80007e45, + 0x80004334, 0x80026228, 0x80026247, 0x80004359, + 0x800262d9, 0x80007f7a, 0x8002633e, 0x80007f95, + 0x80007ffa, 0x80008005, 0x800264da, 0x80026523, + 0x80008060, 0x800265a8, 0x80008070, 0x8002335f, + 0x800043d5, 0x800080b2, 0x80008103, 0x8000440b, + 0x8000813e, 0x80005ab5, 0x800267a7, 0x800267b5, + 0x80023393, 0x8002339c, 0x80008201, 0x80008204, + 0x80008f9e, 0x8000446b, 0x80008291, 0x8000828b, + 0x8000829d, 0x800052b3, 0x800082b1, 0x800082b3, + 0x800082bd, 0x800082e6, 0x80026b3c, 0x800082e5, + 0x8000831d, 0x80008363, 0x800083ad, 0x80008323, + 0x800083bd, 0x800083e7, 0x80008457, 0x80008353, + 0x800083ca, 0x800083cc, 0x800083dc, 0x80026c36, + 0x80026d6b, 0x80026cd5, 0x8000452b, 0x800084f1, + 0x800084f3, 0x80008516, 0x800273ca, 0x80008564, + 0x80026f2c, 0x8000455d, 0x80004561, 0x80026fb1, + 0x800270d2, 0x8000456b, 0x80008650, 0x8000865c, + 0x80008667, 0x80008669, 0x800086a9, 0x80008688, + 0x8000870e, 0x800086e2, 0x80008779, 0x80008728, + 0x8000876b, 0x80008786, 0x80004d57, 0x800087e1, + 0x80008801, 0x800045f9, 0x80008860, 0x80008863, + 0x80027667, 0x800088d7, 0x800088de, 0x80004635, + 0x800088fa, 0x800034bb, 0x800278ae, 0x80027966, + 0x800046be, 0x800046c7, 0x80008aa0, 0x80008aed, + 0x80008b8a, 0x80008c55, 0x80027ca8, 0x80008cab, + 0x80008cc1, 0x80008d1b, 0x80008d77, 0x80027f2f, + 0x80020804, 0x80008dcb, 0x80008dbc, 0x80008df0, + 0x800208de, 0x80008ed4, 0x80008f38, 0x800285d2, + 0x800285ed, 0x80009094, 0x800090f1, 0x80009111, + 0x8002872e, 0x8000911b, 0x80009238, 0x800092d7, + 0x800092d8, 0x8000927c, 0x800093f9, 0x80009415, + 0x80028bfa, 0x8000958b, 0x80004995, 0x800095b7, + 0x80028d77, 0x800049e6, 0x800096c3, 0x80005db2, + 0x80009723, 0x80029145, 0x8002921a, 0x80004a6e, + 0x80004a76, 0x800097e0, 0x8002940a, 0x80004ab2, + 0x80029496, 0x8000980b, 0x8000980b, 0x80009829, + 0x800295b6, 0x800098e2, 0x80004b33, 0x80009929, + 0x800099a7, 0x800099c2, 0x800099fe, 0x80004bce, + 0x80029b30, 0x80009b12, 0x80009c40, 0x80009cfd, + 0x80004cce, 0x80004ced, 0x80009d67, 0x8002a0ce, + 0x80004cf8, 0x8002a105, 0x8002a20e, 0x8002a291, + 0x80009ebb, 0x80004d56, 0x80009ef9, 0x80009efe, + 0x80009f05, 0x80009f0f, 0x80009f16, 0x80009f3b, + 0x8002a600, +}; + + +/* + * Lowercase <-> Uppercase mapping + */ + +/* + * Flags for special case mapping. + */ +#define CMF_FINAL 1 +#define CMF_NONFINAL 2 +#define CMF_LAST 16 +#define CMF_CTXDEP (CMF_FINAL|CMF_NONFINAL) + +#define CASEMAP_BITS_0 9 +#define CASEMAP_BITS_1 7 +#define CASEMAP_BITS_2 5 + +static const unsigned short v320_toupper_imap[] = { + 272, 400, 528, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 784, + 912, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 0, 0, 0, 1, 0, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, + 13, 14, 15, 16, 17, 0, 0, 0, + 0, 0, 18, 0, 19, 20, 21, 22, + 0, 23, 24, 25, 26, 27, 28, 29, + 30, 0, 0, 31, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 33, 34, 35, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 46, 47, 48, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 49, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 50, 51, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 52, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 53, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 54, 55, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, +}; + +static const struct { + unsigned short tbl[32]; +} v320_toupper_table[] = { + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, + 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, + 43, 45, 47, 49, 51, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 53, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, + }}, + {{ + 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, + 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, + 102, 0, 104, 106, 108, 110, 112, 114, 116, 118, + }}, + {{ + 0, 120, 0, 122, 0, 124, 0, 126, 0, 128, 0, + 130, 0, 132, 0, 134, 0, 136, 0, 138, 0, 140, + 0, 142, 0, 144, 0, 146, 0, 148, 0, 150, + }}, + {{ + 0, 152, 0, 154, 0, 156, 0, 158, 0, 160, 0, + 162, 0, 164, 0, 166, 0, 168, 0, 170, 0, 172, + 0, 174, 0, 0, 176, 0, 178, 0, 180, 0, + }}, + {{ + 182, 0, 184, 0, 186, 0, 188, 0, 190, 192, 0, + 195, 0, 197, 0, 199, 0, 201, 0, 203, 0, 205, + 0, 207, 0, 209, 0, 211, 0, 213, 0, 215, + }}, + {{ + 0, 217, 0, 219, 0, 221, 0, 223, 0, 225, 0, + 227, 0, 229, 0, 231, 0, 233, 0, 235, 0, 237, + 0, 239, 0, 0, 241, 0, 243, 0, 245, 247, + }}, + {{ + 0, 0, 0, 249, 0, 251, 0, 0, 253, 0, 0, + 0, 255, 0, 0, 0, 0, 0, 257, 0, 0, 259, + 0, 0, 0, 261, 0, 0, 0, 0, 263, 0, + }}, + {{ + 0, 265, 0, 267, 0, 269, 0, 0, 271, 0, 0, + 0, 0, 273, 0, 0, 275, 0, 0, 0, 277, 0, + 279, 0, 0, 281, 0, 0, 0, 283, 0, 285, + }}, + {{ + 0, 0, 0, 0, 0, 287, 289, 0, 291, 293, 0, + 295, 297, 0, 299, 0, 301, 0, 303, 0, 305, 0, + 307, 0, 309, 0, 311, 0, 313, 315, 0, 317, + }}, + {{ + 0, 319, 0, 321, 0, 323, 0, 325, 0, 327, 0, + 329, 0, 331, 0, 333, 335, 0, 338, 340, 0, 342, + 0, 0, 0, 344, 0, 346, 0, 348, 0, 350, + }}, + {{ + 0, 352, 0, 354, 0, 356, 0, 358, 0, 360, 0, + 362, 0, 364, 0, 366, 0, 368, 0, 370, 0, 372, + 0, 374, 0, 376, 0, 378, 0, 380, 0, 382, + }}, + {{ + 0, 0, 0, 384, 0, 386, 0, 388, 0, 390, 0, + 392, 0, 394, 0, 396, 0, 398, 0, 400, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 402, 404, 0, + 406, 408, 0, 410, 0, 412, 0, 0, 0, 0, + }}, + {{ + 414, 0, 0, 416, 0, 0, 0, 0, 418, 420, 0, + 0, 0, 0, 0, 422, 0, 0, 424, 0, 0, 426, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 428, 0, 0, 430, 0, 0, 0, 0, 432, 0, 434, + 436, 0, 0, 0, 0, 0, 0, 438, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 440, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 442, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 446, 448, 450, 452, 454, 458, 460, 462, 464, 466, + 468, 470, 472, 474, 476, 478, 480, 482, 484, 486, + }}, + {{ + 488, 490, 492, 494, 496, 498, 500, 502, 504, 506, 508, + 510, 512, 514, 516, 0, 518, 520, 0, 0, 0, 522, + 524, 0, 0, 526, 0, 528, 0, 530, 0, 532, + }}, + {{ + 0, 534, 0, 536, 0, 538, 0, 540, 0, 542, 0, + 544, 0, 546, 0, 548, 550, 552, 554, 0, 0, 556, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 558, 560, 562, 564, 566, 568, + 570, 572, 574, 576, 578, 580, 582, 584, 586, 588, + }}, + {{ + 590, 592, 594, 596, 598, 600, 602, 604, 606, 608, 610, + 612, 614, 616, 618, 620, 622, 624, 626, 628, 630, 632, + 634, 636, 638, 640, 642, 644, 646, 648, 650, 652, + }}, + {{ + 0, 654, 0, 656, 0, 658, 0, 660, 0, 662, 0, + 664, 0, 666, 0, 668, 0, 670, 0, 672, 0, 674, + 0, 676, 0, 678, 0, 680, 0, 682, 0, 684, + }}, + {{ + 0, 686, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 688, 0, 690, 0, 692, 0, 694, 0, 696, 0, 698, + 0, 700, 0, 702, 0, 704, 0, 706, 0, 708, + }}, + {{ + 0, 710, 0, 712, 0, 714, 0, 716, 0, 718, 0, + 720, 0, 722, 0, 724, 0, 726, 0, 728, 0, 730, + 0, 732, 0, 734, 0, 736, 0, 738, 0, 740, + }}, + {{ + 0, 0, 742, 0, 744, 0, 746, 0, 748, 0, 750, + 0, 752, 0, 754, 0, 0, 756, 0, 758, 0, 760, + 0, 762, 0, 764, 0, 766, 0, 768, 0, 770, + }}, + {{ + 0, 772, 0, 774, 0, 776, 0, 778, 0, 780, 0, + 782, 0, 784, 0, 786, 0, 788, 0, 790, 0, 792, + 0, 0, 0, 794, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 796, 0, 798, 0, 800, 0, 802, 0, 804, 0, + 806, 0, 808, 0, 810, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 812, 814, 816, 818, 820, 822, 824, 826, 828, 830, + 832, 834, 836, 838, 840, 842, 844, 846, 848, 850, 852, + 854, 856, 858, 860, 862, 864, 866, 868, 870, 872, + }}, + {{ + 874, 876, 878, 880, 882, 884, 886, 888, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 891, 0, 893, 0, 895, 0, 897, 0, 899, 0, + 901, 0, 903, 0, 905, 0, 907, 0, 909, 0, 911, + 0, 913, 0, 915, 0, 917, 0, 919, 0, 921, + }}, + {{ + 0, 923, 0, 925, 0, 927, 0, 929, 0, 931, 0, + 933, 0, 935, 0, 937, 0, 939, 0, 941, 0, 943, + 0, 945, 0, 947, 0, 949, 0, 951, 0, 953, + }}, + {{ + 0, 955, 0, 957, 0, 959, 0, 961, 0, 963, 0, + 965, 0, 967, 0, 969, 0, 971, 0, 973, 0, 975, + 0, 977, 0, 979, 0, 981, 0, 983, 0, 985, + }}, + {{ + 0, 987, 0, 989, 0, 991, 0, 993, 0, 995, 0, + 997, 0, 999, 0, 1001, 0, 1003, 0, 1005, 0, 1007, + 0, 1009, 0, 1011, 0, 1013, 0, 1015, 0, 1017, + }}, + {{ + 0, 1019, 0, 1021, 0, 1023, 0, 1025, 0, 1027, 0, + 1029, 0, 1031, 0, 1033, 0, 1035, 0, 1037, 0, 1039, + 1041, 1044, 1047, 1050, 1053, 1056, 0, 0, 0, 0, + }}, + {{ + 0, 1058, 0, 1060, 0, 1062, 0, 1064, 0, 1066, 0, + 1068, 0, 1070, 0, 1072, 0, 1074, 0, 1076, 0, 1078, + 0, 1080, 0, 1082, 0, 1084, 0, 1086, 0, 1088, + }}, + {{ + 0, 1090, 0, 1092, 0, 1094, 0, 1096, 0, 1098, 0, + 1100, 0, 1102, 0, 1104, 0, 1106, 0, 1108, 0, 1110, + 0, 1112, 0, 1114, 0, 1116, 0, 1118, 0, 1120, + }}, + {{ + 0, 1122, 0, 1124, 0, 1126, 0, 1128, 0, 1130, 0, + 1132, 0, 1134, 0, 1136, 0, 1138, 0, 1140, 0, 1142, + 0, 1144, 0, 1146, 0, 0, 0, 0, 0, 0, + }}, + {{ + 1148, 1150, 1152, 1154, 1156, 1158, 1160, 1162, 0, 0, 0, + 0, 0, 0, 0, 0, 1164, 1166, 1168, 1170, 1172, 1174, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 1176, 1178, 1180, 1182, 1184, 1186, 1188, 1190, 0, 0, 0, + 0, 0, 0, 0, 0, 1192, 1194, 1196, 1198, 1200, 1202, + 1204, 1206, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 1208, 1210, 1212, 1214, 1216, 1218, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1220, 1223, 1225, 1229, 1231, 1235, + 1237, 1241, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 1243, 1245, 1247, 1249, 1251, 1253, 1255, 1257, 0, 0, 0, + 0, 0, 0, 0, 0, 1259, 1261, 1263, 1265, 1267, 1269, + 1271, 1273, 1275, 1277, 1279, 1281, 1283, 1285, 0, 0, + }}, + {{ + 1287, 1292, 1297, 1302, 1307, 1312, 1317, 1322, 1327, 1330, 1333, + 1336, 1339, 1342, 1345, 1348, 1351, 1356, 1361, 1366, 1371, 1376, + 1381, 1386, 1391, 1394, 1397, 1400, 1403, 1406, 1409, 1412, + }}, + {{ + 1415, 1420, 1425, 1430, 1435, 1440, 1445, 1450, 1455, 1458, 1461, + 1464, 1467, 1470, 1473, 1476, 1479, 1481, 1483, 1486, 1491, 0, + 1494, 1497, 0, 0, 0, 0, 1501, 0, 1504, 0, + }}, + {{ + 0, 0, 1506, 1509, 1514, 0, 1517, 1520, 0, 0, 0, + 0, 1524, 0, 0, 0, 1527, 1529, 1531, 1535, 0, 0, + 1539, 1542, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 1546, 1548, 1550, 1554, 1558, 1561, 1563, 1566, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1570, 1573, 1578, 0, + 1581, 1584, 0, 0, 0, 0, 1588, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1591, 1593, 1595, 1597, 1599, 1601, + 1603, 1605, 1607, 1609, 1611, 1613, 1615, 1617, 1619, 1621, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1623, 1625, 1627, 1629, 1631, 1633, + 1635, 1637, 1639, 1641, 1643, 1645, 1647, 1649, 1651, 1653, + }}, + {{ + 1655, 1657, 1659, 1661, 1663, 1665, 1667, 1669, 1671, 1673, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 1675, 1678, 1681, 1684, 1688, 1692, 1695, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 1698, 1701, 1704, + 1707, 1710, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 1713, 1715, 1717, 1719, 1721, 1723, 1725, 1727, 1729, 1731, + 1733, 1735, 1737, 1739, 1741, 1743, 1745, 1747, 1749, 1751, 1753, + 1755, 1757, 1759, 1761, 1763, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 1765, 1767, 1769, + 1771, 1773, 1775, 1777, 1779, 1781, 1783, 1785, 1787, 1789, 1791, + 1793, 1795, 1797, 1799, 1801, 1803, 1805, 1807, 1809, 1811, + }}, + {{ + 1813, 1815, 1817, 1819, 1821, 1823, 1825, 1827, 1829, 1831, 1833, + 1835, 1837, 1839, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, +}; +static const unsigned short v320_tolower_imap[] = { + 272, 400, 528, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 784, + 912, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 0, 0, 1, 0, 0, 0, 2, 0, + 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 13, 14, 15, 16, + 17, 18, 0, 19, 20, 21, 22, 23, + 24, 25, 26, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 40, 41, 42, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 43, 0, 44, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 45, 46, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 47, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 48, 49, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, +}; + +static const struct { + unsigned short tbl[32]; +} v320_tolower_table[] = { + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, + 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, + 43, 45, 47, 49, 51, 0, 0, 0, 0, 0, + }}, + {{ + 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, + 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, + 97, 0, 99, 101, 103, 105, 107, 109, 111, 0, + }}, + {{ + 113, 0, 115, 0, 117, 0, 119, 0, 121, 0, 123, + 0, 125, 0, 127, 0, 129, 0, 131, 0, 133, 0, + 135, 0, 137, 0, 139, 0, 141, 0, 143, 0, + }}, + {{ + 145, 0, 147, 0, 149, 0, 151, 0, 153, 0, 155, + 0, 157, 0, 159, 0, 161, 0, 165, 0, 167, 0, + 169, 0, 0, 171, 0, 173, 0, 175, 0, 177, + }}, + {{ + 0, 179, 0, 181, 0, 183, 0, 185, 0, 0, 187, + 0, 189, 0, 191, 0, 193, 0, 195, 0, 197, 0, + 199, 0, 201, 0, 203, 0, 205, 0, 207, 0, + }}, + {{ + 209, 0, 211, 0, 213, 0, 215, 0, 217, 0, 219, + 0, 221, 0, 223, 0, 225, 0, 227, 0, 229, 0, + 231, 0, 233, 235, 0, 237, 0, 239, 0, 0, + }}, + {{ + 0, 241, 243, 0, 245, 0, 247, 249, 0, 251, 253, + 255, 0, 0, 257, 259, 261, 263, 0, 265, 267, 0, + 269, 271, 273, 0, 0, 0, 275, 277, 0, 279, + }}, + {{ + 281, 0, 283, 0, 285, 0, 287, 289, 0, 291, 0, + 0, 293, 0, 295, 297, 0, 299, 301, 303, 0, 305, + 0, 307, 309, 0, 0, 0, 311, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 313, 315, 0, 317, 319, 0, 321, + 323, 0, 325, 0, 327, 0, 329, 0, 331, 0, 333, + 0, 335, 0, 337, 0, 339, 0, 0, 341, 0, + }}, + {{ + 343, 0, 345, 0, 347, 0, 349, 0, 351, 0, 353, + 0, 355, 0, 357, 0, 0, 359, 361, 0, 363, 0, + 365, 367, 369, 0, 371, 0, 373, 0, 375, 0, + }}, + {{ + 377, 0, 379, 0, 381, 0, 383, 0, 385, 0, 387, + 0, 389, 0, 391, 0, 393, 0, 395, 0, 397, 0, + 399, 0, 401, 0, 403, 0, 405, 0, 407, 0, + }}, + {{ + 409, 0, 411, 0, 413, 0, 415, 0, 417, 0, 419, + 0, 421, 0, 423, 0, 425, 0, 427, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 429, 0, 431, 433, 435, + 0, 437, 0, 439, 441, 0, 443, 445, 447, 449, 451, + 453, 455, 457, 459, 461, 463, 465, 467, 469, 471, + }}, + {{ + 473, 475, 0, 477, 479, 481, 483, 485, 487, 489, 491, + 493, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 495, 0, 497, 0, 499, 0, 501, 0, + }}, + {{ + 503, 0, 505, 0, 507, 0, 509, 0, 511, 0, 513, + 0, 515, 0, 517, 0, 0, 0, 0, 0, 519, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 521, 523, 525, 527, 529, 531, 533, 535, 537, 539, 541, + 543, 545, 547, 549, 551, 553, 555, 557, 559, 561, 563, + 565, 567, 569, 571, 573, 575, 577, 579, 581, 583, + }}, + {{ + 585, 587, 589, 591, 593, 595, 597, 599, 601, 603, 605, + 607, 609, 611, 613, 615, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 617, 0, 619, 0, 621, 0, 623, 0, 625, 0, 627, + 0, 629, 0, 631, 0, 633, 0, 635, 0, 637, 0, + 639, 0, 641, 0, 643, 0, 645, 0, 647, 0, + }}, + {{ + 649, 0, 0, 0, 0, 0, 0, 0, 0, 0, 651, + 0, 653, 0, 655, 0, 657, 0, 659, 0, 661, 0, + 663, 0, 665, 0, 667, 0, 669, 0, 671, 0, + }}, + {{ + 673, 0, 675, 0, 677, 0, 679, 0, 681, 0, 683, + 0, 685, 0, 687, 0, 689, 0, 691, 0, 693, 0, + 695, 0, 697, 0, 699, 0, 701, 0, 703, 0, + }}, + {{ + 0, 705, 0, 707, 0, 709, 0, 711, 0, 713, 0, + 715, 0, 717, 0, 0, 719, 0, 721, 0, 723, 0, + 725, 0, 727, 0, 729, 0, 731, 0, 733, 0, + }}, + {{ + 735, 0, 737, 0, 739, 0, 741, 0, 743, 0, 745, + 0, 747, 0, 749, 0, 751, 0, 753, 0, 755, 0, + 0, 0, 757, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 759, 0, 761, 0, 763, 0, 765, 0, 767, 0, 769, + 0, 771, 0, 773, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 775, 777, 779, 781, 783, + 785, 787, 789, 791, 793, 795, 797, 799, 801, 803, + }}, + {{ + 805, 807, 809, 811, 813, 815, 817, 819, 821, 823, 825, + 827, 829, 831, 833, 835, 837, 839, 841, 843, 845, 847, + 849, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 851, 0, 853, 0, 855, 0, 857, 0, 859, 0, 861, + 0, 863, 0, 865, 0, 867, 0, 869, 0, 871, 0, + 873, 0, 875, 0, 877, 0, 879, 0, 881, 0, + }}, + {{ + 883, 0, 885, 0, 887, 0, 889, 0, 891, 0, 893, + 0, 895, 0, 897, 0, 899, 0, 901, 0, 903, 0, + 905, 0, 907, 0, 909, 0, 911, 0, 913, 0, + }}, + {{ + 915, 0, 917, 0, 919, 0, 921, 0, 923, 0, 925, + 0, 927, 0, 929, 0, 931, 0, 933, 0, 935, 0, + 937, 0, 939, 0, 941, 0, 943, 0, 945, 0, + }}, + {{ + 947, 0, 949, 0, 951, 0, 953, 0, 955, 0, 957, + 0, 959, 0, 961, 0, 963, 0, 965, 0, 967, 0, + 969, 0, 971, 0, 973, 0, 975, 0, 977, 0, + }}, + {{ + 979, 0, 981, 0, 983, 0, 985, 0, 987, 0, 989, + 0, 991, 0, 993, 0, 995, 0, 997, 0, 999, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 1001, 0, 1003, 0, 1005, 0, 1007, 0, 1009, 0, 1011, + 0, 1013, 0, 1015, 0, 1017, 0, 1019, 0, 1021, 0, + 1023, 0, 1025, 0, 1027, 0, 1029, 0, 1031, 0, + }}, + {{ + 1033, 0, 1035, 0, 1037, 0, 1039, 0, 1041, 0, 1043, + 0, 1045, 0, 1047, 0, 1049, 0, 1051, 0, 1053, 0, + 1055, 0, 1057, 0, 1059, 0, 1061, 0, 1063, 0, + }}, + {{ + 1065, 0, 1067, 0, 1069, 0, 1071, 0, 1073, 0, 1075, + 0, 1077, 0, 1079, 0, 1081, 0, 1083, 0, 1085, 0, + 1087, 0, 1089, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 1091, 1093, 1095, + 1097, 1099, 1101, 1103, 1105, 0, 0, 0, 0, 0, 0, + 0, 0, 1107, 1109, 1111, 1113, 1115, 1117, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 1119, 1121, 1123, + 1125, 1127, 1129, 1131, 1133, 0, 0, 0, 0, 0, 0, + 0, 0, 1135, 1137, 1139, 1141, 1143, 1145, 1147, 1149, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 1151, 1153, 1155, + 1157, 1159, 1161, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1163, 0, 1165, 0, 1167, 0, 1169, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 1171, 1173, 1175, + 1177, 1179, 1181, 1183, 1185, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 1187, 1191, 1195, + 1199, 1203, 1207, 1211, 1215, 0, 0, 0, 0, 0, 0, + 0, 0, 1219, 1223, 1227, 1231, 1235, 1239, 1243, 1247, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 1251, 1255, 1259, + 1263, 1267, 1271, 1275, 1279, 0, 0, 0, 0, 0, 0, + 0, 0, 1283, 1285, 1287, 1289, 1291, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 1295, 1297, 1299, + 1301, 1303, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1307, 1309, 1311, 1313, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 1315, 1317, 1319, + 1321, 1323, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1325, 1327, 1329, 1331, 1333, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 1337, 0, 0, 0, 1339, + 1341, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 1343, 1345, 1347, 1349, 1351, 1353, 1355, 1357, 1359, 1361, 1363, + 1365, 1367, 1369, 1371, 1373, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1375, 1377, 1379, 1381, 1383, 1385, 1387, 1389, 1391, 1393, + }}, + {{ + 1395, 1397, 1399, 1401, 1403, 1405, 1407, 1409, 1411, 1413, 1415, + 1417, 1419, 1421, 1423, 1425, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 1427, 1429, 1431, 1433, 1435, 1437, 1439, 1441, 1443, 1445, + 1447, 1449, 1451, 1453, 1455, 1457, 1459, 1461, 1463, 1465, 1467, + 1469, 1471, 1473, 1475, 1477, 0, 0, 0, 0, 0, + }}, + {{ + 1479, 1481, 1483, 1485, 1487, 1489, 1491, 1493, 1495, 1497, 1499, + 1501, 1503, 1505, 1507, 1509, 1511, 1513, 1515, 1517, 1519, 1521, + 1523, 1525, 1527, 1529, 1531, 1533, 1535, 1537, 1539, 1541, + }}, + {{ + 1543, 1545, 1547, 1549, 1551, 1553, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, +}; +static const unsigned long v320_toupper_seq[] = { + 0x00000000, 0x00000010, 0x80000041, 0x00000010, + 0x80000042, 0x00000010, 0x80000043, 0x00000010, + 0x80000044, 0x00000010, 0x80000045, 0x00000010, + 0x80000046, 0x00000010, 0x80000047, 0x00000010, + 0x80000048, 0x00000010, 0x80000049, 0x00000010, + 0x8000004a, 0x00000010, 0x8000004b, 0x00000010, + 0x8000004c, 0x00000010, 0x8000004d, 0x00000010, + 0x8000004e, 0x00000010, 0x8000004f, 0x00000010, + 0x80000050, 0x00000010, 0x80000051, 0x00000010, + 0x80000052, 0x00000010, 0x80000053, 0x00000010, + 0x80000054, 0x00000010, 0x80000055, 0x00000010, + 0x80000056, 0x00000010, 0x80000057, 0x00000010, + 0x80000058, 0x00000010, 0x80000059, 0x00000010, + 0x8000005a, 0x00000010, 0x8000039c, 0x00000010, + 0x00000053, 0x80000053, 0x00000010, 0x800000c0, + 0x00000010, 0x800000c1, 0x00000010, 0x800000c2, + 0x00000010, 0x800000c3, 0x00000010, 0x800000c4, + 0x00000010, 0x800000c5, 0x00000010, 0x800000c6, + 0x00000010, 0x800000c7, 0x00000010, 0x800000c8, + 0x00000010, 0x800000c9, 0x00000010, 0x800000ca, + 0x00000010, 0x800000cb, 0x00000010, 0x800000cc, + 0x00000010, 0x800000cd, 0x00000010, 0x800000ce, + 0x00000010, 0x800000cf, 0x00000010, 0x800000d0, + 0x00000010, 0x800000d1, 0x00000010, 0x800000d2, + 0x00000010, 0x800000d3, 0x00000010, 0x800000d4, + 0x00000010, 0x800000d5, 0x00000010, 0x800000d6, + 0x00000010, 0x800000d8, 0x00000010, 0x800000d9, + 0x00000010, 0x800000da, 0x00000010, 0x800000db, + 0x00000010, 0x800000dc, 0x00000010, 0x800000dd, + 0x00000010, 0x800000de, 0x00000010, 0x80000178, + 0x00000010, 0x80000100, 0x00000010, 0x80000102, + 0x00000010, 0x80000104, 0x00000010, 0x80000106, + 0x00000010, 0x80000108, 0x00000010, 0x8000010a, + 0x00000010, 0x8000010c, 0x00000010, 0x8000010e, + 0x00000010, 0x80000110, 0x00000010, 0x80000112, + 0x00000010, 0x80000114, 0x00000010, 0x80000116, + 0x00000010, 0x80000118, 0x00000010, 0x8000011a, + 0x00000010, 0x8000011c, 0x00000010, 0x8000011e, + 0x00000010, 0x80000120, 0x00000010, 0x80000122, + 0x00000010, 0x80000124, 0x00000010, 0x80000126, + 0x00000010, 0x80000128, 0x00000010, 0x8000012a, + 0x00000010, 0x8000012c, 0x00000010, 0x8000012e, + 0x00000010, 0x80000049, 0x00000010, 0x80000132, + 0x00000010, 0x80000134, 0x00000010, 0x80000136, + 0x00000010, 0x80000139, 0x00000010, 0x8000013b, + 0x00000010, 0x8000013d, 0x00000010, 0x8000013f, + 0x00000010, 0x80000141, 0x00000010, 0x80000143, + 0x00000010, 0x80000145, 0x00000010, 0x80000147, + 0x00000010, 0x000002bc, 0x8000004e, 0x00000010, + 0x8000014a, 0x00000010, 0x8000014c, 0x00000010, + 0x8000014e, 0x00000010, 0x80000150, 0x00000010, + 0x80000152, 0x00000010, 0x80000154, 0x00000010, + 0x80000156, 0x00000010, 0x80000158, 0x00000010, + 0x8000015a, 0x00000010, 0x8000015c, 0x00000010, + 0x8000015e, 0x00000010, 0x80000160, 0x00000010, + 0x80000162, 0x00000010, 0x80000164, 0x00000010, + 0x80000166, 0x00000010, 0x80000168, 0x00000010, + 0x8000016a, 0x00000010, 0x8000016c, 0x00000010, + 0x8000016e, 0x00000010, 0x80000170, 0x00000010, + 0x80000172, 0x00000010, 0x80000174, 0x00000010, + 0x80000176, 0x00000010, 0x80000179, 0x00000010, + 0x8000017b, 0x00000010, 0x8000017d, 0x00000010, + 0x80000053, 0x00000010, 0x80000182, 0x00000010, + 0x80000184, 0x00000010, 0x80000187, 0x00000010, + 0x8000018b, 0x00000010, 0x80000191, 0x00000010, + 0x800001f6, 0x00000010, 0x80000198, 0x00000010, + 0x80000220, 0x00000010, 0x800001a0, 0x00000010, + 0x800001a2, 0x00000010, 0x800001a4, 0x00000010, + 0x800001a7, 0x00000010, 0x800001ac, 0x00000010, + 0x800001af, 0x00000010, 0x800001b3, 0x00000010, + 0x800001b5, 0x00000010, 0x800001b8, 0x00000010, + 0x800001bc, 0x00000010, 0x800001f7, 0x00000010, + 0x800001c4, 0x00000010, 0x800001c4, 0x00000010, + 0x800001c7, 0x00000010, 0x800001c7, 0x00000010, + 0x800001ca, 0x00000010, 0x800001ca, 0x00000010, + 0x800001cd, 0x00000010, 0x800001cf, 0x00000010, + 0x800001d1, 0x00000010, 0x800001d3, 0x00000010, + 0x800001d5, 0x00000010, 0x800001d7, 0x00000010, + 0x800001d9, 0x00000010, 0x800001db, 0x00000010, + 0x8000018e, 0x00000010, 0x800001de, 0x00000010, + 0x800001e0, 0x00000010, 0x800001e2, 0x00000010, + 0x800001e4, 0x00000010, 0x800001e6, 0x00000010, + 0x800001e8, 0x00000010, 0x800001ea, 0x00000010, + 0x800001ec, 0x00000010, 0x800001ee, 0x00000010, + 0x0000004a, 0x8000030c, 0x00000010, 0x800001f1, + 0x00000010, 0x800001f1, 0x00000010, 0x800001f4, + 0x00000010, 0x800001f8, 0x00000010, 0x800001fa, + 0x00000010, 0x800001fc, 0x00000010, 0x800001fe, + 0x00000010, 0x80000200, 0x00000010, 0x80000202, + 0x00000010, 0x80000204, 0x00000010, 0x80000206, + 0x00000010, 0x80000208, 0x00000010, 0x8000020a, + 0x00000010, 0x8000020c, 0x00000010, 0x8000020e, + 0x00000010, 0x80000210, 0x00000010, 0x80000212, + 0x00000010, 0x80000214, 0x00000010, 0x80000216, + 0x00000010, 0x80000218, 0x00000010, 0x8000021a, + 0x00000010, 0x8000021c, 0x00000010, 0x8000021e, + 0x00000010, 0x80000222, 0x00000010, 0x80000224, + 0x00000010, 0x80000226, 0x00000010, 0x80000228, + 0x00000010, 0x8000022a, 0x00000010, 0x8000022c, + 0x00000010, 0x8000022e, 0x00000010, 0x80000230, + 0x00000010, 0x80000232, 0x00000010, 0x80000181, + 0x00000010, 0x80000186, 0x00000010, 0x80000189, + 0x00000010, 0x8000018a, 0x00000010, 0x8000018f, + 0x00000010, 0x80000190, 0x00000010, 0x80000193, + 0x00000010, 0x80000194, 0x00000010, 0x80000197, + 0x00000010, 0x80000196, 0x00000010, 0x8000019c, + 0x00000010, 0x8000019d, 0x00000010, 0x8000019f, + 0x00000010, 0x800001a6, 0x00000010, 0x800001a9, + 0x00000010, 0x800001ae, 0x00000010, 0x800001b1, + 0x00000010, 0x800001b2, 0x00000010, 0x800001b7, + 0x00000010, 0x80000399, 0x00000010, 0x00000399, + 0x00000308, 0x80000301, 0x00000010, 0x80000386, + 0x00000010, 0x80000388, 0x00000010, 0x80000389, + 0x00000010, 0x8000038a, 0x00000010, 0x000003a5, + 0x00000308, 0x80000301, 0x00000010, 0x80000391, + 0x00000010, 0x80000392, 0x00000010, 0x80000393, + 0x00000010, 0x80000394, 0x00000010, 0x80000395, + 0x00000010, 0x80000396, 0x00000010, 0x80000397, + 0x00000010, 0x80000398, 0x00000010, 0x80000399, + 0x00000010, 0x8000039a, 0x00000010, 0x8000039b, + 0x00000010, 0x8000039c, 0x00000010, 0x8000039d, + 0x00000010, 0x8000039e, 0x00000010, 0x8000039f, + 0x00000010, 0x800003a0, 0x00000010, 0x800003a1, + 0x00000010, 0x800003a3, 0x00000010, 0x800003a3, + 0x00000010, 0x800003a4, 0x00000010, 0x800003a5, + 0x00000010, 0x800003a6, 0x00000010, 0x800003a7, + 0x00000010, 0x800003a8, 0x00000010, 0x800003a9, + 0x00000010, 0x800003aa, 0x00000010, 0x800003ab, + 0x00000010, 0x8000038c, 0x00000010, 0x8000038e, + 0x00000010, 0x8000038f, 0x00000010, 0x80000392, + 0x00000010, 0x80000398, 0x00000010, 0x800003a6, + 0x00000010, 0x800003a0, 0x00000010, 0x800003d8, + 0x00000010, 0x800003da, 0x00000010, 0x800003dc, + 0x00000010, 0x800003de, 0x00000010, 0x800003e0, + 0x00000010, 0x800003e2, 0x00000010, 0x800003e4, + 0x00000010, 0x800003e6, 0x00000010, 0x800003e8, + 0x00000010, 0x800003ea, 0x00000010, 0x800003ec, + 0x00000010, 0x800003ee, 0x00000010, 0x8000039a, + 0x00000010, 0x800003a1, 0x00000010, 0x800003a3, + 0x00000010, 0x80000395, 0x00000010, 0x80000410, + 0x00000010, 0x80000411, 0x00000010, 0x80000412, + 0x00000010, 0x80000413, 0x00000010, 0x80000414, + 0x00000010, 0x80000415, 0x00000010, 0x80000416, + 0x00000010, 0x80000417, 0x00000010, 0x80000418, + 0x00000010, 0x80000419, 0x00000010, 0x8000041a, + 0x00000010, 0x8000041b, 0x00000010, 0x8000041c, + 0x00000010, 0x8000041d, 0x00000010, 0x8000041e, + 0x00000010, 0x8000041f, 0x00000010, 0x80000420, + 0x00000010, 0x80000421, 0x00000010, 0x80000422, + 0x00000010, 0x80000423, 0x00000010, 0x80000424, + 0x00000010, 0x80000425, 0x00000010, 0x80000426, + 0x00000010, 0x80000427, 0x00000010, 0x80000428, + 0x00000010, 0x80000429, 0x00000010, 0x8000042a, + 0x00000010, 0x8000042b, 0x00000010, 0x8000042c, + 0x00000010, 0x8000042d, 0x00000010, 0x8000042e, + 0x00000010, 0x8000042f, 0x00000010, 0x80000400, + 0x00000010, 0x80000401, 0x00000010, 0x80000402, + 0x00000010, 0x80000403, 0x00000010, 0x80000404, + 0x00000010, 0x80000405, 0x00000010, 0x80000406, + 0x00000010, 0x80000407, 0x00000010, 0x80000408, + 0x00000010, 0x80000409, 0x00000010, 0x8000040a, + 0x00000010, 0x8000040b, 0x00000010, 0x8000040c, + 0x00000010, 0x8000040d, 0x00000010, 0x8000040e, + 0x00000010, 0x8000040f, 0x00000010, 0x80000460, + 0x00000010, 0x80000462, 0x00000010, 0x80000464, + 0x00000010, 0x80000466, 0x00000010, 0x80000468, + 0x00000010, 0x8000046a, 0x00000010, 0x8000046c, + 0x00000010, 0x8000046e, 0x00000010, 0x80000470, + 0x00000010, 0x80000472, 0x00000010, 0x80000474, + 0x00000010, 0x80000476, 0x00000010, 0x80000478, + 0x00000010, 0x8000047a, 0x00000010, 0x8000047c, + 0x00000010, 0x8000047e, 0x00000010, 0x80000480, + 0x00000010, 0x8000048a, 0x00000010, 0x8000048c, + 0x00000010, 0x8000048e, 0x00000010, 0x80000490, + 0x00000010, 0x80000492, 0x00000010, 0x80000494, + 0x00000010, 0x80000496, 0x00000010, 0x80000498, + 0x00000010, 0x8000049a, 0x00000010, 0x8000049c, + 0x00000010, 0x8000049e, 0x00000010, 0x800004a0, + 0x00000010, 0x800004a2, 0x00000010, 0x800004a4, + 0x00000010, 0x800004a6, 0x00000010, 0x800004a8, + 0x00000010, 0x800004aa, 0x00000010, 0x800004ac, + 0x00000010, 0x800004ae, 0x00000010, 0x800004b0, + 0x00000010, 0x800004b2, 0x00000010, 0x800004b4, + 0x00000010, 0x800004b6, 0x00000010, 0x800004b8, + 0x00000010, 0x800004ba, 0x00000010, 0x800004bc, + 0x00000010, 0x800004be, 0x00000010, 0x800004c1, + 0x00000010, 0x800004c3, 0x00000010, 0x800004c5, + 0x00000010, 0x800004c7, 0x00000010, 0x800004c9, + 0x00000010, 0x800004cb, 0x00000010, 0x800004cd, + 0x00000010, 0x800004d0, 0x00000010, 0x800004d2, + 0x00000010, 0x800004d4, 0x00000010, 0x800004d6, + 0x00000010, 0x800004d8, 0x00000010, 0x800004da, + 0x00000010, 0x800004dc, 0x00000010, 0x800004de, + 0x00000010, 0x800004e0, 0x00000010, 0x800004e2, + 0x00000010, 0x800004e4, 0x00000010, 0x800004e6, + 0x00000010, 0x800004e8, 0x00000010, 0x800004ea, + 0x00000010, 0x800004ec, 0x00000010, 0x800004ee, + 0x00000010, 0x800004f0, 0x00000010, 0x800004f2, + 0x00000010, 0x800004f4, 0x00000010, 0x800004f8, + 0x00000010, 0x80000500, 0x00000010, 0x80000502, + 0x00000010, 0x80000504, 0x00000010, 0x80000506, + 0x00000010, 0x80000508, 0x00000010, 0x8000050a, + 0x00000010, 0x8000050c, 0x00000010, 0x8000050e, + 0x00000010, 0x80000531, 0x00000010, 0x80000532, + 0x00000010, 0x80000533, 0x00000010, 0x80000534, + 0x00000010, 0x80000535, 0x00000010, 0x80000536, + 0x00000010, 0x80000537, 0x00000010, 0x80000538, + 0x00000010, 0x80000539, 0x00000010, 0x8000053a, + 0x00000010, 0x8000053b, 0x00000010, 0x8000053c, + 0x00000010, 0x8000053d, 0x00000010, 0x8000053e, + 0x00000010, 0x8000053f, 0x00000010, 0x80000540, + 0x00000010, 0x80000541, 0x00000010, 0x80000542, + 0x00000010, 0x80000543, 0x00000010, 0x80000544, + 0x00000010, 0x80000545, 0x00000010, 0x80000546, + 0x00000010, 0x80000547, 0x00000010, 0x80000548, + 0x00000010, 0x80000549, 0x00000010, 0x8000054a, + 0x00000010, 0x8000054b, 0x00000010, 0x8000054c, + 0x00000010, 0x8000054d, 0x00000010, 0x8000054e, + 0x00000010, 0x8000054f, 0x00000010, 0x80000550, + 0x00000010, 0x80000551, 0x00000010, 0x80000552, + 0x00000010, 0x80000553, 0x00000010, 0x80000554, + 0x00000010, 0x80000555, 0x00000010, 0x80000556, + 0x00000010, 0x00000535, 0x80000552, 0x00000010, + 0x80001e00, 0x00000010, 0x80001e02, 0x00000010, + 0x80001e04, 0x00000010, 0x80001e06, 0x00000010, + 0x80001e08, 0x00000010, 0x80001e0a, 0x00000010, + 0x80001e0c, 0x00000010, 0x80001e0e, 0x00000010, + 0x80001e10, 0x00000010, 0x80001e12, 0x00000010, + 0x80001e14, 0x00000010, 0x80001e16, 0x00000010, + 0x80001e18, 0x00000010, 0x80001e1a, 0x00000010, + 0x80001e1c, 0x00000010, 0x80001e1e, 0x00000010, + 0x80001e20, 0x00000010, 0x80001e22, 0x00000010, + 0x80001e24, 0x00000010, 0x80001e26, 0x00000010, + 0x80001e28, 0x00000010, 0x80001e2a, 0x00000010, + 0x80001e2c, 0x00000010, 0x80001e2e, 0x00000010, + 0x80001e30, 0x00000010, 0x80001e32, 0x00000010, + 0x80001e34, 0x00000010, 0x80001e36, 0x00000010, + 0x80001e38, 0x00000010, 0x80001e3a, 0x00000010, + 0x80001e3c, 0x00000010, 0x80001e3e, 0x00000010, + 0x80001e40, 0x00000010, 0x80001e42, 0x00000010, + 0x80001e44, 0x00000010, 0x80001e46, 0x00000010, + 0x80001e48, 0x00000010, 0x80001e4a, 0x00000010, + 0x80001e4c, 0x00000010, 0x80001e4e, 0x00000010, + 0x80001e50, 0x00000010, 0x80001e52, 0x00000010, + 0x80001e54, 0x00000010, 0x80001e56, 0x00000010, + 0x80001e58, 0x00000010, 0x80001e5a, 0x00000010, + 0x80001e5c, 0x00000010, 0x80001e5e, 0x00000010, + 0x80001e60, 0x00000010, 0x80001e62, 0x00000010, + 0x80001e64, 0x00000010, 0x80001e66, 0x00000010, + 0x80001e68, 0x00000010, 0x80001e6a, 0x00000010, + 0x80001e6c, 0x00000010, 0x80001e6e, 0x00000010, + 0x80001e70, 0x00000010, 0x80001e72, 0x00000010, + 0x80001e74, 0x00000010, 0x80001e76, 0x00000010, + 0x80001e78, 0x00000010, 0x80001e7a, 0x00000010, + 0x80001e7c, 0x00000010, 0x80001e7e, 0x00000010, + 0x80001e80, 0x00000010, 0x80001e82, 0x00000010, + 0x80001e84, 0x00000010, 0x80001e86, 0x00000010, + 0x80001e88, 0x00000010, 0x80001e8a, 0x00000010, + 0x80001e8c, 0x00000010, 0x80001e8e, 0x00000010, + 0x80001e90, 0x00000010, 0x80001e92, 0x00000010, + 0x80001e94, 0x00000010, 0x00000048, 0x80000331, + 0x00000010, 0x00000054, 0x80000308, 0x00000010, + 0x00000057, 0x8000030a, 0x00000010, 0x00000059, + 0x8000030a, 0x00000010, 0x00000041, 0x800002be, + 0x00000010, 0x80001e60, 0x00000010, 0x80001ea0, + 0x00000010, 0x80001ea2, 0x00000010, 0x80001ea4, + 0x00000010, 0x80001ea6, 0x00000010, 0x80001ea8, + 0x00000010, 0x80001eaa, 0x00000010, 0x80001eac, + 0x00000010, 0x80001eae, 0x00000010, 0x80001eb0, + 0x00000010, 0x80001eb2, 0x00000010, 0x80001eb4, + 0x00000010, 0x80001eb6, 0x00000010, 0x80001eb8, + 0x00000010, 0x80001eba, 0x00000010, 0x80001ebc, + 0x00000010, 0x80001ebe, 0x00000010, 0x80001ec0, + 0x00000010, 0x80001ec2, 0x00000010, 0x80001ec4, + 0x00000010, 0x80001ec6, 0x00000010, 0x80001ec8, + 0x00000010, 0x80001eca, 0x00000010, 0x80001ecc, + 0x00000010, 0x80001ece, 0x00000010, 0x80001ed0, + 0x00000010, 0x80001ed2, 0x00000010, 0x80001ed4, + 0x00000010, 0x80001ed6, 0x00000010, 0x80001ed8, + 0x00000010, 0x80001eda, 0x00000010, 0x80001edc, + 0x00000010, 0x80001ede, 0x00000010, 0x80001ee0, + 0x00000010, 0x80001ee2, 0x00000010, 0x80001ee4, + 0x00000010, 0x80001ee6, 0x00000010, 0x80001ee8, + 0x00000010, 0x80001eea, 0x00000010, 0x80001eec, + 0x00000010, 0x80001eee, 0x00000010, 0x80001ef0, + 0x00000010, 0x80001ef2, 0x00000010, 0x80001ef4, + 0x00000010, 0x80001ef6, 0x00000010, 0x80001ef8, + 0x00000010, 0x80001f08, 0x00000010, 0x80001f09, + 0x00000010, 0x80001f0a, 0x00000010, 0x80001f0b, + 0x00000010, 0x80001f0c, 0x00000010, 0x80001f0d, + 0x00000010, 0x80001f0e, 0x00000010, 0x80001f0f, + 0x00000010, 0x80001f18, 0x00000010, 0x80001f19, + 0x00000010, 0x80001f1a, 0x00000010, 0x80001f1b, + 0x00000010, 0x80001f1c, 0x00000010, 0x80001f1d, + 0x00000010, 0x80001f28, 0x00000010, 0x80001f29, + 0x00000010, 0x80001f2a, 0x00000010, 0x80001f2b, + 0x00000010, 0x80001f2c, 0x00000010, 0x80001f2d, + 0x00000010, 0x80001f2e, 0x00000010, 0x80001f2f, + 0x00000010, 0x80001f38, 0x00000010, 0x80001f39, + 0x00000010, 0x80001f3a, 0x00000010, 0x80001f3b, + 0x00000010, 0x80001f3c, 0x00000010, 0x80001f3d, + 0x00000010, 0x80001f3e, 0x00000010, 0x80001f3f, + 0x00000010, 0x80001f48, 0x00000010, 0x80001f49, + 0x00000010, 0x80001f4a, 0x00000010, 0x80001f4b, + 0x00000010, 0x80001f4c, 0x00000010, 0x80001f4d, + 0x00000010, 0x000003a5, 0x80000313, 0x00000010, + 0x80001f59, 0x00000010, 0x000003a5, 0x00000313, + 0x80000300, 0x00000010, 0x80001f5b, 0x00000010, + 0x000003a5, 0x00000313, 0x80000301, 0x00000010, + 0x80001f5d, 0x00000010, 0x000003a5, 0x00000313, + 0x80000342, 0x00000010, 0x80001f5f, 0x00000010, + 0x80001f68, 0x00000010, 0x80001f69, 0x00000010, + 0x80001f6a, 0x00000010, 0x80001f6b, 0x00000010, + 0x80001f6c, 0x00000010, 0x80001f6d, 0x00000010, + 0x80001f6e, 0x00000010, 0x80001f6f, 0x00000010, + 0x80001fba, 0x00000010, 0x80001fbb, 0x00000010, + 0x80001fc8, 0x00000010, 0x80001fc9, 0x00000010, + 0x80001fca, 0x00000010, 0x80001fcb, 0x00000010, + 0x80001fda, 0x00000010, 0x80001fdb, 0x00000010, + 0x80001ff8, 0x00000010, 0x80001ff9, 0x00000010, + 0x80001fea, 0x00000010, 0x80001feb, 0x00000010, + 0x80001ffa, 0x00000010, 0x80001ffb, 0x00000000, + 0x00001f08, 0x80000399, 0x00000010, 0x80001f88, + 0x00000000, 0x00001f09, 0x80000399, 0x00000010, + 0x80001f89, 0x00000000, 0x00001f0a, 0x80000399, + 0x00000010, 0x80001f8a, 0x00000000, 0x00001f0b, + 0x80000399, 0x00000010, 0x80001f8b, 0x00000000, + 0x00001f0c, 0x80000399, 0x00000010, 0x80001f8c, + 0x00000000, 0x00001f0d, 0x80000399, 0x00000010, + 0x80001f8d, 0x00000000, 0x00001f0e, 0x80000399, + 0x00000010, 0x80001f8e, 0x00000000, 0x00001f0f, + 0x80000399, 0x00000010, 0x80001f8f, 0x00000010, + 0x00001f08, 0x80000399, 0x00000010, 0x00001f09, + 0x80000399, 0x00000010, 0x00001f0a, 0x80000399, + 0x00000010, 0x00001f0b, 0x80000399, 0x00000010, + 0x00001f0c, 0x80000399, 0x00000010, 0x00001f0d, + 0x80000399, 0x00000010, 0x00001f0e, 0x80000399, + 0x00000010, 0x00001f0f, 0x80000399, 0x00000000, + 0x00001f28, 0x80000399, 0x00000010, 0x80001f98, + 0x00000000, 0x00001f29, 0x80000399, 0x00000010, + 0x80001f99, 0x00000000, 0x00001f2a, 0x80000399, + 0x00000010, 0x80001f9a, 0x00000000, 0x00001f2b, + 0x80000399, 0x00000010, 0x80001f9b, 0x00000000, + 0x00001f2c, 0x80000399, 0x00000010, 0x80001f9c, + 0x00000000, 0x00001f2d, 0x80000399, 0x00000010, + 0x80001f9d, 0x00000000, 0x00001f2e, 0x80000399, + 0x00000010, 0x80001f9e, 0x00000000, 0x00001f2f, + 0x80000399, 0x00000010, 0x80001f9f, 0x00000010, + 0x00001f28, 0x80000399, 0x00000010, 0x00001f29, + 0x80000399, 0x00000010, 0x00001f2a, 0x80000399, + 0x00000010, 0x00001f2b, 0x80000399, 0x00000010, + 0x00001f2c, 0x80000399, 0x00000010, 0x00001f2d, + 0x80000399, 0x00000010, 0x00001f2e, 0x80000399, + 0x00000010, 0x00001f2f, 0x80000399, 0x00000000, + 0x00001f68, 0x80000399, 0x00000010, 0x80001fa8, + 0x00000000, 0x00001f69, 0x80000399, 0x00000010, + 0x80001fa9, 0x00000000, 0x00001f6a, 0x80000399, + 0x00000010, 0x80001faa, 0x00000000, 0x00001f6b, + 0x80000399, 0x00000010, 0x80001fab, 0x00000000, + 0x00001f6c, 0x80000399, 0x00000010, 0x80001fac, + 0x00000000, 0x00001f6d, 0x80000399, 0x00000010, + 0x80001fad, 0x00000000, 0x00001f6e, 0x80000399, + 0x00000010, 0x80001fae, 0x00000000, 0x00001f6f, + 0x80000399, 0x00000010, 0x80001faf, 0x00000010, + 0x00001f68, 0x80000399, 0x00000010, 0x00001f69, + 0x80000399, 0x00000010, 0x00001f6a, 0x80000399, + 0x00000010, 0x00001f6b, 0x80000399, 0x00000010, + 0x00001f6c, 0x80000399, 0x00000010, 0x00001f6d, + 0x80000399, 0x00000010, 0x00001f6e, 0x80000399, + 0x00000010, 0x00001f6f, 0x80000399, 0x00000010, + 0x80001fb8, 0x00000010, 0x80001fb9, 0x00000010, + 0x00001fba, 0x80000399, 0x00000000, 0x00000391, + 0x80000399, 0x00000010, 0x80001fbc, 0x00000010, + 0x00000386, 0x80000399, 0x00000010, 0x00000391, + 0x80000342, 0x00000010, 0x00000391, 0x00000342, + 0x80000399, 0x00000010, 0x00000391, 0x80000399, + 0x00000010, 0x80000399, 0x00000010, 0x00001fca, + 0x80000399, 0x00000000, 0x00000397, 0x80000399, + 0x00000010, 0x80001fcc, 0x00000010, 0x00000389, + 0x80000399, 0x00000010, 0x00000397, 0x80000342, + 0x00000010, 0x00000397, 0x00000342, 0x80000399, + 0x00000010, 0x00000397, 0x80000399, 0x00000010, + 0x80001fd8, 0x00000010, 0x80001fd9, 0x00000010, + 0x00000399, 0x00000308, 0x80000300, 0x00000010, + 0x00000399, 0x00000308, 0x80000301, 0x00000010, + 0x00000399, 0x80000342, 0x00000010, 0x00000399, + 0x00000308, 0x80000342, 0x00000010, 0x80001fe8, + 0x00000010, 0x80001fe9, 0x00000010, 0x000003a5, + 0x00000308, 0x80000300, 0x00000010, 0x000003a5, + 0x00000308, 0x80000301, 0x00000010, 0x000003a1, + 0x80000313, 0x00000010, 0x80001fec, 0x00000010, + 0x000003a5, 0x80000342, 0x00000010, 0x000003a5, + 0x00000308, 0x80000342, 0x00000010, 0x00001ffa, + 0x80000399, 0x00000000, 0x000003a9, 0x80000399, + 0x00000010, 0x80001ffc, 0x00000010, 0x0000038f, + 0x80000399, 0x00000010, 0x000003a9, 0x80000342, + 0x00000010, 0x000003a9, 0x00000342, 0x80000399, + 0x00000010, 0x000003a9, 0x80000399, 0x00000010, + 0x80002160, 0x00000010, 0x80002161, 0x00000010, + 0x80002162, 0x00000010, 0x80002163, 0x00000010, + 0x80002164, 0x00000010, 0x80002165, 0x00000010, + 0x80002166, 0x00000010, 0x80002167, 0x00000010, + 0x80002168, 0x00000010, 0x80002169, 0x00000010, + 0x8000216a, 0x00000010, 0x8000216b, 0x00000010, + 0x8000216c, 0x00000010, 0x8000216d, 0x00000010, + 0x8000216e, 0x00000010, 0x8000216f, 0x00000010, + 0x800024b6, 0x00000010, 0x800024b7, 0x00000010, + 0x800024b8, 0x00000010, 0x800024b9, 0x00000010, + 0x800024ba, 0x00000010, 0x800024bb, 0x00000010, + 0x800024bc, 0x00000010, 0x800024bd, 0x00000010, + 0x800024be, 0x00000010, 0x800024bf, 0x00000010, + 0x800024c0, 0x00000010, 0x800024c1, 0x00000010, + 0x800024c2, 0x00000010, 0x800024c3, 0x00000010, + 0x800024c4, 0x00000010, 0x800024c5, 0x00000010, + 0x800024c6, 0x00000010, 0x800024c7, 0x00000010, + 0x800024c8, 0x00000010, 0x800024c9, 0x00000010, + 0x800024ca, 0x00000010, 0x800024cb, 0x00000010, + 0x800024cc, 0x00000010, 0x800024cd, 0x00000010, + 0x800024ce, 0x00000010, 0x800024cf, 0x00000010, + 0x00000046, 0x80000046, 0x00000010, 0x00000046, + 0x80000049, 0x00000010, 0x00000046, 0x8000004c, + 0x00000010, 0x00000046, 0x00000046, 0x80000049, + 0x00000010, 0x00000046, 0x00000046, 0x8000004c, + 0x00000010, 0x00000053, 0x80000054, 0x00000010, + 0x00000053, 0x80000054, 0x00000010, 0x00000544, + 0x80000546, 0x00000010, 0x00000544, 0x80000535, + 0x00000010, 0x00000544, 0x8000053b, 0x00000010, + 0x0000054e, 0x80000546, 0x00000010, 0x00000544, + 0x8000053d, 0x00000010, 0x8000ff21, 0x00000010, + 0x8000ff22, 0x00000010, 0x8000ff23, 0x00000010, + 0x8000ff24, 0x00000010, 0x8000ff25, 0x00000010, + 0x8000ff26, 0x00000010, 0x8000ff27, 0x00000010, + 0x8000ff28, 0x00000010, 0x8000ff29, 0x00000010, + 0x8000ff2a, 0x00000010, 0x8000ff2b, 0x00000010, + 0x8000ff2c, 0x00000010, 0x8000ff2d, 0x00000010, + 0x8000ff2e, 0x00000010, 0x8000ff2f, 0x00000010, + 0x8000ff30, 0x00000010, 0x8000ff31, 0x00000010, + 0x8000ff32, 0x00000010, 0x8000ff33, 0x00000010, + 0x8000ff34, 0x00000010, 0x8000ff35, 0x00000010, + 0x8000ff36, 0x00000010, 0x8000ff37, 0x00000010, + 0x8000ff38, 0x00000010, 0x8000ff39, 0x00000010, + 0x8000ff3a, 0x00000010, 0x80010400, 0x00000010, + 0x80010401, 0x00000010, 0x80010402, 0x00000010, + 0x80010403, 0x00000010, 0x80010404, 0x00000010, + 0x80010405, 0x00000010, 0x80010406, 0x00000010, + 0x80010407, 0x00000010, 0x80010408, 0x00000010, + 0x80010409, 0x00000010, 0x8001040a, 0x00000010, + 0x8001040b, 0x00000010, 0x8001040c, 0x00000010, + 0x8001040d, 0x00000010, 0x8001040e, 0x00000010, + 0x8001040f, 0x00000010, 0x80010410, 0x00000010, + 0x80010411, 0x00000010, 0x80010412, 0x00000010, + 0x80010413, 0x00000010, 0x80010414, 0x00000010, + 0x80010415, 0x00000010, 0x80010416, 0x00000010, + 0x80010417, 0x00000010, 0x80010418, 0x00000010, + 0x80010419, 0x00000010, 0x8001041a, 0x00000010, + 0x8001041b, 0x00000010, 0x8001041c, 0x00000010, + 0x8001041d, 0x00000010, 0x8001041e, 0x00000010, + 0x8001041f, 0x00000010, 0x80010420, 0x00000010, + 0x80010421, 0x00000010, 0x80010422, 0x00000010, + 0x80010423, 0x00000010, 0x80010424, 0x00000010, + 0x80010425, +}; + +static const unsigned long v320_tolower_seq[] = { + 0x00000000, 0x00000010, 0x80000061, 0x00000010, + 0x80000062, 0x00000010, 0x80000063, 0x00000010, + 0x80000064, 0x00000010, 0x80000065, 0x00000010, + 0x80000066, 0x00000010, 0x80000067, 0x00000010, + 0x80000068, 0x00000010, 0x80000069, 0x00000010, + 0x8000006a, 0x00000010, 0x8000006b, 0x00000010, + 0x8000006c, 0x00000010, 0x8000006d, 0x00000010, + 0x8000006e, 0x00000010, 0x8000006f, 0x00000010, + 0x80000070, 0x00000010, 0x80000071, 0x00000010, + 0x80000072, 0x00000010, 0x80000073, 0x00000010, + 0x80000074, 0x00000010, 0x80000075, 0x00000010, + 0x80000076, 0x00000010, 0x80000077, 0x00000010, + 0x80000078, 0x00000010, 0x80000079, 0x00000010, + 0x8000007a, 0x00000010, 0x800000e0, 0x00000010, + 0x800000e1, 0x00000010, 0x800000e2, 0x00000010, + 0x800000e3, 0x00000010, 0x800000e4, 0x00000010, + 0x800000e5, 0x00000010, 0x800000e6, 0x00000010, + 0x800000e7, 0x00000010, 0x800000e8, 0x00000010, + 0x800000e9, 0x00000010, 0x800000ea, 0x00000010, + 0x800000eb, 0x00000010, 0x800000ec, 0x00000010, + 0x800000ed, 0x00000010, 0x800000ee, 0x00000010, + 0x800000ef, 0x00000010, 0x800000f0, 0x00000010, + 0x800000f1, 0x00000010, 0x800000f2, 0x00000010, + 0x800000f3, 0x00000010, 0x800000f4, 0x00000010, + 0x800000f5, 0x00000010, 0x800000f6, 0x00000010, + 0x800000f8, 0x00000010, 0x800000f9, 0x00000010, + 0x800000fa, 0x00000010, 0x800000fb, 0x00000010, + 0x800000fc, 0x00000010, 0x800000fd, 0x00000010, + 0x800000fe, 0x00000010, 0x80000101, 0x00000010, + 0x80000103, 0x00000010, 0x80000105, 0x00000010, + 0x80000107, 0x00000010, 0x80000109, 0x00000010, + 0x8000010b, 0x00000010, 0x8000010d, 0x00000010, + 0x8000010f, 0x00000010, 0x80000111, 0x00000010, + 0x80000113, 0x00000010, 0x80000115, 0x00000010, + 0x80000117, 0x00000010, 0x80000119, 0x00000010, + 0x8000011b, 0x00000010, 0x8000011d, 0x00000010, + 0x8000011f, 0x00000010, 0x80000121, 0x00000010, + 0x80000123, 0x00000010, 0x80000125, 0x00000010, + 0x80000127, 0x00000010, 0x80000129, 0x00000010, + 0x8000012b, 0x00000010, 0x8000012d, 0x00000010, + 0x8000012f, 0x00000000, 0x80000069, 0x00000010, + 0x80000069, 0x00000010, 0x80000133, 0x00000010, + 0x80000135, 0x00000010, 0x80000137, 0x00000010, + 0x8000013a, 0x00000010, 0x8000013c, 0x00000010, + 0x8000013e, 0x00000010, 0x80000140, 0x00000010, + 0x80000142, 0x00000010, 0x80000144, 0x00000010, + 0x80000146, 0x00000010, 0x80000148, 0x00000010, + 0x8000014b, 0x00000010, 0x8000014d, 0x00000010, + 0x8000014f, 0x00000010, 0x80000151, 0x00000010, + 0x80000153, 0x00000010, 0x80000155, 0x00000010, + 0x80000157, 0x00000010, 0x80000159, 0x00000010, + 0x8000015b, 0x00000010, 0x8000015d, 0x00000010, + 0x8000015f, 0x00000010, 0x80000161, 0x00000010, + 0x80000163, 0x00000010, 0x80000165, 0x00000010, + 0x80000167, 0x00000010, 0x80000169, 0x00000010, + 0x8000016b, 0x00000010, 0x8000016d, 0x00000010, + 0x8000016f, 0x00000010, 0x80000171, 0x00000010, + 0x80000173, 0x00000010, 0x80000175, 0x00000010, + 0x80000177, 0x00000010, 0x800000ff, 0x00000010, + 0x8000017a, 0x00000010, 0x8000017c, 0x00000010, + 0x8000017e, 0x00000010, 0x80000253, 0x00000010, + 0x80000183, 0x00000010, 0x80000185, 0x00000010, + 0x80000254, 0x00000010, 0x80000188, 0x00000010, + 0x80000256, 0x00000010, 0x80000257, 0x00000010, + 0x8000018c, 0x00000010, 0x800001dd, 0x00000010, + 0x80000259, 0x00000010, 0x8000025b, 0x00000010, + 0x80000192, 0x00000010, 0x80000260, 0x00000010, + 0x80000263, 0x00000010, 0x80000269, 0x00000010, + 0x80000268, 0x00000010, 0x80000199, 0x00000010, + 0x8000026f, 0x00000010, 0x80000272, 0x00000010, + 0x80000275, 0x00000010, 0x800001a1, 0x00000010, + 0x800001a3, 0x00000010, 0x800001a5, 0x00000010, + 0x80000280, 0x00000010, 0x800001a8, 0x00000010, + 0x80000283, 0x00000010, 0x800001ad, 0x00000010, + 0x80000288, 0x00000010, 0x800001b0, 0x00000010, + 0x8000028a, 0x00000010, 0x8000028b, 0x00000010, + 0x800001b4, 0x00000010, 0x800001b6, 0x00000010, + 0x80000292, 0x00000010, 0x800001b9, 0x00000010, + 0x800001bd, 0x00000010, 0x800001c6, 0x00000010, + 0x800001c6, 0x00000010, 0x800001c9, 0x00000010, + 0x800001c9, 0x00000010, 0x800001cc, 0x00000010, + 0x800001cc, 0x00000010, 0x800001ce, 0x00000010, + 0x800001d0, 0x00000010, 0x800001d2, 0x00000010, + 0x800001d4, 0x00000010, 0x800001d6, 0x00000010, + 0x800001d8, 0x00000010, 0x800001da, 0x00000010, + 0x800001dc, 0x00000010, 0x800001df, 0x00000010, + 0x800001e1, 0x00000010, 0x800001e3, 0x00000010, + 0x800001e5, 0x00000010, 0x800001e7, 0x00000010, + 0x800001e9, 0x00000010, 0x800001eb, 0x00000010, + 0x800001ed, 0x00000010, 0x800001ef, 0x00000010, + 0x800001f3, 0x00000010, 0x800001f3, 0x00000010, + 0x800001f5, 0x00000010, 0x80000195, 0x00000010, + 0x800001bf, 0x00000010, 0x800001f9, 0x00000010, + 0x800001fb, 0x00000010, 0x800001fd, 0x00000010, + 0x800001ff, 0x00000010, 0x80000201, 0x00000010, + 0x80000203, 0x00000010, 0x80000205, 0x00000010, + 0x80000207, 0x00000010, 0x80000209, 0x00000010, + 0x8000020b, 0x00000010, 0x8000020d, 0x00000010, + 0x8000020f, 0x00000010, 0x80000211, 0x00000010, + 0x80000213, 0x00000010, 0x80000215, 0x00000010, + 0x80000217, 0x00000010, 0x80000219, 0x00000010, + 0x8000021b, 0x00000010, 0x8000021d, 0x00000010, + 0x8000021f, 0x00000010, 0x8000019e, 0x00000010, + 0x80000223, 0x00000010, 0x80000225, 0x00000010, + 0x80000227, 0x00000010, 0x80000229, 0x00000010, + 0x8000022b, 0x00000010, 0x8000022d, 0x00000010, + 0x8000022f, 0x00000010, 0x80000231, 0x00000010, + 0x80000233, 0x00000010, 0x800003ac, 0x00000010, + 0x800003ad, 0x00000010, 0x800003ae, 0x00000010, + 0x800003af, 0x00000010, 0x800003cc, 0x00000010, + 0x800003cd, 0x00000010, 0x800003ce, 0x00000010, + 0x800003b1, 0x00000010, 0x800003b2, 0x00000010, + 0x800003b3, 0x00000010, 0x800003b4, 0x00000010, + 0x800003b5, 0x00000010, 0x800003b6, 0x00000010, + 0x800003b7, 0x00000010, 0x800003b8, 0x00000010, + 0x800003b9, 0x00000010, 0x800003ba, 0x00000010, + 0x800003bb, 0x00000010, 0x800003bc, 0x00000010, + 0x800003bd, 0x00000010, 0x800003be, 0x00000010, + 0x800003bf, 0x00000010, 0x800003c0, 0x00000010, + 0x800003c1, 0x00000010, 0x800003c3, 0x00000010, + 0x800003c4, 0x00000010, 0x800003c5, 0x00000010, + 0x800003c6, 0x00000010, 0x800003c7, 0x00000010, + 0x800003c8, 0x00000010, 0x800003c9, 0x00000010, + 0x800003ca, 0x00000010, 0x800003cb, 0x00000010, + 0x800003d9, 0x00000010, 0x800003db, 0x00000010, + 0x800003dd, 0x00000010, 0x800003df, 0x00000010, + 0x800003e1, 0x00000010, 0x800003e3, 0x00000010, + 0x800003e5, 0x00000010, 0x800003e7, 0x00000010, + 0x800003e9, 0x00000010, 0x800003eb, 0x00000010, + 0x800003ed, 0x00000010, 0x800003ef, 0x00000010, + 0x800003b8, 0x00000010, 0x80000450, 0x00000010, + 0x80000451, 0x00000010, 0x80000452, 0x00000010, + 0x80000453, 0x00000010, 0x80000454, 0x00000010, + 0x80000455, 0x00000010, 0x80000456, 0x00000010, + 0x80000457, 0x00000010, 0x80000458, 0x00000010, + 0x80000459, 0x00000010, 0x8000045a, 0x00000010, + 0x8000045b, 0x00000010, 0x8000045c, 0x00000010, + 0x8000045d, 0x00000010, 0x8000045e, 0x00000010, + 0x8000045f, 0x00000010, 0x80000430, 0x00000010, + 0x80000431, 0x00000010, 0x80000432, 0x00000010, + 0x80000433, 0x00000010, 0x80000434, 0x00000010, + 0x80000435, 0x00000010, 0x80000436, 0x00000010, + 0x80000437, 0x00000010, 0x80000438, 0x00000010, + 0x80000439, 0x00000010, 0x8000043a, 0x00000010, + 0x8000043b, 0x00000010, 0x8000043c, 0x00000010, + 0x8000043d, 0x00000010, 0x8000043e, 0x00000010, + 0x8000043f, 0x00000010, 0x80000440, 0x00000010, + 0x80000441, 0x00000010, 0x80000442, 0x00000010, + 0x80000443, 0x00000010, 0x80000444, 0x00000010, + 0x80000445, 0x00000010, 0x80000446, 0x00000010, + 0x80000447, 0x00000010, 0x80000448, 0x00000010, + 0x80000449, 0x00000010, 0x8000044a, 0x00000010, + 0x8000044b, 0x00000010, 0x8000044c, 0x00000010, + 0x8000044d, 0x00000010, 0x8000044e, 0x00000010, + 0x8000044f, 0x00000010, 0x80000461, 0x00000010, + 0x80000463, 0x00000010, 0x80000465, 0x00000010, + 0x80000467, 0x00000010, 0x80000469, 0x00000010, + 0x8000046b, 0x00000010, 0x8000046d, 0x00000010, + 0x8000046f, 0x00000010, 0x80000471, 0x00000010, + 0x80000473, 0x00000010, 0x80000475, 0x00000010, + 0x80000477, 0x00000010, 0x80000479, 0x00000010, + 0x8000047b, 0x00000010, 0x8000047d, 0x00000010, + 0x8000047f, 0x00000010, 0x80000481, 0x00000010, + 0x8000048b, 0x00000010, 0x8000048d, 0x00000010, + 0x8000048f, 0x00000010, 0x80000491, 0x00000010, + 0x80000493, 0x00000010, 0x80000495, 0x00000010, + 0x80000497, 0x00000010, 0x80000499, 0x00000010, + 0x8000049b, 0x00000010, 0x8000049d, 0x00000010, + 0x8000049f, 0x00000010, 0x800004a1, 0x00000010, + 0x800004a3, 0x00000010, 0x800004a5, 0x00000010, + 0x800004a7, 0x00000010, 0x800004a9, 0x00000010, + 0x800004ab, 0x00000010, 0x800004ad, 0x00000010, + 0x800004af, 0x00000010, 0x800004b1, 0x00000010, + 0x800004b3, 0x00000010, 0x800004b5, 0x00000010, + 0x800004b7, 0x00000010, 0x800004b9, 0x00000010, + 0x800004bb, 0x00000010, 0x800004bd, 0x00000010, + 0x800004bf, 0x00000010, 0x800004c2, 0x00000010, + 0x800004c4, 0x00000010, 0x800004c6, 0x00000010, + 0x800004c8, 0x00000010, 0x800004ca, 0x00000010, + 0x800004cc, 0x00000010, 0x800004ce, 0x00000010, + 0x800004d1, 0x00000010, 0x800004d3, 0x00000010, + 0x800004d5, 0x00000010, 0x800004d7, 0x00000010, + 0x800004d9, 0x00000010, 0x800004db, 0x00000010, + 0x800004dd, 0x00000010, 0x800004df, 0x00000010, + 0x800004e1, 0x00000010, 0x800004e3, 0x00000010, + 0x800004e5, 0x00000010, 0x800004e7, 0x00000010, + 0x800004e9, 0x00000010, 0x800004eb, 0x00000010, + 0x800004ed, 0x00000010, 0x800004ef, 0x00000010, + 0x800004f1, 0x00000010, 0x800004f3, 0x00000010, + 0x800004f5, 0x00000010, 0x800004f9, 0x00000010, + 0x80000501, 0x00000010, 0x80000503, 0x00000010, + 0x80000505, 0x00000010, 0x80000507, 0x00000010, + 0x80000509, 0x00000010, 0x8000050b, 0x00000010, + 0x8000050d, 0x00000010, 0x8000050f, 0x00000010, + 0x80000561, 0x00000010, 0x80000562, 0x00000010, + 0x80000563, 0x00000010, 0x80000564, 0x00000010, + 0x80000565, 0x00000010, 0x80000566, 0x00000010, + 0x80000567, 0x00000010, 0x80000568, 0x00000010, + 0x80000569, 0x00000010, 0x8000056a, 0x00000010, + 0x8000056b, 0x00000010, 0x8000056c, 0x00000010, + 0x8000056d, 0x00000010, 0x8000056e, 0x00000010, + 0x8000056f, 0x00000010, 0x80000570, 0x00000010, + 0x80000571, 0x00000010, 0x80000572, 0x00000010, + 0x80000573, 0x00000010, 0x80000574, 0x00000010, + 0x80000575, 0x00000010, 0x80000576, 0x00000010, + 0x80000577, 0x00000010, 0x80000578, 0x00000010, + 0x80000579, 0x00000010, 0x8000057a, 0x00000010, + 0x8000057b, 0x00000010, 0x8000057c, 0x00000010, + 0x8000057d, 0x00000010, 0x8000057e, 0x00000010, + 0x8000057f, 0x00000010, 0x80000580, 0x00000010, + 0x80000581, 0x00000010, 0x80000582, 0x00000010, + 0x80000583, 0x00000010, 0x80000584, 0x00000010, + 0x80000585, 0x00000010, 0x80000586, 0x00000010, + 0x80001e01, 0x00000010, 0x80001e03, 0x00000010, + 0x80001e05, 0x00000010, 0x80001e07, 0x00000010, + 0x80001e09, 0x00000010, 0x80001e0b, 0x00000010, + 0x80001e0d, 0x00000010, 0x80001e0f, 0x00000010, + 0x80001e11, 0x00000010, 0x80001e13, 0x00000010, + 0x80001e15, 0x00000010, 0x80001e17, 0x00000010, + 0x80001e19, 0x00000010, 0x80001e1b, 0x00000010, + 0x80001e1d, 0x00000010, 0x80001e1f, 0x00000010, + 0x80001e21, 0x00000010, 0x80001e23, 0x00000010, + 0x80001e25, 0x00000010, 0x80001e27, 0x00000010, + 0x80001e29, 0x00000010, 0x80001e2b, 0x00000010, + 0x80001e2d, 0x00000010, 0x80001e2f, 0x00000010, + 0x80001e31, 0x00000010, 0x80001e33, 0x00000010, + 0x80001e35, 0x00000010, 0x80001e37, 0x00000010, + 0x80001e39, 0x00000010, 0x80001e3b, 0x00000010, + 0x80001e3d, 0x00000010, 0x80001e3f, 0x00000010, + 0x80001e41, 0x00000010, 0x80001e43, 0x00000010, + 0x80001e45, 0x00000010, 0x80001e47, 0x00000010, + 0x80001e49, 0x00000010, 0x80001e4b, 0x00000010, + 0x80001e4d, 0x00000010, 0x80001e4f, 0x00000010, + 0x80001e51, 0x00000010, 0x80001e53, 0x00000010, + 0x80001e55, 0x00000010, 0x80001e57, 0x00000010, + 0x80001e59, 0x00000010, 0x80001e5b, 0x00000010, + 0x80001e5d, 0x00000010, 0x80001e5f, 0x00000010, + 0x80001e61, 0x00000010, 0x80001e63, 0x00000010, + 0x80001e65, 0x00000010, 0x80001e67, 0x00000010, + 0x80001e69, 0x00000010, 0x80001e6b, 0x00000010, + 0x80001e6d, 0x00000010, 0x80001e6f, 0x00000010, + 0x80001e71, 0x00000010, 0x80001e73, 0x00000010, + 0x80001e75, 0x00000010, 0x80001e77, 0x00000010, + 0x80001e79, 0x00000010, 0x80001e7b, 0x00000010, + 0x80001e7d, 0x00000010, 0x80001e7f, 0x00000010, + 0x80001e81, 0x00000010, 0x80001e83, 0x00000010, + 0x80001e85, 0x00000010, 0x80001e87, 0x00000010, + 0x80001e89, 0x00000010, 0x80001e8b, 0x00000010, + 0x80001e8d, 0x00000010, 0x80001e8f, 0x00000010, + 0x80001e91, 0x00000010, 0x80001e93, 0x00000010, + 0x80001e95, 0x00000010, 0x80001ea1, 0x00000010, + 0x80001ea3, 0x00000010, 0x80001ea5, 0x00000010, + 0x80001ea7, 0x00000010, 0x80001ea9, 0x00000010, + 0x80001eab, 0x00000010, 0x80001ead, 0x00000010, + 0x80001eaf, 0x00000010, 0x80001eb1, 0x00000010, + 0x80001eb3, 0x00000010, 0x80001eb5, 0x00000010, + 0x80001eb7, 0x00000010, 0x80001eb9, 0x00000010, + 0x80001ebb, 0x00000010, 0x80001ebd, 0x00000010, + 0x80001ebf, 0x00000010, 0x80001ec1, 0x00000010, + 0x80001ec3, 0x00000010, 0x80001ec5, 0x00000010, + 0x80001ec7, 0x00000010, 0x80001ec9, 0x00000010, + 0x80001ecb, 0x00000010, 0x80001ecd, 0x00000010, + 0x80001ecf, 0x00000010, 0x80001ed1, 0x00000010, + 0x80001ed3, 0x00000010, 0x80001ed5, 0x00000010, + 0x80001ed7, 0x00000010, 0x80001ed9, 0x00000010, + 0x80001edb, 0x00000010, 0x80001edd, 0x00000010, + 0x80001edf, 0x00000010, 0x80001ee1, 0x00000010, + 0x80001ee3, 0x00000010, 0x80001ee5, 0x00000010, + 0x80001ee7, 0x00000010, 0x80001ee9, 0x00000010, + 0x80001eeb, 0x00000010, 0x80001eed, 0x00000010, + 0x80001eef, 0x00000010, 0x80001ef1, 0x00000010, + 0x80001ef3, 0x00000010, 0x80001ef5, 0x00000010, + 0x80001ef7, 0x00000010, 0x80001ef9, 0x00000010, + 0x80001f00, 0x00000010, 0x80001f01, 0x00000010, + 0x80001f02, 0x00000010, 0x80001f03, 0x00000010, + 0x80001f04, 0x00000010, 0x80001f05, 0x00000010, + 0x80001f06, 0x00000010, 0x80001f07, 0x00000010, + 0x80001f10, 0x00000010, 0x80001f11, 0x00000010, + 0x80001f12, 0x00000010, 0x80001f13, 0x00000010, + 0x80001f14, 0x00000010, 0x80001f15, 0x00000010, + 0x80001f20, 0x00000010, 0x80001f21, 0x00000010, + 0x80001f22, 0x00000010, 0x80001f23, 0x00000010, + 0x80001f24, 0x00000010, 0x80001f25, 0x00000010, + 0x80001f26, 0x00000010, 0x80001f27, 0x00000010, + 0x80001f30, 0x00000010, 0x80001f31, 0x00000010, + 0x80001f32, 0x00000010, 0x80001f33, 0x00000010, + 0x80001f34, 0x00000010, 0x80001f35, 0x00000010, + 0x80001f36, 0x00000010, 0x80001f37, 0x00000010, + 0x80001f40, 0x00000010, 0x80001f41, 0x00000010, + 0x80001f42, 0x00000010, 0x80001f43, 0x00000010, + 0x80001f44, 0x00000010, 0x80001f45, 0x00000010, + 0x80001f51, 0x00000010, 0x80001f53, 0x00000010, + 0x80001f55, 0x00000010, 0x80001f57, 0x00000010, + 0x80001f60, 0x00000010, 0x80001f61, 0x00000010, + 0x80001f62, 0x00000010, 0x80001f63, 0x00000010, + 0x80001f64, 0x00000010, 0x80001f65, 0x00000010, + 0x80001f66, 0x00000010, 0x80001f67, 0x00000000, + 0x80001f80, 0x00000010, 0x80001f80, 0x00000000, + 0x80001f81, 0x00000010, 0x80001f81, 0x00000000, + 0x80001f82, 0x00000010, 0x80001f82, 0x00000000, + 0x80001f83, 0x00000010, 0x80001f83, 0x00000000, + 0x80001f84, 0x00000010, 0x80001f84, 0x00000000, + 0x80001f85, 0x00000010, 0x80001f85, 0x00000000, + 0x80001f86, 0x00000010, 0x80001f86, 0x00000000, + 0x80001f87, 0x00000010, 0x80001f87, 0x00000000, + 0x80001f90, 0x00000010, 0x80001f90, 0x00000000, + 0x80001f91, 0x00000010, 0x80001f91, 0x00000000, + 0x80001f92, 0x00000010, 0x80001f92, 0x00000000, + 0x80001f93, 0x00000010, 0x80001f93, 0x00000000, + 0x80001f94, 0x00000010, 0x80001f94, 0x00000000, + 0x80001f95, 0x00000010, 0x80001f95, 0x00000000, + 0x80001f96, 0x00000010, 0x80001f96, 0x00000000, + 0x80001f97, 0x00000010, 0x80001f97, 0x00000000, + 0x80001fa0, 0x00000010, 0x80001fa0, 0x00000000, + 0x80001fa1, 0x00000010, 0x80001fa1, 0x00000000, + 0x80001fa2, 0x00000010, 0x80001fa2, 0x00000000, + 0x80001fa3, 0x00000010, 0x80001fa3, 0x00000000, + 0x80001fa4, 0x00000010, 0x80001fa4, 0x00000000, + 0x80001fa5, 0x00000010, 0x80001fa5, 0x00000000, + 0x80001fa6, 0x00000010, 0x80001fa6, 0x00000000, + 0x80001fa7, 0x00000010, 0x80001fa7, 0x00000010, + 0x80001fb0, 0x00000010, 0x80001fb1, 0x00000010, + 0x80001f70, 0x00000010, 0x80001f71, 0x00000000, + 0x80001fb3, 0x00000010, 0x80001fb3, 0x00000010, + 0x80001f72, 0x00000010, 0x80001f73, 0x00000010, + 0x80001f74, 0x00000010, 0x80001f75, 0x00000000, + 0x80001fc3, 0x00000010, 0x80001fc3, 0x00000010, + 0x80001fd0, 0x00000010, 0x80001fd1, 0x00000010, + 0x80001f76, 0x00000010, 0x80001f77, 0x00000010, + 0x80001fe0, 0x00000010, 0x80001fe1, 0x00000010, + 0x80001f7a, 0x00000010, 0x80001f7b, 0x00000010, + 0x80001fe5, 0x00000010, 0x80001f78, 0x00000010, + 0x80001f79, 0x00000010, 0x80001f7c, 0x00000010, + 0x80001f7d, 0x00000000, 0x80001ff3, 0x00000010, + 0x80001ff3, 0x00000010, 0x800003c9, 0x00000010, + 0x8000006b, 0x00000010, 0x800000e5, 0x00000010, + 0x80002170, 0x00000010, 0x80002171, 0x00000010, + 0x80002172, 0x00000010, 0x80002173, 0x00000010, + 0x80002174, 0x00000010, 0x80002175, 0x00000010, + 0x80002176, 0x00000010, 0x80002177, 0x00000010, + 0x80002178, 0x00000010, 0x80002179, 0x00000010, + 0x8000217a, 0x00000010, 0x8000217b, 0x00000010, + 0x8000217c, 0x00000010, 0x8000217d, 0x00000010, + 0x8000217e, 0x00000010, 0x8000217f, 0x00000010, + 0x800024d0, 0x00000010, 0x800024d1, 0x00000010, + 0x800024d2, 0x00000010, 0x800024d3, 0x00000010, + 0x800024d4, 0x00000010, 0x800024d5, 0x00000010, + 0x800024d6, 0x00000010, 0x800024d7, 0x00000010, + 0x800024d8, 0x00000010, 0x800024d9, 0x00000010, + 0x800024da, 0x00000010, 0x800024db, 0x00000010, + 0x800024dc, 0x00000010, 0x800024dd, 0x00000010, + 0x800024de, 0x00000010, 0x800024df, 0x00000010, + 0x800024e0, 0x00000010, 0x800024e1, 0x00000010, + 0x800024e2, 0x00000010, 0x800024e3, 0x00000010, + 0x800024e4, 0x00000010, 0x800024e5, 0x00000010, + 0x800024e6, 0x00000010, 0x800024e7, 0x00000010, + 0x800024e8, 0x00000010, 0x800024e9, 0x00000010, + 0x8000ff41, 0x00000010, 0x8000ff42, 0x00000010, + 0x8000ff43, 0x00000010, 0x8000ff44, 0x00000010, + 0x8000ff45, 0x00000010, 0x8000ff46, 0x00000010, + 0x8000ff47, 0x00000010, 0x8000ff48, 0x00000010, + 0x8000ff49, 0x00000010, 0x8000ff4a, 0x00000010, + 0x8000ff4b, 0x00000010, 0x8000ff4c, 0x00000010, + 0x8000ff4d, 0x00000010, 0x8000ff4e, 0x00000010, + 0x8000ff4f, 0x00000010, 0x8000ff50, 0x00000010, + 0x8000ff51, 0x00000010, 0x8000ff52, 0x00000010, + 0x8000ff53, 0x00000010, 0x8000ff54, 0x00000010, + 0x8000ff55, 0x00000010, 0x8000ff56, 0x00000010, + 0x8000ff57, 0x00000010, 0x8000ff58, 0x00000010, + 0x8000ff59, 0x00000010, 0x8000ff5a, 0x00000010, + 0x80010428, 0x00000010, 0x80010429, 0x00000010, + 0x8001042a, 0x00000010, 0x8001042b, 0x00000010, + 0x8001042c, 0x00000010, 0x8001042d, 0x00000010, + 0x8001042e, 0x00000010, 0x8001042f, 0x00000010, + 0x80010430, 0x00000010, 0x80010431, 0x00000010, + 0x80010432, 0x00000010, 0x80010433, 0x00000010, + 0x80010434, 0x00000010, 0x80010435, 0x00000010, + 0x80010436, 0x00000010, 0x80010437, 0x00000010, + 0x80010438, 0x00000010, 0x80010439, 0x00000010, + 0x8001043a, 0x00000010, 0x8001043b, 0x00000010, + 0x8001043c, 0x00000010, 0x8001043d, 0x00000010, + 0x8001043e, 0x00000010, 0x8001043f, 0x00000010, + 0x80010440, 0x00000010, 0x80010441, 0x00000010, + 0x80010442, 0x00000010, 0x80010443, 0x00000010, + 0x80010444, 0x00000010, 0x80010445, 0x00000010, + 0x80010446, 0x00000010, 0x80010447, 0x00000010, + 0x80010448, 0x00000010, 0x80010449, 0x00000010, + 0x8001044a, 0x00000010, 0x8001044b, 0x00000010, + 0x8001044c, 0x00000010, 0x8001044d, +}; + + +/* + * Cased characters and non-spacing marks (for casemap context) + */ + +#define CASEMAP_CTX_BITS_0 9 +#define CASEMAP_CTX_BITS_1 7 +#define CASEMAP_CTX_BITS_2 5 + +#define CTX_CASED 1 +#define CTX_NSM 2 + +static const unsigned short v320_casemap_ctx_imap[] = { + 272, 400, 528, 656, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 912, + 1040, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 1168, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 784, 784, 784, 784, 784, 784, 784, 784, + 0, 0, 1, 1, 0, 2, 3, 3, + 4, 4, 4, 4, 4, 5, 6, 4, + 4, 7, 8, 4, 4, 9, 0, 0, + 10, 10, 11, 11, 12, 13, 14, 15, + 4, 4, 4, 4, 16, 4, 14, 17, + 18, 19, 20, 21, 22, 23, 24, 0, + 0, 0, 25, 26, 0, 0, 27, 28, + 29, 30, 31, 0, 0, 32, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 33, 34, 35, 36, 37, 34, 38, 36, + 39, 34, 40, 41, 33, 34, 42, 0, + 37, 43, 44, 0, 39, 0, 45, 0, + 0, 46, 47, 0, 0, 48, 49, 0, + 0, 0, 50, 0, 0, 0, 51, 0, + 0, 52, 53, 0, 0, 54, 55, 0, + 56, 57, 0, 58, 59, 60, 61, 0, + 0, 62, 56, 0, 0, 4, 63, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 64, 64, 65, 65, 0, 66, 67, 0, + 68, 0, 0, 0, 0, 69, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 4, 4, 4, 4, 70, 4, 4, 71, + 72, 4, 73, 74, 4, 75, 76, 77, + 0, 0, 0, 78, 0, 0, 79, 80, + 81, 82, 83, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 84, 0, 0, 85, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 86, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 11, 87, 0, 0, 0, 0, 0, 0, + 0, 1, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 4, 88, 9, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 89, 90, 91, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 4, 4, 92, 4, 93, 94, 95, 4, + 96, 97, 98, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 99, 100, 5, + 92, 92, 14, 14, 101, 101, 102, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, +}; + +static const struct { + unsigned char tbl[32]; +} v320_casemap_ctx_table[] = { + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, + }}, + {{ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, + }}, + {{ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + }}, + {{ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, + }}, + {{ + 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + }}, + {{ + 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + }}, + {{ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + }}, + {{ + 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + }}, + {{ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + }}, + {{ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 1, 1, 0, 2, 2, 2, 2, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + }}, + {{ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, + }}, + {{ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + }}, + {{ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + }}, + {{ + 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + }}, + {{ + 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 0, 2, + }}, + {{ + 0, 2, 2, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 0, 0, 2, + }}, + {{ + 2, 2, 2, 2, 2, 0, 0, 2, 2, 0, 2, 2, 2, 2, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, + }}, + {{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 2, 0, 0, 0, + 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 2, 2, 0, 0, 0, 0, 2, 2, 0, 0, 2, 2, 2, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, + 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 2, 2, 2, 2, 2, 0, 2, 2, 0, 0, 0, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 2, + }}, + {{ + 0, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, + }}, + {{ + 2, 0, 0, 0, 0, 0, 2, 2, 2, 0, 2, 2, 2, 2, 0, 0, 0, + 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, + }}, + {{ + 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, + 0, 2, 2, 2, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 2, 0, 0, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 2, 0, 0, 2, 2, 2, 2, 2, 2, 0, 2, 2, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 2, 0, 2, 0, 2, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, + }}, + {{ + 2, 2, 2, 2, 2, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 2, + 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, + }}, + {{ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, + 0, 2, 0, 0, 0, 2, 2, 0, 2, 0, 0, 0, 0, 0, 0, + }}, + {{ + 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 2, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, + }}, + {{ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, + }}, + {{ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, + }}, + {{ + 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, + 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, + }}, + {{ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, + }}, + {{ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, + }}, + {{ + 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, + 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, + }}, + {{ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, + 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, + }}, + {{ + 0, 2, 0, 0, 0, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, + }}, + {{ + 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, + 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, + }}, + {{ + 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, + }}, + {{ + 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 2, 0, + }}, + {{ + 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, + }}, + {{ + 2, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + }}, + {{ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, + }}, + {{ + 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, + }}, + {{ + 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + }}, + {{ + 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, + 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, + }}, + {{ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, + }}, + {{ + 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + }}, + {{ + 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + }}, + {{ + 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, + }}, + {{ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + }}, + {{ + 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, +}; + +/* + * Case Folding + */ + +#define CASE_FOLDING_BITS_0 9 +#define CASE_FOLDING_BITS_1 7 +#define CASE_FOLDING_BITS_2 5 + +static const unsigned short v320_case_folding_imap[] = { + 272, 400, 528, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 784, + 912, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 656, 656, 656, 656, 656, 656, 656, 656, + 0, 0, 1, 0, 0, 2, 3, 0, + 4, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 0, 0, 0, 0, 0, 0, + 0, 0, 14, 0, 15, 16, 17, 18, + 19, 20, 0, 21, 22, 23, 24, 25, + 26, 27, 28, 0, 29, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 30, 31, 32, 33, 34, 35, 36, 37, + 38, 39, 40, 41, 42, 43, 44, 45, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 46, 0, 47, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 48, 49, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 50, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 51, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 52, 53, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, +}; + +static const struct { + unsigned short tbl[32]; +} v320_case_folding_table[] = { + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, + 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, + 23, 24, 25, 26, 27, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 28, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, + 51, 0, 52, 53, 54, 55, 56, 57, 58, 59, + }}, + {{ + 61, 0, 62, 0, 63, 0, 64, 0, 65, 0, 66, + 0, 67, 0, 68, 0, 69, 0, 70, 0, 71, 0, + 72, 0, 73, 0, 74, 0, 75, 0, 76, 0, + }}, + {{ + 77, 0, 78, 0, 79, 0, 80, 0, 81, 0, 82, + 0, 83, 0, 84, 0, 87, 0, 88, 0, 89, 0, + 90, 0, 0, 91, 0, 92, 0, 93, 0, 94, + }}, + {{ + 0, 95, 0, 96, 0, 97, 0, 98, 0, 99, 101, + 0, 102, 0, 103, 0, 104, 0, 105, 0, 106, 0, + 107, 0, 108, 0, 109, 0, 110, 0, 111, 0, + }}, + {{ + 112, 0, 113, 0, 114, 0, 115, 0, 116, 0, 117, + 0, 118, 0, 119, 0, 120, 0, 121, 0, 122, 0, + 123, 0, 124, 125, 0, 126, 0, 127, 0, 128, + }}, + {{ + 0, 129, 130, 0, 131, 0, 132, 133, 0, 134, 135, + 136, 0, 0, 137, 138, 139, 140, 0, 141, 142, 0, + 143, 144, 145, 0, 0, 0, 146, 147, 0, 148, + }}, + {{ + 149, 0, 150, 0, 151, 0, 152, 153, 0, 154, 0, + 0, 155, 0, 156, 157, 0, 158, 159, 160, 0, 161, + 0, 162, 163, 0, 0, 0, 164, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 165, 166, 0, 167, 168, 0, 169, + 170, 0, 171, 0, 172, 0, 173, 0, 174, 0, 175, + 0, 176, 0, 177, 0, 178, 0, 0, 179, 0, + }}, + {{ + 180, 0, 181, 0, 182, 0, 183, 0, 184, 0, 185, + 0, 186, 0, 187, 0, 188, 190, 191, 0, 192, 0, + 193, 194, 195, 0, 196, 0, 197, 0, 198, 0, + }}, + {{ + 199, 0, 200, 0, 201, 0, 202, 0, 203, 0, 204, + 0, 205, 0, 206, 0, 207, 0, 208, 0, 209, 0, + 210, 0, 211, 0, 212, 0, 213, 0, 214, 0, + }}, + {{ + 215, 0, 216, 0, 217, 0, 218, 0, 219, 0, 220, + 0, 221, 0, 222, 0, 223, 0, 224, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 225, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 226, 0, 227, 228, 229, + 0, 230, 0, 231, 232, 233, 236, 237, 238, 239, 240, + 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, + }}, + {{ + 251, 252, 0, 253, 254, 255, 256, 257, 258, 259, 260, + 261, 0, 0, 0, 0, 262, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 265, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 266, 267, 0, 0, 0, 268, + 269, 0, 270, 0, 271, 0, 272, 0, 273, 0, + }}, + {{ + 274, 0, 275, 0, 276, 0, 277, 0, 278, 0, 279, + 0, 280, 0, 281, 0, 282, 283, 284, 0, 285, 286, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, + 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, + 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, + }}, + {{ + 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, + 330, 331, 332, 333, 334, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 335, 0, 336, 0, 337, 0, 338, 0, 339, 0, 340, + 0, 341, 0, 342, 0, 343, 0, 344, 0, 345, 0, + 346, 0, 347, 0, 348, 0, 349, 0, 350, 0, + }}, + {{ + 351, 0, 0, 0, 0, 0, 0, 0, 0, 0, 352, + 0, 353, 0, 354, 0, 355, 0, 356, 0, 357, 0, + 358, 0, 359, 0, 360, 0, 361, 0, 362, 0, + }}, + {{ + 363, 0, 364, 0, 365, 0, 366, 0, 367, 0, 368, + 0, 369, 0, 370, 0, 371, 0, 372, 0, 373, 0, + 374, 0, 375, 0, 376, 0, 377, 0, 378, 0, + }}, + {{ + 0, 379, 0, 380, 0, 381, 0, 382, 0, 383, 0, + 384, 0, 385, 0, 0, 386, 0, 387, 0, 388, 0, + 389, 0, 390, 0, 391, 0, 392, 0, 393, 0, + }}, + {{ + 394, 0, 395, 0, 396, 0, 397, 0, 398, 0, 399, + 0, 400, 0, 401, 0, 402, 0, 403, 0, 404, 0, + 0, 0, 405, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 406, 0, 407, 0, 408, 0, 409, 0, 410, 0, 411, + 0, 412, 0, 413, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 414, 415, 416, 417, 418, + 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, + }}, + {{ + 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, + 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, + 451, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 452, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 454, 0, 455, 0, 456, 0, 457, 0, 458, 0, 459, + 0, 460, 0, 461, 0, 462, 0, 463, 0, 464, 0, + 465, 0, 466, 0, 467, 0, 468, 0, 469, 0, + }}, + {{ + 470, 0, 471, 0, 472, 0, 473, 0, 474, 0, 475, + 0, 476, 0, 477, 0, 478, 0, 479, 0, 480, 0, + 481, 0, 482, 0, 483, 0, 484, 0, 485, 0, + }}, + {{ + 486, 0, 487, 0, 488, 0, 489, 0, 490, 0, 491, + 0, 492, 0, 493, 0, 494, 0, 495, 0, 496, 0, + 497, 0, 498, 0, 499, 0, 500, 0, 501, 0, + }}, + {{ + 502, 0, 503, 0, 504, 0, 505, 0, 506, 0, 507, + 0, 508, 0, 509, 0, 510, 0, 511, 0, 512, 0, + 513, 0, 514, 0, 515, 0, 516, 0, 517, 0, + }}, + {{ + 518, 0, 519, 0, 520, 0, 521, 0, 522, 0, 523, + 0, 524, 0, 525, 0, 526, 0, 527, 0, 528, 0, + 529, 531, 533, 535, 537, 539, 0, 0, 0, 0, + }}, + {{ + 540, 0, 541, 0, 542, 0, 543, 0, 544, 0, 545, + 0, 546, 0, 547, 0, 548, 0, 549, 0, 550, 0, + 551, 0, 552, 0, 553, 0, 554, 0, 555, 0, + }}, + {{ + 556, 0, 557, 0, 558, 0, 559, 0, 560, 0, 561, + 0, 562, 0, 563, 0, 564, 0, 565, 0, 566, 0, + 567, 0, 568, 0, 569, 0, 570, 0, 571, 0, + }}, + {{ + 572, 0, 573, 0, 574, 0, 575, 0, 576, 0, 577, + 0, 578, 0, 579, 0, 580, 0, 581, 0, 582, 0, + 583, 0, 584, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 585, 586, 587, + 588, 589, 590, 591, 592, 0, 0, 0, 0, 0, 0, + 0, 0, 593, 594, 595, 596, 597, 598, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 599, 600, 601, + 602, 603, 604, 605, 606, 0, 0, 0, 0, 0, 0, + 0, 0, 607, 608, 609, 610, 611, 612, 613, 614, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 615, 616, 617, + 618, 619, 620, 0, 0, 621, 0, 623, 0, 626, 0, + 629, 0, 0, 632, 0, 633, 0, 634, 0, 635, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 636, 637, 638, + 639, 640, 641, 642, 643, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 644, 646, 648, 650, 652, 654, 656, 658, 662, 665, 668, + 671, 674, 677, 680, 683, 684, 686, 688, 690, 692, 694, + 696, 698, 702, 705, 708, 711, 714, 717, 720, 723, + }}, + {{ + 724, 726, 728, 730, 732, 734, 736, 738, 742, 745, 748, + 751, 754, 757, 760, 763, 0, 0, 764, 766, 768, 0, + 770, 772, 775, 776, 777, 778, 781, 0, 782, 0, + }}, + {{ + 0, 0, 783, 785, 787, 0, 789, 791, 794, 795, 796, + 797, 800, 0, 0, 0, 0, 0, 801, 804, 0, 0, + 807, 809, 812, 813, 814, 815, 0, 0, 0, 0, + }}, + {{ + 0, 0, 816, 819, 822, 0, 824, 826, 829, 830, 831, + 832, 833, 0, 0, 0, 0, 0, 834, 836, 838, 0, + 840, 842, 845, 846, 847, 848, 851, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 852, 0, 0, 0, 853, + 854, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 855, 856, 857, 858, 859, 860, 861, 862, 863, 864, 865, + 866, 867, 868, 869, 870, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 871, 872, 873, 874, 875, 876, 877, 878, 879, 880, + }}, + {{ + 881, 882, 883, 884, 885, 886, 887, 888, 889, 890, 891, + 892, 893, 894, 895, 896, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 897, 899, 901, 903, 906, 909, 911, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 913, 915, 917, + 919, 921, 0, 0, 0, 0, 0, 0, 0, 0, + }}, + {{ + 0, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, + 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, + 944, 945, 946, 947, 948, 0, 0, 0, 0, 0, + }}, + {{ + 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, + 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, + 971, 972, 973, 974, 975, 976, 977, 978, 979, 980, + }}, + {{ + 981, 982, 983, 984, 985, 986, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + }}, +}; +static const unsigned long v320_case_folding_seq[] = { + 0x00000000, 0x80000061, 0x80000062, 0x80000063, + 0x80000064, 0x80000065, 0x80000066, 0x80000067, + 0x80000068, 0x80000069, 0x80000131, 0x8000006a, + 0x8000006b, 0x8000006c, 0x8000006d, 0x8000006e, + 0x8000006f, 0x80000070, 0x80000071, 0x80000072, + 0x80000073, 0x80000074, 0x80000075, 0x80000076, + 0x80000077, 0x80000078, 0x80000079, 0x8000007a, + 0x800003bc, 0x800000e0, 0x800000e1, 0x800000e2, + 0x800000e3, 0x800000e4, 0x800000e5, 0x800000e6, + 0x800000e7, 0x800000e8, 0x800000e9, 0x800000ea, + 0x800000eb, 0x800000ec, 0x800000ed, 0x800000ee, + 0x800000ef, 0x800000f0, 0x800000f1, 0x800000f2, + 0x800000f3, 0x800000f4, 0x800000f5, 0x800000f6, + 0x800000f8, 0x800000f9, 0x800000fa, 0x800000fb, + 0x800000fc, 0x800000fd, 0x800000fe, 0x00000073, + 0x80000073, 0x80000101, 0x80000103, 0x80000105, + 0x80000107, 0x80000109, 0x8000010b, 0x8000010d, + 0x8000010f, 0x80000111, 0x80000113, 0x80000115, + 0x80000117, 0x80000119, 0x8000011b, 0x8000011d, + 0x8000011f, 0x80000121, 0x80000123, 0x80000125, + 0x80000127, 0x80000129, 0x8000012b, 0x8000012d, + 0x8000012f, 0x00000069, 0x80000307, 0x80000069, + 0x80000133, 0x80000135, 0x80000137, 0x8000013a, + 0x8000013c, 0x8000013e, 0x80000140, 0x80000142, + 0x80000144, 0x80000146, 0x80000148, 0x000002bc, + 0x8000006e, 0x8000014b, 0x8000014d, 0x8000014f, + 0x80000151, 0x80000153, 0x80000155, 0x80000157, + 0x80000159, 0x8000015b, 0x8000015d, 0x8000015f, + 0x80000161, 0x80000163, 0x80000165, 0x80000167, + 0x80000169, 0x8000016b, 0x8000016d, 0x8000016f, + 0x80000171, 0x80000173, 0x80000175, 0x80000177, + 0x800000ff, 0x8000017a, 0x8000017c, 0x8000017e, + 0x80000073, 0x80000253, 0x80000183, 0x80000185, + 0x80000254, 0x80000188, 0x80000256, 0x80000257, + 0x8000018c, 0x800001dd, 0x80000259, 0x8000025b, + 0x80000192, 0x80000260, 0x80000263, 0x80000269, + 0x80000268, 0x80000199, 0x8000026f, 0x80000272, + 0x80000275, 0x800001a1, 0x800001a3, 0x800001a5, + 0x80000280, 0x800001a8, 0x80000283, 0x800001ad, + 0x80000288, 0x800001b0, 0x8000028a, 0x8000028b, + 0x800001b4, 0x800001b6, 0x80000292, 0x800001b9, + 0x800001bd, 0x800001c6, 0x800001c6, 0x800001c9, + 0x800001c9, 0x800001cc, 0x800001cc, 0x800001ce, + 0x800001d0, 0x800001d2, 0x800001d4, 0x800001d6, + 0x800001d8, 0x800001da, 0x800001dc, 0x800001df, + 0x800001e1, 0x800001e3, 0x800001e5, 0x800001e7, + 0x800001e9, 0x800001eb, 0x800001ed, 0x800001ef, + 0x0000006a, 0x8000030c, 0x800001f3, 0x800001f3, + 0x800001f5, 0x80000195, 0x800001bf, 0x800001f9, + 0x800001fb, 0x800001fd, 0x800001ff, 0x80000201, + 0x80000203, 0x80000205, 0x80000207, 0x80000209, + 0x8000020b, 0x8000020d, 0x8000020f, 0x80000211, + 0x80000213, 0x80000215, 0x80000217, 0x80000219, + 0x8000021b, 0x8000021d, 0x8000021f, 0x8000019e, + 0x80000223, 0x80000225, 0x80000227, 0x80000229, + 0x8000022b, 0x8000022d, 0x8000022f, 0x80000231, + 0x80000233, 0x800003b9, 0x800003ac, 0x800003ad, + 0x800003ae, 0x800003af, 0x800003cc, 0x800003cd, + 0x800003ce, 0x000003b9, 0x00000308, 0x80000301, + 0x800003b1, 0x800003b2, 0x800003b3, 0x800003b4, + 0x800003b5, 0x800003b6, 0x800003b7, 0x800003b8, + 0x800003b9, 0x800003ba, 0x800003bb, 0x800003bc, + 0x800003bd, 0x800003be, 0x800003bf, 0x800003c0, + 0x800003c1, 0x800003c3, 0x800003c4, 0x800003c5, + 0x800003c6, 0x800003c7, 0x800003c8, 0x800003c9, + 0x800003ca, 0x800003cb, 0x000003c5, 0x00000308, + 0x80000301, 0x800003c3, 0x800003b2, 0x800003b8, + 0x800003c6, 0x800003c0, 0x800003d9, 0x800003db, + 0x800003dd, 0x800003df, 0x800003e1, 0x800003e3, + 0x800003e5, 0x800003e7, 0x800003e9, 0x800003eb, + 0x800003ed, 0x800003ef, 0x800003ba, 0x800003c1, + 0x800003c3, 0x800003b8, 0x800003b5, 0x80000450, + 0x80000451, 0x80000452, 0x80000453, 0x80000454, + 0x80000455, 0x80000456, 0x80000457, 0x80000458, + 0x80000459, 0x8000045a, 0x8000045b, 0x8000045c, + 0x8000045d, 0x8000045e, 0x8000045f, 0x80000430, + 0x80000431, 0x80000432, 0x80000433, 0x80000434, + 0x80000435, 0x80000436, 0x80000437, 0x80000438, + 0x80000439, 0x8000043a, 0x8000043b, 0x8000043c, + 0x8000043d, 0x8000043e, 0x8000043f, 0x80000440, + 0x80000441, 0x80000442, 0x80000443, 0x80000444, + 0x80000445, 0x80000446, 0x80000447, 0x80000448, + 0x80000449, 0x8000044a, 0x8000044b, 0x8000044c, + 0x8000044d, 0x8000044e, 0x8000044f, 0x80000461, + 0x80000463, 0x80000465, 0x80000467, 0x80000469, + 0x8000046b, 0x8000046d, 0x8000046f, 0x80000471, + 0x80000473, 0x80000475, 0x80000477, 0x80000479, + 0x8000047b, 0x8000047d, 0x8000047f, 0x80000481, + 0x8000048b, 0x8000048d, 0x8000048f, 0x80000491, + 0x80000493, 0x80000495, 0x80000497, 0x80000499, + 0x8000049b, 0x8000049d, 0x8000049f, 0x800004a1, + 0x800004a3, 0x800004a5, 0x800004a7, 0x800004a9, + 0x800004ab, 0x800004ad, 0x800004af, 0x800004b1, + 0x800004b3, 0x800004b5, 0x800004b7, 0x800004b9, + 0x800004bb, 0x800004bd, 0x800004bf, 0x800004c2, + 0x800004c4, 0x800004c6, 0x800004c8, 0x800004ca, + 0x800004cc, 0x800004ce, 0x800004d1, 0x800004d3, + 0x800004d5, 0x800004d7, 0x800004d9, 0x800004db, + 0x800004dd, 0x800004df, 0x800004e1, 0x800004e3, + 0x800004e5, 0x800004e7, 0x800004e9, 0x800004eb, + 0x800004ed, 0x800004ef, 0x800004f1, 0x800004f3, + 0x800004f5, 0x800004f9, 0x80000501, 0x80000503, + 0x80000505, 0x80000507, 0x80000509, 0x8000050b, + 0x8000050d, 0x8000050f, 0x80000561, 0x80000562, + 0x80000563, 0x80000564, 0x80000565, 0x80000566, + 0x80000567, 0x80000568, 0x80000569, 0x8000056a, + 0x8000056b, 0x8000056c, 0x8000056d, 0x8000056e, + 0x8000056f, 0x80000570, 0x80000571, 0x80000572, + 0x80000573, 0x80000574, 0x80000575, 0x80000576, + 0x80000577, 0x80000578, 0x80000579, 0x8000057a, + 0x8000057b, 0x8000057c, 0x8000057d, 0x8000057e, + 0x8000057f, 0x80000580, 0x80000581, 0x80000582, + 0x80000583, 0x80000584, 0x80000585, 0x80000586, + 0x00000565, 0x80000582, 0x80001e01, 0x80001e03, + 0x80001e05, 0x80001e07, 0x80001e09, 0x80001e0b, + 0x80001e0d, 0x80001e0f, 0x80001e11, 0x80001e13, + 0x80001e15, 0x80001e17, 0x80001e19, 0x80001e1b, + 0x80001e1d, 0x80001e1f, 0x80001e21, 0x80001e23, + 0x80001e25, 0x80001e27, 0x80001e29, 0x80001e2b, + 0x80001e2d, 0x80001e2f, 0x80001e31, 0x80001e33, + 0x80001e35, 0x80001e37, 0x80001e39, 0x80001e3b, + 0x80001e3d, 0x80001e3f, 0x80001e41, 0x80001e43, + 0x80001e45, 0x80001e47, 0x80001e49, 0x80001e4b, + 0x80001e4d, 0x80001e4f, 0x80001e51, 0x80001e53, + 0x80001e55, 0x80001e57, 0x80001e59, 0x80001e5b, + 0x80001e5d, 0x80001e5f, 0x80001e61, 0x80001e63, + 0x80001e65, 0x80001e67, 0x80001e69, 0x80001e6b, + 0x80001e6d, 0x80001e6f, 0x80001e71, 0x80001e73, + 0x80001e75, 0x80001e77, 0x80001e79, 0x80001e7b, + 0x80001e7d, 0x80001e7f, 0x80001e81, 0x80001e83, + 0x80001e85, 0x80001e87, 0x80001e89, 0x80001e8b, + 0x80001e8d, 0x80001e8f, 0x80001e91, 0x80001e93, + 0x80001e95, 0x00000068, 0x80000331, 0x00000074, + 0x80000308, 0x00000077, 0x8000030a, 0x00000079, + 0x8000030a, 0x00000061, 0x800002be, 0x80001e61, + 0x80001ea1, 0x80001ea3, 0x80001ea5, 0x80001ea7, + 0x80001ea9, 0x80001eab, 0x80001ead, 0x80001eaf, + 0x80001eb1, 0x80001eb3, 0x80001eb5, 0x80001eb7, + 0x80001eb9, 0x80001ebb, 0x80001ebd, 0x80001ebf, + 0x80001ec1, 0x80001ec3, 0x80001ec5, 0x80001ec7, + 0x80001ec9, 0x80001ecb, 0x80001ecd, 0x80001ecf, + 0x80001ed1, 0x80001ed3, 0x80001ed5, 0x80001ed7, + 0x80001ed9, 0x80001edb, 0x80001edd, 0x80001edf, + 0x80001ee1, 0x80001ee3, 0x80001ee5, 0x80001ee7, + 0x80001ee9, 0x80001eeb, 0x80001eed, 0x80001eef, + 0x80001ef1, 0x80001ef3, 0x80001ef5, 0x80001ef7, + 0x80001ef9, 0x80001f00, 0x80001f01, 0x80001f02, + 0x80001f03, 0x80001f04, 0x80001f05, 0x80001f06, + 0x80001f07, 0x80001f10, 0x80001f11, 0x80001f12, + 0x80001f13, 0x80001f14, 0x80001f15, 0x80001f20, + 0x80001f21, 0x80001f22, 0x80001f23, 0x80001f24, + 0x80001f25, 0x80001f26, 0x80001f27, 0x80001f30, + 0x80001f31, 0x80001f32, 0x80001f33, 0x80001f34, + 0x80001f35, 0x80001f36, 0x80001f37, 0x80001f40, + 0x80001f41, 0x80001f42, 0x80001f43, 0x80001f44, + 0x80001f45, 0x000003c5, 0x80000313, 0x000003c5, + 0x00000313, 0x80000300, 0x000003c5, 0x00000313, + 0x80000301, 0x000003c5, 0x00000313, 0x80000342, + 0x80001f51, 0x80001f53, 0x80001f55, 0x80001f57, + 0x80001f60, 0x80001f61, 0x80001f62, 0x80001f63, + 0x80001f64, 0x80001f65, 0x80001f66, 0x80001f67, + 0x00001f00, 0x800003b9, 0x00001f01, 0x800003b9, + 0x00001f02, 0x800003b9, 0x00001f03, 0x800003b9, + 0x00001f04, 0x800003b9, 0x00001f05, 0x800003b9, + 0x00001f06, 0x800003b9, 0x00001f07, 0x800003b9, + 0x00001f00, 0x800003b9, 0x80001f80, 0x00001f01, + 0x800003b9, 0x80001f81, 0x00001f02, 0x800003b9, + 0x80001f82, 0x00001f03, 0x800003b9, 0x80001f83, + 0x00001f04, 0x800003b9, 0x80001f84, 0x00001f05, + 0x800003b9, 0x80001f85, 0x00001f06, 0x800003b9, + 0x80001f86, 0x00001f07, 0x800003b9, 0x80001f87, + 0x00001f20, 0x800003b9, 0x00001f21, 0x800003b9, + 0x00001f22, 0x800003b9, 0x00001f23, 0x800003b9, + 0x00001f24, 0x800003b9, 0x00001f25, 0x800003b9, + 0x00001f26, 0x800003b9, 0x00001f27, 0x800003b9, + 0x00001f20, 0x800003b9, 0x80001f90, 0x00001f21, + 0x800003b9, 0x80001f91, 0x00001f22, 0x800003b9, + 0x80001f92, 0x00001f23, 0x800003b9, 0x80001f93, + 0x00001f24, 0x800003b9, 0x80001f94, 0x00001f25, + 0x800003b9, 0x80001f95, 0x00001f26, 0x800003b9, + 0x80001f96, 0x00001f27, 0x800003b9, 0x80001f97, + 0x00001f60, 0x800003b9, 0x00001f61, 0x800003b9, + 0x00001f62, 0x800003b9, 0x00001f63, 0x800003b9, + 0x00001f64, 0x800003b9, 0x00001f65, 0x800003b9, + 0x00001f66, 0x800003b9, 0x00001f67, 0x800003b9, + 0x00001f60, 0x800003b9, 0x80001fa0, 0x00001f61, + 0x800003b9, 0x80001fa1, 0x00001f62, 0x800003b9, + 0x80001fa2, 0x00001f63, 0x800003b9, 0x80001fa3, + 0x00001f64, 0x800003b9, 0x80001fa4, 0x00001f65, + 0x800003b9, 0x80001fa5, 0x00001f66, 0x800003b9, + 0x80001fa6, 0x00001f67, 0x800003b9, 0x80001fa7, + 0x00001f70, 0x800003b9, 0x000003b1, 0x800003b9, + 0x000003ac, 0x800003b9, 0x000003b1, 0x80000342, + 0x000003b1, 0x00000342, 0x800003b9, 0x80001fb0, + 0x80001fb1, 0x80001f70, 0x80001f71, 0x000003b1, + 0x800003b9, 0x80001fb3, 0x800003b9, 0x00001f74, + 0x800003b9, 0x000003b7, 0x800003b9, 0x000003ae, + 0x800003b9, 0x000003b7, 0x80000342, 0x000003b7, + 0x00000342, 0x800003b9, 0x80001f72, 0x80001f73, + 0x80001f74, 0x80001f75, 0x000003b7, 0x800003b9, + 0x80001fc3, 0x000003b9, 0x00000308, 0x80000300, + 0x000003b9, 0x00000308, 0x80000301, 0x000003b9, + 0x80000342, 0x000003b9, 0x00000308, 0x80000342, + 0x80001fd0, 0x80001fd1, 0x80001f76, 0x80001f77, + 0x000003c5, 0x00000308, 0x80000300, 0x000003c5, + 0x00000308, 0x80000301, 0x000003c1, 0x80000313, + 0x000003c5, 0x80000342, 0x000003c5, 0x00000308, + 0x80000342, 0x80001fe0, 0x80001fe1, 0x80001f7a, + 0x80001f7b, 0x80001fe5, 0x00001f7c, 0x800003b9, + 0x000003c9, 0x800003b9, 0x000003ce, 0x800003b9, + 0x000003c9, 0x80000342, 0x000003c9, 0x00000342, + 0x800003b9, 0x80001f78, 0x80001f79, 0x80001f7c, + 0x80001f7d, 0x000003c9, 0x800003b9, 0x80001ff3, + 0x800003c9, 0x8000006b, 0x800000e5, 0x80002170, + 0x80002171, 0x80002172, 0x80002173, 0x80002174, + 0x80002175, 0x80002176, 0x80002177, 0x80002178, + 0x80002179, 0x8000217a, 0x8000217b, 0x8000217c, + 0x8000217d, 0x8000217e, 0x8000217f, 0x800024d0, + 0x800024d1, 0x800024d2, 0x800024d3, 0x800024d4, + 0x800024d5, 0x800024d6, 0x800024d7, 0x800024d8, + 0x800024d9, 0x800024da, 0x800024db, 0x800024dc, + 0x800024dd, 0x800024de, 0x800024df, 0x800024e0, + 0x800024e1, 0x800024e2, 0x800024e3, 0x800024e4, + 0x800024e5, 0x800024e6, 0x800024e7, 0x800024e8, + 0x800024e9, 0x00000066, 0x80000066, 0x00000066, + 0x80000069, 0x00000066, 0x8000006c, 0x00000066, + 0x00000066, 0x80000069, 0x00000066, 0x00000066, + 0x8000006c, 0x00000073, 0x80000074, 0x00000073, + 0x80000074, 0x00000574, 0x80000576, 0x00000574, + 0x80000565, 0x00000574, 0x8000056b, 0x0000057e, + 0x80000576, 0x00000574, 0x8000056d, 0x8000ff41, + 0x8000ff42, 0x8000ff43, 0x8000ff44, 0x8000ff45, + 0x8000ff46, 0x8000ff47, 0x8000ff48, 0x8000ff49, + 0x8000ff4a, 0x8000ff4b, 0x8000ff4c, 0x8000ff4d, + 0x8000ff4e, 0x8000ff4f, 0x8000ff50, 0x8000ff51, + 0x8000ff52, 0x8000ff53, 0x8000ff54, 0x8000ff55, + 0x8000ff56, 0x8000ff57, 0x8000ff58, 0x8000ff59, + 0x8000ff5a, 0x80010428, 0x80010429, 0x8001042a, + 0x8001042b, 0x8001042c, 0x8001042d, 0x8001042e, + 0x8001042f, 0x80010430, 0x80010431, 0x80010432, + 0x80010433, 0x80010434, 0x80010435, 0x80010436, + 0x80010437, 0x80010438, 0x80010439, 0x8001043a, + 0x8001043b, 0x8001043c, 0x8001043d, 0x8001043e, + 0x8001043f, 0x80010440, 0x80010441, 0x80010442, + 0x80010443, 0x80010444, 0x80010445, 0x80010446, + 0x80010447, 0x80010448, 0x80010449, 0x8001044a, + 0x8001044b, 0x8001044c, 0x8001044d, +}; + diff --git a/contrib/idn/idnkit-1.0-src/lib/unormalize.c b/contrib/idn/idnkit-1.0-src/lib/unormalize.c new file mode 100644 index 0000000..f741724 --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/unormalize.c @@ -0,0 +1,413 @@ +#ifndef lint +static char *rcsid = "$Id: unormalize.c,v 1.1.1.1 2003/06/04 00:26:43 marka Exp $"; +#endif + +/* + * Copyright (c) 2000,2001,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 <config.h> + +#include <stddef.h> +#include <stdlib.h> +#include <string.h> + +#include <idn/result.h> +#include <idn/assert.h> +#include <idn/logmacro.h> +#include <idn/ucs4.h> +#include <idn/unicode.h> +#include <idn/unormalize.h> +#include <idn/debug.h> + +#if !defined(HAVE_MEMMOVE) && defined(HAVE_BCOPY) +#define memmove(a,b,c) bcopy((char *)(b),(char *)(a),(int)(c)) +#endif + +#define WORKBUF_SIZE 128 +#define WORKBUF_SIZE_MAX 10000 + +typedef struct { + idn__unicode_version_t version; /* Unicode version */ + int cur; /* pointing now processing character */ + int last; /* pointing just after the last character */ + int size; /* size of UCS and CLASS array */ + unsigned long *ucs4; /* UCS-4 characters */ + int *class; /* and their canonical classes */ + unsigned long ucs4_buf[WORKBUF_SIZE]; /* local buffer */ + int class_buf[WORKBUF_SIZE]; /* ditto */ +} workbuf_t; + +static idn_result_t normalize(idn__unicode_version_t version, + int do_composition, int compat, + const unsigned long *from, + unsigned long *to, size_t tolen); +static idn_result_t decompose(workbuf_t *wb, unsigned long c, int compat); +static void get_class(workbuf_t *wb); +static void reorder(workbuf_t *wb); +static void compose(workbuf_t *wb); +static idn_result_t flush_before_cur(workbuf_t *wb, + unsigned long **top, size_t *tolenp); +static void workbuf_init(workbuf_t *wb); +static void workbuf_free(workbuf_t *wb); +static idn_result_t workbuf_extend(workbuf_t *wb); +static idn_result_t workbuf_append(workbuf_t *wb, unsigned long c); +static void workbuf_shift(workbuf_t *wb, int shift); +static void workbuf_removevoid(workbuf_t *wb); + +idn_result_t +idn__unormalize_formkc(idn__unicode_version_t version, + const unsigned long *from, unsigned long *to, + size_t tolen) { + assert(version != NULL && from != NULL && to != NULL && tolen >= 0); + TRACE(("idn__unormalize_formkc(from=\"%s\", tolen=%d)\n", + idn__debug_ucs4xstring(from, 50), tolen)); + return (normalize(version, 1, 1, from, to, tolen)); +} + +static idn_result_t +normalize(idn__unicode_version_t version, int do_composition, int compat, + const unsigned long *from, unsigned long *to, size_t tolen) { + workbuf_t wb; + idn_result_t r = idn_success; + + /* + * Initialize working buffer. + */ + workbuf_init(&wb); + wb.version = version; + + while (*from != '\0') { + unsigned long c; + + assert(wb.cur == wb.last); + + /* + * Get one character from 'from'. + */ + c = *from++; + + /* + * Decompose it. + */ + if ((r = decompose(&wb, c, compat)) != idn_success) + goto ret; + + /* + * Get canonical class. + */ + get_class(&wb); + + /* + * Reorder & compose. + */ + for (; wb.cur < wb.last; wb.cur++) { + if (wb.cur == 0) { + continue; + } else if (wb.class[wb.cur] > 0) { + /* + * This is not a starter. Try reordering. + * Note that characters up to it are + * already in canonical order. + */ + reorder(&wb); + continue; + } + + /* + * This is a starter character, and there are + * some characters before it. Those characters + * have been reordered properly, and + * ready for composition. + */ + if (do_composition && wb.class[0] == 0) + compose(&wb); + + /* + * If CUR points to a starter character, + * then process of characters before CUR are + * already finished, because any further + * reordering/composition for them are blocked + * by the starter CUR points. + */ + if (wb.cur > 0 && wb.class[wb.cur] == 0) { + /* Flush everything before CUR. */ + r = flush_before_cur(&wb, &to, &tolen); + if (r != idn_success) + goto ret; + } + } + } + + if (r == idn_success) { + if (do_composition && wb.cur > 0 && wb.class[0] == 0) { + /* + * There is some characters left in WB. + * They are ordered, but not composed yet. + * Now CUR points just after the last character in WB, + * and since compose() tries to compose characters + * between top and CUR inclusive, we must make CUR + * one character back during compose(). + */ + wb.cur--; + compose(&wb); + wb.cur++; + } + /* + * Call this even when WB.CUR == 0, to make TO + * NUL-terminated. + */ + r = flush_before_cur(&wb, &to, &tolen); + if (r != idn_success) + goto ret; + } + + if (tolen <= 0) { + r = idn_buffer_overflow; + goto ret; + } + *to = '\0'; + +ret: + workbuf_free(&wb); + return (r); +} + +static idn_result_t +decompose(workbuf_t *wb, unsigned long c, int compat) { + idn_result_t r; + int dec_len; + +again: + r = idn__unicode_decompose(wb->version, compat, wb->ucs4 + wb->last, + wb->size - wb->last, c, &dec_len); + switch (r) { + case idn_success: + wb->last += dec_len; + return (idn_success); + case idn_notfound: + return (workbuf_append(wb, c)); + case idn_buffer_overflow: + if ((r = workbuf_extend(wb)) != idn_success) + return (r); + if (wb->size > WORKBUF_SIZE_MAX) { + WARNING(("idn__unormalize_form*: " + "working buffer too large\n")); + return (idn_nomemory); + } + goto again; + default: + return (r); + } + /* NOTREACHED */ +} + +static void +get_class(workbuf_t *wb) { + int i; + + for (i = wb->cur; i < wb->last; i++) + wb->class[i] = idn__unicode_canonicalclass(wb->version, + wb->ucs4[i]); +} + +static void +reorder(workbuf_t *wb) { + unsigned long c; + int i; + int class; + + assert(wb != NULL); + + i = wb->cur; + c = wb->ucs4[i]; + class = wb->class[i]; + + while (i > 0 && wb->class[i - 1] > class) { + wb->ucs4[i] = wb->ucs4[i - 1]; + wb->class[i] =wb->class[i - 1]; + i--; + wb->ucs4[i] = c; + wb->class[i] = class; + } +} + +static void +compose(workbuf_t *wb) { + int cur; + unsigned long *ucs4; + int *class; + int last_class; + int nvoids; + int i; + idn__unicode_version_t ver; + + assert(wb != NULL && wb->class[0] == 0); + + cur = wb->cur; + ucs4 = wb->ucs4; + class = wb->class; + ver = wb->version; + + /* + * If there are no decomposition sequence that begins with + * the top character, composition is impossible. + */ + if (!idn__unicode_iscompositecandidate(ver, ucs4[0])) + return; + + last_class = 0; + nvoids = 0; + for (i = 1; i <= cur; i++) { + unsigned long c; + int cl = class[i]; + + if ((last_class < cl || cl == 0) && + idn__unicode_compose(ver, ucs4[0], ucs4[i], + &c) == idn_success) { + /* + * Replace the top character with the composed one. + */ + ucs4[0] = c; + class[0] = idn__unicode_canonicalclass(ver, c); + + class[i] = -1; /* void this character */ + nvoids++; + } else { + last_class = cl; + } + } + + /* Purge void characters, if any. */ + if (nvoids > 0) + workbuf_removevoid(wb); +} + +static idn_result_t +flush_before_cur(workbuf_t *wb, unsigned long **top, size_t *tolenp) { + if (*tolenp < wb->cur) + return (idn_buffer_overflow); + + memcpy(*top, wb->ucs4, sizeof(**top) * wb->cur); + *top += wb->cur; + *tolenp -= wb->cur; + workbuf_shift(wb, wb->cur); + + return (idn_success); +} + +static void +workbuf_init(workbuf_t *wb) { + wb->cur = 0; + wb->last = 0; + wb->size = WORKBUF_SIZE; + wb->ucs4 = wb->ucs4_buf; + wb->class = wb->class_buf; +} + +static void +workbuf_free(workbuf_t *wb) { + if (wb->ucs4 != wb->ucs4_buf) { + free(wb->ucs4); + free(wb->class); + } +} + +static idn_result_t +workbuf_extend(workbuf_t *wb) { + int newsize = wb->size * 3; + + if (wb->ucs4 == wb->ucs4_buf) { + wb->ucs4 = malloc(sizeof(wb->ucs4[0]) * newsize); + wb->class = malloc(sizeof(wb->class[0]) * newsize); + } else { + wb->ucs4 = realloc(wb->ucs4, sizeof(wb->ucs4[0]) * newsize); + wb->class = realloc(wb->class, sizeof(wb->class[0]) * newsize); + } + if (wb->ucs4 == NULL || wb->class == NULL) + return (idn_nomemory); + else + return (idn_success); +} + +static idn_result_t +workbuf_append(workbuf_t *wb, unsigned long c) { + idn_result_t r; + + if (wb->last >= wb->size && (r = workbuf_extend(wb)) != idn_success) + return (r); + wb->ucs4[wb->last++] = c; + return (idn_success); +} + +static void +workbuf_shift(workbuf_t *wb, int shift) { + int nmove; + + assert(wb != NULL && wb->cur >= shift); + + nmove = wb->last - shift; + (void)memmove(&wb->ucs4[0], &wb->ucs4[shift], + nmove * sizeof(wb->ucs4[0])); + (void)memmove(&wb->class[0], &wb->class[shift], + nmove * sizeof(wb->class[0])); + wb->cur -= shift; + wb->last -= shift; +} + +static void +workbuf_removevoid(workbuf_t *wb) { + int i, j; + int last = wb->last; + + for (i = j = 0; i < last; i++) { + if (wb->class[i] >= 0) { + if (j < i) { + wb->ucs4[j] = wb->ucs4[i]; + wb->class[j] = wb->class[i]; + } + j++; + } + } + wb->cur -= last - j; + wb->last = j; +} diff --git a/contrib/idn/idnkit-1.0-src/lib/utf8.c b/contrib/idn/idnkit-1.0-src/lib/utf8.c new file mode 100644 index 0000000..7a9acd6 --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/utf8.c @@ -0,0 +1,276 @@ +#ifndef lint +static char *rcsid = "$Id: utf8.c,v 1.1.1.1 2003/06/04 00:26:44 marka Exp $"; +#endif + +/* + * Copyright (c) 2000 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 <config.h> + +#include <stddef.h> + +#include <idn/assert.h> +#include <idn/logmacro.h> +#include <idn/utf8.h> +#include <idn/debug.h> + +#define UTF8_WIDTH(c) \ + (((c) < 0x80) ? 1 : \ + ((c) < 0xc0) ? 0 : \ + ((c) < 0xe0) ? 2 : \ + ((c) < 0xf0) ? 3 : \ + ((c) < 0xf8) ? 4 : \ + ((c) < 0xfc) ? 5 : \ + ((c) < 0xfe) ? 6 : 0) + +#define VALID_CONT_BYTE(c) (0x80 <= (c) && (c) < 0xc0) + +int +idn_utf8_mblen(const char *s) { + int c = *(unsigned char *)s; + + assert(s != NULL); + +#if 0 + TRACE(("idn_utf8_mblen(s=<%s>)\n", idn__debug_hexstring(s, 6))); +#endif + + return UTF8_WIDTH(c); +} + +int +idn_utf8_getmb(const char *s, size_t len, char *buf) { + /* buf must be at least 7-bytes long */ + const unsigned char *p = (const unsigned char *)s; + unsigned char *q = (unsigned char *)buf; + int width = UTF8_WIDTH(*p); + int w; + + assert(s != NULL); + +#if 0 + TRACE(("idn_utf8_getmb(s=<%s>,len=%d)\n", + idn__debug_hexstring(s, 6), len)); +#endif + + if (width == 0 || len < width) + return (0); + + /* Copy the first byte. */ + *q++ = *p++; + + /* .. and the rest. */ + w = width; + while (--w > 0) { + if (!VALID_CONT_BYTE(*p)) + return (0); + *q++ = *p++; + } + return (width); +} + +int +idn_utf8_getwc(const char *s, size_t len, unsigned long *vp) { + unsigned long v; + unsigned long min; + const unsigned char *p = (const unsigned char *)s; + int c; + int width; + int rest; + + assert(s != NULL); + +#if 0 + TRACE(("idn_utf8_getwc(s=<%s>,len=%d)\n", + idn__debug_hexstring(s, 10), len)); +#endif + + c = *p++; + width = UTF8_WIDTH(c); + + switch (width) { + case 0: + return (0); + case 1: + v = c; + min = 0; + break; + case 2: + v = c & 0x1f; + min = 0x80; + break; + case 3: + v = c & 0xf; + min = 0x800; + break; + case 4: + v = c & 0x7; + min = 0x10000; + break; + case 5: + v = c & 3; + min = 0x200000; + break; + case 6: + v = c & 1; + min = 0x4000000; + break; + default: + FATAL(("idn_utf8_getint: internal error\n")); + return (0); + } + + if (len < width) + return (0); + + rest = width - 1; + while (rest-- > 0) { + if (!VALID_CONT_BYTE(*p)) + return (0); + v = (v << 6) | (*p & 0x3f); + p++; + } + + if (v < min) + return (0); + + *vp = v; + return (width); +} + +int +idn_utf8_putwc(char *s, size_t len, unsigned long v) { + unsigned char *p = (unsigned char *)s; + int mask; + int off; + int l; + + assert(s != NULL); + +#if 0 + TRACE(("idn_utf8_putwc(v=%lx)\n", v)); +#endif + + if (v < 0x80) { + mask = 0; + l = 1; + } else if (v < 0x800) { + mask = 0xc0; + l = 2; + } else if (v < 0x10000) { + mask = 0xe0; + l = 3; + } else if (v < 0x200000) { + mask = 0xf0; + l = 4; + } else if (v < 0x4000000) { + mask = 0xf8; + l = 5; + } else if (v < 0x80000000) { + mask = 0xfc; + l = 6; + } else { + return (0); + } + + if (len < l) + return (0); + + off = 6 * (l - 1); + *p++ = (v >> off) | mask; + mask = 0x80; + while (off > 0) { + off -= 6; + *p++ = ((v >> off) & 0x3f) | mask; + } + return l; +} + +int +idn_utf8_isvalidchar(const char *s) { + unsigned long dummy; + + TRACE(("idn_utf8_isvalidchar(s=<%s>)\n", + idn__debug_hexstring(s, 6))); + + return (idn_utf8_getwc(s, 6, &dummy) > 0); +} + +int +idn_utf8_isvalidstring(const char *s) { + unsigned long dummy; + int width; + + assert(s != NULL); + + TRACE(("idn_utf8_isvalidstring(s=<%s>)\n", + idn__debug_hexstring(s, 20))); + + while (*s != '\0') { + width = idn_utf8_getwc(s, 6, &dummy); + if (width == 0) + return (0); + s += width; + } + return (1); +} + +char * +idn_utf8_findfirstbyte(const char *s, const char *known_top) { + const unsigned char *p = (const unsigned char *)s; + const unsigned char *t = (const unsigned char *)known_top; + + assert(s != NULL && known_top != NULL && known_top <= s); + + TRACE(("idn_utf8_findfirstbyte(s=<%s>)\n", + idn__debug_hexstring(s, 8))); + + while (p >= t) { + if (!VALID_CONT_BYTE(*p)) + break; + p--; + } + if (p < t || UTF8_WIDTH(*p) == 0) + return (NULL); + + return ((char *)p); +} diff --git a/contrib/idn/idnkit-1.0-src/lib/util.c b/contrib/idn/idnkit-1.0-src/lib/util.c new file mode 100644 index 0000000..a2d315a --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/util.c @@ -0,0 +1,162 @@ +#ifndef lint +static char *rcsid = "$Id: util.c,v 1.1.1.1 2003/06/04 00:26:45 marka Exp $"; +#endif + +/* + * Copyright (c) 2000,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 <config.h> + +#ifdef WIN32 +#include <windows.h> +#undef ERROR +#endif + +#include <stddef.h> + +#include <idn/assert.h> +#include <idn/result.h> +#include <idn/logmacro.h> +#include <idn/util.h> +#include <idn/ucs4.h> + +#ifdef WIN32 +#define IDNKEY_IDNKIT "Software\\JPNIC\\IDN" +#endif + +/* + * ASCII ctype macros. + * Note that these macros evaluate the argument multiple times. Be careful. + */ +#define ASCII_ISDIGIT(c) \ + ('0' <= (c) && (c) <= '9') +#define ASCII_ISUPPER(c) \ + ('A' <= (c) && (c) <= 'Z') +#define ASCII_ISLOWER(c) \ + ('a' <= (c) && (c) <= 'z') +#define ASCII_ISALPHA(c) \ + (ASCII_ISUPPER(c) || ASCII_ISLOWER(c)) +#define ASCII_ISALNUM(c) \ + (ASCII_ISDIGIT(c) || ASCII_ISUPPER(c) || ASCII_ISLOWER(c)) + +#define ASCII_TOUPPER(c) \ + (('a' <= (c) && (c) <= 'z') ? ((c) - 'a' + 'A') : (c)) +#define ASCII_TOLOWER(c) \ + (('A' <= (c) && (c) <= 'Z') ? ((c) - 'A' + 'a') : (c)) + +int +idn__util_asciihaveaceprefix(const char *str, const char *prefix) { + assert(str != NULL && prefix != NULL); + + while (*prefix != '\0') { + if (ASCII_TOLOWER(*str) != ASCII_TOLOWER(*prefix)) + return 0; + str++; + prefix++; + } + + return (1); +} + +int +idn__util_ucs4haveaceprefix(const unsigned long *str, const char *prefix) { + assert(str != NULL && prefix != NULL); + + while (*prefix != '\0') { + if (ASCII_TOLOWER(*str) != ASCII_TOLOWER(*prefix)) + return 0; + str++; + prefix++; + } + + return (1); +} + +int +idn__util_ucs4isasciirange(const unsigned long *str) { + while (*str != '\0') { + if (*str > 0x7f) + return (0); + str++; + } + + return (1); +} + +#ifdef WIN32 +int +idn__util_getregistrystring(idn__util_hkey_t topkey, const char *name, + char *str, size_t length) +{ + HKEY top; + LONG stat; + HKEY hk; + DWORD len, type; + + assert((topkey == idn__util_hkey_currentuser || + topkey == idn__util_hkey_localmachine) && + name != NULL && str != NULL); + + if (topkey == idn__util_hkey_currentuser) { + top= HKEY_CURRENT_USER; + } else { /* idn__util_hkey_localmachine */ + top = HKEY_LOCAL_MACHINE; + } + + stat = RegOpenKeyEx(top, IDNKEY_IDNKIT, 0, KEY_READ, &hk); + if (stat != ERROR_SUCCESS) { + return (0); + } + + len = (DWORD)length; + stat = RegQueryValueEx(hk, (LPCTSTR)name, NULL, + &type, (LPBYTE)str, &len); + RegCloseKey(hk); + + if (stat != ERROR_SUCCESS || type != REG_SZ) { + return (0); + } + + return (1); +} +#endif /* WIN32 */ diff --git a/contrib/idn/idnkit-1.0-src/lib/version.c b/contrib/idn/idnkit-1.0-src/lib/version.c new file mode 100644 index 0000000..31fdba7 --- /dev/null +++ b/contrib/idn/idnkit-1.0-src/lib/version.c @@ -0,0 +1,54 @@ +#ifndef lint +static char *rcsid = "$Id: version.c,v 1.1.1.1 2003/06/04 00:26:45 marka Exp $"; +#endif + +/* + * Copyright (c) 2001 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 <config.h> + +#include <idn/version.h> + +const char * +idn_version_getstring(void) { + return IDNKIT_VERSION; +} |