]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
import of idnkit 1.0 from JPNIC see http://www.nic.ad.jp/en/idn/index.html
authorMark Andrews <marka@isc.org>
Wed, 4 Jun 2003 00:27:55 +0000 (00:27 +0000)
committerMark Andrews <marka@isc.org>
Wed, 4 Jun 2003 00:27:55 +0000 (00:27 +0000)
190 files changed:
contrib/idn/idnkit-1.0-src/ChangeLog [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/DISTFILES [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/INSTALL [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/INSTALL.ja [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/LICENSE.txt [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/Makefile.in [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/NEWS [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/README [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/README.ja [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/acconfig.h [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/aclocal.m4 [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/config.guess [new file with mode: 0755]
contrib/idn/idnkit-1.0-src/config.sub [new file with mode: 0755]
contrib/idn/idnkit-1.0-src/configure [new file with mode: 0755]
contrib/idn/idnkit-1.0-src/configure.in [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/include/Makefile.in [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/include/config.h.in [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/include/config.h.win [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/include/idn/Makefile.in [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/include/idn/aliaslist.h [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/include/idn/api.h [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/include/idn/assert.h [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/include/idn/checker.h [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/include/idn/converter.h [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/include/idn/debug.h [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/include/idn/delimitermap.h [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/include/idn/export.h [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/include/idn/filechecker.h [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/include/idn/filemapper.h [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/include/idn/localencoding.h [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/include/idn/log.h [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/include/idn/logmacro.h [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/include/idn/mapper.h [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/include/idn/mapselector.h [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/include/idn/nameprep.h [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/include/idn/normalizer.h [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/include/idn/punycode.h [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/include/idn/race.h [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/include/idn/res.h [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/include/idn/resconf.h [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/include/idn/result.h [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/include/idn/strhash.h [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/include/idn/ucs4.h [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/include/idn/ucsmap.h [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/include/idn/ucsset.h [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/include/idn/unicode.h [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/include/idn/unormalize.h [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/include/idn/utf8.h [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/include/idn/util.h [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/include/idn/version.h [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/include/mdn/Makefile.in [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/include/mdn/api.h [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/include/mdn/localencoding.h [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/include/mdn/log.h [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/include/mdn/res.h [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/include/mdn/resconf.h [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/include/mdn/result.h [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/include/mdn/utf8.h [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/include/mdn/version.h [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/install-sh [new file with mode: 0755]
contrib/idn/idnkit-1.0-src/lib/Makefile.in [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/aliaslist.c [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/aliaslist.sh [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/api.c [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/checker.c [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/converter.c [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/debug.c [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/delimitermap.c [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/filechecker.c [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/filemapper.c [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/idn.conf.sample.in [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/localencoding.c [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/log.c [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/make.wnt [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/mapper.c [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/mapselector.c [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/nameprep.c [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/nameprep_template.c [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/nameprepdata.c [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/normalizer.c [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/punycode.c [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/race.c [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/res.c [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/resconf.c [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/result.c [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/strhash.c [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/tests/Makefile.in [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/tests/api-init1.tsy [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/tests/api-init2.tsy [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/tests/api-init3.tsy [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/tests/api-init4-1.tsy [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/tests/api-init4-2.tsy [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/tests/api-init4-3.tsy [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/tests/api-init5-1.tsy [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/tests/api-init5-2.tsy [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/tests/api-init5-3.tsy [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/tests/api.tsy [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/tests/checker.tsy [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/tests/codeset.h [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/tests/converter.tsy [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/tests/delimitermap.tsy [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/tests/iconvchk.c [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/tests/mapper.tsy [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/tests/mapselector.tsy [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/tests/nameprep.tsy [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/tests/normalizer.tsy [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/tests/res.tsy [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/tests/resconf.tsy [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/tests/setenv.c [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/tests/setenv.h [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/tests/testsuite.c [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/tests/testsuite.h [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/tests/testutil.c [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/tests/testutil.h [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/tests/testygen [new file with mode: 0755]
contrib/idn/idnkit-1.0-src/lib/tests/ucs4.tsy [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/tests/utffilter [new file with mode: 0755]
contrib/idn/idnkit-1.0-src/lib/ucs4.c [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/ucsmap.c [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/ucsset.c [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/unicode.c [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/unicode_template.c [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/unicodedata_320.c [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/unormalize.c [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/utf8.c [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/util.c [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/lib/version.c [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/ltconfig [new file with mode: 0755]
contrib/idn/idnkit-1.0-src/ltmain.sh [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/make.wnt [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/man/Makefile.in [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/man/idn.conf.5.in [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/man/libidnkit.3.in [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/map/Makefile.in [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/map/jp.map [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/mkinstalldirs [new file with mode: 0755]
contrib/idn/idnkit-1.0-src/patch/bind9/bind-9.2.1-patch [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/patch/bind9/bind-9.2.2-patch [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/tools/Makefile.in [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/tools/idnconv/Makefile.in [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/tools/idnconv/idnconv.1 [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/tools/idnconv/idnconv.c [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/tools/idnconv/idnslookup.in [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/tools/idnconv/make.wnt [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/tools/idnconv/selectiveencode.c [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/tools/idnconv/selectiveencode.h [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/tools/idnconv/util.c [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/tools/idnconv/util.h [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/tools/make.wnt [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/tools/rpm/idnkit.spec [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/tools/runidn/Makefile.in [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/tools/runidn/resolver.c [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/tools/runidn/resolver.h [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/tools/runidn/runidn.1 [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/tools/runidn/runidn.in [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/tools/runidn/stub.c [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/tools/runidn/stub.h [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/util/Makefile [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/util/SparseMap.pm [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/util/UCD.pm [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/util/generate_nameprep_data.pl [new file with mode: 0755]
contrib/idn/idnkit-1.0-src/util/generate_normalize_data.pl [new file with mode: 0755]
contrib/idn/idnkit-1.0-src/win/README.WIN [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/wsock/README.txt [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/wsock/README_j.txt [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/wsock/common/checkdll.c [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/wsock/common/convert.c [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/wsock/common/dump.c [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/wsock/common/encoding.c [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/wsock/common/hook.c [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/wsock/common/make.wnt [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/wsock/common/printf.c [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/wsock/common/wrapcommon.h [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/wsock/config/idnconf.tcl [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/wsock/config/make.wnt [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/wsock/make.wnt [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/wsock/wsock11/dlldef.h [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/wsock/wsock11/dllfunc.c [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/wsock/wsock11/dllload.c [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/wsock/wsock11/dllmain.c [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/wsock/wsock11/dllstub.c [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/wsock/wsock11/make.wnt [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/wsock/wsock11/wsock32.def [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/wsock/wsock20/dlldef.h [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/wsock/wsock20/dllfunc.c [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/wsock/wsock20/dllload.c [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/wsock/wsock20/dllmain.c [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/wsock/wsock20/dllstub.c [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/wsock/wsock20/make.wnt [new file with mode: 0644]
contrib/idn/idnkit-1.0-src/wsock/wsock20/ws2_32.def [new file with mode: 0644]

diff --git a/contrib/idn/idnkit-1.0-src/ChangeLog b/contrib/idn/idnkit-1.0-src/ChangeLog
new file mode 100644 (file)
index 0000000..085e3bd
--- /dev/null
@@ -0,0 +1,856 @@
+2003-03-16
+       * idnkit 1.0 release.
+
+       * DISTFILES, README, README.ja, INSTALL, INSTALL.ja: delete BIND8,
+       Squid and libiconv patches.
+
+2003-03-13
+       * wsock/config/idnconf.tcl: change the version number to '1.0'.
+
+2003-03-12
+       * Makefile.in, lib/Makefile.in: Add 'make install-config' to
+       Makefile target.
+
+2003-03-11
+       * patch/bind9/bind-9.2.2-patch: created.
+
+2003-03-06
+       * lib/punycode.c: idn__punycode_encode() outputs an error message
+       if the input string is over PUNYCODE_MAXINPUT (the value is 3800).
+
+2003-03-05
+       * include/idn/api.h, include/idn/checker.h,
+       include/idn/nameprep.h, include/idn/res.h, include/idn/version.h,
+       lib/Makefile.in, lib/checker.c, lib/idn.conf.sample.in,
+       lib/mapper.c, lib/nameprep.c, lib/nameprepdata.c,
+       lib/normalizer.c, lib/tests/checker.tsy, lib/tests/mapper.tsy,
+       lib/tests/nameprep.tsy, lib/tests/normalizer.tsy,
+       man/idn.conf.5.in, tools/idnconv/idnconv.1, wsock/bin/idn.conf:
+       Add NAMEPREP version 'RFC3491', and remove 'nameprep-11'.
+
+2003-02-18
+       * lib/tests/api-init1.tsy, lib/tests/api-init2.tsy,
+       lib/tests/api-init3.tsy, lib/tests/api-init4-1.tsy,
+       lib/tests/api-init4-2.tsy, lib/tests/api-init4-3.tsy,
+       lib/tests/api-init5-1.tsy, lib/tests/api-init5-2.tsy,
+       lib/tests/api-init5-3.tsy, lib/tests/api.tsy, lib/tests/converter.tsy,
+       lib/tests/res.tsy, lib/tests/punycode.c: Change ACE prefix of Punycode
+       from `zq--' to `xn--'.
+       
+2003-02-13
+       * lib/make.wnt: remove dependencies on obsolete files.
+
+       * INSTALL, INSTALL.ja, configure.in, aclocal.m4: Delete configure's
+       --with-punycode-prefix option.
+
+2003-02-05
+       * lib/res.c: improve performance when encoding/decoding
+       loooooooong domain names.
+
+2003-01-22
+       * lib/res.c: idn_res_encodename() and idn_res_decodename() in
+       libidnkit returns `idn_invalid_name' if local converter is not
+       available.
+
+2003-01-20
+       * lib/normalize.c, lib/unormalize.c, include/idn/unormalize.h,
+       lib/tests/normalizer.tsy: unicode-form-c or unicode-form-c/3.2.0 is
+       no longer supported.
+
+       * lib/mapselector.c, lib/tests/mapselector.tsy:
+       idn_mapselector_add() outputs an error message if invalid scheme
+       name or TLD is given.
+
+       * lib/checker.c, lib/normalizer.c, lib/mapselector.c, lib/res.c:
+       modify error messages.
+
+       * lib/result.c: modify an error message for `idn_invalid_length'.
+
+2003-01-16
+       * lib/checker.c, lib/idn.conf.sample.in, lib/mapper.c, lib/nameprep.c,
+       lib/normalizer.c, lib/unicode.c, lib/tests/checker.tsy, 
+       lib/tests/mapper.tsy, lib/tests/nameprep.tsy, lib/tests/normalizer.tsy,
+       man/idn.conf.5.in, tools/idnconv/idnconv.1:
+       delete support for nameprep-03 and nameprep-09.
+
+       * lib/unicodedata_301.c, lib/unicodedata_310.c, DISTFILES:
+       unicodedata_301.c and unicodedata_310.c are removed.
+
+2003-01-14
+       * tools/idnconv/idnconv.c, tools/idnconv/util.c, tools/idnconv/util.h:
+       remove the restriction on the length of input lines.  idnconv can
+       now handle very long lines.
+
+2003-01-10
+       * lib/converter.c: fix a bug in extending intermediate buffer
+       in converter_iconv_convtoucs4(), which causes incorrect
+       codeset conversion when the input string is very long.
+
+2002-12-06
+       * idnkit 1.0pr2 release (preview release).
+
+2002-12-03
+       * lib/mapper.c, lib/normalize.c: Don't check whether an input string
+       is STD3 ASCII label.
+       lib/res.c: Skip localmap if the string is STD3 ASCII label.
+       
+2002-12-02
+       * lib/tests/iconvchk.c, lib/tests/Makefile.in: enable to check
+       whether codeset names "eucJP" and "SJIS" are available in iconv.
+
+2002-12-01
+       * tools/runidn/stub.c: use RTLD_NEXT for dlsym() if it is available.
+
+2002-11-29
+       * almost all files: change the license terms.
+
+2002-11-25
+       * lib/tests/codeset.h: define character encoding names here.
+       * lib/tests/api-init1.tsy, lib/tests/api-init2.tsy,
+       lib/tests/api-init3.tsy, lib/tests/api-init4-3.tsy, 
+       lib/tests/api-init5-3.tsy, lib/tests/converter.tsy,
+       lib/tests/mapselector.tsy, lib/tests/resconf.tsy: include `codeset.h'.
+       lib/tests/api-init4-1.tsy, lib/tests/api-init4-2.tsy, 
+       lib/tests/api-init5-1.tsy, lib/tests/api-init5-2.tsy,
+       lib/tests/mapselector.tsy, lib/tests/resconf.tsy:
+       Delete the unused cpp macro EUCJP_ENCODING_NAME.
+       * INSTALL, INSTALL.ja: describe `lib/tests/codeset.h'.
+
+       * lib/converter.c: Fix bugs in converter_uescape_convfromucs4()
+       and converter_uescape_convtoucs4() that libidnkit might crash
+       when `from' is very long.
+
+2002-11-15
+       * Makefile.in: `make distclean' also removes `libtool'.
+
+2002-10-25
+       * lib/resconf.c: enable the IDN_CONVERTER_RTCHECK flag when it
+       calls idn_converter_create().
+       * tools/idnconv/util.c: enable the IDN_CONVERTER_RTCHECK flag
+       when it calls idn_converter_setlocalconvertername() or 
+       idn_converter_setidnconvertername().
+
+2002-09-20
+       * wsock/README.txt, wsock/README_j.txt: add description on
+       "Force local DLL reference" button.
+
+2002-09-19
+       * idnkit 1.0pr1 release (preview release).
+
+2002-09-13
+       * README, README.ja: update URIs.
+
+       * lib/Makefile.in, lib/tests/Makefile.in: generate libidntest and
+       libidntestlite for test programs.
+
+2002-09-09
+       * wsock/wsock11/dlldef.h, wsock/wsock11/dllfunc.c,
+       wsock/wsock11/dllload.c, wsock/wsock11/dllmain.c,
+       wsock/wsock20/dlldef.h, wsock/wsock20/dllfunc.c,
+       wsock/wsock20/dllload.c, wsock/wsock20/dllmain.c: take out
+       DLL load/unload from DllMain(). load/unload is delayed until
+       it is really necessary.
+       * wsock/common/checkdll.c, wsock/common/wrapcommon.h: move DLL
+       load/unload functions from wsock/{ws11,ws20}/dllmain.c.
+       * wsock/printf.c: make logging more effective.
+
+       * DISTFILES: remove wsock/common/dllmain.c, which is no longer used.
+
+2002-09-05
+       * lib/mapper.c: fix a bug that idn_mapper_add(ctx, "filemap") aborts.
+
+2002-09-04
+       * lib/nameprep.c: GCC says that a variable declared in
+       idn_nameprep_isvalidbidi() might be used uninitialized.  Fixed.
+
+       * wsock/common/convert.c, wsock/common/printf.c,
+       wsock/common/wrapcommon.h: always reset log output callback procedure
+       before calling idnkit library functions.
+       * wsock/wsock11/dllmain.c, wsock/wsock20/dllmain.c: reset
+       log output callback before unloading.
+
+2002-09-03
+       * lib/tests/testygen, lib/tests/testsuite.c, lib/tests/testsuite.h:
+       add verbose and partial exec modes.
+
+2002-08-29
+       * idnkit 020829 snapshot release.
+
+2002-08-28
+       * lib/tests/testygen: fix generation of main().  It didn't destroy
+       a testsuite context.
+       * lib/tests/testsuite.c: fix a double free bug in
+       idn_testsuite_destroy().
+
+       * lib/filemapper.c: fix one memory leak in read_file().
+       * lib/filemapper.c: fix buffer expansion bug in ucsbuf_grow().
+       * lib/res.c: plug up memory leak in idn_res_decodename().
+
+       * lib/tests/setenv.c: fix memory leak bug.
+
+       * lib/filemapper.c, lib/ucsmap.c, lib/ucsset.c: fix misuse of
+       realloc().
+
+       * lib/converter.c: plug up memory leak in
+       converter_iconv_openfromucs4() and converter_iconv_opentoucs4().
+
+2002-08-27
+       * lib/tests/Makefile.in: support the case where the build directory
+       is different from the source directory.
+
+       * lib/tests/Makefile.in: perform tests for lite library only if
+       `--enable-liteonly' has been specified at configuration.
+
+       * lib/tests/setenv.c, lib/tests/setenv.h, lib/tests/Makefile.in,
+       configure.in: support systems which lack setenv() and/or unsetenv().
+
+       * configure.in, lib/Makefile.in, lib/idn.conf.sample, INSTALL,
+       INSTALL.ja: delete `--with-preference'.
+
+2002-08-26
+       * lib/tests/testygen: new option `-L', which suppresses `#line'
+       cpp lines on output.
+
+       * DISTFILES: Add files for tests.
+       * INSTALL, INSTALL.ja: add the `Test' section.
+
+       * lib/resconf.c: fix trace message of idn_resconf_create().
+
+       * win/README.WIN: update the contents.
+
+       * wsock/config/idnconf.tcl: do not display `force local DLL
+       reference' button on Windows 95 and NT, since it is meaningless
+       for these old OSes.
+
+2002-08-22
+       * lib/mapper.c, lib/normalizer.c: add the procedure for the case
+       that ctx->nschems is 0 to idn_mapper_map() and
+       idn_normalizer_normalize().
+
+       * lib/delimitermap.c: idn_delimitermap_add() and 
+       idn_delimitermap_addall() reject a request to add an invalid
+       codepoint.
+
+2002-08-21
+       * lib/api.c: fix a bug that api_nameinit() didn't call
+       idn_resconf_initialize().
+       * lib/api.c: don't set the `ininitialized' flag if idn_nameinit()
+       returns with an error.
+       * lib/api.c, include/idn/api.h: add idn__setconffile().
+
+       * lib/mapselector.c: idn_mapselector_map() and idn_mapselector_map2()
+       now accept `tld' beginning with a dot.
+
+2002-08-20
+       * wsock/common/checkdll.c: back out 0812 change because the check
+       method doesn't seem to work correctly on WinMe.
+       * wsock/wsock11/dllload.c, wsock/wsock20/dllload.c: add some trace
+       statements.
+       * wsock/config/idnconf.tcl: do not install winsock2 wrapper on
+       Win98/Me.
+
+       * lib/tests/testsuite.c, lib/tests/testsuite.h, lib/tests/testygen:
+       exit the testcase if ASSERT fails.
+
+       * lib/tests/testsuite.c, lib/tests/testsuite.h:
+       replace ASSERT_PTRNOTNULL with ASSERT_PTR_NE.
+
+       * lib/tests/testutil.c, lib/testuil.h: new file.
+       It provides create_conf_file().
+
+2002-08-19
+       * lib/resconf.c: if application calls idn_resconf_create() before 
+       idn_resconf_initialize(), idnkit returns `idn_failure'.
+
+2002-08-15
+       * lib/tests/testsuite.c, lib/tests/testsuite.h, lib/tests/testygen:
+       add two assertion macros: ASSERT_PTR and ASSERT_PTRNOTNULL.
+
+       * lib/converter.c: fix some warning messages.
+
+2002-08-14
+       * lib/resconf.c: fix a but that idnkit aborts if a line in config
+       file lacks an argument.
+
+       * wsock/common/hook.c, wsock/wsock11/dllfunc.c, wsock/wsock20/dllfunc.c
+       : make name resolver APIs return the domain name verbatim (instead
+       of returning error) when name decoding fails.
+
+2002-08-13
+       * lib/Makefile.in, lib/checker.c, lib/converter.c, lib/delimitermap.c,
+       lib/filechecker.c, lib/filemapper.c, lib/mapper.c, lib/mapselector.c,
+       lib/nameprep.c, lib/normalizer.c, lib/punycode.c, lib/race.c,
+       lib/resconf.c, lib/unormalize.c: delete main routines for test.
+
+       * lib/tests/: new directory.
+       * configure.in: Check for path of perl command.
+
+       * wsock/config/idnconf.tcl: correct OS version check routine.
+
+2002-08-12
+       * lib/make.wnt: change amcacez.* to punycode.*.
+       * wsock/common/encoding.c, wsock/common/dump.c, wsock/common/convert.c,
+       wsock/commn/hook.c, wsock/common/printf.c, wsock/common/wrapcommon.h,
+       wsock/wsock11/dllfunc.c, wsock/wsock11/dllload.c,
+       wsock/wsock20/dllfunc.c, wsock/wsock20/dllload.c: add extra argument
+       (specifying buffer length) to some interface functions, in order to
+       prevent possible buffer overflow.
+       * wsock/common/printf.c: increase message buffer size.
+       * wsock/wsock11/dllmain.c, wsock/wsock20/dllmain.c: call initialize
+       routine before first log output.
+       * wsock/common/checkdll.c: use light-weight DLL checking using
+       LoadLibraryEx.
+
+       * lib/res.c: fix bugs in idn_res_encodename(), idn_res_decodename()
+       and idn_res_decodename2().  They fell into infinite loops when
+       given `tolen' is 0.
+
+2002-08-08
+       * lib/resconf.c, lib/res.c: remove unused functions and variables.
+
+       * lib/Makefile.in tools/idnconv/Makefile.in,
+       tools/runidn/Makefile.in: add @CPPFLAGS@ to $(CFLAGS).
+
+       * lib/res.c: idn_res_decodename2() copies `from' to `to' and
+       returns immediately when the `actions' argument is 0.
+
+2002-08-07
+       * lib/resconf.c: fix a bug in parse_conf() that if `nameprep' or
+       `idn-encoding' directive is defined twice, default value is set
+       to the directive.
+       * lib/resconf.c: cosmetic changes.
+       delete parse_map(), parse_normalize(), parse_prohibit(),
+       parse_unassigned() and parse_bidi().
+
+       * lib/amcacez.c, include/idn/amcacez.h: renamed to lib/punycode.c
+       and include/idn/punycode.h.
+
+       * include/idn/converter.h, lib/converter.h: define
+       idn_converter_getrealname() externally instead of statically
+       defined get_realname().
+
+2002-08-06
+       * lib/resconf.c: arrange processes of obsolete commands in
+       idn_res_loadfile().
+
+       * INSTALL, INSTALL.ja, man/idn.conf.5.in, tools/idnconv/idnconv.1:
+       remove description of RACE and AMC-ACE-Z.
+
+       * lib/resconf.c: fix a bug in handling of local-converter.
+
+       * lib/converter.c: add initialization check in
+       idn_converter_aliasfile() and idn_converter_resetalias().
+
+       * lib/converter.c: free context memory at some right places in
+       idn_converter_create().
+
+2002-08-05
+       * configure.in, lib/Makefile.in, lib/aliaslist.sh: also add the
+       "UTF-8" entry if --with-utf8=NAME option of configure is specified,
+       and NAME is not "UTF-8".
+
+       * tools/idnconv/idnconv.c: call idn_converter_destroy() after
+       idn_resconf_getidnconverter() and idn_resconf_getlocalconverter()
+       in main().
+
+       * lib/res.c: fix a bug in idn_res_decodename2().
+       When the function called idn_res_decodename(), assertion check in
+       idn_res_decodename() may have failed.
+
+       * lib/res.c: call idn_delimitermap_destroy() after
+       idn_resconf_getdelimitermap() in idn_res_encodename() and
+       idn_res_decodename().
+       
+2002-08-02
+       * lib/res.c: fix mismatched pointer type in idn_res_decodename2().
+       * lib/res.c: fix a bug in handling of `auxencoding', in
+       idn_res_decodename2().
+
+2002-08-01
+       * lib/resconf.c: fix two memory leaks in parse_conf().
+
+       * lib/aliaslist.c: fix an error of size measurement in
+       create_item().
+
+2002-07-31
+       * lib/converter.c: AMC-ACE-Z and RACE are now extra ACE.
+
+2002-07-30
+       * idnkit 020730 snapshot release.
+
+       * lib/resconf.c: fix a bug in idn_resconf_create() that it
+       misses initializing `ctx->bidi_checker'.
+
+2002-07-29
+       * tools/idnconv/idnconv.1: describe bidi character check.
+
+2002-07-24
+       * lib/resconf.c: force to add bidi checker at parsing nameprep
+       entry in config file.
+
+2002-07-19
+       * include/idn/checker.h, include/idn/nameprep.h,
+       include/idn/res.h, include/idn/resconf.h, man/idn.conf.5.in,
+       man/libidnkit.3.in, lib/checker.c, lib/nameprep.c, lib/res.c,
+       lib/resconf.c, tools/idnconv/idnconv.c: add bidirectional label
+       check routine.
+
+       * include/idn/api.h, include/idn/res.h, lib/api.c, lib/res.c,
+       tools/idnconv/idnconv.c, tools/idnconv/util.c,
+       tools/idnconv/util.h: change the type of action flag at conversion
+       functions and define it as ``idn_action_t''.
+
+2002-07-18
+       * wsock/config/idnconf.tcl: implement .exe.local file
+       creation/deletion feature.
+       * lib/make.wnt: update list of files according to the recent
+       changes of the library.
+
+2002-07-12
+       * include/idn/nameprpe.h: define idn_biditype_t.
+       * lib/nameprep_template.c, lib/nameprep.c: support for bidi type
+       check is added.
+
+2002-07-11
+       * idnkit 020711 snapshot release.
+
+2002-07-09
+       * man/Makefile.in, man/idn.conf.5.in: force to make and install
+       manpage of idnalias.conf (merely a copy of idn.conf's manpage).
+
+2002-07-08
+       * DISTFILES: `lib/dude.c' and `include/idn/dude.h' are removed.
+       * DISTFILES: `util/Makefile' is added.
+
+       * tools/idnconv/idnconv.c: fix typo in decode_file().
+
+       * tools/idnconv/idnconv.c: Support "-reverse -out ACE".
+
+       * lib/res.c: fix bugs in label_idndecode() and label_idnencode_ace().
+       If UCS4 to UTF-8 conversion is failed with idn_buffer_overflow,
+       we must extends the size of local buffer and try the conversion
+       again.
+
+2002-07-05
+       * tools/idnconv/idnconv.c: treat input as the string of the local
+       encoding specified by "-out" option at reverse conversion.
+
+       * include/idn/api.h, lib/api.c: add idn_decodename2() function.
+
+       * include/idn/res.h, lib/res.c: add idn_res_decodename2()
+       function.
+
+       * include/idn/res.h, lib/res.c: restore IDN_DELIMMAP flag.
+
+2002-07-02
+       * lib/unicodedata_320.c, lib/checker.c, lib/idn.conf.sample.in,
+       lib/mapper.c, lib/nameprep.c, lib/nameprepdata.c, lib/normalizer.c,
+       lib/unicode.c, unicodedata_320.c, include/idn/nameprep.c, DISTFILES,
+       man/idn.conf.5.in: Support NAMEPREP-11 which adopts Unicode-3.2.
+       Support for NAMEPREP-06, -08, -09 are removed.
+
+2002-07-01
+       * tools/idnconv/idnconv.1: added `-A' option.
+
+       * include/idn/res.h, lib/res.c: redefine IDN_ENCODE_QUERY,
+       IDN_DECODE_QUERY, IDN_ENCODE_STORED, IDN_DECODE_STORED, IDN_ENCODE_APP
+       and IDN_DECODE_APP.
+
+2002-06-26
+       * lib/resconf.c, include/idn/resconf.h: define
+       idn_resconf_getauxidnconverter(), idn_resconf_setauxidnconverter()
+       and idn_resconf_setauxidnconvertername().
+
+2002-06-20
+       * lib/res.c: use action flags at round trip check.
+
+2002-06-19
+       * include/idn/res.h, lib/res.c: remove IDN_UNASCHECK flag from
+       IDN_NAMEPREP.
+
+       * include/idn/res.h, lib/res.c: add IDN_ENCODE_QUERY,
+       IDN_DECODE_QUERY, IDN_ENCODE_STORED, and IDN_DECODE_STORED flags.
+
+       * include/idn/res.h, lib/res.c: IDN_ENCODE_APP and IDN_DECODE_APP
+       have same value as flags for conversion of the query string
+       (IDN_ENCODE_QUERY and IDN_DECODE_QUERY) now.
+
+2002-06-17
+       * include/idn/Makefile.in, lib/Makefile.in, lib/converter.c,
+       tools/runidn/Makefile.in, configure, INSTALL, INSTALL.ja:
+       delete DUDE support.
+       * include/idn/dude.h, lib/dude.c: deleted.
+
+       * README, README.ja: update URL of mdnkit FAQ.
+
+       * include/idn/res.h, lib/res.c, lib/idn.conf.sample.in,
+       lib/delimitermap.c, man/libidnkit.3.in: add default delimiters
+       defined in IDNA specification and always forced to do delimiter
+       mapping.
+
+       * lib/resconf.c, man/idn.conf.5.in: remove "delimiter-map" entry
+       support of configuration file.
+
+       * tools/idnconv/idnconv.c, tools/idnconv/idnconv.1: remove
+       "-delimiter-map" and "-d" options.
+
+2002-06-13
+       * wsock/common/encoding.c: fix registry key setting so that
+       it matches what documents say.
+
+2002-06-11
+       * include/idn/delimitermap.h: remove idn_delimitermap_fix()
+       declaration.
+
+2002-06-10
+       * wsock/wsock2/dllfunc.c: fix a bug which makes wrapping of
+       getaddrinfo()/getnameinfo() always fail.
+
+2002-06-05
+       * wsock/wsock2/dllfunc.c, wsock/wsock2/dllstub.c,
+       wsock/wsock2/ws2_32.def: add new APIs introduced by WinXP.
+
+2002-05-22
+       * tools/idnconv/util.c: reset alias information before loading
+       alias information file.
+
+2002-05-20
+       * idnkit 1.0rc1 release.
+
+       * include/idn/res.h: fix typo in a comment.
+
+2002-05-17
+       * include/idn/version.h: set IDNKIT_VERSION to "1.0rc1".
+
+2002-05-13
+       * tools/rpm/mdnkit.spec: renamed to idnkit.spec, and revised
+       for idnkit-1.0.
+
+2002-05-09
+       * tools/idnconv/idnconv.c: now `idnconv -r' can convert a file
+       from ACE to ACE.
+
+2002-05-08
+       * lib/idn.conf.sample.in: delete "encoding-alias-file" entry
+       because idnkit does not support it any longer.
+
+       * lib/nameprepdata.c lib/nameprep.c, lib/mapper.c, lib/normalizer.c,
+       lib/checker.c, lib/idn.conf.sample.in, man/idn.conf.5.in,
+       tools/idnconv/idnconv.1: support NAMEPREP-09.
+
+       * lib/mapper.c, lib/normalizer.c, lib/checker.c, lib/mapselector.c, 
+       * lib/res.c, lib/race.c: spmplify local buffer managements.
+
+       * tools/idnconv/idnconv.c, tools/idnconv/util.c, tools/idnconv/util.h:
+       fix a bug that wrong local encoding is set to a resconf context.
+       
+2002-05-07
+       * tools/idnconv/util.c: delete set_reverse_context().
+       * tools/idnconv/idnconv.c: fix a serious bug in -reverse conversion.
+
+2002-05-04
+       * include/idn/util.h, lib/converter.c, lib/resconf.c, lib/util.c:
+       simplify Windows registry retrieval function interface.
+       * wsock/common/convert.c, wsock/common/dump.c,
+       wsock/common/encoding.c, wsock/common/wrapcommon.h: fix type
+       conflicts.
+       * wsock/wsock11/dlldef.h, wsock/wsock11/dllmain.c,
+       wsock/wsock20/dlldef.h, wsock/wsock20/dllmain.c: fix typo.
+       * wsock/common/jpnicmdn.def, wsock/common/jpnicmdn.h,
+       wsock/config/mdnconf.tcl: removed.
+       * DISTFILES: add new files, remove obsolete files.
+       
+2002-05-02
+       * tools/idnconv/util.c: create a new function set_reverse_context().
+       * tools/idnconv/idnconv.c: fix a bug in handing of reference count
+       of idn_resconf_t contexts.
+
+       * lib/amcacez.c, lib/race.c, lib/dude.c, lib/delimitermap.c,
+       lib/checker.c, lib/mapper.c, lib/mapselector.c, lib/converter.c,
+       lib/normalizer.c, lib/res.c, lib/ucs4.c, lib/debug.c,
+       include/idn/debug.h: output valuable trace logs for developpers.
+
+       * lib/res.c: fix double free bugs.
+
+       * lib/checker.c, include/idn/checker.h: for symbols of the checker
+       module, use `idn_' prefix instead of `idn__' by default.
+
+       * wsock/common/checkdll.c, wsock/common/convert.c,
+       wsock/common/dump.c, wsock/common/encoding.c, wsock/common/hook.c,
+       wsock/common/printf.c, wsock/common/make.wnt,
+       wsock/wsock11/dlldef.h, wsock/wsock11/dllfunc.c,
+       wsock/wsock11/dllload.c , wsock/wsock11/dllmain.c,
+       wsock/wsock11/dllstub.c, wsock/wsock11/make.wnt,
+       wsock/wsock20/dlldef.h, wsock/wsock20/dllfunc.c,
+       wsock/wsock20/dllload.c , wsock/wsock20/dllmain.c,
+       wsock/wsock20/dllstub.c, wsock/wsock20/make.wnt: adapt idnkit
+       interface, change name from `mDN Wrapper' to `idn wrapper'.
+       * wsock/common/wrapcommon.h: created.
+       * wsock/config/idnconf.tcl: created.
+
+2002-05-01
+       * include/idn/util.h, lib/converter.c, lib/resonf.c, lib/util.c:
+       Move alias information initialization scheme from the resconf
+       context initialization to the converter module initialization.
+
+       * tools/idnconv/idnconv.c: fix a bug in main().
+       Wrong localconverer/idnconverter may be set to resconf2.
+
+2002-04-30
+       * lib/res.c, tools/idnconv/idnconv.c: accept non-ace encoding as
+       idn-encoding and ace encoding as local-encoding at normal conversion.
+
+2002-04-23
+       * man/idn.conf.5.in: use the term "unassigned codepoint", not
+       "unassigned character".
+
+2002-04-19
+       * include/idn/api.h, include/idn/res.h:
+       delete cpp macros for backward compatibility, since they are defined
+       in include/mdn/api.h and include/mdn/res.h.
+
+       * include/idn/checker.h, include/idn/converter.h,
+       include/idn/delimitermap.h, include/idn/filechecker.h, 
+       include/idn/filemapper.h, include/idn/mapper.h,
+       include/idn/mapselector.h, include/idn/nameprep.h,
+       include/idn/normalizer.h, include/idn/unormalize.h:
+       fix obsolete descriptions.
+
+2002-04-17
+       * idnkit 1.0beta2 release.
+       
+2002-04-16
+       * configure.in: check AC_FIND_SYSTEM_SHOBJ(libnsl),
+       AC_CHECK_LIB(socket, socket) and AC_CHECK_LIB(nsl, inet_addr)
+       in case of --enable-runidn.
+
+2002-04-15
+       * tools/idnconv/idnconv.1: fix the "REVERSE CONVERSION MECHANISM"
+       section.
+
+2002-04-12
+       * lib/res.c, include/idn/res.h: rename `idn_res_actionstostring()'
+       to `idn__res_actionstostring()'.
+       * lib/mapper.c, lib/checker.c, lib/converter.c: output trace log
+       which shows scheme a name the module is going to perform.
+
+2002-04-10
+       * man/idn.conf.5.in: delete the "SETFILE SECTION".
+
+2002-04-09
+       * tools/runidn/resolver.c: call idn_nameinit() and then call
+       idn_encodename() or idn_decodename().
+
+2002-04-08
+       * include/idn/export.h: created.
+       * include/idn/Makefile.h, DISTFILES: add export.h.
+       * include/idn/api.h, include/idn/converter.h, include/idn/debug.h,
+       include/idn/delimitermap.h, include/idn/localencoding.h,
+       include/idn/log.h, include/idn/mapper.h, include/idn/mapselector.h,
+       include/idn/nameprep.h, include/idn/normalizer.h, include/idn/res.h,
+       include/idn/resconf.h, include/idn/result.h, include/idn/ucs4.h,
+       include/idn/ucsmap.h, include/idn/ucsset.h, include/idn/unormalize.h,
+       include/idn/utf8.h, include/idn/version.h: include export.h. mark
+       exportable functions with IDN_EXPORT macro.
+       * lib/make.wnt: modify to create DLLs.
+       * configure.in: add existance check for pwd.h.
+       * configure, include/config.h.in: rebuilt.
+       * lib/resconf.c, lib/localencoding.c: port to Win32.
+       * include/mdn/version.h: include <idn/version.h> for the declaration
+       of idn_version_getstring().
+       * tools/make.wnt, tools/idnconv/make.wnt: created.
+       * make.wnt: add tools subdirectory.
+       * DISTFILES: add tools/make.wnt and tools/idnconv/make.wnt.
+
+       * include/idn/mapselector.h, lib/mapselector.c:
+       add idn_mapselector_getnotld() and idn_mapselector_getdefaulttld().
+       Instead delete idn_mapselector_no_tld and idn_mapselector_default.
+
+       * lib/api.c, include/mdn/api.h: define mdn_nameinit(),
+       mdn_encodename() and mdn_decodename().
+
+       * DISTFILES: delete `patch/bind8/bind-8.2.3-patch' and
+       `tools/rpm/mdnsproxy.init'.
+
+       * include/idn/aliaslist.h, include/idn/converter.h,
+       lib/aliaslist.c, lib/converter.c: enable to add an alias
+       information item to either top or bottom of the alias information
+       list.
+
+2002-04-05
+       * include/idn/resconf.h, lib/resconf.c: add
+       idn_resconf_setdefaults().
+       * lib/resconf.c: call idn_converter_aliasfile() at parsing the
+       default alias information file automatically.
+       * include/idn/api.h, lib/api.c: modify api_nameinit() to enable to
+       choose initialization scheme.
+
+       * tools/idnconv/idnconv.c, tools/idnconv/idnconv.1: delete `-map',
+       `-normalize', `-prohibit' and `-unassigned' options.
+       * tools/idnconv/idnconv.c: use default configuration if `-noconf'
+       is specified.
+       
+2002-04-04
+       * tools/idnconv/idnconv.1: fix obsolete description.
+       * tools/runidn/runidn.1: likewise.
+
+2002-04-02
+       * configure.in: add --enable-mdnkit-compat option.
+       * include/mdn/Makefile.in, include/mdn/api.h,
+       include/mdn/localencoding.h, include/mdn/log.h, include/mdn/res.h,
+       include/mdn/resconf.h, include/mdn/result.h, include/mdn/utf8.h,
+       include/mdn/version.h: re-added.
+       * include/Makefile.in: add `idn' to SUBDIRS.
+       * lib/Makefile.in, tools/idnconv/Makefile.in, tools/runidn/Makefile.in,
+       man/Makefile.in: support --enable-mdnkit-compat.
+       * lib/localencoding.c, lib/resconf.c: ditto.
+       * INSTALL: ditto.
+
+       * Makefile.in, include/Makefile.in, include/idn/Makefile.in,
+       include/mdn/Makefile, lib/Makefile.in, tools/Makefile.in,
+       tools/idnconv/Makefile.in, tools/runidn/Makefile.in,
+       man/Makefile.in, map/Makefile.in: support DESTDIR and distclean.
+
+2002-03-28
+       * include/idn/api.h: enclose the contents with `extern "C" {...}'
+       if C++ compiler is used.
+
+2002-03-27
+       * man/Makefile.in: generate and install idnrc.5.
+       * man/idn.conf.5.in: describe the user configuration file ~/.idnrc.
+
+       * tools/idnconv/idnconv.1: add missing description of -nolengthcheck,
+       -noasciicheck and -noroundtrip options.
+
+       * lib/checker.c, lib/mapper.c, lib/normalizer.c,
+       lib/idn.conf.sample.in, tools/idnconv/idnconv.1, man/idn.conf.5.in:
+       Add nameprep-08 support, and delete -05 and -07 instead.
+
+2002-03-26
+       * idnkit 1.0beta1 release.
+
+       * NEWS: add description about Major changes in mDNkit 2.3, 2.3.1,
+       2.4.
+       * NEWS: add description about Major changes in idnkit
+       version1.0beta1.
+
+2002-03-25
+       * DISTFILES: add bind-8.3.1-patch and bind-9.2.0-patch.
+       delete bind-9.1.3-patch.
+
+2002-03-22
+       * lib/mapselector.c: fix a bug in handling of the special TLD `-'.
+
+2002-03-20
+       * lib/converter.c: fix a bug in idn_converter_convtoucs4().
+
+       * lib/res.c: fix a bug that IDN_LENCHECK overlook an empty label
+       generated by nameprep-map or localmap (e.g. "XXX.\u{200b}").
+       * lib/res.c: fix a bug that libidnkit aborts when it decodes "."
+
+       * lib/Makefile.in, tools/runidn/Makefile.in: change library
+       version.
+       * include/idn/version.h: set version `1.0beta1'.
+
+       * configure, configure.in: modify some error messages.
+
+2002-03-19
+       * man/idn.conf.5.in, lib/idn.conf.sample.in, tools/idnconv/idnconv.1:
+       delete DUDE from a list of supported encodings.
+
+       * lib/aliaslist.c, lib/debug.c, lib/strhash.c, lib/ucs4.c: they are
+       private modules.
+
+       * include/idn/resolver.h: moved to tools/runidn/resolver.h.
+
+       * tools/runidn/Makefile.in, tools/idnconv/Makefile.in:
+       insert `-I$(srcdir)' into INCS.
+
+2002-03-18
+       * aclocal.m4, configure, configure.in, include/config.h.in,
+       Makefile.in, map/Makefile.in, src/lib/idn.conf.sample.in,
+       tools/idnconv/selectiveencode.h: replace `MDN' with `IDN'.
+
+       * lib/aliaslist.c: change WARNING message into INFO message when
+       idn_aliaslist_aliasfile() finds an error in alias information
+       file.
+       * lib/resconf.c: change user configuration file name.
+       * lib/resconf.c: add procedure to check the existence of default
+       alias information file before letting converter parse the file.
+       * lib/resconf.c: call idn_converter_aliasfile() even when basic
+       configuration files are not found at all.
+
+       * tools/idnconv/idnconv.c: use hexadecimal numbers for values
+       associated with FLAGS_ macros.
+
+       * include/idn/result.h, lib/result.c: rename `idn_too_long' to
+       `idn_invalid_length'.
+       * lib/res.c: In IDN_LENCHECK, return `idn_invalid_length' for an
+       empty label, but return `idn_success'' for the "." domain name.
+
+       * lib/converter.c: DUDE is now extra ACE.
+
+       * lib/mapselector.c, include/idn/mapselector.h: change types of
+       `idn_mapselector_no_tld' and `idn_mapselector_default' from
+       (const unsigned long []) to (const unsigned long *).
+
+       * DISTFILES: syncronize current source structure.
+       
+2002-03-14
+       * configure, configure.in, include/config.h.in: add
+       `--enable-runidn' option to configure script.  Unless the value
+       for this option is set to `yes', runidn command will not be
+       complied and installed.
+
+2002-03-13
+       * man/libidnkit.3.in: describe new idnkit API.
+       * man/idn.conf.5.in: use the term `internationalized' rather than
+       `multilingual'.
+       * lib/Makefile.in: create idnalias.conf.sample correctly even if
+       the object directory is different from the source directory.
+
+2002-03-12
+       * configure, configure.in, lib/Makefile.in: add
+       `--enable-liteonly' option to configure script and change
+       description of lib/Makefile.in for designating compilation and
+       installation of libidnkitlite alone.
+
+2002-03-08
+       * mDNkit is now renamed to idnkit.  Also files, directories,
+       commands and function names are renamed (e.g. mdnconv -> idnconv).
+
+2002-03-07
+       * include/mdn/nameprep.h, lib/nameprep.c, lib/resconf.c: enable
+       libmdn(lite) to run without configuration file and alias file, and
+       also enable to support user configuration file.
+
+2002-03-05
+       * include/mdn/aliaslist.h, lib/aliaslist.c: change year
+       description to `2002' in copyright notice.
+       * lib/aliaslist.c: fix the initialization scheme of structure's
+       members at creation of both list item and list itself.
+       * lib/aliaslist.c: fix the order of function free() call when
+       an error occurs at list item creation.
+       * make.wnt: remove descriptions related to mdnsproxy.
+
+2002-03-04
+       * include/mdn/aliaslist.h, include/mdn/amcacez.h, include/mdn/assert.h,
+       include/mdn/checker.h, include/mdn/converter.h, include/mdn/debug.h,
+       include/mdn/delimitermap.h, include/mdn/dude.h, 
+       include/mdn/filechecker.h, include/mdn/filemapper.h,
+       include/mdn/localencoding.h, include/mdn/log.h, include/mdn/logmacro.h,
+       include/mdn/mapper.h, include/mdn/mapselector.h,
+       include/mdn/nameprep.h, include/mdn/normalizer.h, include/mdn/race.h,
+       include/mdn/res.h, include/mdn/resconf.h, include/mdn/resolver.h,
+       include/mdn/result.h, include/mdn/strhash.h, include/mdn/ucs4.h,
+       include/mdn/ucsmap.h, include/mdn/ucsset.h, include/mdn/unicode.h,
+       include/mdn/unormalize.h, include/mdn/utf8.h, include/mdn/util.h,
+       include/mdn/version.h: enclose the contents with `extern "C" {...}'
+       if C++ compiler is used.
+       * DISTFILES, Makefile.in, configure, configure.in:
+       remove descriptions related to mdnsproxy.
+
+2002-03-01
+       * include/mdn/result.h, lib/result.h: define new error code
+       `mdn_too_long'.
+       * lib/res.c: return `mdn_too_long' if MDN_LENCHECK is failed.
diff --git a/contrib/idn/idnkit-1.0-src/DISTFILES b/contrib/idn/idnkit-1.0-src/DISTFILES
new file mode 100644 (file)
index 0000000..b81eef2
--- /dev/null
@@ -0,0 +1,191 @@
+# $Id: DISTFILES,v 1.1 2003/06/04 00:25:02 marka Exp $
+README
+README.ja
+INSTALL
+INSTALL.ja
+ChangeLog
+DISTFILES
+LICENSE.txt
+Makefile.in
+NEWS
+make.wnt
+acconfig.h
+aclocal.m4
+config.guess
+config.sub
+ltconfig
+ltmain.sh
+configure.in
+configure
+install-sh
+mkinstalldirs
+include/Makefile.in
+include/config.h.in
+include/config.h.win
+include/idn/Makefile.in
+include/idn/aliaslist.h
+include/idn/api.h
+include/idn/assert.h
+include/idn/checker.h
+include/idn/converter.h
+include/idn/debug.h
+include/idn/delimitermap.h
+include/idn/export.h
+include/idn/filechecker.h
+include/idn/filemapper.h
+include/idn/localencoding.h
+include/idn/log.h
+include/idn/logmacro.h
+include/idn/mapper.h
+include/idn/mapselector.h
+include/idn/nameprep.h
+include/idn/normalizer.h
+include/idn/punycode.h
+include/idn/race.h
+include/idn/res.h
+include/idn/resconf.h
+include/idn/result.h
+include/idn/strhash.h
+include/idn/ucs4.h
+include/idn/ucsmap.h
+include/idn/ucsset.h
+include/idn/unicode.h
+include/idn/unormalize.h
+include/idn/utf8.h
+include/idn/util.h
+include/idn/version.h
+include/mdn/Makefile.in
+include/mdn/api.h
+include/mdn/localencoding.h
+include/mdn/log.h
+include/mdn/res.h
+include/mdn/resconf.h
+include/mdn/result.h
+include/mdn/utf8.h
+include/mdn/version.h
+lib/Makefile.in
+lib/aliaslist.c
+lib/api.c
+lib/checker.c
+lib/converter.c
+lib/debug.c
+lib/delimitermap.c
+lib/filechecker.c
+lib/filemapper.c
+lib/localencoding.c
+lib/log.c
+lib/make.wnt
+lib/mapper.c
+lib/mapselector.c
+lib/nameprep.c
+lib/nameprep_template.c
+lib/nameprepdata.c
+lib/normalizer.c
+lib/punycode.c
+lib/race.c
+lib/res.c
+lib/resconf.c
+lib/result.c
+lib/strhash.c
+lib/ucs4.c
+lib/ucsmap.c
+lib/ucsset.c
+lib/unicode.c
+lib/unicode_template.c
+lib/unicodedata_320.c
+lib/unormalize.c
+lib/utf8.c
+lib/util.c
+lib/version.c
+lib/idn.conf.sample.in
+lib/aliaslist.sh
+lib/tests/Makefile.in
+lib/tests/api-init1.tsy
+lib/tests/api-init2.tsy
+lib/tests/api-init3.tsy
+lib/tests/api-init4-1.tsy
+lib/tests/api-init4-2.tsy
+lib/tests/api-init4-3.tsy
+lib/tests/api-init5-1.tsy
+lib/tests/api-init5-2.tsy
+lib/tests/api-init5-3.tsy
+lib/tests/api.tsy
+lib/tests/checker.tsy
+lib/tests/codeset.h
+lib/tests/converter.tsy
+lib/tests/delimitermap.tsy
+lib/tests/iconvchk.c
+lib/tests/mapper.tsy
+lib/tests/mapselector.tsy
+lib/tests/nameprep.tsy
+lib/tests/normalizer.tsy
+lib/tests/res.tsy
+lib/tests/resconf.tsy
+lib/tests/setenv.c
+lib/tests/setenv.h
+lib/tests/testsuite.c
+lib/tests/testsuite.h
+lib/tests/testutil.c
+lib/tests/testutil.h
+lib/tests/testygen
+lib/tests/ucs4.tsy
+lib/tests/utffilter
+tools/Makefile.in
+tools/idnconv/Makefile.in
+tools/idnconv/make.wnt
+tools/idnconv/idnconv.c
+tools/idnconv/selectiveencode.c
+tools/idnconv/selectiveencode.h
+tools/idnconv/util.c
+tools/idnconv/util.h
+tools/idnconv/idnconv.1
+tools/idnconv/idnslookup.in
+tools/make.wnt
+tools/rpm/idnkit.spec
+tools/runidn/Makefile.in
+tools/runidn/resolver.c
+tools/runidn/resolver.h
+tools/runidn/stub.c
+tools/runidn/stub.h
+tools/runidn/runidn.1
+tools/runidn/runidn.in
+man/Makefile.in
+man/libidnkit.3.in
+man/idn.conf.5.in
+patch/bind9/bind-9.2.1-patch
+patch/bind9/bind-9.2.2-patch
+win/README.WIN
+wsock/README.txt
+wsock/README_j.txt
+wsock/make.wnt
+wsock/common/checkdll.c
+wsock/common/convert.c
+wsock/common/dump.c
+wsock/common/encoding.c
+wsock/common/hook.c
+wsock/common/make.wnt
+wsock/common/printf.c
+wsock/common/wrapcommon.h
+wsock/config/make.wnt
+wsock/config/idnconf.tcl
+wsock/wsock11/dlldef.h
+wsock/wsock11/dllfunc.c
+wsock/wsock11/dllload.c
+wsock/wsock11/dllmain.c
+wsock/wsock11/dllstub.c
+wsock/wsock11/make.wnt
+wsock/wsock11/wsock32.def
+wsock/wsock20/dlldef.h
+wsock/wsock20/dllfunc.c
+wsock/wsock20/dllload.c
+wsock/wsock20/dllmain.c
+wsock/wsock20/dllstub.c
+wsock/wsock20/make.wnt
+wsock/wsock20/ws2_32.def
+util/Makefile
+util/SparseMap.pm
+util/UCD.pm
+util/generate_nameprep_data.pl
+util/generate_normalize_data.pl
+map/Makefile.in
+map/jp.map
diff --git a/contrib/idn/idnkit-1.0-src/INSTALL b/contrib/idn/idnkit-1.0-src/INSTALL
new file mode 100644 (file)
index 0000000..6434185
--- /dev/null
@@ -0,0 +1,309 @@
+
+                               idnkit
+                    Compilation and Installation
+              Japan Network Information Center (JPNIC)
+
+
+This file explains how to compile and install the source package.
+These procedures take the following steps:
+
+    + Prerequisite: making iconv() available
+    + System Configuration: running `configure' script
+    + Compilation: running `make'
+    + Test: running `make test' (optional)
+    + Installation: running `make install'
+    + Site Configuration: tailoring `idn.conf'
+    + Configuration Check (optional)
+    + Clean up (optional)
+
+See also the following section if you'd like to apply patch and install
+BIND9.
+
+    + Applying patches
+
+0. Prerequisite
+
+If you want to install generic idnkit library with code conversion
+support, and also if your system's library does not have iconv()
+function, which is a general codeset conversion utility, install iconv
+as an external library.  You also need external library if the
+system's implementation cannot handle UTF-8 encoding, or it doesn't
+support some encodings which your client applications uses.
+
+You can get a free version of iconv() implementation (under LGPL
+license, aka GNU libiconv) from:
+
+       ftp://ftp.gnu.org/gnu/libiconv/
+       and mirrors of that site.
+
+But if you don't want code conversion support and you want to install
+idnkitlite library without iconv support alone, you have not install
+external library.  Instead, set `--enable-liteonly' value to "yes" at
+configure script execution.
+
+
+1. Running configure script
+
+Run `configure' script in the top directory.  This checks various
+characteristics of your system and it will create Makefiles and
+config.h appropriate for your system.
+
+       % ./configure
+
+`configure' accepts many options.  Here is a list of some important
+options.
+
+    --prefix=PREFIX
+       Specifies the prefix of install directories of idnkit.  The
+       default is /usr/local.  
+
+    --enable-runidn
+        Build `runidn' command.  The default is "no".
+
+       You cannot set this option "yes" when `--enable-liteonly' is
+       also set "yes".
+
+    --with-libiconv=LIBICONV_PREFIX
+       If you have installed GNU libiconv and would like to link it
+       to idnkit, specify this option.  The argument LIBICONV_PREFIX
+       is install prefix of GNU libiconv.  If the argument is omitted,
+       PREFIX (derived from --prefix=PREFIX option) is assumed.
+
+       --with-libiconv is shorthand option for GNU libiconv.
+
+           --with-libiconv=/usr/local
+
+       This is equivalent to:
+
+           --with-iconv-include='-I/usr/local/include'
+           --with-iconv='-L/usr/local/lib -R/usr/local/lib -liconv'
+
+       If both the shorthand option (--with-libiconv) and longhand
+       options (--with-iconv-include and/or --with-iconv) are specified,
+       the longhand options have priority.
+
+       You cannot set this option when --enable-liteonly is set
+       "yes", because libidnkitlite library doesn't need iconv
+       support.
+
+    --with-iconv-include=ICONV_INCDIR
+       If the header file "iconv.h" resides in a directory where your
+       C compiler doesn't search by default, specify the directory as
+       DIR like this:
+       
+           --with-iconv-include=/usr/local/include
+
+       You cannot set this option when `--enable-liteonly' is set
+       "yes", because libidnkitlite library doesn't need iconv
+       support.
+
+    --with-iconv=ICONV_LIB
+       If your libc doesn't contain iconv(), specify the library
+       that contains iconv().  For example, if iconv() is libiconv
+       in /usr/local/lib, you should specify:
+
+           --with-iconv="-L/usr/local/lib -liconv"
+
+       Note that if the library is a shared one, you might also want
+       to specify -R option, like:
+
+           --with-iconv="-L/usr/local/lib -R/usr/local/lib -liconv"
+
+       You cannot set this option when `--enable-liteonly' is set
+       "yes", because libidnkitlite library doesn't need iconv
+       support.
+
+    --with-iconv-sofile=SOFILE_PATH
+       The runidn command in this kit needs to know the pathname of
+       shared library file that contains iconv(), if iconv() is not
+       part of libc.  idnkit tries to find out the pathname from the
+       informaiton provided by `--with-iconv' option described above.
+       But when it fails, you have to specify it with this option,
+       like:
+
+           --with-iconv-sofile=/usr/local/lib/libiconv.so.2.0
+
+       You cannot set this option when `--enable-liteonly' is set
+       "yes", because libidnkitlite library doesn't need iconv
+       support.
+
+    --with-utf8=UTF8_NAME
+       If your iconv() (precisely, iconv_open()) does not accept
+       "UTF-8" as the name of UTF-8 encoding, specify the name for
+       it.  For example if your iconv() uses "utf8" instead, you
+       should specify:
+
+           --with-utf8=utf8
+
+
+2. Other configure options
+
+The configure script has many other options though they are not widely
+used:
+
+    --exec-prefix=EXEC_PREFIX
+       Specifies the prefix of install directories for machine-specific
+       files.  The default is PREFIX (derived from `--prefix=PREFIX'
+       and its default is /usr/local).
+
+    --bindir=BINDIR
+       Specifies the install directory for idnconv and runidn.
+       The default is EXEC_PREFIX/bin.
+
+    --libdir=LIBDIR
+       Specifies the install directory for the libraries (libidnkit
+       and libidnkitlite).  The default is EXEC_PREFIX/lib.
+
+    --includedir=INCDIR
+       Specifies the install directory for the header files of the
+       libraries.  The default is PREFIX/include.
+
+    --sysconfdir=SYSCONFDIR
+       Specifies the install directory for sample configuration files
+       of the libraries.  The default is PREFIX/etc.
+
+    --mandir=MANDIR
+       Specifies the base install directory for online manuals.
+       The default is PREFIX/man.
+
+    --datadir=DATADIR
+       Specifies the base install directory for machine independent
+       data files.  The default is PREFIX/share.  Some data files for
+       idnkit will be put under the DATADIR/idnkit directory.
+
+    --enable-debug
+       Enable debugging codes.  The fault is "no".
+
+    --enable-shared
+       Build shared library.  The fault is "yes".
+
+    --enable-static
+       Build static library.  The fault is "yes".
+
+    --enable-liteonly
+        Build the `libidnlkitite' library only.  Do not build the
+       `libidnkit' library, idnconv and runidn.  The fault is "no".
+
+       If you want to set "yes" to this option, you cannot specify it
+       together with `--enable-runidn', `--with-libiconv',
+       `--with-iconv-include', `--with-iconv' or `--with-iconv-sofile'.
+
+To see the list of available options, you should run it with --help
+option.
+
+       % ./configure --help
+
+
+3. Compiling
+
+Run `make' for compilation.
+
+       % make
+
+
+4. Test
+
+Optionally, type `make test' to compile and run test programs.
+Note that Perl 5 is required for comipilation of the test programs.
+
+       % make test
+
+The test programs assume that iconv() on the system recognizes the
+encoding name "EUC-JP" as Japanese EUC, and "SJIS" as Japanese Shift
+JIS.  If iconv() on the system doesn't support the encoding name,
+please edit `lib/tests/codeset.h' before `make test'.
+
+*Note* 
+  If you use standard iconv which is attached as default on Solaris,
+  converter's test "idn_converter_convfromucs4()" may fail.  But it's
+  not the problem because the result is derived from the difference of
+  specification of iconv.  So please ignore it if you run the test on
+  Solaris.
+
+
+5. Installation
+
+Run `make install' to install binaries and manuals.  Don't forget to
+become a super-user before the installation.
+
+       % su
+       # make install
+
+*Note*
+  If you have installed pre-release versions of idnkit (such as 1.0pr1),
+  idnkit-1.0 may not work correctly because of the old configuration
+  file 'idn.conf'.  If this is the case, you should overwrite existing
+  configuration files with the new ones by executing the following command
+  after 'make install'.
+
+       # make install-config
+
+
+6. Configuration and usage
+
+Edit the `idn.conf' configuation file if you'd like to cosutomize
+conversion/normalization rules of idnkit.  Please refer the manual
+for `idn.conf' for details.  A sample configuration (`idn.conf.sample')
+is also provided for your convenience.
+
+The sample configuration file has also been installed as `idn.conf'
+if it has not exist on your system.
+
+Also online manuals for `idnconv' and `runidn' commands are available.
+Please refer them for the usage and configuration of these commands.
+
+       % man idn.conf
+       % man idnconv
+       % man runidn
+
+
+7. Check your configuration
+
+A simple shell script `idnslookup' is available in the directory
+`tools/idnconv', with which you can make queries for internationalized
+domain names.  It may help you check your configuration.
+
+The usage of `idnslookup' is:
+
+       % tools/idnconv/idnslookup <domain-name> <dns-server>
+
+Suppose that <domain-name> is an internationalized domain name written
+in the local codeset (see ``LOCAL CODESET'' in the `idn.conf' man page
+for details), and <dns-server> is a hostname or IP address of DNS
+server.
+
+`idnslookup' inquires <idn-domain-name> from <dns-server>, using
+`idnconv' and `nslookup' commands.  If something is wrong, you will
+see an error message output by `idnconv', `nslookup' or `idnslookup'
+itself.
+
+
+8. Clean up
+
+Run `make clean' to delete files generated by `make' and `make test'
+from the idnkit source directory.  (Files installed by `make install'
+are not removed.)
+
+       % make clean
+
+Run `make distclean' instead to also delete files generated by
+`configure'.
+
+       % make distclean
+
+After `make distclean', you can run `configure' and compile idnkit for
+another system using the source directory.
+
+
+Appendix A. Applying patches
+
+This distribution also contains patches for BIND9.
+The top of these patch files describe how to apply the patch and
+(re)install.
+
+Note that on Solaris, "patch" command that comes with the system
+sometimes doesn't work correctly.  You may want to install the GNU
+version of the command (http://www.gnu.org/software/patch/) and use
+it.
+
+; $Id: INSTALL,v 1.1 2003/06/04 00:24:59 marka Exp $
diff --git a/contrib/idn/idnkit-1.0-src/INSTALL.ja b/contrib/idn/idnkit-1.0-src/INSTALL.ja
new file mode 100644 (file)
index 0000000..2bc3fae
--- /dev/null
@@ -0,0 +1,310 @@
+
+                               idnkit
+                   \e$B%3%s%Q%$%k$H%$%s%9%H!<%k$NJ}K!\e(B
+       (\e$B<R\e(B) \e$BF|K\%M%C%H%o!<%/%$%s%U%)%a!<%7%g%s%;%s%?!<\e(B (JPNIC)
+
+
+\e$BK\%Q%C%1!<%8$N%3%s%Q%$%k$*$h$S%$%s%9%H!<%k$O!"<!$N$h$&$J%9%F%C%W$G9T\e(B
+\e$B$$$^$9!#\e(B
+
+    + \e$BA0=`Hw\e(B: iconv() \e$B$,MxMQ$G$-$k$h$&$K$9$k\e(B
+    + \e$B%7%9%F%`@_Dj\e(B: `configure' \e$B%9%/%j%W%H$N<B9T\e(B
+    + \e$B%3%s%Q%$%k\e(B: `make' \e$B$N<B9T\e(B
+    + \e$B%F%9%H\e(B: `make test' \e$B$N<B9T\e(B (\e$B>JN,2D\e(B)
+    + \e$B%$%s%9%H!<%k\e(B: `make install' \e$B$N<B9T\e(B
+    + \e$B%5%$%HKh$N@_Dj\e(B: `idn.conf' \e$B$K$h$k@_Dj\e(B
+    + \e$B@_Dj$N3NG'\e(B (\e$B>JN,2D\e(B)
+    + \e$B8eJRIU$1\e(B (\e$B>JN,2D\e(B)
+
+BIND9 \e$B$K%Q%C%A$rEv$F$F%$%s%9%H!<%k$7$?$$>l9g$O!"<!$N9`$b;2>H$7$F2<$5$$!#\e(B
+
+    + \e$B%Q%C%A$NEv$FJ}\e(B
+
+0. \e$BA0=`Hw\e(B
+  
+\e$B$b$7$"$J$?$,%3!<%IJQ495!G=$r%5%]!<%H$7$?DL>o$N\e(B idnkit \e$B%i%$%V%i%j$r%$%s%9\e(B
+\e$B%H!<%k$9$k$D$b$j$G$"$j!"$^$?$"$J$?$,;HMQ$7$F$$$k%7%9%F%`$N%i%$%V%i%j$K\e(B 
+iconv() \e$B$,$J$$>l9g!"$"$k$$$O$"$C$F$b\e(B UTF-8 \e$B$r07$&$3$H$,$G$-$J$$>l9g$K$O\e(B
+\e$B$"$i$+$8$a\e(B iconv() \e$B$r%$%s%9%H!<%k$7$F$*$$$F$/$@$5$$!#\e(Biconv() \e$B$O!"Nc$($P\e(B 
+GNU libiconv \e$B$H8F$P$l$k%U%j!<\e(B (LGPL) \e$B$N<BAu$,\e(B
+
+       ftp://ftp.gnu.org/gnu/libiconv/
+       \e$B$^$?$O$=$N%_%i!<%5%$%H\e(B
+
+\e$B$+$iF~<j2DG=$G$9!#\e(B
+
+\e$B$?$@$7!"%3!<%IJQ49$rI,MW$H$;$:!"\e(Blite \e$B%P!<%8%g%s$N%i%$%V%i%j$N$_$r%$%s%9\e(B
+\e$B%H!<%k$9$k$N$G$"$l$P!"\e(Biconv() \e$B$r4^$`%i%$%V%i%j$OI,MW$"$j$^$;$s!#$=$N>l9g!"\e(B
+configure \e$B%9%/%j%W%H$N<B9T;~$K\e(B `--enable-liteonly' \e$B%*%W%7%g%s$NCM$r\e(B 
+"yes" \e$B$K%;%C%H$7$F$/$@$5$$!#\e(B
+
+
+1. configure \e$B%9%/%j%W%H$N<B9T\e(B
+
+\e$B%H%C%W%G%#%l%/%H%j$K$"$k\e(B configure \e$B%9%/%j%W%H$r<B9T$7$F$/$@$5$$!#\e(B
+
+       % ./configure
+
+configure \e$B%9%/%j%W%H$K$O!"?tB?$/$N%*%W%7%g%s$,MQ0U$5$l$F$$$^$9!#$=$N$&\e(B
+\e$B$A=EMW$H;W$o$l$k$b$N$O<!$NDL$j$G$9!#\e(B
+
+    --prefix=PREFIX
+       idnkit \e$B$r%$%s%9%H!<%k$9$k%G%#%l%/%H%j$N%Q%9$r;XDj$7$^$9!#%G%U%)\e(B
+       \e$B%k%H$O\e(B /usr/local \e$B$G$9!#\e(B
+
+    --enable-runidn
+       runidn \e$B%3%^%s%I$r:n@.$7$F!"%$%s%9%H!<%k$7$^$9!#%G%U%)%k%H$O\e(B "no"
+       (\e$B:n@.$7$J$$\e(B) \e$B$G$9!#\e(B
+
+    --with-libiconv=LIBICONV_PREFIX
+       \e$B%$%s%9%H!<%k:Q$_$N\e(B GNU libiconv \e$B$r\e(B idnkit \e$B$K%j%s%/$5$;$k>l9g$O!"\e(B
+       \e$B$3$N%*%W%7%g%s$r;XDj$7$F2<$5$$!#0z?t\e(B LIBICONV_PREFIX \e$B$K$O!"\e(BGNU
+       libiconv \e$B$,%$%s%9%H!<%k$5$l$F$$$k0LCV$r;XDj$7$^$9!#0z?t$r>JN,\e(B
+       \e$B$9$k$H!"\e(BPREFIX (PREFIX \e$B$NCM$O\e(B --prefix=PREFIX \e$B$+$iF3=P$5$l$^$9\e(B)
+       \e$B$r;XDj$7$?$b$N$H8+$J$5$l$^$9!#\e(B
+
+       --with-libiconv \e$B$O\e(B GNU libiconv \e$BMQ$NC;=L7A$N%*%W%7%g%s$G\e(B
+
+           --with-libiconv=/usr/local
+
+       \e$B$3$l$O<!$HEy2A$K$J$j$^$9!#\e(B
+
+           --with-iconv-include='-I/usr/local/include'
+           --with-iconv='-L/usr/local/lib -R/usr/local/lib -liconv'
+
+       \e$BC;=L7A$N%*%W%7%g%s\e(B (--with-libiconv) \e$B$HDL>oMQ$N%*%W%7%g%s\e(B
+       (--with-iconv-include, --with-iconv) \e$B$rN>J}$H$b;XDj$7$?>l9g$O!"\e(B
+       \e$BDL>oMQ$N%*%W%7%g%s$[$&$,M%@h$5$l$^$9!#\e(B
+
+       \e$B$3$N%*%W%7%g%s$O\e(B --enable-liteonly \e$B$r\e(B "yes" \e$B$K$7$?>l9g$O;XDj$9$k\e(B
+       \e$B$3$H$O$G$-$^$;$s!#$3$l$O!"\e(Blibidnkitlite \e$B%i%$%V%i%j$,\e(B iconv \e$B%5%]!<\e(B
+       \e$B%H$rI,MW$H$7$J$$$?$a$G$9!#\e(B
+
+    --with-iconv-include=ICONV_INCDIR
+       C \e$B%3%s%Q%$%i$,DL>o$G$O8!:w$7$J$$%G%#%l%/%H%j$K\e(B "iconv.h" \e$B$,CV\e(B
+       \e$B$+$l$F$$$k>l9g!"<!$N$h$&$K$7$F$=$N%G%#%l%/%H%j$r;XDj$7$^$9!#\e(B
+       
+           --with-iconv-include=/usr/local/include
+
+       \e$B$3$N%*%W%7%g%s$O\e(B --enable-liteonly \e$B$r\e(B "yes" \e$B$K$7$?>l9g$O;XDj$9$k\e(B
+       \e$B$3$H$O$G$-$^$;$s!#$3$l$O!"\e(Blibidnkitlite \e$B%i%$%V%i%j$,\e(B iconv \e$B%5%]!<\e(B
+       \e$B%H$rI,MW$H$7$J$$$?$a$G$9!#\e(B
+
+    --with-iconv=ICONV_LIB
+       libc \e$B$K\e(B iconv \e$B$,F~$C$F$$$J$$>l9g\e(B (\e$B>e5-$N%Q%C%1!<%8$rF~$l$?\e(B
+       \e$B>l9g$J$I\e(B) \e$B$K!"\e(Biconv \e$B$N%i%$%V%i%j$r;XDj$7$^$9!#Nc$($P\e(B
+
+               --with-iconv="-L/usr/local/lib -liconv"
+
+       \e$B$N$h$&$K;XDj$7$^$9!#$b$7\e(B iconv \e$B$,6&M-%i%$%V%i%j$K$J$C$F$$$k\e(B
+       \e$B>l9g$K$O!"\e(B-R \e$B%*%W%7%g%s$b;XDj$7$F\e(B
+
+               --with-iconv="-L/usr/local/lib -R/usr/local/lib -liconv"
+
+       \e$B$H$9$kI,MW$,$"$k$+$b$7$l$^$;$s!#\e(B
+
+       \e$B$3$N%*%W%7%g%s$O\e(B --enable-liteonly \e$B$r\e(B "yes" \e$B$K$7$?>l9g$O;XDj$9$k\e(B
+       \e$B$3$H$O$G$-$^$;$s!#$3$l$O!"\e(Blibidnkitlite \e$B%i%$%V%i%j$,\e(B iconv \e$B%5%]!<\e(B
+       \e$B%H$rI,MW$H$7$J$$$?$a$G$9!#\e(B
+
+    --with-iconv-sofile=SOFILE_PATH
+       idnkit \e$B$K4^$^$l$F$$$k\e(B runidn \e$B%3%^%s%I$O!"\e(Biconv() \e$B$,\e(B libc \e$B$N0l\e(B
+       \e$BIt$H$7$FDs6!$5$l$J$$$H$-$K!"\e(Biconv() \e$B$r4^$`6&M-%i%$%V%i%j$X$N%Q\e(B
+       \e$B%9L>$rCN$kI,MW$,$"$j$^$9!#\e(Bidnkit \e$B$O!"\e(B--with-iconv \e$B%*%W%7%g%s$N\e(B
+       \e$B5-=R$r4p$K%Q%9L>$r8!:w$7$^$9$,!"$3$l$K<:GT$7$?$H$-$K!"0J2<$N$h\e(B
+       \e$B$&$K6&M-%i%$%V%i%j$r;XDj$9$k$3$H$,$G$-$^$9!#\e(B
+
+               --with-iconv-sofile=/usr/local/lib/libiconv.so.2.0
+
+       \e$B$3$N%*%W%7%g%s$O\e(B --enable-liteonly \e$B$r\e(B "yes" \e$B$K$7$?>l9g$O;XDj$9$k\e(B
+       \e$B$3$H$O$G$-$^$;$s!#$3$l$O!"\e(Blibidnkitlite \e$B%i%$%V%i%j$,\e(B iconv \e$B%5%]!<\e(B
+       \e$B%H$rI,MW$H$7$J$$$?$a$G$9!#\e(B
+
+    --with-utf8=UTF8_NAME
+       iconv \e$B$K\e(B utf-8 \e$B%(%s%3!<%G%#%s%0$r;XDj$9$k>l9g!"K\%i%$%V%i%j$O\e(B
+       \e$B%G%U%)%k%H$G$O\e(B "UTF-8" \e$B$H$$$&L>A0$r;XDj$7$^$9!#$b$7$"$J$?$N\e(B
+       \e$B%7%9%F%`$N\e(B iconv \e$B$,\e(B "UTF-8" \e$B$H$$$&L>A0$r<u$1IU$1$J$$>l9g$K$O!"\e(B
+       \e$BBe$j$NL>A0$r;XDj$7$^$9!#Nc$($P\e(B "UTF-8" \e$B$G$O$J$/\e(B "utf8" \e$B$N\e(B
+       \e$B>l9g$K$O<!$N$h$&$K;XDj$7$^$9!#\e(B
+
+               --with-utf8=utf8
+
+
+2. \e$B$=$NB>$N\e(B configure \e$B$N%*%W%7%g%s\e(B
+
+\e$B$=$l$[$I$h$/;H$&$o$1$G$O$"$j$^$;$s$,!"\e(Bconfigure \e$B$K$OA09`$N$b$N0J30$K\e(B
+\e$B$bMM!9$J%*%W%7%g%s$,MQ0U$5$l$F$$$^$9!#\e(B
+
+    --exec-prefix=EXEC_PREFIX
+       \e$B%^%7%s8GM-$N%U%!%$%k$r%$%s%9%H!<%k$9$k%G%#%l%/%H%j$N%Q%9$r;XDj\e(B
+       \e$B$7$^$9!#%G%U%)%k%H$O\e(B PREFIX (``--prefix=PREFIX'' \e$B$K$h$C$F;XDj\e(B
+       \e$B2DG=!"\e(BPREFIX \e$B$N%G%U%)%k%H$O\e(B /usr/local) \e$B$K$J$j$^$9!#\e(B
+
+    --bindir=BINDIR
+       idnconv \e$B$H\e(B runidn \e$B$r%$%s%9%H!<%k$9$k%G%#%l%/%H%j$r;XDj$7$^$9!#\e(B
+       \e$B%G%U%)%k%H$G$O\e(B EXEC_PREFIX/bin \e$B$G$9!#\e(B
+
+    --libdir=LIBDIR
+       \e$B%i%$%V%i%j\e(B (libidnkit \e$B$*$h$S\e(B libidnkitlite) \e$B$r%$%s%9%H!<%k$9$k\e(B
+       \e$B%G%#%l%/%H%j$r;XDj$7$^$9!#%G%U%)%k%H$G$O\e(B EXEC_PREFIX/lib \e$B$G$9!#\e(B
+
+    --includedir=INCDIR
+       \e$B%i%$%V%i%j$N%X%C%@%U%!%$%k$r%$%s%9%H!<%k$9$k%G%#%l%/%H%j$r;XDj\e(B
+       \e$B$7$^$9!#%G%U%)%k%H$G$O\e(B PREFIX/include \e$B$G$9!#\e(B
+
+    --sysconfdir=SYSCONFDIR
+       \e$B%i%$%V%i%j$N@_Dj%U%!%$%k$N%5%s%W%k$r%$%s%9%H!<%k$9$k%G%#%l%/%H\e(B
+       \e$B%j$r;XDj$7$^$9!#%G%U%)%k%H$G$O\e(B PREFIX/etc \e$B$G$9!#\e(B
+
+    --mandir=MANDIR
+       \e$B%*%s%i%$%s%^%K%e%"%k$N%$%s%9%H!<%k%G%#%l%/%H%j$r;XDj$7$^$9!#\e(B
+       \e$B%G%U%)%k%H$G$O\e(B PREFIX/man \e$B$G$9!#\e(B
+
+    --datadir=DATADIR
+       \e$B0[$J$k%^%7%s$G6&M-2DG=$J%U%!%$%k$r%$%s%9%H!<%k$9$k%G%#%l%/%H%j\e(B
+       \e$B$r;XDj$7$^$9!#%G%U%)%k%H$O\e(B PREFIX/share \e$B$G$9!#\e(BDATADIR/idnkit 
+       \e$B$N2<$K!"\e(Bidnkit \e$B$G;HMQ$9$k4v$D$+$N%G!<%?%U%!%$%k$,%$%s%9%H!<%k\e(B
+       \e$B$5$l$^$9!#\e(B
+
+    --enable-debug
+       \e$B%G%P%C%0MQ$N%3!<%I$rM-8z$K$7$^$9!#%G%U%)%k%H$O\e(B "no" (\e$BL58z\e(B) \e$B$G$9!#\e(B
+
+    --enable-shared
+       \e$B6&M-%i%$%V%i%j$r:n@.$7$^$9!#%G%U%)%k%H$O\e(B "yes" (\e$B:n@.$9$k\e(B) \e$B$G$9!#\e(B
+
+    --enable-static
+       \e$B@EE*%i%$%V%i%j$r:n@.$7$^$9!#%G%U%)%k%H$O\e(B "yes" (\e$B:n@.$9$k\e(B) \e$B$G$9!#\e(B
+
+    --enable-liteonly
+       libidnkitlite \e$B%i%$%V%i%j$N$_$r:n@.$7$^$9!#\e(Blibidnkit \e$B%i%$%V%i%j!"\e(B
+       idnconv, runidn \e$B$O:n@.$7$^$;$s!#%G%U%)%k%H$O\e(B "no" (\e$B$=$l0J30$N\e(B
+       \e$B$b$N$b:n@.$9$k\e(B) \e$B$G$9!#\e(B
+
+       \e$B$3$N%*%W%7%g%s$NCM$r\e(B "yes" \e$B$K$9$k>l9g!"\e(B `--enable-runidn'
+       `--with-libiconv' `--with-iconv-include' `--with-iconv'
+       `--with-iconv-sofile' \e$B$OF1;~$K;XDj$9$k$3$H$O$G$-$^$;$s!#\e(B
+
+configure \e$B$K$OB>$K$bB?$/$N%*%W%7%g%s$,$"$j$^$9$,!";D$j$O0lHLE*$J%*%W%7%g\e(B
+\e$B%s$J$N$G@bL@$O>J$-$^$9!#\e(B
+
+       % ./configure --help
+
+\e$B$r<B9T$9$k$H%*%W%7%g%s$N0lMw$,I=<($5$l$^$9!#\e(B
+
+
+3. \e$B%3%s%Q%$%k\e(B
+
+configure \e$B$r<B9T$9$k$H\e(B Makefile \e$B$J$I$,@8@.$5$l$^$9$N$G!"B3$1$F\e(B make\e$B$r\e(B
+\e$B<B9T$7$F%3%s%Q%$%k$7$^$9!#\e(B
+
+       % make
+
+
+4. \e$B%F%9%H\e(B
+
+\e$B%F%9%H%W%m%0%i%`$r%3%s%Q%$%k$7!"<B9T$9$k$K$O\e(B `make test' \e$B$r<B9T$7$^$9\e(B
+(\e$B>JN,$7$F$b9=$$$^$;$s\e(B)\e$B!#%F%9%H%W%m%0%i%`$N%3%s%Q%$%k$K$O!"\e(BPerl 5 \e$B$,I,\e(B
+\e$BMW$G$9!#\e(B
+
+       % make test
+
+\e$B$J$*!"\e(Biconv() \e$B$,\e(B "EUC-JP" \e$B$rF|K\8l\e(B EUC \e$B$N%(%s%3!<%G%#%s%0L>>N$H$7$FG'\e(B
+\e$B<1$7!"\e(B"SJIS" \e$B$rF|K\8l%7%U%H\e(B JIS \e$B$N%(%s%3!<%G%#%s%0L>>N$H$7$FG'<1$9$k$3\e(B
+\e$B$H$r!"%F%9%H%W%m%0%i%`$G$OA0Ds$H$7$F$$$^$9!#$b$7!"G'<1$7$J$$$h$&$G$"$l\e(B
+\e$B$P!"\e(B`make test' \e$B<B9TA0$K\e(B `lib/tests/codeset.h' \e$B$rJT=8$7$F2<$5$$!#\e(B
+
+*\e$BCm0U\e(B*
+  Solaris \e$B$K$*$$$F\e(B OS \e$BI8=`$N\e(B iconv \e$B$r;HMQ$7$F$$$k>l9g!"\e(Bconverter \e$B$N\e(B
+  idn_converter_convfromucs4() \e$B$N%F%9%H$,<:GT$9$k$3$H$,$"$j$^$9!#$3$l\e(B
+  \e$B$O\e(B iconv \e$B$N;EMM$N0c$$$K$h$k$b$N$J$N$G!">e5-4D6-$K$*$$$F%$%s%9%H!<%k\e(B
+  \e$B$r9T$C$F$$$k>l9g$OL5;k$7$F$/$@$5$$!#\e(B
+
+
+5. \e$B%$%s%9%H!<%k\e(B
+
+\e$B%9!<%Q%f!<%6$K$J$C$F%$%s%9%H!<%k$7$^$9!#\e(B
+
+       % su
+       # make install
+
+*\e$BCm0U\e(B*
+  idnkit \e$B$N\e(B 1.0 \e$B0JA0$N%P!<%8%g%s\e(B (1.0pr1 \e$B$J$I\e(B) \e$B$,$9$G$K%$%s%9%H!<%k$5\e(B
+  \e$B$l$F$$$k>l9g!"%$%s%9%H!<%k$5$l$?@_Dj%U%!%$%k\e(B 'idn.conf' \e$B$NFbMF$,8E$$\e(B
+  \e$B$?$a!"\e(Bidnkit-1.0\e$B$,@5$7$/F0:n$7$^$;$s!#$3$N$?$a!"\e(Bidnkit-1.0 \e$BMQ$N@_Dj\e(B
+  \e$B%U%!%$%k$r>e=q$-%$%s%9%H!<%k$9$kI,MW$,$"$j$^$9!#\e(Bmake install \e$B<B9T8e!"\e(B
+  \e$B0J2<$N%3%^%s%I$r<B9T$7$F$/$@$5$$!#\e(B
+
+       # make install-config
+
+
+6. \e$B@_Dj$H;HMQJ}K!\e(B
+
+idnkit \e$B$N@55,2=$*$h$SJQ495,B'$r%+%9%?%^%$%:$7$9$k$J$i!"@_Dj%U%!%$%k\e(B
+`idn.conf' \e$B$rJT=8$7$^$9!#$3$N@_Dj%U%!%$%k$N>\:Y$K$D$$$F$O\e(B idn.conf \e$B$N\e(B
+\e$B%*%s%i%$%s%^%K%e%"%k$r$4Mw$/$@$5$$!#$^$?@_DjNc$,=q$+$l$?%5%s%W%k%U%!%$\e(B
+\e$B%k\e(B (idn.conf.sample) \e$B$b%$%s%9%H!<%k$5$l$^$9$N$G$4MxMQ$/$@$5$$!#\e(B
+
+\e$B%7%9%F%`$K@_Dj%U%!%$%k$,B8:_$7$J$+$C$?>l9g!"$3$N%5%s%W%k$N@_Dj%U%!%$%k\e(B
+\e$B$O\e(B `idn.conf' \e$B$H$7$F$b%$%s%9%H!<%k$5$l$^$9!#\e(B
+
+\e$B$^$?!"\e(Bidnconv\e$B!"\e(Brunidn \e$B$H$$$C$?%D!<%k$N%*%s%i%$%s%^%K%e%"%k$bDs6!$5$l$F\e(B
+\e$B$$$^$9!#$3$l$i$N%3%^%s%I$N;H$$J}!"@_DjJ}K!$K4X$7$F$O$=$A$i$r;2>H$7$F$/\e(B
+\e$B$@$5$$!#\e(B
+
+       % man idn.conf
+       % man idnconv
+       % man runidn
+
+
+7. \e$B@_Dj$N3NG'\e(B
+
+`idnslookup' \e$B$H$$$&4JC1$J%7%'%k%9%/%j%W%H$,\e(B tools/idnconv \e$B%G%#%l%/%H%j\e(B
+\e$B$KMQ0U$5$l$F$$$^$9!#$3$N%9%/%j%W%H$r;H$&$H\e(B DNS \e$B%5!<%P$KBP$7$F9q:]2=%I\e(B
+\e$B%a%$%sL>$rLd$$9g$o$;$k$3$H$,$G$-$^$9!#@_Dj%U%!%$%k$N3NG'$KLrN)$D$+$bCN\e(B
+\e$B$l$^$;$s!#\e(B
+
+`idnslookup' \e$B$N;HMQJ}K!$O!"<!$NDL$j$G$9!#\e(B
+
+       % tools/idnconv/idnslookup <domain-name> <dns-server>
+
+\e$B$3$3$G\e(B <domain-name> \e$B$O%m!<%+%k%3!<%I%;%C%H\e(B (\e$B>\$7$/$O\e(B idn.conf \e$B$N%^%K%e\e(B
+\e$B%"%k$N\e(B ``LOCAL CODESET'' \e$B$r;2>H$N$3$H\e(B) \e$B$G=q$+$l$?9q:]2=%I%a%$%sL>$G!"\e(B
+<dns-server> \e$B$O\e(B DNS \e$B%5!<%P$N%[%9%HL>$b$7$/$O\e(B IP \e$B%"%I%l%9$G$9!#\e(B
+
+`idnslookup' \e$B$O\e(B `idnconv' \e$B$*$h$S\e(B `nslookup' \e$B%3%^%s%I$rMQ$$$F!"\e(B
+<dns-server> \e$B$KBP$7$F\e(B <domain-name> \e$B$r0z$-$K9T$-$^$9!#@_Dj$K2?$+4V0c$$\e(B
+\e$B$,$"$l$P!"\e(B`idnconv', `nslookup', \e$B$"$k$$$O\e(B `idnslookup' \e$B<+?H$K$h$k%(%i!<\e(B
+\e$B%a%C%;!<%8$,=PNO$5$l$^$9!#\e(B
+
+
+8. \e$B8eJRIU$1\e(B
+
+`make' \e$B$*$h$S\e(B `make test' \e$B$K$h$C$F@8@.$5$l$?%U%!%$%k$r\e(B idnkit \e$B$N%=!<\e(B
+\e$B%9%G%#%l%/%H%j$+$i:o=|$9$k$K$O!"\e(B`make clean' \e$B$r<B9T$7$F2<$5$$!#\e(B
+(`make install' \e$B$N:]$K%$%s%9%H!<%k$5$l$?%U%!%$%k$O!":o=|$5$l$^$;$s!#\e(B)
+
+       % make clean
+
+`configure' \e$B$G@8@.$5$l$?%U%!%$%k$b0l=o$K:o=|$9$k$J$i!"Be$o$j$K\e(B `make
+distclean' \e$B$r<B9T$7$^$9!#\e(B
+
+       % make distclean
+
+`make distclean' \e$B$r9T$($P!"$3$N%=!<%9%G%#%l%/%H%j$r;H$C$F!"A02s$H$OJL\e(B
+\e$B$N%7%9%F%`8~$1$K\e(B `configure' \e$B$*$h$S\e(B idnkit \e$B$N%3%s%Q%$%k$r9T$&$3$H$,$G\e(B
+\e$B$-$k$h$&$K$J$j$^$9!#\e(B
+
+
+\e$BIUO?\e(B A. \e$B%Q%C%A$NEv$FJ}\e(B
+
+\e$B$3$NG[I[%-%C%H$K$O!"\e(BBIND9 \e$B$KBP$9$k%Q%C%A$,4^$^$l$F$$$^$9!#\e(B
+\e$B%Q%C%A$NEv$FJ}$O!"%Q%C%A%U%!%$%k$N@hF,$K=q$+$l$F$$$^$9$N$G$=$A$i$r;2>H\e(B
+\e$B$7$F$/$@$5$$!#\e(B
+
+Solaris \e$B$G$O!"%7%9%F%`IUB0$N\e(B patch \e$B%3%^%s%I$,@5>o$KF0:n$7$J$$$3$H$,$"\e(B
+\e$B$j$^$9!#$=$N$h$&$J>l9g$K$O!"\e(BGNU \e$B%P!<%8%g%s$N\e(B patch
+(http://www.gnu.org/software/patch/) \e$B$r%$%s%9%H!<%k$7$F!"$3$l$r;HMQ$7\e(B
+\e$B$F$/$@$5$$!#\e(B
+
+
+; $Id: INSTALL.ja,v 1.1 2003/06/04 00:25:00 marka Exp $
diff --git a/contrib/idn/idnkit-1.0-src/LICENSE.txt b/contrib/idn/idnkit-1.0-src/LICENSE.txt
new file mode 100644 (file)
index 0000000..1f1e0a0
--- /dev/null
@@ -0,0 +1,39 @@
+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.
diff --git a/contrib/idn/idnkit-1.0-src/Makefile.in b/contrib/idn/idnkit-1.0-src/Makefile.in
new file mode 100644 (file)
index 0000000..247ca7f
--- /dev/null
@@ -0,0 +1,79 @@
+# $Id: Makefile.in,v 1.1 2003/06/04 00:25:03 marka Exp $
+# 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.
+
+srcdir = @srcdir@
+VPATH = @srcdir@
+
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+
+PERL = perl
+MKTARPKG = ../util/mktarpkg
+SHELL = @SHELL@
+
+SUBDIRS = include lib man tools map
+
+all: force all-subdirs
+test check: force test-subdirs
+install: force install-subdirs
+clean: force clean-subdirs
+distclean: force distclean-localdir distclean-subdirs
+
+distclean-localdir:
+       rm -f config.status config.cache config.log libtool Makefile
+
+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
+
+install-config:
+       (cd lib; $(MAKE) install-config);
+
+dist: force
+       @v=`sed -ne '/^# *define *IDNKIT_VERSION/s/^.*"\([^"]*\)".*$$/\1/p' \
+           $(srcdir)/include/idn/version.h`; \
+       echo generate idnkit-$$v-src.tar.gz; \
+       cd $(srcdir); \
+       $(PERL) $(MKTARPKG) --gzip=9 idnkit-$$v-src
+
+force:
diff --git a/contrib/idn/idnkit-1.0-src/NEWS b/contrib/idn/idnkit-1.0-src/NEWS
new file mode 100644 (file)
index 0000000..81c7c02
--- /dev/null
@@ -0,0 +1,186 @@
+; $Id: NEWS,v 1.1 2003/06/04 00:25:03 marka Exp $
+
+Major changes in idnkit version 1.0:
+
+* Change ACE prefix of Punycode from 'zq--' to 'xn--'. And delete
+  configure's --with-punycode-prefix option.
+
+* Add NAMEPREP version RFC3491. Other versions of NAMEPREP are
+  removed.
+
+* Enable idnconv to handle a input line as long as memory permitted
+  when encoding/decoding.
+
+* unicode-form-c and unicode-form-c/3.2.0 are not supported.
+
+* Unicode 3.0.1 and Unicode 3.1.0 are not supported.
+
+* Delete BIND8, Squid and GNU libiconv patches.
+
+Major changes in idnkit version 1.0-pr2:
+
+* The license of idnkit is changed to a less restrictive one. See
+  LICENSE.txt for the new license.
+
+* The local codeset name used in the test suite, which is hard-coded
+  in the previous version, can be specified by a separate header file.
+
+* IDN encoding and decoding now always check the validity of the
+  result by performing roundtrip conversion check.
+
+Major changes in idnkit version 1.0-pr1:
+
+* Some test cases are added to the testsuite.
+
+* The testsuite can run on OpenBSD.
+
+Major changes in idnkit version 020829:
+
+* Testsuit is added for the library behavior check.
+  Testsuit and testcases are in lib/tests.  Read INSTALL (INSTALL.ja)
+  for details.  Tests aim at api, checker, converter, delimitermap,
+  mapper, mapselecter, normalizer, res, resconf, and ucs4 at the
+  moment.
+
+* "amcacez" module is renamed to "punycode".
+
+* AMC-ACE-Z and RACE are now treated as extra ACE.
+
+* Add "--with-utf8=NAME" option to configure script.
+
+Major changes in idnkit version 020730:
+
+* Complete bidi check support for NAMEPREP draft -11.
+
+* Type definitions of action flags for conversion APIs are changed
+  from int to idn_action_t.
+
+* Add -nobidicheck option to idnconv command.
+
+Major changes in idnkit version 020711:
+
+* Default delimiters are added according to IDNA-10.
+
+* ``delimiter-map'' entry in config file is removed.
+
+* Add Unicode version 3.2 support.
+
+* Add preliminary support of NAMEPREP draft -11.
+  This version supports NAMEPREP draft -11 without bidirectional label
+  check.
+
+* Supported NAMEPREP versions are changed. 
+  idnkit supports NAMEPREP draft version -03, -10, and -11.  Others
+  are removed.
+
+* IDN encoding DUDE is removed.
+
+* New action flags are available for conversion APIs.
+  IDN_ENCODE_QUERY, IDN_DECODE_QUERY, IDN_ENCODE_STORED, and
+  IDN_DECODE_STORED are newly created according to IDNA specification.
+  See include/idn/res.h for precise description.
+
+* Action flags IDN_ENCODE_APP, IDN_DECODE_APP and IDN_NAMEPREP change
+  those behavior.
+  See include/idn/res.h for precise description.
+
+* New decode APIs are created.
+  idn_decodename2() and idn_res_decodename2() are defined to add
+  conversion process from "IDN string encoded in local encoding" to
+  UTF-8 before actual decode process of IDN.
+
+* idnconv with -reverse option treats input as IDN string(s) encoded
+  in local encoding specified by -out option.
+
+* idnconv recognizes `-A' option which is synonym for `-noasciicheck'.
+
+* (Windows) idn Wrapper can run on Windows XP.
+
+* BIND-8 patch for BIND-8.3.3 is available and other patches of BIND-8
+  are removed.
+
+Major changes in idnkit version 1.0-rc1:
+
+* NAMEPREP draft -09 is supported.
+
+* idnconv now accepts any encodings specified as argument for `-in'
+  or `-out' option.  `-out' accepts non-ACE, and `-in' accepts ACE.
+
+* In configuration file, `encoding-alias-file' entry is not supported
+  any longer.  It is simply ignored.
+
+Major changes in idnkit version 1.0-beta2:
+
+* Supported nameprep version is changed.
+  Now idnkit supports nameprep-03, nameprep-06, and nameprep-08.
+  Nameprep-05 and nameprep-07 are not supported any more.
+
+* Compatibility with mDNkit is added.
+  This feature provides applications formerly written using mDNkit
+  library with some source level compatibilities.  If you want to use
+  this feature, set `--enable-mdnkit-compat' option at execution time
+  of configure script.
+
+* Now idnkit can set up easily without configuration file.
+  As this feature is added, initialization function and some behavior
+  of top level API are changed.
+
+* BIND-8 patch supports IDN conversion in itself.
+
+* (Windows) idnkit library looks for configuration files with registry
+  information.
+
+* (Windows) idnkit library returns "CP<code page number>" as local
+  encoding name when the environment variable "IDN_LOCAL_CODESET" is
+  not set.
+
+* (Windows) libidnkit/libidnkitlite are now installed as DLL.
+
+* (Windows) idnconv can be executed as a console application.
+
+Major changes in idnkit version 1.0-beta1:
+
+* mDNkit has been renamed idnkit.
+  This means all symbols with "mdn" are renamed with "idn".  For
+  example, a function `mdn_encodename()' is now `idn_encodename()', an
+  environment variable "MDN_DISABLE" is "IDN_DISABLE", system
+  configuretion file is "idn.conf", `runmdn' command is `runidn', and
+  so forth.
+
+* Also, library name has been changed to "libidnkit(lite)".
+
+* `mdnsproxy' command has been removed.
+
+* `runidn' (formerly known as `runmdn') command is not installed by
+  default.
+  If you want to install it, set "yes" to `--enable-runidn' option
+  when you run configure script.
+
+* idnkitlite library only instalation is supported.
+  Set "yes" to `--enable-liteonly' option at execution of configure
+  script to use this feature.
+
+* BIND-9.1.3 patch has been removed.
+
+* User configuration file is supported.
+  idnkit now uses ".idnrc" in user's home directory for configuration
+  of whole scheme.  If there is no user configuration file, then it
+  tries to load the system configuration file "idn.conf".
+
+* idnkit is now able to run without configuration file.
+  If there are no configuration files (both of user's and system's),
+  it sets normal configurations (the latest nameprep scheme it
+  supports and the IDN encoding "Punycode") automatically at runtime.
+
+* Encoding alias information file is supported. (by generic libidnkit)
+  Its name is "idnalias.conf" by default and it should be located in
+  same directory where the system configuration file is.  Example
+  alias information file "idnalias.conf.sample" is installed
+  automatically.
+
+* APIs are renewed.  See manpage.
+
+* Now idnkit has full support of IDNA-07.
+
+* Internal representation of domain name is changed to UCS4 in place
+  of UTF-8.
diff --git a/contrib/idn/idnkit-1.0-src/README b/contrib/idn/idnkit-1.0-src/README
new file mode 100644 (file)
index 0000000..8323082
--- /dev/null
@@ -0,0 +1,159 @@
+
+                               idnkit
+            -- internationalized domain name toolkit --
+                            version 1.0
+              Japan Network Information Center (JPNIC)
+
+
+Table of contents of this file:
+
+  1. Overview
+  2. Directory structure of this distribution
+  3. Supported systems
+  4. Contact information
+
+See the file INSTALL for compilation and installation instructions.
+See the file NEWS for a list of major changes in the current release.
+
+
+1. Overview
+
+idnkit, which was originally known as mDNkit, is a toolkit for handling
+internationalized domain names.  To handle such names, the following
+features are required:
+
+    + Encoding conversion
+       Multilingualized domain names have to be converted from
+       the encoding application uses (local encoding) to
+       the encoding used for name resolution (IDN encoding), and
+       vice versa.  Since domain names in IDN encoding just look
+       like good old ASCII domain names, the encoding is also known
+       as ASCII-compatible encoding (ACE).
+
+    + NAMEPREP
+       Name preparation of domain names before converting to
+       IDN encoding.  Basically this is a normalization process
+       of the domain names.
+
+These conversion/nameprep processes to domain names have to be
+performed before they are sent to DNS servers.  And since the
+processed domain names (in IDN encoding) consist of only legal ASCII
+characters, no changes are required to DNS servers.
+       
+idnkit provides several ways for adding these features.
+
+This kit consists of following components.
+
+    + library for handling internationalized domain names
+      (libidnkit, libidnkitlite)
+       Those libraries implement encoding conversion and nameprep.
+       They provide easy-to-use APIs for handling internationalized
+       domain name in your applications.
+
+       Both libraries provide almost the same API.  The difference
+       between them is that libidnkit internally uses iconv() function
+       to provide encoding conversion from UTF-8 to the local encoding
+       (such as iso-8859-1, usually determined by the current locale),
+       and vise versa.  The idnconv and runidn commands in this toolkit
+       use libidnkit.
+
+       libidnkitlite is lightweight version of libidnkit.  It assumes
+       local encoding is UTF-8 so that it never uses iconv().
+
+    + codeset conversion utility (idnconv)
+       This command can convert internationalized domain name written
+       in local encoding (e.g. EUC-JP) to ACE or the opposite direction.
+       It can also convert named.conf and zone master files for BIND.
+
+    + command which adds IDN feature dynamically to unix applications 
+      (runidn)
+       This command enables normal applications to handle
+       internationalized domain names by dynamically attaching special
+       library to them.  See ``2. using runidn'' below.
+
+       Note that this command is not installed unless you specify the
+       `--enable-runidn' option to `configure'.  See the file `INSTALL'
+       for more information about installation.
+
+    + patch for BIND9 that adds IDN capability
+       This patch adds IDN capability to BIND9.  It adds encoding
+       conversion and nameprep features to `dig', `host' and
+       `nslookup'.  With the patch, those commands become capable of
+       internationalized domain names.
+
+    + IDN wrapper for Windows applications
+        On windows, name resolving request is passed to WINSOCK DLL. So,
+        replacing WINSOCK DLL with multi-lingual domain name version 
+        makes legacy windows applications compatible with IDN.  This is
+       wrapper DLL for WINSOCK's name resolving functions. See
+       ``3. using IDN wrapper'' below.
+
+
+2. Directory structure of this distribution
+
+Below is a directory structure of this distribution with some 
+important files and their brief description.
+
+    +README             this file
+    +README.ja          .. in Japanese
+    +INSTALL            compilation and installation instructions.
+    +INSTALL.ja         .. in Japanese
+    +DISTFILES          list of files in this distribution
+    +NEWS               what's new in this version
+    +ChangeLog          list of changes
+    +Makefile.in        toplevel makefile template
+    +configure          a `configure' script
+    +include/
+    |   +config.h.in    template header file for configuration
+    |   +idn/           header files for libidnkit and libindkitlite
+    |   +mdn/           header files for backward compatibility
+    +lib/               source for libidnkit and libidnkitlite
+    +patch/
+    |   +bind9/         BIND9 patch
+    +tools/
+    |   +idnconv/       source for idnconv command
+    |   +runidn/        source for runidn command
+    +util/              utilities
+    +wsock/             source for IDN wrapper
+
+
+3. Supported systems
+
+We've had successful builds on the following systems:
+
+    -------------------------------------------------------------------
+    OS                      iconv library      configure options
+    ===================================================================
+    FreeBSD 4.7-RELEASE     GNU libiconv       --with-libiconv
+    for Intel               1.8
+    -------------------------------------------------------------------
+    Red Hat Linux 7.3       standard library   none
+    for Intel               (glibc)
+    -------------------------------------------------------------------
+    Solaris 9               standard library   none
+    for Sparc               (libc)
+    -------------------------------------------------------------------
+
+The latest information about supported/unsupported systems will be
+found at the mdnkit FAQ page linked from:
+
+       http://www.nic.ad.jp/en/idn/
+
+
+4. Contact information
+
+Please see
+
+       http://www.nic.ad.jp/en/idn/
+
+for the latest news about this kit.
+Bug reports and comments on this kit should be sent to
+
+       mdnkit-bugs@nic.ad.jp
+and
+       idn-cmt@nic.ad.jp
+
+respectively.
+
+
+; $Id: README,v 1.1 2003/06/04 00:24:58 marka Exp $
diff --git a/contrib/idn/idnkit-1.0-src/README.ja b/contrib/idn/idnkit-1.0-src/README.ja
new file mode 100644 (file)
index 0000000..8663e3a
--- /dev/null
@@ -0,0 +1,151 @@
+
+                               idnkit
+                 -- \e$B9q:]2=%I%a%$%sL>%D!<%k%-%C%H\e(B --
+                           \e$B%P!<%8%g%s\e(B 1.0
+       (\e$B<R\e(B) \e$BF|K\%M%C%H%o!<%/%$%s%U%)%a!<%7%g%s%;%s%?!<\e(B (JPNIC)
+
+
+\e$B$3$N%U%!%$%k$NL\<!\e(B:
+
+  1. \e$B35MW\e(B
+  2. \e$B%G%#%l%/%H%j9=@.\e(B
+  3. \e$BK\%-%C%H$,BP1~$7$F$$$k%7%9%F%`\e(B
+  4. \e$BK\%-%C%H$K4X$9$k:G?7>pJs!"Ld$$9g$o$;$K$D$$$F\e(B
+
+\e$B%3%s%Q%$%k$*$h$S%$%s%9%H!<%kJ}K!$K$D$$$F$O!"\e(BINSTALL.ja \e$B$H$$$&%U%!%$%k$r\e(B
+\e$B$4Mw2<$5$$!#$3$N%P!<%8%g%s$G$N<g$JJQ99E@$KIU$$$F$O!"\e(B(\e$B1QJ8$G$9$,\e(B) NEWS 
+\e$B$H$$$&%U%!%$%k$r$4Mw2<$5$$!#\e(B
+
+
+1. \e$B35MW\e(B
+
+idnkit (\e$B5l>N\e(B mDNkit) \e$B$H$O9q:]2=%I%a%$%sL>$r07$&$?$a$N%D!<%k%-%C%H$G$9!#\e(B
+\e$B9q:]2=%I%a%$%sL>$r07$&$?$a$K$O!"<!$N$h$&$J5!G=$,MW5a$5$l$^$9!#\e(B
+
+\e$B!&%(%s%3!<%G%#%s%0JQ49\e(B
+  \e$B9q:]2=%I%a%$%sL>$KBP$7$F!"$=$N%(%s%3!<%G%#%s%0$r%"%W%j%1!<%7%g%s$,;H\e(B
+  \e$BMQ$7$F$$$k$b$N\e(B (\e$B%m!<%+%k%(%s%3!<%G%#%s%0\e(B) \e$B$+$iL>A02r7h$KMQ$$$i$l$k$b\e(B
+  \e$B$N\e(B (IDN \e$B%(%s%3!<%G%#%s%0\e(B) \e$B$X$NJQ49!"$^$?$=$N5UJ}8~$NJQ49$r9T$$$^$9!#\e(B
+  \e$B%I%a%$%sL>$r\e(B IDN \e$B%(%s%3!<%G%#%s%0$K$7$?7k2L$O!"=>Mh$N%I%a%$%sL>$HF1\e(B
+  \e$B$8$/\e(B ASCII \e$BJ8;z$N$_$G9=@.$5$l$k$N$G!"\e(BIDN \e$B%(%s%3!<%G%#%s%0$O\e(BASCII \e$B8_\e(B
+  \e$B49%(%s%3!<%G%#%s%0\e(B (ACE) \e$B$H$b8F$P$l$^$9!#\e(B
+
+\e$B!&\e(BNAMEPREP
+  \e$B%I%a%$%sL>$r\e(B IDN \e$B%(%s%3!<%G%#%s%0$KJQ49$9$kA0$K!"L>A0$N@55,2=$r9T$$\e(B
+  \e$B$^$9!#$3$l$r\e(B NAMEPREP \e$B$H8F$S$^$9!#\e(B
+
+\e$B>e5-$N=hM}$O%I%a%$%sL>$r\e(B DNS \e$B%5!<%P$KAw$kA0$K<B9T$9$kI,MW$,$"$j$^$9!#\e(B
+\e$B=hM}:Q$N%I%a%$%sL>$O\e(B ASCII \e$BJ8;z$+$i9=@.$5$l!"=>Mh$N\e(B ASCII \e$B%I%a%$%sL>$H\e(B
+\e$B$7$F$b@5$7$$7A<0$K$J$C$F$$$k$N$G!"\e(BDNS \e$B%5!<%PB&$K$O$J$s$NJQ99$bI,MW$"$j\e(B
+\e$B$^$;$s!#\e(B
+
+\e$B$3$NG[I[%-%C%H$K$O<!$N$h$&$J$b$N$,4^$^$l$^$9!#\e(B
+
+\e$B!&9q:]2=%I%a%$%sL>$r=hM}$9$k$?$a$N%i%$%V%i%j\e(B (libidnkit, libidnkitlite)
+  \e$B$3$l$i$N%i%$%V%i%j$G$O!"%(%s%3!<%G%#%s%0JQ49$d\e(B NAMEPREP \e$B$N5!G=$r<B\e(B
+  \e$BAu$7$F$*$j!"%"%W%j%1!<%7%g%s$,9q:]2=%I%a%$%sL>$r4JC1$K07$($k$h$&$K\e(B
+  \e$B$9$k$?$a$N\e(B API \e$B$rHw$($F$$$^$9!#\e(B
+
+  \e$B$I$A$i$N%i%$%V%i%j$b$[$H$s$IF1$8\e(B API \e$B$rDs6!$7$^$9!#N><T$NAj0cE@$G$9\e(B
+  \e$B$,!"\e(Blibidnkit \e$B$N$[$&$O\e(B iconv() \e$B4X?t$r;H$C$F\e(B UTF-8 \e$B$H%m!<%+%k%(%s%3!<\e(B
+  \e$B%G%#%s%0\e(B (iso-8859-1 \e$B$J$I!"DL>o$O\e(B locale \e$B$+$i7hDj$5$l$^$9\e(B) \e$B$H$N4V$N\e(B
+  \e$BJQ495!G=$rDs6!$7$F$$$^$9!#K\%D!<%k%-%C%HIUB0$N\e(B idnconv \e$B$*$h$S\e(B runidn
+  \e$B$O\e(B libidnkit \e$B$r;HMQ$7$F$$$^$9!#\e(B
+
+  libidnkitlite \e$B$O\e(B libidnkit \e$B$N7ZNLHG$G$9!#%m!<%+%k%(%s%3!<%G%#%s%0$O\e(B
+  \e$B>o$K\e(B UTF-8 \e$B$@$H2>Dj$7$F$*$j!"\e(Biconv() \e$B$O;HMQ$7$^$;$s!#\e(B
+
+\e$B!&%3!<%I%;%C%H%3%s%P!<%?\e(B (idnconv)  
+  \e$B%m!<%+%k%(%s%3!<%G%#%s%0\e(B (\e$B$?$H$($P\e(B EUC-JP) \e$B$G=q$+$l$?9q:]2=%I%a%$%s\e(B
+  \e$BL>$+$i\e(B ACE \e$B$X$NJQ49$d!"$=$N5UJQ49$r9T$($k%3%^%s%I$G$9!#\e(BBIND \e$BMQ$N\e(B
+  named.conf \e$B$d%>!<%s%^%9%?%U%!%$%k$rJQ49$9$k$3$H$b2DG=$G$9!#\e(B
+
+\e$B!&\e(BUNIX \e$B%"%W%j%1!<%7%g%s$K\e(B IDN \e$B5!G=$rF0E*$KDI2C$9$k%3%^%s%I\e(B (runidn)
+  UNIX \e$B$NDL>o$N%"%W%j%1!<%7%g%s$G9q:]2=%I%a%$%sL>$r<h$j07$&$?$a$K!"FC\e(B
+  \e$BJL$J%i%$%V%i%j$rF0E*$K%j%s%/$9$k$?$a$N%3%^%s%I$G$9!#>\$7$/$O!"8e=R$N\e(B
+  \e$B!V\e(B2. runidn \e$B$r;H$&!W$r8fMw$/$@$5$$!#\e(B
+
+  \e$B$J$*!"\e(Bconfigure \e$B<B9T;~$K\e(B `--enable-runidn' \e$B$r;XDj$7$J$$$H!"\e(Brunidn \e$B$O\e(B
+  \e$B%$%s%9%H!<%k$5$l$^$;$s!#%$%s%9%H!<%k$K4X$7$F!">\$7$/$O\e(B INSTALL.ja \e$B$H\e(B
+  \e$B$$$&%U%!%$%k$r$4Mw$/$@$5$$!#\e(B
+
+\e$B!&\e(BBIND9 \e$B$K\e(B IDN \e$B5!G=$rDI2C$9$k%Q%C%A\e(B
+  BIND \e$B$K\e(B IDN \e$B$N5!G=$rDI2C$9$k%Q%C%A$G$9!#\e(B`dig'\e$B!"\e(B`host'\e$B!"\e(B`nslookup' \e$B$K\e(B
+  \e$B%(%s%3!<%G%#%s%0JQ49$H\e(B NAMEPREP \e$B$N5!G=$rDI2C$7!"9q:]2=%I%a%$%sL>$,07\e(B
+  \e$B$($k$h$&$K$7$^$9!#\e(B
+
+\e$B!&\e(BWindows \e$B%"%W%j%1!<%7%g%sMQ$N\e(B IDN \e$B%i%C%Q!<\e(B
+  WINSOCK \e$B$NL>A02r7h5!G=$KBP$9$k%i%C%Q!<\e(B DLL \e$B$G$9!#\e(BWindows \e$B>e$G$O!"L>\e(B
+  \e$BA02r7h$NMW5a$O!"\e(BWINSOCK DLL \e$B$rDL$7$F9T$o$l$^$9!#$=$3$G!"$3$l$r9q:]2=\e(B
+  \e$B%I%a%$%sMQ$N\e(B WINSOCK DLL \e$B$KCV$-49$($k$3$H$G!"=>Mh$N\e(B Windows \e$B%"%W%j%1!<\e(B
+  \e$B%7%g%s$G$b\e(B IDN \e$B5!G=$r;HMQ$G$-$k$h$&$K$7$^$9!#>\$7$/$O!"8e=R$N\e(B
+  \e$B!V\e(B3. IDN \e$B%i%C%Q!<$r;H$&!W$r8fMw$/$@$5$$!#\e(B
+
+
+2. \e$B%G%#%l%/%H%j9=@.\e(B
+
+\e$BG[I[%-%C%H$N%G%#%l%/%H%j9=@.$H!"<gMW$J%U%!%$%k$r<($7$^$9!#\e(B
+
+    +README             \e$B1Q8lHG$N\e(B README
+    +README.ja          \e$B$3$N%U%!%$%k\e(B
+    +INSTALL            \e$B1Q8lHG$N\e(B INSTALL
+    +INSTALL.ja         \e$B%3%s%Q%$%k$H%$%s%9%H!<%kJ}K!\e(B
+    +DISTFILES          \e$BG[I[$5$l$k%U%!%$%k0lMw\e(B
+    +NEWS               \e$B<g$JJQ99\e(B
+    +ChangeLog          \e$BJQ99>\:Y\e(B
+    +configure          configure \e$B%9%/%j%W%H\e(B
+    +Makefile.in        \e$B%H%C%W%l%Y%k$N\e(B Makefile \e$B$N%F%s%W%l!<%H\e(B
+    +include/
+    |   +config.h.in    config.h \e$B$N%F%s%W%l!<%H\e(B
+    |   +idn/           libidnkit, libidnkitlite \e$B$N%X%C%@%U%!%$%k\e(B
+    |   +mdn/           \e$B5l%P!<%8%g%s$H$N8_49MQ%X%C%@%U%!%$%k\e(B
+    +lib/               libidnkit, libidnkitlite \e$B$N%=!<%9\e(B
+    +patch/
+    |   +bind9/         BIND9 \e$BMQ%Q%C%A\e(B
+    +tools/
+    |   +idnconv/       idnconv \e$B%3%^%s%I$N%=!<%9\e(B
+    |   +runidn/        runidn \e$B%3%^%s%I$N%=!<%9\e(B
+    +util/              \e$B%f!<%F%#%j%F%#\e(B
+    +wsock/             IDN \e$B%i%C%Q!<$N%=!<%9\e(B
+
+
+3. \e$BK\%-%C%H$,BP1~$7$F$$$k%7%9%F%`\e(B
+
+\e$B@5>o$K%$%s%9%H!<%k$G$-$k$3$H$,3NG'$G$-$F$$$k$N$O!"<!$N%7%9%F%`$G$9!#\e(B
+
+    ------------------------------------------------------------------
+    OS                      iconv              configure \e$B$N%*%W%7%g%s\e(B
+    ==================================================================
+    FreeBSD 4.7-RELEASE     GNU libiconv       --with-libiconv
+    Intel                   1.8
+    -------------------------------------------------------------------
+    Red Hat Linux 7.3       \e$BI8=`%i%$%V%i%j\e(B     \e$B$J$7\e(B
+    Intel                   (glibc)
+    ------------------------------------------------------------------
+    Solaris 9               \e$BI8=`%i%$%V%i%j\e(B     \e$B$J$7\e(B
+    Sparc                   (libc)
+    -------------------------------------------------------------------
+
+\e$BK\%-%C%H$,BP1~$7$F$$$k\e(B/\e$B$7$F$$$J$$%7%9%F%`$K4X$9$k:G?7$N>pJs$O!"<!$N$H\e(B
+\e$B$3$m$+$iC)$l$k\e(B mdnkit FAQ \e$B$N%Z!<%8$K5-$5$l$F$$$^$9!#\e(B
+
+       http://www.nic.ad.jp/ja/idn/
+
+
+4. \e$BK\%-%C%H$K4X$9$k:G?7>pJs!"Ld$$9g$o$;$K$D$$$F\e(B
+
+\e$BK\%-%C%H$K4X$9$k:G?7>pJs$K$D$$$F$O!"\e(B
+
+       http://www.nic.ad.jp/ja/idn/
+
+\e$B$r;2>H$7$F$/$@$5$$\e(B
+\e$BK\%-%C%H$K4X$9$k%P%0%l%]!<%H$*$h$S%3%a%s%H$O!"$=$l$>$l\e(B 
+
+       mdnkit-bugs@nic.ad.jp
+\e$B$*$h$S\e(B
+       idn-cmt@nic.ad.jp
+
+\e$B$X$*4j$$$7$^$9!#\e(B
+
+
+; $Id: README.ja,v 1.1 2003/06/04 00:24:59 marka Exp $
diff --git a/contrib/idn/idnkit-1.0-src/acconfig.h b/contrib/idn/idnkit-1.0-src/acconfig.h
new file mode 100644 (file)
index 0000000..0da81f2
--- /dev/null
@@ -0,0 +1,53 @@
+/* $Id: acconfig.h,v 1.1 2003/06/04 00:25:03 marka Exp $ */
+/*
+ * 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.
+ */
+@TOP@
+
+/* Define as an appropriate type (ex. int) if your system doesn't have. */
+#undef BOOL
+
+@BOTTOM@
+/* Define as the pathname of the shared libc object if your system has one. */
+#undef SOPATH_LIBC
+
+/* Define as the pathname of the shared libnsl object if your system has one. */
+#undef SOPATH_LIBNSL
diff --git a/contrib/idn/idnkit-1.0-src/aclocal.m4 b/contrib/idn/idnkit-1.0-src/aclocal.m4
new file mode 100644 (file)
index 0000000..b165a9a
--- /dev/null
@@ -0,0 +1,472 @@
+##
+## $Id: aclocal.m4,v 1.1 2003/06/04 00:25:05 marka Exp $
+##
+AC_DEFUN(AC_FIND_SYSTEM_SHOBJ,[
+AC_MSG_CHECKING(for $1 shared object)
+shobj_name=$1
+shobj_path=
+case "$host" in
+*-hpux*)
+    SOEXT=sl
+    ;;
+*)
+    SOEXT=so
+    ;;
+esac
+for shobj_libdir in /lib /usr/lib; do
+    if test -f $shobj_libdir/$shobj_name.$SOEXT; then
+        shobj_path=$shobj_libdir/$shobj_name.$SOEXT
+    else
+        shobj_path=`ls -r $shobj_libdir/$shobj_name.$SOEXT* 2>/dev/null | head -1`
+       if test "$shobj_path" != "" -a -f "$shobj_path"; then
+           :
+       else
+           shobj_path=
+       fi
+    fi
+    if test "$shobj_path" != ""; then
+       AC_MSG_RESULT($shobj_path)
+        shobj_pathsymbol=SOPATH_`echo $shobj_name | sed 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
+       AC_DEFINE_UNQUOTED($shobj_pathsymbol, "$shobj_path")
+       break
+    fi
+done
+if test "$shobj_path" = ""; then
+    AC_MSG_RESULT(no)
+fi
+])dnl
+
+## libtool.m4 - Configure libtool for the target system. -*-Shell-script-*-
+## Copyright (C) 1996-1999, 2000 Free Software Foundation, Inc.
+## Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+## General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+##
+## As a special exception to the GNU General Public License, if you
+## distribute this file as part of a program that contains a
+## configuration script generated by Autoconf, you may include it under
+## the same distribution terms that you use for the rest of that program.
+
+# serial 40 AC_PROG_LIBTOOL
+AC_DEFUN(AC_PROG_LIBTOOL,
+[AC_REQUIRE([AC_LIBTOOL_SETUP])dnl
+
+# Save cache, so that ltconfig can load it
+AC_CACHE_SAVE
+
+# Actually configure libtool.  ac_aux_dir is where install-sh is found.
+CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \
+LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \
+LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" \
+DLLTOOL="$DLLTOOL" AS="$AS" OBJDUMP="$OBJDUMP" \
+${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \
+$libtool_flags --no-verify $ac_aux_dir/ltmain.sh $lt_target \
+|| AC_MSG_ERROR([libtool configure failed])
+
+# Reload cache, that may have been modified by ltconfig
+AC_CACHE_LOAD
+
+# This can be used to rebuild libtool when needed
+LIBTOOL_DEPS="$ac_aux_dir/ltconfig $ac_aux_dir/ltmain.sh"
+
+# Always use our own libtool.
+LIBTOOL='$(SHELL) $(top_builddir)/libtool'
+AC_SUBST(LIBTOOL)dnl
+
+# Redirect the config.log output again, so that the ltconfig log is not
+# clobbered by the next message.
+exec 5>>./config.log
+])
+
+AC_DEFUN(AC_LIBTOOL_SETUP,
+[AC_PREREQ(2.13)dnl
+AC_REQUIRE([AC_ENABLE_SHARED])dnl
+AC_REQUIRE([AC_ENABLE_STATIC])dnl
+AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl
+AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_CANONICAL_BUILD])dnl
+AC_REQUIRE([AC_PROG_RANLIB])dnl
+AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([AC_PROG_LD])dnl
+AC_REQUIRE([AC_PROG_NM])dnl
+AC_REQUIRE([AC_PROG_LN_S])dnl
+dnl
+
+case "$target" in
+NONE) lt_target="$host" ;;
+*) lt_target="$target" ;;
+esac
+
+# Check for any special flags to pass to ltconfig.
+libtool_flags="--cache-file=$cache_file"
+test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared"
+test "$enable_static" = no && libtool_flags="$libtool_flags --disable-static"
+test "$enable_fast_install" = no && libtool_flags="$libtool_flags --disable-fast-install"
+test "$ac_cv_prog_gcc" = yes && libtool_flags="$libtool_flags --with-gcc"
+test "$ac_cv_prog_gnu_ld" = yes && libtool_flags="$libtool_flags --with-gnu-ld"
+ifdef([AC_PROVIDE_AC_LIBTOOL_DLOPEN],
+[libtool_flags="$libtool_flags --enable-dlopen"])
+ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL],
+[libtool_flags="$libtool_flags --enable-win32-dll"])
+AC_ARG_ENABLE(libtool-lock,
+  [  --disable-libtool-lock  avoid locking (might break parallel builds)])
+test "x$enable_libtool_lock" = xno && libtool_flags="$libtool_flags --disable-lock"
+test x"$silent" = xyes && libtool_flags="$libtool_flags --silent"
+
+# Some flags need to be propagated to the compiler or linker for good
+# libtool support.
+case "$lt_target" in
+*-*-irix6*)
+  # Find out which ABI we are using.
+  echo '[#]line __oline__ "configure"' > conftest.$ac_ext
+  if AC_TRY_EVAL(ac_compile); then
+    case "`/usr/bin/file conftest.o`" in
+    *32-bit*)
+      LD="${LD-ld} -32"
+      ;;
+    *N32*)
+      LD="${LD-ld} -n32"
+      ;;
+    *64-bit*)
+      LD="${LD-ld} -64"
+      ;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+
+*-*-sco3.2v5*)
+  # On SCO OpenServer 5, we need -belf to get full-featured binaries.
+  SAVE_CFLAGS="$CFLAGS"
+  CFLAGS="$CFLAGS -belf"
+  AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
+    [AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])])
+  if test x"$lt_cv_cc_needs_belf" != x"yes"; then
+    # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
+    CFLAGS="$SAVE_CFLAGS"
+  fi
+  ;;
+
+ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL],
+[*-*-cygwin* | *-*-mingw*)
+  AC_CHECK_TOOL(DLLTOOL, dlltool, false)
+  AC_CHECK_TOOL(AS, as, false)
+  AC_CHECK_TOOL(OBJDUMP, objdump, false)
+  ;;
+])
+esac
+])
+
+# AC_LIBTOOL_DLOPEN - enable checks for dlopen support
+AC_DEFUN(AC_LIBTOOL_DLOPEN, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])])
+
+# AC_LIBTOOL_WIN32_DLL - declare package support for building win32 dll's
+AC_DEFUN(AC_LIBTOOL_WIN32_DLL, [AC_BEFORE([$0], [AC_LIBTOOL_SETUP])])
+
+# AC_ENABLE_SHARED - implement the --enable-shared flag
+# Usage: AC_ENABLE_SHARED[(DEFAULT)]
+#   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
+#   `yes'.
+AC_DEFUN(AC_ENABLE_SHARED, [dnl
+define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl
+AC_ARG_ENABLE(shared,
+changequote(<<, >>)dnl
+<<  --enable-shared[=PKGS]  build shared libraries [default=>>AC_ENABLE_SHARED_DEFAULT],
+changequote([, ])dnl
+[p=${PACKAGE-default}
+case "$enableval" in
+yes) enable_shared=yes ;;
+no) enable_shared=no ;;
+*)
+  enable_shared=no
+  # Look at the argument we got.  We use all the common list separators.
+  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
+  for pkg in $enableval; do
+    if test "X$pkg" = "X$p"; then
+      enable_shared=yes
+    fi
+  done
+  IFS="$ac_save_ifs"
+  ;;
+esac],
+enable_shared=AC_ENABLE_SHARED_DEFAULT)dnl
+])
+
+# AC_DISABLE_SHARED - set the default shared flag to --disable-shared
+AC_DEFUN(AC_DISABLE_SHARED, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+AC_ENABLE_SHARED(no)])
+
+# AC_ENABLE_STATIC - implement the --enable-static flag
+# Usage: AC_ENABLE_STATIC[(DEFAULT)]
+#   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
+#   `yes'.
+AC_DEFUN(AC_ENABLE_STATIC, [dnl
+define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl
+AC_ARG_ENABLE(static,
+changequote(<<, >>)dnl
+<<  --enable-static[=PKGS]  build static libraries [default=>>AC_ENABLE_STATIC_DEFAULT],
+changequote([, ])dnl
+[p=${PACKAGE-default}
+case "$enableval" in
+yes) enable_static=yes ;;
+no) enable_static=no ;;
+*)
+  enable_static=no
+  # Look at the argument we got.  We use all the common list separators.
+  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
+  for pkg in $enableval; do
+    if test "X$pkg" = "X$p"; then
+      enable_static=yes
+    fi
+  done
+  IFS="$ac_save_ifs"
+  ;;
+esac],
+enable_static=AC_ENABLE_STATIC_DEFAULT)dnl
+])
+
+# AC_DISABLE_STATIC - set the default static flag to --disable-static
+AC_DEFUN(AC_DISABLE_STATIC, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+AC_ENABLE_STATIC(no)])
+
+
+# AC_ENABLE_FAST_INSTALL - implement the --enable-fast-install flag
+# Usage: AC_ENABLE_FAST_INSTALL[(DEFAULT)]
+#   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
+#   `yes'.
+AC_DEFUN(AC_ENABLE_FAST_INSTALL, [dnl
+define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl
+AC_ARG_ENABLE(fast-install,
+changequote(<<, >>)dnl
+<<  --enable-fast-install[=PKGS]  optimize for fast installation [default=>>AC_ENABLE_FAST_INSTALL_DEFAULT],
+changequote([, ])dnl
+[p=${PACKAGE-default}
+case "$enableval" in
+yes) enable_fast_install=yes ;;
+no) enable_fast_install=no ;;
+*)
+  enable_fast_install=no
+  # Look at the argument we got.  We use all the common list separators.
+  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
+  for pkg in $enableval; do
+    if test "X$pkg" = "X$p"; then
+      enable_fast_install=yes
+    fi
+  done
+  IFS="$ac_save_ifs"
+  ;;
+esac],
+enable_fast_install=AC_ENABLE_FAST_INSTALL_DEFAULT)dnl
+])
+
+# AC_ENABLE_FAST_INSTALL - set the default to --disable-fast-install
+AC_DEFUN(AC_DISABLE_FAST_INSTALL, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+AC_ENABLE_FAST_INSTALL(no)])
+
+# AC_PROG_LD - find the path to the GNU or non-GNU linker
+AC_DEFUN(AC_PROG_LD,
+[AC_ARG_WITH(gnu-ld,
+[  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]],
+test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
+AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_CANONICAL_BUILD])dnl
+ac_prog=ld
+if test "$ac_cv_prog_gcc" = yes; then
+  # Check if gcc -print-prog-name=ld gives a path.
+  AC_MSG_CHECKING([for ld used by GCC])
+  ac_prog=`($CC -print-prog-name=ld) 2>&5`
+  case "$ac_prog" in
+    # Accept absolute paths.
+changequote(,)dnl
+    [\\/]* | [A-Za-z]:[\\/]*)
+      re_direlt='/[^/][^/]*/\.\./'
+changequote([,])dnl
+      # Canonicalize the path of ld
+      ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
+      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
+       ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
+      done
+      test -z "$LD" && LD="$ac_prog"
+      ;;
+  "")
+    # If it fails, then pretend we aren't using GCC.
+    ac_prog=ld
+    ;;
+  *)
+    # If it is relative, then search for the first ld in PATH.
+    with_gnu_ld=unknown
+    ;;
+  esac
+elif test "$with_gnu_ld" = yes; then
+  AC_MSG_CHECKING([for GNU ld])
+else
+  AC_MSG_CHECKING([for non-GNU ld])
+fi
+AC_CACHE_VAL(ac_cv_path_LD,
+[if test -z "$LD"; then
+  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
+  for ac_dir in $PATH; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+      ac_cv_path_LD="$ac_dir/$ac_prog"
+      # Check to see if the program is GNU ld.  I'd rather use --version,
+      # but apparently some GNU ld's only accept -v.
+      # Break only if it was the GNU/non-GNU ld that we prefer.
+      if "$ac_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
+       test "$with_gnu_ld" != no && break
+      else
+       test "$with_gnu_ld" != yes && break
+      fi
+    fi
+  done
+  IFS="$ac_save_ifs"
+else
+  ac_cv_path_LD="$LD" # Let the user override the test with a path.
+fi])
+LD="$ac_cv_path_LD"
+if test -n "$LD"; then
+  AC_MSG_RESULT($LD)
+else
+  AC_MSG_RESULT(no)
+fi
+test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
+AC_PROG_LD_GNU
+])
+
+AC_DEFUN(AC_PROG_LD_GNU,
+[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], ac_cv_prog_gnu_ld,
+[# I'd rather use --version here, but apparently some GNU ld's only accept -v.
+if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
+  ac_cv_prog_gnu_ld=yes
+else
+  ac_cv_prog_gnu_ld=no
+fi])
+])
+
+# AC_PROG_NM - find the path to a BSD-compatible name lister
+AC_DEFUN(AC_PROG_NM,
+[AC_MSG_CHECKING([for BSD-compatible nm])
+AC_CACHE_VAL(ac_cv_path_NM,
+[if test -n "$NM"; then
+  # Let the user override the test.
+  ac_cv_path_NM="$NM"
+else
+  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
+  for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/nm || test -f $ac_dir/nm$ac_exeext ; then
+      # Check to see if the nm accepts a BSD-compat flag.
+      # Adding the `sed 1q' prevents false positives on HP-UX, which says:
+      #   nm: unknown option "B" ignored
+      if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
+       ac_cv_path_NM="$ac_dir/nm -B"
+       break
+      elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
+       ac_cv_path_NM="$ac_dir/nm -p"
+       break
+      else
+       ac_cv_path_NM=${ac_cv_path_NM="$ac_dir/nm"} # keep the first match, but
+       continue # so that we can try to find one that supports BSD flags
+      fi
+    fi
+  done
+  IFS="$ac_save_ifs"
+  test -z "$ac_cv_path_NM" && ac_cv_path_NM=nm
+fi])
+NM="$ac_cv_path_NM"
+AC_MSG_RESULT([$NM])
+])
+
+# AC_CHECK_LIBM - check for math library
+AC_DEFUN(AC_CHECK_LIBM,
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+LIBM=
+case "$lt_target" in
+*-*-beos* | *-*-cygwin*)
+  # These system don't have libm
+  ;;
+*-ncr-sysv4.3*)
+  AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
+  AC_CHECK_LIB(m, main, LIBM="$LIBM -lm")
+  ;;
+*)
+  AC_CHECK_LIB(m, main, LIBM="-lm")
+  ;;
+esac
+])
+
+# AC_LIBLTDL_CONVENIENCE[(dir)] - sets LIBLTDL to the link flags for
+# the libltdl convenience library and INCLTDL to the include flags for
+# the libltdl header and adds --enable-ltdl-convenience to the
+# configure arguments.  Note that LIBLTDL and INCLTDL are not
+# AC_SUBSTed, nor is AC_CONFIG_SUBDIRS called.  If DIR is not
+# provided, it is assumed to be `libltdl'.  LIBLTDL will be prefixed
+# with '${top_builddir}/' and INCLTDL will be prefixed with
+# '${top_srcdir}/' (note the single quotes!).  If your package is not
+# flat and you're not using automake, define top_builddir and
+# top_srcdir appropriately in the Makefiles.
+AC_DEFUN(AC_LIBLTDL_CONVENIENCE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+  case "$enable_ltdl_convenience" in
+  no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;;
+  "") enable_ltdl_convenience=yes
+      ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;;
+  esac
+  LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdlc.la
+  INCLTDL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl'])
+])
+
+# AC_LIBLTDL_INSTALLABLE[(dir)] - sets LIBLTDL to the link flags for
+# the libltdl installable library and INCLTDL to the include flags for
+# the libltdl header and adds --enable-ltdl-install to the configure
+# arguments.  Note that LIBLTDL and INCLTDL are not AC_SUBSTed, nor is
+# AC_CONFIG_SUBDIRS called.  If DIR is not provided and an installed
+# libltdl is not found, it is assumed to be `libltdl'.  LIBLTDL will
+# be prefixed with '${top_builddir}/' and INCLTDL will be prefixed
+# with '${top_srcdir}/' (note the single quotes!).  If your package is
+# not flat and you're not using automake, define top_builddir and
+# top_srcdir appropriately in the Makefiles.
+# In the future, this macro may have to be called after AC_PROG_LIBTOOL.
+AC_DEFUN(AC_LIBLTDL_INSTALLABLE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+  AC_CHECK_LIB(ltdl, main,
+  [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no],
+  [if test x"$enable_ltdl_install" = xno; then
+     AC_MSG_WARN([libltdl not installed, but installation disabled])
+   else
+     enable_ltdl_install=yes
+   fi
+  ])
+  if test x"$enable_ltdl_install" = x"yes"; then
+    ac_configure_args="$ac_configure_args --enable-ltdl-install"
+    LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdl.la
+    INCLTDL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl'])
+  else
+    ac_configure_args="$ac_configure_args --enable-ltdl-install=no"
+    LIBLTDL="-lltdl"
+    INCLTDL=
+  fi
+])
+
+dnl old names
+AC_DEFUN(AM_PROG_LIBTOOL, [indir([AC_PROG_LIBTOOL])])dnl
+AC_DEFUN(AM_ENABLE_SHARED, [indir([AC_ENABLE_SHARED], $@)])dnl
+AC_DEFUN(AM_ENABLE_STATIC, [indir([AC_ENABLE_STATIC], $@)])dnl
+AC_DEFUN(AM_DISABLE_SHARED, [indir([AC_DISABLE_SHARED], $@)])dnl
+AC_DEFUN(AM_DISABLE_STATIC, [indir([AC_DISABLE_STATIC], $@)])dnl
+AC_DEFUN(AM_PROG_LD, [indir([AC_PROG_LD])])dnl
+AC_DEFUN(AM_PROG_NM, [indir([AC_PROG_NM])])dnl
+
+dnl This is just to silence aclocal about the macro not being used
+ifelse([AC_DISABLE_FAST_INSTALL])dnl
diff --git a/contrib/idn/idnkit-1.0-src/config.guess b/contrib/idn/idnkit-1.0-src/config.guess
new file mode 100755 (executable)
index 0000000..dff9e48
--- /dev/null
@@ -0,0 +1,1317 @@
+#! /bin/sh
+# Attempt to guess a canonical system name.
+#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+#   Free Software Foundation, Inc.
+
+timestamp='2001-09-04'
+
+# This file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Written by Per Bothner <bothner@cygnus.com>.
+# Please send patches to <config-patches@gnu.org>.
+#
+# This script attempts to guess a canonical system name similar to
+# config.sub.  If it succeeds, it prints the system name on stdout, and
+# exits with 0.  Otherwise, it exits with 1.
+#
+# The plan is that this can be called by configure scripts if you
+# don't specify an explicit build system type.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION]
+
+Output the configuration name of the system \`$me' is run on.
+
+Operation modes:
+  -h, --help         print this help, then exit
+  -t, --time-stamp   print date of last modification, then exit
+  -v, --version      print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.guess ($timestamp)
+
+Originally written by Per Bothner.
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions.  There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+  case $1 in
+    --time-stamp | --time* | -t )
+       echo "$timestamp" ; exit 0 ;;
+    --version | -v )
+       echo "$version" ; exit 0 ;;
+    --help | --h* | -h )
+       echo "$usage"; exit 0 ;;
+    -- )     # Stop option processing
+       shift; break ;;
+    - )        # Use stdin as input.
+       break ;;
+    -* )
+       echo "$me: invalid option $1$help" >&2
+       exit 1 ;;
+    * )
+       break ;;
+  esac
+done
+
+if test $# != 0; then
+  echo "$me: too many arguments$help" >&2
+  exit 1
+fi
+
+
+dummy=dummy-$$
+trap 'rm -f $dummy.c $dummy.o $dummy.rel $dummy; exit 1' 1 2 15
+
+# CC_FOR_BUILD -- compiler used by this script.
+# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
+# use `HOST_CC' if defined, but it is deprecated.
+
+set_cc_for_build='case $CC_FOR_BUILD,$HOST_CC,$CC in
+ ,,)    echo "int dummy(){}" > $dummy.c ;
+       for c in cc gcc c89 ; do
+         ($c $dummy.c -c -o $dummy.o) >/dev/null 2>&1 ;
+         if test $? = 0 ; then
+            CC_FOR_BUILD="$c"; break ;
+         fi ;
+       done ;
+       rm -f $dummy.c $dummy.o $dummy.rel ;
+       if test x"$CC_FOR_BUILD" = x ; then
+         CC_FOR_BUILD=no_compiler_found ;
+       fi
+       ;;
+ ,,*)   CC_FOR_BUILD=$CC ;;
+ ,*,*)  CC_FOR_BUILD=$HOST_CC ;;
+esac'
+
+# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
+# (ghazi@noc.rutgers.edu 1994-08-24)
+if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
+       PATH=$PATH:/.attbin ; export PATH
+fi
+
+UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
+UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
+UNAME_SYSTEM=`(uname -s) 2>/dev/null`  || UNAME_SYSTEM=unknown
+UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
+
+# Note: order is significant - the case branches are not exclusive.
+
+case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
+    *:NetBSD:*:*)
+       # Netbsd (nbsd) targets should (where applicable) match one or
+       # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
+       # *-*-netbsdecoff* and *-*-netbsd*.  For targets that recently
+       # switched to ELF, *-*-netbsd* would select the old
+       # object file format.  This provides both forward
+       # compatibility and a consistent mechanism for selecting the
+       # object file format.
+       # Determine the machine/vendor (is the vendor relevant).
+       case "${UNAME_MACHINE}" in
+           amiga) machine=m68k-unknown ;;
+           arm32) machine=arm-unknown ;;
+           atari*) machine=m68k-atari ;;
+           sun3*) machine=m68k-sun ;;
+           mac68k) machine=m68k-apple ;;
+           macppc) machine=powerpc-apple ;;
+           hp3[0-9][05]) machine=m68k-hp ;;
+           ibmrt|romp-ibm) machine=romp-ibm ;;
+           *) machine=${UNAME_MACHINE}-unknown ;;
+       esac
+       # The Operating System including object format, if it has switched
+       # to ELF recently, or will in the future.
+       case "${UNAME_MACHINE}" in
+           i386|sparc|amiga|arm*|hp300|mvme68k|vax|atari|luna68k|mac68k|news68k|next68k|pc532|sun3*|x68k)
+               eval $set_cc_for_build
+               if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
+                       | grep __ELF__ >/dev/null
+               then
+                   # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
+                   # Return netbsd for either.  FIX?
+                   os=netbsd
+               else
+                   os=netbsdelf
+               fi
+               ;;
+           *)
+               os=netbsd
+               ;;
+       esac
+       # The OS release
+       release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+       # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
+       # contains redundant information, the shorter form:
+       # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
+       echo "${machine}-${os}${release}"
+       exit 0 ;;
+    alpha:OSF1:*:*)
+       if test $UNAME_RELEASE = "V4.0"; then
+               UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
+       fi
+       # A Vn.n version is a released version.
+       # A Tn.n version is a released field test version.
+       # A Xn.n version is an unreleased experimental baselevel.
+       # 1.2 uses "1.2" for uname -r.
+       cat <<EOF >$dummy.s
+       .data
+\$Lformat:
+       .byte 37,100,45,37,120,10,0     # "%d-%x\n"
+
+       .text
+       .globl main
+       .align 4
+       .ent main
+main:
+       .frame \$30,16,\$26,0
+       ldgp \$29,0(\$27)
+       .prologue 1
+       .long 0x47e03d80 # implver \$0
+       lda \$2,-1
+       .long 0x47e20c21 # amask \$2,\$1
+       lda \$16,\$Lformat
+       mov \$0,\$17
+       not \$1,\$18
+       jsr \$26,printf
+       ldgp \$29,0(\$26)
+       mov 0,\$16
+       jsr \$26,exit
+       .end main
+EOF
+       eval $set_cc_for_build
+       $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null
+       if test "$?" = 0 ; then
+               case `./$dummy` in
+                       0-0)
+                               UNAME_MACHINE="alpha"
+                               ;;
+                       1-0)
+                               UNAME_MACHINE="alphaev5"
+                               ;;
+                       1-1)
+                               UNAME_MACHINE="alphaev56"
+                               ;;
+                       1-101)
+                               UNAME_MACHINE="alphapca56"
+                               ;;
+                       2-303)
+                               UNAME_MACHINE="alphaev6"
+                               ;;
+                       2-307)
+                               UNAME_MACHINE="alphaev67"
+                               ;;
+                       2-1307)
+                               UNAME_MACHINE="alphaev68"
+                               ;;
+               esac
+       fi
+       rm -f $dummy.s $dummy
+       echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+       exit 0 ;;
+    Alpha\ *:Windows_NT*:*)
+       # How do we know it's Interix rather than the generic POSIX subsystem?
+       # Should we change UNAME_MACHINE based on the output of uname instead
+       # of the specific Alpha model?
+       echo alpha-pc-interix
+       exit 0 ;;
+    21064:Windows_NT:50:3)
+       echo alpha-dec-winnt3.5
+       exit 0 ;;
+    Amiga*:UNIX_System_V:4.0:*)
+       echo m68k-unknown-sysv4
+       exit 0;;
+    amiga:OpenBSD:*:*)
+       echo m68k-unknown-openbsd${UNAME_RELEASE}
+       exit 0 ;;
+    *:[Aa]miga[Oo][Ss]:*:*)
+       echo ${UNAME_MACHINE}-unknown-amigaos
+       exit 0 ;;
+    arc64:OpenBSD:*:*)
+       echo mips64el-unknown-openbsd${UNAME_RELEASE}
+       exit 0 ;;
+    arc:OpenBSD:*:*)
+       echo mipsel-unknown-openbsd${UNAME_RELEASE}
+       exit 0 ;;
+    hkmips:OpenBSD:*:*)
+       echo mips-unknown-openbsd${UNAME_RELEASE}
+       exit 0 ;;
+    pmax:OpenBSD:*:*)
+       echo mipsel-unknown-openbsd${UNAME_RELEASE}
+       exit 0 ;;
+    sgi:OpenBSD:*:*)
+       echo mips-unknown-openbsd${UNAME_RELEASE}
+       exit 0 ;;
+    wgrisc:OpenBSD:*:*)
+       echo mipsel-unknown-openbsd${UNAME_RELEASE}
+       exit 0 ;;
+    *:OS/390:*:*)
+       echo i370-ibm-openedition
+       exit 0 ;;
+    arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
+       echo arm-acorn-riscix${UNAME_RELEASE}
+       exit 0;;
+    SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
+       echo hppa1.1-hitachi-hiuxmpp
+       exit 0;;
+    Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
+       # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
+       if test "`(/bin/universe) 2>/dev/null`" = att ; then
+               echo pyramid-pyramid-sysv3
+       else
+               echo pyramid-pyramid-bsd
+       fi
+       exit 0 ;;
+    NILE*:*:*:dcosx)
+       echo pyramid-pyramid-svr4
+       exit 0 ;;
+    sun4H:SunOS:5.*:*)
+       echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit 0 ;;
+    sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
+       echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit 0 ;;
+    i86pc:SunOS:5.*:*)
+       echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit 0 ;;
+    sun4*:SunOS:6*:*)
+       # According to config.sub, this is the proper way to canonicalize
+       # SunOS6.  Hard to guess exactly what SunOS6 will be like, but
+       # it's likely to be more like Solaris than SunOS4.
+       echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit 0 ;;
+    sun4*:SunOS:*:*)
+       case "`/usr/bin/arch -k`" in
+           Series*|S4*)
+               UNAME_RELEASE=`uname -v`
+               ;;
+       esac
+       # Japanese Language versions have a version number like `4.1.3-JL'.
+       echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
+       exit 0 ;;
+    sun3*:SunOS:*:*)
+       echo m68k-sun-sunos${UNAME_RELEASE}
+       exit 0 ;;
+    sun*:*:4.2BSD:*)
+       UNAME_RELEASE=`(head -1 /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
+       test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
+       case "`/bin/arch`" in
+           sun3)
+               echo m68k-sun-sunos${UNAME_RELEASE}
+               ;;
+           sun4)
+               echo sparc-sun-sunos${UNAME_RELEASE}
+               ;;
+       esac
+       exit 0 ;;
+    aushp:SunOS:*:*)
+       echo sparc-auspex-sunos${UNAME_RELEASE}
+       exit 0 ;;
+    sparc*:NetBSD:*)
+       echo `uname -p`-unknown-netbsd${UNAME_RELEASE}
+       exit 0 ;;
+    atari*:OpenBSD:*:*)
+       echo m68k-unknown-openbsd${UNAME_RELEASE}
+       exit 0 ;;
+    # The situation for MiNT is a little confusing.  The machine name
+    # can be virtually everything (everything which is not
+    # "atarist" or "atariste" at least should have a processor
+    # > m68000).  The system name ranges from "MiNT" over "FreeMiNT"
+    # to the lowercase version "mint" (or "freemint").  Finally
+    # the system name "TOS" denotes a system which is actually not
+    # MiNT.  But MiNT is downward compatible to TOS, so this should
+    # be no problem.
+    atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
+        echo m68k-atari-mint${UNAME_RELEASE}
+       exit 0 ;;
+    atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
+       echo m68k-atari-mint${UNAME_RELEASE}
+        exit 0 ;;
+    *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
+        echo m68k-atari-mint${UNAME_RELEASE}
+       exit 0 ;;
+    milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
+        echo m68k-milan-mint${UNAME_RELEASE}
+        exit 0 ;;
+    hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
+        echo m68k-hades-mint${UNAME_RELEASE}
+        exit 0 ;;
+    *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
+        echo m68k-unknown-mint${UNAME_RELEASE}
+        exit 0 ;;
+    sun3*:OpenBSD:*:*)
+       echo m68k-unknown-openbsd${UNAME_RELEASE}
+       exit 0 ;;
+    mac68k:OpenBSD:*:*)
+       echo m68k-unknown-openbsd${UNAME_RELEASE}
+       exit 0 ;;
+    mvme68k:OpenBSD:*:*)
+       echo m68k-unknown-openbsd${UNAME_RELEASE}
+       exit 0 ;;
+    mvme88k:OpenBSD:*:*)
+       echo m88k-unknown-openbsd${UNAME_RELEASE}
+       exit 0 ;;
+    powerpc:machten:*:*)
+       echo powerpc-apple-machten${UNAME_RELEASE}
+       exit 0 ;;
+    RISC*:Mach:*:*)
+       echo mips-dec-mach_bsd4.3
+       exit 0 ;;
+    RISC*:ULTRIX:*:*)
+       echo mips-dec-ultrix${UNAME_RELEASE}
+       exit 0 ;;
+    VAX*:ULTRIX*:*:*)
+       echo vax-dec-ultrix${UNAME_RELEASE}
+       exit 0 ;;
+    2020:CLIX:*:* | 2430:CLIX:*:*)
+       echo clipper-intergraph-clix${UNAME_RELEASE}
+       exit 0 ;;
+    mips:*:*:UMIPS | mips:*:*:RISCos)
+       eval $set_cc_for_build
+       sed 's/^        //' << EOF >$dummy.c
+#ifdef __cplusplus
+#include <stdio.h>  /* for printf() prototype */
+       int main (int argc, char *argv[]) {
+#else
+       int main (argc, argv) int argc; char *argv[]; {
+#endif
+       #if defined (host_mips) && defined (MIPSEB)
+       #if defined (SYSTYPE_SYSV)
+         printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
+       #endif
+       #if defined (SYSTYPE_SVR4)
+         printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
+       #endif
+       #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
+         printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
+       #endif
+       #endif
+         exit (-1);
+       }
+EOF
+       $CC_FOR_BUILD $dummy.c -o $dummy \
+         && ./$dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
+         && rm -f $dummy.c $dummy && exit 0
+       rm -f $dummy.c $dummy
+       echo mips-mips-riscos${UNAME_RELEASE}
+       exit 0 ;;
+    Motorola:PowerMAX_OS:*:*)
+       echo powerpc-motorola-powermax
+       exit 0 ;;
+    Night_Hawk:Power_UNIX:*:*)
+       echo powerpc-harris-powerunix
+       exit 0 ;;
+    m88k:CX/UX:7*:*)
+       echo m88k-harris-cxux7
+       exit 0 ;;
+    m88k:*:4*:R4*)
+       echo m88k-motorola-sysv4
+       exit 0 ;;
+    m88k:*:3*:R3*)
+       echo m88k-motorola-sysv3
+       exit 0 ;;
+    AViiON:dgux:*:*)
+        # DG/UX returns AViiON for all architectures
+        UNAME_PROCESSOR=`/usr/bin/uname -p`
+       if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
+       then
+           if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
+              [ ${TARGET_BINARY_INTERFACE}x = x ]
+           then
+               echo m88k-dg-dgux${UNAME_RELEASE}
+           else
+               echo m88k-dg-dguxbcs${UNAME_RELEASE}
+           fi
+       else
+           echo i586-dg-dgux${UNAME_RELEASE}
+       fi
+       exit 0 ;;
+    M88*:DolphinOS:*:*)        # DolphinOS (SVR3)
+       echo m88k-dolphin-sysv3
+       exit 0 ;;
+    M88*:*:R3*:*)
+       # Delta 88k system running SVR3
+       echo m88k-motorola-sysv3
+       exit 0 ;;
+    XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
+       echo m88k-tektronix-sysv3
+       exit 0 ;;
+    Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
+       echo m68k-tektronix-bsd
+       exit 0 ;;
+    *:IRIX*:*:*)
+       echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
+       exit 0 ;;
+    ????????:AIX?:[12].1:2)   # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
+       echo romp-ibm-aix      # uname -m gives an 8 hex-code CPU id
+       exit 0 ;;              # Note that: echo "'`uname -s`'" gives 'AIX '
+    i*86:AIX:*:*)
+       echo i386-ibm-aix
+       exit 0 ;;
+    ia64:AIX:*:*)
+       if [ -x /usr/bin/oslevel ] ; then
+               IBM_REV=`/usr/bin/oslevel`
+       else
+               IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+       fi
+       echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
+       exit 0 ;;
+    *:AIX:2:3)
+       if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
+               eval $set_cc_for_build
+               sed 's/^                //' << EOF >$dummy.c
+               #include <sys/systemcfg.h>
+
+               main()
+                       {
+                       if (!__power_pc())
+                               exit(1);
+                       puts("powerpc-ibm-aix3.2.5");
+                       exit(0);
+                       }
+EOF
+               $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0
+               rm -f $dummy.c $dummy
+               echo rs6000-ibm-aix3.2.5
+       elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
+               echo rs6000-ibm-aix3.2.4
+       else
+               echo rs6000-ibm-aix3.2
+       fi
+       exit 0 ;;
+    *:AIX:*:[45])
+       IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | head -1 | awk '{ print $1 }'`
+       if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
+               IBM_ARCH=rs6000
+       else
+               IBM_ARCH=powerpc
+       fi
+       if [ -x /usr/bin/oslevel ] ; then
+               IBM_REV=`/usr/bin/oslevel`
+       else
+               IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+       fi
+       echo ${IBM_ARCH}-ibm-aix${IBM_REV}
+       exit 0 ;;
+    *:AIX:*:*)
+       echo rs6000-ibm-aix
+       exit 0 ;;
+    ibmrt:4.4BSD:*|romp-ibm:BSD:*)
+       echo romp-ibm-bsd4.4
+       exit 0 ;;
+    ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC BSD and
+       echo romp-ibm-bsd${UNAME_RELEASE}   # 4.3 with uname added to
+       exit 0 ;;                           # report: romp-ibm BSD 4.3
+    *:BOSX:*:*)
+       echo rs6000-bull-bosx
+       exit 0 ;;
+    DPX/2?00:B.O.S.:*:*)
+       echo m68k-bull-sysv3
+       exit 0 ;;
+    9000/[34]??:4.3bsd:1.*:*)
+       echo m68k-hp-bsd
+       exit 0 ;;
+    hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
+       echo m68k-hp-bsd4.4
+       exit 0 ;;
+    9000/[34678]??:HP-UX:*:*)
+       HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+       case "${UNAME_MACHINE}" in
+           9000/31? )            HP_ARCH=m68000 ;;
+           9000/[34]?? )         HP_ARCH=m68k ;;
+           9000/[678][0-9][0-9])
+              case "${HPUX_REV}" in
+                11.[0-9][0-9])
+                  if [ -x /usr/bin/getconf ]; then
+                    sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
+                    sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
+                    case "${sc_cpu_version}" in
+                      523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
+                      528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
+                      532)                      # CPU_PA_RISC2_0
+                        case "${sc_kernel_bits}" in
+                          32) HP_ARCH="hppa2.0n" ;;
+                          64) HP_ARCH="hppa2.0w" ;;
+                        esac ;;
+                    esac
+                  fi ;;
+              esac
+              if [ "${HP_ARCH}" = "" ]; then
+             eval $set_cc_for_build
+              sed 's/^              //' << EOF >$dummy.c
+
+              #define _HPUX_SOURCE
+              #include <stdlib.h>
+              #include <unistd.h>
+
+              int main ()
+              {
+              #if defined(_SC_KERNEL_BITS)
+                  long bits = sysconf(_SC_KERNEL_BITS);
+              #endif
+                  long cpu  = sysconf (_SC_CPU_VERSION);
+
+                  switch (cpu)
+               {
+               case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
+               case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
+               case CPU_PA_RISC2_0:
+              #if defined(_SC_KERNEL_BITS)
+                   switch (bits)
+                       {
+                       case 64: puts ("hppa2.0w"); break;
+                       case 32: puts ("hppa2.0n"); break;
+                       default: puts ("hppa2.0"); break;
+                       } break;
+              #else  /* !defined(_SC_KERNEL_BITS) */
+                   puts ("hppa2.0"); break;
+              #endif
+               default: puts ("hppa1.0"); break;
+               }
+                  exit (0);
+              }
+EOF
+           (CCOPTS= $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null ) && HP_ARCH=`./$dummy`
+           if test -z "$HP_ARCH"; then HP_ARCH=hppa; fi
+           rm -f $dummy.c $dummy
+       fi ;;
+       esac
+       echo ${HP_ARCH}-hp-hpux${HPUX_REV}
+       exit 0 ;;
+    ia64:HP-UX:*:*)
+       HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+       echo ia64-hp-hpux${HPUX_REV}
+       exit 0 ;;
+    3050*:HI-UX:*:*)
+       eval $set_cc_for_build
+       sed 's/^        //' << EOF >$dummy.c
+       #include <unistd.h>
+       int
+       main ()
+       {
+         long cpu = sysconf (_SC_CPU_VERSION);
+         /* The order matters, because CPU_IS_HP_MC68K erroneously returns
+            true for CPU_PA_RISC1_0.  CPU_IS_PA_RISC returns correct
+            results, however.  */
+         if (CPU_IS_PA_RISC (cpu))
+           {
+             switch (cpu)
+               {
+                 case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
+                 case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
+                 case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
+                 default: puts ("hppa-hitachi-hiuxwe2"); break;
+               }
+           }
+         else if (CPU_IS_HP_MC68K (cpu))
+           puts ("m68k-hitachi-hiuxwe2");
+         else puts ("unknown-hitachi-hiuxwe2");
+         exit (0);
+       }
+EOF
+       $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0
+       rm -f $dummy.c $dummy
+       echo unknown-hitachi-hiuxwe2
+       exit 0 ;;
+    9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
+       echo hppa1.1-hp-bsd
+       exit 0 ;;
+    9000/8??:4.3bsd:*:*)
+       echo hppa1.0-hp-bsd
+       exit 0 ;;
+    *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
+       echo hppa1.0-hp-mpeix
+       exit 0 ;;
+    hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
+       echo hppa1.1-hp-osf
+       exit 0 ;;
+    hp8??:OSF1:*:*)
+       echo hppa1.0-hp-osf
+       exit 0 ;;
+    i*86:OSF1:*:*)
+       if [ -x /usr/sbin/sysversion ] ; then
+           echo ${UNAME_MACHINE}-unknown-osf1mk
+       else
+           echo ${UNAME_MACHINE}-unknown-osf1
+       fi
+       exit 0 ;;
+    parisc*:Lites*:*:*)
+       echo hppa1.1-hp-lites
+       exit 0 ;;
+    hppa*:OpenBSD:*:*)
+       echo hppa-unknown-openbsd
+       exit 0 ;;
+    C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
+       echo c1-convex-bsd
+        exit 0 ;;
+    C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
+       if getsysinfo -f scalar_acc
+       then echo c32-convex-bsd
+       else echo c2-convex-bsd
+       fi
+        exit 0 ;;
+    C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
+       echo c34-convex-bsd
+        exit 0 ;;
+    C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
+       echo c38-convex-bsd
+        exit 0 ;;
+    C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
+       echo c4-convex-bsd
+        exit 0 ;;
+    CRAY*X-MP:*:*:*)
+       echo xmp-cray-unicos
+        exit 0 ;;
+    CRAY*Y-MP:*:*:*)
+       echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       exit 0 ;;
+    CRAY*[A-Z]90:*:*:*)
+       echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
+       | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
+             -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
+             -e 's/\.[^.]*$/.X/'
+       exit 0 ;;
+    CRAY*TS:*:*:*)
+       echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       exit 0 ;;
+    CRAY*T3D:*:*:*)
+       echo alpha-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       exit 0 ;;
+    CRAY*T3E:*:*:*)
+       echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       exit 0 ;;
+    CRAY*SV1:*:*:*)
+       echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       exit 0 ;;
+    CRAY-2:*:*:*)
+       echo cray2-cray-unicos
+        exit 0 ;;
+    F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
+       FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+        FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
+        echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+        exit 0 ;;
+    hp300:OpenBSD:*:*)
+       echo m68k-unknown-openbsd${UNAME_RELEASE}
+       exit 0 ;;
+    i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
+       echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
+       exit 0 ;;
+    sparc*:BSD/OS:*:*)
+       echo sparc-unknown-bsdi${UNAME_RELEASE}
+       exit 0 ;;
+    *:BSD/OS:*:*)
+       echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
+       exit 0 ;;
+    *:FreeBSD:*:*)
+       echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
+       exit 0 ;;
+    *:OpenBSD:*:*)
+       echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+       exit 0 ;;
+    i*:CYGWIN*:*)
+       echo ${UNAME_MACHINE}-pc-cygwin
+       exit 0 ;;
+    i*:MINGW*:*)
+       echo ${UNAME_MACHINE}-pc-mingw32
+       exit 0 ;;
+    i*:PW*:*)
+       echo ${UNAME_MACHINE}-pc-pw32
+       exit 0 ;;
+    i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
+       # How do we know it's Interix rather than the generic POSIX subsystem?
+       # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
+       # UNAME_MACHINE based on the output of uname instead of i386?
+       echo i386-pc-interix
+       exit 0 ;;
+    i*:UWIN*:*)
+       echo ${UNAME_MACHINE}-pc-uwin
+       exit 0 ;;
+    p*:CYGWIN*:*)
+       echo powerpcle-unknown-cygwin
+       exit 0 ;;
+    prep*:SunOS:5.*:*)
+       echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit 0 ;;
+    *:GNU:*:*)
+       echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
+       exit 0 ;;
+    i*86:Minix:*:*)
+       echo ${UNAME_MACHINE}-pc-minix
+       exit 0 ;;
+    arm*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit 0 ;;
+    ia64:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux
+       exit 0 ;;
+    m68*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit 0 ;;
+    mips:Linux:*:*)
+       case `sed -n '/^byte/s/^.*: \(.*\) endian/\1/p' < /proc/cpuinfo` in
+         big)    echo mips-unknown-linux-gnu && exit 0 ;;
+         little) echo mipsel-unknown-linux-gnu && exit 0 ;;
+       esac
+       ;;
+    ppc:Linux:*:*)
+       echo powerpc-unknown-linux-gnu
+       exit 0 ;;
+    ppc64:Linux:*:*)
+       echo powerpc64-unknown-linux-gnu
+       exit 0 ;;
+    alpha:Linux:*:*)
+       case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
+         EV5)   UNAME_MACHINE=alphaev5 ;;
+         EV56)  UNAME_MACHINE=alphaev56 ;;
+         PCA56) UNAME_MACHINE=alphapca56 ;;
+         PCA57) UNAME_MACHINE=alphapca56 ;;
+         EV6)   UNAME_MACHINE=alphaev6 ;;
+         EV67)  UNAME_MACHINE=alphaev67 ;;
+         EV68*) UNAME_MACHINE=alphaev68 ;;
+        esac
+       objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null
+       if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
+       echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
+       exit 0 ;;
+    parisc:Linux:*:* | hppa:Linux:*:*)
+       # Look for CPU level
+       case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
+         PA7*) echo hppa1.1-unknown-linux-gnu ;;
+         PA8*) echo hppa2.0-unknown-linux-gnu ;;
+         *)    echo hppa-unknown-linux-gnu ;;
+       esac
+       exit 0 ;;
+    parisc64:Linux:*:* | hppa64:Linux:*:*)
+       echo hppa64-unknown-linux-gnu
+       exit 0 ;;
+    s390:Linux:*:* | s390x:Linux:*:*)
+       echo ${UNAME_MACHINE}-ibm-linux
+       exit 0 ;;
+    sh*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit 0 ;;
+    sparc:Linux:*:* | sparc64:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit 0 ;;
+    x86_64:Linux:*:*)
+       echo x86_64-unknown-linux-gnu
+       exit 0 ;;
+    i*86:Linux:*:*)
+       # The BFD linker knows what the default object file format is, so
+       # first see if it will tell us. cd to the root directory to prevent
+       # problems with other programs or directories called `ld' in the path.
+       ld_supported_targets=`cd /; ld --help 2>&1 \
+                        | sed -ne '/supported targets:/!d
+                                   s/[         ][      ]*/ /g
+                                   s/.*supported targets: *//
+                                   s/ .*//
+                                   p'`
+        case "$ld_supported_targets" in
+         elf32-i386)
+               TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
+               ;;
+         a.out-i386-linux)
+               echo "${UNAME_MACHINE}-pc-linux-gnuaout"
+               exit 0 ;;               
+         coff-i386)
+               echo "${UNAME_MACHINE}-pc-linux-gnucoff"
+               exit 0 ;;
+         "")
+               # Either a pre-BFD a.out linker (linux-gnuoldld) or
+               # one that does not give us useful --help.
+               echo "${UNAME_MACHINE}-pc-linux-gnuoldld"
+               exit 0 ;;
+       esac
+       # Determine whether the default compiler is a.out or elf
+       eval $set_cc_for_build
+       cat >$dummy.c <<EOF
+#include <features.h>
+#ifdef __cplusplus
+#include <stdio.h>  /* for printf() prototype */
+       int main (int argc, char *argv[]) {
+#else
+       int main (argc, argv) int argc; char *argv[]; {
+#endif
+#ifdef __ELF__
+# ifdef __GLIBC__
+#  if __GLIBC__ >= 2
+    printf ("%s-pc-linux-gnu\n", argv[1]);
+#  else
+    printf ("%s-pc-linux-gnulibc1\n", argv[1]);
+#  endif
+# else
+   printf ("%s-pc-linux-gnulibc1\n", argv[1]);
+# endif
+#else
+  printf ("%s-pc-linux-gnuaout\n", argv[1]);
+#endif
+  return 0;
+}
+EOF
+       $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm -f $dummy.c $dummy && exit 0
+       rm -f $dummy.c $dummy
+       test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0
+       ;;
+    i*86:DYNIX/ptx:4*:*)
+       # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
+       # earlier versions are messed up and put the nodename in both
+       # sysname and nodename.
+       echo i386-sequent-sysv4
+       exit 0 ;;
+    i*86:UNIX_SV:4.2MP:2.*)
+        # Unixware is an offshoot of SVR4, but it has its own version
+        # number series starting with 2...
+        # I am not positive that other SVR4 systems won't match this,
+       # I just have to hope.  -- rms.
+        # Use sysv4.2uw... so that sysv4* matches it.
+       echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
+       exit 0 ;;
+    i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
+       UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
+       if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
+               echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
+       else
+               echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
+       fi
+       exit 0 ;;
+    i*86:*:5:[78]*)
+       case `/bin/uname -X | grep "^Machine"` in
+           *486*)           UNAME_MACHINE=i486 ;;
+           *Pentium)        UNAME_MACHINE=i586 ;;
+           *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
+       esac
+       echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
+       exit 0 ;;
+    i*86:*:3.2:*)
+       if test -f /usr/options/cb.name; then
+               UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
+               echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
+       elif /bin/uname -X 2>/dev/null >/dev/null ; then
+               UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')`
+               (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486
+               (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \
+                       && UNAME_MACHINE=i586
+               (/bin/uname -X|egrep '^Machine.*Pent ?II' >/dev/null) \
+                       && UNAME_MACHINE=i686
+               (/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) \
+                       && UNAME_MACHINE=i686
+               echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
+       else
+               echo ${UNAME_MACHINE}-pc-sysv32
+       fi
+       exit 0 ;;
+    i*86:*DOS:*:*)
+       echo ${UNAME_MACHINE}-pc-msdosdjgpp
+       exit 0 ;;
+    pc:*:*:*)
+       # Left here for compatibility:
+        # uname -m prints for DJGPP always 'pc', but it prints nothing about
+        # the processor, so we play safe by assuming i386.
+       echo i386-pc-msdosdjgpp
+        exit 0 ;;
+    Intel:Mach:3*:*)
+       echo i386-pc-mach3
+       exit 0 ;;
+    paragon:*:*:*)
+       echo i860-intel-osf1
+       exit 0 ;;
+    i860:*:4.*:*) # i860-SVR4
+       if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
+         echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
+       else # Add other i860-SVR4 vendors below as they are discovered.
+         echo i860-unknown-sysv${UNAME_RELEASE}  # Unknown i860-SVR4
+       fi
+       exit 0 ;;
+    mini*:CTIX:SYS*5:*)
+       # "miniframe"
+       echo m68010-convergent-sysv
+       exit 0 ;;
+    M68*:*:R3V[567]*:*)
+       test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;
+    3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0)
+       OS_REL=''
+       test -r /etc/.relid \
+       && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+       /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+         && echo i486-ncr-sysv4.3${OS_REL} && exit 0
+       /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+         && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;;
+    3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
+        /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+          && echo i486-ncr-sysv4 && exit 0 ;;
+    m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
+       echo m68k-unknown-lynxos${UNAME_RELEASE}
+       exit 0 ;;
+    mc68030:UNIX_System_V:4.*:*)
+       echo m68k-atari-sysv4
+       exit 0 ;;
+    i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
+       echo i386-unknown-lynxos${UNAME_RELEASE}
+       exit 0 ;;
+    TSUNAMI:LynxOS:2.*:*)
+       echo sparc-unknown-lynxos${UNAME_RELEASE}
+       exit 0 ;;
+    rs6000:LynxOS:2.*:*)
+       echo rs6000-unknown-lynxos${UNAME_RELEASE}
+       exit 0 ;;
+    PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*)
+       echo powerpc-unknown-lynxos${UNAME_RELEASE}
+       exit 0 ;;
+    SM[BE]S:UNIX_SV:*:*)
+       echo mips-dde-sysv${UNAME_RELEASE}
+       exit 0 ;;
+    RM*:ReliantUNIX-*:*:*)
+       echo mips-sni-sysv4
+       exit 0 ;;
+    RM*:SINIX-*:*:*)
+       echo mips-sni-sysv4
+       exit 0 ;;
+    *:SINIX-*:*:*)
+       if uname -p 2>/dev/null >/dev/null ; then
+               UNAME_MACHINE=`(uname -p) 2>/dev/null`
+               echo ${UNAME_MACHINE}-sni-sysv4
+       else
+               echo ns32k-sni-sysv
+       fi
+       exit 0 ;;
+    PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+                      # says <Richard.M.Bartel@ccMail.Census.GOV>
+        echo i586-unisys-sysv4
+        exit 0 ;;
+    *:UNIX_System_V:4*:FTX*)
+       # From Gerald Hewes <hewes@openmarket.com>.
+       # How about differentiating between stratus architectures? -djm
+       echo hppa1.1-stratus-sysv4
+       exit 0 ;;
+    *:*:*:FTX*)
+       # From seanf@swdc.stratus.com.
+       echo i860-stratus-sysv4
+       exit 0 ;;
+    *:VOS:*:*)
+       # From Paul.Green@stratus.com.
+       echo hppa1.1-stratus-vos
+       exit 0 ;;
+    mc68*:A/UX:*:*)
+       echo m68k-apple-aux${UNAME_RELEASE}
+       exit 0 ;;
+    news*:NEWS-OS:6*:*)
+       echo mips-sony-newsos6
+       exit 0 ;;
+    R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
+       if [ -d /usr/nec ]; then
+               echo mips-nec-sysv${UNAME_RELEASE}
+       else
+               echo mips-unknown-sysv${UNAME_RELEASE}
+       fi
+        exit 0 ;;
+    BeBox:BeOS:*:*)    # BeOS running on hardware made by Be, PPC only.
+       echo powerpc-be-beos
+       exit 0 ;;
+    BeMac:BeOS:*:*)    # BeOS running on Mac or Mac clone, PPC only.
+       echo powerpc-apple-beos
+       exit 0 ;;
+    BePC:BeOS:*:*)     # BeOS running on Intel PC compatible.
+       echo i586-pc-beos
+       exit 0 ;;
+    SX-4:SUPER-UX:*:*)
+       echo sx4-nec-superux${UNAME_RELEASE}
+       exit 0 ;;
+    SX-5:SUPER-UX:*:*)
+       echo sx5-nec-superux${UNAME_RELEASE}
+       exit 0 ;;
+    Power*:Rhapsody:*:*)
+       echo powerpc-apple-rhapsody${UNAME_RELEASE}
+       exit 0 ;;
+    *:Rhapsody:*:*)
+       echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
+       exit 0 ;;
+    *:Darwin:*:*)
+       echo `uname -p`-apple-darwin${UNAME_RELEASE}
+       exit 0 ;;
+    *:procnto*:*:* | *:QNX:[0123456789]*:*)
+       if test "${UNAME_MACHINE}" = "x86pc"; then
+               UNAME_MACHINE=pc
+       fi
+       echo `uname -p`-${UNAME_MACHINE}-nto-qnx
+       exit 0 ;;
+    *:QNX:*:4*)
+       echo i386-pc-qnx
+       exit 0 ;;
+    NSR-[KW]:NONSTOP_KERNEL:*:*)
+       echo nsr-tandem-nsk${UNAME_RELEASE}
+       exit 0 ;;
+    *:NonStop-UX:*:*)
+       echo mips-compaq-nonstopux
+       exit 0 ;;
+    BS2000:POSIX*:*:*)
+       echo bs2000-siemens-sysv
+       exit 0 ;;
+    DS/*:UNIX_System_V:*:*)
+       echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
+       exit 0 ;;
+    *:Plan9:*:*)
+       # "uname -m" is not consistent, so use $cputype instead. 386
+       # is converted to i386 for consistency with other x86
+       # operating systems.
+       if test "$cputype" = "386"; then
+           UNAME_MACHINE=i386
+       else
+           UNAME_MACHINE="$cputype"
+       fi
+       echo ${UNAME_MACHINE}-unknown-plan9
+       exit 0 ;;
+    i*86:OS/2:*:*)
+       # If we were able to find `uname', then EMX Unix compatibility
+       # is probably installed.
+       echo ${UNAME_MACHINE}-pc-os2-emx
+       exit 0 ;;
+    *:TOPS-10:*:*)
+       echo pdp10-unknown-tops10
+       exit 0 ;;
+    *:TENEX:*:*)
+       echo pdp10-unknown-tenex
+       exit 0 ;;
+    KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
+       echo pdp10-dec-tops20
+       exit 0 ;;
+    XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
+       echo pdp10-xkl-tops20
+       exit 0 ;;
+    *:TOPS-20:*:*)
+       echo pdp10-unknown-tops20
+       exit 0 ;;
+    *:ITS:*:*)
+       echo pdp10-unknown-its
+       exit 0 ;;
+    i*86:XTS-300:*:STOP)
+       echo ${UNAME_MACHINE}-unknown-stop
+       exit 0 ;;
+    i*86:atheos:*:*)
+       echo ${UNAME_MACHINE}-unknown-atheos
+       exit 0 ;;
+esac
+
+#echo '(No uname command or uname output not recognized.)' 1>&2
+#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
+
+eval $set_cc_for_build
+cat >$dummy.c <<EOF
+#ifdef _SEQUENT_
+# include <sys/types.h>
+# include <sys/utsname.h>
+#endif
+main ()
+{
+#if defined (sony)
+#if defined (MIPSEB)
+  /* BFD wants "bsd" instead of "newsos".  Perhaps BFD should be changed,
+     I don't know....  */
+  printf ("mips-sony-bsd\n"); exit (0);
+#else
+#include <sys/param.h>
+  printf ("m68k-sony-newsos%s\n",
+#ifdef NEWSOS4
+          "4"
+#else
+         ""
+#endif
+         ); exit (0);
+#endif
+#endif
+
+#if defined (__arm) && defined (__acorn) && defined (__unix)
+  printf ("arm-acorn-riscix"); exit (0);
+#endif
+
+#if defined (hp300) && !defined (hpux)
+  printf ("m68k-hp-bsd\n"); exit (0);
+#endif
+
+#if defined (NeXT)
+#if !defined (__ARCHITECTURE__)
+#define __ARCHITECTURE__ "m68k"
+#endif
+  int version;
+  version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
+  if (version < 4)
+    printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
+  else
+    printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
+  exit (0);
+#endif
+
+#if defined (MULTIMAX) || defined (n16)
+#if defined (UMAXV)
+  printf ("ns32k-encore-sysv\n"); exit (0);
+#else
+#if defined (CMU)
+  printf ("ns32k-encore-mach\n"); exit (0);
+#else
+  printf ("ns32k-encore-bsd\n"); exit (0);
+#endif
+#endif
+#endif
+
+#if defined (__386BSD__)
+  printf ("i386-pc-bsd\n"); exit (0);
+#endif
+
+#if defined (sequent)
+#if defined (i386)
+  printf ("i386-sequent-dynix\n"); exit (0);
+#endif
+#if defined (ns32000)
+  printf ("ns32k-sequent-dynix\n"); exit (0);
+#endif
+#endif
+
+#if defined (_SEQUENT_)
+    struct utsname un;
+
+    uname(&un);
+
+    if (strncmp(un.version, "V2", 2) == 0) {
+       printf ("i386-sequent-ptx2\n"); exit (0);
+    }
+    if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
+       printf ("i386-sequent-ptx1\n"); exit (0);
+    }
+    printf ("i386-sequent-ptx\n"); exit (0);
+
+#endif
+
+#if defined (vax)
+# if !defined (ultrix)
+#  include <sys/param.h>
+#  if defined (BSD)
+#   if BSD == 43
+      printf ("vax-dec-bsd4.3\n"); exit (0);
+#   else
+#    if BSD == 199006
+      printf ("vax-dec-bsd4.3reno\n"); exit (0);
+#    else
+      printf ("vax-dec-bsd\n"); exit (0);
+#    endif
+#   endif
+#  else
+    printf ("vax-dec-bsd\n"); exit (0);
+#  endif
+# else
+    printf ("vax-dec-ultrix\n"); exit (0);
+# endif
+#endif
+
+#if defined (alliant) && defined (i860)
+  printf ("i860-alliant-bsd\n"); exit (0);
+#endif
+
+  exit (1);
+}
+EOF
+
+$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm -f $dummy.c $dummy && exit 0
+rm -f $dummy.c $dummy
+
+# Apollos put the system type in the environment.
+
+test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; }
+
+# Convex versions that predate uname can use getsysinfo(1)
+
+if [ -x /usr/convex/getsysinfo ]
+then
+    case `getsysinfo -f cpu_type` in
+    c1*)
+       echo c1-convex-bsd
+       exit 0 ;;
+    c2*)
+       if getsysinfo -f scalar_acc
+       then echo c32-convex-bsd
+       else echo c2-convex-bsd
+       fi
+       exit 0 ;;
+    c34*)
+       echo c34-convex-bsd
+       exit 0 ;;
+    c38*)
+       echo c38-convex-bsd
+       exit 0 ;;
+    c4*)
+       echo c4-convex-bsd
+       exit 0 ;;
+    esac
+fi
+
+cat >&2 <<EOF
+$0: unable to guess system type
+
+This script, last modified $timestamp, has failed to recognize
+the operating system you are using. It is advised that you
+download the most up to date version of the config scripts from
+
+    ftp://ftp.gnu.org/pub/gnu/config/
+
+If the version you run ($0) is already up to date, please
+send the following data and any information you think might be
+pertinent to <config-patches@gnu.org> in order to provide the needed
+information to handle your system.
+
+config.guess timestamp = $timestamp
+
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
+/bin/uname -X     = `(/bin/uname -X) 2>/dev/null`
+
+hostinfo               = `(hostinfo) 2>/dev/null`
+/bin/universe          = `(/bin/universe) 2>/dev/null`
+/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null`
+/bin/arch              = `(/bin/arch) 2>/dev/null`
+/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
+
+UNAME_MACHINE = ${UNAME_MACHINE}
+UNAME_RELEASE = ${UNAME_RELEASE}
+UNAME_SYSTEM  = ${UNAME_SYSTEM}
+UNAME_VERSION = ${UNAME_VERSION}
+EOF
+
+exit 1
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
diff --git a/contrib/idn/idnkit-1.0-src/config.sub b/contrib/idn/idnkit-1.0-src/config.sub
new file mode 100755 (executable)
index 0000000..393f13d
--- /dev/null
@@ -0,0 +1,1411 @@
+#! /bin/sh
+# Configuration validation subroutine script.
+#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+#   Free Software Foundation, Inc.
+
+timestamp='2001-09-07'
+
+# This file is (in principle) common to ALL GNU software.
+# The presence of a machine in this file suggests that SOME GNU software
+# can handle that machine.  It does not imply ALL GNU software can.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Please send patches to <config-patches@gnu.org>.
+#
+# Configuration subroutine to validate and canonicalize a configuration type.
+# Supply the specified configuration type as an argument.
+# If it is invalid, we print an error message on stderr and exit with code 1.
+# Otherwise, we print the canonical config type on stdout and succeed.
+
+# This file is supposed to be the same for all GNU packages
+# and recognize all the CPU types, system types and aliases
+# that are meaningful with *any* GNU software.
+# Each package is responsible for reporting which valid configurations
+# it does not support.  The user should be able to distinguish
+# a failure to support a valid configuration from a meaningless
+# configuration.
+
+# The goal of this file is to map all the various variations of a given
+# machine specification into a single specification in the form:
+#      CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
+# or in some cases, the newer four-part form:
+#      CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
+# It is wrong to echo any other type of specification.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION] CPU-MFR-OPSYS
+       $0 [OPTION] ALIAS
+
+Canonicalize a configuration name.
+
+Operation modes:
+  -h, --help         print this help, then exit
+  -t, --time-stamp   print date of last modification, then exit
+  -v, --version      print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.sub ($timestamp)
+
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions.  There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+  case $1 in
+    --time-stamp | --time* | -t )
+       echo "$timestamp" ; exit 0 ;;
+    --version | -v )
+       echo "$version" ; exit 0 ;;
+    --help | --h* | -h )
+       echo "$usage"; exit 0 ;;
+    -- )     # Stop option processing
+       shift; break ;;
+    - )        # Use stdin as input.
+       break ;;
+    -* )
+       echo "$me: invalid option $1$help"
+       exit 1 ;;
+
+    *local*)
+       # First pass through any local machine types.
+       echo $1
+       exit 0;;
+
+    * )
+       break ;;
+  esac
+done
+
+case $# in
+ 0) echo "$me: missing argument$help" >&2
+    exit 1;;
+ 1) ;;
+ *) echo "$me: too many arguments$help" >&2
+    exit 1;;
+esac
+
+# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
+# Here we must recognize all the valid KERNEL-OS combinations.
+maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
+case $maybe_os in
+  nto-qnx* | linux-gnu* | storm-chaos* | os2-emx* | windows32-*)
+    os=-$maybe_os
+    basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
+    ;;
+  *)
+    basic_machine=`echo $1 | sed 's/-[^-]*$//'`
+    if [ $basic_machine != $1 ]
+    then os=`echo $1 | sed 's/.*-/-/'`
+    else os=; fi
+    ;;
+esac
+
+### Let's recognize common machines as not being operating systems so
+### that things like config.sub decstation-3100 work.  We also
+### recognize some manufacturers as not being operating systems, so we
+### can provide default operating systems below.
+case $os in
+       -sun*os*)
+               # Prevent following clause from handling this invalid input.
+               ;;
+       -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
+       -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
+       -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
+       -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
+       -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
+       -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
+       -apple | -axis)
+               os=
+               basic_machine=$1
+               ;;
+       -sim | -cisco | -oki | -wec | -winbond)
+               os=
+               basic_machine=$1
+               ;;
+       -scout)
+               ;;
+       -wrs)
+               os=-vxworks
+               basic_machine=$1
+               ;;
+       -chorusos*)
+               os=-chorusos
+               basic_machine=$1
+               ;;
+       -chorusrdb)
+               os=-chorusrdb
+               basic_machine=$1
+               ;;
+       -hiux*)
+               os=-hiuxwe2
+               ;;
+       -sco5)
+               os=-sco3.2v5
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -sco4)
+               os=-sco3.2v4
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -sco3.2.[4-9]*)
+               os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -sco3.2v[4-9]*)
+               # Don't forget version if it is 3.2v4 or newer.
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -sco*)
+               os=-sco3.2v2
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -udk*)
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -isc)
+               os=-isc2.2
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -clix*)
+               basic_machine=clipper-intergraph
+               ;;
+       -isc*)
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -lynx*)
+               os=-lynxos
+               ;;
+       -ptx*)
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
+               ;;
+       -windowsnt*)
+               os=`echo $os | sed -e 's/windowsnt/winnt/'`
+               ;;
+       -psos*)
+               os=-psos
+               ;;
+       -mint | -mint[0-9]*)
+               basic_machine=m68k-atari
+               os=-mint
+               ;;
+esac
+
+# Decode aliases for certain CPU-COMPANY combinations.
+case $basic_machine in
+       # Recognize the basic CPU types without company name.
+       # Some are omitted here because they have special meanings below.
+       1750a | 580 \
+       | a29k \
+       | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
+       | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \
+       | c4x | clipper \
+       | d10v | d30v | dsp16xx \
+       | fr30 \
+       | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
+       | i370 | i860 | i960 | ia64 \
+       | m32r | m68000 | m68k | m88k | mcore \
+       | mips16 | mips64 | mips64el | mips64orion | mips64orionel \
+       | mips64vr4100 | mips64vr4100el | mips64vr4300 \
+       | mips64vr4300el | mips64vr5000 | mips64vr5000el \
+       | mipsbe | mipseb | mipsel | mipsle | mipstx39 | mipstx39el \
+       | mipsisa32 \
+       | mn10200 | mn10300 \
+       | ns16k | ns32k \
+       | openrisc \
+       | pdp10 | pdp11 | pj | pjl \
+       | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
+       | pyramid \
+       | s390 | s390x \
+       | sh | sh[34] | sh[34]eb | shbe | shle \
+       | sparc | sparc64 | sparclet | sparclite | sparcv9 | sparcv9b \
+       | stormy16 | strongarm \
+       | tahoe | thumb | tic80 | tron \
+       | v850 \
+       | we32k \
+       | x86 | xscale \
+       | z8k)
+               basic_machine=$basic_machine-unknown
+               ;;
+       m6811 | m68hc11 | m6812 | m68hc12)
+               # Motorola 68HC11/12.
+               basic_machine=$basic_machine-unknown
+               os=-none
+               ;;
+       m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
+               ;;
+
+       # We use `pc' rather than `unknown'
+       # because (1) that's what they normally are, and
+       # (2) the word "unknown" tends to confuse beginning users.
+       i*86 | x86_64)
+         basic_machine=$basic_machine-pc
+         ;;
+       # Object if more than one company name word.
+       *-*-*)
+               echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+               exit 1
+               ;;
+       # Recognize the basic CPU types with company name.
+       580-* \
+       | a29k-* \
+       | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
+       | alphapca5[67]-* | arc-* \
+       | arm-*  | armbe-* | armle-* | armv*-* \
+       | bs2000-* \
+       | c[123]* | c30-* | [cjt]90-* | c54x-* \
+       | clipper-* | cray2-* | cydra-* \
+       | d10v-* | d30v-* \
+       | elxsi-* \
+       | f30[01]-* | f700-* | fr30-* | fx80-* \
+       | h8300-* | h8500-* \
+       | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
+       | i*86-* | i860-* | i960-* | ia64-* \
+       | m32r-* \
+       | m68000-* | m680[01234]0-* | m68360-* | m683?2-* | m68k-* \
+       | m88110-* | m88k-* | mcore-* \
+       | mips-* | mips16-* | mips64-* | mips64el-* | mips64orion-* \
+       | mips64orionel-* | mips64vr4100-* | mips64vr4100el-* \
+       | mips64vr4300-* | mips64vr4300el-* | mipsbe-* | mipseb-* \
+       | mipsle-* | mipsel-* | mipstx39-* | mipstx39el-* \
+       | none-* | np1-* | ns16k-* | ns32k-* \
+       | orion-* \
+       | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
+       | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
+       | pyramid-* \
+       | romp-* | rs6000-* \
+       | s390-* | s390x-* \
+       | sh-* | sh[34]-* | sh[34]eb-* | shbe-* | shle-* \
+       | sparc-* | sparc64-* | sparc86x-* | sparclite-* \
+       | sparcv9-* | sparcv9b-* | stormy16-* | strongarm-* | sv1-* \
+       | t3e-* | tahoe-* | thumb-* | tic30-* | tic54x-* | tic80-* | tron-* \
+       | v850-* | vax-* \
+       | we32k-* \
+       | x86-* | x86_64-* | xmp-* | xps100-* | xscale-* \
+       | ymp-* \
+       | z8k-*)
+               ;;
+       # Recognize the various machine names and aliases which stand
+       # for a CPU type and a company and sometimes even an OS.
+       386bsd)
+               basic_machine=i386-unknown
+               os=-bsd
+               ;;
+       3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
+               basic_machine=m68000-att
+               ;;
+       3b*)
+               basic_machine=we32k-att
+               ;;
+       a29khif)
+               basic_machine=a29k-amd
+               os=-udi
+               ;;
+       adobe68k)
+               basic_machine=m68010-adobe
+               os=-scout
+               ;;
+       alliant | fx80)
+               basic_machine=fx80-alliant
+               ;;
+       altos | altos3068)
+               basic_machine=m68k-altos
+               ;;
+       am29k)
+               basic_machine=a29k-none
+               os=-bsd
+               ;;
+       amdahl)
+               basic_machine=580-amdahl
+               os=-sysv
+               ;;
+       amiga | amiga-*)
+               basic_machine=m68k-unknown
+               ;;
+       amigaos | amigados)
+               basic_machine=m68k-unknown
+               os=-amigaos
+               ;;
+       amigaunix | amix)
+               basic_machine=m68k-unknown
+               os=-sysv4
+               ;;
+       apollo68)
+               basic_machine=m68k-apollo
+               os=-sysv
+               ;;
+       apollo68bsd)
+               basic_machine=m68k-apollo
+               os=-bsd
+               ;;
+       aux)
+               basic_machine=m68k-apple
+               os=-aux
+               ;;
+       balance)
+               basic_machine=ns32k-sequent
+               os=-dynix
+               ;;
+       convex-c1)
+               basic_machine=c1-convex
+               os=-bsd
+               ;;
+       convex-c2)
+               basic_machine=c2-convex
+               os=-bsd
+               ;;
+       convex-c32)
+               basic_machine=c32-convex
+               os=-bsd
+               ;;
+       convex-c34)
+               basic_machine=c34-convex
+               os=-bsd
+               ;;
+       convex-c38)
+               basic_machine=c38-convex
+               os=-bsd
+               ;;
+       cray | ymp)
+               basic_machine=ymp-cray
+               os=-unicos
+               ;;
+       cray2)
+               basic_machine=cray2-cray
+               os=-unicos
+               ;;
+       [cjt]90)
+               basic_machine=${basic_machine}-cray
+               os=-unicos
+               ;;
+       crds | unos)
+               basic_machine=m68k-crds
+               ;;
+       cris | cris-* | etrax*)
+               basic_machine=cris-axis
+               ;;
+       da30 | da30-*)
+               basic_machine=m68k-da30
+               ;;
+       decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
+               basic_machine=mips-dec
+               ;;
+       delta | 3300 | motorola-3300 | motorola-delta \
+             | 3300-motorola | delta-motorola)
+               basic_machine=m68k-motorola
+               ;;
+       delta88)
+               basic_machine=m88k-motorola
+               os=-sysv3
+               ;;
+       dpx20 | dpx20-*)
+               basic_machine=rs6000-bull
+               os=-bosx
+               ;;
+       dpx2* | dpx2*-bull)
+               basic_machine=m68k-bull
+               os=-sysv3
+               ;;
+       ebmon29k)
+               basic_machine=a29k-amd
+               os=-ebmon
+               ;;
+       elxsi)
+               basic_machine=elxsi-elxsi
+               os=-bsd
+               ;;
+       encore | umax | mmax)
+               basic_machine=ns32k-encore
+               ;;
+       es1800 | OSE68k | ose68k | ose | OSE)
+               basic_machine=m68k-ericsson
+               os=-ose
+               ;;
+       fx2800)
+               basic_machine=i860-alliant
+               ;;
+       genix)
+               basic_machine=ns32k-ns
+               ;;
+       gmicro)
+               basic_machine=tron-gmicro
+               os=-sysv
+               ;;
+       go32)
+               basic_machine=i386-pc
+               os=-go32
+               ;;
+       h3050r* | hiux*)
+               basic_machine=hppa1.1-hitachi
+               os=-hiuxwe2
+               ;;
+       h8300hms)
+               basic_machine=h8300-hitachi
+               os=-hms
+               ;;
+       h8300xray)
+               basic_machine=h8300-hitachi
+               os=-xray
+               ;;
+       h8500hms)
+               basic_machine=h8500-hitachi
+               os=-hms
+               ;;
+       harris)
+               basic_machine=m88k-harris
+               os=-sysv3
+               ;;
+       hp300-*)
+               basic_machine=m68k-hp
+               ;;
+       hp300bsd)
+               basic_machine=m68k-hp
+               os=-bsd
+               ;;
+       hp300hpux)
+               basic_machine=m68k-hp
+               os=-hpux
+               ;;
+       hp3k9[0-9][0-9] | hp9[0-9][0-9])
+               basic_machine=hppa1.0-hp
+               ;;
+       hp9k2[0-9][0-9] | hp9k31[0-9])
+               basic_machine=m68000-hp
+               ;;
+       hp9k3[2-9][0-9])
+               basic_machine=m68k-hp
+               ;;
+       hp9k6[0-9][0-9] | hp6[0-9][0-9])
+               basic_machine=hppa1.0-hp
+               ;;
+       hp9k7[0-79][0-9] | hp7[0-79][0-9])
+               basic_machine=hppa1.1-hp
+               ;;
+       hp9k78[0-9] | hp78[0-9])
+               # FIXME: really hppa2.0-hp
+               basic_machine=hppa1.1-hp
+               ;;
+       hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
+               # FIXME: really hppa2.0-hp
+               basic_machine=hppa1.1-hp
+               ;;
+       hp9k8[0-9][13679] | hp8[0-9][13679])
+               basic_machine=hppa1.1-hp
+               ;;
+       hp9k8[0-9][0-9] | hp8[0-9][0-9])
+               basic_machine=hppa1.0-hp
+               ;;
+       hppa-next)
+               os=-nextstep3
+               ;;
+       hppaosf)
+               basic_machine=hppa1.1-hp
+               os=-osf
+               ;;
+       hppro)
+               basic_machine=hppa1.1-hp
+               os=-proelf
+               ;;
+       i370-ibm* | ibm*)
+               basic_machine=i370-ibm
+               ;;
+# I'm not sure what "Sysv32" means.  Should this be sysv3.2?
+       i*86v32)
+               basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+               os=-sysv32
+               ;;
+       i*86v4*)
+               basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+               os=-sysv4
+               ;;
+       i*86v)
+               basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+               os=-sysv
+               ;;
+       i*86sol2)
+               basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+               os=-solaris2
+               ;;
+       i386mach)
+               basic_machine=i386-mach
+               os=-mach
+               ;;
+       i386-vsta | vsta)
+               basic_machine=i386-unknown
+               os=-vsta
+               ;;
+       iris | iris4d)
+               basic_machine=mips-sgi
+               case $os in
+                   -irix*)
+                       ;;
+                   *)
+                       os=-irix4
+                       ;;
+               esac
+               ;;
+       isi68 | isi)
+               basic_machine=m68k-isi
+               os=-sysv
+               ;;
+       m88k-omron*)
+               basic_machine=m88k-omron
+               ;;
+       magnum | m3230)
+               basic_machine=mips-mips
+               os=-sysv
+               ;;
+       merlin)
+               basic_machine=ns32k-utek
+               os=-sysv
+               ;;
+       mingw32)
+               basic_machine=i386-pc
+               os=-mingw32
+               ;;
+       miniframe)
+               basic_machine=m68000-convergent
+               ;;
+       *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
+               basic_machine=m68k-atari
+               os=-mint
+               ;;
+       mipsel*-linux*)
+               basic_machine=mipsel-unknown
+               os=-linux-gnu
+               ;;
+       mips*-linux*)
+               basic_machine=mips-unknown
+               os=-linux-gnu
+               ;;
+       mips3*-*)
+               basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
+               ;;
+       mips3*)
+               basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
+               ;;
+       mmix*)
+               basic_machine=mmix-knuth
+               os=-mmixware
+               ;;
+       monitor)
+               basic_machine=m68k-rom68k
+               os=-coff
+               ;;
+       msdos)
+               basic_machine=i386-pc
+               os=-msdos
+               ;;
+       mvs)
+               basic_machine=i370-ibm
+               os=-mvs
+               ;;
+       ncr3000)
+               basic_machine=i486-ncr
+               os=-sysv4
+               ;;
+       netbsd386)
+               basic_machine=i386-unknown
+               os=-netbsd
+               ;;
+       netwinder)
+               basic_machine=armv4l-rebel
+               os=-linux
+               ;;
+       news | news700 | news800 | news900)
+               basic_machine=m68k-sony
+               os=-newsos
+               ;;
+       news1000)
+               basic_machine=m68030-sony
+               os=-newsos
+               ;;
+       news-3600 | risc-news)
+               basic_machine=mips-sony
+               os=-newsos
+               ;;
+       necv70)
+               basic_machine=v70-nec
+               os=-sysv
+               ;;
+       next | m*-next )
+               basic_machine=m68k-next
+               case $os in
+                   -nextstep* )
+                       ;;
+                   -ns2*)
+                     os=-nextstep2
+                       ;;
+                   *)
+                     os=-nextstep3
+                       ;;
+               esac
+               ;;
+       nh3000)
+               basic_machine=m68k-harris
+               os=-cxux
+               ;;
+       nh[45]000)
+               basic_machine=m88k-harris
+               os=-cxux
+               ;;
+       nindy960)
+               basic_machine=i960-intel
+               os=-nindy
+               ;;
+       mon960)
+               basic_machine=i960-intel
+               os=-mon960
+               ;;
+       nonstopux)
+               basic_machine=mips-compaq
+               os=-nonstopux
+               ;;
+       np1)
+               basic_machine=np1-gould
+               ;;
+       nsr-tandem)
+               basic_machine=nsr-tandem
+               ;;
+       op50n-* | op60c-*)
+               basic_machine=hppa1.1-oki
+               os=-proelf
+               ;;
+       OSE68000 | ose68000)
+               basic_machine=m68000-ericsson
+               os=-ose
+               ;;
+       os68k)
+               basic_machine=m68k-none
+               os=-os68k
+               ;;
+       pa-hitachi)
+               basic_machine=hppa1.1-hitachi
+               os=-hiuxwe2
+               ;;
+       paragon)
+               basic_machine=i860-intel
+               os=-osf
+               ;;
+       pbd)
+               basic_machine=sparc-tti
+               ;;
+       pbb)
+               basic_machine=m68k-tti
+               ;;
+        pc532 | pc532-*)
+               basic_machine=ns32k-pc532
+               ;;
+       pentium | p5 | k5 | k6 | nexgen)
+               basic_machine=i586-pc
+               ;;
+       pentiumpro | p6 | 6x86 | athlon)
+               basic_machine=i686-pc
+               ;;
+       pentiumii | pentium2)
+               basic_machine=i686-pc
+               ;;
+       pentium-* | p5-* | k5-* | k6-* | nexgen-*)
+               basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       pentiumpro-* | p6-* | 6x86-* | athlon-*)
+               basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       pentiumii-* | pentium2-*)
+               basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       pn)
+               basic_machine=pn-gould
+               ;;
+       power)  basic_machine=power-ibm
+               ;;
+       ppc)    basic_machine=powerpc-unknown
+               ;;
+       ppc-*)  basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       ppcle | powerpclittle | ppc-le | powerpc-little)
+               basic_machine=powerpcle-unknown
+               ;;
+       ppcle-* | powerpclittle-*)
+               basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       ppc64)  basic_machine=powerpc64-unknown
+               ;;
+       ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       ppc64le | powerpc64little | ppc64-le | powerpc64-little)
+               basic_machine=powerpc64le-unknown
+               ;;
+       ppc64le-* | powerpc64little-*)
+               basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       ps2)
+               basic_machine=i386-ibm
+               ;;
+       pw32)
+               basic_machine=i586-unknown
+               os=-pw32
+               ;;
+       rom68k)
+               basic_machine=m68k-rom68k
+               os=-coff
+               ;;
+       rm[46]00)
+               basic_machine=mips-siemens
+               ;;
+       rtpc | rtpc-*)
+               basic_machine=romp-ibm
+               ;;
+       sa29200)
+               basic_machine=a29k-amd
+               os=-udi
+               ;;
+       sequent)
+               basic_machine=i386-sequent
+               ;;
+       sh)
+               basic_machine=sh-hitachi
+               os=-hms
+               ;;
+       sparclite-wrs)
+               basic_machine=sparclite-wrs
+               os=-vxworks
+               ;;
+       sps7)
+               basic_machine=m68k-bull
+               os=-sysv2
+               ;;
+       spur)
+               basic_machine=spur-unknown
+               ;;
+       st2000)
+               basic_machine=m68k-tandem
+               ;;
+       stratus)
+               basic_machine=i860-stratus
+               os=-sysv4
+               ;;
+       sun2)
+               basic_machine=m68000-sun
+               ;;
+       sun2os3)
+               basic_machine=m68000-sun
+               os=-sunos3
+               ;;
+       sun2os4)
+               basic_machine=m68000-sun
+               os=-sunos4
+               ;;
+       sun3os3)
+               basic_machine=m68k-sun
+               os=-sunos3
+               ;;
+       sun3os4)
+               basic_machine=m68k-sun
+               os=-sunos4
+               ;;
+       sun4os3)
+               basic_machine=sparc-sun
+               os=-sunos3
+               ;;
+       sun4os4)
+               basic_machine=sparc-sun
+               os=-sunos4
+               ;;
+       sun4sol2)
+               basic_machine=sparc-sun
+               os=-solaris2
+               ;;
+       sun3 | sun3-*)
+               basic_machine=m68k-sun
+               ;;
+       sun4)
+               basic_machine=sparc-sun
+               ;;
+       sun386 | sun386i | roadrunner)
+               basic_machine=i386-sun
+               ;;
+       sv1)
+               basic_machine=sv1-cray
+               os=-unicos
+               ;;
+       symmetry)
+               basic_machine=i386-sequent
+               os=-dynix
+               ;;
+       t3e)
+               basic_machine=t3e-cray
+               os=-unicos
+               ;;
+       tic54x | c54x*)
+               basic_machine=tic54x-unknown
+               os=-coff
+               ;;
+       tx39)
+               basic_machine=mipstx39-unknown
+               ;;
+       tx39el)
+               basic_machine=mipstx39el-unknown
+               ;;
+       tower | tower-32)
+               basic_machine=m68k-ncr
+               ;;
+       udi29k)
+               basic_machine=a29k-amd
+               os=-udi
+               ;;
+       ultra3)
+               basic_machine=a29k-nyu
+               os=-sym1
+               ;;
+       v810 | necv810)
+               basic_machine=v810-nec
+               os=-none
+               ;;
+       vaxv)
+               basic_machine=vax-dec
+               os=-sysv
+               ;;
+       vms)
+               basic_machine=vax-dec
+               os=-vms
+               ;;
+       vpp*|vx|vx-*)
+               basic_machine=f301-fujitsu
+               ;;
+       vxworks960)
+               basic_machine=i960-wrs
+               os=-vxworks
+               ;;
+       vxworks68)
+               basic_machine=m68k-wrs
+               os=-vxworks
+               ;;
+       vxworks29k)
+               basic_machine=a29k-wrs
+               os=-vxworks
+               ;;
+       w65*)
+               basic_machine=w65-wdc
+               os=-none
+               ;;
+       w89k-*)
+               basic_machine=hppa1.1-winbond
+               os=-proelf
+               ;;
+       windows32)
+               basic_machine=i386-pc
+               os=-windows32-msvcrt
+               ;;
+       xmp)
+               basic_machine=xmp-cray
+               os=-unicos
+               ;;
+        xps | xps100)
+               basic_machine=xps100-honeywell
+               ;;
+       z8k-*-coff)
+               basic_machine=z8k-unknown
+               os=-sim
+               ;;
+       none)
+               basic_machine=none-none
+               os=-none
+               ;;
+
+# Here we handle the default manufacturer of certain CPU types.  It is in
+# some cases the only manufacturer, in others, it is the most popular.
+       w89k)
+               basic_machine=hppa1.1-winbond
+               ;;
+       op50n)
+               basic_machine=hppa1.1-oki
+               ;;
+       op60c)
+               basic_machine=hppa1.1-oki
+               ;;
+       mips)
+               if [ x$os = x-linux-gnu ]; then
+                       basic_machine=mips-unknown
+               else
+                       basic_machine=mips-mips
+               fi
+               ;;
+       romp)
+               basic_machine=romp-ibm
+               ;;
+       rs6000)
+               basic_machine=rs6000-ibm
+               ;;
+       vax)
+               basic_machine=vax-dec
+               ;;
+       pdp10)
+               # there are many clones, so DEC is not a safe bet
+               basic_machine=pdp10-unknown
+               ;;
+       pdp11)
+               basic_machine=pdp11-dec
+               ;;
+       we32k)
+               basic_machine=we32k-att
+               ;;
+       sh3 | sh4 | sh3eb | sh4eb)
+               basic_machine=sh-unknown
+               ;;
+       sparc | sparcv9 | sparcv9b)
+               basic_machine=sparc-sun
+               ;;
+        cydra)
+               basic_machine=cydra-cydrome
+               ;;
+       orion)
+               basic_machine=orion-highlevel
+               ;;
+       orion105)
+               basic_machine=clipper-highlevel
+               ;;
+       mac | mpw | mac-mpw)
+               basic_machine=m68k-apple
+               ;;
+       pmac | pmac-mpw)
+               basic_machine=powerpc-apple
+               ;;
+       c4x*)
+               basic_machine=c4x-none
+               os=-coff
+               ;;
+       *-unknown)
+               # Make sure to match an already-canonicalized machine name.
+               ;;
+       *)
+               echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+               exit 1
+               ;;
+esac
+
+# Here we canonicalize certain aliases for manufacturers.
+case $basic_machine in
+       *-digital*)
+               basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
+               ;;
+       *-commodore*)
+               basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
+               ;;
+       *)
+               ;;
+esac
+
+# Decode manufacturer-specific aliases for certain operating systems.
+
+if [ x"$os" != x"" ]
+then
+case $os in
+        # First match some system type aliases
+        # that might get confused with valid system types.
+       # -solaris* is a basic system type, with this one exception.
+       -solaris1 | -solaris1.*)
+               os=`echo $os | sed -e 's|solaris1|sunos4|'`
+               ;;
+       -solaris)
+               os=-solaris2
+               ;;
+       -svr4*)
+               os=-sysv4
+               ;;
+       -unixware*)
+               os=-sysv4.2uw
+               ;;
+       -gnu/linux*)
+               os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
+               ;;
+       # First accept the basic system types.
+       # The portable systems comes first.
+       # Each alternative MUST END IN A *, to match a version number.
+       # -sysv* is not here because it comes later, after sysvr4.
+       -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
+             | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
+             | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
+             | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
+             | -aos* \
+             | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
+             | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
+             | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \
+             | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
+             | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
+             | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
+             | -chorusos* | -chorusrdb* \
+             | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+             | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \
+             | -interix* | -uwin* | -rhapsody* | -darwin* | -opened* \
+             | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
+             | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
+             | -os2* | -vos*)
+       # Remember, each alternative MUST END IN *, to match a version number.
+               ;;
+       -qnx*)
+               case $basic_machine in
+                   x86-* | i*86-*)
+                       ;;
+                   *)
+                       os=-nto$os
+                       ;;
+               esac
+               ;;
+       -nto*)
+               os=-nto-qnx
+               ;;
+       -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
+             | -windows* | -osx | -abug | -netware* | -os9* | -beos* \
+             | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
+               ;;
+       -mac*)
+               os=`echo $os | sed -e 's|mac|macos|'`
+               ;;
+       -linux*)
+               os=`echo $os | sed -e 's|linux|linux-gnu|'`
+               ;;
+       -sunos5*)
+               os=`echo $os | sed -e 's|sunos5|solaris2|'`
+               ;;
+       -sunos6*)
+               os=`echo $os | sed -e 's|sunos6|solaris3|'`
+               ;;
+       -opened*)
+               os=-openedition
+               ;;
+       -wince*)
+               os=-wince
+               ;;
+       -osfrose*)
+               os=-osfrose
+               ;;
+       -osf*)
+               os=-osf
+               ;;
+       -utek*)
+               os=-bsd
+               ;;
+       -dynix*)
+               os=-bsd
+               ;;
+       -acis*)
+               os=-aos
+               ;;
+       -386bsd)
+               os=-bsd
+               ;;
+       -ctix* | -uts*)
+               os=-sysv
+               ;;
+       -ns2 )
+               os=-nextstep2
+               ;;
+       -nsk*)
+               os=-nsk
+               ;;
+       # Preserve the version number of sinix5.
+       -sinix5.*)
+               os=`echo $os | sed -e 's|sinix|sysv|'`
+               ;;
+       -sinix*)
+               os=-sysv4
+               ;;
+       -triton*)
+               os=-sysv3
+               ;;
+       -oss*)
+               os=-sysv3
+               ;;
+       -svr4)
+               os=-sysv4
+               ;;
+       -svr3)
+               os=-sysv3
+               ;;
+       -sysvr4)
+               os=-sysv4
+               ;;
+       # This must come after -sysvr4.
+       -sysv*)
+               ;;
+       -ose*)
+               os=-ose
+               ;;
+       -es1800*)
+               os=-ose
+               ;;
+       -xenix)
+               os=-xenix
+               ;;
+        -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+               os=-mint
+               ;;
+       -none)
+               ;;
+       *)
+               # Get rid of the `-' at the beginning of $os.
+               os=`echo $os | sed 's/[^-]*-//'`
+               echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
+               exit 1
+               ;;
+esac
+else
+
+# Here we handle the default operating systems that come with various machines.
+# The value should be what the vendor currently ships out the door with their
+# machine or put another way, the most popular os provided with the machine.
+
+# Note that if you're going to try to match "-MANUFACTURER" here (say,
+# "-sun"), then you have to tell the case statement up towards the top
+# that MANUFACTURER isn't an operating system.  Otherwise, code above
+# will signal an error saying that MANUFACTURER isn't an operating
+# system, and we'll never get to this point.
+
+case $basic_machine in
+       *-acorn)
+               os=-riscix1.2
+               ;;
+       arm*-rebel)
+               os=-linux
+               ;;
+       arm*-semi)
+               os=-aout
+               ;;
+       pdp10-*)
+               os=-tops20
+               ;;
+        pdp11-*)
+               os=-none
+               ;;
+       *-dec | vax-*)
+               os=-ultrix4.2
+               ;;
+       m68*-apollo)
+               os=-domain
+               ;;
+       i386-sun)
+               os=-sunos4.0.2
+               ;;
+       m68000-sun)
+               os=-sunos3
+               # This also exists in the configure program, but was not the
+               # default.
+               # os=-sunos4
+               ;;
+       m68*-cisco)
+               os=-aout
+               ;;
+       mips*-cisco)
+               os=-elf
+               ;;
+       mips*-*)
+               os=-elf
+               ;;
+       *-tti)  # must be before sparc entry or we get the wrong os.
+               os=-sysv3
+               ;;
+       sparc-* | *-sun)
+               os=-sunos4.1.1
+               ;;
+       *-be)
+               os=-beos
+               ;;
+       *-ibm)
+               os=-aix
+               ;;
+       *-wec)
+               os=-proelf
+               ;;
+       *-winbond)
+               os=-proelf
+               ;;
+       *-oki)
+               os=-proelf
+               ;;
+       *-hp)
+               os=-hpux
+               ;;
+       *-hitachi)
+               os=-hiux
+               ;;
+       i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
+               os=-sysv
+               ;;
+       *-cbm)
+               os=-amigaos
+               ;;
+       *-dg)
+               os=-dgux
+               ;;
+       *-dolphin)
+               os=-sysv3
+               ;;
+       m68k-ccur)
+               os=-rtu
+               ;;
+       m88k-omron*)
+               os=-luna
+               ;;
+       *-next )
+               os=-nextstep
+               ;;
+       *-sequent)
+               os=-ptx
+               ;;
+       *-crds)
+               os=-unos
+               ;;
+       *-ns)
+               os=-genix
+               ;;
+       i370-*)
+               os=-mvs
+               ;;
+       *-next)
+               os=-nextstep3
+               ;;
+        *-gould)
+               os=-sysv
+               ;;
+        *-highlevel)
+               os=-bsd
+               ;;
+       *-encore)
+               os=-bsd
+               ;;
+        *-sgi)
+               os=-irix
+               ;;
+        *-siemens)
+               os=-sysv4
+               ;;
+       *-masscomp)
+               os=-rtu
+               ;;
+       f30[01]-fujitsu | f700-fujitsu)
+               os=-uxpv
+               ;;
+       *-rom68k)
+               os=-coff
+               ;;
+       *-*bug)
+               os=-coff
+               ;;
+       *-apple)
+               os=-macos
+               ;;
+       *-atari*)
+               os=-mint
+               ;;
+       *)
+               os=-none
+               ;;
+esac
+fi
+
+# Here we handle the case where we know the os, and the CPU type, but not the
+# manufacturer.  We pick the logical manufacturer.
+vendor=unknown
+case $basic_machine in
+       *-unknown)
+               case $os in
+                       -riscix*)
+                               vendor=acorn
+                               ;;
+                       -sunos*)
+                               vendor=sun
+                               ;;
+                       -aix*)
+                               vendor=ibm
+                               ;;
+                       -beos*)
+                               vendor=be
+                               ;;
+                       -hpux*)
+                               vendor=hp
+                               ;;
+                       -mpeix*)
+                               vendor=hp
+                               ;;
+                       -hiux*)
+                               vendor=hitachi
+                               ;;
+                       -unos*)
+                               vendor=crds
+                               ;;
+                       -dgux*)
+                               vendor=dg
+                               ;;
+                       -luna*)
+                               vendor=omron
+                               ;;
+                       -genix*)
+                               vendor=ns
+                               ;;
+                       -mvs* | -opened*)
+                               vendor=ibm
+                               ;;
+                       -ptx*)
+                               vendor=sequent
+                               ;;
+                       -vxsim* | -vxworks*)
+                               vendor=wrs
+                               ;;
+                       -aux*)
+                               vendor=apple
+                               ;;
+                       -hms*)
+                               vendor=hitachi
+                               ;;
+                       -mpw* | -macos*)
+                               vendor=apple
+                               ;;
+                       -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+                               vendor=atari
+                               ;;
+                       -vos*)
+                               vendor=stratus
+                               ;;
+               esac
+               basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
+               ;;
+esac
+
+echo $basic_machine$os
+exit 0
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
diff --git a/contrib/idn/idnkit-1.0-src/configure b/contrib/idn/idnkit-1.0-src/configure
new file mode 100755 (executable)
index 0000000..1d22dac
--- /dev/null
@@ -0,0 +1,3517 @@
+#! /bin/sh
+
+# Guess values for system-dependent variables and create Makefiles.
+# Generated automatically using autoconf version 2.13 
+# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
+#
+# This configure script is free software; the Free Software Foundation
+# gives unlimited permission to copy, distribute and modify it.
+
+# Defaults:
+ac_help=
+ac_default_prefix=/usr/local
+# Any additions from configure.in:
+ac_help="$ac_help
+  --enable-debug          enable debug codes [default=no]"
+ac_help="$ac_help
+  --enable-mdnkit-compat  enable mDNkit compatibility mode [default=no]"
+ac_help="$ac_help
+  --enable-extra-ace      enable additional ACE converters. [default=no]"
+ac_help="$ac_help
+  --with-utf8=NAME        codeset name for UTF-8 encoding [UTF-8]"
+ac_help="$ac_help
+  --enable-liteonly       compile and install lite library only [default=no]"
+ac_help="$ac_help
+  --enable-runidn         compile and install runidn [default=no]"
+ac_help="$ac_help
+  --with-libiconv=IPREFIX  GNU libiconv are installed in IPREFIX [PREFIX]"
+ac_help="$ac_help
+  --with-iconv-include=DIR  iconv include files are in DIR []"
+ac_help="$ac_help
+  --with-iconv=LIB        special library for iconv []"
+ac_help="$ac_help
+  --with-iconv-sofile=PATH  shared library file for libiconv []"
+ac_help="$ac_help
+  --enable-shared[=PKGS]  build shared libraries [default=yes]"
+ac_help="$ac_help
+  --enable-static[=PKGS]  build static libraries [default=yes]"
+ac_help="$ac_help
+  --enable-fast-install[=PKGS]  optimize for fast installation [default=yes]"
+ac_help="$ac_help
+  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]"
+ac_help="$ac_help
+  --disable-libtool-lock  avoid locking (might break parallel builds)"
+
+# Initialize some variables set by options.
+# The variables have the same names as the options, with
+# dashes changed to underlines.
+build=NONE
+cache_file=./config.cache
+exec_prefix=NONE
+host=NONE
+no_create=
+nonopt=NONE
+no_recursion=
+prefix=NONE
+program_prefix=NONE
+program_suffix=NONE
+program_transform_name=s,x,x,
+silent=
+site=
+srcdir=
+target=NONE
+verbose=
+x_includes=NONE
+x_libraries=NONE
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datadir='${prefix}/share'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+libdir='${exec_prefix}/lib'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+infodir='${prefix}/info'
+mandir='${prefix}/man'
+
+# Initialize some other variables.
+subdirs=
+MFLAGS= MAKEFLAGS=
+SHELL=${CONFIG_SHELL-/bin/sh}
+# Maximum number of lines to put in a shell here document.
+ac_max_here_lines=12
+
+ac_prev=
+for ac_option
+do
+
+  # If the previous option needs an argument, assign it.
+  if test -n "$ac_prev"; then
+    eval "$ac_prev=\$ac_option"
+    ac_prev=
+    continue
+  fi
+
+  case "$ac_option" in
+  -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
+  *) ac_optarg= ;;
+  esac
+
+  # Accept the important Cygnus configure options, so we can diagnose typos.
+
+  case "$ac_option" in
+
+  -bindir | --bindir | --bindi | --bind | --bin | --bi)
+    ac_prev=bindir ;;
+  -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
+    bindir="$ac_optarg" ;;
+
+  -build | --build | --buil | --bui | --bu)
+    ac_prev=build ;;
+  -build=* | --build=* | --buil=* | --bui=* | --bu=*)
+    build="$ac_optarg" ;;
+
+  -cache-file | --cache-file | --cache-fil | --cache-fi \
+  | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
+    ac_prev=cache_file ;;
+  -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
+  | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
+    cache_file="$ac_optarg" ;;
+
+  -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
+    ac_prev=datadir ;;
+  -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
+  | --da=*)
+    datadir="$ac_optarg" ;;
+
+  -disable-* | --disable-*)
+    ac_feature=`echo $ac_option|sed -e 's/-*disable-//'`
+    # Reject names that are not valid shell variable names.
+    if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then
+      { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
+    fi
+    ac_feature=`echo $ac_feature| sed 's/-/_/g'`
+    eval "enable_${ac_feature}=no" ;;
+
+  -enable-* | --enable-*)
+    ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'`
+    # Reject names that are not valid shell variable names.
+    if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then
+      { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
+    fi
+    ac_feature=`echo $ac_feature| sed 's/-/_/g'`
+    case "$ac_option" in
+      *=*) ;;
+      *) ac_optarg=yes ;;
+    esac
+    eval "enable_${ac_feature}='$ac_optarg'" ;;
+
+  -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
+  | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
+  | --exec | --exe | --ex)
+    ac_prev=exec_prefix ;;
+  -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
+  | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
+  | --exec=* | --exe=* | --ex=*)
+    exec_prefix="$ac_optarg" ;;
+
+  -gas | --gas | --ga | --g)
+    # Obsolete; use --with-gas.
+    with_gas=yes ;;
+
+  -help | --help | --hel | --he)
+    # Omit some internal or obsolete options to make the list less imposing.
+    # This message is too long to be a string in the A/UX 3.1 sh.
+    cat << EOF
+Usage: configure [options] [host]
+Options: [defaults in brackets after descriptions]
+Configuration:
+  --cache-file=FILE       cache test results in FILE
+  --help                  print this message
+  --no-create             do not create output files
+  --quiet, --silent       do not print \`checking...' messages
+  --version               print the version of autoconf that created configure
+Directory and file names:
+  --prefix=PREFIX         install architecture-independent files in PREFIX
+                          [$ac_default_prefix]
+  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
+                          [same as prefix]
+  --bindir=DIR            user executables in DIR [EPREFIX/bin]
+  --sbindir=DIR           system admin executables in DIR [EPREFIX/sbin]
+  --libexecdir=DIR        program executables in DIR [EPREFIX/libexec]
+  --datadir=DIR           read-only architecture-independent data in DIR
+                          [PREFIX/share]
+  --sysconfdir=DIR        read-only single-machine data in DIR [PREFIX/etc]
+  --sharedstatedir=DIR    modifiable architecture-independent data in DIR
+                          [PREFIX/com]
+  --localstatedir=DIR     modifiable single-machine data in DIR [PREFIX/var]
+  --libdir=DIR            object code libraries in DIR [EPREFIX/lib]
+  --includedir=DIR        C header files in DIR [PREFIX/include]
+  --oldincludedir=DIR     C header files for non-gcc in DIR [/usr/include]
+  --infodir=DIR           info documentation in DIR [PREFIX/info]
+  --mandir=DIR            man documentation in DIR [PREFIX/man]
+  --srcdir=DIR            find the sources in DIR [configure dir or ..]
+  --program-prefix=PREFIX prepend PREFIX to installed program names
+  --program-suffix=SUFFIX append SUFFIX to installed program names
+  --program-transform-name=PROGRAM
+                          run sed PROGRAM on installed program names
+EOF
+    cat << EOF
+Host type:
+  --build=BUILD           configure for building on BUILD [BUILD=HOST]
+  --host=HOST             configure for HOST [guessed]
+  --target=TARGET         configure for TARGET [TARGET=HOST]
+Features and packages:
+  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
+  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
+  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
+  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
+  --x-includes=DIR        X include files are in DIR
+  --x-libraries=DIR       X library files are in DIR
+EOF
+    if test -n "$ac_help"; then
+      echo "--enable and --with options recognized:$ac_help"
+    fi
+    exit 0 ;;
+
+  -host | --host | --hos | --ho)
+    ac_prev=host ;;
+  -host=* | --host=* | --hos=* | --ho=*)
+    host="$ac_optarg" ;;
+
+  -includedir | --includedir | --includedi | --included | --include \
+  | --includ | --inclu | --incl | --inc)
+    ac_prev=includedir ;;
+  -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
+  | --includ=* | --inclu=* | --incl=* | --inc=*)
+    includedir="$ac_optarg" ;;
+
+  -infodir | --infodir | --infodi | --infod | --info | --inf)
+    ac_prev=infodir ;;
+  -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
+    infodir="$ac_optarg" ;;
+
+  -libdir | --libdir | --libdi | --libd)
+    ac_prev=libdir ;;
+  -libdir=* | --libdir=* | --libdi=* | --libd=*)
+    libdir="$ac_optarg" ;;
+
+  -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
+  | --libexe | --libex | --libe)
+    ac_prev=libexecdir ;;
+  -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
+  | --libexe=* | --libex=* | --libe=*)
+    libexecdir="$ac_optarg" ;;
+
+  -localstatedir | --localstatedir | --localstatedi | --localstated \
+  | --localstate | --localstat | --localsta | --localst \
+  | --locals | --local | --loca | --loc | --lo)
+    ac_prev=localstatedir ;;
+  -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+  | --localstate=* | --localstat=* | --localsta=* | --localst=* \
+  | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
+    localstatedir="$ac_optarg" ;;
+
+  -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
+    ac_prev=mandir ;;
+  -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
+    mandir="$ac_optarg" ;;
+
+  -nfp | --nfp | --nf)
+    # Obsolete; use --without-fp.
+    with_fp=no ;;
+
+  -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+  | --no-cr | --no-c)
+    no_create=yes ;;
+
+  -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+  | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
+    no_recursion=yes ;;
+
+  -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
+  | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
+  | --oldin | --oldi | --old | --ol | --o)
+    ac_prev=oldincludedir ;;
+  -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
+  | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
+  | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
+    oldincludedir="$ac_optarg" ;;
+
+  -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
+    ac_prev=prefix ;;
+  -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
+    prefix="$ac_optarg" ;;
+
+  -program-prefix | --program-prefix | --program-prefi | --program-pref \
+  | --program-pre | --program-pr | --program-p)
+    ac_prev=program_prefix ;;
+  -program-prefix=* | --program-prefix=* | --program-prefi=* \
+  | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
+    program_prefix="$ac_optarg" ;;
+
+  -program-suffix | --program-suffix | --program-suffi | --program-suff \
+  | --program-suf | --program-su | --program-s)
+    ac_prev=program_suffix ;;
+  -program-suffix=* | --program-suffix=* | --program-suffi=* \
+  | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
+    program_suffix="$ac_optarg" ;;
+
+  -program-transform-name | --program-transform-name \
+  | --program-transform-nam | --program-transform-na \
+  | --program-transform-n | --program-transform- \
+  | --program-transform | --program-transfor \
+  | --program-transfo | --program-transf \
+  | --program-trans | --program-tran \
+  | --progr-tra | --program-tr | --program-t)
+    ac_prev=program_transform_name ;;
+  -program-transform-name=* | --program-transform-name=* \
+  | --program-transform-nam=* | --program-transform-na=* \
+  | --program-transform-n=* | --program-transform-=* \
+  | --program-transform=* | --program-transfor=* \
+  | --program-transfo=* | --program-transf=* \
+  | --program-trans=* | --program-tran=* \
+  | --progr-tra=* | --program-tr=* | --program-t=*)
+    program_transform_name="$ac_optarg" ;;
+
+  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+  | -silent | --silent | --silen | --sile | --sil)
+    silent=yes ;;
+
+  -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+    ac_prev=sbindir ;;
+  -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+  | --sbi=* | --sb=*)
+    sbindir="$ac_optarg" ;;
+
+  -sharedstatedir | --sharedstatedir | --sharedstatedi \
+  | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
+  | --sharedst | --shareds | --shared | --share | --shar \
+  | --sha | --sh)
+    ac_prev=sharedstatedir ;;
+  -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
+  | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
+  | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
+  | --sha=* | --sh=*)
+    sharedstatedir="$ac_optarg" ;;
+
+  -site | --site | --sit)
+    ac_prev=site ;;
+  -site=* | --site=* | --sit=*)
+    site="$ac_optarg" ;;
+
+  -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+    ac_prev=srcdir ;;
+  -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+    srcdir="$ac_optarg" ;;
+
+  -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
+  | --syscon | --sysco | --sysc | --sys | --sy)
+    ac_prev=sysconfdir ;;
+  -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
+  | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
+    sysconfdir="$ac_optarg" ;;
+
+  -target | --target | --targe | --targ | --tar | --ta | --t)
+    ac_prev=target ;;
+  -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
+    target="$ac_optarg" ;;
+
+  -v | -verbose | --verbose | --verbos | --verbo | --verb)
+    verbose=yes ;;
+
+  -version | --version | --versio | --versi | --vers)
+    echo "configure generated by autoconf version 2.13"
+    exit 0 ;;
+
+  -with-* | --with-*)
+    ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'`
+    # Reject names that are not valid shell variable names.
+    if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then
+      { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
+    fi
+    ac_package=`echo $ac_package| sed 's/-/_/g'`
+    case "$ac_option" in
+      *=*) ;;
+      *) ac_optarg=yes ;;
+    esac
+    eval "with_${ac_package}='$ac_optarg'" ;;
+
+  -without-* | --without-*)
+    ac_package=`echo $ac_option|sed -e 's/-*without-//'`
+    # Reject names that are not valid shell variable names.
+    if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then
+      { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
+    fi
+    ac_package=`echo $ac_package| sed 's/-/_/g'`
+    eval "with_${ac_package}=no" ;;
+
+  --x)
+    # Obsolete; use --with-x.
+    with_x=yes ;;
+
+  -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
+  | --x-incl | --x-inc | --x-in | --x-i)
+    ac_prev=x_includes ;;
+  -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
+  | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
+    x_includes="$ac_optarg" ;;
+
+  -x-libraries | --x-libraries | --x-librarie | --x-librari \
+  | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
+    ac_prev=x_libraries ;;
+  -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
+  | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
+    x_libraries="$ac_optarg" ;;
+
+  -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; }
+    ;;
+
+  *)
+    if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then
+      echo "configure: warning: $ac_option: invalid host type" 1>&2
+    fi
+    if test "x$nonopt" != xNONE; then
+      { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; }
+    fi
+    nonopt="$ac_option"
+    ;;
+
+  esac
+done
+
+if test -n "$ac_prev"; then
+  { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; }
+fi
+
+trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
+
+# File descriptor usage:
+# 0 standard input
+# 1 file creation
+# 2 errors and warnings
+# 3 some systems may open it to /dev/tty
+# 4 used on the Kubota Titan
+# 6 checking for... messages and results
+# 5 compiler messages saved in config.log
+if test "$silent" = yes; then
+  exec 6>/dev/null
+else
+  exec 6>&1
+fi
+exec 5>./config.log
+
+echo "\
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+" 1>&5
+
+# Strip out --no-create and --no-recursion so they do not pile up.
+# Also quote any args containing shell metacharacters.
+ac_configure_args=
+for ac_arg
+do
+  case "$ac_arg" in
+  -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+  | --no-cr | --no-c) ;;
+  -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+  | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;;
+  *" "*|*"     "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*)
+  ac_configure_args="$ac_configure_args '$ac_arg'" ;;
+  *) ac_configure_args="$ac_configure_args $ac_arg" ;;
+  esac
+done
+
+# NLS nuisances.
+# Only set these to C if already set.  These must not be set unconditionally
+# because not all systems understand e.g. LANG=C (notably SCO).
+# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'!
+# Non-C LC_CTYPE values break the ctype check.
+if test "${LANG+set}"   = set; then LANG=C;   export LANG;   fi
+if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
+if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
+if test "${LC_CTYPE+set}"    = set; then LC_CTYPE=C;    export LC_CTYPE;    fi
+
+# confdefs.h avoids OS command line length limits that DEFS can exceed.
+rm -rf conftest* confdefs.h
+# AIX cpp loses on an empty file, so make sure it contains at least a newline.
+echo > confdefs.h
+
+# A filename unique to this package, relative to the directory that
+# configure is in, which we can look for to find out if srcdir is correct.
+ac_unique_file=include/idn/converter.h
+
+# Find the source files, if location was not specified.
+if test -z "$srcdir"; then
+  ac_srcdir_defaulted=yes
+  # Try the directory containing this script, then its parent.
+  ac_prog=$0
+  ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'`
+  test "x$ac_confdir" = "x$ac_prog" && ac_confdir=.
+  srcdir=$ac_confdir
+  if test ! -r $srcdir/$ac_unique_file; then
+    srcdir=..
+  fi
+else
+  ac_srcdir_defaulted=no
+fi
+if test ! -r $srcdir/$ac_unique_file; then
+  if test "$ac_srcdir_defaulted" = yes; then
+    { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; }
+  else
+    { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; }
+  fi
+fi
+srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'`
+
+# Prefer explicitly selected file to automatically selected ones.
+if test -z "$CONFIG_SITE"; then
+  if test "x$prefix" != xNONE; then
+    CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
+  else
+    CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
+  fi
+fi
+for ac_site_file in $CONFIG_SITE; do
+  if test -r "$ac_site_file"; then
+    echo "loading site script $ac_site_file"
+    . "$ac_site_file"
+  fi
+done
+
+if test -r "$cache_file"; then
+  echo "loading cache $cache_file"
+  . $cache_file
+else
+  echo "creating cache $cache_file"
+  > $cache_file
+fi
+
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
+
+ac_exeext=
+ac_objext=o
+if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
+  # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
+  if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
+    ac_n= ac_c='
+' ac_t='       '
+  else
+    ac_n=-n ac_c= ac_t=
+  fi
+else
+  ac_n= ac_c='\c' ac_t=
+fi
+
+
+
+ac_aux_dir=
+for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do
+  if test -f $ac_dir/install-sh; then
+    ac_aux_dir=$ac_dir
+    ac_install_sh="$ac_aux_dir/install-sh -c"
+    break
+  elif test -f $ac_dir/install.sh; then
+    ac_aux_dir=$ac_dir
+    ac_install_sh="$ac_aux_dir/install.sh -c"
+    break
+  fi
+done
+if test -z "$ac_aux_dir"; then
+  { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; }
+fi
+ac_config_guess=$ac_aux_dir/config.guess
+ac_config_sub=$ac_aux_dir/config.sub
+ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
+
+
+# Make sure we can run config.sub.
+if ${CONFIG_SHELL-/bin/sh} $ac_config_sub sun4 >/dev/null 2>&1; then :
+else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; }
+fi
+
+echo $ac_n "checking host system type""... $ac_c" 1>&6
+echo "configure:582: checking host system type" >&5
+
+host_alias=$host
+case "$host_alias" in
+NONE)
+  case $nonopt in
+  NONE)
+    if host_alias=`${CONFIG_SHELL-/bin/sh} $ac_config_guess`; then :
+    else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; }
+    fi ;;
+  *) host_alias=$nonopt ;;
+  esac ;;
+esac
+
+host=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $host_alias`
+host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+echo "$ac_t""$host" 1>&6
+
+
+debug=no
+# Check whether --enable-debug or --disable-debug was given.
+if test "${enable_debug+set}" = set; then
+  enableval="$enable_debug"
+  debug=$enableval
+fi
+
+case "$debug" in
+yes)
+    CFLAGS="$CFLAGS -DDEBUG"
+    ;;
+esac
+
+mdnkit_compat=no
+COMPAT_TRUE="#"
+COMPAT_FALSE=
+# Check whether --enable-mdnkit-compat or --disable-mdnkit-compat was given.
+if test "${enable_mdnkit_compat+set}" = set; then
+  enableval="$enable_mdnkit_compat"
+  mdnkit_compat=$enableval
+fi
+
+case "$mdnkit_compat" in
+yes)
+    COMPAT_TRUE=
+    COMPAT_FALSE="#"
+    cat >> confdefs.h <<\EOF
+#define ENABLE_MDNKIT_COMPAT 1
+EOF
+
+    ;;
+no)
+    ;;
+*)
+    { echo "configure: error: You must specify yes or no to --enable-runidn option." 1>&2; exit 1; }
+    ;;
+esac
+
+
+
+extraace=no
+# Check whether --enable-extra-ace or --disable-extra-ace was given.
+if test "${enable_extra_ace+set}" = set; then
+  enableval="$enable_extra_ace"
+  extraace=$enableval
+fi
+
+case "$extraace" in
+no)
+    ;;
+yes)
+    cat >> confdefs.h <<\EOF
+#define IDN_EXTRA_ACE 1
+EOF
+
+    ;;
+*)
+    { echo "configure: error: You must specify yes or no to --enable-extra-ace option." 1>&2; exit 1; }
+    ;;
+esac
+
+UTF8_NAME=no
+# Check whether --with-utf8 or --without-utf8 was given.
+if test "${with_utf8+set}" = set; then
+  withval="$with_utf8"
+  UTF8_NAME=$withval
+fi
+
+case "$UTF8_NAME" in
+no)
+    UTF8_NAME=UTF-8
+    ;;
+yes)
+    { echo "configure: error: You must specify NAME to --with-utf8 option." 1>&2; exit 1; }
+    ;;
+*)
+    cat >> confdefs.h <<EOF
+#define IDN_UTF8_ENCODING_NAME "$UTF8_NAME"
+EOF
+
+    ;;
+esac
+
+
+liteonly=no
+LITEONLY_TRUE="#"
+LITEONLY_FALSE=
+# Check whether --enable-liteonly or --disable-liteonly was given.
+if test "${enable_liteonly+set}" = set; then
+  enableval="$enable_liteonly"
+  liteonly=$enableval
+fi
+
+case "$liteonly" in
+no)
+    ;;
+yes)
+    if test "$install_runidn" = yes ; then
+       { echo "configure: error: you can't set value \"yes\" to --enable-runidn and --enable-liteonly simultaneously, because runidn requires iconv support of generic libidnkit." 1>&2; exit 1; }
+    fi
+    LITEONLY_TRUE=
+    LITEONLY_FALSE="#"
+    ;;
+*)
+    { echo "configure: error: You must specify yes or no to --enable-liteonly option." 1>&2; exit 1; }
+    ;;
+esac
+
+
+
+install_runidn=no
+RUNIDN_TRUE="#"
+RUNIDN_FALSE=
+# Check whether --enable-runidn or --disable-runidn was given.
+if test "${enable_runidn+set}" = set; then
+  enableval="$enable_runidn"
+  install_runidn=$enableval
+fi
+
+case "$install_runidn" in
+no)
+    ;;
+yes)
+    if test "$liteonly" = yes ; then
+       { echo "configure: error: you can't set value \"yes\" to --enable-runidn and --enable-liteonly simultaneously, because runidn requires iconv support of generic libidnkit." 1>&2; exit 1; }
+    fi
+    RUNIDN_TRUE=
+    RUNIDN_FALSE="#"
+    ;;
+*)
+    { echo "configure: error: You must specify yes or no to --enable-runidn option." 1>&2; exit 1; }
+    ;;
+esac
+
+
+
+ICONVINC=
+ICONVLIB=
+
+libiconv=unspec
+# Check whether --with-libiconv or --without-libiconv was given.
+if test "${with_libiconv+set}" = set; then
+  withval="$with_libiconv"
+  libiconv=$withval
+fi
+
+case "$libiconv" in
+unspec)
+    ;;
+no)
+    ICONVINC=
+    ICONVLIB=
+    ;;
+yes)
+    if test "$liteonly" = yes ; then
+       { echo "configure: error: you can't set iconv options at all when you set value \"yes\" to --enable-liteonly, because lite library does not have iconv support." 1>&2; exit 1; }
+    fi
+    if test X$prefix = XNONE ; then
+       libiconv=$ac_default_prefix
+    else
+       libiconv=$prefix
+    fi
+    ICONVINC="-I$libiconv/include"
+    ICONVLIB="-L$libiconv/lib -R$libiconv/lib -liconv"
+    ;;
+*)
+    if test "$liteonly" = yes ; then
+       { echo "configure: error: you can't set iconv options at all when you set value \"yes\" to --enable-liteonly, because lite library does not have iconv support." 1>&2; exit 1; }
+    fi
+    ICONVINC="-I$libiconv/include"
+    ICONVLIB="-L$libiconv/lib -R$libiconv/lib -liconv"
+    ;;
+esac
+
+iconv_include=unspec
+# Check whether --with-iconv-include or --without-iconv-include was given.
+if test "${with_iconv_include+set}" = set; then
+  withval="$with_iconv_include"
+  iconv_include=$withval
+fi
+
+case "$iconv_include" in
+unspec)
+    ;;
+no)
+    ICONVINC=
+    ;;
+yes)
+    if test "$liteonly" = yes ; then
+       { echo "configure: error: you can't set iconv options at all when you set value \"yes\" to --enable-liteonly, because lite library does not have iconv support." 1>&2; exit 1; }
+    fi
+    echo "configure: warning: You must supply DIR to --with-iconv-include option.
+  Ignored." 1>&2
+    ICONVINC=
+    ;;
+*)
+    if test "$liteonly" = yes ; then
+       { echo "configure: error: you can't set iconv options at all when you set value \"yes\" to --enable-liteonly, because lite library does not have iconv support." 1>&2; exit 1; }
+    fi
+    ICONVINC="-I$iconv_include"
+    ;;
+esac
+
+if test "X$ICONVINC" != X ; then
+    iconv_include="`echo X$ICONVINC | sed -e 's/^X-I//'`"
+    if test ! -f "$iconv_include/iconv.h" ; then
+       { echo "configure: error: iconv.h doesn't exist in $iconv_include" 1>&2; exit 1; }
+    fi
+fi
+
+
+
+iconv=unspec
+# Check whether --with-iconv or --without-iconv was given.
+if test "${with_iconv+set}" = set; then
+  withval="$with_iconv"
+  iconv=$withval
+fi
+
+case "$iconv" in
+unspec)
+    ;;
+no)
+    ICONVLIB=
+    ;;
+yes)
+    if test "$liteonly" = yes ; then
+       { echo "configure: error: you can't set iconv options at all when you set value \"yes\" to --enable-liteonly, because lite library does not have iconv support." 1>&2; exit 1; }
+    fi
+    echo "configure: warning: You must supply LIB to --with-iconv option.
+  -liconv is assumed." 1>&2
+    ICONVLIB=-liconv
+    ;;
+*)
+    if test "$liteonly" = yes ; then
+       { echo "configure: error: you can't set iconv options at all when you set value \"yes\" to --enable-liteonly, because lite library does not have iconv support." 1>&2; exit 1; }
+    fi
+    ICONVLIB=$iconv
+    ;;
+esac
+
+
+# Check whether --with-iconv-sofile or --without-iconv-sofile was given.
+if test "${with_iconv_sofile+set}" = set; then
+  withval="$with_iconv_sofile"
+  iconv_file=$withval
+else
+  iconv_file=guess
+fi
+
+ICONVSOFILE=
+case "$iconv_file" in
+no)
+    ICONVSOFILE=none
+    ;;
+yes)
+    if test "$liteonly" = yes ; then
+       { echo "configure: error: you can't set iconv options at all when you set value \"yes\" to --enable-liteonly, because lite library does not have iconv support." 1>&2; exit 1; }
+    fi
+    { echo "configure: error: You must supply PATH to --with-iconv-sofile option." 1>&2; exit 1; }
+    ;;
+guess)
+    if test "$liteonly" != yes ; then
+       if test "$ICONVLIB" = ""; then
+           ICONVSOFILE=none
+       else
+           echo $ac_n "checking pathname of iconv shared library""... $ac_c" 1>&6
+echo "configure:870: checking pathname of iconv shared library" >&5
+           ic_libdir=
+           ic_libname=
+           case "$host" in
+           *-hpux*)
+               SO=sl
+               ;;
+           *)
+               SO=so
+               ;;
+           esac
+           for arg in $ICONVLIB; do
+               case "$arg" in
+               -L*) ic_libdir="$ic_libdir `echo $arg | sed s/-L//`" ;;
+               -l*) ic_libname=`echo $arg | sed s/-l//` ;;
+               /*.$SO*) ICONVSOFILE=$arg ;;
+               esac
+           done
+           if test "$ICONVSOFILE" = ""; then
+               if test "$ic_libname" = ""; then
+                   echo "$ac_t""unknown" 1>&6
+                   echo "configure: warning: use --with-iconv-sofile for specifying iconv shared library file" 1>&2
+                   ICONVSOFILE=none
+               else
+                   if test "$ic_libdir" = ""; then
+                       # Standard (and semi-standard) library directories
+                       ic_libdir="/lib /usr/lib /usr/local/lib"
+                   fi
+                   for dir in $ic_libdir; do
+                       ICONVSOFILE=`ls -r $dir/lib$ic_libname.$SO* 2>/dev/null | head -1`
+                       if test "$ICONVSOFILE" != ""; then
+                           break
+                       fi
+                   done
+                   if test "$ICONVSOFILE" != ""; then
+                       echo "$ac_t""$ICONVSOFILE" 1>&6
+                   else
+                       echo "$ac_t""unknown" 1>&6
+                       echo "configure: warning: use --with-iconv-sofile for specifying iconv shared library file" 1>&2
+                       ICONVSOFILE=none
+                   fi
+               fi
+           fi
+       fi
+    else
+       ICONVSOFILE=none
+    fi
+    ;;
+*)
+    if test "$liteonly" = yes ; then
+       { echo "configure: error: you can't set iconv options at all when you set value \"yes\" to --enable-liteonly, because lite library does not have iconv support." 1>&2; exit 1; }
+    fi
+    ICONVSOFILE=$iconv_file
+    ;;
+esac
+
+
+PRELOAD_VAR="LD_PRELOAD"
+PRELOAD_SEP=":"
+PRELOAD_LAST=""
+case "$host" in
+*-solaris*)
+    PRELOAD_SEP=" "
+    ;;
+*-linux*)
+    PRELOAD_SEP=" "
+    ;;
+*-osf*)
+    PRELOAD_VAR="_RLD_LIST"
+    PRELOAD_LAST=":DEFAULT"
+    ;;
+*-netbsd*)
+    if test -x /usr/bin/file -a -x /usr/bin/grep ; then
+        case "`/usr/bin/file /usr/bin/grep`" in
+       *ELF*)
+           PRELOAD_SEP=" "
+           ;;
+       esac
+    fi
+    ;;
+esac
+
+
+
+
+
+# Extract the first word of "gcc", so it can be a program name with args.
+set dummy gcc; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:959: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$ac_word; then
+      ac_cv_prog_CC="gcc"
+      break
+    fi
+  done
+  IFS="$ac_save_ifs"
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+  echo "$ac_t""$CC" 1>&6
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+if test -z "$CC"; then
+  # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:989: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS=":"
+  ac_prog_rejected=no
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$ac_word; then
+      if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
+        ac_prog_rejected=yes
+       continue
+      fi
+      ac_cv_prog_CC="cc"
+      break
+    fi
+  done
+  IFS="$ac_save_ifs"
+if test $ac_prog_rejected = yes; then
+  # We found a bogon in the path, so make sure we never use it.
+  set dummy $ac_cv_prog_CC
+  shift
+  if test $# -gt 0; then
+    # We chose a different compiler from the bogus one.
+    # However, it has the same basename, so the bogon will be chosen
+    # first if we set CC to just the basename; use the full file name.
+    shift
+    set dummy "$ac_dir/$ac_word" "$@"
+    shift
+    ac_cv_prog_CC="$@"
+  fi
+fi
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+  echo "$ac_t""$CC" 1>&6
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+  if test -z "$CC"; then
+    case "`uname -s`" in
+    *win32* | *WIN32*)
+      # Extract the first word of "cl", so it can be a program name with args.
+set dummy cl; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:1040: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$ac_word; then
+      ac_cv_prog_CC="cl"
+      break
+    fi
+  done
+  IFS="$ac_save_ifs"
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+  echo "$ac_t""$CC" 1>&6
+else
+  echo "$ac_t""no" 1>&6
+fi
+ ;;
+    esac
+  fi
+  test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; }
+fi
+
+echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
+echo "configure:1072: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
+
+cat > conftest.$ac_ext << EOF
+
+#line 1083 "configure"
+#include "confdefs.h"
+
+main(){return(0);}
+EOF
+if { (eval echo configure:1088: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  ac_cv_prog_cc_works=yes
+  # If we can't run a trivial program, we are probably using a cross compiler.
+  if (./conftest; exit) 2>/dev/null; then
+    ac_cv_prog_cc_cross=no
+  else
+    ac_cv_prog_cc_cross=yes
+  fi
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  ac_cv_prog_cc_works=no
+fi
+rm -fr conftest*
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
+
+echo "$ac_t""$ac_cv_prog_cc_works" 1>&6
+if test $ac_cv_prog_cc_works = no; then
+  { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
+fi
+echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
+echo "configure:1114: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
+cross_compiling=$ac_cv_prog_cc_cross
+
+echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
+echo "configure:1119: checking whether we are using GNU C" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.c <<EOF
+#ifdef __GNUC__
+  yes;
+#endif
+EOF
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1128: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+  ac_cv_prog_gcc=yes
+else
+  ac_cv_prog_gcc=no
+fi
+fi
+
+echo "$ac_t""$ac_cv_prog_gcc" 1>&6
+
+if test $ac_cv_prog_gcc = yes; then
+  GCC=yes
+else
+  GCC=
+fi
+
+ac_test_CFLAGS="${CFLAGS+set}"
+ac_save_CFLAGS="$CFLAGS"
+CFLAGS=
+echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
+echo "configure:1147: checking whether ${CC-cc} accepts -g" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  echo 'void f(){}' > conftest.c
+if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
+  ac_cv_prog_cc_g=yes
+else
+  ac_cv_prog_cc_g=no
+fi
+rm -f conftest*
+
+fi
+
+echo "$ac_t""$ac_cv_prog_cc_g" 1>&6
+if test "$ac_test_CFLAGS" = set; then
+  CFLAGS="$ac_save_CFLAGS"
+elif test $ac_cv_prog_cc_g = yes; then
+  if test "$GCC" = yes; then
+    CFLAGS="-g -O2"
+  else
+    CFLAGS="-g"
+  fi
+else
+  if test "$GCC" = yes; then
+    CFLAGS="-O2"
+  else
+    CFLAGS=
+  fi
+fi
+
+# Find a good install program.  We prefer a C program (faster),
+# so one script is as good as another.  But avoid the broken or
+# incompatible versions:
+# SysV /etc/install, /usr/sbin/install
+# SunOS /usr/etc/install
+# IRIX /sbin/install
+# AIX /bin/install
+# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
+# AFS /usr/afsws/bin/install, which mishandles nonexistent args
+# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
+# ./install, which can be erroneously created by make from ./install.sh.
+echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
+echo "configure:1190: checking for a BSD compatible install" >&5
+if test -z "$INSTALL"; then
+if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+    IFS="${IFS=        }"; ac_save_IFS="$IFS"; IFS=":"
+  for ac_dir in $PATH; do
+    # Account for people who put trailing slashes in PATH elements.
+    case "$ac_dir/" in
+    /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
+    *)
+      # OSF1 and SCO ODT 3.0 have their own names for install.
+      # Don't use installbsd from OSF since it installs stuff as root
+      # by default.
+      for ac_prog in ginstall scoinst install; do
+        if test -f $ac_dir/$ac_prog; then
+         if test $ac_prog = install &&
+            grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
+           # AIX install.  It has an incompatible calling convention.
+           :
+         else
+           ac_cv_path_install="$ac_dir/$ac_prog -c"
+           break 2
+         fi
+       fi
+      done
+      ;;
+    esac
+  done
+  IFS="$ac_save_IFS"
+
+fi
+  if test "${ac_cv_path_install+set}" = set; then
+    INSTALL="$ac_cv_path_install"
+  else
+    # As a last resort, use the slow shell script.  We don't cache a
+    # path for INSTALL within a source directory, because that will
+    # break other packages using the cache if that directory is
+    # removed, or if the path is relative.
+    INSTALL="$ac_install_sh"
+  fi
+fi
+echo "$ac_t""$INSTALL" 1>&6
+
+# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
+# It thinks the first close brace ends the variable substitution.
+test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
+
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}'
+
+test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
+
+# Check whether --enable-shared or --disable-shared was given.
+if test "${enable_shared+set}" = set; then
+  enableval="$enable_shared"
+  p=${PACKAGE-default}
+case "$enableval" in
+yes) enable_shared=yes ;;
+no) enable_shared=no ;;
+*)
+  enable_shared=no
+  # Look at the argument we got.  We use all the common list separators.
+  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
+  for pkg in $enableval; do
+    if test "X$pkg" = "X$p"; then
+      enable_shared=yes
+    fi
+  done
+  IFS="$ac_save_ifs"
+  ;;
+esac
+else
+  enable_shared=yes
+fi
+
+# Check whether --enable-static or --disable-static was given.
+if test "${enable_static+set}" = set; then
+  enableval="$enable_static"
+  p=${PACKAGE-default}
+case "$enableval" in
+yes) enable_static=yes ;;
+no) enable_static=no ;;
+*)
+  enable_static=no
+  # Look at the argument we got.  We use all the common list separators.
+  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
+  for pkg in $enableval; do
+    if test "X$pkg" = "X$p"; then
+      enable_static=yes
+    fi
+  done
+  IFS="$ac_save_ifs"
+  ;;
+esac
+else
+  enable_static=yes
+fi
+
+# Check whether --enable-fast-install or --disable-fast-install was given.
+if test "${enable_fast_install+set}" = set; then
+  enableval="$enable_fast_install"
+  p=${PACKAGE-default}
+case "$enableval" in
+yes) enable_fast_install=yes ;;
+no) enable_fast_install=no ;;
+*)
+  enable_fast_install=no
+  # Look at the argument we got.  We use all the common list separators.
+  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
+  for pkg in $enableval; do
+    if test "X$pkg" = "X$p"; then
+      enable_fast_install=yes
+    fi
+  done
+  IFS="$ac_save_ifs"
+  ;;
+esac
+else
+  enable_fast_install=yes
+fi
+
+echo $ac_n "checking build system type""... $ac_c" 1>&6
+echo "configure:1312: checking build system type" >&5
+
+build_alias=$build
+case "$build_alias" in
+NONE)
+  case $nonopt in
+  NONE) build_alias=$host_alias ;;
+  *) build_alias=$nonopt ;;
+  esac ;;
+esac
+
+build=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $build_alias`
+build_cpu=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+build_vendor=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+build_os=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+echo "$ac_t""$build" 1>&6
+
+# Extract the first word of "ranlib", so it can be a program name with args.
+set dummy ranlib; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:1332: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  if test -n "$RANLIB"; then
+  ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
+else
+  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$ac_word; then
+      ac_cv_prog_RANLIB="ranlib"
+      break
+    fi
+  done
+  IFS="$ac_save_ifs"
+  test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":"
+fi
+fi
+RANLIB="$ac_cv_prog_RANLIB"
+if test -n "$RANLIB"; then
+  echo "$ac_t""$RANLIB" 1>&6
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+# Check whether --with-gnu-ld or --without-gnu-ld was given.
+if test "${with_gnu_ld+set}" = set; then
+  withval="$with_gnu_ld"
+  test "$withval" = no || with_gnu_ld=yes
+else
+  with_gnu_ld=no
+fi
+
+ac_prog=ld
+if test "$ac_cv_prog_gcc" = yes; then
+  # Check if gcc -print-prog-name=ld gives a path.
+  echo $ac_n "checking for ld used by GCC""... $ac_c" 1>&6
+echo "configure:1371: checking for ld used by GCC" >&5
+  ac_prog=`($CC -print-prog-name=ld) 2>&5`
+  case "$ac_prog" in
+    # Accept absolute paths.
+    [\\/]* | [A-Za-z]:[\\/]*)
+      re_direlt='/[^/][^/]*/\.\./'
+      # Canonicalize the path of ld
+      ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
+      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
+       ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
+      done
+      test -z "$LD" && LD="$ac_prog"
+      ;;
+  "")
+    # If it fails, then pretend we aren't using GCC.
+    ac_prog=ld
+    ;;
+  *)
+    # If it is relative, then search for the first ld in PATH.
+    with_gnu_ld=unknown
+    ;;
+  esac
+elif test "$with_gnu_ld" = yes; then
+  echo $ac_n "checking for GNU ld""... $ac_c" 1>&6
+echo "configure:1395: checking for GNU ld" >&5
+else
+  echo $ac_n "checking for non-GNU ld""... $ac_c" 1>&6
+echo "configure:1398: checking for non-GNU ld" >&5
+fi
+if eval "test \"`echo '$''{'ac_cv_path_LD'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  if test -z "$LD"; then
+  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
+  for ac_dir in $PATH; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+      ac_cv_path_LD="$ac_dir/$ac_prog"
+      # Check to see if the program is GNU ld.  I'd rather use --version,
+      # but apparently some GNU ld's only accept -v.
+      # Break only if it was the GNU/non-GNU ld that we prefer.
+      if "$ac_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
+       test "$with_gnu_ld" != no && break
+      else
+       test "$with_gnu_ld" != yes && break
+      fi
+    fi
+  done
+  IFS="$ac_save_ifs"
+else
+  ac_cv_path_LD="$LD" # Let the user override the test with a path.
+fi
+fi
+
+LD="$ac_cv_path_LD"
+if test -n "$LD"; then
+  echo "$ac_t""$LD" 1>&6
+else
+  echo "$ac_t""no" 1>&6
+fi
+test -z "$LD" && { echo "configure: error: no acceptable ld found in \$PATH" 1>&2; exit 1; }
+echo $ac_n "checking if the linker ($LD) is GNU ld""... $ac_c" 1>&6
+echo "configure:1433: checking if the linker ($LD) is GNU ld" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_gnu_ld'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  # I'd rather use --version here, but apparently some GNU ld's only accept -v.
+if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
+  ac_cv_prog_gnu_ld=yes
+else
+  ac_cv_prog_gnu_ld=no
+fi
+fi
+
+echo "$ac_t""$ac_cv_prog_gnu_ld" 1>&6
+
+
+echo $ac_n "checking for BSD-compatible nm""... $ac_c" 1>&6
+echo "configure:1449: checking for BSD-compatible nm" >&5
+if eval "test \"`echo '$''{'ac_cv_path_NM'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  if test -n "$NM"; then
+  # Let the user override the test.
+  ac_cv_path_NM="$NM"
+else
+  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
+  for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/nm || test -f $ac_dir/nm$ac_exeext ; then
+      # Check to see if the nm accepts a BSD-compat flag.
+      # Adding the `sed 1q' prevents false positives on HP-UX, which says:
+      #   nm: unknown option "B" ignored
+      if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
+       ac_cv_path_NM="$ac_dir/nm -B"
+       break
+      elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
+       ac_cv_path_NM="$ac_dir/nm -p"
+       break
+      else
+       ac_cv_path_NM=${ac_cv_path_NM="$ac_dir/nm"} # keep the first match, but
+       continue # so that we can try to find one that supports BSD flags
+      fi
+    fi
+  done
+  IFS="$ac_save_ifs"
+  test -z "$ac_cv_path_NM" && ac_cv_path_NM=nm
+fi
+fi
+
+NM="$ac_cv_path_NM"
+echo "$ac_t""$NM" 1>&6
+
+echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6
+echo "configure:1485: checking whether ln -s works" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_LN_S'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  rm -f conftestdata
+if ln -s X conftestdata 2>/dev/null
+then
+  rm -f conftestdata
+  ac_cv_prog_LN_S="ln -s"
+else
+  ac_cv_prog_LN_S=ln
+fi
+fi
+LN_S="$ac_cv_prog_LN_S"
+if test "$ac_cv_prog_LN_S" = "ln -s"; then
+  echo "$ac_t""yes" 1>&6
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+
+case "$target" in
+NONE) lt_target="$host" ;;
+*) lt_target="$target" ;;
+esac
+
+# Check for any special flags to pass to ltconfig.
+libtool_flags="--cache-file=$cache_file"
+test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared"
+test "$enable_static" = no && libtool_flags="$libtool_flags --disable-static"
+test "$enable_fast_install" = no && libtool_flags="$libtool_flags --disable-fast-install"
+test "$ac_cv_prog_gcc" = yes && libtool_flags="$libtool_flags --with-gcc"
+test "$ac_cv_prog_gnu_ld" = yes && libtool_flags="$libtool_flags --with-gnu-ld"
+
+
+# Check whether --enable-libtool-lock or --disable-libtool-lock was given.
+if test "${enable_libtool_lock+set}" = set; then
+  enableval="$enable_libtool_lock"
+  :
+fi
+
+test "x$enable_libtool_lock" = xno && libtool_flags="$libtool_flags --disable-lock"
+test x"$silent" = xyes && libtool_flags="$libtool_flags --silent"
+
+# Some flags need to be propagated to the compiler or linker for good
+# libtool support.
+case "$lt_target" in
+*-*-irix6*)
+  # Find out which ABI we are using.
+  echo '#line 1534 "configure"' > conftest.$ac_ext
+  if { (eval echo configure:1535: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    case "`/usr/bin/file conftest.o`" in
+    *32-bit*)
+      LD="${LD-ld} -32"
+      ;;
+    *N32*)
+      LD="${LD-ld} -n32"
+      ;;
+    *64-bit*)
+      LD="${LD-ld} -64"
+      ;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+
+*-*-sco3.2v5*)
+  # On SCO OpenServer 5, we need -belf to get full-featured binaries.
+  SAVE_CFLAGS="$CFLAGS"
+  CFLAGS="$CFLAGS -belf"
+  echo $ac_n "checking whether the C compiler needs -belf""... $ac_c" 1>&6
+echo "configure:1556: checking whether the C compiler needs -belf" >&5
+if eval "test \"`echo '$''{'lt_cv_cc_needs_belf'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 1561 "configure"
+#include "confdefs.h"
+
+int main() {
+
+; return 0; }
+EOF
+if { (eval echo configure:1568: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  rm -rf conftest*
+  lt_cv_cc_needs_belf=yes
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  lt_cv_cc_needs_belf=no
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$lt_cv_cc_needs_belf" 1>&6
+  if test x"$lt_cv_cc_needs_belf" != x"yes"; then
+    # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
+    CFLAGS="$SAVE_CFLAGS"
+  fi
+  ;;
+
+
+esac
+
+
+# Save cache, so that ltconfig can load it
+cat > confcache <<\EOF
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs.  It is not useful on other systems.
+# If it contains results you don't want to keep, you may remove or edit it.
+#
+# By default, configure uses ./config.cache as the cache file,
+# creating it if it does not exist already.  You can give configure
+# the --cache-file=FILE option to use a different cache file; that is
+# what configure does when it calls configure scripts in
+# subdirectories, so they share the cache.
+# Giving --cache-file=/dev/null disables caching, for debugging configure.
+# config.status only pays attention to the cache file if you give it the
+# --recheck option to rerun configure.
+#
+EOF
+# The following way of writing the cache mishandles newlines in values,
+# but we know of no workaround that is simple, portable, and efficient.
+# So, don't put newlines in cache variables' values.
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
+(set) 2>&1 |
+  case `(ac_space=' '; set | grep ac_space) 2>&1` in
+  *ac_space=\ *)
+    # `set' does not quote correctly, so add quotes (double-quote substitution
+    # turns \\\\ into \\, and sed turns \\ into \).
+    sed -n \
+      -e "s/'/'\\\\''/g" \
+      -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p"
+    ;;
+  *)
+    # `set' quotes correctly as required by POSIX, so do not add quotes.
+    sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p'
+    ;;
+  esac >> confcache
+if cmp -s $cache_file confcache; then
+  :
+else
+  if test -w $cache_file; then
+    echo "updating cache $cache_file"
+    cat confcache > $cache_file
+  else
+    echo "not updating unwritable cache $cache_file"
+  fi
+fi
+rm -f confcache
+
+
+# Actually configure libtool.  ac_aux_dir is where install-sh is found.
+CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \
+LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \
+LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" \
+DLLTOOL="$DLLTOOL" AS="$AS" OBJDUMP="$OBJDUMP" \
+${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \
+$libtool_flags --no-verify $ac_aux_dir/ltmain.sh $lt_target \
+|| { echo "configure: error: libtool configure failed" 1>&2; exit 1; }
+
+# Reload cache, that may have been modified by ltconfig
+if test -r "$cache_file"; then
+  echo "loading cache $cache_file"
+  . $cache_file
+else
+  echo "creating cache $cache_file"
+  > $cache_file
+fi
+
+
+# This can be used to rebuild libtool when needed
+LIBTOOL_DEPS="$ac_aux_dir/ltconfig $ac_aux_dir/ltmain.sh"
+
+# Always use our own libtool.
+LIBTOOL='$(SHELL) $(top_builddir)/libtool'
+
+# Redirect the config.log output again, so that the ltconfig log is not
+# clobbered by the next message.
+exec 5>>./config.log
+
+
+for ac_prog in perl
+do
+# Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:1675: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_path_PERL'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  case "$PERL" in
+  /*)
+  ac_cv_path_PERL="$PERL" # Let the user override the test with a path.
+  ;;
+  ?:/*)                         
+  ac_cv_path_PERL="$PERL" # Let the user override the test with a dos path.
+  ;;
+  *)
+  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do 
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$ac_word; then
+      ac_cv_path_PERL="$ac_dir/$ac_word"
+      break
+    fi
+  done
+  IFS="$ac_save_ifs"
+  ;;
+esac
+fi
+PERL="$ac_cv_path_PERL"
+if test -n "$PERL"; then
+  echo "$ac_t""$PERL" 1>&6
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+test -n "$PERL" && break
+done
+test -n "$PERL" || PERL="perl"
+
+
+echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
+echo "configure:1713: checking how to run the C preprocessor" >&5
+# On Suns, sometimes $CPP names a directory.
+if test -n "$CPP" && test -d "$CPP"; then
+  CPP=
+fi
+if test -z "$CPP"; then
+if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+    # This must be in double quotes, not single quotes, because CPP may get
+  # substituted into the Makefile and "${CC-cc}" will confuse make.
+  CPP="${CC-cc} -E"
+  # On the NeXT, cc -E runs the code through the compiler's parser,
+  # not just through cpp.
+  cat > conftest.$ac_ext <<EOF
+#line 1728 "configure"
+#include "confdefs.h"
+#include <assert.h>
+Syntax Error
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1734: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+  :
+else
+  echo "$ac_err" >&5
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  CPP="${CC-cc} -E -traditional-cpp"
+  cat > conftest.$ac_ext <<EOF
+#line 1745 "configure"
+#include "confdefs.h"
+#include <assert.h>
+Syntax Error
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1751: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+  :
+else
+  echo "$ac_err" >&5
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  CPP="${CC-cc} -nologo -E"
+  cat > conftest.$ac_ext <<EOF
+#line 1762 "configure"
+#include "confdefs.h"
+#include <assert.h>
+Syntax Error
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1768: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+  :
+else
+  echo "$ac_err" >&5
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  CPP=/lib/cpp
+fi
+rm -f conftest*
+fi
+rm -f conftest*
+fi
+rm -f conftest*
+  ac_cv_prog_CPP="$CPP"
+fi
+  CPP="$ac_cv_prog_CPP"
+else
+  ac_cv_prog_CPP="$CPP"
+fi
+echo "$ac_t""$CPP" 1>&6
+
+for ac_hdr in unistd.h locale.h langinfo.h pwd.h
+do
+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+echo "configure:1796: checking for $ac_hdr" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 1801 "configure"
+#include "confdefs.h"
+#include <$ac_hdr>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1806: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+  rm -rf conftest*
+  eval "ac_cv_header_$ac_safe=yes"
+else
+  echo "$ac_err" >&5
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+    ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
+  cat >> confdefs.h <<EOF
+#define $ac_tr_hdr 1
+EOF
+else
+  echo "$ac_t""no" 1>&6
+fi
+done
+
+if test "$install_runidn" = yes ; then
+    for ac_hdr in dlfcn.h
+do
+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+echo "configure:1837: checking for $ac_hdr" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 1842 "configure"
+#include "confdefs.h"
+#include <$ac_hdr>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1847: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+  rm -rf conftest*
+  eval "ac_cv_header_$ac_safe=yes"
+else
+  echo "$ac_err" >&5
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+    ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
+  cat >> confdefs.h <<EOF
+#define $ac_tr_hdr 1
+EOF
+else
+  echo "$ac_t""no" 1>&6
+fi
+done
+
+fi
+
+saved_CPPFLAGS=$CPPFLAGS
+CPPFLAGS="$CPPFLAGS $ICONVINC"
+if test "$liteonly" != yes ; then
+    ac_safe=`echo "iconv.h" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for iconv.h""... $ac_c" 1>&6
+echo "configure:1880: checking for iconv.h" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 1885 "configure"
+#include "confdefs.h"
+#include <iconv.h>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1890: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+  rm -rf conftest*
+  eval "ac_cv_header_$ac_safe=yes"
+else
+  echo "$ac_err" >&5
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  :
+else
+  echo "$ac_t""no" 1>&6
+{ echo "configure: error: iconv.h doesn't exist" 1>&2; exit 1; }
+fi
+
+fi
+CPPFLAGS=$saved_CPPFLAGS
+
+echo $ac_n "checking for uid_t in sys/types.h""... $ac_c" 1>&6
+echo "configure:1916: checking for uid_t in sys/types.h" >&5
+if eval "test \"`echo '$''{'ac_cv_type_uid_t'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 1921 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  egrep "uid_t" >/dev/null 2>&1; then
+  rm -rf conftest*
+  ac_cv_type_uid_t=yes
+else
+  rm -rf conftest*
+  ac_cv_type_uid_t=no
+fi
+rm -f conftest*
+
+fi
+
+echo "$ac_t""$ac_cv_type_uid_t" 1>&6
+if test $ac_cv_type_uid_t = no; then
+  cat >> confdefs.h <<\EOF
+#define uid_t int
+EOF
+
+  cat >> confdefs.h <<\EOF
+#define gid_t int
+EOF
+
+fi
+
+echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
+echo "configure:1950: checking for ANSI C header files" >&5
+if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 1955 "configure"
+#include "confdefs.h"
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1963: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+  rm -rf conftest*
+  ac_cv_header_stdc=yes
+else
+  echo "$ac_err" >&5
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+if test $ac_cv_header_stdc = yes; then
+  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+cat > conftest.$ac_ext <<EOF
+#line 1980 "configure"
+#include "confdefs.h"
+#include <string.h>
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  egrep "memchr" >/dev/null 2>&1; then
+  :
+else
+  rm -rf conftest*
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+cat > conftest.$ac_ext <<EOF
+#line 1998 "configure"
+#include "confdefs.h"
+#include <stdlib.h>
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  egrep "free" >/dev/null 2>&1; then
+  :
+else
+  rm -rf conftest*
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+if test "$cross_compiling" = yes; then
+  :
+else
+  cat > conftest.$ac_ext <<EOF
+#line 2019 "configure"
+#include "confdefs.h"
+#include <ctype.h>
+#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int main () { int i; for (i = 0; i < 256; i++)
+if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
+exit (0); }
+
+EOF
+if { (eval echo configure:2030: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+  :
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -fr conftest*
+  ac_cv_header_stdc=no
+fi
+rm -fr conftest*
+fi
+
+fi
+fi
+
+echo "$ac_t""$ac_cv_header_stdc" 1>&6
+if test $ac_cv_header_stdc = yes; then
+  cat >> confdefs.h <<\EOF
+#define STDC_HEADERS 1
+EOF
+
+fi
+
+echo $ac_n "checking for BOOL""... $ac_c" 1>&6
+echo "configure:2054: checking for BOOL" >&5
+if eval "test \"`echo '$''{'ac_cv_type_BOOL'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 2059 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#if STDC_HEADERS
+#include <stdlib.h>
+#include <stddef.h>
+#endif
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  egrep "(^|[^a-zA-Z_0-9])BOOL[^a-zA-Z_0-9]" >/dev/null 2>&1; then
+  rm -rf conftest*
+  ac_cv_type_BOOL=yes
+else
+  rm -rf conftest*
+  ac_cv_type_BOOL=no
+fi
+rm -f conftest*
+
+fi
+echo "$ac_t""$ac_cv_type_BOOL" 1>&6
+if test $ac_cv_type_BOOL = no; then
+  cat >> confdefs.h <<\EOF
+#define BOOL int
+EOF
+
+fi
+
+
+if test "$install_runidn" = yes ; then
+    echo $ac_n "checking for socket in -lsocket""... $ac_c" 1>&6
+echo "configure:2089: checking for socket in -lsocket" >&5
+ac_lib_var=`echo socket'_'socket | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  ac_save_LIBS="$LIBS"
+LIBS="-lsocket  $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 2097 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char socket();
+
+int main() {
+socket()
+; return 0; }
+EOF
+if { (eval echo configure:2108: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=yes"
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+    ac_tr_lib=HAVE_LIB`echo socket | sed -e 's/[^a-zA-Z0-9_]/_/g' \
+    -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
+  cat >> confdefs.h <<EOF
+#define $ac_tr_lib 1
+EOF
+
+  LIBS="-lsocket $LIBS"
+
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+    echo $ac_n "checking for inet_addr in -lnsl""... $ac_c" 1>&6
+echo "configure:2136: checking for inet_addr in -lnsl" >&5
+ac_lib_var=`echo nsl'_'inet_addr | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  ac_save_LIBS="$LIBS"
+LIBS="-lnsl  $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 2144 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char inet_addr();
+
+int main() {
+inet_addr()
+; return 0; }
+EOF
+if { (eval echo configure:2155: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=yes"
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+    ac_tr_lib=HAVE_LIB`echo nsl | sed -e 's/[^a-zA-Z0-9_]/_/g' \
+    -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
+  cat >> confdefs.h <<EOF
+#define $ac_tr_lib 1
+EOF
+
+  LIBS="-lnsl $LIBS"
+
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+    echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6
+echo "configure:2183: checking for dlopen in -ldl" >&5
+ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  ac_save_LIBS="$LIBS"
+LIBS="-ldl  $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 2191 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char dlopen();
+
+int main() {
+dlopen()
+; return 0; }
+EOF
+if { (eval echo configure:2202: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=yes"
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  
+       LIBS="-ldl $LIBS"
+       LIBDL="-ldl"
+       cat >> confdefs.h <<\EOF
+#define HAVE_LIBDL 1
+EOF
+
+       
+    
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+fi
+
+for ac_func in vsnprintf setvbuf setlocale nl_langinfo memmove bcopy setenv \
+    unsetenv
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:2236: checking for $ac_func" >&5
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 2241 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func(); below.  */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char $ac_func();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:2264: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  rm -rf conftest*
+  eval "ac_cv_func_$ac_func=yes"
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+    ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+  cat >> confdefs.h <<EOF
+#define $ac_tr_func 1
+EOF
+else
+  echo "$ac_t""no" 1>&6
+fi
+done
+
+if test "$install_runidn" = yes ; then
+    for ac_func in gethostbyname gethostbyname2 gethostbyaddr
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:2292: checking for $ac_func" >&5
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 2297 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func(); below.  */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char $ac_func();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:2320: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  rm -rf conftest*
+  eval "ac_cv_func_$ac_func=yes"
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+    ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+  cat >> confdefs.h <<EOF
+#define $ac_tr_func 1
+EOF
+else
+  echo "$ac_t""no" 1>&6
+fi
+done
+
+    for ac_func in gethostbyname_r gethostbyname2_r gethostbyaddr_r
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:2347: checking for $ac_func" >&5
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 2352 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func(); below.  */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char $ac_func();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:2375: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  rm -rf conftest*
+  eval "ac_cv_func_$ac_func=yes"
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+    ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+  cat >> confdefs.h <<EOF
+#define $ac_tr_func 1
+EOF
+ find_gethost_r=yes
+else
+  echo "$ac_t""no" 1>&6
+fi
+done
+
+    for ac_func in getipnodebyname getipnodebyaddr freehostent
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:2402: checking for $ac_func" >&5
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 2407 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func(); below.  */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char $ac_func();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:2430: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  rm -rf conftest*
+  eval "ac_cv_func_$ac_func=yes"
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+    ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+  cat >> confdefs.h <<EOF
+#define $ac_tr_func 1
+EOF
+else
+  echo "$ac_t""no" 1>&6
+fi
+done
+
+    for ac_func in getaddrinfo freeaddrinfo getnameinfo
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:2457: checking for $ac_func" >&5
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 2462 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func(); below.  */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char $ac_func();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:2485: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  rm -rf conftest*
+  eval "ac_cv_func_$ac_func=yes"
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+    ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+  cat >> confdefs.h <<EOF
+#define $ac_tr_func 1
+EOF
+else
+  echo "$ac_t""no" 1>&6
+fi
+done
+
+    for ac_func in dlopen dlsym
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:2512: checking for $ac_func" >&5
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 2517 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func(); below.  */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char $ac_func();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:2540: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  rm -rf conftest*
+  eval "ac_cv_func_$ac_func=yes"
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+    ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+  cat >> confdefs.h <<EOF
+#define $ac_tr_func 1
+EOF
+else
+  echo "$ac_t""no" 1>&6
+fi
+done
+
+fi
+
+if test "$install_runidn" = yes ; then
+    echo $ac_n "checking flavor of gethostbyaddr""... $ac_c" 1>&6
+echo "configure:2568: checking flavor of gethostbyaddr" >&5
+if eval "test \"`echo '$''{'ac_cv_flavor_gethostbyaddr'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  ac_cv_flavor_gethostbyaddr=unknown
+    if test "$cross_compiling" = yes; then
+  ac_cv_flavor_gethostbyaddr=unknown
+else
+  cat > conftest.$ac_ext <<EOF
+#line 2577 "configure"
+#include "confdefs.h"
+
+    #include <stddef.h>
+    #include <sys/types.h>
+    #include <sys/socket.h>
+    #include <netdb.h>
+    struct hostent *gethostbyaddr(const void *addr, socklen_t len, int type) {
+       return NULL;
+    }
+    int main() {
+       (void)gethostbyaddr(NULL, 0, 0);
+       return 0;
+    }
+    
+EOF
+if { (eval echo configure:2593: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+  ac_cv_flavor_gethostbyaddr=glibc2_2
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+fi
+rm -fr conftest*
+fi
+
+    if test "$cross_compiling" = yes; then
+  ac_cv_flavor_gethostbyaddr=unknown
+else
+  cat > conftest.$ac_ext <<EOF
+#line 2607 "configure"
+#include "confdefs.h"
+
+    #include <stddef.h>
+    #include <sys/types.h>
+    #include <sys/socket.h>
+    #include <netdb.h>
+    struct hostent *gethostbyaddr(const char *addr, size_t len, int type) {
+       return NULL;
+    }
+    int main() {
+       (void)gethostbyaddr(NULL, 0, 0);
+       return 0;
+    }
+    
+EOF
+if { (eval echo configure:2623: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+  ac_cv_flavor_gethostbyaddr=glibc
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+fi
+rm -fr conftest*
+fi
+
+    if test "$cross_compiling" = yes; then
+  ac_cv_flavor_gethostbyaddr=unknown
+else
+  cat > conftest.$ac_ext <<EOF
+#line 2637 "configure"
+#include "confdefs.h"
+
+    #include <stddef.h>
+    #include <sys/types.h>
+    #include <sys/socket.h>
+    #include <netdb.h>
+    struct hostent *gethostbyaddr(const char *addr, int len, int type) {
+       return NULL;
+    }
+    int main() {
+       (void)gethostbyaddr(NULL, 0, 0);
+       return 0;
+    }
+    
+EOF
+if { (eval echo configure:2653: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+  ac_cv_flavor_gethostbyaddr=traditional
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+fi
+rm -fr conftest*
+fi
+
+    if test "$ac_cv_func_gethostbyaddr" = no ; then
+       ac_cv_flavor_gethostbyaddr=none
+    fi
+fi
+
+echo "$ac_t""$ac_cv_flavor_gethostbyaddr" 1>&6
+
+    case "$ac_cv_flavor_gethostbyaddr" in
+    glibc2_2)
+       ac_cv_type_ghba_addr_t='const void *'
+       ac_cv_type_ghba_addrlen_t='socklen_t'
+       ;;
+    glibc)
+       ac_cv_type_ghba_addr_t='const char *'
+       ac_cv_type_ghba_addrlen_t='size_t'
+       ;;
+    traditional | none)
+       ac_cv_type_ghba_addr_t='const char *'
+       ac_cv_type_ghba_addrlen_t='int'
+       ;;
+    *)
+       { echo "configure: error: can't build runidn, since parameter type list of gethostbyaddr() is unknown to configure." 1>&2; exit 1; }
+       ;;
+    esac
+    cat >> confdefs.h <<EOF
+#define GHBA_ADDR_T $ac_cv_type_ghba_addr_t
+EOF
+
+    cat >> confdefs.h <<EOF
+#define GHBA_ADDRLEN_T $ac_cv_type_ghba_addrlen_t
+EOF
+
+
+    echo $ac_n "checking flavor of getnameinfo""... $ac_c" 1>&6
+echo "configure:2697: checking flavor of getnameinfo" >&5
+if eval "test \"`echo '$''{'ac_cv_flavor_getnameinfo'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  ac_cv_flavor_getnameinfo=unknown
+    if test "$cross_compiling" = yes; then
+  ac_cv_flavor_getnameinfo=unknown
+else
+  cat > conftest.$ac_ext <<EOF
+#line 2706 "configure"
+#include "confdefs.h"
+
+    #include <stddef.h>
+    #include <sys/types.h>
+    #include <sys/socket.h>
+    #include <netdb.h>
+    int getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host,
+                    socklen_t hostlen, char *serv, socklen_t servlen,
+                    unsigned int flags) {
+       return NULL;
+    }
+    int main() {
+       (void)getnameinfo(NULL, 0, NULL, 0, NULL, 0, 0);
+       return 0;
+    }
+    
+EOF
+if { (eval echo configure:2724: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+  ac_cv_flavor_getnameinfo=glibc2_2_2
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+fi
+rm -fr conftest*
+fi
+
+    if test "$cross_compiling" = yes; then
+  ac_cv_flavor_getnameinfo=unknown
+else
+  cat > conftest.$ac_ext <<EOF
+#line 2738 "configure"
+#include "confdefs.h"
+
+    #include <stddef.h>
+    #include <sys/types.h>
+    #include <sys/socket.h>
+    #include <netdb.h>
+    int getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host,
+                    socklen_t hostlen, char *serv, socklen_t servlen,
+                    int flags) {
+       return NULL;
+    }
+    int main() {
+       (void)getnameinfo(NULL, 0, NULL, 0, NULL, 0, 0);
+       return 0;
+    }
+    
+EOF
+if { (eval echo configure:2756: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+  ac_cv_flavor_getnameinfo=rfc2553bis_03
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+fi
+rm -fr conftest*
+fi
+
+    if test "$cross_compiling" = yes; then
+  ac_cv_flavor_getnameinfo=unknown
+else
+  cat > conftest.$ac_ext <<EOF
+#line 2770 "configure"
+#include "confdefs.h"
+
+    #include <stddef.h>
+    #include <sys/types.h>
+    #include <sys/socket.h>
+    #include <netdb.h>
+    int getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host,
+                    size_t hostlen, char *serv, size_t servlen, int flags) {
+       return NULL;
+    }
+    int main() {
+       (void)getnameinfo(NULL, 0, NULL, 0, NULL, 0, 0);
+       return 0;
+    }
+    
+EOF
+if { (eval echo configure:2787: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+  ac_cv_flavor_getnameinfo=rfc2553
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+fi
+rm -fr conftest*
+fi
+
+    if test "$cross_compiling" = yes; then
+  ac_cv_flavor_getnameinfo=unknown
+else
+  cat > conftest.$ac_ext <<EOF
+#line 2801 "configure"
+#include "confdefs.h"
+
+    #include <stddef.h>
+    #include <sys/types.h>
+    #include <sys/socket.h>
+    #include <netdb.h>
+    int getnameinfo(const struct sockaddr *sa, size_t salen, char *host,
+                    size_t hostlen, char *serv, size_t servlen, int flags) {
+       return NULL;
+    }
+    int main() {
+       (void)getnameinfo(NULL, 0, NULL, 0, NULL, 0, 0);
+       return 0;
+    }
+    
+EOF
+if { (eval echo configure:2818: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+  ac_cv_flavor_getnameinfo=rfc2133
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+fi
+rm -fr conftest*
+fi
+
+    if test "$ac_cv_func_getnameinfo" = no ; then
+       ac_cv_flavor_getnameinfo=none
+    fi
+fi
+
+echo "$ac_t""$ac_cv_flavor_getnameinfo" 1>&6
+
+    case "$ac_cv_flavor_getnameinfo" in
+    glibc2_2_2)
+       ac_cv_type_gni_salen_t='socklen_t'
+       ac_cv_type_gni_hostlen_t='socklen_t'
+       ac_cv_type_gni_servlen_t='socklen_t'
+       ac_cv_type_gni_flags_t='unsigned int'
+       ;;
+    rfc2553bis_03)
+       ac_cv_type_gni_salen_t='socklen_t'
+       ac_cv_type_gni_hostlen_t='socklen_t'
+       ac_cv_type_gni_servlen_t='socklen_t'
+       ac_cv_type_gni_flags_t='int'
+       ;;
+    rfc2553)
+       ac_cv_type_gni_salen_t='socklen_t'
+       ac_cv_type_gni_hostlen_t='size_t'
+       ac_cv_type_gni_servlen_t='size_t'
+       ac_cv_type_gni_flags_t='int'
+       ;;
+    rfc2133 | none)
+       ac_cv_type_gni_salen_t='size_t'
+       ac_cv_type_gni_hostlen_t='size_t'
+       ac_cv_type_gni_servlen_t='size_t'
+       ac_cv_type_gni_flags_t='int'
+       ;;
+    *)
+       { echo "configure: error: can't build runidn, since parameter type list of getnameinfo() is unknown to configure." 1>&2; exit 1; }
+    esac
+    cat >> confdefs.h <<EOF
+#define GNI_SALEN_T $ac_cv_type_gni_salen_t
+EOF
+
+    cat >> confdefs.h <<EOF
+#define GNI_HOSTLEN_T $ac_cv_type_gni_hostlen_t
+EOF
+
+    cat >> confdefs.h <<EOF
+#define GNI_SERVLEN_T $ac_cv_type_gni_servlen_t
+EOF
+
+    cat >> confdefs.h <<EOF
+#define GNI_FLAGS_T $ac_cv_type_gni_flags_t
+EOF
+
+fi
+
+if test "$find_gethost_r" = yes; then
+    echo $ac_n "checking flavor of gethostbyname_r""... $ac_c" 1>&6
+echo "configure:2883: checking flavor of gethostbyname_r" >&5
+if eval "test \"`echo '$''{'ac_cv_flavor_gethost_r'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  if test "$cross_compiling" = yes; then
+  ac_cv_flavor_gethost_r=sun
+else
+  cat > conftest.$ac_ext <<EOF
+#line 2891 "configure"
+#include "confdefs.h"
+
+#include <stddef.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netdb.h>
+#include <stdio.h>
+int main()
+{
+    int err = 0;
+    struct hostent hebuf, *hp;
+    char buf[10];
+    /* Try resolving a invalid name using glibc flavor. */
+    (void)gethostbyname_r("@#!", &hebuf, buf, sizeof(buf), &hp, &err);
+    if (err != 0)
+       return 0;       /* glibc flavor */
+    else
+       return 1;       /* Sun flavor */
+}
+
+EOF
+if { (eval echo configure:2913: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+       ac_cv_flavor_gethost_r=glibc
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -fr conftest*
+  ac_cv_flavor_gethost_r=sun
+fi
+rm -fr conftest*
+fi
+
+fi
+
+echo "$ac_t""$ac_cv_flavor_gethost_r" 1>&6
+    if test "$ac_cv_flavor_gethost_r" = "glibc"; then
+       cat >> confdefs.h <<\EOF
+#define GETHOST_R_GLIBC_FLAVOR 1
+EOF
+
+    fi
+fi
+
+
+echo $ac_n "checking for libc shared object""... $ac_c" 1>&6
+echo "configure:2938: checking for libc shared object" >&5
+shobj_name=libc
+shobj_path=
+case "$host" in
+*-hpux*)
+    SOEXT=sl
+    ;;
+*)
+    SOEXT=so
+    ;;
+esac
+for shobj_libdir in /lib /usr/lib; do
+    if test -f $shobj_libdir/$shobj_name.$SOEXT; then
+        shobj_path=$shobj_libdir/$shobj_name.$SOEXT
+    else
+        shobj_path=`ls -r $shobj_libdir/$shobj_name.$SOEXT* 2>/dev/null | head -1`
+       if test "$shobj_path" != "" -a -f "$shobj_path"; then
+           :
+       else
+           shobj_path=
+       fi
+    fi
+    if test "$shobj_path" != ""; then
+       echo "$ac_t""$shobj_path" 1>&6
+        shobj_pathsymbol=SOPATH_`echo $shobj_name | sed 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
+       cat >> confdefs.h <<EOF
+#define $shobj_pathsymbol "$shobj_path"
+EOF
+
+       break
+    fi
+done
+if test "$shobj_path" = ""; then
+    echo "$ac_t""no" 1>&6
+fi
+
+if test "$install_runidn" = yes ; then
+    
+echo $ac_n "checking for libnsl shared object""... $ac_c" 1>&6
+echo "configure:2977: checking for libnsl shared object" >&5
+shobj_name=libnsl
+shobj_path=
+case "$host" in
+*-hpux*)
+    SOEXT=sl
+    ;;
+*)
+    SOEXT=so
+    ;;
+esac
+for shobj_libdir in /lib /usr/lib; do
+    if test -f $shobj_libdir/$shobj_name.$SOEXT; then
+        shobj_path=$shobj_libdir/$shobj_name.$SOEXT
+    else
+        shobj_path=`ls -r $shobj_libdir/$shobj_name.$SOEXT* 2>/dev/null | head -1`
+       if test "$shobj_path" != "" -a -f "$shobj_path"; then
+           :
+       else
+           shobj_path=
+       fi
+    fi
+    if test "$shobj_path" != ""; then
+       echo "$ac_t""$shobj_path" 1>&6
+        shobj_pathsymbol=SOPATH_`echo $shobj_name | sed 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
+       cat >> confdefs.h <<EOF
+#define $shobj_pathsymbol "$shobj_path"
+EOF
+
+       break
+    fi
+done
+if test "$shobj_path" = ""; then
+    echo "$ac_t""no" 1>&6
+fi
+
+fi
+
+if test "$liteonly" != yes ; then
+    echo $ac_n "checking for iconv""... $ac_c" 1>&6
+echo "configure:3017: checking for iconv" >&5
+    saved_CPPFLAGS=$CPPFLAGS
+    saved_LIBS=$LIBS
+    CPPFLAGS="$CPPFLAGS $ICONVINC"
+    LIBS="$LIBS $ICONVLIB"
+    cat > conftest.$ac_ext <<EOF
+#line 3023 "configure"
+#include "confdefs.h"
+
+    #include <iconv.h>
+    
+int main() {
+
+       iconv_t i;
+       i = iconv_open("ISO-8859-1", "UTF-8");
+    
+; return 0; }
+EOF
+if { (eval echo configure:3035: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  rm -rf conftest*
+  iconv_try_link=yes
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  iconv_try_link=no
+fi
+rm -f conftest*
+    LIBS=$saved_LIBS
+    CPPFLAGS=$saved_CPPFLAGS
+    echo "$ac_t""$iconv_try_link" 1>&6
+    if test "$iconv_try_link" = no ; then
+       { echo "configure: error: iconv function not available" 1>&2; exit 1; }
+    fi
+fi
+
+if test "$liteonly" != yes ; then
+    echo $ac_n "checking for codeset name $UTF8_NAME""... $ac_c" 1>&6
+echo "configure:3055: checking for codeset name $UTF8_NAME" >&5
+    saved_CPPFLAGS=$CPPFLAGS
+    saved_LIBS=$LIBS
+    CPPFLAGS="$CPPFLAGS $ICONVINC"
+    LIBS="$LIBS $ICONVLIB"
+    if test "$cross_compiling" = yes; then
+  utf8_name_valid=unknown
+else
+  cat > conftest.$ac_ext <<EOF
+#line 3064 "configure"
+#include "confdefs.h"
+
+    #include <stddef.h>
+    #include <stdlib.h>
+    #include <iconv.h>
+    #define UTF8_NAME "$UTF8_NAME"
+    #define ICONV_FAIL ((iconv_t)(-1))
+    /* Check if the codeset name UTF8_NAME is valid by performing iconv_open(). */
+    int main() {
+       int i;
+       /* list of codeset names likely to exist */
+       static char *codeset[] = {
+           "ASCII", "ISO-8859-1", "ISO8859-1", "iso8859_1", "8859-1",
+           "Shift_JIS", "SJIS", "sjis", NULL,
+       };
+
+       /* First try null conversion. */
+       if (iconv_open(UTF8_NAME, UTF8_NAME) != ICONV_FAIL) return 0;
+
+       /* Unfortunately, above check fails on certain systems, such as Solaris. */
+       for (i = 0; codeset[i] != NULL; i++) {
+           if (iconv_open(UTF8_NAME, codeset[i]) != ICONV_FAIL) return 0;
+       }
+       return 1;
+    }
+    
+EOF
+if { (eval echo configure:3092: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+  utf8_name_valid=yes
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -fr conftest*
+  utf8_name_valid=no
+fi
+rm -fr conftest*
+fi
+
+    LIBS=$saved_LIBS
+    CPPFLAGS=$saved_CPPFLAGS
+    echo "$ac_t""$utf8_name_valid" 1>&6
+fi
+
+
+trap '' 1 2 15
+cat > confcache <<\EOF
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs.  It is not useful on other systems.
+# If it contains results you don't want to keep, you may remove or edit it.
+#
+# By default, configure uses ./config.cache as the cache file,
+# creating it if it does not exist already.  You can give configure
+# the --cache-file=FILE option to use a different cache file; that is
+# what configure does when it calls configure scripts in
+# subdirectories, so they share the cache.
+# Giving --cache-file=/dev/null disables caching, for debugging configure.
+# config.status only pays attention to the cache file if you give it the
+# --recheck option to rerun configure.
+#
+EOF
+# The following way of writing the cache mishandles newlines in values,
+# but we know of no workaround that is simple, portable, and efficient.
+# So, don't put newlines in cache variables' values.
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
+(set) 2>&1 |
+  case `(ac_space=' '; set | grep ac_space) 2>&1` in
+  *ac_space=\ *)
+    # `set' does not quote correctly, so add quotes (double-quote substitution
+    # turns \\\\ into \\, and sed turns \\ into \).
+    sed -n \
+      -e "s/'/'\\\\''/g" \
+      -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p"
+    ;;
+  *)
+    # `set' quotes correctly as required by POSIX, so do not add quotes.
+    sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p'
+    ;;
+  esac >> confcache
+if cmp -s $cache_file confcache; then
+  :
+else
+  if test -w $cache_file; then
+    echo "updating cache $cache_file"
+    cat confcache > $cache_file
+  else
+    echo "not updating unwritable cache $cache_file"
+  fi
+fi
+rm -f confcache
+
+trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
+
+test "x$prefix" = xNONE && prefix=$ac_default_prefix
+# Let make expand exec_prefix.
+test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+
+# Any assignment to VPATH causes Sun make to only execute
+# the first set of double-colon rules, so remove it if not needed.
+# If there is a colon in the path, we need to keep it.
+if test "x$srcdir" = x.; then
+  ac_vpsub='/^[        ]*VPATH[        ]*=[^:]*$/d'
+fi
+
+trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
+
+DEFS=-DHAVE_CONFIG_H
+
+# Without the "./", some shells look in PATH for config.status.
+: ${CONFIG_STATUS=./config.status}
+
+echo creating $CONFIG_STATUS
+rm -f $CONFIG_STATUS
+cat > $CONFIG_STATUS <<EOF
+#! /bin/sh
+# Generated automatically by configure.
+# Run this file to recreate the current configuration.
+# This directory was configured as follows,
+# on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+#
+# $0 $ac_configure_args
+#
+# Compiler output produced by configure, useful for debugging
+# configure, is in ./config.log if it exists.
+
+ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]"
+for ac_option
+do
+  case "\$ac_option" in
+  -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+    echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
+    exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
+  -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
+    echo "$CONFIG_STATUS generated by autoconf version 2.13"
+    exit 0 ;;
+  -help | --help | --hel | --he | --h)
+    echo "\$ac_cs_usage"; exit 0 ;;
+  *) echo "\$ac_cs_usage"; exit 1 ;;
+  esac
+done
+
+ac_given_srcdir=$srcdir
+ac_given_INSTALL="$INSTALL"
+
+trap 'rm -fr `echo "Makefile
+       include/Makefile
+       include/idn/Makefile
+       include/mdn/Makefile
+       lib/Makefile
+       man/Makefile
+       tools/Makefile
+       tools/idnconv/Makefile
+       tools/runidn/Makefile
+       tools/runidn/runidn
+       map/Makefile
+       lib/tests/Makefile
+ include/config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
+EOF
+cat >> $CONFIG_STATUS <<EOF
+
+# Protect against being on the right side of a sed subst in config.status.
+sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g;
+ s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
+$ac_vpsub
+$extrasub
+s%@SHELL@%$SHELL%g
+s%@CFLAGS@%$CFLAGS%g
+s%@CPPFLAGS@%$CPPFLAGS%g
+s%@CXXFLAGS@%$CXXFLAGS%g
+s%@FFLAGS@%$FFLAGS%g
+s%@DEFS@%$DEFS%g
+s%@LDFLAGS@%$LDFLAGS%g
+s%@LIBS@%$LIBS%g
+s%@exec_prefix@%$exec_prefix%g
+s%@prefix@%$prefix%g
+s%@program_transform_name@%$program_transform_name%g
+s%@bindir@%$bindir%g
+s%@sbindir@%$sbindir%g
+s%@libexecdir@%$libexecdir%g
+s%@datadir@%$datadir%g
+s%@sysconfdir@%$sysconfdir%g
+s%@sharedstatedir@%$sharedstatedir%g
+s%@localstatedir@%$localstatedir%g
+s%@libdir@%$libdir%g
+s%@includedir@%$includedir%g
+s%@oldincludedir@%$oldincludedir%g
+s%@infodir@%$infodir%g
+s%@mandir@%$mandir%g
+s%@host@%$host%g
+s%@host_alias@%$host_alias%g
+s%@host_cpu@%$host_cpu%g
+s%@host_vendor@%$host_vendor%g
+s%@host_os@%$host_os%g
+s%@COMPAT_TRUE@%$COMPAT_TRUE%g
+s%@COMPAT_FALSE@%$COMPAT_FALSE%g
+s%@UTF8_NAME@%$UTF8_NAME%g
+s%@LITEONLY_TRUE@%$LITEONLY_TRUE%g
+s%@LITEONLY_FALSE@%$LITEONLY_FALSE%g
+s%@RUNIDN_TRUE@%$RUNIDN_TRUE%g
+s%@RUNIDN_FALSE@%$RUNIDN_FALSE%g
+s%@ICONVINC@%$ICONVINC%g
+s%@ICONVLIB@%$ICONVLIB%g
+s%@ICONVSOFILE@%$ICONVSOFILE%g
+s%@PRELOAD_VAR@%$PRELOAD_VAR%g
+s%@PRELOAD_SEP@%$PRELOAD_SEP%g
+s%@PRELOAD_LAST@%$PRELOAD_LAST%g
+s%@CC@%$CC%g
+s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
+s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g
+s%@INSTALL_DATA@%$INSTALL_DATA%g
+s%@build@%$build%g
+s%@build_alias@%$build_alias%g
+s%@build_cpu@%$build_cpu%g
+s%@build_vendor@%$build_vendor%g
+s%@build_os@%$build_os%g
+s%@RANLIB@%$RANLIB%g
+s%@LN_S@%$LN_S%g
+s%@LIBTOOL@%$LIBTOOL%g
+s%@PERL@%$PERL%g
+s%@CPP@%$CPP%g
+s%@LIBDL@%$LIBDL%g
+
+CEOF
+EOF
+
+cat >> $CONFIG_STATUS <<\EOF
+
+# Split the substitutions into bite-sized pieces for seds with
+# small command number limits, like on Digital OSF/1 and HP-UX.
+ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script.
+ac_file=1 # Number of current file.
+ac_beg=1 # First line for current file.
+ac_end=$ac_max_sed_cmds # Line after last line for current file.
+ac_more_lines=:
+ac_sed_cmds=""
+while $ac_more_lines; do
+  if test $ac_beg -gt 1; then
+    sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file
+  else
+    sed "${ac_end}q" conftest.subs > conftest.s$ac_file
+  fi
+  if test ! -s conftest.s$ac_file; then
+    ac_more_lines=false
+    rm -f conftest.s$ac_file
+  else
+    if test -z "$ac_sed_cmds"; then
+      ac_sed_cmds="sed -f conftest.s$ac_file"
+    else
+      ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file"
+    fi
+    ac_file=`expr $ac_file + 1`
+    ac_beg=$ac_end
+    ac_end=`expr $ac_end + $ac_max_sed_cmds`
+  fi
+done
+if test -z "$ac_sed_cmds"; then
+  ac_sed_cmds=cat
+fi
+EOF
+
+cat >> $CONFIG_STATUS <<EOF
+
+CONFIG_FILES=\${CONFIG_FILES-"Makefile
+       include/Makefile
+       include/idn/Makefile
+       include/mdn/Makefile
+       lib/Makefile
+       man/Makefile
+       tools/Makefile
+       tools/idnconv/Makefile
+       tools/runidn/Makefile
+       tools/runidn/runidn
+       map/Makefile
+       lib/tests/Makefile
+"}
+EOF
+cat >> $CONFIG_STATUS <<\EOF
+for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
+  # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
+  case "$ac_file" in
+  *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
+       ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
+  *) ac_file_in="${ac_file}.in" ;;
+  esac
+
+  # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories.
+
+  # Remove last slash and all that follows it.  Not all systems have dirname.
+  ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
+  if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
+    # The file is in a subdirectory.
+    test ! -d "$ac_dir" && mkdir "$ac_dir"
+    ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`"
+    # A "../" for each directory in $ac_dir_suffix.
+    ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'`
+  else
+    ac_dir_suffix= ac_dots=
+  fi
+
+  case "$ac_given_srcdir" in
+  .)  srcdir=.
+      if test -z "$ac_dots"; then top_srcdir=.
+      else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;;
+  /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;;
+  *) # Relative path.
+    srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix"
+    top_srcdir="$ac_dots$ac_given_srcdir" ;;
+  esac
+
+  case "$ac_given_INSTALL" in
+  [/$]*) INSTALL="$ac_given_INSTALL" ;;
+  *) INSTALL="$ac_dots$ac_given_INSTALL" ;;
+  esac
+
+  echo creating "$ac_file"
+  rm -f "$ac_file"
+  configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure."
+  case "$ac_file" in
+  *Makefile*) ac_comsub="1i\\
+# $configure_input" ;;
+  *) ac_comsub= ;;
+  esac
+
+  ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
+  sed -e "$ac_comsub
+s%@configure_input@%$configure_input%g
+s%@srcdir@%$srcdir%g
+s%@top_srcdir@%$top_srcdir%g
+s%@INSTALL@%$INSTALL%g
+" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file
+fi; done
+rm -f conftest.s*
+
+# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
+# NAME is the cpp macro being defined and VALUE is the value it is being given.
+#
+# ac_d sets the value in "#define NAME VALUE" lines.
+ac_dA='s%^\([  ]*\)#\([        ]*define[       ][      ]*\)'
+ac_dB='\([     ][      ]*\)[^  ]*%\1#\2'
+ac_dC='\3'
+ac_dD='%g'
+# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE".
+ac_uA='s%^\([  ]*\)#\([        ]*\)undef\([    ][      ]*\)'
+ac_uB='\([     ]\)%\1#\2define\3'
+ac_uC=' '
+ac_uD='\4%g'
+# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
+ac_eA='s%^\([  ]*\)#\([        ]*\)undef\([    ][      ]*\)'
+ac_eB='$%\1#\2define\3'
+ac_eC=' '
+ac_eD='%g'
+
+if test "${CONFIG_HEADERS+set}" != set; then
+EOF
+cat >> $CONFIG_STATUS <<EOF
+  CONFIG_HEADERS="include/config.h"
+EOF
+cat >> $CONFIG_STATUS <<\EOF
+fi
+for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then
+  # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
+  case "$ac_file" in
+  *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
+       ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
+  *) ac_file_in="${ac_file}.in" ;;
+  esac
+
+  echo creating $ac_file
+
+  rm -f conftest.frag conftest.in conftest.out
+  ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
+  cat $ac_file_inputs > conftest.in
+
+EOF
+
+# Transform confdefs.h into a sed script conftest.vals that substitutes
+# the proper values into config.h.in to produce config.h.  And first:
+# Protect against being on the right side of a sed subst in config.status.
+# Protect against being in an unquoted here document in config.status.
+rm -f conftest.vals
+cat > conftest.hdr <<\EOF
+s/[\\&%]/\\&/g
+s%[\\$`]%\\&%g
+s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp
+s%ac_d%ac_u%gp
+s%ac_u%ac_e%gp
+EOF
+sed -n -f conftest.hdr confdefs.h > conftest.vals
+rm -f conftest.hdr
+
+# This sed command replaces #undef with comments.  This is necessary, for
+# example, in the case of _POSIX_SOURCE, which is predefined and required
+# on some systems where configure will not decide to define it.
+cat >> conftest.vals <<\EOF
+s%^[   ]*#[    ]*undef[        ][      ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */%
+EOF
+
+# Break up conftest.vals because some shells have a limit on
+# the size of here documents, and old seds have small limits too.
+
+rm -f conftest.tail
+while :
+do
+  ac_lines=`grep -c . conftest.vals`
+  # grep -c gives empty output for an empty file on some AIX systems.
+  if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi
+  # Write a limited-size here document to conftest.frag.
+  echo '  cat > conftest.frag <<CEOF' >> $CONFIG_STATUS
+  sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS
+  echo 'CEOF
+  sed -f conftest.frag conftest.in > conftest.out
+  rm -f conftest.in
+  mv conftest.out conftest.in
+' >> $CONFIG_STATUS
+  sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail
+  rm -f conftest.vals
+  mv conftest.tail conftest.vals
+done
+rm -f conftest.vals
+
+cat >> $CONFIG_STATUS <<\EOF
+  rm -f conftest.frag conftest.h
+  echo "/* $ac_file.  Generated automatically by configure.  */" > conftest.h
+  cat conftest.in >> conftest.h
+  rm -f conftest.in
+  if cmp -s $ac_file conftest.h 2>/dev/null; then
+    echo "$ac_file is unchanged"
+    rm -f conftest.h
+  else
+    # Remove last slash and all that follows it.  Not all systems have dirname.
+      ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
+      if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
+      # The file is in a subdirectory.
+      test ! -d "$ac_dir" && mkdir "$ac_dir"
+    fi
+    rm -f $ac_file
+    mv conftest.h $ac_file
+  fi
+fi; done
+
+EOF
+cat >> $CONFIG_STATUS <<EOF
+
+EOF
+cat >> $CONFIG_STATUS <<\EOF
+
+exit 0
+EOF
+chmod +x $CONFIG_STATUS
+rm -fr confdefs* $ac_clean_files
+test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1
+
diff --git a/contrib/idn/idnkit-1.0-src/configure.in b/contrib/idn/idnkit-1.0-src/configure.in
new file mode 100644 (file)
index 0000000..5d46c70
--- /dev/null
@@ -0,0 +1,711 @@
+dnl $Id: configure.in,v 1.1 2003/06/04 00:25:25 marka Exp $
+dnl Process this file with autoconf to produce a configure script.
+dnl
+dnl Copyright (c) 2000 Japan Network Information Center.  All rights reserved.
+dnl  
+dnl By using this file, you agree to the terms and conditions set forth bellow.
+dnl 
+dnl                    LICENSE TERMS AND CONDITIONS 
+dnl 
+dnl The following License Terms and Conditions apply, unless a different
+dnl license is obtained from Japan Network Information Center ("JPNIC"),
+dnl a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
+dnl Chiyoda-ku, Tokyo 101-0047, Japan.
+dnl 
+dnl 1. Use, Modification and Redistribution (including distribution of any
+dnl    modified or derived work) in source and/or binary forms is permitted
+dnl    under this License Terms and Conditions.
+dnl 
+dnl 2. Redistribution of source code must retain the copyright notices as they
+dnl    appear in each source code file, this License Terms and Conditions.
+dnl 
+dnl 3. Redistribution in binary form must reproduce the Copyright Notice,
+dnl    this License Terms and Conditions, in the documentation and/or other
+dnl    materials provided with the distribution.  For the purposes of binary
+dnl    distribution the "Copyright Notice" refers to the following language:
+dnl    "Copyright (c) 2000-2002 Japan Network Information Center.  All rights reserved."
+dnl 
+dnl 4. The name of JPNIC may not be used to endorse or promote products
+dnl    derived from this Software without specific prior written approval of
+dnl    JPNIC.
+dnl 
+dnl 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
+dnl    "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+dnl    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+dnl    PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL JPNIC BE LIABLE
+dnl    FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+dnl    CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+dnl    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+dnl    BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+dnl    WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+dnl    OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+dnl    ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+AC_INIT(include/idn/converter.h)
+
+AC_CANONICAL_HOST
+
+debug=no
+AC_ARG_ENABLE(debug,
+[  --enable-debug          enable debug codes [default=no]],
+       debug=$enableval)
+case "$debug" in
+yes)
+    CFLAGS="$CFLAGS -DDEBUG"
+    ;;
+esac
+
+mdnkit_compat=no
+COMPAT_TRUE="#"
+COMPAT_FALSE=
+AC_ARG_ENABLE(mdnkit-compat,
+[  --enable-mdnkit-compat  enable mDNkit compatibility mode [default=no]],
+       mdnkit_compat=$enableval)
+case "$mdnkit_compat" in
+yes)
+    COMPAT_TRUE=
+    COMPAT_FALSE="#"
+    AC_DEFINE(ENABLE_MDNKIT_COMPAT, 1,
+       [Define if --enable-mdnkit-compat is specified])
+    ;;
+no)
+    ;;
+*)
+    AC_MSG_ERROR([You must specify yes or no to --enable-runidn option.])
+    ;;
+esac
+AC_SUBST(COMPAT_TRUE)
+AC_SUBST(COMPAT_FALSE)
+
+extraace=no
+AC_ARG_ENABLE(extra-ace,
+[  --enable-extra-ace      enable additional ACE converters. [default=no]],
+       extraace=$enableval)
+case "$extraace" in
+no)
+    ;;
+yes)
+    AC_DEFINE(IDN_EXTRA_ACE, 1,
+       [Define if you want additional ACE converters compiled in.])
+    ;;
+*)
+    AC_MSG_ERROR([You must specify yes or no to --enable-extra-ace option.])
+    ;;
+esac
+
+UTF8_NAME=no
+AC_ARG_WITH(utf8,
+[  --with-utf8=NAME        codeset name for UTF-8 encoding [UTF-8]],
+       UTF8_NAME=$withval)
+case "$UTF8_NAME" in
+no)
+    UTF8_NAME=UTF-8
+    ;;
+yes)
+    AC_MSG_ERROR([You must specify NAME to --with-utf8 option.])
+    ;;
+*)
+    AC_DEFINE_UNQUOTED(IDN_UTF8_ENCODING_NAME, "$UTF8_NAME",
+       [Define if your iconv() does not accept "UTF-8" as the codeset name for utf-8.])
+    ;;
+esac
+AC_SUBST(UTF8_NAME)
+
+liteonly=no
+LITEONLY_TRUE="#"
+LITEONLY_FALSE=
+AC_ARG_ENABLE(liteonly,
+[  --enable-liteonly       compile and install lite library only [default=no]],
+       liteonly=$enableval)
+case "$liteonly" in
+no)
+    ;;
+yes)
+    if test "$install_runidn" = yes ; then
+       AC_MSG_ERROR([you can't set value \"yes\" to --enable-runidn and --enable-liteonly simultaneously, because runidn requires iconv support of generic libidnkit.])
+    fi
+    LITEONLY_TRUE=
+    LITEONLY_FALSE="#"
+    ;;
+*)
+    AC_MSG_ERROR([You must specify yes or no to --enable-liteonly option.])
+    ;;
+esac
+AC_SUBST(LITEONLY_TRUE)
+AC_SUBST(LITEONLY_FALSE)
+
+install_runidn=no
+RUNIDN_TRUE="#"
+RUNIDN_FALSE=
+AC_ARG_ENABLE(runidn,
+[  --enable-runidn         compile and install runidn [default=no]],
+       install_runidn=$enableval)
+case "$install_runidn" in
+no)
+    ;;
+yes)
+    if test "$liteonly" = yes ; then
+       AC_MSG_ERROR([you can't set value \"yes\" to --enable-runidn and --enable-liteonly simultaneously, because runidn requires iconv support of generic libidnkit.])
+    fi
+    RUNIDN_TRUE=
+    RUNIDN_FALSE="#"
+    ;;
+*)
+    AC_MSG_ERROR([You must specify yes or no to --enable-runidn option.])
+    ;;
+esac
+AC_SUBST(RUNIDN_TRUE)
+AC_SUBST(RUNIDN_FALSE)
+
+ICONVINC=
+ICONVLIB=
+
+libiconv=unspec
+AC_ARG_WITH(libiconv,
+[  --with-libiconv=IPREFIX  GNU libiconv are installed in IPREFIX [PREFIX]],
+       libiconv=$withval)
+case "$libiconv" in
+unspec)
+    ;;
+no)
+    ICONVINC=
+    ICONVLIB=
+    ;;
+yes)
+    if test "$liteonly" = yes ; then
+       AC_MSG_ERROR([you can't set iconv options at all when you set value \"yes\" to --enable-liteonly, because lite library does not have iconv support.])
+    fi
+    if test X$prefix = XNONE ; then
+       libiconv=$ac_default_prefix
+    else
+       libiconv=$prefix
+    fi
+    ICONVINC="-I$libiconv/include"
+    ICONVLIB="-L$libiconv/lib -R$libiconv/lib -liconv"
+    ;;
+*)
+    if test "$liteonly" = yes ; then
+       AC_MSG_ERROR([you can't set iconv options at all when you set value \"yes\" to --enable-liteonly, because lite library does not have iconv support.])
+    fi
+    ICONVINC="-I$libiconv/include"
+    ICONVLIB="-L$libiconv/lib -R$libiconv/lib -liconv"
+    ;;
+esac
+
+iconv_include=unspec
+AC_ARG_WITH(iconv-include,
+[  --with-iconv-include=DIR  iconv include files are in DIR []],
+       iconv_include=$withval)
+case "$iconv_include" in
+unspec)
+    ;;
+no)
+    ICONVINC=
+    ;;
+yes)
+    if test "$liteonly" = yes ; then
+       AC_MSG_ERROR([you can't set iconv options at all when you set value \"yes\" to --enable-liteonly, because lite library does not have iconv support.])
+    fi
+    AC_MSG_WARN([You must supply DIR to --with-iconv-include option.
+  Ignored.])
+    ICONVINC=
+    ;;
+*)
+    if test "$liteonly" = yes ; then
+       AC_MSG_ERROR([you can't set iconv options at all when you set value \"yes\" to --enable-liteonly, because lite library does not have iconv support.])
+    fi
+    ICONVINC="-I$iconv_include"
+    ;;
+esac
+
+if test "X$ICONVINC" != X ; then
+    iconv_include="`echo X$ICONVINC | sed -e 's/^X-I//'`"
+    if test ! -f "$iconv_include/iconv.h" ; then
+       AC_MSG_ERROR([iconv.h doesn't exist in $iconv_include])
+    fi
+fi
+
+AC_SUBST(ICONVINC)
+
+iconv=unspec
+AC_ARG_WITH(iconv,
+[  --with-iconv=LIB        special library for iconv []],
+       iconv=$withval)
+case "$iconv" in
+unspec)
+    ;;
+no)
+    ICONVLIB=
+    ;;
+yes)
+    if test "$liteonly" = yes ; then
+       AC_MSG_ERROR([you can't set iconv options at all when you set value \"yes\" to --enable-liteonly, because lite library does not have iconv support.])
+    fi
+    AC_MSG_WARN([You must supply LIB to --with-iconv option.
+  -liconv is assumed.])
+    ICONVLIB=-liconv
+    ;;
+*)
+    if test "$liteonly" = yes ; then
+       AC_MSG_ERROR([you can't set iconv options at all when you set value \"yes\" to --enable-liteonly, because lite library does not have iconv support.])
+    fi
+    ICONVLIB=$iconv
+    ;;
+esac
+AC_SUBST(ICONVLIB)
+
+AC_ARG_WITH(iconv-sofile,
+[  --with-iconv-sofile=PATH  shared library file for libiconv []],
+       iconv_file=$withval, iconv_file=guess)
+ICONVSOFILE=
+case "$iconv_file" in
+no)
+    ICONVSOFILE=none
+    ;;
+yes)
+    if test "$liteonly" = yes ; then
+       AC_MSG_ERROR([you can't set iconv options at all when you set value \"yes\" to --enable-liteonly, because lite library does not have iconv support.])
+    fi
+    AC_MSG_ERROR([You must supply PATH to --with-iconv-sofile option.])
+    ;;
+guess)
+    if test "$liteonly" != yes ; then
+       if test "$ICONVLIB" = ""; then
+           ICONVSOFILE=none
+       else
+           AC_MSG_CHECKING(pathname of iconv shared library)
+           ic_libdir=
+           ic_libname=
+           case "$host" in
+           *-hpux*)
+               SO=sl
+               ;;
+           *)
+               SO=so
+               ;;
+           esac
+           for arg in $ICONVLIB; do
+               case "$arg" in
+               -L*) ic_libdir="$ic_libdir `echo $arg | sed s/-L//`" ;;
+               -l*) ic_libname=`echo $arg | sed s/-l//` ;;
+               /*.$SO*) ICONVSOFILE=$arg ;;
+               esac
+           done
+           if test "$ICONVSOFILE" = ""; then
+               if test "$ic_libname" = ""; then
+                   AC_MSG_RESULT(unknown)
+                   AC_MSG_WARN([use --with-iconv-sofile for specifying iconv shared library file])
+                   ICONVSOFILE=none
+               else
+                   if test "$ic_libdir" = ""; then
+                       # Standard (and semi-standard) library directories
+                       ic_libdir="/lib /usr/lib /usr/local/lib"
+                   fi
+                   for dir in $ic_libdir; do
+                       ICONVSOFILE=`ls -r $dir/lib$ic_libname.$SO* 2>/dev/null | head -1`
+                       if test "$ICONVSOFILE" != ""; then
+                           break
+                       fi
+                   done
+                   if test "$ICONVSOFILE" != ""; then
+                       AC_MSG_RESULT($ICONVSOFILE)
+                   else
+                       AC_MSG_RESULT(unknown)
+                       AC_MSG_WARN([use --with-iconv-sofile for specifying iconv shared library file])
+                       ICONVSOFILE=none
+                   fi
+               fi
+           fi
+       fi
+    else
+       ICONVSOFILE=none
+    fi
+    ;;
+*)
+    if test "$liteonly" = yes ; then
+       AC_MSG_ERROR([you can't set iconv options at all when you set value \"yes\" to --enable-liteonly, because lite library does not have iconv support.])
+    fi
+    ICONVSOFILE=$iconv_file
+    ;;
+esac
+AC_SUBST(ICONVSOFILE)
+
+dnl Figure out preload stuff.
+PRELOAD_VAR="LD_PRELOAD"
+PRELOAD_SEP=":"
+PRELOAD_LAST=""
+case "$host" in
+*-solaris*)
+    PRELOAD_SEP=" "
+    ;;
+*-linux*)
+    PRELOAD_SEP=" "
+    ;;
+*-osf*)
+    PRELOAD_VAR="_RLD_LIST"
+    PRELOAD_LAST=":DEFAULT"
+    ;;
+*-netbsd*)
+    if test -x /usr/bin/file -a -x /usr/bin/grep ; then
+        case "`/usr/bin/file /usr/bin/grep`" in
+       *ELF*)
+           PRELOAD_SEP=" "
+           ;;
+       esac
+    fi
+    ;;
+esac
+
+AC_SUBST(PRELOAD_VAR)
+AC_SUBST(PRELOAD_SEP)
+AC_SUBST(PRELOAD_LAST)
+
+dnl Checks for standard tools.
+AC_PROG_CC
+AC_PROG_INSTALL
+AM_PROG_LIBTOOL
+
+AC_PATH_PROGS(PERL, perl, perl)
+
+dnl Checks for header files.
+AC_CHECK_HEADERS(unistd.h locale.h langinfo.h pwd.h)
+if test "$install_runidn" = yes ; then
+    AC_CHECK_HEADERS(dlfcn.h)
+fi
+
+saved_CPPFLAGS=$CPPFLAGS
+CPPFLAGS="$CPPFLAGS $ICONVINC"
+if test "$liteonly" != yes ; then
+    AC_CHECK_HEADER(iconv.h, , [AC_MSG_ERROR([iconv.h doesn't exist])])
+fi
+CPPFLAGS=$saved_CPPFLAGS
+
+dnl Checks for data types.
+AC_TYPE_UID_T
+dnl for dnsproxy.
+AC_CHECK_TYPE(BOOL, int)
+
+dnl Checks for libraries.
+if test "$install_runidn" = yes ; then
+    AC_CHECK_LIB(socket, socket)
+    AC_CHECK_LIB(nsl, inet_addr)
+    AC_CHECK_LIB(dl, dlopen, [
+       LIBS="-ldl $LIBS"
+       LIBDL="-ldl"
+       AC_DEFINE(HAVE_LIBDL, 1, [Define if you have the dl library (-ldl).])
+       AC_SUBST(LIBDL)
+    ])
+fi
+
+dnl Checks for library functions.
+AC_CHECK_FUNCS(vsnprintf setvbuf setlocale nl_langinfo memmove bcopy setenv \
+    unsetenv)
+if test "$install_runidn" = yes ; then
+    AC_CHECK_FUNCS(gethostbyname gethostbyname2 gethostbyaddr)
+    AC_CHECK_FUNCS(gethostbyname_r gethostbyname2_r gethostbyaddr_r, find_gethost_r=yes)
+    AC_CHECK_FUNCS(getipnodebyname getipnodebyaddr freehostent)
+    AC_CHECK_FUNCS(getaddrinfo freeaddrinfo getnameinfo)
+    AC_CHECK_FUNCS(dlopen dlsym)
+fi
+
+if test "$install_runidn" = yes ; then
+dnl Checks the flavor of gethostbyaddr* functions.
+    AC_CACHE_CHECK(flavor of gethostbyaddr, ac_cv_flavor_gethostbyaddr,
+    [ac_cv_flavor_gethostbyaddr=unknown
+    AC_TRY_RUN(
+    [
+    #include <stddef.h>
+    #include <sys/types.h>
+    #include <sys/socket.h>
+    #include <netdb.h>
+    struct hostent *gethostbyaddr(const void *addr, socklen_t len, int type) {
+       return NULL;
+    }
+    int main() {
+       (void)gethostbyaddr(NULL, 0, 0);
+       return 0;
+    }
+    ], ac_cv_flavor_gethostbyaddr=glibc2_2,,
+       ac_cv_flavor_gethostbyaddr=unknown)
+    AC_TRY_RUN(
+    [
+    #include <stddef.h>
+    #include <sys/types.h>
+    #include <sys/socket.h>
+    #include <netdb.h>
+    struct hostent *gethostbyaddr(const char *addr, size_t len, int type) {
+       return NULL;
+    }
+    int main() {
+       (void)gethostbyaddr(NULL, 0, 0);
+       return 0;
+    }
+    ], ac_cv_flavor_gethostbyaddr=glibc,,
+       ac_cv_flavor_gethostbyaddr=unknown)
+    AC_TRY_RUN(
+    [
+    #include <stddef.h>
+    #include <sys/types.h>
+    #include <sys/socket.h>
+    #include <netdb.h>
+    struct hostent *gethostbyaddr(const char *addr, int len, int type) {
+       return NULL;
+    }
+    int main() {
+       (void)gethostbyaddr(NULL, 0, 0);
+       return 0;
+    }
+    ], ac_cv_flavor_gethostbyaddr=traditional,,
+       ac_cv_flavor_gethostbyaddr=unknown)
+    if test "$ac_cv_func_gethostbyaddr" = no ; then
+       ac_cv_flavor_gethostbyaddr=none
+    fi])
+
+    case "$ac_cv_flavor_gethostbyaddr" in
+    glibc2_2)
+       ac_cv_type_ghba_addr_t='const void *'
+       ac_cv_type_ghba_addrlen_t='socklen_t'
+       ;;
+    glibc)
+       ac_cv_type_ghba_addr_t='const char *'
+       ac_cv_type_ghba_addrlen_t='size_t'
+       ;;
+    traditional | none)
+       ac_cv_type_ghba_addr_t='const char *'
+       ac_cv_type_ghba_addrlen_t='int'
+       ;;
+    *)
+       AC_MSG_ERROR([can't build runidn, since parameter type list of gethostbyaddr() is unknown to configure.])
+       ;;
+    esac
+    AC_DEFINE_UNQUOTED(GHBA_ADDR_T, $ac_cv_type_ghba_addr_t,
+       [Define as the type of the 1st argument of gethostbyaddr.])
+    AC_DEFINE_UNQUOTED(GHBA_ADDRLEN_T, $ac_cv_type_ghba_addrlen_t,
+       [Define as the type of the 2nd argument of gethostbyaddr.])
+
+dnl Checks the flavor of getnameinfo functions.
+    AC_CACHE_CHECK(flavor of getnameinfo, ac_cv_flavor_getnameinfo,
+    [ac_cv_flavor_getnameinfo=unknown
+    AC_TRY_RUN(
+    [
+    #include <stddef.h>
+    #include <sys/types.h>
+    #include <sys/socket.h>
+    #include <netdb.h>
+    int getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host,
+                    socklen_t hostlen, char *serv, socklen_t servlen,
+                    unsigned int flags) {
+       return NULL;
+    }
+    int main() {
+       (void)getnameinfo(NULL, 0, NULL, 0, NULL, 0, 0);
+       return 0;
+    }
+    ], ac_cv_flavor_getnameinfo=glibc2_2_2,,
+       ac_cv_flavor_getnameinfo=unknown)
+    AC_TRY_RUN(
+    [
+    #include <stddef.h>
+    #include <sys/types.h>
+    #include <sys/socket.h>
+    #include <netdb.h>
+    int getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host,
+                    socklen_t hostlen, char *serv, socklen_t servlen,
+                    int flags) {
+       return NULL;
+    }
+    int main() {
+       (void)getnameinfo(NULL, 0, NULL, 0, NULL, 0, 0);
+       return 0;
+    }
+    ], ac_cv_flavor_getnameinfo=rfc2553bis_03,,
+       ac_cv_flavor_getnameinfo=unknown)
+    AC_TRY_RUN(
+    [
+    #include <stddef.h>
+    #include <sys/types.h>
+    #include <sys/socket.h>
+    #include <netdb.h>
+    int getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host,
+                    size_t hostlen, char *serv, size_t servlen, int flags) {
+       return NULL;
+    }
+    int main() {
+       (void)getnameinfo(NULL, 0, NULL, 0, NULL, 0, 0);
+       return 0;
+    }
+    ], ac_cv_flavor_getnameinfo=rfc2553,,
+       ac_cv_flavor_getnameinfo=unknown)
+    AC_TRY_RUN(
+    [
+    #include <stddef.h>
+    #include <sys/types.h>
+    #include <sys/socket.h>
+    #include <netdb.h>
+    int getnameinfo(const struct sockaddr *sa, size_t salen, char *host,
+                    size_t hostlen, char *serv, size_t servlen, int flags) {
+       return NULL;
+    }
+    int main() {
+       (void)getnameinfo(NULL, 0, NULL, 0, NULL, 0, 0);
+       return 0;
+    }
+    ], ac_cv_flavor_getnameinfo=rfc2133,,
+       ac_cv_flavor_getnameinfo=unknown)
+    if test "$ac_cv_func_getnameinfo" = no ; then
+       ac_cv_flavor_getnameinfo=none
+    fi])
+
+    case "$ac_cv_flavor_getnameinfo" in
+    glibc2_2_2)
+       ac_cv_type_gni_salen_t='socklen_t'
+       ac_cv_type_gni_hostlen_t='socklen_t'
+       ac_cv_type_gni_servlen_t='socklen_t'
+       ac_cv_type_gni_flags_t='unsigned int'
+       ;;
+    rfc2553bis_03)
+       ac_cv_type_gni_salen_t='socklen_t'
+       ac_cv_type_gni_hostlen_t='socklen_t'
+       ac_cv_type_gni_servlen_t='socklen_t'
+       ac_cv_type_gni_flags_t='int'
+       ;;
+    rfc2553)
+       ac_cv_type_gni_salen_t='socklen_t'
+       ac_cv_type_gni_hostlen_t='size_t'
+       ac_cv_type_gni_servlen_t='size_t'
+       ac_cv_type_gni_flags_t='int'
+       ;;
+    rfc2133 | none)
+       ac_cv_type_gni_salen_t='size_t'
+       ac_cv_type_gni_hostlen_t='size_t'
+       ac_cv_type_gni_servlen_t='size_t'
+       ac_cv_type_gni_flags_t='int'
+       ;;
+    *)
+       AC_MSG_ERROR([can't build runidn, since parameter type list of getnameinfo() is unknown to configure.])
+    esac
+    AC_DEFINE_UNQUOTED(GNI_SALEN_T, $ac_cv_type_gni_salen_t,
+       [Define as the type of the 2nd argument of getnameinfo.])
+    AC_DEFINE_UNQUOTED(GNI_HOSTLEN_T, $ac_cv_type_gni_hostlen_t,
+       [Define as the type of the 4th argument of getnameinfo.])
+    AC_DEFINE_UNQUOTED(GNI_SERVLEN_T, $ac_cv_type_gni_servlen_t,
+       [Define as the type of the 6th argument of getnameinfo.])
+    AC_DEFINE_UNQUOTED(GNI_FLAGS_T, $ac_cv_type_gni_flags_t,
+       [Define as the type of the 7th argument of getnameinfo.])
+fi
+
+dnl resume here.
+dnl Checks the flavor of gethost*_r functions.
+if test "$find_gethost_r" = yes; then
+    AC_CACHE_CHECK(flavor of gethostbyname_r, ac_cv_flavor_gethost_r,
+    [AC_TRY_RUN(
+changequote(<<, >>)dnl
+<<
+#include <stddef.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netdb.h>
+#include <stdio.h>
+int main()
+{
+    int err = 0;
+    struct hostent hebuf, *hp;
+    char buf[10];
+    /* Try resolving a invalid name using glibc flavor. */
+    (void)gethostbyname_r("@#!", &hebuf, buf, sizeof(buf), &hp, &err);
+    if (err != 0)
+       return 0;       /* glibc flavor */
+    else
+       return 1;       /* Sun flavor */
+}
+>>,
+changequote([, ])dnl
+       ac_cv_flavor_gethost_r=glibc,
+       ac_cv_flavor_gethost_r=sun,
+       ac_cv_flavor_gethost_r=sun)])
+    if test "$ac_cv_flavor_gethost_r" = "glibc"; then
+       AC_DEFINE(GETHOST_R_GLIBC_FLAVOR, 1,
+           [Define if the prototype of gethost*_r is glibc flavor.])
+    fi
+fi
+
+dnl Find system shared object paths.
+AC_FIND_SYSTEM_SHOBJ(libc)
+if test "$install_runidn" = yes ; then
+    AC_FIND_SYSTEM_SHOBJ(libnsl)
+fi
+
+dnl Checks for iconv library.
+if test "$liteonly" != yes ; then
+    AC_MSG_CHECKING(for iconv)
+    saved_CPPFLAGS=$CPPFLAGS
+    saved_LIBS=$LIBS
+    CPPFLAGS="$CPPFLAGS $ICONVINC"
+    LIBS="$LIBS $ICONVLIB"
+    AC_TRY_LINK([
+    #include <iconv.h>
+    ], [
+       iconv_t i;
+       i = iconv_open("ISO-8859-1", "UTF-8");
+    ], [iconv_try_link=yes], [iconv_try_link=no])
+    LIBS=$saved_LIBS
+    CPPFLAGS=$saved_CPPFLAGS
+    AC_MSG_RESULT($iconv_try_link)
+    if test "$iconv_try_link" = no ; then
+       AC_MSG_ERROR(iconv function not available)
+    fi
+fi
+
+dnl Check for codeset name for UTF-8.
+if test "$liteonly" != yes ; then
+    AC_MSG_CHECKING([for codeset name $UTF8_NAME])
+    saved_CPPFLAGS=$CPPFLAGS
+    saved_LIBS=$LIBS
+    CPPFLAGS="$CPPFLAGS $ICONVINC"
+    LIBS="$LIBS $ICONVLIB"
+    AC_TRY_RUN([
+    #include <stddef.h>
+    #include <stdlib.h>
+    #include <iconv.h>
+    #define UTF8_NAME "$UTF8_NAME"
+    #define ICONV_FAIL ((iconv_t)(-1))
+    /* Check if the codeset name UTF8_NAME is valid by performing iconv_open(). */
+    int main() {
+       int i;
+       /* list of codeset names likely to exist */
+       static char *codeset[] = {
+           "ASCII", "ISO-8859-1", "ISO8859-1", "iso8859_1", "8859-1",
+           "Shift_JIS", "SJIS", "sjis", NULL,
+       };
+
+       /* First try null conversion. */
+       if (iconv_open(UTF8_NAME, UTF8_NAME) != ICONV_FAIL) return 0;
+
+       /* Unfortunately, above check fails on certain systems, such as Solaris. */
+       for (i = 0; codeset[i] != NULL; i++) {
+           if (iconv_open(UTF8_NAME, codeset[i]) != ICONV_FAIL) return 0;
+       }
+       return 1;
+    }
+    ], utf8_name_valid=yes, utf8_name_valid=no, utf8_name_valid=unknown)
+    LIBS=$saved_LIBS
+    CPPFLAGS=$saved_CPPFLAGS
+    AC_MSG_RESULT($utf8_name_valid)
+fi
+
+dnl Output.
+AC_CONFIG_HEADER(include/config.h)
+AC_OUTPUT(
+       Makefile
+       include/Makefile
+       include/idn/Makefile
+       include/mdn/Makefile
+       lib/Makefile
+       man/Makefile
+       tools/Makefile
+       tools/idnconv/Makefile
+       tools/runidn/Makefile
+       tools/runidn/runidn
+       map/Makefile
+       lib/tests/Makefile
+)
diff --git a/contrib/idn/idnkit-1.0-src/include/Makefile.in b/contrib/idn/idnkit-1.0-src/include/Makefile.in
new file mode 100644 (file)
index 0000000..8e76d39
--- /dev/null
@@ -0,0 +1,65 @@
+# $Id: Makefile.in,v 1.1 2003/06/04 00:25:33 marka Exp $
+# 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.
+
+srcdir = @srcdir@
+VPATH = @srcdir@
+
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+
+SHELL = @SHELL@
+
+SUBDIRS = idn mdn
+
+all: all-subdirs
+install: install-subdirs
+clean: clean-subdirs
+distclean: distclean-localdir distclean-subdirs
+check test: test-subdirs
+
+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
+
+distclean-localdir:
+       rm -f config.h Makefile
diff --git a/contrib/idn/idnkit-1.0-src/include/config.h.in b/contrib/idn/idnkit-1.0-src/include/config.h.in
new file mode 100644 (file)
index 0000000..ea4ae74
--- /dev/null
@@ -0,0 +1,181 @@
+/* include/config.h.in.  Generated automatically from configure.in by autoheader.  */
+/* $Id: config.h.in,v 1.1 2003/06/04 00:25:34 marka Exp $ */
+/*
+ * 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.
+ */
+
+/* Define to `int' if <sys/types.h> doesn't define.  */
+#undef gid_t
+
+/* Define if you have the ANSI C header files.  */
+#undef STDC_HEADERS
+
+/* Define to `int' if <sys/types.h> doesn't define.  */
+#undef uid_t
+
+/* Define as an appropriate type (ex. int) if your system doesn't have. */
+#undef BOOL
+
+/* Define if you have the bcopy function.  */
+#undef HAVE_BCOPY
+
+/* Define if you have the dlopen function.  */
+#undef HAVE_DLOPEN
+
+/* Define if you have the dlsym function.  */
+#undef HAVE_DLSYM
+
+/* Define if you have the freeaddrinfo function.  */
+#undef HAVE_FREEADDRINFO
+
+/* Define if you have the freehostent function.  */
+#undef HAVE_FREEHOSTENT
+
+/* Define if you have the getaddrinfo function.  */
+#undef HAVE_GETADDRINFO
+
+/* Define if you have the gethostbyaddr function.  */
+#undef HAVE_GETHOSTBYADDR
+
+/* Define if you have the gethostbyaddr_r function.  */
+#undef HAVE_GETHOSTBYADDR_R
+
+/* Define if you have the gethostbyname function.  */
+#undef HAVE_GETHOSTBYNAME
+
+/* Define if you have the gethostbyname2 function.  */
+#undef HAVE_GETHOSTBYNAME2
+
+/* Define if you have the gethostbyname2_r function.  */
+#undef HAVE_GETHOSTBYNAME2_R
+
+/* Define if you have the gethostbyname_r function.  */
+#undef HAVE_GETHOSTBYNAME_R
+
+/* Define if you have the getipnodebyaddr function.  */
+#undef HAVE_GETIPNODEBYADDR
+
+/* Define if you have the getipnodebyname function.  */
+#undef HAVE_GETIPNODEBYNAME
+
+/* Define if you have the getnameinfo function.  */
+#undef HAVE_GETNAMEINFO
+
+/* Define if you have the memmove function.  */
+#undef HAVE_MEMMOVE
+
+/* Define if you have the nl_langinfo function.  */
+#undef HAVE_NL_LANGINFO
+
+/* Define if you have the setenv function.  */
+#undef HAVE_SETENV
+
+/* Define if you have the setlocale function.  */
+#undef HAVE_SETLOCALE
+
+/* Define if you have the setvbuf function.  */
+#undef HAVE_SETVBUF
+
+/* Define if you have the unsetenv function.  */
+#undef HAVE_UNSETENV
+
+/* Define if you have the vsnprintf function.  */
+#undef HAVE_VSNPRINTF
+
+/* Define if you have the <dlfcn.h> header file.  */
+#undef HAVE_DLFCN_H
+
+/* Define if you have the <langinfo.h> header file.  */
+#undef HAVE_LANGINFO_H
+
+/* Define if you have the <locale.h> header file.  */
+#undef HAVE_LOCALE_H
+
+/* Define if you have the <pwd.h> header file.  */
+#undef HAVE_PWD_H
+
+/* Define if you have the <unistd.h> header file.  */
+#undef HAVE_UNISTD_H
+
+/* Define if you have the nsl library (-lnsl).  */
+#undef HAVE_LIBNSL
+
+/* Define if you have the socket library (-lsocket).  */
+#undef HAVE_LIBSOCKET
+
+/* Define if --enable-mdnkit-compat is specified */
+#undef ENABLE_MDNKIT_COMPAT
+
+/* Define if you want additional ACE converters compiled in. */
+#undef IDN_EXTRA_ACE
+
+/* Define if your iconv() does not accept UTF-8 as the codeset name for utf-8. */
+#undef IDN_UTF8_ENCODING_NAME
+
+/* Define if you have the dl library (-ldl). */
+#undef HAVE_LIBDL
+
+/* Define as the type of the 1st argument of gethostbyaddr. */
+#undef GHBA_ADDR_T
+
+/* Define as the type of the 2nd argument of gethostbyaddr. */
+#undef GHBA_ADDRLEN_T
+
+/* Define as the type of the 2nd argument of getnameinfo. */
+#undef GNI_SALEN_T
+
+/* Define as the type of the 4th argument of getnameinfo. */
+#undef GNI_HOSTLEN_T
+
+/* Define as the type of the 6th argument of getnameinfo. */
+#undef GNI_SERVLEN_T
+
+/* Define as the type of the 7th argument of getnameinfo. */
+#undef GNI_FLAGS_T
+
+/* Define if the prototype of gethost*_r is glibc flavor. */
+#undef GETHOST_R_GLIBC_FLAVOR
+
+/* Define as the pathname of the shared libc object if your system has one. */
+#undef SOPATH_LIBC
+
+/* Define as the pathname of the shared libnsl object if your system has one. */
+#undef SOPATH_LIBNSL
diff --git a/contrib/idn/idnkit-1.0-src/include/config.h.win b/contrib/idn/idnkit-1.0-src/include/config.h.win
new file mode 100644 (file)
index 0000000..bd7f00f
--- /dev/null
@@ -0,0 +1,45 @@
+/* $Id: config.h.win,v 1.1 2003/06/04 00:25:34 marka Exp $ */
+/*
+ * 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.
+ */
+
+/* for enabling RACE */
+#define IDN_EXTRA_ACE
diff --git a/contrib/idn/idnkit-1.0-src/include/idn/Makefile.in b/contrib/idn/idnkit-1.0-src/include/idn/Makefile.in
new file mode 100644 (file)
index 0000000..8e20de8
--- /dev/null
@@ -0,0 +1,103 @@
+# $Id: Makefile.in,v 1.1 2003/06/04 00:25:34 marka Exp $
+# 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.
+
+srcdir = @srcdir@
+VPATH = @srcdir@
+
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+
+includedir = @includedir@
+idnincludedir = $(includedir)/idn
+
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_DATA = @INSTALL_DATA@
+MKINSTALLDIRS = @top_srcdir@/mkinstalldirs
+SHELL = @SHELL@
+
+HDRS = \
+       api.h \
+       assert.h \
+       checker.h \
+       converter.h \
+       debug.h \
+       delimitermap.h \
+       export.h \
+       filechecker.h \
+       filemapper.h \
+       localencoding.h \
+       log.h \
+       logmacro.h \
+       mapper.h \
+       mapselector.h \
+       nameprep.h \
+       normalizer.h \
+       punycode.h \
+       race.h \
+       res.h \
+       resconf.h \
+       result.h \
+       strhash.h \
+       ucsmap.h \
+       ucsset.h \
+       unicode.h \
+       unormalize.h \
+       ucs4.h \
+       utf8.h \
+       util.h \
+       version.h
+
+all:
+
+install:
+       $(MKINSTALLDIRS) $(DESTDIR)$(idnincludedir)
+       for hdr in $(HDRS); do \
+           $(INSTALL_DATA) $(srcdir)/$$hdr $(DESTDIR)$(idnincludedir)/$$hdr; \
+       done
+
+clean:
+       rm -f *~
+
+distclean: clean
+       rm -f Makefile
+
+test check:
diff --git a/contrib/idn/idnkit-1.0-src/include/idn/aliaslist.h b/contrib/idn/idnkit-1.0-src/include/idn/aliaslist.h
new file mode 100644 (file)
index 0000000..4551ea0
--- /dev/null
@@ -0,0 +1,114 @@
+/* $Id: aliaslist.h,v 1.1 2003/06/04 00:25:34 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_ALIASLIST_H
+#define IDN_ALIASLIST_H 1
+
+#include <idn/result.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct idn__aliaslist *idn__aliaslist_t;
+
+/*
+ * Create a list.
+ *
+ * Returns:
+ *     idn_success             -- ok.
+ *     idn_nomemory            -- malloc failed.
+ */
+extern idn_result_t
+idn__aliaslist_create(idn__aliaslist_t *listp);
+
+/*
+ * Delete a list created by 'idn__aliaslist_create'.
+ */
+extern void
+idn__aliaslist_destroy(idn__aliaslist_t list);
+
+/*
+ * Parse alias information file and set items to the list.
+ *
+ * Returns:
+ *     idn_success             -- ok.
+ *     idn_nofile              -- no such file.
+ *     idn_invalid_syntax      -- file is malformed.
+ *     idn_nomemory            -- malloc failed.
+ */
+extern idn_result_t
+idn__aliaslist_aliasfile(idn__aliaslist_t list, const char *path);
+
+/*
+ * Add an item to the list.
+ *
+ * If top is 0, item is placed as the last item of the alias list.
+ * Otherwise, it is done as the first item.
+ *
+ * Returns:
+ *     idn_success             -- ok.
+ *     idn_nomemory            -- malloc failed.
+ */
+extern idn_result_t
+idn__aliaslist_additem(idn__aliaslist_t list,
+                      const char *pattern, const char *encoding,
+                      int first_item);
+
+/*
+ * Find the encoding name with the specified pattern by wildcard
+ * match.
+ *
+ * Returns:
+ *     idn_success             -- ok. found.
+ *     idn_noentry             -- not found.
+ */
+extern idn_result_t
+idn__aliaslist_find(idn__aliaslist_t list,
+                  const char *pattern, char **encodingp);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* IDN_ALIASLIST_H */
diff --git a/contrib/idn/idnkit-1.0-src/include/idn/api.h b/contrib/idn/idnkit-1.0-src/include/idn/api.h
new file mode 100644 (file)
index 0000000..3adf06e
--- /dev/null
@@ -0,0 +1,298 @@
+/* $Id: api.h,v 1.1 2003/06/04 00:25:35 marka Exp $ */
+/*
+ * 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.
+ */
+
+#ifndef IDN_API_H
+#define IDN_API_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <idn/export.h>
+#include <idn/result.h>
+#include <idn/res.h>
+
+/*
+ * Application Programming Interface for Internationalized Domain Name
+ * Handling.  This module provides high-level APIs for ordinary applications.
+ * Low-level APIs are also available.  See "res.h" for details.
+ */
+
+/*
+ * Enable or disable IDN conversion scheme.
+ *
+ * If on_off is 0, IDN conversion scheme is disabled. Otherwise, IDN
+ * conversion is enabled even when IDN_DISABLE is defined.
+ */
+IDN_EXPORT void
+idn_enable(int on_off);
+
+/*
+ * Set configuration file name.
+ * This function is for private use only.
+ *
+ * When idn_nameinit(1) is called, this module loads `file'.
+ *
+ * Returns:
+ *     idn_success             -- ok.
+ *     idn_nomemory            -- malloc failed.
+ *     idn_failure             -- idn_nameinit() has already been
+ *                                called.
+ */
+extern idn_result_t
+idn__setconffile(const char *file);
+
+/*
+ * Initialize this module, and load configuration from the default
+ * configuration file (idn.conf).
+ *
+ * The initialization will be done only once when this function is
+ * called first, while either loading of the configuration file or
+ * setting the defaults behavior without the configuration file will
+ * be done every time it is called.
+ *
+ * If load_file is 0, this will set the defaults behavior without the
+ * configuration file.  Otherwise, loading of the configuration file
+ * occurs.
+ *
+ * If 'idn_encodename' or 'idn_decodename' is called without calling
+ * this function, implicit initialization without the configuration
+ * file will be done prior to encoding/decoding process.
+ *
+ * Returns:
+ *     idn_success             -- ok.
+ *     idn_nofile              -- cannot open the configuration file.
+ *     idn_invalid_syntax      -- syntax error found in the file.
+ *     idn_invalid_name        -- there are invalid names (encoding,
+ *                                normalization etc.).
+ *     idn_nomemory            -- malloc failed.
+ */
+IDN_EXPORT idn_result_t
+idn_nameinit(int load_file);
+
+/*
+ * Encode internationalized domain name.
+ *
+ * The encoding process consists of the following 7 steps.
+ *
+ *    1. Local encoding to UTF-8 conversion
+ *       Converts a domain name written with local encoding (e.g. ISO-
+ *       8859-1) to UTF-8.
+ *    2. Delimiter mapping,
+ *       Maps certain characters to period (U+002E, FULL STOP).
+ *    3. Local mapping
+ *       Apply character mappings according with the TLD of the domain
+ *       name.
+ *    4. NAMEPREP
+ *       Perform NAME preparation described in RFC3491.
+ *       This step consists of the following 4 steps:
+ *       4.1. Mapping
+ *       4.2. Normalization
+ *       4.3. Prohibited character check
+ *       4.4. Unassigned check
+ *    5. ASCII range character check
+ *       Checks if the domain name contains non-LDH ASCII character (not
+ *       alpha-numeric or hypen), or it begins or end with hypen.
+ *    6. UTF-8 to IDN encoding conversion.
+ *       Converts the domain name from UTF-8 to ACE (e.g. Punycode).
+ *    7. Length check
+ *       Checks the length of each label.
+ *
+ * 'actions' specifies actions and options of the encoding procedure.
+ * Its value is a bitwise-or of the following flags:
+ *
+ *   IDN_LOCALCONV     -- perform local encoding to UTF-8 conversion (step 1)
+ *   IDN_DELIMMAP      -- perform delimiter mapping (step 2)
+ *   IDN_LOCALMAP      -- perform local mapping (step 3)
+ *   IDN_MAP           -- perform mapping (step 4.1)
+ *   IDN_NORMALIZE     -- perform normalization (step 4.2)
+ *   IDN_PROHCHECK     -- perform prohibited character check (step 4.3)
+ *   IDN_UNASCHECK     -- perform unassigned codepoint check (step 4.4)
+ *   IDN_ASCCHECK      -- perform ASCII range character check (step 5)
+ *   IDN_IDNCONV       -- perform UTF-8 to IDN encoding conversion (step 6)
+ *   IDN_LENCHECK      -- perform length check (step 7)
+ *
+ * Also the following flags are provided for convinience:
+ *
+ *   IDN_ENCODE_QUERY  -- On libidnkit, perform step 1..7, except for step
+ *                        4.4 and 5.
+ *                        On libidnkitlite, perform step 2..7, except for
+ *                        step 4.4 and 5.
+ *   IDN_ENCODE_STORED -- On libidnkit, perform step 1..7, except for step
+ *                        5.
+ *                        On libidnkitlite, perform step 2..7, except for
+ *                        step 5.
+ *   IDN_ENCODE_APP    -- Same as IDN_ENCODE_QUERY.
+ *   IDN_NAMEPREP      -- perform NAMEPREP (step 4) without unassigned
+ *                        codepoint check (step 4.4).
+ *
+ * The following flag does not corresponding to a particular action,
+ * but an option of conversion process:
+ *
+ *   IDN_UNDOIFERR     -- If any step fails, the original input name is
+ *                         returned.
+ *
+ * Note that if no flags are specified, 'idn_encodename' does nothing
+ * fancy, just copies the given name verbatim.
+ *
+ * Returns:
+ *     idn_success             -- ok.
+ *     idn_invalid_action      -- invalid action flag specified.
+ *     idn_invalid_encoding    -- the given string has invalid/illegal
+ *                                byte sequence.
+ *     idn_invalid_length      -- invalid length of a label.
+ *     idn_prohibited          -- prohibited/unassigned code point found.
+ *     idn_buffer_overflow     -- 'tolen' is too small.
+ *     idn_nomemory            -- malloc failed.
+ *
+ * Also, if this function is called without calling 'idn_nameinit',
+ * the following error codes might be returned.
+ *     idn_nofile              -- cannot open the configuration file.
+ *     idn_invalid_syntax      -- syntax error found in the file.
+ *     idn_invalid_name        -- there are invalid names (encoding,
+ *                                normalization etc.).
+ */
+IDN_EXPORT idn_result_t
+idn_encodename(idn_action_t actions, const char *from, char *to, size_t tolen);
+
+/*
+ * Decode internationalized domain name.
+ *
+ * The decoding process consists of the following 5 steps.
+ *
+ *    1. delimiter mapping
+ *       Maps certain characters to period (U+002E, FULL STOP).
+ *    2. NAMEPREP
+ *       Perform NAME preparation described in RFC3491.
+ *       This step consists of the following 4 steps:
+ *       2.1. Mapping
+ *       2.2. Normalization
+ *       2.3. Prohibited character check
+ *       2.4. Unassigned check
+ *    3. IDN encoding to UTF-8 conversion.
+ *       Converts the domain name from ACE (e.g. Punycode) to UCS4.
+ *    4. Perform round-trip check.
+ *       Encode the result of step 3, and then compare it with the result
+ *       of the step 2.  If they are different, the check is failed.
+ *    5. Convert UTF-8 to local encoding.
+ *       If a character in the domain name cannot be converted to local
+ *       encoding, the conversion is failed.
+ *
+ * 'actions' specifies actions of the decoding procedure.
+ * Its value is a bitwise-or of the following flags:
+ *
+ *   IDN_DELIMMAP      -- perform delimiter mapping (step 1)
+ *   IDN_MAP           -- perform mapping (step 2.1)
+ *   IDN_NORMALIZE     -- perform normalization (step 2.2)
+ *   IDN_PROHCHECK     -- perform prohibited character check (step 2.3)
+ *   IDN_UNASCHECK     -- perform unassigned codepoint check (step 2.4)
+ *   IDN_IDNCONV       -- perform IDN encoding to UTF-8 conversion (step 3)
+ *   IDN_RTCHECK        -- perform round-trip check (step 4)
+ *   IDN_ASCCHECK      -- perform ASCII range character check while
+ *                        round-trip check (step 4.1)
+ *   IDN_LOCALCONV      -- perform UTF-8 to local encoding conversion (step 5)
+ *
+ * Also the following flags are provided for the convenience:
+ *
+ *   IDN_DECODE_QUERY  -- On libidnkit, perform step 1..5, except for step
+ *                        2.4 and 4.1.
+ *                        On libidnkitlite, perform step 1..3, except for
+ *                        step 2.4 and 4.1.
+ *   IDN_DECODE_STORED -- On libidnkit, perform step 1..5, except for step
+ *                        4.1.
+ *                        On libidnkitlite, perform step 1..3, except for
+ *                        step 4.1.
+ *   IDN_DECODE_APP    -- Same as IDN_DECODE_QUERY.
+ *   IDN_NAMEPREP      -- perform NAMEPREP (step 2) without unassigned
+ *                        codepoint check (step 2.4).
+ *
+ * If any step fails, the original input name is returned.
+ * 'actions' specifies what actions to take when decoding, and is
+ * a bitwise-or of the following flags:
+ *
+ * Note that if no flags are specified, 'idn_decodename' does nothing
+ * but copying the given name verbatim.
+ *
+ * Returns:
+ *     idn_success             -- ok.
+ *     idn_invalid_action      -- invalid action flag specified.
+ *     idn_invalid_encoding    -- the given string has invalid/illegal
+ *                                byte sequence.
+ *     idn_buffer_overflow     -- 'tolen' is too small.
+ *     idn_invalid_length      -- length of a label is not 1..63 characters.
+ *     idn_nomemory            -- malloc failed.
+ *
+ * Also, if this function is called without calling 'idn_nameinit',
+ * the following error codes might be returned.
+ *     idn_nofile              -- cannot open the configuration file.
+ *     idn_invalid_syntax      -- syntax error found in the file.
+ *     idn_invalid_name        -- there are invalid names (encoding,
+ *                                normalization etc.).
+ */
+IDN_EXPORT idn_result_t
+idn_decodename(idn_action_t actions, const char *from, char *to, size_t tolen);
+
+/*
+ * Decode internationalized domain name with auxiliary encoding
+ * support.
+ *
+ * This is another API for IDN string decode.  The difference between
+ * two is whether the encoding conversion from auxiliary encoding to
+ * UTF-8 occurs prior to the actual decode process (read description
+ * of idn_res_decodename() above) or not.
+ *
+ * If auxencoding is NULL, from is treated as UTF-8 encoded string.
+ * 
+ * Other arguments serve exactly same role as those of
+ * idn_res_decodename().
+ */
+idn_result_t
+idn_decodename2(idn_action_t actions, const char *from, char *to, size_t tolen,
+               const char *auxencoding);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* IDN_API_H */
diff --git a/contrib/idn/idnkit-1.0-src/include/idn/assert.h b/contrib/idn/idnkit-1.0-src/include/idn/assert.h
new file mode 100644 (file)
index 0000000..060caca
--- /dev/null
@@ -0,0 +1,61 @@
+/* $Id: assert.h,v 1.1 2003/06/04 00:25:35 marka Exp $ */
+/*
+ * 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.
+ */
+
+#ifndef IDN_ASSERT_H
+#define IDN_ASSERT_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <assert.h>
+
+#ifndef DEBUG
+#define NDEBUG
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+# endif /* IDN_ASSERT_H */
diff --git a/contrib/idn/idnkit-1.0-src/include/idn/checker.h b/contrib/idn/idnkit-1.0-src/include/idn/checker.h
new file mode 100644 (file)
index 0000000..0d4e6d0
--- /dev/null
@@ -0,0 +1,171 @@
+/* $Id: checker.h,v 1.1 2003/06/04 00:25:36 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.
+ */
+
+#ifndef IDN_CHECKER_H
+#define IDN_CHECKER_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Character Checker.
+ *
+ * Perfom checking characters in the specified domain name.
+ */
+
+#include <idn/result.h>
+#include <idn/filechecker.h>
+#include <idn/nameprep.h>
+
+/*
+ * Schems name prefixes for the standard nameprep prohibit/unassigned
+ * checks.
+ *
+ * If you'd like to add the unassigned check scheme of "RFC3491"
+ * to a checker context, IDN_CHECKER_UNASSIGNED_PREFIX + "RFC3491"
+ * (i.e. "unassigned#RFC3491") is the scheme name passed to
+ * idn_checker_add().
+ */
+#define IDN_CHECKER_PROHIBIT_PREFIX    "prohibit#"
+#define IDN_CHECKER_UNASSIGNED_PREFIX  "unassigned#"
+#define IDN_CHECKER_BIDI_PREFIX                "bidi#"
+
+/*
+ * Checker object type.
+ */
+typedef struct idn_checker *idn_checker_t;
+
+/*
+ * Initialize module.  Must be called before any other calls of
+ * the functions of this module.
+ *
+ * Returns:
+ *      idn_success             -- ok.
+ *      idn_nomemory            -- malloc failed.
+ */
+extern idn_result_t
+idn_checker_initialize(void);
+
+/*
+ * Create a checker context.
+ *
+ * Returns:
+ *      idn_success             -- ok.
+ *      idn_nomemory            -- malloc failed.
+ */
+extern idn_result_t
+idn_checker_create(idn_checker_t *ctxp);
+
+/*
+ * Decrement reference count of the checker `ctx' created by
+ * 'idn_checker_create', if it is still refered by another object.
+ * Otherwise, release all the memory allocated to the checker.
+ */
+extern void
+idn_checker_destroy(idn_checker_t ctx);
+
+/*
+ * Increment reference count of the checker `ctx' created by
+ * 'idn_checker_create'.
+ */
+extern void
+idn_checker_incrref(idn_checker_t ctx);
+
+/*
+ * Add checking scheme `name' to the checker to `ctx'.
+ * 
+ * Returns:
+ *      idn_success             -- ok.
+ *      idn_invalid_name        -- the given name is not valid.
+ *      idn_nomemory            -- malloc failed.
+ */
+extern idn_result_t
+idn_checker_add(idn_checker_t ctx, const char *name);
+
+extern idn_result_t
+idn_checker_addall(idn_checker_t ctx, const char **names, int nnames);
+
+/*
+ * Check a domain name.  All checking schemes regsitered in `ctx' are
+ * applied in the regisration order.
+ *
+ * Returns:
+ *      idn_success             -- ok.
+ *      idn_nomemory            -- malloc failed.
+ *      idn_buffer_overflow     -- output buffer is too small.
+ */
+extern idn_result_t
+idn_checker_lookup(idn_checker_t ctx, const unsigned long *ucs4,
+                  const unsigned long **found);
+
+/*
+ * Checking procedure type.
+ */
+typedef idn_result_t (*idn_checker_createproc_t)(const char *parameter,
+                                                void **ctxp);
+typedef void         (*idn_checker_destroyproc_t)(void *ctx);
+typedef idn_result_t (*idn_checker_lookupproc_t)(void *ctx,
+                                                const unsigned long *ucs4,
+                                                 const unsigned long **found);
+                                              
+/*
+ * Register a new checking scheme.
+ *
+ * You can override the default normalization schemes, if you want.
+ * 
+ * Returns:
+ *      idn_success             -- ok.
+ *      idn_nomemory            -- malloc failed.
+ */
+extern idn_result_t
+idn_checker_register(const char *prefix,
+                    idn_checker_createproc_t create,
+                    idn_checker_destroyproc_t destroy,
+                    idn_checker_lookupproc_t lookup);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* IDN_CHECKER_H */
diff --git a/contrib/idn/idnkit-1.0-src/include/idn/converter.h b/contrib/idn/idnkit-1.0-src/include/idn/converter.h
new file mode 100644 (file)
index 0000000..0c4e03d
--- /dev/null
@@ -0,0 +1,258 @@
+/* $Id: converter.h,v 1.1 2003/06/04 00:25:36 marka Exp $ */
+/*
+ * 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.
+ */
+
+#ifndef IDN_CONVERTER_H
+#define IDN_CONVERTER_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Codeset converter.
+ *
+ * This module provides conversions from some local codeset to UCS4
+ * and vice versa.
+ */
+
+#include <idn/export.h>
+#include <idn/result.h>
+
+/*
+ * Converter context type (opaque).
+ */
+typedef struct idn_converter *idn_converter_t;
+
+/*
+ * Conversion flags.
+ */
+#define IDN_CONVERTER_DELAYEDOPEN      1
+#define IDN_CONVERTER_RTCHECK          2
+
+/*
+ * Encoding types.
+ */
+#define IDN_NONACE                     0
+#define IDN_ACE_STRICTCASE             1
+#define IDN_ACE_LOOSECASE              2
+
+/*
+ * Initialize module.  Must be called before any other calls of
+ * the functions of this module.
+ *
+ * Returns:
+ *     idn_success             -- ok.
+ *     idn_nomemory            -- malloc failed.
+ */
+IDN_EXPORT idn_result_t
+idn_converter_initialize(void);
+
+/*
+ * Create a conversion context.
+ *
+ * Returns:
+ *     idn_success             -- ok.
+ *     idn_invalid_name        -- specified codeset is not supported.
+ *     idn_nomemory            -- malloc failed.
+ *     idn_failure             -- other failure (unknown cause).
+ */
+IDN_EXPORT idn_result_t
+idn_converter_create(const char *name, idn_converter_t *ctxp,
+                    int flags);
+
+/*
+ * Decrement reference count of the converter `ctx' created by
+ * 'idn_converter_create', if it is still refered by another object.
+ * Otherwise, release all the memory allocated to the converter.
+ */
+IDN_EXPORT void
+idn_converter_destroy(idn_converter_t ctx);
+
+/*
+ * Increment reference count of the converter `ctx' created by
+ * 'idn_converter_create'.
+ */
+IDN_EXPORT void
+idn_converter_incrref(idn_converter_t ctx);
+
+/*
+ * Convert between local codeset and UCS4.  Note that each conversion
+ * is started with initial state.
+ *
+ * Returns:
+ *     idn_success             -- ok.
+ *     idn_buffer_overflow     -- output buffer is too small.
+ *     idn_invalid_encoding    -- the input string has invalid/illegal
+ *                                byte sequence.
+ *     idn_invalid_name        -- codeset is not supported (this error
+ *                                should happen only if 'delayedopen'
+ *                                flag was set when idn_converter_create
+ *                                was called)
+ *     idn_failure             -- other failure.
+ */
+IDN_EXPORT idn_result_t
+idn_converter_convfromucs4(idn_converter_t ctx, 
+                          const unsigned long *from, char *to, size_t tolen);
+
+IDN_EXPORT idn_result_t
+idn_converter_convtoucs4(idn_converter_t ctx, 
+                        const char *from, unsigned long *to, size_t tolen);
+
+/*
+ * Get the name of local codeset.  The returned name may be different from
+ * the one specified to idn_converter_create, if the specified one was an
+ * alias.
+ *
+ * Returns:
+ *     the local codeset name.
+ */
+IDN_EXPORT char *
+idn_converter_localencoding(idn_converter_t ctx);
+
+/*
+ * Return the encoding type of this local encoding.
+ *
+ * Returns:
+ *     IDN_NONACE              -- encoding is not ACE.
+ *     IDN_ACE_STRICTCASE      -- encoding is ACE.
+ *                                decoder of this ACE preserve letter case.
+ *     IDN_ACE_LOOSECASE       -- encoding type is ACE.
+ *                                decoder cannot preserve letter case.
+ */
+IDN_EXPORT int
+idn_converter_encodingtype(idn_converter_t ctx);
+
+/*
+ * Return if this local encoding is ACE (Ascii Compatible Encoding).
+ *
+ * Returns:
+ *     1       -- yes, it is ACE.
+ *     0       -- no.
+ */
+IDN_EXPORT int
+idn_converter_isasciicompatible(idn_converter_t ctx);
+
+/*
+ * Register an alias for a codeset name.
+ *
+ * If first_item is 0, alias pattern is placed as the last item of the
+ * alias list.  Otherwise, it is done as the first item.
+ *
+ * Returns:
+ *     idn_success             -- ok.
+ *     idn_nomemory            -- malloc failed.
+ */
+IDN_EXPORT idn_result_t
+idn_converter_addalias(const char *alias_name, const char *real_name,
+                      int first_item);
+
+/*
+ * Register aliases defined by the specified file.
+ *
+ * Returns:
+ *     idn_success             -- ok.
+ *     idn_nofile              -- no such file.
+ *     idn_invalid_syntax      -- file is malformed.
+ *     idn_nomemory            -- malloc failed.
+ */
+IDN_EXPORT idn_result_t
+idn_converter_aliasfile(const char *path);
+
+/*
+ * Unregister all the aliases.
+ */
+IDN_EXPORT idn_result_t
+idn_converter_resetalias(void);
+
+/*
+ * resolve real encoding name from alias information.
+ */
+IDN_EXPORT const char *
+idn_converter_getrealname(const char *name);
+
+
+/*
+ * New converter registration.
+ */
+
+/*
+ * Conversion operation functions.
+ */
+typedef idn_result_t (*idn_converter_openproc_t)(idn_converter_t ctx,
+                                                void **privdata);
+typedef idn_result_t (*idn_converter_closeproc_t)(idn_converter_t ctx,
+                                                 void *privdata);
+typedef idn_result_t
+       (*idn_converter_convfromucs4proc_t)(idn_converter_t ctx,
+                                           void *privdata,
+                                           const unsigned long *from,
+                                           char *to, size_t tolen);
+typedef idn_result_t
+       (*idn_converter_convtoucs4proc_t)(idn_converter_t ctx,
+                                         void *privdata,
+                                         const char *from,
+                                         unsigned long *to,
+                                         size_t tolen);
+
+/*
+ * Register a new converter.
+ * 'encoding_type' is a value which idn_converter_encodingtype() returns.
+ *
+ * Returns:
+ *     idn_success             -- ok.
+ *     idn_nomemory            -- malloc failed.
+ */
+IDN_EXPORT 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);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* IDN_CONVERTER_H */
diff --git a/contrib/idn/idnkit-1.0-src/include/idn/debug.h b/contrib/idn/idnkit-1.0-src/include/idn/debug.h
new file mode 100644 (file)
index 0000000..fad444c
--- /dev/null
@@ -0,0 +1,69 @@
+/* $Id: debug.h,v 1.1 2003/06/04 00:25:36 marka Exp $ */
+/*
+ * 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.
+ */
+
+#ifndef IDN_DEBUG_H
+#define IDN_DEBUG_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Debug utility
+ */
+
+#include <idn/export.h>
+
+IDN_EXPORT char        *idn__debug_hexstring(const char *s, int maxbytes);
+IDN_EXPORT char        *idn__debug_xstring(const char *s, int maxbytes);
+IDN_EXPORT char        *idn__debug_ucs4xstring(const unsigned long *s, int maxbytes);
+IDN_EXPORT char        *idn__debug_utf16xstring(const unsigned short *s,
+                                        int maxbytes);
+IDN_EXPORT char        *idn__debug_hexdata(const char *s, int length, int maxbytes);
+IDN_EXPORT void        idn__debug_hexdump(const char *s, int maxbytes);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* IDN_DEBUG_H */
diff --git a/contrib/idn/idnkit-1.0-src/include/idn/delimitermap.h b/contrib/idn/idnkit-1.0-src/include/idn/delimitermap.h
new file mode 100644 (file)
index 0000000..d9aa33a
--- /dev/null
@@ -0,0 +1,123 @@
+/* $Id: delimitermap.h,v 1.1 2003/06/04 00:25:37 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.
+ */
+
+#ifndef IDN_DELIMITERMAP_H
+#define IDN_DELIMITERMAP_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Mapper.
+ *
+ * Perfom mapping local delimiters to `.'.
+ */
+
+#include <idn/export.h>
+#include <idn/result.h>
+
+/*
+ * Map object type.
+ */
+typedef struct idn_delimitermap *idn_delimitermap_t;
+
+/*
+ * Create a delimitermap context.
+ *
+ * Returns:
+ *      idn_success             -- ok.
+ *      idn_nomemory            -- malloc failed.
+ */
+IDN_EXPORT idn_result_t
+idn_delimitermap_create(idn_delimitermap_t *ctxp);
+
+/*
+ * Decrement reference count of the delimitermap `ctx' created by
+ * 'idn_delimitermap_create', if it is still refered by another object.
+ * Otherwise, release all the memory allocated to the delimitermap.
+ */
+IDN_EXPORT void
+idn_delimitermap_destroy(idn_delimitermap_t ctx);
+
+/*
+ * Increment reference count of the delimitermap `ctx' created by
+ * 'idn_delimitermap_create'.
+ */
+IDN_EXPORT void
+idn_delimitermap_incrref(idn_delimitermap_t ctx);
+
+/*
+ * Add a local delimiter.
+ * 
+ * Returns:
+ *      idn_success             -- ok.
+ *      idn_nomemory            -- malloc failed.
+ *      idn_invalid_codepoint   -- delimiter is not valid UCS4 character.
+ */
+IDN_EXPORT idn_result_t
+idn_delimitermap_add(idn_delimitermap_t ctx, unsigned long delimiter);
+
+IDN_EXPORT idn_result_t
+idn_delimitermap_addall(idn_delimitermap_t ctx, unsigned long *delimiters,
+                       int ndelimiters);
+
+/*
+ * Map local delimiters in `from' to `.'.
+ *
+ * Note that if no delimiter is added to the context, the function copies
+ * the string.
+ *
+ * Returns:
+ *      idn_success             -- ok.
+ *      idn_buffer_overflow     -- output buffer is too small.
+ */
+IDN_EXPORT idn_result_t
+idn_delimitermap_map(idn_delimitermap_t ctx, const unsigned long *from,
+                    unsigned long *to, size_t tolen);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* IDN_DELIMITERMAP_H */
diff --git a/contrib/idn/idnkit-1.0-src/include/idn/export.h b/contrib/idn/idnkit-1.0-src/include/idn/export.h
new file mode 100644 (file)
index 0000000..71e9314
--- /dev/null
@@ -0,0 +1,58 @@
+/* $Id: export.h,v 1.1 2003/06/04 00:25:37 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_EXPORT_H
+#define IDN_EXPORT_H 1
+
+/*
+ * Macro for exporting functions.
+ *
+ * When creating a Windows DLL, define IDN_EXPORT something as
+ * "extern __declspec(dllexport)".
+ */
+
+#ifndef IDN_EXPORT
+#define IDN_EXPORT extern
+#endif
+
+# endif /* IDN_EXPORT_H */
diff --git a/contrib/idn/idnkit-1.0-src/include/idn/filechecker.h b/contrib/idn/idnkit-1.0-src/include/idn/filechecker.h
new file mode 100644 (file)
index 0000000..c69c2b1
--- /dev/null
@@ -0,0 +1,136 @@
+/* $Id: filechecker.h,v 1.1 2003/06/04 00:25:37 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.
+ */
+
+#ifndef IDN_FILECHECKER_H
+#define IDN_FILECHECKER_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Character checker -- check if there are any characters specified
+ * by a file in the given string.
+ */
+
+#include <idn/result.h>
+
+/*
+ * Check object type.
+ */
+typedef struct idn__filechecker *idn__filechecker_t;
+
+/*
+ * Read the contents of the given file and create a context for
+ * checking.
+ *
+ * 'file' is the pathname of the file, which specifies the set of
+ * characters to be checked.  The file is a simple text file, and
+ * each line must be of the form either
+ *   <code_point>
+ * or
+ *   <code_point>-<code_point>
+ * (or comment, see below) where <code_point> is a UCS code point
+ * represented as hexadecimal string with optional prefix `U+'
+ * (ex. `0041' or `U+FEDC').
+ *
+ * The former specifies just one character (a code point, to be precise),
+ * while the latter specified a range of characters.  In the case of
+ * a character range, the first code point (before hyphen) must not be
+ * greater than the second code point (after hyphen).
+ *
+ * Lines starting with `#' are comments.
+ *
+ * If file is read with no errors, the created context is stored in
+ * '*ctxp', and 'idn_success' is returned.  Otherwise, the contents
+ * of '*ctxp' is undefined.
+ *
+ * Returns:
+ *     idn_success             -- ok.
+ *     idn_nofile              -- cannot open the specified file.
+ *     idn_nomemory            -- malloc failed.
+ *     idn_invalid_syntax      -- file format is not valid.
+ */
+extern idn_result_t
+idn__filechecker_create(const char *file, idn__filechecker_t *ctxp);
+
+/*
+ * Release memory for the specified context.
+ */
+extern void
+idn__filechecker_destroy(idn__filechecker_t ctx);
+
+/*
+ * See if the given string contains any specified characters.
+ *
+ * Check if there is any characters pecified by the context 'ctx' in
+ * the UCS4 string 'str'.  If there are none, NULL is stored in '*found'.
+ * Otherwise, the pointer to the first occurence of such character is
+ * stored in '*found'.
+ *
+ * Returns:
+ *     idn_success             -- ok.
+ */
+extern idn_result_t
+idn__filechecker_lookup(idn__filechecker_t ctx, const unsigned long *str,
+                       const unsigned long **found);
+
+/*
+ * The following functions are for internal use.
+ * They are used for this module to be add to the checker module.
+ */
+extern idn_result_t
+idn__filechecker_createproc(const char *parameter, void **ctxp);
+
+extern void
+idn__filechecker_destroyproc(void *ctxp);
+
+extern idn_result_t
+idn__filechecker_lookupproc(void *ctx, const unsigned long *str,
+                           const unsigned long **found);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* IDN_FILECHECKER_H */
diff --git a/contrib/idn/idnkit-1.0-src/include/idn/filemapper.h b/contrib/idn/idnkit-1.0-src/include/idn/filemapper.h
new file mode 100644 (file)
index 0000000..1f8e6b9
--- /dev/null
@@ -0,0 +1,137 @@
+/* $Id: filemapper.h,v 1.1 2003/06/04 00:25:38 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.
+ */
+
+#ifndef IDN_FILEMAPPER_H
+#define IDN_FILEMAPPER_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Perform character mapping (substitution) according to a
+ * map file.
+ */
+
+#include <idn/result.h>
+
+/*
+ * Mapping object type.
+ */
+typedef struct idn__filemapper *idn__filemapper_t;
+
+/*
+ * Read the contents of the given map file and create a context for mapping.
+ *
+ * 'file' is the pathname of the file, which specifies the character
+ * mapping.  The file is a simple text file, and each line specifies
+ * a mapping of a single character.  The format of each line is
+ *
+ *   <code_point>; [<code_point>..][;]
+ *
+ * where <code_point> is a UCS code point represented as a hexadecimal
+ * string with optional prefix `U+' (ex. `0041' or `U+FEDC').
+ * The code point before the first semicolon will be mapped to the
+ * sequence of code points separated by space characters after the
+ * first semicolon.  The sequence may be empty, denoting wiping out
+ * the character.
+ *
+ * For example,
+ *     U+0041; U+0061          -- maps 'A' to 'a'
+ *     20;;                    -- wipes out ' '
+ *     
+ * Anything after the second semicolon is ignored.  Also lines beginning
+ * with '#' are treated as comments.
+ *
+ * If there is no error, the created context is stored in '*ctxp'.
+ * 
+ * Returns:
+ *     idn_success             -- ok.
+ *     idn_nofile              -- cannot open the specified file.
+ *     idn_nomemory            -- malloc failed.
+ *     idn_invalid_syntax      -- file format is not valid.
+ */
+extern idn_result_t
+idn__filemapper_create(const char *file, idn__filemapper_t *ctxp);
+
+/*
+ * Release memory for the given context.
+ */
+extern void
+idn__filemapper_destroy(idn__filemapper_t ctx);
+
+/*
+ * Perform character substitution.
+ *
+ * Each character in the string 'from' is examined and if it
+ * has a mapping, it is substituted to the corresponding
+ * character sequence.  The substituted string is stored in 'to',
+ * whose length is specified by 'tolen'.
+ *
+ * Returns:
+ *     idn_success             -- ok.
+ *     idn_buffer_overflow     -- result buffer is too small.
+ */
+extern idn_result_t
+idn__filemapper_map(idn__filemapper_t ctx, const unsigned long *from,
+                   unsigned long *to, size_t tolen);
+
+/*
+ * The following functions are for internal use.
+ * They are used for this module to be add to the mapper module.
+ */
+extern idn_result_t
+idn__filemapper_createproc(const char *parameter, void **ctxp);
+
+extern void
+idn__filemapper_destroyproc(void *ctxp);
+
+extern idn_result_t
+idn__filemapper_mapproc(void *ctx, const unsigned long *from,
+                       unsigned long *to, size_t tolen);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* IDN_FILEMAPPER_H */
diff --git a/contrib/idn/idnkit-1.0-src/include/idn/localencoding.h b/contrib/idn/idnkit-1.0-src/include/idn/localencoding.h
new file mode 100644 (file)
index 0000000..012c08a
--- /dev/null
@@ -0,0 +1,79 @@
+/* $Id: localencoding.h,v 1.1 2003/06/04 00:25:38 marka Exp $ */
+/*
+ * 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.
+ */
+
+#ifndef IDN_LOCALENCODING_H
+#define IDN_LOCALENCODING_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Local codeset detection.
+ *
+ * Determine the local codeset (the codeset used by the current application),
+ * based on the locale information.
+ */
+
+#include <idn/export.h>
+
+#define IDN_LOCALCS_ENV        "IDN_LOCAL_CODESET"
+
+/*
+ * Get the codeset name corresponding to the current locale,
+ * suitable for passing to 'idn_converter_create'.
+ *
+ * If the codeset cannot be determined, the locale name itself
+ * will be returned in the hope that codeset alias file translates it
+ * to the right name.
+ *
+ * If it cannot retrieve the current locale name, NULL will be
+ * returned.
+ */
+IDN_EXPORT const char  *idn_localencoding_name(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* IDN_LOCALENCODING_H */
diff --git a/contrib/idn/idnkit-1.0-src/include/idn/log.h b/contrib/idn/idnkit-1.0-src/include/idn/log.h
new file mode 100644 (file)
index 0000000..52ea82d
--- /dev/null
@@ -0,0 +1,107 @@
+/* $Id: log.h,v 1.1 2003/06/04 00:25:38 marka Exp $ */
+/*
+ * 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.
+ */
+
+#ifndef IDN_LOG_H
+#define IDN_LOG_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * libidnkit logging facility.
+ */
+
+#include <idn/export.h>
+
+/*
+ * Log level definition.
+ */
+enum {
+       idn_log_level_fatal = 0,
+       idn_log_level_error = 1,
+       idn_log_level_warning = 2,
+       idn_log_level_info = 3,
+       idn_log_level_trace = 4,
+       idn_log_level_dump = 5
+};
+
+/*
+ * Log handler type.
+ */
+typedef void   (*idn_log_proc_t)(int level, const char *msg);
+
+/*
+ * Log routines.
+ */
+IDN_EXPORT void        idn_log_fatal(const char *fmt, ...);
+IDN_EXPORT void        idn_log_error(const char *fmt, ...);
+IDN_EXPORT void        idn_log_warning(const char *fmt, ...);
+IDN_EXPORT void        idn_log_info(const char *fmt, ...);
+IDN_EXPORT void        idn_log_trace(const char *fmt, ...);
+IDN_EXPORT void        idn_log_dump(const char *fmt, ...);
+
+/*
+ * Set/get log level.
+ *
+ * If log level has not been explicitly defined by 'idn_log_setlevel',
+ * the default level is determined by the value of enrironment
+ * variable 'IDN_LOG_LEVEL'.
+ */
+IDN_EXPORT void        idn_log_setlevel(int level);
+IDN_EXPORT int idn_log_getlevel(void);
+
+/*
+ * Set log handler.
+ *
+ * If no log handler is set, log goes to stderr by default.
+ * You can reset the handler to the default one by specifying
+ * NULL.
+ */
+IDN_EXPORT void        idn_log_setproc(idn_log_proc_t proc);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* IDN_LOG_H */
diff --git a/contrib/idn/idnkit-1.0-src/include/idn/logmacro.h b/contrib/idn/idnkit-1.0-src/include/idn/logmacro.h
new file mode 100644 (file)
index 0000000..22b26de
--- /dev/null
@@ -0,0 +1,72 @@
+/* $Id: logmacro.h,v 1.1 2003/06/04 00:25:38 marka Exp $ */
+/*
+ * 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.
+ */
+
+#ifndef IDN_LOGMACRO_H
+#define IDN_LOGMACRO_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <idn/log.h>
+
+#define FATAL(x)       idn_log_fatal x
+#define ERROR(x)       idn_log_error x
+#define WARNING(x)     idn_log_warning x
+#define INFO(x)                LOG_AT_LEVEL(idn_log_level_info, idn_log_info, x)
+#define TRACE(x)       LOG_AT_LEVEL(idn_log_level_trace, idn_log_trace, x)
+
+#ifdef DEBUG
+#define DUMP(x)                LOG_AT_LEVEL(idn_log_level_dump, idn_log_dump, x)
+#else
+#define DUMP(x)
+#endif /* DEBUG */
+
+#define LOG_AT_LEVEL(lv, fun, x) do {if (LOGLEVEL >= (lv)) fun x; } while (0)
+#define LOGLEVEL       idn_log_getlevel()
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* IDN_LOGMACRO_H */
diff --git a/contrib/idn/idnkit-1.0-src/include/idn/mapper.h b/contrib/idn/idnkit-1.0-src/include/idn/mapper.h
new file mode 100644 (file)
index 0000000..4375b74
--- /dev/null
@@ -0,0 +1,159 @@
+/* $Id: mapper.h,v 1.1 2003/06/04 00:25:38 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.
+ */
+
+#ifndef IDN_MAPPER_H
+#define IDN_MAPPER_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Mapper.
+ *
+ * Perfom mapping the specified domain name.
+ */
+
+#include <idn/export.h>
+#include <idn/result.h>
+#include <idn/filemapper.h>
+#include <idn/nameprep.h>
+
+/*
+ * Map object type.
+ */
+typedef struct idn_mapper *idn_mapper_t;
+
+/*
+ * Initialize module.  Must be called before any other calls of
+ * the functions of this module.
+ *
+ * Returns:
+ *      idn_success             -- ok.
+ *      idn_nomemory            -- malloc failed.
+ */
+IDN_EXPORT idn_result_t
+idn_mapper_initialize(void);
+
+/*
+ * Create a mapper context.
+ *
+ * Returns:
+ *      idn_success             -- ok.
+ *      idn_nomemory            -- malloc failed.
+ */
+IDN_EXPORT idn_result_t
+idn_mapper_create(idn_mapper_t *ctxp);
+
+/*
+ * Decrement reference count of the mapper `ctx' created by
+ * 'idn_mapper_create', if it is still refered by another object.
+ * Otherwise, release all the memory allocated to the mapper.
+ */
+IDN_EXPORT void
+idn_mapper_destroy(idn_mapper_t ctx);
+
+/*
+ * Increment reference count of the mapper `ctx' created by
+ * 'idn_mapper_create'.
+ */
+IDN_EXPORT void
+idn_mapper_incrref(idn_mapper_t ctx);
+
+/*
+ * Add mapping scheme `name' to the mapper to `ctx'.
+ * 
+ * Returns:
+ *      idn_success             -- ok.
+ *      idn_invalid_name        -- the given name is not valid.
+ *      idn_nomemory            -- malloc failed.
+ */
+IDN_EXPORT idn_result_t
+idn_mapper_add(idn_mapper_t ctx, const char *name);
+
+IDN_EXPORT idn_result_t
+idn_mapper_addall(idn_mapper_t ctx, const char **names, int nnames);
+
+/*
+ * Map an UCS4 string.  All mapping schemes regsitered in `ctx'
+ * are applied in the regisration order.
+ *
+ * Returns:
+ *      idn_success             -- ok.
+ *      idn_nomemory            -- malloc failed.
+ *      idn_buffer_overflow     -- output buffer is too small.
+ */
+IDN_EXPORT idn_result_t
+idn_mapper_map(idn_mapper_t ctx, const unsigned long *from,
+              unsigned long *to, size_t tolen);
+
+/*
+ * Mapping procedure type.
+ */
+typedef idn_result_t (*idn_mapper_createproc_t)(const char *parameter,
+                                               void **ctxp);
+typedef void         (*idn_mapper_destroyproc_t)(void *ctxp);
+typedef idn_result_t (*idn_mapper_mapproc_t)(void *ctx,
+                                            const unsigned long *from,
+                                             unsigned long *, size_t);
+                                              
+/*
+ * Register a new mapping scheme.
+ *
+ * You can override the default normalization schemes, if you want.
+ * 
+ * Returns:
+ *      idn_success             -- ok.
+ *      idn_nomemory            -- malloc failed.
+ */
+IDN_EXPORT idn_result_t
+idn_mapper_register(const char *prefix,
+                   idn_mapper_createproc_t create,
+                   idn_mapper_destroyproc_t destroy,
+                   idn_mapper_mapproc_t map);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* IDN_MAPPER_H */
diff --git a/contrib/idn/idnkit-1.0-src/include/idn/mapselector.h b/contrib/idn/idnkit-1.0-src/include/idn/mapselector.h
new file mode 100644 (file)
index 0000000..24485ca
--- /dev/null
@@ -0,0 +1,165 @@
+/* $Id: mapselector.h,v 1.1 2003/06/04 00:25:39 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.
+ */
+
+#ifndef IDN_MAPSELECTOR_H
+#define IDN_MAPSELECTOR_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Map selector.
+ *
+ * Perfom mapping the specified domain name according with the TLD
+ * of the donmain name.
+ */
+
+#include <idn/export.h>
+#include <idn/result.h>
+#include <idn/mapper.h>
+
+/*
+ * Special TLDs for map selection.
+ */
+#define IDN_MAPSELECTOR_NOTLD          "-"
+#define IDN_MAPSELECTOR_DEFAULTTLD     "."
+
+IDN_EXPORT const unsigned long *
+idn_mapselector_getnotld(void);
+
+IDN_EXPORT const unsigned long *
+idn_mapselector_getdefaulttld(void);
+
+/*
+ * Mapselector object type.
+ */
+typedef struct idn_mapselector *idn_mapselector_t;
+
+/*
+ * Initialize module.  Must be called before any other calls of
+ * the functions of this module.
+ *
+ * Returns:
+ *      idn_success             -- ok.
+ *      idn_nomemory            -- malloc failed.
+ */
+IDN_EXPORT idn_result_t
+idn_mapselector_initialize(void);
+
+/*
+ * Create a mapselector context.
+ *
+ * Returns:
+ *      idn_success             -- ok.
+ *      idn_nomemory            -- malloc failed.
+ */
+IDN_EXPORT idn_result_t
+idn_mapselector_create(idn_mapselector_t *ctxp);
+
+/*
+ * Decrement reference count of the mapselector `ctx' created by
+ * 'idn_mapselector_create', if it is still refered by another object.
+ * Otherwise, release all the memory allocated to the mapselector.
+ */
+IDN_EXPORT void
+idn_mapselector_destroy(idn_mapselector_t ctx);
+
+/*
+ * Increment reference count of the mapselector `ctx' created by
+ * 'idn_mapselector_create'.
+ */
+IDN_EXPORT void
+idn_mapselector_incrref(idn_mapselector_t ctx);
+
+/*
+ * Return the mapper for `tld' registered in `ctx', or return NULL if
+ * mapper for `tld' is not registered.
+ */
+IDN_EXPORT idn_mapper_t
+idn_mapselector_mapper(idn_mapselector_t ctx, const char *tld);
+
+/*
+ * Add mapping scheme `name' to the mapper for `tld' to the mapselector
+ * context `ctx'.  If no mapper for `TLD' has not been registered, the
+ * function creates a new mapper for `tld', and then adds the given mapping
+ * scheme to the mapper.  Otherwise,  it adds the scheme to the mapper for
+ * TLD registered in `ctx'.
+ * 
+ * Returns:
+ *      idn_success             -- ok.
+ *      idn_invalid_name        -- the given tld or name is not valid.
+ *      idn_nomemory            -- malloc failed.
+ */
+IDN_EXPORT idn_result_t
+idn_mapselector_add(idn_mapselector_t ctx, const char *tld, const char *name);
+
+IDN_EXPORT idn_result_t
+idn_mapselector_addall(idn_mapselector_t ctx, const char *tld,
+                      const char **names, int nnames);
+
+/*
+ * Map an UCS4 string with the mapper for TLD of the domain name.
+ * If there is no mapper suitable for the domain name, the function
+ * simply copies the doman name.
+ *
+ * Returns:
+ *      idn_success             -- ok.
+ *      idn_nomemory            -- malloc failed.
+ *      idn_buffer_overflow     -- output buffer is too small.
+ *     idn_invalid_name        -- the given tld is not valid.
+ */
+IDN_EXPORT idn_result_t
+idn_mapselector_map(idn_mapselector_t ctx, const unsigned long *from,
+                   const char *tld, unsigned long *to, size_t tolen);
+
+IDN_EXPORT idn_result_t
+idn_mapselector_map2(idn_mapselector_t ctx, const unsigned long *from,
+                    const unsigned long *tld, unsigned long *to,
+                    size_t tolen);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* IDN_MAPSELECTOR_H */
diff --git a/contrib/idn/idnkit-1.0-src/include/idn/nameprep.h b/contrib/idn/idnkit-1.0-src/include/idn/nameprep.h
new file mode 100644 (file)
index 0000000..57f6fe5
--- /dev/null
@@ -0,0 +1,185 @@
+/* $Id: nameprep.h,v 1.1 2003/06/04 00:25:39 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.
+ */
+
+#ifndef IDN_NAMEPREP_H
+#define IDN_NAMEPREP_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Perform NAMEPREP (mapping, prohibited/unassigned checking).
+ */
+
+#include <idn/export.h>
+#include <idn/result.h>
+
+/*
+ * BIDI type codes.
+ */      
+typedef enum {
+       idn_biditype_r_al,
+       idn_biditype_l,
+       idn_biditype_others
+} idn_biditype_t;
+
+/*
+ * A Handle for nameprep operations.
+ */
+typedef struct idn_nameprep *idn_nameprep_t;
+
+
+/*
+ * The latest version of nameprep.
+ */
+#define IDN_NAMEPREP_CURRENT   "RFC3491"
+
+/*
+ * Create a handle for nameprep operations.
+ * The handle is stored in '*handlep', which is used other functions
+ * in this module.
+ * The version of the NAMEPREP specification can be specified with
+ * 'version' parameter.  If 'version' is NULL, the latest version
+ * is used.
+ *
+ * Returns:
+ *     idn_success             -- ok.
+ *     idn_notfound            -- specified version not found.
+ */
+IDN_EXPORT idn_result_t
+idn_nameprep_create(const char *version, idn_nameprep_t *handlep);
+
+/*
+ * Close a handle, which was created by 'idn_nameprep_create'.
+ */
+IDN_EXPORT void
+idn_nameprep_destroy(idn_nameprep_t handle);
+
+/*
+ * Perform character mapping on an UCS4 string specified by 'from', and
+ * store the result into 'to', whose length is specified by 'tolen'.
+ *
+ * Returns:
+ *     idn_success             -- ok.
+ *     idn_buffer_overflow     -- result buffer is too small.
+ */
+IDN_EXPORT idn_result_t
+idn_nameprep_map(idn_nameprep_t handle, const unsigned long *from,
+                unsigned long *to, size_t tolen);
+
+/*
+ * Check if an UCS4 string 'str' contains any prohibited characters specified
+ * by the draft.  If found, the pointer to the first such character is stored
+ * into '*found'.  Otherwise '*found' will be NULL.
+ *
+ * Returns:
+ *     idn_success             -- check has been done properly. (But this
+ *                                does not mean that no prohibited character
+ *                                was found.  Check '*found' to see the
+ *                                result.)
+ */
+IDN_EXPORT idn_result_t
+idn_nameprep_isprohibited(idn_nameprep_t handle, const unsigned long *str,
+                         const unsigned long **found);
+
+/*
+ * Check if an UCS4 string 'str' contains any unassigned characters specified
+ * by the draft.  If found, the pointer to the first such character is stored
+ * into '*found'.  Otherwise '*found' will be NULL.
+ *
+ * Returns:
+ *     idn_success             -- check has been done properly. (But this
+ *                                does not mean that no unassinged character
+ *                                was found.  Check '*found' to see the
+ *                                result.)
+ */
+IDN_EXPORT idn_result_t
+idn_nameprep_isunassigned(idn_nameprep_t handle, const unsigned long *str,
+                         const unsigned long **found);
+
+/*
+ * Check if an UCS4 string 'str' is valid string specified by ``bidi check''
+ * of the draft.  If it is not valid, the pointer to the first invalid
+ * character is stored into '*found'.  Otherwise '*found' will be NULL.
+ *
+ * Returns:
+ *     idn_success             -- check has been done properly. (But this
+ *                                does not mean that the string was valid.
+ *                                Check '*found' to see the result.)
+ */
+IDN_EXPORT idn_result_t
+idn_nameprep_isvalidbidi(idn_nameprep_t handle, const unsigned long *str,
+                        const unsigned long **found);
+
+/*
+ * The following functions are for internal use.
+ * They are used for this module to be add to the checker and mapper modules.
+ */
+IDN_EXPORT idn_result_t
+idn_nameprep_createproc(const char *parameter, void **handlep);
+
+IDN_EXPORT void
+idn_nameprep_destroyproc(void *handle);
+
+IDN_EXPORT idn_result_t
+idn_nameprep_mapproc(void *handle, const unsigned long *from,
+                    unsigned long *to, size_t tolen);
+
+IDN_EXPORT idn_result_t
+idn_nameprep_prohibitproc(void *handle, const unsigned long *str,
+                         const unsigned long **found);
+
+IDN_EXPORT idn_result_t
+idn_nameprep_unassignedproc(void *handle, const unsigned long *str,
+                           const unsigned long **found);
+
+IDN_EXPORT idn_result_t
+idn_nameprep_bidiproc(void *handle, const unsigned long *str,
+                     const unsigned long **found);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* IDN_NAMEPREP_H */
diff --git a/contrib/idn/idnkit-1.0-src/include/idn/normalizer.h b/contrib/idn/idnkit-1.0-src/include/idn/normalizer.h
new file mode 100644 (file)
index 0000000..85a1103
--- /dev/null
@@ -0,0 +1,155 @@
+/* $Id: normalizer.h,v 1.1 2003/06/04 00:25:40 marka Exp $ */
+/*
+ * 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.
+ */
+
+#ifndef IDN_NORMALIZER_H
+#define IDN_NORMALIZER_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Domain name normalizer.
+ *
+ * Perform normalization on the specified strings.  String must be
+ * in UCS4 encoding.
+ */
+
+#include <idn/export.h>
+#include <idn/result.h>
+
+/*
+ * Normalizer type (opaque).
+ */
+typedef struct idn_normalizer *idn_normalizer_t;
+
+/*
+ * Normalizer procedure type.
+ */
+typedef idn_result_t (*idn_normalizer_proc_t)(const unsigned long *from,
+                                             unsigned long *to, size_t tolen);
+
+/*
+ * Initialize this module.
+ *
+ * Returns:
+ *     idn_success             -- ok.
+ *     idn_nomemory            -- malloc failed.
+ */
+IDN_EXPORT idn_result_t
+idn_normalizer_initialize(void);
+
+/*
+ * Create a empty normalizer.
+ *
+ * Returns:
+ *     idn_success             -- ok.
+ *     idn_nomemory            -- malloc failed.
+ */
+IDN_EXPORT idn_result_t
+idn_normalizer_create(idn_normalizer_t *ctxp);
+
+/*
+ * Decrement reference count of the normalizer `ctx' created by
+ * 'idn_normalizer_create', if it is still refered by another object.
+ * Otherwise, release all the memory allocated to the normalizer.
+ */
+IDN_EXPORT void
+idn_normalizer_destroy(idn_normalizer_t ctx);
+
+/*
+ * Increment reference count of the normalizer `ctx' created by
+ * 'idn_normalizer_create'.
+ */
+IDN_EXPORT void
+idn_normalizer_incrref(idn_normalizer_t ctx);
+
+/*
+ * Add a normalization scheme to a normalizer.
+ *
+ * Multiple shemes can be added to a normalizer, and they will be
+ * applied in order.
+ *
+ * Returns:
+ *     idn_success             -- ok.
+ *     idn_invalid_name        -- unknown scheme was specified.
+ *     idn_nomemory            -- malloc failed.
+ */
+IDN_EXPORT idn_result_t
+idn_normalizer_add(idn_normalizer_t ctx, const char *scheme_name);
+
+IDN_EXPORT idn_result_t
+idn_normalizer_addall(idn_normalizer_t ctx, const char **scheme_names,
+                     int nschemes);
+
+/*
+ * Perform normalization(s) defined by a normalizer to the specified string, 
+ * If the normalizer has two or more normalization schemes, they are
+ * applied in order.
+ *
+ * Returns:
+ *     idn_success             -- ok.
+ *     idn_buffer_overflow     -- output buffer is too small.
+ *     idn_nomemory            -- malloc failed.
+ */
+IDN_EXPORT idn_result_t
+idn_normalizer_normalize(idn_normalizer_t ctx, const unsigned long *from,
+                        unsigned long *to, size_t tolen);
+
+/*
+ * Register a new normalization scheme.
+ *
+ * You can override the default normalization schemes, if you want.
+ *
+ * Returns:
+ *     idn_success             -- ok.
+ *     idn_nomemory            -- malloc failed.
+ */
+IDN_EXPORT idn_result_t
+idn_normalizer_register(const char *scheme_name, idn_normalizer_proc_t proc);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* IDN_NORMALIZER_H */
diff --git a/contrib/idn/idnkit-1.0-src/include/idn/punycode.h b/contrib/idn/idnkit-1.0-src/include/idn/punycode.h
new file mode 100644 (file)
index 0000000..32cf147
--- /dev/null
@@ -0,0 +1,70 @@
+/* $Id: punycode.h,v 1.1 2003/06/04 00:25:40 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.
+ */
+
+#ifndef IDN_PUNYCODE_H
+#define IDN_PUNYCODE_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Punycode Converter.
+ */
+
+#include <idn/result.h>
+#include <idn/converter.h>
+
+extern idn_result_t
+idn__punycode_decode(idn_converter_t ctx, void *privdata,
+                   const char *from, unsigned long *to, size_t tolen);
+
+extern idn_result_t
+idn__punycode_encode(idn_converter_t ctx, void *privdata,
+                   const unsigned long *from, char *to, size_t tolen);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* IDN_PUNYCODE_H */
diff --git a/contrib/idn/idnkit-1.0-src/include/idn/race.h b/contrib/idn/idnkit-1.0-src/include/idn/race.h
new file mode 100644 (file)
index 0000000..bb713a2
--- /dev/null
@@ -0,0 +1,72 @@
+/* $Id: race.h,v 1.1 2003/06/04 00:25:40 marka Exp $ */
+/*
+ * 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.
+ */
+
+#ifndef IDN_RACE_H
+#define IDN_RACE_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * RACE Converter.
+ *
+ * See Internet Draft draft-ietf-idn-race-03.txt for details.
+ */
+
+#include <idn/result.h>
+#include <idn/converter.h>
+
+extern idn_result_t
+idn__race_encode(idn_converter_t ctx, void *privdata,
+                const unsigned long *from, char *to, size_t tolen);
+
+extern idn_result_t
+idn__race_decode(idn_converter_t ctx, void *privdata,
+                const char *from, unsigned long *to, size_t tolen);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* IDN_RACE_H */
diff --git a/contrib/idn/idnkit-1.0-src/include/idn/res.h b/contrib/idn/idnkit-1.0-src/include/idn/res.h
new file mode 100644 (file)
index 0000000..7502543
--- /dev/null
@@ -0,0 +1,309 @@
+/* $Id: res.h,v 1.1 2003/06/04 00:25:41 marka Exp $ */
+/*
+ * 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.
+ */
+
+#ifndef IDN_RES_H
+#define IDN_RES_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Resolver library support.
+ *
+ * All the functions provided by this module requires IDN resolver
+ * configuration context of type 'idn_resconf_t' as an argument.
+ * This context holds information described in the configuration file
+ * (idn.conf).  See idn_resconf module for details.
+ *
+ * All functions also accept NULL as the context, but since
+ * no conversion/normalization will be done in this case, it is
+ * pretty useless.
+ */
+
+#include <idn/export.h>
+#include <idn/resconf.h>
+#include <idn/result.h>
+
+typedef unsigned long idn_action_t;
+
+/*
+ * Actions
+ */
+#define IDN_LOCALCONV  0x00000001 /* Local encoding <-> UTF-8 conversion */
+#define IDN_DELIMMAP   0x00000002 /* Delimiter mapping */
+#define IDN_LOCALMAP   0x00000004 /* Local mapping */
+#define IDN_MAP                0x00000008 /* NAMEPREP map */
+#define IDN_NORMALIZE  0x00000010 /* NAMEPREP normalize */
+#define IDN_PROHCHECK  0x00000020 /* NAMEPREP prohibited character check */
+#define IDN_UNASCHECK  0x00000040 /* Unassigned code point check */
+#define IDN_BIDICHECK  0x00000080 /* bidirectional string check */
+#define IDN_ASCCHECK   0x00000100 /* Non-LDH ASCII check */
+#define IDN_IDNCONV    0x00000200 /* UTF-8 <-> IDN encoding conversion */
+#define IDN_LENCHECK   0x00000400 /* Label length check */
+#define IDN_RTCHECK    0x00000800 /* Round trip check */
+#define IDN_UNDOIFERR  0x00001000 /* Option: undo if error occurs */
+
+#define IDN_ENCODE_QUERY       0x00002000 /* Encode query string */
+#define IDN_DECODE_QUERY       0x00004000 /* Decode query string */
+
+#define IDN_ENCODE_APP \
+(IDN_ENCODE_QUERY | IDN_ASCCHECK)      /* Standard encode */
+#define IDN_DECODE_APP \
+(IDN_DECODE_QUERY | IDN_ASCCHECK)      /* Standard decode */
+
+#define IDN_ENCODE_STORED \
+(IDN_ENCODE_QUERY | IDN_ASCCHECK | IDN_UNASCHECK) /* Encode query string */
+#define IDN_DECODE_STORED \
+(IDN_DECODE_QUERY | IDN_ASCCHECK | IDN_UNASCHECK) /* Decode query string */
+
+
+#define IDN_NAMEPREP \
+(IDN_MAP | IDN_NORMALIZE | IDN_PROHCHECK | IDN_BIDICHECK)
+
+/*
+ * Enable or disable IDN conversion scheme.
+ *
+ * If on_off is 0, IDN conversion scheme is disabled. Otherwise, IDN
+ * conversion is enabled even when IDN_DISABLE is defined.
+ */
+IDN_EXPORT void
+idn_res_enable(int on_off);
+
+/*
+ * Encode internationalized domain name.
+ *
+ * The encoding process consists of the following 7 steps.
+ *
+ *    1. Local encoding to UTF-8 conversion
+ *       Converts a domain name written with local encoding (e.g. ISO-
+ *       8859-1) to UTF-8.
+ *    2. Delimiter mapping,
+ *       Maps certain characters to period (U+002E, FULL STOP).
+ *    3. Local mapping
+ *       Apply character mappings according with the TLD of the domain
+ *       name.
+ *    4. NAMEPREP
+ *       Perform NAME preparation described in RFC3491.
+ *       This step consists of the following 4 steps:
+ *       4.1. Mapping
+ *       4.2. Normalization
+ *       4.3. Prohibited character check
+ *       4.4. Unassigned check
+ *    5. ASCII range character check
+ *       Checks if the domain name contains non-LDH ASCII character (not
+ *       alpha-numeric or hypen), or it begins or end with hypen.
+ *    6. UTF-8 to IDN encoding conversion.
+ *       Converts the domain name from UTF-8 to ACE (e.g. Punycode).
+ *    7. Length check
+ *       Checks the length of each label.
+ *
+ * 'actions' specifies actions and options of the encoding procedure.
+ * Its value is a bitwise-or of the following flags:
+ *
+ *   IDN_LOCALCONV     -- perform local encoding to UTF-8 conversion (step 1)
+ *   IDN_DELIMMAP      -- perform delimiter mapping (step 2)
+ *   IDN_LOCALMAP      -- perform local mapping (step 3)
+ *   IDN_MAP           -- perform mapping (step 4.1)
+ *   IDN_NORMALIZE     -- perform normalization (step 4.2)
+ *   IDN_PROHCHECK     -- perform prohibited character check (step 4.3)
+ *   IDN_UNASCHECK     -- perform unassigned codepoint check (step 4.4)
+ *   IDN_ASCCHECK      -- perform ASCII range character check (step 5)
+ *   IDN_IDNCONV       -- perform UTF-8 to IDN encoding conversion (step 6)
+ *   IDN_LENCHECK      -- perform length check (step 7)
+ *
+ * Also the following flags are provided for convinience:
+ *
+ *   IDN_ENCODE_QUERY  -- On libidnkit, perform step 1..7, except for step
+ *                        4.4 and 5.
+ *                        On libidnkitlite, perform step 2..7, except for
+ *                        step 4.4 and 5.
+ *   IDN_ENCODE_STORED -- On libidnkit, perform step 1..7, except for step
+ *                        5.
+ *                        On libidnkitlite, perform step 2..7, except for
+ *                        step 5.
+ *   IDN_ENCODE_APP    -- Same as IDN_ENCODE_QUERY.
+ *   IDN_NAMEPREP      -- perform NAMEPREP (step 4) without unassigned
+ *                        codepoint check (step 4.4).
+ *
+ * The following flag does not corresponding to a particular action,
+ * but an option of conversion process:
+ *
+ *   IDN_UNDOIFERR     -- If any step fails, the original input name is
+ *                         returned.
+ *
+ * Note that if no flags are specified, 'idn_encodename' does nothing
+ * fancy, just copies the given name verbatim.
+ *
+ * Returns:
+ *     idn_success             -- ok.
+ *     idn_invalid_action      -- invalid action flag specified.
+ *     idn_invalid_encoding    -- the given string has invalid/illegal
+ *                                byte sequence.
+ *     idn_invalid_length      -- invalid length of a label.
+ *     idn_prohibited          -- prohibited/unassigned code point found.
+ *     idn_buffer_overflow     -- 'tolen' is too small.
+ *     idn_nomemory            -- malloc failed.
+ *
+ * Also, if this function is called without calling 'idn_nameinit',
+ * the following error codes might be returned.
+ *     idn_nofile              -- cannot open the configuration file.
+ *     idn_invalid_syntax      -- syntax error found in the file.
+ *     idn_invalid_name        -- there are invalid names (encoding,
+ *                                normalization etc.).
+ */
+IDN_EXPORT idn_result_t
+idn_res_encodename(idn_resconf_t ctx, idn_action_t actions, const char *from,
+                  char *to, size_t tolen);
+
+/*
+ * Decode internationalized domain name.
+ *
+ * The decoding process consists of the following 5 steps.
+ *
+ *    1. delimiter mapping
+ *       Maps certain characters to period (U+002E, FULL STOP).
+ *    2. NAMEPREP
+ *       Perform NAME preparation described in RFC3491.
+ *       This step consists of the following 4 steps:
+ *       2.1. Mapping
+ *       2.2. Normalization
+ *       2.3. Prohibited character check
+ *       2.4. Unassigned check
+ *    3. IDN encoding to UTF-8 conversion.
+ *       Converts the domain name from ACE (e.g. Punycode) to UCS4.
+ *    4. Perform round-trip check.
+ *       Encode the result of step 3, and then compare it with the result
+ *       of the step 2.  If they are different, the check is failed.
+ *    5. Convert UTF-8 to local encoding.
+ *       If a character in the domain name cannot be converted to local
+ *       encoding, the conversion is failed.
+ *
+ * 'actions' specifies actions of the decoding procedure.
+ * Its value is a bitwise-or of the following flags:
+ *
+ *   IDN_DELIMMAP      -- perform delimiter mapping (step 1)
+ *   IDN_MAP           -- perform mapping (step 2.1)
+ *   IDN_NORMALIZE     -- perform normalization (step 2.2)
+ *   IDN_PROHCHECK     -- perform prohibited character check (step 2.3)
+ *   IDN_UNASCHECK     -- perform unassigned codepoint check (step 2.4)
+ *   IDN_IDNCONV       -- perform IDN encoding to UTF-8 conversion (step 3)
+ *   IDN_RTCHECK        -- perform round-trip check (step 4)
+ *   IDN_ASCCHECK      -- perform ASCII range character check while
+ *                        round-trip check (step 4.1)
+ *   IDN_LOCALCONV      -- perform UTF-8 to local encoding conversion (step 5)
+ *
+ * Also the following flags are provided for the convenience:
+ *
+ *   IDN_DECODE_QUERY  -- On libidnkit, perform step 1..5, except for step
+ *                        2.4 and 4.1.
+ *                        On libidnkitlite, perform step 1..3, except for
+ *                        step 2.4 and 4.1.
+ *   IDN_DECODE_STORED -- On libidnkit, perform step 1..5, except for step
+ *                        4.1.
+ *                        On libidnkitlite, perform step 1..3, except for
+ *                        step 4.1.
+ *   IDN_DECODE_APP    -- Same as IDN_DECODE_QUERY.
+ *   IDN_NAMEPREP      -- perform NAMEPREP (step 2) without unassigned
+ *                        codepoint check (step 2.4).
+ *
+ * If any step fails, the original input name is returned.
+ * 'actions' specifies what actions to take when decoding, and is
+ * a bitwise-or of the following flags:
+ *
+ * Note that if no flags are specified, 'idn_decodename' does nothing
+ * but copying the given name verbatim.
+ *
+ * Returns:
+ *     idn_success             -- ok.
+ *     idn_invalid_action      -- invalid action flag specified.
+ *     idn_invalid_encoding    -- the given string has invalid/illegal
+ *                                byte sequence.
+ *     idn_buffer_overflow     -- 'tolen' is too small.
+ *     idn_invalid_action      -- length of a label is not 1..63 characters.
+ *     idn_nomemory            -- malloc failed.
+ *
+ * Also, if this function is called without calling 'idn_nameinit',
+ * the following error codes might be returned.
+ *     idn_nofile              -- cannot open the configuration file.
+ *     idn_invalid_syntax      -- syntax error found in the file.
+ *     idn_invalid_name        -- there are invalid names (encoding,
+ *                                normalization etc.).
+ */
+IDN_EXPORT idn_result_t
+idn_res_decodename(idn_resconf_t ctx, idn_action_t actions, const char *from,
+                  char *to, size_t tolen);
+
+/*
+ * Decode internationalized domain name with auxiliary encoding
+ * support.
+ *
+ * This is another API for IDN string decode.  The difference between
+ * two is whether the encoding conversion from auxiliary encoding to
+ * UTF-8 occurs prior to the actual decode process (read description
+ * of idn_res_decodename() above) or not.
+ *
+ * If auxencoding is NULL, from is treated as UTF-8 encoded string.
+ * 
+ * Other arguments serve exactly same role as those of
+ * idn_res_decodename().
+ */
+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);
+
+/*
+ * Convert `actions' to a string, and then return the string.
+ * This function is for internal use only.
+ *
+ * Note that this function returns a pointer to static buffer.
+ */
+extern const char *
+idn__res_actionstostring(idn_action_t actions);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* IDN_RES_H */
diff --git a/contrib/idn/idnkit-1.0-src/include/idn/resconf.h b/contrib/idn/idnkit-1.0-src/include/idn/resconf.h
new file mode 100644 (file)
index 0000000..876b31b
--- /dev/null
@@ -0,0 +1,323 @@
+/* $Id: resconf.h,v 1.1 2003/06/04 00:25:41 marka Exp $ */
+/*
+ * 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.
+ */
+
+#ifndef IDN_RESCONF_H
+#define IDN_RESCONF_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * IDN resolver configuration.
+ */
+
+#include <idn/export.h>
+#include <idn/result.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>
+
+/*
+ * Configuration type (opaque).
+ */
+typedef struct idn_resconf *idn_resconf_t;
+
+/*
+ * Initialize.
+ *
+ * Initialize this module and underlying ones.  Must be called before
+ * any other functions of this module.
+ *
+ * Returns:
+ *     idn_success             -- ok.
+ *     idn_nomemory            -- malloc failed.
+ */
+IDN_EXPORT idn_result_t
+idn_resconf_initialize(void);
+
+/*
+ * Create a configuration context.
+ *
+ * Create an empty context and store it in '*ctxp'.
+ *
+ * Returns:
+ *     idn_success             -- ok.
+ *     idn_nomemory            -- malloc failed.
+ */
+IDN_EXPORT idn_result_t
+idn_resconf_create(idn_resconf_t *ctxp);
+
+/*
+ * Destroy the configuration context.
+ *
+ * Destroy the configuration context created by 'idn_resconf_create',
+ * and release memory for it.
+ */
+IDN_EXPORT void
+idn_resconf_destroy(idn_resconf_t ctx);
+
+/*
+ * Increment reference count of the context created by 'idn_resconf_create'.
+ */
+IDN_EXPORT void
+idn_resconf_incrref(idn_resconf_t ctx);
+
+/*
+ * Set default configurations to resconf context.
+ *
+ * "default configurations" means current nameprep and IDN encoding
+ * which IDN standard document suggests.
+ * 
+ * Warning: configurations set previously are removed.
+ * 
+ * Returns:
+ *     idn_success             -- ok.
+ *     idn_invalid_syntax      -- syntax error found.
+ *     idn_invalid_name        -- invalid encoding/nomalization name is
+ *                                specified.
+ *     idn_nomemory            -- malloc failed.
+ */
+IDN_EXPORT idn_result_t
+idn_resconf_setdefaults(idn_resconf_t ctx);
+
+/*
+ * Load configuration file.
+ *
+ * Parse a configuration file whose name is specified by 'file',
+ * store the result in 'ctx'.  If 'file' is NULL, the default file is
+ * loaded.
+ *
+ * Returns:
+ *     idn_success             -- ok.
+ *     idn_nofile              -- couldn't open specified file.
+ *     idn_invalid_syntax      -- syntax error found.
+ *     idn_invalid_name        -- invalid encoding/nomalization name is
+ *                                specified.
+ *     idn_nomemory            -- malloc failed.
+ */
+IDN_EXPORT idn_result_t
+idn_resconf_loadfile(idn_resconf_t ctx, const char *file);
+
+/*
+ * Get the pathname of the default configuration file.
+ *
+ * Returns:
+ *     the pathname of the default configuration file.
+ */
+IDN_EXPORT char *
+idn_resconf_defaultfile(void);
+
+/*
+ * Get an object of lower module that `ctx' holds.
+ */
+IDN_EXPORT idn_delimitermap_t
+idn_resconf_getdelimitermap(idn_resconf_t ctx);
+
+IDN_EXPORT idn_converter_t
+idn_resconf_getidnconverter(idn_resconf_t ctx);
+
+IDN_EXPORT idn_converter_t
+idn_resconf_getauxidnconverter(idn_resconf_t ctx);
+
+IDN_EXPORT idn_converter_t
+idn_resconf_getlocalconverter(idn_resconf_t ctx);
+
+IDN_EXPORT idn_mapselector_t
+idn_resconf_getlocalmapselector(idn_resconf_t ctx);
+
+IDN_EXPORT idn_mapper_t
+idn_resconf_getmapper(idn_resconf_t ctx);
+
+IDN_EXPORT idn_normalizer_t
+idn_resconf_getnormalizer(idn_resconf_t ctx);
+
+IDN_EXPORT idn_checker_t
+idn_resconf_getprohibitchecker(idn_resconf_t ctx);
+
+IDN_EXPORT idn_checker_t
+idn_resconf_getunassignedchecker(idn_resconf_t ctx);
+
+IDN_EXPORT idn_checker_t
+idn_resconf_getbidichecker(idn_resconf_t ctx);
+
+/*
+ * Set an object of lower module to `ctx'.
+ */
+IDN_EXPORT void
+idn_resconf_setdelimitermap(idn_resconf_t ctx,
+                           idn_delimitermap_t delimiter_mapper);
+
+IDN_EXPORT void
+idn_resconf_setidnconverter(idn_resconf_t ctx,
+                            idn_converter_t idn_coverter);
+
+IDN_EXPORT void
+idn_resconf_setauxidnconverter(idn_resconf_t ctx,
+                               idn_converter_t aux_idn_coverter);
+
+IDN_EXPORT void
+idn_resconf_setlocalconverter(idn_resconf_t ctx,
+                             idn_converter_t local_converter);
+
+IDN_EXPORT void
+idn_resconf_setlocalmapselector(idn_resconf_t ctx,
+                               idn_mapselector_t map_selector);
+
+IDN_EXPORT void
+idn_resconf_setmapper(idn_resconf_t ctx, idn_mapper_t mapper);
+
+IDN_EXPORT void
+idn_resconf_setnormalizer(idn_resconf_t ctx, idn_normalizer_t normalizer);
+
+IDN_EXPORT void
+idn_resconf_setprohibitchecker(idn_resconf_t ctx,
+                              idn_checker_t prohibit_checker);
+
+IDN_EXPORT void
+idn_resconf_setunassignedchecker(idn_resconf_t ctx,
+                                idn_checker_t unassigned_checker);
+
+IDN_EXPORT void
+idn_resconf_setbidichecker(idn_resconf_t ctx,
+                          idn_checker_t bidi_checker);
+
+/*
+ * Set name or add names to an object of lower module that `ctx' holds.
+ */
+IDN_EXPORT idn_result_t
+idn_resconf_setidnconvertername(idn_resconf_t ctx, const char *name,
+                               int flags);
+
+IDN_EXPORT idn_result_t
+idn_resconf_setauxidnconvertername(idn_resconf_t ctx, const char *name,
+                                  int flags);
+
+IDN_EXPORT idn_result_t
+idn_resconf_addalldelimitermapucs(idn_resconf_t ctx, unsigned long *v, int nv);
+
+IDN_EXPORT idn_result_t
+idn_resconf_setlocalconvertername(idn_resconf_t ctx, const char *name,
+                                 int flags);
+
+IDN_EXPORT idn_result_t
+idn_resconf_addalllocalmapselectornames(idn_resconf_t ctx, const char *tld,
+                                       const char **names, int nnames);
+
+IDN_EXPORT idn_result_t
+idn_resconf_addallmappernames(idn_resconf_t ctx, const char **names,
+                             int nnames);
+
+IDN_EXPORT idn_result_t
+idn_resconf_addallnormalizernames(idn_resconf_t ctx, const char **names,
+                                 int nnames);
+
+IDN_EXPORT idn_result_t
+idn_resconf_addallprohibitcheckernames(idn_resconf_t ctx, const char **names,
+                                      int nnames);
+
+IDN_EXPORT idn_result_t
+idn_resconf_addallunassignedcheckernames(idn_resconf_t ctx, const char **names,
+                                        int nnames);
+
+IDN_EXPORT idn_result_t
+idn_resconf_addallbidicheckernames(idn_resconf_t ctx, const char **names,
+                                  int nnames);
+
+IDN_EXPORT idn_result_t
+idn_resconf_setnameprepversion(idn_resconf_t ctx, const char *version);
+
+/*
+ * These macros are provided for backward compatibility to mDNkit 2.1
+ * and older.
+ */
+IDN_EXPORT void
+idn_resconf_setalternateconverter(idn_resconf_t ctx,
+                                  idn_converter_t alternate_converter);
+
+IDN_EXPORT idn_result_t
+idn_resconf_setalternateconvertername(idn_resconf_t ctx, const char *name,
+                                     int flags);
+
+IDN_EXPORT idn_converter_t
+idn_resconf_getalternateconverter(idn_resconf_t ctx);
+
+
+/*
+ * These macros are provided for backward compatibility to idnkit 1.x.
+ */
+#define idn_resconf_localconverter(ctx) \
+       idn_resconf_getlocalconverter(ctx)
+
+#define idn_resconf_idnconverter(ctx) \
+       idn_resconf_getidnconverter(ctx)
+
+#define idn_resconf_alternateconverter(ctx) \
+       idn_resconf_getalternateconverter(ctx)
+
+#define idn_resconf_normalizer(ctx) \
+       idn_resconf_getnormalizer(ctx)
+
+#define idn_resconf_mapper(ctx) \
+       idn_resconf_getmapper(ctx)
+
+#define idn_resconf_delimitermap(ctx) \
+       idn_resconf_getdelimitermap(ctx)
+
+#define idn_resconf_localmapselector(ctx) \
+       idn_resconf_getlocalmapselector(ctx)
+
+#define idn_resconf_prohibitchecker(ctx) \
+       idn_resconf_getprohibitchecker(ctx)
+
+#define idn_resconf_unassignedchecker(ctx) \
+       idn_resconf_getunassignedchecker(ctx)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* IDN_RESCONF_H */
diff --git a/contrib/idn/idnkit-1.0-src/include/idn/result.h b/contrib/idn/idnkit-1.0-src/include/idn/result.h
new file mode 100644 (file)
index 0000000..968f9a9
--- /dev/null
@@ -0,0 +1,86 @@
+/* $Id: result.h,v 1.1 2003/06/04 00:25:42 marka Exp $ */
+/*
+ * 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.
+ */
+
+#ifndef IDN_RESULT_H
+#define IDN_RESULT_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <idn/export.h>
+
+/*
+ * libidnkit result code.
+ */
+typedef enum {
+       idn_success,
+       idn_notfound,
+       idn_invalid_encoding,
+       idn_invalid_syntax,
+       idn_invalid_name,
+       idn_invalid_message,
+       idn_invalid_action,
+       idn_invalid_codepoint,
+       idn_invalid_length,
+       idn_buffer_overflow,
+       idn_noentry,
+       idn_nomemory,
+       idn_nofile,
+       idn_nomapping,
+       idn_context_required,
+       idn_prohibited,
+       idn_failure     /* !!This must be the last one!! */
+} idn_result_t;
+
+/*
+ * Get the string description of a result code.
+ */
+IDN_EXPORT char *
+idn_result_tostring(idn_result_t result);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* IDN_RESULT_H */
diff --git a/contrib/idn/idnkit-1.0-src/include/idn/strhash.h b/contrib/idn/idnkit-1.0-src/include/idn/strhash.h
new file mode 100644 (file)
index 0000000..88154c7
--- /dev/null
@@ -0,0 +1,123 @@
+/* $Id: strhash.h,v 1.1 2003/06/04 00:25:42 marka Exp $ */
+/*
+ * 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.
+ */
+
+#ifndef IDN_STRHASH_H
+#define IDN_STRHASH_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * String-keyed hash table
+ *
+ * Just a hash table.  Nothing special.  Number of hash buckets
+ * grows automatically.
+ */
+
+#include <idn/result.h>
+
+/*
+ * Hash table type, which is opaque.
+ */
+typedef struct idn__strhash *idn__strhash_t;
+
+/*
+ * Hash value free proc.
+ */
+typedef void (*idn__strhash_freeproc_t)(void *value);
+
+/*
+ * Create a hash table.
+ *
+ * Returns:
+ *     idn_success             -- ok.
+ *     idn_nomemory            -- malloc failed.
+ */
+extern idn_result_t
+idn__strhash_create(idn__strhash_t *hashp);
+
+/*
+ * Delete a hash table created by 'idn__strhash_create'.
+ * If 'proc' is not NULL, it is called for each value in the
+ * hash to release memory for them.
+ */
+extern void
+idn__strhash_destroy(idn__strhash_t hash, idn__strhash_freeproc_t proc);
+
+/*
+ * Register an item to the hash table.  This function makes a
+ * private copy of the key string.
+ *
+ * Returns:
+ *     idn_success             -- ok.
+ *     idn_nomemory            -- malloc failed.
+ */
+extern idn_result_t
+idn__strhash_put(idn__strhash_t hash, const char *key, void *value);
+
+/*
+ * Find an item with the specified key.
+ *
+ * Returns:
+ *     idn_success             -- ok. found.
+ *     idn_noentry             -- not found.
+ */
+extern idn_result_t
+idn__strhash_get(idn__strhash_t hash, const char *key, void **valuep);
+
+/*
+ * Check if an item with the specified key exists.
+ *
+ * Returns:
+ *     1                       -- yes.
+ *     0                       -- no.
+ */
+extern int
+idn__strhash_exists(idn__strhash_t hash, const char *key);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* IDN_STRHASH_H */
diff --git a/contrib/idn/idnkit-1.0-src/include/idn/ucs4.h b/contrib/idn/idnkit-1.0-src/include/idn/ucs4.h
new file mode 100644 (file)
index 0000000..d984be8
--- /dev/null
@@ -0,0 +1,103 @@
+/* $Id: ucs4.h,v 1.1 2003/06/04 00:25:42 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_UCS4_H
+#define IDN_UCS4_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * UCS4 encoded string facility.
+ */
+
+#include <idn/export.h>
+#include <idn/result.h>
+
+/*
+ * UCS4 to UTF-16 conversion and vice versa.
+ */
+IDN_EXPORT idn_result_t
+idn_ucs4_ucs4toutf16(const unsigned long *ucs4, unsigned short *utf16,
+                    size_t tolen);
+
+IDN_EXPORT idn_result_t
+idn_ucs4_utf16toucs4(const unsigned short *utf16, unsigned long *ucs4,
+                    size_t tolen);
+
+/*
+ * UCS4 to UTF-8 conversion and vice versa.
+ */
+IDN_EXPORT idn_result_t
+idn_ucs4_utf8toucs4(const char *utf8, unsigned long *ucs4, size_t tolen);
+
+IDN_EXPORT idn_result_t
+idn_ucs4_ucs4toutf8(const unsigned long *ucs4, char *utf8, size_t tolen);
+
+/*
+ * UCS4 version of string operation functions.
+ */
+IDN_EXPORT size_t
+idn_ucs4_strlen(const unsigned long *ucs4);
+
+IDN_EXPORT unsigned long *
+idn_ucs4_strcpy(unsigned long *to, const unsigned long *from);
+
+IDN_EXPORT unsigned long *
+idn_ucs4_strcat(unsigned long *to, const unsigned long *from);
+
+IDN_EXPORT int
+idn_ucs4_strcmp(const unsigned long *str1, const unsigned long *str2);
+
+IDN_EXPORT int
+idn_ucs4_strcasecmp(const unsigned long *str1, const unsigned long *str2);
+
+IDN_EXPORT unsigned long *
+idn_ucs4_strdup(const unsigned long *str);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* IDN_UCS4_H */
diff --git a/contrib/idn/idnkit-1.0-src/include/idn/ucsmap.h b/contrib/idn/idnkit-1.0-src/include/idn/ucsmap.h
new file mode 100644 (file)
index 0000000..fe5f9f7
--- /dev/null
@@ -0,0 +1,131 @@
+/* $Id: ucsmap.h,v 1.1 2003/06/04 00:25:42 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.
+ */
+
+#ifndef IDN_UCSMAP_H
+#define IDN_UCSMAP_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Perform UCS character mapping.
+ * This module support one-to-N mapping (N may be zero, one or more).
+ */
+
+#include <idn/export.h>
+#include <idn/result.h>
+
+/*
+ * Mapper type (opaque).
+ */
+typedef struct idn_ucsmap *idn_ucsmap_t;
+
+/*
+ * Create an empty mapping.  The reference count is set to 1.
+ *
+ * Returns:
+ *     idn_success             -- ok.
+ *     idn_nomemory            -- malloc failed.
+ */
+IDN_EXPORT idn_result_t
+idn_ucsmap_create(idn_ucsmap_t *ctxp);
+
+/*
+ * Decrement the reference count of the given set, and if it reaches zero,
+ * release all the memory allocated for it.
+ */
+IDN_EXPORT void
+idn_ucsmap_destroy(idn_ucsmap_t ctx);
+
+/*
+ * Increment the reference count of the given set by one, so that
+ * the map can be shared.
+ */
+IDN_EXPORT void
+idn_ucsmap_incrref(idn_ucsmap_t ctx);
+
+/*
+ * Add a mapping.
+ * 'ucs' is the character to be mapped, 'map' points an array of mapped
+ * characters of length 'maplen'.  'map' may be NULL if 'maplen' is zero,
+ * meaning one-to-none mapping.
+ *
+ * Returns:
+ *     idn_success             -- ok.
+ *     idn_nomemory            -- malloc failed.
+ *     idn_failure             -- already fixed by 'idn_ucsmap_fix',
+ *                                or too large maplen.
+ */
+IDN_EXPORT idn_result_t
+idn_ucsmap_add(idn_ucsmap_t ctx, unsigned long ucs, unsigned long *map,
+              size_t maplen);
+
+/*
+ * Perform internal arrangement of the map for lookup.
+ * Once it is fixed, 'idn_ucsmap_add' cannot be permitted to the map.
+ */
+IDN_EXPORT void
+idn_ucsmap_fix(idn_ucsmap_t ctx);
+
+/*
+ * Find the mapping for the given character.
+ * 'idn_ucsmap_fix' must be performed before calling this function.
+ * Find the mapping for 'v' and store the result to 'to'.  The length
+ * of the mapped sequence is stored in '*maplenp'.  'tolen' specifies
+ * the length allocated for 'to'.
+ *
+ * Returns:
+ *     idn_success             -- ok.
+ *     idn_nomapping           -- specified character has no mapping.
+ *     idn_failure             -- not fixed by 'idn_ucsmap_fix' yet.
+ */
+IDN_EXPORT idn_result_t
+idn_ucsmap_map(idn_ucsmap_t ctx, unsigned long v, unsigned long *to,
+              size_t tolen, size_t *maplenp);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* IDN_UCSMAP_H */
diff --git a/contrib/idn/idnkit-1.0-src/include/idn/ucsset.h b/contrib/idn/idnkit-1.0-src/include/idn/ucsset.h
new file mode 100644 (file)
index 0000000..ab8144d
--- /dev/null
@@ -0,0 +1,145 @@
+/* $Id: ucsset.h,v 1.1 2003/06/04 00:25:43 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.
+ */
+
+#ifndef IDN_UCSSET_H
+#define IDN_UCSSET_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * A 'set' of UCS codepoints.
+ */
+
+#include <idn/export.h>
+#include <idn/result.h>
+
+/*
+ * Type representing a set (opaque).
+ */
+typedef struct idn_ucsset *idn_ucsset_t;
+
+
+/*
+ * Create an empty set.  The reference count is set to 1.
+ *
+ * Returns:
+ *     idn_success             -- ok.
+ *     idn_nomemory            -- malloc failed.
+ */
+IDN_EXPORT idn_result_t
+idn_ucsset_create(idn_ucsset_t *ctxp);
+
+/*
+ * Decrement the reference count of the given set, and if it reaches zero,
+ * release all the memory allocated for it.
+ */
+IDN_EXPORT void
+idn_ucsset_destroy(idn_ucsset_t ctx);
+
+/*
+ * Increments the reference count by one.
+ */
+IDN_EXPORT void
+idn_ucsset_incrref(idn_ucsset_t ctx);
+
+/*
+ * Add a UCS code point to the set.
+ * The set must be in the building phase -- that is, before 'idn_ucsset_fix'
+ * is called for the set.
+ *
+ * Returns:
+ *     idn_success             -- ok.
+ *     idn_invalid_code        -- code point out of range.
+ *     idn_nomemory            -- malloc failed.
+ *     idn_failure             -- already fixed by 'idn_ucsset_fix'.
+ */
+IDN_EXPORT idn_result_t
+idn_ucsset_add(idn_ucsset_t ctx, unsigned long v);
+
+/*
+ * Add a range of code points (from 'from' to 'to', inclusive) to the set.
+ * 'from' must not be greater than 'to'.
+ * This function is similar to 'idn_ucsset_add' except that it accepts
+ * range of code points.
+ *
+ * Returns:
+ *     idn_success             -- ok.
+ *     idn_invalid_code        -- code point out of range, or the range
+ *                                specification is invalid.
+ *     idn_nomemory            -- malloc failed.
+ *     idn_failure             -- already fixed by 'idn_ucsset_fix'.
+ */
+IDN_EXPORT idn_result_t
+idn_ucsset_addrange(idn_ucsset_t ctx, unsigned long from, unsigned long to);
+
+/*
+ * Perform internal arrangement of the set for lookup.
+ * Before calling this function, a set is in 'building' phase, and code
+ * points can be added freely by 'idn_ucsset_add' or 'idn_ucsset_addrange'.
+ * But once it is fixed by this function, the set becomes immutable, and
+ * it shifts into 'lookup' phase.
+ */
+IDN_EXPORT void
+idn_ucsset_fix(idn_ucsset_t ctx);
+
+/*
+ * Find if the given code point is in the set.
+ * The set must be in the lookup phase -- in other words, 'idn_ucsset_fix'
+ * must be called for the set before calling this function.
+ * '*found' is set to 1 if the specified code point is in the set, 0 otherwise.
+ *
+ * Returns:
+ *     idn_success             -- ok.
+ *     idn_invalid_code        -- specified code point is out of range.
+ *     idn_failure             -- not fixed by 'idn_ucsset_fix' yet.
+ */
+IDN_EXPORT idn_result_t
+idn_ucsset_lookup(idn_ucsset_t ctx, unsigned long v, int *found);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* IDN_UCSSET_H */
diff --git a/contrib/idn/idnkit-1.0-src/include/idn/unicode.h b/contrib/idn/idnkit-1.0-src/include/idn/unicode.h
new file mode 100644 (file)
index 0000000..6a0f5d4
--- /dev/null
@@ -0,0 +1,164 @@
+/* $Id: unicode.h,v 1.1 2003/06/04 00:25:43 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 IDN_UNICODE_H
+#define IDN_UNICODE_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Unicode attributes retriever.
+ *
+ * All the information this module provides is based on UnicodeData.txt,
+ * CompositionExclusions-1.txt and SpecialCasing.txt, all of which can be
+ * obtained from unicode.org.
+ *
+ * Unicode characters are represented as 'unsigned long'.
+ */
+
+#include <idn/result.h>
+
+/*
+ * A Handle for Unicode versions.
+ */
+typedef struct idn__unicode_ops *idn__unicode_version_t;
+
+/*
+ * Context information for case conversion.
+ */
+typedef enum {
+       idn__unicode_context_unknown,
+       idn__unicode_context_final,
+       idn__unicode_context_nonfinal
+} idn__unicode_context_t;
+
+/*
+ * Create a handle for a specific Unicode version.
+ * The version number (such as "3.0.1") is specified by 'version' parameter.
+ * If it is NULL, the latest version is used.
+ * The handle is stored in '*versionp', which is used various functions
+ * in this and unormalize modules.
+ *
+ * Returns:
+ *     idn_success             -- ok.
+ *     idn_notfound            -- specified version not found.
+ */
+extern idn_result_t
+idn__unicode_create(const char *version, idn__unicode_version_t *versionp);
+
+/*
+ * Close a handle which was created by 'idn__unicode_create'.
+ */
+extern void
+idn__unicode_destroy(idn__unicode_version_t version);
+
+/*
+ * Get canonical class.
+ *
+ * For characters out of unicode range (i.e. above 0xffff), 0 will
+ * be returned.
+ */
+extern int
+idn__unicode_canonicalclass(idn__unicode_version_t version, unsigned long c);
+
+/*
+ * Decompose a character.
+ *
+ * Decompose character given by 'c', and put the result into 'v',
+ * which can hold 'vlen' characters.  The number of decomposed characters
+ * will be stored in '*decomp_lenp'.
+ *
+ * If 'compat' is true, compatibility decomposition is performed.
+ * Otherwise canonical decomposition is done.
+ *
+ * Since decomposition is done recursively, no further decomposition
+ * will be needed.
+ *
+ * Returns:
+ *     idn_success             -- ok, decomposed.
+ *     idn_notfound            -- no decomposition possible.
+ *     idn_buffer_overflow     -- 'vlen' is too small.
+ */
+extern 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);
+
+/*
+ * Perform canonical composition.
+ *
+ * Do canonical composition to the character sequence 'c1' and 'c2', put the
+ * result into '*compp'.
+ *
+ * Since Unicode Nomalization Froms requires only canonical composition,
+ * compatibility composition is not supported.
+ *
+ * Returns:
+ *     idn_success             -- ok, composed.
+ *     idn_notfound            -- no composition possible.
+ */
+extern idn_result_t
+idn__unicode_compose(idn__unicode_version_t version,
+                    unsigned long c1, unsigned long c2, unsigned long *compp);
+
+/*
+ * Returns if there may be a canonical composition sequence which starts
+ * with the given character.
+ *
+ * Returns:
+ *     1                       -- there may be a composition sequence
+ *                                (maybe not).
+ *     0                       -- no, there is definitely no such sequences.
+ */
+extern int
+idn__unicode_iscompositecandidate(idn__unicode_version_t version,
+                                 unsigned long c);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* IDN_UNICODE_H */
diff --git a/contrib/idn/idnkit-1.0-src/include/idn/unormalize.h b/contrib/idn/idnkit-1.0-src/include/idn/unormalize.h
new file mode 100644 (file)
index 0000000..d06d2f5
--- /dev/null
@@ -0,0 +1,86 @@
+/* $Id: unormalize.h,v 1.1 2003/06/04 00:25:44 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 IDN_UNORMALIZE_H
+#define IDN_UNORMALIZE_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Unicode Normalizations.
+ *
+ * Perform 4 normalizations defined by 'Unicode Normalization Forms'
+ * (http://www.unicode.org/unicode/reports/tr15)
+ *
+ * All of the functions use UCS4 encoding for input/output.
+ */
+
+#include <idn/result.h>
+#include <idn/unicode.h>
+
+/*
+ * Perform Unicode Normalication Form C and KC.
+ *
+ * They take NUL-terminated UCS4 encoded string 'from', perform
+ * the normalization specified by 'version', put the result
+ * (also a NUL-terminated UCS4 encoded string) to 'to', which must be
+ * able to hold at least 'tolen' bytes.
+ *
+ * Returns:
+ *     idn_success             -- ok.
+ *     idn_nomemory            -- malloc failed.
+ *     idn_buffer_overflow     -- 'tolen' is too small.
+ */
+extern idn_result_t
+idn__unormalize_formkc(idn__unicode_version_t version,
+                      const unsigned long *from, unsigned long *to,
+                      size_t tolen);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* IDN_UNORMALIZE_H */
diff --git a/contrib/idn/idnkit-1.0-src/include/idn/utf8.h b/contrib/idn/idnkit-1.0-src/include/idn/utf8.h
new file mode 100644 (file)
index 0000000..b639c20
--- /dev/null
@@ -0,0 +1,137 @@
+/* $Id: utf8.h,v 1.1 2003/06/04 00:25:44 marka Exp $ */
+/*
+ * 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.
+ */
+
+#ifndef IDN_UTF8_H
+#define IDN_UTF8_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * UTF-8 encoded string facility.
+ */
+
+#include <idn/export.h>
+
+/*
+ * Get the length of a character.
+ *
+ * Get the length (in bytes) of a character whose first byte is pointed
+ * by 's'.  Since this function only looks one first byte to determine the
+ * length, it is possible some of the following bytes are invalid.
+ */
+IDN_EXPORT int
+idn_utf8_mblen(const char *s);
+
+/*
+ * Get one character.
+ *
+ * Get the first character of the string pointed by 's', and copy it
+ * to 'buf', whose length is 'len'.  Returns the number of bytes copied,
+ * or zero if the encoding is invalid or len is too small.
+ *
+ * The area pointed by 'buf' must be large enough to store any UTF-8 encoded
+ * character.
+ *
+ * Note that the copied string is not NUL-terminated.
+ */
+IDN_EXPORT int
+idn_utf8_getmb(const char *s, size_t len, char *buf);
+
+/*
+ * Get one character in UCS-4.
+ *
+ * Similar to 'idn_utf8_getmb', except that the result is not in UTF-8
+ * encoding, but in UCS-4 format (plain 32bit integer value).
+ */
+IDN_EXPORT int
+idn_utf8_getwc(const char *s, size_t len, unsigned long *vp);
+
+/*
+ * Put one character.
+ *
+ * This function is an opposite of 'idn_utf8_getwc'.  It takes a UCS-4
+ * value 'v', convert it to UTF-8 encoded sequence, and store it to 's',
+ * whose length is 'len'.  It returns the number of bytes written, or
+ * zero 'v' is out of range or 'len' is too small.
+ */
+IDN_EXPORT int
+idn_utf8_putwc(char *s, size_t len, unsigned long v);
+
+/*
+ * Check the validity of UTF-8 encoded character.
+ *
+ * Check if the character pointed by 's' is a valid UTF-8 encoded
+ * character.  Return the length of the character (in bytes) if it is valid,
+ * 0 otherwise.
+ */
+IDN_EXPORT int
+idn_utf8_isvalidchar(const char *s);
+
+/*
+ * Check the validity of UTF-8 encoded string.
+ *
+ * Check if the NUL-terminated string 's' is valid as a UTF-8 encoded
+ * string.  Return 1 if it is valid, 0 otherwise.
+ */
+IDN_EXPORT int
+idn_utf8_isvalidstring(const char *s);
+
+/*
+ * Find first byte of a character.
+ *
+ * Find the first byte of a character 's' points to.  's' may point
+ * the 2nd or later byte of a character.  'known_top' is a pointer to
+ * a string which contains 's', and is known to be the first byte of
+ * a character.  If it couldn't find the first byte between 'known_top'
+ * and 's', NULL will be returned.
+ */
+IDN_EXPORT char *
+idn_utf8_findfirstbyte(const char *s, const char *known_top);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* IDN_UTF8_H */
diff --git a/contrib/idn/idnkit-1.0-src/include/idn/util.h b/contrib/idn/idnkit-1.0-src/include/idn/util.h
new file mode 100644 (file)
index 0000000..ddafe17
--- /dev/null
@@ -0,0 +1,98 @@
+/* $Id: util.h,v 1.1 2003/06/04 00:25:44 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.
+ */
+
+#ifndef IDN_UTIL_H
+#define IDN_UTIL_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Utility functions.
+ */
+
+/*
+ * Check ACE prefix.
+ *
+ * These functions examine whether `str' begins with `prefix'.
+ * They disregard the case difference of ASCII letters ([A-Za-z]).
+ * They return 1 if `str' has the ACE prefix, 0 otherwise.
+ */
+extern int
+idn__util_asciihaveaceprefix(const char *str, const char *prefix);
+extern int
+idn__util_ucs4haveaceprefix(const unsigned long *str, const char *prefix);
+
+/*
+ * Check if all codepoints in the UCS4 string `str' are in the ASCII
+ * range (i.e. U+0000...U+007F).
+ *
+ * The function return 1 if it is, 0 otherwise.
+ */
+extern int
+idn__util_ucs4isasciirange(const unsigned long *str);
+
+/*
+ * Get registry information from the system. (Windows only)
+ */
+#ifdef WIN32
+/*
+ * registry top type.
+ */
+typedef enum {
+       idn__util_hkey_currentuser,
+       idn__util_hkey_localmachine
+} idn__util_hkey_t;
+
+extern int
+idn__util_getregistrystring(idn__util_hkey_t topkey, const char *name,
+                           char *str, size_t length);
+#endif /* WIN32 */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* IDN_UTIL_H */
diff --git a/contrib/idn/idnkit-1.0-src/include/idn/version.h b/contrib/idn/idnkit-1.0-src/include/idn/version.h
new file mode 100644 (file)
index 0000000..88d876d
--- /dev/null
@@ -0,0 +1,70 @@
+/* $Id: version.h,v 1.1 2003/06/04 00:25:44 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.
+ */
+
+#ifndef IDN_VERSION_H
+#define IDN_VERSION_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <idn/export.h>
+
+/*
+ * Version number of this package.
+ */
+#define IDNKIT_VERSION         "1.0"
+#define IDNKIT_MAJOR_VERSION   1
+#define IDNKIT_MINOR_VERSION   0
+
+/*
+ * Get the version of the library (libidnkit).
+ */
+IDN_EXPORT const char *
+idn_version_getstring(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* IDN_VERSION_H */
diff --git a/contrib/idn/idnkit-1.0-src/include/mdn/Makefile.in b/contrib/idn/idnkit-1.0-src/include/mdn/Makefile.in
new file mode 100644 (file)
index 0000000..48344c9
--- /dev/null
@@ -0,0 +1,83 @@
+# $Id: Makefile.in,v 1.1 2003/06/04 00:25:45 marka Exp $
+# 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.
+
+srcdir = @srcdir@
+VPATH = @srcdir@
+
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+
+includedir = @includedir@
+mdnincludedir = $(includedir)/mdn
+
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_DATA = @INSTALL_DATA@
+MKINSTALLDIRS = @top_srcdir@/mkinstalldirs
+SHELL = @SHELL@
+
+HDRS = \
+       api.h \
+       log.h \
+       res.h \
+       resconf.h \
+       result.h \
+       utf8.h \
+       version.h
+
+all:
+
+@COMPAT_TRUE@install: all install-compat
+@COMPAT_FALSE@install: 
+
+install-compat:
+       $(MKINSTALLDIRS) $(DESTDIR)$(mdnincludedir)
+       for hdr in $(HDRS); do \
+           $(INSTALL_DATA) $(srcdir)/$$hdr $(DESTDIR)$(mdnincludedir)/$$hdr; \
+       done
+
+clean:
+       rm -f *~
+
+distclean:
+       rm -f Makefile
+
+test check:
diff --git a/contrib/idn/idnkit-1.0-src/include/mdn/api.h b/contrib/idn/idnkit-1.0-src/include/mdn/api.h
new file mode 100644 (file)
index 0000000..01c425c
--- /dev/null
@@ -0,0 +1,91 @@
+/* $Id: api.h,v 1.1 2003/06/04 00:25:45 marka Exp $ */
+/*
+ * 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.
+ */
+
+#ifndef MDN_API_H
+#define MDN_API_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <mdn/result.h>
+#include <mdn/res.h>
+#include <idn/api.h>
+
+#define mdn_enable idn_enable
+
+extern idn_result_t
+mdn_nameinit(void);
+
+extern idn_result_t
+mdn_encodename(int actions, const char *from, char *to, size_t tolen);
+
+extern idn_result_t
+mdn_decodename(int actions, const char *from, char *to, size_t tolen);
+
+#define mdn_localtoutf8(from, to, tolen) \
+       mdn_encodename(IDN_LOCALCONV, from, to, len)
+#define mdn_delimitermap(from, to, tolen) \
+       mdn_encodename(IDN_DELIMMAP, from, to, len)
+#define mdn_localmap(from, to, tolen) \
+       mdn_encodename(IDN_LOCALMAP, from, to, len)
+#define mdn_nameprep(from, to, tolen) \
+       mdn_encodename(IDN_NAMEPREP, from, to, len)
+#define mdn_utf8toidn(from, to, tolen) \
+       mdn_encodename(IDN_IDNCONV, from, to, len)
+#define mdn_idntoutf8(from, to, tolen) \
+       mdn_decodename(IDN_IDNCONV, from, to, tolen)
+#define mdn_utf8tolocal(from, to, tolen) \
+       mdn_decodename(IDN_LOCALCONV, from, to, tolen)
+
+#define mdn_localtoidn(from, to, tolen) \
+       mdn_encodename(IDN_ENCODE_APP, from, to, tolen)
+#define mdn_idntolocal(from, to, tolen) \
+       mdn_decodename(IDN_DECODE_APP, from, to, tolen)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* MDN_API_H */
diff --git a/contrib/idn/idnkit-1.0-src/include/mdn/localencoding.h b/contrib/idn/idnkit-1.0-src/include/mdn/localencoding.h
new file mode 100644 (file)
index 0000000..79cb998
--- /dev/null
@@ -0,0 +1,49 @@
+/* $Id: localencoding.h,v 1.1 2003/06/04 00:25:45 marka Exp $ */
+/*
+ * 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.
+ */
+
+#ifndef MDN_LOCALENCODING_H
+#define MDN_LOCALENCODING_H 1
+
+#define MDN_LOCALCS_ENV        "MDN_LOCAL_CODESET"
+
+#endif /* MDN_LOCALENCODING_H */
diff --git a/contrib/idn/idnkit-1.0-src/include/mdn/log.h b/contrib/idn/idnkit-1.0-src/include/mdn/log.h
new file mode 100644 (file)
index 0000000..d17bd52
--- /dev/null
@@ -0,0 +1,92 @@
+/* $Id: log.h,v 1.1 2003/06/04 00:25:45 marka Exp $ */
+/*
+ * 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.
+ */
+
+#ifndef MDN_LOG_H
+#define MDN_LOG_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <idn/log.h>
+
+#define mdn_log_proc_t \
+       idn_log_proc_t
+
+#define mdn_log_level_fatal \
+       idn_log_level_fatal
+#define mdn_log_level_error \
+       idn_log_level_error
+#define mdn_log_level_warning \
+       idn_log_level_warning
+#define mdn_log_level_info \
+       idn_log_level_info
+#define mdn_log_level_trace \
+       idn_log_level_trace
+#define mdn_log_level_dump \
+       idn_log_level_dump
+
+#define mdn_log_fatal \
+       idn_log_fatal
+#define mdn_log_error \
+       idn_log_error
+#define mdn_log_warning \
+       idn_log_warning
+#define mdn_log_info \
+       idn_log_info
+#define mdn_log_trace \
+       idn_log_trace
+#define mdn_log_dump \
+       idn_log_dump
+#define mdn_log_setlevel \
+       idn_log_setlevel
+#define mdn_log_getlevel \
+       idn_log_getlevel
+#define mdn_log_setproc \
+       idn_log_setproc
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* MDN_LOG_H */
diff --git a/contrib/idn/idnkit-1.0-src/include/mdn/res.h b/contrib/idn/idnkit-1.0-src/include/mdn/res.h
new file mode 100644 (file)
index 0000000..7b60838
--- /dev/null
@@ -0,0 +1,121 @@
+/* $Id: res.h,v 1.1 2003/06/04 00:25:45 marka Exp $ */
+/*
+ * 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.
+ */
+
+#ifndef MDN_RES_H
+#define MDN_RES_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <mdn/resconf.h>
+#include <mdn/result.h>
+#include <idn/res.h>
+
+#define MDN_LOCALCONV \
+       IDN_LOCALCONV
+#define MDN_DELIMMAP \
+       IDN_DELIMMAP
+#define MDN_LOCALMAP \
+       IDN_LOCALMAP
+#define MDN_MAP \
+       IDN_MAP
+#define MDN_NORMALIZE \
+       IDN_NORMALIZE
+#define MDN_PROHCHECK \
+       IDN_PROHCHECK
+#define MDN_UNASCHECK \
+       IDN_UNASCHECK
+#define MDN_ASCCHECK \
+       IDN_ASCCHECK
+#define MDN_IDNCONV \
+       IDN_IDNCONV
+#define MDN_LENCHECK \
+       IDN_LENCHECK
+#define MDN_RTCHECK \
+       IDN_RTCHECK
+#define MDN_UNDOIFERR \
+       IDN_UNDOIFERR
+#define MDN_ENCODE_APP \
+       IDN_ENCODE_APP
+#define MDN_DECODE_APP \
+       IDN_DECODE_APP
+#define MDN_NAMEPREP \
+       IDN_NAMEPREP
+
+#define mdn_res_enable \
+       idn_res_enable
+#define mdn_res_encodename \
+       idn_res_encodename
+#define mdn_res_decodename \
+       idn_res_decodename
+#define mdn_res_actiontostring \
+       idn_res_actiontostring
+
+#define mdn_res_localtoutf8 \
+       idn_res_localtoutf8
+#define mdn_res_delimitermap \
+       idn_res_delimitermap
+#define mdn_res_localmap \
+       idn_res_localmap
+#define mdn_res_nameprep \
+       idn_res_nameprep
+#define mdn_res_utf8toidn \
+       idn_res_utf8toidn
+#define mdn_res_idntoutf8 \
+       idn_res_idntoutf8
+#define mdn_res_utf8tolocal \
+       idn_res_utf8tolocal
+#define mdn_res_nameprepcheck \
+       idn_res_nameprepcheck
+#define mdn_res_localtoidn \
+       idn_res_localtoidn
+#define mdn_res_idntolocal \
+       idn_res_idntolocal
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* MDN_RES_H */
diff --git a/contrib/idn/idnkit-1.0-src/include/mdn/resconf.h b/contrib/idn/idnkit-1.0-src/include/mdn/resconf.h
new file mode 100644 (file)
index 0000000..bd40810
--- /dev/null
@@ -0,0 +1,150 @@
+/* $Id: resconf.h,v 1.1 2003/06/04 00:25:46 marka Exp $ */
+/*
+ * 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.
+ */
+
+#ifndef MDN_RESCONF_H
+#define MDN_RESCONF_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <mdn/result.h>
+#include <idn/resconf.h>
+
+#define mdn_resconf_t \
+       idn_resconf_t
+
+#define mdn_resconf_initialize \
+       idn_resconf_initialize
+#define mdn_resconf_create \
+       idn_resconf_create
+#define mdn_resconf_destroy \
+       idn_resconf_destroy
+
+#define mdn_resconf_incrref \
+       idn_resconf_incrref
+#define mdn_resconf_loadfile \
+       idn_resconf_loadfile
+#define mdn_resconf_defaultfile \
+       idn_resconf_defaultfile
+#define mdn_resconf_getdelimitermap \
+       idn_resconf_getdelimitermap
+#define mdn_resconf_getidnconverter \
+       idn_resconf_getidnconverter
+#define mdn_resconf_getlocalconverter \
+       idn_resconf_getlocalconverter
+#define mdn_resconf_getlocalmapselector \
+       idn_resconf_getlocalmapselector
+#define mdn_resconf_getmapper \
+       idn_resconf_getmapper
+#define mdn_resconf_getnormalizer \
+       idn_resconf_getnormalizer
+#define mdn_resconf_getprohibitchecker \
+       idn_resconf_getprohibitchecker
+#define mdn_resconf_getunassignedchecker \
+       idn_resconf_getunassignedchecker
+#define mdn_resconf_setdelimitermap \
+       idn_resconf_setdelimitermap
+#define mdn_resconf_setidnconverter \
+       idn_resconf_setidnconverter
+#define mdn_resconf_setlocalconverter \
+       idn_resconf_setlocalconverter
+#define mdn_resconf_setlocalmapselector \
+       idn_resconf_setlocalmapselector
+#define mdn_resconf_setmapper \
+       idn_resconf_setmapper
+#define mdn_resconf_setnormalizer \
+       idn_resconf_setnormalizer
+#define mdn_resconf_setprohibitchecker \
+       idn_resconf_setprohibitchecker
+#define mdn_resconf_setunassignedchecker \
+       idn_resconf_setunassignedchecker
+#define mdn_resconf_setidnconvertername        \
+       idn_resconf_setidnconvertername
+#define mdn_resconf_addalldelimitermapucs \
+       idn_resconf_addalldelimitermapucs
+#define mdn_resconf_setlocalconvertername \
+       idn_resconf_setlocalconvertername
+#define mdn_resconf_addalllocalmapselectornames        \
+       idn_resconf_addalllocalmapselectornames
+#define mdn_resconf_addallmappernames \
+       idn_resconf_addallmappernames
+#define mdn_resconf_addallnormalizernames \
+       idn_resconf_addallnormalizernames
+#define mdn_resconf_addallprohibitcheckernames \
+       idn_resconf_addallprohibitcheckernames
+#define mdn_resconf_addallunassignedcheckernames \
+       idn_resconf_addallunassignedcheckernames
+#define mdn_resconf_setnameprepversion \
+       idn_resconf_setnameprepversion
+#define mdn_resconf_setalternateconverter \
+       idn_resconf_setalternateconverter
+#define mdn_resconf_setalternateconvertername \
+       idn_resconf_setalternateconvertername
+#define mdn_resconf_getalternateconverter \
+       idn_resconf_getalternateconverter
+
+#define mdn_resconf_localconverter \
+       idn_resconf_localconverter
+#define mdn_resconf_idnconverter \
+       idn_resconf_idnconverter
+#define mdn_resconf_alternateconverter \
+       idn_resconf_alternateconverter
+#define mdn_resconf_normalizer \
+       idn_resconf_normalizer
+#define mdn_resconf_mapper \
+       idn_resconf_mapper
+#define mdn_resconf_delimitermap \
+       idn_resconf_delimitermap
+#define mdn_resconf_localmapselector \
+       idn_resconf_localmapselector
+#define mdn_resconf_prohibitchecker \
+       idn_resconf_prohibitchecker
+#define mdn_resconf_unassignedchecker \
+       idn_resconf_unassignedchecker
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* MDN_RESCONF_H */
diff --git a/contrib/idn/idnkit-1.0-src/include/mdn/result.h b/contrib/idn/idnkit-1.0-src/include/mdn/result.h
new file mode 100644 (file)
index 0000000..54d0d5e
--- /dev/null
@@ -0,0 +1,97 @@
+/* $Id: result.h,v 1.1 2003/06/04 00:25:46 marka Exp $ */
+/*
+ * 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.
+ */
+
+#ifndef MDN_RESULT_H
+#define MDN_RESULT_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <idn/result.h>
+
+#define mdn_result_t \
+       idn_result_t
+
+#define mdn_success \
+       idn_success
+#define mdn_notfound \
+       idn_notfound
+#define mdn_invalid_encoding \
+       idn_invalid_encoding
+#define mdn_invalid_syntax \
+       idn_invalid_syntax
+#define mdn_invalid_name \
+       idn_invalid_name
+#define mdn_invalid_message \
+       idn_invalid_message
+#define mdn_invalid_action \
+       idn_invalid_action
+#define mdn_invalid_codepoint \
+       idn_invalid_codepoint
+#define mdn_invalid_length \
+       idn_invalid_length
+#define mdn_buffer_overflow \
+       idn_buffer_overflow
+#define mdn_noentry \
+       idn_noentry
+#define mdn_nomemory \
+       idn_nomemory
+#define mdn_nofile \
+       idn_nofile
+#define mdn_nomapping \
+       idn_nomapping
+#define mdn_context_required \
+       idn_context_required
+#define mdn_prohibited \
+       idn_prohibited
+#define mdn_failure \
+       idn_failure
+#define mdn_result_tostring \
+       idn_result_tostring
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* MDN_RESULT_H */
diff --git a/contrib/idn/idnkit-1.0-src/include/mdn/utf8.h b/contrib/idn/idnkit-1.0-src/include/mdn/utf8.h
new file mode 100644 (file)
index 0000000..2c2af87
--- /dev/null
@@ -0,0 +1,70 @@
+/* $Id: utf8.h,v 1.1 2003/06/04 00:25:46 marka Exp $ */
+/*
+ * 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.
+ */
+
+#ifndef MDN_UTF8_H
+#define MDN_UTF8_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define mdn_utf8_mblen \
+       idn_utf8_mblen
+#define mdn_utf8_getmb \
+       idn_utf8_getmb
+#define mdn_utf8_getwc \
+       idn_utf8_getwc
+#define mdn_utf8_putwc \
+       idn_utf8_putwc
+#define mdn_utf8_isvalidchar \
+       idn_utf8_isvalidchar
+#define mdn_utf8_isvalidstring \
+       idn_utf8_isvalidstring
+#define mdn_utf8_findfirstbyte \
+       idn_utf8_findfirstbyte
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* MDN_UTF8_H */
diff --git a/contrib/idn/idnkit-1.0-src/include/mdn/version.h b/contrib/idn/idnkit-1.0-src/include/mdn/version.h
new file mode 100644 (file)
index 0000000..0e525a2
--- /dev/null
@@ -0,0 +1,66 @@
+/* $Id: version.h,v 1.1 2003/06/04 00:25:46 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.
+ */
+
+#ifndef MDN_VERSION_H
+#define MDN_VERSION_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <idn/version.h>
+
+/*
+ * Version number of this package.
+ */
+#define MDNKIT_VERSION         "idnkit " IDNKIT_VERSION
+#define MDNKIT_MAJOR_VERSION   (IDNKIT_MAJOR_VERSION + 4)
+#define MDNKIT_MINOR_VERSION   IDNKIT_MINOR_VERSION
+
+#define mdn_version_getstring  idn_version_getstring
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* MDN_VERSION_H */
diff --git a/contrib/idn/idnkit-1.0-src/install-sh b/contrib/idn/idnkit-1.0-src/install-sh
new file mode 100755 (executable)
index 0000000..ebc6691
--- /dev/null
@@ -0,0 +1,250 @@
+#! /bin/sh
+#
+# install - install a program, script, or datafile
+# This comes from X11R5 (mit/util/scripts/install.sh).
+#
+# Copyright 1991 by the Massachusetts Institute of Technology
+#
+# Permission to use, copy, modify, distribute, and sell this software and its
+# documentation for any purpose is hereby granted without fee, provided that
+# the above copyright notice appear in all copies and that both that
+# copyright notice and this permission notice appear in supporting
+# documentation, and that the name of M.I.T. not be used in advertising or
+# publicity pertaining to distribution of the software without specific,
+# written prior permission.  M.I.T. makes no representations about the
+# suitability of this software for any purpose.  It is provided "as is"
+# without express or implied warranty.
+#
+# Calling this script install-sh is preferred over install.sh, to prevent
+# `make' implicit rules from creating a file called install from it
+# when there is no Makefile.
+#
+# This script is compatible with the BSD install script, but was written
+# from scratch.  It can only install one file at a time, a restriction
+# shared with many OS's install programs.
+
+
+# set DOITPROG to echo to test this script
+
+# Don't use :- since 4.3BSD and earlier shells don't like it.
+doit="${DOITPROG-}"
+
+
+# put in absolute paths if you don't have them in your path; or use env. vars.
+
+mvprog="${MVPROG-mv}"
+cpprog="${CPPROG-cp}"
+chmodprog="${CHMODPROG-chmod}"
+chownprog="${CHOWNPROG-chown}"
+chgrpprog="${CHGRPPROG-chgrp}"
+stripprog="${STRIPPROG-strip}"
+rmprog="${RMPROG-rm}"
+mkdirprog="${MKDIRPROG-mkdir}"
+
+transformbasename=""
+transform_arg=""
+instcmd="$mvprog"
+chmodcmd="$chmodprog 0755"
+chowncmd=""
+chgrpcmd=""
+stripcmd=""
+rmcmd="$rmprog -f"
+mvcmd="$mvprog"
+src=""
+dst=""
+dir_arg=""
+
+while [ x"$1" != x ]; do
+    case $1 in
+       -c) instcmd="$cpprog"
+           shift
+           continue;;
+
+       -d) dir_arg=true
+           shift
+           continue;;
+
+       -m) chmodcmd="$chmodprog $2"
+           shift
+           shift
+           continue;;
+
+       -o) chowncmd="$chownprog $2"
+           shift
+           shift
+           continue;;
+
+       -g) chgrpcmd="$chgrpprog $2"
+           shift
+           shift
+           continue;;
+
+       -s) stripcmd="$stripprog"
+           shift
+           continue;;
+
+       -t=*) transformarg=`echo $1 | sed 's/-t=//'`
+           shift
+           continue;;
+
+       -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
+           shift
+           continue;;
+
+       *)  if [ x"$src" = x ]
+           then
+               src=$1
+           else
+               # this colon is to work around a 386BSD /bin/sh bug
+               :
+               dst=$1
+           fi
+           shift
+           continue;;
+    esac
+done
+
+if [ x"$src" = x ]
+then
+       echo "install:  no input file specified"
+       exit 1
+else
+       true
+fi
+
+if [ x"$dir_arg" != x ]; then
+       dst=$src
+       src=""
+       
+       if [ -d $dst ]; then
+               instcmd=:
+       else
+               instcmd=mkdir
+       fi
+else
+
+# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
+# might cause directories to be created, which would be especially bad 
+# if $src (and thus $dsttmp) contains '*'.
+
+       if [ -f $src -o -d $src ]
+       then
+               true
+       else
+               echo "install:  $src does not exist"
+               exit 1
+       fi
+       
+       if [ x"$dst" = x ]
+       then
+               echo "install:  no destination specified"
+               exit 1
+       else
+               true
+       fi
+
+# If destination is a directory, append the input filename; if your system
+# does not like double slashes in filenames, you may need to add some logic
+
+       if [ -d $dst ]
+       then
+               dst="$dst"/`basename $src`
+       else
+               true
+       fi
+fi
+
+## this sed command emulates the dirname command
+dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
+
+# Make sure that the destination directory exists.
+#  this part is taken from Noah Friedman's mkinstalldirs script
+
+# Skip lots of stat calls in the usual case.
+if [ ! -d "$dstdir" ]; then
+defaultIFS='   
+'
+IFS="${IFS-${defaultIFS}}"
+
+oIFS="${IFS}"
+# Some sh's can't handle IFS=/ for some reason.
+IFS='%'
+set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
+IFS="${oIFS}"
+
+pathcomp=''
+
+while [ $# -ne 0 ] ; do
+       pathcomp="${pathcomp}${1}"
+       shift
+
+       if [ ! -d "${pathcomp}" ] ;
+        then
+               $mkdirprog "${pathcomp}"
+       else
+               true
+       fi
+
+       pathcomp="${pathcomp}/"
+done
+fi
+
+if [ x"$dir_arg" != x ]
+then
+       $doit $instcmd $dst &&
+
+       if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
+       if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
+       if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
+       if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
+else
+
+# If we're going to rename the final executable, determine the name now.
+
+       if [ x"$transformarg" = x ] 
+       then
+               dstfile=`basename $dst`
+       else
+               dstfile=`basename $dst $transformbasename | 
+                       sed $transformarg`$transformbasename
+       fi
+
+# don't allow the sed command to completely eliminate the filename
+
+       if [ x"$dstfile" = x ] 
+       then
+               dstfile=`basename $dst`
+       else
+               true
+       fi
+
+# Make a temp file name in the proper directory.
+
+       dsttmp=$dstdir/#inst.$$#
+
+# Move or copy the file name to the temp name
+
+       $doit $instcmd $src $dsttmp &&
+
+       trap "rm -f ${dsttmp}" 0 &&
+
+# and set any options; do chmod last to preserve setuid bits
+
+# If any of these fail, we abort the whole thing.  If we want to
+# ignore errors from any of these, just make sure not to ignore
+# errors from the above "$doit $instcmd $src $dsttmp" command.
+
+       if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
+       if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
+       if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
+       if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
+
+# Now rename the file to the real destination.
+
+       $doit $rmcmd -f $dstdir/$dstfile &&
+       $doit $mvcmd $dsttmp $dstdir/$dstfile 
+
+fi &&
+
+
+exit 0
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 (file)
index 0000000..2c1c55b
--- /dev/null
@@ -0,0 +1,309 @@
+# $Id: Makefile.in,v 1.1 2003/06/04 00:25:47 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) -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 (file)
index 0000000..f893dcc
--- /dev/null
@@ -0,0 +1,355 @@
+#ifndef lint
+static char *rcsid = "$Id: aliaslist.c,v 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 (file)
index 0000000..47c3d4f
--- /dev/null
@@ -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 (file)
index 0000000..772d004
--- /dev/null
@@ -0,0 +1,257 @@
+#ifndef lint
+static char *rcsid = "$Id: api.c,v 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 (file)
index 0000000..52e5b11
--- /dev/null
@@ -0,0 +1,446 @@
+#ifndef lint
+static char *rcsid = "$Id: checker.c,v 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 (file)
index 0000000..b08984c
--- /dev/null
@@ -0,0 +1,1244 @@
+#ifndef lint
+static char *rcsid = "$Id: converter.c,v 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 (file)
index 0000000..51037e9
--- /dev/null
@@ -0,0 +1,267 @@
+#ifndef lint
+static char *rcsid = "$Id: debug.c,v 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 (file)
index 0000000..a54142b
--- /dev/null
@@ -0,0 +1,268 @@
+#ifndef lint
+static char *rcsid = "$Id: delimitermap.c,v 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 (file)
index 0000000..507c931
--- /dev/null
@@ -0,0 +1,261 @@
+#ifndef lint
+static char *rcsid = "$Id: filechecker.c,v 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 (file)
index 0000000..1b75219
--- /dev/null
@@ -0,0 +1,347 @@
+#ifndef lint
+static char *rcsid = "$Id: filemapper.c,v 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 (file)
index 0000000..1110860
--- /dev/null
@@ -0,0 +1,61 @@
+# $Id: idn.conf.sample.in,v 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 (file)
index 0000000..f713d3c
--- /dev/null
@@ -0,0 +1,123 @@
+#ifndef lint
+static char *rcsid = "$Id: localencoding.c,v 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 (file)
index 0000000..2b7c24e
--- /dev/null
@@ -0,0 +1,215 @@
+#ifndef lint
+static char *rcsid = "$Id: log.c,v 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 (file)
index 0000000..b006306
--- /dev/null
@@ -0,0 +1,279 @@
+# $Id: make.wnt,v 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 (file)
index 0000000..22e8520
--- /dev/null
@@ -0,0 +1,482 @@
+#ifndef lint
+static char *rcsid = "$Id: mapper.c,v 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 (file)
index 0000000..bcfb26c
--- /dev/null
@@ -0,0 +1,375 @@
+#ifndef lint
+static char *rcsid = "$Id: mapselector.c,v 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 (file)
index 0000000..b46b81b
--- /dev/null
@@ -0,0 +1,357 @@
+#ifndef lint
+static char *rcsid = "$Id: nameprep.c,v 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 (file)
index 0000000..8a6a60f
--- /dev/null
@@ -0,0 +1,137 @@
+/* $Id: nameprep_template.c,v 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 (file)
index 0000000..f0fe44f
--- /dev/null
@@ -0,0 +1,2546 @@
+/* $Id: nameprepdata.c,v 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 (file)
index 0000000..6695e38
--- /dev/null
@@ -0,0 +1,439 @@
+#ifndef lint
+static char *rcsid = "$Id: normalizer.c,v 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 (file)
index 0000000..292763d
--- /dev/null
@@ -0,0 +1,434 @@
+#ifndef lint
+static char *rcsid = "$Id: punycode.c,v 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 (file)
index 0000000..44c2101
--- /dev/null
@@ -0,0 +1,427 @@
+#ifndef lint
+static char *rcsid = "$Id: race.c,v 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 (file)
index 0000000..a3024d3
--- /dev/null
@@ -0,0 +1,1726 @@
+#ifndef lint
+static char *rcsid = "$Id: res.c,v 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 (file)
index 0000000..9477c28
--- /dev/null
@@ -0,0 +1,1477 @@
+#ifndef lint
+static char *rcsid = "$Id: resconf.c,v 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 (file)
index 0000000..ac3d27d
--- /dev/null
@@ -0,0 +1,76 @@
+#ifndef lint
+static char *rcsid = "$Id: result.c,v 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 (file)
index 0000000..304953d
--- /dev/null
@@ -0,0 +1,283 @@
+#ifndef lint
+static char *rcsid = "$Id: strhash.c,v 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 (file)
index 0000000..6e5a2c3
--- /dev/null
@@ -0,0 +1,304 @@
+# $Id: Makefile.in,v 1.1 2003/06/04 00:26:46 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) -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 (file)
index 0000000..ae9dd2b
--- /dev/null
@@ -0,0 +1,113 @@
+#ifndef lint
+static char *rcsid = "$Id: api-init1.tsy,v 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 (file)
index 0000000..7ce1bbf
--- /dev/null
@@ -0,0 +1,113 @@
+#ifndef lint
+static char *rcsid = "$Id: api-init2.tsy,v 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 (file)
index 0000000..96aa01d
--- /dev/null
@@ -0,0 +1,117 @@
+#ifndef lint
+static char *rcsid = "$Id: api-init3.tsy,v 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 (file)
index 0000000..9212f82
--- /dev/null
@@ -0,0 +1,96 @@
+#ifndef lint
+static char *rcsid = "$Id: api-init4-1.tsy,v 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 (file)
index 0000000..119efe2
--- /dev/null
@@ -0,0 +1,96 @@
+#ifndef lint
+static char *rcsid = "$Id: api-init4-2.tsy,v 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 (file)
index 0000000..7423a06
--- /dev/null
@@ -0,0 +1,102 @@
+#ifndef lint
+static char *rcsid = "$Id: api-init4-3.tsy,v 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 (file)
index 0000000..3399f91
--- /dev/null
@@ -0,0 +1,102 @@
+#ifndef lint
+static char *rcsid = "$Id: api-init5-1.tsy,v 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 (file)
index 0000000..f45f072
--- /dev/null
@@ -0,0 +1,102 @@
+#ifndef lint
+static char *rcsid = "$Id: api-init5-2.tsy,v 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 (file)
index 0000000..8940249
--- /dev/null
@@ -0,0 +1,109 @@
+#ifndef lint
+static char *rcsid = "$Id: api-init5-3.tsy,v 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 (file)
index 0000000..356c177
--- /dev/null
@@ -0,0 +1,1009 @@
+#ifndef lint
+static char *rcsid = "$Id: api.tsy,v 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 (file)
index 0000000..13a300c
--- /dev/null
@@ -0,0 +1,610 @@
+#ifndef lint
+static char *rcsid = "$Id: checker.tsy,v 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 (file)
index 0000000..263a7ea
--- /dev/null
@@ -0,0 +1,71 @@
+/* $Id: codeset.h,v 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 (file)
index 0000000..bbefc38
--- /dev/null
@@ -0,0 +1,822 @@
+#ifndef lint
+static char *rcsid = "$Id: converter.tsy,v 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 (file)
index 0000000..3189f6f
--- /dev/null
@@ -0,0 +1,257 @@
+#ifndef lint
+static char *rcsid = "$Id: delimitermap.tsy,v 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 (file)
index 0000000..73ec8d2
--- /dev/null
@@ -0,0 +1,132 @@
+#ifndef lint
+static char *rcsid = "$Id: iconvchk.c,v 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 (file)
index 0000000..22ed604
--- /dev/null
@@ -0,0 +1,497 @@
+#ifndef lint
+static char *rcsid = "$Id: mapper.tsy,v 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 (file)
index 0000000..3acfc5e
--- /dev/null
@@ -0,0 +1,592 @@
+#ifndef lint
+static char *rcsid = "$Id: mapselector.tsy,v 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 (file)
index 0000000..c1b73ba
--- /dev/null
@@ -0,0 +1,340 @@
+#ifndef lint
+static char *rcsid = "$Id: nameprep.tsy,v 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 (file)
index 0000000..754790f
--- /dev/null
@@ -0,0 +1,346 @@
+#ifndef lint
+static char *rcsid = "$Id: normalizer.tsy,v 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 (file)
index 0000000..afb888c
--- /dev/null
@@ -0,0 +1,1026 @@
+#ifndef lint
+static char *rcsid = "$Id: res.tsy,v 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 (file)
index 0000000..0537ac0
--- /dev/null
@@ -0,0 +1,1026 @@
+#ifndef lint
+static char *rcsid = "$Id: resconf.tsy,v 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 (file)
index 0000000..4d571e1
--- /dev/null
@@ -0,0 +1,134 @@
+#ifndef lint
+static char *rcsid = "$Id: setenv.c,v 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 (file)
index 0000000..81eaaa6
--- /dev/null
@@ -0,0 +1,61 @@
+/* $Id: setenv.h,v 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 (file)
index 0000000..14b202f
--- /dev/null
@@ -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 (file)
index 0000000..49cff43
--- /dev/null
@@ -0,0 +1,276 @@
+/* $Id: testsuite.h,v 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 (file)
index 0000000..9fd1789
--- /dev/null
@@ -0,0 +1,83 @@
+#ifndef lint
+static char *rcsid = "$Id: testutil.c,v 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 (file)
index 0000000..8c2af7a
--- /dev/null
@@ -0,0 +1,71 @@
+/* $Id: testutil.h,v 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 (executable)
index 0000000..5d2f9ca
--- /dev/null
@@ -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 (file)
index 0000000..ba33db3
--- /dev/null
@@ -0,0 +1,257 @@
+#ifndef lint
+static char *rcsid = "$Id: ucs4.tsy,v 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 (executable)
index 0000000..cebd4dc
--- /dev/null
@@ -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 (file)
index 0000000..1d7aea1
--- /dev/null
@@ -0,0 +1,461 @@
+#ifndef lint
+static char *rcsid = "$Id: ucs4.c,v 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 (file)
index 0000000..81e58a9
--- /dev/null
@@ -0,0 +1,380 @@
+#ifndef lint
+static char *rcsid = "$Id: ucsmap.c,v 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 (file)
index 0000000..0918321
--- /dev/null
@@ -0,0 +1,368 @@
+#ifndef lint
+static char *rcsid = "$Id: ucsset.c,v 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 (file)
index 0000000..ecd7612
--- /dev/null
@@ -0,0 +1,309 @@
+#ifndef lint
+static char *rcsid = "$Id: unicode.c,v 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 (file)
index 0000000..87a3607
--- /dev/null
@@ -0,0 +1,101 @@
+/* $Id: unicode_template.c,v 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 (file)
index 0000000..5e321a9
--- /dev/null
@@ -0,0 +1,7916 @@
+/* $Id: unicodedata_320.c,v 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 (file)
index 0000000..e809e39
--- /dev/null
@@ -0,0 +1,413 @@
+#ifndef lint
+static char *rcsid = "$Id: unormalize.c,v 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 (file)
index 0000000..a1810cc
--- /dev/null
@@ -0,0 +1,276 @@
+#ifndef lint
+static char *rcsid = "$Id: utf8.c,v 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 (file)
index 0000000..f986bc4
--- /dev/null
@@ -0,0 +1,162 @@
+#ifndef lint
+static char *rcsid = "$Id: util.c,v 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 (file)
index 0000000..0abbdde
--- /dev/null
@@ -0,0 +1,54 @@
+#ifndef lint
+static char *rcsid = "$Id: version.c,v 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;
+}
diff --git a/contrib/idn/idnkit-1.0-src/ltconfig b/contrib/idn/idnkit-1.0-src/ltconfig
new file mode 100755 (executable)
index 0000000..c1cb8c0
--- /dev/null
@@ -0,0 +1,3114 @@
+#! /bin/sh
+
+# ltconfig - Create a system-specific libtool.
+# Copyright (C) 1996-1999 Free Software Foundation, Inc.
+# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
+#
+# This file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# A lot of this script is taken from autoconf-2.10.
+
+# Check that we are running under the correct shell.
+SHELL=${CONFIG_SHELL-/bin/sh}
+echo=echo
+if test "X$1" = X--no-reexec; then
+  # Discard the --no-reexec flag, and continue.
+  shift
+elif test "X$1" = X--fallback-echo; then
+  # Avoid inline document here, it may be left over
+  :
+elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then
+  # Yippee, $echo works!
+  :
+else
+  # Restart under the correct shell.
+  exec "$SHELL" "$0" --no-reexec ${1+"$@"}
+fi
+
+if test "X$1" = X--fallback-echo; then
+  # used as fallback echo
+  shift
+  cat <<EOF
+$*
+EOF
+  exit 0
+fi
+
+# Find the correct PATH separator.  Usually this is `:', but
+# DJGPP uses `;' like DOS.
+if test "X${PATH_SEPARATOR+set}" != Xset; then
+  UNAME=${UNAME-`uname 2>/dev/null`}
+  case X$UNAME in
+    *-DOS) PATH_SEPARATOR=';' ;;
+    *)     PATH_SEPARATOR=':' ;;
+  esac
+fi
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+if test "X${CDPATH+set}" = Xset; then CDPATH=:; export CDPATH; fi
+
+if test "X${echo_test_string+set}" != Xset; then
+  # find a string as large as possible, as long as the shell can cope with it
+  for cmd in 'sed 50q "$0"' 'sed 20q "$0"' 'sed 10q "$0"' 'sed 2q "$0"' 'echo test'; do
+    # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ...
+    if (echo_test_string="`eval $cmd`") 2>/dev/null &&
+       echo_test_string="`eval $cmd`" &&
+       (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null; then
+      break
+    fi
+  done
+fi
+
+if test "X`($echo '\t') 2>/dev/null`" != 'X\t' ||
+   test "X`($echo "$echo_test_string") 2>/dev/null`" != X"$echo_test_string"; then
+  # The Solaris, AIX, and Digital Unix default echo programs unquote
+  # backslashes.  This makes it impossible to quote backslashes using
+  #   echo "$something" | sed 's/\\/\\\\/g'
+  #
+  # So, first we look for a working echo in the user's PATH.
+
+  IFS="${IFS=  }"; save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}"
+  for dir in $PATH /usr/ucb; do
+    if (test -f $dir/echo || test -f $dir/echo$ac_exeext) &&
+       test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' &&
+       test "X`($dir/echo "$echo_test_string") 2>/dev/null`" = X"$echo_test_string"; then
+      echo="$dir/echo"
+      break
+    fi
+  done
+  IFS="$save_ifs"
+
+  if test "X$echo" = Xecho; then
+    # We didn't find a better echo, so look for alternatives.
+    if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' &&
+       test "X`(print -r "$echo_test_string") 2>/dev/null`" = X"$echo_test_string"; then
+      # This shell has a builtin print -r that does the trick.
+      echo='print -r'
+    elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) &&
+        test "X$CONFIG_SHELL" != X/bin/ksh; then
+      # If we have ksh, try running ltconfig again with it.
+      ORIGINAL_CONFIG_SHELL="${CONFIG_SHELL-/bin/sh}"
+      export ORIGINAL_CONFIG_SHELL
+      CONFIG_SHELL=/bin/ksh
+      export CONFIG_SHELL
+      exec "$CONFIG_SHELL" "$0" --no-reexec ${1+"$@"}
+    else
+      # Try using printf.
+      echo='printf "%s\n"'
+      if test "X`($echo '\t') 2>/dev/null`" = 'X\t' &&
+        test "X`($echo "$echo_test_string") 2>/dev/null`" = X"$echo_test_string"; then
+       # Cool, printf works
+       :
+      elif test "X`("$ORIGINAL_CONFIG_SHELL" "$0" --fallback-echo '\t') 2>/dev/null`" = 'X\t' &&
+          test "X`("$ORIGINAL_CONFIG_SHELL" "$0" --fallback-echo "$echo_test_string") 2>/dev/null`" = X"$echo_test_string"; then
+       CONFIG_SHELL="$ORIGINAL_CONFIG_SHELL"
+       export CONFIG_SHELL
+       SHELL="$CONFIG_SHELL"
+       export SHELL
+       echo="$CONFIG_SHELL $0 --fallback-echo"
+      elif test "X`("$CONFIG_SHELL" "$0" --fallback-echo '\t') 2>/dev/null`" = 'X\t' &&
+          test "X`("$CONFIG_SHELL" "$0" --fallback-echo "$echo_test_string") 2>/dev/null`" = X"$echo_test_string"; then
+       echo="$CONFIG_SHELL $0 --fallback-echo"
+      else
+       # maybe with a smaller string...
+       prev=:
+
+       for cmd in 'echo test' 'sed 2q "$0"' 'sed 10q "$0"' 'sed 20q "$0"' 'sed 50q "$0"'; do
+         if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null; then
+           break
+         fi
+         prev="$cmd"
+       done
+
+       if test "$prev" != 'sed 50q "$0"'; then
+         echo_test_string=`eval $prev`
+         export echo_test_string
+         exec "${ORIGINAL_CONFIG_SHELL}" "$0" ${1+"$@"}
+       else
+         # Oops.  We lost completely, so just stick with echo.
+         echo=echo
+       fi
+      fi
+    fi
+  fi
+fi
+
+# Sed substitution that helps us do robust quoting.  It backslashifies
+# metacharacters that are still active within double-quoted strings.
+Xsed='sed -e s/^X//'
+sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g'
+
+# Same as above, but do not quote variable references.
+double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g'
+
+# Sed substitution to delay expansion of an escaped shell variable in a
+# double_quote_subst'ed string.
+delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
+
+# The name of this program.
+progname=`$echo "X$0" | $Xsed -e 's%^.*/%%'`
+
+# Constants:
+PROGRAM=ltconfig
+PACKAGE=libtool
+VERSION=1.3.5
+TIMESTAMP=" (1.385.2.206 2000/05/27 11:12:27)"
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+rm="rm -f"
+
+help="Try \`$progname --help' for more information."
+
+# Global variables:
+default_ofile=libtool
+can_build_shared=yes
+enable_shared=yes
+# All known linkers require a `.a' archive for static linking (except M$VC,
+# which needs '.lib').
+enable_static=yes
+enable_fast_install=yes
+enable_dlopen=unknown
+enable_win32_dll=no
+ltmain=
+silent=
+srcdir=
+ac_config_guess=
+ac_config_sub=
+host=
+nonopt=
+ofile="$default_ofile"
+verify_host=yes
+with_gcc=no
+with_gnu_ld=no
+need_locks=yes
+ac_ext=c
+objext=o
+libext=a
+exeext=
+cache_file=
+
+old_AR="$AR"
+old_CC="$CC"
+old_CFLAGS="$CFLAGS"
+old_CPPFLAGS="$CPPFLAGS"
+old_LDFLAGS="$LDFLAGS"
+old_LD="$LD"
+old_LN_S="$LN_S"
+old_LIBS="$LIBS"
+old_NM="$NM"
+old_RANLIB="$RANLIB"
+old_DLLTOOL="$DLLTOOL"
+old_OBJDUMP="$OBJDUMP"
+old_AS="$AS"
+
+# Parse the command line options.
+args=
+prev=
+for option
+do
+  case "$option" in
+  -*=*) optarg=`echo "$option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
+  *) optarg= ;;
+  esac
+
+  # If the previous option needs an argument, assign it.
+  if test -n "$prev"; then
+    eval "$prev=\$option"
+    prev=
+    continue
+  fi
+
+  case "$option" in
+  --help) cat <<EOM
+Usage: $progname [OPTION]... [HOST [LTMAIN]]
+
+Generate a system-specific libtool script.
+
+    --debug                enable verbose shell tracing
+    --disable-shared       do not build shared libraries
+    --disable-static       do not build static libraries
+    --disable-fast-install do not optimize for fast installation
+    --enable-dlopen        enable dlopen support
+    --enable-win32-dll     enable building dlls on win32 hosts
+    --help                 display this help and exit
+    --no-verify            do not verify that HOST is a valid host type
+-o, --output=FILE          specify the output file [default=$default_ofile]
+    --quiet                same as \`--silent'
+    --silent               do not print informational messages
+    --srcdir=DIR           find \`config.guess' in DIR
+    --version              output version information and exit
+    --with-gcc             assume that the GNU C compiler will be used
+    --with-gnu-ld          assume that the C compiler uses the GNU linker
+    --disable-lock         disable file locking
+    --cache-file=FILE      configure cache file
+
+LTMAIN is the \`ltmain.sh' shell script fragment or \`ltmain.c' program
+that provides basic libtool functionality.
+
+HOST is the canonical host system name [default=guessed].
+EOM
+  exit 0
+  ;;
+
+  --debug)
+    echo "$progname: enabling shell trace mode"
+    set -x
+    ;;
+
+  --disable-shared) enable_shared=no ;;
+
+  --disable-static) enable_static=no ;;
+
+  --disable-fast-install) enable_fast_install=no ;;
+
+  --enable-dlopen) enable_dlopen=yes ;;
+
+  --enable-win32-dll) enable_win32_dll=yes ;;
+
+  --quiet | --silent) silent=yes ;;
+
+  --srcdir) prev=srcdir ;;
+  --srcdir=*) srcdir="$optarg" ;;
+
+  --no-verify) verify_host=no ;;
+
+  --output | -o) prev=ofile ;;
+  --output=*) ofile="$optarg" ;;
+
+  --version) echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP"; exit 0 ;;
+
+  --with-gcc) with_gcc=yes ;;
+  --with-gnu-ld) with_gnu_ld=yes ;;
+
+  --disable-lock) need_locks=no ;;
+
+  --cache-file=*) cache_file="$optarg" ;;
+
+  -*)
+    echo "$progname: unrecognized option \`$option'" 1>&2
+    echo "$help" 1>&2
+    exit 1
+    ;;
+
+  *)
+    if test -z "$ltmain"; then
+      ltmain="$option"
+    elif test -z "$host"; then
+# This generates an unnecessary warning for sparc-sun-solaris4.1.3_U1
+#      if test -n "`echo $option| sed 's/[-a-z0-9.]//g'`"; then
+#        echo "$progname: warning \`$option' is not a valid host type" 1>&2
+#      fi
+      host="$option"
+    else
+      echo "$progname: too many arguments" 1>&2
+      echo "$help" 1>&2
+      exit 1
+    fi ;;
+  esac
+done
+
+if test -z "$ltmain"; then
+  echo "$progname: you must specify a LTMAIN file" 1>&2
+  echo "$help" 1>&2
+  exit 1
+fi
+
+if test ! -f "$ltmain"; then
+  echo "$progname: \`$ltmain' does not exist" 1>&2
+  echo "$help" 1>&2
+  exit 1
+fi
+
+# Quote any args containing shell metacharacters.
+ltconfig_args=
+for arg
+do
+  case "$arg" in
+  *" "*|*"     "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*)
+  ltconfig_args="$ltconfig_args '$arg'" ;;
+  *) ltconfig_args="$ltconfig_args $arg" ;;
+  esac
+done
+
+# A relevant subset of AC_INIT.
+
+# File descriptor usage:
+# 0 standard input
+# 1 file creation
+# 2 errors and warnings
+# 3 some systems may open it to /dev/tty
+# 4 used on the Kubota Titan
+# 5 compiler messages saved in config.log
+# 6 checking for... messages and results
+if test "$silent" = yes; then
+  exec 6>/dev/null
+else
+  exec 6>&1
+fi
+exec 5>>./config.log
+
+# NLS nuisances.
+# Only set LANG and LC_ALL to C if already set.
+# These must not be set unconditionally because not all systems understand
+# e.g. LANG=C (notably SCO).
+if test "X${LC_ALL+set}" = Xset; then LC_ALL=C; export LC_ALL; fi
+if test "X${LANG+set}"   = Xset; then LANG=C;   export LANG;   fi
+
+if test -n "$cache_file" && test -r "$cache_file"; then
+  echo "loading cache $cache_file within ltconfig"
+  . $cache_file
+fi
+
+if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
+  # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
+  if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
+    ac_n= ac_c='
+' ac_t='       '
+  else
+    ac_n=-n ac_c= ac_t=
+  fi
+else
+  ac_n= ac_c='\c' ac_t=
+fi
+
+if test -z "$srcdir"; then
+  # Assume the source directory is the same one as the path to LTMAIN.
+  srcdir=`$echo "X$ltmain" | $Xsed -e 's%/[^/]*$%%'`
+  test "$srcdir" = "$ltmain" && srcdir=.
+fi
+
+trap "$rm conftest*; exit 1" 1 2 15
+if test "$verify_host" = yes; then
+  # Check for config.guess and config.sub.
+  ac_aux_dir=
+  for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do
+    if test -f $ac_dir/config.guess; then
+      ac_aux_dir=$ac_dir
+      break
+    fi
+  done
+  if test -z "$ac_aux_dir"; then
+    echo "$progname: cannot find config.guess in $srcdir $srcdir/.. $srcdir/../.." 1>&2
+    echo "$help" 1>&2
+    exit 1
+  fi
+  ac_config_guess=$ac_aux_dir/config.guess
+  ac_config_sub=$ac_aux_dir/config.sub
+
+  # Make sure we can run config.sub.
+  if $SHELL $ac_config_sub sun4 >/dev/null 2>&1; then :
+  else
+    echo "$progname: cannot run $ac_config_sub" 1>&2
+    echo "$help" 1>&2
+    exit 1
+  fi
+
+  echo $ac_n "checking host system type""... $ac_c" 1>&6
+
+  host_alias=$host
+  case "$host_alias" in
+  "")
+    if host_alias=`$SHELL $ac_config_guess`; then :
+    else
+      echo "$progname: cannot guess host type; you must specify one" 1>&2
+      echo "$help" 1>&2
+      exit 1
+    fi ;;
+  esac
+  host=`$SHELL $ac_config_sub $host_alias`
+  echo "$ac_t$host" 1>&6
+
+  # Make sure the host verified.
+  test -z "$host" && exit 1
+
+elif test -z "$host"; then
+  echo "$progname: you must specify a host type if you use \`--no-verify'" 1>&2
+  echo "$help" 1>&2
+  exit 1
+else
+  host_alias=$host
+fi
+
+# Transform linux* to *-*-linux-gnu*, to support old configure scripts.
+case "$host_os" in
+linux-gnu*) ;;
+linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'`
+esac
+
+host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+
+case "$host_os" in
+aix3*)
+  # AIX sometimes has problems with the GCC collect2 program.  For some
+  # reason, if we set the COLLECT_NAMES environment variable, the problems
+  # vanish in a puff of smoke.
+  if test "X${COLLECT_NAMES+set}" != Xset; then
+    COLLECT_NAMES=
+    export COLLECT_NAMES
+  fi
+  ;;
+esac
+
+# Determine commands to create old-style static archives.
+old_archive_cmds='$AR cru $oldlib$oldobjs'
+old_postinstall_cmds='chmod 644 $oldlib'
+old_postuninstall_cmds=
+
+# Set a sane default for `AR'.
+test -z "$AR" && AR=ar
+
+# Set a sane default for `OBJDUMP'.
+test -z "$OBJDUMP" && OBJDUMP=objdump
+
+# If RANLIB is not set, then run the test.
+if test "${RANLIB+set}" != "set"; then
+  result=no
+
+  echo $ac_n "checking for ranlib... $ac_c" 1>&6
+  IFS="${IFS=  }"; save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}"
+  for dir in $PATH; do
+    test -z "$dir" && dir=.
+    if test -f $dir/ranlib || test -f $dir/ranlib$ac_exeext; then
+      RANLIB="ranlib"
+      result="ranlib"
+      break
+    fi
+  done
+  IFS="$save_ifs"
+
+  echo "$ac_t$result" 1>&6
+fi
+
+if test -n "$RANLIB"; then
+  old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
+  old_postinstall_cmds="\$RANLIB \$oldlib~$old_postinstall_cmds"
+fi
+
+# Set sane defaults for `DLLTOOL', `OBJDUMP', and `AS', used on cygwin.
+test -z "$DLLTOOL" && DLLTOOL=dlltool
+test -z "$OBJDUMP" && OBJDUMP=objdump
+test -z "$AS" && AS=as
+
+# Check to see if we are using GCC.
+if test "$with_gcc" != yes || test -z "$CC"; then
+  # If CC is not set, then try to find GCC or a usable CC.
+  if test -z "$CC"; then
+    echo $ac_n "checking for gcc... $ac_c" 1>&6
+    IFS="${IFS=        }"; save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}"
+    for dir in $PATH; do
+      test -z "$dir" && dir=.
+      if test -f $dir/gcc || test -f $dir/gcc$ac_exeext; then
+       CC="gcc"
+       break
+      fi
+    done
+    IFS="$save_ifs"
+
+    if test -n "$CC"; then
+      echo "$ac_t$CC" 1>&6
+    else
+      echo "$ac_t"no 1>&6
+    fi
+  fi
+
+  # Not "gcc", so try "cc", rejecting "/usr/ucb/cc".
+  if test -z "$CC"; then
+    echo $ac_n "checking for cc... $ac_c" 1>&6
+    IFS="${IFS=        }"; save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}"
+    cc_rejected=no
+    for dir in $PATH; do
+      test -z "$dir" && dir=.
+      if test -f $dir/cc || test -f $dir/cc$ac_exeext; then
+       if test "$dir/cc" = "/usr/ucb/cc"; then
+         cc_rejected=yes
+         continue
+       fi
+       CC="cc"
+       break
+      fi
+    done
+    IFS="$save_ifs"
+    if test $cc_rejected = yes; then
+      # We found a bogon in the path, so make sure we never use it.
+      set dummy $CC
+      shift
+      if test $# -gt 0; then
+       # We chose a different compiler from the bogus one.
+       # However, it has the same name, so the bogon will be chosen
+       # first if we set CC to just the name; use the full file name.
+       shift
+       set dummy "$dir/cc" "$@"
+       shift
+       CC="$@"
+      fi
+    fi
+
+    if test -n "$CC"; then
+      echo "$ac_t$CC" 1>&6
+    else
+      echo "$ac_t"no 1>&6
+    fi
+
+    if test -z "$CC"; then
+      echo "$progname: error: no acceptable cc found in \$PATH" 1>&2
+      exit 1
+    fi
+  fi
+
+  # Now see if the compiler is really GCC.
+  with_gcc=no
+  echo $ac_n "checking whether we are using GNU C... $ac_c" 1>&6
+  echo "$progname:581: checking whether we are using GNU C" >&5
+
+  $rm conftest.c
+  cat > conftest.c <<EOF
+#ifdef __GNUC__
+  yes;
+#endif
+EOF
+  if { ac_try='${CC-cc} -E conftest.c'; { (eval echo $progname:589: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+    with_gcc=yes
+  fi
+  $rm conftest.c
+  echo "$ac_t$with_gcc" 1>&6
+fi
+
+# Allow CC to be a program name with arguments.
+set dummy $CC
+compiler="$2"
+
+echo $ac_n "checking for object suffix... $ac_c" 1>&6
+$rm conftest*
+echo 'int i = 1;' > conftest.c
+echo "$progname:603: checking for object suffix" >& 5
+if { (eval echo $progname:604: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>conftest.err; }; then
+  # Append any warnings to the config.log.
+  cat conftest.err 1>&5
+
+  for ac_file in conftest.*; do
+    case $ac_file in
+    *.c) ;;
+    *) objext=`echo $ac_file | sed -e s/conftest.//` ;;
+    esac
+  done
+else
+  cat conftest.err 1>&5
+  echo "$progname: failed program was:" >&5
+  cat conftest.c >&5
+fi
+$rm conftest*
+echo "$ac_t$objext" 1>&6
+
+echo $ac_n "checking for executable suffix... $ac_c" 1>&6
+if eval "test \"`echo '$''{'ac_cv_exeext'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  ac_cv_exeext="no"
+  $rm conftest*
+  echo 'main () { return 0; }' > conftest.c
+  echo "$progname:629: checking for executable suffix" >& 5
+  if { (eval echo $progname:630: \"$ac_link\") 1>&5; (eval $ac_link) 2>conftest.err; }; then
+    # Append any warnings to the config.log.
+    cat conftest.err 1>&5
+
+    for ac_file in conftest.*; do
+      case $ac_file in
+      *.c | *.err | *.$objext ) ;;
+      *) ac_cv_exeext=.`echo $ac_file | sed -e s/conftest.//` ;;
+      esac
+    done
+  else
+    cat conftest.err 1>&5
+    echo "$progname: failed program was:" >&5
+    cat conftest.c >&5
+  fi
+  $rm conftest*
+fi
+if test "X$ac_cv_exeext" = Xno; then
+  exeext=""
+else
+  exeext="$ac_cv_exeext"
+fi
+echo "$ac_t$ac_cv_exeext" 1>&6
+
+echo $ac_n "checking for $compiler option to produce PIC... $ac_c" 1>&6
+pic_flag=
+special_shlib_compile_flags=
+wl=
+link_static_flag=
+no_builtin_flag=
+
+if test "$with_gcc" = yes; then
+  wl='-Wl,'
+  link_static_flag='-static'
+
+  case "$host_os" in
+  beos* | irix5* | irix6* | osf3* | osf4* | osf5*)
+    # PIC is the default for these OSes.
+    ;;
+  aix*)
+    # Below there is a dirty hack to force normal static linking with -ldl
+    # The problem is because libdl dynamically linked with both libc and
+    # libC (AIX C++ library), which obviously doesn't included in libraries
+    # list by gcc. This cause undefined symbols with -static flags.
+    # This hack allows C programs to be linked with "-static -ldl", but
+    # we not sure about C++ programs.
+    link_static_flag="$link_static_flag ${wl}-lC"
+    ;;
+  cygwin* | mingw* | os2*)
+    # We can build DLLs from non-PIC.
+    ;;
+  amigaos*)
+    # FIXME: we need at least 68020 code to build shared libraries, but
+    # adding the `-m68020' flag to GCC prevents building anything better,
+    # like `-m68040'.
+    pic_flag='-m68020 -resident32 -malways-restore-a4'
+    ;;
+  sysv4*MP*)
+    if test -d /usr/nec; then
+       pic_flag=-Kconform_pic
+    fi
+    ;;
+  *)
+    pic_flag='-fPIC'
+    ;;
+  esac
+else
+  # PORTME Check for PIC flags for the system compiler.
+  case "$host_os" in
+  aix3* | aix4*)
+    # All AIX code is PIC.
+    link_static_flag='-bnso -bI:/lib/syscalls.exp'
+    ;;
+
+  hpux9* | hpux10* | hpux11*)
+    # Is there a better link_static_flag that works with the bundled CC?
+    wl='-Wl,'
+    link_static_flag="${wl}-a ${wl}archive"
+    pic_flag='+Z'
+    ;;
+
+  irix5* | irix6*)
+    wl='-Wl,'
+    link_static_flag='-non_shared'
+    # PIC (with -KPIC) is the default.
+    ;;
+
+  cygwin* | mingw* | os2*)
+    # We can build DLLs from non-PIC.
+    ;;
+
+  osf3* | osf4* | osf5*)
+    # All OSF/1 code is PIC.
+    wl='-Wl,'
+    link_static_flag='-non_shared'
+    ;;
+
+  sco3.2v5*)
+    pic_flag='-Kpic'
+    link_static_flag='-dn'
+    special_shlib_compile_flags='-belf'
+    ;;
+
+  solaris*)
+    pic_flag='-KPIC'
+    link_static_flag='-Bstatic'
+    wl='-Wl,'
+    ;;
+
+  sunos4*)
+    pic_flag='-PIC'
+    link_static_flag='-Bstatic'
+    wl='-Qoption ld '
+    ;;
+
+  sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+    pic_flag='-KPIC'
+    link_static_flag='-Bstatic'
+    wl='-Wl,'
+    ;;
+
+  uts4*)
+    pic_flag='-pic'
+    link_static_flag='-Bstatic'
+    ;;
+  sysv4*MP*)
+    if test -d /usr/nec ;then
+      pic_flag='-Kconform_pic'
+      link_static_flag='-Bstatic'
+    fi
+    ;;
+  *)
+    can_build_shared=no
+    ;;
+  esac
+fi
+
+if test -n "$pic_flag"; then
+  echo "$ac_t$pic_flag" 1>&6
+
+  # Check to make sure the pic_flag actually works.
+  echo $ac_n "checking if $compiler PIC flag $pic_flag works... $ac_c" 1>&6
+  $rm conftest*
+  echo "int some_variable = 0;" > conftest.c
+  save_CFLAGS="$CFLAGS"
+  CFLAGS="$CFLAGS $pic_flag -DPIC"
+  echo "$progname:776: checking if $compiler PIC flag $pic_flag works" >&5
+  if { (eval echo $progname:777: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>conftest.err; } && test -s conftest.$objext; then
+    # Append any warnings to the config.log.
+    cat conftest.err 1>&5
+    
+    case "$host_os" in
+    hpux9* | hpux10* | hpux11*)
+      # On HP-UX, both CC and GCC only warn that PIC is supported... then they
+      # create non-PIC objects.  So, if there were any warnings, we assume that
+      # PIC is not supported.
+      if test -s conftest.err; then
+       echo "$ac_t"no 1>&6
+       can_build_shared=no
+       pic_flag=
+      else
+       echo "$ac_t"yes 1>&6
+       pic_flag=" $pic_flag"
+      fi
+      ;;
+    *)
+      echo "$ac_t"yes 1>&6
+      pic_flag=" $pic_flag"
+      ;;
+    esac
+  else
+    # Append any errors to the config.log.
+    cat conftest.err 1>&5
+    can_build_shared=no
+    pic_flag=
+    echo "$ac_t"no 1>&6
+  fi
+  CFLAGS="$save_CFLAGS"
+  $rm conftest*
+else
+  echo "$ac_t"none 1>&6
+fi
+
+# Check to see if options -o and -c are simultaneously supported by compiler
+echo $ac_n "checking if $compiler supports -c -o file.o... $ac_c" 1>&6
+$rm -r conftest 2>/dev/null
+mkdir conftest
+cd conftest
+$rm conftest*
+echo "int some_variable = 0;" > conftest.c
+mkdir out
+# According to Tom Tromey, Ian Lance Taylor reported there are C compilers
+# that will create temporary files in the current directory regardless of
+# the output directory.  Thus, making CWD read-only will cause this test
+# to fail, enabling locking or at least warning the user not to do parallel
+# builds.
+chmod -w .
+save_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS -o out/conftest2.o"
+echo "$progname:829: checking if $compiler supports -c -o file.o" >&5
+if { (eval echo $progname:830: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>out/conftest.err; } && test -s out/conftest2.o; then
+
+  # The compiler can only warn and ignore the option if not recognized
+  # So say no if there are warnings
+    if test -s out/conftest.err; then
+      echo "$ac_t"no 1>&6
+      compiler_c_o=no
+    else
+      echo "$ac_t"yes 1>&6
+      compiler_c_o=yes
+    fi
+else
+  # Append any errors to the config.log.
+  cat out/conftest.err 1>&5
+  compiler_c_o=no
+  echo "$ac_t"no 1>&6
+fi
+CFLAGS="$save_CFLAGS"
+chmod u+w .
+$rm conftest* out/*
+rmdir out
+cd ..
+rmdir conftest
+$rm -r conftest 2>/dev/null
+
+if test x"$compiler_c_o" = x"yes"; then
+  # Check to see if we can write to a .lo
+  echo $ac_n "checking if $compiler supports -c -o file.lo... $ac_c" 1>&6
+  $rm conftest*
+  echo "int some_variable = 0;" > conftest.c
+  save_CFLAGS="$CFLAGS"
+  CFLAGS="$CFLAGS -c -o conftest.lo"
+  echo "$progname:862: checking if $compiler supports -c -o file.lo" >&5
+if { (eval echo $progname:863: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>conftest.err; } && test -s conftest.lo; then
+
+    # The compiler can only warn and ignore the option if not recognized
+    # So say no if there are warnings
+      if test -s conftest.err; then
+       echo "$ac_t"no 1>&6
+       compiler_o_lo=no
+      else
+       echo "$ac_t"yes 1>&6
+       compiler_o_lo=yes
+      fi
+  else
+    # Append any errors to the config.log.
+    cat conftest.err 1>&5
+    compiler_o_lo=no
+    echo "$ac_t"no 1>&6
+  fi
+  CFLAGS="$save_CFLAGS"
+  $rm conftest*
+else
+  compiler_o_lo=no
+fi
+
+# Check to see if we can do hard links to lock some files if needed
+hard_links="nottested"
+if test "$compiler_c_o" = no && test "$need_locks" != no; then
+  # do not overwrite the value of need_locks provided by the user
+  echo $ac_n "checking if we can lock with hard links... $ac_c" 1>&6
+  hard_links=yes
+  $rm conftest*
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  touch conftest.a
+  ln conftest.a conftest.b 2>&5 || hard_links=no
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  echo "$ac_t$hard_links" 1>&6
+  $rm conftest*
+  if test "$hard_links" = no; then
+    echo "*** WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2
+    need_locks=warn
+  fi
+else
+  need_locks=no
+fi
+
+if test "$with_gcc" = yes; then
+  # Check to see if options -fno-rtti -fno-exceptions are supported by compiler
+  echo $ac_n "checking if $compiler supports -fno-rtti -fno-exceptions ... $ac_c" 1>&6
+  $rm conftest*
+  echo "int some_variable = 0;" > conftest.c
+  save_CFLAGS="$CFLAGS"
+  CFLAGS="$CFLAGS -fno-rtti -fno-exceptions -c conftest.c"
+  echo "$progname:914: checking if $compiler supports -fno-rtti -fno-exceptions" >&5
+  if { (eval echo $progname:915: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>conftest.err; } && test -s conftest.o; then
+
+    # The compiler can only warn and ignore the option if not recognized
+    # So say no if there are warnings
+      if test -s conftest.err; then
+       echo "$ac_t"no 1>&6
+       compiler_rtti_exceptions=no
+      else
+       echo "$ac_t"yes 1>&6
+       compiler_rtti_exceptions=yes
+      fi
+  else
+    # Append any errors to the config.log.
+    cat conftest.err 1>&5
+    compiler_rtti_exceptions=no
+    echo "$ac_t"no 1>&6
+  fi
+  CFLAGS="$save_CFLAGS"
+  $rm conftest*
+
+  if test "$compiler_rtti_exceptions" = "yes"; then
+    no_builtin_flag=' -fno-builtin -fno-rtti -fno-exceptions'
+  else
+    no_builtin_flag=' -fno-builtin'
+  fi
+  
+fi
+
+# Check for any special shared library compilation flags.
+if test -n "$special_shlib_compile_flags"; then
+  echo "$progname: warning: \`$CC' requires \`$special_shlib_compile_flags' to build shared libraries" 1>&2
+  if echo "$old_CC $old_CFLAGS " | egrep -e "[         ]$special_shlib_compile_flags[  ]" >/dev/null; then :
+  else
+    echo "$progname: add \`$special_shlib_compile_flags' to the CC or CFLAGS env variable and reconfigure" 1>&2
+    can_build_shared=no
+  fi
+fi
+
+echo $ac_n "checking if $compiler static flag $link_static_flag works... $ac_c" 1>&6
+$rm conftest*
+echo 'main(){return(0);}' > conftest.c
+save_LDFLAGS="$LDFLAGS"
+LDFLAGS="$LDFLAGS $link_static_flag"
+echo "$progname:958: checking if $compiler static flag $link_static_flag works" >&5
+if { (eval echo $progname:959: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+  echo "$ac_t$link_static_flag" 1>&6
+else
+  echo "$ac_t"none 1>&6
+  link_static_flag=
+fi
+LDFLAGS="$save_LDFLAGS"
+$rm conftest*
+
+if test -z "$LN_S"; then
+  # Check to see if we can use ln -s, or we need hard links.
+  echo $ac_n "checking whether ln -s works... $ac_c" 1>&6
+  $rm conftest.dat
+  if ln -s X conftest.dat 2>/dev/null; then
+    $rm conftest.dat
+    LN_S="ln -s"
+  else
+    LN_S=ln
+  fi
+  if test "$LN_S" = "ln -s"; then
+    echo "$ac_t"yes 1>&6
+  else
+    echo "$ac_t"no 1>&6
+  fi
+fi
+
+# Make sure LD is an absolute path.
+if test -z "$LD"; then
+  ac_prog=ld
+  if test "$with_gcc" = yes; then
+    # Check if gcc -print-prog-name=ld gives a path.
+    echo $ac_n "checking for ld used by GCC... $ac_c" 1>&6
+    echo "$progname:991: checking for ld used by GCC" >&5
+    ac_prog=`($CC -print-prog-name=ld) 2>&5`
+    case "$ac_prog" in
+    # Accept absolute paths.
+    [\\/]* | [A-Za-z]:[\\/]*)
+      re_direlt='/[^/][^/]*/\.\./'
+      # Canonicalize the path of ld
+      ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
+      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
+       ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
+      done
+      test -z "$LD" && LD="$ac_prog"
+      ;;
+    "")
+      # If it fails, then pretend we are not using GCC.
+      ac_prog=ld
+      ;;
+    *)
+      # If it is relative, then search for the first ld in PATH.
+      with_gnu_ld=unknown
+      ;;
+    esac
+  elif test "$with_gnu_ld" = yes; then
+    echo $ac_n "checking for GNU ld... $ac_c" 1>&6
+    echo "$progname:1015: checking for GNU ld" >&5
+  else
+    echo $ac_n "checking for non-GNU ld""... $ac_c" 1>&6
+    echo "$progname:1018: checking for non-GNU ld" >&5
+  fi
+
+  if test -z "$LD"; then
+    IFS="${IFS=        }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}"
+    for ac_dir in $PATH; do
+      test -z "$ac_dir" && ac_dir=.
+      if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+       LD="$ac_dir/$ac_prog"
+       # Check to see if the program is GNU ld.  I'd rather use --version,
+       # but apparently some GNU ld's only accept -v.
+       # Break only if it was the GNU/non-GNU ld that we prefer.
+       if "$LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
+         test "$with_gnu_ld" != no && break
+       else
+         test "$with_gnu_ld" != yes && break
+       fi
+      fi
+    done
+    IFS="$ac_save_ifs"
+  fi
+
+  if test -n "$LD"; then
+    echo "$ac_t$LD" 1>&6
+  else
+    echo "$ac_t"no 1>&6
+  fi
+
+  if test -z "$LD"; then
+    echo "$progname: error: no acceptable ld found in \$PATH" 1>&2
+    exit 1
+  fi
+fi
+
+# Check to see if it really is or is not GNU ld.
+echo $ac_n "checking if the linker ($LD) is GNU ld... $ac_c" 1>&6
+# I'd rather use --version here, but apparently some GNU ld's only accept -v.
+if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
+  with_gnu_ld=yes
+else
+  with_gnu_ld=no
+fi
+echo "$ac_t$with_gnu_ld" 1>&6
+
+# See if the linker supports building shared libraries.
+echo $ac_n "checking whether the linker ($LD) supports shared libraries... $ac_c" 1>&6
+
+allow_undefined_flag=
+no_undefined_flag=
+need_lib_prefix=unknown
+need_version=unknown
+# when you set need_version to no, make sure it does not cause -set_version
+# flags to be left without arguments
+archive_cmds=
+archive_expsym_cmds=
+old_archive_from_new_cmds=
+export_dynamic_flag_spec=
+whole_archive_flag_spec=
+thread_safe_flag_spec=
+hardcode_libdir_flag_spec=
+hardcode_libdir_separator=
+hardcode_direct=no
+hardcode_minus_L=no
+hardcode_shlibpath_var=unsupported
+runpath_var=
+always_export_symbols=no
+export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | sed '\''s/.* //'\'' | sort | uniq > $export_symbols'
+# include_expsyms should be a list of space-separated symbols to be *always*
+# included in the symbol list
+include_expsyms=
+# exclude_expsyms can be an egrep regular expression of symbols to exclude
+# it will be wrapped by ` (' and `)$', so one must not match beginning or
+# end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
+# as well as any symbol that contains `d'.
+exclude_expsyms="_GLOBAL_OFFSET_TABLE_"
+# Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
+# platforms (ab)use it in PIC code, but their linkers get confused if
+# the symbol is explicitly referenced.  Since portable code cannot
+# rely on this symbol name, it's probably fine to never include it in
+# preloaded symbol tables.
+
+case "$host_os" in
+cygwin* | mingw*)
+  # FIXME: the MSVC++ port hasn't been tested in a loooong time
+  # When not using gcc, we currently assume that we are using
+  # Microsoft Visual C++.
+  if test "$with_gcc" != yes; then
+    with_gnu_ld=no
+  fi
+  ;;
+
+esac
+
+ld_shlibs=yes
+if test "$with_gnu_ld" = yes; then
+  # If archive_cmds runs LD, not CC, wlarc should be empty
+  wlarc='${wl}'
+
+  # See if GNU ld supports shared libraries.
+  case "$host_os" in
+  aix3* | aix4*)
+    # On AIX, the GNU linker is very broken
+    ld_shlibs=no
+    cat <<EOF 1>&2
+
+*** Warning: the GNU linker, at least up to release 2.9.1, is reported
+*** to be unable to reliably create shared libraries on AIX.
+*** Therefore, libtool is disabling shared libraries support.  If you
+*** really care for shared libraries, you may want to modify your PATH
+*** so that a non-GNU linker is found, and then restart.
+
+EOF
+    ;;
+
+  amigaos*)
+    archive_cmds='$rm $objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $objdir/a2ixlibrary.data~$AR cru $lib $libobjs~$RANLIB $lib~(cd $objdir && a2ixlibrary -32)'
+    hardcode_libdir_flag_spec='-L$libdir'
+    hardcode_minus_L=yes
+
+    # Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports
+    # that the semantics of dynamic libraries on AmigaOS, at least up
+    # to version 4, is to share data among multiple programs linked
+    # with the same dynamic library.  Since this doesn't match the
+    # behavior of shared libraries on other platforms, we can use
+    # them.
+    ld_shlibs=no
+    ;;
+
+  beos*)
+    if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
+      allow_undefined_flag=unsupported
+      # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
+      # support --undefined.  This deserves some investigation.  FIXME
+      archive_cmds='$CC -nostart $libobjs $deplibs $linkopts ${wl}-soname $wl$soname -o $lib'
+    else
+      ld_shlibs=no
+    fi
+    ;;
+
+  cygwin* | mingw*)
+    # hardcode_libdir_flag_spec is actually meaningless, as there is
+    # no search path for DLLs.
+    hardcode_libdir_flag_spec='-L$libdir'
+    allow_undefined_flag=unsupported
+    always_export_symbols=yes
+
+    # Extract the symbol export list from an `--export-all' def file,
+    # then regenerate the def file from the symbol export list, so that
+    # the compiled dll only exports the symbol export list.
+    # Be careful not to strip the DATA tag left by newer dlltools.
+    export_symbols_cmds='test -f $objdir/$soname-ltdll.c || sed -e "/^# \/\* ltdll\.c starts here \*\//,/^# \/\* ltdll.c ends here \*\// { s/^# //; p; }" -e d < $0 > $objdir/$soname-ltdll.c~
+      test -f $objdir/$soname-ltdll.$objext || (cd $objdir && $CC -c $soname-ltdll.c)~
+      $DLLTOOL --export-all --exclude-symbols DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12 --output-def $objdir/$soname-def  $objdir/$soname-ltdll.$objext $libobjs $convenience~
+      sed -e "1,/EXPORTS/d" -e "s/ @ [0-9]*//" -e "s/ *;.*$//" < $objdir/$soname-def > $export_symbols'
+
+    # If DATA tags from a recent dlltool are present, honour them!
+    archive_expsym_cmds='echo EXPORTS > $objdir/$soname-def~
+      _lt_hint=1;
+      cat $export_symbols | while read symbol; do
+        set dummy \$symbol;
+        case \$# in
+          2) echo "    \$2 @ \$_lt_hint ; " >> $objdir/$soname-def;;
+          *) echo "     \$2 @ \$_lt_hint \$3 ; " >> $objdir/$soname-def;;
+        esac;
+       _lt_hint=`expr 1 + \$_lt_hint`;
+      done~
+      test -f $objdir/$soname-ltdll.c || sed -e "/^# \/\* ltdll\.c starts here \*\//,/^# \/\* ltdll.c ends here \*\// { s/^# //; p; }" -e d < $0 > $objdir/$soname-ltdll.c~
+      test -f $objdir/$soname-ltdll.$objext || (cd $objdir && $CC -c $soname-ltdll.c)~
+      $CC -Wl,--base-file,$objdir/$soname-base -Wl,--dll -nostartfiles -Wl,-e,__cygwin_dll_entry@12 -o $lib $objdir/$soname-ltdll.$objext $libobjs $deplibs $linkopts~
+      $DLLTOOL --as=$AS --dllname $soname --exclude-symbols DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12 --def $objdir/$soname-def --base-file $objdir/$soname-base --output-exp $objdir/$soname-exp~
+      $CC -Wl,--base-file,$objdir/$soname-base $objdir/$soname-exp -Wl,--dll -nostartfiles -Wl,-e,__cygwin_dll_entry@12 -o $lib $objdir/$soname-ltdll.$objext $libobjs $deplibs $linkopts~
+      $DLLTOOL --as=$AS --dllname $soname --exclude-symbols DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12 --def $objdir/$soname-def --base-file $objdir/$soname-base --output-exp $objdir/$soname-exp~
+      $CC $objdir/$soname-exp -Wl,--dll -nostartfiles -Wl,-e,__cygwin_dll_entry@12 -o $lib $objdir/$soname-ltdll.$objext $libobjs $deplibs $linkopts'
+
+      old_archive_from_new_cmds='$DLLTOOL --as=$AS --dllname $soname --def $objdir/$soname-def --output-lib $objdir/$libname.a' 
+    ;;
+
+  netbsd*)
+    if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+      archive_cmds='$LD -Bshareable $libobjs $deplibs $linkopts -o $lib'
+      # can we support soname and/or expsyms with a.out? -oliva
+    else
+      archive_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname -o $lib'
+      archive_expsym_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+    fi
+    ;;
+
+  solaris* | sysv5*)
+    if $LD -v 2>&1 | egrep 'BFD 2\.8' > /dev/null; then
+      ld_shlibs=no
+      cat <<EOF 1>&2
+
+*** Warning: The releases 2.8.* of the GNU linker cannot reliably
+*** create shared libraries on Solaris systems.  Therefore, libtool
+*** is disabling shared libraries support.  We urge you to upgrade GNU
+*** binutils to release 2.9.1 or newer.  Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+EOF
+    elif $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
+      archive_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname -o $lib'
+      archive_expsym_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+    else
+      ld_shlibs=no
+    fi
+    ;;      
+
+  sunos4*)
+    archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linkopts'
+    wlarc=
+    hardcode_direct=yes
+    hardcode_shlibpath_var=no
+    ;;
+
+  *)
+    if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
+      archive_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname -o $lib'
+      archive_expsym_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+    else
+      ld_shlibs=no
+    fi
+    ;;
+  esac
+
+  if test "$ld_shlibs" = yes; then
+    runpath_var=LD_RUN_PATH
+    hardcode_libdir_flag_spec='${wl}--rpath ${wl}$libdir'
+    export_dynamic_flag_spec='${wl}--export-dynamic'
+    case $host_os in
+    cygwin* | mingw*)
+      # dlltool doesn't understand --whole-archive et. al.
+      whole_archive_flag_spec=
+      ;;
+    *)
+      # ancient GNU ld didn't support --whole-archive et. al.
+      if $LD --help 2>&1 | egrep 'no-whole-archive' > /dev/null; then
+        whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+      else
+        whole_archive_flag_spec=
+      fi
+      ;;
+    esac
+  fi
+else
+  # PORTME fill in a description of your system's linker (not GNU ld)
+  case "$host_os" in
+  aix3*)
+    allow_undefined_flag=unsupported
+    always_export_symbols=yes
+    archive_expsym_cmds='$LD -o $objdir/$soname $libobjs $deplibs $linkopts -bE:$export_symbols -T512 -H512 -bM:SRE~$AR cru $lib $objdir/$soname'
+    # Note: this linker hardcodes the directories in LIBPATH if there
+    # are no directories specified by -L.
+    hardcode_minus_L=yes
+    if test "$with_gcc" = yes && test -z "$link_static_flag"; then
+      # Neither direct hardcoding nor static linking is supported with a
+      # broken collect2.
+      hardcode_direct=unsupported
+    fi
+    ;;
+
+  aix4*)
+    hardcode_libdir_flag_spec='${wl}-b ${wl}nolibpath ${wl}-b ${wl}libpath:$libdir:/usr/lib:/lib'
+    hardcode_libdir_separator=':'
+    if test "$with_gcc" = yes; then
+      collect2name=`${CC} -print-prog-name=collect2`
+      if test -f "$collect2name" && \
+        strings "$collect2name" | grep resolve_lib_name >/dev/null
+      then
+       # We have reworked collect2
+       hardcode_direct=yes
+      else
+       # We have old collect2
+       hardcode_direct=unsupported
+       # It fails to find uninstalled libraries when the uninstalled
+       # path is not listed in the libpath.  Setting hardcode_minus_L
+       # to unsupported forces relinking
+       hardcode_minus_L=yes
+       hardcode_libdir_flag_spec='-L$libdir'
+       hardcode_libdir_separator=
+      fi
+      shared_flag='-shared'
+    else
+      shared_flag='${wl}-bM:SRE'
+      hardcode_direct=yes
+    fi
+    allow_undefined_flag=' ${wl}-berok'
+    archive_cmds="\$CC $shared_flag"' -o $objdir/$soname $libobjs $deplibs $linkopts ${wl}-bexpall ${wl}-bnoentry${allow_undefined_flag}'
+    archive_expsym_cmds="\$CC $shared_flag"' -o $objdir/$soname $libobjs $deplibs $linkopts ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}'
+    case "$host_os" in aix4.[01]|aix4.[01].*)
+      # According to Greg Wooledge, -bexpall is only supported from AIX 4.2 on
+      always_export_symbols=yes ;;
+    esac
+   ;;
+
+  amigaos*)
+    archive_cmds='$rm $objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $objdir/a2ixlibrary.data~$AR cru $lib $libobjs~$RANLIB $lib~(cd $objdir && a2ixlibrary -32)'
+    hardcode_libdir_flag_spec='-L$libdir'
+    hardcode_minus_L=yes
+    # see comment about different semantics on the GNU ld section
+    ld_shlibs=no
+    ;;
+
+  cygwin* | mingw*)
+    # When not using gcc, we currently assume that we are using
+    # Microsoft Visual C++.
+    # hardcode_libdir_flag_spec is actually meaningless, as there is
+    # no search path for DLLs.
+    hardcode_libdir_flag_spec=' '
+    allow_undefined_flag=unsupported
+    # Tell ltmain to make .lib files, not .a files.
+    libext=lib
+    # FIXME: Setting linknames here is a bad hack.
+    archive_cmds='$CC -o $lib $libobjs $linkopts `echo "$deplibs" | sed -e '\''s/ -lc$//'\''` -link -dll~linknames='
+    # The linker will automatically build a .lib file if we build a DLL.
+    old_archive_from_new_cmds='true'
+    # FIXME: Should let the user specify the lib program.
+    old_archive_cmds='lib /OUT:$oldlib$oldobjs'
+    fix_srcfile_path='`cygpath -w $srcfile`'
+    ;;
+
+  freebsd1*)
+    ld_shlibs=no
+    ;;
+
+  # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
+  # support.  Future versions do this automatically, but an explicit c++rt0.o
+  # does not break anything, and helps significantly (at the cost of a little
+  # extra space).
+  freebsd2.2*)
+    archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linkopts /usr/lib/c++rt0.o'
+    hardcode_libdir_flag_spec='-R$libdir'
+    hardcode_direct=yes
+    hardcode_shlibpath_var=no
+    ;;
+
+  # Unfortunately, older versions of FreeBSD 2 do not have this feature.
+  freebsd2*)
+    archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linkopts'
+    hardcode_direct=yes
+    hardcode_minus_L=yes
+    hardcode_shlibpath_var=no
+    ;;
+
+  # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
+  freebsd*)
+    archive_cmds='$CC -shared -o $lib $libobjs $deplibs $linkopts'
+    hardcode_libdir_flag_spec='-R$libdir'
+    hardcode_direct=yes
+    hardcode_shlibpath_var=no
+    ;;
+
+  hpux9* | hpux10* | hpux11*)
+    case "$host_os" in
+    hpux9*) archive_cmds='$rm $objdir/$soname~$LD -b +b $install_libdir -o $objdir/$soname $libobjs $deplibs $linkopts~test $objdir/$soname = $lib || mv $objdir/$soname $lib' ;;
+    *) archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linkopts' ;;
+    esac
+    hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+    hardcode_libdir_separator=:
+    hardcode_direct=yes
+    hardcode_minus_L=yes # Not in the search PATH, but as the default
+                        # location of the library.
+    export_dynamic_flag_spec='${wl}-E'
+    ;;
+
+  irix5* | irix6*)
+    if test "$with_gcc" = yes; then
+      archive_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib'
+    else
+      archive_cmds='$LD -shared $libobjs $deplibs $linkopts -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib'
+    fi
+    hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+    hardcode_libdir_separator=:
+    ;;
+
+  netbsd*)
+    if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+      archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linkopts'  # a.out
+    else
+      archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linkopts'      # ELF
+    fi
+    hardcode_libdir_flag_spec='${wl}-R$libdir'
+    hardcode_direct=yes
+    hardcode_shlibpath_var=no
+    ;;
+
+  openbsd*)
+    archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linkopts'
+    hardcode_libdir_flag_spec='-R$libdir'
+    hardcode_direct=yes
+    hardcode_shlibpath_var=no
+    ;;
+
+  os2*)
+    hardcode_libdir_flag_spec='-L$libdir'
+    hardcode_minus_L=yes
+    allow_undefined_flag=unsupported
+    archive_cmds='$echo "LIBRARY $libname INITINSTANCE" > $objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $objdir/$libname.def~$echo DATA >> $objdir/$libname.def~$echo " SINGLE NONSHARED" >> $objdir/$libname.def~$echo EXPORTS >> $objdir/$libname.def~emxexp $libobjs >> $objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $linkopts $objdir/$libname.def'
+    old_archive_from_new_cmds='emximp -o $objdir/$libname.a $objdir/$libname.def'
+    ;;
+
+  osf3*)
+    if test "$with_gcc" = yes; then
+      allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
+      archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $linkopts ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib'
+    else
+      allow_undefined_flag=' -expect_unresolved \*'
+      archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linkopts -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib'
+    fi
+    hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+    hardcode_libdir_separator=:
+    ;;
+
+  osf4* | osf5*)  # As osf3* with the addition of the -msym flag
+    if test "$with_gcc" = yes; then
+      allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
+      archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $linkopts ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib'
+    else
+      allow_undefined_flag=' -expect_unresolved \*'
+      archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linkopts -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib'
+    fi
+    hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+    hardcode_libdir_separator=:
+    ;;
+  rhapsody*)
+    archive_cmds='$CC -bundle -undefined suppress -o $lib $libobjs $deplibs $linkopts'
+    hardcode_libdir_flags_spec='-L$libdir'
+    hardcode_direct=yes
+    hardcode_shlibpath_var=no
+    ;;
+                                       
+  sco3.2v5*)
+    archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts'
+    hardcode_shlibpath_var=no
+    runpath_var=LD_RUN_PATH
+    hardcode_runpath_var=yes
+    ;;
+
+  solaris*)
+    no_undefined_flag=' -z text'
+    # $CC -shared without GNU ld will not create a library from C++
+    # object files and a static libstdc++, better avoid it by now
+    archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linkopts'
+    archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+               $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linkopts~$rm $lib.exp'
+    hardcode_libdir_flag_spec='-R$libdir'
+    hardcode_shlibpath_var=no
+    case "$host_os" in
+    solaris2.[0-5] | solaris2.[0-5].*) ;;
+    *) # Supported since Solaris 2.6 (maybe 2.5.1?)
+      whole_archive_flag_spec='-z allextract$convenience -z defaultextract' ;;
+    esac
+    ;;
+
+  sunos4*)
+    archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linkopts'
+    hardcode_libdir_flag_spec='-L$libdir'
+    hardcode_direct=yes
+    hardcode_minus_L=yes
+    hardcode_shlibpath_var=no
+    ;;
+
+  sysv4)
+    if test "x$host_vendor" = xsequent; then
+      # Use $CC to link under sequent, because it throws in some extra .o 
+      # files that make .init and .fini sections work.
+      archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $linkopts'
+    else
+      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts'
+    fi
+    runpath_var='LD_RUN_PATH'
+    hardcode_shlibpath_var=no
+    hardcode_direct=no #Motorola manual says yes, but my tests say they lie 
+    ;;  
+
+  sysv4.3*)
+    archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts'
+    hardcode_shlibpath_var=no
+    export_dynamic_flag_spec='-Bexport'
+    ;;
+
+  sysv5*)
+    no_undefined_flag=' -z text'
+    # $CC -shared without GNU ld will not create a library from C++
+    # object files and a static libstdc++, better avoid it by now
+    archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linkopts'
+    archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+               $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linkopts~$rm $lib.exp'
+    hardcode_libdir_flag_spec=
+    hardcode_shlibpath_var=no
+    runpath_var='LD_RUN_PATH'
+    ;;
+
+  uts4*)
+    archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts'
+    hardcode_libdir_flag_spec='-L$libdir'
+    hardcode_shlibpath_var=no
+    ;;
+
+  dgux*)
+    archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts'
+    hardcode_libdir_flag_spec='-L$libdir'
+    hardcode_shlibpath_var=no
+    ;;
+
+  sysv4*MP*)
+    if test -d /usr/nec; then
+      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts'
+      hardcode_shlibpath_var=no
+      runpath_var=LD_RUN_PATH
+      hardcode_runpath_var=yes
+      ld_shlibs=yes
+    fi
+    ;;
+
+  sysv4.2uw2*)
+    archive_cmds='$LD -G -o $lib $libobjs $deplibs $linkopts'
+    hardcode_direct=yes
+    hardcode_minus_L=no
+    hardcode_shlibpath_var=no
+    hardcode_runpath_var=yes
+    runpath_var=LD_RUN_PATH
+    ;;
+
+  unixware7*)
+    archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts'
+    runpath_var='LD_RUN_PATH'
+    hardcode_shlibpath_var=no
+    ;;
+
+  *)
+    ld_shlibs=no
+    ;;
+  esac
+fi
+echo "$ac_t$ld_shlibs" 1>&6
+test "$ld_shlibs" = no && can_build_shared=no
+
+if test -z "$NM"; then
+  echo $ac_n "checking for BSD-compatible nm... $ac_c" 1>&6
+  case "$NM" in
+  [\\/]* | [A-Za-z]:[\\/]*) ;; # Let the user override the test with a path.
+  *)
+    IFS="${IFS=        }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}"
+    for ac_dir in $PATH /usr/ucb /usr/ccs/bin /bin; do
+      test -z "$ac_dir" && ac_dir=.
+      if test -f $ac_dir/nm || test -f $ac_dir/nm$ac_exeext; then
+       # Check to see if the nm accepts a BSD-compat flag.
+       # Adding the `sed 1q' prevents false positives on HP-UX, which says:
+       #   nm: unknown option "B" ignored
+       if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
+         NM="$ac_dir/nm -B"
+         break
+       elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
+         NM="$ac_dir/nm -p"
+         break
+       else
+         NM=${NM="$ac_dir/nm"} # keep the first match, but
+         continue # so that we can try to find one that supports BSD flags
+       fi
+      fi
+    done
+    IFS="$ac_save_ifs"
+    test -z "$NM" && NM=nm
+    ;;
+  esac
+  echo "$ac_t$NM" 1>&6
+fi
+
+# Check for command to grab the raw symbol name followed by C symbol from nm.
+echo $ac_n "checking command to parse $NM output... $ac_c" 1>&6
+
+# These are sane defaults that work on at least a few old systems.
+# [They come from Ultrix.  What could be older than Ultrix?!! ;)]
+
+# Character class describing NM global symbol codes.
+symcode='[BCDEGRST]'
+
+# Regexp to match symbols that can be accessed directly from C.
+sympat='\([_A-Za-z][_A-Za-z0-9]*\)'
+
+# Transform the above into a raw symbol and a C symbol.
+symxfrm='\1 \2\3 \3'
+
+# Transform an extracted symbol line into a proper C declaration
+global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern char \1;/p'"
+
+# Define system-specific variables.
+case "$host_os" in
+aix*)
+  symcode='[BCDT]'
+  ;;
+cygwin* | mingw*)
+  symcode='[ABCDGISTW]'
+  ;;
+hpux*) # Its linker distinguishes data from code symbols
+  global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern char \1();/p' -e 's/^. .* \(.*\)$/extern char \1;/p'"
+  ;;
+irix*)
+  symcode='[BCDEGRST]'
+  ;;
+solaris*)
+  symcode='[BDT]'
+  ;;
+sysv4)
+  symcode='[DFNSTU]'
+  ;;
+esac
+
+# If we're using GNU nm, then use its standard symbol codes.
+if $NM -V 2>&1 | egrep '(GNU|with BFD)' > /dev/null; then
+  symcode='[ABCDGISTW]'
+fi
+
+# Try without a prefix undercore, then with it.
+for ac_symprfx in "" "_"; do
+
+  # Write the raw and C identifiers.
+  global_symbol_pipe="sed -n -e 's/^.*[        ]\($symcode\)[  ][      ]*\($ac_symprfx\)$sympat$/$symxfrm/p'"
+
+  # Check to see that the pipe works correctly.
+  pipe_works=no
+  $rm conftest*
+  cat > conftest.c <<EOF
+#ifdef __cplusplus
+extern "C" {
+#endif
+char nm_test_var;
+void nm_test_func(){}
+#ifdef __cplusplus
+}
+#endif
+main(){nm_test_var='a';nm_test_func();return(0);}
+EOF
+
+  echo "$progname:1653: checking if global_symbol_pipe works" >&5
+  if { (eval echo $progname:1654: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; } && test -s conftest.$objext; then
+    # Now try to grab the symbols.
+    nlist=conftest.nm
+    if { echo "$progname:1657: eval \"$NM conftest.$objext | $global_symbol_pipe > $nlist\"" >&5; eval "$NM conftest.$objext | $global_symbol_pipe > $nlist 2>&5"; } && test -s "$nlist"; then
+
+      # Try sorting and uniquifying the output.
+      if sort "$nlist" | uniq > "$nlist"T; then
+       mv -f "$nlist"T "$nlist"
+      else
+       rm -f "$nlist"T
+      fi
+
+      # Make sure that we snagged all the symbols we need.
+      if egrep ' nm_test_var$' "$nlist" >/dev/null; then
+       if egrep ' nm_test_func$' "$nlist" >/dev/null; then
+         cat <<EOF > conftest.c
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+EOF
+         # Now generate the symbol file.
+         eval "$global_symbol_to_cdecl"' < "$nlist" >> conftest.c'
+
+         cat <<EOF >> conftest.c
+#if defined (__STDC__) && __STDC__
+# define lt_ptr_t void *
+#else
+# define lt_ptr_t char *
+# define const
+#endif
+
+/* The mapping between symbol names and symbols. */
+const struct {
+  const char *name;
+  lt_ptr_t address;
+}
+lt_preloaded_symbols[] =
+{
+EOF
+         sed 's/^. \(.*\) \(.*\)$/  {"\2", (lt_ptr_t) \&\2},/' < "$nlist" >> conftest.c
+         cat <<\EOF >> conftest.c
+  {0, (lt_ptr_t) 0}
+};
+
+#ifdef __cplusplus
+}
+#endif
+EOF
+         # Now try linking the two files.
+         mv conftest.$objext conftstm.$objext
+         save_LIBS="$LIBS"
+         save_CFLAGS="$CFLAGS"
+         LIBS="conftstm.$objext"
+         CFLAGS="$CFLAGS$no_builtin_flag"
+         if { (eval echo $progname:1709: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+           pipe_works=yes
+         else
+           echo "$progname: failed program was:" >&5
+           cat conftest.c >&5
+         fi
+         LIBS="$save_LIBS"
+       else
+         echo "cannot find nm_test_func in $nlist" >&5
+       fi
+      else
+       echo "cannot find nm_test_var in $nlist" >&5
+      fi
+    else
+      echo "cannot run $global_symbol_pipe" >&5
+    fi
+  else
+    echo "$progname: failed program was:" >&5
+    cat conftest.c >&5
+  fi
+  $rm conftest* conftst*
+
+  # Do not use the global_symbol_pipe unless it works.
+  if test "$pipe_works" = yes; then
+    break
+  else
+    global_symbol_pipe=
+  fi
+done
+if test "$pipe_works" = yes; then
+  echo "${ac_t}ok" 1>&6
+else
+  echo "${ac_t}failed" 1>&6
+fi
+
+if test -z "$global_symbol_pipe"; then
+  global_symbol_to_cdecl=
+fi
+
+# Check hardcoding attributes.
+echo $ac_n "checking how to hardcode library paths into programs... $ac_c" 1>&6
+hardcode_action=
+if test -n "$hardcode_libdir_flag_spec" || \
+   test -n "$runpath_var"; then
+
+  # We can hardcode non-existant directories.
+  if test "$hardcode_direct" != no &&
+     # If the only mechanism to avoid hardcoding is shlibpath_var, we
+     # have to relink, otherwise we might link with an installed library
+     # when we should be linking with a yet-to-be-installed one
+     ## test "$hardcode_shlibpath_var" != no &&
+     test "$hardcode_minus_L" != no; then
+    # Linking always hardcodes the temporary library directory.
+    hardcode_action=relink
+  else
+    # We can link without hardcoding, and we can hardcode nonexisting dirs.
+    hardcode_action=immediate
+  fi
+else
+  # We cannot hardcode anything, or else we can only hardcode existing
+  # directories.
+  hardcode_action=unsupported
+fi
+echo "$ac_t$hardcode_action" 1>&6
+
+
+reload_flag=
+reload_cmds='$LD$reload_flag -o $output$reload_objs'
+echo $ac_n "checking for $LD option to reload object files... $ac_c" 1>&6
+# PORTME Some linkers may need a different reload flag.
+reload_flag='-r'
+echo "$ac_t$reload_flag" 1>&6
+test -n "$reload_flag" && reload_flag=" $reload_flag"
+
+# PORTME Fill in your ld.so characteristics
+library_names_spec=
+libname_spec='lib$name'
+soname_spec=
+postinstall_cmds=
+postuninstall_cmds=
+finish_cmds=
+finish_eval=
+shlibpath_var=
+shlibpath_overrides_runpath=unknown
+version_type=none
+dynamic_linker="$host_os ld.so"
+sys_lib_dlsearch_path_spec="/lib /usr/lib"
+sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+file_magic_cmd=
+file_magic_test_file=
+deplibs_check_method='unknown'
+# Need to set the preceding variable on all platforms that support
+# interlibrary dependencies.
+# 'none' -- dependencies not supported.
+# `unknown' -- same as none, but documents that we really don't know.
+# 'pass_all' -- all dependencies passed with no checks.
+# 'test_compile' -- check by making test program.
+# 'file_magic [regex]' -- check by looking for files in library path
+# which responds to the $file_magic_cmd with a given egrep regex.
+# If you have `file' or equivalent on your system and you're not sure
+# whether `pass_all' will *always* work, you probably want this one.
+echo $ac_n "checking dynamic linker characteristics... $ac_c" 1>&6
+case "$host_os" in
+aix3*)
+  version_type=linux
+  library_names_spec='${libname}${release}.so$versuffix $libname.a'
+  shlibpath_var=LIBPATH
+
+  # AIX has no versioning support, so we append a major version to the name.
+  soname_spec='${libname}${release}.so$major'
+  ;;
+
+aix4*)
+  version_type=linux
+  # AIX has no versioning support, so currently we can not hardcode correct
+  # soname into executable. Probably we can add versioning support to
+  # collect2, so additional links can be useful in future.
+  # We preserve .a as extension for shared libraries though AIX4.2
+  # and later linker supports .so
+  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.a'
+  shlibpath_var=LIBPATH
+  deplibs_check_method=pass_all
+  ;;
+
+amigaos*)
+  library_names_spec='$libname.ixlibrary $libname.a'
+  # Create ${libname}_ixlibrary.a entries in /sys/libs.
+  finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "(cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a)"; (cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a) || exit 1; done'
+  ;;
+
+beos*)
+  library_names_spec='${libname}.so'
+  dynamic_linker="$host_os ld.so"
+  shlibpath_var=LIBRARY_PATH
+  deplibs_check_method=pass_all
+  lt_cv_dlopen="load_add_on"
+  lt_cv_dlopen_libs=
+  lt_cv_dlopen_self=yes
+  ;;
+
+bsdi4*)
+  version_type=linux
+  need_version=no
+  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
+  soname_spec='${libname}${release}.so$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)'
+  file_magic_cmd=/usr/bin/file
+  file_magic_test_file=/shlib/libc.so
+  sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
+  sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
+  export_dynamic_flag_spec=-rdynamic
+  # the default ld.so.conf also contains /usr/contrib/lib and
+  # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
+  # libtool to hard-code these into programs
+  ;;
+
+cygwin* | mingw*)
+  version_type=windows
+  need_version=no
+  need_lib_prefix=no
+  if test "$with_gcc" = yes; then
+    library_names_spec='${libname}`echo ${release} | sed -e 's/[.]/-/g'`${versuffix}.dll $libname.a'
+  else
+    library_names_spec='${libname}`echo ${release} | sed -e 's/[.]/-/g'`${versuffix}.dll $libname.lib'
+  fi
+  dynamic_linker='Win32 ld.exe'
+  deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?'
+  file_magic_cmd='${OBJDUMP} -f'
+  # FIXME: first we should search . and the directory the executable is in
+  shlibpath_var=PATH
+  lt_cv_dlopen="LoadLibrary"
+  lt_cv_dlopen_libs=
+  ;;
+
+freebsd1*)
+  dynamic_linker=no
+  ;;
+  
+freebsd*)
+  objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout`
+  version_type=freebsd-$objformat
+  case "$version_type" in
+    freebsd-elf*)
+      deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB shared object'
+      file_magic_cmd=/usr/bin/file
+      file_magic_test_file=`echo /usr/lib/libc.so*`
+      library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so $libname.so'
+      need_version=no
+      need_lib_prefix=no
+      ;;
+    freebsd-*)
+      deplibs_check_method=unknown
+      library_names_spec='${libname}${release}.so$versuffix $libname.so$versuffix'
+      need_version=yes
+      ;;
+  esac
+  shlibpath_var=LD_LIBRARY_PATH
+  case "$host_os" in
+  freebsd2* | freebsd3.[01]* | freebsdelf3.[01]*)
+    shlibpath_overrides_runpath=yes
+    ;;
+  *) # from 3.2 on
+    shlibpath_overrides_runpath=no
+    ;;
+  esac
+  ;;
+
+gnu*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so${major} ${libname}.so'
+  soname_spec='${libname}${release}.so$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+hpux9* | hpux10* | hpux11*)
+  # Give a soname corresponding to the major version so that dld.sl refuses to
+  # link against other versions.
+  dynamic_linker="$host_os dld.sl"
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  shlibpath_var=SHLIB_PATH
+  shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+  library_names_spec='${libname}${release}.sl$versuffix ${libname}${release}.sl$major $libname.sl'
+  soname_spec='${libname}${release}.sl$major'
+  # HP-UX runs *really* slowly unless shared libraries are mode 555.
+  postinstall_cmds='chmod 555 $lib'
+  case "$host_os" in
+  hpux10.20*)
+    # TODO:  Does this work for hpux-11 too?
+    deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9].[0-9]) shared library'
+    file_magic_cmd=/usr/bin/file
+    file_magic_test_file=/usr/lib/libc.sl
+    ;;
+  esac
+  ;;
+
+irix5* | irix6*)
+  version_type=irix
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}.so.$major'
+  library_names_spec='${libname}${release}.so.$versuffix ${libname}${release}.so.$major ${libname}${release}.so $libname.so'
+  case "$host_os" in
+  irix5*)
+    libsuff= shlibsuff=
+    # this will be overridden with pass_all, but let us keep it just in case
+    deplibs_check_method="file_magic ELF 32-bit MSB dynamic lib MIPS - version 1"
+    ;;
+  *)
+    case "$LD" in # libtool.m4 will add one of these switches to LD
+    *-32|*"-32 ") libsuff= shlibsuff= libmagic=32-bit;;
+    *-n32|*"-n32 ") libsuff=32 shlibsuff=N32 libmagic=N32;;
+    *-64|*"-64 ") libsuff=64 shlibsuff=64 libmagic=64-bit;;
+    *) libsuff= shlibsuff= libmagic=never-match;;
+    esac
+    ;;
+  esac
+  shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
+  shlibpath_overrides_runpath=no
+  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
+  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+  file_magic_cmd=/usr/bin/file
+  file_magic_test_file=`echo /lib${libsuff}/libc.so*`
+  deplibs_check_method='pass_all'
+  ;;
+
+# No shared lib support for Linux oldld, aout, or coff.
+linux-gnuoldld* | linux-gnuaout* | linux-gnucoff*)
+  dynamic_linker=no
+  ;;
+
+# This must be Linux ELF.
+linux-gnu*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
+  soname_spec='${libname}${release}.so$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  deplibs_check_method=pass_all
+
+  if test -f /lib/ld.so.1; then
+    dynamic_linker='GNU ld.so'
+  else
+    # Only the GNU ld.so supports shared libraries on MkLinux.
+    case "$host_cpu" in
+    powerpc*) dynamic_linker=no ;;
+    *) dynamic_linker='Linux ld.so' ;;
+    esac
+  fi
+  ;;
+
+netbsd*)
+  version_type=sunos
+  if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+    library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix'
+    finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+    dynamic_linker='NetBSD (a.out) ld.so'
+  else
+    library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major ${libname}${release}.so ${libname}.so'
+    soname_spec='${libname}${release}.so$major'
+    dynamic_linker='NetBSD ld.elf_so'
+  fi
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+openbsd*)
+  version_type=sunos
+  if test "$with_gnu_ld" = yes; then
+    need_lib_prefix=no
+    need_version=no
+  fi
+  library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+os2*)
+  libname_spec='$name'
+  need_lib_prefix=no
+  library_names_spec='$libname.dll $libname.a'
+  dynamic_linker='OS/2 ld.exe'
+  shlibpath_var=LIBPATH
+  ;;
+
+osf3* | osf4* | osf5*)
+  version_type=osf
+  need_version=no
+  soname_spec='${libname}${release}.so'
+  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so $libname.so'
+  shlibpath_var=LD_LIBRARY_PATH
+  # this will be overridden with pass_all, but let us keep it just in case
+  deplibs_check_method='file_magic COFF format alpha shared library'
+  file_magic_cmd=/usr/bin/file
+  file_magic_test_file=/shlib/libc.so
+  deplibs_check_method='pass_all'
+  sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
+  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+  ;;
+
+rhapsody*)
+  version_type=sunos
+  library_names_spec='${libname}.so'
+  soname_spec='${libname}.so'
+  shlibpath_var=DYLD_LIBRARY_PATH
+  deplibs_check_method=pass_all
+  ;;
+
+sco3.2v5*)
+  version_type=osf
+  soname_spec='${libname}${release}.so$major'
+  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+solaris*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
+  soname_spec='${libname}${release}.so$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  # ldd complains unless libraries are executable
+  postinstall_cmds='chmod +x $lib'
+  deplibs_check_method="file_magic ELF [0-9][0-9]-bit [LM]SB dynamic lib"
+  file_magic_cmd=/usr/bin/file
+  file_magic_test_file=/lib/libc.so
+  ;;
+
+sunos4*)
+  version_type=sunos
+  library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix'
+  finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  if test "$with_gnu_ld" = yes; then
+    need_lib_prefix=no
+  fi
+  need_version=yes
+  ;;
+
+sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+  version_type=linux
+  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
+  soname_spec='${libname}${release}.so$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  case "$host_vendor" in
+    sequent)
+      file_magic_cmd='/bin/file'
+      deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )'
+      ;;
+    ncr)
+      deplibs_check_method='pass_all'
+      ;;
+    motorola)
+      need_lib_prefix=no
+      need_version=no
+      shlibpath_overrides_runpath=no
+      sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
+      deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]'
+      file_magic_cmd=/usr/bin/file
+      file_magic_test_file=`echo /usr/lib/libc.so*`
+      ;;
+  esac
+  ;;
+
+uts4*)
+  version_type=linux
+  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
+  soname_spec='${libname}${release}.so$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+dgux*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
+  soname_spec='${libname}${release}.so$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+sysv4*MP*)
+  if test -d /usr/nec ;then
+    version_type=linux
+    library_names_spec='$libname.so.$versuffix $libname.so.$major $libname.so'
+    soname_spec='$libname.so.$major'
+    shlibpath_var=LD_LIBRARY_PATH
+  fi
+  ;;
+
+*)
+  dynamic_linker=no
+  ;;
+esac
+echo "$ac_t$dynamic_linker" 1>&6
+test "$dynamic_linker" = no && can_build_shared=no
+
+# Report the final consequences.
+echo "checking if libtool supports shared libraries... $can_build_shared" 1>&6
+
+# Only try to build win32 dlls if AC_LIBTOOL_WIN32_DLL was used in
+# configure.in, otherwise build static only libraries.
+case "$host_os" in
+cygwin* | mingw* | os2*)
+  if test x$can_build_shared = xyes; then
+    test x$enable_win32_dll = xno && can_build_shared=no
+    echo "checking if package supports dlls... $can_build_shared" 1>&6
+  fi
+;;
+esac
+
+if test -n "$file_magic_test_file" && test -n "$file_magic_cmd"; then
+  case "$deplibs_check_method" in
+  "file_magic "*)
+    file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`"
+    if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
+       egrep "$file_magic_regex" > /dev/null; then
+      :
+    else
+      cat <<EOF 1>&2
+
+*** Warning: the command libtool uses to detect shared libraries,
+*** $file_magic_cmd, produces output that libtool cannot recognize.
+*** The result is that libtool may fail to recognize shared libraries
+*** as such.  This will affect the creation of libtool libraries that
+*** depend on shared libraries, but programs linked with such libtool
+*** libraries will work regardless of this problem.  Nevertheless, you
+*** may want to report the problem to your system manager and/or to
+*** bug-libtool@gnu.org
+
+EOF
+    fi ;;
+  esac
+fi
+
+echo $ac_n "checking whether to build shared libraries... $ac_c" 1>&6
+test "$can_build_shared" = "no" && enable_shared=no
+
+# On AIX, shared libraries and static libraries use the same namespace, and
+# are all built from PIC.
+case "$host_os" in
+aix3*)
+  test "$enable_shared" = yes && enable_static=no
+  if test -n "$RANLIB"; then
+    archive_cmds="$archive_cmds~\$RANLIB \$lib"
+    postinstall_cmds='$RANLIB $lib'
+  fi
+  ;;
+
+aix4*)
+  test "$enable_shared" = yes && enable_static=no
+  ;;
+esac
+
+echo "$ac_t$enable_shared" 1>&6
+
+# Make sure either enable_shared or enable_static is yes.
+test "$enable_shared" = yes || enable_static=yes
+
+echo "checking whether to build static libraries... $enable_static" 1>&6
+
+if test "$hardcode_action" = relink; then
+  # Fast installation is not supported
+  enable_fast_install=no
+elif test "$shlibpath_overrides_runpath" = yes ||
+     test "$enable_shared" = no; then
+  # Fast installation is not necessary
+  enable_fast_install=needless
+fi
+
+echo $ac_n "checking for objdir... $ac_c" 1>&6
+rm -f .libs 2>/dev/null
+mkdir .libs 2>/dev/null
+if test -d .libs; then
+  objdir=.libs
+else
+  # MS-DOS does not allow filenames that begin with a dot.
+  objdir=_libs
+fi
+rmdir .libs 2>/dev/null
+echo "$ac_t$objdir" 1>&6
+
+if test "x$enable_dlopen" != xyes; then
+  enable_dlopen=unknown
+  enable_dlopen_self=unknown
+  enable_dlopen_self_static=unknown
+else
+if eval "test \"`echo '$''{'lt_cv_dlopen'+set}'`\" != set"; then
+  lt_cv_dlopen=no lt_cv_dlopen_libs=
+echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6
+echo "$progname:2248: checking for dlopen in -ldl" >&5
+ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  ac_save_LIBS="$LIBS"
+LIBS="-ldl  $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 2256 "ltconfig"
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dlopen();
+
+int main() {
+dlopen()
+; return 0; }
+EOF
+if { (eval echo $progname:2269: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=yes"
+else
+  echo "$progname: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
+else
+  echo "$ac_t""no" 1>&6
+echo $ac_n "checking for dlopen""... $ac_c" 1>&6
+echo "$progname:2288: checking for dlopen" >&5
+if eval "test \"`echo '$''{'ac_cv_func_dlopen'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 2293 "ltconfig"
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char dlopen(); below.  */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dlopen();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_dlopen) || defined (__stub___dlopen)
+choke me
+#else
+dlopen();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo $progname:2318: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  rm -rf conftest*
+  eval "ac_cv_func_dlopen=yes"
+else
+  echo "$progname: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_func_dlopen=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_func_'dlopen`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  lt_cv_dlopen="dlopen"
+else
+  echo "$ac_t""no" 1>&6
+echo $ac_n "checking for dld_link in -ldld""... $ac_c" 1>&6
+echo "$progname:2335: checking for dld_link in -ldld" >&5
+ac_lib_var=`echo dld'_'dld_link | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  ac_save_LIBS="$LIBS"
+LIBS="-ldld  $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 2343 "ltconfig"
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dld_link();
+
+int main() {
+dld_link()
+; return 0; }
+EOF
+if { (eval echo $progname:2356: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=yes"
+else
+  echo "$progname: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"
+else
+  echo "$ac_t""no" 1>&6
+echo $ac_n "checking for shl_load""... $ac_c" 1>&6
+echo "$progname:2375: checking for shl_load" >&5
+if eval "test \"`echo '$''{'ac_cv_func_shl_load'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 2380 "ltconfig"
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char shl_load(); below.  */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char shl_load();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_shl_load) || defined (__stub___shl_load)
+choke me
+#else
+shl_load();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo $progname:2405: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  rm -rf conftest*
+  eval "ac_cv_func_shl_load=yes"
+else
+  echo "$progname: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_func_shl_load=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'shl_load`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  lt_cv_dlopen="shl_load"
+else
+  echo "$ac_t""no" 1>&6
+echo $ac_n "checking for shl_load in -ldld""... $ac_c" 1>&6
+echo "$progname:2423: checking for shl_load in -ldld" >&5
+ac_lib_var=`echo dld'_'shl_load | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  ac_save_LIBS="$LIBS"
+LIBS="-ldld  $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 2431 "ltconfig"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char shl_load();
+
+int main() {
+shl_load()
+; return 0; }
+EOF
+if { (eval echo $progname:2445: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=yes"
+else
+  echo "$progname: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+
+fi
+
+    
+fi
+
+  
+fi
+
+
+fi
+
+fi
+
+  if test "x$lt_cv_dlopen" != xno; then
+    enable_dlopen=yes
+  fi
+
+  case "$lt_cv_dlopen" in
+  dlopen)
+for ac_hdr in dlfcn.h; do
+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+echo "$progname:2488: checking for $ac_hdr" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 2493 "ltconfig"
+#include <$ac_hdr>
+int fnord = 0;
+EOF
+ac_try="$ac_compile >/dev/null 2>conftest.out"
+{ (eval echo $progname:2498: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+  rm -rf conftest*
+  eval "ac_cv_header_$ac_safe=yes"
+else
+  echo "$ac_err" >&5
+  echo "$progname: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+else
+  echo "$ac_t""no" 1>&6
+fi
+done
+
+    if test "x$ac_cv_header_dlfcn_h" = xyes; then
+      CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
+    fi
+    eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
+    LIBS="$lt_cv_dlopen_libs $LIBS"
+
+  echo $ac_n "checking whether a program can dlopen itself""... $ac_c" 1>&6
+echo "$progname:2526: checking whether a program can dlopen itself" >&5
+if test "${lt_cv_dlopen_self+set}" = set; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  if test "$cross_compiling" = yes; then
+    lt_cv_dlopen_self=cross
+  else
+    cat > conftest.c <<EOF
+#line 2534 "ltconfig"
+
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#include <stdio.h>
+
+#ifdef RTLD_GLOBAL
+# define LTDL_GLOBAL   RTLD_GLOBAL
+#else
+# ifdef DL_GLOBAL
+#  define LTDL_GLOBAL  DL_GLOBAL
+# else
+#  define LTDL_GLOBAL  0
+# endif
+#endif
+
+/* We may have to define LTDL_LAZY_OR_NOW in the command line if we
+   find out it does not work in some platform. */
+#ifndef LTDL_LAZY_OR_NOW
+# ifdef RTLD_LAZY
+#  define LTDL_LAZY_OR_NOW     RTLD_LAZY
+# else
+#  ifdef DL_LAZY
+#   define LTDL_LAZY_OR_NOW    DL_LAZY
+#  else
+#   ifdef RTLD_NOW
+#    define LTDL_LAZY_OR_NOW   RTLD_NOW
+#   else
+#    ifdef DL_NOW
+#     define LTDL_LAZY_OR_NOW  DL_NOW
+#    else
+#     define LTDL_LAZY_OR_NOW  0
+#    endif
+#   endif
+#  endif
+# endif
+#endif
+
+fnord() { int i=42;}
+main() { void *self, *ptr1, *ptr2; self=dlopen(0,LTDL_GLOBAL|LTDL_LAZY_OR_NOW);
+    if(self) { ptr1=dlsym(self,"fnord"); ptr2=dlsym(self,"_fnord");
+              if(ptr1 || ptr2) { dlclose(self); exit(0); } } exit(1); } 
+
+EOF
+if { (eval echo $progname:2580: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+then
+  lt_cv_dlopen_self=yes
+else
+  echo "$progname: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -fr conftest*
+  lt_cv_dlopen_self=no
+fi
+rm -fr conftest*
+fi
+
+fi
+
+echo "$ac_t""$lt_cv_dlopen_self" 1>&6
+
+  if test "$lt_cv_dlopen_self" = yes; then
+    LDFLAGS="$LDFLAGS $link_static_flag"
+  echo $ac_n "checking whether a statically linked program can dlopen itself""... $ac_c" 1>&6
+echo "$progname:2599: checking whether a statically linked program can dlopen itself" >&5
+if test "${lt_cv_dlopen_self_static+set}" = set; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  if test "$cross_compiling" = yes; then
+    lt_cv_dlopen_self_static=cross
+  else
+    cat > conftest.c <<EOF
+#line 2607 "ltconfig"
+
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#include <stdio.h>
+
+#ifdef RTLD_GLOBAL
+# define LTDL_GLOBAL   RTLD_GLOBAL
+#else
+# ifdef DL_GLOBAL
+#  define LTDL_GLOBAL  DL_GLOBAL
+# else
+#  define LTDL_GLOBAL  0
+# endif
+#endif
+
+/* We may have to define LTDL_LAZY_OR_NOW in the command line if we
+   find out it does not work in some platform. */
+#ifndef LTDL_LAZY_OR_NOW
+# ifdef RTLD_LAZY
+#  define LTDL_LAZY_OR_NOW     RTLD_LAZY
+# else
+#  ifdef DL_LAZY
+#   define LTDL_LAZY_OR_NOW    DL_LAZY
+#  else
+#   ifdef RTLD_NOW
+#    define LTDL_LAZY_OR_NOW   RTLD_NOW
+#   else
+#    ifdef DL_NOW
+#     define LTDL_LAZY_OR_NOW  DL_NOW
+#    else
+#     define LTDL_LAZY_OR_NOW  0
+#    endif
+#   endif
+#  endif
+# endif
+#endif
+
+fnord() { int i=42;}
+main() { void *self, *ptr1, *ptr2; self=dlopen(0,LTDL_GLOBAL|LTDL_LAZY_OR_NOW);
+    if(self) { ptr1=dlsym(self,"fnord"); ptr2=dlsym(self,"_fnord");
+    if(ptr1 || ptr2) { dlclose(self); exit(0); } } exit(1); } 
+
+EOF
+if { (eval echo $progname:2653: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+then
+  lt_cv_dlopen_self_static=yes
+else
+  echo "$progname: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -fr conftest*
+  lt_cv_dlopen_self_static=no
+fi
+rm -fr conftest*
+fi
+
+fi
+
+echo "$ac_t""$lt_cv_dlopen_self_static" 1>&6
+fi
+    ;;
+  esac
+
+  case "$lt_cv_dlopen_self" in
+  yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
+  *) enable_dlopen_self=unknown ;;
+  esac
+
+  case "$lt_cv_dlopen_self_static" in
+  yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
+  *) enable_dlopen_self_static=unknown ;;
+  esac
+fi
+
+# Copy echo and quote the copy, instead of the original, because it is
+# used later.
+ltecho="$echo"
+if test "X$ltecho" = "X$CONFIG_SHELL $0 --fallback-echo"; then
+   ltecho="$CONFIG_SHELL \$0 --fallback-echo"
+fi
+LTSHELL="$SHELL"
+
+LTCONFIG_VERSION="$VERSION"
+
+# Only quote variables if we're using ltmain.sh.
+case "$ltmain" in
+*.sh)
+  # Now quote all the things that may contain metacharacters.
+  for var in ltecho old_CC old_CFLAGS old_CPPFLAGS \
+    old_LD old_LDFLAGS old_LIBS \
+    old_NM old_RANLIB old_LN_S old_DLLTOOL old_OBJDUMP old_AS \
+    AR CC LD LN_S NM LTSHELL LTCONFIG_VERSION \
+    reload_flag reload_cmds wl \
+    pic_flag link_static_flag no_builtin_flag export_dynamic_flag_spec \
+    thread_safe_flag_spec whole_archive_flag_spec libname_spec \
+    library_names_spec soname_spec \
+    RANLIB old_archive_cmds old_archive_from_new_cmds old_postinstall_cmds \
+    old_postuninstall_cmds archive_cmds archive_expsym_cmds postinstall_cmds postuninstall_cmds \
+    file_magic_cmd export_symbols_cmds deplibs_check_method allow_undefined_flag no_undefined_flag \
+    finish_cmds finish_eval global_symbol_pipe global_symbol_to_cdecl \
+    hardcode_libdir_flag_spec hardcode_libdir_separator  \
+    sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
+    compiler_c_o compiler_o_lo need_locks exclude_expsyms include_expsyms; do
+
+    case "$var" in
+    reload_cmds | old_archive_cmds | old_archive_from_new_cmds | \
+    old_postinstall_cmds | old_postuninstall_cmds | \
+    export_symbols_cmds | archive_cmds | archive_expsym_cmds | \
+    postinstall_cmds | postuninstall_cmds | \
+    finish_cmds | sys_lib_search_path_spec | sys_lib_dlsearch_path_spec)
+      # Double-quote double-evaled strings.
+      eval "$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\""
+      ;;
+    *)
+      eval "$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\""
+      ;;
+    esac
+  done
+
+  case "$ltecho" in
+  *'\$0 --fallback-echo"')
+    ltecho=`$echo "X$ltecho" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'`
+    ;;
+  esac
+
+  trap "$rm \"$ofile\"; exit 1" 1 2 15
+  echo "creating $ofile"
+  $rm "$ofile"
+  cat <<EOF > "$ofile"
+#! $SHELL
+
+# `$echo "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
+# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP)
+# NOTE: Changes made to this file will be lost: look at ltconfig or ltmain.sh.
+#
+# Copyright (C) 1996-1999 Free Software Foundation, Inc.
+# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Sed that helps us avoid accidentally triggering echo(1) options like -n.
+Xsed="sed -e s/^X//"
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+if test "X\${CDPATH+set}" = Xset; then CDPATH=:; export CDPATH; fi
+
+### BEGIN LIBTOOL CONFIG
+EOF
+  cfgfile="$ofile"
+  ;;
+
+*)
+  # Double-quote the variables that need it (for aesthetics).
+  for var in old_CC old_CFLAGS old_CPPFLAGS \
+    old_LD old_LDFLAGS old_LIBS \
+    old_NM old_RANLIB old_LN_S old_DLLTOOL old_OBJDUMP old_AS; do
+    eval "$var=\\\"\$var\\\""
+  done
+
+  # Just create a config file.
+  cfgfile="$ofile.cfg"
+  trap "$rm \"$cfgfile\"; exit 1" 1 2 15
+  echo "creating $cfgfile"
+  $rm "$cfgfile"
+  cat <<EOF > "$cfgfile"
+# `$echo "$cfgfile" | sed 's%^.*/%%'` - Libtool configuration file.
+# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP)
+EOF
+  ;;
+esac
+
+cat <<EOF >> "$cfgfile"
+# Libtool was configured as follows, on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+#
+# CC=$old_CC CFLAGS=$old_CFLAGS CPPFLAGS=$old_CPPFLAGS \\
+# LD=$old_LD LDFLAGS=$old_LDFLAGS LIBS=$old_LIBS \\
+# NM=$old_NM RANLIB=$old_RANLIB LN_S=$old_LN_S \\
+# DLLTOOL=$old_DLLTOOL OBJDUMP=$old_OBJDUMP AS=$old_AS \\
+#   $0$ltconfig_args
+#
+# Compiler and other test output produced by $progname, useful for
+# debugging $progname, is in ./config.log if it exists.
+
+# The version of $progname that generated this script.
+LTCONFIG_VERSION=$LTCONFIG_VERSION
+
+# Shell to use when invoking shell scripts.
+SHELL=$LTSHELL
+
+# Whether or not to build shared libraries.
+build_libtool_libs=$enable_shared
+
+# Whether or not to build static libraries.
+build_old_libs=$enable_static
+
+# Whether or not to optimize for fast installation.
+fast_install=$enable_fast_install
+
+# The host system.
+host_alias=$host_alias
+host=$host
+
+# An echo program that does not interpret backslashes.
+echo=$ltecho
+
+# The archiver.
+AR=$AR
+
+# The default C compiler.
+CC=$CC
+
+# The linker used to build libraries.
+LD=$LD
+
+# Whether we need hard or soft links.
+LN_S=$LN_S
+
+# A BSD-compatible nm program.
+NM=$NM
+
+# Used on cygwin: DLL creation program.
+DLLTOOL="$DLLTOOL"
+
+# Used on cygwin: object dumper.
+OBJDUMP="$OBJDUMP"
+
+# Used on cygwin: assembler.
+AS="$AS"
+
+# The name of the directory that contains temporary libtool files.
+objdir=$objdir
+
+# How to create reloadable object files.
+reload_flag=$reload_flag
+reload_cmds=$reload_cmds
+
+# How to pass a linker flag through the compiler.
+wl=$wl
+
+# Object file suffix (normally "o").
+objext="$objext"
+
+# Old archive suffix (normally "a").
+libext="$libext"
+
+# Executable file suffix (normally "").
+exeext="$exeext"
+
+# Additional compiler flags for building library objects.
+pic_flag=$pic_flag
+
+# Does compiler simultaneously support -c and -o options?
+compiler_c_o=$compiler_c_o
+
+# Can we write directly to a .lo ?
+compiler_o_lo=$compiler_o_lo
+
+# Must we lock files when doing compilation ?
+need_locks=$need_locks
+
+# Do we need the lib prefix for modules?
+need_lib_prefix=$need_lib_prefix
+
+# Do we need a version for libraries?
+need_version=$need_version
+
+# Whether dlopen is supported.
+dlopen=$enable_dlopen
+
+# Whether dlopen of programs is supported.
+dlopen_self=$enable_dlopen_self
+
+# Whether dlopen of statically linked programs is supported.
+dlopen_self_static=$enable_dlopen_self_static
+
+# Compiler flag to prevent dynamic linking.
+link_static_flag=$link_static_flag
+
+# Compiler flag to turn off builtin functions.
+no_builtin_flag=$no_builtin_flag
+
+# Compiler flag to allow reflexive dlopens.
+export_dynamic_flag_spec=$export_dynamic_flag_spec
+
+# Compiler flag to generate shared objects directly from archives.
+whole_archive_flag_spec=$whole_archive_flag_spec
+
+# Compiler flag to generate thread-safe objects.
+thread_safe_flag_spec=$thread_safe_flag_spec
+
+# Library versioning type.
+version_type=$version_type
+
+# Format of library name prefix.
+libname_spec=$libname_spec
+
+# List of archive names.  First name is the real one, the rest are links.
+# The last name is the one that the linker finds with -lNAME.
+library_names_spec=$library_names_spec
+
+# The coded name of the library, if different from the real name.
+soname_spec=$soname_spec
+
+# Commands used to build and install an old-style archive.
+RANLIB=$RANLIB
+old_archive_cmds=$old_archive_cmds
+old_postinstall_cmds=$old_postinstall_cmds
+old_postuninstall_cmds=$old_postuninstall_cmds
+
+# Create an old-style archive from a shared archive.
+old_archive_from_new_cmds=$old_archive_from_new_cmds
+
+# Commands used to build and install a shared archive.
+archive_cmds=$archive_cmds
+archive_expsym_cmds=$archive_expsym_cmds
+postinstall_cmds=$postinstall_cmds
+postuninstall_cmds=$postuninstall_cmds
+
+# Method to check whether dependent libraries are shared objects.
+deplibs_check_method=$deplibs_check_method
+
+# Command to use when deplibs_check_method == file_magic.
+file_magic_cmd=$file_magic_cmd
+
+# Flag that allows shared libraries with undefined symbols to be built.
+allow_undefined_flag=$allow_undefined_flag
+
+# Flag that forces no undefined symbols.
+no_undefined_flag=$no_undefined_flag
+
+# Commands used to finish a libtool library installation in a directory.
+finish_cmds=$finish_cmds
+
+# Same as above, but a single script fragment to be evaled but not shown.
+finish_eval=$finish_eval
+
+# Take the output of nm and produce a listing of raw symbols and C names.
+global_symbol_pipe=$global_symbol_pipe
+
+# Transform the output of nm in a proper C declaration
+global_symbol_to_cdecl=$global_symbol_to_cdecl
+
+# This is the shared library runtime path variable.
+runpath_var=$runpath_var
+
+# This is the shared library path variable.
+shlibpath_var=$shlibpath_var
+
+# Is shlibpath searched before the hard-coded library search path?
+shlibpath_overrides_runpath=$shlibpath_overrides_runpath
+
+# How to hardcode a shared library path into an executable.
+hardcode_action=$hardcode_action
+
+# Flag to hardcode \$libdir into a binary during linking.
+# This must work even if \$libdir does not exist.
+hardcode_libdir_flag_spec=$hardcode_libdir_flag_spec
+
+# Whether we need a single -rpath flag with a separated argument.
+hardcode_libdir_separator=$hardcode_libdir_separator
+
+# Set to yes if using DIR/libNAME.so during linking hardcodes DIR into the
+# resulting binary.
+hardcode_direct=$hardcode_direct
+
+# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
+# resulting binary.
+hardcode_minus_L=$hardcode_minus_L
+
+# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
+# the resulting binary.
+hardcode_shlibpath_var=$hardcode_shlibpath_var
+
+# Compile-time system search path for libraries
+sys_lib_search_path_spec=$sys_lib_search_path_spec
+
+# Run-time system search path for libraries
+sys_lib_dlsearch_path_spec=$sys_lib_dlsearch_path_spec
+
+# Fix the shell variable \$srcfile for the compiler.
+fix_srcfile_path="$fix_srcfile_path"
+
+# Set to yes if exported symbols are required.
+always_export_symbols=$always_export_symbols
+
+# The commands to list exported symbols.
+export_symbols_cmds=$export_symbols_cmds
+
+# Symbols that should not be listed in the preloaded symbols.
+exclude_expsyms=$exclude_expsyms
+
+# Symbols that must always be exported.
+include_expsyms=$include_expsyms
+
+EOF
+
+case "$ltmain" in
+*.sh)
+  echo '### END LIBTOOL CONFIG' >> "$ofile"
+  echo >> "$ofile"
+  case "$host_os" in
+  aix3*)
+    cat <<\EOF >> "$ofile"
+
+# AIX sometimes has problems with the GCC collect2 program.  For some
+# reason, if we set the COLLECT_NAMES environment variable, the problems
+# vanish in a puff of smoke.
+if test "X${COLLECT_NAMES+set}" != Xset; then
+  COLLECT_NAMES=
+  export COLLECT_NAMES
+fi
+EOF
+    ;;
+  esac
+
+  # Append the ltmain.sh script.
+  sed '$q' "$ltmain" >> "$ofile" || (rm -f "$ofile"; exit 1)
+  # We use sed instead of cat because bash on DJGPP gets confused if
+  # if finds mixed CR/LF and LF-only lines.  Since sed operates in
+  # text mode, it properly converts lines to CR/LF.  This bash problem
+  # is reportedly fixed, but why not run on old versions too?
+
+  chmod +x "$ofile"
+  ;;
+
+*)
+  # Compile the libtool program.
+  echo "FIXME: would compile $ltmain"
+  ;;
+esac
+
+test -n "$cache_file" || exit 0
+
+# AC_CACHE_SAVE
+trap '' 1 2 15
+cat > confcache <<\EOF
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs.  It is not useful on other systems.
+# If it contains results you don't want to keep, you may remove or edit it.
+#
+# By default, configure uses ./config.cache as the cache file,
+# creating it if it does not exist already.  You can give configure
+# the --cache-file=FILE option to use a different cache file; that is
+# what configure does when it calls configure scripts in
+# subdirectories, so they share the cache.
+# Giving --cache-file=/dev/null disables caching, for debugging configure.
+# config.status only pays attention to the cache file if you give it the
+# --recheck option to rerun configure.
+#
+EOF
+# The following way of writing the cache mishandles newlines in values,
+# but we know of no workaround that is simple, portable, and efficient.
+# So, don't put newlines in cache variables' values.
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
+(set) 2>&1 |
+  case `(ac_space=' '; set | grep ac_space) 2>&1` in
+  *ac_space=\ *)
+    # `set' does not quote correctly, so add quotes (double-quote substitution
+    # turns \\\\ into \\, and sed turns \\ into \).
+    sed -n \
+      -e "s/'/'\\\\''/g" \
+      -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p"
+    ;;
+  *)
+    # `set' quotes correctly as required by POSIX, so do not add quotes.
+    sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p'
+    ;;
+  esac >> confcache
+if cmp -s $cache_file confcache; then
+  :
+else
+  if test -w $cache_file; then
+    echo "updating cache $cache_file"
+    cat confcache > $cache_file
+  else
+    echo "not updating unwritable cache $cache_file"
+  fi
+fi
+rm -f confcache
+
+exit 0
+
+# Local Variables:
+# mode:shell-script
+# sh-indentation:2
+# End:
diff --git a/contrib/idn/idnkit-1.0-src/ltmain.sh b/contrib/idn/idnkit-1.0-src/ltmain.sh
new file mode 100644 (file)
index 0000000..766732d
--- /dev/null
@@ -0,0 +1,4024 @@
+# ltmain.sh - Provide generalized library-building support services.
+# NOTE: Changing this file will not affect anything until you rerun ltconfig.
+#
+# Copyright (C) 1996-1999 Free Software Foundation, Inc.
+# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Check that we have a working $echo.
+if test "X$1" = X--no-reexec; then
+  # Discard the --no-reexec flag, and continue.
+  shift
+elif test "X$1" = X--fallback-echo; then
+  # Avoid inline document here, it may be left over
+  :
+elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then
+  # Yippee, $echo works!
+  :
+else
+  # Restart under the correct shell, and then maybe $echo will work.
+  exec $SHELL "$0" --no-reexec ${1+"$@"}
+fi
+
+if test "X$1" = X--fallback-echo; then
+  # used as fallback echo
+  shift
+  cat <<EOF
+$*
+EOF
+  exit 0
+fi
+
+# The name of this program.
+progname=`$echo "$0" | sed 's%^.*/%%'`
+modename="$progname"
+
+# Constants.
+PROGRAM=ltmain.sh
+PACKAGE=libtool
+VERSION=1.3.5
+TIMESTAMP=" (1.385.2.206 2000/05/27 11:12:27)"
+
+default_mode=
+help="Try \`$progname --help' for more information."
+magic="%%%MAGIC variable%%%"
+mkdir="mkdir"
+mv="mv -f"
+rm="rm -f"
+
+# Sed substitution that helps us do robust quoting.  It backslashifies
+# metacharacters that are still active within double-quoted strings.
+Xsed='sed -e 1s/^X//'
+sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
+SP2NL='tr \040 \012'
+NL2SP='tr \015\012 \040\040'
+
+# NLS nuisances.
+# Only set LANG and LC_ALL to C if already set.
+# These must not be set unconditionally because not all systems understand
+# e.g. LANG=C (notably SCO).
+# We save the old values to restore during execute mode.
+if test "${LC_ALL+set}" = set; then
+  save_LC_ALL="$LC_ALL"; LC_ALL=C; export LC_ALL
+fi
+if test "${LANG+set}" = set; then
+  save_LANG="$LANG"; LANG=C; export LANG
+fi
+
+if test "$LTCONFIG_VERSION" != "$VERSION"; then
+  echo "$modename: ltconfig version \`$LTCONFIG_VERSION' does not match $PROGRAM version \`$VERSION'" 1>&2
+  echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
+  exit 1
+fi
+
+if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
+  echo "$modename: not configured to build any kind of library" 1>&2
+  echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
+  exit 1
+fi
+
+# Global variables.
+mode=$default_mode
+nonopt=
+prev=
+prevopt=
+run=
+show="$echo"
+show_help=
+execute_dlfiles=
+lo2o="s/\\.lo\$/.${objext}/"
+o2lo="s/\\.${objext}\$/.lo/"
+
+# Parse our command line options once, thoroughly.
+while test $# -gt 0
+do
+  arg="$1"
+  shift
+
+  case "$arg" in
+  -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;;
+  *) optarg= ;;
+  esac
+
+  # If the previous option needs an argument, assign it.
+  if test -n "$prev"; then
+    case "$prev" in
+    execute_dlfiles)
+      eval "$prev=\"\$$prev \$arg\""
+      ;;
+    *)
+      eval "$prev=\$arg"
+      ;;
+    esac
+
+    prev=
+    prevopt=
+    continue
+  fi
+
+  # Have we seen a non-optional argument yet?
+  case "$arg" in
+  --help)
+    show_help=yes
+    ;;
+
+  --version)
+    echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP"
+    exit 0
+    ;;
+
+  --config)
+    sed -e '1,/^### BEGIN LIBTOOL CONFIG/d' -e '/^### END LIBTOOL CONFIG/,$d' $0
+    exit 0
+    ;;
+
+  --debug)
+    echo "$progname: enabling shell trace mode"
+    set -x
+    ;;
+
+  --dry-run | -n)
+    run=:
+    ;;
+
+  --features)
+    echo "host: $host"
+    if test "$build_libtool_libs" = yes; then
+      echo "enable shared libraries"
+    else
+      echo "disable shared libraries"
+    fi
+    if test "$build_old_libs" = yes; then
+      echo "enable static libraries"
+    else
+      echo "disable static libraries"
+    fi
+    exit 0
+    ;;
+
+  --finish) mode="finish" ;;
+
+  --mode) prevopt="--mode" prev=mode ;;
+  --mode=*) mode="$optarg" ;;
+
+  --quiet | --silent)
+    show=:
+    ;;
+
+  -dlopen)
+    prevopt="-dlopen"
+    prev=execute_dlfiles
+    ;;
+
+  -*)
+    $echo "$modename: unrecognized option \`$arg'" 1>&2
+    $echo "$help" 1>&2
+    exit 1
+    ;;
+
+  *)
+    nonopt="$arg"
+    break
+    ;;
+  esac
+done
+
+if test -n "$prevopt"; then
+  $echo "$modename: option \`$prevopt' requires an argument" 1>&2
+  $echo "$help" 1>&2
+  exit 1
+fi
+
+if test -z "$show_help"; then
+
+  # Infer the operation mode.
+  if test -z "$mode"; then
+    case "$nonopt" in
+    *cc | *++ | gcc* | *-gcc*)
+      mode=link
+      for arg
+      do
+       case "$arg" in
+       -c)
+          mode=compile
+          break
+          ;;
+       esac
+      done
+      ;;
+    *db | *dbx | *strace | *truss)
+      mode=execute
+      ;;
+    *install*|cp|mv)
+      mode=install
+      ;;
+    *rm)
+      mode=uninstall
+      ;;
+    *)
+      # If we have no mode, but dlfiles were specified, then do execute mode.
+      test -n "$execute_dlfiles" && mode=execute
+
+      # Just use the default operation mode.
+      if test -z "$mode"; then
+       if test -n "$nonopt"; then
+         $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2
+       else
+         $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2
+       fi
+      fi
+      ;;
+    esac
+  fi
+
+  # Only execute mode is allowed to have -dlopen flags.
+  if test -n "$execute_dlfiles" && test "$mode" != execute; then
+    $echo "$modename: unrecognized option \`-dlopen'" 1>&2
+    $echo "$help" 1>&2
+    exit 1
+  fi
+
+  # Change the help message to a mode-specific one.
+  generic_help="$help"
+  help="Try \`$modename --help --mode=$mode' for more information."
+
+  # These modes are in order of execution frequency so that they run quickly.
+  case "$mode" in
+  # libtool compile mode
+  compile)
+    modename="$modename: compile"
+    # Get the compilation command and the source file.
+    base_compile=
+    lastarg=
+    srcfile="$nonopt"
+    suppress_output=
+
+    user_target=no
+    for arg
+    do
+      # Accept any command-line options.
+      case "$arg" in
+      -o)
+       if test "$user_target" != "no"; then
+         $echo "$modename: you cannot specify \`-o' more than once" 1>&2
+         exit 1
+       fi
+       user_target=next
+       ;;
+
+      -static)
+       build_old_libs=yes
+       continue
+       ;;
+      esac
+
+      case "$user_target" in
+      next)
+       # The next one is the -o target name
+       user_target=yes
+       continue
+       ;;
+      yes)
+       # We got the output file
+       user_target=set
+       libobj="$arg"
+       continue
+       ;;
+      esac
+
+      # Accept the current argument as the source file.
+      lastarg="$srcfile"
+      srcfile="$arg"
+
+      # Aesthetically quote the previous argument.
+
+      # Backslashify any backslashes, double quotes, and dollar signs.
+      # These are the only characters that are still specially
+      # interpreted inside of double-quoted scrings.
+      lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"`
+
+      # Double-quote args containing other shell metacharacters.
+      # Many Bourne shells cannot handle close brackets correctly in scan
+      # sets, so we specify it separately.
+      case "$lastarg" in
+      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \    ]*|*]*)
+       lastarg="\"$lastarg\""
+       ;;
+      esac
+
+      # Add the previous argument to base_compile.
+      if test -z "$base_compile"; then
+       base_compile="$lastarg"
+      else
+       base_compile="$base_compile $lastarg"
+      fi
+    done
+
+    case "$user_target" in
+    set)
+      ;;
+    no)
+      # Get the name of the library object.
+      libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'`
+      ;;
+    *)
+      $echo "$modename: you must specify a target with \`-o'" 1>&2
+      exit 1
+      ;;
+    esac
+
+    # Recognize several different file suffixes.
+    # If the user specifies -o file.o, it is replaced with file.lo
+    xform='[cCFSfmso]'
+    case "$libobj" in
+    *.ada) xform=ada ;;
+    *.adb) xform=adb ;;
+    *.ads) xform=ads ;;
+    *.asm) xform=asm ;;
+    *.c++) xform=c++ ;;
+    *.cc) xform=cc ;;
+    *.cpp) xform=cpp ;;
+    *.cxx) xform=cxx ;;
+    *.f90) xform=f90 ;;
+    *.for) xform=for ;;
+    esac
+
+    libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"`
+
+    case "$libobj" in
+    *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;;
+    *)
+      $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2
+      exit 1
+      ;;
+    esac
+
+    if test -z "$base_compile"; then
+      $echo "$modename: you must specify a compilation command" 1>&2
+      $echo "$help" 1>&2
+      exit 1
+    fi
+
+    # Delete any leftover library objects.
+    if test "$build_old_libs" = yes; then
+      removelist="$obj $libobj"
+    else
+      removelist="$libobj"
+    fi
+
+    $run $rm $removelist
+    trap "$run $rm $removelist; exit 1" 1 2 15
+
+    # Calculate the filename of the output object if compiler does
+    # not support -o with -c
+    if test "$compiler_c_o" = no; then
+      output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\..*$%%'`.${objext}
+      lockfile="$output_obj.lock"
+      removelist="$removelist $output_obj $lockfile"
+      trap "$run $rm $removelist; exit 1" 1 2 15
+    else
+      need_locks=no
+      lockfile=
+    fi
+
+    # Lock this critical section if it is needed
+    # We use this script file to make the link, it avoids creating a new file
+    if test "$need_locks" = yes; then
+      until ln "$0" "$lockfile" 2>/dev/null; do
+       $show "Waiting for $lockfile to be removed"
+       sleep 2
+      done
+    elif test "$need_locks" = warn; then
+      if test -f "$lockfile"; then
+       echo "\
+*** ERROR, $lockfile exists and contains:
+`cat $lockfile 2>/dev/null`
+
+This indicates that another process is trying to use the same
+temporary object file, and libtool could not work around it because
+your compiler does not support \`-c' and \`-o' together.  If you
+repeat this compilation, it may succeed, by chance, but you had better
+avoid parallel builds (make -j) in this platform, or get a better
+compiler."
+
+       $run $rm $removelist
+       exit 1
+      fi
+      echo $srcfile > "$lockfile"
+    fi
+
+    if test -n "$fix_srcfile_path"; then
+      eval srcfile=\"$fix_srcfile_path\"
+    fi
+
+    # Only build a PIC object if we are building libtool libraries.
+    if test "$build_libtool_libs" = yes; then
+      # Without this assignment, base_compile gets emptied.
+      fbsd_hideous_sh_bug=$base_compile
+
+      # All platforms use -DPIC, to notify preprocessed assembler code.
+      command="$base_compile $srcfile $pic_flag -DPIC"
+      if test "$build_old_libs" = yes; then
+       lo_libobj="$libobj"
+       dir=`$echo "X$libobj" | $Xsed -e 's%/[^/]*$%%'`
+       if test "X$dir" = "X$libobj"; then
+         dir="$objdir"
+       else
+         dir="$dir/$objdir"
+       fi
+       libobj="$dir/"`$echo "X$libobj" | $Xsed -e 's%^.*/%%'`
+
+       if test -d "$dir"; then
+         $show "$rm $libobj"
+         $run $rm $libobj
+       else
+         $show "$mkdir $dir"
+         $run $mkdir $dir
+         status=$?
+         if test $status -ne 0 && test ! -d $dir; then
+           exit $status
+         fi
+       fi
+      fi
+      if test "$compiler_o_lo" = yes; then
+       output_obj="$libobj"
+       command="$command -o $output_obj"
+      elif test "$compiler_c_o" = yes; then
+       output_obj="$obj"
+       command="$command -o $output_obj"
+      fi
+
+      $run $rm "$output_obj"
+      $show "$command"
+      if $run eval "$command"; then :
+      else
+       test -n "$output_obj" && $run $rm $removelist
+       exit 1
+      fi
+
+      if test "$need_locks" = warn &&
+        test x"`cat $lockfile 2>/dev/null`" != x"$srcfile"; then
+       echo "\
+*** ERROR, $lockfile contains:
+`cat $lockfile 2>/dev/null`
+
+but it should contain:
+$srcfile
+
+This indicates that another process is trying to use the same
+temporary object file, and libtool could not work around it because
+your compiler does not support \`-c' and \`-o' together.  If you
+repeat this compilation, it may succeed, by chance, but you had better
+avoid parallel builds (make -j) in this platform, or get a better
+compiler."
+
+       $run $rm $removelist
+       exit 1
+      fi
+
+      # Just move the object if needed, then go on to compile the next one
+      if test x"$output_obj" != x"$libobj"; then
+       $show "$mv $output_obj $libobj"
+       if $run $mv $output_obj $libobj; then :
+       else
+         error=$?
+         $run $rm $removelist
+         exit $error
+       fi
+      fi
+
+      # If we have no pic_flag, then copy the object into place and finish.
+      if test -z "$pic_flag" && test "$build_old_libs" = yes; then
+       # Rename the .lo from within objdir to obj
+       if test -f $obj; then
+         $show $rm $obj
+         $run $rm $obj
+       fi
+
+       $show "$mv $libobj $obj"
+       if $run $mv $libobj $obj; then :
+       else
+         error=$?
+         $run $rm $removelist
+         exit $error
+       fi
+
+       xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'`
+       if test "X$xdir" = "X$obj"; then
+         xdir="."
+       else
+         xdir="$xdir"
+       fi
+       baseobj=`$echo "X$obj" | $Xsed -e "s%.*/%%"`
+       libobj=`$echo "X$baseobj" | $Xsed -e "$o2lo"`
+       # Now arrange that obj and lo_libobj become the same file
+       $show "(cd $xdir && $LN_S $baseobj $libobj)"
+       if $run eval '(cd $xdir && $LN_S $baseobj $libobj)'; then
+         exit 0
+       else
+         error=$?
+         $run $rm $removelist
+         exit $error
+       fi
+      fi
+
+      # Allow error messages only from the first compilation.
+      suppress_output=' >/dev/null 2>&1'
+    fi
+
+    # Only build a position-dependent object if we build old libraries.
+    if test "$build_old_libs" = yes; then
+      command="$base_compile $srcfile"
+      if test "$compiler_c_o" = yes; then
+       command="$command -o $obj"
+       output_obj="$obj"
+      fi
+
+      # Suppress compiler output if we already did a PIC compilation.
+      command="$command$suppress_output"
+      $run $rm "$output_obj"
+      $show "$command"
+      if $run eval "$command"; then :
+      else
+       $run $rm $removelist
+       exit 1
+      fi
+
+      if test "$need_locks" = warn &&
+        test x"`cat $lockfile 2>/dev/null`" != x"$srcfile"; then
+       echo "\
+*** ERROR, $lockfile contains:
+`cat $lockfile 2>/dev/null`
+
+but it should contain:
+$srcfile
+
+This indicates that another process is trying to use the same
+temporary object file, and libtool could not work around it because
+your compiler does not support \`-c' and \`-o' together.  If you
+repeat this compilation, it may succeed, by chance, but you had better
+avoid parallel builds (make -j) in this platform, or get a better
+compiler."
+
+       $run $rm $removelist
+       exit 1
+      fi
+
+      # Just move the object if needed
+      if test x"$output_obj" != x"$obj"; then
+       $show "$mv $output_obj $obj"
+       if $run $mv $output_obj $obj; then :
+       else
+         error=$?
+         $run $rm $removelist
+         exit $error
+       fi
+      fi
+
+      # Create an invalid libtool object if no PIC, so that we do not
+      # accidentally link it into a program.
+      if test "$build_libtool_libs" != yes; then
+       $show "echo timestamp > $libobj"
+       $run eval "echo timestamp > \$libobj" || exit $?
+      else
+       # Move the .lo from within objdir
+       $show "$mv $libobj $lo_libobj"
+       if $run $mv $libobj $lo_libobj; then :
+       else
+         error=$?
+         $run $rm $removelist
+         exit $error
+       fi
+      fi
+    fi
+
+    # Unlock the critical section if it was locked
+    if test "$need_locks" != no; then
+      $rm "$lockfile"
+    fi
+
+    exit 0
+    ;;
+
+  # libtool link mode
+  link)
+    modename="$modename: link"
+    case "$host" in
+    *-*-cygwin* | *-*-mingw* | *-*-os2*)
+      # It is impossible to link a dll without this setting, and
+      # we shouldn't force the makefile maintainer to figure out
+      # which system we are compiling for in order to pass an extra
+      # flag for every libtool invokation.
+      # allow_undefined=no
+
+      # FIXME: Unfortunately, there are problems with the above when trying
+      # to make a dll which has undefined symbols, in which case not
+      # even a static library is built.  For now, we need to specify
+      # -no-undefined on the libtool link line when we can be certain
+      # that all symbols are satisfied, otherwise we get a static library.
+      allow_undefined=yes
+
+      # This is a source program that is used to create dlls on Windows
+      # Don't remove nor modify the starting and closing comments
+# /* ltdll.c starts here */
+# #define WIN32_LEAN_AND_MEAN
+# #include <windows.h>
+# #undef WIN32_LEAN_AND_MEAN
+# #include <stdio.h>
+#
+# #ifndef __CYGWIN__
+# #  ifdef __CYGWIN32__
+# #    define __CYGWIN__ __CYGWIN32__
+# #  endif
+# #endif
+#
+# #ifdef __cplusplus
+# extern "C" {
+# #endif
+# BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved);
+# #ifdef __cplusplus
+# }
+# #endif
+#
+# #ifdef __CYGWIN__
+# #include <cygwin/cygwin_dll.h>
+# DECLARE_CYGWIN_DLL( DllMain );
+# #endif
+# HINSTANCE __hDllInstance_base;
+#
+# BOOL APIENTRY
+# DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved)
+# {
+#   __hDllInstance_base = hInst;
+#   return TRUE;
+# }
+# /* ltdll.c ends here */
+      # This is a source program that is used to create import libraries
+      # on Windows for dlls which lack them. Don't remove nor modify the
+      # starting and closing comments
+# /* impgen.c starts here */
+# /*   Copyright (C) 1999 Free Software Foundation, Inc.
+# 
+#  This file is part of GNU libtool.
+# 
+#  This program is free software; you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or
+#  (at your option) any later version.
+# 
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+# 
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software
+#  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#  */
+# 
+#  #include <stdio.h>          /* for printf() */
+#  #include <unistd.h>         /* for open(), lseek(), read() */
+#  #include <fcntl.h>          /* for O_RDONLY, O_BINARY */
+#  #include <string.h>         /* for strdup() */
+# 
+#  static unsigned int
+#  pe_get16 (fd, offset)
+#       int fd;
+#       int offset;
+#  {
+#    unsigned char b[2];
+#    lseek (fd, offset, SEEK_SET);
+#    read (fd, b, 2);
+#    return b[0] + (b[1]<<8);
+#  }
+# 
+#  static unsigned int
+#  pe_get32 (fd, offset)
+#      int fd;
+#      int offset;
+#  {
+#    unsigned char b[4];
+#    lseek (fd, offset, SEEK_SET);
+#    read (fd, b, 4);
+#    return b[0] + (b[1]<<8) + (b[2]<<16) + (b[3]<<24);
+#  }
+# 
+#  static unsigned int
+#  pe_as32 (ptr)
+#       void *ptr;
+#  {
+#    unsigned char *b = ptr;
+#    return b[0] + (b[1]<<8) + (b[2]<<16) + (b[3]<<24);
+#  }
+# 
+#  int
+#  main (argc, argv)
+#      int argc;
+#      char *argv[];
+#  {
+#      int dll;
+#      unsigned long pe_header_offset, opthdr_ofs, num_entries, i;
+#      unsigned long export_rva, export_size, nsections, secptr, expptr;
+#      unsigned long name_rvas, nexp;
+#      unsigned char *expdata, *erva;
+#      char *filename, *dll_name;
+# 
+#      filename = argv[1];
+# 
+#      dll = open(filename, O_RDONLY|O_BINARY);
+#      if (!dll)
+#      return 1;
+# 
+#      dll_name = filename;
+#    
+#      for (i=0; filename[i]; i++)
+#      if (filename[i] == '/' || filename[i] == '\\'  || filename[i] == ':')
+#          dll_name = filename + i +1;
+# 
+#      pe_header_offset = pe_get32 (dll, 0x3c);
+#      opthdr_ofs = pe_header_offset + 4 + 20;
+#      num_entries = pe_get32 (dll, opthdr_ofs + 92);
+# 
+#      if (num_entries < 1) /* no exports */
+#      return 1;
+# 
+#      export_rva = pe_get32 (dll, opthdr_ofs + 96);
+#      export_size = pe_get32 (dll, opthdr_ofs + 100);
+#      nsections = pe_get16 (dll, pe_header_offset + 4 +2);
+#      secptr = (pe_header_offset + 4 + 20 +
+#            pe_get16 (dll, pe_header_offset + 4 + 16));
+# 
+#      expptr = 0;
+#      for (i = 0; i < nsections; i++)
+#      {
+#      char sname[8];
+#      unsigned long secptr1 = secptr + 40 * i;
+#      unsigned long vaddr = pe_get32 (dll, secptr1 + 12);
+#      unsigned long vsize = pe_get32 (dll, secptr1 + 16);
+#      unsigned long fptr = pe_get32 (dll, secptr1 + 20);
+#      lseek(dll, secptr1, SEEK_SET);
+#      read(dll, sname, 8);
+#      if (vaddr <= export_rva && vaddr+vsize > export_rva)
+#      {
+#          expptr = fptr + (export_rva - vaddr);
+#          if (export_rva + export_size > vaddr + vsize)
+#              export_size = vsize - (export_rva - vaddr);
+#          break;
+#      }
+#      }
+# 
+#      expdata = (unsigned char*)malloc(export_size);
+#      lseek (dll, expptr, SEEK_SET);
+#      read (dll, expdata, export_size);
+#      erva = expdata - export_rva;
+# 
+#      nexp = pe_as32 (expdata+24);
+#      name_rvas = pe_as32 (expdata+32);
+# 
+#      printf ("EXPORTS\n");
+#      for (i = 0; i<nexp; i++)
+#      {
+#      unsigned long name_rva = pe_as32 (erva+name_rvas+i*4);
+#      printf ("\t%s @ %ld ;\n", erva+name_rva, 1+ i);
+#      }
+# 
+#      return 0;
+#  }
+# /* impgen.c ends here */
+      ;;
+    *)
+      allow_undefined=yes
+      ;;
+    esac
+    compile_command="$nonopt"
+    finalize_command="$nonopt"
+
+    compile_rpath=
+    finalize_rpath=
+    compile_shlibpath=
+    finalize_shlibpath=
+    convenience=
+    old_convenience=
+    deplibs=
+    linkopts=
+
+    if test -n "$shlibpath_var"; then
+      # get the directories listed in $shlibpath_var
+      eval lib_search_path=\`\$echo \"X \${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
+    else
+      lib_search_path=
+    fi
+    # now prepend the system-specific ones
+    eval lib_search_path=\"$sys_lib_search_path_spec\$lib_search_path\"
+    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
+    
+    avoid_version=no
+    dlfiles=
+    dlprefiles=
+    dlself=no
+    export_dynamic=no
+    export_symbols=
+    export_symbols_regex=
+    generated=
+    libobjs=
+    link_against_libtool_libs=
+    ltlibs=
+    module=no
+    objs=
+    prefer_static_libs=no
+    preload=no
+    prev=
+    prevarg=
+    release=
+    rpath=
+    xrpath=
+    perm_rpath=
+    temp_rpath=
+    thread_safe=no
+    vinfo=
+
+    # We need to know -static, to get the right output filenames.
+    for arg
+    do
+      case "$arg" in
+      -all-static | -static)
+       if test "X$arg" = "X-all-static"; then
+         if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
+           $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2
+         fi
+         if test -n "$link_static_flag"; then
+           dlopen_self=$dlopen_self_static
+         fi
+       else
+         if test -z "$pic_flag" && test -n "$link_static_flag"; then
+           dlopen_self=$dlopen_self_static
+         fi
+       fi
+       build_libtool_libs=no
+       build_old_libs=yes
+       prefer_static_libs=yes
+       break
+       ;;
+      esac
+    done
+
+    # See if our shared archives depend on static archives.
+    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
+
+    # Go through the arguments, transforming them on the way.
+    while test $# -gt 0; do
+      arg="$1"
+      shift
+
+      # If the previous option needs an argument, assign it.
+      if test -n "$prev"; then
+       case "$prev" in
+       output)
+         compile_command="$compile_command @OUTPUT@"
+         finalize_command="$finalize_command @OUTPUT@"
+         ;;
+       esac
+
+       case "$prev" in
+       dlfiles|dlprefiles)
+         if test "$preload" = no; then
+           # Add the symbol object into the linking commands.
+           compile_command="$compile_command @SYMFILE@"
+           finalize_command="$finalize_command @SYMFILE@"
+           preload=yes
+         fi
+         case "$arg" in
+         *.la | *.lo) ;;  # We handle these cases below.
+         force)
+           if test "$dlself" = no; then
+             dlself=needless
+             export_dynamic=yes
+           fi
+           prev=
+           continue
+           ;;
+         self)
+           if test "$prev" = dlprefiles; then
+             dlself=yes
+           elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
+             dlself=yes
+           else
+             dlself=needless
+             export_dynamic=yes
+           fi
+           prev=
+           continue
+           ;;
+         *)
+           if test "$prev" = dlfiles; then
+             dlfiles="$dlfiles $arg"
+           else
+             dlprefiles="$dlprefiles $arg"
+           fi
+           prev=
+           ;;
+         esac
+         ;;
+       expsyms)
+         export_symbols="$arg"
+         if test ! -f "$arg"; then
+           $echo "$modename: symbol file \`$arg' does not exist"
+           exit 1
+         fi
+         prev=
+         continue
+         ;;
+       expsyms_regex)
+         export_symbols_regex="$arg"
+         prev=
+         continue
+         ;;
+       release)
+         release="-$arg"
+         prev=
+         continue
+         ;;
+       rpath | xrpath)
+         # We need an absolute path.
+         case "$arg" in
+         [\\/]* | [A-Za-z]:[\\/]*) ;;
+         *)
+           $echo "$modename: only absolute run-paths are allowed" 1>&2
+           exit 1
+           ;;
+         esac
+         if test "$prev" = rpath; then
+           case "$rpath " in
+           *" $arg "*) ;;
+           *) rpath="$rpath $arg" ;;
+           esac
+         else
+           case "$xrpath " in
+           *" $arg "*) ;;
+           *) xrpath="$xrpath $arg" ;;
+           esac
+         fi
+         prev=
+         continue
+         ;;
+       *)
+         eval "$prev=\"\$arg\""
+         prev=
+         continue
+         ;;
+       esac
+      fi
+
+      prevarg="$arg"
+
+      case "$arg" in
+      -all-static)
+       if test -n "$link_static_flag"; then
+         compile_command="$compile_command $link_static_flag"
+         finalize_command="$finalize_command $link_static_flag"
+       fi
+       continue
+       ;;
+
+      -allow-undefined)
+       # FIXME: remove this flag sometime in the future.
+       $echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2
+       continue
+       ;;
+
+      -avoid-version)
+       avoid_version=yes
+       continue
+       ;;
+
+      -dlopen)
+       prev=dlfiles
+       continue
+       ;;
+
+      -dlpreopen)
+       prev=dlprefiles
+       continue
+       ;;
+
+      -export-dynamic)
+       export_dynamic=yes
+       continue
+       ;;
+
+      -export-symbols | -export-symbols-regex)
+       if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
+         $echo "$modename: not more than one -exported-symbols argument allowed"
+         exit 1
+       fi
+       if test "X$arg" = "X-export-symbols"; then
+         prev=expsyms
+       else
+         prev=expsyms_regex
+       fi
+       continue
+       ;;
+
+      -L*)
+       dir=`$echo "X$arg" | $Xsed -e 's/^-L//'`
+       # We need an absolute path.
+       case "$dir" in
+       [\\/]* | [A-Za-z]:[\\/]*) ;;
+       *)
+         absdir=`cd "$dir" && pwd`
+         if test -z "$absdir"; then
+           $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2
+           $echo "$modename: passing it literally to the linker, although it might fail" 1>&2
+           absdir="$dir"
+         fi
+         dir="$absdir"
+         ;;
+       esac
+       case " $deplibs " in
+       *" $arg "*) ;;
+       *) deplibs="$deplibs $arg";;
+       esac
+       case " $lib_search_path " in
+       *" $dir "*) ;;
+       *) lib_search_path="$lib_search_path $dir";;
+       esac
+       case "$host" in
+       *-*-cygwin* | *-*-mingw* | *-*-os2*)
+         dllsearchdir=`cd "$dir" && pwd || echo "$dir"`
+         case ":$dllsearchpath:" in
+         ::) dllsearchpath="$dllsearchdir";;
+         *":$dllsearchdir:"*) ;;
+         *) dllsearchpath="$dllsearchpath:$dllsearchdir";;
+         esac
+         ;;
+       esac
+       ;;
+
+      -l*)
+       if test "$arg" = "-lc"; then
+         case "$host" in
+         *-*-cygwin* | *-*-mingw* | *-*-os2* | *-*-beos*)
+           # These systems don't actually have c library (as such)
+           continue
+           ;;
+         esac
+       elif test "$arg" = "-lm"; then
+         case "$host" in
+         *-*-cygwin* | *-*-beos*)
+           # These systems don't actually have math library (as such)
+           continue
+           ;;
+         esac
+       fi
+       deplibs="$deplibs $arg"
+       ;;
+
+      -module)
+       module=yes
+       continue
+       ;;
+
+      -no-undefined)
+       allow_undefined=no
+       continue
+       ;;
+
+      -o) prev=output ;;
+
+      -release)
+       prev=release
+       continue
+       ;;
+
+      -rpath)
+       prev=rpath
+       continue
+       ;;
+
+      -R)
+       prev=xrpath
+       continue
+       ;;
+
+      -R*)
+       dir=`$echo "X$arg" | $Xsed -e 's/^-R//'`
+       # We need an absolute path.
+       case "$dir" in
+       [\\/]* | [A-Za-z]:[\\/]*) ;;
+       *)
+         $echo "$modename: only absolute run-paths are allowed" 1>&2
+         exit 1
+         ;;
+       esac
+       case "$xrpath " in
+       *" $dir "*) ;;
+       *) xrpath="$xrpath $dir" ;;
+       esac
+       continue
+       ;;
+
+      -static)
+       # If we have no pic_flag, then this is the same as -all-static.
+       if test -z "$pic_flag" && test -n "$link_static_flag"; then
+         compile_command="$compile_command $link_static_flag"
+         finalize_command="$finalize_command $link_static_flag"
+       fi
+       continue
+       ;;
+
+      -thread-safe)
+       thread_safe=yes
+       continue
+       ;;
+
+      -version-info)
+       prev=vinfo
+       continue
+       ;;
+
+      # Some other compiler flag.
+      -* | +*)
+       # Unknown arguments in both finalize_command and compile_command need
+       # to be aesthetically quoted because they are evaled later.
+       arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
+       case "$arg" in
+       *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \   ]*|*]*)
+         arg="\"$arg\""
+         ;;
+       esac
+       ;;
+
+      *.o | *.obj | *.a | *.lib)
+       # A standard object.
+       objs="$objs $arg"
+       ;;
+
+      *.lo)
+       # A library object.
+       if test "$prev" = dlfiles; then
+         dlfiles="$dlfiles $arg"
+         if test "$build_libtool_libs" = yes && test "$dlopen" = yes; then
+           prev=
+           continue
+         else
+           # If libtool objects are unsupported, then we need to preload.
+           prev=dlprefiles
+         fi
+       fi
+
+       if test "$prev" = dlprefiles; then
+         # Preload the old-style object.
+         dlprefiles="$dlprefiles "`$echo "X$arg" | $Xsed -e "$lo2o"`
+         prev=
+       fi
+       libobjs="$libobjs $arg"
+       ;;
+
+      *.la)
+       # A libtool-controlled library.
+
+       dlname=
+       libdir=
+       library_names=
+       old_library=
+
+       # Check to see that this really is a libtool archive.
+       if (sed -e '2q' $arg | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
+       else
+         $echo "$modename: \`$arg' is not a valid libtool archive" 1>&2
+         exit 1
+       fi
+
+       # If the library was installed with an old release of libtool,
+       # it will not redefine variable installed.
+       installed=yes
+
+       # Read the .la file
+       # If there is no directory component, then add one.
+       case "$arg" in
+       */* | *\\*) . $arg ;;
+       *) . ./$arg ;;
+       esac
+
+       # Get the name of the library we link against.
+       linklib=
+       for l in $old_library $library_names; do
+         linklib="$l"
+       done
+
+       if test -z "$linklib"; then
+         $echo "$modename: cannot find name of link library for \`$arg'" 1>&2
+         exit 1
+       fi
+
+       # Find the relevant object directory and library name.
+       name=`$echo "X$arg" | $Xsed -e 's%^.*/%%' -e 's/\.la$//' -e 's/^lib//'`
+
+       if test "X$installed" = Xyes; then
+         dir="$libdir"
+       else
+         dir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
+         if test "X$dir" = "X$arg"; then
+           dir="$objdir"
+         else
+           dir="$dir/$objdir"
+         fi
+       fi
+
+       if test -n "$dependency_libs"; then
+         # Extract -R and -L from dependency_libs
+         temp_deplibs=
+         for deplib in $dependency_libs; do
+           case "$deplib" in
+           -R*) temp_xrpath=`$echo "X$deplib" | $Xsed -e 's/^-R//'`
+                case " $rpath $xrpath " in
+                *" $temp_xrpath "*) ;;
+                *) xrpath="$xrpath $temp_xrpath";;
+                esac;;
+           -L*) case "$compile_command $temp_deplibs " in
+                *" $deplib "*) ;;
+                *) temp_deplibs="$temp_deplibs $deplib";;
+                esac
+                temp_dir=`$echo "X$deplib" | $Xsed -e 's/^-L//'`
+                case " $lib_search_path " in
+                *" $temp_dir "*) ;;
+                *) lib_search_path="$lib_search_path $temp_dir";;
+                esac
+                ;;
+           *) temp_deplibs="$temp_deplibs $deplib";;
+           esac
+         done
+         dependency_libs="$temp_deplibs"
+       fi
+
+       if test -z "$libdir"; then
+         # It is a libtool convenience library, so add in its objects.
+         convenience="$convenience $dir/$old_library"
+         old_convenience="$old_convenience $dir/$old_library"
+         deplibs="$deplibs$dependency_libs"
+         compile_command="$compile_command $dir/$old_library$dependency_libs"
+         finalize_command="$finalize_command $dir/$old_library$dependency_libs"
+         continue
+       fi
+
+       # This library was specified with -dlopen.
+       if test "$prev" = dlfiles; then
+         dlfiles="$dlfiles $arg"
+         if test -z "$dlname" || test "$dlopen" != yes || test "$build_libtool_libs" = no; then
+           # If there is no dlname, no dlopen support or we're linking statically,
+           # we need to preload.
+           prev=dlprefiles
+         else
+           # We should not create a dependency on this library, but we
+           # may need any libraries it requires.
+           compile_command="$compile_command$dependency_libs"
+           finalize_command="$finalize_command$dependency_libs"
+           prev=
+           continue
+         fi
+       fi
+
+       # The library was specified with -dlpreopen.
+       if test "$prev" = dlprefiles; then
+         # Prefer using a static library (so that no silly _DYNAMIC symbols
+         # are required to link).
+         if test -n "$old_library"; then
+           dlprefiles="$dlprefiles $dir/$old_library"
+         else
+           dlprefiles="$dlprefiles $dir/$linklib"
+         fi
+         prev=
+       fi
+
+       if test -n "$library_names" &&
+          { test "$prefer_static_libs" = no || test -z "$old_library"; }; then
+         link_against_libtool_libs="$link_against_libtool_libs $arg"
+         if test -n "$shlibpath_var"; then
+           # Make sure the rpath contains only unique directories.
+           case "$temp_rpath " in
+           *" $dir "*) ;;
+           *) temp_rpath="$temp_rpath $dir" ;;
+           esac
+         fi
+
+         # We need an absolute path.
+         case "$dir" in
+         [\\/] | [A-Za-z]:[\\/]*) absdir="$dir" ;;
+         *)
+           absdir=`cd "$dir" && pwd`
+           if test -z "$absdir"; then
+             $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2
+             $echo "$modename: passing it literally to the linker, although it might fail" 1>&2
+             absdir="$dir"
+           fi
+           ;;
+         esac
+         
+         # This is the magic to use -rpath.
+         # Skip directories that are in the system default run-time
+         # search path, unless they have been requested with -R.
+         case " $sys_lib_dlsearch_path " in
+         *" $absdir "*) ;;
+         *)
+           case "$compile_rpath " in
+           *" $absdir "*) ;;
+           *) compile_rpath="$compile_rpath $absdir" 
+           esac
+           ;;
+         esac
+
+         case " $sys_lib_dlsearch_path " in
+         *" $libdir "*) ;;
+         *)
+           case "$finalize_rpath " in
+           *" $libdir "*) ;;
+           *) finalize_rpath="$finalize_rpath $libdir"
+           esac
+           ;;
+         esac
+
+         lib_linked=yes
+         case "$hardcode_action" in
+         immediate | unsupported)
+           if test "$hardcode_direct" = no; then
+             compile_command="$compile_command $dir/$linklib"
+             deplibs="$deplibs $dir/$linklib"
+             case "$host" in
+             *-*-cygwin* | *-*-mingw* | *-*-os2*)
+               dllsearchdir=`cd "$dir" && pwd || echo "$dir"`
+               if test -n "$dllsearchpath"; then
+                 dllsearchpath="$dllsearchpath:$dllsearchdir"
+               else
+                 dllsearchpath="$dllsearchdir"
+               fi
+               ;;
+             esac
+           elif test "$hardcode_minus_L" = no; then
+             case "$host" in
+             *-*-sunos*)
+               compile_shlibpath="$compile_shlibpath$dir:"
+               ;;
+             esac
+             case "$compile_command " in
+             *" -L$dir "*) ;;
+             *) compile_command="$compile_command -L$dir";;
+             esac
+             compile_command="$compile_command -l$name"
+             deplibs="$deplibs -L$dir -l$name"
+           elif test "$hardcode_shlibpath_var" = no; then
+             case ":$compile_shlibpath:" in
+             *":$dir:"*) ;;
+             *) compile_shlibpath="$compile_shlibpath$dir:";;
+             esac
+             compile_command="$compile_command -l$name"
+             deplibs="$deplibs -l$name"
+           else
+             lib_linked=no
+           fi
+           ;;
+
+         relink)
+           if test "$hardcode_direct" = yes; then
+             compile_command="$compile_command $absdir/$linklib"
+             deplibs="$deplibs $absdir/$linklib"
+           elif test "$hardcode_minus_L" = yes; then
+             case "$compile_command " in
+             *" -L$absdir "*) ;;
+             *) compile_command="$compile_command -L$absdir";;
+             esac
+             compile_command="$compile_command -l$name"
+             deplibs="$deplibs -L$absdir -l$name"
+           elif test "$hardcode_shlibpath_var" = yes; then
+             case ":$compile_shlibpath:" in
+             *":$absdir:"*) ;;
+             *) compile_shlibpath="$compile_shlibpath$absdir:";;
+             esac
+             compile_command="$compile_command -l$name"
+             deplibs="$deplibs -l$name"
+           else
+             lib_linked=no
+           fi
+           ;;
+
+         *)
+           lib_linked=no
+           ;;
+         esac
+
+         if test "$lib_linked" != yes; then
+           $echo "$modename: configuration error: unsupported hardcode properties"
+           exit 1
+         fi
+
+         # Finalize command for both is simple: just hardcode it.
+         if test "$hardcode_direct" = yes; then
+           finalize_command="$finalize_command $libdir/$linklib"
+         elif test "$hardcode_minus_L" = yes; then
+           case "$finalize_command " in
+           *" -L$libdir "*) ;;
+           *) finalize_command="$finalize_command -L$libdir";;
+           esac
+           finalize_command="$finalize_command -l$name"
+         elif test "$hardcode_shlibpath_var" = yes; then
+           case ":$finalize_shlibpath:" in
+           *":$libdir:"*) ;;
+           *) finalize_shlibpath="$finalize_shlibpath$libdir:";;
+           esac
+           finalize_command="$finalize_command -l$name"
+         else
+           # We cannot seem to hardcode it, guess we'll fake it.
+           case "$finalize_command " in
+           *" -L$dir "*) ;;
+           *) finalize_command="$finalize_command -L$libdir";;
+           esac
+           finalize_command="$finalize_command -l$name"
+         fi
+       else
+         # Transform directly to old archives if we don't build new libraries.
+         if test -n "$pic_flag" && test -z "$old_library"; then
+           $echo "$modename: cannot find static library for \`$arg'" 1>&2
+           exit 1
+         fi
+
+         # Here we assume that one of hardcode_direct or hardcode_minus_L
+         # is not unsupported.  This is valid on all known static and
+         # shared platforms.
+         if test "$hardcode_direct" != unsupported; then
+           test -n "$old_library" && linklib="$old_library"
+           compile_command="$compile_command $dir/$linklib"
+           finalize_command="$finalize_command $dir/$linklib"
+         else
+           case "$compile_command " in
+           *" -L$dir "*) ;;
+           *) compile_command="$compile_command -L$dir";;
+           esac
+           compile_command="$compile_command -l$name"
+           case "$finalize_command " in
+           *" -L$dir "*) ;;
+           *) finalize_command="$finalize_command -L$dir";;
+           esac
+           finalize_command="$finalize_command -l$name"
+         fi
+       fi
+
+       # Add in any libraries that this one depends upon.
+       compile_command="$compile_command$dependency_libs"
+       finalize_command="$finalize_command$dependency_libs"
+       continue
+       ;;
+
+      # Some other compiler argument.
+      *)
+       # Unknown arguments in both finalize_command and compile_command need
+       # to be aesthetically quoted because they are evaled later.
+       arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
+       case "$arg" in
+       *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \   ]*|*]*)
+         arg="\"$arg\""
+         ;;
+       esac
+       ;;
+      esac
+
+      # Now actually substitute the argument into the commands.
+      if test -n "$arg"; then
+       compile_command="$compile_command $arg"
+       finalize_command="$finalize_command $arg"
+      fi
+    done
+
+    if test -n "$prev"; then
+      $echo "$modename: the \`$prevarg' option requires an argument" 1>&2
+      $echo "$help" 1>&2
+      exit 1
+    fi
+
+    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
+      eval arg=\"$export_dynamic_flag_spec\"
+      compile_command="$compile_command $arg"
+      finalize_command="$finalize_command $arg"
+    fi
+
+    oldlibs=
+    # calculate the name of the file, without its directory
+    outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'`
+    libobjs_save="$libobjs"
+
+    case "$output" in
+    "")
+      $echo "$modename: you must specify an output file" 1>&2
+      $echo "$help" 1>&2
+      exit 1
+      ;;
+
+    *.a | *.lib)
+      if test -n "$link_against_libtool_libs"; then
+       $echo "$modename: error: cannot link libtool libraries into archives" 1>&2
+       exit 1
+      fi
+
+      if test -n "$deplibs"; then
+       $echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2
+      fi
+
+      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+       $echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2
+      fi
+
+      if test -n "$rpath"; then
+       $echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2
+      fi
+
+      if test -n "$xrpath"; then
+       $echo "$modename: warning: \`-R' is ignored for archives" 1>&2
+      fi
+
+      if test -n "$vinfo"; then
+       $echo "$modename: warning: \`-version-info' is ignored for archives" 1>&2
+      fi
+
+      if test -n "$release"; then
+       $echo "$modename: warning: \`-release' is ignored for archives" 1>&2
+      fi
+
+      if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
+       $echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2
+      fi
+
+      # Now set the variables for building old libraries.
+      build_libtool_libs=no
+      oldlibs="$output"
+      ;;
+
+    *.la)
+      # Make sure we only generate libraries of the form `libNAME.la'.
+      case "$outputname" in
+      lib*)
+       name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
+       eval libname=\"$libname_spec\"
+       ;;
+      *)
+       if test "$module" = no; then
+         $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2
+         $echo "$help" 1>&2
+         exit 1
+       fi
+       if test "$need_lib_prefix" != no; then
+         # Add the "lib" prefix for modules if required
+         name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
+         eval libname=\"$libname_spec\"
+       else
+         libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
+       fi
+       ;;
+      esac
+
+      output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'`
+      if test "X$output_objdir" = "X$output"; then
+       output_objdir="$objdir"
+      else
+       output_objdir="$output_objdir/$objdir"
+      fi
+
+      if test -n "$objs"; then
+       $echo "$modename: cannot build libtool library \`$output' from non-libtool objects:$objs" 2>&1
+       exit 1
+      fi
+
+      # How the heck are we supposed to write a wrapper for a shared library?
+      if test -n "$link_against_libtool_libs"; then
+        $echo "$modename: error: cannot link shared libraries into libtool libraries" 1>&2
+        exit 1
+      fi
+
+      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+       $echo "$modename: warning: \`-dlopen' is ignored for libtool libraries" 1>&2
+      fi
+
+      set dummy $rpath
+      if test $# -gt 2; then
+       $echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2
+      fi
+      install_libdir="$2"
+
+      oldlibs=
+      if test -z "$rpath"; then
+       if test "$build_libtool_libs" = yes; then
+         # Building a libtool convenience library.
+         libext=al
+         oldlibs="$output_objdir/$libname.$libext $oldlibs"
+         build_libtool_libs=convenience
+         build_old_libs=yes
+       fi
+       dependency_libs="$deplibs"
+
+       if test -n "$vinfo"; then
+         $echo "$modename: warning: \`-version-info' is ignored for convenience libraries" 1>&2
+       fi
+
+       if test -n "$release"; then
+         $echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2
+       fi
+      else
+
+       # Parse the version information argument.
+       IFS="${IFS=     }"; save_ifs="$IFS"; IFS=':'
+       set dummy $vinfo 0 0 0
+       IFS="$save_ifs"
+
+       if test -n "$8"; then
+         $echo "$modename: too many parameters to \`-version-info'" 1>&2
+         $echo "$help" 1>&2
+         exit 1
+       fi
+
+       current="$2"
+       revision="$3"
+       age="$4"
+
+       # Check that each of the things are valid numbers.
+       case "$current" in
+       0 | [1-9] | [1-9][0-9]*) ;;
+       *)
+         $echo "$modename: CURRENT \`$current' is not a nonnegative integer" 1>&2
+         $echo "$modename: \`$vinfo' is not valid version information" 1>&2
+         exit 1
+         ;;
+       esac
+
+       case "$revision" in
+       0 | [1-9] | [1-9][0-9]*) ;;
+       *)
+         $echo "$modename: REVISION \`$revision' is not a nonnegative integer" 1>&2
+         $echo "$modename: \`$vinfo' is not valid version information" 1>&2
+         exit 1
+         ;;
+       esac
+
+       case "$age" in
+       0 | [1-9] | [1-9][0-9]*) ;;
+       *)
+         $echo "$modename: AGE \`$age' is not a nonnegative integer" 1>&2
+         $echo "$modename: \`$vinfo' is not valid version information" 1>&2
+         exit 1
+         ;;
+       esac
+
+       if test $age -gt $current; then
+         $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2
+         $echo "$modename: \`$vinfo' is not valid version information" 1>&2
+         exit 1
+       fi
+
+       # Calculate the version variables.
+       major=
+       versuffix=
+       verstring=
+       case "$version_type" in
+       none) ;;
+
+       irix)
+         major=`expr $current - $age + 1`
+         versuffix="$major.$revision"
+         verstring="sgi$major.$revision"
+
+         # Add in all the interfaces that we are compatible with.
+         loop=$revision
+         while test $loop != 0; do
+           iface=`expr $revision - $loop`
+           loop=`expr $loop - 1`
+           verstring="sgi$major.$iface:$verstring"
+         done
+         ;;
+
+       linux)
+         major=.`expr $current - $age`
+         versuffix="$major.$age.$revision"
+         ;;
+
+       osf)
+         major=`expr $current - $age`
+         versuffix=".$current.$age.$revision"
+         verstring="$current.$age.$revision"
+
+         # Add in all the interfaces that we are compatible with.
+         loop=$age
+         while test $loop != 0; do
+           iface=`expr $current - $loop`
+           loop=`expr $loop - 1`
+           verstring="$verstring:${iface}.0"
+         done
+
+         # Make executables depend on our current version.
+         verstring="$verstring:${current}.0"
+         ;;
+
+       sunos)
+         major=".$current"
+         versuffix=".$current.$revision"
+         ;;
+
+       freebsd-aout)
+         major=".$current"
+         versuffix=".$current.$revision";
+         ;;
+
+       freebsd-elf)
+         major=".$current"
+         versuffix=".$current";
+         ;;
+
+       windows)
+         # Like Linux, but with '-' rather than '.', since we only
+         # want one extension on Windows 95.
+         major=`expr $current - $age`
+         versuffix="-$major-$age-$revision"
+         ;;
+
+       *)
+         $echo "$modename: unknown library version type \`$version_type'" 1>&2
+         echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
+         exit 1
+         ;;
+       esac
+
+       # Clear the version info if we defaulted, and they specified a release.
+       if test -z "$vinfo" && test -n "$release"; then
+         major=
+         verstring="0.0"
+         if test "$need_version" = no; then
+           versuffix=
+         else
+           versuffix=".0.0"
+         fi
+       fi
+
+       # Remove version info from name if versioning should be avoided
+       if test "$avoid_version" = yes && test "$need_version" = no; then
+         major=
+         versuffix=
+         verstring=""
+       fi
+       
+       # Check to see if the archive will have undefined symbols.
+       if test "$allow_undefined" = yes; then
+         if test "$allow_undefined_flag" = unsupported; then
+           $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2
+           build_libtool_libs=no
+           build_old_libs=yes
+         fi
+       else
+         # Don't allow undefined symbols.
+         allow_undefined_flag="$no_undefined_flag"
+       fi
+
+       dependency_libs="$deplibs"
+       case "$host" in
+       *-*-cygwin* | *-*-mingw* | *-*-os2* | *-*-beos*)
+         # these systems don't actually have a c library (as such)!
+         ;;
+        *-*-rhapsody*)
+         # rhapsody is a little odd...
+         deplibs="$deplibs -framework System"
+         ;;
+       *)
+         # Add libc to deplibs on all other systems.
+         deplibs="$deplibs -lc"
+         ;;
+       esac
+      fi
+
+      # Create the output directory, or remove our outputs if we need to.
+      if test -d $output_objdir; then
+       $show "${rm}r $output_objdir/$outputname $output_objdir/$libname.* $output_objdir/${libname}${release}.*"
+       $run ${rm}r $output_objdir/$outputname $output_objdir/$libname.* $output_objdir/${libname}${release}.*
+      else
+       $show "$mkdir $output_objdir"
+       $run $mkdir $output_objdir
+       status=$?
+       if test $status -ne 0 && test ! -d $output_objdir; then
+         exit $status
+       fi
+      fi
+
+      # Now set the variables for building old libraries.
+      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
+       oldlibs="$oldlibs $output_objdir/$libname.$libext"
+
+       # Transform .lo files to .o files.
+       oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
+      fi
+
+      if test "$build_libtool_libs" = yes; then
+       # Transform deplibs into only deplibs that can be linked in shared.
+       name_save=$name
+       libname_save=$libname
+       release_save=$release
+       versuffix_save=$versuffix
+       major_save=$major
+       # I'm not sure if I'm treating the release correctly.  I think
+       # release should show up in the -l (ie -lgmp5) so we don't want to
+       # add it in twice.  Is that correct?
+       release=""
+       versuffix=""
+       major=""
+       newdeplibs=
+       droppeddeps=no
+       case "$deplibs_check_method" in
+       pass_all)
+         # Don't check for shared/static.  Everything works.
+         # This might be a little naive.  We might want to check
+         # whether the library exists or not.  But this is on
+         # osf3 & osf4 and I'm not really sure... Just
+         # implementing what was already the behaviour.
+         newdeplibs=$deplibs
+         ;;
+       test_compile)
+         # This code stresses the "libraries are programs" paradigm to its
+         # limits. Maybe even breaks it.  We compile a program, linking it
+         # against the deplibs as a proxy for the library.  Then we can check
+         # whether they linked in statically or dynamically with ldd.
+         $rm conftest.c
+         cat > conftest.c <<EOF
+         int main() { return 0; }
+EOF
+         $rm conftest
+         $CC -o conftest conftest.c $deplibs
+         if test $? -eq 0 ; then
+           ldd_output=`ldd conftest`
+           for i in $deplibs; do
+             name="`expr $i : '-l\(.*\)'`"
+             # If $name is empty we are operating on a -L argument.
+             if test "$name" != "" ; then
+               libname=`eval \\$echo \"$libname_spec\"`
+               deplib_matches=`eval \\$echo \"$library_names_spec\"`
+               set dummy $deplib_matches
+               deplib_match=$2
+               if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
+                 newdeplibs="$newdeplibs $i"
+               else
+                 droppeddeps=yes
+                 echo
+                 echo "*** Warning: This library needs some functionality provided by $i."
+                 echo "*** I have the capability to make that library automatically link in when"
+                 echo "*** you link to this library.  But I can only do this if you have a"
+                 echo "*** shared version of the library, which you do not appear to have."
+               fi
+             else
+               newdeplibs="$newdeplibs $i"
+             fi
+           done
+         else
+           # Error occured in the first compile.  Let's try to salvage the situation:
+           # Compile a seperate program for each library.
+           for i in $deplibs; do
+             name="`expr $i : '-l\(.*\)'`"
+            # If $name is empty we are operating on a -L argument.
+             if test "$name" != "" ; then
+               $rm conftest
+               $CC -o conftest conftest.c $i
+               # Did it work?
+               if test $? -eq 0 ; then
+                 ldd_output=`ldd conftest`
+                 libname=`eval \\$echo \"$libname_spec\"`
+                 deplib_matches=`eval \\$echo \"$library_names_spec\"`
+                 set dummy $deplib_matches
+                 deplib_match=$2
+                 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
+                   newdeplibs="$newdeplibs $i"
+                 else
+                   droppeddeps=yes
+                   echo
+                   echo "*** Warning: This library needs some functionality provided by $i."
+                   echo "*** I have the capability to make that library automatically link in when"
+                   echo "*** you link to this library.  But I can only do this if you have a"
+                   echo "*** shared version of the library, which you do not appear to have."
+                 fi
+               else
+                 droppeddeps=yes
+                 echo
+                 echo "*** Warning!  Library $i is needed by this library but I was not able to"
+                 echo "***  make it link in!  You will probably need to install it or some"
+                 echo "*** library that it depends on before this library will be fully"
+                 echo "*** functional.  Installing it before continuing would be even better."
+               fi
+             else
+               newdeplibs="$newdeplibs $i"
+             fi
+           done
+         fi
+         ;;
+       file_magic*)
+         set dummy $deplibs_check_method
+         file_magic_regex="`expr \"$deplibs_check_method\" : \"$2 \(.*\)\"`"
+         for a_deplib in $deplibs; do
+           name="`expr $a_deplib : '-l\(.*\)'`"
+           # If $name is empty we are operating on a -L argument.
+           if test "$name" != "" ; then
+             libname=`eval \\$echo \"$libname_spec\"`
+             for i in $lib_search_path; do
+                   potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
+                   for potent_lib in $potential_libs; do
+                     # Follow soft links.
+                     if ls -lLd "$potent_lib" 2>/dev/null \
+                        | grep " -> " >/dev/null; then
+                       continue 
+                     fi
+                     # The statement above tries to avoid entering an
+                     # endless loop below, in case of cyclic links.
+                     # We might still enter an endless loop, since a link
+                     # loop can be closed while we follow links,
+                     # but so what?
+                     potlib="$potent_lib"
+                     while test -h "$potlib" 2>/dev/null; do
+                       potliblink=`ls -ld $potlib | sed 's/.* -> //'`
+                       case "$potliblink" in
+                       [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
+                       *) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
+                       esac
+                     done
+                     if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \
+                        | sed 10q \
+                        | egrep "$file_magic_regex" > /dev/null; then
+                       newdeplibs="$newdeplibs $a_deplib"
+                       a_deplib=""
+                       break 2
+                     fi
+                   done
+             done
+             if test -n "$a_deplib" ; then
+               droppeddeps=yes
+               echo
+               echo "*** Warning: This library needs some functionality provided by $a_deplib."
+               echo "*** I have the capability to make that library automatically link in when"
+               echo "*** you link to this library.  But I can only do this if you have a"
+               echo "*** shared version of the library, which you do not appear to have."
+             fi
+           else
+             # Add a -L argument.
+             newdeplibs="$newdeplibs $a_deplib"
+           fi
+         done # Gone through all deplibs.
+         ;;
+       none | unknown | *)
+         newdeplibs=""
+         if $echo "X $deplibs" | $Xsed -e 's/ -lc$//' \
+              -e 's/ -[LR][^ ]*//g' -e 's/[    ]//g' |
+            grep . >/dev/null; then
+           echo
+           if test "X$deplibs_check_method" = "Xnone"; then
+             echo "*** Warning: inter-library dependencies are not supported in this platform."
+           else
+             echo "*** Warning: inter-library dependencies are not known to be supported."
+           fi
+           echo "*** All declared inter-library dependencies are being dropped."
+           droppeddeps=yes
+         fi
+         ;;
+       esac
+       versuffix=$versuffix_save
+       major=$major_save
+       release=$release_save
+       libname=$libname_save
+       name=$name_save
+
+       if test "$droppeddeps" = yes; then
+         if test "$module" = yes; then
+           echo
+           echo "*** Warning: libtool could not satisfy all declared inter-library"
+           echo "*** dependencies of module $libname.  Therefore, libtool will create"
+           echo "*** a static module, that should work as long as the dlopening"
+           echo "*** application is linked with the -dlopen flag."
+           if test -z "$global_symbol_pipe"; then
+             echo
+             echo "*** However, this would only work if libtool was able to extract symbol"
+             echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
+             echo "*** not find such a program.  So, this module is probably useless."
+             echo "*** \`nm' from GNU binutils and a full rebuild may help."
+           fi
+           if test "$build_old_libs" = no; then
+             oldlibs="$output_objdir/$libname.$libext"
+             build_libtool_libs=module
+             build_old_libs=yes
+           else
+             build_libtool_libs=no
+           fi
+         else
+           echo "*** The inter-library dependencies that have been dropped here will be"
+           echo "*** automatically added whenever a program is linked with this library"
+           echo "*** or is declared to -dlopen it."
+         fi
+       fi
+       # Done checking deplibs!
+       deplibs=$newdeplibs
+      fi
+
+      # All the library-specific variables (install_libdir is set above).
+      library_names=
+      old_library=
+      dlname=
+      
+      # Test again, we may have decided not to build it any more
+      if test "$build_libtool_libs" = yes; then
+       # Get the real and link names of the library.
+       eval library_names=\"$library_names_spec\"
+       set dummy $library_names
+       realname="$2"
+       shift; shift
+
+       if test -n "$soname_spec"; then
+         eval soname=\"$soname_spec\"
+       else
+         soname="$realname"
+       fi
+
+       lib="$output_objdir/$realname"
+       for link
+       do
+         linknames="$linknames $link"
+       done
+
+       # Ensure that we have .o objects for linkers which dislike .lo
+       # (e.g. aix) in case we are running --disable-static
+       for obj in $libobjs; do
+         xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'`
+         if test "X$xdir" = "X$obj"; then
+           xdir="."
+         else
+           xdir="$xdir"
+         fi
+         baseobj=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
+         oldobj=`$echo "X$baseobj" | $Xsed -e "$lo2o"`
+         if test ! -f $xdir/$oldobj; then
+           $show "(cd $xdir && ${LN_S} $baseobj $oldobj)"
+           $run eval '(cd $xdir && ${LN_S} $baseobj $oldobj)' || exit $?
+         fi
+       done
+
+       # Use standard objects if they are pic
+       test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+
+       # Prepare the list of exported symbols
+       if test -z "$export_symbols"; then
+         if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
+           $show "generating symbol list for \`$libname.la'"
+           export_symbols="$output_objdir/$libname.exp"
+           $run $rm $export_symbols
+           eval cmds=\"$export_symbols_cmds\"
+           IFS="${IFS=         }"; save_ifs="$IFS"; IFS='~'
+           for cmd in $cmds; do
+             IFS="$save_ifs"
+             $show "$cmd"
+             $run eval "$cmd" || exit $?
+           done
+           IFS="$save_ifs"
+           if test -n "$export_symbols_regex"; then
+             $show "egrep -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\""
+             $run eval 'egrep -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
+             $show "$mv \"${export_symbols}T\" \"$export_symbols\""
+             $run eval '$mv "${export_symbols}T" "$export_symbols"'
+           fi
+         fi
+       fi
+
+       if test -n "$export_symbols" && test -n "$include_expsyms"; then
+         $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"'
+       fi
+
+       if test -n "$convenience"; then
+         if test -n "$whole_archive_flag_spec"; then
+           eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
+         else
+           gentop="$output_objdir/${outputname}x"
+           $show "${rm}r $gentop"
+           $run ${rm}r "$gentop"
+           $show "mkdir $gentop"
+           $run mkdir "$gentop"
+           status=$?
+           if test $status -ne 0 && test ! -d "$gentop"; then
+             exit $status
+           fi
+           generated="$generated $gentop"
+
+           for xlib in $convenience; do
+             # Extract the objects.
+             case "$xlib" in
+             [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;;
+             *) xabs=`pwd`"/$xlib" ;;
+             esac
+             xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'`
+             xdir="$gentop/$xlib"
+
+             $show "${rm}r $xdir"
+             $run ${rm}r "$xdir"
+             $show "mkdir $xdir"
+             $run mkdir "$xdir"
+             status=$?
+             if test $status -ne 0 && test ! -d "$xdir"; then
+               exit $status
+             fi
+             $show "(cd $xdir && $AR x $xabs)"
+             $run eval "(cd \$xdir && $AR x \$xabs)" || exit $?
+
+             libobjs="$libobjs "`find $xdir -name \*.o -print -o -name \*.lo -print | $NL2SP`
+           done
+         fi
+       fi
+
+       if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
+         eval flag=\"$thread_safe_flag_spec\"
+         linkopts="$linkopts $flag"
+       fi
+
+       # Do each of the archive commands.
+       if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
+         eval cmds=\"$archive_expsym_cmds\"
+       else
+         eval cmds=\"$archive_cmds\"
+       fi
+       IFS="${IFS=     }"; save_ifs="$IFS"; IFS='~'
+       for cmd in $cmds; do
+         IFS="$save_ifs"
+         $show "$cmd"
+         $run eval "$cmd" || exit $?
+       done
+       IFS="$save_ifs"
+
+       # Create links to the real library.
+       for linkname in $linknames; do
+         if test "$realname" != "$linkname"; then
+           $show "(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)"
+           $run eval '(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)' || exit $?
+         fi
+       done
+
+       # If -module or -export-dynamic was specified, set the dlname.
+       if test "$module" = yes || test "$export_dynamic" = yes; then
+         # On all known operating systems, these are identical.
+         dlname="$soname"
+       fi
+      fi
+      ;;
+
+    *.lo | *.o | *.obj)
+      if test -n "$link_against_libtool_libs"; then
+       $echo "$modename: error: cannot link libtool libraries into objects" 1>&2
+       exit 1
+      fi
+
+      if test -n "$deplibs"; then
+       $echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2
+      fi
+
+      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+       $echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2
+      fi
+
+      if test -n "$rpath"; then
+       $echo "$modename: warning: \`-rpath' is ignored for objects" 1>&2
+      fi
+
+      if test -n "$xrpath"; then
+       $echo "$modename: warning: \`-R' is ignored for objects" 1>&2
+      fi
+
+      if test -n "$vinfo"; then
+       $echo "$modename: warning: \`-version-info' is ignored for objects" 1>&2
+      fi
+
+      if test -n "$release"; then
+       $echo "$modename: warning: \`-release' is ignored for objects" 1>&2
+      fi
+
+      case "$output" in
+      *.lo)
+       if test -n "$objs"; then
+         $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2
+         exit 1
+       fi
+       libobj="$output"
+       obj=`$echo "X$output" | $Xsed -e "$lo2o"`
+       ;;
+      *)
+       libobj=
+       obj="$output"
+       ;;
+      esac
+
+      # Delete the old objects.
+      $run $rm $obj $libobj
+
+      # Objects from convenience libraries.  This assumes
+      # single-version convenience libraries.  Whenever we create
+      # different ones for PIC/non-PIC, this we'll have to duplicate
+      # the extraction.
+      reload_conv_objs=
+      gentop=
+      # reload_cmds runs $LD directly, so let us get rid of
+      # -Wl from whole_archive_flag_spec
+      wl= 
+
+      if test -n "$convenience"; then
+       if test -n "$whole_archive_flag_spec"; then
+         eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\"
+       else
+         gentop="$output_objdir/${obj}x"
+         $show "${rm}r $gentop"
+         $run ${rm}r "$gentop"
+         $show "mkdir $gentop"
+         $run mkdir "$gentop"
+         status=$?
+         if test $status -ne 0 && test ! -d "$gentop"; then
+           exit $status
+         fi
+         generated="$generated $gentop"
+
+         for xlib in $convenience; do
+           # Extract the objects.
+           case "$xlib" in
+           [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;;
+           *) xabs=`pwd`"/$xlib" ;;
+           esac
+           xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'`
+           xdir="$gentop/$xlib"
+
+           $show "${rm}r $xdir"
+           $run ${rm}r "$xdir"
+           $show "mkdir $xdir"
+           $run mkdir "$xdir"
+           status=$?
+           if test $status -ne 0 && test ! -d "$xdir"; then
+             exit $status
+           fi
+           $show "(cd $xdir && $AR x $xabs)"
+           $run eval "(cd \$xdir && $AR x \$xabs)" || exit $?
+
+           reload_conv_objs="$reload_objs "`find $xdir -name \*.o -print -o -name \*.lo -print | $NL2SP`
+         done
+       fi
+      fi
+
+      # Create the old-style object.
+      reload_objs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs"
+
+      output="$obj"
+      eval cmds=\"$reload_cmds\"
+      IFS="${IFS=      }"; save_ifs="$IFS"; IFS='~'
+      for cmd in $cmds; do
+       IFS="$save_ifs"
+       $show "$cmd"
+       $run eval "$cmd" || exit $?
+      done
+      IFS="$save_ifs"
+
+      # Exit if we aren't doing a library object file.
+      if test -z "$libobj"; then
+       if test -n "$gentop"; then
+         $show "${rm}r $gentop"
+         $run ${rm}r $gentop
+       fi
+
+       exit 0
+      fi
+
+      if test "$build_libtool_libs" != yes; then
+       if test -n "$gentop"; then
+         $show "${rm}r $gentop"
+         $run ${rm}r $gentop
+       fi
+
+       # Create an invalid libtool object if no PIC, so that we don't
+       # accidentally link it into a program.
+       $show "echo timestamp > $libobj"
+       $run eval "echo timestamp > $libobj" || exit $?
+       exit 0
+      fi
+
+      if test -n "$pic_flag"; then
+       # Only do commands if we really have different PIC objects.
+       reload_objs="$libobjs $reload_conv_objs"
+       output="$libobj"
+       eval cmds=\"$reload_cmds\"
+       IFS="${IFS=     }"; save_ifs="$IFS"; IFS='~'
+       for cmd in $cmds; do
+         IFS="$save_ifs"
+         $show "$cmd"
+         $run eval "$cmd" || exit $?
+       done
+       IFS="$save_ifs"
+      else
+       # Just create a symlink.
+       $show $rm $libobj
+       $run $rm $libobj
+       xdir=`$echo "X$libobj" | $Xsed -e 's%/[^/]*$%%'`
+       if test "X$xdir" = "X$libobj"; then
+         xdir="."
+       else
+         xdir="$xdir"
+       fi
+       baseobj=`$echo "X$libobj" | $Xsed -e 's%^.*/%%'`
+       oldobj=`$echo "X$baseobj" | $Xsed -e "$lo2o"`
+       $show "(cd $xdir && $LN_S $oldobj $baseobj)"
+       $run eval '(cd $xdir && $LN_S $oldobj $baseobj)' || exit $?
+      fi
+
+      if test -n "$gentop"; then
+       $show "${rm}r $gentop"
+       $run ${rm}r $gentop
+      fi
+
+      exit 0
+      ;;
+
+    # Anything else should be a program.
+    *)
+      if test -n "$vinfo"; then
+       $echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2
+      fi
+
+      if test -n "$release"; then
+       $echo "$modename: warning: \`-release' is ignored for programs" 1>&2
+      fi
+
+      if test "$preload" = yes; then
+       if test "$dlopen" = unknown && test "$dlopen_self" = unknown &&
+          test "$dlopen_self_static" = unknown; then
+         $echo "$modename: warning: \`AC_LIBTOOL_DLOPEN' not used. Assuming no dlopen support."
+       fi 
+      fi
+    
+      if test -n "$rpath$xrpath"; then
+       # If the user specified any rpath flags, then add them.
+       for libdir in $rpath $xrpath; do
+         # This is the magic to use -rpath.
+         case "$compile_rpath " in
+         *" $libdir "*) ;;
+         *) compile_rpath="$compile_rpath $libdir" ;;
+         esac
+         case "$finalize_rpath " in
+         *" $libdir "*) ;;
+         *) finalize_rpath="$finalize_rpath $libdir" ;;
+         esac
+       done
+      fi
+
+      # Now hardcode the library paths
+      rpath=
+      hardcode_libdirs=
+      for libdir in $compile_rpath $finalize_rpath; do
+       if test -n "$hardcode_libdir_flag_spec"; then
+         if test -n "$hardcode_libdir_separator"; then
+           if test -z "$hardcode_libdirs"; then
+             hardcode_libdirs="$libdir"
+           else
+             # Just accumulate the unique libdirs.
+             case "$hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator" in
+             *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
+               ;;
+             *)
+               hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
+               ;;
+             esac
+           fi
+         else
+           eval flag=\"$hardcode_libdir_flag_spec\"
+           rpath="$rpath $flag"
+         fi
+       elif test -n "$runpath_var"; then
+         case "$perm_rpath " in
+         *" $libdir "*) ;;
+         *) perm_rpath="$perm_rpath $libdir" ;;
+         esac
+       fi
+      done
+      # Substitute the hardcoded libdirs into the rpath.
+      if test -n "$hardcode_libdir_separator" &&
+        test -n "$hardcode_libdirs"; then
+       libdir="$hardcode_libdirs"
+       eval rpath=\" $hardcode_libdir_flag_spec\"
+      fi
+      compile_rpath="$rpath"
+
+      rpath=
+      hardcode_libdirs=
+      for libdir in $finalize_rpath; do
+       if test -n "$hardcode_libdir_flag_spec"; then
+         if test -n "$hardcode_libdir_separator"; then
+           if test -z "$hardcode_libdirs"; then
+             hardcode_libdirs="$libdir"
+           else
+             # Just accumulate the unique libdirs.
+             case "$hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator" in
+             *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
+               ;;
+             *)
+               hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
+               ;;
+             esac
+           fi
+         else
+           eval flag=\"$hardcode_libdir_flag_spec\"
+           rpath="$rpath $flag"
+         fi
+       elif test -n "$runpath_var"; then
+         case "$finalize_perm_rpath " in
+         *" $libdir "*) ;;
+         *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
+         esac
+       fi
+      done
+      # Substitute the hardcoded libdirs into the rpath.
+      if test -n "$hardcode_libdir_separator" &&
+        test -n "$hardcode_libdirs"; then
+       libdir="$hardcode_libdirs"
+       eval rpath=\" $hardcode_libdir_flag_spec\"
+      fi
+      finalize_rpath="$rpath"
+
+      output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'`
+      if test "X$output_objdir" = "X$output"; then
+       output_objdir="$objdir"
+      else
+       output_objdir="$output_objdir/$objdir"
+      fi
+
+      # Create the binary in the object directory, then wrap it.
+      if test ! -d $output_objdir; then
+       $show "$mkdir $output_objdir"
+       $run $mkdir $output_objdir
+       status=$?
+       if test $status -ne 0 && test ! -d $output_objdir; then
+         exit $status
+       fi
+      fi
+
+      if test -n "$libobjs" && test "$build_old_libs" = yes; then
+       # Transform all the library objects into standard objects.
+       compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+       finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+      fi
+
+      dlsyms=
+      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+       if test -n "$NM" && test -n "$global_symbol_pipe"; then
+         dlsyms="${outputname}S.c"
+       else
+         $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2
+       fi
+      fi
+
+      if test -n "$dlsyms"; then
+       case "$dlsyms" in
+       "") ;;
+       *.c)
+         # Discover the nlist of each of the dlfiles.
+         nlist="$output_objdir/${outputname}.nm"
+
+         $show "$rm $nlist ${nlist}S ${nlist}T"
+         $run $rm "$nlist" "${nlist}S" "${nlist}T"
+
+         # Parse the name list into a source file.
+         $show "creating $output_objdir/$dlsyms"
+
+         test -z "$run" && $echo > "$output_objdir/$dlsyms" "\
+/* $dlsyms - symbol resolution table for \`$outputname' dlsym emulation. */
+/* Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP */
+
+#ifdef __cplusplus
+extern \"C\" {
+#endif
+
+/* Prevent the only kind of declaration conflicts we can make. */
+#define lt_preloaded_symbols some_other_symbol
+
+/* External symbol declarations for the compiler. */\
+"
+
+         if test "$dlself" = yes; then
+           $show "generating symbol list for \`$output'"
+
+           test -z "$run" && $echo ': @PROGRAM@ ' > "$nlist"
+
+           # Add our own program objects to the symbol list.
+           progfiles=`$echo "X$objs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+           for arg in $progfiles; do
+             $show "extracting global C symbols from \`$arg'"
+             $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
+           done
+
+           if test -n "$exclude_expsyms"; then
+             $run eval 'egrep -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
+             $run eval '$mv "$nlist"T "$nlist"'
+           fi
+           
+           if test -n "$export_symbols_regex"; then
+             $run eval 'egrep -e "$export_symbols_regex" "$nlist" > "$nlist"T'
+             $run eval '$mv "$nlist"T "$nlist"'
+           fi
+
+           # Prepare the list of exported symbols
+           if test -z "$export_symbols"; then
+             export_symbols="$output_objdir/$output.exp"
+             $run $rm $export_symbols
+             $run eval "sed -n -e '/^: @PROGRAM@$/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
+           else
+             $run eval "sed -e 's/\([][.*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$output.exp"'
+             $run eval 'grep -f "$output_objdir/$output.exp" < "$nlist" > "$nlist"T'
+             $run eval 'mv "$nlist"T "$nlist"'
+           fi
+         fi
+
+         for arg in $dlprefiles; do
+           $show "extracting global C symbols from \`$arg'"
+           name=`echo "$arg" | sed -e 's%^.*/%%'`
+           $run eval 'echo ": $name " >> "$nlist"'
+           $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
+         done
+
+         if test -z "$run"; then
+           # Make sure we have at least an empty file.
+           test -f "$nlist" || : > "$nlist"
+
+           if test -n "$exclude_expsyms"; then
+             egrep -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
+             $mv "$nlist"T "$nlist"
+           fi
+
+           # Try sorting and uniquifying the output.
+           if grep -v "^: " < "$nlist" | sort +2 | uniq > "$nlist"S; then
+             :
+           else
+             grep -v "^: " < "$nlist" > "$nlist"S
+           fi
+
+           if test -f "$nlist"S; then
+             eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"'
+           else
+             echo '/* NONE */' >> "$output_objdir/$dlsyms"
+           fi
+
+           $echo >> "$output_objdir/$dlsyms" "\
+
+#undef lt_preloaded_symbols
+
+#if defined (__STDC__) && __STDC__
+# define lt_ptr_t void *
+#else
+# define lt_ptr_t char *
+# define const
+#endif
+
+/* The mapping between symbol names and symbols. */
+const struct {
+  const char *name;
+  lt_ptr_t address;
+}
+lt_preloaded_symbols[] =
+{\
+"
+
+           sed -n -e 's/^: \([^ ]*\) $/  {\"\1\", (lt_ptr_t) 0},/p' \
+               -e 's/^. \([^ ]*\) \([^ ]*\)$/  {"\2", (lt_ptr_t) \&\2},/p' \
+                 < "$nlist" >> "$output_objdir/$dlsyms"
+
+           $echo >> "$output_objdir/$dlsyms" "\
+  {0, (lt_ptr_t) 0}
+};
+
+/* This works around a problem in FreeBSD linker */
+#ifdef FREEBSD_WORKAROUND
+static const void *lt_preloaded_setup() {
+  return lt_preloaded_symbols;
+}
+#endif
+
+#ifdef __cplusplus
+}
+#endif\
+"
+         fi
+
+         pic_flag_for_symtable=
+         case "$host" in
+         # compiling the symbol table file with pic_flag works around
+         # a FreeBSD bug that causes programs to crash when -lm is
+         # linked before any other PIC object.  But we must not use
+         # pic_flag when linking with -static.  The problem exists in
+         # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
+         *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)\r
+           case "$compile_command " in
+           *" -static "*) ;;
+           *) pic_flag_for_symtable=" $pic_flag -DPIC -DFREEBSD_WORKAROUND";;
+           esac;;
+         *-*-hpux*)
+           case "$compile_command " in
+           *" -static "*) ;;
+           *) pic_flag_for_symtable=" $pic_flag -DPIC";;
+           esac
+         esac
+
+         # Now compile the dynamic symbol file.
+         $show "(cd $output_objdir && $CC -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")"
+         $run eval '(cd $output_objdir && $CC -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $?
+
+         # Clean up the generated files.
+         $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T"
+         $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T"
+
+         # Transform the symbol file into the correct name.
+         compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
+         finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
+         ;;
+       *)
+         $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2
+         exit 1
+         ;;
+       esac
+      else
+       # We keep going just in case the user didn't refer to
+       # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
+       # really was required.
+
+       # Nullify the symbol file.
+       compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
+       finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
+      fi
+
+      if test -z "$link_against_libtool_libs" || test "$build_libtool_libs" != yes; then
+       # Replace the output file specification.
+       compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
+       link_command="$compile_command$compile_rpath"
+
+       # We have no uninstalled library dependencies, so finalize right now.
+       $show "$link_command"
+       $run eval "$link_command"
+       status=$?
+       
+       # Delete the generated files.
+       if test -n "$dlsyms"; then
+         $show "$rm $output_objdir/${outputname}S.${objext}"
+         $run $rm "$output_objdir/${outputname}S.${objext}"
+       fi
+
+       exit $status
+      fi
+
+      if test -n "$shlibpath_var"; then
+       # We should set the shlibpath_var
+       rpath=
+       for dir in $temp_rpath; do
+         case "$dir" in
+         [\\/]* | [A-Za-z]:[\\/]*)
+           # Absolute path.
+           rpath="$rpath$dir:"
+           ;;
+         *)
+           # Relative path: add a thisdir entry.
+           rpath="$rpath\$thisdir/$dir:"
+           ;;
+         esac
+       done
+       temp_rpath="$rpath"
+      fi
+
+      if test -n "$compile_shlibpath$finalize_shlibpath"; then
+       compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
+      fi
+      if test -n "$finalize_shlibpath"; then
+       finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
+      fi
+
+      compile_var=
+      finalize_var=
+      if test -n "$runpath_var"; then
+       if test -n "$perm_rpath"; then
+         # We should set the runpath_var.
+         rpath=
+         for dir in $perm_rpath; do
+           rpath="$rpath$dir:"
+         done
+         compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
+       fi
+       if test -n "$finalize_perm_rpath"; then
+         # We should set the runpath_var.
+         rpath=
+         for dir in $finalize_perm_rpath; do
+           rpath="$rpath$dir:"
+         done
+         finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
+       fi
+      fi
+
+      if test "$hardcode_action" = relink; then
+       # Fast installation is not supported
+       link_command="$compile_var$compile_command$compile_rpath"
+       relink_command="$finalize_var$finalize_command$finalize_rpath"
+       
+       $echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2
+       $echo "$modename: \`$output' will be relinked during installation" 1>&2
+      else
+       if test "$fast_install" != no; then
+         link_command="$finalize_var$compile_command$finalize_rpath"
+         if test "$fast_install" = yes; then
+           relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'`
+         else
+           # fast_install is set to needless
+           relink_command=
+         fi
+       else
+         link_command="$compile_var$compile_command$compile_rpath"
+         relink_command="$finalize_var$finalize_command$finalize_rpath"
+       fi
+      fi
+
+      # Replace the output file specification.
+      link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
+      
+      # Delete the old output files.
+      $run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname
+
+      $show "$link_command"
+      $run eval "$link_command" || exit $?
+
+      # Now create the wrapper script.
+      $show "creating $output"
+
+      # Quote the relink command for shipping.
+      if test -n "$relink_command"; then
+       relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
+      fi
+
+      # Quote $echo for shipping.
+      if test "X$echo" = "X$SHELL $0 --fallback-echo"; then
+       case "$0" in
+       [\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $0 --fallback-echo";;
+       *) qecho="$SHELL `pwd`/$0 --fallback-echo";;
+       esac
+       qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"`
+      else
+       qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"`
+      fi
+
+      # Only actually do things if our run command is non-null.
+      if test -z "$run"; then
+       # win32 will think the script is a binary if it has
+       # a .exe suffix, so we strip it off here.
+       case $output in
+         *.exe) output=`echo $output|sed 's,.exe$,,'` ;;
+       esac
+       $rm $output
+       trap "$rm $output; exit 1" 1 2 15
+
+       $echo > $output "\
+#! $SHELL
+
+# $output - temporary wrapper script for $objdir/$outputname
+# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
+#
+# The $output program cannot be directly executed until all the libtool
+# libraries that it depends on are installed.
+#
+# This wrapper script should never be moved out of the build directory.
+# If it is, it will not operate correctly.
+
+# Sed substitution that helps us do robust quoting.  It backslashifies
+# metacharacters that are still active within double-quoted strings.
+Xsed='sed -e 1s/^X//'
+sed_quote_subst='$sed_quote_subst'
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+if test \"\${CDPATH+set}\" = set; then CDPATH=:; export CDPATH; fi
+
+relink_command=\"$relink_command\"
+
+# This environment variable determines our operation mode.
+if test \"\$libtool_install_magic\" = \"$magic\"; then
+  # install mode needs the following variable:
+  link_against_libtool_libs='$link_against_libtool_libs'
+else
+  # When we are sourced in execute mode, \$file and \$echo are already set.
+  if test \"\$libtool_execute_magic\" != \"$magic\"; then
+    echo=\"$qecho\"
+    file=\"\$0\"
+    # Make sure echo works.
+    if test \"X\$1\" = X--no-reexec; then
+      # Discard the --no-reexec flag, and continue.
+      shift
+    elif test \"X\`(\$echo '\t') 2>/dev/null\`\" = 'X\t'; then
+      # Yippee, \$echo works!
+      :
+    else
+      # Restart under the correct shell, and then maybe \$echo will work.
+      exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"}
+    fi
+  fi\
+"
+       $echo >> $output "\
+
+  # Find the directory that this script lives in.
+  thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\`
+  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
+
+  # Follow symbolic links until we get to the real thisdir.
+  file=\`ls -ld \"\$file\" | sed -n 's/.*-> //p'\`
+  while test -n \"\$file\"; do
+    destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`
+
+    # If there was a directory component, then change thisdir.
+    if test \"x\$destdir\" != \"x\$file\"; then
+      case \"\$destdir\" in
+      [\\/]* | [A-Za-z]:[\\/]*) thisdir=\"\$destdir\" ;;
+      *) thisdir=\"\$thisdir/\$destdir\" ;;
+      esac
+    fi
+
+    file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
+    file=\`ls -ld \"\$thisdir/\$file\" | sed -n 's/.*-> //p'\`
+  done
+
+  # Try to get the absolute directory name.
+  absdir=\`cd \"\$thisdir\" && pwd\`
+  test -n \"\$absdir\" && thisdir=\"\$absdir\"
+"
+
+       if test "$fast_install" = yes; then
+         echo >> $output "\
+  program=lt-'$outputname'
+  progdir=\"\$thisdir/$objdir\"
+  
+  if test ! -f \"\$progdir/\$program\" || \\
+     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | sed 1q\`; \\
+       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
+
+    file=\"\$\$-\$program\"
+
+    if test ! -d \"\$progdir\"; then
+      $mkdir \"\$progdir\"
+    else
+      $rm \"\$progdir/\$file\"
+    fi"
+
+         echo >> $output "\
+
+    # relink executable if necessary
+    if test -n \"\$relink_command\"; then
+      if (cd \"\$thisdir\" && eval \$relink_command); then :
+      else
+       $rm \"\$progdir/\$file\"
+       exit 1
+      fi
+    fi
+
+    $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
+    { $rm \"\$progdir/\$program\";
+      $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; }
+    $rm \"\$progdir/\$file\"
+  fi"
+       else
+         echo >> $output "\
+  program='$outputname'
+  progdir=\"\$thisdir/$objdir\"
+"
+       fi
+
+       echo >> $output "\
+
+  if test -f \"\$progdir/\$program\"; then"
+
+       # Export our shlibpath_var if we have one.
+       if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
+         $echo >> $output "\
+    # Add our own library path to $shlibpath_var
+    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
+
+    # Some systems cannot cope with colon-terminated $shlibpath_var
+    # The second colon is a workaround for a bug in BeOS R4 sed
+    $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
+
+    export $shlibpath_var
+"
+       fi
+
+       # fixup the dll searchpath if we need to.
+       if test -n "$dllsearchpath"; then
+         $echo >> $output "\
+    # Add the dll search path components to the executable PATH
+    PATH=$dllsearchpath:\$PATH
+"
+       fi
+
+       $echo >> $output "\
+    if test \"\$libtool_execute_magic\" != \"$magic\"; then
+      # Run the actual program with our arguments.
+"
+       case $host in
+         # win32 systems need to use the prog path for dll
+         # lookup to work
+       *-*-cygwin*)
+         $echo >> $output "\
+      exec \$progdir/\$program \${1+\"\$@\"}
+"
+         ;;
+
+       # Backslashes separate directories on plain windows
+       *-*-mingw | *-*-os2*)
+         $echo >> $output "\
+      exec \$progdir\\\\\$program \${1+\"\$@\"}
+"
+         ;;
+
+       *)
+         $echo >> $output "\
+      # Export the path to the program.
+      PATH=\"\$progdir:\$PATH\"
+      export PATH
+
+      exec \$program \${1+\"\$@\"}
+"
+         ;;
+       esac
+       $echo >> $output "\
+      \$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\"
+      exit 1
+    fi
+  else
+    # The program doesn't exist.
+    \$echo \"\$0: error: \$progdir/\$program does not exist\" 1>&2
+    \$echo \"This script is just a wrapper for \$program.\" 1>&2
+    echo \"See the $PACKAGE documentation for more information.\" 1>&2
+    exit 1
+  fi
+fi\
+"
+       chmod +x $output
+      fi
+      exit 0
+      ;;
+    esac
+
+    # See if we need to build an old-fashioned archive.
+    for oldlib in $oldlibs; do
+
+      if test "$build_libtool_libs" = convenience; then
+       oldobjs="$libobjs_save"
+       addlibs="$convenience"
+       build_libtool_libs=no
+      else
+       if test "$build_libtool_libs" = module; then
+         oldobjs="$libobjs_save"
+         build_libtool_libs=no
+       else
+         oldobjs="$objs "`$echo "X$libobjs_save" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`
+       fi
+       addlibs="$old_convenience"
+      fi
+
+      if test -n "$addlibs"; then
+       gentop="$output_objdir/${outputname}x"
+       $show "${rm}r $gentop"
+       $run ${rm}r "$gentop"
+       $show "mkdir $gentop"
+       $run mkdir "$gentop"
+       status=$?
+       if test $status -ne 0 && test ! -d "$gentop"; then
+         exit $status
+       fi
+       generated="$generated $gentop"
+         
+       # Add in members from convenience archives.
+       for xlib in $addlibs; do
+         # Extract the objects.
+         case "$xlib" in
+         [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;;
+         *) xabs=`pwd`"/$xlib" ;;
+         esac
+         xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'`
+         xdir="$gentop/$xlib"
+
+         $show "${rm}r $xdir"
+         $run ${rm}r "$xdir"
+         $show "mkdir $xdir"
+         $run mkdir "$xdir"
+         status=$?
+         if test $status -ne 0 && test ! -d "$xdir"; then
+           exit $status
+         fi
+         $show "(cd $xdir && $AR x $xabs)"
+         $run eval "(cd \$xdir && $AR x \$xabs)" || exit $?
+
+         oldobjs="$oldobjs "`find $xdir -name \*.${objext} -print -o -name \*.lo -print | $NL2SP`
+       done
+      fi
+
+      # Do each command in the archive commands.
+      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
+       eval cmds=\"$old_archive_from_new_cmds\"
+      else
+       # Ensure that we have .o objects in place in case we decided
+       # not to build a shared library, and have fallen back to building
+       # static libs even though --disable-static was passed!
+       for oldobj in $oldobjs; do
+         if test ! -f $oldobj; then
+           xdir=`$echo "X$oldobj" | $Xsed -e 's%/[^/]*$%%'`
+           if test "X$xdir" = "X$oldobj"; then
+             xdir="."
+           else
+             xdir="$xdir"
+           fi
+           baseobj=`$echo "X$oldobj" | $Xsed -e 's%^.*/%%'`
+           obj=`$echo "X$baseobj" | $Xsed -e "$o2lo"`
+           $show "(cd $xdir && ${LN_S} $obj $baseobj)"
+           $run eval '(cd $xdir && ${LN_S} $obj $baseobj)' || exit $?
+         fi
+       done
+
+       eval cmds=\"$old_archive_cmds\"
+      fi
+      IFS="${IFS=      }"; save_ifs="$IFS"; IFS='~'
+      for cmd in $cmds; do
+       IFS="$save_ifs"
+       $show "$cmd"
+       $run eval "$cmd" || exit $?
+      done
+      IFS="$save_ifs"
+    done
+
+    if test -n "$generated"; then
+      $show "${rm}r$generated"
+      $run ${rm}r$generated
+    fi
+
+    # Now create the libtool archive.
+    case "$output" in
+    *.la)
+      old_library=
+      test "$build_old_libs" = yes && old_library="$libname.$libext"
+      $show "creating $output"
+
+      if test -n "$xrpath"; then
+       temp_xrpath=
+       for libdir in $xrpath; do
+         temp_xrpath="$temp_xrpath -R$libdir"
+       done
+       dependency_libs="$temp_xrpath $dependency_libs"
+      fi
+
+      # Only create the output if not a dry run.
+      if test -z "$run"; then
+       for installed in no yes; do
+         if test "$installed" = yes; then
+           if test -z "$install_libdir"; then
+             break
+           fi
+           output="$output_objdir/$outputname"i
+         fi
+         $rm $output
+         $echo > $output "\
+# $outputname - a libtool library file
+# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# The name that we can dlopen(3).
+dlname='$dlname'
+
+# Names of this library.
+library_names='$library_names'
+
+# The name of the static archive.
+old_library='$old_library'
+
+# Libraries that this one depends upon.
+dependency_libs='$dependency_libs'
+
+# Version information for $libname.
+current=$current
+age=$age
+revision=$revision
+
+# Is this an already installed library?
+installed=$installed
+
+# Directory that this library needs to be installed in:
+libdir='$install_libdir'\
+"
+       done
+      fi
+
+      # Do a symbolic link so that the libtool archive can be found in
+      # LD_LIBRARY_PATH before the program is installed.
+      $show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)"
+      $run eval "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)" || exit $?
+      ;;
+    esac
+    exit 0
+    ;;
+
+  # libtool install mode
+  install)
+    modename="$modename: install"
+
+    # There may be an optional sh(1) argument at the beginning of
+    # install_prog (especially on Windows NT).
+    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh; then
+      # Aesthetically quote it.
+      arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"`
+      case "$arg" in
+      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \    ]*|*]*)
+       arg="\"$arg\""
+       ;;
+      esac
+      install_prog="$arg "
+      arg="$1"
+      shift
+    else
+      install_prog=
+      arg="$nonopt"
+    fi
+
+    # The real first argument should be the name of the installation program.
+    # Aesthetically quote it.
+    arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
+    case "$arg" in
+    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \      ]*|*]*)
+      arg="\"$arg\""
+      ;;
+    esac
+    install_prog="$install_prog$arg"
+
+    # We need to accept at least all the BSD install flags.
+    dest=
+    files=
+    opts=
+    prev=
+    install_type=
+    isdir=no
+    stripme=
+    for arg
+    do
+      if test -n "$dest"; then
+       files="$files $dest"
+       dest="$arg"
+       continue
+      fi
+
+      case "$arg" in
+      -d) isdir=yes ;;
+      -f) prev="-f" ;;
+      -g) prev="-g" ;;
+      -m) prev="-m" ;;
+      -o) prev="-o" ;;
+      -s)
+       stripme=" -s"
+       continue
+       ;;
+      -*) ;;
+
+      *)
+       # If the previous option needed an argument, then skip it.
+       if test -n "$prev"; then
+         prev=
+       else
+         dest="$arg"
+         continue
+       fi
+       ;;
+      esac
+
+      # Aesthetically quote the argument.
+      arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
+      case "$arg" in
+      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \    ]*|*]*)
+       arg="\"$arg\""
+       ;;
+      esac
+      install_prog="$install_prog $arg"
+    done
+
+    if test -z "$install_prog"; then
+      $echo "$modename: you must specify an install program" 1>&2
+      $echo "$help" 1>&2
+      exit 1
+    fi
+
+    if test -n "$prev"; then
+      $echo "$modename: the \`$prev' option requires an argument" 1>&2
+      $echo "$help" 1>&2
+      exit 1
+    fi
+
+    if test -z "$files"; then
+      if test -z "$dest"; then
+       $echo "$modename: no file or destination specified" 1>&2
+      else
+       $echo "$modename: you must specify a destination" 1>&2
+      fi
+      $echo "$help" 1>&2
+      exit 1
+    fi
+
+    # Strip any trailing slash from the destination.
+    dest=`$echo "X$dest" | $Xsed -e 's%/$%%'`
+
+    # Check to see that the destination is a directory.
+    test -d "$dest" && isdir=yes
+    if test "$isdir" = yes; then
+      destdir="$dest"
+      destname=
+    else
+      destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'`
+      test "X$destdir" = "X$dest" && destdir=.
+      destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'`
+
+      # Not a directory, so check to see that there is only one file specified.
+      set dummy $files
+      if test $# -gt 2; then
+       $echo "$modename: \`$dest' is not a directory" 1>&2
+       $echo "$help" 1>&2
+       exit 1
+      fi
+    fi
+    case "$destdir" in
+    [\\/]* | [A-Za-z]:[\\/]*) ;;
+    *)
+      for file in $files; do
+       case "$file" in
+       *.lo) ;;
+       *)
+         $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2
+         $echo "$help" 1>&2
+         exit 1
+         ;;
+       esac
+      done
+      ;;
+    esac
+
+    # This variable tells wrapper scripts just to set variables rather
+    # than running their programs.
+    libtool_install_magic="$magic"
+
+    staticlibs=
+    future_libdirs=
+    current_libdirs=
+    for file in $files; do
+
+      # Do each installation.
+      case "$file" in
+      *.a | *.lib)
+       # Do the static libraries later.
+       staticlibs="$staticlibs $file"
+       ;;
+
+      *.la)
+       # Check to see that this really is a libtool archive.
+       if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
+       else
+         $echo "$modename: \`$file' is not a valid libtool archive" 1>&2
+         $echo "$help" 1>&2
+         exit 1
+       fi
+
+       library_names=
+       old_library=
+       # If there is no directory component, then add one.
+       case "$file" in
+       */* | *\\*) . $file ;;
+       *) . ./$file ;;
+       esac
+
+       # Add the libdir to current_libdirs if it is the destination.
+       if test "X$destdir" = "X$libdir"; then
+         case "$current_libdirs " in
+         *" $libdir "*) ;;
+         *) current_libdirs="$current_libdirs $libdir" ;;
+         esac
+       else
+         # Note the libdir as a future libdir.
+         case "$future_libdirs " in
+         *" $libdir "*) ;;
+         *) future_libdirs="$future_libdirs $libdir" ;;
+         esac
+       fi
+
+       dir="`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/"
+       test "X$dir" = "X$file/" && dir=
+       dir="$dir$objdir"
+
+       # See the names of the shared library.
+       set dummy $library_names
+       if test -n "$2"; then
+         realname="$2"
+         shift
+         shift
+
+         # Install the shared library and build the symlinks.
+         $show "$install_prog $dir/$realname $destdir/$realname"
+         $run eval "$install_prog $dir/$realname $destdir/$realname" || exit $?
+
+         if test $# -gt 0; then
+           # Delete the old symlinks, and create new ones.
+           for linkname
+           do
+             if test "$linkname" != "$realname"; then
+               $show "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)"
+               $run eval "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)"
+             fi
+           done
+         fi
+
+         # Do each command in the postinstall commands.
+         lib="$destdir/$realname"
+         eval cmds=\"$postinstall_cmds\"
+         IFS="${IFS=   }"; save_ifs="$IFS"; IFS='~'
+         for cmd in $cmds; do
+           IFS="$save_ifs"
+           $show "$cmd"
+           $run eval "$cmd" || exit $?
+         done
+         IFS="$save_ifs"
+       fi
+
+       # Install the pseudo-library for information purposes.
+       name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
+       instname="$dir/$name"i
+       $show "$install_prog $instname $destdir/$name"
+       $run eval "$install_prog $instname $destdir/$name" || exit $?
+
+       # Maybe install the static library, too.
+       test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
+       ;;
+
+      *.lo)
+       # Install (i.e. copy) a libtool object.
+
+       # Figure out destination file name, if it wasn't already specified.
+       if test -n "$destname"; then
+         destfile="$destdir/$destname"
+       else
+         destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
+         destfile="$destdir/$destfile"
+       fi
+
+       # Deduce the name of the destination old-style object file.
+       case "$destfile" in
+       *.lo)
+         staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"`
+         ;;
+       *.o | *.obj)
+         staticdest="$destfile"
+         destfile=
+         ;;
+       *)
+         $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2
+         $echo "$help" 1>&2
+         exit 1
+         ;;
+       esac
+
+       # Install the libtool object if requested.
+       if test -n "$destfile"; then
+         $show "$install_prog $file $destfile"
+         $run eval "$install_prog $file $destfile" || exit $?
+       fi
+
+       # Install the old object if enabled.
+       if test "$build_old_libs" = yes; then
+         # Deduce the name of the old-style object file.
+         staticobj=`$echo "X$file" | $Xsed -e "$lo2o"`
+
+         $show "$install_prog $staticobj $staticdest"
+         $run eval "$install_prog \$staticobj \$staticdest" || exit $?
+       fi
+       exit 0
+       ;;
+
+      *)
+       # Figure out destination file name, if it wasn't already specified.
+       if test -n "$destname"; then
+         destfile="$destdir/$destname"
+       else
+         destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
+         destfile="$destdir/$destfile"
+       fi
+
+       # Do a test to see if this is really a libtool program.
+       if (sed -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
+         link_against_libtool_libs=
+         relink_command=
+
+         # If there is no directory component, then add one.
+         case "$file" in
+         */* | *\\*) . $file ;;
+         *) . ./$file ;;
+         esac
+
+         # Check the variables that should have been set.
+         if test -z "$link_against_libtool_libs"; then
+           $echo "$modename: invalid libtool wrapper script \`$file'" 1>&2
+           exit 1
+         fi
+
+         finalize=yes
+         for lib in $link_against_libtool_libs; do
+           # Check to see that each library is installed.
+           libdir=
+           if test -f "$lib"; then
+             # If there is no directory component, then add one.
+             case "$lib" in
+             */* | *\\*) . $lib ;;
+             *) . ./$lib ;;
+             esac
+           fi
+           libfile="$libdir/`$echo "X$lib" | $Xsed -e 's%^.*/%%g'`"
+           if test -n "$libdir" && test ! -f "$libfile"; then
+             $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2
+             finalize=no
+           fi
+         done
+
+         outputname=
+         if test "$fast_install" = no && test -n "$relink_command"; then
+           if test "$finalize" = yes && test -z "$run"; then
+             tmpdir="/tmp"
+             test -n "$TMPDIR" && tmpdir="$TMPDIR"
+             tmpdir="$tmpdir/libtool-$$"
+             if $mkdir -p "$tmpdir" && chmod 700 "$tmpdir"; then :
+             else
+               $echo "$modename: error: cannot create temporary directory \`$tmpdir'" 1>&2
+               continue
+             fi
+             outputname="$tmpdir/$file"
+             # Replace the output file specification.
+             relink_command=`$echo "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'`
+
+             $show "$relink_command"
+             if $run eval "$relink_command"; then :
+             else
+               $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
+               ${rm}r "$tmpdir"
+               continue
+             fi
+             file="$outputname"
+           else
+             $echo "$modename: warning: cannot relink \`$file'" 1>&2
+           fi
+         else
+           # Install the binary that we compiled earlier.
+           file=`$echo "X$file" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"`
+         fi
+       fi
+
+       $show "$install_prog$stripme $file $destfile"
+       $run eval "$install_prog\$stripme \$file \$destfile" || exit $?
+       test -n "$outputname" && ${rm}r "$tmpdir"
+       ;;
+      esac
+    done
+
+    for file in $staticlibs; do
+      name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
+
+      # Set up the ranlib parameters.
+      oldlib="$destdir/$name"
+
+      $show "$install_prog $file $oldlib"
+      $run eval "$install_prog \$file \$oldlib" || exit $?
+
+      # Do each command in the postinstall commands.
+      eval cmds=\"$old_postinstall_cmds\"
+      IFS="${IFS=      }"; save_ifs="$IFS"; IFS='~'
+      for cmd in $cmds; do
+       IFS="$save_ifs"
+       $show "$cmd"
+       $run eval "$cmd" || exit $?
+      done
+      IFS="$save_ifs"
+    done
+
+    if test -n "$future_libdirs"; then
+      $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2
+    fi
+
+    if test -n "$current_libdirs"; then
+      # Maybe just do a dry run.
+      test -n "$run" && current_libdirs=" -n$current_libdirs"
+      exec $SHELL $0 --finish$current_libdirs
+      exit 1
+    fi
+
+    exit 0
+    ;;
+
+  # libtool finish mode
+  finish)
+    modename="$modename: finish"
+    libdirs="$nonopt"
+    admincmds=
+
+    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
+      for dir
+      do
+       libdirs="$libdirs $dir"
+      done
+
+      for libdir in $libdirs; do
+       if test -n "$finish_cmds"; then
+         # Do each command in the finish commands.
+         eval cmds=\"$finish_cmds\"
+         IFS="${IFS=   }"; save_ifs="$IFS"; IFS='~'
+         for cmd in $cmds; do
+           IFS="$save_ifs"
+           $show "$cmd"
+           $run eval "$cmd" || admincmds="$admincmds
+       $cmd"
+         done
+         IFS="$save_ifs"
+       fi
+       if test -n "$finish_eval"; then
+         # Do the single finish_eval.
+         eval cmds=\"$finish_eval\"
+         $run eval "$cmds" || admincmds="$admincmds
+       $cmds"
+       fi
+      done
+    fi
+
+    # Exit here if they wanted silent mode.
+    test "$show" = : && exit 0
+
+    echo "----------------------------------------------------------------------"
+    echo "Libraries have been installed in:"
+    for libdir in $libdirs; do
+      echo "   $libdir"
+    done
+    echo
+    echo "If you ever happen to want to link against installed libraries"
+    echo "in a given directory, LIBDIR, you must either use libtool, and"
+    echo "specify the full pathname of the library, or use \`-LLIBDIR'"
+    echo "flag during linking and do at least one of the following:"
+    if test -n "$shlibpath_var"; then
+      echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
+      echo "     during execution"
+    fi
+    if test -n "$runpath_var"; then
+      echo "   - add LIBDIR to the \`$runpath_var' environment variable"
+      echo "     during linking"
+    fi
+    if test -n "$hardcode_libdir_flag_spec"; then
+      libdir=LIBDIR
+      eval flag=\"$hardcode_libdir_flag_spec\"
+
+      echo "   - use the \`$flag' linker flag"
+    fi
+    if test -n "$admincmds"; then
+      echo "   - have your system administrator run these commands:$admincmds"
+    fi
+    if test -f /etc/ld.so.conf; then
+      echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
+    fi
+    echo
+    echo "See any operating system documentation about shared libraries for"
+    echo "more information, such as the ld(1) and ld.so(8) manual pages."
+    echo "----------------------------------------------------------------------"
+    exit 0
+    ;;
+
+  # libtool execute mode
+  execute)
+    modename="$modename: execute"
+
+    # The first argument is the command name.
+    cmd="$nonopt"
+    if test -z "$cmd"; then
+      $echo "$modename: you must specify a COMMAND" 1>&2
+      $echo "$help"
+      exit 1
+    fi
+
+    # Handle -dlopen flags immediately.
+    for file in $execute_dlfiles; do
+      if test ! -f "$file"; then
+       $echo "$modename: \`$file' is not a file" 1>&2
+       $echo "$help" 1>&2
+       exit 1
+      fi
+
+      dir=
+      case "$file" in
+      *.la)
+       # Check to see that this really is a libtool archive.
+       if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
+       else
+         $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
+         $echo "$help" 1>&2
+         exit 1
+       fi
+
+       # Read the libtool library.
+       dlname=
+       library_names=
+
+       # If there is no directory component, then add one.
+       case "$file" in
+       */* | *\\*) . $file ;;
+       *) . ./$file ;;
+       esac
+
+       # Skip this library if it cannot be dlopened.
+       if test -z "$dlname"; then
+         # Warn if it was a shared library.
+         test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'"
+         continue
+       fi
+
+       dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
+       test "X$dir" = "X$file" && dir=.
+
+       if test -f "$dir/$objdir/$dlname"; then
+         dir="$dir/$objdir"
+       else
+         $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2
+         exit 1
+       fi
+       ;;
+
+      *.lo)
+       # Just add the directory containing the .lo file.
+       dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
+       test "X$dir" = "X$file" && dir=.
+       ;;
+
+      *)
+       $echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2
+       continue
+       ;;
+      esac
+
+      # Get the absolute pathname.
+      absdir=`cd "$dir" && pwd`
+      test -n "$absdir" && dir="$absdir"
+
+      # Now add the directory to shlibpath_var.
+      if eval "test -z \"\$$shlibpath_var\""; then
+       eval "$shlibpath_var=\"\$dir\""
+      else
+       eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
+      fi
+    done
+
+    # This variable tells wrapper scripts just to set shlibpath_var
+    # rather than running their programs.
+    libtool_execute_magic="$magic"
+
+    # Check if any of the arguments is a wrapper script.
+    args=
+    for file
+    do
+      case "$file" in
+      -*) ;;
+      *)
+       # Do a test to see if this is really a libtool program.
+       if (sed -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
+         # If there is no directory component, then add one.
+         case "$file" in
+         */* | *\\*) . $file ;;
+         *) . ./$file ;;
+         esac
+
+         # Transform arg to wrapped name.
+         file="$progdir/$program"
+       fi
+       ;;
+      esac
+      # Quote arguments (to preserve shell metacharacters).
+      file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"`
+      args="$args \"$file\""
+    done
+
+    if test -z "$run"; then
+      if test -n "$shlibpath_var"; then
+        # Export the shlibpath_var.
+        eval "export $shlibpath_var"
+      fi
+
+      # Restore saved enviroment variables
+      if test "${save_LC_ALL+set}" = set; then
+       LC_ALL="$save_LC_ALL"; export LC_ALL
+      fi
+      if test "${save_LANG+set}" = set; then
+       LANG="$save_LANG"; export LANG
+      fi
+
+      # Now actually exec the command.
+      eval "exec \$cmd$args"
+
+      $echo "$modename: cannot exec \$cmd$args"
+      exit 1
+    else
+      # Display what would be done.
+      if test -n "$shlibpath_var"; then
+        eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\""
+        $echo "export $shlibpath_var"
+      fi
+      $echo "$cmd$args"
+      exit 0
+    fi
+    ;;
+
+  # libtool uninstall mode
+  uninstall)
+    modename="$modename: uninstall"
+    rm="$nonopt"
+    files=
+
+    for arg
+    do
+      case "$arg" in
+      -*) rm="$rm $arg" ;;
+      *) files="$files $arg" ;;
+      esac
+    done
+
+    if test -z "$rm"; then
+      $echo "$modename: you must specify an RM program" 1>&2
+      $echo "$help" 1>&2
+      exit 1
+    fi
+
+    for file in $files; do
+      dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
+      test "X$dir" = "X$file" && dir=.
+      name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
+
+      rmfiles="$file"
+
+      case "$name" in
+      *.la)
+       # Possibly a libtool archive, so verify it.
+       if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
+         . $dir/$name
+
+         # Delete the libtool libraries and symlinks.
+         for n in $library_names; do
+           rmfiles="$rmfiles $dir/$n"
+         done
+         test -n "$old_library" && rmfiles="$rmfiles $dir/$old_library"
+
+         $show "$rm $rmfiles"
+         $run $rm $rmfiles
+
+         if test -n "$library_names"; then
+           # Do each command in the postuninstall commands.
+           eval cmds=\"$postuninstall_cmds\"
+           IFS="${IFS=         }"; save_ifs="$IFS"; IFS='~'
+           for cmd in $cmds; do
+             IFS="$save_ifs"
+             $show "$cmd"
+             $run eval "$cmd"
+           done
+           IFS="$save_ifs"
+         fi
+
+         if test -n "$old_library"; then
+           # Do each command in the old_postuninstall commands.
+           eval cmds=\"$old_postuninstall_cmds\"
+           IFS="${IFS=         }"; save_ifs="$IFS"; IFS='~'
+           for cmd in $cmds; do
+             IFS="$save_ifs"
+             $show "$cmd"
+             $run eval "$cmd"
+           done
+           IFS="$save_ifs"
+         fi
+
+         # FIXME: should reinstall the best remaining shared library.
+       fi
+       ;;
+
+      *.lo)
+       if test "$build_old_libs" = yes; then
+         oldobj=`$echo "X$name" | $Xsed -e "$lo2o"`
+         rmfiles="$rmfiles $dir/$oldobj"
+       fi
+       $show "$rm $rmfiles"
+       $run $rm $rmfiles
+       ;;
+
+      *)
+       $show "$rm $rmfiles"
+       $run $rm $rmfiles
+       ;;
+      esac
+    done
+    exit 0
+    ;;
+
+  "")
+    $echo "$modename: you must specify a MODE" 1>&2
+    $echo "$generic_help" 1>&2
+    exit 1
+    ;;
+  esac
+
+  $echo "$modename: invalid operation mode \`$mode'" 1>&2
+  $echo "$generic_help" 1>&2
+  exit 1
+fi # test -z "$show_help"
+
+# We need to display help for each of the modes.
+case "$mode" in
+"") $echo \
+"Usage: $modename [OPTION]... [MODE-ARG]...
+
+Provide generalized library-building support services.
+
+    --config          show all configuration variables
+    --debug           enable verbose shell tracing
+-n, --dry-run         display commands without modifying any files
+    --features        display basic configuration information and exit
+    --finish          same as \`--mode=finish'
+    --help            display this help message and exit
+    --mode=MODE       use operation mode MODE [default=inferred from MODE-ARGS]
+    --quiet           same as \`--silent'
+    --silent          don't print informational messages
+    --version         print version information
+
+MODE must be one of the following:
+
+      compile         compile a source file into a libtool object
+      execute         automatically set library path, then run a program
+      finish          complete the installation of libtool libraries
+      install         install libraries or executables
+      link            create a library or an executable
+      uninstall       remove libraries from an installed directory
+
+MODE-ARGS vary depending on the MODE.  Try \`$modename --help --mode=MODE' for
+a more detailed description of MODE."
+  exit 0
+  ;;
+
+compile)
+  $echo \
+"Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
+
+Compile a source file into a libtool library object.
+
+This mode accepts the following additional options:
+
+  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
+  -static           always build a \`.o' file suitable for static linking
+
+COMPILE-COMMAND is a command to be used in creating a \`standard' object file
+from the given SOURCEFILE.
+
+The output file name is determined by removing the directory component from
+SOURCEFILE, then substituting the C source code suffix \`.c' with the
+library object suffix, \`.lo'."
+  ;;
+
+execute)
+  $echo \
+"Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]...
+
+Automatically set library path, then run a program.
+
+This mode accepts the following additional options:
+
+  -dlopen FILE      add the directory containing FILE to the library path
+
+This mode sets the library path environment variable according to \`-dlopen'
+flags.
+
+If any of the ARGS are libtool executable wrappers, then they are translated
+into their corresponding uninstalled binary, and any of their required library
+directories are added to the library path.
+
+Then, COMMAND is executed, with ARGS as arguments."
+  ;;
+
+finish)
+  $echo \
+"Usage: $modename [OPTION]... --mode=finish [LIBDIR]...
+
+Complete the installation of libtool libraries.
+
+Each LIBDIR is a directory that contains libtool libraries.
+
+The commands that this mode executes may require superuser privileges.  Use
+the \`--dry-run' option if you just want to see what would be executed."
+  ;;
+
+install)
+  $echo \
+"Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND...
+
+Install executables or libraries.
+
+INSTALL-COMMAND is the installation command.  The first component should be
+either the \`install' or \`cp' program.
+
+The rest of the components are interpreted as arguments to that command (only
+BSD-compatible install options are recognized)."
+  ;;
+
+link)
+  $echo \
+"Usage: $modename [OPTION]... --mode=link LINK-COMMAND...
+
+Link object files or libraries together to form another library, or to
+create an executable program.
+
+LINK-COMMAND is a command using the C compiler that you would use to create
+a program from several object files.
+
+The following components of LINK-COMMAND are treated specially:
+
+  -all-static       do not do any dynamic linking at all
+  -avoid-version    do not add a version suffix if possible
+  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
+  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
+  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
+  -export-symbols SYMFILE
+                   try to export only the symbols listed in SYMFILE
+  -export-symbols-regex REGEX
+                   try to export only the symbols matching REGEX
+  -LLIBDIR          search LIBDIR for required installed libraries
+  -lNAME            OUTPUT-FILE requires the installed library libNAME
+  -module           build a library that can dlopened
+  -no-undefined     declare that a library does not refer to external symbols
+  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
+  -release RELEASE  specify package release information
+  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
+  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
+  -static           do not do any dynamic linking of libtool libraries
+  -version-info CURRENT[:REVISION[:AGE]]
+                   specify library version info [each variable defaults to 0]
+
+All other options (arguments beginning with \`-') are ignored.
+
+Every other argument is treated as a filename.  Files ending in \`.la' are
+treated as uninstalled libtool libraries, other files are standard or library
+object files.
+
+If the OUTPUT-FILE ends in \`.la', then a libtool library is created,
+only library objects (\`.lo' files) may be specified, and \`-rpath' is
+required, except when creating a convenience library.
+
+If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
+using \`ar' and \`ranlib', or on Windows using \`lib'.
+
+If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
+is created, otherwise an executable program is created."
+  ;;
+
+uninstall)
+  $echo \
+"Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
+
+Remove libraries from an installation directory.
+
+RM is the name of the program to use to delete files associated with each FILE
+(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
+to RM.
+
+If FILE is a libtool library, all the files associated with it are deleted.
+Otherwise, only FILE itself is deleted using RM."
+  ;;
+
+*)
+  $echo "$modename: invalid operation mode \`$mode'" 1>&2
+  $echo "$help" 1>&2
+  exit 1
+  ;;
+esac
+
+echo
+$echo "Try \`$modename --help' for more information about other modes."
+
+exit 0
+
+# Local Variables:
+# mode:shell-script
+# sh-indentation:2
+# End:
diff --git a/contrib/idn/idnkit-1.0-src/make.wnt b/contrib/idn/idnkit-1.0-src/make.wnt
new file mode 100644 (file)
index 0000000..2b39acf
--- /dev/null
@@ -0,0 +1,76 @@
+# $Id: make.wnt,v 1.1 2003/06/04 00:25:03 marka Exp $
+# 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.
+
+all : force
+       copy include\config.h.win include\config.h
+       cd lib
+       $(MAKE) -f make.wnt
+       cd ..
+       cd tools
+       $(MAKE) -f make.wnt
+       cd ..
+       cd wsock
+       $(MAKE) -f make.wnt
+       cd ..
+
+install : all
+       cd lib
+       $(MAKE) -f make.wnt install
+       cd ..
+       cd tools
+       $(MAKE) -f make.wnt install
+       cd ..
+       cd wsock
+       $(MAKE) -f make.wnt install
+       cd ..
+
+clean : force
+       cd lib
+       $(MAKE) -f make.wnt clean
+       cd ..
+       cd tools
+       $(MAKE) -f make.wnt clean
+       cd ..
+       cd wsock
+       $(MAKE) -f make.wnt clean
+       cd ..
+
+force:
diff --git a/contrib/idn/idnkit-1.0-src/man/Makefile.in b/contrib/idn/idnkit-1.0-src/man/Makefile.in
new file mode 100644 (file)
index 0000000..405418e
--- /dev/null
@@ -0,0 +1,116 @@
+# $Id: Makefile.in,v 1.1 2003/06/04 00:27:14 marka Exp $
+#
+# 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.
+
+top_builddir = ..
+
+srcdir  = @srcdir@
+VPATH   = @srcdir@
+
+prefix  = @prefix@
+exec_prefix = @exec_prefix@
+
+sysconfdir  = @sysconfdir@
+mandir = @mandir@
+man3dir = $(mandir)/man3
+man5dir = $(mandir)/man5
+
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_DATA = @INSTALL_DATA@
+MKINSTALLDIRS = @top_srcdir@/mkinstalldirs
+SHELL = @SHELL@
+
+@LITEONLY_TRUE@all: libidnkitlite.3 idn.conf.5 idnrc.5 idnalias.conf.5
+@LITEONLY_FALSE@all: libidnkitlite.3 idn.conf.5 idnrc.5  idnalias.conf.5 libidnkit.3
+
+libidnkit.3: libidnkit.3.in
+       sed 's%[@]sysconfdir[@]%$(sysconfdir)%' < $(srcdir)/libidnkit.3.in > $@
+libidnkitlite.3: libidnkit.3.in
+       sed 's%[@]sysconfdir[@]%$(sysconfdir)%' < $(srcdir)/libidnkit.3.in > $@
+idn.conf.5: idn.conf.5.in
+       sed 's%[@]sysconfdir[@]%$(sysconfdir)%' < $(srcdir)/idn.conf.5.in > $@
+idnrc.5: idn.conf.5.in
+       sed 's%[@]sysconfdir[@]%$(sysconfdir)%' < $(srcdir)/idn.conf.5.in > $@
+idnalias.conf.5:  idn.conf.5.in
+       sed 's%[@]sysconfdir[@]%$(sysconfdir)%' < $(srcdir)/idn.conf.5.in > $@
+
+@LITEONLY_TRUE@@COMPAT_TRUE@install: all install-common install-compat-common
+@LITEONLY_FALSE@@COMPAT_TRUE@install: all install-common install-nolite install-compat-common install-compat-nolite
+@LITEONLY_TRUE@@COMPAT_FALSE@install: all install-common
+@LITEONLY_FALSE@@COMPAT_FALSE@install: all install-common install-nolite
+
+install-common:
+       $(MKINSTALLDIRS) $(DESTDIR)$(man3dir)
+       $(INSTALL_DATA) libidnkitlite.3 $(DESTDIR)$(man3dir)/libidnkitlite.3
+       $(MKINSTALLDIRS) $(DESTDIR)$(man5dir)
+       $(INSTALL_DATA) idn.conf.5 $(DESTDIR)$(man5dir)/idn.conf.5
+       $(INSTALL_DATA) idnrc.5 $(DESTDIR)$(man5dir)/idnrc.5
+       $(INSTALL_DATA) idnalias.conf.5 $(DESTDIR)$(man5dir)/idnalias.conf.5
+
+install-nolite:
+       $(MKINSTALLDIRS) $(DESTDIR)$(man3dir)
+       $(INSTALL_DATA) libidnkit.3 $(DESTDIR)$(man3dir)/libidnkit.3
+
+install-compat-common:
+       src=$(DESTDIR)$(man3dir)/libidnkitlite.3; \
+       dst=$(DESTDIR)$(man3dir)/libmdnlite.3; \
+       rm -f $$dst; \
+       ln $$src $$dst || cp $$src $$dst
+       src=$(DESTDIR)$(man5dir)/idn.conf.5; \
+       dst=$(DESTDIR)$(man5dir)/mdn.conf.5; \
+       rm -f $$dst; \
+       ln $$src $$dst || cp $$src $$dst
+
+install-compat-nolite:
+       src=$(DESTDIR)$(man3dir)/libidnkit.3; \
+       dst=$(DESTDIR)$(man3dir)/libmdn.3; \
+       rm -f $$dst; \
+       ln $$src $$dst || cp $$src $$dst
+
+clean:
+       rm -f idn.conf.5 idnrc.5 idnalias.conf.5 libidnkit.3 libidnkitlite.3
+       rm -f *~
+
+distclean: clean
+       rm -f Makefile
+
+test check:
diff --git a/contrib/idn/idnkit-1.0-src/man/idn.conf.5.in b/contrib/idn/idnkit-1.0-src/man/idn.conf.5.in
new file mode 100644 (file)
index 0000000..700ced9
--- /dev/null
@@ -0,0 +1,312 @@
+.\" $Id: idn.conf.5.in,v 1.1 2003/06/04 00:27: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.
+.\"
+.TH idn.conf 5 "Mar 8, 2002"
+.\"
+.SH NAME
+idn.conf, .idnrc, idnalias.conf \- configuration files for idnkit library
+.\"
+.SH SYNOPSIS
+@sysconfdir@/idn.conf
+.br
+~/.idnrc
+.br
+@sysconfdir@/idnalias.conf
+.\"
+.SH DESCRIPTION
+\fBidn.conf\fR and \fB.idnrc\fR are configuration files for idnkit
+library which is a toolkit for handling internationalized domain names.
+.PP
+idnkit library tries to load the user's configuration file ~/.idnrc
+first, and then tries the system configutation file 
+@sysconfdir@/idn.conf.
+Note that idnkit library loads either, not both.
+.PP
+To use internationalized domain names in DNS or other protocols, they
+must be converted to an appropriate format before further processing.
+In idnkit, this conversion process is comprised of the following tasks.
+.IP 1. 3
+Convert the given domain name in application's local codeset to Unicode,
+and vice versa.
+.IP 2. 3
+Map certain characters in the name to period character so that they are
+treated as the domain name
+delimiter (\fIdelimiter mapping\fR).
+.IP 3. 3
+Map certain characters in the name to other characters or chracter sequences,
+according to a mapping rule determined by its top level domain (TLD).
+.IP 4. 3
+Perform NAMEPREP, which is a starndard name preparation process for
+internationalized domain names.  This process is composed of
+the tree steps called mapping, normalization, prohibited character
+checking and bidirectional string checking.
+.IP 5. 3
+Convert the nameprepped name to IDN encoding, which is the standard encoding
+for internationalized domain names (also known as ASCII-compatible encoding,
+ACE), and vice versa.
+.PP
+The configuration file specifies the parameters for these tasks, such as:
+.RS 2
+.IP \- 2
+the encoding of internationalized domain names (IDN encoding).
+.IP \- 2
+NAMEPREP schemes.
+.RE
+.\"
+.SH SYNTAX
+The configuration file is a simple text files, and each line in the file
+(other than comment lines, which begin with ``#'', and empty lines)
+forms an entry of the following format:
+.PP
+.RS 4
+.nf
+\fIkeyword\fP\ \fIvalue..\fP
+.fi
+.RE
+\."
+.SH "IDN-ENCODING ENTRY"
+IDN encoding entry specifies the encoding name (codeset name) which
+is used as the encoding of internationalized domain names.
+.PP
+The syntax of this entry is:
+.PP
+.RS 4
+.nf
+\f(CWidn-encoding \fP\fIencoding\fP
+.fi
+.RE
+.PP
+\fIencoding\fP is the encoding name to be used, and any of the following
+names can be specified.
+.RS 2
+.IP "\(bu" 2
+``Punycode''
+.IP "\(bu" 2
+``UTF-8''
+.IP "\(bu" 2
+Codeset names which iconv_open() library function accepts.  Please
+consult iconv() documentation for the available codesets.
+.IP "\(bu" 2
+Any alias names for the above, defined by the alias file.
+(See section ``ENCODING-ALIAS-FILE'')
+.RE
+.PP
+The standard encoding was determined as Punycode.
+.\"
+.SH "NAMEPREP ENTRY"
+Nameprep entry specifies the version of NAMEPREP, which is a specification
+of ``canonicalization'' process of internationalized domain name before
+it is converted to the IDN encoding.
+.PP
+The syntax of this entry is:
+.PP
+.RS 4
+.nf
+\f(CWnameprep \fP\fIversion\fP
+.fi
+.RE
+.PP
+\fIversion\fR is the version name of NAMEPREP specification, and currently
+the following versions can be specified.
+.RS 2
+.IP "\(bu" 2
+``RFC3491''
+.br
+This version refers to RFC3491 ``rfc-3491.txt''.
+.RE
+.PP
+The NAMEPREP process consists of the following 4 subprocesses.
+.IP 1. 3
+mapping, which maps certain characters in a name to other characters,
+possibly none.
+.IP 2. 3
+normalization, which replaces character variants in a name to
+a unique one.
+.IP 3. 3
+prohibited character checking, which detects invalid characters in a name.
+.IP 4. 3
+unassigned codepoint checking, which also invalid codepoints in a name.
+.IP 5. 3
+bidirectional string checking, which detecs invalid string.
+.\"
+.SH "LOCAL-MAP ENTRY"
+This entry specifies localized mapping phase before NAMEPREP takes place.
+Different mapping rules can be specified for each TLD (top-level domain).
+For example, you can have one mapping for ``.tw'' domain, and another for
+``.jp'' domain.
+.PP
+The syntax of this entry is:
+.PP
+.RS 4
+.nf
+\f(CWlocal-map \fItld\f(CW \fIscheme\fR [\fIscheme\fR..]
+.fi
+.RE
+.PP
+\fItld\fR specifies the TLD to which the mapping rule is to be applied,
+and \fIscheme\fR specifies the mapping scheme, and currently available
+schemes are:
+.RS 2
+.TP 4
+\f(CWRFC3491\fP
+Specify mapping defined by RFC3491.
+.TP 4
+\f(CWfilemap:\fP\fIpathname\fP
+Specify mapping defined by the file \fIpathname\fP.
+See ``MAPFILE FORMAT'' for the format of this file.
+.RE
+.PP
+There are two special \fItld\fRs for specifying the mapping rule for
+local domain names (domain names without any dots in them), and the
+default mapping rule.
+If
+\fItld\fR is ``-'', it matches domain names which do not contain any
+dots.
+If \fItld\fR is ``.'', it matches any domain names which don't match
+to any other mapping rules specified by ``local-map'' entries.
+.\"
+.SH "MAPFILE FORMAT"
+A mapfile defines a set of character mapping rules.  It can define
+unconditional one-character to N-character-sequence (N can be 0, 1 or more)
+mappings.
+.PP
+A mapfile is a simple text file, and each line specifies a single mapping.
+Each line is of the form:
+.PP
+.RS 4
+.nf
+\fIsrc-codepoint\fR\f(CW; \fImapped-codepoint-seq\fR\f(CW;\fR
+.fi
+.RE
+.PP
+\fIsrc-codepoint\fR indicates source character of the mapping, and must
+be a Unicode codepoint value in hexadecimal string.
+\fImapped-codepoint-seq\fR is a sequence of characters which is the
+outcome of the mapping, and must be a (possibly empty) list of Unicode
+codepoint values in hexadecimal string, separated by spaces.
+.PP
+Lines which begin with ``#'' are treated as comments and ignored.
+.PP
+A sample mapfile is shown below.
+.PP
+.RS 4
+.nf
+.ft CW
+# map "A" to "a"
+0041; 0061;
+# map "#" to nothing
+0023; ;
+# map "@" to "at"
+0040; 0061 0074;
+.ft R
+.fi
+.RE
+.\"
+.SH "LOCAL CODESET"
+\fBidn.conf\fR or \fB~/.idnrc\fR doesn't have an entry to specify the
+local codeset, since it is determined from the application's current
+locale information.
+So each application can use different local codeset.
+.PP
+Although idnkit tries hard to find out the local codeset, sometimes it
+fails.  For example, there are applications which use non-ASCII codeset
+but work in C locale.  In this case, you can specify the application's
+local codeset by an environment variable ``\fBIDN_LOCAL_CODESET\fR''.
+Just set the codeset name (or its alias name) to the variable, and
+idnkit will use the codeset as the local one, regardless of the locale
+setting.
+.\"
+.SH "ENCODING-ALIAS-FILE"
+Encoding alias file specifies codeset name aliases.  It is located on
+@sysconfdir@/idnalias.conf and always loaded automatically as idn.conf
+and .idnrc.  The aliases in this file can be used just as the real names.
+.PP
+The alias file is a simple text file, consisting of lines of the form:
+.PP
+.RS 4
+.nf
+\fIalias-name\fP\ \fIname\fP
+.fi
+.RE
+.PP
+\fIalias-name\fR is the alias name to be defined, and \fIname\fR is
+the real name or another alias name.
+.\"
+.SH "SAMPLE CONFIGURATION"
+The following shows a sample configuration file.
+.PP
+.RS 4
+.ft CW
+.nf
+#
+# a sample configuration.
+#
+
+# Use Punycode as the IDN encoding.
+idn-encoding Punycode
+
+# Use RFC3491 as NAMEPREP.
+nameprep RFC3491
+
+# Perform Japanese-specific mapping for .jp domain.
+# assuming /usr/local/lib/idnkit/jp-map contains the mapping.
+local-map .jp filemap:/usr/local/lib/idnkit/jp-map
+.fi
+.ft R
+.RE
+.\"
+.SH FILES
+.I @sysconfdir@/idn.conf
+.br
+.I ~/.idnrc
+.br
+.I @sysconfdir@/idnalias.conf
+.br
+.I @sysconfdir@/idn.conf.sample
+\- sample configuration with comments
+.br
+.I @sysconfdir@/idnalias.conf.sample
+\- sample alias file
+.\"
+.SH "SEE ALSO"
+iconv(3)
diff --git a/contrib/idn/idnkit-1.0-src/man/libidnkit.3.in b/contrib/idn/idnkit-1.0-src/man/libidnkit.3.in
new file mode 100644 (file)
index 0000000..66d756f
--- /dev/null
@@ -0,0 +1,480 @@
+.\" $Id: libidnkit.3.in,v 1.1 2003/06/04 00:27:15 marka Exp $
+.\"
+.\" 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.
+.\"
+.TH libidnkit 3 "Mar 11, 2002"
+.\"
+.SH NAME
+libidnkit, libidnkitlite \- Internationalized Domain Name Handling Libraries
+.\"
+.SH SYNOPSIS
+.nf
+#include <idn/api.h>
+
+idn_result_t
+\fBidn_nameinit\fP(int\ load_file)
+
+idn_result_t
+\fBidn_encodename\fP(int\ actions,\ const\ char\ *from,\ char\ *to,\ size_t\ tolen)
+
+idn_result_t
+\fBidn_decodename\fP(int\ actions,\ const\ char\ *from,\ char\ *to,\ size_t\ tolen)
+
+idn_result_t
+\fBidn_decodename2\fP(int\ actions,\ const\ char\ *from,\ char\ *to,\ size_t\ tolen,
+    const\ char\ *auxencoding)
+
+idn_result_t
+\fBidn_enable\fP(int\ on_off)
+
+#include <idn/result.h>
+
+char *
+\fBidn_result_tostring\fP(idn_result_t\ result)
+
+.\"
+.SH OVERVIEW
+The
+\fBlibidnkit\fR and \fBlibidnkitlite\fR libraries support various
+manipulations of internationalized domain names, including:
+.RS 2
+.IP \- 2
+encoding convesion
+.IP \- 2
+name preparation
+.RE
+.PP
+They are designed according to IDNA framework where each application must
+do necessary preparations for the internationalized domain names before
+passing them to the resolver.
+.PP
+To help applications do the preparation, the libraries provide easy-to-use,
+high-level interface for the work.
+.PP
+Both libraries provide almost the same API.
+The difference between them is that \fBlibidnkit\fR internally uses
+\fIiconv\fR function to provide encoding conversion from UTF-8 to the
+local encoding
+(such as iso-8859-1, usually determined by the current locale), and vise
+versa.
+\fBlibidnkitlite\fR is lightweight version of libidnkit.
+It assumes local encoding is UTF-8 so that it never uses \fIiconv\fR.
+.PP
+This manual describes only a small subset of the API that the libraries
+provide, most important functions for application programmers.
+For other API, please refer to the idnkit's specification document
+(which is not yet available) or the header files typically found under
+`/usr/local/include/idn/' on your system.
+.\"
+.SH DESCRIPTION
+.PP
+The \fBidn_nameinit\fR function initializes the library.
+It also sets default configuration if \fIload_file\fR is 0, otherwise
+it tries to read a configuration file.
+If \fBidn_nameinit\fR is called more than once, the library initialization
+will take place only at the first call while the actual configuration
+procedure will occur at every call.
+.PP
+If there are no errors, \fBidn_nameinit\fR returns \fBidn_success\fR.
+Otherwise, the returned value indicates the cause of the error.
+See the section ``RETURN VALUES'' below for the error codes.
+.PP
+Usually you don't have to call this function explicitly because
+it is implicitly called when \fBidn_encodename\fR or \fBidn_decodename\fR
+is first called without prior calling of \fBidn_nameinit\fR.
+In such case, initialization without the configuration file
+takes place.
+.\"
+.PP
+\fBidn_encodename\fR function performs name preparation and encoding
+conversion on the internationalized domain name specified by \fIfrom\fR,
+and stores the result to \fIto\fR, whose length is specified by
+\fItolen\fR.
+\fIactions\fR is a bitwise-OR of the following macros, specifying which
+subprocesses in the encoding process are to be employed.
+.RS 2
+.nf
+.ft CW
+IDN_LOCALCONV     Local encoding to UTF-8 conversion
+IDN_DELIMMAP      Delimiter mapping
+IDN_LOCALMAP      Local mapping
+IDN_NAMEPREP      NAMEPREP mapping, normalization,
+                  prohibited character check and bidirectional
+                  string check
+IDN_UNASCHECK     NAMEPREP unassigned codepoint check
+IDN_ASCCHECK      ASCII range character check
+IDN_IDNCONV       UTF-8 to IDN encoding conversion
+IDN_LENCHECK      Label length check
+.ft R
+.fi
+.RE
+.PP
+Details of this encoding process can be found in the section ``NAME ENCODING''.
+.PP
+For convenience, also \fBIDN_ENCODE_QUERY\fR, \fBIDN_ENCODE_APP\fR
+and \fBIDN_ENCODE_STORED\fR macros are provided.
+\fBIDN_ENCODE_QUERY\fR is used to encode a ``query string''
+(see the IDNA specification).
+It is equal to
+.RS 4
+.nf
+.ft CW
+(IDN_LOCALCONV | IDN_DELIMMAP | IDN_LOCALMAP | IDN_NAMEPREP
+ | IDN_IDNCONV | IDN_LENCHECK)
+.ft R
+.fi
+.RE
+.PP
+if you are using \fBlibidnkit\fR, and equal to 
+.RS 4
+.nf
+.ft CW
+(IDN_DELIMMAP | IDN_LOCALMAP | IDN_NAMEPREP | IDN_IDNCONV
+ | IDN_LENCHECK)
+.ft R
+.fi
+.RE
+.PP
+if you are using \fBlibidnkitlite\fR.
+.PP
+\fBIDN_ENCODE_APP\fR is used for ordinary application to encode a
+domain name.
+It performs \fBIDN_ASCCHECK\fR in addition with \fBIDN_ENCODE_QUERY\fR.
+\fBIDN_ENCODE_STORED\fR is used to encode a ``stored string''
+(see the IDNA specification).
+It performs \fBIDN_ENCODE_APP\fR plus \fBIDN_UNASCHECK\fR.
+.PP
+\fBidn_decodename\fR function performs the reverse of \fBidn_encodename\fR.
+It converts the internationalized domain name given by \fIfrom\fR,
+which is represented in a special encoding called ACE,
+to the application's local codeset and stores into \fIto\fR,
+whose length is specified by \fItolen\fR.
+As in \fBidn_encodename\fR, \fIactions\fR is a bitwise-OR of the following
+macros.
+.RS 2
+.nf
+.ft CW
+IDN_DELIMMAP      Delimiter mapping
+IDN_NAMEPREP      NAMEPREP mapping, normalization,
+                  prohibited character check and bidirectional
+                  string check
+IDN_UNASCHECK     NAMEPREP unassigned codepoint check
+IDN_IDNCONV       UTF-8 to IDN encoding conversion
+IDN_RTCHECK       Round trip check
+IDN_ASCCHECK      ASCII range character check
+IDN_LOCALCONV     Local encoding to UTF-8 conversion
+.ft R
+.fi
+.RE
+.PP
+Details of this decoding process can be found in the section ``NAME DECODING''.
+.PP
+For convenience, also \fBIDN_DECODE_QUERY\fR, \fBIDN_DECODE_APP\fR
+and \fBIDN_DECODE_STORED\fR macros are provided.
+\fBIDN_DECODE_QUERY\fR is used to decode a ``qeury string''
+(see the IDNA specification).
+It is equal to
+.RS 4
+.nf
+.ft CW
+(IDN_DELIMMAP | IDN_NAMEPREP | IDN_IDNCONV | IDN_RTCHECK
+ | IDN_LOCALCONV)
+.ft R
+.fi
+.RE
+.PP
+if you are using \fBlibidnkit\fR, and equal to 
+.RS 4
+.nf
+.ft CW
+(IDN_DELIMMAP | IDN_NAMEPREP | IDN_IDNCONV | IDN_RTCHECK)
+.ft R
+.fi
+.RE
+.PP
+if you are using \fBlibidnkitlite\fR.
+.PP
+\fBIDN_DECODE_APP\fR is used for ordinary application to decode a
+domain name.
+It performs \fBIDN_ASCCHECK\fR in addition with \fBIDN_DECODE_QUERY\fR.
+\fBIDN_DECODE_STORED\fR is used to decode a ``stored string''
+(see the IDNA specification).
+It performs \fBIDN_DECODE_APP\fR plus \fBIDN_UNASCHECK\fR.
+.PP
+\fBidn_decodename2\fR function provides the same functionality as
+\fBidn_decodename\fR except that character encoding of \fIfrom\fR is
+supposed to be \fIauxencoding\fR.
+If IDN encoding is Punycode and \fIauxencoding\fR is ISO 8859-2
+for example, it is assumed that the Punycode string stored in
+\fIfrom\fR is written in ISO 8859-2.
+.PP
+In the IDN decode procedure, \fBIDN_NAMEPREP\fR is done before
+\fBIDN_IDNCONV\fR, and some non-ASCII characters are converted to
+ASCII characters as the result of \fBIDN_NAMEPREP\fR.
+Therefore, ACE string given by \fBfrom\fR may contains those non-ASCII
+characters.
+That is the reason \fBdocode_name2\fR exists.
+.PP
+All of the functions above return error code of type \fBidn_result_t\fR.
+All codes other than \fBidn_success\fR indicates some kind of failure.
+\fBidn_result_tostring\fR function takes an error code \fIresult\fR
+and returns a pointer to the corresponding message string.
+.\"
+.SH "NAME ENCODING"
+Name encoding is a process that transforms the specified
+internationalized domain name to a certain string suitable for name
+resolution.
+For each label in a given domain name, the encoding processor performs:
+.\"
+.IP "(1) Convert to UTF-8 (IDN_LOCALCONV)"
+Convert the encoding of the given domain name from application's local
+encoding (e.g. ISO-8859-1) to UTF-8.
+Note that \fBlibidnkitlite\fR doesn't support this step.
+.\"
+.IP "(2) Delimiter mapping (IDN_DELIMMAP)"
+Map domain name delimiters to `.' (U+002E).
+The recoginzed delimiters are: U+3002 (ideographic full stop),
+U+FF0E (fullwidth full stop), U+FF61 (halfwidth ideographic full stop).
+.\"
+.IP "(3) Local mapping (IDN_LOCALMAP)"
+Apply character mapping whose rule is determined by the TLD of the name.
+.\"
+.IP "(4) NAMEPREP (IDN_NAMEPREP, IDN_UNASCHECK)"
+Perform name preparation (NAMEPREP), which is a standard process for
+name canonicalizaion of internationalized domain names.
+.br
+NAMEPREP consists of 5 steps:
+mapping, normalization, prohibited character check, bidirectional
+text check and unassigned codepoint check.
+The first four steps are done by IDN_NAMEPREP, and the last step is
+done by IDN_UNASCHECK.
+.\"
+.IP "(5) ASCII range character check (IDN_ASCCHECK)"
+Checks if the domain name contains non-LDH ASCII character (not
+alpha-numeric or hyphen), or it begins or end with hyphen.
+.\"
+.IP "(6) Convert to ACE (IDN_IDNCONV)"
+Convert the NAMEPREPed name to a special encoding designed for representing
+internationalized domain names.
+.br
+The encoding is also known as ACE (ASCII Compatible Encoding) since
+a string in the encoding is just like a traditional ASCII domain name
+consisting of only letters, numbers and hyphens.
+.\"
+.IP "(7) Label length check (IDN_LENCHECK)"
+For each label, check the number of characters in it.
+It must be in the range 1 to 63.
+.PP
+There are many configuration parameters for this process, such as the
+ACE or the local mapping rules.  These parameters are read from the
+default idnkit's configuration file, \fBidn.conf\fR.
+See idn.conf(5) for details.
+.\"
+.SH "NAME DECODING"
+Name decoding is a reverse process of the name encoding.
+It transforms the specified
+internationalized domain name in a special encoding suitable for name
+resolution to the normal name string in the application's current codeset.
+However, name encoding and name decoding are not symmetric.
+.PP
+For each label in a given domain name, the decoding processor performs:
+.\"
+.IP "(1) Delimiter mapping (IDN_DELIMMAP)"
+Map domain name delimiters to `.' (U+002E).
+The recoginzed delimiters are: U+3002 (ideographic full stop),
+U+FF0E (fullwidth full stop), U+FF61 (halfwidth ideographic full stop).
+.\"
+.IP "(2) NAMEPREP (IDN_NAMEPREP, IDN_UNASCHECK)"
+Perform name preparation (NAMEPREP), which is a standard process for
+name canonicalizaion of internationalized domain names.
+.\"
+.IP "(3) Convert to UTF-8 (IDN_IDNCONV)"
+Convert the encoding of the given domain name from ACE to UTF-8.
+.\"
+.IP "(4) Round trip check (IDN_RTCHECK)"
+Encode the result of (3) using the ``NAME ENCODING'' scheme, and then
+compare it with the result of the step (2).
+If they are different, the check is failed.
+If IDN_UNASCHECK, IDN_ASCCHECK or both are specified, also they are
+done in the encoding processes.
+.\"
+.IP "(5) Convert to local encoding"
+Convert the result of (3) from UTF-8 to the application's local
+encoding (e.g. ISO-8859-1).
+Note that \fBlibidnkitlite\fR doesn't support this step.
+.PP
+If prohibited character check, unassigned codepoint check or 
+bidirectional text check at step (2) is failed, or round trip check
+at step (4) is failed, the original input label is returned.
+.PP
+The configuration parameters for this process,
+are also read from the configuration file \fBidn.conf\fR.
+.\"
+.SH "IDN_DISABLE"
+If the \fBIDN_DISABLE\fR environ variable is defined at run-time,
+the libraries disable internationalized domain name support, by default.
+In this case, \fBidn_encodename\fR and \fBidn_decodename\fR don't
+encode/decode an input name, but instead they simply ouput a copy
+of the input name as the result of encoding/decoding.
+.PP
+If your application should always enable mulitilingual domain name
+support regardless of definition of \fBIDN_DISABLE\fR, call
+.RS 4
+.nf
+.ft CW
+idn_enable(1)
+.ft R
+.fi
+.RE
+.PP
+before performing encoding/decoding. 
+.\"
+.SH "RETURN VALUES"
+Most of the API functions return values of type \fBidn_result_t\fR in
+order to indicate the status of the call.
+
+The following is a complete list of the status codes.  Note that some
+of them are never returned by the functions described in this manual.
+.TP 15
+.SB idn_success
+Not an error.  The call succeeded.
+.TP
+.SB idn_notfound
+Specified information does not exist.
+.TP
+.SB idn_invalid_encoding
+The encoding of the specified string is invalid.
+.TP
+.SB idn_invalid_syntax
+There is a syntax error in the configuration file.
+.TP
+.SB idn_invalid_name
+The specified name is not valid.
+.TP
+.SB idn_invalid_message
+The specified DNS message is not valid.
+.TP
+.SB idn_invalid_action
+The specified action contains invalid flags.
+.TP
+.SB idn_invalid_codepoint
+The specified Unicode code point value is not valid.
+.TP
+.SB idn_invalid_length
+The number of characters in an ACE label is not in the range 1 to 63.
+.TP
+.SB idn_buffer_overflow
+The specified buffer is too small to hold the result.
+.TP
+.SB idn_noentry
+The specified key does not exist in the hash table.
+.TP
+.SB idn_nomemory
+Memory allocation using malloc failed.
+.TP
+.SB idn_nofile
+The specified file could not be opened.
+.TP
+.SB idn_nomapping
+Some characters do not have the mapping to the target character set.
+.TP
+.SB idn_context_required
+Context information is required.
+.TP
+.SB idn_prohibited
+The specified string contains some prohibited characters.
+.TP
+.SB idn_failure
+Generic error which is not covered by the above codes.
+.\"
+.SH EXAMPLES
+To get the address of a internationalized domain name in the application's
+local codeset, use \fBidn_encodename\fR to convert the name to the format
+suitable for passing to resolver functions.
+.RS 4
+.nf
+.ft CW
+idn_result_t r;
+char ace_name[256];
+struct hostent *hp;
+
+\&...
+r = idn_encodename(IDN_ENCODE_APP, name, ace_name,
+                   sizeof(ace_name));
+if (r != idn_success) {
+    fprintf(stderr, "idn_encodename failed: %s\en",
+            idn_result_tostring(r));
+    exit(1);
+}
+
+hp = gethostbyname(ace_name);
+\&...
+.ft R
+.fi
+.RE
+.PP
+To decode the internationalized domain name returned from a resolver function,
+use \fBidn_decodename\fR.
+.RS 4
+.nf
+.ft CW
+idn_result_t r;
+char local_name[256];
+struct hostent *hp;
+
+\&...
+hp = gethostbyname(name);
+r = idn_decodename(IDN_DECODE_APP, hp->h_name, local_name,
+                   sizeof(local_name));
+if (r != idn_success) {
+    fprintf(stderr, "idn_decodename failed: %s\en",
+            idn_result_tostring(r));
+    exit(1);
+}
+printf("name: %s\en", local_name);
+\&...
+.ft R
+.fi
+.RE
+.\"
+.SH "SEE ALSO"
+idn.conf(5)
diff --git a/contrib/idn/idnkit-1.0-src/map/Makefile.in b/contrib/idn/idnkit-1.0-src/map/Makefile.in
new file mode 100644 (file)
index 0000000..b986a6a
--- /dev/null
@@ -0,0 +1,75 @@
+# $Id: Makefile.in,v 1.1 2003/06/04 00:27:55 marka Exp $
+#
+# 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.
+
+top_builddir = ..
+
+srcdir  = @srcdir@
+VPATH   = @srcdir@
+
+prefix  = @prefix@
+exec_prefix = @exec_prefix@
+
+datadir = @datadir@
+mapdir = $(datadir)/idnkit
+
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+MKINSTALLDIRS = @top_srcdir@/mkinstalldirs
+SHELL = @SHELL@
+
+MAPS = jp.map
+
+all:
+
+install:
+       $(MKINSTALLDIRS) $(DESTDIR)$(mapdir)
+       for map in $(MAPS); do \
+           $(INSTALL_DATA) $(srcdir)/$$map $(DESTDIR)$(mapdir)/$$map; \
+       done
+
+clean:
+       rm -f *~
+
+distclean: clean
+       rm -f Makefile
+
+test check:
diff --git a/contrib/idn/idnkit-1.0-src/map/jp.map b/contrib/idn/idnkit-1.0-src/map/jp.map
new file mode 100644 (file)
index 0000000..3d98cce
--- /dev/null
@@ -0,0 +1,50 @@
+# $Id: jp.map,v 1.1 2003/06/04 00:27:55 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.
+
+#
+# Local map table for JP domain.
+#
+
+# version=1.0
+
+2212; FF0D
+309B; 3099
+309C; 309A
diff --git a/contrib/idn/idnkit-1.0-src/mkinstalldirs b/contrib/idn/idnkit-1.0-src/mkinstalldirs
new file mode 100755 (executable)
index 0000000..6e12439
--- /dev/null
@@ -0,0 +1,40 @@
+#! /bin/sh
+# mkinstalldirs --- make directory hierarchy
+# Author: Noah Friedman <friedman@prep.ai.mit.edu>
+# Created: 1993-05-16
+# Public domain
+
+# $Id: mkinstalldirs,v 1.1 2003/06/04 00:25:33 marka Exp $
+
+errstatus=0
+
+for file
+do
+   set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
+   shift
+
+   pathcomp=
+   for d
+   do
+     pathcomp="$pathcomp$d"
+     case "$pathcomp" in
+       -* ) pathcomp=./$pathcomp ;;
+     esac
+
+     if test ! -d "$pathcomp"; then
+        echo "mkdir $pathcomp"
+
+        mkdir "$pathcomp" || lasterr=$?
+
+        if test ! -d "$pathcomp"; then
+         errstatus=$lasterr
+        fi
+     fi
+
+     pathcomp="$pathcomp/"
+   done
+done
+
+exit $errstatus
+
+# mkinstalldirs ends here
diff --git a/contrib/idn/idnkit-1.0-src/patch/bind9/bind-9.2.1-patch b/contrib/idn/idnkit-1.0-src/patch/bind9/bind-9.2.1-patch
new file mode 100644 (file)
index 0000000..db98d6c
--- /dev/null
@@ -0,0 +1,5900 @@
+IDN patch for bind-9.2.1
+========================
+
+
+This is a patch file for ISC BIND 9.2.1 to make it work with
+internationalized domain names.  With this patch you'll get IDN-aware
+dig/host/nslookup.
+
+To apply this patch, you should go to the top directory of the BIND
+distribution (where you see `README' file), then invoke `patch'
+command like this:
+
+       % patch -p0 < this-file
+
+Then follow the instructions described in `README.idnkit' to compile
+and install.
+
+
+Index: README.idnkit
+diff -c /dev/null mdn/othersrc/bind9/README.idnkit:1.2
+*** README.idnkit      Mon May 27 16:53:24 2002
+--- README.idnkit      Tue Mar 26 16:35:05 2002
+***************
+*** 0 ****
+--- 1,113 ----
++ 
++                      BIND-9 IDN patch
++ 
++             Japan Network Information Center (JPNIC)
++ 
++ 
++ * What is this patch for?
++ 
++ This patch adds internationalized domain name (IDN) support to BIND-9.
++ You'll get internationalized version of dig/host/nslookup commands.
++ 
++     + internationalized dig/host/nslookup
++      dig/host/nslookup accepts non-ASCII domain names in the local
++      codeset (such as Shift JIS, Big5 or ISO8859-1) determined by
++      the locale information.  The domain names are normalized and
++      converted to the encoding on the DNS protocol, and sent to DNS
++      servers.  The replies are converted back to the local codeset
++      and displayed.
++ 
++ 
++ * Compilation & installation
++ 
++ 0. Prerequisite
++ 
++ You have to build and install idnkit before building this patched version
++ of bind-9.
++ 
++ 1. Running configure script
++ 
++ Run `configure' in the top directory.  See `README' for the
++ configuration options.
++ 
++ This patch adds the following 4 options to `configure'.  You should
++ at least specify `--with-idn' option to enable IDN support.
++ 
++     --with-idn[=IDN_PREFIX]
++      To enable IDN support, you have to specify `--with-idn' option.
++      The argument IDN_PREFIX is the install prefix of idnkit.  If
++      IDN_PREFIX is omitted, PREFIX (derived from `--prefix=PREFIX')
++      is assumed.
++ 
++     --with-libiconv[=LIBICONV_PREFIX]
++      Specify this option if idnkit you have installed links GNU
++      libiconv.  The argument LIBICONV_PREFIX is install prefix of
++      GNU libiconv.  If the argument is omitted, PREFIX (derived
++      from `--prefix=PREFIX') is assumed.
++ 
++      `--with-libiconv' is shorthand option for GNU libiconv.
++ 
++          --with-libiconv=/usr/local
++ 
++      This is equivalent to:
++ 
++          --with-iconv='-L/usr/local/lib -R/usr/local/lib -liconv'
++ 
++      `--with-libiconv' assumes that your C compiler has `-R'
++      option, and that the option adds the specified run-time path
++      to an exacutable binary.  If `-R' option of your compiler has
++      different meaning, or your compiler lacks the option, you
++      should use `--with-iconv' option instead.  Binary command
++      without run-time path information might be unexecutable.
++      In that case, you would see an error message like:
++ 
++          error in loading shared libraries: libiconv.so.2: cannot
++          open shared object file
++ 
++      If both `--with-libiconv' and `--with-iconv' options are
++      specified, `--with-iconv' is prior to `--with-libiconv'.
++ 
++     --with-iconv=ICONV_LIBSPEC
++      If your libc doens't provide iconv(), you need to specify the
++      library containing iconv() with this option.  `ICONV_LIBSPEC'
++      is the argument(s) to `cc' or `ld' to link the library, for
++      example, `--with-iconv="-L/usr/local/lib -liconv"'.
++      You don't need to specify the header file directory for "iconv.h"
++      to the compiler, as it isn't included directly by bind-9 with
++      this patch.
++ 
++     --with-idnlib=IDN_LIBSPEC
++      With this option, you can explicitly specify the argument(s)
++      to `cc' or `ld' to link the idnkit's library, `libidnkit'.  If
++      this option is not specified, `-L${PREFIX}/lib -lidnkit' is
++      assumed, where ${PREFIX} is the installation prefix specified
++      with `--with-idn' option above.  You may need to use this
++      option to specify extra argments, for example,
++      `--with-idnlib="-L/usr/local/lib -R/usr/local/lib -lidnkit"'.
++ 
++ Please consult `README' for other configuration options.
++ 
++ Note that if you want to specify some extra header file directories,
++ you should use the environment variable STD_CINCLUDES instead of
++ CFLAGS, as described in README.
++ 
++ 2. Compilation and installation
++ 
++ After running "configure", just do
++ 
++      make
++      make install
++ 
++ for compiling and installing.
++ 
++ 
++ * Contact information
++ 
++ Please see http//www.nic.ad.jp/jp/research/mdn/ for the latest news
++ about idnkit and this patch.
++ 
++ Bug reports and comments on this kit should be sent to
++ mdnkit-bugs@nic.ad.jp and mdn-cmt@nic.ad.jp, respectively.
++ 
++ 
++ ; $Id: bind-9.2.1-patch,v 1.1 2003/06/04 00:27:30 marka Exp $
+Index: config.h.in
+diff -c mdn/othersrc/bind9/config.h.in:1.1.1.6 mdn/othersrc/bind9/config.h.in:1.12
+*** config.h.in        Tue Nov 27 16:55:45 2001
+--- config.h.in        Tue Mar 19 16:45:35 2002
+***************
+*** 141,146 ****
+--- 141,149 ----
+  /* define if you have strerror in the C library. */
+  #undef HAVE_STRERROR
+  
++ /* Define if you have the setlocale function.  */
++ #undef HAVE_SETLOCALE
++ 
+  /* Define if you have the <dlfcn.h> header file.  */
+  #undef HAVE_DLFCN_H
+  
+***************
+*** 150,155 ****
+--- 153,161 ----
+  /* Define if you have the <linux/capability.h> header file.  */
+  #undef HAVE_LINUX_CAPABILITY_H
+  
++ /* Define if you have the <locale.h> header file.  */
++ #undef HAVE_LOCALE_H
++ 
+  /* Define if you have the <sys/prctl.h> header file.  */
+  #undef HAVE_SYS_PRCTL_H
+  
+***************
+*** 176,178 ****
+--- 182,188 ----
+  
+  /* Define if you have the socket library (-lsocket).  */
+  #undef HAVE_LIBSOCKET
++ 
++ /* define if idnkit support is to be included. */
++ #undef WITH_IDN
++ 
+Index: configure
+diff -c mdn/othersrc/bind9/configure:1.1.1.9 mdn/othersrc/bind9/configure:1.15
+*** configure  Wed May 22 17:14:53 2002
+--- configure  Mon May 27 12:10:14 2002
+***************
+*** 369,374 ****
+--- 369,382 ----
+    --with-kame[=PATH] use Kame IPv6 [default path /usr/local/v6]"
+  ac_help="$ac_help
+    --disable-linux-caps       disable linux capabilities"
++ ac_help="$ac_help
++   --with-idn[=MPREFIX]   enable IDN support using idnkit [default PREFIX]"
++ ac_help="$ac_help
++   --with-libiconv[=IPREFIX]   GNU libiconv are in IPREFIX [default PREFIX]"
++ ac_help="$ac_help
++   --with-iconv[=LIBSPEC]   specify iconv library [default -liconv]"
++ ac_help="$ac_help
++   --with-idnlib=ARG    specify libidnkit"
+  
+  # Initialize some variables set by options.
+  # The variables have the same names as the options, with
+***************
+*** 911,917 ****
+  fi
+  
+  echo $ac_n "checking host system type""... $ac_c" 1>&6
+! echo "configure:915: checking host system type" >&5
+  
+  host_alias=$host
+  case "$host_alias" in
+--- 919,925 ----
+  fi
+  
+  echo $ac_n "checking host system type""... $ac_c" 1>&6
+! echo "configure:923: checking host system type" >&5
+  
+  host_alias=$host
+  case "$host_alias" in
+***************
+*** 933,939 ****
+  
+  
+  echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
+! echo "configure:937: checking whether ${MAKE-make} sets \${MAKE}" >&5
+  set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
+  if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+--- 941,947 ----
+  
+  
+  echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
+! echo "configure:945: checking whether ${MAKE-make} sets \${MAKE}" >&5
+  set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
+  if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+***************
+*** 962,968 ****
+  # Extract the first word of "ranlib", so it can be a program name with args.
+  set dummy ranlib; ac_word=$2
+  echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+! echo "configure:966: checking for $ac_word" >&5
+  if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+--- 970,976 ----
+  # Extract the first word of "ranlib", so it can be a program name with args.
+  set dummy ranlib; ac_word=$2
+  echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+! echo "configure:974: checking for $ac_word" >&5
+  if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+***************
+*** 1001,1007 ****
+  # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
+  # ./install, which can be erroneously created by make from ./install.sh.
+  echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
+! echo "configure:1005: checking for a BSD compatible install" >&5
+  if test -z "$INSTALL"; then
+  if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+--- 1009,1015 ----
+  # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
+  # ./install, which can be erroneously created by make from ./install.sh.
+  echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
+! echo "configure:1013: checking for a BSD compatible install" >&5
+  if test -z "$INSTALL"; then
+  if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+***************
+*** 1062,1068 ****
+  # Extract the first word of "ar", so it can be a program name with args.
+  set dummy ar; ac_word=$2
+  echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+! echo "configure:1066: checking for $ac_word" >&5
+  if eval "test \"`echo '$''{'ac_cv_path_AR'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+--- 1070,1076 ----
+  # Extract the first word of "ar", so it can be a program name with args.
+  set dummy ar; ac_word=$2
+  echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+! echo "configure:1074: checking for $ac_word" >&5
+  if eval "test \"`echo '$''{'ac_cv_path_AR'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+***************
+*** 1121,1127 ****
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+  set dummy $ac_prog; ac_word=$2
+  echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+! echo "configure:1125: checking for $ac_word" >&5
+  if eval "test \"`echo '$''{'ac_cv_path_ETAGS'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+--- 1129,1135 ----
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+  set dummy $ac_prog; ac_word=$2
+  echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+! echo "configure:1133: checking for $ac_word" >&5
+  if eval "test \"`echo '$''{'ac_cv_path_ETAGS'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+***************
+*** 1163,1169 ****
+  #
+  if test "X$ETAGS" != "X"; then
+       echo $ac_n "checking for Exuberant Ctags etags""... $ac_c" 1>&6
+! echo "configure:1167: checking for Exuberant Ctags etags" >&5
+       if $ETAGS --version 2>&1 | grep 'Exuberant Ctags' >/dev/null 2>&1; then
+               echo "$ac_t""yes" 1>&6
+               ETAGS="$ETAGS -L"
+--- 1171,1177 ----
+  #
+  if test "X$ETAGS" != "X"; then
+       echo $ac_n "checking for Exuberant Ctags etags""... $ac_c" 1>&6
+! echo "configure:1175: checking for Exuberant Ctags etags" >&5
+       if $ETAGS --version 2>&1 | grep 'Exuberant Ctags' >/dev/null 2>&1; then
+               echo "$ac_t""yes" 1>&6
+               ETAGS="$ETAGS -L"
+***************
+*** 1181,1187 ****
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+  set dummy $ac_prog; ac_word=$2
+  echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+! echo "configure:1185: checking for $ac_word" >&5
+  if eval "test \"`echo '$''{'ac_cv_path_PERL'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+--- 1189,1195 ----
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+  set dummy $ac_prog; ac_word=$2
+  echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+! echo "configure:1193: checking for $ac_word" >&5
+  if eval "test \"`echo '$''{'ac_cv_path_PERL'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+***************
+*** 1328,1334 ****
+  # Extract the first word of "gcc", so it can be a program name with args.
+  set dummy gcc; ac_word=$2
+  echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+! echo "configure:1332: checking for $ac_word" >&5
+  if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+--- 1336,1342 ----
+  # Extract the first word of "gcc", so it can be a program name with args.
+  set dummy gcc; ac_word=$2
+  echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+! echo "configure:1340: checking for $ac_word" >&5
+  if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+***************
+*** 1358,1364 ****
+    # Extract the first word of "cc", so it can be a program name with args.
+  set dummy cc; ac_word=$2
+  echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+! echo "configure:1362: checking for $ac_word" >&5
+  if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+--- 1366,1372 ----
+    # Extract the first word of "cc", so it can be a program name with args.
+  set dummy cc; ac_word=$2
+  echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+! echo "configure:1370: checking for $ac_word" >&5
+  if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+***************
+*** 1409,1415 ****
+        # Extract the first word of "cl", so it can be a program name with args.
+  set dummy cl; ac_word=$2
+  echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+! echo "configure:1413: checking for $ac_word" >&5
+  if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+--- 1417,1423 ----
+        # Extract the first word of "cl", so it can be a program name with args.
+  set dummy cl; ac_word=$2
+  echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+! echo "configure:1421: checking for $ac_word" >&5
+  if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+***************
+*** 1441,1447 ****
+  fi
+  
+  echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
+! echo "configure:1445: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+  
+  ac_ext=c
+  # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+--- 1449,1455 ----
+  fi
+  
+  echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
+! echo "configure:1453: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+  
+  ac_ext=c
+  # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+***************
+*** 1452,1463 ****
+  
+  cat > conftest.$ac_ext << EOF
+  
+! #line 1456 "configure"
+  #include "confdefs.h"
+  
+  main(){return(0);}
+  EOF
+! if { (eval echo configure:1461: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    ac_cv_prog_cc_works=yes
+    # If we can't run a trivial program, we are probably using a cross compiler.
+    if (./conftest; exit) 2>/dev/null; then
+--- 1460,1471 ----
+  
+  cat > conftest.$ac_ext << EOF
+  
+! #line 1464 "configure"
+  #include "confdefs.h"
+  
+  main(){return(0);}
+  EOF
+! if { (eval echo configure:1469: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    ac_cv_prog_cc_works=yes
+    # If we can't run a trivial program, we are probably using a cross compiler.
+    if (./conftest; exit) 2>/dev/null; then
+***************
+*** 1483,1494 ****
+    { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
+  fi
+  echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
+! echo "configure:1487: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+  echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
+  cross_compiling=$ac_cv_prog_cc_cross
+  
+  echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
+! echo "configure:1492: checking whether we are using GNU C" >&5
+  if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+--- 1491,1502 ----
+    { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
+  fi
+  echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
+! echo "configure:1495: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+  echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
+  cross_compiling=$ac_cv_prog_cc_cross
+  
+  echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
+! echo "configure:1500: checking whether we are using GNU C" >&5
+  if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+***************
+*** 1497,1503 ****
+    yes;
+  #endif
+  EOF
+! if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1501: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+    ac_cv_prog_gcc=yes
+  else
+    ac_cv_prog_gcc=no
+--- 1505,1511 ----
+    yes;
+  #endif
+  EOF
+! if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1509: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+    ac_cv_prog_gcc=yes
+  else
+    ac_cv_prog_gcc=no
+***************
+*** 1516,1522 ****
+  ac_save_CFLAGS="$CFLAGS"
+  CFLAGS=
+  echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
+! echo "configure:1520: checking whether ${CC-cc} accepts -g" >&5
+  if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+--- 1524,1530 ----
+  ac_save_CFLAGS="$CFLAGS"
+  CFLAGS=
+  echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
+! echo "configure:1528: checking whether ${CC-cc} accepts -g" >&5
+  if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+***************
+*** 1549,1555 ****
+  
+  
+  echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
+! echo "configure:1553: checking how to run the C preprocessor" >&5
+  # On Suns, sometimes $CPP names a directory.
+  if test -n "$CPP" && test -d "$CPP"; then
+    CPP=
+--- 1557,1563 ----
+  
+  
+  echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
+! echo "configure:1561: checking how to run the C preprocessor" >&5
+  # On Suns, sometimes $CPP names a directory.
+  if test -n "$CPP" && test -d "$CPP"; then
+    CPP=
+***************
+*** 1564,1576 ****
+    # On the NeXT, cc -E runs the code through the compiler's parser,
+    # not just through cpp.
+    cat > conftest.$ac_ext <<EOF
+! #line 1568 "configure"
+  #include "confdefs.h"
+  #include <assert.h>
+  Syntax Error
+  EOF
+  ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+! { (eval echo configure:1574: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+  ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+  if test -z "$ac_err"; then
+    :
+--- 1572,1584 ----
+    # On the NeXT, cc -E runs the code through the compiler's parser,
+    # not just through cpp.
+    cat > conftest.$ac_ext <<EOF
+! #line 1576 "configure"
+  #include "confdefs.h"
+  #include <assert.h>
+  Syntax Error
+  EOF
+  ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+! { (eval echo configure:1582: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+  ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+  if test -z "$ac_err"; then
+    :
+***************
+*** 1581,1593 ****
+    rm -rf conftest*
+    CPP="${CC-cc} -E -traditional-cpp"
+    cat > conftest.$ac_ext <<EOF
+! #line 1585 "configure"
+  #include "confdefs.h"
+  #include <assert.h>
+  Syntax Error
+  EOF
+  ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+! { (eval echo configure:1591: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+  ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+  if test -z "$ac_err"; then
+    :
+--- 1589,1601 ----
+    rm -rf conftest*
+    CPP="${CC-cc} -E -traditional-cpp"
+    cat > conftest.$ac_ext <<EOF
+! #line 1593 "configure"
+  #include "confdefs.h"
+  #include <assert.h>
+  Syntax Error
+  EOF
+  ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+! { (eval echo configure:1599: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+  ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+  if test -z "$ac_err"; then
+    :
+***************
+*** 1598,1610 ****
+    rm -rf conftest*
+    CPP="${CC-cc} -nologo -E"
+    cat > conftest.$ac_ext <<EOF
+! #line 1602 "configure"
+  #include "confdefs.h"
+  #include <assert.h>
+  Syntax Error
+  EOF
+  ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+! { (eval echo configure:1608: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+  ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+  if test -z "$ac_err"; then
+    :
+--- 1606,1618 ----
+    rm -rf conftest*
+    CPP="${CC-cc} -nologo -E"
+    cat > conftest.$ac_ext <<EOF
+! #line 1610 "configure"
+  #include "confdefs.h"
+  #include <assert.h>
+  Syntax Error
+  EOF
+  ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+! { (eval echo configure:1616: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+  ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+  if test -z "$ac_err"; then
+    :
+***************
+*** 1629,1640 ****
+  echo "$ac_t""$CPP" 1>&6
+  
+  echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
+! echo "configure:1633: checking for ANSI C header files" >&5
+  if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 1638 "configure"
+  #include "confdefs.h"
+  #include <stdlib.h>
+  #include <stdarg.h>
+--- 1637,1648 ----
+  echo "$ac_t""$CPP" 1>&6
+  
+  echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
+! echo "configure:1641: checking for ANSI C header files" >&5
+  if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 1646 "configure"
+  #include "confdefs.h"
+  #include <stdlib.h>
+  #include <stdarg.h>
+***************
+*** 1642,1648 ****
+  #include <float.h>
+  EOF
+  ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+! { (eval echo configure:1646: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+  ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+  if test -z "$ac_err"; then
+    rm -rf conftest*
+--- 1650,1656 ----
+  #include <float.h>
+  EOF
+  ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+! { (eval echo configure:1654: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+  ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+  if test -z "$ac_err"; then
+    rm -rf conftest*
+***************
+*** 1659,1665 ****
+  if test $ac_cv_header_stdc = yes; then
+    # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+  cat > conftest.$ac_ext <<EOF
+! #line 1663 "configure"
+  #include "confdefs.h"
+  #include <string.h>
+  EOF
+--- 1667,1673 ----
+  if test $ac_cv_header_stdc = yes; then
+    # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+  cat > conftest.$ac_ext <<EOF
+! #line 1671 "configure"
+  #include "confdefs.h"
+  #include <string.h>
+  EOF
+***************
+*** 1677,1683 ****
+  if test $ac_cv_header_stdc = yes; then
+    # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+  cat > conftest.$ac_ext <<EOF
+! #line 1681 "configure"
+  #include "confdefs.h"
+  #include <stdlib.h>
+  EOF
+--- 1685,1691 ----
+  if test $ac_cv_header_stdc = yes; then
+    # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+  cat > conftest.$ac_ext <<EOF
+! #line 1689 "configure"
+  #include "confdefs.h"
+  #include <stdlib.h>
+  EOF
+***************
+*** 1698,1704 ****
+    :
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 1702 "configure"
+  #include "confdefs.h"
+  #include <ctype.h>
+  #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+--- 1706,1712 ----
+    :
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 1710 "configure"
+  #include "confdefs.h"
+  #include <ctype.h>
+  #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+***************
+*** 1709,1715 ****
+  exit (0); }
+  
+  EOF
+! if { (eval echo configure:1713: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+  then
+    :
+  else
+--- 1717,1723 ----
+  exit (0); }
+  
+  EOF
+! if { (eval echo configure:1721: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+  then
+    :
+  else
+***************
+*** 1737,1753 ****
+  do
+  ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+  echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+! echo "configure:1741: checking for $ac_hdr" >&5
+  if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 1746 "configure"
+  #include "confdefs.h"
+  #include <$ac_hdr>
+  EOF
+  ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+! { (eval echo configure:1751: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+  ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+  if test -z "$ac_err"; then
+    rm -rf conftest*
+--- 1745,1761 ----
+  do
+  ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+  echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+! echo "configure:1749: checking for $ac_hdr" >&5
+  if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 1754 "configure"
+  #include "confdefs.h"
+  #include <$ac_hdr>
+  EOF
+  ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+! { (eval echo configure:1759: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+  ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+  if test -z "$ac_err"; then
+    rm -rf conftest*
+***************
+*** 1775,1786 ****
+  
+  
+  echo $ac_n "checking for working const""... $ac_c" 1>&6
+! echo "configure:1779: checking for working const" >&5
+  if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 1784 "configure"
+  #include "confdefs.h"
+  
+  int main() {
+--- 1783,1794 ----
+  
+  
+  echo $ac_n "checking for working const""... $ac_c" 1>&6
+! echo "configure:1787: checking for working const" >&5
+  if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 1792 "configure"
+  #include "confdefs.h"
+  
+  int main() {
+***************
+*** 1829,1835 ****
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:1833: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    ac_cv_c_const=yes
+  else
+--- 1837,1843 ----
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:1841: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    ac_cv_c_const=yes
+  else
+***************
+*** 1850,1870 ****
+  fi
+  
+  echo $ac_n "checking for inline""... $ac_c" 1>&6
+! echo "configure:1854: checking for inline" >&5
+  if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    ac_cv_c_inline=no
+  for ac_kw in inline __inline__ __inline; do
+    cat > conftest.$ac_ext <<EOF
+! #line 1861 "configure"
+  #include "confdefs.h"
+  
+  int main() {
+  } $ac_kw foo() {
+  ; return 0; }
+  EOF
+! if { (eval echo configure:1868: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    ac_cv_c_inline=$ac_kw; break
+  else
+--- 1858,1878 ----
+  fi
+  
+  echo $ac_n "checking for inline""... $ac_c" 1>&6
+! echo "configure:1862: checking for inline" >&5
+  if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    ac_cv_c_inline=no
+  for ac_kw in inline __inline__ __inline; do
+    cat > conftest.$ac_ext <<EOF
+! #line 1869 "configure"
+  #include "confdefs.h"
+  
+  int main() {
+  } $ac_kw foo() {
+  ; return 0; }
+  EOF
+! if { (eval echo configure:1876: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    ac_cv_c_inline=$ac_kw; break
+  else
+***************
+*** 1890,1901 ****
+  esac
+  
+  echo $ac_n "checking for sysctlbyname""... $ac_c" 1>&6
+! echo "configure:1894: checking for sysctlbyname" >&5
+  if eval "test \"`echo '$''{'ac_cv_func_sysctlbyname'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 1899 "configure"
+  #include "confdefs.h"
+  /* System header to define __stub macros and hopefully few prototypes,
+      which can conflict with char sysctlbyname(); below.  */
+--- 1898,1909 ----
+  esac
+  
+  echo $ac_n "checking for sysctlbyname""... $ac_c" 1>&6
+! echo "configure:1902: checking for sysctlbyname" >&5
+  if eval "test \"`echo '$''{'ac_cv_func_sysctlbyname'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 1907 "configure"
+  #include "confdefs.h"
+  /* System header to define __stub macros and hopefully few prototypes,
+      which can conflict with char sysctlbyname(); below.  */
+***************
+*** 1918,1924 ****
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:1922: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_func_sysctlbyname=yes"
+  else
+--- 1926,1932 ----
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:1930: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_func_sysctlbyname=yes"
+  else
+***************
+*** 1946,1954 ****
+  # is reported to not support "static inline" (RT #1212).
+  #
+  echo $ac_n "checking for static inline breakage""... $ac_c" 1>&6
+! echo "configure:1950: checking for static inline breakage" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 1952 "configure"
+  #include "confdefs.h"
+  
+  int main() {
+--- 1954,1962 ----
+  # is reported to not support "static inline" (RT #1212).
+  #
+  echo $ac_n "checking for static inline breakage""... $ac_c" 1>&6
+! echo "configure:1958: checking for static inline breakage" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 1960 "configure"
+  #include "confdefs.h"
+  
+  int main() {
+***************
+*** 1965,1971 ****
+       
+  ; return 0; }
+  EOF
+! if { (eval echo configure:1969: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    echo "$ac_t""no" 1>&6
+  else
+--- 1973,1979 ----
+       
+  ; return 0; }
+  EOF
+! if { (eval echo configure:1977: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    echo "$ac_t""no" 1>&6
+  else
+***************
+*** 1981,1992 ****
+  rm -f conftest*
+  
+  echo $ac_n "checking for size_t""... $ac_c" 1>&6
+! echo "configure:1985: checking for size_t" >&5
+  if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 1990 "configure"
+  #include "confdefs.h"
+  #include <sys/types.h>
+  #if STDC_HEADERS
+--- 1989,2000 ----
+  rm -f conftest*
+  
+  echo $ac_n "checking for size_t""... $ac_c" 1>&6
+! echo "configure:1993: checking for size_t" >&5
+  if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 1998 "configure"
+  #include "confdefs.h"
+  #include <sys/types.h>
+  #if STDC_HEADERS
+***************
+*** 2014,2025 ****
+  fi
+  
+  echo $ac_n "checking for ssize_t""... $ac_c" 1>&6
+! echo "configure:2018: checking for ssize_t" >&5
+  if eval "test \"`echo '$''{'ac_cv_type_ssize_t'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 2023 "configure"
+  #include "confdefs.h"
+  #include <sys/types.h>
+  #if STDC_HEADERS
+--- 2022,2033 ----
+  fi
+  
+  echo $ac_n "checking for ssize_t""... $ac_c" 1>&6
+! echo "configure:2026: checking for ssize_t" >&5
+  if eval "test \"`echo '$''{'ac_cv_type_ssize_t'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 2031 "configure"
+  #include "confdefs.h"
+  #include <sys/types.h>
+  #if STDC_HEADERS
+***************
+*** 2047,2058 ****
+  fi
+  
+  echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
+! echo "configure:2051: checking whether time.h and sys/time.h may both be included" >&5
+  if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 2056 "configure"
+  #include "confdefs.h"
+  #include <sys/types.h>
+  #include <sys/time.h>
+--- 2055,2066 ----
+  fi
+  
+  echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
+! echo "configure:2059: checking whether time.h and sys/time.h may both be included" >&5
+  if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 2064 "configure"
+  #include "confdefs.h"
+  #include <sys/types.h>
+  #include <sys/time.h>
+***************
+*** 2061,2067 ****
+  struct tm *tp;
+  ; return 0; }
+  EOF
+! if { (eval echo configure:2065: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    ac_cv_header_time=yes
+  else
+--- 2069,2075 ----
+  struct tm *tp;
+  ; return 0; }
+  EOF
+! if { (eval echo configure:2073: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    ac_cv_header_time=yes
+  else
+***************
+*** 2082,2097 ****
+  fi
+  
+  echo $ac_n "checking for long long""... $ac_c" 1>&6
+! echo "configure:2086: checking for long long" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 2088 "configure"
+  #include "confdefs.h"
+  
+  int main() {
+  long long i = 0; return (0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:2095: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    echo "$ac_t""yes" 1>&6
+               ISC_PLATFORM_HAVELONGLONG="#define ISC_PLATFORM_HAVELONGLONG 1"
+--- 2090,2105 ----
+  fi
+  
+  echo $ac_n "checking for long long""... $ac_c" 1>&6
+! echo "configure:2094: checking for long long" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 2096 "configure"
+  #include "confdefs.h"
+  
+  int main() {
+  long long i = 0; return (0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:2103: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    echo "$ac_t""yes" 1>&6
+               ISC_PLATFORM_HAVELONGLONG="#define ISC_PLATFORM_HAVELONGLONG 1"
+***************
+*** 2111,2119 ****
+  case $ac_cv_header_unistd_h in
+  yes)
+  echo $ac_n "checking if unistd.h defines fd_set""... $ac_c" 1>&6
+! echo "configure:2115: checking if unistd.h defines fd_set" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 2117 "configure"
+  #include "confdefs.h"
+  
+  #include <unistd.h>
+--- 2119,2127 ----
+  case $ac_cv_header_unistd_h in
+  yes)
+  echo $ac_n "checking if unistd.h defines fd_set""... $ac_c" 1>&6
+! echo "configure:2123: checking if unistd.h defines fd_set" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 2125 "configure"
+  #include "confdefs.h"
+  
+  #include <unistd.h>
+***************
+*** 2121,2127 ****
+  fd_set read_set; return (0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:2125: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    echo "$ac_t""yes" 1>&6
+        ISC_PLATFORM_NEEDSYSSELECTH="#undef ISC_PLATFORM_NEEDSYSSELECTH"
+--- 2129,2135 ----
+  fd_set read_set; return (0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:2133: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    echo "$ac_t""yes" 1>&6
+        ISC_PLATFORM_NEEDSYSSELECTH="#undef ISC_PLATFORM_NEEDSYSSELECTH"
+***************
+*** 2163,2176 ****
+  # Find the machine's endian flavor.
+  #
+  echo $ac_n "checking whether byte ordering is bigendian""... $ac_c" 1>&6
+! echo "configure:2167: checking whether byte ordering is bigendian" >&5
+  if eval "test \"`echo '$''{'ac_cv_c_bigendian'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    ac_cv_c_bigendian=unknown
+  # See if sys/param.h defines the BYTE_ORDER macro.
+  cat > conftest.$ac_ext <<EOF
+! #line 2174 "configure"
+  #include "confdefs.h"
+  #include <sys/types.h>
+  #include <sys/param.h>
+--- 2171,2184 ----
+  # Find the machine's endian flavor.
+  #
+  echo $ac_n "checking whether byte ordering is bigendian""... $ac_c" 1>&6
+! echo "configure:2175: checking whether byte ordering is bigendian" >&5
+  if eval "test \"`echo '$''{'ac_cv_c_bigendian'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    ac_cv_c_bigendian=unknown
+  # See if sys/param.h defines the BYTE_ORDER macro.
+  cat > conftest.$ac_ext <<EOF
+! #line 2182 "configure"
+  #include "confdefs.h"
+  #include <sys/types.h>
+  #include <sys/param.h>
+***************
+*** 2181,2191 ****
+  #endif
+  ; return 0; }
+  EOF
+! if { (eval echo configure:2185: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    # It does; now see whether it defined to BIG_ENDIAN or not.
+  cat > conftest.$ac_ext <<EOF
+! #line 2189 "configure"
+  #include "confdefs.h"
+  #include <sys/types.h>
+  #include <sys/param.h>
+--- 2189,2199 ----
+  #endif
+  ; return 0; }
+  EOF
+! if { (eval echo configure:2193: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    # It does; now see whether it defined to BIG_ENDIAN or not.
+  cat > conftest.$ac_ext <<EOF
+! #line 2197 "configure"
+  #include "confdefs.h"
+  #include <sys/types.h>
+  #include <sys/param.h>
+***************
+*** 2196,2202 ****
+  #endif
+  ; return 0; }
+  EOF
+! if { (eval echo configure:2200: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    ac_cv_c_bigendian=yes
+  else
+--- 2204,2210 ----
+  #endif
+  ; return 0; }
+  EOF
+! if { (eval echo configure:2208: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    ac_cv_c_bigendian=yes
+  else
+***************
+*** 2216,2222 ****
+      { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 2220 "configure"
+  #include "confdefs.h"
+  main () {
+    /* Are we little or big endian?  From Harbison&Steele.  */
+--- 2224,2230 ----
+      { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 2228 "configure"
+  #include "confdefs.h"
+  main () {
+    /* Are we little or big endian?  From Harbison&Steele.  */
+***************
+*** 2229,2235 ****
+    exit (u.c[sizeof (long) - 1] == 1);
+  }
+  EOF
+! if { (eval echo configure:2233: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+  then
+    ac_cv_c_bigendian=no
+  else
+--- 2237,2243 ----
+    exit (u.c[sizeof (long) - 1] == 1);
+  }
+  EOF
+! if { (eval echo configure:2241: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+  then
+    ac_cv_c_bigendian=no
+  else
+***************
+*** 2257,2263 ****
+  # was --with-openssl specified?
+  #
+  echo $ac_n "checking for OpenSSL library""... $ac_c" 1>&6
+! echo "configure:2261: checking for OpenSSL library" >&5
+  # Check whether --with-openssl or --without-openssl was given.
+  if test "${with_openssl+set}" = set; then
+    withval="$with_openssl"
+--- 2265,2271 ----
+  # was --with-openssl specified?
+  #
+  echo $ac_n "checking for OpenSSL library""... $ac_c" 1>&6
+! echo "configure:2269: checking for OpenSSL library" >&5
+  # Check whether --with-openssl or --without-openssl was given.
+  if test "${with_openssl+set}" = set; then
+    withval="$with_openssl"
+***************
+*** 2298,2304 ****
+               echo "$ac_t""using openssl from $use_openssl/lib and $use_openssl/include" 1>&6
+  
+               echo $ac_n "checking OpenSSL library version""... $ac_c" 1>&6
+! echo "configure:2302: checking OpenSSL library version" >&5
+               saved_cflags="$CFLAGS"
+               saved_libs="$LIBS"
+               CFLAGS="$CFLAGS $DST_OPENSSL_INC"
+--- 2306,2312 ----
+               echo "$ac_t""using openssl from $use_openssl/lib and $use_openssl/include" 1>&6
+  
+               echo $ac_n "checking OpenSSL library version""... $ac_c" 1>&6
+! echo "configure:2310: checking OpenSSL library version" >&5
+               saved_cflags="$CFLAGS"
+               saved_libs="$LIBS"
+               CFLAGS="$CFLAGS $DST_OPENSSL_INC"
+***************
+*** 2307,2313 ****
+    echo "$ac_t""assuming target platform has compatible version" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 2311 "configure"
+  #include "confdefs.h"
+  
+  #include <stdio.h>
+--- 2315,2321 ----
+    echo "$ac_t""assuming target platform has compatible version" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 2319 "configure"
+  #include "confdefs.h"
+  
+  #include <stdio.h>
+***************
+*** 2322,2328 ****
+  }
+  
+  EOF
+! if { (eval echo configure:2326: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+  then
+    echo "$ac_t""ok" 1>&6
+  else
+--- 2330,2336 ----
+  }
+  
+  EOF
+! if { (eval echo configure:2334: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+  then
+    echo "$ac_t""ok" 1>&6
+  else
+***************
+*** 2387,2393 ****
+  # was --with-randomdev specified?
+  #
+  echo $ac_n "checking for random device""... $ac_c" 1>&6
+! echo "configure:2391: checking for random device" >&5
+  # Check whether --with-randomdev or --without-randomdev was given.
+  if test "${with_randomdev+set}" = set; then
+    withval="$with_randomdev"
+--- 2395,2401 ----
+  # was --with-randomdev specified?
+  #
+  echo $ac_n "checking for random device""... $ac_c" 1>&6
+! echo "configure:2399: checking for random device" >&5
+  # Check whether --with-randomdev or --without-randomdev was given.
+  if test "${with_randomdev+set}" = set; then
+    withval="$with_randomdev"
+***************
+*** 2411,2417 ****
+               
+  ac_safe=`echo "$devrandom" | sed 'y%./+-%__p_%'`
+  echo $ac_n "checking for $devrandom""... $ac_c" 1>&6
+! echo "configure:2415: checking for $devrandom" >&5
+  if eval "test \"`echo '$''{'ac_cv_file_$ac_safe'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+--- 2419,2425 ----
+               
+  ac_safe=`echo "$devrandom" | sed 'y%./+-%__p_%'`
+  echo $ac_n "checking for $devrandom""... $ac_c" 1>&6
+! echo "configure:2423: checking for $devrandom" >&5
+  if eval "test \"`echo '$''{'ac_cv_file_$ac_safe'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+***************
+*** 2463,2469 ****
+  #
+  
+  echo $ac_n "checking whether to build with thread support""... $ac_c" 1>&6
+! echo "configure:2467: checking whether to build with thread support" >&5
+  
+  case $host in
+  *-dec-osf*)
+--- 2471,2477 ----
+  #
+  
+  echo $ac_n "checking whether to build with thread support""... $ac_c" 1>&6
+! echo "configure:2475: checking whether to build with thread support" >&5
+  
+  case $host in
+  *-dec-osf*)
+***************
+*** 2551,2557 ****
+               # experiment with it.
+               CC="gcc"
+               echo $ac_n "checking which NetBSD thread library to use""... $ac_c" 1>&6
+! echo "configure:2555: checking which NetBSD thread library to use" >&5
+  
+               # Check whether --with-ptl2 or --without-ptl2 was given.
+  if test "${with_ptl2+set}" = set; then
+--- 2559,2565 ----
+               # experiment with it.
+               CC="gcc"
+               echo $ac_n "checking which NetBSD thread library to use""... $ac_c" 1>&6
+! echo "configure:2563: checking which NetBSD thread library to use" >&5
+  
+               # Check whether --with-ptl2 or --without-ptl2 was given.
+  if test "${with_ptl2+set}" = set; then
+***************
+*** 2590,2596 ****
+               ;;
+               *)
+                       echo $ac_n "checking for pthread_create in -lpthread""... $ac_c" 1>&6
+! echo "configure:2594: checking for pthread_create in -lpthread" >&5
+  ac_lib_var=`echo pthread'_'pthread_create | sed 'y%./+-%__p_%'`
+  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+--- 2598,2604 ----
+               ;;
+               *)
+                       echo $ac_n "checking for pthread_create in -lpthread""... $ac_c" 1>&6
+! echo "configure:2602: checking for pthread_create in -lpthread" >&5
+  ac_lib_var=`echo pthread'_'pthread_create | sed 'y%./+-%__p_%'`
+  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+***************
+*** 2598,2604 ****
+    ac_save_LIBS="$LIBS"
+  LIBS="-lpthread  $LIBS"
+  cat > conftest.$ac_ext <<EOF
+! #line 2602 "configure"
+  #include "confdefs.h"
+  /* Override any gcc2 internal prototype to avoid an error.  */
+  /* We use char because int might match the return type of a gcc2
+--- 2606,2612 ----
+    ac_save_LIBS="$LIBS"
+  LIBS="-lpthread  $LIBS"
+  cat > conftest.$ac_ext <<EOF
+! #line 2610 "configure"
+  #include "confdefs.h"
+  /* Override any gcc2 internal prototype to avoid an error.  */
+  /* We use char because int might match the return type of a gcc2
+***************
+*** 2609,2615 ****
+  pthread_create()
+  ; return 0; }
+  EOF
+! if { (eval echo configure:2613: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_lib_$ac_lib_var=yes"
+  else
+--- 2617,2623 ----
+  pthread_create()
+  ; return 0; }
+  EOF
+! if { (eval echo configure:2621: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_lib_$ac_lib_var=yes"
+  else
+***************
+*** 2635,2641 ****
+  else
+    echo "$ac_t""no" 1>&6
+  echo $ac_n "checking for __pthread_create in -lpthread""... $ac_c" 1>&6
+! echo "configure:2639: checking for __pthread_create in -lpthread" >&5
+  ac_lib_var=`echo pthread'_'__pthread_create | sed 'y%./+-%__p_%'`
+  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+--- 2643,2649 ----
+  else
+    echo "$ac_t""no" 1>&6
+  echo $ac_n "checking for __pthread_create in -lpthread""... $ac_c" 1>&6
+! echo "configure:2647: checking for __pthread_create in -lpthread" >&5
+  ac_lib_var=`echo pthread'_'__pthread_create | sed 'y%./+-%__p_%'`
+  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+***************
+*** 2643,2649 ****
+    ac_save_LIBS="$LIBS"
+  LIBS="-lpthread  $LIBS"
+  cat > conftest.$ac_ext <<EOF
+! #line 2647 "configure"
+  #include "confdefs.h"
+  /* Override any gcc2 internal prototype to avoid an error.  */
+  /* We use char because int might match the return type of a gcc2
+--- 2651,2657 ----
+    ac_save_LIBS="$LIBS"
+  LIBS="-lpthread  $LIBS"
+  cat > conftest.$ac_ext <<EOF
+! #line 2655 "configure"
+  #include "confdefs.h"
+  /* Override any gcc2 internal prototype to avoid an error.  */
+  /* We use char because int might match the return type of a gcc2
+***************
+*** 2654,2660 ****
+  __pthread_create()
+  ; return 0; }
+  EOF
+! if { (eval echo configure:2658: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_lib_$ac_lib_var=yes"
+  else
+--- 2662,2668 ----
+  __pthread_create()
+  ; return 0; }
+  EOF
+! if { (eval echo configure:2666: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_lib_$ac_lib_var=yes"
+  else
+***************
+*** 2680,2686 ****
+  else
+    echo "$ac_t""no" 1>&6
+  echo $ac_n "checking for __pthread_create_system in -lpthread""... $ac_c" 1>&6
+! echo "configure:2684: checking for __pthread_create_system in -lpthread" >&5
+  ac_lib_var=`echo pthread'_'__pthread_create_system | sed 'y%./+-%__p_%'`
+  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+--- 2688,2694 ----
+  else
+    echo "$ac_t""no" 1>&6
+  echo $ac_n "checking for __pthread_create_system in -lpthread""... $ac_c" 1>&6
+! echo "configure:2692: checking for __pthread_create_system in -lpthread" >&5
+  ac_lib_var=`echo pthread'_'__pthread_create_system | sed 'y%./+-%__p_%'`
+  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+***************
+*** 2688,2694 ****
+    ac_save_LIBS="$LIBS"
+  LIBS="-lpthread  $LIBS"
+  cat > conftest.$ac_ext <<EOF
+! #line 2692 "configure"
+  #include "confdefs.h"
+  /* Override any gcc2 internal prototype to avoid an error.  */
+  /* We use char because int might match the return type of a gcc2
+--- 2696,2702 ----
+    ac_save_LIBS="$LIBS"
+  LIBS="-lpthread  $LIBS"
+  cat > conftest.$ac_ext <<EOF
+! #line 2700 "configure"
+  #include "confdefs.h"
+  /* Override any gcc2 internal prototype to avoid an error.  */
+  /* We use char because int might match the return type of a gcc2
+***************
+*** 2699,2705 ****
+  __pthread_create_system()
+  ; return 0; }
+  EOF
+! if { (eval echo configure:2703: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_lib_$ac_lib_var=yes"
+  else
+--- 2707,2713 ----
+  __pthread_create_system()
+  ; return 0; }
+  EOF
+! if { (eval echo configure:2711: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_lib_$ac_lib_var=yes"
+  else
+***************
+*** 2725,2731 ****
+  else
+    echo "$ac_t""no" 1>&6
+  echo $ac_n "checking for pthread_create in -lc_r""... $ac_c" 1>&6
+! echo "configure:2729: checking for pthread_create in -lc_r" >&5
+  ac_lib_var=`echo c_r'_'pthread_create | sed 'y%./+-%__p_%'`
+  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+--- 2733,2739 ----
+  else
+    echo "$ac_t""no" 1>&6
+  echo $ac_n "checking for pthread_create in -lc_r""... $ac_c" 1>&6
+! echo "configure:2737: checking for pthread_create in -lc_r" >&5
+  ac_lib_var=`echo c_r'_'pthread_create | sed 'y%./+-%__p_%'`
+  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+***************
+*** 2733,2739 ****
+    ac_save_LIBS="$LIBS"
+  LIBS="-lc_r  $LIBS"
+  cat > conftest.$ac_ext <<EOF
+! #line 2737 "configure"
+  #include "confdefs.h"
+  /* Override any gcc2 internal prototype to avoid an error.  */
+  /* We use char because int might match the return type of a gcc2
+--- 2741,2747 ----
+    ac_save_LIBS="$LIBS"
+  LIBS="-lc_r  $LIBS"
+  cat > conftest.$ac_ext <<EOF
+! #line 2745 "configure"
+  #include "confdefs.h"
+  /* Override any gcc2 internal prototype to avoid an error.  */
+  /* We use char because int might match the return type of a gcc2
+***************
+*** 2744,2750 ****
+  pthread_create()
+  ; return 0; }
+  EOF
+! if { (eval echo configure:2748: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_lib_$ac_lib_var=yes"
+  else
+--- 2752,2758 ----
+  pthread_create()
+  ; return 0; }
+  EOF
+! if { (eval echo configure:2756: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_lib_$ac_lib_var=yes"
+  else
+***************
+*** 2770,2776 ****
+  else
+    echo "$ac_t""no" 1>&6
+  echo $ac_n "checking for pthread_create in -lc""... $ac_c" 1>&6
+! echo "configure:2774: checking for pthread_create in -lc" >&5
+  ac_lib_var=`echo c'_'pthread_create | sed 'y%./+-%__p_%'`
+  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+--- 2778,2784 ----
+  else
+    echo "$ac_t""no" 1>&6
+  echo $ac_n "checking for pthread_create in -lc""... $ac_c" 1>&6
+! echo "configure:2782: checking for pthread_create in -lc" >&5
+  ac_lib_var=`echo c'_'pthread_create | sed 'y%./+-%__p_%'`
+  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+***************
+*** 2778,2784 ****
+    ac_save_LIBS="$LIBS"
+  LIBS="-lc  $LIBS"
+  cat > conftest.$ac_ext <<EOF
+! #line 2782 "configure"
+  #include "confdefs.h"
+  /* Override any gcc2 internal prototype to avoid an error.  */
+  /* We use char because int might match the return type of a gcc2
+--- 2786,2792 ----
+    ac_save_LIBS="$LIBS"
+  LIBS="-lc  $LIBS"
+  cat > conftest.$ac_ext <<EOF
+! #line 2790 "configure"
+  #include "confdefs.h"
+  /* Override any gcc2 internal prototype to avoid an error.  */
+  /* We use char because int might match the return type of a gcc2
+***************
+*** 2789,2795 ****
+  pthread_create()
+  ; return 0; }
+  EOF
+! if { (eval echo configure:2793: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_lib_$ac_lib_var=yes"
+  else
+--- 2797,2803 ----
+  pthread_create()
+  ; return 0; }
+  EOF
+! if { (eval echo configure:2801: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_lib_$ac_lib_var=yes"
+  else
+***************
+*** 2835,2841 ****
+       # We'd like to use sigwait() too
+       #
+       echo $ac_n "checking for sigwait in -lc""... $ac_c" 1>&6
+! echo "configure:2839: checking for sigwait in -lc" >&5
+  ac_lib_var=`echo c'_'sigwait | sed 'y%./+-%__p_%'`
+  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+--- 2843,2849 ----
+       # We'd like to use sigwait() too
+       #
+       echo $ac_n "checking for sigwait in -lc""... $ac_c" 1>&6
+! echo "configure:2847: checking for sigwait in -lc" >&5
+  ac_lib_var=`echo c'_'sigwait | sed 'y%./+-%__p_%'`
+  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+***************
+*** 2843,2849 ****
+    ac_save_LIBS="$LIBS"
+  LIBS="-lc  $LIBS"
+  cat > conftest.$ac_ext <<EOF
+! #line 2847 "configure"
+  #include "confdefs.h"
+  /* Override any gcc2 internal prototype to avoid an error.  */
+  /* We use char because int might match the return type of a gcc2
+--- 2851,2857 ----
+    ac_save_LIBS="$LIBS"
+  LIBS="-lc  $LIBS"
+  cat > conftest.$ac_ext <<EOF
+! #line 2855 "configure"
+  #include "confdefs.h"
+  /* Override any gcc2 internal prototype to avoid an error.  */
+  /* We use char because int might match the return type of a gcc2
+***************
+*** 2854,2860 ****
+  sigwait()
+  ; return 0; }
+  EOF
+! if { (eval echo configure:2858: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_lib_$ac_lib_var=yes"
+  else
+--- 2862,2868 ----
+  sigwait()
+  ; return 0; }
+  EOF
+! if { (eval echo configure:2866: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_lib_$ac_lib_var=yes"
+  else
+***************
+*** 2876,2882 ****
+  else
+    echo "$ac_t""no" 1>&6
+  echo $ac_n "checking for sigwait in -lpthread""... $ac_c" 1>&6
+! echo "configure:2880: checking for sigwait in -lpthread" >&5
+  ac_lib_var=`echo pthread'_'sigwait | sed 'y%./+-%__p_%'`
+  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+--- 2884,2890 ----
+  else
+    echo "$ac_t""no" 1>&6
+  echo $ac_n "checking for sigwait in -lpthread""... $ac_c" 1>&6
+! echo "configure:2888: checking for sigwait in -lpthread" >&5
+  ac_lib_var=`echo pthread'_'sigwait | sed 'y%./+-%__p_%'`
+  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+***************
+*** 2884,2890 ****
+    ac_save_LIBS="$LIBS"
+  LIBS="-lpthread  $LIBS"
+  cat > conftest.$ac_ext <<EOF
+! #line 2888 "configure"
+  #include "confdefs.h"
+  /* Override any gcc2 internal prototype to avoid an error.  */
+  /* We use char because int might match the return type of a gcc2
+--- 2892,2898 ----
+    ac_save_LIBS="$LIBS"
+  LIBS="-lpthread  $LIBS"
+  cat > conftest.$ac_ext <<EOF
+! #line 2896 "configure"
+  #include "confdefs.h"
+  /* Override any gcc2 internal prototype to avoid an error.  */
+  /* We use char because int might match the return type of a gcc2
+***************
+*** 2895,2901 ****
+  sigwait()
+  ; return 0; }
+  EOF
+! if { (eval echo configure:2899: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_lib_$ac_lib_var=yes"
+  else
+--- 2903,2909 ----
+  sigwait()
+  ; return 0; }
+  EOF
+! if { (eval echo configure:2907: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_lib_$ac_lib_var=yes"
+  else
+***************
+*** 2917,2923 ****
+  else
+    echo "$ac_t""no" 1>&6
+  echo $ac_n "checking for _Psigwait in -lpthread""... $ac_c" 1>&6
+! echo "configure:2921: checking for _Psigwait in -lpthread" >&5
+  ac_lib_var=`echo pthread'_'_Psigwait | sed 'y%./+-%__p_%'`
+  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+--- 2925,2931 ----
+  else
+    echo "$ac_t""no" 1>&6
+  echo $ac_n "checking for _Psigwait in -lpthread""... $ac_c" 1>&6
+! echo "configure:2929: checking for _Psigwait in -lpthread" >&5
+  ac_lib_var=`echo pthread'_'_Psigwait | sed 'y%./+-%__p_%'`
+  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+***************
+*** 2925,2931 ****
+    ac_save_LIBS="$LIBS"
+  LIBS="-lpthread  $LIBS"
+  cat > conftest.$ac_ext <<EOF
+! #line 2929 "configure"
+  #include "confdefs.h"
+  /* Override any gcc2 internal prototype to avoid an error.  */
+  /* We use char because int might match the return type of a gcc2
+--- 2933,2939 ----
+    ac_save_LIBS="$LIBS"
+  LIBS="-lpthread  $LIBS"
+  cat > conftest.$ac_ext <<EOF
+! #line 2937 "configure"
+  #include "confdefs.h"
+  /* Override any gcc2 internal prototype to avoid an error.  */
+  /* We use char because int might match the return type of a gcc2
+***************
+*** 2936,2942 ****
+  _Psigwait()
+  ; return 0; }
+  EOF
+! if { (eval echo configure:2940: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_lib_$ac_lib_var=yes"
+  else
+--- 2944,2950 ----
+  _Psigwait()
+  ; return 0; }
+  EOF
+! if { (eval echo configure:2948: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_lib_$ac_lib_var=yes"
+  else
+***************
+*** 2966,2977 ****
+  
+  
+       echo $ac_n "checking for pthread_attr_getstacksize""... $ac_c" 1>&6
+! echo "configure:2970: checking for pthread_attr_getstacksize" >&5
+  if eval "test \"`echo '$''{'ac_cv_func_pthread_attr_getstacksize'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 2975 "configure"
+  #include "confdefs.h"
+  /* System header to define __stub macros and hopefully few prototypes,
+      which can conflict with char pthread_attr_getstacksize(); below.  */
+--- 2974,2985 ----
+  
+  
+       echo $ac_n "checking for pthread_attr_getstacksize""... $ac_c" 1>&6
+! echo "configure:2978: checking for pthread_attr_getstacksize" >&5
+  if eval "test \"`echo '$''{'ac_cv_func_pthread_attr_getstacksize'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 2983 "configure"
+  #include "confdefs.h"
+  /* System header to define __stub macros and hopefully few prototypes,
+      which can conflict with char pthread_attr_getstacksize(); below.  */
+***************
+*** 2994,3000 ****
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:2998: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_func_pthread_attr_getstacksize=yes"
+  else
+--- 3002,3008 ----
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:3006: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_func_pthread_attr_getstacksize=yes"
+  else
+***************
+*** 3026,3032 ****
+               #
+               *-freebsd*)
+                       echo $ac_n "checking for sigwait in -lc_r""... $ac_c" 1>&6
+! echo "configure:3030: checking for sigwait in -lc_r" >&5
+  ac_lib_var=`echo c_r'_'sigwait | sed 'y%./+-%__p_%'`
+  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+--- 3034,3040 ----
+               #
+               *-freebsd*)
+                       echo $ac_n "checking for sigwait in -lc_r""... $ac_c" 1>&6
+! echo "configure:3038: checking for sigwait in -lc_r" >&5
+  ac_lib_var=`echo c_r'_'sigwait | sed 'y%./+-%__p_%'`
+  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+***************
+*** 3034,3040 ****
+    ac_save_LIBS="$LIBS"
+  LIBS="-lc_r  $LIBS"
+  cat > conftest.$ac_ext <<EOF
+! #line 3038 "configure"
+  #include "confdefs.h"
+  /* Override any gcc2 internal prototype to avoid an error.  */
+  /* We use char because int might match the return type of a gcc2
+--- 3042,3048 ----
+    ac_save_LIBS="$LIBS"
+  LIBS="-lc_r  $LIBS"
+  cat > conftest.$ac_ext <<EOF
+! #line 3046 "configure"
+  #include "confdefs.h"
+  /* Override any gcc2 internal prototype to avoid an error.  */
+  /* We use char because int might match the return type of a gcc2
+***************
+*** 3045,3051 ****
+  sigwait()
+  ; return 0; }
+  EOF
+! if { (eval echo configure:3049: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_lib_$ac_lib_var=yes"
+  else
+--- 3053,3059 ----
+  sigwait()
+  ; return 0; }
+  EOF
+! if { (eval echo configure:3057: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_lib_$ac_lib_var=yes"
+  else
+***************
+*** 3100,3111 ****
+  EOF
+  
+                       echo $ac_n "checking for pthread_setconcurrency""... $ac_c" 1>&6
+! echo "configure:3104: checking for pthread_setconcurrency" >&5
+  if eval "test \"`echo '$''{'ac_cv_func_pthread_setconcurrency'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 3109 "configure"
+  #include "confdefs.h"
+  /* System header to define __stub macros and hopefully few prototypes,
+      which can conflict with char pthread_setconcurrency(); below.  */
+--- 3108,3119 ----
+  EOF
+  
+                       echo $ac_n "checking for pthread_setconcurrency""... $ac_c" 1>&6
+! echo "configure:3112: checking for pthread_setconcurrency" >&5
+  if eval "test \"`echo '$''{'ac_cv_func_pthread_setconcurrency'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 3117 "configure"
+  #include "confdefs.h"
+  /* System header to define __stub macros and hopefully few prototypes,
+      which can conflict with char pthread_setconcurrency(); below.  */
+***************
+*** 3128,3134 ****
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:3132: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_func_pthread_setconcurrency=yes"
+  else
+--- 3136,3142 ----
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:3140: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_func_pthread_setconcurrency=yes"
+  else
+***************
+*** 3166,3177 ****
+       # Look for sysconf to allow detection of the number of processors.
+       #
+       echo $ac_n "checking for sysconf""... $ac_c" 1>&6
+! echo "configure:3170: checking for sysconf" >&5
+  if eval "test \"`echo '$''{'ac_cv_func_sysconf'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 3175 "configure"
+  #include "confdefs.h"
+  /* System header to define __stub macros and hopefully few prototypes,
+      which can conflict with char sysconf(); below.  */
+--- 3174,3185 ----
+       # Look for sysconf to allow detection of the number of processors.
+       #
+       echo $ac_n "checking for sysconf""... $ac_c" 1>&6
+! echo "configure:3178: checking for sysconf" >&5
+  if eval "test \"`echo '$''{'ac_cv_func_sysconf'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 3183 "configure"
+  #include "confdefs.h"
+  /* System header to define __stub macros and hopefully few prototypes,
+      which can conflict with char sysconf(); below.  */
+***************
+*** 3194,3200 ****
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:3198: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_func_sysconf=yes"
+  else
+--- 3202,3208 ----
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:3206: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_func_sysconf=yes"
+  else
+***************
+*** 3275,3286 ****
+  # be defined.
+  #
+  echo $ac_n "checking for flockfile""... $ac_c" 1>&6
+! echo "configure:3279: checking for flockfile" >&5
+  if eval "test \"`echo '$''{'ac_cv_func_flockfile'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 3284 "configure"
+  #include "confdefs.h"
+  /* System header to define __stub macros and hopefully few prototypes,
+      which can conflict with char flockfile(); below.  */
+--- 3283,3294 ----
+  # be defined.
+  #
+  echo $ac_n "checking for flockfile""... $ac_c" 1>&6
+! echo "configure:3287: checking for flockfile" >&5
+  if eval "test \"`echo '$''{'ac_cv_func_flockfile'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 3292 "configure"
+  #include "confdefs.h"
+  /* System header to define __stub macros and hopefully few prototypes,
+      which can conflict with char flockfile(); below.  */
+***************
+*** 3303,3309 ****
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:3307: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_func_flockfile=yes"
+  else
+--- 3311,3317 ----
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:3315: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_func_flockfile=yes"
+  else
+***************
+*** 3326,3337 ****
+  fi
+  
+  echo $ac_n "checking for getc_unlocked""... $ac_c" 1>&6
+! echo "configure:3330: checking for getc_unlocked" >&5
+  if eval "test \"`echo '$''{'ac_cv_func_getc_unlocked'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 3335 "configure"
+  #include "confdefs.h"
+  /* System header to define __stub macros and hopefully few prototypes,
+      which can conflict with char getc_unlocked(); below.  */
+--- 3334,3345 ----
+  fi
+  
+  echo $ac_n "checking for getc_unlocked""... $ac_c" 1>&6
+! echo "configure:3338: checking for getc_unlocked" >&5
+  if eval "test \"`echo '$''{'ac_cv_func_getc_unlocked'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 3343 "configure"
+  #include "confdefs.h"
+  /* System header to define __stub macros and hopefully few prototypes,
+      which can conflict with char getc_unlocked(); below.  */
+***************
+*** 3354,3360 ****
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:3358: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_func_getc_unlocked=yes"
+  else
+--- 3362,3368 ----
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:3366: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_func_getc_unlocked=yes"
+  else
+***************
+*** 3381,3387 ****
+  # Indicate what the final decision was regarding threads.
+  #
+  echo $ac_n "checking whether to build with threads""... $ac_c" 1>&6
+! echo "configure:3385: checking whether to build with threads" >&5
+  if $use_threads; then
+       echo "$ac_t""yes" 1>&6
+  else
+--- 3389,3395 ----
+  # Indicate what the final decision was regarding threads.
+  #
+  echo $ac_n "checking whether to build with threads""... $ac_c" 1>&6
+! echo "configure:3393: checking whether to build with threads" >&5
+  if $use_threads; then
+       echo "$ac_t""yes" 1>&6
+  else
+***************
+*** 3457,3468 ****
+  # NLS
+  #
+  echo $ac_n "checking for catgets""... $ac_c" 1>&6
+! echo "configure:3461: checking for catgets" >&5
+  if eval "test \"`echo '$''{'ac_cv_func_catgets'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 3466 "configure"
+  #include "confdefs.h"
+  /* System header to define __stub macros and hopefully few prototypes,
+      which can conflict with char catgets(); below.  */
+--- 3465,3476 ----
+  # NLS
+  #
+  echo $ac_n "checking for catgets""... $ac_c" 1>&6
+! echo "configure:3469: checking for catgets" >&5
+  if eval "test \"`echo '$''{'ac_cv_func_catgets'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 3474 "configure"
+  #include "confdefs.h"
+  /* System header to define __stub macros and hopefully few prototypes,
+      which can conflict with char catgets(); below.  */
+***************
+*** 3485,3491 ****
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:3489: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_func_catgets=yes"
+  else
+--- 3493,3499 ----
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:3497: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_func_catgets=yes"
+  else
+***************
+*** 3523,3529 ****
+               ;;
+       *)
+               echo $ac_n "checking for socket in -lsocket""... $ac_c" 1>&6
+! echo "configure:3527: checking for socket in -lsocket" >&5
+  ac_lib_var=`echo socket'_'socket | sed 'y%./+-%__p_%'`
+  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+--- 3531,3537 ----
+               ;;
+       *)
+               echo $ac_n "checking for socket in -lsocket""... $ac_c" 1>&6
+! echo "configure:3535: checking for socket in -lsocket" >&5
+  ac_lib_var=`echo socket'_'socket | sed 'y%./+-%__p_%'`
+  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+***************
+*** 3531,3537 ****
+    ac_save_LIBS="$LIBS"
+  LIBS="-lsocket  $LIBS"
+  cat > conftest.$ac_ext <<EOF
+! #line 3535 "configure"
+  #include "confdefs.h"
+  /* Override any gcc2 internal prototype to avoid an error.  */
+  /* We use char because int might match the return type of a gcc2
+--- 3539,3545 ----
+    ac_save_LIBS="$LIBS"
+  LIBS="-lsocket  $LIBS"
+  cat > conftest.$ac_ext <<EOF
+! #line 3543 "configure"
+  #include "confdefs.h"
+  /* Override any gcc2 internal prototype to avoid an error.  */
+  /* We use char because int might match the return type of a gcc2
+***************
+*** 3542,3548 ****
+  socket()
+  ; return 0; }
+  EOF
+! if { (eval echo configure:3546: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_lib_$ac_lib_var=yes"
+  else
+--- 3550,3556 ----
+  socket()
+  ; return 0; }
+  EOF
+! if { (eval echo configure:3554: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_lib_$ac_lib_var=yes"
+  else
+***************
+*** 3570,3576 ****
+  fi
+  
+               echo $ac_n "checking for inet_ntoa in -lnsl""... $ac_c" 1>&6
+! echo "configure:3574: checking for inet_ntoa in -lnsl" >&5
+  ac_lib_var=`echo nsl'_'inet_ntoa | sed 'y%./+-%__p_%'`
+  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+--- 3578,3584 ----
+  fi
+  
+               echo $ac_n "checking for inet_ntoa in -lnsl""... $ac_c" 1>&6
+! echo "configure:3582: checking for inet_ntoa in -lnsl" >&5
+  ac_lib_var=`echo nsl'_'inet_ntoa | sed 'y%./+-%__p_%'`
+  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+***************
+*** 3578,3584 ****
+    ac_save_LIBS="$LIBS"
+  LIBS="-lnsl  $LIBS"
+  cat > conftest.$ac_ext <<EOF
+! #line 3582 "configure"
+  #include "confdefs.h"
+  /* Override any gcc2 internal prototype to avoid an error.  */
+  /* We use char because int might match the return type of a gcc2
+--- 3586,3592 ----
+    ac_save_LIBS="$LIBS"
+  LIBS="-lnsl  $LIBS"
+  cat > conftest.$ac_ext <<EOF
+! #line 3590 "configure"
+  #include "confdefs.h"
+  /* Override any gcc2 internal prototype to avoid an error.  */
+  /* We use char because int might match the return type of a gcc2
+***************
+*** 3589,3595 ****
+  inet_ntoa()
+  ; return 0; }
+  EOF
+! if { (eval echo configure:3593: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_lib_$ac_lib_var=yes"
+  else
+--- 3597,3603 ----
+  inet_ntoa()
+  ; return 0; }
+  EOF
+! if { (eval echo configure:3601: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_lib_$ac_lib_var=yes"
+  else
+***************
+*** 3623,3629 ****
+  # Purify support
+  #
+  echo $ac_n "checking whether to use purify""... $ac_c" 1>&6
+! echo "configure:3627: checking whether to use purify" >&5
+  # Check whether --with-purify or --without-purify was given.
+  if test "${with_purify+set}" = set; then
+    withval="$with_purify"
+--- 3631,3637 ----
+  # Purify support
+  #
+  echo $ac_n "checking whether to use purify""... $ac_c" 1>&6
+! echo "configure:3635: checking whether to use purify" >&5
+  # Check whether --with-purify or --without-purify was given.
+  if test "${with_purify+set}" = set; then
+    withval="$with_purify"
+***************
+*** 3640,3646 ****
+               # Extract the first word of "purify", so it can be a program name with args.
+  set dummy purify; ac_word=$2
+  echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+! echo "configure:3644: checking for $ac_word" >&5
+  if eval "test \"`echo '$''{'ac_cv_path_purify_path'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+--- 3648,3654 ----
+               # Extract the first word of "purify", so it can be a program name with args.
+  set dummy purify; ac_word=$2
+  echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+! echo "configure:3652: checking for $ac_word" >&5
+  if eval "test \"`echo '$''{'ac_cv_path_purify_path'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+***************
+*** 3717,3728 ****
+  case $use_libtool in
+       yes)
+               echo $ac_n "checking for Cygwin environment""... $ac_c" 1>&6
+! echo "configure:3721: checking for Cygwin environment" >&5
+  if eval "test \"`echo '$''{'ac_cv_cygwin'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 3726 "configure"
+  #include "confdefs.h"
+  
+  int main() {
+--- 3725,3736 ----
+  case $use_libtool in
+       yes)
+               echo $ac_n "checking for Cygwin environment""... $ac_c" 1>&6
+! echo "configure:3729: checking for Cygwin environment" >&5
+  if eval "test \"`echo '$''{'ac_cv_cygwin'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 3734 "configure"
+  #include "confdefs.h"
+  
+  int main() {
+***************
+*** 3733,3739 ****
+  return __CYGWIN__;
+  ; return 0; }
+  EOF
+! if { (eval echo configure:3737: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    ac_cv_cygwin=yes
+  else
+--- 3741,3747 ----
+  return __CYGWIN__;
+  ; return 0; }
+  EOF
+! if { (eval echo configure:3745: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    ac_cv_cygwin=yes
+  else
+***************
+*** 3750,3768 ****
+  CYGWIN=
+  test "$ac_cv_cygwin" = yes && CYGWIN=yes
+  echo $ac_n "checking for mingw32 environment""... $ac_c" 1>&6
+! echo "configure:3754: checking for mingw32 environment" >&5
+  if eval "test \"`echo '$''{'ac_cv_mingw32'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 3759 "configure"
+  #include "confdefs.h"
+  
+  int main() {
+  return __MINGW32__;
+  ; return 0; }
+  EOF
+! if { (eval echo configure:3766: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    ac_cv_mingw32=yes
+  else
+--- 3758,3776 ----
+  CYGWIN=
+  test "$ac_cv_cygwin" = yes && CYGWIN=yes
+  echo $ac_n "checking for mingw32 environment""... $ac_c" 1>&6
+! echo "configure:3762: checking for mingw32 environment" >&5
+  if eval "test \"`echo '$''{'ac_cv_mingw32'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 3767 "configure"
+  #include "confdefs.h"
+  
+  int main() {
+  return __MINGW32__;
+  ; return 0; }
+  EOF
+! if { (eval echo configure:3774: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    ac_cv_mingw32=yes
+  else
+***************
+*** 3848,3854 ****
+  fi
+  
+  echo $ac_n "checking build system type""... $ac_c" 1>&6
+! echo "configure:3852: checking build system type" >&5
+  
+  build_alias=$build
+  case "$build_alias" in
+--- 3856,3862 ----
+  fi
+  
+  echo $ac_n "checking build system type""... $ac_c" 1>&6
+! echo "configure:3860: checking build system type" >&5
+  
+  build_alias=$build
+  case "$build_alias" in
+***************
+*** 3877,3883 ****
+  if test "$GCC" = yes; then
+    # Check if gcc -print-prog-name=ld gives a path.
+    echo $ac_n "checking for ld used by GCC""... $ac_c" 1>&6
+! echo "configure:3881: checking for ld used by GCC" >&5
+    case $host in
+    *-*-mingw*)
+      # gcc leaves a trailing carriage return which upsets mingw
+--- 3885,3891 ----
+  if test "$GCC" = yes; then
+    # Check if gcc -print-prog-name=ld gives a path.
+    echo $ac_n "checking for ld used by GCC""... $ac_c" 1>&6
+! echo "configure:3889: checking for ld used by GCC" >&5
+    case $host in
+    *-*-mingw*)
+      # gcc leaves a trailing carriage return which upsets mingw
+***************
+*** 3907,3916 ****
+    esac
+  elif test "$with_gnu_ld" = yes; then
+    echo $ac_n "checking for GNU ld""... $ac_c" 1>&6
+! echo "configure:3911: checking for GNU ld" >&5
+  else
+    echo $ac_n "checking for non-GNU ld""... $ac_c" 1>&6
+! echo "configure:3914: checking for non-GNU ld" >&5
+  fi
+  if eval "test \"`echo '$''{'lt_cv_path_LD'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+--- 3915,3924 ----
+    esac
+  elif test "$with_gnu_ld" = yes; then
+    echo $ac_n "checking for GNU ld""... $ac_c" 1>&6
+! echo "configure:3919: checking for GNU ld" >&5
+  else
+    echo $ac_n "checking for non-GNU ld""... $ac_c" 1>&6
+! echo "configure:3922: checking for non-GNU ld" >&5
+  fi
+  if eval "test \"`echo '$''{'lt_cv_path_LD'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+***************
+*** 3945,3951 ****
+  fi
+  test -z "$LD" && { echo "configure: error: no acceptable ld found in \$PATH" 1>&2; exit 1; }
+  echo $ac_n "checking if the linker ($LD) is GNU ld""... $ac_c" 1>&6
+! echo "configure:3949: checking if the linker ($LD) is GNU ld" >&5
+  if eval "test \"`echo '$''{'lt_cv_prog_gnu_ld'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+--- 3953,3959 ----
+  fi
+  test -z "$LD" && { echo "configure: error: no acceptable ld found in \$PATH" 1>&2; exit 1; }
+  echo $ac_n "checking if the linker ($LD) is GNU ld""... $ac_c" 1>&6
+! echo "configure:3957: checking if the linker ($LD) is GNU ld" >&5
+  if eval "test \"`echo '$''{'lt_cv_prog_gnu_ld'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+***************
+*** 3962,3968 ****
+  
+  
+  echo $ac_n "checking for $LD option to reload object files""... $ac_c" 1>&6
+! echo "configure:3966: checking for $LD option to reload object files" >&5
+  if eval "test \"`echo '$''{'lt_cv_ld_reload_flag'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+--- 3970,3976 ----
+  
+  
+  echo $ac_n "checking for $LD option to reload object files""... $ac_c" 1>&6
+! echo "configure:3974: checking for $LD option to reload object files" >&5
+  if eval "test \"`echo '$''{'lt_cv_ld_reload_flag'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+***************
+*** 3974,3980 ****
+  test -n "$reload_flag" && reload_flag=" $reload_flag"
+  
+  echo $ac_n "checking for BSD-compatible nm""... $ac_c" 1>&6
+! echo "configure:3978: checking for BSD-compatible nm" >&5
+  if eval "test \"`echo '$''{'lt_cv_path_NM'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+--- 3982,3988 ----
+  test -n "$reload_flag" && reload_flag=" $reload_flag"
+  
+  echo $ac_n "checking for BSD-compatible nm""... $ac_c" 1>&6
+! echo "configure:3986: checking for BSD-compatible nm" >&5
+  if eval "test \"`echo '$''{'lt_cv_path_NM'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+***************
+*** 4012,4018 ****
+  echo "$ac_t""$NM" 1>&6
+  
+  echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6
+! echo "configure:4016: checking whether ln -s works" >&5
+  if eval "test \"`echo '$''{'ac_cv_prog_LN_S'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+--- 4020,4026 ----
+  echo "$ac_t""$NM" 1>&6
+  
+  echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6
+! echo "configure:4024: checking whether ln -s works" >&5
+  if eval "test \"`echo '$''{'ac_cv_prog_LN_S'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+***************
+*** 4033,4039 ****
+  fi
+  
+  echo $ac_n "checking how to recognise dependant libraries""... $ac_c" 1>&6
+! echo "configure:4037: checking how to recognise dependant libraries" >&5
+  if eval "test \"`echo '$''{'lt_cv_deplibs_check_method'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+--- 4041,4047 ----
+  fi
+  
+  echo $ac_n "checking how to recognise dependant libraries""... $ac_c" 1>&6
+! echo "configure:4045: checking how to recognise dependant libraries" >&5
+  if eval "test \"`echo '$''{'lt_cv_deplibs_check_method'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+***************
+*** 4206,4218 ****
+  deplibs_check_method=$lt_cv_deplibs_check_method
+  
+  echo $ac_n "checking for object suffix""... $ac_c" 1>&6
+! echo "configure:4210: checking for object suffix" >&5
+  if eval "test \"`echo '$''{'ac_cv_objext'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    rm -f conftest*
+  echo 'int i = 1;' > conftest.$ac_ext
+! if { (eval echo configure:4216: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    for ac_file in conftest.*; do
+      case $ac_file in
+      *.c) ;;
+--- 4214,4226 ----
+  deplibs_check_method=$lt_cv_deplibs_check_method
+  
+  echo $ac_n "checking for object suffix""... $ac_c" 1>&6
+! echo "configure:4218: checking for object suffix" >&5
+  if eval "test \"`echo '$''{'ac_cv_objext'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    rm -f conftest*
+  echo 'int i = 1;' > conftest.$ac_ext
+! if { (eval echo configure:4224: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    for ac_file in conftest.*; do
+      case $ac_file in
+      *.c) ;;
+***************
+*** 4232,4238 ****
+  
+  
+  echo $ac_n "checking for executable suffix""... $ac_c" 1>&6
+! echo "configure:4236: checking for executable suffix" >&5
+  if eval "test \"`echo '$''{'ac_cv_exeext'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+--- 4240,4246 ----
+  
+  
+  echo $ac_n "checking for executable suffix""... $ac_c" 1>&6
+! echo "configure:4244: checking for executable suffix" >&5
+  if eval "test \"`echo '$''{'ac_cv_exeext'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+***************
+*** 4242,4251 ****
+    rm -f conftest*
+    echo 'int main () { return 0; }' > conftest.$ac_ext
+    ac_cv_exeext=
+!   if { (eval echo configure:4246: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
+      for file in conftest.*; do
+        case $file in
+!       *.c | *.o | *.obj) ;;
+        *) ac_cv_exeext=`echo $file | sed -e s/conftest//` ;;
+        esac
+      done
+--- 4250,4259 ----
+    rm -f conftest*
+    echo 'int main () { return 0; }' > conftest.$ac_ext
+    ac_cv_exeext=
+!   if { (eval echo configure:4254: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
+      for file in conftest.*; do
+        case $file in
+!       *.c | *.C | *.o | *.obj) ;;
+        *) ac_cv_exeext=`echo $file | sed -e s/conftest//` ;;
+        esac
+      done
+***************
+*** 4273,4279 ****
+  
+  # Check for command to grab the raw symbol name followed by C symbol from nm.
+  echo $ac_n "checking command to parse $NM output""... $ac_c" 1>&6
+! echo "configure:4277: checking command to parse $NM output" >&5
+  if eval "test \"`echo '$''{'lt_cv_sys_global_symbol_pipe'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+--- 4281,4287 ----
+  
+  # Check for command to grab the raw symbol name followed by C symbol from nm.
+  echo $ac_n "checking command to parse $NM output""... $ac_c" 1>&6
+! echo "configure:4285: checking command to parse $NM output" >&5
+  if eval "test \"`echo '$''{'lt_cv_sys_global_symbol_pipe'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+***************
+*** 4349,4358 ****
+  int main(){nm_test_var='a';nm_test_func();return(0);}
+  EOF
+  
+!   if { (eval echo configure:4353: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+      # Now try to grab the symbols.
+      nlist=conftest.nm
+!     if { (eval echo configure:4356: \"$NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist\") 1>&5; (eval $NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) 2>&5; } && test -s "$nlist"; then
+        # Try sorting and uniquifying the output.
+        if sort "$nlist" | uniq > "$nlist"T; then
+       mv -f "$nlist"T "$nlist"
+--- 4357,4366 ----
+  int main(){nm_test_var='a';nm_test_func();return(0);}
+  EOF
+  
+!   if { (eval echo configure:4361: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+      # Now try to grab the symbols.
+      nlist=conftest.nm
+!     if { (eval echo configure:4364: \"$NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist\") 1>&5; (eval $NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) 2>&5; } && test -s "$nlist"; then
+        # Try sorting and uniquifying the output.
+        if sort "$nlist" | uniq > "$nlist"T; then
+       mv -f "$nlist"T "$nlist"
+***************
+*** 4403,4409 ****
+         save_CFLAGS="$CFLAGS"
+         LIBS="conftstm.$ac_objext"
+         CFLAGS="$CFLAGS$no_builtin_flag"
+!        if { (eval echo configure:4407: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+           pipe_works=yes
+         fi
+         LIBS="$save_LIBS"
+--- 4411,4417 ----
+         save_CFLAGS="$CFLAGS"
+         LIBS="conftstm.$ac_objext"
+         CFLAGS="$CFLAGS$no_builtin_flag"
+!        if { (eval echo configure:4415: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+           pipe_works=yes
+         fi
+         LIBS="$save_LIBS"
+***************
+*** 4449,4465 ****
+  do
+  ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+  echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+! echo "configure:4453: checking for $ac_hdr" >&5
+  if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 4458 "configure"
+  #include "confdefs.h"
+  #include <$ac_hdr>
+  EOF
+  ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+! { (eval echo configure:4463: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+  ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+  if test -z "$ac_err"; then
+    rm -rf conftest*
+--- 4457,4473 ----
+  do
+  ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+  echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+! echo "configure:4461: checking for $ac_hdr" >&5
+  if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 4466 "configure"
+  #include "confdefs.h"
+  #include <$ac_hdr>
+  EOF
+  ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+! { (eval echo configure:4471: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+  ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+  if test -z "$ac_err"; then
+    rm -rf conftest*
+***************
+*** 4494,4500 ****
+  file_magic*)
+    if test "$file_magic_cmd" = '$MAGIC_CMD'; then
+      echo $ac_n "checking for ${ac_tool_prefix}file""... $ac_c" 1>&6
+! echo "configure:4498: checking for ${ac_tool_prefix}file" >&5
+  if eval "test \"`echo '$''{'lt_cv_path_MAGIC_CMD'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+--- 4502,4508 ----
+  file_magic*)
+    if test "$file_magic_cmd" = '$MAGIC_CMD'; then
+      echo $ac_n "checking for ${ac_tool_prefix}file""... $ac_c" 1>&6
+! echo "configure:4506: checking for ${ac_tool_prefix}file" >&5
+  if eval "test \"`echo '$''{'lt_cv_path_MAGIC_CMD'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+***************
+*** 4556,4562 ****
+  if test -z "$lt_cv_path_MAGIC_CMD"; then
+    if test -n "$ac_tool_prefix"; then
+      echo $ac_n "checking for file""... $ac_c" 1>&6
+! echo "configure:4560: checking for file" >&5
+  if eval "test \"`echo '$''{'lt_cv_path_MAGIC_CMD'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+--- 4564,4570 ----
+  if test -z "$lt_cv_path_MAGIC_CMD"; then
+    if test -n "$ac_tool_prefix"; then
+      echo $ac_n "checking for file""... $ac_c" 1>&6
+! echo "configure:4568: checking for file" >&5
+  if eval "test \"`echo '$''{'lt_cv_path_MAGIC_CMD'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+***************
+*** 4627,4633 ****
+  # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
+  set dummy ${ac_tool_prefix}ranlib; ac_word=$2
+  echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+! echo "configure:4631: checking for $ac_word" >&5
+  if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+--- 4635,4641 ----
+  # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
+  set dummy ${ac_tool_prefix}ranlib; ac_word=$2
+  echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+! echo "configure:4639: checking for $ac_word" >&5
+  if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+***************
+*** 4659,4665 ****
+    # Extract the first word of "ranlib", so it can be a program name with args.
+  set dummy ranlib; ac_word=$2
+  echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+! echo "configure:4663: checking for $ac_word" >&5
+  if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+--- 4667,4673 ----
+    # Extract the first word of "ranlib", so it can be a program name with args.
+  set dummy ranlib; ac_word=$2
+  echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+! echo "configure:4671: checking for $ac_word" >&5
+  if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+***************
+*** 4694,4700 ****
+  # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
+  set dummy ${ac_tool_prefix}strip; ac_word=$2
+  echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+! echo "configure:4698: checking for $ac_word" >&5
+  if eval "test \"`echo '$''{'ac_cv_prog_STRIP'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+--- 4702,4708 ----
+  # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
+  set dummy ${ac_tool_prefix}strip; ac_word=$2
+  echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+! echo "configure:4706: checking for $ac_word" >&5
+  if eval "test \"`echo '$''{'ac_cv_prog_STRIP'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+***************
+*** 4726,4732 ****
+    # Extract the first word of "strip", so it can be a program name with args.
+  set dummy strip; ac_word=$2
+  echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+! echo "configure:4730: checking for $ac_word" >&5
+  if eval "test \"`echo '$''{'ac_cv_prog_STRIP'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+--- 4734,4740 ----
+    # Extract the first word of "strip", so it can be a program name with args.
+  set dummy strip; ac_word=$2
+  echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+! echo "configure:4738: checking for $ac_word" >&5
+  if eval "test \"`echo '$''{'ac_cv_prog_STRIP'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+***************
+*** 4775,4782 ****
+  case $host in
+  *-*-irix6*)
+    # Find out which ABI we are using.
+!   echo '#line 4779 "configure"' > conftest.$ac_ext
+!   if { (eval echo configure:4780: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+      case `/usr/bin/file conftest.$ac_objext` in
+      *32-bit*)
+        LD="${LD-ld} -32"
+--- 4783,4790 ----
+  case $host in
+  *-*-irix6*)
+    # Find out which ABI we are using.
+!   echo '#line 4787 "configure"' > conftest.$ac_ext
+!   if { (eval echo configure:4788: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+      case `/usr/bin/file conftest.$ac_objext` in
+      *32-bit*)
+        LD="${LD-ld} -32"
+***************
+*** 4797,4803 ****
+    SAVE_CFLAGS="$CFLAGS"
+    CFLAGS="$CFLAGS -belf"
+    echo $ac_n "checking whether the C compiler needs -belf""... $ac_c" 1>&6
+! echo "configure:4801: checking whether the C compiler needs -belf" >&5
+  if eval "test \"`echo '$''{'lt_cv_cc_needs_belf'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+--- 4805,4811 ----
+    SAVE_CFLAGS="$CFLAGS"
+    CFLAGS="$CFLAGS -belf"
+    echo $ac_n "checking whether the C compiler needs -belf""... $ac_c" 1>&6
+! echo "configure:4809: checking whether the C compiler needs -belf" >&5
+  if eval "test \"`echo '$''{'lt_cv_cc_needs_belf'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+***************
+*** 4810,4823 ****
+  cross_compiling=$ac_cv_prog_cc_cross
+  
+       cat > conftest.$ac_ext <<EOF
+! #line 4814 "configure"
+  #include "confdefs.h"
+  
+  int main() {
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:4821: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    lt_cv_cc_needs_belf=yes
+  else
+--- 4818,4831 ----
+  cross_compiling=$ac_cv_prog_cc_cross
+  
+       cat > conftest.$ac_ext <<EOF
+! #line 4822 "configure"
+  #include "confdefs.h"
+  
+  int main() {
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:4829: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    lt_cv_cc_needs_belf=yes
+  else
+***************
+*** 4932,4938 ****
+  ## FIXME: this should be a separate macro
+  ##
+  echo $ac_n "checking for objdir""... $ac_c" 1>&6
+! echo "configure:4936: checking for objdir" >&5
+  rm -f .libs 2>/dev/null
+  mkdir .libs 2>/dev/null
+  if test -d .libs; then
+--- 4940,4946 ----
+  ## FIXME: this should be a separate macro
+  ##
+  echo $ac_n "checking for objdir""... $ac_c" 1>&6
+! echo "configure:4944: checking for objdir" >&5
+  rm -f .libs 2>/dev/null
+  mkdir .libs 2>/dev/null
+  if test -d .libs; then
+***************
+*** 4963,4969 ****
+  # in isolation, and that seeing it set (from the cache) indicates that
+  # the associated values are set (in the cache) correctly too.
+  echo $ac_n "checking for $compiler option to produce PIC""... $ac_c" 1>&6
+! echo "configure:4967: checking for $compiler option to produce PIC" >&5
+  if eval "test \"`echo '$''{'lt_cv_prog_cc_pic'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+--- 4971,4977 ----
+  # in isolation, and that seeing it set (from the cache) indicates that
+  # the associated values are set (in the cache) correctly too.
+  echo $ac_n "checking for $compiler option to produce PIC""... $ac_c" 1>&6
+! echo "configure:4975: checking for $compiler option to produce PIC" >&5
+  if eval "test \"`echo '$''{'lt_cv_prog_cc_pic'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+***************
+*** 5115,5135 ****
+  
+    # Check to make sure the pic_flag actually works.
+    echo $ac_n "checking if $compiler PIC flag $lt_cv_prog_cc_pic works""... $ac_c" 1>&6
+! echo "configure:5119: checking if $compiler PIC flag $lt_cv_prog_cc_pic works" >&5
+    if eval "test \"`echo '$''{'lt_cv_prog_cc_pic_works'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+        save_CFLAGS="$CFLAGS"
+      CFLAGS="$CFLAGS $lt_cv_prog_cc_pic -DPIC"
+      cat > conftest.$ac_ext <<EOF
+! #line 5126 "configure"
+  #include "confdefs.h"
+  
+  int main() {
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:5133: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+          case $host_os in
+        hpux9* | hpux10* | hpux11*)
+--- 5123,5143 ----
+  
+    # Check to make sure the pic_flag actually works.
+    echo $ac_n "checking if $compiler PIC flag $lt_cv_prog_cc_pic works""... $ac_c" 1>&6
+! echo "configure:5127: checking if $compiler PIC flag $lt_cv_prog_cc_pic works" >&5
+    if eval "test \"`echo '$''{'lt_cv_prog_cc_pic_works'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+        save_CFLAGS="$CFLAGS"
+      CFLAGS="$CFLAGS $lt_cv_prog_cc_pic -DPIC"
+      cat > conftest.$ac_ext <<EOF
+! #line 5134 "configure"
+  #include "confdefs.h"
+  
+  int main() {
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:5141: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+          case $host_os in
+        hpux9* | hpux10* | hpux11*)
+***************
+*** 5185,5191 ****
+  ## FIXME: this should be a separate macro
+  ##
+  echo $ac_n "checking if $compiler static flag $lt_cv_prog_cc_static works""... $ac_c" 1>&6
+! echo "configure:5189: checking if $compiler static flag $lt_cv_prog_cc_static works" >&5
+  if eval "test \"`echo '$''{'lt_cv_prog_cc_static_works'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+--- 5193,5199 ----
+  ## FIXME: this should be a separate macro
+  ##
+  echo $ac_n "checking if $compiler static flag $lt_cv_prog_cc_static works""... $ac_c" 1>&6
+! echo "configure:5197: checking if $compiler static flag $lt_cv_prog_cc_static works" >&5
+  if eval "test \"`echo '$''{'lt_cv_prog_cc_static_works'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+***************
+*** 5193,5206 ****
+    save_LDFLAGS="$LDFLAGS"
+    LDFLAGS="$LDFLAGS $lt_cv_prog_cc_static"
+    cat > conftest.$ac_ext <<EOF
+! #line 5197 "configure"
+  #include "confdefs.h"
+  
+  int main() {
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:5204: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    lt_cv_prog_cc_static_works=yes
+  else
+--- 5201,5214 ----
+    save_LDFLAGS="$LDFLAGS"
+    LDFLAGS="$LDFLAGS $lt_cv_prog_cc_static"
+    cat > conftest.$ac_ext <<EOF
+! #line 5205 "configure"
+  #include "confdefs.h"
+  
+  int main() {
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:5212: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    lt_cv_prog_cc_static_works=yes
+  else
+***************
+*** 5231,5237 ****
+  ##
+  # Check to see if options -o and -c are simultaneously supported by compiler
+  echo $ac_n "checking if $compiler supports -c -o file.$ac_objext""... $ac_c" 1>&6
+! echo "configure:5235: checking if $compiler supports -c -o file.$ac_objext" >&5
+  if eval "test \"`echo '$''{'lt_cv_compiler_c_o'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+--- 5239,5245 ----
+  ##
+  # Check to see if options -o and -c are simultaneously supported by compiler
+  echo $ac_n "checking if $compiler supports -c -o file.$ac_objext""... $ac_c" 1>&6
+! echo "configure:5243: checking if $compiler supports -c -o file.$ac_objext" >&5
+  if eval "test \"`echo '$''{'lt_cv_compiler_c_o'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+***************
+*** 5250,5256 ****
+  save_CFLAGS="$CFLAGS"
+  CFLAGS="$CFLAGS -o out/conftest2.$ac_objext"
+  compiler_c_o=no
+! if { (eval echo configure:5254: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>out/conftest.err; } && test -s out/conftest2.$ac_objext; then
+    # The compiler can only warn and ignore the option if not recognized
+    # So say no if there are warnings
+    if test -s out/conftest.err; then
+--- 5258,5264 ----
+  save_CFLAGS="$CFLAGS"
+  CFLAGS="$CFLAGS -o out/conftest2.$ac_objext"
+  compiler_c_o=no
+! if { (eval echo configure:5262: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>out/conftest.err; } && test -s out/conftest2.$ac_objext; then
+    # The compiler can only warn and ignore the option if not recognized
+    # So say no if there are warnings
+    if test -s out/conftest.err; then
+***************
+*** 5279,5285 ****
+  if test x"$compiler_c_o" = x"yes"; then
+    # Check to see if we can write to a .lo
+    echo $ac_n "checking if $compiler supports -c -o file.lo""... $ac_c" 1>&6
+! echo "configure:5283: checking if $compiler supports -c -o file.lo" >&5
+    if eval "test \"`echo '$''{'lt_cv_compiler_o_lo'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+--- 5287,5293 ----
+  if test x"$compiler_c_o" = x"yes"; then
+    # Check to see if we can write to a .lo
+    echo $ac_n "checking if $compiler supports -c -o file.lo""... $ac_c" 1>&6
+! echo "configure:5291: checking if $compiler supports -c -o file.lo" >&5
+    if eval "test \"`echo '$''{'lt_cv_compiler_o_lo'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+***************
+*** 5288,5301 ****
+    save_CFLAGS="$CFLAGS"
+    CFLAGS="$CFLAGS -c -o conftest.lo"
+    cat > conftest.$ac_ext <<EOF
+! #line 5292 "configure"
+  #include "confdefs.h"
+  
+  int main() {
+  int some_variable = 0;
+  ; return 0; }
+  EOF
+! if { (eval echo configure:5299: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+        # The compiler can only warn and ignore the option if not recognized
+      # So say no if there are warnings
+--- 5296,5309 ----
+    save_CFLAGS="$CFLAGS"
+    CFLAGS="$CFLAGS -c -o conftest.lo"
+    cat > conftest.$ac_ext <<EOF
+! #line 5300 "configure"
+  #include "confdefs.h"
+  
+  int main() {
+  int some_variable = 0;
+  ; return 0; }
+  EOF
+! if { (eval echo configure:5307: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+        # The compiler can only warn and ignore the option if not recognized
+      # So say no if there are warnings
+***************
+*** 5329,5335 ****
+  if test "$compiler_c_o" = no && test "$need_locks" != no; then
+    # do not overwrite the value of need_locks provided by the user
+    echo $ac_n "checking if we can lock with hard links""... $ac_c" 1>&6
+! echo "configure:5333: checking if we can lock with hard links" >&5
+    hard_links=yes
+    $rm conftest*
+    ln conftest.a conftest.b 2>/dev/null && hard_links=no
+--- 5337,5343 ----
+  if test "$compiler_c_o" = no && test "$need_locks" != no; then
+    # do not overwrite the value of need_locks provided by the user
+    echo $ac_n "checking if we can lock with hard links""... $ac_c" 1>&6
+! echo "configure:5341: checking if we can lock with hard links" >&5
+    hard_links=yes
+    $rm conftest*
+    ln conftest.a conftest.b 2>/dev/null && hard_links=no
+***************
+*** 5352,5371 ****
+  if test "$GCC" = yes; then
+    # Check to see if options -fno-rtti -fno-exceptions are supported by compiler
+    echo $ac_n "checking if $compiler supports -fno-rtti -fno-exceptions""... $ac_c" 1>&6
+! echo "configure:5356: checking if $compiler supports -fno-rtti -fno-exceptions" >&5
+    echo "int some_variable = 0;" > conftest.$ac_ext
+    save_CFLAGS="$CFLAGS"
+    CFLAGS="$CFLAGS -fno-rtti -fno-exceptions -c conftest.$ac_ext"
+    compiler_rtti_exceptions=no
+    cat > conftest.$ac_ext <<EOF
+! #line 5362 "configure"
+  #include "confdefs.h"
+  
+  int main() {
+  int some_variable = 0;
+  ; return 0; }
+  EOF
+! if { (eval echo configure:5369: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+        # The compiler can only warn and ignore the option if not recognized
+      # So say no if there are warnings
+--- 5360,5379 ----
+  if test "$GCC" = yes; then
+    # Check to see if options -fno-rtti -fno-exceptions are supported by compiler
+    echo $ac_n "checking if $compiler supports -fno-rtti -fno-exceptions""... $ac_c" 1>&6
+! echo "configure:5364: checking if $compiler supports -fno-rtti -fno-exceptions" >&5
+    echo "int some_variable = 0;" > conftest.$ac_ext
+    save_CFLAGS="$CFLAGS"
+    CFLAGS="$CFLAGS -fno-rtti -fno-exceptions -c conftest.$ac_ext"
+    compiler_rtti_exceptions=no
+    cat > conftest.$ac_ext <<EOF
+! #line 5370 "configure"
+  #include "confdefs.h"
+  
+  int main() {
+  int some_variable = 0;
+  ; return 0; }
+  EOF
+! if { (eval echo configure:5377: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+        # The compiler can only warn and ignore the option if not recognized
+      # So say no if there are warnings
+***************
+*** 5396,5402 ****
+  ##
+  # See if the linker supports building shared libraries.
+  echo $ac_n "checking whether the linker ($LD) supports shared libraries""... $ac_c" 1>&6
+! echo "configure:5400: checking whether the linker ($LD) supports shared libraries" >&5
+  
+  allow_undefined_flag=
+  no_undefined_flag=
+--- 5404,5410 ----
+  ##
+  # See if the linker supports building shared libraries.
+  echo $ac_n "checking whether the linker ($LD) supports shared libraries""... $ac_c" 1>&6
+! echo "configure:5408: checking whether the linker ($LD) supports shared libraries" >&5
+  
+  allow_undefined_flag=
+  no_undefined_flag=
+***************
+*** 6016,6022 ****
+  ##
+  # Check hardcoding attributes.
+  echo $ac_n "checking how to hardcode library paths into programs""... $ac_c" 1>&6
+! echo "configure:6020: checking how to hardcode library paths into programs" >&5
+  hardcode_action=
+  if test -n "$hardcode_libdir_flag_spec" || \
+     test -n "$runpath_var"; then
+--- 6024,6030 ----
+  ##
+  # Check hardcoding attributes.
+  echo $ac_n "checking how to hardcode library paths into programs""... $ac_c" 1>&6
+! echo "configure:6028: checking how to hardcode library paths into programs" >&5
+  hardcode_action=
+  if test -n "$hardcode_libdir_flag_spec" || \
+     test -n "$runpath_var"; then
+***************
+*** 6048,6054 ****
+  striplib=
+  old_striplib=
+  echo $ac_n "checking whether stripping libraries is possible""... $ac_c" 1>&6
+! echo "configure:6052: checking whether stripping libraries is possible" >&5
+  if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then
+    test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
+    test -z "$striplib" && striplib="$STRIP --strip-unneeded"
+--- 6056,6062 ----
+  striplib=
+  old_striplib=
+  echo $ac_n "checking whether stripping libraries is possible""... $ac_c" 1>&6
+! echo "configure:6060: checking whether stripping libraries is possible" >&5
+  if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then
+    test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
+    test -z "$striplib" && striplib="$STRIP --strip-unneeded"
+***************
+*** 6066,6072 ****
+  ##
+  # PORTME Fill in your ld.so characteristics
+  echo $ac_n "checking dynamic linker characteristics""... $ac_c" 1>&6
+! echo "configure:6070: checking dynamic linker characteristics" >&5
+  library_names_spec=
+  libname_spec='lib$name'
+  soname_spec=
+--- 6074,6080 ----
+  ##
+  # PORTME Fill in your ld.so characteristics
+  echo $ac_n "checking dynamic linker characteristics""... $ac_c" 1>&6
+! echo "configure:6078: checking dynamic linker characteristics" >&5
+  library_names_spec=
+  libname_spec='lib$name'
+  soname_spec=
+***************
+*** 6456,6462 ****
+  ##
+  # Report the final consequences.
+  echo $ac_n "checking if libtool supports shared libraries""... $ac_c" 1>&6
+! echo "configure:6460: checking if libtool supports shared libraries" >&5
+  echo "$ac_t""$can_build_shared" 1>&6
+  ##
+  ## END FIXME
+--- 6464,6470 ----
+  ##
+  # Report the final consequences.
+  echo $ac_n "checking if libtool supports shared libraries""... $ac_c" 1>&6
+! echo "configure:6468: checking if libtool supports shared libraries" >&5
+  echo "$ac_t""$can_build_shared" 1>&6
+  ##
+  ## END FIXME
+***************
+*** 6497,6503 ****
+  
+    *)
+      echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6
+! echo "configure:6501: checking for dlopen in -ldl" >&5
+  ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'`
+  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+--- 6505,6511 ----
+  
+    *)
+      echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6
+! echo "configure:6509: checking for dlopen in -ldl" >&5
+  ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'`
+  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+***************
+*** 6505,6511 ****
+    ac_save_LIBS="$LIBS"
+  LIBS="-ldl  $LIBS"
+  cat > conftest.$ac_ext <<EOF
+! #line 6509 "configure"
+  #include "confdefs.h"
+  /* Override any gcc2 internal prototype to avoid an error.  */
+  /* We use char because int might match the return type of a gcc2
+--- 6513,6519 ----
+    ac_save_LIBS="$LIBS"
+  LIBS="-ldl  $LIBS"
+  cat > conftest.$ac_ext <<EOF
+! #line 6517 "configure"
+  #include "confdefs.h"
+  /* Override any gcc2 internal prototype to avoid an error.  */
+  /* We use char because int might match the return type of a gcc2
+***************
+*** 6516,6522 ****
+  dlopen()
+  ; return 0; }
+  EOF
+! if { (eval echo configure:6520: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_lib_$ac_lib_var=yes"
+  else
+--- 6524,6530 ----
+  dlopen()
+  ; return 0; }
+  EOF
+! if { (eval echo configure:6528: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_lib_$ac_lib_var=yes"
+  else
+***************
+*** 6535,6546 ****
+  else
+    echo "$ac_t""no" 1>&6
+  echo $ac_n "checking for dlopen""... $ac_c" 1>&6
+! echo "configure:6539: checking for dlopen" >&5
+  if eval "test \"`echo '$''{'ac_cv_func_dlopen'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 6544 "configure"
+  #include "confdefs.h"
+  /* System header to define __stub macros and hopefully few prototypes,
+      which can conflict with char dlopen(); below.  */
+--- 6543,6554 ----
+  else
+    echo "$ac_t""no" 1>&6
+  echo $ac_n "checking for dlopen""... $ac_c" 1>&6
+! echo "configure:6547: checking for dlopen" >&5
+  if eval "test \"`echo '$''{'ac_cv_func_dlopen'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 6552 "configure"
+  #include "confdefs.h"
+  /* System header to define __stub macros and hopefully few prototypes,
+      which can conflict with char dlopen(); below.  */
+***************
+*** 6563,6569 ****
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:6567: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_func_dlopen=yes"
+  else
+--- 6571,6577 ----
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:6575: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_func_dlopen=yes"
+  else
+***************
+*** 6581,6592 ****
+  else
+    echo "$ac_t""no" 1>&6
+  echo $ac_n "checking for shl_load""... $ac_c" 1>&6
+! echo "configure:6585: checking for shl_load" >&5
+  if eval "test \"`echo '$''{'ac_cv_func_shl_load'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 6590 "configure"
+  #include "confdefs.h"
+  /* System header to define __stub macros and hopefully few prototypes,
+      which can conflict with char shl_load(); below.  */
+--- 6589,6600 ----
+  else
+    echo "$ac_t""no" 1>&6
+  echo $ac_n "checking for shl_load""... $ac_c" 1>&6
+! echo "configure:6593: checking for shl_load" >&5
+  if eval "test \"`echo '$''{'ac_cv_func_shl_load'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 6598 "configure"
+  #include "confdefs.h"
+  /* System header to define __stub macros and hopefully few prototypes,
+      which can conflict with char shl_load(); below.  */
+***************
+*** 6609,6615 ****
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:6613: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_func_shl_load=yes"
+  else
+--- 6617,6623 ----
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:6621: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_func_shl_load=yes"
+  else
+***************
+*** 6627,6633 ****
+  else
+    echo "$ac_t""no" 1>&6
+  echo $ac_n "checking for dlopen in -lsvld""... $ac_c" 1>&6
+! echo "configure:6631: checking for dlopen in -lsvld" >&5
+  ac_lib_var=`echo svld'_'dlopen | sed 'y%./+-%__p_%'`
+  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+--- 6635,6641 ----
+  else
+    echo "$ac_t""no" 1>&6
+  echo $ac_n "checking for dlopen in -lsvld""... $ac_c" 1>&6
+! echo "configure:6639: checking for dlopen in -lsvld" >&5
+  ac_lib_var=`echo svld'_'dlopen | sed 'y%./+-%__p_%'`
+  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+***************
+*** 6635,6641 ****
+    ac_save_LIBS="$LIBS"
+  LIBS="-lsvld  $LIBS"
+  cat > conftest.$ac_ext <<EOF
+! #line 6639 "configure"
+  #include "confdefs.h"
+  /* Override any gcc2 internal prototype to avoid an error.  */
+  /* We use char because int might match the return type of a gcc2
+--- 6643,6649 ----
+    ac_save_LIBS="$LIBS"
+  LIBS="-lsvld  $LIBS"
+  cat > conftest.$ac_ext <<EOF
+! #line 6647 "configure"
+  #include "confdefs.h"
+  /* Override any gcc2 internal prototype to avoid an error.  */
+  /* We use char because int might match the return type of a gcc2
+***************
+*** 6646,6652 ****
+  dlopen()
+  ; return 0; }
+  EOF
+! if { (eval echo configure:6650: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_lib_$ac_lib_var=yes"
+  else
+--- 6654,6660 ----
+  dlopen()
+  ; return 0; }
+  EOF
+! if { (eval echo configure:6658: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_lib_$ac_lib_var=yes"
+  else
+***************
+*** 6665,6671 ****
+  else
+    echo "$ac_t""no" 1>&6
+  echo $ac_n "checking for shl_load in -ldld""... $ac_c" 1>&6
+! echo "configure:6669: checking for shl_load in -ldld" >&5
+  ac_lib_var=`echo dld'_'shl_load | sed 'y%./+-%__p_%'`
+  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+--- 6673,6679 ----
+  else
+    echo "$ac_t""no" 1>&6
+  echo $ac_n "checking for shl_load in -ldld""... $ac_c" 1>&6
+! echo "configure:6677: checking for shl_load in -ldld" >&5
+  ac_lib_var=`echo dld'_'shl_load | sed 'y%./+-%__p_%'`
+  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+***************
+*** 6673,6679 ****
+    ac_save_LIBS="$LIBS"
+  LIBS="-ldld  $LIBS"
+  cat > conftest.$ac_ext <<EOF
+! #line 6677 "configure"
+  #include "confdefs.h"
+  /* Override any gcc2 internal prototype to avoid an error.  */
+  /* We use char because int might match the return type of a gcc2
+--- 6681,6687 ----
+    ac_save_LIBS="$LIBS"
+  LIBS="-ldld  $LIBS"
+  cat > conftest.$ac_ext <<EOF
+! #line 6685 "configure"
+  #include "confdefs.h"
+  /* Override any gcc2 internal prototype to avoid an error.  */
+  /* We use char because int might match the return type of a gcc2
+***************
+*** 6684,6690 ****
+  shl_load()
+  ; return 0; }
+  EOF
+! if { (eval echo configure:6688: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_lib_$ac_lib_var=yes"
+  else
+--- 6692,6698 ----
+  shl_load()
+  ; return 0; }
+  EOF
+! if { (eval echo configure:6696: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_lib_$ac_lib_var=yes"
+  else
+***************
+*** 6737,6743 ****
+      LIBS="$lt_cv_dlopen_libs $LIBS"
+  
+      echo $ac_n "checking whether a program can dlopen itself""... $ac_c" 1>&6
+! echo "configure:6741: checking whether a program can dlopen itself" >&5
+  if eval "test \"`echo '$''{'lt_cv_dlopen_self'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+--- 6745,6751 ----
+      LIBS="$lt_cv_dlopen_libs $LIBS"
+  
+      echo $ac_n "checking whether a program can dlopen itself""... $ac_c" 1>&6
+! echo "configure:6749: checking whether a program can dlopen itself" >&5
+  if eval "test \"`echo '$''{'lt_cv_dlopen_self'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+***************
+*** 6747,6753 ****
+      lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+    lt_status=$lt_dlunknown
+    cat > conftest.$ac_ext <<EOF
+! #line 6751 "configure"
+  #include "confdefs.h"
+  
+  #if HAVE_DLFCN_H
+--- 6755,6761 ----
+      lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+    lt_status=$lt_dlunknown
+    cat > conftest.$ac_ext <<EOF
+! #line 6759 "configure"
+  #include "confdefs.h"
+  
+  #if HAVE_DLFCN_H
+***************
+*** 6808,6814 ****
+      exit (status);
+  }
+  EOF
+!   if { (eval echo configure:6812: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} 2>/dev/null; then
+      (./conftest; exit; ) 2>/dev/null
+      lt_status=$?
+      case x$lt_status in
+--- 6816,6822 ----
+      exit (status);
+  }
+  EOF
+!   if { (eval echo configure:6820: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} 2>/dev/null; then
+      (./conftest; exit; ) 2>/dev/null
+      lt_status=$?
+      case x$lt_status in
+***************
+*** 6831,6837 ****
+      if test "x$lt_cv_dlopen_self" = xyes; then
+        LDFLAGS="$LDFLAGS $link_static_flag"
+        echo $ac_n "checking whether a statically linked program can dlopen itself""... $ac_c" 1>&6
+! echo "configure:6835: checking whether a statically linked program can dlopen itself" >&5
+  if eval "test \"`echo '$''{'lt_cv_dlopen_self_static'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+--- 6839,6845 ----
+      if test "x$lt_cv_dlopen_self" = xyes; then
+        LDFLAGS="$LDFLAGS $link_static_flag"
+        echo $ac_n "checking whether a statically linked program can dlopen itself""... $ac_c" 1>&6
+! echo "configure:6843: checking whether a statically linked program can dlopen itself" >&5
+  if eval "test \"`echo '$''{'lt_cv_dlopen_self_static'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+***************
+*** 6841,6847 ****
+      lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+    lt_status=$lt_dlunknown
+    cat > conftest.$ac_ext <<EOF
+! #line 6845 "configure"
+  #include "confdefs.h"
+  
+  #if HAVE_DLFCN_H
+--- 6849,6855 ----
+      lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+    lt_status=$lt_dlunknown
+    cat > conftest.$ac_ext <<EOF
+! #line 6853 "configure"
+  #include "confdefs.h"
+  
+  #if HAVE_DLFCN_H
+***************
+*** 6902,6908 ****
+      exit (status);
+  }
+  EOF
+!   if { (eval echo configure:6906: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} 2>/dev/null; then
+      (./conftest; exit; ) 2>/dev/null
+      lt_status=$?
+      case x$lt_status in
+--- 6910,6916 ----
+      exit (status);
+  }
+  EOF
+!   if { (eval echo configure:6914: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} 2>/dev/null; then
+      (./conftest; exit; ) 2>/dev/null
+      lt_status=$?
+      case x$lt_status in
+***************
+*** 6953,6966 ****
+      # systems, -lgcc has to come before -lc. If gcc already passes -lc
+      # to ld, don't add -lc before -lgcc.
+      echo $ac_n "checking whether -lc should be explicitly linked in""... $ac_c" 1>&6
+! echo "configure:6957: checking whether -lc should be explicitly linked in" >&5
+      if eval "test \"`echo '$''{'lt_cv_archive_cmds_need_lc'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    $rm conftest*
+      echo 'static int dummy;' > conftest.$ac_ext
+  
+!     if { (eval echo configure:6964: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+        soname=conftest
+        lib=conftest
+        libobjs=conftest.$ac_objext
+--- 6961,6974 ----
+      # systems, -lgcc has to come before -lc. If gcc already passes -lc
+      # to ld, don't add -lc before -lgcc.
+      echo $ac_n "checking whether -lc should be explicitly linked in""... $ac_c" 1>&6
+! echo "configure:6965: checking whether -lc should be explicitly linked in" >&5
+      if eval "test \"`echo '$''{'lt_cv_archive_cmds_need_lc'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    $rm conftest*
+      echo 'static int dummy;' > conftest.$ac_ext
+  
+!     if { (eval echo configure:6972: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+        soname=conftest
+        lib=conftest
+        libobjs=conftest.$ac_objext
+***************
+*** 6973,6979 ****
+        libname=conftest
+        save_allow_undefined_flag=$allow_undefined_flag
+        allow_undefined_flag=
+!       if { (eval echo configure:6977: \"$archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\") 1>&5; (eval $archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5; }
+        then
+       lt_cv_archive_cmds_need_lc=no
+        else
+--- 6981,6987 ----
+        libname=conftest
+        save_allow_undefined_flag=$allow_undefined_flag
+        allow_undefined_flag=
+!       if { (eval echo configure:6985: \"$archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\") 1>&5; (eval $archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5; }
+        then
+       lt_cv_archive_cmds_need_lc=no
+        else
+***************
+*** 7630,7638 ****
+  # the right suffix on the files.
+  #
+  echo $ac_n "checking for IPv6 structures""... $ac_c" 1>&6
+! echo "configure:7634: checking for IPv6 structures" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 7636 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/types.h>
+--- 7638,7646 ----
+  # the right suffix on the files.
+  #
+  echo $ac_n "checking for IPv6 structures""... $ac_c" 1>&6
+! echo "configure:7642: checking for IPv6 structures" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 7644 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/types.h>
+***************
+*** 7642,7648 ****
+  struct sockaddr_in6 sin6; return (0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:7646: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    echo "$ac_t""yes" 1>&6
+        found_ipv6=yes
+--- 7650,7656 ----
+  struct sockaddr_in6 sin6; return (0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:7654: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    echo "$ac_t""yes" 1>&6
+        found_ipv6=yes
+***************
+*** 7660,7666 ****
+  # This is done before other IPv6 linking tests to LIBS is properly set.
+  #
+  echo $ac_n "checking for Kame IPv6 support""... $ac_c" 1>&6
+! echo "configure:7664: checking for Kame IPv6 support" >&5
+  # Check whether --with-kame or --without-kame was given.
+  if test "${with_kame+set}" = set; then
+    withval="$with_kame"
+--- 7668,7674 ----
+  # This is done before other IPv6 linking tests to LIBS is properly set.
+  #
+  echo $ac_n "checking for Kame IPv6 support""... $ac_c" 1>&6
+! echo "configure:7672: checking for Kame IPv6 support" >&5
+  # Check whether --with-kame or --without-kame was given.
+  if test "${with_kame+set}" = set; then
+    withval="$with_kame"
+***************
+*** 7751,7759 ****
+               LWRES_PLATFORM_HAVEIPV6="#define LWRES_PLATFORM_HAVEIPV6 1"
+  
+               echo $ac_n "checking for in6_addr""... $ac_c" 1>&6
+! echo "configure:7755: checking for in6_addr" >&5
+               cat > conftest.$ac_ext <<EOF
+! #line 7757 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/types.h>
+--- 7759,7767 ----
+               LWRES_PLATFORM_HAVEIPV6="#define LWRES_PLATFORM_HAVEIPV6 1"
+  
+               echo $ac_n "checking for in6_addr""... $ac_c" 1>&6
+! echo "configure:7763: checking for in6_addr" >&5
+               cat > conftest.$ac_ext <<EOF
+! #line 7765 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/types.h>
+***************
+*** 7766,7772 ****
+  struct in6_addr in6; return (0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:7770: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    echo "$ac_t""yes" 1>&6
+                ISC_PLATFORM_HAVEINADDR6="#undef ISC_PLATFORM_HAVEINADDR6"
+--- 7774,7780 ----
+  struct in6_addr in6; return (0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:7778: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    echo "$ac_t""yes" 1>&6
+                ISC_PLATFORM_HAVEINADDR6="#undef ISC_PLATFORM_HAVEINADDR6"
+***************
+*** 7784,7792 ****
+  rm -f conftest*
+  
+               echo $ac_n "checking for in6addr_any""... $ac_c" 1>&6
+! echo "configure:7788: checking for in6addr_any" >&5
+               cat > conftest.$ac_ext <<EOF
+! #line 7790 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/types.h>
+--- 7792,7800 ----
+  rm -f conftest*
+  
+               echo $ac_n "checking for in6addr_any""... $ac_c" 1>&6
+! echo "configure:7796: checking for in6addr_any" >&5
+               cat > conftest.$ac_ext <<EOF
+! #line 7798 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/types.h>
+***************
+*** 7800,7806 ****
+  struct in6_addr in6; in6 = in6addr_any; return (in6.s6_addr[0]);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:7804: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    echo "$ac_t""yes" 1>&6
+                        ISC_PLATFORM_NEEDIN6ADDRANY="#undef ISC_PLATFORM_NEEDIN6ADDRANY"
+--- 7808,7814 ----
+  struct in6_addr in6; in6 = in6addr_any; return (in6.s6_addr[0]);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:7812: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    echo "$ac_t""yes" 1>&6
+                        ISC_PLATFORM_NEEDIN6ADDRANY="#undef ISC_PLATFORM_NEEDIN6ADDRANY"
+***************
+*** 7816,7824 ****
+  rm -f conftest*
+  
+               echo $ac_n "checking for in6addr_loopback""... $ac_c" 1>&6
+! echo "configure:7820: checking for in6addr_loopback" >&5
+               cat > conftest.$ac_ext <<EOF
+! #line 7822 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/types.h>
+--- 7824,7832 ----
+  rm -f conftest*
+  
+               echo $ac_n "checking for in6addr_loopback""... $ac_c" 1>&6
+! echo "configure:7828: checking for in6addr_loopback" >&5
+               cat > conftest.$ac_ext <<EOF
+! #line 7830 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/types.h>
+***************
+*** 7832,7838 ****
+  struct in6_addr in6; in6 = in6addr_loopback; return (in6.s6_addr[0]);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:7836: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    echo "$ac_t""yes" 1>&6
+                        ISC_PLATFORM_NEEDIN6ADDRLOOPBACK="#undef ISC_PLATFORM_NEEDIN6ADDRLOOPBACK"
+--- 7840,7846 ----
+  struct in6_addr in6; in6 = in6addr_loopback; return (in6.s6_addr[0]);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:7844: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    echo "$ac_t""yes" 1>&6
+                        ISC_PLATFORM_NEEDIN6ADDRLOOPBACK="#undef ISC_PLATFORM_NEEDIN6ADDRLOOPBACK"
+***************
+*** 7848,7856 ****
+  rm -f conftest*
+  
+               echo $ac_n "checking for sin6_scope_id in struct sockaddr_in6""... $ac_c" 1>&6
+! echo "configure:7852: checking for sin6_scope_id in struct sockaddr_in6" >&5
+               cat > conftest.$ac_ext <<EOF
+! #line 7854 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/types.h>
+--- 7856,7864 ----
+  rm -f conftest*
+  
+               echo $ac_n "checking for sin6_scope_id in struct sockaddr_in6""... $ac_c" 1>&6
+! echo "configure:7860: checking for sin6_scope_id in struct sockaddr_in6" >&5
+               cat > conftest.$ac_ext <<EOF
+! #line 7862 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/types.h>
+***************
+*** 7863,7869 ****
+  struct sockaddr_in6 xyzzy; xyzzy.sin6_scope_id = 0; return (0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:7867: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    echo "$ac_t""yes" 1>&6
+                        result="#define LWRES_HAVE_SIN6_SCOPE_ID 1"
+--- 7871,7877 ----
+  struct sockaddr_in6 xyzzy; xyzzy.sin6_scope_id = 0; return (0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:7875: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    echo "$ac_t""yes" 1>&6
+                        result="#define LWRES_HAVE_SIN6_SCOPE_ID 1"
+***************
+*** 7878,7886 ****
+               LWRES_HAVE_SIN6_SCOPE_ID="$result"
+  
+               echo $ac_n "checking for in6_pktinfo""... $ac_c" 1>&6
+! echo "configure:7882: checking for in6_pktinfo" >&5
+               cat > conftest.$ac_ext <<EOF
+! #line 7884 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/types.h>
+--- 7886,7894 ----
+               LWRES_HAVE_SIN6_SCOPE_ID="$result"
+  
+               echo $ac_n "checking for in6_pktinfo""... $ac_c" 1>&6
+! echo "configure:7890: checking for in6_pktinfo" >&5
+               cat > conftest.$ac_ext <<EOF
+! #line 7892 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/types.h>
+***************
+*** 7893,7899 ****
+  struct in6_pktinfo xyzzy; return (0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:7897: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    echo "$ac_t""yes" 1>&6
+                        ISC_PLATFORM_HAVEIN6PKTINFO="#define ISC_PLATFORM_HAVEIN6PKTINFO 1"
+--- 7901,7907 ----
+  struct in6_pktinfo xyzzy; return (0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:7905: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    echo "$ac_t""yes" 1>&6
+                        ISC_PLATFORM_HAVEIN6PKTINFO="#define ISC_PLATFORM_HAVEIN6PKTINFO 1"
+***************
+*** 7948,7956 ****
+  #
+  
+  echo $ac_n "checking for inet_ntop""... $ac_c" 1>&6
+! echo "configure:7952: checking for inet_ntop" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 7954 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/types.h>
+--- 7956,7964 ----
+  #
+  
+  echo $ac_n "checking for inet_ntop""... $ac_c" 1>&6
+! echo "configure:7960: checking for inet_ntop" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 7962 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/types.h>
+***************
+*** 7960,7966 ****
+  inet_ntop(0, 0, 0, 0); return (0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:7964: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    echo "$ac_t""yes" 1>&6
+          ISC_PLATFORM_NEEDNTOP="#undef ISC_PLATFORM_NEEDNTOP"
+--- 7968,7974 ----
+  inet_ntop(0, 0, 0, 0); return (0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:7972: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    echo "$ac_t""yes" 1>&6
+          ISC_PLATFORM_NEEDNTOP="#undef ISC_PLATFORM_NEEDNTOP"
+***************
+*** 7981,7993 ****
+  # zeros should also be rejected.
+  
+  echo $ac_n "checking for inet_pton""... $ac_c" 1>&6
+! echo "configure:7985: checking for inet_pton" >&5
+  if test "$cross_compiling" = yes; then
+    echo "$ac_t""assuming target platform has working inet_pton" 1>&6
+       ISC_PLATFORM_NEEDPTON="#undef ISC_PLATFORM_NEEDPTON"
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 7991 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/types.h>
+--- 7989,8001 ----
+  # zeros should also be rejected.
+  
+  echo $ac_n "checking for inet_pton""... $ac_c" 1>&6
+! echo "configure:7993: checking for inet_pton" >&5
+  if test "$cross_compiling" = yes; then
+    echo "$ac_t""assuming target platform has working inet_pton" 1>&6
+       ISC_PLATFORM_NEEDPTON="#undef ISC_PLATFORM_NEEDPTON"
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 7999 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/types.h>
+***************
+*** 7997,8003 ****
+  main() { char a[4]; return (inet_pton(AF_INET, "1.2.3", a) == 1 ? 1 :
+                           inet_pton(AF_INET, "1.2.3.04", a) == 1 ? 1 : 0); }
+  EOF
+! if { (eval echo configure:8001: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+  then
+    echo "$ac_t""yes" 1>&6
+          ISC_PLATFORM_NEEDPTON="#undef ISC_PLATFORM_NEEDPTON"
+--- 8005,8011 ----
+  main() { char a[4]; return (inet_pton(AF_INET, "1.2.3", a) == 1 ? 1 :
+                           inet_pton(AF_INET, "1.2.3.04", a) == 1 ? 1 : 0); }
+  EOF
+! if { (eval echo configure:8009: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+  then
+    echo "$ac_t""yes" 1>&6
+          ISC_PLATFORM_NEEDPTON="#undef ISC_PLATFORM_NEEDPTON"
+***************
+*** 8015,8023 ****
+  
+  
+  echo $ac_n "checking for inet_aton""... $ac_c" 1>&6
+! echo "configure:8019: checking for inet_aton" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 8021 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/types.h>
+--- 8023,8031 ----
+  
+  
+  echo $ac_n "checking for inet_aton""... $ac_c" 1>&6
+! echo "configure:8027: checking for inet_aton" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 8029 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/types.h>
+***************
+*** 8027,8033 ****
+  struct in_addr in; inet_aton(0, &in); return (0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:8031: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    echo "$ac_t""yes" 1>&6
+          ISC_PLATFORM_NEEDATON="#undef ISC_PLATFORM_NEEDATON"
+--- 8035,8041 ----
+  struct in_addr in; inet_aton(0, &in); return (0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:8039: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    echo "$ac_t""yes" 1>&6
+          ISC_PLATFORM_NEEDATON="#undef ISC_PLATFORM_NEEDATON"
+***************
+*** 8060,8068 ****
+  esac
+  
+  echo $ac_n "checking for sa_len in struct sockaddr""... $ac_c" 1>&6
+! echo "configure:8064: checking for sa_len in struct sockaddr" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 8066 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/types.h>
+--- 8068,8076 ----
+  esac
+  
+  echo $ac_n "checking for sa_len in struct sockaddr""... $ac_c" 1>&6
+! echo "configure:8072: checking for sa_len in struct sockaddr" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 8074 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/types.h>
+***************
+*** 8071,8077 ****
+  struct sockaddr sa; sa.sa_len = 0; return (0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:8075: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    echo "$ac_t""yes" 1>&6
+       ISC_PLATFORM_HAVESALEN="#define ISC_PLATFORM_HAVESALEN 1"
+--- 8079,8085 ----
+  struct sockaddr sa; sa.sa_len = 0; return (0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:8083: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    echo "$ac_t""yes" 1>&6
+       ISC_PLATFORM_HAVESALEN="#define ISC_PLATFORM_HAVESALEN 1"
+***************
+*** 8092,8100 ****
+  # Look for a 4.4BSD or 4.3BSD struct msghdr
+  #
+  echo $ac_n "checking for struct msghdr flavor""... $ac_c" 1>&6
+! echo "configure:8096: checking for struct msghdr flavor" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 8098 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/types.h>
+--- 8100,8108 ----
+  # Look for a 4.4BSD or 4.3BSD struct msghdr
+  #
+  echo $ac_n "checking for struct msghdr flavor""... $ac_c" 1>&6
+! echo "configure:8104: checking for struct msghdr flavor" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 8106 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/types.h>
+***************
+*** 8103,8109 ****
+  struct msghdr msg; msg.msg_flags = 0; return (0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:8107: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    echo "$ac_t""4.4BSD" 1>&6
+       ISC_PLATFORM_MSGHDRFLAVOR="#define ISC_NET_BSD44MSGHDR 1"
+--- 8111,8117 ----
+  struct msghdr msg; msg.msg_flags = 0; return (0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:8115: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    echo "$ac_t""4.4BSD" 1>&6
+       ISC_PLATFORM_MSGHDRFLAVOR="#define ISC_NET_BSD44MSGHDR 1"
+***************
+*** 8121,8129 ****
+  # Look for in_port_t.
+  #
+  echo $ac_n "checking for type in_port_t""... $ac_c" 1>&6
+! echo "configure:8125: checking for type in_port_t" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 8127 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/types.h>
+--- 8129,8137 ----
+  # Look for in_port_t.
+  #
+  echo $ac_n "checking for type in_port_t""... $ac_c" 1>&6
+! echo "configure:8133: checking for type in_port_t" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 8135 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/types.h>
+***************
+*** 8132,8138 ****
+  in_port_t port = 25; return (0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:8136: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    echo "$ac_t""yes" 1>&6
+       ISC_PLATFORM_NEEDPORTT="#undef ISC_PLATFORM_NEEDPORTT"
+--- 8140,8146 ----
+  in_port_t port = 25; return (0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:8144: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    echo "$ac_t""yes" 1>&6
+       ISC_PLATFORM_NEEDPORTT="#undef ISC_PLATFORM_NEEDPORTT"
+***************
+*** 8150,8158 ****
+  # Check for addrinfo
+  #
+  echo $ac_n "checking for struct addrinfo""... $ac_c" 1>&6
+! echo "configure:8154: checking for struct addrinfo" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 8156 "configure"
+  #include "confdefs.h"
+  
+  #include <netdb.h>
+--- 8158,8166 ----
+  # Check for addrinfo
+  #
+  echo $ac_n "checking for struct addrinfo""... $ac_c" 1>&6
+! echo "configure:8162: checking for struct addrinfo" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 8164 "configure"
+  #include "confdefs.h"
+  
+  #include <netdb.h>
+***************
+*** 8160,8166 ****
+  struct addrinfo a; return (0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:8164: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    echo "$ac_t""yes" 1>&6
+       ISC_LWRES_NEEDADDRINFO="#undef ISC_LWRES_NEEDADDRINFO"
+--- 8168,8174 ----
+  struct addrinfo a; return (0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:8172: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    echo "$ac_t""yes" 1>&6
+       ISC_LWRES_NEEDADDRINFO="#undef ISC_LWRES_NEEDADDRINFO"
+***************
+*** 8182,8190 ****
+  # Check for rrsetinfo
+  #
+  echo $ac_n "checking for struct rrsetinfo""... $ac_c" 1>&6
+! echo "configure:8186: checking for struct rrsetinfo" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 8188 "configure"
+  #include "confdefs.h"
+  
+  #include <netdb.h>
+--- 8190,8198 ----
+  # Check for rrsetinfo
+  #
+  echo $ac_n "checking for struct rrsetinfo""... $ac_c" 1>&6
+! echo "configure:8194: checking for struct rrsetinfo" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 8196 "configure"
+  #include "confdefs.h"
+  
+  #include <netdb.h>
+***************
+*** 8192,8198 ****
+  struct rrsetinfo r; return (0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:8196: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    echo "$ac_t""yes" 1>&6
+       ISC_LWRES_NEEDRRSETINFO="#undef ISC_LWRES_NEEDRRSETINFO"
+--- 8200,8206 ----
+  struct rrsetinfo r; return (0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:8204: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    echo "$ac_t""yes" 1>&6
+       ISC_LWRES_NEEDRRSETINFO="#undef ISC_LWRES_NEEDRRSETINFO"
+***************
+*** 8207,8215 ****
+  
+  
+  echo $ac_n "checking for int sethostent""... $ac_c" 1>&6
+! echo "configure:8211: checking for int sethostent" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 8213 "configure"
+  #include "confdefs.h"
+  
+  #include <netdb.h>
+--- 8215,8223 ----
+  
+  
+  echo $ac_n "checking for int sethostent""... $ac_c" 1>&6
+! echo "configure:8219: checking for int sethostent" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 8221 "configure"
+  #include "confdefs.h"
+  
+  #include <netdb.h>
+***************
+*** 8217,8223 ****
+  int i = sethostent(0); return(0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:8221: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    echo "$ac_t""yes" 1>&6
+       ISC_LWRES_SETHOSTENTINT="#define ISC_LWRES_SETHOSTENTINT 1"
+--- 8225,8231 ----
+  int i = sethostent(0); return(0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:8229: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    echo "$ac_t""yes" 1>&6
+       ISC_LWRES_SETHOSTENTINT="#define ISC_LWRES_SETHOSTENTINT 1"
+***************
+*** 8232,8240 ****
+  
+  
+  echo $ac_n "checking for int endhostent""... $ac_c" 1>&6
+! echo "configure:8236: checking for int endhostent" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 8238 "configure"
+  #include "confdefs.h"
+  
+  #include <netdb.h>
+--- 8240,8248 ----
+  
+  
+  echo $ac_n "checking for int endhostent""... $ac_c" 1>&6
+! echo "configure:8244: checking for int endhostent" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 8246 "configure"
+  #include "confdefs.h"
+  
+  #include <netdb.h>
+***************
+*** 8242,8248 ****
+  int i = endhostent(); return(0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:8246: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    echo "$ac_t""yes" 1>&6
+       ISC_LWRES_ENDHOSTENTINT="#define ISC_LWRES_ENDHOSTENTINT 1"
+--- 8250,8256 ----
+  int i = endhostent(); return(0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:8254: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    echo "$ac_t""yes" 1>&6
+       ISC_LWRES_ENDHOSTENTINT="#define ISC_LWRES_ENDHOSTENTINT 1"
+***************
+*** 8257,8265 ****
+  
+  
+  echo $ac_n "checking for getnetbyaddr(in_addr_t, ...)""... $ac_c" 1>&6
+! echo "configure:8261: checking for getnetbyaddr(in_addr_t, ...)" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 8263 "configure"
+  #include "confdefs.h"
+  
+  #include <netdb.h>
+--- 8265,8273 ----
+  
+  
+  echo $ac_n "checking for getnetbyaddr(in_addr_t, ...)""... $ac_c" 1>&6
+! echo "configure:8269: checking for getnetbyaddr(in_addr_t, ...)" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 8271 "configure"
+  #include "confdefs.h"
+  
+  #include <netdb.h>
+***************
+*** 8268,8274 ****
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:8272: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    echo "$ac_t""yes" 1>&6
+       ISC_LWRES_GETNETBYADDRINADDR="#define ISC_LWRES_GETNETBYADDRINADDR 1"
+--- 8276,8282 ----
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:8280: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    echo "$ac_t""yes" 1>&6
+       ISC_LWRES_GETNETBYADDRINADDR="#define ISC_LWRES_GETNETBYADDRINADDR 1"
+***************
+*** 8283,8291 ****
+  
+  
+  echo $ac_n "checking for int setnetent""... $ac_c" 1>&6
+! echo "configure:8287: checking for int setnetent" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 8289 "configure"
+  #include "confdefs.h"
+  
+  #include <netdb.h>
+--- 8291,8299 ----
+  
+  
+  echo $ac_n "checking for int setnetent""... $ac_c" 1>&6
+! echo "configure:8295: checking for int setnetent" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 8297 "configure"
+  #include "confdefs.h"
+  
+  #include <netdb.h>
+***************
+*** 8293,8299 ****
+  int i = setnetent(0); return(0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:8297: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    echo "$ac_t""yes" 1>&6
+       ISC_LWRES_SETNETENTINT="#define ISC_LWRES_SETNETENTINT 1"
+--- 8301,8307 ----
+  int i = setnetent(0); return(0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:8305: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    echo "$ac_t""yes" 1>&6
+       ISC_LWRES_SETNETENTINT="#define ISC_LWRES_SETNETENTINT 1"
+***************
+*** 8308,8316 ****
+  
+  
+  echo $ac_n "checking for int endnetent""... $ac_c" 1>&6
+! echo "configure:8312: checking for int endnetent" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 8314 "configure"
+  #include "confdefs.h"
+  
+  #include <netdb.h>
+--- 8316,8324 ----
+  
+  
+  echo $ac_n "checking for int endnetent""... $ac_c" 1>&6
+! echo "configure:8320: checking for int endnetent" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 8322 "configure"
+  #include "confdefs.h"
+  
+  #include <netdb.h>
+***************
+*** 8318,8324 ****
+  int i = endnetent(); return(0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:8322: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    echo "$ac_t""yes" 1>&6
+       ISC_LWRES_ENDNETENTINT="#define ISC_LWRES_ENDNETENTINT 1"
+--- 8326,8332 ----
+  int i = endnetent(); return(0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:8330: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    echo "$ac_t""yes" 1>&6
+       ISC_LWRES_ENDNETENTINT="#define ISC_LWRES_ENDNETENTINT 1"
+***************
+*** 8333,8341 ****
+  
+  
+  echo $ac_n "checking for gethostbyaddr(const void *, size_t, ...)""... $ac_c" 1>&6
+! echo "configure:8337: checking for gethostbyaddr(const void *, size_t, ...)" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 8339 "configure"
+  #include "confdefs.h"
+  
+  #include <netdb.h>
+--- 8341,8349 ----
+  
+  
+  echo $ac_n "checking for gethostbyaddr(const void *, size_t, ...)""... $ac_c" 1>&6
+! echo "configure:8345: checking for gethostbyaddr(const void *, size_t, ...)" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 8347 "configure"
+  #include "confdefs.h"
+  
+  #include <netdb.h>
+***************
+*** 8344,8350 ****
+  return(0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:8348: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    echo "$ac_t""yes" 1>&6
+       ISC_LWRES_GETHOSTBYADDRVOID="#define ISC_LWRES_GETHOSTBYADDRVOID 1"
+--- 8352,8358 ----
+  return(0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:8356: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    echo "$ac_t""yes" 1>&6
+       ISC_LWRES_GETHOSTBYADDRVOID="#define ISC_LWRES_GETHOSTBYADDRVOID 1"
+***************
+*** 8359,8367 ****
+  
+  
+  echo $ac_n "checking for h_errno in netdb.h""... $ac_c" 1>&6
+! echo "configure:8363: checking for h_errno in netdb.h" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 8365 "configure"
+  #include "confdefs.h"
+  
+  #include <netdb.h>
+--- 8367,8375 ----
+  
+  
+  echo $ac_n "checking for h_errno in netdb.h""... $ac_c" 1>&6
+! echo "configure:8371: checking for h_errno in netdb.h" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 8373 "configure"
+  #include "confdefs.h"
+  
+  #include <netdb.h>
+***************
+*** 8369,8375 ****
+  h_errno = 1; return(0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:8373: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    echo "$ac_t""yes" 1>&6
+       ISC_LWRES_NEEDHERRNO="#undef ISC_LWRES_NEEDHERRNO"
+--- 8377,8383 ----
+  h_errno = 1; return(0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:8381: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    echo "$ac_t""yes" 1>&6
+       ISC_LWRES_NEEDHERRNO="#undef ISC_LWRES_NEEDHERRNO"
+***************
+*** 8384,8395 ****
+  
+  
+  echo $ac_n "checking for getipnodebyname""... $ac_c" 1>&6
+! echo "configure:8388: checking for getipnodebyname" >&5
+  if eval "test \"`echo '$''{'ac_cv_func_getipnodebyname'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 8393 "configure"
+  #include "confdefs.h"
+  /* System header to define __stub macros and hopefully few prototypes,
+      which can conflict with char getipnodebyname(); below.  */
+--- 8392,8403 ----
+  
+  
+  echo $ac_n "checking for getipnodebyname""... $ac_c" 1>&6
+! echo "configure:8396: checking for getipnodebyname" >&5
+  if eval "test \"`echo '$''{'ac_cv_func_getipnodebyname'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 8401 "configure"
+  #include "confdefs.h"
+  /* System header to define __stub macros and hopefully few prototypes,
+      which can conflict with char getipnodebyname(); below.  */
+***************
+*** 8412,8418 ****
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:8416: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_func_getipnodebyname=yes"
+  else
+--- 8420,8426 ----
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:8424: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_func_getipnodebyname=yes"
+  else
+***************
+*** 8433,8444 ****
+  fi
+  
+  echo $ac_n "checking for getnameinfo""... $ac_c" 1>&6
+! echo "configure:8437: checking for getnameinfo" >&5
+  if eval "test \"`echo '$''{'ac_cv_func_getnameinfo'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 8442 "configure"
+  #include "confdefs.h"
+  /* System header to define __stub macros and hopefully few prototypes,
+      which can conflict with char getnameinfo(); below.  */
+--- 8441,8452 ----
+  fi
+  
+  echo $ac_n "checking for getnameinfo""... $ac_c" 1>&6
+! echo "configure:8445: checking for getnameinfo" >&5
+  if eval "test \"`echo '$''{'ac_cv_func_getnameinfo'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 8450 "configure"
+  #include "confdefs.h"
+  /* System header to define __stub macros and hopefully few prototypes,
+      which can conflict with char getnameinfo(); below.  */
+***************
+*** 8461,8467 ****
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:8465: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_func_getnameinfo=yes"
+  else
+--- 8469,8475 ----
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:8473: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_func_getnameinfo=yes"
+  else
+***************
+*** 8482,8493 ****
+  fi
+  
+  echo $ac_n "checking for getaddrinfo""... $ac_c" 1>&6
+! echo "configure:8486: checking for getaddrinfo" >&5
+  if eval "test \"`echo '$''{'ac_cv_func_getaddrinfo'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 8491 "configure"
+  #include "confdefs.h"
+  /* System header to define __stub macros and hopefully few prototypes,
+      which can conflict with char getaddrinfo(); below.  */
+--- 8490,8501 ----
+  fi
+  
+  echo $ac_n "checking for getaddrinfo""... $ac_c" 1>&6
+! echo "configure:8494: checking for getaddrinfo" >&5
+  if eval "test \"`echo '$''{'ac_cv_func_getaddrinfo'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 8499 "configure"
+  #include "confdefs.h"
+  /* System header to define __stub macros and hopefully few prototypes,
+      which can conflict with char getaddrinfo(); below.  */
+***************
+*** 8510,8516 ****
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:8514: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_func_getaddrinfo=yes"
+  else
+--- 8518,8524 ----
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:8522: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_func_getaddrinfo=yes"
+  else
+***************
+*** 8535,8546 ****
+  fi
+  
+  echo $ac_n "checking for gai_strerror""... $ac_c" 1>&6
+! echo "configure:8539: checking for gai_strerror" >&5
+  if eval "test \"`echo '$''{'ac_cv_func_gai_strerror'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 8544 "configure"
+  #include "confdefs.h"
+  /* System header to define __stub macros and hopefully few prototypes,
+      which can conflict with char gai_strerror(); below.  */
+--- 8543,8554 ----
+  fi
+  
+  echo $ac_n "checking for gai_strerror""... $ac_c" 1>&6
+! echo "configure:8547: checking for gai_strerror" >&5
+  if eval "test \"`echo '$''{'ac_cv_func_gai_strerror'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 8552 "configure"
+  #include "confdefs.h"
+  /* System header to define __stub macros and hopefully few prototypes,
+      which can conflict with char gai_strerror(); below.  */
+***************
+*** 8563,8569 ****
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:8567: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_func_gai_strerror=yes"
+  else
+--- 8571,8577 ----
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:8575: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_func_gai_strerror=yes"
+  else
+***************
+*** 8593,8601 ****
+  # Look for a sysctl call to get the list of network interfaces.
+  #
+  echo $ac_n "checking for interface list sysctl""... $ac_c" 1>&6
+! echo "configure:8597: checking for interface list sysctl" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 8599 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/param.h>
+--- 8601,8609 ----
+  # Look for a sysctl call to get the list of network interfaces.
+  #
+  echo $ac_n "checking for interface list sysctl""... $ac_c" 1>&6
+! echo "configure:8605: checking for interface list sysctl" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 8607 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/param.h>
+***************
+*** 8632,8647 ****
+  # AC_CHECK_FUNC() incorrectly succeeds because it declares
+  # the function itself.
+  echo $ac_n "checking for correctly declared strsep()""... $ac_c" 1>&6
+! echo "configure:8636: checking for correctly declared strsep()" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 8638 "configure"
+  #include "confdefs.h"
+  #include <string.h>
+  int main() {
+  char *sp; char *foo = strsep(&sp, ".");
+  ; return 0; }
+  EOF
+! if { (eval echo configure:8645: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    echo "$ac_t""yes" 1>&6; ISC_PLATFORM_NEEDSTRSEP="#undef ISC_PLATFORM_NEEDSTRSEP"
+  else
+--- 8640,8655 ----
+  # AC_CHECK_FUNC() incorrectly succeeds because it declares
+  # the function itself.
+  echo $ac_n "checking for correctly declared strsep()""... $ac_c" 1>&6
+! echo "configure:8644: checking for correctly declared strsep()" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 8646 "configure"
+  #include "confdefs.h"
+  #include <string.h>
+  int main() {
+  char *sp; char *foo = strsep(&sp, ".");
+  ; return 0; }
+  EOF
+! if { (eval echo configure:8653: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    echo "$ac_t""yes" 1>&6; ISC_PLATFORM_NEEDSTRSEP="#undef ISC_PLATFORM_NEEDSTRSEP"
+  else
+***************
+*** 8653,8664 ****
+  rm -f conftest*
+  
+  echo $ac_n "checking for vsnprintf""... $ac_c" 1>&6
+! echo "configure:8657: checking for vsnprintf" >&5
+  if eval "test \"`echo '$''{'ac_cv_func_vsnprintf'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 8662 "configure"
+  #include "confdefs.h"
+  /* System header to define __stub macros and hopefully few prototypes,
+      which can conflict with char vsnprintf(); below.  */
+--- 8661,8672 ----
+  rm -f conftest*
+  
+  echo $ac_n "checking for vsnprintf""... $ac_c" 1>&6
+! echo "configure:8665: checking for vsnprintf" >&5
+  if eval "test \"`echo '$''{'ac_cv_func_vsnprintf'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 8670 "configure"
+  #include "confdefs.h"
+  /* System header to define __stub macros and hopefully few prototypes,
+      which can conflict with char vsnprintf(); below.  */
+***************
+*** 8681,8687 ****
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:8685: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_func_vsnprintf=yes"
+  else
+--- 8689,8695 ----
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:8693: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_func_vsnprintf=yes"
+  else
+***************
+*** 8706,8717 ****
+  
+  
+  echo $ac_n "checking for strerror""... $ac_c" 1>&6
+! echo "configure:8710: checking for strerror" >&5
+  if eval "test \"`echo '$''{'ac_cv_func_strerror'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 8715 "configure"
+  #include "confdefs.h"
+  /* System header to define __stub macros and hopefully few prototypes,
+      which can conflict with char strerror(); below.  */
+--- 8714,8725 ----
+  
+  
+  echo $ac_n "checking for strerror""... $ac_c" 1>&6
+! echo "configure:8718: checking for strerror" >&5
+  if eval "test \"`echo '$''{'ac_cv_func_strerror'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 8723 "configure"
+  #include "confdefs.h"
+  /* System header to define __stub macros and hopefully few prototypes,
+      which can conflict with char strerror(); below.  */
+***************
+*** 8734,8740 ****
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:8738: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_func_strerror=yes"
+  else
+--- 8742,8748 ----
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:8746: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_func_strerror=yes"
+  else
+***************
+*** 8768,8784 ****
+  # but that's defined elsewhere since we don't use configure on Win32.
+  #
+  echo $ac_n "checking printf format modifier for 64-bit integers""... $ac_c" 1>&6
+! echo "configure:8772: checking printf format modifier for 64-bit integers" >&5
+  if test "$cross_compiling" = yes; then
+    echo "$ac_t""assuming target platform uses ll" 1>&6
+       ISC_PLATFORM_QUADFORMAT='#define ISC_PLATFORM_QUADFORMAT "ll"'
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 8778 "configure"
+  #include "confdefs.h"
+  main() { exit(!(sizeof(long long int) == sizeof(long int))); }
+  EOF
+! if { (eval echo configure:8782: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+  then
+    echo "$ac_t""l" 1>&6
+       ISC_PLATFORM_QUADFORMAT='#define ISC_PLATFORM_QUADFORMAT "l"'
+--- 8776,8792 ----
+  # but that's defined elsewhere since we don't use configure on Win32.
+  #
+  echo $ac_n "checking printf format modifier for 64-bit integers""... $ac_c" 1>&6
+! echo "configure:8780: checking printf format modifier for 64-bit integers" >&5
+  if test "$cross_compiling" = yes; then
+    echo "$ac_t""assuming target platform uses ll" 1>&6
+       ISC_PLATFORM_QUADFORMAT='#define ISC_PLATFORM_QUADFORMAT "ll"'
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 8786 "configure"
+  #include "confdefs.h"
+  main() { exit(!(sizeof(long long int) == sizeof(long int))); }
+  EOF
+! if { (eval echo configure:8790: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+  then
+    echo "$ac_t""l" 1>&6
+       ISC_PLATFORM_QUADFORMAT='#define ISC_PLATFORM_QUADFORMAT "l"'
+***************
+*** 8798,8809 ****
+  # Security Stuff
+  #
+  echo $ac_n "checking for chroot""... $ac_c" 1>&6
+! echo "configure:8802: checking for chroot" >&5
+  if eval "test \"`echo '$''{'ac_cv_func_chroot'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 8807 "configure"
+  #include "confdefs.h"
+  /* System header to define __stub macros and hopefully few prototypes,
+      which can conflict with char chroot(); below.  */
+--- 8806,8817 ----
+  # Security Stuff
+  #
+  echo $ac_n "checking for chroot""... $ac_c" 1>&6
+! echo "configure:8810: checking for chroot" >&5
+  if eval "test \"`echo '$''{'ac_cv_func_chroot'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 8815 "configure"
+  #include "confdefs.h"
+  /* System header to define __stub macros and hopefully few prototypes,
+      which can conflict with char chroot(); below.  */
+***************
+*** 8826,8832 ****
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:8830: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_func_chroot=yes"
+  else
+--- 8834,8840 ----
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:8838: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_func_chroot=yes"
+  else
+***************
+*** 8860,8876 ****
+  do
+  ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+  echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+! echo "configure:8864: checking for $ac_hdr" >&5
+  if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 8869 "configure"
+  #include "confdefs.h"
+  #include <$ac_hdr>
+  EOF
+  ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+! { (eval echo configure:8874: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+  ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+  if test -z "$ac_err"; then
+    rm -rf conftest*
+--- 8868,8884 ----
+  do
+  ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+  echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+! echo "configure:8872: checking for $ac_hdr" >&5
+  if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 8877 "configure"
+  #include "confdefs.h"
+  #include <$ac_hdr>
+  EOF
+  ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+! { (eval echo configure:8882: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+  ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+  if test -z "$ac_err"; then
+    rm -rf conftest*
+***************
+*** 8904,8920 ****
+  do
+  ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+  echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+! echo "configure:8908: checking for $ac_hdr" >&5
+  if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 8913 "configure"
+  #include "confdefs.h"
+  #include <$ac_hdr>
+  EOF
+  ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+! { (eval echo configure:8918: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+  ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+  if test -z "$ac_err"; then
+    rm -rf conftest*
+--- 8912,8928 ----
+  do
+  ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+  echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+! echo "configure:8916: checking for $ac_hdr" >&5
+  if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 8921 "configure"
+  #include "confdefs.h"
+  #include <$ac_hdr>
+  EOF
+  ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+! { (eval echo configure:8926: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+  ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+  if test -z "$ac_err"; then
+    rm -rf conftest*
+***************
+*** 8945,8953 ****
+  # BSD/OS, and perhaps some others, don't define rlim_t.
+  #
+  echo $ac_n "checking for type rlim_t""... $ac_c" 1>&6
+! echo "configure:8949: checking for type rlim_t" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 8951 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/types.h>
+--- 8953,8961 ----
+  # BSD/OS, and perhaps some others, don't define rlim_t.
+  #
+  echo $ac_n "checking for type rlim_t""... $ac_c" 1>&6
+! echo "configure:8957: checking for type rlim_t" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 8959 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/types.h>
+***************
+*** 8957,8963 ****
+  rlim_t rl = 19671212; return (0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:8961: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    echo "$ac_t""yes" 1>&6
+   ISC_PLATFORM_RLIMITTYPE="#define ISC_PLATFORM_RLIMITTYPE rlim_t"
+--- 8965,8971 ----
+  rlim_t rl = 19671212; return (0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:8969: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    echo "$ac_t""yes" 1>&6
+   ISC_PLATFORM_RLIMITTYPE="#define ISC_PLATFORM_RLIMITTYPE rlim_t"
+***************
+*** 8968,8979 ****
+    echo "$ac_t""no" 1>&6
+  
+  echo $ac_n "checking type of rlim_cur""... $ac_c" 1>&6
+! echo "configure:8972: checking type of rlim_cur" >&5
+  if test "$cross_compiling" = yes; then
+    { echo "configure: error: cannot determine type of rlim_cur when cross compiling - define rlim_t" 1>&2; exit 1; }
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 8977 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/types.h>
+--- 8976,8987 ----
+    echo "$ac_t""no" 1>&6
+  
+  echo $ac_n "checking type of rlim_cur""... $ac_c" 1>&6
+! echo "configure:8980: checking type of rlim_cur" >&5
+  if test "$cross_compiling" = yes; then
+    { echo "configure: error: cannot determine type of rlim_cur when cross compiling - define rlim_t" 1>&2; exit 1; }
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 8985 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/types.h>
+***************
+*** 8981,8987 ****
+  #include <sys/resource.h>
+  main() { struct rlimit r; exit(!(sizeof(r.rlim_cur) == sizeof(int)));}
+  EOF
+! if { (eval echo configure:8985: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+  then
+    echo "$ac_t""int" 1>&6
+  ISC_PLATFORM_RLIMITTYPE="#define ISC_PLATFORM_RLIMITTYPE int"
+--- 8989,8995 ----
+  #include <sys/resource.h>
+  main() { struct rlimit r; exit(!(sizeof(r.rlim_cur) == sizeof(int)));}
+  EOF
+! if { (eval echo configure:8993: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+  then
+    echo "$ac_t""int" 1>&6
+  ISC_PLATFORM_RLIMITTYPE="#define ISC_PLATFORM_RLIMITTYPE int"
+***************
+*** 8994,9000 ****
+    { echo "configure: error: this cannot happen" 1>&2; exit 1; }
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 8998 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/types.h>
+--- 9002,9008 ----
+    { echo "configure: error: this cannot happen" 1>&2; exit 1; }
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 9006 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/types.h>
+***************
+*** 9002,9008 ****
+  #include <sys/resource.h>
+  main() { struct rlimit r; exit(!(sizeof(r.rlim_cur) == sizeof(long int)));}
+  EOF
+! if { (eval echo configure:9006: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+  then
+    echo "$ac_t""long int" 1>&6
+  ISC_PLATFORM_RLIMITTYPE="#define ISC_PLATFORM_RLIMITTYPE long int"
+--- 9010,9016 ----
+  #include <sys/resource.h>
+  main() { struct rlimit r; exit(!(sizeof(r.rlim_cur) == sizeof(long int)));}
+  EOF
+! if { (eval echo configure:9014: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+  then
+    echo "$ac_t""long int" 1>&6
+  ISC_PLATFORM_RLIMITTYPE="#define ISC_PLATFORM_RLIMITTYPE long int"
+***************
+*** 9015,9021 ****
+    { echo "configure: error: this cannot happen" 1>&2; exit 1; }
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 9019 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/types.h>
+--- 9023,9029 ----
+    { echo "configure: error: this cannot happen" 1>&2; exit 1; }
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 9027 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/types.h>
+***************
+*** 9023,9029 ****
+  #include <sys/resource.h>
+  main() { struct rlimit r; exit((!sizeof(r.rlim_cur) == sizeof(long long int)));}
+  EOF
+! if { (eval echo configure:9027: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+  then
+    echo "$ac_t""long long int" 1>&6
+  ISC_PLATFORM_RLIMITTYPE="#define ISC_PLATFORM_RLIMITTYPE long long int"
+--- 9031,9037 ----
+  #include <sys/resource.h>
+  main() { struct rlimit r; exit((!sizeof(r.rlim_cur) == sizeof(long long int)));}
+  EOF
+! if { (eval echo configure:9035: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+  then
+    echo "$ac_t""long long int" 1>&6
+  ISC_PLATFORM_RLIMITTYPE="#define ISC_PLATFORM_RLIMITTYPE long long int"
+***************
+*** 9147,9153 ****
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+  set dummy $ac_prog; ac_word=$2
+  echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+! echo "configure:9151: checking for $ac_word" >&5
+  if eval "test \"`echo '$''{'ac_cv_path_OPENJADE'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+--- 9155,9161 ----
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+  set dummy $ac_prog; ac_word=$2
+  echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+! echo "configure:9159: checking for $ac_word" >&5
+  if eval "test \"`echo '$''{'ac_cv_path_OPENJADE'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+***************
+*** 9194,9200 ****
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+  set dummy $ac_prog; ac_word=$2
+  echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+! echo "configure:9198: checking for $ac_word" >&5
+  if eval "test \"`echo '$''{'ac_cv_path_JADETEX'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+--- 9202,9208 ----
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+  set dummy $ac_prog; ac_word=$2
+  echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+! echo "configure:9206: checking for $ac_word" >&5
+  if eval "test \"`echo '$''{'ac_cv_path_JADETEX'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+***************
+*** 9237,9243 ****
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+  set dummy $ac_prog; ac_word=$2
+  echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+! echo "configure:9241: checking for $ac_word" >&5
+  if eval "test \"`echo '$''{'ac_cv_path_PDFJADETEX'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+--- 9245,9251 ----
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+  set dummy $ac_prog; ac_word=$2
+  echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+! echo "configure:9249: checking for $ac_word" >&5
+  if eval "test \"`echo '$''{'ac_cv_path_PDFJADETEX'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+***************
+*** 9293,9299 ****
+  
+  SGMLCATALOG=""
+  echo $ac_n "checking for catalog""... $ac_c" 1>&6
+! echo "configure:9297: checking for catalog" >&5
+  for d in $sgmltrees
+  do
+       f=$d/catalog
+--- 9301,9307 ----
+  
+  SGMLCATALOG=""
+  echo $ac_n "checking for catalog""... $ac_c" 1>&6
+! echo "configure:9305: checking for catalog" >&5
+  for d in $sgmltrees
+  do
+       f=$d/catalog
+***************
+*** 9335,9341 ****
+  
+  HTMLSTYLE=""
+  echo $ac_n "checking for html/docbook.dsl""... $ac_c" 1>&6
+! echo "configure:9339: checking for html/docbook.dsl" >&5
+  for d in $stylepath
+  do
+       f=$d/html/docbook.dsl
+--- 9343,9349 ----
+  
+  HTMLSTYLE=""
+  echo $ac_n "checking for html/docbook.dsl""... $ac_c" 1>&6
+! echo "configure:9347: checking for html/docbook.dsl" >&5
+  for d in $stylepath
+  do
+       f=$d/html/docbook.dsl
+***************
+*** 9356,9362 ****
+  
+  PRINTSTYLE=""
+  echo $ac_n "checking for print/docbook.dsl""... $ac_c" 1>&6
+! echo "configure:9360: checking for print/docbook.dsl" >&5
+  for d in $stylepath
+  do
+       f=$d/print/docbook.dsl
+--- 9364,9370 ----
+  
+  PRINTSTYLE=""
+  echo $ac_n "checking for print/docbook.dsl""... $ac_c" 1>&6
+! echo "configure:9368: checking for print/docbook.dsl" >&5
+  for d in $stylepath
+  do
+       f=$d/print/docbook.dsl
+***************
+*** 9382,9388 ****
+  
+  XMLDCL=""
+  echo $ac_n "checking for docbook/dsssl/modular/dtds/decls/xml.dcl""... $ac_c" 1>&6
+! echo "configure:9386: checking for docbook/dsssl/modular/dtds/decls/xml.dcl" >&5
+  for d in $sgmltrees
+  do
+       f=$d/docbook/dsssl/modular/dtds/decls/xml.dcl
+--- 9390,9396 ----
+  
+  XMLDCL=""
+  echo $ac_n "checking for docbook/dsssl/modular/dtds/decls/xml.dcl""... $ac_c" 1>&6
+! echo "configure:9394: checking for docbook/dsssl/modular/dtds/decls/xml.dcl" >&5
+  for d in $sgmltrees
+  do
+       f=$d/docbook/dsssl/modular/dtds/decls/xml.dcl
+***************
+*** 9408,9414 ****
+  
+  DOCBOOK2MANSPEC=""
+  echo $ac_n "checking for docbook2X/docbook2man-spec.pl""... $ac_c" 1>&6
+! echo "configure:9412: checking for docbook2X/docbook2man-spec.pl" >&5
+  for d in $sgmltrees
+  do
+       f=$d/docbook2X/docbook2man-spec.pl
+--- 9416,9422 ----
+  
+  DOCBOOK2MANSPEC=""
+  echo $ac_n "checking for docbook2X/docbook2man-spec.pl""... $ac_c" 1>&6
+! echo "configure:9420: checking for docbook2X/docbook2man-spec.pl" >&5
+  for d in $sgmltrees
+  do
+       f=$d/docbook2X/docbook2man-spec.pl
+***************
+*** 9428,9433 ****
+--- 9436,9631 ----
+  
+  
+  #
++ # IDN support
++ #
++ # Check whether --with-idn or --without-idn was given.
++ if test "${with_idn+set}" = set; then
++   withval="$with_idn"
++   use_idn="$withval"
++ else
++   use_idn="no"
++ fi
++ 
++ case "$use_idn" in
++ yes)
++      if test X$prefix = XNONE ; then
++              idn_path=/usr/local
++      else
++              idn_path=$prefix
++      fi
++      ;;
++ no)
++      ;;
++ *)
++      idn_path="$use_idn"
++      ;;
++ esac
++ 
++ iconvinc=
++ iconvlib=
++ # Check whether --with-libiconv or --without-libiconv was given.
++ if test "${with_libiconv+set}" = set; then
++   withval="$with_libiconv"
++   use_libiconv="$withval"
++ else
++   use_libiconv="no"
++ fi
++ 
++ case "$use_libiconv" in
++ yes)
++      if test X$prefix = XNONE ; then
++              iconvlib="-L/usr/local/lib -R/usr/local/lib -liconv"
++      else
++              iconvlib="-L$prefix/lib -R$prefix/lib -liconv"
++      fi
++      ;;
++ no)
++      iconvlib=
++      ;;
++ *)
++      iconvlib="-L$use_libiconv/lib -R$use_libiconv/lib -liconv"
++      ;;
++ esac
++ 
++ # Check whether --with-iconv or --without-iconv was given.
++ if test "${with_iconv+set}" = set; then
++   withval="$with_iconv"
++   iconvlib="$withval"
++ fi
++ 
++ case "$iconvlib" in
++ no)
++      iconvlib=
++      ;;
++ yes)
++      iconvlib=-liconv
++      ;;
++ esac
++ 
++ # Check whether --with-idnlib or --without-idnlib was given.
++ if test "${with_idnlib+set}" = set; then
++   withval="$with_idnlib"
++   idnlib="$withval"
++ else
++   idnlib="no"
++ fi
++ 
++ if test "$idnlib" = yes; then
++      { echo "configure: error: You must specify ARG for --with-idnlib." 1>&2; exit 1; }
++ fi
++ 
++ IDNLIBS=
++ if test "$use_idn" != no; then
++      cat >> confdefs.h <<\EOF
++ #define WITH_IDN 1
++ EOF
++ 
++      STD_CINCLUDES="$STD_CINCLUDES -I$idn_path/include"
++      if test "$idnlib" != no; then
++              IDNLIBS="$idnlib $iconvlib"
++      else
++              IDNLIBS="-L$idn_path/lib -lidnkit $iconvlib"
++      fi
++ fi
++ 
++ 
++ for ac_hdr in locale.h
++ do
++ ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
++ echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
++ echo "configure:9537: checking for $ac_hdr" >&5
++ if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
++   echo $ac_n "(cached) $ac_c" 1>&6
++ else
++   cat > conftest.$ac_ext <<EOF
++ #line 9542 "configure"
++ #include "confdefs.h"
++ #include <$ac_hdr>
++ EOF
++ ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
++ { (eval echo configure:9547: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
++ ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
++ if test -z "$ac_err"; then
++   rm -rf conftest*
++   eval "ac_cv_header_$ac_safe=yes"
++ else
++   echo "$ac_err" >&5
++   echo "configure: failed program was:" >&5
++   cat conftest.$ac_ext >&5
++   rm -rf conftest*
++   eval "ac_cv_header_$ac_safe=no"
++ fi
++ rm -f conftest*
++ fi
++ if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
++   echo "$ac_t""yes" 1>&6
++     ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
++   cat >> confdefs.h <<EOF
++ #define $ac_tr_hdr 1
++ EOF
++  
++ else
++   echo "$ac_t""no" 1>&6
++ fi
++ done
++ 
++ for ac_func in setlocale
++ do
++ echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
++ echo "configure:9576: checking for $ac_func" >&5
++ if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
++   echo $ac_n "(cached) $ac_c" 1>&6
++ else
++   cat > conftest.$ac_ext <<EOF
++ #line 9581 "configure"
++ #include "confdefs.h"
++ /* System header to define __stub macros and hopefully few prototypes,
++     which can conflict with char $ac_func(); below.  */
++ #include <assert.h>
++ /* Override any gcc2 internal prototype to avoid an error.  */
++ /* We use char because int might match the return type of a gcc2
++     builtin and then its argument prototype would still apply.  */
++ char $ac_func();
++ 
++ int main() {
++ 
++ /* The GNU C library defines this for functions which it implements
++     to always fail with ENOSYS.  Some functions are actually named
++     something starting with __ and the normal name is an alias.  */
++ #if defined (__stub_$ac_func) || defined (__stub___$ac_func)
++ choke me
++ #else
++ $ac_func();
++ #endif
++ 
++ ; return 0; }
++ EOF
++ if { (eval echo configure:9604: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++   rm -rf conftest*
++   eval "ac_cv_func_$ac_func=yes"
++ else
++   echo "configure: failed program was:" >&5
++   cat conftest.$ac_ext >&5
++   rm -rf conftest*
++   eval "ac_cv_func_$ac_func=no"
++ fi
++ rm -f conftest*
++ fi
++ 
++ if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
++   echo "$ac_t""yes" 1>&6
++     ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
++   cat >> confdefs.h <<EOF
++ #define $ac_tr_func 1
++ EOF
++  
++ else
++   echo "$ac_t""no" 1>&6
++ fi
++ done
++ 
++ 
++ #
+  # Substitutions
+  #
+  
+***************
+*** 9799,9804 ****
+--- 9997,10003 ----
+  s%@PRINTSTYLE@%$PRINTSTYLE%g
+  s%@XMLDCL@%$XMLDCL%g
+  s%@DOCBOOK2MANSPEC@%$DOCBOOK2MANSPEC%g
++ s%@IDNLIBS@%$IDNLIBS%g
+  s%@BIND9_TOP_BUILDDIR@%$BIND9_TOP_BUILDDIR%g
+  s%@BIND9_ISC_BUILDINCLUDE@%$BIND9_ISC_BUILDINCLUDE%g
+  s%@BIND9_ISCCC_BUILDINCLUDE@%$BIND9_ISCCC_BUILDINCLUDE%g
+***************
+*** 9828,9834 ****
+  
+  # Split the substitutions into bite-sized pieces for seds with
+  # small command number limits, like on Digital OSF/1 and HP-UX.
+! ac_max_sed_cmds=50 # Maximum number of lines to put in a sed script.
+  ac_file=1 # Number of current file.
+  ac_beg=1 # First line for current file.
+  ac_end=$ac_max_sed_cmds # Line after last line for current file.
+--- 10027,10033 ----
+  
+  # Split the substitutions into bite-sized pieces for seds with
+  # small command number limits, like on Digital OSF/1 and HP-UX.
+! ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script.
+  ac_file=1 # Number of current file.
+  ac_beg=1 # First line for current file.
+  ac_end=$ac_max_sed_cmds # Line after last line for current file.
+Index: configure.in
+diff -c mdn/othersrc/bind9/configure.in:1.1.1.9 mdn/othersrc/bind9/configure.in:1.15
+*** configure.in       Wed May 22 17:14:53 2002
+--- configure.in       Mon May 27 12:10:14 2002
+***************
+*** 1614,1619 ****
+--- 1614,1695 ----
+  NOM_PATH_FILE(DOCBOOK2MANSPEC, docbook2X/docbook2man-spec.pl, $sgmltrees)
+  
+  #
++ # IDN support
++ #
++ AC_ARG_WITH(idn,
++      [  --with-idn[=MPREFIX]   enable IDN support using idnkit [default PREFIX]],
++      use_idn="$withval", use_idn="no")
++ case "$use_idn" in
++ yes)
++      if test X$prefix = XNONE ; then
++              idn_path=/usr/local
++      else
++              idn_path=$prefix
++      fi
++      ;;
++ no)
++      ;;
++ *)
++      idn_path="$use_idn"
++      ;;
++ esac
++ 
++ iconvinc=
++ iconvlib=
++ AC_ARG_WITH(libiconv,
++      [  --with-libiconv[=IPREFIX]   GNU libiconv are in IPREFIX [default PREFIX]],
++      use_libiconv="$withval", use_libiconv="no")
++ case "$use_libiconv" in
++ yes)
++      if test X$prefix = XNONE ; then
++              iconvlib="-L/usr/local/lib -R/usr/local/lib -liconv"
++      else
++              iconvlib="-L$prefix/lib -R$prefix/lib -liconv"
++      fi
++      ;;
++ no)
++      iconvlib=
++      ;;
++ *)
++      iconvlib="-L$use_libiconv/lib -R$use_libiconv/lib -liconv"
++      ;;
++ esac
++ 
++ AC_ARG_WITH(iconv,
++      [  --with-iconv[=LIBSPEC]   specify iconv library [default -liconv]],
++      iconvlib="$withval")
++ case "$iconvlib" in
++ no)
++      iconvlib=
++      ;;
++ yes)
++      iconvlib=-liconv
++      ;;
++ esac
++ 
++ AC_ARG_WITH(idnlib,
++      [  --with-idnlib=ARG    specify libidnkit],
++      idnlib="$withval", idnlib="no")
++ if test "$idnlib" = yes; then
++      AC_MSG_ERROR([You must specify ARG for --with-idnlib.])
++ fi
++ 
++ IDNLIBS=
++ if test "$use_idn" != no; then
++      AC_DEFINE(WITH_IDN, 1, [define if idnkit support is to be included.])
++      STD_CINCLUDES="$STD_CINCLUDES -I$idn_path/include"
++      if test "$idnlib" != no; then
++              IDNLIBS="$idnlib $iconvlib"
++      else
++              IDNLIBS="-L$idn_path/lib -lidnkit $iconvlib"
++      fi
++ fi
++ AC_SUBST(IDNLIBS)
++ 
++ AC_CHECK_HEADERS(locale.h)
++ AC_CHECK_FUNCS(setlocale)
++ 
++ #
+  # Substitutions
+  #
+  AC_SUBST(BIND9_TOP_BUILDDIR)
+Index: bin/dig/Makefile.in
+diff -c mdn/othersrc/bind9/bin/dig/Makefile.in:1.1.1.6 mdn/othersrc/bind9/bin/dig/Makefile.in:1.3
+*** bin/dig/Makefile.in        Tue Nov 27 16:55:50 2001
+--- bin/dig/Makefile.in        Tue Mar 19 16:45:35 2002
+***************
+*** 36,42 ****
+  
+  DEPLIBS =    ${DNSDEPLIBS} ${ISCDEPLIBS}
+  
+! LIBS =               ${DNSLIBS} ${ISCLIBS} @LIBS@
+  
+  SUBDIRS =
+  
+--- 36,42 ----
+  
+  DEPLIBS =    ${DNSDEPLIBS} ${ISCDEPLIBS}
+  
+! LIBS =               ${DNSLIBS} ${ISCLIBS} @IDNLIBS@ @LIBS@
+  
+  SUBDIRS =
+  
+Index: bin/dig/dig.1
+diff -c mdn/othersrc/bind9/bin/dig/dig.1:1.1.1.2 mdn/othersrc/bind9/bin/dig/dig.1:1.4
+*** bin/dig/dig.1      Wed May 22 17:14:53 2002
+--- bin/dig/dig.1      Mon May 27 12:10:14 2002
+***************
+*** 349,354 ****
+--- 349,365 ----
+  \fI+noqr\fR which means that \fBdig\fR
+  will not print the initial query when it looks up the NS records for
+  isc.org.
++ .SH "IDN SUPPORT"
++ .PP
++ If \fBdig\fR has been built with IDN (internationalized
++ domain name) support, it can accept and display non-ASCII domain names.
++ \fBdig\fR appropriately converts character encoding of
++ domain name before sending a request to DNS server or displaying a
++ reply from the server.
++ If you'd like to turn off the IDN support for some reason, defines
++ the \fBIDN_DISABLE\fR environment variable.
++ The IDN support is disabled if the the variable is set when 
++ \fBdig\fR runs.
+  .SH "FILES"
+  .PP
+  \fI/etc/resolv.conf\fR
+Index: bin/dig/dig.docbook
+diff -c mdn/othersrc/bind9/bin/dig/dig.docbook:1.1.1.2 mdn/othersrc/bind9/bin/dig/dig.docbook:1.4
+*** bin/dig/dig.docbook        Wed May 22 17:14:53 2002
+--- bin/dig/dig.docbook        Mon May 27 12:10:15 2002
+***************
+*** 523,528 ****
+--- 523,543 ----
+  </refsect1>
+  
+  <refsect1>
++ <title>IDN SUPPORT</title>
++ <para>
++ If <command>dig</command> has been built with IDN (internationalized
++ domain name) support, it can accept and display non-ASCII domain names.
++ <command>dig</command> appropriately converts character encoding of
++ domain name before sending a request to DNS server or displaying a
++ reply from the server.
++ If you'd like to turn off the IDN support for some reason, defines
++ the <envar>IDN_DISABLE</envar> environment variable.
++ The IDN support is disabled if the the variable is set when 
++ <command>dig</command> runs.
++ </para>
++ </refsect1>
++ 
++ <refsect1>
+  <title>FILES</title>
+  <para>
+  <filename>/etc/resolv.conf</filename>
+Index: bin/dig/dighost.c
+diff -c mdn/othersrc/bind9/bin/dig/dighost.c:1.1.1.12 mdn/othersrc/bind9/bin/dig/dighost.c:1.32
+*** bin/dig/dighost.c  Wed May 22 17:14:53 2002
+--- bin/dig/dighost.c  Mon May 27 12:10:15 2002
+***************
+*** 32,37 ****
+--- 32,48 ----
+  #include <string.h>
+  #include <limits.h>
+  
++ #ifdef HAVE_LOCALE_H
++ #include <locale.h>
++ #endif
++ 
++ #ifdef WITH_IDN
++ #include <idn/result.h>
++ #include <idn/log.h>
++ #include <idn/resconf.h>
++ #include <idn/api.h>
++ #endif
++ 
+  #include <dns/byaddr.h>
+  #include <dns/fixedname.h>
+  #include <dns/message.h>
+***************
+*** 130,135 ****
+--- 141,158 ----
+  isc_mutex_t lookup_lock;
+  dig_lookup_t *current_lookup = NULL;
+  
++ #ifdef WITH_IDN
++ static void        initialize_idn(void);
++ static isc_result_t   output_filter(isc_buffer_t *buffer,
++                                  unsigned int used_org,
++                                  isc_boolean_t absolute);
++ static idn_result_t   append_textname(char *name, const char *origin,
++                                    size_t namesize);
++ static void        idn_check_result(idn_result_t r, const char *msg);
++ 
++ #define MAXDLEN               256
++ #endif
++ 
+  /*
+   * Apply and clear locks at the event level in global task.
+   * Can I get rid of these using shutdown events?  XXX
+***************
+*** 648,653 ****
+--- 671,680 ----
+               ISC_LIST_APPEND(server_list, srv, link);
+       }
+  
++ #ifdef WITH_IDN
++      initialize_idn();
++ #endif
++ 
+       if (keyfile[0] != 0)
+               setup_file_key();
+       else if (keysecret[0] != 0)
+***************
+*** 1168,1173 ****
+--- 1195,1208 ----
+       isc_buffer_t b;
+       dns_compress_t cctx;
+       char store[MXNAME];
++ #ifdef WITH_IDN
++      idn_result_t mr;
++      char utf8_textname[MXNAME], utf8_origin[MXNAME], idn_textname[MXNAME];
++ #endif
++ 
++ #ifdef WITH_IDN
++      dns_name_settotextfilter(output_filter);
++ #endif
+  
+       REQUIRE(lookup != NULL);
+       INSIST(!free_now);
+***************
+*** 1196,1201 ****
+--- 1231,1247 ----
+       isc_buffer_init(&lookup->onamebuf, lookup->onamespace,
+                       sizeof(lookup->onamespace));
+  
++ #ifdef WITH_IDN
++      /*
++       * We cannot convert `textname' and `origin' separately.
++       * `textname' doesn't contain TLD, but local mapping needs
++       * TLD.
++       */
++      mr = idn_encodename(IDN_LOCALCONV | IDN_DELIMMAP, lookup->textname,
++                          utf8_textname, sizeof(utf8_textname));
++      idn_check_result(mr, "convert textname to UTF-8");
++ #endif
++ 
+       /*
+        * If the name has too many dots, force the origin to be NULL
+        * (which produces an absolute lookup).  Otherwise, take the origin
+***************
+*** 1204,1215 ****
+--- 1250,1290 ----
+        * is TRUE or we got a domain line in the resolv.conf file.
+        */
+       /* XXX New search here? */
++ #ifdef WITH_IDN
++      if ((count_dots(utf8_textname) >= ndots) || !usesearch)
++              lookup->origin = NULL; /* Force abs lookup */
++      else if (lookup->origin == NULL && lookup->new_search && usesearch) {
++              lookup->origin = ISC_LIST_HEAD(search_list);
++      }
++ #else
+       if ((count_dots(lookup->textname) >= ndots) || !usesearch)
+               lookup->origin = NULL; /* Force abs lookup */
+       else if (lookup->origin == NULL && lookup->new_search && usesearch) {
+               lookup->origin = ISC_LIST_HEAD(search_list);
+       }
++ #endif
++ 
++ #ifdef WITH_IDN
+       if (lookup->origin != NULL) {
++              mr = idn_encodename(IDN_LOCALCONV | IDN_DELIMMAP,
++                                  lookup->origin->origin, utf8_origin,
++                                  sizeof(utf8_origin));
++              idn_check_result(mr, "convert origin to UTF-8");
++              mr = append_textname(utf8_textname, utf8_origin,
++                                   sizeof(utf8_textname));
++              idn_check_result(mr, "append origin to textname");
++      }
++      mr = idn_encodename(IDN_LOCALMAP | IDN_NAMEPREP | IDN_ASCCHECK |
++                          IDN_IDNCONV | IDN_LENCHECK, utf8_textname,
++                          idn_textname, sizeof(idn_textname));
++      idn_check_result(mr, "convert UTF-8 textname to IDN encoding");
++ #endif
++ 
++ #ifdef WITH_IDN
++      if (0) {
++ #else
++      if (lookup->origin != NULL) {
++ #endif
+               debug("trying origin %s", lookup->origin->origin);
+               result = dns_message_gettempname(lookup->sendmsg,
+                                                &lookup->oname);
+***************
+*** 1254,1259 ****
+--- 1329,1343 ----
+               if (lookup->trace && lookup->trace_root)
+                       dns_name_clone(dns_rootname, lookup->name);
+               else {
++ #ifdef WITH_IDN
++                      len = strlen(idn_textname);
++                      isc_buffer_init(&b, idn_textname, len);
++                      isc_buffer_add(&b, len);
++                      result = dns_name_fromtext(lookup->name, &b,
++                                                 dns_rootname,
++                                                 ISC_FALSE,
++                                                 &lookup->namebuf);
++ #else
+                       len = strlen(lookup->textname);
+                       isc_buffer_init(&b, lookup->textname, len);
+                       isc_buffer_add(&b, len);
+***************
+*** 1261,1266 ****
+--- 1345,1351 ----
+                                                  dns_rootname,
+                                                  ISC_FALSE,
+                                                  &lookup->namebuf);
++ #endif
+               }
+               if (result != ISC_R_SUCCESS) {
+                       dns_message_puttempname(lookup->sendmsg,
+***************
+*** 2591,2593 ****
+--- 2676,2776 ----
+       if (mctx != NULL)
+               isc_mem_destroy(&mctx);
+  }
++ 
++ #ifdef WITH_IDN
++ static void
++ initialize_idn(void) {
++      idn_result_t r;
++ 
++ #ifdef HAVE_SETLOCALE
++      /* Set locale */
++      (void)setlocale(LC_ALL, "");
++ #endif
++      /* Create configuration context. */
++      r = idn_nameinit(1);
++      if (r != idn_success)
++              fatal("idn api initialization failed: %s",
++                    idn_result_tostring(r));
++ 
++      /* Set domain name -> text post-conversion filter. */
++      dns_name_settotextfilter(output_filter);
++ }
++ 
++ static isc_result_t
++ output_filter(isc_buffer_t *buffer, unsigned int used_org,
++            isc_boolean_t absolute)
++ {
++      char tmp1[MAXDLEN], tmp2[MAXDLEN];
++      size_t fromlen, tolen;
++      isc_boolean_t end_with_dot;
++ 
++      /*
++       * Copy contents of 'buffer' to 'tmp1', supply trailing dot
++       * if 'absolute' is true, and terminate with NUL.
++       */
++      fromlen = isc_buffer_usedlength(buffer) - used_org;
++      if (fromlen >= MAXDLEN)
++              return (ISC_R_SUCCESS);
++      memcpy(tmp1, (char *)isc_buffer_base(buffer) + used_org, fromlen);
++      end_with_dot = (tmp1[fromlen - 1] == '.') ? ISC_TRUE : ISC_FALSE;
++      if (absolute && !end_with_dot) {
++              fromlen++;
++              if (fromlen >= MAXDLEN)
++                      return (ISC_R_SUCCESS);
++              tmp1[fromlen - 1] = '.';
++      }
++      tmp1[fromlen] = '\0';
++ 
++      /*
++       * Convert contents of 'tmp1' to local encoding.
++       */
++      if (idn_decodename(IDN_DECODE_APP, tmp1, tmp2, MAXDLEN) != idn_success)
++              return (ISC_R_SUCCESS);
++      strcpy(tmp1, tmp2);
++ 
++      /*
++       * Copy the converted contents in 'tmp1' back to 'buffer'.
++       * If we have appended trailing dot, remove it.
++       */
++      tolen = strlen(tmp1);
++      if (absolute && !end_with_dot && tmp1[tolen - 1] == '.')
++              tolen--;
++ 
++      if (isc_buffer_length(buffer) < used_org + tolen)
++              return (ISC_R_NOSPACE);
++ 
++      isc_buffer_subtract(buffer, isc_buffer_usedlength(buffer) - used_org);
++      memcpy(isc_buffer_used(buffer), tmp1, tolen);
++      isc_buffer_add(buffer, tolen);
++ 
++      return (ISC_R_SUCCESS);
++ }
++ 
++ static idn_result_t
++ append_textname(char *name, const char *origin, size_t namesize) {
++      size_t namelen = strlen(name);
++      size_t originlen = strlen(origin);
++ 
++      /* Already absolute? */
++      if (namelen > 0 && name[namelen - 1] == '.')
++              return idn_success;
++ 
++      /* Append dot and origin */
++ 
++      if (namelen + 1 + originlen >= namesize)
++              return idn_buffer_overflow;
++ 
++      name[namelen++] = '.';
++      (void)strcpy(name + namelen, origin);
++      return idn_success;
++ }
++ 
++ static void
++ idn_check_result(idn_result_t r, const char *msg) {
++      if (r != idn_success) {
++              exitcode = 1;
++              fatal("%s: %s", msg, idn_result_tostring(r));
++      }
++ }
++ 
++ #endif /* WITH_IDN */
+Index: bin/dig/host.1
+diff -c mdn/othersrc/bind9/bin/dig/host.1:1.1.1.1 mdn/othersrc/bind9/bin/dig/host.1:1.3
+*** bin/dig/host.1     Tue Nov 27 16:55:51 2001
+--- bin/dig/host.1     Tue Mar 19 16:45:36 2002
+***************
+*** 120,125 ****
+--- 120,136 ----
+  effectively wait forever for a reply. The time to wait for a response
+  will be set to the number of seconds given by the hardware's maximum
+  value for an integer quantity.
++ .SH "IDN SUPPORT"
++ .PP
++ If \fBhost\fR has been built with IDN (internationalized
++ domain name) support, it can accept and display non-ASCII domain names.
++ \fBhost\fR appropriately converts character encoding of
++ domain name before sending a request to DNS server or displaying a
++ reply from the server.
++ If you'd like to turn off the IDN support for some reason, defines
++ the \fBIDN_DISABLE\fR environment variable.
++ The IDN support is disabled if the the variable is set when
++ \fBhost\fR runs.
+  .SH "FILES"
+  .PP
+  \fI/etc/resolv.conf\fR
+Index: bin/dig/host.docbook
+diff -c mdn/othersrc/bind9/bin/dig/host.docbook:1.1.1.1 mdn/othersrc/bind9/bin/dig/host.docbook:1.3
+*** bin/dig/host.docbook       Tue Nov 27 16:55:51 2001
+--- bin/dig/host.docbook       Tue Mar 19 16:45:36 2002
+***************
+*** 181,186 ****
+--- 181,201 ----
+  </refsect1>
+  
+  <refsect1>
++ <title>IDN SUPPORT</title>
++ <para>
++ If <command>host</command> has been built with IDN (internationalized
++ domain name) support, it can accept and display non-ASCII domain names.
++ <command>host</command> appropriately converts character encoding of
++ domain name before sending a request to DNS server or displaying a
++ reply from the server.
++ If you'd like to turn off the IDN support for some reason, defines
++ the <envar>IDN_DISABLE</envar> environment variable.
++ The IDN support is disabled if the the variable is set when
++ <command>host</command> runs.
++ </para>
++ </refsect1>
++ 
++ <refsect1>
+  <title>FILES</title>
+  <para>
+  <filename>/etc/resolv.conf</filename>
+Index: lib/dns/name.c
+diff -c mdn/othersrc/bind9/lib/dns/name.c:1.1.1.10 mdn/othersrc/bind9/lib/dns/name.c:1.14
+*** lib/dns/name.c     Wed May 22 17:15:27 2002
+--- lib/dns/name.c     Mon May 27 12:10:15 2002
+***************
+*** 194,199 ****
+--- 194,206 ----
+  /* XXXDCL make const? */
+  dns_name_t *dns_wildcardname = &wild;
+  
++ #ifdef WITH_IDN
++ /*
++  * dns_name_t to text post-conversion procedure.
++  */
++ static dns_name_totextfilter_t totext_filter_proc = NULL;
++ #endif
++ 
+  static void
+  set_offsets(const dns_name_t *name, unsigned char *offsets,
+           dns_name_t *set_name);
+***************
+*** 1682,1687 ****
+--- 1689,1697 ----
+       unsigned int labels;
+       isc_boolean_t saw_root = ISC_FALSE;
+       char num[4];
++ #ifdef WITH_IDN
++      unsigned int oused = target->used;
++ #endif
+  
+       /*
+        * This function assumes the name is in proper uncompressed
+***************
+*** 1859,1864 ****
+--- 1869,1878 ----
+  
+       isc_buffer_add(target, tlen - trem);
+  
++ #ifdef WITH_IDN
++      if (totext_filter_proc != NULL)
++              return ((*totext_filter_proc)(target, oused, saw_root));
++ #endif
+       return (ISC_R_SUCCESS);
+  }
+  
+***************
+*** 3315,3317 ****
+--- 3329,3337 ----
+       return (ISC_R_SUCCESS);
+  }
+  
++ #ifdef WITH_IDN
++ void
++ dns_name_settotextfilter(dns_name_totextfilter_t proc) {
++      totext_filter_proc = proc;
++ }
++ #endif
+Index: lib/dns/include/dns/name.h
+diff -c mdn/othersrc/bind9/lib/dns/include/dns/name.h:1.1.1.7 mdn/othersrc/bind9/lib/dns/include/dns/name.h:1.10
+*** lib/dns/include/dns/name.h Wed May 22 17:15:29 2002
+--- lib/dns/include/dns/name.h Mon May 27 12:10:15 2002
+***************
+*** 219,224 ****
+--- 219,235 ----
+   */
+  #define DNS_NAME_MAXWIRE 255
+  
++ #ifdef WITH_IDN
++ /*
++  * Text output filter procedure.
++  * 'target' is the buffer to be converted.  The region to be converted
++  * is from 'buffer'->base + 'used_org' to the end of the used region.
++  */
++ typedef isc_result_t (*dns_name_totextfilter_t)(isc_buffer_t *target,
++                                              unsigned int used_org,
++                                              isc_boolean_t absolute);
++ #endif
++ 
+  /***
+   *** Initialization
+   ***/
+***************
+*** 1244,1249 ****
+--- 1255,1268 ----
+   *   'size' > 0.
+   *
+   */
++ 
++ #ifdef WITH_IDN
++ void
++ dns_name_settotextfilter(dns_name_totextfilter_t proc);
++ /*
++  * Call 'proc' at the end of dns_name_totext.
++  */
++ #endif /* WITH_IDN */
+  
+  #define DNS_NAME_FORMATSIZE (DNS_NAME_MAXTEXT + 1)
+  /*
diff --git a/contrib/idn/idnkit-1.0-src/patch/bind9/bind-9.2.2-patch b/contrib/idn/idnkit-1.0-src/patch/bind9/bind-9.2.2-patch
new file mode 100644 (file)
index 0000000..151f9dd
--- /dev/null
@@ -0,0 +1,1169 @@
+IDN patch for bind-9.2.2
+========================
+
+
+This is a patch file for ISC BIND 9.2.2 to make it work with
+internationalized domain names.  With this patch you'll get IDN-aware
+dig/host/nslookup.
+
+To apply this patch, you should go to the top directory of the BIND
+distribution (where you see `README' file), then invoke `patch'
+command like this:
+
+       % patch -p0 < this-file
+
+Then follow the instructions described in `README.idnkit' to compile
+and install.
+
+
+Index: README.idnkit
+diff -c /dev/null mdn/othersrc/bind9/README.idnkit:1.3
+*** README.idnkit      Tue Mar 11 08:55:20 2003
+--- README.idnkit      Mon Mar 10 09:47:41 2003
+***************
+*** 0 ****
+--- 1,113 ----
++ 
++                      BIND-9 IDN patch
++ 
++             Japan Network Information Center (JPNIC)
++ 
++ 
++ * What is this patch for?
++ 
++ This patch adds internationalized domain name (IDN) support to BIND-9.
++ You'll get internationalized version of dig/host/nslookup commands.
++ 
++     + internationalized dig/host/nslookup
++      dig/host/nslookup accepts non-ASCII domain names in the local
++      codeset (such as Shift JIS, Big5 or ISO8859-1) determined by
++      the locale information.  The domain names are normalized and
++      converted to the encoding on the DNS protocol, and sent to DNS
++      servers.  The replies are converted back to the local codeset
++      and displayed.
++ 
++ 
++ * Compilation & installation
++ 
++ 0. Prerequisite
++ 
++ You have to build and install idnkit before building this patched version
++ of bind-9.
++ 
++ 1. Running configure script
++ 
++ Run `configure' in the top directory.  See `README' for the
++ configuration options.
++ 
++ This patch adds the following 4 options to `configure'.  You should
++ at least specify `--with-idn' option to enable IDN support.
++ 
++     --with-idn[=IDN_PREFIX]
++      To enable IDN support, you have to specify `--with-idn' option.
++      The argument IDN_PREFIX is the install prefix of idnkit.  If
++      IDN_PREFIX is omitted, PREFIX (derived from `--prefix=PREFIX')
++      is assumed.
++ 
++     --with-libiconv[=LIBICONV_PREFIX]
++      Specify this option if idnkit you have installed links GNU
++      libiconv.  The argument LIBICONV_PREFIX is install prefix of
++      GNU libiconv.  If the argument is omitted, PREFIX (derived
++      from `--prefix=PREFIX') is assumed.
++ 
++      `--with-libiconv' is shorthand option for GNU libiconv.
++ 
++          --with-libiconv=/usr/local
++ 
++      This is equivalent to:
++ 
++          --with-iconv='-L/usr/local/lib -R/usr/local/lib -liconv'
++ 
++      `--with-libiconv' assumes that your C compiler has `-R'
++      option, and that the option adds the specified run-time path
++      to an exacutable binary.  If `-R' option of your compiler has
++      different meaning, or your compiler lacks the option, you
++      should use `--with-iconv' option instead.  Binary command
++      without run-time path information might be unexecutable.
++      In that case, you would see an error message like:
++ 
++          error in loading shared libraries: libiconv.so.2: cannot
++          open shared object file
++ 
++      If both `--with-libiconv' and `--with-iconv' options are
++      specified, `--with-iconv' is prior to `--with-libiconv'.
++ 
++     --with-iconv=ICONV_LIBSPEC
++      If your libc doens't provide iconv(), you need to specify the
++      library containing iconv() with this option.  `ICONV_LIBSPEC'
++      is the argument(s) to `cc' or `ld' to link the library, for
++      example, `--with-iconv="-L/usr/local/lib -liconv"'.
++      You don't need to specify the header file directory for "iconv.h"
++      to the compiler, as it isn't included directly by bind-9 with
++      this patch.
++ 
++     --with-idnlib=IDN_LIBSPEC
++      With this option, you can explicitly specify the argument(s)
++      to `cc' or `ld' to link the idnkit's library, `libidnkit'.  If
++      this option is not specified, `-L${PREFIX}/lib -lidnkit' is
++      assumed, where ${PREFIX} is the installation prefix specified
++      with `--with-idn' option above.  You may need to use this
++      option to specify extra argments, for example,
++      `--with-idnlib="-L/usr/local/lib -R/usr/local/lib -lidnkit"'.
++ 
++ Please consult `README' for other configuration options.
++ 
++ Note that if you want to specify some extra header file directories,
++ you should use the environment variable STD_CINCLUDES instead of
++ CFLAGS, as described in README.
++ 
++ 2. Compilation and installation
++ 
++ After running "configure", just do
++ 
++      make
++      make install
++ 
++ for compiling and installing.
++ 
++ 
++ * Contact information
++ 
++ Please see http//www.nic.ad.jp/en/idn/ for the latest news
++ about idnkit and this patch.
++ 
++ Bug reports and comments on this kit should be sent to
++ mdnkit-bugs@nic.ad.jp and idn-cmt@nic.ad.jp, respectively.
++ 
++ 
++ ; $Id: bind-9.2.2-patch,v 1.1 2003/06/04 00:27:32 marka Exp $
+Index: config.h.in
+diff -c mdn/othersrc/bind9/config.h.in:1.1.1.6 mdn/othersrc/bind9/config.h.in:1.12
+*** config.h.in        Tue Nov 27 16:55:45 2001
+--- config.h.in        Tue Mar 19 16:45:35 2002
+***************
+*** 141,146 ****
+--- 141,149 ----
+  /* define if you have strerror in the C library. */
+  #undef HAVE_STRERROR
+  
++ /* Define if you have the setlocale function.  */
++ #undef HAVE_SETLOCALE
++ 
+  /* Define if you have the <dlfcn.h> header file.  */
+  #undef HAVE_DLFCN_H
+  
+***************
+*** 150,155 ****
+--- 153,161 ----
+  /* Define if you have the <linux/capability.h> header file.  */
+  #undef HAVE_LINUX_CAPABILITY_H
+  
++ /* Define if you have the <locale.h> header file.  */
++ #undef HAVE_LOCALE_H
++ 
+  /* Define if you have the <sys/prctl.h> header file.  */
+  #undef HAVE_SYS_PRCTL_H
+  
+***************
+*** 176,178 ****
+--- 182,188 ----
+  
+  /* Define if you have the socket library (-lsocket).  */
+  #undef HAVE_LIBSOCKET
++ 
++ /* define if idnkit support is to be included. */
++ #undef WITH_IDN
++ 
+Index: configure
+diff -c mdn/othersrc/bind9/configure:1.1.1.10 mdn/othersrc/bind9/configure:1.16
+*** configure  Wed Mar  5 17:14:55 2003
+--- configure  Thu Mar  6 20:10:05 2003
+***************
+*** 1007,1012 ****
+--- 1007,1016 ----
+      --with-gnu-ld           assume the C compiler uses GNU ld default=no
+      --with-pic              try to use only PIC/non-PIC objects default=use both
+    --with-kame=PATH   use Kame IPv6 default path /usr/local/v6
++   --with-idn=MPREFIX   enable IDN support using idnkit default PREFIX
++   --with-libiconv=IPREFIX   GNU libiconv are in IPREFIX default PREFIX
++   --with-iconv=LIBSPEC   specify iconv library default -liconv
++   --with-idnlib=ARG    specify libidnkit
+  
+  Some influential environment variables:
+    CC          C compiler command
+***************
+*** 7371,7377 ****
+  case $host in
+  *-*-irix6*)
+    # Find out which ABI we are using.
+!   echo '#line 7374 "configure"' > conftest.$ac_ext
+    if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+    (eval $ac_compile) 2>&5
+    ac_status=$?
+--- 7375,7381 ----
+  case $host in
+  *-*-irix6*)
+    # Find out which ABI we are using.
+!   echo '#line 7378 "configure"' > conftest.$ac_ext
+    if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+    (eval $ac_compile) 2>&5
+    ac_status=$?
+***************
+*** 7914,7920 ****
+  save_CFLAGS="$CFLAGS"
+  CFLAGS="$CFLAGS -o out/conftest2.$ac_objext"
+  compiler_c_o=no
+! if { (eval echo configure:7917: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>out/conftest.err; } && test -s out/conftest2.$ac_objext; then
+    # The compiler can only warn and ignore the option if not recognized
+    # So say no if there are warnings
+    if test -s out/conftest.err; then
+--- 7918,7924 ----
+  save_CFLAGS="$CFLAGS"
+  CFLAGS="$CFLAGS -o out/conftest2.$ac_objext"
+  compiler_c_o=no
+! if { (eval echo configure:7921: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>out/conftest.err; } && test -s out/conftest2.$ac_objext; then
+    # The compiler can only warn and ignore the option if not recognized
+    # So say no if there are warnings
+    if test -s out/conftest.err; then
+***************
+*** 9599,9605 ****
+      lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+    lt_status=$lt_dlunknown
+    cat > conftest.$ac_ext <<EOF
+! #line 9602 "configure"
+  #include "confdefs.h"
+  
+  #if HAVE_DLFCN_H
+--- 9603,9609 ----
+      lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+    lt_status=$lt_dlunknown
+    cat > conftest.$ac_ext <<EOF
+! #line 9606 "configure"
+  #include "confdefs.h"
+  
+  #if HAVE_DLFCN_H
+***************
+*** 9697,9703 ****
+      lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+    lt_status=$lt_dlunknown
+    cat > conftest.$ac_ext <<EOF
+! #line 9700 "configure"
+  #include "confdefs.h"
+  
+  #if HAVE_DLFCN_H
+--- 9701,9707 ----
+      lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+    lt_status=$lt_dlunknown
+    cat > conftest.$ac_ext <<EOF
+! #line 9704 "configure"
+  #include "confdefs.h"
+  
+  #if HAVE_DLFCN_H
+***************
+*** 13265,13270 ****
+--- 13269,13580 ----
+  
+  
+  #
++ # IDN support
++ #
++ 
++ # Check whether --with-idn or --without-idn was given.
++ if test "${with_idn+set}" = set; then
++   withval="$with_idn"
++   use_idn="$withval"
++ else
++   use_idn="no"
++ fi;
++ case "$use_idn" in
++ yes)
++      if test X$prefix = XNONE ; then
++              idn_path=/usr/local
++      else
++              idn_path=$prefix
++      fi
++      ;;
++ no)
++      ;;
++ *)
++      idn_path="$use_idn"
++      ;;
++ esac
++ 
++ iconvinc=
++ iconvlib=
++ 
++ # Check whether --with-libiconv or --without-libiconv was given.
++ if test "${with_libiconv+set}" = set; then
++   withval="$with_libiconv"
++   use_libiconv="$withval"
++ else
++   use_libiconv="no"
++ fi;
++ case "$use_libiconv" in
++ yes)
++      if test X$prefix = XNONE ; then
++              iconvlib="-L/usr/local/lib -R/usr/local/lib -liconv"
++      else
++              iconvlib="-L$prefix/lib -R$prefix/lib -liconv"
++      fi
++      ;;
++ no)
++      iconvlib=
++      ;;
++ *)
++      iconvlib="-L$use_libiconv/lib -R$use_libiconv/lib -liconv"
++      ;;
++ esac
++ 
++ 
++ # Check whether --with-iconv or --without-iconv was given.
++ if test "${with_iconv+set}" = set; then
++   withval="$with_iconv"
++   iconvlib="$withval"
++ fi;
++ case "$iconvlib" in
++ no)
++      iconvlib=
++      ;;
++ yes)
++      iconvlib=-liconv
++      ;;
++ esac
++ 
++ 
++ # Check whether --with-idnlib or --without-idnlib was given.
++ if test "${with_idnlib+set}" = set; then
++   withval="$with_idnlib"
++   idnlib="$withval"
++ else
++   idnlib="no"
++ fi;
++ if test "$idnlib" = yes; then
++      { { echo "$as_me:$LINENO: error: You must specify ARG for --with-idnlib." >&5
++ echo "$as_me: error: You must specify ARG for --with-idnlib." >&2;}
++    { (exit 1); exit 1; }; }
++ fi
++ 
++ IDNLIBS=
++ if test "$use_idn" != no; then
++ 
++ cat >>confdefs.h <<\_ACEOF
++ #define WITH_IDN 1
++ _ACEOF
++ 
++      STD_CINCLUDES="$STD_CINCLUDES -I$idn_path/include"
++      if test "$idnlib" != no; then
++              IDNLIBS="$idnlib $iconvlib"
++      else
++              IDNLIBS="-L$idn_path/lib -lidnkit $iconvlib"
++      fi
++ fi
++ 
++ 
++ 
++ for ac_header in locale.h
++ do
++ as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
++ if eval "test \"\${$as_ac_Header+set}\" = set"; then
++   echo "$as_me:$LINENO: checking for $ac_header" >&5
++ echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
++ if eval "test \"\${$as_ac_Header+set}\" = set"; then
++   echo $ECHO_N "(cached) $ECHO_C" >&6
++ fi
++ echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
++ echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
++ else
++   # Is the header compilable?
++ echo "$as_me:$LINENO: checking $ac_header usability" >&5
++ echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
++ cat >conftest.$ac_ext <<_ACEOF
++ #line $LINENO "configure"
++ #include "confdefs.h"
++ $ac_includes_default
++ #include <$ac_header>
++ _ACEOF
++ rm -f conftest.$ac_objext
++ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
++   (eval $ac_compile) 2>&5
++   ac_status=$?
++   echo "$as_me:$LINENO: \$? = $ac_status" >&5
++   (exit $ac_status); } &&
++          { ac_try='test -s conftest.$ac_objext'
++   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++   (eval $ac_try) 2>&5
++   ac_status=$?
++   echo "$as_me:$LINENO: \$? = $ac_status" >&5
++   (exit $ac_status); }; }; then
++   ac_header_compiler=yes
++ else
++   echo "$as_me: failed program was:" >&5
++ cat conftest.$ac_ext >&5
++ ac_header_compiler=no
++ fi
++ rm -f conftest.$ac_objext conftest.$ac_ext
++ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
++ echo "${ECHO_T}$ac_header_compiler" >&6
++ 
++ # Is the header present?
++ echo "$as_me:$LINENO: checking $ac_header presence" >&5
++ echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
++ cat >conftest.$ac_ext <<_ACEOF
++ #line $LINENO "configure"
++ #include "confdefs.h"
++ #include <$ac_header>
++ _ACEOF
++ if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
++   (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
++   ac_status=$?
++   egrep -v '^ *\+' conftest.er1 >conftest.err
++   rm -f conftest.er1
++   cat conftest.err >&5
++   echo "$as_me:$LINENO: \$? = $ac_status" >&5
++   (exit $ac_status); } >/dev/null; then
++   if test -s conftest.err; then
++     ac_cpp_err=$ac_c_preproc_warn_flag
++   else
++     ac_cpp_err=
++   fi
++ else
++   ac_cpp_err=yes
++ fi
++ if test -z "$ac_cpp_err"; then
++   ac_header_preproc=yes
++ else
++   echo "$as_me: failed program was:" >&5
++   cat conftest.$ac_ext >&5
++   ac_header_preproc=no
++ fi
++ rm -f conftest.err conftest.$ac_ext
++ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
++ echo "${ECHO_T}$ac_header_preproc" >&6
++ 
++ # So?  What about this header?
++ case $ac_header_compiler:$ac_header_preproc in
++   yes:no )
++     { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
++ echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
++     { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
++ echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};;
++   no:yes )
++     { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
++ echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
++     { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
++ echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
++     { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
++ echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};;
++ esac
++ echo "$as_me:$LINENO: checking for $ac_header" >&5
++ echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
++ if eval "test \"\${$as_ac_Header+set}\" = set"; then
++   echo $ECHO_N "(cached) $ECHO_C" >&6
++ else
++   eval "$as_ac_Header=$ac_header_preproc"
++ fi
++ echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
++ echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
++ 
++ fi
++ if test `eval echo '${'$as_ac_Header'}'` = yes; then
++   cat >>confdefs.h <<_ACEOF
++ #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
++ _ACEOF
++ 
++ fi
++ 
++ done
++ 
++ 
++ for ac_func in setlocale
++ do
++ as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
++ echo "$as_me:$LINENO: checking for $ac_func" >&5
++ echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
++ if eval "test \"\${$as_ac_var+set}\" = set"; then
++   echo $ECHO_N "(cached) $ECHO_C" >&6
++ else
++   cat >conftest.$ac_ext <<_ACEOF
++ #line $LINENO "configure"
++ #include "confdefs.h"
++ /* From autoconf 2.57 */
++ /* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
++    For example, HP-UX 11i <limits.h> declares gettimeofday.  */
++ #define $ac_func innocuous_$ac_func
++ 
++ /* System header to define __stub macros and hopefully few prototypes,
++     which can conflict with char $ac_func (); below.
++     Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
++     <limits.h> exists even on freestanding compilers.  */
++ 
++ #ifdef __STDC__
++ # include <limits.h>
++ #else
++ # include <assert.h>
++ #endif
++ 
++ #undef $ac_func
++ 
++ /* Override any gcc2 internal prototype to avoid an error.  */
++ #ifdef __cplusplus
++ extern "C"
++ {
++ #endif
++ /* We use char because int might match the return type of a gcc2
++    builtin and then its argument prototype would still apply.  */
++ char $ac_func ();
++ /* The GNU C library defines this for functions which it implements
++     to always fail with ENOSYS.  Some functions are actually named
++     something starting with __ and the normal name is an alias.  */
++ #if defined (__stub_$ac_func) || defined (__stub___$ac_func)
++ choke me
++ #else
++ char (*f) () = $ac_func;
++ #endif
++ #ifdef __cplusplus
++ }
++ #endif
++ 
++ #ifdef F77_DUMMY_MAIN
++ #  ifdef __cplusplus
++      extern "C"
++ #  endif
++    int F77_DUMMY_MAIN() { return 1; }
++ #endif
++ int
++ main ()
++ {
++ return f != $ac_func;
++   ;
++   return 0;
++ }
++ _ACEOF
++ rm -f conftest.$ac_objext conftest$ac_exeext
++ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
++   (eval $ac_link) 2>&5
++   ac_status=$?
++   echo "$as_me:$LINENO: \$? = $ac_status" >&5
++   (exit $ac_status); } &&
++          { ac_try='test -s conftest$ac_exeext'
++   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++   (eval $ac_try) 2>&5
++   ac_status=$?
++   echo "$as_me:$LINENO: \$? = $ac_status" >&5
++   (exit $ac_status); }; }; then
++   eval "$as_ac_var=yes"
++ else
++   echo "$as_me: failed program was:" >&5
++ cat conftest.$ac_ext >&5
++ eval "$as_ac_var=no"
++ fi
++ rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
++ fi
++ echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
++ echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
++ if test `eval echo '${'$as_ac_var'}'` = yes; then
++   cat >>confdefs.h <<_ACEOF
++ #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
++ _ACEOF
++ 
++ fi
++ done
++ 
++ 
++ #
+  # Substitutions
+  #
+  
+***************
+*** 14061,14066 ****
+--- 14371,14377 ----
+  s,@PRINTSTYLE@,$PRINTSTYLE,;t t
+  s,@XMLDCL@,$XMLDCL,;t t
+  s,@DOCBOOK2MANSPEC@,$DOCBOOK2MANSPEC,;t t
++ s,@IDNLIBS@,$IDNLIBS,;t t
+  s,@BIND9_TOP_BUILDDIR@,$BIND9_TOP_BUILDDIR,;t t
+  s,@BIND9_ISC_BUILDINCLUDE@,$BIND9_ISC_BUILDINCLUDE,;t t
+  s,@BIND9_ISCCC_BUILDINCLUDE@,$BIND9_ISCCC_BUILDINCLUDE,;t t
+Index: configure.in
+diff -c mdn/othersrc/bind9/configure.in:1.1.1.10 mdn/othersrc/bind9/configure.in:1.16
+*** configure.in       Wed Mar  5 17:14:56 2003
+--- configure.in       Wed Mar  5 17:37:08 2003
+***************
+*** 1681,1686 ****
+--- 1681,1762 ----
+  NOM_PATH_FILE(DOCBOOK2MANSPEC, docbook2X/docbook2man-spec.pl, $sgmltrees)
+  
+  #
++ # IDN support
++ #
++ AC_ARG_WITH(idn,
++      [  --with-idn[=MPREFIX]   enable IDN support using idnkit [default PREFIX]],
++      use_idn="$withval", use_idn="no")
++ case "$use_idn" in
++ yes)
++      if test X$prefix = XNONE ; then
++              idn_path=/usr/local
++      else
++              idn_path=$prefix
++      fi
++      ;;
++ no)
++      ;;
++ *)
++      idn_path="$use_idn"
++      ;;
++ esac
++ 
++ iconvinc=
++ iconvlib=
++ AC_ARG_WITH(libiconv,
++      [  --with-libiconv[=IPREFIX]   GNU libiconv are in IPREFIX [default PREFIX]],
++      use_libiconv="$withval", use_libiconv="no")
++ case "$use_libiconv" in
++ yes)
++      if test X$prefix = XNONE ; then
++              iconvlib="-L/usr/local/lib -R/usr/local/lib -liconv"
++      else
++              iconvlib="-L$prefix/lib -R$prefix/lib -liconv"
++      fi
++      ;;
++ no)
++      iconvlib=
++      ;;
++ *)
++      iconvlib="-L$use_libiconv/lib -R$use_libiconv/lib -liconv"
++      ;;
++ esac
++ 
++ AC_ARG_WITH(iconv,
++      [  --with-iconv[=LIBSPEC]   specify iconv library [default -liconv]],
++      iconvlib="$withval")
++ case "$iconvlib" in
++ no)
++      iconvlib=
++      ;;
++ yes)
++      iconvlib=-liconv
++      ;;
++ esac
++ 
++ AC_ARG_WITH(idnlib,
++      [  --with-idnlib=ARG    specify libidnkit],
++      idnlib="$withval", idnlib="no")
++ if test "$idnlib" = yes; then
++      AC_MSG_ERROR([You must specify ARG for --with-idnlib.])
++ fi
++ 
++ IDNLIBS=
++ if test "$use_idn" != no; then
++      AC_DEFINE(WITH_IDN, 1, [define if idnkit support is to be included.])
++      STD_CINCLUDES="$STD_CINCLUDES -I$idn_path/include"
++      if test "$idnlib" != no; then
++              IDNLIBS="$idnlib $iconvlib"
++      else
++              IDNLIBS="-L$idn_path/lib -lidnkit $iconvlib"
++      fi
++ fi
++ AC_SUBST(IDNLIBS)
++ 
++ AC_CHECK_HEADERS(locale.h)
++ AC_CHECK_FUNCS(setlocale)
++ 
++ #
+  # Substitutions
+  #
+  AC_SUBST(BIND9_TOP_BUILDDIR)
+Index: bin/dig/Makefile.in
+diff -c mdn/othersrc/bind9/bin/dig/Makefile.in:1.1.1.6 mdn/othersrc/bind9/bin/dig/Makefile.in:1.3
+*** bin/dig/Makefile.in        Tue Nov 27 16:55:50 2001
+--- bin/dig/Makefile.in        Tue Mar 19 16:45:35 2002
+***************
+*** 36,42 ****
+  
+  DEPLIBS =    ${DNSDEPLIBS} ${ISCDEPLIBS}
+  
+! LIBS =               ${DNSLIBS} ${ISCLIBS} @LIBS@
+  
+  SUBDIRS =
+  
+--- 36,42 ----
+  
+  DEPLIBS =    ${DNSDEPLIBS} ${ISCDEPLIBS}
+  
+! LIBS =               ${DNSLIBS} ${ISCLIBS} @IDNLIBS@ @LIBS@
+  
+  SUBDIRS =
+  
+Index: bin/dig/dig.1
+diff -c mdn/othersrc/bind9/bin/dig/dig.1:1.1.1.3 mdn/othersrc/bind9/bin/dig/dig.1:1.5
+*** bin/dig/dig.1      Wed Mar  5 17:14:57 2003
+--- bin/dig/dig.1      Wed Mar  5 17:42:53 2003
+***************
+*** 349,354 ****
+--- 349,365 ----
+  \fI+noqr\fR which means that \fBdig\fR
+  will not print the initial query when it looks up the NS records for
+  isc.org.
++ .SH "IDN SUPPORT"
++ .PP
++ If \fBdig\fR has been built with IDN (internationalized
++ domain name) support, it can accept and display non-ASCII domain names.
++ \fBdig\fR appropriately converts character encoding of
++ domain name before sending a request to DNS server or displaying a
++ reply from the server.
++ If you'd like to turn off the IDN support for some reason, defines
++ the \fBIDN_DISABLE\fR environment variable.
++ The IDN support is disabled if the the variable is set when 
++ \fBdig\fR runs.
+  .SH "FILES"
+  .PP
+  \fI/etc/resolv.conf\fR
+Index: bin/dig/dig.docbook
+diff -c mdn/othersrc/bind9/bin/dig/dig.docbook:1.1.1.3 mdn/othersrc/bind9/bin/dig/dig.docbook:1.5
+*** bin/dig/dig.docbook        Wed Mar  5 17:14:57 2003
+--- bin/dig/dig.docbook        Wed Mar  5 17:42:53 2003
+***************
+*** 523,528 ****
+--- 523,543 ----
+  </refsect1>
+  
+  <refsect1>
++ <title>IDN SUPPORT</title>
++ <para>
++ If <command>dig</command> has been built with IDN (internationalized
++ domain name) support, it can accept and display non-ASCII domain names.
++ <command>dig</command> appropriately converts character encoding of
++ domain name before sending a request to DNS server or displaying a
++ reply from the server.
++ If you'd like to turn off the IDN support for some reason, defines
++ the <envar>IDN_DISABLE</envar> environment variable.
++ The IDN support is disabled if the the variable is set when 
++ <command>dig</command> runs.
++ </para>
++ </refsect1>
++ 
++ <refsect1>
+  <title>FILES</title>
+  <para>
+  <filename>/etc/resolv.conf</filename>
+Index: bin/dig/dighost.c
+diff -c mdn/othersrc/bind9/bin/dig/dighost.c:1.1.1.13 mdn/othersrc/bind9/bin/dig/dighost.c:1.33
+*** bin/dig/dighost.c  Wed Mar  5 17:14:57 2003
+--- bin/dig/dighost.c  Wed Mar  5 17:42:53 2003
+***************
+*** 32,37 ****
+--- 32,48 ----
+  #include <string.h>
+  #include <limits.h>
+  
++ #ifdef HAVE_LOCALE_H
++ #include <locale.h>
++ #endif
++ 
++ #ifdef WITH_IDN
++ #include <idn/result.h>
++ #include <idn/log.h>
++ #include <idn/resconf.h>
++ #include <idn/api.h>
++ #endif
++ 
+  #include <dns/byaddr.h>
+  #include <dns/fixedname.h>
+  #include <dns/message.h>
+***************
+*** 130,135 ****
+--- 141,158 ----
+  isc_mutex_t lookup_lock;
+  dig_lookup_t *current_lookup = NULL;
+  
++ #ifdef WITH_IDN
++ static void        initialize_idn(void);
++ static isc_result_t   output_filter(isc_buffer_t *buffer,
++                                  unsigned int used_org,
++                                  isc_boolean_t absolute);
++ static idn_result_t   append_textname(char *name, const char *origin,
++                                    size_t namesize);
++ static void        idn_check_result(idn_result_t r, const char *msg);
++ 
++ #define MAXDLEN               256
++ #endif
++ 
+  /*
+   * Apply and clear locks at the event level in global task.
+   * Can I get rid of these using shutdown events?  XXX
+***************
+*** 648,653 ****
+--- 671,680 ----
+               ISC_LIST_APPEND(server_list, srv, link);
+       }
+  
++ #ifdef WITH_IDN
++      initialize_idn();
++ #endif
++ 
+       if (keyfile[0] != 0)
+               setup_file_key();
+       else if (keysecret[0] != 0)
+***************
+*** 1168,1173 ****
+--- 1195,1208 ----
+       isc_buffer_t b;
+       dns_compress_t cctx;
+       char store[MXNAME];
++ #ifdef WITH_IDN
++      idn_result_t mr;
++      char utf8_textname[MXNAME], utf8_origin[MXNAME], idn_textname[MXNAME];
++ #endif
++ 
++ #ifdef WITH_IDN
++      dns_name_settotextfilter(output_filter);
++ #endif
+  
+       REQUIRE(lookup != NULL);
+       INSIST(!free_now);
+***************
+*** 1196,1201 ****
+--- 1231,1247 ----
+       isc_buffer_init(&lookup->onamebuf, lookup->onamespace,
+                       sizeof(lookup->onamespace));
+  
++ #ifdef WITH_IDN
++      /*
++       * We cannot convert `textname' and `origin' separately.
++       * `textname' doesn't contain TLD, but local mapping needs
++       * TLD.
++       */
++      mr = idn_encodename(IDN_LOCALCONV | IDN_DELIMMAP, lookup->textname,
++                          utf8_textname, sizeof(utf8_textname));
++      idn_check_result(mr, "convert textname to UTF-8");
++ #endif
++ 
+       /*
+        * If the name has too many dots, force the origin to be NULL
+        * (which produces an absolute lookup).  Otherwise, take the origin
+***************
+*** 1204,1215 ****
+--- 1250,1290 ----
+        * is TRUE or we got a domain line in the resolv.conf file.
+        */
+       /* XXX New search here? */
++ #ifdef WITH_IDN
++      if ((count_dots(utf8_textname) >= ndots) || !usesearch)
++              lookup->origin = NULL; /* Force abs lookup */
++      else if (lookup->origin == NULL && lookup->new_search && usesearch) {
++              lookup->origin = ISC_LIST_HEAD(search_list);
++      }
++ #else
+       if ((count_dots(lookup->textname) >= ndots) || !usesearch)
+               lookup->origin = NULL; /* Force abs lookup */
+       else if (lookup->origin == NULL && lookup->new_search && usesearch) {
+               lookup->origin = ISC_LIST_HEAD(search_list);
+       }
++ #endif
++ 
++ #ifdef WITH_IDN
+       if (lookup->origin != NULL) {
++              mr = idn_encodename(IDN_LOCALCONV | IDN_DELIMMAP,
++                                  lookup->origin->origin, utf8_origin,
++                                  sizeof(utf8_origin));
++              idn_check_result(mr, "convert origin to UTF-8");
++              mr = append_textname(utf8_textname, utf8_origin,
++                                   sizeof(utf8_textname));
++              idn_check_result(mr, "append origin to textname");
++      }
++      mr = idn_encodename(IDN_LOCALMAP | IDN_NAMEPREP | IDN_ASCCHECK |
++                          IDN_IDNCONV | IDN_LENCHECK, utf8_textname,
++                          idn_textname, sizeof(idn_textname));
++      idn_check_result(mr, "convert UTF-8 textname to IDN encoding");
++ #endif
++ 
++ #ifdef WITH_IDN
++      if (0) {
++ #else
++      if (lookup->origin != NULL) {
++ #endif
+               debug("trying origin %s", lookup->origin->origin);
+               result = dns_message_gettempname(lookup->sendmsg,
+                                                &lookup->oname);
+***************
+*** 1254,1259 ****
+--- 1329,1343 ----
+               if (lookup->trace && lookup->trace_root)
+                       dns_name_clone(dns_rootname, lookup->name);
+               else {
++ #ifdef WITH_IDN
++                      len = strlen(idn_textname);
++                      isc_buffer_init(&b, idn_textname, len);
++                      isc_buffer_add(&b, len);
++                      result = dns_name_fromtext(lookup->name, &b,
++                                                 dns_rootname,
++                                                 ISC_FALSE,
++                                                 &lookup->namebuf);
++ #else
+                       len = strlen(lookup->textname);
+                       isc_buffer_init(&b, lookup->textname, len);
+                       isc_buffer_add(&b, len);
+***************
+*** 1261,1266 ****
+--- 1345,1351 ----
+                                                  dns_rootname,
+                                                  ISC_FALSE,
+                                                  &lookup->namebuf);
++ #endif
+               }
+               if (result != ISC_R_SUCCESS) {
+                       dns_message_puttempname(lookup->sendmsg,
+***************
+*** 2663,2665 ****
+--- 2748,2848 ----
+       if (mctx != NULL)
+               isc_mem_destroy(&mctx);
+  }
++ 
++ #ifdef WITH_IDN
++ static void
++ initialize_idn(void) {
++      idn_result_t r;
++ 
++ #ifdef HAVE_SETLOCALE
++      /* Set locale */
++      (void)setlocale(LC_ALL, "");
++ #endif
++      /* Create configuration context. */
++      r = idn_nameinit(1);
++      if (r != idn_success)
++              fatal("idn api initialization failed: %s",
++                    idn_result_tostring(r));
++ 
++      /* Set domain name -> text post-conversion filter. */
++      dns_name_settotextfilter(output_filter);
++ }
++ 
++ static isc_result_t
++ output_filter(isc_buffer_t *buffer, unsigned int used_org,
++            isc_boolean_t absolute)
++ {
++      char tmp1[MAXDLEN], tmp2[MAXDLEN];
++      size_t fromlen, tolen;
++      isc_boolean_t end_with_dot;
++ 
++      /*
++       * Copy contents of 'buffer' to 'tmp1', supply trailing dot
++       * if 'absolute' is true, and terminate with NUL.
++       */
++      fromlen = isc_buffer_usedlength(buffer) - used_org;
++      if (fromlen >= MAXDLEN)
++              return (ISC_R_SUCCESS);
++      memcpy(tmp1, (char *)isc_buffer_base(buffer) + used_org, fromlen);
++      end_with_dot = (tmp1[fromlen - 1] == '.') ? ISC_TRUE : ISC_FALSE;
++      if (absolute && !end_with_dot) {
++              fromlen++;
++              if (fromlen >= MAXDLEN)
++                      return (ISC_R_SUCCESS);
++              tmp1[fromlen - 1] = '.';
++      }
++      tmp1[fromlen] = '\0';
++ 
++      /*
++       * Convert contents of 'tmp1' to local encoding.
++       */
++      if (idn_decodename(IDN_DECODE_APP, tmp1, tmp2, MAXDLEN) != idn_success)
++              return (ISC_R_SUCCESS);
++      strcpy(tmp1, tmp2);
++ 
++      /*
++       * Copy the converted contents in 'tmp1' back to 'buffer'.
++       * If we have appended trailing dot, remove it.
++       */
++      tolen = strlen(tmp1);
++      if (absolute && !end_with_dot && tmp1[tolen - 1] == '.')
++              tolen--;
++ 
++      if (isc_buffer_length(buffer) < used_org + tolen)
++              return (ISC_R_NOSPACE);
++ 
++      isc_buffer_subtract(buffer, isc_buffer_usedlength(buffer) - used_org);
++      memcpy(isc_buffer_used(buffer), tmp1, tolen);
++      isc_buffer_add(buffer, tolen);
++ 
++      return (ISC_R_SUCCESS);
++ }
++ 
++ static idn_result_t
++ append_textname(char *name, const char *origin, size_t namesize) {
++      size_t namelen = strlen(name);
++      size_t originlen = strlen(origin);
++ 
++      /* Already absolute? */
++      if (namelen > 0 && name[namelen - 1] == '.')
++              return idn_success;
++ 
++      /* Append dot and origin */
++ 
++      if (namelen + 1 + originlen >= namesize)
++              return idn_buffer_overflow;
++ 
++      name[namelen++] = '.';
++      (void)strcpy(name + namelen, origin);
++      return idn_success;
++ }
++ 
++ static void
++ idn_check_result(idn_result_t r, const char *msg) {
++      if (r != idn_success) {
++              exitcode = 1;
++              fatal("%s: %s", msg, idn_result_tostring(r));
++      }
++ }
++ 
++ #endif /* WITH_IDN */
+Index: bin/dig/host.1
+diff -c mdn/othersrc/bind9/bin/dig/host.1:1.1.1.2 mdn/othersrc/bind9/bin/dig/host.1:1.4
+*** bin/dig/host.1     Wed Mar  5 17:14:57 2003
+--- bin/dig/host.1     Wed Mar  5 17:42:53 2003
+***************
+*** 120,125 ****
+--- 120,136 ----
+  effectively wait forever for a reply. The time to wait for a response
+  will be set to the number of seconds given by the hardware's maximum
+  value for an integer quantity.
++ .SH "IDN SUPPORT"
++ .PP
++ If \fBhost\fR has been built with IDN (internationalized
++ domain name) support, it can accept and display non-ASCII domain names.
++ \fBhost\fR appropriately converts character encoding of
++ domain name before sending a request to DNS server or displaying a
++ reply from the server.
++ If you'd like to turn off the IDN support for some reason, defines
++ the \fBIDN_DISABLE\fR environment variable.
++ The IDN support is disabled if the the variable is set when
++ \fBhost\fR runs.
+  .SH "FILES"
+  .PP
+  \fI/etc/resolv.conf\fR
+Index: bin/dig/host.docbook
+diff -c mdn/othersrc/bind9/bin/dig/host.docbook:1.1.1.2 mdn/othersrc/bind9/bin/dig/host.docbook:1.4
+*** bin/dig/host.docbook       Wed Mar  5 17:14:57 2003
+--- bin/dig/host.docbook       Wed Mar  5 17:42:53 2003
+***************
+*** 181,186 ****
+--- 181,201 ----
+  </refsect1>
+  
+  <refsect1>
++ <title>IDN SUPPORT</title>
++ <para>
++ If <command>host</command> has been built with IDN (internationalized
++ domain name) support, it can accept and display non-ASCII domain names.
++ <command>host</command> appropriately converts character encoding of
++ domain name before sending a request to DNS server or displaying a
++ reply from the server.
++ If you'd like to turn off the IDN support for some reason, defines
++ the <envar>IDN_DISABLE</envar> environment variable.
++ The IDN support is disabled if the the variable is set when
++ <command>host</command> runs.
++ </para>
++ </refsect1>
++ 
++ <refsect1>
+  <title>FILES</title>
+  <para>
+  <filename>/etc/resolv.conf</filename>
+Index: lib/dns/name.c
+diff -c mdn/othersrc/bind9/lib/dns/name.c:1.1.1.11 mdn/othersrc/bind9/lib/dns/name.c:1.15
+*** lib/dns/name.c     Wed Mar  5 17:16:22 2003
+--- lib/dns/name.c     Wed Mar  5 17:49:58 2003
+***************
+*** 194,199 ****
+--- 194,206 ----
+  /* XXXDCL make const? */
+  dns_name_t *dns_wildcardname = &wild;
+  
++ #ifdef WITH_IDN
++ /*
++  * dns_name_t to text post-conversion procedure.
++  */
++ static dns_name_totextfilter_t totext_filter_proc = NULL;
++ #endif
++ 
+  static void
+  set_offsets(const dns_name_t *name, unsigned char *offsets,
+           dns_name_t *set_name);
+***************
+*** 1684,1689 ****
+--- 1691,1699 ----
+       unsigned int labels;
+       isc_boolean_t saw_root = ISC_FALSE;
+       char num[4];
++ #ifdef WITH_IDN
++      unsigned int oused = target->used;
++ #endif
+  
+       /*
+        * This function assumes the name is in proper uncompressed
+***************
+*** 1861,1866 ****
+--- 1871,1880 ----
+  
+       isc_buffer_add(target, tlen - trem);
+  
++ #ifdef WITH_IDN
++      if (totext_filter_proc != NULL)
++              return ((*totext_filter_proc)(target, oused, saw_root));
++ #endif
+       return (ISC_R_SUCCESS);
+  }
+  
+***************
+*** 3325,3327 ****
+--- 3339,3347 ----
+       return (ISC_R_SUCCESS);
+  }
+  
++ #ifdef WITH_IDN
++ void
++ dns_name_settotextfilter(dns_name_totextfilter_t proc) {
++      totext_filter_proc = proc;
++ }
++ #endif
+Index: lib/dns/include/dns/name.h
+diff -c mdn/othersrc/bind9/lib/dns/include/dns/name.h:1.1.1.7 mdn/othersrc/bind9/lib/dns/include/dns/name.h:1.10
+*** lib/dns/include/dns/name.h Wed May 22 17:15:29 2002
+--- lib/dns/include/dns/name.h Mon May 27 12:10:15 2002
+***************
+*** 219,224 ****
+--- 219,235 ----
+   */
+  #define DNS_NAME_MAXWIRE 255
+  
++ #ifdef WITH_IDN
++ /*
++  * Text output filter procedure.
++  * 'target' is the buffer to be converted.  The region to be converted
++  * is from 'buffer'->base + 'used_org' to the end of the used region.
++  */
++ typedef isc_result_t (*dns_name_totextfilter_t)(isc_buffer_t *target,
++                                              unsigned int used_org,
++                                              isc_boolean_t absolute);
++ #endif
++ 
+  /***
+   *** Initialization
+   ***/
+***************
+*** 1244,1249 ****
+--- 1255,1268 ----
+   *   'size' > 0.
+   *
+   */
++ 
++ #ifdef WITH_IDN
++ void
++ dns_name_settotextfilter(dns_name_totextfilter_t proc);
++ /*
++  * Call 'proc' at the end of dns_name_totext.
++  */
++ #endif /* WITH_IDN */
+  
+  #define DNS_NAME_FORMATSIZE (DNS_NAME_MAXTEXT + 1)
+  /*
diff --git a/contrib/idn/idnkit-1.0-src/tools/Makefile.in b/contrib/idn/idnkit-1.0-src/tools/Makefile.in
new file mode 100644 (file)
index 0000000..4ccc7e9
--- /dev/null
@@ -0,0 +1,65 @@
+# $Id: Makefile.in,v 1.1 2003/06/04 00:27:05 marka Exp $
+# 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.
+
+srcdir = @srcdir@
+VPATH = @srcdir@
+
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+
+SUBDIRS = idnconv runidn
+
+SHELL = @SHELL@
+
+all: all-subdirs
+install: install-subdirs
+clean: clean-subdirs
+distclean: distclean-localdir distclean-subdirs
+test check: test-subdirs
+
+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
+
+distclean-localdir:
+       rm -f Makefile
diff --git a/contrib/idn/idnkit-1.0-src/tools/idnconv/Makefile.in b/contrib/idn/idnkit-1.0-src/tools/idnconv/Makefile.in
new file mode 100644 (file)
index 0000000..72af913
--- /dev/null
@@ -0,0 +1,116 @@
+# $Id: Makefile.in,v 1.1 2003/06/04 00:27:05 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.
+
+top_builddir = ../..
+
+srcdir = @srcdir@
+VPATH = @srcdir@
+
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+
+bindir = @bindir@
+mandir = @mandir@
+man1dir = $(mandir)/man1
+
+CC = @CC@
+RANLIB = @RANLIB@
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_DATA = @INSTALL_DATA@
+MKINSTALLDIRS = @top_srcdir@/mkinstalldirs
+SHELL   = @SHELL@
+LIBTOOL = @LIBTOOL@
+
+ICONVINC = @ICONVINC@
+ICONVLIB = @ICONVLIB@
+IDNLIB = ../../lib/libidnkit.la
+
+INCS = -I$(srcdir) -I$(srcdir)/../../include -I../../include $(ICONVINC)
+DEFS =
+
+CFLAGS = $(INCS) $(DEFS) @CPPFLAGS@ @CFLAGS@
+LDFLAGS = @LDFLAGS@
+
+SRCS = idnconv.c util.c selectiveencode.c
+OBJS = idnconv.o util.o selectiveencode.o
+
+@LITEONLY_TRUE@all:
+@LITEONLY_FALSE@all: idnconv idnslookup idnconv.1
+
+idnconv: $(OBJS) $(IDNLIB)
+       $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ \
+               $(OBJS) $(IDNLIB) $(ICONVLIB)
+
+idnslookup: $(srcdir)/idnslookup.in
+       sed -e 's%[@]bindir[@]%$(bindir)%' $(srcdir)/idnslookup.in > idnslookup
+       chmod 0755 idnslookup
+
+@LITEONLY_TRUE@install:
+@LITEONLY_FALSE@@COMPAT_TRUE@install: all install-nolite install-compat
+@LITEONLY_FALSE@@COMPAT_FALSE@install: all install-nolite
+
+install-nolite:
+       $(MKINSTALLDIRS) $(DESTDIR)$(bindir)
+       $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) idnconv \
+           $(DESTDIR)$(bindir)/idnconv
+       $(MKINSTALLDIRS) $(DESTDIR)$(man1dir)
+       $(INSTALL_DATA) $(srcdir)/idnconv.1 $(DESTDIR)$(man1dir)/idnconv.1
+
+install-compat:
+       src=$(DESTDIR)$(bindir)/idnconv; \
+       dst=$(DESTDIR)$(bindir)/mdnconv; \
+       rm -f $$dst; \
+       ln $$src $$dst || cp $$src $$dst
+       src=$(DESTDIR)$(man1dir)/idnconv.1; \
+       dst=$(DESTDIR)$(man1dir)/mdnconv.1; \
+       rm -f $$dst; \
+       ln $$src $$dst || cp $$src $$dst
+
+clean:
+       rm -f *.o idnconv idnslookup *.core core *~
+       rm -fr .libs/
+
+distclean: clean
+       rm -f Makefile
+
+test check:
diff --git a/contrib/idn/idnkit-1.0-src/tools/idnconv/idnconv.1 b/contrib/idn/idnkit-1.0-src/tools/idnconv/idnconv.1
new file mode 100644 (file)
index 0000000..3ffe6b8
--- /dev/null
@@ -0,0 +1,373 @@
+.\" $Id: idnconv.1,v 1.1 2003/06/04 00:27:10 marka Exp $
+.\"
+.\" 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.
+.\"
+.TH IDNCONV 1 "Mar 3, 2001"
+.\"
+.SH NAME
+idnconv \- codeset converter for named.conf and zone master files
+.\"
+.SH SYNOPSIS
+\fBidnconv\fP [\fIoptions..\fP] [\fIfile\fP...]
+.\"
+.SH DESCRIPTION
+\fBidnconv\fR is a codeset converter for named configuration files
+and zone master files.
+\fBidnconv\fR performs codeset conversion specified either
+by the command-line arguments or by the configuration file,
+and writes the converted text to stdout.
+.PP
+If file name is specified, \fBidnconv\fR converts the contents of
+the file.
+Otherwise, \fBidnconv\fR converts \fIstdin\fR.
+.PP
+Since \fBidnconv\fR is specifically designed for converting
+internatinalized domain names, it may not be suitable as a general
+codeset converter.
+.\"
+.SH "OPERATION MODES"
+\fBidnconv\fR has two operation modes.
+.PP
+One is a mode to convert local-encoded domain names to IDN-encoded
+one.  Usually this mode is used for preparing domain names to be
+listed in named configuration files or zone master files.
+In this mode, the following processes are performed in addition to
+the codeset (encoding) conversion.
+.RS 2
+.IP \- 2
+local mapping
+.IP \- 2
+standard domain name preperation (NAMEPREP)
+.RE
+.PP
+The other mode is a reverse conversion, from IDN-encoded domain name to
+local-encoded domain names.
+In this mode, local mapping and NAMEPREP are not performed since
+IDN-encoded names should already be normalized.
+Instead, a check is done in order to make sure the IDN-encoded domain name
+is properly NAMEPREP'ed.  If it is not, the name will be output in
+IDN encoding, not in the local encoding.
+.\"
+.SH OPTIONS
+Normally \fBidnconv\fR reads system's default configuration file
+(idn.conf) and performs conversion or name preparation according to
+the parameters specified in the file.
+You can override the setting in the configuration file by various
+command line options below.
+.TP 4
+\fB\-in\fP \fIin-code\fP, \fB\-i\fP \fIin-code\fP
+Specify the codeset name of the input text.
+Any of the following codeset names can be specified.
+.RS 4
+.IP "\(bu" 2
+Any codeset names which \fIiconv_open()\fP library function accepts
+.IP "\(bu" 2
+\f(CWPunycode\fR
+.IP "\(bu" 2
+\f(CWUTF-8\fR
+.IP "\(bu" 2
+Any alias names for the above, defined by the codeset alias file.
+.RE
+.IP "" 4
+If this option is not specified, the default codeset is determined
+from the locale in normal conversion mode.
+In reverse conversion mode, the default codeset is the IDN encoding
+specified by the configuration file (``idn-encoding'' entry).
+.TP 4
+\fB\-out\fP \fIout-code\fP, \fB\-o\fP \fIout-code\fP
+Specify the codeset name of the output text. \fIout-code\fP can be any
+codeset name that can be specified for \fB\-in\fR option.
+.IP "" 4
+If this option is not specified, the default is the IDN encoding
+specified by the configuration file (``idn-encoding'' entry) in
+normal conversion mode.
+In reverse conversion mode, the default codeset is determined from
+the locale.
+.TP 4
+\fB\-conf\fP \fIpath\fP, \fB\-c\fP \fIpath\fP
+Specify the pathname of idnkit configuration file (``idn.conf'').
+If not specified, system's default file is used, unless \-noconf
+option is specified.
+.TP 4
+\fB\-noconf\fP, \fB\-C\fP
+Specify that no configuration file is to be used.
+.TP 4
+\fB\-reverse\fP, \fB\-r\fP
+Specify reverse conversion mode.
+.br
+If this option is not specified, the normal conversion mode is used.
+.TP 4
+\fB\-nameprep\fR \fIversion\fR, \fB\-n\fR \fIversion\fR
+Specify the version of NAMEPREP.
+The following is a list of currently available versions.
+.RS 4
+.IP \f(CWRFC3491\fR 4
+Perform NAMEPREP according to the RFC3491
+``rfc-3491.txt''.
+.RE
+.TP 4
+\fB\-nonameprep\fR, \fB\-N\fR
+Specify to skip NAMEPREP process (or NAMEPREP verification process
+in the reverse conversion mode).
+This option implies -nounassigncheck and -nobidicheck.
+.TP 4
+\fB\-localmap\fR \fImap\fR
+Specify the name of local mapping rule.
+Currently, following maps are available.
+.RS 4
+.IP \f(CWRFC3491\fR 4
+Use the list of mappings specified by RFC3491.
+.IP \f(CWfilemap:\fR\fIpath\fR 4
+Use list of mappings specified by mapfile \fIpath\fR.
+See idn.conf(5) for the format of a mapfile.
+.RE
+.IP "" 4
+This option can be specified more than once.
+In that case, each mapping will be performed in the order of the
+specification.
+.TP 4
+\fB\-nounassigncheck\fR, \fB\-U\fR
+Skip unassigned codepoint check.
+.TP 4
+\fB\-nobidicheck\fR, \fB\-B\fR
+Skip bidi character check.
+.TP 4
+\fB\-nolengthcheck\fR
+Do not check label length of normal conversion result.
+This option is only meaningful in the normal conversion mode.
+.TP 4
+\fB\-noasciicheck\fR, \fB\-A\fR
+Do not check ASCII range characters.
+This option is only meaningful in the normal conversion mode.
+.TP 4
+\fB\-noroundtripcheck\fR
+Do not perform round trip check.
+This option is only meaningful in the reverse conversion mode.
+.TP 4
+\fB\-delimiter\fR \fIcodepoint\fP
+Specify the character to be mapped to domain name delimiter (period).
+This option can be specified more than once in order to specify multiple
+characters.
+.br
+This option is only meaningful in the normal conversion mode.
+.TP 4
+\fB\-whole\fP, \fB\-w\fP
+Perform local mapping, nameprep and conversion to output codeset for the entire
+input text.  If this option is not specified, only non-ASCII characters
+and their surrounding texts will be processed.
+See ``NORAML CONVERSION MECHANISM'' and ``REVERSE CONVERSION MECHANISM''
+for details.
+.TP 4
+\fB\-alias\fP \fIpath\fP, \fB\-a\fP \fIpath\fP
+Specify a codeset alias file.  It is a simple text file, where
+each line has a pair of alias name and real name separated by one
+or more white spaces like below:
+.nf
+.ft CW
+
+    \fIalias-codeset-name\fP    \fIreal-codeset-name\fP
+
+.ft R
+.fi
+Lines starting with ``#'' are treated as comments.
+.TP 4
+\fB\-flush\fP
+Force line-buffering mode.
+.TP 4
+\fB\-version\fP, \fB\-v\fP
+Print version information and quit.
+.\"
+.SH LOCAL CODESET
+idnconv guesses local codeset from locale and environment variables.
+See the ``LOCAL CODESET'' section in idn.conf(5) for more details.
+.\"
+.SH NORMAL CONVERSION MECHANISM
+\fBidnconv\fR performs conversion line by line.
+Here describes how \fBidnconv\fR does its job for each line.
+.\"
+.IP "1. read a line from input text" 4
+.IP "2. convert the line to UTF-8" 4
+\fBidnconv\fR converts the line from local encoding to UTF-8.
+.IP "3. find internationalized domain names" 4
+If the \-whole\ (or \-w) option is specified, the entire line is
+assumed as an internationalized domain name.
+Otherwise, \fBidnconv\fR recognizes any character sequences having
+the following properties in the line as internationalized domain names.
+.RS 4
+.IP "\(bu" 2
+containing at least one non-ASCII character, and
+.IP "\(bu" 2
+consisting of legal domain name characters (alphabets, digits, hypens),
+non-ASCII characters and period.
+.RE
+.IP "4. convert internationalized domain names to ACE" 4
+For each internationalized domain name found in the line,
+\fBidnconv\fR converts the name to ACE.
+The details about the conversion procedure is:
+.RS 4
+.IP "4.1. delimiter mapping" 4
+Substibute certain characters specified as domain name delimiter
+with period.
+.IP "4.2. local mapping" 4
+Perform local mapping.
+If the local mapping is specified by command line option \-localmap,
+the specified mapping rule is applied.  Otherwise, find the mapping rule
+from the configuration file which matches to the TLD of the name,
+and perform mapping according to the matched rule.
+.br
+This step is skipped if the \-nolocalmap (or \-L) option is specified.
+.IP "4.3. NAMEPREP" 4
+Perform name preparation (NAMEPREP).
+Mapping, normalization, prohibited character checking, unassigned
+codepoint checking, bidirectional character checking are done in
+that order.
+If the prohibited character check, unassigned codepoint check, or
+bidi character check fails, the normal conversion procedure aborts.
+.br
+This step is skipped if the \-nonameprep (or \-N) option is specified.
+.IP "4.4. ASCII character checking" 4
+Checks ASCII range character in the domain name.
+the normal conversion procedure aborts, if the domain name has a label
+beginning or end with hyphen (U+002D) or it contains ASCII range character
+except for alphanumeric and hyphen,
+.br
+This step is skipped if the \-noasciicheck (or \-A) option is specified.
+.IP "4.5. ACE conversion" 4
+Convert the string to ACE.
+.IP "4.6. label length checking" 4
+The normal conversion procedure aborts, if the domain name has an empty
+label or too long label (64 characters or more).
+.br
+This step is skipped if the \-nolengthcheck option is specified.
+.RE
+.IP "5. output the result" 4
+.PP
+.\"
+.SH REVERSE CONVERSION MECHANISM
+This is like the normal conversion mechanism, but they are not symmetric.
+\fBidnconv\fR does its job for each line.
+.\"
+.IP "1. read a line from input text" 4
+.IP "2. convert the line to UTF-8" 4
+\fBidnconv\fR converts the line from local encoding to UTF-8.
+.IP "3. find internationalized domain names" 4
+If the \-whole\ (or \-w) option is specified, the entire line is
+assumed as an internationalized domain name.
+Otherwise, \fBidnconv\fR decodes any valid ASCII domain names
+including ACE names in the line.
+.IP "4. convert domain names to local encoding"
+Then, \fBidnconv\fR decodes the domain names.
+The decode procedure consists of the following steps.
+.RS 4
+.IP "4.1. Delimiter mapping" 4
+Substibute certain characters specified as domain name delimiter
+with period.
+.br
+.IP "4.2. NAMEPREP" 4
+Perform name preparation (NAMEPREP) for each label in the domain name.
+Mapping, normalization, prohibited character checking, unassigned
+codepoint checking, bidirectional character checking are done in
+that order.
+If the prohibited character check, unassigned codepoint check, or
+bidi character check fails, disqualified labels are restored to
+original input strings and further conversion on those labels are
+not performed.
+.br
+This step is skipped if the \-nonameprep (or \-N) option is specified.
+.IP "4.3. ACE conversion" 4
+Convert the string from ACE to UTF-8.
+.IP "4.4. Round trip checkning" 4
+For each label, perform the normal conversion and compare it with
+the result of the step 4.2.
+This check succeeds, if they are equivalent strings.
+In case of failure, disqualified labels are restored to original
+input strings and further conversion on those labels are not
+performed.
+.br
+This step is skipped if the \-noroundtripcheck option is specified.
+.IP "4.5. local encoding conversion" 4
+Convert the result of the step 4.3. from UTF-8 to local encoding.
+If a label in the domain name contains a character which cannot be
+represented in the local encoding, the label is restored to the
+original input string.
+.RE
+.IP "5. output the result" 4
+.PP
+.\"
+.SH FILE MANAGEMENT
+Maybe the best way to manage named.conf or zone master files that contains
+internationalized domain name is to keep them in your local codeset so that
+they can be edited with your favorite editor, and generate a version in
+the IDN encoding using \fBidnconv\fP.
+.PP
+`make' is a convenient tool for this purpose.
+Suppose the local codeset version has suffix `.lc', and its ACE version
+has suffix `.ace'.  The following Makefile enables you to generate
+ACE version from local codeset version by just typing `make'.
+.RS 4
+.nf
+.ft CW
+
+\&.SUFFIXES: .lc .ace
+\&.lc.ace:
+       idnconv -in $(LOCALCODE) -out $(IDNCODE) \\
+           $(IDNCONVOPT) $< > $@
+
+LOCALCODE = EUC-JP
+IDNCODE = Punycode
+IDNCONVOPT = 
+
+DESTFILES = db.zone1.ace db.zone2.ace
+
+all: $(DESTFILES)
+.ft
+.fi
+.RE
+.\"
+.SH SEE ALSO
+idn.conf(5),
+iconv(3)
+.\"
+.SH BUGS
+The automatic input-code selection depends on your system, and sometimes
+it cannot guess or guess wrong.  It is better to explicitly specify it
+using \-in option.
diff --git a/contrib/idn/idnkit-1.0-src/tools/idnconv/idnconv.c b/contrib/idn/idnkit-1.0-src/tools/idnconv/idnconv.c
new file mode 100644 (file)
index 0000000..f14fddc
--- /dev/null
@@ -0,0 +1,803 @@
+#ifndef lint
+static char *rcsid = "$Id: idnconv.c,v 1.1 2003/06/04 00:27: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.
+ */
+
+/*
+ * idnconv -- Codeset converter for named.conf and zone files
+ */
+
+#include <config.h>
+
+#include <stdio.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#ifdef HAVE_LOCALE_H
+#include <locale.h>
+#endif
+
+#include <idn/result.h>
+#include <idn/converter.h>
+#include <idn/normalizer.h>
+#include <idn/utf8.h>
+#include <idn/resconf.h>
+#include <idn/res.h>
+#include <idn/util.h>
+#include <idn/version.h>
+
+#include "util.h"
+
+#define MAX_DELIMITER          10
+#define MAX_LOCALMAPPER                10
+#define MAX_MAPPER             10
+#define MAX_NORMALIZER         10
+#define MAX_CHEKER             10
+
+#define FLAG_REVERSE           0x0001
+#define FLAG_DELIMMAP          0x0002
+#define FLAG_LOCALMAP          0x0004
+#define FLAG_MAP               0x0008
+#define FLAG_NORMALIZE         0x0010
+#define FLAG_PROHIBITCHECK     0x0020
+#define FLAG_UNASSIGNCHECK     0x0040
+#define FLAG_BIDICHECK         0x0080
+#define FLAG_ASCIICHECK                0x0100
+#define FLAG_LENGTHCHECK       0x0200
+#define FLAG_ROUNDTRIPCHECK    0x0400
+#define FLAG_SELECTIVE         0x0800
+
+#define FLAG_NAMEPREP \
+       (FLAG_MAP|FLAG_NORMALIZE|FLAG_PROHIBITCHECK|FLAG_UNASSIGNCHECK|\
+        FLAG_BIDICHECK)
+
+#define DEFAULT_FLAGS \
+       (FLAG_LOCALMAP|FLAG_NAMEPREP|FLAG_ASCIICHECK|FLAG_LENGTHCHECK|\
+       FLAG_ROUNDTRIPCHECK|FLAG_SELECTIVE|FLAG_DELIMMAP)
+
+int            line_number;            /* current input file line number */
+static int     flush_every_line = 0;   /* pretty obvious */
+
+static int             encode_file(idn_resconf_t conf1, idn_resconf_t conf2, 
+                                   FILE *fp, int flags);
+static int             decode_file(idn_resconf_t conf1, idn_resconf_t conf2, 
+                                   FILE *fp, int flags);
+static int             trim_newline(idnconv_strbuf_t *buf);
+static idn_result_t    convert_line(idnconv_strbuf_t *from,
+                                    idnconv_strbuf_t *to,
+                                    idn_resconf_t conf,
+                                    idn_action_t actions, int flags);
+static void            print_usage(char *cmd);
+static void            print_version(void);
+static unsigned long   get_ucs(const char *p);
+
+int
+main(int ac, char **av) {
+       char *cmd = *av;
+       char *cname;
+       unsigned long delimiters[MAX_DELIMITER];
+       char *localmappers[MAX_LOCALMAPPER];
+       char *nameprep_version = NULL;
+       int ndelimiters = 0;
+       int nlocalmappers = 0;
+       char *in_code = NULL;
+       char *out_code = NULL;
+       char *resconf_file = NULL;
+       int no_resconf = 0;
+       char *encoding_alias = NULL;
+       int flags = DEFAULT_FLAGS;
+       FILE *fp;
+       idn_result_t r;
+       idn_resconf_t resconf1, resconf2;
+       idn_converter_t conv;
+       int exit_value;
+
+#ifdef HAVE_SETLOCALE
+       (void)setlocale(LC_ALL, "");
+#endif
+
+       /*
+        * If the command name begins with 'r', reverse mode is assumed.
+        */
+       if ((cname = strrchr(cmd, '/')) != NULL)
+               cname++;
+       else
+               cname = cmd;
+       if (cname[0] == 'r')
+               flags |= FLAG_REVERSE;
+
+       ac--;
+       av++;
+       while (ac > 0 && **av == '-') {
+
+#define OPT_MATCH(opt) (strcmp(*av, opt) == 0)
+#define MUST_HAVE_ARG if (ac < 2) print_usage(cmd)
+#define APPEND_LIST(array, size, item, what) \
+       if (size >= (sizeof(array) / sizeof(array[0]))) { \
+               errormsg("too many " what "\n"); \
+               exit(1); \
+       } \
+       array[size++] = item; \
+       ac--; av++
+
+               if (OPT_MATCH("-in") || OPT_MATCH("-i")) {
+                       MUST_HAVE_ARG;
+                       in_code = av[1];
+                       ac--;
+                       av++;
+               } else if (OPT_MATCH("-out") || OPT_MATCH("-o")) {
+                       MUST_HAVE_ARG;
+                       out_code = av[1];
+                       ac--;
+                       av++;
+               } else if (OPT_MATCH("-conf") || OPT_MATCH("-c")) {
+                       MUST_HAVE_ARG;
+                       resconf_file = av[1];
+                       ac--;
+                       av++;
+               } else if (OPT_MATCH("-nameprep") || OPT_MATCH("-n")) {
+                       MUST_HAVE_ARG;
+                       nameprep_version = av[1];
+                       ac--;
+                       av++;
+               } else if (OPT_MATCH("-noconf") || OPT_MATCH("-C")) {
+                       no_resconf = 1;
+               } else if (OPT_MATCH("-reverse") || OPT_MATCH("-r")) {
+                       flags |= FLAG_REVERSE;
+               } else if (OPT_MATCH("-nolocalmap") || OPT_MATCH("-L")) {
+                       flags &= ~FLAG_LOCALMAP;
+               } else if (OPT_MATCH("-nonameprep") || OPT_MATCH("-N")) {
+                       flags &= ~FLAG_NAMEPREP;
+               } else if (OPT_MATCH("-unassigncheck") || OPT_MATCH("-u")) {
+                       flags |= FLAG_UNASSIGNCHECK;
+               } else if (OPT_MATCH("-nounassigncheck") || OPT_MATCH("-U")) {
+                       flags &= ~FLAG_UNASSIGNCHECK;
+               } else if (OPT_MATCH("-nobidicheck") || OPT_MATCH("-B")) {
+                       flags &= ~FLAG_BIDICHECK;
+               } else if (OPT_MATCH("-noasciicheck") || OPT_MATCH("-A")) {
+                       flags &= ~FLAG_ASCIICHECK;
+               } else if (OPT_MATCH("-nolengthcheck")) {
+                       flags &= ~FLAG_LENGTHCHECK;
+               } else if (OPT_MATCH("-noroundtripcheck")) {
+                       flags &= ~FLAG_ROUNDTRIPCHECK;
+               } else if (OPT_MATCH("-whole") || OPT_MATCH("-w")) {
+                       flags &= ~FLAG_SELECTIVE;
+               } else if (OPT_MATCH("-localmap")) {
+                       MUST_HAVE_ARG;
+                       APPEND_LIST(localmappers, nlocalmappers, av[1],
+                                   "local maps");
+               } else if (OPT_MATCH("-delimiter")) {
+                       unsigned long v;
+                       MUST_HAVE_ARG;
+                       v = get_ucs(av[1]);
+                       APPEND_LIST(delimiters, ndelimiters, v,
+                                   "delimiter maps");
+               } else if (OPT_MATCH("-alias") || OPT_MATCH("-a")) {
+                       MUST_HAVE_ARG;
+                       encoding_alias = av[1];
+                       ac--;
+                       av++;
+               } else if (OPT_MATCH("-flush")) {
+                       flush_every_line = 1;
+               } else if (OPT_MATCH("-version") || OPT_MATCH("-v")) {
+                       print_version();
+               } else {
+                       print_usage(cmd);
+               }
+#undef OPT_MATCH
+#undef MUST_HAVE_ARG
+#undef APPEND_LIST
+
+               ac--;
+               av++;
+       }
+
+       if (ac > 1)
+               print_usage(cmd);
+
+       /* Initialize. */
+       if ((r = idn_resconf_initialize()) != idn_success) {
+               errormsg("error initializing library\n");
+               return (1);
+       }
+
+       /*
+        * Create resource contexts.
+        * `resconf1' and `resconf2' are almost the same but local and
+        * IDN encodings are reversed.
+        */
+       resconf1 = NULL;
+       resconf2 = NULL;
+       if (idn_resconf_create(&resconf1) != idn_success ||
+           idn_resconf_create(&resconf2) != idn_success) {
+               errormsg("error initializing configuration contexts\n");
+               return (1);
+       }
+
+       /* Load configuration file. */
+       if (no_resconf) {
+               set_defaults(resconf1);
+               set_defaults(resconf2);
+       } else {
+               load_conf_file(resconf1, resconf_file);
+               load_conf_file(resconf2, resconf_file);
+       }
+
+       /* Set encoding alias file. */
+       if (encoding_alias != NULL)
+               set_encoding_alias(encoding_alias);
+
+       /* Set input codeset. */
+       if (flags & FLAG_REVERSE) {
+               if (in_code == NULL) {
+                       conv = idn_resconf_getidnconverter(resconf1);
+                       if (conv == NULL) {
+                               errormsg("cannot get the IDN encoding.\n"
+                                        "please specify an appropriate one "
+                                        "with `-in' option.\n");
+                               exit(1);
+                       }
+                       idn_resconf_setlocalconverter(resconf2, conv);
+                       idn_converter_destroy(conv);
+               } else {
+                       set_idncode(resconf1, in_code);
+                       set_localcode(resconf2, in_code);
+               }
+       } else {
+               if (in_code == NULL) {
+                       conv = idn_resconf_getlocalconverter(resconf1);
+                       if (conv == NULL) {
+                               errormsg("cannot get the local encoding.\n"
+                                        "please specify an appropriate one "
+                                        "with `-in' option.\n");
+                               exit(1);
+                       }
+                       idn_resconf_setidnconverter(resconf2, conv);
+                       idn_converter_destroy(conv);
+               } else {
+                       set_localcode(resconf1, in_code);
+                       set_idncode(resconf2, in_code);
+               }
+       }
+
+       /* Set output codeset. */
+       if (flags & FLAG_REVERSE) {
+               if (out_code == NULL) {
+                       conv = idn_resconf_getlocalconverter(resconf1);
+                       if (conv == NULL) {
+                               errormsg("cannot get the local encoding.\n"
+                                        "please specify an appropriate one "
+                                        "with `-out' option.\n");
+                               exit(1);
+                       }
+                       idn_resconf_setidnconverter(resconf2, conv);
+                       idn_converter_destroy(conv);
+               } else {
+                       set_localcode(resconf1, out_code);
+                       set_idncode(resconf2, out_code);
+               }
+       } else {
+               if (out_code == NULL) {
+                       conv = idn_resconf_getidnconverter(resconf1);
+                       if (conv == NULL) {
+                               errormsg("cannot get the IDN encoding.\n"
+                                        "please specify an appropriate one "
+                                        "with `-out' option.\n");
+                               exit(1);
+                       }
+                       idn_resconf_setlocalconverter(resconf2, conv);
+                       idn_converter_destroy(conv);
+               } else {
+                       set_idncode(resconf1, out_code);
+                       set_localcode(resconf2, out_code);
+               }
+       }
+
+       /* Set delimiter map(s). */
+       if (ndelimiters > 0) {
+               set_delimitermapper(resconf1, delimiters, ndelimiters);
+               set_delimitermapper(resconf2, delimiters, ndelimiters);
+       }
+
+       /* Set local map(s). */
+       if (nlocalmappers > 0) {
+               set_localmapper(resconf1, localmappers, nlocalmappers);
+               set_localmapper(resconf2, localmappers, nlocalmappers);
+       }
+
+       /* Set NAMEPREP version. */
+       if (nameprep_version != NULL) {
+               set_nameprep(resconf1, nameprep_version);
+               set_nameprep(resconf2, nameprep_version);
+       }
+
+       idn_res_enable(1);
+
+       /* Open input file. */
+       if (ac > 0) {
+               if ((fp = fopen(av[0], "r")) == NULL) {
+                       errormsg("cannot open file %s: %s\n",
+                                av[0], strerror(errno));
+                       return (1);
+               }
+       } else {
+               fp = stdin;
+       }
+
+       /* Do the conversion. */
+       if (flags & FLAG_REVERSE)
+               exit_value = decode_file(resconf1, resconf2, fp, flags);
+       else
+               exit_value = encode_file(resconf1, resconf2, fp, flags);
+
+       idn_resconf_destroy(resconf1);
+       idn_resconf_destroy(resconf2);
+
+       return exit_value;
+}
+
+static int
+encode_file(idn_resconf_t conf1, idn_resconf_t conf2, FILE *fp, int flags) {
+       idn_result_t r;
+       idnconv_strbuf_t buf1, buf2;
+       idn_action_t actions1, actions2;
+       int nl_trimmed;
+       int local_ace_hack;
+       idn_converter_t conv;
+
+       /*
+        * See if the input codeset is an ACE.
+        */
+       conv = idn_resconf_getlocalconverter(conf1);
+       if (conv != NULL && idn_converter_isasciicompatible(conv) &&
+           (flags & FLAG_SELECTIVE))
+               local_ace_hack = 1;
+       else
+               local_ace_hack = 0;
+       if (conv != NULL)
+               idn_converter_destroy(conv);
+
+       if (local_ace_hack) {
+               actions1 = IDN_IDNCONV;
+               if (flags & FLAG_ROUNDTRIPCHECK)
+                       actions1 |= IDN_RTCHECK;
+       } else {
+               actions1 = IDN_LOCALCONV;
+       }
+
+       actions2 = IDN_IDNCONV;
+       if (flags & FLAG_DELIMMAP)
+               actions2 |= IDN_DELIMMAP;
+       if (flags & FLAG_LOCALMAP)
+               actions2 |= IDN_LOCALMAP;
+       if (flags & FLAG_MAP)
+               actions2 |= IDN_MAP;
+       if (flags & FLAG_NORMALIZE)
+               actions2 |= IDN_NORMALIZE;
+       if (flags & FLAG_PROHIBITCHECK)
+               actions2 |= IDN_PROHCHECK;
+       if (flags & FLAG_UNASSIGNCHECK)
+               actions2 |= IDN_UNASCHECK;
+       if (flags & FLAG_BIDICHECK)
+               actions2 |= IDN_BIDICHECK;
+       if (flags & FLAG_ASCIICHECK)
+               actions2 |= IDN_ASCCHECK;
+       if (flags & FLAG_LENGTHCHECK)
+               actions2 |= IDN_LENCHECK;
+
+       strbuf_init(&buf1);
+       strbuf_init(&buf2);
+       line_number = 1;
+       while (strbuf_getline(&buf1, fp) != NULL) {
+               /*
+                * Trim newline at the end.  This is needed for
+                * those ascii-comatible encodings such as UTF-5 or RACE
+                * not to try converting newlines, which will result
+                * in `invalid encoding' error.
+                */
+               nl_trimmed = trim_newline(&buf1);
+
+               /*
+                * Convert input line to UTF-8.
+                */
+               if (local_ace_hack)
+                       r = convert_line(&buf1, &buf2, conf2, actions1,
+                                        FLAG_REVERSE|FLAG_SELECTIVE);
+               else
+                       r = convert_line(&buf1, &buf2, conf1, actions1,
+                                        0);
+                                
+               if (r != idn_success) {
+                       errormsg("conversion failed at line %d: %s\n",
+                                line_number,
+                                idn_result_tostring(r));
+                       goto error;
+               }
+               if (!idn_utf8_isvalidstring(strbuf_get(&buf2))) {
+                       errormsg("conversion to utf-8 failed at line %d\n",
+                                line_number);
+                       goto error;
+               }
+
+               /*
+                * Perform local mapping and NAMEPREP, and convert to
+                * the output codeset.
+                */
+               r = convert_line(&buf2, &buf1, conf1, actions2,
+                                flags & FLAG_SELECTIVE);
+                                
+               if (r != idn_success) {
+                       errormsg("error in nameprep or output conversion "
+                                "at line %d: %s\n",
+                                line_number, idn_result_tostring(r));
+                       goto error;
+               }
+
+               fputs(strbuf_get(&buf1), stdout);
+               if (nl_trimmed)
+                       putc('\n', stdout);
+
+               if (flush_every_line)
+                       fflush(stdout);
+
+               line_number++;
+       }
+
+       strbuf_reset(&buf1);
+       strbuf_reset(&buf2);
+       return (0);
+
+ error:
+       strbuf_reset(&buf1);
+       strbuf_reset(&buf2);
+       return (1);
+}
+
+static int
+decode_file(idn_resconf_t conf1, idn_resconf_t conf2, FILE *fp, int flags) {
+       idn_result_t r;
+       idnconv_strbuf_t buf1, buf2;
+       idn_action_t actions1, actions2;
+       int nl_trimmed;
+       int local_ace_hack, idn_ace_hack;
+       idn_converter_t conv;
+
+       /*
+        * See if the input codeset is an ACE.
+        */
+       conv = idn_resconf_getidnconverter(conf1);
+       if (conv != NULL && idn_converter_isasciicompatible(conv) &&
+           (flags & FLAG_SELECTIVE))
+               idn_ace_hack = 1;
+       else
+               idn_ace_hack = 0;
+       if (conv != NULL)
+               idn_converter_destroy(conv);
+
+       conv = idn_resconf_getlocalconverter(conf1);
+       if (conv != NULL && idn_converter_isasciicompatible(conv) &&
+           (flags & FLAG_SELECTIVE))
+               local_ace_hack = 1;
+       else
+               local_ace_hack = 0;
+       if (conv != NULL)
+               idn_converter_destroy(conv);
+
+       actions1 = IDN_IDNCONV;
+
+       if (local_ace_hack) {
+               actions2 = IDN_IDNCONV;
+               if (flags & FLAG_MAP)
+                       actions2 |= IDN_MAP;
+               if (flags & FLAG_NORMALIZE)
+                       actions2 |= IDN_NORMALIZE;
+               if (flags & FLAG_PROHIBITCHECK)
+                       actions2 |= IDN_PROHCHECK;
+               if (flags & FLAG_UNASSIGNCHECK)
+                       actions2 |= IDN_UNASCHECK;
+               if (flags & FLAG_BIDICHECK)
+                       actions2 |= IDN_BIDICHECK;
+               if (flags & FLAG_ASCIICHECK)
+                       actions2 |= IDN_ASCCHECK;
+               if (flags & FLAG_LENGTHCHECK)
+                       actions2 |= IDN_LENCHECK;
+       } else {
+               actions2 = IDN_LOCALCONV;
+       }
+
+       if (flags & FLAG_DELIMMAP)
+               actions1 |= IDN_DELIMMAP;
+       if (flags & FLAG_MAP)
+               actions1 |= IDN_MAP;
+       if (flags & FLAG_NORMALIZE)
+               actions1 |= IDN_NORMALIZE;
+       if (flags & FLAG_NORMALIZE)
+               actions1 |= IDN_NORMALIZE;
+       if (flags & FLAG_PROHIBITCHECK)
+               actions1 |= IDN_PROHCHECK;
+       if (flags & FLAG_UNASSIGNCHECK)
+               actions1 |= IDN_UNASCHECK;
+       if (flags & FLAG_BIDICHECK)
+               actions1 |= IDN_BIDICHECK;
+       if (flags & FLAG_ASCIICHECK)
+               actions1 |= IDN_ASCCHECK;
+       if (flags & FLAG_ROUNDTRIPCHECK)
+               actions1 |= IDN_RTCHECK;
+
+       strbuf_init(&buf1);
+       strbuf_init(&buf2);
+       line_number = 1;
+       while (strbuf_getline(&buf1, fp) != NULL) {
+               /*
+                * Trim newline at the end.  This is needed for
+                * those ascii-comatible encodings such as UTF-5 or RACE
+                * not to try converting newlines, which will result
+                * in `invalid encoding' error.
+                */
+               nl_trimmed = trim_newline(&buf1);
+
+               /*
+                * Treat input line as the string encoded in local
+                * encoding and convert it to UTF-8 encoded string.
+                */
+               if (local_ace_hack) {
+                       if (strbuf_copy(&buf2, strbuf_get(&buf1)) == NULL)
+                               r = idn_nomemory;
+                       else
+                               r = idn_success;
+               } else {
+                       r = convert_line(&buf1, &buf2, conf1, IDN_LOCALCONV,
+                                        0);
+               }
+               if (r != idn_success) {
+                       errormsg("conversion failed at line %d: %s\n",
+                                line_number, idn_result_tostring(r));
+                       goto error;
+               }
+
+               /*
+                * Convert internationalized domain names in the line.
+                */
+               if (idn_ace_hack) {
+                       r = convert_line(&buf2, &buf1, conf1, actions1,
+                                        FLAG_REVERSE|FLAG_SELECTIVE);
+               } else {
+                       r = convert_line(&buf2, &buf1, conf1, actions1,
+                                        FLAG_REVERSE);
+               }
+               if (r != idn_success) {
+                       errormsg("conversion failed at line %d: %s\n",
+                                line_number,
+                                idn_result_tostring(r));
+                       goto error;
+               }
+               if (!idn_utf8_isvalidstring(strbuf_get(&buf1))) {
+                       errormsg("conversion to utf-8 failed at line %d\n",
+                                line_number);
+                       goto error;
+               }
+
+               /*
+                * Perform round trip check and convert to the output
+                * codeset.
+                */
+               if (local_ace_hack) {
+                       r = convert_line(&buf1, &buf2, conf2, actions2,
+                                        FLAG_SELECTIVE);
+               } else {
+                       r = convert_line(&buf1, &buf2, conf1, actions2,
+                                        FLAG_REVERSE);
+               }
+
+               if (r != idn_success) {
+                       errormsg("error in nameprep or output conversion "
+                                "at line %d: %s\n",
+                                line_number, idn_result_tostring(r));
+                       goto error;
+               }
+
+               fputs(strbuf_get(&buf2), stdout);
+               if (nl_trimmed)
+                       putc('\n', stdout);
+
+               if (flush_every_line)
+                       fflush(stdout);
+
+               line_number++;
+       }
+       strbuf_reset(&buf1);
+       strbuf_reset(&buf2);
+       return (0);
+
+ error:
+       strbuf_reset(&buf1);
+       strbuf_reset(&buf2);
+       return (1);
+}
+
+static int
+trim_newline(idnconv_strbuf_t *buf) {
+       /*
+        * If the string in BUF ends with a newline, trim it and
+        * return 1.  Otherwise, just return 0 without modifying BUF.
+        */
+       char *s = strbuf_get(buf);
+       size_t len = strlen(s);
+
+       if (s[len - 1] == '\n') {
+               s[len - 1] = '\0';
+               return (1);
+       }
+
+       return (0);
+}
+
+static idn_result_t
+convert_line(idnconv_strbuf_t *from, idnconv_strbuf_t *to,
+            idn_resconf_t conf, idn_action_t actions, int flags)
+{
+       idn_result_t r = idn_success;
+       char *from_str = strbuf_get(from);
+
+       for (;;) {
+               char *to_str = strbuf_get(to);
+               size_t to_size = strbuf_size(to);
+
+               switch (flags & (FLAG_REVERSE|FLAG_SELECTIVE)) {
+               case 0:
+                       r = idn_res_encodename(conf, actions, from_str,
+                                              to_str, to_size);
+                       break;
+               case FLAG_REVERSE:
+                       r = idn_res_decodename(conf, actions, from_str,
+                                              to_str, to_size);
+                       break;
+               case FLAG_SELECTIVE:
+                       r = selective_encode(conf, actions, from_str,
+                                            to_str, to_size);
+                       break;
+               case FLAG_REVERSE|FLAG_SELECTIVE:
+                       r = selective_decode(conf, actions, from_str,
+                                            to_str, to_size);
+                       break;
+               }
+               if (r == idn_buffer_overflow) {
+                       /*
+                        * Conversion is not successful because
+                        * the size of the target buffer is not enough.
+                        * Double the size and retry.
+                        */
+                       if (strbuf_double(to) == NULL) {
+                               /* oops. allocation failed. */
+                               return (idn_nomemory);
+                       }
+               } else {
+                       break;
+               }
+       }
+       return (r);
+}
+
+static char *options[] = {
+       "-in INPUT-CODESET   : specifies input codeset name.",
+       "-i INPUT-CODESET    : synonym for -in",
+       "-out OUTPUT-CODESET : specifies output codeset name.",
+       "-o OUTPUT-CODESET   : synonym for -out",
+       "-conf CONF-FILE     : specifies idnkit configuration file.",
+       "-c CONF-FILE        : synonym for -conf",
+       "-noconf             : do not load idnkit configuration file.",
+       "-C                  : synonym for -noconf",
+       "-reverse            : specifies reverse conversion.",
+       "                      (i.e. IDN encoding to local encoding)",
+       "-r                  : synonym for -reverse",
+       "-nameprep VERSION   : specifies version name of NAMEPREP.",
+       "-n VERSION          : synonym for -nameprep",
+       "-nonameprep         : do not perform NAMEPREP.",
+       "-N                  : synonym for -nonameprep",
+       "-localmap MAPPING   : specifies local mapping.",
+       "-nolocalmap         : do not perform local mapping.",
+       "-L                  : synonym for -nolocalmap",
+       "-nounassigncheck    : do not perform unassigned codepoint check.",
+       "-U                  : synonym for -nounassigncheck",
+       "-nobidicheck        : do not perform bidirectional text check.",
+       "-B                  : synonym for -nobidicheck",
+       "-nolengthcheck      : do not check label length.",
+       "-noasciicheck       : do not check ASCII range characters.",
+       "-A                  : synonym for -noasciicheck",
+       "-noroundtripcheck   : do not perform round trip check.",
+       "-delimiter U+XXXX   : specifies local delimiter code point.",
+       "-alias alias-file   : specifies codeset alias file.",
+       "-a                  : synonym for -alias",
+       "-flush              : line-buffering mode.",
+       "-whole              : convert the whole region instead of",
+       "                      regions containing non-ascii characters.",
+       "-w                  : synonym for -whole",
+       "-version            : print version number, then exit.",
+       "-v                  : synonym for -version",
+       "",
+       " The following options can be specified multiple times",
+       "   -localmap, -delimiter",
+       NULL,
+};
+
+static void
+print_version() {
+       fprintf(stderr, "idnconv (idnkit) version: %s\n"
+               "library version: %s\n",
+               IDNKIT_VERSION,
+               idn_version_getstring());
+       exit(0);
+}
+
+static void
+print_usage(char *cmd) {
+       int i;
+
+       fprintf(stderr, "Usage: %s [options..] [file]\n", cmd);
+
+       for (i = 0; options[i] != NULL; i++)
+               fprintf(stderr, "\t%s\n", options[i]);
+
+       exit(1);
+}
+
+static unsigned long
+get_ucs(const char *p) {
+       unsigned long v;
+       char *end;
+
+       /* Skip optional 'U+' */
+       if (strncmp(p, "U+", 2) == 0)
+               p += 2;
+
+       v = strtoul(p, &end, 16);
+       if (*end != '\0') {
+               fprintf(stderr, "invalid UCS code point \"%s\"\n", p);
+               exit(1);
+       }
+
+       return v;
+}
diff --git a/contrib/idn/idnkit-1.0-src/tools/idnconv/idnslookup.in b/contrib/idn/idnkit-1.0-src/tools/idnconv/idnslookup.in
new file mode 100644 (file)
index 0000000..65d0a3d
--- /dev/null
@@ -0,0 +1,116 @@
+#! /bin/sh
+# $Id: idnslookup.in,v 1.1 2003/06/04 00:27:10 marka Exp $
+#
+# 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.
+
+USAGE="Usage: $0 domain-name DNS-server"
+
+#
+# Parse command line arguments.
+#
+if [ $# -lt 2 ] ; then
+    echo "$0: too few argument" 1>&2
+    echo $USAGE 1>&2
+    exit 1
+fi
+
+if [ $# -gt 2 ] ; then
+    echo "$0: too many argument" 1>&2
+    echo $USAGE 1>&2
+    exit 1
+fi
+
+case "$1" in
+-*) echo "$0: unknown option $1" 1>&2
+    echo $USAGE 1>&2
+    exit 1
+    ;;
+esac
+
+LOCAL_DOMAIN_NAME="$1"
+NAME_SERVER="$2"
+
+#
+# Append some directories to PATH.
+#
+[ -d /usr/sbin ] && PATH=$PATH:/usr/sbin
+[ -d /sbin ] && PATH=$PATH:/sbin
+
+#
+# Find `nslookup' command.
+#
+if [ x"$NSLOOKUP" = x ] ; then
+    for I in `echo $PATH | sed -e 's/:/ /g'` ; do
+       if [ -x $I/nslookup ] ; then
+           NSLOOKUP="$I/nslookup"
+           break
+       fi
+    done
+    if [ "$NSLOOKUP" = "" ] ; then
+       echo "$0: nslookup not found" 1>&2
+       exit 1
+    fi
+fi
+if [ ! -x "$NSLOOKUP" ] ; then
+    echo "$0: nslookup not found" 1>&2
+    exit 1
+fi
+
+#
+# Check if `idnconv' command exists.
+#
+IDNCONV=${IDNCONV-"@bindir@/idnconv"}
+if [ ! -x "$IDNCONV" ] ; then
+    echo "$0: idnconv not found" 1>&2
+    exit 1
+fi
+
+#
+# Convert domain name to IDN encoding.
+#
+IDN_DOMAIN_NAME="`echo $LOCAL_DOMAIN_NAME | $IDNCONV -w`" || exit 1
+
+#
+# Invoke nslookup.
+#
+$NSLOOKUP $IDN_DOMAIN_NAME $NAME_SERVER < /dev/null || exit 1
+
+exit 0
diff --git a/contrib/idn/idnkit-1.0-src/tools/idnconv/make.wnt b/contrib/idn/idnkit-1.0-src/tools/idnconv/make.wnt
new file mode 100644 (file)
index 0000000..2f44114
--- /dev/null
@@ -0,0 +1,72 @@
+# $Id: make.wnt,v 1.1 2003/06/04 00:27:06 marka Exp $
+# Makefile for idnconv, 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
+IDNLIBDIR = ..\..\lib
+LIBS = $(IDNLIBDIR)\idnkit.lib $(ICONVDIR)\iconv.lib
+SYSLIBS = $(conlibsdll)
+
+SRCS = idnconv.c util.c selectiveencode.c
+OBJS = idnconv.obj util.obj selectiveencode.obj
+
+TARGET = idnconv.exe
+
+all: $(TARGET)
+
+idnconv.exe: $(OBJS) $(LIBS)
+       $(link) $(conflags) /out:idnconv.exe $(OBJS) $(LIBS) $(SYSLIBS)
+
+install:
+
+clean:
+       -del *.exe *.obj *.lib core *.core *~
+
+idnconv.obj: idnconv.c
+       $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) $*.c
+util.obj: util.c
+       $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) $*.c
+selectiveencode.obj: selectiveencode.c
+       $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) $*.c
diff --git a/contrib/idn/idnkit-1.0-src/tools/idnconv/selectiveencode.c b/contrib/idn/idnkit-1.0-src/tools/idnconv/selectiveencode.c
new file mode 100644 (file)
index 0000000..eed4b34
--- /dev/null
@@ -0,0 +1,127 @@
+#ifndef lint
+static char *rcsid = "$Id: selectiveencode.c,v 1.1 2003/06/04 00:27:07 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 <idn/assert.h>
+#include <idn/logmacro.h>
+#include <idn/result.h>
+#include <idn/utf8.h>
+#include <idn/debug.h>
+
+#include "selectiveencode.h"
+
+static int     is_domain_delimiter(char c);
+static char    *find_nonascii(const char *s);
+
+idn_result_t
+idn_selectiveencode_findregion(const char *s,
+                              char **startp, char **endp)
+{
+       char *non_ascii;
+       char *start, *end;
+
+       assert(s != NULL && startp != NULL && endp != NULL);
+
+       TRACE(("idn_selectiveencode_findregion(s=\"%s\")\n",
+             idn__debug_xstring(s, 20)));
+
+       /*
+        * Scan the specified string looking for non-ascii character.
+        */
+       if ((non_ascii = find_nonascii(s)) == NULL)
+               return (idn_notfound);
+
+       /*
+        * Non-ascii character found.
+        * Determine the region to encode.
+        */
+       
+       /*
+        * First, we scan backwards to find the beginning of the region
+        * that should be converted.
+        */
+       start = non_ascii;
+       while (start > s) {
+               char *prev = idn_utf8_findfirstbyte(start - 1, s);
+               if (is_domain_delimiter(*prev))
+                       break;                  /* Found */
+               start = prev;
+       }
+       *startp = start;
+
+       /*
+        * Next we scan forwards looking for the end of the region.
+        */
+       end = non_ascii + idn_utf8_mblen(non_ascii);
+       while (!is_domain_delimiter(*end))
+               end += idn_utf8_mblen(end);
+       *endp = end;
+
+       return (idn_success);
+}
+
+static int
+is_domain_delimiter(char c) {
+       return ((unsigned char)c < 0x80 &&
+               !('A' <= c && c <= 'Z') &&
+               !('a' <= c && c <= 'z') &&
+               !('0' <= c && c <= '9') &&
+               c != '-' && c != '.');
+}
+
+static char *
+find_nonascii(const char *s) {
+       while (*s != '\0' && (unsigned char)*s < 0x80)
+               s++;
+       if (*s == '\0')
+               return (NULL);
+       else
+               return ((char *)s);
+}
diff --git a/contrib/idn/idnkit-1.0-src/tools/idnconv/selectiveencode.h b/contrib/idn/idnkit-1.0-src/tools/idnconv/selectiveencode.h
new file mode 100644 (file)
index 0000000..0006911
--- /dev/null
@@ -0,0 +1,70 @@
+/* $Id: selectiveencode.h,v 1.1 2003/06/04 00:27:08 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.
+ */
+
+#ifndef IDN_SELECTIVENCODE_H
+#define IDN_SELECTIVENCODE_H 1
+
+/*
+ * Find where to convert.
+ *
+ * Find a substring for which IDN domain name codeset conversion is necessary.
+ */
+
+#include <idn/result.h>
+
+/*
+ * Scan the given string 's' (in UTF-8 encoding) looking for a substring
+ * made of
+ *   + at least one non-ascii character and
+ *   + zero or more legitimate domain-name characters (i.e. ascii alphabets,
+ *     digits and hyphens) and periods.
+ *
+ * Returns:
+ *     idn_success             -- ok, found.
+ *     idn_notfound            -- not found.
+ */
+extern idn_result_t
+idn_selectiveencode_findregion(const char *s, char **startp, char **endp);
+
+#endif /* IDN_SELECTIVENCODE_H */
diff --git a/contrib/idn/idnkit-1.0-src/tools/idnconv/util.c b/contrib/idn/idnkit-1.0-src/tools/idnconv/util.c
new file mode 100644 (file)
index 0000000..216b9f2
--- /dev/null
@@ -0,0 +1,554 @@
+#ifndef lint
+static char *rcsid = "$Id: util.c,v 1.1 2003/06/04 00:27:08 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 <stddef.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <ctype.h>
+#include <errno.h>
+
+#include <idn/resconf.h>
+#include <idn/converter.h>
+#include <idn/res.h>
+#include <idn/utf8.h>
+
+#include "util.h"
+#include "selectiveencode.h"
+
+extern int             line_number;
+
+idn_result_t
+selective_encode(idn_resconf_t conf, idn_action_t actions,
+                char *from, char *to, int tolen)
+{
+       for (;;) {
+               int len;
+               char *region_start, *region_end;
+               idn_result_t r;
+               char save;
+
+               /*
+                * Find the region that needs conversion.
+                */
+               r = idn_selectiveencode_findregion(from, &region_start,
+                                                  &region_end);
+               if (r == idn_notfound) {
+                       /*
+                        * Not found.  Just copy the whole thing.
+                        */
+                       if (tolen <= strlen(from))
+                               return (idn_buffer_overflow);
+                       (void)strcpy(to, from);
+                       return (idn_success);
+               } else if (r != idn_success) {
+                       /* This should not happen.. */
+                       errormsg("internal error at line %d: %s\n",
+                                line_number, idn_result_tostring(r));
+                       return (r);
+               }
+
+               /*
+                * We have found a region to convert.
+                * First, copy the prefix part verbatim.
+                */
+               len = region_start - from;
+               if (tolen < len) {
+                       errormsg("internal buffer overflow at line %d\n",
+                                line_number);
+                       return (idn_buffer_overflow);
+               }
+               (void)memcpy(to, from, len);
+               to += len;
+               tolen -= len;
+
+               /*
+                * Terminate the region with NUL.
+                */
+               save = *region_end;
+               *region_end = '\0';
+
+               /*
+                * Encode the region.
+                */
+               r = idn_res_encodename(conf, actions, region_start, to, tolen);
+
+               /*
+                * Restore character.
+                */
+               *region_end = save;
+
+               if (r != idn_success)
+                       return (r);
+
+               len = strlen(to);
+               to += len;
+               tolen -= len;
+
+               from = region_end;
+       }
+}
+
+idn_result_t
+selective_decode(idn_resconf_t conf, idn_action_t actions,
+                char *from, char *to, int tolen)
+{
+       char *domain_name;
+       char *ignored_chunk;
+       char save;
+       int len;
+       idn_result_t r;
+
+       /*
+        * While `*from' points to a character in a string which may be
+        * a domain name, `domain_name' refers to the beginning of the
+        * domain name.
+        */
+       domain_name = NULL;
+
+       /*
+        * We ignore chunks matching to the regular expression:
+        *    [\-\.][0-9A-Za-z\-\.]*
+        *
+        * While `*from' points to a character in such a chunk,
+        * `ignored_chunk' refers to the beginning of the chunk.
+        */
+       ignored_chunk = NULL;
+
+       for (;;) {
+               if (*from == '-') {
+                       /*
+                        * We don't recognize `.-' as a part of domain name.
+                        */
+                       if (domain_name != NULL) {
+                               if (*(from - 1) == '.') {
+                                       ignored_chunk = domain_name;
+                                       domain_name = NULL;
+                               }
+                       } else if (ignored_chunk == NULL) {
+                               ignored_chunk = from;
+                       }
+
+               } else if (*from == '.') {
+                       /*
+                        * We don't recognize `-.' nor `..' as a part of
+                        * domain name.
+                        */
+                       if (domain_name != NULL) {
+                               if (*(from - 1) == '-' || *(from - 1) == '.') {
+                                       ignored_chunk = domain_name;
+                                       domain_name = NULL;
+                               }
+                       } else if (ignored_chunk == NULL) {
+                               ignored_chunk = from;
+                       }
+
+               } else if (('a' <= *from && *from <= 'z') ||
+                          ('A' <= *from && *from <= 'Z') ||
+                          ('0' <= *from && *from <= '9')) {
+                       if (ignored_chunk == NULL && domain_name == NULL)
+                               domain_name = from;
+
+               } else {
+                       if (ignored_chunk != NULL) {
+                               /*
+                                * `from' reaches the end of the ignored chunk.
+                                * Copy the chunk to `to'.
+                                */
+                               len = from - ignored_chunk;
+                               if (tolen < len)
+                                       return (idn_buffer_overflow);
+                               (void)memcpy(to, ignored_chunk, len);
+                               to += len;
+                               tolen -= len;
+
+                       } else if (domain_name != NULL) {
+                               /*
+                                * `from' reaches the end of the domain name.
+                                * Decode the domain name, and copy the result
+                                * to `to'.
+                                */
+                               save = *from;
+                               *from = '\0';
+                               r = idn_res_decodename(conf, actions,
+                                                      domain_name, to, tolen);
+                               *from = save;
+
+                               if (r == idn_success) {
+                                       len = strlen(to);
+                               } else if (r == idn_invalid_encoding) {
+                                       len = from - domain_name;
+                                       if (tolen < len)
+                                               return (idn_buffer_overflow);
+                                       (void)memcpy(to, domain_name, len);
+                               } else {
+                                       return (r);
+                               }
+                               to += len;
+                               tolen -= len;
+                       }
+
+                       /*
+                        * Copy a character `*from' to `to'.
+                        */
+                       if (tolen < 1)
+                               return (idn_buffer_overflow);
+                       *to = *from;
+                       to++;
+                       tolen--;
+
+                       domain_name = NULL;
+                       ignored_chunk = NULL;
+
+                       if (*from == '\0')
+                               break;
+               }
+
+               from++;
+       }
+
+       return (idn_success);
+}
+
+void
+set_defaults(idn_resconf_t conf) {
+       idn_result_t r;
+
+       if ((r = idn_resconf_setdefaults(conf)) != idn_success) {
+               errormsg("error setting default configuration: %s\n",
+                        idn_result_tostring(r));
+               exit(1);
+       }
+}
+
+void
+load_conf_file(idn_resconf_t conf, const char *file) {
+       idn_result_t r;
+
+       if ((r = idn_resconf_loadfile(conf, file)) != idn_success) {
+               errormsg("error reading configuration file: %s\n",
+                        idn_result_tostring(r));
+               exit(1);
+       }
+}
+
+void
+set_encoding_alias(const char *encoding_alias) {
+       idn_result_t r;
+
+       if ((r = idn_converter_resetalias()) != idn_success) {
+               errormsg("cannot reset alias information: %s\n",
+                        idn_result_tostring(r));
+               exit(1);
+       }
+
+       if ((r = idn_converter_aliasfile(encoding_alias)) != idn_success) {
+               errormsg("cannot read alias file %s: %s\n",
+                        encoding_alias, idn_result_tostring(r));
+               exit(1);
+       }
+}
+
+void
+set_localcode(idn_resconf_t conf, const char *code) {
+       idn_result_t r;
+
+       r = idn_resconf_setlocalconvertername(conf, code,
+                                             IDN_CONVERTER_RTCHECK);
+       if (r != idn_success) {
+               errormsg("cannot create converter for codeset %s: %s\n",
+                        code, idn_result_tostring(r));
+               exit(1);
+       }
+}
+
+void
+set_idncode(idn_resconf_t conf, const char *code) {
+       idn_result_t r;
+
+       r = idn_resconf_setidnconvertername(conf, code,
+                                           IDN_CONVERTER_RTCHECK);
+       if (r != idn_success) {
+               errormsg("cannot create converter for codeset %s: %s\n",
+                        code, idn_result_tostring(r));
+               exit(1);
+       }
+}
+
+void
+set_delimitermapper(idn_resconf_t conf, unsigned long *delimiters,
+                   int ndelimiters) {
+       idn_result_t r;
+
+       r = idn_resconf_addalldelimitermapucs(conf, delimiters, ndelimiters);
+       if (r != idn_success) {
+               errormsg("cannot add delimiter: %s\n",
+                        idn_result_tostring(r));
+               exit(1);
+       }
+}
+
+void
+set_localmapper(idn_resconf_t conf, char **mappers, int nmappers) {
+       idn_result_t r;
+
+       /* Add mapping. */
+       r = idn_resconf_addalllocalmapselectornames(conf, 
+                                                   IDN_MAPSELECTOR_DEFAULTTLD,
+                                                   (const char **)mappers,
+                                                   nmappers);
+       if (r != idn_success) {
+               errormsg("cannot add local map: %s\n",
+                        idn_result_tostring(r));
+               exit(1);
+       }
+}
+
+void
+set_nameprep(idn_resconf_t conf, char *version) {
+       idn_result_t r;
+
+       r = idn_resconf_setnameprepversion(conf, version);
+       if (r != idn_success) {
+               errormsg("error setting nameprep %s: %s\n",
+                        version, idn_result_tostring(r));
+               exit(1);
+       }
+}
+
+void
+set_mapper(idn_resconf_t conf, char **mappers, int nmappers) {
+       idn_result_t r;
+
+       /* Configure mapper. */
+       r = idn_resconf_addallmappernames(conf, (const char **)mappers,
+                                         nmappers);
+       if (r != idn_success) {
+               errormsg("cannot add nameprep map: %s\n",
+                        idn_result_tostring(r));
+               exit(1);
+       }
+}
+
+void
+set_normalizer(idn_resconf_t conf, char **normalizers, int nnormalizer) {
+       idn_result_t r;
+
+       r = idn_resconf_addallnormalizernames(conf,
+                                             (const char **)normalizers,
+                                             nnormalizer);
+       if (r != idn_success) {
+               errormsg("cannot add normalizer: %s\n",
+                        idn_result_tostring(r));
+               exit(1);
+       }
+}
+
+void
+set_prohibit_checkers(idn_resconf_t conf, char **prohibits, int nprohibits) {
+       idn_result_t r;
+
+       r = idn_resconf_addallprohibitcheckernames(conf,
+                                                  (const char **)prohibits,
+                                                  nprohibits);
+       if (r != idn_success) {
+               errormsg("cannot add prohibit checker: %s\n",
+                        idn_result_tostring(r));
+               exit(1);
+       }
+}
+
+void
+set_unassigned_checkers(idn_resconf_t conf, char **unassigns, int nunassigns) {
+       idn_result_t r;
+
+       r = idn_resconf_addallunassignedcheckernames(conf,
+                                                    (const char **)unassigns,
+                                                    nunassigns);
+       if (r != idn_success) {
+               errormsg("cannot add unassigned checker: %s\n",
+                        idn_result_tostring(r));
+               exit(1);
+       }
+}
+
+void
+errormsg(const char *fmt, ...) {
+       va_list args;
+
+       va_start(args, fmt);
+       vfprintf(stderr, fmt, args);
+       va_end(args);
+}
+
+
+/*
+ * Dynamic Stirng Buffer Utility
+ */
+
+void
+strbuf_init(idnconv_strbuf_t *buf) {
+       /*
+        * Initialize the given string buffer.
+        * Caller must allocate the structure (idnconv_strbuf_t)
+        * as an automatic variable or by malloc().
+        */
+       buf->str = buf->local_buf;
+       buf->str[0] = '\0';
+       buf->size = sizeof(buf->local_buf);
+}
+
+void
+strbuf_reset(idnconv_strbuf_t *buf) {
+       /*
+        * Reset the given string buffer.
+        * Free memory allocated by this utility, and 
+        * re-initialize.
+        */
+       if (buf->str != NULL && buf->str != buf->local_buf) {
+               free(buf->str);
+       }
+       strbuf_init(buf);
+}
+
+char *
+strbuf_get(idnconv_strbuf_t *buf) {
+       /*
+        * Get the pointer of the buffer.
+        */
+       return (buf->str);
+}
+
+size_t
+strbuf_size(idnconv_strbuf_t *buf) {
+       /*
+        * Get the allocated size of the buffer.
+        */
+       return (buf->size);
+}
+
+char *
+strbuf_copy(idnconv_strbuf_t *buf, const char *str) {
+       /*
+        * Copy STR to BUF.
+        */
+       size_t  len = strlen(str);
+
+       if (strbuf_alloc(buf, len + 1) == NULL)
+               return (NULL);
+       strcpy(buf->str, str);
+       return (buf->str);
+}
+
+char *
+strbuf_append(idnconv_strbuf_t *buf, const char *str) {
+       /*
+        * Append STR to the end of BUF.
+        */
+       size_t  len1 = strlen(buf->str);
+       size_t  len2 = strlen(str);
+       char *p;
+#define MARGIN 50
+
+       p = strbuf_alloc(buf, len1 + len2 + 1 + MARGIN);
+       if (p != NULL)
+               strcpy(buf->str + len1, str);
+       return (p);
+}
+
+char *
+strbuf_alloc(idnconv_strbuf_t *buf, size_t size) {
+       /*
+        * Reallocate the buffer of BUF if needed
+        * so that BUF can hold SIZE bytes of data at least.
+        */
+       char *p;
+
+       if (buf->size >= size)
+               return (buf->str);
+       if (buf->str == buf->local_buf) {
+               if ((p = malloc(size)) == NULL)
+                       return (NULL);
+               memcpy(p, buf->local_buf, sizeof(buf->local_buf));
+       } else {
+               if ((p = realloc(buf->str, size)) == NULL)
+                       return (NULL);
+       }
+       buf->str = p;
+       buf->size = size;
+       return (buf->str);
+}
+
+char *
+strbuf_double(idnconv_strbuf_t *buf) {
+       /*
+        * Double the size of the buffer of BUF.
+        */
+       return (strbuf_alloc(buf, buf->size * 2));
+}
+
+char *
+strbuf_getline(idnconv_strbuf_t *buf, FILE *fp) {
+       /*
+        * Read a line from FP.
+        */
+       char s[256];
+
+       buf->str[0] = '\0';
+       while (fgets(s, sizeof(s), fp) != NULL) {
+               if (strbuf_append(buf, s) == NULL)
+                       return (NULL);
+               if (strlen(s) < sizeof(s) - 1 || s[sizeof(s) - 2] == '\n')
+                       return (buf->str);
+       }
+       if (buf->str[0] != '\0')
+               return (buf->str);
+       return (NULL);
+}
diff --git a/contrib/idn/idnkit-1.0-src/tools/idnconv/util.h b/contrib/idn/idnkit-1.0-src/tools/idnconv/util.h
new file mode 100644 (file)
index 0000000..adc2196
--- /dev/null
@@ -0,0 +1,96 @@
+/* $Id: util.h,v 1.1 2003/06/04 00:27:09 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 IDN_IDNCONV_UTIL_H
+#define IDN_IDNCONV_UTIL_H 1
+
+#include <idn/res.h>
+
+#define IDNCONV_LOCALBUF_SIZE  512
+
+typedef struct {
+       char    *str;
+       size_t  size;
+       char    local_buf[IDNCONV_LOCALBUF_SIZE];
+} idnconv_strbuf_t;
+
+extern idn_result_t    selective_encode(idn_resconf_t conf,
+                                        idn_action_t actions, char *from,
+                                        char *to, int tolen);
+extern idn_result_t    selective_decode(idn_resconf_t conf,
+                                        idn_action_t actions, char *from,
+                                        char *to, int tolen);
+extern void            set_defaults(idn_resconf_t conf);
+extern void            load_conf_file(idn_resconf_t conf, const char *file);
+extern void            set_encoding_alias(const char *encoding_alias);
+extern void            set_localcode(idn_resconf_t conf, const char *code);
+extern void            set_idncode(idn_resconf_t conf, const char *code);
+extern void            set_delimitermapper(idn_resconf_t conf,
+                                           unsigned long *delimiters,
+                                           int ndelimiters);
+extern void            set_localmapper(idn_resconf_t conf,
+                                       char **mappers, int nmappers);
+extern void            set_nameprep(idn_resconf_t conf, char *version);
+extern void            set_mapper(idn_resconf_t conf,
+                                  char **mappers, int nmappers);
+extern void            set_normalizer(idn_resconf_t conf,
+                                      char **normalizer, int nnormalizer);
+extern void            set_prohibit_checkers(idn_resconf_t conf,
+                                             char **prohibits,
+                                             int nprohibits);
+extern void            set_unassigned_checkers(idn_resconf_t conf,
+                                               char **unassigns,
+                                               int nunassigns);
+extern void            errormsg(const char *fmt, ...);
+extern void            strbuf_init(idnconv_strbuf_t *buf);
+extern void            strbuf_reset(idnconv_strbuf_t *buf);
+extern char            *strbuf_get(idnconv_strbuf_t *buf);
+extern size_t          strbuf_size(idnconv_strbuf_t *buf);
+extern char            *strbuf_copy(idnconv_strbuf_t *buf, const char *str);
+extern char            *strbuf_append(idnconv_strbuf_t *buf, const char *str);
+extern char            *strbuf_alloc(idnconv_strbuf_t *buf, size_t size);
+extern char            *strbuf_double(idnconv_strbuf_t *buf);
+extern char            *strbuf_getline(idnconv_strbuf_t *buf, FILE *fp);
+
+#endif /* IDN_IDNCONV_UTIL_H */
diff --git a/contrib/idn/idnkit-1.0-src/tools/make.wnt b/contrib/idn/idnkit-1.0-src/tools/make.wnt
new file mode 100644 (file)
index 0000000..1ea01c7
--- /dev/null
@@ -0,0 +1,57 @@
+# $Id: make.wnt,v 1.1 2003/06/04 00:27:05 marka Exp $
+# 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.
+
+all : force
+       cd idnconv
+       $(MAKE) -f make.wnt
+       cd ..
+
+install : all
+       cd idnconv
+       $(MAKE) -f make.wnt install
+       cd ..
+
+clean : force
+       cd idnconv
+       $(MAKE) -f make.wnt clean
+       cd ..
+
+force:
diff --git a/contrib/idn/idnkit-1.0-src/tools/rpm/idnkit.spec b/contrib/idn/idnkit-1.0-src/tools/rpm/idnkit.spec
new file mode 100644 (file)
index 0000000..c740570
--- /dev/null
@@ -0,0 +1,142 @@
+%define prefix /usr
+%define sysconfdir /etc
+%define version 1.0
+
+# official/beta release:
+#define release 1
+#define distrel %{version}
+
+# release candidate:
+%define release rc1
+%define distrel %{version}-%{release}
+
+%define serial 2002051501
+
+%define name idnkit
+%define distsrc %{name}-%{distrel}-src
+
+Name: %{name}
+Version: %{version}
+Release: %{release}
+Copyright: distributable
+Group: System Environment
+Source: %{distsrc}.tar.gz
+BuildRoot: /var/tmp/%{name}-root
+Serial: %{serial}
+Summary: Internationalized Domain Name kit (idnkit/JPNIC)
+Vendor: JPNIC
+Packager: Japan Network Information Center
+
+%description
+idnkit is a kit for handling Internationalized Domain Name.
+
+%package devel
+Group: Development/Libraries
+Summary: The development files for idnkit
+
+%description devel
+The header files and libraries (libidnkit.a and libidnkitlite.a)
+to develop applications that use the libraries.
+
+%prep
+%setup -n %{distsrc}
+
+%build
+if [ -f /usr/lib/libiconv.a -o -f /usr/lib/libiconv.so ]
+then
+  if [ -f /lib/libc-2.0* ]
+  then
+    ICONV="--with-iconv=yes"
+  fi
+fi
+
+CFLAGS="$RPM_OPT_FLAGS" ./configure \
+       --prefix=%{prefix} --sysconfdir=%{sysconfdir} \
+       --enable-runidn \
+       $ICONV
+make
+
+%install
+rm -fr $RPM_BUILD_ROOT
+make DESTDIR=$RPM_BUILD_ROOT install
+mv $RPM_BUILD_ROOT/etc/idn.conf.sample $RPM_BUILD_ROOT/etc/idn.conf
+mv $RPM_BUILD_ROOT/etc/idnalias.conf.sample $RPM_BUILD_ROOT/etc/idnalias.conf
+
+# devel kit
+#install -c lib/libidnkit.a $RPM_BUILD_ROOT/usr/lib
+#cp -r include/idn $RPM_BUILD_ROOT/usr/include
+
+# docs
+mkdir rpm_docs
+(cp NEWS INSTALL INSTALL.ja DISTFILES README.ja README LICENSE.txt \
+    ChangeLog rpm_docs)
+cp -r patch rpm_docs
+
+%clean
+rm -fr $RPM_BUILD_ROOT
+
+%files
+%defattr(-, root, root)
+%{prefix}/bin/idnconv
+%{prefix}/bin/runidn
+%{prefix}/lib/libidnkit.so.*
+%{prefix}/lib/libidnkitlite.so.*
+%{prefix}/lib/libidnkitres.so.*
+%{prefix}/share/idnkit/*
+%config %{sysconfdir}/idn.conf
+%config %{sysconfdir}/idnalias.conf
+%attr(0644, root, root) %config(noreplace) 
+%attr(0644, root, man) %{prefix}/man/man1/*
+%attr(0644, root, man) %{prefix}/man/man3/*
+%attr(0644, root, man) %{prefix}/man/man5/*
+%doc rpm_docs/*
+
+%files devel
+%defattr(-, root, root)
+%{prefix}/lib/libidnkit.a
+%{prefix}/lib/libidnkit.la
+%{prefix}/lib/libidnkit.so
+%{prefix}/lib/libidnkitlite.a
+%{prefix}/lib/libidnkitlite.la
+%{prefix}/lib/libidnkitlite.so
+%{prefix}/lib/libidnkitres.a
+%{prefix}/lib/libidnkitres.la
+%{prefix}/lib/libidnkitres.so
+%{prefix}/include/idn/*
+
+%changelog
+* Web May 15 2002 Motoyuki Kasahara <m-kasahr@sra.co.jp>
+- 1.0beta2, experimental.
+
+* Mon May 28 2001 MANABE Takashi <manabe@dsl.gr.jp>
+- include runmdn, libmdnresolv
+
+* Mon Apr  4 2001 Motoyuki Kasahara <m-kasahr@sra.co.jp>
+- 2.1 release
+
+* Mon Apr  4 2001 Motoyuki Kasahara <m-kasahr@sra.co.jp>
+- 2.0.1 release
+
+* Mon Apr  2 2001 MANABE Takashi <manabe@dsl.gr.jp>
+- 2.0 release
+
+* Fri Mar  3 2001 MANABE Takashi <manabe@dsl.gr.jp>
+- 1.3 release
+
+* Mon Dec  6 2000 MANABE Takashi <manabe@dsl.gr.jp>
+- add brace/lace functions to libmdnresolv(mdnkit-1.2-runmdn.patch)
+- include /var/dnsproxy
+- change files section for compressed man pages
+
+* Mon Nov 27 2000 Makoto Ishisone <ishisone@sra.co.jp>
+- 1.2 release
+
+* Thu Nov  2 2000 MANABE Takashi <manabe@dsl.gr.jp>
+- 1.1 release
+
+* Fri Oct 27 2000 MANABE Takashi <manabe@dsl.gr.jp>
+- dnsproxy.patch1
+- move libmdnresolv.{la,so} from mdnkit-devel to mdnkit package
+
+* Wed Oct 18 2000 MANABE Takashi <manabe@dsl.gr.jp>
+- 1.0 release
diff --git a/contrib/idn/idnkit-1.0-src/tools/runidn/Makefile.in b/contrib/idn/idnkit-1.0-src/tools/runidn/Makefile.in
new file mode 100644 (file)
index 0000000..8e3875f
--- /dev/null
@@ -0,0 +1,167 @@
+# $Id: Makefile.in,v 1.1 2003/06/04 00:27:11 marka Exp $
+# 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.
+
+LIB_CURRENT = 1
+LIB_REVISION = 1
+LIB_AGE = 0
+
+.SUFFIXES:
+.SUFFIXES: .c .lo
+
+top_builddir = ../..
+subdir = tools/runidn
+
+srcdir = @srcdir@
+VPATH = @srcdir@
+
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+
+bindir = @bindir@
+libdir = @libdir@
+mandir = @mandir@
+man1dir = $(mandir)/man1
+
+CC      = @CC@
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_DATA = @INSTALL_DATA@
+MKINSTALLDIRS = @top_srcdir@/mkinstalldirs
+SHELL = @SHELL@
+LIBTOOL = @LIBTOOL@
+
+ICONVINC = @ICONVINC@
+ICONVLIB = @ICONVLIB@
+
+INCS    = -I$(srcdir) -I$(srcdir)/../../include -I../../include $(ICONVINC)
+DEFS    = 
+
+CFLAGS  = $(INCS) $(DEFS) @CPPFLAGS@ @CFLAGS@
+LDFLAGS = @LDFLAGS@
+
+LIB     = libidnkitres
+OBJS    = rtresolver.lo stub.lo  $(IDNOBJS)
+SCRIPT  = runidn
+LIBDL   = @LIBDL@
+
+IDNDIR  = ../../lib
+IDNOBJS  = \
+       $(IDNDIR)/aliaslist.lo \
+       $(IDNDIR)/api.lo \
+       $(IDNDIR)/checker.lo \
+       $(IDNDIR)/converter.lo \
+       $(IDNDIR)/debug.lo \
+       $(IDNDIR)/delimitermap.lo \
+       $(IDNDIR)/filechecker.lo \
+       $(IDNDIR)/filemapper.lo \
+       $(IDNDIR)/localencoding.lo \
+       $(IDNDIR)/log.lo \
+       $(IDNDIR)/mapper.lo \
+       $(IDNDIR)/mapselector.lo \
+       $(IDNDIR)/nameprep.lo \
+       $(IDNDIR)/normalizer.lo \
+       $(IDNDIR)/punycode.lo \
+       $(IDNDIR)/race.lo \
+       $(IDNDIR)/res.lo \
+       $(IDNDIR)/resconf.lo \
+       $(IDNDIR)/result.lo \
+       $(IDNDIR)/strhash.lo \
+       $(IDNDIR)/ucsmap.lo \
+       $(IDNDIR)/ucsset.lo \
+       $(IDNDIR)/unicode.lo \
+       $(IDNDIR)/unormalize.lo \
+       $(IDNDIR)/ucs4.lo \
+       $(IDNDIR)/utf8.lo \
+       $(IDNDIR)/util.lo \
+       $(IDNDIR)/version.lo
+
+.c.lo:
+       $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c $<
+
+@RUNIDN_TRUE@all: $(LIB).la runidn
+@RUNIDN_FALSE@all:
+
+rtresolver.lo: $(srcdir)/resolver.c
+       $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -DFOR_RUNIDN -o $@ \
+           -c $(srcdir)/resolver.c
+
+$(LIB).la: $(OBJS)
+       $(LIBTOOL) --mode=link $(LD) $(LDFLAGS) -o $@ \
+           -version-info $(LIB_CURRENT):$(LIB_REVISION):$(LIB_AGE) \
+           -module -rpath $(libdir) $(OBJS) $(LIBDL)
+
+runidn: $(srcdir)/runidn.in
+       cd $(top_builddir) && \
+           CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= CONFIG_LINKS= \
+           $(SHELL) ./config.status
+
+@RUNIDN_TRUE@@COMPAT_TRUE@install: all install-runidn install-compat
+@RUNIDN_TRUE@@COMPAT_FALSE@install: all install-runidn
+@RUNIDN_FALSE@install: 
+
+install-runidn:
+       $(MKINSTALLDIRS) $(DESTDIR)$(libdir)
+       $(LIBTOOL) --mode=install $(INSTALL_DATA) $(LIB).la \
+           $(DESTDIR)$(libdir)/$(LIB).la
+       $(MKINSTALLDIRS) $(DESTDIR)$(bindir)
+       $(INSTALL_SCRIPT) $(SCRIPT) $(DESTDIR)$(bindir)
+       $(MKINSTALLDIRS) $(DESTDIR)$(man1dir)
+       $(INSTALL_DATA) $(srcdir)/runidn.1 $(DESTDIR)$(man1dir)/runidn.1
+
+install-compat:
+       src=$(DESTDIR)$(bindir)/runidn; \
+       dst=$(DESTDIR)$(bindir)/runmdn; \
+       rm -f $$dst; \
+       ln $$src $$dst || cp $$src $$dst
+       src=$(DESTDIR)$(man1dir)/runidn.1; \
+       dst=$(DESTDIR)$(man1dir)/runmdn.1; \
+       rm -f $$dst; \
+       ln $$src $$dst || cp $$src $$dst
+
+clean:
+       rm -f *.lo *.la *.o
+       rm -fr .libs/
+
+distclean: clean
+       rm -f runidn Makefile
+
+test check:
diff --git a/contrib/idn/idnkit-1.0-src/tools/runidn/resolver.c b/contrib/idn/idnkit-1.0-src/tools/runidn/resolver.c
new file mode 100644 (file)
index 0000000..eaa9328
--- /dev/null
@@ -0,0 +1,1056 @@
+#ifndef lint
+static char *rcsid = "$Id: resolver.c,v 1.1 2003/06/04 00:27:12 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 <stdio.h>
+#include <stddef.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netdb.h>
+#include <errno.h>
+
+#include <idn/api.h>
+#include <idn/log.h>
+#include <idn/logmacro.h>
+#include <idn/debug.h>
+
+#ifdef FOR_RUNIDN
+/*
+ * This file is specially compiled for runidn.
+ * runidn replaces existing resolver functions dynamically with ones
+ * with IDN processing (encoding conversion and normalization).
+ * So entry names must be same as the system's one.
+ */
+#include "stub.h"
+
+#define ENTRY(name) name
+#define REAL(name) idn_stub_ ## name
+#else
+/*
+ * For normal use.  All the entry names are prefixed with "idn_resolver_".
+ * <idn/resolver.h> has bunch of #defines to substitute the standard
+ * name resolver functions with ones provided here.
+ */
+#include "resolver.h"
+#undef  gethostbyname
+#undef  gethostbyname2
+#undef  gethostbyaddr
+#undef  gethostbyname_r
+#undef  gethostbyname2_r
+#undef  gethostbyaddr_r
+#undef  getipnodebyname
+#undef  getipnodebyaddr
+#undef  getaddrinfo
+#undef  getnameinfo
+
+#define ENTRY(name) idn_resolver_ ## name
+#define REAL(name) name
+#endif
+
+#define IDN_NAME_SIZE          512
+
+#define IDN_HOSTBUF_SIZE       2048
+typedef union {
+       char *dummy_for_alignment;
+       char data[IDN_HOSTBUF_SIZE];
+} hostbuf_t;
+
+typedef struct obj_lock {
+       void *key;
+       struct obj_lock *next;
+} obj_lock_t;
+
+#define OBJLOCKHASH_SIZE       127
+static obj_lock_t *obj_lock_hash[OBJLOCKHASH_SIZE];
+
+/*
+ * This variable is to prevent IDN processing occuring more than once for
+ * a single name resolution.  This will happen if some resolver function
+ * is implemented using another function (e.g. gethostbyname() implemented
+ * using gethostbyname2()).
+ * No, using the static variable is not a correct thing to do for a multi-
+ * threading environment, but I don't think of a better solution..
+ */
+static int idn_isprocessing = 0;
+
+static int             obj_hash(void *key);
+static int             obj_islocked(void *key);
+static void            obj_lock(void *key);
+static void            obj_unlock(void *key);
+static struct hostent  *copy_decode_hostent_static(struct hostent *hp,
+                                                   struct hostent *newhp,
+                                                   char *buf, size_t buflen,
+                                                   int *errp);
+static char            *decode_name_dynamic(const char *name);
+static struct hostent  *copy_decode_hostent_dynamic(struct hostent *hp,
+                                                    int *errp);
+static void            free_copied_hostent(struct hostent *hp);
+#ifdef HAVE_GETADDRINFO
+static struct addrinfo *copy_decode_addrinfo_dynamic(struct addrinfo *aip);
+#endif
+#ifdef HAVE_FREEADDRINFO
+static void            free_copied_addrinfo(struct addrinfo *aip);
+#endif
+
+/*
+ * Object locking facility.
+ */
+
+static int
+obj_hash(void *key) {
+       /*
+        * Hash function for obj_*.
+        * 'key' is supposed to be an address.
+        */
+       unsigned long v = (unsigned long)key;
+
+       return ((v >> 3) % OBJLOCKHASH_SIZE);
+}
+
+static int
+obj_islocked(void *key)
+{
+       /*
+        * Check if the object specified by 'key' is locked.
+        * Return 1 if so, 0 otherwise.
+        */
+       int h = obj_hash(key);
+       obj_lock_t *olp = obj_lock_hash[h];
+
+       while (olp != NULL) {
+               if (olp->key == key)
+                       return (1);
+               olp = olp->next;
+       }
+       return (0);
+}
+
+static void
+obj_lock(void *key)
+{
+       /*
+        * Lock an object specified by 'key'.
+        */
+       int h = obj_hash(key);
+       obj_lock_t *olp;
+
+       olp = malloc(sizeof(obj_lock_t));
+       if (olp != NULL) {
+               olp->key = key;
+               olp->next = obj_lock_hash[h];
+               obj_lock_hash[h] = olp;
+       }
+}
+
+static void
+obj_unlock(void *key)
+{
+       /*
+        * Unlock an object specified by 'key'.
+        */
+       int h = obj_hash(key);
+       obj_lock_t *olp, *olp0;
+
+       olp = obj_lock_hash[h];
+       olp0 = NULL;
+       while (olp != NULL) {
+               if (olp->key == key) {
+                       if (olp0 == NULL)
+                               obj_lock_hash[h] = olp->next;
+                       else
+                               olp0->next = olp->next;
+                       free(olp);
+                       return;
+               }
+               olp0 = olp;
+               olp = olp->next;
+       }
+}
+
+static struct hostent *
+copy_decode_hostent_static(struct hostent *hp, struct hostent *newhp,
+                          char *buf, size_t buflen, int *errp)
+{
+       /*
+        * Copy "struct hostent" data referenced by 'hp' to 'newhp'.
+        * It's a deep-copy, meaning all the data referenced by 'hp' are
+        * also copied.  They are copied into 'buf', whose length is 'buflen'.
+        * The domain names ('hp->h_name' and 'hp->h_aliases') are
+        * decoded from ACE to the local encoding before they are copied.
+        * If 'buf' is too small to hold all the data, NULL will be
+        * returned and '*errp' is set to NO_RECOVERY.
+        */
+       int naliases = 0;
+       int naddrs = 0;
+
+       if (hp == NULL)
+               return (NULL);
+
+       *newhp = *hp;
+
+       if (hp->h_aliases != NULL) {
+               /*
+                * Allocate aliase table in 'buf'.
+                */
+               size_t sz;
+
+               while (hp->h_aliases[naliases] != NULL)
+                       naliases++;
+
+               newhp->h_aliases = (char **)buf;
+               sz = sizeof(char *) * (naliases + 1);
+
+               if (buflen < sz)
+                       goto overflow;
+
+               buf += sz;
+               buflen -= sz;
+       }
+
+       if (hp->h_addr_list != NULL) {
+               /*
+                * Allocate address table in 'buf'.
+                */
+               size_t sz;
+               int i;
+
+               while (hp->h_addr_list[naddrs] != NULL)
+                       naddrs++;
+
+               newhp->h_addr_list = (char **)buf;
+               sz = sizeof(char *) * (naddrs + 1);
+
+               if (buflen < sz)
+                       goto overflow;
+
+               buf += sz;
+               buflen -= sz;
+
+               /*
+                * Copy the addresses.
+                */
+               sz = hp->h_length * naddrs;
+               if (buflen < sz)
+                       goto overflow;
+
+               for (i = 0; i < naddrs; i++) {
+                       newhp->h_addr_list[i] = buf;
+                       memcpy(buf, hp->h_addr_list[i], hp->h_length);
+                       buf += hp->h_length;
+               }
+               newhp->h_addr_list[naddrs] = NULL;
+
+               buf += sz;
+               buflen -= sz;
+       }
+
+       if (hp->h_name != NULL) {
+               /*
+                * Decode the name in h_name.
+                */
+               idn_result_t r;
+               size_t slen;
+
+               idn_enable(1);
+               idn_nameinit(1);
+               r = idn_decodename(IDN_DECODE_APP, hp->h_name,
+                                  buf, buflen);
+               switch (r) {
+               case idn_success:
+                       newhp->h_name = buf;
+                       break;
+               default:
+                       /* Copy hp->h_name verbatim. */
+                       if (strlen(hp->h_name) + 1 <= buflen) {
+                               newhp->h_name = buf;
+                               strcpy(buf, hp->h_name);
+                               break;
+                       }
+                       /* falllthrough */
+               case idn_buffer_overflow:
+                       goto overflow;
+               }
+
+               slen = strlen(buf) + 1;
+               buf += slen;
+               buflen -= slen;
+       }
+
+       if (hp->h_aliases != NULL) {
+               /*
+                * Decode the names in h_aliases.
+                */
+               char **aliases = hp->h_aliases;
+               char **newaliases = newhp->h_aliases;
+               int i;
+
+               for (i = 0; i < naliases; i++) {
+                       idn_result_t r;
+                       size_t slen;
+
+                       idn_enable(1);
+                       idn_nameinit(1);
+                       r = idn_decodename(IDN_DECODE_APP, aliases[i],
+                                          buf, buflen);
+
+                       switch (r) {
+                       case idn_success:
+                               newaliases[i] = buf;
+                               break;
+                       default:
+                               /* Copy hp->h_name verbatim. */
+                               if (strlen(aliases[i]) + 1 <= buflen) {
+                                       newaliases[i] = buf;
+                                       strcpy(buf, aliases[i]);
+                                       break;
+                               }
+                               /* falllthrough */
+                       case idn_buffer_overflow:
+                               goto overflow;
+                       }
+
+                       slen = strlen(buf) + 1;
+                       buf += slen;
+                       buflen -= slen;
+               }
+               newaliases[naliases] = NULL;
+       }
+
+       return (newhp);
+
+ overflow:
+       *errp = NO_RECOVERY;
+       return (NULL);
+}
+
+static char *
+decode_name_dynamic(const char *name) {
+       idn_result_t r;
+       char buf[IDN_NAME_SIZE];
+       char *s;
+
+       idn_enable(1);
+       idn_nameinit(1);
+       r = idn_decodename(IDN_DECODE_APP, name, buf, sizeof(buf));
+       if (r == idn_success) {
+               name = buf;
+       }
+       s = malloc(strlen(name) + 1);
+       if (s == NULL)
+               return (NULL);
+       else
+               return (strcpy(s, name));
+}
+               
+static struct hostent *
+copy_decode_hostent_dynamic(struct hostent *hp, int *errp) {
+       /*
+        * Make a deep-copy of the data referenced by 'hp', and return
+        * a pointer to the copied data.
+        * All the data are dynamically allocated using malloc().
+        * The domain names ('hp->h_name' and 'hp->h_aliases') are
+        * decoded from ACE to the local encoding before they are copied.
+        * If malloc() fails, NULL will be returned and '*errp' is set to
+        * NO_RECOVERY.
+        */
+       struct hostent *newhp;
+       char **pp;
+       size_t alloc_size;
+       int naliases = 0;
+       int naddrs = 0;
+       int i;
+
+       if (hp == NULL)
+               return (NULL);
+
+       if (hp->h_aliases != NULL) {
+               while (hp->h_aliases[naliases] != NULL)
+                       naliases++;
+       }
+
+       if (hp->h_addr_list != NULL) {
+               while (hp->h_addr_list[naddrs] != NULL)
+                       naddrs++;
+       }
+
+       alloc_size = sizeof(struct hostent) +
+               sizeof(char *) * (naliases + 1) +
+               sizeof(char *) * (naddrs + 1) +
+               hp->h_length * naddrs;
+
+       if ((newhp = malloc(alloc_size)) == NULL) {
+               return (hp);
+       }
+
+       memset(newhp, 0, alloc_size);
+
+       pp = (char **)(newhp + 1);
+
+       if (hp->h_name != NULL) {
+               newhp->h_name = decode_name_dynamic(hp->h_name);
+               if (newhp->h_name == NULL)
+                       goto alloc_fail;
+       }
+
+       newhp->h_addrtype = hp->h_addrtype;
+       newhp->h_length = hp->h_length;
+
+       if (hp->h_aliases != NULL) {
+               newhp->h_aliases = pp;
+               for (i = 0; i < naliases; i++) {
+                       newhp->h_aliases[i] =
+                               decode_name_dynamic(hp->h_aliases[i]);
+                       if (newhp->h_aliases[i] == NULL)
+                               goto alloc_fail;
+               }
+               newhp->h_aliases[naliases] = NULL;
+               pp += naliases + 1;
+       }
+
+       if (hp->h_addr_list != NULL) {
+               char *p;
+
+               newhp->h_addr_list = pp;
+               pp += naddrs + 1;
+               p = (char *)pp;
+
+               for (i = 0; i < naddrs; i++) {
+                       newhp->h_addr_list[i] = p;
+                       memcpy(p, hp->h_addr_list[i], hp->h_length);
+                       p += hp->h_length;
+               }
+               newhp->h_addr_list[naddrs] = NULL;
+       }
+
+       return (newhp);
+
+ alloc_fail:
+       free_copied_hostent(hp);
+       *errp = NO_RECOVERY;
+       return (NULL);
+}
+
+static void
+free_copied_hostent(struct hostent *hp) {
+       /*
+        * Free all the memory allocated by copy_decode_hostent_dynamic().
+        */
+       if (hp->h_name != NULL)
+               free(hp->h_name);
+       if (hp->h_aliases != NULL) {
+               char **pp = hp->h_aliases;
+               while (*pp != NULL)
+                       free(*pp++);
+       }
+       free(hp);
+}
+
+#ifdef HAVE_GETNAMEINFO
+static struct addrinfo *
+copy_decode_addrinfo_dynamic(struct addrinfo *aip) {
+       struct addrinfo *newaip;
+
+       if (aip == NULL)
+               return (NULL);
+
+       newaip = malloc(sizeof(struct addrinfo) + aip->ai_addrlen);
+       if (newaip == NULL)
+               return (NULL);
+
+       *newaip = *aip;
+       newaip->ai_addr = (struct sockaddr *)(newaip + 1);
+       memcpy(newaip->ai_addr, aip->ai_addr, aip->ai_addrlen);
+
+       if (newaip->ai_canonname != NULL)
+               newaip->ai_canonname = decode_name_dynamic(aip->ai_canonname);
+
+       newaip->ai_next = copy_decode_addrinfo_dynamic(aip->ai_next);
+       return (newaip);
+}
+#endif
+
+#ifdef HAVE_FREEADDRINFO
+static void
+free_copied_addrinfo(struct addrinfo *aip) {
+       while (aip != NULL) {
+               struct addrinfo *next = aip->ai_next;
+
+               if (aip->ai_canonname != NULL)
+                       free(aip->ai_canonname);
+               free(aip);
+               aip = next;
+       }
+}
+#endif
+
+#ifdef HAVE_GETHOSTBYNAME
+struct hostent *
+ENTRY(gethostbyname)(const char *name) {
+       static hostbuf_t buf;
+       static struct hostent he;
+       idn_result_t r;
+       struct hostent *hp;
+
+       if (idn_isprocessing)
+               return (REAL(gethostbyname)(name));
+
+       TRACE(("gethostbyname(name=%s)\n", idn__debug_xstring(name, 60)));
+
+       idn_isprocessing = 1;
+       idn_enable(1);
+       idn_nameinit(1);
+       r = idn_encodename(IDN_ENCODE_APP, name, buf.data, sizeof(buf));
+       if (r == idn_success)
+               name = buf.data;
+
+       hp = copy_decode_hostent_static(REAL(gethostbyname)(name),
+                                       &he, buf.data, sizeof(buf),
+                                       &h_errno);
+       idn_isprocessing = 0;
+       return (hp);
+}
+#endif
+
+#ifdef HAVE_GETHOSTBYNAME2
+struct hostent *
+ENTRY(gethostbyname2)(const char *name, int af) {
+       static hostbuf_t buf;
+       static struct hostent he;
+       idn_result_t r;
+       struct hostent *hp;
+
+       if (idn_isprocessing)
+               return (REAL(gethostbyname2)(name, af));
+
+       TRACE(("gethostbyname2(name=%s)\n", idn__debug_xstring(name, 60), af));
+
+       idn_isprocessing = 1;
+       idn_enable(1);
+       idn_nameinit(1);
+       r = idn_encodename(IDN_ENCODE_APP, name, buf.data, sizeof(buf));
+       if (r == idn_success)
+               name = buf.data;
+
+       hp = copy_decode_hostent_static(REAL(gethostbyname2)(name, af),
+                                       &he, buf.data, sizeof(buf),
+                                       &h_errno);
+       idn_isprocessing = 0;
+       return (hp);
+}
+#endif
+
+#ifdef HAVE_GETHOSTBYADDR
+struct hostent *
+ENTRY(gethostbyaddr)(GHBA_ADDR_T addr, GHBA_ADDRLEN_T len, int type) {
+       static hostbuf_t buf;
+       static struct hostent he;
+       struct hostent *hp;
+
+       if (idn_isprocessing)
+               return (REAL(gethostbyaddr)(addr, len, type));
+
+       TRACE(("gethostbyaddr()\n"));
+
+       idn_isprocessing = 1;
+       hp = copy_decode_hostent_static(REAL(gethostbyaddr)(addr, len, type),
+                                       &he, buf.data, sizeof(buf),
+                                       &h_errno);
+       idn_isprocessing = 0;
+       return (hp);
+}
+#endif
+
+#ifdef GETHOST_R_GLIBC_FLAVOR
+
+#ifdef HAVE_GETHOSTBYNAME_R
+int
+ENTRY(gethostbyname_r)(const char *name, struct hostent *result,
+                      char *buffer, size_t buflen,
+                      struct hostent **rp, int *errp)
+{
+       char namebuf[IDN_NAME_SIZE];
+       char *data;
+       size_t datalen;
+       idn_result_t r;
+       struct hostent he;
+       hostbuf_t buf;
+       int n;
+
+       if (idn_isprocessing)
+               return (REAL(gethostbyname_r)(name, result, buffer,
+                                             buflen, rp, errp));
+
+       TRACE(("gethostbyname_r(name=%s,buflen=%d)\n",
+              idn__debug_xstring(name, 60), buflen));
+
+       if (buflen <= sizeof(buf)) {
+               data = buf.data;
+               datalen = sizeof(buf);
+       } else {
+               data = malloc(buflen);
+               datalen = buflen;
+               if (data == NULL) {
+                       *errp = NO_RECOVERY;
+                       return (ENOMEM);
+               }
+       }
+
+       idn_isprocessing = 1;
+       idn_enable(1);
+       idn_nameinit(1);
+       r = idn_encodename(IDN_ENCODE_APP, name, namebuf, sizeof(namebuf));
+       if (r == idn_success)
+               name = namebuf;
+
+       *errp = 0;
+       n = REAL(gethostbyname_r)(name, &he, data, datalen, rp, errp);
+
+       if (n == 0 && *rp != NULL)
+               *rp = copy_decode_hostent_static(*rp, result, buffer, buflen,
+                                                errp);
+       idn_isprocessing = 0;
+
+       if (data != buf.data)
+               free(data);
+
+       if (*errp != 0)
+               n = EINVAL;     /* XXX */
+
+       return (n);
+}
+#endif
+
+#ifdef HAVE_GETHOSTBYNAME2_R
+int
+ENTRY(gethostbyname2_r)(const char *name, int af, struct hostent *result,
+                       char *buffer, size_t buflen,
+                       struct hostent **rp, int *errp)
+{
+       char namebuf[IDN_NAME_SIZE];
+       char *data;
+       size_t datalen;
+       idn_result_t r;
+       struct hostent he;
+       hostbuf_t buf;
+       int n;
+
+       if (idn_isprocessing)
+               return (REAL(gethostbyname2_r)(name, af, result, buffer,
+                                              buflen, rp, errp));
+
+       TRACE(("gethostbyname2_r(name=%s,buflen=%d)\n",
+              idn__debug_xstring(name, 60), buflen));
+
+       if (buflen <= sizeof(buf)) {
+               data = buf.data;
+               datalen = sizeof(buf);
+       } else {
+               data = malloc(buflen);
+               datalen = buflen;
+               if (data == NULL) {
+                       *errp = NO_RECOVERY;
+                       return (ENOMEM);
+               }
+       }
+
+       idn_isprocessing = 1;
+       idn_enable(1);
+       idn_nameinit(1);
+       r = idn_encodename(IDN_ENCODE_APP, name, namebuf, sizeof(namebuf));
+       if (r == idn_success)
+               name = namebuf;
+
+       n = REAL(gethostbyname2_r)(name, af, &he, data, datalen, rp, errp);
+
+       if (n == 0 && *rp != NULL)
+               *rp = copy_decode_hostent_static(*rp, result, buffer, buflen,
+                                                errp);
+       idn_isprocessing = 0;
+
+       if (data != buf.data)
+               free(data);
+
+       if (*errp != 0)
+               n = EINVAL;     /* XXX */
+
+       return (n);
+}
+#endif
+
+#ifdef HAVE_GETHOSTBYADDR_R
+int
+ENTRY(gethostbyaddr_r)(GHBA_ADDR_T addr, GHBA_ADDRLEN_T len, int type,
+                      struct hostent *result,
+                      char *buffer, size_t buflen,
+                      struct hostent **rp, int *errp)
+{
+       char *data;
+       size_t datalen;
+       struct hostent he;
+       hostbuf_t buf;
+       int n;
+
+       if (idn_isprocessing) {
+               return (REAL(gethostbyaddr_r)(addr, len, type, result,
+                                             buffer, buflen, rp, errp));
+       }
+
+       TRACE(("gethostbyaddr_r(buflen=%d)\n", buflen));
+
+       if (buflen <= sizeof(buf)) {
+               data = buf.data;
+               datalen = sizeof(buf);
+       } else {
+               data = malloc(buflen);
+               datalen = buflen;
+               if (data == NULL) {
+                       *errp = NO_RECOVERY;
+                       return (ENOMEM);
+               }
+       }
+
+       idn_isprocessing = 1;
+       n = REAL(gethostbyaddr_r)(addr, len, type, &he,
+                                  data, datalen, rp, errp);
+
+       if (n == 0 && *rp != NULL)
+               *rp = copy_decode_hostent_static(*rp, result, buffer, buflen,
+                                                errp);
+       idn_isprocessing = 0;
+
+       if (data != buf.data)
+               free(data);
+
+       if (*errp != 0)
+               n = EINVAL;     /* XXX */
+
+       return (0);
+}
+#endif
+
+#else /* GETHOST_R_GLIBC_FLAVOR */
+
+#ifdef HAVE_GETHOSTBYNAME_R
+struct hostent *
+ENTRY(gethostbyname_r)(const char *name, struct hostent *result,
+                      char *buffer, int buflen, int *errp)
+{
+       char namebuf[IDN_NAME_SIZE];
+       char *data;
+       size_t datalen;
+       idn_result_t r;
+       struct hostent *hp, he;
+       hostbuf_t buf;
+
+       if (idn_isprocessing)
+               return (REAL(gethostbyname_r)(name, result, buffer,
+                                             buflen, errp));
+
+       TRACE(("gethostbyname_r(name=%s,buflen=%d)\n",
+              idn__debug_xstring(name, 60), buflen));
+
+       if (buflen <= sizeof(buf)) {
+               data = buf.data;
+               datalen = sizeof(buf);
+       } else {
+               data = malloc(buflen);
+               datalen = buflen;
+               if (data == NULL) {
+                       *errp = NO_RECOVERY;
+                       return (NULL);
+               }
+       }
+
+       idn_isprocessing = 1;
+       idn_enable(1);
+       idn_nameinit(1);
+       r = idn_encodename(IDN_ENCODE_APP, name, namebuf, sizeof(namebuf));
+       if (r == idn_success)
+               name = namebuf;
+
+       hp = REAL(gethostbyname_r)(name, &he, data, datalen, errp);
+
+       if (hp != NULL)
+               hp = copy_decode_hostent_static(hp, result, buffer, buflen,
+                                               errp);
+       idn_isprocessing = 0;
+
+       if (data != buf.data)
+               free(data);
+
+       return (hp);
+}
+#endif
+
+#ifdef HAVE_GETHOSTBYADDR_R
+struct hostent *
+ENTRY(gethostbyaddr_r)(GHBA_ADDR_T addr, GHBA_ADDRLEN_T len, int type,
+                      struct hostent *result,
+                      char *buffer, int buflen, int *errp)
+{
+       char *data;
+       size_t datalen;
+       struct hostent *hp, he;
+       hostbuf_t buf;
+
+       if (idn_isprocessing) {
+               return (REAL(gethostbyaddr_r)(addr, len, type, result,
+                                             buffer, buflen, errp));
+       }
+
+       TRACE(("gethostbyaddr_r(buflen=%d)\n", buflen));
+
+       if (buflen <= sizeof(buf)) {
+               data = buf.data;
+               datalen = sizeof(buf);
+       } else {
+               data = malloc(buflen);
+               datalen = buflen;
+               if (data == NULL) {
+                       *errp = NO_RECOVERY;
+                       return (NULL);
+               }
+       }
+
+       idn_isprocessing = 1;
+       hp = REAL(gethostbyaddr_r)(addr, len, type, &he, data, datalen, errp);
+
+       if (hp != NULL)
+               hp = copy_decode_hostent_static(hp, result, buffer, buflen,
+                                               errp);
+       idn_isprocessing = 0;
+
+       if (data != buf.data)
+               free(data);
+
+       return (hp);
+}
+#endif
+
+#endif /* GETHOST_R_GLIBC_FLAVOR */
+
+#ifdef HAVE_GETIPNODEBYNAME
+struct hostent *
+ENTRY(getipnodebyname)(const char *name, int af, int flags, int *errp) {
+       char namebuf[IDN_NAME_SIZE];
+       idn_result_t r;
+       struct hostent *hp;
+
+       if (idn_isprocessing)
+               return (REAL(getipnodebyname)(name, af, flags, errp));
+
+       TRACE(("getipnodebyname(name=%s)\n", idn__debug_xstring(name, 60), af));
+
+       idn_isprocessing = 1;
+       idn_enable(1);
+       idn_nameinit(1);
+       r = idn_encodename(IDN_ENCODE_APP, name, namebuf, sizeof(namebuf));
+       if (r == idn_success)
+               name = namebuf;
+
+       hp = REAL(getipnodebyname)(name, af, flags, errp);
+       if (hp != NULL) {
+               struct hostent *newhp = copy_decode_hostent_dynamic(hp, errp);
+               if (newhp != hp) {
+                       REAL(freehostent)(hp);
+                       obj_lock(newhp);
+                       hp = newhp;
+               }
+       }
+       idn_isprocessing = 0;
+       return (hp);
+}
+#endif
+
+#ifdef HAVE_GETIPNODEBYADDR
+struct hostent *
+ENTRY(getipnodebyaddr)(const void *src, size_t len, int af, int *errp) {
+       struct hostent *hp;
+
+       if (idn_isprocessing)
+               return (REAL(getipnodebyaddr)(src, len, af, errp));
+
+       TRACE(("getipnodebyaddr()\n"));
+
+       idn_isprocessing = 1;
+       hp = REAL(getipnodebyaddr)(src, len, af, errp);
+       if (hp != NULL) {
+               struct hostent *newhp = copy_decode_hostent_dynamic(hp, errp);
+               if (newhp != hp) {
+                       REAL(freehostent)(hp);
+                       obj_lock(newhp);
+                       hp = newhp;
+               }
+       }
+       idn_isprocessing = 0;
+       return (hp);
+}
+#endif
+
+#ifdef HAVE_FREEHOSTENT
+void
+ENTRY(freehostent)(struct hostent *hp) {
+       TRACE(("freehostent(hp=%p)\n", (void *)hp));
+
+       if (obj_islocked(hp)) {
+               /*
+                * We allocated the data.
+                */
+               obj_unlock(hp);
+               free_copied_hostent(hp);
+       } else {
+               /*
+                * It was allocated the original getipnodeby*().
+                */
+               REAL(freehostent)(hp);
+       }
+}
+#endif
+
+#ifdef HAVE_GETADDRINFO
+int
+ENTRY(getaddrinfo)(const char *nodename, const char *servname,
+                  const struct addrinfo *hints, struct addrinfo **res)
+{
+       char namebuf[IDN_NAME_SIZE];
+       idn_result_t r;
+       struct addrinfo *aip;
+       int err;
+
+       if (nodename == NULL || idn_isprocessing)
+               return (REAL(getaddrinfo)(nodename, servname, hints, res));
+
+       TRACE(("getaddrinfo(nodename=%s)\n", idn__debug_xstring(nodename, 60)));
+
+       idn_isprocessing = 1;
+       idn_enable(1);
+       idn_nameinit(1);
+       r = idn_encodename(IDN_ENCODE_APP, nodename,
+                          namebuf, sizeof(namebuf));
+       if (r == idn_success)
+               nodename = namebuf;
+
+       err = REAL(getaddrinfo)(nodename, servname, hints, &aip);
+       if (err == 0 && aip != NULL) {
+               *res = copy_decode_addrinfo_dynamic(aip);
+               if (*res == NULL)
+                       err = EAI_FAIL;
+               else 
+                       obj_lock(*res);
+               if (aip != NULL)
+                       REAL(freeaddrinfo)(aip);
+       }
+       idn_isprocessing = 0;
+       return (err);
+}
+#endif
+
+#ifdef HAVE_FREEADDRINFO
+void
+ENTRY(freeaddrinfo)(struct addrinfo *aip) {
+       TRACE(("freeaddrinfo(aip=%p)\n", (void *)aip));
+
+       if (obj_islocked(aip)) {
+               /*
+                * We allocated the data.
+                */
+               obj_unlock(aip);
+               free_copied_addrinfo(aip);
+       } else {
+               /*
+                * It was allocated the original getaddrinfo().
+                */
+               REAL(freeaddrinfo)(aip);
+       }
+}
+#endif
+
+#ifdef HAVE_GETNAMEINFO
+int
+ENTRY(getnameinfo)(const struct sockaddr *sa, GNI_SALEN_T salen,
+                  char *host, GNI_HOSTLEN_T hostlen, char *serv,
+                  GNI_SERVLEN_T servlen, GNI_FLAGS_T flags)
+{
+       char name[IDN_NAME_SIZE];
+       size_t namelen = sizeof(name);
+       int code;
+       idn_result_t r;
+
+       if (host == NULL || hostlen == 0 || idn_isprocessing) {
+               return (REAL(getnameinfo)(sa, salen, host, hostlen,
+                                         serv, servlen, flags));
+       }
+
+       TRACE(("getnameinfo(hostlen=%u)\n", hostlen));
+
+       idn_isprocessing = 1;
+       code = REAL(getnameinfo)(sa, salen, name, namelen,
+                                serv, servlen, flags);
+       if (code == 0 && name[0] != '\0') {
+               idn_enable(1);
+               idn_nameinit(1);
+               r = idn_decodename(IDN_DECODE_APP, name, host, hostlen);
+               switch (r) {
+               case idn_success:
+                       code = 0;
+                       break;
+               case idn_buffer_overflow:
+               case idn_nomemory:
+                       code = EAI_MEMORY;
+                       break;
+               default:
+                       code = EAI_FAIL;
+                       break;
+               }
+       }
+       idn_isprocessing = 0;
+       return (code);
+}
+#endif
diff --git a/contrib/idn/idnkit-1.0-src/tools/runidn/resolver.h b/contrib/idn/idnkit-1.0-src/tools/runidn/resolver.h
new file mode 100644 (file)
index 0000000..c11dab1
--- /dev/null
@@ -0,0 +1,70 @@
+/* $Id: resolver.h,v 1.1 2003/06/04 00:27:13 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.
+ */
+
+#ifndef RESOLVER_H
+#define RESOLVER_H 1
+
+#undef  gethostbyname
+#define gethostbyname  idn_resolver_gethostbyname
+#undef  gethostbyname2
+#define gethostbyname2 idn_resolver_gethostbyname2
+#undef  gethostbyname_r
+#define gethostbyname_r        idn_resolver_gethostbyname_r
+#undef  gethostbyaddr
+#define gethostbyaddr  idn_resolver_gethostbyaddr
+#undef  gethostbyaddr
+#define gethostbyaddr_r        idn_resolver_gethostbyaddr_r
+#undef  getipnodebyname
+#define getipnodebyname        idn_resolver_getipnodebyname
+#undef  getipnodebyaddr
+#define getipnodebyaddr        idn_resolver_getipnodebyaddr
+#undef  freehostent
+#define freehostent    idn_resolver_freehostent
+#undef  getaddrinfo
+#define getaddrinfo    idn_resolver_getaddrinfo
+#undef  freeaddrinfo
+#define freeaddrinfo   idn_resolver_freeaddrinfo
+#undef  getnameinfo
+#define getnameinfo    idn_resolver_getnameinfo
+
+#endif /* RESOLVER_H */
diff --git a/contrib/idn/idnkit-1.0-src/tools/runidn/runidn.1 b/contrib/idn/idnkit-1.0-src/tools/runidn/runidn.1
new file mode 100644 (file)
index 0000000..244e611
--- /dev/null
@@ -0,0 +1,151 @@
+.\" $Id: runidn.1,v 1.1 2003/06/04 00:27:14 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.
+.\"
+.TH RUNIDN 1 "April 6, 2001"
+.\"
+.SH NAME
+runidn \- A script to allow applications to use internationalized domain names.
+.\"
+.SH SYNOPSIS
+\fBrunidn\fP [\fB-e\fP \fIlocal-codeset\fP] \fIprogram-name\fP [\fIargs..\fP]
+.\"
+.SH DESCRIPTION
+\fBrunidn\fP enables applications to use internationalized domain names
+without recompilation.
+Just add ``runidn'' before the application-name, and the application
+can handle non-ASCII domain names.  For example, you can do:
+.PP
+.RS 4
+.nf
+\f(CW% runidn telnet \fInon-ASCII-hostname\fR
+.fi
+.RE
+.PP
+Before using runidn, you should set up properties related to
+internationalized DNS by configuring idnkit's configuration file
+\fBidn.conf\fP.
+See idn.conf(5) which describes the configuration.
+.\"
+.SH OPTION
+The following option is available:
+.TP 4
+\fB\-e\fP \fIlocal-codeset\fP
+Specify the application's local codeset.
+If the option is not specified, \fBrunidn\fR guesses the codeset
+from the current locale.
+See the ``NOTE'' section for more details about local codeset.
+.\"
+.SH IMPLEMENTATION
+\fBrunidn\fR is a small shell script that sets up an environment variable
+called ``LD_PRELOAD'', so that an application dynamically links a shared
+library ``libidnkitres'' before any other shared libraries.
+.PP
+The library ``libidnkitres'' provides a special version of resolver
+functions which implement features for handling internationalized
+domain names.
+\fBrunidn\fR replaces the following functions with the special version:
+.PP
+.RS 4
+.nf
+.ft CW
+gethostbyname
+gethostbyname2
+gethostbyaddr
+gethostbyname_r
+gethostbyname2_r
+gethostbyaddr_r
+getipnodebyname
+getipnodebyaddr
+freehostent
+getaddrinfo
+freeaddrinfo
+getnameinfo
+.ft R
+.fi
+.RE
+.PP
+By overriding them in the standard libraries with the special version
+provided by ``libidnkitres'',
+\fBrunidn\fR enables applications to use internationalized domain names.
+.RS 4
+.IP \(bu 2
+These API functions accept non-ASCII domain names encoded
+in the local codeset that the application is using.
+Also the result from these APIs may contain non-ASCII domain names.
+.IP \(bu 2
+The normalization and codeset conversion between application's local
+codeset and the codeset used in DNS protocol data are handled
+automatically, so users/applications need not worry about them.
+.RE
+.PP
+Properties of internationalized DNS (such as the normalization or
+the codeset used on DNS protocol data) can be configured with the
+idnkit's configuration file (\fBidn.conf\fR).
+See idn.conf(5) for details.
+.\"
+.SH NOTE
+Unless \fB\-e\fP option is specified, \fBrunidn\fR tries to guess
+the application's local codeset from the application's current locale.
+However, sometimes it cannot guess the codeset correctly, for example
+if the application does not set the locale appropriately by calling
+`setlocale()'.
+In that case, you can explicitly specify the local codeset by setting an
+environment variable ``IDN_LOCAL_CODESET''.
+See the section ``LOCAL CODESET'' in idn.conf(5) for details.
+.PP
+The idea of using ``LD_PRELOAD'' to replace some functions in the standard
+library was taken from ``runsocks'' script distributed as part of SOCKS5
+reference implementation.
+.SH BUGS
+There are many cases where \fBrunidn\fR does not work.
+.PP
+Your system must support ``LD_PRELOAD'' mechanism in the first place.
+.PP
+Due to security reasons, ``LD_PRELOAD'' mechanism is disabled for
+setuid programs in any sane systems.
+So \fBrunidn\fR does not work for setuid programs such as ping or rsh.
+.PP
+If your application uses a function other than the ones runidn supports for
+name resolution, you lose.
+.SH "SEE ALSO"
+idn.conf(5), runsocks(1)
diff --git a/contrib/idn/idnkit-1.0-src/tools/runidn/runidn.in b/contrib/idn/idnkit-1.0-src/tools/runidn/runidn.in
new file mode 100644 (file)
index 0000000..3ee6d87
--- /dev/null
@@ -0,0 +1,109 @@
+#! /bin/sh
+# $Id: runidn.in,v 1.1 2003/06/04 00:27:14 marka Exp $
+#
+# 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.
+
+# Parse command line options.
+usage="Usage: `basename $0` [-e local-encoding] command [argument..]"
+while test $# -gt 0; do
+    case "$1" in
+    -e)
+       if test $# -le 1; then
+           echo $usage 1>&2
+           exit 1
+       fi
+       IDN_LOCAL_CODESET="$2"
+       export IDN_LOCAL_CODESET
+       shift
+       ;;
+    -)
+       break
+       ;;
+    -*)
+       echo $usage 1>&2
+       exit 1
+       ;;
+    *)
+       break
+       ;;
+    esac
+    shift
+done
+if test $# -eq 0; then
+    echo $usage 1>&2
+    exit 1
+fi
+
+# Load library info.
+preload=
+iconv_file=@ICONVSOFILE@
+if test "$iconv_file" != none; then
+    preload="$iconv_file@PRELOAD_SEP@"
+fi
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=`echo @libdir@`
+if test ! -f $libdir/libidnkitres.la; then
+    cat <<EOF 1>&2
+Have you installed idnkit?  I cannot find libidnkitres.la.
+EOF
+    exit 1
+fi
+eval `grep '^dlname' $libdir/libidnkitres.la`
+if test "$dlname" = ""; then
+    cat <<EOF 1>&2
+Sorry, runidn won't work because libidnkitres is not dynamically loadable.
+EOF
+    exit 1
+fi
+preload=$preload$libdir/$dlname
+
+# Set @PRELOAD_VAR@.
+if [ X$@PRELOAD_VAR@ = X ]; then
+    @PRELOAD_VAR@="$preload@PRELOAD_LAST@"
+else
+    @PRELOAD_VAR@="$preload@PRELOAD_SEP@$@PRELOAD_VAR@@PRELOAD_LAST@"
+fi
+export @PRELOAD_VAR@
+
+# Shoot.
+exec "$@"
diff --git a/contrib/idn/idnkit-1.0-src/tools/runidn/stub.c b/contrib/idn/idnkit-1.0-src/tools/runidn/stub.c
new file mode 100644 (file)
index 0000000..b5e203c
--- /dev/null
@@ -0,0 +1,387 @@
+#ifndef lint
+static char *rcsid = "$Id: stub.c,v 1.1 2003/06/04 00:27:13 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 <stdarg.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netdb.h>
+#include <errno.h>
+#ifdef HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#include <idn/logmacro.h>
+#include <idn/debug.h>
+
+#include "stub.h"
+
+#ifndef RTLD_NEXT
+typedef struct {
+       const char *name;
+       void *handle;
+} shared_obj_t;
+
+static shared_obj_t shobj[] = {
+#ifdef SOPATH_LIBC
+       { SOPATH_LIBC },
+#endif
+#ifdef SOPATH_LIBNSL
+       { SOPATH_LIBNSL },
+#endif
+       { NULL },
+};
+#endif
+
+static void    *shared_obj_findsym(void *handle, const char *name);
+static void    *shared_obj_findsymx(void *handle, const char *name);
+static void    *get_func_addr(const char *name);
+
+#ifndef RTLD_NEXT
+static void *
+shared_obj_open(const char *path) {
+#ifdef HAVE_DLOPEN
+       return (dlopen(path, RTLD_LAZY));
+#endif
+       FATAL(("stub: no way to load shared object file\n"));
+       return (NULL);
+}
+#endif
+
+static void *
+shared_obj_findsym(void *handle, const char *name) {
+       char namebuf[100];
+       void *addr;
+       static int need_leading_underscore = -1;
+
+       /* Prepend underscore. */
+       namebuf[0] = '_';
+       (void)strcpy(namebuf + 1, name);
+       name = namebuf;
+
+       if (need_leading_underscore < 0) {
+               /* First try without one. */
+               if ((addr = shared_obj_findsymx(handle, name + 1)) != NULL) {
+                       need_leading_underscore = 0;
+                       return (addr);
+               }
+               /* Then try with one. */
+               if ((addr = shared_obj_findsymx(handle, name)) != NULL) {
+                       need_leading_underscore = 1;
+                       return (addr);
+               }
+       } else if (need_leading_underscore) {
+               return (shared_obj_findsymx(handle, name));
+       } else {
+               return (shared_obj_findsymx(handle, name + 1));
+       }
+       return (NULL);
+}
+               
+static void *
+shared_obj_findsymx(void *handle, const char *name) {
+#ifdef HAVE_DLSYM
+       return (dlsym(handle, name));
+#endif
+       /* logging */
+       FATAL(("stub: no way to get symbol address\n"));
+       return (NULL);
+}
+
+static void *
+get_func_addr(const char *name) {
+#ifdef RTLD_NEXT
+       void *addr = shared_obj_findsym(RTLD_NEXT, name);
+
+       if (addr != NULL) {
+               TRACE(("stub: %s found in the subsequent objects\n", name));
+               return (addr);
+       }
+#else
+       int i;
+
+       for (i = 0; shobj[i].name != NULL; i++) {
+               if (shobj[i].handle == NULL) {
+                       TRACE(("stub: loading %s\n", shobj[i].name));
+                       shobj[i].handle = shared_obj_open(shobj[i].name);
+               }
+               if (shobj[i].handle != NULL) {
+                       void *addr = shared_obj_findsym(shobj[i].handle, name);
+                       if (addr != NULL) {
+                               TRACE(("stub: %s found in %s\n",
+                                      name, shobj[i].name));
+                               return (addr);
+                       }
+               }
+       }
+#endif
+       TRACE(("stub: %s not found\n", name));
+       return (NULL);
+}
+
+#ifdef HAVE_GETHOSTBYNAME
+struct hostent *
+idn_stub_gethostbyname(const char *name) {
+       static struct hostent *(*fp)(const char *name);
+
+       if (fp == NULL)
+               fp = get_func_addr("gethostbyname");
+       if (fp != NULL)
+               return ((*fp)(name));
+       return (NULL);
+}
+#endif
+
+#ifdef HAVE_GETHOSTBYNAME2
+struct hostent *
+idn_stub_gethostbyname2(const char *name, int af) {
+       static struct hostent *(*fp)(const char *name, int af);
+
+       if (fp == NULL)
+               fp = get_func_addr("gethostbyname2");
+       if (fp != NULL)
+               return ((*fp)(name, af));
+       return (NULL);
+}
+#endif
+
+#ifdef HAVE_GETHOSTBYADDR
+struct hostent *
+idn_stub_gethostbyaddr(GHBA_ADDR_T addr, GHBA_ADDRLEN_T len, int type) {
+       static struct hostent *(*fp)(GHBA_ADDR_T name,
+                                    GHBA_ADDRLEN_T len, int type);
+
+       if (fp == NULL)
+               fp = get_func_addr("gethostbyaddr");
+       if (fp != NULL)
+               return ((*fp)(addr, len, type));
+       return (NULL);
+}
+#endif
+
+#ifdef GETHOST_R_GLIBC_FLAVOR
+
+#ifdef HAVE_GETHOSTBYNAME_R
+int
+idn_stub_gethostbyname_r(const char *name, struct hostent *result,
+                        char *buffer, size_t buflen,
+                        struct hostent **rp, int *errp)
+{
+       static int (*fp)(const char *name, struct hostent *result,
+                        char *buffer, size_t buflen,
+                        struct hostent **rp, int *errp);
+
+       if (fp == NULL)
+               fp = get_func_addr("gethostbyname_r");
+       if (fp != NULL)
+               return ((*fp)(name, result, buffer, buflen, rp, errp));
+       return (ENOENT);        /* ??? */
+}
+#endif
+
+#ifdef HAVE_GETHOSTBYNAME2_R
+int
+idn_stub_gethostbyname2_r(const char *name, int af, struct hostent *result,
+                         char *buffer, size_t buflen,
+                         struct hostent **rp, int *errp)
+{
+       static int (*fp)(const char *name, int af, struct hostent *result,
+                        char *buffer, size_t buflen,
+                        struct hostent **rp, int *errp);
+
+       if (fp == NULL)
+               fp = get_func_addr("gethostbyname2_r");
+       if (fp != NULL)
+               return ((*fp)(name, af, result, buffer, buflen, rp, errp));
+       return (ENOENT);        /* ??? */
+}
+#endif
+
+#ifdef HAVE_GETHOSTBYADDR_R
+int
+idn_stub_gethostbyaddr_r(GHBA_ADDR_T addr, GHBA_ADDRLEN_T len, int type,
+                        struct hostent *result, char *buffer,
+                        size_t buflen, struct hostent **rp, int *errp)
+{
+       static int (*fp)(GHBA_ADDR_T addr, GHBA_ADDRLEN_T len, int type,
+                        struct hostent *result, char *buffer,
+                        size_t buflen, struct hostent **rp, int *errp);
+
+       if (fp == NULL)
+               fp = get_func_addr("gethostbyaddr_r");
+       if (fp != NULL)
+               return ((*fp)(addr, len, type, result,
+                             buffer, buflen, rp, errp));
+       return (ENOENT);        /* ??? */
+}
+#endif
+
+#else /* GETHOST_R_GLIBC_FLAVOR */
+
+#ifdef HAVE_GETHOSTBYNAME_R
+struct hostent *
+idn_stub_gethostbyname_r(const char *name, struct hostent *result,
+                        char *buffer, int buflen, int *errp)
+{
+       static struct hostent *(*fp)(const char *name, struct hostent *result,
+                                    char *buffer, int buflen, int *errp);
+
+       if (fp == NULL)
+               fp = get_func_addr("gethostbyname_r");
+       if (fp != NULL)
+               return ((*fp)(name, result, buffer, buflen, errp));
+       return (NULL);
+}
+#endif
+
+#ifdef HAVE_GETHOSTBYADDR_R
+struct hostent *
+idn_stub_gethostbyaddr_r(GHBA_ADDR_T addr, int len, int type,
+                        struct hostent *result, char *buffer,
+                        int buflen, int *errp)
+{
+       static struct hostent *(*fp)(GHBA_ADDR_T addr, int len, int type,
+                                    struct hostent *result, char *buffer,
+                                    int buflen, int *errp);
+
+       if (fp == NULL)
+               fp = get_func_addr("gethostbyaddr_r");
+       if (fp != NULL)
+               return ((*fp)(addr, len, type, result, buffer, buflen, errp));
+       return (NULL);
+}
+#endif
+
+#endif /* GETHOST_R_GLIBC_FLAVOR */
+
+#ifdef HAVE_GETIPNODEBYNAME
+struct hostent *
+idn_stub_getipnodebyname(const char *name, int af, int flags, int *errp) {
+       static struct hostent *(*fp)(const char *name, int af, int flags,
+                                    int *errp);
+
+       if (fp == NULL)
+               fp = get_func_addr("getipnodebyname");
+       if (fp != NULL)
+               return ((*fp)(name, af, flags, errp));
+       return (NULL);
+}
+#endif
+
+#ifdef HAVE_GETIPNODEBYADDR
+struct hostent *
+idn_stub_getipnodebyaddr(const void *src, size_t len, int af, int *errp) {
+       static struct hostent *(*fp)(const void *src, size_t len, int af,
+                                    int *errp);
+
+       if (fp == NULL)
+               fp = get_func_addr("getipnodebyaddr");
+       if (fp != NULL)
+               return ((*fp)(src, len, af, errp));
+       return (NULL);
+}
+#endif
+
+#ifdef HAVE_FREEHOSTENT
+void
+idn_stub_freehostent(struct hostent *hp) {
+       static void (*fp)(struct hostent *hp);
+
+       if (fp == NULL)
+               fp = get_func_addr("freehostent");
+       if (fp != NULL)
+               (*fp)(hp);
+}
+#endif
+
+#ifdef HAVE_GETADDRINFO
+int
+idn_stub_getaddrinfo(const char *nodename, const char *servname,
+                    const struct addrinfo *hints, struct addrinfo **res)
+{
+       static int (*fp)(const char *nodename, const char *servname,
+                        const struct addrinfo *hints, struct addrinfo **res);
+
+       if (fp == NULL)
+               fp = get_func_addr("getaddrinfo");
+       if (fp != NULL)
+               return ((*fp)(nodename, servname, hints, res));
+       return (EAI_FAIL);
+}
+#endif
+
+#ifdef HAVE_FREEADDRINFO
+void
+idn_stub_freeaddrinfo(struct addrinfo *aip) {
+       static void (*fp)(struct addrinfo *aip);
+
+       if (fp == NULL)
+               fp = get_func_addr("freeaddrinfo");
+       if (fp != NULL)
+               (*fp)(aip);
+}
+#endif
+
+#ifdef HAVE_GETNAMEINFO
+int
+idn_stub_getnameinfo(const struct sockaddr *sa, GNI_SALEN_T salen,
+                    char *host, GNI_HOSTLEN_T hostlen,
+                    char *serv, GNI_SERVLEN_T servlen, GNI_FLAGS_T flags) {
+       static int (*fp)(const struct sockaddr *sa, GNI_SALEN_T salen,
+                        char *host, GNI_HOSTLEN_T hostlen,
+                        char *serv, GNI_SERVLEN_T servlen,
+                        GNI_FLAGS_T flags);
+
+       if (fp == NULL)
+               fp = get_func_addr("getnameinfo");
+       if (fp != NULL)
+               return ((*fp)(sa, salen, host, hostlen, serv, servlen, flags));
+       return (EAI_FAIL);
+}
+#endif
diff --git a/contrib/idn/idnkit-1.0-src/tools/runidn/stub.h b/contrib/idn/idnkit-1.0-src/tools/runidn/stub.h
new file mode 100644 (file)
index 0000000..bb4e3d2
--- /dev/null
@@ -0,0 +1,94 @@
+/* $Id: stub.h,v 1.1 2003/06/04 00:27:13 marka Exp $ */
+
+#ifndef STUB_H
+#define STUB_H
+
+#ifdef HAVE_GETHOSTBYNAME
+extern struct hostent *
+idn_stub_gethostbyname(const char *name);
+#endif
+
+#ifdef GETHOST_R_GLIBC_FLAVOR
+#ifdef HAVE_GETHOSTBYNAME_R
+extern int
+idn_stub_gethostbyname_r(const char *name, struct hostent *result,
+                        char *buffer, size_t buflen,
+                        struct hostent **rp, int *errp);
+#endif
+#else /* GETHOST_R_GLIBC_FLAVOR */
+#ifdef HAVE_GETHOSTBYNAME_R
+extern struct hostent *
+idn_stub_gethostbyname_r(const char *name, struct hostent *result,
+                        char *buffer, int buflen, int *errp);
+#endif
+#endif /* GETHOST_R_GLIBC_FLAVOR */
+
+#ifdef HAVE_GETHOSTBYNAME2
+extern struct hostent *
+idn_stub_gethostbyname2(const char *name, int af);
+#endif
+
+#ifdef GETHOST_R_GLIBC_FLAVOR
+#ifdef HAVE_GETHOSTBYNAME2_R
+extern int
+idn_stub_gethostbyname2_r(const char *name, int af, struct hostent *result,
+                         char *buffer, size_t buflen,
+                         struct hostent **rp, int *errp);
+#endif
+#endif /* GETHOST_R_GLIBC_FLAVOR */
+
+#ifdef HAVE_GETHOSTBYADDR
+extern struct hostent *
+idn_stub_gethostbyaddr(GHBA_ADDR_T addr, GHBA_ADDRLEN_T len, int type);
+#endif
+
+#ifdef GETHOST_R_GLIBC_FLAVOR
+#ifdef HAVE_GETHOSTBYADDR_R
+extern int
+idn_stub_gethostbyaddr_r(GHBA_ADDR_T addr, GHBA_ADDRLEN_T len, int type,
+                        struct hostent *result, char *buffer,
+                        size_t buflen, struct hostent **rp, int *errp);
+#endif
+#else /* GETHOST_R_GLIBC_FLAVOR */
+#ifdef HAVE_GETHOSTBYADDR_R
+extern struct hostent *
+idn_stub_gethostbyaddr_r(GHBA_ADDR_T addr, GHBA_ADDRLEN_T len, int type,
+                        struct hostent *result, char *buffer,
+                        int buflen, int *errp);
+#endif
+#endif /* GETHOST_R_GLIBC_FLAVOR */
+
+#ifdef HAVE_GETIPNODEBYNAME
+extern struct hostent *
+idn_stub_getipnodebyname(const char *name, int af, int flags, int *errp);
+#endif
+
+#ifdef HAVE_GETIPNODEBYADDR
+extern struct hostent *
+idn_stub_getipnodebyaddr(const void *src, size_t len, int af, int *errp);
+#endif
+
+#ifdef HAVE_FREEHOSTENT
+extern void
+idn_stub_freehostent(struct hostent *hp);
+#endif
+
+#ifdef HAVE_GETADDRINFO
+extern int
+idn_stub_getaddrinfo(const char *nodename, const char *servname,
+                    const struct addrinfo *hints, struct addrinfo **res);
+#endif
+
+#ifdef HAVE_FREEADDRINFO
+extern void
+idn_stub_freeaddrinfo(struct addrinfo *aip);
+#endif
+
+#ifdef HAVE_GETNAMEINFO
+extern int
+idn_stub_getnameinfo(const struct sockaddr *sa, GNI_SALEN_T salen,
+                    char *host, GNI_HOSTLEN_T hostlen, char *serv,
+                    GNI_SERVLEN_T servlen, GNI_FLAGS_T flags);
+#endif
+
+#endif /* STUB_H */
diff --git a/contrib/idn/idnkit-1.0-src/util/Makefile b/contrib/idn/idnkit-1.0-src/util/Makefile
new file mode 100644 (file)
index 0000000..9acbbc5
--- /dev/null
@@ -0,0 +1,43 @@
+# $Id: Makefile,v 1.1 2003/06/04 00:27:52 marka Exp $
+
+PERL = /usr/local/bin/perl -w
+
+V301_NORM_DIR = data/unicode-3.0.0
+V310_NORM_DIR = data/unicode-3.1.0
+V320_NORM_DIR = data/unicode-3.2.0
+NORM_GENERATOR = ./generate_normalize_data.pl
+
+NAMEPREP_DIR  = data/nameprep
+NAMEPREP_FILES = \
+       $(NAMEPREP_DIR)/nameprep.rfc3491.map \
+       $(NAMEPREP_DIR)/nameprep.rfc3491.prohibited \
+       $(NAMEPREP_DIR)/nameprep.rfc3491.unassigned \
+       $(NAMEPREP_DIR)/nameprep.rfc3491.bidi
+NAMEPREP_GENERATOR = ./generate_nameprep_data.pl
+NAMEPREP_VERSIONS = rfc3491
+
+all: normalize nameprep
+
+normalize: ../lib/unicodedata_320.c
+
+nameprep: ../lib/nameprepdata.c
+
+../lib/unicodedata_301.c: $(NORM_GENERATOR)
+       -rm -f $@.tmp
+       $(PERL) $(NORM_GENERATOR) -prefix v301_ -dir $(V301_NORM_DIR) \
+               > $@.tmp && mv $@.tmp $@
+
+../lib/unicodedata_310.c: $(NORM_GENERATOR)
+       -rm -f $@.tmp
+       $(PERL) $(NORM_GENERATOR) -prefix v310_ -dir $(V310_NORM_DIR) \
+               > $@.tmp && mv $@.tmp $@
+
+../lib/unicodedata_320.c: $(NORM_GENERATOR)
+       -rm -f $@.tmp
+       $(PERL) $(NORM_GENERATOR) -prefix v320_ -dir $(V320_NORM_DIR) \
+               > $@.tmp && mv $@.tmp $@
+
+../lib/nameprepdata.c: $(NAMEPREP_GENERATOR) $(NAMEPREP_FILES)
+       -rm -f $@.tmp
+       $(PERL) $(NAMEPREP_GENERATOR) -dir $(NAMEPREP_DIR) \
+               $(NAMEPREP_VERSIONS) > $@.tmp && mv $@.tmp $@
diff --git a/contrib/idn/idnkit-1.0-src/util/SparseMap.pm b/contrib/idn/idnkit-1.0-src/util/SparseMap.pm
new file mode 100644 (file)
index 0000000..ca9933b
--- /dev/null
@@ -0,0 +1,575 @@
+# $Id: SparseMap.pm,v 1.1 2003/06/04 00:27:53 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.
+#
+
+package SparseMap;
+
+use strict;
+use Carp;
+
+my $debug = 0;
+
+sub new {
+    # common options are:
+    #   BITS => [8, 7, 6],     # 3-level map, 2nd level bits=7, 3rd = 6.
+    #   MAX  => 0x110000       # actually, max + 1.
+    my $class = shift;
+    my $self = {@_};
+
+    croak "BITS unspecified" unless exists $self->{BITS};
+    croak "BITS is not an array reference"
+       unless ref($self->{BITS}) eq 'ARRAY';
+    croak "MAX unspecified" unless exists $self->{MAX};
+
+    $self->{MAXLV} = @{$self->{BITS}} - 1;
+    $self->{FIXED} = 0;
+
+    my $lv0size = (indices($self, $self->{MAX} - 1))[0] + 1;
+
+    my @map = (undef) x $lv0size;
+    $self->{MAP} = \@map;
+
+    bless $self, $class;
+}
+
+sub add1 {
+    my ($self, $n, $val) = @_;
+
+    croak "Already fixed" if $self->{FIXED};
+    carp("data ($n) out of range"), return if $n >= $self->{MAX};
+
+    my @index = $self->indices($n);
+    my $r = $self->{MAP};
+    my $maxlv = $self->{MAXLV};
+    my $idx;
+    my $lv;
+
+    for ($lv = 0; $lv < $maxlv - 1; $lv++) {
+       $idx = $index[$lv];
+       $r->[$idx] = $self->create_imap($lv + 1, undef)
+           unless defined $r->[$idx];
+       $r = $r->[$idx];
+    }
+    $idx = $index[$lv];
+    $r->[$idx] = $self->create_dmap() unless defined $r->[$idx];
+    $self->add_to_dmap($r->[$idx], $index[$maxlv], $val);
+}
+
+sub fix {
+    my $self = shift;
+    my $map = $self->{MAP};
+    my $maxlv = $self->{MAXLV};
+    my @tmp;
+    my @zero;
+
+    carp "Already fixed" if $self->{FIXED};
+    $self->collapse_tree();
+    $self->fill_default();
+    $self->{FIXED} = 1;
+}
+
+sub indices {
+    my $self = shift;
+    my $v = shift;
+    my @bits = @{$self->{BITS}};
+    my @idx;
+
+    print "indices($v,", join(',', @bits), ") = " if $debug;
+    for (my $i = @bits - 1; $i >= 0; $i--) {
+       my $bit = $bits[$i];
+       unshift @idx, $v & ((1 << $bit) - 1);
+       $v = $v >> $bit;
+    }
+    print "(", join(',', @idx), ")\n" if $debug;
+    @idx;
+}
+
+sub get {
+    my $self = shift;
+    my $v = shift;
+    my $map = $self->{MAP};
+    my @index = $self->indices($v);
+
+    croak "Not yet fixed" unless $self->{FIXED};
+
+    my $lastidx = pop @index;
+    foreach my $idx (@index) {
+       return $map->{DEFAULT} unless defined $map->[$idx];
+       $map = $map->[$idx];
+    }
+    $map->[$lastidx];
+}
+
+sub indirectmap {
+    my $self = shift;
+
+    croak "Not yet fixed" unless $self->{FIXED};
+
+    my @maps = $self->collect_maps();
+    my $maxlv = $self->{MAXLV};
+    my @bits = @{$self->{BITS}};
+
+    my @indirect = ();
+    for (my $lv = 0; $lv < $maxlv; $lv++) {
+       my $offset;
+       my $chunksz;
+       my $mapsz = @{$maps[$lv]->[0]};
+       if ($lv < $maxlv - 1) {
+           # indirect map
+           $offset = @indirect + @{$maps[$lv]} * @{$maps[$lv]->[0]};
+           $chunksz = (1 << $bits[$lv + 1]);
+       } else {
+           # direct map
+           $offset = 0;
+           $chunksz = 1;
+       }
+       my $nextmaps = $maps[$lv + 1];
+       foreach my $mapref (@{$maps[$lv]}) {
+           croak "mapsize inconsistent ", scalar(@$mapref),
+               " should be ", $mapsz, " (lv $lv)\n" if @$mapref != $mapsz;
+           foreach my $m (@$mapref) {
+               my $idx;
+               for ($idx = 0; $idx < @$nextmaps; $idx++) {
+                   last if $nextmaps->[$idx] == $m;
+               }
+               croak "internal error: map corrupted" if $idx >= @$nextmaps;
+               push @indirect, $offset + $chunksz * $idx;
+           }
+       }
+    }
+    @indirect;
+}
+
+sub cprog_imap {
+    my $self = shift;
+    my %opt = @_;
+    my $name = $opt{NAME} || 'map';
+    my @indirect = $self->indirectmap();
+    my $prog;
+    my $i;
+    my ($idtype, $idcol, $idwid);
+
+    my $max = 0;
+    $max < $_ and $max = $_ foreach @indirect;
+
+    if ($max < 256) {
+       $idtype = 'char';
+       $idcol = 8;
+       $idwid = 3;
+    } elsif ($max < 65536) {
+       $idtype = 'short';
+       $idcol = 8;
+       $idwid = 5;
+    } else {
+       $idtype = 'long';
+       $idcol = 4;
+       $idwid = 10;
+    }
+    $prog = "static const unsigned $idtype ${name}_imap[] = {\n";
+    $i = 0;
+    foreach my $v (@indirect) {
+       if ($i % $idcol == 0) {
+           $prog .= "\n" if $i != 0;
+           $prog .= "\t";
+       }
+       $prog .= sprintf "%${idwid}d, ", $v;
+       $i++;
+    }
+    $prog .= "\n};\n";
+    $prog;
+}
+
+sub cprog {
+    my $self = shift;
+    $self->cprog_imap(@_) . "\n" . $self->cprog_dmap(@_);
+}
+
+sub stat {
+    my $self = shift;
+    my @maps = $self->collect_maps();
+    my $elsize = $self->{ELSIZE};
+    my $i;
+    my $total = 0;
+    my @lines;
+
+    for ($i = 0; $i < $self->{MAXLV}; $i++) {
+       my $nmaps = @{$maps[$i]};
+       my $mapsz = @{$maps[$i]->[0]};
+       push @lines, "level $i: $nmaps maps (size $mapsz) ";
+       push @lines, "[", $nmaps * $mapsz * $elsize, "]" if $elsize;
+       push @lines, "\n";
+    }
+    my $ndmaps = @{$maps[$i]};
+    push @lines, "level $i: $ndmaps dmaps";
+    my $r = $maps[$i]->[0];
+    if (ref($r) eq 'ARRAY') {
+       push @lines, " (size ", scalar(@$r), ")";
+    }
+    push @lines, "\n";
+    join '', @lines;
+}
+
+sub collapse_tree {
+    my $self = shift;
+    my @tmp;
+
+    $self->_collapse_tree_rec($self->{MAP}, 0, \@tmp);
+}
+
+sub _collapse_tree_rec {
+    my ($self, $r, $lv, $refs) = @_;
+    my $ref = $refs->[$lv];
+    my $maxlv = $self->{MAXLV};
+    my $found;
+
+    return $r unless defined $r;
+
+    $ref = $refs->[$lv] = [] unless defined $ref;
+
+    if ($lv == $maxlv) {
+       $found = $self->find_dmap($ref, $r);
+    } else {
+       for (my $i = 0; $i < @$r; $i++) {
+           $r->[$i] = $self->_collapse_tree_rec($r->[$i], $lv + 1, $refs);
+       }
+       $found = $self->find_imap($ref, $r);
+    }
+    unless ($found) {
+       $found = $r;
+       push @$ref, $found;
+    }
+    return $found;
+}
+
+sub fill_default {
+    my $self = shift;
+    my $maxlv = $self->{MAXLV};
+    my $bits = $self->{BITS};
+    my @zeros;
+
+    $zeros[$maxlv] = $self->create_dmap();
+    for (my $lv = $maxlv - 1; $lv >= 0; $lv--) {
+       my $r = $zeros[$lv + 1];
+       $zeros[$lv] = $self->create_imap($lv, $r);
+    }
+    _fill_default_rec($self->{MAP}, 0, $maxlv, \@zeros);
+}
+
+sub _fill_default_rec {
+    my ($r, $lv, $maxlv, $zeros) = @_;
+
+    return if $lv == $maxlv;
+    for (my $i = 0; $i < @$r; $i++) {
+       if (defined($r->[$i])) {
+           _fill_default_rec($r->[$i], $lv + 1, $maxlv, $zeros);
+       } else {
+           $r->[$i] = $zeros->[$lv + 1];
+       }
+    }
+}
+
+sub create_imap {
+    my ($self, $lv, $v) = @_;
+    my @map;
+    @map = ($v) x (1 << $self->{BITS}->[$lv]);
+    \@map;
+}
+
+sub find_imap {
+    my ($self, $maps, $map) = @_;
+    my $i;
+
+    foreach my $el (@$maps) {
+       next unless @$el == @$map;
+       for ($i = 0; $i < @$el; $i++) {
+           last unless ($el->[$i] || 0) == ($map->[$i] || 0);
+       }
+       return $el if $i >= @$el;
+    }
+    undef;
+}
+
+sub collect_maps {
+    my $self = shift;
+    my @maps;
+    _collect_maps_rec($self->{MAP}, 0, $self->{MAXLV}, \@maps);
+    @maps;
+}
+
+sub _collect_maps_rec {
+    my ($r, $lv, $maxlv, $maps) = @_;
+    my $mapref = $maps->[$lv];
+
+    return unless defined $r;
+    foreach my $ref (@{$mapref}) {
+       return if $ref == $r;
+    }
+    push @{$maps->[$lv]}, $r;
+    if ($lv < $maxlv) {
+       _collect_maps_rec($_, $lv + 1, $maxlv, $maps) foreach @{$r};
+    }
+}
+    
+sub add {confess "Subclass responsibility";}
+sub create_dmap {confess "Subclass responsibility";}
+sub add_to_dmap {confess "Subclass responsibility";}
+sub find_dmap {confess "Subclass responsibility";}
+sub cprog_dmap {confess "Subclass responsibility";}
+
+1;
+
+package SparseMap::Bit;
+
+use strict;
+use vars qw(@ISA);
+use Carp;
+#use SparseMap;
+
+@ISA = qw(SparseMap);
+
+sub new {
+    my $class = shift;
+    my $self = $class->SUPER::new(@_);
+    $self->{DEFAULT} = 0;
+    bless $self, $class;
+}
+
+sub add {
+    my $self = shift;
+
+    $self->add1($_, undef) foreach @_;
+}
+
+sub create_dmap {
+    my $self = shift;
+    my $bmbits = $self->{BITS}->[-1];
+
+    my $s = "\0" x (1 << ($bmbits - 3));
+    \$s;
+}
+
+sub add_to_dmap {
+    my ($self, $map, $idx, $val) = @_;
+    vec($$map, $idx, 1) = 1;
+}
+
+sub find_dmap {
+    my ($self, $ref, $r) = @_;
+    foreach my $map (@$ref) {
+       return $map if $$map eq $$r;
+    }
+    return undef;
+}
+
+sub cprog_dmap {
+    my $self = shift;
+    my %opt = @_;
+    my $name = $opt{NAME} || 'map';
+    my @maps = $self->collect_maps();
+    my @bitmap = @{$maps[-1]};
+    my $prog;
+    my $bmsize = 1 << ($self->{BITS}->[-1] - 3);
+
+    $prog = <<"END";
+static const struct {
+       unsigned char bm[$bmsize];
+} ${name}_bitmap[] = {
+END
+
+    foreach my $bm (@bitmap) {
+       my $i = 0;
+       $prog .= "\t{{\n";
+       foreach my $v (unpack 'C*', $$bm) {
+           if ($i % 16 == 0) {
+               $prog .= "\n" if $i != 0;
+               $prog .= "\t";
+           }
+           $prog .= sprintf "%3d,", $v;
+           $i++;
+       }
+       $prog .= "\n\t}},\n";
+    }
+    $prog .= "};\n";
+    $prog;
+}
+
+1;
+
+package SparseMap::Int;
+
+use strict;
+use vars qw(@ISA);
+use Carp;
+#use SparseMap;
+
+@ISA = qw(SparseMap);
+
+sub new {
+    my $class = shift;
+    my $self = $class->SUPER::new(@_);
+    $self->{DEFAULT} = 0 unless exists $self->{DEFAULT};
+    bless $self, $class;
+}
+
+sub add {
+    my $self = shift;
+    while (@_ > 0) {
+       my $n = shift;
+       my $val = shift;
+       $self->add1($n, $val);
+    }
+}
+
+sub create_dmap {
+    my $self = shift;
+    my $tblbits = $self->{BITS}->[-1];
+    my $default = $self->{DEFAULT};
+
+    my @tbl = ($default) x (1 << $tblbits);
+    \@tbl;
+}
+
+sub add_to_dmap {
+    my ($self, $map, $idx, $val) = @_;
+    $map->[$idx] = $val;
+}
+
+sub find_dmap {
+    my ($self, $ref, $r) = @_;
+    foreach my $map (@$ref) {
+       if (@$map == @$r) {
+           my $i;
+           for ($i = 0; $i < @$map; $i++) {
+               last if $map->[$i] != $r->[$i];
+           }
+           return $map if $i == @$map;
+       }
+    }
+    return undef;
+}
+
+sub cprog_dmap {
+    my $self = shift;
+    my %opt = @_;
+    my $name = $opt{NAME} || 'map';
+    my @maps = $self->collect_maps();
+    my @table = @{$maps[-1]};
+    my $prog;
+    my $i;
+    my ($idtype, $idcol, $idwid);
+    my $tblsize = 1 << $self->{BITS}->[-1];
+
+    my ($min, $max);
+    foreach my $a (@table) {
+       foreach my $v (@$a) {
+           $min = $v if !defined($min) or $min > $v;
+           $max = $v if !defined($max) or $max < $v;
+       }
+    }
+    if (exists $opt{MAPTYPE}) {
+       $idtype = $opt{MAPTYPE};
+    } else {
+       my $u = $min < 0 ? '' : 'unsigned ';
+       my $absmax = abs($max);
+       $absmax = abs($min) if abs($min) > $absmax;
+
+       if ($absmax < 256) {
+           $idtype = "${u}char";
+       } elsif ($absmax < 65536) {
+           $idtype = "${u}short";
+       } else {
+           $idtype = "${u}long";
+       }
+    }
+
+    $idwid = decimalwidth($max);
+    $idwid = decimalwidth($min) if decimalwidth($min) > $idwid;
+
+    $prog = <<"END";
+static const struct {
+       $idtype tbl[$tblsize];
+} ${name}_table[] = {
+END
+
+    foreach my $a (@table) {
+       my $i = 0;
+       my $col = 0;
+       $prog .= "\t{{\n\t";
+       foreach my $v (@$a) {
+           my $s = sprintf "%${idwid}d, ", $v;
+           $col += length($s);
+           if ($col > 70) {
+               $prog .= "\n\t";
+               $col = length($s);
+           }
+           $prog .= $s;
+       }
+       $prog .= "\n\t}},\n";
+    }
+    $prog .= "};\n";
+    $prog;
+}
+
+sub decimalwidth {
+    my $n = shift;
+    my $neg = 0;
+    my $w;
+
+    if ($n < 0) {
+       $neg = 1;
+       $n = -$n;
+    }
+    if ($n < 100) {
+       $w = 2;
+    } elsif ($n < 10000) {
+       $w = 4;
+    } elsif ($n < 1000000) {
+       $w = 6;
+    } elsif ($n < 100000000) {
+       $w = 8;
+    } else {
+       $w = 10;
+    }
+    $w + $neg;
+}
+
+1;
diff --git a/contrib/idn/idnkit-1.0-src/util/UCD.pm b/contrib/idn/idnkit-1.0-src/util/UCD.pm
new file mode 100644 (file)
index 0000000..24f02d6
--- /dev/null
@@ -0,0 +1,194 @@
+# $Id: UCD.pm,v 1.1 2003/06/04 00:27:53 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.
+#
+
+package UCD;
+
+#
+# UCD.pm -- parser for Unicode Character Database files.
+#
+# This file is an aggregation of the following modules, each of which
+# provides a parser for a specific data file of UCD.
+#      UCD::UnicodeData                -- for UnicodeData.txt
+#      UCD::CaseFolding                -- for CaseFolding.txt
+#      UCD::SpecialCasing              -- for SpecialCasing.txt
+#      UCD::CompositionExclusions      -- for CompositionExclusions-1.txt
+#
+# Each module provides two subroutines:
+#
+#   $line = getline(\*HANDLE);
+#      reads next non-comment line from HANDLE, and returns it.
+#      undef will be returned upon EOF.
+#
+#   %fields = parse($line);
+#      parses a line and extract fields, and returns a list of
+#      field name and its value, suitable for assignment to a hash.
+#
+
+package UCD::UnicodeData;
+
+use strict;
+use Carp;
+
+sub getline {
+    my $fh = shift;
+    my $s = <$fh>;
+    $s =~ s/\r?\n$// if $s;
+    $s;
+}
+
+sub parseline {
+    my $s = shift;
+
+    my @f = split /;/, $s, -1;
+    return (CODE     => hex($f[0]),
+           NAME     => $f[1],
+           CATEGORY => $f[2],
+           CLASS    => $f[3]+0,
+           BIDI     => $f[4],
+           DECOMP   => dcmap($f[5]),
+           DECIMAL  => dvalue($f[6]),
+           DIGIT    => dvalue($f[7]),
+           NUMERIC  => dvalue($f[8]),
+           MIRRORED => $f[9] eq 'Y',
+           NAME10   => $f[10],
+           COMMENT  => $f[11],
+           UPPER    => ucode($f[12]),
+           LOWER    => ucode($f[13]),
+           TITLE    => ucode($f[14]));
+}
+
+sub dcmap {
+    my $v = shift;
+    return undef if $v eq '';
+    $v =~ /^(?:(<[^>]+>)\s*)?(\S.*)/
+       or croak "invalid decomposition mapping \"$v\"";
+    my $tag = $1 || '';
+    [$tag, map {hex($_)} split(' ', $2)];
+}
+
+sub ucode {
+    my $v = shift;
+    return undef if $v eq '';
+    hex($v);
+}
+
+sub dvalue {
+    my $v = shift;
+    return undef if $v eq '';
+    $v;
+}
+
+package UCD::CaseFolding;
+
+use strict;
+
+sub getline {
+    my $fh = shift;
+    while (defined(my $s = <$fh>)) {
+       next if $s =~ /^\#/;
+       next if $s =~ /^\s*$/;
+       $s =~ s/\r?\n$//;
+       return $s;
+    }
+    undef;
+}
+
+sub parseline {
+    my $s = shift;
+    my @f = split /;\s*/, $s, -1;
+    return (CODE => hex($f[0]),
+           TYPE => $f[1],
+           MAP  => [map(hex, split ' ', $f[2])],
+          );
+}
+
+package UCD::SpecialCasing;
+
+use strict;
+
+sub getline {
+    my $fh = shift;
+    while (defined(my $s = <$fh>)) {
+       next if $s =~ /^\#/;
+       next if $s =~ /^\s*$/;
+       $s =~ s/\r?\n$//;
+       return $s;
+    }
+    undef;
+}
+
+sub parseline {
+    my $s = shift;
+
+    my @f = split /;\s*/, $s, -1;
+    my $cond = (@f > 5) ? $f[4] : undef;
+    return (CODE => hex($f[0]),
+           LOWER => [map(hex, split ' ', $f[1])],
+           TITLE => [map(hex, split ' ', $f[2])],
+           UPPER => [map(hex, split ' ', $f[3])],
+           CONDITION => $cond);
+}
+
+package UCD::CompositionExclusions;
+
+use strict;
+
+sub getline {
+    my $fh = shift;
+    while (defined(my $s = <$fh>)) {
+       next if $s =~ /^\#/;
+       next if $s =~ /^\s*$/;
+       $s =~ s/\r?\n$//;
+       return $s;
+    }
+    undef;
+}
+
+sub parseline {
+    my $s = shift;
+    m/^[0-9A-Fa-f]+/;
+    return (CODE => hex($&));
+}
+
+1;
diff --git a/contrib/idn/idnkit-1.0-src/util/generate_nameprep_data.pl b/contrib/idn/idnkit-1.0-src/util/generate_nameprep_data.pl
new file mode 100755 (executable)
index 0000000..c93f3ae
--- /dev/null
@@ -0,0 +1,405 @@
+#! /usr/local/bin/perl -w
+# $Id: generate_nameprep_data.pl,v 1.1 2003/06/04 00:27:54 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.
+#
+
+use v5.6.0;            # for pack('U')
+use bytes;
+
+use lib qw(.);
+
+use SparseMap;
+use Getopt::Long;
+
+(my $myid = '$Id: generate_nameprep_data.pl,v 1.1 2003/06/04 00:27:54 marka Exp $') =~ s/\$([^\$]+)\$/\$-$1-\$/;
+
+my @map_bits = (9, 7, 5);
+my @proh_bits = (7, 7, 7);
+my @unas_bits = (7, 7, 7);
+my @bidi_bits = (9, 7, 5);
+
+my @bidi_types = ('OTHERS', 'R_AL', 'L');
+
+my $dir = '.';
+my @versions = ();
+
+GetOptions('dir=s', \$dir) or die usage();
+@versions = @ARGV;
+
+print_header();
+
+bits_definition("MAP", @map_bits);
+bits_definition("PROH", @proh_bits);
+bits_definition("UNAS", @unas_bits);
+bits_definition("BIDI", @bidi_bits);
+
+generate_data($_) foreach @ARGV;
+
+sub usage {
+    die "Usage: $0 [-dir dir] version..\n";
+}
+
+sub generate_data {
+    my $version = shift;
+    generate_mapdata($version, "$dir/nameprep.$version.map");
+    generate_prohibiteddata($version, "$dir/nameprep.$version.prohibited");
+    generate_unassigneddata($version, "$dir/nameprep.$version.unassigned");
+    generate_bididata($version, "$dir/nameprep.$version.bidi");
+}
+
+#
+# Generate mapping data.
+#
+sub generate_mapdata {
+    my $version = shift;
+    my $file = shift;
+
+    my $map = SparseMap::Int->new(BITS => [@map_bits],
+                                 MAX => 0x110000,
+                                 MAPALL => 1,
+                                 DEFAULT => 0);
+    open FILE, $file or die "cannot open $file: $!\n";
+
+    my $mapbuf = "\0"; # dummy
+    my %maphash = ();
+    while (<FILE>) {
+       if ($. == 1 and /^%\s*SAME-AS\s+(\S+)/) {
+           my $same_as = $1;
+           if (grep {$_ eq $same_as} @versions > 0) {
+               generate_map_ref($version, $same_as);
+               close FILE;
+               return;
+           }
+           next;
+       }
+       next if /^\#/;
+       next if /^\s*$/;
+       register_map($map, \$mapbuf, \%maphash, $_);
+    }
+    close FILE;
+    generate_map($version, $map, \$mapbuf);
+}
+
+#
+# Generate prohibited character data.
+#
+sub generate_prohibiteddata {
+    my $version = shift;
+    my $file = shift;
+
+    my $proh = SparseMap::Bit->new(BITS => [@proh_bits],
+                                  MAX => 0x110000);
+    open FILE, $file or die "cannot open $file: $!\n";
+    while (<FILE>) {
+       if ($. == 1 and /^%\s*SAME-AS\s+(\S+)/) {
+           my $same_as = $1;
+           if (grep {$_ eq $same_as} @versions > 0) {
+               generate_prohibited_ref($version, $same_as);
+               close FILE;
+               return;
+           }
+           next;
+       }
+       next if /^\#/;
+       next if /^\s*$/;
+       register_prohibited($proh, $_);
+    }
+    close FILE;
+    generate_prohibited($version, $proh);
+}
+
+#
+# Generate unassigned codepoint data.
+#
+sub generate_unassigneddata {
+    my $version = shift;
+    my $file = shift;
+
+    my $unas = SparseMap::Bit->new(BITS => [@unas_bits],
+                                  MAX => 0x110000);
+    open FILE, $file or die "cannot open $file: $!\n";
+    while (<FILE>) {
+       if ($. == 1 and /^%\s*SAME-AS\s+(\S+)/) {
+           my $same_as = $1;
+           if (grep {$_ eq $same_as} @versions > 0) {
+               generate_unassigned_ref($version, $same_as);
+               close FILE;
+               return;
+           }
+           next;
+       }
+       next if /^\#/;
+       next if /^\s*$/;
+       register_unassigned($unas, $_);
+    }
+    close FILE;
+    generate_unassigned($version, $unas);
+}
+
+#
+# Generate data of bidi "R" or "AL" characters.
+#
+sub generate_bididata {
+    my $version = shift;
+    my $file = shift;
+
+    my $bidi = SparseMap::Int->new(BITS => [@bidi_bits],
+                                  MAX => 0x110000);
+    open FILE, $file or die "cannot open $file: $!\n";
+
+    my $type = 0;
+    while (<FILE>) {
+       if ($. == 1 and /^%\s*SAME-AS\s+(\S+)/) {
+           my $same_as = $1;
+           if (grep {$_ eq $same_as} @versions > 0) {
+               generate_unassigned_ref($version, $same_as);
+               close FILE;
+               return;
+           }
+           next;
+       }
+       if (/^%\s*BIDI_TYPE\s+(\S+)$/) {
+           my $i = 0;
+           for ($i = 0; $i < @bidi_types; $i++) {
+               if ($1 eq $bidi_types[$i]) {
+                   $type = $i;
+                   last;
+               }
+           }
+           die "unrecognized line: $_" if ($i >= @bidi_types);
+           next;
+       }
+       next if /^\#/;
+       next if /^\s*$/;
+       register_bidi($bidi, $type, $_);
+    }
+    close FILE;
+
+    generate_bidi($version, $bidi);
+}
+
+sub print_header {
+    print <<"END";
+/* \$Id\$ */
+/* $myid */
+/*
+ * Do not edit this file!
+ * This file is generated from NAMEPREP specification.
+ */
+
+END
+}
+
+sub bits_definition {
+    my $name = shift;
+    my @bits = @_;
+    my $i = 0;
+
+    foreach my $n (@bits) {
+       print "#define ${name}_BITS_$i\t$n\n";
+       $i++;
+    }
+    print "\n";
+}
+
+sub register_map {
+    my ($map, $bufref, $hashref, $line) = @_;
+
+    my ($from, $to) = split /;/, $line;
+    my @fcode = map {hex($_)} split ' ', $from;
+    my @tcode = map {hex($_)} split ' ', $to;
+
+    my $ucs4 = pack('V*', @tcode);
+    $ucs4 =~ s/\000+$//;
+
+    my $offset;
+    if (exists $hashref->{$ucs4}) {
+       $offset = $hashref->{$ucs4};
+    } else {
+       $offset = length $$bufref;
+       $$bufref .= pack('C', length($ucs4)) . $ucs4;
+       $hashref->{$ucs4} = $offset;
+    }
+
+    die "unrecognized line: $line" if @fcode != 1;
+    $map->add($fcode[0], $offset);
+}
+
+sub generate_map {
+    my ($version, $map, $bufref) = @_;
+
+    $map->fix();
+
+    print $map->cprog(NAME => "nameprep_${version}_map");
+    print "\nstatic const unsigned char nameprep_${version}_map_data[] = \{\n";
+    print_uchararray($$bufref);
+    print "};\n\n";
+}
+
+sub generate_map_ref {
+    my ($version, $refversion) = @_;
+    print <<"END";
+#define nameprep_${version}_map_imap   nameprep_${refversion}_map_imap
+#define nameprep_${version}_map_table  nameprep_${refversion}_map_table
+#define nameprep_${version}_map_data   nameprep_${refversion}_map_data
+
+END
+}
+
+sub print_uchararray {
+    my @chars = unpack 'C*', $_[0];
+    my $i = 0;
+    foreach my $v (@chars) {
+       if ($i % 12 == 0) {
+           print "\n" if $i != 0;
+           print "\t";
+       }
+       printf "%3d, ", $v;
+       $i++;
+    }
+    print "\n";
+}
+
+sub register_prohibited {
+    my $proh = shift;
+    register_bitmap($proh, @_);
+}
+
+sub register_unassigned {
+    my $unas = shift;
+    register_bitmap($unas, @_);
+}
+
+sub register_bidi {
+    my $bidi = shift;
+    my $type = shift;
+    register_intmap($bidi, $type, @_);
+}
+
+sub generate_prohibited {
+    my ($version, $proh) = @_;
+    generate_bitmap($proh, "nameprep_${version}_prohibited");
+    print "\n";
+}
+
+sub generate_prohibited_ref {
+    my ($version, $refversion) = @_;
+    print <<"END";
+#define nameprep_${version}_prohibited_imap    nameprep_${refversion}_prohibited_imap
+#define nameprep_${version}_prohibited_bitmap  nameprep_${refversion}_prohibited_bitmap
+
+END
+}
+
+sub generate_unassigned {
+    my ($version, $unas) = @_;
+    generate_bitmap($unas, "nameprep_${version}_unassigned");
+    print "\n";
+}
+
+sub generate_unassigned_ref {
+    my ($version, $refversion) = @_;
+    print <<"END";
+#define nameprep_${version}_unassigned_imap    nameprep_${refversion}_unassigned_imap
+#define nameprep_${version}_unassigned_bitmap  nameprep_${refversion}_unassigned_bitmap
+
+END
+}
+
+sub generate_bidi {
+    my ($version, $bidi) = @_;
+
+    $bidi->fix();
+
+    print $bidi->cprog(NAME => "nameprep_${version}_bidi");
+    print "\n";
+    print "static const unsigned char nameprep_${version}_bidi_data[] = \{\n";
+
+    foreach my $type (@bidi_types) {
+       printf "\tidn_biditype_%s, \n", lc($type);
+    }
+    print "};\n\n";
+}
+
+sub generate_bidi_ref {
+    my ($version, $refversion) = @_;
+    print <<"END";
+#define nameprep_${version}_bidi_imap  nameprep_${refversion}_bidi_imap
+#define nameprep_${version}_bidi_table nameprep_${refversion}_bidi_table
+
+END
+}
+
+sub register_bitmap {
+    my $map = shift;
+    my $line = shift;
+
+    /^([0-9A-Fa-f]+)(?:-([0-9A-Fa-f]+))?/ or die "unrecognized line: $line";
+    my $start = hex($1);
+    my $end = defined($2) ? hex($2) : undef;
+    if (defined $end) {
+       $map->add($start .. $end);
+    } else {
+       $map->add($start);
+    }
+}
+
+sub register_intmap {
+    my $map = shift;
+    my $value = shift;
+    my $line = shift;
+
+    /^([0-9A-Fa-f]+)(?:-([0-9A-Fa-f]+))?/ or die "unrecognized line: $line";
+    my $start = hex($1);
+    my $end = defined($2) ? hex($2) : $start;
+    for (my $i = $start; $i <= $end; $i++) {
+       $map->add($i, $value);
+    }
+}
+
+sub generate_bitmap {
+    my $map = shift;
+    my $name = shift;
+    $map->fix();
+    #$map->stat();
+    print $map->cprog(NAME => $name);
+}
diff --git a/contrib/idn/idnkit-1.0-src/util/generate_normalize_data.pl b/contrib/idn/idnkit-1.0-src/util/generate_normalize_data.pl
new file mode 100755 (executable)
index 0000000..2ba1a2f
--- /dev/null
@@ -0,0 +1,586 @@
+#! /usr/local/bin/perl -w
+# $Id: generate_normalize_data.pl,v 1.1 2003/06/04 00:27:55 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.
+#
+
+# 
+# Generate lib/unicodedata.c from UnicodeData.txt,
+# CompositionExclusions-1.txt, SpecialCasing.txt and CaseFolding.txt,
+# all of them available from ftp://ftp.unicode.org/Public/UNIDATA/.
+#
+
+use strict;
+use lib qw(.);
+
+use Getopt::Long;
+use UCD;
+use SparseMap;
+
+use constant UCS_MAX => 0x110000;
+use constant END_BIT => 0x80000000;
+
+my $DECOMP_COMPAT_BIT = 0x8000;
+
+my $CASEMAP_FINAL_BIT = 0x1;
+my $CASEMAP_NONFINAL_BIT = 0x2;
+my $CASEMAP_LAST_BIT = 0x10;
+
+my $LETTER_BIT = 1;
+my $NSPMARK_BIT = 2;
+
+(my $myid = '$Id: generate_normalize_data.pl,v 1.1 2003/06/04 00:27:55 marka Exp $') =~ s/\$([^\$]+)\$/\$-$1-\$/;
+
+my @default_bits = (9, 7, 5);
+#my @default_bits = (7, 7, 7);
+my @canon_class_bits = @default_bits;
+my @decomp_bits = @default_bits;
+my @comp_bits = @default_bits;
+my @folding_bits = @default_bits;
+my @casemap_bits = @default_bits;
+my @casemap_ctx_bits = @default_bits;
+
+my $prefix = '';
+my $dir = '.';
+my $unicodedatafile = 'UnicodeData.txt';
+my $exclusionfile = 'CompositionExclusions.txt';
+my $specialcasefile = 'SpecialCasing.txt';
+my $casefoldingfile = 'CaseFolding.txt';
+my $verbose;
+
+GetOptions('dir|d=s' => \$dir,
+          'unicodedata|u=s' => \$unicodedatafile,
+          'exclude|e=s' => \$exclusionfile,    
+          'specialcase|s=s' => \$specialcasefile,
+          'casefold|c=s' => \$casefoldingfile,
+          'prefix|p=s' => \$prefix,
+          'verbose|v' => \$verbose,
+) or usage();
+
+foreach my $r (\$unicodedatafile, \$exclusionfile,
+              \$specialcasefile, \$casefoldingfile) {
+    $$r = "$dir/$$r" unless $$r =~ m|^/|;
+}
+
+my %exclusions;
+my %lower_special;
+my %upper_special;
+
+my @decomp_data;
+my @comp_data;
+my @toupper_data;
+my @tolower_data;
+my @folding_data;
+
+#
+# Create Mapping/Bitmap objects.
+#
+
+# canonical class
+my $canon_class = SparseMap::Int->new(BITS => [@canon_class_bits],
+                                    MAX => UCS_MAX,
+                                    MAPALL => 1,
+                                    DEFAULT => 0);
+
+# canonical/compatibility decomposition
+my $decomp = SparseMap::Int->new(BITS => [@decomp_bits],
+                                MAX => UCS_MAX,
+                                MAPALL => 1,
+                                DEFAULT => 0);
+
+# canonical composition
+my $comp = SparseMap::Int->new(BITS => [@comp_bits],
+                              MAX => UCS_MAX,
+                              MAPALL => 1,
+                              DEFAULT => 0);
+
+# uppercase/lowercase
+my $upper = SparseMap::Int->new(BITS => [@casemap_bits],
+                               MAX => UCS_MAX,
+                               MAPALL => 1,
+                               DEFAULT => 0);
+my $lower = SparseMap::Int->new(BITS => [@casemap_bits],
+                               MAX => UCS_MAX,
+                               MAPALL => 1,
+                               DEFAULT => 0);
+
+# final/nonfinal context
+my $casemap_ctx = SparseMap::Int->new(BITS => [@casemap_ctx_bits],
+                                     MAX => UCS_MAX,
+                                     MAPALL => 1,
+                                     DEFAULT => 0);
+
+# casefolding
+my $folding = SparseMap::Int->new(BITS => [@folding_bits],
+                                 MAX => UCS_MAX,
+                                 MAPALL => 1,
+                                 DEFAULT => 0);
+
+#
+# Read datafiles.
+#
+
+read_exclusion_file();
+read_specialcasing_file();
+read_unicodedata_file();
+read_casefolding_file();
+
+print_header();
+print_canon_class();
+print_composition();
+print_decomposition();
+print_casemap();
+print_casemap_context();
+print_casefolding();
+
+exit;
+
+sub usage {
+    print STDERR <<"END";
+Usage: $0 [options..]
+  options:
+    -d DIR  directory where Unicode Character Data files resides [./]
+    -u FILE name of the UnicodeData file [UnicodeData.txt]
+    -e FILE name of the CompositionExclusion file [CompositionExclusions-1.txt]
+    -s FILE name of the SpecialCasing file [SpecialCasing.txt]
+    -c FILE name of the CaseFolding file [CaseFolding.txt]
+END
+    exit 1;
+}
+
+#
+# read_exclusion_file -- read CompositionExclusions-1.txt.
+#
+sub read_exclusion_file {
+    open EXCLUDE, $exclusionfile   or die "cannot open $exclusionfile: $!\n";
+    while ($_ = UCD::CompositionExclusions::getline(\*EXCLUDE)) {
+       my %data = UCD::CompositionExclusions::parseline($_);
+       $exclusions{$data{CODE}} = 1;
+    }
+    close EXCLUDE;
+}
+
+#
+# read_specialcasing_file -- read SpecialCasing.txt
+#
+sub read_specialcasing_file {
+    open SPCASE, $specialcasefile or die "cannot open $specialcasefile: $!\n";
+    while ($_ = UCD::SpecialCasing::getline(\*SPCASE)) {
+       my %data = UCD::SpecialCasing::parseline($_);
+       my $code = $data{CODE};
+       my $lower = $data{LOWER};
+       my $upper = $data{UPPER};
+       my $cond = $data{CONDITION} || '';
+
+       next unless $cond eq '' or $cond =~ /^(NON_)?FINAL/;
+
+       if (defined $cond && (@$lower > 1 || $lower->[0] != $code)
+           or @$lower > 1 or $lower->[0] != $code) {
+           $lower_special{$code} = [$lower, $cond];
+       }
+       if (defined $cond && (@$upper > 1 || $upper->[0] != $code)
+           or @$upper > 1 or $upper->[0] != $code) {
+           $upper_special{$code} = [$upper, $cond];
+       }
+    }
+    close SPCASE;
+}
+
+#
+# read_unicodedata_file -- read UnicodeData.txt
+#
+sub read_unicodedata_file {
+    open UCD, $unicodedatafile or die "cannot open $unicodedatafile: $!\n";
+
+    @decomp_data = (0);
+    @toupper_data = (0);
+    @tolower_data = (0);
+
+    my @comp_cand;     # canonical composition candidates
+    my %nonstarter;
+
+    while ($_ = UCD::UnicodeData::getline(\*UCD)) {
+       my %data = UCD::UnicodeData::parseline($_);
+       my $code = $data{CODE};
+
+       # combining class
+       if ($data{CLASS} > 0) {
+           $nonstarter{$code} = 1;
+           $canon_class->add($code, $data{CLASS});
+       }
+
+       # uppercasing
+       if (exists $upper_special{$code} or defined $data{UPPER}) {
+           my $offset = @toupper_data;
+           my @casedata;
+
+           $upper->add($code, $offset);
+           if (exists $upper_special{$code}) {
+               push @casedata, $upper_special{$code};
+           }
+           if (defined $data{UPPER}) {
+               push @casedata, $data{UPPER};
+           }
+           push @toupper_data, casemap_data(@casedata);
+       }
+
+       # lowercasing
+       if (exists $lower_special{$code} or defined $data{LOWER}) {
+           my $offset = @tolower_data;
+           my @casedata;
+
+           $lower->add($code, $offset);
+           if (exists $lower_special{$code}) {
+               push @casedata, $lower_special{$code};
+           }
+           if (defined $data{LOWER}) {
+               push @casedata, $data{LOWER};
+           }
+           push @tolower_data, casemap_data(@casedata);
+       }
+
+       # composition/decomposition
+       if ($data{DECOMP}) {
+           my ($tag, @decomp) = @{$data{DECOMP}};
+           my $offset = @decomp_data;
+
+           # composition
+           if ($tag eq '' and @decomp > 1 and not exists $exclusions{$code}) {
+               # canonical composition candidate
+               push @comp_cand, [$code, @decomp];
+           }
+
+           # decomposition
+           if ($tag ne '') {
+               # compatibility decomposition
+               $offset |= $DECOMP_COMPAT_BIT;
+           }
+           $decomp->add($code, $offset);
+           push @decomp_data, @decomp;
+           $decomp_data[-1] |= END_BIT;
+
+       }
+
+       # final/nonfinal context
+       if ($data{CATEGORY} =~ /L[ult]/) {
+           $casemap_ctx->add($code, $LETTER_BIT);
+       } elsif ($data{CATEGORY} eq 'Mn') {
+           $casemap_ctx->add($code, $NSPMARK_BIT);
+       }
+    }
+    close UCD;
+
+    # Eliminate composition candidates whose decomposition starts with
+    # a non-starter.
+    @comp_cand = grep {not exists $nonstarter{$_->[1]}} @comp_cand;
+
+    @comp_data = ([0, 0, 0]);
+    my $last_code = -1;
+    my $last_offset = @comp_data;
+    for my $r (sort {$a->[1] <=> $b->[1] || $a->[2] <=> $b->[2]} @comp_cand) {
+       if ($r->[1] != $last_code) {
+           $comp->add($last_code,
+                      ($last_offset | ((@comp_data - $last_offset)<<16)))
+               unless $last_code == -1;
+           $last_code = $r->[1];
+           $last_offset = @comp_data;
+       }
+       push @comp_data, $r;
+    }
+    $comp->add($last_code,
+              ($last_offset | ((@comp_data - $last_offset)<<16)));
+}
+
+sub casemap_data {
+    my @data = @_;
+    my @result = ();
+    while (@data > 0) {
+       my $r = shift @data;
+       my $flag = 0;
+       if (ref $r) {
+           if ($r->[1] eq 'FINAL') {
+               $flag |= $CASEMAP_FINAL_BIT;
+           } elsif ($r->[1] eq 'NON_FINAL') {
+               $flag |= $CASEMAP_NONFINAL_BIT;
+           } elsif ($r->[1] ne '') {
+               die "unknown condition \"", $r->[1], "\"\n";
+           }
+       }
+       $flag |= $CASEMAP_LAST_BIT if @data == 0;
+       push @result, $flag;
+       push @result, (ref $r) ? @{$r->[0]} : $r;
+       $result[-1] |= END_BIT;
+    }
+    @result;
+}
+
+#
+# read_casefolding_file -- read CaseFolding.txt
+#
+sub read_casefolding_file {
+    open FOLD, $casefoldingfile or die "cannto open $casefoldingfile: $!\n";
+
+    # dummy.
+    @folding_data = (0);
+
+    while ($_ = UCD::CaseFolding::getline(\*FOLD)) {
+       my %data = UCD::CaseFolding::parseline($_);
+
+       $folding->add($data{CODE}, scalar(@folding_data));
+       push @folding_data, @{$data{MAP}};
+       $folding_data[-1] |= END_BIT;
+    }
+    close FOLD;
+}
+
+sub print_header {
+    print <<"END";
+/* \$Id\$ */
+/* $myid */
+/*
+ * Do not edit this file!
+ * This file is generated from UnicodeData.txt, CompositionExclusions-1.txt,
+ * SpecialCasing.txt and CaseFolding.txt.
+ */
+
+END
+}
+
+#
+# print_canon_class -- generate data for canonical class
+#
+sub print_canon_class {
+    $canon_class->fix();
+    print STDERR "** cannon_class\n", $canon_class->stat() if $verbose;
+
+    print <<"END";
+
+/*
+ * Canonical Class
+ */
+
+END
+    print_bits("CANON_CLASS", @canon_class_bits);
+    print "\n";
+    print $canon_class->cprog(NAME => "${prefix}canon_class");
+}
+
+#
+# print_composition -- generate data for canonical composition
+#
+sub print_composition {
+    $comp->fix();
+    print STDERR "** composition\n", $comp->stat() if $verbose;
+
+    print <<"END";
+
+/*
+ * Canonical Composition
+ */
+
+END
+    print_bits("CANON_COMPOSE", @comp_bits);
+    print "\n";
+    print $comp->cprog(NAME => "${prefix}compose");
+    print <<"END";
+
+static const struct composition ${prefix}compose_seq[] = {
+END
+    my $i = 0;
+    foreach my $r (@comp_data) {
+       if ($i % 2 == 0) {
+           print "\n" if $i != 0;
+           print "\t";
+       }
+       printf "{ 0x%08x, 0x%08x }, ", $r->[2], $r->[0];
+       $i++;
+    }
+    print "\n};\n\n";
+}
+
+#
+# print_decomposition -- generate data for canonical/compatibility
+# decomposition
+#
+sub print_decomposition {
+    $decomp->fix();
+    print STDERR "** decomposition\n", $decomp->stat() if $verbose;
+
+    print <<"END";
+
+/*
+ * Canonical/Compatibility Decomposition
+ */
+
+END
+    print_bits("DECOMP", @decomp_bits);
+    print "#define DECOMP_COMPAT\t$DECOMP_COMPAT_BIT\n\n";
+
+    print $decomp->cprog(NAME => "${prefix}decompose");
+
+    print "static const unsigned long ${prefix}decompose_seq[] = {\n";
+    print_ulseq(@decomp_data);
+    print "};\n\n";
+}
+
+#
+# print_casemap -- generate data for case mapping
+#
+sub print_casemap {
+    $upper->fix();
+    $lower->fix();
+    print STDERR "** upper mapping\n", $upper->stat() if $verbose;
+    print STDERR "** lower mapping\n", $lower->stat() if $verbose;
+
+    print <<"END";
+
+/*
+ * Lowercase <-> Uppercase mapping
+ */
+
+/*
+ * Flags for special case mapping.
+ */
+#define CMF_FINAL      $CASEMAP_FINAL_BIT
+#define CMF_NONFINAL   $CASEMAP_NONFINAL_BIT
+#define CMF_LAST       $CASEMAP_LAST_BIT
+#define CMF_CTXDEP     (CMF_FINAL|CMF_NONFINAL)
+
+END
+    print_bits("CASEMAP", @casemap_bits);
+    print "\n";
+    print $upper->cprog(NAME => "${prefix}toupper");
+    print $lower->cprog(NAME => "${prefix}tolower");
+
+    print "static const unsigned long ${prefix}toupper_seq[] = {\n";
+    print_ulseq(@toupper_data);
+    print "};\n\n";
+
+    print "static const unsigned long ${prefix}tolower_seq[] = {\n";
+    print_ulseq(@tolower_data);
+    print "};\n\n";
+}
+
+#
+# print_casefolding -- generate data for case folding
+#
+sub print_casefolding {
+    $folding->fix();
+    print STDERR "** case folding\n", $folding->stat() if $verbose;
+
+    print <<"END";
+
+/*
+ * Case Folding
+ */
+
+END
+    print_bits("CASE_FOLDING", @folding_bits);
+    print "\n";
+    print $folding->cprog(NAME => "${prefix}case_folding");
+
+    print "static const unsigned long ${prefix}case_folding_seq[] = {\n";
+    print_ulseq(@folding_data);
+    print "};\n\n";
+}
+
+#
+# print_casemap_context -- gerarate data for determining context
+# (final/non-final)
+#
+sub print_casemap_context {
+    $casemap_ctx->fix();
+    print STDERR "** casemap context\n", $casemap_ctx->stat() if $verbose;
+
+    print <<"END";
+
+/*
+ * Cased characters and non-spacing marks (for casemap context)
+ */
+
+END
+
+    print_bits("CASEMAP_CTX", @casemap_ctx_bits);
+    print <<"END";
+
+#define CTX_CASED      $LETTER_BIT
+#define CTX_NSM                $NSPMARK_BIT
+
+END
+    print $casemap_ctx->cprog(NAME => "${prefix}casemap_ctx");
+}
+
+sub sprint_composition_hash {
+    my $i = 0;
+    my $s = '';
+    foreach my $r (@_) {
+       if ($i % 2 == 0) {
+           $s .= "\n" if $i != 0;
+           $s .= "\t";
+       }
+       $s .= sprintf "{0x%04x, 0x%04x, 0x%04x}, ", @{$r};
+       $i++;
+    }
+    $s;
+}
+
+sub print_bits {
+    my $prefix = shift;
+    my $i = 0;
+    foreach my $bit (@_) {
+       print "#define ${prefix}_BITS_$i\t$bit\n";
+       $i++;
+    }
+}
+
+sub print_ulseq {
+    my $i = 0;
+    foreach my $v (@_) {
+       if ($i % 4 == 0) {
+           print "\n" if $i != 0;
+           print "\t";
+       }
+       printf "0x%08x, ", $v;
+       $i++;
+    }
+    print "\n";
+}
diff --git a/contrib/idn/idnkit-1.0-src/win/README.WIN b/contrib/idn/idnkit-1.0-src/win/README.WIN
new file mode 100644 (file)
index 0000000..425200b
--- /dev/null
@@ -0,0 +1,17 @@
+To build idnkit for Windows, follow the instruction below.
+
+To build Windows version, you need `iconv' library.  A LGPL
+implemenation is available from the following place.
+
+    http://www.gnu.org/software/libiconv/
+
+Follow the instructions described in README.woe32 file which can be
+found in the distribution, and you'll get a DLL vesion of `libiconv'.
+Copy the DLL (iconv.dll), the header (iconv.h) and the import library
+(iconv.lib) here.
+
+Then go to the top directory and run the following command.
+
+       nmake -f make.wnt
+
+; $Id: README.WIN,v 1.1 2003/06/04 00:27:32 marka Exp $
diff --git a/contrib/idn/idnkit-1.0-src/wsock/README.txt b/contrib/idn/idnkit-1.0-src/wsock/README.txt
new file mode 100644 (file)
index 0000000..e7723b4
--- /dev/null
@@ -0,0 +1,665 @@
+
+    idn wrapper - Client Side IDN Conversion Software for Windows
+
+    Copyright (c) 2000,2001,2002 Japan Network Information Center.
+                All rights reserved.
+
+    *** NOTICE ******************************************************
+    If you have installed mDN Wrapper (former version of idn wrapper)
+    on your system, you should unwrap all the programs before
+    installing idn wrapper.
+    *****************************************************************
+
+
+1. Introduction
+
+    For supporting internationalized domain names, each client
+    application should convert domain names (their encodings) to that
+    DNS server accepts.  This requires applications to handle
+    internationalized domain names in its core, and it is the vendor's
+    responsibility to make their programs IDN-compatible.
+
+    Although there are ongoing efforts in IETF to standardize IDN
+    framework (architecture, encoding etc.) and several RFCs are
+    expected to be published soon as the result, not many applications
+    support IDN to this date.
+
+    So, there are needs for some helper application which makes legacy
+    applications IDN-aware.  `runidn' in idnkit is one of such
+    solutions for Unix-like operating systems, and this software, `idn
+    wrapper' is the one for Windows.
+
+    On windows, name resolving request is passed to WINSOCK DLL.  idn
+    wrapper replaces WINSOCK DLL with the one that can handle IDN,
+    which makes legacy windows applications compatible with IDN.
+
+2. Architecture
+
+2.1. Wrapper DLL
+
+    Wrapper DLL resides between application and original DLL.  It
+    intercept application's calls to original DLL, and preforms some
+    additional processing on those calls.
+
+    +------------+  Call  +------------+  Call  +------------+
+    |            |------->|            |------->|            |
+    |Application |        |Wrapper DLL |        |Original DLL|
+    |            |<-------|            |<-------|            |
+    +------------+ Return +------------+ Return +------------+
+                           additional
+                          processing
+                          here
+
+    DLL call from apllication is passed to wrapper DLL.  Wrapper DLL
+    then performs some additional processing on that call, and then
+    calls original DLL.  Also, result from original DLL will once passed
+    to wrapper DLL and wrapper does additional process on that result,
+    and finally result will passed to the application.
+
+    idn wrapper provides wrapper DLLs for WINSOCK,
+    
+        WSOCK32.DLL     WINSOCK V1.1
+       WS2_32.DLL      WINSOCK V2.0
+
+    to resolve multi-lingual domain names.
+
+2.2. Wrapping APIs
+
+    idn wrapper performs additional processing on name resolving APIs in
+    WINSOCK, listed below.
+
+    both WINSOCK 1.1, WINSOCK 2.0
+    
+        gethostbyaddr
+       gethostbyname
+       WSAAsyncGetHostByAddr
+       WSAAsyncGetHostByName
+       
+    only in WINSOCK 2.0
+    
+       getaddrinfo
+       freeaddrinfo
+       getnameinfo
+        WSALookupServiceBeginA
+       WSALookupServiceNextA
+       WSALookupServiceEnd
+
+    Some applications do not use these APIs to resolve domain names. 
+    `nslookup' is one of those programs. `nslookup' builds and parse DNS
+    messages internally and does not use WINSOCK's name resolver APIs.
+    idn wrapper cannot make those programs IDN-aware.
+    
+    NOTE:
+      WINSOCK 2.0 also contains WIDE-CHARACTER based name resolution
+      APIs,
+
+          WSALookupServiceBeginW
+          WSALookupServiceNextW
+
+      idn wrapper does not wrap these APIs.  These APIs are used in
+      Microsoft's own internationalization framework.  It is dangerous
+      to convert to another internationalization framework.
+    
+2.3. Other APIs in WINSOCK
+
+    For other APIs in WINSOCK, idn wrapper does nothing, only calls
+    original DLL's entries.
+
+    idn wrapper copies original WINSOCK DLLs with renaming
+    as below, and forward requests to them.
+
+        wsock32.dll     ->  wsock32o.dll
+       ws2_32.dll      ->  ws2_32o.dll
+
+    Wrappper DLL will be installed with original DLL names. So after
+    installation of idn wrapper, WINSOCK DLLs should be
+
+        wsock32.dll         idn wrapper for WINSOCK V1.1
+       ws2_32.dll          idn wrapper for WINSOCK V2.0
+       wsock32o.dll        Original WINSOCK V1.1 DLL
+       ws2_32o.dll         Original WINSOCK V2.0 DLL 
+
+2.4. Asynchronous API
+
+    Domain name conversion take place on
+    
+        request to DNS
+
+            convert from local encoding to DNS compatible encoding
+
+        response from DNS
+
+            convert from DNS encoding to local encoding
+
+    For synchronous APIs, local to DNS conversion is done before calling
+    original API, and after return from original API, name should be
+    converted from DNS encoding to local encoding.
+
+    But WINSOCK having some asynchronous APIs, such as
+
+       WSAAsyncGetHostByAddr
+       WSAAsyncGetHostByName
+
+    In these APIs, completion is notified with windows message.  To
+    perform DNS to local conversion, wrapper should hook target window
+    procedure to capture those completion messages.
+    
+    So, if asynchronous API was called, idn wrapper set hook to target
+    window procedure (passed with API parameter).  If hook found
+    notify message (also given with API parameter), then convert
+    resulting name (in DNS encoding) to local encoding.
+    
+2.5. Installing Wrapper DLLs
+
+    WINSOCK DLLs are placed at Windows's system directory.  To wrap
+    WINSOCK DLLs, one could do following sequence at system directory.
+
+        + Rename Original WINSOCK DLLs
+
+           ren wsock32.dll wsock32o.dll
+           ren ws2_32.dll  ws2_32o.dll
+
+        + Install (copy in) Wrapper DLLs
+
+           copy somewhere\wsock32.dll wsock32.dll
+           copy somewhere\ws2_32.dll  ws2_32.dll
+           copy another DLLs also
+
+    However, replacing DLLs in Window's system directory is very
+    dangerous:
+
+    a)  If you re-install idn wrapper again, original WINSOCK DLLs
+        may be lost.
+
+    b)  Some application or service pack will replace WINSOCK DLLs.  It
+        may corrupt WINSOCK environment.
+
+    If these happen, at least networking does not work, and worse,
+    Windows never startup again.
+
+    So, idn wrapper usually does not wrap in the system directory, but wrap in
+    each indivisual application's directory.
+
+    In Windows, DLL will be searched in the following places:
+    
+        Application's Load Directory
+       %SystemRoot%\System32
+       %SystemRoot%
+       Directories in PATH
+
+    and loaded & linked first found one.  So if installed wrapper DLLs is
+    found on application's load directory, the application's call to
+    WINSOCK will wrapped.
+
+    But some applications or DLLs are binded to specific DLL, they do
+    not rely on above DLL's search path.  For those applcaitons or DLLs,
+    idn wrapper (in standard installation) cannot wrap them.
+
+    NOTE:   Netscape is one of those program.  It cannot be wrapped if
+            installed to applications directory.  Also WINSOCK DLLs are
+            also binded to related DLLs in system directory.  On the
+            other hand, Internet Explore or Window Media Player relys on
+            standard DLL search path, and well wrapped with idn wrapper.
+
+2.6. At which point conversion applied
+
+    If windows supporting WINSOCK 2.0, there are DLLs one for 1.1 and
+    another for 2.0, and call to WINSOCK 1.1 will redirected to 2.0 DLL.
+
+        +------------+  Call  +------------+  Call  +------------+
+        |            |------->|            |------->|            |
+        |Application |        |WINSOCK 1.1 |        |WINSOCK 2.0 |
+        |            |<-------|            |<-------|            |
+        +------------+ Return +------------+ Return +------------+
+
+    In this case, calls to 1.1 and 2.0 are both passed to 2.0 DLL.  So
+    conversion will done in WINSOCK 2.0 DLL side.
+
+    If windows only supports WINSOCK 1.1, there's 1.1 DLL only.
+
+        +------------+  Call  +------------+
+        |            |------->|            |
+        |Application |        |WINSOCK 1.1 |
+        |            |<-------|            |
+        +------------+ Return +------------+
+
+    In this case, conversion must done in 1.1 DLL.
+
+    If idn wrapper was installed on system directory, DLLs will work as
+    described above.  But if wrapper was installed on application's
+    directory, call/return sequence changes.  Original WINSOCK 1.1 DLL
+    in windows seems binded to specific WINSOCK 2.0 DLL, placed at
+    window's system diretory.  So call from WINSOCK 1.1 to WINSOCK 2.0
+    will passed to original DLL (in system directory) and never passed
+    to wrapper DLL in application's directory.  So in this case, both
+    1.1 and 2.0 DLLs should coonvert domain name encodings.
+    
+    These DLL binding is not documented.  It may be change on OS
+    versions or DLL versions.  So, mDn wrapper determines place of
+    conversion on registry value.  With this registry value, idn
+    wrappper absolb OS/DLL variations.
+    
+    Registry values for idn wrapper will placed under
+
+        HKEY_LOCAL_MACHINE\SOFTWARE\JPNIC\IDN
+       HKEY_CURRENT_USER\SOFTWARE\JPNIC\IDN
+
+    Place of conversion is determined with registry value "Where",
+    
+        Registry Value "Where"   REG_DWORD
+           
+           0       both on WINSOCK 1.1 and WINSOCK 2.0
+           1       if WINSOCK 2.0 exist, only in WINSOCK 2.0
+                   otherwise, convert on WINSOCK 1.1
+            2       only in WINSOCK 1.1
+           3       only in WINSOCK 2.0
+
+    If you install idn wrapper into application's directory, use "0".
+    If you install idn wrapper into system directory, use "1".  If there
+    are no "Where" value, idn wrapper uses "0" as default, it is suited
+    to installation into application's directory (default installation).
+
+2.7. Converting From/To
+
+    Wrapper DLL convert resolving domain name encoded with local code to
+    DNS server's encoding.  Also, wrapper DLL convert resulting name (
+    encoded with DNS's encoding) back to local encoding.
+    
+    There are several proposals for DNS encodings to handle multi-lingual
+    domain names.  Wrapper DLL should be configured to convert to one of
+    those encodings.  This DNS side encoding will specified with
+    registry.  When installing idn wrapper, this registry will set to
+    some (yet undefined) DNS encoding.
+    
+    Registry values for idn wrapper will placed under
+
+        HKEY_LOCAL_MACHINE\SOFTWARE\JPNIC\IDN
+       HKEY_CURRENT_USER\SOFTWARE\JPNIC\IDN
+
+    DNS encoding name will given with registry value (REG_SZ) of "Encoding",
+    this name must be one of encoding names which 'libmdn' recognize.
+
+        Registry Value "Encoding"   REG_SZ
+       
+           Encoding name of DNS server accepts.
+    
+    Local encodings (Windows Apllication Encodings) is generally
+    acquired from process's code page.  'iconv' library, used for idn
+    wrapper, generally accepts MS's codepage names.
+
+    Some windows apllication encode domain name with some specific multi-
+    lingual encoding. For example, if you configured IE to use UTF-8,
+    then domain names are encoded with UTF-8. UTF-8 is one of proposed
+    DNS encoding, but DNS server may expect another encoding.
+    
+    For those cases, idn wrapper accept program specific encoding as
+    local encoding.  These program specific local encoding should be
+    marked in registry.
+    
+    Program specific registry setting will placed under
+
+        HKEY_LOCAL_MACHINE\SOFTWARE\JPNIC\IDN\PerProg
+       HKEY_CURRENT_USER\SOFTWARE\JPNIC\IDN\PerProg
+    
+    using program name (executable file name) as key.  For example,
+    setting specific to Internet Explore, it executable name is 
+    "IEXPLORE", will plcaed at
+
+        HKEY_LOCAL_MACHINE\SOFTWARE\JPNIC\IDN\PerProg\IEXPLORE
+
+    Local encoding name will specified with registry value (REG_SZ) of 
+    "Encoding".  This name must be one of encoding names which '
+    recognize.libmdn'
+
+        Registry Value "Encoding"   REG_SZ
+       
+           Encoding name of application program encodes, if it is not
+            system's default encoding.
+
+3. Setup and Configuration
+
+    idn wrapper wraps WINSOCK DLL by placing wrapper (fake) DLLs in
+    the application's directory.  For the installation, idn wrapper
+    comes with a setup program and a configuration program.
+
+    NOTE:   You can also install idn wrapper DLLs in the Windows
+            system directory.  But this installation is very dangerous
+           and may cause severe problems in your system.
+           You should try it at your own risk.
+
+3.1. Setup Program
+
+    To install idn wrapper, run "setup.exe".  Setup program will do:
+    
+    Installing Files
+    
+        Copy idn wrapper files (DLL, Program EXE, etc) into diretory
+       
+           "\Program Files\JPNIC\idn wrapper"
+
+        This directory may be changed on setup sequence.
+
+    Setting registry entries
+
+        Setup program will create keys and values under registry:
+       
+           "HKEY_LOCAL_MACHINES\Software\JPNIC\IDN"
+
+       InstallDir      REG_SZ  "<installation directory>"
+           Pathname of the idn wrapper's installation directory.
+           The installer makes copies of the original WINSOCK DLLs
+           in that directory, which is referenced by the idn wrapper's
+           fake DLLs.
+    
+        ConfFile        REG_SZ  "<installation directory>\idn.conf"
+           Name of the idnkit's configuration file, which defines
+           various parameter regarding multilingual domain name
+           handling.  See the contents of the file for details.
+            This value can be changed with the Configuration Program
+           or the registry editor.
+
+       LogFile         REG_SZ  "<installation directory>\idn_wrapper.log"
+           Name of the idn wrapper's log file.
+            This value can be changed with the Configuration Program
+           or the registry editor.
+
+       LogLevel        DWORD   -1
+           Logging level.  Default is -1, which indicates no logging
+           is made.  This value can be changed with the Configuration
+           Program or the registry editor.
+
+        PerProg         KEY
+       
+           Under this key, idn wrapper set program specific values. idn
+            wrapper uses program's executable name as key, and put
+            values under that key.
+           
+           PerProg\<progname>\Where    REG_DWORD Encoding Position
+           PerProg\>progname>\Encoding REG_SZ    Local Encoding Name
+
+            Configuration program set local encpoding name.  "Where"
+            value is usually not required in standard installation.  If
+            you installed idn wrapper in system directory, chanage
+            "Where" values to fit your environment.
+
+    Creating ICON
+    
+        Setup program will create program icon for idn wrapper's
+        configuration program, and put it into "Start Menu".  You can
+        start configuration program with it.
+          
+3.2. Configuration Program
+
+    Configuration program is a tool for wrap specific program, or unwrap
+    programs.  If you start "Configuration Program", you'll get window
+    like this.
+
+    +---+-------------------------------------------------+---+---+---+
+    |   | idn wrapper - Configuration                     | _ | O | X |
+    +---+-------------------------------------------------+---+---+---+
+    |          idn wrapper Configuration Program version X.X          |
+    +-----------------------------------------------------------------+
+    |                  Wrapped Program                    +---------+ |
+    | +---------------------------------------------+---+ | Wrap..  | |
+    | |                                             | A | +---------+ |
+    | |                                             +---+ +---------+ |
+    | |                                             |   | | Unwrap..| |
+    | |                                             |   | +---------+ |
+    | |                                             |   | +---------+ |
+    | |                                             |   | |UnwrapAll| |
+    | |                                             |   | +---------+ |
+    | |                                             |   | +---------+ |
+    | |                                             |   | |RewrapAll| |
+    | |                                             |   | +---------+ |
+    | |                                             |   | +---------+ |
+    | |                                             |   | |  Log..  | |
+    | |                                             |   | +---------+ |
+    | |                                             |   | +---------+ |
+    | |                                             +---+ |Advanced.| |
+    | |                                             | V | +---------+ |
+    | +---+-------------------------------------+---+---+ +---------+ |
+    | | < |                                     | > |     |  Exit   | |
+    | +---+-------------------------------------+---+     +---------+ |
+    +-----------------------------------------------------------------+
+
+    Listbox contains list of current wrapped programs.  Initially it is
+    empty.  
+    
+    To wrap a program, press button "wrap".  You'll get following dialog.
+    
+    +---+-------------------------------------------------+---+---+---+
+    |   | idn wrapper - Wrap Executable                   | _ | O | X |
+    +---+-------------------------------------------------+---+---+---+
+    |           +----------------------------------------+ +--------+ |
+    |  Program: |                                        | |Browse..| |
+    |           +----------------------------------------+ +--------+ |
+    |           +----------+                                          |
+    | Encoding: |          |  o Default  o UTF-8                      |
+    |           +----------+                                          |
+    |           [] Force local DLL reference                          |
+    +-----------------------------------------------------------------+
+    |                                           +--------+ +--------+ |
+    |                                           |  Wrap  | | Cancel | |
+    |                                           +--------+ +--------+ |
+    +-----------------------------------------------------------------+
+
+    First, enter program (executable name with full path) or browse
+    wrapping exectable from file browser. Then set local encoding of
+    that program.  Usually use "Default" as local encoding. If target
+    program uses internationalized encoding, then specify "UFT-8". 
+
+    The "Force local DLL reference" button controls the DLL search
+    order of the program to be wrapped (Windows95 does not have this
+    capability, hence this button does not appear).  If it is checked,
+    DLLs in the local directory (the directory which the executable
+    file is in) are always preferred, even if the executable specifies
+    otherwise.  If you have problem with wrapping, checking this
+    button may solve the problem, but it is also possible that it
+    causes other problem.
+
+    Finally, put "wrap" button to wrap specified program with given
+    encoding. Wrapped program will be listed in listbox of the first
+    window.
+
+    When you install a new version of idn wrapper, you have to re-wrap
+    your programs in order to update DLLs used for wrapping.  "Rewrap
+    all" button is provided for this purpose.  Just press the button,
+    and all the currently wrapped programs will be re-wrapped.
+
+    To unwrap a program, press button "unwrap".  You'll get following 
+    confirmating dialog.
+    
+    +---+-------------------------------------------------+---+---+---+
+    |   | idn wrapper - Unwrap Executable                 | _ | O | X |
+    +---+-------------------------------------------------+---+---+---+
+    |           +---------------------------------------------------+ |
+    | Program:  |                                                   | |
+    |           +---------------------------------------------------+ |
+    +-----------------------------------------------------------------+
+    |                                           +--------+ +--------+ |
+    |                                           | Unwrap | | Cancel | |
+    |                                           +--------+ +--------+ |
+    +-----------------------------------------------------------------+
+
+    If you unwrap a program, the program will be vanished from listbox
+    of the first window.
+
+    Also "Unwrap all" button is provided to unwrap all the programs
+    that are currently wrapped.
+
+    To configure logging, press button "log".  You'll get the following
+    dialog.
+
+    +---+-------------------------------------------------+---+---+---+
+    |   | idn wrapper - Log Configuration                 | _ | O | X |
+    +---+-------------------------------------------------+---+---+---+
+    |    Log Level: o None o Fatal o Error o Warning o Info o Trace   |
+    |                                                                 |
+    |              +------------------------------------+ +---------+ |
+    |     Log File:|                                    | | Browse..| |
+    |              +------------------------------------+ +---------+ |
+    |               +------+ +--------+                               |
+    |Log Operation: | View | | Delete |                               |
+    |               +------+ +--------+                               |
+    +-----------------------------------------------------------------+
+    |                                           +--------+ +--------+ |
+    |                                           |   OK   | | Cancel | |
+    |                                           +--------+ +--------+ |
+    +-----------------------------------------------------------------+
+
+    Logging level can be selected from the followings.
+       None    no logging at all
+       Fatal   only records fatal errors
+       Error   also records non-fatal errors
+       Warning also records warning mssages
+       Info    also records informational messages
+       Trace   also records trace information
+    Note that these levels are for log output from IDN library (idnkit.dll).
+    idn wrapper itself supports only off (None) and on (the rest).
+
+    Pathname of the log file can also be specified with this dialog.
+
+    You can view the current log file contents by pressing "View" button,
+    or delete it by "Delete" button.
+
+    Note that log level and log file configuration doesn't affect already
+    running processes.
+
+    Press "advanced" button to invoke the advanced configuration dialog.
+    This dialog is for advanced users and enables customization for
+    some basic parameters which normal users need not change, since
+    appropriate defaults are provided.
+
+    +---+-------------------------------------------------+---+---+---+
+    |   | idn wrapper - Advanced Configuration            | _ | O | X |
+    +---+-------------------------------------------------+---+---+---+
+    |                    IDN Wrapping Mode                            |
+    |  o Wrap both WINSOCK 1.1 and WINSOCK 2.0                        |
+    |  o Wrap only WINSOCK 1.1                                        |
+    |  o Wrap only WINSOCK 2.0                                        |
+    |  o Wrap only WINSOCK 2.0 if it exists.                          |
+    |    Otherwise wrap only WINSOCK 1.1                              |
+    +-----------------------------------------------------------------+
+    |                       IDN Configuration                         |
+    |               +--------------------------------+ +----------+   |
+    |  Config File: |                                | | Browse.. |   |
+    |               +--------------------------------+ +----------+   |
+    |               +------+                                          |
+    |               | Edit |                                          |
+    |               +------+                                          |
+    +-----------------------------------------------------------------+
+    |                                           +--------+ +--------+ |
+    |                                           |   OK   | | Cancel | |
+    |                                           +--------+ +--------+ |
+    +-----------------------------------------------------------------+
+
+    With the dialog users can do the following configuration.
+
+    Wrapping Mode
+       Customize wrapping mode.  Normally the default item should be
+       appropriate.  Changing it to other item may help when you
+       have problems.
+
+    IDN Configuration
+       Set the configuration file for multilingual domain name handling.
+       By pressing "Edit" button, you can edit then contents of the file.
+
+4. Limitations
+
+4.1. DLL Versions
+
+    Wrapper DLL is tightly coupled with specific DLL version, because
+    it must export all the entries including un-documented ones.
+    If WINSOCK DLL version changed, idn wrapper may not work correctly.
+
+    Current idn wrapper is tested on
+    
+        Win2000         (WINSOCK 1.1 + 2.0)
+        WinME           (WINSOCK 1.1 + 2.0)
+
+    But there are no assuarance for future versions of Windows.
+
+4.2. DNS, WINS, LMHOSTS
+
+    There are three name resolving methods in windows, DNS, WINS and
+    LMHOSTS. Using idn wrapper, domain name conversion will performed 
+    on all of thoses methods.  It may cause some trouble if windows 
+    using WINS or LMHOSTS.  We recommend use DNS oly if you want to use
+    idn wrapper.
+
+4.3. Converting Names other than Domain Name
+
+    In WINSOCK 2.0, there are generic name resolution APIs are
+    introduced.
+    
+        WSALookupServiceBeginA
+       WSALookupServiceNextA
+       WSALookupServiceEnd
+
+    They are use mainly domain name conversion now, but not limited to
+    resolving domain name.  idn wrapper hooks this API and convert
+    given name anyway.  This causes some trouble if conversion name is
+    not domain name.
+
+4.4. Applications don't use these APIa
+
+    Some applications don't use these APIs to resolving domain names.
+    For example, 'nslookup' issue DNS request locally.  For these
+    applications, idn wrapper does not work.
+
+4.5. Applications bound to specific WINSOCK DLL
+
+    Some applications are bound to specific DLL, not relying on
+    standard DLL search path. Netscape Communicator seems to be one of
+    such programs.  idn wrapper in standard installation cannot wrap
+    such programs.
+    
+    If you want to wrap those programs, you may use installation into
+    system directory.  But this installation is very dangerous, for
+    it is possible that your system cannot boot again.
+
+5. Registry Setting - Summary
+
+5.1. Priority of Setting
+
+    Settings of idn wrapper is placed on registry 
+    
+        Software\JPNIC\IDN
+       
+    under HKEY_LOCAL_MACHINE or HKEY_CURRENT_USER.  idn wrapper first
+    read HKEY_LOCAL_MACHINE, and if HKEY_CURRENT_USER exist, overwrite
+    with this one.  Usually set HKEY_LOCAL_MACHINE only.  But if you
+    need per user setting, then set HKEY_CURRENT_USER.
+
+    Note that the configuration program reads/writes only
+    HKEY_LOCAL_MACHINE.
+
+5.2. Registry Key
+
+    There's common settings and per program settings.
+    
+_Common Settings
+
+       Software\JPNIC\IDN\InstallDir    Installation directory
+        Software\JPNIC\IDN\Where         Where to convert encoding
+                           0: both WINSOCK 1.1 and WINSOCK 2.0
+                            1: if WINSOCK 2.0 exist, convert at 2.0 DLL
+                               if WINSOCK 1.1 only, convert at 1.1 DLL
+                           2: only in WINSOCK1.1
+                           3: only in WINSOCK2.0
+        Software\JPNIC\IDN\ConfFile     idnkit Configuration File
+        Software\JPNIC\IDN\LogFile       Log File
+        Software\JPNIC\IDN\LogLevel      Log Level
+
+_Per Program Settings
+
+    Converting position and program's local encoding may be set per
+    program bases.
+
+        Software\JPNIC\IDN\PerProg\<name>\Where
+        Software\JPNIC\IDN\PerProg\<name>\Encoding
+
+    If not specified, the following values are assumed.
+    
+        Where       0 (both 1.1 DLL and 2.0 DLL)
+       Encoding    [process's code page]
diff --git a/contrib/idn/idnkit-1.0-src/wsock/README_j.txt b/contrib/idn/idnkit-1.0-src/wsock/README_j.txt
new file mode 100644 (file)
index 0000000..354f46c
--- /dev/null
@@ -0,0 +1,717 @@
+
+    idn wrapper - Windows \82É\82¨\82¯\82é\83N\83\89\83C\83A\83\93\83g\91¤\82Å\82Ì IDN \95Ï\8a·\83\\83t\83g\83E\83F\83A
+
+    Copyright (c) 2000,2001,2002 Japan Network Information Center.
+                All rights reserved.
+
+    *** \92\8d\88Ó **********************************************************
+    \82à\82µ\82à\82·\82Å\82É mDN Wrapper (idn wrapper \82Ì\91O\90g) \82ª\83C\83\93\83X\83g\81[\83\8b\82³\82ê\82Ä
+    \82¢\82é\83}\83V\83\93\82É idn wrapper \82ð\83C\83\93\83X\83g\81[\83\8b\82·\82é\8fê\8d\87\82É\82Í\81A\83C\83\93\83X\83g\81[\83\8b\91O
+    \82É\81A\83\89\83b\83v\82³\82ê\82Ä\82¢\82é\82·\82×\82Ä\82Ì\83v\83\8d\83O\83\89\83\80\82ð\83A\83\93\83\89\83b\83v\82µ\82Ä\82­\82¾\82³\82¢\81B
+    *******************************************************************
+
+
+1. \82Í\82\82ß\82É
+
+    Windows \82Å\8d\91\8dÛ\89»\83h\83\81\83C\83\93\96¼\82ð\88µ\82¦\82é\82æ\82¤\82É\82·\82é\82½\82ß\82É\82Í\81AWindows \8fã\82Ì
+    \83N\83\89\83C\83A\83\93\83g\83A\83v\83\8a\83P\81[\83V\83\87\83\93\82É\82¨\82¢\82Ä\81A\89ð\8c\88\82µ\82æ\82¤\82Æ\82·\82é\96¼\91O\82Ì\83G\83\93\83R\81[
+    \83f\83B\83\93\83O\82ð\81ADNS \83T\81[\83o\82ª\8eó\95t\82¯\82é\8c`\8e®\82Ì\82à\82Ì\82É\95Ï\8a·\82·\82é\95K\97v\82ª\82 \82è\82Ü\82·\81B
+    \82±\82ê\82Í\81AWindows \8fã\82Ì\83A\83v\83\8a\83P\81[\83V\83\87\83\93\82ª\81A\82«\82¿\82ñ\82Æ\8d\91\8dÛ\89»\83h\83\81\83C\83\93\96¼\82ð
+    \88µ\82¦\82é\82æ\82¤\82É\82È\82Á\82Ä\82¢\82È\82¯\82ê\82Î\82È\82ç\82È\82¢\81A\82Æ\82¢\82¤\82±\82Æ\82Å\82 \82è\81A\96{\97\88\82Í\82»\82ê
+    \82¼\82ê\82Ì\83v\83\8d\83O\83\89\83\80\82Ì\8dì\90¬\8eÒ\82ª\8ds\82È\82¤\82×\82«\82±\82Æ\82Å\82·\81B
+    
+    \8c»\8dÝ IETF \82É\82Ä\8d\91\8dÛ\89»\83h\83\81\83C\83\93\96¼\82Ì\83t\83\8c\81[\83\80\83\8f\81[\83N\82ð\95W\8f\80\89»\82·\82é\93w\97Í\82ª\91±
+    \82¯\82ç\82ê\82Ä\82¨\82è\81A\82»\82Ì\8c\8b\89Ê\82Æ\82µ\82Ä\88ê\98A\82Ì RFC \82ª\82à\82¤\82·\82®\94­\8ds\82³\82ê\82é\82±\82Æ\82É
+    \82È\82Á\82Ä\82¢\82Ü\82·\82ª\81A\82»\82ê\82Å\82à\8d\91\8dÛ\89»\83h\83\81\83C\83\93\96¼\82É\91Î\89\9e\82µ\82½\83A\83v\83\8a\83P\81[\83V\83\87\83\93
+    \82Í\82Ü\82¾\82Ü\82¾\8f­\82È\82¢\82Ì\82ª\8c»\8fó\82Å\82·\81B
+
+    \82»\82±\82Å\81A\8aù\91\82Ì\83A\83v\83\8a\83P\81[\83V\83\87\83\93\82ð\8d\91\8dÛ\89»\83h\83\81\83C\83\93\96¼\82É\91Î\89\9e\82³\82¹\82é\82½\82ß\82Ì
+    \83w\83\8b\83p\81[\83A\83v\83\8a\83P\81[\83V\83\87\83\93\82ª\95K\97v\82É\82È\82è\82Ü\82·\81Bidnkit \82É\8aÜ\82Ü\82ê\82é runidn 
+    \83R\83}\83\93\83h\82Í Unix \8cn\82Ì OS \82Å\82Ì\88ê\82Â\82Ì\89ð\8c\88\8dô\82Å\82·\82µ\81AWindows \82É\91Î\82·\82é\89ð
+    \8c\88\8dô\82Æ\82µ\82Ä\82Í\82±\82±\82Å\90à\96¾\82·\82é idn wrapper \82ª\82 \82è\82Ü\82·\81B
+    
+    Windows \82É\82¨\82¢\82Ä\81A\91½\82­\82Ì\8fê\8d\87\81A\83h\83\81\83C\83\93\96¼\89ð\8c\88\82Ì\97v\8b\81\82ÍWINSOCK DLL \82É
+    \93n\82³\82ê\82Ü\82·\81B\82»\82±\82Å\81AWINSOCK DLL \82ð\8d\91\8dÛ\89»\83h\83\81\83C\83\93\96¼\91Î\89\9e\82Ì\82à\82Ì\82É\92u\82«
+    \8a·\82¦\82Ä\82â\82ê\82Î\81A\8aù\91\82Ì\83v\83\8d\83O\83\89\83\80\82©\82ç\82Å\82à\8d\91\8dÛ\89»\83h\83\81\83C\83\93\96¼\82ð\8eg\82¤\82±\82Æ\82ª
+    \82Å\82«\82é\82æ\82¤\82É\82È\82è\82Ü\82·\81B
+
+2. \8eÀ\8c»\95û\96@
+
+2.1. \83\89\83b\83p\81[DLL
+
+    \83\89\83b\83p\81[DLL \82Í\81A\83A\83v\83\8a\83P\81[\83V\83\87\83\93\82Æ\8c³\82ÌDLL \82Æ\82Ì\8aÔ\82É\8a\84\82è\8d\9e\82ñ\82Å\81A\83A\83v\83\8a
+    \83P\81[\83V\83\87\83\93\82©\82ç\82ÌDLL \82Ì\8cÄ\82Ñ\8fo\82µ\82ð\89¡\8eæ\82è\82µ\82Ä\81A\96{\97\88\82ÌDLL \82Æ\82Í\88Ù\82È\82Á\82½\8f\88
+    \97\9d\82ð\82³\82¹\82é\82à\82Ì\82Å\82·\81B
+
+    +------------+  Call  +------------+  Call  +------------+
+    |            |------->|            |------->|            |
+    |Application |        |Wrapper DLL |        |Original DLL|
+    |            |<-------|            |<-------|            |
+    +------------+ Return +------------+ Return +------------+
+                           additional
+                          processing
+                          here
+
+    \83A\83v\83\8a\83P\81[\83V\83\87\83\93\82©\82ç\82ÌDLL \82Ì\8cÄ\82Ñ\8fo\82µ\82Í\83\89\83b\83p\81[ DLL\82É\93n\82³\82ê\82Ü\82·\81B\83\89\83b
+    \83p\81[ DLL\82Í\82»\82±\82Å\81A\95t\89Á\93I\82È\8f\88\97\9d\82ð\8ds\82È\82Á\82Ä\81A\8c³\82ÌDLL \82Ì\83G\83\93\83g\83\8a\82ð\8cÄ\82Ñ\8fo
+    \82µ\82Ü\82·\81B\82Ü\82½\81A\8c³\82ÌDLL \82Ì\8f\88\97\9d\8c\8b\89Ê\82Í\88ê\92U\83\89\83b\83p\81[ DLL\82É\95Ô\82³\82ê\81A\82±\82±\82Å\82à
+    \95t\89Á\93I\82È\8f\88\97\9d\82ð\8ds\82È\82Á\82Ä\81A\8dÅ\8fI\93I\82È\8c\8b\89Ê\82ª\83A\83v\83\8a\83P\81[\83V\83\87\83\93\82É\95Ô\82³\82ê\82é\82±\82Æ
+    \82É\82È\82è\82Ü\82·\81B
+
+    idn wrapper \82Å\82Í\81AWINSOCK DLL\82Ì
+    
+        WSOCK32.DLL     WINSOCK V1.1
+       WS2_32.DLL      WINSOCK V2.0
+
+    \82É\91Î\82·\82é\83\89\83b\83p\81[DLL \82ð\92ñ\8b\9f\82µ\82Ä\81A\8d\91\8dÛ\89»\83h\83\81\83C\83\93\96¼\82Ì\96¼\91O\89ð\8c\88\82ª\82Å\82«\82é\82æ
+    \82¤\82É\82µ\82Ü\82·\81B16\83r\83b\83g\94Å\82ÌWINSOCK (WINSOCK.DLL) \82Í\91Î\8fÛ\8aO\82Å\82·\81B
+
+2.2. \8f\88\97\9d\91Î\8fÛ\82ÌAPI
+
+    idn wrapper \82ÍWINSOCK \82Ì\96¼\91O\89ð\8c\88\82É\8aÖ\98A\82µ\82½API \82É\82Â\82¢\82Ä\82Ì\82Ý\95t\89Á\93I\82È\8f\88
+    \97\9d\82ð\8ds\82È\82¢\82Ü\82·\81B\8f\88\97\9d\82Ì\91Î\8fÛ\82Æ\82È\82éWINSOCK API\82Í\88È\89º\82Ì\82à\82Ì\82Å\82·\81B
+
+    WINSOCK 1.1, WINSOCK 2.0 \82Ì\97¼\95û\82É\82 \82é\82à\82Ì
+    
+        gethostbyaddr
+       gethostbyname
+       WSAAsyncGetHostByAddr
+       WSAAsyncGetHostByName
+       
+    WINSOCK 2.0 \82¾\82¯\82É\82 \82é\82à\82Ì
+    
+        WSALookupServiceBeginA
+       WSALookupServiceNextA
+       WSALookupServiceEnd
+
+    \83A\83v\83\8a\83P\81[\83V\83\87\83\93\82É\82æ\82Á\82Ä\82Í\81A\82±\82ê\82ç\82ÌAPI \82ð\8eg\82í\82È\82¢\82Å\93Æ\8e©\82É\83h\83\81\83C\83\93\96¼
+    \82Ì\89ð\8c\88\82ð\8ds\82È\82¤\82à\82Ì\82à\82 \82è\82Ü\82·\81B\97á\82¦\82Î\81Anslookup\82Í\81A\82±\82ê\82ç\82ÌAPI \82ð\8eg\82í
+    \82È\82¢\82Å\81A\93à\95\94\82Å\93Æ\8e©\82ÉDNS \83\8a\83N\83G\83X\83g\82Ì\90\90¬\81A\89ð\8eß\82ð\8ds\82È\82Á\82Ä\82¢\82Ü\82·\81B\93\96\91R
+    \82Ì\82±\82Æ\82È\82ª\82ç\81A\82±\82ê\82ç\82Ì\83A\83v\83\8a\83P\81[\83V\83\87\83\93\82É\82Â\82¢\82Ä\82Í\81Aidn wrapper \82Å\82Í\91½
+    \8c¾\8cê\89»\91Î\89\9e\82³\82¹\82é\82±\82Æ\82Í\82Å\82«\82Ü\82¹\82ñ\81B
+    
+    \92\8d\81FWINSOCK 2.0 \82É\82Í\81AWIDE CHARACTER \83x\81[\83X\82Ì\96¼\91O\89ð\8c\88\82ÌAPI \82Æ\82µ\82Ä
+
+            WSALookupServiceBeginW
+            WSALookupServiceNextW
+    
+        \82à\82 \82è\82Ü\82·\82ª\81A\82±\82ê\82ç\82É\82Â\82¢\82Ä\82Í\83\89\83b\83v\82µ\82Ü\82¹\82ñ\81B\82±\82ê\82ç\82ÌAPI \82Í\83}
+        \83C\83N\83\8d\83\\83t\83g\8ed\97l\82É\82æ\82é\8d\91\8dÛ\89»\82É\91Î\89\9e\82µ\82½\82à\82Ì\82Å\82·\82©\82ç\81A\82»\82Ì\83t\83\8c\81[
+        \83\80\83\8f\81[\83N\8fã\82Å\8eg\82¤\82×\82«\82à\82Ì\82Å\82·\81B\82±\82ê\82ç\82É\82Â\82¢\82Ä\82Í\91¼\82Ì\91½\8c¾\8cê\89»\83t\83\8c\81[
+        \83\80\83\8f\81[\83N\82É\95Ï\8a·\82µ\82Ä\82µ\82Ü\82¤\82Ì\82Í\8aë\8c¯\82Å\82Í\82È\82¢\82Æ\94»\92f\82µ\82Ü\82µ\82½\81B
+
+2.3. \8f\88\97\9d\91Î\8fÛ\8aO\82ÌAPI
+
+    \8fã\8bL\88È\8aO\82ÌWINSOCK API \82É\82Â\82¢\82Ä\82Í\81Aidn wrapper \82Í\82È\82É\82à\82µ\82È\82¢\82Å\81A\8c³\82Ì
+    WINSOCK API \82ð\8cÄ\82Ñ\8fo\82µ\82Ü\82·\81B
+
+    idn wrapper \82Å\82Í\81A\8c³\82ÌWINSOCK DLL \82ð\96¼\91O\82ð\95Ï\82¦\82Ä\83R\83s\81[\82µ\81A\82»\82ê\82ð
+    \8cÄ\82Ñ\8fo\82·\82æ\82¤\82É\8dì\82ç\82ê\82Ä\82¢\82Ü\82·\81B
+    
+        wsock32.dll     ->  wsock32o.dll
+       ws2_32.dll      ->  ws2_32o.dll
+
+    \83\89\83b\83p\81[DLL \82Í\8c³\82ÌWINSOCK DLL \82Æ\93¯\82\96¼\91O\82Å\8dì\90¬\82³\82ê\82Ü\82·\81B\8f]\82Á\82Äidn
+    wrapper \82ª\83C\83\93\83X\83g\81[\83\8b\82³\82ê\82½\8fó\91Ô\82Å\82Í\81A
+    
+        wsock32.dll         idn wrapper for WINSOCK V1.1
+       ws2_32.dll          idn wrapper for WINSOCK V2.0
+       wsock32o.dll        Original WINSOCK V1.1 DLL
+       ws2_32o.dll         Original WINSOCK V2.0 DLL 
+
+    \82Æ\82È\82è\82Ü\82·\81B
+
+2.4. \94ñ\93¯\8aú API
+
+    \83h\83\81\83C\83\93\96¼\82Ì\95Ï\8a·\82Í\81A\88È\89º\82Ì\83^\83C\83~\83\93\83O\82Å\8ds\82È\82í\82ê\82é\95K\97v\82ª\82 \82è\82Ü\82·\81B
+
+        DNS \82Ö\82Ì\83\8a\83N\83G\83X\83g\8e\9e
+       
+            \83\8d\81[\83J\83\8b\83G\83\93\83R\81[\83f\83B\83\93\83O -> DNS \83G\83\93\83R\81[\83f\83B\83\93\83O
+
+        DNS \82©\82ç\82Ì\89\9e\93\9a\8eó\90M\8e\9e
+
+            DNS \83G\83\93\83R\81[\83f\83B\83\93\83O -> \83\8d\81[\83J\83\8b\83G\83\93\83R\81[\83f\83B\83\93\83O
+
+    \93¯\8aúAPI \82É\82¨\82¢\82Ä\82Í\81A\83\8d\81[\83J\83\8b\83G\83\93\83R\81[\83f\83B\83\93\83O\82©\82çDNS \83G\83\93\83R\81[\83f\83B\83\93\83O
+    \82Ö\82Ì\95Ï\8a·\82Í\81A\8c³\82ÌAPI \82ð\8cÄ\82Ñ\8fo\82·\91O\82É\8ds\82í\82ê\81ADNS \83G\83\93\83R\81[\83f\83B\83\93\83O\82©\82ç\83\8d\81[
+    \83J\83\8b\83G\83\93\83R\81[\83f\83B\83\93\83O\82Ö\82Ì\95Ï\8a·\82Í\81A\8c³\82ÌAPI \82©\82ç\95\9c\8bA\82µ\82Ä\82«\82½\82Æ\82±\82ë\82Å\8ds\82È
+    \82í\82ê\82Ü\82·\81B
+
+    \82µ\82©\82µ\81AWINSOCK \82Ì\88È\89º\82ÌAPI \82Í\94ñ\93¯\8aúAPI \82Å\81ADNS \82©\82ç\82Ì\89\9e\93\9a\8eó\90M\91O\82É\95\9c
+    \8bA\82µ\82Ä\82µ\82Ü\82¢\82Ü\82·\81B
+
+       WSAAsyncGetHostByAddr
+       WSAAsyncGetHostByName
+
+    \82±\82ê\82ç\82ÌAPI \82É\82¨\82¢\82Ä\82Í\81A\96¼\91O\89ð\8c\88\82Ì\8a®\97¹\82Í\81AWindows \82Ö\82Ì\83\81\83b\83Z\81[\83W\82É\82æ\82Á
+    \82Ä\92Ê\92m\82³\82ê\82Ü\82·\81B\82±\82Ì\82½\82ß\81ADNS \83G\83\93\83R\81[\83f\83B\83\93\83O\82©\82ç\83\8d\81[\83J\83\8b\83G\83\93\83R\81[\83f\83B\83\93
+    \83O\82Ö\82Ì\95Ï\8a·\82ð\8ds\82È\82¤\82É\82Í\81A\83\89\83b\83p\81[\82Í\92Ê\92m\90æ\82Ì\83E\83B\83\93\83h\83E\83v\83\8d\83V\83W\83\83\82Ì\83\81\83b
+    \83Z\81[\83W\83L\83\85\81[\82ð\83t\83b\83N\82µ\82Ä\81A\82±\82Ì\8a®\97¹\83\81\83b\83Z\81[\83W\82ð\95ß\8al\82·\82é\95K\97v\82ª\82 \82è\82Ü\82·\81B
+
+    \82»\82±\82Å\81A\94ñ\93¯\8aúAPI \82ª\8cÄ\82Ñ\8fo\82³\82ê\82½\8fê\8d\87\82É\82Í\81Aidn wrapper \82Í\81A\92Ê\92m\90æ\82Ì\83E\83B\83\93
+    \83h\83E\83v\83\8d\83V\83W\83\83\81i\82±\82ê\82ÍAPI \82Ì\83p\83\89\83\81\83^\82Å\8ew\8e¦\82³\82ê\82Ü\82·\81j\82É\83t\83b\83N\82ð\90Ý\92è\82µ
+    \82Ü\82·\81B\83t\83b\83N\82ª\8a®\97¹\83\81\83b\83Z\81[\83W\81i\82±\82ê\82àAPI \82Ì\83p\83\89\83\81\83^\82Å\8ew\8e¦\82³\82ê\82Ü\82·\81j\82ð
+    \8c\9f\8fo\82µ\82½\82È\82ç\81A\83t\83b\83N\82Í\8c\8b\89Ê\82Ì\8ai\94[\97Ì\88æ\81i\82±\82ê\82àAPI \82Ì\83p\83\89\83\81\83^\82Å\8ew\8e¦\82³\82ê
+    \82Ä\82¢\82Ü\82·\81j\82Ì\83h\83\81\83C\83\93\96¼\82ð\81ADNS \91¤\82Ì\83G\83\93\83R\81[\83f\83B\83\93\83O\82©\82ç\83\8d\81[\83J\83\8b\83G\83\93\83R\81[
+    \83f\83B\83\93\83O\82É\95Ï\8a·\82·\82é\82à\82Ì\82Æ\82µ\82Ü\82·\81B
+
+2.5. Wrapper DLL \82Ì\83C\83\93\83X\83g\81[\83\8b
+
+    WINSOCK DLL \82ÍWindows \82Ì\83V\83X\83e\83\80\83f\83B\83\8c\83N\83g\83\8a\82É\92u\82©\82ê\82Ä\82¢\82Ü\82·\81B
+    WINSOCK \82ð\8am\8eÀ\82É\83\89\83b\83v\82·\82é\82É\82Í\81A\83V\83X\83e\83\80\83f\83B\83\8c\83N\83g\83\8a\82É\82¨\82¢\82Ä
+    
+        \83I\83\8a\83W\83i\83\8bWINSOCK DLL \82Ì\96¼\91O\82Ì\95Ï\8dX
+
+           ren wsock32.dll wsock32o.dll
+           ren ws2_32.dll  ws2_32o.dll
+
+       \83\89\83b\83p\81[DLL \82Ì\93±\93ü
+       
+           copy somewhere\wsock32.dll wsock32.dll
+           copy somewhere\ws2_32.dll  ws2_32.dll
+           copy another DLLs also
+
+    \82ð\8ds\82È\82¤\95K\97v\82ª\82 \82è\82Ü\82·\81B
+
+    \82µ\82©\82µ\81A\83V\83X\83e\83\80\83f\83B\83\8c\83N\83g\83\8a\82Å\82±\82Ì\82æ\82¤\82ÈDLL \82Ì\92u\82«\8a·\82¦\82ð\8ds\82È\82¤\82Ì\82Í\91å
+    \95Ï\8aë\8c¯\82È\91\80\8dì\82É\82È\82è\82Ü\82·\81B
+    
+    a)  DLL \82ð\93ü\82ê\91Ö\82¦\82½\8fó\91Ô\82Å\81A\82à\82¤\82¢\82¿\82Ç\93¯\82\91\80\8dì\82ð\8ds\82È\82¤\82Æ\81A\83I\83\8a\83W\83i\83\8b
+        \82ÌWINSOCK DLL \82ª\8e¸\82í\82ê\82Ä\82µ\82Ü\82¤\82±\82Æ\82É\82È\82è\82Ü\82·\81B
+
+    b)  \83T\81[\83r\83X\83p\83b\83N\82â\83A\83v\83\8a\83P\81[\83V\83\87\83\93\82È\82Ç\82Å\81AWINSOCK DLL \82ð\8dÄ\93±\93ü\82·\82é
+        \82à\82Ì\82ª\82 \82è\82Ü\82·\82ª\81A\82±\82ê\82É\82æ\82Á\82Ä\82àWINSOCK \82ª\97\98\97p\95s\94\\82É\82È\82é\82±\82Æ\82ª\82 
+        \82è\82Ü\82·\81B
+
+    \82±\82Ì\82æ\82¤\82È\8fó\91Ô\82É\82È\82é\82Æ\81A\83l\83b\83g\83\8f\81[\83N\8b@\94\\82ª\91S\82­\8eg\82¦\82È\82­\82È\82Á\82½\82è\81A\8dÅ\88«
+    \82ÍWindows \82Ì\8bN\93®\82·\82ç\8fo\97\88\82È\82­\82È\82é\89Â\94\\90«\82ª\82 \82è\82Ü\82·\81B
+
+    \82»\82±\82Å\81Aidn wrapper \82Å\82Í\81A\8fã\82Ì\82æ\82¤\82È\83V\83X\83e\83\80\83\8c\83x\83\8b\82Ì\83\89\83b\83v\82Å\82Í\82È\82­\81A
+    \83A\83v\83\8a\83P\81[\83V\83\87\83\93\82É\91Î\82·\82é\83\89\83b\83v\82ð\8aî\96{\8b@\94\\82Æ\82µ\82Ä\92ñ\8b\9f\82·\82é\82à\82Ì\82Æ\82µ\82Ü\82·\81B
+
+    Windows \82É\82¨\82¢\82Ä\81ADLL \82Í\81A\8aî\96{\93I\82É\82Í
+
+        \83A\83v\83\8a\83P\81[\83V\83\87\83\93\82Ì\83\8d\81[\83h\83f\83B\83\8c\83N\83g\83\8a
+       %SystemRoot%\System32
+       %SystemRoot%
+       PATH \82Å\8ew\8e¦\82³\82ê\82é\83f\83B\83\8c\83N\83g\83\8a
+
+    \82Ì\8f\87\8f\98\82Å\8c\9f\8dõ\82³\82ê\82Ä\81A\8dÅ\8f\89\82É\8c©\82Â\82©\82Á\82½\82à\82Ì\82ª\83\8d\81[\83h\82³\82ê\82Ü\82·\81B\82Å\82·\82©\82ç\81A
+    \88ê\94Ê\93I\82É\82Í\81ADLL \82ð\83A\83v\83\8a\83P\81[\83V\83\87\83\93\82Ì\83\8d\81[\83h\83f\83B\83\8c\83N\83g\83\8a\82É\83C\83\93\83X\83g\81[\83\8b
+    \82·\82ê\82Î\81A\82»\82Ì\83A\83v\83\8a\83P\81[\83V\83\87\83\93\82©\82ç\82ÌWINSOCK \82Ì\8cÄ\82Ñ\8fo\82µ\82ð\83\89\83b\83v\82·\82é\82±\82Æ
+    \82ª\82Å\82«\82Ü\82·\81B
+
+    \82½\82¾\82µ\81A\82¢\82­\82Â\82©\82Ì\83A\83v\83\8a\83P\81[\83V\83\87\83\93\81ADLL \82Å\82Í\81A\8c\9f\8dõ\83p\83X\82ð\8co\97R\82¹\82¸\82É\93Á
+    \92è\82ÌDLL \82ð\83\8a\83\93\83N\82·\82é\82æ\82¤\82É\82È\82Á\82Ä\82¢\82é\82à\82Ì\82ª\82 \82è\82Ü\82·\81B\82±\82Ì\82æ\82¤\82È\8d\\90¬\82Ì
+    \83A\83v\83\8a\83P\81[\83V\83\87\83\93\81ADLL \82ª\8eg\82í\82ê\82½\8fê\8d\87\82É\82Í idn wrapper\82Å\82Í\91Î\8f\88\82·\82é\82±\82Æ
+    \82Í\82Å\82«\82Ü\82¹\82ñ\81B
+
+    \92\8d\81FNetscape\82Í\93Á\92èDLL \82É\83o\83C\83\93\83h\82³\82ê\82Ä\82¢\82é\82æ\82¤\82Å\81A\83A\83v\83\8a\83P\81[\83V\83\87\83\93\83f\83B
+        \83\8c\83N\83g\83\8a\82Ö\82Ì\83C\83\93\83X\83g\81[\83\8b\82Å\82Í\83\89\83b\83v\82Å\82«\82Ü\82¹\82ñ\81BWINSOCK DLL \8e©\91Ì\82à
+       \83V\83X\83e\83\80\83f\83B\83\8c\83N\83g\83\8a\82Ì\8aÖ\98ADLL \82É\83o\83C\83\93\83h\82³\82ê\82Ä\82¢\82é\82æ\82¤\82Å\82·\81B\88ê\95û\81A
+       Internet Explore\82âWindows Media Player\82Í\95W\8f\80\82Ì\83T\81[\83`\83p\83X\82É\8f]\82Á\82Ä
+        \82¢\82é\82Ì\82Å\81A\83\89\83b\83v\82·\82é\82±\82Æ\82ª\82Å\82«\82Ü\82·\81B
+
+2.6. \83G\83\93\83R\81[\83f\83B\83\93\83O\82Ì\95Ï\8a·\88Ê\92u
+
+    WINSOCK 2.0 \82ð\83T\83|\81[\83g\82µ\82Ä\82¢\82éWindows \82É\82Í\81AWINSOCK \82Ì1.1 \82Æ2.0 \82Ì\82»
+    \82ê\82¼\82ê\82É\91Î\89\9e\82·\82éDLL \82ª\82 \82è\81AWINSOCK 1.1 \82ÌAPI \82Ì\8cÄ\82Ñ\8fo\82µ\82Í2.0 \82Ì\93¯\82
+    \83G\83\93\83g\83\8a\82É\83\8a\83_\83C\83\8c\83N\83g\82³\82ê\82é\82æ\82¤\82É\82È\82Á\82Ä\82¢\82Ü\82·\81B
+
+        +------------+  Call  +------------+  Call  +------------+
+        |            |------->|            |------->|            |
+        |Application |        |WINSOCK 1.1 |        |WINSOCK 2.0 |
+        |            |<-------|            |<-------|            |
+        +------------+ Return +------------+ Return +------------+
+
+    \82±\82Ì\8fê\8d\87\82É\82Í1.1 \82É\91Î\82·\82é\8cÄ\82Ñ\8fo\82µ\82à2.0 \82É\91Î\82·\82é\8cÄ\82Ñ\8fo\82µ\82à\81A\82Æ\82à\82ÉV2.0
+    \97p\82ÌDLL \82É\93n\82³\82ê\82é\82Ì\82Å\81A2.0\97p\82Ì\83\89\83b\83p\81[DLL \91¤\82¾\82¯\82Å\83G\83\93\83R\81[\83f\83B\83\93\83O\82Ì
+    \95Ï\8a·\82ð\8ds\82È\82¤\82æ\82¤\82É\82·\82é\82×\82«\82Å\82µ\82å\82¤\81B
+
+    \88ê\95û\81AWINSOCK 1.1 \82µ\82©\83T\83|\81[\83g\82µ\82Ä\82¢\82È\82¢\8fê\8d\87(Win95)\82É\82Í\81A1.1 \82É\91Î\89\9e\82µ
+    \82½DLL \82µ\82©\82 \82è\82Ü\82¹\82ñ\81B
+
+        +------------+  Call  +------------+
+        |            |------->|            |
+        |Application |        |WINSOCK 1.1 |
+        |            |<-------|            |
+        +------------+ Return +------------+
+
+    \82±\82Ì\8fê\8d\87\82É\82Í\95K\91R\93I\82É1.1 \97p\82Ì\83\89\83b\83p\81[DLL \82Å\83G\83\93\83R\81[\83f\83B\83\93\83O\82ð\95Ï\8a·\82µ\82È
+    \82¯\82ê\82Î\82È\82è\82Ü\82¹\82ñ\81B
+    
+    idn Wrapepr \82ªwindows \82Ì\83V\83X\83e\83\80\83f\83B\83\8c\83N\83g\83\8a\82É\83C\83\93\83X\83g\81[\83\8b\82³\82ê\82½\8fê\8d\87
+    \82É\82Í\81A\8fã\82Ì\92Ê\82è\82É\93®\8dì\82·\82é\82Ì\82Å\81A
+    
+        WINSOCK 2.0 \82 \82è        2.0 \83\89\83b\83p\81[\82Å\95Ï\8a·
+       WINSOCK 1.1 \82Ì\82Ý        1.1 \83\89\83b\83p\81[\82Å\95Ï\8a·
+
+    \82·\82é\95K\97v\82ª\82 \82è\82Ü\82·\81B
+    
+    \82µ\82©\82µ\81A\83A\83v\83\8a\83P\81[\83V\83\87\83\93\83f\83B\83\8c\83N\83g\83\8a\82É\83C\83\93\83X\83g\81[\83\8b\82³\82ê\82½\8fê\8d\87\82É\82Í\93®\8dì
+    \82ª\95Ï\82í\82Á\82Ä\82«\82Ü\82·\81BWindows \95t\91®\82Ì WINSOCK 1.1 DLL\82Í\81A\83V\83X\83e\83\80\83f\83B\83\8c\83N
+    \83g\83\8a\82ÌWINSOCK 2.0 \82É\83o\83C\83\93\83h\82³\82ê\82Ä\82¢\82é\82½\82ß\81A\83A\83v\83\8a\83P\81[\83V\83\87\83\93\83f\83B\83\8c\83N
+    \83g\83\8a\91¤\82ÌWINSOCK 2.0 \83\89\83b\83p\81[DLL \82É\82Í\83\8a\83_\83C\83\8c\83N\83g\82³\82ê\82Ä\82«\82Ü\82¹\82ñ\81B\82±\82Ì
+    \82½\82ß\81A\83A\83v\83\8a\83P\81[\83V\83\87\83\93\83f\83B\83\8c\83N\83g\83\8a\82Ö\82Ì\83C\83\93\83X\83g\81[\83\8b\82É\82¨\82¢\82Ä\82Í\81A1.1DLL\81A
+    2.0DLL\82Ì\97¼\95û\82Å\83G\83\93\83R\81[\83f\83B\83\93\83O\82ð\95Ï\8a·\82·\82é\95K\97v\82ª\82 \82è\82Ü\82·\81B
+
+    \82±\82Ì\82æ\82¤\82ÈDLL \8aÔ\82Ì\83o\83C\83\93\83f\83B\83\93\83O\82Í\83h\83L\83\85\83\81\83\93\83g\82³\82ê\82Ä\82¢\82Ü\82¹\82ñ\82Ì\82Å\81A\8aÂ
+    \8b«\81A\83o\81[\83W\83\87\83\93\82É\82æ\82Á\82Ä\82Í\88Ù\82È\82Á\82½\93®\8dì\82ð\82·\82é\82©\82à\92m\82ê\82Ü\82¹\82ñ\81B\82»\82±\82Åidn 
+    wrapper \82Å\82Í\81A\83\8c\83W\83X\83g\83\8a\92l\82É\82æ\82Á\82Ä\81A\83\89\83b\83p\81[DLL \82Ì\82Ç\82±\82Å\95Ï\8a·\82ð\8ds\82È\82¤
+    \82©\82ð\8c\88\92è\82·\82é\82æ\82¤\82É\82µ\82Ä\81A\83C\83\93\83X\83g\81[\83\8b\90æ\82É\82æ\82é\8d·\88Ù\81A\82 \82é\82¢\82Í\83o\81[\83W\83\87\83\93
+    \82É\82æ\82é\8d·\88Ù\82ð\8bz\8eû\82·\82é\82æ\82¤\82É\82µ\82Ü\82·\81B
+    
+    idn wrapper \97p\82Ì\83\8c\83W\83X\83g\83\8a\90Ý\92è\82Í
+    
+        HKEY_LOCAL_MACHINE\SOFTWARE\JPNIC\IDN
+       HKEY_CURRENT_USER\SOFTWARE\JPNIC\IDN
+
+    \88È\89º\82É\94z\92u\82³\82ê\82Ü\82·\81B\83G\83\93\83R\81[\83f\83B\83\93\83O\95Ï\8a·\82ð\8ds\82È\82¤\88Ê\92u\82É\82Â\82¢\82Ä\82Í\81A\82±\82Ì
+    \92¼\89º\82Ì\83\8c\83W\83X\83g\83\8a\92l Where\81iREG_DWORD\81\82É\82æ\82Á\82Ä\8c\88\92è\82µ\82Ü\82·\81B\97L\8cø\82È\92l\82Í\81A
+    
+        \83\8c\83W\83X\83g\83\8a Where (REG_DWORD)
+
+        0       WINSOCK 1.1\81AWINSOCK 2.0 \82Ì\97¼\95û\82Å\95Ï\8a·\82·\82é
+       1       WINSOCK 2.0 \82ª\82 \82ê\82Î\81AWINSOCK 2.0\82¾\82¯\82Å\95Ï\8a·\82·\82é
+               WINSOCK 1.1 \82¾\82¯\82Ì\8fê\8d\87\82É\82Í WINSOCK 1.1 \82Å\95Ï\8a·\82·\82é
+       2       WINSOCK 1.1 \82¾\82¯\82Å\95Ï\8a·\82·\82é
+       3       WINSOCK 2.0 \82¾\82¯\82Å\95Ï\8a·\82·\82é
+    
+    \82Ì\82S\92Ê\82è\82Å\82·\81B\83A\83v\83\8a\83P\81[\83V\83\87\83\93\83f\83B\83\8c\83N\83g\83\8a\82É\83C\83\93\83X\83g\81[\83\8b\82·\82é\8fê\8d\87\82É\82Í
+    \81u\82O\81v\82ð\81A\83V\83X\83e\83\80\83f\83B\83\8c\83N\83g\83\8a\82É\83C\83\93\83X\83g\81[\83\8b\82·\82é\8fê\8d\87\82É\82Í\81u\82P\81v\82ð\90Ý\92è
+    \82·\82é\95K\97v\82ª\82 \82è\82Ü\82·\81B\83\8c\83W\83X\83g\83\8a\92l\82ª\91\8dÝ\82µ\82È\82¢\8fê\8d\87\82É\82Í\81u\82O\81v\82ð\91z\92è\82µ\82Ü
+    \82·\81B\82±\82ê\82Í\83A\83v\83\8a\83P\81[\83V\83\87\83\93\83f\83B\83\8c\83N\83g\83\8a\82Ö\82Ì\83C\83\93\83X\83g\81[\83\8b\82ð\95W\8f\80\82Æ\82µ\82½\82à
+    \82Ì\82Å\82·\81B
+
+2.7. \95Ï\8a·\8c³/\90æ\82Ì\83G\83\93\83N\83R\81[\83f\83B\83\93\83O
+
+    \83\89\83b\83p\81[DLL \82Å\82Í\81A\89ð\8c\88\82µ\82æ\82¤\82Æ\82·\82é\83h\83\81\83C\83\93\96¼\82ð\81A\83}\83V\83\93\82Ì\83\8d\81[\83J\83\8b\83G\83\93
+    \83R\81[\83f\83B\83\93\83O\82©\82çDNS \83T\81[\83o\82Ì\83G\83\93\83R\81[\83f\83B\83\93\83O\82É\95Ï\8a·\82µ\81A\82Ü\82½\81ADNS \82ª\95Ô
+    \82µ\82Ä\82«\82½\83h\83\81\83C\83\93\96¼(DNS \83T\81[\83o\82Ì\83G\83\93\83R\81[\83f\83B\83\93\83O)\82ð\83}\83V\83\93\82Ì\83\8d\81[\83J\83\8b\83G\83\93
+    \83R\81[\83f\83B\83\93\83O\82É\96ß\82µ\82Ü\82·\81B
+
+    \8c»\8dÝ\81ADNS \91¤\82Ì\8d\91\8dÛ\89»\83G\83\93\83R\81[\83f\83B\83\93\83O\82É\82Â\82¢\82Ä\82Í\81A\82¢\82­\82Â\82à\82Ì\95û\8e®\82ª\92ñ
+    \88Ä\82³\82ê\82Ä\82¢\82Ü\82·\81B\83\89\83b\83p\81[DLL \82Í\82»\82ê\82ç\82ÌDNS \91¤\83G\83\93\83R\81[\83f\83B\83\93\83O\82Ì\82Ç\82ê\82©
+    \82Ð\82Æ\82Â\82É\95Ï\8a·\82·\82é\82æ\82¤\82É\8d\\90¬\82³\82ê\82Ü\82·\81B\82±\82ÌDNS \91¤\83G\83\93\83R\81[\83f\83B\83\93\83O\82Í\83\8c\83W
+    \83X\83g\83\8a\82Å\8ew\8e¦\82³\82ê\82Ü\82·\81B\82±\82Ì\83\8c\83W\83X\83g\83\8a\82É\82Í\81Aidn wrapper \82Ì\83C\83\93\83X\83g\81[\83\8b
+    \8e\9e\82É\81i\8c»\8e\9e\93_\82Å\82Í\96¢\92è\82Ì\81j\83f\83t\83H\83\8b\83g\83G\83\93\83R\81[\83f\83B\83\93\83O\82ª\90Ý\92è\82³\82ê\82Ü\82·\81B\93\96
+    \91R\81A\82±\82Ì\83\8c\83W\83X\83g\83\8a\82Í\81A\8cã\82Å\91¼\82Ì\82à\82Ì\82É\95Ï\8dX\82·\82é\82±\82Æ\82à\82Å\82«\82Ü\82·\81B
+
+    idn wrapper \97p\82Ì\83\8c\83W\83X\83g\83\8a\90Ý\92è\82Í
+    
+        HKEY_LOCAL_MACHINE\SOFTWARE\JPNIC\IDN
+       HKEY_CURRENT_USER\SOFTWARE\JPNIC\IDN
+
+    \88È\89º\82É\94z\92u\82³\82ê\82Ü\82·\81BDNS \91¤\82Ì\83G\83\93\83R\81[\83f\83B\83\93\83O\82Í\83\8c\83W\83X\83g\83\8a\92l Encoding 
+    \81iREG_SZ\81j\82Å\8ew\8e¦\82³\82ê\82Ü\82·\81B\82±\82Ì\83G\83\93\83R\81[\83f\83B\83\93\83O\96¼\82Í\81Alibmdn\82Å\94F\8e¯\82³\82ê
+    \82é\82à\82Ì\82Å\82È\82¯\82ê\82Î\82È\82è\82Ü\82¹\82ñ\81B
+
+        \83\8c\83W\83X\83g\83\8a  Encoding    (REG_SZ)
+           DNS \83T\81[\83o\91¤\82Ì\83G\83\93\83R\81[\83f\83B\83\93\83O\96¼\82ð\90Ý\92è\82µ\82Ü\82·
+    
+    \88ê\95û\81A\83A\83v\83\8a\83P\81[\83V\83\87\83\93\82ª\8eg\97p\82µ\82Ä\82¢\82é\83\8d\81[\83J\83\8b\83G\83\93\83R\81[\83f\83B\83\93\83O\82Í\81A\92Ê\8fí
+    \82Í\83v\83\8d\83Z\83X\82Ì\83R\81[\83h\83y\81[\83W\82©\82ç\8b\81\82ß\82Ü\82·\81B\83\89\83b\83p\81[DLL \82ª\8eg\97p\82·\82é 'iconv' 
+    \83\89\83C\83u\83\89\83\8a\82Í\81Awindows \82Ì\83R\81[\83h\83y\81[\83W\96¼\82ð\83G\83\93\83R\81[\83f\83B\83\93\83O\96¼\82Æ\82µ\82Ä\8eó\95t
+    \82¯\82é\82±\82Æ\82ª\82Å\82«\82é\82Ì\82Å\81A\83R\81[\83h\83y\81[\83W\96¼\82ð\82»\82Ì\82Ü\82Ü\83\8d\81[\83J\83\8b\83G\83\93\83R\81[\83f\83B\83\93
+    \83O\96¼\82Æ\82µ\82Ä\8eg\97p\82µ\82Ü\82·\81B
+
+    \82µ\82©\82µ\81A\83A\83v\83\8a\83P\81[\83V\83\87\83\93\82É\82æ\82Á\82Ä\82Í\81A\93Á\92è\82Ì\8d\91\8dÛ\89»\83G\83\93\83R\81[\83f\83B\83\93\83O\82Å
+    \83h\83\81\83C\83\93\96¼\82ð\83G\83\93\83R\81[\83f\83B\83\93\83O\82µ\82Ä\82µ\82Ü\82¤\82à\82Ì\82à\82 \82è\82Ü\82·\81B\97á\82¦\82Î\81AIE\82Å\82Í
+    \83h\83\81\83C\83\93\96¼\82ðUTF-8 \82Å\95\\8bL\82·\82é\82æ\82¤\82É\8ew\8e¦\82·\82é\82±\82Æ\82ª\82Å\82«\82é\82æ\82¤\82É\82È\82Á\82Ä\82¢
+    \82Ü\82·\81BUTF-8 \82É\82æ\82é\83G\83\93\83R\81[\83f\83B\83\93\83O\82Í\81A\92ñ\88Ä\82³\82ê\82Ä\82¢\82é\8d\91\8dÛ\89»\95û\8e®\82Ì\82Ð
+    \82Æ\82Â\82Å\82·\82ª\81A\8d\91\8dÛ\89»\82³\82ê\82½DNS \83T\81[\83o\82Í\91¼\82Ì\83G\83\93\83R\81[\83f\83B\83\93\83O\82µ\82©\8eó\95t\82¯
+    \82È\82¢\82©\82à\92m\82ê\82Ü\82¹\82ñ\81B
+    
+    \82±\82Ì\82æ\82¤\82È\8fó\8bµ\82É\91Î\8f\88\82·\82é\82½\82ß\81Aidn \83\89\83b\83p\81[\82Í\81A\83\8d\81[\83J\83\8b\83G\83\93\83R\81[\83f\83B\83\93
+    \83O\82Æ\82µ\82Ä\83v\83\8d\83O\83\89\83\80\93Á\97L\82Ì\83G\83\93\83R\81[\83f\83B\83\93\83O\82à\8eó\95t\82¯\82é\82±\82Æ\82ª\82Å\82«\82é\82æ\82¤\82É
+    \82µ\82Ü\82·\81B\82±\82Ì\82æ\82¤\82È\83v\83\8d\83O\83\89\83\80\93Á\97L\82Ì\83\8d\81[\83J\83\8b\83G\83\93\83R\81[\83f\83B\83\93\83O\82Í\83\8c\83W\83X\83g
+    \83\8a\8bL\8dÚ\82³\82ê\82é\82à\82Ì\82Æ\82µ\82Ü\82·\81B
+
+    idn wrapper \97p\82Ì\83v\83\8d\83O\83\89\83\80\93Á\97L\82Ì\83\8c\83W\83X\83g\83\8a\90Ý\92è\82Í
+    
+        HKEY_LOCAL_MACHINE\SOFTWARE\JPNIC\IDN\PerProg
+       HKEY_CURRENT_USER\SOFTWARE\JPNIC\IDN\PerProg
+
+    \88È\89º\82É\81A\83v\83\8d\83O\83\89\83\80\96¼\81i\8eÀ\8ds\83\82\83W\83\85\81[\83\8b\83t\83@\83C\83\8b\96¼\81j\82ð\83L\81[\82Æ\82µ\82Ä\94z\92u\82³\82ê
+    \82Ü\82·\81B\97á\82¦\82Î\81AInternet Explore \82Ì\8fê\8d\87\82É\82Í\81A\8eÀ\8ds\83\82\83W\83\85\81[\83\8b\96¼\82Ì
+    IEXPLORE\82ð\83L\81[\82Æ\82µ\82Ä
+
+        HKEY_LOCAL_MACHINE\SOFTWARE\JPNIC\IDN\PerProg\IEXPLORE
+
+    \88È\89º\82É\92u\82©\82ê\82Ü\82·\81B\83\8d\81[\83J\83\8b\83G\83\93\83R\81[\83f\83B\83\93\83O\96¼\82Í\81A\83\8c\83W\83X\83g\83\8a\92l
+    Encoding \81iREG_SZ\81j\82Å\8ew\8e¦\82µ\82Ü\82·\81B\82±\82ê\82àlibmdn\82Å\94F\8e¯\82³\82ê\82é\82à\82Ì\82Å\82È\82¯\82ê
+    \82Î\82È\82è\82Ü\82¹\82ñ\81B
+
+        \83\8c\83W\83X\83g\83\8a  Encoding    (REG_SZ)
+       
+           \83A\83v\83\8a\83P\81[\83V\83\87\83\93\83v\83\8d\83O\83\89\83\80\93Á\97L\82Ì\83G\83\93\83R\81[\83f\83B\83\93\83O\96¼\81i\83f\83t\83H\83\8b
+            \83g\82Ì\83G\83\93\83R\81[\83f\83B\83\93\83O\88È\8aO\82ð\95K\97v\82Æ\82·\82é\8fê\8d\87\81j\82ð\8ew\92è\82µ\82Ü\82·\81B
+
+3.\83Z\83b\83g\83A\83b\83v\82Æ\83R\83\93\83t\83B\83M\83\85\83\8c\81[\83V\83\87\83\93
+
+    idn wrapper \82Í\81A\8aî\96{\83C\83\93\83X\83g\83\8c\81[\83V\83\87\83\93\82Æ\82µ\82Ä\81A\83A\83v\83\8a\83P\81[\83V\83\87\83\93\83f\83B\83\8c
+    \83N\83g\83\8a\82ÅWINSOCK \82ð\83\89\83b\83v\82µ\82Ü\82·\81B\82±\82ê\82É\8d\87\82í\82¹\82Ä\81A\83Z\83b\83g\83A\83b\83v\83v\83\8d\83O\83\89
+    \83\80\82Æ\83R\83\93\83t\83B\83M\83\85\83\8c\81[\83V\83\87\83\93\83v\83\8d\83O\83\89\83\80\82Æ\82ð\92ñ\8b\9f\82µ\82Ü\82·\81B
+    
+    \92\8d\81F\83V\83X\83e\83\80\83f\83B\83\8c\83N\83g\83\8a\82Å\82Ì\83\89\83b\83v\82à\89Â\94\\82Å\82·\82ª\81A\82±\82ê\82Í\8aë\8c¯\82È\90Ý\92è\82Å\82·
+        \82Ì\82Å\81A\95W\8f\80\83C\83\93\83X\83g\83\8c\81[\83V\83\87\83\93\82Æ\82µ\82Ä\82Í\92ñ\8b\9f\82µ\82Ü\82¹\82ñ\81B\83V\83X\83e\83\80\83f\83B\83\8c
+        \83N\83g\83\8a\82Ö\82Ì\83C\83\93\83X\83g\81[\83\8b\82ð\8ds\82È\82¤\8fê\8d\87\82É\82Í\81A\8e©\8cÈ\90Ó\94C\82Å\82â\82Á\82Ä\82­\82¾\82³\82¢\81B
+    
+3.1.\83Z\83b\83g\83A\83b\83v\83v\83\8d\83O\83\89\83\80
+
+    idn wrapper \82ð\83C\83\93\83X\83g\81[\83\8b\82·\82é\82É\82Í"setup.exe" \82ð\8eÀ\8ds\82µ\82Ü\82·\81B\83Z\83b\83g\83A\83b
+    \83v\83v\83\8d\83O\83\89\83\80\82Í\88È\89º\82Ì\8f\88\97\9d\82ð\8eÀ\8ds\82µ\82Ü\82·\81B
+
+    \83t\83@\83C\83\8b\82Ì\83C\83\93\83X\83g\81[\83\8b
+
+        \83f\83B\83\8c\83N\83g\83\8a\81u\Program Files\JPNIC\idn wrapper\81\81\83Z\83b\83g\83A\83b\83v
+       \8e\9e\93_\82Å\95Ï\8dX\89Â\94\\81j\88È\89º\82É\81Aidn wrapper \82ð\8d\\90¬\82·\82é\83t\83@\83C\83\8b\82ð\83R\83s\81[\82µ
+       \82Ü\82·\81B
+
+    \83\8c\83W\83X\83g\83\8a\82Ì\90Ý\92è
+    
+        HKEY_LOCAL_MACHINE\Software\JPNIC\IDN \88È\89º\82É\95K\97v\82È\83\8c\83W\83X\83g\83\8a\83L\81[\81A
+        \83\8c\83W\83X\83g\83\8a\92l\82ð\8dì\90¬\81A\90Ý\92è\82µ\82Ü\82·\81B
+       
+       InstallDir      REG_SZ  "<\83C\83\93\83X\83g\81[\83\8b\83f\83B\83\8c\83N\83g\83\8a>"
+           idn wrapper \82Ì\83C\83\93\83X\83g\81[\83\8b\83f\83B\83\8c\83N\83g\83\8a\82Ì\83p\83X\96¼\82Å\82·\81B\83Z\83b\83g
+           \83A\83b\83v\83v\83\8d\83O\83\89\83\80\82Í\82±\82Ì\83f\83B\83\8c\83N\83g\83\8a\82É\83I\83\8a\83W\83i\83\8b\82ÌWINSOCK
+           DLL \82Ì\83R\83s\81[\82ð\8dì\90¬\82µ\82Ü\82·\81Bidn wrapper \82Ì\83\89\83b\83p\81[ DLL \82Í\8eÀ
+           \8ds\8e\9e\82É\82±\82Ì DLL \82ð\8eQ\8fÆ\82µ\82Ü\82·\81B
+
+        ConfFile    REG_SZ      "<\83C\83\93\83X\83g\81[\83\8b\83f\83B\83\8c\83N\83g\83\8a>\idn.conf"
+           idn wrapper \82ª\8d\91\8dÛ\89»\83h\83\81\83C\83\93\96¼\82Ì\95Ï\8a·\8f\88\97\9d\82É\8eg\97p\82µ\82Ä\82¢\82é
+           idnkit \82Ì\83R\83\93\83t\83B\83M\83\85\83\8c\81[\83V\83\87\83\93\83t\83@\83C\83\8b\82Ì\96¼\91O\82Å\82·\81B\82±\82Ì\83t\83@
+           \83C\83\8b\82Í\8d\91\8dÛ\89»\83h\83\81\83C\83\93\96¼\82Ì\8f\88\97\9d\82É\95K\97v\82È\8ae\8eí\82Ì\83p\83\89\83\81\81[\83^\82ð\90Ý\92è
+           \82·\82é\82½\82ß\82Ì\82à\82Ì\82Å\82·\81B\8fÚ\82µ\82­\82Í\83t\83@\83C\83\8b\82Ì\93à\97e\82ð\82²\97\97\82­\82¾\82³\82¢\81B
+           \82±\82Ì\92l\82Í\8cã\8fq\82·\82é\83R\83\93\83t\83B\83M\83\85\83\8c\81[\83V\83\87\83\93\83v\83\8d\83O\83\89\83\80\82Å\95Ï\8dX\82·\82é
+           \82±\82Æ\82ª\82Å\82«\82Ü\82·\81B
+    
+        LogFile     REG_SZ      "<\83C\83\93\83X\83g\81[\83\8b\83f\83B\83\8c\83N\83g\83\8a>\idn_wrapper.log"
+           idn wrapper \82Ì\83\8d\83O\83t\83@\83C\83\8b\82Ì\96¼\91O\82Å\82·\81B\82±\82Ì\92l\82à\83R\83\93\83t\83B\83M\83\85
+           \83\8c\81[\83V\83\87\83\93\83v\83\8d\83O\83\89\83\80\82Å\95Ï\8dX\82·\82é\82±\82Æ\82ª\82Å\82«\82Ü\82·\81B
+    
+       LogLevel        DWORD   -1
+           \83\8d\83O\83\8c\83x\83\8b\82Ì\8ew\92è\82Å\82·\81B\83f\83t\83H\83\8b\83g\82Í -1 \82Å\81A\82±\82ê\82Í\91S\82­\83\8d\83O\82ð
+           \8fo\97Í\82µ\82È\82¢\82Æ\82¢\82¤\88Ó\96¡\82Å\82·\81B\82±\82Ì\92l\82à\83R\83\93\83t\83B\83M\83\85\83\8c\81[\83V\83\87\83\93\83v
+           \83\8d\83O\83\89\83\80\82Å\95Ï\8dX\82·\82é\82±\82Æ\82ª\82Å\82«\82Ü\82·\81B
+
+        PerProg     \83L\81[
+       
+           \83v\83\8d\83O\83\89\83\80\96\88\82Ì\90Ý\92è\92l\82ð\8ai\94[\82·\82é\82½\82ß\82Ì\83L\81[\82Å\82·\81B\82±\82Ì\89º\82É\81A\83v\83\8d
+            \83O\83\89\83\80\82Ì\8eÀ\8ds\83\82\83W\83\85\81[\83\8b\96¼\82ð\83L\81[\82Æ\82µ\82Ä\83v\83\8d\83O\83\89\83\80\8cÂ\95Ê\82Ì\90Ý\92è\82ª\8bL
+            \98^\82³\82ê\82Ü\82·\81B\90Ý\92è\82³\82ê\82é\8fî\95ñ\82Í\88È\89º\82Ì\93ñ\82Â\82Å\82·\81B
+           
+           PerProg\<progname>\Where        REG_DWORD \95Ï\8a·\88Ê\92u
+           PerProg\<progname>\Encoding     REG_SZ    \83G\83\93\83R\81[\83f\83B\83\93\83O\96¼
+
+            \83G\83\93\83R\81[\83f\83B\83\93\83O\96¼\82Í\92Ê\8fí\83R\83\93\83t\83B\83M\83\85\83\8c\81[\83V\83\87\83\93\83v\83\8d\83O\83\89\83\80\82É\82æ\82Á
+           \82Ä\90Ý\92è\82³\82ê\82Ü\82·\81B\95Ï\8a·\88Ê\92u\82Í\81A\95W\8f\80\83C\83\93\83X\83g\81[\83\8b\82Å\82Í\95s\97v\82Å\82·\81B\83V
+            \83X\83e\83\80\83f\83B\83\8c\83N\83g\83\8a\82Ö\82Ì\83C\83\93\83X\83g\81[\83\8b\82ð\8ds\82È\82Á\82½\8fê\8d\87\82É\82Í\81A\83\8c\83W\83X
+            \83g\83\8a\83G\83f\83B\83^\82Å\8aÂ\8b«\82É\8d\87\82í\82¹\82Ä\90Ý\92è\82·\82é\95K\97v\82ª\82 \82è\82Ü\82·\81B
+
+    \83A\83C\83R\83\93\82Ì\8dì\90¬
+    
+        \83R\83\93\83t\83B\83M\83\85\83\8c\81[\83V\83\87\83\93\83v\83\8d\83O\83\89\83\80\82Ì\83A\83C\83R\83\93\82ð\8dì\90¬\82µ\81A\83X\83^\81[\83g\83\81\83j\83\85\81[
+        \82É\93o\98^\82µ\82Ü\82·\81B\82±\82ê\82É\82æ\82Á\82Ä\83R\83\93\83t\83B\83M\83\85\83\8c\81[\83V\83\87\83\93\83v\83\8d\83O\83\89\83\80\82ð\8bN\93®
+        \82·\82é\82±\82Æ\82ª\82Å\82«\82Ü\82·\81B
+
+    \83A\83\93\83C\83\93\83X\83g\81[\83\8b\82·\82é\82É\82Í\81A\83R\83\93\83g\83\8d\81[\83\8b\83p\83l\83\8b\82Ì\81u\83A\83v\83\8a\83P\81[\83V\83\87\83\93\82Ì\92Ç
+    \89Á\82Æ\8dí\8f\9c\81v\82Å\81A\81uidn wrapper\81\82ð\91I\91ð\82µ\82Ä\8dí\8f\9c\81i\81u\92Ç\89Á\82Æ\8dí\8f\9c\81v\83{\83^\83\93\81j
+    \82µ\82Ü\82·\81B
+
+3.2.\83R\83\93\83t\83B\83M\83\85\83\8c\81[\83V\83\87\83\93\83v\83\8d\83O\83\89\83\80
+
+    \83R\83\93\83t\83B\83M\83\85\83\8c\81[\83V\83\87\83\93\83v\83\8d\83O\83\89\83\80\82Í\81A\83A\83v\83\8a\83P\81[\83V\83\87\83\93\82ð\93Á\92è\82µ\82Ä\83\89\83b\83v
+    \82µ\82½\82è\81A\83A\83v\83\8a\83P\81[\83V\83\87\83\93\82Ì\83\89\83b\83v\82ð\89ð\8f\9c\82·\82é\82½\82ß\82Ì\83c\81[\83\8b\82Å\82·\81B
+
+    \8bN\93®\82·\82é\82Æ\88È\89º\82Ì\82æ\82¤\82È\89æ\96Ê\82ª\95\\8e¦\82³\82ê\82Ü\82·\81B
+
+    \84¡\84\9f\84¦\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84¦\84\9f\84¦\84\9f\84¦\84\9f\84¢
+    \84 \81@\84 idn wrapper - Configuration                       \84 \81Q\84 \81 \84 \81~\84 
+    \84¥\84\9f\84¨\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84¨\84\9f\84¨\84\9f\84¨\84\9f\84§
+    \84           idn wrapper Configuration Program version X.X           \84 
+    \84¥\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84§
+    \84                   Wrapped Program                   \84¡\84\9f\84\9f\84\9f\84\9f\84\9f\84¢\84 
+    \84 \84¡\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84¦\84\9f\84¢\84   Wrap..  \84 \84 
+    \84 \84                                             \84 \81È\84 \84¤\84\9f\84\9f\84\9f\84\9f\84\9f\84£\84 
+    \84 \84                                             \84¥\84\9f\84§\84¡\84\9f\84\9f\84\9f\84\9f\84\9f\84¢\84 
+    \84 \84                                             \84   \84 \84  Unwrap.. \84 \84 
+    \84 \84                                             \84   \84 \84¤\84\9f\84\9f\84\9f\84\9f\84\9f\84£\84 
+    \84 \84                                             \84   \84 \84¡\84\9f\84\9f\84\9f\84\9f\84\9f\84¢\84 
+    \84 \84                                             \84   \84 \84 UnwrapAll.\84 \84 
+    \84 \84                                             \84   \84 \84¤\84\9f\84\9f\84\9f\84\9f\84\9f\84£\84 
+    \84 \84                                             \84   \84 \84¡\84\9f\84\9f\84\9f\84\9f\84\9f\84¢\84 
+    \84 \84                                             \84   \84 \84 RewrapAll.\84 \84 
+    \84 \84                                             \84   \84 \84¤\84\9f\84\9f\84\9f\84\9f\84\9f\84£\84 
+    \84 \84                                             \84   \84 \84¡\84\9f\84\9f\84\9f\84\9f\84\9f\84¢\84 
+    \84 \84                                             \84   \84 \84   Log..   \84 \84 
+    \84 \84                                             \84   \84 \84¤\84\9f\84\9f\84\9f\84\9f\84\9f\84£\84 
+    \84 \84                                             \84   \84 \84¡\84\9f\84\9f\84\9f\84\9f\84\9f\84¢\84 
+    \84 \84                                             \84¥\84\9f\84§\84 Advanced..\84 \84 
+    \84 \84                                             \84 \81É\84 \84¤\84\9f\84\9f\84\9f\84\9f\84\9f\84£\84 
+    \84 \84¥\84\9f\84¦\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84¦\84\9f\84©\84\9f\84£\84¡\84\9f\84\9f\84\9f\84\9f\84\9f\84¢\84 
+    \84 \84 \81q\84                                     \84 \81r\84     \84    Exit   \84 \84 
+    \84 \84¤\84\9f\84¨\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84¨\84\9f\84£    \84¤\84\9f\84\9f\84\9f\84\9f\84\9f\84£\84 
+    \84¤\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84£
+
+    \83\8a\83X\83g\83{\83b\83N\83X\82É\82Í\81A\82»\82Ì\8e\9e\93_\82Å\83\89\83b\83v\82³\82ê\82Ä\82¢\82é\83v\83\8d\83O\83\89\83\80\82ª\95\\8e¦\82³\82ê\82Ü
+    \82·\81B\8dÅ\8f\89\82É\8eÀ\8ds\82µ\82½\8fê\8d\87\82É\82Í\8bó\82É\82È\82Á\82Ä\82¢\82Ü\82·\81B
+
+    \83v\83\8d\83O\83\89\83\80\82ð\83\89\83b\83v\82·\82é\82É\82Í\81A"wrap"\83{\83^\83\93\82ð\89\9f\82µ\82Ü\82·\81B"wrap"\83{\83^\83\93\82ð\89\9f
+    \82·\82Æ\88È\89º\82Ì\82æ\82¤\82È\83_\83C\83A\83\8d\83O\82ª\95\\8e¦\82³\82ê\82Ü\82·\81B
+
+    \84¡\84\9f\84¦\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84¦\84\9f\84¦\84\9f\84¦\84\9f\84¢
+    \84 \81@\84 idn wrapper - Wrap Executable                   \84 \81Q\84 \81 \84 \81~\84 
+    \84¥\84\9f\84¨\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84¨\84\9f\84¨\84\9f\84¨\84\9f\84§
+    \84           \84¡\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84¢\84¡\84\9f\84\9f\84\9f\84\9f\84¢\84 
+    \84  Program: \84                                       \84 \84 Browse..\84 \84 
+    \84           \84¤\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84£\84¤\84\9f\84\9f\84\9f\84\9f\84£\84 
+    \84           \84¡\84\9f\84\9f\84\9f\84¢                                            \84 
+    \84 Encoding: \84       \84   \81\9bDefault  \81\9bUTF-8                        \84 
+    \84           \84¤\84\9f\84\9f\84\9f\84£                                            \84 
+    \84            \81  Force local DLL reference                         \84 
+    \84¥\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84§
+    \84                                         \84¡\84\9f\84\9f\84\9f\84\9f\84¢\84¡\84\9f\84\9f\84\9f\84\9f\84¢\84 
+    \84                                         \84   wrap  \84 \84  cancel \84 \84 
+    \84                                         \84¤\84\9f\84\9f\84\9f\84\9f\84£\84¤\84\9f\84\9f\84\9f\84\9f\84£\84 
+    \84¤\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84£
+
+    \8dÅ\8f\89\82É\81A\83\89\83b\83v\82·\82é\83v\83\8d\83O\83\89\83\80\82Ì\8eÀ\8ds\83t\83@\83C\83\8b\96¼\82ð\90Ý\92è\82µ\82Ü\82·\81B\92¼\90Ú\93ü\97Í
+    \82·\82é\82©\81A\83u\83\89\83E\83Y\83{\83^\83\93\82Å\83t\83@\83C\83\8b\82ð\92T\82µ\82Ä\82­\82¾\82³\82¢\81B\8e\9f\82É\82»\82Ì\83v\83\8d\83O\83\89
+    \83\80\82Ì\83\8d\81[\83J\83\8b\83G\83\93\83R\81[\83f\83B\83\93\83O\82ð\8ew\92è\82µ\82Ü\82·\81B\92Ê\8fí\82Í\81uDefault\81\82Å\82©\82Ü
+    \82¢\82Ü\82¹\82ñ\81B\83v\83\8d\83O\83\89\83\80\82ª\8d\91\8dÛ\89»\83G\83\93\83R\81[\83f\83B\83\93\83O\82É\8f]\82Á\82Ä\82¢\82é\8fê\8d\87\82É\82Ì\82Ý
+    \81uUTF-8\81\82ð\8ew\8e¦\82µ\82Ü\82·\81B
+
+    \81uForce local DLL reference\81v\83{\83^\83\93\82É\82æ\82è\81A\83\89\83b\83v\82·\82é\83v\83\8d\83O\83\89\83\80\82Ì
+    DLL \82Ì\92T\8dõ\8f\87\8f\98\82ð\95Ï\8dX\82·\82é\82±\82Æ\82ª\82Å\82«\82Ü\82· (\82½\82¾\82µ Windows95 \82É\82Í\82±\82Ì
+    \8b@\94\\82ª\82È\82¢\82½\82ß\81A\82±\82Ì\83{\83^\83\93\82à\95\\8e¦\82³\82ê\82Ü\82¹\82ñ)\81B\82±\82Ì\83{\83^\83\93\82ð\83`\83F\83b\83N
+    \82·\82é\82Æ\81A\82½\82Æ\82¦\83v\83\8d\83O\83\89\83\80\82ª\95Ê\82Ì\8fê\8f\8a\82Ì DLL \82ð\8ew\92è\82µ\82Ä\82¢\82Ä\82à\81A\8fí\82É\8eÀ
+    \8ds\83t\83@\83C\83\8b\82ª\82 \82é\83f\83B\83\8c\83N\83g\83\8a\82Ì DLL \82ª\97D\90æ\82³\82ê\82é\82æ\82¤\82É\82È\82è\82Ü\82·\81B\82à
+    \82µ\83v\83\8d\83O\83\89\83\80\82ª\82¤\82Ü\82­\83\89\83b\83v\82Å\82«\82È\82¢\8fê\8d\87\82É\82Í\81A\82±\82Ì\83{\83^\83\93\82ð\83`\83F\83b\83N\82·
+    \82é\82Æ\82¤\82Ü\82­\82¢\82­\82©\82à\82µ\82ê\82Ü\82¹\82ñ\81B\82½\82¾\82µ\93¯\8e\9e\82É\91¼\82Ì\96â\91è\82ª\94­\90\82·\82é\89Â\94\\90«
+    \82à\82 \82è\82Ü\82·\81B
+
+    \8dÅ\8cã\82É\81uwrap\81v\83{\83^\83\93\82ð\89\9f\82¹\82Î\81A\83v\83\8d\83O\83\89\83\80\82ª\81A\8ew\92è\82³\82ê\82½\83G\83\93\83R\81[\83f\83B
+    \83\93\83O\82Å\83\89\83b\83v\82³\82ê\82Ü\82·\81B\83\89\83b\83v\82³\82ê\82½\83v\83\8d\83O\83\89\83\80\82Í\81A\8dÅ\8f\89\82Ì\83E\83B\83\93\83h\83E\82Ì
+    \83\8a\83X\83g\83{\83b\83N\83X\82É\94½\89f\82³\82ê\82Ü\82·\81B
+
+    idn wrapper \82ð\83o\81[\83W\83\87\83\93\83A\83b\83v\82µ\82½\8fê\8d\87\82É\82Í\81A\83\89\83b\83v\97p\82Ì DLL \82ð\83A\83b\83v
+    \83f\81[\83g\82·\82é\82½\82ß\82É\81A\83v\83\8d\83O\83\89\83\80\82ð\8dÄ\83\89\83b\83v\82·\82é\95K\97v\82ª\82 \82è\82Ü\82·\81B\82±\82Ì\82½\82ß\82É\81A
+    \8c»\8dÝ\83\89\83b\83v\82³\82ê\82Ä\82¢\82é\83v\83\8d\83O\83\89\83\80\82É\91Î\82µ\82Ä\8dÄ\93x\83\89\83b\83v\82ð\8ds\82¤\82½\82ß\82Ì\81urewrap
+    all\81v\83{\83^\83\93\82ª\97p\88Ó\82³\82ê\82Ä\82¢\82Ü\82·\81B
+
+    \83v\83\8d\83O\83\89\83\80\82É\91Î\82·\82é\83\89\83b\83v\82ð\89ð\8f\9c\82·\82é\82É\82Í\81A\83\8a\83X\83g\83{\83b\83N\83X\82Å\89ð\8f\9c\82·\82é\83v\83\8d
+    \83O\83\89\83\80\82ð\91I\91ð\82µ\82Ä\81A\81uunwrap\81v\83{\83^\83\93\82ð\89\9f\82µ\82Ü\82·\81B\88È\89º\82Ì\8am\94F\97p\82Ì\83_\83C\83A\83\8d
+    \83O\82ª\95\\8e¦\82³\82ê\82Ü\82·\82Ì\82Å\81A\8aÔ\88á\82¢\82ª\82È\82¯\82ê\82Î\81uunwrap\81v\83{\83^\83\93\82ð\89\9f\82µ\82Ä\82­\82¾\82³
+    \82¢\81B
+
+    \84¡\84\9f\84¦\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84¦\84\9f\84¦\84\9f\84¦\84\9f\84¢
+    \84 \81@\84 idn wrapper - Unwrap Executable                 \84 \81Q\84 \81 \84 \81~\84 
+    \84¥\84\9f\84¨\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84¨\84\9f\84¨\84\9f\84¨\84\9f\84§
+    \84           \84¡\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84¢\84 
+    \84 Program:  \84                                                   \84 \84 
+    \84           \84¤\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84£\84 
+    \84¥\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84§
+    \84                                         \84¡\84\9f\84\9f\84\9f\84\9f\84¢\84¡\84\9f\84\9f\84\9f\84\9f\84¢\84 
+    \84                                         \84  Unwrap \84 \84  Cancel \84 \84 
+    \84                                         \84¤\84\9f\84\9f\84\9f\84\9f\84£\84¤\84\9f\84\9f\84\9f\84\9f\84£\84 
+    \84¤\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84£
+
+    \83\89\83b\83v\82ª\89ð\8f\9c\82³\82ê\82é\82Æ\81A\82»\82Ì\83v\83\8d\83O\83\89\83\80\82Í\8dÅ\8f\89\82Ì\83E\83B\83\93\83h\83E\82Ì\83\8a\83X\83g\83{\83b\83N
+    \83X\82©\82ç\82à\8dí\8f\9c\82³\82ê\82Ü\82·\81B
+
+    \83v\83\8d\83O\83\89\83\80\82É\91Î\82µ\82Ä\8c»\8dÝ\90Ý\92è\82³\82ê\82Ä\82¢\82é\83\89\83b\83v\82ð\82·\82×\82Ä\89ð\8f\9c\82·\82é\82½\82ß\82Ì
+    \81uunwrap all\81v\83{\83^\83\93\82à\97p\88Ó\82³\82ê\82Ä\82¢\82Ü\82·\81B
+
+    \83\8d\83O\82Ì\90Ý\92è\82ð\8ds\82¤\82É\82Í\81A"log" \83{\83^\83\93\82ð\89\9f\82µ\82Ü\82·\81B\8e\9f\82Ì\82æ\82¤\82È\83_\83C\83A\83\8d\83O\82ª
+    \95\\8e¦\82³\82ê\82Ü\82·\81B
+
+    \84¡\84\9f\84¦\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84¦\84\9f\84¦\84\9f\84¦\84\9f\84¢
+    \84 \81@\84 idn wrapper - Log Configuration                 \84 \81Q\84 \81 \84 \81~\84 
+    \84¥\84\9f\84¨\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84¨\84\9f\84¨\84\9f\84¨\84\9f\84§
+    \84     Log Level: \81\9bNone \81\9bFatal \81\9bError \81\9bWarning \81\9bInfo \81\9bTrace  \84 
+    \84               \84¡\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84¢\84¡\84\9f\84\9f\84\9f\84\9f\84¢\84 
+    \84      Log File:\84                                   \84 \84 Browse..\84 \84 
+    \84               \84¤\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84£\84¤\84\9f\84\9f\84\9f\84\9f\84£\84 
+    \84               \84¡\84\9f\84\9f\84\9f\84¢ \84¡\84\9f\84\9f\84\9f\84¢                             \84 
+    \84 Log Operation:\84  View \84  \84 Delete\84                              \84 
+    \84               \84¤\84\9f\84\9f\84\9f\84£ \84¤\84\9f\84\9f\84\9f\84£                             \84 
+    \84¥\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84§
+    \84                                         \84¡\84\9f\84\9f\84\9f\84\9f\84¢\84¡\84\9f\84\9f\84\9f\84\9f\84¢\84 
+    \84                                         \84    OK   \84 \84  Cancel \84 \84 
+    \84                                         \84¤\84\9f\84\9f\84\9f\84\9f\84£\84¤\84\9f\84\9f\84\9f\84\9f\84£\84 
+    \84¤\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84£
+
+    \83\8d\83O\83\8c\83x\83\8b\82Í\8e\9f\82Ì\92\86\82©\82ç\91I\91ð\82·\82é\82±\82Æ\82ª\82Å\82«\82Ü\82·\81B
+       None    \83\8d\83O\82ð\8fo\97Í\82µ\82È\82¢
+       Fatal   \92v\96½\93I\83G\83\89\81[\82Ì\82Ý\8bL\98^\82·\82é
+       Error   \92v\96½\93I\82Å\82È\82¢\83G\83\89\81[\82à\8bL\98^\82·\82é
+       Warning \8cx\8d\90\83\81\83b\83Z\81[\83W\82à\8bL\98^\82·\82é
+       Info    \82»\82Ì\91¼\82Ì\8fî\95ñ\82à\8bL\98^\82·\82é
+       Trace   \83g\83\8c\81[\83X\8fo\97Í\82à\8bL\98^\82·\82é
+    \82±\82±\82É\82 \82°\82½\83\8d\83O\83\8c\83x\83\8b\82Ì\90Ý\92è\82Í\81AIDN \83\89\83C\83u\83\89\83\8a (idnkit.dll) \82ª\8fo\97Í\82·\82é
+    \83\8d\83O\82É\91Î\82µ\82Ä\82Ì\82Ý\97L\8cø\82Å\82·\81Bidn wrapper \8e©\90g\82ª\8fo\97Í\82·\82é\83\8d\83O\82Í ON/OFF
+    \82µ\82©\82Å\82«\82Ü\82¹\82ñ\81BNone \82ð\8ew\92è\82·\82é\82Æ OFF \82É\81A\82»\82ê\88È\8aO\82Ì\83\8c\83x\83\8b\82ð\8ew\92è\82·\82é\82Æ
+    ON \82É\82È\82è\82Ü\82·\81B
+
+    \82±\82Ì\83_\83C\83A\83\8d\83O\82ð\97p\82¢\82Ä\81A\83\8d\83O\83t\83@\83C\83\8b\82Ì\83p\83X\96¼\82ð\8ew\92è\82·\82é\82±\82Æ\82à\82Å\82«\82Ü\82·\81B
+
+    \82Ü\82½\81A\83\8d\83O\83t\83@\83C\83\8b\82Ì\93à\97e\82ð\95\\8e¦\82³\82¹\82½\82è\81A\83\8d\83O\83t\83@\83C\83\8b\82ð\8dí\8f\9c\82·\82é\82±\82Æ\82à
+    \89Â\94\\82Å\82·\81B
+
+    \83\8d\83O\83\8c\83x\83\8b\82â\83\8d\83O\83t\83@\83C\83\8b\82Ì\90Ý\92è\82Í\81A\90Ý\92è\8e\9e\82É\82·\82Å\82É\93®\8dì\82µ\82Ä\82¢\82é\83v\83\8d\83Z\83X
+    \82É\82Í\89e\8b¿\82ð\97^\82¦\82È\82¢\82±\82Æ\82É\8bC\82ð\82Â\82¯\82Ä\82­\82¾\82³\82¢\81B
+
+    "advanced" \83{\83^\83\93\82ð\89\9f\82·\82Æ\81uadvanced configuration\81v\97p\82Ì\83_\83C\83A\83\8d\83O
+    \82ª\95\\8e¦\82³\82ê\82Ü\82·\81B\82±\82Ì\83_\83C\83A\83\8d\83O\82Í\8fã\8b\89\83\86\81[\83U\82Ì\82½\82ß\82Ì\82à\82Ì\82Å\81A\93K\90Ø\82È\83f
+    \83t\83H\83\8b\83g\82ª\90Ý\92è\82³\82ê\82Ä\82¢\82é\82½\82ß\82É\92Ê\8fí\83\86\81[\83U\82ª\95Ï\8dX\82·\82é\95K\97v\82Ì\82È\82¢\82æ\82¤\82È
+    \8aî\96{\93I\82È\83p\83\89\83\81\81[\83^\82ð\95Ï\8dX\82·\82é\82±\82Æ\82ª\82Å\82«\82Ü\82·\81B
+
+    \84¡\84\9f\84¦\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84¦\84\9f\84¦\84\9f\84¦\84\9f\84¢
+    \84 \81@\84 idn wrapper - Advanced Configuration            \84 \81Q\84 \81 \84 \81~\84 
+    \84¥\84\9f\84¨\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84¨\84\9f\84¨\84\9f\84¨\84\9f\84§
+    \84                     IDN Wrapping Mode                           \84 
+    \84   \81\9bWrap both WINSOCK 1.1 and WINSOCK 2.0                       \84 
+    \84   \81\9bWrap only WINSOCK 1.1                                       \84 
+    \84   \81\9bWrap only WINSOCK 2.0                                       \84 
+    \84   \81\9bWrap only WINSOCK 2.0 if it exists.                         \84 
+    \84     Otherwise wrap only WINSOCK 1.1                             \84 
+    \84¥\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84§
+    \84                     IDN Configuration                           \84 
+    \84               \84¡\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84¢\84¡\84\9f\84\9f\84\9f\84\9f\84¢\84 
+    \84      Log File:\84                                   \84 \84 Browse..\84 \84 
+    \84               \84¤\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84£\84¤\84\9f\84\9f\84\9f\84\9f\84£\84 
+    \84               \84¡\84\9f\84\9f\84\9f\84¢                                        \84 
+    \84               \84  Edit \84                                         \84 
+    \84               \84¤\84\9f\84\9f\84\9f\84£                                        \84 
+    \84¥\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84§
+    \84                                         \84¡\84\9f\84\9f\84\9f\84\9f\84¢\84¡\84\9f\84\9f\84\9f\84\9f\84¢\84 
+    \84                                         \84    OK   \84 \84  Cancel \84 \84 
+    \84                                         \84¤\84\9f\84\9f\84\9f\84\9f\84£\84¤\84\9f\84\9f\84\9f\84\9f\84£\84 
+    \84¤\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84£
+    
+    \82±\82Ì\83_\83C\83A\83\8d\83O\82ð\8eg\97p\82µ\82Ä\81A\8e\9f\82Ì3\8eí\97Þ\82Ì\90Ý\92è\82ð\8ds\82¤\82±\82Æ\82ª\82Å\82«\82Ü\82·\81B
+
+    Wrapping Mode
+       \83\89\83b\83v\95û\96@\82ð\90Ý\92è\82µ\82Ü\82·\81B\92Ê\8fí\82Í\83f\83t\83H\83\8b\83g\82Å\90Ý\92è\82³\82ê\82Ä\82¢\82é\8d\80\96Ú\82ð
+       \91I\91ð\82µ\82Ä\82¨\82¯\82Î\82æ\82¢\82Í\82¸\82Å\82·\82ª\81A\96â\91è\82ª\8bN\82Á\82½\82Æ\82«\82É\82Í\95Ê\82Ì\8d\80\96Ú\82É\82·
+       \82é\82Æ\93®\82­\82æ\82¤\82É\82È\82é\82©\82à\82µ\82ê\82Ü\82¹\82ñ\81B
+
+    IDN Configuration
+       \83R\83\93\83t\83B\83M\83\85\83\8c\81[\83V\83\87\83\93\83t\83@\83C\83\8b\96¼\82ð\8ew\92è\82µ\82Ü\82·\81B\82Ü\82½ "Edit" \83{\83^
+       \83\93\82ð\89\9f\82·\82±\82Æ\82É\82æ\82è\81A\83t\83@\83C\83\8b\82Ì\93à\97e\82ð\95Ò\8fW\82·\82é\82±\82Æ\82à\89Â\94\\82Å\82·\81B
+    
+4. \90§\8cÀ\8e\96\8d\80
+
+4.1. DLL \83o\81[\83W\83\87\83\93
+
+    \83\89\83b\83p\81[DLL \82Í\81A\8c³\82ÌWINSOCK \82ÌDLL \82Ì\83o\81[\83W\83\87\83\93\82É\8b­\82­\88Ë\91\82µ\82Ü\82·\81B\82±\82ê
+    \82Í\81A\94ñ\8cö\8aJ\82Ì\83G\83\93\83g\83\8a\82à\8aÜ\82ß\82Ä\82·\82×\82Ä\82Ì\83G\83\93\83g\83\8a\82ð\92ñ\8b\9f\82·\82é\95K\97v\82ª\82 \82é\82½\82ß
+    \82Å\82·\81B\82±\82Ì\82½\82ßWINSOCK DLL \82Ì\83o\81[\83W\83\87\83\93\82ª\95Ï\82í\82é\82Æ\81Aidn wrapper \82ª\93®\8dì
+    \82µ\82È\82­\82È\82é\89Â\94\\90«\82ª\82 \82è\82Ü\82·\81B
+    
+    \8d¡\89ñ\8dì\90¬\82³\82ê\82½idn wrapper \82Í\81A
+    
+        Win2000         (WINSOCK 1.1 + 2.0)
+       WinME           (WINSOCK 1.1 + 2.0)
+
+    \82Å\93®\8dì\82ð\8am\94F\82µ\82Ä\82¢\82Ü\82·\81B\82½\82¾\81A\8f«\97\88\82É\82í\82½\82Á\82Ä\93®\8dì\82·\82é\95Û\8fØ\82Í\82 \82è\82Ü\82¹\82ñ\81B
+
+4.2. DNS, WINS, LMHOSTS
+
+    Windows \82Å\82Í\81ADNS \82¾\82¯\82Å\82Í\82È\82­\81AWINS\82âLMHOSTS \82É\82æ\82Á\82Ä\82à\83h\83\81\83C\83\93\96¼\81A
+    \83z\83X\83g\96¼\82Ì\89ð\8c\88\82ª\8ds\82È\82í\82ê\82Ü\82·\81Bidn wrapper \82ð\8eg\82Á\82½\8fê\8d\87\82É\82Í\81A\83h\83\81\83C\83\93
+    \96¼\82Ì\95Ï\8a·\82ª\81A\82±\82ê\82ç\82Ì\95û\8e®\82Ö\82Ì\83f\83B\83X\83p\83b\83`\82ð\8ds\82È\82¤\8fê\8f\8a\82æ\82è\82à\8fã\88Ê\91w\82Å\8ds
+    \82È\82í\82ê\82é\82Ì\82Å\81A\82±\82ê\82ç\82Ì\82·\82×\82Ä\82Ì\95û\8e®\82É\82Â\82¢\82Ä\81A\83h\83\81\83C\83\93\96¼\81A\83z\83X\83g\96¼\82Ì\95Ï
+    \8a·\82ª\8ds\82È\82í\82ê\82é\82±\82Æ\82É\82È\82è\82Ü\82·\81B\82±\82Ì\82½\82ß\81AWindows \82ª\81AWINS\82âLMHOSTS \82ð
+    \8eg\82Á\82Ä\82¢\82é\8fê\8d\87\82É\82Í\81A\97\\8aú\82µ\82È\82¢\96â\91è\82ª\94­\90\82·\82é\89Â\94\\90«\82ª\82 \82è\82Ü\82·\81B\82±\82ê\82É
+    \82Â\82¢\82Ä\82Í\81Aidn wrapper \82ð\8eg\82¤\8fê\8d\87\82É\82Í\81A\96¼\91O\89ð\8c\88\82ÉDNS \82¾\82¯\82ð\8eg\97p\82·\82é\82±
+    \82Æ\82ð\82¨\8a©\82ß\82µ\82Ü\82·\81B
+
+3.3. \83h\83\81\83C\83\93\96¼\88È\8aO\82Ì\96¼\91O\82Ì\89ð\8c\88
+
+    WINSOCK 2.0 \82Ì\96¼\91O\89ð\8c\88API 
+
+        WSALookupServiceBeginA
+       WSALookupServiceNextA
+       WSALookupServiceEnd
+
+    \82Í\81A\83h\83\81\83C\83\93\96¼\88È\8aO\82Å\82à\8eg\97p\82Å\82«\82é\81A\94Ä\97p\82Ì\96¼\91O\89ð\8c\88\97p\82ÌAPI \82Æ\82µ\82Ä\92è\8b`\82³
+    \82ê\82Ä\82¢\82Ü\82·\81B\8c»\8e\9e\93_\82Å\82Í\81A\82±\82ê\82ç\82Í\82à\82Á\82Ï\82ç\83h\83\81\83C\83\93\96¼\82Ì\89ð\8c\88\82Å\8eg\97p\82³\82ê\82Ä
+    \82¢\82Ü\82·\82ª\81A\91¼\82Ì\96¼\91O(\97á\82¦\82Î\83T\81[\83r\83X\96¼)\82Ì\89ð\8c\88\82É\82à\8eg\97p\82Å\82«\82é\82±\82Æ\82É\82È\82Á\82Ä
+    \82¢\82Ü\82·\81B
+
+    idn wrapper \82Í\81A\96¼\91O\82Ì\91Î\8fÛ\82Ì\94@\89½\82É\82©\82©\82í\82ç\82¸\81A\96¼\91O\82Ì\83G\83\93\83R\81[\83f\83B\83\93\83O
+    \82ð\95Ï\8a·\82µ\82Ä\82µ\82Ü\82¤\82Ì\82Å\81A\82±\82ê\82ç\82ÌAPI \82ª\81A\83h\83\81\83C\83\93\96¼\88È\8aO\82Ì\89ð\8c\88\82É\8eg\82í\82ê\82Ä
+    \82¢\82é\8fê\8d\87\82É\82Í\81A\96â\91è\82ð\88ø\82«\8bN\82±\82·\89Â\94\\90«\82ª\82 \82è\82Ü\82·\81B
+
+4.4. \96¼\91O\89ð\8c\88API \82ð\8eg\82í\82È\82¢\83v\83\8d\83O\83\89\83\80
+
+    \83A\83v\83\8a\83P\81[\83V\83\87\83\93\82É\82æ\82Á\82Ä\82Í\81A\83h\83\81\83C\83\93\96¼\82Ì\89ð\8c\88\82É\82±\82ê\82ç\82ÌAPI \82ð\8eg\97p\82µ\82È
+    \82¢\82à\82Ì\82à\82 \82è\82Ü\82·\81B\97á\82¦\82Î\81A'nslookup'\82Í\81A\82±\82ê\82ç\82ÌAPI \82ð\8eg\97p\82µ\82È\82¢\82Å\81A
+    \92¼\90ÚDNS \83T\81[\83o\82Æ\92Ê\90M\82µ\82Ä\82µ\82Ü\82¢\82Ü\82·\81B\82±\82Ì\82æ\82¤\82È\83A\83v\83\8a\83P\81[\83V\83\87\83\93\82É\82Â\82¢
+    \82Ä\82Í\81Aidn wrapper \82Í\96ð\82É\97§\82¿\82Ü\82¹\82ñ\81B
+
+4.5. \93Á\92èWINSOCK DLL \82É\83o\83C\83\93\83h\82³\82ê\82½\83A\83v\83\8a\83P\81[\83V\83\87\83\93
+
+    \83A\83v\83\8a\83P\81[\83V\83\87\83\93\82É\82æ\82Á\82Ä\82Í\81A\95W\8f\80\82ÌDLL \83T\81[\83`\83p\83X\82É\8f]\82í\82È\82¢\82Å\81A\93Á\92è\82Ì
+    \83p\83X\82ÌDLL \82É\83o\83C\83\93\83h\82³\82ê\82Ä\82¢\82é\82à\82Ì\82ª\82 \82è\82Ü\82·\81B\82æ\82­\8eg\82í\82ê\82é\83v\83\8d\83O\83\89\83\80
+    \82Ì\92\86\82Å\82Í\81ANetscape Communicator \82ª\82»\82¤\82È\82Á\82Ä\82¢\82Ü\82·\81B\82±\82Ì\82æ\82¤\82È\83v\83\8d\83O
+    \83\89\83\80\82É\82Â\82¢\82Ä\82Í\81A\95W\8f\80\82Ì\83C\83\93\83X\83g\81[\83\8b\81^\83R\83\93\83t\83B\83M\83\85\83\8c\81[\83V\83\87\83\93\82Å\82Í\83\89\83b\83v
+    \82·\82é\82±\82Æ\82Í\82Å\82«\82Ü\82¹\82ñ\81B
+    
+    \82±\82Ì\82æ\82¤\82È\83v\83\8d\83O\83\89\83\80\82É\82Â\82¢\82Ä\81A\82Ç\82¤\82µ\82Ä\82à\83\89\83b\83v\82·\82é\95K\97v\82ª\82 \82é\82È\82ç\81A\83V
+    \83X\83e\83\80\83f\83B\83\8c\83N\83g\83\8a\82Ö\82Ì\83C\83\93\83X\83g\81[\83\8b\82ð\8ds\82È\82¤\82±\82Æ\82ª\82Å\82«\82Ü\82·\81B\82½\82¾\82µ\81A\82±
+    \82Ì\83C\83\93\83X\83g\81[\83\8b\82Í\91å\95Ï\8aë\8c¯\82Å\81A\8fê\8d\87\82É\82æ\82Á\82Ä\82Í\83V\83X\83e\83\80\82ð\8dÄ\8bN\93®\95s\94\\82É\82µ\82Ä
+    \82µ\82Ü\82¤\89Â\94\\90«\82à\82 \82è\82Ü\82·\81B
+
+5. \83\8c\83W\83X\83g\83\8a\90Ý\92è - \82Ü\82Æ\82ß
+
+5.1. \83\8c\83W\83X\83g\83\8a\82Ì\97D\90æ\8f\87\88Ê
+
+    idn wrapper \82Ì\90Ý\92è\8fî\95ñ\82Í\81AHKEY_LOCAL_MACHINE\81AHKEY_CURRENT_USER\82Ì
+
+        Software\JPNIC\IDN
+
+    \88È\89º\82É\8ai\94[\82³\82ê\82Ü\82·\81Bidn wrapper\82Í\8dÅ\8f\89\82ÉHKEY_LOCAL_MACHINE\82Ì\90Ý\92è\82ð\93Ç
+    \82Ý\8d\9e\82Ý\81AHKEY_CURRENT_USER\91¤\82É\82à\90Ý\92è\82ª\82 \82ê\82Î\81A\82±\82ê\82Å\8fã\8f\91\82«\82µ\82Ü\82·\81B\92Ê
+    \8fí\82Í\81AHKEY_LOCAL_MACHINE \91¤\82¾\82¯\82ð\90Ý\92è\82µ\82Ü\82·\81B\83\86\81[\83U\8cÂ\95Ê\82É\88Ù\82È\82Á\82½\90Ý
+    \92è\82ð\8eg\82¢\82½\82¢\8fê\8d\87\82Ì\82Ý\81AHKEY_CURRENT_USER\82ð\90Ý\92è\82·\82é\82æ\82¤\82É\82µ\82Ä\82­\82¾\82³\82¢\81B
+
+    \82È\82¨\81A\83R\83\93\83t\83B\83M\83\85\83\8c\81[\83V\83\87\83\93\83v\83\8d\83O\83\89\83\80\82Í HKEY_LOCAL_MACHINE \82Ì\90Ý\92è
+    \82¾\82¯\82ð\93Ç\82Ý\8f\91\82«\82·\82é\82æ\82¤\82É\82È\82Á\82Ä\82¢\82Ü\82·\81B
+    
+4.2. \83\8c\83W\83X\83g\83\8a\83L\81[
+
+    \91S\91Ì\82Ì\8b¤\92Ê\82Ì\90Ý\92è\82Æ\81A\83v\83\8d\83O\83\89\83\80\8cÂ\95Ê\90Ý\92è\82Æ\82ª\82 \82è\82Ü\82·\81B
+
+\81Q\8b¤\92Ê\92è\8b`
+
+       Software\JPNIC\IDN\InstallDir    \83C\83\93\83X\83g\81[\83\8b\83f\83B\83\8c\83N\83g\83\8a
+        Software\JPNIC\IDN\Where         \95Ï\8a·\88Ê\92u
+                           0:WINSOCK1.1 WINSOCK2.0\82Ì\97¼\95û\82Å
+                            1:WINSOCK2.0 \82ª\82 \82ê\82Î\82»\82¿\82ç\82Å
+                           2:WINSOCK1.1 \82¾\82¯\82Å
+                           3:WINSOCK2.0 \82¾\82¯\82Å
+       Software\JPNIC\IDN\ConfFile      idnkit \82Ì\90Ý\92è\83t\83@\83C\83\8b
+        Software\JPNIC\IDN\LogLevel      \83\8d\83O\83\8c\83x\83\8b
+        Software\JPNIC\IDN\LogFile       \83\8d\83O\83t\83@\83C\83\8b
+
+\81Q\83v\83\8d\83O\83\89\83\80\8cÂ\95Ê\90Ý\92è
+
+    \95Ï\8a·\88Ê\92u\81A\82¨\82æ\82Ñ\83v\83\8d\83O\83\89\83\80\91¤\82Ì\83G\83\93\83R\81[\83f\83B\83\93\83O\82Í\83v\83\8d\83O\83\89\83\80\96\88\82É\93Á\92è\82·
+    \82é\82±\82Æ\82à\82Å\82«\82Ü\82·\81B\82±\82ê\82ç\82Í\81A\88È\89º\82Ì\83L\81[\83n\83C\83u\82Ì\89º\82É\81A\83v\83\8d\83O\83\89\83\80\96¼\82ð\83L\81[
+    \82Æ\82·\82é\92l\82Å\90Ý\92è\82µ\82Ü\82·\81B
+
+        Software\JPNIC\IDN\PerProg\<name>\Where
+        Software\JPNIC\IDN\PerProg\<name>\Encoding
+
+    \8ew\92è\82³\82ê\82Ä\82¢\82È\82¢\8fê\8d\87\82É\82Í\81A
+    
+        Where       0       1.1\81A2.0 \82Ì\97¼\95û\82Å\95Ï\8a·
+       Encoding            \83v\83\8d\83Z\83X\82Ì\83R\81[\83h\83y\81[\83W
+
+    \82Æ\82Ý\82È\82µ\82Ü\82·\81B
+
diff --git a/contrib/idn/idnkit-1.0-src/wsock/common/checkdll.c b/contrib/idn/idnkit-1.0-src/wsock/common/checkdll.c
new file mode 100644 (file)
index 0000000..a620cc9
--- /dev/null
@@ -0,0 +1,242 @@
+/*
+ * checkdll.c - Winsock DLL/IDN processing status
+ */
+
+/*
+ * 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 <windows.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "wrapcommon.h"
+
+static int winsock_idx;                /* index of winsock_info[] */
+
+static struct winsock_type {
+       char *version;          /* winsock version */
+       char *name;             /* wrapper DLL name */
+       char *original_name;    /* original DLL name */
+} winsock_info[] = {
+#define IDN_IDX_WS11 0
+       { "1.1", "WSOCK32", "WSOCK32O" },
+#define IDN_IDX_WS20 1
+       { "2.0", "WS2_32",  "WS2_32O" },
+       { NULL, NULL, NULL },
+};
+
+static HINSTANCE       load_original_dll(void);
+static BOOL            check_idn_processing(void);
+static BOOL            check_dll(const char *name);
+
+BOOL
+idnWinsockVersion(const char *version) {
+       int i;
+       for (i = 0; winsock_info[i].version != NULL; i++) {
+               if (strcmp(winsock_info[i].version, version) == 0) {
+                       winsock_idx = i;
+                       idnLogPrintf(idn_log_level_trace,
+                                    "idnWinsockVersion: version %s\n",
+                                    version);
+                       return (TRUE);
+               }
+       }
+       idnLogPrintf(idn_log_level_fatal,
+                    "idnWinsockVersion: unknown winsock version %s\n",
+                    version);
+       return (FALSE);
+}
+
+HINSTANCE
+idnWinsockHandle(void) {
+       static HINSTANCE dll_handle = NULL;
+       static int initialized = 0;
+
+       if (!initialized) {
+               /* Get the handle of the original winsock DLL */
+               idnLogPrintf(idn_log_level_trace,
+                            "idnWinsockHandle: loading original DLL..\n");
+               dll_handle = load_original_dll();
+       }
+       initialized = 1;
+       return (dll_handle);
+}
+
+idn_resconf_t
+idnGetContext(void) {
+       static int initialized = 0;
+       static idn_resconf_t ctx = NULL;
+
+       if (!initialized) {
+               /*
+                * Check whether IDN processing should be done
+                * in this wrapper DLL.
+                */
+               idnLogPrintf(idn_log_level_trace,
+                            "idnGetContext: checking IDN status..\n");
+               if (check_idn_processing()) {
+                       /* Initialize idnkit */
+                       ctx = idnConvInit();
+                       idnLogPrintf(idn_log_level_info,
+                                    "Processing context: %08x\n", ctx);
+               } else {
+                       idnLogPrintf(idn_log_level_info,
+                                    "NOT process IDN here\n");
+                       ctx = NULL;
+               }
+               initialized = 1;
+       }
+
+       return (ctx);
+}
+
+static HINSTANCE
+load_original_dll(void) {
+       /*
+        * Load Original DLL
+        */
+       char dllpath[MAX_PATH];
+       const char *dll_name = winsock_info[winsock_idx].original_name;
+       HINSTANCE handle;
+
+       /*
+        * Get idn wrapper's install directory, where the copies of
+        * the original winsock DLLs are saved.
+        */
+       dllpath[0] = '\0';
+       if (idnGetInstallDir(dllpath, sizeof(dllpath)) != TRUE) {
+               idnLogPrintf(idn_log_level_fatal,
+                            "idnWinsockHandle: cannot find idn wrapper's "
+                            "install directory\n");
+               abort();
+               return (NULL);  /* for lint */
+       }
+       /* Strip the trailing backslash. */
+       if (dllpath[0] != '\0' &&
+           dllpath[strlen(dllpath) - 1] == '\\') {
+               dllpath[strlen(dllpath) - 1] = '\0';
+       }
+       /* Is the pathname is insanely long? */
+       if (strlen(dllpath) + strlen(dll_name) + 1 + 4 >= sizeof(dllpath)) {
+               idnLogPrintf(idn_log_level_fatal,
+                            "idnWinsockHandle: idn wrapper's install path is "
+                            "too long to be true\n");
+               abort();
+               return (NULL);  /* for lint */
+       }
+       /* Append the DLL name to form a full pathname of the DLL. */
+       strcat(dllpath, "\\");
+       strcat(dllpath, dll_name);
+       strcat(dllpath, ".DLL");
+
+       idnLogPrintf(idn_log_level_trace,
+                    "idnWinsockHandle: loading original winsock DLL (%s)\n",
+                    dllpath);
+       if ((handle = LoadLibrary(dllpath)) == NULL) {
+               idnLogPrintf(idn_log_level_fatal,
+                            "idnWinsockHandle: no DLL %-.100s\n", dllpath);
+               abort();
+               return (NULL);  /* font lint */
+       }
+       return (handle);
+}
+
+static BOOL
+check_idn_processing(void) {
+       int where = idnEncodeWhere();
+       BOOL here = FALSE;
+
+       idnLogPrintf(idn_log_level_trace,
+                    "idnGetContext: Winsock%s, where=%d\n",
+                    winsock_info[winsock_idx].version, where);
+
+       switch (winsock_idx) {
+       case IDN_IDX_WS11:
+               switch (where) {
+               case IDN_ENCODE_ALWAYS:
+               case IDN_ENCODE_ONLY11:
+                       return (TRUE);
+               case IDN_ENCODE_CHECK:
+                       if (!check_dll(winsock_info[winsock_idx].name)) {
+                               return (TRUE);
+                       }
+                       break;
+               }
+               break;
+       case IDN_IDX_WS20:
+               switch (where) {
+               case IDN_ENCODE_ALWAYS:
+               case IDN_ENCODE_ONLY20:
+               case IDN_ENCODE_CHECK:
+                       return (TRUE);
+                       break;
+               }
+               break;
+       }
+       return (FALSE);
+}
+
+static BOOL
+check_dll(const char *name) {
+       HINSTANCE hdll = NULL;
+
+#if 1
+       hdll = LoadLibrary(name);
+#else
+       /*
+        * Just check the existence of the named DLL, without taking
+        * the trouble of calling DllMain.
+        */
+       hdll = LoadLibraryEx(name, NULL, LOAD_LIBRARY_AS_DATAFILE);
+#endif
+       if (hdll == NULL) {
+               idnLogPrintf(idn_log_level_trace,
+                            "idnGetContext: DLL %s does not exist\n");
+               return (FALSE);
+       } else {
+               idnLogPrintf(idn_log_level_trace,
+                            "idnGetContext: DLL %s exists\n");
+               FreeLibrary(hdll);
+               return (TRUE);
+       }
+}
diff --git a/contrib/idn/idnkit-1.0-src/wsock/common/convert.c b/contrib/idn/idnkit-1.0-src/wsock/common/convert.c
new file mode 100644 (file)
index 0000000..b2c202e
--- /dev/null
@@ -0,0 +1,180 @@
+/*
+ * convert.c - convert domain name
+ */
+
+/*
+ * 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 <windows.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "wrapcommon.h"
+
+/*
+ * prepare/dispose conversion context
+ */
+void
+idnConvDone(idn_resconf_t ctx)
+{
+       if (ctx != NULL) {
+               idnLogReset();
+               idn_resconf_destroy(ctx);
+       }
+}
+
+idn_resconf_t
+idnConvInit(void)
+{
+       char encoding[256];
+       idn_resconf_t ctx;
+       idn_result_t r;
+    
+       idnLogReset();
+
+       idnLogPrintf(idn_log_level_info, "idnkit version: %-.20s\n",
+                    idn_version_getstring());
+
+       /*
+        * Initialize.
+        */
+       if ((r = idn_resconf_initialize()) != idn_success) {
+               idnPrintf("idnConvInit: cannot initialize idn library: %s\n",
+                         idn_result_tostring(r));
+               return NULL;
+       }
+       if ((r = idn_resconf_create(&ctx)) != idn_success) {
+               idnPrintf("idnConvInit: cannot create context: %s\n",
+                         idn_result_tostring(r));
+               return NULL;
+       }
+       /*
+        * load configuration file.
+        */
+       if ((r = idn_resconf_loadfile(ctx, NULL)) != idn_success) {
+               idnPrintf("idnConvInit: cannot read configuration file: %s\n",
+                         idn_result_tostring(r));
+               if ((r = idn_resconf_setdefaults(ctx)) != idn_success) {
+                       idnPrintf("idnConvInit: setting default configuration"
+                                 " failed: %s\n",
+                                 idn_result_tostring(r));
+                       idnConvDone(ctx);
+                       return (NULL);
+               }
+               idnPrintf("idnConvInit: using default configuration\n");
+       }
+       /*
+        * Set local codeset.
+        */
+       if (idnGetPrgEncoding(encoding, sizeof(encoding)) == TRUE) {
+               idnPrintf("Encoding PRG <%-.100s>\n", encoding);
+               r = idn_resconf_setlocalconvertername(ctx, encoding,
+                                                     IDN_CONVERTER_RTCHECK);
+               if (r != idn_success) {
+                       idnPrintf("idnConvInit: invalid local codeset "
+                                 "\"%-.100s\": %s\n",
+                                 encoding, idn_result_tostring(r));
+                       idnConvDone(ctx);
+                       return NULL;
+               }
+       }
+       return ctx;
+}
+
+/*
+ * idnConvReq - convert domain name in a DNS request
+ *
+ *      convert local encoding to DNS encoding
+ */
+BOOL
+idnConvReq(idn_resconf_t ctx, const char FAR *from, char FAR *to, size_t tolen)
+{
+       idn_result_t r;
+
+       idnLogReset();
+
+       idnLogPrintf(idn_log_level_trace, "idnConvReq(from=%-.100s)\n", from);
+       if (ctx == NULL) {
+               idnLogPrintf(idn_log_level_trace, "idnConvReq: ctx is NULL\n");
+               if (strlen(from) >= tolen)
+                       return FALSE;
+               strcpy(to, from);
+               return TRUE;
+       }
+
+       r = idn_res_encodename(ctx, IDN_ENCODE_APP, from, to, tolen);
+
+       if (r == idn_success) {
+               return TRUE;
+       } else {
+               return FALSE;
+       }
+}
+
+/*
+ * idnConvRsp - convert domain name in a DNS response
+ *
+ *      convert DNS encoding to local encoding
+ */
+
+BOOL
+idnConvRsp(idn_resconf_t ctx, const char FAR *from, char FAR *to, size_t tolen)
+{
+       idnLogReset();
+
+       idnLogPrintf(idn_log_level_trace, "idnConvRsp(from=%-.100s)\n", from);
+       if (ctx == NULL) {
+               if (strlen(from) >= tolen)
+                       return FALSE;
+               strcpy(to, from);
+               return TRUE;
+       } else if (idn_res_decodename(ctx, IDN_DECODE_APP,
+                                     from, to, tolen) == idn_success) {
+               return TRUE;
+       } else {
+               return FALSE;
+       }
+}
diff --git a/contrib/idn/idnkit-1.0-src/wsock/common/dump.c b/contrib/idn/idnkit-1.0-src/wsock/common/dump.c
new file mode 100644 (file)
index 0000000..1f16bd5
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+ * dump.c - dump data
+ */
+
+/*
+ * 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 <windows.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "wrapcommon.h"
+
+char *
+dumpAddr(const char FAR *addr, int len, char *buff, size_t size) {
+       int i;
+       char *p;
+    
+       buff[0] = '\0';
+       for (i = 0, p = buff; i < len; i++) {
+               char digits[8];
+
+               sprintf(digits, "%d", (addr[i] & 0xff));
+               if (i + 1 < len) {
+                       strcat(digits, ".");
+               }
+               if (strlen(digits) >= size) {
+                       break;
+               }
+               strcpy(p, digits);
+               p += strlen(digits);
+               size -= strlen(digits);
+       }
+       return (buff);
+}
+
+char *
+dumpHost(const struct hostent FAR *hp, char *buff, size_t size) {
+       char *p = buff;
+
+       p[0] = '\0';
+       if (strlen(hp->h_name) + 1 < size) {
+               sprintf(p, "%s ", hp->h_name);
+               p += strlen(p);
+               size -= strlen(p);
+       }
+       dumpAddr(hp->h_addr_list[0], hp->h_length, p, size);
+       return (buff);
+}
+
+char *
+dumpName(const char *name, char *buff, size_t size) {
+       const char *sp;
+       char *dp;
+    
+       for (sp = name, dp = buff; *sp != '\0'; sp++) {
+               if (*sp >= 0x21 && *sp <= 0x7e) {
+                       if (size < 2) {
+                               break;
+                       }
+                       *dp++ = *sp;
+                       size--;
+               } else {
+                       if (size < 5) {
+                               break;
+                       }
+                       dp[0] = '\\';
+                       dp[1] = 'x';
+                       sprintf(dp + 2, "%02x", *sp & 0xff);
+                       dp += 4;
+                       size -= 4;
+               }
+       }
+       *dp = '\0';
+
+       return (buff);
+}
+
diff --git a/contrib/idn/idnkit-1.0-src/wsock/common/encoding.c b/contrib/idn/idnkit-1.0-src/wsock/common/encoding.c
new file mode 100644 (file)
index 0000000..f8ad9e7
--- /dev/null
@@ -0,0 +1,271 @@
+/*
+ * encoding.c - get DNS/Local encodings
+ *
+ *      Software\JPNIC\IDN\Where
+ *                        \LogFile
+ *                       \LogLevel
+ *                       \InstallDir   
+ *                        \PerProg\<name>\Where
+ *                        \PerProg\<name>\Encoding
+ */
+
+/*
+ * 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 <windows.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+
+#include "wrapcommon.h"
+
+#define IDN_GLOBAL     1
+#define IDN_PERPROG    2
+#define IDN_CURUSER    4
+
+/*
+ * Registry of Encodings
+ */
+
+#define        IDNKEY_WRAPPER  "Software\\JPNIC\\IDN"
+#define        IDNKEY_PERPROG  "Software\\JPNIC\\IDN\\PerProg"
+#define        IDNVAL_WHERE    "Where"
+#define        IDNVAL_ENCODE   "Encoding"
+#define        IDNVAL_LOGLVL   "LogLevel"
+#define        IDNVAL_LOGFILE  "LogFile"
+#define IDNVAL_INSDIR  "InstallDir"
+
+static int     GetRegistry(HKEY top, const char *key, const char *name,
+                           DWORD type, void *param, DWORD length);
+static char    *GetPerProgKey(char *buf, size_t len);
+static int     GetFromRegistry(const char *name, int where, DWORD type,
+                               void *param, DWORD length);
+static int     GetIntFromRegistry(const char *name, int defvalue, int where);
+static BOOL    GetStringFromRegistry(const char *name, char *result,
+                                     size_t length, int where);
+
+static int
+GetRegistry(HKEY top, const char *key, const char *name, DWORD type,
+           void *param, DWORD length)
+{
+       LONG stat;
+       HKEY hk;
+       DWORD realtype;
+
+       stat = RegOpenKeyEx(top, key, 0, KEY_READ, &hk);
+       if (stat != ERROR_SUCCESS) {
+               return 0;
+       }
+
+       stat = RegQueryValueEx(hk, (LPCTSTR)name, NULL,
+                              &realtype, (LPBYTE)param, &length);
+
+       RegCloseKey(hk);
+
+       if (stat != ERROR_SUCCESS || realtype != type)
+               return 0;
+
+       return 1;
+}
+
+static char *
+GetPerProgKey(char *buf, size_t len)
+{
+       char exename[256];
+       char prgname[256];
+       char *p, *last;
+
+       GetModuleFileName(NULL, exename, 256);
+     
+       for (p = exename, last = NULL; *p != '\0'; p++) {
+               if (*p == '/' || *p == '\\') {
+                       last = p;
+               }
+       }
+       strcpy(prgname, (last == NULL) ? exename : (last + 1));
+       if ((p = strrchr(prgname, '.')) != NULL) {
+               *p = '\0';
+       }
+
+       if (strlen(IDNKEY_PERPROG) + 1 + strlen(prgname) >= len) {
+               return (NULL);
+       }
+       sprintf(buf, "%s\\%s", IDNKEY_PERPROG, prgname);
+       return buf;
+}
+
+static int
+GetFromRegistry(const char *name, int where, DWORD type,
+               void *param, DWORD length)
+{
+       if (where & IDN_PERPROG) {
+               /*
+                * First, try program specific setting.
+                */
+               char keyname[256];
+
+               /*
+                * Try HKEY_CURRENT_USER and HKEY_LOCAL_MACHINE.
+                */
+               if (GetPerProgKey(keyname, sizeof(keyname)) != NULL) {
+                       if (((where & IDN_CURUSER) &&
+                            GetRegistry(HKEY_CURRENT_USER, keyname, name,
+                                        type, param, length)) ||
+                           GetRegistry(HKEY_LOCAL_MACHINE, keyname, name,
+                                       type, param, length)) {
+                               return (1);
+                       }
+               }
+       }
+
+       if (where & IDN_GLOBAL) {
+               /*
+                * Try global setting.
+                */
+               if (((where & IDN_CURUSER) &&
+                    GetRegistry(HKEY_CURRENT_USER, IDNKEY_WRAPPER, name,
+                                type, param, length)) ||
+                   GetRegistry(HKEY_LOCAL_MACHINE, IDNKEY_WRAPPER, name,
+                               type, param, length)) {
+                       return (1);
+               }
+       }
+
+       /*
+        * Not found.
+        */
+       return (0);
+}
+
+static int
+GetIntFromRegistry(const char *name, int defvalue, int where)
+{
+    DWORD param;
+
+    if (GetFromRegistry(name, where, REG_DWORD, &param, sizeof(param))) {
+           return ((int)param);
+    }
+    return (defvalue);
+}
+
+static BOOL
+GetStringFromRegistry(const char *name, char *result, size_t length, int where)
+{
+    if (GetFromRegistry(name, where, REG_SZ, result, (DWORD)length)) {
+           return (TRUE);
+    }
+    return (FALSE);
+}
+
+/*
+ * idnEncodeWhere - which module should convert domain name
+ */
+int
+idnEncodeWhere(void)
+{
+       int v = GetIntFromRegistry(IDNVAL_WHERE, IDN_ENCODE_ALWAYS,
+                                  IDN_GLOBAL|IDN_PERPROG|IDN_CURUSER);
+
+       idnLogPrintf(idn_log_level_trace, "idnEncodeWhere: %d\n", v);
+       return (v);
+}
+
+/*
+ * idnGetLogFile - refer to log file
+ */
+BOOL
+idnGetLogFile(char *file, size_t len)
+{
+       BOOL v = GetStringFromRegistry(IDNVAL_LOGFILE, file, len,
+                                      IDN_GLOBAL|IDN_CURUSER);
+
+       idnLogPrintf(idn_log_level_trace, "idnGetLogFile: %-.100s\n",
+                    (v == TRUE) ? file : "<none>");
+       return (v);
+}
+
+/*
+ * idnGetPrgEncoding - refer to Program's Local Encoding
+ *
+ *      use program name as registry key
+ */
+BOOL
+idnGetPrgEncoding(char *enc, size_t len)
+{
+       if (GetStringFromRegistry(IDNVAL_ENCODE, enc, len,
+                                 IDN_PERPROG|IDN_CURUSER) != TRUE ||
+           enc[0] == '\0') {
+               sprintf(enc, "CP%d", GetACP());
+       }
+       idnLogPrintf(idn_log_level_trace,
+                    "idnGetPrgEncoding: %-.30s\n", enc);
+       return (TRUE);
+}
+
+/*
+ * idnGetLogLevel
+ */
+int
+idnGetLogLevel(void)
+{
+       int v  = GetIntFromRegistry(IDNVAL_LOGLVL, 0,
+                                   IDN_GLOBAL|IDN_CURUSER);
+
+       idnLogPrintf(idn_log_level_trace, "idnGetLogLevel: %d\n", v);
+       return (v);
+}
+
+/*
+ * idnGetInstallDir - get idn wrapper install directory
+ */
+BOOL
+idnGetInstallDir(char *dir, size_t len)
+{
+       /* No need to look at HKEY_CURRENT_USER */
+       BOOL v = GetStringFromRegistry(IDNVAL_INSDIR, dir, len, IDN_GLOBAL);
+
+       idnLogPrintf(idn_log_level_trace, "idnGetInstallDir: %-.100s\n",
+                    (v == TRUE) ? dir : "<none>");
+       return (v);
+}
diff --git a/contrib/idn/idnkit-1.0-src/wsock/common/hook.c b/contrib/idn/idnkit-1.0-src/wsock/common/hook.c
new file mode 100644 (file)
index 0000000..b520f10
--- /dev/null
@@ -0,0 +1,224 @@
+/*
+ * hook.c - Hooking Asynchronous Completion
+ */
+
+/*
+ * 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 <windows.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "wrapcommon.h"
+
+/*
+ * Hook Managements
+ */
+
+static  HHOOK   hookHandle = NULL ;
+
+typedef struct _HOOK    *HOOKPTR;
+
+typedef struct _HOOK {
+       HOOKPTR     prev;
+       HOOKPTR     next;
+       idn_resconf_t ctx;
+       HWND        hWnd;
+       u_int       wMsg;
+       char FAR    *pBuf;
+} HOOKREC;
+
+static  HOOKREC hookList = { 0 } ;
+
+static void
+hookListInit(void) {
+       if (hookList.prev == NULL || hookList.next == NULL) {
+               hookList.prev = &hookList;
+               hookList.next = &hookList;
+       }
+}
+
+static HOOKPTR
+hookListSearch(HWND hWnd, u_int wMsg) {
+       HOOKPTR hp;
+    
+       for (hp = hookList.next ; hp != &hookList ; hp = hp->next) {
+               if (hp->hWnd == hWnd && hp->wMsg == wMsg) {
+                       return (hp);
+               }
+       }
+       return (NULL);
+}
+
+static BOOL
+hookListAppend(HWND hWnd, u_int wMsg, char FAR *buf, idn_resconf_t ctx) {
+       HOOKPTR hp, prev, next;
+    
+       if ((hp = (HOOKPTR)malloc(sizeof(HOOKREC))) == NULL) {
+               idnPrintf("cannot create hook record\n");
+               return (FALSE);
+       }
+       memset(hp, 0, sizeof(*hp));
+    
+       hp->ctx = ctx;
+       hp->hWnd = hWnd;
+       hp->wMsg = wMsg;
+       hp->pBuf = buf;
+    
+       prev = hookList.prev;
+       next = prev->next;
+       prev->next = hp;
+       next->prev = hp;
+       hp->next = next;
+       hp->prev = prev;    
+
+       return (TRUE);
+}
+
+static void
+hookListDelete(HOOKPTR hp)
+{
+       HOOKPTR prev, next;
+    
+       prev = hp->prev;
+       next = hp->next;
+       prev->next = next;
+       next->prev = prev;
+    
+       free(hp);
+}
+
+static void
+hookListDone(void)
+{
+       HOOKPTR hp;
+    
+       while ((hp = hookList.next) != &hookList) {
+               hookListDelete(hp);
+       }
+}
+
+/*
+ * idnHookInit - initialize Hook Management
+ */
+void
+idnHookInit(void) {
+       hookListInit();
+}
+
+/*
+ * idnHookDone - finalize Hook Management
+ */
+void
+idnHookDone(void) {
+       if (hookHandle != NULL) {
+               UnhookWindowsHookEx(hookHandle);
+               hookHandle = NULL;
+       }
+       hookListDone();
+}
+
+/*
+ * hookProc - hookprocedure, used as WH_GETMESSAGE hook
+ */
+LRESULT CALLBACK
+hookProc(int nCode, WPARAM wParam, LPARAM lParam) {
+       MSG             *pMsg;
+       HOOKPTR         pHook;
+       struct  hostent *pHost;
+       char            nbuff[256];
+       char            hbuff[256];
+    
+       if (nCode < 0) {
+               return (CallNextHookEx(hookHandle, nCode, wParam, lParam));
+       } else if (nCode != HC_ACTION) {
+               return (0);
+       }
+       if ((pMsg = (MSG *)lParam) == NULL) {
+               return (0);
+       }
+       if ((pHook = hookListSearch(pMsg->hwnd, pMsg->message)) == NULL) {
+               return (0);
+       }
+    
+       /*
+        * Convert the Host Name
+        */
+       pHost = (struct hostent *)pHook->pBuf;
+       idnPrintf("AsyncComplete Resulting <%s>\n",
+                 dumpName(pHost->h_name, hbuff, sizeof(hbuff)));
+       if (idnConvRsp(pHook->ctx, pHost->h_name,
+                      nbuff, sizeof(nbuff)) == TRUE) {
+               idnPrintf("AsyncComplete Converted <%s>\n",
+                         dumpName(nbuff, hbuff, sizeof(hbuff)));
+               strcpy(pHost->h_name, nbuff);
+       }
+
+       /*
+        * Delete target
+        */
+       hookListDelete(pHook);
+
+       return (0);
+}
+
+/*
+ * idnHook - hook async. completion message
+ */
+BOOL
+idnHook(HWND hWnd, u_int wMsg, char FAR *buf, idn_resconf_t ctx)
+{
+       if (hookHandle == NULL) {
+               hookHandle = SetWindowsHookEx(WH_GETMESSAGE, hookProc,
+                                             NULL, GetCurrentThreadId());
+       }
+       if (hookHandle == NULL) {
+               idnPrintf("idnHook: cannot set hook\n");
+               return (FALSE);
+       }
+       if (hookListAppend(hWnd, wMsg, buf, ctx) != TRUE) {
+               return (FALSE);
+       }
+       return (TRUE);
+}
diff --git a/contrib/idn/idnkit-1.0-src/wsock/common/make.wnt b/contrib/idn/idnkit-1.0-src/wsock/common/make.wnt
new file mode 100644 (file)
index 0000000..4dde4dd
--- /dev/null
@@ -0,0 +1,102 @@
+#
+# Makefile for WinSock Wrapper (common part)
+#
+
+# 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 <win32.mak>
+
+SYSLIBS = $(libcdll) kernel32.lib advapi32.lib user32.lib
+
+#
+# Files to use
+#
+
+HDRS = wrapcommon.h
+SRCS = printf.c   dump.c   checkdll.c   encoding.c   convert.c   hook.c
+OBJS = printf.obj dump.obj checkdll.obj encoding.obj convert.obj hook.obj
+LIBS = ..\..\lib\idnkit.lib ..\..\win\iconv.lib
+
+cflags = $(cflags) -I..\..\include
+
+#
+# Targets to Build
+#
+
+TARGETS = wrapcommon.lib
+
+all : $(TARGETS)
+
+wrapcommon.lib : $(OBJS)
+       -del wrapcommon.lib
+       lib /out:wrapcommon.lib $(OBJS)
+
+install :
+
+clean : force
+       -del *.obj
+       -del *.lib
+       -del *.exp
+
+#
+# Dependencies
+#
+
+printf.obj  : printf.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -DDEBUG $*.c
+
+dump.obj    : dump.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -DDEBUG $*.c
+
+checkdll.obj : checkdll.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -DDEBUG $*.c
+
+encoding.obj : encoding.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -DDEBUG $*.c
+
+convert.obj  : convert.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -DDEBUG $*.c
+
+hook.obj     : hook.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -DDEBUG $*.c
+
+force :
+
diff --git a/contrib/idn/idnkit-1.0-src/wsock/common/printf.c b/contrib/idn/idnkit-1.0-src/wsock/common/printf.c
new file mode 100644 (file)
index 0000000..7d6d2e4
--- /dev/null
@@ -0,0 +1,138 @@
+/*
+ * printf.c - printf like debug print function
+ */
+
+/*
+ * 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 <windows.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <process.h>
+
+#include "wrapcommon.h"
+
+/*
+ * Debug Tracer for DLL
+ */
+
+static char    logfile_name[256];
+static int     log_level = -1;
+static char    log_header[30];
+
+void
+idnPrintf(char *fmt, ...) {
+       va_list arg_ptr;
+       FILE *fp;
+       char msg[512];
+
+       if (log_level < 0 || logfile_name[0] == '\0')
+               return;
+
+       va_start(arg_ptr, fmt);
+       vsprintf(msg, fmt, arg_ptr);
+       va_end(arg_ptr);
+    
+       if ((fp = fopen(logfile_name, "a")) != NULL) {
+               fputs(log_header, fp);
+               fputs(msg, fp);
+               fclose(fp);
+       }
+}
+
+void
+idnLogPrintf(int level, char *fmt, ...) {
+       va_list arg_ptr;
+       FILE *fp;
+       char msg[512];
+
+       if (level > log_level || logfile_name[0] == '\0')
+               return;
+
+       va_start(arg_ptr, fmt);
+       vsprintf(msg, fmt, arg_ptr);
+       va_end(arg_ptr);
+    
+       if ((fp = fopen(logfile_name, "a")) != NULL) {
+               fputs(log_header, fp);
+               fputs(msg, fp);
+               fclose(fp);
+       }
+}
+
+static void
+log_proc(int level, const char *msg) {
+       FILE *fp;
+
+       if (log_level < 0 || logfile_name[0] == '\0')
+               return;
+
+       if ((fp = fopen(logfile_name, "a")) != NULL) {
+               fputs(msg, fp);
+               fclose(fp);
+       }
+}
+
+void
+idnLogInit(const char *title) {
+       log_level = idnGetLogLevel();
+       /* If log file is not stored in the registry, don't do logging. */
+       if (idnGetLogFile(logfile_name, sizeof(logfile_name)) == FALSE) {
+               log_level = -1;
+       }
+       sprintf(log_header, "%08x %-.16s: ", getpid(), title);
+       idn_log_setproc(log_proc);
+       idn_log_setlevel(log_level < 0 ? 0 : log_level);
+}
+
+void
+idnLogReset(void) {
+       idn_log_setproc(log_proc);
+}
+
+void
+idnLogFinish(void) {
+       idn_log_setproc(NULL);
+       /* idn_log_setlevel(0); */
+}
diff --git a/contrib/idn/idnkit-1.0-src/wsock/common/wrapcommon.h b/contrib/idn/idnkit-1.0-src/wsock/common/wrapcommon.h
new file mode 100644 (file)
index 0000000..c186a33
--- /dev/null
@@ -0,0 +1,109 @@
+/*
+ * wrapcommon.h
+ */
+
+/*
+ * 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.
+ */
+
+#ifndef _WRAPCOMMON_H
+#define _WRAPCOMMON_H
+
+#include <idn/res.h>
+#include <idn/log.h>
+#include <idn/version.h>
+
+#define WRAPPER_EXPORT extern __declspec(dllexport)
+
+extern void idnPrintf(char *fmt, ...);
+extern void idnLogPrintf(int level, char *fmt, ...);
+extern void idnLogInit(const char *title);
+extern void idnLogReset(void);
+extern void idnLogFinish(void);
+
+extern char *dumpAddr(const char FAR *addr, int len, char *buff, size_t size);
+extern char *dumpHost(const struct hostent FAR *hp, char *buff, size_t size);
+extern char *dumpName(const char *name, char *buff, size_t size);
+
+extern int idnEncodeWhere(void);
+
+#define IDN_ENCODE_ALWAYS   0
+#define IDN_ENCODE_CHECK    1
+#define IDN_ENCODE_ONLY11   2
+#define IDN_ENCODE_ONLY20   3
+
+extern BOOL idnGetPrgEncoding(char *enc, size_t len);
+extern BOOL idnGetLogFile(char *file, size_t len);
+
+extern int  idnGetLogLevel(void);  /* 0 : fatal        */
+                                    /* 1 : error        */
+                                   /* 2 : warning      */
+                                   /* 3 : info         */
+                                   /* 4 : trace        */
+                                   /* 5 : dump         */
+extern int  idnGetInstallDir(char *dir, size_t len);
+
+extern idn_resconf_t idnConvInit(void);
+extern void idnConvDone(idn_resconf_t ctx);
+
+extern BOOL idnWinsockVersion(const char *version);
+extern HINSTANCE idnWinsockHandle(void);
+extern idn_resconf_t idnGetContext(void);
+
+/*
+ * Converting Request/Response
+ */
+
+extern BOOL idnConvReq(idn_resconf_t ctx, const char FAR *from,
+                      char FAR *to, size_t tolen);
+extern BOOL idnConvRsp(idn_resconf_t ctx, const char FAR *from,
+                      char FAR *to, size_t tolen);
+
+/*
+ * Hook for Asynchronouse Query
+ */
+
+extern void idnHookInit(void);
+extern void idnHookDone(void);
+extern BOOL idnHook(HWND hWnd, u_int wMsg, char FAR *buf, idn_resconf_t ctx);
+
+#endif  /* _WRAPCOMMON_H */
diff --git a/contrib/idn/idnkit-1.0-src/wsock/config/idnconf.tcl b/contrib/idn/idnkit-1.0-src/wsock/config/idnconf.tcl
new file mode 100644 (file)
index 0000000..a140ed2
--- /dev/null
@@ -0,0 +1,1123 @@
+# $Id: idnconf.tcl,v 1.1 2003/06/04 00:27:42 marka Exp $
+#
+# idnconf.tcl - configure idn wrapper
+#
+
+#############################################################################
+#  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.
+#############################################################################
+
+global  configFile configBack
+global  registryKey registryEnc registryDef
+global  filesCpy filesRen filesDel
+
+# idnkit version
+set version    "1.0"
+
+set configFile  "idnconf.lst"   ;# list of wrapped program
+set configBack  "idnconf.bak"   ;# backup of previous data
+
+set serverKey          "HKEY_LOCAL_MACHINE\\Software\\JPNIC\\IDN"
+set serverLogLevel     LogLevel
+set serverLogLevelDef  -1
+set serverLogLevelNone -1
+set serverLogFile      LogFile
+set serverLogFileDef   {C:\idn_wrapper.log}
+set serverConfFile     ConfFile
+
+set perprogKey         "HKEY_LOCAL_MACHINE\\Software\\JPNIC\\IDN\\PerProg\\"
+set perprogEnc         Encoding
+set perprogDef         Default
+
+set logFileNameDef     idn_wrapper.log
+set confFileNameDef    idn.conf
+
+set filesCpy11 { "wsock32.dll" }
+set filesCpy20 { "wsock32.dll" "ws2_32.dll" }
+set filesDel11 { "wsock32.dll" }
+set filesDel20 { "wsock32.dll" "ws2_32.dll" }
+
+set local_dll          0
+
+########################################################################
+#
+# OS version check
+#
+
+proc get_os_version {} {
+    global os_version tcl_platform
+
+    if {[llength [info globals os_version]] > 0} {
+       return $os_version
+    }
+
+    switch -- $tcl_platform(os) {
+       "Windows 95" {
+           switch -- $tcl_platform(osVersion) {
+               4.0 {
+                   set os_version {Windows 95}
+               }
+               4.10 {
+                   set os_version {Windows 98}
+               }
+               4.90 {
+                   set os_version {Windows Me}
+               }
+           }
+       }
+       "Windows NT" {
+           switch -- $tcl_platform(osVersion) {
+               3.51 -
+               4.0 {
+                   set os_version {Windows NT}
+               }
+               5.0 {
+                   set os_version {Windows 2000}
+               }
+               default {
+                   # XP or .NET
+                   set os_version {Windows XP}
+               }
+           }
+       }
+       "Win32s" {
+           error "idn wrapper does not support Windows 3.1"
+       }
+       default {
+           set os_version "Unknown"
+       }
+    }
+    set os_version
+}
+
+proc support_dll_redirection {} {
+    global dll_redirection
+
+    if {[llength [info globals dll_redirection]] > 0} {
+       return $dll_redirection
+    }
+
+    switch -- [get_os_version] {
+       {Windows 95} -
+       {Windows NT} {
+           # cannot force local DLL reference by .local file.
+           set dll_redirection 0
+       }
+       default {
+           set dll_redirection 1
+       }
+    }
+    set dll_redirection
+}
+
+########################################################################
+#
+# handling pathname
+#
+
+proc getExeName { prg } {
+    set elem [file split $prg]
+    set leng [expr {[llength $elem] - 1}]
+    set name [lindex $elem $leng]
+    set exe  [file rootname $name]
+    return $exe
+}
+
+proc getDirName { prg } {
+    file dirname $prg
+}
+
+proc getSystemDir {} {
+    global env
+    switch -- [get_os_version] {
+        "Windows 95" -
+        "Windows 98" -
+       "Windows Me" {
+            set sysDir $env(windir)/system
+        }
+       default {
+            set sysDir $env(SystemRoot)/system32
+        }
+    }
+    return $sysDir
+}
+
+########################################################################
+#
+# loadList / saveList
+#
+#   loadList - load list of wrapped executables from $configFile
+#   saveList - save list of wrapped executables into $configFile
+#
+
+proc loadList {} {
+
+    global configFile configBack
+
+    if { [file exists $configFile] } {
+        file copy -force $configFile $configBack
+    }
+
+    set aList {}
+    set fd [open $configFile {CREAT RDONLY}]
+    while { ! [eof $fd]} {
+        set line [gets $fd]
+       if { [string length $line] > 0} {
+            lappend aList "$line"
+        }
+    }
+    close $fd
+    return $aList
+}
+
+proc saveList { aList } {
+    global configFile
+    file delete -force $configFile
+    set fd [open $configFile {CREAT WRONLY}]
+    foreach e $aList {
+        puts $fd $e
+    }
+    close $fd
+}
+
+########################################################################
+#
+# putList / getList - set/get list to/from listbox
+#
+
+proc putList { lb aList } {
+    foreach e $aList {
+        $lb insert end $e
+    }
+}
+
+proc getList { lb } {
+    $lb get 0 end
+}
+
+########################################################################
+#
+# checkList / appendList / deleteList - check / append / delete program from/to listbox
+#
+
+proc checkList { lb prg } {
+    set cnt 0
+    set lst [getList $lb]
+    
+    foreach n $lst {
+        if { [string compare $prg $n] == 0 } {
+           incr cnt
+        }
+    }
+    return $cnt
+}
+
+proc appendList { lb prg } {
+
+    if {  [checkList $lb $prg] == 0 } {
+        $lb insert end $prg
+    }
+}
+
+proc deleteList { lb prg } {
+    set cnt 0
+    set lst [getList $lb]
+
+    foreach n $lst {
+        if { [string compare $n $prg] == 0 } {
+           $lb delete $cnt
+        }
+       incr cnt
+    }
+}
+
+########################################################################
+#
+# registry operations
+#
+
+proc regGetEncode { prg } {
+
+    global  perprogKey perprogEnc perprogDef
+
+    if { [string compare $prg "" ] == 0 } {
+        return $perprogDef
+    }
+
+    if {![isWindows]} {
+        return $perprogDef
+    }
+    package require registry 1.0
+    
+    set name [getExeName $prg]
+    set key $perprogKey$name
+
+    if { [catch {set enc [registry get $key $perprogEnc]} err] } {
+        return $perprogDef
+    }
+    if { [string compare $enc ""] == 0 } {
+        return $perprogDef
+    }
+    return $enc
+}
+
+proc regSetEncode { prg enc } {
+
+    global  perprogKey perprogEnc perprogDef
+
+    if {![isWindows]} {
+        return 1
+    }
+
+    package require registry 1.0
+
+    set name [getExeName $prg]
+    set key $perprogKey$name
+
+    if { [string compare $enc $perprogDef] == 0 } {
+        set enc ""
+    }
+    if { [catch {registry set $key $perprogEnc $enc sz} ] } {
+        return 2
+    }
+    return 0
+}
+
+proc regGetLogLevel {} {
+    global serverKey serverLogLevel serverLogLevelDef
+    regGetValue $serverKey $serverLogLevel $serverLogLevelDef
+}
+
+proc regSetLogLevel {level} {
+    global serverKey serverLogLevel
+    regSetValue $serverKey $serverLogLevel $level dword
+}
+
+proc regGetLogFile {} {
+    global serverKey serverLogFile serverLogFileDef
+    set file [regGetValue $serverKey $serverLogFile $serverLogFileDef]
+    if {[catch {file attributes $file -longname} lfile]} {
+       # Maybe $file doesn't exist (yet).  Get the longname of
+       # directory portion.
+       set dir [file dirname $file]
+       if {[catch {file attributes $dir -longname} ldir]} {
+           set ldir $dir
+       }
+       set lfile [file join $ldir [file tail $file]]
+    }
+    file nativename $lfile
+}
+
+proc regSetLogFile {file} {
+    global serverKey serverLogFile
+    regSetValue $serverKey $serverLogFile [file nativename $file]
+}
+
+proc regGetConfFile {} {
+    global serverKey serverConfFile
+    set file [regGetValue $serverKey $serverConfFile {}]
+    if {[string compare $file {}] == 0} {
+       return {}
+    }
+    if {[catch {file attributes $file -longname} lfile]} {
+       # Maybe $file doesn't exist (yet).  Get the longname of
+       # directory portion.
+       set dir [file dirname $file]
+       if {[catch {file attributes $dir -longname} ldir]} {
+           set ldir $dir
+       }
+       set lfile [file join $ldir [file tail $file]]
+    }
+    file nativename $lfile
+}
+
+proc regSetConfFile {file} {
+    global serverKey serverConfFile
+    regSetValue $serverKey $serverConfFile [file nativename $file]
+}
+
+proc regGetWhere {} {
+    global serverKey
+    regGetValue $serverKey Where 0
+}
+
+proc regSetWhere {where} {
+    global serverKey
+    regSetValue $serverKey Where $where dword
+}
+
+proc regGetValue {key name default} {
+    if {![isWindows]} {
+       puts "--regGetValue $key $name"
+        return $default
+    }
+    package require registry 1.0
+    
+    if {[catch {registry get $key $name} value]} {
+        return $default
+    }
+    if {[string compare $value {}] == 0} {
+        return $default
+    }
+    return $value
+}
+
+proc regSetValue {key name value {type sz}} {
+    if {![isWindows]} {
+       puts "--regSetValue $key $name $value"
+        return 1
+    }
+
+    package require registry 1.0
+
+    if {[catch {registry set $key $name $value $type}]} {
+        return 2 
+    }
+    return 0
+}
+
+########################################################################
+#
+# install / uninstall DLL s
+#
+
+proc fileInstall { prg } {
+
+    global env
+    global filesCpy11 filesCpy20
+    
+    if {![isWindows]} {
+        return 1
+    }
+
+    switch -- [get_os_version] {
+        "Windows 95" -
+        "Windows 98" -
+       "Windows Me" {
+            set winDir $env(windir)
+           set sysDir $winDir/system
+           set filesCpy $filesCpy11
+       }
+       default {
+            set winDir $env(SystemRoot)
+            set sysDir $winDir/system32
+           set filesCpy $filesCpy20
+        }
+    }
+
+    set toDir [getDirName $prg ]
+
+    foreach n $filesCpy {
+        file copy -force $n $toDir
+    }
+    return 0
+}
+
+proc fileRemove { prg } {
+    
+    global filesDel11 filesDel20
+    
+    if {![isWindows]} {
+        return 1
+    }
+
+    switch -- [get_os_version] {
+        "Windows 95" {
+           set filesDel $filesDel11
+       }
+        "Windows 98" -
+       "Windows Me" {
+           set filesDel $filesDel20
+        }
+       default {
+           set filesDel $filesDel20
+        }
+    }
+
+    set fromDir [getDirName $prg ]
+
+    foreach n $filesDel {
+        file delete -force $fromDir/$n
+    }
+    return 0
+}
+
+########################################################################
+#
+# Wrap/Unwrap program
+#
+
+proc execWrap { pw lb dlg prg enc } {
+
+    set prgName [$prg get]
+    set encName [$enc get]
+
+    # Make sure the program name is not empty
+    if {[string compare $prgName {}] == 0} {
+       confErrorDialog $dlg "Program must be specified.\nClick \"Browse..\" button for browsing."
+       return
+    }
+
+    # It is dangerous to wrap programs in the system directory.
+    set prgdir [file nativename [getDirName $prgName]]
+    set sysdir [file nativename [getSystemDir]]
+    if {[string compare -nocase $prgdir $sysdir] == 0} {
+       tk_messageBox -icon error -type ok -title "Directory Error" \
+               -parent $dlg \
+               -message "Cannot wrap applications in the system directory.\nPlease copy the EXE file to elsewhere and wrap the copied one."
+       destroy $dlg
+       return 1
+    }
+
+    # Okay, copy the wrapper DLLs.
+    if { [fileInstall $prgName] } {
+        tk_messageBox -icon warning -type ok \
+                     -title "Warning" \
+                     -message "Cannot install DLLs" \
+                     -parent $dlg
+        destroy $dlg
+       return 1
+    }
+    if { [regSetEncode $prgName $encName] } {
+        tk_messageBox -icon warning -type ok \
+                     -title "Warning" \
+                     -message "Cannot set encoding" \
+                     -parent $dlg
+        fileRemove $prgName
+        destroy $dlg
+       return 2
+    }
+
+    # if local flag is on, create $prgName.local.
+    global local_dll
+    if {$local_dll} {
+       create_dot_local $prgName $dlg
+    } else {
+       remove_dot_local $prgName $dlg
+    }
+
+    if { [checkList $lb $prgName] == 0 } {
+        appendList $lb $prgName
+    }
+    saveList [getList $lb]
+    destroy $dlg
+}
+
+proc execUnwrap { pw lb dlg prg } {
+
+    set prgName [$prg get]
+    
+    if {[support_dll_redirection] && [file exists $prgName.local]} {
+       set ans [tk_messageBox -icon question -type yesno \
+                       -title "Confirmation" \
+                       -message "Also remove $prgName.local file?" \
+                       -parent $dlg]
+       if {[string compare $ans yes] == 0} {
+           remove_dot_local $prgName $dlg
+       }
+    }
+
+    if { [checkList $lb $prgName] == 1 } {
+        fileRemove $prgName
+    }
+    deleteList $lb $prgName
+    saveList [getList $lb]
+    destroy $dlg
+}
+proc create_dot_local {path {parent .}} {
+    set dotlocal $path.local
+    if {[file exists $dotlocal]} {
+       return 0
+    }
+    if {[catch {open $dotlocal w} fh]} {
+       tk_messageBox -icon warning -type ok -title "Warning" \
+               -message "Cannot create $dotlocal" -parent $parent
+       return -1
+    }
+    close $fh
+    return 0
+}
+
+proc remove_dot_local {path {parent .}} {
+    set dotlocal $path.local
+    if {[file exists $dotlocal] && [catch {file delete $dotlocal}]} {
+       tk_messageBox -icon warning -type ok -title "Warning" \
+               -message "Cannot remove $dotlocal" -parent $parent
+       return -1
+    }
+    return 0
+}
+
+########################################################################
+#
+# dialog for Wrap / Unwrap
+#
+
+proc syncEncode { v i op } {
+    global prgName encName
+    set enc [regGetEncode $prgName]
+    if { [string compare $encName $enc] != 0 } {
+        set encName $enc
+    }
+}
+
+proc confBrowse { p ePrg eEnc } {
+
+    set types { 
+        { "Executable" .exe }
+    }
+
+    set file [tk_getOpenFile -filetypes $types -parent $p ]
+
+    if { [string compare $file ""] == 0 } {
+        return
+    }
+    set enc [regGetEncode $file]
+    $ePrg delete 0 end
+    $ePrg insert 0 $file
+}
+
+proc confWrap { pw lb } {
+
+    global prgName encName local_dll
+
+    set idx [$lb curselection]
+    if { [llength $idx] == 1 } {
+        set prg [$lb get $idx]
+       set local_dll [file exists $prg.local]
+    } else {
+        set prg ""
+    }
+
+    set top .wrap
+    toplevel $top
+    grab     $top
+    wm title $top "idn wrapper - Wrap Executable"
+
+    frame $top.f1 -bd 1 -relief raised
+    frame $top.f2 -bd 1 -relief raised
+    pack $top.f1 -side top -fill x -expand on
+    pack $top.f2 -side top -fill x -expand on
+
+    frame $top.f1.f 
+    pack $top.f1.f -fill both -expand on -padx 4 -pady 4
+
+    set w $top.f1.f
+    label $w.prgtitle -text "Program:"
+    label $w.enctitle -text "Encoding:"
+
+    entry $w.prgname -relief sunken -width 56 -textvariable prgName
+    entry $w.encname -relief sunken -width  8 -textvariable encName
+    set w_prgname $w.prgname
+    set w_encname $w.encname
+    button $w.browse -text "Browse.." \
+                -command [list confBrowse $w $w_prgname $w_encname]
+
+    frame $w.rbf
+    radiobutton $w.rbf.encdef -text "Default" -variable encName \
+           -value "Default"
+    radiobutton $w.rbf.encutf -text "UTF-8"   -variable encName \
+           -value "UTF-8"
+    pack $w.rbf.encdef $w.rbf.encutf -side left -padx 4
+
+    grid $w.prgtitle -row 0 -column 0 -sticky e
+    grid $w.enctitle -row 1 -column 0 -sticky e
+    grid $w.prgname  -row 0 -column 1 -sticky we -pady 4 -padx 2 -columnspan 2
+    grid $w.browse   -row 0 -column 3 -sticky w  -pady 4 -padx 4 
+    grid $w.encname  -row 1 -column 1 -sticky we -pady 4 -padx 2
+    grid $w.rbf      -row 1 -column 2 -sticky w -padx 2
+    if {[support_dll_redirection]} {
+       checkbutton $w.local -text "Force local DLL reference" \
+               -variable local_dll
+       grid $w.local    -row 2 -column 1 -sticky w -padx 4 -pady 4
+    }
+    grid columnconfig $w 1 -weight 1 -minsize 20
+    grid columnconfig $w 2 -weight 2 -minsize 20
+
+    trace variable prgName w syncEncode
+
+    $w.prgname delete 0 end
+    $w.prgname insert 0 $prg
+
+    focus $w.prgname
+
+    set w $top.f2
+    button $w.wrap   -text "Wrap" \
+           -command [list execWrap $pw $lb $top $w_prgname $w_encname]
+    button $w.cancel -text "Cancel" \
+                -command [list destroy $top]
+    pack $w.cancel -side right -fill y -padx 12 -pady 4
+    pack $w.wrap -side right -fill y -padx 12 -pady 4
+
+    tkwait window $top
+}
+
+proc confUnwrap { pw lb } {
+
+    set idx [$lb curselection]
+    if { [llength $idx] != 1 } {
+        tk_messageBox -icon warning -type ok \
+                     -title "Warning" \
+                     -message "first, select unwrapping executable" \
+                     -parent $pw
+       return 0
+    }
+    set prg [$lb get $idx]
+    if { [string length $prg] == 0 } {
+        tk_messageBox -icon warning -type ok \
+                     -title "Warning" \
+                     -message "first, select unwrapping executable" \
+                     -parent $pw
+       return 0
+    }
+    
+    set top .unwrap
+    toplevel $top
+    grab     $top
+    wm title $top "idn wrapper - Unwrap Executable"
+
+    frame $top.f1 -bd 1 -relief raised
+    frame $top.f2 -bd 1 -relief raised
+    pack $top.f2 -side bottom -fill x
+    pack $top.f1 -side bottom -fill x -expand on
+
+    frame $top.f1.f
+    pack $top.f1.f -padx 4 -pady 4 -fill both -expand on
+    set w $top.f1.f
+    label $w.prgtitle -text "Program:"
+    entry $w.prgname -relief sunken -width 56 -textvariable prgName
+    $w.prgname delete 0 end
+    $w.prgname insert 0 $prg
+
+    set w_prgname $w.prgname
+
+    grid $w.prgtitle -row 0 -column 0 -sticky w
+    grid $w.prgname  -row 0 -column 1 -sticky we -pady 4
+    grid columnconfig $w 1 -weight 1 -minsize 20
+
+    set w $top.f2
+    button $w.wrap   -text "Unwrap" \
+                -command [list execUnwrap $pw $lb $top $w_prgname]
+    button $w.cancel -text "Cancel" \
+                -command [list destroy $top]
+
+    pack $w.cancel -side right -padx 12 -pady 6
+    pack $w.wrap -side right -padx 12 -pady 6
+
+    focus $w.wrap
+    tkwait window $top
+}
+
+proc unwrapAll {pw lb} {
+    set ans [tk_messageBox -type yesno -default no -icon question \
+           -parent $pw -title {idn wrapper Configuration} \
+           -message {Really unwrap all programs?}]
+    if {[string compare $ans yes] != 0} {
+       return
+    }
+
+    foreach prog [$lb get 0 end] {
+       fileRemove $prog
+    }
+
+    if {[support_dll_redirection]} {
+       set delete_type yes
+       foreach prog [$lb get 0 end] {
+           if {![file exists $prog.local]} continue
+           switch -- $delete_type {
+               yes -
+               no {
+                   set delete_type [dotLocalDialog $prog $delete_type]
+               }
+           }
+           switch -- $delete_type {
+               yes -
+               yesall {
+                   remove_dot_local $prog $pw
+               }
+           }
+       }
+    }
+
+    $lb delete 0 end
+    saveList {}
+}
+
+proc rewrapAll {pw lb} {
+    set ans [tk_messageBox -type yesno -default yes -icon question \
+           -parent $pw -title {idn wrapper Configuration} \
+           -message {Really rewrap all programs?}]
+    if {[string compare $ans yes] != 0} {
+       return
+    }
+    foreach prog [$lb get 0 end] {
+       fileInstall $prog
+    }
+}
+
+proc confLog {pw} {
+    global _logLevel _logFile
+
+    set top .log
+    catch {destroy $top}
+    toplevel $top
+    wm title $top "idn wrapper - Log Configuration"
+    # wm transient $top $pw
+
+    set _logLevel [regGetLogLevel]
+    set _logFile [regGetLogFile]
+
+    frame $top.f1 -bd 1 -relief raised
+    frame $top.f2 -bd 1 -relief raised
+    pack $top.f2 -side bottom -fill x
+    pack $top.f1 -side top -fill both -expand on
+
+    set w $top.f1
+    label $w.lv_l -text "Log Level:"
+    frame $w.lv_v
+    global serverLogLevelNone
+    set i 0
+    foreach {lvl text} [list $serverLogLevelNone None \
+           0 Fatal 1 Error 2 Warning 3 Info 4 Trace] {
+       radiobutton $w.lv_v.btn$i -text $text -value $lvl -variable _logLevel
+       pack $w.lv_v.btn$i -side left -padx 3
+       incr i
+    }
+    label $w.ld_l -text "Log File:"
+    frame $w.ld_v
+    entry $w.ld_v.e -width 40 -textvariable _logFile
+    focus $w.ld_v.e
+    button $w.ld_v.b -text "Browse.." -command [list selectLog $top $w.ld_v.e]
+    pack $w.ld_v.b -side right -fill y -padx 6
+    pack $w.ld_v.e -side left -fill both -expand yes
+    #label $w.lo_l -text "Log Operation:"
+    frame $w.lo_v
+    button $w.lo_v.show -text "View" -command [list showLog $top]
+    button $w.lo_v.delete -text "Delete" -command [list deleteLog $top]
+    pack $w.lo_v.show $w.lo_v.delete -side left -padx 4
+
+    grid $w.lv_l -row 0 -column 0 -sticky e -padx 4
+    grid $w.ld_l -row 1 -column 0 -sticky e -padx 4
+    #grid $w.lo_l -row 2 -column 0 -sticky e -padx 4
+    grid $w.lv_v -row 0 -column 1 -sticky w -padx 4 -pady 4
+    grid $w.ld_v -row 1 -column 1 -sticky we -padx 4 -pady 4
+    grid $w.lo_v -row 2 -column 1 -sticky w -padx 4 -pady 4
+
+    set w $top.f2
+    button $w.ok -text "OK" -command [list configureLog $top]
+    button $w.cancel -text "Cancel" -command [list destroy $top]
+    pack $w.cancel -side right -padx 12 -pady 6
+    pack $w.ok -side right -padx 12 -pady 6
+}
+
+proc configureLog {top} {
+    global _logLevel _logFile
+
+    if {$_logLevel != [regGetLogLevel] ||
+        [string compare $_logFile [regGetLogFile]] != 0} {
+       set dir [file dirname $_logFile]
+       if {[string compare $dir {}]} {
+           if {![file exists $dir]} {
+               confErrorDialog $top "Directory $dir doesn't exist"
+               return
+           } elseif {![file isdirectory $dir]} {
+               confErrorDialog $top "$dir is not a directory"
+               return
+           }
+       }
+       regSetLogLevel $_logLevel
+       regSetLogFile $_logFile
+       tk_messageBox -type ok -default ok -icon info -parent $top \
+               -title "idn wrapper Configuration" \
+               -message "Changing log level or file does not affect already running processes."
+    }
+    destroy $top
+}
+
+proc selectLog {top e} {
+    global logFileNameDef
+    set file [tk_getSaveFile -title {idn wrapper Logfile Selection} \
+           -defaultextension .log \
+           -filetypes {{{Log Files} .log} {{All Files} *}} \
+           -initialfile $logFileNameDef \
+           -parent $top]
+    if {[string compare $file {}]} {
+       $e delete 0 end
+       $e insert insert $file
+    }
+}
+    
+proc showLog {top} {
+    global _logFile
+    if {[catch {exec notepad.exe $_logFile &} r]} {
+       confErrorDialog $top "Cannot execute notepad"
+    }
+}
+
+proc deleteLog {top} {
+    global _logFile
+    set ans [tk_messageBox -type yesno -default no -icon question \
+           -parent $top -title "idn wrapper Configuration" \
+           -message "Really delete $_logFile?"]
+    if {[string compare $ans yes] == 0} {
+       file delete $_logFile
+    }
+}
+
+########################################################################
+#
+# dialog for .local deletion
+#
+
+proc dotLocalDialog {path {default yes}} {
+    set parent .
+    set dlg .dotlocaldlg
+    catch {destroy $dlg}
+    toplevel $dlg
+
+    wm iconname $dlg Dialog
+    wm title $dlg Confirmation
+    wm transient $dlg $parent
+    wm protocol $dlg WM_DELETE_WINDOW {}
+
+    frame $dlg.f1 -bd 1 -relief raised
+    frame $dlg.f2 -bd 1 -relief raised
+    pack $dlg.f1 -side top -fill x -expand on -ipadx 2m -ipady 4m
+    pack $dlg.f2 -side top -fill x -ipadx 2m
+
+    label $dlg.f1.bm -bitmap question -bd 0
+    label $dlg.f1.msg -text "Remove $path.local?" -wraplength 10c
+    pack $dlg.f1.bm -side left -padx 3m -pady 2m
+    pack $dlg.f1.msg -side left -padx 2m -pady 2m
+
+    global dotlocal_selection
+    foreach {btn lbl} {yes Yes no No yesall {Yes to All} noall {No to All}} {
+       set bw $dlg.f2.btn$btn
+       button $bw -text $lbl -default normal \
+               -command [list set dotlocal_selection $btn]
+       if {[string compare $default $btn] == 0} {
+           $bw configure -default active
+           focus $bw
+       }
+       bind $bw <Return> {%W flash; %W invoke}
+       pack $bw -side left -padx 3m -pady 2m
+    }
+
+    grab $dlg
+    ::tk::PlaceWindow $dlg widget $parent
+
+    vwait dotlocal_selection
+    destroy $dlg
+    return $dotlocal_selection
+}
+
+########################################################################
+#
+# dialog for advanced configuration
+#
+
+proc advancedConf {pw} {
+    set top .adv
+    catch {destroy $top}
+    toplevel $top
+    wm title $top "idn wrapper - Advanced Configuration"
+
+    global _mdnOperation _confFile
+    set _mdnOperation [regGetWhere]
+    set _confFile [regGetConfFile]
+
+    foreach f {f1 f2 f3} {
+       frame $top.$f -bd 1 -relief raised
+       pack $top.$f -side top -fill x
+    }
+    
+    set f $top.f1
+    label $f.lbl -text {IDN Wrapping Mode}
+    set w $f.f
+    frame $w
+    foreach {rb val txt} [list \
+           rb1 0 {Wrap both WINSOCK 1.1 and WINSOCK 2.0} \
+           rb2 2 {Wrap only WINSOCK 1.1} \
+           rb3 3 {Wrap only WINSOCK 2.0} \
+           rb4 1 "Wrap only WINSOCK2.0 if it exists.\nOtherwise wrap only WINSOCK1.1"] {
+       radiobutton $w.$rb -text $txt -variable _mdnOperation -value $val \
+               -anchor w -justify left
+       pack $w.$rb -side top -fill x -pady 1
+    }
+    pack $f.lbl -side top -fill x -pady 4
+    pack $w -side top -fill both -padx 20 -pady 10
+
+    set f $top.f2
+    label $f.lbl -text {IDN Configuration}
+    pack $f.lbl -side top -fill x -pady 6
+
+    set w $f.f
+    frame $w
+    pack $w -side top -fill both -padx 10 -pady 6
+    label $w.l1 -text {Config File:}
+    #label $w.l2 -text {Config Operation:}
+    entry $w.e -width 40 -textvariable _confFile
+    focus $w.e
+    button $w.br -text "Browse.." -command [list selectConf $top $w.e]
+    button $w.b -text Edit -command [list editConf $top]
+    grid $w.l1 -row 0 -column 0 -sticky e -padx 4
+    #grid $w.l2 -row 1 -column 0 -sticky e -padx 4
+    grid $w.e -row 0 -column 1 -sticky we -padx 4 -pady 4
+    grid $w.b -row 1 -column 1 -sticky w -padx 4 -pady 4
+    grid $w.br -row 0 -column 2 -sticky w -padx 4 -pady 4
+
+    set w $top.f3
+    button $w.ok -text "OK" -command [list advConf $top]
+    button $w.cancel -text "Cancel" -command [list destroy $top]
+    pack $w.cancel -side right -padx 12 -pady 8
+    pack $w.ok -side right -padx 12 -pady 8
+}
+
+proc editConf {top} {
+    global _confFile
+    if {[catch {exec notepad.exe $_confFile &} r]} {
+       confErrorDialog $top "Cannot execute notepad"
+    }
+}
+
+proc selectConf {top e} {
+    global confFileNameDef
+    set file [tk_getOpenFile -title {idn wrapper Config File Selection} \
+           -defaultextension .conf \
+           -filetypes {{{Config Files} .conf} {{All Files} *}} \
+           -initialfile $confFileNameDef \
+           -parent $top]
+    if {[string compare $file {}]} {
+       $e delete 0 end
+       $e insert insert $file
+    }
+}
+
+proc advConf {top} {
+    global _mdnOperation _confFile
+    regSetWhere $_mdnOperation
+    regSetConfFile $_confFile
+    destroy $top
+}
+
+########################################################################
+#
+# utility
+#
+
+proc confErrorDialog {top message} {
+    tk_messageBox -default ok -icon error -parent $top -type ok \
+           -title {idn wrapper Configuration Error} -message $message
+}
+
+proc isWindows {} {
+    global tcl_platform
+    expr {[string compare $tcl_platform(platform) "windows"] == 0}
+}
+
+########################################################################
+#
+# config program start here
+#
+
+wm title    . "idn wrapper - Configuration"
+wm iconname . "idn wrapper - Configuration"
+
+
+label .title -bd 1 -relief raised -pady 5 \
+       -text "idn wrapper Configuration Program version $version"
+
+frame .left -bd 1 -relief raised
+frame .right -bd 1 -relief raised
+
+frame .lst
+label .lst.title -text "Wrapped Programs" -pady 3
+listbox .lst.list -width 64 -height 16 -setgrid 1 \
+            -xscrollcommand ".lst.xscroll set" \
+            -yscrollcommand ".lst.yscroll set"
+scrollbar .lst.yscroll -orient vertical   -command ".lst.list yview"
+scrollbar .lst.xscroll -orient horizontal -command ".lst.list xview"
+grid .lst.title   -row 0 -column 0 -columnspan 2 -sticky news
+grid .lst.list    -row 1 -column 0 -sticky news
+grid .lst.xscroll -row 2 -column 0 -sticky news
+grid .lst.yscroll -row 1 -column 1 -sticky news
+grid rowconfig .lst 1 -weight 1
+grid columnconfig .lst 0 -weight 1
+
+frame .btn
+button .btn.wrap -text "Wrap.." -command [list confWrap . .lst.list]
+button .btn.unwrap -text "Unwrap.." -command [list confUnwrap . .lst.list]
+button .btn.unwrapall -text "Unwrap All" -command [list unwrapAll . .lst.list]
+button .btn.rewrapall -text "Rewrap All" -command [list rewrapAll . .lst.list]
+frame .btn.spacing1 -width 1 -height 12 -bd 0
+button .btn.log -text "Log.." -command [list confLog .]
+frame .btn.spacing2 -width 1 -height 12 -bd 0
+button .btn.adv -text "Advanced.." -command [list advancedConf .]
+button .btn.exit -text Exit -command exit
+pack .btn.wrap   -side top    -fill x -pady 4
+pack .btn.unwrap -side top    -fill x -pady 4
+pack .btn.unwrapall -side top -fill x -pady 4
+pack .btn.rewrapall -side top -fill x -pady 4
+pack .btn.spacing1 -side top
+pack .btn.log    -side top    -fill x -pady 4
+pack .btn.spacing2 -side top
+pack .btn.adv    -side top    -fill x -pady 4
+pack .btn.exit   -side bottom -fill x -pady 4
+
+pack .lst -in .left -padx 4 -pady 4 -fill both -expand on
+pack .btn -in .right -padx 6 -pady 4 -fill both -expand on
+
+pack .title -side top -fill x
+pack .right -side right -fill y
+pack .left -side left -fill y -expand on
+
+#
+# then set current list into listbox
+#
+
+set theList [loadList]
+#saveList $theList
+putList .lst.list $theList
+
+#
+########################################################################
diff --git a/contrib/idn/idnkit-1.0-src/wsock/config/make.wnt b/contrib/idn/idnkit-1.0-src/wsock/config/make.wnt
new file mode 100644 (file)
index 0000000..1099fbe
--- /dev/null
@@ -0,0 +1,58 @@
+#
+# Makefile for building mDNS Wrapper Configuration Tool
+#
+
+# 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.
+
+TARGETS = idnconf.exe
+
+all : $(TARGETS)
+
+idnconf.exe : idnconf.tcl
+       freewrap idnconf.tcl
+
+install : $(TARGETS)
+       copy idnconf.exe ..\bin
+
+clean : force
+       -del idnconf.exe
+
+force :
diff --git a/contrib/idn/idnkit-1.0-src/wsock/make.wnt b/contrib/idn/idnkit-1.0-src/wsock/make.wnt
new file mode 100644 (file)
index 0000000..3c45432
--- /dev/null
@@ -0,0 +1,97 @@
+#
+# Top Level Makefile for building WINSOCK idn wrapper
+#
+
+# 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.
+
+all : force
+       cd common
+       $(MAKE) -f make.wnt all
+       cd ..
+       cd wsock11
+       $(MAKE) -f make.wnt all
+       cd ..
+       cd wsock20
+       $(MAKE) -f make.wnt all
+       cd ..
+       cd config
+       $(MAKE) -f make.wnt all
+       cd ..
+
+install : force
+       copy ..\win\iconv.dll bin   
+       copy ..\lib\idnkit.dll bin
+       copy ..\lib\idnkitlite.dll bin
+       copy ..\map\jp.map bin
+       cd common
+       $(MAKE) -f make.wnt install
+       cd ..
+       cd wsock11
+       $(MAKE) -f make.wnt install
+       cd ..
+       cd wsock20
+       $(MAKE) -f make.wnt install
+       cd ..
+       cd config
+       $(MAKE) -f make.wnt install
+       cd ..
+
+setup : force
+       cd bin
+       iscc idn_wrapper.iss
+       cd ..
+
+clean : force
+       cd common
+       $(MAKE) -f make.wnt clean
+       cd ..
+       cd wsock11
+       $(MAKE) -f make.wnt clean
+       cd ..
+       cd wsock20
+       $(MAKE) -f make.wnt clean
+       cd ..
+       cd config
+       $(MAKE) -f make.wnt clean
+       cd ..
+
+force :
+
diff --git a/contrib/idn/idnkit-1.0-src/wsock/wsock11/dlldef.h b/contrib/idn/idnkit-1.0-src/wsock/wsock11/dlldef.h
new file mode 100644 (file)
index 0000000..569a264
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * dlldef.h
+ */
+
+/*
+ * 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.
+ */
+
+#ifndef _DLLDEF_H
+#define _DLLDEF_H
+
+#include "../common/wrapcommon.h"
+
+/*
+ * Execution Tracing
+ */
+extern int procPid;
+
+#ifdef  DEBUG
+#define TRACE   idnPrintf
+#define FATAL   idnPrintf
+#else
+#define TRACE
+#define FATAL   idnPrintf
+#endif
+
+/*
+ * Stub functions for calling original version.
+ */
+extern int PASCAL
+_org_gethostname(char FAR * name, int namelen);
+
+extern struct hostent FAR * PASCAL
+_org_gethostbyname(const char FAR * name);
+
+extern struct hostent FAR * PASCAL
+_org_gethostbyaddr(const char FAR * addr, int len, int type);
+
+extern HANDLE PASCAL
+_org_WSAAsyncGetHostByName(HWND hWnd, u_int wMsg, const char FAR * name,
+                          char FAR * buf, int buflen);
+extern HANDLE PASCAL
+_org_WSAAsyncGetHostByAddr(HWND hWnd, u_int wMsg, const char FAR * addr,
+                          int len, int type, char FAR * buf, int buflen);
+
+
+#endif  /* _DLLDEF_H */
diff --git a/contrib/idn/idnkit-1.0-src/wsock/wsock11/dllfunc.c b/contrib/idn/idnkit-1.0-src/wsock/wsock11/dllfunc.c
new file mode 100644 (file)
index 0000000..4b709f6
--- /dev/null
@@ -0,0 +1,212 @@
+/*
+ * dllfunc.c - wrapper functions
+ */
+
+/*
+ * 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 <windows.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <process.h>
+
+#include "dlldef.h"
+
+WRAPPER_EXPORT int PASCAL FAR
+gethostname(char FAR * name, int namelen) {
+       int ret;
+    
+       TRACE("ENTER gethostname\n");
+       ret = _org_gethostname(name, namelen);
+       TRACE("LEAVE gethostname %d <%-.100s>\n", ret, name);
+
+       return (ret);
+}
+
+WRAPPER_EXPORT struct hostent FAR * PASCAL FAR
+gethostbyname(const char FAR * name) {
+       struct hostent FAR *ret;
+       char    nbuff[256];
+       char    hbuff[256];
+       BOOL    stat;
+       idn_resconf_t   encodeCtx;
+    
+       TRACE("ENTER gethostbyname <%-.100s>\n",
+             (name != NULL ? name : "NULL"));
+
+       encodeCtx = idnGetContext();
+
+       if (encodeCtx == NULL) {
+               TRACE("gethostbyname: not encode here\n");
+               ret = _org_gethostbyname(name);
+       } else if (name == NULL) {
+               TRACE("gethostbyname: name is NULL\n");
+               ret = _org_gethostbyname(name);
+       } else {
+               stat = idnConvReq(encodeCtx, name, nbuff, sizeof(nbuff));
+               if (stat == FALSE) {
+                       TRACE("idnConvReq failed\n");
+                       ret = NULL;
+               } else {
+                       TRACE("Converted Name <%s>\n",
+                             dumpName(nbuff, hbuff, sizeof(hbuff)));
+                       ret = _org_gethostbyname(nbuff);
+               }
+       }
+
+       if (ret != NULL && encodeCtx != NULL) {
+               TRACE("Resulting Name <%s>\n",
+                     dumpName(ret->h_name, hbuff, sizeof(hbuff)));
+               stat = idnConvRsp(encodeCtx, ret->h_name, nbuff,
+                                 sizeof(nbuff));
+               if (stat == FALSE) {
+                       TRACE("Decoding failed - return the name verbatim\n");
+               } else {
+                       TRACE("Converted Back <%s>\n",
+                             dumpName(nbuff, hbuff, sizeof(hbuff)));
+                       strcpy(ret->h_name, nbuff);
+               }
+       }
+
+       if (ret == NULL) {
+               TRACE("LEAVE gethostbyname NULL\n");
+       } else {
+               TRACE("LEAVE gethostbyname <%s>\n",
+                     dumpHost(ret, hbuff, sizeof(hbuff)));
+       }
+       return (ret);
+}
+
+WRAPPER_EXPORT struct hostent FAR * PASCAL FAR
+gethostbyaddr(const char FAR * addr, int len, int type) {
+       struct hostent FAR *ret;
+       char    nbuff[256];
+       char    abuff[256];
+       char    hbuff[256];
+       BOOL    stat;
+       idn_resconf_t   encodeCtx;
+    
+       TRACE("ENTER gethostbyaddr <%s>\n",
+             dumpAddr(addr, len, abuff, sizeof(abuff)));
+
+       encodeCtx = idnGetContext();
+
+       ret = _org_gethostbyaddr(addr, len, type);
+
+       if (ret != NULL && encodeCtx != NULL) {
+               TRACE("Resulting Name <%s>\n",
+                     dumpName(ret->h_name, hbuff, sizeof(hbuff)));
+               stat = idnConvRsp(encodeCtx, ret->h_name,
+                                 nbuff, sizeof(nbuff));
+               if (stat == FALSE) {
+                       TRACE("Decoding failed - return the name verbatim\n");
+               } else {
+                       TRACE("Converted Back <%s>\n",
+                             dumpName(nbuff, hbuff, sizeof(hbuff)));
+                       strcpy(ret->h_name, nbuff);
+               }
+       }
+
+       if (ret == NULL) {
+               TRACE("LEAVE gethostbyaddr NULL\n") ;
+       } else {
+               TRACE("LEAVE gethostbyaddr <%s>\n",
+                     dumpHost(ret, hbuff, sizeof(hbuff)));
+       }    
+       return (ret);
+}
+
+WRAPPER_EXPORT HANDLE PASCAL FAR
+WSAAsyncGetHostByName(HWND hWnd, u_int wMsg, 
+                     const char FAR * name, char FAR * buf, int buflen)
+{
+       HANDLE  ret;
+       char    nbuff[256];
+       char    hbuff[256];
+       idn_resconf_t   encodeCtx;
+    
+       TRACE("ENTER WSAAsyncGetHostByName <%-.100s>\n", name);
+
+       encodeCtx = idnGetContext();
+
+       if (encodeCtx == NULL || name == NULL) {
+               ret = _org_WSAAsyncGetHostByName(hWnd, wMsg, name,
+                                                buf, buflen);
+       } else {
+               idnHook(hWnd, wMsg, buf, encodeCtx);
+               idnConvReq(encodeCtx, name, nbuff, sizeof(nbuff));
+               TRACE("Converted Name <%s>\n",
+                     dumpName(nbuff, hbuff, sizeof(hbuff)));
+               ret = _org_WSAAsyncGetHostByName(hWnd, wMsg, nbuff,
+                                                buf, buflen);
+       }
+
+       TRACE("LEAVE WSAAsyncGetHostByName HANDLE %08x\n", ret);
+
+       return (ret);
+}
+
+WRAPPER_EXPORT HANDLE PASCAL FAR
+WSAAsyncGetHostByAddr(HWND hWnd, u_int wMsg, const char FAR * addr,
+                     int len, int type, char FAR * buf, int buflen)
+{
+       HANDLE  ret;
+       char    abuff[256];
+       idn_resconf_t   encodeCtx;
+    
+       encodeCtx = idnGetContext();
+
+       if (encodeCtx != NULL) {
+               idnHook(hWnd, wMsg, buf, encodeCtx);
+       }
+
+       TRACE("ENTER WSAAsyncGetHostByAddr <%s>\n",
+             dumpAddr(addr, len, abuff, sizeof(abuff)));
+       ret = _org_WSAAsyncGetHostByAddr(hWnd, wMsg, addr, len, type,
+                                        buf, buflen);
+       TRACE("LEAVE WSAAsyncGetHostByAddr HANDLE %08x\n", ret);
+
+       return (ret);
+}
+
+
diff --git a/contrib/idn/idnkit-1.0-src/wsock/wsock11/dllload.c b/contrib/idn/idnkit-1.0-src/wsock/wsock11/dllload.c
new file mode 100644 (file)
index 0000000..68c2a7e
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * dllload.c - load original entries
+ */
+
+/*
+ * 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 <windows.h>
+#include <winsock.h>
+#include <nspapi.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <process.h>
+
+#include "dlldef.h"
+
+/*
+ * Manages original DLL 
+ */
+#define DLLHANDLE      idnWinsockHandle()
+
+#include "dllstub.c"
diff --git a/contrib/idn/idnkit-1.0-src/wsock/wsock11/dllmain.c b/contrib/idn/idnkit-1.0-src/wsock/wsock11/dllmain.c
new file mode 100644 (file)
index 0000000..177f722
--- /dev/null
@@ -0,0 +1,96 @@
+/*
+ * dllmain.c - entry for DLL
+ */
+
+/*
+ * 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 <windows.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <process.h>
+
+#include "dlldef.h"
+
+/*
+ * Control Variables
+ */
+int procPid = 0;
+
+static char procExe[256];
+
+/*
+ * DLL Entry
+ */
+
+BOOL APIENTRY
+DllMain(HMODULE hmod, DWORD reason, LPVOID *resv) {
+       switch (reason) {
+
+       case DLL_PROCESS_ATTACH:
+               procPid = getpid();
+               GetModuleFileName(NULL, procExe, 256);
+
+               idnLogInit("ws11");
+               idnHookInit();
+
+               TRACE("Attached to Process <%s>\n", procExe);
+               return (idnWinsockVersion("1.1"));
+
+       case DLL_PROCESS_DETACH:
+               idnConvDone(idnGetContext());
+               idnHookDone();
+               TRACE("Detached from Process\n");
+               idnLogFinish();
+               break;
+
+       case DLL_THREAD_ATTACH:
+               break;
+       case DLL_THREAD_DETACH:
+               break;
+       }
+
+       return (TRUE);
+}
+
diff --git a/contrib/idn/idnkit-1.0-src/wsock/wsock11/dllstub.c b/contrib/idn/idnkit-1.0-src/wsock/wsock11/dllstub.c
new file mode 100644 (file)
index 0000000..af8a2b6
--- /dev/null
@@ -0,0 +1,1541 @@
+/* $Id: dllstub.c,v 1.1 2003/06/04 00:27:45 marka Exp $ */
+
+SOCKET   PASCAL
+accept(SOCKET a0, struct sockaddr* a1, int* a2)
+{
+    static SOCKET   (PASCAL *fp)(SOCKET a0, struct sockaddr* a1, int* a2);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub accept() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "accept")) == NULL) {
+           FATAL("cannot find entry accept (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2);
+}
+
+int   PASCAL
+bind(SOCKET a0, const struct sockaddr* a1, int a2)
+{
+    static int   (PASCAL *fp)(SOCKET a0, const struct sockaddr* a1, int a2);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub bind() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "bind")) == NULL) {
+           FATAL("cannot find entry bind (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2);
+}
+
+int   PASCAL
+closesocket(SOCKET a0)
+{
+    static int   (PASCAL *fp)(SOCKET a0);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub closesocket() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "closesocket")) == NULL) {
+           FATAL("cannot find entry closesocket (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0);
+}
+
+int   PASCAL
+connect(SOCKET a0, const struct sockaddr* a1, int a2)
+{
+    static int   (PASCAL *fp)(SOCKET a0, const struct sockaddr* a1, int a2);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub connect() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "connect")) == NULL) {
+           FATAL("cannot find entry connect (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2);
+}
+
+int   PASCAL
+getpeername(SOCKET a0, struct sockaddr* a1, int* a2)
+{
+    static int   (PASCAL *fp)(SOCKET a0, struct sockaddr* a1, int* a2);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub getpeername() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "getpeername")) == NULL) {
+           FATAL("cannot find entry getpeername (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2);
+}
+
+int   PASCAL
+getsockname(SOCKET a0, struct sockaddr* a1, int* a2)
+{
+    static int   (PASCAL *fp)(SOCKET a0, struct sockaddr* a1, int* a2);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub getsockname() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "getsockname")) == NULL) {
+           FATAL("cannot find entry getsockname (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2);
+}
+
+int   PASCAL
+getsockopt(SOCKET a0, int a1, int a2, char* a3, int* a4)
+{
+    static int   (PASCAL *fp)(SOCKET a0, int a1, int a2, char* a3, int* a4);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub getsockopt() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "getsockopt")) == NULL) {
+           FATAL("cannot find entry getsockopt (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3, a4);
+}
+
+u_long   PASCAL
+htonl(u_long a0)
+{
+    static u_long   (PASCAL *fp)(u_long a0);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub htonl() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "htonl")) == NULL) {
+           FATAL("cannot find entry htonl (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0);
+}
+
+u_short   PASCAL
+htons(u_short a0)
+{
+    static u_short   (PASCAL *fp)(u_short a0);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub htons() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "htons")) == NULL) {
+           FATAL("cannot find entry htons (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0);
+}
+
+unsigned long   PASCAL
+inet_addr(const char* a0)
+{
+    static unsigned long   (PASCAL *fp)(const char* a0);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub inet_addr() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "inet_addr")) == NULL) {
+           FATAL("cannot find entry inet_addr (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0);
+}
+
+ char * PASCAL
+inet_ntoa(struct in_addr a0)
+{
+    static  char * (PASCAL *fp)(struct in_addr a0);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub inet_ntoa() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "inet_ntoa")) == NULL) {
+           FATAL("cannot find entry inet_ntoa (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0);
+}
+
+int   PASCAL
+ioctlsocket(SOCKET a0, long a1, u_long * a2)
+{
+    static int   (PASCAL *fp)(SOCKET a0, long a1, u_long * a2);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub ioctlsocket() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "ioctlsocket")) == NULL) {
+           FATAL("cannot find entry ioctlsocket (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2);
+}
+
+int   PASCAL
+listen(SOCKET a0, int a1)
+{
+    static int   (PASCAL *fp)(SOCKET a0, int a1);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub listen() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "listen")) == NULL) {
+           FATAL("cannot find entry listen (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1);
+}
+
+u_long   PASCAL
+ntohl(u_long a0)
+{
+    static u_long   (PASCAL *fp)(u_long a0);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub ntohl() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "ntohl")) == NULL) {
+           FATAL("cannot find entry ntohl (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0);
+}
+
+u_short   PASCAL
+ntohs(u_short a0)
+{
+    static u_short   (PASCAL *fp)(u_short a0);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub ntohs() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "ntohs")) == NULL) {
+           FATAL("cannot find entry ntohs (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0);
+}
+
+int   PASCAL
+recv(SOCKET a0, char* a1, int a2, int a3)
+{
+    static int   (PASCAL *fp)(SOCKET a0, char* a1, int a2, int a3);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub recv() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "recv")) == NULL) {
+           FATAL("cannot find entry recv (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3);
+}
+
+int   PASCAL
+recvfrom(SOCKET a0, char* a1, int a2, int a3, struct sockaddr* a4, int* a5)
+{
+    static int   (PASCAL *fp)(SOCKET a0, char* a1, int a2, int a3, struct sockaddr* a4, int* a5);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub recvfrom() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "recvfrom")) == NULL) {
+           FATAL("cannot find entry recvfrom (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3, a4, a5);
+}
+
+int   PASCAL
+select(int a0, fd_set* a1, fd_set* a2, fd_set* a3, const struct timeval* a4)
+{
+    static int   (PASCAL *fp)(int a0, fd_set* a1, fd_set* a2, fd_set* a3, const struct timeval* a4);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub select() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "select")) == NULL) {
+           FATAL("cannot find entry select (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3, a4);
+}
+
+int   PASCAL
+send(SOCKET a0, const char* a1, int a2, int a3)
+{
+    static int   (PASCAL *fp)(SOCKET a0, const char* a1, int a2, int a3);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub send() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "send")) == NULL) {
+           FATAL("cannot find entry send (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3);
+}
+
+int   PASCAL
+sendto(SOCKET a0, const char* a1, int a2, int a3, const struct sockaddr* a4, int a5)
+{
+    static int   (PASCAL *fp)(SOCKET a0, const char* a1, int a2, int a3, const struct sockaddr* a4, int a5);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub sendto() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "sendto")) == NULL) {
+           FATAL("cannot find entry sendto (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3, a4, a5);
+}
+
+int   PASCAL
+setsockopt(SOCKET a0, int a1, int a2, const char* a3, int a4)
+{
+    static int   (PASCAL *fp)(SOCKET a0, int a1, int a2, const char* a3, int a4);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub setsockopt() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "setsockopt")) == NULL) {
+           FATAL("cannot find entry setsockopt (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3, a4);
+}
+
+int   PASCAL
+shutdown(SOCKET a0, int a1)
+{
+    static int   (PASCAL *fp)(SOCKET a0, int a1);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub shutdown() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "shutdown")) == NULL) {
+           FATAL("cannot find entry shutdown (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1);
+}
+
+SOCKET   PASCAL
+socket(int a0, int a1, int a2)
+{
+    static SOCKET   (PASCAL *fp)(int a0, int a1, int a2);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub socket() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "socket")) == NULL) {
+           FATAL("cannot find entry socket (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2);
+}
+
+int  PASCAL
+MigrateWinsockConfiguration(int a0, int a1, int a2)
+{
+    static int  (PASCAL *fp)(int a0, int a1, int a2);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub MigrateWinsockConfiguration() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "MigrateWinsockConfiguration")) == NULL) {
+           FATAL("cannot find entry MigrateWinsockConfiguration (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2);
+}
+
+ struct hostent * PASCAL
+_org_gethostbyaddr(const char* a0, int a1, int a2)
+{
+    static  struct hostent * (PASCAL *fp)(const char* a0, int a1, int a2);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub _org_gethostbyaddr() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "gethostbyaddr")) == NULL) {
+           FATAL("cannot find entry gethostbyaddr (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2);
+}
+
+ struct hostent * PASCAL
+_org_gethostbyname(const char* a0)
+{
+    static  struct hostent * (PASCAL *fp)(const char* a0);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub _org_gethostbyname() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "gethostbyname")) == NULL) {
+           FATAL("cannot find entry gethostbyname (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0);
+}
+
+ struct protoent * PASCAL
+getprotobyname(const char* a0)
+{
+    static  struct protoent * (PASCAL *fp)(const char* a0);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub getprotobyname() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "getprotobyname")) == NULL) {
+           FATAL("cannot find entry getprotobyname (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0);
+}
+
+ struct protoent * PASCAL
+getprotobynumber(int a0)
+{
+    static  struct protoent * (PASCAL *fp)(int a0);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub getprotobynumber() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "getprotobynumber")) == NULL) {
+           FATAL("cannot find entry getprotobynumber (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0);
+}
+
+ struct servent * PASCAL
+getservbyname(const char* a0, const char* a1)
+{
+    static  struct servent * (PASCAL *fp)(const char* a0, const char* a1);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub getservbyname() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "getservbyname")) == NULL) {
+           FATAL("cannot find entry getservbyname (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1);
+}
+
+ struct servent * PASCAL
+getservbyport(int a0, const char* a1)
+{
+    static  struct servent * (PASCAL *fp)(int a0, const char* a1);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub getservbyport() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "getservbyport")) == NULL) {
+           FATAL("cannot find entry getservbyport (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1);
+}
+
+int   PASCAL
+_org_gethostname(char* a0, int a1)
+{
+    static int   (PASCAL *fp)(char* a0, int a1);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub _org_gethostname() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "gethostname")) == NULL) {
+           FATAL("cannot find entry gethostname (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1);
+}
+
+int   PASCAL
+WSAAsyncSelect(SOCKET a0, HWND a1, u_int a2, long a3)
+{
+    static int   (PASCAL *fp)(SOCKET a0, HWND a1, u_int a2, long a3);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSAAsyncSelect() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSAAsyncSelect")) == NULL) {
+           FATAL("cannot find entry WSAAsyncSelect (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3);
+}
+
+HANDLE   PASCAL
+_org_WSAAsyncGetHostByAddr(HWND a0, u_int a1, const char* a2, int a3, int a4, char* a5, int a6)
+{
+    static HANDLE   (PASCAL *fp)(HWND a0, u_int a1, const char* a2, int a3, int a4, char* a5, int a6);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub _org_WSAAsyncGetHostByAddr() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSAAsyncGetHostByAddr")) == NULL) {
+           FATAL("cannot find entry WSAAsyncGetHostByAddr (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3, a4, a5, a6);
+}
+
+HANDLE   PASCAL
+_org_WSAAsyncGetHostByName(HWND a0, u_int a1, const char* a2, char* a3, int a4)
+{
+    static HANDLE   (PASCAL *fp)(HWND a0, u_int a1, const char* a2, char* a3, int a4);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub _org_WSAAsyncGetHostByName() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSAAsyncGetHostByName")) == NULL) {
+           FATAL("cannot find entry WSAAsyncGetHostByName (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3, a4);
+}
+
+HANDLE   PASCAL
+WSAAsyncGetProtoByNumber(HWND a0, u_int a1, int a2, char* a3, int a4)
+{
+    static HANDLE   (PASCAL *fp)(HWND a0, u_int a1, int a2, char* a3, int a4);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSAAsyncGetProtoByNumber() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSAAsyncGetProtoByNumber")) == NULL) {
+           FATAL("cannot find entry WSAAsyncGetProtoByNumber (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3, a4);
+}
+
+HANDLE   PASCAL
+WSAAsyncGetProtoByName(HWND a0, u_int a1, const char* a2, char* a3, int a4)
+{
+    static HANDLE   (PASCAL *fp)(HWND a0, u_int a1, const char* a2, char* a3, int a4);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSAAsyncGetProtoByName() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSAAsyncGetProtoByName")) == NULL) {
+           FATAL("cannot find entry WSAAsyncGetProtoByName (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3, a4);
+}
+
+HANDLE   PASCAL
+WSAAsyncGetServByPort(HWND a0, u_int a1, int a2, const char* a3, char* a4, int a5)
+{
+    static HANDLE   (PASCAL *fp)(HWND a0, u_int a1, int a2, const char* a3, char* a4, int a5);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSAAsyncGetServByPort() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSAAsyncGetServByPort")) == NULL) {
+           FATAL("cannot find entry WSAAsyncGetServByPort (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3, a4, a5);
+}
+
+HANDLE   PASCAL
+WSAAsyncGetServByName(HWND a0, u_int a1, const char* a2, const char* a3, char* a4, int a5)
+{
+    static HANDLE   (PASCAL *fp)(HWND a0, u_int a1, const char* a2, const char* a3, char* a4, int a5);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSAAsyncGetServByName() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSAAsyncGetServByName")) == NULL) {
+           FATAL("cannot find entry WSAAsyncGetServByName (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3, a4, a5);
+}
+
+int   PASCAL
+WSACancelAsyncRequest(HANDLE a0)
+{
+    static int   (PASCAL *fp)(HANDLE a0);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSACancelAsyncRequest() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSACancelAsyncRequest")) == NULL) {
+           FATAL("cannot find entry WSACancelAsyncRequest (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0);
+}
+
+FARPROC   PASCAL
+WSASetBlockingHook(FARPROC a0)
+{
+    static FARPROC   (PASCAL *fp)(FARPROC a0);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSASetBlockingHook() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSASetBlockingHook")) == NULL) {
+           FATAL("cannot find entry WSASetBlockingHook (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0);
+}
+
+int   PASCAL
+WSAUnhookBlockingHook(void)
+{
+    static int   (PASCAL *fp)(void);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSAUnhookBlockingHook() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSAUnhookBlockingHook")) == NULL) {
+           FATAL("cannot find entry WSAUnhookBlockingHook (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)();
+}
+
+int   PASCAL
+WSAGetLastError(void)
+{
+    static int   (PASCAL *fp)(void);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSAGetLastError() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSAGetLastError")) == NULL) {
+           FATAL("cannot find entry WSAGetLastError (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)();
+}
+
+void   PASCAL
+WSASetLastError(int a0)
+{
+    static void   (PASCAL *fp)(int a0);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSASetLastError() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSASetLastError")) == NULL) {
+           FATAL("cannot find entry WSASetLastError (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+     (*fp)(a0);
+}
+
+int   PASCAL
+WSACancelBlockingCall(void)
+{
+    static int   (PASCAL *fp)(void);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSACancelBlockingCall() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSACancelBlockingCall")) == NULL) {
+           FATAL("cannot find entry WSACancelBlockingCall (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)();
+}
+
+BOOL   PASCAL
+WSAIsBlocking(void)
+{
+    static BOOL   (PASCAL *fp)(void);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSAIsBlocking() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSAIsBlocking")) == NULL) {
+           FATAL("cannot find entry WSAIsBlocking (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)();
+}
+
+int   PASCAL
+WSAStartup(WORD a0, LPWSADATA a1)
+{
+    static int   (PASCAL *fp)(WORD a0, LPWSADATA a1);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSAStartup() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSAStartup")) == NULL) {
+           FATAL("cannot find entry WSAStartup (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1);
+}
+
+int   PASCAL
+WSACleanup(void)
+{
+    static int   (PASCAL *fp)(void);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSACleanup() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSACleanup")) == NULL) {
+           FATAL("cannot find entry WSACleanup (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)();
+}
+
+int   PASCAL
+__WSAFDIsSet(SOCKET a0, fd_set* a1)
+{
+    static int   (PASCAL *fp)(SOCKET a0, fd_set* a1);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub __WSAFDIsSet() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "__WSAFDIsSet")) == NULL) {
+           FATAL("cannot find entry __WSAFDIsSet (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1);
+}
+
+int  PASCAL
+WEP(void)
+{
+    static int  (PASCAL *fp)(void);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WEP() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WEP")) == NULL) {
+           FATAL("cannot find entry WEP (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)();
+}
+
+int  PASCAL
+WSApSetPostRoutine(int a0)
+{
+    static int  (PASCAL *fp)(int a0);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSApSetPostRoutine() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSApSetPostRoutine")) == NULL) {
+           FATAL("cannot find entry WSApSetPostRoutine (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0);
+}
+
+int  PASCAL
+WsControl(int a0, int a1, int a2, int a3, int a4, int a5)
+{
+    static int  (PASCAL *fp)(int a0, int a1, int a2, int a3, int a4, int a5);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WsControl() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WsControl")) == NULL) {
+           FATAL("cannot find entry WsControl (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3, a4, a5);
+}
+
+int  PASCAL
+closesockinfo(int a0)
+{
+    static int  (PASCAL *fp)(int a0);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub closesockinfo() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "closesockinfo")) == NULL) {
+           FATAL("cannot find entry closesockinfo (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0);
+}
+
+int  PASCAL
+Arecv(int a0, int a1, int a2, int a3)
+{
+    static int  (PASCAL *fp)(int a0, int a1, int a2, int a3);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub Arecv() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "Arecv")) == NULL) {
+           FATAL("cannot find entry Arecv (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3);
+}
+
+int  PASCAL
+Asend(int a0, int a1, int a2, int a3)
+{
+    static int  (PASCAL *fp)(int a0, int a1, int a2, int a3);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub Asend() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "Asend")) == NULL) {
+           FATAL("cannot find entry Asend (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3);
+}
+
+int  PASCAL
+WSHEnumProtocols(void)
+{
+    static int  (PASCAL *fp)(void);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSHEnumProtocols() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSHEnumProtocols")) == NULL) {
+           FATAL("cannot find entry WSHEnumProtocols (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)();
+}
+
+int  PASCAL
+inet_network(int a0)
+{
+    static int  (PASCAL *fp)(int a0);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub inet_network() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "inet_network")) == NULL) {
+           FATAL("cannot find entry inet_network (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0);
+}
+
+int  PASCAL
+getnetbyname(int a0)
+{
+    static int  (PASCAL *fp)(int a0);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub getnetbyname() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "getnetbyname")) == NULL) {
+           FATAL("cannot find entry getnetbyname (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0);
+}
+
+int  PASCAL
+rcmd(int a0, int a1, int a2, int a3, int a4, int a5)
+{
+    static int  (PASCAL *fp)(int a0, int a1, int a2, int a3, int a4, int a5);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub rcmd() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "rcmd")) == NULL) {
+           FATAL("cannot find entry rcmd (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3, a4, a5);
+}
+
+int  PASCAL
+rexec(int a0, int a1, int a2, int a3, int a4, int a5)
+{
+    static int  (PASCAL *fp)(int a0, int a1, int a2, int a3, int a4, int a5);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub rexec() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "rexec")) == NULL) {
+           FATAL("cannot find entry rexec (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3, a4, a5);
+}
+
+int  PASCAL
+rresvport(int a0)
+{
+    static int  (PASCAL *fp)(int a0);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub rresvport() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "rresvport")) == NULL) {
+           FATAL("cannot find entry rresvport (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0);
+}
+
+int  PASCAL
+sethostname(int a0, int a1)
+{
+    static int  (PASCAL *fp)(int a0, int a1);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub sethostname() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "sethostname")) == NULL) {
+           FATAL("cannot find entry sethostname (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1);
+}
+
+int  PASCAL
+dn_expand(int a0, int a1, int a2, int a3, int a4)
+{
+    static int  (PASCAL *fp)(int a0, int a1, int a2, int a3, int a4);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub dn_expand() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "dn_expand")) == NULL) {
+           FATAL("cannot find entry dn_expand (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3, a4);
+}
+
+int   PASCAL
+WSARecvEx(SOCKET a0, char* a1, int a2, int* a3)
+{
+    static int   (PASCAL *fp)(SOCKET a0, char* a1, int a2, int* a3);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSARecvEx() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSARecvEx")) == NULL) {
+           FATAL("cannot find entry WSARecvEx (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3);
+}
+
+int  PASCAL
+s_perror(int a0, int a1)
+{
+    static int  (PASCAL *fp)(int a0, int a1);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub s_perror() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "s_perror")) == NULL) {
+           FATAL("cannot find entry s_perror (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1);
+}
+
+INT   PASCAL
+GetAddressByNameA(DWORD a0, LPGUID a1, LPSTR a2, LPINT a3, DWORD a4, LPSERVICE_ASYNC_INFO a5, LPVOID a6, LPDWORD a7, LPSTR a8, LPDWORD a9)
+{
+    static INT   (PASCAL *fp)(DWORD a0, LPGUID a1, LPSTR a2, LPINT a3, DWORD a4, LPSERVICE_ASYNC_INFO a5, LPVOID a6, LPDWORD a7, LPSTR a8, LPDWORD a9);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub GetAddressByNameA() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "GetAddressByNameA")) == NULL) {
+           FATAL("cannot find entry GetAddressByNameA (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9);
+}
+
+INT   PASCAL
+GetAddressByNameW(DWORD a0, LPGUID a1, LPWSTR a2, LPINT a3, DWORD a4, LPSERVICE_ASYNC_INFO a5, LPVOID a6, LPDWORD a7, LPWSTR a8, LPDWORD a9)
+{
+    static INT   (PASCAL *fp)(DWORD a0, LPGUID a1, LPWSTR a2, LPINT a3, DWORD a4, LPSERVICE_ASYNC_INFO a5, LPVOID a6, LPDWORD a7, LPWSTR a8, LPDWORD a9);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub GetAddressByNameW() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "GetAddressByNameW")) == NULL) {
+           FATAL("cannot find entry GetAddressByNameW (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9);
+}
+
+INT   PASCAL
+EnumProtocolsA(LPINT a0, LPVOID a1, LPDWORD a2)
+{
+    static INT   (PASCAL *fp)(LPINT a0, LPVOID a1, LPDWORD a2);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub EnumProtocolsA() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "EnumProtocolsA")) == NULL) {
+           FATAL("cannot find entry EnumProtocolsA (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2);
+}
+
+INT   PASCAL
+EnumProtocolsW(LPINT a0, LPVOID a1, LPDWORD a2)
+{
+    static INT   (PASCAL *fp)(LPINT a0, LPVOID a1, LPDWORD a2);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub EnumProtocolsW() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "EnumProtocolsW")) == NULL) {
+           FATAL("cannot find entry EnumProtocolsW (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2);
+}
+
+INT   PASCAL
+GetTypeByNameA(LPSTR a0, LPGUID a1)
+{
+    static INT   (PASCAL *fp)(LPSTR a0, LPGUID a1);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub GetTypeByNameA() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "GetTypeByNameA")) == NULL) {
+           FATAL("cannot find entry GetTypeByNameA (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1);
+}
+
+INT   PASCAL
+GetTypeByNameW(LPWSTR a0, LPGUID a1)
+{
+    static INT   (PASCAL *fp)(LPWSTR a0, LPGUID a1);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub GetTypeByNameW() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "GetTypeByNameW")) == NULL) {
+           FATAL("cannot find entry GetTypeByNameW (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1);
+}
+
+INT   PASCAL
+GetNameByTypeA(LPGUID a0, LPSTR a1, DWORD a2)
+{
+    static INT   (PASCAL *fp)(LPGUID a0, LPSTR a1, DWORD a2);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub GetNameByTypeA() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "GetNameByTypeA")) == NULL) {
+           FATAL("cannot find entry GetNameByTypeA (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2);
+}
+
+INT   PASCAL
+GetNameByTypeW(LPGUID a0, LPWSTR a1, DWORD a2)
+{
+    static INT   (PASCAL *fp)(LPGUID a0, LPWSTR a1, DWORD a2);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub GetNameByTypeW() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "GetNameByTypeW")) == NULL) {
+           FATAL("cannot find entry GetNameByTypeW (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2);
+}
+
+INT   PASCAL
+SetServiceA(DWORD a0, DWORD a1, DWORD a2, LPSERVICE_INFOA a3, LPSERVICE_ASYNC_INFO a4, LPDWORD a5)
+{
+    static INT   (PASCAL *fp)(DWORD a0, DWORD a1, DWORD a2, LPSERVICE_INFOA a3, LPSERVICE_ASYNC_INFO a4, LPDWORD a5);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub SetServiceA() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "SetServiceA")) == NULL) {
+           FATAL("cannot find entry SetServiceA (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3, a4, a5);
+}
+
+INT   PASCAL
+SetServiceW(DWORD a0, DWORD a1, DWORD a2, LPSERVICE_INFOW a3, LPSERVICE_ASYNC_INFO a4, LPDWORD a5)
+{
+    static INT   (PASCAL *fp)(DWORD a0, DWORD a1, DWORD a2, LPSERVICE_INFOW a3, LPSERVICE_ASYNC_INFO a4, LPDWORD a5);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub SetServiceW() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "SetServiceW")) == NULL) {
+           FATAL("cannot find entry SetServiceW (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3, a4, a5);
+}
+
+INT   PASCAL
+GetServiceA(DWORD a0, LPGUID a1, LPSTR a2, DWORD a3, LPVOID a4, LPDWORD a5, LPSERVICE_ASYNC_INFO a6)
+{
+    static INT   (PASCAL *fp)(DWORD a0, LPGUID a1, LPSTR a2, DWORD a3, LPVOID a4, LPDWORD a5, LPSERVICE_ASYNC_INFO a6);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub GetServiceA() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "GetServiceA")) == NULL) {
+           FATAL("cannot find entry GetServiceA (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3, a4, a5, a6);
+}
+
+INT   PASCAL
+GetServiceW(DWORD a0, LPGUID a1, LPWSTR a2, DWORD a3, LPVOID a4, LPDWORD a5, LPSERVICE_ASYNC_INFO a6)
+{
+    static INT   (PASCAL *fp)(DWORD a0, LPGUID a1, LPWSTR a2, DWORD a3, LPVOID a4, LPDWORD a5, LPSERVICE_ASYNC_INFO a6);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub GetServiceW() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "GetServiceW")) == NULL) {
+           FATAL("cannot find entry GetServiceW (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3, a4, a5, a6);
+}
+
+int  PASCAL
+NPLoadNameSpaces(int a0, int a1, int a2)
+{
+    static int  (PASCAL *fp)(int a0, int a1, int a2);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub NPLoadNameSpaces() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "NPLoadNameSpaces")) == NULL) {
+           FATAL("cannot find entry NPLoadNameSpaces (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2);
+}
+
+int  PASCAL
+NSPStartup(int a0, int a1)
+{
+    static int  (PASCAL *fp)(int a0, int a1);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub NSPStartup() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "NSPStartup")) == NULL) {
+           FATAL("cannot find entry NSPStartup (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1);
+}
+
+BOOL   PASCAL
+TransmitFile(SOCKET a0, HANDLE a1, DWORD a2, DWORD a3, LPOVERLAPPED a4, LPTRANSMIT_FILE_BUFFERS a5, DWORD a6)
+{
+    static BOOL   (PASCAL *fp)(SOCKET a0, HANDLE a1, DWORD a2, DWORD a3, LPOVERLAPPED a4, LPTRANSMIT_FILE_BUFFERS a5, DWORD a6);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub TransmitFile() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "TransmitFile")) == NULL) {
+           FATAL("cannot find entry TransmitFile (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3, a4, a5, a6);
+}
+
+BOOL   PASCAL
+AcceptEx(SOCKET a0, SOCKET a1, PVOID a2, DWORD a3, DWORD a4, DWORD a5, LPDWORD a6, LPOVERLAPPED a7)
+{
+    static BOOL   (PASCAL *fp)(SOCKET a0, SOCKET a1, PVOID a2, DWORD a3, DWORD a4, DWORD a5, LPDWORD a6, LPOVERLAPPED a7);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub AcceptEx() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "AcceptEx")) == NULL) {
+           FATAL("cannot find entry AcceptEx (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3, a4, a5, a6, a7);
+}
+
+VOID   PASCAL
+GetAcceptExSockaddrs(PVOID a0, DWORD a1, DWORD a2, DWORD a3, struct sockaddr** a4, LPINT a5, struct sockaddr** a6, LPINT a7)
+{
+    static VOID   (PASCAL *fp)(PVOID a0, DWORD a1, DWORD a2, DWORD a3, struct sockaddr** a4, LPINT a5, struct sockaddr** a6, LPINT a7);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub GetAcceptExSockaddrs() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "GetAcceptExSockaddrs")) == NULL) {
+           FATAL("cannot find entry GetAcceptExSockaddrs (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+     (*fp)(a0, a1, a2, a3, a4, a5, a6, a7);
+}
+
diff --git a/contrib/idn/idnkit-1.0-src/wsock/wsock11/make.wnt b/contrib/idn/idnkit-1.0-src/wsock/wsock11/make.wnt
new file mode 100644 (file)
index 0000000..5543a6d
--- /dev/null
@@ -0,0 +1,98 @@
+#
+# Makefile for WinSock Wrapper (for WinSock 1.1)
+#
+
+# 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 <win32.mak>
+
+SYSLIBS = $(libcdll) kernel32.lib advapi32.lib user32.lib
+
+#
+# Files to use
+#
+
+HDRS = dlldef.h ..\common\wrapcommon.h
+SRCS = dllmain.c   dllload.c   dllfunc.c dllstub.c
+OBJS = dllmain.obj dllload.obj dllfunc.obj
+LIBS = ..\common\wrapcommon.lib ..\..\lib\idnkit.lib ..\..\win\iconv.lib
+
+cflags = $(cflags) -I..\..\include
+
+#
+# Targets to Build
+#
+
+TARGETS = wsock32.dll
+
+all : $(TARGETS)
+
+wsock32.dll : wsock32.def $(OBJS) $(LIBS)
+       $(link) $(dlllflags) /OUT:wsock32.dll /DEF:wsock32.def $(OBJS) $(LIBS) $(SYSLIBS)
+
+install : $(TARGETS)
+       copy wsock32.dll ..\bin
+
+clean : force
+       -del *.obj
+       -del *.lib
+       -del *.dll
+       -del *.exp
+
+#
+# Dependencies
+#
+
+dllmain.obj : dllmain.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -DDEBUG $*.c
+
+dllload.obj : dllload.c dllstub.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -DDEBUG $*.c
+
+
+dllfunc.obj : dllfunc.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -DDEBUG $*.c
+
+wsock32o.lib : wsock32o.def
+       LIB /DEF:wsock32o.def /MACHINE:IX86
+
+force :
+
diff --git a/contrib/idn/idnkit-1.0-src/wsock/wsock11/wsock32.def b/contrib/idn/idnkit-1.0-src/wsock/wsock11/wsock32.def
new file mode 100644 (file)
index 0000000..5501d26
--- /dev/null
@@ -0,0 +1,87 @@
+;
+; Library Defition for idn wrapper's wrapper DLL
+;
+LIBRARY wsock32
+DESCRIPTION "JPNIC idn wrapper DLL for WSOCK32"
+EXPORTS
+  accept                      @1
+  bind                        @2
+  closesocket                 @3
+  connect                     @4
+  getpeername                 @5
+  getsockname                 @6
+  getsockopt                  @7
+  htonl                       @8
+  htons                       @9
+  inet_addr                   @10
+  inet_ntoa                   @11
+  ioctlsocket                 @12
+  listen                      @13
+  ntohl                       @14
+  ntohs                       @15
+  recv                        @16
+  recvfrom                    @17
+  select                      @18
+  send                        @19
+  sendto                      @20
+  setsockopt                  @21
+  shutdown                    @22
+  socket                      @23
+  MigrateWinsockConfiguration @24
+  gethostbyaddr               @51
+  gethostbyname               @52
+  getprotobyname              @53
+  getprotobynumber            @54
+  getservbyname               @55
+  getservbyport               @56
+  gethostname                 @57
+  WSAAsyncSelect              @101
+  WSAAsyncGetHostByAddr       @102
+  WSAAsyncGetHostByName       @103
+  WSAAsyncGetProtoByNumber    @104
+  WSAAsyncGetProtoByName      @105
+  WSAAsyncGetServByPort       @106
+  WSAAsyncGetServByName       @107
+  WSACancelAsyncRequest       @108
+  WSASetBlockingHook          @109
+  WSAUnhookBlockingHook       @110
+  WSAGetLastError             @111
+  WSASetLastError             @112
+  WSACancelBlockingCall       @113
+  WSAIsBlocking               @114
+  WSAStartup                  @115
+  WSACleanup                  @116
+  __WSAFDIsSet                @151
+  WEP                         @500
+  WSApSetPostRoutine          @1000
+  WsControl                   @1001
+  closesockinfo               @1002
+  Arecv                       @1003
+  Asend                       @1004
+  WSHEnumProtocols            @1005
+  inet_network                @1100
+  getnetbyname                @1101
+  rcmd                        @1102
+  rexec                       @1103
+  rresvport                   @1104
+  sethostname                 @1105
+  dn_expand                   @1106
+  WSARecvEx                   @1107
+  s_perror                    @1108
+  GetAddressByNameA           @1109
+  GetAddressByNameW           @1110
+  EnumProtocolsA              @1111
+  EnumProtocolsW              @1112
+  GetTypeByNameA              @1113
+  GetTypeByNameW              @1114
+  GetNameByTypeA              @1115
+  GetNameByTypeW              @1116
+  SetServiceA                 @1117
+  SetServiceW                 @1118
+  GetServiceA                 @1119
+  GetServiceW                 @1120
+  NPLoadNameSpaces            @1130
+  NSPStartup                  @1131
+  TransmitFile                @1140
+  AcceptEx                    @1141
+  GetAcceptExSockaddrs        @1142
diff --git a/contrib/idn/idnkit-1.0-src/wsock/wsock20/dlldef.h b/contrib/idn/idnkit-1.0-src/wsock/wsock20/dlldef.h
new file mode 100644 (file)
index 0000000..52a2567
--- /dev/null
@@ -0,0 +1,123 @@
+/*
+ * dlldef.h
+ */
+
+/*
+ * 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.
+ */
+
+#ifndef _DLLDEF_H
+#define _DLLDEF_H
+
+#include "../common/wrapcommon.h"
+
+/*
+ * Execution Tracing
+ */
+extern  int     procPid;
+
+#ifdef  DEBUG
+#define TRACE   idnPrintf
+#define FATAL   idnPrintf
+#else
+#define TRACE
+#define FATAL   idnPrintf
+#endif
+
+/*
+ * entry points to wrap
+ */
+
+extern  int WSAAPI
+_org_gethostname(char FAR * name, int namelen);
+
+extern  struct hostent FAR * WSAAPI
+_org_gethostbyaddr(const char FAR * addr, int len, int type);
+
+extern  struct hostent FAR * WSAAPI
+_org_gethostbyname(const char FAR * name);
+
+extern  HANDLE WSAAPI
+_org_WSAAsyncGetHostByName(HWND hWnd, u_int wMsg, const char FAR * name,
+                          char FAR * buf,int buflen);
+
+extern  HANDLE WSAAPI
+_org_WSAAsyncGetHostByAddr(HWND hWnd, u_int wMsg, const char FAR * addr,
+                          int len, int type, char FAR * buf, int buflen);
+
+extern  INT WSAAPI
+_org_WSALookupServiceBeginA(LPWSAQUERYSETA lpqsRestrictions,
+                           DWORD          dwControlFlags,
+                           LPHANDLE       lphLookup);
+
+extern  INT WSAAPI
+_org_WSALookupServiceBeginW(LPWSAQUERYSETW lpqsRestrictions,
+                           DWORD          dwControlFlags,
+                           LPHANDLE       lphLookup);
+
+extern  INT WSAAPI
+_org_WSALookupServiceNextA(HANDLE           hLookup,
+                          DWORD            dwControlFlags,
+                          LPDWORD          lpdwBufferLength,
+                          LPWSAQUERYSETA   lpqsResults);
+
+extern  INT WSAAPI
+_org_WSALookupServiceNextW(HANDLE           hLookup,
+                          DWORD            dwControlFlags,
+                          LPDWORD          lpdwBufferLength,
+                          LPWSAQUERYSETW   lpqsResults);
+
+extern  INT WSAAPI
+_org_WSALookupServiceEnd(HANDLE  hLookup);
+
+extern int WSAAPI
+_org_getaddrinfo(const char *nodename, const char *servname,
+                LPVOID hints, LPVOID res);
+
+extern void WSAAPI
+_org_freeaddrinfo(LPVOID aip);
+
+extern int WSAAPI
+_org_getnameinfo(LPVOID sa, DWORD salen, char* host, DWORD hostlen,
+                char* serv, DWORD servlen, int flags);
+
+#endif  /* _DLLDEF_H */
diff --git a/contrib/idn/idnkit-1.0-src/wsock/wsock20/dllfunc.c b/contrib/idn/idnkit-1.0-src/wsock/wsock20/dllfunc.c
new file mode 100644 (file)
index 0000000..cec2d06
--- /dev/null
@@ -0,0 +1,592 @@
+/*
+ * dllfunc.c - wrapper functions
+ */
+
+/*
+ * 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 <windows.h>
+#include <svcguid.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <process.h>
+
+#include "dlldef.h"
+
+#ifndef EAI_MEMORY
+#define EAI_MEMORY     WSA_NOT_ENOUGH_MEMORY
+#endif
+#ifndef EAI_FAIL
+#define EAI_FAIL       WSANO_RECOVERY
+#endif
+
+static GUID guid_habn = SVCID_INET_HOSTADDRBYNAME;
+static GUID guid_habis = SVCID_INET_HOSTADDRBYINETSTRING;
+
+#define SVCID_IS_HABN(p) (memcmp(p, &guid_habn, sizeof(GUID)) == 0)
+#define SVCID_IS_HABIS(p) (memcmp(p, &guid_habis, sizeof(GUID)) == 0)
+
+/*
+ * Rename addrinfo to my_addrinfo for avoiding possible name conflict.
+ */
+struct my_addrinfo {
+       int     ai_flags;
+       int     ai_family;
+       int     ai_socktype;
+       int     ai_protocol;
+       size_t  ai_addrlen;
+       char   *ai_canonname;
+       struct sockaddr  *ai_addr;
+       struct my_addrinfo  *ai_next;
+};
+
+typedef struct obj_lock {
+       void *key;
+       struct obj_lock *next;
+} obj_lock_t;
+
+#define OBJLOCKHASH_SIZE       127
+static obj_lock_t *obj_lock_hash[OBJLOCKHASH_SIZE];
+
+static int     obj_hash(void *key);
+static int     obj_islocked(void *key);
+static void    obj_lock(void *key);
+static void    obj_unlock(void *key);
+static char    *decode_name_dynamic(const char *name, idn_resconf_t idnctx);
+static struct my_addrinfo
+               *copy_decode_addrinfo_dynamic(struct my_addrinfo *aip,
+                                             idn_resconf_t idnctx);
+static void    free_copied_addrinfo(struct my_addrinfo *aip);
+
+WRAPPER_EXPORT int WSAAPI
+gethostname(char FAR * name, int namelen) {
+       int ret;
+    
+       TRACE("ENTER gethostname\n");
+       ret = _org_gethostname(name, namelen);
+       TRACE("LEAVE gethostname %d <%-.100s>\n", ret, name);
+
+       return (ret);
+}
+
+WRAPPER_EXPORT struct hostent FAR * WSAAPI
+gethostbyname(const char FAR * name) {
+       struct hostent FAR *ret;
+       char    nbuff[256];
+       char    hbuff[256];
+       BOOL    stat;
+       idn_resconf_t   encodeCtx;
+    
+       TRACE("ENTER gethostbyname <%-.100s>\n",
+             (name != NULL ? name : "NULL"));
+    
+       encodeCtx = idnGetContext();
+
+       if (encodeCtx == NULL || name == NULL) {
+               ret = _org_gethostbyname(name);
+       } else {
+               stat = idnConvReq(encodeCtx, name, nbuff, sizeof(nbuff));
+               if (stat == FALSE) {
+                       TRACE("idnConvReq failed\n");
+                       ret = NULL;
+               } else {
+                       TRACE("Converted Name <%s>\n",
+                             dumpName(nbuff, hbuff, sizeof(hbuff)));
+                       ret = _org_gethostbyname(nbuff);
+               }
+       }
+
+       if (ret != NULL && encodeCtx != NULL) {
+               TRACE("Resulting Name <%s>\n",
+                     dumpName(ret->h_name, hbuff, sizeof(hbuff)));
+               stat = idnConvRsp(encodeCtx, ret->h_name,
+                                 nbuff, sizeof(nbuff));
+               if (stat == FALSE) {
+                       TRACE("Decoding failed - return the name verbatim\n");
+               } else {
+                       TRACE("Converted Back <%s>\n",
+                             dumpName(nbuff, hbuff, sizeof(hbuff)));
+                       strcpy(ret->h_name, nbuff);
+               }
+       }
+
+       if (ret == NULL) {
+               TRACE("LEAVE gethostbyname NULL\n");
+       } else {
+               TRACE("LEAVE gethostbyname <%s>\n",
+                     dumpHost(ret, hbuff, sizeof(hbuff)));
+       }
+       return (ret);
+}
+
+WRAPPER_EXPORT struct hostent FAR * WSAAPI
+gethostbyaddr(const char FAR * addr, int len, int type) {
+       struct hostent FAR *ret;
+       char    nbuff[256];
+       char    abuff[256];
+       char    hbuff[256];
+       BOOL    stat;
+       idn_resconf_t   encodeCtx;
+    
+       TRACE("ENTER gethostbyaddr <%s>\n",
+             dumpAddr(addr, len, abuff, sizeof(abuff)));
+
+       encodeCtx = idnGetContext();
+
+       ret = _org_gethostbyaddr(addr, len, type);
+
+       if (ret != NULL && encodeCtx != NULL) {
+               TRACE("Resulting Name <%s>\n",
+                     dumpName(ret->h_name, hbuff, sizeof(hbuff)));
+               stat = idnConvRsp(encodeCtx, ret->h_name,
+                                 nbuff, sizeof(nbuff));
+               if (stat == FALSE) {
+                       TRACE("Decoding failed - return the name verbatim\n");
+               } else {
+                       TRACE("Converted Back <%s>\n",
+                             dumpName(nbuff, hbuff, sizeof(hbuff)));
+                       strcpy(ret->h_name, nbuff);
+               }
+       }
+    
+       if (ret == NULL) {
+               TRACE("LEAVE gethostbyaddr NULL\n");
+       } else {
+               TRACE("LEAVE gethostbyaddr <%s>\n",
+                     dumpHost(ret, hbuff, sizeof(hbuff)));
+       }    
+       return (ret);
+}
+
+WRAPPER_EXPORT HANDLE WSAAPI
+WSAAsyncGetHostByName(HWND hWnd, u_int wMsg, 
+                     const char FAR * name, char FAR * buf, int buflen)
+{
+       HANDLE  ret;
+       char    nbuff[256];
+       char    hbuff[256];
+       idn_resconf_t   encodeCtx;
+    
+       TRACE("ENTER WSAAsyncGetHostByName <%-.100s>\n", name);
+
+       encodeCtx = idnGetContext();
+
+       if (encodeCtx == NULL || name == NULL) {
+               ret = _org_WSAAsyncGetHostByName(hWnd, wMsg,
+                                                name, buf, buflen);
+       } else {
+               idnHook(hWnd, wMsg, buf, encodeCtx);
+               idnConvReq(encodeCtx, name, nbuff, sizeof(nbuff));
+               TRACE("Converted Name <%s>\n",
+                     dumpName(nbuff, hbuff, sizeof(hbuff)));
+               ret = _org_WSAAsyncGetHostByName(hWnd, wMsg, nbuff,
+                                                buf, buflen);
+       }
+
+       TRACE("LEAVE WSAAsyncGetHostByName HANDLE %08x\n", ret);
+    
+       return (ret);
+}
+
+WRAPPER_EXPORT HANDLE WSAAPI
+WSAAsyncGetHostByAddr(HWND hWnd, u_int wMsg, const char FAR * addr,
+                     int len, int type, char FAR * buf, int buflen)
+{
+       HANDLE  ret;
+       char    abuff[256];
+       idn_resconf_t   encodeCtx;
+    
+       encodeCtx = idnGetContext();
+
+       if (encodeCtx != NULL) {
+               idnHook(hWnd, wMsg, buf, encodeCtx);
+       }
+    
+       TRACE("ENTER WSAAsyncGetHostByAddr <%s>\n",
+             dumpAddr(addr, len, abuff, sizeof(abuff)));
+       ret = _org_WSAAsyncGetHostByAddr(hWnd, wMsg, addr, len, type,
+                                        buf, buflen);
+       TRACE("LEAVE WSAAsyncGetHostByAddr HANDLE %08x\n", ret);
+
+       return (ret);
+}
+
+WRAPPER_EXPORT INT WSAAPI
+WSALookupServiceBeginA(LPWSAQUERYSETA lpqsRestrictions, 
+                      DWORD dwControlFlags, LPHANDLE lphLookup)
+{
+       INT     ret;
+       char    nbuff[256];
+       char    hbuff[256];
+       LPSTR   name = lpqsRestrictions->lpszServiceInstanceName;
+       LPGUID  class = lpqsRestrictions->lpServiceClassId;
+       idn_resconf_t   encodeCtx;
+    
+       TRACE("ENTER WSALookupServiceBeginA <%-.100s>\n",
+             name == NULL ? "<NULL>" : name);
+
+       encodeCtx = idnGetContext();
+
+       if (name != NULL && encodeCtx != NULL && SVCID_IS_HABN(class) == 0) {
+               idnConvReq(encodeCtx, name, nbuff, sizeof(nbuff));
+               TRACE("Converted Name <%s>\n",
+                     dumpName(nbuff, hbuff, sizeof(hbuff)));
+               /* strcpy(lpqsRestrictions->lpszQueryString, nbuff); */
+               lpqsRestrictions->lpszServiceInstanceName = nbuff;
+       }
+       ret = _org_WSALookupServiceBeginA(lpqsRestrictions,
+                                         dwControlFlags, lphLookup);
+       TRACE("LEAVE WSALookupServiceBeginA %d\n", ret);
+
+       return (ret);
+}
+
+WRAPPER_EXPORT INT WSAAPI
+WSALookupServiceNextA(HANDLE hLookup, DWORD dwControlFlags, 
+                     LPDWORD lpdwBufferLength, LPWSAQUERYSETA lpqsResults)
+{
+       INT     ret;
+       char    nbuff[256];
+       char    hbuff[256];
+       LPGUID  class;
+       idn_resconf_t   encodeCtx;
+    
+       TRACE("ENTER WSALookupServiceNextA\n");
+
+       encodeCtx = idnGetContext();
+
+       ret = _org_WSALookupServiceNextA(hLookup, dwControlFlags,
+                                        lpdwBufferLength, lpqsResults);
+       class = lpqsResults->lpServiceClassId;
+
+       if (ret == 0 &&
+           encodeCtx != NULL &&
+           (dwControlFlags & LUP_RETURN_NAME) &&
+           (SVCID_IS_HABN(class) || SVCID_IS_HABIS(class))) {
+               TRACE("Resulting Name <%s>\n",
+                     dumpName(lpqsResults->lpszServiceInstanceName,
+                              hbuff, sizeof(hbuff)));
+               if (idnConvRsp(encodeCtx, 
+                              lpqsResults->lpszServiceInstanceName,
+                              nbuff, sizeof(nbuff)) == FALSE) {
+                       TRACE("Decoding failed - return the name verbatim\n");
+               } else {
+                       TRACE("Converted Back <%s>\n",
+                             dumpName(nbuff, hbuff, sizeof(hbuff)));
+                       strcpy(lpqsResults->lpszServiceInstanceName, nbuff);
+               }
+       }
+       TRACE("LEAVE WSALookupServiceNextA %d <%s>\n", ret, nbuff);
+
+       return (ret);
+}         
+
+WRAPPER_EXPORT INT WSAAPI
+WSALookupServiceBeginW(LPWSAQUERYSETW lpqsRestrictions,
+                      DWORD dwControlFlags, LPHANDLE lphLookup)
+{
+       INT     ret;
+    
+       TRACE("ENTER WSALookupServiceBeginW\n");
+       ret = _org_WSALookupServiceBeginW(lpqsRestrictions,
+                                         dwControlFlags,lphLookup);
+       TRACE("LEAVE WSALookupServiceBeginW %d\n", ret);
+
+       return (ret);
+}
+
+WRAPPER_EXPORT INT WSAAPI
+WSALookupServiceNextW(HANDLE hLookup, DWORD dwControlFlags,
+                     LPDWORD lpdwBufferLength, LPWSAQUERYSETW lpqsResults)
+{
+       INT     ret;
+    
+       TRACE("ENTER WSALookupServiceNextW\n");
+       ret = _org_WSALookupServiceNextW(hLookup, dwControlFlags,
+                                        lpdwBufferLength, lpqsResults);
+       TRACE("LEAVE WSALookupServiceNextW %d\n", ret);
+
+       return (ret);
+}         
+
+WRAPPER_EXPORT INT WSAAPI
+WSALookupServiceEnd(HANDLE  hLookup) {
+       INT     ret;
+    
+       TRACE("ENTER WSALookupServiceEnd\n");
+       ret = _org_WSALookupServiceEnd(hLookup);
+       TRACE("LEAVE WSALookupServiceEnd %d\n", ret);
+
+       return (ret);
+}
+
+static int
+obj_hash(void *key) {
+       /*
+        * Hash function for obj_*.
+        * 'key' is supposed to be an address.
+        */
+       unsigned long v = (unsigned long)key;
+
+       return ((v >> 3) % OBJLOCKHASH_SIZE);
+}
+
+static int
+obj_islocked(void *key)
+{
+       /*
+        * Check if the object specified by 'key' is locked.
+        * Return 1 if so, 0 otherwise.
+        */
+       int h = obj_hash(key);
+       obj_lock_t *olp = obj_lock_hash[h];
+
+       while (olp != NULL) {
+               if (olp->key == key)
+                       return (1);
+               olp = olp->next;
+       }
+       return (0);
+}
+
+static void
+obj_lock(void *key)
+{
+       /*
+        * Lock an object specified by 'key'.
+        */
+       int h = obj_hash(key);
+       obj_lock_t *olp;
+
+       olp = malloc(sizeof(obj_lock_t));
+       if (olp != NULL) {
+               olp->key = key;
+               olp->next = obj_lock_hash[h];
+               obj_lock_hash[h] = olp;
+       }
+}
+
+static void
+obj_unlock(void *key)
+{
+       /*
+        * Unlock an object specified by 'key'.
+        */
+       int h = obj_hash(key);
+       obj_lock_t *olp, *olp0;
+
+       olp = obj_lock_hash[h];
+       olp0 = NULL;
+       while (olp != NULL) {
+               if (olp->key == key) {
+                       if (olp0 == NULL)
+                               obj_lock_hash[h] = olp->next;
+                       else
+                               olp0->next = olp->next;
+                       free(olp);
+                       return;
+               }
+               olp0 = olp;
+               olp = olp->next;
+       }
+}
+
+static char *
+decode_name_dynamic(const char *name, idn_resconf_t idnctx) {
+       BOOL stat;
+       char buf[256], tmp[256];
+       char *s;
+
+       if (idnConvRsp(idnctx, name, buf, sizeof(buf)) == TRUE) {
+               TRACE("Converted Back <%s>\n",
+                     dumpName(buf, tmp, sizeof(tmp)));
+               name = buf;
+       } else {
+               TRACE("Decoding failed - return the name verbatim\n");
+       }
+       s = malloc(strlen(name) + 1);
+       if (s == NULL)
+               return (NULL);
+       else
+               return (strcpy(s, name));
+}
+               
+static struct my_addrinfo *
+copy_decode_addrinfo_dynamic(struct my_addrinfo *aip, idn_resconf_t idnctx)
+{
+       struct my_addrinfo *newaip;
+
+       if (aip == NULL)
+               return (NULL);
+
+       newaip = malloc(sizeof(struct my_addrinfo) + aip->ai_addrlen);
+       if (newaip == NULL)
+               return (NULL);
+
+       *newaip = *aip;
+       newaip->ai_addr = (struct sockaddr *)(newaip + 1);
+       memcpy(newaip->ai_addr, aip->ai_addr, aip->ai_addrlen);
+
+       if (newaip->ai_canonname != NULL)
+               newaip->ai_canonname = decode_name_dynamic(aip->ai_canonname,
+                                                          idnctx);
+
+       newaip->ai_next = copy_decode_addrinfo_dynamic(aip->ai_next, idnctx);
+       return (newaip);
+}
+
+static void
+free_copied_addrinfo(struct my_addrinfo *aip) {
+       while (aip != NULL) {
+               struct my_addrinfo *next = aip->ai_next;
+
+               if (aip->ai_canonname != NULL)
+                       free(aip->ai_canonname);
+               free(aip);
+               aip = next;
+       }
+}
+
+WRAPPER_EXPORT int WSAAPI
+getaddrinfo(const char *nodename, const char *servname,
+           const struct my_addrinfo *hints, struct my_addrinfo **res)
+{
+       char namebuf[256];
+       BOOL stat;
+       struct my_addrinfo *aip;
+       int err;
+       idn_resconf_t   encodeCtx;
+
+       TRACE("ENTER getaddrinfo <%-.100s>\n", nodename ? nodename : "NULL");
+
+       encodeCtx = idnGetContext();
+
+       if (nodename == NULL || encodeCtx == NULL) {
+               TRACE("conversion unnecessary\n");
+               err = _org_getaddrinfo(nodename, servname, hints, res);
+       } else {
+               stat = idnConvReq(encodeCtx, nodename,
+                                 namebuf, sizeof(namebuf));
+               if (stat == TRUE) {
+                       nodename = namebuf;
+                       TRACE("Converted Name <%-.100s>\n", namebuf);
+               }
+
+               err = _org_getaddrinfo(nodename, servname, hints, &aip);
+               if (err == 0 && aip != NULL) {
+                       *res = copy_decode_addrinfo_dynamic(aip, encodeCtx);
+                       if (*res == NULL)
+                               err = EAI_FAIL;
+                       else 
+                               obj_lock(*res);
+                       if (aip != NULL)
+                               _org_freeaddrinfo(aip);
+               }
+       }
+
+       TRACE("LEAVE getaddrinfo %d\n", err);
+       return (err);
+}
+
+WRAPPER_EXPORT void WSAAPI
+freeaddrinfo(struct my_addrinfo *aip) {
+       TRACE("ENTER freeaddrinfo aip=%p\n", (void *)aip);
+
+       if (obj_islocked(aip)) {
+               /*
+                * We allocated the data.
+                */
+               obj_unlock(aip);
+               free_copied_addrinfo(aip);
+       } else {
+               /*
+                * It was allocated the original getaddrinfo().
+                */
+               TRACE("Not allocated by the wrapper\n");
+               _org_freeaddrinfo(aip);
+       }
+       TRACE("LEAVE freeaddrinfo\n");
+}
+
+WRAPPER_EXPORT int WSAAPI
+getnameinfo(const struct sockaddr *sa, DWORD salen,
+           char *host, DWORD hostlen, char *serv,
+           DWORD servlen, int flags)
+{
+       char name[256];
+       size_t namelen = sizeof(name);
+       int code;
+       BOOL stat;
+       idn_resconf_t   encodeCtx;
+
+       TRACE("ENTER getnameinfo\n");
+
+       encodeCtx = idnGetContext();
+
+       if (host == NULL || hostlen == 0 || encodeCtx == NULL) {
+               TRACE("conversion unnecessary\n");
+               code = _org_getnameinfo(sa, salen, host, hostlen,
+                                       serv, servlen, flags);
+       } else {
+               code = _org_getnameinfo(sa, salen, name, namelen,
+                                       serv, servlen, flags);
+               if (code == 0 && name[0] != '\0') {
+                       stat = idnConvRsp(encodeCtx, name, host, hostlen);
+                       if (stat == FALSE) {
+                               TRACE("Decoding failed - return the name verbatim\n");
+                               if (strlen(name) >= hostlen) {
+                                       code = EAI_FAIL;
+                               } else {
+                                       strcpy(host, name);
+                               }
+                       } else {
+                               TRACE("Converted Back <%s>\n",
+                                     dumpName(host, name, sizeof(name)));
+                       }
+               }
+       }
+
+       TRACE("LEAVE getnameinfo %d\n", code);
+       return (code);
+}
diff --git a/contrib/idn/idnkit-1.0-src/wsock/wsock20/dllload.c b/contrib/idn/idnkit-1.0-src/wsock/wsock20/dllload.c
new file mode 100644 (file)
index 0000000..0f1257e
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * dllload.c - load original entries
+ */
+
+/*
+ * 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 <windows.h>
+#include <winsock2.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <process.h>
+
+#include "dlldef.h"
+
+/*
+ * Manages original DLL 
+ */
+#define DLLHANDLE      idnWinsockHandle()
+
+#include "dllstub.c"
diff --git a/contrib/idn/idnkit-1.0-src/wsock/wsock20/dllmain.c b/contrib/idn/idnkit-1.0-src/wsock/wsock20/dllmain.c
new file mode 100644 (file)
index 0000000..c6609bc
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+ * dllmain.c - entry for DLL
+ */
+
+/*
+ * 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 <windows.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <process.h>
+
+#include "dlldef.h"
+
+/*
+ * Control Variables
+ */
+
+int procPid = 0;
+
+static char procExe[256];
+
+/*
+ * DLL Entry
+ */
+BOOL APIENTRY
+DllMain(HMODULE hmod, DWORD reason, LPVOID *resv) {
+       switch (reason) {
+       case DLL_PROCESS_ATTACH:
+               procPid = getpid();
+               GetModuleFileName(NULL, procExe, 256);
+       
+               idnLogInit("ws20");
+               idnHookInit();
+
+               TRACE("Attached to Process <%s>\n", procExe);
+               return (idnWinsockVersion("2.0"));
+
+       case DLL_PROCESS_DETACH:
+               idnConvDone(idnGetContext());
+               idnHookDone();
+               TRACE("Detached from Process\n");
+               idnLogFinish();
+               break;
+
+       case DLL_THREAD_ATTACH:
+               break;
+       case DLL_THREAD_DETACH:
+               break;
+       }
+
+       return (TRUE);
+}
diff --git a/contrib/idn/idnkit-1.0-src/wsock/wsock20/dllstub.c b/contrib/idn/idnkit-1.0-src/wsock/wsock20/dllstub.c
new file mode 100644 (file)
index 0000000..f3e695e
--- /dev/null
@@ -0,0 +1,2168 @@
+/* $Id: dllstub.c,v 1.1 2003/06/04 00:27:51 marka Exp $ */
+
+SOCKET   PASCAL
+accept(SOCKET a0, struct sockaddr* a1, int* a2)
+{
+    static SOCKET   (PASCAL *fp)(SOCKET a0, struct sockaddr* a1, int* a2);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub accept() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "accept")) == NULL) {
+           FATAL("cannot find entry accept (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2);
+}
+
+int   PASCAL
+bind(SOCKET a0, const struct sockaddr* a1, int a2)
+{
+    static int   (PASCAL *fp)(SOCKET a0, const struct sockaddr* a1, int a2);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub bind() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "bind")) == NULL) {
+           FATAL("cannot find entry bind (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2);
+}
+
+int   PASCAL
+closesocket(SOCKET a0)
+{
+    static int   (PASCAL *fp)(SOCKET a0);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub closesocket() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "closesocket")) == NULL) {
+           FATAL("cannot find entry closesocket (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0);
+}
+
+int   PASCAL
+connect(SOCKET a0, const struct sockaddr* a1, int a2)
+{
+    static int   (PASCAL *fp)(SOCKET a0, const struct sockaddr* a1, int a2);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub connect() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "connect")) == NULL) {
+           FATAL("cannot find entry connect (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2);
+}
+
+int   PASCAL
+getpeername(SOCKET a0, struct sockaddr* a1, int* a2)
+{
+    static int   (PASCAL *fp)(SOCKET a0, struct sockaddr* a1, int* a2);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub getpeername() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "getpeername")) == NULL) {
+           FATAL("cannot find entry getpeername (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2);
+}
+
+int   PASCAL
+getsockname(SOCKET a0, struct sockaddr* a1, int* a2)
+{
+    static int   (PASCAL *fp)(SOCKET a0, struct sockaddr* a1, int* a2);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub getsockname() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "getsockname")) == NULL) {
+           FATAL("cannot find entry getsockname (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2);
+}
+
+int   PASCAL
+getsockopt(SOCKET a0, int a1, int a2, char* a3, int* a4)
+{
+    static int   (PASCAL *fp)(SOCKET a0, int a1, int a2, char* a3, int* a4);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub getsockopt() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "getsockopt")) == NULL) {
+           FATAL("cannot find entry getsockopt (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3, a4);
+}
+
+u_long   PASCAL
+htonl(u_long a0)
+{
+    static u_long   (PASCAL *fp)(u_long a0);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub htonl() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "htonl")) == NULL) {
+           FATAL("cannot find entry htonl (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0);
+}
+
+u_short   PASCAL
+htons(u_short a0)
+{
+    static u_short   (PASCAL *fp)(u_short a0);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub htons() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "htons")) == NULL) {
+           FATAL("cannot find entry htons (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0);
+}
+
+int   PASCAL
+ioctlsocket(SOCKET a0, long a1, u_long * a2)
+{
+    static int   (PASCAL *fp)(SOCKET a0, long a1, u_long * a2);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub ioctlsocket() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "ioctlsocket")) == NULL) {
+           FATAL("cannot find entry ioctlsocket (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2);
+}
+
+unsigned long   PASCAL
+inet_addr(const char* a0)
+{
+    static unsigned long   (PASCAL *fp)(const char* a0);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub inet_addr() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "inet_addr")) == NULL) {
+           FATAL("cannot find entry inet_addr (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0);
+}
+
+ char * PASCAL
+inet_ntoa(struct in_addr a0)
+{
+    static  char * (PASCAL *fp)(struct in_addr a0);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub inet_ntoa() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "inet_ntoa")) == NULL) {
+           FATAL("cannot find entry inet_ntoa (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0);
+}
+
+int   PASCAL
+listen(SOCKET a0, int a1)
+{
+    static int   (PASCAL *fp)(SOCKET a0, int a1);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub listen() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "listen")) == NULL) {
+           FATAL("cannot find entry listen (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1);
+}
+
+u_long   PASCAL
+ntohl(u_long a0)
+{
+    static u_long   (PASCAL *fp)(u_long a0);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub ntohl() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "ntohl")) == NULL) {
+           FATAL("cannot find entry ntohl (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0);
+}
+
+u_short   PASCAL
+ntohs(u_short a0)
+{
+    static u_short   (PASCAL *fp)(u_short a0);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub ntohs() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "ntohs")) == NULL) {
+           FATAL("cannot find entry ntohs (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0);
+}
+
+int   PASCAL
+recv(SOCKET a0, char* a1, int a2, int a3)
+{
+    static int   (PASCAL *fp)(SOCKET a0, char* a1, int a2, int a3);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub recv() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "recv")) == NULL) {
+           FATAL("cannot find entry recv (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3);
+}
+
+int   PASCAL
+recvfrom(SOCKET a0, char* a1, int a2, int a3, struct sockaddr* a4, int* a5)
+{
+    static int   (PASCAL *fp)(SOCKET a0, char* a1, int a2, int a3, struct sockaddr* a4, int* a5);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub recvfrom() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "recvfrom")) == NULL) {
+           FATAL("cannot find entry recvfrom (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3, a4, a5);
+}
+
+int   PASCAL
+select(int a0, fd_set* a1, fd_set* a2, fd_set* a3, const struct timeval* a4)
+{
+    static int   (PASCAL *fp)(int a0, fd_set* a1, fd_set* a2, fd_set* a3, const struct timeval* a4);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub select() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "select")) == NULL) {
+           FATAL("cannot find entry select (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3, a4);
+}
+
+int   PASCAL
+send(SOCKET a0, const char* a1, int a2, int a3)
+{
+    static int   (PASCAL *fp)(SOCKET a0, const char* a1, int a2, int a3);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub send() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "send")) == NULL) {
+           FATAL("cannot find entry send (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3);
+}
+
+int   PASCAL
+sendto(SOCKET a0, const char* a1, int a2, int a3, const struct sockaddr* a4, int a5)
+{
+    static int   (PASCAL *fp)(SOCKET a0, const char* a1, int a2, int a3, const struct sockaddr* a4, int a5);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub sendto() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "sendto")) == NULL) {
+           FATAL("cannot find entry sendto (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3, a4, a5);
+}
+
+int   PASCAL
+setsockopt(SOCKET a0, int a1, int a2, const char* a3, int a4)
+{
+    static int   (PASCAL *fp)(SOCKET a0, int a1, int a2, const char* a3, int a4);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub setsockopt() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "setsockopt")) == NULL) {
+           FATAL("cannot find entry setsockopt (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3, a4);
+}
+
+int   PASCAL
+shutdown(SOCKET a0, int a1)
+{
+    static int   (PASCAL *fp)(SOCKET a0, int a1);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub shutdown() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "shutdown")) == NULL) {
+           FATAL("cannot find entry shutdown (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1);
+}
+
+SOCKET   PASCAL
+socket(int a0, int a1, int a2)
+{
+    static SOCKET   (PASCAL *fp)(int a0, int a1, int a2);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub socket() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "socket")) == NULL) {
+           FATAL("cannot find entry socket (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2);
+}
+
+int  PASCAL
+WSApSetPostRoutine(int a0)
+{
+    static int  (PASCAL *fp)(int a0);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSApSetPostRoutine() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSApSetPostRoutine")) == NULL) {
+           FATAL("cannot find entry WSApSetPostRoutine (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0);
+}
+
+WSAEVENT   WSAAPI
+WPUCompleteOverlappedRequest(SOCKET a0, LPWSAOVERLAPPED a1, DWORD a2, DWORD a3, LPINT a4)
+{
+    static WSAEVENT   (WSAAPI *fp)(SOCKET a0, LPWSAOVERLAPPED a1, DWORD a2, DWORD a3, LPINT a4);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WPUCompleteOverlappedRequest() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WPUCompleteOverlappedRequest")) == NULL) {
+           FATAL("cannot find entry WPUCompleteOverlappedRequest (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3, a4);
+}
+
+SOCKET   WINAPI
+WSAAccept(SOCKET a0, struct sockaddr * a1, LPINT a2, LPCONDITIONPROC a3, DWORD a4)
+{
+    static SOCKET   (WINAPI *fp)(SOCKET a0, struct sockaddr * a1, LPINT a2, LPCONDITIONPROC a3, DWORD a4);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSAAccept() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSAAccept")) == NULL) {
+           FATAL("cannot find entry WSAAccept (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3, a4);
+}
+
+INT   WINAPI
+WSAAddressToStringA(LPSOCKADDR a0, DWORD a1, LPWSAPROTOCOL_INFOA a2, LPSTR a3, LPDWORD a4)
+{
+    static INT   (WINAPI *fp)(LPSOCKADDR a0, DWORD a1, LPWSAPROTOCOL_INFOA a2, LPSTR a3, LPDWORD a4);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSAAddressToStringA() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSAAddressToStringA")) == NULL) {
+           FATAL("cannot find entry WSAAddressToStringA (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3, a4);
+}
+
+INT   WINAPI
+WSAAddressToStringW(LPSOCKADDR a0, DWORD a1, LPWSAPROTOCOL_INFOW a2, LPWSTR a3, LPDWORD a4)
+{
+    static INT   (WINAPI *fp)(LPSOCKADDR a0, DWORD a1, LPWSAPROTOCOL_INFOW a2, LPWSTR a3, LPDWORD a4);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSAAddressToStringW() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSAAddressToStringW")) == NULL) {
+           FATAL("cannot find entry WSAAddressToStringW (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3, a4);
+}
+
+BOOL   WINAPI
+WSACloseEvent(WSAEVENT a0)
+{
+    static BOOL   (WINAPI *fp)(WSAEVENT a0);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSACloseEvent() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSACloseEvent")) == NULL) {
+           FATAL("cannot find entry WSACloseEvent (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0);
+}
+
+int   WINAPI
+WSAConnect(SOCKET a0, const struct sockaddr * a1, int a2, LPWSABUF a3, LPWSABUF a4, LPQOS a5, LPQOS a6)
+{
+    static int   (WINAPI *fp)(SOCKET a0, const struct sockaddr * a1, int a2, LPWSABUF a3, LPWSABUF a4, LPQOS a5, LPQOS a6);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSAConnect() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSAConnect")) == NULL) {
+           FATAL("cannot find entry WSAConnect (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3, a4, a5, a6);
+}
+
+WSAEVENT   WINAPI
+WSACreateEvent(void)
+{
+    static WSAEVENT   (WINAPI *fp)(void);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSACreateEvent() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSACreateEvent")) == NULL) {
+           FATAL("cannot find entry WSACreateEvent (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)();
+}
+
+int   WINAPI
+WSADuplicateSocketA(SOCKET a0, DWORD a1, LPWSAPROTOCOL_INFOA a2)
+{
+    static int   (WINAPI *fp)(SOCKET a0, DWORD a1, LPWSAPROTOCOL_INFOA a2);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSADuplicateSocketA() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSADuplicateSocketA")) == NULL) {
+           FATAL("cannot find entry WSADuplicateSocketA (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2);
+}
+
+int   WINAPI
+WSADuplicateSocketW(SOCKET a0, DWORD a1, LPWSAPROTOCOL_INFOW a2)
+{
+    static int   (WINAPI *fp)(SOCKET a0, DWORD a1, LPWSAPROTOCOL_INFOW a2);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSADuplicateSocketW() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSADuplicateSocketW")) == NULL) {
+           FATAL("cannot find entry WSADuplicateSocketW (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2);
+}
+
+INT   WINAPI
+WSAEnumNameSpaceProvidersA(LPDWORD a0, LPWSANAMESPACE_INFOA a1)
+{
+    static INT   (WINAPI *fp)(LPDWORD a0, LPWSANAMESPACE_INFOA a1);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSAEnumNameSpaceProvidersA() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSAEnumNameSpaceProvidersA")) == NULL) {
+           FATAL("cannot find entry WSAEnumNameSpaceProvidersA (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1);
+}
+
+INT   WINAPI
+WSAEnumNameSpaceProvidersW(LPDWORD a0, LPWSANAMESPACE_INFOW a1)
+{
+    static INT   (WINAPI *fp)(LPDWORD a0, LPWSANAMESPACE_INFOW a1);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSAEnumNameSpaceProvidersW() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSAEnumNameSpaceProvidersW")) == NULL) {
+           FATAL("cannot find entry WSAEnumNameSpaceProvidersW (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1);
+}
+
+int   WINAPI
+WSAEnumNetworkEvents(SOCKET a0, WSAEVENT a1, LPWSANETWORKEVENTS a2)
+{
+    static int   (WINAPI *fp)(SOCKET a0, WSAEVENT a1, LPWSANETWORKEVENTS a2);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSAEnumNetworkEvents() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSAEnumNetworkEvents")) == NULL) {
+           FATAL("cannot find entry WSAEnumNetworkEvents (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2);
+}
+
+int   WINAPI
+WSAEnumProtocolsA(LPINT a0, LPWSAPROTOCOL_INFOA a1, LPDWORD a2)
+{
+    static int   (WINAPI *fp)(LPINT a0, LPWSAPROTOCOL_INFOA a1, LPDWORD a2);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSAEnumProtocolsA() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSAEnumProtocolsA")) == NULL) {
+           FATAL("cannot find entry WSAEnumProtocolsA (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2);
+}
+
+int   WINAPI
+WSAEnumProtocolsW(LPINT a0, LPWSAPROTOCOL_INFOW a1, LPDWORD a2)
+{
+    static int   (WINAPI *fp)(LPINT a0, LPWSAPROTOCOL_INFOW a1, LPDWORD a2);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSAEnumProtocolsW() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSAEnumProtocolsW")) == NULL) {
+           FATAL("cannot find entry WSAEnumProtocolsW (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2);
+}
+
+int   WINAPI
+WSAEventSelect(SOCKET a0, WSAEVENT a1, long a2)
+{
+    static int   (WINAPI *fp)(SOCKET a0, WSAEVENT a1, long a2);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSAEventSelect() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSAEventSelect")) == NULL) {
+           FATAL("cannot find entry WSAEventSelect (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2);
+}
+
+BOOL   WINAPI
+WSAGetOverlappedResult(SOCKET a0, LPWSAOVERLAPPED a1, LPDWORD a2, BOOL a3, LPDWORD a4)
+{
+    static BOOL   (WINAPI *fp)(SOCKET a0, LPWSAOVERLAPPED a1, LPDWORD a2, BOOL a3, LPDWORD a4);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSAGetOverlappedResult() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSAGetOverlappedResult")) == NULL) {
+           FATAL("cannot find entry WSAGetOverlappedResult (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3, a4);
+}
+
+BOOL   WINAPI
+WSAGetQOSByName(SOCKET a0, LPWSABUF a1, LPQOS a2)
+{
+    static BOOL   (WINAPI *fp)(SOCKET a0, LPWSABUF a1, LPQOS a2);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSAGetQOSByName() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSAGetQOSByName")) == NULL) {
+           FATAL("cannot find entry WSAGetQOSByName (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2);
+}
+
+INT   WINAPI
+WSAGetServiceClassInfoA(LPGUID a0, LPGUID a1, LPDWORD a2, LPWSASERVICECLASSINFOA a3)
+{
+    static INT   (WINAPI *fp)(LPGUID a0, LPGUID a1, LPDWORD a2, LPWSASERVICECLASSINFOA a3);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSAGetServiceClassInfoA() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSAGetServiceClassInfoA")) == NULL) {
+           FATAL("cannot find entry WSAGetServiceClassInfoA (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3);
+}
+
+INT   WINAPI
+WSAGetServiceClassInfoW(LPGUID a0, LPGUID a1, LPDWORD a2, LPWSASERVICECLASSINFOW a3)
+{
+    static INT   (WINAPI *fp)(LPGUID a0, LPGUID a1, LPDWORD a2, LPWSASERVICECLASSINFOW a3);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSAGetServiceClassInfoW() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSAGetServiceClassInfoW")) == NULL) {
+           FATAL("cannot find entry WSAGetServiceClassInfoW (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3);
+}
+
+INT   WINAPI
+WSAGetServiceClassNameByClassIdA(LPGUID a0, LPSTR a1, LPDWORD a2)
+{
+    static INT   (WINAPI *fp)(LPGUID a0, LPSTR a1, LPDWORD a2);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSAGetServiceClassNameByClassIdA() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSAGetServiceClassNameByClassIdA")) == NULL) {
+           FATAL("cannot find entry WSAGetServiceClassNameByClassIdA (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2);
+}
+
+INT   WINAPI
+WSAGetServiceClassNameByClassIdW(LPGUID a0, LPWSTR a1, LPDWORD a2)
+{
+    static INT   (WINAPI *fp)(LPGUID a0, LPWSTR a1, LPDWORD a2);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSAGetServiceClassNameByClassIdW() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSAGetServiceClassNameByClassIdW")) == NULL) {
+           FATAL("cannot find entry WSAGetServiceClassNameByClassIdW (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2);
+}
+
+int   WINAPI
+WSAHtonl(SOCKET a0, unsigned long a1, unsigned long * a2)
+{
+    static int   (WINAPI *fp)(SOCKET a0, unsigned long a1, unsigned long * a2);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSAHtonl() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSAHtonl")) == NULL) {
+           FATAL("cannot find entry WSAHtonl (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2);
+}
+
+int   WINAPI
+WSAHtons(SOCKET a0, unsigned short a1, unsigned short * a2)
+{
+    static int   (WINAPI *fp)(SOCKET a0, unsigned short a1, unsigned short * a2);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSAHtons() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSAHtons")) == NULL) {
+           FATAL("cannot find entry WSAHtons (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2);
+}
+
+INT   WINAPI
+WSAInstallServiceClassA(LPWSASERVICECLASSINFOA a0)
+{
+    static INT   (WINAPI *fp)(LPWSASERVICECLASSINFOA a0);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSAInstallServiceClassA() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSAInstallServiceClassA")) == NULL) {
+           FATAL("cannot find entry WSAInstallServiceClassA (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0);
+}
+
+INT   WINAPI
+WSAInstallServiceClassW(LPWSASERVICECLASSINFOW a0)
+{
+    static INT   (WINAPI *fp)(LPWSASERVICECLASSINFOW a0);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSAInstallServiceClassW() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSAInstallServiceClassW")) == NULL) {
+           FATAL("cannot find entry WSAInstallServiceClassW (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0);
+}
+
+int   WINAPI
+WSAIoctl(SOCKET a0, DWORD a1, LPVOID a2, DWORD a3, LPVOID a4, DWORD a5, LPDWORD a6, LPWSAOVERLAPPED a7, LPWSAOVERLAPPED_COMPLETION_ROUTINE a8)
+{
+    static int   (WINAPI *fp)(SOCKET a0, DWORD a1, LPVOID a2, DWORD a3, LPVOID a4, DWORD a5, LPDWORD a6, LPWSAOVERLAPPED a7, LPWSAOVERLAPPED_COMPLETION_ROUTINE a8);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSAIoctl() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSAIoctl")) == NULL) {
+           FATAL("cannot find entry WSAIoctl (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3, a4, a5, a6, a7, a8);
+}
+
+ struct hostent * PASCAL
+_org_gethostbyaddr(const char* a0, int a1, int a2)
+{
+    static  struct hostent * (PASCAL *fp)(const char* a0, int a1, int a2);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub _org_gethostbyaddr() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "gethostbyaddr")) == NULL) {
+           FATAL("cannot find entry gethostbyaddr (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2);
+}
+
+ struct hostent * PASCAL
+_org_gethostbyname(const char* a0)
+{
+    static  struct hostent * (PASCAL *fp)(const char* a0);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub _org_gethostbyname() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "gethostbyname")) == NULL) {
+           FATAL("cannot find entry gethostbyname (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0);
+}
+
+ struct protoent * PASCAL
+getprotobyname(const char* a0)
+{
+    static  struct protoent * (PASCAL *fp)(const char* a0);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub getprotobyname() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "getprotobyname")) == NULL) {
+           FATAL("cannot find entry getprotobyname (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0);
+}
+
+ struct protoent * PASCAL
+getprotobynumber(int a0)
+{
+    static  struct protoent * (PASCAL *fp)(int a0);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub getprotobynumber() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "getprotobynumber")) == NULL) {
+           FATAL("cannot find entry getprotobynumber (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0);
+}
+
+ struct servent * PASCAL
+getservbyname(const char* a0, const char* a1)
+{
+    static  struct servent * (PASCAL *fp)(const char* a0, const char* a1);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub getservbyname() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "getservbyname")) == NULL) {
+           FATAL("cannot find entry getservbyname (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1);
+}
+
+ struct servent * PASCAL
+getservbyport(int a0, const char* a1)
+{
+    static  struct servent * (PASCAL *fp)(int a0, const char* a1);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub getservbyport() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "getservbyport")) == NULL) {
+           FATAL("cannot find entry getservbyport (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1);
+}
+
+int   PASCAL
+_org_gethostname(char* a0, int a1)
+{
+    static int   (PASCAL *fp)(char* a0, int a1);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub _org_gethostname() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "gethostname")) == NULL) {
+           FATAL("cannot find entry gethostname (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1);
+}
+
+SOCKET   WINAPI
+WSAJoinLeaf(SOCKET a0, const struct sockaddr * a1, int a2, LPWSABUF a3, LPWSABUF a4, LPQOS a5, LPQOS a6, DWORD a7)
+{
+    static SOCKET   (WINAPI *fp)(SOCKET a0, const struct sockaddr * a1, int a2, LPWSABUF a3, LPWSABUF a4, LPQOS a5, LPQOS a6, DWORD a7);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSAJoinLeaf() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSAJoinLeaf")) == NULL) {
+           FATAL("cannot find entry WSAJoinLeaf (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3, a4, a5, a6, a7);
+}
+
+INT   WINAPI
+_org_WSALookupServiceBeginA(LPWSAQUERYSETA a0, DWORD a1, LPHANDLE a2)
+{
+    static INT   (WINAPI *fp)(LPWSAQUERYSETA a0, DWORD a1, LPHANDLE a2);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub _org_WSALookupServiceBeginA() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSALookupServiceBeginA")) == NULL) {
+           FATAL("cannot find entry WSALookupServiceBeginA (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2);
+}
+
+INT   WINAPI
+_org_WSALookupServiceBeginW(LPWSAQUERYSETW a0, DWORD a1, LPHANDLE a2)
+{
+    static INT   (WINAPI *fp)(LPWSAQUERYSETW a0, DWORD a1, LPHANDLE a2);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub _org_WSALookupServiceBeginW() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSALookupServiceBeginW")) == NULL) {
+           FATAL("cannot find entry WSALookupServiceBeginW (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2);
+}
+
+INT   WINAPI
+_org_WSALookupServiceEnd(HANDLE a0)
+{
+    static INT   (WINAPI *fp)(HANDLE a0);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub _org_WSALookupServiceEnd() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSALookupServiceEnd")) == NULL) {
+           FATAL("cannot find entry WSALookupServiceEnd (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0);
+}
+
+INT   WINAPI
+_org_WSALookupServiceNextA(HANDLE a0, DWORD a1, LPDWORD a2, LPWSAQUERYSETA a3)
+{
+    static INT   (WINAPI *fp)(HANDLE a0, DWORD a1, LPDWORD a2, LPWSAQUERYSETA a3);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub _org_WSALookupServiceNextA() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSALookupServiceNextA")) == NULL) {
+           FATAL("cannot find entry WSALookupServiceNextA (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3);
+}
+
+INT   WINAPI
+_org_WSALookupServiceNextW(HANDLE a0, DWORD a1, LPDWORD a2, LPWSAQUERYSETW a3)
+{
+    static INT   (WINAPI *fp)(HANDLE a0, DWORD a1, LPDWORD a2, LPWSAQUERYSETW a3);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub _org_WSALookupServiceNextW() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSALookupServiceNextW")) == NULL) {
+           FATAL("cannot find entry WSALookupServiceNextW (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3);
+}
+
+int   WINAPI
+WSANtohl(SOCKET a0, unsigned long a1, unsigned long * a2)
+{
+    static int   (WINAPI *fp)(SOCKET a0, unsigned long a1, unsigned long * a2);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSANtohl() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSANtohl")) == NULL) {
+           FATAL("cannot find entry WSANtohl (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2);
+}
+
+int   WINAPI
+WSANtohs(SOCKET a0, unsigned short a1, unsigned short * a2)
+{
+    static int   (WINAPI *fp)(SOCKET a0, unsigned short a1, unsigned short * a2);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSANtohs() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSANtohs")) == NULL) {
+           FATAL("cannot find entry WSANtohs (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2);
+}
+
+int   WSAAPI
+WSAProviderConfigChange(LPHANDLE a0, LPWSAOVERLAPPED a1, LPWSAOVERLAPPED_COMPLETION_ROUTINE a2)
+{
+    static int   (WSAAPI *fp)(LPHANDLE a0, LPWSAOVERLAPPED a1, LPWSAOVERLAPPED_COMPLETION_ROUTINE a2);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSAProviderConfigChange() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSAProviderConfigChange")) == NULL) {
+           FATAL("cannot find entry WSAProviderConfigChange (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2);
+}
+
+int   WINAPI
+WSARecv(SOCKET a0, LPWSABUF a1, DWORD a2, LPDWORD a3, LPDWORD a4, LPWSAOVERLAPPED a5, LPWSAOVERLAPPED_COMPLETION_ROUTINE a6)
+{
+    static int   (WINAPI *fp)(SOCKET a0, LPWSABUF a1, DWORD a2, LPDWORD a3, LPDWORD a4, LPWSAOVERLAPPED a5, LPWSAOVERLAPPED_COMPLETION_ROUTINE a6);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSARecv() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSARecv")) == NULL) {
+           FATAL("cannot find entry WSARecv (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3, a4, a5, a6);
+}
+
+int   WINAPI
+WSARecvDisconnect(SOCKET a0, LPWSABUF a1)
+{
+    static int   (WINAPI *fp)(SOCKET a0, LPWSABUF a1);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSARecvDisconnect() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSARecvDisconnect")) == NULL) {
+           FATAL("cannot find entry WSARecvDisconnect (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1);
+}
+
+int   WINAPI
+WSARecvFrom(SOCKET a0, LPWSABUF a1, DWORD a2, LPDWORD a3, LPDWORD a4, struct sockaddr * a5, LPINT a6, LPWSAOVERLAPPED a7, LPWSAOVERLAPPED_COMPLETION_ROUTINE a8)
+{
+    static int   (WINAPI *fp)(SOCKET a0, LPWSABUF a1, DWORD a2, LPDWORD a3, LPDWORD a4, struct sockaddr * a5, LPINT a6, LPWSAOVERLAPPED a7, LPWSAOVERLAPPED_COMPLETION_ROUTINE a8);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSARecvFrom() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSARecvFrom")) == NULL) {
+           FATAL("cannot find entry WSARecvFrom (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3, a4, a5, a6, a7, a8);
+}
+
+INT   WINAPI
+WSARemoveServiceClass(LPGUID a0)
+{
+    static INT   (WINAPI *fp)(LPGUID a0);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSARemoveServiceClass() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSARemoveServiceClass")) == NULL) {
+           FATAL("cannot find entry WSARemoveServiceClass (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0);
+}
+
+BOOL   WINAPI
+WSAResetEvent(WSAEVENT a0)
+{
+    static BOOL   (WINAPI *fp)(WSAEVENT a0);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSAResetEvent() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSAResetEvent")) == NULL) {
+           FATAL("cannot find entry WSAResetEvent (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0);
+}
+
+int   WINAPI
+WSASend(SOCKET a0, LPWSABUF a1, DWORD a2, LPDWORD a3, DWORD a4, LPWSAOVERLAPPED a5, LPWSAOVERLAPPED_COMPLETION_ROUTINE a6)
+{
+    static int   (WINAPI *fp)(SOCKET a0, LPWSABUF a1, DWORD a2, LPDWORD a3, DWORD a4, LPWSAOVERLAPPED a5, LPWSAOVERLAPPED_COMPLETION_ROUTINE a6);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSASend() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSASend")) == NULL) {
+           FATAL("cannot find entry WSASend (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3, a4, a5, a6);
+}
+
+int   WINAPI
+WSASendDisconnect(SOCKET a0, LPWSABUF a1)
+{
+    static int   (WINAPI *fp)(SOCKET a0, LPWSABUF a1);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSASendDisconnect() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSASendDisconnect")) == NULL) {
+           FATAL("cannot find entry WSASendDisconnect (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1);
+}
+
+int   WINAPI
+WSASendTo(SOCKET a0, LPWSABUF a1, DWORD a2, LPDWORD a3, DWORD a4, const struct sockaddr * a5, int a6, LPWSAOVERLAPPED a7, LPWSAOVERLAPPED_COMPLETION_ROUTINE a8)
+{
+    static int   (WINAPI *fp)(SOCKET a0, LPWSABUF a1, DWORD a2, LPDWORD a3, DWORD a4, const struct sockaddr * a5, int a6, LPWSAOVERLAPPED a7, LPWSAOVERLAPPED_COMPLETION_ROUTINE a8);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSASendTo() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSASendTo")) == NULL) {
+           FATAL("cannot find entry WSASendTo (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3, a4, a5, a6, a7, a8);
+}
+
+BOOL   WINAPI
+WSASetEvent(WSAEVENT a0)
+{
+    static BOOL   (WINAPI *fp)(WSAEVENT a0);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSASetEvent() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSASetEvent")) == NULL) {
+           FATAL("cannot find entry WSASetEvent (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0);
+}
+
+INT   WSAAPI
+WSASetServiceA(LPWSAQUERYSETA a0, WSAESETSERVICEOP a1, DWORD a2)
+{
+    static INT   (WSAAPI *fp)(LPWSAQUERYSETA a0, WSAESETSERVICEOP a1, DWORD a2);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSASetServiceA() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSASetServiceA")) == NULL) {
+           FATAL("cannot find entry WSASetServiceA (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2);
+}
+
+INT   WINAPI
+WSASetServiceW(LPWSAQUERYSETW a0, WSAESETSERVICEOP a1, DWORD a2)
+{
+    static INT   (WINAPI *fp)(LPWSAQUERYSETW a0, WSAESETSERVICEOP a1, DWORD a2);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSASetServiceW() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSASetServiceW")) == NULL) {
+           FATAL("cannot find entry WSASetServiceW (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2);
+}
+
+SOCKET   WINAPI
+WSASocketA(int a0, int a1, int a2, LPWSAPROTOCOL_INFOA a3, GROUP a4, DWORD a5)
+{
+    static SOCKET   (WINAPI *fp)(int a0, int a1, int a2, LPWSAPROTOCOL_INFOA a3, GROUP a4, DWORD a5);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSASocketA() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSASocketA")) == NULL) {
+           FATAL("cannot find entry WSASocketA (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3, a4, a5);
+}
+
+SOCKET   WINAPI
+WSASocketW(int a0, int a1, int a2, LPWSAPROTOCOL_INFOW a3, GROUP a4, DWORD a5)
+{
+    static SOCKET   (WINAPI *fp)(int a0, int a1, int a2, LPWSAPROTOCOL_INFOW a3, GROUP a4, DWORD a5);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSASocketW() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSASocketW")) == NULL) {
+           FATAL("cannot find entry WSASocketW (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3, a4, a5);
+}
+
+INT   WINAPI
+WSAStringToAddressA(LPSTR a0, INT a1, LPWSAPROTOCOL_INFOA a2, LPSOCKADDR a3, LPINT a4)
+{
+    static INT   (WINAPI *fp)(LPSTR a0, INT a1, LPWSAPROTOCOL_INFOA a2, LPSOCKADDR a3, LPINT a4);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSAStringToAddressA() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSAStringToAddressA")) == NULL) {
+           FATAL("cannot find entry WSAStringToAddressA (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3, a4);
+}
+
+INT   WINAPI
+WSAStringToAddressW(LPWSTR a0, INT a1, LPWSAPROTOCOL_INFOW a2, LPSOCKADDR a3, LPINT a4)
+{
+    static INT   (WINAPI *fp)(LPWSTR a0, INT a1, LPWSAPROTOCOL_INFOW a2, LPSOCKADDR a3, LPINT a4);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSAStringToAddressW() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSAStringToAddressW")) == NULL) {
+           FATAL("cannot find entry WSAStringToAddressW (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3, a4);
+}
+
+DWORD   WINAPI
+WSAWaitForMultipleEvents(DWORD a0, const WSAEVENT * a1, BOOL a2, DWORD a3, BOOL a4)
+{
+    static DWORD   (WINAPI *fp)(DWORD a0, const WSAEVENT * a1, BOOL a2, DWORD a3, BOOL a4);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSAWaitForMultipleEvents() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSAWaitForMultipleEvents")) == NULL) {
+           FATAL("cannot find entry WSAWaitForMultipleEvents (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3, a4);
+}
+
+int   WINAPI
+WSCDeinstallProvider(LPGUID a0, LPINT a1)
+{
+    static int   (WINAPI *fp)(LPGUID a0, LPINT a1);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSCDeinstallProvider() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSCDeinstallProvider")) == NULL) {
+           FATAL("cannot find entry WSCDeinstallProvider (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1);
+}
+
+int   WINAPI
+WSCEnableNSProvider(LPGUID a0, BOOL a1)
+{
+    static int   (WINAPI *fp)(LPGUID a0, BOOL a1);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSCEnableNSProvider() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSCEnableNSProvider")) == NULL) {
+           FATAL("cannot find entry WSCEnableNSProvider (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1);
+}
+
+int   WINAPI
+WSCEnumProtocols(LPINT a0, LPWSAPROTOCOL_INFOW a1, LPDWORD a2, LPINT a3)
+{
+    static int   (WINAPI *fp)(LPINT a0, LPWSAPROTOCOL_INFOW a1, LPDWORD a2, LPINT a3);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSCEnumProtocols() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSCEnumProtocols")) == NULL) {
+           FATAL("cannot find entry WSCEnumProtocols (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3);
+}
+
+int   WINAPI
+WSCGetProviderPath(LPGUID a0, LPWSTR a1, LPINT a2, LPINT a3)
+{
+    static int   (WINAPI *fp)(LPGUID a0, LPWSTR a1, LPINT a2, LPINT a3);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSCGetProviderPath() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSCGetProviderPath")) == NULL) {
+           FATAL("cannot find entry WSCGetProviderPath (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3);
+}
+
+int   WINAPI
+WSCInstallNameSpace(LPWSTR a0, LPWSTR a1, DWORD a2, DWORD a3, LPGUID a4)
+{
+    static int   (WINAPI *fp)(LPWSTR a0, LPWSTR a1, DWORD a2, DWORD a3, LPGUID a4);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSCInstallNameSpace() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSCInstallNameSpace")) == NULL) {
+           FATAL("cannot find entry WSCInstallNameSpace (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3, a4);
+}
+
+int   WINAPI
+WSCInstallProvider(const LPGUID a0, const LPWSTR a1, const LPWSAPROTOCOL_INFOW a2, DWORD a3, LPINT a4)
+{
+    static int   (WINAPI *fp)(const LPGUID a0, const LPWSTR a1, const LPWSAPROTOCOL_INFOW a2, DWORD a3, LPINT a4);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSCInstallProvider() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSCInstallProvider")) == NULL) {
+           FATAL("cannot find entry WSCInstallProvider (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3, a4);
+}
+
+int   WINAPI
+WSCUnInstallNameSpace(LPGUID a0)
+{
+    static int   (WINAPI *fp)(LPGUID a0);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSCUnInstallNameSpace() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSCUnInstallNameSpace")) == NULL) {
+           FATAL("cannot find entry WSCUnInstallNameSpace (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0);
+}
+
+int   PASCAL
+WSAAsyncSelect(SOCKET a0, HWND a1, u_int a2, long a3)
+{
+    static int   (PASCAL *fp)(SOCKET a0, HWND a1, u_int a2, long a3);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSAAsyncSelect() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSAAsyncSelect")) == NULL) {
+           FATAL("cannot find entry WSAAsyncSelect (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3);
+}
+
+HANDLE   PASCAL
+_org_WSAAsyncGetHostByAddr(HWND a0, u_int a1, const char* a2, int a3, int a4, char* a5, int a6)
+{
+    static HANDLE   (PASCAL *fp)(HWND a0, u_int a1, const char* a2, int a3, int a4, char* a5, int a6);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub _org_WSAAsyncGetHostByAddr() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSAAsyncGetHostByAddr")) == NULL) {
+           FATAL("cannot find entry WSAAsyncGetHostByAddr (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3, a4, a5, a6);
+}
+
+HANDLE   PASCAL
+_org_WSAAsyncGetHostByName(HWND a0, u_int a1, const char* a2, char* a3, int a4)
+{
+    static HANDLE   (PASCAL *fp)(HWND a0, u_int a1, const char* a2, char* a3, int a4);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub _org_WSAAsyncGetHostByName() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSAAsyncGetHostByName")) == NULL) {
+           FATAL("cannot find entry WSAAsyncGetHostByName (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3, a4);
+}
+
+HANDLE   PASCAL
+WSAAsyncGetProtoByNumber(HWND a0, u_int a1, int a2, char* a3, int a4)
+{
+    static HANDLE   (PASCAL *fp)(HWND a0, u_int a1, int a2, char* a3, int a4);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSAAsyncGetProtoByNumber() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSAAsyncGetProtoByNumber")) == NULL) {
+           FATAL("cannot find entry WSAAsyncGetProtoByNumber (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3, a4);
+}
+
+HANDLE   PASCAL
+WSAAsyncGetProtoByName(HWND a0, u_int a1, const char* a2, char* a3, int a4)
+{
+    static HANDLE   (PASCAL *fp)(HWND a0, u_int a1, const char* a2, char* a3, int a4);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSAAsyncGetProtoByName() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSAAsyncGetProtoByName")) == NULL) {
+           FATAL("cannot find entry WSAAsyncGetProtoByName (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3, a4);
+}
+
+HANDLE   PASCAL
+WSAAsyncGetServByPort(HWND a0, u_int a1, int a2, const char* a3, char* a4, int a5)
+{
+    static HANDLE   (PASCAL *fp)(HWND a0, u_int a1, int a2, const char* a3, char* a4, int a5);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSAAsyncGetServByPort() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSAAsyncGetServByPort")) == NULL) {
+           FATAL("cannot find entry WSAAsyncGetServByPort (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3, a4, a5);
+}
+
+HANDLE   PASCAL
+WSAAsyncGetServByName(HWND a0, u_int a1, const char* a2, const char* a3, char* a4, int a5)
+{
+    static HANDLE   (PASCAL *fp)(HWND a0, u_int a1, const char* a2, const char* a3, char* a4, int a5);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSAAsyncGetServByName() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSAAsyncGetServByName")) == NULL) {
+           FATAL("cannot find entry WSAAsyncGetServByName (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3, a4, a5);
+}
+
+int   PASCAL
+WSACancelAsyncRequest(HANDLE a0)
+{
+    static int   (PASCAL *fp)(HANDLE a0);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSACancelAsyncRequest() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSACancelAsyncRequest")) == NULL) {
+           FATAL("cannot find entry WSACancelAsyncRequest (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0);
+}
+
+FARPROC   PASCAL
+WSASetBlockingHook(FARPROC a0)
+{
+    static FARPROC   (PASCAL *fp)(FARPROC a0);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSASetBlockingHook() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSASetBlockingHook")) == NULL) {
+           FATAL("cannot find entry WSASetBlockingHook (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0);
+}
+
+int   PASCAL
+WSAUnhookBlockingHook(void)
+{
+    static int   (PASCAL *fp)(void);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSAUnhookBlockingHook() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSAUnhookBlockingHook")) == NULL) {
+           FATAL("cannot find entry WSAUnhookBlockingHook (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)();
+}
+
+int   PASCAL
+WSAGetLastError(void)
+{
+    static int   (PASCAL *fp)(void);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSAGetLastError() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSAGetLastError")) == NULL) {
+           FATAL("cannot find entry WSAGetLastError (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)();
+}
+
+void   PASCAL
+WSASetLastError(int a0)
+{
+    static void   (PASCAL *fp)(int a0);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSASetLastError() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSASetLastError")) == NULL) {
+           FATAL("cannot find entry WSASetLastError (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+     (*fp)(a0);
+}
+
+int   PASCAL
+WSACancelBlockingCall(void)
+{
+    static int   (PASCAL *fp)(void);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSACancelBlockingCall() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSACancelBlockingCall")) == NULL) {
+           FATAL("cannot find entry WSACancelBlockingCall (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)();
+}
+
+BOOL   PASCAL
+WSAIsBlocking(void)
+{
+    static BOOL   (PASCAL *fp)(void);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSAIsBlocking() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSAIsBlocking")) == NULL) {
+           FATAL("cannot find entry WSAIsBlocking (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)();
+}
+
+int   PASCAL
+WSAStartup(WORD a0, LPWSADATA a1)
+{
+    static int   (PASCAL *fp)(WORD a0, LPWSADATA a1);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSAStartup() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSAStartup")) == NULL) {
+           FATAL("cannot find entry WSAStartup (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1);
+}
+
+int   PASCAL
+WSACleanup(void)
+{
+    static int   (PASCAL *fp)(void);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSACleanup() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSACleanup")) == NULL) {
+           FATAL("cannot find entry WSACleanup (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)();
+}
+
+int   PASCAL
+__WSAFDIsSet(SOCKET a0, fd_set* a1)
+{
+    static int   (PASCAL *fp)(SOCKET a0, fd_set* a1);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub __WSAFDIsSet() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "__WSAFDIsSet")) == NULL) {
+           FATAL("cannot find entry __WSAFDIsSet (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1);
+}
+
+int  PASCAL
+WEP(void)
+{
+    static int  (PASCAL *fp)(void);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WEP() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WEP")) == NULL) {
+           FATAL("cannot find entry WEP (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)();
+}
+
+int  PASCAL
+WSCWriteNameSpaceOrder(int a0, int a1)
+{
+    static int  (PASCAL *fp)(int a0, int a1);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSCWriteNameSpaceOrder() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSCWriteNameSpaceOrder")) == NULL) {
+           FATAL("cannot find entry WSCWriteNameSpaceOrder (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1);
+}
+
+int   PASCAL
+WSCWriteProviderOrder(LPDWORD a0, DWORD a1)
+{
+    static int   (PASCAL *fp)(LPDWORD a0, DWORD a1);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSCWriteProviderOrder() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSCWriteProviderOrder")) == NULL) {
+           FATAL("cannot find entry WSCWriteProviderOrder (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1);
+}
+
+int   PASCAL
+WSANSPIoctl(HANDLE a0, DWORD a1, LPVOID a2, DWORD a3, LPVOID a4, DWORD a5, LPDWORD a6, LPVOID a7)
+{
+    static int   (PASCAL *fp)(HANDLE a0, DWORD a1, LPVOID a2, DWORD a3, LPVOID a4, DWORD a5, LPDWORD a6, LPVOID a7);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSANSPIoctl() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSANSPIoctl")) == NULL) {
+           FATAL("cannot find entry WSANSPIoctl (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3, a4, a5, a6, a7);
+}
+
+int   PASCAL
+WSCUpdateProvider(LPGUID a0, const WCHAR FAR* a1, const LPVOID a2, DWORD a3, LPINT a4)
+{
+    static int   (PASCAL *fp)(LPGUID a0, const WCHAR FAR* a1, const LPVOID a2, DWORD a3, LPINT a4);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub WSCUpdateProvider() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "WSCUpdateProvider")) == NULL) {
+           FATAL("cannot find entry WSCUpdateProvider (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3, a4);
+}
+
+int   PASCAL
+_org_getaddrinfo(const char* a0, const char* a1, LPVOID a2, LPVOID a3)
+{
+    static int   (PASCAL *fp)(const char* a0, const char* a1, LPVOID a2, LPVOID a3);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub _org_getaddrinfo() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "getaddrinfo")) == NULL) {
+           FATAL("cannot find entry getaddrinfo (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3);
+}
+
+void   PASCAL
+_org_freeaddrinfo(LPVOID a0)
+{
+    static void   (PASCAL *fp)(LPVOID a0);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub _org_freeaddrinfo() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "freeaddrinfo")) == NULL) {
+           FATAL("cannot find entry freeaddrinfo (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+     (*fp)(a0);
+}
+
+int   PASCAL
+_org_getnameinfo(LPVOID a0, DWORD a1, char* a2, DWORD a3, char* a4, DWORD a5, int a6)
+{
+    static int   (PASCAL *fp)(LPVOID a0, DWORD a1, char* a2, DWORD a3, char* a4, DWORD a5, int a6);
+
+#ifdef DEBUG_STUB
+    idnLogPrintf(idn_log_level_trace, "stub _org_getnameinfo() called\n");
+#endif
+    if (fp == NULL) {
+       void *p;
+       if ((p = GetProcAddress(DLLHANDLE, "getnameinfo")) == NULL) {
+           FATAL("cannot find entry getnameinfo (%d)\n", GetLastError());
+           abort();
+       }
+       fp = p;
+    }
+    return (*fp)(a0, a1, a2, a3, a4, a5, a6);
+}
+
diff --git a/contrib/idn/idnkit-1.0-src/wsock/wsock20/make.wnt b/contrib/idn/idnkit-1.0-src/wsock/wsock20/make.wnt
new file mode 100644 (file)
index 0000000..b5283aa
--- /dev/null
@@ -0,0 +1,97 @@
+#
+# Makefile for WinSock Wrapper (for WinSock 2.0)
+#
+
+# 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 <win32.mak>
+
+SYSLIBS = $(libcdll) kernel32.lib advapi32.lib user32.lib
+
+#
+# Files to use
+#
+
+HDRS = dlldef.h ..\common\wrapcommon.h
+SRCS = dllmain.c   dllload.obj dllfunc.c dllstub.c
+OBJS = dllmain.obj dllload.obj dllfunc.obj
+LIBS = ..\common\wrapcommon.lib ..\..\lib\idnkit.lib ..\..\win\iconv.lib
+
+cflags = $(cflags) -I..\..\include
+
+#
+# Targets to Build
+#
+
+TARGETS = ws2_32.dll
+
+all : $(TARGETS)
+
+ws2_32.dll : ws2_32.def $(OBJS) $(LIBS)
+       $(link) $(dlllflags) /OUT:ws2_32.dll /DEF:ws2_32.def $(OBJS) $(LIBS) $(SYSLIBS)
+
+install : $(TARGETS)
+       copy ws2_32.dll ..\bin
+
+clean : force
+       -del *.obj
+       -del *.lib
+       -del *.dll
+       -del *.exp
+
+#
+# Dependencies
+#
+
+dllmain.obj : dllmain.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -DDEBUG $*.c
+
+dllload.obj : dllload.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -DDEBUG $*.c
+
+dllfunc.obj : dllfunc.c dllstub.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -DDEBUG $*.c
+
+ws2_32o.lib : ws2_32o.def
+       LIB /DEF:ws2_32o.def /MACHINE:IX86
+
+force:
+
diff --git a/contrib/idn/idnkit-1.0-src/wsock/wsock20/ws2_32.def b/contrib/idn/idnkit-1.0-src/wsock/wsock20/ws2_32.def
new file mode 100644 (file)
index 0000000..ba9a44c
--- /dev/null
@@ -0,0 +1,120 @@
+;
+; Library Defition for idn wrapper's wrapper DLL
+;
+LIBRARY ws2_32
+DESCRIPTION "JPNIC idn warpper DLL for WS2_32"
+EXPORTS
+  accept                           @1
+  bind                             @2
+  closesocket                      @3
+  connect                          @4
+  getpeername                      @5
+  getsockname                      @6
+  getsockopt                       @7
+  htonl                            @8
+  htons                            @9
+  ioctlsocket                      @10
+  inet_addr                        @11
+  inet_ntoa                        @12
+  listen                           @13
+  ntohl                            @14
+  ntohs                            @15
+  recv                             @16
+  recvfrom                         @17
+  select                           @18
+  send                             @19
+  sendto                           @20
+  setsockopt                       @21
+  shutdown                         @22
+  socket                           @23
+  WSApSetPostRoutine               @24
+  WPUCompleteOverlappedRequest     @25
+  WSAAccept                        @26
+  WSAAddressToStringA              @27
+  WSAAddressToStringW              @28
+  WSACloseEvent                    @29
+  WSAConnect                       @30
+  WSACreateEvent                   @31
+  WSADuplicateSocketA              @32
+  WSADuplicateSocketW              @33
+  WSAEnumNameSpaceProvidersA       @34
+  WSAEnumNameSpaceProvidersW       @35
+  WSAEnumNetworkEvents             @36
+  WSAEnumProtocolsA                @37
+  WSAEnumProtocolsW                @38
+  WSAEventSelect                   @39
+  WSAGetOverlappedResult           @40
+  WSAGetQOSByName                  @41
+  WSAGetServiceClassInfoA          @42
+  WSAGetServiceClassInfoW          @43
+  WSAGetServiceClassNameByClassIdA @44
+  WSAGetServiceClassNameByClassIdW @45
+  WSAHtonl                         @46
+  WSAHtons                         @47
+  WSAInstallServiceClassA          @48
+  WSAInstallServiceClassW          @49
+  WSAIoctl                         @50
+  gethostbyaddr                    @51
+  gethostbyname                    @52
+  getprotobyname                   @53
+  getprotobynumber                 @54
+  getservbyname                    @55
+  getservbyport                    @56
+  gethostname                      @57
+  WSAJoinLeaf                      @58
+  WSALookupServiceBeginA           @59
+  WSALookupServiceBeginW           @60
+  WSALookupServiceEnd              @61
+  WSALookupServiceNextA            @62
+  WSALookupServiceNextW            @63
+  WSANtohl                         @64
+  WSANtohs                         @65
+  WSAProviderConfigChange          @66
+  WSARecv                          @67
+  WSARecvDisconnect                @68
+  WSARecvFrom                      @69
+  WSARemoveServiceClass            @70
+  WSAResetEvent                    @71
+  WSASend                          @72
+  WSASendDisconnect                @73
+  WSASendTo                        @74
+  WSASetEvent                      @75
+  WSASetServiceA                   @76
+  WSASetServiceW                   @77
+  WSASocketA                       @78
+  WSASocketW                       @79
+  WSAStringToAddressA              @80
+  WSAStringToAddressW              @81
+  WSAWaitForMultipleEvents         @82
+  WSCDeinstallProvider             @83
+  WSCEnableNSProvider              @84
+  WSCEnumProtocols                 @85
+  WSCGetProviderPath               @86
+  WSCInstallNameSpace              @87
+  WSCInstallProvider               @88
+  WSCUnInstallNameSpace            @89
+  WSCWriteNameSpaceOrder           @90
+  WSCWriteProviderOrder            @91
+  freeaddrinfo                     @94
+  getaddrinfo                      @95
+  getnameinfo                      @96
+  WSAAsyncSelect                   @101
+  WSAAsyncGetHostByAddr            @102
+  WSAAsyncGetHostByName            @103
+  WSAAsyncGetProtoByNumber         @104
+  WSAAsyncGetProtoByName           @105
+  WSAAsyncGetServByPort            @106
+  WSAAsyncGetServByName            @107
+  WSACancelAsyncRequest            @108
+  WSASetBlockingHook               @109
+  WSAUnhookBlockingHook            @110
+  WSAGetLastError                  @111
+  WSASetLastError                  @112
+  WSACancelBlockingCall            @113
+  WSAIsBlocking                    @114
+  WSAStartup                       @115
+  WSACleanup                       @116
+  __WSAFDIsSet                     @151
+  WEP                              @500
+  WSANSPIoctl                      @600
+  WSCUpdateProvider                @601