]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
JPNIC mDNkit 2.1 update
authorDavid Lawrence <source@isc.org>
Sat, 9 Jun 2001 00:30:55 +0000 (00:30 +0000)
committerDavid Lawrence <source@isc.org>
Sat, 9 Jun 2001 00:30:55 +0000 (00:30 +0000)
168 files changed:
contrib/idn/mdnkit/ChangeLog
contrib/idn/mdnkit/Makefile.in
contrib/idn/mdnkit/NEWS
contrib/idn/mdnkit/README
contrib/idn/mdnkit/README.ja
contrib/idn/mdnkit/acconfig.h
contrib/idn/mdnkit/aclocal.m4
contrib/idn/mdnkit/configure
contrib/idn/mdnkit/configure.in
contrib/idn/mdnkit/dnsproxy/dnsproxy.conf.sample [deleted file]
contrib/idn/mdnkit/dnsproxy/logging.c [deleted file]
contrib/idn/mdnkit/dnsproxy/translate.c [deleted file]
contrib/idn/mdnkit/include/Makefile.in
contrib/idn/mdnkit/include/config.h.in
contrib/idn/mdnkit/include/mdn/Makefile.in
contrib/idn/mdnkit/include/mdn/ace.h [new file with mode: 0644]
contrib/idn/mdnkit/include/mdn/altdude.h [new file with mode: 0644]
contrib/idn/mdnkit/include/mdn/amcacem.h [moved from contrib/idn/mdnkit/include/mdn/translator.h with 65% similarity]
contrib/idn/mdnkit/include/mdn/amcaceo.h [new file with mode: 0644]
contrib/idn/mdnkit/include/mdn/amcacer.h [new file with mode: 0644]
contrib/idn/mdnkit/include/mdn/api.h [new file with mode: 0644]
contrib/idn/mdnkit/include/mdn/brace.h
contrib/idn/mdnkit/include/mdn/checker.h [new file with mode: 0644]
contrib/idn/mdnkit/include/mdn/converter.h
contrib/idn/mdnkit/include/mdn/delimitermap.h [new file with mode: 0644]
contrib/idn/mdnkit/include/mdn/dude.h [new file with mode: 0644]
contrib/idn/mdnkit/include/mdn/filechecker.h [new file with mode: 0644]
contrib/idn/mdnkit/include/mdn/filemapper.h [new file with mode: 0644]
contrib/idn/mdnkit/include/mdn/lace.h
contrib/idn/mdnkit/include/mdn/mapper.h [new file with mode: 0644]
contrib/idn/mdnkit/include/mdn/mapselector.h [new file with mode: 0644]
contrib/idn/mdnkit/include/mdn/msgtrans.h
contrib/idn/mdnkit/include/mdn/nameprep.h [new file with mode: 0644]
contrib/idn/mdnkit/include/mdn/normalizer.h
contrib/idn/mdnkit/include/mdn/race.h
contrib/idn/mdnkit/include/mdn/res.h
contrib/idn/mdnkit/include/mdn/resconf.h
contrib/idn/mdnkit/include/mdn/result.h
contrib/idn/mdnkit/include/mdn/ucsmap.h [new file with mode: 0644]
contrib/idn/mdnkit/include/mdn/ucsset.h [new file with mode: 0644]
contrib/idn/mdnkit/include/mdn/unicode.h
contrib/idn/mdnkit/include/mdn/utf6.h [moved from contrib/idn/mdnkit/include/mdn/zldrule.h with 66% similarity]
contrib/idn/mdnkit/include/mdn/util.h
contrib/idn/mdnkit/include/mdn/version.h [new file with mode: 0644]
contrib/idn/mdnkit/lib/Makefile.in
contrib/idn/mdnkit/lib/README [deleted file]
contrib/idn/mdnkit/lib/ace.c [new file with mode: 0644]
contrib/idn/mdnkit/lib/altdude.c [new file with mode: 0644]
contrib/idn/mdnkit/lib/amcacem.c [new file with mode: 0644]
contrib/idn/mdnkit/lib/amcaceo.c [new file with mode: 0644]
contrib/idn/mdnkit/lib/amcacer.c [new file with mode: 0644]
contrib/idn/mdnkit/lib/api.c [new file with mode: 0644]
contrib/idn/mdnkit/lib/brace.c
contrib/idn/mdnkit/lib/checker.c [new file with mode: 0644]
contrib/idn/mdnkit/lib/converter.c
contrib/idn/mdnkit/lib/delimitermap.c [new file with mode: 0644]
contrib/idn/mdnkit/lib/dude.c [new file with mode: 0644]
contrib/idn/mdnkit/lib/filechecker.c [new file with mode: 0644]
contrib/idn/mdnkit/lib/filemapper.c [new file with mode: 0644]
contrib/idn/mdnkit/lib/lace.c
contrib/idn/mdnkit/lib/make.wnt [new file with mode: 0644]
contrib/idn/mdnkit/lib/mapper.c [new file with mode: 0644]
contrib/idn/mdnkit/lib/mapselector.c [new file with mode: 0644]
contrib/idn/mdnkit/lib/mdn.conf.sample.in [new file with mode: 0644]
contrib/idn/mdnkit/lib/mdnres.conf.sample [deleted file]
contrib/idn/mdnkit/lib/msgtrans.c
contrib/idn/mdnkit/lib/nameprep.c [new file with mode: 0644]
contrib/idn/mdnkit/lib/nameprep_template.c [new file with mode: 0644]
contrib/idn/mdnkit/lib/nameprepdata.c [new file with mode: 0644]
contrib/idn/mdnkit/lib/normalizer.c
contrib/idn/mdnkit/lib/race.c
contrib/idn/mdnkit/lib/res.c
contrib/idn/mdnkit/lib/resconf.c
contrib/idn/mdnkit/lib/result.c
contrib/idn/mdnkit/lib/selectiveencode.c
contrib/idn/mdnkit/lib/translator.c [deleted file]
contrib/idn/mdnkit/lib/ucsmap.c [new file with mode: 0644]
contrib/idn/mdnkit/lib/ucsset.c [new file with mode: 0644]
contrib/idn/mdnkit/lib/unicode.c
contrib/idn/mdnkit/lib/unicodedata.c
contrib/idn/mdnkit/lib/utf6.c [new file with mode: 0644]
contrib/idn/mdnkit/lib/util.c
contrib/idn/mdnkit/lib/version.c [new file with mode: 0644]
contrib/idn/mdnkit/lib/zldrule.c [deleted file]
contrib/idn/mdnkit/libtool [deleted file]
contrib/idn/mdnkit/ltconfig
contrib/idn/mdnkit/make.wnt [new file with mode: 0644]
contrib/idn/mdnkit/man/Makefile.in
contrib/idn/mdnkit/man/libmdn.3.in [new file with mode: 0644]
contrib/idn/mdnkit/man/mdn.conf.5.in [new file with mode: 0644]
contrib/idn/mdnkit/man/mdnres.conf.5.in [deleted file]
contrib/idn/mdnkit/map/Makefile.in [new file with mode: 0644]
contrib/idn/mdnkit/map/jp.map [new file with mode: 0644]
contrib/idn/mdnkit/mdnsproxy/Makefile.in [moved from contrib/idn/mdnkit/dnsproxy/Makefile.in with 74% similarity]
contrib/idn/mdnkit/mdnsproxy/acl.c [new file with mode: 0644]
contrib/idn/mdnkit/mdnsproxy/logging.c [new file with mode: 0644]
contrib/idn/mdnkit/mdnsproxy/make.wnt [new file with mode: 0644]
contrib/idn/mdnkit/mdnsproxy/mdnsproxy.8.in [moved from contrib/idn/mdnkit/dnsproxy/dnsproxy.8.in with 66% similarity]
contrib/idn/mdnkit/mdnsproxy/mdnsproxy.conf.sample [new file with mode: 0644]
contrib/idn/mdnkit/mdnsproxy/mdnsproxy.def [moved from contrib/idn/mdnkit/dnsproxy/dnsproxy.def with 100% similarity]
contrib/idn/mdnkit/mdnsproxy/mdnsproxy.h [moved from contrib/idn/mdnkit/dnsproxy/dnsproxy.h with 90% similarity]
contrib/idn/mdnkit/mdnsproxy/message.c [moved from contrib/idn/mdnkit/dnsproxy/message.c with 99% similarity]
contrib/idn/mdnkit/mdnsproxy/os2main.c [moved from contrib/idn/mdnkit/dnsproxy/os2main.c with 83% similarity]
contrib/idn/mdnkit/mdnsproxy/proxycnf.c [moved from contrib/idn/mdnkit/dnsproxy/proxycnf.c with 70% similarity]
contrib/idn/mdnkit/mdnsproxy/proxycnf.h [moved from contrib/idn/mdnkit/dnsproxy/proxycnf.h with 77% similarity]
contrib/idn/mdnkit/mdnsproxy/server.c [moved from contrib/idn/mdnkit/dnsproxy/server.c with 93% similarity]
contrib/idn/mdnkit/mdnsproxy/translate.c [new file with mode: 0644]
contrib/idn/mdnkit/mdnsproxy/unxmain.c [moved from contrib/idn/mdnkit/dnsproxy/unxmain.c with 74% similarity]
contrib/idn/mdnkit/mdnsproxy/winmain.c [moved from contrib/idn/mdnkit/dnsproxy/winmain.c with 95% similarity]
contrib/idn/mdnkit/mdnsproxy/winserv.c [moved from contrib/idn/mdnkit/dnsproxy/winserv.c with 97% similarity]
contrib/idn/mdnkit/mdnsproxy/winserv.h [moved from contrib/idn/mdnkit/dnsproxy/winserv.h with 98% similarity]
contrib/idn/mdnkit/mkinstalldirs [new file with mode: 0644]
contrib/idn/mdnkit/patch/bind8/bind-8.2.3-patch [new file with mode: 0644]
contrib/idn/mdnkit/patch/bind9/bind-9.1.2-patch [new file with mode: 0644]
contrib/idn/mdnkit/patch/libiconv/libiconv-1.6.1.patch [new file with mode: 0644]
contrib/idn/mdnkit/patch/squid/squid-2.4.STABLE1-patch [new file with mode: 0644]
contrib/idn/mdnkit/tools/Makefile.in
contrib/idn/mdnkit/tools/mdnconv/Makefile.in
contrib/idn/mdnkit/tools/mdnconv/README.ja [deleted file]
contrib/idn/mdnkit/tools/mdnconv/mdnconv.1
contrib/idn/mdnkit/tools/mdnconv/mdnconv.c
contrib/idn/mdnkit/tools/mdnconv/util.c
contrib/idn/mdnkit/tools/mdnconv/util.h
contrib/idn/mdnkit/tools/rpm/mdnkit.spec
contrib/idn/mdnkit/tools/rpm/mdnsproxy.init [moved from contrib/idn/mdnkit/tools/rpm/dnsproxy.init with 55% similarity]
contrib/idn/mdnkit/tools/runmdn/Makefile.in
contrib/idn/mdnkit/tools/runmdn/ns_name.c [deleted file]
contrib/idn/mdnkit/tools/runmdn/res_comp.c [deleted file]
contrib/idn/mdnkit/tools/runmdn/resolver.c [new file with mode: 0644]
contrib/idn/mdnkit/tools/runmdn/runmdn.1
contrib/idn/mdnkit/tools/runmdn/stub.c [new file with mode: 0644]
contrib/idn/mdnkit/tools/runmdn/stub.h [new file with mode: 0644]
contrib/idn/mdnkit/util/SparseMap.pm [new file with mode: 0644]
contrib/idn/mdnkit/util/UCD.pm [new file with mode: 0644]
contrib/idn/mdnkit/util/generate_nameprep_data.pl [new file with mode: 0644]
contrib/idn/mdnkit/util/generate_normalize_data.pl
contrib/idn/mdnkit/win/README.WIN [new file with mode: 0644]
contrib/idn/mdnkit/wsock/README.txt [new file with mode: 0644]
contrib/idn/mdnkit/wsock/README_j.txt [new file with mode: 0644]
contrib/idn/mdnkit/wsock/common/checkdll.c [new file with mode: 0644]
contrib/idn/mdnkit/wsock/common/convert.c [new file with mode: 0644]
contrib/idn/mdnkit/wsock/common/dllmain.c [new file with mode: 0644]
contrib/idn/mdnkit/wsock/common/dump.c [new file with mode: 0644]
contrib/idn/mdnkit/wsock/common/encoding.c [new file with mode: 0644]
contrib/idn/mdnkit/wsock/common/hook.c [new file with mode: 0644]
contrib/idn/mdnkit/wsock/common/jpnicmdn.def [new file with mode: 0644]
contrib/idn/mdnkit/wsock/common/jpnicmdn.h [new file with mode: 0644]
contrib/idn/mdnkit/wsock/common/make.wnt [new file with mode: 0644]
contrib/idn/mdnkit/wsock/common/printf.c [new file with mode: 0644]
contrib/idn/mdnkit/wsock/config/make.wnt [new file with mode: 0644]
contrib/idn/mdnkit/wsock/config/mdnconf.tcl [new file with mode: 0644]
contrib/idn/mdnkit/wsock/make.wnt [new file with mode: 0644]
contrib/idn/mdnkit/wsock/wsock11/dlldef.h [new file with mode: 0644]
contrib/idn/mdnkit/wsock/wsock11/dllfunc.c [new file with mode: 0644]
contrib/idn/mdnkit/wsock/wsock11/dllload.c [new file with mode: 0644]
contrib/idn/mdnkit/wsock/wsock11/dllmain.c [new file with mode: 0644]
contrib/idn/mdnkit/wsock/wsock11/dllstub.c [new file with mode: 0644]
contrib/idn/mdnkit/wsock/wsock11/make.wnt [new file with mode: 0644]
contrib/idn/mdnkit/wsock/wsock11/wsock32.def [new file with mode: 0644]
contrib/idn/mdnkit/wsock/wsock11/wsock32o.def [new file with mode: 0644]
contrib/idn/mdnkit/wsock/wsock20/dlldef.h [moved from contrib/idn/mdnkit/include/config.h with 61% similarity]
contrib/idn/mdnkit/wsock/wsock20/dllfunc.c [new file with mode: 0644]
contrib/idn/mdnkit/wsock/wsock20/dllload.c [moved from contrib/idn/mdnkit/include/config.h.os2 with 80% similarity]
contrib/idn/mdnkit/wsock/wsock20/dllmain.c [new file with mode: 0644]
contrib/idn/mdnkit/wsock/wsock20/dllstub.c [new file with mode: 0644]
contrib/idn/mdnkit/wsock/wsock20/make.wnt [new file with mode: 0644]
contrib/idn/mdnkit/wsock/wsock20/ws2_32.def [new file with mode: 0644]
contrib/idn/mdnkit/wsock/wsock20/ws2_32o.def [new file with mode: 0644]

index bee2fffd383992c6a1effb330247cf435c6503e8..2c7f660bb18d9753aca3629a233ea68c3486dad6 100644 (file)
@@ -1,3 +1,874 @@
+2001-06-01
+       * 2.1 release.
+
+       * patch/libiconv/libiconv-1.6.1.patch: created.  this patch fixes
+       a bug in ltconfig included in libiconv-1.6.1 distribution.  similar
+       fix is already incorporated in mDNkit (see 2001-05-21 entry).
+       * DISTFILES: add above file to the distribution list.
+       * README, README.ja: add note for the libiconv patch.
+       * tools/rpm/mdnkit.spec: update for 2.1 release.
+       * include/mdn/version.h: set MDNKIT_VERSION to `2.1'.
+
+2001-05-31
+       * lib/normalizer.c: create a new typedef for the function pointer
+       used in normalizer_unicode_caseconv() with argument prototype
+       so that compiler can detect argument mismatch.
+       * lib/selectiveencode.c, lib/util.c: include <mdn/selectiveencode.h>
+       and <mdn/util.h> respectively, which should obviously have been
+       included.
+       * mdnsproxy/logging.c: make log_strtofacility() static.
+       * mdnsproxy/mdnsproxy.h: add declaration of translate_finish().
+       * mdnsproxy/Makefile.in: remove extra `/' from CONFIG_PATH.  just
+       a cosmetic change.
+
+2001-05-30
+       * lib/normalizer.c: fix a bug in normalizer_unicode_caseconv().
+       It might pass a pointer of incompatible sized object to
+       mdn__unicode_toupper().
+
+2001-05-21
+       * 2.1beta2 release.
+
+       * ltconfig: fix a bug that caused runtime link error in NetBSD 1.5.
+       * include/mdn/version.h: set MDNKIT_VERSION to `2.1beta2'.
+
+       * patch/bind9/bind-9.1.2-patch: created.
+       * DISTFILES: replace patch/bind9/bind-9.1.1-patch with the above
+       file.
+
+2001-05-18
+       * configure.in: fix a bug that makes --with-logdir option ignored.
+       * configure.in: add --with-preference option to specify preference
+       of the default configuration.
+       * configure: rebuilt.
+       * lib/mdn.conf.sample.in: add configuration data for preference "jp".
+       * lib/Makefile.in: tailor mdn.conf.sample to the preference.
+       install default mdn.conf (if not exists) when a preference is
+       specified.
+       * README, README.ja: add description on --with-preference.
+       * tools/mdnconv/mdnconv.c: provide single character options
+       (such as -i) for frequently used ones.
+       * tools/mdnconv/mdnconv.1: list those options.
+       * tools/mdnconv/mdnconv.c: assume -reverse option if the command
+       name begins with `r' (like `rmdnconv').
+
+2001-05-15
+       * man/libmdn.3.in: created.
+       * man/Makefile.in: generate and install libmdn.3 from libmdn.3.in.
+       * DISTFILES: add man/libmdn.3.in to the distribution list.
+       * lib/res.c: make sure convesion actually takes place when 
+       converting from alternate encoding to utf8.
+
+2001-05-10
+       * make.os2, include/config.h.os2, lib/make.os2, mdnsproxy/make.os2:
+       removed, since they are no longer maintained.
+       * win/iconv.dll, win/iconv.h, win/iconv.lib: removed, since
+       it is easy to create them using libiconv and VC++.
+       * DISTFILES: delete above files from the distribution.
+       * win/README.WIN: update description appropriately.
+
+2001-05-07
+       * mdnsproxy/mdnsproxy.8.in: fix typo in FILES.
+       * lib/Makefile.in: ignore exit status of a command sequence
+       combined with `&&' so that `make install' correctly works
+       when `--disable-static' option is specified to `configure'.
+       * wsock/README.txt, wsock/README_j.txt: change `dnsproxy' to
+       `mdnsproxy'.
+
+2001-05-02
+       * patch/squid/squid-2.4.STABLE1-patch: created.
+       * DISTFILES: replace squid-2.3.STABLE3-patch with the above one.
+       * README, README.ja: update squid patch version.
+
+2001-04-26
+       * patch/bind9/bind-9.1.1-patch: clean up and remove unnecessary
+       modifications.
+
+2001-04-24
+       * 2.1beta1 release.
+
+       * lib/mapselector.c: fix TLD-mapping routine so that domain
+       name like `foo.' is not recognized as a local domain name.
+       * lib/mdn.conf.sample.in: revise comments on local-map entry.
+       * man/mdn.conf.5.in: add description on the special
+       TLD patterns `-' and `.' in local-map entry.
+
+       * include/mdn/version.h: Set MDNKIT_VERSION to `2.1beta1'.
+
+       * tools/rpm/mdnkit.spec: Set version to `2.1', and serial to
+       `2001042501'.
+
+2001-04-23
+       * tools/runmdn/runmdn.1: add a note on guessing local codeset.
+
+       * mdnsproxy/proxycnf.h, mdnsproxy/unxmain.c: implement
+       `-version' option.
+       * mdnsproxy/mdnsproxy.8.in: add description of `-version'
+       option.
+
+2001-04-20
+       * include/mdn/version.h, lib/version.c: created.  implement
+       `mdn_version_getstring()'.
+       * include/mdn/util.h, lib/util.c: remove `mdn_get_version()'.
+       * lib/Makefile.in, lib/make.wnt, tools/runmdn/Makefile.in:
+       add `version.c' to the source file list.
+       * tools/mdnconv/mdnconv.c: replace `mdn_get_version()' with
+       `mdn_version_getstring()'.  print both mdnconv's version and
+       library version.
+       * DISTFILES: add `lib/version.c' to the distribution list.
+
+       * wsock/config/mdnconf.tcl: display the name of the program and
+       its version at the top of the window.
+       * wsock/common/convert.c: log the version number if the log level
+       is `info' or higher.
+       * wsock/common/jpnicmdn.h: include <mdn/version.h> for getting
+       version string.
+       * wsock/common/encoding.c: do not create unnecessary registry
+       keys.
+
+       * tools/mdnconv/mdnconv.1: add description on `-version' option.
+
+       * tools/runmdn/stub.h: fix typo.
+       
+       * mdnsproxy/logging.c: fix a bug that mdnsproxy doesn't output 
+       libmdn log message to log file.
+       * mdnsproxy/logging.c: output version information to the log.
+
+       * configure.in: substitute @LIBDL@ to -ldl if libdl exists.
+       * configure: rebuilt.
+       * tools/runmdn/Makefile.in: add @LIBDL@ to the dependency
+       library for libmdnresolv, so that dlopen is available when
+       libmdnresolv is loaded.
+       
+       * README, README.ja: update for version 2.1.
+
+2001-04-19
+       * DISTFILES: Add `patch/bind9/bind-9.1.1-patch'.
+
+       * aclocal.m4: add AC_ACE_PREFIX, AC_ACE_SUFFIX, AC_ACE_SIGNATURE
+       macro for dealing with ACE signature options.
+       * configure.in: use the above macro.  add new options
+       `--with-utf-6-prefix', `--with-dude-prefix', `--with-altdude-prefix',
+       `--with-altdude-suffix', `--with-amc-ace-m-prefix',
+       `--with-amc-ace-m-suffix', `--with-amc-ace-o-prefix',
+       `--with-amc-ace-o-suffix' and `--with-amc-ace-r-prefix'.
+       * README, README.ja: add description for these options.
+       * configure, include/config.h.in: rebuilt.
+
+       * lib/filechecker.c: relax the setfile syntax check so that
+       lines like `XXXX;' becomes valid.
+       * tools/mdnconv/mdnconv.c: fix a bug in parsing `-alias' option.
+
+2001-04-18
+       * configure.in: check the type of the 2nd argument of gethostbyaddr,
+       which is either `int' or `size_t' depending on your system,
+       and define `GHBA_ADDRLEN_T' appropriately.
+       * acconfig.h: add `GHBA_ADDRLEN_T'.
+       * configure, include/config.h.in: rebuilt.
+       * tools/runmdn/resolver.c, tools/runmdn/stub.c, tools/runmdn/stub.h:
+       make use of `GHBA_ADDRLEN_T'.
+
+2001-04-17
+       * lib/converter.c: incorporate AltDUDE, AMC-ACE-{M,O,R} with
+       normal configuration.
+       * lib/mak.wnt: add altdude.c, amcace{m,o,r}.c.
+       * man/mdn.conf.5.in, tools/mdnconv/mdnconv.1,lib/mdn.conf.sample.in:
+       add AltDUDE, AMC-ACE-{M,O,R} to the list of available encodings.
+
+       * include/mdn/version.h.in, include/mdn/version.h: delete
+       `include/mdn/version.h.in' and instead add `include/mdn/version.h'.
+       * DISTFILES: likewise.
+       * configure.in: delete definition of VERSION, PREV_VERSION and
+       PREV_TAG.
+       * Makefile.in: get version number from `include/mdn/version.h',
+       when making a source package.
+       * Makefile.in: delete the `patch' rule.
+
+       * lib/util.c: include <mdn/version.h>.
+       get version number from the cpp macro `MDNKIT_VERSION', not `VERSION'.
+
+       * configure.in: check existance of gethostbyname2_r.  check
+       the flavor of gethostbyXXX_r functions.  define
+       GETHOST_R_GLIBC_FLAVOR if the flavor is glibc.
+       * acconfig.h: add GETHOST_R_GLIBC_FLAVOR.
+       * configure, include/config.h.in: rebuilt.
+       * tools/runmdn/resolver.c, tools/runmdn/stub.c: support glibc
+       style gethostXXX_r functions.
+       * tools/runmdn/runmdn.1: add gethostbyname2_r to the list of
+       functions replaced by runmdn.
+
+       * lib/amcacer.c: change the default ACE signature of AMC-ACE-R
+       from suffix (-amc3) to prefix (amc3-) in order for the converted
+       names not to begin with a hyphen.
+
+       * tools/runmdn/resolver.c: include <errno.h>.
+       * tools/runmdn/stub.c: ditto.
+       * tools/runmdn/stub.h: add declaration of mdn_stub_gethostbyname_r(),
+       mdn_stub_gethostbyname2_r() and mdn_stub_gethostbyaddr_r() for glibc.
+
+2001-04-16
+       * lib/delimitermap.c: not to use the ucsset module to simplify
+       API for the Perl modules.
+
+       * tools/mdnconv/util.c: fix the number of arguments passed to
+       errormsg().
+
+       * configure.in: define VERSION, PREV_VERSION and PREV_TAG.
+       * Makefile.in: refer to @VERSION@, @PREV_VERSION@ and @PREV_TAG@.
+       * lib/util.c, include/mdn/util.h: add mdn_get_version().
+       * tools/mdnconv/mdnconv.c: add `-version' option.
+
+       * include/mdn/version.h.in: new file.
+       * include/mdn/Makefile.in: add version.h to HDRS.
+       * DISTFILES: add include/mdn/version.h.in.
+       * configure.in: add include/mdn/version.h to AC_OUTPUT.
+       * configure.in: get MAJOR_VERSION and MINOR_VERSION from VERSION,
+       and substitute them using AC_SUBST.
+
+2001-04-13
+       * tools/runmdn/resolver.c: increase static buffer size.
+       better error handling.  add comments.
+       * configure.in: use space character for the separator in
+       LD_PRELOAD on linux.
+       * wsock/wsock11/dllstub.c, wsock/wsock20/dllstub.c: disable
+       outputing trace messages unless DEBUG_STUB is defined.
+
+2001-04-11
+       * tools/mdnconv/mdnconv.c: fix a bug in parsing an argument to
+       -delimitermap option.
+
+       * lib/resoconf.c: mdn_resconf_setlocalconverter() rejects NULL
+       encoding name.  fixed.
+
+2001-04-10
+       * tools/runmdn/resolver.c: fix bugs in wrappers for
+       getipnodebyname() and getipnodebyaddr().
+       * tools/mdnconv/mdnconv.c: fix a bug that makes -reverse
+       operation (decoding) sometimes fail.
+
+2001-04-06
+       * include/mdn/amcaceo.h, lib/amcaceo.c: created.  implement
+       "AMC-ACE-O".
+       * DISTFILES: add above new files.
+       * include/mdn/Makefile.in, lib/Makefile.in: ditto.
+       * lib/converter.c: add new converter for "AMC-ACE-O".
+       * lib/amcacer.c: rewrite refpoint update routine so that it's
+       easier to understand.
+       * include/mdn/api.h: fix incorrect comment for mdn_decodename.
+       * mdnsproxy/translate.c: remove obsolete functions.
+       * tools/runmdn/resolver.c: created.  implement resolver API
+       (such as gethostbyname) with MDN capability.
+       * tools/runmdn/stub.c, tools/runmdn/stub.h: created.  provide
+       stub functions for calling orginal resolver API functions.
+       * tools/runmdn/res_comp.c, tools/runmdn/ns_name.c: removed.
+       * tools/runmdn/Makefile.in: change to use above new files.
+       * tools/runmdn/runmdn.1: revised.
+       * configure.in, acconfig.h: add new tests for checking the
+       existance of various resolver functions/libraries.
+       * aclocal.m4: add a new macro to find the pathname of a shared
+       library object.
+       * configure, include/config.h.in: updated.
+       * DISTFILES, tools/Makefile.in: bring back runmdn.
+
+2001-04-04
+       * 2.0.1 release.
+
+       * mdnsproxy/Makefile.in: fix typo.
+       * lib/amcacem.c: fix a bug in computing a reference code point for
+       compression.
+
+       * DISTFILES: rename tools/rpm/dnsproxy.init to
+       tools/rpm/mdnsproxy.init.
+
+2001-03-30
+       * 2.0 release.
+       * include/mdn/amcacem.h, lib/amcacem.c: created.  implement a
+       new ACE called "AMC-ACE-M".
+       * include/mdn/amcacer.h, lib/amcacer.c: created.  implement a
+       new ACE called "AMC-ACE-R".
+       * DISTFILES: add above new files.
+       * include/mdn/Makefile.in, lib/Makefile.in, tools/runmdn/Makefile.in:
+       add above new files.
+       * lib/converter.c: add new converters for "AMC-ACE-M" and "AMC-ACE-R".
+       
+2001-03-28
+       * Makefile.in, include/mdn/Makefile.in, man/Makefile.in,
+       map/Makefile.in, tools/Makefile.in: define SHELL.
+
+       * include/mdn/Makefile.in, lib/Makefile.in, man/Makefile.in,
+       man/mdn.conf.5.in tools/Makefile.in, tools/mdnconv/Makefile.in:
+       unify variable names for install directory.
+
+       * lib/Makefile.in: generate mdn.conf.sample from mdn.conf.sample.in.
+       * DISTFILES: distribute mdn.conf.sample.in, not mdn.conf.sample.
+
+       * lib/lace.c: Set max run-length to 254.
+       * lib/autdude.c: fix decoding bug.
+
+       * lib/res.c: fix a bug that nameconv("m") cannot map a domain name
+       which ends with ".".
+
+2001-03-27
+       * tools/mdnconv/mdnconv.c: fix help message.
+
+       * mdnsproxy/logging.c: don't reopen syslog when receives SIGHUP.
+
+2001-03-26
+       * 2.0beta3 release.
+
+       * Makefile.in: set CUR_VERSION to 2.0beta3.
+
+       * configure.in: remove --enable-zld option because ZLD is no longer
+       supported, and add --enable-extra-ace option to incorporate
+       undocumented extra ACE converters.
+       * include/mdn/dude.h, lib/dude.c: change slightly to conform to
+       -01 draft.
+       * include/mdn/altdude.h, lib/altdude.c: created.  implement a new
+       ACE called "AltDUDE".
+       * include/mdn/Makefile.in, lib/Makefile.in, tools/runmdn/Makefile.in:
+       add altdude.{c,h,lo}.
+       * DISTFILES: add altdude.{c,h}
+
+2001-03-21
+       * 2.0beta2 release.
+
+       * wsock/wsock11/wsock32.def, wsock/wsock20/ws2_32.def: remove
+       function forwarders.
+       * wsock/wsock11/dllload.c, wsock/wsock20/dllload.c: use explicit
+       link for calling WINSOCK API.
+       * wsock/wsock11/dllstub.c, wsock/wsock20/dllstub.c: created.
+       stub functions for WINSOCK API.
+       * wsock/wsock11/dlldef.h, wsock/wsock11/dllfunc.c,
+       wsock/wsock20/dlldef.h, wsock/wsock20/dllfunc.c: use stub functions
+       for calling original API.
+       * wsock/wsock11/make.wnt, wsock/wsock20/make.wnt: adjust to the
+       above changes.
+       * wsock/common/jpnicmdn.def, wsock/common/jpnicmdn.h,
+       wsock/common/printf.c: add and export mdnLogPrintf().
+       * wsock/README.txt, wsock/README_j.txt: revise for version 2.0.
+
+2001-03-15
+       * mdnsproxy/make.wnt: add acl.c/acl.o.
+       * win/iconv.h, win/iconv.lib, win/iconv.dll: update to version 1.6.
+       * win/README.WIN: revise description.
+       * DISTFILES: add files relating mDN Wrapper, which were temporaly
+       removed form distribution.
+
+       * mdnsproxy/mdnsproxy.conf.sample: fix an erratum in client-encoding.
+
+       * include/mdn/api.h: fix typo in comment.
+
+2001-03-14
+       * wsock/common/convert.c, wsock/wsock11/dllmain.c,
+       wsock/wsock20/dllmain.c: use the new API.
+       * wsock/common/encoding.c: remove functions to access registry
+       entries no longer needed. add a function to get configuration
+       file path.
+       * wsock/common/jpnicmdn.def, wsock/common/jpnicmdn.h,
+       wsock/wsock11/dlldef.h, wsock/wsock20/dlldef.h: remove old
+       definitions.
+       * wsock/config/mdnconv.tcl: update for version 2.0.
+       * make.wnt, mdnsproxy/make.wnt: update for version 2.0.
+       * lib/res.c, lib/resconf.c, mdnsproxy/translate.c: remove
+       inclusion of old header files which no longer exist.
+
+       * mdnsproxy/logging.c, mdnsproxy/translate.c: mdn log level and log
+       handler are set by log_configure(), not by translate_initialize().
+
+       * mdnsproxy/logging.c: Don't use syslog if HAVE_SYSLOG is undefined.
+       * configure.in: add `syslog' to AC_CHECK_FUNCS.
+
+2001-03-13
+       * Makefile.in: set CUR_VERSION to 2.0beta2.
+
+       * configure.in: fix a bug in libiconv check.  add ICONVLIB to
+       LIBS, not to LDFLAGS.
+       * mdnsproxy/Makefile.in, tools/mdnconv/Makefile.in: set LIBS to
+       @LIBS@, MDNLIB to @MDNLIB@ and ICONVLIB to @ICONVLIB@.
+       * README.ja: update for version 2.0.
+       * README: revised.
+
+       * mdnsproxy/logging.c: syslog support.
+       * mdnsproxy/proxycnf.c, mdnsproxy/proxycnf.h: recognize new command
+       `syslog-facility'.
+       * mdnsproxy/mdnsproxy.8.in, mdnsproxy/mdnsproxy.conf.sample: add
+       description of syslog support.
+
+       * include/mdn/resconf.h, lib/resconf.c: delete
+       mdn_resconf_adddelimitermapucs(),
+       mdn_resconf_addlocalmapselectorname(),
+       mdn_resconf_addmappername(),
+       mdn_resconf_addnormalizername(),
+       mdn_resconf_addprohibitcheckername() and
+       mdn_resconf_addunassignedcheckername(). 
+
+       * lib/converter.c: converter_iconv_convert() appends reset-state
+       sequence to the output string.
+
+2001-03-09
+       * mdnsproxy/mdnsproxy.conf.sample: fix typo in mdn-conf-file entry.
+
+       * lib/mdn.conf.sample: fix typo in local-map entry.
+
+2001-03-08
+       * 2.0beta1 release.
+
+       * Makefile.in: set CUR_VERSION to 2.0beta1.
+
+       * README: update for version 2.0.
+
+       * lib/converter.c: fix a bug in converter_iconv_close().
+       private data area was disposed twice.
+
+       * map/Makefile.in, map/jp.map: new files.
+       * configure.in: add map/Makefile to AC_OUTPUT.
+       * Makefile.in: add map to SUBDIRS.
+       * DISTFILES: add map/Makefile.in and map/jp.map.
+
+       * DISTFILES: add `man/mdn.conf.5.in', and delete
+       `man/mdnres.conf.5.in'.
+
+       * configure.in: temporary delete `tools/runmdn/Makefile' and
+       `tools/runmdn/runmdn' from AC_OUTPUT.
+
+2001-03-07
+       * lib/ace.c, include/mdn/ace.h: created.
+       * include/mdn/Makefile.in, lib/Makefile.in, tools/runmdn/Makefile.in:
+       add ace.c and ace.h.
+       * lib/brace.c, lib/dude.c, lib/lace.c, lib/race.c, lib/utf6.c:
+       rewrite using ace utility module.
+       * DISTFILES: add ace.c and ace.h.
+       * lib/nameprep_template.c: remove duplicated macro defininition
+       (UNICODE_MAX).
+       * tools/mdnconv/mdnconv.c: avoid assertion fail when libmdn cannot
+       guess the local codeset.
+
+       * mdnsproxy/loggin.c: open a log file before chroot().
+       * mdnsproxy/loggin.c fix a but that log file name specified in the
+       configuration file is ignored.
+
+2001-03-06
+       * man/mdn.conf.5.in, tools/mdnconv/mdnconv.1: add description for
+       `nameprep-03'.
+       * lib/mdn.conf.sample: ditto.
+       * DISTFILES: update for version 2.0 release.  bind9-patch,
+       mDN Wrapper and runmdn are removed (temporary) from the
+       distribution list.
+       * lib/Makefile.in: change install filename from `mdnres.conf.sample'
+       to `mdn.conf.sample'.
+       * lib/brace.c, lib/dude.c, lib/lace.c, lib/race.c, lib/utf6.c:
+       fix behavior for converting null labels.
+       * lib/converter.c: fix bug in calling free().
+       * tools/mdnconv/util.c: include more info in error messages.
+       * tools/Makefile.in: remove runmdn temporary from subdirectory list.
+       
+2001-03-05
+       * man/mdn.conf.5.in: created.
+       * man/mdnres.conf.5.in: removed.
+       * man/Makefile.in: change mdnres.conf -> mdn.conf.
+       * tools/mdnconv/mdnconv.1: updated. existing sections are rewritten
+       according to the new spec, and some new sections are added.
+
+       * DISTFILES: add `mdn.conf.sample' and delete `mdnres.conf.sample'.
+       * lib/mdnres.conf.sample: deleted.
+       * lib/mdn.conf.sample: added.
+       * lib/Makefile.in: install `mdn.conf.sample', not `mdnres.conf.sample'.
+
+       * util/generate_nameprep_data.pl: add a feature of data sharing
+       among nameprep versions.
+       * lib/nameprepdata.c, lib/nameprep.c: add data for nameprep-03.
+       * lib/checker.c, lib/mapper.c, lib/normalizer.c: add `nameprep-03'
+       scheme.
+
+2001-03-01
+       * lib/resconf.c: fix a bug in mdn_resconf_setlocalconvertername().
+
+       * lib/res.c: fix a bug in `n' action of mdn_res_nameconv().
+       The result string is not terminted if the input string is ".".
+
+2001-02-27
+       * lib/Makefile.in, tools/runmdn/Makefile.in: Change library
+       version info from 5:0:1 to 6:0:0.
+
+2001-02-26
+       * lib/res.c: cosmetic changes.  split static function nameconv()
+       to 11 functions, a function per action.
+
+       * lib/resconf.c: mdn_resconf_setidnconvertername() accepts
+       ASCII uncompatible encoding name.
+
+       * lib/converter.h: change the type definition of
+       mdn_converter_openproc_t, mdn_converter_closeproc_t and
+       mdn_converter_convertproc_t.  `privdata' is added to their argument
+       list.
+       * lib/converter.c: conform openproc, closeproc, and convertproc
+       interfaces of the standard converters (iconv, utf5 and none) to
+       those of the converter module.
+       * lib/brace.c, lib/dude.c, lib/lace.c, lib/race.c, lib/utf6.c: ditto.
+
+2001-02-23
+       * tools/mdnconv/mdnconv.c, tools/mdnconv/util.c: add -delimiter, 
+       -delimitermap and -nameprep optinos.
+
+       * lib/nameprep.c, lib/filemapper.c: add functions compatible with
+       mdn_mapper_createproc_t, mdn_mapper_destroyproc_t and 
+       mdn_mapper_mapproct_t.
+       * lib/nameprep.c, lib/filechecker.c: add functions suitable for
+       mdn_checker_createproc_t, mdn_checker_destroyproc_t and 
+       mdn_checker_lookupproct_t.
+
+       * lib/mapselector.c: map_selector_map() didn't get TLD from a given
+       domain name. fixed.
+
+       * mdnsproxy/proxycnf.c: fix typo.
+
+       * lib/checker.c, lib/delimitermap.c, lib/mapper.c,
+       lib/mapselector.c, lib/nameprep.c, lib/normalizer.c: add _addall()
+       functions.
+       * include/mdn/checker.h, include/mdn/delimitermap.h,
+       include/mdn/mapper.h, include/mdn/mapselector.h,
+       include/mdn/normalizer.h: likewise.
+
+       * lib/Makefile.in, mdnxproxy/Makefile.in, tools/mdnconv/Makefile.in,
+       tools/runmdn/Makefile.in: remove .libs at make clean.
+
+       * lib/resconf.c, include/mdn/resconf.h: add set-by-name functions
+       for convinience.
+
+       * lib/res.c: don't perform NAMEPREP against a domain label which
+       conforms STD13.
+
+       * lib/util.c: extend mdn_util_validstd13().
+       If the 2nd argument `end' is NULL, end of the 1st argument is
+       assumed.
+
+2001-02-22
+       * lib/resconf.c, include/mdn/resconf.h: add
+       mdn_resconf_setnameprepversion().
+
+       * lib/Makefile.in: add api.c to SRCS and api.lo to OBJS.
+       * include/mdn/Makefile.in: add api.h to HDRS.
+       * DISTFILES: add lib/api.c, lib/delimitermap.c, lib/filechecker.c,
+       lib/filemapper.c, lib/mapper.c, lib/mapselector.c, lib/nameprep.c,
+       lib/nameprep_template.c, lib/nameprepdata.c, lib/ucsmap.c,
+       lib/ucsset.c, include/mdn/api.h, include/mdn/checker.h, 
+       include/mdn/delimitermap.h, include/mdn/filechecker.h,
+       include/mdn/filemapper.h, include/mdn/mapper.h,
+       include/mdn/mapselector.h, include/mdn/nameprep.h,
+       include/mdn/ucsmap.h, include/mdn/ucsset.h.
+
+       * tools/runmdn/ns_name.c: use api modoule to convert domain name.
+       * tools/runmdn/Makefile.in: add api.lo, checker.lo, delimitermap.lo,
+       mapper.lo and mapselector.lo MDNOBJS.
+
+2001-02-21
+       * fix a bug in command line option parser.
+
+       * lib/msgtrans.c: don't include resolv.h or arpa/nameser.h if system
+       doesn't have it.
+
+2001-02-20
+       * acconfig.h: diet. Description of cpp macro defined in config.h.in
+       is now given by the 3rd argument of AC_DEFINE or AC_DEFINE_UNQUOTED.
+
+       * tools/runmdn/ns_name.c, tools/runmdn/res_comp.c: include config.h.
+       * tools/runmdn/res_comp.c: don't include resolv.h or arpa/nameser.h
+       if system doesn't have it.
+
+       * lib/utf6.c: fix a decoder bug.
+
+2001-02-19
+       * lib/normalizer.c: remove ja-* schemes, and add `nameprep-02' as an
+       alias of `unicode-form-kc'.
+       * lib/filemapper.c, lib/filechecker.c: add partial support of
+       draft-ietf-idn-version-00.txt i.e. allow version specification
+       line at the top of the map/check files.  if those files begin
+       with a line of the form `version=...', ignore the line.
+       * lib/filechecker.c: allow lines that end with semicolons.
+
+       * dnsproxy/proxycnf.c: dnsproxy rejected bind4compat option to
+       `forward'.  Fixed.
+
+       * configure.in: check for a `iconv' function.
+
+       * dnsproxy: the directory name is renamed to `mdnsproxy'.
+
+       * configure.in, Makefile.in, dnsproxy/Makefile.in, 
+       dnsproxy/dnsproxy.8.in, dnsproxy/dnsproxy.conf.sample,
+       dnsproxy/dnsproxy.def, dnsproxy/dnsproxy.h: rename `dnsproxy' to
+       `mdnsproxy'.
+       * dnsproxy/acl.c, dnsproxy/logging.c, dnsproxy/message.c, 
+       * dnsproxy/os2main.c, dnsproxy/proxyconf.c, dnsproxy/translate.c, 
+       * dnsproxy/unxmain.c, dnsproxy/winmain.c, dnsproxy/winserv.c:
+       include `dnsproxy.h' not `mdnsproxy.h'.
+
+       * mdnsproxy/mdnsproxy.8.in, mdnsproxy/mdnsproxy.conf.sample:
+       corresponds to mDNkit-2.0.
+
+       * lib/translator.c, lib/zldrule.c: removed.
+       * lib/Makefile.in: remove translator.c and zldrule.c from SRCS, 
+       translator.lo and zldrule.lo from OBJS.
+       * include/mdn/translator.h, include/mdn/zldrule.h: removed.
+       * include/mdn/Makefile.in: remove translator.h and zldrule.h from
+       HDRS.
+       * tools/runmdn/Makefile.in: remove translator.lo and zldrule.lo from
+       OBJS.
+
+2001-02-16
+       * lib/checker.c: mdn_checker_lookup() doesn't think `.' as prohibited
+       character.
+       * lib/res.c: fix a bug of the nameconv action `L'.
+
+       * configure.in: add `--with-logdir=DIR' option.
+
+       * dnsproxy/Makefile.in: rename variable names; from `SBINDIR' to
+       `sbindir', from `ETCDIR' to `sysconfdir', from `MANDIR' to `mandir'.
+       * dnsproxy/Makefile.in: define `sysconfdir' and `logdir'.
+       * dnsproxy/Makefile.in: delete `CONFIG_PATH'.
+       * dnsproxy/Makefile.in: add `-DLOGDIR=...' option to DEFS.
+       * dnsproxy/Makefile.in: replace `@sysconfdir@' and `@logdir' in
+       dnsproxy.8.in.
+       * dnsproxy/dnsproxy.8.in: use @sysconfdir@ and @logdir@.
+       * dnsproxy/logging.c: default log file is set to LOGDIR/mdnsproxy.conf.
+
+       * dnsproxy/proxycnf.h: define all configuration commands as cpp macros
+       with the prefix KW_.
+       * dnsproxy/proxycnf.h: define all command line options as cpp macros
+       with the prefix CMDOPT_.
+
+       * dnsproxy/dnsproxy.h: include proxycnf.h.
+       * dnsproxy/dnsproxy.h: delete `zld' and `cconverter' from
+       translation_context_t.
+
+       * dnsproxy/proxycnf.c: record line numbers of commands when reading
+       a configuration file.
+       * dnsproxy/proxycnf.c: don't expand $(...) in a configuration file
+       name.
+       * dnsproxy/proxycnf.c: reject obsolete and unknown commands.
+
+       * dnsproxy/translate.c: use the resconf module in libmdn, and
+       and pass the resconf object to mdn_msgtrans_translate() to convert
+       DNS request and query data.
+       * dnsproxy/translate.c: ZLD is no longer supported.
+
+       * include/mdn/Makefile.in: add nameprep.h to HDRS.
+
+2001-02-15
+       * lib/msgtrans.c: re-implement using res and resconf module.
+       also change API.
+       * include/mdn/msgtrans.h: change API.
+       * tools/mdnconv/mdnconv.c, tools/mdnconv/util.c, tools/mdnconv/util.h:
+       re-implement using new res module interface.
+
+       * lib/res.c, include/mdn/res.h: rename the action characters.
+       Now, conversion from UTF-8 to ACE is done by `I', and conversion
+       from ACE to UTF-8 is done by `i'.
+
+       * include/mdn/checker.h: define MDN_CHECKER_PROHIBIT_PREFIX and
+       MDN_CHECKER_UNASSIGNED_PREFIX.
+
+       * lib/resconf.c: update the local converter each time 
+       mdn_resconf_getlocalconverter() is called, if the converter is not
+       set by mdn_resconf_setlocalconverter().
+
+       * lib/res.c: fix a bug in mdn_res_nameconv() that it returns
+       `mdn_invalid_action' for a valid action sequence.
+
+       * dnsproxy/Makefile.in, lib/Makefile.in, man/Makefile.in, 
+       include/mdn/Makefile.in, tools/mdnconv/Makefile.in,
+       tools/runmdn/Makefile.in: use `mkinstalldirs' to create missing
+       install directories.
+       * mkinstalldirs: new file.
+
+2001-02-14
+       * lib/unicode.c: fix typo.
+       * lib/normalizer.c: fix type confliction.
+       * wsock/README.txt, wsock/README_j.txt: remove a notice that
+       uninstallation of older version is needed before installing a
+       new version of mDN Wrapper, since it is not necessary any more.
+       also add a short description of "rewrap all" button.
+
+       * inclde/mdn/resconf.h: define the following macros for backward
+       compatibility; mdn_resconf_localconverter, mdn_resconf_idnconverter,
+       mdn_resconf_getalternateconverter, mdn_resconf_getnormalizer,
+       mdn_resconf_mapper, mdn_resconf_delimitermap,
+       mdn_resconf_localmapselector, mdn_resconf_prohibitchecker and
+       mdn_resconf_unassignedchecker.
+
+       * lib/resconf.c: fix a bug that parse_delimiter_map() might returns
+       incorrect return value.
+
+       * lib/utf6.c: fix a bug that the decoder might cause buffer overflow.
+
+       * lib/race.c, lib/utf6.c: delete comma at end of enumerator list.
+
+       * lib/res.c, include/mdn/res.h: revised for version 2.0.
+
+       * dnsproxy/unxmain.c, dnsproxy/os2main.c: reject unknown command line
+       options.
+
+       * lib/resconf.c: detect unbalanced quotation in configuration.
+
+       * lib/resconf.c: fix a serious bug that cannot read a configuration
+       file without a newline character at end of the file.
+
+       * lib/res.c: in mdn_res_nameconv(), action `l' tries to convert a
+       string using the alternate_encoder, and then tries using the
+       local_converter.
+
+       * configure.in: fix help message.
+
+       * lib/converter.c: register UTF-6.
+       * tools/mdnconv/mdnconv.1: Add UTF-6 to the ACE list.
+       * tools/runmdn/Makefile.in: Support UTF-6.
+
+2001-02-13
+       * util/UCD.pm, util/SparseMap.pm: created.
+       * util/generate_normalize_data.pl: wholly rewritten using above
+       two perl modules.
+       * util/generate_nameprep_data.pl: created.
+       * lib/unicodedata.c: re-generated.
+       * lib/unicode.c: change the basic lookup algorithm so that it should
+       adapt to the forthcoming new unicode standard easily.
+       * lib/unicode.c, include/mdn/unicode.h: implement unicode case
+       folding.
+       * lib/nameprepdata.c: fix a bug.
+       * lib/normalizer.c: add 'unicode-foldcase' normalization scheme.
+
+       * lib/resconf.c, include/mdn/resconf.h: revised for version 2.0.
+
+       * lib/delimitermap.c, include/mdn/delimitermap.h: new flies.
+       * lib/Makefile.in: add `delimitermap.c' to `SRCS'.
+       add `delimitermap.lo' to `OBJS'.
+       * include/mdn/Makefile.in: add `delimitermap.h' to `HDRS'.
+       * include/mdn/api.h, lib/api.c: created.
+       
+2001-02-09
+       * dnsproxy/unxmain.c: fix a bug that 'group-id' entry in the
+       configuration file causes an error, if specified together with
+       'user-id'.
+
+       * dnsproxy/dnsproxy.8.in, dnsproxy/dnsproxy.conf.sample:
+       Use the term `IP prefix' to an IP address followed by a slash
+       and netmask.
+
+       * lib/checker.c, include/mdn/checker.h: new files.
+       * lib/Makefile.in: add `checker.c' to `SRCS'.
+       add `checker.lo' to `OBJS'.
+       * include/mdn/Makefile.in: add `checker.h' to `HDRS'.
+
+2001-02-08
+       * lib/mapper.c, include/mdn/mapper.h: new files.
+       * lib/mapselector.c, include/mdn/mapselector.h: new files.
+       * lib/Makefile.in: add `mapper.c' and `mapselector.c' to `SRCS'.
+       add `mapper.lo' and `mapselector.lo' to `OBJS'.
+       * include/mdn/Makefile.in: add `mapper.h' and `mapselector.h' to
+       `HDRS'.
+
+2001-02-07
+       * lib/filechecker.c, include/mdn/filechecker.h: created.
+       * lib/filemapper.c, include/mdn/filemapper.h: created.
+       * lib/nameprep.c, lib/nameprepdata.c, lib/nameprep_template.c:
+       created.
+       * lib/Makefile.in, include/mdn/Makefile.in, tools/runmdn/Makefile.in:
+       incorporates newly created files above.
+       * dnsproxy/proxycnf.c, dnsproxy/dnsproxy.h: change variable name
+       'restrict' to 'src_restrict', since the next C standard makes
+       'restrict' a keyword, and there are some compilers already
+       implement the new spec.
+
+2001-02-05
+       * lib/converter.c, lib/normalizer.c: reference count support.
+       * include/mdn/converter.h: add the declaration of
+       mdn_converter_incrref().
+       * include/mdn/normalizer.h: add the declaration of
+       mdn_normalizer_incrref().
+       * include/mdn/result.h, lib/result.c : add new result codes
+       * (mdn_invalid_action, mdn_invalid_codepoint and mdn_prohibited).
+       * lib/ucsmap.c, include/mdn/ucsmap.h: created.
+       * lib/ucsset.c, include/mdn/ucsset.h: created.
+       * lib/Makefile.in: add ucsmap.c and ucsset.c.
+       * tools/runmdn/Makefile.in: add ucsmap.lo and ucsset.lo.
+       * include/mdn/Makefile.in: add ucsmap.h and ucsset.h.
+
+2001-02-02
+       * wsock/config/mdnconf.tcl: add `rewrap' button.
+
+2001-02-01
+        * Makefile.in: update for 1.3.
+       * README, README.ja: ditto.
+       * lib/Makefile.in, tools/runmdn/Makefile.in: update library version.
+
+       * patch/bind8/bind-8.2.3-patch: created.
+       * patch/bind8/bind-8.2.2-P7-patch: removed.
+       * patch/bind8/bind-8.2.3-T9B-patch: removed.
+       * patch/bind9/bind-9.1.0-patch: created.
+       * DISTFILES: remove bind-8.2.2-P7-patch and bind-8.2.3-T9B-patch,
+       and then add bind-8.2.3-patch and bind-9.1.0-patch.
+
+2000-12-28
+        * Makefile.in: update for 1.2.1-rc2.
+        * README, README.ja: update for 1.2.1-rc2 release.
+
+2001-01-30
+       * lib/Makefile.in: add `utf6.c' to SRCS.  add `utf6.o' to OBJS.
+       * include/mdn/Makefile.in: add `utf6.h' to HDRS.
+       * lib/utf6.c, include/mdn/utf6.h: new files.
+       * DISTFILES: add lib/utf6.c and include/mdn/utf6.h.
+
+2001-01-29
+       * tools/runmdn/ns_name.c: include resolv.h and arpa/nameser.h only
+       if they exist.
+       * configure.in: add check for resolv.h and arpa/nameser.h.
+       * configure, include/config.h.in: re-generated.
+       * include/mdn/dude.h: add a comment about conformance.
+       
+2001-01-22
+       * lib/brace.c, lib/dude.c, lib/lace.c, lib/race.c: fix a bug that
+       ACE encoders cannot encode a domain name which ends with `.'.
+       * dnsproxy/acl.c: fix a bug of ACL initialization.
+
+2001-01-18
+       * lib/lace.c: catch up with draft-ietf-idn-lace-01.txt.
+
+2001-01-16
+       * dnsproxy/proxycnf.c: rewrite getHostPort(), and define
+       getHostPort2().  They parse `host:port' string more stritctly.
+       * dnsproxy/acl.c: fix error messages.
+       * DISTFILES: add dnsproxy/acl.c.
+       * lib/util.c, include/mdn/util.h: defines mdn_util_validstd13().
+       * lib/brace.c, lib/dude.c, lib/lace.c, lib/race.c: use
+       mdn_util_validstd13() to test whether a domain name conforms STD-13.
+
+2001-01-15
+       * lib/dude.c, include/mdn/dude.h: created.
+       * lib/converter.c: add DUDE encoding.
+       * lib/Makefile.in, include/mdn/Makefile.in: add dude.[ch].
+       * tools/runmdn/Makefile.in: add dude.lo.
+       * DISTFILES: add dude.[ch].
+
+       * dnsproxy/logging.c: log_configure() returns BOOL.
+       * dnsproxy/unxmain.c, dnsproxy/os2main.c, dnsproxy/winmain.c,
+       dnsproxy/winserv.c: exit if a configuration file has an invalid
+       `log-level' line.
+       * dnsproxy/proxycnf.c, dnsproxy/logging.c: fix error and warning
+       messages.
+       
+2001-01-12
+       * dnsproxy/acl.c: new file.
+       * dnsproxy/server.c: add access control feature.
+       * dnsproxy/server.c: sockAccept(), sockRecvTcp() and sockRecvUdp()
+       returns `int', not `BOOL'.  The return value from the functions is
+       SUCESS, FAILURE, or DENIED.
+       * dnsproxy/proxycnf.c: define config_query_log_on_denied().
+       * dnsproxy/dnsproxy.h: add declaration of config_query_log_on_denied(),
+       acl_initialize(), acl_test() and acl_finalize().
+       * dnsproxy/Makefile.in: add `acl.c' to SRCS, and `acl.o' to OBJS.
+       * dnsproxy/dnsproxy.conf.sample: add `allow-access' and `log-on-denied'
+       entires.
+       * dnsproxy/dnsproxy.8.in: likewise.
+
 2001-01-12
        * Makefile.in: update for 1.2.1.
        * version 1.2.1 release
index 906c8d6c328d1df437969d5b05a003bd51fa0ead..602e22caf76972963224aff2071ec38cb59c6378 100644 (file)
@@ -1,4 +1,4 @@
-# $Id: Makefile.in,v 1.34 2001/01/12 00:28:08 ishisone Exp $
+# $Id: Makefile.in,v 1.44 2001/04/17 03:24:09 m-kasahr 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.
@@ -63,15 +63,9 @@ exec_prefix = @exec_prefix@
 
 PERL = perl
 MKTARPKG = ../util/mktarpkg
+SHELL = @SHELL@
 
-SUBDIRS = include lib dnsproxy man tools
-
-CUR_VERSION  = 1.2.1
-PREV_VERSION = 1.2
-PREV_TAG = REL_1_2
-
-DISTFILE = mdnkit-$(CUR_VERSION)-src
-PATCHFILE = mdnkit-$(PREV_VERSION)-$(CUR_VERSION)-src-patch
+SUBDIRS = include lib mdnsproxy man tools map
 
 all:
        for d in $(SUBDIRS); do (cd $$d; $(MAKE) all); done
@@ -83,8 +77,8 @@ clean:
        for d in $(SUBDIRS); do (cd $$d; $(MAKE) clean); done
 
 dist:
-       cd $(srcdir); $(PERL) $(MKTARPKG) --gzip=9 $(DISTFILE)
-
-patch:
-       cd $(srcdir); mkcvspatch --gzip=9 --header=patch.header \
-               --from=$(PREV_TAG) $(PATCHFILE)
+       @v=`sed -ne '/^# *define *MDNKIT_VERSION/s/^.*"\([^"]*\)".*$$/\1/p' \
+               $(srcdir)/include/mdn/version.h`; \
+       echo generate mdnkit-$$v-src.tar.gz; \
+       cd $(srcdir); \
+       $(PERL) $(MKTARPKG) --gzip=9 mdnkit-$$v-src
index 35c41ff5d3ac74dd316069437be61a85b3c2adb6..165fad440f035a2de55a291fb09ed3e52847062a 100644 (file)
@@ -1,4 +1,95 @@
-; $Id: NEWS,v 1.8 2000/12/28 02:36:29 ishisone Exp $
+; $Id: NEWS,v 1.22 2001/06/01 01:20:39 ishisone Exp $
+
+Major changes in version 2.1:
+
+* BIND-9 patch is back.  The patch adds encoding conversion and
+  NAMEPREP capability to `dig', `host' and `nslookup'.
+  Since version 2 adopts IDNA, in which all the MDN processing are
+  performed in the application layer before calling the resolver
+  layer, patch to the BIND-9's light-weight resolver found in version
+  1.x are removed.
+
+* Runmdn is back.  The strategy for making resolver MDN-aware has been
+  changed from replacing low-level resolver functions to wrapping
+  resolver API functions, so that it should also work for exotic
+  resolver implementations such as Solaris's.
+
+* Several new ACEs are supported.  These are `AltDUDE', `AMC-ACE-M',
+  `AMC-ACE-O' and  `AMC-ACE-R'.
+
+* `-version' option is added to mdnconv and mdnsproxy.  When the option
+  is specified, the command prints its version number and exits
+  immediately.
+
+* For some of frequently used options, single-character short-cut options
+  are provided for mdnconv.
+
+* The base versions of Squid patch is now 2.4.STABLE1.
+
+* A build problem on NetBSD 1.5 is fixed.
+
+
+Major changes in version 2.0.1:
+
+* A bug in mdnsproxy/Makefile.in is fixed.  Now mdnsproxy 2.X can be
+  built on Solaris.
+
+
+Major changes in version 2.0:
+
+* The MDN library (libmdn) performs domain name preparation (NAMEPREP)
+  according to the current Internet Draft.  Currently nameprep-02 and
+  nameprep-03 are supported.  Also additional local name preparation
+  can be performed before NAMEPREP.  Along with this change, command
+  line options of `mdnconv' are greatly changed.  See the man page
+  mdnconv(1) for more details.
+
+* mDNkit adopts IDNA, which is an architecture for handling
+  multilingual domain names currently being discussed at IETF IDN
+  working group.  MDN library provides new API in accordance with this
+  IDNA, and NAMEPREP.
+
+* The default configuration file name for the MDN Library is changed
+  from `mdnres.conf' to `mdn.conf'.  Note that syntax of the file has
+  some incompatible changes.  See the man page mdn.conf(5).
+
+* dnsproxy is renamed to `mdnsproxy'.  The default configuration file
+  is also renamed from `dnsproxy.conf' to `mdnsproxy.conf', and its
+  syntax is revised.  Unlike dnsproxy which only reads `dnsproxy.conf',
+  mdnsproxy also reads mdn.conf.  The path name of `mdn.conf' can be
+  specified in mdnsproxy.conf.  See mdnsproxy.conf(5) for more details.
+
+* For security reason, default directory where mdnsproxy outputs log
+  files is moved from `/tmp' to `/var/log/mdnsproxy'.  `--with-logdir'
+  option to configure can customize the directory location.
+
+* mdnsproxy can output log messages with syslog.
+
+* DUDE converter is revised and now conforms to -01 draft.
+
+* This release doesn't contain runmdn and bind9 patch.  They are
+  expected to appear again in future versions.
+
+
+Major changes in version 1.3:
+
+* dnsproxy supports access control.  dnsproxy now recognizes
+  `allow-access' and `log-on-denied' entries in a configuration file.
+  See dnsproxy.8 and dnsproxy.conf.sample for more details.
+
+* LACE converter incorporates numeral checks introduced by -01 draft.
+
+* New encoding converters for `DUDE' and `UTF-6' are implemented.
+
+* Whether a given name conforms the host name requirement in STD13 or
+  not is checked more strictly by the MDN library.  A name starting
+  or ending with hypen is not considered as STD13 conformed name, even
+  if the name consists exclusively of alphabets, digits and hypens.
+  
+* The base versions of BIND-9 patch are now 9.0.1 and 9.1.0.
+
+* The base versions of BIND-8 patch is now 8.2.3 only.
+
 
 Major changes in version 1.2.1:
 
index 8d5c8ff79acaf1bd8c12fca420d68f3bab8fedc6..74f946a3352a8955e8f38e2914bdb22254794b95 100644 (file)
@@ -1,43 +1,65 @@
 
                                mDNkit
-           -- multilingual domain name evaluation kit --
-                           version 1.2.1
+               -- multilingual domain name toolkit --
+                            version 2.1
               Japan Network Information Center (JPNIC)
 
 
 * Overview
 
-mDNkit is a kit for evaluating various proposed methods regarding
-multilingualized/internationalized DNS.  To handle multilingualized
-domain name, the following features are required:
-       + encoding conversion of domain names between
-         the encoding application uses (local encoding) and
-         the encoding on DNS protocol.
-       + normalization of domain names.
+mDNkit is a toolkit for handling multilingualized/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.
+       
 mDNkit provides several ways for adding these features.
 
 This kit consists of following components.
 
-    + DNS proxy server (dnsproxy)
+    + library for handling multilingual domain names (libmdn)
+       This is a library implementing encoding conversion and
+       nameprep.  The library provides easy-to-use API for these
+       features, so it should be easy to add capability of handling
+       multilingual domain name to your applications using this
+       library.
+       This library is also used for implementing various commands in
+       this toolkit (such as mdnsproxy and mdnconv).
+
+    + DNS proxy server (mdnsproxy)
        This works as a fake DNS server for the clients.  It receives
        DNS request containing domain names in the client's local
        encoding (e.g. Shift_JIS), translates them into the encoding
        on DNS protocol (e.g. UTF-8 or RACE), and forwards to the real
        DNS server.  Also the response from the server is converted
        back to the client's local encoding and returned.  See
-       ``1. using dnsproxy'' below.
+       ``2. using mdnsproxy'' below.
 
     + a command dynamically adds MDN feature to unix applications (runmdn)
        This command enables normal applications to handle
        multilingual domain names by dynamically attaching special
-       library to them.  See ``2. using runmdn'' below.
+       library to them.  See ``3. using runmdn'' below.
 
     + a patch for BIND-9 that adds MDN capability
-       This patch adds MDN capability to BIND9.  BIND 9 employs a
-       completely new name resolving scheme called ``light weight
-       resolver'', consisting of client-side library (liblwres) and a
-       name resolving daemon (lwresd).  This patch adds MDN features
-       to them.  See ``3. using patched version of bind-9'' below.
+       This patch adds MDN capability to BIND9.  It adds encoding
+       conversion and nameprep features to `dig', `host' and
+       `nslookup'.  With the patch, those commands become capable of
+       multilingual domain names.
 
     + mDN wrapper for Windows applications
         On windows, name resolving request is passed to WINSOCK DLL. So,
@@ -50,12 +72,7 @@ This kit consists of following components.
        This is a codeset (encoding) converter specially designed for
        converting named.conf and zone master files from your local
        encoding (e.g. EUC-JP) to the encoding which internationalized
-       DNS servers employ (e.g. UTF-8).
-
-    + libraries for handling multilingual domain names (libmdn, libmdnres)
-       These are the basic libraries implementing encoding conversion
-       and normalization.  All the commands in this kit (such as
-       dnsproxy and mdnconv) are built using these libraries.
+       DNS servers employ (e.g. RACE).
 
     + a patch that makes BIND-8 8-bit through
        This is needed in order for named and resolver to handle
@@ -72,48 +89,59 @@ This kit consists of following components.
 This kit provides several ways to handle multilingual domain names
 using above components.
 
- ** 1. using dnsproxy
+ ** 1. using API
+    This is the preferred way to handle multilingual domain names,
+    applications are required to explicitly call the name conversion
+    API mDNkit provides.
+
+                                 domain name
+   +-----------+-------+--------+   in ACE
+   |           |       |        |  encoding  +------------+
+   |  client   |  mdn  |system's|----------->| DNS server |
+   |application|library|resolver|<-----------|            |
+   |           |       |        |            +------------+
+   +-----------+-------+--------+ 
+
+ ** 2. using mdnsproxy
+    In case the application cannot be modified to use the above API,
+    you can still be able to use multilingual domain names using
+    mdnsproxy, provided that the application uses 8bit-through
+    resolver.
 
                  domain name      encoding      domain name
-                  in local     conversion and   in encoding 
-   +------------+  encoding     normalization      on DNS      
-   |   client   |             +----------------+  protocol   +----------+
-   |application |------------>|    dnsproxy    |------------>|DNS server|
+                  in local     conversion and     in ACE
+   +------------+  encoding        nameprep       endoding
+   |   client   |             +----------------+             +----------+
+   |application |------------>|   mdnsproxy    |------------>|DNS server|
    |    with    |<------------|                |<------------|          |
    |8bit through|             +----------------+             +----------+
    |  resolver  |
    +------------+
 
- ** 2. using runmdn
+ ** 3. using runmdn
+    Or if the client application dynamically links resolver API (such as
+    gethostbyname) and the OS supports certain features, you can use
+    runmdn.  By replacing the resolver API with a version which performs
+    encoding conversion and nameprep, runmdn enables normal applications
+    to resolve multilingual domain names.
 
                   encoding      domain name
-               conversion and   in encoding
-               normalization      on DNS
-   +-----------+-------------+    protocol
-   |   client  | dynamically |                 +----------+
-   |application|  attached   |---------------->|DNS server|
-   |with normal|   library   |<----------------|          |
-   | resolver  | (libmdnres) |                 +----------+
+               conversion and     in ACE
+                  nameprep       encoding
+   +-----------+-------------+                 +----------+
+   |   client  | dynamically |---------------->|DNS server|
+   |application|  attached   |<----------------|          |
+   |           |   library   |                 +----------+
    +-----------+-------------+
 
- ** 3. using patched version of bind-9
-
-                 domain name    normalization   domain name
-                  in UTF-8      and encoding    in encoding
-   +------------+  encoding       conversion       on DNS
-   |   client   |             +----------------+  protocol   +----------+
-   |application |------------>|  light weight  |------------>|DNS server|
-   |with bind9's|<------------|    resolver    |<------------|          |
-   |light weight|             |     daemon     |             +----------+
-   |  resolver  |             +----------------+
-   +------------+
-
  ** 4. using mDN wrapper
+    By wrapping WINSOCK DLL, mDN Wrapper enables Windows applications
+    to resolve multilingual domain names.
 
-                domain name   normalization       domain name
-                 in local     and encoding        in ecnoding
-   +-----------+ encoding      conversion           on DNS
-   |  legacy   |             +---------+---------+ protocol  +----------+
+                domain name    nameprep           domain name
+                 in local     and encoding          in ACE
+   +-----------+ encoding      conversion          encoding
+   |  legacy   |             +---------+---------+           +----------+
    |  windows  |------------>|   mDN   | orignal |---------->|DNS server|
    |  network  |<------------| wrapper | winsock |<----------|          |
    |application|             +---------+---------+           +----------+
@@ -129,22 +157,23 @@ important files and their brief description.
     +DISTFILES         list of files in this distribution
     +NEWS              what's new in this version
     +ChangeLog         list of changes
-    +configure         a `configure' script
     +Makefile.in       toplevel makefile template
+    +configure         a `configure' script
     +include/
     |  +config.h.in    template header file for configuration
     |  +mdn/           header files for mdn library
-    +dnsproxy/         source directory for DNS proxy server
     +lib/              source directory for mdn library
-    +wsock/            source directory for mDN wrapper
-    +tools/            source directory for tools
-    |  +mdnconv/       source directory for codeset converter
-    |   +runmdn/       source directory for runmdn command
+    +mdnsproxy/                source directory for DNS proxy server
     +patch/            various patch files
     |  +bind8/         bind-8 patch directory
     |  +bind9/         bind-9 patch directory
+    |   +libiconv/     libiconv patch directory
     |  +squid/         squid patch directory
+    +tools/            source directory for tools
+    |  +mdnconv/       source directory for codeset converter
+    |   +runmdn/       source directory for runmdn command
     +util/             utilities
+    +wsock/            source directory for mDN wrapper
 
 
 * Compilation and installation
@@ -162,6 +191,14 @@ license), from:
 
        http://clisp.cons.org/~haible/packages-libiconv.html
 
+*Note*
+  The current version of the above implementation (libiconv-1.6.1) is
+  known to have a compilation problem on NetBSD 1.5.  There is a patch
+  file for the bug under patch/libiconv directory.  If you are a
+  NetBSD 1.5 user and found a problem in compiling libiconv, apply the
+  patch and try again.  The patch file contains brief instructions on
+  how to apply it at the beginning.
+
 1. Running configure script
 
 Run `configure' script in the top directory.  This checks various
@@ -207,27 +244,46 @@ options.
 
            --with-utf8=utf8
 
+    --with-preference=PREFERENCE
+       This option sets the preference for the sample mDNkit
+       configuration file (mdn.conf.sample).  Also this option
+       enables to install default configuration file (mdn.conf)
+       if the file didn't exist.
+       The only preference supported by this version is "jp".
+
     --with-race-prefix=PREFIX
     --with-brace-suffix=SUFFIX
     --with-lace-prefix=PREFIX
+    --with-dude-prefix=PREFIX
        RACE (Row-based ASCII-Compatible Encoding), BRACE (Bi-mode
-       Row-based ASCII-Compatible Encoding) and LACE (Length-based
-       ASCII Compatible Encoding) are proposed encodings for
-       multilingual domain name in DNS protocol data.  They uses a
-       fixed prefix (or suffix) string to distinguish names encoded
-       by them from normal ASCII domain names.  These prefix/suffix
-       are defined by the current Internet Drafts and mDNkit uses
-       them by default, but later version of the drafts may change
-       them.  In that case you can specify the prefix/suffix with
-       these options.
-
-    --enable-zld
-       The ZLD (zero level domain) support is disabled by default.
-       If you want to try this feature, this option must be
-       specified.
+       Row-based ASCII-Compatible Encoding), LACE (Length-based ASCII
+       Compatible Encoding) and DUDE (Differential Unicode Domain
+       Encoding) are proposed encodings for multilingual domain name
+       in DNS protocol data.  They uses a fixed prefix (or suffix)
+       string to distinguish names encoded by them from normal ASCII
+       domain names.  These prefix/suffix are defined by the current
+       Internet Drafts and mDNkit uses them by default, but later
+       version of the drafts may change them.  In that case you can
+       specify the prefix/suffix with these options.
+
+    --with-altdude-prefix=PREFIX
+    --with-altdude-suffix=SUFFIX
+    --with-amc-ace-m-prefix=PREFIX
+    --with-amc-ace-m-suffix=SUFFIX
+    --with-amc-ace-o-prefix=PREFIX
+    --with-amc-ace-o-suffix=SUFFIX
+    --with-amc-ace-r-prefix=PREFIX
+       AltDUDE, AMC-ACE-M, AMC-ACE-O and AMC-ACE-R are also proposed
+       encodings for multilingual domain names.  Unlike encodings
+       mentioned above, the Internet Drafts for these do not define
+       specific prefixes nor suffixes.  mDNkit provides default for
+       them, but you can override them with these options.
+       You can specify either prefix or suffix for AltDUDE, AMC-ACE-M
+       and AMC-ACE-O.  In case both are specified, prefix is
+       preferred.
 
     --sbindir=DIR
-       Specifies the install directory for dnsproxy.  Default is
+       Specifies the install directory for mdnsproxy.  Default is
        /usr/local/sbin.
 
     --bindir=DIR
@@ -235,7 +291,7 @@ options.
        Default is /usr/local/bin.
 
     --sysconfdir=DIR
-       Specifies the install directory for sample files of dnsproxy
+       Specifies the install directory for sample files of mdnsproxy
        configuration and mDNkit's resolver configuration.  Default is
        /usr/local/etc.
 
@@ -270,21 +326,20 @@ become a super-user before the installation.
 
 4. Configuration and usage
 
-Please consult online manuals for configuration and usage of `dnsproxy'
+Please consult online manuals for configuration and usage of `mdnsproxy'
 `mdnconv', and `runmdn'.  Also for `mdnconv' and `runmdn', please refer
-the manual of mDNkit's resolver configuration file `mdnres.conf'.
+the manual of mDNkit's resolver configuration file `mdn.conf'.
 
-       % man dnsproxy
+       % man mdnsproxy
        % man mdnconv
-       % man runmdn
-       % man mdnres.conf
+       % man mdn.conf
 
 
 * Applying patches
 
-This distribution also contains patches for BIND 8.2.2-P7,
-BIND 8.2.3-T9B, BIND 9.0.1 and Squid 2.3.STABLE3.  The top of these
-patch files describe how to apply the patch and (re)install.
+This distribution also contains patches for BIND 9.1.1, BIND 8.2.3 and
+Squid 2.4.STABLE1.  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
@@ -301,4 +356,4 @@ 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.18 2000/12/28 04:09:28 ishisone Exp $
+; $Id: README,v 1.29 2001/06/01 01:13:46 ishisone Exp $
index ba1d375167e6acf78821cdc1612090f1fbcf792f..456e9f820152fe837ccd9111c04be44c0c47c979 100644 (file)
@@ -1,45 +1,60 @@
 
                                mDNkit
-                  -- Â¿¸À¸ì¥É¥á¥¤¥ó̾ɾ²Á¥­¥Ã¥È --
-                          ¥Ð¡¼¥¸¥ç¥ó 1.2.1
+                 -- Â¿¸À¸ì¥É¥á¥¤¥ó̾¥Ä¡¼¥ë¥­¥Ã¥È --
+                           ¥Ð¡¼¥¸¥ç¥ó 2.1
        (¼Ò) ÆüËܥͥåȥ¥¯¥¤¥ó¥Õ¥©¥á¡¼¥·¥ç¥ó¥»¥ó¥¿¡¼ (JPNIC)
 
 
 * ³µÍ×
 
-mDNkit ¤È¤Ï DNS ¤Ç¿¸À¸ì¥É¥á¥¤¥ó̾¤ò°·¤¦¤¿¤á¤ËÄ󰯤µ¤ì¤Æ¤¤¤ë³Æ¼ï¤ÎÊý¼°
-¤òɾ²Á¤¹¤ë¤¿¤á¤Î¥­¥Ã¥È¤Ç¤¹¡£Â¿¸À¸ì¥É¥á¥¤¥ó̾¤ò°·¤¦¤¿¤á¤Ë¤Ï¡¢¼¡¤Î¤è¤¦¤Ê
-µ¡Ç½¤¬Í׵ᤵ¤ì¤Þ¤¹¡£
+mDNkit ¤È¤Ï¿¸À¸ì¥É¥á¥¤¥ó̾¤ò°·¤¦¤¿¤á¤Î¥Ä¡¼¥ë¥­¥Ã¥È¤Ç¤¹¡£Â¿¸À¸ì¥É¥á¥¤
+¥ó̾¤ò°·¤¦¤¿¤á¤Ë¤Ï¡¢¼¡¤Î¤è¤¦¤Êµ¡Ç½¤¬Í׵ᤵ¤ì¤Þ¤¹¡£
 
-¡¦¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤¬»ÈÍѤ¹¤ë¥¨¥ó¥³¡¼¥Ç¥£¥ó¥° (¥í¡¼¥«¥ë¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°)
-  ¤È DNS ¥×¥í¥È¥³¥ë¾å¤Î¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°¤È¤Î´Ö¤Î¡¢¥É¥á¥¤¥ó̾¤Î¥¨¥ó¥³¡¼
-  ¥Ç¥£¥ó¥°ÊÑ´¹¡£
-¡¦¥É¥á¥¤¥ó̾¤ÎÀµµ¬²½¡£
+¡¦¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°ÊÑ´¹
+  Â¿¸À¸ì¥É¥á¥¤¥ó̾¤ËÂФ·¤Æ¡¢¤½¤Î¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°¤ò¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤¬»È
+  ÍѤ·¤Æ¤¤¤ë¤â¤Î (¥í¡¼¥«¥ë¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°) ¤«¤é̾Á°²ò·è¤ËÍѤ¤¤é¤ì¤ë¤â
+  ¤Î (IDN ¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°) ¤Ø¤ÎÊÑ´¹¡¢¤Þ¤¿¤½¤ÎµÕÊý¸þ¤ÎÊÑ´¹¤ò¹Ô¤¤¤Þ¤¹¡£
+  ¥É¥á¥¤¥ó̾¤ò IDN ¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°¤Ë¤·¤¿·ë²Ì¤Ï¡¢½¾Íè¤Î¥É¥á¥¤¥ó̾¤ÈƱ
+  ¤¸¤¯ ASCII Ê¸»ú¤Î¤ß¤Ç¹½À®¤µ¤ì¤ë¤Î¤Ç¡¢IDN ¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°¤ÏASCII ¸ß
+  ´¹¥¨¥ó¥³¡¼¥Ç¥£¥ó¥° (ACE) ¤È¤â¸Æ¤Ð¤ì¤Þ¤¹¡£
 
-mDNkit ¤Ç¤Ï¡¢¤³¤ì¤é¤Îµ¡Ç½¤òÄɲ乤뤿¤á¤Î³Æ¼ï¤ÎÊýË¡¤òÄ󶡤·¤Æ¤¤¤Þ¤¹¡£
+¡¦NAMEPREP
+  ¥É¥á¥¤¥ó̾¤ò IDN ¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°¤ËÊÑ´¹¤¹¤ëÁ°¤Ë¡¢Ì¾Á°¤ÎÀµµ¬²½¤ò¹Ô¤¤
+  ¤Þ¤¹¡£¤³¤ì¤ò NAMEPREP ¤È¸Æ¤Ó¤Þ¤¹¡£
+
+¾åµ­¤Î½èÍý¤Ï¥É¥á¥¤¥ó̾¤ò DNS ¥µ¡¼¥Ð¤ËÁ÷¤ëÁ°¤Ë¼Â¹Ô¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£
+½èÍýºÑ¤Î¥É¥á¥¤¥ó̾¤Ï ASCII Ê¸»ú¤«¤é¹½À®¤µ¤ì¡¢½¾Íè¤Î ASCII ¥É¥á¥¤¥ó̾¤È
+¤·¤Æ¤âÀµ¤·¤¤·Á¼°¤Ë¤Ê¤Ã¤Æ¤¤¤ë¤Î¤Ç¡¢DNS ¥µ¡¼¥Ð¦¤Ë¤Ï¤Ê¤ó¤ÎÊѹ¹¤âɬÍפ¢¤ê
+¤Þ¤»¤ó¡£
 
 ¤³¤ÎÇÛÉÛ¥­¥Ã¥È¤Ë¤Ï¼¡¤Î¤è¤¦¤Ê¤â¤Î¤¬´Þ¤Þ¤ì¤Þ¤¹¡£
 
-¡¦DNS¥×¥í¥­¥·¥µ¡¼¥Ð (dnsproxy)
+¡¦Â¿¸À¸ì¥É¥á¥¤¥ó̾¤ò½èÍý¤¹¤ë¤¿¤á¤Î¥é¥¤¥Ö¥é¥ê (libmdn)
+  ¤³¤ì¤Ï¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°ÊÑ´¹¤ä NAMEPREP ¤Îµ¡Ç½¤ò¼ÂÁõ¤·¤¿¥é¥¤¥Ö¥é¥ê¤Ç¤¹¡£
+  ¤³¤Î¥é¥¤¥Ö¥é¥ê¤Ï¤³¤ì¤é¤Îµ¡Ç½¤ò»È¤¦¤¿¤á¤Î¥·¥ó¥×¥ë¤Ê API ¤òÈ÷¤¨¤Æ¤¤¤ë¤Î¤Ç¡¢
+  ¤³¤Î¥é¥¤¥Ö¥é¥ê¤ò»ÈÍѤ¹¤ì¤Ð¡¢Â¿¸À¸ì¥É¥á¥¤¥ó̾¤ò°·¤¦µ¡Ç½¤ò´Êñ¤Ë
+  ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤ËÄɲ乤뤳¤È¤¬¤Ç¤­¤Þ¤¹¡£
+  ¤Þ¤¿¤³¤Î¥é¥¤¥Ö¥é¥ê¤ÏËܥġ¼¥ë¥­¥Ã¥È¤Ë´Þ¤Þ¤ì¤ë¤µ¤Þ¤¶¤Þ¤Ê¥³¥Þ¥ó¥É 
+  (mdnsproxy ¤ä mdnconv ¤Ê¤É) ¤ò¼ÂÁõ¤¹¤ë¤Î¤Ë¤â»È¤ï¤ì¤Æ¤¤¤Þ¤¹¡£
+  
+¡¦DNS¥×¥í¥­¥·¥µ¡¼¥Ð (mdnsproxy)
   ¥É¥á¥¤¥ó̾ÊÑ´¹µ¡Ç½¤ò¤â¤Ä DNS ¤Î¥×¥í¥­¥·¥µ¡¼¥Ð¤Ç¤¹¡£¥¯¥é¥¤¥¢¥ó¥È¤«¤é
   ¼õ¿®¤·¤¿ DNS ¥á¥Ã¥»¡¼¥¸Ãæ¤Î¥É¥á¥¤¥ó̾¤ò¥¯¥é¥¤¥¢¥ó¥È¤Î¥í¡¼¥«¥ë¥¨¥ó¥³¡¼
   ¥Ç¥£¥ó¥°¤«¤é DNS ¥µ¡¼¥Ð¤Î»ÈÍѤ¹¤ë DNS ¥×¥í¥È¥³¥ë¾å¤Î¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°
   ¤Ø¤ÈÊÑ´¹¤·¤Æ DNS ¥µ¡¼¥Ð¤ËÁ÷¿®¤·¤Þ¤¹¡£¤Þ¤¿ DNS ¥µ¡¼¥Ð¤«¤éÊÖ¤µ¤ì¤¿DNS 
   ¥á¥Ã¥»¡¼¥¸Ãæ¤Î¥É¥á¥¤¥ó̾¤ò¥¯¥é¥¤¥¢¥ó¥È¤Î¥í¡¼¥«¥ë¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°¤ËÌá
-  ¤·¤Æ¥¯¥é¥¤¥¢¥ó¥È¤ËÊÖ¤·¤Þ¤¹¡£¾Ü¤·¤¯¤Ï¡¢¸å½Ò¤Î¡Ö1. dnsproxy ¤ò»È¤¦¡×¤ò
-  ¸æÍ÷¤¯¤À¤µ¤¤¡£
+  ¤·¤Æ¥¯¥é¥¤¥¢¥ó¥È¤ËÊÖ¤·¤Þ¤¹¡£¾Ü¤·¤¯¤Ï¡¢¸å½Ò¤Î¡Ö2. mdnsproxy ¤ò»È¤¦¡×
+  ¤ò¸æÍ÷¤¯¤À¤µ¤¤¡£
 
 ¡¦UNIX ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ë MDN µ¡Ç½¤òưŪ¤ËÄɲ乤륳¥Þ¥ó¥É (runmdn)
   UNIX ¤ÎÄ̾ï¤Î¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ç¿¸À¸ì¥É¥á¥¤¥ó̾¤ò¼è¤ê°·¤¦¤¿¤á¤Ë¡¢ÆÃ
   Ê̤ʥ饤¥Ö¥é¥ê¤òưŪ¤Ë¥ê¥ó¥¯¤¹¤ë¤¿¤á¤Î¥³¥Þ¥ó¥É¤Ç¤¹¡£¾Ü¤·¤¯¤Ï¡¢¸å½Ò¤Î
-  ¡Ö2. runmdn ¤ò»È¤¦¡×¤ò¸æÍ÷¤¯¤À¤µ¤¤¡£
+  ¡Ö3. runmdn ¤ò»È¤¦¡×¤ò¸æÍ÷¤¯¤À¤µ¤¤¡£
 
 ¡¦bind-9 ¤Ë MDN µ¡Ç½¤òÄɲ乤ë¥Ñ¥Ã¥Á
-  bind-9 ¤Ë MDN ¤Îµ¡Ç½¤òÄɲ乤ë¥Ñ¥Ã¥Á¤Ç¤¹¡£bind-9 ¤Ç¤Ï¡¢¥¯¥é¥¤¥¢¥ó¥È
-  Â¦¤Î¥é¥¤¥Ö¥é¥ê (liblwres) ¤È¡¢¿·¤·¤¤Ì¾Á°²ò·èÍѥǡ¼¥â¥ó (lwresd) ¤«¤é
-  À®¤ë¡¢¥é¥¤¥È¥¦¥¨¥¤¥È¥ê¥¾¥ë¥Ð¤È¤¤¤¦Á´¤¯¿·¤·¤¤Ì¾Á°²ò·è¤ÎÊýË¡¤¬»È¤ï¤ì¤Æ
-  ¤¤¤Þ¤¹¡£¤³¤Î¥Ñ¥Ã¥Á¤Ï¡¢¤³¤ì¤é¤Ë MDN ¤Îµ¡Ç½¤òÄɲä·¤Þ¤¹¡£¾Ü¤·¤¯¤Ï¡¢¸å
-  ½Ò¤Î¡Ö3. bind9 ¤Ë¥Ñ¥Ã¥Á¤òÅö¤Æ¤Æ»È¤¦¡×¤ò¸æÍ÷¤¯¤À¤µ¤¤¡£
+  bind-9 ¤Ë MDN ¤Îµ¡Ç½¤òÄɲ乤ë¥Ñ¥Ã¥Á¤Ç¤¹¡£`dig'¡¢`host'¡¢`nslookup'
+  ¤Ë¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°ÊÑ´¹¤È NAMEPREP ¤Îµ¡Ç½¤òÄɲä·¡¢Â¿¸À¸ì¥É¥á¥¤¥ó̾¤¬
+  °·¤¨¤ë¤è¤¦¤Ë¤·¤Þ¤¹¡£
 
 ¡¦Windows ¥¢¥×¥ê¥±¡¼¥·¥ç¥óÍѤΠmDN ¥é¥Ã¥Ñ¡¼
   WINSOCK ¤Î̾Á°²ò·èµ¡Ç½¤ËÂФ¹¤ë¥é¥Ã¥Ñ¡¼ DLL ¤Ç¤¹¡£Windows ¾å¤Ç¤Ï¡¢Ì¾
@@ -50,14 +65,10 @@ mDNkit 
 
 ¡¦named.conf ¤ª¤è¤Ó¥¾¡¼¥ó¥Þ¥¹¥¿¥Õ¥¡¥¤¥ëÍÑ¥³¡¼¥É¥»¥Ã¥È¥³¥ó¥Ð¡¼¥¿ (mdnconv)
   named.conf ¤ª¤è¤Ó¥¾¡¼¥ó¥Þ¥¹¥¿¥Õ¥¡¥¤¥ë¤òÂоݤȤ·¤¿¥³¡¼¥É¥»¥Ã¥È (¥¨¥ó
-  ¥³¡¼¥Ç¥£¥ó¥°)ÊÑ´¹Íѥġ¼¥ë¤Ç¤¹¡£SJIS ¤Ê¤É¤Î¥í¡¼¥«¥ë¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°¤Ç
-  ½ñ¤«¤ì¤¿¤³¤ì¤é¤Î¥Õ¥¡¥¤¥ë¤ò¡¢Â¿¸À¸ì²½ DNS ¤Ç»ÈÍѤ¹¤ë¥¨¥ó¥³¡¼¥Ç¥£¥ó¥° 
-  (Î㤨¤ÐUTF-8) ¤Ø¤ÈÊÑ´¹¤·¤Þ¤¹¡£
+  ¥³¡¼¥Ç¥£¥ó¥°) ÊÑ´¹Íѥġ¼¥ë¤Ç¤¹¡£SJIS ¤Ê¤É¤Î¥í¡¼¥«¥ë¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°
+  ¤Ç½ñ¤«¤ì¤¿¤³¤ì¤é¤Î¥Õ¥¡¥¤¥ë¤ò¡¢IDN ¥¨¥ó¥³¡¼¥Ç¥£¥ó¥° (Î㤨¤Ð RACE) ¤Ø
+  ¤ÈÊÑ´¹¤·¤Þ¤¹¡£
 
-¡¦Â¿¸À¸ì¥É¥á¥¤¥ó̾¤ò½èÍý¤¹¤ë¤¿¤á¤Î¥é¥¤¥Ö¥é¥ê (libmdn, libmdnres)
-  dnsproxy ¤ä mdnconv ¤¬ÍøÍѤ·¤Æ¤¤¤ë¥é¥¤¥Ö¥é¥ê¤Ç¤¹¡£¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°ÊÑ
-  ´¹¤äÀµµ¬²½¡¢ZLD (zero-level domain) ¤Î½èÍýÅù¤Îµ¡Ç½¤òÄ󶡤·¤Þ¤¹¡£
-  
 ¡¦bind-8 ¤ò 8 ¥Ó¥Ã¥È¥¹¥ë¡¼²½¤¹¤ë¥Ñ¥Ã¥Á
   named ¤ä¥ê¥¾¥ë¥Ð¤Ç¥í¡¼¥«¥ë¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°¤ä UTF-8 ¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°
   ¤Î¥É¥á¥¤¥ó̾¤ò»ÈÍѲÄǽ¤Ë¤¹¤ë¤¿¤á¤Î¥Ñ¥Ã¥Á¤Ç¤¹¡£8¥Ó¥Ã¥È¥¹¥ë¡¼¤Ê¤Î¤Ç¤Û
@@ -72,43 +83,57 @@ mDNkit 
 ¤³¤ÎÇÛÉÛ¥­¥Ã¥È¤Ï¡¢°Ê¾å¤Î¤â¤Î¤òÍѤ¤¤Æ¡¢Â¿¸À¸ì¥É¥á¥¤¥ó̾¤ò°·¤¦¤¿¤á¤ÎÊ£¿ô
 ¤ÎÊýË¡¤òÄ󶡤·¤Æ¤¤¤Þ¤¹¡£
 
- ** 1. dnsproxy ¤ò»È¤¦
-
-                    ¥í¡¼¥«¥ë¥¨¥ó  ¥¨¥ó¥³¡¼¥Ç¥£¥ó  DNS ¥×¥í¥È¥³¥ë¾å¤Î
-                    ¥³¡¼¥É¥£¥ó¥°  ¥°ÊÑ´¹¤ª¤è¤ÓÀµ  ¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°¤Î
-   +----------------+¤Î¥É¥á¥¤¥ó̾  µ¬²½                   ¥É¥á¥¤¥ó̾
-   |¥¯¥é¥¤¥¢¥ó¥È    |             +--------------+             +------+
-   |¥¢¥×¥ê¥±¡¼¥·¥ç¥ó|------------>|   dnsproxy   |------------>| DNS  |
+ ** 1. API ¤ò»È¤¦
+    Â¿¸À¸ì¥É¥á¥¤¥ó̾¤ò°·¤¦¤¿¤á¤ÎÊý¼°¤È¤·¤Æ¤Ï¤³¤ÎÊýË¡¤¬¿ä¾©¤µ¤ì¤Æ¤¤¤Þ¤¹¡£
+    ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ï mDNkit ¤ÎÄ󶡤¹¤ë API ¤òÌÀ¼¨Åª¤Ë¸Æ¤Ó½Ð¤·¤Æ
+    ¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°ÊÑ´¹¤ä NAMEPREP ¤ò¹Ô¤¤¤Þ¤¹¡£
+    
+                                 ACE ¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°¤Î
+   +----------------+-------+--------+ ¥É¥á¥¤¥ó̾
+   |                |       |        |            +------------+
+   |  ¥¯¥é¥¤¥¢¥ó¥È  |  mdn  |¥·¥¹¥Æ¥à|----------->| DNS ¥µ¡¼¥Ð |
+   |¥¢¥×¥ê¥±¡¼¥·¥ç¥ó|library| ÉÕ°¤Î |<-----------|            |
+   |                |       |¥ê¥¾¥ë¥Ð|            +------------+
+   +----------------+-------+--------+ 
+
+ ** 2. mdnsproxy ¤ò»È¤¦
+    ¾åµ­¤Î API ¤ò»È¤¦¤è¤¦¤Ë¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤ò½¤Àµ¤Ç¤­¤Ê¤¤¾ì¹ç¤Ç¤â¡¢
+    mdnsproxy ¤ò»ÈÍѤ¹¤ì¤Ð¿¸À¸ì¥É¥á¥¤¥ó̾¤Î̾Á°²ò·è¤ò¹Ô¤¦¤³¤È¤¬
+    ²Äǽ¤Ç¤¹¡£¤¿¤À¤·¤³¤Î¾ì¹ç¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤¬ 8 ¥Ó¥Ã¥È¥¹¥ë¡¼¤Î
+    ¥ê¥¾¥ë¥Ð¤ò»È¤Ã¤Æ¤¤¤ë¤³¤È¤¬Á°Äó¤È¤Ê¤ê¤Þ¤¹¡£
+
+                    ¥í¡¼¥«¥ë¥¨¥ó  ¥¨¥ó¥³¡¼¥Ç¥£¥ó  ACE¥¨¥ó¥³¡¼¥Ç¥£
+                    ¥³¡¼¥É¥£¥ó¥°  ¥°ÊÑ´¹¤ª¤è¤ÓÀµ  ¥ó¥°¤Î¥É¥á¥¤¥ó̾
+   +----------------+¤Î¥É¥á¥¤¥ó̾  µ¬²½                   
+   |  ¥¯¥é¥¤¥¢¥ó¥È  |             +--------------+             +------+
+   |¥¢¥×¥ê¥±¡¼¥·¥ç¥ó|------------>|  mdnsproxy   |------------>| DNS  |
    |¤È 8¥Ó¥Ã¥È¥¹¥ë¡¼|<------------|              |<------------|¥µ¡¼¥Ð|
-   |²½¤·¤¿¥ê¥¾¥ë¥Ð  |             +--------------+             +------+
+   | ²½¤·¤¿¥ê¥¾¥ë¥Ð |             +--------------+             +------+
    +----------------+
 
- ** 2. runmdn ¤ò»È¤¦
-
-                    ¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°ÊÑ´¹  DNS ¥×¥í¥È¥³¥ë¾å¤Î
-                    ¤ª¤è¤ÓÀµµ¬²½          ¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°¤Î
-   +----------------+------------------+   ¥É¥á¥¤¥ó̾
-   |¥¯¥é¥¤¥¢¥ó¥È    |ưŪ¤Ë¥ê¥ó¥¯¤µ¤ì¤¿|                 +------+
+ ** 3. runmdn ¤ò»È¤¦
+    ¤¢¤ë¤¤¤Ï¡¢¥¯¥é¥¤¥¢¥ó¥È¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤¬Ì¾Á°²ò·è ÍѤΠAPI
+    (gethostbyname ¤Ê¤É) ¤òưŪ¤Ë¥ê¥ó¥¯¤·¡¢¤«¤Ä OS ¤¬Å¬Àڤʵ¡Ç½¤ò
+    È÷¤¨¤Æ¤¤¤ë¾ì¹ç¤Ë¤Ï runmdn ¤ò»È¤¦¤³¤È¤â¤Ç¤­¤Þ¤¹¡£Ì¾Á°²ò·èÍѤÎ
+    API ¤ò¡¢¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°ÊÑ´¹¤ä NAMEPREP µ¡Ç½¤òÈ÷¤¨¤¿¥Ð¡¼¥¸¥ç¥ó¤Î
+    ¤â¤Î¤ËưŪ¤ËÃÖ´¹¤¨¤ë¤³¤È¤Ë¤è¤ê¡¢Ä̾ï¤Î¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤¬Â¿¸À¸ì
+    ¥É¥á¥¤¥ó̾¤ò̾Á°²ò·è¤Ç¤­¤ë¤è¤¦¤Ë¤·¤Þ¤¹¡£
+
+                    ¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°ÊÑ´¹  ACE¥¨¥ó¥³¡¼¥Ç¥£
+                    ¤ª¤è¤ÓÀµµ¬²½          ¥ó¥°¤Î¥É¥á¥¤¥ó̾
+   +----------------+------------------+   
+   |  ¥¯¥é¥¤¥¢¥ó¥È  |ưŪ¤Ë¥ê¥ó¥¯¤µ¤ì¤¿|                 +------+
    |¥¢¥×¥ê¥±¡¼¥·¥ç¥ó|    ¥é¥¤¥Ö¥é¥ê    |---------------->| DNS  |
-   |¤ÈÄ̾ï¤Î¥ê¥¾¥ë¥Ð|   (libmdnres)    |<----------------|¥µ¡¼¥Ð|
+   |¤ÈÄ̾ï¤Î¥ê¥¾¥ë¥Ð|                  |<----------------|¥µ¡¼¥Ð|
    +----------------+------------------+                 +------+
 
- ** 3. bind9 ¤Ë¥Ñ¥Ã¥Á¤òÅö¤Æ¤Æ»È¤¦
-
-                    UTF-8 ¤Î¥É    ¥¨¥ó¥³¡¼¥Ç¥£    DNS ¥×¥í¥È¥³¥ë¾å¤Î
-                    ¥á¥¤¥ó̾      ¥ó¥°ÊÑ´¹¤ª¤è    ¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°¤Î
-   +----------------+             ¤ÓÀµµ¬²½        ¥É¥á¥¤¥ó̾
-   |¥¯¥é¥¤¥¢¥ó¥È    |           +----------------+             +------+
-   |¥¢¥×¥ê¥±¡¼¥·¥ç¥ó|---------->| ¥é¥¤¥È¥¦¥§¥¤¥È |------------>| DNS  |
-   |¤È bind9¤Î¥é¥¤¥È|-----------|    ¥ê¥¾¥ë¥Ð    |<------------|¥µ¡¼¥Ð|
-   |¥¦¥§¥¤¥È¥ê¥¾¥ë¥Ð|           |    ¥Ç¡¼¥â¥ó    |             +------+
-   +----------------+           +----------------+
-
  ** 4. mDN ¥é¥Ã¥Ñ¡¼¤ò»È¤¦
+    WINSOCK DLL ¤ò¥é¥Ã¥×¤¹¤ë¤³¤È¤Ë¤è¤ê¡¢mDN ¥é¥Ã¥Ñ¡¼¤Ï Windows ¤Î
+    ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤¬Â¿¸À¸ì¥É¥á¥¤¥ó̾¤ò̾Á°²ò·è¤Ç¤­¤ë¤è¤¦¤Ë¤·¤Þ¤¹¡£
 
-                     ¥í¡¼¥«¥ë¥¨  Àµµ¬²½¤ª¤è¤Ó          DNS ¥×¥í¥È¥³¥ë¾å¤Î
-                     ¥ó¥³¡¼¥Ç¥£  ¥¨¥ó¥³¡¼¥Ç¥£          ¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°¤Î
-   +----------------+ ¥ó¥°¤Î¥É¥á  ¥ó¥°ÊÑ´¹             ¥É¥á¥¤¥ó̾
+                     ¥í¡¼¥«¥ë¥¨  Àµµ¬²½¤ª¤è¤Ó          ACE¥¨¥ó¥³¡¼¥Ç¥£
+                     ¥ó¥³¡¼¥Ç¥£  ¥¨¥ó¥³¡¼¥Ç¥£          ¥ó¥°¤Î¥É¥á¥¤¥ó̾
+   +----------------+ ¥ó¥°¤Î¥É¥á  ¥ó¥°ÊÑ´¹             
    |½¾Íè¤Î Windows  | ¥¤¥ó̾    +---------+------------+           +------+
    |¥Í¥Ã¥È¥ï¡¼¥¯    |---------->|   mDN   | ¥ª¥ê¥¸¥Ê¥ë |---------->| DNS  |
    |¥¢¥×¥ê¥±¡¼¥·¥ç¥ó|<----------| ¥é¥Ã¥Ñ¡¼|  winsock   |<----------|¥µ¡¼¥Ð|
@@ -129,17 +154,18 @@ mDNkit 
        include/                ¥¤¥ó¥¯¥ë¡¼¥É¥Õ¥¡¥¤¥ë¥Ç¥£¥ì¥¯¥È¥ê
            config.h.in         config.h ¤Î¥Æ¥ó¥×¥ì¡¼¥È
            mdn/                mdn ¥é¥¤¥Ö¥é¥êÍÑ¥¤¥ó¥¯¥ë¡¼¥É¥Õ¥¡¥¤¥ë
-       dnsproxy/               DNS ¥×¥í¥­¥·¥µ¡¼¥Ð¥½¡¼¥¹
        lib/                    mdn ¥é¥¤¥Ö¥é¥ê¥½¡¼¥¹
-       wsock/                  mDN ¥é¥Ã¥Ñ¡¼¥½¡¼¥¹
-       tools/                  ¼þÊեġ¼¥ë
-           mdnconv/            ¥³¡¼¥É¥»¥Ã¥È¥³¥ó¥Ð¡¼¥¿¥½¡¼¥¹
-           runmdn/             runmdn ¥³¥Þ¥ó¥É¥½¡¼¥¹
+       mdnsproxy/              DNS ¥×¥í¥­¥·¥µ¡¼¥Ð¥½¡¼¥¹
        patch/                  ³Æ¼ï¥Ñ¥Ã¥Á¥Õ¥¡¥¤¥ë
            bind8/              bind8 ÍѥѥåÁ
            bind9/              bind9 ÍѥѥåÁ
+           libiconv/           libiconv ÍѥѥåÁ
            squid/              squid ÍѥѥåÁ
+       tools/                  ¼þÊեġ¼¥ë
+           mdnconv/            ¥³¡¼¥É¥»¥Ã¥È¥³¥ó¥Ð¡¼¥¿¥½¡¼¥¹
+           runmdn/             runmdn ¥³¥Þ¥ó¥É¥½¡¼¥¹
        util/                   ¥æ¡¼¥Æ¥£¥ê¥Æ¥£
+       wsock/                  mDN ¥é¥Ã¥Ñ¡¼¥½¡¼¥¹
 
 
 * ¥³¥ó¥Ñ¥¤¥ë¤ª¤è¤Ó¥¤¥ó¥¹¥È¡¼¥ë
@@ -154,6 +180,13 @@ mDNkit 
 
 ¤«¤éÆþ¼ê²Äǽ¤Ç¤¹¡£
 
+*Ãí°Õ*
+  ¾åµ­¼ÂÁõ¤ÎºÇ¿·ÈÇ (libiconv-1.6.1) ¤Ï NetBSD 1.5 ¤È¤ÎÁȹç¤ï¤»¤ÇÌäÂ꤬
+  ¤¢¤ê¡¢¥³¥ó¥Ñ¥¤¥ë»þ¤Ë¥¨¥é¡¼¤¬È¯À¸¤·¤Þ¤¹¡£¤³¤Î¥Ð¥°¤ò½¤Àµ¤¹¤ë¤¿¤á¤Î¥Ñ¥Ã
+  ¥Á¤¬ patch/libiconv ¥Ç¥£¥ì¥¯¥È¥ê¤Î²¼¤ËÍѰդµ¤ì¤Æ¤¤¤Þ¤¹¤Î¤Ç¡¢¤³¤ÎÌäÂê
+  ¤ËÁø¶ø¤·¤¿¾ì¹ç¤Ë¤Ï¥Ñ¥Ã¥Á¤òÅö¤Æ¤Æ¤«¤éºÆ¥¤¥ó¥¹¥È¡¼¥ë¤·¤Æ¤¯¤À¤µ¤¤¡£¤Ê¤ª¡¢
+  ¥Ñ¥Ã¥Á¤ÎÅö¤ÆÊý¤Ï¥Ñ¥Ã¥Á¥Õ¥¡¥¤¥ë¤ÎÀèÆ¬¤Ë½ñ¤«¤ì¤Æ¤¤¤Þ¤¹¡£
+
 1. configure ¥¹¥¯¥ê¥×¥È¤Î¼Â¹Ô
 
 ¥È¥Ã¥×¥Ç¥£¥ì¥¯¥È¥ê¤Ë¤¢¤ë configure ¥¹¥¯¥ê¥×¥È¤ò¼Â¹Ô¤·¤Æ¤¯¤À¤µ¤¤¡£
@@ -194,25 +227,48 @@ mdn 
 
                --with-utf8=utf8
 
+    --with-preference=PREFERENCE
+       mDNkit ¤Î¥µ¥ó¥×¥ë¥³¥ó¥Õ¥£¥®¥å¥ì¡¼¥·¥ç¥ó¥Õ¥¡¥¤¥ë (mdn.conf.sample) 
+       ¤ÎÀßÄê¤ò PREFERENCE ¸þ¤±¤Î¤â¤Î¤Ë¤·¤Þ¤¹¡£¤Þ¤¿¤³¤Î¥ª¥×¥·¥ç¥ó¤ò»ØÄê
+       ¤¹¤ë¤È¥Ç¥Õ¥©¥ë¥È¤Î¥³¥ó¥Õ¥£¥®¥å¥ì¡¼¥·¥ç¥ó¥Õ¥¡¥¤¥ë (mdn.conf) ¤¬
+       ¥¤¥ó¥¹¥È¡¼¥ë¤µ¤ì¤Þ¤¹¡£¤¿¤À¤·¥Õ¥¡¥¤¥ë¤¬¤¹¤Ç¤Ë¸ºß¤·¤Æ¤¤¤ë¾ì¹ç¤Ë¤Ï
+       ¥¤¥ó¥¹¥È¡¼¥ë¤·¤Þ¤»¤ó¡£
+       ¸½ºß¤Î¤È¤³¤í¡¢»ØÄê¤Ç¤­¤ë PREFERENCE ¤Ï "jp" ¤Î¤ß¤Ç¤¹¡£
+
     --with-race-prefix=PREFIX
     --with-brace-suffix=SUFFIX
     --with-lace-prefix=PREFIX
+    --with-dude-prefix=PREFIX
        RACE (Row-based ASCII-Compatible Encoding)¡¢BRACE (Bi-mode
-       Row-based ASCII-Compatible Encoding) ¤ª¤è¤Ó LACE (Length-based
-       ASCII Compatible Encoding) ¤Ï¤¤¤º¤ì¤â DNS ¥×¥í¥È¥³¥ë
-       ¾å¤Ç»ÈÍѤµ¤ì¤ë¿¸À¸ì¥É¥á¥¤¥ó̾¤Ë´Ø¤·¤ÆÄ󰯤µ¤ì¤Æ¤¤¤ë¥¨¥ó¥³¡¼¥Ç¥£
-       ¥ó¥°Êý¼°¤Ç¤¹¡£Ä̾ï¤Î ASCII ¥É¥á¥¤¥ó̾¤È¤³¤ì¤é¤Ë¤è¤Ã¤Æ¥¨¥ó¥³¡¼
-       ¥É¤µ¤ì¤¿¥É¥á¥¤¥ó̾¤ò¶èÊ̤¹¤ë¤¿¤á¤Ë¡¢¸ÇÄê¤ÎÀÜÆ¬¼­ (BRACE ¤Î¾ì¹ç
-       ¤Ë¤ÏÀÜÈø¼­) ¤¬ÍѤ¤¤é¤ì¤Þ¤¹¡£
-
+       Row-based ASCII-Compatible Encoding)¡¢ LACE (Length-based
+       ASCII Compatible Encoding) ¤ª¤è¤Ó DUDE (Differential Unicode
+       Domain Encoding) ¤Ï¤¤¤º¤ì¤â DNS ¥×¥í¥È¥³¥ë¾å¤Ç»ÈÍѤµ¤ì¤ë¿¸À¸ì
+       ¥É¥á¥¤¥ó̾¤Ë´Ø¤·¤ÆÄ󰯤µ¤ì¤Æ¤¤¤ë¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°Êý¼°¤Ç¤¹¡£Ä̾ï
+       ¤Î ASCII ¥É¥á¥¤¥ó̾¤È¤³¤ì¤é¤Ë¤è¤Ã¤Æ¥¨¥ó¥³¡¼¥É¤µ¤ì¤¿¥É¥á¥¤¥ó̾
+       ¤ò¶èÊ̤¹¤ë¤¿¤á¤Ë¡¢¸ÇÄê¤ÎÀÜÆ¬¼­ (BRACE ¤Î¾ì¹ç¤Ë¤ÏÀÜÈø¼­) ¤¬ÍѤ¤
+       ¤é¤ì¤Þ¤¹¡£
        mDNkit ¤Ç¤Ï¸½ºß¤Î¥¤¥ó¥¿¡¼¥Í¥Ã¥È¥É¥é¥Õ¥È¤ÇÄêµÁ¤µ¤ì¤Æ¤¤¤ëÀÜÆ¬¼­
        ¤¢¤ë¤¤¤ÏÀÜÈø¼­¤ò»ÈÍѤ¹¤ë¤è¤¦¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹¤¬¡¢º£¸å¤Î¥É¥é¥Õ¥È¤Ç
        ÊѤï¤ë¤«¤â¤·¤ì¤Þ¤»¤ó¡£¤½¤³¤Ç¡¢¤³¤ì¤é¤Î¥ª¥×¥·¥ç¥ó¤òÍѤ¤¤Æ»ØÄê¤Ç
        ¤­¤ë¤è¤¦¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡£
 
-    --enable-zld
-       ZLD (zero level domain) ¤Ï¡¢¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï»ÈÍѤǤ­¤Þ¤»¤ó¡£¤³¤Î
-       µ¡Ç½¤ò»ÈÍѤ·¤¿¤¤¤È¤­¤Ë¡¢¤³¤Î¥ª¥×¥·¥ç¥ó¤ò»ØÄꤷ¤Þ¤¹¡£
+    --with-altdude-prefix=PREFIX
+    --with-altdude-suffix=SUFFIX
+    --with-amc-ace-m-prefix=PREFIX
+    --with-amc-ace-m-suffix=SUFFIX
+    --with-amc-ace-o-prefix=PREFIX
+    --with-amc-ace-o-suffix=SUFFIX
+    --with-amc-ace-r-prefix=PREFIX
+       AltDUDE¡¢AMC-ACE-M¡¢AMC-ACE-O ¤ª¤è¤Ó AMC-ACE-R ¤â RACE ¤Ê¤É¤È
+       Æ±ÍͤË¿¸À¸ì¥É¥á¥¤¥ó¤Î¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°¤È¤·¤ÆÄ󰯤µ¤ì¤Æ¤¤¤ë¤â¤Î
+       ¤Ç¤¹¡£¤¿¤À¤·¤³¤ì¤é¤Î¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°¤Ï RACE ¤Ê¤É¾å¤Ë¤¢¤²¤¿¤â¤Î
+       ¤È°Û¤Ê¤ê¡¢¥¤¥ó¥¿¡¼¥Í¥Ã¥È¥É¥é¥Õ¥È¤Ç¤ÏÆÃÄê¤ÎÀÜÆ¬¼­¡¢ÀÜÈø¼­¤¬ÄêµÁ
+       ¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£mDNkit ¤Ç¤Ï¥Ç¥Õ¥©¥ë¥È¤ÎÀÜÆ¬¼­/ÀÜÈø¼­¤òÀßÄꤷ¤Æ
+       ¤¢¤ê¤Þ¤¹¤¬¡¢¤³¤³¤Ë¤¢¤²¤¿¥ª¥×¥·¥ç¥ó¤ò»ÈÍѤ¹¤ì¤ÐÊ̤Τâ¤Î¤ËÊѹ¹¤¹
+       ¤ë¤³¤È¤¬²Äǽ¤Ç¤¹¡£
+       AltDUDE¡¢AMC-ACE-M ¤ª¤è¤Ó AMC-ACE-O ¤Ë¤Ä¤¤¤Æ¤Ï¡¢ÀÜÆ¬¼­¡¢ÀÜÈø¼­
+       ¤Î¤É¤Á¤é¤ò»ØÄꤹ¤ë¤³¤È¤â²Äǽ¤Ç¤¹¡£¤â¤·ÀÜÆ¬¼­¤ÈÀÜÈø¼­¤ÎξÊý¤¬»Ø
+       Äꤵ¤ì¤¿¾ì¹ç¤Ë¤Ï¡¢ÀÜÆ¬¼­¤Î»ØÄ꤬ͥÀ褵¤ì¤Þ¤¹¡£
 
     --sbindir=DIR
        DNS ¥×¥í¥­¥·¥µ¡¼¥Ð¤ò¥¤¥ó¥¹¥È¡¼¥ë¤¹¤ë¥Ç¥£¥ì¥¯¥È¥ê¤ò»ØÄꤷ¤Þ¤¹¡£
@@ -265,22 +321,22 @@ configure 
 
 4. Configuration and usage
 
-¥¤¥ó¥¹¥È¡¼¥ë¤µ¤ì¤ë¥Ä¡¼¥ë (dnsproxy¡¢mdnconv¡¢runmdn) ¤Î»È¤¤Êý¡¢ÀßÄêÊý
+¥¤¥ó¥¹¥È¡¼¥ë¤µ¤ì¤ë¥Ä¡¼¥ë (mdnsproxy¡¢mdnconv¡¢runmdn) ¤Î»È¤¤Êý¡¢ÀßÄêÊý
 Ë¡¤Ë´Ø¤·¤Æ¤Ï¥ª¥ó¥é¥¤¥ó¥Þ¥Ë¥å¥¢¥ë¤ò¤´Í÷¤¯¤À¤µ¤¤¡£mdnconv ¤È runmdn ¤Ë¤Ä
-¤¤¤Æ¤Ï¡¢mDNkit ¤Î¥ê¥¾¥ë¥ÐÀßÄê¥Õ¥¡¥¤¥ë mdnres.conf ¤Î¥Þ¥Ë¥å¥¢¥ë¤â»²¾È¤·
Ƥ¯¤À¤µ¤¤¡£
+¤¤¤Æ¤Ï¡¢mDNkit ¤Î¥ê¥¾¥ë¥ÐÀßÄê¥Õ¥¡¥¤¥ë mdn.conf ¤Î¥Þ¥Ë¥å¥¢¥ë¤â»²¾È¤·¤Æ
+¤¯¤À¤µ¤¤¡£
 
-       % man dnsproxy
+       % man mdnsproxy
        % man mdnconv
        % man runmdn
-       % man mdnres.conf
+       % man mdn.conf
 
 
 * ¥Ñ¥Ã¥Á¤ÎÅö¤ÆÊý
 
-¤³¤ÎÇÛÉÛ¥­¥Ã¥È¤Ë¤Ï¡¢bind-8.2.2-P7¡¢bind-8.2.3-T9B¡¢bind-9.0.1¡¢¤ª¤è¤Ó 
-squid-2.3-STABLE3 ¤ËÂФ¹¤ë¥Ñ¥Ã¥Á¤¬´Þ¤Þ¤ì¤Æ¤¤¤Þ¤¹¡£¥Ñ¥Ã¥Á¤ÎÅö¤ÆÊý¤Ï¡¢¥Ñ¥Ã
-¥Á¥Õ¥¡¥¤¥ë¤ÎÀèÆ¬¤Ë½ñ¤«¤ì¤Æ¤¤¤Þ¤¹¤Î¤Ç¤½¤Á¤é¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£
+¤³¤ÎÇÛÉÛ¥­¥Ã¥È¤Ë¤Ï¡¢bind-9.1.1¡¢bind-8.2.3 ¤ª¤è¤Ó squid-2.4-STABLE1 ¤Ë
+ÂФ¹¤ë¥Ñ¥Ã¥Á¤¬´Þ¤Þ¤ì¤Æ¤¤¤Þ¤¹¡£¥Ñ¥Ã¥Á¤ÎÅö¤ÆÊý¤Ï¡¢¥Ñ¥Ã¥Á¥Õ¥¡¥¤¥ë¤ÎÀèÆ¬¤Ë
+½ñ¤«¤ì¤Æ¤¤¤Þ¤¹¤Î¤Ç¤½¤Á¤é¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£
 
 Solaris ¤Ç¤Ï¡¢¥·¥¹¥Æ¥àÉÕ°¤Î patch ¥³¥Þ¥ó¥É¤¬Àµ¾ï¤Ëưºî¤·¤Ê¤¤¤³¤È¤¬¤¢
 ¤ê¤Þ¤¹¡£¤½¤Î¤è¤¦¤Ê¾ì¹ç¤Ë¤Ï¡¢GNU ¥Ð¡¼¥¸¥ç¥ó¤Î patch
@@ -297,4 +353,4 @@ http://www.nic.ad.jp/jp/research/idn/ 
 mdnkit-bugs@nic.ad.jp ¤ª¤è¤Ó idn-cmt@nic.ad.jp ¤Ø¤ª´ê¤¤¤·¤Þ¤¹¡£
 
 
-; $Id: README.ja,v 1.20 2000/12/28 04:09:28 ishisone Exp $
+; $Id: README.ja,v 1.29 2001/06/01 01:13:46 ishisone Exp $
index f1fdd3cac38da98cbc7bd17af280475740cd2ded..6915f20aa01969afc445f61b495b2299026ae133 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: acconfig.h,v 1.4 2000/11/17 06:51:11 ishisone Exp $ */
+/* $Id: acconfig.h,v 1.8 2001/04/18 02:07:32 ishisone Exp $ */
 /*
  * Copyright (c) 2000 Japan Network Information Center.  All rights reserved.
  *  
  */
 @TOP@
 
-/* Define if your iconv() does not accept "UTF-8" as the codeset name for utf-8. */
-#undef MDN_UTF8_ENCODING_NAME
-
-/* Define if you want ZLD feature compiled in. */
-#undef MDN_SUPPORT_ZLD
+/* Define as an appropriate type (ex. int) if your system doesn't have. */
+#undef BOOL
 
-/* Define if the prefix of RACE encoding differs from 'bq--'. */
-#undef MDN_RACE_PREFIX
+/* Define if the prototype of gethost*_r is glibc flavor. */
+#undef GETHOST_R_GLIBC_FLAVOR
 
-/* Define if the suffix of BRACE encoding differs from '-8q9'. */
-#undef MDN_BRACE_SUFFIX
+/* Define as the type of the 2nd argument of gethostbyaddr. */
+#undef GHBA_ADDRLEN_T
 
-/* Define if the prefix of LACE encoding differs from 'bq--'. */
-#undef MDN_LACE_PREFIX
+@BOTTOM@
+/* Define as the pathname of the shared libc object if your system has one. */
+#undef SOPATH_LIBC
 
-/* Define as an appropriate type (ex. int) if your system doesn't have. */
-#undef BOOL
+/* Define as the pathname of the shared libnsl object if your system has one. */
+#undef SOPATH_LIBNSL
index c41d84aa471080a60ed52dc3fc6e1fd924971061..1ddc51a97357592dfd09b602f484260e00270216 100644 (file)
@@ -1,3 +1,126 @@
+##
+## $Id: aclocal.m4,v 1.5 2001/04/19 07:20:51 ishisone Exp $
+##
+dnl
+dnl AC_ACE_PREFIX(ace-name, default)
+dnl AC_ACE_SUFFIX(ace-name, default)
+dnl AC_ACE_SIGNATURE(ace-name, prefix-default, suffix-default)
+dnl
+define([AC_ACE_PREPARE], [dnl
+undefine([ACE_ID])undefine([ACE_PSYM])undefine([ACE_SSYM])dnl
+define([ACE_ID],translit($1,[A-Z_],[a-z-]))dnl
+define([ACE_PSYM],[MDN_]translit(ACE_ID,[a-z-],[A-Z])[_PREFIX])dnl
+define([ACE_SSYM],[MDN_]translit(ACE_ID,[a-z-],[A-Z])[_SUFFIX])])dnl
+dnl
+AC_DEFUN([AC_ACE_PREFIX],[AC_ACE_PREPARE($1)dnl
+ace_prefix=no
+AC_ARG_WITH(ACE_ID-prefix,
+[  --with-]ACE_ID[-prefix=PREFIX  prefix for $1 encoding [$2]],
+       ace_prefix=$withval)
+case "${ace_prefix}" in
+no)
+    ace_prefix="$2"
+    ;;
+yes)
+    AC_MSG_ERROR([You must specify PREFIX to --with-ACE_ID-prefix option.])
+    ;;
+esac
+if test "${ace_prefix}" != ""; then
+    AC_DEFINE_UNQUOTED(ACE_PSYM, "${ace_prefix}",
+      [Define if the prefix of $1 encoding differs from '$2'.])
+fi
+])
+AC_DEFUN([AC_ACE_SUFFIX],[AC_ACE_PREPARE($1)dnl
+ace_suffix=no
+AC_ARG_WITH(ACE_ID-suffix,
+[  --with-]ACE_ID[-suffix=SUFFIX  suffix for $1 encoding [$2]],
+       ace_suffix=$withval)
+case "${ace_suffix}" in
+no)
+    ace_suffix="$2"
+    ;;
+yes)
+    AC_MSG_ERROR([You must specify SUFFIX to --with-ACE_ID-suffix option.])
+    ;;
+esac
+if test "${ace_suffix}" != ""; then
+    AC_DEFINE_UNQUOTED(ACE_SSYM, "${ace_suffix}",
+      [Define if the suffix of $1 encoding differs from '$2'.])
+fi
+])
+AC_DEFUN([AC_ACE_SIGNATURE],[AC_ACE_PREPARE($1)dnl
+ace_prefix=no
+ace_suffix=no
+AC_ARG_WITH(ACE_ID-prefix,
+[  --with-]ACE_ID[-prefix=PREFIX  prefix for $1 encoding [$2]],
+       ace_prefix=$withval)
+case "${ace_prefix}" in
+no)
+    ace_prefix=""
+    ;;
+yes)
+    AC_MSG_ERROR([You must specify PREFIX to --with-ACE_ID-prefix option.])
+    ;;
+esac
+AC_ARG_WITH(ACE_ID-suffix,
+[  --with-]ACE_ID[-suffix=SUFFIX  suffix for $1 encoding [$3]],
+       ace_suffix=$withval)
+case "${ace_suffix}" in
+no)
+    ace_suffix=""
+    ;;
+yes)
+    AC_MSG_ERROR([You must specify SUFFIX to --with-ACE_ID-suffix option.])
+    ;;
+esac
+if test "${ace_prefix}${ace_suffix}" = ""; then
+    ace_prefix="$2"
+    ace_suffix="$3"
+fi
+if test "${ace_prefix}" != ""; then
+    AC_DEFINE_UNQUOTED(ACE_PSYM, "${ace_prefix}",
+      [Define if the prefix of $1 encoding differs from '$2'.])
+elif test "${ace_suffix}" != ""; then
+    AC_DEFINE_UNQUOTED(ACE_SSYM, "${ace_suffix}",
+      [Define if the suffix of $1 encoding differs from '$3'.])
+fi
+])
+
+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 | tr a-z A-Z`
+       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
index 4c1fafb2885686a98b543a9b5b5033c2a5b30263..f462b5bb9121550708bbc990054e450a84605ae2 100644 (file)
@@ -12,19 +12,43 @@ ac_help=
 ac_default_prefix=/usr/local
 # Any additions from configure.in:
 ac_help="$ac_help
-  --enable-zld            enable ZLD support. [default=no]"
+  --with-logdir=DIR       mdnsproxy's log files are in DIR.
+                          [default=LOCALSTATEDIR/mdnsproxy]"
+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
-  --with-race-prefix=PREFIX     prefix for RACE encoding [bq--]"
+  --with-race-prefix=PREFIX  prefix for RACE encoding [bq--]"
+ac_help="$ac_help
+  --with-brace-suffix=SUFFIX  suffix for BRACE encoding [-8q9]"
+ac_help="$ac_help
+  --with-lace-prefix=PREFIX  prefix for LACE encoding [lq--]"
+ac_help="$ac_help
+  --with-utf-6-prefix=PREFIX  prefix for UTF-6 encoding [wq--]"
+ac_help="$ac_help
+  --with-dude-prefix=PREFIX  prefix for DUDE encoding [dq--]"
+ac_help="$ac_help
+  --with-altdude-prefix=PREFIX  prefix for AltDUDE encoding [a---]"
+ac_help="$ac_help
+  --with-altdude-suffix=SUFFIX  suffix for AltDUDE encoding []"
+ac_help="$ac_help
+  --with-amc-ace-m-prefix=PREFIX  prefix for AMC-ACE-M encoding []"
 ac_help="$ac_help
-  --with-brace-suffix=PREFIX     suffix for BRACE encoding [-8q9]"
+  --with-amc-ace-m-suffix=SUFFIX  suffix for AMC-ACE-M encoding [-amc1]"
 ac_help="$ac_help
-  --with-lace-prefix=PREFIX     prefix for LACE encoding [bq--]"
+  --with-amc-ace-o-prefix=PREFIX  prefix for AMC-ACE-O encoding []"
+ac_help="$ac_help
+  --with-amc-ace-o-suffix=SUFFIX  suffix for AMC-ACE-O encoding [-amc2]"
+ac_help="$ac_help
+  --with-amc-ace-r-prefix=PREFIX  prefix for AMC-ACE-R encoding [amc3-]"
 ac_help="$ac_help
   --with-iconv=LIB        special library for iconv []"
 ac_help="$ac_help
-  --with-iconv-sofile=PATH        shared library file for libiconv []"
+  --with-iconv-sofile=PATH shared library file for libiconv []"
+ac_help="$ac_help
+  --with-preference=ARG   change the default configuration to the one
+                          suitable for ARG."
 ac_help="$ac_help
   --enable-shared[=PKGS]  build shared libraries [default=yes]"
 ac_help="$ac_help
@@ -572,7 +596,7 @@ 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:576: checking host system type" >&5
+echo "configure:600: checking host system type" >&5
 
 host_alias=$host
 case "$host_alias" in
@@ -593,24 +617,41 @@ host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
 echo "$ac_t""$host" 1>&6
 
 
-zld=no
-# Check whether --enable-zld or --disable-zld was given.
-if test "${enable_zld+set}" = set; then
-  enableval="$enable_zld"
-  zld=$enableval
+logdir=no
+# Check whether --with-logdir or --without-logdir was given.
+if test "${with_logdir+set}" = set; then
+  withval="$with_logdir"
+  logdir=$withval
+fi
+
+case "$logdir" in
+no)
+    logdir='${localstatedir}/mdnsproxy'
+    ;;
+yes)
+    { echo "configure: error: You must specify DIR to --with-logdir 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 "$zld" in
+case "$extraace" in
 no)
     ;;
 yes)
     cat >> confdefs.h <<\EOF
-#define MDN_SUPPORT_ZLD 1
+#define MDN_EXTRA_ACE 1
 EOF
 
     ;;
 *)
-    { echo "configure: error: You must specify yes or no to --enable-zld option." 1>&2; exit 1; }
+    { echo "configure: error: You must specify yes or no to --enable-extra-ace option." 1>&2; exit 1; }
     ;;
 esac
 
@@ -635,68 +676,276 @@ EOF
     ;;
 esac
 
-raceprefix=no
+ace_prefix=no
 # Check whether --with-race-prefix or --without-race-prefix was given.
 if test "${with_race_prefix+set}" = set; then
   withval="$with_race_prefix"
-  raceprefix=$withval
+  ace_prefix=$withval
 fi
 
-case "$raceprefix" in
+case "${ace_prefix}" in
 no)
+    ace_prefix="bq--"
     ;;
 yes)
     { echo "configure: error: You must specify PREFIX to --with-race-prefix option." 1>&2; exit 1; }
     ;;
-*)
+esac
+if test "${ace_prefix}" != ""; then
     cat >> confdefs.h <<EOF
-#define MDN_RACE_PREFIX "$raceprefix"
+#define MDN_RACE_PREFIX "${ace_prefix}"
 EOF
 
-    ;;
-esac
+fi
 
-bracesuffix=no
+ace_suffix=no
 # Check whether --with-brace-suffix or --without-brace-suffix was given.
 if test "${with_brace_suffix+set}" = set; then
   withval="$with_brace_suffix"
-  bracesuffix=$withval
+  ace_suffix=$withval
 fi
 
-case "$bracesuffix" in
+case "${ace_suffix}" in
 no)
+    ace_suffix="-8q9"
     ;;
 yes)
     { echo "configure: error: You must specify SUFFIX to --with-brace-suffix option." 1>&2; exit 1; }
     ;;
-*)
+esac
+if test "${ace_suffix}" != ""; then
     cat >> confdefs.h <<EOF
-#define MDN_BRACE_SUFFIX "$bracesuffix"
+#define MDN_BRACE_SUFFIX "${ace_suffix}"
 EOF
 
-    ;;
-esac
+fi
 
-laceprefix=no
+ace_prefix=no
 # Check whether --with-lace-prefix or --without-lace-prefix was given.
 if test "${with_lace_prefix+set}" = set; then
   withval="$with_lace_prefix"
-  laceprefix=$withval
+  ace_prefix=$withval
 fi
 
-case "$laceprefix" in
+case "${ace_prefix}" in
 no)
+    ace_prefix="lq--"
     ;;
 yes)
     { echo "configure: error: You must specify PREFIX to --with-lace-prefix option." 1>&2; exit 1; }
     ;;
-*)
+esac
+if test "${ace_prefix}" != ""; then
+    cat >> confdefs.h <<EOF
+#define MDN_LACE_PREFIX "${ace_prefix}"
+EOF
+
+fi
+
+ace_prefix=no
+# Check whether --with-utf-6-prefix or --without-utf-6-prefix was given.
+if test "${with_utf_6_prefix+set}" = set; then
+  withval="$with_utf_6_prefix"
+  ace_prefix=$withval
+fi
+
+case "${ace_prefix}" in
+no)
+    ace_prefix="wq--"
+    ;;
+yes)
+    { echo "configure: error: You must specify PREFIX to --with-utf-6-prefix option." 1>&2; exit 1; }
+    ;;
+esac
+if test "${ace_prefix}" != ""; then
+    cat >> confdefs.h <<EOF
+#define MDN_UTF6_PREFIX "${ace_prefix}"
+EOF
+
+fi
+
+ace_prefix=no
+# Check whether --with-dude-prefix or --without-dude-prefix was given.
+if test "${with_dude_prefix+set}" = set; then
+  withval="$with_dude_prefix"
+  ace_prefix=$withval
+fi
+
+case "${ace_prefix}" in
+no)
+    ace_prefix="dq--"
+    ;;
+yes)
+    { echo "configure: error: You must specify PREFIX to --with-dude-prefix option." 1>&2; exit 1; }
+    ;;
+esac
+if test "${ace_prefix}" != ""; then
+    cat >> confdefs.h <<EOF
+#define MDN_DUDE_PREFIX "${ace_prefix}"
+EOF
+
+fi
+
+ace_prefix=no
+ace_suffix=no
+# Check whether --with-altdude-prefix or --without-altdude-prefix was given.
+if test "${with_altdude_prefix+set}" = set; then
+  withval="$with_altdude_prefix"
+  ace_prefix=$withval
+fi
+
+case "${ace_prefix}" in
+no)
+    ace_prefix=""
+    ;;
+yes)
+    { echo "configure: error: You must specify PREFIX to --with-altdude-prefix option." 1>&2; exit 1; }
+    ;;
+esac
+# Check whether --with-altdude-suffix or --without-altdude-suffix was given.
+if test "${with_altdude_suffix+set}" = set; then
+  withval="$with_altdude_suffix"
+  ace_suffix=$withval
+fi
+
+case "${ace_suffix}" in
+no)
+    ace_suffix=""
+    ;;
+yes)
+    { echo "configure: error: You must specify SUFFIX to --with-altdude-suffix option." 1>&2; exit 1; }
+    ;;
+esac
+if test "${ace_prefix}${ace_suffix}" = ""; then
+    ace_prefix="a---"
+    ace_suffix=""
+fi
+if test "${ace_prefix}" != ""; then
+    cat >> confdefs.h <<EOF
+#define MDN_ALTDUDE_PREFIX "${ace_prefix}"
+EOF
+
+elif test "${ace_suffix}" != ""; then
+    cat >> confdefs.h <<EOF
+#define MDN_ALTDUDE_SUFFIX "${ace_suffix}"
+EOF
+
+fi
+
+ace_prefix=no
+ace_suffix=no
+# Check whether --with-amc-ace-m-prefix or --without-amc-ace-m-prefix was given.
+if test "${with_amc_ace_m_prefix+set}" = set; then
+  withval="$with_amc_ace_m_prefix"
+  ace_prefix=$withval
+fi
+
+case "${ace_prefix}" in
+no)
+    ace_prefix=""
+    ;;
+yes)
+    { echo "configure: error: You must specify PREFIX to --with-amc-ace-m-prefix option." 1>&2; exit 1; }
+    ;;
+esac
+# Check whether --with-amc-ace-m-suffix or --without-amc-ace-m-suffix was given.
+if test "${with_amc_ace_m_suffix+set}" = set; then
+  withval="$with_amc_ace_m_suffix"
+  ace_suffix=$withval
+fi
+
+case "${ace_suffix}" in
+no)
+    ace_suffix=""
+    ;;
+yes)
+    { echo "configure: error: You must specify SUFFIX to --with-amc-ace-m-suffix option." 1>&2; exit 1; }
+    ;;
+esac
+if test "${ace_prefix}${ace_suffix}" = ""; then
+    ace_prefix=""
+    ace_suffix="-amc1"
+fi
+if test "${ace_prefix}" != ""; then
+    cat >> confdefs.h <<EOF
+#define MDN_AMCACEM_PREFIX "${ace_prefix}"
+EOF
+
+elif test "${ace_suffix}" != ""; then
+    cat >> confdefs.h <<EOF
+#define MDN_AMCACEM_SUFFIX "${ace_suffix}"
+EOF
+
+fi
+
+ace_prefix=no
+ace_suffix=no
+# Check whether --with-amc-ace-o-prefix or --without-amc-ace-o-prefix was given.
+if test "${with_amc_ace_o_prefix+set}" = set; then
+  withval="$with_amc_ace_o_prefix"
+  ace_prefix=$withval
+fi
+
+case "${ace_prefix}" in
+no)
+    ace_prefix=""
+    ;;
+yes)
+    { echo "configure: error: You must specify PREFIX to --with-amc-ace-o-prefix option." 1>&2; exit 1; }
+    ;;
+esac
+# Check whether --with-amc-ace-o-suffix or --without-amc-ace-o-suffix was given.
+if test "${with_amc_ace_o_suffix+set}" = set; then
+  withval="$with_amc_ace_o_suffix"
+  ace_suffix=$withval
+fi
+
+case "${ace_suffix}" in
+no)
+    ace_suffix=""
+    ;;
+yes)
+    { echo "configure: error: You must specify SUFFIX to --with-amc-ace-o-suffix option." 1>&2; exit 1; }
+    ;;
+esac
+if test "${ace_prefix}${ace_suffix}" = ""; then
+    ace_prefix=""
+    ace_suffix="-amc2"
+fi
+if test "${ace_prefix}" != ""; then
+    cat >> confdefs.h <<EOF
+#define MDN_AMCACEO_PREFIX "${ace_prefix}"
+EOF
+
+elif test "${ace_suffix}" != ""; then
     cat >> confdefs.h <<EOF
-#define MDN_LACE_PREFIX "$laceprefix"
+#define MDN_AMCACEO_SUFFIX "${ace_suffix}"
 EOF
 
+fi
+
+ace_prefix=no
+# Check whether --with-amc-ace-r-prefix or --without-amc-ace-r-prefix was given.
+if test "${with_amc_ace_r_prefix+set}" = set; then
+  withval="$with_amc_ace_r_prefix"
+  ace_prefix=$withval
+fi
+
+case "${ace_prefix}" in
+no)
+    ace_prefix="amc3-"
+    ;;
+yes)
+    { echo "configure: error: You must specify PREFIX to --with-amc-ace-r-prefix option." 1>&2; exit 1; }
     ;;
 esac
+if test "${ace_prefix}" != ""; then
+    cat >> confdefs.h <<EOF
+#define MDN_AMCACER_PREFIX "${ace_prefix}"
+EOF
+
+fi
+
 
 iconv=no
 # Check whether --with-iconv or --without-iconv was given.
@@ -741,7 +990,7 @@ guess)
        ICONVSOFILE=none
     else
        echo $ac_n "checking pathname of iconv shared library""... $ac_c" 1>&6
-echo "configure:745: checking pathname of iconv shared library" >&5
+echo "configure:994: checking pathname of iconv shared library" >&5
        ic_libdir=
        ic_libname=
        case "$host" in
@@ -792,6 +1041,32 @@ echo "configure:745: checking pathname of iconv shared library" >&5
 esac
 
 
+CONF_PREFERENCE=no
+INSTALL_DEFAULT_CONF=yes
+# Check whether --with-preference or --without-preference was given.
+if test "${with_preference+set}" = set; then
+  withval="$with_preference"
+  CONF_PREFERENCE=$withval
+fi
+
+CONF_PREFERENCE=`echo $CONF_PREFERENCE | tr A-Z a-z`
+case "$CONF_PREFERENCE" in
+no)
+    CONF_PREFERENCE=default
+    INSTALL_DEFAULT_CONF=no
+    ;;
+yes)
+    { echo "configure: error: You must specify ARG to --with-preference option." 1>&2; exit 1; }
+    ;;
+jp)
+    ;;
+*)
+    { echo "configure: error: Unknown ARG for --with-preference option." 1>&2; exit 1; }
+    ;;
+esac
+
+
+
 PRELOAD_VAR="LD_PRELOAD"
 PRELOAD_SEP=":"
 PRELOAD_LAST=""
@@ -799,6 +1074,9 @@ case "$host" in
 *-solaris*)
     PRELOAD_SEP=" "
     ;;
+*-linux*)
+    PRELOAD_SEP=" "
+    ;;
 *-osf*)
     PRELOAD_VAR="_RLD_LIST"
     PRELOAD_LAST=":DEFAULT"
@@ -811,7 +1089,7 @@ 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:815: checking for $ac_word" >&5
+echo "configure:1093: 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
@@ -841,7 +1119,7 @@ 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:845: checking for $ac_word" >&5
+echo "configure:1123: 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
@@ -892,7 +1170,7 @@ fi
       # 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:896: checking for $ac_word" >&5
+echo "configure:1174: 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
@@ -924,7 +1202,7 @@ fi
 fi
 
 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:928: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+echo "configure:1206: 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.
@@ -935,12 +1213,12 @@ cross_compiling=$ac_cv_prog_cc_cross
 
 cat > conftest.$ac_ext << EOF
 
-#line 939 "configure"
+#line 1217 "configure"
 #include "confdefs.h"
 
 main(){return(0);}
 EOF
-if { (eval echo configure:944: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1222: \"$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
@@ -966,12 +1244,12 @@ 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:970: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:1248: 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:975: checking whether we are using GNU C" >&5
+echo "configure:1253: 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
@@ -980,7 +1258,7 @@ else
   yes;
 #endif
 EOF
-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:984: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1262: \"$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
@@ -999,7 +1277,7 @@ 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:1003: checking whether ${CC-cc} accepts -g" >&5
+echo "configure:1281: 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
@@ -1042,7 +1320,7 @@ fi
 # 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:1046: checking for a BSD compatible install" >&5
+echo "configure:1324: 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
@@ -1164,7 +1442,7 @@ else
 fi
 
 echo $ac_n "checking build system type""... $ac_c" 1>&6
-echo "configure:1168: checking build system type" >&5
+echo "configure:1446: checking build system type" >&5
 
 build_alias=$build
 case "$build_alias" in
@@ -1184,7 +1462,7 @@ 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:1188: checking for $ac_word" >&5
+echo "configure:1466: 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
@@ -1223,7 +1501,7 @@ 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:1227: checking for ld used by GCC" >&5
+echo "configure:1505: checking for ld used by GCC" >&5
   ac_prog=`($CC -print-prog-name=ld) 2>&5`
   case "$ac_prog" in
     # Accept absolute paths.
@@ -1247,10 +1525,10 @@ echo "configure:1227: checking for ld used by GCC" >&5
   esac
 elif test "$with_gnu_ld" = yes; then
   echo $ac_n "checking for GNU ld""... $ac_c" 1>&6
-echo "configure:1251: checking for GNU ld" >&5
+echo "configure:1529: checking for GNU ld" >&5
 else
   echo $ac_n "checking for non-GNU ld""... $ac_c" 1>&6
-echo "configure:1254: checking for non-GNU ld" >&5
+echo "configure:1532: 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
@@ -1285,7 +1563,7 @@ else
 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:1289: checking if the linker ($LD) is GNU ld" >&5
+echo "configure:1567: 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
@@ -1301,7 +1579,7 @@ echo "$ac_t""$ac_cv_prog_gnu_ld" 1>&6
 
 
 echo $ac_n "checking for BSD-compatible nm""... $ac_c" 1>&6
-echo "configure:1305: checking for BSD-compatible nm" >&5
+echo "configure:1583: 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
@@ -1337,7 +1615,7 @@ 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:1341: checking whether ln -s works" >&5
+echo "configure:1619: 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
@@ -1386,8 +1664,8 @@ test x"$silent" = xyes && libtool_flags="$libtool_flags --silent"
 case "$lt_target" in
 *-*-irix6*)
   # Find out which ABI we are using.
-  echo '#line 1390 "configure"' > conftest.$ac_ext
-  if { (eval echo configure:1391: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+  echo '#line 1668 "configure"' > conftest.$ac_ext
+  if { (eval echo configure:1669: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
     case "`/usr/bin/file conftest.o`" in
     *32-bit*)
       LD="${LD-ld} -32"
@@ -1408,19 +1686,19 @@ case "$lt_target" in
   SAVE_CFLAGS="$CFLAGS"
   CFLAGS="$CFLAGS -belf"
   echo $ac_n "checking whether the C compiler needs -belf""... $ac_c" 1>&6
-echo "configure:1412: checking whether the C compiler needs -belf" >&5
+echo "configure:1690: 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 1417 "configure"
+#line 1695 "configure"
 #include "confdefs.h"
 
 int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:1424: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1702: \"$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
@@ -1523,7 +1801,7 @@ exec 5>>./config.log
 
 
 echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:1527: checking how to run the C preprocessor" >&5
+echo "configure:1805: checking how to run the C preprocessor" >&5
 # On Suns, sometimes $CPP names a directory.
 if test -n "$CPP" && test -d "$CPP"; then
   CPP=
@@ -1538,13 +1816,13 @@ else
   # On the NeXT, cc -E runs the code through the compiler's parser,
   # not just through cpp.
   cat > conftest.$ac_ext <<EOF
-#line 1542 "configure"
+#line 1820 "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:1548: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1826: \"$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
   :
@@ -1555,13 +1833,13 @@ else
   rm -rf conftest*
   CPP="${CC-cc} -E -traditional-cpp"
   cat > conftest.$ac_ext <<EOF
-#line 1559 "configure"
+#line 1837 "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:1565: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1843: \"$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,13 +1850,13 @@ else
   rm -rf conftest*
   CPP="${CC-cc} -nologo -E"
   cat > conftest.$ac_ext <<EOF
-#line 1576 "configure"
+#line 1854 "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; }
+{ (eval echo configure:1860: \"$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
   :
@@ -1602,21 +1880,101 @@ else
 fi
 echo "$ac_t""$CPP" 1>&6
 
-for ac_hdr in unistd.h locale.h langinfo.h sys/select.h
+for ac_hdr in unistd.h locale.h langinfo.h resolv.h
+do
+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+echo "configure:1888: 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 1893 "configure"
+#include "confdefs.h"
+#include <$ac_hdr>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1898: \"$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_hdr in sys/select.h arpa/nameser.h
+do
+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+echo "configure:1928: 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 1933 "configure"
+#include "confdefs.h"
+#include <$ac_hdr>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1938: \"$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_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:1610: checking for $ac_hdr" >&5
+echo "configure:1968: 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 1615 "configure"
+#line 1973 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1620: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1978: \"$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*
@@ -1644,12 +2002,12 @@ done
 
 
 echo $ac_n "checking for uid_t in sys/types.h""... $ac_c" 1>&6
-echo "configure:1648: checking for uid_t in sys/types.h" >&5
+echo "configure:2006: 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 1653 "configure"
+#line 2011 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 EOF
@@ -1678,12 +2036,12 @@ EOF
 fi
 
 echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:1682: checking for ANSI C header files" >&5
+echo "configure:2040: 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 1687 "configure"
+#line 2045 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 #include <stdarg.h>
@@ -1691,7 +2049,7 @@ else
 #include <float.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1695: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2053: \"$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*
@@ -1708,7 +2066,7 @@ 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 1712 "configure"
+#line 2070 "configure"
 #include "confdefs.h"
 #include <string.h>
 EOF
@@ -1726,7 +2084,7 @@ 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 1730 "configure"
+#line 2088 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 EOF
@@ -1747,7 +2105,7 @@ if test "$cross_compiling" = yes; then
   :
 else
   cat > conftest.$ac_ext <<EOF
-#line 1751 "configure"
+#line 2109 "configure"
 #include "confdefs.h"
 #include <ctype.h>
 #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@@ -1758,7 +2116,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
 exit (0); }
 
 EOF
-if { (eval echo configure:1762: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2120: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   :
 else
@@ -1782,12 +2140,12 @@ EOF
 fi
 
 echo $ac_n "checking for BOOL""... $ac_c" 1>&6
-echo "configure:1786: checking for BOOL" >&5
+echo "configure:2144: 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 1791 "configure"
+#line 2149 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -1816,7 +2174,7 @@ fi
 
 
 echo $ac_n "checking for socket in -lsocket""... $ac_c" 1>&6
-echo "configure:1820: checking for socket in -lsocket" >&5
+echo "configure:2178: 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
@@ -1824,7 +2182,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1828 "configure"
+#line 2186 "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
@@ -1835,7 +2193,7 @@ int main() {
 socket()
 ; return 0; }
 EOF
-if { (eval echo configure:1839: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2197: \"$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
@@ -1863,7 +2221,7 @@ else
 fi
 
 echo $ac_n "checking for inet_addr in -lnsl""... $ac_c" 1>&6
-echo "configure:1867: checking for inet_addr in -lnsl" >&5
+echo "configure:2225: 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
@@ -1871,7 +2229,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lnsl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1875 "configure"
+#line 2233 "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
@@ -1882,7 +2240,7 @@ int main() {
 inet_addr()
 ; return 0; }
 EOF
-if { (eval echo configure:1886: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2244: \"$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
@@ -1909,53 +2267,156 @@ else
   echo "$ac_t""no" 1>&6
 fi
 
-
-for ac_func in vsnprintf setvbuf setlocale nl_langinfo memmove bcopy
-do
-echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1917: checking for $ac_func" >&5
-if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6
+echo "configure:2272: 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
-  cat > conftest.$ac_ext <<EOF
-#line 1922 "configure"
+  ac_save_LIBS="$LIBS"
+LIBS="-ldl  $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 2280 "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();
+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_$ac_func) || defined (__stub___$ac_func)
-choke me
-#else
-$ac_func();
-#endif
-
+dlopen()
 ; return 0; }
 EOF
-if { (eval echo configure:1945: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2291: \"$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"
+  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_func_$ac_func=no"
+  eval "ac_cv_lib_$ac_lib_var=no"
 fi
 rm -f conftest*
-fi
+LIBS="$ac_save_LIBS"
 
-if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
   echo "$ac_t""yes" 1>&6
-    ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+  
+    LIBS="-ldl $LIBS"
+    LIBDL="-ldl"
+    cat >> confdefs.h <<\EOF
+#define HAVE_LIBDL 1
+EOF
+
+    
+
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+
+for ac_func in vsnprintf setvbuf setlocale nl_langinfo memmove bcopy syslog
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:2323: 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 2328 "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:2351: \"$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 gethostbyname2 gethostbyaddr
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:2378: 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 2383 "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:2406: \"$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
@@ -1965,6 +2426,438 @@ else
 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:2433: 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 2438 "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:2461: \"$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:2488: 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 2493 "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:2516: \"$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:2543: 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 2548 "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:2571: \"$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:2598: 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 2603 "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:2626: \"$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
+
+
+echo $ac_n "checking flavor of gethostbyaddr""... $ac_c" 1>&6
+echo "configure:2652: 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
+  if test "$cross_compiling" = yes; then
+  ac_cv_flavor_gethostbyaddr=traditional
+else
+  cat > conftest.$ac_ext <<EOF
+#line 2660 "configure"
+#include "confdefs.h"
+
+#include <stddef.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:2674: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+  ac_cv_flavor_gethostbyaddr=standard
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -fr conftest*
+  ac_cv_flavor_gethostbyaddr=traditional
+fi
+rm -fr conftest*
+fi
+
+fi
+
+echo "$ac_t""$ac_cv_flavor_gethostbyaddr" 1>&6
+if test "$ac_cv_flavor_gethostbyaddr" = "standard"; then
+    cat >> confdefs.h <<\EOF
+#define GHBA_ADDRLEN_T size_t
+EOF
+
+else
+    cat >> confdefs.h <<\EOF
+#define GHBA_ADDRLEN_T int
+EOF
+
+fi
+
+if test "$find_gethost_r" = yes; then
+    echo $ac_n "checking flavor of gethostbyname_r""... $ac_c" 1>&6
+echo "configure:2703: 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 2711 "configure"
+#include "confdefs.h"
+
+#include <stdio.h>
+#include <netdb.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:2730: \"$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:2755: 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 | tr a-z A-Z`
+       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
+
+
+echo $ac_n "checking for libnsl shared object""... $ac_c" 1>&6
+echo "configure:2793: 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 | tr a-z A-Z`
+       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
+
+
+echo $ac_n "checking for iconv""... $ac_c" 1>&6
+echo "configure:2831: checking for iconv" >&5
+saved_LIBS=$LIBS
+LIBS="$LIBS $ICONVLIB"
+cat > conftest.$ac_ext <<EOF
+#line 2835 "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:2847: \"$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
+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
 
 
 trap '' 1 2 15
@@ -2072,12 +2965,13 @@ trap 'rm -fr `echo "Makefile
        include/Makefile
        include/mdn/Makefile
        lib/Makefile
-       dnsproxy/Makefile
+       mdnsproxy/Makefile
        man/Makefile
        tools/Makefile
        tools/mdnconv/Makefile
        tools/runmdn/Makefile
        tools/runmdn/runmdn
+       map/Makefile
  include/config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
 EOF
 cat >> $CONFIG_STATUS <<EOF
@@ -2115,8 +3009,11 @@ 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%@logdir@%$logdir%g
 s%@ICONVLIB@%$ICONVLIB%g
 s%@ICONVSOFILE@%$ICONVSOFILE%g
+s%@CONF_PREFERENCE@%$CONF_PREFERENCE%g
+s%@INSTALL_DEFAULT_CONF@%$INSTALL_DEFAULT_CONF%g
 s%@PRELOAD_VAR@%$PRELOAD_VAR%g
 s%@PRELOAD_SEP@%$PRELOAD_SEP%g
 s%@PRELOAD_LAST@%$PRELOAD_LAST%g
@@ -2133,6 +3030,7 @@ s%@RANLIB@%$RANLIB%g
 s%@LN_S@%$LN_S%g
 s%@LIBTOOL@%$LIBTOOL%g
 s%@CPP@%$CPP%g
+s%@LIBDL@%$LIBDL%g
 
 CEOF
 EOF
@@ -2178,12 +3076,13 @@ CONFIG_FILES=\${CONFIG_FILES-"Makefile
        include/Makefile
        include/mdn/Makefile
        lib/Makefile
-       dnsproxy/Makefile
+       mdnsproxy/Makefile
        man/Makefile
        tools/Makefile
        tools/mdnconv/Makefile
        tools/runmdn/Makefile
        tools/runmdn/runmdn
+       map/Makefile
 "}
 EOF
 cat >> $CONFIG_STATUS <<\EOF
index d7a05b4bcab616a43dab246c6318055ef8e6643f..b767c21d0c91eafb7201b96501d4c66922bb8f9b 100644 (file)
@@ -1,4 +1,4 @@
-dnl $Id: configure.in,v 1.25 2000/11/17 06:51:11 ishisone Exp $
+dnl $Id: configure.in,v 1.47 2001/05/18 04:02:29 ishisone Exp $
 dnl Process this file with autoconf to produce a configure script.
 dnl
 dnl Copyright (c) 2000 Japan Network Information Center.  All rights reserved.
@@ -61,80 +61,62 @@ AC_INIT(include/mdn/converter.h)
 
 AC_CANONICAL_HOST
 
-zld=no
-AC_ARG_ENABLE(zld,
-[  --enable-zld            enable ZLD support. [default=no]],
-       zld=$enableval)
-case "$zld" in
+logdir=no
+AC_ARG_WITH(logdir,
+[  --with-logdir=DIR       mdnsproxy's log files are in DIR.
+                          [default=LOCALSTATEDIR/mdnsproxy]],
+       logdir=$withval)
+case "$logdir" in
 no)
+    logdir='${localstatedir}/mdnsproxy'
     ;;
 yes)
-    AC_DEFINE(MDN_SUPPORT_ZLD)
-    ;;
-*)
-    AC_MSG_ERROR([You must specify yes or no to --enable-zld option.])
+    AC_MSG_ERROR([You must specify DIR to --with-logdir option.])
     ;;
 esac
+AC_SUBST(logdir)
 
-utf8name=no
-AC_ARG_WITH(utf8,
-[  --with-utf8=NAME        codeset name for UTF-8 encoding [UTF-8]],
-       utf8name=$withval)
-case "$utf8name" in
+extraace=no
+AC_ARG_ENABLE(extra-ace,
+[  --enable-extra-ace      enable additional ACE converters. [default=no]],
+       extraace=$enableval)
+case "$extraace" in
 no)
     ;;
 yes)
-    AC_MSG_ERROR([You must specify NAME to --with-utf8 option.])
+    AC_DEFINE(MDN_EXTRA_ACE, 1,
+       [Define if you want additional ACE converters compiled in.])
     ;;
 *)
-    AC_DEFINE_UNQUOTED(MDN_UTF8_ENCODING_NAME, "$utf8name")
+    AC_MSG_ERROR([You must specify yes or no to --enable-extra-ace option.])
     ;;
 esac
 
-raceprefix=no
-AC_ARG_WITH(race-prefix,
-[  --with-race-prefix=PREFIX     prefix for RACE encoding [bq--]],
-       raceprefix=$withval)
-case "$raceprefix" in
-no)
-    ;;
-yes)
-    AC_MSG_ERROR([You must specify PREFIX to --with-race-prefix option.])
-    ;;
-*)
-    AC_DEFINE_UNQUOTED(MDN_RACE_PREFIX, "$raceprefix")
-    ;;
-esac
-
-bracesuffix=no
-AC_ARG_WITH(brace-suffix,
-[  --with-brace-suffix=PREFIX     suffix for BRACE encoding [-8q9]],
-       bracesuffix=$withval)
-case "$bracesuffix" in
+utf8name=no
+AC_ARG_WITH(utf8,
+[  --with-utf8=NAME        codeset name for UTF-8 encoding [UTF-8]],
+       utf8name=$withval)
+case "$utf8name" in
 no)
     ;;
 yes)
-    AC_MSG_ERROR([You must specify SUFFIX to --with-brace-suffix option.])
+    AC_MSG_ERROR([You must specify NAME to --with-utf8 option.])
     ;;
 *)
-    AC_DEFINE_UNQUOTED(MDN_BRACE_SUFFIX, "$bracesuffix")
+    AC_DEFINE_UNQUOTED(MDN_UTF8_ENCODING_NAME, "$utf8name",
+       [Define if your iconv() does not accept "UTF-8" as the codeset name for utf-8.])
     ;;
 esac
 
-laceprefix=no
-AC_ARG_WITH(lace-prefix,
-[  --with-lace-prefix=PREFIX     prefix for LACE encoding [bq--]],
-       laceprefix=$withval)
-case "$laceprefix" in
-no)
-    ;;
-yes)
-    AC_MSG_ERROR([You must specify PREFIX to --with-lace-prefix option.])
-    ;;
-*)
-    AC_DEFINE_UNQUOTED(MDN_LACE_PREFIX, "$laceprefix")
-    ;;
-esac
+AC_ACE_PREFIX(RACE, [bq--])
+AC_ACE_SUFFIX(BRACE, [-8q9])
+AC_ACE_PREFIX(LACE, [lq--])
+AC_ACE_PREFIX(UTF-6, [wq--])
+AC_ACE_PREFIX(DUDE, [dq--])
+AC_ACE_SIGNATURE(AltDUDE, [a---], [])
+AC_ACE_SIGNATURE(AMC-ACE-M, [], [-amc1])
+AC_ACE_SIGNATURE(AMC-ACE-O, [], [-amc2])
+AC_ACE_PREFIX(AMC-ACE-R, [amc3-])
 
 iconv=no
 AC_ARG_WITH(iconv,
@@ -156,7 +138,7 @@ esac
 AC_SUBST(ICONVLIB)
 
 AC_ARG_WITH(iconv-sofile,
-[  --with-iconv-sofile=PATH        shared library file for libiconv []],
+[  --with-iconv-sofile=PATH shared library file for libiconv []],
        iconv_file=$withval, iconv_file=guess)
 ICONVSOFILE=
 case "$iconv_file" in
@@ -221,6 +203,30 @@ guess)
 esac
 AC_SUBST(ICONVSOFILE)
 
+CONF_PREFERENCE=no
+INSTALL_DEFAULT_CONF=yes
+AC_ARG_WITH(preference,
+[  --with-preference=ARG   change the default configuration to the one
+                          suitable for ARG.],
+       CONF_PREFERENCE=$withval)
+CONF_PREFERENCE=`echo $CONF_PREFERENCE | tr A-Z a-z`
+case "$CONF_PREFERENCE" in
+no)
+    CONF_PREFERENCE=default
+    INSTALL_DEFAULT_CONF=no
+    ;;
+yes)
+    AC_MSG_ERROR([You must specify ARG to --with-preference option.])
+    ;;
+jp)
+    ;;
+*)
+    AC_MSG_ERROR([Unknown ARG for --with-preference option.])
+    ;;
+esac
+AC_SUBST(CONF_PREFERENCE)
+AC_SUBST(INSTALL_DEFAULT_CONF)
+
 dnl Figure out preload stuff.
 PRELOAD_VAR="LD_PRELOAD"
 PRELOAD_SEP=":"
@@ -229,6 +235,9 @@ case "$host" in
 *-solaris*)
     PRELOAD_SEP=" "
     ;;
+*-linux*)
+    PRELOAD_SEP=" "
+    ;;
 *-osf*)
     PRELOAD_VAR="_RLD_LIST"
     PRELOAD_LAST=":DEFAULT"
@@ -244,7 +253,9 @@ AC_PROG_INSTALL
 AM_PROG_LIBTOOL
 
 dnl Checks for header files.
-AC_CHECK_HEADERS(unistd.h locale.h langinfo.h sys/select.h)
+AC_CHECK_HEADERS(unistd.h locale.h langinfo.h resolv.h)
+AC_CHECK_HEADERS(sys/select.h arpa/nameser.h)
+AC_CHECK_HEADERS(dlfcn.h)
 
 dnl Checks for data types.
 AC_TYPE_UID_T
@@ -254,9 +265,93 @@ AC_CHECK_TYPE(BOOL, int)
 dnl Checks for libraries.
 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)
+    AC_SUBST(LIBDL)
+])
 
 dnl Checks for library functions.
-AC_CHECK_FUNCS(vsnprintf setvbuf setlocale nl_langinfo memmove bcopy)
+AC_CHECK_FUNCS(vsnprintf setvbuf setlocale nl_langinfo memmove bcopy syslog)
+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)
+
+dnl Checks the flavor of gethostbyaddr* functions.
+AC_CACHE_CHECK(flavor of gethostbyaddr, ac_cv_flavor_gethostbyaddr,
+[AC_TRY_RUN(
+[
+#include <stddef.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=standard,
+  ac_cv_flavor_gethostbyaddr=traditional,
+  ac_cv_flavor_gethostbyaddr=traditional)])
+if test "$ac_cv_flavor_gethostbyaddr" = "standard"; then
+    AC_DEFINE(GHBA_ADDRLEN_T, size_t)
+else
+    AC_DEFINE(GHBA_ADDRLEN_T, int)
+fi
+
+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 <stdio.h>
+#include <netdb.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)
+    fi
+fi
+
+dnl Find system shared object paths.
+AC_FIND_SYSTEM_SHOBJ(libc)
+AC_FIND_SYSTEM_SHOBJ(libnsl)
+
+dnl Checks for iconv library.
+AC_MSG_CHECKING(for iconv)
+saved_LIBS=$LIBS
+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
+AC_MSG_RESULT($iconv_try_link)
+if test "$iconv_try_link" = no ; then
+    AC_MSG_ERROR(iconv function not available)
+fi
 
 dnl Output.
 AC_CONFIG_HEADER(include/config.h)
@@ -265,10 +360,11 @@ AC_OUTPUT(
        include/Makefile
        include/mdn/Makefile
        lib/Makefile
-       dnsproxy/Makefile
+       mdnsproxy/Makefile
        man/Makefile
        tools/Makefile
        tools/mdnconv/Makefile
        tools/runmdn/Makefile
        tools/runmdn/runmdn
+       map/Makefile
 )
diff --git a/contrib/idn/mdnkit/dnsproxy/dnsproxy.conf.sample b/contrib/idn/mdnkit/dnsproxy/dnsproxy.conf.sample
deleted file mode 100755 (executable)
index 4425d72..0000000
+++ /dev/null
@@ -1,170 +0,0 @@
-# $Id: dnsproxy.conf.sample,v 1.6 2000/11/22 06:57:30 ishisone Exp $
-#
-# Sample dnsproxy configuration file 'dnsproxy.conf'.
-#
-
-#
-# 'listen' entry specifies the dnsproxy's listening port.
-# The default is to use address 0.0.0.0 (INADDR_ANY) and port 53.
-#
-# syntax)
-#      listen [<IP address>][:<port number>]
-#
-# ex)  listen 127.0.0.1        -- only accept loopback connections
-#      listen :1053            -- port number can be specified
-#      listen 127.0.0.1:1053   -- combination of above
-#
-#listen  127.0.0.1
-
-#
-# 'forward' entry specifies the name server's port to which dnsproxy
-# forwards requests.  This entry MUST be specified.
-#
-# Normally dnsproxy uses unspecified local port number for sending
-# queries to the server, but if 'bind4compat' option is specified,
-# dnsproxy uses the same port number as the listening port specified
-# by the 'listen' entry.
-#
-# syntax)
-#      forward <IP address>[:<port number>] [bind4compat]
-#
-# ex)  forward 10.0.0.2                -- forward 10.0.0.2 port 53
-#      forward 10.0.0.2:1053           -- port number can be specified
-#      forward 10.0.0.2 bind4compat    -- use fixed port number.
-forward        xxx.xxx.xxx.xxx
-
-#
-# 'client-tranlation' entries specify the codeset (encoding) of domain
-# names in the messages sent by the clients.  If you configure mDNkit
-# with '--enable-zld' option, ZLD (zero level domain) can be specified.
-# In this case multiple entries are permitted as long as each entry has
-# different ZLD.
-#
-# If ZLD is not enabled (this is the default), ZLD part is ignored.
-#
-# syntax)
-#      client-translation <ZLD> <codeset>
-#
-# ex)  client-translation .xyz UTF-5
-#              -- If the domain name ends with '.xyz', the client encoding
-#                 is assumed to be UTF-5.  The ZLD part (.xyz) will be removed
-#                 from the domain name before converting to the server
-#                 encoding.
-#      client-translation . Shift_JIS
-#              -- '.' denotes absence of ZLD.  If the given domain name
-#                 doesn't match any of other ZLDs, this entry matches
-#                 and codeset Shift_JIS is assumed.
-#
-#client-translation .i-dns.net UTF-5   # ZLD is .i-dns.net, codeset is UTF-5
-client-translation . Shift_JIS
-
-#
-# Normally domain names in the DNS reply messages from the (real) name
-# server are translated back to the client codeset determined by the
-# above 'client-translation' entries.
-#
-# 'alternate-encoding' entry specifies the alternative codeset which
-# is used instead of the client codeset when the translation to the
-# client codeset fails.  This alternative codeset must be an ASCII-
-# compatible encoding, such as RACE.
-#
-# syntax)
-#      alternate-encoding <codeset>
-#
-alternate-encoding     RACE
-
-#
-#
-# 'normalize' entry specifies the normalization.  You can specify any of
-# these normalization schemes:
-#      ascii-lowercase         -- ASCII uppercase letters to lowercase
-#      ascii-uppercase         -- ASCII lowercase letters to uppercase
-#      unicode-lowercase       -- Unicode uppercase letters to lowercase
-#      unicode-uppercase       -- Unicode lowercase letters to uppercase
-#      unicode-form-c          -- Unicode normalization form C
-#      unicode-form-kc         -- Unicode normalization form KC
-#      ja-kana-fullwidth       -- Japanese halfwidth kana letters to fullwidth
-#      ja-alnum-halfwidth      -- Fullwidth alphabets, digits and minus sign
-#                                 to halfwidth
-#      ja-compose-voiced-sound -- Combine Japanese fullwidth kana and the
-#                                 following (semi) voiced sound mark
-#      ja-minus-hack           -- Japanse fullwidth minus sign to '-'
-#
-# If more than one schemes are specified, they are applied in turn.
-#
-# syntax)
-#      normalize <normalization scheme>...
-#
-# ex)  normalize unicode-form-kc unicode-lowercase
-#                      -- first 'unicode-form-kc', then 'unicode-lowercase'
-#
-normalize      unicode-lowercase unicode-form-kc
-
-#
-# 'server-translation' entry specifies the codeset (encoding) of domain
-# names used by the (real) name servers.  Also ZLD can be specified if
-# configured with '--enable-zld' option.
-#
-# syntax)
-#      server-translation <ZLD> <encoding>
-#
-# ex)  server-translation . UTF-8      -- use UTF-8 without ZLD
-#
-server-translation . RACE
-
-#
-# 'log-file' entry specifies the pathname of the log file.  If it is
-# not specified, default log file (/tmp/dnsproxy.log) will be used.
-#
-# syntax)
-#      log-file <pathname>
-#
-log-file    /var/log/dnsproxy.log
-
-#
-# 'user-id' entry and 'group-id' entry specify the user/group ID
-# in which privilege dnsproxy operates.  dnsproxy tries to switch
-# to the specified user/group after initialization process is finished.
-#
-# syntax)
-#      user-id <name-or-number>
-#      group-id <name-or-number>
-#
-# ex)  user-id nobody          -- specify by name,
-#      group-id 1000           -- or by number
-#
-user-id nobody
-#group-id nobody
-
-#
-# 'root-directory' entry specifies the root directory of dnsproxy
-# process.  dnsproxy performs chroot() to this directory after
-# initialization.  Note that chroot() is allowed only for super-users.
-#
-# syntax)
-#      root-directory <path>
-#
-root-directory /var/dnsproxy
-
-#
-# 'log-level' entry specifies the logging level for dnsproxy.
-# Valid levels are 'none' (no logging at all, not recommended),
-# 'fatal' (only logs fatal errors), 'warn' (also logs warning messages)
-# and 'trace' (also includes trace messages).  The default level is 'warn'.
-# 'trace' level is useful for debugging dnsproxy itself, but it makes
-# the log file grow rather quickly.
-#
-# syntax)
-#      log-level <level>
-#
-log-level warn
-
-#
-# 'mdn-log-level' entry specifies the logging level for libmdn, the
-# library responsible for most of the MDN processing for dnsproxy.
-# Unless you are debugging mDNkit, you should keep this entry unspecified.
-#
-# syntax)
-#      mdn-log-level <number>
-#
-# mdn-log-level 1
diff --git a/contrib/idn/mdnkit/dnsproxy/logging.c b/contrib/idn/mdnkit/dnsproxy/logging.c
deleted file mode 100644 (file)
index 78c6137..0000000
+++ /dev/null
@@ -1,294 +0,0 @@
-/*
- * logging.c - logging support
- */
-
-/*
- * 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
- * Tokyo, 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) Japan Network Information Center.  All rights reserved."
- * 
- * 4. Neither the name of JPNIC may 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.
- * 
- * 6. Indemnification by Licensee
- *    Any person or entities using and/or redistributing this Software under
- *    this License Terms and Conditions shall defend indemnify and hold
- *    harmless JPNIC from and against any and all judgements damages,
- *    expenses, settlement liabilities, cost and other liabilities of any
- *    kind as a result of use and redistribution of this Software or any
- *    claim, suite, action, litigation or proceeding by any third party
- *    arising out of or relates to this License Terms and Conditions.
- * 
- * 7. Governing Law, Jurisdiction and Venue
- *    This License Terms and Conditions shall be governed by and and
- *    construed in accordance with the law of Japan. Any person or entities
- *    using and/or redistributing this Software under this License Terms and
- *    Conditions hereby agrees and consent to the personal and exclusive
- *    jurisdiction and venue of Tokyo District Court of Japan.
- */
-
-#ifndef lint
-static char *rcsid = "$Id: logging.c,v 1.13 2000/11/17 05:46:23 ishisone Exp $";
-#endif
-
-#include <config.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdarg.h>
-#include <time.h>
-
-#include "dnsproxy.h"
-
-#define DEFAULT_LOGFILE        "dnsproxy.log"
-
-#ifdef DEBUG
-#define DEFAULT_LOG_LEVEL LOGLEVEL_TRACE
-#else
-#define DEFAULT_LOG_LEVEL LOGLEVEL_WARN
-#endif
-
-/*
- * Logging Control Variables
- */
-
-static  char    logFname[256] = { 0 } ;
-static  FILE    *logFptr = NULL       ;
-static int     logLevel = DEFAULT_LOG_LEVEL ;
-static  int    timeToTurnOver = 0 ;
-
-/*
- * log_default_path -- get default log file pathname
- */
-
-static void    log_default_path(void)
-{
-#ifdef UNIX
-    (void)strcpy(logFname, "/tmp/") ;
-    (void)strcat(logFname, DEFAULT_LOGFILE) ;
-#endif
-#if defined(WIN32) || defined(OS2)
-    {
-       char *env;
-       if ((env = getenv("TEMP")) == NULL)
-           env = getenv("TMP");
-       if (env != NULL &&
-           strlen(env) + strlen(DEFAULT_LOGFILE) + 1 < sizeof(logFname)) {
-           (void)strcpy(logFname, env);
-           (void)strcat(logFname, "\\");
-           (void)strcat(logFname, DEFAULT_LOGFILE);
-       }
-    }
-#endif
-}
-
-/*
- * log_configure - configure logging (must be called after 'config_load')
- */
-
-void    log_configure(int ac, char *av[])
-{
-    int     i, nArgs   ;
-    char    **aArgs    ;
-    char    *fn = NULL ;
-
-    if (config_query_value("log-file", &nArgs, &aArgs) == TRUE) {
-        if (nArgs >= 2) {
-           fn = aArgs[1] ;
-       }
-    }
-    for (i = 1 ; i < ac ; i++) {
-        if (strcmp(av[i], "-logfile") == 0) {
-           fn = av[i+=1] ;
-       }
-    }
-    if (fn != NULL && strlen(fn) < sizeof(logFname)) {
-        strcpy(logFname, fn) ;
-    } else {
-       log_default_path();
-    }
-
-    if (config_query_value("log-level", &nArgs, &aArgs) == TRUE) {
-       int level ;
-
-       if (nArgs != 2) {
-           WARN("syntax error at log-level line\n");
-       } else if ((level = log_strtolevel(aArgs[1])) < 0) {
-           WARN("invalid log level %s\n", aArgs[1]);
-       } else {
-           log_setlevel(level);
-       }
-    }
-}
-
-/*
- * log_terminate - terminate logging
- */
-
-void    log_terminate(void)
-{
-    if (logFptr != NULL) {
-        fclose(logFptr) ;
-        logFptr = NULL  ;
-    }
-}
-
-/*
- * log_turnover_request - request turning over log
- *     this function is intended for calling from singnal handler.
- */
-
-void   log_turnover_request(void)
-{
-    timeToTurnOver = 1;
-}
-
-/*
- * log_turnover - turn over log if requested
- */
-
-void   log_turnover(void)
-{
-    if (timeToTurnOver) {
-       timeToTurnOver = 0;
-       log_trace_printf("--- log file turned over\n");
-       log_terminate() ;
-    }
-}
-
-/*
- * log_setlevel - set log level
- */
-void   log_setlevel(int level)
-{
-    logLevel = level;
-}
-
-/*
- * log_strtolevel - string to log level
- */
-int    log_strtolevel(char *s)
-{
-    if ('0' <= s[0] && s[0] <= '9') {
-       return atoi(s) ;
-    } else if (!strcmp(s, "none")) {
-       return LOGLEVEL_NONE;
-    } else if (!strcmp(s, "fatal")) {
-       return LOGLEVEL_FATAL;
-    } else if (!strcmp(s, "warn") || !strcmp(s, "warning")) {
-       return LOGLEVEL_WARN;
-    } else if (!strcmp(s, "trace")) {
-       return LOGLEVEL_TRACE;
-    } else {
-       return -1;
-    }
-}
-
-/*
- * log_vprintf - as name describes
- */
-
-static void    log_vprintf(int level, char *fmt, va_list arg_ptr)
-{
-    char    buff[512] ;
-    
-    if (logLevel < level) {
-       return;
-    }
-
-    /*
-     * format message
-     */
-     
-    vsprintf(buff, fmt, arg_ptr) ;
-
-#ifdef  DEBUG
-    printf("%s", buff) ;
-    fflush(stdout)    ;
-#endif
-
-    /*
-     * log to file
-     */
-     
-    if (*logFname == '\0') {
-        return ;                /* no logging file specified */
-    }
-    if (logFptr == NULL) {
-        logFptr = fopen(logFname, "a") ;
-    }
-    if (logFptr != NULL) {
-        fputs(buff, logFptr) ;
-       fflush(logFptr) ;
-    }
-#ifdef  WIN32               /* For NT, having trouble with      */
-    fclose(logFptr) ;       /* reading open'd logging file      */
-    logFptr = NULL  ;       /* so, close and re-open it         */
-#endif
-}
-
-/*
- * log_fatal_printf, log_warn_printf, log_trace_printf - write out
- *     fatal/warning/trace log to the log file
- */
-
-void    log_fatal_printf(char *fmt, ...)
-{
-    va_list arg_ptr   ;
-    
-    va_start(arg_ptr, fmt) ;
-    log_vprintf(LOGLEVEL_FATAL, fmt, arg_ptr) ;
-    va_end(arg_ptr) ;
-}
-
-void    log_warn_printf(char *fmt, ...)
-{
-    va_list arg_ptr   ;
-    
-    va_start(arg_ptr, fmt) ;
-    log_vprintf(LOGLEVEL_WARN, fmt, arg_ptr) ;
-    va_end(arg_ptr) ;
-}
-
-void    log_trace_printf(char *fmt, ...)
-{
-    va_list arg_ptr   ;
-    
-    va_start(arg_ptr, fmt) ;
-    log_vprintf(LOGLEVEL_TRACE, fmt, arg_ptr) ;
-    va_end(arg_ptr) ;
-}
diff --git a/contrib/idn/mdnkit/dnsproxy/translate.c b/contrib/idn/mdnkit/dnsproxy/translate.c
deleted file mode 100644 (file)
index c4ce242..0000000
+++ /dev/null
@@ -1,521 +0,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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
- * Tokyo, 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) Japan Network Information Center.  All rights reserved."
- * 
- * 4. Neither the name of JPNIC may 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.
- * 
- * 6. Indemnification by Licensee
- *    Any person or entities using and/or redistributing this Software under
- *    this License Terms and Conditions shall defend indemnify and hold
- *    harmless JPNIC from and against any and all judgements damages,
- *    expenses, settlement liabilities, cost and other liabilities of any
- *    kind as a result of use and redistribution of this Software or any
- *    claim, suite, action, litigation or proceeding by any third party
- *    arising out of or relates to this License Terms and Conditions.
- * 
- * 7. Governing Law, Jurisdiction and Venue
- *    This License Terms and Conditions shall be governed by and and
- *    construed in accordance with the law of Japan. Any person or entities
- *    using and/or redistributing this Software under this License Terms and
- *    Conditions hereby agrees and consent to the personal and exclusive
- *    jurisdiction and venue of Tokyo District Court of Japan.
- */
-
-#ifndef lint
-static char *rcsid = "$Id: translate.c,v 1.22 2000/11/21 02:09:02 ishisone Exp $";
-#endif
-
-#include <config.h>
-
-#include <stddef.h>
-#include <stdarg.h>
-#include <stdlib.h>
-
-#ifdef  WIN32
-#include <windows.h>
-#include <winsock.h>
-#else   /* for normal systems */
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#endif
-
-#include <mdn/result.h>
-#include <mdn/log.h>
-#include <mdn/converter.h>
-#include <mdn/normalizer.h>
-#include <mdn/translator.h>
-#include <mdn/zldrule.h>
-#include <mdn/msgtrans.h>
-
-#include "dnsproxy.h"
-
-/*
- * Configuration file keywords.
- */
-#define KW_LOG_LEVEL           "mdn-log-level"         /* tentative */
-#define KW_ALIAS_FILE          "encoding-alias-file"
-#define KW_CLIENT_TRANSLATION  "client-translation"
-#define KW_ALTERNATE_ENCODING  "alternate-encoding"
-#define KW_NORMALIZATION       "normalize"
-#define KW_SERVER_TRANSLATION  "server-translation"
-
-/*
- * DNS message rcode.
- */
-enum {
-    RCODE_NO_ERROR = 0,
-    RCODE_FORMAT_ERROR = 1,
-    RCODE_SERVER_FAILURE = 2,
-    RCODE_NAME_ERROR = 3,
-    RCODE_NOT_IMPLEMENTED = 4,
-    RCODE_REFUSED = 5
-};
-
-typedef struct translation {
-    mdn_zldrule_t rule;
-    char *server_zld;
-    mdn_converter_t server_converter;
-    mdn_normalizer_t normalizer;
-    mdn_converter_t alternate_converter;
-} translation_t;
-
-static translation_t   trans;
-
-static int     result_to_rcode(mdn_result_t r);
-static char    *address_to_string(struct sockaddr *sa);
-static int     string_to_loglevel(char *s);
-static void    config_required(char *keyword);
-static void    mdnerror(int code, char *fmt, ...);
-static void    translate_log_handler(int level, const char *msg);
-
-
-BOOL
-translate_initialize(void)
-{
-    mdn_result_t r;
-    config_ctx_t cctx;
-    int ac;
-    char **av;
-    int i;
-
-    TRACE("translate_initialize()\n");
-
-    /*
-     * Set MDN library log handler.
-     */
-    mdn_log_setproc(translate_log_handler);
-
-    /*
-     * Set log level before calling any other functions in
-     * MDN library.
-     */
-    if (config_query_value(KW_LOG_LEVEL, &ac, &av)) {
-       int level;
-
-       if (ac != 2) {
-           WARN("syntax error at %s line\n", KW_LOG_LEVEL);
-           return FALSE;
-       }
-       if ((level = string_to_loglevel(av[1])) >= 0) {
-           mdn_log_setlevel(level);
-       } else {
-           WARN("unknown log level %.100s -- ignored\n", av[1]);
-       }
-    }
-
-    /*
-     * Initialize modules.
-     */
-    mdn_converter_initialize();
-    mdn_normalizer_initialize();
-
-    /*
-     * Create context.
-     */
-    if ((r = mdn_zldrule_create(&trans.rule)) != mdn_success) {
-       mdnerror(r, "initializing ZLD rules");
-       return FALSE;
-    }
-    if ((r = mdn_normalizer_create(&trans.normalizer)) != mdn_success) {
-       mdnerror(r, "initializing normalization");
-       return FALSE;
-    }
-
-    /*
-     * Load configuration data other than log level.
-     */
-
-    /*
-     * Encoding alias file.
-     */
-    if (config_query_value(KW_ALIAS_FILE, &ac, &av)) {
-       if (ac != 2) {
-           WARN("syntax error at %s line\n", KW_ALIAS_FILE);
-           return FALSE;
-       }
-       if ((r = mdn_converter_aliasfile(av[1])) != mdn_success) {
-           mdnerror(r, "reading codeset alias file %.200s", av[1]);
-           return FALSE;
-       }
-    }
-
-    /*
-     * Client-side translation rule.
-     */
-    if ((cctx = config_query_open(KW_CLIENT_TRANSLATION, &ac, &av)) == NULL) {
-       config_required(KW_CLIENT_TRANSLATION);
-       return FALSE;
-    }
-    do {
-       if (ac < 3) {
-           WARN("syntax error at %s line\n", KW_ALIAS_FILE);
-           return FALSE;
-       }
-#ifndef MDN_SUPPORT_ZLD
-       if (strcmp(av[1], "") != 0 && strcmp(av[1], ".") != 0) {
-           WARN("ignore ZLD %s\n", av[1]);
-       }
-#endif
-       r = mdn_zldrule_add(trans.rule, av[1], (const char **)&av[2], ac - 2);
-       if (r != mdn_success) {
-           mdnerror(r, "adding ZLD rules for %s", av[1]);
-           return FALSE;
-       }
-    } while ((cctx = config_query_more(cctx, &ac, &av)) != NULL);
-    config_query_close(cctx);
-
-    /*
-     * Client-side alternate encoding.
-     */
-    if (config_query_value(KW_ALTERNATE_ENCODING, &ac, &av)) {
-       if (ac != 2) {
-           WARN("syntax error at %s line\n", KW_ALTERNATE_ENCODING);
-           return FALSE;
-       }
-       if ((r = mdn_converter_create(av[1], &trans.alternate_converter, 0))
-           != mdn_success) {
-           mdnerror(r, "alternate encoding %s", av[2]);
-           return FALSE;
-       }
-       if (!mdn_converter_isasciicompatible(trans.alternate_converter)) {
-           WARN("alternate encoding must be ASCII-compatible\n");
-           return FALSE;
-       }
-    } else {
-       trans.alternate_converter = NULL;
-    }
-
-    /*
-     * Normalization.
-     */
-    if (!config_query_value(KW_NORMALIZATION, &ac, &av)) {
-       config_required(KW_NORMALIZATION);
-       return FALSE;
-    }
-    for (i = 1; i < ac; i++) {
-       if ((r = mdn_normalizer_add(trans.normalizer, av[i])) != mdn_success) {
-           mdnerror(r, "adding normalization scheme %s", av[i]);
-           return FALSE;
-       }
-    }
-
-    /*
-     * Server-side translation.
-     */
-    if (!config_query_value(KW_SERVER_TRANSLATION, &ac, &av)) {
-       config_required(KW_SERVER_TRANSLATION);
-       return FALSE;
-    }
-    if (ac != 3) {
-       WARN("syntax error at %s line\n", KW_SERVER_TRANSLATION);
-       return FALSE;
-    }
-    if ((r = mdn_translator_canonicalzld(av[1], &trans.server_zld))
-       != mdn_success) {
-       mdnerror(r, "server-side ZLD %s", av[2]);
-       return FALSE;
-    }
-#ifndef MDN_SUPPORT_ZLD
-    if (trans.server_zld != NULL) {
-       WARN("ignore ZLD %s\n", av[1]);
-       free(trans.server_zld);
-       trans.server_zld = NULL;
-    }
-#endif
-    if ((r = mdn_converter_create(av[2], &trans.server_converter, 0))
-       != mdn_success) {
-       mdnerror(r, "server-side encoding %s", av[2]);
-       return FALSE;
-    }
-
-    return TRUE;
-}
-
-void
-translate_finish(void)
-{
-    if (trans.rule != NULL) {
-       mdn_zldrule_destroy(trans.rule);
-       trans.rule = NULL;
-    }
-    if (trans.server_zld != NULL) {
-       free(trans.server_zld);
-       trans.server_zld = NULL;
-    }
-    if (trans.server_converter != NULL) {
-       mdn_converter_destroy(trans.server_converter);
-       trans.server_converter = NULL;
-    }
-    if (trans.normalizer != NULL) {
-       mdn_normalizer_destroy(trans.normalizer);
-       trans.normalizer = NULL;
-    }
-    if (trans.alternate_converter != NULL) {
-       mdn_converter_destroy(trans.alternate_converter);
-       trans.alternate_converter = NULL;
-    }
-}
-
-int
-translate_request(translation_context_t *ctx,
-                 const char *msg, size_t msglen,
-                 char *translated, size_t bufsize, size_t *translatedlenp)
-{
-    mdn_msgtrans_param_t param;
-    mdn_result_t r;
-
-    TRACE("translate_request()\n");
-
-    ctx->zld = NULL;
-    ctx->converter = NULL;
-
-    /*
-     * Initialize translation parameters.
-     */
-    param.use_local_rule = 1;
-    param.local_rule = trans.rule;
-    param.local_converter = NULL;
-    param.local_zld = NULL;
-    param.local_alt_converter = trans.alternate_converter;
-    param.target_converter = trans.server_converter;
-    param.target_alt_converter = NULL;
-    param.target_zld = trans.server_zld;
-    param.normalizer = trans.normalizer;
-
-    r = mdn_msgtrans_translate(&param, msg, msglen,
-                              translated, bufsize, translatedlenp);
-
-    if (r != mdn_success) {
-       mdnerror(r, "translating request message from %s(%s)",
-                address_to_string(ctx->client),
-                ctx->protocol == SOCK_STREAM ? "tcp" : "udp");
-    } else {
-       ctx->zld = param.local_zld;
-       ctx->converter = param.local_converter;
-    }
-
-    return result_to_rcode(r);
-}
-
-int
-translate_reply(translation_context_t *ctx,
-               const char *msg, size_t msglen,
-               char *translated, size_t bufsize, size_t *translatedlenp)
-{
-    mdn_msgtrans_param_t param;
-    mdn_result_t r;
-
-    TRACE("translate_reply()\n");
-
-    if (ctx->converter == NULL) {
-       /*
-        * No translation required.
-        */
-       TRACE("translate_reply: pass through message (old_id=%d,new_id=%d)\n",
-             ctx->old_id, ctx->new_id);
-       if (bufsize < msglen)
-           return (RCODE_SERVER_FAILURE);
-       (void)memcpy(translated, msg, msglen);
-       *translatedlenp = msglen;
-       return RCODE_NO_ERROR;
-    }
-
-    /*
-     * Initialize translation parameters.
-     */
-    param.use_local_rule = 0;
-    param.local_rule = NULL;
-    param.local_converter = trans.server_converter;
-    param.local_zld = trans.server_zld;
-    param.local_alt_converter = NULL;
-    param.target_converter = ctx->converter; 
-    param.target_alt_converter = trans.alternate_converter;
-    param.target_zld = ctx->zld;
-    param.normalizer = NULL;
-
-    r = mdn_msgtrans_translate(&param, msg, msglen,
-                              translated, bufsize, translatedlenp);
-
-    if (r != mdn_success) {
-       mdnerror(r, "translating reply message from %s",
-                address_to_string(ctx->client));
-    }
-
-    return result_to_rcode(r);
-}
-
-static int
-result_to_rcode(mdn_result_t r)
-{
-    int rcode;
-
-    switch (r) {
-    case mdn_success:
-       rcode = RCODE_NO_ERROR;
-       break;
-    case mdn_buffer_overflow:
-    case mdn_nomemory:
-       rcode = RCODE_SERVER_FAILURE;
-       break;
-    case mdn_invalid_message:
-    case mdn_invalid_encoding:
-       rcode = RCODE_FORMAT_ERROR;
-       break;
-    default:
-       rcode = RCODE_SERVER_FAILURE;
-       break;
-    }
-    return rcode;
-}
-
-static char *
-address_to_string(struct sockaddr *sa)
-{
-    static char tmp[200];
-
-    switch (sa->sa_family) {
-    case AF_INET:
-    {
-       struct sockaddr_in *sin = (struct sockaddr_in *)sa;
-
-       sprintf(tmp, "%s/%d", inet_ntoa(sin->sin_addr),
-               ntohs(sin->sin_port));
-       break;
-    }
-#if 0
-#ifdef AF_INET6
-    case AF_INET6:
-    {
-       char buf[INET6_ADDRSTRLEN];
-
-       struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sa;
-
-       sprintf(tmp, "%s/%d",
-               inet_ntop(AF_INET6, &sin6->sin6_addr, buf, sizeof(buf)),
-               ntohs(sin6->sin6_port));
-       break;
-    }
-#endif
-#endif
-    default:
-       sprintf(tmp, "unknown address family %d", sa->sa_family);
-       break;
-    }
-    return tmp;
-}
-
-static int
-string_to_loglevel(char *s)
-{
-    if ('0' <= s[0] && s[0] <= '9')
-       return atoi(s);
-    else if (!strcmp(s, "fatal"))
-       return mdn_log_level_fatal;
-    else if (!strcmp(s, "error"))
-       return mdn_log_level_error;
-    else if (!strcmp(s, "warning"))
-       return mdn_log_level_warning;
-    else if (!strcmp(s, "info"))
-       return mdn_log_level_info;
-    else if (!strcmp(s, "trace"))
-       return mdn_log_level_trace;
-    else if (!strcmp(s, "dump"))
-       return mdn_log_level_dump;
-    else
-       return -1;
-}
-
-static void
-config_required(char *keyword)
-{
-    WARN("%s line required in the configuration file\n", keyword);
-}
-
-static void
-mdnerror(int code, char *fmt, ...)
-{
-    char buf[1024];
-    va_list args;
-
-    va_start(args, fmt);
-    vsprintf(buf, fmt, args);
-    va_end(args);
-
-    sprintf(buf + strlen(buf), ": %s", mdn_result_tostring(code));
-    WARN("%s\n", buf);
-}
-
-static void
-translate_log_handler(int level, const char *msg)
-{
-    switch (level) {
-    case mdn_log_level_fatal:
-       FATAL((char *)msg);
-       break;
-    case mdn_log_level_warning:
-    case mdn_log_level_info:
-       WARN((char *)msg);
-       break;
-    case mdn_log_level_trace:
-    case mdn_log_level_dump:
-       TRACE((char *)msg);
-       break;
-    }
-}
index a5c3ad607ee30620b5f14752a1dfcc24fb046320..b0a953af9e0681128d17b6cb88fa46d11a9aba6b 100644 (file)
@@ -1,4 +1,4 @@
-# $Id: Makefile.in,v 1.1 2000/08/09 07:10:31 ishisone Exp $
+# $Id: Makefile.in,v 1.2 2001/03/28 02:12:35 m-kasahr 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.
@@ -61,6 +61,8 @@ VPATH = @srcdir@
 prefix = @prefix@
 exec_prefix = @exec_prefix@
 
+SHELL = @SHELL@
+
 SUBDIRS = mdn
 
 all:
index 4cd1d255058501d3d356fe222c8f3d9048ef718b..2fb964ebd2ab60a37f3edc976e1a989746395632 100644 (file)
@@ -1,5 +1,5 @@
 /* include/config.h.in.  Generated automatically from configure.in by autoheader.  */
-/* $Id: config.h.in,v 1.16 2000/11/17 06:51:36 ishisone Exp $ */
+/* $Id: config.h.in,v 1.30 2001/04/25 06:26:18 m-kasahr Exp $ */
 /*
  * Copyright (c) 2000 Japan Network Information Center.  All rights reserved.
  *  
 /* Define to `int' if <sys/types.h> doesn't define.  */
 #undef uid_t
 
-/* Define if your iconv() does not accept "UTF-8" as the codeset name for utf-8. */
-#undef MDN_UTF8_ENCODING_NAME
+/* Define as an appropriate type (ex. int) if your system doesn't have. */
+#undef BOOL
 
-/* Define if you want ZLD feature compiled in. */
-#undef MDN_SUPPORT_ZLD
+/* Define if the prototype of gethost*_r is glibc flavor. */
+#undef GETHOST_R_GLIBC_FLAVOR
 
-/* Define if the prefix of RACE encoding differs from 'bq--'. */
-#undef MDN_RACE_PREFIX
+/* Define as the type of the 2nd argument of gethostbyaddr. */
+#undef GHBA_ADDRLEN_T
 
-/* Define if the suffix of BRACE encoding differs from '-8q9'. */
-#undef MDN_BRACE_SUFFIX
+/* Define if you have the bcopy function.  */
+#undef HAVE_BCOPY
 
-/* Define if the prefix of LACE encoding differs from 'bq--'. */
-#undef MDN_LACE_PREFIX
+/* Define if you have the dlopen function.  */
+#undef HAVE_DLOPEN
 
-/* Define as an appropriate type (ex. int) if your system doesn't have. */
-#undef BOOL
+/* Define if you have the dlsym function.  */
+#undef HAVE_DLSYM
 
-/* Define if you have the bcopy function.  */
-#undef HAVE_BCOPY
+/* 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 setvbuf function.  */
 #undef HAVE_SETVBUF
 
+/* Define if you have the syslog function.  */
+#undef HAVE_SYSLOG
+
 /* Define if you have the vsnprintf function.  */
 #undef HAVE_VSNPRINTF
 
+/* Define if you have the <arpa/nameser.h> header file.  */
+#undef HAVE_ARPA_NAMESER_H
+
+/* 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 <resolv.h> header file.  */
+#undef HAVE_RESOLV_H
+
 /* Define if you have the <sys/select.h> header file.  */
 #undef HAVE_SYS_SELECT_H
 
 /* Define if you have the <unistd.h> header file.  */
 #undef HAVE_UNISTD_H
 
+/* Define if you have the dl library (-ldl).  */
+#undef HAVE_LIBDL
+
 /* Define if you have the nsl library (-lnsl).  */
 #undef HAVE_LIBNSL
 
 /* Define if you have the socket library (-lsocket).  */
 #undef HAVE_LIBSOCKET
+
+/* Define if you want additional ACE converters compiled in. */
+#undef MDN_EXTRA_ACE
+
+/* Define if your iconv() does not accept UTF-8 as the codeset name for utf-8. */
+#undef MDN_UTF8_ENCODING_NAME
+
+/* Define if the prefix of RACE encoding differs from 'bq--'. */
+#undef MDN_RACE_PREFIX
+
+/* Define if the suffix of BRACE encoding differs from '-8q9'. */
+#undef MDN_BRACE_SUFFIX
+
+/* Define if the prefix of LACE encoding differs from 'lq--'. */
+#undef MDN_LACE_PREFIX
+
+/* Define if the prefix of UTF-6 encoding differs from 'wq--'. */
+#undef MDN_UTF6_PREFIX
+
+/* Define if the prefix of DUDE encoding differs from 'dq--'. */
+#undef MDN_DUDE_PREFIX
+
+/* Define if the prefix of AltDUDE encoding differs from 'a---'. */
+#undef MDN_ALTDUDE_PREFIX
+
+/* Define if the suffix of AltDUDE encoding differs from ''. */
+#undef MDN_ALTDUDE_SUFFIX
+
+/* Define if the prefix of AMC-ACE-M encoding differs from ''. */
+#undef MDN_AMCACEM_PREFIX
+
+/* Define if the suffix of AMC-ACE-M encoding differs from '-amc1'. */
+#undef MDN_AMCACEM_SUFFIX
+
+/* Define if the prefix of AMC-ACE-O encoding differs from ''. */
+#undef MDN_AMCACEO_PREFIX
+
+/* Define if the suffix of AMC-ACE-O encoding differs from '-amc2'. */
+#undef MDN_AMCACEO_SUFFIX
+
+/* Define if the prefix of AMC-ACE-R encoding differs from 'amc3-'. */
+#undef MDN_AMCACER_PREFIX
+
+/* 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
index a7306db1f9308e33e850d1874055c6a99960d4f6..0e1ab9f8837dfc77115e3793ad941e97a0fe90ae 100644 (file)
@@ -1,4 +1,4 @@
-# $Id: Makefile.in,v 1.4 2000/11/14 00:13:29 ishisone Exp $
+# $Id: Makefile.in,v 1.21 2001/04/16 06:20:25 m-kasahr 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.
@@ -61,27 +61,41 @@ VPATH = @srcdir@
 prefix = @prefix@
 exec_prefix = @exec_prefix@
 
-BINDIR = @bindir@
-LIBDIR = @libdir@
-INCDIR = @includedir@
-MDNINCDIR = $(INCDIR)/mdn
+includedir = @includedir@
+mdnincludedir = $(includedir)/mdn
 
 INSTALL = @INSTALL@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_DATA = @INSTALL_DATA@
+MKINSTALLDIRS = @top_srcdir@/mkinstalldirs
+SHELL = @SHELL@
 
 HDRS = \
+       ace.h \
+       altdude.h \
+       amcacem.h \
+       amcaceo.h \
+       amcacer.h \
+       api.h \
        assert.h \
        brace.h \
+       checker.h \
        converter.h \
        debug.h \
+       delimitermap.h \
+       dude.h \
        dn.h \
+       filechecker.h \
+       filemapper.h \
        lace.h \
        localencoding.h \
        log.h \
        logmacro.h \
+       mapper.h \
+       mapselector.h \
        msgheader.h \
        msgtrans.h \
+       nameprep.h \
        normalizer.h \
        race.h \
        res.h \
@@ -89,21 +103,22 @@ HDRS = \
        result.h \
        selectiveencode.h \
        strhash.h \
-       translator.h \
+       ucsmap.h \
+       ucsset.h \
        unicode.h \
        unormalize.h \
        utf5.h \
+       utf6.h \
        utf8.h \
        util.h \
-       zldrule.h
+       version.h
 
 all:
 
 install:
-       [ -d $(INCDIR) ] || mkdir $(INCDIR)
-       [ -d $(MDNINCDIR) ] || mkdir $(MDNINCDIR)
+       $(MKINSTALLDIRS) $(mdnincludedir)
        for hdr in $(HDRS); \
-               do $(INSTALL_DATA) $(srcdir)/$$hdr $(MDNINCDIR); done
+               do $(INSTALL_DATA) $(srcdir)/$$hdr $(mdnincludedir); done
 
 clean:
        rm -f *~
diff --git a/contrib/idn/mdnkit/include/mdn/ace.h b/contrib/idn/mdnkit/include/mdn/ace.h
new file mode 100644 (file)
index 0000000..9d18e8c
--- /dev/null
@@ -0,0 +1,130 @@
+/* $Id: ace.h,v 1.1 2001/06/09 00:29:55 tale 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+ * Tokyo, 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) Japan Network Information Center.  All rights reserved."
+ * 
+ * 4. Neither the name of JPNIC may 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.
+ * 
+ * 6. Indemnification by Licensee
+ *    Any person or entities using and/or redistributing this Software under
+ *    this License Terms and Conditions shall defend indemnify and hold
+ *    harmless JPNIC from and against any and all judgements damages,
+ *    expenses, settlement liabilities, cost and other liabilities of any
+ *    kind as a result of use and redistribution of this Software or any
+ *    claim, suite, action, litigation or proceeding by any third party
+ *    arising out of or relates to this License Terms and Conditions.
+ * 
+ * 7. Governing Law, Jurisdiction and Venue
+ *    This License Terms and Conditions shall be governed by and and
+ *    construed in accordance with the law of Japan. Any person or entities
+ *    using and/or redistributing this Software under this License Terms and
+ *    Conditions hereby agrees and consent to the personal and exclusive
+ *    jurisdiction and venue of Tokyo District Court of Japan.
+ */
+
+#ifndef MDN_ACE_H
+#define MDN_ACE_H 1
+
+/*
+ * ACE converter utility module.
+ */
+
+#include <mdn/result.h>
+
+/*
+ * ACE identifier type -- prefix or suffix.
+ */
+enum {
+       mdn__ace_prefix,
+       mdn__ace_suffix
+};
+
+/*
+ * ACE encoding/decode procedure.
+ *
+ * This prototype applies to both encode and decode procedure.  Both
+ * of which converts a domain label (i.e. contains no dots) pointed by
+ * 'from', whose length is 'fromlen', and stores the result to 'to',
+ * whose size is 'tolen'.
+ * the ACE string must not have ACE prefix/suffix, as it is automatically
+ * handled by 'mdn__ace_convert'.
+ */
+typedef mdn_result_t (*mdn__ace_proc_t)(const char *from, size_t fromlen,
+                                       char *to, size_t tolen);
+
+/*
+ * ACE converter property.
+ *
+ * 'id_type' shows the type of ACE identifier, which is either
+ * 'mdn__ace_prefix' or 'mdn__ace_suffix'.  'id_str' is the ACE
+ * identifier itself.  'encoder' and 'decode' are pointers to the
+ * encode and decode procedures.
+ * Encode procedure converts a domain name label in UTF-8 to
+ * ACE-encoded one, and decode procedure converts ACE-encoded label to
+ * UTF-8 encoded one.
+ */
+typedef struct {
+       int id_type;                    /* mdn__ace_prefix/mdn__ace_suffix */
+       const char *id_str;             /* prefix/suffix string */
+       mdn__ace_proc_t encoder;        /* encode procedure */
+       mdn__ace_proc_t decoder;        /* decode procedure */
+} mdn__ace_t;
+
+/*
+ * Utility for ACE converter.
+ *
+ * Convert a domain name given by 'from' and stores the result to
+ * 'to', whose length is 'tolen'.  If 'dir' is 'mdn_convert_u2l',
+ * 'from' points UTF-8 string which is converted to ACE encoding.  If
+ * 'dir' is 'mdn_convert_l2u', 'from' points ACE string which is
+ * converted to UTF-8.
+ * This function first breaks down the given name into labels,
+ * and encode/decode each label.  When encoding, conversion of
+ * STD13 conforming labels (i.e. valid ASCII labels) is skipped.
+ * When decoding, if the decoding failed but the label is a legitimate
+ * ASCII label, those labels are copied verbatim.  To reject illegally
+ * encoded labels, the decoding process performs two kinds of checks:
+ *  1. check that the decoded string does NOT comform to STD13.
+ *  2. try encoding the decoded string, and see if the result matches
+ *     to the original string.
+ */
+extern mdn_result_t
+mdn__ace_convert(mdn__ace_t *ctx, mdn_converter_dir_t dir,
+                const char *from, char *to, size_t tolen);
+
+#endif /* MDN_ACE_H */
diff --git a/contrib/idn/mdnkit/include/mdn/altdude.h b/contrib/idn/mdnkit/include/mdn/altdude.h
new file mode 100644 (file)
index 0000000..9dd523a
--- /dev/null
@@ -0,0 +1,88 @@
+/* $Id: altdude.h,v 1.1 2001/06/09 00:29:55 tale 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+ * Tokyo, 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) Japan Network Information Center.  All rights reserved."
+ * 
+ * 4. Neither the name of JPNIC may 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.
+ * 
+ * 6. Indemnification by Licensee
+ *    Any person or entities using and/or redistributing this Software under
+ *    this License Terms and Conditions shall defend indemnify and hold
+ *    harmless JPNIC from and against any and all judgements damages,
+ *    expenses, settlement liabilities, cost and other liabilities of any
+ *    kind as a result of use and redistribution of this Software or any
+ *    claim, suite, action, litigation or proceeding by any third party
+ *    arising out of or relates to this License Terms and Conditions.
+ * 
+ * 7. Governing Law, Jurisdiction and Venue
+ *    This License Terms and Conditions shall be governed by and and
+ *    construed in accordance with the law of Japan. Any person or entities
+ *    using and/or redistributing this Software under this License Terms and
+ *    Conditions hereby agrees and consent to the personal and exclusive
+ *    jurisdiction and venue of Tokyo District Court of Japan.
+ */
+
+#ifndef MDN_ALTDUDE_H
+#define MDN_ALTDUDE_H 1
+
+/*
+ * AltDUDE Converter.
+ *
+ * See Internet Draft draft-ietf-idn-altdude-00.txt for details.  Note
+ * that this implementation does not support "case preservation"
+ * option.
+ */
+
+#include <mdn/result.h>
+#include <mdn/converter.h>
+
+extern mdn_result_t
+mdn__altdude_open(mdn_converter_t ctx, mdn_converter_dir_t dir,
+                 void **privdata);
+
+extern mdn_result_t
+mdn__altdude_close(mdn_converter_t ctx, void *privdata,
+                  mdn_converter_dir_t dir);
+
+extern mdn_result_t
+mdn__altdude_convert(mdn_converter_t ctx, void *privdata,
+                    mdn_converter_dir_t dir,
+                    const char *from, char *to, size_t tolen);
+
+#endif /* MDN_ALTDUDE_H */
similarity index 65%
rename from contrib/idn/mdnkit/include/mdn/translator.h
rename to contrib/idn/mdnkit/include/mdn/amcacem.h
index cdb5c4e402ee1f871b6990aa4edd1869023cc38e..828c41d15c21472d42919dd5c2b10dcfdba189ea 100644 (file)
@@ -1,6 +1,6 @@
-/* $Id: translator.h,v 1.10 2000/11/21 02:09:04 ishisone Exp $ */
+/* $Id: amcacem.h,v 1.1 2001/06/09 00:29:55 tale Exp $ */
 /*
- * Copyright (c) 2000 Japan Network Information Center.  All rights reserved.
+ * Copyright (c) 2001 Japan Network Information Center.  All rights reserved.
  *  
  * By using this file, you agree to the terms and conditions set forth bellow.
  * 
  *    jurisdiction and venue of Tokyo District Court of Japan.
  */
 
-#ifndef MDN_TRANSLATOR_H
-#define MDN_TRANSLATOR_H 1
+#ifndef MDN_AMCACEM_H
+#define MDN_AMCACEM_H 1
 
 /*
- * Domain name ZLD/codeset translator.
+ * AMC-ACE-M Converter.
+ *
+ * See Internet Draft draft-ietf-idn-amc-ace-m-00.txt for details.
  */
 
 #include <mdn/result.h>
 #include <mdn/converter.h>
-#include <mdn/normalizer.h>
 
-/*
- * Translate domain name encoded in the local codeset to the target
- * codeset.
- *
- * Requires:
- *     Both 'local_zld' and 'target_zld' must be canonicalized (or NULL)
- *     using mdn_translator_canonicalzld.
- *
- * Returns:
- *     mdn_success             -- ok.
- *     mdn_nomemory            -- malloc failed.
- *     mdn_buffer_overflow     -- output buffer too small.
- *     mdn_invalid_encoding    -- there are some invalid characters in
- *                                the specified domain name.
- */
 extern mdn_result_t
-mdn_translator_translate(mdn_converter_t local_converter,
-                        mdn_converter_t local_alternate_converter,
-                        const char *local_zld,
-                        mdn_normalizer_t normalizer,
-                        mdn_converter_t target_converter,
-                        mdn_converter_t target_alternate_converter,
-                        const char *target_zld,
-                        const char *from, char *to, size_t tolen);
+mdn__amcacem_open(mdn_converter_t ctx, mdn_converter_dir_t dir,
+                 void **privdata);
 
-/*
- * Canonicalize ZLD.
- *
- * Note:
- *     The string returned in *canonicalizedp is malloc'ed by this
- *     function.  You should free it when no longer needed.
- *
- *     If specified ZLD is "" or ".", NULL will be returned in
- *     *canonicalizedp.
- *
- * Returns:
- *     mdn_success             -- ok.
- *     mdn_nomemory            -- malloc failed.
- */
 extern mdn_result_t
-mdn_translator_canonicalzld(const char *zld, char **canonicalizedp);
+mdn__amcacem_close(mdn_converter_t ctx, void *privdata,
+                mdn_converter_dir_t dir);
 
-/*
- * Try matching ZLD against domain name.
- *
- * Requires:
- *     'zld' must be canonicalized (or NULL) using
- *     mdn_translator_canonicalzld.
- *
- * Returns:
- *     1               -- match.
- *     0               -- no match.
- */
-extern int
-mdn_translator_matchzld(const char *domain, const char *zld);
+extern mdn_result_t
+mdn__amcacem_convert(mdn_converter_t ctx, void *privdata,
+                  mdn_converter_dir_t dir, const char *from, char *to,
+                  size_t tolen);
 
-#endif /* MDN_TRANSLATOR_H */
+#endif /* MDN_AMCACEM_H */
diff --git a/contrib/idn/mdnkit/include/mdn/amcaceo.h b/contrib/idn/mdnkit/include/mdn/amcaceo.h
new file mode 100644 (file)
index 0000000..157888e
--- /dev/null
@@ -0,0 +1,85 @@
+/* $Id: amcaceo.h,v 1.1 2001/06/09 00:29:55 tale 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+ * Tokyo, 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) Japan Network Information Center.  All rights reserved."
+ * 
+ * 4. Neither the name of JPNIC may 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.
+ * 
+ * 6. Indemnification by Licensee
+ *    Any person or entities using and/or redistributing this Software under
+ *    this License Terms and Conditions shall defend indemnify and hold
+ *    harmless JPNIC from and against any and all judgements damages,
+ *    expenses, settlement liabilities, cost and other liabilities of any
+ *    kind as a result of use and redistribution of this Software or any
+ *    claim, suite, action, litigation or proceeding by any third party
+ *    arising out of or relates to this License Terms and Conditions.
+ * 
+ * 7. Governing Law, Jurisdiction and Venue
+ *    This License Terms and Conditions shall be governed by and and
+ *    construed in accordance with the law of Japan. Any person or entities
+ *    using and/or redistributing this Software under this License Terms and
+ *    Conditions hereby agrees and consent to the personal and exclusive
+ *    jurisdiction and venue of Tokyo District Court of Japan.
+ */
+
+#ifndef MDN_AMCACEO_H
+#define MDN_AMCACEO_H 1
+
+/*
+ * AMC-ACE-O Converter.
+ *
+ * See Internet Draft draft-ietf-idn-amc-ace-o-00.txt for details.
+ */
+
+#include <mdn/result.h>
+#include <mdn/converter.h>
+
+extern mdn_result_t
+mdn__amcaceo_open(mdn_converter_t ctx, mdn_converter_dir_t dir,
+                 void **privdata);
+
+extern mdn_result_t
+mdn__amcaceo_close(mdn_converter_t ctx, void *privdata,
+                  mdn_converter_dir_t dir);
+
+extern mdn_result_t
+mdn__amcaceo_convert(mdn_converter_t ctx, void *privdata,
+                    mdn_converter_dir_t dir, const char *from, char *to,
+                    size_t tolen);
+
+#endif /* MDN_AMCACEO_H */
diff --git a/contrib/idn/mdnkit/include/mdn/amcacer.h b/contrib/idn/mdnkit/include/mdn/amcacer.h
new file mode 100644 (file)
index 0000000..b42b296
--- /dev/null
@@ -0,0 +1,86 @@
+/* $Id: amcacer.h,v 1.1 2001/06/09 00:29:55 tale 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+ * Tokyo, 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) Japan Network Information Center.  All rights reserved."
+ * 
+ * 4. Neither the name of JPNIC may 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.
+ * 
+ * 6. Indemnification by Licensee
+ *    Any person or entities using and/or redistributing this Software under
+ *    this License Terms and Conditions shall defend indemnify and hold
+ *    harmless JPNIC from and against any and all judgements damages,
+ *    expenses, settlement liabilities, cost and other liabilities of any
+ *    kind as a result of use and redistribution of this Software or any
+ *    claim, suite, action, litigation or proceeding by any third party
+ *    arising out of or relates to this License Terms and Conditions.
+ * 
+ * 7. Governing Law, Jurisdiction and Venue
+ *    This License Terms and Conditions shall be governed by and and
+ *    construed in accordance with the law of Japan. Any person or entities
+ *    using and/or redistributing this Software under this License Terms and
+ *    Conditions hereby agrees and consent to the personal and exclusive
+ *    jurisdiction and venue of Tokyo District Court of Japan.
+ */
+
+#ifndef MDN_AMCACER_H
+#define MDN_AMCACER_H 1
+
+/*
+ * AMC-ACE-R Converter.
+ *
+ * See Internet Draft draft-ietf-idn-amc-ace-r-00.txt (but not yet
+ * published at the time of this writing) for details.
+ */
+
+#include <mdn/result.h>
+#include <mdn/converter.h>
+
+extern mdn_result_t
+mdn__amcacer_open(mdn_converter_t ctx, mdn_converter_dir_t dir,
+                 void **privdata);
+
+extern mdn_result_t
+mdn__amcacer_close(mdn_converter_t ctx, void *privdata,
+                mdn_converter_dir_t dir);
+
+extern mdn_result_t
+mdn__amcacer_convert(mdn_converter_t ctx, void *privdata,
+                  mdn_converter_dir_t dir, const char *from, char *to,
+                  size_t tolen);
+
+#endif /* MDN_AMCACER_H */
diff --git a/contrib/idn/mdnkit/include/mdn/api.h b/contrib/idn/mdnkit/include/mdn/api.h
new file mode 100644 (file)
index 0000000..4a6ee27
--- /dev/null
@@ -0,0 +1,224 @@
+/* $Id: api.h,v 1.1 2001/06/09 00:29:55 tale 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+ * Tokyo, 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) Japan Network Information Center.  All rights reserved."
+ * 
+ * 4. Neither the name of JPNIC may 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.
+ * 
+ * 6. Indemnification by Licensee
+ *    Any person or entities using and/or redistributing this Software under
+ *    this License Terms and Conditions shall defend indemnify and hold
+ *    harmless JPNIC from and against any and all judgements damages,
+ *    expenses, settlement liabilities, cost and other liabilities of any
+ *    kind as a result of use and redistribution of this Software or any
+ *    claim, suite, action, litigation or proceeding by any third party
+ *    arising out of or relates to this License Terms and Conditions.
+ * 
+ * 7. Governing Law, Jurisdiction and Venue
+ *    This License Terms and Conditions shall be governed by and and
+ *    construed in accordance with the law of Japan. Any person or entities
+ *    using and/or redistributing this Software under this License Terms and
+ *    Conditions hereby agrees and consent to the personal and exclusive
+ *    jurisdiction and venue of Tokyo District Court of Japan.
+ */
+
+#ifndef MDN_API_H
+#define MDN_API_H 1
+
+#include <mdn/result.h>
+
+/*
+ * Application Programming Interface for Multilingual Domain Name Handling.
+ * This module provides high-level APIs for ordinary applications.
+ * Low-level APIs are also available.  See "res.h" for details.
+ */
+
+/*
+ * Actions
+ */
+#define MDN_LOCALCONV  0x0001 /* Local encoding <-> UTF-8 conversion */
+#define MDN_IDNCONV    0x0002 /* UTF-8 <-> IDN encoding (ACE) conversion */
+#define MDN_NAMEPREP   0x0004 /* NAMEPREP */
+#define MDN_UNASCHECK  0x0008 /* Unassigned code point check */
+#define MDN_DELIMMAP   0x0100 /* Delimiter mapping */
+#define MDN_LOCALMAP   0x0200 /* Local mapping */
+
+/*
+ * Actions needed for ordinary applications.
+ */
+#define MDN_ENCODE_APP \
+       (MDN_LOCALCONV|MDN_DELIMMAP|MDN_LOCALMAP|MDN_NAMEPREP|MDN_IDNCONV)
+#define MDN_DECODE_APP (MDN_IDNCONV|MDN_LOCALCONV)
+
+/*
+ * Initialize the whole library, and load configuration from the default
+ * configuration file (mdn.conf).
+ *
+ * Initialization of the library will be done only once when this function
+ * is called first, while loading of the configuration file will be done
+ * every time it is called.
+ *
+ * If 'mdn_encodename' or 'mdn_decodename' is called without calling this
+ * function, implicit initialization will be done prior to encoding/decoding
+ * process.
+ *
+ * Returns:
+ *     mdn_success             -- ok.
+ *     mdn_nofile              -- cannot open the configuration file.
+ *     mdn_invalid_syntax      -- syntax error found in the file.
+ *     mdn_invalid_name        -- there are invalid names (encoding,
+ *                                normalization etc.).
+ *     mdn_nomemory            -- malloc failed.
+ */
+extern mdn_result_t
+mdn_nameinit(void);
+
+/*
+ * Encode multilingual domain name for name resolution.
+ *
+ * The encoding process consists of the following 5 steps.
+ *
+ *    1. local encoding (such as Shift-JIS or Big5) to UTF-8 conversion.
+ *    2. delimiter mapping, which maps certain characters to period
+ *       (U+002E, FULL STOP) character.
+ *    3. non-standard local mapping, whose exact rule is determined by
+ *       the TLD of the domain name to be encoded.  This allows
+ *      locale-specific mapping for each ccTLD.
+ *    4. NAMEPREP, as described in the Internet Draft
+ *       (draft-ietf-idn-nameprep-XX).  This step has an option of
+ *       prohibiting use of unassigned code points in the domain name.
+ *    5. UTF-8 to IDN encoding (ACE) conversion.
+ *
+ * Some steps can be skipped according to the application's needs.
+ * For example, if the application holds the multilingual domain names in
+ * UTF-8, step 1 above won't be necessary.
+ *
+ * 'actions' specifies what actions to take when encoding, and is
+ * a bitwise-or of the following flags:
+ *
+ *   MDN_LOCALCONV     -- perform local encoding to UTF-8 conversion (step 1)
+ *   MDN_DELIMMAP      -- perform delimiter mapping (step 2)
+ *   MDN_LOCALMAP      -- perform local mapping (step 3)
+ *   MDN_NAMEPREP       -- perform NAMEPREP (step 4)
+ *   MDN_UNASCHECK     -- perform optional unassigned codepoint check
+ *                        (also step 4)
+ *   MDN_IDNCONV       -- perform UTF-8 to IDN encoding conversion (step 5)
+ *
+ * Note that if no flags are specified, 'mdn_encodename' does nothing
+ * fancy, just copies the given name verbatim.
+ *
+ * Returns:
+ *     mdn_success             -- ok.
+ *     mdn_invalid_action      -- invalid action flag specified.
+ *     mdn_invalid_encoding    -- the given string has invalid/illegal
+ *                                byte sequence.
+ *     mdn_prohibited          -- prohibited/unassigned code point found.
+ *     mdn_buffer_overflow     -- 'tolen' is too small.
+ *     mdn_nomemory            -- malloc failed.
+ *
+ * Also, if this function is called without calling 'mdn_nameinit',
+ * the following error codes might be returned.
+ *     mdn_nofile              -- cannot open the configuration file.
+ *     mdn_invalid_syntax      -- syntax error found in the file.
+ *     mdn_invalid_name        -- there are invalid names (encoding,
+ *                                normalization etc.).
+ */
+extern mdn_result_t
+mdn_encodename(int actions, const char *from, char *to, size_t tolen);
+
+/*
+ * Decode multilingual domain name returned from resolver.
+ *
+ * The decoding process consists of the following 2 steps.  It is much
+ * simpler than the encoding process because no name preparation is
+ * necessary.
+ *
+ *    1. server encoding (ACE) to UTF-8 conversion.
+ *    2. UTF-8 to local encoding conversion.
+ *
+ * 'actions' specifies what actions to take when decoding, and is
+ * a bitwise-or of the following flags:
+ *
+ *   MDN_IDNCONV       -- perform IDN encoding to UTF-8 conversion (step 1)
+ *   MDN_LOCALCONV     -- perform UTF-8 to local encoding conversion (step 2)
+ *
+ * Note that if no flags are specified, 'mdn_decodename' does nothing
+ * but copying the given name verbatim.
+ *
+ * Returns:
+ *     mdn_success             -- ok.
+ *     mdn_invalid_action      -- invalid action flag specified.
+ *     mdn_invalid_encoding    -- the given string has invalid/illegal
+ *                                byte sequence.
+ *     mdn_buffer_overflow     -- 'tolen' is too small.
+ *     mdn_nomemory            -- malloc failed.
+ *
+ * Also, if this function is called without calling 'mdn_nameinit',
+ * the following error codes might be returned.
+ *     mdn_nofile              -- cannot open the configuration file.
+ *     mdn_invalid_syntax      -- syntax error found in the file.
+ *     mdn_invalid_name        -- there are invalid names (encoding,
+ *                                normalization etc.).
+ */
+extern mdn_result_t
+mdn_decodename(int actions, const char *from, char *to, size_t tolen);
+
+/*
+ * For convenience.
+ */
+#define mdn_localtoutf8(from, to, tolen) \
+       mdn_encodename(MDN_LOCALCONV, from, to, len)
+#define mdn_delimitermap(from, to, tolen) \
+       mdn_encodename(MDN_DELIMMAP, from, to, len)
+#define mdn_localmap(from, to, tolen) \
+       mdn_encodename(MDN_LOCALMAP, from, to, len)
+#define mdn_nameprep(from, to, tolen) \
+       mdn_encodename(MDN_NAMEPREP, from, to, len)
+#define mdn_utf8toidn(from, to, tolen) \
+       mdn_encodename(MDN_IDNCONV, from, to, len)
+#define mdn_idntoutf8(from, to, tolen) \
+       mdn_decodename(MDN_IDNCONV, from, to, tolen)
+#define mdn_utf8tolocal(from, to, tolen) \
+       mdn_decodename(MDN_LOCALCONV, from, to, tolen)
+
+#define mdn_localtoidn(from, to, tolen) \
+       mdn_encodename(MDN_ENCODE_APP, from, to, tolen)
+#define mdn_idntolocal(from, to, tolen) \
+       mdn_decodename(MDN_DECODE_APP, from, to, tolen)
+
+#endif /* MDN_API_H */
index da93bc3f3f402bdb6523eedd320046147c9311d5..f562e8e1dcc22aac48baaf6a329814bab5cb783d 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: brace.h,v 1.1 2000/11/14 00:13:29 ishisone Exp $ */
+/* $Id: brace.h,v 1.2 2001/02/26 09:32:25 m-kasahr Exp $ */
 /*
  * Copyright (c) 2000 Japan Network Information Center.  All rights reserved.
  *  
 #include <mdn/converter.h>
 
 extern mdn_result_t
-mdn__brace_open(mdn_converter_t ctx, mdn_converter_dir_t dir);
+mdn__brace_open(mdn_converter_t ctx, mdn_converter_dir_t dir, void **privdata);
 
 extern mdn_result_t
-mdn__brace_close(mdn_converter_t ctx, mdn_converter_dir_t dir);
+mdn__brace_close(mdn_converter_t ctx, void *privdata,
+                mdn_converter_dir_t dir);
 
 extern mdn_result_t
-mdn__brace_convert(mdn_converter_t ctx, mdn_converter_dir_t dir,
-                  const char *from, char *to, size_t tolen);
+mdn__brace_convert(mdn_converter_t ctx, void *privdata,
+                  mdn_converter_dir_t dir, const char *from, char *to,
+                  size_t tolen);
 
 #endif /* MDN_BRACE_H */
diff --git a/contrib/idn/mdnkit/include/mdn/checker.h b/contrib/idn/mdnkit/include/mdn/checker.h
new file mode 100644 (file)
index 0000000..0efb436
--- /dev/null
@@ -0,0 +1,178 @@
+/* $Id: checker.h,v 1.1 2001/06/09 00:29:56 tale 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+ * Tokyo, 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) Japan Network Information Center.  All rights reserved."
+ * 
+ * 4. Neither the name of JPNIC may 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.
+ * 
+ * 6. Indemnification by Licensee
+ *    Any person or entities using and/or redistributing this Software under
+ *    this License Terms and Conditions shall defend indemnify and hold
+ *    harmless JPNIC from and against any and all judgements damages,
+ *    expenses, settlement liabilities, cost and other liabilities of any
+ *    kind as a result of use and redistribution of this Software or any
+ *    claim, suite, action, litigation or proceeding by any third party
+ *    arising out of or relates to this License Terms and Conditions.
+ * 
+ * 7. Governing Law, Jurisdiction and Venue
+ *    This License Terms and Conditions shall be governed by and and
+ *    construed in accordance with the law of Japan. Any person or entities
+ *    using and/or redistributing this Software under this License Terms and
+ *    Conditions hereby agrees and consent to the personal and exclusive
+ *    jurisdiction and venue of Tokyo District Court of Japan.
+ */
+
+#ifndef MDN_CHECKER_H
+#define MDN_CHECKER_H 1
+
+/*
+ * Character Checker.
+ *
+ * Perfom checking characters in the specified domain name.
+ */
+
+#include <mdn/result.h>
+#include <mdn/filechecker.h>
+#include <mdn/nameprep.h>
+
+/*
+ * Schems name prefixes for the standard nameprep prohibit/unassigned
+ * checks.
+ *
+ * If you'd like to add the unassigned check scheme of "nameprep-XX"
+ * to a checker context, MDN_CHECKER_UNASSIGNED_PREFIX + "nameprep-XX"
+ * (i.e. "unassigned#nameprep-XX") is the scheme name passed to
+ * mdn_checker_add().
+ */
+#define MDN_CHECKER_PROHIBIT_PREFIX    "prohibit#"
+#define MDN_CHECKER_UNASSIGNED_PREFIX  "unassigned#"
+
+/*
+ * Checker object type.
+ */
+typedef struct mdn_checker *mdn_checker_t;
+
+/*
+ * Initialize module.  Must be called before any other calls of
+ * the functions of this module.
+ *
+ * Returns:
+ *      mdn_success             -- ok.
+ *      mdn_nomemory            -- malloc failed.
+ */
+extern mdn_result_t
+mdn_checker_initialize(void);
+
+/*
+ * Create a checker context.
+ *
+ * Returns:
+ *      mdn_success             -- ok.
+ *      mdn_nomemory            -- malloc failed.
+ */
+extern mdn_result_t
+mdn_checker_create(mdn_checker_t *ctxp);
+
+/*
+ * Decrement reference count of the checker `ctx' created by
+ * 'mdn_checker_create', if it is still refered by another object.
+ * Otherwise, release all the memory allocated to the checker.
+ */
+extern void
+mdn_checker_destroy(mdn_checker_t ctx);
+
+/*
+ * Increment reference count of the checker `ctx' created by
+ * 'mdn_checker_create'.
+ */
+extern void
+mdn_checker_incrref(mdn_checker_t ctx);
+
+/*
+ * Add checking scheme `name' to the checker to `ctx'.
+ * 
+ * Returns:
+ *      mdn_success             -- ok.
+ *      mdn_invalid_name        -- the given name is not valid.
+ *      mdn_nomemory            -- malloc failed.
+ */
+extern mdn_result_t
+mdn_checker_add(mdn_checker_t ctx, const char *name);
+
+extern mdn_result_t
+mdn_checker_addall(mdn_checker_t ctx, const char **names, int nnames);
+
+/*
+ * Check an UTF-8 name.  All checking schemes regsitered in `ctx'
+ * are applied in the regisration order.
+ *
+ * Returns:
+ *      mdn_success             -- ok.
+ *      mdn_nomemory            -- malloc failed.
+ *      mdn_buffer_overflow     -- output buffer is too small.
+ *      mdn_invalid_encoding    -- the input string has invalid/illegal
+ *                                 UTF-8 sequence.
+ */
+extern mdn_result_t
+mdn_checker_lookup(mdn_checker_t ctx, const char *utf8, const char **found);
+
+/*
+ * Checking procedure type.
+ */
+typedef mdn_result_t (*mdn_checker_createproc_t)(const char *parameter,
+                                                void **ctxp);
+typedef void         (*mdn_checker_destroyproc_t)(void *ctx);
+typedef mdn_result_t (*mdn_checker_lookupproc_t)(void *ctx, const char *utf8,
+                                                 const char **found);
+                                              
+/*
+ * Register a new checking scheme.
+ *
+ * You can override the default normalization schemes, if you want.
+ * 
+ * Returns:
+ *      mdn_success             -- ok.
+ *      mdn_nomemory            -- malloc failed.
+ */
+extern mdn_result_t
+mdn_checker_register(const char *prefix,
+                    mdn_checker_createproc_t create,
+                    mdn_checker_destroyproc_t destroy,
+                    mdn_checker_lookupproc_t lookup);
+
+#endif /* MDN_CHECKER_H */
index dc9705fcf1a9da0aff94c166873cc1cbfcef0b83..6d62924524a7d8e03c2f76dcb1dad2a312a3eae8 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: converter.h,v 1.13 2000/08/02 02:06:40 ishisone Exp $ */
+/* $Id: converter.h,v 1.15 2001/02/26 09:32:25 m-kasahr Exp $ */
 /*
  * Copyright (c) 2000 Japan Network Information Center.  All rights reserved.
  *  
@@ -113,11 +113,20 @@ mdn_converter_create(const char *name, mdn_converter_t *ctxp,
                     int flags);
 
 /*
- * Destroy the conversion context created by mdn_converter_create.
+ * Decrement reference count of the converter `ctx' created by
+ * 'mdn_converter_create', if it is still refered by another object.
+ * Otherwise, release all the memory allocated to the converter.
  */
 extern void
 mdn_converter_destroy(mdn_converter_t ctx);
 
+/*
+ * Increment reference count of the converter `ctx' created by
+ * 'mdn_converter_create'.
+ */
+extern void
+mdn_converter_incrref(mdn_converter_t ctx);
+
 /*
  * Convert between local codeset and UTF-8.  Note that each conversion
  * is started with initial state.
@@ -207,10 +216,13 @@ mdn_converter_resetalias(void);
  * Conversion operation functions.
  */
 typedef mdn_result_t (*mdn_converter_openproc_t)(mdn_converter_t ctx,
-                                                mdn_converter_dir_t dir);
+                                                mdn_converter_dir_t dir,
+                                                void **privdata);
 typedef mdn_result_t (*mdn_converter_closeproc_t)(mdn_converter_t ctx,
+                                                 void *privdata,
                                                  mdn_converter_dir_t dir);
 typedef mdn_result_t (*mdn_converter_convertproc_t)(mdn_converter_t ctx,
+                                                   void *privdata,
                                                    mdn_converter_dir_t dir,
                                                    const char *from,
                                                    char *to, size_t tolen);
diff --git a/contrib/idn/mdnkit/include/mdn/delimitermap.h b/contrib/idn/mdnkit/include/mdn/delimitermap.h
new file mode 100644 (file)
index 0000000..9fef761
--- /dev/null
@@ -0,0 +1,148 @@
+/* $Id: delimitermap.h,v 1.1 2001/06/09 00:29:58 tale 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+ * Tokyo, 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) Japan Network Information Center.  All rights reserved."
+ * 
+ * 4. Neither the name of JPNIC may 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.
+ * 
+ * 6. Indemnification by Licensee
+ *    Any person or entities using and/or redistributing this Software under
+ *    this License Terms and Conditions shall defend indemnify and hold
+ *    harmless JPNIC from and against any and all judgements damages,
+ *    expenses, settlement liabilities, cost and other liabilities of any
+ *    kind as a result of use and redistribution of this Software or any
+ *    claim, suite, action, litigation or proceeding by any third party
+ *    arising out of or relates to this License Terms and Conditions.
+ * 
+ * 7. Governing Law, Jurisdiction and Venue
+ *    This License Terms and Conditions shall be governed by and and
+ *    construed in accordance with the law of Japan. Any person or entities
+ *    using and/or redistributing this Software under this License Terms and
+ *    Conditions hereby agrees and consent to the personal and exclusive
+ *    jurisdiction and venue of Tokyo District Court of Japan.
+ */
+
+#ifndef MDN_DELIMITERMAP_H
+#define MDN_DELIMITERMAP_H 1
+
+/*
+ * Mapper.
+ *
+ * Perfom mapping local delimiters to `.'.
+ */
+
+#include <mdn/result.h>
+
+/*
+ * Map object type.
+ */
+typedef struct mdn_delimitermap *mdn_delimitermap_t;
+
+/*
+ * Create a delimitermap context.
+ *
+ * Returns:
+ *      mdn_success             -- ok.
+ *      mdn_nomemory            -- malloc failed.
+ */
+extern mdn_result_t
+mdn_delimitermap_create(mdn_delimitermap_t *ctxp);
+
+/*
+ * Decrement reference count of the delimitermap `ctx' created by
+ * 'mdn_delimitermap_create', if it is still refered by another object.
+ * Otherwise, release all the memory allocated to the delimitermap.
+ */
+extern void
+mdn_delimitermap_destroy(mdn_delimitermap_t ctx);
+
+/*
+ * Increment reference count of the delimitermap `ctx' created by
+ * 'mdn_delimitermap_create'.
+ */
+extern void
+mdn_delimitermap_incrref(mdn_delimitermap_t ctx);
+
+/*
+ * Add a local delimiter.
+ * The context must be in the building phase -- that is, before
+ * 'mdn_delimitermap_fix' is called for the context.
+ * 
+ * Returns:
+ *      mdn_success             -- ok.
+ *      mdn_nomemory            -- malloc failed.
+ *      mdn_invalid_codepoint   -- delimiter is not valid UCS-4 character.
+ *     mdn_failure             -- already fixed by 'mdn_delimitermap_fix'.
+ */
+extern mdn_result_t
+mdn_delimitermap_add(mdn_delimitermap_t ctx, unsigned long delimiter);
+
+extern mdn_result_t
+mdn_delimitermap_addall(mdn_delimitermap_t ctx, unsigned long *delimiters,
+                       int ndelimiters);
+
+/*
+ * Perform internal arrangement of mapping.
+ * Once the context is fixed by this function, it becomes immutable,
+ * and it shifts into 'lookup' phase.
+ */
+extern void
+mdn_delimitermap_fix(mdn_delimitermap_t ctx);
+
+/*
+ * Map local delimiters in an UTF-8 domain name to `.'.
+ * The context must be in the lookup phase -- in other words,
+ * 'mdn_delimitermap_fix' must be called for the context before calling
+ * this function.
+ *
+ * Note that if no delimiter is added to the context, the function copies
+ * the string and doesn't check that the input string has valid UTF-8
+ * sequence.
+ *
+ * Returns:
+ *      mdn_success             -- ok.
+ *      mdn_buffer_overflow     -- output buffer is too small.
+ *      mdn_invalid_encoding    -- the input string has invalid/illegal
+ *                                 UTF-8 sequence.
+ *     mdn_failure             -- not fixed by 'mdn_delimitermap_fix' yet.
+ */
+extern mdn_result_t
+mdn_delimitermap_map(mdn_delimitermap_t ctx, const char *from, char *to,
+                    size_t tolen);
+
+#endif /* MDN_DELIMITERMAP_H */
diff --git a/contrib/idn/mdnkit/include/mdn/dude.h b/contrib/idn/mdnkit/include/mdn/dude.h
new file mode 100644 (file)
index 0000000..aaa4aeb
--- /dev/null
@@ -0,0 +1,86 @@
+/* $Id: dude.h,v 1.1 2001/06/09 00:29:58 tale 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+ * Tokyo, 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) Japan Network Information Center.  All rights reserved."
+ * 
+ * 4. Neither the name of JPNIC may 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.
+ * 
+ * 6. Indemnification by Licensee
+ *    Any person or entities using and/or redistributing this Software under
+ *    this License Terms and Conditions shall defend indemnify and hold
+ *    harmless JPNIC from and against any and all judgements damages,
+ *    expenses, settlement liabilities, cost and other liabilities of any
+ *    kind as a result of use and redistribution of this Software or any
+ *    claim, suite, action, litigation or proceeding by any third party
+ *    arising out of or relates to this License Terms and Conditions.
+ * 
+ * 7. Governing Law, Jurisdiction and Venue
+ *    This License Terms and Conditions shall be governed by and and
+ *    construed in accordance with the law of Japan. Any person or entities
+ *    using and/or redistributing this Software under this License Terms and
+ *    Conditions hereby agrees and consent to the personal and exclusive
+ *    jurisdiction and venue of Tokyo District Court of Japan.
+ */
+
+#ifndef MDN_DUDE_H
+#define MDN_DUDE_H 1
+
+/*
+ * DUDE Converter.
+ *
+ * See Internet Draft draft-ietf-idn-dude-01.txt for details.  Note
+ * that this implementation does not support the optional feature of
+ * DUDE, which is "case preservation".  Implementing this feature
+ * requires reimplementation of NAMEPREP process of libmdn.
+ */
+
+#include <mdn/result.h>
+#include <mdn/converter.h>
+
+extern mdn_result_t
+mdn__dude_open(mdn_converter_t ctx, mdn_converter_dir_t dir, void **privdata);
+
+extern mdn_result_t
+mdn__dude_close(mdn_converter_t ctx, void *privdata, mdn_converter_dir_t dir);
+
+extern mdn_result_t
+mdn__dude_convert(mdn_converter_t ctx, void *privdata, mdn_converter_dir_t dir,
+                 const char *from, char *to, size_t tolen);
+
+#endif /* MDN_DUDE_H */
diff --git a/contrib/idn/mdnkit/include/mdn/filechecker.h b/contrib/idn/mdnkit/include/mdn/filechecker.h
new file mode 100644 (file)
index 0000000..653c6aa
--- /dev/null
@@ -0,0 +1,144 @@
+/* $Id: filechecker.h,v 1.1 2001/06/09 00:29:58 tale 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+ * Tokyo, 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) Japan Network Information Center.  All rights reserved."
+ * 
+ * 4. Neither the name of JPNIC may 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.
+ * 
+ * 6. Indemnification by Licensee
+ *    Any person or entities using and/or redistributing this Software under
+ *    this License Terms and Conditions shall defend indemnify and hold
+ *    harmless JPNIC from and against any and all judgements damages,
+ *    expenses, settlement liabilities, cost and other liabilities of any
+ *    kind as a result of use and redistribution of this Software or any
+ *    claim, suite, action, litigation or proceeding by any third party
+ *    arising out of or relates to this License Terms and Conditions.
+ * 
+ * 7. Governing Law, Jurisdiction and Venue
+ *    This License Terms and Conditions shall be governed by and and
+ *    construed in accordance with the law of Japan. Any person or entities
+ *    using and/or redistributing this Software under this License Terms and
+ *    Conditions hereby agrees and consent to the personal and exclusive
+ *    jurisdiction and venue of Tokyo District Court of Japan.
+ */
+
+#ifndef MDN_FILECHECKER_H
+#define MDN_FILECHECKER_H 1
+
+/*
+ * Character checker -- check if there are any characters specified
+ * by a file in the given string.
+ */
+
+#include <mdn/result.h>
+
+/*
+ * Check object type.
+ */
+typedef struct mdn__filechecker *mdn__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 'mdn_success' is returned.  Otherwise, the contents
+ * of '*ctxp' is undefined.
+ *
+ * Returns:
+ *     mdn_success             -- ok.
+ *     mdn_nofile              -- cannot open the specified file.
+ *     mdn_nomemory            -- malloc failed.
+ *     mdn_invalid_syntax      -- file format is not valid.
+ */
+extern mdn_result_t
+mdn__filechecker_create(const char *file, mdn__filechecker_t *ctxp);
+
+/*
+ * Release memory for the specified context.
+ */
+extern void
+mdn__filechecker_destroy(mdn__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 string 'str', which must be a valid UTF-8 string.  If there
+ * are none, NULL is stored in '*found'.  Otherwise, the pointer to
+ * the first occurence of such character is stored in '*found'.
+ *
+ * Returns:
+ *     mdn_success             -- ok.
+ *     mdn_invalid_encoding    -- 'str' is not a valid UTF-8 string.
+ */
+extern mdn_result_t
+mdn__filechecker_lookup(mdn__filechecker_t ctx, const char *str,
+                       const char **found);
+
+/*
+ * The following functions are for internal use.
+ * They are used for this module to be add to the checker module.
+ */
+extern mdn_result_t
+mdn__filechecker_createproc(const char *parameter, void **ctxp);
+
+extern void
+mdn__filechecker_destroyproc(void *ctxp);
+
+extern mdn_result_t
+mdn__filechecker_lookupproc(void *ctx, const char *str, const char **found);
+
+#endif /* MDN_FILECHECKER_H */
diff --git a/contrib/idn/mdnkit/include/mdn/filemapper.h b/contrib/idn/mdnkit/include/mdn/filemapper.h
new file mode 100644 (file)
index 0000000..045d191
--- /dev/null
@@ -0,0 +1,145 @@
+/* $Id: filemapper.h,v 1.1 2001/06/09 00:29:58 tale 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+ * Tokyo, 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) Japan Network Information Center.  All rights reserved."
+ * 
+ * 4. Neither the name of JPNIC may 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.
+ * 
+ * 6. Indemnification by Licensee
+ *    Any person or entities using and/or redistributing this Software under
+ *    this License Terms and Conditions shall defend indemnify and hold
+ *    harmless JPNIC from and against any and all judgements damages,
+ *    expenses, settlement liabilities, cost and other liabilities of any
+ *    kind as a result of use and redistribution of this Software or any
+ *    claim, suite, action, litigation or proceeding by any third party
+ *    arising out of or relates to this License Terms and Conditions.
+ * 
+ * 7. Governing Law, Jurisdiction and Venue
+ *    This License Terms and Conditions shall be governed by and and
+ *    construed in accordance with the law of Japan. Any person or entities
+ *    using and/or redistributing this Software under this License Terms and
+ *    Conditions hereby agrees and consent to the personal and exclusive
+ *    jurisdiction and venue of Tokyo District Court of Japan.
+ */
+
+#ifndef MDN_FILEMAPPER_H
+#define MDN_FILEMAPPER_H 1
+
+/*
+ * Perform character mapping (substitution) according to a
+ * map file.
+ */
+
+#include <mdn/result.h>
+
+/*
+ * Mapping object type.
+ */
+typedef struct mdn__filemapper *mdn__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:
+ *     mdn_success             -- ok.
+ *     mdn_nofile              -- cannot open the specified file.
+ *     mdn_nomemory            -- malloc failed.
+ *     mdn_invalid_syntax      -- file format is not valid.
+ */
+extern mdn_result_t
+mdn__filemapper_create(const char *file, mdn__filemapper_t *ctxp);
+
+/*
+ * Release memory for the given context.
+ */
+extern void
+mdn__filemapper_destroy(mdn__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:
+ *     mdn_success             -- ok.
+ *     mdn_buffer_overflow     -- result buffer is too small.
+ *     mdn_invalid_encoding    -- 'str' is not a valid UTF-8 string.
+ */
+extern mdn_result_t
+mdn__filemapper_map(mdn__filemapper_t ctx, const char *from,
+                   char *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 mdn_result_t
+mdn__filemapper_createproc(const char *parameter, void **ctxp);
+
+extern void
+mdn__filemapper_destroyproc(void *ctxp);
+
+extern mdn_result_t
+mdn__filemapper_mapproc(void *ctx, const char *from, char *to, size_t tolen);
+
+#endif /* MDN_FILEMAPPER_H */
index 1c0e792343abbfb8325a8687623120302337cf37..8f2a561439b3d7d46259b3523f9bb1b944a83c99 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: lace.h,v 1.1 2000/11/14 00:13:29 ishisone Exp $ */
+/* $Id: lace.h,v 1.2 2001/02/26 09:32:25 m-kasahr Exp $ */
 /*
  * Copyright (c) 2000 Japan Network Information Center.  All rights reserved.
  *  
 #include <mdn/converter.h>
 
 extern mdn_result_t
-mdn__lace_open(mdn_converter_t ctx, mdn_converter_dir_t dir);
+mdn__lace_open(mdn_converter_t ctx, mdn_converter_dir_t dir, void **privdata);
 
 extern mdn_result_t
-mdn__lace_close(mdn_converter_t ctx, mdn_converter_dir_t dir);
+mdn__lace_close(mdn_converter_t ctx, void *privdata, mdn_converter_dir_t dir);
 
 extern mdn_result_t
-mdn__lace_convert(mdn_converter_t ctx, mdn_converter_dir_t dir,
+mdn__lace_convert(mdn_converter_t ctx, void *privdata, mdn_converter_dir_t dir,
                  const char *from, char *to, size_t tolen);
 
 #endif /* MDN_LACE_H */
diff --git a/contrib/idn/mdnkit/include/mdn/mapper.h b/contrib/idn/mdnkit/include/mdn/mapper.h
new file mode 100644 (file)
index 0000000..16506b4
--- /dev/null
@@ -0,0 +1,166 @@
+/* $Id: mapper.h,v 1.1 2001/06/09 00:29:59 tale 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+ * Tokyo, 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) Japan Network Information Center.  All rights reserved."
+ * 
+ * 4. Neither the name of JPNIC may 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.
+ * 
+ * 6. Indemnification by Licensee
+ *    Any person or entities using and/or redistributing this Software under
+ *    this License Terms and Conditions shall defend indemnify and hold
+ *    harmless JPNIC from and against any and all judgements damages,
+ *    expenses, settlement liabilities, cost and other liabilities of any
+ *    kind as a result of use and redistribution of this Software or any
+ *    claim, suite, action, litigation or proceeding by any third party
+ *    arising out of or relates to this License Terms and Conditions.
+ * 
+ * 7. Governing Law, Jurisdiction and Venue
+ *    This License Terms and Conditions shall be governed by and and
+ *    construed in accordance with the law of Japan. Any person or entities
+ *    using and/or redistributing this Software under this License Terms and
+ *    Conditions hereby agrees and consent to the personal and exclusive
+ *    jurisdiction and venue of Tokyo District Court of Japan.
+ */
+
+#ifndef MDN_MAPPER_H
+#define MDN_MAPPER_H 1
+
+/*
+ * Mapper.
+ *
+ * Perfom mapping the specified domain name.
+ */
+
+#include <mdn/result.h>
+#include <mdn/filemapper.h>
+#include <mdn/nameprep.h>
+
+/*
+ * Map object type.
+ */
+typedef struct mdn_mapper *mdn_mapper_t;
+
+/*
+ * Initialize module.  Must be called before any other calls of
+ * the functions of this module.
+ *
+ * Returns:
+ *      mdn_success             -- ok.
+ *      mdn_nomemory            -- malloc failed.
+ */
+extern mdn_result_t
+mdn_mapper_initialize(void);
+
+/*
+ * Create a mapper context.
+ *
+ * Returns:
+ *      mdn_success             -- ok.
+ *      mdn_nomemory            -- malloc failed.
+ */
+extern mdn_result_t
+mdn_mapper_create(mdn_mapper_t *ctxp);
+
+/*
+ * Decrement reference count of the mapper `ctx' created by
+ * 'mdn_mapper_create', if it is still refered by another object.
+ * Otherwise, release all the memory allocated to the mapper.
+ */
+extern void
+mdn_mapper_destroy(mdn_mapper_t ctx);
+
+/*
+ * Increment reference count of the mapper `ctx' created by
+ * 'mdn_mapper_create'.
+ */
+extern void
+mdn_mapper_incrref(mdn_mapper_t ctx);
+
+/*
+ * Add mapping scheme `name' to the mapper to `ctx'.
+ * 
+ * Returns:
+ *      mdn_success             -- ok.
+ *      mdn_invalid_name        -- the given name is not valid.
+ *      mdn_nomemory            -- malloc failed.
+ */
+extern mdn_result_t
+mdn_mapper_add(mdn_mapper_t ctx, const char *name);
+
+extern mdn_result_t
+mdn_mapper_addall(mdn_mapper_t ctx, const char **names, int nnames);
+
+/*
+ * Map an UTF-8 domain name.  All mapping schemes regsitered in `ctx'
+ * are applied in the regisration order.
+ *
+ * Returns:
+ *      mdn_success             -- ok.
+ *      mdn_nomemory            -- malloc failed.
+ *      mdn_buffer_overflow     -- output buffer is too small.
+ *      mdn_invalid_encoding    -- the input string has invalid/illegal
+ *                                 UTF-8 sequence.
+ */
+extern mdn_result_t
+mdn_mapper_map(mdn_mapper_t ctx, const char *from, char *to, size_t tolen);
+
+/*
+ * Mapping procedure type.
+ */
+typedef mdn_result_t (*mdn_mapper_createproc_t)(const char *parameter,
+                                               void **ctxp);
+typedef void         (*mdn_mapper_destroyproc_t)(void *ctxp);
+typedef mdn_result_t (*mdn_mapper_mapproc_t)(void *ctx, const char *from,
+                                             char *, size_t);
+                                              
+/*
+ * Register a new mapping scheme.
+ *
+ * You can override the default normalization schemes, if you want.
+ * 
+ * Returns:
+ *      mdn_success             -- ok.
+ *      mdn_nomemory            -- malloc failed.
+ */
+extern mdn_result_t
+mdn_mapper_register(const char *prefix,
+                   mdn_mapper_createproc_t create,
+                   mdn_mapper_destroyproc_t destroy,
+                   mdn_mapper_mapproc_t map);
+
+#endif /* MDN_MAPPER_H */
diff --git a/contrib/idn/mdnkit/include/mdn/mapselector.h b/contrib/idn/mdnkit/include/mdn/mapselector.h
new file mode 100644 (file)
index 0000000..fc3e032
--- /dev/null
@@ -0,0 +1,162 @@
+/* $Id: mapselector.h,v 1.1 2001/06/09 00:29:59 tale 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+ * Tokyo, 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) Japan Network Information Center.  All rights reserved."
+ * 
+ * 4. Neither the name of JPNIC may 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.
+ * 
+ * 6. Indemnification by Licensee
+ *    Any person or entities using and/or redistributing this Software under
+ *    this License Terms and Conditions shall defend indemnify and hold
+ *    harmless JPNIC from and against any and all judgements damages,
+ *    expenses, settlement liabilities, cost and other liabilities of any
+ *    kind as a result of use and redistribution of this Software or any
+ *    claim, suite, action, litigation or proceeding by any third party
+ *    arising out of or relates to this License Terms and Conditions.
+ * 
+ * 7. Governing Law, Jurisdiction and Venue
+ *    This License Terms and Conditions shall be governed by and and
+ *    construed in accordance with the law of Japan. Any person or entities
+ *    using and/or redistributing this Software under this License Terms and
+ *    Conditions hereby agrees and consent to the personal and exclusive
+ *    jurisdiction and venue of Tokyo District Court of Japan.
+ */
+
+#ifndef MDN_MAPSELECTOR_H
+#define MDN_MAPSELECTOR_H 1
+
+/*
+ * Map selector.
+ *
+ * Perfom mapping the specified domain name according with the TLD
+ * of the donmain name.
+ */
+
+#include <mdn/result.h>
+#include <mdn/mapper.h>
+
+/*
+ * Special TLDs for map selection.
+ */
+#define MDN_MAPSELECTOR_NO_TLD         "-"
+#define MDN_MAPSELECTOR_DEFAULT                "."
+
+/*
+ * Mapselector object type.
+ */
+typedef struct mdn_mapselector *mdn_mapselector_t;
+
+/*
+ * Initialize module.  Must be called before any other calls of
+ * the functions of this module.
+ *
+ * Returns:
+ *      mdn_success             -- ok.
+ *      mdn_nomemory            -- malloc failed.
+ */
+extern mdn_result_t
+mdn_mapselector_initialize(void);
+
+/*
+ * Create a mapselector context.
+ *
+ * Returns:
+ *      mdn_success             -- ok.
+ *      mdn_nomemory            -- malloc failed.
+ */
+extern mdn_result_t
+mdn_mapselector_create(mdn_mapselector_t *ctxp);
+
+/*
+ * Decrement reference count of the mapselector `ctx' created by
+ * 'mdn_mapselector_create', if it is still refered by another object.
+ * Otherwise, release all the memory allocated to the mapselector.
+ */
+extern void
+mdn_mapselector_destroy(mdn_mapselector_t ctx);
+
+/*
+ * Increment reference count of the mapselector `ctx' created by
+ * 'mdn_mapselector_create'.
+ */
+extern void
+mdn_mapselector_incrref(mdn_mapselector_t ctx);
+
+/*
+ * Return the mapper for `tld' registered in `ctx', or return NULL if
+ * mapper for `tld' is not registered.
+ */
+extern mdn_mapper_t
+mdn_mapselector_mapper(mdn_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:
+ *      mdn_success             -- ok.
+ *      mdn_invalid_name        -- the given tld or name is not valid.
+ *      mdn_nomemory            -- malloc failed.
+ */
+extern mdn_result_t
+mdn_mapselector_add(mdn_mapselector_t ctx, const char *tld, const char *name);
+
+extern mdn_result_t
+mdn_mapselector_addall(mdn_mapselector_t ctx, const char *tld,
+                      const char **names, int nnames);
+
+/*
+ * Map an UTF-8 domain name 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:
+ *      mdn_success             -- ok.
+ *      mdn_nomemory            -- malloc failed.
+ *      mdn_buffer_overflow     -- output buffer is too small.
+ *      mdn_invalid_encoding    -- the input string has invalid/illegal
+ *                                 UTF-8 sequence.
+ */
+extern mdn_result_t
+mdn_mapselector_map(mdn_mapselector_t ctx,
+                    const char *from, char *to, size_t tolen);
+
+#endif /* MDN_MAPSELECTOR_H */
index f99f511c6cfac4536182d7e4b9c77d33eafc30c5..7f5167e7ee59e36cce72ed9e61ac7d313c4533b5 100644 (file)
@@ -1,6 +1,7 @@
-/* $Id: msgtrans.h,v 1.11 2000/11/21 02:09:04 ishisone Exp $ */
+/* $Id: msgtrans.h,v 1.12 2001/02/15 01:15:25 ishisone Exp $ */
 /*
- * Copyright (c) 2000 Japan Network Information Center.  All rights reserved.
+ * 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.
  * 
  */
 
 #include <mdn/result.h>
-#include <mdn/converter.h>
-#include <mdn/normalizer.h>
-#include <mdn/zldrule.h>
-
-/*
- * Translation parameters.
- *
- * 'use_local_rule' determines how local codeset and ZLD should be
- * derived.
- *
- * If 'use_local_rule' is true, 'local_rule' will be used for
- * determining ZLD/codeset.  'mdn_msgtrans_translate' will use
- * the rule to determine the ZLD and codeset, and set 'local_zld'
- * and 'local_converter' properly upon return.
- *
- * Otherwise, 'mdn_msgtrans_translate' will assume that specified
- * domain name is either
- *   + the one having ZLD specified by 'local_zld' and codeset
- *     specified by 'local_converter', or
- *   + the one without ZLD and made of only legitimate characters
- *     (alphabets, digits and hyphens), that is, a non-internationalized
- *     domain name.
- *
- * If 'local_alt_converter' is not NULL, 'mdn_msgtrans_translate' tries
- * converting the specified domain name using it before attempting
- * 'local_conerter'.
- *
- * 'target_conveter' and 'target_zld' together define the ZLD/codeset
- * of the target.  If 'target_alt_converter' is not NULL, then it is
- * used instead of 'target_converter' if the conversion from UTF-8 to
- * the target encoding fails with error 'mdn_nomapping'.
- *
- * 'normalizer' defines the normalization schemes.
- */
-typedef struct mdn_msgtrans_param {
-       int use_local_rule;
-       mdn_zldrule_t local_rule;
-       mdn_converter_t local_converter;
-       mdn_converter_t local_alt_converter;
-       char *local_zld;
-       mdn_converter_t target_converter;
-       mdn_converter_t target_alt_converter;
-       char *target_zld;
-       mdn_normalizer_t normalizer;
-} mdn_msgtrans_param_t;
+#include <mdn/resconf.h>
 
 /*
  * Translate DNS message according to the parameters given.
  *
+ * The parameters are given by 'resconf', which is created by
+ * 'mdn_resconf_create'.
+ *
  * Returns:
  *     mdn_success             -- ok, translated successfully.
  *     mdn_invalid_message     -- the specified message is not valid.
  *     mdn_nomemory            -- malloc failed.
  */
 extern mdn_result_t
-mdn_msgtrans_translate(mdn_msgtrans_param_t *param,
+mdn_msgtrans_translate(mdn_resconf_t resconf,
                       const char *msg, size_t msglen,
                       char *outbuf, size_t outbufsize, size_t *outmsglenp);
 
diff --git a/contrib/idn/mdnkit/include/mdn/nameprep.h b/contrib/idn/mdnkit/include/mdn/nameprep.h
new file mode 100644 (file)
index 0000000..53f3961
--- /dev/null
@@ -0,0 +1,155 @@
+/* $Id: nameprep.h,v 1.1 2001/06/09 00:30:00 tale 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+ * Tokyo, 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) Japan Network Information Center.  All rights reserved."
+ * 
+ * 4. Neither the name of JPNIC may 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.
+ * 
+ * 6. Indemnification by Licensee
+ *    Any person or entities using and/or redistributing this Software under
+ *    this License Terms and Conditions shall defend indemnify and hold
+ *    harmless JPNIC from and against any and all judgements damages,
+ *    expenses, settlement liabilities, cost and other liabilities of any
+ *    kind as a result of use and redistribution of this Software or any
+ *    claim, suite, action, litigation or proceeding by any third party
+ *    arising out of or relates to this License Terms and Conditions.
+ * 
+ * 7. Governing Law, Jurisdiction and Venue
+ *    This License Terms and Conditions shall be governed by and and
+ *    construed in accordance with the law of Japan. Any person or entities
+ *    using and/or redistributing this Software under this License Terms and
+ *    Conditions hereby agrees and consent to the personal and exclusive
+ *    jurisdiction and venue of Tokyo District Court of Japan.
+ */
+
+#ifndef MDN_NAMEPREP_H
+#define MDN_NAMEPREP_H 1
+
+/*
+ * Perform NAMEPREP (mapping, prohibited/unassigned checking).
+ */
+
+#include <mdn/result.h>
+
+/*
+ * A Handle for nameprep operations.
+ */
+typedef struct mdn_nameprep *mdn_nameprep_t;
+
+
+/*
+ * 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:
+ *     mdn_success             -- ok.
+ *     mdn_notfound            -- specified version not found.
+ */
+extern mdn_result_t
+mdn_nameprep_create(const char *version, mdn_nameprep_t *handlep);
+
+/*
+ * Close a handle, which was created by 'mdn_nameprep_create'.
+ */
+extern void
+mdn_nameprep_destroy(mdn_nameprep_t handle);
+
+/*
+ * Perform character mapping on UTF-8 string specified by 'from', and
+ * store the result into 'to', whose length is specified by 'tolen'.
+ *
+ * Returns:
+ *     mdn_success             -- ok.
+ *     mdn_invalid_encoding    -- input is not a valid UTF-8 string.
+ *     mdn_buffer_overflow     -- result buffer is too small.
+ */
+extern mdn_result_t
+mdn_nameprep_map(mdn_nameprep_t handle, const char *from,
+                char *to, size_t tolen);
+
+/*
+ * Check if a UTF-8 string 's' 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:
+ *     mdn_success             -- no prohibited character found.
+ *     mdn_invalid_encoding    -- input is not a valid UTF-8 string.
+ */
+extern mdn_result_t
+mdn_nameprep_isprohibited(mdn_nameprep_t handle, const char *s,
+                         const char **found);
+
+/*
+ * Check if a UTF-8 string 's' 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:
+ *     mdn_success             -- no unassigned character found.
+ *     mdn_invalid_encoding    -- input is not a valid UTF-8 string.
+ */
+extern mdn_result_t
+mdn_nameprep_isunassigned(mdn_nameprep_t handle, const char *s,
+                         const char **found);
+
+/*
+ * The following functions are for internal use.
+ * They are used for this module to be add to the checker and mapper modules.
+ */
+extern mdn_result_t
+mdn__nameprep_createproc(const char *parameter, void **handlep);
+
+extern void
+mdn__nameprep_destroyproc(void *handle);
+
+extern mdn_result_t
+mdn__nameprep_mapproc(void *handle, const char *from, char *to, size_t tolen);
+
+extern mdn_result_t
+mdn__nameprep_prohibitproc(void *handle, const char *str, const char **found);
+
+extern mdn_result_t
+mdn__nameprep_unassignedproc(void *handle, const char *str,
+                            const char **found);
+
+#endif /* MDN_NAMEPREP_H */
index 07b9cfdc20f8d7e065887cd2d1806a704c09a2d5..c1b7f80c487dbb2891a5a35535fe35e2ad7864f6 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: normalizer.h,v 1.11 2000/08/23 05:52:40 ishisone Exp $ */
+/* $Id: normalizer.h,v 1.13 2001/02/23 10:36:51 m-kasahr Exp $ */
 /*
  * Copyright (c) 2000 Japan Network Information Center.  All rights reserved.
  *  
@@ -101,12 +101,20 @@ extern mdn_result_t
 mdn_normalizer_create(mdn_normalizer_t *ctxp);
 
 /*
- * Release all the memory allocated for a normalizer created by
- * 'mdn_normalizer_create'.
+ * Decrement reference count of the normalizer `ctx' created by
+ * 'mdn_normalizer_create', if it is still refered by another object.
+ * Otherwise, release all the memory allocated to the normalizer.
  */
 extern void
 mdn_normalizer_destroy(mdn_normalizer_t ctx);
 
+/*
+ * Increment reference count of the normalizer `ctx' created by
+ * 'mdn_normalizer_create'.
+ */
+extern void
+mdn_normalizer_incrref(mdn_normalizer_t ctx);
+
 /*
  * Add a normalization scheme to a normalizer.
  *
@@ -121,6 +129,10 @@ mdn_normalizer_destroy(mdn_normalizer_t ctx);
 extern mdn_result_t
 mdn_normalizer_add(mdn_normalizer_t ctx, const char *scheme_name);
 
+extern mdn_result_t
+mdn_normalizer_addall(mdn_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
index 9b83d9aa181a827d9c4b7b3f95dcb41ead1614d3..cb885ff69a8fc52882c9f622a7af6536b9319533 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: race.h,v 1.8 2000/10/18 02:15:28 ishisone Exp $ */
+/* $Id: race.h,v 1.9 2001/02/26 09:32:25 m-kasahr Exp $ */
 /*
  * Copyright (c) 2000 Japan Network Information Center.  All rights reserved.
  *  
 /*
  * RACE Converter.
  *
- * See Internet Draft draft-ietf-idn-race-02.txt for details.
+ * See Internet Draft draft-ietf-idn-race-03.txt for details.
  */
 
 #include <mdn/result.h>
 #include <mdn/converter.h>
 
 extern mdn_result_t
-mdn__race_open(mdn_converter_t ctx, mdn_converter_dir_t dir);
+mdn__race_open(mdn_converter_t ctx, mdn_converter_dir_t dir, void **privdata);
 
 extern mdn_result_t
-mdn__race_close(mdn_converter_t ctx, mdn_converter_dir_t dir);
+mdn__race_close(mdn_converter_t ctx, void *privdata, mdn_converter_dir_t dir);
 
 extern mdn_result_t
-mdn__race_convert(mdn_converter_t ctx, mdn_converter_dir_t dir,
-                 const char *from, char *to, size_t tolen);
+mdn__race_convert(mdn_converter_t ctx, void *privdata,
+                 mdn_converter_dir_t dir, const char *from, char *to,
+                 size_t tolen);
 
 #endif /* MDN_RACE_H */
index 011b1f0e7174d908f8c7463bb1edd53b2b8d9149..4d47505aca69b498682b66df2f497a8e2a6d618e 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: res.h,v 1.3 2000/08/23 06:56:58 ishisone Exp $ */
+/* $Id: res.h,v 1.7 2001/04/11 08:16:07 m-kasahr Exp $ */
 /*
  * Copyright (c) 2000 Japan Network Information Center.  All rights reserved.
  *  
 #include <mdn/resconf.h>
 
 /*
- * Convert from the local codeset string to UCS (UTF-8).
- *
- * 'local_name' is a string containing a domain name encoded in the
- * local codeset or the encoding specified by 'alternate-encoding'
- * directive in the MDN configuration file (mdnres.conf).
- * This function converts it to UCS and stores in
- * the buffer 'ucs_name', which is 'ucs_name_len' bytes long.
- *
- * 'conf' is a MDN resolver configuration context created by
- * 'mdn_resconf_create()', or NULL.  If it is NULL, no conversion is
- * performed, and the contents of 'local_name' are copied to 'ucs_name'
- * verbatim.
+ * Convert and check the string.
+ *
+ * This function converts the string `from' to `to', checks `from' or
+ * combination of them, using `actions'.
+ *
+ * `actions' is a sequence of characters as follows:
+ *
+ *     l       convert the local codeset string to UTF-8.
+ *     L       convert the UTF-8 string to the local codeset.
+ *     d       perform local delimiter mapping.
+ *     M       perfrom TLD based local mapping.
+ *     m       perform the nameprep mapping.
+ *     n       perform nameprep normalization.
+ *     p       check whether the string contains nameprep prohibited
+ *             character.
+ *     N       equivalent to "mnp".
+ *     u       check whether the string contains nameprep unassigned
+ *             codepoint.
+ *     I       convert the UTF-8 string to ACE.
+ *     i       convert the ACE string to UTF-8.
+ *     a       convert the alternative encoded ACE sting to UTF-8.
+ *     A       convert the UTF-8 string to alternative ACE encoding.
  *
  * Returns:
  *     mdn_success             -- ok.
  *     mdn_buffer_overflow     -- output buffer is too small.
  *     mdn_invalid_encoding    -- input string has invalid byte sequence.
  *     mdn_invalid_name        -- local encoding (codeset) name is invalid.
- *     mdn_failure             -- other failure.
+ *     mdn_invalid_action      -- `actions' contains invalid action.
+ *     mdn_invalid_nomemory    -- out of memory.
+ *     mdn_invalid_nomapping   -- no mapping to output codeset.
+ *     mdn_prohibited          -- input string has a prohibited character.
+ *     mdn_failuer             -- other failure.
  */
 extern mdn_result_t
-mdn_res_localtoucs(mdn_resconf_t conf, const char *local_name,
-                  char *ucs_name, size_t ucs_name_len);
+mdn_res_nameconv(mdn_resconf_t ctx, const char *actions, const char *from,
+                char *to, size_t tolen);
 
 /*
- * Convert from UCS (UTF-8) string to the local codeset.
- *
- * 'ucs_name' is a string containing a domain name encoded in UTF-8.
- * This function converts it to the local codeset and stores in
- * the buffer 'local_name', which is 'local_name_len' bytes long.
- * If there are any characters which cannot be converted to the local
- * codeset, the 'alternate-encoding' is used instead of the local codeset.
- *
- * 'conf' is a MDN resolver configuration context created by
- * 'mdn_resconf_create()', or NULL.  If it is NULL, no conversion is
- * performed, and the contents of 'local_name' are copied to 'ucs_name'
- * verbatim.
- *
- * Returns:
- *     mdn_success             -- ok.
- *     mdn_buffer_overflow     -- output buffer is too small.
- *     mdn_invalid_encoding    -- input string has invalid byte sequence.
- *     mdn_invalid_name        -- local encoding (codeset) name is invalid.
- *     mdn_failure             -- other failure.
+ * Convert the local codeset string to UTF-8.
+ * equivalent to:
+ *     mdn_res_nameconv(ctx, "l", from, to, tolen);
  */
 extern mdn_result_t
-mdn_res_ucstolocal(mdn_resconf_t conf, const char *ucs_name,
-                  char *local_name, size_t local_name_len);
+mdn_res_localtoucs(mdn_resconf_t ctx, const char *from, char *to,
+                  size_t tolen);
+
+#define mdn_res_localtoucs(ctx, from, to, tolen) \
+       mdn_res_nameconv(ctx, "l", from, to, tolen)
 
 /*
- * Normalize UCS string.
- *
- * Perform normalization/canonicalization specified by the configuration
- * context 'conf' on the UTF-8 encoded string 'name', and store the result
- * in 'normalized_name', whose size is 'normalized_name_len' bytes.
- *
- * 'conf' is a MDN resolver configuration context created by
- * 'mdn_resconf_create()', or NULL.  If it is NULL, no normalization is
- * performed, and the contents of 'name' are copied to 'normalized_name'
- * verbatim.
- *
- * Returns:
- *     mdn_success             -- ok.
- *     mdn_buffer_overflow     -- output buffer is too small.
- *     mdn_invalid_encoding    -- input is not a valid UTF-8 string.
- *     mdn_nomemory            -- malloc failed.
+ * Convert the UTF-8 string to the local codeset.
+ * equivalent to:
+ *     mdn_res_nameconv(ctx, "L", from, to, tolen);
  */
 extern mdn_result_t
-mdn_res_normalize(mdn_resconf_t conf, const char *name,
-                 char *normalized_name, size_t normalized_name_len);
+mdn_res_ucstolocal(mdn_resconf_t ctx, const char *from, char *to,
+                  size_t tolen);
+
+#define mdn_res_ucstolocal(ctx, from, to, tolen) \
+       mdn_res_nameconv(ctx, "L", from, to, tolen)
 
 /*
- * Convert from UCS (UTF-8) string to the encoding used in DNS protocol.
- *
- * 'ucs_name' is a string containing a domain name encoded in UTF-8.
- * This function converts it to the encoding used in DNS protocol data
- * (such as RACE), and stores in the buffer 'dns_name', which is
- * 'dns_name_len' bytes long.  Also if ZLD is specified in the configuration
- * file, it is appended to the conversion result.
- *
- * Both the encoding used in DNS protocol and ZLD are specified by 'conf'
- * which is a MDN resolver configuration context.  If 'conf' is NULL,
- * then no conversion is done.
- *
- * Requires:
- *     'ucs_name' must be a FQDN.  Otherwise the conversion result might
- *     not be correct for some DNS protocol encoding (namely UTF-5).
- *
- * Returns:
- *     mdn_success             -- ok.
- *     mdn_buffer_overflow     -- output buffer is too small.
- *     mdn_invalid_encoding    -- input string has invalid byte sequence.
- *     mdn_invalid_name        -- local encoding (codeset) name is invalid.
- *     mdn_failure             -- other failure.
+ * Perform the nameprep mapping.
+ * equivalent to:
+ *     mdn_res_nameconv(ctx, "m", from, to, tolen);
  */
 extern mdn_result_t
-mdn_res_ucstodns(mdn_resconf_t conf, const char *ucs_name, char *dns_name,
-                size_t dns_name_len);
+mdn_res_map(mdn_resconf_t ctx, const char *from, char *to, size_t tolen);
+
+#define mdn_res_map(ctx, from, to, tolen) \
+       mdn_res_nameconv(ctx, "m", from, to, tolen)
 
 /*
- * Convert from the DNS protocol encoding to UCS (UTF-8).
- *
- * This function converts 'dns_name' whose encoding is the encoding
- * used in DNS protocol data into UTF-8, and stores the result in the
- * buffer 'ucs_name', which is 'ucs_name_len' bytes long.  Also, if
- * 'dns_name' has ZLD specified by 'conf', the ZLD part is removed
- * from 'dns_name' before the conversion.
- *
- * Both the encoding used in DNS protocol and ZLD are specified by 'conf'
- * which is a MDN resolver configuration context.  If 'conf' is NULL,
- * then no conversion is done.
- *
- * Returns:
- *     mdn_success             -- ok.
- *     mdn_buffer_overflow     -- output buffer is too small.
- *     mdn_invalid_encoding    -- input string has invalid byte sequence.
- *     mdn_invalid_name        -- local encoding (codeset) name is invalid.
- *     mdn_failure             -- other failure.
+ * Perform nameprep normalization.
+ * equivalent to:
+ *     mdn_res_nameconv(ctx, "n", from, to, tolen);
+ */
+extern mdn_result_t
+mdn_res_normalize(mdn_resconf_t ctx, const char *from, char *to, size_t tolen);
+
+#define mdn_res_normalize(ctx, from, to, tolen) \
+       mdn_res_nameconv(ctx, "n", from, to, tolen)
+
+/*
+ * Check whether the string contains nameprep prohibited character.
+ * equivalent to:
+ *     mdn_res_nameconv(ctx, "p", from, to, tolen);
+ */
+extern mdn_result_t
+mdn_res_prohibitcheck(mdn_resconf_t ctx, const char *from, char *to,
+                     size_t tolen);
+
+#define mdn_res_prohibitcheck(ctx, from, to, tolen) \
+       mdn_res_nameconv(ctx, "p", from, to, tolen)
+
+/*
+ * Check whether the string contains nameprep unassigned character.
+ * equivalent to:
+ *     mdn_res_nameconv(ctx, "u", from, to, tolen);
+ */
+extern mdn_result_t
+mdn_res_unassignedcheck(mdn_resconf_t ctx, const char *from, char *to,
+                       size_t tolen);
+
+#define mdn_res_unassignedcheck(ctx, from, to, tolen) \
+       mdn_res_nameconv(ctx, "u", from, to, tolen)
+
+/*
+ * Perform local delimiter mapping.
+ * equivalent to:
+ *     mdn_res_nameconv(ctx, "d", from, to, tolen);
  */
 extern mdn_result_t
-mdn_res_dnstoucs(mdn_resconf_t conf, const char *dns_name, char *ucs_name,
-                size_t ucs_name_len);
+mdn_res_delimitermap(mdn_resconf_t ctx, const char *from, char *to,
+                    size_t tolen);
+
+#define mdn_res_delimitermap(ctx, from, to, tolen) \
+       mdn_res_nameconv(ctx, "d", from, to, tolen)
+
+/*
+ * Perfrom TLD based local mapping.
+ * equivalent to:
+ *     mdn_res_nameconv(ctx, "M", from, to, tolen);
+ */
+extern mdn_result_t
+mdn_res_localmap(mdn_resconf_t ctx, const char *from, char *to, size_t tolen);
+
+#define mdn_res_localmap(ctx, from, to, tolen) \
+       mdn_res_nameconv(ctx, "M", from, to, tolen)
+
+/*
+ * Convert the UTF-8 string to ACE.
+ * equivalent to:
+ *     mdn_res_nameconv(ctx, "I", from, to, tolen);
+ */
+extern mdn_result_t
+mdn_res_ucstodns(mdn_resconf_t ctx, const char *from, char *to, size_t tolen);
+
+#define mdn_res_ucstodns(ctx, from, to, tolen) \
+       mdn_res_nameconv(ctx, "I", from, to, tolen)
+
+/*
+ * Convert the ACE string to UTF-8.
+ * equivalent to:
+ *     mdn_res_nameconv(ctx, "i", from, to, tolen);
+ */
+extern mdn_result_t
+mdn_res_dnstoucs(mdn_resconf_t ctx, const char *from, char *to, size_t tolen);
+
+#define mdn_res_dnstoucs(ctx, from, to, tolen) \
+       mdn_res_nameconv(ctx, "i", from, to, tolen)
 
-#endif
+#endif /* MDN_RES_H */
index 1f9747becc1d384a42aef595def29331931eb091..c737c43523a213d7333dd998b0348334eb4ad5ca 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: resconf.h,v 1.4 2000/08/23 05:53:23 ishisone Exp $ */
+/* $Id: resconf.h,v 1.12 2001/04/16 02:25:17 m-kasahr Exp $ */
 /*
  * Copyright (c) 2000 Japan Network Information Center.  All rights reserved.
  *  
 #include <mdn/result.h>
 #include <mdn/converter.h>
 #include <mdn/normalizer.h>
+#include <mdn/checker.h>
+#include <mdn/mapper.h>
+#include <mdn/mapselector.h>
+#include <mdn/delimitermap.h>
 
 /*
  * Configuration type (opaque).
@@ -107,6 +111,12 @@ mdn_resconf_create(mdn_resconf_t *ctxp);
 extern void
 mdn_resconf_destroy(mdn_resconf_t ctx);
 
+/*
+ * Increment reference count of the context created by 'mdn_resconf_create'.
+ */
+extern void
+mdn_resconf_incrref(mdn_resconf_t ctx);
+
 /*
  * Load configuration file.
  *
@@ -135,10 +145,10 @@ extern char *
 mdn_resconf_defaultfile(void);
 
 /*
- * Get codeset converters.
+ * Get/Set codeset converters.
  *
  *  + for local encoding,
- *  + for DNS protocol encoding,
+ *  + for IDN encoding,
  *  + for alternate encoding (which is used when the string to be converterd
  *    to the local encoding has some characters having no mapping to the
  *    local encoding)
@@ -146,28 +156,159 @@ mdn_resconf_defaultfile(void);
  */
 
 extern mdn_converter_t
-mdn_resconf_localconverter(mdn_resconf_t ctx);
+mdn_resconf_getlocalconverter(mdn_resconf_t ctx);
 
 extern mdn_converter_t
-mdn_resconf_serverconverter(mdn_resconf_t ctx);
+mdn_resconf_getidnconverter(mdn_resconf_t ctx);
 
 extern mdn_converter_t
-mdn_resconf_alternateconverter(mdn_resconf_t ctx);
+mdn_resconf_getalternateconverter(mdn_resconf_t ctx);
+
+extern void
+mdn_resconf_setlocalconverter(mdn_resconf_t ctx,
+                             mdn_converter_t local_converter);
+extern void
+mdn_resconf_setidnconverter(mdn_resconf_t ctx,
+                            mdn_converter_t idn_coverter);
+
+extern void
+mdn_resconf_setalternateconverter(mdn_resconf_t ctx,
+                                  mdn_converter_t alternate_converter);
 
 /*
- * Get Zero-Level-Domain name.
+ * Get/Set domain name normalizer.
  *
- * If there's no ZLD, NULL will be returned.
+ * In case of error, NULL will be returned.
  */
-extern const char *
-mdn_resconf_zld(mdn_resconf_t ctx);
+extern mdn_normalizer_t
+mdn_resconf_getnormalizer(mdn_resconf_t ctx);
+
+extern void
+mdn_resconf_setnormalizer(mdn_resconf_t ctx, mdn_normalizer_t normalizer);
 
 /*
- * Get domain name normalizer.
+ * Get/Set domain name mapper.
  *
+ *  + for nameprep mapping.
+ *  + for TLD based local mapping.
+ *  + for local delimiter mapping.
  * In case of error, NULL will be returned.
  */
-extern mdn_normalizer_t
-mdn_resconf_normalizer(mdn_resconf_t ctx);
+extern mdn_mapper_t
+mdn_resconf_getmapper(mdn_resconf_t ctx);
+
+extern mdn_delimitermap_t
+mdn_resconf_getdelimitermap(mdn_resconf_t ctx);
+
+extern mdn_mapselector_t
+mdn_resconf_getlocalmapselector(mdn_resconf_t ctx);
+
+extern void
+mdn_resconf_setmapper(mdn_resconf_t ctx, mdn_mapper_t mapper);
+
+extern void
+mdn_resconf_setdelimitermap(mdn_resconf_t ctx,
+                           mdn_delimitermap_t delimiter_mapper);
+
+extern void
+mdn_resconf_setlocalmapselector(mdn_resconf_t ctx,
+                               mdn_mapselector_t map_selector);
+
+/*
+ * Get domain name checker.
+ *
+ *  + for prohibited character checking.
+ *  + for unassigned character checking.
+ * In case of error, NULL will be returned.
+ */
+extern mdn_checker_t
+mdn_resconf_getprohibitchecker(mdn_resconf_t ctx);
+
+extern mdn_checker_t
+mdn_resconf_getunassignedchecker(mdn_resconf_t ctx);
+
+extern void
+mdn_resconf_setprohibitchecker(mdn_resconf_t ctx,
+                              mdn_checker_t prohibit_checker);
+
+extern void
+mdn_resconf_setunassignedchecker(mdn_resconf_t ctx,
+                                mdn_checker_t unassigned_checker);
+
+/*
+ * Set mapper, normalizer, prohibit checker and unassigned checker in
+ * the resconf context to the specified NAMEPREP version.
+ */
+extern mdn_result_t
+mdn_resconf_setalternateconvertername(mdn_resconf_t ctx, const char *name,
+                                     int flags);
+
+/*
+ * Set converter, delimitermap, mapper, mapselector, normalizer, checker
+ * by name.
+ */
+extern mdn_result_t
+mdn_resconf_setidnconvertername(mdn_resconf_t ctx, const char *name,
+                               int flags);
+
+extern mdn_result_t
+mdn_resconf_setlocalconvertername(mdn_resconf_t ctx, const char *name,
+                                 int flags);
+
+extern mdn_result_t
+mdn_resconf_addalldelimitermapucs(mdn_resconf_t ctx, unsigned long *v, int nv);
+
+extern mdn_result_t
+mdn_resconf_addalllocalmapselectornames(mdn_resconf_t ctx, const char *tld,
+                                       const char **names, int nnames);
+
+extern mdn_result_t
+mdn_resconf_addallmappernames(mdn_resconf_t ctx, const char **names,
+                             int nnames);
+
+extern mdn_result_t
+mdn_resconf_addallnormalizernames(mdn_resconf_t ctx, const char **names,
+                                 int nnames);
+
+extern mdn_result_t
+mdn_resconf_addallprohibitcheckernames(mdn_resconf_t ctx, const char **names,
+                                      int nnames);
+
+extern mdn_result_t
+mdn_resconf_addallunassignedcheckernames(mdn_resconf_t ctx, const char **names,
+                                        int nnames);
+
+extern mdn_result_t
+mdn_resconf_setnameprepversion(mdn_resconf_t ctx, const char *version);
+
+/*
+ * These macros are provided for backward compatibility to mDNkit 1.x.
+ */
+#define mdn_resconf_localconverter(ctx) \
+       mdn_resconf_getlocalconverter(ctx)
+
+#define mdn_resconf_idnconverter(ctx) \
+       mdn_resconf_getidnconverter(ctx)
+
+#define mdn_resconf_alternateconverter(ctx) \
+       mdn_resconf_getalternateconverter(ctx)
+
+#define mdn_resconf_normalizer(ctx) \
+       mdn_resconf_getnormalizer(ctx)
+
+#define mdn_resconf_mapper(ctx) \
+       mdn_resconf_getmapper(ctx)
+
+#define mdn_resconf_delimitermap(ctx) \
+       mdn_resconf_getdelimitermap(ctx)
+
+#define mdn_resconf_localmapselector(ctx) \
+       mdn_resconf_getlocalmapselector(ctx)
+
+#define mdn_resconf_prohibitchecker(ctx) \
+       mdn_resconf_getprohibitchecker(ctx)
+
+#define mdn_resconf_unassignedchecker(ctx) \
+       mdn_resconf_getunassignedchecker(ctx)
 
-#endif
+#endif /* MDN_RESCONF_H */
index 47a2f8c38a74223895fea955c33553655dee0d62..9015199d2bb1b70042fdb726e2c84211c9da8101 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: result.h,v 1.10 2000/09/27 02:55:37 ishisone Exp $ */
+/* $Id: result.h,v 1.11 2001/02/05 09:10:56 ishisone Exp $ */
 /*
  * Copyright (c) 2000 Japan Network Information Center.  All rights reserved.
  *  
@@ -70,12 +70,15 @@ typedef enum {
        mdn_invalid_syntax,
        mdn_invalid_name,
        mdn_invalid_message,
+       mdn_invalid_action,
+       mdn_invalid_codepoint,
        mdn_buffer_overflow,
        mdn_noentry,
        mdn_nomemory,
        mdn_nofile,
        mdn_nomapping,
        mdn_context_required,
+       mdn_prohibited,
        mdn_failure     /* !!This must be the last one!! */
 } mdn_result_t;
 
diff --git a/contrib/idn/mdnkit/include/mdn/ucsmap.h b/contrib/idn/mdnkit/include/mdn/ucsmap.h
new file mode 100644 (file)
index 0000000..6927a8d
--- /dev/null
@@ -0,0 +1,138 @@
+/* $Id: ucsmap.h,v 1.1 2001/06/09 00:30:06 tale 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+ * Tokyo, 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) Japan Network Information Center.  All rights reserved."
+ * 
+ * 4. Neither the name of JPNIC may 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.
+ * 
+ * 6. Indemnification by Licensee
+ *    Any person or entities using and/or redistributing this Software under
+ *    this License Terms and Conditions shall defend indemnify and hold
+ *    harmless JPNIC from and against any and all judgements damages,
+ *    expenses, settlement liabilities, cost and other liabilities of any
+ *    kind as a result of use and redistribution of this Software or any
+ *    claim, suite, action, litigation or proceeding by any third party
+ *    arising out of or relates to this License Terms and Conditions.
+ * 
+ * 7. Governing Law, Jurisdiction and Venue
+ *    This License Terms and Conditions shall be governed by and and
+ *    construed in accordance with the law of Japan. Any person or entities
+ *    using and/or redistributing this Software under this License Terms and
+ *    Conditions hereby agrees and consent to the personal and exclusive
+ *    jurisdiction and venue of Tokyo District Court of Japan.
+ */
+
+#ifndef MDN_UCSMAP_H
+#define MDN_UCSMAP_H 1
+
+/*
+ * Perform UCS character mapping.
+ * This module support one-to-N mapping (N may be zero, one or more).
+ */
+
+#include <mdn/result.h>
+
+/*
+ * Mapper type (opaque).
+ */
+typedef struct mdn_ucsmap *mdn_ucsmap_t;
+
+/*
+ * Create an empty mapping.  The reference count is set to 1.
+ *
+ * Returns:
+ *     mdn_success             -- ok.
+ *     mdn_nomemory            -- malloc failed.
+ */
+extern mdn_result_t
+mdn_ucsmap_create(mdn_ucsmap_t *ctxp);
+
+/*
+ * Decrement the reference count of the given set, and if it reaches zero,
+ * release all the memory allocated for it.
+ */
+extern void
+mdn_ucsmap_destroy(mdn_ucsmap_t ctx);
+
+/*
+ * Increment the reference count of the given set by one, so that
+ * the map can be shared.
+ */
+extern void
+mdn_ucsmap_incrref(mdn_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:
+ *     mdn_success             -- ok.
+ *     mdn_nomemory            -- malloc failed.
+ *     mdn_failure             -- already fixed by 'mdn_ucsmap_fix',
+ *                                or too large maplen.
+ */
+extern mdn_result_t
+mdn_ucsmap_add(mdn_ucsmap_t ctx, unsigned long ucs, unsigned long *map,
+              size_t maplen);
+
+/*
+ * Perform internal arrangement of the map for lookup.
+ * Once it is fixed, 'mdn_ucsmap_add' cannot be permitted to the map.
+ */
+extern void
+mdn_ucsmap_fix(mdn_ucsmap_t ctx);
+
+/*
+ * Find the mapping for the given character.
+ * 'mdn_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:
+ *     mdn_success             -- ok.
+ *     mdn_nomapping           -- specified character has no mapping.
+ *     mdn_failure             -- not fixed by 'mdn_ucsmap_fix' yet.
+ */
+mdn_result_t
+mdn_ucsmap_map(mdn_ucsmap_t ctx, unsigned long v, unsigned long *to,
+              size_t tolen, size_t *maplenp);
+
+#endif /* MDN_UCSMAP_H */
diff --git a/contrib/idn/mdnkit/include/mdn/ucsset.h b/contrib/idn/mdnkit/include/mdn/ucsset.h
new file mode 100644 (file)
index 0000000..548b66c
--- /dev/null
@@ -0,0 +1,152 @@
+/* $Id: ucsset.h,v 1.1 2001/06/09 00:30:06 tale 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+ * Tokyo, 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) Japan Network Information Center.  All rights reserved."
+ * 
+ * 4. Neither the name of JPNIC may 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.
+ * 
+ * 6. Indemnification by Licensee
+ *    Any person or entities using and/or redistributing this Software under
+ *    this License Terms and Conditions shall defend indemnify and hold
+ *    harmless JPNIC from and against any and all judgements damages,
+ *    expenses, settlement liabilities, cost and other liabilities of any
+ *    kind as a result of use and redistribution of this Software or any
+ *    claim, suite, action, litigation or proceeding by any third party
+ *    arising out of or relates to this License Terms and Conditions.
+ * 
+ * 7. Governing Law, Jurisdiction and Venue
+ *    This License Terms and Conditions shall be governed by and and
+ *    construed in accordance with the law of Japan. Any person or entities
+ *    using and/or redistributing this Software under this License Terms and
+ *    Conditions hereby agrees and consent to the personal and exclusive
+ *    jurisdiction and venue of Tokyo District Court of Japan.
+ */
+
+#ifndef MDN_UCSSET_H
+#define MDN_UCSSET_H 1
+
+/*
+ * A 'set' of UCS codepoints.
+ */
+
+#include <mdn/result.h>
+
+/*
+ * Type representing a set (opaque).
+ */
+typedef struct mdn_ucsset *mdn_ucsset_t;
+
+
+/*
+ * Create an empty set.  The reference count is set to 1.
+ *
+ * Returns:
+ *     mdn_success             -- ok.
+ *     mdn_nomemory            -- malloc failed.
+ */
+extern mdn_result_t
+mdn_ucsset_create(mdn_ucsset_t *ctxp);
+
+/*
+ * Decrement the reference count of the given set, and if it reaches zero,
+ * release all the memory allocated for it.
+ */
+extern void
+mdn_ucsset_destroy(mdn_ucsset_t ctx);
+
+/*
+ * Increments the reference count by one.
+ */
+extern void
+mdn_ucsset_incrref(mdn_ucsset_t ctx);
+
+/*
+ * Add a UCS code point to the set.
+ * The set must be in the building phase -- that is, before 'mdn_ucsset_fix'
+ * is called for the set.
+ *
+ * Returns:
+ *     mdn_success             -- ok.
+ *     mdn_invalid_code        -- code point out of range.
+ *     mdn_nomemory            -- malloc failed.
+ *     mdn_failure             -- already fixed by 'mdn_ucsset_fix'.
+ */
+extern mdn_result_t
+mdn_ucsset_add(mdn_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 'mdn_ucsset_add' except that it accepts
+ * range of code points.
+ *
+ * Returns:
+ *     mdn_success             -- ok.
+ *     mdn_invalid_code        -- code point out of range, or the range
+ *                                specification is invalid.
+ *     mdn_nomemory            -- malloc failed.
+ *     mdn_failure             -- already fixed by 'mdn_ucsset_fix'.
+ */
+extern mdn_result_t
+mdn_ucsset_addrange(mdn_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 'mdn_ucsset_add' or 'mdn_ucsset_addrange'.
+ * But once it is fixed by this function, the set becomes immutable, and
+ * it shifts into 'lookup' phase.
+ */
+extern void
+mdn_ucsset_fix(mdn_ucsset_t ctx);
+
+/*
+ * Find if the given code point is in the set.
+ * The set must be in the lookup phase -- in other words, 'mdn_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:
+ *     mdn_success             -- ok.
+ *     mdn_invalid_code        -- specified code point is out of range.
+ *     mdn_failure             -- not fixed by 'mdn_ucsset_fix' yet.
+ */
+mdn_result_t
+mdn_ucsset_lookup(mdn_ucsset_t ctx, unsigned long v, int *found);
+
+#endif /* MDN_UCSSET_H */
index ff3a76cb03934e2d1c7e41e79a038cde27f74e1b..7d7cc88dae8b4ec4cbe1c5658f4dd740a67b2857 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: unicode.h,v 1.9 2000/09/27 02:55:37 ishisone Exp $ */
+/* $Id: unicode.h,v 1.10 2001/02/13 08:26:22 ishisone Exp $ */
 /*
  * Copyright (c) 2000 Japan Network Information Center.  All rights reserved.
  *  
@@ -190,4 +190,22 @@ mdn__unicode_tolower(unsigned long c, mdn__unicode_context_t ctx,
 extern mdn__unicode_context_t
 mdn__unicode_getcontext(unsigned long c);
 
-#endif
+/*
+ * Perform case-folding for caseless matching, defined by Unicode
+ * Technical Report #21 "Case Mappings".
+ *
+ * Performs case-folding on the given unicode character 'c' and put
+ * the result into 'v', whose size is specified by 'vlen'.  The actual
+ * number of characters stored in 'v' are returned as '*foldlenp'.  In
+ * case 'c' has no mapping, 'v[0]' will contain 'c', and '*foldlenp'
+ * will be 1.
+ *
+ * Returns:
+ *     mdn_success             -- successfully converted.
+ *     mdn_buffer_overflow     -- 'vlen' is too small.
+ */
+extern mdn_result_t
+mdn__unicode_casefold(unsigned long c, unsigned long *v, size_t vlen,
+                     int *foldlenp);
+
+#endif /* MDN_UNICODE_H */
similarity index 66%
rename from contrib/idn/mdnkit/include/mdn/zldrule.h
rename to contrib/idn/mdnkit/include/mdn/utf6.h
index 3a5de7563c63279efc42aa408147a4971f842d9c..5fe17ffbcc2fda530885050b19b73b6fc1fd732d 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: zldrule.h,v 1.8 2000/08/02 02:06:41 ishisone Exp $ */
+/* $Id: utf6.h,v 1.1 2001/06/09 00:30:08 tale Exp $ */
 /*
  * Copyright (c) 2000 Japan Network Information Center.  All rights reserved.
  *  
  *    jurisdiction and venue of Tokyo District Court of Japan.
  */
 
-#ifndef MDN_ZLDRULE_H
-#define MDN_ZLDRULE_H 1
+#ifndef MDN_UTF6_H
+#define MDN_UTF6_H 1
 
 /*
- * ZLD matcher.
+ * UTF6 Converter.
  *
- * This module provides a function that takes a domain name as input,
- * and matches against set of ZLDs.
- *
- * Each ZLD has its corresponding codeset (character encoding), or codesets
- * in which a domain name with the ZLD is encoded.
- *
- * The function returns the matched ZLD and the corresponding codeset.
- *
- * If a name matches more than one ZLDs, the longer one takes precedence.
- *
- * If matched ZLD has more than one codesets, each codeset is applied to
- * the given domain name in order, and the first one for which the name
- * is valid is chosen.
+ * See Internet Draft draft-ietf-idn-utf6-00.txt for details.
  */
 
 #include <mdn/result.h>
 #include <mdn/converter.h>
 
-/*
- * ZLD matching rule set type (opaque)
- */
-typedef struct mdn_zldrule *mdn_zldrule_t;
-
-/*
- * Create an empty rule set.
- *
- * Returns:
- *     mdn_success             -- ok.
- *     mdn_nomemory            -- malloc failed.
- */
 extern mdn_result_t
-mdn_zldrule_create(mdn_zldrule_t *ctxp);
+mdn__utf6_open(mdn_converter_t ctx, mdn_converter_dir_t dir, void **privdata);
 
-/*
- * Destroy the rule set created by mdn_zldrule_create.
- */
-extern void
-mdn_zldrule_destroy(mdn_zldrule_t ctx);
-
-/*
- * Add a ZLD and corresponding encoding(s) to the rule set.
- *
- * Returns:
- *     mdn_success             -- ok.
- *     mdn_nomemory            -- malloc failed.
- */
 extern mdn_result_t
-mdn_zldrule_add(mdn_zldrule_t ctx, const char *zld,
-               const char **encodings, int nencodings);
+mdn__utf6_close(mdn_converter_t ctx, void *privdata, mdn_converter_dir_t dir);
 
-/*
- * Select matching ZLD and encoding for the specified domain name.
- *
- * Returns:
- *     mdn_success             -- found.
- *     mdn_notfound            -- not found.
- *     mdn_invalid_encoding    -- ZLD matched, but encoding is wrong.
- */
 extern mdn_result_t
-mdn_zldrule_select(mdn_zldrule_t ctx, const char *domain,
-                  char **zldp, mdn_converter_t *convctxp);
+mdn__utf6_convert(mdn_converter_t ctx, void *privdata, mdn_converter_dir_t dir,
+                 const char *from, char *to, size_t tolen);
 
-#endif /* MDN_ZLDRULE_H */
+#endif /* MDN_UTF6_H */
index 41b082636067335362a6f1e7f36d3181c1486432..b9a4f1b245bc9b16ab3e55431a500e4350c4e763 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: util.h,v 1.2 2000/11/14 00:15:35 ishisone Exp $ */
+/* $Id: util.h,v 1.5 2001/04/20 00:45:06 ishisone Exp $ */
 /*
  * Copyright (c) 2000 Japan Network Information Center.  All rights reserved.
  *  
@@ -87,6 +87,16 @@ mdn_util_casematch(const char *s1, const char *s2, size_t n);
 extern const char *
 mdn_util_domainspan(const char *s, const char *end);
 
+/*
+ * Test whether a string is valid domain name defined by STD 13.
+ *
+ * This function sees each character in string 's' until 'end', and
+ * checks if the string is valid as an ASCII domain name that STD 13
+ * defines.  If valid, it returns 1.  Otherwise, it returns 0.
+ */
+extern int
+mdn_util_validstd13(const char *s, const char *end);
+
 /*
  * UTF-8 to UTF-16 conversion and vice versa.
  */
diff --git a/contrib/idn/mdnkit/include/mdn/version.h b/contrib/idn/mdnkit/include/mdn/version.h
new file mode 100644 (file)
index 0000000..1ae7845
--- /dev/null
@@ -0,0 +1,76 @@
+/* $Id: version.h,v 1.1 2001/06/09 00:30:09 tale 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+ * Tokyo, 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) Japan Network Information Center.  All rights reserved."
+ * 
+ * 4. Neither the name of JPNIC may 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.
+ * 
+ * 6. Indemnification by Licensee
+ *    Any person or entities using and/or redistributing this Software under
+ *    this License Terms and Conditions shall defend indemnify and hold
+ *    harmless JPNIC from and against any and all judgements damages,
+ *    expenses, settlement liabilities, cost and other liabilities of any
+ *    kind as a result of use and redistribution of this Software or any
+ *    claim, suite, action, litigation or proceeding by any third party
+ *    arising out of or relates to this License Terms and Conditions.
+ * 
+ * 7. Governing Law, Jurisdiction and Venue
+ *    This License Terms and Conditions shall be governed by and and
+ *    construed in accordance with the law of Japan. Any person or entities
+ *    using and/or redistributing this Software under this License Terms and
+ *    Conditions hereby agrees and consent to the personal and exclusive
+ *    jurisdiction and venue of Tokyo District Court of Japan.
+ */
+
+#ifndef MDN_VERSION_H
+#define MDN_VERSION_H 1
+
+/*
+ * Version number of this package.
+ */
+#define MDNKIT_VERSION         "2.1"
+#define MDNKIT_MAJOR_VERSION   2
+#define MDNKIT_MINOR_VERSION   1
+
+/*
+ * Get the version of the library (libmdn).
+ */
+extern const char *
+mdn_version_getstring(void);
+
+#endif /* MDN_VERSION_H */
index f90777d54223dd5b04b806b0411e3e2f6d6e0aa1..c23df94861adf5641f9e7a547bd6c30f94c194dc 100644 (file)
@@ -1,4 +1,4 @@
-# $Id: Makefile.in,v 1.24 2000/12/21 01:57:30 ishisone Exp $
+# $Id: Makefile.in,v 1.48 2001/05/22 03:00:23 m-kasahr 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.
@@ -55,8 +55,9 @@
 #    Conditions hereby agrees and consent to the personal and exclusive
 #    jurisdiction and venue of Tokyo District Court of Japan.
 
-LIB_CURRENT = 4
-LIB_REVISION = 1
+LIB_CURRENT = 7
+LIB_REVISION = 0
+LIB_AGE = 0
 
 .SUFFIXES: .lo
 
@@ -68,21 +69,25 @@ VPATH = @srcdir@
 prefix = @prefix@
 exec_prefix = @exec_prefix@
 
-BINDIR = @bindir@
-LIBDIR = @libdir@
-ETCDIR = @sysconfdir@
+libdir = @libdir@
+sysconfdir = @sysconfdir@
+datadir = @datadir@
+mapdir = $(datadir)/mdnkit
+preference = @CONF_PREFERENCE@
+install_conf = @INSTALL_DEFAULT_CONF@
 
 CC = @CC@
 RANLIB = @RANLIB@
 INSTALL = @INSTALL@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_DATA = @INSTALL_DATA@
+MKINSTALLDIRS = @top_srcdir@/mkinstalldirs
 SHELL = @SHELL@
 LIBTOOL = @LIBTOOL@
 
 OPTS =
 INCS = -I$(srcdir)/../include -I../include
-DEFS = -DMDN_RESCONF_DIR="\"$(ETCDIR)\""
+DEFS = -DMDN_RESCONF_DIR="\"$(sysconfdir)\""
 
 CFLAGS = $(OPTS) $(INCS) $(DEFS) @CFLAGS@
 LDFLAGS = @LDFLAGS@
@@ -90,15 +95,31 @@ LDFLAGS = @LDFLAGS@
 ICONVLIB = @ICONVLIB@
 
 SRCS =  \
+       ace.c \
+       altdude.c \
+       amcacem.c \
+       amcaceo.c \
+       amcacer.c \
+       api.c \
        brace.c \
+       checker.c \
        converter.c \
        debug.c \
+       delimitermap.c \
        dn.c \
+       dude.c \
+       filechecker.c \
+       filemapper.c \
        lace.c \
        localencoding.c \
        log.c \
+       mapper.c \
+       mapselector.c \
        msgheader.c \
        msgtrans.c \
+       nameprep.c \
+       nameprep_template.c \
+       nameprepdata.c \
        normalizer.c \
        race.c \
        res.c \
@@ -106,25 +127,41 @@ SRCS =  \
        result.c \
        selectiveencode.c \
        strhash.c \
-       translator.c \
+       ucsmap.c \
+       ucsset.c \
        unicode.c \
        unicodedata.c \
        unormalize.c \
        utf5.c \
+       utf6.c \
        utf8.c \
        util.c \
-       zldrule.c
+       version.c
 
 OBJS =  \
+       ace.lo \
+       altdude.lo \
+       amcacem.lo \
+       amcaceo.lo \
+       amcacer.lo \
+       api.lo \
        brace.lo \
+       checker.lo \
        converter.lo \
        debug.lo \
+       delimitermap.lo \
        dn.lo \
+       dude.lo \
+       filechecker.lo \
+       filemapper.lo \
        lace.lo \
        localencoding.lo \
        log.lo \
+       mapper.lo \
+       mapselector.lo \
        msgheader.lo \
        msgtrans.lo \
+       nameprep.lo \
        normalizer.lo \
        race.lo \
        res.lo \
@@ -132,32 +169,45 @@ OBJS =  \
        result.lo \
        selectiveencode.lo \
        strhash.lo \
-       translator.lo \
+       ucsmap.lo \
+       ucsset.lo \
        unicode.lo \
        unormalize.lo \
        utf5.lo \
+       utf6.lo \
        utf8.lo \
        util.lo \
-       zldrule.lo
+       version.lo
 
 LIB = libmdn
 
 .c.lo:
        $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c $<
 
-all: $(LIB).la
+all: $(LIB).la mdn.conf.sample
 
 $(LIB).la: $(OBJS)
        $(LIBTOOL) --mode=link $(LD) $(LDFLAGS) -o $@ \
-               -version-info $(LIB_CURRENT):$(LIB_REVISION) \
-               -rpath $(LIBDIR) $(OBJS)
-
-install: $(LIB).la
-       [ -d $(LIBDIR) ] || mkdir $(LIBDIR)
-       $(LIBTOOL) $(INSTALL_DATA) $(LIB).la $(LIBDIR)
-       [ -f $(LIBDIR)/$(LIB).a ] && $(RANLIB) $(LIBDIR)/$(LIB).a
-       [ -d $(ETCDIR) ] || mkdir $(ETCDIR)
-       $(INSTALL_DATA) $(srcdir)/mdnres.conf.sample $(ETCDIR)
+               -version-info $(LIB_CURRENT):$(LIB_REVISION):$(LIB_AGE) \
+               -rpath $(libdir) $(OBJS)
+
+mdn.conf.sample: mdn.conf.sample.in
+       sed -e 's%[@]mapdir[@]%$(mapdir)%' \
+           -e 's%[@]preference[@]%$(preference)%' \
+            -e 's%^#\[$(preference)\] *%%' < $(srcdir)/mdn.conf.sample.in > $@
+
+install: $(LIB).la mdn.conf.sample
+       $(MKINSTALLDIRS) $(libdir)
+       $(LIBTOOL) $(INSTALL_DATA) $(LIB).la $(libdir)
+       -[ -f $(libdir)/$(LIB).a ] && $(RANLIB) $(libdir)/$(LIB).a
+       $(MKINSTALLDIRS) $(sysconfdir)
+       $(INSTALL_DATA) mdn.conf.sample $(sysconfdir)
+       @if [ $(install_conf) = yes -a ! -f $(sysconfdir)/mdn.conf ]; then \
+           echo "** installing default mdn.conf"; \
+           $(INSTALL_DATA) mdn.conf.sample $(sysconfdir)/mdn.conf; \
+       fi
 
 clean:
        rm -f *.o *.lo *.la *.a core *.core *~
+       rm -f mdn.conf.sample
+       rm -fr .libs/
diff --git a/contrib/idn/mdnkit/lib/README b/contrib/idn/mdnkit/lib/README
deleted file mode 100644 (file)
index 63d0d7d..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-This directory contains source files for MDN library.
-
-Here's the brief description of each module.
-
-
-* Higher level modules
-
-msgtrans.c
-       DNS message translator.
-       This is the heart of 'dnsproxy' daemon.
-
-translator.c
-       Domain name translator.
-       Perform domain name translation, including
-         + add/remove ZLD
-         + conversion between local codeset and target codeset
-         + normalization
-
-res.c
-resconf.c
-       Domain name translation interface suitable for embedding in
-       client-side resolver library, including configuration file
-       (mdnres.conf) reader.
-
-* Lower level modules
-
-converter.c
-       Codeset converter.
-       All the conversion is done between some local encoding and UTF-8.
-       It is specially designed for domain-name conversion.
-       For example some converter (such as UTF-5 <-> UTF-8)
-       treats period specially.
-
-normalizer.c
-       String normalizer, including Unicode normalization forms.
-
-unormalize.c
-       Perform normalization defined in "Unicode Normalization Forms".
-
-zldrule.c
-       Find out ZLD and codeset of a domain name.
-
-
-* Utility modules
-
-localencoding.c
-       Local encoding (codeset) detecter based on the locale information.
-
-debug.c
-       Debug utilities.
-
-log.c
-       Logging facility.
-
-msgheader.c
-       DNS message header parser/builder.
-
-dn.c
-       Domain name compression/expansion, similar to dn_comp/dn_expand
-       in the resolver library.
-
-race.c
-       Codeset conversion routine for RACE encoding.
-
-result.c
-       MDN result code to string conversion.
-
-strhash.c
-       String-keyed hash table.
-
-utf5.c
-       UTF-5 encoding utility.
-
-utf8.c
-       UTF-8 encoding utility.
-
-unicode.c
-       Provide access to various information contained in "UnicodeData.txt".
-
-selectiveencode.c
-       Find a substring which seems to be a part of domain name containing
-       non-ascii characters.
diff --git a/contrib/idn/mdnkit/lib/ace.c b/contrib/idn/mdnkit/lib/ace.c
new file mode 100644 (file)
index 0000000..cc79390
--- /dev/null
@@ -0,0 +1,291 @@
+#ifndef lint
+static char *rcsid = "$Id: ace.c,v 1.1 2001/06/09 00:30:12 tale Exp $";
+#endif
+
+/*
+ * 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+ * Tokyo, 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) Japan Network Information Center.  All rights reserved."
+ * 
+ * 4. Neither the name of JPNIC may 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.
+ * 
+ * 6. Indemnification by Licensee
+ *    Any person or entities using and/or redistributing this Software under
+ *    this License Terms and Conditions shall defend indemnify and hold
+ *    harmless JPNIC from and against any and all judgements damages,
+ *    expenses, settlement liabilities, cost and other liabilities of any
+ *    kind as a result of use and redistribution of this Software or any
+ *    claim, suite, action, litigation or proceeding by any third party
+ *    arising out of or relates to this License Terms and Conditions.
+ * 
+ * 7. Governing Law, Jurisdiction and Venue
+ *    This License Terms and Conditions shall be governed by and and
+ *    construed in accordance with the law of Japan. Any person or entities
+ *    using and/or redistributing this Software under this License Terms and
+ *    Conditions hereby agrees and consent to the personal and exclusive
+ *    jurisdiction and venue of Tokyo District Court of Japan.
+ */
+
+#include <config.h>
+
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <mdn/result.h>
+#include <mdn/assert.h>
+#include <mdn/converter.h>
+#include <mdn/util.h>
+#include <mdn/ace.h>
+
+static mdn_result_t    l2u(mdn__ace_t *ctx, const char *from, const char *end,
+                           char *to, size_t tolen, size_t *clenp);
+static mdn_result_t    u2l(mdn__ace_t *ctx, const char *from, const char *end,
+                           char *to, size_t tolen, size_t *clenp);
+
+mdn_result_t
+mdn__ace_convert(mdn__ace_t *ctx, mdn_converter_dir_t dir,
+                const char *from, char *to, size_t tolen)
+{
+       assert(ctx != NULL && ctx->encoder != NULL && ctx->decoder != NULL &&
+              from != NULL && to != NULL &&
+              (dir == mdn_converter_l2u || dir == mdn_converter_u2l));
+
+       for (;;) {
+               const char *end;
+               size_t convlen = 0;
+               mdn_result_t r;
+
+               /*
+                * Find the end of this component (label).
+                */
+               if ((end = strchr(from, '.')) == NULL)
+                       end = from + strlen(from);
+
+               /*
+                * Convert it.
+                */
+               if (end > from) {
+                       if (dir == mdn_converter_l2u)
+                               r = l2u(ctx, from, end, to, tolen, &convlen);
+                       else
+                               r = u2l(ctx, from, end, to, tolen, &convlen);
+                       if (r != mdn_success)
+                               return (r);
+               }
+
+               /*
+                * Copy '.' or NUL.
+                */
+               if (tolen <= convlen)
+                       return (mdn_buffer_overflow);
+
+               to += convlen;
+               *to++ = *end;
+               tolen -= convlen + 1;
+
+               /*
+                * Finished?
+                */
+               if (*end == '\0') {
+                       break;
+               } else if (*(end + 1) == '\0') {
+                       /* End with '.' */
+                       if (tolen < 1)
+                               return (mdn_buffer_overflow);
+                       *to++ = '\0';
+                       tolen--;
+                       break;
+               }
+
+               from = end + 1;
+       }
+
+       return (mdn_success);
+}
+
+static mdn_result_t
+l2u(mdn__ace_t *ctx, const char *from, const char *end,
+    char *to, size_t tolen, size_t *clenp)
+{
+       size_t acelen = end - from;
+       size_t idlen = strlen(ctx->id_str);
+       size_t utflen;
+       const char *top;
+       mdn_result_t r;
+       char *buf;
+       char local_buf[256];
+
+       if (ctx->id_type == mdn__ace_prefix &&
+           acelen >= idlen &&
+           mdn_util_casematch(from, ctx->id_str, idlen)) {
+               /*
+                * Prefix found.
+                */
+               top = from + idlen;
+               acelen -= idlen;
+       } else if (ctx->id_type == mdn__ace_suffix &&
+                  acelen >= idlen &&
+                  mdn_util_casematch(end - idlen, ctx->id_str, idlen)) {
+               /*
+                * Suffix found.
+                */
+               top = from;
+               acelen -= idlen;
+       } else {
+               /*
+                * Not ACE encoded.
+                */
+       copy:
+               /*
+                * Check if it comforms to STD-13.
+                */
+               if (!mdn_util_validstd13(from, end)) {
+                       /* invalid character found */
+                       return (mdn_invalid_encoding);
+               }
+
+               /*
+                * Copy verbatim.
+                */
+               acelen = end - from;
+               if (tolen < acelen)
+                       return (mdn_buffer_overflow);
+               (void)memcpy(to, from, acelen);
+
+               *clenp = acelen;
+               return (mdn_success);
+       }
+
+       /*
+        * Now, top and acelen refers the ACE encoded name
+        * without prefix/suffix.
+        */
+
+       /* Decode it. */
+       r = (*ctx->decoder)(top, acelen, to, tolen);
+       if (r == mdn_invalid_encoding)
+               goto copy;
+       else if (r != mdn_success)
+               return (r);
+
+       *clenp = utflen = strlen(to);
+
+       /*
+        * Check if the decode result is a STD13 conforming name.
+        */
+       if (mdn_util_validstd13(to, to + utflen))
+               return (mdn_invalid_encoding);
+
+       /*
+        * Do round-trip conversion check.  Encode the decoded result,
+        * and compare it with the original.  If they don't match,
+        * the original name must be illegally encoded.
+        *
+        * We need a buffer at least acelen+1 (for the NUL byte) bytes long.
+        */
+       if (acelen >= sizeof(local_buf)) {
+               if ((buf = malloc(acelen + 1)) == NULL)
+                       return (mdn_nomemory);
+       } else {
+               buf = local_buf;
+       }
+       if ((*ctx->encoder)(to, utflen, buf, acelen + 1) != mdn_success ||
+           strlen(buf) != acelen ||
+           !mdn_util_casematch(buf, top, acelen)) {
+               r = mdn_invalid_encoding;
+       }
+       if (buf != local_buf)
+               free(buf);
+
+       return (r);
+}
+
+static mdn_result_t
+u2l(mdn__ace_t *ctx, const char *from, const char *end,
+    char *to, size_t tolen, size_t *clenp)
+{
+       size_t len = end - from;
+
+       /*
+        * See if encoding is really necessary.
+        */
+       if (!mdn_util_validstd13(from, end)) {
+               /*
+                * Conversion is necessary.
+                */
+               mdn_result_t r;
+               size_t idlen = strlen(ctx->id_str);
+               size_t acelen;
+
+               if (ctx->id_type == mdn__ace_prefix) {
+                       /* Prepend prefix. */
+                       if (tolen < idlen)
+                               return (mdn_buffer_overflow);
+                       (void)memcpy(to, ctx->id_str, idlen);
+                       to += idlen;
+                       tolen -= idlen;
+               }
+
+               r = (*ctx->encoder)(from, len, to, tolen);
+               if (r != mdn_success)
+                       return (r);
+               acelen = strlen(to);
+
+               if (ctx->id_type == mdn__ace_suffix) {
+                       /* Append suffix. */
+                       if (acelen + idlen > tolen)
+                               return (mdn_buffer_overflow);
+                       (void)memcpy(to + acelen, ctx->id_str, idlen);
+               }
+
+               len = idlen + acelen;
+       } else {
+               /*
+                * Conversion is NOT necessary.
+                * Copy verbatim.
+                */
+
+               if (tolen < len)
+                       return (mdn_buffer_overflow);
+
+               (void)memcpy(to, from, len);
+       }
+       *clenp = len;
+       return (mdn_success);
+}
diff --git a/contrib/idn/mdnkit/lib/altdude.c b/contrib/idn/mdnkit/lib/altdude.c
new file mode 100644 (file)
index 0000000..dabe0c1
--- /dev/null
@@ -0,0 +1,306 @@
+#ifndef lint
+static char *rcsid = "$Id: altdude.c,v 1.1 2001/06/09 00:30:12 tale Exp $";
+#endif
+
+/*
+ * 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+ * Tokyo, 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) Japan Network Information Center.  All rights reserved."
+ * 
+ * 4. Neither the name of JPNIC may 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.
+ * 
+ * 6. Indemnification by Licensee
+ *    Any person or entities using and/or redistributing this Software under
+ *    this License Terms and Conditions shall defend indemnify and hold
+ *    harmless JPNIC from and against any and all judgements damages,
+ *    expenses, settlement liabilities, cost and other liabilities of any
+ *    kind as a result of use and redistribution of this Software or any
+ *    claim, suite, action, litigation or proceeding by any third party
+ *    arising out of or relates to this License Terms and Conditions.
+ * 
+ * 7. Governing Law, Jurisdiction and Venue
+ *    This License Terms and Conditions shall be governed by and and
+ *    construed in accordance with the law of Japan. Any person or entities
+ *    using and/or redistributing this Software under this License Terms and
+ *    Conditions hereby agrees and consent to the personal and exclusive
+ *    jurisdiction and venue of Tokyo District Court of Japan.
+ */
+
+#include <config.h>
+
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <mdn/result.h>
+#include <mdn/assert.h>
+#include <mdn/logmacro.h>
+#include <mdn/converter.h>
+#include <mdn/utf8.h>
+#include <mdn/debug.h>
+#include <mdn/altdude.h>
+#include <mdn/ace.h>
+#include <mdn/util.h>
+
+/*
+ * Although draft-ietf-idn-altdude-00.txt doesn't specify the ACE
+ * signature for ALTDUDE, we have to choose one.
+ */
+#if !defined(MDN_ALTDUDE_PREFIX) && !defined(MDN_ALTDUDE_SUFFIX)
+#define MDN_ALTDUDE_PREFIX             "a---"
+#endif
+
+static const char *base32encode = "abcdefghijkmnpqrstuvwxyz23456789";
+static const int base32decode_ascii[26] = {
+       0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, 11, 12, -1, 13, 14, 15,
+       16, 17, 18, 19, 20, 21, 22, 23,
+};
+static const int base32decode_digit[10] = {
+       -1, -1, 24, 25, 26, 27, 28, 29, 30, 31,
+};
+
+static mdn_result_t    altdude_decode(const char *from, size_t fromlen,
+                                   char *to, size_t tolen);
+static mdn_result_t    altdude_encode(const char *from, size_t fromlen,
+                                   char *to, size_t tolen);
+static int             get_nibblelength(unsigned long v);
+static int             altdude_getwc(const char *s, size_t len,
+                                  unsigned long *vp);
+static int             altdude_putwc(char *s, size_t len, unsigned long v);
+
+static mdn__ace_t altdude_ctx = {
+#ifdef MDN_ALTDUDE_PREFIX
+       mdn__ace_prefix,
+       MDN_ALTDUDE_PREFIX,
+#else
+       mdn__ace_suffix,
+       MDN_ALTDUDE_SUFFIX,
+#endif
+       altdude_encode,
+       altdude_decode,
+};
+
+/* ARGSUSED */
+mdn_result_t
+mdn__altdude_open(mdn_converter_t ctx, mdn_converter_dir_t dir,
+                 void **privdata)
+{
+       return (mdn_success);
+}
+
+/* ARGSUSED */
+mdn_result_t
+mdn__altdude_close(mdn_converter_t ctx, void *privdata,
+                  mdn_converter_dir_t dir)
+{
+       return (mdn_success);
+}
+
+mdn_result_t
+mdn__altdude_convert(mdn_converter_t ctx, void *privdata,
+                    mdn_converter_dir_t dir,
+                    const char *from, char *to, size_t tolen)
+{
+       mdn_result_t r;
+
+       assert(ctx != NULL &&
+              (dir == mdn_converter_l2u || dir == mdn_converter_u2l));
+
+       TRACE(("mdn__altdude_convert(dir=%s,from=\"%s\")\n",
+              dir == mdn_converter_l2u ? "l2u" : "u2l",
+              mdn_debug_xstring(from, 20)));
+
+       r = mdn__ace_convert(&altdude_ctx, dir, from, to, tolen);
+       if (r != mdn_success)
+               return (r);
+
+       DUMP(("mdn__altdude_convert: \"%s\"\n", mdn_debug_xstring(to, 70)));
+
+       return (r);
+}
+
+static mdn_result_t
+altdude_decode(const char *from, size_t fromlen, char *to, size_t tolen) {
+       size_t len;
+       unsigned long prev, v;
+
+       prev = 96;
+       while (fromlen > 0) {
+               if (from[0] == '-') {
+                       v = '-';
+                       from++;
+                       fromlen--;
+               } else {
+                       len = altdude_getwc(from, fromlen, &v);
+                       if (len == 0)
+                               return (mdn_invalid_encoding);
+                       from += len;
+                       fromlen -= len;
+                       v = prev ^ v;
+
+                       /*
+                        * Since round-trip check is performed later
+                        * by mdn__ace_convert(), we don't need the
+                        * following sanity checking.
+                        *
+                        * if (v == '-' || get_nibblelength(v) != len)
+                        *      return (mdn_invalid_encoding);
+                        */
+
+                       prev = v;
+               }
+               len = mdn_utf8_putwc(to, tolen, v);
+               if (len == 0)
+                       return (mdn_buffer_overflow);
+               to += len;
+               tolen -= len;
+       }
+
+       /*
+        * Terminate with NUL.
+        */
+       if (tolen <= 0)
+               return (mdn_buffer_overflow);
+
+       *to = '\0';
+       return (mdn_success);
+}
+
+static mdn_result_t
+altdude_encode(const char *from, size_t fromlen, char *to, size_t tolen) {
+       size_t len;
+       unsigned long prev, c;
+
+       prev = 96;
+       while (fromlen > 0) {
+               len = mdn_utf8_getwc(from, fromlen, &c);
+               from += len;
+               fromlen -= len;
+               if (len == 0)
+                       return (mdn_invalid_encoding);
+               if (c == '-') {
+                       /*
+                        * Hyphens are treated specially.
+                        */
+                       if (tolen < 1)
+                               return (mdn_buffer_overflow);
+                       *to++ = '-';
+                       tolen--;
+               } else {
+                       len = altdude_putwc(to, tolen, prev ^ c);
+                       if (len == 0)
+                               return (mdn_buffer_overflow);
+                       prev = c;
+                       to += len;
+                       tolen -= len;
+               }
+       }
+
+       /*
+        * Terminate with NUL.
+        */
+       if (tolen <= 0)
+               return (mdn_buffer_overflow);
+
+       *to = '\0';
+
+       return (mdn_success);
+}
+
+static int
+get_nibblelength(unsigned long v) {
+       assert(v <= 0x7fffffff);
+
+       if (v < (1<<16)) {                      /* v <= 16bit */
+               if (v < (1<<8))                 /* v <= 8bit */
+                       return ((v < (1<<4)) ? 1 : 2);
+               else                            /* 8bit < v <= 16bit */
+                       return ((v < (1<<12)) ? 3 : 4);
+       } else {                                /* 16bit < c */
+               if (v < (1<<24))                /* 16bit < c <= 24bit */
+                       return ((v < (1<<20)) ? 5 : 6);
+               else                            /* 24bit < c <= 31bit */
+                       return ((v < (1<<28)) ? 7 : 8);
+       }
+}
+
+static int
+altdude_getwc(const char *s, size_t len, unsigned long *vp) {
+       size_t orglen = len;
+       unsigned long v = 0;
+
+       while (len > 0) {
+               int c = *s++;
+
+               if ('a' <= c && c <= 'z')
+                       c = base32decode_ascii[c - 'a'];
+               else if ('A' <= c && c <= 'Z')
+                       c = base32decode_ascii[c - 'A'];
+               else if ('0' <= c && c <= '9')
+                       c = base32decode_digit[c - '0'];
+               else
+                       c = -1;
+
+               if (c < 0)
+                       return (0);     /* invalid character */
+
+               v = (v << 4) + (c & 0xf);
+
+               len--;
+               if ((c & 0x10) == 0) {
+                       *vp = v;
+                       return (orglen - len);
+               }
+       }
+       return (0);     /* final character missing */
+}
+
+static int
+altdude_putwc(char *s, size_t len, unsigned long v) {
+       int i, w, shift;
+
+       if ((w = get_nibblelength(v)) > len)
+               return (0);
+
+       for (shift = 0, i = w - 1; i >= 0; i--) {
+               s[i] = base32encode[(v & 0xf) + shift];
+               v >>= 4;
+               shift = 16;
+       }
+       return (w);
+}
diff --git a/contrib/idn/mdnkit/lib/amcacem.c b/contrib/idn/mdnkit/lib/amcacem.c
new file mode 100644 (file)
index 0000000..d0f1fc1
--- /dev/null
@@ -0,0 +1,829 @@
+#ifndef lint
+static char *rcsid = "$Id: amcacem.c,v 1.1 2001/06/09 00:30:12 tale 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+ * Tokyo, 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) Japan Network Information Center.  All rights reserved."
+ * 
+ * 4. Neither the name of JPNIC may 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.
+ * 
+ * 6. Indemnification by Licensee
+ *    Any person or entities using and/or redistributing this Software under
+ *    this License Terms and Conditions shall defend indemnify and hold
+ *    harmless JPNIC from and against any and all judgements damages,
+ *    expenses, settlement liabilities, cost and other liabilities of any
+ *    kind as a result of use and redistribution of this Software or any
+ *    claim, suite, action, litigation or proceeding by any third party
+ *    arising out of or relates to this License Terms and Conditions.
+ * 
+ * 7. Governing Law, Jurisdiction and Venue
+ *    This License Terms and Conditions shall be governed by and and
+ *    construed in accordance with the law of Japan. Any person or entities
+ *    using and/or redistributing this Software under this License Terms and
+ *    Conditions hereby agrees and consent to the personal and exclusive
+ *    jurisdiction and venue of Tokyo District Court of Japan.
+ */
+
+#include <config.h>
+
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <mdn/result.h>
+#include <mdn/assert.h>
+#include <mdn/logmacro.h>
+#include <mdn/converter.h>
+#include <mdn/utf8.h>
+#include <mdn/debug.h>
+#include <mdn/amcacem.h>
+#include <mdn/ace.h>
+#include <mdn/util.h>
+
+/*
+ * The current draft, there is discrepancy between the spec and the
+ * sample implementation/examples.  Defining the following symbol
+ * makes this code agree with the sample code.
+ */
+/* #define CONFORM_TO_SAMPLE */
+
+/*
+ * Although draft-ietf-idn-amc-ace-m-00.txt doesn't specify the ACE
+ * signature, we have to choose one.
+ */
+#if !defined(MDN_AMCACEM_PREFIX) && !defined(MDN_AMCACEM_SUFFIX)
+#define MDN_AMCACEM_SUFFIX     "-amc1"
+#endif
+
+#define AMCACEM_MAX_CODEPOINT  0x10ffff
+
+enum { amcacem_narrow_style, amcacem_wide_style };
+
+#define UCSBUF_LOCAL_SIZE      40
+
+typedef struct ucsbuf {
+       unsigned long *ucs;
+       size_t size;
+       size_t len;
+       unsigned long local[UCSBUF_LOCAL_SIZE];
+} ucsbuf_t;
+
+static const char *base32encode = "abcdefghijkmnpqrstuvwxyz23456789";
+static const int base32decode_ascii[26] = {
+       0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, 11, 12, -1, 13, 14, 15,
+       16, 17, 18, 19, 20, 21, 22, 23,
+};
+static const int base32decode_digit[10] = {
+       -1, -1, 24, 25, 26, 27, 28, 29, 30, 31,
+};
+
+#define AMCACEM_SPECIAL_RANGE_FIRST    0x20
+#define AMCACEM_SPECIAL_RANGE_END      0x36f
+unsigned long acem_special_row[8] = {
+       0x020, 0x05b, 0x07b, 0x0a0, 0x0c0, 0x0df, 0x134, 0x270,
+};
+
+static mdn_result_t    amcacem_decode(const char *from, size_t fromlen,
+                                   char *to, size_t tolen);
+static mdn_result_t    amcacem_encode(const char *from, size_t fromlen,
+                                   char *to, size_t tolen);
+static int             most_populous_row(const unsigned long *ucs,
+                                         size_t len);
+static int             most_populous_16win(const unsigned long *ucs,
+                                           size_t len, unsigned long base);
+static int             most_populous_20kwin(const unsigned long *ucs,
+                                            size_t len, unsigned long base);
+static unsigned long   row_offset(int row);
+static int             choose_style(const unsigned long *ucs, size_t len,
+                                    int a, int b, int c);
+static int             estimate(int style, const unsigned long *ucs,
+                                size_t ulen, int a, int b, int c);
+static unsigned long   base32decode(const char *s, int len, int *err);
+static mdn_result_t    utf8_to_ucs4(const char *utf8, size_t fromlen,
+                                    ucsbuf_t *b);
+static void            ucsbuf_init(ucsbuf_t *b);
+static mdn_result_t    ucsbuf_grow(ucsbuf_t *b);
+static mdn_result_t    ucsbuf_append(ucsbuf_t *b, unsigned long v);
+static void            ucsbuf_free(ucsbuf_t *b);
+static int             is_ldh(unsigned long v);
+
+static mdn__ace_t amcacem_ctx = {
+#ifdef MDN_AMCACEM_PREFIX
+       mdn__ace_prefix,
+       MDN_AMCACEM_PREFIX,
+#else
+       mdn__ace_suffix,
+       MDN_AMCACEM_SUFFIX,
+#endif
+       amcacem_encode,
+       amcacem_decode,
+};
+
+/* ARGSUSED */
+mdn_result_t
+mdn__amcacem_open(mdn_converter_t ctx, mdn_converter_dir_t dir,
+                 void **privdata)
+{
+       return (mdn_success);
+}
+
+/* ARGSUSED */
+mdn_result_t
+mdn__amcacem_close(mdn_converter_t ctx, void *privdata,
+                  mdn_converter_dir_t dir)
+{
+       return (mdn_success);
+}
+
+mdn_result_t
+mdn__amcacem_convert(mdn_converter_t ctx, void *privdata,
+                    mdn_converter_dir_t dir,
+                    const char *from, char *to, size_t tolen)
+{
+       mdn_result_t r;
+
+       assert(ctx != NULL &&
+              (dir == mdn_converter_l2u || dir == mdn_converter_u2l));
+
+       TRACE(("mdn__amcaceo_convert(dir=%s,from=\"%s\")\n",
+              dir == mdn_converter_l2u ? "l2u" : "u2l",
+              mdn_debug_xstring(from, 20)));
+
+       r = mdn__ace_convert(&amcacem_ctx, dir, from, to, tolen);
+       if (r != mdn_success)
+               return (r);
+
+       DUMP(("mdn__amcacem_convert: \"%s\"\n", mdn_debug_xstring(to, 70)));
+
+       return (r);
+}
+
+static mdn_result_t
+amcacem_decode(const char *from, size_t fromlen, char *to, size_t tolen) {
+       size_t len;
+       int literal_mode = 0;
+       int a, b, c;
+       unsigned long offseta, offsetb, offsetc;
+       int style;
+       int err = 0;
+
+       /*
+        * Decode header.
+        */
+       if (fromlen < 3)
+               return (mdn_invalid_encoding);
+
+       a = b = c = 0;                  /* for lint */
+       style = amcacem_narrow_style;   /* for lint */
+
+       switch (base32decode(from, 1, &err) & 0x18) {
+       case 0:
+               style = amcacem_narrow_style;
+               b = base32decode(from, 2, &err);
+               a = base32decode(from + 2, 1, &err);
+               from += 3;
+               fromlen -= 3;
+               break;
+       case 0x8:
+               if (fromlen < 4)
+                       return (mdn_invalid_encoding);
+               style = amcacem_narrow_style;
+               b = base32decode(from, 3, &err) & 0x1fff;
+               a = base32decode(from + 3, 1, &err);
+               from += 4;
+               fromlen -= 4;
+               break;
+       case 0x10:
+               style = amcacem_wide_style;
+               b = base32decode(from, 2, &err) & 0xff;
+               c = base32decode(from + 2, 1, &err);
+               from += 3;
+               fromlen -= 3;
+               break;
+       case 0x18:
+               if (fromlen < 5)
+                       return (mdn_invalid_encoding);
+               style = amcacem_wide_style;
+               b = base32decode(from, 3, &err) & 0x1fff;
+               c = base32decode(from + 3, 2, &err);
+               from += 5;
+               fromlen -= 5;
+               break;
+       }
+       if (err)
+               return (mdn_invalid_encoding);
+
+       offsetb = row_offset(b);
+       offseta = ((offsetb >> 3) + a) << 3;
+       if (style == amcacem_narrow_style)
+               offsetc = (offsetb >> 12) << 12;
+       else
+               offsetc = c << 11;
+
+       while (fromlen > 0) {
+               unsigned long v;
+
+               if (from[0] == '-') {
+                       if (fromlen > 1 && from[1] == '-') {
+                               v = '-';
+                               from += 2;
+                               fromlen -= 2;
+                       } else {
+                               literal_mode = !literal_mode;
+                               from++;
+                               fromlen--;
+                               continue;
+                       }
+               } else if (literal_mode) {
+                       v = from[0];
+                       from++;
+                       fromlen--;
+               } else {
+                       v = base32decode(from, 1, &err);
+                       if (err)
+                               return (mdn_invalid_encoding);
+                       if (v < 16) {
+                               if (style == amcacem_narrow_style) {
+                                       v += offseta;
+                                       len = 1;
+                               } else {
+                                       if (fromlen < 3)
+                                               return (mdn_invalid_encoding);
+                                       v = base32decode(from, 3, &err)
+                                               + offsetc + 0x1000;
+                                       if (err)
+                                               return (mdn_invalid_encoding);
+                                       len = 3;
+                               }
+                       } else {
+                               v = 0;
+                               for (len = 0; len < 5; len++) {
+                                       int x;
+                                       if (tolen <= len)
+                                               return (mdn_invalid_encoding);
+                                       x = base32decode(from + len, 1, &err);
+                                       v = (v << 4) + (x & 0xf);
+                                       if (x < 16)
+                                               break;
+                               }
+                               if (err)
+                                       return (mdn_invalid_encoding);
+                                       
+                               switch (++len) {
+                               case 2:
+                                       v += offsetb;
+                                       break;
+                               case 3:
+                                       v += offsetc;
+                                       break;
+                               case 4:
+                                       break;
+                               case 5:
+                                       v += 0x10000;
+                                       break;
+                               default:
+                                       return (mdn_invalid_encoding);
+                               }
+                       }
+                       from += len;
+                       fromlen -= len;
+               }
+               len = mdn_utf8_putwc(to, tolen, v);
+               if (len == 0)
+                       return (mdn_buffer_overflow);
+               to += len;
+               tolen -= len;
+       }
+
+       /*
+        * Terminate with NUL.
+        */
+       if (tolen <= 0)
+               return (mdn_buffer_overflow);
+
+       *to = '\0';
+
+       return (mdn_success);
+}
+
+static mdn_result_t
+amcacem_encode(const char *from, size_t fromlen, char *to, size_t tolen) {
+       ucsbuf_t ucsb;
+       unsigned long *buf;
+       size_t len;
+       int literal_mode = 0;
+       int a, b, c;
+       unsigned long offseta, offsetb, offsetc;
+       mdn_result_t r;
+       int style;
+       int i;
+
+       /*
+        * Convert input string to UCS-4.
+        */
+       ucsbuf_init(&ucsb);
+       if ((r = utf8_to_ucs4(from, fromlen, &ucsb)) != mdn_success)
+               return (r);
+
+       buf = ucsb.ucs;
+       len = ucsb.len;
+
+       /*
+        * Now 'buf' contains UCS-4 string consisting of 'len' characters.
+        */
+
+       /*
+        * Make sure all the codepoints are below 0x110000.
+        */
+       for (i = 0; i < len; i++) {
+               if (buf[i] > AMCACEM_MAX_CODEPOINT)
+                       return (mdn_invalid_encoding);
+       }
+
+       b = most_populous_row(buf, len);
+       offsetb = row_offset(b);
+       a = most_populous_16win(buf, len, offsetb);
+       offseta = ((offsetb >> 3) + a) << 3;
+       c = most_populous_20kwin(buf, len, offsetb);
+
+       style = choose_style(buf, len, a, b, c);
+
+       if (style == amcacem_narrow_style) {
+               if (b <= 0xff) {
+                       if (tolen < 3)
+                               goto overflow;
+                       to[0] = base32encode[b >> 5];
+                       to[1] = base32encode[b & 0x1f];
+                       to[2] = base32encode[a];
+                       to += 3;
+                       tolen -= 3;
+               } else {
+                       if (tolen < 4)
+                               goto overflow;
+                       to[0] = base32encode[8 + (b >> 10)];
+                       to[1] = base32encode[(b >> 5) & 0x1f];
+                       to[2] = base32encode[b & 0x1f];
+                       to[3] = base32encode[a];
+                       to += 4;
+                       tolen -= 4;
+               }
+               offsetc = (offsetb >> 12) << 12;
+       } else {
+               if (b <= 0xff && c <= 0x1f) {
+                       if (tolen < 3)
+                               goto overflow;
+                       to[0] = base32encode[0x10 + (b >> 5)];
+                       to[1] = base32encode[b & 0x1f];
+                       to[2] = base32encode[c];
+                       to += 3;
+                       tolen -= 3;
+               } else {
+                       if (tolen < 5)
+                               goto overflow;
+                       to[0] = base32encode[0x18 + (b >> 10)];
+                       to[1] = base32encode[(b >> 5) & 0x1f];
+                       to[2] = base32encode[b & 0x1f];
+                       to[3] = base32encode[c >> 5];
+                       to[4] = base32encode[c & 0x1f];
+                       to += 5;
+                       tolen -= 5;
+               }
+               offsetc = c << 11;
+       }
+
+       for (i = 0; i < len; i++) {
+               unsigned long c = buf[i];
+
+               if (c == '-') {
+                       /*
+                        * Convert "-" to "--".
+                        */
+                       if (tolen < 2)
+                               return (mdn_buffer_overflow);
+                       to[0] = to[1] = '-';
+                       to += 2;
+                       tolen -= 2;
+               } else if (is_ldh(c)) {
+                       /*
+                        * LDH characters.
+                        */
+                       if (literal_mode == 0) {
+                               /*
+                                * Go into literal mode.
+                                */
+                               if (tolen < 1)
+                                       goto overflow;
+                               *to++ = '-';
+                               tolen--;
+                               literal_mode = 1;
+                       }
+                       if (tolen < 1)
+                               goto overflow;
+                       *to++ = c;
+                       tolen--;
+               } else {
+                       /*
+                        * Non-LDH characters.
+                        */
+                       if (literal_mode != 0) {
+                               /*
+                                * Get out of literal mode.
+                                */
+                               if (tolen < 1)
+                                       goto overflow;
+                               *to++ = '-';
+                               tolen--;
+                               literal_mode = 0;
+
+                       }
+                       if (style == amcacem_narrow_style &&
+                           offseta <= c && c <= offseta + 0xf) {
+                               if (tolen < 1)
+                                       goto overflow;
+                               *to++ = base32encode[c - offseta];
+                               tolen--;
+                       } else if (offsetb <= c && c <= offsetb + 0xff) {
+                               if (tolen < 2)
+                                       goto overflow;
+                               c -= offsetb;
+                               to[0] = base32encode[0x10 + (c >> 4)];
+                               to[1] = base32encode[c & 0xf];
+                               to += 2;
+                               tolen -= 2;
+                       } else if (offsetc <= c && c <= offsetc + 0xfff) {
+                               if (tolen < 3)
+                                       goto overflow;
+                               c -= offsetc;
+                               to[0] = base32encode[0x10 + (c >> 8)];
+                               to[1] = base32encode[0x10 + ((c >> 4) & 0xf)];
+                               to[2] = base32encode[c & 0xf];
+                               to += 3;
+                               tolen -= 3;
+                       } else if (style == amcacem_wide_style &&
+                                  offsetc +0x1000 <= c &&
+                                  c <= offsetc + 0x4fff) {
+                               if (tolen < 3)
+                                       goto overflow;
+                               c -= offsetc + 0x1000;
+                               to[0] = base32encode[c >> 10];
+                               to[1] = base32encode[(c >> 5) & 0x1f];
+                               to[2] = base32encode[c & 0x1f];
+                               to += 3;
+                               tolen -= 3;
+                       } else if (c <= 0xffff) {
+                               if (tolen < 4)
+                                       goto overflow;
+                               to[0] = base32encode[0x10 + (c >> 12)];
+                               to[1] = base32encode[0x10 + ((c >> 8) & 0xf)];
+                               to[2] = base32encode[0x10 + ((c >> 4) & 0xf)];
+                               to[3] = base32encode[c & 0xf];
+                               to += 4;
+                               tolen -= 4;
+                       } else {
+                               if (tolen < 5)
+                                       goto overflow;
+                               c -= 0x10000;
+                               to[0] = base32encode[0x10 + (c >> 16)];
+                               to[1] = base32encode[0x10 + ((c >> 12) & 0xf)];
+                               to[2] = base32encode[0x10 + ((c >> 8) & 0xf)];
+                               to[3] = base32encode[0x10 + ((c >> 4) & 0xf)];
+                               to[4] = base32encode[c & 0xf];
+                               to += 5;
+                               tolen -= 5;
+                       }
+               }
+       }
+
+       /*
+        * Terminate with NUL.
+        */
+       if (tolen <= 0)
+               return (mdn_buffer_overflow);
+
+       *to = '\0';
+
+       ucsbuf_free(&ucsb);
+       return (mdn_success);
+
+ overflow:
+       ucsbuf_free(&ucsb);
+       return (mdn_buffer_overflow);
+}
+
+static int
+most_populous_row(const unsigned long *ucs, size_t len) {
+       int pop[256];
+       int bestpop;
+       int bestrow;
+       int i, j;
+
+       memset(pop, 0, sizeof(pop));
+       for (i = 0; i < len; i++) {
+               unsigned long c = ucs[i];
+
+               if (is_ldh(c))
+                       continue;
+
+               pop[c >> 8]++;
+
+               if (c >= AMCACEM_SPECIAL_RANGE_FIRST &&
+                   c <= AMCACEM_SPECIAL_RANGE_END) {
+                       for (j = 0; j < 8; j++) {
+                               if (c >= acem_special_row[j] &&
+                                   c < acem_special_row[j] + 256) {
+                                       pop[0xd8 + j]++;
+                               }
+                       }
+               }
+       }
+
+       bestpop = -1;
+       bestrow = 0;            /* for lint */
+       for (i = 0; i < 256; i++) {
+               if (pop[i] > bestpop) {
+                       bestpop = pop[i];
+                       bestrow = i;
+               }
+       }
+       return (bestrow);
+}
+
+static int
+most_populous_16win(const unsigned long *ucs, size_t len,
+                   unsigned long base)
+{
+       unsigned long hi, lo;
+       int i;
+       int pop[32];
+       int bestpop;
+       int bestwin;
+
+       memset(pop, 0, sizeof(pop));
+
+       lo = (base >> 3) << 3;
+       hi = (((base >> 3) + 31) << 3) + 16;
+
+       for (i = 0; i < len; i++) {
+               int blk;
+
+               if (ucs[i] < lo || ucs[i] >= hi || is_ldh(ucs[i]))
+                       continue;
+
+               blk = (ucs[i] - lo) / 8;
+               if (blk < 32)
+                       pop[blk]++;
+               if (blk > 0)
+                       pop[blk - 1]++;
+       }
+
+       bestpop = -1;
+       bestwin = 0;            /* for lint */
+       for (i = 0; i < 32; i++) {
+               if (pop[i] > bestpop) {
+                       bestpop = pop[i];
+                       bestwin = i;
+               }
+       }
+       return (bestwin);
+}
+
+static int
+most_populous_20kwin(const unsigned long *ucs, size_t len,
+                    unsigned long base)
+{
+       int i, j;
+       int bestcnt = -1;
+       int bestwin = 0;
+
+       for (i = 0; i < len; i++) {
+               unsigned long c = ucs[i];
+               unsigned long n, lo, hi;
+               int count;
+
+               count = 0;
+               n = c >> 11;
+               lo = n << 11;
+               hi = lo + 0x4fff;
+
+               for (j = 0; j < len; j++) {
+                       unsigned long v = ucs[j];
+#ifndef CONFORM_TO_SAMPLE
+                       /*
+                        * The draft says not to count code points in row B,
+                        * but the sample code does, and example encoding 
+                        * agrees with the sample code.
+                        */
+                       if ((base <= v && v < base + 256) || is_ldh(v))
+#else
+                       if (is_ldh(v))
+#endif
+                               continue;
+                       if (lo <= v && v <= hi)
+                               count++;
+               }
+               if (count > bestcnt || (count == bestcnt && n < bestwin)) {
+                       bestcnt = count;
+                       bestwin = n;
+               }
+       }
+       return (bestwin);
+}
+
+static unsigned long
+row_offset(int row) {
+       assert (0 <= row && row < 256);
+
+       if (0xd8 <= row && row <= 0xdf) {
+               return (acem_special_row[row - 0xd8]);
+       } else {
+               return (row << 8);
+       }
+}
+
+static int
+choose_style(const unsigned long *ucs, size_t len, int a, int b, int c) {
+       int narrow = estimate(amcacem_narrow_style, ucs, len, a, b, c);
+       int wide = estimate(amcacem_wide_style, ucs, len, a, b, c);
+
+       if (narrow <= wide)
+               return (amcacem_narrow_style);
+       else
+               return (amcacem_wide_style);
+}
+
+static int
+estimate(int style, const unsigned long *ucs, size_t ulen,
+        int a, int b, int c)
+{
+       unsigned long offseta, offsetb, offsetc;
+       int i;
+       int len;
+
+       offsetb = row_offset(b);
+       offseta = ((offsetb >> 3) + a) << 3;
+
+       if (style == amcacem_narrow_style) {
+               offsetc = (offsetb >> 12) << 12;
+               if (b <= 0xff)
+                       len = 3;
+               else
+                       len = 4;
+       } else {
+               offsetc = c << 11;
+               if (b <= 0xff && c <= 0x1f)
+                       len = 3;
+               else
+                       len = 5;
+       }
+
+       for (i = 0; i < ulen; i++) {
+               unsigned long c = ucs[i];
+
+               if (is_ldh(c))
+                       continue;
+               if (style == amcacem_narrow_style &&
+                   offseta <= c && c <= offseta + 0xf)
+                       len++;
+               else if (offsetb <= c && c <= offsetb + 0xff)
+                       len += 2;
+               else if (offsetc <= c && c <= offsetc + 0xfff)
+                       len += 3;
+               else if (style == amcacem_wide_style &&
+                          offsetc +0x1000 <= c && c <= offsetc + 0x4fff)
+                       len += 3;
+               else if (c <= 0xffff)
+                       len += 4;
+               else
+                       len += 5;
+       }
+       return (len);
+}
+
+static unsigned long
+base32decode(const char *s, int len, int *err) {
+       long v = 0;
+
+       while (len-- > 0) {
+               int c = *s++;
+               if ('a' <= c && c <= 'z') {
+                       c = base32decode_ascii[c - 'a'];
+               } else if ('A' <= c && c <= 'Z') {
+                       c = base32decode_ascii[c - 'A'];
+               } else if ('0' <= c && c <= '9') {
+                       c = base32decode_digit[c - '0'];
+               } else {
+                       *err = 1;
+                       return (0);
+               }
+               v = (v << 5) + c;
+       }
+       return (v);
+}
+
+/*
+ * Common Utility Functions.
+ */
+
+static mdn_result_t
+utf8_to_ucs4(const char *utf8, size_t fromlen, ucsbuf_t *b) {
+       mdn_result_t r;
+
+       while (fromlen > 0) {
+               unsigned long c;
+               int w;
+
+               if ((w = mdn_utf8_getwc(utf8, fromlen, &c)) == 0)
+                       return (mdn_invalid_encoding);
+               utf8 += w;
+               fromlen -= w;
+
+               if ((r = ucsbuf_append(b, c)) != mdn_success)
+                       return (r);
+       }
+       return (mdn_success);
+}
+
+static void
+ucsbuf_init(ucsbuf_t *b) {
+       b->ucs = b->local;
+       b->size = UCSBUF_LOCAL_SIZE;
+       b->len = 0;
+}
+
+static mdn_result_t
+ucsbuf_grow(ucsbuf_t *b) {
+       if (b->ucs == b->local)
+               b->ucs = NULL;
+       b->size *= 2;
+       b->ucs = realloc(b->ucs, sizeof(unsigned long) * b->size);
+       if (b->ucs == NULL)
+               return (mdn_nomemory);
+       return (mdn_success);
+}
+
+static mdn_result_t
+ucsbuf_append(ucsbuf_t *b, unsigned long v) {
+       mdn_result_t r;
+
+       if (b->len + 1 > b->size) {
+               r = ucsbuf_grow(b);
+               if (r != mdn_success)
+                       return (r);
+       }
+       b->ucs[b->len++] = v;
+       return (mdn_success);
+}
+
+static void
+ucsbuf_free(ucsbuf_t *b) {
+       if (b->ucs != b->local) {
+               free(b->ucs);
+               b->ucs = b->local;
+       }
+}
+
+static int
+is_ldh(unsigned long v) {
+       if (('a' <= v && v <= 'z') || ('A' <= v && v <= 'Z') ||
+           ('0' <= v && v <= '9') || v == '-')
+               return (1);
+       else
+               return (0);
+}
diff --git a/contrib/idn/mdnkit/lib/amcaceo.c b/contrib/idn/mdnkit/lib/amcaceo.c
new file mode 100644 (file)
index 0000000..1882c40
--- /dev/null
@@ -0,0 +1,656 @@
+#ifndef lint
+static char *rcsid = "$Id: amcaceo.c,v 1.1 2001/06/09 00:30:12 tale 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+ * Tokyo, 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) Japan Network Information Center.  All rights reserved."
+ * 
+ * 4. Neither the name of JPNIC may 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.
+ * 
+ * 6. Indemnification by Licensee
+ *    Any person or entities using and/or redistributing this Software under
+ *    this License Terms and Conditions shall defend indemnify and hold
+ *    harmless JPNIC from and against any and all judgements damages,
+ *    expenses, settlement liabilities, cost and other liabilities of any
+ *    kind as a result of use and redistribution of this Software or any
+ *    claim, suite, action, litigation or proceeding by any third party
+ *    arising out of or relates to this License Terms and Conditions.
+ * 
+ * 7. Governing Law, Jurisdiction and Venue
+ *    This License Terms and Conditions shall be governed by and and
+ *    construed in accordance with the law of Japan. Any person or entities
+ *    using and/or redistributing this Software under this License Terms and
+ *    Conditions hereby agrees and consent to the personal and exclusive
+ *    jurisdiction and venue of Tokyo District Court of Japan.
+ */
+
+#include <config.h>
+
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <mdn/result.h>
+#include <mdn/assert.h>
+#include <mdn/logmacro.h>
+#include <mdn/converter.h>
+#include <mdn/utf8.h>
+#include <mdn/debug.h>
+#include <mdn/amcaceo.h>
+#include <mdn/ace.h>
+#include <mdn/util.h>
+
+/*
+ * Although draft-ietf-idn-amc-ace-o-00.txt doesn't specify the ACE
+ * signature, we have to choose one.
+ */
+#if !defined(MDN_AMCACEO_PREFIX) && !defined(MDN_AMCACEO_SUFFIX)
+#define MDN_AMCACEO_SUFFIX             "-amc2"
+#endif
+
+#define UCSBUF_LOCAL_SIZE      40
+
+typedef struct ucsbuf {
+       unsigned long *ucs;
+       size_t size;
+       size_t len;
+       unsigned long local[UCSBUF_LOCAL_SIZE];
+} ucsbuf_t;
+
+static const char *base32encode = "abcdefghijkmnpqrstuvwxyz23456789";
+static const int base32decode_ascii[26] = {
+       0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, 11, 12, -1, 13, 14, 15,
+       16, 17, 18, 19, 20, 21, 22, 23,
+};
+static const int base32decode_digit[10] = {
+       -1, -1, 24, 25, 26, 27, 28, 29, 30, 31,
+};
+static const unsigned long special_refpoint[] = {
+       0x20, 0x50, 0x70, 0xa0, 0xc0, 0xe0, 0x140, 0x270,
+};
+
+typedef struct {
+       unsigned long refpoint[5];
+       unsigned long prefix[3];
+       int best_count;
+       unsigned long best_refpoint;
+       unsigned long best_prefix;
+       unsigned long *input;
+       size_t input_len;
+} amcaceo_encode_ctx;
+
+typedef struct {
+       unsigned long refpoint[5];
+} amcaceo_decode_ctx;
+
+static mdn_result_t    amcaceo_decode(const char *from, size_t fromlen,
+                                   char *to, size_t tolen);
+static mdn_result_t    amcaceo_encode(const char *from, size_t fromlen,
+                                   char *to, size_t tolen);
+static void            init_encode_ctx(amcaceo_encode_ctx *ctx);
+static void            choose_refpoints(amcaceo_encode_ctx *ctx);
+static unsigned long   prefix_to_refpoint(int k, unsigned long prefix);
+static void            census(amcaceo_encode_ctx *ctx, int k,
+                              unsigned long prefix);
+static int             find_refpoint(unsigned long *refpoint,
+                                     int start, unsigned long v);
+static int             encode_refpoints(amcaceo_encode_ctx *ctx,
+                                        char *to, size_t tolen);
+static int             encode_point(unsigned long *refpoint,
+                                    unsigned long v, char *to, size_t tolen);
+static int             decode_point(unsigned long *refpoint,
+                                    const char *from, size_t fromlen,
+                                    unsigned long *vp);
+static void            bootstrap(unsigned long *refpoint,
+                                 int k, unsigned long prefix);
+static int             amcaceo_getwc(const char *s, size_t len,
+                                     unsigned long *vp);
+static int             amcaceo_putwc(char *s, size_t len,
+                                     unsigned long v, int w);
+
+static mdn_result_t    utf8_to_ucs4(const char *utf8, size_t fromlen,
+                                    ucsbuf_t *b);
+static void            ucsbuf_init(ucsbuf_t *b);
+static mdn_result_t    ucsbuf_grow(ucsbuf_t *b);
+static mdn_result_t    ucsbuf_append(ucsbuf_t *b, unsigned long v);
+static void            ucsbuf_free(ucsbuf_t *b);
+static int             is_ldh(unsigned long v);
+
+static mdn__ace_t amcaceo_ctx = {
+#ifdef MDN_AMCACEO_PREFIX
+       mdn__ace_prefix,
+       MDN_AMCACEO_PREFIX,
+#else
+       mdn__ace_suffix,
+       MDN_AMCACEO_SUFFIX,
+#endif
+       amcaceo_encode,
+       amcaceo_decode,
+};
+
+/* ARGSUSED */
+mdn_result_t
+mdn__amcaceo_open(mdn_converter_t ctx, mdn_converter_dir_t dir,
+                 void **privdata)
+{
+       return (mdn_success);
+}
+
+/* ARGSUSED */
+mdn_result_t
+mdn__amcaceo_close(mdn_converter_t ctx, void *privdata,
+                  mdn_converter_dir_t dir)
+{
+       return (mdn_success);
+}
+
+mdn_result_t
+mdn__amcaceo_convert(mdn_converter_t ctx, void *privdata,
+                    mdn_converter_dir_t dir,
+                    const char *from, char *to, size_t tolen)
+{
+       mdn_result_t r;
+
+       assert(ctx != NULL &&
+              (dir == mdn_converter_l2u || dir == mdn_converter_u2l));
+
+       TRACE(("mdn__amcaceo_convert(dir=%s,from=\"%s\")\n",
+              dir == mdn_converter_l2u ? "l2u" : "u2l",
+              mdn_debug_xstring(from, 20)));
+
+       r = mdn__ace_convert(&amcaceo_ctx, dir, from, to, tolen);
+       if (r != mdn_success)
+               return (r);
+
+       DUMP(("mdn__amcaceo_convert: \"%s\"\n", mdn_debug_xstring(to, 70)));
+
+       return (r);
+}
+
+static mdn_result_t
+amcaceo_decode(const char *from, size_t fromlen, char *to, size_t tolen) {
+       size_t len;
+       int k;
+       int literal_mode = 0;
+       unsigned long v;
+       unsigned long refpoint[5];
+       static unsigned long refpoint_initial[5] = {
+               0, 0x10, 0, 0, 0x10000,
+       };
+
+       memcpy(refpoint, refpoint_initial, sizeof(refpoint));
+       for (k = 2; k >= 0; k--) {
+               len = decode_point(refpoint, from, fromlen, &v);
+               if (len == 0)
+                       return (mdn_invalid_encoding);
+               from += len;
+               fromlen -= len;
+               bootstrap(refpoint, k, v);
+       }
+
+       while (fromlen > 0) {
+               if (from[0] == '-') {
+                       if (fromlen > 1 && from[1] == '-') {
+                               v = '-';
+                               from += 2;
+                               fromlen -= 2;
+                       } else {
+                               literal_mode = !literal_mode;
+                               from++;
+                               fromlen--;
+                               continue;
+                       }
+               } else if (literal_mode) {
+                       v = from[0];
+                       from++;
+                       fromlen--;
+               } else {
+                       len = decode_point(refpoint, from, fromlen, &v);
+                       if (len == 0)
+                               return (mdn_invalid_encoding);
+                       from += len;
+                       fromlen -= len;
+               }
+               len = mdn_utf8_putwc(to, tolen, v);
+               if (len == 0)
+                       return (mdn_buffer_overflow);
+               to += len;
+               tolen -= len;
+       }
+
+       /*
+        * Terminate with NUL.
+        */
+       if (tolen <= 0)
+               return (mdn_buffer_overflow);
+
+       *to = '\0';
+       return (mdn_success);
+}
+
+static mdn_result_t
+amcaceo_encode(const char *from, size_t fromlen, char *to, size_t tolen) {
+       ucsbuf_t ucsb;
+       amcaceo_encode_ctx ctx;
+       size_t len;
+       mdn_result_t r;
+       int literal_mode = 0;
+       int i;
+
+       /*
+        * Convert to UCS-4.
+        */
+       ucsbuf_init(&ucsb);
+       if ((r = utf8_to_ucs4(from, fromlen, &ucsb)) != mdn_success)
+               return (r);
+
+       /*
+        * Verify that all the code points are within 0-0x10FFFF range.
+        */
+       for (i = 0; i < ucsb.len; i++) {
+               if (ucsb.ucs[i] > 0x10FFFF) {
+                       ucsbuf_free(&ucsb);
+                       return (mdn_invalid_encoding);
+               }
+       }
+
+       init_encode_ctx(&ctx);
+       ctx.input = ucsb.ucs;
+       ctx.input_len = ucsb.len;
+       choose_refpoints(&ctx);
+       if ((len = encode_refpoints(&ctx, to, tolen)) == 0)
+               goto overflow;
+
+       to += len;
+       tolen -= len;
+
+       for (i = 0; i < ctx.input_len; i++) {
+               unsigned long v = ctx.input[i];
+
+               if (v == '-') {
+                       /*
+                        * Convert "-" to "--".
+                        */
+                       if (tolen < 2)
+                               goto overflow;
+                       to[0] = to[1] = '-';
+                       to += 2;
+                       tolen -= 2;
+               } else if (is_ldh(v)) {
+                       /*
+                        * LDH characters.
+                        */
+                       if (literal_mode == 0) {
+                               /*
+                                * Go into literal mode.
+                                */
+                               if (tolen < 1)
+                                       goto overflow;
+                               *to++ = '-';
+                               tolen--;
+                               literal_mode = 1;
+                       }
+                       if (tolen < 1)
+                               goto overflow;
+                       *to++ = v;
+                       tolen--;
+               } else {
+                       /*
+                        * Non-LDH characters.
+                        */
+                       if (literal_mode != 0) {
+                               /*
+                                * Get out of literal mode.
+                                */
+                               if (tolen < 1)
+                                       goto overflow;
+                               *to++ = '-';
+                               tolen--;
+                               literal_mode = 0;
+                       }
+                       len = encode_point(ctx.refpoint, v, to, tolen);
+                       if (len == 0)
+                               goto overflow;
+                       to += len;
+                       tolen -= len;
+               }
+       }
+
+       /*
+        * Terminate with NUL.
+        */
+       if (tolen < 1)
+               return (mdn_buffer_overflow);
+
+       to[0] = '\0';
+
+       ucsbuf_free(&ucsb);
+       return (mdn_success);
+
+ overflow:
+       ucsbuf_free(&ucsb);
+       return (mdn_buffer_overflow);
+}
+
+static void
+init_encode_ctx(amcaceo_encode_ctx *ctx) {
+       ctx->refpoint[0] = 0;
+       ctx->refpoint[1] = 0;
+       ctx->refpoint[2] = 0;
+       ctx->refpoint[3] = 0;
+       ctx->refpoint[4] = 0x10000;
+       ctx->prefix[0] = 0;
+       ctx->prefix[1] = 0;
+       ctx->prefix[2] = 0;
+       ctx->best_count = 0;
+       ctx->best_refpoint = 0;
+       ctx->input = NULL;
+       ctx->input_len = 0;
+}
+
+static void
+choose_refpoints(amcaceo_encode_ctx *ctx) {
+       unsigned long *v = ctx->input;
+       size_t len = ctx->input_len;
+       int k, i;
+
+       for (k = 0; k < 3; k++) {
+               unsigned long prefix;
+
+               ctx->best_count = 0;
+               ctx->best_refpoint = 0;
+               ctx->best_prefix = 0;
+
+               /*
+                * Try various prefixes and choose the best one.
+                */
+               for (i = 0; i < len; i++) {
+                       prefix = v[i] >> ((k + 1) * 4);
+                       census(ctx, k, prefix);
+               }
+               if (k == 1) {
+                       for (i = 0; i < 8; i++) {
+                               prefix = 0xd8 + i;
+                               census(ctx, k, prefix);
+                       }
+               } else if (k == 2) {
+                       prefix = 0xd;
+                       census(ctx, k, prefix);
+               }
+               ctx->refpoint[k] = ctx->best_refpoint;
+               ctx->prefix[k] = ctx->best_prefix;
+       }
+}
+
+static unsigned long
+prefix_to_refpoint(int k, unsigned long prefix) {
+       if (k == 1 && 0xd8 <= prefix && prefix <= 0xdf)
+               return (special_refpoint[prefix - 0xd8]);
+       else
+               return (prefix << ((k + 1) * 4));
+}
+
+static void
+census(amcaceo_encode_ctx *ctx, int k, unsigned long prefix) {
+       unsigned long *v = ctx->input;
+       size_t len = ctx->input_len;
+       int count;
+       int i;
+       unsigned long *refpoint = ctx->refpoint;
+
+       ctx->refpoint[k] = prefix_to_refpoint(k, prefix);
+
+       count = 0;
+       for (i = 0; i < len; i++) {
+               if (!is_ldh(v[i]) && find_refpoint(refpoint, 0, v[i]) == k)
+                       count++;
+       }
+       for (i = 0; i < k; i++) {       /* draft say until i <= k */
+               if (find_refpoint(refpoint, i + 1,
+                                 ctx->prefix[i] << (4 * (i + 1))) == k)
+                       count++;
+       }
+       if (count > ctx->best_count) {
+               ctx->best_count = count;
+               ctx->best_refpoint = refpoint[k];
+               ctx->best_prefix = prefix;
+       }
+}
+
+static int
+find_refpoint(unsigned long *refpoint, int start, unsigned long v) {
+       int i;
+       static unsigned long window_size[] = {
+               0x10, 0x100, 0x1000, 0x10000, 0x100000,
+       };
+
+       for (i = start; i < 5; i++) {
+               if (v >= refpoint[i] && (v - refpoint[i]) < window_size[i])
+                       return (i);
+       }
+       return (-1);
+}
+
+static int
+encode_refpoints(amcaceo_encode_ctx *ctx, char *to, size_t tolen) {
+       int len;
+       int total = 0;
+       int k;
+
+       /*
+        * No, despite the name, we are encoding prefixes, not refpoints.
+        */
+
+       /*
+        * Set initial fixed refpoints.  Otherwise decoder cannot guess
+        * what they are.  The initial value is chosen so that prefix can
+        * be encoded efficiently.
+        */
+       ctx->refpoint[0] = 0;
+       ctx->refpoint[1] = 0x10;
+
+       for (k = 2; k >= 0; k--) {
+               len = encode_point(ctx->refpoint, ctx->prefix[k], to, tolen);
+               if (len == 0)
+                       return (0);
+               to += len;
+               tolen -= len;
+               total += len;
+               bootstrap(ctx->refpoint, k, ctx->prefix[k]);
+       }
+
+       /*
+        * Here, all the refpoints is automagically restored to the
+        * original value.
+        */
+       return (total);
+}
+
+static int
+encode_point(unsigned long *refpoint, unsigned long v, char *to, size_t tolen)
+{
+       int k = find_refpoint(refpoint, 0, v);
+       unsigned long delta = v - refpoint[k];
+
+       return (amcaceo_putwc(to, tolen, delta, k + 1));
+}
+
+static int
+decode_point(unsigned long *refpoint, const char *from, size_t fromlen,
+            unsigned long *vp)
+{
+       unsigned long delta;
+       int w;
+
+       w = amcaceo_getwc(from, fromlen, &delta);
+       if (w > 0)
+               *vp = refpoint[w - 1] + delta;
+
+       return (w);
+}
+
+static void
+bootstrap(unsigned long *refpoint, int k, unsigned long prefix) {
+       int i;
+
+       for (i = 3; i > 0; i--)
+               refpoint[i] = refpoint[i - 1] << 4;
+       if (k == 1 && 0xd8 <= prefix && prefix <= 0xdf)
+               refpoint[0] = special_refpoint[prefix - 0xd8] >> 4;
+       else
+               refpoint[0] = prefix << 4;
+}
+
+static int
+amcaceo_getwc(const char *s, size_t len, unsigned long *vp) {
+       size_t orglen = len;
+       unsigned long v = 0;
+
+       while (len > 0) {
+               int c = *s++;
+
+               if ('a' <= c && c <= 'z')
+                       c = base32decode_ascii[c - 'a'];
+               else if ('A' <= c && c <= 'Z')
+                       c = base32decode_ascii[c - 'A'];
+               else if ('0' <= c && c <= '9')
+                       c = base32decode_digit[c - '0'];
+               else
+                       c = -1;
+
+               if (c < 0)
+                       return (0);     /* invalid character */
+
+               v = (v << 4) + (c & 0xf);
+
+               len--;
+               if ((c & 0x10) == 0) {
+                       *vp = v;
+                       return (orglen - len);
+               }
+       }
+       return (0);     /* final character missing */
+}
+
+static int
+amcaceo_putwc(char *s, size_t len, unsigned long v, int w) {
+       int i, shift;
+
+       if (len < w)
+               return (0);
+
+       for (shift = 0, i = w - 1; i >= 0; i--) {
+               s[i] = base32encode[(v & 0xf) + shift];
+               v >>= 4;
+               shift = 16;
+       }
+       return (w);
+}
+
+/*
+ * Common Utility Functions.
+ */
+
+static mdn_result_t
+utf8_to_ucs4(const char *utf8, size_t fromlen, ucsbuf_t *b) {
+       mdn_result_t r;
+
+       while (fromlen > 0) {
+               unsigned long c;
+               int w;
+
+               if ((w = mdn_utf8_getwc(utf8, fromlen, &c)) == 0)
+                       return (mdn_invalid_encoding);
+               utf8 += w;
+               fromlen -= w;
+
+               if ((r = ucsbuf_append(b, c)) != mdn_success)
+                       return (r);
+       }
+       return (mdn_success);
+}
+
+static void
+ucsbuf_init(ucsbuf_t *b) {
+       b->ucs = b->local;
+       b->size = UCSBUF_LOCAL_SIZE;
+       b->len = 0;
+}
+
+static mdn_result_t
+ucsbuf_grow(ucsbuf_t *b) {
+       if (b->ucs == b->local)
+               b->ucs = NULL;
+       b->size *= 2;
+       b->ucs = realloc(b->ucs, sizeof(unsigned long) * b->size);
+       if (b->ucs == NULL)
+               return (mdn_nomemory);
+       return (mdn_success);
+}
+
+static mdn_result_t
+ucsbuf_append(ucsbuf_t *b, unsigned long v) {
+       mdn_result_t r;
+
+       if (b->len + 1 > b->size) {
+               r = ucsbuf_grow(b);
+               if (r != mdn_success)
+                       return (r);
+       }
+       b->ucs[b->len++] = v;
+       return (mdn_success);
+}
+
+static void
+ucsbuf_free(ucsbuf_t *b) {
+       if (b->ucs != b->local) {
+               free(b->ucs);
+               b->ucs = b->local;
+       }
+}
+
+static int
+is_ldh(unsigned long v) {
+       if (('a' <= v && v <= 'z') || ('A' <= v && v <= 'Z') ||
+           ('0' <= v && v <= '9') || v == '-')
+               return (1);
+       else
+               return (0);
+}
diff --git a/contrib/idn/mdnkit/lib/amcacer.c b/contrib/idn/mdnkit/lib/amcacer.c
new file mode 100644 (file)
index 0000000..a8cd8eb
--- /dev/null
@@ -0,0 +1,503 @@
+#ifndef lint
+static char *rcsid = "$Id: amcacer.c,v 1.1 2001/06/09 00:30:12 tale 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+ * Tokyo, 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) Japan Network Information Center.  All rights reserved."
+ * 
+ * 4. Neither the name of JPNIC may 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.
+ * 
+ * 6. Indemnification by Licensee
+ *    Any person or entities using and/or redistributing this Software under
+ *    this License Terms and Conditions shall defend indemnify and hold
+ *    harmless JPNIC from and against any and all judgements damages,
+ *    expenses, settlement liabilities, cost and other liabilities of any
+ *    kind as a result of use and redistribution of this Software or any
+ *    claim, suite, action, litigation or proceeding by any third party
+ *    arising out of or relates to this License Terms and Conditions.
+ * 
+ * 7. Governing Law, Jurisdiction and Venue
+ *    This License Terms and Conditions shall be governed by and and
+ *    construed in accordance with the law of Japan. Any person or entities
+ *    using and/or redistributing this Software under this License Terms and
+ *    Conditions hereby agrees and consent to the personal and exclusive
+ *    jurisdiction and venue of Tokyo District Court of Japan.
+ */
+
+#include <config.h>
+
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <mdn/result.h>
+#include <mdn/assert.h>
+#include <mdn/logmacro.h>
+#include <mdn/converter.h>
+#include <mdn/utf8.h>
+#include <mdn/debug.h>
+#include <mdn/amcacer.h>
+#include <mdn/ace.h>
+#include <mdn/util.h>
+
+/*
+ * Although draft-ietf-idn-amc-ace-r-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.
+ */
+#if !defined(MDN_AMCACER_PREFIX) && !defined(MDN_AMCACER_SUFFIX)
+#define MDN_AMCACER_PREFIX     "amc3-"
+#endif
+
+#define UCSBUF_LOCAL_SIZE      40
+
+typedef struct ucsbuf {
+       unsigned long *ucs;
+       size_t size;
+       size_t len;
+       unsigned long local[UCSBUF_LOCAL_SIZE];
+} ucsbuf_t;
+
+static const char *base32encode = "abcdefghijkmnpqrstuvwxyz23456789";
+static const int base32decode_ascii[26] = {
+       0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, 11, 12, -1, 13, 14, 15,
+       16, 17, 18, 19, 20, 21, 22, 23,
+};
+static const int base32decode_digit[10] = {
+       -1, -1, 24, 25, 26, 27, 28, 29, 30, 31,
+};
+
+static mdn_result_t    amcacer_decode(const char *from, size_t fromlen,
+                                   char *to, size_t tolen);
+static mdn_result_t    amcacer_encode(const char *from, size_t fromlen,
+                                   char *to, size_t tolen);
+static void            amcacer_update_refpoints(unsigned long *refpoint,
+                                                unsigned long *history,
+                                                int n);
+static int             amcacer_getwc(const char *s, size_t len,
+                                     unsigned long *vp);
+static int             amcacer_putwc(char *s, size_t len,
+                                     unsigned long v, int w);
+
+static mdn_result_t    utf8_to_ucs4(const char *utf8, size_t fromlen,
+                                    ucsbuf_t *b);
+static mdn_result_t    ucs4_to_utf8(ucsbuf_t *b, char *utf8, size_t ulen);
+static void            ucsbuf_init(ucsbuf_t *b);
+static mdn_result_t    ucsbuf_grow(ucsbuf_t *b);
+static mdn_result_t    ucsbuf_append(ucsbuf_t *b, unsigned long v);
+static void            ucsbuf_free(ucsbuf_t *b);
+static int             is_ldh(unsigned long v);
+
+static mdn__ace_t amcacer_ctx = {
+#ifdef MDN_AMCACER_PREFIX
+       mdn__ace_prefix,
+       MDN_AMCACER_PREFIX,
+#else
+       mdn__ace_suffix,
+       MDN_AMCACER_SUFFIX,
+#endif
+       amcacer_encode,
+       amcacer_decode,
+};
+
+static const unsigned long amcacer_refpoint_initial[6] = {
+       0, 0x60, 0, 0, 0, 0x10000,
+};
+
+
+/* ARGSUSED */
+mdn_result_t
+mdn__amcacer_open(mdn_converter_t ctx, mdn_converter_dir_t dir,
+                 void **privdata)
+{
+       return (mdn_success);
+}
+
+/* ARGSUSED */
+mdn_result_t
+mdn__amcacer_close(mdn_converter_t ctx, void *privdata,
+                  mdn_converter_dir_t dir)
+{
+       return (mdn_success);
+}
+
+mdn_result_t
+mdn__amcacer_convert(mdn_converter_t ctx, void *privdata,
+                    mdn_converter_dir_t dir,
+                    const char *from, char *to, size_t tolen)
+{
+       mdn_result_t r;
+
+       assert(ctx != NULL &&
+              (dir == mdn_converter_l2u || dir == mdn_converter_u2l));
+
+       TRACE(("mdn__amcacer_convert(dir=%s,from=\"%s\")\n",
+              dir == mdn_converter_l2u ? "l2u" : "u2l",
+              mdn_debug_xstring(from, 20)));
+
+       r = mdn__ace_convert(&amcacer_ctx, dir, from, to, tolen);
+       if (r != mdn_success)
+               return (r);
+
+       DUMP(("mdn__amcacer_convert: \"%s\"\n", mdn_debug_xstring(to, 70)));
+
+       return (r);
+}
+
+static mdn_result_t
+amcacer_decode(const char *from, size_t fromlen, char *to, size_t tolen) {
+       size_t len;
+       unsigned long refpoint[6], v;
+       ucsbuf_t ucsb;
+       int literal_mode = 0;
+       mdn_result_t r;
+
+       (void)memcpy(refpoint, amcacer_refpoint_initial, sizeof(refpoint));
+
+       ucsbuf_init(&ucsb);
+
+       while (fromlen > 0) {
+               if (from[0] == '-') {
+                       if (fromlen > 1 && from[1] == '-') {
+                               v = '-';
+                               from += 2;
+                               fromlen -= 2;
+                       } else {
+                               literal_mode = !literal_mode;
+                               from++;
+                               fromlen--;
+                               continue;
+                       }
+               } else if (literal_mode) {
+                       v = from[0];
+                       from++;
+                       fromlen--;
+               } else {
+                       len = amcacer_getwc(from, fromlen, &v);
+                       if (len == 0) {
+                               r = mdn_invalid_encoding;
+                               goto finish;
+                       }
+                       from += len;
+                       fromlen -= len;
+                       v = refpoint[len] + v;
+               }
+               if ((r = ucsbuf_append(&ucsb, v)) != mdn_success)
+                       goto finish;
+               amcacer_update_refpoints(refpoint, ucsb.ucs, ucsb.len - 1);
+       }
+
+       r = ucs4_to_utf8(&ucsb, to, tolen);
+ finish:
+       ucsbuf_free(&ucsb);
+
+       return (r);
+}
+
+static mdn_result_t
+amcacer_encode(const char *from, size_t fromlen, char *to, size_t tolen) {
+       ucsbuf_t ucsb;
+       unsigned long *buf;
+       size_t len;
+       int literal_mode = 0;
+       unsigned long refpoint[6];
+       mdn_result_t r;
+       int i;
+
+       /* Initialize refpoints. */
+       (void)memcpy(refpoint, amcacer_refpoint_initial, sizeof(refpoint));
+
+       /*
+        * Convert input string to UCS-4.
+        */
+       ucsbuf_init(&ucsb);
+       if ((r = utf8_to_ucs4(from, fromlen, &ucsb)) != mdn_success)
+               return (r);
+
+       buf = ucsb.ucs;
+       len = ucsb.len;
+
+       /*
+        * Now 'buf' contains UCS-4 string consisting of 'len' characters.
+        */
+
+       for (i = 0; i < len; i++) {
+               if (buf[i] == '-') {
+                       /*
+                        * Convert "-" to "--".
+                        */
+                       if (tolen < 2)
+                               return (mdn_buffer_overflow);
+                       to[0] = to[1] = '-';
+                       to += 2;
+                       tolen -= 2;
+               } else if (is_ldh(buf[i])) {
+                       /*
+                        * LDH characters.
+                        */
+                       if (literal_mode == 0) {
+                               /*
+                                * Go into literal mode.
+                                */
+                               if (tolen < 1)
+                                       goto overflow;
+                               *to++ = '-';
+                               tolen--;
+                               literal_mode = 1;
+                       }
+                       if (tolen < 1)
+                               goto overflow;
+                       *to++ = buf[i];
+                       tolen--;
+               } else {
+                       /*
+                        * Non-LDH characters.
+                        */
+                       int k;
+
+                       if (literal_mode != 0) {
+                               /*
+                                * Get out of literal mode.
+                                */
+                               if (tolen < 1)
+                                       goto overflow;
+                               *to++ = '-';
+                               tolen--;
+                               literal_mode = 0;
+                       }
+                       for (k = 1; k < 6; k++) {
+                               if (buf[i] >= refpoint[k] &&
+                                   buf[i] - refpoint[k] < (1 << (4 * k)))
+                                       break;
+                       }
+                       k = amcacer_putwc(to, tolen, buf[i] - refpoint[k],
+                                           k);
+                       if (k == 0)
+                               goto overflow;
+                       to += k;
+                       tolen -= k;
+                       amcacer_update_refpoints(refpoint, buf, i);
+               }
+       }
+
+       /*
+        * Terminate with NUL.
+        */
+       if (tolen <= 0)
+               return (mdn_buffer_overflow);
+
+       *to = '\0';
+
+       ucsbuf_free(&ucsb);
+       return (mdn_success);
+
+ overflow:
+       ucsbuf_free(&ucsb);
+       return (mdn_buffer_overflow);
+}
+
+static void
+amcacer_update_refpoints(unsigned long *refpoint,
+                        unsigned long *history, int n)
+{
+       int k;
+       unsigned long lastchar = history[n];
+
+#define MAX_K(k)       (1 << (4 * (k)))
+#define ROUND_K(v, k)  (((v) >> (4 * (k))) << (4 * (k)))
+       if (n == 0) {
+               for (k = 1; k < 4; k++)
+                       refpoint[k] = ROUND_K(lastchar, k);
+               return;
+       }
+
+       for (k = 1; k < 4; k++) {
+               unsigned long max = MAX_K(k);
+               int i;
+
+               for (i = n - 1; i >= 0; i--) {
+                       if (is_ldh(history[i]))
+                               continue;
+                       if ((refpoint[k] ^ history[i]) < max)
+                               break;
+                       if ((lastchar ^ history[i]) < max) {
+                               refpoint[k] = ROUND_K(lastchar, k);
+                               return;
+                       }
+               }
+       }
+#undef MAX_K
+#undef ROUND_K
+}
+
+static int
+amcacer_getwc(const char *s, size_t len, unsigned long *vp) {
+       size_t orglen = len;
+       unsigned long v = 0;
+
+       while (len > 0) {
+               int c = *s++;
+
+               if ('a' <= c && c <= 'z')
+                       c = base32decode_ascii[c - 'a'];
+               else if ('A' <= c && c <= 'Z')
+                       c = base32decode_ascii[c - 'A'];
+               else if ('0' <= c && c <= '9')
+                       c = base32decode_digit[c - '0'];
+               else
+                       c = -1;
+
+               if (c < 0)
+                       return (0);     /* invalid character */
+
+               v = (v << 4) + (c & 0xf);
+
+               len--;
+               if ((c & 0x10) == 0) {
+                       *vp = v;
+                       return (orglen - len);
+               }
+       }
+       return (0);     /* final character missing */
+}
+
+static int
+amcacer_putwc(char *s, size_t len, unsigned long v, int w) {
+       int i, shift;
+
+       for (shift = 0, i = w - 1; i >= 0; i--) {
+               s[i] = base32encode[(v & 0xf) + shift];
+               v >>= 4;
+               shift = 16;
+       }
+       return (w);
+}
+
+/*
+ * Common Utility Functions.
+ */
+
+static mdn_result_t
+utf8_to_ucs4(const char *utf8, size_t fromlen, ucsbuf_t *b) {
+       mdn_result_t r;
+
+       while (fromlen > 0) {
+               unsigned long c;
+               int w;
+
+               if ((w = mdn_utf8_getwc(utf8, fromlen, &c)) == 0)
+                       return (mdn_invalid_encoding);
+               utf8 += w;
+               fromlen -= w;
+
+               if ((r = ucsbuf_append(b, c)) != mdn_success)
+                       return (r);
+       }
+       return (mdn_success);
+}
+
+static mdn_result_t
+ucs4_to_utf8(ucsbuf_t *b, char *utf8, size_t ulen) {
+       unsigned long *s = b->ucs;
+       size_t len = b->len;
+       int i;
+
+       for (i = 0; i < len; i++) {
+               int w = mdn_utf8_putwc(utf8, ulen, s[i]);
+
+               if (w == 0)
+                       return (mdn_buffer_overflow);
+               utf8 += w;
+               ulen -= w;
+       }
+       if (ulen < 1)
+               return (mdn_buffer_overflow);
+       *utf8 = '\0';
+       return (mdn_success);
+}
+
+static void
+ucsbuf_init(ucsbuf_t *b) {
+       b->ucs = b->local;
+       b->size = UCSBUF_LOCAL_SIZE;
+       b->len = 0;
+}
+
+static mdn_result_t
+ucsbuf_grow(ucsbuf_t *b) {
+       if (b->ucs == b->local)
+               b->ucs = NULL;
+       b->size *= 2;
+       b->ucs = realloc(b->ucs, sizeof(unsigned long) * b->size);
+       if (b->ucs == NULL)
+               return (mdn_nomemory);
+       return (mdn_success);
+}
+
+static mdn_result_t
+ucsbuf_append(ucsbuf_t *b, unsigned long v) {
+       mdn_result_t r;
+
+       if (b->len + 1 > b->size) {
+               r = ucsbuf_grow(b);
+               if (r != mdn_success)
+                       return (r);
+       }
+       b->ucs[b->len++] = v;
+       return (mdn_success);
+}
+
+static void
+ucsbuf_free(ucsbuf_t *b) {
+       if (b->ucs != b->local) {
+               free(b->ucs);
+               b->ucs = b->local;
+       }
+}
+
+static int
+is_ldh(unsigned long v) {
+       if (('a' <= v && v <= 'z') || ('A' <= v && v <= 'Z') ||
+           ('0' <= v && v <= '9') || v == '-')
+               return (1);
+       else
+               return (0);
+}
diff --git a/contrib/idn/mdnkit/lib/api.c b/contrib/idn/mdnkit/lib/api.c
new file mode 100644 (file)
index 0000000..cd25322
--- /dev/null
@@ -0,0 +1,207 @@
+#ifndef lint
+static char *rcsid = "$Id: api.c,v 1.1 2001/06/09 00:30:12 tale 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+ * Tokyo, 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) Japan Network Information Center.  All rights reserved."
+ * 
+ * 4. Neither the name of JPNIC may 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.
+ * 
+ * 6. Indemnification by Licensee
+ *    Any person or entities using and/or redistributing this Software under
+ *    this License Terms and Conditions shall defend indemnify and hold
+ *    harmless JPNIC from and against any and all judgements damages,
+ *    expenses, settlement liabilities, cost and other liabilities of any
+ *    kind as a result of use and redistribution of this Software or any
+ *    claim, suite, action, litigation or proceeding by any third party
+ *    arising out of or relates to this License Terms and Conditions.
+ * 
+ * 7. Governing Law, Jurisdiction and Venue
+ *    This License Terms and Conditions shall be governed by and and
+ *    construed in accordance with the law of Japan. Any person or entities
+ *    using and/or redistributing this Software under this License Terms and
+ *    Conditions hereby agrees and consent to the personal and exclusive
+ *    jurisdiction and venue of Tokyo District Court of Japan.
+ */
+
+#include <config.h>
+
+#include <string.h>
+
+#include <mdn/result.h>
+#include <mdn/assert.h>
+#include <mdn/log.h>
+#include <mdn/logmacro.h>
+#include <mdn/resconf.h>
+#include <mdn/api.h>
+#include <mdn/debug.h>
+#include <mdn/res.h>
+
+static struct actiondesc {
+       int bit;
+       char *desc;
+} actiondesc[] = {
+       { MDN_LOCALCONV, "local-conv" },
+       { MDN_IDNCONV, "idn-conv" },
+       { MDN_NAMEPREP, "nameprep" },
+       { MDN_UNASCHECK, "unassigned-check" },
+       { MDN_LOCALMAP, "local-map" },
+       { MDN_DELIMMAP, "delimiter-map" },
+       { 0, "" },
+};
+
+#define ENCODE_MASK \
+       (MDN_LOCALCONV|MDN_IDNCONV|MDN_NAMEPREP|MDN_UNASCHECK|\
+        MDN_DELIMMAP|MDN_LOCALMAP)
+#define DECODE_MASK (MDN_LOCALCONV|MDN_IDNCONV)
+
+static int initialized;
+static mdn_resconf_t default_conf;
+
+static char    *actions_to_string(int actions);
+
+mdn_result_t
+mdn_nameinit(void) {
+       mdn_result_t r;
+       static int firsttime = 1;
+
+       TRACE(("mdn_nameinit()\n"));
+
+       initialized = 1;
+       if (firsttime) {
+               mdn_resconf_initialize();
+               firsttime = 0;
+       }
+       if (default_conf != NULL) {
+               mdn_resconf_destroy(default_conf);
+               default_conf = NULL;
+       }
+       if ((r = mdn_resconf_create(&default_conf)) == mdn_success) {
+               r = mdn_resconf_loadfile(default_conf, NULL);
+       }
+       return (r);
+}
+
+mdn_result_t
+mdn_encodename(int actions, const char *from, char *to, size_t tolen) {
+       char buf[20];
+       char *p = buf;
+       mdn_result_t r;
+
+       assert(from != NULL && to != NULL);
+
+       TRACE(("mdn_encodename(actions=%s, from=\"%s\")\n",
+              actions_to_string(actions),
+              mdn_debug_xstring(from, 30)));
+
+       if (actions & ~ENCODE_MASK) {
+               WARNING(("mdn_encodename: invalid actions 0x%x\n", actions));
+               return mdn_invalid_action;
+       }
+
+       if (!initialized && ((r = mdn_nameinit()) != mdn_success))
+               return (r);
+
+       if (actions & MDN_LOCALCONV)
+               *p++ = 'l';
+       if (actions & MDN_LOCALMAP)
+               *p++ = 'd';
+       if (actions & MDN_LOCALMAP)
+               *p++ = 'M';
+       if (actions & MDN_NAMEPREP) {
+               p[0] = 'm';
+               p[1] = 'n';
+               p[2] = 'p';
+               p += 3;
+       }
+       if (actions & MDN_UNASCHECK)
+               *p++ = 'u';
+       if (actions & MDN_IDNCONV)
+               *p++ = 'I';
+       *p = '\0';
+
+       return (mdn_res_nameconv(default_conf, buf, from, to, tolen));
+}
+
+mdn_result_t
+mdn_decodename(int actions, const char *from, char *to, size_t tolen) {
+       char buf[20];
+       char *p = buf;
+       mdn_result_t r;
+
+       assert(from != NULL && to != NULL);
+
+       TRACE(("mdn_decodename(actions=%s, from=\"%s\")\n",
+              actions_to_string(actions),
+              mdn_debug_xstring(from, 30)));
+
+       if (actions & ~DECODE_MASK) {
+               WARNING(("mdn_decodename: invalid actions 0x%x\n", actions));
+               return mdn_invalid_action;
+       }
+
+       if (!initialized && ((r = mdn_nameinit()) != mdn_success))
+               return (r);
+
+       if (actions & MDN_IDNCONV)
+               *p++ = 'i';
+       if (actions & MDN_LOCALCONV)
+               *p++ = 'L';
+       *p = '\0';
+
+       return (mdn_res_nameconv(default_conf, buf, from, to, tolen));
+}
+
+static char *
+actions_to_string(int actions) {
+       static char buf[100];
+       int i;
+       int first = 1;
+
+       buf[0] = '\0';
+       for (i = 0; actiondesc[i].bit != 0; i++) {
+               if (actions & actiondesc[i].bit) {
+                       if (!first)
+                               strcat(buf, "|");
+                       strcat(buf, actiondesc[i].desc);
+                       first = 0;
+               }
+       }
+       return (buf);
+}
index 4fa22f2cf876c166a33b5d264c2c9a42479be27b..d87533e472ea68a04811de2768b7a1fd29d4b212 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
-static char *rcsid = "$Id: brace.c,v 1.11 2000/11/22 06:33:33 m-kasahr Exp $";
+static char *rcsid = "$Id: brace.c,v 1.16 2001/03/07 00:58:51 ishisone Exp $";
 #endif
 
 /*
@@ -73,12 +73,12 @@ static char *rcsid = "$Id: brace.c,v 1.11 2000/11/22 06:33:33 m-kasahr Exp $";
 #include <mdn/utf8.h>
 #include <mdn/debug.h>
 #include <mdn/brace.h>
+#include <mdn/ace.h>
 #include <mdn/util.h>
 
 #ifndef MDN_BRACE_SUFFIX
 #define MDN_BRACE_SUFFIX               "-8q9"
 #endif
-#define BRACE_SUFFIX_LEN       (strlen(MDN_BRACE_SUFFIX))
 #define BRACE_BUF_SIZE         128             /* more than enough */
 #define BRACE_BASE32(n)                (brace_base32[n])
 #define BRACE_RBASE32(c)       (brace_rbase32(c))
@@ -102,10 +102,6 @@ enum {
  */
 static char brace_base32[] = "23456789abcdefghijkmnpqrstuvwxyz";
 
-static mdn_result_t    brace_l2u(const char *from, const char *end,
-                                 char *to, size_t tolen, size_t *clenp);
-static mdn_result_t    brace_u2l(const char *from, const char *end,
-                                 char *to, size_t tolen, size_t *clenp);
 static mdn_result_t    brace_decode(const char *from, size_t fromlen,
                                     char *to, size_t tolen);
 static mdn_result_t    brace_decode_utf16(const char *from,
@@ -122,23 +118,33 @@ static mdn_result_t       get_encoding_style(unsigned short *p, size_t len,
                                           int *stylep, unsigned short *rowp);
 static int             brace_rbase32(int c);
 
+static mdn__ace_t brace_ctx = {
+       mdn__ace_suffix,
+       MDN_BRACE_SUFFIX,
+       brace_encode,
+       brace_decode,
+};
+
 /* ARGSUSED */
 mdn_result_t
-mdn__brace_open(mdn_converter_t ctx, mdn_converter_dir_t dir) {
+mdn__brace_open(mdn_converter_t ctx, mdn_converter_dir_t dir,
+               void **privdata) {
        return (mdn_success);
 }
 
 /* ARGSUSED */
 mdn_result_t
-mdn__brace_close(mdn_converter_t ctx, mdn_converter_dir_t dir) {
+mdn__brace_close(mdn_converter_t ctx, void *privdata,
+                mdn_converter_dir_t dir) {
        return (mdn_success);
 }
 
 mdn_result_t
-mdn__brace_convert(mdn_converter_t ctx, mdn_converter_dir_t dir,
-                  const char *from, char *toorg, size_t tolen)
+mdn__brace_convert(mdn_converter_t ctx, void *privdata,
+                  mdn_converter_dir_t dir, const char *from, char *to,
+                  size_t tolen)
 {
-       char *to = toorg;
+       mdn_result_t r;
 
        assert(ctx != NULL &&
               (dir == mdn_converter_l2u || dir == mdn_converter_u2l));
@@ -147,128 +153,13 @@ mdn__brace_convert(mdn_converter_t ctx, mdn_converter_dir_t dir,
               dir == mdn_converter_l2u ? "l2u" : "u2l",
               mdn_debug_xstring(from, 20)));
 
-       for (;;) {
-               const char *end;
-               size_t convlen;
-               mdn_result_t r;
-
-               /*
-                * Find the end of this component (label).
-                */
-               if ((end = strchr(from, '.')) == NULL)
-                       end = from + strlen(from);
-
-               /*
-                * Convert it.
-                */
-               if (dir == mdn_converter_l2u)
-                       r = brace_l2u(from, end, to, tolen, &convlen);
-               else
-                       r = brace_u2l(from, end, to, tolen, &convlen);
-               if (r != mdn_success)
-                       return (r);
-
-               /*
-                * Copy '.' or NUL.
-                */
-               if (tolen <= convlen)
-                       return (mdn_buffer_overflow);
-
-               to += convlen;
-               *to++ = *end;
-               tolen -= convlen + 1;
-
-               if (*end == '\0')
-                       break;
-
-               from = end + 1;
-       }
-
-       DUMP(("mdn__brace_convert: \"%s\"\n", mdn_debug_xstring(toorg, 70)));
-
-       return (mdn_success);
-}
-
-static mdn_result_t
-brace_l2u(const char *from, const char *end,
-         char *to, size_t tolen, size_t *clenp) {
-       size_t len = end - from;
-       size_t suflen = BRACE_SUFFIX_LEN;
-
-       if (len >= suflen &&
-           mdn_util_casematch(end - suflen, MDN_BRACE_SUFFIX, suflen)) {
-               /*
-                * BRACE encoding suffix found.
-                */
-               mdn_result_t r;
-
-               r = brace_decode(from, len - suflen, to, tolen);
-               if (r == mdn_invalid_encoding)
-                       goto copy;
-               else if (r != mdn_success)
-                       return (r);
-
-               len = strlen(to);
-       } else {
-               /*
-                * Not BRACE encoded.  Copy verbatim.
-                */
-       copy:
-               if (mdn_util_domainspan(from, end) < end) {
-                       /* invalid character found */
-                       return (mdn_invalid_encoding);
-               }
-
-               if (tolen < len)
-                       return (mdn_buffer_overflow);
-
-               (void)memcpy(to, from, len);
-       }
-       *clenp = len;
-       return (mdn_success);
-}
-
-static mdn_result_t
-brace_u2l(const char *from, const char *end,
-         char *to, size_t tolen, size_t *clenp) {
-       size_t len = end - from;
-       size_t suflen = BRACE_SUFFIX_LEN;
-
-       /*
-        * See if encoding is necessary.
-        */
-       if (mdn_util_domainspan(from, end) < end ||
-           (len >= suflen &&
-            mdn_util_casematch(end - suflen, MDN_BRACE_SUFFIX, suflen))) {
-               /*
-                * Conversion is necessary.
-                */
-               mdn_result_t r;
-               size_t t;
-
-               r = brace_encode(from, len, to, tolen);
-               if (r != mdn_success)
-                       return (r);
-               t = strlen(to);
-
-               /* Append suffix. */
-               if (tolen < t + suflen)
-                       return (mdn_buffer_overflow);
-               (void)memcpy(to + t, MDN_BRACE_SUFFIX, suflen);
+       r = mdn__ace_convert(&brace_ctx, dir, from, to, tolen);
+       if (r != mdn_success)
+               return (r);
 
-               len = t + suflen;
-       } else {
-               /*
-                * Conversion is NOT necessary.
-                * Copy verbatim.
-                */
-               if (tolen < len)
-                       return (mdn_buffer_overflow);
+       DUMP(("mdn__brace_convert: \"%s\"\n", mdn_debug_xstring(to, 70)));
 
-               (void)memcpy(to, from, len);
-       }
-       *clenp = len;
-       return (mdn_success);
+       return (r);
 }
 
 static mdn_result_t
diff --git a/contrib/idn/mdnkit/lib/checker.c b/contrib/idn/mdnkit/lib/checker.c
new file mode 100644 (file)
index 0000000..93d9135
--- /dev/null
@@ -0,0 +1,528 @@
+#ifndef lint
+static char *rcsid = "$Id: checker.c,v 1.1 2001/06/09 00:30:14 tale 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+ * Tokyo, 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) Japan Network Information Center.  All rights reserved."
+ * 
+ * 4. Neither the name of JPNIC may 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.
+ * 
+ * 6. Indemnification by Licensee
+ *    Any person or entities using and/or redistributing this Software under
+ *    this License Terms and Conditions shall defend indemnify and hold
+ *    harmless JPNIC from and against any and all judgements damages,
+ *    expenses, settlement liabilities, cost and other liabilities of any
+ *    kind as a result of use and redistribution of this Software or any
+ *    claim, suite, action, litigation or proceeding by any third party
+ *    arising out of or relates to this License Terms and Conditions.
+ * 
+ * 7. Governing Law, Jurisdiction and Venue
+ *    This License Terms and Conditions shall be governed by and and
+ *    construed in accordance with the law of Japan. Any person or entities
+ *    using and/or redistributing this Software under this License Terms and
+ *    Conditions hereby agrees and consent to the personal and exclusive
+ *    jurisdiction and venue of Tokyo District Court of Japan.
+ */
+
+#include <config.h>
+
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <mdn/result.h>
+#include <mdn/assert.h>
+#include <mdn/logmacro.h>
+#include <mdn/checker.h>
+#include <mdn/strhash.h>
+#include <mdn/debug.h>
+
+/*
+ * Type for checking scheme.
+ */
+typedef struct {
+       char *prefix;
+       char *parameter;
+       mdn_checker_createproc_t create;
+       mdn_checker_destroyproc_t destroy;
+       mdn_checker_lookupproc_t lookup;
+       void *context;
+} check_scheme_t;
+
+/*
+ * Standard checking schemes.
+ */
+static const check_scheme_t nameprep_02_prohibit_scheme = {
+       "prohibit#nameprep-02",
+       "nameprep-02",
+       mdn__nameprep_createproc,
+       mdn__nameprep_destroyproc,
+       mdn__nameprep_prohibitproc,
+       NULL,
+};
+
+static const check_scheme_t nameprep_02_unasigned_scheme = {
+       "unassigned#nameprep-02",
+       "nameprep-02",
+       mdn__nameprep_createproc,
+       mdn__nameprep_destroyproc,
+       mdn__nameprep_unassignedproc,
+       NULL,
+};
+
+static const check_scheme_t nameprep_03_prohibit_scheme = {
+       "prohibit#nameprep-03",
+       "nameprep-03",
+       mdn__nameprep_createproc,
+       mdn__nameprep_destroyproc,
+       mdn__nameprep_prohibitproc,
+       NULL,
+};
+
+static const check_scheme_t nameprep_03_unasigned_scheme = {
+       "unassigned#nameprep-03",
+       "nameprep-03",
+       mdn__nameprep_createproc,
+       mdn__nameprep_destroyproc,
+       mdn__nameprep_unassignedproc,
+       NULL,
+};
+
+static const check_scheme_t filecheck_prohibit_scheme = {
+       "prohibit#fileset",
+       NULL,
+       mdn__filechecker_createproc,
+       mdn__filechecker_destroyproc,
+       mdn__filechecker_lookupproc,
+       NULL,
+};
+
+static const check_scheme_t filecheck_unassigned_scheme = {
+       "unassigned#fileset",
+       NULL,
+       mdn__filechecker_createproc,
+       mdn__filechecker_destroyproc,
+       mdn__filechecker_lookupproc,
+       NULL,
+};
+
+static const check_scheme_t *standard_check_schemes[] = {
+       &nameprep_02_unasigned_scheme,
+       &nameprep_02_prohibit_scheme,
+       &nameprep_03_unasigned_scheme,
+       &nameprep_03_prohibit_scheme,
+       &filecheck_prohibit_scheme,
+       &filecheck_unassigned_scheme,
+       NULL,
+};
+
+/*
+ * Hash table for checking schemes.
+ */
+static mdn_strhash_t scheme_hash = NULL;
+
+/*
+ * Mapper object type.
+ */
+struct mdn_checker {
+       int nschemes;
+       int scheme_size;
+       check_scheme_t *schemes;
+       int reference_count;
+};
+
+#define MAPPER_INITIAL_SCHEME_SIZE     1
+
+mdn_result_t
+mdn_checker_initialize(void) {
+       mdn_result_t r;
+       check_scheme_t **scheme;
+
+       TRACE(("mdn_checker_initialize()\n"));
+
+       if (scheme_hash != NULL)
+               return (mdn_success);   /* already initialized */
+
+       r = mdn_strhash_create(&scheme_hash);
+       if (r != mdn_success) {
+               WARNING(("mdn_checker_initialize: "
+                       "hash table creation failed\n"));
+               goto failure;
+       }
+
+       for (scheme = (check_scheme_t **)standard_check_schemes;
+               *scheme != NULL; scheme++) {
+               r = mdn_strhash_put(scheme_hash, (*scheme)->prefix, *scheme);
+               if (r != mdn_success) {
+                       WARNING(("mdn_checker_initialize: "
+                               "hash table creation failed\n"));
+                       goto failure;
+               }
+       }
+
+       return (mdn_success);
+
+failure:
+       if (scheme_hash != NULL) {
+               mdn_strhash_destroy(scheme_hash, NULL);
+               scheme_hash = NULL;
+       }
+       return (r);
+}
+
+mdn_result_t
+mdn_checker_create(mdn_checker_t *ctxp) {
+       mdn_checker_t ctx = NULL;
+       mdn_result_t r;
+
+       assert(scheme_hash != NULL);
+       assert(ctxp != NULL);
+
+       TRACE(("mdn_checker_create()\n"));
+
+       ctx = (mdn_checker_t) malloc(sizeof(struct mdn_checker));
+       if (ctx == NULL) {
+               WARNING(("mdn_checker_create: malloc failed\n"));
+               r = mdn_nomemory;
+               goto failure;
+       }
+
+       ctx->schemes = (check_scheme_t *) malloc(sizeof(check_scheme_t)
+                * MAPPER_INITIAL_SCHEME_SIZE);
+       if (ctx->schemes == NULL) {
+               WARNING(("mdn_checker_create: malloc failed\n"));
+               r = mdn_nomemory;
+               goto failure;
+       }
+
+       ctx->nschemes = 0;
+       ctx->scheme_size = MAPPER_INITIAL_SCHEME_SIZE;
+       ctx->reference_count = 1;
+       *ctxp = ctx;
+
+       return (mdn_success);
+
+failure:
+       if (ctx != NULL)
+               free(ctx->schemes);
+       free(ctx);
+       return (r);
+}
+
+void
+mdn_checker_destroy(mdn_checker_t ctx) {
+       int i;
+
+       assert(scheme_hash != NULL);
+       assert(ctx != NULL);
+
+       TRACE(("mdn_checker_destroy()\n"));
+       TRACE(("mdn_checker_destroy: update reference count (%d->%d)\n",
+           ctx->reference_count, ctx->reference_count - 1));
+
+       ctx->reference_count--;
+       if (ctx->reference_count <= 0) {
+               TRACE(("mdn_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);
+       }
+}
+
+void
+mdn_checker_incrref(mdn_checker_t ctx) {
+       assert(ctx != NULL && scheme_hash != NULL);
+
+       TRACE(("mdn_checker_incrref()\n"));
+       TRACE(("mdn_checker_incrref: update reference count (%d->%d)\n",
+               ctx->reference_count, ctx->reference_count + 1));
+
+       ctx->reference_count++;
+}
+
+mdn_result_t
+mdn_checker_add(mdn_checker_t ctx, const char *scheme_name) {
+       mdn_result_t r;
+       check_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(("mdn_checker_add(scheme_name=%s)\n",
+               mdn_debug_xstring(scheme_name, 20)));
+
+       /*
+        * 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;
+               if (scheme_prefixlen + 1 > sizeof(static_buffer)) {
+                       buffer = (char *) malloc(scheme_prefixlen + 1);
+                       if (buffer == NULL) {
+                               r = mdn_nomemory;
+                               goto failure;
+                       }
+               }
+               memcpy(buffer, scheme_name, scheme_prefixlen);
+               *(buffer + scheme_prefixlen) = '\0';
+               scheme_prefix = buffer;
+               scheme_parameter++;
+       }
+
+       /*
+        * Find a scheme.
+        */
+       if (mdn_strhash_get(scheme_hash, scheme_prefix, (void **)&scheme)
+               != mdn_success) {
+               WARNING(("mdn_checker_add: invalid scheme %s\n",
+                        scheme_name));
+               r = mdn_invalid_name;
+               goto failure;
+       }
+       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) {
+                       WARNING(("mdn_checker_add: malloc failed\n"));
+                       r = mdn_nomemory;
+                       goto failure;
+               }
+               ctx->schemes = new_schemes;
+               ctx->scheme_size *= 2;
+       }
+
+       r = scheme->create(scheme_parameter, &scheme_context);
+       if (r != mdn_success)
+               goto failure;
+
+       memcpy(ctx->schemes + ctx->nschemes, scheme, sizeof(check_scheme_t));
+       ctx->schemes[ctx->nschemes].context = scheme_context;
+       ctx->nschemes++;
+
+       return (mdn_success);
+
+failure:
+       if (buffer != static_buffer)
+               free(buffer);
+       free(scheme_context);
+       return (r);
+}
+
+mdn_result_t
+mdn_checker_addall(mdn_checker_t ctx, const char **scheme_names,
+                  int nschemes) {
+       mdn_result_t r;
+       int i;
+
+       assert(scheme_hash != NULL);
+       assert(ctx != NULL && scheme_names != NULL);
+
+       TRACE(("mdn_checker_addall(nschemes=%d)\n", nschemes));
+
+       for (i = 0; i < nschemes; i++) {
+               r = mdn_checker_add(ctx, (const char *)*scheme_names);
+               if (r != mdn_success)
+                       return (r);
+               scheme_names++;
+       }
+
+       return (mdn_success);
+}
+
+mdn_result_t
+mdn_checker_lookup(mdn_checker_t ctx, const char *utf8, const char **found) {
+       mdn_result_t r;
+       int i;
+
+       assert(scheme_hash != NULL);
+       assert(ctx != NULL && utf8 != NULL && found != NULL);
+
+       TRACE(("mdn_checker_lookup(utf8=\"%s\")\n",
+               mdn_debug_xstring(utf8, 20)));
+
+       /*
+        * Lookup.
+        */
+       for (i = 0; i < ctx->nschemes; i++) {
+               r = (ctx->schemes[i].lookup)(ctx->schemes[i].context, utf8,
+                       found);
+               if (r != mdn_success)
+                       return (r);
+               else if (*found == NULL)
+                       return (mdn_success);
+               else if (**found != '.')
+                       return (mdn_prohibited);
+               utf8 = *found + 1;
+       }
+
+       *found = NULL;
+
+       return (mdn_success);
+}
+
+mdn_result_t
+mdn_checker_register(const char *prefix,                   
+                   mdn_checker_createproc_t create,
+                   mdn_checker_destroyproc_t destroy,
+                   mdn_checker_lookupproc_t lookup) {
+       mdn_result_t r;
+       check_scheme_t *scheme = NULL;
+
+       assert(scheme_hash != NULL);
+       assert(prefix != NULL && create != NULL && destroy != NULL &&
+               lookup != NULL);
+
+       TRACE(("mdn_checker_register(prefix=%s)\n", prefix));
+
+       scheme = (check_scheme_t *) malloc(sizeof(check_scheme_t));
+       if (scheme == NULL) {
+               WARNING(("mdn_checker_register: malloc failed\n"));
+               r = mdn_nomemory;
+               goto failure;
+       }
+
+       scheme->prefix = (char *) malloc(strlen(prefix) + 1);
+       if (scheme->prefix == NULL) {
+               WARNING(("mdn_checker_register: malloc failed\n"));
+               r = mdn_nomemory;
+               goto failure;
+       }
+
+       strcpy(scheme->prefix, prefix);
+       scheme->parameter = NULL;
+       scheme->create    = create;
+       scheme->destroy   = destroy;
+       scheme->lookup    = lookup;
+
+       r = mdn_strhash_put(scheme_hash, prefix, scheme);
+       if (r != mdn_success)
+               WARNING(("mdn_checker_register: registration failed\n"));
+
+       return (r);
+
+failure:
+       if (scheme != NULL)
+               free(scheme->prefix);
+       free(scheme);
+       return (r);
+}
+
+#ifdef TEST
+#include <stdio.h>
+
+/*
+ * Test program for this module.
+ *
+ * The test program repeatedly prompt you to input a command.  The
+ * following command is currently recognized.
+ *
+ *    add TLD           add selectable check for TLD. (e.g. com, jp)
+ *    DOMANNAME         try checking DOMANNAME.
+ *
+ * Input EOF to exit.
+ */
+int
+main(int ac, char **av) {
+       mdn_checker_t ctx;
+       char from[1024];
+       char *found;
+       size_t fromlen;
+       mdn_result_t r;
+
+       mdn_log_setlevel(mdn_log_level_trace);
+       mdn_checker_initialize();
+       r = mdn_checker_create(&ctx);
+       if (r != mdn_success) {
+               fprintf(stderr, "mdn_checker_create: %s\n",
+                       mdn_result_tostring(r));
+               return 1;
+       }
+       while (fgets(from, sizeof(from), stdin) != NULL) {
+               fromlen = strlen(from);
+               if (from[fromlen - 1] == '\n')
+                       from[fromlen - 1] = '\0';
+               if (from[0] == '\0')
+                       continue;
+
+               if (strncmp(from, "add ", 4) == 0) {
+                       r = mdn_checker_add(ctx, from + 4);
+                       if (r != mdn_success) {
+                               fprintf(stderr, "mdn_checker_add: %s\n",
+                                       mdn_result_tostring(r));
+                               conitinue;
+                       }
+               } else {
+                       r = mdn_checker_lookup(ctx, from, &found);
+                       if (r != mdn_success) {
+                               fprintf(stderr, "mdn_checker_check: %s\n",
+                                       mdn_result_tostring(r));
+                               conitinue;
+                       }
+                       if (found != NULL)
+                               fprintf(stderr, "->%s\n", found);
+               }
+       }
+
+       mdn_checker_destroy(ctx);
+       return 0;
+}
+
+#endif /* TEST */
index 0e9a2bfbf602df79a95366b80ebabe8f6b35dd10..32a558a621f0a8ac7f7e77784edcf308a721eda7 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
-static char *rcsid = "$Id: converter.c,v 1.23 2000/11/14 00:13:31 ishisone Exp $";
+static char *rcsid = "$Id: converter.c,v 1.35 2001/04/17 01:35:42 ishisone Exp $";
 #endif
 
 /*
@@ -76,15 +76,24 @@ static char *rcsid = "$Id: converter.c,v 1.23 2000/11/14 00:13:31 ishisone Exp $
 #include <mdn/converter.h>
 #include <mdn/strhash.h>
 #include <mdn/utf8.h>
+#include <mdn/utf6.h>
 #include <mdn/utf5.h>
 #include <mdn/debug.h>
 #include <mdn/race.h>
 #include <mdn/brace.h>
 #include <mdn/lace.h>
+#include <mdn/dude.h>
+#include <mdn/altdude.h>
+#include <mdn/amcacem.h>
+#include <mdn/amcaceo.h>
+#include <mdn/amcacer.h>
 
 #ifndef MDN_UTF8_ENCODING_NAME
 #define MDN_UTF8_ENCODING_NAME "UTF-8"         /* by IANA */
 #endif
+#ifndef MDN_UTF6_ENCODING_NAME
+#define MDN_UTF6_ENCODING_NAME "UTF-6"
+#endif
 #ifndef MDN_UTF5_ENCODING_NAME
 #define MDN_UTF5_ENCODING_NAME "UTF-5"
 #endif
@@ -97,6 +106,21 @@ static char *rcsid = "$Id: converter.c,v 1.23 2000/11/14 00:13:31 ishisone Exp $
 #ifndef MDN_LACE_ENCODING_NAME
 #define MDN_LACE_ENCODING_NAME "LACE"
 #endif
+#ifndef MDN_DUDE_ENCODING_NAME
+#define MDN_DUDE_ENCODING_NAME "DUDE"
+#endif
+#ifndef MDN_ALTDUDE_ENCODING_NAME
+#define MDN_ALTDUDE_ENCODING_NAME "AltDUDE"
+#endif
+#ifndef MDN_AMCACEM_ENCODING_NAME
+#define MDN_AMCACEM_ENCODING_NAME "AMC-ACE-M"
+#endif
+#ifndef MDN_AMCACEO_ENCODING_NAME
+#define MDN_AMCACEO_ENCODING_NAME "AMC-ACE-O"
+#endif
+#ifndef MDN_AMCACER_ENCODING_NAME
+#define MDN_AMCACER_ENCODING_NAME "AMC-ACE-R"
+#endif
 
 #define MAX_RECURSE    20
 
@@ -112,7 +136,8 @@ struct mdn_converter {
        converter_ops_t *ops;
        int flags;
        int opened[2];
-       iconv_t ictx[2];
+       int reference_count;
+       void *private_data;
 };
 
 static mdn_strhash_t encoding_name_hash;
@@ -128,39 +153,52 @@ static void               free_alias_value(void *value);
 static mdn_result_t    roundtrip_check(mdn_converter_t ctx,
                                        mdn_converter_dir_t dir,
                                        const char *from, const char *to);
+
 static mdn_result_t    converter_none_open(mdn_converter_t ctx,
-                                           mdn_converter_dir_t dir);
+                                           mdn_converter_dir_t dir,
+                                           void **privdata);
 static mdn_result_t    converter_none_close(mdn_converter_t ctx,
+                                            void *privdata,
                                             mdn_converter_dir_t dir);
 static mdn_result_t    converter_none_convert(mdn_converter_t ctx,
+                                              void *privdata,
                                               mdn_converter_dir_t dir,
                                               const char *from,
                                               char *to, size_t tolen);
 static mdn_result_t    converter_iconv_open(mdn_converter_t ctx,
-                                            mdn_converter_dir_t dir);
+                                            mdn_converter_dir_t dir,
+                                            void **privdata);
 static mdn_result_t    converter_iconv_close(mdn_converter_t ctx,
+                                             void *privdata,
                                              mdn_converter_dir_t dir);
 static mdn_result_t    converter_iconv_convert(mdn_converter_t ctx,
+                                               void *privdata,
                                                mdn_converter_dir_t dir,
                                                const char *from,
                                                char *to, size_t tolen);
 static mdn_result_t    converter_utf5_open(mdn_converter_t ctx,
-                                           mdn_converter_dir_t dir);
+                                           mdn_converter_dir_t dir,
+                                           void **privdata);
 static mdn_result_t    converter_utf5_close(mdn_converter_t ctx,
+                                            void *privdata,
                                             mdn_converter_dir_t dir);
 static mdn_result_t    converter_utf5_convert(mdn_converter_t ctx,
+                                              void *privdata,
                                               mdn_converter_dir_t dir,
                                               const char *from,
                                               char *to, size_t tolen);
 #ifdef DEBUG
 static mdn_result_t    converter_uescape_open(mdn_converter_t ctx,
-                                           mdn_converter_dir_t dir);
+                                              mdn_converter_dir_t dir,
+                                              void **privdata);
 static mdn_result_t    converter_uescape_close(mdn_converter_t ctx,
-                                            mdn_converter_dir_t dir);
+                                               void *privdata,
+                                               mdn_converter_dir_t dir);
 static mdn_result_t    converter_uescape_convert(mdn_converter_t ctx,
-                                              mdn_converter_dir_t dir,
-                                              const char *from,
-                                              char *to, size_t tolen);
+                                                 void *privdata,
+                                                 mdn_converter_dir_t dir,
+                                                 const char *from,
+                                                 char *to, size_t tolen);
 #endif
 
 static converter_ops_t none_converter_ops = {
@@ -230,6 +268,8 @@ mdn_converter_create(const char *name, mdn_converter_t *ctxp, int flags) {
        ctx->local_encoding_name = (char *)(ctx + 1);
        (void)strcpy(ctx->local_encoding_name, realname);
        ctx->flags = flags;
+       ctx->reference_count = 1;
+       ctx->private_data = NULL;
 
        assert(encoding_name_hash != NULL);
 
@@ -274,7 +314,7 @@ converter_open(mdn_converter_t ctx, mdn_converter_dir_t dir) {
               (dir == mdn_converter_l2u || dir == mdn_converter_u2l));
 
        if (!ctx->opened[dir]) {
-               st = (*ctx->ops->open)(ctx, dir);
+               st = (*ctx->ops->open)(ctx, dir, &(ctx->private_data));
                if (st == mdn_success)
                        ctx->opened[dir] = 1;
        }
@@ -286,10 +326,27 @@ mdn_converter_destroy(mdn_converter_t ctx) {
        assert(ctx != NULL);
 
        TRACE(("mdn_converter_destroy()\n"));
+       TRACE(("mdn_converter_destroy: update reference count (%d->%d)\n",
+           ctx->reference_count, ctx->reference_count - 1));
+
+       ctx->reference_count--;
+       if (ctx->reference_count <= 0) {
+               TRACE(("mdn_converter_destroy: the object is destroyed\n"));
+               (void)converter_close(ctx, mdn_converter_l2u);
+               (void)converter_close(ctx, mdn_converter_u2l);
+               free(ctx);
+       }
+}
 
-       (void)converter_close(ctx, mdn_converter_l2u);
-       (void)converter_close(ctx, mdn_converter_u2l);
-       free(ctx);
+void
+mdn_converter_incrref(mdn_converter_t ctx) {
+       assert(ctx != NULL);
+
+       TRACE(("mdn_converter_incrref()\n"));
+       TRACE(("mdn_converter_incrref: update reference count (%d->%d)\n",
+           ctx->reference_count, ctx->reference_count + 1));
+
+       ctx->reference_count++;
 }
 
 static mdn_result_t
@@ -300,7 +357,7 @@ converter_close(mdn_converter_t ctx, mdn_converter_dir_t dir) {
               (dir == mdn_converter_l2u || dir == mdn_converter_u2l));
 
        if (ctx->opened[dir]) {
-               st = (*ctx->ops->close)(ctx, dir);
+               st = (*ctx->ops->close)(ctx, ctx->private_data, dir);
                if (st == mdn_success)
                        ctx->opened[dir] = 0;
        }
@@ -347,7 +404,7 @@ mdn_converter_convert(mdn_converter_t ctx, mdn_converter_dir_t dir,
                return (mdn_success);
        }
 
-       r = (*ctx->ops->convert)(ctx, dir, from, to, tolen);
+       r = (*ctx->ops->convert)(ctx, ctx->private_data, dir, from, to, tolen);
        if (r == mdn_success && dir == mdn_converter_u2l &&
            (ctx->flags & MDN_CONVERTER_RTCHECK) != 0) {
                return (roundtrip_check(ctx, dir, from, to));
@@ -426,6 +483,54 @@ register_standard_encoding(void) {
        if (r != mdn_success)
                return (r);
 
+       r = mdn_converter_register(MDN_DUDE_ENCODING_NAME,
+                                  mdn__dude_open,
+                                  mdn__dude_close,
+                                  mdn__dude_convert,
+                                  1);
+       if (r != mdn_success)
+               return (r);
+
+       r = mdn_converter_register(MDN_UTF6_ENCODING_NAME,
+                                  mdn__utf6_open,
+                                  mdn__utf6_close,
+                                  mdn__utf6_convert,
+                                  1);
+       if (r != mdn_success)
+               return (r);
+
+       r = mdn_converter_register(MDN_ALTDUDE_ENCODING_NAME,
+                                  mdn__altdude_open,
+                                  mdn__altdude_close,
+                                  mdn__altdude_convert,
+                                  1);
+       if (r != mdn_success)
+               return (r);
+
+       r = mdn_converter_register(MDN_AMCACEM_ENCODING_NAME,
+                                  mdn__amcacem_open,
+                                  mdn__amcacem_close,
+                                  mdn__amcacem_convert,
+                                  1);
+       if (r != mdn_success)
+               return (r);
+
+       r = mdn_converter_register(MDN_AMCACEO_ENCODING_NAME,
+                                  mdn__amcaceo_open,
+                                  mdn__amcaceo_close,
+                                  mdn__amcaceo_convert,
+                                  1);
+       if (r != mdn_success)
+               return (r);
+
+       r = mdn_converter_register(MDN_AMCACER_ENCODING_NAME,
+                                  mdn__amcacer_open,
+                                  mdn__amcacer_close,
+                                  mdn__amcacer_convert,
+                                  1);
+       if (r != mdn_success)
+               return (r);
+
 #ifdef DEBUG
        /* This is convenient for debug.  Not useful for other purposes. */
        r = mdn_converter_register("U-escape",
@@ -628,20 +733,22 @@ roundtrip_check(mdn_converter_t ctx, mdn_converter_dir_t dir,
 
 /* ARGSUSED */
 static mdn_result_t
-converter_none_open(mdn_converter_t ctx, mdn_converter_dir_t dir) {
+converter_none_open(mdn_converter_t ctx, mdn_converter_dir_t dir,
+                   void **privdata) {
        return (mdn_success);
 }
 
 /* ARGSUSED */
 static mdn_result_t
-converter_none_close(mdn_converter_t ctx, mdn_converter_dir_t dir) {
+converter_none_close(mdn_converter_t ctx, void *privdata,
+                    mdn_converter_dir_t dir) {
        return (mdn_success);
 }
 
 static mdn_result_t
-converter_none_convert(mdn_converter_t ctx, mdn_converter_dir_t dir,
-                      const char *from, char *to, size_t tolen)
-{
+converter_none_convert(mdn_converter_t ctx, void *privdata,
+                      mdn_converter_dir_t dir, const char *from, char *to,
+                      size_t tolen) {
        size_t fromlen;
 
        assert(ctx != NULL &&
@@ -668,9 +775,19 @@ converter_none_convert(mdn_converter_t ctx, mdn_converter_dir_t dir,
  */
 
 static mdn_result_t
-converter_iconv_open(mdn_converter_t ctx, mdn_converter_dir_t dir) {
+converter_iconv_open(mdn_converter_t ctx, mdn_converter_dir_t dir,
+                    void **privdata) {
        iconv_t ictx;
 
+       if (*privdata == NULL) {
+               ictx = (iconv_t)(-1);
+               *privdata = malloc(sizeof(iconv_t) * 2);
+               if (*privdata == NULL)
+                       return (mdn_nomemory);
+               *((iconv_t *)*privdata) = (iconv_t)(-1);
+               *((iconv_t *)*privdata + 1) = (iconv_t)(-1);
+       }
+
        if (dir == mdn_converter_l2u) {
                ictx = iconv_open(MDN_UTF8_ENCODING_NAME,
                                  ctx->local_encoding_name);
@@ -678,8 +795,8 @@ converter_iconv_open(mdn_converter_t ctx, mdn_converter_dir_t dir) {
                ictx = iconv_open(ctx->local_encoding_name,
                                  MDN_UTF8_ENCODING_NAME);
        }
-       ctx->ictx[dir] = ictx;
        if (ictx == (iconv_t)(-1)) {
+               free(*privdata);
                switch (errno) {
                case ENOMEM:
                        return (mdn_nomemory);
@@ -690,23 +807,37 @@ converter_iconv_open(mdn_converter_t ctx, mdn_converter_dir_t dir) {
                        return (mdn_failure);
                }
        }
+
+       memcpy((iconv_t *)*privdata + dir, &ictx, sizeof(iconv_t));
+
        return (mdn_success);
 }
 
 static mdn_result_t
-converter_iconv_close(mdn_converter_t ctx, mdn_converter_dir_t dir) {
+converter_iconv_close(mdn_converter_t ctx, void *privdata,
+                     mdn_converter_dir_t dir) {
+       iconv_t *ictxp;
+
        assert(ctx != NULL &&
               (dir == mdn_converter_l2u || dir == mdn_converter_u2l));
 
-       if (ctx->opened[dir])
-               (void)iconv_close(ctx->ictx[dir]);
+       ictxp = (iconv_t *)privdata;
+       if (ictxp[dir] != (iconv_t)(-1))
+               (void)iconv_close(ictxp[dir]);
+       ictxp[dir] = (iconv_t)(-1);
+       if (ictxp[mdn_converter_l2u] == (iconv_t)(-1) &&
+           ictxp[mdn_converter_u2l] == (iconv_t)(-1)) {
+               free(privdata);
+       }
+
        return (mdn_success);
 }
 
 static mdn_result_t
-converter_iconv_convert(mdn_converter_t ctx, mdn_converter_dir_t dir,
-                        const char *from, char *to, size_t tolen)
-{
+converter_iconv_convert(mdn_converter_t ctx, void *privdata,
+                       mdn_converter_dir_t dir, const char *from, char *to,
+                       size_t tolen) {
+       iconv_t ictx;
        char *toorg = to;
        size_t sz;
        size_t fromsz;
@@ -732,8 +863,9 @@ converter_iconv_convert(mdn_converter_t ctx, mdn_converter_dir_t dir,
        /*
         * Reset internal state.
         */
+       ictx = ((iconv_t *)privdata)[dir];
 #if 0
-       (void)iconv(ctx->ictx[dir], (const char **)NULL, (size_t *)NULL, 
+       (void)iconv(ictx, (const char **)NULL, (size_t *)NULL, 
                    (char **)NULL, (size_t *)NULL);
 #else
        /*
@@ -743,13 +875,12 @@ converter_iconv_convert(mdn_converter_t ctx, mdn_converter_dir_t dir,
         */
        fromsz = tosz = 0;
        p = NULL;
-       (void)iconv(ctx->ictx[dir], (const char **)NULL,
-                   &fromsz, &p, &tosz);
+       (void)iconv(ictx, (const char **)NULL, &fromsz, &p, &tosz);
 #endif
 
        fromsz = strlen(from);
        tosz = tolen - 1;       /* reserve space for terminating NUL */
-       sz = iconv(ctx->ictx[dir], &from, &fromsz, &to, &tosz);
+       sz = iconv(ictx, &from, &fromsz, &to, &tosz);
 
        if (sz == (size_t)(-1) || fromsz > 0) {
                switch (errno) {
@@ -777,16 +908,37 @@ converter_iconv_convert(mdn_converter_t ctx, mdn_converter_dir_t dir,
                        return (mdn_failure);
                }
        }
-       *to = '\0';
 
-       /*
-        * For local -> utf-8 conversion, check the validity of the
-        * output string.
-        */
-       if (dir == mdn_converter_l2u && !mdn_utf8_isvalidstring(toorg)) {
-               WARNING(("mdn_converter_convert: "
-                        "output is not a valid UTF-8 string\n"));
-               return (mdn_invalid_encoding);
+       if (dir == mdn_converter_l2u) {
+               /*
+                * For local -> utf-8 conversion, check the validity of the
+                * output string.
+                */
+               *to = '\0';
+               if (!mdn_utf8_isvalidstring(toorg)) {
+                       WARNING(("mdn_converter_convert: "
+                                "output is not a valid UTF-8 string\n"));
+                       return (mdn_invalid_encoding);
+               }
+       } else {
+               /*
+                * For utf-8 -> local conversion, append a sequence of
+                * state reset.
+                */
+               fromsz = 0;
+               sz = iconv(ictx, (const char **)NULL, &fromsz, &to, &tosz);
+               if (sz == (size_t)(-1)) {
+                       switch (errno) {
+                       case EILSEQ:
+                       case EINVAL:
+                               return (mdn_invalid_encoding);
+                       case E2BIG:
+                               return (mdn_buffer_overflow);
+                       default:
+                               return (mdn_failure);
+                       }
+               }
+               *to = '\0';
        }
 
        return (mdn_success);
@@ -798,20 +950,22 @@ converter_iconv_convert(mdn_converter_t ctx, mdn_converter_dir_t dir,
 
 /* ARGSUSED */
 static mdn_result_t
-converter_utf5_open(mdn_converter_t ctx, mdn_converter_dir_t dir) {
+converter_utf5_open(mdn_converter_t ctx, mdn_converter_dir_t dir,
+                   void **privdata) {
        return (mdn_success);
 }
 
 /* ARGSUSED */
 static mdn_result_t
-converter_utf5_close(mdn_converter_t ctx, mdn_converter_dir_t dir) {
+converter_utf5_close(mdn_converter_t ctx, void *privdata, 
+                    mdn_converter_dir_t dir) {
        return (mdn_success);
 }
 
 static mdn_result_t
-converter_utf5_convert(mdn_converter_t ctx, mdn_converter_dir_t dir,
-                       const char *from, char *to, size_t tolen)
-{
+converter_utf5_convert(mdn_converter_t ctx, void *privdata, 
+                      mdn_converter_dir_t dir, const char *from, char *to,
+                      size_t tolen) {
        size_t fromlen = strlen(from);
 
        if (dir == mdn_converter_l2u) {
@@ -881,19 +1035,22 @@ static int       uescape_putwc(char *to, size_t tolen, unsigned long v);
 
 /* ARGSUSED */
 static mdn_result_t
-converter_uescape_open(mdn_converter_t ctx, mdn_converter_dir_t dir) {
+converter_uescape_open(mdn_converter_t ctx, mdn_converter_dir_t dir,
+                      void **privdata) {
        return (mdn_success);
 }
 
 /* ARGSUSED */
 static mdn_result_t
-converter_uescape_close(mdn_converter_t ctx, mdn_converter_dir_t dir) {
+converter_uescape_close(mdn_converter_t ctx, void *privdata,
+                       mdn_converter_dir_t dir) {
        return (mdn_success);
 }
 
 static mdn_result_t
-converter_uescape_convert(mdn_converter_t ctx, mdn_converter_dir_t dir,
-                       const char *from, char *to, size_t tolen)
+converter_uescape_convert(mdn_converter_t ctx, void *privdata,
+                         mdn_converter_dir_t dir, const char *from, char *to,
+                         size_t tolen)
 {
        size_t fromlen = strlen(from);
 
diff --git a/contrib/idn/mdnkit/lib/delimitermap.c b/contrib/idn/mdnkit/lib/delimitermap.c
new file mode 100644 (file)
index 0000000..4f8fa78
--- /dev/null
@@ -0,0 +1,360 @@
+#ifndef lint
+static char *rcsid = "$Id: delimitermap.c,v 1.1 2001/06/09 00:30:15 tale 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+ * Tokyo, 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) Japan Network Information Center.  All rights reserved."
+ * 
+ * 4. Neither the name of JPNIC may 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.
+ * 
+ * 6. Indemnification by Licensee
+ *    Any person or entities using and/or redistributing this Software under
+ *    this License Terms and Conditions shall defend indemnify and hold
+ *    harmless JPNIC from and against any and all judgements damages,
+ *    expenses, settlement liabilities, cost and other liabilities of any
+ *    kind as a result of use and redistribution of this Software or any
+ *    claim, suite, action, litigation or proceeding by any third party
+ *    arising out of or relates to this License Terms and Conditions.
+ * 
+ * 7. Governing Law, Jurisdiction and Venue
+ *    This License Terms and Conditions shall be governed by and and
+ *    construed in accordance with the law of Japan. Any person or entities
+ *    using and/or redistributing this Software under this License Terms and
+ *    Conditions hereby agrees and consent to the personal and exclusive
+ *    jurisdiction and venue of Tokyo District Court of Japan.
+ */
+
+#include <config.h>
+
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <mdn/result.h>
+#include <mdn/assert.h>
+#include <mdn/logmacro.h>
+#include <mdn/delimitermap.h>
+#include <mdn/util.h>
+#include <mdn/debug.h>
+#include <mdn/utf8.h>
+
+/*
+ * Mapper object type.
+ */
+struct mdn_delimitermap {
+       int ndelimiters;
+       int delimiter_size;
+       unsigned long *delimiters;
+       int reference_count;
+};
+
+#define DELIMITERMAP_INITIAL_DELIMITER_SIZE    4
+
+mdn_result_t
+mdn_delimitermap_create(mdn_delimitermap_t *ctxp) {
+       mdn_delimitermap_t ctx = NULL;
+       mdn_result_t r;
+
+       assert(ctxp != NULL);
+       TRACE(("mdn_delimitermap_create()\n"));
+
+       ctx = (mdn_delimitermap_t) malloc(sizeof(struct mdn_delimitermap));
+       if (ctx == NULL) {
+               WARNING(("mdn_mapper_create: malloc failed\n"));
+               r = mdn_nomemory;
+               goto failure;
+       }
+
+       ctx->delimiters = (unsigned long *) malloc(sizeof(unsigned long)
+               * DELIMITERMAP_INITIAL_DELIMITER_SIZE);
+       if (ctx->delimiters == NULL) {
+               WARNING(("mdn_delimitermap_create: malloc failed\n"));
+               r = mdn_nomemory;
+               goto failure;
+       }
+       ctx->ndelimiters = 0;
+       ctx->delimiter_size = DELIMITERMAP_INITIAL_DELIMITER_SIZE;
+       ctx->reference_count = 1;
+       *ctxp = ctx;
+
+       return (mdn_success);
+
+failure:
+       free(ctx);
+       return (r);
+}
+
+void
+mdn_delimitermap_destroy(mdn_delimitermap_t ctx) {
+       assert(ctx != NULL);
+
+       TRACE(("mdn_delimitermap_destroy()\n"));
+       TRACE(("mdn_delimitermap_destroy: update reference count (%d->%d)\n",
+           ctx->reference_count, ctx->reference_count - 1));
+
+       ctx->reference_count--;
+       if (ctx->reference_count <= 0) {
+               TRACE(("mdn_mapper_destroy: the object is destroyed\n"));
+               free(ctx->delimiters);
+               free(ctx);
+       }
+}
+
+void
+mdn_delimitermap_incrref(mdn_delimitermap_t ctx) {
+       assert(ctx != NULL);
+
+       TRACE(("mdn_delimitermap_incrref()\n"));
+       TRACE(("mdn_delimitermap_incrref: update reference count (%d->%d)\n",
+               ctx->reference_count, ctx->reference_count + 1));
+
+       ctx->reference_count++;
+}
+
+mdn_result_t
+mdn_delimitermap_add(mdn_delimitermap_t ctx, unsigned long delimiter) {
+       mdn_result_t r;
+
+       assert(ctx != NULL && ctx->ndelimiters <= ctx->delimiter_size);
+       TRACE(("mdn_delimitermap_add(delimiter=%lX)\n", delimiter));
+
+       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) {
+                       WARNING(("mdn_checker_add: malloc failed\n"));
+                       r = mdn_nomemory;
+                       goto failure;
+               }
+               ctx->delimiters = new_delimiters;
+               ctx->delimiter_size *= 2;
+       }
+
+       ctx->delimiters[ctx->ndelimiters] = delimiter;
+       ctx->ndelimiters++;
+
+       return (mdn_success);
+
+failure:
+       if (ctx != NULL)
+               free(ctx->delimiters);
+       free(ctx);
+       return (r);
+}
+
+mdn_result_t
+mdn_delimitermap_addall(mdn_delimitermap_t ctx, unsigned long *delimiters,
+                       int ndelimiters) {
+       mdn_result_t r;
+       int i;
+
+       assert(ctx != NULL && delimiters != NULL);
+
+       TRACE(("mdn_delimitermap_addall(ndelimiters=%d)\n", ndelimiters));
+
+       for (i = 0; i < ndelimiters; i++) {
+               r = mdn_delimitermap_add(ctx, *delimiters);
+               if (r != mdn_success)
+                       return (r);
+               delimiters++;
+       }
+
+       return (mdn_success);
+}
+
+mdn_result_t
+mdn_delimitermap_map(mdn_delimitermap_t ctx, const char *from, char *to,
+                    size_t tolen) {
+       size_t fromlen;
+       size_t mblen;
+       unsigned long wc;
+       int i, j;
+
+       assert(ctx != NULL && from != NULL && to != NULL);
+
+       TRACE(("mdn_delimitermap_map(from=\"%s\")\n",
+               mdn_debug_xstring(from, 20)));
+
+       fromlen = strlen(from);
+
+       /*
+        * Copy the string if no delimiter is added.
+        */
+       if (ctx->ndelimiters == 0) {
+               if (fromlen + 1 > tolen)
+                       return (mdn_buffer_overflow);
+               memcpy(to, from, fromlen + 1);
+               return (mdn_success);
+       }
+
+       /*
+        * Map.
+        */
+       while (fromlen > 0) {
+               mblen = mdn_utf8_getwc(from, fromlen, &wc);
+               if (mblen == 0)
+                       return (mdn_invalid_encoding);
+
+               for (i = 0; i < ctx->ndelimiters; i++) {
+                       if (ctx->delimiters[i] == wc)
+                               break;
+               }
+               if (i < ctx->ndelimiters) {
+                       if (tolen < 1)
+                               return (mdn_buffer_overflow);
+                       from += mblen;
+                       *to++ = '.';
+                       tolen--;
+               } else {
+                       if (tolen < mblen)
+                               return (mdn_buffer_overflow);
+                       for (j = 0; j < mblen; j++)
+                               *to++ = *from++;
+                       tolen -= mblen;
+               }
+
+               fromlen -= mblen;
+       }
+
+       if (tolen < 1)
+               return (mdn_buffer_overflow);
+       *to = '\0';
+
+       return (mdn_success);
+}
+
+#ifdef TEST
+#include <stdio.h>
+#include <mdn/converter.h>
+
+/*
+ * Test program for this module.
+ *
+ * The test program repeatedly prompt you to input a command.  The
+ * following command is currently recognized.
+ *
+ *    tolen N          set the length of output buffer. (1...1024)
+ *    DOMANNAME         try mapping DOMANNAME.
+ *
+ * Input EOF to exit.
+ */
+int
+main(int ac, char **av) {
+       mdn_delimitermap_t mapper;
+       mdn_converter_t converter;
+       char local[1024], utf8[1024];
+       size_t locallen, utf8len = sizeof(utf8);
+       mdn_result_t r;
+
+       if (ac != 2) {
+               fprintf(stderr, "usage: %s local-encoding-name\n", av[0]);
+               exit(EXIT_FAILURE);
+       }
+
+       mdn_log_setlevel(mdn_log_level_trace);
+       mdn_converter_initialize();
+
+       r = mdn_converter_create(av[1], &converter, 0);
+       if (r != mdn_success) {
+               fprintf(stderr, "mdn_converter_create: %s\n",
+                       mdn_result_tostring(r));
+               return 1;
+       }
+
+       r = mdn_delimitermap_create(&mapper);
+       if (r != mdn_success) {
+               fprintf(stderr, "mdn_delimitermap_create: %s\n",
+                       mdn_result_tostring(r));
+               return 1;
+       }
+
+       r = mdn_delimitermap_add(mapper, 0x3002);
+       if (r != mdn_success) {
+               fprintf(stderr, "mdn_delimitermap_add: %s\n",
+                       mdn_result_tostring(r));
+               return 1;
+       }
+       mdn_delimitermap_fix(mapper);
+
+       while (fgets(local, sizeof(local), stdin) != NULL) {
+               locallen = strlen(local);
+               if (local[locallen - 1] == '\n')
+                       local[locallen - 1] = '\0';
+               if (local[0] == '\0')
+                       continue;
+
+               if (strncmp(local, "tolen ", 6) == 0) {
+                       utf8len = atoi(local + 6);
+               } else {
+                       r = mdn_converter_localtoutf8(converter, local, utf8, 
+                               sizeof(utf8));
+                       if (r != mdn_success) {
+                               fprintf(stderr,
+                                       "mdn_converter_localtoutf8: %s\n",
+                                       mdn_result_tostring(r));
+                               conitinue;
+                       }
+
+                       r = mdn_delimitermap_map(mapper, utf8, utf8, utf8len);
+                       if (r != mdn_success) {
+                               fprintf(stderr, "mdn_delimitermap_map: %s\n",
+                                       mdn_result_tostring(r));
+                               conitinue;
+                       }
+
+                       r = mdn_converter_utf8tolocal(converter, utf8, local,
+                               sizeof(local));
+                       if (r != mdn_success) {
+                               fprintf(stderr,
+                                       "mdn_converter_utf8tolocal: %s\n",
+                                       mdn_result_tostring(r));
+                               conitinue;
+                       }
+
+                       fprintf(stderr, "%s\n", local);
+               }
+       }
+
+       mdn_delimitermap_destroy(mapper);
+       return 0;
+}
+
+#endif /* TEST */
diff --git a/contrib/idn/mdnkit/lib/dude.c b/contrib/idn/mdnkit/lib/dude.c
new file mode 100644 (file)
index 0000000..b6ed0a4
--- /dev/null
@@ -0,0 +1,313 @@
+#ifndef lint
+static char *rcsid = "$Id: dude.c,v 1.1 2001/06/09 00:30:15 tale Exp $";
+#endif
+
+/*
+ * 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+ * Tokyo, 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) Japan Network Information Center.  All rights reserved."
+ * 
+ * 4. Neither the name of JPNIC may 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.
+ * 
+ * 6. Indemnification by Licensee
+ *    Any person or entities using and/or redistributing this Software under
+ *    this License Terms and Conditions shall defend indemnify and hold
+ *    harmless JPNIC from and against any and all judgements damages,
+ *    expenses, settlement liabilities, cost and other liabilities of any
+ *    kind as a result of use and redistribution of this Software or any
+ *    claim, suite, action, litigation or proceeding by any third party
+ *    arising out of or relates to this License Terms and Conditions.
+ * 
+ * 7. Governing Law, Jurisdiction and Venue
+ *    This License Terms and Conditions shall be governed by and and
+ *    construed in accordance with the law of Japan. Any person or entities
+ *    using and/or redistributing this Software under this License Terms and
+ *    Conditions hereby agrees and consent to the personal and exclusive
+ *    jurisdiction and venue of Tokyo District Court of Japan.
+ */
+
+#include <config.h>
+
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <mdn/result.h>
+#include <mdn/assert.h>
+#include <mdn/logmacro.h>
+#include <mdn/converter.h>
+#include <mdn/utf8.h>
+#include <mdn/debug.h>
+#include <mdn/dude.h>
+#include <mdn/ace.h>
+#include <mdn/util.h>
+
+#ifndef MDN_DUDE_PREFIX
+#define MDN_DUDE_PREFIX                "dq--"
+#endif
+
+static unsigned long nibble_mask[] = {
+       0,              /* dummy: this element is never referenced. */
+       0xf,
+       0xff,
+       0xfff,
+       0xffff,
+       0xfffff,
+};
+
+static mdn_result_t    dude_decode(const char *from, size_t fromlen,
+                                   char *to, size_t tolen);
+static mdn_result_t    dude_encode(const char *from, size_t fromlen,
+                                   char *to, size_t tolen);
+static int             get_nibblelength(unsigned long v);
+static int             dude_getwc(const char *s, size_t len,
+                                  unsigned long *vp);
+static int             dude_putwc(char *s, size_t len, unsigned long v,
+                                  int w);
+
+static mdn__ace_t dude_ctx = {
+       mdn__ace_prefix,
+       MDN_DUDE_PREFIX,
+       dude_encode,
+       dude_decode,
+};
+
+/* ARGSUSED */
+mdn_result_t
+mdn__dude_open(mdn_converter_t ctx, mdn_converter_dir_t dir, void **privdata) {
+       return (mdn_success);
+}
+
+/* ARGSUSED */
+mdn_result_t
+mdn__dude_close(mdn_converter_t ctx, void *privdata, mdn_converter_dir_t dir) {
+       return (mdn_success);
+}
+
+mdn_result_t
+mdn__dude_convert(mdn_converter_t ctx, void *privdata, mdn_converter_dir_t dir,
+                 const char *from, char *to, size_t tolen)
+{
+       mdn_result_t r;
+
+       assert(ctx != NULL &&
+              (dir == mdn_converter_l2u || dir == mdn_converter_u2l));
+
+       TRACE(("mdn__dude_convert(dir=%s,from=\"%s\")\n",
+              dir == mdn_converter_l2u ? "l2u" : "u2l",
+              mdn_debug_xstring(from, 20)));
+
+       r = mdn__ace_convert(&dude_ctx, dir, from, to, tolen);
+       if (r != mdn_success)
+               return (r);
+
+       DUMP(("mdn__dude_convert: \"%s\"\n", mdn_debug_xstring(to, 70)));
+
+       return (r);
+}
+
+static mdn_result_t
+dude_decode(const char *from, size_t fromlen, char *to, size_t tolen) {
+       size_t len;
+       unsigned long prev, v, mask;
+
+       prev = 0;
+       while (fromlen > 0) {
+               if (from[0] == '-') {
+                       v = '-';
+                       from++;
+                       fromlen--;
+               } else {
+                       len = dude_getwc(from, fromlen, &v);
+                       if (len == 0)
+                               return (mdn_invalid_encoding);
+                       from += len;
+                       fromlen -= len;
+                       mask = nibble_mask[len];
+                       v = (prev & ~mask) | v;
+
+                       /*
+                        * Perform extra sanity checks.
+                        */
+                       if (v == '-' || get_nibblelength(prev ^ v) != len)
+                               return (mdn_invalid_encoding);
+
+                       prev = v;
+               }
+               len = mdn_utf8_putwc(to, tolen, v);
+               if (len == 0)
+                       return (mdn_buffer_overflow);
+               to += len;
+               tolen -= len;
+       }
+
+       /*
+        * Terminate with NUL.
+        */
+       if (tolen <= 0)
+               return (mdn_buffer_overflow);
+
+       *to = '\0';
+       return (mdn_success);
+}
+
+static mdn_result_t
+dude_encode(const char *from, size_t fromlen, char *to, size_t tolen) {
+       size_t len;
+       unsigned long prev, c, v, mask;
+
+       prev = 0;
+       while (fromlen > 0) {
+               len = mdn_utf8_getwc(from, fromlen, &c);
+               from += len;
+               fromlen -= len;
+               if (len == 0 || c >= 0x100000)
+                       return (mdn_invalid_encoding);
+               if (c == '-') {
+                       /*
+                        * Hyphens are treated specially.
+                        */
+                       if (tolen < 1)
+                               return (mdn_buffer_overflow);
+                       *to++ = '-';
+                       tolen--;
+               } else {
+                       int nlen = get_nibblelength(prev ^ c);
+                       mask = nibble_mask[nlen];
+                       v = c & mask;
+                       prev = c;
+                       len = dude_putwc(to, tolen, v, nlen);
+                       if (len == 0)
+                               return (mdn_buffer_overflow);
+                       to += len;
+                       tolen -= len;
+               }
+       }
+
+       /*
+        * Terminate with NUL.
+        */
+       if (tolen <= 0)
+               return (mdn_buffer_overflow);
+
+       *to = '\0';
+
+       return (mdn_success);
+}
+
+static int
+get_nibblelength(unsigned long v) {
+       assert(v < 0x100000);
+
+       if (v <= 0xf)
+               return 1;
+       else if (v <= 0xff)
+               return 2;
+       else if (v <= 0xfff)
+               return 3;
+       else if (v <= 0xffff)
+               return 4;
+       else
+               return 5;
+}
+
+static int
+dude_getwc(const char *s, size_t len, unsigned long *vp) {
+       size_t orglen = len;
+       unsigned long v = 0;
+       int c;
+
+       if (len < 1)
+               return (0);
+
+       c = *s++;
+       len--;
+
+       if ('G' <= c && c <= 'V')
+               v = c - 'G';
+       else if ('g' <= c && c <= 'v')
+               v = c - 'g';
+       else    /* invalid character */
+               return (0);
+
+       while (len > 0) {
+               c = *s++;
+               if ('0' <= c && c <= '9')
+                       c = c - '0';
+               else if ('A' <= c && c <= 'F')
+                       c = c - 'A' + 10;
+               else if ('a' <= c && c <= 'f')
+                       c = c - 'a' + 10;
+               else
+                       break;
+               v = (v << 4) + c;
+               len--;
+       }
+       len = orglen - len;
+
+       if (len > 5)
+               return (0);
+
+       *vp = v;
+       return (len);
+}
+
+static int
+dude_putwc(char *s, size_t len, unsigned long v, int w) {
+       int i;
+
+       assert(v < 0x100000);
+       assert(w > 0 && w < 6 && v <= nibble_mask[w]);
+
+       if (len < w)
+               return (0);
+
+       for (i = w - 1; i >= 0; i--) {
+               int x = v & 0xf;
+
+               if (i == 0)
+                       s[i] = 'g' + x;
+               else if (x < 10)
+                       s[i] = '0' + x;
+               else
+                       s[i] = 'a' + x - 10;
+               v >>= 4;
+       }
+
+       return (w);
+}
diff --git a/contrib/idn/mdnkit/lib/filechecker.c b/contrib/idn/mdnkit/lib/filechecker.c
new file mode 100644 (file)
index 0000000..e960c4e
--- /dev/null
@@ -0,0 +1,324 @@
+#ifndef lint
+static char *rcsid = "$Id: filechecker.c,v 1.1 2001/06/09 00:30:15 tale 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+ * Tokyo, 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) Japan Network Information Center.  All rights reserved."
+ * 
+ * 4. Neither the name of JPNIC may 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.
+ * 
+ * 6. Indemnification by Licensee
+ *    Any person or entities using and/or redistributing this Software under
+ *    this License Terms and Conditions shall defend indemnify and hold
+ *    harmless JPNIC from and against any and all judgements damages,
+ *    expenses, settlement liabilities, cost and other liabilities of any
+ *    kind as a result of use and redistribution of this Software or any
+ *    claim, suite, action, litigation or proceeding by any third party
+ *    arising out of or relates to this License Terms and Conditions.
+ * 
+ * 7. Governing Law, Jurisdiction and Venue
+ *    This License Terms and Conditions shall be governed by and and
+ *    construed in accordance with the law of Japan. Any person or entities
+ *    using and/or redistributing this Software under this License Terms and
+ *    Conditions hereby agrees and consent to the personal and exclusive
+ *    jurisdiction and venue of Tokyo District Court of Japan.
+ */
+
+#include <config.h>
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+
+#include <mdn/result.h>
+#include <mdn/assert.h>
+#include <mdn/log.h>
+#include <mdn/logmacro.h>
+#include <mdn/utf8.h>
+#include <mdn/ucsset.h>
+#include <mdn/filechecker.h>
+
+#define SUPPORT_VERSIONING
+
+struct mdn__filechecker {
+       mdn_ucsset_t set;
+};
+
+static mdn_result_t    read_file(const char *file, FILE *fp,
+                                 mdn_ucsset_t set);
+static int             get_range(char *s, unsigned long *ucs1,
+                                 unsigned long *ucs2);
+static char            *get_ucs(char *p, unsigned long *vp);
+
+
+mdn_result_t
+mdn__filechecker_create(const char *file, mdn__filechecker_t *ctxp) {
+       FILE *fp;
+       mdn__filechecker_t ctx;
+       mdn_result_t r;
+
+       assert(file != NULL && ctxp != NULL);
+
+       TRACE(("mdn__filechecker_create(file=\"%-.100s\")\n", file));
+
+       if ((fp = fopen(file, "r")) == NULL) {
+               WARNING(("mdn__filechecker_create: cannot open %-.100s\n",
+                        file));
+               return (mdn_nofile);
+       }
+
+       if ((ctx = malloc(sizeof(struct mdn__filechecker))) == NULL)
+               return (mdn_nomemory);
+
+       if ((r = mdn_ucsset_create(&ctx->set)) != mdn_success) {
+               free(ctx);
+               return (r);
+       }
+
+       r = read_file(file, fp, ctx->set);
+       fclose(fp);
+
+       if (r == mdn_success) {
+               mdn_ucsset_fix(ctx->set);
+               *ctxp = ctx;
+       } else {
+               mdn_ucsset_destroy(ctx->set);
+               free(ctx);
+       }
+       return (r);
+}
+
+void
+mdn__filechecker_destroy(mdn__filechecker_t ctx) {
+       assert(ctx != NULL);
+
+       TRACE(("mdn__filechecker_destroy()\n"));
+
+       mdn_ucsset_destroy(ctx->set);
+       free(ctx);
+}
+
+mdn_result_t
+mdn__filechecker_lookup(mdn__filechecker_t ctx, const char *str,
+                       const char **found)
+{
+       mdn_result_t r = mdn_success;
+       unsigned long v;
+       size_t len = strlen(str);
+
+       assert(ctx != NULL && str != NULL);
+
+       while (len > 0) {
+               int w;
+               int exists;
+
+               if ((w = mdn_utf8_getwc(str, len, &v)) == 0)
+                       return (mdn_invalid_encoding);
+
+               r = mdn_ucsset_lookup(ctx->set, v, &exists);
+
+               if (r != mdn_success) {
+                       return (r);
+               } else if (exists) {
+                       /* Found. */
+                       *found = str;
+                       return (mdn_success);
+               }
+
+               str += w;
+               len -= w;
+       }
+       *found = NULL;
+       return (mdn_success);
+}
+
+static mdn_result_t
+read_file(const char *file, FILE *fp, mdn_ucsset_t set) {
+       char line[256];
+       mdn_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 (mdn_invalid_syntax);
+               }
+               if ((r = mdn_ucsset_addrange(set, ucs1, ucs2)) != mdn_success)
+                       return (r);
+       }
+       return (mdn_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(("mdn__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(("mdn__filechecker_create: UCS code point expected\n"));
+               return (NULL);
+       }
+       p = end;
+
+       /* Skip trailing space */
+       while (isspace((unsigned char)*p))
+               p++;
+       return p;
+}
+
+mdn_result_t
+mdn__filechecker_createproc(const char *parameter, void **ctxp) {
+       return mdn__filechecker_create(parameter, (mdn__filechecker_t *)ctxp);
+}
+
+void
+mdn__filechecker_destroyproc(void *ctxp) {
+       mdn__filechecker_destroy((mdn__filechecker_t)ctxp);
+}
+
+mdn_result_t
+mdn__filechecker_lookupproc(void *ctx, const char *str, const char **found) {
+       return mdn__filechecker_lookup((mdn__filechecker_t)ctx, str, found);
+}
+
+
+#ifdef TEST
+int
+main(int ac, char **av) {
+       mdn__filechecker_t chk;
+       mdn_result_t r;
+       char line[1024];
+       char *found;
+       int lineno = 0;
+
+       if (ac < 2) {
+               fprintf(stderr, "Usage: %s file\n", av[0]);
+               return 1;
+       }
+       r = mdn__filechecker_create(av[1], &chk);
+       if (r != mdn_success) {
+               fprintf(stderr, "mdn__filechecker_create: %s\n",
+                       mdn_result_tostring(r));
+               return 1;
+       }
+       while (fgets(line, sizeof(line), stdin) != NULL) {
+               int valid;
+               size_t len = strlen(line);
+
+               lineno++;
+               /* since \n is likely to be prohibited, remove it beforehand */
+               if (line[len - 1] == '\n')
+                       line[len - 1] = '\0';
+
+               r = mdn__filechecker_check(priv, line, &found);
+               if (r != mdn_success) {
+                       fprintf(stderr, "error at line %d: %s\n",
+                               lineno, mdn_result_tostring(r));
+                       return 1;
+               }
+               if (found != NULL) {
+                       printf("line %d: invalid\n", lineno);
+               }
+       }
+       return 0;
+}
+#endif /* TEST */
diff --git a/contrib/idn/mdnkit/lib/filemapper.c b/contrib/idn/mdnkit/lib/filemapper.c
new file mode 100644 (file)
index 0000000..5669e8b
--- /dev/null
@@ -0,0 +1,404 @@
+#ifndef lint
+static char *rcsid = "$Id: filemapper.c,v 1.1 2001/06/09 00:30:15 tale 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+ * Tokyo, 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) Japan Network Information Center.  All rights reserved."
+ * 
+ * 4. Neither the name of JPNIC may 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.
+ * 
+ * 6. Indemnification by Licensee
+ *    Any person or entities using and/or redistributing this Software under
+ *    this License Terms and Conditions shall defend indemnify and hold
+ *    harmless JPNIC from and against any and all judgements damages,
+ *    expenses, settlement liabilities, cost and other liabilities of any
+ *    kind as a result of use and redistribution of this Software or any
+ *    claim, suite, action, litigation or proceeding by any third party
+ *    arising out of or relates to this License Terms and Conditions.
+ * 
+ * 7. Governing Law, Jurisdiction and Venue
+ *    This License Terms and Conditions shall be governed by and and
+ *    construed in accordance with the law of Japan. Any person or entities
+ *    using and/or redistributing this Software under this License Terms and
+ *    Conditions hereby agrees and consent to the personal and exclusive
+ *    jurisdiction and venue of Tokyo District Court of Japan.
+ */
+
+#include <config.h>
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+
+#include <mdn/result.h>
+#include <mdn/assert.h>
+#include <mdn/log.h>
+#include <mdn/logmacro.h>
+#include <mdn/debug.h>
+#include <mdn/utf8.h>
+#include <mdn/ucsmap.h>
+#include <mdn/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 mdn__filemapper {
+       mdn_ucsmap_t map;
+};
+
+static void            ucsbuf_init(ucsbuf_t *b);
+static mdn_result_t    ucsbuf_grow(ucsbuf_t *b);
+static mdn_result_t    ucsbuf_append(ucsbuf_t *b, unsigned long v);
+static void            ucsbuf_free(ucsbuf_t *b);
+static mdn_result_t    read_file(const char *file, FILE *fp,
+                                 mdn_ucsmap_t map);
+static mdn_result_t    get_map(char *p, ucsbuf_t *b);
+static char            *get_ucs(char *p, unsigned long *vp);
+
+
+mdn_result_t
+mdn__filemapper_create(const char *file, mdn__filemapper_t *ctxp) {
+       FILE *fp;
+       mdn__filemapper_t ctx;
+       mdn_result_t r;
+
+       assert(file != NULL && ctxp != NULL);
+
+       TRACE(("mdn__filemapper_create(file=\"%-.100s\")\n", file));
+
+       if ((fp = fopen(file, "r")) == NULL) {
+               WARNING(("mdn__filemapper_create: cannot open %-.100s\n",
+                        file));
+               return (mdn_nofile);
+       }
+       if ((ctx = malloc(sizeof(struct mdn__filemapper))) == NULL)
+               return (mdn_nomemory);
+
+       if ((r = mdn_ucsmap_create(&ctx->map)) != mdn_success) {
+               free(ctx);
+               return (r);
+       }
+
+       r = read_file(file, fp, ctx->map);
+       fclose(fp);
+
+       if (r == mdn_success) {
+               mdn_ucsmap_fix(ctx->map);
+               *ctxp = ctx;
+       } else {
+               mdn_ucsmap_destroy(ctx->map);
+               free(ctx);
+       }
+       return (r);
+}
+
+void
+mdn__filemapper_destroy(mdn__filemapper_t ctx) {
+
+       assert(ctx != NULL);
+
+       TRACE(("mdn__filemapper_destroy()\n"));
+
+       mdn_ucsmap_destroy(ctx->map);
+       free(ctx);
+}
+
+mdn_result_t
+mdn__filemapper_map(mdn__filemapper_t ctx, const char *from,
+                   char *to, size_t tolen)
+{
+       mdn_result_t r = mdn_success;
+       unsigned long v;
+       ucsbuf_t ub;
+       size_t fromlen = strlen(from);
+
+       assert(ctx != NULL && from != NULL && to != NULL);
+
+       TRACE(("mdn__filemapper_map(from=\"%s\")\n",
+              mdn_debug_xstring(from, 40)));
+
+       /* Initialize temporary buffer. */
+       ucsbuf_init(&ub);
+
+       while (fromlen > 0) {
+               int i;
+               int w;
+
+               /* Get one character. */
+               if ((w = mdn_utf8_getwc(from, fromlen, &v)) == 0) {
+                       r = mdn_invalid_encoding;
+                       break;
+               }
+               from += w;
+               fromlen -= w;
+
+       again:
+               /* Try mapping. */
+               r = mdn_ucsmap_map(ctx->map, v, ub.ucs, ub.size, &ub.len);
+               switch (r) {
+               case mdn_buffer_overflow:
+                       /* Temporary buffer too small.  Enlarge and retry. */
+                       if ((r = ucsbuf_grow(&ub)) != mdn_success)
+                               break;
+                       goto again;
+               case mdn_nomapping:
+                       /* There is no mapping. */
+                       r = mdn_success;
+                       /* fallthrough */
+               case mdn_success:
+                       for (i = 0; i < ub.len; i++) {
+                               w = mdn_utf8_putwc(to, tolen, ub.ucs[i]);
+                               if (w == 0) {
+                                       r = mdn_buffer_overflow;
+                                       break;
+                               }
+                               to += w;
+                               tolen -= w;
+                       }
+                       break;
+               default:
+                       goto ret;
+               }
+       }
+
+ ret:
+       ucsbuf_free(&ub);
+
+       if (r == mdn_success) {
+               /* Terminate with NUL. */
+               if (tolen == 0)
+                       return (mdn_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 mdn_result_t
+ucsbuf_grow(ucsbuf_t *b) {
+       if (b->ucs == b->local)
+               b->ucs = NULL;
+       b->size *= 2;
+       b->ucs = realloc(b->ucs, sizeof(unsigned long) * b->size);
+       if (b->ucs == NULL)
+               return (mdn_nomemory);
+       return (mdn_success);
+}
+
+static mdn_result_t
+ucsbuf_append(ucsbuf_t *b, unsigned long v) {
+       mdn_result_t r;
+
+       if (b->len + 1 > b->size) {
+               r = ucsbuf_grow(b);
+               if (r != mdn_success)
+                       return (r);
+       }
+       b->ucs[b->len++] = v;
+       return (mdn_success);
+}
+
+static void
+ucsbuf_free(ucsbuf_t *b) {
+       if (b->ucs != b->local)
+               free(b->ucs);
+}
+
+static mdn_result_t
+read_file(const char *file, FILE *fp, mdn_ucsmap_t map) {
+       char line[1024];
+       ucsbuf_t ub;
+       mdn_result_t r = mdn_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 mdn_success:
+                       r = mdn_ucsmap_add(map, ub.ucs[0],
+                                          &ub.ucs[1], ub.len - 1);
+                       break;
+               case mdn_buffer_overflow:
+                       if ((r = ucsbuf_grow(&ub)) != mdn_success)
+                               break;
+                       goto again;
+               case mdn_invalid_syntax:
+                       WARNING(("syntax error in file \"%-.100s\" line %d: "
+                                "%-.100s", file, lineno, line));
+                       /* fall through */
+               default:
+                       return (r);
+               }
+       }
+       ucsbuf_free(&ub);
+       return (r);
+}
+
+static mdn_result_t
+get_map(char *p, ucsbuf_t *b) {
+       unsigned long v;
+       mdn_result_t r = mdn_success;
+
+       for (;;) {
+               if ((p = get_ucs(p, &v)) == NULL)
+                       return (mdn_invalid_syntax);
+               if ((r = ucsbuf_append(b, v)) != mdn_success)
+                       return (r);
+               if (b->len == 1) {
+                       if (*p != ';')
+                               return (mdn_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(("mdn__filemapper_create: UCS code point expected\n"));
+               return (NULL);
+       }
+       p = end;
+
+       /* Skip trailing space */
+       while (isspace((unsigned char)*p))
+               p++;
+       return p;
+}
+
+mdn_result_t
+mdn__filemapper_createproc(const char *parameter, void **ctxp) {
+       return mdn__filemapper_create(parameter, (mdn__filemapper_t *)ctxp);
+}
+
+void
+mdn__filemapper_destroyproc(void *ctxp) {
+       mdn__filemapper_destroy((mdn__filemapper_t)ctxp);
+}
+
+mdn_result_t
+mdn__filemapper_mapproc(void *ctx, const char *from, char *to, size_t tolen) {
+       return mdn__filemapper_map((mdn__filemapper_t)ctx, from, to, tolen);
+}
+
+
+#ifdef TEST
+int
+main(int ac, char **av) {
+       mdn__filemapper_t ctx;
+       mdn_result_t r;
+       char line[1024], mapped[1024];
+       int lineno = 0;
+
+       if (ac == 1) {
+               while (fgets(line, sizeof(line), stdin) != NULL) {
+                       lineno++;
+                       fputs(line, stdout);
+               }
+       } else {
+               r = mdn__filemapper_create(av[1], &ctx);
+               if (r != mdn_success) {
+                       fprintf(stderr, "mdn__filemapper_create: %s\n",
+                               mdn_result_tostring(r));
+                       return 1;
+               }
+               while (fgets(line, sizeof(line), stdin) != NULL) {
+                       lineno++;
+                       r = mdn__filemapper_map(ctx, line, mapped,
+                                               sizeof(mapped));
+                       if (r != mdn_success) {
+                               fprintf(stderr, "error at line %d: %s\n",
+                                       lineno, mdn_result_tostring(r));
+                               return 1;
+                       }
+                       fputs(mapped, stdout);
+               }
+       }
+       return 0;
+}
+#endif /* TEST */
index 9d643a253247bf655819935cdd7023dd76cc9435..8562e87520f2eaa99bee0cf447f80f35db52d6ce 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
-static char *rcsid = "$Id: lace.c,v 1.4 2000/11/22 01:52:18 ishisone Exp $";
+static char *rcsid = "$Id: lace.c,v 1.11 2001/03/28 06:37:24 m-kasahr Exp $";
 #endif
 
 /*
@@ -73,24 +73,16 @@ static char *rcsid = "$Id: lace.c,v 1.4 2000/11/22 01:52:18 ishisone Exp $";
 #include <mdn/utf8.h>
 #include <mdn/debug.h>
 #include <mdn/lace.h>
+#include <mdn/ace.h>
 #include <mdn/util.h>
 
-#ifdef DEBUG
-/* Be paranoid. */
-#define PARANOID
-#endif
-
 #ifndef MDN_LACE_PREFIX
-#define MDN_LACE_PREFIX                "bq--"
+#define MDN_LACE_PREFIX                "lq--"
 #endif
-#define LACE_PREFIX_LEN                (strlen(MDN_LACE_PREFIX))
 
+#define LACE_MAX_COMPRESS_LEN  254             /* max run length */
 #define LACE_BUF_SIZE          128             /* more than enough */
 
-static mdn_result_t    lace_l2u(const char *from, const char *end,
-                                char *to, size_t tolen, size_t *clenp);
-static mdn_result_t    lace_u2l(const char *from, const char *end,
-                                char *to, size_t tolen, size_t *clenp);
 static mdn_result_t    lace_decode(const char *from, size_t fromlen,
                                    char *to, size_t tolen);
 static mdn_result_t    lace_decode_utf16(const char *from, size_t fromlen,
@@ -102,23 +94,30 @@ static mdn_result_t        lace_encode_utf16(const unsigned short *p,
                                          int compress);
 static int             is_compress_effective(unsigned short *p, size_t len);
 
+static mdn__ace_t lace_ctx = {
+       mdn__ace_prefix,
+       MDN_LACE_PREFIX,
+       lace_encode,
+       lace_decode,
+};
+
 /* ARGSUSED */
 mdn_result_t
-mdn__lace_open(mdn_converter_t ctx, mdn_converter_dir_t dir) {
+mdn__lace_open(mdn_converter_t ctx, mdn_converter_dir_t dir, void **privdata) {
        return (mdn_success);
 }
 
 /* ARGSUSED */
 mdn_result_t
-mdn__lace_close(mdn_converter_t ctx, mdn_converter_dir_t dir) {
+mdn__lace_close(mdn_converter_t ctx, void *privdata, mdn_converter_dir_t dir) {
        return (mdn_success);
 }
 
 mdn_result_t
-mdn__lace_convert(mdn_converter_t ctx, mdn_converter_dir_t dir,
-                   const char *from, char *toorg, size_t tolen)
+mdn__lace_convert(mdn_converter_t ctx, void *privdata, mdn_converter_dir_t dir,
+                 const char *from, char *to, size_t tolen)
 {
-       char *to = toorg;
+       mdn_result_t r;
 
        assert(ctx != NULL &&
               (dir == mdn_converter_l2u || dir == mdn_converter_u2l));
@@ -127,128 +126,13 @@ mdn__lace_convert(mdn_converter_t ctx, mdn_converter_dir_t dir,
               dir == mdn_converter_l2u ? "l2u" : "u2l",
               mdn_debug_xstring(from, 20)));
 
-       for (;;) {
-               const char *end;
-               size_t convlen;
-               mdn_result_t r;
-
-               /*
-                * Find the end of this component (label).
-                */
-               if ((end = strchr(from, '.')) == NULL)
-                       end = from + strlen(from);
-
-               /*
-                * Convert it.
-                */
-               if (dir == mdn_converter_l2u)
-                       r = lace_l2u(from, end, to, tolen, &convlen);
-               else
-                       r = lace_u2l(from, end, to, tolen, &convlen);
-               if (r != mdn_success)
-                       return (r);
-
-               /*
-                * Copy '.' or NUL.
-                */
-               if (tolen <= convlen)
-                       return (mdn_buffer_overflow);
-
-               to += convlen;
-               *to++ = *end;
-               tolen -= convlen + 1;
-
-               if (*end == '\0')
-                       break;
-
-               from = end + 1;
-       }
-
-       DUMP(("mdn__lace_convert: \"%s\"\n", mdn_debug_xstring(toorg, 70)));
-
-       return (mdn_success);
-}
-
-static mdn_result_t
-lace_l2u(const char *from, const char *end,
-        char *to, size_t tolen, size_t *clenp)
-{
-       size_t len = end - from;
-       size_t prefix_len = LACE_PREFIX_LEN;
-
-       if (len >= prefix_len &&
-           mdn_util_casematch(from, MDN_LACE_PREFIX, prefix_len)) {
-               /*
-                * LACE encoding prefix found.
-                */
-               mdn_result_t r;
-
-               r = lace_decode(from + prefix_len,
-                               len - prefix_len, to, tolen);
-               if (r == mdn_invalid_encoding)
-                       goto copy;
-               else if (r != mdn_success)
-                       return (r);
-
-               len = strlen(to);
-       } else {
-               /*
-                * Not LACE encoded.  Copy verbatim.
-                */
-       copy:
-               if (mdn_util_domainspan(from, end) < end) {
-                       /* invalid character found */
-                       return (mdn_invalid_encoding);
-               }
-
-               if (tolen < len)
-                       return (mdn_buffer_overflow);
-
-               (void)memcpy(to, from, len);
-       }
-       *clenp = len;
-       return (mdn_success);
-}
-
-static mdn_result_t
-lace_u2l(const char *from, const char *end,
-          char *to, size_t tolen, size_t *clenp) {
-       size_t len = end - from;
-       size_t prefix_len = LACE_PREFIX_LEN;
-
-       /*
-        * See if encoding is necessary.
-        */
-       if (mdn_util_domainspan(from, end) < end) {
-               /*
-                * Conversion is necessary.
-                */
-               mdn_result_t r;
-
-               /* Set prefix. */
-               if (tolen < prefix_len)
-                       return (mdn_buffer_overflow);
-               (void)memcpy(to, MDN_LACE_PREFIX, prefix_len);
-               to += prefix_len;
-               tolen -= prefix_len;
-
-               r = lace_encode(from, len, to, tolen);
-               if (r != mdn_success)
-                       return (r);
+       r = mdn__ace_convert(&lace_ctx, dir, from, to, tolen);
+       if (r != mdn_success)
+               return (r);
 
-               len = prefix_len + strlen(to);
-       } else {
-               /*
-                * Conversion is NOT necessary.
-                * Copy verbatim.
-                */
-               if (tolen < len)
-                       return (mdn_buffer_overflow);
+       DUMP(("mdn__lace_convert: \"%s\"\n", mdn_debug_xstring(to, 70)));
 
-               (void)memcpy(to, from, len);
-       }
-       *clenp = len;
-       return (mdn_success);
+       return (r);
 }
 
 static mdn_result_t
@@ -261,8 +145,8 @@ lace_decode(const char *from, size_t fromlen, char *to, size_t tolen) {
        /*
         * Allocate sufficient buffer.
         */
-       if (fromlen > LACE_BUF_SIZE) {
-               if ((buf = malloc(sizeof(*buf) * fromlen)) == NULL)
+       if (fromlen + 1 > LACE_BUF_SIZE) {
+               if ((buf = malloc(sizeof(*buf) * (fromlen + 1))) == NULL)
                        return (mdn_nomemory);
        } else {
                /* Use local buffer. */
@@ -291,12 +175,21 @@ lace_decode(const char *from, size_t fromlen, char *to, size_t tolen) {
                r = mdn_buffer_overflow;
                goto ret;
        }
+       *(to + reslen) = '\0';
 
-       to += reslen;
-       *to = '\0';
-       tolen -= reslen;
-
-       r = mdn_success;
+       /*
+        * Encode the result, and compare the result with `from', in
+        * order to test whether an input string is encoded correctly.
+        * If `from' was encoded with wrong compression mode, we return
+        * `mdn_invalid_encoding'.
+        */
+       r = lace_encode(to, reslen, (char *)buf, fromlen + 1);
+       if (r != mdn_success)
+               goto ret;
+       if (!mdn_util_casematch((char *)buf, from, fromlen)) {
+               r = mdn_invalid_encoding;
+               goto ret;
+       }
 
 ret:
        if (buf != local_buf)
@@ -340,18 +233,19 @@ lace_decode_utf16(const char *from, size_t fromlen,
                        bitlen -= 8;
                }
        }
-#ifdef PARANOID
-       /* Check if the padding bits are all zero. */
-       if (bitlen > 0 && (bitbuf & ((1 << bitlen) - 1)) != 0) {
-               WARNING(("mdn__lace_convert: non-zero padding\n"));
-               return (mdn_invalid_encoding);
-       }
-#endif
+
        len = p - buf;
 
        if (len == 0)
                return (mdn_invalid_encoding);
 
+       /*
+        * The number of unused bits MUST be 4 or less, and all the
+        * bits MUST be zero.
+        */
+       if (bitlen >= 5 || (bitbuf & ((1 << bitlen) - 1)) != 0)
+               return (mdn_invalid_encoding);
+
        /*
         * Now 'buf' holds the decoded bytes.  Rebuild the
         * original UTF-16 string.
@@ -368,16 +262,6 @@ lace_decode_utf16(const char *from, size_t fromlen,
                for (p = buf + 1, q = buf; len > 0; p += 2, q++, len -= 2) {
                        *q = (p[0] << 8) | p[1];
                }
-#ifdef PARANOID
-               if (is_compress_effective(buf, q - buf)) {
-                       /*
-                        * This string must have been compressed.
-                        */
-                       WARNING(("mdn__lace_convert: decoded string is not "
-                                "compressed, though it should be.\n"));
-                       return (mdn_invalid_encoding);
-               }
-#endif
        } else {
                /*
                 * Compressed.
@@ -391,6 +275,9 @@ lace_decode_utf16(const char *from, size_t fromlen,
                                        return (mdn_invalid_encoding);
                                /* Get COUNT and HIGH. */
                                count = p[0];
+                               if (count == 0 ||
+                                   count > LACE_MAX_COMPRESS_LEN)
+                                       return (mdn_invalid_encoding);
                                high = p[1] << 8;
                                p += 2;
                                len -= 2;
@@ -400,16 +287,6 @@ lace_decode_utf16(const char *from, size_t fromlen,
                }
                if (count != 0)
                        return (mdn_invalid_encoding);
-#ifdef PARANOID
-               if (!is_compress_effective(buf, q - buf)) {
-                       /*
-                        * This string must not have been compressed.
-                        */
-                       WARNING(("mdn__lace_convert: decoded string is "
-                                "compressed, though it shouldn't.\n"));
-                       return (mdn_invalid_encoding);
-               }
-#endif
        }
 
        *lenp = q - buf;
@@ -464,7 +341,7 @@ lace_encode_utf16(const unsigned short *p, size_t len,
 {
        unsigned long bitbuf = 0;       /* bit stream buffer */
        int bitlen = 0;                 /* # of bits in 'bitbuf' */
-       int compress_count = 0;
+       int count = 0;
        int i, j;
 
        if (!compress) {
@@ -485,27 +362,28 @@ lace_encode_utf16(const unsigned short *p, size_t len,
                        bitbuf <<= 5 - (bitlen % 5);    /* padding with zero */
                        bitlen += 5 - (bitlen % 5);
                } else if (compress) {
-                       if (compress_count == 0) {
+                       if (count == 0) {
                                /*
                                 * Get the number of consecutive characters
                                 * with the same high byte.
                                 */
                                unsigned short high = p[i] & 0xff00;
 
-                               compress_count = 1;
-                               for (j = i + 1; j < len; j++) {
+                               count = 1;
+                               for (j = i + 1;
+                                    j < len && count < LACE_MAX_COMPRESS_LEN;
+                                    j++) {
                                        if ((p[j] & 0xff00) != high)
                                                break;
-                                       compress_count++;
+                                       count++;
                                }
-                               bitbuf = (bitbuf << 16) |
-                                       (compress_count << 8) |
+                               bitbuf = (bitbuf << 16) | (count << 8) |
                                        (high >> 8);
                                bitlen += 16;
                        }
                        bitbuf = (bitbuf << 8) | (p[i] & 0xff);
                        bitlen += 8;
-                       compress_count--;
+                       count--;
                } else {
                        bitbuf = (bitbuf << 16) | p[i];
                        bitlen += 16;
diff --git a/contrib/idn/mdnkit/lib/make.wnt b/contrib/idn/mdnkit/lib/make.wnt
new file mode 100644 (file)
index 0000000..961316c
--- /dev/null
@@ -0,0 +1,283 @@
+# $Id: make.wnt,v 1.3 2001/06/09 00:30:16 tale Exp $
+# Makefile for MDN library, manually configured for WIN-NT (VC5.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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+# Tokyo, 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) Japan Network Information Center.  All rights reserved."
+# 
+# 4. Neither the name of JPNIC may 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.
+# 
+# 6. Indemnification by Licensee
+#    Any person or entities using and/or redistributing this Software under
+#    this License Terms and Conditions shall defend indemnify and hold
+#    harmless JPNIC from and against any and all judgements damages,
+#    expenses, settlement liabilities, cost and other liabilities of any
+#    kind as a result of use and redistribution of this Software or any
+#    claim, suite, action, litigation or proceeding by any third party
+#    arising out of or relates to this License Terms and Conditions.
+# 
+# 7. Governing Law, Jurisdiction and Venue
+#    This License Terms and Conditions shall be governed by and and
+#    construed in accordance with the law of Japan. Any person or entities
+#    using and/or redistributing this Software under this License Terms and
+#    Conditions hereby agrees and consent to the personal and exclusive
+#    jurisdiction and venue of Tokyo District Court of Japan.
+
+!include <ntwin32.mak>
+
+INCDIR = ..\include
+ICONVDIR = ..\win
+LIBS =
+SYSLIBS = $(conlibsdll)
+
+#
+# Files to build MDN library
+#
+
+HDRS =  $(ICONVDIR)\iconv.h \
+       $(INCDIR)\config.h \
+       $(INCDIR)\mdn\ace.h \
+       $(INCDIR)\mdn\altdude.h \
+       $(INCDIR)\mdn\amcacem.h \
+       $(INCDIR)\mdn\amcaceo.h \
+       $(INCDIR)\mdn\amcacer.h \
+       $(INCDIR)\mdn\api.h \
+       $(INCDIR)\mdn\assert.h \
+       $(INCDIR)\mdn\brace.h \
+       $(INCDIR)\mdn\checker.h \
+       $(INCDIR)\mdn\converter.h \
+       $(INCDIR)\mdn\debug.h \
+       $(INCDIR)\mdn\delimitermap.h \
+       $(INCDIR)\mdn\dn.h \
+       $(INCDIR)\mdn\dude.h \
+       $(INCDIR)\mdn\filechecker.h \
+       $(INCDIR)\mdn\filemapper.h \
+       $(INCDIR)\mdn\lace.h \
+       $(INCDIR)\mdn\localencoding.h \
+       $(INCDIR)\mdn\log.h \
+       $(INCDIR)\mdn\logmacro.h \
+       $(INCDIR)\mdn\mapper.h \
+       $(INCDIR)\mdn\mapselector.h \
+       $(INCDIR)\mdn\msgheader.h \
+       $(INCDIR)\mdn\msgtrans.h \
+       $(INCDIR)\mdn\nameprep.h \
+       $(INCDIR)\mdn\normalizer.h \
+       $(INCDIR)\mdn\race.h \
+       $(INCDIR)\mdn\res.h \
+       $(INCDIR)\mdn\resconf.h \
+       $(INCDIR)\mdn\result.h \
+       $(INCDIR)\mdn\selectiveencode.h \
+       $(INCDIR)\mdn\strhash.h \
+       $(INCDIR)\mdn\ucsmap.h \
+       $(INCDIR)\mdn\ucsset.h \
+       $(INCDIR)\mdn\unicode.h \
+       $(INCDIR)\mdn\unormalize.h \
+       $(INCDIR)\mdn\utf5.h \
+       $(INCDIR)\mdn\utf6.h \
+       $(INCDIR)\mdn\utf8.h \
+       $(INCDIR)\mdn\util.h \
+       $(INCDIR)\mdn\version.h
+
+SRCS =  ace.c altdude.c amcacem.c amcaceo.c amcacer.c api.c \
+       brace.c checker.c converter.c \
+       debug.c delimitermap.c dn.c dude.c \
+       filechecker.c filemapper.c \
+       lace.c localencoding.c log.c \
+       mapper.c mapselector.c msgheader.c msgtrans.c \
+       nameprep.c normalizer.c \
+       race.c res.c resconf.c result.c \
+       selectiveencode.c strhash.c \
+       ucsmap.c ucsset.c unicode.c unormalize.c \
+       utf5.c utf6.c utf8.c util.c version.c
+
+OBJS =  ace.obj altdude.obj amcacem.obj amcaceo.obj amcacer.obj api.obj \
+       brace.obj checker.obj converter.obj \
+       debug.obj delimitermap.obj dn.obj dude.obj \
+       filechecker.obj filemapper.obj \
+       lace.obj localencoding.obj log.obj \
+       mapper.obj mapselector.obj msgheader.obj msgtrans.obj \
+       nameprep.obj normalizer.obj \
+       race.obj res.obj resconf.obj result.obj \
+       selectiveencode.obj strhash.obj \
+       ucsmap.obj ucsset.obj unicode.obj unormalize.obj \
+       utf5.obj utf6.obj utf8.obj util.obj version.obj
+
+LIB = libmdn.lib
+
+DBG = -DDEBUG
+
+#
+# Target to build
+#
+
+all: $(LIB)
+
+libmdn.lib: $(OBJS)
+        -del libmdn.lib
+       lib /out:libmdn.lib $(OBJS)
+
+#
+# Dependencies
+#
+
+ace.obj: ace.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) $(DBG) $*.c
+
+altdude.obj: ace.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) $(DBG) $*.c
+
+amcacem.obj: ace.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) $(DBG) $*.c
+
+amcaceo.obj: ace.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) $(DBG) $*.c
+
+amcacer.obj: ace.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) $(DBG) $*.c
+
+api.obj: api.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) $(DBG) $*.c
+
+brace.obj: brace.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) $(DBG) $*.c
+
+checker.obj: checker.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) $(DBG) $*.c
+
+converter.obj: converter.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) $(DBG) $*.c
+
+debug.obj: debug.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) $(DBG) $*.c
+
+delimitermap.obj: delimitermap.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) $(DBG) $*.c
+
+dn.obj: dn.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) $(DBG) $*.c
+
+dude.obj: dude.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) $(DBG) $*.c
+
+filechecker.obj: filechecker.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) $(DBG) $*.c
+
+filemapper.obj: filemapper.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) $(DBG) $*.c
+
+lace.obj: lace.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) $(DBG) $*.c
+
+localencoding.obj: localencoding.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) $(DBG) $*.c
+
+log.obj: log.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) $(DBG) $*.c
+
+mapper.obj: mapper.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) $(DBG) $*.c
+
+mapselector.obj: mapselector.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) $(DBG) $*.c
+
+msgheader.obj: msgheader.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) $(DBG) $*.c
+
+msgtrans.obj: msgtrans.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) $(DBG) $*.c
+
+nameprep.obj: nameprep.c nameprep_template.c nameprepdata.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) $(DBG) $*.c
+
+normalizer.obj: normalizer.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) $(DBG) $*.c
+
+race.obj: race.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) $(DBG) $*.c
+
+res.obj: res.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) $(DBG) $*.c
+
+resconf.obj: resconf.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) $(DBG) $*.c
+
+result.obj: result.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) $(DBG) $*.c
+
+selectiveencode.obj: selectiveencode.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) $(DBG) $*.c
+
+strhash.obj: strhash.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) $(DBG) $*.c
+
+ucsmap.obj: ucsmap.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) $(DBG) $*.c
+
+ucsset.obj: ucsset.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) $(DBG) $*.c
+
+unicode.obj: unicode.c unicodedata.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) $(DBG) $*.c
+
+unormalize.obj: unormalize.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) $(DBG) $*.c
+
+utf5.obj: utf5.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) $(DBG) $*.c
+
+utf6.obj: utf6.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) $(DBG) $*.c
+
+utf8.obj: utf8.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) $(DBG) $*.c
+
+util.obj: util.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) $(DBG) $*.c
+
+version.obj: version.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) $(DBG) $*.c
+
+
+#
+# misc.
+#
+
+install:
+
+clean:
+       del *.obj *.lib core *.core *~
+
diff --git a/contrib/idn/mdnkit/lib/mapper.c b/contrib/idn/mdnkit/lib/mapper.c
new file mode 100644 (file)
index 0000000..5e926d8
--- /dev/null
@@ -0,0 +1,584 @@
+#ifndef lint
+static char *rcsid = "$Id: mapper.c,v 1.1 2001/06/09 00:30:17 tale 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+ * Tokyo, 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) Japan Network Information Center.  All rights reserved."
+ * 
+ * 4. Neither the name of JPNIC may 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.
+ * 
+ * 6. Indemnification by Licensee
+ *    Any person or entities using and/or redistributing this Software under
+ *    this License Terms and Conditions shall defend indemnify and hold
+ *    harmless JPNIC from and against any and all judgements damages,
+ *    expenses, settlement liabilities, cost and other liabilities of any
+ *    kind as a result of use and redistribution of this Software or any
+ *    claim, suite, action, litigation or proceeding by any third party
+ *    arising out of or relates to this License Terms and Conditions.
+ * 
+ * 7. Governing Law, Jurisdiction and Venue
+ *    This License Terms and Conditions shall be governed by and and
+ *    construed in accordance with the law of Japan. Any person or entities
+ *    using and/or redistributing this Software under this License Terms and
+ *    Conditions hereby agrees and consent to the personal and exclusive
+ *    jurisdiction and venue of Tokyo District Court of Japan.
+ */
+
+#include <config.h>
+
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <mdn/result.h>
+#include <mdn/assert.h>
+#include <mdn/logmacro.h>
+#include <mdn/mapper.h>
+#include <mdn/strhash.h>
+#include <mdn/debug.h>
+
+/*
+ * Type for mapping scheme.
+ */
+typedef struct {
+       char *prefix;
+       char *parameter;
+       mdn_mapper_createproc_t create;
+       mdn_mapper_destroyproc_t destroy;
+       mdn_mapper_mapproc_t map;
+       void *context;
+} map_scheme_t;
+
+/*
+ * Standard mapping schemes.
+ */
+static const map_scheme_t nameprep_02_scheme = {
+       "nameprep-02",
+       "nameprep-02",
+       mdn__nameprep_createproc,
+       mdn__nameprep_destroyproc,
+       mdn__nameprep_mapproc,
+       NULL,
+};
+
+static const map_scheme_t nameprep_03_scheme = {
+       "nameprep-03",
+       "nameprep-03",
+       mdn__nameprep_createproc,
+       mdn__nameprep_destroyproc,
+       mdn__nameprep_mapproc,
+       NULL,
+};
+
+static const map_scheme_t filemap_scheme = {
+       "filemap",
+       NULL,
+       mdn__filemapper_createproc,
+       mdn__filemapper_destroyproc,
+       mdn__filemapper_mapproc,
+       NULL,
+};
+
+static const map_scheme_t *standard_map_schemes[] = {
+       &nameprep_02_scheme,
+       &nameprep_03_scheme,
+       &filemap_scheme,
+       NULL,
+};
+
+/*
+ * Hash table for mapping schemes.
+ */
+static mdn_strhash_t scheme_hash = NULL;
+
+/*
+ * Mapper object type.
+ */
+struct mdn_mapper {
+       int nschemes;
+       int scheme_size;
+       map_scheme_t *schemes;
+       int reference_count;
+};
+
+#define MAPPER_INITIAL_SCHEME_SIZE     1
+
+mdn_result_t
+mdn_mapper_initialize(void) {
+       mdn_result_t r;
+       map_scheme_t **scheme;
+
+       TRACE(("mdn_mapper_initialize()\n"));
+
+       if (scheme_hash != NULL)
+               return (mdn_success);   /* already initialized */
+
+       r = mdn_strhash_create(&scheme_hash);
+       if (r != mdn_success) {
+               WARNING(("mdn_mapper_initialize: "
+                       "hash table creation failed\n"));
+               goto failure;
+       }
+
+       for (scheme = (map_scheme_t **)standard_map_schemes;
+               *scheme != NULL; scheme++) {
+               r = mdn_strhash_put(scheme_hash, (*scheme)->prefix, *scheme);
+               if (r != mdn_success) {
+                       WARNING(("mdn_mapper_initialize: "
+                               "hash table creation failed\n"));
+                       goto failure;
+               }
+       }
+
+       return (mdn_success);
+
+failure:
+       if (scheme_hash != NULL) {
+               mdn_strhash_destroy(scheme_hash, NULL);
+               scheme_hash = NULL;
+       }
+       return (r);
+}
+
+mdn_result_t
+mdn_mapper_create(mdn_mapper_t *ctxp) {
+       mdn_mapper_t ctx = NULL;
+       mdn_result_t r;
+
+       assert(scheme_hash != NULL);
+       assert(ctxp != NULL);
+
+       TRACE(("mdn_mapper_create()\n"));
+
+       ctx = (mdn_mapper_t) malloc(sizeof(struct mdn_mapper));
+       if (ctx == NULL) {
+               WARNING(("mdn_mapper_create: malloc failed\n"));
+               r = mdn_nomemory;
+               goto failure;
+       }
+
+       ctx->schemes = (map_scheme_t *) malloc(sizeof(map_scheme_t)
+                * MAPPER_INITIAL_SCHEME_SIZE);
+       if (ctx->schemes == NULL) {
+               WARNING(("mdn_mapper_create: malloc failed\n"));
+               r = mdn_nomemory;
+               goto failure;
+       }
+
+       ctx->nschemes = 0;
+       ctx->scheme_size = MAPPER_INITIAL_SCHEME_SIZE;
+       ctx->reference_count = 1;
+       *ctxp = ctx;
+
+       return (mdn_success);
+
+failure:
+       if (ctx != NULL)
+               free(ctx->schemes);
+       free(ctx);
+       return (r);
+}
+
+void
+mdn_mapper_destroy(mdn_mapper_t ctx) {
+       int i;
+
+       assert(scheme_hash != NULL);
+       assert(ctx != NULL);
+
+       TRACE(("mdn_mapper_destroy()\n"));
+       TRACE(("mdn_mapper_destroy: update reference count (%d->%d)\n",
+           ctx->reference_count, ctx->reference_count - 1));
+
+       ctx->reference_count--;
+       if (ctx->reference_count <= 0) {
+               TRACE(("mdn_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);
+       }
+}
+
+void
+mdn_mapper_incrref(mdn_mapper_t ctx) {
+       assert(ctx != NULL && scheme_hash != NULL);
+
+       TRACE(("mdn_mapper_incrref()\n"));
+       TRACE(("mdn_mapper_incrref: update reference count (%d->%d)\n",
+               ctx->reference_count, ctx->reference_count + 1));
+
+       ctx->reference_count++;
+}
+
+mdn_result_t
+mdn_mapper_add(mdn_mapper_t ctx, const char *scheme_name) {
+       mdn_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(("mdn_mapper_add(scheme_name=%s)\n",
+               mdn_debug_xstring(scheme_name, 20)));
+
+       /*
+        * 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;
+               if (scheme_prefixlen + 1 > sizeof(static_buffer)) {
+                       buffer = (char *) malloc(scheme_prefixlen + 1);
+                       if (buffer == NULL) {
+                               r = mdn_nomemory;
+                               goto failure;
+                       }
+               }
+               memcpy(buffer, scheme_name, scheme_prefixlen);
+               *(buffer + scheme_prefixlen) = '\0';
+               scheme_prefix = buffer;
+               scheme_parameter++;
+       }
+
+       /*
+        * Find a scheme.
+        */
+       if (mdn_strhash_get(scheme_hash, scheme_prefix, (void **)&scheme)
+               != mdn_success) {
+               WARNING(("mdn_mapper_add: invalid scheme %s\n",
+                        scheme_name));
+               r = mdn_invalid_name;
+               goto failure;
+       }
+       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) {
+               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) {
+                       WARNING(("mdn_mapper_add: malloc failed\n"));
+                       r = mdn_nomemory;
+                       goto failure;
+               }
+               ctx->schemes = new_schemes;
+               ctx->scheme_size *= 2;
+       }
+
+       r = scheme->create(scheme_parameter, &scheme_context);
+       if (r != mdn_success)
+               goto failure;
+
+       memcpy(ctx->schemes + ctx->nschemes, scheme, sizeof(map_scheme_t));
+       ctx->schemes[ctx->nschemes].context = scheme_context;
+       ctx->nschemes++;
+
+       return (mdn_success);
+
+failure:
+       if (buffer != static_buffer)
+               free(buffer);
+       free(scheme_context);
+       return (r);
+}
+
+mdn_result_t
+mdn_mapper_addall(mdn_mapper_t ctx, const char **scheme_names, int nschemes) {
+       mdn_result_t r;
+       int i;
+
+       assert(scheme_hash != NULL);
+       assert(ctx != NULL && scheme_names != NULL);
+
+       TRACE(("mdn_mapper_addall(nschemes=%d)\n", nschemes));
+
+       for (i = 0; i < nschemes; i++) {
+               r = mdn_mapper_add(ctx, (const char *)*scheme_names);
+               if (r != mdn_success)
+                       return (r);
+               scheme_names++;
+       }
+
+       return (mdn_success);
+}
+
+mdn_result_t
+mdn_mapper_map(mdn_mapper_t ctx, const char *from, char *to, size_t tolen) {
+       mdn_result_t r;
+       size_t fromlen;
+       char *src, *dst;
+       char static_buffers[2][1024];   /* large enough */
+       char *dynamic_buffers[2];
+       size_t dynamic_buflen[2];
+       size_t dstlen;
+       int idx;
+       int i;
+
+       assert(scheme_hash != NULL);
+       assert(ctx != NULL && from != NULL && to != NULL);
+
+       TRACE(("mdn_mapper_map(from=\"%s\")\n", mdn_debug_xstring(from, 20)));
+
+       /*
+        * Initialize the buffers to use the local
+        * storage (stack memory).
+        */
+       dynamic_buffers[0] = NULL;
+       dynamic_buffers[1] = NULL;
+       dynamic_buflen[0] = 0;
+       dynamic_buflen[1] = 0;
+
+       fromlen = strlen(from);
+
+       /*
+        * If no mapping scheme has been registered, copy the string.
+        */
+       if (ctx->nschemes == 0) {
+               if (fromlen + 1 > tolen)
+                       return (mdn_buffer_overflow);
+               memcpy(to, from, fromlen + 1);
+               return (mdn_success);
+       }
+
+       /*
+        * Map.
+        */
+       src = (void *)from;
+       dstlen = fromlen + 1;
+
+       i = 0;
+       while (i < ctx->nschemes) {
+               /*
+                * Choose destination area to restore the result of a mapping.
+                */
+               if (i + 1 == ctx->nschemes) {
+                       dst = to;
+                       dstlen = tolen;
+
+               } else if (dstlen <= sizeof(static_buffers[0])) {
+                       if (src == static_buffers[0])
+                               idx = 1;
+                       else
+                               idx = 0;
+
+                       dst = static_buffers[idx];
+                       dstlen = sizeof(static_buffers[0]);
+
+               } else {
+                       if (src == dynamic_buffers[0])
+                               idx = 1;
+                       else
+                               idx = 0;
+
+                       if (dynamic_buflen[idx] == 0) {
+                               dynamic_buffers[idx] = (char *) malloc(dstlen);
+                               if (dynamic_buffers[idx] == NULL) {
+                                       r = mdn_nomemory;
+                                       goto failure;
+                               }
+                               dynamic_buflen[idx] = dstlen;
+
+                       } else if (dynamic_buflen[idx] < dstlen) {
+                               char *newbuf;
+
+                               newbuf = realloc(dynamic_buffers[idx], dstlen);
+                               if (newbuf == NULL) {
+                                       r = mdn_nomemory;
+                                       goto failure;
+                               }
+                               dynamic_buffers[idx] = newbuf;
+                               dynamic_buflen[idx] = dstlen;
+                       }
+
+                       dst = dynamic_buffers[idx];
+                       dstlen = dynamic_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 == mdn_buffer_overflow && dst != to) {
+                       dstlen *= 2;
+                       continue;
+               }
+               if (r != mdn_success)
+                       goto failure;
+
+               src = dst;
+               i++;
+       }
+
+       return (mdn_success);
+
+failure:
+       free(dynamic_buffers[0]);
+       free(dynamic_buffers[1]);
+       return (r);
+}
+
+mdn_result_t
+mdn_mapper_register(const char *prefix,                    
+                   mdn_mapper_createproc_t create,
+                   mdn_mapper_destroyproc_t destroy,
+                   mdn_mapper_mapproc_t map) {
+       mdn_result_t r;
+       map_scheme_t *scheme = NULL;
+
+       assert(scheme_hash != NULL);
+       assert(prefix != NULL && create != NULL && destroy != NULL &&
+               map != NULL);
+
+       TRACE(("mdn_mapper_register(prefix=%s)\n", prefix));
+
+       scheme = (map_scheme_t *) malloc(sizeof(map_scheme_t));
+       if (scheme == NULL) {
+               WARNING(("mdn_mapper_register: malloc failed\n"));
+               r = mdn_nomemory;
+               goto failure;
+       }
+
+       scheme->prefix = (char *) malloc(strlen(prefix) + 1);
+       if (scheme->prefix == NULL) {
+               WARNING(("mdn_mapper_register: malloc failed\n"));
+               r = mdn_nomemory;
+               goto failure;
+       }
+
+       strcpy(scheme->prefix, prefix);
+       scheme->parameter = NULL;
+       scheme->create    = create;
+       scheme->destroy   = destroy;
+       scheme->map       = map;
+
+       r = mdn_strhash_put(scheme_hash, prefix, scheme);
+       if (r != mdn_success)
+               WARNING(("mdn_mapper_register: registration failed\n"));
+
+       return (r);
+
+failure:
+       if (scheme != NULL)
+               free(scheme->prefix);
+       free(scheme);
+       return (r);
+}
+
+#ifdef TEST
+#include <stdio.h>
+
+/*
+ * Test program for this module.
+ *
+ * The test program repeatedly prompt you to input a command.  The
+ * following command is currently recognized.
+ *
+ *    tolen N          set the length of output buffer. (1...1024)
+ *    add TLD           add selectable map for TLD. (e.g. com, jp)
+ *    DOMANNAME         try mapping DOMANNAME.
+ *
+ * Input EOF to exit.
+ */
+int
+main(int ac, char **av) {
+       mdn_mapper_t ctx;
+       char from[1024], to[1024];
+       size_t fromlen, tolen = sizeof(to);
+       mdn_result_t r;
+
+       mdn_log_setlevel(mdn_log_level_trace);
+       mdn_mapper_initialize();
+       r = mdn_mapper_create(&ctx);
+       if (r != mdn_success) {
+               fprintf(stderr, "mdn_mapper_create: %s\n",
+                       mdn_result_tostring(r));
+               return 1;
+       }
+       while (fgets(from, sizeof(from), stdin) != NULL) {
+               fromlen = strlen(from);
+               if (from[fromlen - 1] == '\n')
+                       from[fromlen - 1] = '\0';
+               if (from[0] == '\0')
+                       continue;
+
+               if (strncmp(from, "tolen ", 6) == 0) {
+                       tolen = atoi(from + 6);
+               } else if (strncmp(from, "add ", 4) == 0) {
+                       r = mdn_mapper_add(ctx, from + 4);
+                       if (r != mdn_success) {
+                               fprintf(stderr, "mdn_mapper_add: %s\n",
+                                       mdn_result_tostring(r));
+                               conitinue;
+                       }
+               } else {
+                       r = mdn_mapper_map(ctx, from, to, tolen);
+                       if (r != mdn_success) {
+                               fprintf(stderr, "mdn_mapper_map: %s\n",
+                                       mdn_result_tostring(r));
+                               conitinue;
+                       }
+                       fprintf(stderr, "%s\n", to);
+               }
+       }
+
+       mdn_mapper_destroy(ctx);
+       return 0;
+}
+
+#endif /* TEST */
diff --git a/contrib/idn/mdnkit/lib/mapselector.c b/contrib/idn/mdnkit/lib/mapselector.c
new file mode 100644 (file)
index 0000000..b2df0bc
--- /dev/null
@@ -0,0 +1,430 @@
+#ifndef lint
+static char *rcsid = "$Id: mapselector.c,v 1.1 2001/06/09 00:30:17 tale 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+ * Tokyo, 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) Japan Network Information Center.  All rights reserved."
+ * 
+ * 4. Neither the name of JPNIC may 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.
+ * 
+ * 6. Indemnification by Licensee
+ *    Any person or entities using and/or redistributing this Software under
+ *    this License Terms and Conditions shall defend indemnify and hold
+ *    harmless JPNIC from and against any and all judgements damages,
+ *    expenses, settlement liabilities, cost and other liabilities of any
+ *    kind as a result of use and redistribution of this Software or any
+ *    claim, suite, action, litigation or proceeding by any third party
+ *    arising out of or relates to this License Terms and Conditions.
+ * 
+ * 7. Governing Law, Jurisdiction and Venue
+ *    This License Terms and Conditions shall be governed by and and
+ *    construed in accordance with the law of Japan. Any person or entities
+ *    using and/or redistributing this Software under this License Terms and
+ *    Conditions hereby agrees and consent to the personal and exclusive
+ *    jurisdiction and venue of Tokyo District Court of Japan.
+ */
+
+#include <config.h>
+
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <mdn/assert.h>
+#include <mdn/logmacro.h>
+#include <mdn/result.h>
+#include <mdn/mapselector.h>
+#include <mdn/strhash.h>
+#include <mdn/debug.h>
+
+struct mdn_mapselector {
+       mdn_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 *memrchr(const void *s, int c, size_t n);
+static void string_ascii_tolower(char *string);
+
+mdn_result_t
+mdn_mapselector_initialize(void) {
+       TRACE(("mdn_mapselector_initialize()\n"));
+
+       return mdn_mapper_initialize();
+}
+
+mdn_result_t
+mdn_mapselector_create(mdn_mapselector_t *ctxp) {
+       mdn_mapselector_t ctx = NULL;
+       mdn_result_t r;
+
+       assert(ctxp != NULL);
+       TRACE(("mdn_mapselector_create()\n"));
+
+       ctx = (mdn_mapselector_t)malloc(sizeof(struct mdn_mapselector));
+       if (ctx == NULL) {
+               WARNING(("mdn_mapselector_create: malloc failed\n"));
+               r = mdn_nomemory;
+               goto failure;
+       }
+
+       ctx->maphash = NULL;
+       ctx->reference_count = 1;
+
+       r = mdn_strhash_create(&(ctx->maphash));
+       if (r != mdn_success)
+               goto failure;
+
+       *ctxp = ctx;
+
+       return (mdn_success);
+
+failure:
+       if (ctx != NULL)
+               free(ctx->maphash);
+       free(ctx);
+       return (r);
+}
+
+void
+mdn_mapselector_destroy(mdn_mapselector_t ctx) {
+       assert(ctx != NULL);
+
+       TRACE(("mdn_mapselector_destroy()\n"));
+       TRACE(("mdn_mapselector_destroy: update reference count (%d->%d)\n",
+           ctx->reference_count, ctx->reference_count - 1));
+
+       ctx->reference_count--;
+       if (ctx->reference_count <= 0) {
+               TRACE(("mdn_mapselector_destroy: the object is destroyed\n"));
+               mdn_strhash_destroy(ctx->maphash,
+                       (mdn_strhash_freeproc_t)&mdn_mapper_destroy);
+               free(ctx);
+       }
+}
+
+void
+mdn_mapselector_incrref(mdn_mapselector_t ctx) {
+       assert(ctx != NULL);
+
+       TRACE(("mdn_mapselector_incrref()\n"));
+       TRACE(("mdn_mapselector_incrref: update reference count (%d->%d)\n",
+               ctx->reference_count, ctx->reference_count + 1));
+
+       ctx->reference_count++;
+}
+
+mdn_result_t
+mdn_mapselector_add(mdn_mapselector_t ctx, const char *tld, const char *name) {
+       mdn_result_t r;
+       mdn_mapper_t mapper;
+       char hash_key[MAPSELECTOR_MAX_TLD_LENGTH + 1];
+
+       assert(ctx != NULL && tld != NULL);
+
+       TRACE(("mdn_mapselector_add(tld=%s, name=%s)\n", tld, name));
+
+       if (*tld != '.' || *(tld + 1) != '\0') {
+               if (*tld == '.')
+                       tld++;
+               if (strchr(tld, '.') != NULL)
+                       return (mdn_invalid_name);
+       }
+       if (strlen(tld) > MAPSELECTOR_MAX_TLD_LENGTH)
+               return (mdn_invalid_name);
+       strcpy(hash_key, tld);
+       string_ascii_tolower(hash_key);
+
+       if (mdn_strhash_get(ctx->maphash, hash_key, (void **)&mapper)
+               != mdn_success) {
+               r = mdn_mapper_create(&mapper);
+               if (r != mdn_success)
+                       return (r);
+
+               r = mdn_strhash_put(ctx->maphash, hash_key, mapper);
+               if (r != mdn_success)
+                       return (r);
+       }
+
+       return (mdn_mapper_add(mapper, name));
+}
+
+mdn_result_t
+mdn_mapselector_addall(mdn_mapselector_t ctx, const char *tld,
+                      const char **scheme_names, int nschemes) {
+       mdn_result_t r;
+       int i;
+
+       assert(ctx != NULL && tld != NULL && scheme_names != NULL);
+
+       TRACE(("mdn_mapselector_addall(tld=%s, nschemes=%d)\n", 
+             tld, nschemes));
+
+       for (i = 0; i < nschemes; i++) {
+               r = mdn_mapselector_add(ctx, tld, (const char *)*scheme_names);
+               if (r != mdn_success)
+                       return (r);
+               scheme_names++;
+       }
+
+       return (mdn_success);
+}
+
+mdn_mapper_t
+mdn_mapselector_mapper(mdn_mapselector_t ctx, const char *tld) {
+       mdn_result_t r;
+       mdn_mapper_t mapper;
+       char hash_key[MAPSELECTOR_MAX_TLD_LENGTH + 1];
+
+       assert(ctx != NULL && tld != NULL);
+
+       TRACE(("mdn_mapselector_mapper(tld=%s)\n", tld));
+
+       if (*tld != '.' || *(tld + 1) != '\0') {
+               if (*tld == '.')
+                       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 = mdn_strhash_get(ctx->maphash, hash_key, (void **)&mapper);
+       if (r != mdn_success)
+               return (NULL);
+
+       mdn_mapper_incrref(mapper);
+
+       return (mapper);
+}
+
+mdn_result_t
+mdn_mapselector_map(mdn_mapselector_t ctx, 
+                    const char *from, char *to, size_t tolen) {
+       mdn_result_t r;
+       mdn_mapper_t mapper = NULL;
+       char tld[MAPSELECTOR_MAX_TLD_LENGTH + 1];
+       size_t fromlen;
+       size_t tldlen;
+       const char *last_dot;
+
+       assert(ctx != NULL && from != NULL && to != NULL);
+
+       TRACE(("mdn_mapselector_map(from=\"%s\")\n",
+               mdn_debug_xstring(from, 20)));
+
+       fromlen = strlen(from);
+
+       /*
+        * Get TLD from `from'.
+        */
+       if (from[0] == '\0') {
+               /* 'from' is empty. */
+               tld[0] = '\0';
+       } else if (from[0] == '.' && from[1] == '\0') {
+               /* 'from' is just a '.'. */
+               tld[0] = '\0';
+       } else if (from[fromlen - 1] == '.') {
+               /*
+                * 'from' ends with dot.
+                */
+               const char *tld_top;
+
+               /* Find the second last dot. */
+               last_dot = memrchr(from, '.', fromlen - 1);
+               if (last_dot == NULL) {
+                       /* 'from' is a single label followed by a dot. */
+                       tld_top = from;
+               } else {
+                       tld_top = last_dot + 1;
+               }
+               tldlen = strlen(tld_top) - 1;
+               if (tldlen > MAPSELECTOR_MAX_TLD_LENGTH)
+                       return (mdn_invalid_name);
+               memcpy(tld, tld_top, tldlen);
+               tld[tldlen] = '\0';
+       } else {
+               /* Find the last dot. */
+               last_dot = memrchr(from, '.', fromlen);
+               if (last_dot == NULL) {
+                       /* 'from' contains no dots. */
+                       strcpy(tld, MDN_MAPSELECTOR_NO_TLD);
+               } else {
+                       tldlen = strlen(last_dot + 1);
+                       if (tldlen > MAPSELECTOR_MAX_TLD_LENGTH)
+                               return (mdn_invalid_name);
+                       memcpy(tld, last_dot + 1, tldlen);
+                       tld[tldlen] = '\0';
+               }
+       }
+
+       string_ascii_tolower(tld);
+
+       /*
+        * Get the mapper for the TLD.
+        */
+       if (tld[0] != '\0' &&
+               mdn_strhash_get(ctx->maphash, tld, (void **)&mapper)
+               != mdn_success) {
+               strcpy(tld, MDN_MAPSELECTOR_DEFAULT);
+               mdn_strhash_get(ctx->maphash, tld, (void **)&mapper);
+       }
+
+       /*
+        * Map.
+        * If default mapper has not been registered, copy the string.
+        */
+       if (mapper == NULL) {
+               TRACE(("mdn_mapselector_map: no mapper\n"));
+               if (fromlen + 1 > tolen)
+                       return (mdn_buffer_overflow);
+               memcpy(to, from, fromlen + 1);
+               r = mdn_success;
+       } else {
+               TRACE(("mdn_mapselector_map: tld=%s\n", tld));
+               r = mdn_mapper_map(mapper, from, to, tolen);
+       }
+
+       return (r);
+}
+
+
+/*
+ * The memrchr() function returns the last occurrence of c (converted to
+ * an unsigned char) in the first n characters (each character is converted
+ * to an unsigned char) of the object s, or returns NULL if c does not
+ * occur.
+ */
+static void *
+memrchr(const void *s, int c, size_t n) {
+       const unsigned char *p = (const unsigned char *)s;
+       void *save = NULL;
+
+       if (n == 0)
+               return (NULL);
+
+       do {
+               if (*p == c)
+                       save = (void *)p;
+               p++;
+       } while (--n != 0);
+
+       return (save);
+}
+
+
+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';
+       }
+}
+
+#ifdef TEST
+#include <stdio.h>
+
+/*
+ * Test program for this module.
+ *
+ * The test program repeatedly prompt you to input a command.  The
+ * following command is currently recognized.
+ *
+ *    tolen N          set the length of output buffer. (1...1024)
+ *    add TLD           add selectable map for TLD. (e.g. com, jp)
+ *    DOMANNAME         try mapping DOMANNAME.
+ *
+ * Input EOF to exit.
+ */
+int
+main(int ac, char **av) {
+       mdn_mapselector_t ctx;
+       char from[1024], to[1024];
+       size_t fromlen, tolen = sizeof(to);
+       mdn_result_t r;
+
+       mdn_log_setlevel(mdn_log_level_trace);
+       mdn_mapselector_initialize();
+       r = mdn_mapselector_create(&ctx);
+       if (r != mdn_success) {
+               fprintf(stderr, "mdn_mapselector_create: %s\n",
+                       mdn_result_tostring(r));
+               return 1;
+       }
+       while (fgets(from, sizeof(from), stdin) != NULL) {
+               fromlen = strlen(from);
+               if (from[fromlen - 1] == '\n')
+                       from[fromlen - 1] = '\0';
+               if (from[0] == '\0')
+                       continue;
+
+               if (strncmp(from, "tolen ", 6) == 0) {
+                       tolen = atoi(from + 6);
+               } else if (strncmp(from, "add ", 4) == 0) {
+                       r = mdn_mapselector_add(ctx, from + 4, "dummy");
+                       if (r != mdn_success) {
+                               fprintf(stderr, "mdn_mapselector_add: %s\n",
+                                       mdn_result_tostring(r));
+                               conitinue;
+                       }
+               } else {
+                       r = mdn_mapselector_map(ctx, from, to, tolen);
+                       if (r != mdn_success) {
+                               fprintf(stderr, "mdn_mapselector_map: %s\n",
+                                       mdn_result_tostring(r));
+                               conitinue;
+                       }
+               }
+       }
+
+       mdn_mapselector_destroy(ctx);
+       return 0;
+}
+
+#endif /* TEST */
diff --git a/contrib/idn/mdnkit/lib/mdn.conf.sample.in b/contrib/idn/mdnkit/lib/mdn.conf.sample.in
new file mode 100644 (file)
index 0000000..04503d7
--- /dev/null
@@ -0,0 +1,168 @@
+# $Id: mdn.conf.sample.in,v 1.1 2001/06/09 00:30:17 tale Exp $
+#
+# Sample file for mDNkit version 2 resolver configuration file (mdn.conf).
+#
+# [This file is tailored for preference "@preference@".]
+#
+
+#
+# `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:
+#
+#      RACE
+#      BRACE
+#      LACE
+#      DUDE
+#      UTF-6
+#      UTF-8
+#      AltDUDE
+#      AMC-ACE-M
+#      AMC-ACE-O
+#      AMC-ACE-R
+#      <codeset names your iconv_open() accepts>
+#
+# syntax)
+#      idn-encoding <encoding>
+#
+idn-encoding RACE
+
+#
+# `nameprep' entry specifies the version of NAMEPREP.
+# mDNkit currently supports the following version:
+#
+#      nameprep-03             -- name preparation scheme described in the
+#                                 IETF draft `idn-nameprep-03'
+#      nameprep-02             -- name preparation scheme described in the
+#                                 IETF draft `idn-nameprep-02'
+#
+# syntax)
+#      nameprep <nameprep version>
+#
+# This entry and the follwoing four entries have the same effect.
+# 
+#       nameprep-map <nameprep version>
+#       nameprep-normalize <nameprep version>
+#       nameprep-prohibit <nameprep version>
+#      nameprep-unassigned <nameprep version>
+#
+# If both `nameprep' and more-specific entries (i.e. `nameprep-*' entries)
+# are specified, more-specific ones take precedence.
+#
+nameprep nameprep-03
+
+#
+# `nameprep-map' entry specifies the mapping scheme of NAMEPREP process.
+# Avaialable mapping schemes are:
+#
+#      <nameprep version>      -- nameprep version
+#      filemap:<pathname>      -- read mapping rules from a file
+#
+# syntax)
+#      nameprep-map <scheme> ...
+#
+# If multiple schemes are specified, they are applied in turn.
+#
+#nameprep-map nameprep-03
+
+#
+# `nameprep-normalize' entry specifies the normalization scheme of NAMEPREP
+# process.  Avaialable normalization schemes are:
+#
+#      <nameprep version>      -- nameprep version
+#      ascii-lowercase         -- ASCII uppercase letters to lowercase
+#      ascii-uppercase         -- ASCII lowercase letters to uppercase
+#      unicode-lowercase       -- Unicode uppercase letters to lowercase
+#      unicode-uppercase       -- Unicode lowercase letters to uppercase
+#      unicode-foldcase        -- Unicode case-folding.
+#      unicode-form-c          -- Unicode normalization form C
+#      unicode-form-kc         -- Unicode normalization form KC
+#
+# syntax)
+#      nameprep-normalize <scheme> ...
+#
+# If multiple schemes are specified, they are applied in turn.
+#
+#nameprep-normalize nameprep-03
+
+#
+# `nameprep-prohibit' entry specifies the prohibited characters in the
+# NAMEPREP process.  The following sets are recognized.
+#
+#      <nameprep version>      -- nameprep version
+#      fileset:<pathname>      -- read definition from a file.
+#
+# syntax)
+#      nameprep-prohibit <set> ...
+#
+# If multiple sets are specified, they are applied in turn.
+#
+#nameprep-prohibit nameprep-03
+
+#
+# `nameprep-unassigned' entry specifies the unassigned characters in the
+# NAMEPREP process.  The following sets are recognized.
+#
+#      <nameprep version>      -- nameprep version
+#      fileset:<pathname>      -- read definition from a file.
+#
+# syntax)
+#      nameprep-prohibit <set> ...
+#
+# If multiple sets are specified, they are applied in turn.
+#
+#nameprep-unassigned nameprep-03
+
+#
+# `alternate-encoding' entry specifies the alternative encoding to use in
+# case of the conversion from IDN encoding to the application's local
+# encoding fails due to the lack of certain character in the character set
+# of the local encoding.  The alternative encoding must be ASCII compatible
+# encoding (ACE).
+#
+# syntax)
+#      alternate-encoding <encoding>
+#
+alternate-encoding RACE
+
+#
+# `encoding-alias-file' specifies the file which defines encoding name 
+# aliases.
+#
+# syntax)
+#      encoding-alais-file <pathname>
+#
+#encoding-alias-file /some/where/mdnalias.txt
+
+#
+# `local-map' entry specifies TLD (top level domain) based local mapping
+# schemes, which is performed before NAMEPREP.  Available schemes of
+# `local-map' are the same as those of the `nameprep-map' entry.
+# 
+# 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
+
+#
+# `delimiter-map' entry specifies local domain name delimiters mapped to
+# `.'.
+#
+# syntax)
+#      delimiter-map <unicode codepoint> ...
+#
+#[jp] delimiter-map U+3002 U+FF0E
diff --git a/contrib/idn/mdnkit/lib/mdnres.conf.sample b/contrib/idn/mdnkit/lib/mdnres.conf.sample
deleted file mode 100644 (file)
index 78a141b..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-# $Id: mdnres.conf.sample,v 1.6 2000/11/22 06:57:31 ishisone Exp $
-#
-# A sample file for mDNkit's resolver configuration file (mdnres.conf)
-#
-
-#
-# The following line specifies the encoding which DNS protocol uses,
-# such as RACE or UTF-8.
-# Note that the application's local encoding is determined from its
-# locale, so there is no 'client-encoding' line.
-#
-server-encoding RACE
-
-#
-# If the server-encoding needs ZLD (zero level domain).  Use the following
-# line to spcify.  Note that you must enable ZLD feature (by giving
-# "--enable-zld" option to the configure script) to use it.
-#
-# server-zld zld.to.be.used
-
-#
-# The following line specifies the normalization scheme(s) to be used.
-# If two or more shemes are specified, they are applied in order
-# (from left to right).  The available shmemes are:
-#      ascii-lowercase         -- ASCII uppercase letters to lowercase
-#      ascii-uppercase         -- ASCII lowercase letters to uppercase
-#      unicode-lowercase       -- Unicode uppercase letters to lowercase
-#      unicode-uppercase       -- Unicode lowercase letters to uppercase
-#      unicode-form-c          -- Unicode normalization form C
-#      unicode-form-kc         -- Unicode normalization form KC
-#      ja-kana-fullwidth       -- Japanese halfwidth kana letters to fullwidth
-#      ja-alnum-halfwidth      -- Fullwidth alphabets, digits and minus sign
-#                                 to halfwidth
-#      ja-compose-voiced-sound -- Combine Japanese fullwidth kana and the
-#                                 following (semi) voiced sound mark
-#      ja-minus-hack           -- Japanse fullwidth minus sign to '-'
-#
-normalize unicode-lowercase unicode-form-kc
-
-#
-# The following line specifies the alternative encoding to use in case
-# the conversion from DNS protocol encoding to the application's local
-# encoding fails due to the lack of certain character in the character
-# set of the local encoding.
-# The alternative encoding must be an ASCII-compatible encoding (ACE).
-#
-alternate-encoding RACE
-
-#
-# You can add alias names to the encoding (codeset) names.  The following
-# line specifies the pathname of the alias definition file.
-#
-# alias-file /some/where/mdnalias.txt
index 55dd8be0dcd34d84ffe4c9ef566863b8bb804600..e1294bdd0f537c3945d626a55f2386114119c5af 100644 (file)
@@ -1,9 +1,10 @@
 #ifndef lint
-static char *rcsid = "$Id: msgtrans.c,v 1.22 2000/11/21 02:09:05 ishisone Exp $";
+static char *rcsid = "$Id: msgtrans.c,v 1.24 2001/02/21 05:54:17 m-kasahr Exp $";
 #endif
 
 /*
- * Copyright (c) 2000 Japan Network Information Center.  All rights reserved.
+ * 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.
  * 
@@ -72,22 +73,44 @@ static char *rcsid = "$Id: msgtrans.c,v 1.22 2000/11/21 02:09:05 ishisone Exp $"
 #include <errno.h>
 #include <sys/types.h>
 #include <netinet/in.h>
+#ifdef HAVE_ARPA_NAMESER_H
 #include <arpa/nameser.h>
+#endif
+#ifdef HAVE_RESOLV_H
 #include <resolv.h>
 #endif
+#endif
 
 #include <mdn/result.h>
 #include <mdn/assert.h>
 #include <mdn/logmacro.h>
 #include <mdn/converter.h>
 #include <mdn/normalizer.h>
-#include <mdn/translator.h>
-#include <mdn/zldrule.h>
+#include <mdn/res.h>
 #include <mdn/msgheader.h>
 #include <mdn/msgtrans.h>
 #include <mdn/dn.h>
 #include <mdn/debug.h>
 
+/*
+ * Name translation instructions.
+ *
+ * For query, perform
+ *   1. local encoding to UTF-8 conversion
+ *   2. delimiter mapping
+ *   3. local mapping
+ *   4. nameprep
+ *   5. UTF-8 to IDN encoding conversion
+ *
+ * For reply,
+ *   1. IDN encoding to UTF-8 conversion
+ *   2. UTF-8 to local encoding conversion
+ *
+ * See mdn/res.h for the mnemonic.
+ */
+#define INSN_QUERY     "ldMNI"
+#define INSN_REPLY     "iL"
+
 #define DNS_HEADER_SIZE                12
 #define DNAME_SIZE             512
 #define RRFORMAT_HASH_SIZE     47
@@ -142,16 +165,16 @@ enum {
 };
 
 typedef struct msgtrans_ctx {
-       const char *in;                 /* input message */
-       size_t in_len;                  /* length of it */
-       const char *in_ptr;             /* current pointer */
-       size_t in_remain;               /* # of remaining octets */
-       char *out;                      /* output (translated) message */
-       char *out_ptr;                  /* current pointer */
-       size_t out_remain;              /* # of remaining (available) octets */
-       mdn__dn_t dn_ctx;               /* for compression */
-       int determined;                 /* if ZLD/codeset are determined */
-       mdn_msgtrans_param_t *param;    /* translation parameters */
+       char *insn;             /* name translation instruction */
+       const char *in;         /* input message */
+       size_t in_len;          /* length of it */
+       const char *in_ptr;     /* current pointer */
+       size_t in_remain;       /* # of remaining octets */
+       char *out;              /* output (translated) message */
+       char *out_ptr;          /* current pointer */
+       size_t out_remain;      /* # of remaining (available) octets */
+       mdn__dn_t dn_ctx;       /* for compression */
+       mdn_resconf_t conf;     /* translation parameters */
 } msgtrans_ctx_t;
 
 static struct rrformat {
@@ -193,14 +216,14 @@ static mdn_result_t       translate_rdata(msgtrans_ctx_t *ctx,
                                        unsigned int rr_type,
                                        unsigned int rr_class,
                                        unsigned int rr_length);
-static const char      *rdata_format(unsigned int rr_type, unsigned int rr_class);
+static const char      *rdata_format(unsigned int rr_type,
+                                     unsigned int rr_class);
 static mdn_result_t    translate_domain(msgtrans_ctx_t *ctx);
-static mdn_result_t    translate_name(mdn_msgtrans_param_t *param,
-                                      char *from, char *to, size_t tolen);
-static mdn_result_t    get_domainname(msgtrans_ctx_t *ctx, char *buf, size_t bufsize);
+static mdn_result_t    get_domainname(msgtrans_ctx_t *ctx, char *buf,
+                                      size_t bufsize);
 static mdn_result_t    put_domainname(msgtrans_ctx_t *ctx, char *name);
 static void            ctx_init(msgtrans_ctx_t *ctx,
-                                mdn_msgtrans_param_t *param,
+                                mdn_resconf_t conf, mdn_msgheader_t *header,
                                 const char *msg, size_t msglen,
                                 char *outbuf, size_t outbufsize);
 static mdn_result_t    copy_rest(msgtrans_ctx_t *ctx);
@@ -211,20 +234,20 @@ static void               dump_message(const char *title, const char *p,
 
 
 mdn_result_t
-mdn_msgtrans_translate(mdn_msgtrans_param_t *param,
+mdn_msgtrans_translate(mdn_resconf_t conf,
                       const char *msg, size_t msglen,
                       char *outbuf, size_t outbufsize, size_t *outmsglenp)
 {
        mdn_result_t r;
        msgtrans_ctx_t ctx;
        mdn_msgheader_t header;
-       int i;
+       int i, n;
 
-       assert(param != NULL && msg != NULL &&
+       assert(conf != NULL && msg != NULL &&
               outbuf != NULL && outbufsize > 0 && outmsglenp != NULL);
 
        TRACE(("mdn_msgtrans_translate(msg=<%s>,msglen=%d)\n",
-             mdn_debug_hexdata(msg, msglen, 64), msglen));
+              mdn_debug_hexdata(msg, msglen, 64), msglen));
 
        if (LOGLEVEL >= mdn_log_level_dump)
                dump_message("before translation", msg, msglen);
@@ -243,15 +266,15 @@ mdn_msgtrans_translate(mdn_msgtrans_param_t *param,
         */
        if ((r = mdn_msgheader_parse(msg, msglen, &header)) != mdn_success) {
                WARNING(("mdn_msgtrans_translate: message header "
-                       "parsing failed: %s\n",
-                       mdn_result_tostring(r)));
+                        "parsing failed: %s\n",
+                        mdn_result_tostring(r)));
                return (r);
        }
 
        /*
         * Create translation context.
         */
-       ctx_init(&ctx, param, msg, msglen, outbuf, outbufsize);
+       ctx_init(&ctx, conf, &header, msg, msglen, outbuf, outbufsize);
 
        /*
         * We handle only query, notify and update messages.
@@ -278,7 +301,8 @@ mdn_msgtrans_translate(mdn_msgtrans_param_t *param,
        /*
         * Parse question/zone section.
         */
-       for (i = 0; i < header.qdcount; i++) {
+       n = header.qdcount;
+       for (i = 0; i < n; i++) {
                if ((r = translate_question(&ctx)) != mdn_success)
                        return (r);
        }
@@ -286,9 +310,8 @@ mdn_msgtrans_translate(mdn_msgtrans_param_t *param,
        /*
         * Translate other sections.
         */
-       for (i = 0;
-            i < header.ancount + header.nscount + header.arcount;
-            i++) {
+       n = header.ancount + header.nscount + header.arcount;
+       for (i = 0; i < n; i++) {
                if ((r = translate_rr(&ctx)) != mdn_success)
                        return (r);
        }
@@ -319,41 +342,15 @@ copy_header(msgtrans_ctx_t *ctx) {
 static mdn_result_t
 translate_question(msgtrans_ctx_t *ctx) {
        mdn_result_t r;
-       mdn_msgtrans_param_t *param;
        char qname[DNAME_SIZE], qname_translated[DNAME_SIZE];
 
-       param = ctx->param;
-
        /* Get QNAME. */
        if ((r = get_domainname(ctx, qname, sizeof(qname))) != mdn_success)
                return (r);
 
-       if (!ctx->determined) {
-               /*
-                * Determine ZLD and character set/encoding.
-                */
-               r = mdn_zldrule_select(param->local_rule, qname,
-                                      &param->local_zld,
-                                      &param->local_converter);
-               switch (r) {
-               case mdn_success:
-                       ctx->determined = 1;
-                       break;
-               case mdn_notfound:
-                       /*
-                        * No matching ZLD, no default.
-                        */
-                       param->local_zld = NULL;
-                       param->local_converter = NULL;
-                       break;
-               default:
-                       return (r);
-               }
-       }
-
        /* Translate QNAME. */
-       r = translate_name(param, qname, qname_translated,
-                          sizeof(qname_translated));
+       r = mdn_res_nameconv(ctx->conf, ctx->insn, qname,
+                            qname_translated, sizeof(qname_translated));
        if (r != mdn_success)
                return (r);
 
@@ -377,8 +374,8 @@ translate_rr(msgtrans_ctx_t *ctx) {
                return (r);
 
        /* Translate NAME. */
-       r = translate_name(ctx->param, dname, dname_translated,
-                          sizeof(dname_translated));
+       r = mdn_res_nameconv(ctx->conf, ctx->insn, dname,
+                            dname_translated, sizeof(dname_translated));
        if (r != mdn_success)
                return (r);
 
@@ -514,8 +511,8 @@ translate_domain(msgtrans_ctx_t *ctx) {
                return (r);
 
        /* Translate NAME. */
-       r = translate_name(ctx->param, dname, dname_translated,
-                          sizeof(dname_translated));
+       r = mdn_res_nameconv(ctx->conf, ctx->insn, dname,
+                            dname_translated, sizeof(dname_translated));
        if (r != mdn_success)
                return (r);
 
@@ -525,31 +522,6 @@ translate_domain(msgtrans_ctx_t *ctx) {
        return (mdn_success);
 }
 
-static mdn_result_t
-translate_name(mdn_msgtrans_param_t *param,
-                    char *from, char *to, size_t tolen)
-{
-       if (param->local_converter == NULL) {
-               /*
-                * No translation is required.
-                */
-               size_t fromlen = strlen(from) + 1;
-               if (fromlen > tolen)
-                       return (mdn_buffer_overflow);
-               (void)memcpy(to, from, fromlen);
-               return (mdn_success);
-       } else {
-               return (mdn_translator_translate(param->local_converter,
-                                                param->local_alt_converter,
-                                                param->local_zld,
-                                                param->normalizer,
-                                                param->target_converter,
-                                                param->target_alt_converter,
-                                                param->target_zld,
-                                                from, to, tolen));
-       }
-}
-
 static mdn_result_t
 get_domainname(msgtrans_ctx_t *ctx, char *buf, size_t bufsize) {
        mdn_result_t r;
@@ -579,16 +551,16 @@ put_domainname(msgtrans_ctx_t *ctx, char *name) {
 }
 
 static void
-ctx_init(msgtrans_ctx_t *ctx, mdn_msgtrans_param_t *param,
+ctx_init(msgtrans_ctx_t *ctx, mdn_resconf_t conf, mdn_msgheader_t *header,
         const char *msg, size_t msglen, char *outbuf, size_t outbufsize)
 {
+       ctx->insn = (header->qr == 0) ? INSN_QUERY : INSN_REPLY;
        ctx->in = ctx->in_ptr = msg;
        ctx->in_len = ctx->in_remain = msglen;
        ctx->out = ctx->out_ptr = outbuf;
        ctx->out_remain = outbufsize;
-       ctx->determined = !param->use_local_rule;
-       ctx->param = param;
        mdn__dn_initcompress(&ctx->dn_ctx, outbuf);
+       ctx->conf = conf;
 }
 
 static mdn_result_t
diff --git a/contrib/idn/mdnkit/lib/nameprep.c b/contrib/idn/mdnkit/lib/nameprep.c
new file mode 100644 (file)
index 0000000..6ef5164
--- /dev/null
@@ -0,0 +1,296 @@
+#ifndef lint
+static char *rcsid = "$Id: nameprep.c,v 1.1 2001/06/09 00:30:19 tale 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+ * Tokyo, 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) Japan Network Information Center.  All rights reserved."
+ * 
+ * 4. Neither the name of JPNIC may 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.
+ * 
+ * 6. Indemnification by Licensee
+ *    Any person or entities using and/or redistributing this Software under
+ *    this License Terms and Conditions shall defend indemnify and hold
+ *    harmless JPNIC from and against any and all judgements damages,
+ *    expenses, settlement liabilities, cost and other liabilities of any
+ *    kind as a result of use and redistribution of this Software or any
+ *    claim, suite, action, litigation or proceeding by any third party
+ *    arising out of or relates to this License Terms and Conditions.
+ * 
+ * 7. Governing Law, Jurisdiction and Venue
+ *    This License Terms and Conditions shall be governed by and and
+ *    construed in accordance with the law of Japan. Any person or entities
+ *    using and/or redistributing this Software under this License Terms and
+ *    Conditions hereby agrees and consent to the personal and exclusive
+ *    jurisdiction and venue of Tokyo District Court of Japan.
+ */
+
+#include <config.h>
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <mdn/result.h>
+#include <mdn/assert.h>
+#include <mdn/log.h>
+#include <mdn/logmacro.h>
+#include <mdn/utf8.h>
+#include <mdn/debug.h>
+#include <mdn/nameprep.h>
+
+#define UCS_MAX                0x7fffffff
+#define UNICODE_MAX    0x10ffff
+
+/*
+ * The latest version.
+ */
+#define NAMEPREP_CURRENT       "nameprep-03"
+
+/*
+ * Load NAMEPREP compiled tables.
+ */
+#include "nameprepdata.c"
+
+/*
+ * Define mapping/checking functions for each version of the draft.
+ */
+
+#define VERSION id02
+#include "nameprep_template.c"
+#undef VERSION
+
+#define VERSION id03
+#include "nameprep_template.c"
+#undef VERSION
+
+typedef char   *(*nameprep_mapproc)(unsigned long v);
+typedef int    (*nameprep_checkproc)(unsigned long v);
+
+static struct mdn_nameprep {
+       char *version;
+       nameprep_mapproc map_proc;
+       nameprep_checkproc prohibited_proc;
+       nameprep_checkproc unassigned_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) }
+       MAKE_NAMEPREP_HANDLE("nameprep-02", id02),
+       MAKE_NAMEPREP_HANDLE("nameprep-03", id03),
+       { NULL, NULL, NULL },
+};
+
+static mdn_result_t    mdn_nameprep_check(nameprep_checkproc proc,
+                                          const char *str,
+                                          const char **found);
+
+mdn_result_t
+mdn_nameprep_create(const char *version, mdn_nameprep_t *handlep) {
+       mdn_nameprep_t handle;
+
+       assert(handlep != NULL);
+
+       TRACE(("mdn_nameprep_create(version=%-.50s)\n",
+              version == NULL ? "<NULL>" : version));
+
+       if (version == NULL)
+               version = 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 (mdn_success);
+               }
+       }
+       return (mdn_notfound);
+}
+
+void
+mdn_nameprep_destroy(mdn_nameprep_t handle) {
+       assert(handle != NULL);
+
+       TRACE(("mdn_nameprep_destroy()\n"));
+
+       /* Nothing to do. */
+}
+
+mdn_result_t
+mdn_nameprep_map(mdn_nameprep_t handle, const char *from,
+                char *to, size_t tolen) {
+       size_t fromlen;
+
+       assert(handle != NULL && from != NULL && to != NULL);
+
+       TRACE(("mdn_nameprep_map(from=\"%s\")\n",
+              mdn_debug_xstring(from, 50)));
+
+       fromlen = strlen(from);
+       while (fromlen > 0) {
+               unsigned long v;
+               int w;
+               char *mapped;
+
+               if ((w = mdn_utf8_getwc(from, fromlen, &v)) == 0)
+                       return (mdn_invalid_encoding);
+
+               if (v > UCS_MAX) {
+                       /* This cannot happen, but just in case.. */
+                       return (mdn_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 < w)
+                               return (mdn_buffer_overflow);
+                       (void)memcpy(to, from, w);
+                       to += w;
+                       tolen -= w;
+               } else {
+                       size_t mappedlen = strlen(mapped);
+
+                       if (tolen < mappedlen)
+                               return (mdn_buffer_overflow);
+                       (void)memcpy(to, mapped, mappedlen);
+                       to += mappedlen;
+                       tolen -= mappedlen;
+               }
+               from += w;
+               fromlen -= w;
+       }
+       if (tolen == 0)
+               return (mdn_buffer_overflow);
+       *to = '\0';
+       return (mdn_success);
+}
+
+mdn_result_t
+mdn_nameprep_isprohibited(mdn_nameprep_t handle, const char *str,
+                         const char **found)
+{
+       assert(handle != NULL && str != NULL && found != NULL);
+
+       TRACE(("mdn_nameprep_isprohibited(str=\"%s\")\n",
+              mdn_debug_xstring(str, 50)));
+
+       return (mdn_nameprep_check(handle->prohibited_proc, str, found));
+}
+               
+mdn_result_t
+mdn_nameprep_isunassigned(mdn_nameprep_t handle, const char *str,
+                         const char **found)
+{
+       assert(handle != NULL && str != NULL && found != NULL);
+
+       TRACE(("mdn_nameprep_isunassigned(str=\"%s\")\n",
+              mdn_debug_xstring(str, 50)));
+
+       return (mdn_nameprep_check(handle->unassigned_proc, str, found));
+}
+               
+static mdn_result_t
+mdn_nameprep_check(nameprep_checkproc proc, const char *str,
+                  const char **found)
+{
+       size_t len;
+
+       len = strlen(str);
+       while (len > 0) {
+               unsigned long v;
+               int w;
+
+               if ((w = mdn_utf8_getwc(str, len, &v)) == 0)
+                       return (mdn_invalid_encoding);
+
+               if (v > UCS_MAX) {
+                       /* This cannot happen, but just in case.. */
+                       return (mdn_invalid_codepoint);
+               } else if (v > UNICODE_MAX) {
+                       /* It is invalid.. */
+                       *found = str;
+                       return (mdn_success);
+               } else if ((*proc)(v)) {
+                       *found = str;
+                       return (mdn_success);
+               }
+
+               str += w;
+               len -= w;
+       }
+       *found = NULL;
+       return (mdn_success);
+}
+
+mdn_result_t
+mdn__nameprep_createproc(const char *parameter, void **handlep) {
+       return mdn_nameprep_create(parameter, (mdn_nameprep_t *)handlep);
+}
+
+void
+mdn__nameprep_destroyproc(void *handle) {
+       mdn_nameprep_destroy((mdn_nameprep_t)handle);
+}
+
+mdn_result_t
+mdn__nameprep_mapproc(void *handle, const char *from, char *to, size_t tolen) {
+       return mdn_nameprep_map((mdn_nameprep_t)handle, from, to, tolen);
+}
+
+mdn_result_t
+mdn__nameprep_prohibitproc(void *handle, const char *str, const char **found) {
+       return mdn_nameprep_isprohibited((mdn_nameprep_t)handle, str, found);
+}
+
+mdn_result_t
+mdn__nameprep_unassignedproc(void *handle, const char *str,
+                            const char **found) {
+       return mdn_nameprep_isunassigned((mdn_nameprep_t)handle, str, found);
+}
+
diff --git a/contrib/idn/mdnkit/lib/nameprep_template.c b/contrib/idn/mdnkit/lib/nameprep_template.c
new file mode 100644 (file)
index 0000000..543fd78
--- /dev/null
@@ -0,0 +1,136 @@
+/* $Id: nameprep_template.c,v 1.1 2001/06/09 00:30:19 tale 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+ * Tokyo, 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) Japan Network Information Center.  All rights reserved."
+ * 
+ * 4. Neither the name of JPNIC may 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.
+ * 
+ * 6. Indemnification by Licensee
+ *    Any person or entities using and/or redistributing this Software under
+ *    this License Terms and Conditions shall defend indemnify and hold
+ *    harmless JPNIC from and against any and all judgements damages,
+ *    expenses, settlement liabilities, cost and other liabilities of any
+ *    kind as a result of use and redistribution of this Software or any
+ *    claim, suite, action, litigation or proceeding by any third party
+ *    arising out of or relates to this License Terms and Conditions.
+ * 
+ * 7. Governing Law, Jurisdiction and Venue
+ *    This License Terms and Conditions shall be governed by and and
+ *    construed in accordance with the law of Japan. Any person or entities
+ *    using and/or redistributing this Software under this License Terms and
+ *    Conditions hereby agrees and consent to the personal and exclusive
+ *    jurisdiction and venue of Tokyo District Court of Japan.
+ */
+
+/*
+ * 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 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 (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);
+       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);
+       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
+}
diff --git a/contrib/idn/mdnkit/lib/nameprepdata.c b/contrib/idn/mdnkit/lib/nameprepdata.c
new file mode 100644 (file)
index 0000000..67b164d
--- /dev/null
@@ -0,0 +1,1694 @@
+/* $Id: nameprepdata.c,v 1.1 2001/06/09 00:30:19 tale Exp $ */
+/* $-Id: generate_nameprep_data.pl,v 1.2 2001/03/05 09:04:36 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
+
+static unsigned short nameprep_id02_map_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,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         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, 
+           0,    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, 
+          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, 
+          31,    32,    33,    34,    35,    36,    37,    38, 
+          39,    40,    41,    42,    43,    44,    45,    46, 
+          47,     0,     0,     0,     0,    48,     0,     0, 
+          49,    50,     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,    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,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,    54,    55,    56,    57,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+          58,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,    59, 
+           0,    60,     0,     0,     0,     0,     0,     0, 
+};
+
+static struct {
+       unsigned short tbl[32];
+} nameprep_id02_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,    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,   53,    0,    0,    0,    0,    0,    0,    0,   54, 
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+       }},
+       {{
+         57,   60,   63,   66,   69,   72,   75,   78,   81,   84,   87, 
+         90,   93,   96,   99,  102,  105,  108,  111,  114,  117,  120, 
+        123,    0,  126,  129,  132,  135,  138,  141,  144,  147, 
+       }},
+       {{
+        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, 
+       }},
+       {{
+        198,    0,  201,    0,  204,    0,  207,    0,  210,    0,  213, 
+          0,  216,    0,  219,    0,   17,   17,  222,    0,  225,    0, 
+        228,    0,    0,  231,    0,  234,    0,  237,    0,  240, 
+       }},
+       {{
+          0,  243,    0,  246,    0,  249,    0,  252,    0,  255,  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,    0,  313,    0,  316,    0,  319,    0,  322,    0, 
+        325,    0,  328,  331,    0,  334,    0,  337,    0,   37, 
+       }},
+       {{
+          0,  340,  343,    0,  346,    0,  349,  352,    0,  355,  358, 
+        361,    0,    0,  364,  367,  370,  373,    0,  376,  379,    0, 
+        382,  385,  388,    0,    0,    0,  391,  394,    0,  397, 
+       }},
+       {{
+        400,    0,  403,    0,  406,    0,  409,  412,    0,  415,    0, 
+          0,  418,    0,  421,  424,    0,  427,  430,  433,    0,  436, 
+          0,  439,  442,    0,    0,    0,  445,    0,    0,    0, 
+       }},
+       {{
+          0,    0,    0,    0,  448,  448,    0,  451,  451,    0,  454, 
+        454,    0,  457,    0,  460,    0,  463,    0,  466,    0,  469, 
+          0,  472,    0,  475,    0,  478,    0,    0,  481,    0, 
+       }},
+       {{
+        484,    0,  487,    0,  490,    0,  493,    0,  496,    0,  499, 
+          0,  502,    0,  505,    0,  508,  512,  512,    0,  515,    0, 
+        518,  521,  524,    0,  527,    0,  530,    0,  533,    0, 
+       }},
+       {{
+        536,    0,  539,    0,  542,    0,  545,    0,  548,    0,  551, 
+          0,  554,    0,  557,    0,  560,    0,  563,    0,  566,    0, 
+        569,    0,  572,    0,  575,    0,  578,    0,  581,    0, 
+       }},
+       {{
+          0,    0,  584,    0,  587,    0,  590,    0,  593,    0,  596, 
+          0,  599,    0,  602,    0,  605,    0,  608,    0,    0,    0, 
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+       }},
+       {{
+          0,    0,    0,    0,    0,  611,    0,    0,    0,    0,    0, 
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+       }},
+       {{
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+          0,    0,    0,    0,  614,    0,    0,    0,    0,    0, 
+       }},
+       {{
+          0,    0,    0,    0,    0,    0,  618,    0,  621,  624,  627, 
+          0,  630,    0,  633,  636,  639,  646,  649,  652,  655,  658, 
+        661,  664,  667,  611,  670,  673,   54,  676,  679,  682, 
+       }},
+       {{
+        685,  688,    0,  691,  694,  697,  700,  703,  706,  709,  712, 
+        715,    0,    0,    0,    0,  718,    0,    0,    0,    0,    0, 
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+       }},
+       {{
+          0,    0,  691,  691,    0,    0,    0,    0,    0,    0,    0, 
+          0,    0,    0,    0,    0,  649,  667,  697,  633,  715,  700, 
+        685,    0,    0,    0,  725,    0,  728,    0,  731,    0, 
+       }},
+       {{
+        734,    0,  737,    0,  740,    0,  743,    0,  746,    0,  749, 
+          0,  752,    0,  755,    0,  670,  688,  691,    0,    0,    0, 
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+       }},
+       {{
+        758,  761,  764,  767,  770,  773,  776,  779,  782,  785,  788, 
+        791,  794,  797,  800,  803,  806,  809,  812,  815,  818,  821, 
+        824,  827,  830,  833,  836,  839,  842,  845,  848,  851, 
+       }},
+       {{
+        854,  857,  860,  863,  866,  869,  872,  875,  878,  881,  884, 
+        887,  890,  893,  896,  899,    0,    0,    0,    0,    0,    0, 
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+       }},
+       {{
+        902,    0,  905,    0,  908,    0,  911,    0,  914,    0,  917, 
+          0,  920,    0,  923,    0,  926,    0,  929,    0,  932,    0, 
+        935,    0,  938,    0,  941,    0,  944,    0,  947,    0, 
+       }},
+       {{
+        950,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+          0,  953,    0,  956,    0,  959,    0,  962,    0,  965,    0, 
+        968,    0,  971,    0,  974,    0,  977,    0,  980,    0, 
+       }},
+       {{
+        983,    0,  986,    0,  989,    0,  992,    0,  995,    0,  998, 
+          0, 1001,    0, 1004,    0, 1007,    0, 1010,    0, 1013,    0, 
+       1016,    0, 1019,    0, 1022,    0, 1025,    0, 1028,    0, 
+       }},
+       {{
+          0, 1031,    0, 1034,    0,    0,    0, 1037,    0,    0,    0, 
+       1040,    0,    0,    0,    0, 1043,    0, 1046,    0, 1049,    0, 
+       1052,    0, 1055,    0, 1058,    0, 1061,    0, 1064,    0, 
+       }},
+       {{
+       1067,    0, 1070,    0, 1073,    0, 1076,    0, 1079,    0, 1082, 
+          0, 1085,    0, 1088,    0, 1091,    0, 1094,    0, 1097,    0, 
+          0,    0, 1100,    0,    0,    0,    0,    0,    0,    0, 
+       }},
+       {{
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+          0,    0,    0,    0,    0,    0, 1103, 1106, 1109, 1112, 1115, 
+       1118, 1121, 1124, 1127, 1130, 1133, 1136, 1139, 1142, 1145, 
+       }},
+       {{
+       1148, 1151, 1154, 1157, 1160, 1163, 1166, 1169, 1172, 1175, 1178, 
+       1181, 1184, 1187, 1190, 1193, 1196, 1199, 1202, 1205, 1208, 1211, 
+       1214,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+       }},
+       {{
+          0,    0,    0,    0,    0,    0,    0, 1217,    0,    0,    0, 
+          0,    0,    0,    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, 
+         53,   53,   53,    0,    0,    0,    0,    0,    0,    0,    0, 
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+       }},
+       {{
+       1222,    0, 1226,    0, 1230,    0, 1234,    0, 1238,    0, 1242, 
+          0, 1246,    0, 1250,    0, 1254,    0, 1258,    0, 1262,    0, 
+       1266,    0, 1270,    0, 1274,    0, 1278,    0, 1282,    0, 
+       }},
+       {{
+       1286,    0, 1290,    0, 1294,    0, 1298,    0, 1302,    0, 1306, 
+          0, 1310,    0, 1314,    0, 1318,    0, 1322,    0, 1326,    0, 
+       1330,    0, 1334,    0, 1338,    0, 1342,    0, 1346,    0, 
+       }},
+       {{
+       1350,    0, 1354,    0, 1358,    0, 1362,    0, 1366,    0, 1370, 
+          0, 1374,    0, 1378,    0, 1382,    0, 1386,    0, 1390,    0, 
+       1394,    0, 1398,    0, 1402,    0, 1406,    0, 1410,    0, 
+       }},
+       {{
+       1414,    0, 1418,    0, 1422,    0, 1426,    0, 1430,    0, 1434, 
+          0, 1438,    0, 1442,    0, 1446,    0, 1450,    0, 1454,    0, 
+       1458,    0, 1462,    0, 1466,    0, 1470,    0, 1474,    0, 
+       }},
+       {{
+       1478,    0, 1482,    0, 1486,    0, 1490,    0, 1494,    0, 1498, 
+          0, 1502,    0, 1506,    0, 1510,    0, 1514,    0, 1518,    0, 
+       1522, 1526, 1530, 1534, 1538, 1414,    0,    0,    0,    0, 
+       }},
+       {{
+       1542,    0, 1546,    0, 1550,    0, 1554,    0, 1558,    0, 1562, 
+          0, 1566,    0, 1570,    0, 1574,    0, 1578,    0, 1582,    0, 
+       1586,    0, 1590,    0, 1594,    0, 1598,    0, 1602,    0, 
+       }},
+       {{
+       1606,    0, 1610,    0, 1614,    0, 1618,    0, 1622,    0, 1626, 
+          0, 1630,    0, 1634,    0, 1638,    0, 1642,    0, 1646,    0, 
+       1650,    0, 1654,    0, 1658,    0, 1662,    0, 1666,    0, 
+       }},
+       {{
+       1670,    0, 1674,    0, 1678,    0, 1682,    0, 1686,    0, 1690, 
+          0, 1694,    0, 1698,    0, 1702,    0, 1706,    0, 1710,    0, 
+       1714,    0, 1718,    0,    0,    0,    0,    0,    0,    0, 
+       }},
+       {{
+          0,    0,    0,    0,    0,    0,    0,    0, 1722, 1726, 1730, 
+       1734, 1738, 1742, 1746, 1750,    0,    0,    0,    0,    0,    0, 
+          0,    0, 1754, 1758, 1762, 1766, 1770, 1774,    0,    0, 
+       }},
+       {{
+          0,    0,    0,    0,    0,    0,    0,    0, 1778, 1782, 1786, 
+       1790, 1794, 1798, 1802, 1806,    0,    0,    0,    0,    0,    0, 
+          0,    0, 1810, 1814, 1818, 1822, 1826, 1830, 1834, 1838, 
+       }},
+       {{
+          0,    0,    0,    0,    0,    0,    0,    0, 1842, 1846, 1850, 
+       1854, 1858, 1862,    0,    0, 1866,    0, 1871,    0, 1878,    0, 
+       1885,    0,    0, 1892,    0, 1896,    0, 1900,    0, 1904, 
+       }},
+       {{
+          0,    0,    0,    0,    0,    0,    0,    0, 1908, 1912, 1916, 
+       1920, 1924, 1928, 1932, 1936,    0,    0,    0,    0,    0,    0, 
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+       }},
+       {{
+       1940, 1946, 1952, 1958, 1964, 1970, 1976, 1982, 1940, 1946, 1952, 
+       1958, 1964, 1970, 1976, 1982, 1988, 1994, 2000, 2006, 2012, 2018, 
+       2024, 2030, 1988, 1994, 2000, 2006, 2012, 2018, 2024, 2030, 
+       }},
+       {{
+       2036, 2042, 2048, 2054, 2060, 2066, 2072, 2078, 2036, 2042, 2048, 
+       2054, 2060, 2066, 2072, 2078,    0,    0, 2084, 2090, 2095,    0, 
+       2100, 2105, 2112, 2116, 2120, 2124, 2090,    0,  611,    0, 
+       }},
+       {{
+          0,    0, 2128, 2134, 2139,    0, 2144, 2149, 2156, 2160, 2164, 
+       2168, 2134,    0,    0,    0,    0,    0, 2172,  639,    0,    0, 
+       2179, 2184, 2191, 2195, 2199, 2203,    0,    0,    0,    0, 
+       }},
+       {{
+          0,    0, 2207,  718, 2214,    0, 2219, 2224, 2231, 2235, 2239, 
+       2243, 2247,    0,    0,    0,    0,    0, 2251, 2257, 2262,    0, 
+       2267, 2272, 2279, 2283, 2287, 2291, 2257,    0,    0,    0, 
+       }},
+       {{
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+         53,   53,   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, 2295,    0,    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, 2298,    0,    0,    0,  370,    0, 2302,    0, 
+         15,   15,   15,    0,    0,   17,   17,   23,    0,    0,   27, 
+       2306,    0,    0,   31,   33,   35,   35,   35,    0,    0, 
+       }},
+       {{
+       2309, 2312, 2316,    0,   51,    0,  709,    0,   51,    0,   21, 
+         72,    3,    5,    0,    0,    9,   11,    0,   25,    0,    0, 
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+       }},
+       {{
+       2319, 2323, 2327, 2331, 2335, 2339, 2343, 2347, 2351, 2355, 2359, 
+       2363, 2367, 2371, 2375, 2379,    0,    0,    0,    0,    0,    0, 
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+       }},
+       {{
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+       2383, 2387, 2391, 2395, 2399, 2403, 2407, 2411, 2415, 2419, 
+       }},
+       {{
+       2423, 2427, 2431, 2435, 2439, 2443, 2447, 2451, 2455, 2459, 2463, 
+       2467, 2471, 2475, 2479, 2483,    0,    0,    0,    0,    0,    0, 
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+       }},
+       {{
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+          0,    0,    0,    0,    0,    0, 2487,    0, 2491,    0, 2494, 
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+       }},
+       {{
+       2497, 2500, 2503, 2507, 2510, 2513, 2516, 2519,    0,    0, 2522, 
+       2525, 2528,    0,    0,    0, 2532, 2535, 2539, 2543, 2547,    0, 
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+       }},
+       {{
+          0,    0,    0,    0,    0,    0,    0,    0,    0, 2497, 2551, 
+       2555, 2559,    0,    0,    0,    0,    0,    0,    0, 2563, 2566, 
+       2569, 2573, 2576, 2573, 2579, 2582, 2585, 2589, 2592, 2589, 
+       }},
+       {{
+       2595, 2599,    0, 2603,    0,    0, 2606, 2613, 2617, 2620,    0, 
+       2623,    0, 2626, 2629,    0,    0,    0,    0,    0,    0,    0, 
+          0, 2632,    0, 2635, 2639,    0, 2642, 2645,    0,    0, 
+       }},
+       {{
+       2648, 2651, 2654, 2657, 2661, 2665, 2665,    0,    0,    0,    0, 
+          0,    0,    0,    0,    0,    0,    0,    0, 2668, 2673, 2678, 
+       2683, 2688,    0,    0,    0,    0,    0,    0,    0,    0, 
+       }},
+       {{
+          0,    0,    0,    0,    0,    0,    0,    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, 2693, 2697, 2701, 2705, 2709, 2713, 2717, 2721, 2725, 2729, 
+       2733, 2737, 2741, 2745, 2749, 2753, 2757, 2761, 2765, 2769, 2773, 
+       2777, 2781, 2785, 2789, 2793,    0,    0,    0,    0,    0, 
+       }},
+};
+
+static unsigned char nameprep_id02_map_data[] = {
+         0,  97,   0,  98,   0,  99,   0, 100,   0, 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,   0, 206, 188,   0, 195, 160,   0, 
+       195, 161,   0, 195, 162,   0, 195, 163,   0, 195, 164,   0, 
+       195, 165,   0, 195, 166,   0, 195, 167,   0, 195, 168,   0, 
+       195, 169,   0, 195, 170,   0, 195, 171,   0, 195, 172,   0, 
+       195, 173,   0, 195, 174,   0, 195, 175,   0, 195, 176,   0, 
+       195, 177,   0, 195, 178,   0, 195, 179,   0, 195, 180,   0, 
+       195, 181,   0, 195, 182,   0, 195, 184,   0, 195, 185,   0, 
+       195, 186,   0, 195, 187,   0, 195, 188,   0, 195, 189,   0, 
+       195, 190,   0, 115, 115,   0, 196, 129,   0, 196, 131,   0, 
+       196, 133,   0, 196, 135,   0, 196, 137,   0, 196, 139,   0, 
+       196, 141,   0, 196, 143,   0, 196, 145,   0, 196, 147,   0, 
+       196, 149,   0, 196, 151,   0, 196, 153,   0, 196, 155,   0, 
+       196, 157,   0, 196, 159,   0, 196, 161,   0, 196, 163,   0, 
+       196, 165,   0, 196, 167,   0, 196, 169,   0, 196, 171,   0, 
+       196, 173,   0, 196, 175,   0, 196, 179,   0, 196, 181,   0, 
+       196, 183,   0, 196, 186,   0, 196, 188,   0, 196, 190,   0, 
+       197, 128,   0, 197, 130,   0, 197, 132,   0, 197, 134,   0, 
+       197, 136,   0, 202, 188, 110,   0, 197, 139,   0, 197, 141, 
+         0, 197, 143,   0, 197, 145,   0, 197, 147,   0, 197, 149, 
+         0, 197, 151,   0, 197, 153,   0, 197, 155,   0, 197, 157, 
+         0, 197, 159,   0, 197, 161,   0, 197, 163,   0, 197, 165, 
+         0, 197, 167,   0, 197, 169,   0, 197, 171,   0, 197, 173, 
+         0, 197, 175,   0, 197, 177,   0, 197, 179,   0, 197, 181, 
+         0, 197, 183,   0, 195, 191,   0, 197, 186,   0, 197, 188, 
+         0, 197, 190,   0, 201, 147,   0, 198, 131,   0, 198, 133, 
+         0, 201, 148,   0, 198, 136,   0, 201, 150,   0, 201, 151, 
+         0, 198, 140,   0, 199, 157,   0, 201, 153,   0, 201, 155, 
+         0, 198, 146,   0, 201, 160,   0, 201, 163,   0, 201, 169, 
+         0, 201, 168,   0, 198, 153,   0, 201, 175,   0, 201, 178, 
+         0, 201, 181,   0, 198, 161,   0, 198, 163,   0, 198, 165, 
+         0, 202, 128,   0, 198, 168,   0, 202, 131,   0, 198, 173, 
+         0, 202, 136,   0, 198, 176,   0, 202, 138,   0, 202, 139, 
+         0, 198, 180,   0, 198, 182,   0, 202, 146,   0, 198, 185, 
+         0, 198, 189,   0, 199, 134,   0, 199, 137,   0, 199, 140, 
+         0, 199, 142,   0, 199, 144,   0, 199, 146,   0, 199, 148, 
+         0, 199, 150,   0, 199, 152,   0, 199, 154,   0, 199, 156, 
+         0, 199, 159,   0, 199, 161,   0, 199, 163,   0, 199, 165, 
+         0, 199, 167,   0, 199, 169,   0, 199, 171,   0, 199, 173, 
+         0, 199, 175,   0, 106, 204, 140,   0, 199, 179,   0, 199, 
+       181,   0, 198, 149,   0, 198, 191,   0, 199, 185,   0, 199, 
+       187,   0, 199, 189,   0, 199, 191,   0, 200, 129,   0, 200, 
+       131,   0, 200, 133,   0, 200, 135,   0, 200, 137,   0, 200, 
+       139,   0, 200, 141,   0, 200, 143,   0, 200, 145,   0, 200, 
+       147,   0, 200, 149,   0, 200, 151,   0, 200, 153,   0, 200, 
+       155,   0, 200, 157,   0, 200, 159,   0, 200, 163,   0, 200, 
+       165,   0, 200, 167,   0, 200, 169,   0, 200, 171,   0, 200, 
+       173,   0, 200, 175,   0, 200, 177,   0, 200, 179,   0, 206, 
+       185,   0,  32, 206, 185,   0, 206, 172,   0, 206, 173,   0, 
+       206, 174,   0, 206, 175,   0, 207, 140,   0, 207, 141,   0, 
+       207, 142,   0, 206, 185, 204, 136, 204, 129,   0, 206, 177, 
+         0, 206, 178,   0, 206, 179,   0, 206, 180,   0, 206, 181, 
+         0, 206, 182,   0, 206, 183,   0, 206, 184,   0, 206, 186, 
+         0, 206, 187,   0, 206, 189,   0, 206, 190,   0, 206, 191, 
+         0, 207, 128,   0, 207, 129,   0, 207, 130,   0, 207, 132, 
+         0, 207, 133,   0, 207, 134,   0, 207, 135,   0, 207, 136, 
+         0, 207, 137,   0, 207, 138,   0, 207, 139,   0, 207, 133, 
+       204, 136, 204, 129,   0, 207, 155,   0, 207, 157,   0, 207, 
+       159,   0, 207, 161,   0, 207, 163,   0, 207, 165,   0, 207, 
+       167,   0, 207, 169,   0, 207, 171,   0, 207, 173,   0, 207, 
+       175,   0, 209, 144,   0, 209, 145,   0, 209, 146,   0, 209, 
+       147,   0, 209, 148,   0, 209, 149,   0, 209, 150,   0, 209, 
+       151,   0, 209, 152,   0, 209, 153,   0, 209, 154,   0, 209, 
+       155,   0, 209, 156,   0, 209, 157,   0, 209, 158,   0, 209, 
+       159,   0, 208, 176,   0, 208, 177,   0, 208, 178,   0, 208, 
+       179,   0, 208, 180,   0, 208, 181,   0, 208, 182,   0, 208, 
+       183,   0, 208, 184,   0, 208, 185,   0, 208, 186,   0, 208, 
+       187,   0, 208, 188,   0, 208, 189,   0, 208, 190,   0, 208, 
+       191,   0, 209, 128,   0, 209, 129,   0, 209, 130,   0, 209, 
+       131,   0, 209, 132,   0, 209, 133,   0, 209, 134,   0, 209, 
+       135,   0, 209, 136,   0, 209, 137,   0, 209, 138,   0, 209, 
+       139,   0, 209, 140,   0, 209, 141,   0, 209, 142,   0, 209, 
+       143,   0, 209, 161,   0, 209, 163,   0, 209, 165,   0, 209, 
+       167,   0, 209, 169,   0, 209, 171,   0, 209, 173,   0, 209, 
+       175,   0, 209, 177,   0, 209, 179,   0, 209, 181,   0, 209, 
+       183,   0, 209, 185,   0, 209, 187,   0, 209, 189,   0, 209, 
+       191,   0, 210, 129,   0, 210, 141,   0, 210, 143,   0, 210, 
+       145,   0, 210, 147,   0, 210, 149,   0, 210, 151,   0, 210, 
+       153,   0, 210, 155,   0, 210, 157,   0, 210, 159,   0, 210, 
+       161,   0, 210, 163,   0, 210, 165,   0, 210, 167,   0, 210, 
+       169,   0, 210, 171,   0, 210, 173,   0, 210, 175,   0, 210, 
+       177,   0, 210, 179,   0, 210, 181,   0, 210, 183,   0, 210, 
+       185,   0, 210, 187,   0, 210, 189,   0, 210, 191,   0, 211, 
+       130,   0, 211, 132,   0, 211, 136,   0, 211, 140,   0, 211, 
+       145,   0, 211, 147,   0, 211, 149,   0, 211, 151,   0, 211, 
+       153,   0, 211, 155,   0, 211, 157,   0, 211, 159,   0, 211, 
+       161,   0, 211, 163,   0, 211, 165,   0, 211, 167,   0, 211, 
+       169,   0, 211, 171,   0, 211, 173,   0, 211, 175,   0, 211, 
+       177,   0, 211, 179,   0, 211, 181,   0, 211, 185,   0, 213, 
+       161,   0, 213, 162,   0, 213, 163,   0, 213, 164,   0, 213, 
+       165,   0, 213, 166,   0, 213, 167,   0, 213, 168,   0, 213, 
+       169,   0, 213, 170,   0, 213, 171,   0, 213, 172,   0, 213, 
+       173,   0, 213, 174,   0, 213, 175,   0, 213, 176,   0, 213, 
+       177,   0, 213, 178,   0, 213, 179,   0, 213, 180,   0, 213, 
+       181,   0, 213, 182,   0, 213, 183,   0, 213, 184,   0, 213, 
+       185,   0, 213, 186,   0, 213, 187,   0, 213, 188,   0, 213, 
+       189,   0, 213, 190,   0, 213, 191,   0, 214, 128,   0, 214, 
+       129,   0, 214, 130,   0, 214, 131,   0, 214, 132,   0, 214, 
+       133,   0, 214, 134,   0, 213, 165, 214, 130,   0, 225, 184, 
+       129,   0, 225, 184, 131,   0, 225, 184, 133,   0, 225, 184, 
+       135,   0, 225, 184, 137,   0, 225, 184, 139,   0, 225, 184, 
+       141,   0, 225, 184, 143,   0, 225, 184, 145,   0, 225, 184, 
+       147,   0, 225, 184, 149,   0, 225, 184, 151,   0, 225, 184, 
+       153,   0, 225, 184, 155,   0, 225, 184, 157,   0, 225, 184, 
+       159,   0, 225, 184, 161,   0, 225, 184, 163,   0, 225, 184, 
+       165,   0, 225, 184, 167,   0, 225, 184, 169,   0, 225, 184, 
+       171,   0, 225, 184, 173,   0, 225, 184, 175,   0, 225, 184, 
+       177,   0, 225, 184, 179,   0, 225, 184, 181,   0, 225, 184, 
+       183,   0, 225, 184, 185,   0, 225, 184, 187,   0, 225, 184, 
+       189,   0, 225, 184, 191,   0, 225, 185, 129,   0, 225, 185, 
+       131,   0, 225, 185, 133,   0, 225, 185, 135,   0, 225, 185, 
+       137,   0, 225, 185, 139,   0, 225, 185, 141,   0, 225, 185, 
+       143,   0, 225, 185, 145,   0, 225, 185, 147,   0, 225, 185, 
+       149,   0, 225, 185, 151,   0, 225, 185, 153,   0, 225, 185, 
+       155,   0, 225, 185, 157,   0, 225, 185, 159,   0, 225, 185, 
+       161,   0, 225, 185, 163,   0, 225, 185, 165,   0, 225, 185, 
+       167,   0, 225, 185, 169,   0, 225, 185, 171,   0, 225, 185, 
+       173,   0, 225, 185, 175,   0, 225, 185, 177,   0, 225, 185, 
+       179,   0, 225, 185, 181,   0, 225, 185, 183,   0, 225, 185, 
+       185,   0, 225, 185, 187,   0, 225, 185, 189,   0, 225, 185, 
+       191,   0, 225, 186, 129,   0, 225, 186, 131,   0, 225, 186, 
+       133,   0, 225, 186, 135,   0, 225, 186, 137,   0, 225, 186, 
+       139,   0, 225, 186, 141,   0, 225, 186, 143,   0, 225, 186, 
+       145,   0, 225, 186, 147,   0, 225, 186, 149,   0, 104, 204, 
+       177,   0, 116, 204, 136,   0, 119, 204, 138,   0, 121, 204, 
+       138,   0,  97, 202, 190,   0, 225, 186, 161,   0, 225, 186, 
+       163,   0, 225, 186, 165,   0, 225, 186, 167,   0, 225, 186, 
+       169,   0, 225, 186, 171,   0, 225, 186, 173,   0, 225, 186, 
+       175,   0, 225, 186, 177,   0, 225, 186, 179,   0, 225, 186, 
+       181,   0, 225, 186, 183,   0, 225, 186, 185,   0, 225, 186, 
+       187,   0, 225, 186, 189,   0, 225, 186, 191,   0, 225, 187, 
+       129,   0, 225, 187, 131,   0, 225, 187, 133,   0, 225, 187, 
+       135,   0, 225, 187, 137,   0, 225, 187, 139,   0, 225, 187, 
+       141,   0, 225, 187, 143,   0, 225, 187, 145,   0, 225, 187, 
+       147,   0, 225, 187, 149,   0, 225, 187, 151,   0, 225, 187, 
+       153,   0, 225, 187, 155,   0, 225, 187, 157,   0, 225, 187, 
+       159,   0, 225, 187, 161,   0, 225, 187, 163,   0, 225, 187, 
+       165,   0, 225, 187, 167,   0, 225, 187, 169,   0, 225, 187, 
+       171,   0, 225, 187, 173,   0, 225, 187, 175,   0, 225, 187, 
+       177,   0, 225, 187, 179,   0, 225, 187, 181,   0, 225, 187, 
+       183,   0, 225, 187, 185,   0, 225, 188, 128,   0, 225, 188, 
+       129,   0, 225, 188, 130,   0, 225, 188, 131,   0, 225, 188, 
+       132,   0, 225, 188, 133,   0, 225, 188, 134,   0, 225, 188, 
+       135,   0, 225, 188, 144,   0, 225, 188, 145,   0, 225, 188, 
+       146,   0, 225, 188, 147,   0, 225, 188, 148,   0, 225, 188, 
+       149,   0, 225, 188, 160,   0, 225, 188, 161,   0, 225, 188, 
+       162,   0, 225, 188, 163,   0, 225, 188, 164,   0, 225, 188, 
+       165,   0, 225, 188, 166,   0, 225, 188, 167,   0, 225, 188, 
+       176,   0, 225, 188, 177,   0, 225, 188, 178,   0, 225, 188, 
+       179,   0, 225, 188, 180,   0, 225, 188, 181,   0, 225, 188, 
+       182,   0, 225, 188, 183,   0, 225, 189, 128,   0, 225, 189, 
+       129,   0, 225, 189, 130,   0, 225, 189, 131,   0, 225, 189, 
+       132,   0, 225, 189, 133,   0, 207, 133, 204, 147,   0, 207, 
+       133, 204, 147, 204, 128,   0, 207, 133, 204, 147, 204, 129, 
+         0, 207, 133, 204, 147, 205, 130,   0, 225, 189, 145,   0, 
+       225, 189, 147,   0, 225, 189, 149,   0, 225, 189, 151,   0, 
+       225, 189, 160,   0, 225, 189, 161,   0, 225, 189, 162,   0, 
+       225, 189, 163,   0, 225, 189, 164,   0, 225, 189, 165,   0, 
+       225, 189, 166,   0, 225, 189, 167,   0, 225, 188, 128, 206, 
+       185,   0, 225, 188, 129, 206, 185,   0, 225, 188, 130, 206, 
+       185,   0, 225, 188, 131, 206, 185,   0, 225, 188, 132, 206, 
+       185,   0, 225, 188, 133, 206, 185,   0, 225, 188, 134, 206, 
+       185,   0, 225, 188, 135, 206, 185,   0, 225, 188, 160, 206, 
+       185,   0, 225, 188, 161, 206, 185,   0, 225, 188, 162, 206, 
+       185,   0, 225, 188, 163, 206, 185,   0, 225, 188, 164, 206, 
+       185,   0, 225, 188, 165, 206, 185,   0, 225, 188, 166, 206, 
+       185,   0, 225, 188, 167, 206, 185,   0, 225, 189, 160, 206, 
+       185,   0, 225, 189, 161, 206, 185,   0, 225, 189, 162, 206, 
+       185,   0, 225, 189, 163, 206, 185,   0, 225, 189, 164, 206, 
+       185,   0, 225, 189, 165, 206, 185,   0, 225, 189, 166, 206, 
+       185,   0, 225, 189, 167, 206, 185,   0, 225, 189, 176, 206, 
+       185,   0, 206, 177, 206, 185,   0, 206, 172, 206, 185,   0, 
+       206, 177, 205, 130,   0, 206, 177, 205, 130, 206, 185,   0, 
+       225, 190, 176,   0, 225, 190, 177,   0, 225, 189, 176,   0, 
+       225, 189, 177,   0, 225, 189, 180, 206, 185,   0, 206, 183, 
+       206, 185,   0, 206, 174, 206, 185,   0, 206, 183, 205, 130, 
+         0, 206, 183, 205, 130, 206, 185,   0, 225, 189, 178,   0, 
+       225, 189, 179,   0, 225, 189, 180,   0, 225, 189, 181,   0, 
+       206, 185, 204, 136, 204, 128,   0, 206, 185, 205, 130,   0, 
+       206, 185, 204, 136, 205, 130,   0, 225, 191, 144,   0, 225, 
+       191, 145,   0, 225, 189, 182,   0, 225, 189, 183,   0, 207, 
+       133, 204, 136, 204, 128,   0, 207, 129, 204, 147,   0, 207, 
+       133, 205, 130,   0, 207, 133, 204, 136, 205, 130,   0, 225, 
+       191, 160,   0, 225, 191, 161,   0, 225, 189, 186,   0, 225, 
+       189, 187,   0, 225, 191, 165,   0, 225, 189, 188, 206, 185, 
+         0, 207, 137, 206, 185,   0, 207, 142, 206, 185,   0, 207, 
+       137, 205, 130,   0, 207, 137, 205, 130, 206, 185,   0, 225, 
+       189, 184,   0, 225, 189, 185,   0, 225, 189, 188,   0, 225, 
+       189, 189,   0, 114, 115,   0, 194, 176,  99,   0, 194, 176, 
+       102,   0, 110, 111,   0, 115, 109,   0, 116, 101, 108,   0, 
+       116, 109,   0, 226, 133, 176,   0, 226, 133, 177,   0, 226, 
+       133, 178,   0, 226, 133, 179,   0, 226, 133, 180,   0, 226, 
+       133, 181,   0, 226, 133, 182,   0, 226, 133, 183,   0, 226, 
+       133, 184,   0, 226, 133, 185,   0, 226, 133, 186,   0, 226, 
+       133, 187,   0, 226, 133, 188,   0, 226, 133, 189,   0, 226, 
+       133, 190,   0, 226, 133, 191,   0, 226, 147, 144,   0, 226, 
+       147, 145,   0, 226, 147, 146,   0, 226, 147, 147,   0, 226, 
+       147, 148,   0, 226, 147, 149,   0, 226, 147, 150,   0, 226, 
+       147, 151,   0, 226, 147, 152,   0, 226, 147, 153,   0, 226, 
+       147, 154,   0, 226, 147, 155,   0, 226, 147, 156,   0, 226, 
+       147, 157,   0, 226, 147, 158,   0, 226, 147, 159,   0, 226, 
+       147, 160,   0, 226, 147, 161,   0, 226, 147, 162,   0, 226, 
+       147, 163,   0, 226, 147, 164,   0, 226, 147, 165,   0, 226, 
+       147, 166,   0, 226, 147, 167,   0, 226, 147, 168,   0, 226, 
+       147, 169,   0, 104, 112,  97,   0,  97, 117,   0, 111, 118, 
+         0, 112,  97,   0, 110,  97,   0, 206, 188,  97,   0, 109, 
+        97,   0, 107,  97,   0, 107,  98,   0, 109,  98,   0, 103, 
+        98,   0, 112, 102,   0, 110, 102,   0, 206, 188, 102,   0, 
+       104, 122,   0, 107, 104, 122,   0, 109, 104, 122,   0, 103, 
+       104, 122,   0, 116, 104, 122,   0, 107, 112,  97,   0, 109, 
+       112,  97,   0, 103, 112,  97,   0, 112, 118,   0, 110, 118, 
+         0, 206, 188, 118,   0, 109, 118,   0, 107, 118,   0, 112, 
+       119,   0, 110, 119,   0, 206, 188, 119,   0, 109, 119,   0, 
+       107, 119,   0, 107, 207, 137,   0, 109, 207, 137,   0,  98, 
+       113,   0,  99, 226, 136, 149, 107, 103,   0,  99, 111,  46, 
+         0, 100,  98,   0, 103, 121,   0, 104, 112,   0, 107, 107, 
+         0, 107, 109,   0, 112, 104,   0, 112, 112, 109,   0, 112, 
+       114,   0, 115, 118,   0, 119,  98,   0, 102, 102,   0, 102, 
+       105,   0, 102, 108,   0, 102, 102, 105,   0, 102, 102, 108, 
+         0, 115, 116,   0, 213, 180, 213, 182,   0, 213, 180, 213, 
+       165,   0, 213, 180, 213, 171,   0, 213, 190, 213, 182,   0, 
+       213, 180, 213, 173,   0, 239, 189, 129,   0, 239, 189, 130, 
+         0, 239, 189, 131,   0, 239, 189, 132,   0, 239, 189, 133, 
+         0, 239, 189, 134,   0, 239, 189, 135,   0, 239, 189, 136, 
+         0, 239, 189, 137,   0, 239, 189, 138,   0, 239, 189, 139, 
+         0, 239, 189, 140,   0, 239, 189, 141,   0, 239, 189, 142, 
+         0, 239, 189, 143,   0, 239, 189, 144,   0, 239, 189, 145, 
+         0, 239, 189, 146,   0, 239, 189, 147,   0, 239, 189, 148, 
+         0, 239, 189, 149,   0, 239, 189, 150,   0, 239, 189, 151, 
+         0, 239, 189, 152,   0, 239, 189, 153,   0, 239, 189, 154, 
+         0, 
+};
+
+static unsigned short nameprep_id02_prohibited_imap[] = {
+          68,   196,   196,   324,   196,   196,   196,   452, 
+         196,   196,   196,   452,   196,   196,   196,   452, 
+         196,   196,   196,   452,   196,   196,   196,   452, 
+         196,   196,   196,   452,   196,   196,   196,   452, 
+         196,   196,   196,   452,   196,   196,   196,   452, 
+         196,   196,   196,   452,   196,   196,   196,   452, 
+         196,   196,   196,   452,   196,   196,   196,   452, 
+         196,   196,   196,   452,   580,   580,   580,   580, 
+         580,   580,   580,   580,     0,     1,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     3,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     4,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     5,     3,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     6,     6,     6,     6, 
+           6,     6,     6,     6,     6,     6,     6,     6, 
+           6,     6,     6,     6,     6,     6,     6,     6, 
+           6,     6,     6,     6,     6,     6,     6,     6, 
+           6,     6,     6,     6,     6,     6,     6,     6, 
+           6,     6,     6,     6,     6,     6,     6,     6, 
+           6,     6,     6,     6,     6,     6,     6,     6, 
+           6,     6,     6,     6,     6,     6,     6,     6, 
+           6,     6,     6,     6,     6,     6,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     7,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     8,     6,     6,     6,     6, 
+           6,     6,     6,     6,     6,     6,     6,     6, 
+           6,     6,     6,     6,     6,     6,     6,     6, 
+           6,     6,     6,     6,     6,     6,     6,     6, 
+           6,     6,     6,     6,     6,     6,     6,     6, 
+           6,     6,     6,     6,     6,     6,     6,     6, 
+           6,     6,     6,     6,     6,     6,     6,     6, 
+           6,     6,     6,     6,     6,     6,     6,     6, 
+           6,     6,     6,     6,     6,     6,     6,     6, 
+           6,     6,     6,     6,     6,     6,     6,     6, 
+           6,     6,     6,     6,     6,     6,     6,     6, 
+           6,     6,     6,     6,     6,     6,     6,     6, 
+           6,     6,     6,     6,     6,     6,     6,     6, 
+           6,     6,     6,     6,     6,     6,     6,     6, 
+           6,     6,     6,     6,     6,     6,     6,     6, 
+           6,     6,     6,     6,     6,     6,     6,     6, 
+           6,     6,     6,     6, 
+};
+
+static struct {
+       unsigned char bm[16];
+} nameprep_id02_prohibited_bitmap[] = {
+       {{
+       255,255,255,255,255,223,  0,252,  1,  0,  0,248,  1,  0,  0,248,
+       }},
+       {{
+       255,255,255,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,
+       }},
+       {{
+         1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
+       }},
+       {{
+       255,207,  0,  0,  0,255,  0,  0,  0,  0,  0,  0,  0,252,  0,  0,
+       }},
+       {{
+         0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,255,255,
+       }},
+       {{
+       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,  0,  0,  0,  0,  0,254,
+       }},
+       {{
+         0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,192,
+       }},
+};
+static unsigned short nameprep_id02_unassigned_imap[] = {
+          68,   196,   324,   452,   580,   580,   580,   708, 
+         580,   580,   580,   708,   580,   580,   580,   708, 
+         580,   580,   580,   708,   580,   580,   580,   708, 
+         580,   580,   580,   708,   580,   580,   580,   708, 
+         580,   580,   580,   708,   580,   580,   580,   708, 
+         580,   580,   580,   708,   580,   580,   580,   708, 
+         580,   580,   580,   708,   580,   580,   580,   708, 
+         580,   580,   580,   708,   836,   836,   836,   836, 
+         836,   836,   836,   836,     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,    12,    38,    39,    40,    12,    12, 
+          12,    12,    12,    12,    12,    12,    12,    12, 
+           0,    41,    42,    43,    44,    45,    46,    47, 
+           0,    48,    49,    50,    51,    52,     0,    53, 
+          54,    12,    55,    56,     0,     0,    12,    12, 
+          12,    12,    12,    12,    12,    12,    12,    12, 
+          12,    57,     0,    58,    59,    60,    61,    62, 
+          63,    64,    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,    67, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,    68,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,    69,    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,    70,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+          71,    12,    72,    73,     0,     0,    74,    75, 
+          76,    77,    78,    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,    80,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     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 struct {
+       unsigned char bm[16];
+} nameprep_id02_unassigned_bitmap[] = {
+       {{
+         0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
+       }},
+       {{
+         0,  0,  0,  0,  3,  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,128,255,255,248,255,207,187,
+       }},
+       {{
+        15, 40,  0,  0,  4,  0,  0,  0,  0,128,  0,  3,  0,  0,240,255,
+       }},
+       {{
+       128, 12,  0,  0,  0,  0,  0,  0, 96,230,  0,  0,  0,  0,192,252,
+       }},
+       {{
+       255,255,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,192,  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,254,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,128,247,
+       }},
+       {{
+         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,  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,128,192,255,255,255,  3, 14,  0,
+       }},
+       {{
+         0,128,255,255,  0,  0,255,255,255,255,  0,  0,240,255,255,255,
+       }},
+       {{
+         0,  0,  0,  0,  0,  0,  0,248,255,255,  7,  0,  0,  0,  0,  0,
+       }},
+       {{
+       240,255,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,240,255,
+       }},
+       {{
+         0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,252,255,
+       }},
+       {{
+         0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 16,
+       }},
+       {{
+         0,  0,  0,248,255,255,255,255,255,255,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,248,255,255,
+       }},
+       {{
+         0,  0,192,255,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,255,
+       }},
+       {{
+         0,  0,240,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,252,255,
+       }},
+       {{
+        33, 12,  0,  0,  0,  1,  0,  0,  0, 80,184,128,  1,255, 63,  0,
+       }},
+       {{
+         0,  0,224,  0,  0,  0,  1,128,255,255,255,255,255,255,255,255,
+       }},
+       {{
+         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, 56,  1,  0,  0,  0,  0,  0,  0,  0,
+       }},
+       {{
+         0,  0,224,129,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,128,
+       }},
+       {{
+        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,255,255,
+       }},
+       {{
+         0,  0,  0,224,  0,  0,  0,  0,240,255,255,255,  0,  0,  0,112,
+       }},
+       {{
+         0,  0,  0,  0,  0,  0,254,255,  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, 12,  0, 16,  0,162,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,255,255,255,255,255,255,255,255,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,240,
+       }},
+       {{
+       255,255,255,255,240,255,  0,  0,224,  1,  8,  0,128,240, 40,  0,
+       }},
+       {{
+         0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 96,
+       }},
+       {{
+         1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,128,  1,  0,  0,  0,
+       }},
+       {{
+         0,  0,  0,  0,  0,  0,  0,128,  3,  3,  3,227,128,128,255,  1,
+       }},
+       {{
+       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, 63,
+       }},
+};
+#define nameprep_id03_map_imap nameprep_id02_map_imap
+#define nameprep_id03_map_table        nameprep_id02_map_table
+#define nameprep_id03_map_data nameprep_id02_map_data
+
+static unsigned short nameprep_id03_prohibited_imap[] = {
+          68,   196,   196,   324,   196,   196,   196,   452, 
+         196,   196,   196,   452,   196,   196,   196,   452, 
+         196,   196,   196,   452,   196,   196,   196,   452, 
+         196,   196,   196,   452,   196,   196,   196,   452, 
+         196,   196,   196,   452,   196,   196,   196,   452, 
+         196,   196,   196,   452,   196,   196,   196,   452, 
+         196,   196,   196,   452,   196,   196,   196,   452, 
+         196,   196,   196,   452,   580,   580,   580,   580, 
+         580,   580,   580,   580,     0,     1,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     3,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     4,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     5,     6,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     7,     7,     7,     7, 
+           7,     7,     7,     7,     7,     7,     7,     7, 
+           7,     7,     7,     7,     7,     7,     7,     7, 
+           7,     7,     7,     7,     7,     7,     7,     7, 
+           7,     7,     7,     7,     7,     7,     7,     7, 
+           7,     7,     7,     7,     7,     7,     7,     7, 
+           7,     7,     7,     7,     7,     7,     7,     7, 
+           7,     7,     7,     7,     7,     7,     7,     7, 
+           7,     7,     7,     7,     7,     7,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     8,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     2,     2,     2,     2,     2, 
+           2,     2,     2,     9,     7,     7,     7,     7, 
+           7,     7,     7,     7,     7,     7,     7,     7, 
+           7,     7,     7,     7,     7,     7,     7,     7, 
+           7,     7,     7,     7,     7,     7,     7,     7, 
+           7,     7,     7,     7,     7,     7,     7,     7, 
+           7,     7,     7,     7,     7,     7,     7,     7, 
+           7,     7,     7,     7,     7,     7,     7,     7, 
+           7,     7,     7,     7,     7,     7,     7,     7, 
+           7,     7,     7,     7,     7,     7,     7,     7, 
+           7,     7,     7,     7,     7,     7,     7,     7, 
+           7,     7,     7,     7,     7,     7,     7,     7, 
+           7,     7,     7,     7,     7,     7,     7,     7, 
+           7,     7,     7,     7,     7,     7,     7,     7, 
+           7,     7,     7,     7,     7,     7,     7,     7, 
+           7,     7,     7,     7,     7,     7,     7,     7, 
+           7,     7,     7,     7,     7,     7,     7,     7, 
+           7,     7,     7,     7, 
+};
+
+static struct {
+       unsigned char bm[16];
+} nameprep_id03_prohibited_bitmap[] = {
+       {{
+       255,255,255,255,255,223,  0,252,  1,  0,  0,248,  1,  0,  0,248,
+       }},
+       {{
+       255,255,255,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,
+       }},
+       {{
+         1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
+       }},
+       {{
+       255,207,  0,  0,  0,255,  0,  0,  0,  0,  0,  0,  0,252,  0,  0,
+       }},
+       {{
+         0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,255,255,
+       }},
+       {{
+         5,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
+       }},
+       {{
+       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,  0,  0,  0,  0,  0,254,
+       }},
+       {{
+         0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,192,
+       }},
+};
+static unsigned short nameprep_id03_unassigned_imap[] = {
+          68,   196,   324,   452,   580,   580,   580,   708, 
+         580,   580,   580,   708,   580,   580,   580,   708, 
+         580,   580,   580,   708,   580,   580,   580,   708, 
+         580,   580,   580,   708,   580,   580,   580,   708, 
+         580,   580,   580,   708,   580,   580,   580,   708, 
+         580,   580,   580,   708,   580,   580,   580,   708, 
+         580,   580,   580,   708,   580,   580,   580,   708, 
+         580,   580,   580,   708,   836,   836,   836,   836, 
+         836,   836,   836,   836,     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,    12,    38,    39,    40,    12,    12, 
+          12,    12,    12,    12,    12,    12,    12,    12, 
+           0,    41,    42,    43,    44,    45,    46,    47, 
+           0,    48,    49,    50,    51,    52,     0,    53, 
+          54,    12,    55,    56,     0,     0,    12,    12, 
+          12,    12,    12,    12,    12,    12,    12,    12, 
+          12,    57,     0,    58,    59,    60,    61,    62, 
+          63,    64,    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,    67, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,    68,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,    69,    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,    70,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+          71,    12,    72,    73,     0,     0,    74,    75, 
+          76,    77,    78,    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,    80,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     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 struct {
+       unsigned char bm[16];
+} nameprep_id03_unassigned_bitmap[] = {
+       {{
+         0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
+       }},
+       {{
+         0,  0,  0,  0,  3,  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,128,255,255,248,255,207,187,
+       }},
+       {{
+        15, 40,  0,  0,  4,  0,  0,  0,  0,128,  0,  3,  0,  0,240,255,
+       }},
+       {{
+       128, 12,  0,  0,  0,  0,  0,  0, 96,230,  0,  0,  0,  0,192,252,
+       }},
+       {{
+       255,255,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,192,  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,254,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,128,247,
+       }},
+       {{
+         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,  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,128,192,255,255,255,  3, 14,  0,
+       }},
+       {{
+         0,128,255,255,  0,  0,255,255,255,255,  0,  0,240,255,255,255,
+       }},
+       {{
+         0,  0,  0,  0,  0,  0,  0,248,255,255,  7,  0,  0,  0,  0,  0,
+       }},
+       {{
+       240,255,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,240,255,
+       }},
+       {{
+         0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,252,255,
+       }},
+       {{
+         0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 16,
+       }},
+       {{
+         0,  0,  0,248,255,255,255,255,255,255,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,248,255,255,
+       }},
+       {{
+         0,  0,192,255,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,255,
+       }},
+       {{
+         0,  0,240,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,252,255,
+       }},
+       {{
+        33, 12,  0,  0,  0,  1,  0,  0,  0, 80,184,128,  1,255, 63,  0,
+       }},
+       {{
+         0,  0,224,  0,  0,  0,  1,128,255,255,255,255,255,255,255,255,
+       }},
+       {{
+         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, 56,  1,  0,  0,  0,  0,  0,  0,  0,
+       }},
+       {{
+         0,  0,224,129,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,128,
+       }},
+       {{
+        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,255,255,
+       }},
+       {{
+         0,  0,  0,224,  0,  0,  0,  0,240,255,255,255,  0,  0,  0,112,
+       }},
+       {{
+         0,  0,  0,  0,  0,  0,254,255,  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, 12,  0, 16,  0,162,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,255,255,255,255,255,255,255,255,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,255,255,255,255,  0,240,
+       }},
+       {{
+       255,255,255,255,240,255,  0,  0,224,  1,  8,  0,128,240, 40,  0,
+       }},
+       {{
+         0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 96,
+       }},
+       {{
+         1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,128,  1,  0,  0,  0,
+       }},
+       {{
+         0,  0,  0,  0,  0,  0,  0,128,  3,  3,  3,227,128,128,255,  1,
+       }},
+       {{
+       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, 63,
+       }},
+};
index b48ce5a3e3d59d75f3cadebdb2a5a78ace826249..7e83a584a16abfdd90bc61ab9cdf6190f585850a 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
-static char *rcsid = "$Id: normalizer.c,v 1.16 2000/11/17 06:00:02 ishisone Exp $";
+static char *rcsid = "$Id: normalizer.c,v 1.25 2001/05/31 05:21:37 ishisone Exp $";
 #endif
 
 /*
@@ -77,22 +77,6 @@ static char *rcsid = "$Id: normalizer.c,v 1.16 2000/11/17 06:00:02 ishisone Exp
 #include <mdn/utf8.h>
 #include <mdn/debug.h>
 
-#define UNICODE_IDEOGRAPHIC_FULL_STOP                          0x3002
-#define UNICODE_FULLWIDTH_FULL_STOP                            0xff0e
-#define UNICODE_HALFWIDTH_IDEOGRAPHIC_FULL_STOP                        0xff61
-#define UNICODE_HALFWIDTH_KATAKANA_SEMI_VOICED_SOUND_MARK      0xff9f
-#define UNICODE_MINUS_SIGN                                     0x2212
-#define UNICODE_FULLWIDTH_DIGIT_ZERO                           0xff10
-#define UNICODE_FULLWIDTH_DIGIT_NINE                           0xff19
-#define UNICODE_FULLWIDTH_LATIN_CAPITAL_LETTER_A               0xff21
-#define UNICODE_FULLWIDTH_LATIN_CAPITAL_LETTER_Z               0xff3a
-#define UNICODE_FULLWIDTH_LATIN_SMALL_LETTER_A                 0xff41
-#define UNICODE_FULLWIDTH_LATIN_SMALL_LETTER_Z                 0xff5a
-#define UNICODE_KATAKANA_HIRAGANA_VOICED_SOUND_MARK            0x309b
-#define UNICODE_KATAKANA_HIRAGANA_SEMI_VOICED_SOUND_MARK       0x309c
-#define UNICODE_VOICED_SOUND_CANDIDATE_BEGIN                   0x304b /* ka */
-#define UNICODE_VOICED_SOUND_CANDIDATE_END                     0x30dd /* ho */
-
 #define MAX_LOCAL_SCHEME       3
 
 #define INITIALIZED            (scheme_hash != NULL)
@@ -102,62 +86,15 @@ typedef struct {
        mdn_normalizer_proc_t proc;
 } normalize_scheme_t;
 
+typedef mdn_result_t (*caseconv_proc_t)(unsigned long, mdn__unicode_context_t,
+                                       unsigned long *, size_t, int *);
+
 struct mdn_normalizer {
        int nschemes;
        int scheme_size;
        normalize_scheme_t **schemes;
        normalize_scheme_t *local_buf[MAX_LOCAL_SCHEME];
-};
-
-static unsigned long ja_half_to_full[] = {
-       0x3002, 0x300c, 0x300d, 0x3001, 0x30fb, 0x30f2,
-       0x30a1, 0x30a3, 0x30a5, 0x30a7, 0x30a9, 0x30e3,
-       0x30e5, 0x30e7, 0x30c3, 0x30fc, 0x30a2, 0x30a4,
-       0x30a6, 0x30a8, 0x30aa, 0x30ab, 0x30ad, 0x30af,
-       0x30b1, 0x30b3, 0x30b5, 0x30b7, 0x30b9, 0x30bb,
-       0x30bd, 0x30bf, 0x30c1, 0x30c4, 0x30c6, 0x30c8,
-       0x30ca, 0x30cb, 0x30cc, 0x30cd, 0x30ce, 0x30cf,
-       0x30d2, 0x30d5, 0x30d8, 0x30db, 0x30de, 0x30df,
-       0x30e0, 0x30e1, 0x30e2, 0x30e4, 0x30e6, 0x30e8,
-       0x30e9, 0x30ea, 0x30eb, 0x30ec, 0x30ed, 0x30ef,
-       0x30f3, 0x309b, 0x309c,
-};
-
-typedef struct {
-       unsigned long ucs;
-       unsigned long composed_ucs;
-} voiced_sound_tbl_t;
-
-static voiced_sound_tbl_t ja_voiced_sound[] = {
-       { 0x304b, 0x304c }, { 0x304d, 0x304e }, 
-       { 0x304f, 0x3050 }, { 0x3051, 0x3052 }, 
-       { 0x3053, 0x3054 }, { 0x3055, 0x3056 }, 
-       { 0x3057, 0x3058 }, { 0x3059, 0x305a }, 
-       { 0x305b, 0x305c }, { 0x305d, 0x305e }, 
-       { 0x305f, 0x3060 }, { 0x3061, 0x3062 }, 
-       { 0x3064, 0x3065 }, { 0x3066, 0x3067 }, 
-       { 0x3068, 0x3069 }, { 0x306f, 0x3070 }, 
-       { 0x3072, 0x3073 }, { 0x3075, 0x3076 }, 
-       { 0x3078, 0x3079 }, { 0x307b, 0x307c }, 
-       { 0x30a6, 0x30f4 }, { 0x30ab, 0x30ac }, 
-       { 0x30ad, 0x30ae }, { 0x30af, 0x30b0 }, 
-       { 0x30b1, 0x30b2 }, { 0x30b3, 0x30b4 }, 
-       { 0x30b5, 0x30b6 }, { 0x30b7, 0x30b8 }, 
-       { 0x30b9, 0x30ba }, { 0x30bb, 0x30bc }, 
-       { 0x30bd, 0x30be }, { 0x30bf, 0x30c0 }, 
-       { 0x30c1, 0x30c2 }, { 0x30c4, 0x30c5 }, 
-       { 0x30c6, 0x30c7 }, { 0x30c8, 0x30c9 }, 
-       { 0x30cf, 0x30d0 }, { 0x30d2, 0x30d3 }, 
-       { 0x30d5, 0x30d6 }, { 0x30d8, 0x30d9 }, 
-       { 0x30db, 0x30dc }, 
-};
-
-static voiced_sound_tbl_t ja_semi_voiced_sound[] = {
-       { 0x306f, 0x3071 }, { 0x3072, 0x3074 }, 
-       { 0x3075, 0x3077 }, { 0x3078, 0x307a }, 
-       { 0x307b, 0x307d }, { 0x30cf, 0x30d1 }, 
-       { 0x30d2, 0x30d4 }, { 0x30d5, 0x30d7 }, 
-       { 0x30d8, 0x30da }, { 0x30db, 0x30dd }, 
+       int reference_count;
 };
 
 static mdn_strhash_t scheme_hash;
@@ -172,24 +109,13 @@ static mdn_result_t       normalizer_unicode_lowercase(const char *from,
                                                     char *to, size_t tolen);
 static mdn_result_t    normalizer_unicode_uppercase(const char *from,
                                                     char *to, size_t tolen);
-static mdn_result_t    normalizer_unicode_caseconv(mdn_result_t (*caseconv)(),
+static mdn_result_t    normalizer_unicode_caseconv(caseconv_proc_t caseconv,
                                                    const char *from,
                                                    char *to, size_t tolen);
 static mdn__unicode_context_t  get_casemap_context(const char *from,
                                                    size_t fromlen);
-static mdn_result_t    normalizer_ja_minus_hack(const char *from,
-                                                char *to, size_t tolen);
-static mdn_result_t    normalizer_ja_delimiter_hack(const char *from,
-                                                    char *to, size_t tolen);
-static mdn_result_t    normalizer_ja_fullwidth(const char *from,
-                                               char *to, size_t tolen);
-static mdn_result_t    normalizer_ja_alnum_halfwidth(const char *from,
-                                                     char *to, size_t tolen);
-static mdn_result_t    normalizer_ja_voicedsound(const char *from,
-                                                 char *to, size_t tolen);
-static int             compose_voicedsound(unsigned long ucs1,
-                                           unsigned long ucs2,
-                                           unsigned long *composed);
+static mdn_result_t    normalizer_unicode_casefold(const char *from,
+                                                   char *to, size_t tolen);
 
 static struct standard_normalizer {
        char *name;
@@ -199,16 +125,13 @@ static struct standard_normalizer {
        { "ascii-uppercase", normalizer_ascii_uppercase },
        { "unicode-lowercase", normalizer_unicode_lowercase },
        { "unicode-uppercase", normalizer_unicode_uppercase },
+       { "unicode-foldcase", normalizer_unicode_casefold },
        { "unicode-form-c", mdn__unormalize_formc },
        { "unicode-form-d", mdn__unormalize_formd },
        { "unicode-form-kc", mdn__unormalize_formkc },
        { "unicode-form-kd", mdn__unormalize_formkd },
-       { "ja-minus-hack", normalizer_ja_minus_hack },
-       { "ja-delimiter-hack", normalizer_ja_delimiter_hack },
-       { "ja-fullwidth", normalizer_ja_fullwidth },
-       { "ja-kana-fullwidth", normalizer_ja_fullwidth },
-       { "ja-alnum-halfwidth", normalizer_ja_alnum_halfwidth },
-       { "ja-compose-voiced-sound", normalizer_ja_voicedsound },
+       { "nameprep-02", mdn__unormalize_formkc },
+       { "nameprep-03", mdn__unormalize_formkc },
        { NULL, NULL },
 };
 
@@ -246,6 +169,7 @@ mdn_normalizer_create(mdn_normalizer_t *ctxp) {
        ctx->nschemes = 0;
        ctx->scheme_size = MAX_LOCAL_SCHEME;
        ctx->schemes = ctx->local_buf;
+       ctx->reference_count = 1;
        *ctxp = ctx;
 
        return (mdn_success);
@@ -256,11 +180,27 @@ mdn_normalizer_destroy(mdn_normalizer_t ctx) {
        assert(ctx != NULL);
 
        TRACE(("mdn_normalizer_destroy()\n"));
+       TRACE(("mdn_normalizer_destroy: update reference count (%d->%d)\n",
+           ctx->reference_count, ctx->reference_count - 1));
+
+       ctx->reference_count--;
+       if (ctx->reference_count <= 0) {
+               TRACE(("mdn_normalizer_destroy: the object is destroyed\n"));
+               if (ctx->schemes != ctx->local_buf)
+                       free(ctx->schemes);
+               free(ctx);
+       }
+}
 
-       if (ctx->schemes != ctx->local_buf)
-               free(ctx->schemes);
+void
+mdn_normalizer_incrref(mdn_normalizer_t ctx) {
+       assert(ctx != NULL);
+
+       TRACE(("mdn_normalizer_incrref()\n"));
+       TRACE(("mdn_normalizer_incrref: update reference count (%d->%d)\n",
+           ctx->reference_count, ctx->reference_count + 1));
 
-       free(ctx);
+       ctx->reference_count++;
 }
 
 mdn_result_t
@@ -295,6 +235,25 @@ mdn_normalizer_add(mdn_normalizer_t ctx, const char *scheme_name) {
        return (mdn_success);
 }
 
+mdn_result_t
+mdn_normalizer_addall(mdn_normalizer_t ctx, const char **scheme_names,
+                     int nschemes) {
+       mdn_result_t r;
+       int i;
+
+       assert(ctx != NULL && scheme_names != NULL);
+
+       TRACE(("mdn_normalizer_addall(nschemes=%d)\n", nschemes));
+
+       for (i = 0; i < nschemes; i++) {
+               r = mdn_normalizer_add(ctx, (const char *)*scheme_names);
+               if (r != mdn_success)
+                       return (r);
+               scheme_names++;
+       }
+
+       return (mdn_success);
+}
 
 mdn_result_t
 mdn_normalizer_normalize(mdn_normalizer_t ctx, const char *from,
@@ -561,7 +520,7 @@ normalizer_unicode_uppercase(const char *from, char *to, size_t tolen) {
 }
 
 static mdn_result_t
-normalizer_unicode_caseconv(mdn_result_t (*caseconv)(),
+normalizer_unicode_caseconv(caseconv_proc_t caseconv,
                            const char *from, char *to, size_t tolen)
 {
        size_t fromlen = strlen(from);
@@ -572,7 +531,7 @@ normalizer_unicode_caseconv(mdn_result_t (*caseconv)(),
                unsigned long v[CASEMAPBUFSZ];
                mdn_result_t r;
                mdn__unicode_context_t ctx = mdn__unicode_context_unknown;
-               size_t vlen;
+               int vlen;
                int w;
                int i;
 
@@ -631,130 +590,42 @@ get_casemap_context(const char *from, size_t fromlen) {
 }
 
 static mdn_result_t
-normalizer_ja_minus_hack(const char *from, char *to, size_t tolen) {
+normalizer_unicode_casefold(const char *from, char *to, size_t tolen) {
        size_t fromlen = strlen(from);
 
        while (fromlen > 0 && tolen > 0) {
-               unsigned long ucs;
-               int width;
-
-               if ((width = mdn_utf8_getwc(from, fromlen, &ucs)) == 0)
-                       return (mdn_invalid_encoding);
-               from += width;
-               fromlen -= width;
-
-               if (ucs == UNICODE_MINUS_SIGN)
-                       ucs = '-';
-
-               if ((width = mdn_utf8_putwc(to, tolen, ucs)) == 0)
-                       return (mdn_buffer_overflow);
-               to += width;
-               tolen -= width;
-       }
-
-       if (tolen <= 0)
-               return (mdn_buffer_overflow);
-
-       *to = '\0';
-       return (mdn_success);
-}
-
-static mdn_result_t
-normalizer_ja_delimiter_hack(const char *from, char *to, size_t tolen) {
-       size_t fromlen = strlen(from);
-
-       while (fromlen > 0 && tolen > 0) {
-               unsigned long ucs;
-               int width;
-
-               if ((width = mdn_utf8_getwc(from, fromlen, &ucs)) == 0)
-                       return (mdn_invalid_encoding);
-               from += width;
-               fromlen -= width;
-
-               if (ucs == UNICODE_IDEOGRAPHIC_FULL_STOP ||
-                   ucs == UNICODE_FULLWIDTH_FULL_STOP)
-                       ucs = '.';
-
-               if ((width = mdn_utf8_putwc(to, tolen, ucs)) == 0)
-                       return (mdn_buffer_overflow);
-               to += width;
-               tolen -= width;
-       }
-
-       if (tolen <= 0)
-               return (mdn_buffer_overflow);
-
-       *to = '\0';
-       return (mdn_success);
-}
-
-static mdn_result_t
-normalizer_ja_fullwidth(const char *from, char *to, size_t tolen) {
-       size_t fromlen = strlen(from);
-
-       while (fromlen > 0 && tolen > 0) {
-               unsigned long ucs;
-               int width;
+#define CASEFOLDBUFSZ  4
+               unsigned long c;
+               unsigned long v[CASEFOLDBUFSZ];
+               mdn_result_t r;
+               int vlen;
+               int w;
+               int i;
 
-               if ((width = mdn_utf8_getwc(from, fromlen, &ucs)) == 0)
+               if ((w = mdn_utf8_getwc(from, fromlen, &c)) == 0)
                        return (mdn_invalid_encoding);
-               from += width;
-               fromlen -= width;
+               from += w;
+               fromlen -= w;
 
-               if (UNICODE_HALFWIDTH_IDEOGRAPHIC_FULL_STOP <= ucs &&
-                   ucs <= UNICODE_HALFWIDTH_KATAKANA_SEMI_VOICED_SOUND_MARK) {
-                       ucs = ja_half_to_full[ucs - UNICODE_HALFWIDTH_IDEOGRAPHIC_FULL_STOP];
+               r = mdn__unicode_casefold(c, v, CASEFOLDBUFSZ, &vlen);
+               switch (r) {
+               case mdn_success:
+                       break;
+               case mdn_buffer_overflow:
+                       FATAL(("mdn_normalizer_normalize: "
+                              "internal buffer overflow\n"));
+                       break;
+               default:
+                       return (r);
                }
 
-               if ((width = mdn_utf8_putwc(to, tolen, ucs)) == 0)
-                       return (mdn_buffer_overflow);
-               to += width;
-               tolen -= width;
-       }
-
-       if (tolen <= 0)
-               return (mdn_buffer_overflow);
-
-       *to = '\0';
-       return (mdn_success);
-}
-
-static mdn_result_t
-normalizer_ja_alnum_halfwidth(const char *from, char *to, size_t tolen) {
-       size_t fromlen = strlen(from);
-
-       while (fromlen > 0 && tolen > 0) {
-               unsigned long ucs;
-               int width;
-
-               if ((width = mdn_utf8_getwc(from, fromlen, &ucs)) == 0)
-                       return (mdn_invalid_encoding);
-               from += width;
-               fromlen -= width;
-
-               if (ucs >= UNICODE_FULLWIDTH_DIGIT_ZERO &&
-                   ucs <= UNICODE_FULLWIDTH_DIGIT_NINE) {
-                       ucs -= UNICODE_FULLWIDTH_DIGIT_ZERO;
-                       ucs += '0';
-               } else if (ucs >= UNICODE_FULLWIDTH_LATIN_CAPITAL_LETTER_A &&
-                          ucs <= UNICODE_FULLWIDTH_LATIN_CAPITAL_LETTER_Z) {
-                       ucs -= UNICODE_FULLWIDTH_LATIN_CAPITAL_LETTER_A;
-                       ucs += 'A';
-               } else if (ucs >= UNICODE_FULLWIDTH_LATIN_SMALL_LETTER_A &&
-                          ucs <= UNICODE_FULLWIDTH_LATIN_SMALL_LETTER_Z) {
-                       ucs -= UNICODE_FULLWIDTH_LATIN_SMALL_LETTER_A;
-                       ucs += 'a';
-               } else if (ucs == UNICODE_MINUS_SIGN) {
-                       ucs = '-';
+               for (i = 0; i < vlen; i++) {
+                       if ((w = mdn_utf8_putwc(to, tolen, v[i])) == 0)
+                               return (mdn_buffer_overflow);
+                       to += w;
+                       tolen -= w;
                }
-
-               if ((width = mdn_utf8_putwc(to, tolen, ucs)) == 0)
-                       return (mdn_buffer_overflow);
-               to += width;
-               tolen -= width;
        }
-
        if (tolen <= 0)
                return (mdn_buffer_overflow);
 
@@ -762,106 +633,3 @@ normalizer_ja_alnum_halfwidth(const char *from, char *to, size_t tolen) {
        return (mdn_success);
 }
 
-static mdn_result_t
-normalizer_ja_voicedsound(const char *from, char *to, size_t tolen) {
-       size_t fromlen = strlen(from);
-       unsigned long ucs, last_ucs;
-       int width;
-
-#define VOID_UCS         0xffffffff    /* not a valid UCS-4 character. */
-
-       for (last_ucs = VOID_UCS; fromlen > 0 && tolen > 0; last_ucs = ucs) {
-               unsigned long composed_ucs;
-
-               if ((width = mdn_utf8_getwc(from, fromlen, &ucs)) == 0)
-                       return (mdn_invalid_encoding);
-               from += width;
-               fromlen -= width;
-
-               if (last_ucs == VOID_UCS)
-                       continue;
-
-               /*
-                * See if 'ucs' can be composed with the previous character
-                * 'last_ucs'.
-                */
-               if ((ucs == UNICODE_KATAKANA_HIRAGANA_SEMI_VOICED_SOUND_MARK ||
-                    ucs == UNICODE_KATAKANA_HIRAGANA_VOICED_SOUND_MARK) &&
-                   compose_voicedsound(last_ucs, ucs, &composed_ucs)) {
-                       /*
-                        * They can be composed.  Replace 'last_ucs'
-                        * with the composed character, and void 'ucs'.
-                        */
-                       last_ucs = composed_ucs;
-                       ucs = VOID_UCS;
-               }
-
-               /*
-                * Append 'last_ucs' to the result buffer.
-                */
-               if ((width = mdn_utf8_putwc(to, tolen, last_ucs)) == 0)
-                       return (mdn_buffer_overflow);
-               to += width;
-               tolen -= width;
-       }
-
-       /*
-        * If there is non-void 'last_ucs' character, append it to
-        * the result buffer.
-        */
-       if (last_ucs != VOID_UCS) {
-               if ((width = mdn_utf8_putwc(to, tolen, last_ucs)) == 0)
-                       return (mdn_buffer_overflow);
-               to += width;
-               tolen -= width;
-       }
-#undef VOID_UCS
-
-       /*
-        * Terminate the result buffer with NUL.
-        */
-       if (tolen <= 0)
-               return (mdn_buffer_overflow);
-       *to = '\0';
-
-       return (mdn_success);
-}
-
-static int
-compose_voicedsound(unsigned long ucs1, unsigned long ucs2,
-                   unsigned long *composed)
-{
-       voiced_sound_tbl_t *tbl;
-       size_t tblsize;
-       int top, end;
-
-       assert(ucs2 == UNICODE_KATAKANA_HIRAGANA_VOICED_SOUND_MARK ||
-              ucs2 == UNICODE_KATAKANA_HIRAGANA_SEMI_VOICED_SOUND_MARK);
-
-       if (ucs1 < UNICODE_VOICED_SOUND_CANDIDATE_BEGIN ||
-           ucs1 > UNICODE_VOICED_SOUND_CANDIDATE_END)
-               return (0);
-
-       if (ucs2 == UNICODE_KATAKANA_HIRAGANA_VOICED_SOUND_MARK) {
-               tbl = ja_voiced_sound;
-               tblsize = sizeof(ja_voiced_sound) / sizeof(tbl[0]);
-       } else {
-               tbl = ja_semi_voiced_sound;
-               tblsize = sizeof(ja_semi_voiced_sound) / sizeof(tbl[0]);
-       }
-
-       for (top = 0, end = tblsize - 1; top <= end;) {
-               int mid = (top + end) / 2;
-               unsigned long miducs = tbl[mid].ucs;
-
-               if (ucs1 == miducs) {
-                       *composed = tbl[mid].composed_ucs;
-                       return (1);
-               } else if (ucs1 < miducs) {
-                       end = mid - 1;
-               } else {
-                       top = mid + 1;
-               }
-       }
-       return (0);
-}
index 63a13b48d90988aea4d535f0b93922c308574848..293c1717509e01b9e288debfc1338dd6e33560bf 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
-static char *rcsid = "$Id: race.c,v 1.17 2000/12/26 08:17:01 m-kasahr Exp $";
+static char *rcsid = "$Id: race.c,v 1.23 2001/03/07 00:58:52 ishisone Exp $";
 #endif
 
 /*
@@ -73,12 +73,12 @@ static char *rcsid = "$Id: race.c,v 1.17 2000/12/26 08:17:01 m-kasahr Exp $";
 #include <mdn/utf8.h>
 #include <mdn/debug.h>
 #include <mdn/race.h>
+#include <mdn/ace.h>
 #include <mdn/util.h>
 
 #ifndef MDN_RACE_PREFIX
 #define MDN_RACE_PREFIX                "bq--"
 #endif
-#define RACE_PREFIX_LEN                (strlen(MDN_RACE_PREFIX))
 #define RACE_2OCTET_MODE       0xd8
 #define RACE_ESCAPE            0xff
 #define RACE_ESCAPE_2ND                0x99
@@ -104,13 +104,9 @@ static char *rcsid = "$Id: race.c,v 1.17 2000/12/26 08:17:01 m-kasahr Exp $";
 enum {
        compress_one,   /* all characters are in a single row */
        compress_two,   /* row 0 and another row */
-       compress_none,  /* nope */
+       compress_none   /* nope */
 };
 
-static mdn_result_t    race_l2u(const char *from, const char *end,
-                                char *to, size_t tolen, size_t *clenp);
-static mdn_result_t    race_u2l(const char *from, const char *end,
-                                char *to, size_t tolen, size_t *clenp);
 static mdn_result_t    race_decode(const char *from, size_t fromlen,
                                    char *to, size_t tolen);
 static mdn_result_t    race_decode_decompress(const char *from,
@@ -124,23 +120,30 @@ static mdn_result_t       race_compress_encode(const unsigned short *p,
                                             char *to, size_t tolen);
 static int             get_compress_mode(unsigned short *p, size_t len);
 
+static mdn__ace_t race_ctx = {
+       mdn__ace_prefix,
+       MDN_RACE_PREFIX,
+       race_encode,
+       race_decode,
+};
+
 /* ARGSUSED */
 mdn_result_t
-mdn__race_open(mdn_converter_t ctx, mdn_converter_dir_t dir) {
+mdn__race_open(mdn_converter_t ctx, mdn_converter_dir_t dir, void **privdata) {
        return (mdn_success);
 }
 
 /* ARGSUSED */
 mdn_result_t
-mdn__race_close(mdn_converter_t ctx, mdn_converter_dir_t dir) {
+mdn__race_close(mdn_converter_t ctx, void *privdata, mdn_converter_dir_t dir) {
        return (mdn_success);
 }
 
 mdn_result_t
-mdn__race_convert(mdn_converter_t ctx, mdn_converter_dir_t dir,
-                   const char *from, char *toorg, size_t tolen)
+mdn__race_convert(mdn_converter_t ctx, void *privdata, mdn_converter_dir_t dir,
+                 const char *from, char *to, size_t tolen)
 {
-       char *to = toorg;
+       mdn_result_t r;
 
        assert(ctx != NULL &&
               (dir == mdn_converter_l2u || dir == mdn_converter_u2l));
@@ -149,134 +152,13 @@ mdn__race_convert(mdn_converter_t ctx, mdn_converter_dir_t dir,
              dir == mdn_converter_l2u ? "l2u" : "u2l",
              mdn_debug_xstring(from, 20)));
 
-       for (;;) {
-               const char *end;
-               size_t convlen;
-               mdn_result_t r;
-
-               /*
-                * Find the end of this component (label).
-                */
-               if ((end = strchr(from, '.')) == NULL)
-                       end = from + strlen(from);
-
-               /*
-                * Convert it.
-                */
-               if (dir == mdn_converter_l2u)
-                       r = race_l2u(from, end, to, tolen, &convlen);
-               else
-                       r = race_u2l(from, end, to, tolen, &convlen);
-               if (r != mdn_success)
-                       return (r);
-
-               /*
-                * Copy '.' or NUL.
-                */
-               if (tolen <= convlen)
-                       return (mdn_buffer_overflow);
-
-               to += convlen;
-               *to++ = *end;
-               tolen -= convlen + 1;
-
-               if (*end == '\0')
-                       break;
-
-               from = end + 1;
-       }
-
-       DUMP(("mdn__race_convert: \"%s\"\n", mdn_debug_xstring(toorg, 70)));
-
-       return (mdn_success);
-}
-
-static mdn_result_t
-race_l2u(const char *from, const char *end,
-          char *to, size_t tolen, size_t *clenp) {
-       size_t len = end - from;
-
-       if (len >= RACE_PREFIX_LEN &&
-           mdn_util_casematch(from, MDN_RACE_PREFIX, RACE_PREFIX_LEN)) {
-               /*
-                * RACE encoding prefix found.
-                */
-               mdn_result_t r;
-
-               r = race_decode(from + RACE_PREFIX_LEN,
-                               len - RACE_PREFIX_LEN, to, tolen);
-               if (r == mdn_invalid_encoding)
-                       goto copy;
-               else if (r != mdn_success)
-                       return (r);
-
-               len = strlen(to);
-
-               /*
-                * RACE doesn't permit encoding a domain name which fits
-                * the host name requirement [STD13].
-                */
-               if (mdn_util_domainspan(to, to + len) == to + len)
-                       return (mdn_invalid_encoding);
-
-       } else {
-               /*
-                * Not RACE encoded.  Copy verbatim.
-                */
-       copy:
-               if (mdn_util_domainspan(from, end) < end) {
-                       /* invalid character found */
-                       return (mdn_invalid_encoding);
-               }
-
-               if (tolen < len)
-                       return (mdn_buffer_overflow);
-
-               (void)memcpy(to, from, len);
-       }
-       *clenp = len;
-       return (mdn_success);
-}
-
-static mdn_result_t
-race_u2l(const char *from, const char *end,
-          char *to, size_t tolen, size_t *clenp) {
-       size_t len = end - from;
-
-       /*
-        * See if encoding is necessary.
-        */
-       if (mdn_util_domainspan(from, end) < end) {
-               /*
-                * Conversion is necessary.
-                */
-               mdn_result_t r;
-
-               /* Set prefix. */
-               if (tolen < RACE_PREFIX_LEN)
-                       return (mdn_buffer_overflow);
-               (void)memcpy(to, MDN_RACE_PREFIX, RACE_PREFIX_LEN);
-               to += RACE_PREFIX_LEN;
-               tolen -= RACE_PREFIX_LEN;
-
-               r = race_encode(from, len, to, tolen);
-               if (r != mdn_success)
-                       return (r);
-
-               len = RACE_PREFIX_LEN + strlen(to);
-       } else {
-               /*
-                * Conversion is NOT necessary.
-                * Copy verbatim.
-                */
+       r = mdn__ace_convert(&race_ctx, dir, from, to, tolen);
+       if (r != mdn_success)
+               return (r);
 
-               if (tolen < len)
-                       return (mdn_buffer_overflow);
+       DUMP(("mdn__race_convert: \"%s\"\n", mdn_debug_xstring(to, 70)));
 
-               (void)memcpy(to, from, len);
-       }
-       *clenp = len;
-       return (mdn_success);
+       return (r);
 }
 
 static mdn_result_t
@@ -284,7 +166,6 @@ race_decode(const char *from, size_t fromlen, char *to, size_t tolen) {
        unsigned short *buf;
        unsigned short local_buf[RACE_BUF_SIZE];
        size_t len, reslen;
-       char *reversed_from;
        mdn_result_t r;
 
        /*
@@ -323,20 +204,6 @@ race_decode(const char *from, size_t fromlen, char *to, size_t tolen) {
        }
        *(to + reslen) = '\0';
 
-       /*
-        * Encode the result, and compare the result with `from', in
-        * order to test whether an input string is encoded correctly.
-        * If `from' was encoded with wrong compression mode, we return
-        * `mdn_invalid_encoding'.
-        */
-       r = race_encode(to, reslen, (char *)buf, fromlen + 1);
-       if (r != mdn_success)
-               goto ret;
-       if (!mdn_util_casematch((char *)buf, from, fromlen)) {
-               r = mdn_invalid_encoding;
-               goto ret;
-       }
-
 ret:
        if (buf != local_buf)
                free(buf);
index f0a5362844ead2b2f3d5dbfdba88df5077c7b386..25c97c2ea43f69c41c27a1de067f2f4a1e780208 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
-static char *rcsid = "$Id: res.c,v 1.5 2000/09/20 02:47:32 ishisone Exp $";
+static char *rcsid = "$Id: res.c,v 1.17 2001/05/15 05:04:00 ishisone Exp $";
 #endif
 
 /*
@@ -71,215 +71,658 @@ static char *rcsid = "$Id: res.c,v 1.5 2000/09/20 02:47:32 ishisone Exp $";
 #include <mdn/logmacro.h>
 #include <mdn/converter.h>
 #include <mdn/normalizer.h>
-#include <mdn/translator.h>
+#include <mdn/checker.h>
+#include <mdn/mapper.h>
+#include <mdn/mapselector.h>
+#include <mdn/delimitermap.h>
 #include <mdn/resconf.h>
 #include <mdn/res.h>
+#include <mdn/util.h>
 #include <mdn/debug.h>
 
+static mdn_result_t    nameconv_l(mdn_resconf_t ctx, const char *from,
+                                  char *to, size_t tolen);
+static mdn_result_t    nameconv_L(mdn_resconf_t ctx, const char *from,
+                                  char *to, size_t tolen);
+static mdn_result_t    nameconv_d(mdn_resconf_t ctx, const char *from,
+                                  char *to, size_t tolen);
+static mdn_result_t    nameconv_M(mdn_resconf_t ctx, const char *from,
+                                  char *to, size_t tolen);
+static mdn_result_t    nameconv_m(mdn_resconf_t ctx, const char *from,
+                                  char *to, size_t tolen);
+static mdn_result_t    nameconv_n(mdn_resconf_t ctx, const char *from,
+                                  char *to, size_t tolen);
+static mdn_result_t    nameconv_p(mdn_resconf_t ctx, const char *from,
+                                  char *to, size_t tolen);
+static mdn_result_t    nameconv_u(mdn_resconf_t ctx, const char *from,
+                                  char *to, size_t tolen);
+static mdn_result_t    nameconv_I(mdn_resconf_t ctx, const char *from,
+                                  char *to, size_t tolen);
+static mdn_result_t    nameconv_i(mdn_resconf_t ctx, const char *from,
+                                  char *to, size_t tolen);
+static mdn_result_t    nameconv_a(mdn_resconf_t ctx, const char *from,
+                                  char *to, size_t tolen);
+static mdn_result_t    nameconv_A(mdn_resconf_t ctx, const char *from,
+                                  char *to, size_t tolen);
 static mdn_result_t    copy_verbatim(const char *from, char *to,
                                      size_t tolen);
-static int             contain_invalid_char(const char *name);
 
 mdn_result_t
-mdn_res_localtoucs(mdn_resconf_t conf, const char *local_name,
-                  char *ucs_name, size_t ucs_name_len)
+mdn_res_nameconv(mdn_resconf_t ctx, const char *actions, const char *from,
+                char *to, size_t tolen)
 {
-       mdn_converter_t conv;
        mdn_result_t r;
+       size_t fromlen;
+       char *src, *dst;
+       char static_buffers[2][1024];   /* large enough */
+       char *dynamic_buffers[2];
+       size_t dynamic_buflen[2];
+       char actions_buffer[64];        /* large enough */
+       char *ap;
+       size_t dstlen;
+       int idx;
+
+       assert(ctx != NULL && from != NULL && to != NULL);
+
+       TRACE(("mdn_res_nameconv(from=\"%s\")\n",
+               mdn_debug_xstring(from, 20)));
+
+       /*
+        * Copy `actions' to `actions_buffer' + 2.
+        * We make two characters space to extend the action `N'.
+        */
+       if (strlen(actions) + 1 > sizeof(actions_buffer) - 2)
+               return (mdn_invalid_action);
+       strcpy(actions_buffer + 2, actions);
+       ap = actions_buffer + 2;
+
+       /*
+        * Initialize the buffers to use the local
+        * storage (stack memory).
+        */
+       dynamic_buffers[0] = NULL;
+       dynamic_buffers[1] = NULL;
+       dynamic_buflen[0] = 0;
+       dynamic_buflen[1] = 0;
+
+       fromlen = strlen(from);
+
+       /*
+        * Convert.
+        */
+       src = (void *)from;
+       dstlen = fromlen + 1;
+
+       while (*ap != '\0') {
+               if (*ap == ' ' || *ap == '\t') {
+                       ap++;
+                       continue;
+               }
+
+               /*
+                * Choose destination area to restore the result of a mapping.
+                */
+               if (*ap == 'p' || *ap == 'u') {
+                       dst = src;
+               } else if (dstlen <= sizeof(static_buffers[0])) {
+                       if (src == static_buffers[0])
+                               idx = 1;
+                       else
+                               idx = 0;
 
-       assert(local_name != NULL && ucs_name != NULL);
+                       dst = static_buffers[idx];
+                       dstlen = sizeof(static_buffers[0]);
 
-       TRACE(("mdn_res_localtoucs(local_name=\"%-.20s\")\n", local_name));
+               } else {
+                       if (src == dynamic_buffers[0])
+                               idx = 1;
+                       else
+                               idx = 0;
+
+                       if (dynamic_buflen[idx] == 0) {
+                               dynamic_buffers[idx] = (char *) malloc(dstlen);
+                               if (dynamic_buffers[idx] == NULL) {
+                                       r = mdn_nomemory;
+                                       goto failure;
+                               }
+                               dynamic_buflen[idx] = dstlen;
+
+                       } else if (dynamic_buflen[idx] < dstlen) {
+                               char *newbuf;
+
+                               newbuf = realloc(dynamic_buffers[idx], dstlen);
+                               if (newbuf == NULL) {
+                                       r = mdn_nomemory;
+                                       goto failure;
+                               }
+                               dynamic_buffers[idx] = newbuf;
+                               dynamic_buflen[idx] = dstlen;
+                       }
+
+                       dst = dynamic_buffers[idx];
+                       dstlen = dynamic_buflen[idx];
+               }
 
-       if (conf == NULL)
-               return (copy_verbatim(local_name, ucs_name, ucs_name_len));
+               /*
+                * Determine an action character.
+                * If the current action is `N', we resolve it into "mnp".
+                */
+               if (*ap == 'N') {
+                       *(ap - 2) = 'm';
+                       *(ap - 1) = 'n';
+                       *ap = 'p';
+                       ap -= 2;
+               }
 
-       if (!contain_invalid_char(local_name) &&
-           (conv = mdn_resconf_alternateconverter(conf)) != NULL) {
-               TRACE(("mdn_res_localtoucs: trying alternate converter..\n"));
-               r = mdn_converter_convert(conv, mdn_converter_l2u,
-                                         local_name, ucs_name, ucs_name_len);
-               if (r == mdn_success)
+               /*
+                * Perform a conversion or check.
+                * If buffer size is not enough, we double it and try again.
+                */
+               switch (*ap) {
+               case 'l':
+                       r = nameconv_l(ctx, src, dst, dstlen);
+                       break;
+               case 'L':
+                       r = nameconv_L(ctx, src, dst, dstlen);
+                       break;
+               case 'd':
+                       r = nameconv_d(ctx, src, dst, dstlen);
+                       break;
+               case 'M':
+                       r = nameconv_M(ctx, src, dst, dstlen);
+                       break;
+               case 'm':
+                       r = nameconv_m(ctx, src, dst, dstlen);
+                       break;
+               case 'n':
+                       r = nameconv_n(ctx, src, dst, dstlen);
+                       break;
+               case 'p':
+                       r = nameconv_p(ctx, src, dst, dstlen);
+                       break;
+               case 'u':
+                       r = nameconv_u(ctx, src, dst, dstlen);
+                       break;
+               case 'I':
+                       r = nameconv_I(ctx, src, dst, dstlen);
+                       break;
+               case 'i':
+                       r = nameconv_i(ctx, src, dst, dstlen);
+                       break;
+               case 'a':
+                       r = nameconv_a(ctx, src, dst, dstlen);
+                       break;
+               case 'A':
+                       r = nameconv_A(ctx, src, dst, dstlen);
+                       break;
+               default:
+                       r = mdn_invalid_action;
+                       break;
+               }
+
+               if (r == mdn_buffer_overflow) {
+                       dstlen *= 2;
+                       continue;
+               } else if (r != mdn_success)
+                       goto failure;
+
+               ap++;
+               src = dst;
+       }
+
+       r = copy_verbatim(src, to, tolen);
+       if (r != mdn_success)
+               goto failure;
+
+       return (mdn_success);
+
+failure:
+       free(dynamic_buffers[0]);
+       free(dynamic_buffers[1]);
+       return (r);
+}
+
+static mdn_result_t
+nameconv_l(mdn_resconf_t ctx, const char *from, char *to, size_t tolen)
+{
+       mdn_result_t r;
+       mdn_converter_t local_converter;
+       mdn_converter_t alternate_converter;
+
+       alternate_converter = mdn_resconf_getalternateconverter(ctx);
+       if (alternate_converter != NULL) {
+               r = mdn_converter_localtoutf8(alternate_converter, from, to,
+                                             tolen);
+               mdn_converter_destroy(alternate_converter);
+               if (r == mdn_success && strcmp(from, to) != 0)
                        return (r);
        }
-       
-       if ((conv = mdn_resconf_localconverter(conf)) == NULL)
-               return (copy_verbatim(local_name, ucs_name, ucs_name_len));
+       local_converter = mdn_resconf_getlocalconverter(ctx);
+       if (local_converter != NULL) {
+               r = mdn_converter_localtoutf8(local_converter, from, to,
+                                             tolen);
+               mdn_converter_destroy(local_converter);
+       } else {
+               r = copy_verbatim(from, to, tolen);
+       }
 
-       TRACE(("mdn_res_localtoucs: using local converter..\n"));
-       return (mdn_converter_convert(conv, mdn_converter_l2u,
-                                     local_name, ucs_name, ucs_name_len));
+       return (r);
 }
 
-mdn_result_t
-mdn_res_ucstolocal(mdn_resconf_t conf, const char *ucs_name,
-                  char *local_name, size_t local_name_len)
+static mdn_result_t
+nameconv_L(mdn_resconf_t ctx, const char *from, char *to, size_t tolen)
 {
-       mdn_converter_t conv;
        mdn_result_t r;
+       mdn_converter_t local_converter;
+       mdn_converter_t alternate_converter;
+
+       local_converter = mdn_resconf_getlocalconverter(ctx);
+       if (local_converter != NULL) {
+               r = mdn_converter_utf8tolocal(local_converter, from, to,
+                                             tolen);
+               mdn_converter_destroy(local_converter);
+       } else {
+               r = copy_verbatim(from, to, tolen);
+       }
+       if (r != mdn_nomapping)
+               return (r);
 
-       assert(ucs_name != NULL && local_name != NULL);
+       alternate_converter = mdn_resconf_getalternateconverter(ctx);
+       if (alternate_converter != NULL) {
+               r = mdn_converter_utf8tolocal(alternate_converter, from, to,
+                                             tolen);
+               mdn_converter_destroy(alternate_converter);
+       }
 
-       TRACE(("mdn_res_ucstolocal(ucs_name=\"%s\")\n",
-             mdn_debug_xstring(ucs_name, 20)));
+       return (r);
+}
 
-       if (conf == NULL ||
-           (conv = mdn_resconf_localconverter(conf)) == NULL)
-               return (copy_verbatim(ucs_name, local_name, local_name_len));
+static mdn_result_t
+nameconv_d(mdn_resconf_t ctx, const char *from, char *to, size_t tolen)
+{
+       mdn_result_t r;
+       mdn_delimitermap_t delimiter_mapper;
+
+       delimiter_mapper = mdn_resconf_getdelimitermap(ctx);
+       if (delimiter_mapper != NULL) {
+               r = mdn_delimitermap_map(delimiter_mapper, from, to, tolen);
+               mdn_delimitermap_destroy(delimiter_mapper);
+       } else {
+               r = copy_verbatim(from, to, tolen);
+       }
 
-       r = mdn_converter_convert(conv, mdn_converter_u2l,
-                                 ucs_name, local_name, local_name_len);
+       return (r);
+}
+
+static mdn_result_t
+nameconv_M(mdn_resconf_t ctx, const char *from, char *to, size_t tolen)
+{
+       mdn_result_t r;
+       mdn_mapselector_t local_mapper;
 
-       if (r == mdn_nomapping &&
-           (conv = mdn_resconf_alternateconverter(conf)) != NULL) {
-               TRACE(("mdn_res_ucstolocal: switched to alternate converter\n"));
-               r = mdn_converter_convert(conv, mdn_converter_u2l,
-                                         ucs_name, local_name,
-                                         local_name_len);
+       local_mapper = mdn_resconf_getlocalmapselector(ctx);
+       if (local_mapper != NULL) {
+               r = mdn_mapselector_map(local_mapper, from, to, tolen);
+               mdn_mapselector_destroy(local_mapper);
+       } else {
+               r = copy_verbatim(from, to, tolen);
        }
+
        return (r);
 }
 
-mdn_result_t
-mdn_res_normalize(mdn_resconf_t conf, const char *name,
-                 char *normalized_name, size_t normalized_name_len)
+static mdn_result_t
+nameconv_p(mdn_resconf_t ctx, const char *from, char *to, size_t tolen)
 {
-       mdn_normalizer_t norm;
+       mdn_result_t r;
+       const char *found;
+       mdn_checker_t prohibit_checker;
+
+       prohibit_checker = mdn_resconf_getprohibitchecker(ctx);
+       if (prohibit_checker != NULL) {
+               r = mdn_checker_lookup(prohibit_checker, from, &found);
+               if (found != NULL)
+                       r = mdn_prohibited;
+               mdn_checker_destroy(prohibit_checker);
+       } else {
+               r = mdn_success;
+       }
 
-       assert(name != NULL && normalized_name != NULL);
+       return (r);
+}
 
-       TRACE(("mdn_res_normalize(name=\"%s\")\n",
-             mdn_debug_xstring(name, 20)));
+static mdn_result_t
+nameconv_u(mdn_resconf_t ctx, const char *from, char *to, size_t tolen)
+{
+       mdn_result_t r;
+       mdn_checker_t unassigned_checker;
+       const char *found;
+
+       unassigned_checker = mdn_resconf_getunassignedchecker(ctx);
+       if (unassigned_checker != NULL) {
+               r = mdn_checker_lookup(unassigned_checker, from, &found);
+               if (found != NULL)
+                       r = mdn_prohibited;
+               mdn_checker_destroy(unassigned_checker);
+       } else {
+               r = mdn_success;
+       }
 
-       if (conf == NULL ||
-           (norm = mdn_resconf_normalizer(conf)) == NULL)
-               return (copy_verbatim(name, normalized_name,
-                                     normalized_name_len));
-       return (mdn_normalizer_normalize(norm, name, normalized_name,
-                                        normalized_name_len));
+       return (r);
 }
 
-mdn_result_t
-mdn_res_ucstodns(mdn_resconf_t conf, const char *ucs_name, char *dns_name,
-                size_t dns_name_len)
+static mdn_result_t
+nameconv_m(mdn_resconf_t ctx, const char *from, char *to, size_t tolen)
 {
-       mdn_converter_t conv;
+       mdn_mapper_t mapper = NULL;
        mdn_result_t r;
-       const char *zld;
+       size_t fromlen;
+       size_t steplen;
+       char static_buffer[1024];       /* large enough */
+       char *dynamic_buffer = NULL;
+       char *label;
+       char *dot;
+
+       fromlen = strlen(from);
+
+       mapper = mdn_resconf_getmapper(ctx);
+       if (mapper == NULL) {
+               r = copy_verbatim(from, to, tolen);
+               return (r);
+       }
+
+       if (fromlen + 1 > sizeof(static_buffer)) {
+               dynamic_buffer = (char *) malloc(fromlen + 1);
+               if (dynamic_buffer == NULL) {
+                       r = mdn_nomemory;
+                       goto failure;
+               }
+               label = dynamic_buffer;
+       } else {
+               label = static_buffer;
+       }
 
-       assert(ucs_name != NULL && dns_name != NULL);
+       strcpy(label, from);
 
-       TRACE(("mdn_res_ucstodns(ucs_name=\"%s\")\n",
-             mdn_debug_xstring(ucs_name, 20)));
+       for (;;) {
+               dot = strchr(label, '.');
+               if (dot != NULL)
+                       *dot = '\0';
 
-       if (conf == NULL ||
-           (conv = mdn_resconf_serverconverter(conf)) == NULL ||
-           !contain_invalid_char(ucs_name))
-               return (copy_verbatim(ucs_name, dns_name, dns_name_len));
+               if (*label == '\0' || mdn_util_validstd13(label, NULL)) {
+                       r = copy_verbatim(label, to, tolen);
+               } else {
+                       r = mdn_mapper_map(mapper, label, to, tolen);
+               }
+               if (r != mdn_success)
+                       goto failure;
 
-       r = mdn_converter_convert(conv, mdn_converter_u2l,
-                                 ucs_name, dns_name, dns_name_len);
-       if (r != mdn_success)
-               return (r);
+               steplen = strlen(to);
+               tolen -= steplen;
+               to += steplen;
 
-       if ((zld = mdn_resconf_zld(conf)) != NULL) {
-               size_t len;
+               if (dot == NULL)
+                       break;
 
-               TRACE(("mdn_res_ucstodns: adding ZLD\n"));
-               len = strlen(dns_name);
-               if (len > 0 && dns_name[len - 1] != '.') {
-                       if (len + 1 >= dns_name_len)
-                               return (mdn_buffer_overflow);
-                       strcpy(dns_name + len, ".");
-                       len++;
+               if (tolen <= 1) {
+                       r = mdn_buffer_overflow;
+                       return (r);
                }
-               if (len + strlen(zld) >= dns_name_len)
-                       return (mdn_buffer_overflow);
-               (void)strcat(dns_name, zld);
+               *to++ = '.';
+               tolen--;
+
+               label = dot + 1;
+               if (*label == '\0')
+                       break;
        }
+
+       /*
+        * Don't delete the following.  If `from' ends with ".", `to' is
+        * terminated by this line.
+        */
+       *to = '\0';
+
+       free(dynamic_buffer);
+       mdn_mapper_destroy(mapper);
        return (mdn_success);
+
+failure:
+       free(dynamic_buffer);
+       if (mapper != NULL)
+               mdn_mapper_destroy(mapper);
+       return (r);
 }
 
-mdn_result_t
-mdn_res_dnstoucs(mdn_resconf_t conf, const char *dns_name, char *ucs_name,
-                size_t ucs_name_len)
+static mdn_result_t
+nameconv_n(mdn_resconf_t ctx, const char *from, char *to, size_t tolen)
 {
-       const char *zld;
-       mdn_converter_t conv;
-       char domainbuf[512];
-       int convert;
-
-       assert(dns_name != NULL && ucs_name != NULL);
-
-       TRACE(("mdn_res_dnstoucs(dns_name=\"%s\")\n",
-             mdn_debug_xstring(dns_name, 20)));
-
-       if (conf == NULL ||
-           (conv = mdn_resconf_serverconverter(conf)) == NULL)
-               return (copy_verbatim(dns_name, ucs_name, ucs_name_len));
-
-       if ((zld = mdn_resconf_zld(conf)) != NULL) {
-               if (mdn_translator_matchzld(dns_name, zld)) {
-                       /*
-                        * Strip 'zld' from 'dns_name'.
-                        */
-                       size_t namelen = strlen(dns_name);
-
-                       TRACE(("mdn_res_dnstoucs: ZLD matched\n"));
-                       /* 'zld' must end with dot, but 'dns_name' may not. */
-                       if (namelen > 0 && dns_name[namelen - 1] != '.')
-                               namelen++;
-                       namelen -= strlen(zld);
-                       if (namelen >= sizeof(domainbuf))
-                               return (mdn_invalid_name);
-                       (void)strncpy(domainbuf, dns_name, namelen);
-                       domainbuf[namelen] = '\0';
-                       dns_name = domainbuf;
-                       convert = 1;
-               } else if (contain_invalid_char(dns_name)) {
-                       TRACE(("mdn_res_dnstoucs: contain invalid char\n"));
-                       return (mdn_invalid_name);
+       mdn_normalizer_t normalizer = NULL;
+       mdn_result_t r;
+       size_t fromlen;
+       size_t steplen;
+       char static_buffer[1024];       /* large enough */
+       char *dynamic_buffer = NULL;
+       char *label;
+       char *dot;
+
+       fromlen = strlen(from);
+
+       normalizer = mdn_resconf_getnormalizer(ctx);
+       if (normalizer == NULL) {
+               r = copy_verbatim(from, to, tolen);
+               return (r);
+       }
+
+       if (fromlen + 1 > sizeof(static_buffer)) {
+               dynamic_buffer = (char *) malloc(fromlen + 1);
+               if (dynamic_buffer == NULL) {
+                       r = mdn_nomemory;
+                       goto failure;
+               }
+               label = dynamic_buffer;
+       } else {
+               label = static_buffer;
+       }
+
+       strcpy(label, from);
+
+       for (;;) {
+               dot = strchr(label, '.');
+               if (dot != NULL)
+                       *dot = '\0';
+
+               if (*label == '\0' || mdn_util_validstd13(label, NULL)) {
+                       r = copy_verbatim(label, to, tolen);
                } else {
-                       convert = 0;
+                       r = mdn_normalizer_normalize(normalizer, label, to,
+                               tolen);
                }
-       } else if (!mdn_converter_isasciicompatible(conv) &&
-                  !contain_invalid_char(dns_name)) {
-               convert = 0;
+               if (r != mdn_success)
+                       goto failure;
+
+               steplen = strlen(to);
+               tolen -= steplen;
+               to += steplen;
+
+               if (dot == NULL)
+                       break;
+
+               if (tolen <= 1) {
+                       r = mdn_buffer_overflow;
+                       return (r);
+               }
+               *to++ = '.';
+               tolen--;
+
+               label = dot + 1;
+               if (*label == '\0')
+                       break;
+       }
+
+       /*
+        * Don't delete the following.  If `from' ends with ".", `to' is
+        * terminated by this line.
+        */
+       *to = '\0';
+
+       free(dynamic_buffer);
+       mdn_normalizer_destroy(normalizer);
+       return (mdn_success);
+
+failure:
+       free(dynamic_buffer);
+       if (normalizer != NULL)
+               mdn_normalizer_destroy(normalizer);
+       return (r);
+}
+
+static mdn_result_t
+nameconv_I(mdn_resconf_t ctx, const char *from, char *to, size_t tolen)
+{
+       mdn_result_t r;
+       mdn_converter_t idn_converter;
+
+       idn_converter = mdn_resconf_getidnconverter(ctx);
+       if (idn_converter != NULL) {
+               r = mdn_converter_utf8tolocal(idn_converter, from, to, tolen);
+               mdn_converter_destroy(idn_converter);
        } else {
-               convert = 1;
+               r = copy_verbatim(from, to, tolen);
        }
 
-       if (convert) {
-               TRACE(("mdn_res_dnstoucs: convert to ucs\n"));
-               return (mdn_converter_convert(conv, mdn_converter_l2u,
-                                             dns_name, ucs_name,
-                                             ucs_name_len));
+       return (r);
+}
+
+static mdn_result_t
+nameconv_i(mdn_resconf_t ctx, const char *from, char *to, size_t tolen)
+{
+       mdn_result_t r;
+       mdn_converter_t idn_converter;
+
+       idn_converter = mdn_resconf_getidnconverter(ctx);
+       if (idn_converter != NULL) {
+               r = mdn_converter_localtoutf8(idn_converter, from, to, tolen);
+               mdn_converter_destroy(idn_converter);
        } else {
-               return (copy_verbatim(dns_name, ucs_name, ucs_name_len));
+               r = copy_verbatim(from, to, tolen);
        }
+
+       return (r);
+}
+
+static mdn_result_t
+nameconv_a(mdn_resconf_t ctx, const char *from, char *to, size_t tolen)
+{
+       mdn_result_t r;
+       mdn_converter_t alternate_converter;
+
+       alternate_converter = mdn_resconf_getalternateconverter(ctx);
+       if (alternate_converter != NULL) {
+               r = mdn_converter_localtoutf8(alternate_converter, from, to,
+                                             tolen);
+               mdn_converter_destroy(alternate_converter);
+       } else {
+               r = copy_verbatim(from, to, tolen);
+       }
+
+       return (r);
+}
+
+static mdn_result_t
+nameconv_A(mdn_resconf_t ctx, const char *from, char *to, size_t tolen)
+{
+       mdn_result_t r;
+       mdn_converter_t alternate_converter;
+
+       alternate_converter = mdn_resconf_getalternateconverter(ctx);
+       if (alternate_converter != NULL) {
+               r = mdn_converter_utf8tolocal(alternate_converter, from, to,
+                                             tolen);
+               mdn_converter_destroy(alternate_converter);
+       } else {
+               r = copy_verbatim(from, to, tolen);
+       }
+
+       return (r);
 }
 
 static mdn_result_t
 copy_verbatim(const char *from, char *to, size_t tolen) {
-       size_t fromlen = strlen(from) + 1;
+       size_t fromlen = strlen(from);
 
-       if (tolen < fromlen)
+       if (fromlen + 1 > tolen)
                return (mdn_buffer_overflow);
-       (void)memcpy(to, from, fromlen);
+       (void)memcpy(to, from, fromlen + 1);
        return (mdn_success);
 }
 
-static int
-contain_invalid_char(const char *name) {
-       int c;
-
-       while ((c = *name++) != '\0') {
-               if (('a' <= c && c <= 'z') ||
-                   ('A' <= c && c <= 'Z') ||
-                   ('0' <= c && c <= '9') ||
-                   c == '.' || c == '-')
-                       continue;       /* valid character */
-               return (1);
-       }
-       return (0);
+#undef mdn_res_localtoucs
+#undef mdn_res_ucstolocal
+#undef mdn_res_map
+#undef mdn_res_normalize
+#undef mdn_res_prohibitcheck
+#undef mdn_res_unassignedcheck
+#undef mdn_res_delimitermap
+#undef mdn_res_localmap
+#undef mdn_res_ucstodns
+#undef mdn_res_dnstoucs
+
+mdn_result_t
+mdn_res_localtoucs(mdn_resconf_t ctx, const char *from, char *to,
+                  size_t tolen) {
+       return mdn_res_nameconv(ctx, "l", from, to, tolen);
+}
+
+mdn_result_t
+mdn_res_ucstolocal(mdn_resconf_t ctx, const char *from, char *to,
+                  size_t tolen) {
+       return mdn_res_nameconv(ctx, "L", from, to, tolen);
+}
+
+mdn_result_t
+mdn_res_map(mdn_resconf_t ctx, const char *from, char *to, size_t tolen) {
+       return mdn_res_nameconv(ctx, "m", from, to, tolen);
 }
+
+
+mdn_result_t
+mdn_res_normalize(mdn_resconf_t ctx, const char *from, char *to,
+                 size_t tolen) {
+       return mdn_res_nameconv(ctx, "n", from, to, tolen);
+}
+
+mdn_result_t
+mdn_res_prohibitcheck(mdn_resconf_t ctx, const char *from, char *to,
+                     size_t tolen) {
+       return mdn_res_nameconv(ctx, "p", from, to, tolen);
+}
+
+mdn_result_t
+mdn_res_unassignedcheck(mdn_resconf_t ctx, const char *from, char *to,
+                       size_t tolen) {
+       return mdn_res_nameconv(ctx, "u", from, to, tolen);
+}
+
+mdn_result_t
+mdn_res_delimitermap(mdn_resconf_t ctx, const char *from, char *to,
+                    size_t tolen) {
+       return mdn_res_nameconv(ctx, "d", from, to, tolen);
+}
+
+mdn_result_t
+mdn_res_localmap(mdn_resconf_t ctx, const char *from, char *to, size_t tolen) {
+       return mdn_res_nameconv(ctx, "M", from, to, tolen);
+}
+
+mdn_result_t
+mdn_res_ucstodns(mdn_resconf_t ctx, const char *from, char *to,
+                size_t tolen) {
+       return mdn_res_nameconv(ctx, "I", from, to, tolen);
+}
+
+mdn_result_t
+mdn_res_dnstoucs(mdn_resconf_t ctx, const char *from, char *to,
+                size_t tolen) {
+       return mdn_res_nameconv(ctx, "i", from, to, tolen);
+}
+
index ae56fc07698ced5a3014894d3fc4e022285e3a54..bf886f7ddd0fb13f42f39da7036c00f7da356d55 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
-static char *rcsid = "$Id: resconf.c,v 1.4 2000/09/20 02:47:32 ishisone Exp $";
+static char *rcsid = "$Id: resconf.c,v 1.25 2001/04/16 02:25:17 m-kasahr Exp $";
 #endif
 
 /*
@@ -75,7 +75,10 @@ static char *rcsid = "$Id: resconf.c,v 1.4 2000/09/20 02:47:32 ishisone Exp $";
 #include <mdn/logmacro.h>
 #include <mdn/converter.h>
 #include <mdn/normalizer.h>
-#include <mdn/translator.h>
+#include <mdn/checker.h>
+#include <mdn/mapper.h>
+#include <mdn/mapselector.h>
+#include <mdn/delimitermap.h>
 #include <mdn/localencoding.h>
 #include <mdn/resconf.h>
 #include <mdn/debug.h>
@@ -83,33 +86,50 @@ static char *rcsid = "$Id: resconf.c,v 1.4 2000/09/20 02:47:32 ishisone Exp $";
 #ifndef MDN_RESCONF_DIR
 #define MDN_RESCONF_DIR                "/etc"
 #endif
-#define MDN_RESCONF_FILE       MDN_RESCONF_DIR "/mdnres.conf"
+#define MDN_RESCONF_FILE       MDN_RESCONF_DIR "/mdn.conf"
+
+#define MAX_CONF_LINE_LENGTH   255
+#define MAX_CONF_LINE_ARGS     63
 
 struct mdn_resconf {
        char *local_encoding;
        mdn_converter_t local_converter;
+       mdn_converter_t idn_converter;
        mdn_converter_t alternate_converter;
-       mdn_converter_t server_converter;
        mdn_normalizer_t normalizer;
-       char *zld;
-       int edns0;
+       mdn_checker_t prohibit_checker;
+       mdn_checker_t unassigned_checker;
+       mdn_mapper_t mapper;
+       mdn_mapselector_t local_mapper;
+       mdn_delimitermap_t delimiter_mapper;
+       int reference_count;
 };
 
 static mdn_result_t    parse_conf(mdn_resconf_t ctx, FILE *fp);
-static mdn_result_t    parse_normalize(mdn_resconf_t ctx, int argc,
-                                       char **argv);
-static mdn_result_t    parse_alias_file(mdn_resconf_t ctx, int argc,
-                                        char **argv);
-static mdn_result_t    parse_server_encoding(mdn_resconf_t ctx, int argc,
-                                             char **argv);
-static mdn_result_t    parse_server_zld(mdn_resconf_t ctx, int argc,
-                                        char **argv);
-static mdn_result_t    parse_alternate_encoding(mdn_resconf_t ctx, int argc,
-                                               char **argv);
-static int             split_args(char *s, char **av, int nav);
+static mdn_result_t    parse_alternate_encoding(mdn_resconf_t ctx,
+                                                char *args, int lineno);
+static mdn_result_t    parse_delimiter_map(mdn_resconf_t ctx, char *args,
+                                           int lineno);
+static mdn_result_t    parse_encoding_alias_file(mdn_resconf_t ctx,
+                                                 char *args, int lineno);
+static mdn_result_t    parse_idn_encoding(mdn_resconf_t ctx, char *args,
+                                          int lineno);
+static mdn_result_t    parse_local_map(mdn_resconf_t ctx, char *args,
+                                       int lineno);
+static mdn_result_t    parse_nameprep(mdn_resconf_t ctx, char *args,
+                                      int lineno, char **nameprep);
+static mdn_result_t    parse_map(mdn_resconf_t ctx, char *args, int lineno);
+static mdn_result_t    parse_normalize(mdn_resconf_t ctx, char *args,
+                                       int lineno);
+static mdn_result_t    parse_prohibit(mdn_resconf_t ctx, char *args,
+                                      int lineno);
+static mdn_result_t    parse_unassigned(mdn_resconf_t ctx, char *args,
+                                        int lineno);
+static int             split_args(char *s, char **av, int max_ac);
 static void            resetconf(mdn_resconf_t ctx);
 static mdn_result_t    update_local_converter(mdn_resconf_t ctx);
 static mdn_result_t    mystrdup(const char *from, char **top);
+static const char *    get_ucs(const char *p, unsigned long *vp);
 
 mdn_result_t
 mdn_resconf_initialize(void) {
@@ -117,11 +137,21 @@ mdn_resconf_initialize(void) {
 
        TRACE(("mdn_resconf_initialize()\n"));
 
+       /*
+        * Initialize sub modules.
+        */
        if ((r = mdn_converter_initialize()) != mdn_success)
                return (r);
        if ((r = mdn_normalizer_initialize()) != mdn_success)
                return (r);
-       return (r);
+       if ((r = mdn_checker_initialize()) != mdn_success)
+               return (r);
+       if ((r = mdn_mapselector_initialize()) != mdn_success)
+               return (r);
+       if ((r = mdn_mapper_initialize()) != mdn_success)
+               return (r);
+
+       return (mdn_success);
 }
 
 mdn_result_t
@@ -134,14 +164,21 @@ mdn_resconf_create(mdn_resconf_t *ctxp) {
 
        if ((ctx = malloc(sizeof(*ctx))) == NULL)
                return (mdn_nomemory);
+
        ctx->local_encoding = NULL;
        ctx->local_converter = NULL;
-       ctx->server_converter = NULL;
+       ctx->idn_converter = NULL;
        ctx->alternate_converter = NULL;
        ctx->normalizer = NULL;
-       ctx->zld = NULL;
-       ctx->edns0 = 0;
+       ctx->prohibit_checker = NULL;
+       ctx->unassigned_checker = NULL;
+       ctx->mapper = NULL;
+       ctx->local_mapper = NULL;
+       ctx->delimiter_mapper = NULL;
+       ctx->reference_count = 1;
+
        *ctxp = ctx;
+
        return (mdn_success);
 }
 
@@ -181,96 +218,655 @@ mdn_resconf_loadfile(mdn_resconf_t ctx, const char *file) {
 void
 mdn_resconf_destroy(mdn_resconf_t ctx) {
        TRACE(("mdn_resconf_destroy()\n"));
-       resetconf(ctx);
-       free(ctx);
+       TRACE(("mdn_resconf_destroy: update reference count (%d->%d)\n",
+           ctx->reference_count, ctx->reference_count - 1));
+
+       ctx->reference_count--;
+       if (ctx->reference_count <= 0) {
+               TRACE(("mdn_converter_destroy: the object is destroyed\n"));
+               resetconf(ctx);
+               free(ctx);
+       }
+}
+
+void
+mdn_resconf_incrref(mdn_resconf_t ctx) {
+       assert(ctx != NULL);
+
+       TRACE(("mdn_resconf_incrref()\n"));
+       TRACE(("mdn_resconf_incrref: update reference count (%d->%d)\n",
+               ctx->reference_count, ctx->reference_count + 1));
+
+       ctx->reference_count++;
 }
 
 mdn_converter_t
-mdn_resconf_localconverter(mdn_resconf_t ctx) {
-       TRACE(("mdn_resconf_localconverter()\n"));
-       if (update_local_converter(ctx) != mdn_success)
-               return (NULL);
-       return (ctx->local_converter);
+mdn_resconf_getalternateconverter(mdn_resconf_t ctx) {
+       TRACE(("mdn_resconf_alternateconverter()\n"));
+
+       if (ctx->alternate_converter != NULL)
+               mdn_converter_incrref(ctx->alternate_converter);
+       return (ctx->alternate_converter);
+}
+
+mdn_delimitermap_t
+mdn_resconf_getdelimitermap(mdn_resconf_t ctx) {
+       TRACE(("mdn_resconf_getdelimitermap()\n"));
+
+       if (ctx->delimiter_mapper != NULL)
+               mdn_delimitermap_incrref(ctx->delimiter_mapper);
+       return (ctx->delimiter_mapper);
 }
 
 mdn_converter_t
-mdn_resconf_serverconverter(mdn_resconf_t ctx) {
-       TRACE(("mdn_resconf_serverconverter()\n"));
-       return (ctx->server_converter);
+mdn_resconf_getidnconverter(mdn_resconf_t ctx) {
+       TRACE(("mdn_resconf_getidnconverter()\n"));
+
+       if (ctx->idn_converter != NULL)
+               mdn_converter_incrref(ctx->idn_converter);
+       return (ctx->idn_converter);
 }
 
 mdn_converter_t
-mdn_resconf_alternateconverter(mdn_resconf_t ctx) {
-       TRACE(("mdn_resconf_alternateconverter()\n"));
-       return (ctx->alternate_converter);
+mdn_resconf_getlocalconverter(mdn_resconf_t ctx) {
+       TRACE(("mdn_resconf_getlocalconverter()\n"));
+
+       if (update_local_converter(ctx) != mdn_success)
+               return (NULL);
+       mdn_converter_incrref(ctx->local_converter);
+       return (ctx->local_converter);
 }
 
-const char *
-mdn_resconf_zld(mdn_resconf_t ctx) {
-       TRACE(("mdn_resconf_zld()\n"));
-       return (ctx->zld);
+mdn_mapselector_t
+mdn_resconf_getlocalmapselector(mdn_resconf_t ctx) {
+       TRACE(("mdn_resconf_getlocalmapselector()\n"));
+
+       if (ctx->local_mapper != NULL)
+               mdn_mapselector_incrref(ctx->local_mapper);
+       return (ctx->local_mapper);
+}
+
+mdn_mapper_t
+mdn_resconf_getmapper(mdn_resconf_t ctx) {
+       TRACE(("mdn_resconf_getmapper()\n"));
+
+       if (ctx->mapper != NULL)
+               mdn_mapper_incrref(ctx->mapper);
+       return (ctx->mapper);
 }
 
 mdn_normalizer_t
-mdn_resconf_normalizer(mdn_resconf_t ctx) {
-       TRACE(("mdn_resconf_normalizer()\n"));
+mdn_resconf_getnormalizer(mdn_resconf_t ctx) {
+       TRACE(("mdn_resconf_getnormalizer()\n"));
+
+       if (ctx->normalizer != NULL)
+               mdn_normalizer_incrref(ctx->normalizer);
        return (ctx->normalizer);
 }
 
+mdn_checker_t
+mdn_resconf_getprohibitchecker(mdn_resconf_t ctx) {
+       TRACE(("mdn_resconf_getprohibitchecker()\n"));
+
+       if (ctx->prohibit_checker != NULL)
+               mdn_checker_incrref(ctx->prohibit_checker);
+       return (ctx->prohibit_checker);
+}
+
+mdn_checker_t
+mdn_resconf_getunassignedchecker(mdn_resconf_t ctx) {
+       TRACE(("mdn_resconf_getunassignedchecker()\n"));
+
+       if (ctx->unassigned_checker != NULL)
+               mdn_checker_incrref(ctx->unassigned_checker);
+       return (ctx->unassigned_checker);
+}
+
+void
+mdn_resconf_setalternateconverter(mdn_resconf_t ctx,
+                                 mdn_converter_t alternate_converter) {
+       TRACE(("mdn_resconf_setalternateconverter()\n"));
+
+       if (ctx->alternate_converter != NULL)
+               mdn_converter_destroy(ctx->alternate_converter);
+       ctx->alternate_converter = alternate_converter;
+       mdn_converter_incrref(ctx->alternate_converter);
+}
+
+void
+mdn_resconf_setdelimitermap(mdn_resconf_t ctx,
+                           mdn_delimitermap_t delimiter_mapper) {
+       TRACE(("mdn_resconf_setdelimitermap()\n"));
+       if (ctx->delimiter_mapper != NULL)
+               mdn_delimitermap_destroy(ctx->delimiter_mapper);
+       ctx->delimiter_mapper = delimiter_mapper;
+       mdn_delimitermap_incrref(ctx->delimiter_mapper);
+}
+
+void
+mdn_resconf_setidnconverter(mdn_resconf_t ctx, 
+                           mdn_converter_t idn_converter) {
+       TRACE(("mdn_resconf_setidnconverter()\n"));
+
+       if (ctx->idn_converter != NULL)
+               mdn_converter_destroy(ctx->idn_converter);
+       ctx->idn_converter = idn_converter;
+       mdn_converter_incrref(ctx->idn_converter);
+}
+
+void
+mdn_resconf_setlocalconverter(mdn_resconf_t ctx,
+                                 mdn_converter_t local_converter) {
+       TRACE(("mdn_resconf_setlocalconverter()\n"));
+
+       if (ctx->local_converter != NULL)
+               mdn_converter_destroy(ctx->local_converter);
+       free(ctx->local_encoding);
+       ctx->local_encoding = NULL;     /* See update_local_converter(). */
+       ctx->local_converter = local_converter;
+       if (local_converter != NULL)
+               mdn_converter_incrref(local_converter);
+}
+
+void
+mdn_resconf_setlocalmapselector(mdn_resconf_t ctx,
+                               mdn_mapselector_t local_mapper) {
+       TRACE(("mdn_resconf_setlocalmapselector()\n"));
+
+       if (ctx->local_mapper != NULL)
+               mdn_mapselector_destroy(ctx->local_mapper);
+       ctx->local_mapper = local_mapper;
+       mdn_mapselector_incrref(ctx->local_mapper);
+}
+
+void
+mdn_resconf_setmapper(mdn_resconf_t ctx, mdn_mapper_t mapper) {
+       TRACE(("mdn_resconf_setmapper()\n"));
+
+       if (ctx->mapper != NULL)
+               mdn_mapper_destroy(ctx->mapper);
+       ctx->mapper = mapper;
+       mdn_mapper_incrref(ctx->mapper);
+}
+
+void
+mdn_resconf_setnormalizer(mdn_resconf_t ctx, mdn_normalizer_t normalizer) {
+       TRACE(("mdn_resconf_setnormalizer()\n"));
+
+       if (ctx->normalizer != NULL)
+               mdn_normalizer_destroy(ctx->normalizer);
+       ctx->normalizer = normalizer;
+       mdn_normalizer_incrref(ctx->normalizer);
+}
+
+void
+mdn_resconf_setprohibitchecker(mdn_resconf_t ctx,
+                              mdn_checker_t prohibit_checker) {
+       TRACE(("mdn_resconf_setprohibitchecker()\n"));
+
+       if (ctx->prohibit_checker != NULL)
+               mdn_checker_destroy(ctx->prohibit_checker);
+       ctx->prohibit_checker = prohibit_checker;
+       mdn_checker_incrref(ctx->prohibit_checker);
+}
+
+void
+mdn_resconf_setunassignedchecker(mdn_resconf_t ctx,
+                                mdn_checker_t unassigned_checker) {
+       TRACE(("mdn_resconf_setunassignedchecker()\n"));
+       if (ctx->unassigned_checker != NULL)
+               mdn_checker_destroy(ctx->unassigned_checker);
+       ctx->unassigned_checker = unassigned_checker;
+       mdn_checker_incrref(ctx->unassigned_checker);
+}
+
+mdn_result_t
+mdn_resconf_setnameprepversion(mdn_resconf_t ctx, const char *version)
+{
+       char prohibit_scheme_name[MAX_CONF_LINE_LENGTH + 1];
+       char unassigned_scheme_name[MAX_CONF_LINE_LENGTH + 1];
+       mdn_mapper_t mapper = NULL;
+       mdn_normalizer_t normalizer = NULL;
+       mdn_checker_t prohibit_checker = NULL;
+       mdn_checker_t unassigned_checker = NULL;
+       mdn_result_t r;
+
+       assert(ctx != NULL && version != NULL);
+
+       TRACE(("mdn_resconf_setnameprepversion()\n"));
+
+       /*
+        * Set canonical scheme names.
+        */
+       if (strlen(version) + strlen(MDN_CHECKER_PROHIBIT_PREFIX)
+           > MAX_CONF_LINE_LENGTH) {
+               r = mdn_invalid_name;
+               goto failure;
+       }
+       sprintf(prohibit_scheme_name, "%s%s",
+               MDN_CHECKER_PROHIBIT_PREFIX, version);
+
+       if (strlen(version) + strlen(MDN_CHECKER_UNASSIGNED_PREFIX)
+           > MAX_CONF_LINE_LENGTH) {
+               r = mdn_invalid_name;
+               goto failure;
+       }
+       sprintf(unassigned_scheme_name, "%s%s",
+               MDN_CHECKER_UNASSIGNED_PREFIX, version);
+
+       /*
+        * Create objects.
+        */
+       r = mdn_mapper_create(&mapper);
+       if (r != mdn_success)
+               goto failure;
+       r = mdn_normalizer_create(&normalizer);
+       if (r != mdn_success)
+               goto failure;
+       r = mdn_checker_create(&prohibit_checker);
+       if (r != mdn_success)
+               goto failure;
+       r = mdn_checker_create(&unassigned_checker);
+       if (r != mdn_success)
+               goto failure;
+
+       r = mdn_mapper_add(mapper, version);
+       if (r != mdn_success)
+               goto failure;
+       r = mdn_normalizer_add(normalizer, version);
+       if (r != mdn_success)
+               goto failure;
+       r = mdn_checker_add(prohibit_checker, prohibit_scheme_name);
+       if (r != mdn_success)
+               goto failure;
+       r = mdn_checker_add(unassigned_checker, unassigned_scheme_name);
+       if (r != mdn_success)
+               goto failure;
+
+       /*
+        * Set the objects.
+        */
+       mdn_resconf_setmapper(ctx, mapper);
+       mdn_resconf_setnormalizer(ctx, normalizer);
+       mdn_resconf_setprohibitchecker(ctx, prohibit_checker);
+       mdn_resconf_setunassignedchecker(ctx, unassigned_checker);
+
+       /*
+        * Destroy the objects.
+        */
+       mdn_mapper_destroy(mapper);
+       mdn_normalizer_destroy(normalizer);
+       mdn_checker_destroy(prohibit_checker);
+       mdn_checker_destroy(unassigned_checker);
+
+       return (mdn_success);
+
+failure:
+       if (mapper != NULL)
+               mdn_mapper_destroy(mapper);
+       if (normalizer != NULL)
+               mdn_normalizer_destroy(normalizer);
+       if (prohibit_checker != NULL)
+               mdn_checker_destroy(prohibit_checker);
+       if (unassigned_checker != NULL)
+               mdn_checker_destroy(unassigned_checker);
+
+       return (r);
+}
+
+mdn_result_t
+mdn_resconf_setalternateconvertername(mdn_resconf_t ctx, const char *name,
+                                     int flags) {
+       mdn_converter_t alternate_converter;
+       mdn_result_t r;
+
+       assert(ctx != NULL && name != NULL);
+
+       TRACE(("mdn_resconf_setalternateconvertername(name=%s, flags=%d)\n",
+             name, flags));
+
+       r = mdn_converter_create(name, &alternate_converter, flags);
+       if (r != mdn_success)
+               return (r);
+
+       if (!mdn_converter_isasciicompatible(alternate_converter)) {
+               mdn_converter_destroy(alternate_converter);
+               return (mdn_invalid_name);
+       }
+
+       if (ctx->alternate_converter != NULL)
+               mdn_converter_destroy(ctx->alternate_converter);
+       ctx->alternate_converter = alternate_converter;
+
+       return (mdn_success);
+}
+
+mdn_result_t
+mdn_resconf_setidnconvertername(mdn_resconf_t ctx, const char *name,
+                               int flags) {
+       mdn_converter_t idn_converter;
+       mdn_result_t r;
+
+       assert(ctx != NULL && name != NULL);
+
+       TRACE(("mdn_resconf_setidnconvertername(name=%s, flags=%d)\n",
+             name, flags));
+
+       r = mdn_converter_create(name, &idn_converter, flags);
+       if (r != mdn_success)
+               return (r);
+
+       if (ctx->idn_converter != NULL)
+               mdn_converter_destroy(ctx->idn_converter);
+       ctx->idn_converter = idn_converter;
+
+       return (mdn_success);
+}
+
+mdn_result_t
+mdn_resconf_setlocalconvertername(mdn_resconf_t ctx, const char *name,
+                                 int flags) {
+       mdn_converter_t local_converter;
+       char *local_encoding = NULL;
+       mdn_result_t r;
+
+       assert(ctx != NULL);
+
+       TRACE(("mdn_resconf_setlocalconvertername(mame=%s, flags=%d)\n",
+             name == NULL ? "<null>" : name, flags));
+
+       if (name == NULL) {
+               local_converter = NULL;
+       } else {
+               r = mdn_converter_create(name, &local_converter, flags);
+               if (r != mdn_success) {
+                       free(local_encoding);
+                       return (r);
+               }
+       }
+       if (ctx->local_converter != NULL)
+               mdn_converter_destroy(ctx->local_converter);
+       free(ctx->local_encoding);
+       ctx->local_converter = local_converter;
+       ctx->local_encoding = NULL;     /* See update_local_converter(). */
+
+       return (mdn_success);
+}
+
+mdn_result_t
+mdn_resconf_addalldelimitermapucs(mdn_resconf_t ctx, unsigned long *v,
+                                 int nv) {
+       mdn_result_t r;
+
+       TRACE(("mdn_resconf_addalldelimitermapucs(nv=%d)\n", nv));
+
+       if (ctx->delimiter_mapper == NULL) {
+               r = mdn_delimitermap_create(&(ctx->delimiter_mapper));
+               if (r != mdn_success)
+                       return (r);
+       }
+
+       r = mdn_delimitermap_addall(ctx->delimiter_mapper, v, nv);
+       return (r);
+}
+
+mdn_result_t
+mdn_resconf_addalllocalmapselectornames(mdn_resconf_t ctx, const char *tld,
+                                       const char **names, int nnames) {
+       mdn_result_t r;
+
+       assert(ctx != NULL && names != NULL);
+
+       TRACE(("mdn_resconf_addalllocalmapselectorname(tld=%s, nnames=%d)\n",
+             tld, nnames));
+
+       if (ctx->local_mapper == NULL) {
+               r = mdn_mapselector_create(&(ctx->local_mapper));
+               if (r != mdn_success)
+                       return (r);
+       }
+
+       r = mdn_mapselector_addall(ctx->local_mapper, tld, names, nnames);
+       return (r);
+}
+
+mdn_result_t
+mdn_resconf_addallmappernames(mdn_resconf_t ctx, const char **names,
+                             int nnames) {
+       mdn_result_t r;
+
+       assert(ctx != NULL && names != NULL);
+
+       TRACE(("mdn_resconf_addallmappername()\n"));
+
+       if (ctx->mapper == NULL) {
+               r = mdn_mapper_create(&(ctx->mapper));
+               if (r != mdn_success)
+                       return (r);
+       }
+
+       r = mdn_mapper_addall(ctx->mapper, names, nnames);
+       return (r);
+}
+
+mdn_result_t
+mdn_resconf_addallnormalizernames(mdn_resconf_t ctx, const char **names,
+                                 int nnames) {
+       mdn_result_t r;
+
+       assert(ctx != NULL && names != NULL);
+
+       TRACE(("mdn_resconf_addallnormalizername(nnames=%d)\n", nnames));
+
+       if (ctx->normalizer == NULL) {
+               r = mdn_normalizer_create(&(ctx->normalizer));
+               if (r != mdn_success)
+                       return (r);
+       }
+
+       r = mdn_normalizer_addall(ctx->normalizer, names, nnames);
+       return (r);
+}
+
+mdn_result_t
+mdn_resconf_addallprohibitcheckernames(mdn_resconf_t ctx, const char **names,
+                                      int nnames) {
+       char long_name[MAX_CONF_LINE_LENGTH + 1];
+       mdn_result_t r;
+       int i;
+
+       assert(ctx != NULL && names != NULL);
+
+       TRACE(("mdn_resconf_addallprohibitcheckername(nnames=%d)\n", nnames));
+
+       if (ctx->prohibit_checker == NULL) {
+               r = mdn_checker_create(&(ctx->prohibit_checker));
+               if (r != mdn_success)
+                       return (r);
+       }
+
+       for (i = 0; i < nnames; i++, names++) {
+               if (strlen(*names) + strlen(MDN_CHECKER_PROHIBIT_PREFIX)
+                       > MAX_CONF_LINE_LENGTH) {
+                       return (mdn_invalid_name);
+               }
+               strcpy(long_name, MDN_CHECKER_PROHIBIT_PREFIX);
+               strcat(long_name, *names);
+
+               r = mdn_checker_add(ctx->prohibit_checker, long_name);
+               if (r != mdn_success)
+                       return (r);
+       }
+
+       return (mdn_success);
+}
+
+mdn_result_t
+mdn_resconf_addallunassignedcheckernames(mdn_resconf_t ctx, const char **names,
+                                        int nnames) {
+       char long_name[MAX_CONF_LINE_LENGTH + 1];
+       mdn_result_t r;
+       int i;
+
+       assert(ctx != NULL && names != NULL);
+
+       TRACE(("mdn_resconf_addallunassignedcheckername(nnames=%d)\n",
+             nnames));
+
+       if (ctx->unassigned_checker == NULL) {
+               r = mdn_checker_create(&(ctx->unassigned_checker));
+               if (r != mdn_success)
+                       return (r);
+       }
+
+       for (i = 0; i < nnames; i++, names++) {
+               if (strlen(*names) + strlen(MDN_CHECKER_UNASSIGNED_PREFIX)
+                       > MAX_CONF_LINE_LENGTH) {
+                       return (mdn_invalid_name);
+               }
+               strcpy(long_name, MDN_CHECKER_UNASSIGNED_PREFIX);
+               strcat(long_name, *names);
+
+               r = mdn_checker_add(ctx->unassigned_checker, long_name);
+               if (r != mdn_success)
+                       return (r);
+       }
+
+       return (mdn_success);
+}
+
 static mdn_result_t
 parse_conf(mdn_resconf_t ctx, FILE *fp) {
-       char line[256];
-       char *argv[20];
+       char line[MAX_CONF_LINE_LENGTH + 1];
+       int lineno = 0;
+       char *argv[3];
        int argc;
        mdn_result_t r;
-       char *sencoding_line = NULL;
-       char *fencoding_line = NULL;
+       char *alternate_encoding_args = NULL;
+       int alternate_encoding_lineno = 0;
+       char *idn_encoding_args = NULL;
+       int idn_encoding_lineno = 0;
+       char *nameprep = NULL;
 
        /*
-        * Parse config file.  parsing of 'server-encoding' and
-        * 'alternate-encoding' lines are postponed because
+        * Parse config file.  parsing of 'alternate-encoding' and
+        * 'idn-encoding' lines are postponed because
         * 'alias-file' line must be processed before them.
         */
        while (fgets(line, sizeof(line), fp) != NULL) {
-               char buf[256];
+               char *newline;
 
-               if (line[0] == '\n')
-                       continue;
+               lineno++;
+               newline = strpbrk(line, "\r\n");
+               if (newline != NULL)
+                       *newline = '\0';
+               else if (fgetc(fp) != EOF) {
+                       mdn_log_error("mdnres: too long line \"%-.30s\", "
+                                     "line %d", line, lineno);
+                       return (mdn_invalid_syntax);
+               }
 
-               (void)strcpy(buf, line);
-               argc = split_args(buf, argv, 20);
-               if (argc == 0 || argv[0][0] == '#')
+               argc = split_args(line, argv, 2);
+               if (argc == -1) {
+                       mdn_log_error("mdnres: syntax error, line %d\n",
+                               lineno);
+                       return (mdn_invalid_syntax);
+               } else if (argc == 0 || argv[0][0] == '#') {
                        continue;
-               if (strcmp(argv[0], "normalize") == 0)
-                       r = parse_normalize(ctx, argc, argv);
-               else if (strcmp(argv[0], "alias-file") == 0)
-                       r = parse_alias_file(ctx, argc, argv);
-               else if (strcmp(argv[0], "server-zld") == 0)
-                       r = parse_server_zld(ctx, argc, argv);
-               else if (strcmp(argv[0], "server-encoding") == 0)
-                       r = mystrdup(line, &sencoding_line);
-               else if (strcmp(argv[0], "alternate-encoding") == 0)
-                       r = mystrdup(line, &fencoding_line);
-               else {
+               }
+
+               if (strcmp(argv[0], "alternate-encoding") == 0) {
+                       r = mystrdup(argv[1], &alternate_encoding_args);
+                       if (r != mdn_success) {
+                               mdn_log_error("mdnres: %s, line %d\n",
+                                             mdn_result_tostring(r), lineno);
+                       }
+                       alternate_encoding_lineno = lineno;
+
+               } else if (strcmp(argv[0], "delimiter-map") == 0) {
+                       r = parse_delimiter_map(ctx, argv[1], lineno);
+
+               } else if (strcmp(argv[0], "encoding-alias-file") == 0) {
+                       r = parse_encoding_alias_file(ctx, argv[1], lineno);
+
+               } else if (strcmp(argv[0], "idn-encoding") == 0) {
+                       r = mystrdup(argv[1], &idn_encoding_args);
+                       if (r != mdn_success) {
+                               mdn_log_error("mdnres: %s, line %d\n",
+                                             mdn_result_tostring(r), lineno);
+                       }
+                       idn_encoding_lineno = lineno;
+
+               } else if (strcmp(argv[0], "local-map") == 0) {
+                       r = parse_local_map(ctx, argv[1], lineno);
+
+               } else if (strcmp(argv[0], "nameprep") == 0) {
+                       r = parse_nameprep(ctx, argv[1], lineno, &nameprep);
+
+               } else if (strcmp(argv[0], "nameprep-map") == 0) {
+                       r = parse_map(ctx, argv[1], lineno);
+
+               } else if (strcmp(argv[0], "nameprep-normalize") == 0) {
+                       r = parse_normalize(ctx, argv[1], lineno);
+
+               } else if (strcmp(argv[0], "nameprep-prohibit") == 0) {
+                       r = parse_prohibit(ctx, argv[1], lineno);
+
+               } else if (strcmp(argv[0], "nameprep-unassigned") == 0) {
+                       r = parse_unassigned(ctx, argv[1], lineno);
+
+               } else if (strcmp(argv[0], "server-zld") == 0 || 
+                       strcmp(argv[0], "alias-file") == 0 ||
+                       strcmp(argv[0], "normalize") == 0 ||
+                       strcmp(argv[0], "server-encoding") == 0) {
+                       mdn_log_warning("mdnres: obsolete command "
+                                       "\"%-.30s\", line %d (ignored)\n",
+                                       argv[0], lineno);
+                       r = mdn_success;
+               } else {
                        mdn_log_error("mdnres: unrecognized command "
-                                     "\"%-.30s\"\n", argv[0]);
+                                     "\"%-.30s\", line %d\n",
+                                     argv[0], lineno);
                        r = mdn_invalid_syntax;
                }
                if (r != mdn_success)
                        return (r);
        }
 
-       if (sencoding_line != NULL) {
-               argc = split_args(sencoding_line, argv, 50);
-               r = parse_server_encoding(ctx, argc, argv);
-               free(sencoding_line);
+       lineno++;
+
+       if (nameprep != NULL) {
+               if (ctx->mapper == NULL) {
+                       r = parse_map(ctx, nameprep, lineno);
+                       if (r != mdn_success)
+                               return (r);
+               }
+               if (ctx->normalizer == NULL) {
+                       r = parse_normalize(ctx, nameprep, lineno);
+                       if (r != mdn_success)
+                               return (r);
+               }
+               if (ctx->prohibit_checker == NULL) {
+                       r = parse_prohibit(ctx, nameprep, lineno);
+                       if (r != mdn_success)
+                               return (r);
+               }
+               if (ctx->unassigned_checker == NULL) {
+                       r = parse_unassigned(ctx, nameprep, lineno);
+                       if (r != mdn_success)
+                               return (r);
+               }
+       }
+
+       if (alternate_encoding_args != NULL) {
+               r = parse_alternate_encoding(ctx, alternate_encoding_args,
+                                            alternate_encoding_lineno);
                if (r != mdn_success)
                        return (r);
        }
-       if (fencoding_line != NULL) {
-               argc = split_args(fencoding_line, argv, 50);
-               r = parse_alternate_encoding(ctx, argc, argv);
-               free(fencoding_line);
+       if (idn_encoding_args != NULL) {
+               r = parse_idn_encoding(ctx, idn_encoding_args,
+                                      idn_encoding_lineno);
                if (r != mdn_success)
                        return (r);
        }
@@ -279,127 +875,407 @@ parse_conf(mdn_resconf_t ctx, FILE *fp) {
 }
 
 static mdn_result_t
-parse_normalize(mdn_resconf_t ctx, int argc, char **argv) {
+parse_alternate_encoding(mdn_resconf_t ctx, char *args, int lineno) {
        mdn_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) {
+               mdn_log_error("mdnres: wrong # of args for "
+                             "alternate-encoding, line %d\n", lineno);
+               return (mdn_invalid_syntax);
+       }
+
+       r = mdn_converter_create(argv[0], &ctx->alternate_converter,
+                                MDN_CONVERTER_DELAYEDOPEN);
+       if (r != mdn_success) {
+               mdn_log_error("mdnres: cannot create alternate-encodng "
+                             "converter, %s, line %d\n", 
+                             mdn_result_tostring(r), lineno);
+               return (mdn_invalid_syntax);
+       }
+
+       if (!mdn_converter_isasciicompatible(ctx->alternate_converter)) {
+               mdn_log_error("mdnres: alternate encoding must be "
+                             "ASCII-compatible, line %d\n", lineno);
+               mdn_converter_destroy(ctx->alternate_converter);
+               ctx->alternate_converter = NULL;
+               return (mdn_invalid_name);
+       }
+
+       return (r);
+}
+
+static mdn_result_t
+parse_delimiter_map(mdn_resconf_t ctx, char *args, int lineno) {
+       mdn_result_t r;
+       char *argv[MAX_CONF_LINE_ARGS + 1];
+       int argc;
+       unsigned long ucs;
        int i;
 
-       if (ctx->normalizer == NULL) {
-               r = mdn_normalizer_create(&ctx->normalizer);
-               if (r != mdn_success)
+       argc = split_args(args, argv, MAX_CONF_LINE_ARGS + 1);
+
+       if (argc > MAX_CONF_LINE_ARGS) {
+               mdn_log_error("mdnres: wrong # of args for delimiter-map, "
+                             "line %d\n", lineno);
+               return (mdn_invalid_syntax);
+       }
+
+       if (ctx->delimiter_mapper == NULL) {
+               r = mdn_delimitermap_create(&ctx->delimiter_mapper);
+               if (r != mdn_success) {
+                       mdn_log_error("mdnres: cannot create delimiter "
+                                     "mapper, %s, line %d\n", 
+                                     mdn_result_tostring(r), lineno);
                        return (r);
+               }
        }
-       for (i = 1; i < argc; i++) {
-               r = mdn_normalizer_add(ctx->normalizer, argv[i]);
+
+       for (i = 0; i < argc; i++) {
+               if (get_ucs(argv[i], &ucs) == NULL) {
+                       mdn_log_error("mdnres: invalid delimiter "
+                                     "\"%-.30s\", line %d\n",
+                                     argv[i], lineno);
+                       return (mdn_invalid_syntax);
+               }
+               r = mdn_delimitermap_add(ctx->delimiter_mapper, ucs);
+               if (r == mdn_invalid_codepoint) {
+                       mdn_log_error("mdnres: invalid delimiter "
+                                     "\"%-.30s\", line %d\n",
+                                     argv[i], lineno);
+                       return (r);
+               } else if (r != mdn_success) {
+                       return (r);
+               }
+       }
+
+       return (mdn_success);
+}
+
+static mdn_result_t
+parse_encoding_alias_file(mdn_resconf_t ctx, char *args, int lineno) {
+       mdn_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) {
+               mdn_log_error("mdnres: wrong # of args for "
+                             "encoding-alias-file, line %d\n", lineno);
+               return (mdn_invalid_syntax);
+       }
+
+       r = mdn_converter_aliasfile(argv[0]);
+       if (r != mdn_success) {
+               mdn_log_error("mdnres: cannot set aliasfile, %s, line %d\n",
+                             mdn_result_tostring(r), lineno);
+       }
+
+       return (r);
+}
+
+static mdn_result_t
+parse_idn_encoding(mdn_resconf_t ctx, char *args, int lineno) {
+       mdn_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) {
+               mdn_log_error("mdnres: wrong # of args for idn-encoding, "
+                             "line %d\n", lineno);
+               return (mdn_invalid_syntax);
+       }
+
+       r = mdn_converter_create(argv[0], &ctx->idn_converter,
+                                MDN_CONVERTER_DELAYEDOPEN);
+       if (r != mdn_success) {
+               mdn_log_error("mdnres: cannot create idn converter, %s, "
+                             "line %d\n", mdn_result_tostring(r), lineno);
+       }
+
+       return (r);
+}
+
+static mdn_result_t
+parse_local_map(mdn_resconf_t ctx, char *args, int lineno) {
+       mdn_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) {
+               mdn_log_error("mdnres: wrong # of args for local-map, "
+                             "line %d\n", lineno);
+               return (mdn_invalid_syntax);
+       }
+
+       if (ctx->local_mapper == NULL) {
+               r = mdn_mapselector_create(&ctx->local_mapper);
                if (r != mdn_success) {
-                       if (r == mdn_invalid_name)
-                               mdn_log_error("mdnres: unknown "
-                                             "normalization scheme %-.30s\n",
-                                             argv[i]);
+                       mdn_log_error("mdnres: cannot create local mapper, "
+                                     "%s, line %d\n",
+                                     mdn_result_tostring(r), lineno);
                        return (r);
                }
        }
+
+       for (i = 1; i < argc; i++) {
+               r = mdn_mapselector_add(ctx->local_mapper, argv[0], argv[i]);
+               if (r == mdn_invalid_name) {
+                       mdn_log_error("mdnres: map scheme unavailable "
+                                     "\"%-.30s\", line %d\n",
+                                     argv[i], lineno);
+                       return (r);
+               } else if (r != mdn_success) {
+                       return (r);
+               }
+       }
+
        return (mdn_success);
 }
 
 static mdn_result_t
-parse_alias_file(mdn_resconf_t ctx, int argc, char **argv) {
-       if (argc != 2) {
-               mdn_log_error("mdnres: wrong # of args for %s\n", argv[0]);
+parse_nameprep(mdn_resconf_t ctx, char *args, int lineno, char **nameprep) {
+       mdn_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) {
+               mdn_log_error("mdnres: wrong # of args for nameprep, "
+                             "line %d\n", lineno);
                return (mdn_invalid_syntax);
        }
-       return (mdn_converter_aliasfile(argv[1]));
+
+       r = mystrdup(argv[0], nameprep);
+       if (r != mdn_success) {
+               mdn_log_error("mdnres: cannot set nameprep, %s, line %d\n",
+                             mdn_result_tostring(r), lineno);
+       }
+       
+       return (r);
 }
 
 static mdn_result_t
-parse_server_encoding(mdn_resconf_t ctx, int argc, char **argv) {
-       if (argc != 2) {
-               mdn_log_error("mdnres: wrong # of args for %s\n", argv[0]);
+parse_map(mdn_resconf_t ctx, char *args, int lineno) {
+       mdn_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 > MAX_CONF_LINE_ARGS) {
+               mdn_log_error("mdnres: wrong # of args for map, line %d\n",
+                             lineno);
                return (mdn_invalid_syntax);
        }
-       return (mdn_converter_create(argv[1], &ctx->server_converter,
-                                    MDN_CONVERTER_DELAYEDOPEN));
+
+       if (ctx->mapper == NULL) {
+               r = mdn_mapper_create(&ctx->mapper);
+               if (r != mdn_success) {
+                       mdn_log_error("mdnres: cannot create mapper, %s, "
+                                     "line %d\n", mdn_result_tostring(r),
+                                     lineno);
+                       return (r);
+               }
+       }
+
+       for (i = 0; i < argc; i++) {
+               r = mdn_mapper_add(ctx->mapper, argv[i]);
+               if (r == mdn_invalid_name) {
+                       mdn_log_error("mdnres: map scheme unavailable "
+                                     "\"%-.30s\", line %d\n",
+                                     argv[i], lineno);
+                       return (r);
+               } else if (r != mdn_success) {
+                       return (r);
+               }
+       }
+
+       return (mdn_success);
 }
 
 static mdn_result_t
-parse_server_zld(mdn_resconf_t ctx, int argc, char **argv) {
-#ifdef MDN_SUPPORT_ZLD
+parse_normalize(mdn_resconf_t ctx, char *args, int lineno) {
        mdn_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) {
-               mdn_log_error("mdnres: wrong # of args for %s\n", argv[0]);
+       if (argc > MAX_CONF_LINE_ARGS) {
+               mdn_log_error("mdnres: wrong # of args for normalize, "
+                             "line %d\n", lineno);
                return (mdn_invalid_syntax);
        }
-       r = mdn_translator_canonicalzld(argv[1], &ctx->zld);
-       if (r != mdn_success)
-               return (r);
+
+       if (ctx->normalizer == NULL) {
+               r = mdn_normalizer_create(&ctx->normalizer);
+               if (r != mdn_success) {
+                       mdn_log_error("mdnres: cannot create normalizer, %s, "
+                                     "line %d\n", mdn_result_tostring(r),
+                                     lineno);
+                       return (r);
+               }
+       }
+
+       for (i = 0; i < argc; i++) {
+               r = mdn_normalizer_add(ctx->normalizer, argv[i]);
+               if (r == mdn_invalid_name) {
+                       mdn_log_error("mdnres: unknown normalization scheme "
+                                     "\"%-.30s\", line %d\n",
+                                     argv[i], lineno);
+                       return (r);
+               } else if (r != mdn_success) {
+                       return (r);
+               }
+       }
 
        return (mdn_success);
-#else
-       mdn_log_warning("mdnres: ZLD support is disabled -- ignored\n");
+}
+
+static mdn_result_t
+parse_prohibit(mdn_resconf_t ctx, char *args, int lineno) {
+       mdn_result_t r;
+       char *argv[MAX_CONF_LINE_ARGS + 1];
+       int argc;
+       char scheme_name[MAX_CONF_LINE_LENGTH + 1];
+       int i;
+
+       argc = split_args(args, argv, MAX_CONF_LINE_ARGS + 1);
+
+       if (argc > MAX_CONF_LINE_ARGS) {
+               mdn_log_error("mdnres: wrong # of args for prohibit, "
+                             "line %d\n", lineno);
+               return (mdn_invalid_syntax);
+       }
+
+       if (ctx->prohibit_checker == NULL) {
+               r = mdn_checker_create(&ctx->prohibit_checker);
+               if (r != mdn_success) {
+                       mdn_log_error("mdnres: cannot create prohibit "
+                                     "checker, %s, line %d\n",
+                                     mdn_result_tostring(r), lineno);
+                       return (r);
+               }
+       }
+
+       for (i = 0; i < argc; i++) {
+               sprintf(scheme_name, "%s%s", MDN_CHECKER_PROHIBIT_PREFIX,
+                       argv[i]);
+               r = mdn_checker_add(ctx->prohibit_checker, scheme_name);
+               if (r == mdn_invalid_name) {
+                       mdn_log_error("mdnres: prohibit scheme unavailable "
+                                     "\"%-.30s\", line %d\n",
+                                     argv[i], lineno);
+                       return (r);
+               } else if (r != mdn_success) {
+                       return (r);
+               }
+       }
+
        return (mdn_success);
-#endif /* MDN_SUPPORT_ZLD */
 }
 
 static mdn_result_t
-parse_alternate_encoding(mdn_resconf_t ctx, int argc, char **argv) {
+parse_unassigned(mdn_resconf_t ctx, char *args, int lineno) {
        mdn_result_t r;
+       char *argv[MAX_CONF_LINE_ARGS + 1];
+       int argc;
+       char scheme_name[MAX_CONF_LINE_LENGTH + 1];
+       int i;
+
+       argc = split_args(args, argv, MAX_CONF_LINE_ARGS + 1);
 
-       if (argc != 2) {
-               mdn_log_error("mdnres: wrong # of args for %s\n", argv[0]);
+       if (argc > MAX_CONF_LINE_ARGS) {
+               mdn_log_error("mdnres: wrong # of args for unassigned, "
+                             "line %d\n", lineno);
                return (mdn_invalid_syntax);
        }
-       r = mdn_converter_create(argv[1], &ctx->alternate_converter,
-                                MDN_CONVERTER_DELAYEDOPEN);
-       if (r == mdn_success &&
-           !mdn_converter_isasciicompatible(ctx->alternate_converter)) {
-               mdn_log_error("mdnres: alternate encoding must be "
-                             "ASCII-compatible\n");
-               mdn_converter_destroy(ctx->alternate_converter);
-               ctx->alternate_converter = NULL;
-               return (mdn_invalid_name);
+
+       if (ctx->unassigned_checker == NULL) {
+               r = mdn_checker_create(&ctx->unassigned_checker);
+               if (r != mdn_success) {
+                       mdn_log_error("mdnres: cannot create unassigned "
+                                     "checker, %s, line %d\n",
+                                     mdn_result_tostring(r), lineno);
+                       return (r);
+               }
        }
-       return (r);
+
+       for (i = 0; i < argc; i++) {
+               sprintf(scheme_name, "%s%s", MDN_CHECKER_UNASSIGNED_PREFIX,
+                       argv[i]);
+               r = mdn_checker_add(ctx->unassigned_checker, scheme_name);
+               if (r == mdn_invalid_name) {
+                       mdn_log_error("mdnres: unassigned scheme unavailable "
+                                     "\"%-.30s\", line %d\n",
+                                     argv[i], lineno);
+                       return (r);
+               } else if (r != mdn_success) {
+                       return (r);
+               }
+       }
+
+       return (mdn_success);
 }
 
 static int
-split_args(char *s, char **av, int nav) {
+split_args(char *s, char **av, int max_ac) {
+       int ac;
        int i;
 
-       for (i = 0; i < nav; 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[i] = s;
-                       while (*s != '\0' && *s != qc)
+                       av[ac] = s;
+                       while (*s != qc) {
+                               if (*s == '\0')
+                                       return (-1);
                                s++;
+                       }
                } else {
-                       av[i] = s;
+                       av[ac] = s;
                        while (*s != '\0' && !isspace((unsigned char)*s))
                                s++;
                }
-               if (*s == '\0')
-                       return (i + 1);
-               *s++ = '\0';
        }
-       return (i);
+
+       for (i = ac; i < max_ac; i++)
+               av[i] = NULL;
+
+       return (ac);
 }
 
 static void
 resetconf(mdn_resconf_t ctx) {
-       if (ctx->local_encoding != NULL) {
-               free(ctx->local_encoding);
-               ctx->local_encoding = NULL;
-       }
+       free(ctx->local_encoding);
+       ctx->local_encoding = NULL;
+
        if (ctx->local_converter != NULL) {
                mdn_converter_destroy(ctx->local_converter);
                ctx->local_converter = NULL;
        }
-       if (ctx->server_converter != NULL) {
-               mdn_converter_destroy(ctx->server_converter);
-               ctx->server_converter = NULL;
+       if (ctx->idn_converter != NULL) {
+               mdn_converter_destroy(ctx->idn_converter);
+               ctx->idn_converter = NULL;
        }
        if (ctx->alternate_converter != NULL) {
                mdn_converter_destroy(ctx->alternate_converter);
@@ -409,40 +1285,64 @@ resetconf(mdn_resconf_t ctx) {
                mdn_normalizer_destroy(ctx->normalizer);
                ctx->normalizer = NULL;
        }
-       if (ctx->zld != NULL) {
-               free(ctx->zld);
-               ctx->zld = NULL;
+       if (ctx->prohibit_checker != NULL) {
+               mdn_checker_destroy(ctx->prohibit_checker);
+               ctx->prohibit_checker = NULL;
+       }
+       if (ctx->unassigned_checker != NULL) {
+               mdn_checker_destroy(ctx->unassigned_checker);
+               ctx->unassigned_checker = NULL;
+       }
+       if (ctx->mapper != NULL) {
+               mdn_mapper_destroy(ctx->mapper);
+               ctx->mapper = NULL;
+       }
+       if (ctx->local_mapper != NULL) {
+               mdn_mapselector_destroy(ctx->local_mapper);
+               ctx->local_mapper = NULL;
+       }
+       if (ctx->delimiter_mapper != NULL) {
+               mdn_delimitermap_destroy(ctx->delimiter_mapper);
+               ctx->delimiter_mapper = NULL;
        }
-       ctx->edns0 = 0;
 }
 
-
 static mdn_result_t
 update_local_converter(mdn_resconf_t ctx) {
        mdn_result_t r;
-       const char *local_encoding = mdn_localencoding_name();
+       const char *new_local_encoding;
 
-       if (local_encoding == NULL) {
+       /*
+        * This condition comes true only when the converter is set by
+        * mdn_resconf_setlocalconverter().  In this case, we don't
+        * update the local converter.
+        */
+       if (ctx->local_encoding == NULL && ctx->local_converter != NULL)
+               return (mdn_success);
+
+       /*
+        * Update the local converer if the local encoding is changed.
+        */
+       new_local_encoding = mdn_localencoding_name();
+       if (new_local_encoding == NULL) {
                mdn_log_error("cannot determine local codeset name\n");
                return (mdn_notfound);
        }
 
        if (ctx->local_encoding != NULL &&
-           strcmp(ctx->local_encoding, local_encoding) == 0 &&
-           ctx->local_converter != NULL) {
+           ctx->local_converter != NULL &&
+           strcmp(ctx->local_encoding, new_local_encoding) == 0) {
                return (mdn_success);
        }
 
-       if (ctx->local_encoding != NULL) {
-               free(ctx->local_encoding);
-               ctx->local_encoding = NULL;
-       }
+       free(ctx->local_encoding);
+       ctx->local_encoding = NULL;
        if (ctx->local_converter != NULL) {
                mdn_converter_destroy(ctx->local_converter);
                ctx->local_converter = NULL;
        }
 
-       r = mystrdup(local_encoding, &ctx->local_encoding);
+       r = mystrdup(new_local_encoding, &ctx->local_encoding);
        if (r != mdn_success)
                return (r);
        r = mdn_converter_create(ctx->local_encoding,
@@ -453,16 +1353,83 @@ update_local_converter(mdn_resconf_t ctx) {
 
 static mdn_result_t
 mystrdup(const char *from, char **top) {
-       char *s = malloc(strlen(from) + 1);
+       char *s;
 
        if (*top != NULL) {
                free(*top);
                *top = NULL;
        }
 
+       if (from == NULL)
+               from = "";
+       s = malloc(strlen(from) + 1);
        if (s == NULL)
                return (mdn_nomemory);
        (void)strcpy(s, from);
        *top = s;
        return (mdn_success);
 }
+
+static const char *
+get_ucs(const 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) {
+               return (NULL);
+       }
+       p = end;
+
+       /* Skip trailing space */
+       while (isspace((unsigned char)*p))
+               p++;
+       return p;
+}
+
+#ifdef TEST
+
+int
+main(int argc, char *argv[])
+{
+       mdn_resconf_t resconf;
+       mdn_result_t r;
+       char *conf_file;
+
+       if (argc == 1)
+               conf_file = mdn_resconf_defaultfile();
+       else
+               conf_file = argv[1];
+
+       r = mdn_resconf_initialize();
+       if (r != mdn_success) {
+               fprintf(stderr, "%s: %s\n", argv[0], mdn_result_tostring(r));
+               exit(1);
+       }
+
+       r = mdn_resconf_create(&resconf);
+       if (r != mdn_success) {
+               fprintf(stderr, "%s: %s\n", argv[0], mdn_result_tostring(r));
+               exit(1);
+       }
+
+       r = mdn_resconf_loadfile(resconf, conf_file);
+       if (r != mdn_success) {
+               fprintf(stderr, "%s: %s, %s\n", argv[0],
+                       mdn_result_tostring(r), conf_file);
+               exit(1);
+       }
+
+       mdn_resconf_destroy(resconf);
+
+       return 0;
+}
+
+#endif /* TEST */
index eb66ca59c4f627ec31d4cc8b53febe6c0f7fd549..4bbf4684d59e05c6260d3cb21108272560e0c747 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
-static char *rcsid = "$Id: result.c,v 1.9 2000/09/27 02:55:38 ishisone Exp $";
+static char *rcsid = "$Id: result.c,v 1.10 2001/02/05 09:10:58 ishisone Exp $";
 #endif
 
 /*
@@ -70,12 +70,15 @@ static char *result_string[] = {
        "syntax error",
        "invalid name",
        "invalid message",
+       "invalid action",
+       "invalid code point",
        "buffer overflow",
        "no such entry",
        "out of memory",
        "no such file",
        "no mapping to output codeset",
        "context information required",
+       "prohibited character found",
        "generic failure",
 };
 
index 683dfe4452eeb879f87fd5def6e4c54dfc6bb3ea..bb1a760e2b222eab2636ec886ca2150fdafed779 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
-static char *rcsid = "$Id: selectiveencode.c,v 1.7 2000/09/20 02:47:32 ishisone Exp $";
+static char *rcsid = "$Id: selectiveencode.c,v 1.8 2001/05/31 05:21:38 ishisone Exp $";
 #endif
 
 /*
@@ -68,6 +68,7 @@ static char *rcsid = "$Id: selectiveencode.c,v 1.7 2000/09/20 02:47:32 ishisone
 #include <mdn/logmacro.h>
 #include <mdn/result.h>
 #include <mdn/utf8.h>
+#include <mdn/selectiveencode.h>
 #include <mdn/debug.h>
 
 static int     is_domain_delimiter(char c);
diff --git a/contrib/idn/mdnkit/lib/translator.c b/contrib/idn/mdnkit/lib/translator.c
deleted file mode 100644 (file)
index cdd22d2..0000000
+++ /dev/null
@@ -1,376 +0,0 @@
-#ifndef lint
-static char *rcsid = "$Id: translator.c,v 1.17 2000/11/21 02:09:05 ishisone 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
- * Tokyo, 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) Japan Network Information Center.  All rights reserved."
- * 
- * 4. Neither the name of JPNIC may 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.
- * 
- * 6. Indemnification by Licensee
- *    Any person or entities using and/or redistributing this Software under
- *    this License Terms and Conditions shall defend indemnify and hold
- *    harmless JPNIC from and against any and all judgements damages,
- *    expenses, settlement liabilities, cost and other liabilities of any
- *    kind as a result of use and redistribution of this Software or any
- *    claim, suite, action, litigation or proceeding by any third party
- *    arising out of or relates to this License Terms and Conditions.
- * 
- * 7. Governing Law, Jurisdiction and Venue
- *    This License Terms and Conditions shall be governed by and and
- *    construed in accordance with the law of Japan. Any person or entities
- *    using and/or redistributing this Software under this License Terms and
- *    Conditions hereby agrees and consent to the personal and exclusive
- *    jurisdiction and venue of Tokyo District Court of Japan.
- */
-
-#include <config.h>
-
-#include <stddef.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <mdn/result.h>
-#include <mdn/assert.h>
-#include <mdn/logmacro.h>
-#include <mdn/converter.h>
-#include <mdn/normalizer.h>
-#include <mdn/translator.h>
-#include <mdn/debug.h>
-
-static int             numdots(const char *s);
-static int             contain_invalid_char(const char *s);
-static mdn_result_t    append_zld(char *s, size_t len, const char *zld);
-
-mdn_result_t
-mdn_translator_translate(mdn_converter_t local_converter,
-                        mdn_converter_t local_alternate_converter,
-                        const char *local_zld,
-                        mdn_normalizer_t normalizer,
-                        mdn_converter_t target_converter,
-                        mdn_converter_t target_alternate_converter,
-                        const char *target_zld,
-                        const char *from, char *to, size_t tolen)
-{
-       mdn_result_t r;
-       size_t fromlen;
-       int process;
-       char domainbuf1[512], domainbuf2[512];  /* enough */
-
-       assert(local_converter != NULL && target_converter != NULL &&
-              from != NULL && to != NULL && tolen >= 0);
-
-       TRACE(("mdn_translator_translate(local_encoding=%s,local_zld=%s,"
-             "target_encoding=%s,target_zld=%s,from=\"%s\")\n",
-             mdn_converter_localencoding(local_converter),
-             local_zld == NULL ? "(none)" : local_zld,
-             mdn_converter_localencoding(target_converter),
-             target_zld == NULL ? "(none)" : target_zld,
-             mdn_debug_xstring(from, 30)));
-
-       fromlen = strlen(from);
-       if (fromlen + 1 > sizeof(domainbuf1)) {
-               WARNING(("mdn_translator_translate: "
-                       "given domainname too long\n"));
-               return (mdn_invalid_name);
-       }
-
-       (void)strcpy(domainbuf1, from);
-
-       DUMP(("mdn_translator_translate: before translation \"%s\"\n",
-            mdn_debug_xstring(domainbuf1, 200)));
-
-#define PROCESS_LOCAL          1
-#define PROCESS_LOCALALT       2
-#define PROCESS_DONE           4
-
-       process = 0;
-
-       if (local_zld != NULL) {
-               /*
-                * Check if the domain name matches the local ZLD.
-                * If it does, strip ZLD and continue translation.
-                * Otherwise, no further processing is needed.
-                */
-               if (mdn_translator_matchzld(domainbuf1, local_zld)) {
-                       /* Remove ZLD. */
-                       domainbuf1[fromlen - strlen(local_zld)] = '\0';
-                       process |= PROCESS_LOCAL;
-                       if (local_alternate_converter != NULL &&
-                           !contain_invalid_char(domainbuf1))
-                               process |= PROCESS_LOCALALT;
-               }
-       } else if (contain_invalid_char(domainbuf1)) {
-               /*
-                * The name contains invalid characters (as a legal
-                * traditional domain name).  So there's no point in
-                * trying local-alt codeset.
-                */
-               process |= PROCESS_LOCAL;
-       } else {
-               /*
-                * The given name is a valid ASCII domain name.
-                */
-               if (mdn_converter_isasciicompatible(local_converter))
-                       process |= PROCESS_LOCAL;
-               if (local_alternate_converter != NULL)
-                       process |= PROCESS_LOCALALT;
-       }
-
-       if ((process & PROCESS_LOCALALT) != 0) {
-               /*
-                * First, try converting from the alternate encoding to UTF-8.
-                */
-               TRACE(("mdn_translator_translate: %s to UTF-8\n",
-                      mdn_converter_localencoding(
-                              local_alternate_converter)));
-               r = mdn_converter_convert(local_alternate_converter,
-                                         mdn_converter_l2u,
-                                         domainbuf1, domainbuf2,
-                                         sizeof(domainbuf2));
-               if (r == mdn_success)
-                       process |= PROCESS_DONE;
-               else if (r != mdn_invalid_encoding)
-                       return (r);
-       }
-       if ((process & PROCESS_DONE) == 0 && (process & PROCESS_LOCAL) != 0) {
-               /*
-                * Convert from local encoding to UTF-8.
-                */
-               TRACE(("mdn_translator_translate: %s to UTF-8\n",
-                      mdn_converter_localencoding(local_converter)));
-               r = mdn_converter_convert(local_converter,
-                                         mdn_converter_l2u,
-                                         domainbuf1, domainbuf2,
-                                         sizeof(domainbuf2));
-               if (r == mdn_success)
-                       process |= PROCESS_DONE;
-               else if (r != mdn_invalid_encoding)
-                       return (r);
-       }
-       if ((process & PROCESS_DONE) == 0) {
-               /*
-                * Not converted.  Copy verbatim.
-                */
-               TRACE(("mdn_translator_translate: no translation required\n"));
-               if (tolen < fromlen + 1)
-                       return (mdn_buffer_overflow);
-               (void)memcpy(to, from, fromlen + 1);
-               return (mdn_success);
-       }
-#undef PROCESS_LOCAL
-#undef PROCESS_LOCALALT
-#undef PROCESS_DONE
-
-       DUMP(("mdn_translator_translate: UTF-8 string \"%s\"\n",
-            mdn_debug_xstring(domainbuf2, 200)));
-
-       /*
-        * Normalize, if normalizer is specified.
-        */
-       if (normalizer != NULL) {
-               r = mdn_normalizer_normalize(normalizer,
-                                            domainbuf2, domainbuf1,
-                                            sizeof(domainbuf1));
-               if (r != mdn_success)
-                       return (r);
-
-               DUMP(("mdn_translator_translate: after normalization \"%s\"\n",
-                    mdn_debug_xstring(domainbuf1, 200)));
-               
-               if (numdots(domainbuf2) != numdots(domainbuf1)) {
-                       INFO(("mdn_translator_translate: "
-                            "number of labels has been changed by "
-                            "normalization\n"));
-               }
-       }
-
-       /*
-        * Convert from UTF-8 to target encoding.
-        */
-       TRACE(("mdn_translator_translate: UTF-8 to %s\n",
-             mdn_converter_localencoding(target_converter)));
-       r = mdn_converter_convert(target_converter,
-                                 mdn_converter_u2l,
-                                 normalizer == NULL ?
-                                     domainbuf2 : domainbuf1,
-                                 to, tolen);
-       if (r == mdn_nomapping && target_alternate_converter != NULL) {
-               TRACE(("mdn_translator_translate: use alternate encoding\n"));
-               r = mdn_converter_convert(target_alternate_converter,
-                                         mdn_converter_u2l,
-                                         normalizer == NULL ?
-                                         domainbuf2 : domainbuf1,
-                                         to, tolen);
-       }
-       if (r != mdn_success)
-               return (r);
-
-       /*
-        * Append ZLD, if any.
-        */
-       if (target_zld != NULL)
-               r = append_zld(to, tolen, target_zld);
-
-       DUMP(("mdn_translator_translate: after translation \"%s\"\n",
-            mdn_debug_xstring(to, 200)));
-
-       return (r);
-}
-
-int
-mdn_translator_matchzld(const char *domain, const char *zld) {
-       int dlen;
-       int zlen;
-       const char *p;
-       int i;
-
-       /* An empty ZLD can match everything. */
-       if (zld == NULL)
-               return (1);
-
-       dlen = strlen(domain);
-       zlen = strlen(zld);
-
-       /*
-        * Since ZLD is canonicalized, it must end with dot.
-        * DOMAIN may or may not end with dot.
-        */
-       if (dlen > 0 && domain[dlen - 1] != '.')
-               zlen--;
-
-       /* If ZLD is longer than domain, no way. */
-       if (zlen > dlen)
-               return (0);
-
-       p = domain + dlen - zlen;
-       for (i = 0; p[i] != '\0'; i++) {
-               /* ZLD is canonicalized (i.e. uppercase letters) */
-               if (p[i] == zld[i] ||
-                   ('a' <= p[i] && p[i] <= 'z' && p[i] - 'a' + 'A' == zld[i]))
-                       continue;
-               else
-                       return (0);
-       }
-
-       if (p > domain && p[-1] != '.')
-               return (0);
-
-       return (1);
-}
-
-/*
- * Canonicalize ZLD.
- *  -- empty ZLD are nullified.
- *  -- leading dot is removed.
- *  -- append dot if it does not end with dot.
- *  -- lowercase characters are converted to uppercase.
- */
-mdn_result_t
-mdn_translator_canonicalzld(const char *zld, char **canonicalizedp) {
-       size_t len;
-       int append_dot = 0;
-       char *canonicalized, *p;
-       int c;
-
-       /* Remove leading '.' */
-       if (zld != NULL && zld[0] == '.')
-               zld++;
-
-       /* Is it empty? */
-       if (zld == NULL || strcmp(zld, "") == 0) {
-               *canonicalizedp = NULL;
-               return (mdn_success);
-       }
-
-       len = strlen(zld);
-       if (zld[len - 1] != '.')
-               append_dot = 1;
-
-       if ((canonicalized = malloc(len + 1 + append_dot)) == NULL)
-               return (mdn_nomemory);
-       *canonicalizedp = canonicalized;
-
-       for (p = canonicalized; (c = *zld) != '\0'; zld++, p++) {
-               if ('a' <= c && c <= 'z')
-                       c += 'A' - 'a';
-               *p = c;
-       }
-       if (append_dot)
-               *p++ = '.';
-       *p = '\0';
-
-       return (mdn_success);
-}
-
-static int
-numdots(const char *s) {
-       int n = 0;
-
-       while ((s = strchr(s, '.')) != NULL) {
-               n++;
-               s++;
-       }
-       return (n);
-}
-
-static int
-contain_invalid_char(const char *s) {
-       int c;
-
-       while ((c = *s++) != '\0') {
-               if (('a' <= c && c <= 'z') ||
-                   ('A' <= c && c <= 'Z') ||
-                   ('0' <= c && c <= '9') ||
-                   c == '.' || c == '-')
-                       continue;       /* valid character */
-               return (1);
-       }
-       return (0);
-}
-
-static mdn_result_t
-append_zld(char *s, size_t len, const char *zld) {
-       size_t slen = strlen(s);
-
-       if (slen + strlen(zld) + 1 > len)
-               return (mdn_buffer_overflow);
-       (void)strcpy(s + slen, zld);
-       return (mdn_success);
-}
diff --git a/contrib/idn/mdnkit/lib/ucsmap.c b/contrib/idn/mdnkit/lib/ucsmap.c
new file mode 100644 (file)
index 0000000..bd62e18
--- /dev/null
@@ -0,0 +1,393 @@
+#ifndef lint
+static char *rcsid = "$Id: ucsmap.c,v 1.1 2001/06/09 00:30:27 tale 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+ * Tokyo, 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) Japan Network Information Center.  All rights reserved."
+ * 
+ * 4. Neither the name of JPNIC may 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.
+ * 
+ * 6. Indemnification by Licensee
+ *    Any person or entities using and/or redistributing this Software under
+ *    this License Terms and Conditions shall defend indemnify and hold
+ *    harmless JPNIC from and against any and all judgements damages,
+ *    expenses, settlement liabilities, cost and other liabilities of any
+ *    kind as a result of use and redistribution of this Software or any
+ *    claim, suite, action, litigation or proceeding by any third party
+ *    arising out of or relates to this License Terms and Conditions.
+ * 
+ * 7. Governing Law, Jurisdiction and Venue
+ *    This License Terms and Conditions shall be governed by and and
+ *    construed in accordance with the law of Japan. Any person or entities
+ *    using and/or redistributing this Software under this License Terms and
+ *    Conditions hereby agrees and consent to the personal and exclusive
+ *    jurisdiction and venue of Tokyo District Court of Japan.
+ */
+
+#include <config.h>
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <mdn/result.h>
+#include <mdn/assert.h>
+#include <mdn/log.h>
+#include <mdn/logmacro.h>
+#include <mdn/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 mdn_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(mdn_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);
+
+mdn_result_t
+mdn_ucsmap_create(mdn_ucsmap_t *ctxp) {
+       mdn_ucsmap_t ctx;
+
+       assert(ctxp != NULL);
+
+       TRACE(("mdn_ucsmap_create()\n"));
+
+       if ((ctx = malloc(sizeof(*ctx))) == NULL) {
+               WARNING(("mdn_ucsmap_create: malloc failed\n"));
+               return (mdn_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 (mdn_success);
+}
+
+void
+mdn_ucsmap_destroy(mdn_ucsmap_t ctx) {
+       assert(ctx != NULL && ctx->refcnt > 0);
+
+       TRACE(("mdn_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
+mdn_ucsmap_incrref(mdn_ucsmap_t ctx) {
+       assert(ctx != NULL && ctx->refcnt > 0);
+
+       ctx->refcnt++;
+}
+
+mdn_result_t
+mdn_ucsmap_add(mdn_ucsmap_t ctx, unsigned long ucs,
+              unsigned long *map, size_t maplen)
+{
+       ucsmap_entry_t *e;
+
+       assert(ctx != NULL && ctx->refcnt > 0);
+
+       TRACE(("mdn_ucsmap_add(ucs=U+%lX, maplen=%u)\n", ucs, maplen));
+
+       /* Make sure it is not fixed yet. */
+       if (ctx->fixed) {
+               WARNING(("mdn_ucsmap_add: attempt to add to fixed map\n"));
+               return (mdn_failure);
+       }
+
+       if (maplen > MAX_MAPLEN) {
+               WARNING(("mdn_ucsmap_add: maplen too large (> %d)\n",
+                        MAX_MAPLEN));
+               return (mdn_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;
+               ctx->entries = realloc(ctx->entries,
+                                      sizeof(*e) * ctx->entry_size);
+       }
+       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 (mdn_nomemory);
+       } else {
+               /*
+                * Zero 'maplen' is perfectly valid meaning one-to-zero
+                * mapping.
+                */
+               e->map = NULL;
+       }
+       ctx->nentries++;
+
+       return (mdn_success);
+}
+
+void
+mdn_ucsmap_fix(mdn_ucsmap_t ctx) {
+       ucsmap_entry_t *e;
+       int last_hidx;
+       int i;
+
+       assert(ctx != NULL && ctx->refcnt > 0);
+
+       TRACE(("mdn_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++;
+       }
+}
+
+mdn_result_t
+mdn_ucsmap_map(mdn_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(("mdn_ucsmap_map(v=U+%lX)\n", v));
+
+       if (!ctx->fixed) {
+               WARNING(("mdn_ucsmap_map: not fixed yet\n"));
+               return (mdn_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 (mdn_buffer_overflow);
+                       memcpy(to, e[mid].map, sizeof(*to) * e[mid].len);
+                       *maplenp = e[mid].len;
+                       return (mdn_success);
+               }
+       }
+
+       /*
+        * Not found. Put the original character to 'to'
+        * just for convenience.
+        */
+ nomap:
+       if (tolen < 1)
+               return (mdn_buffer_overflow);
+       *to = v;
+       *maplenp = 1;
+       return (mdn_nomapping);
+}
+
+static int
+ucsmap_hash(unsigned long v) {
+       return (v % UCSMAP_HASH_SIZE);
+}
+
+static unsigned long *
+save_mapped_sequence(mdn_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 - 1));
+               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/mdnkit/lib/ucsset.c b/contrib/idn/mdnkit/lib/ucsset.c
new file mode 100644 (file)
index 0000000..a9a3545
--- /dev/null
@@ -0,0 +1,382 @@
+#ifndef lint
+static char *rcsid = "$Id: ucsset.c,v 1.1 2001/06/09 00:30:27 tale 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+ * Tokyo, 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) Japan Network Information Center.  All rights reserved."
+ * 
+ * 4. Neither the name of JPNIC may 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.
+ * 
+ * 6. Indemnification by Licensee
+ *    Any person or entities using and/or redistributing this Software under
+ *    this License Terms and Conditions shall defend indemnify and hold
+ *    harmless JPNIC from and against any and all judgements damages,
+ *    expenses, settlement liabilities, cost and other liabilities of any
+ *    kind as a result of use and redistribution of this Software or any
+ *    claim, suite, action, litigation or proceeding by any third party
+ *    arising out of or relates to this License Terms and Conditions.
+ * 
+ * 7. Governing Law, Jurisdiction and Venue
+ *    This License Terms and Conditions shall be governed by and and
+ *    construed in accordance with the law of Japan. Any person or entities
+ *    using and/or redistributing this Software under this License Terms and
+ *    Conditions hereby agrees and consent to the personal and exclusive
+ *    jurisdiction and venue of Tokyo District Court of Japan.
+ */
+
+#include <config.h>
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <mdn/result.h>
+#include <mdn/assert.h>
+#include <mdn/logmacro.h>
+#include <mdn/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 'mdn_ucsset_add' or
+ * 'mdn_ucsset_addrange' are simply appended to the array.
+ * And 'mdn_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 'mdn_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 mdn_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 mdn_result_t    addrange(mdn_ucsset_t ctx, unsigned long from,
+                                unsigned long to, char *func_name);
+static int             comp_range(const void *v1, const void *v2);
+
+mdn_result_t
+mdn_ucsset_create(mdn_ucsset_t *ctx) {
+       mdn_ucsset_t bm;
+
+       assert(ctx != NULL);
+
+       TRACE(("mdn_ucsset_create()\n"));
+
+       if ((bm = malloc(sizeof(ucsset))) == NULL) {
+               WARNING(("mdn_ucsset_create: malloc failed\n"));
+               return mdn_nomemory;
+       }
+       bm->size = bm->nranges = 0;
+       bm->ranges = NULL;
+       bm->fixed = 0;
+       bm->refcnt = 1;
+       *ctx = bm;
+       return (mdn_success);
+}
+
+void
+mdn_ucsset_destroy(mdn_ucsset_t ctx) {
+       assert(ctx != NULL && ctx->refcnt > 0);
+
+       TRACE(("mdn_ucsset_destroy()\n"));
+
+       if (--ctx->refcnt == 0) {
+               if (ctx->ranges != NULL)
+                       free(ctx->ranges);
+               free(ctx);
+       }
+}
+
+void
+mdn_ucsset_incrref(mdn_ucsset_t ctx) {
+       assert(ctx != NULL && ctx->refcnt > 0);
+
+       TRACE(("mdn_ucsset_incrref()\n"));
+
+       ctx->refcnt++;
+}
+
+mdn_result_t
+mdn_ucsset_add(mdn_ucsset_t ctx, unsigned long v) {
+       assert(ctx != NULL && ctx->refcnt > 0);
+
+       TRACE(("mdn_ucsset_add(v=U+%lX)\n", v));
+
+       return (addrange(ctx, v, v, "mdn_ucsset_add"));
+}
+
+mdn_result_t
+mdn_ucsset_addrange(mdn_ucsset_t ctx, unsigned long from,
+                        unsigned long to)
+{
+       assert(ctx != NULL && ctx->refcnt > 0);
+
+       TRACE(("mdn_ucsset_addrange(from=U+%lX, to=U+%lX)\n",
+              from, to));
+
+       return (addrange(ctx, from, to, "mdn_ucsset_addrange"));
+}
+
+void
+mdn_ucsset_fix(mdn_ucsset_t ctx) {
+       int nranges;
+       range_t *ranges;
+       segment_t *segments;
+       int i, j;
+
+       assert(ctx != NULL && ctx->refcnt > 0);
+
+       TRACE(("mdn_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
+}
+
+mdn_result_t
+mdn_ucsset_lookup(mdn_ucsset_t ctx, unsigned long v, int *found) {
+       int idx;
+       segment_t *segments;
+
+       assert(ctx != NULL && ctx->refcnt > 0 && found != NULL);
+
+       TRACE(("mdn_ucsset_lookup(v=U+%lX)\n", v));
+
+       /* Make sure it is fixed. */
+       if (!ctx->fixed) {
+               WARNING(("mdn_ucsset_lookup: not fixed yet\n"));
+               return (mdn_failure);
+       }
+
+       /* Check the given code point. */
+       if (v >= UCS_MAX)
+               return (mdn_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 (mdn_success);
+}
+
+static mdn_result_t
+addrange(mdn_ucsset_t ctx, unsigned long from, unsigned long to,
+        char *func_name)
+{
+       /* Check the given code points. */
+       if (from > UCS_MAX) {
+               WARNING(("%s: code point out of range (U+%lX)\n",
+                        func_name, from));
+               return (mdn_invalid_codepoint);
+       } else if (to > UCS_MAX) {
+               WARNING(("%s: code point out of range (U+%lX)\n",
+                        func_name, to));
+               return (mdn_invalid_codepoint);
+       } else if (from > to) {
+               WARNING(("%s: invalid range spec (U+%lX-U+%lX)\n",
+                        func_name, from, to));
+               return (mdn_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 (mdn_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;
+               ctx->ranges = realloc(ctx->ranges,
+                                     ctx->size * sizeof(range_t));
+               if (ctx->ranges == NULL)
+                       return (mdn_nomemory);
+       }
+       ctx->ranges[ctx->nranges].from = from;
+       ctx->ranges[ctx->nranges].to = to;
+       ctx->nranges++;
+
+       return (mdn_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);
+}
index 4f405827ce147238a252918d8845654cf850bdcc..1a4e04410f9eed1e9877ad04bfd395c7f631e1d2 100644 (file)
@@ -1,9 +1,10 @@
 #ifndef lint
-static char *rcsid = "$Id: unicode.c,v 1.11 2000/10/16 07:50:53 ishisone Exp $";
+static char *rcsid = "$Id: unicode.c,v 1.13 2001/02/14 02:16:15 ishisone Exp $";
 #endif
 
 /*
- * Copyright (c) 2000 Japan Network Information Center.  All rights reserved.
+ * 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.
  * 
@@ -64,27 +65,14 @@ static char *rcsid = "$Id: unicode.c,v 1.11 2000/10/16 07:50:53 ishisone Exp $";
 
 #include <stddef.h>
 #include <stdlib.h>
-#ifdef DEBUG_HASHSTAT
-#include <stdio.h>
-#endif
 
 #include <mdn/result.h>
 #include <mdn/logmacro.h>
 #include <mdn/assert.h>
 #include <mdn/unicode.h>
 
-#ifndef CANON_CLASS_NBUCKETS
-#define CANON_CLASS_NBUCKETS   121
-#endif
-#ifndef COMPOSITION_NBUCKETS
-#define COMPOSITION_NBUCKETS   332
-#endif
-#ifndef DECOMPOSITION_NBUCKETS
-#define DECOMPOSITION_NBUCKETS 731
-#endif
-#ifndef CASEMAP_NBUCKETS
-#define CASEMAP_NBUCKETS       269
-#endif
+#define UCS_MAX                0x10ffff
+#define END_BIT                0x80000000
 
 /*
  * Some constants for Hangul decomposition/composition.
@@ -98,87 +86,46 @@ static char *rcsid = "$Id: unicode.c,v 1.11 2000/10/16 07:50:53 ishisone Exp $";
 #define TCount         28
 #define SLast          (SBase + LCount * VCount * TCount)
 
-typedef unsigned short unicode_t;      /* 16bit unsigned integer is suffice */
-
-struct canon_class {
-       unicode_t c;
-       unsigned short class;
-       struct canon_class *next;
-};
-
-struct composition {
-       unicode_t c1;
-       unicode_t c2;
-       unicode_t composed;
-       struct composition *next;
-};
-
-struct decomposition {
-       unicode_t c;
-       unsigned short offset;
-       unsigned short length;
-       struct decomposition *next;
-};
-
-struct casemap {
-       unicode_t c;
-       unicode_t map;
-       unsigned short flags;
-       unsigned short length;
-       struct casemap *next;
-};
-
 #include "unicodedata.c"
 
 /*
- * Hash tables.
+ * 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)]
 
-static struct canon_class      *canon_class_hash[CANON_CLASS_NBUCKETS];
-static struct composition      *composition_hash[COMPOSITION_NBUCKETS];
-static struct decomposition    *canon_decomposition_hash[DECOMPOSITION_NBUCKETS];
-static struct decomposition    *compat_decomposition_hash[DECOMPOSITION_NBUCKETS];
-static struct casemap          *toupper_hash[CASEMAP_NBUCKETS];
-static struct casemap          *tolower_hash[CASEMAP_NBUCKETS];
+#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))
 
-static int     initialized = 0;
+#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))
 
-static mdn_result_t    casemap(unsigned long c, mdn__unicode_context_t ctx,
-                               unsigned long *v, size_t vlen, int *convlenp,
-                               unsigned long *bitmap, struct casemap **hash);
-static int             canon_class_hashval(unicode_t c);
-static int             composition_hashval(unicode_t c1, unicode_t c2);
-static int             decomposition_hashval(unicode_t c);
-static int             casemap_hashval(unicode_t c);
-static void            initialize(void);
+#define BITS1(mprefix) mprefix ## _BITS_1
+#define BITS2(mprefix) mprefix ## _BITS_2
 
+#define IMAP(vprefix)  vprefix ## _imap
+#define DMAP(vprefix)  vprefix ## _table
 
-#define CHECKBIT(v, bitmap, shift) \
-       (((bitmap)[((v)>>(shift)) / 32] & (1 << (((v)>>(shift)) & 31))) != 0)
+static mdn_result_t    casemap(unsigned long c, mdn__unicode_context_t ctx,
+                               unsigned long *v, size_t vlen, int *convlenp,
+                               int do_uppercase);
 
 int
 mdn__unicode_canonicalclass(unsigned long c) {
-       struct canon_class *hp;
-
 #if 0
        TRACE(("mdn__unicode_canonicalclass(c=%lx)\n", c));
 #endif
 
-       initialize();
-
-       if (c > 0xffff)
+       if (c > UCS_MAX)
                return (0);
 
-       if (!CHECKBIT(c, canon_class_bitmap, CANON_CLASS_BM_SHIFT))
-               return (0);
-
-       hp = canon_class_hash[canon_class_hashval((unicode_t)c)];
-       while (hp != NULL) {
-               if (hp->c == c)
-                       return (hp->class);
-               hp = hp->next;
-       }
-       return 0;
+       return (LOOKUPTBL(canon_class, CANON_CLASS, c));
 }
 
 mdn_result_t
@@ -186,10 +133,8 @@ mdn__unicode_decompose(int compat, unsigned long *v, size_t vlen,
                       unsigned long c, int *decomp_lenp)
 {
        unsigned long *vorg = v;
-       int h;
-       struct decomposition *hp;
-       unicode_t *base;
-       int i;
+       int seqidx;
+       unsigned long *seq;
 
        assert(v != NULL && vlen >= 0 && decomp_lenp != NULL);
 
@@ -198,7 +143,8 @@ mdn__unicode_decompose(int compat, unsigned long *v, size_t vlen,
              compat, vlen, c));
 #endif
 
-       initialize();
+       if (c > UCS_MAX)
+               return (mdn_notfound);
 
        /*
         * First, check for Hangul.
@@ -222,69 +168,42 @@ mdn__unicode_decompose(int compat, unsigned long *v, size_t vlen,
        }
 
        /*
-        * Check bitmap.
+        * Look up decomposition table.  If no decomposition is defined
+        * or if it is a compatibility decomosition when canonical
+        * decomposition requested, return 'mdn_notfound'.
         */
-       if (c > 0xffff ||
-           (compat &&
-            !CHECKBIT(c, compat_decompose_bitmap, DECOMPOSE_BM_SHIFT)) ||
-           (!compat &&
-            !CHECKBIT(c, canon_decompose_bitmap, DECOMPOSE_BM_SHIFT)))
+       seqidx = LOOKUPTBL(decompose, DECOMP, c);
+       if (seqidx == 0 || (compat == 0 && (seqidx & DECOMP_COMPAT) != 0))
                return (mdn_notfound);
-
-       /*
-        * Now, C is a decomposition candidate.
-        * Search the hash tables.
-        */
-       h = decomposition_hashval((unicode_t)c);
-
+       
        /*
-        * First, look for canonical decomposition.
+        * Copy the decomposed sequence.  The end of the sequence are
+        * marked with END_BIT.
         */
-       base = canon_decompose_data;
-       hp = canon_decomposition_hash[h];
-       while (hp != NULL) {
-               if (hp->c == c)
-                       goto found;
-               hp = hp->next;
-       }
-
-       if (!compat)
-               return (mdn_notfound);
-
-       /*
-        * Then, compatibility decomposition.
-        */
-       base = compat_decompose_data;
-       hp = compat_decomposition_hash[h];
-       while (hp != NULL) {
-               if (hp->c == c)
-                       goto found;
-               hp = hp->next;
-       }
-
-       return (mdn_notfound);
-
-found:
-       /* Do we have enough space? */
-       if (vlen < hp->length)
-               return (mdn_buffer_overflow);
-
-       base += hp->offset;
-       for (i = 0; i < hp->length; i++) {
+       seq = &decompose_seq[seqidx & ~DECOMP_COMPAT];
+       do {
+               unsigned long c;
+               size_t dlen;
                mdn_result_t r;
-               int len;
 
-               /* Decompose recursively. */
-               r = mdn__unicode_decompose(compat, v, vlen, base[i], &len);
+               c = *seq & ~END_BIT;
 
+               /* Decompose recursively. */
+               r = mdn__unicode_decompose(compat, v, vlen, c, &dlen);
                if (r == mdn_success) {
-                       v += len;
-                       vlen -= len;
-               } else {
-                       *v++ = base[i];
+                       v += dlen;
+                       vlen -= dlen;
+               } else if (r == mdn_notfound) {
+                       if (vlen < 1)
+                               return (mdn_buffer_overflow);
+                       *v++ = c;
                        vlen--;
+               } else {
+                       return (r);
                }
-       }
+
+       } while ((*seq++ & END_BIT) == 0);
+       
        *decomp_lenp = v - vorg;
 
        return (mdn_success);
@@ -295,16 +214,31 @@ mdn__unicode_iscompositecandidate(unsigned long c) {
 #if 0
        TRACE(("mdn__unicode_iscompositecandidate(c=%lx)\n", c));
 #endif
-       return (c <= 0xffff &&
-               ((LBase <= c && c < LBase + LCount) ||
-                (SBase <= c && c < SLast) ||
-                CHECKBIT(c, compose_bitmap, COMPOSE_BM_SHIFT)));
+
+       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 (LOOKUPTBL(compose, CANON_COMPOSE, c) == 0)
+               return (0);
+       else
+               return (1);
 }
 
 mdn_result_t
 mdn__unicode_compose(unsigned long c1, unsigned long c2, unsigned long *compp)
 {
-       struct composition *hp;
+       unsigned long x;
+       int n;
+       int seqidx, lo, hi;
 
        assert(compp != NULL);
 
@@ -312,7 +246,8 @@ mdn__unicode_compose(unsigned long c1, unsigned long c2, unsigned long *compp)
        TRACE(("mdn__unicode_compose(c1=%lx,c2=%lx)\n", c1, c2));
 #endif
 
-       initialize();
+       if (c1 > UCS_MAX || c2 > UCS_MAX)
+               return (mdn_notfound);
 
        /*
         * Check for Hangul.
@@ -336,23 +271,33 @@ mdn__unicode_compose(unsigned long c1, unsigned long c2, unsigned long *compp)
        }
 
        /*
-        * Check bitmap.
+        * 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 (c1 > 0xffff || c2 > 0xffff ||
-           !CHECKBIT(c1, compose_bitmap, COMPOSE_BM_SHIFT))
+       if ((x = LOOKUPTBL(compose, CANON_COMPOSE, c1)) == 0)
                return (mdn_notfound);
+       n = x >> 16;
+       seqidx = x & 0xffff;
 
        /*
-        * Composition candidate.  Search the hash table.
+        * The composite sequences are sorted by the 2nd character 'c2'.
+        * So we can use binary search.
         */
-       hp = composition_hash[composition_hashval((unicode_t)c1,
-                                                 (unicode_t)c2)];
-       while (hp != NULL) {
-               if (hp->c1 == c1 && hp->c2 == c2) {
-                       *compp = hp->composed;
+       lo = seqidx;
+       hi = seqidx + n - 1;
+       while (lo <= hi) {
+               int mid = (lo + hi) / 2;
+
+               if (compose_seq[mid].c2 < c2) {
+                       lo = mid + 1;
+               } else if (compose_seq[mid].c2 > c2) {
+                       hi = mid - 1;
+               } else {
+                       *compp = compose_seq[mid].comp;
                        return (mdn_success);
                }
-               hp = hp->next;
        }
        return (mdn_notfound);
 }
@@ -364,9 +309,7 @@ mdn__unicode_toupper(unsigned long c, mdn__unicode_context_t ctx,
 #if 0
        TRACE(("mdn__unicode_toupper(c=%lx)\n", c));
 #endif
-       initialize();
-       return (casemap(c, ctx, v, vlen, convlenp,
-                       toupper_bitmap, toupper_hash));
+       return (casemap(c, ctx, v, vlen, convlenp, 1));
 }
 
 mdn_result_t
@@ -376,61 +319,106 @@ mdn__unicode_tolower(unsigned long c, mdn__unicode_context_t ctx,
 #if 0
        TRACE(("mdn__unicode_tolower(c=%lx)\n", c));
 #endif
-       initialize();
-       return (casemap(c, ctx, v, vlen, convlenp,
-                       tolower_bitmap, tolower_hash));
+       return (casemap(c, ctx, v, vlen, convlenp, 0));
 }
 
 static mdn_result_t
 casemap(unsigned long c, mdn__unicode_context_t ctx,
-       unsigned long *v, size_t vlen, int *convlenp,
-       unsigned long *bitmap, struct casemap **hash)
+       unsigned long *v, size_t vlen, int *convlenp, int do_uppercase)
 {
-       struct casemap *hp;
+       unsigned long *seq;
+       int seqidx;
 
        if (vlen < 1)
                return (mdn_buffer_overflow);
 
-       if (c > 0xffff)
-               goto one_to_one;
-
-       if (!CHECKBIT(c, bitmap, CASEMAP_BM_SHIFT))
-               goto one_to_one;
-
-       hp = hash[casemap_hashval((unicode_t)c)];
-       while (hp != NULL) {
-               if (hp->c == c) {
-                       if ((hp->flags & CMF_CTXDEP) == 0) {
-                       found:
-                               if (hp->flags & CMF_MULTICHAR) {
-                                       int len = hp->length;
-                                       unicode_t *up;
-
-                                       if (vlen < hp->length)
-                                               return (mdn_buffer_overflow);
-                                       up = multichar_casemap_data +
-                                               (unsigned int)hp->map;
-                                       *convlenp = len;
-                                       while (len-- > 0)
-                                               *v++ = (unsigned long)*up++;
-                                       return (mdn_success);
-                               } else {
-                                       c = hp->map;
-                                       goto one_to_one;
-                               }
-                       } else if (ctx == mdn__unicode_context_unknown) {
+       if (c > UCS_MAX)
+               goto nomap;
+
+       /*
+        * Look up toupper/tolower mapping table.
+        */
+       if (do_uppercase) {
+               seq = toupper_seq;
+               seqidx = LOOKUPTBL(toupper, CASEMAP, c);
+       } else {
+               seq = tolower_seq;
+               seqidx = LOOKUPTBL(tolower, CASEMAP, c);
+       }
+
+       /* Zero means there are no mapping. */
+       if (seqidx == 0)
+               goto nomap;
+
+       /*
+        * There are two kinds of mapping, context-dependent and
+        * context-independent.  It is possible that both mappings
+        * are defined for a single character, so we have to loop
+        * through all the mappings.
+        */
+       seq += seqidx;
+       for (;;) {
+               int found = 0;
+               unsigned long flags = *seq++;
+
+               if (flags & CMF_CTXDEP) {
+                       /*
+                        * This is a context-dependent mapping.
+                        * Check the specified context.
+                        */
+                       switch (ctx) {
+                       case mdn__unicode_context_final:
+                               if (flags & CMF_FINAL)
+                                       found = 1;
+                               break;
+                       case mdn__unicode_context_nonfinal:
+                               if (flags & CMF_NONFINAL)
+                                       found = 1;
+                               break;
+                       default: /* mdn__unicode_context_unknown */
+                               /*
+                                * Request context information.
+                                */
                                return (mdn_context_required);
-                       } else if (((hp->flags & CMF_FINAL) &&
-                                   ctx == mdn__unicode_context_final) ||
-                                  ((hp->flags & CMF_NONFINAL) &&
-                                   ctx == mdn__unicode_context_nonfinal)) {
-                               goto found;
+                       }
+               } else {
+                       /*
+                        * This is an ordinary, context-independent
+                        * mapping.
+                        */
+                       found = 1;
+               }
+
+               if (found) {
+                       /*
+                        * Mapping found. Copy it.
+                        */
+                       int i = 0;
+
+                       do {
+                               if (vlen-- < 1)
+                                       return (mdn_buffer_overflow);
+                               *v++ = seq[i] & ~END_BIT;
+                       } while ((seq[i++] & END_BIT) == 0);
+
+                       *convlenp = i;
+                       return (mdn_success);
+               } else {
+                       /*
+                        * This entry doesn't match.  Try next etnry.
+                        */
+                       if (flags & CMF_LAST) {
+                               /* This is the last entry. */
+                               break;
+                       } else {
+                               /* Skip this entry. */
+                               while ((*seq++ & END_BIT) == 0)
+                                       /* do nothing */;
                        }
                }
-               hp = hp->next;
        }
 
one_to_one:
nomap:
        *convlenp = 1;
        *v = c;
        return (mdn_success);
@@ -438,188 +426,59 @@ casemap(unsigned long c, mdn__unicode_context_t ctx,
 
 mdn__unicode_context_t
 mdn__unicode_getcontext(unsigned long c) {
-       int idx;
-       int offset;
-       unsigned long *bm;
-       int v;
-
 #if 0
        TRACE(("mdn__unicode_getcontext(c=%lx)\n", c));
 #endif
 
-       if (c > 0xffff) {
-               return (mdn__unicode_context_final);
-       }
-       idx = c / CTX_BLOCK_SZ;
-       offset = c % CTX_BLOCK_SZ;
-       if ((bm = casemap_ctx_sections[idx]) == NULL) {
+       if (c > UCS_MAX)
                return (mdn__unicode_context_final);
-       }
-       v = (bm[(offset * 2) / 32] >> ((offset * 2) % 32)) & 3;
-       if (v & CTX_NSM)
-               return (mdn__unicode_context_unknown);
-       else if (v & CTX_CASED)
+
+       switch (LOOKUPTBL(casemap_ctx, CASEMAP_CTX, c)) {
+       case CTX_CASED:
                return (mdn__unicode_context_nonfinal);
-       else
+       case CTX_NSM:
+               return (mdn__unicode_context_unknown);
+       default:
                return (mdn__unicode_context_final);
-}
-
-static int
-canon_class_hashval(unicode_t c) {
-       return c % CANON_CLASS_NBUCKETS;
-}
-
-static int
-composition_hashval(unicode_t c1, unicode_t c2) {
-       return (c1 * 11 + c2) % COMPOSITION_NBUCKETS;
-}
-
-static int
-decomposition_hashval(unicode_t c) {
-       return c % DECOMPOSITION_NBUCKETS;
-}
-
-static int
-casemap_hashval(unicode_t c) {
-       return c % CASEMAP_NBUCKETS;
-}
-
-static void
-initialize(void) {
-       int i;
-
-       if (initialized)
-               return;
-
-#define ARRAYSIZE(var) (sizeof(var) / sizeof((var)[0]))
-#define INSERT(tbl, h, what) \
-       (what).next = (tbl)[h]; \
-       (tbl)[h] = &(what)
-
-       for (i = 0; i < ARRAYSIZE(canon_class); i++) {
-               int h = canon_class_hashval(canon_class[i].c);
-               INSERT(canon_class_hash, h, canon_class[i]);
-       }
-       for (i = 0; i < ARRAYSIZE(compose_seq); i++) {
-               int h = composition_hashval(compose_seq[i].c1,
-                                           compose_seq[i].c2);
-               INSERT(composition_hash, h, compose_seq[i]);
-       }
-       for (i = 0; i < ARRAYSIZE(canon_decompose_seq); i++) {
-               int h = decomposition_hashval(canon_decompose_seq[i].c);
-               INSERT(canon_decomposition_hash, h, canon_decompose_seq[i]);
-       }
-       for (i = 0; i < ARRAYSIZE(compat_decompose_seq); i++) {
-               int h = decomposition_hashval(compat_decompose_seq[i].c);
-               INSERT(compat_decomposition_hash, h, compat_decompose_seq[i]);
-       }
-       for (i = 0; i < ARRAYSIZE(toupper_map); i++) {
-               int h = casemap_hashval(toupper_map[i].c);
-               INSERT(toupper_hash, h, toupper_map[i]);
        }
-       for (i = 0; i < ARRAYSIZE(tolower_map); i++) {
-               int h = casemap_hashval(tolower_map[i].c);
-               INSERT(tolower_hash, h, tolower_map[i]);
-       }
-#undef ARRAYSIZE
-#undef INSERT
-
-       initialized = 1;
-}
-
-#ifdef DEBUG_HASHSTAT
-
-#define DEFINE_GETLENGTH(name, type) \
-static int                             \
-name(type p) {                         \
-       int len = 0;                    \
-       while (p != NULL) {             \
-               len++;                  \
-               p = p->next;            \
-       }                               \
-       return (len);                   \
 }
 
-DEFINE_GETLENGTH(getlength_canon_class, struct canon_class *)
-DEFINE_GETLENGTH(getlength_composition, struct composition *)
-DEFINE_GETLENGTH(getlength_decomposition, struct decomposition *)
-DEFINE_GETLENGTH(getlength_casemap, struct casemap *)
-
-static void
-print_hash_stat(void) {
-       int i;
-       int len;
-       int total, max;
-
-#define LENGTH(n) total += (n); if ((n) > max) {max = (n);}
-#define PRINT(nb) \
-       printf("\n nbuckets=%d, total=%d, max=%d (avr=%f)\n", \
-              nb, total, max, (double)total / nb)
-
-#if 1
-       printf("canon_class hash:\n  ");
-       for (i = total = max = 0; i < CANON_CLASS_NBUCKETS; i++) {
-               len = getlength_canon_class(canon_class_hash[i]);
-               LENGTH(len);
-               printf("%d ", len);
-       }
-       PRINT(CANON_CLASS_NBUCKETS);
-#endif
-
-#if 1
-       printf("composition hash:\n  ");
-       for (i = total = max = 0; i < COMPOSITION_NBUCKETS; i++) {
-               len = getlength_composition(composition_hash[i]);
-               LENGTH(len);
-               printf("%d ", len);
-       }
-       PRINT(COMPOSITION_NBUCKETS);
-#endif
+mdn_result_t
+mdn__unicode_casefold(unsigned long c, unsigned long *v, size_t vlen,
+                     int *foldlenp)
+{
+       unsigned long *vorg = v;
+       int seqidx;
+       unsigned long *seq;
 
-#if 1
-       printf("canonical decomposition hash:\n  ");
-       for (i = total = max = 0; i < DECOMPOSITION_NBUCKETS; i++) {
-               len = getlength_decomposition(canon_decomposition_hash[i]);
-               LENGTH(len);
-               printf("%d ", len);
-       }
-       PRINT(DECOMPOSITION_NBUCKETS);
-#endif
+       assert(v != NULL && vlen >= 0 && foldlenp != NULL);
 
-#if 1
-       printf("compatibility decomposition hash:\n  ");
-       for (i = total = max = 0; i < DECOMPOSITION_NBUCKETS; i++) {
-               len = getlength_decomposition(compat_decomposition_hash[i]);
-               LENGTH(len);
-               printf("%d ", len);
-       }
-       PRINT(DECOMPOSITION_NBUCKETS);
+#if 0
+       TRACE(("mdn__unicode_casefold(compat=%d,vlen=%d,c=%lx)\n",
+             compat, vlen, c));
 #endif
 
-#if 1
-       printf("toupper hash:\n  ");
-       for (i = total = max = 0; i < CASEMAP_NBUCKETS; i++) {
-               len = getlength_casemap(toupper_hash[i]);
-               LENGTH(len);
-               printf("%d ", len);
-       }
-       PRINT(CASEMAP_NBUCKETS);
-#endif
+       if (c > UCS_MAX)
+               goto nomap;
 
-#if 1
-       printf("tolower hash:\n  ");
-       for (i = total = max = 0; i < CASEMAP_NBUCKETS; i++) {
-               len = getlength_casemap(tolower_hash[i]);
-               LENGTH(len);
-               printf("%d ", len);
-       }
-       PRINT(CASEMAP_NBUCKETS);
-#endif
-}
+       /* Look up case folding table. */
+       if ((seqidx = LOOKUPTBL(case_folding, CASE_FOLDING, c)) == 0)
+               goto nomap;
+       
+       seq = &case_folding_seq[seqidx];
+       do {
+               if (vlen-- < 1)
+                       return (mdn_buffer_overflow);
+               *v++ = *seq & ~END_BIT;
+       } while ((*seq++ & END_BIT) == 0);
+       
+       *foldlenp = v - vorg;
 
-int
-main(int ac, char **av) {
-       initialize();
-       print_hash_stat();
+       return (mdn_success);
+ nomap:
+       if (vlen < 1)
+               return (mdn_buffer_overflow);
+       *foldlenp = 1;
+       *v = c;
+       return (mdn_success);
 }
-#endif /* DEBUG_HASHSTAT */
index 9e7f17573e5f1622441473ab70c2cdbcfeb4a84a..54b3389123121d9da88d22fbd1aded271f6c20bb 100644 (file)
@@ -1,10 +1,9 @@
-/* $Id: unicodedata.c,v 1.7 2000/09/29 05:44:28 ishisone Exp $ */
-/* $-Id: generate_normalize_data.pl,v 1.4 2000/09/27 02:55:40 ishisone Exp -$ */
+/* $Id: unicodedata.c,v 1.8 2001/02/13 08:25:53 ishisone Exp $ */
+/* $-Id: generate_normalize_data.pl,v 1.5 2001/02/13 07:34:02 ishisone Exp -$ */
 /*
  * Do not edit this file!
- * This file is generated from UnicodeData.txt and
- * CompositionExclusions-1.txt.
- *
+ * This file is generated from UnicodeData.txt, CompositionExclusions-1.txt,
+ * SpecialCasing.txt and CaseFolding.txt.
  */
 
 
  * Canonical Class
  */
 
-#define CANON_CLASS_BM_SHIFT   (16 - 11)
+#define CANON_CLASS_BITS_0     9
+#define CANON_CLASS_BITS_1     7
+#define CANON_CLASS_BITS_2     5
 
-static unsigned long canon_class_bitmap[] = {
-       0x0f000000, 0x07cc7010, 0x46666600, 0x5b664444, 
-       0x00000002, 0x40000000, 0x00000020, 0x00000000, 
-       0x000000c0, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000012, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x01000000, 0x00020000, 
+static unsigned short 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,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         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, 
+           0,     0,     0,     0,     0,     0,    31,     0, 
+           0,     0,     0,     0,     0,    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,    33,    34, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     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,    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,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           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,     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, 
 };
 
-static struct canon_class canon_class[] = {
-       {0x0300, 230}, {0x0301, 230}, {0x0302, 230}, {0x0303, 230}, 
-       {0x0304, 230}, {0x0305, 230}, {0x0306, 230}, {0x0307, 230}, 
-       {0x0308, 230}, {0x0309, 230}, {0x030a, 230}, {0x030b, 230}, 
-       {0x030c, 230}, {0x030d, 230}, {0x030e, 230}, {0x030f, 230}, 
-       {0x0310, 230}, {0x0311, 230}, {0x0312, 230}, {0x0313, 230}, 
-       {0x0314, 230}, {0x0315, 232}, {0x0316, 220}, {0x0317, 220}, 
-       {0x0318, 220}, {0x0319, 220}, {0x031a, 232}, {0x031b, 216}, 
-       {0x031c, 220}, {0x031d, 220}, {0x031e, 220}, {0x031f, 220}, 
-       {0x0320, 220}, {0x0321, 202}, {0x0322, 202}, {0x0323, 220}, 
-       {0x0324, 220}, {0x0325, 220}, {0x0326, 220}, {0x0327, 202}, 
-       {0x0328, 202}, {0x0329, 220}, {0x032a, 220}, {0x032b, 220}, 
-       {0x032c, 220}, {0x032d, 220}, {0x032e, 220}, {0x032f, 220}, 
-       {0x0330, 220}, {0x0331, 220}, {0x0332, 220}, {0x0333, 220}, 
-       {0x0334,   1}, {0x0335,   1}, {0x0336,   1}, {0x0337,   1}, 
-       {0x0338,   1}, {0x0339, 220}, {0x033a, 220}, {0x033b, 220}, 
-       {0x033c, 220}, {0x033d, 230}, {0x033e, 230}, {0x033f, 230}, 
-       {0x0340, 230}, {0x0341, 230}, {0x0342, 230}, {0x0343, 230}, 
-       {0x0344, 230}, {0x0345, 240}, {0x0346, 230}, {0x0347, 220}, 
-       {0x0348, 220}, {0x0349, 220}, {0x034a, 230}, {0x034b, 230}, 
-       {0x034c, 230}, {0x034d, 220}, {0x034e, 220}, {0x0360, 234}, 
-       {0x0361, 234}, {0x0362, 233}, {0x0483, 230}, {0x0484, 230}, 
-       {0x0485, 230}, {0x0486, 230}, {0x0591, 220}, {0x0592, 230}, 
-       {0x0593, 230}, {0x0594, 230}, {0x0595, 230}, {0x0596, 220}, 
-       {0x0597, 230}, {0x0598, 230}, {0x0599, 230}, {0x059a, 222}, 
-       {0x059b, 220}, {0x059c, 230}, {0x059d, 230}, {0x059e, 230}, 
-       {0x059f, 230}, {0x05a0, 230}, {0x05a1, 230}, {0x05a3, 220}, 
-       {0x05a4, 220}, {0x05a5, 220}, {0x05a6, 220}, {0x05a7, 220}, 
-       {0x05a8, 230}, {0x05a9, 230}, {0x05aa, 220}, {0x05ab, 230}, 
-       {0x05ac, 230}, {0x05ad, 222}, {0x05ae, 228}, {0x05af, 230}, 
-       {0x05b0,  10}, {0x05b1,  11}, {0x05b2,  12}, {0x05b3,  13}, 
-       {0x05b4,  14}, {0x05b5,  15}, {0x05b6,  16}, {0x05b7,  17}, 
-       {0x05b8,  18}, {0x05b9,  19}, {0x05bb,  20}, {0x05bc,  21}, 
-       {0x05bd,  22}, {0x05bf,  23}, {0x05c1,  24}, {0x05c2,  25}, 
-       {0x05c4, 230}, {0x064b,  27}, {0x064c,  28}, {0x064d,  29}, 
-       {0x064e,  30}, {0x064f,  31}, {0x0650,  32}, {0x0651,  33}, 
-       {0x0652,  34}, {0x0653, 230}, {0x0654, 230}, {0x0655, 220}, 
-       {0x0670,  35}, {0x06d6, 230}, {0x06d7, 230}, {0x06d8, 230}, 
-       {0x06d9, 230}, {0x06da, 230}, {0x06db, 230}, {0x06dc, 230}, 
-       {0x06df, 230}, {0x06e0, 230}, {0x06e1, 230}, {0x06e2, 230}, 
-       {0x06e3, 220}, {0x06e4, 230}, {0x06e7, 230}, {0x06e8, 230}, 
-       {0x06ea, 220}, {0x06eb, 230}, {0x06ec, 230}, {0x06ed, 220}, 
-       {0x0711,  36}, {0x0730, 230}, {0x0731, 220}, {0x0732, 230}, 
-       {0x0733, 230}, {0x0734, 220}, {0x0735, 230}, {0x0736, 230}, 
-       {0x0737, 220}, {0x0738, 220}, {0x0739, 220}, {0x073a, 230}, 
-       {0x073b, 220}, {0x073c, 220}, {0x073d, 230}, {0x073e, 220}, 
-       {0x073f, 230}, {0x0740, 230}, {0x0741, 230}, {0x0742, 220}, 
-       {0x0743, 230}, {0x0744, 220}, {0x0745, 230}, {0x0746, 220}, 
-       {0x0747, 230}, {0x0748, 220}, {0x0749, 230}, {0x074a, 230}, 
-       {0x093c,   7}, {0x094d,   9}, {0x0951, 230}, {0x0952, 220}, 
-       {0x0953, 230}, {0x0954, 230}, {0x09bc,   7}, {0x09cd,   9}, 
-       {0x0a3c,   7}, {0x0a4d,   9}, {0x0abc,   7}, {0x0acd,   9}, 
-       {0x0b3c,   7}, {0x0b4d,   9}, {0x0bcd,   9}, {0x0c4d,   9}, 
-       {0x0c55,  84}, {0x0c56,  91}, {0x0ccd,   9}, {0x0d4d,   9}, 
-       {0x0dca,   9}, {0x0e38, 103}, {0x0e39, 103}, {0x0e3a,   9}, 
-       {0x0e48, 107}, {0x0e49, 107}, {0x0e4a, 107}, {0x0e4b, 107}, 
-       {0x0eb8, 118}, {0x0eb9, 118}, {0x0ec8, 122}, {0x0ec9, 122}, 
-       {0x0eca, 122}, {0x0ecb, 122}, {0x0f18, 220}, {0x0f19, 220}, 
-       {0x0f35, 220}, {0x0f37, 220}, {0x0f39, 216}, {0x0f71, 129}, 
-       {0x0f72, 130}, {0x0f74, 132}, {0x0f7a, 130}, {0x0f7b, 130}, 
-       {0x0f7c, 130}, {0x0f7d, 130}, {0x0f80, 130}, {0x0f82, 230}, 
-       {0x0f83, 230}, {0x0f84,   9}, {0x0f86, 230}, {0x0f87, 230}, 
-       {0x0fc6, 220}, {0x1037,   7}, {0x1039,   9}, {0x17d2,   9}, 
-       {0x18a9, 228}, {0x20d0, 230}, {0x20d1, 230}, {0x20d2,   1}, 
-       {0x20d3,   1}, {0x20d4, 230}, {0x20d5, 230}, {0x20d6, 230}, 
-       {0x20d7, 230}, {0x20d8,   1}, {0x20d9,   1}, {0x20da,   1}, 
-       {0x20db, 230}, {0x20dc, 230}, {0x20e1, 230}, {0x302a, 218}, 
-       {0x302b, 228}, {0x302c, 232}, {0x302d, 222}, {0x302e, 224}, 
-       {0x302f, 224}, {0x3099,   8}, {0x309a,   8}, {0xfb1e,  26}, 
-       {0xfe20, 230}, {0xfe21, 230}, {0xfe22, 230}, {0xfe23, 230}, 
+static struct {
+       unsigned char tbl[32];
+} 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,    0,    0,    0,    0,    0,    0,    0,    0, 
+          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,    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,    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,    0,    0,    0,    0,    0,    0, 
+          0,    0,    0,    0,    0,    0,    0,    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, 
+       }},
 };
 
-
 /*
  * Canonical Composition
  */
 
-#define COMPOSE_BM_SHIFT       (16 - 11)
+#define CANON_COMPOSE_BITS_0   9
+#define CANON_COMPOSE_BITS_1   7
+#define CANON_COMPOSE_BITS_2   5
+
+static unsigned short 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,    23,     0, 
+           0,    24,    25,     0,     0,     0,    26,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,    27,     0,     0,     0,     0,    28,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,    29,     0,    30,     0,    31,     0, 
+           0,     0,    32,     0,     0,    33,    34,     0, 
+           0,     0,    35,     0,     0,     0,    36,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     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,    38,    39,    40,     0,    41,    42,     0, 
+          43,    44,    45,    46,     0,    47,    48,    49, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,    50,     0,    51,     0, 
+          52,    53,    54,    55,    56,    57,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,    58,    59,    60,    61,    62,    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,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           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 unsigned long compose_bitmap[] = {
-       0x7012adee, 0x004640cf, 0x54004200, 0x00004464, 
-       0x00000002, 0x00000000, 0x00000000, 0xef6e0000, 
-       0x003f5000, 0x00000000, 0x00000000, 0x00000000, 
-       0x000000fc, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
+static struct {
+       unsigned long tbl[32];
+} 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, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0,    66174,        0,        0, 
+              0,        0,        0,        0, 
+       }},
+       {{
+              0,        0,        0,        0,        0,        0,        0, 
+         197247,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0, 
+       }},
+       {{
+              0,        0,        0,        0,        0,        0,        0, 
+              0,    66178,        0,    66179,        0,        0,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0, 
+       }},
+       {{
+              0,    66180,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0,    66181,        0,        0, 
+          66182,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0, 
+       }},
+       {{
+              0,        0,        0,        0,        0,        0,        0, 
+              0,    66183,        0,        0,        0,        0,        0, 
+              0,        0,    66184,        0,        0,    66185,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0, 
+       }},
+       {{
+              0,        0,        0,        0,        0,        0,        0, 
+         131722,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0, 
+       }},
+       {{
+              0,        0,        0,        0,        0,        0,        0, 
+         197260,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0, 
+       }},
+       {{
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0,    66191,        0,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0, 
+       }},
+       {{
+              0,        0,        0,        0,        0,        0,   131728, 
+          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,    66195, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0, 
+       }},
+       {{
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,    66196, 
+       }},
+       {{
+              0,        0,        0,        0,        0,        0,   197269, 
+              0,        0,        0,    66200,        0,        0,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0, 
+       }},
+       {{
+              0,        0,        0,        0,        0,        0,   131737, 
+          66203,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0, 
+       }},
+       {{
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0,   197276,        0,        0, 
+          66207,        0,        0,        0, 
+       }},
+       {{
+              0,        0,        0,        0,        0,    66208,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0, 
+       }},
+       {{
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,    66209,    66210,        0,        0,        0,        0, 
+              0,        0,        0,        0, 
+       }},
+       {{
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0,        0,    66211,    66212, 
+              0,        0,        0,        0, 
+       }},
+       {{
+              0,        0,    66213,    66214,        0,        0,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0, 
+       }},
+       {{
+         131751,   131753,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,    66219,    66220,        0,        0, 
+              0,        0,        0,        0, 
+       }},
+       {{
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0,        0,    66221,    66222, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0, 
+       }},
+       {{
+         262831,   262835,    66231,    66232,    66233,    66234,    66235, 
+          66236,   262845,   262849,    66245,    66246,    66247,    66248, 
+          66249,    66250,   131787,   131789,        0,        0,        0, 
+              0,        0,        0,   131791,   131793,        0,        0, 
+              0,        0,        0,        0, 
+       }},
+       {{
+         262867,   262871,    66267,    66268,    66269,    66270,    66271, 
+          66272,   262881,   262885,    66281,    66282,    66283,    66284, 
+          66285,    66286,   197359,   197362,        0,        0,        0, 
+              0,        0,        0,   197365,   197368,        0,        0, 
+              0,        0,        0,        0, 
+       }},
+       {{
+         131835,   131837,        0,        0,        0,        0,        0, 
+              0,   131839,   131841,        0,        0,        0,        0, 
+              0,        0,   197379,   197382,        0,        0,        0, 
+              0,        0,        0,        0,   197385,        0,        0, 
+              0,        0,        0,        0, 
+       }},
+       {{
+         262924,   262928,    66324,    66325,    66326,    66327,    66328, 
+          66329,   262938,   262942,    66338,    66339,    66340,    66341, 
+          66342,    66343,    66344,        0,        0,        0,    66345, 
+              0,        0,        0,        0,        0,        0,        0, 
+          66346,        0,        0,        0, 
+       }},
+       {{
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,    66347,        0,        0,        0,        0,        0, 
+              0,        0,        0,   197420, 
+       }},
+       {{
+              0,        0,        0,        0,        0,        0,    66351, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0, 
+       }},
+       {{
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,    66352,        0,        0,        0,        0,        0, 
+              0,        0,   197425,        0, 
+       }},
+       {{
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,    66356,        0,    66357,        0,    66358, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0, 
+       }},
+       {{
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,    66359,        0,    66360,        0,    66361, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0, 
+       }},
+       {{
+              0,        0,        0,    66362,        0,        0,        0, 
+              0,    66363,        0,        0,    66364,        0,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0, 
+       }},
+       {{
+              0,        0,        0,    66365,        0,    66366,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+          66367,        0,        0,        0, 
+       }},
+       {{
+              0,        0,        0,    66368,        0,    66369,        0, 
+              0,    66370,        0,        0,        0,        0,    66371, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0, 
+       }},
+       {{
+              0,    66372,        0,        0,    66373,    66374,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0,    66375,    66376,        0, 
+              0,    66377,    66378,        0,        0,    66379,    66380, 
+          66381,    66382,        0,        0, 
+       }},
+       {{
+              0,        0,    66383,    66384,        0,        0,    66385, 
+          66386,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,    66387,    66388,        0,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0, 
+       }},
+       {{
+              0,        0,    66389,        0,        0,        0,        0, 
+              0,    66390,    66391,        0,    66392,        0,        0, 
+              0,        0,        0,        0,    66393,    66394,    66395, 
+          66396,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0, 
+       }},
+       {{
+              0,        0,        0,        0,        0,        0,    66397, 
+              0,        0,        0,        0,    66398,        0,    66399, 
+              0,    66400,        0,    66401,        0,    66402,        0, 
+          66403,        0,    66404,        0,    66405,        0,    66406, 
+              0,    66407,        0,    66408, 
+       }},
+       {{
+              0,    66409,        0,        0,    66410,        0,    66411, 
+              0,    66412,        0,        0,        0,        0,        0, 
+              0,   131949,        0,        0,   131951,        0,        0, 
+         131953,        0,        0,   131955,        0,        0,   131957, 
+              0,        0,        0,        0, 
+       }},
+       {{
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,    66423,        0,        0, 
+       }},
+       {{
+              0,        0,        0,        0,        0,        0,    66424, 
+              0,        0,        0,        0,    66425,        0,    66426, 
+              0,    66427,        0,    66428,        0,    66429,        0, 
+          66430,        0,    66431,        0,    66432,        0,    66433, 
+              0,    66434,        0,    66435, 
+       }},
+       {{
+              0,    66436,        0,        0,    66437,        0,    66438, 
+              0,    66439,        0,        0,        0,        0,        0, 
+              0,   131976,        0,        0,   131978,        0,        0, 
+         131980,        0,        0,   131982,        0,        0,   131984, 
+              0,        0,        0,        0, 
+       }},
+       {{
+              0,        0,        0,        0,        0,        0,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,    66450,    66451,    66452,    66453,        0,        0, 
+              0,        0,        0,        0,        0,        0,        0, 
+              0,    66454,        0,        0, 
+       }},
 };
 
-static struct composition compose_seq[] = {
-       {0x0041, 0x0300, 0x00c0}, {0x0041, 0x0301, 0x00c1}, 
-       {0x0041, 0x0302, 0x00c2}, {0x0041, 0x0303, 0x00c3}, 
-       {0x0041, 0x0308, 0x00c4}, {0x0041, 0x030a, 0x00c5}, 
-       {0x0043, 0x0327, 0x00c7}, {0x0045, 0x0300, 0x00c8}, 
-       {0x0045, 0x0301, 0x00c9}, {0x0045, 0x0302, 0x00ca}, 
-       {0x0045, 0x0308, 0x00cb}, {0x0049, 0x0300, 0x00cc}, 
-       {0x0049, 0x0301, 0x00cd}, {0x0049, 0x0302, 0x00ce}, 
-       {0x0049, 0x0308, 0x00cf}, {0x004e, 0x0303, 0x00d1}, 
-       {0x004f, 0x0300, 0x00d2}, {0x004f, 0x0301, 0x00d3}, 
-       {0x004f, 0x0302, 0x00d4}, {0x004f, 0x0303, 0x00d5}, 
-       {0x004f, 0x0308, 0x00d6}, {0x0055, 0x0300, 0x00d9}, 
-       {0x0055, 0x0301, 0x00da}, {0x0055, 0x0302, 0x00db}, 
-       {0x0055, 0x0308, 0x00dc}, {0x0059, 0x0301, 0x00dd}, 
-       {0x0061, 0x0300, 0x00e0}, {0x0061, 0x0301, 0x00e1}, 
-       {0x0061, 0x0302, 0x00e2}, {0x0061, 0x0303, 0x00e3}, 
-       {0x0061, 0x0308, 0x00e4}, {0x0061, 0x030a, 0x00e5}, 
-       {0x0063, 0x0327, 0x00e7}, {0x0065, 0x0300, 0x00e8}, 
-       {0x0065, 0x0301, 0x00e9}, {0x0065, 0x0302, 0x00ea}, 
-       {0x0065, 0x0308, 0x00eb}, {0x0069, 0x0300, 0x00ec}, 
-       {0x0069, 0x0301, 0x00ed}, {0x0069, 0x0302, 0x00ee}, 
-       {0x0069, 0x0308, 0x00ef}, {0x006e, 0x0303, 0x00f1}, 
-       {0x006f, 0x0300, 0x00f2}, {0x006f, 0x0301, 0x00f3}, 
-       {0x006f, 0x0302, 0x00f4}, {0x006f, 0x0303, 0x00f5}, 
-       {0x006f, 0x0308, 0x00f6}, {0x0075, 0x0300, 0x00f9}, 
-       {0x0075, 0x0301, 0x00fa}, {0x0075, 0x0302, 0x00fb}, 
-       {0x0075, 0x0308, 0x00fc}, {0x0079, 0x0301, 0x00fd}, 
-       {0x0079, 0x0308, 0x00ff}, {0x0041, 0x0304, 0x0100}, 
-       {0x0061, 0x0304, 0x0101}, {0x0041, 0x0306, 0x0102}, 
-       {0x0061, 0x0306, 0x0103}, {0x0041, 0x0328, 0x0104}, 
-       {0x0061, 0x0328, 0x0105}, {0x0043, 0x0301, 0x0106}, 
-       {0x0063, 0x0301, 0x0107}, {0x0043, 0x0302, 0x0108}, 
-       {0x0063, 0x0302, 0x0109}, {0x0043, 0x0307, 0x010a}, 
-       {0x0063, 0x0307, 0x010b}, {0x0043, 0x030c, 0x010c}, 
-       {0x0063, 0x030c, 0x010d}, {0x0044, 0x030c, 0x010e}, 
-       {0x0064, 0x030c, 0x010f}, {0x0045, 0x0304, 0x0112}, 
-       {0x0065, 0x0304, 0x0113}, {0x0045, 0x0306, 0x0114}, 
-       {0x0065, 0x0306, 0x0115}, {0x0045, 0x0307, 0x0116}, 
-       {0x0065, 0x0307, 0x0117}, {0x0045, 0x0328, 0x0118}, 
-       {0x0065, 0x0328, 0x0119}, {0x0045, 0x030c, 0x011a}, 
-       {0x0065, 0x030c, 0x011b}, {0x0047, 0x0302, 0x011c}, 
-       {0x0067, 0x0302, 0x011d}, {0x0047, 0x0306, 0x011e}, 
-       {0x0067, 0x0306, 0x011f}, {0x0047, 0x0307, 0x0120}, 
-       {0x0067, 0x0307, 0x0121}, {0x0047, 0x0327, 0x0122}, 
-       {0x0067, 0x0327, 0x0123}, {0x0048, 0x0302, 0x0124}, 
-       {0x0068, 0x0302, 0x0125}, {0x0049, 0x0303, 0x0128}, 
-       {0x0069, 0x0303, 0x0129}, {0x0049, 0x0304, 0x012a}, 
-       {0x0069, 0x0304, 0x012b}, {0x0049, 0x0306, 0x012c}, 
-       {0x0069, 0x0306, 0x012d}, {0x0049, 0x0328, 0x012e}, 
-       {0x0069, 0x0328, 0x012f}, {0x0049, 0x0307, 0x0130}, 
-       {0x004a, 0x0302, 0x0134}, {0x006a, 0x0302, 0x0135}, 
-       {0x004b, 0x0327, 0x0136}, {0x006b, 0x0327, 0x0137}, 
-       {0x004c, 0x0301, 0x0139}, {0x006c, 0x0301, 0x013a}, 
-       {0x004c, 0x0327, 0x013b}, {0x006c, 0x0327, 0x013c}, 
-       {0x004c, 0x030c, 0x013d}, {0x006c, 0x030c, 0x013e}, 
-       {0x004e, 0x0301, 0x0143}, {0x006e, 0x0301, 0x0144}, 
-       {0x004e, 0x0327, 0x0145}, {0x006e, 0x0327, 0x0146}, 
-       {0x004e, 0x030c, 0x0147}, {0x006e, 0x030c, 0x0148}, 
-       {0x004f, 0x0304, 0x014c}, {0x006f, 0x0304, 0x014d}, 
-       {0x004f, 0x0306, 0x014e}, {0x006f, 0x0306, 0x014f}, 
-       {0x004f, 0x030b, 0x0150}, {0x006f, 0x030b, 0x0151}, 
-       {0x0052, 0x0301, 0x0154}, {0x0072, 0x0301, 0x0155}, 
-       {0x0052, 0x0327, 0x0156}, {0x0072, 0x0327, 0x0157}, 
-       {0x0052, 0x030c, 0x0158}, {0x0072, 0x030c, 0x0159}, 
-       {0x0053, 0x0301, 0x015a}, {0x0073, 0x0301, 0x015b}, 
-       {0x0053, 0x0302, 0x015c}, {0x0073, 0x0302, 0x015d}, 
-       {0x0053, 0x0327, 0x015e}, {0x0073, 0x0327, 0x015f}, 
-       {0x0053, 0x030c, 0x0160}, {0x0073, 0x030c, 0x0161}, 
-       {0x0054, 0x0327, 0x0162}, {0x0074, 0x0327, 0x0163}, 
-       {0x0054, 0x030c, 0x0164}, {0x0074, 0x030c, 0x0165}, 
-       {0x0055, 0x0303, 0x0168}, {0x0075, 0x0303, 0x0169}, 
-       {0x0055, 0x0304, 0x016a}, {0x0075, 0x0304, 0x016b}, 
-       {0x0055, 0x0306, 0x016c}, {0x0075, 0x0306, 0x016d}, 
-       {0x0055, 0x030a, 0x016e}, {0x0075, 0x030a, 0x016f}, 
-       {0x0055, 0x030b, 0x0170}, {0x0075, 0x030b, 0x0171}, 
-       {0x0055, 0x0328, 0x0172}, {0x0075, 0x0328, 0x0173}, 
-       {0x0057, 0x0302, 0x0174}, {0x0077, 0x0302, 0x0175}, 
-       {0x0059, 0x0302, 0x0176}, {0x0079, 0x0302, 0x0177}, 
-       {0x0059, 0x0308, 0x0178}, {0x005a, 0x0301, 0x0179}, 
-       {0x007a, 0x0301, 0x017a}, {0x005a, 0x0307, 0x017b}, 
-       {0x007a, 0x0307, 0x017c}, {0x005a, 0x030c, 0x017d}, 
-       {0x007a, 0x030c, 0x017e}, {0x004f, 0x031b, 0x01a0}, 
-       {0x006f, 0x031b, 0x01a1}, {0x0055, 0x031b, 0x01af}, 
-       {0x0075, 0x031b, 0x01b0}, {0x0041, 0x030c, 0x01cd}, 
-       {0x0061, 0x030c, 0x01ce}, {0x0049, 0x030c, 0x01cf}, 
-       {0x0069, 0x030c, 0x01d0}, {0x004f, 0x030c, 0x01d1}, 
-       {0x006f, 0x030c, 0x01d2}, {0x0055, 0x030c, 0x01d3}, 
-       {0x0075, 0x030c, 0x01d4}, {0x00dc, 0x0304, 0x01d5}, 
-       {0x00fc, 0x0304, 0x01d6}, {0x00dc, 0x0301, 0x01d7}, 
-       {0x00fc, 0x0301, 0x01d8}, {0x00dc, 0x030c, 0x01d9}, 
-       {0x00fc, 0x030c, 0x01da}, {0x00dc, 0x0300, 0x01db}, 
-       {0x00fc, 0x0300, 0x01dc}, {0x00c4, 0x0304, 0x01de}, 
-       {0x00e4, 0x0304, 0x01df}, {0x0226, 0x0304, 0x01e0}, 
-       {0x0227, 0x0304, 0x01e1}, {0x00c6, 0x0304, 0x01e2}, 
-       {0x00e6, 0x0304, 0x01e3}, {0x0047, 0x030c, 0x01e6}, 
-       {0x0067, 0x030c, 0x01e7}, {0x004b, 0x030c, 0x01e8}, 
-       {0x006b, 0x030c, 0x01e9}, {0x004f, 0x0328, 0x01ea}, 
-       {0x006f, 0x0328, 0x01eb}, {0x01ea, 0x0304, 0x01ec}, 
-       {0x01eb, 0x0304, 0x01ed}, {0x01b7, 0x030c, 0x01ee}, 
-       {0x0292, 0x030c, 0x01ef}, {0x006a, 0x030c, 0x01f0}, 
-       {0x0047, 0x0301, 0x01f4}, {0x0067, 0x0301, 0x01f5}, 
-       {0x004e, 0x0300, 0x01f8}, {0x006e, 0x0300, 0x01f9}, 
-       {0x00c5, 0x0301, 0x01fa}, {0x00e5, 0x0301, 0x01fb}, 
-       {0x00c6, 0x0301, 0x01fc}, {0x00e6, 0x0301, 0x01fd}, 
-       {0x00d8, 0x0301, 0x01fe}, {0x00f8, 0x0301, 0x01ff}, 
-       {0x0041, 0x030f, 0x0200}, {0x0061, 0x030f, 0x0201}, 
-       {0x0041, 0x0311, 0x0202}, {0x0061, 0x0311, 0x0203}, 
-       {0x0045, 0x030f, 0x0204}, {0x0065, 0x030f, 0x0205}, 
-       {0x0045, 0x0311, 0x0206}, {0x0065, 0x0311, 0x0207}, 
-       {0x0049, 0x030f, 0x0208}, {0x0069, 0x030f, 0x0209}, 
-       {0x0049, 0x0311, 0x020a}, {0x0069, 0x0311, 0x020b}, 
-       {0x004f, 0x030f, 0x020c}, {0x006f, 0x030f, 0x020d}, 
-       {0x004f, 0x0311, 0x020e}, {0x006f, 0x0311, 0x020f}, 
-       {0x0052, 0x030f, 0x0210}, {0x0072, 0x030f, 0x0211}, 
-       {0x0052, 0x0311, 0x0212}, {0x0072, 0x0311, 0x0213}, 
-       {0x0055, 0x030f, 0x0214}, {0x0075, 0x030f, 0x0215}, 
-       {0x0055, 0x0311, 0x0216}, {0x0075, 0x0311, 0x0217}, 
-       {0x0053, 0x0326, 0x0218}, {0x0073, 0x0326, 0x0219}, 
-       {0x0054, 0x0326, 0x021a}, {0x0074, 0x0326, 0x021b}, 
-       {0x0048, 0x030c, 0x021e}, {0x0068, 0x030c, 0x021f}, 
-       {0x0041, 0x0307, 0x0226}, {0x0061, 0x0307, 0x0227}, 
-       {0x0045, 0x0327, 0x0228}, {0x0065, 0x0327, 0x0229}, 
-       {0x00d6, 0x0304, 0x022a}, {0x00f6, 0x0304, 0x022b}, 
-       {0x00d5, 0x0304, 0x022c}, {0x00f5, 0x0304, 0x022d}, 
-       {0x004f, 0x0307, 0x022e}, {0x006f, 0x0307, 0x022f}, 
-       {0x022e, 0x0304, 0x0230}, {0x022f, 0x0304, 0x0231}, 
-       {0x0059, 0x0304, 0x0232}, {0x0079, 0x0304, 0x0233}, 
-       {0x00a8, 0x0301, 0x0385}, {0x0391, 0x0301, 0x0386}, 
-       {0x0395, 0x0301, 0x0388}, {0x0397, 0x0301, 0x0389}, 
-       {0x0399, 0x0301, 0x038a}, {0x039f, 0x0301, 0x038c}, 
-       {0x03a5, 0x0301, 0x038e}, {0x03a9, 0x0301, 0x038f}, 
-       {0x03ca, 0x0301, 0x0390}, {0x0399, 0x0308, 0x03aa}, 
-       {0x03a5, 0x0308, 0x03ab}, {0x03b1, 0x0301, 0x03ac}, 
-       {0x03b5, 0x0301, 0x03ad}, {0x03b7, 0x0301, 0x03ae}, 
-       {0x03b9, 0x0301, 0x03af}, {0x03cb, 0x0301, 0x03b0}, 
-       {0x03b9, 0x0308, 0x03ca}, {0x03c5, 0x0308, 0x03cb}, 
-       {0x03bf, 0x0301, 0x03cc}, {0x03c5, 0x0301, 0x03cd}, 
-       {0x03c9, 0x0301, 0x03ce}, {0x03d2, 0x0301, 0x03d3}, 
-       {0x03d2, 0x0308, 0x03d4}, {0x0415, 0x0300, 0x0400}, 
-       {0x0415, 0x0308, 0x0401}, {0x0413, 0x0301, 0x0403}, 
-       {0x0406, 0x0308, 0x0407}, {0x041a, 0x0301, 0x040c}, 
-       {0x0418, 0x0300, 0x040d}, {0x0423, 0x0306, 0x040e}, 
-       {0x0418, 0x0306, 0x0419}, {0x0438, 0x0306, 0x0439}, 
-       {0x0435, 0x0300, 0x0450}, {0x0435, 0x0308, 0x0451}, 
-       {0x0433, 0x0301, 0x0453}, {0x0456, 0x0308, 0x0457}, 
-       {0x043a, 0x0301, 0x045c}, {0x0438, 0x0300, 0x045d}, 
-       {0x0443, 0x0306, 0x045e}, {0x0474, 0x030f, 0x0476}, 
-       {0x0475, 0x030f, 0x0477}, {0x0416, 0x0306, 0x04c1}, 
-       {0x0436, 0x0306, 0x04c2}, {0x0410, 0x0306, 0x04d0}, 
-       {0x0430, 0x0306, 0x04d1}, {0x0410, 0x0308, 0x04d2}, 
-       {0x0430, 0x0308, 0x04d3}, {0x0415, 0x0306, 0x04d6}, 
-       {0x0435, 0x0306, 0x04d7}, {0x04d8, 0x0308, 0x04da}, 
-       {0x04d9, 0x0308, 0x04db}, {0x0416, 0x0308, 0x04dc}, 
-       {0x0436, 0x0308, 0x04dd}, {0x0417, 0x0308, 0x04de}, 
-       {0x0437, 0x0308, 0x04df}, {0x0418, 0x0304, 0x04e2}, 
-       {0x0438, 0x0304, 0x04e3}, {0x0418, 0x0308, 0x04e4}, 
-       {0x0438, 0x0308, 0x04e5}, {0x041e, 0x0308, 0x04e6}, 
-       {0x043e, 0x0308, 0x04e7}, {0x04e8, 0x0308, 0x04ea}, 
-       {0x04e9, 0x0308, 0x04eb}, {0x042d, 0x0308, 0x04ec}, 
-       {0x044d, 0x0308, 0x04ed}, {0x0423, 0x0304, 0x04ee}, 
-       {0x0443, 0x0304, 0x04ef}, {0x0423, 0x0308, 0x04f0}, 
-       {0x0443, 0x0308, 0x04f1}, {0x0423, 0x030b, 0x04f2}, 
-       {0x0443, 0x030b, 0x04f3}, {0x0427, 0x0308, 0x04f4}, 
-       {0x0447, 0x0308, 0x04f5}, {0x042b, 0x0308, 0x04f8}, 
-       {0x044b, 0x0308, 0x04f9}, {0x0627, 0x0653, 0x0622}, 
-       {0x0627, 0x0654, 0x0623}, {0x0648, 0x0654, 0x0624}, 
-       {0x0627, 0x0655, 0x0625}, {0x064a, 0x0654, 0x0626}, 
-       {0x06d5, 0x0654, 0x06c0}, {0x06c1, 0x0654, 0x06c2}, 
-       {0x06d2, 0x0654, 0x06d3}, {0x0928, 0x093c, 0x0929}, 
-       {0x0930, 0x093c, 0x0931}, {0x0933, 0x093c, 0x0934}, 
-       {0x09c7, 0x09be, 0x09cb}, {0x09c7, 0x09d7, 0x09cc}, 
-       {0x0b47, 0x0b56, 0x0b48}, {0x0b47, 0x0b3e, 0x0b4b}, 
-       {0x0b47, 0x0b57, 0x0b4c}, {0x0b92, 0x0bd7, 0x0b94}, 
-       {0x0bc6, 0x0bbe, 0x0bca}, {0x0bc7, 0x0bbe, 0x0bcb}, 
-       {0x0bc6, 0x0bd7, 0x0bcc}, {0x0c46, 0x0c56, 0x0c48}, 
-       {0x0cbf, 0x0cd5, 0x0cc0}, {0x0cc6, 0x0cd5, 0x0cc7}, 
-       {0x0cc6, 0x0cd6, 0x0cc8}, {0x0cc6, 0x0cc2, 0x0cca}, 
-       {0x0cca, 0x0cd5, 0x0ccb}, {0x0d46, 0x0d3e, 0x0d4a}, 
-       {0x0d47, 0x0d3e, 0x0d4b}, {0x0d46, 0x0d57, 0x0d4c}, 
-       {0x0dd9, 0x0dca, 0x0dda}, {0x0dd9, 0x0dcf, 0x0ddc}, 
-       {0x0ddc, 0x0dca, 0x0ddd}, {0x0dd9, 0x0ddf, 0x0dde}, 
-       {0x1025, 0x102e, 0x1026}, {0x0041, 0x0325, 0x1e00}, 
-       {0x0061, 0x0325, 0x1e01}, {0x0042, 0x0307, 0x1e02}, 
-       {0x0062, 0x0307, 0x1e03}, {0x0042, 0x0323, 0x1e04}, 
-       {0x0062, 0x0323, 0x1e05}, {0x0042, 0x0331, 0x1e06}, 
-       {0x0062, 0x0331, 0x1e07}, {0x00c7, 0x0301, 0x1e08}, 
-       {0x00e7, 0x0301, 0x1e09}, {0x0044, 0x0307, 0x1e0a}, 
-       {0x0064, 0x0307, 0x1e0b}, {0x0044, 0x0323, 0x1e0c}, 
-       {0x0064, 0x0323, 0x1e0d}, {0x0044, 0x0331, 0x1e0e}, 
-       {0x0064, 0x0331, 0x1e0f}, {0x0044, 0x0327, 0x1e10}, 
-       {0x0064, 0x0327, 0x1e11}, {0x0044, 0x032d, 0x1e12}, 
-       {0x0064, 0x032d, 0x1e13}, {0x0112, 0x0300, 0x1e14}, 
-       {0x0113, 0x0300, 0x1e15}, {0x0112, 0x0301, 0x1e16}, 
-       {0x0113, 0x0301, 0x1e17}, {0x0045, 0x032d, 0x1e18}, 
-       {0x0065, 0x032d, 0x1e19}, {0x0045, 0x0330, 0x1e1a}, 
-       {0x0065, 0x0330, 0x1e1b}, {0x0228, 0x0306, 0x1e1c}, 
-       {0x0229, 0x0306, 0x1e1d}, {0x0046, 0x0307, 0x1e1e}, 
-       {0x0066, 0x0307, 0x1e1f}, {0x0047, 0x0304, 0x1e20}, 
-       {0x0067, 0x0304, 0x1e21}, {0x0048, 0x0307, 0x1e22}, 
-       {0x0068, 0x0307, 0x1e23}, {0x0048, 0x0323, 0x1e24}, 
-       {0x0068, 0x0323, 0x1e25}, {0x0048, 0x0308, 0x1e26}, 
-       {0x0068, 0x0308, 0x1e27}, {0x0048, 0x0327, 0x1e28}, 
-       {0x0068, 0x0327, 0x1e29}, {0x0048, 0x032e, 0x1e2a}, 
-       {0x0068, 0x032e, 0x1e2b}, {0x0049, 0x0330, 0x1e2c}, 
-       {0x0069, 0x0330, 0x1e2d}, {0x00cf, 0x0301, 0x1e2e}, 
-       {0x00ef, 0x0301, 0x1e2f}, {0x004b, 0x0301, 0x1e30}, 
-       {0x006b, 0x0301, 0x1e31}, {0x004b, 0x0323, 0x1e32}, 
-       {0x006b, 0x0323, 0x1e33}, {0x004b, 0x0331, 0x1e34}, 
-       {0x006b, 0x0331, 0x1e35}, {0x004c, 0x0323, 0x1e36}, 
-       {0x006c, 0x0323, 0x1e37}, {0x1e36, 0x0304, 0x1e38}, 
-       {0x1e37, 0x0304, 0x1e39}, {0x004c, 0x0331, 0x1e3a}, 
-       {0x006c, 0x0331, 0x1e3b}, {0x004c, 0x032d, 0x1e3c}, 
-       {0x006c, 0x032d, 0x1e3d}, {0x004d, 0x0301, 0x1e3e}, 
-       {0x006d, 0x0301, 0x1e3f}, {0x004d, 0x0307, 0x1e40}, 
-       {0x006d, 0x0307, 0x1e41}, {0x004d, 0x0323, 0x1e42}, 
-       {0x006d, 0x0323, 0x1e43}, {0x004e, 0x0307, 0x1e44}, 
-       {0x006e, 0x0307, 0x1e45}, {0x004e, 0x0323, 0x1e46}, 
-       {0x006e, 0x0323, 0x1e47}, {0x004e, 0x0331, 0x1e48}, 
-       {0x006e, 0x0331, 0x1e49}, {0x004e, 0x032d, 0x1e4a}, 
-       {0x006e, 0x032d, 0x1e4b}, {0x00d5, 0x0301, 0x1e4c}, 
-       {0x00f5, 0x0301, 0x1e4d}, {0x00d5, 0x0308, 0x1e4e}, 
-       {0x00f5, 0x0308, 0x1e4f}, {0x014c, 0x0300, 0x1e50}, 
-       {0x014d, 0x0300, 0x1e51}, {0x014c, 0x0301, 0x1e52}, 
-       {0x014d, 0x0301, 0x1e53}, {0x0050, 0x0301, 0x1e54}, 
-       {0x0070, 0x0301, 0x1e55}, {0x0050, 0x0307, 0x1e56}, 
-       {0x0070, 0x0307, 0x1e57}, {0x0052, 0x0307, 0x1e58}, 
-       {0x0072, 0x0307, 0x1e59}, {0x0052, 0x0323, 0x1e5a}, 
-       {0x0072, 0x0323, 0x1e5b}, {0x1e5a, 0x0304, 0x1e5c}, 
-       {0x1e5b, 0x0304, 0x1e5d}, {0x0052, 0x0331, 0x1e5e}, 
-       {0x0072, 0x0331, 0x1e5f}, {0x0053, 0x0307, 0x1e60}, 
-       {0x0073, 0x0307, 0x1e61}, {0x0053, 0x0323, 0x1e62}, 
-       {0x0073, 0x0323, 0x1e63}, {0x015a, 0x0307, 0x1e64}, 
-       {0x015b, 0x0307, 0x1e65}, {0x0160, 0x0307, 0x1e66}, 
-       {0x0161, 0x0307, 0x1e67}, {0x1e62, 0x0307, 0x1e68}, 
-       {0x1e63, 0x0307, 0x1e69}, {0x0054, 0x0307, 0x1e6a}, 
-       {0x0074, 0x0307, 0x1e6b}, {0x0054, 0x0323, 0x1e6c}, 
-       {0x0074, 0x0323, 0x1e6d}, {0x0054, 0x0331, 0x1e6e}, 
-       {0x0074, 0x0331, 0x1e6f}, {0x0054, 0x032d, 0x1e70}, 
-       {0x0074, 0x032d, 0x1e71}, {0x0055, 0x0324, 0x1e72}, 
-       {0x0075, 0x0324, 0x1e73}, {0x0055, 0x0330, 0x1e74}, 
-       {0x0075, 0x0330, 0x1e75}, {0x0055, 0x032d, 0x1e76}, 
-       {0x0075, 0x032d, 0x1e77}, {0x0168, 0x0301, 0x1e78}, 
-       {0x0169, 0x0301, 0x1e79}, {0x016a, 0x0308, 0x1e7a}, 
-       {0x016b, 0x0308, 0x1e7b}, {0x0056, 0x0303, 0x1e7c}, 
-       {0x0076, 0x0303, 0x1e7d}, {0x0056, 0x0323, 0x1e7e}, 
-       {0x0076, 0x0323, 0x1e7f}, {0x0057, 0x0300, 0x1e80}, 
-       {0x0077, 0x0300, 0x1e81}, {0x0057, 0x0301, 0x1e82}, 
-       {0x0077, 0x0301, 0x1e83}, {0x0057, 0x0308, 0x1e84}, 
-       {0x0077, 0x0308, 0x1e85}, {0x0057, 0x0307, 0x1e86}, 
-       {0x0077, 0x0307, 0x1e87}, {0x0057, 0x0323, 0x1e88}, 
-       {0x0077, 0x0323, 0x1e89}, {0x0058, 0x0307, 0x1e8a}, 
-       {0x0078, 0x0307, 0x1e8b}, {0x0058, 0x0308, 0x1e8c}, 
-       {0x0078, 0x0308, 0x1e8d}, {0x0059, 0x0307, 0x1e8e}, 
-       {0x0079, 0x0307, 0x1e8f}, {0x005a, 0x0302, 0x1e90}, 
-       {0x007a, 0x0302, 0x1e91}, {0x005a, 0x0323, 0x1e92}, 
-       {0x007a, 0x0323, 0x1e93}, {0x005a, 0x0331, 0x1e94}, 
-       {0x007a, 0x0331, 0x1e95}, {0x0068, 0x0331, 0x1e96}, 
-       {0x0074, 0x0308, 0x1e97}, {0x0077, 0x030a, 0x1e98}, 
-       {0x0079, 0x030a, 0x1e99}, {0x017f, 0x0307, 0x1e9b}, 
-       {0x0041, 0x0323, 0x1ea0}, {0x0061, 0x0323, 0x1ea1}, 
-       {0x0041, 0x0309, 0x1ea2}, {0x0061, 0x0309, 0x1ea3}, 
-       {0x00c2, 0x0301, 0x1ea4}, {0x00e2, 0x0301, 0x1ea5}, 
-       {0x00c2, 0x0300, 0x1ea6}, {0x00e2, 0x0300, 0x1ea7}, 
-       {0x00c2, 0x0309, 0x1ea8}, {0x00e2, 0x0309, 0x1ea9}, 
-       {0x00c2, 0x0303, 0x1eaa}, {0x00e2, 0x0303, 0x1eab}, 
-       {0x1ea0, 0x0302, 0x1eac}, {0x1ea1, 0x0302, 0x1ead}, 
-       {0x0102, 0x0301, 0x1eae}, {0x0103, 0x0301, 0x1eaf}, 
-       {0x0102, 0x0300, 0x1eb0}, {0x0103, 0x0300, 0x1eb1}, 
-       {0x0102, 0x0309, 0x1eb2}, {0x0103, 0x0309, 0x1eb3}, 
-       {0x0102, 0x0303, 0x1eb4}, {0x0103, 0x0303, 0x1eb5}, 
-       {0x1ea0, 0x0306, 0x1eb6}, {0x1ea1, 0x0306, 0x1eb7}, 
-       {0x0045, 0x0323, 0x1eb8}, {0x0065, 0x0323, 0x1eb9}, 
-       {0x0045, 0x0309, 0x1eba}, {0x0065, 0x0309, 0x1ebb}, 
-       {0x0045, 0x0303, 0x1ebc}, {0x0065, 0x0303, 0x1ebd}, 
-       {0x00ca, 0x0301, 0x1ebe}, {0x00ea, 0x0301, 0x1ebf}, 
-       {0x00ca, 0x0300, 0x1ec0}, {0x00ea, 0x0300, 0x1ec1}, 
-       {0x00ca, 0x0309, 0x1ec2}, {0x00ea, 0x0309, 0x1ec3}, 
-       {0x00ca, 0x0303, 0x1ec4}, {0x00ea, 0x0303, 0x1ec5}, 
-       {0x1eb8, 0x0302, 0x1ec6}, {0x1eb9, 0x0302, 0x1ec7}, 
-       {0x0049, 0x0309, 0x1ec8}, {0x0069, 0x0309, 0x1ec9}, 
-       {0x0049, 0x0323, 0x1eca}, {0x0069, 0x0323, 0x1ecb}, 
-       {0x004f, 0x0323, 0x1ecc}, {0x006f, 0x0323, 0x1ecd}, 
-       {0x004f, 0x0309, 0x1ece}, {0x006f, 0x0309, 0x1ecf}, 
-       {0x00d4, 0x0301, 0x1ed0}, {0x00f4, 0x0301, 0x1ed1}, 
-       {0x00d4, 0x0300, 0x1ed2}, {0x00f4, 0x0300, 0x1ed3}, 
-       {0x00d4, 0x0309, 0x1ed4}, {0x00f4, 0x0309, 0x1ed5}, 
-       {0x00d4, 0x0303, 0x1ed6}, {0x00f4, 0x0303, 0x1ed7}, 
-       {0x1ecc, 0x0302, 0x1ed8}, {0x1ecd, 0x0302, 0x1ed9}, 
-       {0x01a0, 0x0301, 0x1eda}, {0x01a1, 0x0301, 0x1edb}, 
-       {0x01a0, 0x0300, 0x1edc}, {0x01a1, 0x0300, 0x1edd}, 
-       {0x01a0, 0x0309, 0x1ede}, {0x01a1, 0x0309, 0x1edf}, 
-       {0x01a0, 0x0303, 0x1ee0}, {0x01a1, 0x0303, 0x1ee1}, 
-       {0x01a0, 0x0323, 0x1ee2}, {0x01a1, 0x0323, 0x1ee3}, 
-       {0x0055, 0x0323, 0x1ee4}, {0x0075, 0x0323, 0x1ee5}, 
-       {0x0055, 0x0309, 0x1ee6}, {0x0075, 0x0309, 0x1ee7}, 
-       {0x01af, 0x0301, 0x1ee8}, {0x01b0, 0x0301, 0x1ee9}, 
-       {0x01af, 0x0300, 0x1eea}, {0x01b0, 0x0300, 0x1eeb}, 
-       {0x01af, 0x0309, 0x1eec}, {0x01b0, 0x0309, 0x1eed}, 
-       {0x01af, 0x0303, 0x1eee}, {0x01b0, 0x0303, 0x1eef}, 
-       {0x01af, 0x0323, 0x1ef0}, {0x01b0, 0x0323, 0x1ef1}, 
-       {0x0059, 0x0300, 0x1ef2}, {0x0079, 0x0300, 0x1ef3}, 
-       {0x0059, 0x0323, 0x1ef4}, {0x0079, 0x0323, 0x1ef5}, 
-       {0x0059, 0x0309, 0x1ef6}, {0x0079, 0x0309, 0x1ef7}, 
-       {0x0059, 0x0303, 0x1ef8}, {0x0079, 0x0303, 0x1ef9}, 
-       {0x03b1, 0x0313, 0x1f00}, {0x03b1, 0x0314, 0x1f01}, 
-       {0x1f00, 0x0300, 0x1f02}, {0x1f01, 0x0300, 0x1f03}, 
-       {0x1f00, 0x0301, 0x1f04}, {0x1f01, 0x0301, 0x1f05}, 
-       {0x1f00, 0x0342, 0x1f06}, {0x1f01, 0x0342, 0x1f07}, 
-       {0x0391, 0x0313, 0x1f08}, {0x0391, 0x0314, 0x1f09}, 
-       {0x1f08, 0x0300, 0x1f0a}, {0x1f09, 0x0300, 0x1f0b}, 
-       {0x1f08, 0x0301, 0x1f0c}, {0x1f09, 0x0301, 0x1f0d}, 
-       {0x1f08, 0x0342, 0x1f0e}, {0x1f09, 0x0342, 0x1f0f}, 
-       {0x03b5, 0x0313, 0x1f10}, {0x03b5, 0x0314, 0x1f11}, 
-       {0x1f10, 0x0300, 0x1f12}, {0x1f11, 0x0300, 0x1f13}, 
-       {0x1f10, 0x0301, 0x1f14}, {0x1f11, 0x0301, 0x1f15}, 
-       {0x0395, 0x0313, 0x1f18}, {0x0395, 0x0314, 0x1f19}, 
-       {0x1f18, 0x0300, 0x1f1a}, {0x1f19, 0x0300, 0x1f1b}, 
-       {0x1f18, 0x0301, 0x1f1c}, {0x1f19, 0x0301, 0x1f1d}, 
-       {0x03b7, 0x0313, 0x1f20}, {0x03b7, 0x0314, 0x1f21}, 
-       {0x1f20, 0x0300, 0x1f22}, {0x1f21, 0x0300, 0x1f23}, 
-       {0x1f20, 0x0301, 0x1f24}, {0x1f21, 0x0301, 0x1f25}, 
-       {0x1f20, 0x0342, 0x1f26}, {0x1f21, 0x0342, 0x1f27}, 
-       {0x0397, 0x0313, 0x1f28}, {0x0397, 0x0314, 0x1f29}, 
-       {0x1f28, 0x0300, 0x1f2a}, {0x1f29, 0x0300, 0x1f2b}, 
-       {0x1f28, 0x0301, 0x1f2c}, {0x1f29, 0x0301, 0x1f2d}, 
-       {0x1f28, 0x0342, 0x1f2e}, {0x1f29, 0x0342, 0x1f2f}, 
-       {0x03b9, 0x0313, 0x1f30}, {0x03b9, 0x0314, 0x1f31}, 
-       {0x1f30, 0x0300, 0x1f32}, {0x1f31, 0x0300, 0x1f33}, 
-       {0x1f30, 0x0301, 0x1f34}, {0x1f31, 0x0301, 0x1f35}, 
-       {0x1f30, 0x0342, 0x1f36}, {0x1f31, 0x0342, 0x1f37}, 
-       {0x0399, 0x0313, 0x1f38}, {0x0399, 0x0314, 0x1f39}, 
-       {0x1f38, 0x0300, 0x1f3a}, {0x1f39, 0x0300, 0x1f3b}, 
-       {0x1f38, 0x0301, 0x1f3c}, {0x1f39, 0x0301, 0x1f3d}, 
-       {0x1f38, 0x0342, 0x1f3e}, {0x1f39, 0x0342, 0x1f3f}, 
-       {0x03bf, 0x0313, 0x1f40}, {0x03bf, 0x0314, 0x1f41}, 
-       {0x1f40, 0x0300, 0x1f42}, {0x1f41, 0x0300, 0x1f43}, 
-       {0x1f40, 0x0301, 0x1f44}, {0x1f41, 0x0301, 0x1f45}, 
-       {0x039f, 0x0313, 0x1f48}, {0x039f, 0x0314, 0x1f49}, 
-       {0x1f48, 0x0300, 0x1f4a}, {0x1f49, 0x0300, 0x1f4b}, 
-       {0x1f48, 0x0301, 0x1f4c}, {0x1f49, 0x0301, 0x1f4d}, 
-       {0x03c5, 0x0313, 0x1f50}, {0x03c5, 0x0314, 0x1f51}, 
-       {0x1f50, 0x0300, 0x1f52}, {0x1f51, 0x0300, 0x1f53}, 
-       {0x1f50, 0x0301, 0x1f54}, {0x1f51, 0x0301, 0x1f55}, 
-       {0x1f50, 0x0342, 0x1f56}, {0x1f51, 0x0342, 0x1f57}, 
-       {0x03a5, 0x0314, 0x1f59}, {0x1f59, 0x0300, 0x1f5b}, 
-       {0x1f59, 0x0301, 0x1f5d}, {0x1f59, 0x0342, 0x1f5f}, 
-       {0x03c9, 0x0313, 0x1f60}, {0x03c9, 0x0314, 0x1f61}, 
-       {0x1f60, 0x0300, 0x1f62}, {0x1f61, 0x0300, 0x1f63}, 
-       {0x1f60, 0x0301, 0x1f64}, {0x1f61, 0x0301, 0x1f65}, 
-       {0x1f60, 0x0342, 0x1f66}, {0x1f61, 0x0342, 0x1f67}, 
-       {0x03a9, 0x0313, 0x1f68}, {0x03a9, 0x0314, 0x1f69}, 
-       {0x1f68, 0x0300, 0x1f6a}, {0x1f69, 0x0300, 0x1f6b}, 
-       {0x1f68, 0x0301, 0x1f6c}, {0x1f69, 0x0301, 0x1f6d}, 
-       {0x1f68, 0x0342, 0x1f6e}, {0x1f69, 0x0342, 0x1f6f}, 
-       {0x03b1, 0x0300, 0x1f70}, {0x03b5, 0x0300, 0x1f72}, 
-       {0x03b7, 0x0300, 0x1f74}, {0x03b9, 0x0300, 0x1f76}, 
-       {0x03bf, 0x0300, 0x1f78}, {0x03c5, 0x0300, 0x1f7a}, 
-       {0x03c9, 0x0300, 0x1f7c}, {0x1f00, 0x0345, 0x1f80}, 
-       {0x1f01, 0x0345, 0x1f81}, {0x1f02, 0x0345, 0x1f82}, 
-       {0x1f03, 0x0345, 0x1f83}, {0x1f04, 0x0345, 0x1f84}, 
-       {0x1f05, 0x0345, 0x1f85}, {0x1f06, 0x0345, 0x1f86}, 
-       {0x1f07, 0x0345, 0x1f87}, {0x1f08, 0x0345, 0x1f88}, 
-       {0x1f09, 0x0345, 0x1f89}, {0x1f0a, 0x0345, 0x1f8a}, 
-       {0x1f0b, 0x0345, 0x1f8b}, {0x1f0c, 0x0345, 0x1f8c}, 
-       {0x1f0d, 0x0345, 0x1f8d}, {0x1f0e, 0x0345, 0x1f8e}, 
-       {0x1f0f, 0x0345, 0x1f8f}, {0x1f20, 0x0345, 0x1f90}, 
-       {0x1f21, 0x0345, 0x1f91}, {0x1f22, 0x0345, 0x1f92}, 
-       {0x1f23, 0x0345, 0x1f93}, {0x1f24, 0x0345, 0x1f94}, 
-       {0x1f25, 0x0345, 0x1f95}, {0x1f26, 0x0345, 0x1f96}, 
-       {0x1f27, 0x0345, 0x1f97}, {0x1f28, 0x0345, 0x1f98}, 
-       {0x1f29, 0x0345, 0x1f99}, {0x1f2a, 0x0345, 0x1f9a}, 
-       {0x1f2b, 0x0345, 0x1f9b}, {0x1f2c, 0x0345, 0x1f9c}, 
-       {0x1f2d, 0x0345, 0x1f9d}, {0x1f2e, 0x0345, 0x1f9e}, 
-       {0x1f2f, 0x0345, 0x1f9f}, {0x1f60, 0x0345, 0x1fa0}, 
-       {0x1f61, 0x0345, 0x1fa1}, {0x1f62, 0x0345, 0x1fa2}, 
-       {0x1f63, 0x0345, 0x1fa3}, {0x1f64, 0x0345, 0x1fa4}, 
-       {0x1f65, 0x0345, 0x1fa5}, {0x1f66, 0x0345, 0x1fa6}, 
-       {0x1f67, 0x0345, 0x1fa7}, {0x1f68, 0x0345, 0x1fa8}, 
-       {0x1f69, 0x0345, 0x1fa9}, {0x1f6a, 0x0345, 0x1faa}, 
-       {0x1f6b, 0x0345, 0x1fab}, {0x1f6c, 0x0345, 0x1fac}, 
-       {0x1f6d, 0x0345, 0x1fad}, {0x1f6e, 0x0345, 0x1fae}, 
-       {0x1f6f, 0x0345, 0x1faf}, {0x03b1, 0x0306, 0x1fb0}, 
-       {0x03b1, 0x0304, 0x1fb1}, {0x1f70, 0x0345, 0x1fb2}, 
-       {0x03b1, 0x0345, 0x1fb3}, {0x03ac, 0x0345, 0x1fb4}, 
-       {0x03b1, 0x0342, 0x1fb6}, {0x1fb6, 0x0345, 0x1fb7}, 
-       {0x0391, 0x0306, 0x1fb8}, {0x0391, 0x0304, 0x1fb9}, 
-       {0x0391, 0x0300, 0x1fba}, {0x0391, 0x0345, 0x1fbc}, 
-       {0x00a8, 0x0342, 0x1fc1}, {0x1f74, 0x0345, 0x1fc2}, 
-       {0x03b7, 0x0345, 0x1fc3}, {0x03ae, 0x0345, 0x1fc4}, 
-       {0x03b7, 0x0342, 0x1fc6}, {0x1fc6, 0x0345, 0x1fc7}, 
-       {0x0395, 0x0300, 0x1fc8}, {0x0397, 0x0300, 0x1fca}, 
-       {0x0397, 0x0345, 0x1fcc}, {0x1fbf, 0x0300, 0x1fcd}, 
-       {0x1fbf, 0x0301, 0x1fce}, {0x1fbf, 0x0342, 0x1fcf}, 
-       {0x03b9, 0x0306, 0x1fd0}, {0x03b9, 0x0304, 0x1fd1}, 
-       {0x03ca, 0x0300, 0x1fd2}, {0x03b9, 0x0342, 0x1fd6}, 
-       {0x03ca, 0x0342, 0x1fd7}, {0x0399, 0x0306, 0x1fd8}, 
-       {0x0399, 0x0304, 0x1fd9}, {0x0399, 0x0300, 0x1fda}, 
-       {0x1ffe, 0x0300, 0x1fdd}, {0x1ffe, 0x0301, 0x1fde}, 
-       {0x1ffe, 0x0342, 0x1fdf}, {0x03c5, 0x0306, 0x1fe0}, 
-       {0x03c5, 0x0304, 0x1fe1}, {0x03cb, 0x0300, 0x1fe2}, 
-       {0x03c1, 0x0313, 0x1fe4}, {0x03c1, 0x0314, 0x1fe5}, 
-       {0x03c5, 0x0342, 0x1fe6}, {0x03cb, 0x0342, 0x1fe7}, 
-       {0x03a5, 0x0306, 0x1fe8}, {0x03a5, 0x0304, 0x1fe9}, 
-       {0x03a5, 0x0300, 0x1fea}, {0x03a1, 0x0314, 0x1fec}, 
-       {0x00a8, 0x0300, 0x1fed}, {0x1f7c, 0x0345, 0x1ff2}, 
-       {0x03c9, 0x0345, 0x1ff3}, {0x03ce, 0x0345, 0x1ff4}, 
-       {0x03c9, 0x0342, 0x1ff6}, {0x1ff6, 0x0345, 0x1ff7}, 
-       {0x039f, 0x0300, 0x1ff8}, {0x03a9, 0x0300, 0x1ffa}, 
-       {0x03a9, 0x0345, 0x1ffc}, {0x2190, 0x0338, 0x219a}, 
-       {0x2192, 0x0338, 0x219b}, {0x2194, 0x0338, 0x21ae}, 
-       {0x21d0, 0x0338, 0x21cd}, {0x21d4, 0x0338, 0x21ce}, 
-       {0x21d2, 0x0338, 0x21cf}, {0x2203, 0x0338, 0x2204}, 
-       {0x2208, 0x0338, 0x2209}, {0x220b, 0x0338, 0x220c}, 
-       {0x2223, 0x0338, 0x2224}, {0x2225, 0x0338, 0x2226}, 
-       {0x223c, 0x0338, 0x2241}, {0x2243, 0x0338, 0x2244}, 
-       {0x2245, 0x0338, 0x2247}, {0x2248, 0x0338, 0x2249}, 
-       {0x003d, 0x0338, 0x2260}, {0x2261, 0x0338, 0x2262}, 
-       {0x224d, 0x0338, 0x226d}, {0x003c, 0x0338, 0x226e}, 
-       {0x003e, 0x0338, 0x226f}, {0x2264, 0x0338, 0x2270}, 
-       {0x2265, 0x0338, 0x2271}, {0x2272, 0x0338, 0x2274}, 
-       {0x2273, 0x0338, 0x2275}, {0x2276, 0x0338, 0x2278}, 
-       {0x2277, 0x0338, 0x2279}, {0x227a, 0x0338, 0x2280}, 
-       {0x227b, 0x0338, 0x2281}, {0x2282, 0x0338, 0x2284}, 
-       {0x2283, 0x0338, 0x2285}, {0x2286, 0x0338, 0x2288}, 
-       {0x2287, 0x0338, 0x2289}, {0x22a2, 0x0338, 0x22ac}, 
-       {0x22a8, 0x0338, 0x22ad}, {0x22a9, 0x0338, 0x22ae}, 
-       {0x22ab, 0x0338, 0x22af}, {0x227c, 0x0338, 0x22e0}, 
-       {0x227d, 0x0338, 0x22e1}, {0x2291, 0x0338, 0x22e2}, 
-       {0x2292, 0x0338, 0x22e3}, {0x22b2, 0x0338, 0x22ea}, 
-       {0x22b3, 0x0338, 0x22eb}, {0x22b4, 0x0338, 0x22ec}, 
-       {0x22b5, 0x0338, 0x22ed}, {0x304b, 0x3099, 0x304c}, 
-       {0x304d, 0x3099, 0x304e}, {0x304f, 0x3099, 0x3050}, 
-       {0x3051, 0x3099, 0x3052}, {0x3053, 0x3099, 0x3054}, 
-       {0x3055, 0x3099, 0x3056}, {0x3057, 0x3099, 0x3058}, 
-       {0x3059, 0x3099, 0x305a}, {0x305b, 0x3099, 0x305c}, 
-       {0x305d, 0x3099, 0x305e}, {0x305f, 0x3099, 0x3060}, 
-       {0x3061, 0x3099, 0x3062}, {0x3064, 0x3099, 0x3065}, 
-       {0x3066, 0x3099, 0x3067}, {0x3068, 0x3099, 0x3069}, 
-       {0x306f, 0x3099, 0x3070}, {0x306f, 0x309a, 0x3071}, 
-       {0x3072, 0x3099, 0x3073}, {0x3072, 0x309a, 0x3074}, 
-       {0x3075, 0x3099, 0x3076}, {0x3075, 0x309a, 0x3077}, 
-       {0x3078, 0x3099, 0x3079}, {0x3078, 0x309a, 0x307a}, 
-       {0x307b, 0x3099, 0x307c}, {0x307b, 0x309a, 0x307d}, 
-       {0x3046, 0x3099, 0x3094}, {0x309d, 0x3099, 0x309e}, 
-       {0x30ab, 0x3099, 0x30ac}, {0x30ad, 0x3099, 0x30ae}, 
-       {0x30af, 0x3099, 0x30b0}, {0x30b1, 0x3099, 0x30b2}, 
-       {0x30b3, 0x3099, 0x30b4}, {0x30b5, 0x3099, 0x30b6}, 
-       {0x30b7, 0x3099, 0x30b8}, {0x30b9, 0x3099, 0x30ba}, 
-       {0x30bb, 0x3099, 0x30bc}, {0x30bd, 0x3099, 0x30be}, 
-       {0x30bf, 0x3099, 0x30c0}, {0x30c1, 0x3099, 0x30c2}, 
-       {0x30c4, 0x3099, 0x30c5}, {0x30c6, 0x3099, 0x30c7}, 
-       {0x30c8, 0x3099, 0x30c9}, {0x30cf, 0x3099, 0x30d0}, 
-       {0x30cf, 0x309a, 0x30d1}, {0x30d2, 0x3099, 0x30d3}, 
-       {0x30d2, 0x309a, 0x30d4}, {0x30d5, 0x3099, 0x30d6}, 
-       {0x30d5, 0x309a, 0x30d7}, {0x30d8, 0x3099, 0x30d9}, 
-       {0x30d8, 0x309a, 0x30da}, {0x30db, 0x3099, 0x30dc}, 
-       {0x30db, 0x309a, 0x30dd}, {0x30a6, 0x3099, 0x30f4}, 
-       {0x30ef, 0x3099, 0x30f7}, {0x30f0, 0x3099, 0x30f8}, 
-       {0x30f1, 0x3099, 0x30f9}, {0x30f2, 0x3099, 0x30fa}, 
-       {0x30fd, 0x3099, 0x30fe}, {0x05d9, 0x05b4, 0xfb1d}, 
+static struct composition {
+       unsigned long c2;       /* 2nd character */
+       unsigned long comp;     /* composed character */
+} 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 }, 
+       { 0x000005b4, 0x0000fb1d }, { 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 }, 
 };
 
 
@@ -598,2612 +1397,5410 @@ static struct composition compose_seq[] = {
  * Canonical/Compatibility Decomposition
  */
 
-#define DECOMPOSE_BM_SHIFT     (16 - 10)
+#define DECOMP_BITS_0  9
+#define DECOMP_BITS_1  7
+#define DECOMP_BITS_2  5
+#define DECOMP_COMPAT  32768
 
-static unsigned long canon_decompose_bitmap[] = {
-       0x090be1f8, 0x60aae3b0, 0x00000001, 0xff000000, 
-       0x00001fd1, 0x00000000, 0x0000000e, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x000031f0, 
+static unsigned short 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,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         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, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     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, 
+          97,    98,    99,   100,   101,   102,   103,     0, 
+         104,   105,   106,   107,   108,   109,   110,   111, 
+           0,   112,   113,   114,   115,     0,     0,     0, 
+         116,   117,   118,   119,   120,   121,   122,   123, 
+         124,   125,   126,   127,   128,   129,   130,   131, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+         132,   133,   134,   135,   136,   137,   138,   139, 
+         140,   141,     0,     0,     0,     0,     0,     0, 
+         142,   143,   144,   145,   146,   147,   148,   149, 
+         150,   151,   152,   153,   154,   155,   156,   157, 
+         158,   159,   160,   161,   162,   163,   164,   165, 
+           0,   166,   167,   168,   169,   170,   171,   172, 
+         173,   174,   175,   176,   177,   178,   179,   180, 
 };
 
-static struct decomposition canon_decompose_seq[] = {
-       {0x00c0,    0,  2}, {0x00c1,    2,  2}, {0x00c2,    4,  2}, 
-       {0x00c3,    6,  2}, {0x00c4,    8,  2}, {0x00c5,   10,  2}, 
-       {0x00c7,   12,  2}, {0x00c8,   14,  2}, {0x00c9,   16,  2}, 
-       {0x00ca,   18,  2}, {0x00cb,   20,  2}, {0x00cc,   22,  2}, 
-       {0x00cd,   24,  2}, {0x00ce,   26,  2}, {0x00cf,   28,  2}, 
-       {0x00d1,   30,  2}, {0x00d2,   32,  2}, {0x00d3,   34,  2}, 
-       {0x00d4,   36,  2}, {0x00d5,   38,  2}, {0x00d6,   40,  2}, 
-       {0x00d9,   42,  2}, {0x00da,   44,  2}, {0x00db,   46,  2}, 
-       {0x00dc,   48,  2}, {0x00dd,   50,  2}, {0x00e0,   52,  2}, 
-       {0x00e1,   54,  2}, {0x00e2,   56,  2}, {0x00e3,   58,  2}, 
-       {0x00e4,   60,  2}, {0x00e5,   62,  2}, {0x00e7,   64,  2}, 
-       {0x00e8,   66,  2}, {0x00e9,   68,  2}, {0x00ea,   70,  2}, 
-       {0x00eb,   72,  2}, {0x00ec,   74,  2}, {0x00ed,   76,  2}, 
-       {0x00ee,   78,  2}, {0x00ef,   80,  2}, {0x00f1,   82,  2}, 
-       {0x00f2,   84,  2}, {0x00f3,   86,  2}, {0x00f4,   88,  2}, 
-       {0x00f5,   90,  2}, {0x00f6,   92,  2}, {0x00f9,   94,  2}, 
-       {0x00fa,   96,  2}, {0x00fb,   98,  2}, {0x00fc,  100,  2}, 
-       {0x00fd,  102,  2}, {0x00ff,  104,  2}, {0x0100,  106,  2}, 
-       {0x0101,  108,  2}, {0x0102,  110,  2}, {0x0103,  112,  2}, 
-       {0x0104,  114,  2}, {0x0105,  116,  2}, {0x0106,  118,  2}, 
-       {0x0107,  120,  2}, {0x0108,  122,  2}, {0x0109,  124,  2}, 
-       {0x010a,  126,  2}, {0x010b,  128,  2}, {0x010c,  130,  2}, 
-       {0x010d,  132,  2}, {0x010e,  134,  2}, {0x010f,  136,  2}, 
-       {0x0112,  138,  2}, {0x0113,  140,  2}, {0x0114,  142,  2}, 
-       {0x0115,  144,  2}, {0x0116,  146,  2}, {0x0117,  148,  2}, 
-       {0x0118,  150,  2}, {0x0119,  152,  2}, {0x011a,  154,  2}, 
-       {0x011b,  156,  2}, {0x011c,  158,  2}, {0x011d,  160,  2}, 
-       {0x011e,  162,  2}, {0x011f,  164,  2}, {0x0120,  166,  2}, 
-       {0x0121,  168,  2}, {0x0122,  170,  2}, {0x0123,  172,  2}, 
-       {0x0124,  174,  2}, {0x0125,  176,  2}, {0x0128,  178,  2}, 
-       {0x0129,  180,  2}, {0x012a,  182,  2}, {0x012b,  184,  2}, 
-       {0x012c,  186,  2}, {0x012d,  188,  2}, {0x012e,  190,  2}, 
-       {0x012f,  192,  2}, {0x0130,  194,  2}, {0x0134,  196,  2}, 
-       {0x0135,  198,  2}, {0x0136,  200,  2}, {0x0137,  202,  2}, 
-       {0x0139,  204,  2}, {0x013a,  206,  2}, {0x013b,  208,  2}, 
-       {0x013c,  210,  2}, {0x013d,  212,  2}, {0x013e,  214,  2}, 
-       {0x0143,  216,  2}, {0x0144,  218,  2}, {0x0145,  220,  2}, 
-       {0x0146,  222,  2}, {0x0147,  224,  2}, {0x0148,  226,  2}, 
-       {0x014c,  228,  2}, {0x014d,  230,  2}, {0x014e,  232,  2}, 
-       {0x014f,  234,  2}, {0x0150,  236,  2}, {0x0151,  238,  2}, 
-       {0x0154,  240,  2}, {0x0155,  242,  2}, {0x0156,  244,  2}, 
-       {0x0157,  246,  2}, {0x0158,  248,  2}, {0x0159,  250,  2}, 
-       {0x015a,  252,  2}, {0x015b,  254,  2}, {0x015c,  256,  2}, 
-       {0x015d,  258,  2}, {0x015e,  260,  2}, {0x015f,  262,  2}, 
-       {0x0160,  264,  2}, {0x0161,  266,  2}, {0x0162,  268,  2}, 
-       {0x0163,  270,  2}, {0x0164,  272,  2}, {0x0165,  274,  2}, 
-       {0x0168,  276,  2}, {0x0169,  278,  2}, {0x016a,  280,  2}, 
-       {0x016b,  282,  2}, {0x016c,  284,  2}, {0x016d,  286,  2}, 
-       {0x016e,  288,  2}, {0x016f,  290,  2}, {0x0170,  292,  2}, 
-       {0x0171,  294,  2}, {0x0172,  296,  2}, {0x0173,  298,  2}, 
-       {0x0174,  300,  2}, {0x0175,  302,  2}, {0x0176,  304,  2}, 
-       {0x0177,  306,  2}, {0x0178,  308,  2}, {0x0179,  310,  2}, 
-       {0x017a,  312,  2}, {0x017b,  314,  2}, {0x017c,  316,  2}, 
-       {0x017d,  318,  2}, {0x017e,  320,  2}, {0x01a0,  322,  2}, 
-       {0x01a1,  324,  2}, {0x01af,  326,  2}, {0x01b0,  328,  2}, 
-       {0x01cd,  330,  2}, {0x01ce,  332,  2}, {0x01cf,  334,  2}, 
-       {0x01d0,  336,  2}, {0x01d1,  338,  2}, {0x01d2,  340,  2}, 
-       {0x01d3,  342,  2}, {0x01d4,  344,  2}, {0x01d5,  346,  2}, 
-       {0x01d6,  348,  2}, {0x01d7,  350,  2}, {0x01d8,  352,  2}, 
-       {0x01d9,  354,  2}, {0x01da,  356,  2}, {0x01db,  358,  2}, 
-       {0x01dc,  360,  2}, {0x01de,  362,  2}, {0x01df,  364,  2}, 
-       {0x01e0,  366,  2}, {0x01e1,  368,  2}, {0x01e2,  370,  2}, 
-       {0x01e3,  372,  2}, {0x01e6,  374,  2}, {0x01e7,  376,  2}, 
-       {0x01e8,  378,  2}, {0x01e9,  380,  2}, {0x01ea,  382,  2}, 
-       {0x01eb,  384,  2}, {0x01ec,  386,  2}, {0x01ed,  388,  2}, 
-       {0x01ee,  390,  2}, {0x01ef,  392,  2}, {0x01f0,  394,  2}, 
-       {0x01f4,  396,  2}, {0x01f5,  398,  2}, {0x01f8,  400,  2}, 
-       {0x01f9,  402,  2}, {0x01fa,  404,  2}, {0x01fb,  406,  2}, 
-       {0x01fc,  408,  2}, {0x01fd,  410,  2}, {0x01fe,  412,  2}, 
-       {0x01ff,  414,  2}, {0x0200,  416,  2}, {0x0201,  418,  2}, 
-       {0x0202,  420,  2}, {0x0203,  422,  2}, {0x0204,  424,  2}, 
-       {0x0205,  426,  2}, {0x0206,  428,  2}, {0x0207,  430,  2}, 
-       {0x0208,  432,  2}, {0x0209,  434,  2}, {0x020a,  436,  2}, 
-       {0x020b,  438,  2}, {0x020c,  440,  2}, {0x020d,  442,  2}, 
-       {0x020e,  444,  2}, {0x020f,  446,  2}, {0x0210,  448,  2}, 
-       {0x0211,  450,  2}, {0x0212,  452,  2}, {0x0213,  454,  2}, 
-       {0x0214,  456,  2}, {0x0215,  458,  2}, {0x0216,  460,  2}, 
-       {0x0217,  462,  2}, {0x0218,  464,  2}, {0x0219,  466,  2}, 
-       {0x021a,  468,  2}, {0x021b,  470,  2}, {0x021e,  472,  2}, 
-       {0x021f,  474,  2}, {0x0226,  476,  2}, {0x0227,  478,  2}, 
-       {0x0228,  480,  2}, {0x0229,  482,  2}, {0x022a,  484,  2}, 
-       {0x022b,  486,  2}, {0x022c,  488,  2}, {0x022d,  490,  2}, 
-       {0x022e,  492,  2}, {0x022f,  494,  2}, {0x0230,  496,  2}, 
-       {0x0231,  498,  2}, {0x0232,  500,  2}, {0x0233,  502,  2}, 
-       {0x0340,  504,  1}, {0x0341,  505,  1}, {0x0343,  506,  1}, 
-       {0x0344,  507,  2}, {0x0374,  509,  1}, {0x037e,  510,  1}, 
-       {0x0385,  511,  2}, {0x0386,  513,  2}, {0x0387,  515,  1}, 
-       {0x0388,  516,  2}, {0x0389,  518,  2}, {0x038a,  520,  2}, 
-       {0x038c,  522,  2}, {0x038e,  524,  2}, {0x038f,  526,  2}, 
-       {0x0390,  528,  2}, {0x03aa,  530,  2}, {0x03ab,  532,  2}, 
-       {0x03ac,  534,  2}, {0x03ad,  536,  2}, {0x03ae,  538,  2}, 
-       {0x03af,  540,  2}, {0x03b0,  542,  2}, {0x03ca,  544,  2}, 
-       {0x03cb,  546,  2}, {0x03cc,  548,  2}, {0x03cd,  550,  2}, 
-       {0x03ce,  552,  2}, {0x03d3,  554,  2}, {0x03d4,  556,  2}, 
-       {0x0400,  558,  2}, {0x0401,  560,  2}, {0x0403,  562,  2}, 
-       {0x0407,  564,  2}, {0x040c,  566,  2}, {0x040d,  568,  2}, 
-       {0x040e,  570,  2}, {0x0419,  572,  2}, {0x0439,  574,  2}, 
-       {0x0450,  576,  2}, {0x0451,  578,  2}, {0x0453,  580,  2}, 
-       {0x0457,  582,  2}, {0x045c,  584,  2}, {0x045d,  586,  2}, 
-       {0x045e,  588,  2}, {0x0476,  590,  2}, {0x0477,  592,  2}, 
-       {0x04c1,  594,  2}, {0x04c2,  596,  2}, {0x04d0,  598,  2}, 
-       {0x04d1,  600,  2}, {0x04d2,  602,  2}, {0x04d3,  604,  2}, 
-       {0x04d6,  606,  2}, {0x04d7,  608,  2}, {0x04da,  610,  2}, 
-       {0x04db,  612,  2}, {0x04dc,  614,  2}, {0x04dd,  616,  2}, 
-       {0x04de,  618,  2}, {0x04df,  620,  2}, {0x04e2,  622,  2}, 
-       {0x04e3,  624,  2}, {0x04e4,  626,  2}, {0x04e5,  628,  2}, 
-       {0x04e6,  630,  2}, {0x04e7,  632,  2}, {0x04ea,  634,  2}, 
-       {0x04eb,  636,  2}, {0x04ec,  638,  2}, {0x04ed,  640,  2}, 
-       {0x04ee,  642,  2}, {0x04ef,  644,  2}, {0x04f0,  646,  2}, 
-       {0x04f1,  648,  2}, {0x04f2,  650,  2}, {0x04f3,  652,  2}, 
-       {0x04f4,  654,  2}, {0x04f5,  656,  2}, {0x04f8,  658,  2}, 
-       {0x04f9,  660,  2}, {0x0622,  662,  2}, {0x0623,  664,  2}, 
-       {0x0624,  666,  2}, {0x0625,  668,  2}, {0x0626,  670,  2}, 
-       {0x06c0,  672,  2}, {0x06c2,  674,  2}, {0x06d3,  676,  2}, 
-       {0x0929,  678,  2}, {0x0931,  680,  2}, {0x0934,  682,  2}, 
-       {0x0958,  684,  2}, {0x0959,  686,  2}, {0x095a,  688,  2}, 
-       {0x095b,  690,  2}, {0x095c,  692,  2}, {0x095d,  694,  2}, 
-       {0x095e,  696,  2}, {0x095f,  698,  2}, {0x09cb,  700,  2}, 
-       {0x09cc,  702,  2}, {0x09dc,  704,  2}, {0x09dd,  706,  2}, 
-       {0x09df,  708,  2}, {0x0a33,  710,  2}, {0x0a36,  712,  2}, 
-       {0x0a59,  714,  2}, {0x0a5a,  716,  2}, {0x0a5b,  718,  2}, 
-       {0x0a5e,  720,  2}, {0x0b48,  722,  2}, {0x0b4b,  724,  2}, 
-       {0x0b4c,  726,  2}, {0x0b5c,  728,  2}, {0x0b5d,  730,  2}, 
-       {0x0b94,  732,  2}, {0x0bca,  734,  2}, {0x0bcb,  736,  2}, 
-       {0x0bcc,  738,  2}, {0x0c48,  740,  2}, {0x0cc0,  742,  2}, 
-       {0x0cc7,  744,  2}, {0x0cc8,  746,  2}, {0x0cca,  748,  2}, 
-       {0x0ccb,  750,  2}, {0x0d4a,  752,  2}, {0x0d4b,  754,  2}, 
-       {0x0d4c,  756,  2}, {0x0dda,  758,  2}, {0x0ddc,  760,  2}, 
-       {0x0ddd,  762,  2}, {0x0dde,  764,  2}, {0x0f43,  766,  2}, 
-       {0x0f4d,  768,  2}, {0x0f52,  770,  2}, {0x0f57,  772,  2}, 
-       {0x0f5c,  774,  2}, {0x0f69,  776,  2}, {0x0f73,  778,  2}, 
-       {0x0f75,  780,  2}, {0x0f76,  782,  2}, {0x0f78,  784,  2}, 
-       {0x0f81,  786,  2}, {0x0f93,  788,  2}, {0x0f9d,  790,  2}, 
-       {0x0fa2,  792,  2}, {0x0fa7,  794,  2}, {0x0fac,  796,  2}, 
-       {0x0fb9,  798,  2}, {0x1026,  800,  2}, {0x1e00,  802,  2}, 
-       {0x1e01,  804,  2}, {0x1e02,  806,  2}, {0x1e03,  808,  2}, 
-       {0x1e04,  810,  2}, {0x1e05,  812,  2}, {0x1e06,  814,  2}, 
-       {0x1e07,  816,  2}, {0x1e08,  818,  2}, {0x1e09,  820,  2}, 
-       {0x1e0a,  822,  2}, {0x1e0b,  824,  2}, {0x1e0c,  826,  2}, 
-       {0x1e0d,  828,  2}, {0x1e0e,  830,  2}, {0x1e0f,  832,  2}, 
-       {0x1e10,  834,  2}, {0x1e11,  836,  2}, {0x1e12,  838,  2}, 
-       {0x1e13,  840,  2}, {0x1e14,  842,  2}, {0x1e15,  844,  2}, 
-       {0x1e16,  846,  2}, {0x1e17,  848,  2}, {0x1e18,  850,  2}, 
-       {0x1e19,  852,  2}, {0x1e1a,  854,  2}, {0x1e1b,  856,  2}, 
-       {0x1e1c,  858,  2}, {0x1e1d,  860,  2}, {0x1e1e,  862,  2}, 
-       {0x1e1f,  864,  2}, {0x1e20,  866,  2}, {0x1e21,  868,  2}, 
-       {0x1e22,  870,  2}, {0x1e23,  872,  2}, {0x1e24,  874,  2}, 
-       {0x1e25,  876,  2}, {0x1e26,  878,  2}, {0x1e27,  880,  2}, 
-       {0x1e28,  882,  2}, {0x1e29,  884,  2}, {0x1e2a,  886,  2}, 
-       {0x1e2b,  888,  2}, {0x1e2c,  890,  2}, {0x1e2d,  892,  2}, 
-       {0x1e2e,  894,  2}, {0x1e2f,  896,  2}, {0x1e30,  898,  2}, 
-       {0x1e31,  900,  2}, {0x1e32,  902,  2}, {0x1e33,  904,  2}, 
-       {0x1e34,  906,  2}, {0x1e35,  908,  2}, {0x1e36,  910,  2}, 
-       {0x1e37,  912,  2}, {0x1e38,  914,  2}, {0x1e39,  916,  2}, 
-       {0x1e3a,  918,  2}, {0x1e3b,  920,  2}, {0x1e3c,  922,  2}, 
-       {0x1e3d,  924,  2}, {0x1e3e,  926,  2}, {0x1e3f,  928,  2}, 
-       {0x1e40,  930,  2}, {0x1e41,  932,  2}, {0x1e42,  934,  2}, 
-       {0x1e43,  936,  2}, {0x1e44,  938,  2}, {0x1e45,  940,  2}, 
-       {0x1e46,  942,  2}, {0x1e47,  944,  2}, {0x1e48,  946,  2}, 
-       {0x1e49,  948,  2}, {0x1e4a,  950,  2}, {0x1e4b,  952,  2}, 
-       {0x1e4c,  954,  2}, {0x1e4d,  956,  2}, {0x1e4e,  958,  2}, 
-       {0x1e4f,  960,  2}, {0x1e50,  962,  2}, {0x1e51,  964,  2}, 
-       {0x1e52,  966,  2}, {0x1e53,  968,  2}, {0x1e54,  970,  2}, 
-       {0x1e55,  972,  2}, {0x1e56,  974,  2}, {0x1e57,  976,  2}, 
-       {0x1e58,  978,  2}, {0x1e59,  980,  2}, {0x1e5a,  982,  2}, 
-       {0x1e5b,  984,  2}, {0x1e5c,  986,  2}, {0x1e5d,  988,  2}, 
-       {0x1e5e,  990,  2}, {0x1e5f,  992,  2}, {0x1e60,  994,  2}, 
-       {0x1e61,  996,  2}, {0x1e62,  998,  2}, {0x1e63, 1000,  2}, 
-       {0x1e64, 1002,  2}, {0x1e65, 1004,  2}, {0x1e66, 1006,  2}, 
-       {0x1e67, 1008,  2}, {0x1e68, 1010,  2}, {0x1e69, 1012,  2}, 
-       {0x1e6a, 1014,  2}, {0x1e6b, 1016,  2}, {0x1e6c, 1018,  2}, 
-       {0x1e6d, 1020,  2}, {0x1e6e, 1022,  2}, {0x1e6f, 1024,  2}, 
-       {0x1e70, 1026,  2}, {0x1e71, 1028,  2}, {0x1e72, 1030,  2}, 
-       {0x1e73, 1032,  2}, {0x1e74, 1034,  2}, {0x1e75, 1036,  2}, 
-       {0x1e76, 1038,  2}, {0x1e77, 1040,  2}, {0x1e78, 1042,  2}, 
-       {0x1e79, 1044,  2}, {0x1e7a, 1046,  2}, {0x1e7b, 1048,  2}, 
-       {0x1e7c, 1050,  2}, {0x1e7d, 1052,  2}, {0x1e7e, 1054,  2}, 
-       {0x1e7f, 1056,  2}, {0x1e80, 1058,  2}, {0x1e81, 1060,  2}, 
-       {0x1e82, 1062,  2}, {0x1e83, 1064,  2}, {0x1e84, 1066,  2}, 
-       {0x1e85, 1068,  2}, {0x1e86, 1070,  2}, {0x1e87, 1072,  2}, 
-       {0x1e88, 1074,  2}, {0x1e89, 1076,  2}, {0x1e8a, 1078,  2}, 
-       {0x1e8b, 1080,  2}, {0x1e8c, 1082,  2}, {0x1e8d, 1084,  2}, 
-       {0x1e8e, 1086,  2}, {0x1e8f, 1088,  2}, {0x1e90, 1090,  2}, 
-       {0x1e91, 1092,  2}, {0x1e92, 1094,  2}, {0x1e93, 1096,  2}, 
-       {0x1e94, 1098,  2}, {0x1e95, 1100,  2}, {0x1e96, 1102,  2}, 
-       {0x1e97, 1104,  2}, {0x1e98, 1106,  2}, {0x1e99, 1108,  2}, 
-       {0x1e9b, 1110,  2}, {0x1ea0, 1112,  2}, {0x1ea1, 1114,  2}, 
-       {0x1ea2, 1116,  2}, {0x1ea3, 1118,  2}, {0x1ea4, 1120,  2}, 
-       {0x1ea5, 1122,  2}, {0x1ea6, 1124,  2}, {0x1ea7, 1126,  2}, 
-       {0x1ea8, 1128,  2}, {0x1ea9, 1130,  2}, {0x1eaa, 1132,  2}, 
-       {0x1eab, 1134,  2}, {0x1eac, 1136,  2}, {0x1ead, 1138,  2}, 
-       {0x1eae, 1140,  2}, {0x1eaf, 1142,  2}, {0x1eb0, 1144,  2}, 
-       {0x1eb1, 1146,  2}, {0x1eb2, 1148,  2}, {0x1eb3, 1150,  2}, 
-       {0x1eb4, 1152,  2}, {0x1eb5, 1154,  2}, {0x1eb6, 1156,  2}, 
-       {0x1eb7, 1158,  2}, {0x1eb8, 1160,  2}, {0x1eb9, 1162,  2}, 
-       {0x1eba, 1164,  2}, {0x1ebb, 1166,  2}, {0x1ebc, 1168,  2}, 
-       {0x1ebd, 1170,  2}, {0x1ebe, 1172,  2}, {0x1ebf, 1174,  2}, 
-       {0x1ec0, 1176,  2}, {0x1ec1, 1178,  2}, {0x1ec2, 1180,  2}, 
-       {0x1ec3, 1182,  2}, {0x1ec4, 1184,  2}, {0x1ec5, 1186,  2}, 
-       {0x1ec6, 1188,  2}, {0x1ec7, 1190,  2}, {0x1ec8, 1192,  2}, 
-       {0x1ec9, 1194,  2}, {0x1eca, 1196,  2}, {0x1ecb, 1198,  2}, 
-       {0x1ecc, 1200,  2}, {0x1ecd, 1202,  2}, {0x1ece, 1204,  2}, 
-       {0x1ecf, 1206,  2}, {0x1ed0, 1208,  2}, {0x1ed1, 1210,  2}, 
-       {0x1ed2, 1212,  2}, {0x1ed3, 1214,  2}, {0x1ed4, 1216,  2}, 
-       {0x1ed5, 1218,  2}, {0x1ed6, 1220,  2}, {0x1ed7, 1222,  2}, 
-       {0x1ed8, 1224,  2}, {0x1ed9, 1226,  2}, {0x1eda, 1228,  2}, 
-       {0x1edb, 1230,  2}, {0x1edc, 1232,  2}, {0x1edd, 1234,  2}, 
-       {0x1ede, 1236,  2}, {0x1edf, 1238,  2}, {0x1ee0, 1240,  2}, 
-       {0x1ee1, 1242,  2}, {0x1ee2, 1244,  2}, {0x1ee3, 1246,  2}, 
-       {0x1ee4, 1248,  2}, {0x1ee5, 1250,  2}, {0x1ee6, 1252,  2}, 
-       {0x1ee7, 1254,  2}, {0x1ee8, 1256,  2}, {0x1ee9, 1258,  2}, 
-       {0x1eea, 1260,  2}, {0x1eeb, 1262,  2}, {0x1eec, 1264,  2}, 
-       {0x1eed, 1266,  2}, {0x1eee, 1268,  2}, {0x1eef, 1270,  2}, 
-       {0x1ef0, 1272,  2}, {0x1ef1, 1274,  2}, {0x1ef2, 1276,  2}, 
-       {0x1ef3, 1278,  2}, {0x1ef4, 1280,  2}, {0x1ef5, 1282,  2}, 
-       {0x1ef6, 1284,  2}, {0x1ef7, 1286,  2}, {0x1ef8, 1288,  2}, 
-       {0x1ef9, 1290,  2}, {0x1f00, 1292,  2}, {0x1f01, 1294,  2}, 
-       {0x1f02, 1296,  2}, {0x1f03, 1298,  2}, {0x1f04, 1300,  2}, 
-       {0x1f05, 1302,  2}, {0x1f06, 1304,  2}, {0x1f07, 1306,  2}, 
-       {0x1f08, 1308,  2}, {0x1f09, 1310,  2}, {0x1f0a, 1312,  2}, 
-       {0x1f0b, 1314,  2}, {0x1f0c, 1316,  2}, {0x1f0d, 1318,  2}, 
-       {0x1f0e, 1320,  2}, {0x1f0f, 1322,  2}, {0x1f10, 1324,  2}, 
-       {0x1f11, 1326,  2}, {0x1f12, 1328,  2}, {0x1f13, 1330,  2}, 
-       {0x1f14, 1332,  2}, {0x1f15, 1334,  2}, {0x1f18, 1336,  2}, 
-       {0x1f19, 1338,  2}, {0x1f1a, 1340,  2}, {0x1f1b, 1342,  2}, 
-       {0x1f1c, 1344,  2}, {0x1f1d, 1346,  2}, {0x1f20, 1348,  2}, 
-       {0x1f21, 1350,  2}, {0x1f22, 1352,  2}, {0x1f23, 1354,  2}, 
-       {0x1f24, 1356,  2}, {0x1f25, 1358,  2}, {0x1f26, 1360,  2}, 
-       {0x1f27, 1362,  2}, {0x1f28, 1364,  2}, {0x1f29, 1366,  2}, 
-       {0x1f2a, 1368,  2}, {0x1f2b, 1370,  2}, {0x1f2c, 1372,  2}, 
-       {0x1f2d, 1374,  2}, {0x1f2e, 1376,  2}, {0x1f2f, 1378,  2}, 
-       {0x1f30, 1380,  2}, {0x1f31, 1382,  2}, {0x1f32, 1384,  2}, 
-       {0x1f33, 1386,  2}, {0x1f34, 1388,  2}, {0x1f35, 1390,  2}, 
-       {0x1f36, 1392,  2}, {0x1f37, 1394,  2}, {0x1f38, 1396,  2}, 
-       {0x1f39, 1398,  2}, {0x1f3a, 1400,  2}, {0x1f3b, 1402,  2}, 
-       {0x1f3c, 1404,  2}, {0x1f3d, 1406,  2}, {0x1f3e, 1408,  2}, 
-       {0x1f3f, 1410,  2}, {0x1f40, 1412,  2}, {0x1f41, 1414,  2}, 
-       {0x1f42, 1416,  2}, {0x1f43, 1418,  2}, {0x1f44, 1420,  2}, 
-       {0x1f45, 1422,  2}, {0x1f48, 1424,  2}, {0x1f49, 1426,  2}, 
-       {0x1f4a, 1428,  2}, {0x1f4b, 1430,  2}, {0x1f4c, 1432,  2}, 
-       {0x1f4d, 1434,  2}, {0x1f50, 1436,  2}, {0x1f51, 1438,  2}, 
-       {0x1f52, 1440,  2}, {0x1f53, 1442,  2}, {0x1f54, 1444,  2}, 
-       {0x1f55, 1446,  2}, {0x1f56, 1448,  2}, {0x1f57, 1450,  2}, 
-       {0x1f59, 1452,  2}, {0x1f5b, 1454,  2}, {0x1f5d, 1456,  2}, 
-       {0x1f5f, 1458,  2}, {0x1f60, 1460,  2}, {0x1f61, 1462,  2}, 
-       {0x1f62, 1464,  2}, {0x1f63, 1466,  2}, {0x1f64, 1468,  2}, 
-       {0x1f65, 1470,  2}, {0x1f66, 1472,  2}, {0x1f67, 1474,  2}, 
-       {0x1f68, 1476,  2}, {0x1f69, 1478,  2}, {0x1f6a, 1480,  2}, 
-       {0x1f6b, 1482,  2}, {0x1f6c, 1484,  2}, {0x1f6d, 1486,  2}, 
-       {0x1f6e, 1488,  2}, {0x1f6f, 1490,  2}, {0x1f70, 1492,  2}, 
-       {0x1f71, 1494,  1}, {0x1f72, 1495,  2}, {0x1f73, 1497,  1}, 
-       {0x1f74, 1498,  2}, {0x1f75, 1500,  1}, {0x1f76, 1501,  2}, 
-       {0x1f77, 1503,  1}, {0x1f78, 1504,  2}, {0x1f79, 1506,  1}, 
-       {0x1f7a, 1507,  2}, {0x1f7b, 1509,  1}, {0x1f7c, 1510,  2}, 
-       {0x1f7d, 1512,  1}, {0x1f80, 1513,  2}, {0x1f81, 1515,  2}, 
-       {0x1f82, 1517,  2}, {0x1f83, 1519,  2}, {0x1f84, 1521,  2}, 
-       {0x1f85, 1523,  2}, {0x1f86, 1525,  2}, {0x1f87, 1527,  2}, 
-       {0x1f88, 1529,  2}, {0x1f89, 1531,  2}, {0x1f8a, 1533,  2}, 
-       {0x1f8b, 1535,  2}, {0x1f8c, 1537,  2}, {0x1f8d, 1539,  2}, 
-       {0x1f8e, 1541,  2}, {0x1f8f, 1543,  2}, {0x1f90, 1545,  2}, 
-       {0x1f91, 1547,  2}, {0x1f92, 1549,  2}, {0x1f93, 1551,  2}, 
-       {0x1f94, 1553,  2}, {0x1f95, 1555,  2}, {0x1f96, 1557,  2}, 
-       {0x1f97, 1559,  2}, {0x1f98, 1561,  2}, {0x1f99, 1563,  2}, 
-       {0x1f9a, 1565,  2}, {0x1f9b, 1567,  2}, {0x1f9c, 1569,  2}, 
-       {0x1f9d, 1571,  2}, {0x1f9e, 1573,  2}, {0x1f9f, 1575,  2}, 
-       {0x1fa0, 1577,  2}, {0x1fa1, 1579,  2}, {0x1fa2, 1581,  2}, 
-       {0x1fa3, 1583,  2}, {0x1fa4, 1585,  2}, {0x1fa5, 1587,  2}, 
-       {0x1fa6, 1589,  2}, {0x1fa7, 1591,  2}, {0x1fa8, 1593,  2}, 
-       {0x1fa9, 1595,  2}, {0x1faa, 1597,  2}, {0x1fab, 1599,  2}, 
-       {0x1fac, 1601,  2}, {0x1fad, 1603,  2}, {0x1fae, 1605,  2}, 
-       {0x1faf, 1607,  2}, {0x1fb0, 1609,  2}, {0x1fb1, 1611,  2}, 
-       {0x1fb2, 1613,  2}, {0x1fb3, 1615,  2}, {0x1fb4, 1617,  2}, 
-       {0x1fb6, 1619,  2}, {0x1fb7, 1621,  2}, {0x1fb8, 1623,  2}, 
-       {0x1fb9, 1625,  2}, {0x1fba, 1627,  2}, {0x1fbb, 1629,  1}, 
-       {0x1fbc, 1630,  2}, {0x1fbe, 1632,  1}, {0x1fc1, 1633,  2}, 
-       {0x1fc2, 1635,  2}, {0x1fc3, 1637,  2}, {0x1fc4, 1639,  2}, 
-       {0x1fc6, 1641,  2}, {0x1fc7, 1643,  2}, {0x1fc8, 1645,  2}, 
-       {0x1fc9, 1647,  1}, {0x1fca, 1648,  2}, {0x1fcb, 1650,  1}, 
-       {0x1fcc, 1651,  2}, {0x1fcd, 1653,  2}, {0x1fce, 1655,  2}, 
-       {0x1fcf, 1657,  2}, {0x1fd0, 1659,  2}, {0x1fd1, 1661,  2}, 
-       {0x1fd2, 1663,  2}, {0x1fd3, 1665,  1}, {0x1fd6, 1666,  2}, 
-       {0x1fd7, 1668,  2}, {0x1fd8, 1670,  2}, {0x1fd9, 1672,  2}, 
-       {0x1fda, 1674,  2}, {0x1fdb, 1676,  1}, {0x1fdd, 1677,  2}, 
-       {0x1fde, 1679,  2}, {0x1fdf, 1681,  2}, {0x1fe0, 1683,  2}, 
-       {0x1fe1, 1685,  2}, {0x1fe2, 1687,  2}, {0x1fe3, 1689,  1}, 
-       {0x1fe4, 1690,  2}, {0x1fe5, 1692,  2}, {0x1fe6, 1694,  2}, 
-       {0x1fe7, 1696,  2}, {0x1fe8, 1698,  2}, {0x1fe9, 1700,  2}, 
-       {0x1fea, 1702,  2}, {0x1feb, 1704,  1}, {0x1fec, 1705,  2}, 
-       {0x1fed, 1707,  2}, {0x1fee, 1709,  1}, {0x1fef, 1710,  1}, 
-       {0x1ff2, 1711,  2}, {0x1ff3, 1713,  2}, {0x1ff4, 1715,  2}, 
-       {0x1ff6, 1717,  2}, {0x1ff7, 1719,  2}, {0x1ff8, 1721,  2}, 
-       {0x1ff9, 1723,  1}, {0x1ffa, 1724,  2}, {0x1ffb, 1726,  1}, 
-       {0x1ffc, 1727,  2}, {0x1ffd, 1729,  1}, {0x2000, 1730,  1}, 
-       {0x2001, 1731,  1}, {0x2126, 1732,  1}, {0x212a, 1733,  1}, 
-       {0x212b, 1734,  1}, {0x219a, 1735,  2}, {0x219b, 1737,  2}, 
-       {0x21ae, 1739,  2}, {0x21cd, 1741,  2}, {0x21ce, 1743,  2}, 
-       {0x21cf, 1745,  2}, {0x2204, 1747,  2}, {0x2209, 1749,  2}, 
-       {0x220c, 1751,  2}, {0x2224, 1753,  2}, {0x2226, 1755,  2}, 
-       {0x2241, 1757,  2}, {0x2244, 1759,  2}, {0x2247, 1761,  2}, 
-       {0x2249, 1763,  2}, {0x2260, 1765,  2}, {0x2262, 1767,  2}, 
-       {0x226d, 1769,  2}, {0x226e, 1771,  2}, {0x226f, 1773,  2}, 
-       {0x2270, 1775,  2}, {0x2271, 1777,  2}, {0x2274, 1779,  2}, 
-       {0x2275, 1781,  2}, {0x2278, 1783,  2}, {0x2279, 1785,  2}, 
-       {0x2280, 1787,  2}, {0x2281, 1789,  2}, {0x2284, 1791,  2}, 
-       {0x2285, 1793,  2}, {0x2288, 1795,  2}, {0x2289, 1797,  2}, 
-       {0x22ac, 1799,  2}, {0x22ad, 1801,  2}, {0x22ae, 1803,  2}, 
-       {0x22af, 1805,  2}, {0x22e0, 1807,  2}, {0x22e1, 1809,  2}, 
-       {0x22e2, 1811,  2}, {0x22e3, 1813,  2}, {0x22ea, 1815,  2}, 
-       {0x22eb, 1817,  2}, {0x22ec, 1819,  2}, {0x22ed, 1821,  2}, 
-       {0x2329, 1823,  1}, {0x232a, 1824,  1}, {0x304c, 1825,  2}, 
-       {0x304e, 1827,  2}, {0x3050, 1829,  2}, {0x3052, 1831,  2}, 
-       {0x3054, 1833,  2}, {0x3056, 1835,  2}, {0x3058, 1837,  2}, 
-       {0x305a, 1839,  2}, {0x305c, 1841,  2}, {0x305e, 1843,  2}, 
-       {0x3060, 1845,  2}, {0x3062, 1847,  2}, {0x3065, 1849,  2}, 
-       {0x3067, 1851,  2}, {0x3069, 1853,  2}, {0x3070, 1855,  2}, 
-       {0x3071, 1857,  2}, {0x3073, 1859,  2}, {0x3074, 1861,  2}, 
-       {0x3076, 1863,  2}, {0x3077, 1865,  2}, {0x3079, 1867,  2}, 
-       {0x307a, 1869,  2}, {0x307c, 1871,  2}, {0x307d, 1873,  2}, 
-       {0x3094, 1875,  2}, {0x309e, 1877,  2}, {0x30ac, 1879,  2}, 
-       {0x30ae, 1881,  2}, {0x30b0, 1883,  2}, {0x30b2, 1885,  2}, 
-       {0x30b4, 1887,  2}, {0x30b6, 1889,  2}, {0x30b8, 1891,  2}, 
-       {0x30ba, 1893,  2}, {0x30bc, 1895,  2}, {0x30be, 1897,  2}, 
-       {0x30c0, 1899,  2}, {0x30c2, 1901,  2}, {0x30c5, 1903,  2}, 
-       {0x30c7, 1905,  2}, {0x30c9, 1907,  2}, {0x30d0, 1909,  2}, 
-       {0x30d1, 1911,  2}, {0x30d3, 1913,  2}, {0x30d4, 1915,  2}, 
-       {0x30d6, 1917,  2}, {0x30d7, 1919,  2}, {0x30d9, 1921,  2}, 
-       {0x30da, 1923,  2}, {0x30dc, 1925,  2}, {0x30dd, 1927,  2}, 
-       {0x30f4, 1929,  2}, {0x30f7, 1931,  2}, {0x30f8, 1933,  2}, 
-       {0x30f9, 1935,  2}, {0x30fa, 1937,  2}, {0x30fe, 1939,  2}, 
-       {0xf900, 1941,  1}, {0xf901, 1942,  1}, {0xf902, 1943,  1}, 
-       {0xf903, 1944,  1}, {0xf904, 1945,  1}, {0xf905, 1946,  1}, 
-       {0xf906, 1947,  1}, {0xf907, 1948,  1}, {0xf908, 1949,  1}, 
-       {0xf909, 1950,  1}, {0xf90a, 1951,  1}, {0xf90b, 1952,  1}, 
-       {0xf90c, 1953,  1}, {0xf90d, 1954,  1}, {0xf90e, 1955,  1}, 
-       {0xf90f, 1956,  1}, {0xf910, 1957,  1}, {0xf911, 1958,  1}, 
-       {0xf912, 1959,  1}, {0xf913, 1960,  1}, {0xf914, 1961,  1}, 
-       {0xf915, 1962,  1}, {0xf916, 1963,  1}, {0xf917, 1964,  1}, 
-       {0xf918, 1965,  1}, {0xf919, 1966,  1}, {0xf91a, 1967,  1}, 
-       {0xf91b, 1968,  1}, {0xf91c, 1969,  1}, {0xf91d, 1970,  1}, 
-       {0xf91e, 1971,  1}, {0xf91f, 1972,  1}, {0xf920, 1973,  1}, 
-       {0xf921, 1974,  1}, {0xf922, 1975,  1}, {0xf923, 1976,  1}, 
-       {0xf924, 1977,  1}, {0xf925, 1978,  1}, {0xf926, 1979,  1}, 
-       {0xf927, 1980,  1}, {0xf928, 1981,  1}, {0xf929, 1982,  1}, 
-       {0xf92a, 1983,  1}, {0xf92b, 1984,  1}, {0xf92c, 1985,  1}, 
-       {0xf92d, 1986,  1}, {0xf92e, 1987,  1}, {0xf92f, 1988,  1}, 
-       {0xf930, 1989,  1}, {0xf931, 1990,  1}, {0xf932, 1991,  1}, 
-       {0xf933, 1992,  1}, {0xf934, 1993,  1}, {0xf935, 1994,  1}, 
-       {0xf936, 1995,  1}, {0xf937, 1996,  1}, {0xf938, 1997,  1}, 
-       {0xf939, 1998,  1}, {0xf93a, 1999,  1}, {0xf93b, 2000,  1}, 
-       {0xf93c, 2001,  1}, {0xf93d, 2002,  1}, {0xf93e, 2003,  1}, 
-       {0xf93f, 2004,  1}, {0xf940, 2005,  1}, {0xf941, 2006,  1}, 
-       {0xf942, 2007,  1}, {0xf943, 2008,  1}, {0xf944, 2009,  1}, 
-       {0xf945, 2010,  1}, {0xf946, 2011,  1}, {0xf947, 2012,  1}, 
-       {0xf948, 2013,  1}, {0xf949, 2014,  1}, {0xf94a, 2015,  1}, 
-       {0xf94b, 2016,  1}, {0xf94c, 2017,  1}, {0xf94d, 2018,  1}, 
-       {0xf94e, 2019,  1}, {0xf94f, 2020,  1}, {0xf950, 2021,  1}, 
-       {0xf951, 2022,  1}, {0xf952, 2023,  1}, {0xf953, 2024,  1}, 
-       {0xf954, 2025,  1}, {0xf955, 2026,  1}, {0xf956, 2027,  1}, 
-       {0xf957, 2028,  1}, {0xf958, 2029,  1}, {0xf959, 2030,  1}, 
-       {0xf95a, 2031,  1}, {0xf95b, 2032,  1}, {0xf95c, 2033,  1}, 
-       {0xf95d, 2034,  1}, {0xf95e, 2035,  1}, {0xf95f, 2036,  1}, 
-       {0xf960, 2037,  1}, {0xf961, 2038,  1}, {0xf962, 2039,  1}, 
-       {0xf963, 2040,  1}, {0xf964, 2041,  1}, {0xf965, 2042,  1}, 
-       {0xf966, 2043,  1}, {0xf967, 2044,  1}, {0xf968, 2045,  1}, 
-       {0xf969, 2046,  1}, {0xf96a, 2047,  1}, {0xf96b, 2048,  1}, 
-       {0xf96c, 2049,  1}, {0xf96d, 2050,  1}, {0xf96e, 2051,  1}, 
-       {0xf96f, 2052,  1}, {0xf970, 2053,  1}, {0xf971, 2054,  1}, 
-       {0xf972, 2055,  1}, {0xf973, 2056,  1}, {0xf974, 2057,  1}, 
-       {0xf975, 2058,  1}, {0xf976, 2059,  1}, {0xf977, 2060,  1}, 
-       {0xf978, 2061,  1}, {0xf979, 2062,  1}, {0xf97a, 2063,  1}, 
-       {0xf97b, 2064,  1}, {0xf97c, 2065,  1}, {0xf97d, 2066,  1}, 
-       {0xf97e, 2067,  1}, {0xf97f, 2068,  1}, {0xf980, 2069,  1}, 
-       {0xf981, 2070,  1}, {0xf982, 2071,  1}, {0xf983, 2072,  1}, 
-       {0xf984, 2073,  1}, {0xf985, 2074,  1}, {0xf986, 2075,  1}, 
-       {0xf987, 2076,  1}, {0xf988, 2077,  1}, {0xf989, 2078,  1}, 
-       {0xf98a, 2079,  1}, {0xf98b, 2080,  1}, {0xf98c, 2081,  1}, 
-       {0xf98d, 2082,  1}, {0xf98e, 2083,  1}, {0xf98f, 2084,  1}, 
-       {0xf990, 2085,  1}, {0xf991, 2086,  1}, {0xf992, 2087,  1}, 
-       {0xf993, 2088,  1}, {0xf994, 2089,  1}, {0xf995, 2090,  1}, 
-       {0xf996, 2091,  1}, {0xf997, 2092,  1}, {0xf998, 2093,  1}, 
-       {0xf999, 2094,  1}, {0xf99a, 2095,  1}, {0xf99b, 2096,  1}, 
-       {0xf99c, 2097,  1}, {0xf99d, 2098,  1}, {0xf99e, 2099,  1}, 
-       {0xf99f, 2100,  1}, {0xf9a0, 2101,  1}, {0xf9a1, 2102,  1}, 
-       {0xf9a2, 2103,  1}, {0xf9a3, 2104,  1}, {0xf9a4, 2105,  1}, 
-       {0xf9a5, 2106,  1}, {0xf9a6, 2107,  1}, {0xf9a7, 2108,  1}, 
-       {0xf9a8, 2109,  1}, {0xf9a9, 2110,  1}, {0xf9aa, 2111,  1}, 
-       {0xf9ab, 2112,  1}, {0xf9ac, 2113,  1}, {0xf9ad, 2114,  1}, 
-       {0xf9ae, 2115,  1}, {0xf9af, 2116,  1}, {0xf9b0, 2117,  1}, 
-       {0xf9b1, 2118,  1}, {0xf9b2, 2119,  1}, {0xf9b3, 2120,  1}, 
-       {0xf9b4, 2121,  1}, {0xf9b5, 2122,  1}, {0xf9b6, 2123,  1}, 
-       {0xf9b7, 2124,  1}, {0xf9b8, 2125,  1}, {0xf9b9, 2126,  1}, 
-       {0xf9ba, 2127,  1}, {0xf9bb, 2128,  1}, {0xf9bc, 2129,  1}, 
-       {0xf9bd, 2130,  1}, {0xf9be, 2131,  1}, {0xf9bf, 2132,  1}, 
-       {0xf9c0, 2133,  1}, {0xf9c1, 2134,  1}, {0xf9c2, 2135,  1}, 
-       {0xf9c3, 2136,  1}, {0xf9c4, 2137,  1}, {0xf9c5, 2138,  1}, 
-       {0xf9c6, 2139,  1}, {0xf9c7, 2140,  1}, {0xf9c8, 2141,  1}, 
-       {0xf9c9, 2142,  1}, {0xf9ca, 2143,  1}, {0xf9cb, 2144,  1}, 
-       {0xf9cc, 2145,  1}, {0xf9cd, 2146,  1}, {0xf9ce, 2147,  1}, 
-       {0xf9cf, 2148,  1}, {0xf9d0, 2149,  1}, {0xf9d1, 2150,  1}, 
-       {0xf9d2, 2151,  1}, {0xf9d3, 2152,  1}, {0xf9d4, 2153,  1}, 
-       {0xf9d5, 2154,  1}, {0xf9d6, 2155,  1}, {0xf9d7, 2156,  1}, 
-       {0xf9d8, 2157,  1}, {0xf9d9, 2158,  1}, {0xf9da, 2159,  1}, 
-       {0xf9db, 2160,  1}, {0xf9dc, 2161,  1}, {0xf9dd, 2162,  1}, 
-       {0xf9de, 2163,  1}, {0xf9df, 2164,  1}, {0xf9e0, 2165,  1}, 
-       {0xf9e1, 2166,  1}, {0xf9e2, 2167,  1}, {0xf9e3, 2168,  1}, 
-       {0xf9e4, 2169,  1}, {0xf9e5, 2170,  1}, {0xf9e6, 2171,  1}, 
-       {0xf9e7, 2172,  1}, {0xf9e8, 2173,  1}, {0xf9e9, 2174,  1}, 
-       {0xf9ea, 2175,  1}, {0xf9eb, 2176,  1}, {0xf9ec, 2177,  1}, 
-       {0xf9ed, 2178,  1}, {0xf9ee, 2179,  1}, {0xf9ef, 2180,  1}, 
-       {0xf9f0, 2181,  1}, {0xf9f1, 2182,  1}, {0xf9f2, 2183,  1}, 
-       {0xf9f3, 2184,  1}, {0xf9f4, 2185,  1}, {0xf9f5, 2186,  1}, 
-       {0xf9f6, 2187,  1}, {0xf9f7, 2188,  1}, {0xf9f8, 2189,  1}, 
-       {0xf9f9, 2190,  1}, {0xf9fa, 2191,  1}, {0xf9fb, 2192,  1}, 
-       {0xf9fc, 2193,  1}, {0xf9fd, 2194,  1}, {0xf9fe, 2195,  1}, 
-       {0xf9ff, 2196,  1}, {0xfa00, 2197,  1}, {0xfa01, 2198,  1}, 
-       {0xfa02, 2199,  1}, {0xfa03, 2200,  1}, {0xfa04, 2201,  1}, 
-       {0xfa05, 2202,  1}, {0xfa06, 2203,  1}, {0xfa07, 2204,  1}, 
-       {0xfa08, 2205,  1}, {0xfa09, 2206,  1}, {0xfa0a, 2207,  1}, 
-       {0xfa0b, 2208,  1}, {0xfa0c, 2209,  1}, {0xfa0d, 2210,  1}, 
-       {0xfa10, 2211,  1}, {0xfa12, 2212,  1}, {0xfa15, 2213,  1}, 
-       {0xfa16, 2214,  1}, {0xfa17, 2215,  1}, {0xfa18, 2216,  1}, 
-       {0xfa19, 2217,  1}, {0xfa1a, 2218,  1}, {0xfa1b, 2219,  1}, 
-       {0xfa1c, 2220,  1}, {0xfa1d, 2221,  1}, {0xfa1e, 2222,  1}, 
-       {0xfa20, 2223,  1}, {0xfa22, 2224,  1}, {0xfa25, 2225,  1}, 
-       {0xfa26, 2226,  1}, {0xfa2a, 2227,  1}, {0xfa2b, 2228,  1}, 
-       {0xfa2c, 2229,  1}, {0xfa2d, 2230,  1}, {0xfb1d, 2231,  2}, 
-       {0xfb1f, 2233,  2}, {0xfb2a, 2235,  2}, {0xfb2b, 2237,  2}, 
-       {0xfb2c, 2239,  2}, {0xfb2d, 2241,  2}, {0xfb2e, 2243,  2}, 
-       {0xfb2f, 2245,  2}, {0xfb30, 2247,  2}, {0xfb31, 2249,  2}, 
-       {0xfb32, 2251,  2}, {0xfb33, 2253,  2}, {0xfb34, 2255,  2}, 
-       {0xfb35, 2257,  2}, {0xfb36, 2259,  2}, {0xfb38, 2261,  2}, 
-       {0xfb39, 2263,  2}, {0xfb3a, 2265,  2}, {0xfb3b, 2267,  2}, 
-       {0xfb3c, 2269,  2}, {0xfb3e, 2271,  2}, {0xfb40, 2273,  2}, 
-       {0xfb41, 2275,  2}, {0xfb43, 2277,  2}, {0xfb44, 2279,  2}, 
-       {0xfb46, 2281,  2}, {0xfb47, 2283,  2}, {0xfb48, 2285,  2}, 
-       {0xfb49, 2287,  2}, {0xfb4a, 2289,  2}, {0xfb4b, 2291,  2}, 
-       {0xfb4c, 2293,  2}, {0xfb4d, 2295,  2}, {0xfb4e, 2297,  2}, 
+static struct {
+       unsigned short tbl[32];
+} 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,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+       }},
+       {{
+          656,    658,      0,    660,      0,      0,      0,    662, 
+            0,      0,      0,      0,    664,    666,    668,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,    670,      0,      0,      0,      0,      0,      0, 
+       }},
+       {{
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      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, 
+          674,    676,      0,    678,      0,      0,      0,    680, 
+            0,      0,      0,      0,    682,    684,    686,      0, 
+       }},
+       {{
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,    688,    690, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+       }},
+       {{
+            0,    692,    694,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+          696,    698,    700,    702,      0,      0,    704,    706, 
+            0,      0,    708,    710,    712,    714,    716,    718, 
+       }},
+       {{
+            0,      0,    720,    722,    724,    726,    728,    730, 
+            0,      0,    732,    734,    736,    738,    740,    742, 
+          744,    746,    748,    750,    752,    754,      0,      0, 
+          756,    758,      0,      0,      0,      0,      0,      0, 
+       }},
+       {{
+            0,      0,      0,      0,      0,      0,      0,  33528, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+       }},
+       {{
+            0,      0,    762,    764,    766,    768,    770,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+       }},
+       {{
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,  33540,  33542,  33544, 
+        33546,      0,      0,      0,      0,      0,      0,      0, 
+       }},
+       {{
+          780,      0,    782,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,    784,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+       }},
+       {{
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,    786,      0,      0,      0,      0,      0,      0, 
+            0,    788,      0,      0,    790,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+       }},
+       {{
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+          792,    794,    796,    798,    800,    802,    804,    806, 
+       }},
+       {{
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,    808,    810,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,    812,    814,      0,    816, 
+       }},
+       {{
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,    818,      0,      0,    820,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+       }},
+       {{
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,    822,    824,    826,      0,      0,    828,      0, 
+       }},
+       {{
+            0,      0,      0,      0,      0,      0,      0,      0, 
+          830,      0,      0,    832,    834,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,    836,    838,      0,      0, 
+       }},
+       {{
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,    840,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+       }},
+       {{
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,    842,    844,    846,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+       }},
+       {{
+            0,      0,      0,      0,      0,      0,      0,      0, 
+          848,      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,    852, 
+          854,      0,    856,    858,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+       }},
+       {{
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,    860,    862,    864,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+       }},
+       {{
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,    866,      0,    868,    870,    872,      0, 
+       }},
+       {{
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,  33642,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      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,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,  33646,  33648,      0,      0, 
+       }},
+       {{
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,  33650,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+       }},
+       {{
+            0,      0,      0,    883,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,    885,      0,      0, 
+            0,      0,    887,      0,      0,      0,      0,    889, 
+            0,      0,      0,      0,    891,      0,      0,      0, 
+       }},
+       {{
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,    893,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,    895,      0,    897,    899,  33669, 
+          903,  33673,      0,      0,      0,      0,      0,      0, 
+       }},
+       {{
+            0,    907,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,    909,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,    911,      0,      0, 
+       }},
+       {{
+            0,      0,    913,      0,      0,      0,      0,    915, 
+            0,      0,      0,      0,    917,      0,      0,      0, 
+            0,      0,      0,      0,      0,      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,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+       }},
+       {{
+          923,    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,  33999,   1233,      0,      0,      0,      0, 
+       }},
+       {{
+         1235,   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,      0,      0,      0,      0,      0,      0, 
+       }},
+       {{
+         1415,   1417,   1419,   1421,   1423,   1425,   1427,   1429, 
+         1431,   1433,   1435,   1437,   1439,   1441,   1443,   1445, 
+         1447,   1449,   1451,   1453,   1455,   1457,      0,      0, 
+         1459,   1461,   1463,   1465,   1467,   1469,      0,      0, 
+       }},
+       {{
+         1471,   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,      0,      0, 
+         1547,   1549,   1551,   1553,   1555,   1557,      0,      0, 
+         1559,   1561,   1563,   1565,   1567,   1569,   1571,   1573, 
+            0,   1575,      0,   1577,      0,   1579,      0,   1581, 
+       }},
+       {{
+         1583,   1585,   1587,   1589,   1591,   1593,   1595,   1597, 
+         1599,   1601,   1603,   1605,   1607,   1609,   1611,   1613, 
+         1615,   1617,   1618,   1620,   1621,   1623,   1624,   1626, 
+         1627,   1629,   1630,   1632,   1633,   1635,      0,      0, 
+       }},
+       {{
+         1636,   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,      0,   1742,   1744, 
+         1746,   1748,   1750,   1752,   1753,  34523,   1757,  34526, 
+       }},
+       {{
+        34528,   1762,   1764,   1766,   1768,      0,   1770,   1772, 
+         1774,   1776,   1777,   1779,   1780,   1782,   1784,   1786, 
+         1788,   1790,   1792,   1794,      0,      0,   1795,   1797, 
+         1799,   1801,   1803,   1805,      0,   1806,   1808,   1810, 
+       }},
+       {{
+         1812,   1814,   1816,   1818,   1819,   1821,   1823,   1825, 
+         1827,   1829,   1831,   1833,   1834,   1836,   1838,   1839, 
+            0,      0,   1840,   1842,   1844,      0,   1846,   1848, 
+         1850,   1852,   1853,   1855,   1856,   1858,  34627,      0, 
+       }},
+       {{
+         1861,   1862,  34631,  34632,  34633,  34634,  34635,  34636, 
+        34637,  34638,  34639,      0,      0,      0,      0,      0, 
+            0,  34640,      0,      0,      0,      0,      0,  34641, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+       }},
+       {{
+            0,      0,      0,      0,  34643,  34644,  34646,      0, 
+            0,      0,      0,      0,      0,      0,      0,  34649, 
+            0,      0,      0,  34650,  34652,      0,  34655,  34657, 
+            0,      0,      0,      0,  34660,      0,  34662,      0, 
+       }},
+       {{
+            0,      0,      0,      0,      0,      0,      0,      0, 
+        34664,  34666,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+       }},
+       {{
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+        34668,      0,      0,      0,  34669,  34670,  34671,  34672, 
+        34673,  34674,  34675,  34676,  34677,  34678,  34679,  34680, 
+       }},
+       {{
+        34681,  34682,  34683,  34684,  34685,  34686,  34687,  34688, 
+        34689,  34690,  34691,  34692,  34693,  34694,  34695,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+       }},
+       {{
+            0,      0,      0,      0,      0,      0,      0,      0, 
+        34696,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+       }},
+       {{
+        34698,  34701,  34704,  34705,      0,  34707,  34710,  34713, 
+            0,  34714,  34716,  34717,  34718,  34719,  34720,  34721, 
+        34722,  34723,  34724,  34725,      0,  34726,  34727,      0, 
+            0,  34729,  34730,  34731,  34732,  34733,      0,      0, 
+       }},
+       {{
+        34734,  34736,  34739,      0,  34741,      0,   1974,      0, 
+        34743,      0,   1976,   1977,  34746,  34747,      0,  34748, 
+        34749,  34750,      0,  34751,  34752,  34753,  34754,  34755, 
+        34756,  34757,      0,      0,      0,      0,      0,      0, 
+       }},
+       {{
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,  34758,  34761,  34764,  34767,  34770, 
+        34773,  34776,  34779,  34782,  34785,  34788,  34791,  34794, 
+       }},
+       {{
+        34796,  34797,  34799,  34802,  34804,  34805,  34807,  34810, 
+        34814,  34816,  34817,  34819,  34822,  34823,  34824,  34825, 
+        34826,  34827,  34829,  34832,  34834,  34835,  34837,  34840, 
+        34844,  34846,  34847,  34849,  34852,  34853,  34854,  34855, 
+       }},
+       {{
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,   2088,   2090,      0,      0,      0,      0, 
+       }},
+       {{
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,   2092,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+       }},
+       {{
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,   2094,   2096,   2098, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+       }},
+       {{
+            0,      0,      0,      0,   2100,      0,      0,      0, 
+            0,   2102,      0,      0,   2104,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+       }},
+       {{
+            0,      0,      0,      0,   2106,      0,   2108,      0, 
+            0,      0,      0,      0,  34878,  34880,      0,  34883, 
+        34885,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+       }},
+       {{
+            0,   2120,      0,      0,   2122,      0,      0,   2124, 
+            0,   2126,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+       }},
+       {{
+         2128,      0,   2130,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,   2132,   2134,   2136, 
+         2138,   2140,      0,      0,   2142,   2144,      0,      0, 
+         2146,   2148,      0,      0,      0,      0,      0,      0, 
+       }},
+       {{
+         2150,   2152,      0,      0,   2154,   2156,      0,      0, 
+         2158,   2160,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+       }},
+       {{
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,   2162,   2164,   2166,   2168, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+       }},
+       {{
+         2170,   2172,   2174,   2176,      0,      0,      0,      0, 
+            0,      0,   2178,   2180,   2182,   2184,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+       }},
+       {{
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,   2186,   2187,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+       }},
+       {{
+        34956,  34957,  34958,  34959,  34960,  34961,  34962,  34963, 
+        34964,  34965,  34967,  34969,  34971,  34973,  34975,  34977, 
+        34979,  34981,  34983,  34985,  34987,  34990,  34993,  34996, 
+        34999,  35002,  35005,  35008,  35011,  35014,  35018,  35022, 
+       }},
+       {{
+        35026,  35030,  35034,  35038,  35042,  35046,  35050,  35054, 
+        35058,  35060,  35062,  35064,  35066,  35068,  35070,  35072, 
+        35074,  35076,  35079,  35082,  35085,  35088,  35091,  35094, 
+        35097,  35100,  35103,  35106,  35109,  35112,  35115,  35118, 
+       }},
+       {{
+        35121,  35124,  35127,  35130,  35133,  35136,  35139,  35142, 
+        35145,  35148,  35151,  35154,  35157,  35160,  35163,  35166, 
+        35169,  35172,  35175,  35178,  35181,  35184,  35187,  35188, 
+        35189,  35190,  35191,  35192,  35193,  35194,  35195,  35196, 
+       }},
+       {{
+        35197,  35198,  35199,  35200,  35201,  35202,  35203,  35204, 
+        35205,  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,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+       }},
+       {{
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,  35240, 
+       }},
+       {{
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,  35241,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+       }},
+       {{
+        35242,  35243,  35244,  35245,  35246,  35247,  35248,  35249, 
+        35250,  35251,  35252,  35253,  35254,  35255,  35256,  35257, 
+        35258,  35259,  35260,  35261,  35262,  35263,  35264,  35265, 
+        35266,  35267,  35268,  35269,  35270,  35271,  35272,  35273, 
+       }},
+       {{
+        35274,  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,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+       }},
+       {{
+        35456,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+       }},
+       {{
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,  35457,      0, 
+        35458,  35459,  35460,      0,      0,      0,      0,      0, 
+       }},
+       {{
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,   2693,      0,   2695,      0, 
+         2697,      0,   2699,      0,   2701,      0,   2703,      0, 
+         2705,      0,   2707,      0,   2709,      0,   2711,      0, 
+       }},
+       {{
+         2713,      0,   2715,      0,      0,   2717,      0,   2719, 
+            0,   2721,      0,      0,      0,      0,      0,      0, 
+         2723,   2725,      0,   2727,   2729,      0,   2731,   2733, 
+            0,   2735,   2737,      0,   2739,   2741,      0,      0, 
+       }},
+       {{
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,   2743,      0,      0,      0, 
+            0,      0,      0,  35513,  35515,      0,   2749,      0, 
+       }},
+       {{
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,   2751,      0,   2753,      0, 
+         2755,      0,   2757,      0,   2759,      0,   2761,      0, 
+         2763,      0,   2765,      0,   2767,      0,   2769,      0, 
+       }},
+       {{
+         2771,      0,   2773,      0,      0,   2775,      0,   2777, 
+            0,   2779,      0,      0,      0,      0,      0,      0, 
+         2781,   2783,      0,   2785,   2787,      0,   2789,   2791, 
+            0,   2793,   2795,      0,   2797,   2799,      0,      0, 
+       }},
+       {{
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,   2801,      0,      0,   2803, 
+         2805,   2807,   2809,      0,      0,      0,   2811,      0, 
+       }},
+       {{
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,  35581,  35582,  35583,  35584,  35585,  35586,  35587, 
+        35588,  35589,  35590,  35591,  35592,  35593,  35594,  35595, 
+       }},
+       {{
+        35596,  35597,  35598,  35599,  35600,  35601,  35602,  35603, 
+        35604,  35605,  35606,  35607,  35608,  35609,  35610,  35611, 
+        35612,  35613,  35614,  35615,  35616,  35617,  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,      0, 
+            0,      0,  35675,  35676,  35677,  35678,  35679,  35680, 
+        35681,  35682,  35683,  35684,  35685,  35686,  35687,  35688, 
+       }},
+       {{
+        35689,  35692,  35695,  35698,  35701,  35704,  35707,  35710, 
+        35713,  35716,  35719,  35722,  35725,  35728,  35731,  35735, 
+        35739,  35743,  35747,  35751,  35755,  35759,  35763,  35767, 
+        35771,  35775,  35779,  35783,  35787,      0,      0,      0, 
+       }},
+       {{
+        35791,  35794,  35797,  35800,  35803,  35806,  35809,  35812, 
+        35815,  35818,  35821,  35824,  35827,  35830,  35833,  35836, 
+        35839,  35842,  35845,  35848,  35851,  35854,  35857,  35860, 
+        35863,  35866,  35869,  35872,  35875,  35878,  35881,  35884, 
+       }},
+       {{
+        35887,  35890,  35893,  35896,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+       }},
+       {{
+        35899,  35900,  35901,  35902,  35903,  35904,  35905,  35906, 
+        35907,  35908,  35909,  35910,  35911,  35912,  35913,  35915, 
+        35917,  35919,  35921,  35923,  35925,  35927,  35929,  35931, 
+        35933,  35935,  35937,  35939,      0,      0,      0,      0, 
+       }},
+       {{
+        35941,  35942,  35943,  35944,  35945,  35946,  35947,  35948, 
+        35949,  35950,  35951,  35952,  35953,  35954,  35955,  35956, 
+        35957,  35958,  35959,  35960,  35961,  35962,  35963,  35964, 
+        35965,  35966,  35967,  35968,  35969,  35970,  35971,  35972, 
+       }},
+       {{
+        35973,  35974,  35975,  35976,  35977,  35978,  35979,  35980, 
+        35981,  35982,  35983,  35984,  35985,  35986,  35987,  35988, 
+        35989,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+       }},
+       {{
+        35990,  35992,  35994,  35996,  35998,  36000,  36002,  36004, 
+        36006,  36008,  36011,  36014,      0,      0,      0,      0, 
+        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,  36058,  36059,  36060,  36061,  36062,  36063,      0, 
+       }},
+       {{
+        36064,  36068,  36072,  36076,  36079,  36083,  36086,  36089, 
+        36094,  36098,  36101,  36104,  36107,  36111,  36115,  36118, 
+        36121,  36123,  36126,  36130,  36134,  36136,  36141,  36147, 
+        36152,  36155,  36160,  36165,  36169,  36172,  36175,  36178, 
+       }},
+       {{
+        36182,  36187,  36191,  36194,  36197,  36200,  36202,  36204, 
+        36206,  36208,  36211,  36214,  36219,  36222,  36226,  36231, 
+        36234,  36236,  36238,  36243,  36247,  36252,  36255,  36260, 
+        36262,  36265,  36268,  36271,  36274,  36277,  36281,  36284, 
+       }},
+       {{
+        36286,  36289,  36292,  36295,  36299,  36302,  36305,  36308, 
+        36313,  36317,  36319,  36324,  36326,  36330,  36334,  36337, 
+        36340,  36343,  36347,  36349,  36352,  36356,  36358,  36363, 
+        36366,  36368,  36370,  36372,  36374,  36376,  36378,  36380, 
+       }},
+       {{
+        36382,  36384,  36386,  36389,  36392,  36395,  36398,  36401, 
+        36404,  36407,  36410,  36413,  36416,  36419,  36422,  36425, 
+        36428,  36431,  36434,  36436,  36438,  36441,  36443,      0, 
+            0,      0,      0,  36445,  36447,  36449,  36451,  36453, 
+       }},
+       {{
+        36457,  36459,  36461,  36463,  36465,  36467,  36469,  36471, 
+        36473,  36476,  36480,  36482,  36484,  36486,  36488,  36490, 
+        36492,  36494,  36497,  36500,  36503,  36506,  36508,  36510, 
+        36512,  36514,  36516,  36518,  36520,  36522,  36524,  36526, 
+       }},
+       {{
+        36529,  36532,  36534,  36537,  36540,  36543,  36545,  36548, 
+        36551,  36555,  36557,  36560,  36563,  36566,  36569,  36574, 
+        36580,  36582,  36584,  36586,  36588,  36590,  36592,  36594, 
+        36596,  36598,  36600,  36602,  36604,  36606,  36608,  36610, 
+       }},
+       {{
+        36612,  36614,  36616,  36620,  36622,  36624,  36626,  36630, 
+        36633,  36635,  36637,  36639,  36641,  36643,  36645,  36647, 
+        36649,  36651,  36653,  36656,  36658,  36660,  36663,  36666, 
+        36668,  36672,  36675,  36677,  36679,  36681,      0,      0, 
+       }},
+       {{
+        36683,  36685,  36687,  36689,  36691,  36693,  36695,  36697, 
+        36699,  36701,  36704,  36707,  36710,  36713,  36716,  36719, 
+        36722,  36725,  36728,  36731,  36734,  36737,  36740,  36743, 
+        36746,  36749,  36752,  36755,  36758,  36761,  36764,      0, 
+       }},
+       {{
+         3999,   4000,   4001,   4002,   4003,   4004,   4005,   4006, 
+         4007,   4008,   4009,   4010,   4011,   4012,   4013,   4014, 
+         4015,   4016,   4017,   4018,   4019,   4020,   4021,   4022, 
+         4023,   4024,   4025,   4026,   4027,   4028,   4029,   4030, 
+       }},
+       {{
+         4031,   4032,   4033,   4034,   4035,   4036,   4037,   4038, 
+         4039,   4040,   4041,   4042,   4043,   4044,   4045,   4046, 
+         4047,   4048,   4049,   4050,   4051,   4052,   4053,   4054, 
+         4055,   4056,   4057,   4058,   4059,   4060,   4061,   4062, 
+       }},
+       {{
+         4063,   4064,   4065,   4066,   4067,   4068,   4069,   4070, 
+         4071,   4072,   4073,   4074,   4075,   4076,   4077,   4078, 
+         4079,   4080,   4081,   4082,   4083,   4084,   4085,   4086, 
+         4087,   4088,   4089,   4090,   4091,   4092,   4093,   4094, 
+       }},
+       {{
+         4095,   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,      0,      0, 
+         4269,      0,   4270,      0,      0,   4271,   4272,   4273, 
+         4274,   4275,   4276,   4277,   4278,   4279,   4280,      0, 
+       }},
+       {{
+         4281,      0,   4282,      0,      0,   4283,   4284,      0, 
+            0,      0,   4285,   4286,   4287,   4288,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+       }},
+       {{
+        37057,  37059,  37061,  37063,  37066,  37069,  37071,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,  37073,  37075,  37077,  37079,  37081, 
+            0,      0,      0,      0,      0,   4315,      0,   4317, 
+       }},
+       {{
+        37087,  37088,  37089,  37090,  37091,  37092,  37093,  37094, 
+        37095,  37096,   4329,   4331,   4333,   4335,   4337,   4339, 
+         4341,   4343,   4345,   4347,   4349,   4351,   4353,      0, 
+         4355,   4357,   4359,   4361,   4363,      0,   4365,      0, 
+       }},
+       {{
+         4367,   4369,      0,   4371,   4373,      0,   4375,   4377, 
+         4379,   4381,   4383,   4385,   4387,   4389,   4391,  37161, 
+        37163,  37164,  37165,  37166,  37167,  37168,  37169,  37170, 
+        37171,  37172,  37173,  37174,  37175,  37176,  37177,  37178, 
+       }},
+       {{
+        37179,  37180,  37181,  37182,  37183,  37184,  37185,  37186, 
+        37187,  37188,  37189,  37190,  37191,  37192,  37193,  37194, 
+        37195,  37196,  37197,  37198,  37199,  37200,  37201,  37202, 
+        37203,  37204,  37205,  37206,  37207,  37208,  37209,  37210, 
+       }},
+       {{
+        37211,  37212,  37213,  37214,  37215,  37216,  37217,  37218, 
+        37219,  37220,  37221,  37222,  37223,  37224,  37225,  37226, 
+        37227,  37228,  37229,  37230,  37231,  37232,  37233,  37234, 
+        37235,  37236,  37237,  37238,  37239,  37240,  37241,  37242, 
+       }},
+       {{
+        37243,  37244,  37245,  37246,  37247,  37248,  37249,  37250, 
+        37251,  37252,  37253,  37254,  37255,  37256,  37257,  37258, 
+        37259,  37260,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+       }},
+       {{
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,  37261,  37262,  37263,  37264,  37265, 
+        37266,  37267,  37268,  37269,  37270,  37271,  37272,  37273, 
+       }},
+       {{
+        37274,  37275,  37276,  37277,  37278,  37279,  37280,  37281, 
+        37282,  37283,  37284,  37286,  37288,  37290,  37292,  37294, 
+        37296,  37298,  37300,  37302,  37304,  37306,  37308,  37310, 
+        37312,  37314,  37316,  37318,  37320,  37321,  37322,  37323, 
+       }},
+       {{
+        37324,  37326,  37328,  37330,  37332,  37334,  37336,  37338, 
+        37340,  37342,  37344,  37346,  37348,  37350,  37352,  37354, 
+        37356,  37358,  37360,  37362,  37364,  37366,  37368,  37370, 
+        37372,  37374,  37376,  37378,  37380,  37382,  37384,  37386, 
+       }},
+       {{
+        37388,  37390,  37392,  37394,  37396,  37398,  37400,  37402, 
+        37404,  37406,  37408,  37410,  37412,  37414,  37416,  37418, 
+        37420,  37422,  37424,  37426,  37428,  37430,  37432,  37434, 
+        37436,  37438,  37440,  37442,  37444,  37446,  37448,  37450, 
+       }},
+       {{
+        37452,  37454,  37456,  37458,  37460,  37462,  37464,  37466, 
+        37468,  37470,  37472,  37474,  37476,  37478,  37480,  37482, 
+        37484,  37486,  37488,  37490,  37492,  37494,  37496,  37498, 
+        37500,  37502,  37504,  37506,  37508,  37510,  37512,  37515, 
+       }},
+       {{
+        37518,  37521,  37524,  37527,  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,  37670,  37672,  37674,  37676,  37678,  37680, 
+        37682,  37684,  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,  37817,  37820,  37823,  37825,  37827, 
+        37829,  37831,  37833,  37835,  37837,  37839,  37841,  37843, 
+       }},
+       {{
+        37845,  37847,  37849,  37851,  37853,  37855,  37857,  37859, 
+        37861,  37863,  37865,  37867,  37869,  37871,  37873,  37875, 
+        37877,  37879,  37881,  37883,  37885,  37887,  37889,  37891, 
+        37893,  37895,  37897,  37899,  37901,  37903,  37905,  37907, 
+       }},
+       {{
+        37909,  37911,  37913,  37915,  37917,  37919,  37921,  37923, 
+        37925,  37927,  37929,  37931,  37933,  37935,  37937,  37939, 
+        37941,  37943,  37945,  37947,  37949,  37951,  37953,  37955, 
+        37957,  37959,  37961,  37963,  37965,  37967,      0,      0, 
+       }},
+       {{
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+        37969,  37972,  37975,  37978,  37981,  37984,  37987,  37990, 
+        37993,  37996,  37999,  38002,  38005,  38008,  38011,  38014, 
+       }},
+       {{
+        38017,  38020,  38023,  38026,  38029,  38032,  38035,  38038, 
+        38041,  38044,  38047,  38050,  38053,  38056,  38059,  38062, 
+        38065,  38068,  38071,  38074,  38077,  38080,  38083,  38086, 
+        38089,  38092,  38095,  38098,  38101,  38104,  38107,  38110, 
+       }},
+       {{
+        38113,  38116,  38119,  38122,  38125,  38128,  38131,  38134, 
+        38137,  38140,  38143,  38146,  38149,  38152,  38155,  38158, 
+            0,      0,  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,  38317,  38320, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+       }},
+       {{
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+        38323,  38326,  38329,  38333,  38337,  38341,  38345,  38349, 
+        38353,  38357,  38360,  38378,      0,      0,      0,      0, 
+       }},
+       {{
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+        38386,  38387,  38388,  38389,  38390,  38391,  38392,  38393, 
+        38394,  38395,  38396,  38397,  38398,  38399,  38400,  38401, 
+       }},
+       {{
+        38402,  38403,  38404,  38405,  38406,      0,      0,      0, 
+            0,  38407,  38408,  38409,  38410,  38411,  38412,  38413, 
+        38414,  38415,  38416,      0,  38417,  38418,  38419,  38420, 
+        38421,  38422,  38423,  38424,  38425,  38426,  38427,  38428, 
+       }},
+       {{
+        38429,  38430,  38431,  38432,  38433,  38434,  38435,      0, 
+        38436,  38437,  38438,  38439,      0,      0,      0,      0, 
+        38440,  38442,  38444,      0,  38446,      0,  38448,  38450, 
+        38452,  38454,  38456,  38458,  38460,  38462,  38464,  38466, 
+       }},
+       {{
+        38468,  38469,  38470,  38471,  38472,  38473,  38474,  38475, 
+        38476,  38477,  38478,  38479,  38480,  38481,  38482,  38483, 
+        38484,  38485,  38486,  38487,  38488,  38489,  38490,  38491, 
+        38492,  38493,  38494,  38495,  38496,  38497,  38498,  38499, 
+       }},
+       {{
+        38500,  38501,  38502,  38503,  38504,  38505,  38506,  38507, 
+        38508,  38509,  38510,  38511,  38512,  38513,  38514,  38515, 
+        38516,  38517,  38518,  38519,  38520,  38521,  38522,  38523, 
+        38524,  38525,  38526,  38527,  38528,  38529,  38530,  38531, 
+       }},
+       {{
+        38532,  38533,  38534,  38535,  38536,  38537,  38538,  38539, 
+        38540,  38541,  38542,  38543,  38544,  38545,  38546,  38547, 
+        38548,  38549,  38550,  38551,  38552,  38553,  38554,  38555, 
+        38556,  38557,  38558,  38559,  38560,  38561,  38562,  38563, 
+       }},
+       {{
+        38564,  38565,  38566,  38567,  38568,  38569,  38570,  38571, 
+        38572,  38573,  38574,  38575,  38576,  38577,  38578,  38579, 
+        38580,  38581,  38582,  38583,  38584,  38585,  38587,  38589, 
+        38591,  38593,  38595,  38597,  38599,      0,      0,      0, 
+       }},
+       {{
+            0,  38601,  38602,  38603,  38604,  38605,  38606,  38607, 
+        38608,  38609,  38610,  38611,  38612,  38613,  38614,  38615, 
+        38616,  38617,  38618,  38619,  38620,  38621,  38622,  38623, 
+        38624,  38625,  38626,  38627,  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,      0, 
+       }},
+       {{
+            0,  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,  38746,  38747,  38748,  38749, 
+        38750,  38751,  38752,  38753,  38754,  38755,  38756,  38757, 
+       }},
+       {{
+        38758,  38759,  38760,  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,      0, 
+       }},
+       {{
+            0,      0,  38789,  38790,  38791,  38792,  38793,  38794, 
+            0,      0,  38795,  38796,  38797,  38798,  38799,  38800, 
+            0,      0,  38801,  38802,  38803,  38804,  38805,  38806, 
+            0,      0,  38807,  38808,  38809,      0,      0,      0, 
+       }},
+       {{
+        38810,  38811,  38812,  38813,  38814,  38815,  38816,      0, 
+        38817,  38818,  38819,  38820,  38821,  38822,  38823,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+            0,      0,      0,      0,      0,      0,      0,      0, 
+       }},
 };
-
-static unicode_t canon_decompose_data[] = {
-          65,   768,    65,   769,    65,   770,    65,   771,    65,   776, 
-          65,   778,    67,   807,    69,   768,    69,   769,    69,   770, 
-          69,   776,    73,   768,    73,   769,    73,   770,    73,   776, 
-          78,   771,    79,   768,    79,   769,    79,   770,    79,   771, 
-          79,   776,    85,   768,    85,   769,    85,   770,    85,   776, 
-          89,   769,    97,   768,    97,   769,    97,   770,    97,   771, 
-          97,   776,    97,   778,    99,   807,   101,   768,   101,   769, 
-         101,   770,   101,   776,   105,   768,   105,   769,   105,   770, 
-         105,   776,   110,   771,   111,   768,   111,   769,   111,   770, 
-         111,   771,   111,   776,   117,   768,   117,   769,   117,   770, 
-         117,   776,   121,   769,   121,   776,    65,   772,    97,   772, 
-          65,   774,    97,   774,    65,   808,    97,   808,    67,   769, 
-          99,   769,    67,   770,    99,   770,    67,   775,    99,   775, 
-          67,   780,    99,   780,    68,   780,   100,   780,    69,   772, 
-         101,   772,    69,   774,   101,   774,    69,   775,   101,   775, 
-          69,   808,   101,   808,    69,   780,   101,   780,    71,   770, 
-         103,   770,    71,   774,   103,   774,    71,   775,   103,   775, 
-          71,   807,   103,   807,    72,   770,   104,   770,    73,   771, 
-         105,   771,    73,   772,   105,   772,    73,   774,   105,   774, 
-          73,   808,   105,   808,    73,   775,    74,   770,   106,   770, 
-          75,   807,   107,   807,    76,   769,   108,   769,    76,   807, 
-         108,   807,    76,   780,   108,   780,    78,   769,   110,   769, 
-          78,   807,   110,   807,    78,   780,   110,   780,    79,   772, 
-         111,   772,    79,   774,   111,   774,    79,   779,   111,   779, 
-          82,   769,   114,   769,    82,   807,   114,   807,    82,   780, 
-         114,   780,    83,   769,   115,   769,    83,   770,   115,   770, 
-          83,   807,   115,   807,    83,   780,   115,   780,    84,   807, 
-         116,   807,    84,   780,   116,   780,    85,   771,   117,   771, 
-          85,   772,   117,   772,    85,   774,   117,   774,    85,   778, 
-         117,   778,    85,   779,   117,   779,    85,   808,   117,   808, 
-          87,   770,   119,   770,    89,   770,   121,   770,    89,   776, 
-          90,   769,   122,   769,    90,   775,   122,   775,    90,   780, 
-         122,   780,    79,   795,   111,   795,    85,   795,   117,   795, 
-          65,   780,    97,   780,    73,   780,   105,   780,    79,   780, 
-         111,   780,    85,   780,   117,   780,   220,   772,   252,   772, 
-         220,   769,   252,   769,   220,   780,   252,   780,   220,   768, 
-         252,   768,   196,   772,   228,   772,   550,   772,   551,   772, 
-         198,   772,   230,   772,    71,   780,   103,   780,    75,   780, 
-         107,   780,    79,   808,   111,   808,   490,   772,   491,   772, 
-         439,   780,   658,   780,   106,   780,    71,   769,   103,   769, 
-          78,   768,   110,   768,   197,   769,   229,   769,   198,   769, 
-         230,   769,   216,   769,   248,   769,    65,   783,    97,   783, 
-          65,   785,    97,   785,    69,   783,   101,   783,    69,   785, 
-         101,   785,    73,   783,   105,   783,    73,   785,   105,   785, 
-          79,   783,   111,   783,    79,   785,   111,   785,    82,   783, 
-         114,   783,    82,   785,   114,   785,    85,   783,   117,   783, 
-          85,   785,   117,   785,    83,   806,   115,   806,    84,   806, 
-         116,   806,    72,   780,   104,   780,    65,   775,    97,   775, 
-          69,   807,   101,   807,   214,   772,   246,   772,   213,   772, 
-         245,   772,    79,   775,   111,   775,   558,   772,   559,   772, 
-          89,   772,   121,   772,   768,   769,   787,   776,   769,   697, 
-          59,   168,   769,   913,   769,   183,   917,   769,   919,   769, 
-         921,   769,   927,   769,   933,   769,   937,   769,   970,   769, 
-         921,   776,   933,   776,   945,   769,   949,   769,   951,   769, 
-         953,   769,   971,   769,   953,   776,   965,   776,   959,   769, 
-         965,   769,   969,   769,   978,   769,   978,   776,  1045,   768, 
-        1045,   776,  1043,   769,  1030,   776,  1050,   769,  1048,   768, 
-        1059,   774,  1048,   774,  1080,   774,  1077,   768,  1077,   776, 
-        1075,   769,  1110,   776,  1082,   769,  1080,   768,  1091,   774, 
-        1140,   783,  1141,   783,  1046,   774,  1078,   774,  1040,   774, 
-        1072,   774,  1040,   776,  1072,   776,  1045,   774,  1077,   774, 
-        1240,   776,  1241,   776,  1046,   776,  1078,   776,  1047,   776, 
-        1079,   776,  1048,   772,  1080,   772,  1048,   776,  1080,   776, 
-        1054,   776,  1086,   776,  1256,   776,  1257,   776,  1069,   776, 
-        1101,   776,  1059,   772,  1091,   772,  1059,   776,  1091,   776, 
-        1059,   779,  1091,   779,  1063,   776,  1095,   776,  1067,   776, 
-        1099,   776,  1575,  1619,  1575,  1620,  1608,  1620,  1575,  1621, 
-        1610,  1620,  1749,  1620,  1729,  1620,  1746,  1620,  2344,  2364, 
-        2352,  2364,  2355,  2364,  2325,  2364,  2326,  2364,  2327,  2364, 
-        2332,  2364,  2337,  2364,  2338,  2364,  2347,  2364,  2351,  2364, 
-        2503,  2494,  2503,  2519,  2465,  2492,  2466,  2492,  2479,  2492, 
-        2610,  2620,  2616,  2620,  2582,  2620,  2583,  2620,  2588,  2620, 
-        2603,  2620,  2887,  2902,  2887,  2878,  2887,  2903,  2849,  2876, 
-        2850,  2876,  2962,  3031,  3014,  3006,  3015,  3006,  3014,  3031, 
-        3142,  3158,  3263,  3285,  3270,  3285,  3270,  3286,  3270,  3266, 
-        3274,  3285,  3398,  3390,  3399,  3390,  3398,  3415,  3545,  3530, 
-        3545,  3535,  3548,  3530,  3545,  3551,  3906,  4023,  3916,  4023, 
-        3921,  4023,  3926,  4023,  3931,  4023,  3904,  4021,  3953,  3954, 
-        3953,  3956,  4018,  3968,  4019,  3968,  3953,  3968,  3986,  4023, 
-        3996,  4023,  4001,  4023,  4006,  4023,  4011,  4023,  3984,  4021, 
-        4133,  4142,    65,   805,    97,   805,    66,   775,    98,   775, 
-          66,   803,    98,   803,    66,   817,    98,   817,   199,   769, 
-         231,   769,    68,   775,   100,   775,    68,   803,   100,   803, 
-          68,   817,   100,   817,    68,   807,   100,   807,    68,   813, 
-         100,   813,   274,   768,   275,   768,   274,   769,   275,   769, 
-          69,   813,   101,   813,    69,   816,   101,   816,   552,   774, 
-         553,   774,    70,   775,   102,   775,    71,   772,   103,   772, 
-          72,   775,   104,   775,    72,   803,   104,   803,    72,   776, 
-         104,   776,    72,   807,   104,   807,    72,   814,   104,   814, 
-          73,   816,   105,   816,   207,   769,   239,   769,    75,   769, 
-         107,   769,    75,   803,   107,   803,    75,   817,   107,   817, 
-          76,   803,   108,   803,  7734,   772,  7735,   772,    76,   817, 
-         108,   817,    76,   813,   108,   813,    77,   769,   109,   769, 
-          77,   775,   109,   775,    77,   803,   109,   803,    78,   775, 
-         110,   775,    78,   803,   110,   803,    78,   817,   110,   817, 
-          78,   813,   110,   813,   213,   769,   245,   769,   213,   776, 
-         245,   776,   332,   768,   333,   768,   332,   769,   333,   769, 
-          80,   769,   112,   769,    80,   775,   112,   775,    82,   775, 
-         114,   775,    82,   803,   114,   803,  7770,   772,  7771,   772, 
-          82,   817,   114,   817,    83,   775,   115,   775,    83,   803, 
-         115,   803,   346,   775,   347,   775,   352,   775,   353,   775, 
-        7778,   775,  7779,   775,    84,   775,   116,   775,    84,   803, 
-         116,   803,    84,   817,   116,   817,    84,   813,   116,   813, 
-          85,   804,   117,   804,    85,   816,   117,   816,    85,   813, 
-         117,   813,   360,   769,   361,   769,   362,   776,   363,   776, 
-          86,   771,   118,   771,    86,   803,   118,   803,    87,   768, 
-         119,   768,    87,   769,   119,   769,    87,   776,   119,   776, 
-          87,   775,   119,   775,    87,   803,   119,   803,    88,   775, 
-         120,   775,    88,   776,   120,   776,    89,   775,   121,   775, 
-          90,   770,   122,   770,    90,   803,   122,   803,    90,   817, 
-         122,   817,   104,   817,   116,   776,   119,   778,   121,   778, 
-         383,   775,    65,   803,    97,   803,    65,   777,    97,   777, 
-         194,   769,   226,   769,   194,   768,   226,   768,   194,   777, 
-         226,   777,   194,   771,   226,   771,  7840,   770,  7841,   770, 
-         258,   769,   259,   769,   258,   768,   259,   768,   258,   777, 
-         259,   777,   258,   771,   259,   771,  7840,   774,  7841,   774, 
-          69,   803,   101,   803,    69,   777,   101,   777,    69,   771, 
-         101,   771,   202,   769,   234,   769,   202,   768,   234,   768, 
-         202,   777,   234,   777,   202,   771,   234,   771,  7864,   770, 
-        7865,   770,    73,   777,   105,   777,    73,   803,   105,   803, 
-          79,   803,   111,   803,    79,   777,   111,   777,   212,   769, 
-         244,   769,   212,   768,   244,   768,   212,   777,   244,   777, 
-         212,   771,   244,   771,  7884,   770,  7885,   770,   416,   769, 
-         417,   769,   416,   768,   417,   768,   416,   777,   417,   777, 
-         416,   771,   417,   771,   416,   803,   417,   803,    85,   803, 
-         117,   803,    85,   777,   117,   777,   431,   769,   432,   769, 
-         431,   768,   432,   768,   431,   777,   432,   777,   431,   771, 
-         432,   771,   431,   803,   432,   803,    89,   768,   121,   768, 
-          89,   803,   121,   803,    89,   777,   121,   777,    89,   771, 
-         121,   771,   945,   787,   945,   788,  7936,   768,  7937,   768, 
-        7936,   769,  7937,   769,  7936,   834,  7937,   834,   913,   787, 
-         913,   788,  7944,   768,  7945,   768,  7944,   769,  7945,   769, 
-        7944,   834,  7945,   834,   949,   787,   949,   788,  7952,   768, 
-        7953,   768,  7952,   769,  7953,   769,   917,   787,   917,   788, 
-        7960,   768,  7961,   768,  7960,   769,  7961,   769,   951,   787, 
-         951,   788,  7968,   768,  7969,   768,  7968,   769,  7969,   769, 
-        7968,   834,  7969,   834,   919,   787,   919,   788,  7976,   768, 
-        7977,   768,  7976,   769,  7977,   769,  7976,   834,  7977,   834, 
-         953,   787,   953,   788,  7984,   768,  7985,   768,  7984,   769, 
-        7985,   769,  7984,   834,  7985,   834,   921,   787,   921,   788, 
-        7992,   768,  7993,   768,  7992,   769,  7993,   769,  7992,   834, 
-        7993,   834,   959,   787,   959,   788,  8000,   768,  8001,   768, 
-        8000,   769,  8001,   769,   927,   787,   927,   788,  8008,   768, 
-        8009,   768,  8008,   769,  8009,   769,   965,   787,   965,   788, 
-        8016,   768,  8017,   768,  8016,   769,  8017,   769,  8016,   834, 
-        8017,   834,   933,   788,  8025,   768,  8025,   769,  8025,   834, 
-         969,   787,   969,   788,  8032,   768,  8033,   768,  8032,   769, 
-        8033,   769,  8032,   834,  8033,   834,   937,   787,   937,   788, 
-        8040,   768,  8041,   768,  8040,   769,  8041,   769,  8040,   834, 
-        8041,   834,   945,   768,   940,   949,   768,   941,   951,   768, 
-         942,   953,   768,   943,   959,   768,   972,   965,   768,   973, 
-         969,   768,   974,  7936,   837,  7937,   837,  7938,   837,  7939, 
-         837,  7940,   837,  7941,   837,  7942,   837,  7943,   837,  7944, 
-         837,  7945,   837,  7946,   837,  7947,   837,  7948,   837,  7949, 
-         837,  7950,   837,  7951,   837,  7968,   837,  7969,   837,  7970, 
-         837,  7971,   837,  7972,   837,  7973,   837,  7974,   837,  7975, 
-         837,  7976,   837,  7977,   837,  7978,   837,  7979,   837,  7980, 
-         837,  7981,   837,  7982,   837,  7983,   837,  8032,   837,  8033, 
-         837,  8034,   837,  8035,   837,  8036,   837,  8037,   837,  8038, 
-         837,  8039,   837,  8040,   837,  8041,   837,  8042,   837,  8043, 
-         837,  8044,   837,  8045,   837,  8046,   837,  8047,   837,   945, 
-         774,   945,   772,  8048,   837,   945,   837,   940,   837,   945, 
-         834,  8118,   837,   913,   774,   913,   772,   913,   768,   902, 
-         913,   837,   953,   168,   834,  8052,   837,   951,   837,   942, 
-         837,   951,   834,  8134,   837,   917,   768,   904,   919,   768, 
-         905,   919,   837,  8127,   768,  8127,   769,  8127,   834,   953, 
-         774,   953,   772,   970,   768,   912,   953,   834,   970,   834, 
-         921,   774,   921,   772,   921,   768,   906,  8190,   768,  8190, 
-         769,  8190,   834,   965,   774,   965,   772,   971,   768,   944, 
-         961,   787,   961,   788,   965,   834,   971,   834,   933,   774, 
-         933,   772,   933,   768,   910,   929,   788,   168,   768,   901, 
-          96,  8060,   837,   969,   837,   974,   837,   969,   834,  8182, 
-         837,   927,   768,   908,   937,   768,   911,   937,   837,   180, 
-        8194,  8195,   937,    75,   197,  8592,   824,  8594,   824,  8596, 
-         824,  8656,   824,  8660,   824,  8658,   824,  8707,   824,  8712, 
-         824,  8715,   824,  8739,   824,  8741,   824,  8764,   824,  8771, 
-         824,  8773,   824,  8776,   824,    61,   824,  8801,   824,  8781, 
-         824,    60,   824,    62,   824,  8804,   824,  8805,   824,  8818, 
-         824,  8819,   824,  8822,   824,  8823,   824,  8826,   824,  8827, 
-         824,  8834,   824,  8835,   824,  8838,   824,  8839,   824,  8866, 
-         824,  8872,   824,  8873,   824,  8875,   824,  8828,   824,  8829, 
-         824,  8849,   824,  8850,   824,  8882,   824,  8883,   824,  8884, 
-         824,  8885,   824, 12296, 12297, 12363, 12441, 12365, 12441, 12367, 
-       12441, 12369, 12441, 12371, 12441, 12373, 12441, 12375, 12441, 12377, 
-       12441, 12379, 12441, 12381, 12441, 12383, 12441, 12385, 12441, 12388, 
-       12441, 12390, 12441, 12392, 12441, 12399, 12441, 12399, 12442, 12402, 
-       12441, 12402, 12442, 12405, 12441, 12405, 12442, 12408, 12441, 12408, 
-       12442, 12411, 12441, 12411, 12442, 12358, 12441, 12445, 12441, 12459, 
-       12441, 12461, 12441, 12463, 12441, 12465, 12441, 12467, 12441, 12469, 
-       12441, 12471, 12441, 12473, 12441, 12475, 12441, 12477, 12441, 12479, 
-       12441, 12481, 12441, 12484, 12441, 12486, 12441, 12488, 12441, 12495, 
-       12441, 12495, 12442, 12498, 12441, 12498, 12442, 12501, 12441, 12501, 
-       12442, 12504, 12441, 12504, 12442, 12507, 12441, 12507, 12442, 12454, 
-       12441, 12527, 12441, 12528, 12441, 12529, 12441, 12530, 12441, 12541, 
-       12441, 35912, 26356, 36554, 36040, 28369, 20018, 21477, 40860, 40860, 
-       22865, 37329, 21895, 22856, 25078, 30313, 32645, 34367, 34746, 35064, 
-       37007, 27138, 27931, 28889, 29662, 33853, 37226, 39409, 20098, 21365, 
-       27396, 29211, 34349, 40478, 23888, 28651, 34253, 35172, 25289, 33240, 
-       34847, 24266, 26391, 28010, 29436, 37070, 20358, 20919, 21214, 25796, 
-       27347, 29200, 30439, 32769, 34310, 34396, 36335, 38706, 39791, 40442, 
-       30860, 31103, 32160, 33737, 37636, 40575, 35542, 22751, 24324, 31840, 
-       32894, 29282, 30922, 36034, 38647, 22744, 23650, 27155, 28122, 28431, 
-       32047, 32311, 38651, 21202, 32907, 20956, 20940, 31260, 32190, 33777, 
-       38517, 35712, 25295, 27138, 35582, 20025, 23527, 24594, 29575, 30064, 
-       21271, 30971, 20415, 24489, 19981, 27852, 25976, 32034, 21443, 22622, 
-       30465, 33865, 35498, 27578, 36784, 27784, 25342, 33509, 25504, 30053, 
-       20142, 20841, 20937, 26753, 31975, 33391, 35538, 37327, 21237, 21570, 
-       22899, 24300, 26053, 28670, 31018, 38317, 39530, 40599, 40654, 21147, 
-       26310, 27511, 36706, 24180, 24976, 25088, 25754, 28451, 29001, 29833, 
-       31178, 32244, 32879, 36646, 34030, 36899, 37706, 21015, 21155, 21693, 
-       28872, 35010, 35498, 24265, 24565, 25467, 27566, 31806, 29557, 20196, 
-       22265, 23527, 23994, 24604, 29618, 29801, 32666, 32838, 37428, 38646, 
-       38728, 38936, 20363, 31150, 37300, 38584, 24801, 20102, 20698, 23534, 
-       23615, 26009, 27138, 29134, 30274, 34044, 36988, 40845, 26248, 38446, 
-       21129, 26491, 26611, 27969, 28316, 29705, 30041, 30827, 32016, 39006, 
-       20845, 25134, 38520, 20523, 23833, 28138, 36650, 24459, 24900, 26647, 
-       29575, 38534, 21033, 21519, 23653, 26131, 26446, 26792, 27877, 29702, 
-       30178, 32633, 35023, 35041, 37324, 38626, 21311, 28346, 21533, 29136, 
-       29848, 34298, 38563, 40023, 40607, 26519, 28107, 33256, 31435, 31520, 
-       31890, 29376, 28825, 35672, 20160, 33590, 21050, 20999, 24230, 25299, 
-       31958, 23429, 27934, 26292, 36667, 34892, 38477, 35211, 24275, 20800, 
-       21952, 22618, 26228, 20958, 29482, 30410, 31036, 31070, 31077, 31119, 
-       38742, 31934, 32701, 34322, 35576, 36920, 37117, 39151, 39164, 39208, 
-       40372,  1497,  1460,  1522,  1463,  1513,  1473,  1513,  1474, 64329, 
-        1473, 64329,  1474,  1488,  1463,  1488,  1464,  1488,  1468,  1489, 
-        1468,  1490,  1468,  1491,  1468,  1492,  1468,  1493,  1468,  1494, 
-        1468,  1496,  1468,  1497,  1468,  1498,  1468,  1499,  1468,  1500, 
-        1468,  1502,  1468,  1504,  1468,  1505,  1468,  1507,  1468,  1508, 
-        1468,  1510,  1468,  1511,  1468,  1512,  1468,  1513,  1468,  1514, 
-        1468,  1493,  1465,  1489,  1471,  1499,  1471,  1508,  1471, 
-};
-
-static unsigned long compat_decompose_bitmap[] = {
-       0x0b4bedfc, 0x7daae3b0, 0x00000001, 0xff000000, 
-       0x000e1ff7, 0xfc000000, 0x0000ff7f, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0xfffff1f0, 
+static unsigned long 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, 
+       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, 0x80000021, 0x00000021, 0x8000003f, 
+       0x80000030, 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, 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, 
+       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, 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, 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, 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, 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, 
+       0x800096fb, 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, 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, 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, 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, 
 };
 
-static struct decomposition compat_decompose_seq[] = {
-       {0x00a0,    0,  1}, {0x00a8,    1,  2}, {0x00aa,    3,  1}, 
-       {0x00af,    4,  2}, {0x00b2,    6,  1}, {0x00b3,    7,  1}, 
-       {0x00b4,    8,  2}, {0x00b5,   10,  1}, {0x00b8,   11,  2}, 
-       {0x00b9,   13,  1}, {0x00ba,   14,  1}, {0x00bc,   15,  3}, 
-       {0x00bd,   18,  3}, {0x00be,   21,  3}, {0x0132,   24,  2}, 
-       {0x0133,   26,  2}, {0x013f,   28,  2}, {0x0140,   30,  2}, 
-       {0x0149,   32,  2}, {0x017f,   34,  1}, {0x01c4,   35,  2}, 
-       {0x01c5,   37,  2}, {0x01c6,   39,  2}, {0x01c7,   41,  2}, 
-       {0x01c8,   43,  2}, {0x01c9,   45,  2}, {0x01ca,   47,  2}, 
-       {0x01cb,   49,  2}, {0x01cc,   51,  2}, {0x01f1,   53,  2}, 
-       {0x01f2,   55,  2}, {0x01f3,   57,  2}, {0x02b0,   59,  1}, 
-       {0x02b1,   60,  1}, {0x02b2,   61,  1}, {0x02b3,   62,  1}, 
-       {0x02b4,   63,  1}, {0x02b5,   64,  1}, {0x02b6,   65,  1}, 
-       {0x02b7,   66,  1}, {0x02b8,   67,  1}, {0x02d8,   68,  2}, 
-       {0x02d9,   70,  2}, {0x02da,   72,  2}, {0x02db,   74,  2}, 
-       {0x02dc,   76,  2}, {0x02dd,   78,  2}, {0x02e0,   80,  1}, 
-       {0x02e1,   81,  1}, {0x02e2,   82,  1}, {0x02e3,   83,  1}, 
-       {0x02e4,   84,  1}, {0x037a,   85,  2}, {0x0384,   87,  2}, 
-       {0x03d0,   89,  1}, {0x03d1,   90,  1}, {0x03d2,   91,  1}, 
-       {0x03d5,   92,  1}, {0x03d6,   93,  1}, {0x03f0,   94,  1}, 
-       {0x03f1,   95,  1}, {0x03f2,   96,  1}, {0x0587,   97,  2}, 
-       {0x0675,   99,  2}, {0x0676,  101,  2}, {0x0677,  103,  2}, 
-       {0x0678,  105,  2}, {0x0e33,  107,  2}, {0x0eb3,  109,  2}, 
-       {0x0edc,  111,  2}, {0x0edd,  113,  2}, {0x0f0c,  115,  1}, 
-       {0x0f77,  116,  2}, {0x0f79,  118,  2}, {0x1e9a,  120,  2}, 
-       {0x1fbd,  122,  2}, {0x1fbf,  124,  2}, {0x1fc0,  126,  2}, 
-       {0x1ffe,  128,  2}, {0x2002,  130,  1}, {0x2003,  131,  1}, 
-       {0x2004,  132,  1}, {0x2005,  133,  1}, {0x2006,  134,  1}, 
-       {0x2007,  135,  1}, {0x2008,  136,  1}, {0x2009,  137,  1}, 
-       {0x200a,  138,  1}, {0x2011,  139,  1}, {0x2017,  140,  2}, 
-       {0x2024,  142,  1}, {0x2025,  143,  2}, {0x2026,  145,  3}, 
-       {0x202f,  148,  1}, {0x2033,  149,  2}, {0x2034,  151,  3}, 
-       {0x2036,  154,  2}, {0x2037,  156,  3}, {0x203c,  159,  2}, 
-       {0x203e,  161,  2}, {0x2048,  163,  2}, {0x2049,  165,  2}, 
-       {0x2070,  167,  1}, {0x2074,  168,  1}, {0x2075,  169,  1}, 
-       {0x2076,  170,  1}, {0x2077,  171,  1}, {0x2078,  172,  1}, 
-       {0x2079,  173,  1}, {0x207a,  174,  1}, {0x207b,  175,  1}, 
-       {0x207c,  176,  1}, {0x207d,  177,  1}, {0x207e,  178,  1}, 
-       {0x207f,  179,  1}, {0x2080,  180,  1}, {0x2081,  181,  1}, 
-       {0x2082,  182,  1}, {0x2083,  183,  1}, {0x2084,  184,  1}, 
-       {0x2085,  185,  1}, {0x2086,  186,  1}, {0x2087,  187,  1}, 
-       {0x2088,  188,  1}, {0x2089,  189,  1}, {0x208a,  190,  1}, 
-       {0x208b,  191,  1}, {0x208c,  192,  1}, {0x208d,  193,  1}, 
-       {0x208e,  194,  1}, {0x20a8,  195,  2}, {0x2100,  197,  3}, 
-       {0x2101,  200,  3}, {0x2102,  203,  1}, {0x2103,  204,  2}, 
-       {0x2105,  206,  3}, {0x2106,  209,  3}, {0x2107,  212,  1}, 
-       {0x2109,  213,  2}, {0x210a,  215,  1}, {0x210b,  216,  1}, 
-       {0x210c,  217,  1}, {0x210d,  218,  1}, {0x210e,  219,  1}, 
-       {0x210f,  220,  1}, {0x2110,  221,  1}, {0x2111,  222,  1}, 
-       {0x2112,  223,  1}, {0x2113,  224,  1}, {0x2115,  225,  1}, 
-       {0x2116,  226,  2}, {0x2119,  228,  1}, {0x211a,  229,  1}, 
-       {0x211b,  230,  1}, {0x211c,  231,  1}, {0x211d,  232,  1}, 
-       {0x2120,  233,  2}, {0x2121,  235,  3}, {0x2122,  238,  2}, 
-       {0x2124,  240,  1}, {0x2128,  241,  1}, {0x212c,  242,  1}, 
-       {0x212d,  243,  1}, {0x212f,  244,  1}, {0x2130,  245,  1}, 
-       {0x2131,  246,  1}, {0x2133,  247,  1}, {0x2134,  248,  1}, 
-       {0x2135,  249,  1}, {0x2136,  250,  1}, {0x2137,  251,  1}, 
-       {0x2138,  252,  1}, {0x2139,  253,  1}, {0x2153,  254,  3}, 
-       {0x2154,  257,  3}, {0x2155,  260,  3}, {0x2156,  263,  3}, 
-       {0x2157,  266,  3}, {0x2158,  269,  3}, {0x2159,  272,  3}, 
-       {0x215a,  275,  3}, {0x215b,  278,  3}, {0x215c,  281,  3}, 
-       {0x215d,  284,  3}, {0x215e,  287,  3}, {0x215f,  290,  2}, 
-       {0x2160,  292,  1}, {0x2161,  293,  2}, {0x2162,  295,  3}, 
-       {0x2163,  298,  2}, {0x2164,  300,  1}, {0x2165,  301,  2}, 
-       {0x2166,  303,  3}, {0x2167,  306,  4}, {0x2168,  310,  2}, 
-       {0x2169,  312,  1}, {0x216a,  313,  2}, {0x216b,  315,  3}, 
-       {0x216c,  318,  1}, {0x216d,  319,  1}, {0x216e,  320,  1}, 
-       {0x216f,  321,  1}, {0x2170,  322,  1}, {0x2171,  323,  2}, 
-       {0x2172,  325,  3}, {0x2173,  328,  2}, {0x2174,  330,  1}, 
-       {0x2175,  331,  2}, {0x2176,  333,  3}, {0x2177,  336,  4}, 
-       {0x2178,  340,  2}, {0x2179,  342,  1}, {0x217a,  343,  2}, 
-       {0x217b,  345,  3}, {0x217c,  348,  1}, {0x217d,  349,  1}, 
-       {0x217e,  350,  1}, {0x217f,  351,  1}, {0x222c,  352,  2}, 
-       {0x222d,  354,  3}, {0x222f,  357,  2}, {0x2230,  359,  3}, 
-       {0x2460,  362,  1}, {0x2461,  363,  1}, {0x2462,  364,  1}, 
-       {0x2463,  365,  1}, {0x2464,  366,  1}, {0x2465,  367,  1}, 
-       {0x2466,  368,  1}, {0x2467,  369,  1}, {0x2468,  370,  1}, 
-       {0x2469,  371,  2}, {0x246a,  373,  2}, {0x246b,  375,  2}, 
-       {0x246c,  377,  2}, {0x246d,  379,  2}, {0x246e,  381,  2}, 
-       {0x246f,  383,  2}, {0x2470,  385,  2}, {0x2471,  387,  2}, 
-       {0x2472,  389,  2}, {0x2473,  391,  2}, {0x2474,  393,  3}, 
-       {0x2475,  396,  3}, {0x2476,  399,  3}, {0x2477,  402,  3}, 
-       {0x2478,  405,  3}, {0x2479,  408,  3}, {0x247a,  411,  3}, 
-       {0x247b,  414,  3}, {0x247c,  417,  3}, {0x247d,  420,  4}, 
-       {0x247e,  424,  4}, {0x247f,  428,  4}, {0x2480,  432,  4}, 
-       {0x2481,  436,  4}, {0x2482,  440,  4}, {0x2483,  444,  4}, 
-       {0x2484,  448,  4}, {0x2485,  452,  4}, {0x2486,  456,  4}, 
-       {0x2487,  460,  4}, {0x2488,  464,  2}, {0x2489,  466,  2}, 
-       {0x248a,  468,  2}, {0x248b,  470,  2}, {0x248c,  472,  2}, 
-       {0x248d,  474,  2}, {0x248e,  476,  2}, {0x248f,  478,  2}, 
-       {0x2490,  480,  2}, {0x2491,  482,  3}, {0x2492,  485,  3}, 
-       {0x2493,  488,  3}, {0x2494,  491,  3}, {0x2495,  494,  3}, 
-       {0x2496,  497,  3}, {0x2497,  500,  3}, {0x2498,  503,  3}, 
-       {0x2499,  506,  3}, {0x249a,  509,  3}, {0x249b,  512,  3}, 
-       {0x249c,  515,  3}, {0x249d,  518,  3}, {0x249e,  521,  3}, 
-       {0x249f,  524,  3}, {0x24a0,  527,  3}, {0x24a1,  530,  3}, 
-       {0x24a2,  533,  3}, {0x24a3,  536,  3}, {0x24a4,  539,  3}, 
-       {0x24a5,  542,  3}, {0x24a6,  545,  3}, {0x24a7,  548,  3}, 
-       {0x24a8,  551,  3}, {0x24a9,  554,  3}, {0x24aa,  557,  3}, 
-       {0x24ab,  560,  3}, {0x24ac,  563,  3}, {0x24ad,  566,  3}, 
-       {0x24ae,  569,  3}, {0x24af,  572,  3}, {0x24b0,  575,  3}, 
-       {0x24b1,  578,  3}, {0x24b2,  581,  3}, {0x24b3,  584,  3}, 
-       {0x24b4,  587,  3}, {0x24b5,  590,  3}, {0x24b6,  593,  1}, 
-       {0x24b7,  594,  1}, {0x24b8,  595,  1}, {0x24b9,  596,  1}, 
-       {0x24ba,  597,  1}, {0x24bb,  598,  1}, {0x24bc,  599,  1}, 
-       {0x24bd,  600,  1}, {0x24be,  601,  1}, {0x24bf,  602,  1}, 
-       {0x24c0,  603,  1}, {0x24c1,  604,  1}, {0x24c2,  605,  1}, 
-       {0x24c3,  606,  1}, {0x24c4,  607,  1}, {0x24c5,  608,  1}, 
-       {0x24c6,  609,  1}, {0x24c7,  610,  1}, {0x24c8,  611,  1}, 
-       {0x24c9,  612,  1}, {0x24ca,  613,  1}, {0x24cb,  614,  1}, 
-       {0x24cc,  615,  1}, {0x24cd,  616,  1}, {0x24ce,  617,  1}, 
-       {0x24cf,  618,  1}, {0x24d0,  619,  1}, {0x24d1,  620,  1}, 
-       {0x24d2,  621,  1}, {0x24d3,  622,  1}, {0x24d4,  623,  1}, 
-       {0x24d5,  624,  1}, {0x24d6,  625,  1}, {0x24d7,  626,  1}, 
-       {0x24d8,  627,  1}, {0x24d9,  628,  1}, {0x24da,  629,  1}, 
-       {0x24db,  630,  1}, {0x24dc,  631,  1}, {0x24dd,  632,  1}, 
-       {0x24de,  633,  1}, {0x24df,  634,  1}, {0x24e0,  635,  1}, 
-       {0x24e1,  636,  1}, {0x24e2,  637,  1}, {0x24e3,  638,  1}, 
-       {0x24e4,  639,  1}, {0x24e5,  640,  1}, {0x24e6,  641,  1}, 
-       {0x24e7,  642,  1}, {0x24e8,  643,  1}, {0x24e9,  644,  1}, 
-       {0x24ea,  645,  1}, {0x2e9f,  646,  1}, {0x2ef3,  647,  1}, 
-       {0x2f00,  648,  1}, {0x2f01,  649,  1}, {0x2f02,  650,  1}, 
-       {0x2f03,  651,  1}, {0x2f04,  652,  1}, {0x2f05,  653,  1}, 
-       {0x2f06,  654,  1}, {0x2f07,  655,  1}, {0x2f08,  656,  1}, 
-       {0x2f09,  657,  1}, {0x2f0a,  658,  1}, {0x2f0b,  659,  1}, 
-       {0x2f0c,  660,  1}, {0x2f0d,  661,  1}, {0x2f0e,  662,  1}, 
-       {0x2f0f,  663,  1}, {0x2f10,  664,  1}, {0x2f11,  665,  1}, 
-       {0x2f12,  666,  1}, {0x2f13,  667,  1}, {0x2f14,  668,  1}, 
-       {0x2f15,  669,  1}, {0x2f16,  670,  1}, {0x2f17,  671,  1}, 
-       {0x2f18,  672,  1}, {0x2f19,  673,  1}, {0x2f1a,  674,  1}, 
-       {0x2f1b,  675,  1}, {0x2f1c,  676,  1}, {0x2f1d,  677,  1}, 
-       {0x2f1e,  678,  1}, {0x2f1f,  679,  1}, {0x2f20,  680,  1}, 
-       {0x2f21,  681,  1}, {0x2f22,  682,  1}, {0x2f23,  683,  1}, 
-       {0x2f24,  684,  1}, {0x2f25,  685,  1}, {0x2f26,  686,  1}, 
-       {0x2f27,  687,  1}, {0x2f28,  688,  1}, {0x2f29,  689,  1}, 
-       {0x2f2a,  690,  1}, {0x2f2b,  691,  1}, {0x2f2c,  692,  1}, 
-       {0x2f2d,  693,  1}, {0x2f2e,  694,  1}, {0x2f2f,  695,  1}, 
-       {0x2f30,  696,  1}, {0x2f31,  697,  1}, {0x2f32,  698,  1}, 
-       {0x2f33,  699,  1}, {0x2f34,  700,  1}, {0x2f35,  701,  1}, 
-       {0x2f36,  702,  1}, {0x2f37,  703,  1}, {0x2f38,  704,  1}, 
-       {0x2f39,  705,  1}, {0x2f3a,  706,  1}, {0x2f3b,  707,  1}, 
-       {0x2f3c,  708,  1}, {0x2f3d,  709,  1}, {0x2f3e,  710,  1}, 
-       {0x2f3f,  711,  1}, {0x2f40,  712,  1}, {0x2f41,  713,  1}, 
-       {0x2f42,  714,  1}, {0x2f43,  715,  1}, {0x2f44,  716,  1}, 
-       {0x2f45,  717,  1}, {0x2f46,  718,  1}, {0x2f47,  719,  1}, 
-       {0x2f48,  720,  1}, {0x2f49,  721,  1}, {0x2f4a,  722,  1}, 
-       {0x2f4b,  723,  1}, {0x2f4c,  724,  1}, {0x2f4d,  725,  1}, 
-       {0x2f4e,  726,  1}, {0x2f4f,  727,  1}, {0x2f50,  728,  1}, 
-       {0x2f51,  729,  1}, {0x2f52,  730,  1}, {0x2f53,  731,  1}, 
-       {0x2f54,  732,  1}, {0x2f55,  733,  1}, {0x2f56,  734,  1}, 
-       {0x2f57,  735,  1}, {0x2f58,  736,  1}, {0x2f59,  737,  1}, 
-       {0x2f5a,  738,  1}, {0x2f5b,  739,  1}, {0x2f5c,  740,  1}, 
-       {0x2f5d,  741,  1}, {0x2f5e,  742,  1}, {0x2f5f,  743,  1}, 
-       {0x2f60,  744,  1}, {0x2f61,  745,  1}, {0x2f62,  746,  1}, 
-       {0x2f63,  747,  1}, {0x2f64,  748,  1}, {0x2f65,  749,  1}, 
-       {0x2f66,  750,  1}, {0x2f67,  751,  1}, {0x2f68,  752,  1}, 
-       {0x2f69,  753,  1}, {0x2f6a,  754,  1}, {0x2f6b,  755,  1}, 
-       {0x2f6c,  756,  1}, {0x2f6d,  757,  1}, {0x2f6e,  758,  1}, 
-       {0x2f6f,  759,  1}, {0x2f70,  760,  1}, {0x2f71,  761,  1}, 
-       {0x2f72,  762,  1}, {0x2f73,  763,  1}, {0x2f74,  764,  1}, 
-       {0x2f75,  765,  1}, {0x2f76,  766,  1}, {0x2f77,  767,  1}, 
-       {0x2f78,  768,  1}, {0x2f79,  769,  1}, {0x2f7a,  770,  1}, 
-       {0x2f7b,  771,  1}, {0x2f7c,  772,  1}, {0x2f7d,  773,  1}, 
-       {0x2f7e,  774,  1}, {0x2f7f,  775,  1}, {0x2f80,  776,  1}, 
-       {0x2f81,  777,  1}, {0x2f82,  778,  1}, {0x2f83,  779,  1}, 
-       {0x2f84,  780,  1}, {0x2f85,  781,  1}, {0x2f86,  782,  1}, 
-       {0x2f87,  783,  1}, {0x2f88,  784,  1}, {0x2f89,  785,  1}, 
-       {0x2f8a,  786,  1}, {0x2f8b,  787,  1}, {0x2f8c,  788,  1}, 
-       {0x2f8d,  789,  1}, {0x2f8e,  790,  1}, {0x2f8f,  791,  1}, 
-       {0x2f90,  792,  1}, {0x2f91,  793,  1}, {0x2f92,  794,  1}, 
-       {0x2f93,  795,  1}, {0x2f94,  796,  1}, {0x2f95,  797,  1}, 
-       {0x2f96,  798,  1}, {0x2f97,  799,  1}, {0x2f98,  800,  1}, 
-       {0x2f99,  801,  1}, {0x2f9a,  802,  1}, {0x2f9b,  803,  1}, 
-       {0x2f9c,  804,  1}, {0x2f9d,  805,  1}, {0x2f9e,  806,  1}, 
-       {0x2f9f,  807,  1}, {0x2fa0,  808,  1}, {0x2fa1,  809,  1}, 
-       {0x2fa2,  810,  1}, {0x2fa3,  811,  1}, {0x2fa4,  812,  1}, 
-       {0x2fa5,  813,  1}, {0x2fa6,  814,  1}, {0x2fa7,  815,  1}, 
-       {0x2fa8,  816,  1}, {0x2fa9,  817,  1}, {0x2faa,  818,  1}, 
-       {0x2fab,  819,  1}, {0x2fac,  820,  1}, {0x2fad,  821,  1}, 
-       {0x2fae,  822,  1}, {0x2faf,  823,  1}, {0x2fb0,  824,  1}, 
-       {0x2fb1,  825,  1}, {0x2fb2,  826,  1}, {0x2fb3,  827,  1}, 
-       {0x2fb4,  828,  1}, {0x2fb5,  829,  1}, {0x2fb6,  830,  1}, 
-       {0x2fb7,  831,  1}, {0x2fb8,  832,  1}, {0x2fb9,  833,  1}, 
-       {0x2fba,  834,  1}, {0x2fbb,  835,  1}, {0x2fbc,  836,  1}, 
-       {0x2fbd,  837,  1}, {0x2fbe,  838,  1}, {0x2fbf,  839,  1}, 
-       {0x2fc0,  840,  1}, {0x2fc1,  841,  1}, {0x2fc2,  842,  1}, 
-       {0x2fc3,  843,  1}, {0x2fc4,  844,  1}, {0x2fc5,  845,  1}, 
-       {0x2fc6,  846,  1}, {0x2fc7,  847,  1}, {0x2fc8,  848,  1}, 
-       {0x2fc9,  849,  1}, {0x2fca,  850,  1}, {0x2fcb,  851,  1}, 
-       {0x2fcc,  852,  1}, {0x2fcd,  853,  1}, {0x2fce,  854,  1}, 
-       {0x2fcf,  855,  1}, {0x2fd0,  856,  1}, {0x2fd1,  857,  1}, 
-       {0x2fd2,  858,  1}, {0x2fd3,  859,  1}, {0x2fd4,  860,  1}, 
-       {0x2fd5,  861,  1}, {0x3000,  862,  1}, {0x3036,  863,  1}, 
-       {0x3038,  864,  1}, {0x3039,  865,  1}, {0x303a,  866,  1}, 
-       {0x309b,  867,  2}, {0x309c,  869,  2}, {0x3131,  871,  1}, 
-       {0x3132,  872,  1}, {0x3133,  873,  1}, {0x3134,  874,  1}, 
-       {0x3135,  875,  1}, {0x3136,  876,  1}, {0x3137,  877,  1}, 
-       {0x3138,  878,  1}, {0x3139,  879,  1}, {0x313a,  880,  1}, 
-       {0x313b,  881,  1}, {0x313c,  882,  1}, {0x313d,  883,  1}, 
-       {0x313e,  884,  1}, {0x313f,  885,  1}, {0x3140,  886,  1}, 
-       {0x3141,  887,  1}, {0x3142,  888,  1}, {0x3143,  889,  1}, 
-       {0x3144,  890,  1}, {0x3145,  891,  1}, {0x3146,  892,  1}, 
-       {0x3147,  893,  1}, {0x3148,  894,  1}, {0x3149,  895,  1}, 
-       {0x314a,  896,  1}, {0x314b,  897,  1}, {0x314c,  898,  1}, 
-       {0x314d,  899,  1}, {0x314e,  900,  1}, {0x314f,  901,  1}, 
-       {0x3150,  902,  1}, {0x3151,  903,  1}, {0x3152,  904,  1}, 
-       {0x3153,  905,  1}, {0x3154,  906,  1}, {0x3155,  907,  1}, 
-       {0x3156,  908,  1}, {0x3157,  909,  1}, {0x3158,  910,  1}, 
-       {0x3159,  911,  1}, {0x315a,  912,  1}, {0x315b,  913,  1}, 
-       {0x315c,  914,  1}, {0x315d,  915,  1}, {0x315e,  916,  1}, 
-       {0x315f,  917,  1}, {0x3160,  918,  1}, {0x3161,  919,  1}, 
-       {0x3162,  920,  1}, {0x3163,  921,  1}, {0x3164,  922,  1}, 
-       {0x3165,  923,  1}, {0x3166,  924,  1}, {0x3167,  925,  1}, 
-       {0x3168,  926,  1}, {0x3169,  927,  1}, {0x316a,  928,  1}, 
-       {0x316b,  929,  1}, {0x316c,  930,  1}, {0x316d,  931,  1}, 
-       {0x316e,  932,  1}, {0x316f,  933,  1}, {0x3170,  934,  1}, 
-       {0x3171,  935,  1}, {0x3172,  936,  1}, {0x3173,  937,  1}, 
-       {0x3174,  938,  1}, {0x3175,  939,  1}, {0x3176,  940,  1}, 
-       {0x3177,  941,  1}, {0x3178,  942,  1}, {0x3179,  943,  1}, 
-       {0x317a,  944,  1}, {0x317b,  945,  1}, {0x317c,  946,  1}, 
-       {0x317d,  947,  1}, {0x317e,  948,  1}, {0x317f,  949,  1}, 
-       {0x3180,  950,  1}, {0x3181,  951,  1}, {0x3182,  952,  1}, 
-       {0x3183,  953,  1}, {0x3184,  954,  1}, {0x3185,  955,  1}, 
-       {0x3186,  956,  1}, {0x3187,  957,  1}, {0x3188,  958,  1}, 
-       {0x3189,  959,  1}, {0x318a,  960,  1}, {0x318b,  961,  1}, 
-       {0x318c,  962,  1}, {0x318d,  963,  1}, {0x318e,  964,  1}, 
-       {0x3192,  965,  1}, {0x3193,  966,  1}, {0x3194,  967,  1}, 
-       {0x3195,  968,  1}, {0x3196,  969,  1}, {0x3197,  970,  1}, 
-       {0x3198,  971,  1}, {0x3199,  972,  1}, {0x319a,  973,  1}, 
-       {0x319b,  974,  1}, {0x319c,  975,  1}, {0x319d,  976,  1}, 
-       {0x319e,  977,  1}, {0x319f,  978,  1}, {0x3200,  979,  3}, 
-       {0x3201,  982,  3}, {0x3202,  985,  3}, {0x3203,  988,  3}, 
-       {0x3204,  991,  3}, {0x3205,  994,  3}, {0x3206,  997,  3}, 
-       {0x3207, 1000,  3}, {0x3208, 1003,  3}, {0x3209, 1006,  3}, 
-       {0x320a, 1009,  3}, {0x320b, 1012,  3}, {0x320c, 1015,  3}, 
-       {0x320d, 1018,  3}, {0x320e, 1021,  4}, {0x320f, 1025,  4}, 
-       {0x3210, 1029,  4}, {0x3211, 1033,  4}, {0x3212, 1037,  4}, 
-       {0x3213, 1041,  4}, {0x3214, 1045,  4}, {0x3215, 1049,  4}, 
-       {0x3216, 1053,  4}, {0x3217, 1057,  4}, {0x3218, 1061,  4}, 
-       {0x3219, 1065,  4}, {0x321a, 1069,  4}, {0x321b, 1073,  4}, 
-       {0x321c, 1077,  4}, {0x3220, 1081,  3}, {0x3221, 1084,  3}, 
-       {0x3222, 1087,  3}, {0x3223, 1090,  3}, {0x3224, 1093,  3}, 
-       {0x3225, 1096,  3}, {0x3226, 1099,  3}, {0x3227, 1102,  3}, 
-       {0x3228, 1105,  3}, {0x3229, 1108,  3}, {0x322a, 1111,  3}, 
-       {0x322b, 1114,  3}, {0x322c, 1117,  3}, {0x322d, 1120,  3}, 
-       {0x322e, 1123,  3}, {0x322f, 1126,  3}, {0x3230, 1129,  3}, 
-       {0x3231, 1132,  3}, {0x3232, 1135,  3}, {0x3233, 1138,  3}, 
-       {0x3234, 1141,  3}, {0x3235, 1144,  3}, {0x3236, 1147,  3}, 
-       {0x3237, 1150,  3}, {0x3238, 1153,  3}, {0x3239, 1156,  3}, 
-       {0x323a, 1159,  3}, {0x323b, 1162,  3}, {0x323c, 1165,  3}, 
-       {0x323d, 1168,  3}, {0x323e, 1171,  3}, {0x323f, 1174,  3}, 
-       {0x3240, 1177,  3}, {0x3241, 1180,  3}, {0x3242, 1183,  3}, 
-       {0x3243, 1186,  3}, {0x3260, 1189,  1}, {0x3261, 1190,  1}, 
-       {0x3262, 1191,  1}, {0x3263, 1192,  1}, {0x3264, 1193,  1}, 
-       {0x3265, 1194,  1}, {0x3266, 1195,  1}, {0x3267, 1196,  1}, 
-       {0x3268, 1197,  1}, {0x3269, 1198,  1}, {0x326a, 1199,  1}, 
-       {0x326b, 1200,  1}, {0x326c, 1201,  1}, {0x326d, 1202,  1}, 
-       {0x326e, 1203,  2}, {0x326f, 1205,  2}, {0x3270, 1207,  2}, 
-       {0x3271, 1209,  2}, {0x3272, 1211,  2}, {0x3273, 1213,  2}, 
-       {0x3274, 1215,  2}, {0x3275, 1217,  2}, {0x3276, 1219,  2}, 
-       {0x3277, 1221,  2}, {0x3278, 1223,  2}, {0x3279, 1225,  2}, 
-       {0x327a, 1227,  2}, {0x327b, 1229,  2}, {0x3280, 1231,  1}, 
-       {0x3281, 1232,  1}, {0x3282, 1233,  1}, {0x3283, 1234,  1}, 
-       {0x3284, 1235,  1}, {0x3285, 1236,  1}, {0x3286, 1237,  1}, 
-       {0x3287, 1238,  1}, {0x3288, 1239,  1}, {0x3289, 1240,  1}, 
-       {0x328a, 1241,  1}, {0x328b, 1242,  1}, {0x328c, 1243,  1}, 
-       {0x328d, 1244,  1}, {0x328e, 1245,  1}, {0x328f, 1246,  1}, 
-       {0x3290, 1247,  1}, {0x3291, 1248,  1}, {0x3292, 1249,  1}, 
-       {0x3293, 1250,  1}, {0x3294, 1251,  1}, {0x3295, 1252,  1}, 
-       {0x3296, 1253,  1}, {0x3297, 1254,  1}, {0x3298, 1255,  1}, 
-       {0x3299, 1256,  1}, {0x329a, 1257,  1}, {0x329b, 1258,  1}, 
-       {0x329c, 1259,  1}, {0x329d, 1260,  1}, {0x329e, 1261,  1}, 
-       {0x329f, 1262,  1}, {0x32a0, 1263,  1}, {0x32a1, 1264,  1}, 
-       {0x32a2, 1265,  1}, {0x32a3, 1266,  1}, {0x32a4, 1267,  1}, 
-       {0x32a5, 1268,  1}, {0x32a6, 1269,  1}, {0x32a7, 1270,  1}, 
-       {0x32a8, 1271,  1}, {0x32a9, 1272,  1}, {0x32aa, 1273,  1}, 
-       {0x32ab, 1274,  1}, {0x32ac, 1275,  1}, {0x32ad, 1276,  1}, 
-       {0x32ae, 1277,  1}, {0x32af, 1278,  1}, {0x32b0, 1279,  1}, 
-       {0x32c0, 1280,  2}, {0x32c1, 1282,  2}, {0x32c2, 1284,  2}, 
-       {0x32c3, 1286,  2}, {0x32c4, 1288,  2}, {0x32c5, 1290,  2}, 
-       {0x32c6, 1292,  2}, {0x32c7, 1294,  2}, {0x32c8, 1296,  2}, 
-       {0x32c9, 1298,  3}, {0x32ca, 1301,  3}, {0x32cb, 1304,  3}, 
-       {0x32d0, 1307,  1}, {0x32d1, 1308,  1}, {0x32d2, 1309,  1}, 
-       {0x32d3, 1310,  1}, {0x32d4, 1311,  1}, {0x32d5, 1312,  1}, 
-       {0x32d6, 1313,  1}, {0x32d7, 1314,  1}, {0x32d8, 1315,  1}, 
-       {0x32d9, 1316,  1}, {0x32da, 1317,  1}, {0x32db, 1318,  1}, 
-       {0x32dc, 1319,  1}, {0x32dd, 1320,  1}, {0x32de, 1321,  1}, 
-       {0x32df, 1322,  1}, {0x32e0, 1323,  1}, {0x32e1, 1324,  1}, 
-       {0x32e2, 1325,  1}, {0x32e3, 1326,  1}, {0x32e4, 1327,  1}, 
-       {0x32e5, 1328,  1}, {0x32e6, 1329,  1}, {0x32e7, 1330,  1}, 
-       {0x32e8, 1331,  1}, {0x32e9, 1332,  1}, {0x32ea, 1333,  1}, 
-       {0x32eb, 1334,  1}, {0x32ec, 1335,  1}, {0x32ed, 1336,  1}, 
-       {0x32ee, 1337,  1}, {0x32ef, 1338,  1}, {0x32f0, 1339,  1}, 
-       {0x32f1, 1340,  1}, {0x32f2, 1341,  1}, {0x32f3, 1342,  1}, 
-       {0x32f4, 1343,  1}, {0x32f5, 1344,  1}, {0x32f6, 1345,  1}, 
-       {0x32f7, 1346,  1}, {0x32f8, 1347,  1}, {0x32f9, 1348,  1}, 
-       {0x32fa, 1349,  1}, {0x32fb, 1350,  1}, {0x32fc, 1351,  1}, 
-       {0x32fd, 1352,  1}, {0x32fe, 1353,  1}, {0x3300, 1354,  4}, 
-       {0x3301, 1358,  4}, {0x3302, 1362,  4}, {0x3303, 1366,  3}, 
-       {0x3304, 1369,  4}, {0x3305, 1373,  3}, {0x3306, 1376,  3}, 
-       {0x3307, 1379,  5}, {0x3308, 1384,  4}, {0x3309, 1388,  3}, 
-       {0x330a, 1391,  3}, {0x330b, 1394,  3}, {0x330c, 1397,  4}, 
-       {0x330d, 1401,  4}, {0x330e, 1405,  3}, {0x330f, 1408,  3}, 
-       {0x3310, 1411,  2}, {0x3311, 1413,  3}, {0x3312, 1416,  4}, 
-       {0x3313, 1420,  4}, {0x3314, 1424,  2}, {0x3315, 1426,  5}, 
-       {0x3316, 1431,  6}, {0x3317, 1437,  5}, {0x3318, 1442,  3}, 
-       {0x3319, 1445,  5}, {0x331a, 1450,  5}, {0x331b, 1455,  4}, 
-       {0x331c, 1459,  3}, {0x331d, 1462,  3}, {0x331e, 1465,  3}, 
-       {0x331f, 1468,  4}, {0x3320, 1472,  5}, {0x3321, 1477,  4}, 
-       {0x3322, 1481,  3}, {0x3323, 1484,  3}, {0x3324, 1487,  3}, 
-       {0x3325, 1490,  2}, {0x3326, 1492,  2}, {0x3327, 1494,  2}, 
-       {0x3328, 1496,  2}, {0x3329, 1498,  3}, {0x332a, 1501,  3}, 
-       {0x332b, 1504,  5}, {0x332c, 1509,  3}, {0x332d, 1512,  4}, 
-       {0x332e, 1516,  5}, {0x332f, 1521,  3}, {0x3330, 1524,  2}, 
-       {0x3331, 1526,  2}, {0x3332, 1528,  5}, {0x3333, 1533,  4}, 
-       {0x3334, 1537,  5}, {0x3335, 1542,  3}, {0x3336, 1545,  5}, 
-       {0x3337, 1550,  2}, {0x3338, 1552,  3}, {0x3339, 1555,  3}, 
-       {0x333a, 1558,  3}, {0x333b, 1561,  3}, {0x333c, 1564,  3}, 
-       {0x333d, 1567,  4}, {0x333e, 1571,  3}, {0x333f, 1574,  2}, 
-       {0x3340, 1576,  3}, {0x3341, 1579,  3}, {0x3342, 1582,  3}, 
-       {0x3343, 1585,  4}, {0x3344, 1589,  3}, {0x3345, 1592,  3}, 
-       {0x3346, 1595,  3}, {0x3347, 1598,  5}, {0x3348, 1603,  4}, 
-       {0x3349, 1607,  2}, {0x334a, 1609,  5}, {0x334b, 1614,  2}, 
-       {0x334c, 1616,  4}, {0x334d, 1620,  4}, {0x334e, 1624,  3}, 
-       {0x334f, 1627,  3}, {0x3350, 1630,  3}, {0x3351, 1633,  4}, 
-       {0x3352, 1637,  2}, {0x3353, 1639,  3}, {0x3354, 1642,  4}, 
-       {0x3355, 1646,  2}, {0x3356, 1648,  5}, {0x3357, 1653,  3}, 
-       {0x3358, 1656,  2}, {0x3359, 1658,  2}, {0x335a, 1660,  2}, 
-       {0x335b, 1662,  2}, {0x335c, 1664,  2}, {0x335d, 1666,  2}, 
-       {0x335e, 1668,  2}, {0x335f, 1670,  2}, {0x3360, 1672,  2}, 
-       {0x3361, 1674,  2}, {0x3362, 1676,  3}, {0x3363, 1679,  3}, 
-       {0x3364, 1682,  3}, {0x3365, 1685,  3}, {0x3366, 1688,  3}, 
-       {0x3367, 1691,  3}, {0x3368, 1694,  3}, {0x3369, 1697,  3}, 
-       {0x336a, 1700,  3}, {0x336b, 1703,  3}, {0x336c, 1706,  3}, 
-       {0x336d, 1709,  3}, {0x336e, 1712,  3}, {0x336f, 1715,  3}, 
-       {0x3370, 1718,  3}, {0x3371, 1721,  3}, {0x3372, 1724,  2}, 
-       {0x3373, 1726,  2}, {0x3374, 1728,  3}, {0x3375, 1731,  2}, 
-       {0x3376, 1733,  2}, {0x337b, 1735,  2}, {0x337c, 1737,  2}, 
-       {0x337d, 1739,  2}, {0x337e, 1741,  2}, {0x337f, 1743,  4}, 
-       {0x3380, 1747,  2}, {0x3381, 1749,  2}, {0x3382, 1751,  2}, 
-       {0x3383, 1753,  2}, {0x3384, 1755,  2}, {0x3385, 1757,  2}, 
-       {0x3386, 1759,  2}, {0x3387, 1761,  2}, {0x3388, 1763,  3}, 
-       {0x3389, 1766,  4}, {0x338a, 1770,  2}, {0x338b, 1772,  2}, 
-       {0x338c, 1774,  2}, {0x338d, 1776,  2}, {0x338e, 1778,  2}, 
-       {0x338f, 1780,  2}, {0x3390, 1782,  2}, {0x3391, 1784,  3}, 
-       {0x3392, 1787,  3}, {0x3393, 1790,  3}, {0x3394, 1793,  3}, 
-       {0x3395, 1796,  2}, {0x3396, 1798,  2}, {0x3397, 1800,  2}, 
-       {0x3398, 1802,  2}, {0x3399, 1804,  2}, {0x339a, 1806,  2}, 
-       {0x339b, 1808,  2}, {0x339c, 1810,  2}, {0x339d, 1812,  2}, 
-       {0x339e, 1814,  2}, {0x339f, 1816,  3}, {0x33a0, 1819,  3}, 
-       {0x33a1, 1822,  2}, {0x33a2, 1824,  3}, {0x33a3, 1827,  3}, 
-       {0x33a4, 1830,  3}, {0x33a5, 1833,  2}, {0x33a6, 1835,  3}, 
-       {0x33a7, 1838,  3}, {0x33a8, 1841,  4}, {0x33a9, 1845,  2}, 
-       {0x33aa, 1847,  3}, {0x33ab, 1850,  3}, {0x33ac, 1853,  3}, 
-       {0x33ad, 1856,  3}, {0x33ae, 1859,  5}, {0x33af, 1864,  6}, 
-       {0x33b0, 1870,  2}, {0x33b1, 1872,  2}, {0x33b2, 1874,  2}, 
-       {0x33b3, 1876,  2}, {0x33b4, 1878,  2}, {0x33b5, 1880,  2}, 
-       {0x33b6, 1882,  2}, {0x33b7, 1884,  2}, {0x33b8, 1886,  2}, 
-       {0x33b9, 1888,  2}, {0x33ba, 1890,  2}, {0x33bb, 1892,  2}, 
-       {0x33bc, 1894,  2}, {0x33bd, 1896,  2}, {0x33be, 1898,  2}, 
-       {0x33bf, 1900,  2}, {0x33c0, 1902,  2}, {0x33c1, 1904,  2}, 
-       {0x33c2, 1906,  4}, {0x33c3, 1910,  2}, {0x33c4, 1912,  2}, 
-       {0x33c5, 1914,  2}, {0x33c6, 1916,  4}, {0x33c7, 1920,  3}, 
-       {0x33c8, 1923,  2}, {0x33c9, 1925,  2}, {0x33ca, 1927,  2}, 
-       {0x33cb, 1929,  2}, {0x33cc, 1931,  2}, {0x33cd, 1933,  2}, 
-       {0x33ce, 1935,  2}, {0x33cf, 1937,  2}, {0x33d0, 1939,  2}, 
-       {0x33d1, 1941,  2}, {0x33d2, 1943,  3}, {0x33d3, 1946,  2}, 
-       {0x33d4, 1948,  2}, {0x33d5, 1950,  3}, {0x33d6, 1953,  3}, 
-       {0x33d7, 1956,  2}, {0x33d8, 1958,  4}, {0x33d9, 1962,  3}, 
-       {0x33da, 1965,  2}, {0x33db, 1967,  2}, {0x33dc, 1969,  2}, 
-       {0x33dd, 1971,  2}, {0x33e0, 1973,  2}, {0x33e1, 1975,  2}, 
-       {0x33e2, 1977,  2}, {0x33e3, 1979,  2}, {0x33e4, 1981,  2}, 
-       {0x33e5, 1983,  2}, {0x33e6, 1985,  2}, {0x33e7, 1987,  2}, 
-       {0x33e8, 1989,  2}, {0x33e9, 1991,  3}, {0x33ea, 1994,  3}, 
-       {0x33eb, 1997,  3}, {0x33ec, 2000,  3}, {0x33ed, 2003,  3}, 
-       {0x33ee, 2006,  3}, {0x33ef, 2009,  3}, {0x33f0, 2012,  3}, 
-       {0x33f1, 2015,  3}, {0x33f2, 2018,  3}, {0x33f3, 2021,  3}, 
-       {0x33f4, 2024,  3}, {0x33f5, 2027,  3}, {0x33f6, 2030,  3}, 
-       {0x33f7, 2033,  3}, {0x33f8, 2036,  3}, {0x33f9, 2039,  3}, 
-       {0x33fa, 2042,  3}, {0x33fb, 2045,  3}, {0x33fc, 2048,  3}, 
-       {0x33fd, 2051,  3}, {0x33fe, 2054,  3}, {0xfb00, 2057,  2}, 
-       {0xfb01, 2059,  2}, {0xfb02, 2061,  2}, {0xfb03, 2063,  3}, 
-       {0xfb04, 2066,  3}, {0xfb05, 2069,  2}, {0xfb06, 2071,  2}, 
-       {0xfb13, 2073,  2}, {0xfb14, 2075,  2}, {0xfb15, 2077,  2}, 
-       {0xfb16, 2079,  2}, {0xfb17, 2081,  2}, {0xfb20, 2083,  1}, 
-       {0xfb21, 2084,  1}, {0xfb22, 2085,  1}, {0xfb23, 2086,  1}, 
-       {0xfb24, 2087,  1}, {0xfb25, 2088,  1}, {0xfb26, 2089,  1}, 
-       {0xfb27, 2090,  1}, {0xfb28, 2091,  1}, {0xfb29, 2092,  1}, 
-       {0xfb4f, 2093,  2}, {0xfb50, 2095,  1}, {0xfb51, 2096,  1}, 
-       {0xfb52, 2097,  1}, {0xfb53, 2098,  1}, {0xfb54, 2099,  1}, 
-       {0xfb55, 2100,  1}, {0xfb56, 2101,  1}, {0xfb57, 2102,  1}, 
-       {0xfb58, 2103,  1}, {0xfb59, 2104,  1}, {0xfb5a, 2105,  1}, 
-       {0xfb5b, 2106,  1}, {0xfb5c, 2107,  1}, {0xfb5d, 2108,  1}, 
-       {0xfb5e, 2109,  1}, {0xfb5f, 2110,  1}, {0xfb60, 2111,  1}, 
-       {0xfb61, 2112,  1}, {0xfb62, 2113,  1}, {0xfb63, 2114,  1}, 
-       {0xfb64, 2115,  1}, {0xfb65, 2116,  1}, {0xfb66, 2117,  1}, 
-       {0xfb67, 2118,  1}, {0xfb68, 2119,  1}, {0xfb69, 2120,  1}, 
-       {0xfb6a, 2121,  1}, {0xfb6b, 2122,  1}, {0xfb6c, 2123,  1}, 
-       {0xfb6d, 2124,  1}, {0xfb6e, 2125,  1}, {0xfb6f, 2126,  1}, 
-       {0xfb70, 2127,  1}, {0xfb71, 2128,  1}, {0xfb72, 2129,  1}, 
-       {0xfb73, 2130,  1}, {0xfb74, 2131,  1}, {0xfb75, 2132,  1}, 
-       {0xfb76, 2133,  1}, {0xfb77, 2134,  1}, {0xfb78, 2135,  1}, 
-       {0xfb79, 2136,  1}, {0xfb7a, 2137,  1}, {0xfb7b, 2138,  1}, 
-       {0xfb7c, 2139,  1}, {0xfb7d, 2140,  1}, {0xfb7e, 2141,  1}, 
-       {0xfb7f, 2142,  1}, {0xfb80, 2143,  1}, {0xfb81, 2144,  1}, 
-       {0xfb82, 2145,  1}, {0xfb83, 2146,  1}, {0xfb84, 2147,  1}, 
-       {0xfb85, 2148,  1}, {0xfb86, 2149,  1}, {0xfb87, 2150,  1}, 
-       {0xfb88, 2151,  1}, {0xfb89, 2152,  1}, {0xfb8a, 2153,  1}, 
-       {0xfb8b, 2154,  1}, {0xfb8c, 2155,  1}, {0xfb8d, 2156,  1}, 
-       {0xfb8e, 2157,  1}, {0xfb8f, 2158,  1}, {0xfb90, 2159,  1}, 
-       {0xfb91, 2160,  1}, {0xfb92, 2161,  1}, {0xfb93, 2162,  1}, 
-       {0xfb94, 2163,  1}, {0xfb95, 2164,  1}, {0xfb96, 2165,  1}, 
-       {0xfb97, 2166,  1}, {0xfb98, 2167,  1}, {0xfb99, 2168,  1}, 
-       {0xfb9a, 2169,  1}, {0xfb9b, 2170,  1}, {0xfb9c, 2171,  1}, 
-       {0xfb9d, 2172,  1}, {0xfb9e, 2173,  1}, {0xfb9f, 2174,  1}, 
-       {0xfba0, 2175,  1}, {0xfba1, 2176,  1}, {0xfba2, 2177,  1}, 
-       {0xfba3, 2178,  1}, {0xfba4, 2179,  1}, {0xfba5, 2180,  1}, 
-       {0xfba6, 2181,  1}, {0xfba7, 2182,  1}, {0xfba8, 2183,  1}, 
-       {0xfba9, 2184,  1}, {0xfbaa, 2185,  1}, {0xfbab, 2186,  1}, 
-       {0xfbac, 2187,  1}, {0xfbad, 2188,  1}, {0xfbae, 2189,  1}, 
-       {0xfbaf, 2190,  1}, {0xfbb0, 2191,  1}, {0xfbb1, 2192,  1}, 
-       {0xfbd3, 2193,  1}, {0xfbd4, 2194,  1}, {0xfbd5, 2195,  1}, 
-       {0xfbd6, 2196,  1}, {0xfbd7, 2197,  1}, {0xfbd8, 2198,  1}, 
-       {0xfbd9, 2199,  1}, {0xfbda, 2200,  1}, {0xfbdb, 2201,  1}, 
-       {0xfbdc, 2202,  1}, {0xfbdd, 2203,  1}, {0xfbde, 2204,  1}, 
-       {0xfbdf, 2205,  1}, {0xfbe0, 2206,  1}, {0xfbe1, 2207,  1}, 
-       {0xfbe2, 2208,  1}, {0xfbe3, 2209,  1}, {0xfbe4, 2210,  1}, 
-       {0xfbe5, 2211,  1}, {0xfbe6, 2212,  1}, {0xfbe7, 2213,  1}, 
-       {0xfbe8, 2214,  1}, {0xfbe9, 2215,  1}, {0xfbea, 2216,  2}, 
-       {0xfbeb, 2218,  2}, {0xfbec, 2220,  2}, {0xfbed, 2222,  2}, 
-       {0xfbee, 2224,  2}, {0xfbef, 2226,  2}, {0xfbf0, 2228,  2}, 
-       {0xfbf1, 2230,  2}, {0xfbf2, 2232,  2}, {0xfbf3, 2234,  2}, 
-       {0xfbf4, 2236,  2}, {0xfbf5, 2238,  2}, {0xfbf6, 2240,  2}, 
-       {0xfbf7, 2242,  2}, {0xfbf8, 2244,  2}, {0xfbf9, 2246,  2}, 
-       {0xfbfa, 2248,  2}, {0xfbfb, 2250,  2}, {0xfbfc, 2252,  1}, 
-       {0xfbfd, 2253,  1}, {0xfbfe, 2254,  1}, {0xfbff, 2255,  1}, 
-       {0xfc00, 2256,  2}, {0xfc01, 2258,  2}, {0xfc02, 2260,  2}, 
-       {0xfc03, 2262,  2}, {0xfc04, 2264,  2}, {0xfc05, 2266,  2}, 
-       {0xfc06, 2268,  2}, {0xfc07, 2270,  2}, {0xfc08, 2272,  2}, 
-       {0xfc09, 2274,  2}, {0xfc0a, 2276,  2}, {0xfc0b, 2278,  2}, 
-       {0xfc0c, 2280,  2}, {0xfc0d, 2282,  2}, {0xfc0e, 2284,  2}, 
-       {0xfc0f, 2286,  2}, {0xfc10, 2288,  2}, {0xfc11, 2290,  2}, 
-       {0xfc12, 2292,  2}, {0xfc13, 2294,  2}, {0xfc14, 2296,  2}, 
-       {0xfc15, 2298,  2}, {0xfc16, 2300,  2}, {0xfc17, 2302,  2}, 
-       {0xfc18, 2304,  2}, {0xfc19, 2306,  2}, {0xfc1a, 2308,  2}, 
-       {0xfc1b, 2310,  2}, {0xfc1c, 2312,  2}, {0xfc1d, 2314,  2}, 
-       {0xfc1e, 2316,  2}, {0xfc1f, 2318,  2}, {0xfc20, 2320,  2}, 
-       {0xfc21, 2322,  2}, {0xfc22, 2324,  2}, {0xfc23, 2326,  2}, 
-       {0xfc24, 2328,  2}, {0xfc25, 2330,  2}, {0xfc26, 2332,  2}, 
-       {0xfc27, 2334,  2}, {0xfc28, 2336,  2}, {0xfc29, 2338,  2}, 
-       {0xfc2a, 2340,  2}, {0xfc2b, 2342,  2}, {0xfc2c, 2344,  2}, 
-       {0xfc2d, 2346,  2}, {0xfc2e, 2348,  2}, {0xfc2f, 2350,  2}, 
-       {0xfc30, 2352,  2}, {0xfc31, 2354,  2}, {0xfc32, 2356,  2}, 
-       {0xfc33, 2358,  2}, {0xfc34, 2360,  2}, {0xfc35, 2362,  2}, 
-       {0xfc36, 2364,  2}, {0xfc37, 2366,  2}, {0xfc38, 2368,  2}, 
-       {0xfc39, 2370,  2}, {0xfc3a, 2372,  2}, {0xfc3b, 2374,  2}, 
-       {0xfc3c, 2376,  2}, {0xfc3d, 2378,  2}, {0xfc3e, 2380,  2}, 
-       {0xfc3f, 2382,  2}, {0xfc40, 2384,  2}, {0xfc41, 2386,  2}, 
-       {0xfc42, 2388,  2}, {0xfc43, 2390,  2}, {0xfc44, 2392,  2}, 
-       {0xfc45, 2394,  2}, {0xfc46, 2396,  2}, {0xfc47, 2398,  2}, 
-       {0xfc48, 2400,  2}, {0xfc49, 2402,  2}, {0xfc4a, 2404,  2}, 
-       {0xfc4b, 2406,  2}, {0xfc4c, 2408,  2}, {0xfc4d, 2410,  2}, 
-       {0xfc4e, 2412,  2}, {0xfc4f, 2414,  2}, {0xfc50, 2416,  2}, 
-       {0xfc51, 2418,  2}, {0xfc52, 2420,  2}, {0xfc53, 2422,  2}, 
-       {0xfc54, 2424,  2}, {0xfc55, 2426,  2}, {0xfc56, 2428,  2}, 
-       {0xfc57, 2430,  2}, {0xfc58, 2432,  2}, {0xfc59, 2434,  2}, 
-       {0xfc5a, 2436,  2}, {0xfc5b, 2438,  2}, {0xfc5c, 2440,  2}, 
-       {0xfc5d, 2442,  2}, {0xfc5e, 2444,  3}, {0xfc5f, 2447,  3}, 
-       {0xfc60, 2450,  3}, {0xfc61, 2453,  3}, {0xfc62, 2456,  3}, 
-       {0xfc63, 2459,  3}, {0xfc64, 2462,  2}, {0xfc65, 2464,  2}, 
-       {0xfc66, 2466,  2}, {0xfc67, 2468,  2}, {0xfc68, 2470,  2}, 
-       {0xfc69, 2472,  2}, {0xfc6a, 2474,  2}, {0xfc6b, 2476,  2}, 
-       {0xfc6c, 2478,  2}, {0xfc6d, 2480,  2}, {0xfc6e, 2482,  2}, 
-       {0xfc6f, 2484,  2}, {0xfc70, 2486,  2}, {0xfc71, 2488,  2}, 
-       {0xfc72, 2490,  2}, {0xfc73, 2492,  2}, {0xfc74, 2494,  2}, 
-       {0xfc75, 2496,  2}, {0xfc76, 2498,  2}, {0xfc77, 2500,  2}, 
-       {0xfc78, 2502,  2}, {0xfc79, 2504,  2}, {0xfc7a, 2506,  2}, 
-       {0xfc7b, 2508,  2}, {0xfc7c, 2510,  2}, {0xfc7d, 2512,  2}, 
-       {0xfc7e, 2514,  2}, {0xfc7f, 2516,  2}, {0xfc80, 2518,  2}, 
-       {0xfc81, 2520,  2}, {0xfc82, 2522,  2}, {0xfc83, 2524,  2}, 
-       {0xfc84, 2526,  2}, {0xfc85, 2528,  2}, {0xfc86, 2530,  2}, 
-       {0xfc87, 2532,  2}, {0xfc88, 2534,  2}, {0xfc89, 2536,  2}, 
-       {0xfc8a, 2538,  2}, {0xfc8b, 2540,  2}, {0xfc8c, 2542,  2}, 
-       {0xfc8d, 2544,  2}, {0xfc8e, 2546,  2}, {0xfc8f, 2548,  2}, 
-       {0xfc90, 2550,  2}, {0xfc91, 2552,  2}, {0xfc92, 2554,  2}, 
-       {0xfc93, 2556,  2}, {0xfc94, 2558,  2}, {0xfc95, 2560,  2}, 
-       {0xfc96, 2562,  2}, {0xfc97, 2564,  2}, {0xfc98, 2566,  2}, 
-       {0xfc99, 2568,  2}, {0xfc9a, 2570,  2}, {0xfc9b, 2572,  2}, 
-       {0xfc9c, 2574,  2}, {0xfc9d, 2576,  2}, {0xfc9e, 2578,  2}, 
-       {0xfc9f, 2580,  2}, {0xfca0, 2582,  2}, {0xfca1, 2584,  2}, 
-       {0xfca2, 2586,  2}, {0xfca3, 2588,  2}, {0xfca4, 2590,  2}, 
-       {0xfca5, 2592,  2}, {0xfca6, 2594,  2}, {0xfca7, 2596,  2}, 
-       {0xfca8, 2598,  2}, {0xfca9, 2600,  2}, {0xfcaa, 2602,  2}, 
-       {0xfcab, 2604,  2}, {0xfcac, 2606,  2}, {0xfcad, 2608,  2}, 
-       {0xfcae, 2610,  2}, {0xfcaf, 2612,  2}, {0xfcb0, 2614,  2}, 
-       {0xfcb1, 2616,  2}, {0xfcb2, 2618,  2}, {0xfcb3, 2620,  2}, 
-       {0xfcb4, 2622,  2}, {0xfcb5, 2624,  2}, {0xfcb6, 2626,  2}, 
-       {0xfcb7, 2628,  2}, {0xfcb8, 2630,  2}, {0xfcb9, 2632,  2}, 
-       {0xfcba, 2634,  2}, {0xfcbb, 2636,  2}, {0xfcbc, 2638,  2}, 
-       {0xfcbd, 2640,  2}, {0xfcbe, 2642,  2}, {0xfcbf, 2644,  2}, 
-       {0xfcc0, 2646,  2}, {0xfcc1, 2648,  2}, {0xfcc2, 2650,  2}, 
-       {0xfcc3, 2652,  2}, {0xfcc4, 2654,  2}, {0xfcc5, 2656,  2}, 
-       {0xfcc6, 2658,  2}, {0xfcc7, 2660,  2}, {0xfcc8, 2662,  2}, 
-       {0xfcc9, 2664,  2}, {0xfcca, 2666,  2}, {0xfccb, 2668,  2}, 
-       {0xfccc, 2670,  2}, {0xfccd, 2672,  2}, {0xfcce, 2674,  2}, 
-       {0xfccf, 2676,  2}, {0xfcd0, 2678,  2}, {0xfcd1, 2680,  2}, 
-       {0xfcd2, 2682,  2}, {0xfcd3, 2684,  2}, {0xfcd4, 2686,  2}, 
-       {0xfcd5, 2688,  2}, {0xfcd6, 2690,  2}, {0xfcd7, 2692,  2}, 
-       {0xfcd8, 2694,  2}, {0xfcd9, 2696,  2}, {0xfcda, 2698,  2}, 
-       {0xfcdb, 2700,  2}, {0xfcdc, 2702,  2}, {0xfcdd, 2704,  2}, 
-       {0xfcde, 2706,  2}, {0xfcdf, 2708,  2}, {0xfce0, 2710,  2}, 
-       {0xfce1, 2712,  2}, {0xfce2, 2714,  2}, {0xfce3, 2716,  2}, 
-       {0xfce4, 2718,  2}, {0xfce5, 2720,  2}, {0xfce6, 2722,  2}, 
-       {0xfce7, 2724,  2}, {0xfce8, 2726,  2}, {0xfce9, 2728,  2}, 
-       {0xfcea, 2730,  2}, {0xfceb, 2732,  2}, {0xfcec, 2734,  2}, 
-       {0xfced, 2736,  2}, {0xfcee, 2738,  2}, {0xfcef, 2740,  2}, 
-       {0xfcf0, 2742,  2}, {0xfcf1, 2744,  2}, {0xfcf2, 2746,  3}, 
-       {0xfcf3, 2749,  3}, {0xfcf4, 2752,  3}, {0xfcf5, 2755,  2}, 
-       {0xfcf6, 2757,  2}, {0xfcf7, 2759,  2}, {0xfcf8, 2761,  2}, 
-       {0xfcf9, 2763,  2}, {0xfcfa, 2765,  2}, {0xfcfb, 2767,  2}, 
-       {0xfcfc, 2769,  2}, {0xfcfd, 2771,  2}, {0xfcfe, 2773,  2}, 
-       {0xfcff, 2775,  2}, {0xfd00, 2777,  2}, {0xfd01, 2779,  2}, 
-       {0xfd02, 2781,  2}, {0xfd03, 2783,  2}, {0xfd04, 2785,  2}, 
-       {0xfd05, 2787,  2}, {0xfd06, 2789,  2}, {0xfd07, 2791,  2}, 
-       {0xfd08, 2793,  2}, {0xfd09, 2795,  2}, {0xfd0a, 2797,  2}, 
-       {0xfd0b, 2799,  2}, {0xfd0c, 2801,  2}, {0xfd0d, 2803,  2}, 
-       {0xfd0e, 2805,  2}, {0xfd0f, 2807,  2}, {0xfd10, 2809,  2}, 
-       {0xfd11, 2811,  2}, {0xfd12, 2813,  2}, {0xfd13, 2815,  2}, 
-       {0xfd14, 2817,  2}, {0xfd15, 2819,  2}, {0xfd16, 2821,  2}, 
-       {0xfd17, 2823,  2}, {0xfd18, 2825,  2}, {0xfd19, 2827,  2}, 
-       {0xfd1a, 2829,  2}, {0xfd1b, 2831,  2}, {0xfd1c, 2833,  2}, 
-       {0xfd1d, 2835,  2}, {0xfd1e, 2837,  2}, {0xfd1f, 2839,  2}, 
-       {0xfd20, 2841,  2}, {0xfd21, 2843,  2}, {0xfd22, 2845,  2}, 
-       {0xfd23, 2847,  2}, {0xfd24, 2849,  2}, {0xfd25, 2851,  2}, 
-       {0xfd26, 2853,  2}, {0xfd27, 2855,  2}, {0xfd28, 2857,  2}, 
-       {0xfd29, 2859,  2}, {0xfd2a, 2861,  2}, {0xfd2b, 2863,  2}, 
-       {0xfd2c, 2865,  2}, {0xfd2d, 2867,  2}, {0xfd2e, 2869,  2}, 
-       {0xfd2f, 2871,  2}, {0xfd30, 2873,  2}, {0xfd31, 2875,  2}, 
-       {0xfd32, 2877,  2}, {0xfd33, 2879,  2}, {0xfd34, 2881,  2}, 
-       {0xfd35, 2883,  2}, {0xfd36, 2885,  2}, {0xfd37, 2887,  2}, 
-       {0xfd38, 2889,  2}, {0xfd39, 2891,  2}, {0xfd3a, 2893,  2}, 
-       {0xfd3b, 2895,  2}, {0xfd3c, 2897,  2}, {0xfd3d, 2899,  2}, 
-       {0xfd50, 2901,  3}, {0xfd51, 2904,  3}, {0xfd52, 2907,  3}, 
-       {0xfd53, 2910,  3}, {0xfd54, 2913,  3}, {0xfd55, 2916,  3}, 
-       {0xfd56, 2919,  3}, {0xfd57, 2922,  3}, {0xfd58, 2925,  3}, 
-       {0xfd59, 2928,  3}, {0xfd5a, 2931,  3}, {0xfd5b, 2934,  3}, 
-       {0xfd5c, 2937,  3}, {0xfd5d, 2940,  3}, {0xfd5e, 2943,  3}, 
-       {0xfd5f, 2946,  3}, {0xfd60, 2949,  3}, {0xfd61, 2952,  3}, 
-       {0xfd62, 2955,  3}, {0xfd63, 2958,  3}, {0xfd64, 2961,  3}, 
-       {0xfd65, 2964,  3}, {0xfd66, 2967,  3}, {0xfd67, 2970,  3}, 
-       {0xfd68, 2973,  3}, {0xfd69, 2976,  3}, {0xfd6a, 2979,  3}, 
-       {0xfd6b, 2982,  3}, {0xfd6c, 2985,  3}, {0xfd6d, 2988,  3}, 
-       {0xfd6e, 2991,  3}, {0xfd6f, 2994,  3}, {0xfd70, 2997,  3}, 
-       {0xfd71, 3000,  3}, {0xfd72, 3003,  3}, {0xfd73, 3006,  3}, 
-       {0xfd74, 3009,  3}, {0xfd75, 3012,  3}, {0xfd76, 3015,  3}, 
-       {0xfd77, 3018,  3}, {0xfd78, 3021,  3}, {0xfd79, 3024,  3}, 
-       {0xfd7a, 3027,  3}, {0xfd7b, 3030,  3}, {0xfd7c, 3033,  3}, 
-       {0xfd7d, 3036,  3}, {0xfd7e, 3039,  3}, {0xfd7f, 3042,  3}, 
-       {0xfd80, 3045,  3}, {0xfd81, 3048,  3}, {0xfd82, 3051,  3}, 
-       {0xfd83, 3054,  3}, {0xfd84, 3057,  3}, {0xfd85, 3060,  3}, 
-       {0xfd86, 3063,  3}, {0xfd87, 3066,  3}, {0xfd88, 3069,  3}, 
-       {0xfd89, 3072,  3}, {0xfd8a, 3075,  3}, {0xfd8b, 3078,  3}, 
-       {0xfd8c, 3081,  3}, {0xfd8d, 3084,  3}, {0xfd8e, 3087,  3}, 
-       {0xfd8f, 3090,  3}, {0xfd92, 3093,  3}, {0xfd93, 3096,  3}, 
-       {0xfd94, 3099,  3}, {0xfd95, 3102,  3}, {0xfd96, 3105,  3}, 
-       {0xfd97, 3108,  3}, {0xfd98, 3111,  3}, {0xfd99, 3114,  3}, 
-       {0xfd9a, 3117,  3}, {0xfd9b, 3120,  3}, {0xfd9c, 3123,  3}, 
-       {0xfd9d, 3126,  3}, {0xfd9e, 3129,  3}, {0xfd9f, 3132,  3}, 
-       {0xfda0, 3135,  3}, {0xfda1, 3138,  3}, {0xfda2, 3141,  3}, 
-       {0xfda3, 3144,  3}, {0xfda4, 3147,  3}, {0xfda5, 3150,  3}, 
-       {0xfda6, 3153,  3}, {0xfda7, 3156,  3}, {0xfda8, 3159,  3}, 
-       {0xfda9, 3162,  3}, {0xfdaa, 3165,  3}, {0xfdab, 3168,  3}, 
-       {0xfdac, 3171,  3}, {0xfdad, 3174,  3}, {0xfdae, 3177,  3}, 
-       {0xfdaf, 3180,  3}, {0xfdb0, 3183,  3}, {0xfdb1, 3186,  3}, 
-       {0xfdb2, 3189,  3}, {0xfdb3, 3192,  3}, {0xfdb4, 3195,  3}, 
-       {0xfdb5, 3198,  3}, {0xfdb6, 3201,  3}, {0xfdb7, 3204,  3}, 
-       {0xfdb8, 3207,  3}, {0xfdb9, 3210,  3}, {0xfdba, 3213,  3}, 
-       {0xfdbb, 3216,  3}, {0xfdbc, 3219,  3}, {0xfdbd, 3222,  3}, 
-       {0xfdbe, 3225,  3}, {0xfdbf, 3228,  3}, {0xfdc0, 3231,  3}, 
-       {0xfdc1, 3234,  3}, {0xfdc2, 3237,  3}, {0xfdc3, 3240,  3}, 
-       {0xfdc4, 3243,  3}, {0xfdc5, 3246,  3}, {0xfdc6, 3249,  3}, 
-       {0xfdc7, 3252,  3}, {0xfdf0, 3255,  3}, {0xfdf1, 3258,  3}, 
-       {0xfdf2, 3261,  4}, {0xfdf3, 3265,  4}, {0xfdf4, 3269,  4}, 
-       {0xfdf5, 3273,  4}, {0xfdf6, 3277,  4}, {0xfdf7, 3281,  4}, 
-       {0xfdf8, 3285,  4}, {0xfdf9, 3289,  3}, {0xfdfa, 3292, 18}, 
-       {0xfdfb, 3310,  8}, {0xfe30, 3318,  1}, {0xfe31, 3319,  1}, 
-       {0xfe32, 3320,  1}, {0xfe33, 3321,  1}, {0xfe34, 3322,  1}, 
-       {0xfe35, 3323,  1}, {0xfe36, 3324,  1}, {0xfe37, 3325,  1}, 
-       {0xfe38, 3326,  1}, {0xfe39, 3327,  1}, {0xfe3a, 3328,  1}, 
-       {0xfe3b, 3329,  1}, {0xfe3c, 3330,  1}, {0xfe3d, 3331,  1}, 
-       {0xfe3e, 3332,  1}, {0xfe3f, 3333,  1}, {0xfe40, 3334,  1}, 
-       {0xfe41, 3335,  1}, {0xfe42, 3336,  1}, {0xfe43, 3337,  1}, 
-       {0xfe44, 3338,  1}, {0xfe49, 3339,  1}, {0xfe4a, 3340,  1}, 
-       {0xfe4b, 3341,  1}, {0xfe4c, 3342,  1}, {0xfe4d, 3343,  1}, 
-       {0xfe4e, 3344,  1}, {0xfe4f, 3345,  1}, {0xfe50, 3346,  1}, 
-       {0xfe51, 3347,  1}, {0xfe52, 3348,  1}, {0xfe54, 3349,  1}, 
-       {0xfe55, 3350,  1}, {0xfe56, 3351,  1}, {0xfe57, 3352,  1}, 
-       {0xfe58, 3353,  1}, {0xfe59, 3354,  1}, {0xfe5a, 3355,  1}, 
-       {0xfe5b, 3356,  1}, {0xfe5c, 3357,  1}, {0xfe5d, 3358,  1}, 
-       {0xfe5e, 3359,  1}, {0xfe5f, 3360,  1}, {0xfe60, 3361,  1}, 
-       {0xfe61, 3362,  1}, {0xfe62, 3363,  1}, {0xfe63, 3364,  1}, 
-       {0xfe64, 3365,  1}, {0xfe65, 3366,  1}, {0xfe66, 3367,  1}, 
-       {0xfe68, 3368,  1}, {0xfe69, 3369,  1}, {0xfe6a, 3370,  1}, 
-       {0xfe6b, 3371,  1}, {0xfe70, 3372,  2}, {0xfe71, 3374,  2}, 
-       {0xfe72, 3376,  2}, {0xfe74, 3378,  2}, {0xfe76, 3380,  2}, 
-       {0xfe77, 3382,  2}, {0xfe78, 3384,  2}, {0xfe79, 3386,  2}, 
-       {0xfe7a, 3388,  2}, {0xfe7b, 3390,  2}, {0xfe7c, 3392,  2}, 
-       {0xfe7d, 3394,  2}, {0xfe7e, 3396,  2}, {0xfe7f, 3398,  2}, 
-       {0xfe80, 3400,  1}, {0xfe81, 3401,  1}, {0xfe82, 3402,  1}, 
-       {0xfe83, 3403,  1}, {0xfe84, 3404,  1}, {0xfe85, 3405,  1}, 
-       {0xfe86, 3406,  1}, {0xfe87, 3407,  1}, {0xfe88, 3408,  1}, 
-       {0xfe89, 3409,  1}, {0xfe8a, 3410,  1}, {0xfe8b, 3411,  1}, 
-       {0xfe8c, 3412,  1}, {0xfe8d, 3413,  1}, {0xfe8e, 3414,  1}, 
-       {0xfe8f, 3415,  1}, {0xfe90, 3416,  1}, {0xfe91, 3417,  1}, 
-       {0xfe92, 3418,  1}, {0xfe93, 3419,  1}, {0xfe94, 3420,  1}, 
-       {0xfe95, 3421,  1}, {0xfe96, 3422,  1}, {0xfe97, 3423,  1}, 
-       {0xfe98, 3424,  1}, {0xfe99, 3425,  1}, {0xfe9a, 3426,  1}, 
-       {0xfe9b, 3427,  1}, {0xfe9c, 3428,  1}, {0xfe9d, 3429,  1}, 
-       {0xfe9e, 3430,  1}, {0xfe9f, 3431,  1}, {0xfea0, 3432,  1}, 
-       {0xfea1, 3433,  1}, {0xfea2, 3434,  1}, {0xfea3, 3435,  1}, 
-       {0xfea4, 3436,  1}, {0xfea5, 3437,  1}, {0xfea6, 3438,  1}, 
-       {0xfea7, 3439,  1}, {0xfea8, 3440,  1}, {0xfea9, 3441,  1}, 
-       {0xfeaa, 3442,  1}, {0xfeab, 3443,  1}, {0xfeac, 3444,  1}, 
-       {0xfead, 3445,  1}, {0xfeae, 3446,  1}, {0xfeaf, 3447,  1}, 
-       {0xfeb0, 3448,  1}, {0xfeb1, 3449,  1}, {0xfeb2, 3450,  1}, 
-       {0xfeb3, 3451,  1}, {0xfeb4, 3452,  1}, {0xfeb5, 3453,  1}, 
-       {0xfeb6, 3454,  1}, {0xfeb7, 3455,  1}, {0xfeb8, 3456,  1}, 
-       {0xfeb9, 3457,  1}, {0xfeba, 3458,  1}, {0xfebb, 3459,  1}, 
-       {0xfebc, 3460,  1}, {0xfebd, 3461,  1}, {0xfebe, 3462,  1}, 
-       {0xfebf, 3463,  1}, {0xfec0, 3464,  1}, {0xfec1, 3465,  1}, 
-       {0xfec2, 3466,  1}, {0xfec3, 3467,  1}, {0xfec4, 3468,  1}, 
-       {0xfec5, 3469,  1}, {0xfec6, 3470,  1}, {0xfec7, 3471,  1}, 
-       {0xfec8, 3472,  1}, {0xfec9, 3473,  1}, {0xfeca, 3474,  1}, 
-       {0xfecb, 3475,  1}, {0xfecc, 3476,  1}, {0xfecd, 3477,  1}, 
-       {0xfece, 3478,  1}, {0xfecf, 3479,  1}, {0xfed0, 3480,  1}, 
-       {0xfed1, 3481,  1}, {0xfed2, 3482,  1}, {0xfed3, 3483,  1}, 
-       {0xfed4, 3484,  1}, {0xfed5, 3485,  1}, {0xfed6, 3486,  1}, 
-       {0xfed7, 3487,  1}, {0xfed8, 3488,  1}, {0xfed9, 3489,  1}, 
-       {0xfeda, 3490,  1}, {0xfedb, 3491,  1}, {0xfedc, 3492,  1}, 
-       {0xfedd, 3493,  1}, {0xfede, 3494,  1}, {0xfedf, 3495,  1}, 
-       {0xfee0, 3496,  1}, {0xfee1, 3497,  1}, {0xfee2, 3498,  1}, 
-       {0xfee3, 3499,  1}, {0xfee4, 3500,  1}, {0xfee5, 3501,  1}, 
-       {0xfee6, 3502,  1}, {0xfee7, 3503,  1}, {0xfee8, 3504,  1}, 
-       {0xfee9, 3505,  1}, {0xfeea, 3506,  1}, {0xfeeb, 3507,  1}, 
-       {0xfeec, 3508,  1}, {0xfeed, 3509,  1}, {0xfeee, 3510,  1}, 
-       {0xfeef, 3511,  1}, {0xfef0, 3512,  1}, {0xfef1, 3513,  1}, 
-       {0xfef2, 3514,  1}, {0xfef3, 3515,  1}, {0xfef4, 3516,  1}, 
-       {0xfef5, 3517,  2}, {0xfef6, 3519,  2}, {0xfef7, 3521,  2}, 
-       {0xfef8, 3523,  2}, {0xfef9, 3525,  2}, {0xfefa, 3527,  2}, 
-       {0xfefb, 3529,  2}, {0xfefc, 3531,  2}, {0xff01, 3533,  1}, 
-       {0xff02, 3534,  1}, {0xff03, 3535,  1}, {0xff04, 3536,  1}, 
-       {0xff05, 3537,  1}, {0xff06, 3538,  1}, {0xff07, 3539,  1}, 
-       {0xff08, 3540,  1}, {0xff09, 3541,  1}, {0xff0a, 3542,  1}, 
-       {0xff0b, 3543,  1}, {0xff0c, 3544,  1}, {0xff0d, 3545,  1}, 
-       {0xff0e, 3546,  1}, {0xff0f, 3547,  1}, {0xff10, 3548,  1}, 
-       {0xff11, 3549,  1}, {0xff12, 3550,  1}, {0xff13, 3551,  1}, 
-       {0xff14, 3552,  1}, {0xff15, 3553,  1}, {0xff16, 3554,  1}, 
-       {0xff17, 3555,  1}, {0xff18, 3556,  1}, {0xff19, 3557,  1}, 
-       {0xff1a, 3558,  1}, {0xff1b, 3559,  1}, {0xff1c, 3560,  1}, 
-       {0xff1d, 3561,  1}, {0xff1e, 3562,  1}, {0xff1f, 3563,  1}, 
-       {0xff20, 3564,  1}, {0xff21, 3565,  1}, {0xff22, 3566,  1}, 
-       {0xff23, 3567,  1}, {0xff24, 3568,  1}, {0xff25, 3569,  1}, 
-       {0xff26, 3570,  1}, {0xff27, 3571,  1}, {0xff28, 3572,  1}, 
-       {0xff29, 3573,  1}, {0xff2a, 3574,  1}, {0xff2b, 3575,  1}, 
-       {0xff2c, 3576,  1}, {0xff2d, 3577,  1}, {0xff2e, 3578,  1}, 
-       {0xff2f, 3579,  1}, {0xff30, 3580,  1}, {0xff31, 3581,  1}, 
-       {0xff32, 3582,  1}, {0xff33, 3583,  1}, {0xff34, 3584,  1}, 
-       {0xff35, 3585,  1}, {0xff36, 3586,  1}, {0xff37, 3587,  1}, 
-       {0xff38, 3588,  1}, {0xff39, 3589,  1}, {0xff3a, 3590,  1}, 
-       {0xff3b, 3591,  1}, {0xff3c, 3592,  1}, {0xff3d, 3593,  1}, 
-       {0xff3e, 3594,  1}, {0xff3f, 3595,  1}, {0xff40, 3596,  1}, 
-       {0xff41, 3597,  1}, {0xff42, 3598,  1}, {0xff43, 3599,  1}, 
-       {0xff44, 3600,  1}, {0xff45, 3601,  1}, {0xff46, 3602,  1}, 
-       {0xff47, 3603,  1}, {0xff48, 3604,  1}, {0xff49, 3605,  1}, 
-       {0xff4a, 3606,  1}, {0xff4b, 3607,  1}, {0xff4c, 3608,  1}, 
-       {0xff4d, 3609,  1}, {0xff4e, 3610,  1}, {0xff4f, 3611,  1}, 
-       {0xff50, 3612,  1}, {0xff51, 3613,  1}, {0xff52, 3614,  1}, 
-       {0xff53, 3615,  1}, {0xff54, 3616,  1}, {0xff55, 3617,  1}, 
-       {0xff56, 3618,  1}, {0xff57, 3619,  1}, {0xff58, 3620,  1}, 
-       {0xff59, 3621,  1}, {0xff5a, 3622,  1}, {0xff5b, 3623,  1}, 
-       {0xff5c, 3624,  1}, {0xff5d, 3625,  1}, {0xff5e, 3626,  1}, 
-       {0xff61, 3627,  1}, {0xff62, 3628,  1}, {0xff63, 3629,  1}, 
-       {0xff64, 3630,  1}, {0xff65, 3631,  1}, {0xff66, 3632,  1}, 
-       {0xff67, 3633,  1}, {0xff68, 3634,  1}, {0xff69, 3635,  1}, 
-       {0xff6a, 3636,  1}, {0xff6b, 3637,  1}, {0xff6c, 3638,  1}, 
-       {0xff6d, 3639,  1}, {0xff6e, 3640,  1}, {0xff6f, 3641,  1}, 
-       {0xff70, 3642,  1}, {0xff71, 3643,  1}, {0xff72, 3644,  1}, 
-       {0xff73, 3645,  1}, {0xff74, 3646,  1}, {0xff75, 3647,  1}, 
-       {0xff76, 3648,  1}, {0xff77, 3649,  1}, {0xff78, 3650,  1}, 
-       {0xff79, 3651,  1}, {0xff7a, 3652,  1}, {0xff7b, 3653,  1}, 
-       {0xff7c, 3654,  1}, {0xff7d, 3655,  1}, {0xff7e, 3656,  1}, 
-       {0xff7f, 3657,  1}, {0xff80, 3658,  1}, {0xff81, 3659,  1}, 
-       {0xff82, 3660,  1}, {0xff83, 3661,  1}, {0xff84, 3662,  1}, 
-       {0xff85, 3663,  1}, {0xff86, 3664,  1}, {0xff87, 3665,  1}, 
-       {0xff88, 3666,  1}, {0xff89, 3667,  1}, {0xff8a, 3668,  1}, 
-       {0xff8b, 3669,  1}, {0xff8c, 3670,  1}, {0xff8d, 3671,  1}, 
-       {0xff8e, 3672,  1}, {0xff8f, 3673,  1}, {0xff90, 3674,  1}, 
-       {0xff91, 3675,  1}, {0xff92, 3676,  1}, {0xff93, 3677,  1}, 
-       {0xff94, 3678,  1}, {0xff95, 3679,  1}, {0xff96, 3680,  1}, 
-       {0xff97, 3681,  1}, {0xff98, 3682,  1}, {0xff99, 3683,  1}, 
-       {0xff9a, 3684,  1}, {0xff9b, 3685,  1}, {0xff9c, 3686,  1}, 
-       {0xff9d, 3687,  1}, {0xff9e, 3688,  1}, {0xff9f, 3689,  1}, 
-       {0xffa0, 3690,  1}, {0xffa1, 3691,  1}, {0xffa2, 3692,  1}, 
-       {0xffa3, 3693,  1}, {0xffa4, 3694,  1}, {0xffa5, 3695,  1}, 
-       {0xffa6, 3696,  1}, {0xffa7, 3697,  1}, {0xffa8, 3698,  1}, 
-       {0xffa9, 3699,  1}, {0xffaa, 3700,  1}, {0xffab, 3701,  1}, 
-       {0xffac, 3702,  1}, {0xffad, 3703,  1}, {0xffae, 3704,  1}, 
-       {0xffaf, 3705,  1}, {0xffb0, 3706,  1}, {0xffb1, 3707,  1}, 
-       {0xffb2, 3708,  1}, {0xffb3, 3709,  1}, {0xffb4, 3710,  1}, 
-       {0xffb5, 3711,  1}, {0xffb6, 3712,  1}, {0xffb7, 3713,  1}, 
-       {0xffb8, 3714,  1}, {0xffb9, 3715,  1}, {0xffba, 3716,  1}, 
-       {0xffbb, 3717,  1}, {0xffbc, 3718,  1}, {0xffbd, 3719,  1}, 
-       {0xffbe, 3720,  1}, {0xffc2, 3721,  1}, {0xffc3, 3722,  1}, 
-       {0xffc4, 3723,  1}, {0xffc5, 3724,  1}, {0xffc6, 3725,  1}, 
-       {0xffc7, 3726,  1}, {0xffca, 3727,  1}, {0xffcb, 3728,  1}, 
-       {0xffcc, 3729,  1}, {0xffcd, 3730,  1}, {0xffce, 3731,  1}, 
-       {0xffcf, 3732,  1}, {0xffd2, 3733,  1}, {0xffd3, 3734,  1}, 
-       {0xffd4, 3735,  1}, {0xffd5, 3736,  1}, {0xffd6, 3737,  1}, 
-       {0xffd7, 3738,  1}, {0xffda, 3739,  1}, {0xffdb, 3740,  1}, 
-       {0xffdc, 3741,  1}, {0xffe0, 3742,  1}, {0xffe1, 3743,  1}, 
-       {0xffe2, 3744,  1}, {0xffe3, 3745,  1}, {0xffe4, 3746,  1}, 
-       {0xffe5, 3747,  1}, {0xffe6, 3748,  1}, {0xffe8, 3749,  1}, 
-       {0xffe9, 3750,  1}, {0xffea, 3751,  1}, {0xffeb, 3752,  1}, 
-       {0xffec, 3753,  1}, {0xffed, 3754,  1}, {0xffee, 3755,  1}, 
-};
-
-static unicode_t compat_decompose_data[] = {
-          32,    32,   776,    97,    32,   772,    50,    51,    32,   769, 
-         956,    32,   807,    49,   111,    49,  8260,    52,    49,  8260, 
-          50,    51,  8260,    52,    73,    74,   105,   106,    76,   183, 
-         108,   183,   700,   110,   115,    68,   381,    68,   382,   100, 
-         382,    76,    74,    76,   106,   108,   106,    78,    74,    78, 
-         106,   110,   106,    68,    90,    68,   122,   100,   122,   104, 
-         614,   106,   114,   633,   635,   641,   119,   121,    32,   774, 
-          32,   775,    32,   778,    32,   808,    32,   771,    32,   779, 
-         611,   108,   115,   120,   661,    32,   837,    32,   769,   946, 
-         952,   933,   966,   960,   954,   961,   962,  1381,  1410,  1575, 
-        1652,  1608,  1652,  1735,  1652,  1610,  1652,  3661,  3634,  3789, 
-        3762,  3755,  3737,  3755,  3745,  3851,  4018,  3969,  4019,  3969, 
-          97,   702,    32,   787,    32,   787,    32,   834,    32,   788, 
-          32,    32,    32,    32,    32,    32,    32,    32,    32,  8208, 
-          32,   819,    46,    46,    46,    46,    46,    46,    32,  8242, 
-        8242,  8242,  8242,  8242,  8245,  8245,  8245,  8245,  8245,    33, 
-          33,    32,   773,    63,    33,    33,    63,    48,    52,    53, 
-          54,    55,    56,    57,    43,  8722,    61,    40,    41,   110, 
-          48,    49,    50,    51,    52,    53,    54,    55,    56,    57, 
-          43,  8722,    61,    40,    41,    82,   115,    97,    47,    99, 
-          97,    47,   115,    67,   176,    67,    99,    47,   111,    99, 
-          47,   117,   400,   176,    70,   103,    72,    72,    72,   104, 
-         295,    73,    73,    76,   108,    78,    78,   111,    80,    81, 
-          82,    82,    82,    83,    77,    84,    69,    76,    84,    77, 
-          90,    90,    66,    67,   101,    69,    70,    77,   111,  1488, 
-        1489,  1490,  1491,   105,    49,  8260,    51,    50,  8260,    51, 
-          49,  8260,    53,    50,  8260,    53,    51,  8260,    53,    52, 
-        8260,    53,    49,  8260,    54,    53,  8260,    54,    49,  8260, 
-          56,    51,  8260,    56,    53,  8260,    56,    55,  8260,    56, 
-          49,  8260,    73,    73,    73,    73,    73,    73,    73,    86, 
-          86,    86,    73,    86,    73,    73,    86,    73,    73,    73, 
-          73,    88,    88,    88,    73,    88,    73,    73,    76,    67, 
-          68,    77,   105,   105,   105,   105,   105,   105,   105,   118, 
-         118,   118,   105,   118,   105,   105,   118,   105,   105,   105, 
-         105,   120,   120,   120,   105,   120,   105,   105,   108,    99, 
-         100,   109,  8747,  8747,  8747,  8747,  8747,  8750,  8750,  8750, 
-        8750,  8750,    49,    50,    51,    52,    53,    54,    55,    56, 
-          57,    49,    48,    49,    49,    49,    50,    49,    51,    49, 
-          52,    49,    53,    49,    54,    49,    55,    49,    56,    49, 
-          57,    50,    48,    40,    49,    41,    40,    50,    41,    40, 
-          51,    41,    40,    52,    41,    40,    53,    41,    40,    54, 
-          41,    40,    55,    41,    40,    56,    41,    40,    57,    41, 
-          40,    49,    48,    41,    40,    49,    49,    41,    40,    49, 
-          50,    41,    40,    49,    51,    41,    40,    49,    52,    41, 
-          40,    49,    53,    41,    40,    49,    54,    41,    40,    49, 
-          55,    41,    40,    49,    56,    41,    40,    49,    57,    41, 
-          40,    50,    48,    41,    49,    46,    50,    46,    51,    46, 
-          52,    46,    53,    46,    54,    46,    55,    46,    56,    46, 
-          57,    46,    49,    48,    46,    49,    49,    46,    49,    50, 
-          46,    49,    51,    46,    49,    52,    46,    49,    53,    46, 
-          49,    54,    46,    49,    55,    46,    49,    56,    46,    49, 
-          57,    46,    50,    48,    46,    40,    97,    41,    40,    98, 
-          41,    40,    99,    41,    40,   100,    41,    40,   101,    41, 
-          40,   102,    41,    40,   103,    41,    40,   104,    41,    40, 
-         105,    41,    40,   106,    41,    40,   107,    41,    40,   108, 
-          41,    40,   109,    41,    40,   110,    41,    40,   111,    41, 
-          40,   112,    41,    40,   113,    41,    40,   114,    41,    40, 
-         115,    41,    40,   116,    41,    40,   117,    41,    40,   118, 
-          41,    40,   119,    41,    40,   120,    41,    40,   121,    41, 
-          40,   122,    41,    65,    66,    67,    68,    69,    70,    71, 
-          72,    73,    74,    75,    76,    77,    78,    79,    80,    81, 
-          82,    83,    84,    85,    86,    87,    88,    89,    90,    97, 
-          98,    99,   100,   101,   102,   103,   104,   105,   106,   107, 
-         108,   109,   110,   111,   112,   113,   114,   115,   116,   117, 
-         118,   119,   120,   121,   122,    48, 27597, 40863, 19968, 20008, 
-       20022, 20031, 20057, 20101, 20108, 20128, 20154, 20799, 20837, 20843, 
-       20866, 20886, 20907, 20960, 20981, 20992, 21147, 21241, 21269, 21274, 
-       21304, 21313, 21340, 21353, 21378, 21430, 21448, 21475, 22231, 22303, 
-       22763, 22786, 22794, 22805, 22823, 22899, 23376, 23424, 23544, 23567, 
-       23586, 23608, 23662, 23665, 24027, 24037, 24049, 24062, 24178, 24186, 
-       24191, 24308, 24318, 24331, 24339, 24400, 24417, 24435, 24515, 25096, 
-       25142, 25163, 25903, 25908, 25991, 26007, 26020, 26041, 26080, 26085, 
-       26352, 26376, 26408, 27424, 27490, 27513, 27571, 27595, 27604, 27611, 
-       27663, 27668, 27700, 28779, 29226, 29238, 29243, 29247, 29255, 29273, 
-       29275, 29356, 29572, 29577, 29916, 29926, 29976, 29983, 29992, 30000, 
-       30091, 30098, 30326, 30333, 30382, 30399, 30446, 30683, 30690, 30707, 
-       31034, 31160, 31166, 31348, 31435, 31481, 31859, 31992, 32566, 32593, 
-       32650, 32701, 32769, 32780, 32786, 32819, 32895, 32905, 33251, 33258, 
-       33267, 33276, 33292, 33307, 33311, 33390, 33394, 33400, 34381, 34411, 
-       34880, 34892, 34915, 35198, 35211, 35282, 35328, 35895, 35910, 35925, 
-       35960, 35997, 36196, 36208, 36275, 36523, 36554, 36763, 36784, 36789, 
-       37009, 37193, 37318, 37324, 37329, 38263, 38272, 38428, 38582, 38585, 
-       38632, 38737, 38750, 38754, 38761, 38859, 38893, 38899, 38913, 39080, 
-       39131, 39135, 39318, 39321, 39340, 39592, 39640, 39647, 39717, 39727, 
-       39730, 39740, 39770, 40165, 40565, 40575, 40613, 40635, 40643, 40653, 
-       40657, 40697, 40701, 40718, 40723, 40736, 40763, 40778, 40786, 40845, 
-       40860, 40864,    32, 12306, 21313, 21316, 21317,    32, 12441,    32, 
-       12442,  4352,  4353,  4522,  4354,  4524,  4525,  4355,  4356,  4357, 
-        4528,  4529,  4530,  4531,  4532,  4533,  4378,  4358,  4359,  4360, 
-        4385,  4361,  4362,  4363,  4364,  4365,  4366,  4367,  4368,  4369, 
-        4370,  4449,  4450,  4451,  4452,  4453,  4454,  4455,  4456,  4457, 
-        4458,  4459,  4460,  4461,  4462,  4463,  4464,  4465,  4466,  4467, 
-        4468,  4469,  4448,  4372,  4373,  4551,  4552,  4556,  4558,  4563, 
-        4567,  4569,  4380,  4573,  4575,  4381,  4382,  4384,  4386,  4387, 
-        4391,  4393,  4395,  4396,  4397,  4398,  4399,  4402,  4406,  4416, 
-        4423,  4428,  4593,  4594,  4439,  4440,  4441,  4484,  4485,  4488, 
-        4497,  4498,  4500,  4510,  4513, 19968, 20108, 19977, 22235, 19978, 
-       20013, 19979, 30002, 20057, 19993, 19969, 22825, 22320, 20154,    40, 
-        4352,    41,    40,  4354,    41,    40,  4355,    41,    40,  4357, 
-          41,    40,  4358,    41,    40,  4359,    41,    40,  4361,    41, 
-          40,  4363,    41,    40,  4364,    41,    40,  4366,    41,    40, 
-        4367,    41,    40,  4368,    41,    40,  4369,    41,    40,  4370, 
-          41,    40,  4352,  4449,    41,    40,  4354,  4449,    41,    40, 
-        4355,  4449,    41,    40,  4357,  4449,    41,    40,  4358,  4449, 
-          41,    40,  4359,  4449,    41,    40,  4361,  4449,    41,    40, 
-        4363,  4449,    41,    40,  4364,  4449,    41,    40,  4366,  4449, 
-          41,    40,  4367,  4449,    41,    40,  4368,  4449,    41,    40, 
-        4369,  4449,    41,    40,  4370,  4449,    41,    40,  4364,  4462, 
-          41,    40, 19968,    41,    40, 20108,    41,    40, 19977,    41, 
-          40, 22235,    41,    40, 20116,    41,    40, 20845,    41,    40, 
-       19971,    41,    40, 20843,    41,    40, 20061,    41,    40, 21313, 
-          41,    40, 26376,    41,    40, 28779,    41,    40, 27700,    41, 
-          40, 26408,    41,    40, 37329,    41,    40, 22303,    41,    40, 
-       26085,    41,    40, 26666,    41,    40, 26377,    41,    40, 31038, 
-          41,    40, 21517,    41,    40, 29305,    41,    40, 36001,    41, 
-          40, 31069,    41,    40, 21172,    41,    40, 20195,    41,    40, 
-       21628,    41,    40, 23398,    41,    40, 30435,    41,    40, 20225, 
-          41,    40, 36039,    41,    40, 21332,    41,    40, 31085,    41, 
-          40, 20241,    41,    40, 33258,    41,    40, 33267,    41,  4352, 
-        4354,  4355,  4357,  4358,  4359,  4361,  4363,  4364,  4366,  4367, 
-        4368,  4369,  4370,  4352,  4449,  4354,  4449,  4355,  4449,  4357, 
-        4449,  4358,  4449,  4359,  4449,  4361,  4449,  4363,  4449,  4364, 
-        4449,  4366,  4449,  4367,  4449,  4368,  4449,  4369,  4449,  4370, 
-        4449, 19968, 20108, 19977, 22235, 20116, 20845, 19971, 20843, 20061, 
-       21313, 26376, 28779, 27700, 26408, 37329, 22303, 26085, 26666, 26377, 
-       31038, 21517, 29305, 36001, 31069, 21172, 31192, 30007, 22899, 36969, 
-       20778, 21360, 27880, 38917, 20241, 20889, 27491, 19978, 20013, 19979, 
-       24038, 21491, 21307, 23447, 23398, 30435, 20225, 36039, 21332, 22812, 
-          49, 26376,    50, 26376,    51, 26376,    52, 26376,    53, 26376, 
-          54, 26376,    55, 26376,    56, 26376,    57, 26376,    49,    48, 
-       26376,    49,    49, 26376,    49,    50, 26376, 12450, 12452, 12454, 
-       12456, 12458, 12459, 12461, 12463, 12465, 12467, 12469, 12471, 12473, 
-       12475, 12477, 12479, 12481, 12484, 12486, 12488, 12490, 12491, 12492, 
-       12493, 12494, 12495, 12498, 12501, 12504, 12507, 12510, 12511, 12512, 
-       12513, 12514, 12516, 12518, 12520, 12521, 12522, 12523, 12524, 12525, 
-       12527, 12528, 12529, 12530, 12450, 12497, 12540, 12488, 12450, 12523, 
-       12501, 12449, 12450, 12531, 12506, 12450, 12450, 12540, 12523, 12452, 
-       12491, 12531, 12464, 12452, 12531, 12481, 12454, 12457, 12531, 12456, 
-       12473, 12463, 12540, 12489, 12456, 12540, 12459, 12540, 12458, 12531, 
-       12473, 12458, 12540, 12512, 12459, 12452, 12522, 12459, 12521, 12483, 
-       12488, 12459, 12525, 12522, 12540, 12460, 12525, 12531, 12460, 12531, 
-       12510, 12462, 12460, 12462, 12491, 12540, 12461, 12517, 12522, 12540, 
-       12462, 12523, 12480, 12540, 12461, 12525, 12461, 12525, 12464, 12521, 
-       12512, 12461, 12525, 12513, 12540, 12488, 12523, 12461, 12525, 12527, 
-       12483, 12488, 12464, 12521, 12512, 12464, 12521, 12512, 12488, 12531, 
-       12463, 12523, 12476, 12452, 12525, 12463, 12525, 12540, 12493, 12465, 
-       12540, 12473, 12467, 12523, 12490, 12467, 12540, 12509, 12469, 12452, 
-       12463, 12523, 12469, 12531, 12481, 12540, 12512, 12471, 12522, 12531, 
-       12464, 12475, 12531, 12481, 12475, 12531, 12488, 12480, 12540, 12473, 
-       12487, 12471, 12489, 12523, 12488, 12531, 12490, 12494, 12494, 12483, 
-       12488, 12495, 12452, 12484, 12497, 12540, 12475, 12531, 12488, 12497, 
-       12540, 12484, 12496, 12540, 12524, 12523, 12500, 12450, 12473, 12488, 
-       12523, 12500, 12463, 12523, 12500, 12467, 12499, 12523, 12501, 12449, 
-       12521, 12483, 12489, 12501, 12451, 12540, 12488, 12502, 12483, 12471, 
-       12455, 12523, 12501, 12521, 12531, 12504, 12463, 12479, 12540, 12523, 
-       12506, 12477, 12506, 12491, 12498, 12504, 12523, 12484, 12506, 12531, 
-       12473, 12506, 12540, 12472, 12505, 12540, 12479, 12509, 12452, 12531, 
-       12488, 12508, 12523, 12488, 12507, 12531, 12509, 12531, 12489, 12507, 
-       12540, 12523, 12507, 12540, 12531, 12510, 12452, 12463, 12525, 12510, 
-       12452, 12523, 12510, 12483, 12495, 12510, 12523, 12463, 12510, 12531, 
-       12471, 12519, 12531, 12511, 12463, 12525, 12531, 12511, 12522, 12511, 
-       12522, 12496, 12540, 12523, 12513, 12460, 12513, 12460, 12488, 12531, 
-       12513, 12540, 12488, 12523, 12516, 12540, 12489, 12516, 12540, 12523, 
-       12518, 12450, 12531, 12522, 12483, 12488, 12523, 12522, 12521, 12523, 
-       12500, 12540, 12523, 12540, 12502, 12523, 12524, 12512, 12524, 12531, 
-       12488, 12466, 12531, 12527, 12483, 12488,    48, 28857,    49, 28857, 
-          50, 28857,    51, 28857,    52, 28857,    53, 28857,    54, 28857, 
-          55, 28857,    56, 28857,    57, 28857,    49,    48, 28857,    49, 
-          49, 28857,    49,    50, 28857,    49,    51, 28857,    49,    52, 
-       28857,    49,    53, 28857,    49,    54, 28857,    49,    55, 28857, 
-          49,    56, 28857,    49,    57, 28857,    50,    48, 28857,    50, 
-          49, 28857,    50,    50, 28857,    50,    51, 28857,    50,    52, 
-       28857,   104,    80,    97,   100,    97,    65,    85,    98,    97, 
-         114,   111,    86,   112,    99, 24179, 25104, 26157, 21644, 22823, 
-       27491, 26126, 27835, 26666, 24335, 20250, 31038,   112,    65,   110, 
-          65,   956,    65,   109,    65,   107,    65,    75,    66,    77, 
-          66,    71,    66,    99,    97,   108,   107,    99,    97,   108, 
-         112,    70,   110,    70,   956,    70,   956,   103,   109,   103, 
-         107,   103,    72,   122,   107,    72,   122,    77,    72,   122, 
-          71,    72,   122,    84,    72,   122,   956,  8467,   109,  8467, 
-         100,  8467,   107,  8467,   102,   109,   110,   109,   956,   109, 
-         109,   109,    99,   109,   107,   109,   109,   109,   178,    99, 
-         109,   178,   109,   178,   107,   109,   178,   109,   109,   179, 
-          99,   109,   179,   109,   179,   107,   109,   179,   109,  8725, 
-         115,   109,  8725,   115,   178,    80,    97,   107,    80,    97, 
-          77,    80,    97,    71,    80,    97,   114,    97,   100,   114, 
-          97,   100,  8725,   115,   114,    97,   100,  8725,   115,   178, 
-         112,   115,   110,   115,   956,   115,   109,   115,   112,    86, 
-         110,    86,   956,    86,   109,    86,   107,    86,    77,    86, 
-         112,    87,   110,    87,   956,    87,   109,    87,   107,    87, 
-          77,    87,   107,   937,    77,   937,    97,    46,   109,    46, 
-          66,   113,    99,    99,    99,   100,    67,  8725,   107,   103, 
-          67,   111,    46,   100,    66,    71,   121,   104,    97,    72, 
-          80,   105,   110,    75,    75,    75,    77,   107,   116,   108, 
-         109,   108,   110,   108,   111,   103,   108,   120,   109,    98, 
-         109,   105,   108,   109,   111,   108,    80,    72,   112,    46, 
-         109,    46,    80,    80,    77,    80,    82,   115,   114,    83, 
-         118,    87,    98,    49, 26085,    50, 26085,    51, 26085,    52, 
-       26085,    53, 26085,    54, 26085,    55, 26085,    56, 26085,    57, 
-       26085,    49,    48, 26085,    49,    49, 26085,    49,    50, 26085, 
-          49,    51, 26085,    49,    52, 26085,    49,    53, 26085,    49, 
-          54, 26085,    49,    55, 26085,    49,    56, 26085,    49,    57, 
-       26085,    50,    48, 26085,    50,    49, 26085,    50,    50, 26085, 
-          50,    51, 26085,    50,    52, 26085,    50,    53, 26085,    50, 
-          54, 26085,    50,    55, 26085,    50,    56, 26085,    50,    57, 
-       26085,    51,    48, 26085,    51,    49, 26085,   102,   102,   102, 
-         105,   102,   108,   102,   102,   105,   102,   102,   108,   383, 
-         116,   115,   116,  1396,  1398,  1396,  1381,  1396,  1387,  1406, 
-        1398,  1396,  1389,  1506,  1488,  1491,  1492,  1499,  1500,  1501, 
-        1512,  1514,    43,  1488,  1500,  1649,  1649,  1659,  1659,  1659, 
-        1659,  1662,  1662,  1662,  1662,  1664,  1664,  1664,  1664,  1658, 
-        1658,  1658,  1658,  1663,  1663,  1663,  1663,  1657,  1657,  1657, 
-        1657,  1700,  1700,  1700,  1700,  1702,  1702,  1702,  1702,  1668, 
-        1668,  1668,  1668,  1667,  1667,  1667,  1667,  1670,  1670,  1670, 
-        1670,  1671,  1671,  1671,  1671,  1677,  1677,  1676,  1676,  1678, 
-        1678,  1672,  1672,  1688,  1688,  1681,  1681,  1705,  1705,  1705, 
-        1705,  1711,  1711,  1711,  1711,  1715,  1715,  1715,  1715,  1713, 
-        1713,  1713,  1713,  1722,  1722,  1723,  1723,  1723,  1723,  1728, 
-        1728,  1729,  1729,  1729,  1729,  1726,  1726,  1726,  1726,  1746, 
-        1746,  1747,  1747,  1709,  1709,  1709,  1709,  1735,  1735,  1734, 
-        1734,  1736,  1736,  1655,  1739,  1739,  1733,  1733,  1737,  1737, 
-        1744,  1744,  1744,  1744,  1609,  1609,  1574,  1575,  1574,  1575, 
-        1574,  1749,  1574,  1749,  1574,  1608,  1574,  1608,  1574,  1735, 
-        1574,  1735,  1574,  1734,  1574,  1734,  1574,  1736,  1574,  1736, 
-        1574,  1744,  1574,  1744,  1574,  1744,  1574,  1609,  1574,  1609, 
-        1574,  1609,  1740,  1740,  1740,  1740,  1574,  1580,  1574,  1581, 
-        1574,  1605,  1574,  1609,  1574,  1610,  1576,  1580,  1576,  1581, 
-        1576,  1582,  1576,  1605,  1576,  1609,  1576,  1610,  1578,  1580, 
-        1578,  1581,  1578,  1582,  1578,  1605,  1578,  1609,  1578,  1610, 
-        1579,  1580,  1579,  1605,  1579,  1609,  1579,  1610,  1580,  1581, 
-        1580,  1605,  1581,  1580,  1581,  1605,  1582,  1580,  1582,  1581, 
-        1582,  1605,  1587,  1580,  1587,  1581,  1587,  1582,  1587,  1605, 
-        1589,  1581,  1589,  1605,  1590,  1580,  1590,  1581,  1590,  1582, 
-        1590,  1605,  1591,  1581,  1591,  1605,  1592,  1605,  1593,  1580, 
-        1593,  1605,  1594,  1580,  1594,  1605,  1601,  1580,  1601,  1581, 
-        1601,  1582,  1601,  1605,  1601,  1609,  1601,  1610,  1602,  1581, 
-        1602,  1605,  1602,  1609,  1602,  1610,  1603,  1575,  1603,  1580, 
-        1603,  1581,  1603,  1582,  1603,  1604,  1603,  1605,  1603,  1609, 
-        1603,  1610,  1604,  1580,  1604,  1581,  1604,  1582,  1604,  1605, 
-        1604,  1609,  1604,  1610,  1605,  1580,  1605,  1581,  1605,  1582, 
-        1605,  1605,  1605,  1609,  1605,  1610,  1606,  1580,  1606,  1581, 
-        1606,  1582,  1606,  1605,  1606,  1609,  1606,  1610,  1607,  1580, 
-        1607,  1605,  1607,  1609,  1607,  1610,  1610,  1580,  1610,  1581, 
-        1610,  1582,  1610,  1605,  1610,  1609,  1610,  1610,  1584,  1648, 
-        1585,  1648,  1609,  1648,    32,  1612,  1617,    32,  1613,  1617, 
-          32,  1614,  1617,    32,  1615,  1617,    32,  1616,  1617,    32, 
-        1617,  1648,  1574,  1585,  1574,  1586,  1574,  1605,  1574,  1606, 
-        1574,  1609,  1574,  1610,  1576,  1585,  1576,  1586,  1576,  1605, 
-        1576,  1606,  1576,  1609,  1576,  1610,  1578,  1585,  1578,  1586, 
-        1578,  1605,  1578,  1606,  1578,  1609,  1578,  1610,  1579,  1585, 
-        1579,  1586,  1579,  1605,  1579,  1606,  1579,  1609,  1579,  1610, 
-        1601,  1609,  1601,  1610,  1602,  1609,  1602,  1610,  1603,  1575, 
-        1603,  1604,  1603,  1605,  1603,  1609,  1603,  1610,  1604,  1605, 
-        1604,  1609,  1604,  1610,  1605,  1575,  1605,  1605,  1606,  1585, 
-        1606,  1586,  1606,  1605,  1606,  1606,  1606,  1609,  1606,  1610, 
-        1609,  1648,  1610,  1585,  1610,  1586,  1610,  1605,  1610,  1606, 
-        1610,  1609,  1610,  1610,  1574,  1580,  1574,  1581,  1574,  1582, 
-        1574,  1605,  1574,  1607,  1576,  1580,  1576,  1581,  1576,  1582, 
-        1576,  1605,  1576,  1607,  1578,  1580,  1578,  1581,  1578,  1582, 
-        1578,  1605,  1578,  1607,  1579,  1605,  1580,  1581,  1580,  1605, 
-        1581,  1580,  1581,  1605,  1582,  1580,  1582,  1605,  1587,  1580, 
-        1587,  1581,  1587,  1582,  1587,  1605,  1589,  1581,  1589,  1582, 
-        1589,  1605,  1590,  1580,  1590,  1581,  1590,  1582,  1590,  1605, 
-        1591,  1581,  1592,  1605,  1593,  1580,  1593,  1605,  1594,  1580, 
-        1594,  1605,  1601,  1580,  1601,  1581,  1601,  1582,  1601,  1605, 
-        1602,  1581,  1602,  1605,  1603,  1580,  1603,  1581,  1603,  1582, 
-        1603,  1604,  1603,  1605,  1604,  1580,  1604,  1581,  1604,  1582, 
-        1604,  1605,  1604,  1607,  1605,  1580,  1605,  1581,  1605,  1582, 
-        1605,  1605,  1606,  1580,  1606,  1581,  1606,  1582,  1606,  1605, 
-        1606,  1607,  1607,  1580,  1607,  1605,  1607,  1648,  1610,  1580, 
-        1610,  1581,  1610,  1582,  1610,  1605,  1610,  1607,  1574,  1605, 
-        1574,  1607,  1576,  1605,  1576,  1607,  1578,  1605,  1578,  1607, 
-        1579,  1605,  1579,  1607,  1587,  1605,  1587,  1607,  1588,  1605, 
-        1588,  1607,  1603,  1604,  1603,  1605,  1604,  1605,  1606,  1605, 
-        1606,  1607,  1610,  1605,  1610,  1607,  1600,  1614,  1617,  1600, 
-        1615,  1617,  1600,  1616,  1617,  1591,  1609,  1591,  1610,  1593, 
-        1609,  1593,  1610,  1594,  1609,  1594,  1610,  1587,  1609,  1587, 
-        1610,  1588,  1609,  1588,  1610,  1581,  1609,  1581,  1610,  1580, 
-        1609,  1580,  1610,  1582,  1609,  1582,  1610,  1589,  1609,  1589, 
-        1610,  1590,  1609,  1590,  1610,  1588,  1580,  1588,  1581,  1588, 
-        1582,  1588,  1605,  1588,  1585,  1587,  1585,  1589,  1585,  1590, 
-        1585,  1591,  1609,  1591,  1610,  1593,  1609,  1593,  1610,  1594, 
-        1609,  1594,  1610,  1587,  1609,  1587,  1610,  1588,  1609,  1588, 
-        1610,  1581,  1609,  1581,  1610,  1580,  1609,  1580,  1610,  1582, 
-        1609,  1582,  1610,  1589,  1609,  1589,  1610,  1590,  1609,  1590, 
-        1610,  1588,  1580,  1588,  1581,  1588,  1582,  1588,  1605,  1588, 
-        1585,  1587,  1585,  1589,  1585,  1590,  1585,  1588,  1580,  1588, 
-        1581,  1588,  1582,  1588,  1605,  1587,  1607,  1588,  1607,  1591, 
-        1605,  1587,  1580,  1587,  1581,  1587,  1582,  1588,  1580,  1588, 
-        1581,  1588,  1582,  1591,  1605,  1592,  1605,  1575,  1611,  1575, 
-        1611,  1578,  1580,  1605,  1578,  1581,  1580,  1578,  1581,  1580, 
-        1578,  1581,  1605,  1578,  1582,  1605,  1578,  1605,  1580,  1578, 
-        1605,  1581,  1578,  1605,  1582,  1580,  1605,  1581,  1580,  1605, 
-        1581,  1581,  1605,  1610,  1581,  1605,  1609,  1587,  1581,  1580, 
-        1587,  1580,  1581,  1587,  1580,  1609,  1587,  1605,  1581,  1587, 
-        1605,  1581,  1587,  1605,  1580,  1587,  1605,  1605,  1587,  1605, 
-        1605,  1589,  1581,  1581,  1589,  1581,  1581,  1589,  1605,  1605, 
-        1588,  1581,  1605,  1588,  1581,  1605,  1588,  1580,  1610,  1588, 
-        1605,  1582,  1588,  1605,  1582,  1588,  1605,  1605,  1588,  1605, 
-        1605,  1590,  1581,  1609,  1590,  1582,  1605,  1590,  1582,  1605, 
-        1591,  1605,  1581,  1591,  1605,  1581,  1591,  1605,  1605,  1591, 
-        1605,  1610,  1593,  1580,  1605,  1593,  1605,  1605,  1593,  1605, 
-        1605,  1593,  1605,  1609,  1594,  1605,  1605,  1594,  1605,  1610, 
-        1594,  1605,  1609,  1601,  1582,  1605,  1601,  1582,  1605,  1602, 
-        1605,  1581,  1602,  1605,  1605,  1604,  1581,  1605,  1604,  1581, 
-        1610,  1604,  1581,  1609,  1604,  1580,  1580,  1604,  1580,  1580, 
-        1604,  1582,  1605,  1604,  1582,  1605,  1604,  1605,  1581,  1604, 
-        1605,  1581,  1605,  1581,  1580,  1605,  1581,  1605,  1605,  1581, 
-        1610,  1605,  1580,  1581,  1605,  1580,  1605,  1605,  1582,  1580, 
-        1605,  1582,  1605,  1605,  1580,  1582,  1607,  1605,  1580,  1607, 
-        1605,  1605,  1606,  1581,  1605,  1606,  1581,  1609,  1606,  1580, 
-        1605,  1606,  1580,  1605,  1606,  1580,  1609,  1606,  1605,  1610, 
-        1606,  1605,  1609,  1610,  1605,  1605,  1610,  1605,  1605,  1576, 
-        1582,  1610,  1578,  1580,  1610,  1578,  1580,  1609,  1578,  1582, 
-        1610,  1578,  1582,  1609,  1578,  1605,  1610,  1578,  1605,  1609, 
-        1580,  1605,  1610,  1580,  1581,  1609,  1580,  1605,  1609,  1587, 
-        1582,  1609,  1589,  1581,  1610,  1588,  1581,  1610,  1590,  1581, 
-        1610,  1604,  1580,  1610,  1604,  1605,  1610,  1610,  1581,  1610, 
-        1610,  1580,  1610,  1610,  1605,  1610,  1605,  1605,  1610,  1602, 
-        1605,  1610,  1606,  1581,  1610,  1602,  1605,  1581,  1604,  1581, 
-        1605,  1593,  1605,  1610,  1603,  1605,  1610,  1606,  1580,  1581, 
-        1605,  1582,  1610,  1604,  1580,  1605,  1603,  1605,  1605,  1604, 
-        1580,  1605,  1606,  1580,  1581,  1580,  1581,  1610,  1581,  1580, 
-        1610,  1605,  1580,  1610,  1601,  1605,  1610,  1576,  1581,  1610, 
-        1603,  1605,  1605,  1593,  1580,  1605,  1589,  1605,  1605,  1587, 
-        1582,  1610,  1606,  1580,  1610,  1589,  1604,  1746,  1602,  1604, 
-        1746,  1575,  1604,  1604,  1607,  1575,  1603,  1576,  1585,  1605, 
-        1581,  1605,  1583,  1589,  1604,  1593,  1605,  1585,  1587,  1608, 
-        1604,  1593,  1604,  1610,  1607,  1608,  1587,  1604,  1605,  1589, 
-        1604,  1609,  1589,  1604,  1609,    32,  1575,  1604,  1604,  1607, 
-          32,  1593,  1604,  1610,  1607,    32,  1608,  1587,  1604,  1605, 
-        1580,  1604,    32,  1580,  1604,  1575,  1604,  1607,  8229,  8212, 
-        8211,    95,    95,    40,    41,   123,   125, 12308, 12309, 12304, 
-       12305, 12298, 12299, 12296, 12297, 12300, 12301, 12302, 12303,  8254, 
-        8254,  8254,  8254,    95,    95,    95,    44, 12289,    46,    59, 
-          58,    63,    33,  8212,    40,    41,   123,   125, 12308, 12309, 
-          35,    38,    42,    43,    45,    60,    62,    61,    92,    36, 
-          37,    64,    32,  1611,  1600,  1611,    32,  1612,    32,  1613, 
-          32,  1614,  1600,  1614,    32,  1615,  1600,  1615,    32,  1616, 
-        1600,  1616,    32,  1617,  1600,  1617,    32,  1618,  1600,  1618, 
-        1569,  1570,  1570,  1571,  1571,  1572,  1572,  1573,  1573,  1574, 
-        1574,  1574,  1574,  1575,  1575,  1576,  1576,  1576,  1576,  1577, 
-        1577,  1578,  1578,  1578,  1578,  1579,  1579,  1579,  1579,  1580, 
-        1580,  1580,  1580,  1581,  1581,  1581,  1581,  1582,  1582,  1582, 
-        1582,  1583,  1583,  1584,  1584,  1585,  1585,  1586,  1586,  1587, 
-        1587,  1587,  1587,  1588,  1588,  1588,  1588,  1589,  1589,  1589, 
-        1589,  1590,  1590,  1590,  1590,  1591,  1591,  1591,  1591,  1592, 
-        1592,  1592,  1592,  1593,  1593,  1593,  1593,  1594,  1594,  1594, 
-        1594,  1601,  1601,  1601,  1601,  1602,  1602,  1602,  1602,  1603, 
-        1603,  1603,  1603,  1604,  1604,  1604,  1604,  1605,  1605,  1605, 
-        1605,  1606,  1606,  1606,  1606,  1607,  1607,  1607,  1607,  1608, 
-        1608,  1609,  1609,  1610,  1610,  1610,  1610,  1604,  1570,  1604, 
-        1570,  1604,  1571,  1604,  1571,  1604,  1573,  1604,  1573,  1604, 
-        1575,  1604,  1575,    33,    34,    35,    36,    37,    38,    39, 
-          40,    41,    42,    43,    44,    45,    46,    47,    48,    49, 
-          50,    51,    52,    53,    54,    55,    56,    57,    58,    59, 
-          60,    61,    62,    63,    64,    65,    66,    67,    68,    69, 
-          70,    71,    72,    73,    74,    75,    76,    77,    78,    79, 
-          80,    81,    82,    83,    84,    85,    86,    87,    88,    89, 
-          90,    91,    92,    93,    94,    95,    96,    97,    98,    99, 
-         100,   101,   102,   103,   104,   105,   106,   107,   108,   109, 
-         110,   111,   112,   113,   114,   115,   116,   117,   118,   119, 
-         120,   121,   122,   123,   124,   125,   126, 12290, 12300, 12301, 
-       12289, 12539, 12530, 12449, 12451, 12453, 12455, 12457, 12515, 12517, 
-       12519, 12483, 12540, 12450, 12452, 12454, 12456, 12458, 12459, 12461, 
-       12463, 12465, 12467, 12469, 12471, 12473, 12475, 12477, 12479, 12481, 
-       12484, 12486, 12488, 12490, 12491, 12492, 12493, 12494, 12495, 12498, 
-       12501, 12504, 12507, 12510, 12511, 12512, 12513, 12514, 12516, 12518, 
-       12520, 12521, 12522, 12523, 12524, 12525, 12527, 12531, 12441, 12442, 
-       12644, 12593, 12594, 12595, 12596, 12597, 12598, 12599, 12600, 12601, 
-       12602, 12603, 12604, 12605, 12606, 12607, 12608, 12609, 12610, 12611, 
-       12612, 12613, 12614, 12615, 12616, 12617, 12618, 12619, 12620, 12621, 
-       12622, 12623, 12624, 12625, 12626, 12627, 12628, 12629, 12630, 12631, 
-       12632, 12633, 12634, 12635, 12636, 12637, 12638, 12639, 12640, 12641, 
-       12642, 12643,   162,   163,   172,   175,   166,   165,  8361,  9474, 
-        8592,  8593,  8594,  8595,  9632,  9675, 
-};
-
-
-/*
- * Flags for special case mapping.
- */
-#define CMF_MULTICHAR  0x1
-#define CMF_FINAL      0x2
-#define CMF_NONFINAL   0x4
-#define CMF_CTXDEP     (CMF_FINAL|CMF_NONFINAL)
 
 /*
  * Lowercase <-> Uppercase mapping
  */
 
-#define CASEMAP_BM_SHIFT       (16 - 11)
-
-static unsigned long toupper_bitmap[] = {
-       0xf41fffe8, 0x000018fe, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0xffff0000, 
-       0x00000800, 0x000000c0, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x01000000, 0x04000000, 
-};
-
-static struct casemap toupper_map[] = {
-       /* non-conditional one-to-one mapping */
-       {0x0061, 0x0041}, {0x0062, 0x0042}, {0x0063, 0x0043}, {0x0064, 0x0044}, 
-       {0x0065, 0x0045}, {0x0066, 0x0046}, {0x0067, 0x0047}, {0x0068, 0x0048}, 
-       {0x0069, 0x0049}, {0x006a, 0x004a}, {0x006b, 0x004b}, {0x006c, 0x004c}, 
-       {0x006d, 0x004d}, {0x006e, 0x004e}, {0x006f, 0x004f}, {0x0070, 0x0050}, 
-       {0x0071, 0x0051}, {0x0072, 0x0052}, {0x0073, 0x0053}, {0x0074, 0x0054}, 
-       {0x0075, 0x0055}, {0x0076, 0x0056}, {0x0077, 0x0057}, {0x0078, 0x0058}, 
-       {0x0079, 0x0059}, {0x007a, 0x005a}, {0x00b5, 0x039c}, {0x00e0, 0x00c0}, 
-       {0x00e1, 0x00c1}, {0x00e2, 0x00c2}, {0x00e3, 0x00c3}, {0x00e4, 0x00c4}, 
-       {0x00e5, 0x00c5}, {0x00e6, 0x00c6}, {0x00e7, 0x00c7}, {0x00e8, 0x00c8}, 
-       {0x00e9, 0x00c9}, {0x00ea, 0x00ca}, {0x00eb, 0x00cb}, {0x00ec, 0x00cc}, 
-       {0x00ed, 0x00cd}, {0x00ee, 0x00ce}, {0x00ef, 0x00cf}, {0x00f0, 0x00d0}, 
-       {0x00f1, 0x00d1}, {0x00f2, 0x00d2}, {0x00f3, 0x00d3}, {0x00f4, 0x00d4}, 
-       {0x00f5, 0x00d5}, {0x00f6, 0x00d6}, {0x00f8, 0x00d8}, {0x00f9, 0x00d9}, 
-       {0x00fa, 0x00da}, {0x00fb, 0x00db}, {0x00fc, 0x00dc}, {0x00fd, 0x00dd}, 
-       {0x00fe, 0x00de}, {0x00ff, 0x0178}, {0x0101, 0x0100}, {0x0103, 0x0102}, 
-       {0x0105, 0x0104}, {0x0107, 0x0106}, {0x0109, 0x0108}, {0x010b, 0x010a}, 
-       {0x010d, 0x010c}, {0x010f, 0x010e}, {0x0111, 0x0110}, {0x0113, 0x0112}, 
-       {0x0115, 0x0114}, {0x0117, 0x0116}, {0x0119, 0x0118}, {0x011b, 0x011a}, 
-       {0x011d, 0x011c}, {0x011f, 0x011e}, {0x0121, 0x0120}, {0x0123, 0x0122}, 
-       {0x0125, 0x0124}, {0x0127, 0x0126}, {0x0129, 0x0128}, {0x012b, 0x012a}, 
-       {0x012d, 0x012c}, {0x012f, 0x012e}, {0x0131, 0x0049}, {0x0133, 0x0132}, 
-       {0x0135, 0x0134}, {0x0137, 0x0136}, {0x013a, 0x0139}, {0x013c, 0x013b}, 
-       {0x013e, 0x013d}, {0x0140, 0x013f}, {0x0142, 0x0141}, {0x0144, 0x0143}, 
-       {0x0146, 0x0145}, {0x0148, 0x0147}, {0x014b, 0x014a}, {0x014d, 0x014c}, 
-       {0x014f, 0x014e}, {0x0151, 0x0150}, {0x0153, 0x0152}, {0x0155, 0x0154}, 
-       {0x0157, 0x0156}, {0x0159, 0x0158}, {0x015b, 0x015a}, {0x015d, 0x015c}, 
-       {0x015f, 0x015e}, {0x0161, 0x0160}, {0x0163, 0x0162}, {0x0165, 0x0164}, 
-       {0x0167, 0x0166}, {0x0169, 0x0168}, {0x016b, 0x016a}, {0x016d, 0x016c}, 
-       {0x016f, 0x016e}, {0x0171, 0x0170}, {0x0173, 0x0172}, {0x0175, 0x0174}, 
-       {0x0177, 0x0176}, {0x017a, 0x0179}, {0x017c, 0x017b}, {0x017e, 0x017d}, 
-       {0x017f, 0x0053}, {0x0183, 0x0182}, {0x0185, 0x0184}, {0x0188, 0x0187}, 
-       {0x018c, 0x018b}, {0x0192, 0x0191}, {0x0195, 0x01f6}, {0x0199, 0x0198}, 
-       {0x01a1, 0x01a0}, {0x01a3, 0x01a2}, {0x01a5, 0x01a4}, {0x01a8, 0x01a7}, 
-       {0x01ad, 0x01ac}, {0x01b0, 0x01af}, {0x01b4, 0x01b3}, {0x01b6, 0x01b5}, 
-       {0x01b9, 0x01b8}, {0x01bd, 0x01bc}, {0x01bf, 0x01f7}, {0x01c5, 0x01c4}, 
-       {0x01c6, 0x01c4}, {0x01c8, 0x01c7}, {0x01c9, 0x01c7}, {0x01cb, 0x01ca}, 
-       {0x01cc, 0x01ca}, {0x01ce, 0x01cd}, {0x01d0, 0x01cf}, {0x01d2, 0x01d1}, 
-       {0x01d4, 0x01d3}, {0x01d6, 0x01d5}, {0x01d8, 0x01d7}, {0x01da, 0x01d9}, 
-       {0x01dc, 0x01db}, {0x01dd, 0x018e}, {0x01df, 0x01de}, {0x01e1, 0x01e0}, 
-       {0x01e3, 0x01e2}, {0x01e5, 0x01e4}, {0x01e7, 0x01e6}, {0x01e9, 0x01e8}, 
-       {0x01eb, 0x01ea}, {0x01ed, 0x01ec}, {0x01ef, 0x01ee}, {0x01f2, 0x01f1}, 
-       {0x01f3, 0x01f1}, {0x01f5, 0x01f4}, {0x01f9, 0x01f8}, {0x01fb, 0x01fa}, 
-       {0x01fd, 0x01fc}, {0x01ff, 0x01fe}, {0x0201, 0x0200}, {0x0203, 0x0202}, 
-       {0x0205, 0x0204}, {0x0207, 0x0206}, {0x0209, 0x0208}, {0x020b, 0x020a}, 
-       {0x020d, 0x020c}, {0x020f, 0x020e}, {0x0211, 0x0210}, {0x0213, 0x0212}, 
-       {0x0215, 0x0214}, {0x0217, 0x0216}, {0x0219, 0x0218}, {0x021b, 0x021a}, 
-       {0x021d, 0x021c}, {0x021f, 0x021e}, {0x0223, 0x0222}, {0x0225, 0x0224}, 
-       {0x0227, 0x0226}, {0x0229, 0x0228}, {0x022b, 0x022a}, {0x022d, 0x022c}, 
-       {0x022f, 0x022e}, {0x0231, 0x0230}, {0x0233, 0x0232}, {0x0253, 0x0181}, 
-       {0x0254, 0x0186}, {0x0256, 0x0189}, {0x0257, 0x018a}, {0x0259, 0x018f}, 
-       {0x025b, 0x0190}, {0x0260, 0x0193}, {0x0263, 0x0194}, {0x0268, 0x0197}, 
-       {0x0269, 0x0196}, {0x026f, 0x019c}, {0x0272, 0x019d}, {0x0275, 0x019f}, 
-       {0x0280, 0x01a6}, {0x0283, 0x01a9}, {0x0288, 0x01ae}, {0x028a, 0x01b1}, 
-       {0x028b, 0x01b2}, {0x0292, 0x01b7}, {0x0345, 0x0399}, {0x03ac, 0x0386}, 
-       {0x03ad, 0x0388}, {0x03ae, 0x0389}, {0x03af, 0x038a}, {0x03b1, 0x0391}, 
-       {0x03b2, 0x0392}, {0x03b3, 0x0393}, {0x03b4, 0x0394}, {0x03b5, 0x0395}, 
-       {0x03b6, 0x0396}, {0x03b7, 0x0397}, {0x03b8, 0x0398}, {0x03b9, 0x0399}, 
-       {0x03ba, 0x039a}, {0x03bb, 0x039b}, {0x03bc, 0x039c}, {0x03bd, 0x039d}, 
-       {0x03be, 0x039e}, {0x03bf, 0x039f}, {0x03c0, 0x03a0}, {0x03c1, 0x03a1}, 
-       {0x03c2, 0x03a3}, {0x03c3, 0x03a3}, {0x03c4, 0x03a4}, {0x03c5, 0x03a5}, 
-       {0x03c6, 0x03a6}, {0x03c7, 0x03a7}, {0x03c8, 0x03a8}, {0x03c9, 0x03a9}, 
-       {0x03ca, 0x03aa}, {0x03cb, 0x03ab}, {0x03cc, 0x038c}, {0x03cd, 0x038e}, 
-       {0x03ce, 0x038f}, {0x03d0, 0x0392}, {0x03d1, 0x0398}, {0x03d5, 0x03a6}, 
-       {0x03d6, 0x03a0}, {0x03db, 0x03da}, {0x03dd, 0x03dc}, {0x03df, 0x03de}, 
-       {0x03e1, 0x03e0}, {0x03e3, 0x03e2}, {0x03e5, 0x03e4}, {0x03e7, 0x03e6}, 
-       {0x03e9, 0x03e8}, {0x03eb, 0x03ea}, {0x03ed, 0x03ec}, {0x03ef, 0x03ee}, 
-       {0x03f0, 0x039a}, {0x03f1, 0x03a1}, {0x03f2, 0x03a3}, {0x0430, 0x0410}, 
-       {0x0431, 0x0411}, {0x0432, 0x0412}, {0x0433, 0x0413}, {0x0434, 0x0414}, 
-       {0x0435, 0x0415}, {0x0436, 0x0416}, {0x0437, 0x0417}, {0x0438, 0x0418}, 
-       {0x0439, 0x0419}, {0x043a, 0x041a}, {0x043b, 0x041b}, {0x043c, 0x041c}, 
-       {0x043d, 0x041d}, {0x043e, 0x041e}, {0x043f, 0x041f}, {0x0440, 0x0420}, 
-       {0x0441, 0x0421}, {0x0442, 0x0422}, {0x0443, 0x0423}, {0x0444, 0x0424}, 
-       {0x0445, 0x0425}, {0x0446, 0x0426}, {0x0447, 0x0427}, {0x0448, 0x0428}, 
-       {0x0449, 0x0429}, {0x044a, 0x042a}, {0x044b, 0x042b}, {0x044c, 0x042c}, 
-       {0x044d, 0x042d}, {0x044e, 0x042e}, {0x044f, 0x042f}, {0x0450, 0x0400}, 
-       {0x0451, 0x0401}, {0x0452, 0x0402}, {0x0453, 0x0403}, {0x0454, 0x0404}, 
-       {0x0455, 0x0405}, {0x0456, 0x0406}, {0x0457, 0x0407}, {0x0458, 0x0408}, 
-       {0x0459, 0x0409}, {0x045a, 0x040a}, {0x045b, 0x040b}, {0x045c, 0x040c}, 
-       {0x045d, 0x040d}, {0x045e, 0x040e}, {0x045f, 0x040f}, {0x0461, 0x0460}, 
-       {0x0463, 0x0462}, {0x0465, 0x0464}, {0x0467, 0x0466}, {0x0469, 0x0468}, 
-       {0x046b, 0x046a}, {0x046d, 0x046c}, {0x046f, 0x046e}, {0x0471, 0x0470}, 
-       {0x0473, 0x0472}, {0x0475, 0x0474}, {0x0477, 0x0476}, {0x0479, 0x0478}, 
-       {0x047b, 0x047a}, {0x047d, 0x047c}, {0x047f, 0x047e}, {0x0481, 0x0480}, 
-       {0x048d, 0x048c}, {0x048f, 0x048e}, {0x0491, 0x0490}, {0x0493, 0x0492}, 
-       {0x0495, 0x0494}, {0x0497, 0x0496}, {0x0499, 0x0498}, {0x049b, 0x049a}, 
-       {0x049d, 0x049c}, {0x049f, 0x049e}, {0x04a1, 0x04a0}, {0x04a3, 0x04a2}, 
-       {0x04a5, 0x04a4}, {0x04a7, 0x04a6}, {0x04a9, 0x04a8}, {0x04ab, 0x04aa}, 
-       {0x04ad, 0x04ac}, {0x04af, 0x04ae}, {0x04b1, 0x04b0}, {0x04b3, 0x04b2}, 
-       {0x04b5, 0x04b4}, {0x04b7, 0x04b6}, {0x04b9, 0x04b8}, {0x04bb, 0x04ba}, 
-       {0x04bd, 0x04bc}, {0x04bf, 0x04be}, {0x04c2, 0x04c1}, {0x04c4, 0x04c3}, 
-       {0x04c8, 0x04c7}, {0x04cc, 0x04cb}, {0x04d1, 0x04d0}, {0x04d3, 0x04d2}, 
-       {0x04d5, 0x04d4}, {0x04d7, 0x04d6}, {0x04d9, 0x04d8}, {0x04db, 0x04da}, 
-       {0x04dd, 0x04dc}, {0x04df, 0x04de}, {0x04e1, 0x04e0}, {0x04e3, 0x04e2}, 
-       {0x04e5, 0x04e4}, {0x04e7, 0x04e6}, {0x04e9, 0x04e8}, {0x04eb, 0x04ea}, 
-       {0x04ed, 0x04ec}, {0x04ef, 0x04ee}, {0x04f1, 0x04f0}, {0x04f3, 0x04f2}, 
-       {0x04f5, 0x04f4}, {0x04f9, 0x04f8}, {0x0561, 0x0531}, {0x0562, 0x0532}, 
-       {0x0563, 0x0533}, {0x0564, 0x0534}, {0x0565, 0x0535}, {0x0566, 0x0536}, 
-       {0x0567, 0x0537}, {0x0568, 0x0538}, {0x0569, 0x0539}, {0x056a, 0x053a}, 
-       {0x056b, 0x053b}, {0x056c, 0x053c}, {0x056d, 0x053d}, {0x056e, 0x053e}, 
-       {0x056f, 0x053f}, {0x0570, 0x0540}, {0x0571, 0x0541}, {0x0572, 0x0542}, 
-       {0x0573, 0x0543}, {0x0574, 0x0544}, {0x0575, 0x0545}, {0x0576, 0x0546}, 
-       {0x0577, 0x0547}, {0x0578, 0x0548}, {0x0579, 0x0549}, {0x057a, 0x054a}, 
-       {0x057b, 0x054b}, {0x057c, 0x054c}, {0x057d, 0x054d}, {0x057e, 0x054e}, 
-       {0x057f, 0x054f}, {0x0580, 0x0550}, {0x0581, 0x0551}, {0x0582, 0x0552}, 
-       {0x0583, 0x0553}, {0x0584, 0x0554}, {0x0585, 0x0555}, {0x0586, 0x0556}, 
-       {0x1e01, 0x1e00}, {0x1e03, 0x1e02}, {0x1e05, 0x1e04}, {0x1e07, 0x1e06}, 
-       {0x1e09, 0x1e08}, {0x1e0b, 0x1e0a}, {0x1e0d, 0x1e0c}, {0x1e0f, 0x1e0e}, 
-       {0x1e11, 0x1e10}, {0x1e13, 0x1e12}, {0x1e15, 0x1e14}, {0x1e17, 0x1e16}, 
-       {0x1e19, 0x1e18}, {0x1e1b, 0x1e1a}, {0x1e1d, 0x1e1c}, {0x1e1f, 0x1e1e}, 
-       {0x1e21, 0x1e20}, {0x1e23, 0x1e22}, {0x1e25, 0x1e24}, {0x1e27, 0x1e26}, 
-       {0x1e29, 0x1e28}, {0x1e2b, 0x1e2a}, {0x1e2d, 0x1e2c}, {0x1e2f, 0x1e2e}, 
-       {0x1e31, 0x1e30}, {0x1e33, 0x1e32}, {0x1e35, 0x1e34}, {0x1e37, 0x1e36}, 
-       {0x1e39, 0x1e38}, {0x1e3b, 0x1e3a}, {0x1e3d, 0x1e3c}, {0x1e3f, 0x1e3e}, 
-       {0x1e41, 0x1e40}, {0x1e43, 0x1e42}, {0x1e45, 0x1e44}, {0x1e47, 0x1e46}, 
-       {0x1e49, 0x1e48}, {0x1e4b, 0x1e4a}, {0x1e4d, 0x1e4c}, {0x1e4f, 0x1e4e}, 
-       {0x1e51, 0x1e50}, {0x1e53, 0x1e52}, {0x1e55, 0x1e54}, {0x1e57, 0x1e56}, 
-       {0x1e59, 0x1e58}, {0x1e5b, 0x1e5a}, {0x1e5d, 0x1e5c}, {0x1e5f, 0x1e5e}, 
-       {0x1e61, 0x1e60}, {0x1e63, 0x1e62}, {0x1e65, 0x1e64}, {0x1e67, 0x1e66}, 
-       {0x1e69, 0x1e68}, {0x1e6b, 0x1e6a}, {0x1e6d, 0x1e6c}, {0x1e6f, 0x1e6e}, 
-       {0x1e71, 0x1e70}, {0x1e73, 0x1e72}, {0x1e75, 0x1e74}, {0x1e77, 0x1e76}, 
-       {0x1e79, 0x1e78}, {0x1e7b, 0x1e7a}, {0x1e7d, 0x1e7c}, {0x1e7f, 0x1e7e}, 
-       {0x1e81, 0x1e80}, {0x1e83, 0x1e82}, {0x1e85, 0x1e84}, {0x1e87, 0x1e86}, 
-       {0x1e89, 0x1e88}, {0x1e8b, 0x1e8a}, {0x1e8d, 0x1e8c}, {0x1e8f, 0x1e8e}, 
-       {0x1e91, 0x1e90}, {0x1e93, 0x1e92}, {0x1e95, 0x1e94}, {0x1e9b, 0x1e60}, 
-       {0x1ea1, 0x1ea0}, {0x1ea3, 0x1ea2}, {0x1ea5, 0x1ea4}, {0x1ea7, 0x1ea6}, 
-       {0x1ea9, 0x1ea8}, {0x1eab, 0x1eaa}, {0x1ead, 0x1eac}, {0x1eaf, 0x1eae}, 
-       {0x1eb1, 0x1eb0}, {0x1eb3, 0x1eb2}, {0x1eb5, 0x1eb4}, {0x1eb7, 0x1eb6}, 
-       {0x1eb9, 0x1eb8}, {0x1ebb, 0x1eba}, {0x1ebd, 0x1ebc}, {0x1ebf, 0x1ebe}, 
-       {0x1ec1, 0x1ec0}, {0x1ec3, 0x1ec2}, {0x1ec5, 0x1ec4}, {0x1ec7, 0x1ec6}, 
-       {0x1ec9, 0x1ec8}, {0x1ecb, 0x1eca}, {0x1ecd, 0x1ecc}, {0x1ecf, 0x1ece}, 
-       {0x1ed1, 0x1ed0}, {0x1ed3, 0x1ed2}, {0x1ed5, 0x1ed4}, {0x1ed7, 0x1ed6}, 
-       {0x1ed9, 0x1ed8}, {0x1edb, 0x1eda}, {0x1edd, 0x1edc}, {0x1edf, 0x1ede}, 
-       {0x1ee1, 0x1ee0}, {0x1ee3, 0x1ee2}, {0x1ee5, 0x1ee4}, {0x1ee7, 0x1ee6}, 
-       {0x1ee9, 0x1ee8}, {0x1eeb, 0x1eea}, {0x1eed, 0x1eec}, {0x1eef, 0x1eee}, 
-       {0x1ef1, 0x1ef0}, {0x1ef3, 0x1ef2}, {0x1ef5, 0x1ef4}, {0x1ef7, 0x1ef6}, 
-       {0x1ef9, 0x1ef8}, {0x1f00, 0x1f08}, {0x1f01, 0x1f09}, {0x1f02, 0x1f0a}, 
-       {0x1f03, 0x1f0b}, {0x1f04, 0x1f0c}, {0x1f05, 0x1f0d}, {0x1f06, 0x1f0e}, 
-       {0x1f07, 0x1f0f}, {0x1f10, 0x1f18}, {0x1f11, 0x1f19}, {0x1f12, 0x1f1a}, 
-       {0x1f13, 0x1f1b}, {0x1f14, 0x1f1c}, {0x1f15, 0x1f1d}, {0x1f20, 0x1f28}, 
-       {0x1f21, 0x1f29}, {0x1f22, 0x1f2a}, {0x1f23, 0x1f2b}, {0x1f24, 0x1f2c}, 
-       {0x1f25, 0x1f2d}, {0x1f26, 0x1f2e}, {0x1f27, 0x1f2f}, {0x1f30, 0x1f38}, 
-       {0x1f31, 0x1f39}, {0x1f32, 0x1f3a}, {0x1f33, 0x1f3b}, {0x1f34, 0x1f3c}, 
-       {0x1f35, 0x1f3d}, {0x1f36, 0x1f3e}, {0x1f37, 0x1f3f}, {0x1f40, 0x1f48}, 
-       {0x1f41, 0x1f49}, {0x1f42, 0x1f4a}, {0x1f43, 0x1f4b}, {0x1f44, 0x1f4c}, 
-       {0x1f45, 0x1f4d}, {0x1f51, 0x1f59}, {0x1f53, 0x1f5b}, {0x1f55, 0x1f5d}, 
-       {0x1f57, 0x1f5f}, {0x1f60, 0x1f68}, {0x1f61, 0x1f69}, {0x1f62, 0x1f6a}, 
-       {0x1f63, 0x1f6b}, {0x1f64, 0x1f6c}, {0x1f65, 0x1f6d}, {0x1f66, 0x1f6e}, 
-       {0x1f67, 0x1f6f}, {0x1f70, 0x1fba}, {0x1f71, 0x1fbb}, {0x1f72, 0x1fc8}, 
-       {0x1f73, 0x1fc9}, {0x1f74, 0x1fca}, {0x1f75, 0x1fcb}, {0x1f76, 0x1fda}, 
-       {0x1f77, 0x1fdb}, {0x1f78, 0x1ff8}, {0x1f79, 0x1ff9}, {0x1f7a, 0x1fea}, 
-       {0x1f7b, 0x1feb}, {0x1f7c, 0x1ffa}, {0x1f7d, 0x1ffb}, {0x1f80, 0x1f88}, 
-       {0x1f81, 0x1f89}, {0x1f82, 0x1f8a}, {0x1f83, 0x1f8b}, {0x1f84, 0x1f8c}, 
-       {0x1f85, 0x1f8d}, {0x1f86, 0x1f8e}, {0x1f87, 0x1f8f}, {0x1f90, 0x1f98}, 
-       {0x1f91, 0x1f99}, {0x1f92, 0x1f9a}, {0x1f93, 0x1f9b}, {0x1f94, 0x1f9c}, 
-       {0x1f95, 0x1f9d}, {0x1f96, 0x1f9e}, {0x1f97, 0x1f9f}, {0x1fa0, 0x1fa8}, 
-       {0x1fa1, 0x1fa9}, {0x1fa2, 0x1faa}, {0x1fa3, 0x1fab}, {0x1fa4, 0x1fac}, 
-       {0x1fa5, 0x1fad}, {0x1fa6, 0x1fae}, {0x1fa7, 0x1faf}, {0x1fb0, 0x1fb8}, 
-       {0x1fb1, 0x1fb9}, {0x1fb3, 0x1fbc}, {0x1fbe, 0x0399}, {0x1fc3, 0x1fcc}, 
-       {0x1fd0, 0x1fd8}, {0x1fd1, 0x1fd9}, {0x1fe0, 0x1fe8}, {0x1fe1, 0x1fe9}, 
-       {0x1fe5, 0x1fec}, {0x1ff3, 0x1ffc}, {0x2170, 0x2160}, {0x2171, 0x2161}, 
-       {0x2172, 0x2162}, {0x2173, 0x2163}, {0x2174, 0x2164}, {0x2175, 0x2165}, 
-       {0x2176, 0x2166}, {0x2177, 0x2167}, {0x2178, 0x2168}, {0x2179, 0x2169}, 
-       {0x217a, 0x216a}, {0x217b, 0x216b}, {0x217c, 0x216c}, {0x217d, 0x216d}, 
-       {0x217e, 0x216e}, {0x217f, 0x216f}, {0x24d0, 0x24b6}, {0x24d1, 0x24b7}, 
-       {0x24d2, 0x24b8}, {0x24d3, 0x24b9}, {0x24d4, 0x24ba}, {0x24d5, 0x24bb}, 
-       {0x24d6, 0x24bc}, {0x24d7, 0x24bd}, {0x24d8, 0x24be}, {0x24d9, 0x24bf}, 
-       {0x24da, 0x24c0}, {0x24db, 0x24c1}, {0x24dc, 0x24c2}, {0x24dd, 0x24c3}, 
-       {0x24de, 0x24c4}, {0x24df, 0x24c5}, {0x24e0, 0x24c6}, {0x24e1, 0x24c7}, 
-       {0x24e2, 0x24c8}, {0x24e3, 0x24c9}, {0x24e4, 0x24ca}, {0x24e5, 0x24cb}, 
-       {0x24e6, 0x24cc}, {0x24e7, 0x24cd}, {0x24e8, 0x24ce}, {0x24e9, 0x24cf}, 
-       {0xff41, 0xff21}, {0xff42, 0xff22}, {0xff43, 0xff23}, {0xff44, 0xff24}, 
-       {0xff45, 0xff25}, {0xff46, 0xff26}, {0xff47, 0xff27}, {0xff48, 0xff28}, 
-       {0xff49, 0xff29}, {0xff4a, 0xff2a}, {0xff4b, 0xff2b}, {0xff4c, 0xff2c}, 
-       {0xff4d, 0xff2d}, {0xff4e, 0xff2e}, {0xff4f, 0xff2f}, {0xff50, 0xff30}, 
-       {0xff51, 0xff31}, {0xff52, 0xff32}, {0xff53, 0xff33}, {0xff54, 0xff34}, 
-       {0xff55, 0xff35}, {0xff56, 0xff36}, {0xff57, 0xff37}, {0xff58, 0xff38}, 
-       {0xff59, 0xff39}, {0xff5a, 0xff3a}, 
-       /* conditional or one-to-many mapping */
-       {0x00df, 0x0000, CMF_MULTICHAR, 2}, {0xfb00, 0x0002, CMF_MULTICHAR, 2}, 
-       {0xfb01, 0x0004, CMF_MULTICHAR, 2}, {0xfb02, 0x0006, CMF_MULTICHAR, 2}, 
-       {0xfb03, 0x0008, CMF_MULTICHAR, 3}, {0xfb04, 0x000b, CMF_MULTICHAR, 3}, 
-       {0xfb05, 0x000e, CMF_MULTICHAR, 2}, {0xfb06, 0x0010, CMF_MULTICHAR, 2}, 
-       {0x0587, 0x0012, CMF_MULTICHAR, 2}, {0xfb13, 0x0014, CMF_MULTICHAR, 2}, 
-       {0xfb14, 0x0016, CMF_MULTICHAR, 2}, {0xfb15, 0x0018, CMF_MULTICHAR, 2}, 
-       {0xfb16, 0x001a, CMF_MULTICHAR, 2}, {0xfb17, 0x001c, CMF_MULTICHAR, 2}, 
-       {0x0149, 0x001e, CMF_MULTICHAR, 2}, {0x0390, 0x0020, CMF_MULTICHAR, 3}, 
-       {0x03b0, 0x0023, CMF_MULTICHAR, 3}, {0x01f0, 0x0026, CMF_MULTICHAR, 2}, 
-       {0x1e96, 0x0028, CMF_MULTICHAR, 2}, {0x1e97, 0x002a, CMF_MULTICHAR, 2}, 
-       {0x1e98, 0x002c, CMF_MULTICHAR, 2}, {0x1e99, 0x002e, CMF_MULTICHAR, 2}, 
-       {0x1e9a, 0x0030, CMF_MULTICHAR, 2}, {0x1f50, 0x0032, CMF_MULTICHAR, 2}, 
-       {0x1f52, 0x0034, CMF_MULTICHAR, 3}, {0x1f54, 0x0037, CMF_MULTICHAR, 3}, 
-       {0x1f56, 0x003a, CMF_MULTICHAR, 3}, {0x1fb6, 0x003d, CMF_MULTICHAR, 2}, 
-       {0x1fc6, 0x003f, CMF_MULTICHAR, 2}, {0x1fd2, 0x0041, CMF_MULTICHAR, 3}, 
-       {0x1fd3, 0x0044, CMF_MULTICHAR, 3}, {0x1fd6, 0x0047, CMF_MULTICHAR, 2}, 
-       {0x1fd7, 0x0049, CMF_MULTICHAR, 3}, {0x1fe2, 0x004c, CMF_MULTICHAR, 3}, 
-       {0x1fe3, 0x004f, CMF_MULTICHAR, 3}, {0x1fe4, 0x0052, CMF_MULTICHAR, 2}, 
-       {0x1fe6, 0x0054, CMF_MULTICHAR, 2}, {0x1fe7, 0x0056, CMF_MULTICHAR, 3}, 
-       {0x1ff6, 0x0059, CMF_MULTICHAR, 2}, {0x1f80, 0x005b, CMF_MULTICHAR, 2}, 
-       {0x1f81, 0x005d, CMF_MULTICHAR, 2}, {0x1f82, 0x005f, CMF_MULTICHAR, 2}, 
-       {0x1f83, 0x0061, CMF_MULTICHAR, 2}, {0x1f84, 0x0063, CMF_MULTICHAR, 2}, 
-       {0x1f85, 0x0065, CMF_MULTICHAR, 2}, {0x1f86, 0x0067, CMF_MULTICHAR, 2}, 
-       {0x1f87, 0x0069, CMF_MULTICHAR, 2}, {0x1f88, 0x006b, CMF_MULTICHAR, 2}, 
-       {0x1f89, 0x006d, CMF_MULTICHAR, 2}, {0x1f8a, 0x006f, CMF_MULTICHAR, 2}, 
-       {0x1f8b, 0x0071, CMF_MULTICHAR, 2}, {0x1f8c, 0x0073, CMF_MULTICHAR, 2}, 
-       {0x1f8d, 0x0075, CMF_MULTICHAR, 2}, {0x1f8e, 0x0077, CMF_MULTICHAR, 2}, 
-       {0x1f8f, 0x0079, CMF_MULTICHAR, 2}, {0x1f90, 0x007b, CMF_MULTICHAR, 2}, 
-       {0x1f91, 0x007d, CMF_MULTICHAR, 2}, {0x1f92, 0x007f, CMF_MULTICHAR, 2}, 
-       {0x1f93, 0x0081, CMF_MULTICHAR, 2}, {0x1f94, 0x0083, CMF_MULTICHAR, 2}, 
-       {0x1f95, 0x0085, CMF_MULTICHAR, 2}, {0x1f96, 0x0087, CMF_MULTICHAR, 2}, 
-       {0x1f97, 0x0089, CMF_MULTICHAR, 2}, {0x1f98, 0x008b, CMF_MULTICHAR, 2}, 
-       {0x1f99, 0x008d, CMF_MULTICHAR, 2}, {0x1f9a, 0x008f, CMF_MULTICHAR, 2}, 
-       {0x1f9b, 0x0091, CMF_MULTICHAR, 2}, {0x1f9c, 0x0093, CMF_MULTICHAR, 2}, 
-       {0x1f9d, 0x0095, CMF_MULTICHAR, 2}, {0x1f9e, 0x0097, CMF_MULTICHAR, 2}, 
-       {0x1f9f, 0x0099, CMF_MULTICHAR, 2}, {0x1fa0, 0x009b, CMF_MULTICHAR, 2}, 
-       {0x1fa1, 0x009d, CMF_MULTICHAR, 2}, {0x1fa2, 0x009f, CMF_MULTICHAR, 2}, 
-       {0x1fa3, 0x00a1, CMF_MULTICHAR, 2}, {0x1fa4, 0x00a3, CMF_MULTICHAR, 2}, 
-       {0x1fa5, 0x00a5, CMF_MULTICHAR, 2}, {0x1fa6, 0x00a7, CMF_MULTICHAR, 2}, 
-       {0x1fa7, 0x00a9, CMF_MULTICHAR, 2}, {0x1fa8, 0x00ab, CMF_MULTICHAR, 2}, 
-       {0x1fa9, 0x00ad, CMF_MULTICHAR, 2}, {0x1faa, 0x00af, CMF_MULTICHAR, 2}, 
-       {0x1fab, 0x00b1, CMF_MULTICHAR, 2}, {0x1fac, 0x00b3, CMF_MULTICHAR, 2}, 
-       {0x1fad, 0x00b5, CMF_MULTICHAR, 2}, {0x1fae, 0x00b7, CMF_MULTICHAR, 2}, 
-       {0x1faf, 0x00b9, CMF_MULTICHAR, 2}, {0x1fb3, 0x00bb, CMF_MULTICHAR, 2}, 
-       {0x1fbc, 0x00bd, CMF_MULTICHAR, 2}, {0x1fc3, 0x00bf, CMF_MULTICHAR, 2}, 
-       {0x1fcc, 0x00c1, CMF_MULTICHAR, 2}, {0x1ff3, 0x00c3, CMF_MULTICHAR, 2}, 
-       {0x1ffc, 0x00c5, CMF_MULTICHAR, 2}, {0x1fb2, 0x00c7, CMF_MULTICHAR, 2}, 
-       {0x1fb4, 0x00c9, CMF_MULTICHAR, 2}, {0x1fc2, 0x00cb, CMF_MULTICHAR, 2}, 
-       {0x1fc4, 0x00cd, CMF_MULTICHAR, 2}, {0x1ff2, 0x00cf, CMF_MULTICHAR, 2}, 
-       {0x1ff4, 0x00d1, CMF_MULTICHAR, 2}, {0x1fb7, 0x00d3, CMF_MULTICHAR, 3}, 
-       {0x1fc7, 0x00d6, CMF_MULTICHAR, 3}, {0x1ff7, 0x00d9, CMF_MULTICHAR, 3}, 
-};
-
-static unsigned long tolower_bitmap[] = {
-       0xf003ff44, 0x000006fb, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0xffff0000, 
-       0x00000a00, 0x00000060, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x02000000, 
-};
-
-static struct casemap tolower_map[] = {
-       /* non-conditional one-to-one mapping */
-       {0x0041, 0x0061}, {0x0042, 0x0062}, {0x0043, 0x0063}, {0x0044, 0x0064}, 
-       {0x0045, 0x0065}, {0x0046, 0x0066}, {0x0047, 0x0067}, {0x0048, 0x0068}, 
-       {0x0049, 0x0069}, {0x004a, 0x006a}, {0x004b, 0x006b}, {0x004c, 0x006c}, 
-       {0x004d, 0x006d}, {0x004e, 0x006e}, {0x004f, 0x006f}, {0x0050, 0x0070}, 
-       {0x0051, 0x0071}, {0x0052, 0x0072}, {0x0053, 0x0073}, {0x0054, 0x0074}, 
-       {0x0055, 0x0075}, {0x0056, 0x0076}, {0x0057, 0x0077}, {0x0058, 0x0078}, 
-       {0x0059, 0x0079}, {0x005a, 0x007a}, {0x00c0, 0x00e0}, {0x00c1, 0x00e1}, 
-       {0x00c2, 0x00e2}, {0x00c3, 0x00e3}, {0x00c4, 0x00e4}, {0x00c5, 0x00e5}, 
-       {0x00c6, 0x00e6}, {0x00c7, 0x00e7}, {0x00c8, 0x00e8}, {0x00c9, 0x00e9}, 
-       {0x00ca, 0x00ea}, {0x00cb, 0x00eb}, {0x00cc, 0x00ec}, {0x00cd, 0x00ed}, 
-       {0x00ce, 0x00ee}, {0x00cf, 0x00ef}, {0x00d0, 0x00f0}, {0x00d1, 0x00f1}, 
-       {0x00d2, 0x00f2}, {0x00d3, 0x00f3}, {0x00d4, 0x00f4}, {0x00d5, 0x00f5}, 
-       {0x00d6, 0x00f6}, {0x00d8, 0x00f8}, {0x00d9, 0x00f9}, {0x00da, 0x00fa}, 
-       {0x00db, 0x00fb}, {0x00dc, 0x00fc}, {0x00dd, 0x00fd}, {0x00de, 0x00fe}, 
-       {0x0100, 0x0101}, {0x0102, 0x0103}, {0x0104, 0x0105}, {0x0106, 0x0107}, 
-       {0x0108, 0x0109}, {0x010a, 0x010b}, {0x010c, 0x010d}, {0x010e, 0x010f}, 
-       {0x0110, 0x0111}, {0x0112, 0x0113}, {0x0114, 0x0115}, {0x0116, 0x0117}, 
-       {0x0118, 0x0119}, {0x011a, 0x011b}, {0x011c, 0x011d}, {0x011e, 0x011f}, 
-       {0x0120, 0x0121}, {0x0122, 0x0123}, {0x0124, 0x0125}, {0x0126, 0x0127}, 
-       {0x0128, 0x0129}, {0x012a, 0x012b}, {0x012c, 0x012d}, {0x012e, 0x012f}, 
-       {0x0130, 0x0069}, {0x0132, 0x0133}, {0x0134, 0x0135}, {0x0136, 0x0137}, 
-       {0x0139, 0x013a}, {0x013b, 0x013c}, {0x013d, 0x013e}, {0x013f, 0x0140}, 
-       {0x0141, 0x0142}, {0x0143, 0x0144}, {0x0145, 0x0146}, {0x0147, 0x0148}, 
-       {0x014a, 0x014b}, {0x014c, 0x014d}, {0x014e, 0x014f}, {0x0150, 0x0151}, 
-       {0x0152, 0x0153}, {0x0154, 0x0155}, {0x0156, 0x0157}, {0x0158, 0x0159}, 
-       {0x015a, 0x015b}, {0x015c, 0x015d}, {0x015e, 0x015f}, {0x0160, 0x0161}, 
-       {0x0162, 0x0163}, {0x0164, 0x0165}, {0x0166, 0x0167}, {0x0168, 0x0169}, 
-       {0x016a, 0x016b}, {0x016c, 0x016d}, {0x016e, 0x016f}, {0x0170, 0x0171}, 
-       {0x0172, 0x0173}, {0x0174, 0x0175}, {0x0176, 0x0177}, {0x0178, 0x00ff}, 
-       {0x0179, 0x017a}, {0x017b, 0x017c}, {0x017d, 0x017e}, {0x0181, 0x0253}, 
-       {0x0182, 0x0183}, {0x0184, 0x0185}, {0x0186, 0x0254}, {0x0187, 0x0188}, 
-       {0x0189, 0x0256}, {0x018a, 0x0257}, {0x018b, 0x018c}, {0x018e, 0x01dd}, 
-       {0x018f, 0x0259}, {0x0190, 0x025b}, {0x0191, 0x0192}, {0x0193, 0x0260}, 
-       {0x0194, 0x0263}, {0x0196, 0x0269}, {0x0197, 0x0268}, {0x0198, 0x0199}, 
-       {0x019c, 0x026f}, {0x019d, 0x0272}, {0x019f, 0x0275}, {0x01a0, 0x01a1}, 
-       {0x01a2, 0x01a3}, {0x01a4, 0x01a5}, {0x01a6, 0x0280}, {0x01a7, 0x01a8}, 
-       {0x01a9, 0x0283}, {0x01ac, 0x01ad}, {0x01ae, 0x0288}, {0x01af, 0x01b0}, 
-       {0x01b1, 0x028a}, {0x01b2, 0x028b}, {0x01b3, 0x01b4}, {0x01b5, 0x01b6}, 
-       {0x01b7, 0x0292}, {0x01b8, 0x01b9}, {0x01bc, 0x01bd}, {0x01c4, 0x01c6}, 
-       {0x01c5, 0x01c6}, {0x01c7, 0x01c9}, {0x01c8, 0x01c9}, {0x01ca, 0x01cc}, 
-       {0x01cb, 0x01cc}, {0x01cd, 0x01ce}, {0x01cf, 0x01d0}, {0x01d1, 0x01d2}, 
-       {0x01d3, 0x01d4}, {0x01d5, 0x01d6}, {0x01d7, 0x01d8}, {0x01d9, 0x01da}, 
-       {0x01db, 0x01dc}, {0x01de, 0x01df}, {0x01e0, 0x01e1}, {0x01e2, 0x01e3}, 
-       {0x01e4, 0x01e5}, {0x01e6, 0x01e7}, {0x01e8, 0x01e9}, {0x01ea, 0x01eb}, 
-       {0x01ec, 0x01ed}, {0x01ee, 0x01ef}, {0x01f1, 0x01f3}, {0x01f2, 0x01f3}, 
-       {0x01f4, 0x01f5}, {0x01f6, 0x0195}, {0x01f7, 0x01bf}, {0x01f8, 0x01f9}, 
-       {0x01fa, 0x01fb}, {0x01fc, 0x01fd}, {0x01fe, 0x01ff}, {0x0200, 0x0201}, 
-       {0x0202, 0x0203}, {0x0204, 0x0205}, {0x0206, 0x0207}, {0x0208, 0x0209}, 
-       {0x020a, 0x020b}, {0x020c, 0x020d}, {0x020e, 0x020f}, {0x0210, 0x0211}, 
-       {0x0212, 0x0213}, {0x0214, 0x0215}, {0x0216, 0x0217}, {0x0218, 0x0219}, 
-       {0x021a, 0x021b}, {0x021c, 0x021d}, {0x021e, 0x021f}, {0x0222, 0x0223}, 
-       {0x0224, 0x0225}, {0x0226, 0x0227}, {0x0228, 0x0229}, {0x022a, 0x022b}, 
-       {0x022c, 0x022d}, {0x022e, 0x022f}, {0x0230, 0x0231}, {0x0232, 0x0233}, 
-       {0x0386, 0x03ac}, {0x0388, 0x03ad}, {0x0389, 0x03ae}, {0x038a, 0x03af}, 
-       {0x038c, 0x03cc}, {0x038e, 0x03cd}, {0x038f, 0x03ce}, {0x0391, 0x03b1}, 
-       {0x0392, 0x03b2}, {0x0393, 0x03b3}, {0x0394, 0x03b4}, {0x0395, 0x03b5}, 
-       {0x0396, 0x03b6}, {0x0397, 0x03b7}, {0x0398, 0x03b8}, {0x0399, 0x03b9}, 
-       {0x039a, 0x03ba}, {0x039b, 0x03bb}, {0x039c, 0x03bc}, {0x039d, 0x03bd}, 
-       {0x039e, 0x03be}, {0x039f, 0x03bf}, {0x03a0, 0x03c0}, {0x03a1, 0x03c1}, 
-       {0x03a3, 0x03c3}, {0x03a4, 0x03c4}, {0x03a5, 0x03c5}, {0x03a6, 0x03c6}, 
-       {0x03a7, 0x03c7}, {0x03a8, 0x03c8}, {0x03a9, 0x03c9}, {0x03aa, 0x03ca}, 
-       {0x03ab, 0x03cb}, {0x03da, 0x03db}, {0x03dc, 0x03dd}, {0x03de, 0x03df}, 
-       {0x03e0, 0x03e1}, {0x03e2, 0x03e3}, {0x03e4, 0x03e5}, {0x03e6, 0x03e7}, 
-       {0x03e8, 0x03e9}, {0x03ea, 0x03eb}, {0x03ec, 0x03ed}, {0x03ee, 0x03ef}, 
-       {0x0400, 0x0450}, {0x0401, 0x0451}, {0x0402, 0x0452}, {0x0403, 0x0453}, 
-       {0x0404, 0x0454}, {0x0405, 0x0455}, {0x0406, 0x0456}, {0x0407, 0x0457}, 
-       {0x0408, 0x0458}, {0x0409, 0x0459}, {0x040a, 0x045a}, {0x040b, 0x045b}, 
-       {0x040c, 0x045c}, {0x040d, 0x045d}, {0x040e, 0x045e}, {0x040f, 0x045f}, 
-       {0x0410, 0x0430}, {0x0411, 0x0431}, {0x0412, 0x0432}, {0x0413, 0x0433}, 
-       {0x0414, 0x0434}, {0x0415, 0x0435}, {0x0416, 0x0436}, {0x0417, 0x0437}, 
-       {0x0418, 0x0438}, {0x0419, 0x0439}, {0x041a, 0x043a}, {0x041b, 0x043b}, 
-       {0x041c, 0x043c}, {0x041d, 0x043d}, {0x041e, 0x043e}, {0x041f, 0x043f}, 
-       {0x0420, 0x0440}, {0x0421, 0x0441}, {0x0422, 0x0442}, {0x0423, 0x0443}, 
-       {0x0424, 0x0444}, {0x0425, 0x0445}, {0x0426, 0x0446}, {0x0427, 0x0447}, 
-       {0x0428, 0x0448}, {0x0429, 0x0449}, {0x042a, 0x044a}, {0x042b, 0x044b}, 
-       {0x042c, 0x044c}, {0x042d, 0x044d}, {0x042e, 0x044e}, {0x042f, 0x044f}, 
-       {0x0460, 0x0461}, {0x0462, 0x0463}, {0x0464, 0x0465}, {0x0466, 0x0467}, 
-       {0x0468, 0x0469}, {0x046a, 0x046b}, {0x046c, 0x046d}, {0x046e, 0x046f}, 
-       {0x0470, 0x0471}, {0x0472, 0x0473}, {0x0474, 0x0475}, {0x0476, 0x0477}, 
-       {0x0478, 0x0479}, {0x047a, 0x047b}, {0x047c, 0x047d}, {0x047e, 0x047f}, 
-       {0x0480, 0x0481}, {0x048c, 0x048d}, {0x048e, 0x048f}, {0x0490, 0x0491}, 
-       {0x0492, 0x0493}, {0x0494, 0x0495}, {0x0496, 0x0497}, {0x0498, 0x0499}, 
-       {0x049a, 0x049b}, {0x049c, 0x049d}, {0x049e, 0x049f}, {0x04a0, 0x04a1}, 
-       {0x04a2, 0x04a3}, {0x04a4, 0x04a5}, {0x04a6, 0x04a7}, {0x04a8, 0x04a9}, 
-       {0x04aa, 0x04ab}, {0x04ac, 0x04ad}, {0x04ae, 0x04af}, {0x04b0, 0x04b1}, 
-       {0x04b2, 0x04b3}, {0x04b4, 0x04b5}, {0x04b6, 0x04b7}, {0x04b8, 0x04b9}, 
-       {0x04ba, 0x04bb}, {0x04bc, 0x04bd}, {0x04be, 0x04bf}, {0x04c1, 0x04c2}, 
-       {0x04c3, 0x04c4}, {0x04c7, 0x04c8}, {0x04cb, 0x04cc}, {0x04d0, 0x04d1}, 
-       {0x04d2, 0x04d3}, {0x04d4, 0x04d5}, {0x04d6, 0x04d7}, {0x04d8, 0x04d9}, 
-       {0x04da, 0x04db}, {0x04dc, 0x04dd}, {0x04de, 0x04df}, {0x04e0, 0x04e1}, 
-       {0x04e2, 0x04e3}, {0x04e4, 0x04e5}, {0x04e6, 0x04e7}, {0x04e8, 0x04e9}, 
-       {0x04ea, 0x04eb}, {0x04ec, 0x04ed}, {0x04ee, 0x04ef}, {0x04f0, 0x04f1}, 
-       {0x04f2, 0x04f3}, {0x04f4, 0x04f5}, {0x04f8, 0x04f9}, {0x0531, 0x0561}, 
-       {0x0532, 0x0562}, {0x0533, 0x0563}, {0x0534, 0x0564}, {0x0535, 0x0565}, 
-       {0x0536, 0x0566}, {0x0537, 0x0567}, {0x0538, 0x0568}, {0x0539, 0x0569}, 
-       {0x053a, 0x056a}, {0x053b, 0x056b}, {0x053c, 0x056c}, {0x053d, 0x056d}, 
-       {0x053e, 0x056e}, {0x053f, 0x056f}, {0x0540, 0x0570}, {0x0541, 0x0571}, 
-       {0x0542, 0x0572}, {0x0543, 0x0573}, {0x0544, 0x0574}, {0x0545, 0x0575}, 
-       {0x0546, 0x0576}, {0x0547, 0x0577}, {0x0548, 0x0578}, {0x0549, 0x0579}, 
-       {0x054a, 0x057a}, {0x054b, 0x057b}, {0x054c, 0x057c}, {0x054d, 0x057d}, 
-       {0x054e, 0x057e}, {0x054f, 0x057f}, {0x0550, 0x0580}, {0x0551, 0x0581}, 
-       {0x0552, 0x0582}, {0x0553, 0x0583}, {0x0554, 0x0584}, {0x0555, 0x0585}, 
-       {0x0556, 0x0586}, {0x1e00, 0x1e01}, {0x1e02, 0x1e03}, {0x1e04, 0x1e05}, 
-       {0x1e06, 0x1e07}, {0x1e08, 0x1e09}, {0x1e0a, 0x1e0b}, {0x1e0c, 0x1e0d}, 
-       {0x1e0e, 0x1e0f}, {0x1e10, 0x1e11}, {0x1e12, 0x1e13}, {0x1e14, 0x1e15}, 
-       {0x1e16, 0x1e17}, {0x1e18, 0x1e19}, {0x1e1a, 0x1e1b}, {0x1e1c, 0x1e1d}, 
-       {0x1e1e, 0x1e1f}, {0x1e20, 0x1e21}, {0x1e22, 0x1e23}, {0x1e24, 0x1e25}, 
-       {0x1e26, 0x1e27}, {0x1e28, 0x1e29}, {0x1e2a, 0x1e2b}, {0x1e2c, 0x1e2d}, 
-       {0x1e2e, 0x1e2f}, {0x1e30, 0x1e31}, {0x1e32, 0x1e33}, {0x1e34, 0x1e35}, 
-       {0x1e36, 0x1e37}, {0x1e38, 0x1e39}, {0x1e3a, 0x1e3b}, {0x1e3c, 0x1e3d}, 
-       {0x1e3e, 0x1e3f}, {0x1e40, 0x1e41}, {0x1e42, 0x1e43}, {0x1e44, 0x1e45}, 
-       {0x1e46, 0x1e47}, {0x1e48, 0x1e49}, {0x1e4a, 0x1e4b}, {0x1e4c, 0x1e4d}, 
-       {0x1e4e, 0x1e4f}, {0x1e50, 0x1e51}, {0x1e52, 0x1e53}, {0x1e54, 0x1e55}, 
-       {0x1e56, 0x1e57}, {0x1e58, 0x1e59}, {0x1e5a, 0x1e5b}, {0x1e5c, 0x1e5d}, 
-       {0x1e5e, 0x1e5f}, {0x1e60, 0x1e61}, {0x1e62, 0x1e63}, {0x1e64, 0x1e65}, 
-       {0x1e66, 0x1e67}, {0x1e68, 0x1e69}, {0x1e6a, 0x1e6b}, {0x1e6c, 0x1e6d}, 
-       {0x1e6e, 0x1e6f}, {0x1e70, 0x1e71}, {0x1e72, 0x1e73}, {0x1e74, 0x1e75}, 
-       {0x1e76, 0x1e77}, {0x1e78, 0x1e79}, {0x1e7a, 0x1e7b}, {0x1e7c, 0x1e7d}, 
-       {0x1e7e, 0x1e7f}, {0x1e80, 0x1e81}, {0x1e82, 0x1e83}, {0x1e84, 0x1e85}, 
-       {0x1e86, 0x1e87}, {0x1e88, 0x1e89}, {0x1e8a, 0x1e8b}, {0x1e8c, 0x1e8d}, 
-       {0x1e8e, 0x1e8f}, {0x1e90, 0x1e91}, {0x1e92, 0x1e93}, {0x1e94, 0x1e95}, 
-       {0x1ea0, 0x1ea1}, {0x1ea2, 0x1ea3}, {0x1ea4, 0x1ea5}, {0x1ea6, 0x1ea7}, 
-       {0x1ea8, 0x1ea9}, {0x1eaa, 0x1eab}, {0x1eac, 0x1ead}, {0x1eae, 0x1eaf}, 
-       {0x1eb0, 0x1eb1}, {0x1eb2, 0x1eb3}, {0x1eb4, 0x1eb5}, {0x1eb6, 0x1eb7}, 
-       {0x1eb8, 0x1eb9}, {0x1eba, 0x1ebb}, {0x1ebc, 0x1ebd}, {0x1ebe, 0x1ebf}, 
-       {0x1ec0, 0x1ec1}, {0x1ec2, 0x1ec3}, {0x1ec4, 0x1ec5}, {0x1ec6, 0x1ec7}, 
-       {0x1ec8, 0x1ec9}, {0x1eca, 0x1ecb}, {0x1ecc, 0x1ecd}, {0x1ece, 0x1ecf}, 
-       {0x1ed0, 0x1ed1}, {0x1ed2, 0x1ed3}, {0x1ed4, 0x1ed5}, {0x1ed6, 0x1ed7}, 
-       {0x1ed8, 0x1ed9}, {0x1eda, 0x1edb}, {0x1edc, 0x1edd}, {0x1ede, 0x1edf}, 
-       {0x1ee0, 0x1ee1}, {0x1ee2, 0x1ee3}, {0x1ee4, 0x1ee5}, {0x1ee6, 0x1ee7}, 
-       {0x1ee8, 0x1ee9}, {0x1eea, 0x1eeb}, {0x1eec, 0x1eed}, {0x1eee, 0x1eef}, 
-       {0x1ef0, 0x1ef1}, {0x1ef2, 0x1ef3}, {0x1ef4, 0x1ef5}, {0x1ef6, 0x1ef7}, 
-       {0x1ef8, 0x1ef9}, {0x1f08, 0x1f00}, {0x1f09, 0x1f01}, {0x1f0a, 0x1f02}, 
-       {0x1f0b, 0x1f03}, {0x1f0c, 0x1f04}, {0x1f0d, 0x1f05}, {0x1f0e, 0x1f06}, 
-       {0x1f0f, 0x1f07}, {0x1f18, 0x1f10}, {0x1f19, 0x1f11}, {0x1f1a, 0x1f12}, 
-       {0x1f1b, 0x1f13}, {0x1f1c, 0x1f14}, {0x1f1d, 0x1f15}, {0x1f28, 0x1f20}, 
-       {0x1f29, 0x1f21}, {0x1f2a, 0x1f22}, {0x1f2b, 0x1f23}, {0x1f2c, 0x1f24}, 
-       {0x1f2d, 0x1f25}, {0x1f2e, 0x1f26}, {0x1f2f, 0x1f27}, {0x1f38, 0x1f30}, 
-       {0x1f39, 0x1f31}, {0x1f3a, 0x1f32}, {0x1f3b, 0x1f33}, {0x1f3c, 0x1f34}, 
-       {0x1f3d, 0x1f35}, {0x1f3e, 0x1f36}, {0x1f3f, 0x1f37}, {0x1f48, 0x1f40}, 
-       {0x1f49, 0x1f41}, {0x1f4a, 0x1f42}, {0x1f4b, 0x1f43}, {0x1f4c, 0x1f44}, 
-       {0x1f4d, 0x1f45}, {0x1f59, 0x1f51}, {0x1f5b, 0x1f53}, {0x1f5d, 0x1f55}, 
-       {0x1f5f, 0x1f57}, {0x1f68, 0x1f60}, {0x1f69, 0x1f61}, {0x1f6a, 0x1f62}, 
-       {0x1f6b, 0x1f63}, {0x1f6c, 0x1f64}, {0x1f6d, 0x1f65}, {0x1f6e, 0x1f66}, 
-       {0x1f6f, 0x1f67}, {0x1f88, 0x1f80}, {0x1f89, 0x1f81}, {0x1f8a, 0x1f82}, 
-       {0x1f8b, 0x1f83}, {0x1f8c, 0x1f84}, {0x1f8d, 0x1f85}, {0x1f8e, 0x1f86}, 
-       {0x1f8f, 0x1f87}, {0x1f98, 0x1f90}, {0x1f99, 0x1f91}, {0x1f9a, 0x1f92}, 
-       {0x1f9b, 0x1f93}, {0x1f9c, 0x1f94}, {0x1f9d, 0x1f95}, {0x1f9e, 0x1f96}, 
-       {0x1f9f, 0x1f97}, {0x1fa8, 0x1fa0}, {0x1fa9, 0x1fa1}, {0x1faa, 0x1fa2}, 
-       {0x1fab, 0x1fa3}, {0x1fac, 0x1fa4}, {0x1fad, 0x1fa5}, {0x1fae, 0x1fa6}, 
-       {0x1faf, 0x1fa7}, {0x1fb8, 0x1fb0}, {0x1fb9, 0x1fb1}, {0x1fba, 0x1f70}, 
-       {0x1fbb, 0x1f71}, {0x1fbc, 0x1fb3}, {0x1fc8, 0x1f72}, {0x1fc9, 0x1f73}, 
-       {0x1fca, 0x1f74}, {0x1fcb, 0x1f75}, {0x1fcc, 0x1fc3}, {0x1fd8, 0x1fd0}, 
-       {0x1fd9, 0x1fd1}, {0x1fda, 0x1f76}, {0x1fdb, 0x1f77}, {0x1fe8, 0x1fe0}, 
-       {0x1fe9, 0x1fe1}, {0x1fea, 0x1f7a}, {0x1feb, 0x1f7b}, {0x1fec, 0x1fe5}, 
-       {0x1ff8, 0x1f78}, {0x1ff9, 0x1f79}, {0x1ffa, 0x1f7c}, {0x1ffb, 0x1f7d}, 
-       {0x1ffc, 0x1ff3}, {0x2126, 0x03c9}, {0x212a, 0x006b}, {0x212b, 0x00e5}, 
-       {0x2160, 0x2170}, {0x2161, 0x2171}, {0x2162, 0x2172}, {0x2163, 0x2173}, 
-       {0x2164, 0x2174}, {0x2165, 0x2175}, {0x2166, 0x2176}, {0x2167, 0x2177}, 
-       {0x2168, 0x2178}, {0x2169, 0x2179}, {0x216a, 0x217a}, {0x216b, 0x217b}, 
-       {0x216c, 0x217c}, {0x216d, 0x217d}, {0x216e, 0x217e}, {0x216f, 0x217f}, 
-       {0x24b6, 0x24d0}, {0x24b7, 0x24d1}, {0x24b8, 0x24d2}, {0x24b9, 0x24d3}, 
-       {0x24ba, 0x24d4}, {0x24bb, 0x24d5}, {0x24bc, 0x24d6}, {0x24bd, 0x24d7}, 
-       {0x24be, 0x24d8}, {0x24bf, 0x24d9}, {0x24c0, 0x24da}, {0x24c1, 0x24db}, 
-       {0x24c2, 0x24dc}, {0x24c3, 0x24dd}, {0x24c4, 0x24de}, {0x24c5, 0x24df}, 
-       {0x24c6, 0x24e0}, {0x24c7, 0x24e1}, {0x24c8, 0x24e2}, {0x24c9, 0x24e3}, 
-       {0x24ca, 0x24e4}, {0x24cb, 0x24e5}, {0x24cc, 0x24e6}, {0x24cd, 0x24e7}, 
-       {0x24ce, 0x24e8}, {0x24cf, 0x24e9}, {0xff21, 0xff41}, {0xff22, 0xff42}, 
-       {0xff23, 0xff43}, {0xff24, 0xff44}, {0xff25, 0xff45}, {0xff26, 0xff46}, 
-       {0xff27, 0xff47}, {0xff28, 0xff48}, {0xff29, 0xff49}, {0xff2a, 0xff4a}, 
-       {0xff2b, 0xff4b}, {0xff2c, 0xff4c}, {0xff2d, 0xff4d}, {0xff2e, 0xff4e}, 
-       {0xff2f, 0xff4f}, {0xff30, 0xff50}, {0xff31, 0xff51}, {0xff32, 0xff52}, 
-       {0xff33, 0xff53}, {0xff34, 0xff54}, {0xff35, 0xff55}, {0xff36, 0xff56}, 
-       {0xff37, 0xff57}, {0xff38, 0xff58}, {0xff39, 0xff59}, {0xff3a, 0xff5a}, 
-       /* conditional or one-to-many mapping */
-       {0x03a3, 0x03c2, CMF_FINAL}, 
-};
-
-static unicode_t multichar_casemap_data[] = {
-          83,    83,    70,    70,    70,    73,    70,    76,    70,    70, 
-          73,    70,    70,    76,    83,    84,    83,    84,  1333,  1362, 
-        1348,  1350,  1348,  1333,  1348,  1339,  1358,  1350,  1348,  1341, 
-         700,    78,   921,   776,   769,   933,   776,   769,    74,   780, 
-          72,   817,    84,   776,    87,   778,    89,   778,    65,   702, 
-         933,   787,   933,   787,   768,   933,   787,   769,   933,   787, 
-         834,   913,   834,   919,   834,   921,   776,   768,   921,   776, 
-         769,   921,   834,   921,   776,   834,   933,   776,   768,   933, 
-         776,   769,   929,   787,   933,   834,   933,   776,   834,   937, 
-         834,  7944,   921,  7945,   921,  7946,   921,  7947,   921,  7948, 
-         921,  7949,   921,  7950,   921,  7951,   921,  7944,   921,  7945, 
-         921,  7946,   921,  7947,   921,  7948,   921,  7949,   921,  7950, 
-         921,  7951,   921,  7976,   921,  7977,   921,  7978,   921,  7979, 
-         921,  7980,   921,  7981,   921,  7982,   921,  7983,   921,  7976, 
-         921,  7977,   921,  7978,   921,  7979,   921,  7980,   921,  7981, 
-         921,  7982,   921,  7983,   921,  8040,   921,  8041,   921,  8042, 
-         921,  8043,   921,  8044,   921,  8045,   921,  8046,   921,  8047, 
-         921,  8040,   921,  8041,   921,  8042,   921,  8043,   921,  8044, 
-         921,  8045,   921,  8046,   921,  8047,   921,   913,   921,   913, 
-         921,   919,   921,   919,   921,   937,   921,   937,   921,  8122, 
-         921,   902,   921,  8138,   921,   905,   921,  8186,   921,   911, 
-         921,   913,   834,   921,   919,   834,   921,   937,   834,   921, 
-};
-
 /*
- * Cased characters and non-spacing marks (for casemap context)
+ * 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 CTX_BLOCK_SZ   512
-#define CTX_CASED      1       /* cased character */
-#define CTX_NSM                2       /* non-spacing mark */
+#define CASEMAP_BITS_0 9
+#define CASEMAP_BITS_1 7
+#define CASEMAP_BITS_2 5
 
-static unsigned long casemap_ctx_section0[] = {
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x55555554, 0x00155555, 0x55555554, 0x00155555, 
-       0x00000000, 0x00000000, 0x00100000, 0x00100400, 
-       0x55555555, 0x55551555, 0x55555555, 0x55551555, 
-       0x55555555, 0x55555555, 0x55555555, 0x55555555, 
-       0x55555555, 0x55555555, 0x55555555, 0x55555555, 
-       0x55555555, 0x55555555, 0x55555555, 0x55155555, 
-       0x55555500, 0x55555555, 0x55555555, 0x55555555, 
+static unsigned short toupper_imap[] = {
+         272,   400,   528,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   784, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         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, 
+           0,     0,     0,    30,    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,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           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, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,    48,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,    49,    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, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           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,    52,     0,     0,     0,     0,     0, 
 };
 
-static unsigned long casemap_ctx_section1[] = {
-       0x55555555, 0x55555555, 0x55555550, 0x00000055, 
-       0x00000000, 0x55555555, 0x55555555, 0x55555555, 
-       0x55555555, 0x55555555, 0x05555555, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0xaaaaaaaa, 0xaaaaaaaa, 0xaaaaaaaa, 0xaaaaaaaa, 
-       0x2aaaaaaa, 0x00000000, 0x0000002a, 0x00000000, 
-       0x51151000, 0x55555555, 0x55555545, 0x55555555, 
-       0x15555555, 0x55505555, 0x55555555, 0x00000055, 
+static struct {
+       unsigned short tbl[32];
+} 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,    0,    0, 
+       }},
+       {{
+          0,  263,    0,  265,    0,  267,    0,    0,  269,    0,    0, 
+          0,    0,  271,    0,    0,  273,    0,    0,    0,  275,    0, 
+        277,    0,    0,  279,    0,    0,    0,  281,    0,  283, 
+       }},
+       {{
+          0,    0,    0,    0,    0,  285,  287,    0,  289,  291,    0, 
+        293,  295,    0,  297,    0,  299,    0,  301,    0,  303,    0, 
+        305,    0,  307,    0,  309,    0,  311,  313,    0,  315, 
+       }},
+       {{
+          0,  317,    0,  319,    0,  321,    0,  323,    0,  325,    0, 
+        327,    0,  329,    0,  331,  333,    0,  336,  338,    0,  340, 
+          0,    0,    0,  342,    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,    0,    0,  382,    0,  384,    0,  386,    0,  388,    0, 
+        390,    0,  392,    0,  394,    0,  396,    0,  398,    0,    0, 
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+       }},
+       {{
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+          0,    0,    0,    0,    0,    0,    0,    0,  400,  402,    0, 
+        404,  406,    0,  408,    0,  410,    0,    0,    0,    0, 
+       }},
+       {{
+        412,    0,    0,  414,    0,    0,    0,    0,  416,  418,    0, 
+          0,    0,    0,    0,  420,    0,    0,  422,    0,    0,  424, 
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+       }},
+       {{
+        426,    0,    0,  428,    0,    0,    0,    0,  430,    0,  432, 
+        434,    0,    0,    0,    0,    0,    0,  436,    0,    0,    0, 
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    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,    0,    0,    0,    0,    0,    0,    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,  444,  446,  448,  450,  452,  456,  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,    0,  516,  518,    0,    0,    0,  520, 
+        522,    0,    0,    0,    0,  524,    0,  526,    0,  528, 
+       }},
+       {{
+          0,  530,    0,  532,    0,  534,    0,  536,    0,  538,    0, 
+        540,    0,  542,    0,  544,  546,  548,  550,    0,    0,    0, 
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+       }},
+       {{
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+          0,    0,    0,    0,    0,  552,  554,  556,  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, 
+       }},
+       {{
+          0,  648,    0,  650,    0,  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,    0,    0,    0,    0,    0,    0,    0,    0, 
+          0,    0,  682,    0,  684,    0,  686,    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,    0,  734,    0,  736,    0,    0,    0,  738,    0,    0, 
+          0,  740,    0,    0,    0,    0,  742,    0,  744,    0,  746, 
+          0,  748,    0,  750,    0,  752,    0,  754,    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,    0,    0,  780,    0,    0,    0,    0,    0,    0, 
+       }},
+       {{
+          0,  782,  784,  786,  788,  790,  792,  794,  796,  798,  800, 
+        802,  804,  806,  808,  810,  812,  814,  816,  818,  820,  822, 
+        824,  826,  828,  830,  832,  834,  836,  838,  840,  842, 
+       }},
+       {{
+        844,  846,  848,  850,  852,  854,  856,  858,    0,    0,    0, 
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+       }},
+       {{
+          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, 1001,    0, 1003,    0, 1005,    0, 1007,    0, 1009, 
+       1011, 1014, 1017, 1020, 1023, 1026,    0,    0,    0,    0, 
+       }},
+       {{
+          0, 1028,    0, 1030,    0, 1032,    0, 1034,    0, 1036,    0, 
+       1038,    0, 1040,    0, 1042,    0, 1044,    0, 1046,    0, 1048, 
+          0, 1050,    0, 1052,    0, 1054,    0, 1056,    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,    0,    0,    0,    0,    0, 
+       }},
+       {{
+       1118, 1120, 1122, 1124, 1126, 1128, 1130, 1132,    0,    0,    0, 
+          0,    0,    0,    0,    0, 1134, 1136, 1138, 1140, 1142, 1144, 
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+       }},
+       {{
+       1146, 1148, 1150, 1152, 1154, 1156, 1158, 1160,    0,    0,    0, 
+          0,    0,    0,    0,    0, 1162, 1164, 1166, 1168, 1170, 1172, 
+       1174, 1176,    0,    0,    0,    0,    0,    0,    0,    0, 
+       }},
+       {{
+       1178, 1180, 1182, 1184, 1186, 1188,    0,    0,    0,    0,    0, 
+          0,    0,    0,    0,    0, 1190, 1193, 1195, 1199, 1201, 1205, 
+       1207, 1211,    0,    0,    0,    0,    0,    0,    0,    0, 
+       }},
+       {{
+       1213, 1215, 1217, 1219, 1221, 1223, 1225, 1227,    0,    0,    0, 
+          0,    0,    0,    0,    0, 1229, 1231, 1233, 1235, 1237, 1239, 
+       1241, 1243, 1245, 1247, 1249, 1251, 1253, 1255,    0,    0, 
+       }},
+       {{
+       1257, 1262, 1267, 1272, 1277, 1282, 1287, 1292, 1297, 1300, 1303, 
+       1306, 1309, 1312, 1315, 1318, 1321, 1326, 1331, 1336, 1341, 1346, 
+       1351, 1356, 1361, 1364, 1367, 1370, 1373, 1376, 1379, 1382, 
+       }},
+       {{
+       1385, 1390, 1395, 1400, 1405, 1410, 1415, 1420, 1425, 1428, 1431, 
+       1434, 1437, 1440, 1443, 1446, 1449, 1451, 1453, 1456, 1461,    0, 
+       1464, 1467,    0,    0,    0,    0, 1471,    0, 1474,    0, 
+       }},
+       {{
+          0,    0, 1476, 1479, 1484,    0, 1487, 1490,    0,    0,    0, 
+          0, 1494,    0,    0,    0, 1497, 1499, 1501, 1505,    0,    0, 
+       1509, 1512,    0,    0,    0,    0,    0,    0,    0,    0, 
+       }},
+       {{
+       1516, 1518, 1520, 1524, 1528, 1531, 1533, 1536,    0,    0,    0, 
+          0,    0,    0,    0,    0,    0,    0, 1540, 1543, 1548,    0, 
+       1551, 1554,    0,    0,    0,    0, 1558,    0,    0,    0, 
+       }},
+       {{
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+          0,    0,    0,    0,    0, 1561, 1563, 1565, 1567, 1569, 1571, 
+       1573, 1575, 1577, 1579, 1581, 1583, 1585, 1587, 1589, 1591, 
+       }},
+       {{
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+          0,    0,    0,    0,    0, 1593, 1595, 1597, 1599, 1601, 1603, 
+       1605, 1607, 1609, 1611, 1613, 1615, 1617, 1619, 1621, 1623, 
+       }},
+       {{
+       1625, 1627, 1629, 1631, 1633, 1635, 1637, 1639, 1641, 1643,    0, 
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+       }},
+       {{
+       1645, 1648, 1651, 1654, 1658, 1662, 1665,    0,    0,    0,    0, 
+          0,    0,    0,    0,    0,    0,    0,    0, 1668, 1671, 1674, 
+       1677, 1680,    0,    0,    0,    0,    0,    0,    0,    0, 
+       }},
+       {{
+          0, 1683, 1685, 1687, 1689, 1691, 1693, 1695, 1697, 1699, 1701, 
+       1703, 1705, 1707, 1709, 1711, 1713, 1715, 1717, 1719, 1721, 1723, 
+       1725, 1727, 1729, 1731, 1733,    0,    0,    0,    0,    0, 
+       }},
 };
-
-static unsigned long casemap_ctx_section2[] = {
-       0x55555555, 0x55555555, 0x55555555, 0x55555555, 
-       0x55555555, 0x55555555, 0x55555555, 0x55555555, 
-       0x55002a85, 0x55555555, 0x55555555, 0x55555555, 
-       0x01414155, 0x55555555, 0x55555555, 0x00050555, 
-       0x00000000, 0x00000000, 0x00000000, 0x55555554, 
-       0x55555555, 0x00001555, 0x55555554, 0x55555555, 
-       0x00005555, 0xaaaaaaa8, 0xaaaaaa8a, 0x8a8aaaaa, 
-       0x00000228, 0x00000000, 0x00000000, 0x00000000, 
+static unsigned short tolower_imap[] = {
+         272,   400,   528,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   784, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         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, 
+           0,    24,    25,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           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,    27,    28,    29,    30,    31,    32,    33, 
+          34,    35,    36,    37,    38,    39,    40,    41, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,    42,     0,    43,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,    44,    45,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,    46,     0,     0,     0,     0,     0,     0, 
 };
 
-static unsigned long casemap_ctx_section3[] = {
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0xaa800000, 0x00000aaa, 0x00000000, 0x00000002, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x82aaa000, 0x0aa282aa, 0x00000000, 
-       0x00000000, 0x00000008, 0x00000000, 0xaaaaaaaa, 
-       0x002aaaaa, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0xaaaaa000, 0x00000002, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
+static struct {
+       unsigned short tbl[32];
+} 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,  163,    0,  165,    0, 
+        167,    0,    0,  169,    0,  171,    0,  173,    0,  175, 
+       }},
+       {{
+          0,  177,    0,  179,    0,  181,    0,  183,    0,    0,  185, 
+          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,  233,    0,  235,    0,  237,    0,    0, 
+       }},
+       {{
+          0,  239,  241,    0,  243,    0,  245,  247,    0,  249,  251, 
+        253,    0,    0,  255,  257,  259,  261,    0,  263,  265,    0, 
+        267,  269,  271,    0,    0,    0,  273,  275,    0,  277, 
+       }},
+       {{
+        279,    0,  281,    0,  283,    0,  285,  287,    0,  289,    0, 
+          0,  291,    0,  293,  295,    0,  297,  299,  301,    0,  303, 
+          0,  305,  307,    0,    0,    0,  309,    0,    0,    0, 
+       }},
+       {{
+          0,    0,    0,    0,  311,  313,    0,  315,  317,    0,  319, 
+        321,    0,  323,    0,  325,    0,  327,    0,  329,    0,  331, 
+          0,  333,    0,  335,    0,  337,    0,    0,  339,    0, 
+       }},
+       {{
+        341,    0,  343,    0,  345,    0,  347,    0,  349,    0,  351, 
+          0,  353,    0,  355,    0,    0,  357,  359,    0,  361,    0, 
+        363,  365,  367,    0,  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, 
+       }},
+       {{
+          0,    0,  407,    0,  409,    0,  411,    0,  413,    0,  415, 
+          0,  417,    0,  419,    0,  421,    0,  423,    0,    0,    0, 
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+       }},
+       {{
+          0,    0,    0,    0,    0,    0,  425,    0,  427,  429,  431, 
+          0,  433,    0,  435,  437,    0,  439,  441,  443,  445,  447, 
+        449,  451,  453,  455,  457,  459,  461,  463,  465,  467, 
+       }},
+       {{
+        469,  471,    0,  473,  477,  479,  481,  483,  485,  487,  489, 
+        491,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+       }},
+       {{
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+          0,    0,    0,    0,  493,    0,  495,    0,  497,    0, 
+       }},
+       {{
+        499,    0,  501,    0,  503,    0,  505,    0,  507,    0,  509, 
+          0,  511,    0,  513,    0,    0,    0,    0,    0,    0,    0, 
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+       }},
+       {{
+        515,  517,  519,  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,    0,    0,    0,    0,    0,    0, 
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+       }},
+       {{
+        611,    0,  613,    0,  615,    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,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+          0,  645,    0,  647,    0,  649,    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, 
+       }},
+       {{
+          0,  697,    0,  699,    0,    0,    0,  701,    0,    0,    0, 
+        703,    0,    0,    0,    0,  705,    0,  707,    0,  709,    0, 
+        711,    0,  713,    0,  715,    0,  717,    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, 
+          0,    0,  743,    0,    0,    0,    0,    0,    0,    0, 
+       }},
+       {{
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+          0,    0,    0,    0,    0,    0,  745,  747,  749,  751,  753, 
+        755,  757,  759,  761,  763,  765,  767,  769,  771,  773, 
+       }},
+       {{
+        775,  777,  779,  781,  783,  785,  787,  789,  791,  793,  795, 
+        797,  799,  801,  803,  805,  807,  809,  811,  813,  815,  817, 
+        819,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+       }},
+       {{
+        821,    0,  823,    0,  825,    0,  827,    0,  829,    0,  831, 
+          0,  833,    0,  835,    0,  837,    0,  839,    0,  841,    0, 
+        843,    0,  845,    0,  847,    0,  849,    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, 
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    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,    0, 1041,    0, 1043,    0, 1045, 
+          0, 1047,    0, 1049,    0, 1051,    0, 1053,    0, 1055,    0, 
+       1057,    0, 1059,    0,    0,    0,    0,    0,    0,    0, 
+       }},
+       {{
+          0,    0,    0,    0,    0,    0,    0,    0, 1061, 1063, 1065, 
+       1067, 1069, 1071, 1073, 1075,    0,    0,    0,    0,    0,    0, 
+          0,    0, 1077, 1079, 1081, 1083, 1085, 1087,    0,    0, 
+       }},
+       {{
+          0,    0,    0,    0,    0,    0,    0,    0, 1089, 1091, 1093, 
+       1095, 1097, 1099, 1101, 1103,    0,    0,    0,    0,    0,    0, 
+          0,    0, 1105, 1107, 1109, 1111, 1113, 1115, 1117, 1119, 
+       }},
+       {{
+          0,    0,    0,    0,    0,    0,    0,    0, 1121, 1123, 1125, 
+       1127, 1129, 1131,    0,    0,    0,    0,    0,    0,    0,    0, 
+          0,    0,    0, 1133,    0, 1135,    0, 1137,    0, 1139, 
+       }},
+       {{
+          0,    0,    0,    0,    0,    0,    0,    0, 1141, 1143, 1145, 
+       1147, 1149, 1151, 1153, 1155,    0,    0,    0,    0,    0,    0, 
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+       }},
+       {{
+          0,    0,    0,    0,    0,    0,    0,    0, 1157, 1161, 1165, 
+       1169, 1173, 1177, 1181, 1185,    0,    0,    0,    0,    0,    0, 
+          0,    0, 1189, 1193, 1197, 1201, 1205, 1209, 1213, 1217, 
+       }},
+       {{
+          0,    0,    0,    0,    0,    0,    0,    0, 1221, 1225, 1229, 
+       1233, 1237, 1241, 1245, 1249,    0,    0,    0,    0,    0,    0, 
+          0,    0, 1253, 1255, 1257, 1259, 1261,    0,    0,    0, 
+       }},
+       {{
+          0,    0,    0,    0,    0,    0,    0,    0, 1265, 1267, 1269, 
+       1271, 1273,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+          0,    0, 1277, 1279, 1281, 1283,    0,    0,    0,    0, 
+       }},
+       {{
+          0,    0,    0,    0,    0,    0,    0,    0, 1285, 1287, 1289, 
+       1291, 1293,    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, 1307,    0,    0,    0, 1309, 
+       1311,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+       }},
+       {{
+       1313, 1315, 1317, 1319, 1321, 1323, 1325, 1327, 1329, 1331, 1333, 
+       1335, 1337, 1339, 1341, 1343,    0,    0,    0,    0,    0,    0, 
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+       }},
+       {{
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+       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,    0,    0,    0,    0,    0,    0, 
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+       }},
+       {{
+          0, 1397, 1399, 1401, 1403, 1405, 1407, 1409, 1411, 1413, 1415, 
+       1417, 1419, 1421, 1423, 1425, 1427, 1429, 1431, 1433, 1435, 1437, 
+       1439, 1441, 1443, 1445, 1447,    0,    0,    0,    0,    0, 
+       }},
 };
-
-static unsigned long casemap_ctx_section4[] = {
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000028, 0x00000000, 0x00000000, 0x02000000, 
-       0x0802aaa8, 0x000002a8, 0x000000a0, 0x00000000, 
-       0x00000008, 0x00000000, 0x00000000, 0x02000000, 
-       0x080002a8, 0x00000000, 0x000000a0, 0x00000000, 
+static unsigned long 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, 
+       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, 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, 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, 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, 0x800004c7, 
+       0x00000010, 0x800004cb, 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, 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, 
 };
 
-static unsigned long casemap_ctx_section5[] = {
-       0x00000020, 0x00000000, 0x00000000, 0x02000000, 
-       0x0a828028, 0x00000000, 0x00000000, 0x0000000a, 
-       0x00000028, 0x00000000, 0x00000000, 0x02000000, 
-       0x08028aa8, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000008, 0x00000000, 0x00000000, 0x82000000, 
-       0x080000a8, 0x00002000, 0x00000000, 0x00000000, 
-       0x00000020, 0x00000000, 0x00000000, 0x00000000, 
-       0x08000002, 0x00000000, 0x00000000, 0x00000000, 
+static unsigned long 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, 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, 
+       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, 0x00000001, 0x800003c2, 0x00000010, 
+       0x800003c3, 0x00000010, 0x800003c4, 0x00000010, 
+       0x800003c5, 0x00000010, 0x800003c6, 0x00000010, 
+       0x800003c7, 0x00000010, 0x800003c8, 0x00000010, 
+       0x800003c9, 0x00000010, 0x800003ca, 0x00000010, 
+       0x800003cb, 0x00000010, 0x800003db, 0x00000010, 
+       0x800003dd, 0x00000010, 0x800003df, 0x00000010, 
+       0x800003e1, 0x00000010, 0x800003e3, 0x00000010, 
+       0x800003e5, 0x00000010, 0x800003e7, 0x00000010, 
+       0x800003e9, 0x00000010, 0x800003eb, 0x00000010, 
+       0x800003ed, 0x00000010, 0x800003ef, 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, 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, 0x800004c8, 0x00000010, 
+       0x800004cc, 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, 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, 
 };
 
-static unsigned long casemap_ctx_section6[] = {
-       0x00000000, 0x00000000, 0x00000000, 0xa0000000, 
-       0x0aa2a002, 0x00002800, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x80000000, 
-       0x0a002000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x080000a8, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00200000, 0x000022a0, 0x00000000, 0x00000000, 
-};
 
-static unsigned long casemap_ctx_section7[] = {
-       0x00000000, 0x00000000, 0x00000000, 0x002aaa08, 
-       0x2aaa8000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x028aaa08, 
-       0x0aaa0000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x000a0000, 0x00000000, 0x00088800, 
-       0x00000000, 0x00000000, 0x00000000, 0x2aaaaaa8, 
-       0x0000a2aa, 0xaaa8aaaa, 0xaaaaaaaa, 0x02aaaaaa, 
-       0x00002000, 0x00000000, 0x00000000, 0x00000000, 
-};
+/*
+ * Cased characters and non-spacing marks (for casemap context)
+ */
 
-static unsigned long casemap_ctx_section8[] = {
-       0x00000000, 0x00000000, 0xa8000000, 0x0008a022, 
-       0x00000000, 0x000a0000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x55555555, 0x55555555, 
-       0x00000555, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-};
+#define CASEMAP_CTX_BITS_0     9
+#define CASEMAP_CTX_BITS_1     7
+#define CASEMAP_CTX_BITS_2     5
 
-static unsigned long casemap_ctx_section11[] = {
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x0aaa8000, 
-       0xaaa82000, 0x000000aa, 0x00000000, 0x00000000, 
-};
+#define CTX_CASED      1
+#define CTX_NSM                2
 
-static unsigned long casemap_ctx_section12[] = {
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00080000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
+static unsigned short casemap_ctx_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,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         784,   784,   784,   784,   784,   784,   784,   784, 
+         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,    12,    13,    14,    15,    16, 
+           4,     4,     4,     4,    17,     4,    18,    19, 
+           0,    20,    21,    22,    23,    24,    25,     0, 
+           0,     0,    26,    27,     0,     0,    28,    29, 
+          30,    31,    32,     0,     0,    33,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+          34,    35,    36,    37,    38,    35,    39,    37, 
+          40,    35,    41,    42,    34,    35,    43,     0, 
+          38,    44,    45,     0,    40,     0,    46,     0, 
+           0,    47,    48,     0,     0,    49,    50,     0, 
+           0,     0,    51,     0,     0,     0,    52,     0, 
+           0,    53,    54,     0,     0,    55,    56,     0, 
+          57,    58,     0,    59,    60,    61,    62,     0, 
+           0,    63,    57,     0,     0,     4,    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,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,    65,    66,     0, 
+           0,     0,     0,     0,     0,    67,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           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,    68,     4,     4,    69, 
+          70,     4,    71,    72,     4,    73,    74,    75, 
+           0,     0,     0,    76,     0,     0,    77,    38, 
+          78,    79,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,    80,     0,     0,    81,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+          82,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,    83,     0,     0,     0,     0,     0,     0, 
+           0,     1,     1,     0,     0,     0,     0,     0, 
 };
 
-static unsigned long casemap_ctx_section15[] = {
-       0x55555555, 0x55555555, 0x55555555, 0x55555555, 
-       0x55555555, 0x55555555, 0x55555555, 0x55555555, 
-       0x55555555, 0x00555555, 0x55555555, 0x55555555, 
-       0x55555555, 0x55555555, 0x55555555, 0x00055555, 
-       0x55555555, 0x05550555, 0x55555555, 0x55555555, 
-       0x05550555, 0x44445555, 0x55555555, 0x05555555, 
-       0x55555555, 0x55555555, 0x55555555, 0x11555155, 
-       0x01555150, 0x00555055, 0x01555555, 0x01555150, 
+static struct {
+       unsigned char tbl[32];
+} 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, 
+       }},
+       {{
+        0,  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,  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, 
+       }},
+       {{
+        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,  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, 
+       }},
+       {{
+        1,  1,  0,  2,  2,  2,  2,  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,  0,  0,  1,  1,  0,  0,  1,  1,  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,  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, 
+        1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  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,  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,  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, 
+        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,  2, 
+        2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  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,  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, 
+       }},
 };
 
-static unsigned long casemap_ctx_section16[] = {
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x40000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x02aaaaaa, 0x00000008, 0x00000000, 
-       0x55504010, 0x05540455, 0x45511100, 0x00040145, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-};
+/*
+ * Case Folding
+ */
 
-static unsigned long casemap_ctx_section24[] = {
-       0x00000000, 0x00000000, 0xaaa00000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00280000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-};
+#define CASE_FOLDING_BITS_0    9
+#define CASE_FOLDING_BITS_1    7
+#define CASE_FOLDING_BITS_2    5
 
-static unsigned long casemap_ctx_section125[] = {
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00001555, 0x20005540, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
+static unsigned short case_folding_imap[] = {
+         272,   400,   528,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   784, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         656,   656,   656,   656,   656,   656,   656,   656, 
+         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, 
+           0,    26,    27,     0,    28,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     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, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,    45,     0,    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,    47,    48,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     0,     0,     0, 
+           0,     0,     0,     0,     0,     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,     0,     0,     0,     0,     0, 
+           0,    50,     0,     0,     0,     0,     0,     0, 
 };
 
-static unsigned long casemap_ctx_section127[] = {
-       0x00000000, 0x00000000, 0x000000aa, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x55555554, 0x00155555, 
-       0x55555554, 0x00155555, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-       0x00000000, 0x00000000, 0x00000000, 0x00000000, 
+static struct {
+       unsigned short tbl[32];
+} 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,    9,   10, 
+         11,   12,   13,   14,   15,   16,   17,   18,   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,   27, 
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+       }},
+       {{
+         28,   29,   30,   31,   32,   33,   34,   35,   36,   37,   38, 
+         39,   40,   41,   42,   43,   44,   45,   46,   47,   48,   49, 
+         50,    0,   51,   52,   53,   54,   55,   56,   57,   58, 
+       }},
+       {{
+         60,    0,   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,   85,   86,    0,   87,    0, 
+         88,    0,    0,   89,    0,   90,    0,   91,    0,   92, 
+       }},
+       {{
+          0,   93,    0,   94,    0,   95,    0,   96,    0,   97,   99, 
+          0,  100,    0,  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,  123,    0,  124,    0,  125,    0,  126, 
+       }},
+       {{
+          0,  127,  128,    0,  129,    0,  130,  131,    0,  132,  133, 
+        134,    0,    0,  135,  136,  137,  138,    0,  139,  140,    0, 
+        141,  142,  143,    0,    0,    0,  144,  145,    0,  146, 
+       }},
+       {{
+        147,    0,  148,    0,  149,    0,  150,  151,    0,  152,    0, 
+          0,  153,    0,  154,  155,    0,  156,  157,  158,    0,  159, 
+          0,  160,  161,    0,    0,    0,  162,    0,    0,    0, 
+       }},
+       {{
+          0,    0,    0,    0,  163,  164,    0,  165,  166,    0,  167, 
+        168,    0,  169,    0,  170,    0,  171,    0,  172,    0,  173, 
+          0,  174,    0,  175,    0,  176,    0,    0,  177,    0, 
+       }},
+       {{
+        178,    0,  179,    0,  180,    0,  181,    0,  182,    0,  183, 
+          0,  184,    0,  185,    0,  186,  188,  189,    0,  190,    0, 
+        191,  192,  193,    0,  194,    0,  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, 
+       }},
+       {{
+          0,    0,  213,    0,  214,    0,  215,    0,  216,    0,  217, 
+          0,  218,    0,  219,    0,  220,    0,  221,    0,    0,    0, 
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+       }},
+       {{
+          0,    0,    0,    0,    0,  222,    0,    0,    0,    0,    0, 
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+       }},
+       {{
+          0,    0,    0,    0,    0,    0,  223,    0,  224,  225,  226, 
+          0,  227,    0,  228,  229,  230,  233,  234,  235,  236,  237, 
+        238,  239,  240,  241,  242,  243,  244,  245,  246,  247, 
+       }},
+       {{
+        248,  249,    0,  250,  251,  252,  253,  254,  255,  256,  257, 
+        258,    0,    0,    0,    0,  259,    0,    0,    0,    0,    0, 
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+       }},
+       {{
+          0,    0,  262,  263,    0,    0,    0,    0,    0,    0,    0, 
+          0,    0,    0,    0,    0,  264,  265,    0,    0,    0,  266, 
+        267,    0,    0,    0,  268,    0,  269,    0,  270,    0, 
+       }},
+       {{
+        271,    0,  272,    0,  273,    0,  274,    0,  275,    0,  276, 
+          0,  277,    0,  278,    0,  279,  280,  281,    0,    0,    0, 
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+       }},
+       {{
+        282,  283,  284,  285,  286,  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,    0,    0,    0,    0,    0,    0, 
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+       }},
+       {{
+        330,    0,  331,    0,  332,    0,  333,    0,  334,    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,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+          0,  347,    0,  348,    0,  349,    0,  350,    0,  351,    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, 
+       }},
+       {{
+          0,  373,    0,  374,    0,    0,    0,  375,    0,    0,    0, 
+        376,    0,    0,    0,    0,  377,    0,  378,    0,  379,    0, 
+        380,    0,  381,    0,  382,    0,  383,    0,  384,    0, 
+       }},
+       {{
+        385,    0,  386,    0,  387,    0,  388,    0,  389,    0,  390, 
+          0,  391,    0,  392,    0,  393,    0,  394,    0,  395,    0, 
+          0,    0,  396,    0,    0,    0,    0,    0,    0,    0, 
+       }},
+       {{
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+          0,    0,    0,    0,    0,    0,  397,  398,  399,  400,  401, 
+        402,  403,  404,  405,  406,  407,  408,  409,  410,  411, 
+       }},
+       {{
+        412,  413,  414,  415,  416,  417,  418,  419,  420,  421,  422, 
+        423,  424,  425,  426,  427,  428,  429,  430,  431,  432,  433, 
+        434,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+       }},
+       {{
+          0,    0,    0,    0,    0,    0,    0,  435,    0,    0,    0, 
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+       }},
+       {{
+        437,    0,  438,    0,  439,    0,  440,    0,  441,    0,  442, 
+          0,  443,    0,  444,    0,  445,    0,  446,    0,  447,    0, 
+        448,    0,  449,    0,  450,    0,  451,    0,  452,    0, 
+       }},
+       {{
+        453,    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,  514,  516,  518,  520,  522,    0,    0,    0,    0, 
+       }},
+       {{
+        523,    0,  524,    0,  525,    0,  526,    0,  527,    0,  528, 
+          0,  529,    0,  530,    0,  531,    0,  532,    0,  533,    0, 
+        534,    0,  535,    0,  536,    0,  537,    0,  538,    0, 
+       }},
+       {{
+        539,    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,    0,    0,    0,    0,    0,    0, 
+       }},
+       {{
+          0,    0,    0,    0,    0,    0,    0,    0,  568,  569,  570, 
+        571,  572,  573,  574,  575,    0,    0,    0,    0,    0,    0, 
+          0,    0,  576,  577,  578,  579,  580,  581,    0,    0, 
+       }},
+       {{
+          0,    0,    0,    0,    0,    0,    0,    0,  582,  583,  584, 
+        585,  586,  587,  588,  589,    0,    0,    0,    0,    0,    0, 
+          0,    0,  590,  591,  592,  593,  594,  595,  596,  597, 
+       }},
+       {{
+          0,    0,    0,    0,    0,    0,    0,    0,  598,  599,  600, 
+        601,  602,  603,    0,    0,  604,    0,  606,    0,  609,    0, 
+        612,    0,    0,  615,    0,  616,    0,  617,    0,  618, 
+       }},
+       {{
+          0,    0,    0,    0,    0,    0,    0,    0,  619,  620,  621, 
+        622,  623,  624,  625,  626,    0,    0,    0,    0,    0,    0, 
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+       }},
+       {{
+        627,  629,  631,  633,  635,  637,  639,  641,  643,  645,  647, 
+        649,  651,  653,  655,  657,  659,  661,  663,  665,  667,  669, 
+        671,  673,  675,  677,  679,  681,  683,  685,  687,  689, 
+       }},
+       {{
+        691,  693,  695,  697,  699,  701,  703,  705,  707,  709,  711, 
+        713,  715,  717,  719,  721,    0,    0,  723,  725,  727,    0, 
+        729,  731,  734,  735,  736,  737,  738,    0,  740,    0, 
+       }},
+       {{
+          0,    0,  741,  743,  745,    0,  747,  749,  752,  753,  754, 
+        755,  756,    0,    0,    0,    0,    0,  758,  761,    0,    0, 
+        764,  766,  769,  770,  771,  772,    0,    0,    0,    0, 
+       }},
+       {{
+          0,    0,  773,  776,  779,    0,  781,  783,  786,  787,  788, 
+        789,  790,    0,    0,    0,    0,    0,  791,  793,  795,    0, 
+        797,  799,  802,  803,  804,  805,  806,    0,    0,    0, 
+       }},
+       {{
+          0,    0,    0,    0,    0,    0,  808,    0,    0,    0,  809, 
+        810,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+       }},
+       {{
+        811,  812,  813,  814,  815,  816,  817,  818,  819,  820,  821, 
+        822,  823,  824,  825,  826,    0,    0,    0,    0,    0,    0, 
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+       }},
+       {{
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+        827,  828,  829,  830,  831,  832,  833,  834,  835,  836, 
+       }},
+       {{
+        837,  838,  839,  840,  841,  842,  843,  844,  845,  846,  847, 
+        848,  849,  850,  851,  852,    0,    0,    0,    0,    0,    0, 
+          0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
+       }},
+       {{
+        853,  855,  857,  859,  862,  865,  867,    0,    0,    0,    0, 
+          0,    0,    0,    0,    0,    0,    0,    0,  869,  871,  873, 
+        875,  877,    0,    0,    0,    0,    0,    0,    0,    0, 
+       }},
+       {{
+          0,  879,  880,  881,  882,  883,  884,  885,  886,  887,  888, 
+        889,  890,  891,  892,  893,  894,  895,  896,  897,  898,  899, 
+        900,  901,  902,  903,  904,    0,    0,    0,    0,    0, 
+       }},
 };
-
-static unsigned long *casemap_ctx_sections[] = {
-       casemap_ctx_section0,
-       casemap_ctx_section1,
-       casemap_ctx_section2,
-       casemap_ctx_section3,
-       casemap_ctx_section4,
-       casemap_ctx_section5,
-       casemap_ctx_section6,
-       casemap_ctx_section7,
-       casemap_ctx_section8,
-       NULL,
-       NULL,
-       casemap_ctx_section11,
-       casemap_ctx_section12,
-       NULL,
-       NULL,
-       casemap_ctx_section15,
-       casemap_ctx_section16,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       casemap_ctx_section24,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       casemap_ctx_section125,
-       NULL,
-       casemap_ctx_section127,
+static unsigned long case_folding_seq[] = {
+       0x00000000, 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, 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, 
+       0x80000069, 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, 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, 0x800003c2, 0x800003c4, 
+       0x800003c5, 0x800003c6, 0x800003c7, 0x800003c8, 
+       0x800003c9, 0x800003ca, 0x800003cb, 0x000003c5, 
+       0x00000308, 0x80000301, 0x800003c2, 0x800003c2, 
+       0x800003b2, 0x800003b8, 0x800003c6, 0x800003c0, 
+       0x800003db, 0x800003dd, 0x800003df, 0x800003e1, 
+       0x800003e3, 0x800003e5, 0x800003e7, 0x800003e9, 
+       0x800003eb, 0x800003ed, 0x800003ef, 0x800003ba, 
+       0x800003c1, 0x800003c2, 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, 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, 0x800004c8, 
+       0x800004cc, 0x800004d1, 0x800004d3, 0x800004d5, 
+       0x800004d7, 0x800004d9, 0x800004db, 0x800004dd, 
+       0x800004df, 0x800004e1, 0x800004e3, 0x800004e5, 
+       0x800004e7, 0x800004e9, 0x800004eb, 0x800004ed, 
+       0x800004ef, 0x800004f1, 0x800004f3, 0x800004f5, 
+       0x800004f9, 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, 0x00001f01, 0x800003b9, 0x00001f02, 
+       0x800003b9, 0x00001f03, 0x800003b9, 0x00001f04, 
+       0x800003b9, 0x00001f05, 0x800003b9, 0x00001f06, 
+       0x800003b9, 0x00001f07, 0x800003b9, 0x00001f20, 
+       0x800003b9, 0x00001f21, 0x800003b9, 0x00001f22, 
+       0x800003b9, 0x00001f23, 0x800003b9, 0x00001f24, 
+       0x800003b9, 0x00001f25, 0x800003b9, 0x00001f26, 
+       0x800003b9, 0x00001f27, 0x800003b9, 0x00001f20, 
+       0x800003b9, 0x00001f21, 0x800003b9, 0x00001f22, 
+       0x800003b9, 0x00001f23, 0x800003b9, 0x00001f24, 
+       0x800003b9, 0x00001f25, 0x800003b9, 0x00001f26, 
+       0x800003b9, 0x00001f27, 0x800003b9, 0x00001f60, 
+       0x800003b9, 0x00001f61, 0x800003b9, 0x00001f62, 
+       0x800003b9, 0x00001f63, 0x800003b9, 0x00001f64, 
+       0x800003b9, 0x00001f65, 0x800003b9, 0x00001f66, 
+       0x800003b9, 0x00001f67, 0x800003b9, 0x00001f60, 
+       0x800003b9, 0x00001f61, 0x800003b9, 0x00001f62, 
+       0x800003b9, 0x00001f63, 0x800003b9, 0x00001f64, 
+       0x800003b9, 0x00001f65, 0x800003b9, 0x00001f66, 
+       0x800003b9, 0x00001f67, 0x800003b9, 0x00001f70, 
+       0x800003b9, 0x000003b1, 0x800003b9, 0x000003ac, 
+       0x800003b9, 0x000003b1, 0x80000342, 0x000003b1, 
+       0x00000342, 0x800003b9, 0x80001fb0, 0x80001fb1, 
+       0x80001f70, 0x80001f71, 0x000003b1, 0x800003b9, 
+       0x800003b9, 0x00001f74, 0x800003b9, 0x000003b7, 
+       0x800003b9, 0x000003ae, 0x800003b9, 0x000003b7, 
+       0x80000342, 0x000003b7, 0x00000342, 0x800003b9, 
+       0x80001f72, 0x80001f73, 0x80001f74, 0x80001f75, 
+       0x000003b7, 0x800003b9, 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, 
+       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, 
 };
 
diff --git a/contrib/idn/mdnkit/lib/utf6.c b/contrib/idn/mdnkit/lib/utf6.c
new file mode 100644 (file)
index 0000000..6f0d942
--- /dev/null
@@ -0,0 +1,551 @@
+#ifndef lint
+static char *rcsid = "$Id: utf6.c,v 1.1 2001/06/09 00:30:30 tale 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+ * Tokyo, 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) Japan Network Information Center.  All rights reserved."
+ * 
+ * 4. Neither the name of JPNIC may 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.
+ * 
+ * 6. Indemnification by Licensee
+ *    Any person or entities using and/or redistributing this Software under
+ *    this License Terms and Conditions shall defend indemnify and hold
+ *    harmless JPNIC from and against any and all judgements damages,
+ *    expenses, settlement liabilities, cost and other liabilities of any
+ *    kind as a result of use and redistribution of this Software or any
+ *    claim, suite, action, litigation or proceeding by any third party
+ *    arising out of or relates to this License Terms and Conditions.
+ * 
+ * 7. Governing Law, Jurisdiction and Venue
+ *    This License Terms and Conditions shall be governed by and and
+ *    construed in accordance with the law of Japan. Any person or entities
+ *    using and/or redistributing this Software under this License Terms and
+ *    Conditions hereby agrees and consent to the personal and exclusive
+ *    jurisdiction and venue of Tokyo District Court of Japan.
+ */
+
+#include <config.h>
+
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <mdn/result.h>
+#include <mdn/assert.h>
+#include <mdn/logmacro.h>
+#include <mdn/converter.h>
+#include <mdn/utf8.h>
+#include <mdn/debug.h>
+#include <mdn/utf6.h>
+#include <mdn/ace.h>
+#include <mdn/util.h>
+
+#ifndef MDN_UTF6_PREFIX
+#define MDN_UTF6_PREFIX                "wq--"
+#endif
+
+#define UTF6_SAME_BYTE_MASK    0x00ff
+#define UTF6_SAME_NIBBLE_MASK  0x0fff
+#define UTF6_PLAIN_MASK                0xffff
+
+#define UTF6_BUF_SIZE          128             /* more than enough */
+
+/*
+ * Compression type.
+ */
+enum {
+       same_byte_mode,         /* the most significant byte of all non
+                                  '-' characters is the same value */
+       same_nibble_mode,       /* the most significant nibble of all non
+                                  '-' characters is the same value */
+       plain_mode              /* not compressed */
+};
+
+static mdn_result_t    utf6_decode(const char *from, size_t fromlen,
+                                   char *to, size_t tolen);
+static mdn_result_t    utf6_decode_utf16(const char *from, size_t fromlen,
+                                         unsigned short *buf, size_t *lenp);
+static mdn_result_t    utf6_decode_vlhex(const char *from, size_t len,
+                                         size_t *reslen,
+                                         unsigned short *value);
+static mdn_result_t    utf6_encode(const char *from, size_t fromlen,
+                                   char *to, size_t tolen);
+static mdn_result_t    utf6_encode_utf16(const unsigned short *p,
+                                         size_t len, char *to, size_t tolen,
+                                         int compress);
+static mdn_result_t    utf6_encode_vlhex(unsigned short value, char *to,
+                                         size_t tolen, size_t *reslen);
+static int             get_compress_mode(const unsigned short *p, size_t len);
+
+static mdn__ace_t utf6_ctx = {
+       mdn__ace_prefix,
+       MDN_UTF6_PREFIX,
+       utf6_encode,
+       utf6_decode,
+};
+
+/* ARGSUSED */
+mdn_result_t
+mdn__utf6_open(mdn_converter_t ctx, mdn_converter_dir_t dir, void **privdata) {
+       return (mdn_success);
+}
+
+/* ARGSUSED */
+mdn_result_t
+mdn__utf6_close(mdn_converter_t ctx, void *privdata, mdn_converter_dir_t dir) {
+       return (mdn_success);
+}
+
+mdn_result_t
+mdn__utf6_convert(mdn_converter_t ctx, void *privdata, mdn_converter_dir_t dir,
+                   const char *from, char *to, size_t tolen)
+{
+       mdn_result_t r;
+
+       assert(ctx != NULL &&
+              (dir == mdn_converter_l2u || dir == mdn_converter_u2l));
+
+       TRACE(("mdn__utf6_convert(dir=%s,from=\"%s\")\n",
+              dir == mdn_converter_l2u ? "l2u" : "u2l",
+              mdn_debug_xstring(from, 20)));
+
+       r = mdn__ace_convert(&utf6_ctx, dir, from, to, tolen);
+       if (r != mdn_success)
+               return (r);
+
+       DUMP(("mdn__utf6_convert: \"%s\"\n", mdn_debug_xstring(to, 70)));
+
+       return (r);
+}
+
+static mdn_result_t
+utf6_decode(const char *from, size_t fromlen, char *to, size_t tolen) {
+       unsigned short *buf;
+       unsigned short local_buf[UTF6_BUF_SIZE];
+       size_t len, reslen;
+       mdn_result_t r;
+
+       /*
+        * Allocate sufficient buffer.
+        */
+       if (fromlen > UTF6_BUF_SIZE) {
+               if ((buf = malloc(sizeof(*buf) * fromlen)) == NULL)
+                       return (mdn_nomemory);
+       } else {
+               /* Use local buffer. */
+               buf = local_buf;
+       }
+
+       /*
+        * Decode base32 and decompress.
+        */
+       r = utf6_decode_utf16(from, fromlen, buf, &len);
+       if (r != mdn_success)
+               goto ret;
+
+       /*
+        * Now 'buf' holds the decompressed string, which must contain
+        * UTF-16 characters.  Convert them into UTF-8.
+        */
+       r = mdn_util_utf16toutf8(buf, len, to, tolen, &reslen);
+       if (r != mdn_success)
+               goto ret;
+
+       /*
+        * Terminate with NUL.
+        */
+       if (tolen <= reslen) {
+               r = mdn_buffer_overflow;
+               goto ret;
+       }
+
+       to += reslen;
+       *to = '\0';
+       tolen -= reslen;
+
+       r = mdn_success;
+
+ret:
+       if (buf != local_buf)
+               free(buf);
+       return (r);
+}
+
+static mdn_result_t
+utf6_decode_utf16(const char *from, size_t fromlen,
+                 unsigned short *buf, size_t *lenp)
+{
+       mdn_result_t r;
+       unsigned short value;
+       unsigned short cpart;
+       unsigned short vmax;
+       size_t len;
+       size_t reslen;
+
+       /*
+        * Decode Base32 and put the result bytes to 'buf'.
+        * Since decoded string will be shorter in length, and
+        * the caller allocated 'buf' so that its length is not
+        * less than 'fromlen', we don't have to worry about overflow.
+        */
+
+       if (fromlen <= 0)
+           return mdn_success;
+
+       switch (*from) {
+       case 'y':
+       case 'Y':
+               /*
+                * same_byte_mode.
+                */
+               fromlen--;
+               from++;
+               r = utf6_decode_vlhex(from, fromlen, &reslen, &value);
+               if (r != mdn_success)
+                       return (mdn_invalid_encoding);
+               from += reslen;
+               fromlen -= reslen;
+
+               cpart = value * 0x0100;
+               vmax = 0x00ff;
+               break;
+
+       case 'z':
+       case 'Z':
+               /*
+                * same_nibble_mode.
+                */
+               fromlen--;
+               from++;
+               r = utf6_decode_vlhex(from, fromlen, &reslen, &value);
+               if (r != mdn_success)
+                       return (mdn_invalid_encoding);
+               from += reslen;
+               fromlen -= reslen;
+
+               cpart = value * 0x1000;
+               vmax = 0x0fff;
+               break;
+
+       default:
+               /*
+                * plain_mode.
+                */
+               cpart = 0x0000;
+               vmax = 0xffff;
+               break;
+       }
+
+       
+       for (len = 0; fromlen > 0; len++) {
+               if (*from == '-') {
+                       *buf++ = '-';
+                       from++;
+                       fromlen--;
+               } else {
+                       r = utf6_decode_vlhex(from, fromlen, &reslen, &value);
+                       if (r != mdn_success)
+                               return (mdn_invalid_encoding);
+                       if (value > vmax)
+                               return (mdn_invalid_encoding);
+                       *buf++ = cpart + value;
+                       from += reslen;
+                       fromlen -= reslen;
+               }
+       }
+
+       *buf = '\0';
+       *lenp = len;
+       return (mdn_success);
+}
+
+static mdn_result_t
+utf6_decode_vlhex(const char *from, size_t len, size_t *reslen,
+                 unsigned short *value) {
+       unsigned short v;
+       int i;
+
+       /*
+        * Decode the first character of a variable length HEX string.
+        * The character must be in set of [ghijklmnopqrstuv].
+        */
+       if (len <= 0)
+               return (mdn_invalid_encoding);
+
+       if ('G' <= *from && *from <= 'V')
+               v = *from - 'G';
+       else if ('g' <= *from && *from <= 'v')
+               v = *from - 'g';
+       else
+               return (mdn_invalid_encoding);
+       from++;
+       len--;
+       i = 1;
+
+       /*
+        * Decode the rest characters of a variable length HEX string.
+        * The every character must be in set of [0123456789abcdef].
+        */
+       for (;;) {
+               if (len <= 0)
+                       break;
+               if ('0' <= *from && *from <= '9')
+                       v = (v << 4) + (*from - '0');
+               else if ('A' <= *from && *from <= 'F')
+                       v = (v << 4) + 0x0a + (*from - 'A');
+               else if ('a' <= *from && *from <= 'f')
+                       v = (v << 4) + 0x0a + (*from - 'a');
+               else
+                       break;
+               from++;
+               len--;
+               i++;
+       }
+
+       *value = v;
+       *reslen = i;
+       return (mdn_success);
+}
+
+static mdn_result_t
+utf6_encode(const char *from, size_t fromlen, char *to, size_t tolen) {
+       unsigned short *buf;
+       unsigned short local_buf[UTF6_BUF_SIZE];        /* UTF-16 */
+       mdn_result_t r;
+       size_t buflen, len;
+
+       /*
+        * Convert to UTF-16.
+        */
+       buf = local_buf;
+       buflen = UTF6_BUF_SIZE;
+       for (;;) {
+               r = mdn_util_utf8toutf16(from, fromlen,
+                                        buf, buflen, &len);
+               if (r == mdn_buffer_overflow) {
+                       buflen *= 2;
+                       if (buf == local_buf)
+                               buf = malloc(sizeof(*buf) * buflen);
+                       else
+                               buf = realloc(buf, sizeof(*buf) * buflen);
+                       if (buf == NULL)
+                               return (mdn_nomemory);
+               } else if (r == mdn_success) {
+                       break;
+               } else {
+                       goto ret;
+               }
+       }
+
+       /*
+        * Compress, encode in base-32 and output.
+        */
+       r = utf6_encode_utf16(buf, len, to, tolen,
+                             get_compress_mode(buf, len));
+
+ret:
+       if (buf != local_buf)
+               free(buf);
+       return (r);
+}
+
+static mdn_result_t
+utf6_encode_utf16(const unsigned short *p, size_t len,
+                 char *to, size_t tolen, int compress_mode)
+{
+       mdn_result_t r;
+       unsigned short mask;
+       size_t reslen;
+       int i;
+
+       if (len <= 0)
+           return mdn_success;
+
+       switch (compress_mode) {
+       case same_byte_mode:
+               mask = UTF6_SAME_BYTE_MASK;
+
+               if (tolen < 1)
+                       return (mdn_buffer_overflow);
+               *to++ = 'y';
+               tolen--;
+               r = utf6_encode_vlhex((p[0] >> 8) & 0x00ff, to, tolen,
+                                     &reslen);
+               if (r != mdn_success)
+                       return (r);
+               to += reslen;
+               tolen -= reslen;
+
+               break;
+
+       case same_nibble_mode:
+               mask = UTF6_SAME_NIBBLE_MASK;
+
+               if (tolen < 1)
+                       return (mdn_buffer_overflow);
+               *to++ = 'z';
+               tolen--;
+               r = utf6_encode_vlhex((p[0] >> 4) & 0x0fff, to, tolen,
+                                     &reslen);
+               if (r != mdn_success)
+                       return (r);
+               to += reslen;
+               tolen -= reslen;
+
+               break;
+
+       default:
+               mask = UTF6_PLAIN_MASK;
+               break;
+       }
+
+       for (i = 0; i < len; i++) {
+               if (p[i] == '-') {
+                       if (tolen < 1)
+                               return (mdn_buffer_overflow);
+                       *to++ = '-';
+                       tolen--;
+                       
+               } else {
+                       r = utf6_encode_vlhex(p[i] & mask, to, tolen, &reslen);
+                       if (r != mdn_success)
+                               return (r);
+                       to += reslen;
+                       tolen -= reslen;
+               }
+       }
+
+       if (tolen <= 0)
+               return (mdn_buffer_overflow);
+
+       *to = '\0';
+       return (mdn_success);
+}
+
+static mdn_result_t
+utf6_encode_vlhex(unsigned short value, char *to, size_t tolen,
+                 size_t *reslen) {
+
+       static const char *vlhex_string1 = "ghijklmnopqrstuv";
+       static const char *vlhex_string2 = "0123456789abcdef";
+
+       /*
+        * Encode an integer in the range of 0x000 - 0xffff as variable
+        * length HEX string.
+        */
+       if (value <= 0x000f) {
+               if (tolen < 1)
+                       return (mdn_buffer_overflow);
+               *to++ = vlhex_string1[ value        & 0x0f];
+               *reslen = 1;
+
+       } else if (value <= 0x00ff) {
+               if (tolen < 2)
+                       return (mdn_buffer_overflow);
+               *to++ = vlhex_string1[(value >> 4)  & 0x0f];
+               *to++ = vlhex_string2[ value        & 0x0f];
+               *reslen = 2;
+
+       } else if (value <= 0x0fff) {
+               if (tolen < 3)
+                       return (mdn_buffer_overflow);
+               *to++ = vlhex_string1[(value >> 8)  & 0x0f];
+               *to++ = vlhex_string2[(value >> 4)  & 0x0f];
+               *to++ = vlhex_string2[ value        & 0x0f];
+               *reslen = 3;
+
+       } else {
+               if (tolen < 4)
+                       return (mdn_buffer_overflow);
+               *to++ = vlhex_string1[(value >> 12) & 0x0f];
+               *to++ = vlhex_string2[(value >> 8)  & 0x0f];
+               *to++ = vlhex_string2[(value >> 4)  & 0x0f];
+               *to++ = vlhex_string2[ value        & 0x0f];
+               *reslen = 4;
+       }
+
+       return (mdn_success);
+}
+
+static int
+get_compress_mode(const unsigned short *p, size_t len) {
+       int non_hyphens = 0;
+       unsigned short same_bytes = 0;
+       unsigned short same_nibbles = 0;
+       int i;
+
+       if (len <= 0)
+               return plain_mode;
+
+       for (i = 0; i < len; i++) {
+               if (p[i] != '-') {
+                       non_hyphens++;
+                       if ((p[0] & 0xff00) == (p[i] & 0xff00))
+                               same_bytes++;
+                       else if ((p[0] & 0xf000) == (p[i] & 0xf000))
+                               same_nibbles++;
+               }
+       }
+
+       if (non_hyphens < 2) {
+               /*
+                * The number of non '-' characters is less than 2.
+                */
+               return plain_mode;
+       } else if (same_bytes == non_hyphens) {
+               /*
+                * The same most significant byte of the every non '-'
+                * character is the same value.
+                */
+               return same_byte_mode;
+       } else if (same_nibbles == non_hyphens) {
+               /*
+                * The same most significant nibble of the every non '-'
+                * character is the same value.
+                */
+               return same_nibble_mode;
+       } else {
+               /*
+                * Not matched above.
+                */
+               return plain_mode;
+       }
+
+       /* Not reached */       
+}
index 2302b026f061b4d234a65e404100cd97a0b79c23..a3cad1a305122903806c31ccdf3d5a8778d40ce2 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
-static char *rcsid = "$Id: util.c,v 1.2 2000/11/14 00:15:36 ishisone Exp $";
+static char *rcsid = "$Id: util.c,v 1.8 2001/05/31 05:21:38 ishisone Exp $";
 #endif
 
 /*
@@ -68,11 +68,25 @@ static char *rcsid = "$Id: util.c,v 1.2 2000/11/14 00:15:36 ishisone Exp $";
 #include <mdn/result.h>
 #include <mdn/logmacro.h>
 #include <mdn/utf8.h>
+#include <mdn/util.h>
 
 /*
- * ASCII tolower() macro.
- * Note that this macro evaluates the argument multiple times.  Be careful.
+ * 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))
 
@@ -106,15 +120,35 @@ mdn_util_casematch(const char *s1, const char *s2, size_t n) {
 
 const char *
 mdn_util_domainspan(const char *s, const char *end) {
-       while (s < end &&
-              (('a' <= *s && *s <= 'z') ||
-               ('A' <= *s && *s <= 'Z') ||
-               ('0' <= *s && *s <= '9') ||
-               *s == '-'))
+       while (s < end && (ASCII_ISALNUM(*s) || *s == '-'))
                s++;
        return (s);
 }
 
+int
+mdn_util_validstd13(const char *s, const char *end) {
+       if (!ASCII_ISALNUM(*s))
+               return (0);
+       s++;
+       if (end == NULL) {
+               while (*s != '\0') {
+                       if (!ASCII_ISALNUM(*s) && *s != '-')
+                               return (0);
+                       s++;
+               }
+       } else {
+               while (s < end) {
+                       if (!ASCII_ISALNUM(*s) && *s != '-')
+                               return (0);
+                       s++;
+               }
+       }
+       s--;
+       if (!ASCII_ISALNUM(*s))
+               return (0);
+       return (1);
+}
+
 mdn_result_t
 mdn_util_utf8toutf16(const char *utf8, size_t fromlen,
                     unsigned short *utf16, size_t tolen, size_t *reslenp)
diff --git a/contrib/idn/mdnkit/lib/version.c b/contrib/idn/mdnkit/lib/version.c
new file mode 100644 (file)
index 0000000..9c7e489
--- /dev/null
@@ -0,0 +1,70 @@
+#ifndef lint
+static char *rcsid = "$Id: version.c,v 1.1 2001/06/09 00:30:31 tale 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+ * Tokyo, 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) Japan Network Information Center.  All rights reserved."
+ * 
+ * 4. Neither the name of JPNIC may 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.
+ * 
+ * 6. Indemnification by Licensee
+ *    Any person or entities using and/or redistributing this Software under
+ *    this License Terms and Conditions shall defend indemnify and hold
+ *    harmless JPNIC from and against any and all judgements damages,
+ *    expenses, settlement liabilities, cost and other liabilities of any
+ *    kind as a result of use and redistribution of this Software or any
+ *    claim, suite, action, litigation or proceeding by any third party
+ *    arising out of or relates to this License Terms and Conditions.
+ * 
+ * 7. Governing Law, Jurisdiction and Venue
+ *    This License Terms and Conditions shall be governed by and and
+ *    construed in accordance with the law of Japan. Any person or entities
+ *    using and/or redistributing this Software under this License Terms and
+ *    Conditions hereby agrees and consent to the personal and exclusive
+ *    jurisdiction and venue of Tokyo District Court of Japan.
+ */
+
+#include <config.h>
+
+#include <mdn/version.h>
+
+const char *
+mdn_version_getstring(void) {
+       return MDNKIT_VERSION;
+}
diff --git a/contrib/idn/mdnkit/lib/zldrule.c b/contrib/idn/mdnkit/lib/zldrule.c
deleted file mode 100644 (file)
index 1b451a4..0000000
+++ /dev/null
@@ -1,262 +0,0 @@
-#ifndef lint
-static char *rcsid = "$Id: zldrule.c,v 1.10 2000/09/20 02:47:33 ishisone 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
- * Tokyo, 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) Japan Network Information Center.  All rights reserved."
- * 
- * 4. Neither the name of JPNIC may 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.
- * 
- * 6. Indemnification by Licensee
- *    Any person or entities using and/or redistributing this Software under
- *    this License Terms and Conditions shall defend indemnify and hold
- *    harmless JPNIC from and against any and all judgements damages,
- *    expenses, settlement liabilities, cost and other liabilities of any
- *    kind as a result of use and redistribution of this Software or any
- *    claim, suite, action, litigation or proceeding by any third party
- *    arising out of or relates to this License Terms and Conditions.
- * 
- * 7. Governing Law, Jurisdiction and Venue
- *    This License Terms and Conditions shall be governed by and and
- *    construed in accordance with the law of Japan. Any person or entities
- *    using and/or redistributing this Software under this License Terms and
- *    Conditions hereby agrees and consent to the personal and exclusive
- *    jurisdiction and venue of Tokyo District Court of Japan.
- */
-
-#include <config.h>
-
-#include <stddef.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <mdn/result.h>
-#include <mdn/assert.h>
-#include <mdn/logmacro.h>
-#include <mdn/converter.h>
-#include <mdn/translator.h>
-#include <mdn/zldrule.h>
-#include <mdn/debug.h>
-
-typedef struct zld_rule {
-       struct zld_rule *next;
-       char *zld;
-       int zld_depth;
-       int nencodings;
-       mdn_converter_t ctx[1];         /* actually, a variable sized array */
-} zld_rule_t;
-
-struct mdn_zldrule {
-       zld_rule_t *rules;
-};
-
-static int     delayedopen = MDN_CONVERTER_RTCHECK;    /* XXX */
-
-static void            insert_rule(mdn_zldrule_t ctx, zld_rule_t *rule);
-static int             domain_depth(const char *domain);
-
-
-mdn_result_t
-mdn_zldrule_create(mdn_zldrule_t *ctxp) {
-       mdn_zldrule_t ctx;
-
-       assert(ctxp != NULL);
-
-       TRACE(("mdn_zldrule_create()\n"));
-
-       *ctxp = NULL;
-
-       if ((ctx = malloc(sizeof(*ctx))) == NULL) {
-               WARNING(("mdn_zldrule_create: malloc failed\n"));
-               return (mdn_nomemory);
-       }
-
-       ctx->rules = NULL;
-
-       *ctxp = ctx;
-       return (mdn_success);
-}
-
-void
-mdn_zldrule_destroy(mdn_zldrule_t ctx) {
-       zld_rule_t *rule;
-
-       assert(ctx != NULL);
-
-       TRACE(("mdn_zldrule_destroy()\n"));
-
-       rule = ctx->rules;
-       while (rule != NULL) {
-               zld_rule_t *next = rule->next;
-               int i;
-
-               free(rule->zld);
-               for (i = 0; i < rule->nencodings; i++)
-                       mdn_converter_destroy(rule->ctx[i]);
-               free(rule);
-               rule = next;
-       }
-
-       free(ctx);
-}
-
-mdn_result_t
-mdn_zldrule_add(mdn_zldrule_t ctx, const char *zld,
-               const char **encodings, int nencodings)
-{
-       mdn_result_t r;
-       zld_rule_t *rule;
-       size_t sz;
-       int i;
-
-       assert(ctx != NULL && zld != NULL && encodings != NULL &&
-              nencodings > 0);
-
-       TRACE(("mdn_zldrule_add(zld=%s)\n", zld));
-
-       sz = sizeof(*rule) + sizeof(mdn_converter_t) * nencodings;
-       if ((rule = malloc(sz)) == NULL) {
-               WARNING(("mdn_zldrule_add: malloc failed\n"));
-               return (mdn_nomemory);
-       }
-       rule->next = NULL;
-       rule->zld = NULL;
-       rule->zld_depth = 0;
-       rule->nencodings = 0;
-
-       r = mdn_translator_canonicalzld(zld, &rule->zld);
-       if (r != mdn_success)
-               goto error;
-
-       rule->zld_depth = domain_depth(rule->zld);
-
-       for (i = 0; i < nencodings; i++) {
-               r = mdn_converter_create(encodings[i], &rule->ctx[i],
-                                        delayedopen);
-               if (r != mdn_success)
-                       goto error;
-       }
-
-       insert_rule(ctx, rule);
-
-       return (mdn_success);
-
-error:
-       free(rule);
-       return (r);
-}
-
-mdn_result_t
-mdn_zldrule_select(mdn_zldrule_t ctx, const char *domain,
-                  char **zldp, mdn_converter_t *convctxp)
-{
-       char dummy[1024];
-       zld_rule_t *rule;
-       int i;
-       mdn_result_t r;
-
-       assert(ctx != NULL && domain != NULL &&
-              zldp != NULL && convctxp != NULL);
-
-       TRACE(("mdn_zldrule_select(domain=\"%s\")\n",
-             mdn_debug_xstring(domain, 30)));
-
-       for (rule = ctx->rules; rule != NULL; rule = rule->next) {
-               if (mdn_translator_matchzld(domain, rule->zld))
-                       goto found;
-       }
-       return (mdn_notfound);
-
-found:
-       *zldp = rule->zld;
-       if (rule->nencodings > 1) {
-               for (i = 0; i < rule->nencodings; i++) {
-                       mdn_converter_t convctx = rule->ctx[i];
-                       r = mdn_converter_convert(convctx, mdn_converter_l2u,
-                                                 domain, dummy,
-                                                 sizeof(dummy));
-                       if (r != mdn_success)
-                               continue;
-                       *convctxp = rule->ctx[i];
-                       return (mdn_success);
-               }
-               return (mdn_invalid_encoding);
-       } else {
-               *convctxp = rule->ctx[0];
-       }
-
-       return (mdn_success);
-}
-
-static void
-insert_rule(mdn_zldrule_t ctx, zld_rule_t *rule) {
-       zld_rule_t *prev, *cur;
-
-       for (prev = NULL, cur = ctx->rules;
-            cur != NULL;
-            prev = cur, cur = cur->next) {
-               if (cur->zld_depth <= rule->zld_depth) {
-                       rule->next = cur;
-                       if (prev == NULL)
-                               ctx->rules = rule;
-                       else
-                               prev->next = rule;
-                       return;
-               }
-       }
-       rule ->next = NULL;
-       if (prev == NULL)
-               ctx->rules = rule;
-       else
-               prev->next = rule;
-}
-
-static int
-domain_depth(const char *s) {
-       int n = 0;
-
-       if (s == NULL)
-               return (0);
-
-       while ((s = strchr(s, '.')) != NULL) {
-               n++;
-               s++;
-       }
-       return (n);
-}
diff --git a/contrib/idn/mdnkit/libtool b/contrib/idn/mdnkit/libtool
deleted file mode 100755 (executable)
index e41c013..0000000
+++ /dev/null
@@ -1,4284 +0,0 @@
-#! /bin/sh
-
-# libtool - Provide generalized library-building support services.
-# Generated automatically by ltconfig (GNU libtool 1.3.5 (1.385.2.206 2000/05/27 11:12:27))
-# 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
-# Libtool was configured as follows, on host go.dd.org:
-#
-# CC="gcc" CFLAGS="-g -I/usr/local/include" CPPFLAGS="" \
-# LD="/usr/bin/ld" LDFLAGS="" LIBS="" \
-# NM="/usr/bin/nm -B" RANLIB="ranlib" LN_S="ln -s" \
-# DLLTOOL="" OBJDUMP="" AS="" \
-#   ./ltconfig --cache-file=./config.cache --with-gcc --with-gnu-ld --no-verify ./ltmain.sh i386-unknown-netbsdelf1.5.
-#
-# Compiler and other test output produced by ltconfig, useful for
-# debugging ltconfig, is in ./config.log if it exists.
-
-# The version of ltconfig that generated this script.
-LTCONFIG_VERSION="1.3.5"
-
-# Shell to use when invoking shell scripts.
-SHELL="/bin/sh"
-
-# Whether or not to build shared libraries.
-build_libtool_libs=yes
-
-# Whether or not to build static libraries.
-build_old_libs=yes
-
-# Whether or not to optimize for fast installation.
-fast_install=yes
-
-# The host system.
-host_alias=i386-unknown-netbsdelf1.5.
-host=i386-unknown-netbsdelf1.5.
-
-# An echo program that does not interpret backslashes.
-echo="echo"
-
-# The archiver.
-AR="ar"
-
-# The default C compiler.
-CC="gcc"
-
-# The linker used to build libraries.
-LD="/usr/bin/ld"
-
-# Whether we need hard or soft links.
-LN_S="ln -s"
-
-# A BSD-compatible nm program.
-NM="/usr/bin/nm -B"
-
-# 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=.libs
-
-# How to create reloadable object files.
-reload_flag=" -r"
-reload_cmds="\$LD\$reload_flag -o \$output\$reload_objs"
-
-# How to pass a linker flag through the compiler.
-wl="-Wl,"
-
-# Object file suffix (normally "o").
-objext="o"
-
-# Old archive suffix (normally "a").
-libext="a"
-
-# Executable file suffix (normally "").
-exeext=""
-
-# Additional compiler flags for building library objects.
-pic_flag=" -fPIC"
-
-# Does compiler simultaneously support -c and -o options?
-compiler_c_o="yes"
-
-# Can we write directly to a .lo ?
-compiler_o_lo="yes"
-
-# Must we lock files when doing compilation ?
-need_locks="no"
-
-# Do we need the lib prefix for modules?
-need_lib_prefix=unknown
-
-# Do we need a version for libraries?
-need_version=unknown
-
-# Whether dlopen is supported.
-dlopen=unknown
-
-# Whether dlopen of programs is supported.
-dlopen_self=unknown
-
-# Whether dlopen of statically linked programs is supported.
-dlopen_self_static=unknown
-
-# Compiler flag to prevent dynamic linking.
-link_static_flag="-static"
-
-# Compiler flag to turn off builtin functions.
-no_builtin_flag=" -fno-builtin -fno-rtti -fno-exceptions"
-
-# Compiler flag to allow reflexive dlopens.
-export_dynamic_flag_spec="\${wl}--export-dynamic"
-
-# Compiler flag to generate shared objects directly from archives.
-whole_archive_flag_spec="\${wl}--whole-archive\$convenience \${wl}--no-whole-archive"
-
-# Compiler flag to generate thread-safe objects.
-thread_safe_flag_spec=""
-
-# Library versioning type.
-version_type=sunos
-
-# Format of library name prefix.
-libname_spec="lib\$name"
-
-# 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="\${libname}\${release}.so\$versuffix \${libname}\${release}.so\$major \${libname}\${release}.so \${libname}.so"
-
-# The coded name of the library, if different from the real name.
-soname_spec="\${libname}\${release}.so\$major"
-
-# Commands used to build and install an old-style archive.
-RANLIB="ranlib"
-old_archive_cmds="\$AR cru \$oldlib\$oldobjs~\$RANLIB \$oldlib"
-old_postinstall_cmds="\$RANLIB \$oldlib~chmod 644 \$oldlib"
-old_postuninstall_cmds=""
-
-# Create an old-style archive from a shared archive.
-old_archive_from_new_cmds=""
-
-# Commands used to build and install a shared archive.
-archive_cmds="\$LD -Bshareable \$libobjs \$deplibs \$linkopts -o \$lib"
-archive_expsym_cmds=""
-postinstall_cmds=""
-postuninstall_cmds=""
-
-# Method to check whether dependent libraries are shared objects.
-deplibs_check_method="unknown"
-
-# Command to use when deplibs_check_method == file_magic.
-file_magic_cmd=""
-
-# Flag that allows shared libraries with undefined symbols to be built.
-allow_undefined_flag=""
-
-# Flag that forces no undefined symbols.
-no_undefined_flag=""
-
-# Commands used to finish a libtool library installation in a directory.
-finish_cmds=""
-
-# Same as above, but a single script fragment to be evaled but not shown.
-finish_eval=""
-
-# Take the output of nm and produce a listing of raw symbols and C names.
-global_symbol_pipe="sed -n -e 's/^.*[  ]\\([ABCDGISTW]\\)[     ][      ]*\\(\\)\\([_A-Za-z][_A-Za-z0-9]*\\)\$/\\1 \\2\\3 \\3/p'"
-
-# Transform the output of nm in a proper C declaration
-global_symbol_to_cdecl="sed -n -e 's/^. .* \\(.*\\)\$/extern char \\1;/p'"
-
-# This is the shared library runtime path variable.
-runpath_var=LD_RUN_PATH
-
-# This is the shared library path variable.
-shlibpath_var=LD_LIBRARY_PATH
-
-# Is shlibpath searched before the hard-coded library search path?
-shlibpath_overrides_runpath=unknown
-
-# How to hardcode a shared library path into an executable.
-hardcode_action=immediate
-
-# Flag to hardcode $libdir into a binary during linking.
-# This must work even if $libdir does not exist.
-hardcode_libdir_flag_spec="\${wl}--rpath \${wl}\$libdir"
-
-# Whether we need a single -rpath flag with a separated argument.
-hardcode_libdir_separator=""
-
-# Set to yes if using DIR/libNAME.so during linking hardcodes DIR into the
-# resulting binary.
-hardcode_direct=no
-
-# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
-# resulting binary.
-hardcode_minus_L=no
-
-# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
-# the resulting binary.
-hardcode_shlibpath_var=unsupported
-
-# Compile-time system search path for libraries
-sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
-
-# Run-time system search path for libraries
-sys_lib_dlsearch_path_spec="/lib /usr/lib"
-
-# Fix the shell variable $srcfile for the compiler.
-fix_srcfile_path=""
-
-# Set to yes if exported symbols are required.
-always_export_symbols=no
-
-# The commands to list exported symbols.
-export_symbols_cmds="\$NM \$libobjs \$convenience | \$global_symbol_pipe | sed 's/.* //' | sort | uniq > \$export_symbols"
-
-# Symbols that should not be listed in the preloaded symbols.
-exclude_expsyms="_GLOBAL_OFFSET_TABLE_"
-
-# Symbols that must always be exported.
-include_expsyms=""
-
-### END LIBTOOL CONFIG
-
-# 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:
index c14d83c169756c5630e337e713b7a4762a4f0c97..c1cb8c0bf66508b507df11d13e85e84d9ebd0740 100644 (file)
@@ -1194,11 +1194,11 @@ EOF
 
   netbsd*)
     if echo __ELF__ | $CC -E - | grep __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
       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
     ;;
 
diff --git a/contrib/idn/mdnkit/make.wnt b/contrib/idn/mdnkit/make.wnt
new file mode 100644 (file)
index 0000000..cac8358
--- /dev/null
@@ -0,0 +1,92 @@
+# $Id: make.wnt,v 1.1 2001/06/09 00:29:31 tale 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+# Tokyo, 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) Japan Network Information Center.  All rights reserved."
+# 
+# 4. Neither the name of JPNIC may 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.
+# 
+# 6. Indemnification by Licensee
+#    Any person or entities using and/or redistributing this Software under
+#    this License Terms and Conditions shall defend indemnify and hold
+#    harmless JPNIC from and against any and all judgements damages,
+#    expenses, settlement liabilities, cost and other liabilities of any
+#    kind as a result of use and redistribution of this Software or any
+#    claim, suite, action, litigation or proceeding by any third party
+#    arising out of or relates to this License Terms and Conditions.
+# 
+# 7. Governing Law, Jurisdiction and Venue
+#    This License Terms and Conditions shall be governed by and and
+#    construed in accordance with the law of Japan. Any person or entities
+#    using and/or redistributing this Software under this License Terms and
+#    Conditions hereby agrees and consent to the personal and exclusive
+#    jurisdiction and venue of Tokyo District Court of Japan.
+
+all : force
+       copy include\config.h.win include\config.h
+       cd lib
+       $(MAKE) -f make.wnt
+       cd ..
+       cd mdnsproxy
+       $(MAKE) -f make.wnt
+       cd ..
+       cd wsock
+       $(MAKE) -f make.wnt
+       cd ..
+
+install : all
+       cd lib
+       $(MAKE) -f make.wnt install
+       cd ..
+       cd mdnsproxy
+       $(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 mdnsproxy
+       $(MAKE) -f make.wnt clean
+       cd ..
+       cd wsock
+       $(MAKE) -f make.wnt clean
+       cd ..
+
+force:
index 5ceb6fa961b5a2e6ffac12cf0a418a2ca04370f5..dd217127959b5fed86477009dab80a69d93df9b3 100644 (file)
@@ -1,4 +1,4 @@
-# $Id: Makefile.in,v 1.1 2000/09/08 03:17:31 ishisone Exp $
+# $Id: Makefile.in,v 1.5 2001/05/15 04:44:18 ishisone Exp $
 #
 # Copyright (c) 2000 Japan Network Information Center.  All rights reserved.
 #  
@@ -64,27 +64,33 @@ VPATH   = @srcdir@
 prefix  = @prefix@
 exec_prefix = @exec_prefix@
 
-ETCDIR  = @sysconfdir@
-MANDIR = @mandir@
+sysconfdir  = @sysconfdir@
+mandir = @mandir@
 
 INSTALL = @INSTALL@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_DATA = @INSTALL_DATA@
+MKINSTALLDIRS = @top_srcdir@/mkinstalldirs
+SHELL = @SHELL@
 
-GEN_FILES = mdnres.conf.5
-MAN5 = mdnres.conf.5
+GEN_FILES = mdn.conf.5 libmdn.3
+MAN3 = libmdn.3
+MAN5 = mdn.conf.5
 
 all: $(GEN_FILES)
 
 install: install-man
 
-install-man:
-       [ -d $(MANDIR) ] || mkdir $(MANDIR)
-       [ -d $(MANDIR)/man5 ] || mkdir $(MANDIR)/man5
-       $(INSTALL_DATA) $(MAN5) $(MANDIR)/man5
+install-man: $(MAN3) $(MAN5)
+       $(MKINSTALLDIRS) $(mandir)/man3
+       $(MKINSTALLDIRS) $(mandir)/man5
+       $(INSTALL_DATA) $(MAN3) $(mandir)/man3
+       $(INSTALL_DATA) $(MAN5) $(mandir)/man5
 
-mdnres.conf.5: mdnres.conf.5.in
-       sed 's%@ETCDIR@%$(ETCDIR)%' < $(srcdir)/mdnres.conf.5.in > $@
+mdn.conf.5: mdn.conf.5.in
+       sed 's%[@]sysconfdir[@]%$(sysconfdir)%' < $(srcdir)/mdn.conf.5.in > $@
+libmdn.3: libmdn.3.in
+       sed 's%[@]sysconfdir[@]%$(sysconfdir)%' < $(srcdir)/libmdn.3.in > $@
 
 clean:
        rm -f *~ $(GEN_FILES)
diff --git a/contrib/idn/mdnkit/man/libmdn.3.in b/contrib/idn/mdnkit/man/libmdn.3.in
new file mode 100644 (file)
index 0000000..9020478
--- /dev/null
@@ -0,0 +1,410 @@
+.\" $Id: libmdn.3.in,v 1.1 2001/06/09 00:30:33 tale 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+.\" Tokyo, 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) Japan Network Information Center.  All rights reserved."
+.\" 
+.\" 4. Neither the name of JPNIC may 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.
+.\" 
+.\" 6. Indemnification by Licensee
+.\"    Any person or entities using and/or redistributing this Software under
+.\"    this License Terms and Conditions shall defend indemnify and hold
+.\"    harmless JPNIC from and against any and all judgements damages,
+.\"    expenses, settlement liabilities, cost and other liabilities of any
+.\"    kind as a result of use and redistribution of this Software or any
+.\"    claim, suite, action, litigation or proceeding by any third party
+.\"    arising out of or relates to this License Terms and Conditions.
+.\" 
+.\" 7. Governing Law, Jurisdiction and Venue
+.\"    This License Terms and Conditions shall be governed by and and
+.\"    construed in accordance with the law of Japan. Any person or entities
+.\"    using and/or redistributing this Software under this License Terms and
+.\"    Conditions hereby agrees and consent to the personal and exclusive
+.\"    jurisdiction and venue of Tokyo District Court of Japan.
+.\"
+.TH libmdn 3 "Apr 23, 2001"
+.\"
+.SH NAME
+libmdn \- Mulitilingual Domain Name Handling Library
+.\"
+.SH SYNOPSIS
+.nf
+#include <mdn/api.h>
+
+mdn_result_t
+\fBmdn_nameinit\fP(void)
+
+mdn_result_t
+\fBmdn_encodename\fP(int\ actions,\ const\ char\ *from,\ char\ *to,\ size_t\ tolen)
+
+mdn_result_t
+\fBmdn_decodename\fP(int\ actions,\ const\ char\ *from,\ char\ *to,\ size_t\ tolen)
+
+char *
+\fBmdn_result_tostring\fP(mdn_result_t\ result)
+
+.\"
+.SH OVERVIEW
+The
+.B libmdn
+library supports various manipulations of multilingual domain names,
+including:
+.RS 2
+.IP \- 2
+encoding convesion
+.IP \- 2
+normalization
+.RE
+.PP
+.B Libmdn
+is designed according to IDNA framework where each application must do
+necessary preparations for the multilingual domain names before passing them
+to the resolver.
+.PP
+To help applications do the preparation, libmdn provides easy-to-use,
+high-level interface for the work.
+.PP
+This manual describes only a small subset of the API that libmdn provides,
+most important functions for application programmers.  For other API,
+please refer to the mDNkit's specification document (which is not yet
+available) or the libmdn's header files typically found under
+`/usr/local/include/mdn/' on your system.
+.\"
+.SH DESCRIPTION
+.PP
+The
+.B mdn_nameinit
+function initializes the whole library, and reads the default
+configuration file
+.BR mdn.conf ,
+which includes configuration parameters for multilingual domain name
+preparation.
+If
+.B mdn_nameinit
+is called more than once, the library initialization will take place
+only at the first call while the configuration file will be (re)read
+at every call.
+.PP
+If there are no errors,
+.B mdn_nameinit
+returns
+.BR mdn_success .
+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
+.B mdn_encodename
+or
+.B mdn_decodename
+is first called without prior calling of
+.BR mdn_nameinit .
+.\"
+.PP
+.B mdn_encodename
+function performs normalization and encoding conversion on the 
+multilingual domain name specified by
+.IR from ,
+and stores the result to
+.IR to ,
+whose length is specified by 
+.IR tolen .
+.I actions
+is a bitwise-OR of the following flags, specifying which subprocesses in
+the encoding process are to be employed.
+.RS 2
+.nf
+.ft CW
+#define MDN_LOCALCONV 0x0001 /* Local encoding <-> UTF-8 conversion */
+#define MDN_IDNCONV   0x0002 /* UTF-8 <-> IDN encoding conversion */
+#define MDN_NAMEPREP  0x0004 /* NAMEPREP */
+#define MDN_UNASCHECK 0x0008 /* Unassigned code point check */
+#define MDN_DELIMMAP  0x0100 /* Delimiter mapping */
+#define MDN_LOCALMAP  0x0200 /* Local mapping */
+.ft R
+.fi
+.RE
+.PP
+Details of this encoding process can be found in the section ``NAME ENCODING''.
+.PP
+For ordinary application, the following macro is provided for the convenience.
+.RS 2
+.nf
+.ft CW
+#define MDN_ENCODE_APP \e
+  (MDN_LOCALCONV|MDN_DELIMMAP|MDN_LOCALMAP|MDN_NAMEPREP|MDN_IDNCONV)
+.ft R
+.fi
+.RE
+.PP
+.B mdn_decodename
+function performs the reverse of
+.BR mdn_encodename .
+It converts the multilingual domain name given by
+.IR from ,
+which is represented in a special encoding called ACE,
+to the application's local codeset and stores into
+.IR to ,
+whose length is specified by
+.IR tolen .
+.I actions
+specifies which subprocesses in decoding process take place, as in
+.BR mdn_encodename ,
+except that only \f(CWMDN_IDNCONV\fP and \f(CWMDN_LOCALCONV\fP are allowed.
+Details of this decoding process can be found in the section ``NAME DECODING''.
+.PP
+For ordinary application, the following macro is provided for the convenience.
+.RS 2
+.nf
+.ft CW
+#define MDN_DECODE_APP    (MDN_IDNCONV|MDN_LOCALCONV)
+.ft R
+.fi
+.RE
+.PP
+All of the functions above return error code of type
+.BR mdn_result_t .
+All codes other than
+.B mdn_success
+indicates some kind of failure.
+.B mdn_result_tostring
+function takes an error code
+.I result
+and returns a pointer to the corresponding message string.
+.\"
+.SH "NAME ENCODING"
+Name encoding is a process that transforms the specified
+multilingual domain name to a certain string suitable for name
+resolution.
+.BR libmdn 's
+name encoding process consists of the following steps.
+.IP "(1) Encoding conversion (local codeset to UCS)"
+Convert the encoding of the given domain name to
+Unicode/ISO10646 UTF-8 format string.
+The source encoding must be one of the two encodings below:
+.RS 2
+.IP \- 2
+The application's local encoding (codeset).
+.IP \- 2
+The alternate encoding specified by the configuration file.
+.RE
+The latter is suppored because name decoding process may produce
+strings in the alternate encoding when its attempt to convert to the
+local encoding fails.  See the section ``NAME DECODING'' for details.
+.IP "(2) Local mapping"
+Apply any locale/language-specific mapping.  This process is
+further divided into two subprocesses:
+.RS 2
+.IP "(2-1) Delimiter mapping"
+Map certain characters to the domain name delimiter (U+002E).
+.IP "(2-2) Local mapping based on TLD"
+Apply character mapping whose rule is determined by the TLD of the name.
+.RE
+.IP "(3) NAMEPREP"
+Perform name preparation (NAMEPREP), which is a standard process for
+normalizing multilingual domain names.  This process includes checking
+of characters which are not allowed in multilingual domain names.
+.IP "(4) Encoding conversion (UCS to ACE)"
+Convert the NAMEPREPed name to a special encoding designed for representing
+multilingual 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.
+.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 mDNkit's configuration file,
+.BR mdn.conf .
+See mdn.conf(5) for details.
+.PP
+The libmdn API allows to skip some of these subprocesses.
+For example step (1) can be skipped if you have names already in
+UTF-8 format.
+.\"
+.SH "NAME DECODING"
+Name decoding is a reverse process of the name encoding.
+It transforms the specified
+multilingual 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.
+Name encoding involves NAMEPREP and local mapping in order for the names
+to be normalized, but name decoding presumes the name is already
+in normalized form, so these subprocesses are not in the decoding process.
+.PP
+.BR libmdn 's
+name decoding process consists of the following steps.
+.IP "(1) Encoding conversion (ACE to UCS)"
+Convert the encoding of the given domain name
+from a special one designed for representing
+multilingual domain names (ACE) to Unicode/ISO10646 UTF-8.
+.IP "(2) Encoding conversion (UCS to local codeset)"
+Convert the encoding of the name from UTF-8 to
+the application's local codeset.
+The local codeset is determined by the application's locale.
+.br
+However, it is possible that the conversion to the application's
+local codeset fails because the name includes some characters
+which don't have mappings to the local codeset.
+In this case, libmdn tries instead to convert to an encoding
+called ``alternate encoding,'' which is specified by the
+configuration file.  
+.PP
+The configuration parameters for this process,
+are also read from the configuration file
+.BR mdn.conf .
+.PP
+The libmdn API allows to skip some of these subprocesses.
+For example step (2) can be skipped if you want a name in
+UTF-8 format.
+.\"
+.SH "RETURN VALUES"
+Most of the
+.B libmdn
+API functions return values of type
+.B mdn_result_t
+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 mdn_success
+Not an error.  The call succeeded.
+.TP
+.SB mdn_notfound
+Specified information does not exist.
+.TP
+.SB mdn_invalid_encoding
+The encoding of the specified string is invalid.
+.TP
+.SB mdn_invalid_syntax
+There is a syntax error in the configuration file.
+.TP
+.SB mdn_invalid_name
+The specified name is not valid.
+.TP
+.SB mdn_invalid_message
+The specified DNS message is not valid.
+.TP
+.SB mdn_invalid_action
+The specified action contains invalid flags.
+.TP
+.SB mdn_invalid_codepoint
+The specified Unicode code point value is not valid.
+.TP
+.SB mdn_buffer_overflow
+The specified buffer is too small to hold the result.
+.TP
+.SB mdn_noentry
+The specified key does not exist in the hash table.
+.TP
+.SB mdn_nomemory
+Memory allocation using malloc failed.
+.TP
+.SB mdn_nofile
+The specified file could not be opened.
+.TP
+.SB mdn_nomapping
+Some characters do not have the mapping to the target character set.
+.TP
+.SB mdn_context_required
+Context information is required.
+.TP
+.SB mdn_prohibited
+The specified string contains some prohibited characters.
+.TP
+.SB mdn_failure
+Generic error which is not covered by the above codes.
+.\"
+.SH EXAMPLES
+To get the address of a multilingual domain name in the application's
+local codeset, use
+.B mdn_encodename
+to convert the name to the format suitable for passing to resolver functions.
+.RS 4
+.nf
+.ft CW
+mdn_result_t r;
+char ace_name[256];
+struct hostent *hp;
+
+\&...
+r = mdn_encodename(MDN_ENCODE_APP, name, ace_name,
+                   sizeof(ace_name));
+if (r != mdn_success) {
+    fprintf(stderr, "mdn_encodename failed: %s\en",
+            mdn_result_tostring(r));
+    exit(1);
+}
+
+hp = gethostbyname(ace_name);
+\&...
+.ft R
+.fi
+.RE
+.PP
+To decode the multilingual domain name returned from a resolver function,
+use
+.BR mdn_decodename .
+.RS 4
+.nf
+.ft CW
+mdn_result_t r;
+char local_name[256];
+struct hostent *hp;
+
+\&...
+hp = gethostbyname(name);
+r = mdn_decodename(MDN_DECODE_APP, hp->h_name, local_name,
+                   sizeof(local_name));
+if (r != mdn_success) {
+    fprintf(stderr, "mdn_decodename failed: %s\en",
+            mdn_result_tostring(r));
+    exit(1);
+}
+printf("name: %s\en", local_name);
+\&...
+.ft R
+.fi
+.RE
+.\"
+.SH FILES
+.I @sysconfdir@/mdn.conf
+.\"
+.SH "SEE ALSO"
+mdn.conf(5)
+
diff --git a/contrib/idn/mdnkit/man/mdn.conf.5.in b/contrib/idn/mdnkit/man/mdn.conf.5.in
new file mode 100644 (file)
index 0000000..bb0c9fd
--- /dev/null
@@ -0,0 +1,605 @@
+.\" $Id: mdn.conf.5.in,v 1.1 2001/06/09 00:30:33 tale 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+.\" Tokyo, 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) Japan Network Information Center.  All rights reserved."
+.\" 
+.\" 4. Neither the name of JPNIC may 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.
+.\" 
+.\" 6. Indemnification by Licensee
+.\"    Any person or entities using and/or redistributing this Software under
+.\"    this License Terms and Conditions shall defend indemnify and hold
+.\"    harmless JPNIC from and against any and all judgements damages,
+.\"    expenses, settlement liabilities, cost and other liabilities of any
+.\"    kind as a result of use and redistribution of this Software or any
+.\"    claim, suite, action, litigation or proceeding by any third party
+.\"    arising out of or relates to this License Terms and Conditions.
+.\" 
+.\" 7. Governing Law, Jurisdiction and Venue
+.\"    This License Terms and Conditions shall be governed by and and
+.\"    construed in accordance with the law of Japan. Any person or entities
+.\"    using and/or redistributing this Software under this License Terms and
+.\"    Conditions hereby agrees and consent to the personal and exclusive
+.\"    jurisdiction and venue of Tokyo District Court of Japan.
+.\"
+.TH mdn.conf 5 "Mar 1, 2001"
+.\"
+.SH NAME
+mdn.conf \- configuration file for internationalized domain name handling
+.\"
+.SH SYNOPSIS
+@sysconfdir@/mdn.conf
+.\"
+.SH DESCRIPTION
+.B mdn.conf
+is a configuration file for mDNkit,
+which is a toolkit for handling internationalized/multilingualized
+domain names.
+.PP
+To use internationalized domain names in DNS or other protocols, they
+must be converted to an appropriate format before further processing.
+In mDNkit, 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 and prohibited character
+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
+.B mdn.conf
+specifies the parameters for these tasks, such as:
+.RS 2
+.IP \- 2
+the encoding of internationalized domain names (IDN encoding).
+.IP \- 2
+NAMEPREP schemes.
+.IP \- 2
+the alternative encoding which is used in case the domain name in
+the IDN encoding cannot be convertible to the local encoding.
+.RE
+.\"
+.SH SYNTAX
+.B mdn.conf
+is a simple text file, 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 multilingualized domain names by resolvers and DNS
+servers.
+.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
+``RACE''
+.IP "\(bu" 2
+``BRACE''
+.IP "\(bu" 2
+``LACE''
+.IP "\(bu" 2
+``DUDE''
+.IP "\(bu" 2
+``UTF-6''
+.IP "\(bu" 2
+``AltDUDE''
+.IP "\(bu" 2
+``AMC-ACE-M''
+.IP "\(bu" 2
+``AMC-ACE-O''
+.IP "\(bu" 2
+``AMC-ACE-R''
+.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 ENTRY'')
+.RE
+.PP
+The standard encoding is being discussed by IETF IDN working group.
+.\"
+.SH "NAMEPREP ENTRY"
+Nameprep entry specifies the version of NAMEPREP, which is a specification
+of ``canonicalization'' process of multilingual domain name before
+it is converted to the IDN encoding.
+It is also being discussed by IETF IDN working group.
+.PP
+The syntax of this entry is:
+.PP
+.RS 4
+.nf
+\f(CWnameprep \fP\fIversion\fP
+.fi
+.RE
+.PP
+.I version
+is the version name of NAMEPREP specification, and currently
+the following 
+.IR version s
+can be specified.
+.RS 2
+.IP "\(bu" 2
+``nameprep-02''
+.br
+This version refers to Internet Draft ``draft-ietf-idn-nameprep-02.txt''.
+.IP "\(bu" 2
+``nameprep-03''
+.br
+This version refers to Internet Draft ``draft-ietf-idn-nameprep-03.txt''.
+.RE
+.PP
+The NAMEPREP process consists of the following 3 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/unassigned character checking, which detects invalid
+characters in a name.
+.PP
+This entry is a shorthand for specifying all of them at once.
+Actually,
+.PP
+.RS 4
+\f(CWnameprep \fP\fIversion\fP
+.RE
+.PP
+has the same effect of specifying following 4 entries.
+.PP
+.RS 4
+.nf
+\f(CWnameprep-map \fP\fIversion\fP
+\f(CWnameprep-normalize \fP\fIversion\fP
+\f(CWnameprep-prohibit \fP\fIversion\fP
+\f(CWnameprep-unassigned \fP\fIversion\fP
+.fi
+.RE
+.PP
+If both this entry and more-specific entries above are specified,
+more-specific ones take precedence.
+.\"
+.SH "NAMEPREP-MAP ENTRY"
+Mapping entry specifies the mapping scheme of NAMEPREP process.
+The syntax of this entry is:
+.PP
+.RS 4
+.nf
+\f(CWnameprep-map \fP\fIscheme\fP [\fIscheme\fP..]
+.fi
+.RE
+.PP
+.I scheme
+specifies the mapping scheme, and currently available schemes are:
+.RS 2
+.TP 4
+\f(CWnameprep-02\fP
+Specify mapping defined by NAMEPREP-02 draft.
+.TP 4
+\f(CWnameprep-03\fP
+Specify mapping defined by NAMEPREP-03 draft.
+.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
+More than one \fIscheme\fP can be specified.
+If multiple schemes are specified, they are applied in turn.
+.\"
+.SH "NAMEPREP-NORMALIZE ENTRY"
+Normalization entry specifies the normalization schemes which should be
+applied to the domain names before sending them to name servers.
+.\"
+The syntax of this entry is:
+.PP
+.RS 4
+.nf
+\f(CWnameprep-normalize \fP\fIscheme\fP [\fIscheme\fP..]
+.fi
+.RE
+.PP
+.I scheme
+is the normalization scheme, and following shows the currently available
+schemes:
+.RS 2
+.TP 4
+\f(CWnameprep-02\fP
+Synonim for \f(CWunicode-form-kc\fR.
+.TP 4
+\f(CWnameprep-03\fP
+Synonim for \f(CWunicode-form-kc\fR.
+.TP 4
+\f(CWascii-lowercase\fP
+Convert ASCII uppercase letters to lowercase.
+.TP 4
+\f(CWascii-uppercase\fP
+Convert ASCII lowercase letters to uppercase.
+.TP 4
+\f(CWunicode-lowercase\fP
+Convert Unicode uppercase letters to lowercase, based on ``Unicode
+Technical Report #21: Case Mappings''.
+Note that only locale-independent conversion is supported.
+.TP 4
+\f(CWunicode-uppercase\fP
+Convert Unicode lowercase letters to uppercase, based on ``Unicode
+Technical Report #21: Case Mappings''.
+Note that only locale-independent conversion is supported.
+.TP 4
+\f(CWunicode-foldcase\fP
+Perform Unicode case-folding for case-less string matching,
+which is also defined by ``Unicode Technical Report #21: Case Mappings''.
+.TP 4
+\f(CWunicode-form-c\fP
+Perform Unicode normalization called ``Unicode Normalization Form C''.
+.TP 4
+\f(CWunicode-form-kc\fP
+Perform Unicode normalization called ``Unicode Normalization Form KC''.
+.RE
+.PP
+More than one
+.IR scheme s
+can be specified.
+If multiple schemes are specified, they are applied in turn.
+.\"
+.SH "NAMEPREP-PROHIBIT ENTRY"
+Prohibit entry specifies the prohibited characters in the NAMEPREP
+process. The syntax of this entry is:
+.PP
+.RS 4
+.nf
+\f(CWnameprep-prohibit \fP\fIset\fP [\fIset\fP..]
+.fi
+.RE
+.PP
+.I set
+specifies the set of prohibited characters.  Currently following sets
+can be specified.
+.RS 2
+.TP 4
+\f(CWnameprep-02\fP
+Specify set of prohibited characters defined by NAMEPREP-02 draft.
+.TP 4
+\f(CWnameprep-03\fP
+Specify set of prohibited characters defined by NAMEPREP-03 draft.
+.TP 4
+\f(CWfileset:\fP\fIpathname\fP
+Specify set of prohibited characters defined by the file \fIpathname\fP.
+See ``SETFILE FORMAT '' for the format of this file.
+.RE
+.PP
+When more than one 
+.IR set s
+are specified, a character is considered prohibited if it belongs to
+any of those sets.
+.\"
+.SH "NAMEPREP-UNASSIGNED ENTRY"
+Unassigned entry specifies the unassigned codepoints in the NAMEPREP
+process. The syntax of this entry is:
+.PP
+.RS 4
+.nf
+\f(CWnameprep-unassigned \fP\fIset\fP [\fIset\fP..]
+.fi
+.RE
+.PP
+.I set
+specifies the set of unassigned characters.  Currently following sets
+can be specified.
+.RS 2
+.TP 4
+\f(CWnameprep-02\fP
+Specify set of unassigned characters defined by NAMEPREP-02 draft.
+.TP 4
+\f(CWnameprep-03\fP
+Specify set of unassigned characters defined by NAMEPREP-03 draft.
+.TP 4
+\f(CWfileset:\fP\fIpathname\fP
+Specify set of unassigned characters defined by the file \fIpathname\fP.
+See ``SETFILE FORMAT '' for the format of this file.
+.RE
+.PP
+When more than one 
+.IR set s
+are specified, a character is considered unassigned if it belongs to
+any one of those sets.
+.\"
+.SH "ALTERNATE-ENCODING ENTRY"
+mDNkit provides local codeset coversion feature, and in domain name
+decoding process, multilingual domain names are converted to the
+local codeset the application is using.
+However, it is possible that the conversion fails because some
+characters in the domain names have no mapping to the local codeset.
+This occurs, for example, when a Japanese application using Japanese
+codeset receives a DNS reply containing Chinese characters which
+are not included in the Japanese character set.
+.PP
+Alternative encoding entry specifies the codeset name to be used
+instead of the local codeset in case the above problem happens.
+.PP
+The syntax of this entry is:
+.PP
+.RS 4
+.nf
+\f(CWalternate-encoding \fP\fIencoding\fP
+.fi
+.RE
+.PP
+.I encoding
+is the name of the codeset.  It must be an ASCII-compatible
+encoding (ACE) such as ``RACE''.
+.\"
+.SH "ENCODING-ALIAS-FILE ENTRY"
+Encoding alias entry specifies the file containing codeset name aliases.
+The aliases can be used just as the real names.
+.PP
+The syntax of this entry is:
+.PP
+.RS 4
+.nf
+\f(CWencoding-alias-file \fP\fIpathname\fP
+.fi
+.RE
+.PP
+.I pathname
+specifies the path name of the alias file.
+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
+.I alias-name
+is the alias name to be defined, and
+.I name
+is the real name or another alias name.
+.\"
+.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
+.I tld
+specifies the TLD to which the mapping rule is to be applied, and
+.I scheme
+specifies the mapping scheme.  Available schemes are same as
+\f(CWnameprep-map\fR entry.  See ``NAMEPREP-MAP ENTRY'' for details.
+.PP
+There are two special
+.IR tld s
+for specifying the mapping rule for local domain names (domain names
+without any dots in them), and the default mapping rule.
+If
+.I tld
+is ``-'', it matches domain names which do not contain any dots.
+If
+.I tld
+is ``.'', it matches any domain names which don't match to any other
+mapping rules specified by ``local-map'' entries.
+.\"
+.SH "DELIMITER-MAP ENTRY"
+This entry specifies characters to be regarded as the domain name delimiter,
+which is period (``.'').
+.PP
+The syntax of this entry is:
+.PP
+.RS 4
+.nf
+\f(CWdelimiter-map \fIcodepoint\fR [\fIcodepoint\fR..]
+.fi
+.RE
+.PP
+.I codepoint
+specifies the Unicode codepoint value (in hexadecimal format) for the
+character to be regarded as a delimiter.
+.\"
+.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
+.I src-codepoint
+indicates source character of the mapping, and must be a Unicode codepoint
+value in hexadecimal string.
+.I mapped-codepoint-seq
+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 "SETFILE FORMAT"
+A setfile defines a set of characters, and is used for specifying
+prohibited/unasssigned characters.  The set is specified by
+enumerating either individual character codepoints or ranges of
+character codepoints.
+.PP
+A setfile is also a simple text file, and each line specifies a single
+character codepoint, or a range of codepoints as follows:
+.PP
+.RS 4
+.nf
+\fIcodepoint\fP
+\fIcodepoint-start\fR\f(CW-\fR\fIcodepoint-end\fR
+.fi
+.RE
+.PP
+.IR codepoint ,
+.I codepoint-start
+and
+.I codepoint-end
+are Unicode codepoint values in hexadecimal format.
+.PP
+Lines which begin with ``#'' are treated as comments and ignored.
+.PP
+A sample setfile is shown below.
+.PP
+.RS 4
+.nf
+.ft CW
+# Prohibit tilde
+007E
+# Prohibit control characters
+0000-001F
+007F-000F
+# Prohibit all the Unicode characters beyond BMP
+10000-10FFFF
+.ft R
+.fi
+.RE
+.\"
+.SH "LOCAL CODESET"
+.B mdn.conf
+does not 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 mDNkit 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 ``\fBMDN_LOCAL_CODESET\fR''.
+Just set the codeset name (or its alias name) to the variable, and
+mDNkit will use the codeset as the local one, regardless of the locale
+setting.
+.\"
+.SH "SAMPLE CONFIGURATION"
+The following shows a sample configuration file.
+.PP
+.RS 4
+.ft CW
+.nf
+#
+# a sample configuration.
+#
+
+# Use RACE as the IDN encoding.
+idn-encoding RACE
+
+# Use draft-ietf-idn-nameprep-03.txt as NAMEPREP.
+nameprep nameprep-03
+
+# Use BRACE as the alternative encoding.
+alternate-encoding BRACE
+
+# Regard U+3002 (IDEOGRAPHIC FULL STOP) and U+FF0E
+# (FULLWIDTH FULL STOP) as the domain component delimiter
+# as well as ``.''.
+delimiter-map U+3002 U+FF0E
+
+# Perform Japanese-specific mapping for .jp domain.
+# assuming /usr/local/lib/mdnkit/jp-map contains the mapping.
+local-map .jp filemap:/usr/local/lib/mdnkit/jp-map
+.fi
+.ft R
+.RE
+.\"
+.SH FILES
+.I @sysconfdir@/mdn.conf
+.br
+.I @sysconfdir@/mdn.conf.sample
+\- sample configuration with comments
+.\"
+.SH "SEE ALSO"
+iconv(3), mdnsproxy(8)
diff --git a/contrib/idn/mdnkit/man/mdnres.conf.5.in b/contrib/idn/mdnkit/man/mdnres.conf.5.in
deleted file mode 100644 (file)
index b4924b3..0000000
+++ /dev/null
@@ -1,296 +0,0 @@
-.\" $Id: mdnres.conf.5.in,v 1.6 2000/11/17 07:18:57 ishisone 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
-.\" Tokyo, 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) Japan Network Information Center.  All rights reserved."
-.\" 
-.\" 4. Neither the name of JPNIC may 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.
-.\" 
-.\" 6. Indemnification by Licensee
-.\"    Any person or entities using and/or redistributing this Software under
-.\"    this License Terms and Conditions shall defend indemnify and hold
-.\"    harmless JPNIC from and against any and all judgements damages,
-.\"    expenses, settlement liabilities, cost and other liabilities of any
-.\"    kind as a result of use and redistribution of this Software or any
-.\"    claim, suite, action, litigation or proceeding by any third party
-.\"    arising out of or relates to this License Terms and Conditions.
-.\" 
-.\" 7. Governing Law, Jurisdiction and Venue
-.\"    This License Terms and Conditions shall be governed by and and
-.\"    construed in accordance with the law of Japan. Any person or entities
-.\"    using and/or redistributing this Software under this License Terms and
-.\"    Conditions hereby agrees and consent to the personal and exclusive
-.\"    jurisdiction and venue of Tokyo District Court of Japan.
-.\"
-.TH mdnres.conf 5 "Sep 7, 2000"
-.\"
-.SH NAME
-mdnres.conf \- configuration file for the mDNkit client-side library
-.\"
-.SH SYNOPSIS
-@ETCDIR@/mdnres.conf
-.\"
-.SH DESCRIPTION
-.B mdnres.conf
-is read by the client-side resolver which is multilingualized
-(internationalized) using mDNkit.
-This file specifies various properties regarding multilingual domain names
-such as:
-.RS 4
-\- the encoding of domain names in DNS protocol.
-.br
-\- normalization schemes.
-.br
-\- the alternative encoding which is used in case the domain name in
-   the DNS reply message cannot be convertible to the local encoding.
-.br
-\- encoding name aliases.
-.RE
-.PP
-This file is a simple text file, and each line in the file
-(other than comment lines that begin with # and empty lines) forms an entry
-of the following format:
-.PP
-.RS 8
-.nf
-\fIkeyword\fP\ \fIvalue..\fP
-.fi
-.RE
-\."
-.SH "SERVER ENCODING ENTRY"
-Server encoding entry specifies the encoding name (codeset name) which
-is used as the encoding of multilingualized domain names by the DNS protocol.
-.PP
-The syntax of this entry is:
-.PP
-.RS 8
-.nf
-\f(CWserver-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 4
-.IP "\(bu" 2
-``UTF-8''
-.IP "\(bu" 2
-``RACE''
-.IP "\(bu" 2
-``BRACE''
-.IP "\(bu" 2
-``LACE''
-.IP "\(bu" 2
-``UTF-5''
-.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 ENTRY'')
-.RE
-.SH "SERVER ZLD ENTRY"
-Some of the encodings used by internationalized name servers (the one
-specified by `server-encoding' entry) requires ZLD (zero-level domain),
-additional toplevel domain that is hidden from users/applications.
-This entry specifies the ZLD.
-.PP
-The syntax of this entry is:
-.PP
-.RS 8
-.nf
-\f(CWserver-zld \fP\fIZLD\fP
-.fi
-.RE
-.PP
-Note that this entry is ignored unless mDNkit is configured with
-\f(CW--enable-zld\fR so that its ZLD support is enabled.
-.SH "NORMALIZATION ENTRY"
-Normalization entry specifies the normalization schemes which should be
-applied to the domain names before sending them to name servers.
-.\"
-The syntax of this entry is:
-.PP
-.RS 8
-.nf
-\f(CWnormalize \fP\fIscheme\fP [\fIscheme\fP..]
-.fi
-.RE
-.PP
-.I scheme
-is the normalization scheme, and following shows the currently available
-schemes:
-.RS 4
-.TP 4
-\f(CWascii-lowercase\fP
-Convert ASCII uppercase letters to lowercase.
-.TP 4
-\f(CWascii-uppercase\fP
-Convert ASCII lowercase letters to uppercase.
-.TP 4
-\f(CWunicode-lowercase\fP
-Convert Unicode uppercase letters to lowercase, based on ``Unicode
-Technical Report #21: Case Mappings''.
-Note that only locale-independent conversion is supported.
-.TP 4
-\f(CWunicode-uppercase\fP
-Convert Unicode lowercase letters to uppercase, based on ``Unicode
-Technical Report #21: Case Mappings''.
-Note that only locale-independent conversion is supported.
-.TP 4
-\f(CWunicode-form-c\fP
-Perform Unicode normalization called ``Unicode Normalization Form C''.
-.TP 4
-\f(CWunicode-form-kc\fP
-Perform Unicode normalization called ``Unicode Normalization Form KC''.
-.TP 4
-\f(CWja-compose-voiced-sound\fP
-Compose Japanese full-width hiragana/katakana character and the following
-(semi) voiced sound mark (dakuten or han-dakuten in Japanese) into a
-single combined letter if such letter exists.
-.TP 4
-\f(CWja-kana-fullwidth\fP
-Convert Japanese half-width kana characters to full-width.
-.TP 4
-\f(CWja-alnum-halfwidth\fP
-Convert full-width alphabets, digits and minus sign to half-width.
-.TP 4
-\f(CWja-minus-hack\fP
-Convert Japanese full-width minus sign
-(Unicode ``MINUS SIGN'') to ``\-'' (Unicode ``HYPHEN-MINUS'').
-.RE
-.PP
-More than one
-.I schemes
-can be specified.
-If multiple schemes are specified, they are applied in turn.
-.SH "ALTERNATIVE ENCODING ENTRY"
-The resolver library multilingualized by mDNkit automatically
-determines the local codeset the application uses, and tries to
-convert domain names in a DNS reply message to the codeset.
-However, it is possible that the conversion fails because some
-characters in the domain names have no mapping to the local codeset.
-This occurs, for example, when a Japanese application using Japanese
-codeset receives a DNS reply containing Chinese characters which
-are not included in the Japanese character set.
-.PP
-Alternative encoding entry specifies the codeset name to be used
-instead of the local codeset in case the above problem happens.
-.PP
-The syntax of this entry is:
-.PP
-.RS 8
-.nf
-\f(CWalternate-encoding \fP\fIencoding\fP
-.fi
-.RE
-.PP
-.I encoding
-is the name of the codeset.  It must be an ASCII-compatible
-encoding such as RACE.
-.\"
-.SH "ENCODING ALIAS ENTRY"
-Encoding alias entry specifies the file containing codeset name aliases.
-The aliases can be used just as the real names.
-.PP
-The syntax of this entry is:
-.PP
-.RS 8
-.nf
-\f(CWalias-file \fP\fIpathname\fP
-.fi
-.RE
-.PP
-.I pathname
-specifies the path name of the alias file.
-The alias file is a simple text file, consisting of lines of the form:
-.PP
-.RS 8
-.nf
-\fIalias-name\fP\ \fIname\fP
-.fi
-.RE
-.PP
-.I alias-name
-is the alias name to be defined, and
-.I name
-is the real name or another alias name.
-.\"
-.SH "LOCAL CODESET"
-.B mdnres.conf
-does not 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 mDNkit 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 ``MDN_LOCAL_CODESET''.
-Just set the codeset name (or its alias name) to the variable, and
-mDNkit will use the codeset as the local one, regardless of the locale
-setting.
-.SH "SAMPLE CONFIGURATION"
-The following shows a sample configuration file.
-.RS 4
-.ft CW
-.nf
-
-#
-# a sample configuration.
-#
-
-# Use RACE as the DNS protocol encoding.
-server-encoding RACE
-
-# Use lowercase conversion and Normalization Form KC for normalization.
-normalize unicode-lowercase unicode-form-kc
-
-# Use RACE as the alternative encoding.
-alternate-encoding RACE
-
-.fi
-.ft R
-.RE
-.\"
-.SH FILES
-.I @ETCDIR@/mdnres.conf
-.br
-.I @ETCDIR@/mdnres.conf.sample
-\- sample configuration with comments
-.\"
-.SH "SEE ALSO"
-iconv(3)
diff --git a/contrib/idn/mdnkit/map/Makefile.in b/contrib/idn/mdnkit/map/Makefile.in
new file mode 100644 (file)
index 0000000..1af5998
--- /dev/null
@@ -0,0 +1,87 @@
+# $Id: Makefile.in,v 1.1 2001/06/09 00:30:34 tale 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+# Tokyo, 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) Japan Network Information Center.  All rights reserved."
+# 
+# 4. Neither the name of JPNIC may 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.
+# 
+# 6. Indemnification by Licensee
+#    Any person or entities using and/or redistributing this Software under
+#    this License Terms and Conditions shall defend indemnify and hold
+#    harmless JPNIC from and against any and all judgements damages,
+#    expenses, settlement liabilities, cost and other liabilities of any
+#    kind as a result of use and redistribution of this Software or any
+#    claim, suite, action, litigation or proceeding by any third party
+#    arising out of or relates to this License Terms and Conditions.
+# 
+# 7. Governing Law, Jurisdiction and Venue
+#    This License Terms and Conditions shall be governed by and and
+#    construed in accordance with the law of Japan. Any person or entities
+#    using and/or redistributing this Software under this License Terms and
+#    Conditions hereby agrees and consent to the personal and exclusive
+#    jurisdiction and venue of Tokyo District Court of Japan.
+
+top_builddir = ..
+
+srcdir  = @srcdir@
+VPATH   = @srcdir@
+
+prefix  = @prefix@
+exec_prefix = @exec_prefix@
+
+datadir = @datadir@
+mapdir = $(datadir)/mdnkit
+
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+MKINSTALLDIRS = @top_srcdir@/mkinstalldirs
+SHELL = @SHELL@
+
+MAPS = jp.map
+
+all:
+
+install: install-data
+
+install-data: $(MAPS)
+       $(MKINSTALLDIRS) $(mapdir)
+       for map in $(MAPS); do \
+               $(INSTALL_DATA) $(srcdir)/$$map $(mapdir); done
+
+clean:
+       rm -f *~
diff --git a/contrib/idn/mdnkit/map/jp.map b/contrib/idn/mdnkit/map/jp.map
new file mode 100644 (file)
index 0000000..972641a
--- /dev/null
@@ -0,0 +1,66 @@
+# $Id: jp.map,v 1.1 2001/06/09 00:30:34 tale 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+# Tokyo, 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) Japan Network Information Center.  All rights reserved."
+# 
+# 4. Neither the name of JPNIC may 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.
+# 
+# 6. Indemnification by Licensee
+#    Any person or entities using and/or redistributing this Software under
+#    this License Terms and Conditions shall defend indemnify and hold
+#    harmless JPNIC from and against any and all judgements damages,
+#    expenses, settlement liabilities, cost and other liabilities of any
+#    kind as a result of use and redistribution of this Software or any
+#    claim, suite, action, litigation or proceeding by any third party
+#    arising out of or relates to this License Terms and Conditions.
+# 
+# 7. Governing Law, Jurisdiction and Venue
+#    This License Terms and Conditions shall be governed by and and
+#    construed in accordance with the law of Japan. Any person or entities
+#    using and/or redistributing this Software under this License Terms and
+#    Conditions hereby agrees and consent to the personal and exclusive
+#    jurisdiction and venue of Tokyo District Court of Japan.
+
+#
+# Local map table for JP domain.
+#
+
+# version=1.0
+
+2212; FF0D
+309B; 3099
+309C; 309A
similarity index 74%
rename from contrib/idn/mdnkit/dnsproxy/Makefile.in
rename to contrib/idn/mdnkit/mdnsproxy/Makefile.in
index c95879eb9735f5841610f780dd0fe03a35fd7ade..bfe2e9230c5a50ca772a37bf3ee6ae69ac05efdc 100644 (file)
@@ -1,4 +1,4 @@
-# $Id: Makefile.in,v 1.18 2000/11/17 07:36:37 ishisone Exp $
+# $Id: Makefile.in,v 1.1 2001/06/09 00:30:35 tale Exp $
 # Makefile for mDNS Proxy Server
 #
 # Copyright (c) 2000 Japan Network Information Center.  All rights reserved.
@@ -65,50 +65,53 @@ VPATH   = @srcdir@
 prefix  = @prefix@
 exec_prefix = @exec_prefix@
 
-SBINDIR = @sbindir@
-ETCDIR  = @sysconfdir@
-CONFIG_PATH = $(ETCDIR)
-MANDIR = @mandir@
+sbindir = @sbindir@
+sysconfdir = @sysconfdir@
+localstatedir = @localstatedir@
+logdir  = @logdir@
+mandir  = @mandir@
 
 CC      = @CC@
 PURIFY  = purify
 INSTALL = @INSTALL@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_DATA = @INSTALL_DATA@
+MKINSTALLDIRS = @top_srcdir@/mkinstalldirs
 SHELL   = @SHELL@
 LIBTOOL = @LIBTOOL@
 
 OPTS    =
 INCS    = -I$(srcdir)/../include -I../include
-DEFS    = -DUNIX -DCONFIG_PATH="\"$(CONFIG_PATH)/\""
+DEFS    = -DUNIX -DCONFIG_PATH="\"$(sysconfdir)\"" -DLOGDIR="\"$(logdir)\""
 CFLAGS  = $(OPTS) $(INCS) $(DEFS) @CFLAGS@
 LDFLAGS = $(OPTS) @LDFLAGS@
 
-LIBS    = ../lib/libmdn.la
-SYSLIBS = @LIBS@ @ICONVLIB@
+MDNLIB  = ../lib/libmdn.la
+ICONVLIB = @ICONVLIB@
+LIBS   = @LIBS@
 
 #
 # Files to build mDNS Proxy
 #
 
-SRCS = unxmain.c server.c message.c logging.c proxycnf.c translate.c
-OBJS = unxmain.o server.o message.o logging.o proxycnf.o translate.o
+SRCS = unxmain.c server.c message.c logging.c proxycnf.c translate.c acl.c
+OBJS = unxmain.o server.o message.o logging.o proxycnf.o translate.o acl.o
 
 #
 # Target to build
 #
 
-TARGETS = dnsproxy dnsproxy.8
+TARGETS = mdnsproxy mdnsproxy.8
 
 all : $(TARGETS)
 
-dnsproxy : $(OBJS) $(LIBS)
+mdnsproxy : $(OBJS) $(MDNLIB)
        $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ \
-               $(OBJS) $(LIBS) $(SYSLIBS)
+               $(OBJS) $(MDNLIB) $(ICONVLIB) $(LIBS)
 
-dnsproxy.purify : $(OBJS) $(LIBS)
+mdnsproxy.purify : $(OBJS) $(MDNLIB)
        $(LIBTOOL) --mode=link $(PURIFY) $(CC) $(LDFLAGS) -o $@ \
-               $(OBJS) $(LIBS) $(SYSLIBS)
+               $(OBJS) $(MDNLIB) $(ICONVLIB) $(LIBS)
 
 #
 # Installation
@@ -116,43 +119,35 @@ dnsproxy.purify : $(OBJS) $(LIBS)
 
 install: install-program install-config install-man
 
-install-program: dnsproxy
-       [ -d $(SBINDIR) ] || mkdir $(SBINDIR)
-       $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) dnsproxy $(SBINDIR)
+install-program: mdnsproxy
+       $(MKINSTALLDIRS) $(sbindir)
+       $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) mdnsproxy $(sbindir)
 
 # Do not overwrite existing configuration file.
 install-config:
-       [ -d $(ETCDIR) ] || mkdir $(ETCDIR)
-       @if [ -f $(ETCDIR)/dnsproxy.conf ]; then \
-           echo '** dnsproxy.conf already exists in the install directory.'; \
-           echo '** install as dnsproxy.conf.sample.'; \
-           $(INSTALL_DATA) $(srcdir)/dnsproxy.conf.sample $(ETCDIR)/; \
-       else \
-           echo installing sample configuration file.; \
-           $(INSTALL_DATA) $(srcdir)/dnsproxy.conf.sample \
-               $(ETCDIR)/dnsproxy.conf; fi
-
-install-man: dnsproxy.8
-       [ -d $(MANDIR) ] || mkdir $(MANDIR)
-       [ -d $(MANDIR)/man8 ] || mkdir $(MANDIR)/man8
-       $(INSTALL_DATA) dnsproxy.8 $(MANDIR)/man8
-
-dnsproxy.8: dnsproxy.8.in
-       sed 's%@ETCDIR@%$(ETCDIR)%' < $(srcdir)/dnsproxy.8.in > $@
+       $(MKINSTALLDIRS) $(sysconfdir)
+       echo installing sample configuration file.
+       $(INSTALL_DATA) $(srcdir)/mdnsproxy.conf.sample $(sysconfdir)/
+
+install-man: mdnsproxy.8
+       $(MKINSTALLDIRS) $(mandir)/man8
+       $(INSTALL_DATA) mdnsproxy.8 $(mandir)/man8
+
+mdnsproxy.8: mdnsproxy.8.in
+       sed -e 's%[@]sysconfdir[@]%$(sysconfdir)%' \
+               -e 's%[@]logdir[@]%$(logdir)%' $(srcdir)/mdnsproxy.8.in > $@
 
 clean:
        rm -f $(TARGETS) *.o core *.core *~
+       rm -fr .libs/
 
 #
 # Dependecnies
 #
 
-unxmain.o  : unxmain.c dnsproxy.h
-
-server.o   : server.c dnsproxy.h
-
-message.o  : message.c dnsproxy.h
-
-logging.o  : logging.c dnsproxy.h
-
-proxycnf.o   : proxycnf.c dnsproxy.h proxycnf.h
+unxmain.o  : unxmain.c mdnsproxy.h
+server.o   : server.c mdnsproxy.h
+message.o  : message.c mdnsproxy.h
+logging.o  : logging.c mdnsproxy.h
+proxycnf.o : proxycnf.c mdnsproxy.h proxycnf.h
+acl.o      : acl.c mdnsproxy.h
diff --git a/contrib/idn/mdnkit/mdnsproxy/acl.c b/contrib/idn/mdnkit/mdnsproxy/acl.c
new file mode 100644 (file)
index 0000000..8614ad9
--- /dev/null
@@ -0,0 +1,388 @@
+/*
+ * acl.c - managing access control list.
+ */
+
+/*
+ * 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+ * Tokyo, 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) Japan Network Information Center.  All rights reserved."
+ * 
+ * 4. Neither the name of JPNIC may 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.
+ * 
+ * 6. Indemnification by Licensee
+ *    Any person or entities using and/or redistributing this Software under
+ *    this License Terms and Conditions shall defend indemnify and hold
+ *    harmless JPNIC from and against any and all judgements damages,
+ *    expenses, settlement liabilities, cost and other liabilities of any
+ *    kind as a result of use and redistribution of this Software or any
+ *    claim, suite, action, litigation or proceeding by any third party
+ *    arising out of or relates to this License Terms and Conditions.
+ * 
+ * 7. Governing Law, Jurisdiction and Venue
+ *    This License Terms and Conditions shall be governed by and and
+ *    construed in accordance with the law of Japan. Any person or entities
+ *    using and/or redistributing this Software under this License Terms and
+ *    Conditions hereby agrees and consent to the personal and exclusive
+ *    jurisdiction and venue of Tokyo District Court of Japan.
+ */
+
+#ifndef lint
+static char *rcsid = "$Id: acl.c,v 1.1 2001/06/09 00:30:35 tale Exp $";
+#endif
+
+#include <config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#ifdef  WIN32
+#include <windows.h>
+#include <winsock.h>
+#else   /* for normal systems */
+#include <sys/types.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#endif
+
+#include "mdnsproxy.h"
+
+#ifdef TEST
+#undef WARN
+#define WARN printf
+#endif
+
+/*
+ * Entry in an access control list.
+ */
+typedef struct _acl acl_t;
+struct _acl {
+    struct in_addr address;            /* IP address */
+    struct in_addr netmask;            /* net mask */
+    acl_t *next;                       /* pointer to a next entry */
+};
+
+/*
+ * Access control list.
+ */
+static acl_t   *acl = NULL;
+
+
+/*
+ * Internal functions.
+ */
+static BOOL
+acl_parse_address(const char *pattern, struct in_addr *address, 
+                 struct in_addr *netmask, int lineNo);
+
+/*
+ * Initialize the access control list `acl'.
+ */
+int
+acl_initialize(void)
+{
+    struct in_addr address;
+    struct in_addr netmask;
+    config_ctx_t config_ctx;
+    acl_t *new_entry;
+    acl_t *last_entry;
+    int value_count;
+    char **values;
+    int lineNo;
+    int i;
+
+    TRACE("acl_initialize()\n");
+
+    acl = NULL;
+    last_entry = NULL;
+
+    config_ctx = config_query_open(KW_ALLOW_ACCESS, &value_count, &values,
+       &lineNo);
+
+    while (config_ctx != NULL) {
+       if (value_count < 2) {
+           WARN("acl_initialize - wrong # of args for \"%s\", line %d\n",
+               KW_ALLOW_ACCESS, lineNo);
+           return FALSE;
+       }
+
+       for (i = 1; i < value_count; i++) {
+           if (!acl_parse_address(values[i], &address, &netmask, lineNo))
+               return FALSE;
+
+           new_entry = (acl_t *)malloc(sizeof(acl_t));
+           if (new_entry == NULL) {
+               WARN("acl_initialize - cannot allocate memory\n");
+               return FALSE;
+           }
+           new_entry->address.s_addr = address.s_addr;
+           new_entry->netmask.s_addr = netmask.s_addr;
+           new_entry->next = NULL;
+
+           if (last_entry == NULL)
+               acl = new_entry;
+           else
+               last_entry->next = new_entry;
+           last_entry = new_entry;
+       }
+       config_ctx = config_query_more(config_ctx, &value_count, &values,
+           &lineNo);
+    }
+
+    return TRUE;
+}
+
+/*
+ * netmask length to netmask conversion table.
+ */
+static const unsigned long netmasks_by_mask_length[] = {
+    0x00000000UL, 0x80000000UL, 0xc0000000UL, 0xe0000000UL,  /*  0.. 3 */
+    0xf0000000UL, 0xf8000000UL, 0xfc000000UL, 0xfe000000UL,  /*  4.. 7 */
+    0xff000000UL, 0xff800000UL, 0xffc00000UL, 0xffe00000UL,  /*  8..12 */
+    0xfff00000UL, 0xfff80000UL, 0xfffc0000UL, 0xfffe0000UL,  /* 13..15 */
+    0xffff0000UL, 0xffff8000UL, 0xffffc000UL, 0xffffe000UL,  /* 16..19 */
+    0xfffff000UL, 0xfffff800UL, 0xfffffc00UL, 0xfffffe00UL,  /* 20..23 */
+    0xffffff00UL, 0xffffff80UL, 0xffffffc0UL, 0xffffffe0UL,  /* 24..27 */
+    0xfffffff0UL, 0xfffffff8UL, 0xfffffffcUL, 0xfffffffeUL,  /* 28..31 */
+    0xffffffffUL,                                            /* 32     */
+};
+
+/*
+ * Parse an ACL address pattern (e.g. 192.168.100/24), and put the result
+ * into `address' and `netmask'.  It returns TRUE upon success.
+ *
+ * We accepts the following address patterns:
+ * 
+ *     octet.octet.octet.octet
+ *     octet.octet.octet.octet/netmask
+ *     octet.octet.octet/netmask
+ *     octet.octet/netmask
+ *     octet/netmask
+ *
+ * Ommited octets are regarded as `0'.
+ */
+static BOOL
+acl_parse_address(const char *pattern, struct in_addr *address, 
+                 struct in_addr *netmask, int lineNo)
+{
+    unsigned int octets[4];
+    int netmask_length;
+    int digit_count;
+    int octet_count;
+    const char *p = pattern;
+
+    octets[1] = 0;
+    octets[2] = 0;
+    octets[3] = 0;
+    netmask_length = 32;
+
+    /*
+     * Parse an dot noted IP address.
+     */
+    octet_count = 0;
+    while (octet_count < 4) {
+       octets[octet_count] = 0;
+       if (*p == '0' && '0' <= *(p + 1) && *(p + 1) <= '9') {
+           WARN("acl_parse_address - invalid address \"%.100s\", line %d\n",
+               pattern, lineNo);
+           return FALSE;
+       }
+       for (digit_count = 0; '0' <= *p && *p <= '9'; p++, digit_count++)
+           octets[octet_count] = octets[octet_count] * 10 + (*p - '0');
+       if (digit_count == 0 || digit_count > 3 || octets[octet_count] > 255) {
+           WARN("acl_parse_address - invalid address \"%.100s\", line %d\n",
+               pattern, lineNo);
+           return FALSE;
+       }
+
+       octet_count++;
+       if (*p != '.')
+           break;
+       p++;
+    }
+
+    if (*p == '\0' && octet_count != 4) {
+       WARN("acl_parse_address - malformed address \"%.100s\", line %d\n",
+           pattern, lineNo);
+       return FALSE;
+    }
+
+    /*
+     * Parse an optional netmask length preceded by `/'.
+     */
+    if (*p == '/') {
+       netmask_length = 0;
+       p++;
+       if (*p == '0' && '0' <= *(p + 1) && *(p + 1) <= '9') {
+           WARN("acl_parse_address - invalid netmask length \"%.100s\", "
+               "line %d\n", pattern, lineNo);
+           return FALSE;
+       }
+       for (digit_count = 0; '0' <= *p && *p <= '9'; p++, digit_count++)
+           netmask_length = netmask_length * 10 + (*p - '0');
+       if (digit_count == 0 || digit_count > 2 || netmask_length > 32) {
+           WARN("acl_parse_address - invalid netmask length \"%.100s\", "
+               "line %d\n", pattern, lineNo);
+           return FALSE;
+       }
+    }
+
+    if (*p != '\0') {
+       WARN("acl_parse_address - invalid address \"%.100s\", line %d\n",
+           pattern, lineNo);
+       return FALSE;
+    }
+
+    /*
+     * Put the result into `address' and `netmask'.
+     */
+    address->s_addr = htonl((octets[0] << 24) + (octets[1] << 16)
+       + (octets[2] << 8) + octets[3]);
+    netmask->s_addr = htonl(netmasks_by_mask_length[netmask_length]);
+
+    /*
+     * Check address/netmask mismatch. (e.g. 192.168.10.8/16)
+     */
+    if ((address->s_addr & netmask->s_addr) != address->s_addr) {
+       WARN("acl_parse_address - address/netmask mismatch \"%.100s\", "
+           "line %d\n", pattern, lineNo);
+       return FALSE;
+    }
+
+    return TRUE;
+}
+
+/*
+ * Return TRUE if access from `address' is permitted or not.
+ * Note that we returns TRUE if no access control pattern is registered.
+ */
+BOOL
+acl_test(struct sockaddr *address)
+{
+    acl_t *acl_entry;
+    struct in_addr inet_address;
+
+    if (acl == NULL)
+       return TRUE;
+
+    inet_address.s_addr = ((struct sockaddr_in *)address)->sin_addr.s_addr;
+
+    for (acl_entry = acl; acl_entry != NULL; acl_entry = acl_entry->next) {
+       if ((inet_address.s_addr & acl_entry->netmask.s_addr)
+           == acl_entry->address.s_addr) {
+           return TRUE;
+       }
+    }
+
+    return FALSE;
+}
+
+/*
+ * Finalize the access control list `acl'.
+ */
+void
+acl_finalize(void)
+{
+    acl_t *acl_entry;
+    acl_t *saved_next;
+
+    acl_entry = acl;
+    while (acl_entry != NULL) {
+       saved_next = acl_entry->next;
+       free(acl_entry);
+       acl_entry = saved_next;
+    }
+
+    acl = NULL;
+}
+
+
+/*
+ * main for test.
+ * `proxycnf.o' and `logging.o' are reuqired to build this test program.
+ */
+#ifdef TEST
+
+#include <string.h>
+
+int
+main(int argc, char *argv[])
+{
+    char line[512];
+    char *newline;
+    struct sockaddr_in address;
+
+    printf("ACL allow/deny test program\n");
+    fflush(stdout);
+
+    if (config_load(argc, argv) != TRUE) {
+        printf("failed to load configurations\n");
+        return 1 ;
+    }
+    printf("loaded configuration.\n");
+
+    if (!acl_initialize()) {
+        printf("failed to initialize ACL\n");
+       return 1;
+    }
+
+    for (;;) {
+       printf("input address> ");
+       fflush(stdout);
+       if (fgets(line, 512, stdin) == NULL)
+           break;
+
+       newline = strpbrk(line, "\r\n");
+       if (newline != NULL)
+           *newline = '\0';
+
+       if (!inet_aton(line, &address.sin_addr)) {
+           printf("invalid address\n");
+           continue;
+       }
+
+       if (acl_test((struct sockaddr *)&address))
+           printf("access from %s is allowed.\n", line);
+       else
+           printf("access from %s is denied.\n", line);
+    }
+
+    acl_finalize();
+
+    return 0;
+}
+
+#endif /* TEST */
diff --git a/contrib/idn/mdnkit/mdnsproxy/logging.c b/contrib/idn/mdnkit/mdnsproxy/logging.c
new file mode 100644 (file)
index 0000000..93f5287
--- /dev/null
@@ -0,0 +1,557 @@
+/*
+ * logging.c - logging support
+ */
+
+/*
+ * 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+ * Tokyo, 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) Japan Network Information Center.  All rights reserved."
+ * 
+ * 4. Neither the name of JPNIC may 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.
+ * 
+ * 6. Indemnification by Licensee
+ *    Any person or entities using and/or redistributing this Software under
+ *    this License Terms and Conditions shall defend indemnify and hold
+ *    harmless JPNIC from and against any and all judgements damages,
+ *    expenses, settlement liabilities, cost and other liabilities of any
+ *    kind as a result of use and redistribution of this Software or any
+ *    claim, suite, action, litigation or proceeding by any third party
+ *    arising out of or relates to this License Terms and Conditions.
+ * 
+ * 7. Governing Law, Jurisdiction and Venue
+ *    This License Terms and Conditions shall be governed by and and
+ *    construed in accordance with the law of Japan. Any person or entities
+ *    using and/or redistributing this Software under this License Terms and
+ *    Conditions hereby agrees and consent to the personal and exclusive
+ *    jurisdiction and venue of Tokyo District Court of Japan.
+ */
+
+#ifndef lint
+static char *rcsid = "$Id: logging.c,v 1.1 2001/06/09 00:30:35 tale Exp $";
+#endif
+
+#include <config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#include <time.h>
+
+#ifdef HAVE_SYSLOG
+#include <syslog.h>
+#endif
+
+#include <mdn/log.h>
+#include <mdn/version.h>
+
+#include "mdnsproxy.h"
+
+#define DEFAULT_LOGFILE        "mdnsproxy.log"
+
+#ifdef DEBUG
+#define DEFAULT_LOG_LEVEL LOGLEVEL_TRACE
+#else
+#define DEFAULT_LOG_LEVEL LOGLEVEL_WARN
+#endif
+
+#ifndef LOGDIR
+#define LOGDIR "/var/mdnsproxy"
+#endif
+
+/*
+ * Logging Control Variables
+ */
+
+static  char    logFname[256] = { 0 } ;
+static  FILE    *logFptr = NULL       ;
+static  int    logMode = LOGMODE_FILE;
+static int     logFacility;
+static int     logLevel = DEFAULT_LOG_LEVEL ;
+static  int    timeToTurnOver = 0 ;
+
+/*
+ * log_default_path -- get default log file pathname
+ */
+
+static void    log_default_path(void)
+{
+#ifdef UNIX
+    sprintf(logFname, "%s/%s", LOGDIR, DEFAULT_LOGFILE) ;
+#endif
+#if defined(WIN32) || defined(OS2)
+    {
+       char *env;
+       if ((env = getenv("TEMP")) == NULL)
+           env = getenv("TMP");
+       if (env != NULL &&
+           strlen(env) + strlen(DEFAULT_LOGFILE) + 1 < sizeof(logFname)) {
+           (void)strcpy(logFname, env);
+           (void)strcat(logFname, "\\");
+           (void)strcat(logFname, DEFAULT_LOGFILE);
+       }
+    }
+#endif
+}    const char *name;
+
+
+/*
+ * log_setlevel - set log level
+ */
+void   log_setlevel(int level)
+{
+    logLevel = level;
+}
+
+/*
+ * log_strtolevel - string to log level
+ */
+int    log_strtolevel(char *s)
+{
+    if ('0' <= s[0] && s[0] <= '9') {
+       return atoi(s) ;
+    } else if (!strcmp(s, "none")) {
+       return LOGLEVEL_NONE;
+    } else if (!strcmp(s, "fatal")) {
+       return LOGLEVEL_FATAL;
+    } else if (!strcmp(s, "warn") || !strcmp(s, "warning")) {
+       return LOGLEVEL_WARN;
+    } else if (!strcmp(s, "trace")) {
+       return LOGLEVEL_TRACE;
+    } else {
+       return -1;
+    }
+}
+
+typedef struct {
+    const char *name;
+    int value;
+} syslog_facility_t;
+
+static const syslog_facility_t facility_table[] = {
+#ifdef LOG_AUTH
+    {"auth",           LOG_AUTH},
+#endif
+#ifdef LOG_AUTHPRIV
+    {"authpriv",       LOG_AUTHPRIV},
+#endif
+#ifdef LOG_CRON
+    {"cron",           LOG_CRON},
+#endif
+#ifdef LOG_DAEMON
+    {"daemon",         LOG_DAEMON},
+#endif
+#ifdef LOG_FTP
+    {"ftp",            LOG_FTP},
+#endif
+#ifdef LOG_KERN
+    {"kern",           LOG_KERN},
+#endif
+#ifdef LOG_LOCAL0
+    {"local0",         LOG_LOCAL0},
+#endif
+#ifdef LOG_LOCAL1
+    {"local1",         LOG_LOCAL1},
+#endif
+#ifdef LOG_LOCAL2
+    {"local2",         LOG_LOCAL2},
+#endif
+#ifdef LOG_LOCAL3
+    {"local3",         LOG_LOCAL3},
+#endif
+#ifdef LOG_LOCAL4
+    {"local4",         LOG_LOCAL4},
+#endif
+#ifdef LOG_LOCAL5
+    {"local5",         LOG_LOCAL5},
+#endif
+#ifdef LOG_LOCAL6
+    {"local6",         LOG_LOCAL6},
+#endif
+#ifdef LOG_LOCAL7
+    {"local7",         LOG_LOCAL7},
+#endif
+#ifdef LOG_LPR
+    {"lpr",            LOG_LPR},
+#endif
+#ifdef LOG_MAIL
+    {"mail",           LOG_MAIL},
+#endif
+#ifdef LOG_NEWS
+    {"news",           LOG_NEWS},
+#endif
+#ifdef LOG_SYSLOG
+    {"syslog",         LOG_SYSLOG},
+#endif
+#ifdef LOG_USER
+    {"user",           LOG_USER},
+#endif
+#ifdef LOG_UUCP
+    {"uucp",           LOG_UUCP},
+#endif
+    {NULL,             0}
+};
+
+/*
+ * log_strtofacility - string to log facility
+ */
+static int     log_strtofacility(char *name, int *value)
+{
+    const syslog_facility_t *p;
+
+    for (p = facility_table; p->name != NULL; p++) {
+       if (strcmp(name, p->name) == 0) {
+           *value = p->value;
+           return 1;
+       }
+    }
+
+    return 0;
+}
+
+/*
+ * log_terminate - terminate logging
+ */
+
+void    log_terminate(void)
+{
+    if (logMode == LOGMODE_FILE && logFptr != NULL) {
+       fclose(logFptr) ;
+       logFptr = NULL  ;
+    }
+}
+
+/*
+ * log_turnover_request - request turning over log
+ *     this function is intended for calling from singnal handler.
+ */
+
+void   log_turnover_request(void)
+{
+    timeToTurnOver = 1;
+}
+
+/*
+ * log_turnover - turn over log if requested
+ */
+
+void   log_turnover(void)
+{
+    if (timeToTurnOver && logMode == LOGMODE_FILE) {
+       timeToTurnOver = 0;
+       log_trace_printf("--- log file turned over\n");
+       log_terminate() ;
+    }
+}
+
+/*
+ * libmdn_logproc_file - log hander for libmdn
+ *     output message to a regular log file.
+ */
+static void
+libmdn_logproc_file(int level, const char *buf)
+{
+    switch (level) {
+    case mdn_log_level_fatal:
+        FATAL((char *)buf);
+        break;
+    case mdn_log_level_warning:
+    case mdn_log_level_info:
+        WARN((char *)buf);
+        break;
+    case mdn_log_level_trace:
+    case mdn_log_level_dump:
+        TRACE((char *)buf);
+        break;
+    }
+}
+
+/*
+ * libmdn_logproc_syslog - log hander for libmdn.
+ *     output message to syslog.
+ */
+static void
+libmdn_logproc_syslog(int level, const char *buf)
+{
+#ifdef HAVE_SYSLOG
+    switch (level) {
+    case mdn_log_level_fatal:
+       syslog(LOG_ERR, "[FATAL] %s", buf);
+       break;
+    case mdn_log_level_error:
+       syslog(LOG_ERR, "[ERROR] %s", buf);
+       break;
+    case mdn_log_level_warning:
+       syslog(LOG_WARNING, "[WARNING] %s", buf);
+       break;
+    case mdn_log_level_info:
+       syslog(LOG_INFO, "[INFO] %s", buf);
+       break;
+    case mdn_log_level_trace:
+       syslog(LOG_DEBUG, "[TRACE] %s", buf);
+       break;
+    case mdn_log_level_dump:
+       syslog(LOG_DEBUG, "[DUMP] %s", buf);
+       break;
+    default:
+       syslog(LOG_NOTICE, "[LEVEL%d] %s", level, buf);
+       break;
+    }
+#endif /* HAVE_SYSLOG */
+}
+
+/*
+ * libmdn_string_to_loglevel - convert log level name to value.
+ */
+
+static int
+libmdn_string_to_loglevel(char *s)
+{
+    if ('0' <= s[0] && s[0] <= '9')
+       return atoi(s);
+    else if (!strcmp(s, "fatal"))
+       return mdn_log_level_fatal;
+    else if (!strcmp(s, "error"))
+       return mdn_log_level_error;
+    else if (!strcmp(s, "warning"))
+       return mdn_log_level_warning;
+    else if (!strcmp(s, "info"))
+       return mdn_log_level_info;
+    else if (!strcmp(s, "trace"))
+       return mdn_log_level_trace;
+    else if (!strcmp(s, "dump"))
+       return mdn_log_level_dump;
+    else
+       return -1;
+}
+
+/*
+ * log_vprintf - as name describes
+ */
+
+static void    log_vprintf(int level, char *fmt, va_list arg_ptr)
+{
+    char    buff[512] ;
+    
+    if (logLevel < level) {
+       return;
+    }
+
+    /*
+     * format message
+     */
+     
+    vsprintf(buff, fmt, arg_ptr) ;
+
+#ifdef  DEBUG
+    printf("%s", buff) ;
+    fflush(stdout)    ;
+#endif
+
+    if (logMode == LOGMODE_SYSLOG) {
+#ifdef HAVE_SYSLOG
+       switch (level) {
+       case LOGLEVEL_FATAL:
+           syslog(LOG_ERR, buff);
+           break;
+       case LOGLEVEL_WARN:
+           syslog(LOG_WARNING, buff);
+           break;
+       case LOGLEVEL_TRACE:
+           syslog(LOG_DEBUG, buff);
+           break;
+       }
+#endif /* HAVE_SYSLOG */
+    } else if (logFptr != NULL) {
+       fputs(buff, logFptr) ;
+       fflush(logFptr) ;
+    }
+
+#ifdef  WIN32               /* For NT, having trouble with      */
+    fclose(logFptr) ;       /* reading open'd logging file      */
+    logFptr = NULL  ;       /* so, close and re-open it         */
+#endif
+}
+
+/*
+ * log_fatal_printf, log_warn_printf, log_trace_printf - write out
+ *     fatal/warning/trace log to the log file
+ */
+
+void    log_fatal_printf(char *fmt, ...)
+{
+    va_list arg_ptr   ;
+    
+    va_start(arg_ptr, fmt) ;
+    log_vprintf(LOGLEVEL_FATAL, fmt, arg_ptr) ;
+    va_end(arg_ptr) ;
+}
+
+void    log_warn_printf(char *fmt, ...)
+{
+    va_list arg_ptr   ;
+    
+    va_start(arg_ptr, fmt) ;
+    log_vprintf(LOGLEVEL_WARN, fmt, arg_ptr) ;
+    va_end(arg_ptr) ;
+}
+
+void    log_trace_printf(char *fmt, ...)
+{
+    va_list arg_ptr   ;
+    
+    va_start(arg_ptr, fmt) ;
+    log_vprintf(LOGLEVEL_TRACE, fmt, arg_ptr) ;
+    va_end(arg_ptr) ;
+}
+
+/*
+ * log_configure - configure logging (must be called after 'config_load')
+ */
+
+BOOL    log_configure(int ac, char *av[])
+{
+    int     i, nArgs   ;
+    char    **aArgs    ;
+    char    *fn = NULL ;
+    int     lineNo;
+
+    log_default_path();
+
+#ifdef HAVE_SYSLOG
+    logFacility = LOG_DAEMON;
+#endif
+
+    for (i = 1 ; i < ac ; i++) {
+        if (strcmp(av[i], CMDOPT_LOGFILE) == 0) {
+           fn = av[i+=1] ;
+       }
+    }
+    if (fn != NULL) {
+       if (strlen(fn) + 1 < sizeof(logFname)) {
+               WARN("log_configure - too long log file name \"%.100s...\"\n",
+                    fn);
+           return FALSE;
+       }
+        strcpy(logFname, fn) ;
+
+    } else if (config_query_value(KW_LOG_FILE, &nArgs, &aArgs, &lineNo)) {
+       if (nArgs != 2) {
+           WARN("log_configure - wrong # of args for \"%s\", line %d\n", 
+               KW_LOG_FILE, lineNo);
+           return FALSE;
+       }
+        strcpy(logFname, aArgs[1]) ;
+    }
+
+    if (config_query_value(KW_LOG_LEVEL, &nArgs, &aArgs, &lineNo) == TRUE) {
+       int level ;
+
+       if (nArgs != 2) {
+           WARN("log_configure - wrong # of args for \"%s\", line %d\n",
+               KW_LOG_LEVEL, lineNo);
+           return FALSE;
+       }
+       if ((level = log_strtolevel(aArgs[1])) < 0) {
+           WARN("log_configure - invalid log level \"%.100s\", line %d\n",
+               aArgs[1], lineNo);
+           return FALSE;
+       }
+       log_setlevel(level);
+    }
+
+    if (config_query_value(KW_MDN_LOG_LEVEL, &nArgs, &aArgs, &lineNo)) {
+       int level;
+
+       if (nArgs != 2) {
+           WARN("wrong # of args for \"%s\", line %d\n", KW_MDN_LOG_LEVEL,
+               lineNo);
+           return FALSE;
+       }
+       if ((level = libmdn_string_to_loglevel(aArgs[1])) < 0) {
+           WARN("unknown mdn log level \"%.100s\", line %d\n", aArgs[1],
+               lineNo);
+           return FALSE;
+       }
+       mdn_log_setlevel(level);
+    }
+
+#ifdef HAVE_SYSLOG
+    if (config_query_value(KW_SYSLOG_FACILITY, &nArgs, &aArgs, &lineNo)
+       == TRUE) {
+       if (nArgs != 2) {
+           WARN("log_configure - wrong # of args for \"%s\", line %d\n",
+               KW_LOG_LEVEL, lineNo);
+           return FALSE;
+       } else if (!log_strtofacility(aArgs[1], &logFacility)) {
+           WARN("log_configure - unknown syslog facility \"%.100s\", "
+               "line %d\n", aArgs[1], lineNo);
+           return FALSE;
+       }
+    }
+#endif /* HAVE_SYSLOG */
+
+    if (*logFname == '\0') {
+       WARN("log_configure - no logging file specified\n");
+        return FALSE;
+    }
+
+    if (strcmp(logFname, "syslog") == 0) {
+#ifdef HAVE_SYSLOG
+       logMode = LOGMODE_SYSLOG;
+       logFptr = NULL;
+       openlog("mdnsproxy", LOG_NDELAY | LOG_PID, logFacility);
+       mdn_log_setproc(libmdn_logproc_syslog);
+       syslog(LOG_NOTICE, "** mdnsproxy version %s", mdn_version_getstring());
+#else /* not HAVE_SYSLOG */
+       WARN("log_configure - syslog is unavailable\n");
+       return FALSE;
+#endif /* not HAVE_SYSLOG */
+    } else {
+       logMode = LOGMODE_FILE;
+       logFptr = fopen(logFname, "a") ;
+       mdn_log_setproc(libmdn_logproc_file);
+       if (logFptr == NULL) {
+           WARN("log_configure - cannot open, the log file\"%.100s\"\n",
+               logFname);
+           return FALSE;
+       }
+       WARN("** mdnsproxy version %s\n", mdn_version_getstring());
+    }
+
+    return TRUE;
+}
diff --git a/contrib/idn/mdnkit/mdnsproxy/make.wnt b/contrib/idn/mdnkit/mdnsproxy/make.wnt
new file mode 100644 (file)
index 0000000..d744dd5
--- /dev/null
@@ -0,0 +1,128 @@
+#
+# Makefile for mDNS Proxy Server, WINNT version
+#
+# $Id: make.wnt,v 1.1 2001/06/09 00:30:35 tale 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+# Tokyo, 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) Japan Network Information Center.  All rights reserved."
+# 
+# 4. Neither the name of JPNIC may 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.
+# 
+# 6. Indemnification by Licensee
+#    Any person or entities using and/or redistributing this Software under
+#    this License Terms and Conditions shall defend indemnify and hold
+#    harmless JPNIC from and against any and all judgements damages,
+#    expenses, settlement liabilities, cost and other liabilities of any
+#    kind as a result of use and redistribution of this Software or any
+#    claim, suite, action, litigation or proceeding by any third party
+#    arising out of or relates to this License Terms and Conditions.
+# 
+# 7. Governing Law, Jurisdiction and Venue
+#    This License Terms and Conditions shall be governed by and and
+#    construed in accordance with the law of Japan. Any person or entities
+#    using and/or redistributing this Software under this License Terms and
+#    Conditions hereby agrees and consent to the personal and exclusive
+#    jurisdiction and venue of Tokyo District Court of Japan.
+#
+
+!include <ntwin32.mak>
+
+ICONVDIR = ..\win
+MDNDIR   = ..\lib
+BINDIR   = ..\..\bin\win
+
+INCDIR = ..\include
+LIBS = $(MDNDIR)\libmdn.lib $(ICONVDIR)\iconv.lib
+SYSLIBS = $(conlibsdll)
+
+#
+# Files to build mDNS Proxy
+#
+
+HDRS = mdnsproxy.h winserv.h
+
+SRCS = winmain.c   winserv.c   server.c   message.c   translate.c   \
+       logging.c   proxycnf.c acl.c
+OBJS = winmain.obj winserv.obj server.obj message.obj translate.obj \
+       logging.obj proxycnf.obj acl.obj
+
+#
+# Target to build
+#
+
+TARGETS = mdnsproxy.exe $(ICONVDIR)\iconv.dll
+
+all : $(TARGETS)
+
+install : $(TARGETS)
+       copy mdnsproxy.exe $(BINDIR)
+       copy $(ICONVDIR)\iconv.dll $(BINDIR)
+
+mdnsproxy.exe : $(OBJS) $(LIBS)
+       $(link) $(conflags) -out:mdnsproxy.exe $(OBJS) $(LIBS) $(SYSLIBS)
+
+clean:
+       del *.exe *.obj *.lib core *.core *~
+
+#
+# Dependecnies
+#
+
+winmain.obj  : winmain.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -DDEBUG $*.c
+
+winserv.obj  : winserv.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -DDEBUG $*.c
+
+server.obj   : server.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -DDEBUG $*.c
+
+message.obj  : message.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -DDEBUG $*.c
+
+translate.obj  : translate.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -DDEBUG $*.c
+
+logging.obj  : logging.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -DDEBUG $*.c
+
+proxycnf.obj   : proxycnf.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -DDEBUG $*.c
+
+acl.obj   : acl.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -DDEBUG $*.c
similarity index 66%
rename from contrib/idn/mdnkit/dnsproxy/dnsproxy.8.in
rename to contrib/idn/mdnkit/mdnsproxy/mdnsproxy.8.in
index 0606b7a68e9c27992bd6f7d65cbd3707b3296cf4..fa094b407c61014f578fccdd23264f7828cac129 100644 (file)
@@ -1,4 +1,4 @@
-.\" $Id: dnsproxy.8.in,v 1.10 2000/11/17 07:36:37 ishisone Exp $
+.\" $Id: mdnsproxy.8.in,v 1.1 2001/06/09 00:30:35 tale Exp $
 .\"
 .\"  Copyright (c) 2000 Japan Network Information Center.  All rights reserved.
 .\"   
 .\"     jurisdiction and venue of Tokyo District Court of Japan.
 .TH DNSPROXY 8
 .SH NAME
-dnsproxy \- DNS proxy server for multi-lingual DNS
+mdnsproxy \- DNS proxy server for multi-lingual DNS
 
 .SH SYNOPSIS
-.B dnsproxy
+.B mdnsproxy
 [ \-daemon ] [ \-config <config\-file> ] [ \-logfile <log\-file> ]
+.br
+.B mdnsproxy
+\-version
 
 .SH DESCRIPTION
-.B dnsproxy
+.B mdnsproxy
 resides between application (resolver) and DNS server.
 .PP
 It accepts DNS requests from application (resolver) and converting
@@ -77,22 +80,25 @@ applications.
 .SH OPTIONS
 .TP
 .B \-daemon
-Run dnsproxy as daemon.  Otherwise, dnsproxy will run as normal
+Run mdnsproxy as daemon.  Otherwise, mdnsproxy will run as normal
 console program.
 .TP
 .B \-config <config\-file>
 Specifies configuration file (see later).  If not specified,
-dnsproxy uses default configuration file.
+mdnsproxy uses default configuration file.
 See
 .B FILES
 section for default configuration file.
 .TP
 .B \-logfile <log\-file>
 Specifies logging file. If not specified.
-dnsproxy uses default logging file.
+mdnsproxy uses default logging file.
 See
 .B FILES
 section for default configuration file.
+.TP
+.B \-version
+Prints version information to standard error and quits.
 
 .SH CONFIGURATION
 Configuration file is simple text file which defines several
@@ -109,7 +115,7 @@ Defines listening port (both TCP and UDP).  <address> is one of
 <IP address>
 .PP
 .RE
-If omitted, dnsproxy uses default value shown below.
+If omitted, mdnsproxy uses default value shown below.
 .RS
 .PP
 IP Address      INADDR_ANY (0.0.0.0)
@@ -127,81 +133,65 @@ example:
 forward 10.1.2.3
 .RE
 .PP
-If "bind4compat" was given, dnsproxy uses above listen port
-as forwading UDP's source address.  If not given, dnsproxy uses
+If "bind4compat" was given, mdnsproxy uses above listen port
+as forwading UDP's source address.  If not given, mdnsproxy uses
 port > 1024 as forwading UDP's source.
 .RE
-.IP "log-file <path>"
-.RS
-Defines log file name.  It may be overridden with command line
-option '-logfile <path>'.  If no log file given, dnsproxy writes
-log data into "/tmp/dnsproxy.log".
-Sending SIGHUP causes dnsproxy to close the log file and then reopen it.
-.RE
-.IP "client-translation <ZLD> <Encoding>"
+.IP "client-encoding <Encoding>"
 .RS
-Defines client side character encoding scheme.  Some clients
-locally encode domain name and add <ZLD> (Zero Level Domain) to
-it.  In those cases, use <ZLD> and specify corresponding encoding.
-Usually, no mDNS'nized client passes domain name in client's
-local encoding.  For those case, use '.' as ZLD.  You may
-specify several 'client-translation's if client uses several
-encoding with different ZLD.
+Defines client side character encoding scheme.
 .PP
 example:
-.RS    
+.RS
 .nf
-client-translation .i-dns.net UTF-5     # accept ZLDs
-client-translation .          Shift_JIS
+client-encoding\ \ EUC-JP
 .fi
-.RE    
-.PP
-Acceptable ZLD will depend on client programs.  Also acceptable
-encodings depend on client and the implementation of `iconv()' function,
-which dnsproxy uses internally for encoding conversion.
-Check the document on `iconv()' for acceptable encoding names.
 .RE
-.IP "alternate-encoding <Encoding>"
-.RS
-Defines client side alternative encoding scheme.  The alternative
-encoding will be used when the conversion from server-side encoding
-to the default local encoding is failed due to the lack of mapping
-some certain characters to the local character set.
-.PP
-example:
-.RS    
-alternate-encoding\ \ RACE
-.RE    
-.PP
-The alternative encoding must be an ASCII compatible encoding, such as RACE.
 .RE
-.IP "normalize <Normalization Scheme> ..."
-.RS
-Defines domain name normalization schemes.  You can specify
-several normalizations and they are applied left to right.
-.PP
-example:
+.IP "mdn-conf-file <path>"
 .RS
-normalize ja-fullwidth unicode-form-c
+Specifies configuration file for libmdn, the library responsible for most
+of the MDN processing for mdnsproxy.
+If the entry is ommitted, mdnsproxy reads "@sysconfdir@/mdn.conf".
 .RE
+.IP "log-file <path>"
+.RS
+Defines log file name.  It may be overridden with command line
+option '-logfile <path>'.  If no log file given, mdnsproxy writes
+log data into "@logdir@/mdnsproxy.log".
+Sending SIGHUP causes mdnsproxy to close the log file and then reopen it.
 .PP
-Acceptable normalizations depend on 'libmdn' library.  Check
-documents for 'libmdn' for more detail.
+If <path> is set to ``syslog'', mdnsproxy outputs log messages with
+syslog.
 .RE
-.IP "server-translation <Encoding>"
+.IP "log-level <Level>"
 .RS
-Defines server side character encoding scheme.  Finally, domain 
-names in DNS request from clients are converted to this encoding
-and forwarded to mDNS'nized DNS server.
+Sets the log level.  Available levels are ``none'' (no logging at all),
+``fatal'' (only logs fatal errors), ``warn'' (also logs warning messages)
+and ``trace'' (also includes trace level messages).  The default level is
+``warn''.  Please note that if you set the level to ``trace'', the size of
+the log file grows quickly.
 .PP
-example:
+If mdnsproxy is configured to output log messages with syslog (see the
+description of the ``log-file'' entry), ``fatal'' messages are output
+with ``err'' priority, ``warning'' messages with ``warning'' and ``trace''
+messages with ``debug''.
+.RE
+.IP "mdn-log-level <Number>"
 .RS
-server-translation . UTF-8
+Specifies the logging level for libmdn.
+Unless you are debugging mDNkit, you should keep this entry unspecified.
 .RE
+.IP "syslog-facility <Facility>"
+.RS
+Specifies the syslog facility to be assigned to log messages output by
+mdnsproxy.  The entry is ignored unless the `log-file' entry is set to
+``syslog''.  If the entry is not specified, ``daemon'' will be used.
+
 .RE
 .IP "user-id <Name-or-ID>"
 .RS
-Defines a user ID in which dnsproxy operates.
+Defines a user ID in which mdnsproxy operates.
 Dnsproxy tries to change the user ID of its process to the specified one,
 soon after initialization.
 .PP
@@ -217,7 +207,7 @@ It is strongly recommended to use this option for security reasons.
 .RE
 .IP "group-id <Name-or-ID>"
 .RS
-Defines a group ID in which dnsproxy operates.
+Defines a group ID in which mdnsproxy operates.
 Dnsproxy tries to change the group ID of its process to the specified one,
 soon after initialization.
 .PP
@@ -231,29 +221,64 @@ group-id\ \ 9999
 .RE
 .IP "root-directory <Directory>"
 .RS
-Defines the pathname of the root directory for the dnsproxy process.
+Defines the pathname of the root directory for the mdnsproxy process.
 Dnsproxy performs chroot() to set the specified directory as the
 root directory for the process after initialization.
 .PP
 example:
 .RS
 .nf
-root-directory /var/dnsproxy
+root-directory /var/mdnsproxy
 .fi
 .RE
 .RE
-.IP "log-level <Level>"
+.IP "allow-access <Address> ..."
 .RS
-Sets the log level.  Available levels are ``none'' (no logging at all),
-``fatal'' (only logs fatal errors), ``warn'' (also logs warning messages)
-and ``trace'' (also includes trace level messages).  The default level is
-``warn''.  Please note that if you set the level to ``trace'', the size of
-the log file grows quickly.
+Specifies which hosts are allowed to access to the server.
+<Address> is an IP address (in dotted numeric form) or IP prefix
+(IP address followed by a slash and netmask).
+.PP
+example:
+.RS
+.nf
+allow-access 192.168.100.1
+allow-access 192.168.10.0/24
+.fi
+.RE
+.PP
+You can specify one or more <Address>.  The server rejects accesses
+from clients not matched to any <Address>.
+You can also define allow-access several times.
+.PP
+.RS
+.nf
+allow-access 192.168.100.1
+allow-access 192.168.100.2
+.fi
+.RE
+.PP
+This is equivarent to:
+.PP
+.RS
+.nf
+allow-access 192.168.100.1 192.168.100.2
+.fi
+.RE
+.PP
+If no entry is specified, the server allows to access from all hosts.
+.RE
+.IP "log-on-denied <Flag>"
+.RS
+is used to tell mdnsproxy whether or not to log denied access.
+<Flag> is either "yes" or "no".
+If "yes" is specified, the server records denied access.
+The default value is "no".
+.RE
 .RE
 
 .SH NOTES
 Some applications locally mangles domain names.  In those cases,
-dnsproxy cannot works correctly.
+mdnsproxy cannot works correctly.
 .PP
 For 'nslookup', it generally reject non-ascii domain names.
 You need 8bit through patched version of nslookup.
@@ -261,22 +286,27 @@ You need 8bit through patched version of nslookup.
 For UNIX resolver generally rejects domain names using non-ascii characters.
 You need 8bit through patched version of resolver.
 .PP
-For Windows, NS works well with dnsproxy.  For IE, turn off "use UTF-8"
+For Windows, NS works well with mdnsproxy.  For IE, turn off "use UTF-8"
 setting, and generally works.  But for IE, embedded URL's in page will
 converted by IE (to page's original encoding),
-and they conflict with dnsproxy.
+and they conflict with mdnsproxy.
 
 .SH FILES
 .PD 0
-.TP 30
-.B @ETCDIR@/dnsproxy.conf
-Default configuration file.
 .TP
-.B /tmp/dnsproxy.log
+.B @sysconfdir@/mdnsproxy.conf
+Default configuration file for mdnsproxy.
+.TP
+.B @sysconfdir@/mdn.conf
+Default configuration file for libmdn.
+.TP
+.B @logdir@/mdnsproxy.log
 Default logging file.
 .PD
 
 .SH SLL ALSO
 .BR named(8),
+.BR syslogd(8),
+.BR syslog.conf(5),
 .BR libmdn(3),
 .BR iconv(3)
diff --git a/contrib/idn/mdnkit/mdnsproxy/mdnsproxy.conf.sample b/contrib/idn/mdnkit/mdnsproxy/mdnsproxy.conf.sample
new file mode 100644 (file)
index 0000000..fe34459
--- /dev/null
@@ -0,0 +1,148 @@
+# $Id: mdnsproxy.conf.sample,v 1.1 2001/06/09 00:30:35 tale Exp $
+#
+# Sample mdnsproxy configuration file 'mdnsproxy.conf'.
+#
+
+#
+# 'listen' entry specifies the mdnsproxy's listening port.
+# The default is to use address 0.0.0.0 (INADDR_ANY) and port 53.
+#
+# syntax)
+#      listen [<IP address>][:<port number>]
+#
+# ex)  listen 127.0.0.1        -- only accept loopback connections
+#      listen :1053            -- port number can be specified
+#      listen 127.0.0.1:1053   -- combination of above
+#
+#listen  127.0.0.1
+
+#
+# 'forward' entry specifies the name server's port to which mdnsproxy
+# forwards requests.  This entry MUST be specified.
+#
+# Normally mdnsproxy uses unspecified local port number for sending
+# queries to the server, but if 'bind4compat' option is specified,
+# mdnsproxy uses the same port number as the listening port specified
+# by the 'listen' entry.
+#
+# syntax)
+#      forward <IP address>[:<port number>] [bind4compat]
+#
+# ex)  forward 10.0.0.2                -- forward 10.0.0.2 port 53
+#      forward 10.0.0.2:1053           -- port number can be specified
+#      forward 10.0.0.2 bind4compat    -- use fixed port number.
+forward        xxx.xxx.xxx.xxx
+
+#
+# 'client-encoding' entry specifies the codeset (encoding) of domain
+# names in the messages sent by the clients.
+#
+# syntax)
+#      client-encoding <encoding>
+#
+#client-encoding EUC-JP
+client-encoding Shift_JIS
+
+#
+# 'mdn-conf-file' entry specifies the pathname of configuration file for
+# libmdn, the library responsible for most of the MDN processing for
+# mdnsproxy.  If it is not specified, mdnsproxy reads default configuration
+# file.
+#
+# syntax)
+#      mdn-conf-file <pathname>
+#
+#mdn-conf-file    /usr/local/etc/mdn.conf
+
+#
+# 'log-file' entry specifies the pathname of the log file.  If the string
+# `syslog' is given, mdnsproxy will record its events with syslog.
+#  If the entry is not specified, default log file will be used.
+#
+# syntax)
+#      log-file (<pathname> | syslog)
+#
+#log-file    /var/log/mdnsproxy.log
+
+#
+# 'log-level' entry specifies the logging level for mdnsproxy.
+# Valid levels are 'none' (no logging at all, not recommended),
+# 'fatal' (only logs fatal errors), 'warn' (also logs warning messages)
+# and 'trace' (also includes trace messages).  The default level is 'warn'.
+# 'trace' level is useful for debugging mdnsproxy itself, but it makes
+# the log file grow rather quickly.
+#
+# syntax)
+#      log-level <level>
+#
+log-level warn
+
+#
+# 'mdn-log-level' entry specifies the logging level for libmdn.
+# Unless you are debugging mDNkit, you should keep this entry unspecified.
+#
+# syntax)
+#      mdn-log-level <level>
+#
+#mdn-log-level 1
+
+#
+# 'syslog-facility' entry specifies the syslog facility to be assigned to
+# log messages output by mdnsproxy.  The entry is ignored unless the
+# `log-file' entry is set to `syslog'.  If the entry is not specified,
+# `daemon' will be used.
+#
+# syntax)
+#      syslog-facility <facility>
+#
+#syslog-facility daemon
+
+#
+# 'user-id' entry and 'group-id' entry specify the user/group ID
+# in which privilege mdnsproxy operates.  mdnsproxy tries to switch
+# to the specified user/group after initialization process is finished.
+#
+# syntax)
+#      user-id <name-or-number>
+#      group-id <name-or-number>
+#
+# ex)  user-id nobody          -- specify by name,
+#      group-id 1000           -- or by number
+#
+user-id nobody
+#group-id nobody
+
+#
+# 'root-directory' entry specifies the root directory of mdnsproxy
+# process.  mdnsproxy performs chroot() to this directory after
+# initialization.  Note that chroot() is allowed only for super-users.
+#
+# syntax)
+#      root-directory <path>
+#
+root-directory /var/mdnsproxy
+
+#
+# `allow-access' entry specifies which hosts are allowed to access to the
+# server.  Defining multiple entries are also permitted.  If it is not
+# specified, the server allows to acceess from all hosts.  
+#
+# syntax)
+#      allow-access <IP address> | <IP prefix>
+#
+# ex)  allow-access 127.0.0.1
+#              -- allow access from the host 127.0.0.1
+#      allow-access 192.168.100.0/24
+#              -- allow access from hosts on the network 192.168.100.0/24.
+#
+#allow-access xxx.xxx.xxx.xxx
+
+#
+# `log-on-denied' entry specifies whether or not to log denied access.
+# If it is not specified, the server doesn't record denied access.
+#
+# syntax)
+#      log-on-denied <yes>
+#      log-on-denied <no>
+#
+#log-on-denied no
similarity index 90%
rename from contrib/idn/mdnkit/dnsproxy/dnsproxy.h
rename to contrib/idn/mdnkit/mdnsproxy/mdnsproxy.h
index 8b0500edafde2d5608f6cf9f924e691b406ed1b5..c63a8cdea3a6671317cb280f299c5256ce8a5f4e 100644 (file)
@@ -60,7 +60,7 @@
  *    jurisdiction and venue of Tokyo District Court of Japan.
  */
 
-/* $Id: dnsproxy.h,v 1.13 2000/11/17 05:57:56 ishisone Exp $ */
+/* $Id: mdnsproxy.h,v 1.1 2001/06/09 00:30:35 tale Exp $ */
 
 #ifndef DNSPROXY_H
 #define DNSPROXY_H 1
 #else   /* for normal systems */
 #include <sys/types.h>
 #include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
 #endif
 
+#include "proxycnf.h"
+
 /*
  * Redefine TRUE and FALSE.
  */
  * Macro for Error Logging
  */
 
+enum {
+    LOGMODE_FILE = 0,
+    LOGMODE_SYSLOG = 1
+};
+
 enum {
     LOGLEVEL_NONE = 0,
     LOGLEVEL_FATAL = 1,
@@ -94,7 +103,7 @@ enum {
     LOGLEVEL_TRACE = 3
 };
 
-void    log_configure(int ac, char *av[]) ;
+BOOL    log_configure(int ac, char *av[]) ;
 void    log_terminate(void) ;
 void   log_turnover_request(void) ;
 void   log_turnover(void) ;
@@ -147,10 +156,11 @@ void    config_dump(FILE *ofp) ;
  * query configuration data
  */
 
-BOOL    config_query_value(char *key, int *count, char ***array) ;
+BOOL    config_query_value(char *key, int *count, char ***array, int *lineNo) ;
 BOOL    config_query_listen(struct sockaddr *addr)  ;
 BOOL    config_query_forward(struct sockaddr *addr) ;
-BOOL    config_query_restrict(BOOL *restrict) ;
+BOOL    config_query_restrict(BOOL *src_restrict) ;
+BOOL    config_query_log_on_denied(BOOL *flag) ;
 
 /*
  * Message (domain name) translation
@@ -161,11 +171,10 @@ typedef struct translation_context {
     int protocol;              /* IPPROTO_TCP or IPPROTO_UDP */
     unsigned int old_id;       /* original message ID */
     unsigned int new_id;       /* new message ID */
-    char *zld;                 /* ZLD */
-    void *converter;           /* encoding: actual type is mdn_converter_t */
 } translation_context_t;
 
 BOOL    translate_initialize(void) ;
+void    translate_finish(void) ;
 int     translate_request(translation_context_t *ctx,
                  const char *msg, size_t msglen,
                  char *translated, size_t bufsize, size_t *translatedlenp) ;
@@ -185,8 +194,17 @@ int     translate_reply(translation_context_t *ctx,
 
 typedef void    *config_ctx_t ;     /* opaque pointer to lookup context */
 
-config_ctx_t    config_query_open(char *key, int *count, char ***array) ;
-config_ctx_t    config_query_more(config_ctx_t ctx, int *count, char ***array) ;
+config_ctx_t    config_query_open(char *key, int *count, char ***array,
+                       int *lineNo) ;
+config_ctx_t    config_query_more(config_ctx_t ctx, int *count, char ***array,
+                       int *lineNo) ;
 void            config_query_close(config_ctx_t ctx) ;
 
+/*
+ * managing access control list.
+ */
+int            acl_initialize(void);
+BOOL           acl_test(struct sockaddr *address);
+void           acl_finalize(void);
+
 #endif  /* DNSPROXY_H */
similarity index 99%
rename from contrib/idn/mdnkit/dnsproxy/message.c
rename to contrib/idn/mdnkit/mdnsproxy/message.c
index ab83c9e9ca000c87cdeb1b66411ab254c50e330d..deba583c25302ed4b27ebea49b64ceffdfdaaa8f 100644 (file)
@@ -65,7 +65,7 @@
  */
 
 #ifndef lint
-static char *rcsid = "$Id: message.c,v 1.18 2000/11/17 05:46:23 ishisone Exp $";
+static char *rcsid = "$Id: message.c,v 1.1 2001/06/09 00:30:35 tale Exp $";
 #endif
 
 #include <config.h>
@@ -85,7 +85,7 @@ static char *rcsid = "$Id: message.c,v 1.18 2000/11/17 05:46:23 ishisone Exp $";
 #include <netinet/in.h>
 #endif
 
-#include "dnsproxy.h"
+#include "mdnsproxy.h"
 
 /*
  * address handling utilities
similarity index 83%
rename from contrib/idn/mdnkit/dnsproxy/os2main.c
rename to contrib/idn/mdnkit/mdnsproxy/os2main.c
index 93a8fda53f9d0de5957b5b7b95011f2be83502c9..30108b8da80745bb659408c29ab3ac39a97acec0 100644 (file)
@@ -68,7 +68,7 @@
  */
 
 #ifndef lint
-static char *rcsid = "$Id: os2main.c,v 1.12 2000/07/04 03:52:28 ishisone Exp $";
+static char *rcsid = "$Id: os2main.c,v 1.1 2001/06/09 00:30:35 tale Exp $";
 #endif
 
 #ifdef  OS2
@@ -78,7 +78,7 @@ static char *rcsid = "$Id: os2main.c,v 1.12 2000/07/04 03:52:28 ishisone Exp $";
 #include <string.h>
 #include <signal.h>
 
-#include "dnsproxy.h"       /* Common definitions for mDNS proxy    */
+#include "mdnsproxy.h"       /* Common definitions for mDNS proxy    */
 
 /*
  * signal handler to catch signal to terminate server
@@ -96,11 +96,39 @@ static  void    handler(int signo)
 
 int     main(int ac, char *av[])
 {
+    int     i, pid ;
+
+    for (i = 1 ; i < ac ; i++) {
+        if (strcmp(av[i], "-daemon") == 0) {
+           as_daemon = TRUE ;
+       } else if (strcmp(av[i], "-conf") == 0) {
+           if (i + 1 == ac) {
+               fprintf(stderr, "missing argument to \"%s\"\n", av[i]) ;
+               return 1 ;
+           }
+        } else if (strcmp(av[i], "-logfile") == 0) {
+           if (i + 1 == ac) {
+               fprintf(stderr, "missing argument to \"%s\"\n", av[i]) ;
+               return 1 ;
+           }
+       } else if (av[i][0] == '-' && av[i][1] != '\0') {
+               fprintf(stderr, "unknown option \"%s\"\n", av[i]) ;
+               return 1 ;
+       } else {
+               fprintf(stderr, "too many arguments\n");
+               return 1 ;
+       }
+    }
+
     if (config_load(ac, av) != TRUE) {
         printf("cannot load configurations\n") ;
        return 1 ;
     }
-    log_configure(ac, av) ;
+
+    if (log_configure(ac, av) != TRUE) {
+        printf("cannot logging\n") ;
+       return 1 ;
+    }
     
     if (server_init(ac, av) != TRUE) {
         printf("cannot initialize server\n") ;
similarity index 70%
rename from contrib/idn/mdnkit/dnsproxy/proxycnf.c
rename to contrib/idn/mdnkit/mdnsproxy/proxycnf.c
index da5bd140ef9eebad97b1e3143e26e8f53258da6b..b528d9fbe245afb214985c8602dfc6017c72442c 100644 (file)
@@ -61,7 +61,7 @@
  */
 
 #ifndef lint
-static char *rcsid = "$Id: proxycnf.c,v 1.16 2000/11/17 05:46:23 ishisone Exp $";
+static char *rcsid = "$Id: proxycnf.c,v 1.1 2001/06/09 00:30:35 tale Exp $";
 #endif
 
 #include <config.h>
@@ -70,6 +70,7 @@ static char *rcsid = "$Id: proxycnf.c,v 1.16 2000/11/17 05:46:23 ishisone Exp $"
 #include <stdlib.h>
 #include <string.h>
 #include <ctype.h>
+#include <errno.h>
 
 #ifdef  WIN32
 #include <windows.h>
@@ -81,8 +82,7 @@ static char *rcsid = "$Id: proxycnf.c,v 1.16 2000/11/17 05:46:23 ishisone Exp $"
 #include <arpa/inet.h>
 #endif
 
-#include "dnsproxy.h"       /* Common definitions for mDNS proxy    */
-#include "proxycnf.h"       /* Machine/Env specific configuration   */
+#include "mdnsproxy.h"       /* Common definitions for mDNS proxy    */
 
 /*
  * Note that logging macros (FATAL, WARN and TRACE) cannot be used
@@ -99,8 +99,8 @@ static char *rcsid = "$Id: proxycnf.c,v 1.16 2000/11/17 05:46:23 ishisone Exp $"
 #define CONFIG_PATH "./"
 #endif
 #ifndef CONFIG_FILE
-#warning "no \"CONFIG_FILE\", use "dnsproxy.ini" as default" 
-#define CONFIG_FILE "dnsproxy.ini"
+#warning "no \"CONFIG_FILE\", use "mdnsproxy.ini" as default" 
+#define CONFIG_FILE "mdnsproxy.ini"
 #endif
 #ifndef CONFIG_HOME
 #warning "no \"CONFIG_HOME\", use "\"./\" as default" 
@@ -110,7 +110,7 @@ static char *rcsid = "$Id: proxycnf.c,v 1.16 2000/11/17 05:46:23 ishisone Exp $"
 static  u_char  *confFile = CONFIG_FILE ;
 
 static  u_char  *confPath[] = {
-#ifdef  DEBUG
+#if defined(DEBUG) && !defined(UNIX)
     "./",
     CONFIG_HOME,
 #endif
@@ -118,12 +118,39 @@ static  u_char  *confPath[] = {
     NULL
 } ;
 
+static u_char *confCommands[] = {
+    KW_LISTEN,
+    KW_FORWARD,
+    KW_CLIENT_ENCODING,
+    KW_MDN_CONF_FILE,
+    KW_LOG_FILE,
+    KW_LOG_LEVEL,
+    KW_MDN_LOG_LEVEL,
+    KW_SYSLOG_FACILITY,
+    KW_USER_ID,
+    KW_GROUP_ID,
+    KW_ROOT_DIRECTORY,
+    KW_ALLOW_ACCESS,
+    KW_LOG_ON_DENIED,
+    NULL
+};
+
+static u_char *confObsoleteCommands[] = {
+    KW_CLIENT_TRANSLATION,
+    KW_ALTERNATE_ENCODING,
+    KW_NORMALIZE,
+    KW_SERVER_TRANSLATION,
+    KW_ENCODING_ALIAS_FILE,
+    NULL
+};
+
 static  u_char  *expandName(u_char *name, u_char *buff)
 {
+#ifndef UNIX
     int     inEnv = FALSE ;
     u_char  *bp, *ep ;
     u_char  env[512] ;
-    
+
     for (bp = buff, ep = env ; *name != '\0' ; name++) {
         if (inEnv == FALSE) {
            if (*name == '$') {
@@ -150,6 +177,10 @@ static  u_char  *expandName(u_char *name, u_char *buff)
            }
        }
     }
+#else /* UNIX */
+    strcpy(buff, name);
+#endif /* UNIX */
+
     return buff ;
 }
 
@@ -204,6 +235,7 @@ static  FILE    *openConfig(u_char *fname)
 typedef struct  _CONF   *CNFPTR ;
 
 typedef struct _CONF {
+    int     lineNo   ;
     CNFPTR  prev     ;
     CNFPTR  next     ;
     u_char  *key     ;  /* really, buffer for key & val     */
@@ -282,7 +314,31 @@ static  u_char  *getQuoted(u_char *p, CNFPTR pCnf)
     return p ;
 }
 
-static  BOOL    appendData(u_char *line)
+static BOOL    findCommand(u_char *name)
+{
+    u_char **cmd;
+
+    for (cmd = (u_char **)confCommands; *cmd != NULL; cmd++) {
+       if (strcmp(*cmd, name) == 0)
+           return TRUE;
+    }
+
+    return FALSE;
+}
+
+static BOOL    findObsoleteCommand(u_char *name)
+{
+    u_char **cmd;
+
+    for (cmd = (u_char **)confObsoleteCommands; *cmd != NULL; cmd++) {
+       if (strcmp(*cmd, name) == 0)
+           return TRUE;
+    }
+
+    return FALSE;
+}
+
+static  BOOL    appendData(u_char *line, int lineNo)
 {
     int     len ;
     u_char  *pStr, *p  ;
@@ -308,7 +364,7 @@ static  BOOL    appendData(u_char *line)
     pStr = malloc(len + 2) ;
     
     if (pStr == NULL || pCnf == NULL) {
-        fprintf(stderr, "configure - cannot allocate parsing buffer\n") ;
+        fprintf(stderr, "appendData - cannot allocate memory\n") ;
        if (pStr != NULL) free(pStr) ;
        if (pCnf != NULL) free(pCnf) ;
        return FALSE ;
@@ -352,6 +408,17 @@ static  BOOL    appendData(u_char *line)
        return TRUE ;
     }
 
+    if (findObsoleteCommand(pStr)) {
+        fprintf(stderr, "appendData - obsolete command \"%.100s\", line %d\n",
+           pStr, lineNo) ;
+       return FALSE;
+    }
+    if (!findCommand(pStr)) {
+        fprintf(stderr, "appendData - unknown command \"%.100s\", line %d\n",
+           pStr, lineNo) ;
+       return FALSE;
+    }
+
     /*
      * create resulting CNF record
      */
@@ -359,7 +426,7 @@ static  BOOL    appendData(u_char *line)
     pNew = (CNFPTR) malloc(sizeof(CNFREC) + sizeof(u_char *) * pCnf->nVal) ;
     
     if (pNew == NULL) {
-        fprintf(stderr, "configure - cannot allocate parsed record\n") ;
+        fprintf(stderr, "appendData - cannot allocate memory\n") ;
        free(pStr) ;
        free(pCnf) ;
        return FALSE ;
@@ -367,6 +434,7 @@ static  BOOL    appendData(u_char *line)
 
     memset(pNew, 0, sizeof(CNFREC)) ;
     
+    pNew->lineNo = lineNo;
     pNew->key = pStr ;
     pNew->nVal = pCnf->nVal ;
     memcpy(pNew->aVal, pCnf->aVal, sizeof(u_char *) * pCnf->nVal) ;
@@ -397,12 +465,13 @@ BOOL    config_load(int ac, char *av[])
     u_char  *conf ;
     FILE    *fp   ;
     u_char  line[512] ;
+    int            lineNo ;
     
     /*
      * check if alternate config file specified
      */
 
-    for (i = 1, conf = NULL ; i < ac ; i++) {
+    for (i = 1, conf = CONFIG_PATH "/" CONFIG_FILE ; i < ac ; i++) {
         if (strcmp(av[i], "-config") == 0) {
            if ((i + 1) < ac) {
                conf = av[i+=1] ;
@@ -415,17 +484,19 @@ BOOL    config_load(int ac, char *av[])
      */
      
     if ((fp = openConfig(conf)) == NULL) {
-        fprintf(stderr, "config - cannot locate config file\n") ;
+        fprintf(stderr, "config_load - cannot open the configuration file, "
+           "%s, \"%.100s\"\n", strerror(errno), conf) ;
        return FALSE ;
     }
 
     /*
      * read and parse configuration data (per line)
      */
-
+    lineNo = 0;
     while (fgets(line, 512, fp) != NULL) {
-        if (appendData(line) != TRUE) {
-           fprintf(stderr, "config - cannot load data %s\n", line) ;
+       lineNo++;
+        if (appendData(line, lineNo) != TRUE) {
+           fprintf(stderr, "config_load - error in \"%s\"\n", conf) ;
            fclose(fp) ;
            return FALSE ;
        }
@@ -491,7 +562,7 @@ void    config_free(void)
  *      configuration data, such as client-translation
  */
 
-BOOL    config_query_value(char *key, int *count, char ***array)
+BOOL    config_query_value(char *key, int *count, char ***array, int *lineNo)
 {
     CNFPTR  p ;
     
@@ -501,6 +572,7 @@ BOOL    config_query_value(char *key, int *count, char ***array)
        }
        *count = p->nVal ;
        *array = (char **) p->aVal ;
+       *lineNo = p->lineNo;
        return TRUE ;
     }
     return FALSE ;
@@ -540,90 +612,162 @@ static  CNFPTR  queryData(u_char *key)
     return NULL ;
 }
 
-static  void    getHostPort(u_char *arg, u_char *host, u_char *port)
+/*
+ * Parse `host:port'.  Either `host' or `port' can be omitted.
+ */
+static  BOOL    getHostPort(u_char *arg, struct sockaddr_in *iaddr, int lineNo)
 {
-    for (*host = '\0' ; *arg != '\0' ; arg++) {
-        if (*arg == ':') {
-           arg += 1 ;
-           break ;
+    unsigned int octets[4];
+    unsigned short port;
+    int digit_count;
+    int octet_count;
+    const char *p = arg;
+
+    octets[0] = (DEFAULT_ADDR >> 24) & 0xff;
+    octets[1] = (DEFAULT_ADDR >> 16) & 0xff;
+    octets[2] = (DEFAULT_ADDR >> 8)  & 0xff;
+    octets[3] = (DEFAULT_ADDR)       & 0xff;
+    port = DEFAULT_PORT;
+
+    /*
+     * Parse an dot noted IP address.
+     */
+    if ('0' <= *p && *p <= '9') {
+       octet_count = 0; 
+       while (octet_count < 4) {
+           octets[octet_count] = 0;
+           if (*p == '0' && '0' <= *(p + 1) && *(p + 1) <= '9') {
+               WARN("getHostPort - invalid address \"%.100s\", line %d\n",
+                   arg, lineNo);
+               return FALSE;
+           }
+           for (digit_count = 0; '0' <= *p && *p <= '9'; p++, digit_count++)
+               octets[octet_count] = octets[octet_count] * 10 + (*p - '0');
+           if (digit_count == 0 || digit_count > 3 ||
+               octets[octet_count] > 255) {
+               WARN("getHostPort - invalid address \"%.100s\" line %d\n",
+                   arg, lineNo);
+               return FALSE;
+           }
+           octet_count++;
+
+           if (octet_count != 4) {
+               if (*p != '.') {
+                   WARN("getHostPort - malformed address \"%.100s\", "
+                       "line %d\n", arg, lineNo);
+                   return FALSE;
+               }
+               p++;
+           }
        }
-       *host++ = *arg ;
-       *host = '\0'   ;
     }
-    for (*port = '\0' ; *arg != '\0' ; arg++) {
-        *port++ = *arg ;
-       *port = '\0' ;
+
+    /*
+     * Parse an optional port number preceded by `:'.
+     */
+    if (*p == ':') {
+       port = 0;
+       p++;
+       if (*p == '0' && '0' <= *(p + 1) && *(p + 1) <= '9') {
+           WARN("getHostPort - invalid port number \"%.100s\", line %d\n",
+               arg, lineNo);
+           return FALSE;
+       }
+       for (digit_count = 0; '0' <= *p && *p <= '9'; p++, digit_count++)
+           port = port * 10 + (*p - '0');
+       if (digit_count == 0 && *p == '\0') {
+           port = DEFAULT_PORT;
+       } else if (digit_count == 0 || digit_count > 5 || port == 0 ||
+           port > 65535) {
+           WARN("getHostPort - invalid port number \"%.100s\", line %d\n",
+               arg, lineNo);
+           return FALSE;
+       }
+    }
+
+    if (*p != '\0') {
+       WARN("getHostPort - invalid address \"%.100s\", line %d\n",
+           arg, lineNo);
+       return FALSE;
     }
+
+    /*
+     * Put the result into `address' and `port'.
+     */
+    iaddr->sin_addr.s_addr = htonl((octets[0] << 24) + (octets[1] << 16)
+       + (octets[2] << 8) + octets[3]);
+    iaddr->sin_port = htons(port);
+
+    return TRUE;
+}
+
+/*
+ * Parse `host:port'.  `port' can be omitted.
+ */
+static  BOOL    getHostPort2(u_char *arg, struct sockaddr_in *iaddr, 
+                            int lineNo)
+{
+    if (*arg == ':') {
+       WARN("getHostPort2 - missing host name \"%.100s\", line %d\n",
+           arg, lineNo);
+       return FALSE;
+    }
+
+    return getHostPort(arg, iaddr, lineNo);
 }
 
 BOOL    config_query_listen(struct sockaddr *addr)
 {
     CNFPTR  pListen ;
-    u_char  host[64], port[64] ;
     struct sockaddr_in  *iaddr ;
 
     memset(addr, 0, sizeof(struct sockaddr)) ;
     iaddr = (struct sockaddr_in *) addr      ;
     
-    iaddr->sin_family = AF_INET ;
-    
-    if ((pListen = queryData("listen")) == NULL) {
+    if ((pListen = queryData(KW_LISTEN)) == NULL) {
         iaddr->sin_addr.s_addr = htonl(DEFAULT_ADDR) ;
        iaddr->sin_port        = htons(DEFAULT_PORT) ;
        return TRUE ;
     }
-    if (pListen->nVal < 2) {
-        iaddr->sin_addr.s_addr = htonl(DEFAULT_ADDR) ;
-       iaddr->sin_port        = htons(DEFAULT_PORT) ;
-       return TRUE ;
+    if (pListen->nVal != 2) {
+        WARN("config_query_listen - wrong # of args for \"%s\", line %d\n",
+           KW_LISTEN, pListen->lineNo) ;
+       return FALSE ;
     }
 
-    getHostPort(pListen->aVal[1], host, port) ;
-    
-    if (isdigit(*host)) {
-        iaddr->sin_addr.s_addr = inet_addr(host) ;
-    } else {
-        iaddr->sin_addr.s_addr = htonl(DEFAULT_ADDR) ;
-    }
-    if (isdigit(*port)) {
-        iaddr->sin_port = htons(atoi(port)) ;
-    } else {
-        iaddr->sin_port = htons(DEFAULT_PORT) ;
+    if (!getHostPort(pListen->aVal[1], iaddr, pListen->lineNo)) {
+       return FALSE;
     }
+
+    iaddr->sin_family = AF_INET ;
+    
     return TRUE ;
 }
 
 BOOL    config_query_forward(struct sockaddr *addr)
 {
     CNFPTR  pForward ;
-    u_char  host[64], port[64] ;
     struct sockaddr_in  *iaddr ;
     
     memset(addr, 0, sizeof(struct sockaddr)) ;
     iaddr = (struct sockaddr_in *) addr      ;
+    iaddr->sin_family = AF_INET ;
 
-    if ((pForward = queryData("forward")) == NULL) {
-        WARN("config - no \"forward\" record\n") ;
+    if ((pForward = queryData(KW_FORWARD)) == NULL) {
+        WARN("config_query_forward - \"%s\" not found in the configuration "
+           "file\n", KW_FORWARD) ;
        return FALSE ;
     }
-    if (pForward->nVal < 2) {
-        WARN("config - no \"forward\" value\n") ;
+    if (pForward->nVal != 2 && pForward->nVal != 3) {
+        WARN("config_query_forward - wrong # of args for \"%s\", line %d\n",
+           KW_FORWARD, pForward->lineNo) ;
        return FALSE ;
     }
 
-    getHostPort(pForward->aVal[1], host, port) ;
-
-    if (isdigit(*host)) {
-        iaddr->sin_addr.s_addr = inet_addr(host) ;
-    } else {
-        WARN("config - no \"forward\" address\n") ;
-        return FALSE ;
-    }
-    if (isdigit(*port)) {
-        iaddr->sin_port = htons(atoi(port)) ;
-    } else {
-        iaddr->sin_port = htons(DEFAULT_PORT) ;
+    if (!getHostPort2(pForward->aVal[1], iaddr, pForward->lineNo)) {
+       return FALSE ;
     }
+
     iaddr->sin_family = AF_INET ;
 
     return TRUE ;      
@@ -633,22 +777,47 @@ BOOL    config_query_forward(struct sockaddr *addr)
  * config_query_restrict - query 'source-restrict' flag
  */
 
-BOOL    config_query_restrict(BOOL *restrict)
+BOOL    config_query_restrict(BOOL *src_restrict)
 {
     CNFPTR  pForward ;
     
-    if ((pForward = queryData("forward")) == NULL) {
-        *restrict = FALSE ;
+    if ((pForward = queryData(KW_FORWARD)) == NULL) {
+        *src_restrict = FALSE ;
     } else if (pForward->nVal < 3) {
-        *restrict = FALSE ;
+        *src_restrict = FALSE ;
     } else if (strcmp(pForward->aVal[2], "bind4compat") != 0) {
-        *restrict = FALSE ;
+        *src_restrict = FALSE ;
     } else {
-        *restrict = TRUE ;
+        *src_restrict = TRUE ;
     }
     return TRUE ;
 }
 
+/*
+ * config_query_log_on_denied - query 'log-on-denied' flag
+ */
+
+BOOL    config_query_log_on_denied(BOOL *flag)
+{
+    CNFPTR  pForward ;
+    
+    if ((pForward = queryData("log-on-denied")) == NULL) {
+        *flag = FALSE ;
+       return TRUE ;
+    }
+    if (pForward->nVal != 2)
+       return FALSE ;
+
+    if (strcmp(pForward->aVal[1], "yes") == 0)
+        *flag = TRUE ;
+    else if (strcmp(pForward->aVal[1], "no") == 0)
+        *flag = FALSE ;
+    else
+       return FALSE ;
+
+    return TRUE;
+}
+
 /*
  * config_query_open, config_query_more, config_query_close
  *
@@ -656,7 +825,8 @@ BOOL    config_query_restrict(BOOL *restrict)
  *      for multiple entires for same key value.
  */
 
-config_ctx_t    config_query_open(char *key, int *count, char ***array)
+config_ctx_t    config_query_open(char *key, int *count, char ***array,
+                                 int *lineNo)
 {
     CNFPTR  p ;
     
@@ -666,12 +836,14 @@ config_ctx_t    config_query_open(char *key, int *count, char ***array)
        }
        *count = p->nVal ;
        *array = (char **) p->aVal ;
+       *lineNo = p->lineNo;
        return (config_ctx_t) p ;
     }
     return NULL ;
 }
 
-config_ctx_t    config_query_more(config_ctx_t ctx, int *count, char ***array)
+config_ctx_t    config_query_more(config_ctx_t ctx, int *count, char ***array,
+                                 int *lineNo)
 {
     CNFPTR  p = (CNFPTR) ctx ;
     CNFPTR  np ;
@@ -682,6 +854,7 @@ config_ctx_t    config_query_more(config_ctx_t ctx, int *count, char ***array)
        }
        *count = np->nVal ;
        *array = (char **) np->aVal ;
+       *lineNo = np->lineNo;
        return (config_ctx_t) np ;
     }
     return NULL ;
@@ -731,30 +904,25 @@ int     main(int ac, char *av[])
     int     count   ;
     char    **array ;
     config_ctx_t    ctx ;
-    
+    int                        lineNo;
+
     if ((stat = config_load(ac, av)) != TRUE) {
         printf("config_load failed %d\n", stat) ;
        return 1 ;
     }
     config_dump(stdout) ;
 
-    if (config_query_value("listen", &count, &array) == TRUE) {
+    if (config_query_value(KW_LISTEN, &count, &array, &lineNo) == TRUE) {
         dumpvalue("listen", count, array) ;
     }
-    if (config_query_value("forward", &count, &array) == TRUE) {
+    if (config_query_value(KW_FORWARD, &count, &array, &lineNo) == TRUE) {
         dumpvalue("forward", count, array) ;
     }
-    if (config_query_value("normalize", &count, &array) == TRUE) {
-        dumpvalue("normalize", count, array) ;
-    }
-    if (config_query_value("server-translation", &count, &array) == TRUE) {
-        dumpvalue("server-translation", count, array) ;
-    }
     
-    ctx = config_query_open("client-translation", &count, &array) ;
+    ctx = config_query_open("client-translation", &count, &array, &lineNo) ;
     while (ctx != NULL) {
         dumpvalue("client-translation", count, array) ;
-        ctx = config_query_more(ctx, &count, &array) ;
+        ctx = config_query_more(ctx, &count, &array, &lineNo) ;
     }
     config_query_close(ctx) ;
 
similarity index 77%
rename from contrib/idn/mdnkit/dnsproxy/proxycnf.h
rename to contrib/idn/mdnkit/mdnsproxy/proxycnf.h
index 44197b47d216fc40a69afb9262e061c38f126a21..c6cc6345853cb815433c4870ced7c5b66a69c1fb 100644 (file)
@@ -60,7 +60,7 @@
  *    jurisdiction and venue of Tokyo District Court of Japan.
  */
 
-/* $Id: proxycnf.h,v 1.9 2000/11/17 05:42:09 ishisone Exp $ */
+/* $Id: proxycnf.h,v 1.1 2001/06/09 00:30:35 tale Exp $ */
 
 #ifndef PROXYCNF_H
 #define PROXYCNF_H 1
 
 #ifndef CONFIG_FILE
 #ifdef  UNIX
-#define CONFIG_FILE     "dnsproxy.conf"
+#define CONFIG_FILE     "mdnsproxy.conf"
 #endif
 #ifdef  WIN32
-#define CONFIG_FILE     "dnsproxy.cnf"
+#define CONFIG_FILE     "mdnsproxy.cnf"
 #endif
 #ifdef  OS2
-#define CONFIG_FILE     "dnsproxy.cnf"
+#define CONFIG_FILE     "mdnsproxy.cnf"
 #endif
 #endif  /* CONFIG_FILE */
 
 #endif
 #endif  /* CONFIG_HOME */
 
+/*
+ * Commands used in configuration file
+ */
+#define KW_LISTEN              "listen"
+#define KW_FORWARD             "forward"
+#define KW_CLIENT_ENCODING     "client-encoding"
+#define KW_MDN_CONF_FILE       "mdn-conf-file"
+#define KW_LOG_FILE            "log-file"
+#define KW_LOG_LEVEL           "log-level"
+#define KW_MDN_LOG_LEVEL       "mdn-log-level"
+#define KW_USER_ID             "user-id"
+#define KW_GROUP_ID            "group-id"
+#define KW_ROOT_DIRECTORY      "root-directory"
+#define KW_ALLOW_ACCESS                "allow-access"
+#define KW_LOG_ON_DENIED       "log-on-denied"
+#define KW_SYSLOG_FACILITY     "syslog-facility"
+
+/* The following commands are obsoleted. */
+#define KW_CLIENT_TRANSLATION  "client-translation"
+#define KW_ALTERNATE_ENCODING  "alternate-encoding"
+#define KW_NORMALIZE           "normalize"
+#define KW_SERVER_TRANSLATION  "server-translation"
+#define KW_ENCODING_ALIAS_FILE "encoding-alias-file"
+
+/*
+ * Command line options.
+ */
+#define CMDOPT_LOGFILE         "-logfile"
+#define CMDOPT_DAEMON          "-daemon"
+#define CMDOPT_CONFIG          "-config"
+#define CMDOPT_VERSION         "-version"
+
 #endif  /* PROXYCNF_H */
similarity index 93%
rename from contrib/idn/mdnkit/dnsproxy/server.c
rename to contrib/idn/mdnkit/mdnsproxy/server.c
index d4b1ea74975df23e32843658946d4442fd931011..222b782f65def8fad8d65c97f49e43eb9365d266 100644 (file)
@@ -61,7 +61,7 @@
  */
 
 #ifndef lint
-static char *rcsid = "$Id: server.c,v 1.23 2000/11/17 05:46:23 ishisone Exp $";
+static char *rcsid = "$Id: server.c,v 1.1 2001/06/09 00:30:35 tale Exp $";
 #endif
 
 #include <config.h>
@@ -89,7 +89,7 @@ static char *rcsid = "$Id: server.c,v 1.23 2000/11/17 05:46:23 ishisone Exp $";
 #include <errno.h>
 #endif
 
-#include "dnsproxy.h"
+#include "mdnsproxy.h"
 
 #ifdef  WIN32
 #define close(s)    closesocket(s)
@@ -100,6 +100,13 @@ static char *rcsid = "$Id: server.c,v 1.23 2000/11/17 05:46:23 ishisone Exp $";
 #define max(x, y)   ((x) > (y) ? (x) : (y))
 #endif
 
+/*
+ * Status of receiving data or accept a TCP connection.
+ */
+#define SUCCESS  0         /* succeeded        */ 
+#define FAILURE  1         /* failed           */
+#define DENIED   2         /* denied           */
+
 /*
  * send buffer for TCP
  *      hold sending data when sending socket blocked
@@ -162,6 +169,11 @@ static  NETREC  listNet = { 0 } ;   /* list of transports   */
 #define xalloc(x)   malloc((x))
 #define xfree(p)    free((p))
 
+/*
+ * Whether to log denied access from client.
+ */
+static int     logOnDenied = 0;
+
 /*
  * transientError - utility for handling "soft" errors
  */
@@ -282,7 +294,7 @@ static  void    netDispose(NETPTR pNet)
     SNDPTR  pSnd ;
     
     if (listNet.prev == NULL || listNet.next == NULL) {
-        WARN("netCreate - transport list is not initialized\n") ;
+        WARN("netDispose - transport list is not initialized\n") ;
        listNet.prev = &listNet ;
        listNet.next = &listNet ;
     }
@@ -606,9 +618,14 @@ BOOL    server_init(int ac, char *av[])
        server_done() ;
        return FALSE ;
     }
+    if (config_query_log_on_denied(&logOnDenied) != TRUE) {
+        WARN("syntax error at log-on-denied line\n") ;
+       server_done() ;
+       return FALSE ;
+    }
     
     /*
-     * also initialize translator
+     * initialize translator
      */
      
     if (translate_initialize() != TRUE) {
@@ -617,6 +634,16 @@ BOOL    server_init(int ac, char *av[])
        return FALSE ;
     }
 
+    /*
+     * initialize ACL.
+     */
+     
+    if (acl_initialize() != TRUE) {
+       WARN("server_init - access list configuration failed\n") ;
+       server_done() ;
+       return FALSE ;
+    }
+
     /*
      * now server is ready, turn on active flags now
      */
@@ -717,7 +744,7 @@ static  int     setWtFds(fd_set *wfds)
  * sockAccept - accept connection from client
  */
  
-static  BOOL    sockAccept(NETPTR p)
+static  int    sockAccept(NETPTR p)
 {
     NETPTR  np ;
     int     ns, addrlen ;
@@ -731,21 +758,31 @@ static  BOOL    sockAccept(NETPTR p)
 
     if ((ns = accept(p->sock, &addr, &addrlen)) < 0) {
         WARN("sockAccept - cannot accept connection %d\n", errno) ;
-       return FALSE ;
+       return FAILURE ;
     }
     
     addrlen = sizeof(peer) ;
     getpeername(ns, &peer, &addrlen) ;
+
+    if (!acl_test(&peer)) {
+       if (logOnDenied) {
+           WARN("sockAccept - deny access from %s\n",
+               addrFmt(&peer, SOCK_STREAM));
+       }
+       shutdown(ns, 2) ;
+       close(ns) ;
+       return DENIED ;
+    }
     
     if ((np = netCreate(ns, &peer, SOCK_STREAM, NET_CLIENT)) == NULL) {
         WARN("sockAccept - cannot create control block\n") ;
        close(ns) ;
-       return FALSE ;
+       return FAILURE ;
     }
 
     TRACE("sockAccept - accept connection from %s on socket %d\n", addrFmt(&peer, SOCK_STREAM), ns) ;
 
-    return TRUE ;
+    return SUCCESS ;
 }
 
 /*
@@ -755,7 +792,7 @@ static  BOOL    sockAccept(NETPTR p)
  *  notify message arrival.
  */
  
-static  BOOL    sockRecvTcp(NETPTR p)
+static  int    sockRecvTcp(NETPTR p)
 {
     int     n, len ;
     u_char  buff[2] ;
@@ -767,11 +804,11 @@ static  BOOL    sockRecvTcp(NETPTR p)
 
     if (p == NULL || p->proto != SOCK_STREAM) {
         WARN("sockRecvTcp - bad parameter\n") ;
-       return FALSE ;
+       return FAILURE ;
     }
     if (p->recv.buff == NULL || p->recv.size == 0) {
         WARN("sockRecvTcp - no receiver buffer\n") ;
-       return FALSE ;
+       return FAILURE ;
     }
 
     /*
@@ -782,15 +819,15 @@ static  BOOL    sockRecvTcp(NETPTR p)
     if (p->recv.stat == RCV_STAT_LEN1) {
         if ((n = recv(p->sock, buff, 2, 0)) <= 0) {
            if (errno == EWOULDBLOCK) {
-               return TRUE ;
+               return SUCCESS ;
            }
            WARN("sockRecvTcp - recv error %d on socket %d, STAT_LEN1\n", errno, p->sock) ;
-           return FALSE ;
+           return FAILURE ;
        }
        if (n == 1) {
            p->recv.leng = ((int) (buff[0] & 0xff)) * 256 ;
            p->recv.stat = RCV_STAT_LEN2 ;
-           return TRUE ;   /* blocked, try later */
+           return SUCCESS  ;   /* blocked, try later */
        }
        p->recv.leng = ((int) (buff[0] & 0xff)) * 256 + ((int) (buff[1] & 0xff)) ;
        p->recv.stat = RCV_STAT_DATA ;
@@ -800,10 +837,10 @@ static  BOOL    sockRecvTcp(NETPTR p)
     if (p->recv.stat == RCV_STAT_LEN2) {
         if ((n = recv(p->sock, buff, 1, 0)) <= 0) {
            if (errno == EWOULDBLOCK) {
-               return TRUE ;
+               return SUCCESS ;
            }
            WARN("sockRecvTcp - recv error %d on socket %d, STAT_LEN2\n", errno, p->sock) ;
-           return FALSE ;
+           return FAILURE ;
        }
        p->recv.leng += ((int) (buff[0] & 0xff)) ;
        p->recv.stat = RCV_STAT_DATA ;
@@ -814,7 +851,7 @@ static  BOOL    sockRecvTcp(NETPTR p)
         if (p->recv.size < p->recv.leng) {
             if (netExpand(p) != TRUE) {
                WARN("sockRecvTcp - cannot expand recv buffer\n") ;
-               return FALSE ;
+               return FAILURE ;
            }
         }
 
@@ -823,14 +860,15 @@ static  BOOL    sockRecvTcp(NETPTR p)
 
        if ((n = recv(p->sock, bp, len, 0)) <= 0) {
            if (errno == EWOULDBLOCK) {
-               return TRUE ;
+               return SUCCESS ;
            }
-           WARN("sockRecvTcp - recv error %d on socket %d, STAT_DATA %d (%d/%d)\n", 
-                       errno, p->sock, len, p->recv.recv, p->recv.leng) ;
-           return FALSE ;
+           WARN("sockRecvTcp - recv error %d on socket %d, "
+               "STAT_DATA %d (%d/%d)\n", 
+               errno, p->sock, len, p->recv.recv, p->recv.leng) ;
+           return FAILURE ;
        }
        if ((p->recv.recv += n) < p->recv.leng) {
-           return TRUE ;       /* still in-complete */
+           return SUCCESS ;       /* still in-complete */
        }
        
        /*
@@ -847,13 +885,13 @@ static  BOOL    sockRecvTcp(NETPTR p)
        p->recv.leng = 0 ;
        p->recv.recv = 0 ;
 
-       return TRUE ;
+       return SUCCESS ;
     }
     WARN("sockRecvTcp - something wrong\n") ;
-    return FALSE ;
+    return FAILURE ;
 }
 
-static  BOOL    sockRecvUdp(NETPTR p)
+static  int    sockRecvUdp(NETPTR p)
 {
     int             n, fromlen ;
     struct sockaddr fromaddr   ;
@@ -864,11 +902,11 @@ static  BOOL    sockRecvUdp(NETPTR p)
 
     if (p == NULL || p->proto != SOCK_DGRAM) {
         WARN("sockRecvUdp - bad parameter\n") ;
-       return FALSE ;
+       return FAILURE ;
     }
     if (p->recv.buff == NULL || p->recv.size == 0) {
         WARN("sockRecvUdp - no receiver buffer\n") ;
-       return FALSE ;
+       return FAILURE ;
     }
 
     /*
@@ -878,13 +916,13 @@ static  BOOL    sockRecvUdp(NETPTR p)
     fromlen = sizeof(fromaddr) ;
     
     n = recvfrom(p->sock, p->recv.buff, p->recv.size, 0, &fromaddr, &fromlen) ;
-                
+
     if (n == 0) {
        WARN("sockRecvUdp - no data\n") ;
-       return TRUE ;
+       return SUCCESS ;
     } else if (n < 0) {
        if (transientError(errno))
-           return TRUE ;
+           return SUCCESS ;
        switch (errno) {
 #ifdef ECONNREFUSED
        case ECONNREFUSED:
@@ -896,20 +934,28 @@ static  BOOL    sockRecvUdp(NETPTR p)
        case EHOSTUNREACH:
 #endif
            WARN("sockRecvUdp - recv error %d (ignored)\n", errno) ;
-           return TRUE ;
+           return SUCCESS ;
        default:
            WARN("sockRecvUdp - recv error %d\n", errno) ;
-           return FALSE ;
+           return FAILURE ;
        }
     }
 
+    if (!addrEq(&fromaddr, &serverDefaultAddr) && !acl_test(&fromaddr)) {
+       if (logOnDenied) {
+           WARN("sockRecvUdp - deny access from %s\n", 
+               addrFmt(&fromaddr, SOCK_DGRAM));
+       }
+       return DENIED ;
+    }
+                
     /*
      * notify message arrival
      */
 
     notify_message(&fromaddr, SOCK_DGRAM, p->recv.buff, n) ;
 
-    return TRUE ;
+    return SUCCESS ;
 }
 
 /*
@@ -919,7 +965,7 @@ static  BOOL    sockRecvUdp(NETPTR p)
 static  void    sockDispatch(int nfds, fd_set *rfds, fd_set *wfds)
 {
     NETPTR  p, np ;
-    BOOL    stat ;
+    int     stat ;
     
     /*
      * process on ready sockets
@@ -933,7 +979,7 @@ static  void    sockDispatch(int nfds, fd_set *rfds, fd_set *wfds)
     for (p = listNet.next ; p != &listNet ; p = np) {
 
         np = p->next ;
-       stat = TRUE  ;  /* assume no problem */
+       stat = SUCCESS ;  /* assume no problem */
         
         /*
         * if receiving socket ready, then
@@ -944,7 +990,7 @@ static  void    sockDispatch(int nfds, fd_set *rfds, fd_set *wfds)
         *      SERVER          receive message
         */
         
-       if (stat == TRUE && FD_ISSET(p->sock, rfds)) {
+       if (FD_ISSET(p->sock, rfds)) {
            if (p->type != NET_LISTEN) {
                if (p->proto == SOCK_STREAM) {
                    stat = sockRecvTcp(p) ;
@@ -965,7 +1011,7 @@ static  void    sockDispatch(int nfds, fd_set *rfds, fd_set *wfds)
         *      this happens only for TCP socket to CLIENT/SERVER
         */
         
-       if (stat == TRUE && FD_ISSET(p->sock, wfds)) {
+       if (stat == SUCCESS && FD_ISSET(p->sock, wfds)) {
            tcpFlush(p) ;
        }
        
@@ -973,7 +1019,7 @@ static  void    sockDispatch(int nfds, fd_set *rfds, fd_set *wfds)
         * if something wrong on socket, dispose it
         */
 
-        if (stat != TRUE) {
+        if (stat == FAILURE) {
             if (p->type == NET_LISTEN || p->proto == SOCK_DGRAM) {
                WARN("sockDispatch - error on listening socket\n") ;
                server_stop() ;
@@ -1379,7 +1425,8 @@ void    server_forward(struct sockaddr *to, int proto, u_char *msg, int len)
         to = &serverDefaultAddr ;
     }
     if ((p = getServer(to, proto)) == NULL) {
-        WARN("server_forward - no transport to server %s\n", addrFmt(to, proto)) ;
+        WARN("server_forward - no transport to server %s\n",
+           addrFmt(to, proto)) ;
        return ;
     }
     if (proto == SOCK_STREAM) {
@@ -1390,7 +1437,7 @@ void    server_forward(struct sockaddr *to, int proto, u_char *msg, int len)
 }
 
 /*
- * server_response - response to cllient
+ * server_response - response to client
  */
  
 void    server_response(struct sockaddr *to, int proto, u_char *msg, int len)
@@ -1398,7 +1445,8 @@ void    server_response(struct sockaddr *to, int proto, u_char *msg, int len)
     NETPTR  p ;
     
     if ((p = getClient(to, proto)) == NULL) {
-        WARN("server_response - no transport to client %s\n", addrFmt(to, proto)) ;
+        WARN("server_response - no transport to client %s\n",
+           addrFmt(to, proto)) ;
         return ;
     }
     if (proto == SOCK_STREAM) {
diff --git a/contrib/idn/mdnkit/mdnsproxy/translate.c b/contrib/idn/mdnkit/mdnsproxy/translate.c
new file mode 100644 (file)
index 0000000..f3026dc
--- /dev/null
@@ -0,0 +1,291 @@
+/*
+ * 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+ * Tokyo, 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) Japan Network Information Center.  All rights reserved."
+ * 
+ * 4. Neither the name of JPNIC may 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.
+ * 
+ * 6. Indemnification by Licensee
+ *    Any person or entities using and/or redistributing this Software under
+ *    this License Terms and Conditions shall defend indemnify and hold
+ *    harmless JPNIC from and against any and all judgements damages,
+ *    expenses, settlement liabilities, cost and other liabilities of any
+ *    kind as a result of use and redistribution of this Software or any
+ *    claim, suite, action, litigation or proceeding by any third party
+ *    arising out of or relates to this License Terms and Conditions.
+ * 
+ * 7. Governing Law, Jurisdiction and Venue
+ *    This License Terms and Conditions shall be governed by and and
+ *    construed in accordance with the law of Japan. Any person or entities
+ *    using and/or redistributing this Software under this License Terms and
+ *    Conditions hereby agrees and consent to the personal and exclusive
+ *    jurisdiction and venue of Tokyo District Court of Japan.
+ */
+
+#ifndef lint
+static char *rcsid = "$Id: translate.c,v 1.1 2001/06/09 00:30:35 tale Exp $";
+#endif
+
+#include <config.h>
+
+#include <stddef.h>
+#include <stdarg.h>
+#include <stdlib.h>
+
+#ifdef  WIN32
+#include <windows.h>
+#include <winsock.h>
+#else   /* for normal systems */
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#endif
+
+#include <mdn/result.h>
+#include <mdn/log.h>
+#include <mdn/converter.h>
+#include <mdn/normalizer.h>
+#include <mdn/msgtrans.h>
+
+#include "mdnsproxy.h"
+
+/*
+ * DNS message rcode.
+ */
+enum {
+    RCODE_NO_ERROR = 0,
+    RCODE_FORMAT_ERROR = 1,
+    RCODE_SERVER_FAILURE = 2,
+    RCODE_NAME_ERROR = 3,
+    RCODE_NOT_IMPLEMENTED = 4,
+    RCODE_REFUSED = 5
+};
+
+mdn_converter_t client_converter;
+mdn_resconf_t resconf;
+
+static int     result_to_rcode(mdn_result_t r);
+static char    *address_to_string(struct sockaddr *sa);
+static void    mdnerror(int code, char *fmt, ...);
+
+
+BOOL
+translate_initialize(void)
+{
+    mdn_result_t r;
+    char *mdn_conf_file;
+    int ac;
+    char **av;
+    int lineNo;
+
+    TRACE("translate_initialize()\n");
+
+    /*
+     * Initialize the resconf module.
+     */
+    mdn_resconf_initialize();
+    mdn_converter_initialize();
+
+    /*
+     * Create a resconf module.
+     */
+    if (!config_query_value(KW_MDN_CONF_FILE, &ac, &av, &lineNo)) {
+       mdn_conf_file = mdn_resconf_defaultfile();
+    } else {
+       if (ac != 2) {
+           WARN("wrong # of args for \"%s\", line %d\n", KW_MDN_CONF_FILE,
+               lineNo);
+           return FALSE;
+       }
+       mdn_conf_file = av[1];
+    }
+
+    if ((r = mdn_resconf_create(&resconf)) != mdn_success) {
+       mdnerror(r, "mdn conf file");
+       return FALSE;
+    }
+    if ((r = mdn_resconf_loadfile(resconf, mdn_conf_file)) != mdn_success) {
+       mdnerror(r, "mdn conf file %s", mdn_conf_file);
+       return FALSE;
+    }
+
+    /*
+     * Create a converter for local encoding.
+     */
+    if (!config_query_value(KW_CLIENT_ENCODING, &ac, &av, &lineNo)) {
+       WARN("\"%s\" not found in the configuration file\n",
+           KW_ALTERNATE_ENCODING);
+       return FALSE;
+    }
+    if (ac != 2) {
+       WARN("wrong # of args for \"%s\", line %d\n", KW_CLIENT_ENCODING,
+           lineNo);
+       return FALSE;
+    }
+    if ((r = mdn_converter_create(av[1], &client_converter, 0))
+       != mdn_success) {
+       mdnerror(r, "client encoding %s", av[1]);
+       return FALSE;
+    }
+
+    mdn_resconf_setlocalconverter(resconf, client_converter);
+
+    return TRUE;
+}
+
+void
+translate_finish(void)
+{
+    mdn_converter_destroy(client_converter);
+    mdn_resconf_destroy(resconf);
+}
+
+int
+translate_request(translation_context_t *ctx,
+                 const char *msg, size_t msglen,
+                 char *translated, size_t bufsize, size_t *translatedlenp)
+{
+    mdn_result_t r;
+
+    TRACE("translate_request()\n");
+
+    r = mdn_msgtrans_translate(resconf, msg, msglen,
+                              translated, bufsize, translatedlenp);
+
+    if (r != mdn_success) {
+       mdnerror(r, "translating request message from %s(%s)",
+                address_to_string(ctx->client),
+                ctx->protocol == SOCK_STREAM ? "tcp" : "udp");
+    }
+
+    return result_to_rcode(r);
+}
+
+int
+translate_reply(translation_context_t *ctx,
+               const char *msg, size_t msglen,
+               char *translated, size_t bufsize, size_t *translatedlenp)
+{
+    mdn_result_t r;
+
+    TRACE("translate_reply()\n");
+
+    r = mdn_msgtrans_translate(resconf, msg, msglen,
+                              translated, bufsize, translatedlenp);
+
+    if (r != mdn_success) {
+       mdnerror(r, "translating reply message from %s",
+                address_to_string(ctx->client));
+    }
+
+    return result_to_rcode(r);
+}
+
+static int
+result_to_rcode(mdn_result_t r)
+{
+    int rcode;
+
+    switch (r) {
+    case mdn_success:
+       rcode = RCODE_NO_ERROR;
+       break;
+    case mdn_buffer_overflow:
+    case mdn_nomemory:
+       rcode = RCODE_SERVER_FAILURE;
+       break;
+    case mdn_invalid_message:
+    case mdn_invalid_encoding:
+       rcode = RCODE_FORMAT_ERROR;
+       break;
+    default:
+       rcode = RCODE_SERVER_FAILURE;
+       break;
+    }
+    return rcode;
+}
+
+static char *
+address_to_string(struct sockaddr *sa)
+{
+    static char tmp[200];
+
+    switch (sa->sa_family) {
+    case AF_INET:
+    {
+       struct sockaddr_in *sin = (struct sockaddr_in *)sa;
+
+       sprintf(tmp, "%s/%d", inet_ntoa(sin->sin_addr),
+               ntohs(sin->sin_port));
+       break;
+    }
+#if 0
+#ifdef AF_INET6
+    case AF_INET6:
+    {
+       char buf[INET6_ADDRSTRLEN];
+
+       struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sa;
+
+       sprintf(tmp, "%s/%d",
+               inet_ntop(AF_INET6, &sin6->sin6_addr, buf, sizeof(buf)),
+               ntohs(sin6->sin6_port));
+       break;
+    }
+#endif
+#endif
+    default:
+       sprintf(tmp, "unknown address family %d", sa->sa_family);
+       break;
+    }
+    return tmp;
+}
+
+static void
+mdnerror(int code, char *fmt, ...)
+{
+    char buf[1024];
+    va_list args;
+
+    va_start(args, fmt);
+    vsprintf(buf, fmt, args);
+    va_end(args);
+
+    sprintf(buf + strlen(buf), ": %s", mdn_result_tostring(code));
+    WARN("%s\n", buf);
+}
similarity index 74%
rename from contrib/idn/mdnkit/dnsproxy/unxmain.c
rename to contrib/idn/mdnkit/mdnsproxy/unxmain.c
index 8ae42db74fe053ad3fc518e63841334bfaa65732..be7237d9d7ff65af8296e690f4f40936e167bcbb 100644 (file)
@@ -61,7 +61,7 @@
  */
 
 #ifndef lint
-static char *rcsid = "$Id: unxmain.c,v 1.16 2000/11/17 05:46:23 ishisone Exp $";
+static char *rcsid = "$Id: unxmain.c,v 1.1 2001/06/09 00:30:35 tale Exp $";
 #endif
 
 #ifdef UNIX
@@ -80,11 +80,8 @@ static char *rcsid = "$Id: unxmain.c,v 1.16 2000/11/17 05:46:23 ishisone Exp $";
 #include <sys/types.h>
 #include <pwd.h>
 #include <grp.h>
-#include "dnsproxy.h"       /* Common definitions for mDNS proxy    */
-
-#define KW_ROOT_DIR    "root-directory"
-#define KW_USER_ID     "user-id"
-#define KW_GROUP_ID    "group-id"
+#include "mdnsproxy.h"       /* Common definitions for mDNS proxy    */
+#include <mdn/version.h>
 
 static uid_t   uid;
 static gid_t   gid;
@@ -135,15 +132,15 @@ static    void    set_id(void)
 {
     int                err;
 
-    if (uid_specified && setuid(uid) < 0) {
+    if (gid_specified && setgid(gid) < 0) {
        err = errno;
-       FATAL("cannot set user ID: %s\n", strerror(err));
+       FATAL("cannot set group ID: %s\n", strerror(err));
        exit(1);
     }
 
-    if (gid_specified && setgid(gid) < 0) {
+    if (uid_specified && setuid(uid) < 0) {
        err = errno;
-       FATAL("cannot set group ID: %s\n", strerror(err));
+       FATAL("cannot set user ID: %s\n", strerror(err));
        exit(1);
     }
 }
@@ -156,10 +153,12 @@ static    void    get_security_conf(void)
 {
     int                ac;
     char       **av;
+    int                lineNo;
 
-    if (config_query_value(KW_ROOT_DIR, &ac, &av)) {
+    if (config_query_value(KW_ROOT_DIRECTORY, &ac, &av, &lineNo)) {
        if (ac != 2) {
-           WARN("syntax error at %s line\n", KW_ROOT_DIR);
+           WARN("wrong # of args for \"%s\", line %d\n", KW_ROOT_DIRECTORY,
+               lineNo);
            exit(1);
        }
        root_dir = malloc(strlen(av[1]) + 1);
@@ -170,11 +169,11 @@ static    void    get_security_conf(void)
        (void)strcpy(root_dir, av[1]);
     }
 
-    if (config_query_value(KW_USER_ID, &ac, &av)) {
+    if (config_query_value(KW_USER_ID, &ac, &av, &lineNo)) {
        struct passwd   *pwd;
 
        if (ac != 2) {
-           WARN("syntax error at %s line\n", KW_USER_ID);
+           WARN("wrong # of args for \"%s\", line %d\n", KW_USER_ID, lineNo);
            exit(1);
        } else if ((pwd = getpwnam(av[1])) != NULL) {
            uid = pwd->pw_uid;
@@ -183,16 +182,16 @@ static    void    get_security_conf(void)
            uid = atoi(av[1]);
            uid_specified = TRUE;
        } else {
-           FATAL("unknown user %s\n", av[1]);
+           FATAL("unknown user \"%.100s\", line %d\n", av[1], lineNo);
            exit(1);
        }
     }
 
-    if (config_query_value(KW_GROUP_ID, &ac, &av)) {
+    if (config_query_value(KW_GROUP_ID, &ac, &av, &lineNo)) {
        struct group    *gr;
 
        if (ac != 2) {
-           WARN("syntax error at %s line\n", KW_GROUP_ID);
+           WARN("wrong # of args for \"%s\", line %d\n", KW_GROUP_ID, lineNo);
            exit(1);
        } else if ((gr = getgrnam(av[1])) != NULL) {
            gid = gr->gr_gid;
@@ -201,12 +200,24 @@ static    void    get_security_conf(void)
            gid = atoi(av[1]);
            gid_specified = TRUE;
        } else {
-           FATAL("unknown group %s\n", av[1]);
+           FATAL("unknown group \"%.100s\", line %d\n", av[1], lineNo);
            exit(1);
        }
     }
 }
 
+/*
+ * print_version - print version information to stderr.
+ */
+
+static void    print_version(void)
+{
+    fprintf(stderr, "mdnsproxy (mDNkit) version: %s\n"
+           "library version: %s\n",
+           MDNKIT_VERSION,
+           mdn_version_getstring());
+}
+
 /*
  * main - entry of UNIX version
  */
@@ -216,21 +227,48 @@ int     main(int ac, char *av[])
     int     i, pid ;
     BOOL    as_daemon = FALSE ;
     
-    for (i = 1 ; i < ac ; i++) {
-        if (strcmp(av[i], "-daemon") == 0) {
+    i = 1;
+    while (i < ac) {
+        if (strcmp(av[i], CMDOPT_DAEMON) == 0) {
            as_daemon = TRUE ;
+           i++;
+       } else if (strcmp(av[i], CMDOPT_CONFIG) == 0) {
+           if (i + 1 == ac) {
+               fprintf(stderr, "missing argument to \"%s\"\n", av[i]) ;
+               return 1 ;
+           }
+           i += 2;
+        } else if (strcmp(av[i], CMDOPT_LOGFILE) == 0) {
+           if (i + 1 == ac) {
+               fprintf(stderr, "missing argument to \"%s\"\n", av[i]) ;
+               return 1 ;
+           }
+           i += 2;
+        } else if (strcmp(av[i], CMDOPT_VERSION) == 0) {
+           print_version();
+           return 0;
+       } else if (av[i][0] == '-' && av[i][1] != '\0') {
+               fprintf(stderr, "unknown option \"%s\"\n", av[i]) ;
+               return 1 ;
+       } else {
+               fprintf(stderr, "too many arguments\n");
+               return 1 ;
        }
     }
+
     if (config_load(ac, av) != TRUE) {
-        printf("cannot load configurations\n") ;
+        fprintf(stderr, "cannot load configuration\n") ;
        return 1 ;
     }
-    log_configure(ac, av) ;
-    
+    if (log_configure(ac, av) != TRUE) {
+        fprintf(stderr, "cannot logging\n") ;
+       return 1 ;
+    }
+
     get_security_conf();
 
     if (server_init(ac, av) != TRUE) {
-        printf("cannot initialize server\n") ;
+        fprintf(stderr, "cannot initialize server\n") ;
        log_terminate() ;
        return 1 ;
     }
@@ -238,7 +276,7 @@ int     main(int ac, char *av[])
     if (as_daemon) {
         switch (pid = fork()) {
        case -1 :
-           printf("cannot start daemon %d\n", errno) ;
+           fprintf(stderr, "cannot start daemon, %s\n", strerror(errno)) ;
            server_done()   ;
            log_terminate() ;
            return 2 ;
@@ -249,7 +287,7 @@ int     main(int ac, char *av[])
            close(2) ;
            break ;
         default :
-           printf("start daemon PID %d\n", pid) ;
+           fprintf(stderr, "start daemon PID %d\n", pid) ;
            return 0 ;
         }
     }
@@ -266,13 +304,13 @@ int     main(int ac, char *av[])
     signal(SIGTERM, handler)  ;
     
 #ifdef  DEBUG
-    printf("Service Started\n") ;
+    fprintf(stderr, "Service Started\n") ;
 #endif
     
     server_loop() ;
     
 #ifdef  DEBUG
-    printf("Service Terminating...\n") ;
+    fprintf(stderr, "Service Terminating...\n") ;
 #endif
 
     server_done() ;
@@ -280,7 +318,7 @@ int     main(int ac, char *av[])
     log_terminate() ;
     
 #ifdef  DEBUG
-    printf("Service Terminated\n") ;
+    fprintf(stderr, "Service Terminated\n") ;
 #endif
     
     return 0 ;
similarity index 95%
rename from contrib/idn/mdnkit/dnsproxy/winmain.c
rename to contrib/idn/mdnkit/mdnsproxy/winmain.c
index 75e65226d7e2f062f8c42f13af887ac99bb8937b..a487945279dc9fc21f48baac33d7f53e58e6300c 100644 (file)
@@ -78,7 +78,7 @@
  */
 
 #ifndef lint
-static char *rcsid = "$Id: winmain.c,v 1.10 2000/07/04 03:52:29 ishisone Exp $";
+static char *rcsid = "$Id: winmain.c,v 1.1 2001/06/09 00:30:36 tale Exp $";
 #endif
 
 #ifdef  WIN32
@@ -89,7 +89,7 @@ static char *rcsid = "$Id: winmain.c,v 1.10 2000/07/04 03:52:29 ishisone Exp $";
 #include <string.h>
 #include <signal.h>
 
-#include "dnsproxy.h"       /* Common definitions for mDNS proxy    */
+#include "mdnsproxy.h"       /* Common definitions for mDNS proxy    */
 #include "winserv.h"        /* WIN32 Service Related Functions      */
 
 /*
@@ -138,7 +138,11 @@ int     main(int ac, char *av[])
         printf("cannot load configration\n") ;
        return 1 ;
     }
-    log_configure(ac, av) ;
+
+    if (log_configure(ac, av) != TRUE) {
+        printf("cannot logging\n") ;
+       return 1 ;
+    }
     
     if (WSAStartup(version, &wsaData) != 0) {
         printf("cannot startup WinSock\n") ;
similarity index 97%
rename from contrib/idn/mdnkit/dnsproxy/winserv.c
rename to contrib/idn/mdnkit/mdnsproxy/winserv.c
index 122c19257a7ac42b7cb1ea17ed4f323b06c84287..3e590a3824a5df42f5c5e3b94ef70738273ee0f0 100644 (file)
@@ -61,7 +61,7 @@
  */
 
 #ifndef lint
-static char *rcsid = "$Id: winserv.c,v 1.10 2000/10/27 03:09:58 ishisone Exp $";
+static char *rcsid = "$Id: winserv.c,v 1.1 2001/06/09 00:30:36 tale Exp $";
 #endif
 
 #ifdef  WIN32
@@ -72,14 +72,14 @@ static char *rcsid = "$Id: winserv.c,v 1.10 2000/10/27 03:09:58 ishisone Exp $";
 #include <string.h>
 #include <tchar.h>
 
-#include "dnsproxy.h"       /* Common definitions for mDNS proxy    */
+#include "mdnsproxy.h"       /* Common definitions for mDNS proxy    */
 #include "winserv.h"        /* Windows's Service Specific           */
 
 /*
  * Parameters for WIN32 Service
  */
 
-#define SERVICENAME     "dnsproxy"
+#define SERVICENAME     "mdnsproxy"
 #define DISPLAYNAME     "mDNS Proxy"
 
 static  UCHAR   pathService[1024] ;
@@ -263,7 +263,12 @@ VOID    ServiceMain(DWORD dwArgc, LPTSTR *lpszArgv)
         serviceReport(SERVICE_STOPPED, 0, 0) ;
         return ;
     }
-    log_configure((int) dwArgc, (char **) lpszArgv) ;
+
+    if (log_configure((int) dwArgc, (char **) lpszArgv) != TRUE) {
+        serviceLogError("cannot logging") ;
+        serviceReport(SERVICE_STOPPED, 0, 0) ;
+        return ;
+    }
         
     if (WSAStartup(version, &wsaData) != 0) {
         serviceLogError("cannot initialize WinSock") ;
similarity index 98%
rename from contrib/idn/mdnkit/dnsproxy/winserv.h
rename to contrib/idn/mdnkit/mdnsproxy/winserv.h
index ded129aec817b7eccb1fe5689bcb958bc3dc8df5..61496dffa7551358ddf7b35eb41b5c2fcb7d1adf 100644 (file)
@@ -60,7 +60,7 @@
  *    jurisdiction and venue of Tokyo District Court of Japan.
  */
 
-/* $Id: winserv.h,v 1.6 2000/07/04 03:52:29 ishisone Exp $ */
+/* $Id: winserv.h,v 1.1 2001/06/09 00:30:36 tale Exp $ */
 
 #ifndef WINSERV_H
 #define WINSERV_H 1
diff --git a/contrib/idn/mdnkit/mkinstalldirs b/contrib/idn/mdnkit/mkinstalldirs
new file mode 100644 (file)
index 0000000..d8d17b4
--- /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 2001/06/09 00:29:31 tale 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/mdnkit/patch/bind8/bind-8.2.3-patch b/contrib/idn/mdnkit/patch/bind8/bind-8.2.3-patch
new file mode 100644 (file)
index 0000000..b35432f
--- /dev/null
@@ -0,0 +1,2429 @@
+8bit-through patch for bind-8.2.3
+=================================
+
+This is a patch file for ISC BIND 8.2.3 to make it work with
+internationalized domain names.  With this patch you'll get:
+       + 8bit-clean named
+       + 8bit-clean resolver (libbind)
+       + (almost) 8bit-clean nslookup
+
+This patch also contains fixes for incorrect usage of ctype
+macros/functions in the original source code.
+
+To apply this patch, you should go to the top directory of the distribution
+(where you see `src' subdirectory), then invoke `patch' command like this:
+
+       % patch -p0 < this-file
+
+Then follow the instructions described in `src/INSTALL' to compile
+and install.
+
+
+Known bugs
+----------
+
+* The `+domain=...' option of dig doesn't work correctly, whether the
+  given argument is multilingual domain name or not.
+  dig in ISC BIND 8.2.3 without the MDN patch has the same bug.
+
+
+Index: src/bin/addr/addr.c
+diff -c mdn/othersrc/bind8/src/bin/addr/addr.c:1.1.1.1 mdn/othersrc/bind8/src/bin/addr/addr.c:1.2
+*** src/bin/addr/addr.c        Wed May 24 15:35:10 2000
+--- src/bin/addr/addr.c        Mon Jul  3 13:08:49 2000
+***************
+*** 65,71 ****
+                       src++;
+                       continue;
+               }
+!              if (isascii(ch) && (isspace(ch) || ispunct(ch))) {
+                       if (digits > 0) {
+                               if (ptr == end)
+                                       return (0);
+--- 65,71 ----
+                       src++;
+                       continue;
+               }
+!              if (isascii((unsigned char)ch) && (isspace((unsigned char)ch) || ispunct((unsigned char)ch))) {
+                       if (digits > 0) {
+                               if (ptr == end)
+                                       return (0);
+***************
+*** 76,85 ****
+                       digits = 0;
+                       continue;
+               }
+!              if (!isascii(ch) || !isxdigit(ch))
+                       return (0);
+!              if (isupper(ch))
+!                      ch = tolower(ch);
+               /* Clock it in using little endian arithmetic. */
+               val <<= 4;
+               val |= (strchr(xdigits, ch) - xdigits);
+--- 76,85 ----
+                       digits = 0;
+                       continue;
+               }
+!              if (!isascii((unsigned char)ch) || !isxdigit((unsigned char)ch))
+                       return (0);
+!              if (isupper((unsigned char)ch))
+!                      ch = tolower((unsigned char)ch);
+               /* Clock it in using little endian arithmetic. */
+               val <<= 4;
+               val |= (strchr(xdigits, ch) - xdigits);
+Index: src/bin/dig/dig.c
+diff -c mdn/othersrc/bind8/src/bin/dig/dig.c:1.1.1.4 mdn/othersrc/bind8/src/bin/dig/dig.c:1.5
+*** src/bin/dig/dig.c  Mon Jan 29 17:22:41 2001
+--- src/bin/dig/dig.c  Mon Jan 29 17:32:27 2001
+***************
+*** 1154,1168 ****
+                               b = 8; p++;
+                               continue;
+                       }
+!              if (isupper(*p))
+!                      *p = tolower(*p);
+               if (*p == 'x') {
+                       b = 16; p++;
+                       continue;
+               }
+!              if (isdigit(*p)) {
+                       i = *p - '0';
+!              } else if (isxdigit(*p)) {
+                       i = *p - 'a' + 10;
+               } else {
+                       fprintf(stderr,
+--- 1154,1168 ----
+                               b = 8; p++;
+                               continue;
+                       }
+!              if (isupper((unsigned char)*p))
+!                      *p = tolower((unsigned char)*p);
+               if (*p == 'x') {
+                       b = 16; p++;
+                       continue;
+               }
+!              if (isdigit((unsigned char)*p)) {
+                       i = *p - '0';
+!              } else if (isxdigit((unsigned char)*p)) {
+                       i = *p - 'a' + 10;
+               } else {
+                       fprintf(stderr,
+***************
+*** 1659,1665 ****
+                       break;
+               default:
+                       *y++ = l;
+!                      while (!isspace(*l))
+                               l++;
+                       if (*l == '\n')
+                               done++;
+--- 1659,1665 ----
+                       break;
+               default:
+                       *y++ = l;
+!                      while (!isspace((unsigned char)*l))
+                               l++;
+                       if (*l == '\n')
+                               done++;
+Index: src/bin/dnskeygen/dnskeygen.c
+diff -c mdn/othersrc/bind8/src/bin/dnskeygen/dnskeygen.c:1.1.1.3 mdn/othersrc/bind8/src/bin/dnskeygen/dnskeygen.c:1.4
+*** src/bin/dnskeygen/dnskeygen.c      Mon Jan 29 17:22:42 2001
+--- src/bin/dnskeygen/dnskeygen.c      Mon Jan 29 17:32:27 2001
+***************
+*** 87,100 ****
+                       }
+                       break;
+               case 'p':
+!                      if (optarg && isdigit(optarg[0]))
+                               protocol = atoi(optarg);
+                       else
+                               usage("-p flag not followed by a number", 0);
+                       break;
+               case 's':
+                       /* Default: not signatory key */
+!                      if (optarg && isdigit(optarg[0]))
+                               sign_val = (int) atoi(optarg);
+                       else
+                               usage("-s flag requires a value",0);
+--- 87,100 ----
+                       }
+                       break;
+               case 'p':
+!                      if (optarg && isdigit((unsigned char)optarg[0]))
+                               protocol = atoi(optarg);
+                       else
+                               usage("-p flag not followed by a number", 0);
+                       break;
+               case 's':
+                       /* Default: not signatory key */
+!                      if (optarg && isdigit((unsigned char)optarg[0]))
+                               sign_val = (int) atoi(optarg);
+                       else
+                               usage("-s flag requires a value",0);
+***************
+*** 112,118 ****
+                       key_type++;
+                       break;
+               case 'H':
+!                      if (optarg && isdigit(optarg[0]))
+                               size = (int) atoi(optarg);
+                       else
+                               usage("-H flag requires a size",0);
+--- 112,118 ----
+                       key_type++;
+                       break;
+               case 'H':
+!                      if (optarg && isdigit((unsigned char)optarg[0]))
+                               size = (int) atoi(optarg);
+                       else
+                               usage("-H flag requires a size",0);
+***************
+*** 124,130 ****
+                                     PRINT_SUPPORTED);
+                       break;
+               case 'R':
+!                      if (optarg && isdigit(optarg[0]))
+                               size = (int) atoi(optarg);
+                       else
+                               usage("-R flag requires a size",0);
+--- 124,130 ----
+                                     PRINT_SUPPORTED);
+                       break;
+               case 'R':
+!                      if (optarg && isdigit((unsigned char)optarg[0]))
+                               size = (int) atoi(optarg);
+                       else
+                               usage("-R flag requires a size",0);
+***************
+*** 136,142 ****
+                                     PRINT_SUPPORTED);
+                       break;
+               case 'D':
+!                      if (optarg && isdigit(optarg[0]))
+                               size = (int) atoi(optarg);
+                       else
+                               usage("-D flag requires a size", 0);
+--- 136,142 ----
+                                     PRINT_SUPPORTED);
+                       break;
+               case 'D':
+!                      if (optarg && isdigit((unsigned char)optarg[0]))
+                               size = (int) atoi(optarg);
+                       else
+                               usage("-D flag requires a size", 0);
+Index: src/bin/irpd/irpd.c
+diff -c mdn/othersrc/bind8/src/bin/irpd/irpd.c:1.1.1.4 mdn/othersrc/bind8/src/bin/irpd/irpd.c:1.5
+*** src/bin/irpd/irpd.c        Mon Jan 29 17:22:42 2001
+--- src/bin/irpd/irpd.c        Mon Jan 29 17:32:27 2001
+***************
+*** 2049,2058 ****
+  
+       /* count + 1 of the number of runs of non-whitespace. */
+       for (iswh = 1, i = 1, p = string ; p != NULL && *p ; p++) {
+!              if (iswh && !isspace(*p)) {
+                       iswh = 0;
+                       i++;
+!              } else if (!iswh && isspace(*p)) {
+                       iswh = 1;
+               }
+       }
+--- 2049,2058 ----
+  
+       /* count + 1 of the number of runs of non-whitespace. */
+       for (iswh = 1, i = 1, p = string ; p != NULL && *p ; p++) {
+!              if (iswh && !isspace((unsigned char)*p)) {
+                       iswh = 0;
+                       i++;
+!              } else if (!iswh && isspace((unsigned char)*p)) {
+                       iswh = 1;
+               }
+       }
+***************
+*** 2073,2079 ****
+       a->iovlen = i;
+  
+       for (c = 0, p = string ; p != NULL && *p ; c++) {
+!              while (isspace(*p)) {
+                       p++;
+               }
+  
+--- 2073,2079 ----
+       a->iovlen = i;
+  
+       for (c = 0, p = string ; p != NULL && *p ; c++) {
+!              while (isspace((unsigned char)*p)) {
+                       p++;
+               }
+  
+***************
+*** 2082,2088 ****
+  
+               iovs[c].iov_base = (void *)p;
+  
+!              while (*p && !isspace(*p)) {
+                       p++;
+               }
+               iovs[c].iov_len = p - (char *)iovs[c].iov_base;
+--- 2082,2088 ----
+  
+               iovs[c].iov_base = (void *)p;
+  
+!              while (*p && !isspace((unsigned char)*p)) {
+                       p++;
+               }
+               iovs[c].iov_len = p - (char *)iovs[c].iov_base;
+Index: src/bin/named/db_defs.h
+diff -c mdn/othersrc/bind8/src/bin/named/db_defs.h:1.1.1.3 mdn/othersrc/bind8/src/bin/named/db_defs.h:1.4
+*** src/bin/named/db_defs.h    Mon Dec 25 13:48:48 2000
+--- src/bin/named/db_defs.h    Tue Dec 26 14:07:22 2000
+***************
+*** 201,207 ****
+  #define HASHMASK     0x1f
+  #define HASHROTATE(v) \
+       (((v) << HASHSHIFT) | ((v) >> ((sizeof(v) * 8) - HASHSHIFT)))
+! #define HASHLOWER(c) ((isascii(c) && isupper(c)) ? tolower(c) : (c))
+  #define HASHIMILATE(v,c) ((v) = (HASHROTATE(v)) + (HASHLOWER(c) & HASHMASK))
+  
+  #define TSIG_BUF_SIZE 640
+--- 201,207 ----
+  #define HASHMASK     0x1f
+  #define HASHROTATE(v) \
+       (((v) << HASHSHIFT) | ((v) >> ((sizeof(v) * 8) - HASHSHIFT)))
+! #define HASHLOWER(c) ((isascii((unsigned char)c) && isupper((unsigned char)c)) ? tolower((unsigned char)c) : (c))
+  #define HASHIMILATE(v,c) ((v) = (HASHROTATE(v)) + (HASHLOWER(c) & HASHMASK))
+  
+  #define TSIG_BUF_SIZE 640
+Index: src/bin/named/db_glue.c
+diff -c mdn/othersrc/bind8/src/bin/named/db_glue.c:1.1.1.4 mdn/othersrc/bind8/src/bin/named/db_glue.c:1.5
+*** src/bin/named/db_glue.c    Mon Jan 29 17:22:43 2001
+--- src/bin/named/db_glue.c    Mon Jan 29 17:32:28 2001
+***************
+*** 315,321 ****
+  get_class(const char *class) {
+       const struct map *mp;
+  
+!      if (isdigit(*class))
+               return (atoi(class));
+       for (mp = map_class; mp->token != NULL; mp++)
+               if (strcasecmp(class, mp->token) == 0)
+--- 315,321 ----
+  get_class(const char *class) {
+       const struct map *mp;
+  
+!      if (isdigit((unsigned char)*class))
+               return (atoi(class));
+       for (mp = map_class; mp->token != NULL; mp++)
+               if (strcasecmp(class, mp->token) == 0)
+Index: src/bin/named/db_ixfr.c
+diff -c mdn/othersrc/bind8/src/bin/named/db_ixfr.c:1.1.1.4 mdn/othersrc/bind8/src/bin/named/db_ixfr.c:1.5
+*** src/bin/named/db_ixfr.c    Mon Jan 29 17:22:43 2001
+--- src/bin/named/db_ixfr.c    Mon Jan 29 17:32:28 2001
+***************
+*** 543,549 ****
+                       n = 0;
+                       data[0] = '\0';
+                       (void) getword(buf, sizeof buf, fp, 1);
+!                      if (isdigit(buf[0])) {    /* ttl */
+                               if (ns_parse_ttl(buf, &l) < 0) {
+                                       err++;
+                                       break;
+--- 543,549 ----
+                       n = 0;
+                       data[0] = '\0';
+                       (void) getword(buf, sizeof buf, fp, 1);
+!                      if (isdigit((unsigned char)buf[0])) {    /* ttl */
+                               if (ns_parse_ttl(buf, &l) < 0) {
+                                       err++;
+                                       break;
+***************
+*** 705,711 ****
+                       case T_RT:
+                               n = 0;
+                               cp = buf;
+!                              while (isdigit(*cp))
+                                       n = n * 10 + (*cp++ - '0');
+                               /* catch bad values */
+                               cp = data;
+--- 705,711 ----
+                       case T_RT:
+                               n = 0;
+                               cp = buf;
+!                              while (isdigit((unsigned char)*cp))
+                                       n = n * 10 + (*cp++ - '0');
+                               /* catch bad values */
+                               cp = data;
+***************
+*** 730,736 ****
+                               n = 0;
+                               data[0] = '\0';
+                               cp = buf;
+!                              while (isdigit(*cp))
+                                       n = n * 10 + (*cp++ - '0');
+                               cp = data;
+                               PUTSHORT((u_int16_t) n, cp);
+--- 730,736 ----
+                               n = 0;
+                               data[0] = '\0';
+                               cp = buf;
+!                              while (isdigit((unsigned char)*cp))
+                                       n = n * 10 + (*cp++ - '0');
+                               cp = data;
+                               PUTSHORT((u_int16_t) n, cp);
+Index: src/bin/named/db_load.c
+diff -c mdn/othersrc/bind8/src/bin/named/db_load.c:1.1.1.4 mdn/othersrc/bind8/src/bin/named/db_load.c:1.5
+*** src/bin/named/db_load.c    Mon Jan 29 17:22:44 2001
+--- src/bin/named/db_load.c    Mon Jan 29 17:32:28 2001
+***************
+*** 821,827 ****
+                               n = 0;
+                               cp = buf;
+                               /* Order */
+!                              while (isdigit(*cp))
+                                       n = n * 10 + (*cp++ - '0');
+                               /* catch bad values */
+                               if (cp == buf || n > 65535)
+--- 821,827 ----
+                               n = 0;
+                               cp = buf;
+                               /* Order */
+!                              while (isdigit((unsigned char)*cp))
+                                       n = n * 10 + (*cp++ - '0');
+                               /* catch bad values */
+                               if (cp == buf || n > 65535)
+***************
+*** 889,895 ****
+                       case ns_t_srv:
+                               n = 0;
+                               cp = buf;
+!                              while (isdigit(*cp))
+                                       n = n * 10 + (*cp++ - '0');
+                               /* catch bad values */
+                               if ((cp == buf) || (n > 65535))
+--- 889,895 ----
+                       case ns_t_srv:
+                               n = 0;
+                               cp = buf;
+!                              while (isdigit((unsigned char)*cp))
+                                       n = n * 10 + (*cp++ - '0');
+                               /* catch bad values */
+                               if ((cp == buf) || (n > 65535))
+***************
+*** 928,934 ****
+                               n = 0;
+                               data[0] = '\0';
+                               cp = buf;
+!                              while (isdigit(*cp))
+                                       n = n * 10 + (*cp++ - '0');
+                               /* catch bad values */
+                               if ((cp == buf) || (n > 65535))
+--- 928,934 ----
+                               n = 0;
+                               data[0] = '\0';
+                               cp = buf;
+!                              while (isdigit((unsigned char)*cp))
+                                       n = n * 10 + (*cp++ - '0');
+                               /* catch bad values */
+                               if ((cp == buf) || (n > 65535))
+***************
+*** 1893,1899 ****
+               wordtouint32_error = 1;
+       else
+               while ('\0' != *bufend) {
+!                      if (isspace(*bufend))
+                               bufend++;
+                       else {
+                               wordtouint32_error = 1;
+--- 1893,1899 ----
+               wordtouint32_error = 1;
+       else
+               while ('\0' != *bufend) {
+!                      if (isspace((unsigned char)*bufend))
+                               bufend++;
+                       else {
+                               wordtouint32_error = 1;
+Index: src/bin/named/ns_config.c
+diff -c mdn/othersrc/bind8/src/bin/named/ns_config.c:1.1.1.4 mdn/othersrc/bind8/src/bin/named/ns_config.c:1.5
+*** src/bin/named/ns_config.c  Mon Jan 29 17:22:45 2001
+--- src/bin/named/ns_config.c  Mon Jan 29 17:32:28 2001
+***************
+*** 430,436 ****
+--- 430,440 ----
+       memset(zp, 0, sizeof (struct zoneinfo));
+       zp->z_origin = name;
+       zp->z_class = class;
++ #ifdef NO_8BIT_THRU
+       zp->z_checknames = not_set;
++ #else
++      zp->z_checknames = ignore;
++ #endif
+       if (server_options->flags & OPTION_MAINTAIN_IXFR_BASE)
+                zp->z_maintain_ixfr_base = 1;
+       else
+Index: src/bin/named/ns_init.c
+diff -c mdn/othersrc/bind8/src/bin/named/ns_init.c:1.1.1.4 mdn/othersrc/bind8/src/bin/named/ns_init.c:1.5
+*** src/bin/named/ns_init.c    Mon Jan 29 17:22:46 2001
+--- src/bin/named/ns_init.c    Mon Jan 29 17:32:28 2001
+***************
+*** 433,439 ****
+--- 433,443 ----
+         const char *owner,
+         struct in_addr source)
+  {
++ #ifdef NO_8BIT_THRU
+       enum severity severity = not_set;
++ #else
++      enum severity severity = ignore;
++ #endif
+       int ok = 1;
+  
+       if (zp != NULL)
+Index: src/bin/named/ns_lexer.c
+diff -c mdn/othersrc/bind8/src/bin/named/ns_lexer.c:1.1.1.3 mdn/othersrc/bind8/src/bin/named/ns_lexer.c:1.4
+*** src/bin/named/ns_lexer.c   Mon Dec 25 13:48:50 2000
+--- src/bin/named/ns_lexer.c   Tue Dec 26 14:07:22 2000
+***************
+*** 65,71 ****
+          int          warnings;
+          int          errors;
+       u_int           pushback_count;
+!      char            pushback[LEXER_MAX_PUSHBACK];
+       struct lexer_file_context *
+                       next;
+  } *LexerFileContext;
+--- 65,71 ----
+          int          warnings;
+          int          errors;
+       u_int           pushback_count;
+!      int             pushback[LEXER_MAX_PUSHBACK];
+       struct lexer_file_context *
+                       next;
+  } *LexerFileContext;
+Index: src/bin/named/ns_main.c
+diff -c mdn/othersrc/bind8/src/bin/named/ns_main.c:1.1.1.4 mdn/othersrc/bind8/src/bin/named/ns_main.c:1.5
+*** src/bin/named/ns_main.c    Mon Jan 29 17:22:47 2001
+--- src/bin/named/ns_main.c    Mon Jan 29 17:32:28 2001
+***************
+*** 2839,2845 ****
+       if (*s == '\0')
+               return (0);
+       while (*s != '\0') {
+!              if (!isdigit(*s))
+                       return (0);
+               s++;
+       }
+--- 2839,2845 ----
+       if (*s == '\0')
+               return (0);
+       while (*s != '\0') {
+!              if (!isdigit((unsigned char)*s))
+                       return (0);
+               s++;
+       }
+Index: src/bin/named/ns_parseutil.c
+diff -c mdn/othersrc/bind8/src/bin/named/ns_parseutil.c:1.1.1.2 mdn/othersrc/bind8/src/bin/named/ns_parseutil.c:1.3
+*** src/bin/named/ns_parseutil.c       Fri Sep  8 13:25:17 2000
+--- src/bin/named/ns_parseutil.c       Fri Sep  8 14:21:52 2000
+***************
+*** 116,123 ****
+  
+       for (s = key; *s != '\0'; s++) {
+               c = *s;
+!              if (isascii(c) && isupper(c))
+!                      c = tolower(c);
+               h = ( h << 4 ) + c;
+               if ((g = ( h & 0xf0000000 )) != 0) {
+                       h = h ^ (g >> 24);
+--- 116,123 ----
+  
+       for (s = key; *s != '\0'; s++) {
+               c = *s;
+!              if (isascii((unsigned char)c) && isupper((unsigned char)c))
+!                      c = tolower((unsigned char)c);
+               h = ( h << 4 ) + c;
+               if ((g = ( h & 0xf0000000 )) != 0) {
+                       h = h ^ (g >> 24);
+***************
+*** 213,219 ****
+       for (; (c = *in) != '\0'; in++) {
+               if (units_done)
+                       return (0);
+!              if (isdigit(c)) {
+                       result *= 10;
+                       result += (c - '0');
+               } else {
+--- 213,219 ----
+       for (; (c = *in) != '\0'; in++) {
+               if (units_done)
+                       return (0);
+!              if (isdigit((unsigned char)c)) {
+                       result *= 10;
+                       result += (c - '0');
+               } else {
+Index: src/bin/named/ns_update.c
+diff -c mdn/othersrc/bind8/src/bin/named/ns_update.c:1.1.1.4 mdn/othersrc/bind8/src/bin/named/ns_update.c:1.5
+*** src/bin/named/ns_update.c  Mon Jan 29 17:22:50 2001
+--- src/bin/named/ns_update.c  Mon Jan 29 17:32:28 2001
+***************
+*** 2354,2360 ****
+                       n = 0;
+                       data[0] = '\0';
+                       (void) getword(buf, sizeof buf, fp, 1);
+!                      if (isdigit(buf[0])) {  /* ttl */
+                               if (ns_parse_ttl(buf, &l) < 0) {
+                                       err++;
+                                       break;
+--- 2354,2360 ----
+                       n = 0;
+                       data[0] = '\0';
+                       (void) getword(buf, sizeof buf, fp, 1);
+!                      if (isdigit((unsigned char)buf[0])) {   /* ttl */
+                               if (ns_parse_ttl(buf, &l) < 0) {
+                                       err++;
+                                       break;
+***************
+*** 2523,2529 ****
+                               case T_RT:
+                                       n = 0;
+                                       cp = buf;
+!                                      while (isdigit(*cp))
+                                               n = n * 10 + (*cp++ - '0');
+                                       /* catch bad values */
+                                       cp = data;
+--- 2523,2529 ----
+                               case T_RT:
+                                       n = 0;
+                                       cp = buf;
+!                                      while (isdigit((unsigned char)*cp))
+                                               n = n * 10 + (*cp++ - '0');
+                                       /* catch bad values */
+                                       cp = data;
+***************
+*** 2549,2555 ****
+                                       n = 0;
+                                       data[0] = '\0';
+                                       cp = buf;
+!                                      while (isdigit(*cp))
+                                               n = n * 10 + (*cp++ - '0');
+                                       cp = data;
+                                       PUTSHORT((u_int16_t)n, cp);
+--- 2549,2555 ----
+                                       n = 0;
+                                       data[0] = '\0';
+                                       cp = buf;
+!                                      while (isdigit((unsigned char)*cp))
+                                               n = n * 10 + (*cp++ - '0');
+                                       cp = data;
+                                       PUTSHORT((u_int16_t)n, cp);
+Index: src/bin/named-xfer/named-xfer.c
+diff -c mdn/othersrc/bind8/src/bin/named-xfer/named-xfer.c:1.1.1.4 mdn/othersrc/bind8/src/bin/named-xfer/named-xfer.c:1.5
+*** src/bin/named-xfer/named-xfer.c    Mon Jan 29 17:22:51 2001
+--- src/bin/named-xfer/named-xfer.c    Mon Jan 29 17:32:28 2001
+***************
+*** 817,823 ****
+               fgets(buf, sizeof(buf), fp);
+               buf[strlen(buf)-1] = 0;
+               cp = buf;
+!              while (isspace(*cp))
+                       cp++;
+  
+               secret_len = b64_pton(cp, secret, sizeof(secret));
+--- 817,823 ----
+               fgets(buf, sizeof(buf), fp);
+               buf[strlen(buf)-1] = 0;
+               cp = buf;
+!              while (isspace((unsigned char)*cp))
+                       cp++;
+  
+               secret_len = b64_pton(cp, secret, sizeof(secret));
+Index: src/bin/ndc/ndc.c
+diff -c mdn/othersrc/bind8/src/bin/ndc/ndc.c:1.1.1.4 mdn/othersrc/bind8/src/bin/ndc/ndc.c:1.5
+*** src/bin/ndc/ndc.c  Mon Jan 29 17:22:52 2001
+--- src/bin/ndc/ndc.c  Mon Jan 29 17:32:29 2001
+***************
+*** 369,375 ****
+               long l = 0;
+               char ch;
+  
+!              while ((ch = *++cp) != '\0' && ch != '>' && isdigit(ch))
+                       l *= 10, l += (ch - '0');
+               if (ch == '>') {
+                       *pidp = (pid_t)l;
+--- 369,375 ----
+               long l = 0;
+               char ch;
+  
+!              while ((ch = *++cp) != '\0' && ch != '>' && isdigit((unsigned char)ch))
+                       l *= 10, l += (ch - '0');
+               if (ch == '>') {
+                       *pidp = (pid_t)l;
+Index: src/bin/nslookup/commands.l
+diff -c mdn/othersrc/bind8/src/bin/nslookup/commands.l:1.1.1.3 mdn/othersrc/bind8/src/bin/nslookup/commands.l:1.6
+*** src/bin/nslookup/commands.l        Mon Jan 29 17:22:52 2001
+--- src/bin/nslookup/commands.l        Mon Jan 29 17:32:29 2001
+***************
+*** 103,113 ****
+  extern void PrintHelp();
+  extern void ViewList(char *);
+  
+! %}
+! WS   [ \t]
+  FLET [A-Za-z0-9.*\\_]
+  LET  [A-Za-z0-9.*_]
+  NAME [A-Za-z0-9.*=_/-]
+  %%
+  ^{WS}*server{WS}+{LET}{NAME}*{WS}*$  {
+                                           /*
+--- 103,125 ----
+  extern void PrintHelp();
+  extern void ViewList(char *);
+  
+! #ifdef NO_8BIT_THRU
+! #error "Please change following lexical definitions by hand, and delete me."
+! /*
+!  * Please change following lexical definitions to
+  FLET [A-Za-z0-9.*\\_]
+  LET  [A-Za-z0-9.*_]
+  NAME [A-Za-z0-9.*=_/-]
++   by hand. Sorry for your inconvinience.
++  */
++ #endif
++ 
++ %}
++ %p 5000
++ WS   [ \t]
++ FLET [^ \t\n]
++ LET  [^ \t\n]
++ NAME [^ \t\n]
+  %%
+  ^{WS}*server{WS}+{LET}{NAME}*{WS}*$  {
+                                           /*
+Index: src/bin/nslookup/main.c
+diff -c mdn/othersrc/bind8/src/bin/nslookup/main.c:1.1.1.4 mdn/othersrc/bind8/src/bin/nslookup/main.c:1.5
+*** src/bin/nslookup/main.c    Mon Jan 29 17:22:52 2001
+--- src/bin/nslookup/main.c    Mon Jan 29 17:32:29 2001
+***************
+*** 441,450 ****
+  {
+      register char *cp;
+  
+!     if (isdigit(host[0])) {
+           /* Make sure it has only digits and dots. */
+           for (cp = host; *cp; ++cp) {
+!              if (!isdigit(*cp) && *cp != '.') 
+                   return FALSE;
+           }
+           /* If it has a trailing dot, don't treat it as an address. */
+--- 441,450 ----
+  {
+      register char *cp;
+  
+!     if (isdigit((unsigned char)host[0])) {
+           /* Make sure it has only digits and dots. */
+           for (cp = host; *cp; ++cp) {
+!              if (!isdigit((unsigned char)*cp) && *cp != '.') 
+                   return FALSE;
+           }
+           /* If it has a trailing dot, don't treat it as an address. */
+***************
+*** 888,898 ****
+      int              tmp;
+      int              i;
+  
+!     while (isspace(*option))
+       ++option;
+      if (strncmp (option, "set ", 4) == 0)
+       option += 4;
+!     while (isspace(*option))
+       ++option;
+  
+      if (*option == 0) {
+--- 888,898 ----
+      int              tmp;
+      int              i;
+  
+!     while (isspace((unsigned char)*option))
+       ++option;
+      if (strncmp (option, "set ", 4) == 0)
+       option += 4;
+!     while (isspace((unsigned char)*option))
+       ++option;
+  
+      if (*option == 0) {
+Index: src/bin/nslookup/subr.c
+diff -c mdn/othersrc/bind8/src/bin/nslookup/subr.c:1.1.1.2 mdn/othersrc/bind8/src/bin/nslookup/subr.c:1.3
+*** src/bin/nslookup/subr.c    Mon Jan 29 17:22:53 2001
+--- src/bin/nslookup/subr.c    Mon Jan 29 17:32:29 2001
+***************
+*** 513,522 ****
+       if (dest_size == 0 || dest == NULL || src == NULL)
+               return 0;
+       
+!      for (start = src ; isspace(*start) ; start++)
+               /* nada */ ;
+  
+!         for (end = start ; *end != '\0' && !isspace(*end) ; end++)
+               /* nada */ ;
+  
+       sublen = end - start ;
+--- 513,522 ----
+       if (dest_size == 0 || dest == NULL || src == NULL)
+               return 0;
+       
+!      for (start = src ; isspace((unsigned char)*start) ; start++)
+               /* nada */ ;
+  
+!         for (end = start ; *end != '\0' && !isspace((unsigned char)*end) ; end++)
+               /* nada */ ;
+  
+       sublen = end - start ;
+***************
+*** 560,582 ****
+       if (f == NULL || s == NULL)
+               goto notfound;
+  
+!      if (isspace(*f)) {
+!              while (isspace(*f))
+                       f++ ;
+!              while (isspace(*s))
+                       s++ ;
+       }
+       
+       while (1) {
+!              if (isspace(*f)) {
+!                      if (!isspace(*s))
+                               goto notfound;
+!                      while(isspace(*s))
+                               s++;
+                       /* any amount of whitespace in the format string
+                          will match any amount of space in the source
+                          string. */
+!                      while (isspace(*f))
+                               f++;
+               } else if (*f == '\0') {
+                       return (s - src);
+--- 560,582 ----
+       if (f == NULL || s == NULL)
+               goto notfound;
+  
+!      if (isspace((unsigned char)*f)) {
+!              while (isspace((unsigned char)*f))
+                       f++ ;
+!              while (isspace((unsigned char)*s))
+                       s++ ;
+       }
+       
+       while (1) {
+!              if (isspace((unsigned char)*f)) {
+!                      if (!isspace((unsigned char)*s))
+                               goto notfound;
+!                      while(isspace((unsigned char)*s))
+                               s++;
+                       /* any amount of whitespace in the format string
+                          will match any amount of space in the source
+                          string. */
+!                      while (isspace((unsigned char)*f))
+                               f++;
+               } else if (*f == '\0') {
+                       return (s - src);
+Index: src/bin/nsupdate/nsupdate.c
+diff -c mdn/othersrc/bind8/src/bin/nsupdate/nsupdate.c:1.1.1.4 mdn/othersrc/bind8/src/bin/nsupdate/nsupdate.c:1.5
+*** src/bin/nsupdate/nsupdate.c        Mon Jan 29 17:22:53 2001
+--- src/bin/nsupdate/nsupdate.c        Mon Jan 29 17:32:29 2001
+***************
+*** 397,403 ****
+  
+               (void) getword_str(buf2, sizeof buf2, &startp, endp);
+  
+!              if (isdigit(buf2[0])) { /* ttl */
+                   r_ttl = strtoul(buf2, 0, 10);
+                   if (errno == ERANGE && r_ttl == ULONG_MAX) {
+                       fprintf(stderr, "oversized ttl: %s\n", buf2);
+--- 397,403 ----
+  
+               (void) getword_str(buf2, sizeof buf2, &startp, endp);
+  
+!              if (isdigit((unsigned char)buf2[0])) { /* ttl */
+                   r_ttl = strtoul(buf2, 0, 10);
+                   if (errno == ERANGE && r_ttl == ULONG_MAX) {
+                       fprintf(stderr, "oversized ttl: %s\n", buf2);
+***************
+*** 458,464 ****
+                        * depending on type
+                        */
+                       cp = startp;
+!                      while (cp <= endp && isspace(*cp))
+                           cp++;
+                       r_size = endp - cp + 1;
+                       break;
+--- 458,464 ----
+                        * depending on type
+                        */
+                       cp = startp;
+!                      while (cp <= endp && isspace((unsigned char)*cp))
+                           cp++;
+                       r_size = endp - cp + 1;
+                       break;
+***************
+*** 488,494 ****
+                               }
+                       /* read rdata portion, if specified */
+                       cp = startp;
+!                      while (cp <= endp && isspace(*cp))
+                           cp++;
+                       r_size = endp - cp + 1;
+                       break;
+--- 488,494 ----
+                               }
+                       /* read rdata portion, if specified */
+                       cp = startp;
+!                      while (cp <= endp && isspace((unsigned char)*cp))
+                           cp++;
+                       r_size = endp - cp + 1;
+                       break;
+***************
+*** 512,518 ****
+                       }
+                       /* read rdata portion */
+                       cp = startp;
+!                      while (cp < endp && isspace(*cp))
+                           cp++;
+                       r_size = endp - cp + 1;
+                       if (r_size <= 0) {
+--- 512,518 ----
+                       }
+                       /* read rdata portion */
+                       cp = startp;
+!                      while (cp < endp && isspace((unsigned char)*cp))
+                           cp++;
+                       r_size = endp - cp + 1;
+                       if (r_size <= 0) {
+***************
+*** 616,622 ****
+   
+          for (cp = buf; *startpp <= endp; ) {
+                  c = **startpp;
+!                 if (isspace(c) || c == '\0') {
+                          if (cp != buf) /* trailing whitespace */
+                                  break;
+                          else { /* leading whitespace */
+--- 616,622 ----
+   
+          for (cp = buf; *startpp <= endp; ) {
+                  c = **startpp;
+!                 if (isspace((unsigned char)c) || c == '\0') {
+                          if (cp != buf) /* trailing whitespace */
+                                  break;
+                          else { /* leading whitespace */
+***************
+*** 649,655 ****
+               while(buf[i] && buf[i] != '"')
+                    i++;
+          } else {
+!              while(isspace(*buf))
+                    i++;
+          }
+          if (i > MAXCHARSTRING) {
+--- 649,655 ----
+               while(buf[i] && buf[i] != '"')
+                    i++;
+          } else {
+!              while(isspace((unsigned char)*buf))
+                    i++;
+          }
+          if (i > MAXCHARSTRING) {
+***************
+*** 667,673 ****
+          memmove(data + 1 + n, buf, i);
+          buf += i + 1;
+          n += i + 1;
+!         while(*buf && isspace(*buf))
+               buf++;
+     } while (nfield < maxfields && *buf);
+  
+--- 667,673 ----
+          memmove(data + 1 + n, buf, i);
+          buf += i + 1;
+          n += i + 1;
+!         while(*buf && isspace((unsigned char)*buf))
+               buf++;
+     } while (nfield < maxfields && *buf);
+  
+Index: src/lib/bsd/mktemp.c
+diff -c mdn/othersrc/bind8/src/lib/bsd/mktemp.c:1.1.1.1 mdn/othersrc/bind8/src/lib/bsd/mktemp.c:1.2
+*** src/lib/bsd/mktemp.c       Wed May 24 15:35:15 2000
+--- src/lib/bsd/mktemp.c       Mon Jul  3 13:09:02 2000
+***************
+*** 140,146 ****
+                       if (*trv == 'z')
+                               *trv++ = 'a';
+                       else {
+!                              if (isdigit(*trv))
+                                       *trv = 'a';
+                               else
+                                       ++*trv;
+--- 140,146 ----
+                       if (*trv == 'z')
+                               *trv++ = 'a';
+                       else {
+!                              if (isdigit((unsigned char)*trv))
+                                       *trv = 'a';
+                               else
+                                       ++*trv;
+Index: src/lib/bsd/strtoul.c
+diff -c mdn/othersrc/bind8/src/lib/bsd/strtoul.c:1.1.1.1 mdn/othersrc/bind8/src/lib/bsd/strtoul.c:1.2
+*** src/lib/bsd/strtoul.c      Wed May 24 15:35:15 2000
+--- src/lib/bsd/strtoul.c      Mon Jul  3 13:09:02 2000
+***************
+*** 71,77 ****
+        */
+       do {
+               c = *s++;
+!      } while (isspace(c));
+       if (c == '-') {
+               neg = 1;
+               c = *s++;
+--- 71,77 ----
+        */
+       do {
+               c = *s++;
+!      } while (isspace((unsigned char)c));
+       if (c == '-') {
+               neg = 1;
+               c = *s++;
+***************
+*** 88,97 ****
+       cutoff = (u_long)ULONG_MAX / (u_long)base;
+       cutlim = (u_long)ULONG_MAX % (u_long)base;
+       for (acc = 0, any = 0;; c = *s++) {
+!              if (isdigit(c))
+                       c -= '0';
+!              else if (isalpha(c))
+!                      c -= isupper(c) ? 'A' - 10 : 'a' - 10;
+               else
+                       break;
+               if (c >= base)
+--- 88,97 ----
+       cutoff = (u_long)ULONG_MAX / (u_long)base;
+       cutlim = (u_long)ULONG_MAX % (u_long)base;
+       for (acc = 0, any = 0;; c = *s++) {
+!              if (isdigit((unsigned char)c))
+                       c -= '0';
+!              else if (isalpha((unsigned char)c))
+!                      c -= isupper((unsigned char)c) ? 'A' - 10 : 'a' - 10;
+               else
+                       break;
+               if (c >= base)
+Index: src/lib/dst/dst_api.c
+diff -c mdn/othersrc/bind8/src/lib/dst/dst_api.c:1.1.1.4 mdn/othersrc/bind8/src/lib/dst/dst_api.c:1.5
+*** src/lib/dst/dst_api.c      Mon Jan 29 17:23:02 2001
+--- src/lib/dst/dst_api.c      Mon Jan 29 17:32:29 2001
+***************
+*** 555,561 ****
+       enckey[--len] = '\0';
+  
+       /* remove leading spaces */
+!      for (notspace = (char *) enckey; isspace(*notspace); len--)
+               notspace++;
+  
+       dlen = b64_pton(notspace, deckey, sizeof(deckey));
+--- 555,561 ----
+       enckey[--len] = '\0';
+  
+       /* remove leading spaces */
+!      for (notspace = (char *) enckey; isspace((unsigned char)*notspace); len--)
+               notspace++;
+  
+       dlen = b64_pton(notspace, deckey, sizeof(deckey));
+Index: src/lib/inet/inet_addr.c
+diff -c mdn/othersrc/bind8/src/lib/inet/inet_addr.c:1.1.1.1 mdn/othersrc/bind8/src/lib/inet/inet_addr.c:1.2
+*** src/lib/inet/inet_addr.c   Wed May 24 15:35:18 2000
+--- src/lib/inet/inet_addr.c   Mon Jul  3 13:09:05 2000
+***************
+*** 121,127 ****
+                * Values are specified as for C:
+                * 0x=hex, 0=octal, isdigit=decimal.
+                */
+!              if (!isdigit(c))
+                       return (0);
+               val = 0; base = 10; digit = 0;
+               if (c == '0') {
+--- 121,127 ----
+                * Values are specified as for C:
+                * 0x=hex, 0=octal, isdigit=decimal.
+                */
+!              if (!isdigit((unsigned char)c))
+                       return (0);
+               val = 0; base = 10; digit = 0;
+               if (c == '0') {
+***************
+*** 134,148 ****
+                       }
+               }
+               for (;;) {
+!                      if (isascii(c) && isdigit(c)) {
+                               if (base == 8 && (c == '8' || c == '9'))
+                                       return (0);
+                               val = (val * base) + (c - '0');
+                               c = *++cp;
+                               digit = 1;
+!                      } else if (base == 16 && isascii(c) && isxdigit(c)) {
+                               val = (val << 4) |
+!                                      (c + 10 - (islower(c) ? 'a' : 'A'));
+                               c = *++cp;
+                               digit = 1;
+                       } else
+--- 134,148 ----
+                       }
+               }
+               for (;;) {
+!                      if (isascii((unsigned char)c) && isdigit((unsigned char)c)) {
+                               if (base == 8 && (c == '8' || c == '9'))
+                                       return (0);
+                               val = (val * base) + (c - '0');
+                               c = *++cp;
+                               digit = 1;
+!                      } else if (base == 16 && isascii((unsigned char)c) && isxdigit((unsigned char)c)) {
+                               val = (val << 4) |
+!                                      (c + 10 - (islower((unsigned char)c) ? 'a' : 'A'));
+                               c = *++cp;
+                               digit = 1;
+                       } else
+***************
+*** 165,171 ****
+       /*
+        * Check for trailing characters.
+        */
+!      if (c != '\0' && (!isascii(c) || !isspace(c)))
+               return (0);
+       /*
+        * Did we get a valid digit?
+--- 165,171 ----
+       /*
+        * Check for trailing characters.
+        */
+!      if (c != '\0' && (!isascii((unsigned char)c) || !isspace((unsigned char)c)))
+               return (0);
+       /*
+        * Did we get a valid digit?
+Index: src/lib/inet/inet_cidr_pton.c
+diff -c mdn/othersrc/bind8/src/lib/inet/inet_cidr_pton.c:1.1.1.2 mdn/othersrc/bind8/src/lib/inet/inet_cidr_pton.c:1.3
+*** src/lib/inet/inet_cidr_pton.c      Mon Jan 29 17:23:03 2001
+--- src/lib/inet/inet_cidr_pton.c      Mon Jan 29 17:32:30 2001
+***************
+*** 80,86 ****
+       size_t size = 4;
+  
+       /* Get the mantissa. */
+!      while (ch = *src++, (isascii(ch) && isdigit(ch))) {
+               tmp = 0;
+               do {
+                       n = strchr(digits, ch) - digits;
+--- 80,86 ----
+       size_t size = 4;
+  
+       /* Get the mantissa. */
+!      while (ch = *src++, (isascii((unsigned char)ch) && isdigit((unsigned char)ch))) {
+               tmp = 0;
+               do {
+                       n = strchr(digits, ch) - digits;
+***************
+*** 89,95 ****
+                       tmp += n;
+                       if (tmp > 255)
+                               goto enoent;
+!              } while ((ch = *src++) != '\0' && isascii(ch) && isdigit(ch));
+               if (size-- == 0)
+                       goto emsgsize;
+               *dst++ = (u_char) tmp;
+--- 89,95 ----
+                       tmp += n;
+                       if (tmp > 255)
+                               goto enoent;
+!              } while ((ch = *src++) != '\0' && isascii((unsigned char)ch) && isdigit((unsigned char)ch));
+               if (size-- == 0)
+                       goto emsgsize;
+               *dst++ = (u_char) tmp;
+***************
+*** 101,107 ****
+  
+       /* Get the prefix length if any. */
+       bits = -1;
+!      if (ch == '/' && isascii(src[0]) && isdigit(src[0]) && dst > odst) {
+               /* CIDR width specifier.  Nothing can follow it. */
+               ch = *src++;    /* Skip over the /. */
+               bits = 0;
+--- 101,107 ----
+  
+       /* Get the prefix length if any. */
+       bits = -1;
+!      if (ch == '/' && isascii((unsigned char)src[0]) && isdigit((unsigned char)src[0]) && dst > odst) {
+               /* CIDR width specifier.  Nothing can follow it. */
+               ch = *src++;    /* Skip over the /. */
+               bits = 0;
+***************
+*** 110,116 ****
+                       INSIST(n >= 0 && n <= 9);
+                       bits *= 10;
+                       bits += n;
+!              } while ((ch = *src++) != '\0' && isascii(ch) && isdigit(ch));
+               if (ch != '\0')
+                       goto enoent;
+               if (bits > 32)
+--- 110,116 ----
+                       INSIST(n >= 0 && n <= 9);
+                       bits *= 10;
+                       bits += n;
+!              } while ((ch = *src++) != '\0' && isascii((unsigned char)ch) && isdigit((unsigned char)ch));
+               if (ch != '\0')
+                       goto enoent;
+               if (bits > 32)
+Index: src/lib/inet/inet_net_pton.c
+diff -c mdn/othersrc/bind8/src/lib/inet/inet_net_pton.c:1.1.1.1 mdn/othersrc/bind8/src/lib/inet/inet_net_pton.c:1.2
+*** src/lib/inet/inet_net_pton.c       Wed May 24 15:35:18 2000
+--- src/lib/inet/inet_net_pton.c       Mon Jul  3 13:09:06 2000
+***************
+*** 103,117 ****
+  
+       ch = *src++;
+       if (ch == '0' && (src[0] == 'x' || src[0] == 'X')
+!          && isascii(src[1]) && isxdigit(src[1])) {
+               /* Hexadecimal: Eat nybble string. */
+               if (size <= 0)
+                       goto emsgsize;
+               dirty = 0;
+               src++;  /* skip x or X. */
+!              while ((ch = *src++) != '\0' && isascii(ch) && isxdigit(ch)) {
+!                      if (isupper(ch))
+!                              ch = tolower(ch);
+                       n = strchr(xdigits, ch) - xdigits;
+                       INSIST(n >= 0 && n <= 15);
+                       if (dirty == 0)
+--- 103,117 ----
+  
+       ch = *src++;
+       if (ch == '0' && (src[0] == 'x' || src[0] == 'X')
+!          && isascii((unsigned char)src[1]) && isxdigit((unsigned char)src[1])) {
+               /* Hexadecimal: Eat nybble string. */
+               if (size <= 0)
+                       goto emsgsize;
+               dirty = 0;
+               src++;  /* skip x or X. */
+!              while ((ch = *src++) != '\0' && isascii((unsigned char)ch) && isxdigit((unsigned char)ch)) {
+!                      if (isupper((unsigned char)ch))
+!                              ch = tolower((unsigned char)ch);
+                       n = strchr(xdigits, ch) - xdigits;
+                       INSIST(n >= 0 && n <= 15);
+                       if (dirty == 0)
+***************
+*** 130,136 ****
+                               goto emsgsize;
+                       *dst++ = (u_char) (tmp << 4);
+               }
+!      } else if (isascii(ch) && isdigit(ch)) {
+               /* Decimal: eat dotted digit string. */
+               for (;;) {
+                       tmp = 0;
+--- 130,136 ----
+                               goto emsgsize;
+                       *dst++ = (u_char) (tmp << 4);
+               }
+!      } else if (isascii((unsigned char)ch) && isdigit((unsigned char)ch)) {
+               /* Decimal: eat dotted digit string. */
+               for (;;) {
+                       tmp = 0;
+***************
+*** 142,148 ****
+                               if (tmp > 255)
+                                       goto enoent;
+                       } while ((ch = *src++) != '\0' &&
+!                               isascii(ch) && isdigit(ch));
+                       if (size-- <= 0)
+                               goto emsgsize;
+                       *dst++ = (u_char) tmp;
+--- 142,148 ----
+                               if (tmp > 255)
+                                       goto enoent;
+                       } while ((ch = *src++) != '\0' &&
+!                               isascii((unsigned char)ch) && isdigit((unsigned char)ch));
+                       if (size-- <= 0)
+                               goto emsgsize;
+                       *dst++ = (u_char) tmp;
+***************
+*** 151,164 ****
+                       if (ch != '.')
+                               goto enoent;
+                       ch = *src++;
+!                      if (!isascii(ch) || !isdigit(ch))
+                               goto enoent;
+               }
+       } else
+               goto enoent;
+  
+       bits = -1;
+!      if (ch == '/' && isascii(src[0]) && isdigit(src[0]) && dst > odst) {
+               /* CIDR width specifier.  Nothing can follow it. */
+               ch = *src++;    /* Skip over the /. */
+               bits = 0;
+--- 151,164 ----
+                       if (ch != '.')
+                               goto enoent;
+                       ch = *src++;
+!                      if (!isascii((unsigned char)ch) || !isdigit((unsigned char)ch))
+                               goto enoent;
+               }
+       } else
+               goto enoent;
+  
+       bits = -1;
+!      if (ch == '/' && isascii((unsigned char)src[0]) && isdigit((unsigned char)src[0]) && dst > odst) {
+               /* CIDR width specifier.  Nothing can follow it. */
+               ch = *src++;    /* Skip over the /. */
+               bits = 0;
+***************
+*** 167,173 ****
+                       INSIST(n >= 0 && n <= 9);
+                       bits *= 10;
+                       bits += n;
+!              } while ((ch = *src++) != '\0' && isascii(ch) && isdigit(ch));
+               if (ch != '\0')
+                       goto enoent;
+               if (bits > 32)
+--- 167,173 ----
+                       INSIST(n >= 0 && n <= 9);
+                       bits *= 10;
+                       bits += n;
+!              } while ((ch = *src++) != '\0' && isascii((unsigned char)ch) && isdigit((unsigned char)ch));
+               if (ch != '\0')
+                       goto enoent;
+               if (bits > 32)
+Index: src/lib/inet/inet_network.c
+diff -c mdn/othersrc/bind8/src/lib/inet/inet_network.c:1.1.1.1 mdn/othersrc/bind8/src/lib/inet/inet_network.c:1.2
+*** src/lib/inet/inet_network.c        Wed May 24 15:35:18 2000
+--- src/lib/inet/inet_network.c        Mon Jul  3 13:09:06 2000
+***************
+*** 65,71 ****
+       if (*cp == 'x' || *cp == 'X')
+               base = 16, cp++;
+       while ((c = *cp) != 0) {
+!              if (isdigit(c)) {
+                       if (base == 8 && (c == '8' || c == '9'))
+                               return (INADDR_NONE);
+                       val = (val * base) + (c - '0');
+--- 65,71 ----
+       if (*cp == 'x' || *cp == 'X')
+               base = 16, cp++;
+       while ((c = *cp) != 0) {
+!              if (isdigit((unsigned char)c)) {
+                       if (base == 8 && (c == '8' || c == '9'))
+                               return (INADDR_NONE);
+                       val = (val * base) + (c - '0');
+***************
+*** 73,80 ****
+                       digit = 1;
+                       continue;
+               }
+!              if (base == 16 && isxdigit(c)) {
+!                      val = (val << 4) + (c + 10 - (islower(c) ? 'a' : 'A'));
+                       cp++;
+                       digit = 1;
+                       continue;
+--- 73,80 ----
+                       digit = 1;
+                       continue;
+               }
+!              if (base == 16 && isxdigit((unsigned char)c)) {
+!                      val = (val << 4) + (c + 10 - (islower((unsigned char)c) ? 'a' : 'A'));
+                       cp++;
+                       digit = 1;
+                       continue;
+***************
+*** 89,95 ****
+               *pp++ = val, cp++;
+               goto again;
+       }
+!      if (*cp && !isspace(*cp))
+               return (INADDR_NONE);
+       *pp++ = val;
+       n = pp - parts;
+--- 89,95 ----
+               *pp++ = val, cp++;
+               goto again;
+       }
+!      if (*cp && !isspace((unsigned char)*cp))
+               return (INADDR_NONE);
+       *pp++ = val;
+       n = pp - parts;
+Index: src/lib/inet/nsap_addr.c
+diff -c mdn/othersrc/bind8/src/lib/inet/nsap_addr.c:1.1.1.1 mdn/othersrc/bind8/src/lib/inet/nsap_addr.c:1.2
+*** src/lib/inet/nsap_addr.c   Wed May 24 15:35:18 2000
+--- src/lib/inet/nsap_addr.c   Mon Jul  3 13:09:06 2000
+***************
+*** 47,62 ****
+       while ((c = *ascii++) != '\0' && len < (u_int)maxlen) {
+               if (c == '.' || c == '+' || c == '/')
+                       continue;
+!              if (!isascii(c))
+                       return (0);
+!              if (islower(c))
+!                      c = toupper(c);
+!              if (isxdigit(c)) {
+                       nib = xtob(c);
+                       c = *ascii++;
+                       if (c != '\0') {
+!                              c = toupper(c);
+!                              if (isxdigit(c)) {
+                                       *binary++ = (nib << 4) | xtob(c);
+                                       len++;
+                               } else
+--- 47,62 ----
+       while ((c = *ascii++) != '\0' && len < (u_int)maxlen) {
+               if (c == '.' || c == '+' || c == '/')
+                       continue;
+!              if (!isascii((unsigned char)c))
+                       return (0);
+!              if (islower((unsigned char)c))
+!                      c = toupper((unsigned char)c);
+!              if (isxdigit((unsigned char)c)) {
+                       nib = xtob(c);
+                       c = *ascii++;
+                       if (c != '\0') {
+!                              c = toupper((unsigned char)c);
+!                              if (isxdigit((unsigned char)c)) {
+                                       *binary++ = (nib << 4) | xtob(c);
+                                       len++;
+                               } else
+Index: src/lib/irs/dns_nw.c
+diff -c mdn/othersrc/bind8/src/lib/irs/dns_nw.c:1.1.1.1 mdn/othersrc/bind8/src/lib/irs/dns_nw.c:1.2
+*** src/lib/irs/dns_nw.c       Wed May 24 15:35:18 2000
+--- src/lib/irs/dns_nw.c       Mon Jul  3 13:09:07 2000
+***************
+*** 539,546 ****
+  
+       /* Make lower case. */
+       for (t = name; *t; t++)
+!              if (isascii(*t) && isupper(*t))
+!                      *t = tolower(*t);
+  
+       /* Remove trailing dots. */
+       while (t > name && t[-1] == '.')
+--- 539,546 ----
+  
+       /* Make lower case. */
+       for (t = name; *t; t++)
+!              if (isascii((unsigned char)*t) && isupper((unsigned char)*t))
+!                      *t = tolower((unsigned char)*t);
+  
+       /* Remove trailing dots. */
+       while (t > name && t[-1] == '.')
+Index: src/lib/irs/dns_pr.c
+diff -c mdn/othersrc/bind8/src/lib/irs/dns_pr.c:1.1.1.1 mdn/othersrc/bind8/src/lib/irs/dns_pr.c:1.2
+*** src/lib/irs/dns_pr.c       Wed May 24 15:35:18 2000
+--- src/lib/irs/dns_pr.c       Mon Jul  3 13:09:07 2000
+***************
+*** 201,207 ****
+  
+               /* Skip blank lines. */
+               p = cp;
+!              while (*p && !isspace(*p))
+                       p++;
+               if (!*p)
+                       continue;
+--- 201,207 ----
+  
+               /* Skip blank lines. */
+               p = cp;
+!              while (*p && !isspace((unsigned char)*p))
+                       p++;
+               if (!*p)
+                       continue;
+***************
+*** 213,226 ****
+  
+               p = pvt->prbuf;
+               pvt->proto.p_name = p;
+!              while (*p && !isspace(*p))
+                       p++;
+               if (!*p)
+                       continue;
+               *p++ = '\0';
+  
+               pvt->proto.p_proto = atoi(p);
+!              while (*p && !isspace(*p))
+                       p++;
+               if (*p)
+                       *p++ = '\0';
+--- 213,226 ----
+  
+               p = pvt->prbuf;
+               pvt->proto.p_name = p;
+!              while (*p && !isspace((unsigned char)*p))
+                       p++;
+               if (!*p)
+                       continue;
+               *p++ = '\0';
+  
+               pvt->proto.p_proto = atoi(p);
+!              while (*p && !isspace((unsigned char)*p))
+                       p++;
+               if (*p)
+                       *p++ = '\0';
+***************
+*** 237,243 ****
+                               pvt->proto.p_aliases = new;
+                       }
+                       pvt->proto.p_aliases[num++] = p;
+!                      while (*p && !isspace(*p))
+                               p++;
+                       if (*p)
+                               *p++ = '\0';
+--- 237,243 ----
+                               pvt->proto.p_aliases = new;
+                       }
+                       pvt->proto.p_aliases[num++] = p;
+!                      while (*p && !isspace((unsigned char)*p))
+                               p++;
+                       if (*p)
+                               *p++ = '\0';
+Index: src/lib/irs/dns_sv.c
+diff -c mdn/othersrc/bind8/src/lib/irs/dns_sv.c:1.1.1.2 mdn/othersrc/bind8/src/lib/irs/dns_sv.c:1.3
+*** src/lib/irs/dns_sv.c       Fri Sep  8 13:25:25 2000
+--- src/lib/irs/dns_sv.c       Fri Sep  8 14:21:55 2000
+***************
+*** 189,195 ****
+  
+               /* Check to make sure the protocol matches. */
+               p = cp;
+!              while (*p && !isspace(*p))
+                       p++;
+               if (!*p)
+                       continue;
+--- 189,195 ----
+  
+               /* Check to make sure the protocol matches. */
+               p = cp;
+!              while (*p && !isspace((unsigned char)*p))
+                       p++;
+               if (!*p)
+                       continue;
+***************
+*** 197,204 ****
+                    proto_len = strlen(proto);
+                    if (strncasecmp(++p, proto, proto_len) != 0)
+                         continue;
+!                   if (p[proto_len] && !isspace(p[proto_len]))
+!                        continue;
+               }
+               /* OK, we've got a live one.  Let's parse it for real. */
+               if (pvt->svbuf)
+--- 197,204 ----
+                    proto_len = strlen(proto);
+                    if (strncasecmp(++p, proto, proto_len) != 0)
+                         continue;
+!                   if (p[proto_len] && !isspace((unsigned char)p[proto_len]))
+!                        continue;
+               }
+               /* OK, we've got a live one.  Let's parse it for real. */
+               if (pvt->svbuf)
+***************
+*** 207,227 ****
+  
+               p = pvt->svbuf;
+               pvt->serv.s_name = p;
+!              while (*p && !isspace(*p))
+                       p++;
+               if (!*p)
+                       continue;
+               *p++ = '\0';
+  
+               pvt->serv.s_proto = p;
+!              while (*p && !isspace(*p))
+                       p++;
+               if (!*p)
+                       continue;
+               *p++ = '\0';
+  
+               pvt->serv.s_port = htons((u_short) atoi(p));
+!              while (*p && !isspace(*p))
+                       p++;
+               if (*p)
+                       *p++ = '\0';
+--- 207,227 ----
+  
+               p = pvt->svbuf;
+               pvt->serv.s_name = p;
+!              while (*p && !isspace((unsigned char)*p))
+                       p++;
+               if (!*p)
+                       continue;
+               *p++ = '\0';
+  
+               pvt->serv.s_proto = p;
+!              while (*p && !isspace((unsigned char)*p))
+                       p++;
+               if (!*p)
+                       continue;
+               *p++ = '\0';
+  
+               pvt->serv.s_port = htons((u_short) atoi(p));
+!              while (*p && !isspace((unsigned char)*p))
+                       p++;
+               if (*p)
+                       *p++ = '\0';
+***************
+*** 238,244 ****
+                               pvt->serv.s_aliases = new;
+                       }
+                       pvt->serv.s_aliases[num++] = p;
+!                      while (*p && !isspace(*p))
+                               p++;
+                       if (*p)
+                               *p++ = '\0';
+--- 238,244 ----
+                               pvt->serv.s_aliases = new;
+                       }
+                       pvt->serv.s_aliases[num++] = p;
+!                      while (*p && !isspace((unsigned char)*p))
+                               p++;
+                       if (*p)
+                               *p++ = '\0';
+Index: src/lib/irs/gen.c
+diff -c mdn/othersrc/bind8/src/lib/irs/gen.c:1.1.1.1 mdn/othersrc/bind8/src/lib/irs/gen.c:1.2
+*** src/lib/irs/gen.c  Wed May 24 15:35:18 2000
+--- src/lib/irs/gen.c  Mon Jul  3 13:09:07 2000
+***************
+*** 399,405 ****
+               char *tmp;
+               int n;
+  
+!              for (tmp = line; isascii(*tmp) && isspace(*tmp); tmp++)
+                       (void)NULL;
+               if (*tmp == '#' || *tmp == '\n' || *tmp == '\0')
+                       continue;
+--- 399,405 ----
+               char *tmp;
+               int n;
+  
+!              for (tmp = line; isascii((unsigned char)*tmp) && isspace((unsigned char)*tmp); tmp++)
+                       (void)NULL;
+               if (*tmp == '#' || *tmp == '\n' || *tmp == '\0')
+                       continue;
+Index: src/lib/irs/getnetent.c
+diff -c mdn/othersrc/bind8/src/lib/irs/getnetent.c:1.1.1.2 mdn/othersrc/bind8/src/lib/irs/getnetent.c:1.3
+*** src/lib/irs/getnetent.c    Mon Jan 29 17:23:04 2001
+--- src/lib/irs/getnetent.c    Mon Jan 29 17:32:30 2001
+***************
+*** 259,268 ****
+               RES_SET_H_ERRNO(net_data->res, NETDB_INTERNAL);
+               return (NULL);
+       }
+!      if (!isascii(name[0]) || !isdigit(name[0]))
+               return (NULL);
+       for (cp = name; *cp; ++cp)
+!              if (!isascii(*cp) || (!isdigit(*cp) && *cp != '.'))
+                       return (NULL);
+       if (*--cp == '.')
+               return (NULL);
+--- 259,268 ----
+               RES_SET_H_ERRNO(net_data->res, NETDB_INTERNAL);
+               return (NULL);
+       }
+!      if (!isascii((unsigned char)name[0]) || !isdigit((unsigned char)name[0]))
+               return (NULL);
+       for (cp = name; *cp; ++cp)
+!              if (!isascii((unsigned char)*cp) || (!isdigit((unsigned char)*cp) && *cp != '.'))
+                       return (NULL);
+       if (*--cp == '.')
+               return (NULL);
+Index: src/lib/irs/irp.c
+diff -c mdn/othersrc/bind8/src/lib/irs/irp.c:1.1.1.2 mdn/othersrc/bind8/src/lib/irs/irp.c:1.3
+*** src/lib/irs/irp.c  Fri Sep  8 13:25:25 2000
+--- src/lib/irs/irp.c  Fri Sep  8 14:21:55 2000
+***************
+*** 387,395 ****
+               code = 0;
+       } else if (text != NULL && textlen > 0) {
+               p = line;
+!              while (isspace(*p)) p++;
+!              while (isdigit(*p)) p++;
+!              while (isspace(*p)) p++;
+               strncpy(text, p, textlen - 1);
+               p[textlen - 1] = '\0';
+       }
+--- 387,395 ----
+               code = 0;
+       } else if (text != NULL && textlen > 0) {
+               p = line;
+!              while (isspace((unsigned char)*p)) p++;
+!              while (isdigit((unsigned char)*p)) p++;
+!              while (isspace((unsigned char)*p)) p++;
+               strncpy(text, p, textlen - 1);
+               p[textlen - 1] = '\0';
+       }
+Index: src/lib/irs/irpmarshall.c
+diff -c mdn/othersrc/bind8/src/lib/irs/irpmarshall.c:1.1.1.2 mdn/othersrc/bind8/src/lib/irs/irpmarshall.c:1.3
+*** src/lib/irs/irpmarshall.c  Mon Dec 25 13:49:06 2000
+--- src/lib/irs/irpmarshall.c  Tue Dec 26 14:07:24 2000
+***************
+*** 1256,1262 ****
+       *host = *user = *domain = NULL;
+  
+       p = buffer;
+!      while (isspace(*p)) {
+               p++;
+       }
+       if (*p != '(') {
+--- 1256,1262 ----
+       *host = *user = *domain = NULL;
+  
+       p = buffer;
+!      while (isspace((unsigned char)*p)) {
+               p++;
+       }
+       if (*p != '(') {
+***************
+*** 1908,1920 ****
+  static int
+  strcmp_nws(const char *a, const char *b) {
+       while (*a && *b) {
+!              if (isspace(*a) && isspace(*b)) {
+                       do {
+                               a++;
+!                      } while (isspace(*a));
+                       do {
+                               b++;
+!                      } while (isspace(*b));
+               }
+               if (*a < *b)
+                       return (-1);
+--- 1908,1920 ----
+  static int
+  strcmp_nws(const char *a, const char *b) {
+       while (*a && *b) {
+!              if (isspace((unsigned char)*a) && isspace((unsigned char)*b)) {
+                       do {
+                               a++;
+!                      } while (isspace((unsigned char)*a));
+                       do {
+                               b++;
+!                      } while (isspace((unsigned char)*b));
+               }
+               if (*a < *b)
+                       return (-1);
+Index: src/lib/irs/nis_pr.c
+diff -c mdn/othersrc/bind8/src/lib/irs/nis_pr.c:1.1.1.1 mdn/othersrc/bind8/src/lib/irs/nis_pr.c:1.2
+*** src/lib/irs/nis_pr.c       Wed May 24 15:35:20 2000
+--- src/lib/irs/nis_pr.c       Mon Jul  3 13:09:08 2000
+***************
+*** 222,228 ****
+  
+       for (p = pvt->prbuf; *p && *p != '#'; p++)
+               NULL;
+!      while (p > pvt->prbuf && isspace(p[-1]))
+               p--;
+       *p = '\0';
+  
+--- 222,228 ----
+  
+       for (p = pvt->prbuf; *p && *p != '#'; p++)
+               NULL;
+!      while (p > pvt->prbuf && isspace((unsigned char)p[-1]))
+               p--;
+       *p = '\0';
+  
+***************
+*** 230,245 ****
+       n = m = 0;
+  
+       pvt->proto.p_name = p;
+!      while (*p && !isspace(*p))
+               p++;
+       if (!*p)
+               return (NULL);
+       *p++ = '\0';
+  
+!      while (*p && isspace(*p))
+               p++;
+       pvt->proto.p_proto = atoi(p);
+!      while (*p && !isspace(*p))
+               p++;
+       *p++ = '\0';
+  
+--- 230,245 ----
+       n = m = 0;
+  
+       pvt->proto.p_name = p;
+!      while (*p && !isspace((unsigned char)*p))
+               p++;
+       if (!*p)
+               return (NULL);
+       *p++ = '\0';
+  
+!      while (*p && isspace((unsigned char)*p))
+               p++;
+       pvt->proto.p_proto = atoi(p);
+!      while (*p && !isspace((unsigned char)*p))
+               p++;
+       *p++ = '\0';
+  
+***************
+*** 255,261 ****
+                       pvt->proto.p_aliases = t;
+               }
+               pvt->proto.p_aliases[n++] = p;
+!              while (*p && !isspace(*p))
+                       p++;
+               if (*p)
+                       *p++ = '\0';
+--- 255,261 ----
+                       pvt->proto.p_aliases = t;
+               }
+               pvt->proto.p_aliases[n++] = p;
+!              while (*p && !isspace((unsigned char)*p))
+                       p++;
+               if (*p)
+                       *p++ = '\0';
+Index: src/lib/irs/nis_sv.c
+diff -c mdn/othersrc/bind8/src/lib/irs/nis_sv.c:1.1.1.1 mdn/othersrc/bind8/src/lib/irs/nis_sv.c:1.2
+*** src/lib/irs/nis_sv.c       Wed May 24 15:35:20 2000
+--- src/lib/irs/nis_sv.c       Mon Jul  3 13:09:08 2000
+***************
+*** 242,248 ****
+       pvt->serv.s_port = htons((u_short) atoi(p));
+       pvt->serv.s_proto = NULL;
+       
+!      while (*p && !isspace(*p))
+               if (*p++ == '/')
+                       pvt->serv.s_proto = p;
+       if (!pvt->serv.s_proto)
+--- 242,248 ----
+       pvt->serv.s_port = htons((u_short) atoi(p));
+       pvt->serv.s_proto = NULL;
+       
+!      while (*p && !isspace((unsigned char)*p))
+               if (*p++ == '/')
+                       pvt->serv.s_proto = p;
+       if (!pvt->serv.s_proto)
+Index: src/lib/isc/base64.c
+diff -c mdn/othersrc/bind8/src/lib/isc/base64.c:1.1.1.1 mdn/othersrc/bind8/src/lib/isc/base64.c:1.2
+*** src/lib/isc/base64.c       Wed May 24 15:35:20 2000
+--- src/lib/isc/base64.c       Mon Jul  3 13:09:09 2000
+***************
+*** 210,216 ****
+       tarindex = 0;
+  
+       while ((ch = *src++) != '\0') {
+!              if (isspace(ch))        /* Skip whitespace anywhere. */
+                       continue;
+  
+               if (ch == Pad64)
+--- 210,216 ----
+       tarindex = 0;
+  
+       while ((ch = *src++) != '\0') {
+!              if (isspace((unsigned char)ch)) /* Skip whitespace anywhere. */
+                       continue;
+  
+               if (ch == Pad64)
+***************
+*** 280,286 ****
+               case 2:         /* Valid, means one byte of info */
+                       /* Skip any number of spaces. */
+                       for ((void)NULL; ch != '\0'; ch = *src++)
+!                              if (!isspace(ch))
+                                       break;
+                       /* Make sure there is another trailing = sign. */
+                       if (ch != Pad64)
+--- 280,286 ----
+               case 2:         /* Valid, means one byte of info */
+                       /* Skip any number of spaces. */
+                       for ((void)NULL; ch != '\0'; ch = *src++)
+!                              if (!isspace((unsigned char)ch))
+                                       break;
+                       /* Make sure there is another trailing = sign. */
+                       if (ch != Pad64)
+***************
+*** 295,301 ****
+                        * whitespace after it?
+                        */
+                       for ((void)NULL; ch != '\0'; ch = *src++)
+!                              if (!isspace(ch))
+                                       return (-1);
+  
+                       /*
+--- 295,301 ----
+                        * whitespace after it?
+                        */
+                       for ((void)NULL; ch != '\0'; ch = *src++)
+!                              if (!isspace((unsigned char)ch))
+                                       return (-1);
+  
+                       /*
+Index: src/lib/isc/ctl_clnt.c
+diff -c mdn/othersrc/bind8/src/lib/isc/ctl_clnt.c:1.1.1.2 mdn/othersrc/bind8/src/lib/isc/ctl_clnt.c:1.3
+*** src/lib/isc/ctl_clnt.c     Mon Dec 25 13:49:07 2000
+--- src/lib/isc/ctl_clnt.c     Tue Dec 26 14:07:24 2000
+***************
+*** 55,62 ****
+  /* Macros. */
+  
+  #define donefunc_p(ctx) ((ctx).donefunc != NULL)
+! #define arpacode_p(line) (isdigit(line[0]) && isdigit(line[1]) && \
+!                        isdigit(line[2]))
+  #define arpacont_p(line) (line[3] == '-')
+  #define arpadone_p(line) (line[3] == ' ' || line[3] == '\t' || \
+                         line[3] == '\r' || line[3] == '\0')
+--- 55,62 ----
+  /* Macros. */
+  
+  #define donefunc_p(ctx) ((ctx).donefunc != NULL)
+! #define arpacode_p(line) (isdigit((unsigned char)line[0]) && isdigit((unsigned char)line[1]) && \
+!                        isdigit((unsigned char)line[2]))
+  #define arpacont_p(line) (line[3] == '-')
+  #define arpadone_p(line) (line[3] == ' ' || line[3] == '\t' || \
+                         line[3] == '\r' || line[3] == '\0')
+***************
+*** 243,249 ****
+       memcpy(tran->outbuf.text, cmd, len);
+       tran->outbuf.used = len;
+       for (pc = tran->outbuf.text, n = 0; n < tran->outbuf.used; pc++, n++)
+!              if (!isascii(*pc) || !isprint(*pc))
+                       *pc = '\040';
+       start_write(ctx);
+       return (0);
+--- 243,249 ----
+       memcpy(tran->outbuf.text, cmd, len);
+       tran->outbuf.used = len;
+       for (pc = tran->outbuf.text, n = 0; n < tran->outbuf.used; pc++, n++)
+!              if (!isascii((unsigned char)*pc) || !isprint((unsigned char)*pc))
+                       *pc = '\040';
+       start_write(ctx);
+       return (0);
+Index: src/lib/isc/ctl_srvr.c
+diff -c mdn/othersrc/bind8/src/lib/isc/ctl_srvr.c:1.1.1.3 mdn/othersrc/bind8/src/lib/isc/ctl_srvr.c:1.4
+*** src/lib/isc/ctl_srvr.c     Mon Dec 25 13:49:07 2000
+--- src/lib/isc/ctl_srvr.c     Tue Dec 26 14:07:24 2000
+***************
+*** 328,334 ****
+                                    code, (flags & CTL_MORE) != 0 ? '-' : ' ',
+                                    text));
+       for (pc = sess->outbuf.text, n = 0; n < sess->outbuf.used-2; pc++, n++)
+!              if (!isascii(*pc) || !isprint(*pc))
+                       *pc = '\040';
+       *iovp++ = evConsIovec(sess->outbuf.text, sess->outbuf.used);
+       if (body != NULL) {
+--- 328,334 ----
+                                    code, (flags & CTL_MORE) != 0 ? '-' : ' ',
+                                    text));
+       for (pc = sess->outbuf.text, n = 0; n < sess->outbuf.used-2; pc++, n++)
+!              if (!isascii((unsigned char)*pc) || !isprint((unsigned char)*pc))
+                       *pc = '\040';
+       *iovp++ = evConsIovec(sess->outbuf.text, sess->outbuf.used);
+       if (body != NULL) {
+Index: src/lib/nameser/ns_date.c
+diff -c mdn/othersrc/bind8/src/lib/nameser/ns_date.c:1.1.1.1 mdn/othersrc/bind8/src/lib/nameser/ns_date.c:1.2
+*** src/lib/nameser/ns_date.c  Wed May 24 15:35:21 2000
+--- src/lib/nameser/ns_date.c  Mon Jul  3 13:09:11 2000
+***************
+*** 116,122 ****
+       int i;
+  
+       for (i = 0; i < size; i++) {
+!              if (!isdigit(buf[i]))
+                       *errp = 1;
+               result = (result * 10) + buf[i] - '0';
+       }
+--- 116,122 ----
+       int i;
+  
+       for (i = 0; i < size; i++) {
+!              if (!isdigit((unsigned char)buf[i]))
+                       *errp = 1;
+               result = (result * 10) + buf[i] - '0';
+       }
+Index: src/lib/nameser/ns_name.c
+diff -c mdn/othersrc/bind8/src/lib/nameser/ns_name.c:1.1.1.2 mdn/othersrc/bind8/src/lib/nameser/ns_name.c:1.4
+*** src/lib/nameser/ns_name.c  Fri Sep  8 13:25:28 2000
+--- src/lib/nameser/ns_name.c  Fri Dec 22 15:33:28 2000
+***************
+*** 171,179 ****
+--- 171,181 ----
+                               c = n;
+                       }
+                       escaped = 0;
++ #ifdef NO_8BIT_THRU
+               } else if (c == '\\') {
+                       escaped = 1;
+                       continue;
++ #endif
+               } else if (c == '.') {
+                       c = (bp - label - 1);
+                       if ((c & NS_CMPRSFLGS) != 0) {  /* Label too big. */
+***************
+*** 270,276 ****
+--- 272,282 ----
+               }
+               for ((void)NULL; n > 0; n--) {
+                       c = *cp++;
++ #ifdef NO_8BIT_THRU
+                       if (isupper(c))
++ #else
++                      if (c < 128 && isupper(c))
++ #endif
+                               *dn++ = tolower(c);
+                       else
+                               *dn++ = c;
+***************
+*** 566,571 ****
+--- 572,578 ----
+   */
+  static int
+  special(int ch) {
++ #ifdef NO_8BIT_THRU
+       switch (ch) {
+       case 0x22: /* '"' */
+       case 0x2E: /* '.' */
+***************
+*** 578,583 ****
+--- 585,593 ----
+       default:
+               return (0);
+       }
++ #else
++      return (0);
++ #endif
+  }
+  
+  /*
+***************
+*** 589,595 ****
+--- 599,609 ----
+   */
+  static int
+  printable(int ch) {
++ #ifdef NO_8BIT_THRU
+       return (ch > 0x20 && ch < 0x7f);
++ #else
++      return (1);
++ #endif
+  }
+  
+  /*
+Index: src/lib/nameser/ns_ttl.c
+diff -c mdn/othersrc/bind8/src/lib/nameser/ns_ttl.c:1.1.1.1 mdn/othersrc/bind8/src/lib/nameser/ns_ttl.c:1.2
+*** src/lib/nameser/ns_ttl.c   Wed May 24 15:35:21 2000
+--- src/lib/nameser/ns_ttl.c   Mon Jul  3 13:09:11 2000
+***************
+*** 86,93 ****
+               int ch;
+  
+               for (p = odst; (ch = *p) != '\0'; p++)
+!                      if (isascii(ch) && isupper(ch))
+!                              *p = tolower(ch);
+       }
+  
+       return (dst - odst);
+--- 86,93 ----
+               int ch;
+  
+               for (p = odst; (ch = *p) != '\0'; p++)
+!                      if (isascii((unsigned char)ch) && isupper((unsigned char)ch))
+!                              *p = tolower((unsigned char)ch);
+       }
+  
+       return (dst - odst);
+***************
+*** 103,111 ****
+       digits = 0;
+       dirty = 0;
+       while ((ch = *src++) != '\0') {
+!              if (!isascii(ch) || !isprint(ch))
+                       goto einval;
+!              if (isdigit(ch)) {
+                       tmp *= 10;
+                       tmp += (ch - '0');
+                       digits++;
+--- 103,111 ----
+       digits = 0;
+       dirty = 0;
+       while ((ch = *src++) != '\0') {
+!              if (!isascii((unsigned char)ch) || !isprint((unsigned char)ch))
+                       goto einval;
+!              if (isdigit((unsigned char)ch)) {
+                       tmp *= 10;
+                       tmp += (ch - '0');
+                       digits++;
+***************
+*** 113,120 ****
+               }
+               if (digits == 0)
+                       goto einval;
+!              if (islower(ch))
+!                      ch = toupper(ch);
+               switch (ch) {
+               case 'W':  tmp *= 7;
+               case 'D':  tmp *= 24;
+--- 113,120 ----
+               }
+               if (digits == 0)
+                       goto einval;
+!              if (islower((unsigned char)ch))
+!                      ch = toupper((unsigned char)ch);
+               switch (ch) {
+               case 'W':  tmp *= 7;
+               case 'D':  tmp *= 24;
+Index: src/lib/resolv/res_comp.c
+diff -c mdn/othersrc/bind8/src/lib/resolv/res_comp.c:1.1.1.1 mdn/othersrc/bind8/src/lib/resolv/res_comp.c:1.2
+*** src/lib/resolv/res_comp.c  Wed May 24 15:35:21 2000
+--- src/lib/resolv/res_comp.c  Wed May 24 17:16:22 2000
+***************
+*** 144,156 ****
+--- 144,164 ----
+  #define bslashchar(c) ((c) == 0x5c)
+  #define periodchar(c) ((c) == PERIOD)
+  #define asterchar(c) ((c) == 0x2a)
++ #ifdef NO_8BIT_THRU
+  #define alphachar(c) (((c) >= 0x41 && (c) <= 0x5a) \
+                  || ((c) >= 0x61 && (c) <= 0x7a))
++ #else
++ #define alphachar(c) (1)
++ #endif
+  #define digitchar(c) ((c) >= 0x30 && (c) <= 0x39)
+  
+  #define borderchar(c) (alphachar(c) || digitchar(c))
+  #define middlechar(c) (borderchar(c) || hyphenchar(c))
++ #ifdef NO_8BIT_THRU
+  #define      domainchar(c) ((c) > 0x20 && (c) < 0x7f)
++ #else
++ #define      domainchar(c) (1)
++ #endif
+  
+  int
+  res_hnok(const char *dn) {
+Index: src/lib/resolv/res_debug.c
+diff -c mdn/othersrc/bind8/src/lib/resolv/res_debug.c:1.1.1.3 mdn/othersrc/bind8/src/lib/resolv/res_debug.c:1.4
+*** src/lib/resolv/res_debug.c Mon Dec 25 13:49:09 2000
+--- src/lib/resolv/res_debug.c Tue Dec 26 14:07:25 2000
+***************
+*** 647,660 ****
+  
+       cp = *strptr;
+  
+!      while (isdigit(*cp))
+               mval = mval * 10 + (*cp++ - '0');
+  
+       if (*cp == '.') {               /* centimeters */
+               cp++;
+!              if (isdigit(*cp)) {
+                       cmval = (*cp++ - '0') * 10;
+!                      if (isdigit(*cp)) {
+                               cmval += (*cp++ - '0');
+                       }
+               }
+--- 647,660 ----
+  
+       cp = *strptr;
+  
+!      while (isdigit((unsigned char)*cp))
+               mval = mval * 10 + (*cp++ - '0');
+  
+       if (*cp == '.') {               /* centimeters */
+               cp++;
+!              if (isdigit((unsigned char)*cp)) {
+                       cmval = (*cp++ - '0') * 10;
+!                      if (isdigit((unsigned char)*cp)) {
+                               cmval += (*cp++ - '0');
+                       }
+               }
+***************
+*** 688,731 ****
+  
+       cp = *latlonstrptr;
+  
+!      while (isdigit(*cp))
+               deg = deg * 10 + (*cp++ - '0');
+  
+!      while (isspace(*cp))
+               cp++;
+  
+!      if (!(isdigit(*cp)))
+               goto fndhemi;
+  
+!      while (isdigit(*cp))
+               min = min * 10 + (*cp++ - '0');
+  
+!      while (isspace(*cp))
+               cp++;
+  
+!      if (!(isdigit(*cp)))
+               goto fndhemi;
+  
+!      while (isdigit(*cp))
+               secs = secs * 10 + (*cp++ - '0');
+  
+       if (*cp == '.') {               /* decimal seconds */
+               cp++;
+!              if (isdigit(*cp)) {
+                       secsfrac = (*cp++ - '0') * 100;
+!                      if (isdigit(*cp)) {
+                               secsfrac += (*cp++ - '0') * 10;
+!                              if (isdigit(*cp)) {
+                                       secsfrac += (*cp++ - '0');
+                               }
+                       }
+               }
+       }
+  
+!      while (!isspace(*cp))   /* if any trailing garbage */
+               cp++;
+  
+!      while (isspace(*cp))
+               cp++;
+  
+   fndhemi:
+--- 688,731 ----
+  
+       cp = *latlonstrptr;
+  
+!      while (isdigit((unsigned char)*cp))
+               deg = deg * 10 + (*cp++ - '0');
+  
+!      while (isspace((unsigned char)*cp))
+               cp++;
+  
+!      if (!(isdigit((unsigned char)*cp)))
+               goto fndhemi;
+  
+!      while (isdigit((unsigned char)*cp))
+               min = min * 10 + (*cp++ - '0');
+  
+!      while (isspace((unsigned char)*cp))
+               cp++;
+  
+!      if (!(isdigit((unsigned char)*cp)))
+               goto fndhemi;
+  
+!      while (isdigit((unsigned char)*cp))
+               secs = secs * 10 + (*cp++ - '0');
+  
+       if (*cp == '.') {               /* decimal seconds */
+               cp++;
+!              if (isdigit((unsigned char)*cp)) {
+                       secsfrac = (*cp++ - '0') * 100;
+!                      if (isdigit((unsigned char)*cp)) {
+                               secsfrac += (*cp++ - '0') * 10;
+!                              if (isdigit((unsigned char)*cp)) {
+                                       secsfrac += (*cp++ - '0');
+                               }
+                       }
+               }
+       }
+  
+!      while (!isspace((unsigned char)*cp))    /* if any trailing garbage */
+               cp++;
+  
+!      while (isspace((unsigned char)*cp))
+               cp++;
+  
+   fndhemi:
+***************
+*** 763,772 ****
+  
+       cp++;                   /* skip the hemisphere */
+  
+!      while (!isspace(*cp))   /* if any trailing garbage */
+               cp++;
+  
+!      while (isspace(*cp))    /* move to next field */
+               cp++;
+  
+       *latlonstrptr = cp;
+--- 763,772 ----
+  
+       cp++;                   /* skip the hemisphere */
+  
+!      while (!isspace((unsigned char)*cp))    /* if any trailing garbage */
+               cp++;
+  
+!      while (isspace((unsigned char)*cp))     /* move to next field */
+               cp++;
+  
+       *latlonstrptr = cp;
+***************
+*** 824,837 ****
+       if (*cp == '+')
+               cp++;
+  
+!      while (isdigit(*cp))
+               altmeters = altmeters * 10 + (*cp++ - '0');
+  
+       if (*cp == '.') {               /* decimal meters */
+               cp++;
+!              if (isdigit(*cp)) {
+                       altfrac = (*cp++ - '0') * 10;
+!                      if (isdigit(*cp)) {
+                               altfrac += (*cp++ - '0');
+                       }
+               }
+--- 824,837 ----
+       if (*cp == '+')
+               cp++;
+  
+!      while (isdigit((unsigned char)*cp))
+               altmeters = altmeters * 10 + (*cp++ - '0');
+  
+       if (*cp == '.') {               /* decimal meters */
+               cp++;
+!              if (isdigit((unsigned char)*cp)) {
+                       altfrac = (*cp++ - '0') * 10;
+!                      if (isdigit((unsigned char)*cp)) {
+                               altfrac += (*cp++ - '0');
+                       }
+               }
+***************
+*** 839,848 ****
+  
+       alt = (10000000 + (altsign * (altmeters * 100 + altfrac)));
+  
+!      while (!isspace(*cp) && (cp < maxcp)) /* if trailing garbage or m */
+               cp++;
+  
+!      while (isspace(*cp) && (cp < maxcp))
+               cp++;
+  
+       if (cp >= maxcp)
+--- 839,848 ----
+  
+       alt = (10000000 + (altsign * (altmeters * 100 + altfrac)));
+  
+!      while (!isspace((unsigned char)*cp) && (cp < maxcp)) /* if trailing garbage or m */
+               cp++;
+  
+!      while (isspace((unsigned char)*cp) && (cp < maxcp))
+               cp++;
+  
+       if (cp >= maxcp)
+***************
+*** 850,859 ****
+  
+       siz = precsize_aton(&cp);
+       
+!      while (!isspace(*cp) && (cp < maxcp))   /* if trailing garbage or m */
+               cp++;
+  
+!      while (isspace(*cp) && (cp < maxcp))
+               cp++;
+  
+       if (cp >= maxcp)
+--- 850,859 ----
+  
+       siz = precsize_aton(&cp);
+       
+!      while (!isspace((unsigned char)*cp) && (cp < maxcp))    /* if trailing garbage or m */
+               cp++;
+  
+!      while (isspace((unsigned char)*cp) && (cp < maxcp))
+               cp++;
+  
+       if (cp >= maxcp)
+***************
+*** 861,870 ****
+  
+       hp = precsize_aton(&cp);
+  
+!      while (!isspace(*cp) && (cp < maxcp))   /* if trailing garbage or m */
+               cp++;
+  
+!      while (isspace(*cp) && (cp < maxcp))
+               cp++;
+  
+       if (cp >= maxcp)
+--- 861,870 ----
+  
+       hp = precsize_aton(&cp);
+  
+!      while (!isspace((unsigned char)*cp) && (cp < maxcp))    /* if trailing garbage or m */
+               cp++;
+  
+!      while (isspace((unsigned char)*cp) && (cp < maxcp))
+               cp++;
+  
+       if (cp >= maxcp)
+Index: src/lib/resolv/res_init.c
+diff -c mdn/othersrc/bind8/src/lib/resolv/res_init.c:1.1.1.3 mdn/othersrc/bind8/src/lib/resolv/res_init.c:1.4
+*** src/lib/resolv/res_init.c  Mon Dec 25 13:49:09 2000
+--- src/lib/resolv/res_init.c  Tue Dec 26 14:07:25 2000
+***************
+*** 307,313 ****
+                           break;
+                       net = cp;
+                       while (*cp && !ISSORTMASK(*cp) && *cp != ';' &&
+!                             isascii(*cp) && !isspace(*cp))
+                               cp++;
+                       n = *cp;
+                       *cp = 0;
+--- 307,313 ----
+                           break;
+                       net = cp;
+                       while (*cp && !ISSORTMASK(*cp) && *cp != ';' &&
+!                             isascii((unsigned char)*cp) && !isspace((unsigned char)*cp))
+                               cp++;
+                       n = *cp;
+                       *cp = 0;
+***************
+*** 317,323 ****
+                               *cp++ = n;
+                               net = cp;
+                               while (*cp && *cp != ';' &&
+!                                      isascii(*cp) && !isspace(*cp))
+                                   cp++;
+                               n = *cp;
+                               *cp = 0;
+--- 317,323 ----
+                               *cp++ = n;
+                               net = cp;
+                               while (*cp && *cp != ';' &&
+!                                      isascii((unsigned char)*cp) && !isspace((unsigned char)*cp))
+                                   cp++;
+                               n = *cp;
+                               *cp = 0;
+Index: src/lib/resolv/res_query.c
+diff -c mdn/othersrc/bind8/src/lib/resolv/res_query.c:1.1.1.2 mdn/othersrc/bind8/src/lib/resolv/res_query.c:1.3
+*** src/lib/resolv/res_query.c Fri Sep  8 13:25:29 2000
+--- src/lib/resolv/res_query.c Fri Sep  8 14:21:56 2000
+***************
+*** 383,399 ****
+       setbuf(fp, NULL);
+       buf[sizeof(buf) - 1] = '\0';
+       while (fgets(buf, sizeof(buf), fp)) {
+!              for (cp1 = buf; *cp1 && !isspace(*cp1); ++cp1)
+                       ;
+               if (!*cp1)
+                       break;
+               *cp1 = '\0';
+               if (ns_samename(buf, name) == 1) {
+!                      while (isspace(*++cp1))
+                               ;
+                       if (!*cp1)
+                               break;
+!                      for (cp2 = cp1 + 1; *cp2 && !isspace(*cp2); ++cp2)
+                               ;
+                       *cp2 = '\0';
+                       strncpy(dst, cp1, siz - 1);
+--- 383,399 ----
+       setbuf(fp, NULL);
+       buf[sizeof(buf) - 1] = '\0';
+       while (fgets(buf, sizeof(buf), fp)) {
+!              for (cp1 = buf; *cp1 && !isspace((unsigned char)*cp1); ++cp1)
+                       ;
+               if (!*cp1)
+                       break;
+               *cp1 = '\0';
+               if (ns_samename(buf, name) == 1) {
+!                      while (isspace((unsigned char)*++cp1))
+                               ;
+                       if (!*cp1)
+                               break;
+!                      for (cp2 = cp1 + 1; *cp2 && !isspace((unsigned char)*cp2); ++cp2)
+                               ;
+                       *cp2 = '\0';
+                       strncpy(dst, cp1, siz - 1);
diff --git a/contrib/idn/mdnkit/patch/bind9/bind-9.1.2-patch b/contrib/idn/mdnkit/patch/bind9/bind-9.1.2-patch
new file mode 100644 (file)
index 0000000..49145db
--- /dev/null
@@ -0,0 +1,3899 @@
+MDN patch for bind-9.1.2
+========================
+
+This is a patch file for ISC BIND 9.1.2 to make it work with
+internationalized/multilingual domain names.  With this patch you'll
+get MDN-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.mdnkit' to compile
+and install.
+
+
+Index: README.mdnkit
+diff -c /dev/null mdn/othersrc/bind9/README.mdnkit:1.6
+*** README.mdnkit      Mon May 21 16:25:43 2001
+--- README.mdnkit      Thu Apr 26 14:04:09 2001
+***************
+*** 0 ****
+--- 1,96 ----
++ 
++                      BIND-9 MDN patch
++ 
++             Japan Network Information Center (JPNIC)
++ 
++ 
++ * What is this patch for?
++ 
++ This patch adds multilingual domain name (MDN) support to BIND-9.
++ You'll get multilingualized version of dig/host/nslookup commands.
++ 
++     + mulltilingualized 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 mDNkit 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 3 options to `configure'.  You should
++ at least specify `--with-mdn' option to enable MDN support.
++ 
++     --with-mdn[=PREFIX]
++      To enable MDN support, you have to specify `--with-mdn'
++      option.  If you specified installation prefix other than
++      `/usr/local' (which is the default) when conifguring mDNkit,
++      also specify the prefix, like `--with-mdn=/usr/local/mdnkit'.
++ 
++     --with-iconv=LIBSPEC
++      If your libc doens't provide iconv(), you need to specify the
++      library containing iconv() with this option.  `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-mdnlib=LIBSPEC
++      With this option, you can explicitly specify the argument(s)
++      to `cc' or `ld' to link the mDNkit's library, `libmdn'.  If
++      this option is not specified, `-L${PREFIX}/lib -lmdn' is
++      assumed, where ${PREFIX} is the installation prefix specified
++      with `--with-mdn' option above.  You may need to use this
++      option to specify extra argments, for example,
++      `--with-mdnlib="-L/usr/local/lib -R/usr/local/lib -lmdn"'.
++ 
++ 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.
++ 
++ 3. Resolver configuration
++ 
++ To handle multilingual domain names, you have to specify the
++ properties like:
++      + name encoding used in DNS protocol data
++      + normalization (NAMEPREP) schemes
++ These properties are specified by the mDNkit's configuration file,
++ "mdn.conf".  You have to create and set up the file properly.  The
++ pathname of the file and contents are described in the manual
++ "mdn.conf".
++ 
++ 
++ * Contact information
++ 
++ Please see http//www.nic.ad.jp/jp/research/idn/ for the latest news
++ about mDNkit 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.1.2-patch,v 1.1 2001/06/09 00:30:36 tale Exp $
+Index: config.h.in
+diff -c mdn/othersrc/bind9/config.h.in:1.1.1.5 mdn/othersrc/bind9/config.h.in:1.8
+*** config.h.in        Tue Apr 17 14:17:01 2001
+--- config.h.in        Thu Apr 26 13:54:40 2001
+***************
+*** 132,137 ****
+--- 132,140 ----
+  /* define if pthread_attr_getstacksize() is available */
+  #undef HAVE_PTHREAD_ATTR_GETSTACKSIZE
+  
++ /* Define if you have the setlocale function.  */
++ #undef HAVE_SETLOCALE
++ 
+  /* Define if you have the <fcntl.h> header file.  */
+  #undef HAVE_FCNTL_H
+  
+***************
+*** 141,146 ****
+--- 144,152 ----
+  /* Define if you have the <linux/prctl.h> header file.  */
+  #undef HAVE_LINUX_PRCTL_H
+  
++ /* Define if you have the <locale.h> header file.  */
++ #undef HAVE_LOCALE_H
++ 
+  /* Define if you have the <sys/sockio.h> header file.  */
+  #undef HAVE_SYS_SOCKIO_H
+  
+***************
+*** 158,160 ****
+--- 164,170 ----
+  
+  /* Define if you have the socket library (-lsocket).  */
+  #undef HAVE_LIBSOCKET
++ 
++ /* define if mDNkit support is to be included. */
++ #undef WITH_MDN
++ 
+Index: configure
+diff -c mdn/othersrc/bind9/configure:1.1.1.6 mdn/othersrc/bind9/configure:1.8
+*** configure  Tue Apr 17 14:17:03 2001
+--- configure  Tue Apr 17 17:31:12 2001
+***************
+*** 153,158 ****
+--- 153,164 ----
+    --enable-ipv6              use IPv6 [default=autodetect]"
+  ac_help="$ac_help
+    --with-kame[=PATH] use Kame IPv6 [default path /usr/local/v6]"
++ ac_help="$ac_help
++   --with-mdn[=PREFIX]    enable MDN support using mDNkit [default prefix /usr/local]"
++ ac_help="$ac_help
++   --with-iconv[=LIBSPEC]   specify iconv library [default -liconv]"
++ ac_help="$ac_help
++   --with-mdnlib=ARG    specify libmdn"
+  
+  # Initialize some variables set by options.
+  # The variables have the same names as the options, with
+***************
+*** 693,699 ****
+  fi
+  
+  echo $ac_n "checking host system type""... $ac_c" 1>&6
+! echo "configure:697: checking host system type" >&5
+  
+  host_alias=$host
+  case "$host_alias" in
+--- 699,705 ----
+  fi
+  
+  echo $ac_n "checking host system type""... $ac_c" 1>&6
+! echo "configure:703: checking host system type" >&5
+  
+  host_alias=$host
+  case "$host_alias" in
+***************
+*** 715,721 ****
+  
+  
+  echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
+! echo "configure:719: 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
+--- 721,727 ----
+  
+  
+  echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
+! echo "configure:725: 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
+***************
+*** 744,750 ****
+  # 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:748: 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
+--- 750,756 ----
+  # 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:754: 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
+***************
+*** 783,789 ****
+  # 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:787: 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
+--- 789,795 ----
+  # 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:793: 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
+***************
+*** 844,850 ****
+  # 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:848: 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
+--- 850,856 ----
+  # 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:854: 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
+***************
+*** 900,906 ****
+  # 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:904: 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
+--- 906,912 ----
+  # 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:910: 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
+***************
+*** 945,951 ****
+  # 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:949: 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
+--- 951,957 ----
+  # 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:955: 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
+***************
+*** 1093,1106 ****
+  # Find the machine's endian flavor.
+  #
+  echo $ac_n "checking whether byte ordering is bigendian""... $ac_c" 1>&6
+! echo "configure:1097: 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 1104 "configure"
+  #include "confdefs.h"
+  #include <sys/types.h>
+  #include <sys/param.h>
+--- 1099,1112 ----
+  # Find the machine's endian flavor.
+  #
+  echo $ac_n "checking whether byte ordering is bigendian""... $ac_c" 1>&6
+! echo "configure:1103: 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 1110 "configure"
+  #include "confdefs.h"
+  #include <sys/types.h>
+  #include <sys/param.h>
+***************
+*** 1111,1121 ****
+  #endif
+  ; return 0; }
+  EOF
+! if { (eval echo configure:1115: \"$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 1119 "configure"
+  #include "confdefs.h"
+  #include <sys/types.h>
+  #include <sys/param.h>
+--- 1117,1127 ----
+  #endif
+  ; return 0; }
+  EOF
+! if { (eval echo configure:1121: \"$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 1125 "configure"
+  #include "confdefs.h"
+  #include <sys/types.h>
+  #include <sys/param.h>
+***************
+*** 1126,1132 ****
+  #endif
+  ; return 0; }
+  EOF
+! if { (eval echo configure:1130: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    ac_cv_c_bigendian=yes
+  else
+--- 1132,1138 ----
+  #endif
+  ; return 0; }
+  EOF
+! if { (eval echo configure:1136: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    ac_cv_c_bigendian=yes
+  else
+***************
+*** 1146,1152 ****
+      { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 1150 "configure"
+  #include "confdefs.h"
+  main () {
+    /* Are we little or big endian?  From Harbison&Steele.  */
+--- 1152,1158 ----
+      { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 1156 "configure"
+  #include "confdefs.h"
+  main () {
+    /* Are we little or big endian?  From Harbison&Steele.  */
+***************
+*** 1159,1165 ****
+    exit (u.c[sizeof (long) - 1] == 1);
+  }
+  EOF
+! if { (eval echo configure:1163: \"$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
+--- 1165,1171 ----
+    exit (u.c[sizeof (long) - 1] == 1);
+  }
+  EOF
+! if { (eval echo configure:1169: \"$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
+***************
+*** 1187,1193 ****
+  # was --with-openssl specified?
+  #
+  echo $ac_n "checking for compatible OpenSSL library""... $ac_c" 1>&6
+! echo "configure:1191: checking for compatible OpenSSL library" >&5
+  # Check whether --with-openssl or --without-openssl was given.
+  if test "${with_openssl+set}" = set; then
+    withval="$with_openssl"
+--- 1193,1199 ----
+  # was --with-openssl specified?
+  #
+  echo $ac_n "checking for compatible OpenSSL library""... $ac_c" 1>&6
+! echo "configure:1197: checking for compatible OpenSSL library" >&5
+  # Check whether --with-openssl or --without-openssl was given.
+  if test "${with_openssl+set}" = set; then
+    withval="$with_openssl"
+***************
+*** 1278,1284 ****
+  # was --with-randomdev specified?
+  #
+  echo $ac_n "checking for random device""... $ac_c" 1>&6
+! echo "configure:1282: checking for random device" >&5
+  # Check whether --with-randomdev or --without-randomdev was given.
+  if test "${with_randomdev+set}" = set; then
+    withval="$with_randomdev"
+--- 1284,1290 ----
+  # was --with-randomdev specified?
+  #
+  echo $ac_n "checking for random device""... $ac_c" 1>&6
+! echo "configure:1288: checking for random device" >&5
+  # Check whether --with-randomdev or --without-randomdev was given.
+  if test "${with_randomdev+set}" = set; then
+    withval="$with_randomdev"
+***************
+*** 1325,1331 ****
+  # 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:1329: 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
+--- 1331,1337 ----
+  # 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:1335: 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
+***************
+*** 1355,1361 ****
+    # 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:1359: 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
+--- 1361,1367 ----
+    # 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:1365: 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
+***************
+*** 1406,1412 ****
+        # 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:1410: 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
+--- 1412,1418 ----
+        # 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:1416: 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
+***************
+*** 1438,1444 ****
+  fi
+  
+  echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
+! echo "configure:1442: 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.
+--- 1444,1450 ----
+  fi
+  
+  echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
+! echo "configure:1448: 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,1460 ****
+  
+  cat > conftest.$ac_ext << EOF
+  
+! #line 1453 "configure"
+  #include "confdefs.h"
+  
+  main(){return(0);}
+  EOF
+! if { (eval echo configure:1458: \"$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
+--- 1455,1466 ----
+  
+  cat > conftest.$ac_ext << EOF
+  
+! #line 1459 "configure"
+  #include "confdefs.h"
+  
+  main(){return(0);}
+  EOF
+! if { (eval echo configure:1464: \"$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
+***************
+*** 1480,1491 ****
+    { 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:1484: 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:1489: 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
+--- 1486,1497 ----
+    { 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:1490: 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:1495: 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
+***************
+*** 1494,1500 ****
+    yes;
+  #endif
+  EOF
+! if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1498: \"$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
+--- 1500,1506 ----
+    yes;
+  #endif
+  EOF
+! if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1504: \"$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
+***************
+*** 1513,1519 ****
+  ac_save_CFLAGS="$CFLAGS"
+  CFLAGS=
+  echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
+! echo "configure:1517: 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
+--- 1519,1525 ----
+  ac_save_CFLAGS="$CFLAGS"
+  CFLAGS=
+  echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
+! echo "configure:1523: 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 ****
+  # 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:1553: checking for $ac_word" >&5
+  if eval "test \"`echo '$''{'ac_cv_prog_YACC'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+--- 1555,1561 ----
+  # 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:1559: checking for $ac_word" >&5
+  if eval "test \"`echo '$''{'ac_cv_prog_YACC'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+***************
+*** 1581,1587 ****
+  
+  
+  echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
+! echo "configure:1585: checking how to run the C preprocessor" >&5
+  # On Suns, sometimes $CPP names a directory.
+  if test -n "$CPP" && test -d "$CPP"; then
+    CPP=
+--- 1587,1593 ----
+  
+  
+  echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
+! echo "configure:1591: checking how to run the C preprocessor" >&5
+  # On Suns, sometimes $CPP names a directory.
+  if test -n "$CPP" && test -d "$CPP"; then
+    CPP=
+***************
+*** 1596,1608 ****
+    # On the NeXT, cc -E runs the code through the compiler's parser,
+    # not just through cpp.
+    cat > conftest.$ac_ext <<EOF
+! #line 1600 "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:1606: \"$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
+    :
+--- 1602,1614 ----
+    # On the NeXT, cc -E runs the code through the compiler's parser,
+    # not just through cpp.
+    cat > conftest.$ac_ext <<EOF
+! #line 1606 "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:1612: \"$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
+    :
+***************
+*** 1613,1625 ****
+    rm -rf conftest*
+    CPP="${CC-cc} -E -traditional-cpp"
+    cat > conftest.$ac_ext <<EOF
+! #line 1617 "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:1623: \"$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
+    :
+--- 1619,1631 ----
+    rm -rf conftest*
+    CPP="${CC-cc} -E -traditional-cpp"
+    cat > conftest.$ac_ext <<EOF
+! #line 1623 "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:1629: \"$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
+    :
+***************
+*** 1630,1642 ****
+    rm -rf conftest*
+    CPP="${CC-cc} -nologo -E"
+    cat > conftest.$ac_ext <<EOF
+! #line 1634 "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:1640: \"$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
+    :
+--- 1636,1648 ----
+    rm -rf conftest*
+    CPP="${CC-cc} -nologo -E"
+    cat > conftest.$ac_ext <<EOF
+! #line 1640 "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: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
+    :
+***************
+*** 1661,1672 ****
+  echo "$ac_t""$CPP" 1>&6
+  
+  echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
+! echo "configure:1665: 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 1670 "configure"
+  #include "confdefs.h"
+  #include <stdlib.h>
+  #include <stdarg.h>
+--- 1667,1678 ----
+  echo "$ac_t""$CPP" 1>&6
+  
+  echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
+! echo "configure:1671: 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 1676 "configure"
+  #include "confdefs.h"
+  #include <stdlib.h>
+  #include <stdarg.h>
+***************
+*** 1674,1680 ****
+  #include <float.h>
+  EOF
+  ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+! { (eval echo configure:1678: \"$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*
+--- 1680,1686 ----
+  #include <float.h>
+  EOF
+  ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+! { (eval echo configure:1684: \"$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*
+***************
+*** 1691,1697 ****
+  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 1695 "configure"
+  #include "confdefs.h"
+  #include <string.h>
+  EOF
+--- 1697,1703 ----
+  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 1701 "configure"
+  #include "confdefs.h"
+  #include <string.h>
+  EOF
+***************
+*** 1709,1715 ****
+  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 1713 "configure"
+  #include "confdefs.h"
+  #include <stdlib.h>
+  EOF
+--- 1715,1721 ----
+  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 1719 "configure"
+  #include "confdefs.h"
+  #include <stdlib.h>
+  EOF
+***************
+*** 1730,1736 ****
+    :
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 1734 "configure"
+  #include "confdefs.h"
+  #include <ctype.h>
+  #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+--- 1736,1742 ----
+    :
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 1740 "configure"
+  #include "confdefs.h"
+  #include <ctype.h>
+  #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+***************
+*** 1741,1747 ****
+  exit (0); }
+  
+  EOF
+! if { (eval echo configure:1745: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+  then
+    :
+  else
+--- 1747,1753 ----
+  exit (0); }
+  
+  EOF
+! if { (eval echo configure:1751: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+  then
+    :
+  else
+***************
+*** 1769,1785 ****
+  do
+  ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+  echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+! echo "configure:1773: 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 1778 "configure"
+  #include "confdefs.h"
+  #include <$ac_hdr>
+  EOF
+  ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+! { (eval echo configure:1783: \"$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,1791 ----
+  do
+  ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+  echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+! echo "configure:1779: 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 1784 "configure"
+  #include "confdefs.h"
+  #include <$ac_hdr>
+  EOF
+  ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+! { (eval echo configure:1789: \"$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*
+***************
+*** 1807,1818 ****
+  
+  
+  echo $ac_n "checking for working const""... $ac_c" 1>&6
+! echo "configure:1811: 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 1816 "configure"
+  #include "confdefs.h"
+  
+  int main() {
+--- 1813,1824 ----
+  
+  
+  echo $ac_n "checking for working const""... $ac_c" 1>&6
+! echo "configure:1817: 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 1822 "configure"
+  #include "confdefs.h"
+  
+  int main() {
+***************
+*** 1861,1867 ****
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:1865: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    ac_cv_c_const=yes
+  else
+--- 1867,1873 ----
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:1871: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    ac_cv_c_const=yes
+  else
+***************
+*** 1882,1902 ****
+  fi
+  
+  echo $ac_n "checking for inline""... $ac_c" 1>&6
+! echo "configure:1886: 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 1893 "configure"
+  #include "confdefs.h"
+  
+  int main() {
+  } $ac_kw foo() {
+  ; return 0; }
+  EOF
+! if { (eval echo configure:1900: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    ac_cv_c_inline=$ac_kw; break
+  else
+--- 1888,1908 ----
+  fi
+  
+  echo $ac_n "checking for inline""... $ac_c" 1>&6
+! echo "configure:1892: 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 1899 "configure"
+  #include "confdefs.h"
+  
+  int main() {
+  } $ac_kw foo() {
+  ; return 0; }
+  EOF
+! if { (eval echo configure:1906: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    ac_cv_c_inline=$ac_kw; break
+  else
+***************
+*** 1922,1933 ****
+  esac
+  
+  echo $ac_n "checking for size_t""... $ac_c" 1>&6
+! echo "configure:1926: 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 1931 "configure"
+  #include "confdefs.h"
+  #include <sys/types.h>
+  #if STDC_HEADERS
+--- 1928,1939 ----
+  esac
+  
+  echo $ac_n "checking for size_t""... $ac_c" 1>&6
+! echo "configure:1932: 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 1937 "configure"
+  #include "confdefs.h"
+  #include <sys/types.h>
+  #if STDC_HEADERS
+***************
+*** 1955,1966 ****
+  fi
+  
+  echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
+! echo "configure:1959: 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 1964 "configure"
+  #include "confdefs.h"
+  #include <sys/types.h>
+  #include <sys/time.h>
+--- 1961,1972 ----
+  fi
+  
+  echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
+! echo "configure:1965: 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 1970 "configure"
+  #include "confdefs.h"
+  #include <sys/types.h>
+  #include <sys/time.h>
+***************
+*** 1969,1975 ****
+  struct tm *tp;
+  ; return 0; }
+  EOF
+! if { (eval echo configure:1973: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    ac_cv_header_time=yes
+  else
+--- 1975,1981 ----
+  struct tm *tp;
+  ; return 0; }
+  EOF
+! if { (eval echo configure:1979: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    ac_cv_header_time=yes
+  else
+***************
+*** 1996,2002 ****
+  # First, decide whether to use multithreading or not.
+  #
+  echo $ac_n "checking whether to look for thread support""... $ac_c" 1>&6
+! echo "configure:2000: checking whether to look for thread support" >&5
+  # Check whether --enable-threads or --disable-threads was given.
+  if test "${enable_threads+set}" = set; then
+    enableval="$enable_threads"
+--- 2002,2008 ----
+  # First, decide whether to use multithreading or not.
+  #
+  echo $ac_n "checking whether to look for thread support""... $ac_c" 1>&6
+! echo "configure:2006: checking whether to look for thread support" >&5
+  # Check whether --enable-threads or --disable-threads was given.
+  if test "${enable_threads+set}" = set; then
+    enableval="$enable_threads"
+***************
+*** 2033,2039 ****
+               # experiment with it.
+               CC="gcc"
+               echo $ac_n "checking which NetBSD thread library to use""... $ac_c" 1>&6
+! echo "configure:2037: checking which NetBSD thread library to use" >&5
+  
+               # Check whether --with-ptl2 or --without-ptl2 was given.
+  if test "${with_ptl2+set}" = set; then
+--- 2039,2045 ----
+               # experiment with it.
+               CC="gcc"
+               echo $ac_n "checking which NetBSD thread library to use""... $ac_c" 1>&6
+! echo "configure:2043: checking which NetBSD thread library to use" >&5
+  
+               # Check whether --with-ptl2 or --without-ptl2 was given.
+  if test "${with_ptl2+set}" = set; then
+***************
+*** 2072,2078 ****
+               ;;
+               *)
+                       echo $ac_n "checking for pthread_create in -lpthread""... $ac_c" 1>&6
+! echo "configure:2076: 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
+--- 2078,2084 ----
+               ;;
+               *)
+                       echo $ac_n "checking for pthread_create in -lpthread""... $ac_c" 1>&6
+! echo "configure:2082: 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
+***************
+*** 2080,2086 ****
+    ac_save_LIBS="$LIBS"
+  LIBS="-lpthread  $LIBS"
+  cat > conftest.$ac_ext <<EOF
+! #line 2084 "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
+--- 2086,2092 ----
+    ac_save_LIBS="$LIBS"
+  LIBS="-lpthread  $LIBS"
+  cat > conftest.$ac_ext <<EOF
+! #line 2090 "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
+***************
+*** 2091,2097 ****
+  pthread_create()
+  ; return 0; }
+  EOF
+! if { (eval echo configure:2095: \"$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
+--- 2097,2103 ----
+  pthread_create()
+  ; return 0; }
+  EOF
+! if { (eval echo configure:2101: \"$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
+***************
+*** 2117,2123 ****
+  else
+    echo "$ac_t""no" 1>&6
+  echo $ac_n "checking for __pthread_create in -lpthread""... $ac_c" 1>&6
+! echo "configure:2121: 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
+--- 2123,2129 ----
+  else
+    echo "$ac_t""no" 1>&6
+  echo $ac_n "checking for __pthread_create in -lpthread""... $ac_c" 1>&6
+! echo "configure:2127: 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
+***************
+*** 2125,2131 ****
+    ac_save_LIBS="$LIBS"
+  LIBS="-lpthread  $LIBS"
+  cat > conftest.$ac_ext <<EOF
+! #line 2129 "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
+--- 2131,2137 ----
+    ac_save_LIBS="$LIBS"
+  LIBS="-lpthread  $LIBS"
+  cat > conftest.$ac_ext <<EOF
+! #line 2135 "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
+***************
+*** 2136,2142 ****
+  __pthread_create()
+  ; return 0; }
+  EOF
+! if { (eval echo configure:2140: \"$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
+--- 2142,2148 ----
+  __pthread_create()
+  ; return 0; }
+  EOF
+! if { (eval echo configure:2146: \"$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
+***************
+*** 2162,2168 ****
+  else
+    echo "$ac_t""no" 1>&6
+  echo $ac_n "checking for __pthread_create_system in -lpthread""... $ac_c" 1>&6
+! echo "configure:2166: 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
+--- 2168,2174 ----
+  else
+    echo "$ac_t""no" 1>&6
+  echo $ac_n "checking for __pthread_create_system in -lpthread""... $ac_c" 1>&6
+! echo "configure:2172: 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
+***************
+*** 2170,2176 ****
+    ac_save_LIBS="$LIBS"
+  LIBS="-lpthread  $LIBS"
+  cat > conftest.$ac_ext <<EOF
+! #line 2174 "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
+--- 2176,2182 ----
+    ac_save_LIBS="$LIBS"
+  LIBS="-lpthread  $LIBS"
+  cat > conftest.$ac_ext <<EOF
+! #line 2180 "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
+***************
+*** 2181,2187 ****
+  __pthread_create_system()
+  ; return 0; }
+  EOF
+! if { (eval echo configure:2185: \"$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
+--- 2187,2193 ----
+  __pthread_create_system()
+  ; return 0; }
+  EOF
+! if { (eval echo configure:2191: \"$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
+***************
+*** 2207,2213 ****
+  else
+    echo "$ac_t""no" 1>&6
+  echo $ac_n "checking for pthread_create in -lc_r""... $ac_c" 1>&6
+! echo "configure:2211: 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
+--- 2213,2219 ----
+  else
+    echo "$ac_t""no" 1>&6
+  echo $ac_n "checking for pthread_create in -lc_r""... $ac_c" 1>&6
+! echo "configure:2217: 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
+***************
+*** 2215,2221 ****
+    ac_save_LIBS="$LIBS"
+  LIBS="-lc_r  $LIBS"
+  cat > conftest.$ac_ext <<EOF
+! #line 2219 "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
+--- 2221,2227 ----
+    ac_save_LIBS="$LIBS"
+  LIBS="-lc_r  $LIBS"
+  cat > conftest.$ac_ext <<EOF
+! #line 2225 "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
+***************
+*** 2226,2232 ****
+  pthread_create()
+  ; return 0; }
+  EOF
+! if { (eval echo configure:2230: \"$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
+--- 2232,2238 ----
+  pthread_create()
+  ; return 0; }
+  EOF
+! if { (eval echo configure:2236: \"$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
+***************
+*** 2252,2258 ****
+  else
+    echo "$ac_t""no" 1>&6
+  echo $ac_n "checking for pthread_create in -lc""... $ac_c" 1>&6
+! echo "configure:2256: 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
+--- 2258,2264 ----
+  else
+    echo "$ac_t""no" 1>&6
+  echo $ac_n "checking for pthread_create in -lc""... $ac_c" 1>&6
+! echo "configure:2262: 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
+***************
+*** 2260,2266 ****
+    ac_save_LIBS="$LIBS"
+  LIBS="-lc  $LIBS"
+  cat > conftest.$ac_ext <<EOF
+! #line 2264 "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
+--- 2266,2272 ----
+    ac_save_LIBS="$LIBS"
+  LIBS="-lc  $LIBS"
+  cat > conftest.$ac_ext <<EOF
+! #line 2270 "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
+***************
+*** 2271,2277 ****
+  pthread_create()
+  ; return 0; }
+  EOF
+! if { (eval echo configure:2275: \"$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
+--- 2277,2283 ----
+  pthread_create()
+  ; return 0; }
+  EOF
+! if { (eval echo configure:2281: \"$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
+***************
+*** 2317,2323 ****
+       # We'd like to use sigwait() too
+       #
+       echo $ac_n "checking for sigwait in -lc""... $ac_c" 1>&6
+! echo "configure:2321: 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
+--- 2323,2329 ----
+       # We'd like to use sigwait() too
+       #
+       echo $ac_n "checking for sigwait in -lc""... $ac_c" 1>&6
+! echo "configure:2327: 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
+***************
+*** 2325,2331 ****
+    ac_save_LIBS="$LIBS"
+  LIBS="-lc  $LIBS"
+  cat > conftest.$ac_ext <<EOF
+! #line 2329 "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
+--- 2331,2337 ----
+    ac_save_LIBS="$LIBS"
+  LIBS="-lc  $LIBS"
+  cat > conftest.$ac_ext <<EOF
+! #line 2335 "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
+***************
+*** 2336,2342 ****
+  sigwait()
+  ; return 0; }
+  EOF
+! if { (eval echo configure:2340: \"$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
+--- 2342,2348 ----
+  sigwait()
+  ; return 0; }
+  EOF
+! if { (eval echo configure:2346: \"$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
+***************
+*** 2358,2364 ****
+  else
+    echo "$ac_t""no" 1>&6
+  echo $ac_n "checking for sigwait in -lpthread""... $ac_c" 1>&6
+! echo "configure:2362: 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
+--- 2364,2370 ----
+  else
+    echo "$ac_t""no" 1>&6
+  echo $ac_n "checking for sigwait in -lpthread""... $ac_c" 1>&6
+! echo "configure:2368: 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
+***************
+*** 2366,2372 ****
+    ac_save_LIBS="$LIBS"
+  LIBS="-lpthread  $LIBS"
+  cat > conftest.$ac_ext <<EOF
+! #line 2370 "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
+--- 2372,2378 ----
+    ac_save_LIBS="$LIBS"
+  LIBS="-lpthread  $LIBS"
+  cat > conftest.$ac_ext <<EOF
+! #line 2376 "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
+***************
+*** 2377,2383 ****
+  sigwait()
+  ; return 0; }
+  EOF
+! if { (eval echo configure:2381: \"$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
+--- 2383,2389 ----
+  sigwait()
+  ; return 0; }
+  EOF
+! if { (eval echo configure:2387: \"$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
+***************
+*** 2399,2405 ****
+  else
+    echo "$ac_t""no" 1>&6
+  echo $ac_n "checking for _Psigwait in -lpthread""... $ac_c" 1>&6
+! echo "configure:2403: 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
+--- 2405,2411 ----
+  else
+    echo "$ac_t""no" 1>&6
+  echo $ac_n "checking for _Psigwait in -lpthread""... $ac_c" 1>&6
+! echo "configure:2409: 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
+***************
+*** 2407,2413 ****
+    ac_save_LIBS="$LIBS"
+  LIBS="-lpthread  $LIBS"
+  cat > conftest.$ac_ext <<EOF
+! #line 2411 "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
+--- 2413,2419 ----
+    ac_save_LIBS="$LIBS"
+  LIBS="-lpthread  $LIBS"
+  cat > conftest.$ac_ext <<EOF
+! #line 2417 "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
+***************
+*** 2418,2424 ****
+  _Psigwait()
+  ; return 0; }
+  EOF
+! if { (eval echo configure:2422: \"$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
+--- 2424,2430 ----
+  _Psigwait()
+  ; return 0; }
+  EOF
+! if { (eval echo configure:2428: \"$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
+***************
+*** 2448,2459 ****
+  
+  
+       echo $ac_n "checking for pthread_attr_getstacksize""... $ac_c" 1>&6
+! echo "configure:2452: 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 2457 "configure"
+  #include "confdefs.h"
+  /* System header to define __stub macros and hopefully few prototypes,
+      which can conflict with char pthread_attr_getstacksize(); below.  */
+--- 2454,2465 ----
+  
+  
+       echo $ac_n "checking for pthread_attr_getstacksize""... $ac_c" 1>&6
+! echo "configure:2458: 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 2463 "configure"
+  #include "confdefs.h"
+  /* System header to define __stub macros and hopefully few prototypes,
+      which can conflict with char pthread_attr_getstacksize(); below.  */
+***************
+*** 2476,2482 ****
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:2480: \"$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
+--- 2482,2488 ----
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:2486: \"$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
+***************
+*** 2508,2514 ****
+               #
+               *-freebsd*)
+                       echo $ac_n "checking for sigwait in -lc_r""... $ac_c" 1>&6
+! echo "configure:2512: 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
+--- 2514,2520 ----
+               #
+               *-freebsd*)
+                       echo $ac_n "checking for sigwait in -lc_r""... $ac_c" 1>&6
+! echo "configure:2518: 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
+***************
+*** 2516,2522 ****
+    ac_save_LIBS="$LIBS"
+  LIBS="-lc_r  $LIBS"
+  cat > conftest.$ac_ext <<EOF
+! #line 2520 "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
+--- 2522,2528 ----
+    ac_save_LIBS="$LIBS"
+  LIBS="-lc_r  $LIBS"
+  cat > conftest.$ac_ext <<EOF
+! #line 2526 "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
+***************
+*** 2527,2533 ****
+  sigwait()
+  ; return 0; }
+  EOF
+! if { (eval echo configure:2531: \"$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
+--- 2533,2539 ----
+  sigwait()
+  ; return 0; }
+  EOF
+! if { (eval echo configure:2537: \"$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
+***************
+*** 2582,2593 ****
+  EOF
+  
+                       echo $ac_n "checking for pthread_setconcurrency""... $ac_c" 1>&6
+! echo "configure:2586: 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 2591 "configure"
+  #include "confdefs.h"
+  /* System header to define __stub macros and hopefully few prototypes,
+      which can conflict with char pthread_setconcurrency(); below.  */
+--- 2588,2599 ----
+  EOF
+  
+                       echo $ac_n "checking for pthread_setconcurrency""... $ac_c" 1>&6
+! echo "configure:2592: 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 2597 "configure"
+  #include "confdefs.h"
+  /* System header to define __stub macros and hopefully few prototypes,
+      which can conflict with char pthread_setconcurrency(); below.  */
+***************
+*** 2610,2616 ****
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:2614: \"$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
+--- 2616,2622 ----
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:2620: \"$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
+***************
+*** 2648,2659 ****
+       # Look for sysconf to allow detection of the number of processors.
+       #
+       echo $ac_n "checking for sysconf""... $ac_c" 1>&6
+! echo "configure:2652: 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 2657 "configure"
+  #include "confdefs.h"
+  /* System header to define __stub macros and hopefully few prototypes,
+      which can conflict with char sysconf(); below.  */
+--- 2654,2665 ----
+       # Look for sysconf to allow detection of the number of processors.
+       #
+       echo $ac_n "checking for sysconf""... $ac_c" 1>&6
+! echo "configure:2658: 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 2663 "configure"
+  #include "confdefs.h"
+  /* System header to define __stub macros and hopefully few prototypes,
+      which can conflict with char sysconf(); below.  */
+***************
+*** 2676,2682 ****
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:2680: \"$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
+--- 2682,2688 ----
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:2686: \"$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
+***************
+*** 2753,2764 ****
+  # even if compiled with --disable-threads.
+  #
+  echo $ac_n "checking for flockfile""... $ac_c" 1>&6
+! echo "configure:2757: 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 2762 "configure"
+  #include "confdefs.h"
+  /* System header to define __stub macros and hopefully few prototypes,
+      which can conflict with char flockfile(); below.  */
+--- 2759,2770 ----
+  # even if compiled with --disable-threads.
+  #
+  echo $ac_n "checking for flockfile""... $ac_c" 1>&6
+! echo "configure:2763: 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 2768 "configure"
+  #include "confdefs.h"
+  /* System header to define __stub macros and hopefully few prototypes,
+      which can conflict with char flockfile(); below.  */
+***************
+*** 2781,2787 ****
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:2785: \"$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
+--- 2787,2793 ----
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:2791: \"$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
+***************
+*** 2808,2814 ****
+  # Indicate what the final decision was regarding threads.
+  #
+  echo $ac_n "checking whether to build with threads""... $ac_c" 1>&6
+! echo "configure:2812: checking whether to build with threads" >&5
+  if $use_threads; then
+       echo "$ac_t""yes" 1>&6
+  else
+--- 2814,2820 ----
+  # Indicate what the final decision was regarding threads.
+  #
+  echo $ac_n "checking whether to build with threads""... $ac_c" 1>&6
+! echo "configure:2818: checking whether to build with threads" >&5
+  if $use_threads; then
+       echo "$ac_t""yes" 1>&6
+  else
+***************
+*** 2884,2895 ****
+  # NLS
+  #
+  echo $ac_n "checking for catgets""... $ac_c" 1>&6
+! echo "configure:2888: 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 2893 "configure"
+  #include "confdefs.h"
+  /* System header to define __stub macros and hopefully few prototypes,
+      which can conflict with char catgets(); below.  */
+--- 2890,2901 ----
+  # NLS
+  #
+  echo $ac_n "checking for catgets""... $ac_c" 1>&6
+! echo "configure:2894: 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 2899 "configure"
+  #include "confdefs.h"
+  /* System header to define __stub macros and hopefully few prototypes,
+      which can conflict with char catgets(); below.  */
+***************
+*** 2912,2918 ****
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:2916: \"$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
+--- 2918,2924 ----
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:2922: \"$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
+***************
+*** 2950,2956 ****
+               ;;
+       *)
+               echo $ac_n "checking for socket in -lsocket""... $ac_c" 1>&6
+! echo "configure:2954: 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
+--- 2956,2962 ----
+               ;;
+       *)
+               echo $ac_n "checking for socket in -lsocket""... $ac_c" 1>&6
+! echo "configure:2960: 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
+***************
+*** 2958,2964 ****
+    ac_save_LIBS="$LIBS"
+  LIBS="-lsocket  $LIBS"
+  cat > conftest.$ac_ext <<EOF
+! #line 2962 "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
+--- 2964,2970 ----
+    ac_save_LIBS="$LIBS"
+  LIBS="-lsocket  $LIBS"
+  cat > conftest.$ac_ext <<EOF
+! #line 2968 "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
+***************
+*** 2969,2975 ****
+  socket()
+  ; return 0; }
+  EOF
+! if { (eval echo configure:2973: \"$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
+--- 2975,2981 ----
+  socket()
+  ; return 0; }
+  EOF
+! if { (eval echo configure:2979: \"$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
+***************
+*** 2997,3003 ****
+  fi
+  
+               echo $ac_n "checking for inet_ntoa in -lnsl""... $ac_c" 1>&6
+! echo "configure:3001: 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
+--- 3003,3009 ----
+  fi
+  
+               echo $ac_n "checking for inet_ntoa in -lnsl""... $ac_c" 1>&6
+! echo "configure:3007: 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
+***************
+*** 3005,3011 ****
+    ac_save_LIBS="$LIBS"
+  LIBS="-lnsl  $LIBS"
+  cat > conftest.$ac_ext <<EOF
+! #line 3009 "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
+--- 3011,3017 ----
+    ac_save_LIBS="$LIBS"
+  LIBS="-lnsl  $LIBS"
+  cat > conftest.$ac_ext <<EOF
+! #line 3015 "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
+***************
+*** 3016,3022 ****
+  inet_ntoa()
+  ; return 0; }
+  EOF
+! if { (eval echo configure:3020: \"$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
+--- 3022,3028 ----
+  inet_ntoa()
+  ; return 0; }
+  EOF
+! if { (eval echo configure:3026: \"$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
+***************
+*** 3131,3137 ****
+  fi
+  
+  echo $ac_n "checking build system type""... $ac_c" 1>&6
+! echo "configure:3135: checking build system type" >&5
+  
+  build_alias=$build
+  case "$build_alias" in
+--- 3137,3143 ----
+  fi
+  
+  echo $ac_n "checking build system type""... $ac_c" 1>&6
+! echo "configure:3141: checking build system type" >&5
+  
+  build_alias=$build
+  case "$build_alias" in
+***************
+*** 3160,3166 ****
+  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:3164: checking for ld used by GCC" >&5
+    ac_prog=`($CC -print-prog-name=ld) 2>&5`
+    case "$ac_prog" in
+      # Accept absolute paths.
+--- 3166,3172 ----
+  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:3170: checking for ld used by GCC" >&5
+    ac_prog=`($CC -print-prog-name=ld) 2>&5`
+    case "$ac_prog" in
+      # Accept absolute paths.
+***************
+*** 3184,3193 ****
+    esac
+  elif test "$with_gnu_ld" = yes; then
+    echo $ac_n "checking for GNU ld""... $ac_c" 1>&6
+! echo "configure:3188: checking for GNU ld" >&5
+  else
+    echo $ac_n "checking for non-GNU ld""... $ac_c" 1>&6
+! echo "configure:3191: 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
+--- 3190,3199 ----
+    esac
+  elif test "$with_gnu_ld" = yes; then
+    echo $ac_n "checking for GNU ld""... $ac_c" 1>&6
+! echo "configure:3194: checking for GNU ld" >&5
+  else
+    echo $ac_n "checking for non-GNU ld""... $ac_c" 1>&6
+! echo "configure:3197: 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
+***************
+*** 3222,3228 ****
+  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:3226: 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
+--- 3228,3234 ----
+  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:3232: 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
+***************
+*** 3238,3244 ****
+  
+  
+  echo $ac_n "checking for BSD-compatible nm""... $ac_c" 1>&6
+! echo "configure:3242: 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
+--- 3244,3250 ----
+  
+  
+  echo $ac_n "checking for BSD-compatible nm""... $ac_c" 1>&6
+! echo "configure:3248: 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
+***************
+*** 3274,3280 ****
+  echo "$ac_t""$NM" 1>&6
+  
+  echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6
+! echo "configure:3278: 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
+--- 3280,3286 ----
+  echo "$ac_t""$NM" 1>&6
+  
+  echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6
+! echo "configure:3284: 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
+***************
+*** 3323,3330 ****
+  case "$lt_target" in
+  *-*-irix6*)
+    # Find out which ABI we are using.
+!   echo '#line 3327 "configure"' > conftest.$ac_ext
+!   if { (eval echo configure:3328: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+      case "`/usr/bin/file conftest.o`" in
+      *32-bit*)
+        LD="${LD-ld} -32"
+--- 3329,3336 ----
+  case "$lt_target" in
+  *-*-irix6*)
+    # Find out which ABI we are using.
+!   echo '#line 3333 "configure"' > conftest.$ac_ext
+!   if { (eval echo configure:3334: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+      case "`/usr/bin/file conftest.o`" in
+      *32-bit*)
+        LD="${LD-ld} -32"
+***************
+*** 3345,3363 ****
+    SAVE_CFLAGS="$CFLAGS"
+    CFLAGS="$CFLAGS -belf"
+    echo $ac_n "checking whether the C compiler needs -belf""... $ac_c" 1>&6
+! echo "configure:3349: 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 3354 "configure"
+  #include "confdefs.h"
+  
+  int main() {
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:3361: \"$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
+--- 3351,3369 ----
+    SAVE_CFLAGS="$CFLAGS"
+    CFLAGS="$CFLAGS -belf"
+    echo $ac_n "checking whether the C compiler needs -belf""... $ac_c" 1>&6
+! echo "configure:3355: 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 3360 "configure"
+  #include "confdefs.h"
+  
+  int main() {
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:3367: \"$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
+***************
+*** 3508,3516 ****
+  # the right suffix on the files.
+  #
+  echo $ac_n "checking for IPv6 structures""... $ac_c" 1>&6
+! echo "configure:3512: checking for IPv6 structures" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 3514 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/types.h>
+--- 3514,3522 ----
+  # the right suffix on the files.
+  #
+  echo $ac_n "checking for IPv6 structures""... $ac_c" 1>&6
+! echo "configure:3518: checking for IPv6 structures" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 3520 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/types.h>
+***************
+*** 3520,3526 ****
+  struct sockaddr_in6 sin6; return (0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:3524: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    echo "$ac_t""yes" 1>&6
+        found_ipv6=yes
+--- 3526,3532 ----
+  struct sockaddr_in6 sin6; return (0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:3530: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    echo "$ac_t""yes" 1>&6
+        found_ipv6=yes
+***************
+*** 3538,3544 ****
+  # 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:3542: 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"
+--- 3544,3550 ----
+  # 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:3548: 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"
+***************
+*** 3628,3636 ****
+               LWRES_PLATFORM_HAVEIPV6="#define LWRES_PLATFORM_HAVEIPV6 1"
+  
+               echo $ac_n "checking for in6_addr""... $ac_c" 1>&6
+! echo "configure:3632: checking for in6_addr" >&5
+               cat > conftest.$ac_ext <<EOF
+! #line 3634 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/types.h>
+--- 3634,3642 ----
+               LWRES_PLATFORM_HAVEIPV6="#define LWRES_PLATFORM_HAVEIPV6 1"
+  
+               echo $ac_n "checking for in6_addr""... $ac_c" 1>&6
+! echo "configure:3638: checking for in6_addr" >&5
+               cat > conftest.$ac_ext <<EOF
+! #line 3640 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/types.h>
+***************
+*** 3643,3649 ****
+  struct in6_addr in6; return (0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:3647: \"$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"
+--- 3649,3655 ----
+  struct in6_addr in6; return (0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:3653: \"$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"
+***************
+*** 3661,3669 ****
+  rm -f conftest*
+  
+               echo $ac_n "checking for in6addr_any""... $ac_c" 1>&6
+! echo "configure:3665: checking for in6addr_any" >&5
+               cat > conftest.$ac_ext <<EOF
+! #line 3667 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/types.h>
+--- 3667,3675 ----
+  rm -f conftest*
+  
+               echo $ac_n "checking for in6addr_any""... $ac_c" 1>&6
+! echo "configure:3671: checking for in6addr_any" >&5
+               cat > conftest.$ac_ext <<EOF
+! #line 3673 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/types.h>
+***************
+*** 3677,3683 ****
+  struct in6_addr in6; in6 = in6addr_any; return (0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:3681: \"$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"
+--- 3683,3689 ----
+  struct in6_addr in6; in6 = in6addr_any; return (0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:3687: \"$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"
+***************
+*** 3693,3701 ****
+  rm -f conftest*
+  
+               echo $ac_n "checking for sin6_scope_id in struct sockaddr_in6""... $ac_c" 1>&6
+! echo "configure:3697: checking for sin6_scope_id in struct sockaddr_in6" >&5
+               cat > conftest.$ac_ext <<EOF
+! #line 3699 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/types.h>
+--- 3699,3707 ----
+  rm -f conftest*
+  
+               echo $ac_n "checking for sin6_scope_id in struct sockaddr_in6""... $ac_c" 1>&6
+! echo "configure:3703: checking for sin6_scope_id in struct sockaddr_in6" >&5
+               cat > conftest.$ac_ext <<EOF
+! #line 3705 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/types.h>
+***************
+*** 3708,3714 ****
+  struct sockaddr_in6 xyzzy; xyzzy.sin6_scope_id = 0; return (0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:3712: \"$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"
+--- 3714,3720 ----
+  struct sockaddr_in6 xyzzy; xyzzy.sin6_scope_id = 0; return (0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:3718: \"$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"
+***************
+*** 3723,3731 ****
+               LWRES_HAVE_SIN6_SCOPE_ID="$result"
+  
+               echo $ac_n "checking for in6_pktinfo""... $ac_c" 1>&6
+! echo "configure:3727: checking for in6_pktinfo" >&5
+               cat > conftest.$ac_ext <<EOF
+! #line 3729 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/types.h>
+--- 3729,3737 ----
+               LWRES_HAVE_SIN6_SCOPE_ID="$result"
+  
+               echo $ac_n "checking for in6_pktinfo""... $ac_c" 1>&6
+! echo "configure:3733: checking for in6_pktinfo" >&5
+               cat > conftest.$ac_ext <<EOF
+! #line 3735 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/types.h>
+***************
+*** 3738,3744 ****
+  struct in6_pktinfo xyzzy; return (0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:3742: \"$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"
+--- 3744,3750 ----
+  struct in6_pktinfo xyzzy; return (0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:3748: \"$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"
+***************
+*** 3790,3798 ****
+  # which provides some (all?) of the desired functions.
+  #
+  echo $ac_n "checking for inet_ntop""... $ac_c" 1>&6
+! echo "configure:3794: checking for inet_ntop" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 3796 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/types.h>
+--- 3796,3804 ----
+  # which provides some (all?) of the desired functions.
+  #
+  echo $ac_n "checking for inet_ntop""... $ac_c" 1>&6
+! echo "configure:3800: checking for inet_ntop" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 3802 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/types.h>
+***************
+*** 3802,3808 ****
+  inet_ntop(0, 0, 0, 0); return (0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:3806: \"$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"
+--- 3808,3814 ----
+  inet_ntop(0, 0, 0, 0); return (0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:3812: \"$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"
+***************
+*** 3817,3825 ****
+  fi
+  rm -f conftest*
+  echo $ac_n "checking for inet_pton""... $ac_c" 1>&6
+! echo "configure:3821: checking for inet_pton" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 3823 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/types.h>
+--- 3823,3831 ----
+  fi
+  rm -f conftest*
+  echo $ac_n "checking for inet_pton""... $ac_c" 1>&6
+! echo "configure:3827: checking for inet_pton" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 3829 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/types.h>
+***************
+*** 3829,3835 ****
+  inet_pton(0, 0, 0); return (0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:3833: \"$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_NEEDPTON="#undef ISC_PLATFORM_NEEDPTON"
+--- 3835,3841 ----
+  inet_pton(0, 0, 0); return (0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:3839: \"$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_NEEDPTON="#undef ISC_PLATFORM_NEEDPTON"
+***************
+*** 3844,3852 ****
+  fi
+  rm -f conftest*
+  echo $ac_n "checking for inet_aton""... $ac_c" 1>&6
+! echo "configure:3848: checking for inet_aton" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 3850 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/types.h>
+--- 3850,3858 ----
+  fi
+  rm -f conftest*
+  echo $ac_n "checking for inet_aton""... $ac_c" 1>&6
+! echo "configure:3854: checking for inet_aton" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 3856 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/types.h>
+***************
+*** 3856,3862 ****
+  struct in_addr in; inet_aton(0, &in); return (0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:3860: \"$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"
+--- 3862,3868 ----
+  struct in_addr in; inet_aton(0, &in); return (0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:3866: \"$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"
+***************
+*** 3889,3897 ****
+  esac
+  
+  echo $ac_n "checking for sa_len in struct sockaddr""... $ac_c" 1>&6
+! echo "configure:3893: checking for sa_len in struct sockaddr" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 3895 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/types.h>
+--- 3895,3903 ----
+  esac
+  
+  echo $ac_n "checking for sa_len in struct sockaddr""... $ac_c" 1>&6
+! echo "configure:3899: checking for sa_len in struct sockaddr" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 3901 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/types.h>
+***************
+*** 3900,3906 ****
+  struct sockaddr sa; sa.sa_len = 0; return (0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:3904: \"$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"
+--- 3906,3912 ----
+  struct sockaddr sa; sa.sa_len = 0; return (0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:3910: \"$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"
+***************
+*** 3921,3929 ****
+  # Look for a 4.4BSD or 4.3BSD struct msghdr
+  #
+  echo $ac_n "checking for struct msghdr flavor""... $ac_c" 1>&6
+! echo "configure:3925: checking for struct msghdr flavor" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 3927 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/types.h>
+--- 3927,3935 ----
+  # Look for a 4.4BSD or 4.3BSD struct msghdr
+  #
+  echo $ac_n "checking for struct msghdr flavor""... $ac_c" 1>&6
+! echo "configure:3931: checking for struct msghdr flavor" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 3933 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/types.h>
+***************
+*** 3932,3938 ****
+  struct msghdr msg; msg.msg_flags = 0; return (0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:3936: \"$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"
+--- 3938,3944 ----
+  struct msghdr msg; msg.msg_flags = 0; return (0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:3942: \"$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"
+***************
+*** 3950,3958 ****
+  # Look for in_port_t.
+  #
+  echo $ac_n "checking for type in_port_t""... $ac_c" 1>&6
+! echo "configure:3954: checking for type in_port_t" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 3956 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/types.h>
+--- 3956,3964 ----
+  # Look for in_port_t.
+  #
+  echo $ac_n "checking for type in_port_t""... $ac_c" 1>&6
+! echo "configure:3960: checking for type in_port_t" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 3962 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/types.h>
+***************
+*** 3961,3967 ****
+  in_port_t port = 25; return (0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:3965: \"$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"
+--- 3967,3973 ----
+  in_port_t port = 25; return (0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:3971: \"$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"
+***************
+*** 3979,3987 ****
+  # Check for addrinfo
+  #
+  echo $ac_n "checking for struct addrinfo""... $ac_c" 1>&6
+! echo "configure:3983: checking for struct addrinfo" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 3985 "configure"
+  #include "confdefs.h"
+  
+  #include <netdb.h>
+--- 3985,3993 ----
+  # Check for addrinfo
+  #
+  echo $ac_n "checking for struct addrinfo""... $ac_c" 1>&6
+! echo "configure:3989: checking for struct addrinfo" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 3991 "configure"
+  #include "confdefs.h"
+  
+  #include <netdb.h>
+***************
+*** 3989,3995 ****
+  struct addrinfo a; return (0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:3993: \"$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"
+--- 3995,4001 ----
+  struct addrinfo a; return (0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:3999: \"$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"
+***************
+*** 4008,4016 ****
+  
+  
+  echo $ac_n "checking for int sethostent""... $ac_c" 1>&6
+! echo "configure:4012: checking for int sethostent" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 4014 "configure"
+  #include "confdefs.h"
+  
+  #include <netdb.h>
+--- 4014,4022 ----
+  
+  
+  echo $ac_n "checking for int sethostent""... $ac_c" 1>&6
+! echo "configure:4018: checking for int sethostent" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 4020 "configure"
+  #include "confdefs.h"
+  
+  #include <netdb.h>
+***************
+*** 4018,4024 ****
+  int i = sethostent(0); return(0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:4022: \"$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"
+--- 4024,4030 ----
+  int i = sethostent(0); return(0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:4028: \"$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"
+***************
+*** 4033,4041 ****
+  
+  
+  echo $ac_n "checking for int endhostent""... $ac_c" 1>&6
+! echo "configure:4037: checking for int endhostent" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 4039 "configure"
+  #include "confdefs.h"
+  
+  #include <netdb.h>
+--- 4039,4047 ----
+  
+  
+  echo $ac_n "checking for int endhostent""... $ac_c" 1>&6
+! echo "configure:4043: checking for int endhostent" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 4045 "configure"
+  #include "confdefs.h"
+  
+  #include <netdb.h>
+***************
+*** 4043,4049 ****
+  int i = endhostent(); return(0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:4047: \"$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"
+--- 4049,4055 ----
+  int i = endhostent(); return(0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:4053: \"$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"
+***************
+*** 4058,4066 ****
+  
+  
+  echo $ac_n "checking for getnetbyaddr(in_addr_t, ...)""... $ac_c" 1>&6
+! echo "configure:4062: checking for getnetbyaddr(in_addr_t, ...)" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 4064 "configure"
+  #include "confdefs.h"
+  
+  #include <netdb.h>
+--- 4064,4072 ----
+  
+  
+  echo $ac_n "checking for getnetbyaddr(in_addr_t, ...)""... $ac_c" 1>&6
+! echo "configure:4068: checking for getnetbyaddr(in_addr_t, ...)" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 4070 "configure"
+  #include "confdefs.h"
+  
+  #include <netdb.h>
+***************
+*** 4069,4075 ****
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:4073: \"$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"
+--- 4075,4081 ----
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:4079: \"$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"
+***************
+*** 4084,4092 ****
+  
+  
+  echo $ac_n "checking for int setnetent""... $ac_c" 1>&6
+! echo "configure:4088: checking for int setnetent" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 4090 "configure"
+  #include "confdefs.h"
+  
+  #include <netdb.h>
+--- 4090,4098 ----
+  
+  
+  echo $ac_n "checking for int setnetent""... $ac_c" 1>&6
+! echo "configure:4094: checking for int setnetent" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 4096 "configure"
+  #include "confdefs.h"
+  
+  #include <netdb.h>
+***************
+*** 4094,4100 ****
+  int i = setnetent(0); return(0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:4098: \"$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"
+--- 4100,4106 ----
+  int i = setnetent(0); return(0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:4104: \"$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"
+***************
+*** 4109,4117 ****
+  
+  
+  echo $ac_n "checking for int endnetent""... $ac_c" 1>&6
+! echo "configure:4113: checking for int endnetent" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 4115 "configure"
+  #include "confdefs.h"
+  
+  #include <netdb.h>
+--- 4115,4123 ----
+  
+  
+  echo $ac_n "checking for int endnetent""... $ac_c" 1>&6
+! echo "configure:4119: checking for int endnetent" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 4121 "configure"
+  #include "confdefs.h"
+  
+  #include <netdb.h>
+***************
+*** 4119,4125 ****
+  int i = endnetent(); return(0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:4123: \"$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"
+--- 4125,4131 ----
+  int i = endnetent(); return(0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:4129: \"$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"
+***************
+*** 4134,4142 ****
+  
+  
+  echo $ac_n "checking for gethostbyaddr(const void *, size_t, ...)""... $ac_c" 1>&6
+! echo "configure:4138: checking for gethostbyaddr(const void *, size_t, ...)" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 4140 "configure"
+  #include "confdefs.h"
+  
+  #include <netdb.h>
+--- 4140,4148 ----
+  
+  
+  echo $ac_n "checking for gethostbyaddr(const void *, size_t, ...)""... $ac_c" 1>&6
+! echo "configure:4144: checking for gethostbyaddr(const void *, size_t, ...)" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 4146 "configure"
+  #include "confdefs.h"
+  
+  #include <netdb.h>
+***************
+*** 4145,4151 ****
+  return(0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:4149: \"$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"
+--- 4151,4157 ----
+  return(0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:4155: \"$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"
+***************
+*** 4160,4168 ****
+  
+  
+  echo $ac_n "checking for h_errno in netdb.h""... $ac_c" 1>&6
+! echo "configure:4164: checking for h_errno in netdb.h" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 4166 "configure"
+  #include "confdefs.h"
+  
+  #include <netdb.h>
+--- 4166,4174 ----
+  
+  
+  echo $ac_n "checking for h_errno in netdb.h""... $ac_c" 1>&6
+! echo "configure:4170: checking for h_errno in netdb.h" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 4172 "configure"
+  #include "confdefs.h"
+  
+  #include <netdb.h>
+***************
+*** 4170,4176 ****
+  h_errno = 1; return(0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:4174: \"$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"
+--- 4176,4182 ----
+  h_errno = 1; return(0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:4180: \"$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"
+***************
+*** 4185,4196 ****
+  
+  
+  echo $ac_n "checking for getipnodebyname""... $ac_c" 1>&6
+! echo "configure:4189: 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 4194 "configure"
+  #include "confdefs.h"
+  /* System header to define __stub macros and hopefully few prototypes,
+      which can conflict with char getipnodebyname(); below.  */
+--- 4191,4202 ----
+  
+  
+  echo $ac_n "checking for getipnodebyname""... $ac_c" 1>&6
+! echo "configure:4195: 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 4200 "configure"
+  #include "confdefs.h"
+  /* System header to define __stub macros and hopefully few prototypes,
+      which can conflict with char getipnodebyname(); below.  */
+***************
+*** 4213,4219 ****
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:4217: \"$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
+--- 4219,4225 ----
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:4223: \"$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
+***************
+*** 4234,4245 ****
+  fi
+  
+  echo $ac_n "checking for getnameinfo""... $ac_c" 1>&6
+! echo "configure:4238: 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 4243 "configure"
+  #include "confdefs.h"
+  /* System header to define __stub macros and hopefully few prototypes,
+      which can conflict with char getnameinfo(); below.  */
+--- 4240,4251 ----
+  fi
+  
+  echo $ac_n "checking for getnameinfo""... $ac_c" 1>&6
+! echo "configure:4244: 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 4249 "configure"
+  #include "confdefs.h"
+  /* System header to define __stub macros and hopefully few prototypes,
+      which can conflict with char getnameinfo(); below.  */
+***************
+*** 4262,4268 ****
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:4266: \"$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
+--- 4268,4274 ----
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:4272: \"$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
+***************
+*** 4283,4294 ****
+  fi
+  
+  echo $ac_n "checking for getaddrinfo""... $ac_c" 1>&6
+! echo "configure:4287: 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 4292 "configure"
+  #include "confdefs.h"
+  /* System header to define __stub macros and hopefully few prototypes,
+      which can conflict with char getaddrinfo(); below.  */
+--- 4289,4300 ----
+  fi
+  
+  echo $ac_n "checking for getaddrinfo""... $ac_c" 1>&6
+! echo "configure:4293: 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 4298 "configure"
+  #include "confdefs.h"
+  /* System header to define __stub macros and hopefully few prototypes,
+      which can conflict with char getaddrinfo(); below.  */
+***************
+*** 4311,4317 ****
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:4315: \"$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
+--- 4317,4323 ----
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:4321: \"$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
+***************
+*** 4336,4347 ****
+  fi
+  
+  echo $ac_n "checking for gai_strerror""... $ac_c" 1>&6
+! echo "configure:4340: 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 4345 "configure"
+  #include "confdefs.h"
+  /* System header to define __stub macros and hopefully few prototypes,
+      which can conflict with char gai_strerror(); below.  */
+--- 4342,4353 ----
+  fi
+  
+  echo $ac_n "checking for gai_strerror""... $ac_c" 1>&6
+! echo "configure:4346: 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 4351 "configure"
+  #include "confdefs.h"
+  /* System header to define __stub macros and hopefully few prototypes,
+      which can conflict with char gai_strerror(); below.  */
+***************
+*** 4364,4370 ****
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:4368: \"$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
+--- 4370,4376 ----
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:4374: \"$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
+***************
+*** 4394,4402 ****
+  # 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:4398: checking for interface list sysctl" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 4400 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/param.h>
+--- 4400,4408 ----
+  # 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:4404: checking for interface list sysctl" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 4406 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/param.h>
+***************
+*** 4426,4437 ****
+  # Check for some other useful functions that are not ever-present.
+  #
+  echo $ac_n "checking for strsep""... $ac_c" 1>&6
+! echo "configure:4430: checking for strsep" >&5
+  if eval "test \"`echo '$''{'ac_cv_func_strsep'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 4435 "configure"
+  #include "confdefs.h"
+  /* System header to define __stub macros and hopefully few prototypes,
+      which can conflict with char strsep(); below.  */
+--- 4432,4443 ----
+  # Check for some other useful functions that are not ever-present.
+  #
+  echo $ac_n "checking for strsep""... $ac_c" 1>&6
+! echo "configure:4436: checking for strsep" >&5
+  if eval "test \"`echo '$''{'ac_cv_func_strsep'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 4441 "configure"
+  #include "confdefs.h"
+  /* System header to define __stub macros and hopefully few prototypes,
+      which can conflict with char strsep(); below.  */
+***************
+*** 4454,4460 ****
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:4458: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_func_strsep=yes"
+  else
+--- 4460,4466 ----
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:4464: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+    rm -rf conftest*
+    eval "ac_cv_func_strsep=yes"
+  else
+***************
+*** 4475,4486 ****
+  fi
+  
+  echo $ac_n "checking for vsnprintf""... $ac_c" 1>&6
+! echo "configure:4479: 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 4484 "configure"
+  #include "confdefs.h"
+  /* System header to define __stub macros and hopefully few prototypes,
+      which can conflict with char vsnprintf(); below.  */
+--- 4481,4492 ----
+  fi
+  
+  echo $ac_n "checking for vsnprintf""... $ac_c" 1>&6
+! echo "configure:4485: 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 4490 "configure"
+  #include "confdefs.h"
+  /* System header to define __stub macros and hopefully few prototypes,
+      which can conflict with char vsnprintf(); below.  */
+***************
+*** 4503,4509 ****
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:4507: \"$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
+--- 4509,4515 ----
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:4513: \"$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
+***************
+*** 4532,4548 ****
+  
+  
+  echo $ac_n "checking for sizeof(long long int) == sizeof(long int)""... $ac_c" 1>&6
+! echo "configure:4536: checking for sizeof(long long int) == sizeof(long int)" >&5
+  if test "$cross_compiling" = yes; then
+    echo "$ac_t""default yes" 1>&6
+       ISC_PLATFORM_LONGLONGEQUALLONG="#define ISC_PLATFORM_LONGLONGEQUALLONG 1"
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 4542 "configure"
+  #include "confdefs.h"
+  main() { exit(!(sizeof(long long int) == sizeof(long int))); }
+  EOF
+! if { (eval echo configure:4546: \"$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_LONGLONGEQUALLONG="#define ISC_PLATFORM_LONGLONGEQUALLONG 1"
+--- 4538,4554 ----
+  
+  
+  echo $ac_n "checking for sizeof(long long int) == sizeof(long int)""... $ac_c" 1>&6
+! echo "configure:4542: checking for sizeof(long long int) == sizeof(long int)" >&5
+  if test "$cross_compiling" = yes; then
+    echo "$ac_t""default yes" 1>&6
+       ISC_PLATFORM_LONGLONGEQUALLONG="#define ISC_PLATFORM_LONGLONGEQUALLONG 1"
+  else
+    cat > conftest.$ac_ext <<EOF
+! #line 4548 "configure"
+  #include "confdefs.h"
+  main() { exit(!(sizeof(long long int) == sizeof(long int))); }
+  EOF
+! if { (eval echo configure:4552: \"$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_LONGLONGEQUALLONG="#define ISC_PLATFORM_LONGLONGEQUALLONG 1"
+***************
+*** 4562,4573 ****
+  # Security Stuff
+  #
+  echo $ac_n "checking for chroot""... $ac_c" 1>&6
+! echo "configure:4566: 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 4571 "configure"
+  #include "confdefs.h"
+  /* System header to define __stub macros and hopefully few prototypes,
+      which can conflict with char chroot(); below.  */
+--- 4568,4579 ----
+  # Security Stuff
+  #
+  echo $ac_n "checking for chroot""... $ac_c" 1>&6
+! echo "configure:4572: 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 4577 "configure"
+  #include "confdefs.h"
+  /* System header to define __stub macros and hopefully few prototypes,
+      which can conflict with char chroot(); below.  */
+***************
+*** 4590,4596 ****
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:4594: \"$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
+--- 4596,4602 ----
+  
+  ; return 0; }
+  EOF
+! if { (eval echo configure:4600: \"$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
+***************
+*** 4616,4632 ****
+  do
+  ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+  echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+! echo "configure:4620: 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 4625 "configure"
+  #include "confdefs.h"
+  #include <$ac_hdr>
+  EOF
+  ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+! { (eval echo configure:4630: \"$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*
+--- 4622,4638 ----
+  do
+  ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+  echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+! echo "configure:4626: 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 4631 "configure"
+  #include "confdefs.h"
+  #include <$ac_hdr>
+  EOF
+  ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+! { (eval echo configure:4636: \"$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*
+***************
+*** 4656,4672 ****
+  do
+  ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+  echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+! echo "configure:4660: 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 4665 "configure"
+  #include "confdefs.h"
+  #include <$ac_hdr>
+  EOF
+  ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+! { (eval echo configure:4670: \"$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*
+--- 4662,4678 ----
+  do
+  ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+  echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+! echo "configure:4666: 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 4671 "configure"
+  #include "confdefs.h"
+  #include <$ac_hdr>
+  EOF
+  ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+! { (eval echo configure:4676: \"$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*
+***************
+*** 4697,4705 ****
+  # 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:4701: checking for type rlim_t" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 4703 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/types.h>
+--- 4703,4711 ----
+  # 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:4707: checking for type rlim_t" >&5
+  cat > conftest.$ac_ext <<EOF
+! #line 4709 "configure"
+  #include "confdefs.h"
+  
+  #include <sys/types.h>
+***************
+*** 4709,4715 ****
+  rlim_t rl = 19671212; return (0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:4713: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    echo "$ac_t""yes" 1>&6
+           cat >> confdefs.h <<\EOF
+--- 4715,4721 ----
+  rlim_t rl = 19671212; return (0);
+  ; return 0; }
+  EOF
+! if { (eval echo configure:4719: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+    rm -rf conftest*
+    echo "$ac_t""yes" 1>&6
+           cat >> confdefs.h <<\EOF
+***************
+*** 4802,4808 ****
+  # 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:4806: checking for $ac_word" >&5
+  if eval "test \"`echo '$''{'ac_cv_path_JADE'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+--- 4808,4814 ----
+  # 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:4812: checking for $ac_word" >&5
+  if eval "test \"`echo '$''{'ac_cv_path_JADE'+set}'`\" = set"; then
+    echo $ac_n "(cached) $ac_c" 1>&6
+  else
+***************
+*** 4848,4854 ****
+  SGMLDIR=""
+  
+  echo $ac_n "checking for SGML files""... $ac_c" 1>&6
+! echo "configure:4852: checking for SGML files" >&5
+  for d in /usr/pkg/share/sgml /usr/local/share/sgml 
+  do
+       if test -f $d/docbook/dsssl/modular/html/docbook.dsl
+--- 4854,4860 ----
+  SGMLDIR=""
+  
+  echo $ac_n "checking for SGML files""... $ac_c" 1>&6
+! echo "configure:4858: checking for SGML files" >&5
+  for d in /usr/pkg/share/sgml /usr/local/share/sgml 
+  do
+       if test -f $d/docbook/dsssl/modular/html/docbook.dsl
+***************
+*** 4874,4880 ****
+  XGMLDIR=""
+  
+  echo $ac_n "checking for XML files""... $ac_c" 1>&6
+! echo "configure:4878: checking for XML files" >&5
+  for d in /usr/pkg/share/xml /usr/local/share/xml
+  do
+       if test -f $d/dtd/docbook/docbookx.dtd
+--- 4880,4886 ----
+  XGMLDIR=""
+  
+  echo $ac_n "checking for XML files""... $ac_c" 1>&6
+! echo "configure:4884: checking for XML files" >&5
+  for d in /usr/pkg/share/xml /usr/local/share/xml
+  do
+       if test -f $d/dtd/docbook/docbookx.dtd
+***************
+*** 4891,4896 ****
+--- 4897,5061 ----
+       XMLDIR=/usr/local/share/xml
+  fi
+  
++ 
++ 
++ #
++ # MDN support
++ #
++ # Check whether --with-mdn or --without-mdn was given.
++ if test "${with_mdn+set}" = set; then
++   withval="$with_mdn"
++   use_mdn="$withval"
++ else
++   use_mdn="no"
++ fi
++ 
++ case "$use_mdn" in
++ yes)
++      mdn_path=/usr/local
++      ;;
++ no)
++      ;;
++ *)
++      mdn_path="$use_mdn"
++      ;;
++ esac
++ 
++ # Check whether --with-iconv or --without-iconv was given.
++ if test "${with_iconv+set}" = set; then
++   withval="$with_iconv"
++   iconvlib="$withval"
++ else
++   iconvlib="no"
++ fi
++ 
++ case "$iconvlib" in
++ no)
++     iconvlib=
++     ;;
++ yes)
++     iconvlib=-liconv
++     ;;
++ esac
++ 
++ # Check whether --with-mdnlib or --without-mdnlib was given.
++ if test "${with_mdnlib+set}" = set; then
++   withval="$with_mdnlib"
++   mdnlib="$withval"
++ else
++   mdnlib="no"
++ fi
++ 
++ if test "$mdnlib" = yes; then
++      { echo "configure: error: You must specify ARG for --with-mdnlib." 1>&2; exit 1; }
++ fi
++ 
++ if test "$use_mdn" != no; then
++      cat >> confdefs.h <<\EOF
++ #define WITH_MDN 1
++ EOF
++ 
++      STD_CINCLUDES="$STD_CINCLUDES -I$mdn_path/include"
++      if test "$mdnlib" != no; then
++              LIBS="$mdnlib $iconvlib $LIBS"
++      else
++              LIBS="-L$mdn_path/lib -lmdn $iconvlib $LIBS"
++      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:4970: 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 4975 "configure"
++ #include "confdefs.h"
++ #include <$ac_hdr>
++ EOF
++ ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
++ { (eval echo configure:4980: \"$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:5009: 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 5014 "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:5037: \"$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
+  
+  
+  #
+Index: configure.in
+diff -c mdn/othersrc/bind9/configure.in:1.1.1.6 mdn/othersrc/bind9/configure.in:1.8
+*** configure.in       Tue Apr 17 14:17:03 2001
+--- configure.in       Tue Apr 17 17:31:13 2001
+***************
+*** 1239,1244 ****
+--- 1239,1292 ----
+  AC_SUBST(XMLDIR)
+  
+  #
++ # MDN support
++ #
++ AC_ARG_WITH(mdn,
++      [  --with-mdn[=PREFIX]    enable MDN support using mDNkit [default prefix /usr/local]],
++      use_mdn="$withval", use_mdn="no")
++ case "$use_mdn" in
++ yes)
++      mdn_path=/usr/local
++      ;;
++ no)
++      ;;
++ *)
++      mdn_path="$use_mdn"
++      ;;
++ esac
++ 
++ AC_ARG_WITH(iconv,
++      [  --with-iconv[=LIBSPEC]   specify iconv library [default -liconv]],
++      iconvlib="$withval", iconvlib="no")
++ case "$iconvlib" in
++ no)
++     iconvlib=
++     ;;
++ yes)
++     iconvlib=-liconv
++     ;;
++ esac
++ 
++ AC_ARG_WITH(mdnlib,
++      [  --with-mdnlib=ARG    specify libmdn],
++      mdnlib="$withval", mdnlib="no")
++ if test "$mdnlib" = yes; then
++      AC_MSG_ERROR([You must specify ARG for --with-mdnlib.])
++ fi
++ 
++ if test "$use_mdn" != no; then
++      AC_DEFINE(WITH_MDN, 1, [define if mDNkit support is to be included.])
++      STD_CINCLUDES="$STD_CINCLUDES -I$mdn_path/include"
++      if test "$mdnlib" != no; then
++              LIBS="$mdnlib $iconvlib $LIBS"
++      else
++              LIBS="-L$mdn_path/lib -lmdn $iconvlib $LIBS"
++      fi
++ fi
++ AC_CHECK_HEADERS(locale.h)
++ AC_CHECK_FUNCS(setlocale)
++ 
++ #
+  # Substitutions
+  #
+  AC_SUBST(BIND9_TOP_BUILDDIR)
+Index: bin/dig/dighost.c
+diff -c mdn/othersrc/bind9/bin/dig/dighost.c:1.1.1.9 mdn/othersrc/bind9/bin/dig/dighost.c:1.20
+*** bin/dig/dighost.c  Mon May 21 15:49:55 2001
+--- bin/dig/dighost.c  Mon May 21 15:57:32 2001
+***************
+*** 33,38 ****
+--- 33,49 ----
+  #include <string.h>
+  #include <limits.h>
+  
++ #ifdef HAVE_LOCALE_H
++ #include <locale.h>
++ #endif
++ 
++ #ifdef WITH_MDN
++ #include <mdn/result.h>
++ #include <mdn/log.h>
++ #include <mdn/resconf.h>
++ #include <mdn/res.h>
++ #endif
++ 
+  #include <dns/byaddr.h>
+  #include <dns/fixedname.h>
+  #include <dns/message.h>
+***************
+*** 135,140 ****
+--- 146,165 ----
+  dig_lookup_t *current_lookup = NULL;
+  isc_uint32_t rr_limit = INT_MAX;
+  
++ #ifdef WITH_MDN
++ mdn_resconf_t mdnconf;
++ 
++ static void          initialize_mdn(void);
++ static isc_result_t  output_filter(isc_buffer_t *buffer,
++                                    unsigned int used_org,
++                                    isc_boolean_t absolute);
++ static mdn_result_t  append_textname(char *name, const char *origin,
++                                      size_t namesize);
++ static void          mdn_check_result(mdn_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
+***************
+*** 694,699 ****
+--- 719,728 ----
+               ISC_LIST_APPEND(server_list, srv, link);
+       }
+  
++ #ifdef WITH_MDN
++      initialize_mdn();
++ #endif
++ 
+       if (keyfile[0] != 0)
+               setup_file_key();
+       else if (keysecret[0] != 0)
+***************
+*** 1229,1234 ****
+--- 1258,1267 ----
+       isc_region_t r;
+       isc_buffer_t b;
+       char store[MXNAME];
++ #ifdef WITH_MDN
++      mdn_result_t mr;
++      char idn_textname[MXNAME], idn_origin[MXNAME], idn_tmp[MXNAME];
++ #endif
+  
+       REQUIRE(lookup != NULL);
+       INSIST(!free_now);
+***************
+*** 1288,1293 ****
+--- 1321,1367 ----
+       }
+       if (lookup->origin != NULL) {
+               debug("trying origin %s", lookup->origin->origin);
++ #ifdef WITH_MDN
++              /*
++               * We cannot convert name and origin separately and combine
++               * them later, because some encoding scheme (such as UTF-5)
++               * can be applied only to an entire domain name, not a
++               * partial one.
++               */
++              mr = mdn_res_nameconv(mdnconf, "l", lookup->textname,
++                                    idn_textname, sizeof(idn_textname));
++              mdn_check_result(mr, "convert textname to UCS");
++              mr = mdn_res_nameconv(mdnconf, "l", lookup->origin->origin,
++                                    idn_origin, sizeof(idn_origin));
++              mdn_check_result(mr, "convert origin to UCS");
++              mr = append_textname(idn_textname, idn_origin,
++                                   sizeof(idn_textname));
++              mdn_check_result(mr, "append UCS origin to UCS textname");
++              mr = mdn_res_nameconv(mdnconf, "dMNI", idn_textname,
++                                    idn_tmp, sizeof(idn_tmp));
++              mdn_check_result(mr, "convert UCS textname to IDN encoding");
++              strcpy(idn_textname, idn_tmp);
++ 
++              if (!lookup->trace_root) {
++                      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 {
++                      dns_name_clone(dns_rootname, lookup->name);
++              }
++              if (result != ISC_R_SUCCESS) {
++                      dns_message_puttempname(lookup->sendmsg,
++                                              &lookup->name);
++                      isc_buffer_init(&b, store, MXNAME);
++                      fatal("'%s' is not a legal name syntax "
++                            "(%s)", lookup->textname,
++                            dns_result_totext(result));
++              }
++ #else /* WITH_MDN */
+               result = dns_message_gettempname(lookup->sendmsg,
+                                                &lookup->oname);
+               check_result(result, "dns_message_gettempname");
+***************
+*** 1326,1334 ****
+--- 1400,1423 ----
+                             lookup->textname, dns_result_totext(result));
+               }
+               dns_message_puttempname(lookup->sendmsg, &lookup->oname);
++ #endif /* WITH_MDN */
+       } else {
+               debug("using root origin");
+               if (!lookup->trace_root) {
++ #ifdef WITH_MDN
++                      mr = mdn_res_nameconv(mdnconf, "ldMNI",
++                                            lookup->textname, idn_textname,
++                                            sizeof(idn_textname));
++                      mdn_check_result(mr,
++                                       "convert textname to IDN encoding");
++                      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 /* WITH_MDN */
+                       len = strlen(lookup->textname);
+                       isc_buffer_init(&b, lookup->textname, len);
+                       isc_buffer_add(&b, len);
+***************
+*** 1336,1341 ****
+--- 1425,1431 ----
+                                                  dns_rootname,
+                                                  ISC_FALSE,
+                                                  &lookup->namebuf);
++ #endif /* WITH_MDN */
+               } else {
+                       dns_name_clone(dns_rootname, lookup->name);
+               }
+***************
+*** 2756,2758 ****
+--- 2846,2962 ----
+       if (mctx != NULL)
+               isc_mem_destroy(&mctx);
+  }
++ 
++ #ifdef WITH_MDN
++ static void
++ initialize_mdn(void) {
++      mdn_result_t r;
++      mdn_converter_t conv;
++ 
++ #ifdef HAVE_SETLOCALE
++      /* Set locale */
++      (void)setlocale(LC_ALL, "");
++ #endif
++ 
++      /* General initialization. */
++      r = mdn_resconf_initialize();
++      if (r != mdn_success)
++              fatal("mdn initialization failed: %s",
++                    mdn_result_tostring(r));
++ 
++      /* Create configuration context. */
++      r = mdn_resconf_create(&mdnconf);
++      if (r != mdn_success)
++              fatal("mdn resconf initialization failed: %s",
++                    mdn_result_tostring(r));
++ 
++ 
++      /* Load mdn configuration file. */
++      r = mdn_resconf_loadfile(mdnconf, NULL);
++      if (r != mdn_success)
++              fatal("mdn configuration loading failed: %s",
++                    mdn_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 (mdn_res_nameconv(mdnconf, "iL", tmp1, tmp2, MAXDLEN)
++          != mdn_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 mdn_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 mdn_success;
++ 
++      /* Append dot and origin */
++ 
++      if (namelen + 1 + originlen >= namesize)
++              return mdn_buffer_overflow;
++ 
++      name[namelen++] = '.';
++      (void)strcpy(name + namelen, origin);
++      return mdn_success;
++ }
++ 
++ static void
++ mdn_check_result(mdn_result_t r, const char *msg) {
++      if (r != mdn_success) {
++              exitcode = 1;
++              fatal("%s: %s", msg, mdn_result_tostring(r));
++      }
++ }
++ 
++ #endif /* WITH_MDN */
+Index: lib/dns/name.c
+diff -c mdn/othersrc/bind9/lib/dns/name.c:1.1.1.7 mdn/othersrc/bind9/lib/dns/name.c:1.10
+*** lib/dns/name.c     Mon May 21 15:50:37 2001
+--- lib/dns/name.c     Mon May 21 15:57:49 2001
+***************
+*** 205,210 ****
+--- 205,217 ----
+  /* XXXDCL make const? */
+  dns_name_t *dns_wildcardname = &wild.name;
+  
++ #ifdef WITH_MDN
++ /*
++  * 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);
+***************
+*** 1705,1710 ****
+--- 1712,1720 ----
+       unsigned int labels;
+       isc_boolean_t saw_root = ISC_FALSE;
+       char num[4];
++ #ifdef WITH_MDN
++      unsigned int oused = target->used;
++ #endif
+  
+       /*
+        * This function assumes the name is in proper uncompressed
+***************
+*** 1883,1888 ****
+--- 1893,1902 ----
+  
+       isc_buffer_add(target, tlen - trem);
+  
++ #ifdef WITH_MDN
++      if (totext_filter_proc != NULL)
++              return ((*totext_filter_proc)(target, oused, saw_root));
++ #endif
+       return (ISC_R_SUCCESS);
+  }
+  
+***************
+*** 3154,3156 ****
+--- 3168,3177 ----
+       } else
+               snprintf(cp, size, "<unknown>");
+  }
++ 
++ #ifdef WITH_MDN
++ 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.5 mdn/othersrc/bind9/lib/dns/include/dns/name.h:1.7
+*** lib/dns/include/dns/name.h Tue Apr 17 14:18:27 2001
+--- lib/dns/include/dns/name.h Thu Apr 26 13:54:43 2001
+***************
+*** 217,222 ****
+--- 217,233 ----
+   */
+  #define DNS_NAME_MAXWIRE 255
+  
++ #ifdef WITH_MDN
++ /*
++  * 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
+   ***/
+***************
+*** 1215,1220 ****
+--- 1226,1239 ----
+   *   'size' > 0.
+   *
+   */
++ 
++ #ifdef WITH_MDN
++ void
++ dns_name_settotextfilter(dns_name_totextfilter_t proc);
++ /*
++  * Call 'proc' at the end of dns_name_totext.
++  */
++ #endif /* WITH_MDN */
+  
+  #define DNS_NAME_FORMATSIZE (DNS_NAME_MAXTEXT + 1)
+  /*
diff --git a/contrib/idn/mdnkit/patch/libiconv/libiconv-1.6.1.patch b/contrib/idn/mdnkit/patch/libiconv/libiconv-1.6.1.patch
new file mode 100644 (file)
index 0000000..ac2edd5
--- /dev/null
@@ -0,0 +1,71 @@
+Patch for libiconv-1.6.1+NetBSD 1.5
+===================================
+
+This is a patch file for libiconv-1.6.1 to make it work on NetBSD 1.5.
+
+To apply this patch, you should go to the top directory of the libiconv
+source tree (where you see `README' file), then invoke `patch' command
+like this:
+
+       % patch -p0 < this-file
+
+Then follow the normal build instructions described in README and
+INSTALL.generic.
+
+
+diff -c -r ../libiconv-1.6.1.org/autoconf/ltconfig ./autoconf/ltconfig
+*** ../libiconv-1.6.1.org/autoconf/ltconfig    Mon Feb 26 21:52:17 2001
+--- ./autoconf/ltconfig        Fri Jun  1 09:29:30 2001
+***************
+*** 1188,1198 ****
+  
+    netbsd*)
+      if echo __ELF__ | $CC -E - | grep __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
+        archive_cmds='$LD -Bshareable $libobjs $deplibs $linkopts -o $lib'
+        # can we support soname and/or expsyms with a.out? -oliva
+      fi
+      ;;
+  
+--- 1188,1198 ----
+  
+    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
+      ;;
+  
+diff -c -r ../libiconv-1.6.1.org/libcharset/autoconf/ltconfig ./libcharset/autoconf/ltconfig
+*** ../libiconv-1.6.1.org/libcharset/autoconf/ltconfig Mon Feb 26 21:49:31 2001
+--- ./libcharset/autoconf/ltconfig     Fri Jun  1 09:29:31 2001
+***************
+*** 1194,1204 ****
+  
+    netbsd*)
+      if echo __ELF__ | $CC -E - | grep __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
+        archive_cmds='$LD -Bshareable $libobjs $deplibs $linkopts -o $lib'
+        # can we support soname and/or expsyms with a.out? -oliva
+      fi
+      ;;
+  
+--- 1194,1204 ----
+  
+    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
+      ;;
+  
diff --git a/contrib/idn/mdnkit/patch/squid/squid-2.4.STABLE1-patch b/contrib/idn/mdnkit/patch/squid/squid-2.4.STABLE1-patch
new file mode 100644 (file)
index 0000000..278c0da
--- /dev/null
@@ -0,0 +1,32 @@
+8bit-through patch for Squid 2.4-STABLE1
+========================================
+
+This is a patch file for Squid 2.4-STABLE1 to make it work with
+internationalized host names.  It simply disables validity check of
+host names.
+
+To apply this patch, you should go to the top directory of the source
+tree (where README file resides), then invoke `patch' command like this:
+
+        % patch -p1 < this-file
+
+Then follow the instructions described in INSTALL to configure and
+(re)build the squid cache server.
+
+*** squid-2.4.STABLE1/src/url.c.dist   Fri Jan 12 09:51:32 2001
+--- squid-2.4.STABLE1/src/url.c        Tue May  1 17:42:15 2001
+***************
+*** 298,307 ****
+--- 298,309 ----
+           *q = '\0';
+       }
+      }
++ #if 0
+      if (strspn(host, valid_hostname_chars) != strlen(host)) {
+       debug(23, 1) ("urlParse: Illegal character in hostname '%s'\n", host);
+       return NULL;
+      }
++ #endif
+      /* remove trailing dots from hostnames */
+      while ((l = strlen(host)) > 0 && host[--l] == '.')
+       host[l] = '\0';
index dfee66b8e1d028302c286d6c59d20c5a8912c60c..ee67587959f8929120fa8467a8065bbff7f1dbbc 100644 (file)
@@ -1,4 +1,4 @@
-# $Id: Makefile.in,v 1.6 2000/07/19 05:00:16 ishisone Exp $
+# $Id: Makefile.in,v 1.9 2001/04/06 07:53:12 ishisone 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.
@@ -63,6 +63,8 @@ exec_prefix = @exec_prefix@
 
 SUBDIRS = mdnconv runmdn
 
+SHELL = @SHELL@
+
 all:
        for d in $(SUBDIRS); do (cd $$d; $(MAKE) all); done
 
index ac101b8b5760f9249633c65b522f564352b13b15..d6f4ab8e317024e5d7faac1b9d25c83d0991a415 100644 (file)
@@ -1,4 +1,4 @@
-# $Id: Makefile.in,v 1.11 2000/11/17 06:53:23 ishisone Exp $
+# $Id: Makefile.in,v 1.15 2001/03/28 02:12:37 m-kasahr 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.
@@ -63,15 +63,15 @@ VPATH = @srcdir@
 prefix = @prefix@
 exec_prefix = @exec_prefix@
 
-BINDIR = @bindir@
-LIBDIR = @libdir@
-MANDIR = @mandir@
+bindir = @bindir@
+mandir = @mandir@
 
 CC = @CC@
 RANLIB = @RANLIB@
 INSTALL = @INSTALL@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_DATA = @INSTALL_DATA@
+MKINSTALLDIRS = @top_srcdir@/mkinstalldirs
 SHELL   = @SHELL@
 LIBTOOL = @LIBTOOL@
 
@@ -87,23 +87,21 @@ OBJS = mdnconv.o util.o
 ICONVLIB = @ICONVLIB@
 MDNLIB = ../../lib/libmdn.la
 
-LIBS = $(MDNLIB) $(ICONVLIB)
-
 all: mdnconv
 
 mdnconv: $(OBJS) $(MDNLIB)
-       $(LIBTOOL) --mode=link $(CC) -o $@ $(OBJS) $(LIBS)
+       $(LIBTOOL) --mode=link $(CC) -o $@ $(OBJS) $(MDNLIB) $(ICONVLIB)
 
 install: install-prog install-man
 
 install-prog: mdnconv
-       [ -d $(BINDIR) ] || mkdir $(BINDIR)
-       $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) mdnconv $(BINDIR)
+       $(MKINSTALLDIRS) $(bindir)
+       $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) mdnconv $(bindir)
 
 install-man:
-       [ -d $(MANDIR) ] || mkdir $(MANDIR)
-       [ -d $(MANDIR)/man1 ] || mkdir $(MANDIR)/man1
-       $(INSTALL_DATA) $(srcdir)/mdnconv.1 $(MANDIR)/man1
+       $(MKINSTALLDIRS) $(mandir)/man1
+       $(INSTALL_DATA) $(srcdir)/mdnconv.1 $(mandir)/man1
 
 clean:
        rm -f *.o mdnconv *.core core *~
+       rm -fr .libs/
diff --git a/contrib/idn/mdnkit/tools/mdnconv/README.ja b/contrib/idn/mdnkit/tools/mdnconv/README.ja
deleted file mode 100644 (file)
index 93cabdd..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-
-       mdnconv -- named.conf/¥¾¡¼¥ó¥Õ¥¡¥¤¥ëÍÑ¥³¡¼¥É¥»¥Ã¥È¥³¥ó¥Ð¡¼¥¿
-
-* »ÈÍÑË¡
-       mdnconv [¥ª¥×¥·¥ç¥ó..] [¥Õ¥¡¥¤¥ë]
-
-* ³µÍ×
-
-mdnconv ¤Ï¥³¥Þ¥ó¥É¹Ô°ú¿ô¤Ç»ØÄꤵ¤ì¤¿¥ª¥×¥·¥ç¥ó¤Ë¤·¤¿¤¬¤Ã¤Æ¥Æ¥­¥¹¥È¤Î¥³¡¼
-¥É¥»¥Ã¥È¤òÊÑ´¹¤·¡¢É¸½à½ÐÎϤ˽ñ¤­½Ð¤·¤Þ¤¹¡£°ú¿ô¤È¤·¤Æ¥Õ¥¡¥¤¥ë̾¤¬»ØÄꤵ
-¤ì¤ì¤Ð¤½¤ÎÆâÍÆ¤òÊÑ´¹¤·¡¢»ØÄꤵ¤ì¤Ê¤±¤ì¤Ðɸ½àÆþÎÏ¤ÎÆâÍÆ¤òÊÑ´¹¤·¤Þ¤¹¡£
-
-* ¥ª¥×¥·¥ç¥ó
-
-mdnconv ¤Ï¼¡¤Î¤è¤¦¤Ê¥ª¥×¥·¥ç¥ó¤ò¼õ¤±ÉÕ¤±¤Þ¤¹¡£
-
-       -in ÆþÎÏ¥³¡¼¥É
-               ÆþÎÏ¥³¡¼¥É¥»¥Ã¥È¤Î»ØÄê¤Ç¤¹¡£»ØÄê¤Ç¤­¤ëÃͤϡ¢
-               iconv() ¤¬¼õ¤±ÉÕ¤±¤ë¥³¡¼¥É¥»¥Ã¥È̾¡¢"UTF-5"¡¢
-               ¤ª¤è¤Ó¸å½Ò¤¹¤ë -alias ¥ª¥×¥·¥ç¥ó¤ÇÄêµÁ¤·¤¿¤½¤ì¤é¤ÎÊÌ̾¤Ç¤¹¡£
-               ¸½ºß¤Î¥Ð¡¼¥¸¥ç¥ó¤Ç¤Ï¤³¤Î¥ª¥×¥·¥ç¥ó¤Î»ØÄê¤Ïɬ¿Ü¤Ç¤¹¡£
-
-       -out ½ÐÎÏ¥³¡¼¥É
-               ½ÐÎÏ¥³¡¼¥É¥»¥Ã¥È¤Î»ØÄê¤Ç¤¹¡£»ØÄê¤Ç¤­¤ëÃͤϡ¢
-               iconv() ¤¬¼õ¤±ÉÕ¤±¤ë¥³¡¼¥É¥»¥Ã¥È̾¡¢"UTF-5"¡¢
-               ¤ª¤è¤Ó¸å½Ò¤¹¤ë -alias ¥ª¥×¥·¥ç¥ó¤ÇÄêµÁ¤·¤¿¤½¤ì¤é¤ÎÊÌ̾¤Ç¤¹¡£
-               ¥Ç¥Õ¥©¥ë¥È¤Ï UTF-8 ¤Ç¤¹¡£
-
-       -normalize Àµµ¬²½
-               ¼Â¹Ô¤¹¤ëÀµµ¬²½¤Î¼ïÎà¤ò»ØÄꤷ¤Þ¤¹¡£¤³¤Î¥ª¥×¥·¥ç¥ó¤ÏÊ£¿ô
-               »ØÄꤹ¤ë¤³¤È¤¬¤Ç¤­¡¢¤½¤Î¾ì¹ç¤Ë¤Ï»ØÄꤵ¤ì¤¿½ç½ø¤Ç
-               Àµµ¬²½¤¬¹Ô¤ï¤ì¤Þ¤¹¡£¸½ºß¡¢»ÈÍѤǤ­¤ëÀµµ¬²½¤Î̾¾Î¤Ï
-               °Ê²¼¤ÎÄ̤ê¤Ç¤¹¡£
-
-               ascii-lowercase
-                       ASCII ¤ÎÂçʸ»ú¤ò¾®Ê¸»ú¤ËÊÑ´¹¤·¤Þ¤¹¡£
-               ascii-uppercase
-                       ASCII ¤Î¾®Ê¸»ú¤òÂçʸ»ú¤ËÊÑ´¹¤·¤Þ¤¹¡£
-               unicode-lowercase
-                       UnicodeData.txt ¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë Lowercase Mapping
-                       ¤Ë¤·¤¿¤¬¤Ã¤ÆÂçʸ»ú¤ò¾®Ê¸»ú¤ËÊÑ´¹¤·¤Þ¤¹¡£
-               unicode-uppercase
-                       UnicodeData.txt ¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë Uppercase Mapping
-                       ¤Ë¤·¤¿¤¬¤Ã¤Æ¾®Ê¸»ú¤òÂçʸ»ú¤ËÊÑ´¹¤·¤Þ¤¹¡£
-               unicode-form-c
-                       Unicode Normalization Form C ¤Ë¤·¤¿¤¬¤Ã¤Æ
-                       Àµµ¬²½¤ò¹Ô¤¤¤Þ¤¹¡£
-               unicode-form-kc
-                       Unicode Normalization Form KC ¤Ë¤·¤¿¤¬¤Ã¤Æ
-                       Àµµ¬²½¤ò¹Ô¤¤¤Þ¤¹¡£
-               ja-delimiter-hack
-                       Á´³Ñ¤Î¶çÅÀ¡Ø¡£¡Ù¤ª¤è¤Ó¥Ô¥ê¥ª¥É¡Ø¡¥¡Ù¤ò
-                       È¾³Ñ¤Î¥Ô¥ê¥ª¥É¡Ø.¡Ù¤ËÊÑ´¹¤·¤Þ¤¹¡£
-               ja-fullwidth
-                       È¾³Ñ¥«¥¿¥«¥Ê¤òÁ´³Ñ¥«¥¿¥«¥Ê¤ËÊÑ´¹¤·¤Þ¤¹¡£
-
-       -zld ZLD
-               ZLD ¤ò»ØÄꤷ¤Þ¤¹¡£UTF-5 ¤Ø¤ÎÊÑ´¹¤ÎºÝ¡¢¥É¥á¥¤¥ó̾¤Î
-               ºÇ¸å¤¬»ØÄꤵ¤ì¤¿ ZLD ¤Ë°ìÃפ¹¤ë¾ì¹ç¡¢ZLD Éôʬ¤Ï
-               UTF-5 ¤ËÊÑ´¹¤µ¤ì¤Þ¤»¤ó¡£
-               ¤¢¤ë¤¤¤Ï¼¡¤Î -auto ¤ÈÁȤ߹ç¤ï¤»¤¿¾ì¹ç¤Ë¤Ï¡¢
-               ¥É¥á¥¤¥ó̾¤ÎºÇ¸å¤¬¥Ô¥ê¥ª¥É¤Ç¤¢¤ê¡¢¤«¤ÄÈóASCII
-               Ê¸»ú¤ò´Þ¤ó¤Ç¤¤¤¿¾ì¹ç¡¢»ØÄꤷ¤¿ZLD ¤¬¼«Æ°Åª¤ËÉղ䵤ì¤Þ¤¹¡£
-
-       -auto
-               ¥É¥á¥¤¥ó̾¤ÎºÇ¸å¤¬¥Ô¥ê¥ª¥É¤Ç¤¢¤ê¡¢¤«¤ÄÈóASCII
-               Ê¸»ú¤ò´Þ¤ó¤Ç¤¤¤ë¾ì¹ç¤Ë¡¢-zld ¥ª¥×¥·¥ç¥ó¤Ç»ØÄꤷ¤¿ZLD ¤ò
-               ¼«Æ°Åª¤ËÉղä·¤Þ¤¹¡£
-
-       -whole
-               Àµµ¬²½¤ª¤è¤Ó½ÐÎÏ¥³¡¼¥É¥»¥Ã¥È¤Ø¤ÎÊÑ´¹¤òÆþÎϥƥ­¥¹¥È
-               Á´ÂΤˤ錄¤Ã¤Æ¹Ô¤¤¤Þ¤¹¡£¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï¡¢ÆþÎϥƥ­¥¹¥È¤Î
-               ÈóASCIIʸ»ú¤ª¤è¤Ó¤½¤Î¼þÊդΤߤòÂоݤȤ·¤Þ¤¹¡£
-
-       -alias ÊÌ̾¥Õ¥¡¥¤¥ë
-               ¥³¡¼¥É¥»¥Ã¥È̾¤ÎÊÌ̾¤òÄêµÁ¤·¤¿¥Õ¥¡¥¤¥ë¤ò»ØÄꤷ¤Þ¤¹¡£
-
-       -flush
-               ¹Ôñ°Ì¤Ç½ÐÎϤò¥Õ¥é¥Ã¥·¥å¤·¤Þ¤¹¡£
-
-
-* ÊÑ´¹¤Î»ÅÁȤß
-
-mdnconv ¤Ï¡¢ÆþÎϤµ¤ì¤¿¥Ç¡¼¥¿¤ò¤Þ¤º UTF-8 ¤Ø¤ÈÊÑ´¹¤·¤Þ¤¹¡£UTF-8 ¤Î¾õÂÖ
-¤ÇÀµµ¬²½¤ò¼Â¹Ô¤·¡¢ºÇ¸å¤Ë UTF-8 ¤«¤é½ÐÎÏ¥³¡¼¥É¥»¥Ã¥È¤Ø¤ÈÊÑ´¹¤·¤Æ½ÐÎϤ·
-¤Þ¤¹¡£ÆþÎϤµ¤ì¤¿¥Ç¡¼¥¿¤ÎUTF-8¤Ø¤ÎÊÑ´¹¡¢¤Ï¤¹¤Ù¤Æ¤Î¥Ç¡¼¥¿¤ËÂФ·¤Æ¹Ô¤ï¤ì
-¤Þ¤¹¤¬¡¢Àµµ¬²½¤ª¤è¤Ó UTF-8 ¤«¤é½ÐÎÏ¥³¡¼¥É¥»¥Ã¥È¤Ø¤ÎÊÑ´¹¤Ï¡¢ÈóASCIIʸ»ú
-¤È¤½¤Î¼þÊÕ¤ËÂФ·¤Æ¤Î¤ß¹Ô¤ï¤ì¤Þ¤¹¡£¶ñÂÎŪ¤Ë¤Ï¡¢
-
-       ÈóASCIIʸ»ú¡¢¤ª¤è¤Ó¤½¤ÎÁ°¸å¤Î¥É¥á¥¤¥ó̾¤ò¹½À®¤¹¤ëASCIIʸ»ú
-       ¤È¥Ô¥ê¥ª¥É ([-0-9A-Za-z.]) ¤ÎÉôʬ
-
-¤¬ÊÑ´¹Âоݤˤʤê¤Þ¤¹¡£mdnconv ¤ÏÆþÎϥǡ¼¥¿¤ò¹½Ê¸²òÀϤ¹¤ë¤è¤¦¤Ê½èÍý¤Ï¤·
-¤Æ¤¤¤Þ¤»¤ó¤Î¤Ç¡¢¼ÂºÝ¤Ë¤Ï¥É¥á¥¤¥ó̾¤Ç¤Ï¤Ê¤¯¤Æ¤â¡¢¾åµ­¤Î¾ò·ï¤Ë°ìÃפ¹¤ë¸Ä
-½ê¤Ï¤¹¤Ù¤ÆÊÑ´¹Âоݤˤʤê¤Þ¤¹¡£
-
--whole ¥ª¥×¥·¥ç¥ó¤ò»ØÄꤷ¤Æ mdnconv ¤òµ¯Æ°¤¹¤ë¤³¤È¤Ë¤è¤ê¡¢¤¹¤Ù¤Æ¤Î¥Ç¡¼¥¿¤Ë
-ÂФ·¤ÆÀµµ¬²½¤È½ÐÎÏ¥³¡¼¥É¥»¥Ã¥È¤Ø¤ÎÊÑ´¹¤ò¹Ô¤¦¤³¤È¤¬²Äǽ¤Ç¤¹¡£
-
-
-* named.conf/¥¾¡¼¥ó¥Õ¥¡¥¤¥ë¤Î´ÉÍýÊýË¡
-
-named.conf ¤ä¥¾¡¼¥ó¥Õ¥¡¥¤¥ë¤Ï¥í¡¼¥«¥ë¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°¤Ç½ñ¤«¤ì¤¿¤â¤Î¤ò
-¥Þ¥¹¥¿¡¼¤È¤·¡¢¤³¤ì¤ò mdnconv ¤Ç UTF-8 ¤ä UTF-5 ¤ËÊÑ´¹¤·¤Æ named ¤Ë¿©¤ï
-¤»¤ë¤Î¤¬¤è¤¤¤Ç¤·¤ç¤¦¡£Î㤨¤Ð¥í¡¼¥«¥ë¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°¤Î¥Õ¥¡¥¤¥ë¤Ë¥µ¥Õ¥£¥Ã
-¥¯¥¹ .lc ¤ò¡¢UTF-5/UTF-8 ¤Î¥Õ¥¡¥¤¥ë¤Ë¤½¤ì¤¾¤ì¥µ¥Õ¥£¥Ã¥¯¥¹.utf5 .utf8 
-¤ò¤Ä¤±¤ë¤³¤È¤Ë¤¹¤ì¤Ð¡¢¤Ä¤®¤Î¤è¤¦¤Ê Makefile ¤Î¥ë¡¼¥ë¤ò»ØÄꤹ¤ë¤³¤È¤ÇÊÑ
-´¹¤¬¤Ç¤­¤Þ¤¹¡£
-
-       .SUFFIXES: .lc .utf5 .utf8
-       .lc.utf5:
-               mdnconv -in $(LOCALCODE) -out UTF-5 $< > $@
-       .lc.utf8:
-               mdnconv -in $(LOCALCODE) -out UTF-8 $< > $@
-
-
-; $Id: README.ja,v 1.2 2000/06/12 04:23:57 ishisone Exp $
index 1ef431ba63bdbdb02699b3fac97e6470ed6d7cb4..13bb3936c23927983f366225115204127694d070 100644 (file)
@@ -1,6 +1,7 @@
-.\" $Id: mdnconv.1,v 1.11 2000/11/17 07:18:58 ishisone Exp $
+.\" $Id: mdnconv.1,v 1.17 2001/05/18 04:16:27 ishisone Exp $
 .\"
-.\" Copyright (c) 2000 Japan Network Information Center.  All rights reserved.
+.\" 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.
 .\" 
@@ -56,7 +57,7 @@
 .\"    Conditions hereby agrees and consent to the personal and exclusive
 .\"    jurisdiction and venue of Tokyo District Court of Japan.
 .\"
-.TH MDNCONV 1 "June 30, 2000"
+.TH MDNCONV 1 "Mar 3, 2001"
 .\"
 .SH NAME
 mdnconv \- codeset converter for named.conf and zone master files
@@ -68,143 +69,321 @@ mdnconv \- codeset converter for named.conf and zone master files
 .B mdnconv
 is a codeset converter for named configuration files and zone master files.
 .B mdnconv
-performs codeset conversion specified by the command-line arguments,
+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,
 .B mdnconv
 converts the contents of the file.  Otherwise,
 .B mdnconv
-converts stdin.
+converts
+.IR stdin .
 .PP
+Since
 .B mdnconv
 is specifically designed for converting internatinalized domain names,
-and may not be suitable as a general codeset converter.
+it may not be suitable as a general codeset converter.
+.\"
+.SH "OPERATION MODES"
+.B mdnconv
+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
+Furthermore, delimiter mapping is also performed in case \-delimitermap
+command line option is specified.
+.PP
+The other mode is a reverse convertion, from IDN-encoded domain name to
+local-encoded domain names.
+Since IDN-ecoded names are usually already normalized by local mapping and
+NAMEPREP process, only codeset conversion is performed in this mode.
+.\"
 .SH OPTIONS
+Normally
+.B mdnconv
+reads system's default configuration file (mdn.conf) and perform
+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\-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
-Codeset names which iconv_open() library function accepts
+Any codeset names which \fIiconv_open()\fP library function accepts
+.IP "\(bu" 2
+\f(CWRACE\fR
+.IP "\(bu" 2
+\f(CWBRACE\fR
 .IP "\(bu" 2
-``UTF-5''
+\f(CWLACE\fR
 .IP "\(bu" 2
-``RACE''
+\f(CWDUDE\fR
 .IP "\(bu" 2
-``BRACE''
+\f(CWUTF-5\fR
 .IP "\(bu" 2
-``LACE''
+\f(CWUTF-6\fR
+.IP "\(bu" 2
+\f(CWAltDUDE\fR
+.IP "\(bu" 2
+\f(CWAMC-ACE-O\fR
+.IP "\(bu" 2
+\f(CWAMC-ACE-M\fR
+.IP "\(bu" 2
+\f(CWAMC-ACE-R\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 current locale.
+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\-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 
 .B \-in
 option.
-If this option is not specified, the default is the codeset specified
-in MDN resolver configuration file (``server-encoding'' line).
+.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 mDNkit configuration file (``mdn.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
+.IR version s.
+.RS 4
+.IP \f(CWnameprep-02\fR 4
+Perform NAMEPREP according to the Internet Draft
+``draft-ietf-idn-nameprep-02.txt'' (NAMEPREP-02).
+.IP \f(CWnameprep-03\fR 4
+Perform NAMEPREP according to the Internet Draft
+``draft-ietf-idn-nameprep-03.txt'' (NAMEPREP-03).
+.RE
+.IP "" 4
+This option is a shorthand for specifying the 4 options below.
+.PP
+.RS 8
+.ft CW
+-map 
+.I version
+.br
+-normalize
+.I version
+.br
+-prohibit
+.I version
+.br
+-unassigned
+.I version
+.ft R
+.RE
+.IP "" 4
+This option is only meaningful in the normal conversion mode.
+.TP 4
+\fB\-nonameprep\fR, \fB\-N\fR
+Specify to skip NAMEPREP process in the normal conversion mode.
+.br
+This option is only meaningful in the normal conversion mode.
+.TP 4
+\fB\-map\fR \fImap\fR
+Specify the name of the mapping rule for NAMEPREP mapping process.
+Currently, following
+.IR map s
+are available.
+.RS 4
+.IP \f(CWnameprep-02\fR 4
+Use the list of mappings specified by NAMEPREP-02 draft.
+.IP \f(CWnameprep-03\fR 4
+Use the list of mappings specified by NAMEPREP-03 draft.
+.IP \f(CWfilemap:\fR\fIpath\fR 4
+Use list of mappings specified by mapfile
+.IR path .
+See mdn.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.
+.br
+If neither this option nor ``\-nameprep'' are specified,
+the schemes specified in the configuration file (``nameprep-map'' entry)
+are used.
+.br
+This option is only meaningful in the normal conversion mode.
 .TP 4
 \fB\-normalize\fP \fIscheme\fP
-Perform normalization specified by \fIscheme\fP.
+Specify the normalization scheme for NAMEPREP normalization process.
 Currently, following \fIscheme\fPs are available:
 .RS 4
-.IP ``ascii-uppercase''
+.IP \f(CWascii-uppercase\fR
 ASCII lowercase to uppercase mapping.
-.IP ``ascii-lowercase''
+.IP \f(CWascii-lowercase\fR
 ASCII uppercase to lowercase mapping.
-.IP ``unicode-uppercase''
+.IP \f(CWunicode-uppercase\fR
 Unicode lowercase to uppercase mapping, which is described in
 ``Unicode Technical Report #21: Case Mappings'',
 available from unicode.org.
-.IP ``unicode-lowercase''
+.IP \f(CWunicode-lowercase\fR
 Unicode uppercase to lowercase mapping, according ``Case Mappings''.
-.IP ``unicode-form-c''
+.IP \f(CWunicode-foldcase\fR
+Unicode case-folding for case-less string matching,
+also described in the above document.
+.IP \f(CWunicode-form-c\fR
 Unicode Normlization Form C, which is described in
 ``Unicode Technical Report #15: Unicode Normalization Forms'',
 also available from unicode.org.
-.IP ``unicode-form-kc''
-Perform Unicode Normlization Form KC, also described in the above
+.IP \f(CWunicode-form-kc\fR
+Unicode Normlization Form KC, also described in the above
 document.
-.IP ``ja-compose-voiced-sound''
-Compose Japanese full-width hiragana/katakana character and the following
-(semi) voiced sound mark (dakuten or han-dakuten in Japanese) into a
-single combined letter if such letter exists.
-.IP ``ja-kana-fullwidth''
-Convert Japanese half-width katakana characters (aka ``hankaku katakana'')
-to their corresponding full-width characters.
-.IP ``ja-alnum-halfwidth''
-Convert full-width alphabets, digits and minus sign to half-width.
-.IP ``ja-minus-hack''
-Convert Japanese full-width minus sign (U+2212 ``MINUS SIGN'') to
-``\-'' (U+002D ``HYPHEN-MINUS'').
-.IP ``ja-delimiter-hack''
-Map ``IDEOGRAPHIC FULL STOP'' (U+3002) and ``FULLWIDTH FULL STOP'' (U+FF0E)
-characters to period (``.'') so that these two characters can be used as
-domain component separaters.
-.br
-Note that there is no good reason to use this scheme when you convert
-configuration files or zone files, and its use is strongly
-deprecated.
+.IP \f(CWnameprep-02\fR
+Synonim for ``unicode-form-kc''.
+.IP \f(CWnameprep-03\fR
+Synonim for ``unicode-form-kc''.
 .RE
 .IP "" 4
 This option can be specified more than once.
 In that case, each normalization will be performed in the order of the
 specification.
 .br
-If this option is not specified, the schemes specified in MDN resolver
-configuration file (``normalize'' line) are used.
+If neither this option nor ``\-nameprep'' are specified,
+the schemes specified in the configuration file (``nameprep-normalize'' entry)
+are used.
+.br
+This option is only meaningful in the normal conversion mode.
+.TP 4
+\fB\-prohibit\fR \fIset\fR
+Specify the set of prohibited characters.
+Currently, following
+.IR set s
+are available.
+.RS 4
+.IP \f(CWnameprep-02\fR 4
+Use list of prohibit characters specified by NAMEPREP-02 draft.
+.IP \f(CWnameprep-03\fR 4
+Use list of prohibit characters specified by NAMEPREP-03 draft.
+.IP \f(CWfileset:\fR\fIpath\fR 4
+Use list of characters specified by setfile
+.IR path .
+See mdn.conf(5) for the format of a setfile.
+.RE
+.IP "" 4
+This option can be specified more than once.  In this case, the set of
+prohibited characters is the union of the specified sets.
+.br
+If neither this option nor ``\-nameprep'' is specified,
+list of characters specified by the configuration file
+(``nameprep-prohibit'' entry) is used.
+.br
+This option is only meaningful in the normal conversion mode.
+.TP 4
+\fB\-unassigned\fR \fIset\fR
+Specify the set of unassigned codepoints.
+Currently, following
+.IR set s
+are available.
+.RS 4
+.IP \f(CWnameprep-02\fR 4
+Use the list of unassigned characters specified by NAMEPREP-02 draft.
+.IP \f(CWnameprep-03\fR 4
+Use the list of unassigned characters specified by NAMEPREP-03 draft.
+.IP \f(CWfileset:\fR\fIpath\fR 4
+Use list of characters specified by setfile
+.IR path .
+See mdn.conf(5) for the format of a setfile.
+.RE
+.IP "" 4
+Note that unassigned codepoint checking is not performed
+unless \-unassigncheck option is specified.
+.br
+This option can be specified more than once.  In this case, the set of
+prohibited characters is the union of the specified sets.
+.br
+If neither this option nor ``\-nameprep'' is specified,
+list of characters specified by the configuration file
+(``nameprep-unassigned'' entry) is used.
+.br
+This option is only meaningful in the normal conversion mode.
+.TP 4
+\fB\-unassigncheck\fR, \fB\-u\fR
+Specify unassigned codepoint check should be performed.
+Unassigned codepoint check is disabled by default.
+.br
+This option is only meaningful in the normal conversion mode.
 .TP 4
-\fB\-zld\fP \fIZLD\fP
-Specify ZLD (zero-level domain) to use.
-If a domain name to be converted ends with the specified ZLD,
-the matching part will not be converted.
-This is important for some codesets such as UTF-5, in order to
-protect ZLD part intact from conversion.
+\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
+If this option is not specified, characters specified by the
+configuration file (``delimiter-map'') is used.
+.br
+Note that delimiter mapping is not performed unless \-delimitermap option
+is specified.
 .br
-If this option is not specified, the default is the one specified
-in MDN resolver configuration file (``server-zld'' line) or empty (no ZLD).
+This option is only meaningful in the normal conversion mode.
 .TP 4
-\fB\-auto\fP
-Automatically append ZLD specified by \-zld option to domain names,
-if they contain non-ASCII character and end with period (``.'').
-By using this option, you don't have to specify ZLD explicitly in
-your zone master file.  It is not perfect though, there are cases
-you have to write ZLD explicitly.  So take care.
+\fB\-delimitermap\fR, \fB\-d\fR
+Specify delimiter mapping should be performed.
+By default, delimiter mapping is disabled.
+.br
+This option is only meaningful in the normal conversion mode.
 .TP 4
-\fB\-whole\fP
-Perform normalization and conversion to output codeset for the entire
+\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 normalized and converted.
+and their surrounding texts will be processed.
 See ``CONVERSION MECHANISM'' for details.
 .TP 4
-\fB\-alias\fP \fIpath\fP
+\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
 
-    some-alias-codeset-name    real-codeset-name
+    \fIalias-codeset-name\fP    \fIreal-codeset-name\fP
 
-.ft P
+.ft R
 .fi
 Lines starting with ``#'' are treated as comments.
 .TP 4
-\fB\-conf\fP \fIpath\fP
-Specify a MDN resolver configuration file (``mdnres.conf'').
-If not specified, system's default file is used.
-.TP 4
-\fB\-noconf\fP
-Specify that no configuration file is to be used.
-.TP 4
 \fB\-flush\fP
 Force line-buffering mode.
+.TP 4
+\fB\-version\fP, \fB\-v\fP
+Print version information and quit.
+.\"
 .SH CONVERSION MECHANISM
 Here is a brief step-by-step description of how
 .B mdnconv
@@ -213,7 +392,21 @@ does its job.
 .B mdnconv
 reads input text line by line, and converts them from the input codeset
 to UTF-8 encoding.  Basically this conversion is done using iconv() utility,
-but for some special codesets like UTF-5, special converter will be used.
+but for some special codesets like RACE, special converter will be used.
+.br
+Normally the whole line is converted, but if the input codeset is an
+ACE (ASCII-compatible encoding, such as RACE), a special conversion
+prodedure shown below is used:
+.RS 4
+.IP 1) 3
+Find substrings which are valid ASCII domain names (i.e. constructed from
+alphanumeric characters and hyphens) in the line.
+.IP 2) 3
+For each substring found, try converting it to UTF-8.
+.IP 3) 3
+If the conversion succeeds, replace the substring with the conversion
+result. Otherwise, the original substring is retained.
+.RE
 .IP "2. finding where to process" 4
 Then
 .B mdnconv
@@ -222,7 +415,7 @@ and picks them up for further processing.
 .br
 .B mdnconv
 recognizes the character sequence having the following property as
-the internationalized domain name.
+an internationalized domain name.
 .RS 4
 .IP "\(bu" 2
 containing at least one non-ASCII character, and
@@ -252,37 +445,57 @@ the following lines (`#' denotes non-ASCII character).
 .fi
 If \-whole option is specified, this step is skipped and the entire line
 is subject to further processing.
-.IP "3. normalization"
-For each string picked up by the last step, normalization is performed.
-Multiple normalization schemes can be applied. 
-.IP "4. output-side conversion" 4
+.IP "3. delimiter mapping" 4
+For each string picked up by the last step, delimiter mapping is performed.
+That is, substibute certain characters specified as domain name delimiter
+with period.
+.IP "4. 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.
+.IP "5. nameprep" 4
+Perform name preparation (NAMEPREP).  This is a following 3-step process.
+.RS 6
+.nf
+1) Mapping
+2) Normalization
+3) Prohibited/unassigned character checking
+.fi
+.RE
+.IP "6. output-side conversion" 4
 Finally,
 .B mdnconv
-converts the normalized strings from UTF-8 encoding to the output codeset,
-typically UTF-8, UTF-5 or RACE.  And it writes them to stdout together with
-the rest of the line.
+converts the nameprepped strings from UTF-8 encoding to the output codeset.
+And it writes them to stdout together with the rest of the line.
+.PP
+If
+.B mdnconv
+operates in the reverse conversion mode, step 3, 4 and 5 above are skipped.
+.\"
 .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 UTF-8 or
-UTF-5 (or whatever) version using \fBmdnconv\fP.
-
+they can be edited with your favorite editor, and generate a version in
+the IDN encoding using \fBmdnconv\fP.
+.PP
 `make' is a convenient tool for this purpose.
-Suppose the local codeset version has suffix `.lc', and its UTF-8 version
-has suffix `.utf8'.  The following Makefile enables you to generate
-UTF-8 version from local codeset version by just typing `make'.
+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 .utf8
-\&.lc.utf8:
-        mdnconv -in $(LOCALCODE) -out UTF-8 $(MDNCONVOPT) $< > $@
+\&.SUFFIXES: .lc .ace
+\&.lc.ace:
+        mdnconv -in $(LOCALCODE) $(MDNCONVOPT) $< > $@
 
 LOCALCODE = EUC-JP
-MDNCONVOPT = -normalize unicode-form-c
+MDNCONVOPT = 
 
-DESTFILES = db.zone1.utf8 db.zone2.utf8
+DESTFILES = db.zone1.ace db.zone2.ace
 
 all: $(DESTFILES)
 .ft
@@ -290,15 +503,10 @@ all: $(DESTFILES)
 .RE
 .\"
 .SH SEE ALSO
-mdnres.conf(5),
-iconv(3) (if your system has one)
+mdn.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.
-.PP
-ZLD handling has some problems.  Especially automatic ZLD supply feature
-(\-auto option) is inherently imperfect and you shouldn't rely on it.
-.PP
-Some mechanism is required to force normalization and output-side conversion
-on ASCII-only domain names.
+it cannot guess or guess wrong.  It is better to explicitly specify it
+using \-in option.
index 0263f3593f6a5ce62df6c802306daa7d02be0dba..3d424b5afcd365c85f867ea6c69898463683f4eb 100644 (file)
@@ -1,9 +1,10 @@
 #ifndef lint
-static char *rcsid = "$Id: mdnconv.c,v 1.20 2000/12/06 09:46:34 m-kasahr Exp $";
+static char *rcsid = "$Id: mdnconv.c,v 1.32 2001/05/18 04:16:28 ishisone Exp $";
 #endif
 
 /*
- * Copyright (c) 2000 Japan Network Information Center.  All rights reserved.
+ * 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.
  * 
@@ -70,7 +71,6 @@ static char *rcsid = "$Id: mdnconv.c,v 1.20 2000/12/06 09:46:34 m-kasahr Exp $";
 #include <stddef.h>
 #include <stdlib.h>
 #include <string.h>
-#include <stdarg.h>
 #include <errno.h>
 #ifdef HAVE_LOCALE_H
 #include <locale.h>
@@ -79,119 +79,190 @@ static char *rcsid = "$Id: mdnconv.c,v 1.20 2000/12/06 09:46:34 m-kasahr Exp $";
 #include <mdn/result.h>
 #include <mdn/converter.h>
 #include <mdn/normalizer.h>
-#include <mdn/localencoding.h>
 #include <mdn/utf8.h>
 #include <mdn/resconf.h>
+#include <mdn/res.h>
+#include <mdn/util.h>
+#include <mdn/version.h>
 
 #include "util.h"
 
-/* Maxmum number of normalizers */
-#define MAX_NORMALIZER 10
+#define MAX_DELIMITER          10
+#define MAX_LOCALMAPPER                10
+#define MAX_MAPPER             10
+#define MAX_NORMALIZER         10
+#define MAX_CHEKER             10
 
-int                    line_number;    /* current input file line number */
-int                    flush_every_line = 0; /* pretty obvious */
-mdn_converter_t                conv_in_ctx;    /* input converter */
-mdn_converter_t                conv_out_ctx;   /* output converter */
-mdn_normalizer_t       norm_ctx;       /* normalizer */
+#define FLAG_REVERSE           1
+#define FLAG_DELIMITERMAP      2
+#define FLAG_LOCALMAP          4
+#define FLAG_NAMEPREP          8
+#define FLAG_UNASSIGNCHECK     16
+#define FLAG_SELECTIVE         32
 
-void                   errormsg(const char *fmt, ...);
-static int             convert_file(FILE *fp, char *zld, int auto_zld,
-                                    int selective);
-static void            usage(char *cmd);
+int            line_number;            /* current input file line number */
+static int     flush_every_line = 0;   /* pretty obvious */
+
+static int             convert_file(mdn_resconf_t conf, FILE *fp, 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 *normalizer[MAX_NORMALIZER];
-       int nnormalizer = 0;
-       const char *in_code = NULL;
-       const char *out_code = NULL;
+       char *cname;
+       unsigned long delimiters[MAX_DELIMITER];
+       char *localmappers[MAX_LOCALMAPPER];
+       char *mappers[MAX_MAPPER];
+       char *normalizers[MAX_NORMALIZER];
+       char *prohibits[MAX_CHEKER];
+       char *unassigns[MAX_CHEKER];
+       char *nameprep_version = NULL;
+       int ndelimiters = 0;
+       int nlocalmappers = 0;
+       int nmappers = 0;
+       int nnormalizers = 0;
+       int nprohibits = 0;
+       int nunassigns = 0;
+       char *in_code = NULL;
+       char *out_code = NULL;
        char *resconf_file = NULL;
        int no_resconf = 0;
-       char zld[256 + 1];
-       int zld_specified = 0;
-       int auto_zld = 0;
        char *encoding_alias = NULL;
-       int selective = 1;
+       int check_unassigned = 0;
+       int flags = FLAG_LOCALMAP | FLAG_NAMEPREP | FLAG_SELECTIVE;
        FILE *fp;
+       mdn_result_t r;
        mdn_resconf_t resconf;
 
 #ifdef HAVE_SETLOCALE
        (void)setlocale(LC_ALL, "");
 #endif
 
-       zld[0] = '\0';
+       /*
+        * 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 MUST_HAVE_ARG if (ac < 2) usage(cmd)
-               if (strcmp(*av, "-in") == 0) {
+#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 (strcmp(*av, "-out") == 0) {
+               } else if (OPT_MATCH("-out") || OPT_MATCH("-o")) {
                        MUST_HAVE_ARG;
                        out_code = av[1];
                        ac--;
                        av++;
-               } else if (strcmp(*av, "-conf") == 0) {
+               } else if (OPT_MATCH("-conf") || OPT_MATCH("-c")) {
                        MUST_HAVE_ARG;
                        resconf_file = av[1];
                        ac--;
                        av++;
-               } else if (strcmp(*av, "-noconf") == 0) {
-                       no_resconf = 1;
-               } else if (strcmp(*av, "-zld") == 0) {
+               } else if (OPT_MATCH("-nameprep") || OPT_MATCH("-n")) {
                        MUST_HAVE_ARG;
-                       canonical_zld(zld, av[1]);
-                       zld_specified = 1;
+                       nameprep_version = av[1];
                        ac--;
                        av++;
-               } else if (strcmp(*av, "-auto") == 0) {
-                       auto_zld = 1;
-               } else if (strcmp(*av, "-normalize") == 0) {
+               } 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("-delimitermap") || OPT_MATCH("-d")) {
+                       flags |= FLAG_DELIMITERMAP;
+               } 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("-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;
-                       if (nnormalizer >= MAX_NORMALIZER) {
-                               errormsg("too many normalizers\n");
-                               exit(1);
-                       }
-                       normalizer[nnormalizer++] = av[1];
+                       v = get_ucs(av[1]);
+                       APPEND_LIST(delimiters, ndelimiters, v,
+                                   "delimiter maps");
+               } else if (OPT_MATCH("-map")) {
+                       MUST_HAVE_ARG;
+                       APPEND_LIST(mappers, nmappers, av[1], "mappers");
+               } else if (OPT_MATCH("-normalize")) {
+                       MUST_HAVE_ARG;
+                       APPEND_LIST(normalizers, nnormalizers, av[1],
+                                   "normalizers");
+               } else if (OPT_MATCH("-prohibit")) {
+                       MUST_HAVE_ARG;
+                       APPEND_LIST(prohibits, nprohibits, av[1],
+                                   "prohibited checkers");
+               } else if (OPT_MATCH("-unassigned")) {
+                       MUST_HAVE_ARG;
+                       APPEND_LIST(unassigns, nunassigns, av[1],
+                                   "unassigned checkers");
+                       check_unassigned = 1;
+               } else if (OPT_MATCH("-alias") || OPT_MATCH("-a")) {
+                       MUST_HAVE_ARG;
+                       encoding_alias = av[1];
                        ac--;
                        av++;
-               } else if (strcmp(*av, "-alias") == 0) {
-                       MUST_HAVE_ARG;
-                       encoding_alias = *av;
-               } else if (strcmp(*av, "-flush") == 0) {
+               } else if (OPT_MATCH("-flush")) {
                        flush_every_line = 1;
-               } else if (strcmp(*av, "-whole") == 0) {
-                       selective = 0;
+               } else if (OPT_MATCH("-version") || OPT_MATCH("-v")) {
+                       print_version();
                } else {
-                       usage(cmd);
+                       print_usage(cmd);
                }
+#undef OPT_MATCH
 #undef MUST_HAVE_ARG
+#undef APPEND_LIST
 
                ac--;
                av++;
        }
 
        if (ac > 1)
-               usage(cmd);
+               print_usage(cmd);
 
-       /*
-        * Load configuration file.
-        */
+       /* Initialize. */
+       if ((r = mdn_resconf_initialize()) != mdn_success) {
+               errormsg("error initializing library\n");
+               return (1);
+       }
+
+       /* Create resource context. */
        resconf = NULL;
-       if (!no_resconf) {
-               mdn_result_t r;
+       if ((r = mdn_resconf_create(&resconf)) != mdn_success) {
+               errormsg("error initilizing configuration parameters\n");
+               return (1);
+       }
 
-               r = mdn_resconf_initialize();
-               if (r == mdn_success)
-                       r = mdn_resconf_create(&resconf);
-               if (r == mdn_success)
-                       r = mdn_resconf_loadfile(resconf, resconf_file);
+       /* Load configuration file. */
+       if (!no_resconf) {
+               r = mdn_resconf_loadfile(resconf, resconf_file);
                if (r != mdn_success) {
                        errormsg("error reading configuration file: %s\n",
                                 mdn_result_tostring(r));
@@ -199,55 +270,52 @@ main(int ac, char **av) {
                }
        }
 
-       /*
-        * Get default input/output code.
-        */
-       if (in_code == NULL)
-               in_code = mdn_localencoding_name();
-
-       if (out_code == NULL) {
-               mdn_converter_t c;
-               if (resconf != NULL &&
-                   (c = mdn_resconf_serverconverter(resconf)) != NULL)
-                       out_code = mdn_converter_localencoding(c);
-       }
+       /* Set encoding alias file. */
+       if (encoding_alias != NULL)
+               set_encoding_alias(encoding_alias);
 
-       if (in_code == NULL) {
-               errormsg("input codeset must be specified\n");
-               return (1);
-       }
-       if (out_code == NULL) {
-               errormsg("output codeset must be specified\n");
-               return (1);
+       /* Set input/output codeset. */
+       if (flags & FLAG_REVERSE) {
+               if (in_code != NULL)
+                       set_idncode(resconf, in_code);
+               if (out_code != NULL)
+                       set_localcode(resconf, out_code);
+       } else {
+               if (in_code != NULL)
+                       set_localcode(resconf, in_code);
+               if (out_code != NULL)
+                       set_idncode(resconf, out_code);
        }
 
-       /*
-        * Initialize codeset converter.
-        */
-       if (!initialize_converter(in_code, out_code, encoding_alias))
-               return (1);
+       /* Set delimiter map(s). */
+       if (ndelimiters > 0)
+               set_delimitermapper(resconf, delimiters, ndelimiters);
 
-       /*
-        * Initialize normalizer.
-        */
-       if (nnormalizer == 0 && resconf != NULL)
-               norm_ctx = mdn_resconf_normalizer(resconf);
-       if (norm_ctx == NULL &&
-           !initialize_normalizer(normalizer, nnormalizer))
-               return (1);
+       /* Set local map(s). */
+       if (nlocalmappers > 0)
+               set_localmapper(resconf, localmappers, nlocalmappers);
 
-       /*
-        * Default ZLD.
-        */
-       if (!zld_specified && resconf != NULL) {
-               const char *conf_zld = mdn_resconf_zld(resconf);
-               if (conf_zld != NULL)
-                       canonical_zld(zld, conf_zld);
-       }
+       /* Set NAMEPREP version. */
+       if (nameprep_version != NULL)
+               set_nameprep(resconf, nameprep_version);
 
-       /*
-        * Open input file.
-        */
+       /* Set NAMEPREP mapper. */
+       if (nmappers > 0)
+               set_mapper(resconf, mappers, nmappers);
+
+       /* Set NAMEPREP normalizer. */
+       if (nnormalizers > 0)
+               set_normalizer(resconf, normalizers, nnormalizers);
+
+       /* Set NAMEPREP prohibit checker. */
+       if (nprohibits > 0)
+               set_prohibit_checkers(resconf, prohibits, nprohibits);
+
+       /* Set NAMEPREP unassigned checker. */
+       if (nunassigns > 0)
+               set_unassigned_checkers(resconf, unassigns, nunassigns);
+
+       /* Open input file. */
        if (ac > 0) {
                if ((fp = fopen(av[0], "r")) == NULL) {
                        errormsg("cannot open file %s: %s\n",
@@ -258,24 +326,53 @@ main(int ac, char **av) {
                fp = stdin;
        }
 
-       /*
-        * Do the conversion.
-        */
-       return convert_file(fp, zld, auto_zld, selective);
+       /* Do the conversion. */
+       return convert_file(resconf, fp, flags);
 }
 
 static int
-convert_file(FILE *fp, char *zld, int auto_zld, int selective) {
+convert_file(mdn_resconf_t conf, FILE *fp, int flags) {
        mdn_result_t r;
        char line1[1024];
        char line2[1024];
+       char insn1[10], insn2[10];
        int nl_trimmed;
        int ace_hack;
+       mdn_converter_t conv;
 
-       if (mdn_converter_isasciicompatible(conv_in_ctx))
+       /*
+        * See if the input codeset is an ACE.
+        */
+       if (flags & FLAG_REVERSE)
+               conv = mdn_resconf_getidnconverter(conf);
+       else
+               conv = mdn_resconf_getlocalconverter(conf);
+       if (conv != NULL && mdn_converter_isasciicompatible(conv))
                ace_hack = 1;
        else
                ace_hack = 0;
+       if (conv != NULL)
+               mdn_converter_destroy(conv);
+
+       if (flags & FLAG_REVERSE) {
+               strcpy(insn1, "i");
+               strcpy(insn2, "L");
+       } else {
+               char *insnp = insn2;
+
+               strcpy(insn1, "l");
+
+               if (flags & FLAG_DELIMITERMAP)
+                       *insnp++ = 'd';
+               if (flags & FLAG_LOCALMAP)
+                       *insnp++ = 'M';
+               if (flags & FLAG_NAMEPREP)
+                       *insnp++ = 'N';
+               if (flags & FLAG_UNASSIGNCHECK)
+                       *insnp++ = 'u';
+               *insnp++ = 'I';
+               *insnp = '\0';
+       }
 
        line_number = 1;
        while (fgets(line1, sizeof(line1), fp) != NULL) {
@@ -299,10 +396,11 @@ convert_file(FILE *fp, char *zld, int auto_zld, int selective) {
                        /*
                         * Selectively decode those portions.
                         */
-                       r = selective_decode(line1, line2, 1024);
+                       r = selective_decode(conf, insn1, line1, line2,
+                                            sizeof(line2));
                } else {
-                       r = mdn_converter_localtoutf8(conv_in_ctx,
-                                                     line1, line2, 1024);
+                       r = mdn_res_nameconv(conf, insn1,
+                                            line1, line2, sizeof(line2));
                }
                if (r != mdn_success) {
                        errormsg("conversion failed at line %d: %s\n",
@@ -317,17 +415,22 @@ convert_file(FILE *fp, char *zld, int auto_zld, int selective) {
                }
 
                /*
-                * Normalize and convert to the output codeset.
+                * Perform local mapping and NAMEPREP, and convert to
+                * the output codeset.
                 */
-               if (selective) {
-                       r = selective_encode(line2, line1, sizeof(line1),
-                                            zld, auto_zld);
+               if (flags & FLAG_SELECTIVE) {
+                       r = selective_encode(conf, insn2, line2, line1,
+                                            sizeof(line1));
                } else {
-                       r = encode_region(line2, line1, sizeof(line1),
-                                         zld, auto_zld);
+                       r = mdn_res_nameconv(conf, insn2, line2, line1,
+                                            sizeof(line1));
                }
-               if (r != mdn_success)
+               if (r != mdn_success) {
+                       errormsg("error in nameprep or output conversion "
+                                "at line %d: %s\n",
+                                line_number, mdn_result_tostring(r));
                        return (1);
+               }
 
                fputs(line1, stdout);
                if (nl_trimmed)
@@ -341,37 +444,60 @@ convert_file(FILE *fp, char *zld, int auto_zld, int selective) {
        return (0);
 }
 
-void
-errormsg(const char *fmt, ...) {
-       va_list args;
+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 pathname of MDN configuration file.",
+       "-c CONF-FILE        : synonym for -conf",
+       "-noconf             : do not load MDN 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",
+       "-map SCHEME         : specifies mapping scheme.",
+       "-normalize SCHEME   : specifies normalization scheme.",
+       "-prohibit SET       : specifies set of prohibited characters.",
+       "-unassigned SET     : specifies set of unassigned code points.",
+       "-unassigncheck      : perform unassigned codepoint check.",
+       "-u                  : synonym for -unassigncheck",
+       "-delimiter U+XXXX   : specifies local delimiter code point.",
+       "-delimitermap       : perform local delimiter mapping.",
+       "-d                  : synonym for -delimitermap",
+       "-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, -map, -normalize, -prohibit, -unassigned -delimiter",
+       NULL,
+};
 
-       va_start(args, fmt);
-       vfprintf(stderr, fmt, args);
-       va_end(args);
+static void
+print_version() {
+       fprintf(stderr, "mdnconv (mDNkit) version: %s\n"
+               "library version: %s\n",
+               MDNKIT_VERSION,
+               mdn_version_getstring());
+       exit(0);
 }
 
 static void
-usage(char *cmd) {
+print_usage(char *cmd) {
        int i;
-       static char *options[] = {
-               "-in input-codeset   : specifies input codeset name.",
-               "-out output-codeset : specifies output codeset name.",
-               "-normalize scheme   : specifies normalization scheme.",
-               "                      this option can be specified",
-               "                      multiple times.",
-               "-zld zld            : specifies ZLD to use.",
-               "-auto               : automatically appends ZLD where",
-               "                      seemed appropriate.",
-               "-alias alias-file   : specifies codeset alias file.",
-               "-conf conf-file     : specifies pathname of MDN resolver",
-               "                      configuration file.",
-               "-noconf             : do not load MDN resolver configuration",
-               "                      file.",
-               "-flush              : line-buffering mode.",
-               "-whole              : convert the whole region instead of",
-               "                      regions containing non-ascii characters",
-               NULL,
-       };
 
        fprintf(stderr, "Usage: %s [options..] [file]\n", cmd);
 
@@ -380,3 +506,21 @@ usage(char *cmd) {
 
        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;
+}
index 0c4ac8553361c412b9f7ac43db9e7f484bacf19a..08d22f9cadd5e211ad6148bf39b7e2b5eea151a5 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
-static char *rcsid = "$Id: util.c,v 1.9 2000/12/07 02:35:12 m-kasahr Exp $";
+static char *rcsid = "$Id: util.c,v 1.17 2001/04/16 02:18:15 m-kasahr Exp $";
 #endif
 
 /*
@@ -65,32 +65,23 @@ static char *rcsid = "$Id: util.c,v 1.9 2000/12/07 02:35:12 m-kasahr Exp $";
 #include <stdio.h>
 #include <stddef.h>
 #include <stdlib.h>
+#include <stdarg.h>
 #include <string.h>
 #include <ctype.h>
 #include <errno.h>
 
-#include <mdn/result.h>
-#include <mdn/converter.h>
-#include <mdn/normalizer.h>
-#include <mdn/localencoding.h>
+#include <mdn/resconf.h>
+#include <mdn/res.h>
 #include <mdn/utf8.h>
 #include <mdn/selectiveencode.h>
-#include <mdn/util.h>
 
 #include "util.h"
 
 extern int             line_number;
-extern mdn_converter_t conv_in_ctx;
-extern mdn_converter_t conv_out_ctx;
-extern mdn_normalizer_t        norm_ctx;
-
-extern void            errormsg(const char *fmt, ...);
-
-static int             ascii_tolower(int c);
 
 mdn_result_t
-selective_encode(char *from, char *to, int tolen,
-                const char *zld, int auto_zld)
+selective_encode(mdn_resconf_t conf, char *insn,
+                char *from, char *to, int tolen)
 {
        for (;;) {
                int len;
@@ -141,7 +132,7 @@ selective_encode(char *from, char *to, int tolen,
                /*
                 * Encode the region.
                 */
-               r = encode_region(region_start, to, tolen, zld, auto_zld);
+               r = mdn_res_nameconv(conf, insn, region_start, to, tolen);
 
                /*
                 * Restore character.
@@ -160,135 +151,9 @@ selective_encode(char *from, char *to, int tolen,
 }
 
 mdn_result_t
-encode_region(const char *region, char *to, int tolen,
-             const char *zld, int auto_zld)
+selective_decode(mdn_resconf_t conf, char *insn,
+                char *from, char *to, int tolen)
 {
-       int len;
-       mdn_result_t r;
-       int full_domain;
-       int protect_zld;
-       char line[1024];
-               
-       /*
-        * Perform normalization.
-        */
-       r = mdn_normalizer_normalize(norm_ctx, region, line, 1024);
-       if (r != mdn_success) {
-               errormsg("normalization failed at line %d: %s\n",
-                        line_number,
-                        mdn_result_tostring(r));
-               return (r);
-       }
-       /*
-        * This is not necessary if the noramlizer works correctly,
-        * but just in case..
-        */
-       if (!mdn_utf8_isvalidstring(line)) {
-               errormsg("normalizer corrupsed line %d\n",
-                        line_number);
-               return (mdn_invalid_encoding);
-       }
-
-       /*
-        * Now we have normalized string in line.
-        * See if it ends with '.'.
-        */
-       len = strlen(line);
-       full_domain = (line[len - 1] == '.');
-
-       /*
-        * Protect ZLD part (if any) from conversion.
-        */
-       if ((protect_zld = zld_match(line, zld)) != 0)
-               line[len - strlen(zld)] = '\0';
-
-       /*
-        * Convert the region to the output encoding.
-        */
-       r = mdn_converter_utf8tolocal(conv_out_ctx, line, to, tolen);
-       if (r != mdn_success) {
-               errormsg("conversion to %s failed at line %d: %s\n",
-                        mdn_converter_localencoding(conv_out_ctx),
-                        line_number,
-                        mdn_result_tostring(r));
-               return (r);
-       }
-
-       len = strlen(to);
-       to += len;
-       tolen -= len;
-               
-       if ((full_domain && auto_zld) || protect_zld) {
-               /*
-                * Append ZLD.
-                */
-               if ((len = strlen(zld)) >= tolen)
-                       return (mdn_buffer_overflow);
-               (void)strcpy(to, zld);
-               to += len;
-               tolen -= len;
-       }
-
-       return (mdn_success);
-}
-
-void
-canonical_zld(char *s, const char *zld) {
-       int i;
-       int zlen = strlen(zld);
-
-       if (zlen > 256) {
-               errormsg("ZLD is too long\n");
-               exit(1);
-       }
-
-       /* Remove leading dot. */
-       if (zld[0] == '.') {
-               zld++;
-               zlen--;
-       }
-
-       for (i = 0; i < zlen; i++) {
-               int c = *zld;
-               if (('A' <= c && c <= 'Z') ||
-                   ('a' <= c && c <= 'z') ||
-                   ('0' <= c && c <= '9') ||
-                   c == '.' || c == '-') {
-                       *s++ = *zld++;
-               } else {
-                       errormsg("ZLD contains illegal character %c\n", c);
-                       exit(1);
-               }
-       }
-
-       /* Supply trailing dot, if needed. */
-       if (zlen > 0 && s[-1] != '.')
-               (void)strcpy(s, ".");
-}
-
-int
-zld_match(const char *s, const char *zld) {
-       int slen = strlen(s);
-       int zlen = strlen(zld);
-       int i;
-
-       if (slen < zlen)
-               return (0);
-
-       /* oops, strcasecmp is not a stnadard function. */
-       /* return (strcasecmp(s + slen - zlen, zld) == 0); */
-       s += slen - zlen;
-       for (i = 0; i < zlen; i++) {
-               if (s[i] != zld[i] &&
-                   s[i] != tolower((unsigned char)zld[i]) &&
-                   s[i] != toupper((unsigned char)zld[i]))
-                       return (0);
-       }
-       return (1);
-}
-
-mdn_result_t
-selective_decode(char *from, char *to, int tolen) {
        char *domain_name;
        char *ignored_chunk;
        char save;
@@ -366,9 +231,8 @@ selective_decode(char *from, char *to, int tolen) {
                                 */
                                save = *from;
                                *from = '\0';
-                               r = mdn_converter_localtoutf8(conv_in_ctx,
-                                                             domain_name, to,
-                                                             tolen);
+                               r = mdn_res_nameconv(conf, insn,
+                                                    domain_name, to, tolen);
                                *from = save;
 
                                if (r == mdn_success) {
@@ -408,68 +272,143 @@ selective_decode(char *from, char *to, int tolen) {
        return (mdn_success);
 }
 
-int
-initialize_converter(const char *in_code, const char *out_code,
-                    const char *encoding_alias)
-{
+void
+set_encoding_alias(const char *encoding_alias) {
        mdn_result_t r;
 
-       if (encoding_alias != NULL &&
-           (r = mdn_converter_aliasfile(encoding_alias)) != mdn_success) {
+       if ((r = mdn_converter_aliasfile(encoding_alias)) != mdn_success) {
                errormsg("cannot read alias file %s: %s\n",
                         encoding_alias, mdn_result_tostring(r));
-               return (0);
-       }
-       if ((r = mdn_converter_initialize()) != mdn_success) {
-               errormsg("converter initialization failed: %s\n",
-                        mdn_result_tostring(r));
-               return (0);
+               exit(1);
        }
-       if ((r = mdn_converter_create(in_code, &conv_in_ctx, 0))
-           != mdn_success) {
+}
+
+void
+set_localcode(mdn_resconf_t conf, const char *code) {
+       mdn_result_t r;
+
+       r = mdn_resconf_setlocalconvertername(conf, code, 0);
+       if (r != mdn_success) {
                errormsg("cannot create converter for codeset %s: %s\n",
-                        in_code, mdn_result_tostring(r));
-               return (0);
+                        code, mdn_result_tostring(r));
+               exit(1);
        }
-       if ((r = mdn_converter_create(out_code, &conv_out_ctx, 0))
-           != mdn_success) {
+}
+
+void
+set_idncode(mdn_resconf_t conf, const char *code) {
+       mdn_result_t r;
+
+       r = mdn_resconf_setidnconvertername(conf, code, 0);
+       if (r != mdn_success) {
                errormsg("cannot create converter for codeset %s: %s\n",
-                        out_code, mdn_result_tostring(r));
-               return (0);
+                        code, mdn_result_tostring(r));
+               exit(1);
        }
-       return (1);
 }
 
-int
-initialize_normalizer(char **normalizer, int nnormalizer) {
+void
+set_delimitermapper(mdn_resconf_t conf, unsigned long *delimiters,
+                   int ndelimiters) {
        mdn_result_t r;
-       int i;
 
-       if ((r = mdn_normalizer_initialize()) != mdn_success) {
-               errormsg("normalizer initialization failed: %s\n",
+       r = mdn_resconf_addalldelimitermapucs(conf, delimiters, ndelimiters);
+       if (r != mdn_success) {
+               errormsg("cannot add delimiter: %s\n",
                         mdn_result_tostring(r));
-               return (0);
+               exit(1);
        }
-       if ((r = mdn_normalizer_create(&norm_ctx)) != mdn_success) {
-               errormsg("cannot create normalizer: %s\n",
+}
+
+void
+set_localmapper(mdn_resconf_t conf, char **mappers, int nmappers) {
+       mdn_result_t r;
+
+       /* Add mapping. */
+       r = mdn_resconf_addalllocalmapselectornames(conf, 
+                                                   MDN_MAPSELECTOR_DEFAULT,
+                                                   (const char **)mappers,
+                                                   nmappers);
+       if (r != mdn_success) {
+               errormsg("cannot add local map: %s\n",
                         mdn_result_tostring(r));
-               return (0);
+               exit(1);
        }
-       for (i = 0; i < nnormalizer; i++) {
-               if ((r = mdn_normalizer_add(norm_ctx, normalizer[i]))
-                    != mdn_success) {
-                       errormsg("cannot add normalizer %s: %s\n",
-                                normalizer[i], mdn_result_tostring(r));
-                       return (0);
-               }
+}
+
+void
+set_nameprep(mdn_resconf_t conf, char *version) {
+       mdn_result_t r;
+
+       r = mdn_resconf_setnameprepversion(conf, version);
+       if (r != mdn_success) {
+               errormsg("error setting nameprep %s: %s\n",
+                        version, mdn_result_tostring(r));
+               exit(1);
        }
-       return (1);
 }
 
-static int
-ascii_tolower(int c) {
-       if ('A' <= c && c <= 'Z')
-               return (c - 'A' + 'a');
-       else
-               return (c);
+void
+set_mapper(mdn_resconf_t conf, char **mappers, int nmappers) {
+       mdn_result_t r;
+
+       /* Configure mapper. */
+       r = mdn_resconf_addallmappernames(conf, (const char **)mappers,
+                                         nmappers);
+       if (r != mdn_success) {
+               errormsg("cannot add nameprep map: %s\n",
+                        mdn_result_tostring(r));
+               exit(1);
+       }
+}
+
+void
+set_normalizer(mdn_resconf_t conf, char **normalizers, int nnormalizer) {
+       mdn_result_t r;
+
+       r = mdn_resconf_addallnormalizernames(conf,
+                                             (const char **)normalizers,
+                                             nnormalizer);
+       if (r != mdn_success) {
+               errormsg("cannot add normalizer: %s\n",
+                        mdn_result_tostring(r));
+               exit(1);
+       }
+}
+
+void
+set_prohibit_checkers(mdn_resconf_t conf, char **prohibits, int nprohibits) {
+       mdn_result_t r;
+
+       r = mdn_resconf_addallprohibitcheckernames(conf,
+                                                  (const char **)prohibits,
+                                                  nprohibits);
+       if (r != mdn_success) {
+               errormsg("cannot add prohibit checker: %s\n",
+                        mdn_result_tostring(r));
+               exit(1);
+       }
+}
+
+void
+set_unassigned_checkers(mdn_resconf_t conf, char **unassigns, int nunassigns) {
+       mdn_result_t r;
+
+       r = mdn_resconf_addallunassignedcheckernames(conf,
+                                                    (const char **)unassigns,
+                                                    nunassigns);
+       if (r != mdn_success) {
+               errormsg("cannot add unassigned checker: %s\n",
+                        mdn_result_tostring(r));
+               exit(1);
+       }
+}
+
+void
+errormsg(const char *fmt, ...) {
+       va_list args;
+
+       va_start(args, fmt);
+       vfprintf(stderr, fmt, args);
+       va_end(args);
 }
index bdf2a88773475acd45f389065875e985afdc48fe..2ec6aa6c4b44ca9ff06fa26c492d47e69239c2bb 100644 (file)
@@ -1,6 +1,7 @@
-/* $Id: util.h,v 1.3 2000/12/06 09:46:35 m-kasahr Exp $ */
+/* $Id: util.h,v 1.7 2001/02/23 10:36:52 m-kasahr Exp $ */
 /*
- * Copyright (c) 2000 Japan Network Information Center.  All rights reserved.
+ * 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.
  * 
  *    jurisdiction and venue of Tokyo District Court of Japan.
  */
 
-extern mdn_result_t    selective_encode(char *from, char *to, int tolen,
-                                        const char *zld, int auto_zld);
-extern mdn_result_t    encode_region(const char *region, char *to, int tolen,
-                                     const char *zld, int auto_zld);
-extern void            canonical_zld(char *s, const char *zld);
-extern int             zld_match(const char *s, const char *zld);
-extern mdn_result_t    selective_decode(char *from, char *to, int tolen);
-extern int             initialize_converter(const char *in_code,
-                                            const char *out_code,
-                                            const char *encoding_alias);
-extern int             initialize_normalizer(char **normalizer,
-                                             int nnormalizer);
+extern mdn_result_t    selective_encode(mdn_resconf_t conf, char *insn,
+                                        char *from, char *to, int tolen);
+extern mdn_result_t    selective_decode(mdn_resconf_t conf, char *insn,
+                                        char *from, char *to, int tolen);
+extern void            set_encoding_alias(const char *encoding_alias);
+extern void            set_localcode(mdn_resconf_t conf, const char *code);
+extern void            set_idncode(mdn_resconf_t conf, const char *code);
+extern void            set_delimitermapper(mdn_resconf_t conf,
+                                           unsigned long *delimiters,
+                                           int ndelimiters);
+extern void            set_localmapper(mdn_resconf_t conf,
+                                       char **mappers, int nmappers);
+extern void            set_nameprep(mdn_resconf_t conf, char *version);
+extern void            set_mapper(mdn_resconf_t conf,
+                                  char **mappers, int nmappers);
+extern void            set_normalizer(mdn_resconf_t conf,
+                                      char **normalizer, int nnormalizer);
+extern void            set_prohibit_checkers(mdn_resconf_t conf,
+                                             char **prohibits,
+                                             int nprohibits);
+extern void            set_unassigned_checkers(mdn_resconf_t conf,
+                                               char **unassigns,
+                                               int nunassigns);
+extern void            errormsg(const char *fmt, ...);
+
index 06e9a25d54204dfc14829bb2db6408282d4ebdb1..c52031d6533d0fbed442b3ebc33ee5a0610e6059 100644 (file)
@@ -1,22 +1,25 @@
+%define version 2.1
+
+# official/beta release:
+%define release 1
+%define distrel %{version}
+
+# release candidate:
+#define release rc1
+#define distrel %{version}-%{release}
+
+%define serial 2001052801
+
 %define name mdnkit
-%define version 1.2.1
-%define disttop %{name}-%{version}-src
-%define bind_version 8.2.2-P7
-%define serial 2000122101
+%define distsrc %{name}-%{distrel}-src
 
 Name: %{name}
 Version: %{version}
-Release:  1
+Release: %{release}
 Copyright: distributable
 Group: System Environment/Daemons
-Source: %{disttop}.tar.gz
-#Source10: ftp://ftp.isc.org/isc/bind/src/%{bind_version}/bind-src.tar.gz
-#Source11: ftp://ftp.isc.org/isc/bind/src/%{bind_version}/bind-doc.tar.gz
-#Source12: ftp://ftp.isc.org/isc/bind/src/%{bind_version}/bind-contrib.tar.gz
-#NoSource: 10
-#NoSource: 11
-#NoSource: 12
-#Patch0: mdnkit-1.2-runmdn.patch
+Source: %{distsrc}.tar.gz
+#Source1: mdnsproxy.init
 BuildRoot: /var/tmp/%{name}-root
 Serial: %{serial}
 Summary: multilingual Domain Name evaluation kit (mDNkit/JPNIC)
@@ -36,7 +39,7 @@ The header files and library(libmdn.a) to develop applications
 that use MDN library.
 
 %prep
-%setup -n %{disttop}
+%setup -n %{distsrc}
 #%patch0 -p1 -b .runmdn
 
 %build
@@ -48,7 +51,9 @@ then
   fi
 fi
 
-CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=/usr --sysconfdir=/etc $ICONV
+CFLAGS="$RPM_OPT_FLAGS" ./configure \
+       --prefix=/usr --sysconfdir=/etc \
+       --localstatedir=/var $ICONV
 make
 
 %install
@@ -58,12 +63,15 @@ mkdir -p $RPM_BUILD_ROOT/usr/bin
 mkdir -p $RPM_BUILD_ROOT/usr/sbin
 mkdir -p $RPM_BUILD_ROOT/usr/lib
 mkdir -p $RPM_BUILD_ROOT/usr/include
-mkdir -p $RPM_BUILD_ROOT/var/dnsproxy
+mkdir -p $RPM_BUILD_ROOT/usr/share/mdnkit
+mkdir -p $RPM_BUILD_ROOT/var/mdnsproxy
 mkdir -p $RPM_BUILD_ROOT/etc/rc.d/init.d
-make prefix=$RPM_BUILD_ROOT/usr ETCDIR=$RPM_BUILD_ROOT/etc install
-# make prefix=$RPM_BUILD_ROOT/usr sysconfdir=$RPM_BUILD_ROOT/etc install
+make prefix=$RPM_BUILD_ROOT/usr sysconfdir=$RPM_BUILD_ROOT/etc \
+       localstatedir=$RPM_BUILD_ROOT/var install
 
-install -c -m 755 tools/rpm/dnsproxy.init $RPM_BUILD_ROOT/etc/rc.d/init.d/dnsproxy
+mv $RPM_BUILD_ROOT/etc/mdn.conf.sample $RPM_BUILD_ROOT/etc/mdn.conf
+mv $RPM_BUILD_ROOT/etc/mdnsproxy.conf.sample $RPM_BUILD_ROOT/etc/mdnsproxy.conf
+install -c -m 755 tools/rpm/mdnsproxy.init $RPM_BUILD_ROOT/etc/rc.d/init.d/mdnsproxy
 
 # devel kit
 #install -c lib/libmdn.a $RPM_BUILD_ROOT/usr/lib
@@ -71,14 +79,28 @@ install -c -m 755 tools/rpm/dnsproxy.init $RPM_BUILD_ROOT/etc/rc.d/init.d/dnspro
 
 # docs
 mkdir rpm_docs
-(cp DISTFILES README.ja README LICENSE.txt ChangeLog rpm_docs)
-cp tools/mdnconv/README.ja rpm_docs/README-mdnconv.ja
+(cp NEWS DISTFILES README.ja README LICENSE.txt ChangeLog rpm_docs)
 cp -r patch rpm_docs
 
 %clean
 rm -fr $RPM_BUILD_ROOT
 
 %changelog
+* 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
@@ -99,17 +121,17 @@ rm -fr $RPM_BUILD_ROOT
 
 %files
 %defattr(-, root, root)
-/usr/sbin/dnsproxy
-/var/dnsproxy
+/usr/sbin/mdnsproxy
+/var/mdnsproxy
 /usr/bin/mdnconv
 /usr/bin/runmdn
-/etc/rc.d/init.d/dnsproxy
+/etc/rc.d/init.d/mdnsproxy
 /usr/lib/libmdn.so.*
 /usr/lib/libmdnresolv.so.*
-/usr/lib/libmdnresolv.so
 /usr/lib/libmdnresolv.la
-%attr(0644, root, root) %config(noreplace) /etc/dnsproxy.conf
-%attr(0644, root, root) /etc/mdnres.conf.sample
+/usr/share/mdnkit/*
+%attr(0644, root, root) %config(noreplace) /etc/mdn.conf
+%attr(0644, root, root) %config(noreplace) /etc/mdnsproxy.conf
 %attr(0644, root, man) /usr/man/man1/*
 %attr(0644, root, man) /usr/man/man5/*
 %attr(0644, root, man) /usr/man/man8/*
@@ -122,4 +144,3 @@ rm -fr $RPM_BUILD_ROOT
 /usr/lib/libmdn.so
 /usr/lib/libmdnresolv.a
 /usr/include/mdn/*
-%doc lib/README
similarity index 55%
rename from contrib/idn/mdnkit/tools/rpm/dnsproxy.init
rename to contrib/idn/mdnkit/tools/rpm/mdnsproxy.init
index fd0edefe16c704a87be674614fcc368af63dda80..347ce64928c6227c707fab7fef6a61f57b9bedbe 100644 (file)
@@ -2,7 +2,7 @@
 #
 # chkconfig: 345 60 10
 # description: This shell script takes care of starting and stopping
-#               dnsproxy (DNS proxy server).
+#               mdnsproxy (mDNS proxy server).
 #
 
 # Source function library.
 # Check that networking is up.
 [ ${NETWORKING} = "no" ] && exit 0
 
-[ -f /usr/sbin/dnsproxy ] || exit 0
+[ -f /usr/sbin/mdnsproxy ] || exit 0
 
-[ -f /etc/dnsproxy.conf ] || exit 0
+[ -f /etc/mdnsproxy.conf ] || exit 0
 
 # See how we were called.
 case "$1" in
   start)
         # Start daemons.
-        echo -n "Starting dnsproxy: "
-        daemon dnsproxy -daemon
+        echo -n "Starting mdnsproxy: "
+        daemon mdnsproxy -daemon
         echo
-        touch /var/lock/subsys/dnsproxy
+        touch /var/lock/subsys/mdnsproxy
         ;;
   stop)
         # Stop daemons.
-        echo -n "Shutting down dnsproxy: "
-        killproc dnsproxy
+        echo -n "Shutting down mdnsproxy: "
+        killproc mdnsproxy
         echo "done"
-        rm -f /var/lock/subsys/dnsproxy
+        rm -f /var/lock/subsys/mdnsproxy
         ;;
   *)
-        echo "Usage: dnsproxy {start|stop}"
+        echo "Usage: mdnsproxy {start|stop}"
         exit 1
 esac
 
index 99eecd0d3c3f8d3c274012ffae81e6e641c8e92d..b2c8c660b925543ca5a1d4c3b794026bdc7299c0 100644 (file)
@@ -1,4 +1,4 @@
-# $Id: Makefile.in,v 1.14 2000/12/21 01:57:31 ishisone Exp $
+# $Id: Makefile.in,v 1.32 2001/05/22 03:00:23 m-kasahr 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.
@@ -55,8 +55,9 @@
 #    Conditions hereby agrees and consent to the personal and exclusive
 #    jurisdiction and venue of Tokyo District Court of Japan.
 
-LIB_CURRENT=4
-LIB_REVISION=1
+LIB_CURRENT=7
+LIB_REVISION=0
+LIB_AGE=0
 
 .SUFFIXES: .lo
 
@@ -76,6 +77,7 @@ INSTALL = @INSTALL@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
 INSTALL_DATA = @INSTALL_DATA@
+MKINSTALLDIRS = @top_srcdir@/mkinstalldirs
 SHELL   = @SHELL@
 LIBTOOL = @LIBTOOL@
 
@@ -86,31 +88,48 @@ CFLAGS  = $(INCS) $(OPTS) $(DEFS) @CFLAGS@
 LDFLAGS = @LDFLAGS@
 
 LIB     = libmdnresolv
-OBJS    = res_comp.lo ns_name.lo $(MDNOBJS)
+OBJS    = rtresolver.lo stub.lo  $(MDNOBJS)
 SCRIPT  = runmdn
+LIBDL   = @LIBDL@
 
 MDNDIR  = ../../lib
 MDNOBJS  = \
+       $(MDNDIR)/ace.lo \
+       $(MDNDIR)/altdude.lo \
+       $(MDNDIR)/amcacem.lo \
+       $(MDNDIR)/amcaceo.lo \
+       $(MDNDIR)/amcacer.lo \
+       $(MDNDIR)/api.lo \
        $(MDNDIR)/brace.lo \
+       $(MDNDIR)/checker.lo \
        $(MDNDIR)/converter.lo \
        $(MDNDIR)/debug.lo \
+       $(MDNDIR)/delimitermap.lo \
        $(MDNDIR)/dn.lo \
+       $(MDNDIR)/dude.lo \
+       $(MDNDIR)/filechecker.lo \
+       $(MDNDIR)/filemapper.lo \
        $(MDNDIR)/lace.lo \
        $(MDNDIR)/localencoding.lo \
        $(MDNDIR)/log.lo \
+       $(MDNDIR)/mapper.lo \
+       $(MDNDIR)/mapselector.lo \
+       $(MDNDIR)/nameprep.lo \
        $(MDNDIR)/normalizer.lo \
        $(MDNDIR)/race.lo \
        $(MDNDIR)/res.lo \
        $(MDNDIR)/resconf.lo \
        $(MDNDIR)/result.lo \
        $(MDNDIR)/strhash.lo \
-       $(MDNDIR)/translator.lo \
+       $(MDNDIR)/ucsmap.lo \
+       $(MDNDIR)/ucsset.lo \
        $(MDNDIR)/unicode.lo \
        $(MDNDIR)/unormalize.lo \
        $(MDNDIR)/utf5.lo \
+       $(MDNDIR)/utf6.lo \
        $(MDNDIR)/utf8.lo \
        $(MDNDIR)/util.lo \
-       $(MDNDIR)/zldrule.lo
+       $(MDNDIR)/version.lo
 
 ICONVLIB = @ICONVLIB@
 
@@ -119,28 +138,32 @@ ICONVLIB = @ICONVLIB@
 
 all: $(LIB).la
 
+rtresolver.lo: $(srcdir)/resolver.c
+       $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -DFOR_RUNMDN -o $@ \
+               -I$(srcdir) -c $(srcdir)/resolver.c
+
 $(LIB).la: $(OBJS)
        $(LIBTOOL) --mode=link $(LD) $(LDFLAGS) -o $@ \
-               -version-info $(LIB_CURRENT):$(LIB_REVISION) \
-               -module -rpath $(libdir) $(OBJS)
+               -version-info $(LIB_CURRENT):$(LIB_REVISION):$(LIB_AGE) \
+               -module -rpath $(libdir) $(OBJS) $(LIBDL)
 
 install: install-lib install-script install-man
 
 install-script:
-       [ -d $(bindir) ] || mkdir $(bindir)
+       $(MKINSTALLDIRS) $(bindir)
        $(INSTALL_SCRIPT) $(SCRIPT) $(bindir)
 
-install-lib:
-       [ -d $(libdir) ] || mkdir $(libdir)
-       $(LIBTOOL) --mode=install $(INSTALL_DATA) libmdnresolv.la $(libdir)
+install-lib: $(LIB).la
+       $(MKINSTALLDIRS) $(libdir)
+       $(LIBTOOL) --mode=install $(INSTALL_DATA) $(LIB).la $(libdir)
 
 install-man:
-       [ -d $(mandir) ] || mkdir $(mandir)
-       [ -d $(mandir)/man1 ] || mkdir $(mandir)/man1
+       $(MKINSTALLDIRS) $(mandir)/man1
        $(INSTALL_DATA) $(srcdir)/runmdn.1 $(mandir)/man1
 
 clean:
        rm -f *.lo *.la *.o
+       rm -fr .libs/
 
 realclean:
        rm -f Makefile runmdn config.cache config.log config.status libtool
diff --git a/contrib/idn/mdnkit/tools/runmdn/ns_name.c b/contrib/idn/mdnkit/tools/runmdn/ns_name.c
deleted file mode 100644 (file)
index 2781302..0000000
+++ /dev/null
@@ -1,695 +0,0 @@
-/*
- * Copyright (c) 1996,1999 by Internet Software Consortium.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
- * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
- * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
- * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
- * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
- * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- */
-
-#ifndef lint
-static const char rcsid[] = "$Id: ns_name.c,v 1.5 2000/10/11 13:17:36 ishisone Exp $";
-#endif
-
-#include <sys/types.h>
-
-#include <netinet/in.h>
-#include <arpa/nameser.h>
-
-#include <errno.h>
-#include <resolv.h>
-#include <string.h>
-#include <ctype.h>
-
-#include <mdn/resconf.h>
-#include <mdn/res.h>
-
-#ifndef NS_CMPRSFLGS
-#define NS_CMPRSFLGS   0xc0
-#endif
-#ifndef NS_MAXCDNAME
-#define NS_MAXCDNAME   255
-#endif
-
-/* Data. */
-
-static const char      digits[] = "0123456789";
-
-static int             mdn_initialized = 0;
-static mdn_resconf_t   mdn_conf = NULL;
-
-/* Forward. */
-
-static int             special(int);
-static int             dn_find(const u_char *, const u_char *,
-                               const u_char * const *,
-                               const u_char * const *);
-static void            mdn_initialize(void);
-static const char      *convert_from_local(const char *local_name,
-                                           char *dns_name,
-                                           size_t dns_name_len);
-static const char      *convert_to_local(const char *dns_name,
-                                         char *local_name,
-                                         size_t local_name_len);
-
-/* Public. */
-
-/*
- * ns_name_ntop(src, dst, dstsiz)
- *     Convert an encoded domain name to printable ascii as per RFC1035.
- * return:
- *     Number of bytes written to buffer, or -1 (with errno set)
- * notes:
- *     The root is returned as "."
- *     All other domains are returned in non absolute form
- */
-int
-ns_name_ntop(const u_char *src, char *dst, size_t dstsiz) {
-       const u_char *cp;
-       char *dn, *eom;
-       u_char c;
-       u_int n;
-       char mdnbuf[256];
-
-       cp = src;
-       dn = mdnbuf;
-       eom = mdnbuf + sizeof(mdnbuf);
-
-       while ((n = *cp++) != 0) {
-               if ((n & NS_CMPRSFLGS) != 0) {
-                       /* Some kind of compression pointer. */
-                       errno = EMSGSIZE;
-                       return (-1);
-               }
-               if (dn != mdnbuf) {
-                       if (dn >= eom) {
-                               errno = EMSGSIZE;
-                               return (-1);
-                       }
-                       *dn++ = '.';
-               }
-               if (dn + n >= eom) {
-                       errno = EMSGSIZE;
-                       return (-1);
-               }
-               for ((void)NULL; n > 0; n--) {
-                       c = *cp++;
-                       if (special(c)) {
-                               if (dn + 1 >= eom) {
-                                       errno = EMSGSIZE;
-                                       return (-1);
-                               }
-                               *dn++ = '\\';
-                               *dn++ = (char)c;
-                       } else {
-                               if (dn >= eom) {
-                                       errno = EMSGSIZE;
-                                       return (-1);
-                               }
-                               *dn++ = (char)c;
-                       }
-               }
-       }
-       if (dn == mdnbuf) {
-               if (dn >= eom) {
-                       errno = EMSGSIZE;
-                       return (-1);
-               }
-               *dn++ = '.';
-       }
-       if (dn >= eom) {
-               errno = EMSGSIZE;
-               return (-1);
-       }
-       *dn++ = '\0';
-
-       n = dn - mdnbuf;
-       if (convert_to_local(mdnbuf, dst, dstsiz) == mdnbuf) {
-               if (dstsiz < n) {
-                       errno = EMSGSIZE;
-                       return (-1);
-               }
-               (void)memcpy(dst, mdnbuf, n);
-       }
-       return (n);
-}
-
-/*
- * For glibc-2.1, we want to define __ns_name_ntop() in addition with
- * ns_name_ntop().
- * However, on some systems the header files contain a macro that
- * expands ns_name_ntop into __ns_name_ntop, causing function redefinition
- * error.  To prevent the error, we prepend "__" to what is the result
- * of macro expansion of "ns_name_ntop".  This requires two macros below.
- */
-#define mdn_prepend(x) _mdn_prepend(x)
-#define _mdn_prepend(x) __ ## x
-int
-mdn_prepend(ns_name_ntop)(const u_char *src, char *dst, size_t dstsiz) {
-       return (ns_name_ntop(src, dst, dstsiz));
-}
-
-/*
- * ns_name_pton(src, dst, dstsiz)
- *     Convert a ascii string into an encoded domain name as per RFC1035.
- * return:
- *     -1 if it fails
- *     1 if string was fully qualified
- *     0 is string was not fully qualified
- * notes:
- *     Enforces label and domain length limits.
- */
-
-int
-ns_name_pton(const char *src, u_char *dst, size_t dstsiz) {
-       u_char *label, *bp, *eom;
-       int c, n, escaped;
-       char *cp;
-       char mdnbuf[256];
-
-       src = convert_from_local(src, mdnbuf, sizeof(mdnbuf));
-
-       escaped = 0;
-       bp = dst;
-       eom = dst + dstsiz;
-       label = bp++;
-
-       while ((c = *src++) != 0) {
-               if (c == '.') {
-                       c = (bp - label - 1);
-                       if ((c & NS_CMPRSFLGS) != 0) {  /* Label too big. */
-                               errno = EMSGSIZE;
-                               return (-1);
-                       }
-                       if (label >= eom) {
-                               errno = EMSGSIZE;
-                               return (-1);
-                       }
-                       *label = c;
-                       /* Fully qualified ? */
-                       if (*src == '\0') {
-                               if (c != 0) {
-                                       if (bp >= eom) {
-                                               errno = EMSGSIZE;
-                                               return (-1);
-                                       }
-                                       *bp++ = '\0';
-                               }
-                               if ((bp - dst) > MAXCDNAME) {
-                                       errno = EMSGSIZE;
-                                       return (-1);
-                               }
-                               return (1);
-                       }
-                       if (c == 0 || *src == '.') {
-                               errno = EMSGSIZE;
-                               return (-1);
-                       }
-                       label = bp++;
-                       continue;
-               }
-               if (bp >= eom) {
-                       errno = EMSGSIZE;
-                       return (-1);
-               }
-               *bp++ = (u_char)c;
-       }
-       c = (bp - label - 1);
-       if ((c & NS_CMPRSFLGS) != 0) {          /* Label too big. */
-               errno = EMSGSIZE;
-               return (-1);
-       }
-       if (label >= eom) {
-               errno = EMSGSIZE;
-               return (-1);
-       }
-       *label = c;
-       if (c != 0) {
-               if (bp >= eom) {
-                       errno = EMSGSIZE;
-                       return (-1);
-               }
-               *bp++ = 0;
-       }
-       if ((bp - dst) > MAXCDNAME) {   /* src too big */
-               errno = EMSGSIZE;
-               return (-1);
-       }
-       return (0);
-}
-
-/*
- * ns_name_ntol(src, dst, dstsiz)
- *     Convert a network strings labels into all lowercase.
- * return:
- *     Number of bytes written to buffer, or -1 (with errno set)
- * notes:
- *     Enforces label and domain length limits.
- */
-
-int
-ns_name_ntol(const u_char *src, u_char *dst, size_t dstsiz) {
-       const u_char *cp;
-       u_char *dn, *eom;
-       u_char c;
-       u_int n;
-
-       cp = src;
-       dn = dst;
-       eom = dst + dstsiz;
-
-       while ((n = *cp++) != 0) {
-               if ((n & NS_CMPRSFLGS) != 0) {
-                       /* Some kind of compression pointer. */
-                       errno = EMSGSIZE;
-                       return (-1);
-               }
-               *dn++ = n;
-               if (dn + n >= eom) {
-                       errno = EMSGSIZE;
-                       return (-1);
-               }
-               for ((void)NULL; n > 0; n--) {
-                       c = *cp++;
-                       if (c < 128 && isupper(c))
-                               *dn++ = tolower(c);
-                       else
-                               *dn++ = c;
-               }
-       }
-       *dn++ = '\0';
-       return (dn - dst);
-}
-
-/*
- * ns_name_unpack(msg, eom, src, dst, dstsiz)
- *     Unpack a domain name from a message, source may be compressed.
- * return:
- *     -1 if it fails, or consumed octets if it succeeds.
- */
-int
-ns_name_unpack(const u_char *msg, const u_char *eom, const u_char *src,
-              u_char *dst, size_t dstsiz)
-{
-       const u_char *srcp, *dstlim;
-       u_char *dstp;
-       int n, len, checked;
-
-       len = -1;
-       checked = 0;
-       dstp = dst;
-       srcp = src;
-       dstlim = dst + dstsiz;
-       if (srcp < msg || srcp >= eom) {
-               errno = EMSGSIZE;
-               return (-1);
-       }
-       /* Fetch next label in domain name. */
-       while ((n = *srcp++) != 0) {
-               /* Check for indirection. */
-               switch (n & NS_CMPRSFLGS) {
-               case 0:
-                       /* Limit checks. */
-                       if (dstp + n + 1 >= dstlim || srcp + n >= eom) {
-                               errno = EMSGSIZE;
-                               return (-1);
-                       }
-                       checked += n + 1;
-                       *dstp++ = n;
-                       memcpy(dstp, srcp, n);
-                       dstp += n;
-                       srcp += n;
-                       break;
-
-               case NS_CMPRSFLGS:
-                       if (srcp >= eom) {
-                               errno = EMSGSIZE;
-                               return (-1);
-                       }
-                       if (len < 0)
-                               len = srcp - src + 1;
-                       srcp = msg + (((n & 0x3f) << 8) | (*srcp & 0xff));
-                       if (srcp < msg || srcp >= eom) {  /* Out of range. */
-                               errno = EMSGSIZE;
-                               return (-1);
-                       }
-                       checked += 2;
-                       /*
-                        * Check for loops in the compressed name;
-                        * if we've looked at the whole message,
-                        * there must be a loop.
-                        */
-                       if (checked >= eom - msg) {
-                               errno = EMSGSIZE;
-                               return (-1);
-                       }
-                       break;
-
-               default:
-                       errno = EMSGSIZE;
-                       return (-1);                    /* flag error */
-               }
-       }
-       *dstp = '\0';
-       if (len < 0)
-               len = srcp - src;
-       return (len);
-}
-
-/*
- * ns_name_pack(src, dst, dstsiz, dnptrs, lastdnptr)
- *     Pack domain name 'domain' into 'comp_dn'.
- * return:
- *     Size of the compressed name, or -1.
- * notes:
- *     'dnptrs' is an array of pointers to previous compressed names.
- *     dnptrs[0] is a pointer to the beginning of the message. The array
- *     ends with NULL.
- *     'lastdnptr' is a pointer to the end of the array pointed to
- *     by 'dnptrs'.
- * Side effects:
- *     The list of pointers in dnptrs is updated for labels inserted into
- *     the message as we compress the name.  If 'dnptr' is NULL, we don't
- *     try to compress names. If 'lastdnptr' is NULL, we don't update the
- *     list.
- */
-int
-ns_name_pack(const u_char *src, u_char *dst, int dstsiz,
-            const u_char **dnptrs, const u_char **lastdnptr)
-{
-       u_char *dstp;
-       const u_char **cpp, **lpp, *eob, *msg;
-       const u_char *srcp;
-       int n, l;
-
-       srcp = src;
-       dstp = dst;
-       eob = dstp + dstsiz;
-       lpp = cpp = NULL;
-       if (dnptrs != NULL) {
-               if ((msg = *dnptrs++) != NULL) {
-                       for (cpp = dnptrs; *cpp != NULL; cpp++)
-                               (void)NULL;
-                       lpp = cpp;      /* end of list to search */
-               }
-       } else
-               msg = NULL;
-
-       /* make sure the domain we are about to add is legal */
-       l = 0;
-       do {
-               n = *srcp;
-               if ((n & NS_CMPRSFLGS) != 0) {
-                       errno = EMSGSIZE;
-                       return (-1);
-               }
-               l += n + 1;
-               if (l > MAXCDNAME) {
-                       errno = EMSGSIZE;
-                       return (-1);
-               }
-               srcp += n + 1;
-       } while (n != 0);
-
-       /* from here on we need to reset compression pointer array on error */
-       srcp = src;
-       do {
-               /* Look to see if we can use pointers. */
-               n = *srcp;
-               if (n != 0 && msg != NULL) {
-                       l = dn_find(srcp, msg, (const u_char * const *)dnptrs,
-                                   (const u_char * const *)lpp);
-                       if (l >= 0) {
-                               if (dstp + 1 >= eob) {
-                                       goto cleanup;
-                               }
-                               *dstp++ = (l >> 8) | NS_CMPRSFLGS;
-                               *dstp++ = l % 256;
-                               return (dstp - dst);
-                       }
-                       /* Not found, save it. */
-                       if (lastdnptr != NULL && cpp < lastdnptr - 1 &&
-                           (dstp - msg) < 0x4000) {
-                               *cpp++ = dstp;
-                               *cpp = NULL;
-                       }
-               }
-               /* copy label to buffer */
-               if (n & NS_CMPRSFLGS) {         /* Should not happen. */
-                       goto cleanup;
-               }
-               if (dstp + 1 + n >= eob) {
-                       goto cleanup;
-               }
-               memcpy(dstp, srcp, n + 1);
-               srcp += n + 1;
-               dstp += n + 1;
-       } while (n != 0);
-
-       if (dstp > eob) {
-cleanup:
-               if (msg != NULL)
-                       *lpp = NULL;
-               errno = EMSGSIZE;
-               return (-1);
-       } 
-       return (dstp - dst);
-}
-
-/*
- * ns_name_uncompress(msg, eom, src, dst, dstsiz)
- *     Expand compressed domain name to presentation format.
- * return:
- *     Number of bytes read out of `src', or -1 (with errno set).
- * note:
- *     Root domain returns as "." not "".
- */
-int
-ns_name_uncompress(const u_char *msg, const u_char *eom, const u_char *src,
-                  char *dst, size_t dstsiz)
-{
-       u_char tmp[NS_MAXCDNAME];
-       int n;
-       
-       if ((n = ns_name_unpack(msg, eom, src, tmp, sizeof tmp)) == -1)
-               return (-1);
-       if (ns_name_ntop(tmp, dst, dstsiz) == -1)
-               return (-1);
-       return (n);
-}
-
-/*
- * ns_name_compress(src, dst, dstsiz, dnptrs, lastdnptr)
- *     Compress a domain name into wire format, using compression pointers.
- * return:
- *     Number of bytes consumed in `dst' or -1 (with errno set).
- * notes:
- *     'dnptrs' is an array of pointers to previous compressed names.
- *     dnptrs[0] is a pointer to the beginning of the message.
- *     The list ends with NULL.  'lastdnptr' is a pointer to the end of the
- *     array pointed to by 'dnptrs'. Side effect is to update the list of
- *     pointers for labels inserted into the message as we compress the name.
- *     If 'dnptr' is NULL, we don't try to compress names. If 'lastdnptr'
- *     is NULL, we don't update the list.
- */
-int
-ns_name_compress(const char *src, u_char *dst, size_t dstsiz,
-                const u_char **dnptrs, const u_char **lastdnptr)
-{
-       u_char tmp[NS_MAXCDNAME];
-
-       if (ns_name_pton(src, tmp, sizeof tmp) == -1)
-               return (-1);
-       return (ns_name_pack(tmp, dst, dstsiz, dnptrs, lastdnptr));
-}
-
-/*
- * ns_name_skip(ptrptr, eom)
- *     Advance *ptrptr to skip over the compressed name it points at.
- * return:
- *     0 on success, -1 (with errno set) on failure.
- */
-int
-ns_name_skip(const u_char **ptrptr, const u_char *eom) {
-       const u_char *cp;
-       u_int n;
-
-       cp = *ptrptr;
-       while (cp < eom && (n = *cp++) != 0) {
-               /* Check for indirection. */
-               switch (n & NS_CMPRSFLGS) {
-               case 0:                 /* normal case, n == len */
-                       cp += n;
-                       continue;
-               case NS_CMPRSFLGS:      /* indirection */
-                       cp++;
-                       break;
-               default:                /* illegal type */
-                       errno = EMSGSIZE;
-                       return (-1);
-               }
-               break;
-       }
-       if (cp > eom) {
-               errno = EMSGSIZE;
-               return (-1);
-       }
-       *ptrptr = cp;
-       return (0);
-}
-
-/* Private. */
-
-/*
- * special(ch)
- *     Thinking in noninternationalized USASCII (per the DNS spec),
- *     is this characted special ("in need of quoting") ?
- * return:
- *     boolean.
- */
-static int
-special(int ch) {
-       switch (ch) {
-       case 0x22: /* '"' */
-       case 0x2E: /* '.' */
-       case 0x3B: /* ';' */
-       case 0x5C: /* '\\' */
-       /* Special modifiers in zone files. */
-       case 0x40: /* '@' */
-       case 0x24: /* '$' */
-               return (1);
-       default:
-               return (0);
-       }
-}
-
-/*
- *     Thinking in noninternationalized USASCII (per the DNS spec),
- *     convert this character to lower case if it's upper case.
- */
-static int
-mklower(int ch) {
-       if (ch >= 0x41 && ch <= 0x5A)
-               return (ch + 0x20);
-       return (ch);
-}
-
-/*
- * dn_find(domain, msg, dnptrs, lastdnptr)
- *     Search for the counted-label name in an array of compressed names.
- * return:
- *     offset from msg if found, or -1.
- * notes:
- *     dnptrs is the pointer to the first name on the list,
- *     not the pointer to the start of the message.
- */
-static int
-dn_find(const u_char *domain, const u_char *msg,
-       const u_char * const *dnptrs,
-       const u_char * const *lastdnptr)
-{
-       const u_char *dn, *cp, *sp;
-       const u_char * const *cpp;
-       u_int n;
-
-       for (cpp = dnptrs; cpp < lastdnptr; cpp++) {
-               dn = domain;
-               sp = cp = *cpp;
-               while ((n = *cp++) != 0) {
-                       /*
-                        * check for indirection
-                        */
-                       switch (n & NS_CMPRSFLGS) {
-                       case 0:                 /* normal case, n == len */
-                               if (n != *dn++)
-                                       goto next;
-                               for ((void)NULL; n > 0; n--)
-                                       if (mklower(*dn++) != mklower(*cp++))
-                                               goto next;
-                               /* Is next root for both ? */
-                               if (*dn == '\0' && *cp == '\0')
-                                       return (sp - msg);
-                               if (*dn)
-                                       continue;
-                               goto next;
-
-                       case NS_CMPRSFLGS:      /* indirection */
-                               cp = msg + (((n & 0x3f) << 8) | *cp);
-                               break;
-
-                       default:        /* illegal type */
-                               errno = EMSGSIZE;
-                               return (-1);
-                       }
-               }
- next: ;
-       }
-       errno = ENOENT;
-       return (-1);
-}
-
-/*
- * MDN support.
- */
-
-static void
-mdn_initialize() {
-       mdn_resconf_t ctx;
-
-       if (mdn_initialized)
-               return;
-
-       mdn_initialized = 1;
-       if (mdn_resconf_initialize() != mdn_success)
-               return;
-       if (mdn_resconf_create(&ctx) != mdn_success)
-               return;
-       if (mdn_resconf_loadfile(ctx, NULL) != mdn_success)
-               return;
-       mdn_conf = ctx;
-}
-
-static const char *
-convert_from_local(const char *local_name, char *dns_name,
-                  size_t dns_name_len)
-{
-       mdn_result_t r;
-       char buf1[256], buf2[256];
-
-       mdn_initialize();
-       r = mdn_res_localtoucs(mdn_conf, local_name, buf1, sizeof(buf1));
-       if (r != mdn_success)
-               return (local_name);
-       r = mdn_res_normalize(mdn_conf, buf1, buf2, sizeof(buf2));
-       if (r != mdn_success)
-               return (local_name);
-       r = mdn_res_ucstodns(mdn_conf, buf2, dns_name, dns_name_len);
-       if (r != mdn_success)
-               return (local_name);
-       return (dns_name);
-}
-
-static const char *
-convert_to_local(const char *dns_name, char *local_name,
-                size_t local_name_len)
-{
-       mdn_result_t r;
-       char buf[256];
-
-       mdn_initialize();
-       r = mdn_res_dnstoucs(mdn_conf, dns_name, buf, sizeof(buf));
-       if (r != mdn_success)
-               return (dns_name);
-       r = mdn_res_ucstolocal(mdn_conf, buf, local_name, local_name_len);
-       if (r != mdn_success)
-               return (dns_name);
-       return (local_name);
-}
diff --git a/contrib/idn/mdnkit/tools/runmdn/res_comp.c b/contrib/idn/mdnkit/tools/runmdn/res_comp.c
deleted file mode 100644 (file)
index 6382dc6..0000000
+++ /dev/null
@@ -1,238 +0,0 @@
-/*
- * Copyright (c) 1985, 1993
- *    The Regents of the University of California.  All rights reserved.
- * 
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 THE REGENTS OR CONTRIBUTORS 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 DAMAGE.
- */
-
-/*
- * Portions Copyright (c) 1993 by Digital Equipment Corporation.
- * 
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies, and that
- * the name of Digital Equipment Corporation not be used in advertising or
- * publicity pertaining to distribution of the document or software without
- * specific, written prior permission.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
- * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
- * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
- * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
- * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
- * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- */
-
-/*
- * Portions Copyright (c) 1996-1999 by Internet Software Consortium.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
- * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
- * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
- * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
- * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
- * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static const char sccsid[] = "@(#)res_comp.c   8.1 (Berkeley) 6/4/93";
-static const char rcsid[] = "$Id: res_comp.c,v 1.1 2000/07/07 06:58:22 ishisone Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <sys/types.h>
-#include <netinet/in.h>
-#include <arpa/nameser.h>
-#include <ctype.h>
-#include <resolv.h>
-#include <stdio.h>
-#include <string.h>
-
-/*
- * Expand compressed domain name 'comp_dn' to full domain name.
- * 'msg' is a pointer to the begining of the message,
- * 'eomorig' points to the first location after the message,
- * 'exp_dn' is a pointer to a buffer of size 'length' for the result.
- * Return size of compressed name or -1 if there was an error.
- */
-int
-dn_expand(const u_char *msg, const u_char *eom, const u_char *src,
-         char *dst, int dstsiz)
-{
-       int n = ns_name_uncompress(msg, eom, src, dst, (size_t)dstsiz);
-
-       if (n > 0 && dst[0] == '.')
-               dst[0] = '\0';
-       return (n);
-}
-
-/*
- * Pack domain name 'exp_dn' in presentation form into 'comp_dn'.
- * Return the size of the compressed name or -1.
- * 'length' is the size of the array pointed to by 'comp_dn'.
- */
-int
-dn_comp(const char *src, u_char *dst, int dstsiz,
-       u_char **dnptrs, u_char **lastdnptr)
-{
-       return (ns_name_compress(src, dst, (size_t)dstsiz,
-                                (const u_char **)dnptrs,
-                                (const u_char **)lastdnptr));
-}
-
-/*
- * Skip over a compressed domain name. Return the size or -1.
- */
-int
-dn_skipname(const u_char *ptr, const u_char *eom) {
-       const u_char *saveptr = ptr;
-
-       if (ns_name_skip(&ptr, eom) == -1)
-               return (-1);
-       return (ptr - saveptr);
-}
-
-/*
- * Verify that a domain name uses an acceptable character set.
- */
-
-/*
- * Note the conspicuous absence of ctype macros in these definitions.  On
- * non-ASCII hosts, we can't depend on string literals or ctype macros to
- * tell us anything about network-format data.  The rest of the BIND system
- * is not careful about this, but for some reason, we're doing it right here.
- */
-#define PERIOD 0x2e
-#define        hyphenchar(c) ((c) == 0x2d)
-#define bslashchar(c) ((c) == 0x5c)
-#define periodchar(c) ((c) == PERIOD)
-#define asterchar(c) ((c) == 0x2a)
-#ifdef NO_8BIT_THRU
-#define alphachar(c) (((c) >= 0x41 && (c) <= 0x5a) \
-                  || ((c) >= 0x61 && (c) <= 0x7a))
-#else
-#define alphachar(c) (1)
-#endif
-#define digitchar(c) ((c) >= 0x30 && (c) <= 0x39)
-
-#define borderchar(c) (alphachar(c) || digitchar(c))
-#define middlechar(c) (borderchar(c) || hyphenchar(c))
-#ifdef NO_8BIT_THRU
-#define        domainchar(c) ((c) > 0x20 && (c) < 0x7f)
-#else
-#define        domainchar(c) (1)
-#endif
-
-int
-res_hnok(const char *dn) {
-       int ppch = '\0', pch = PERIOD, ch = *dn++;
-
-       while (ch != '\0') {
-               int nch = *dn++;
-
-               if (periodchar(ch)) {
-                       (void)NULL;
-               } else if (periodchar(pch)) {
-                       if (!borderchar(ch))
-                               return (0);
-               } else if (periodchar(nch) || nch == '\0') {
-                       if (!borderchar(ch))
-                               return (0);
-               } else {
-                       if (!middlechar(ch))
-                               return (0);
-               }
-               ppch = pch, pch = ch, ch = nch;
-       }
-       return (1);
-}
-
-/*
- * hostname-like (A, MX, WKS) owners can have "*" as their first label
- * but must otherwise be as a host name.
- */
-int
-res_ownok(const char *dn) {
-       if (asterchar(dn[0])) {
-               if (periodchar(dn[1]))
-                       return (res_hnok(dn+2));
-               if (dn[1] == '\0')
-                       return (1);
-       }
-       return (res_hnok(dn));
-}
-
-/*
- * SOA RNAMEs and RP RNAMEs can have any printable character in their first
- * label, but the rest of the name has to look like a host name.
- */
-int
-res_mailok(const char *dn) {
-       int ch, escaped = 0;
-
-       /* "." is a valid missing representation */
-       if (*dn == '\0')
-               return (1);
-
-       /* otherwise <label>.<hostname> */
-       while ((ch = *dn++) != '\0') {
-               if (!domainchar(ch))
-                       return (0);
-               if (!escaped && periodchar(ch))
-                       break;
-               if (escaped)
-                       escaped = 0;
-               else if (bslashchar(ch))
-                       escaped = 1;
-       }
-       if (periodchar(ch))
-               return (res_hnok(dn));
-       return (0);
-}
-
-/*
- * This function is quite liberal, since RFC 1034's character sets are only
- * recommendations.
- */
-int
-res_dnok(const char *dn) {
-       int ch;
-
-       while ((ch = *dn++) != '\0')
-               if (!domainchar(ch))
-                       return (0);
-       return (1);
-}
diff --git a/contrib/idn/mdnkit/tools/runmdn/resolver.c b/contrib/idn/mdnkit/tools/runmdn/resolver.c
new file mode 100644 (file)
index 0000000..e545218
--- /dev/null
@@ -0,0 +1,1049 @@
+#ifndef lint
+static char *rcsid = "$Id: resolver.c,v 1.1 2001/06/09 00:30:50 tale 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+ * Tokyo, 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) Japan Network Information Center.  All rights reserved."
+ * 
+ * 4. Neither the name of JPNIC may 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.
+ * 
+ * 6. Indemnification by Licensee
+ *    Any person or entities using and/or redistributing this Software under
+ *    this License Terms and Conditions shall defend indemnify and hold
+ *    harmless JPNIC from and against any and all judgements damages,
+ *    expenses, settlement liabilities, cost and other liabilities of any
+ *    kind as a result of use and redistribution of this Software or any
+ *    claim, suite, action, litigation or proceeding by any third party
+ *    arising out of or relates to this License Terms and Conditions.
+ * 
+ * 7. Governing Law, Jurisdiction and Venue
+ *    This License Terms and Conditions shall be governed by and and
+ *    construed in accordance with the law of Japan. Any person or entities
+ *    using and/or redistributing this Software under this License Terms and
+ *    Conditions hereby agrees and consent to the personal and exclusive
+ *    jurisdiction and venue of Tokyo District Court of Japan.
+ */
+
+#include <config.h>
+
+#include <stdio.h>
+#include <stddef.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netdb.h>
+#include <errno.h>
+
+#include <mdn/api.h>
+#include <mdn/log.h>
+#include <mdn/logmacro.h>
+#include <mdn/debug.h>
+
+#ifdef FOR_RUNMDN
+/*
+ * This file is specially compiled for runmdn.
+ * Runmdn replaces existing resolver functions dynamically with ones
+ * with MDN 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) mdn_stub_ ## name
+#else
+/*
+ * For normal use.  All the entry names are prefixed with "mdn_resolver_".
+ * <mdn/resolver.h> has bunch of #defines to substitute the standard
+ * name resolver functions with ones provided here.
+ */
+#include <mdn/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) mdn_resolver_ ## name
+#define REAL(name) name
+#endif
+
+#define MDN_NAME_SIZE          512
+
+#define MDN_HOSTBUF_SIZE       2048
+typedef union {
+       char *dummy_for_alignment;
+       char data[MDN_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 MDN 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 mdn_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.
+                */
+               mdn_result_t r;
+               size_t slen;
+
+               r = mdn_decodename(MDN_DECODE_APP, hp->h_name,
+                                  buf, buflen);
+               switch (r) {
+               case mdn_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 mdn_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++) {
+                       mdn_result_t r;
+                       size_t slen;
+
+                       r = mdn_decodename(MDN_DECODE_APP, aliases[i],
+                                          buf, buflen);
+
+                       switch (r) {
+                       case mdn_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 mdn_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) {
+       mdn_result_t r;
+       char buf[MDN_NAME_SIZE];
+       char *s;
+
+       r = mdn_decodename(MDN_DECODE_APP, name, buf, sizeof(buf));
+       if (r == mdn_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;
+       mdn_result_t r;
+       struct hostent *hp;
+
+       if (mdn_isprocessing)
+               return (REAL(gethostbyname)(name));
+
+       TRACE(("gethostbyname(name=%s)\n", mdn_debug_xstring(name, 60)));
+
+       mdn_isprocessing = 1;
+       r = mdn_encodename(MDN_ENCODE_APP, name, buf.data, sizeof(buf));
+       if (r == mdn_success)
+               name = buf.data;
+
+       hp = copy_decode_hostent_static(REAL(gethostbyname)(name),
+                                       &he, buf.data, sizeof(buf),
+                                       &h_errno);
+       mdn_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;
+       mdn_result_t r;
+       struct hostent *hp;
+
+       if (mdn_isprocessing)
+               return (REAL(gethostbyname2)(name, af));
+
+       TRACE(("gethostbyname2(name=%s)\n", mdn_debug_xstring(name, 60), af));
+
+       mdn_isprocessing = 1;
+       r = mdn_encodename(MDN_ENCODE_APP, name, buf.data, sizeof(buf));
+       if (r == mdn_success)
+               name = buf.data;
+
+       hp = copy_decode_hostent_static(REAL(gethostbyname2)(name, af),
+                                       &he, buf.data, sizeof(buf),
+                                       &h_errno);
+       mdn_isprocessing = 0;
+       return (hp);
+}
+#endif
+
+#ifdef HAVE_GETHOSTBYADDR
+struct hostent *
+ENTRY(gethostbyaddr)(const char *addr, GHBA_ADDRLEN_T len, int type) {
+       static hostbuf_t buf;
+       static struct hostent he;
+       struct hostent *hp;
+
+       if (mdn_isprocessing)
+               return (REAL(gethostbyaddr)(addr, len, type));
+
+       TRACE(("gethostbyaddr()\n"));
+
+       mdn_isprocessing = 1;
+       hp = copy_decode_hostent_static(REAL(gethostbyaddr)(addr, len, type),
+                                       &he, buf.data, sizeof(buf),
+                                       &h_errno);
+       mdn_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[MDN_NAME_SIZE];
+       char *data;
+       size_t datalen;
+       mdn_result_t r;
+       struct hostent *hp, he;
+       hostbuf_t buf;
+       int n;
+
+       if (mdn_isprocessing)
+               return (REAL(gethostbyname_r)(name, result, buffer,
+                                             buflen, rp, errp));
+
+       TRACE(("gethostbyname_r(name=%s,buflen=%d)\n",
+              mdn_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);
+               }
+       }
+
+       mdn_isprocessing = 1;
+       r = mdn_encodename(MDN_ENCODE_APP, name, namebuf, sizeof(namebuf));
+       if (r == mdn_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);
+       mdn_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[MDN_NAME_SIZE];
+       char *data;
+       size_t datalen;
+       mdn_result_t r;
+       struct hostent *hp, he;
+       hostbuf_t buf;
+       int n;
+
+       if (mdn_isprocessing)
+               return (REAL(gethostbyname2_r)(name, af, result, buffer,
+                                              buflen, rp, errp));
+
+       TRACE(("gethostbyname2_r(name=%s,buflen=%d)\n",
+              mdn_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);
+               }
+       }
+
+       mdn_isprocessing = 1;
+       r = mdn_encodename(MDN_ENCODE_APP, name, namebuf, sizeof(namebuf));
+       if (r == mdn_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);
+       mdn_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)(const char *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 *hp, he;
+       hostbuf_t buf;
+       int n;
+
+       if (mdn_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);
+               }
+       }
+
+       mdn_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);
+       mdn_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[MDN_NAME_SIZE];
+       char *data;
+       size_t datalen;
+       mdn_result_t r;
+       struct hostent *hp, he;
+       hostbuf_t buf;
+
+       if (mdn_isprocessing)
+               return (REAL(gethostbyname_r)(name, result, buffer,
+                                             buflen, errp));
+
+       TRACE(("gethostbyname_r(name=%s,buflen=%d)\n",
+              mdn_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);
+               }
+       }
+
+       mdn_isprocessing = 1;
+       r = mdn_encodename(MDN_ENCODE_APP, name, namebuf, sizeof(namebuf));
+       if (r == mdn_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);
+       mdn_isprocessing = 0;
+
+       if (data != buf.data)
+               free(data);
+
+       return (hp);
+}
+#endif
+
+#ifdef HAVE_GETHOSTBYADDR_R
+struct hostent *
+ENTRY(gethostbyaddr_r)(const char *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 (mdn_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);
+               }
+       }
+
+       mdn_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);
+       mdn_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[MDN_NAME_SIZE];
+       mdn_result_t r;
+       struct hostent *hp;
+
+       if (mdn_isprocessing)
+               return (REAL(getipnodebyname)(name, af, flags, errp));
+
+       TRACE(("getipnodebyname(name=%s)\n", mdn_debug_xstring(name, 60), af));
+
+       mdn_isprocessing = 1;
+       r = mdn_encodename(MDN_ENCODE_APP, name, namebuf, sizeof(namebuf));
+       if (r == mdn_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;
+               }
+       }
+       mdn_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 (mdn_isprocessing)
+               return (REAL(getipnodebyaddr)(src, len, af, errp));
+
+       TRACE(("getipnodebyaddr()\n"));
+
+       mdn_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;
+               }
+       }
+       mdn_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[MDN_NAME_SIZE];
+       mdn_result_t r;
+       struct addrinfo *aip;
+       int err;
+
+       if (nodename == NULL || mdn_isprocessing)
+               return (REAL(getaddrinfo)(nodename, servname, hints, res));
+
+       TRACE(("getaddrinfo(nodename=%s)\n", mdn_debug_xstring(nodename, 60)));
+
+       mdn_isprocessing = 1;
+       r = mdn_encodename(MDN_ENCODE_APP, nodename,
+                          namebuf, sizeof(namebuf));
+       if (r == mdn_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);
+       }
+       mdn_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, socklen_t salen,
+                  char *host, size_t hostlen, char *serv, size_t servlen,
+                  int flags)
+{
+       char name[MDN_NAME_SIZE];
+       size_t namelen = sizeof(name);
+       int code;
+       mdn_result_t r;
+
+       if (host == NULL || hostlen == 0 || mdn_isprocessing) {
+               return (REAL(getnameinfo)(sa, salen, host, hostlen,
+                                         serv, servlen, flags));
+       }
+
+       TRACE(("getnameinfo(hostlen=%u)\n", hostlen));
+
+       mdn_isprocessing = 1;
+       code = REAL(getnameinfo)(sa, salen, name, namelen,
+                                serv, servlen, flags);
+       if (code == 0 && name[0] != '\0') {
+               r = mdn_decodename(MDN_DECODE_APP, name, host, hostlen);
+               switch (r) {
+               case mdn_success:
+                       code = 0;
+                       break;
+               case mdn_buffer_overflow:
+               case mdn_nomemory:
+                       code = EAI_MEMORY;
+                       break;
+               default:
+                       code = EAI_FAIL;
+                       break;
+               }
+       }
+       mdn_isprocessing = 0;
+       return (code);
+}
+#endif
index 38c6e0ccd9bb4bf9a00395592576aa4ac03a3a41..c21c32ac066c63e96bde08eb6c644081b095f4a5 100644 (file)
@@ -1,6 +1,7 @@
-.\" $Id: runmdn.1,v 1.3 2000/09/08 05:58:39 ishisone Exp $
+.\" $Id: runmdn.1,v 1.7 2001/04/23 05:56:27 ishisone Exp $
 .\"
-.\" Copyright (c) 2000 Japan Network Information Center.  All rights reserved.
+.\" 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.
 .\" 
@@ -56,7 +57,7 @@
 .\"    Conditions hereby agrees and consent to the personal and exclusive
 .\"    jurisdiction and venue of Tokyo District Court of Japan.
 .\"
-.TH MDNCONV 1 "July 7, 2000"
+.TH RUNMDN 1 "April 6, 2001"
 .\"
 .SH NAME
 runmdn \- A script to allow applications to use multilingual domain names.
@@ -77,9 +78,9 @@ can handle non-ASCII domain names.  For example, you can do:
 .RE
 .PP
 Before using runmdn, you should set up properties related to
-multilingual DNS by configuring mDNkit's resolver configuration file
-\fBmdnres.conf\fP.
-See mdnres.conf(5) which describes the configuration.
+multilingual DNS by configuring mDNkit's configuration file
+\fBmdn.conf\fP.
+See mdn.conf(5) which describes the configuration.
 .\"
 .SH IMPLEMENTATION
 .B runmdn
@@ -87,7 +88,7 @@ is a small shell script that sets up an environment variable called
 ``LD_PRELOAD'', so that an application dynamically links a shared
 library ``libmdnresolv'' before any other shared libraries.
 .PP
-The library ``libmdnresolv'' provides a special version of some
+The library ``libmdnresolv'' provides a special version of
 resolver functions which implement features for handling multilingual
 domain names.
 .B runmdn
@@ -96,25 +97,29 @@ replaces the following functions with the special version:
 .RS 4
 .nf
 .ft CW
-dn_comp
-dn_expand
-res_hnok
-res_ownok
-res_mailok
-res_dnok
+gethostbyname
+gethostbyname2
+gethostbyaddr
+gethostbyname_r
+gethostbyname2_r
+gethostbyaddr_r
+getipnodebyname
+getipnodebyaddr
+freehostent
+getaddrinfo
+freeaddrinfo
+getnameinfo
 .ft R
 .fi
 .RE
 .PP
-These are the crucial functions in resolver library for multilingual
-domain name processing.
 By overriding them in the standard libraries with the special version
 provided by ``libmdnresolv'',
 .B runmdn
 enables applications to use multilingual domain names.
 .RS 4
 .IP \(bu 2
-Resolver API (such as gethostbyname()) accepts non-ASCII domain names
+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
@@ -125,20 +130,21 @@ automatically, so users/applications need not worry about them.
 .PP
 Properties of multilingual DNS (such as the normalization or the codeset
 used on DNS protocol data) can be configured with the mDNkit's
-resolver configuration file (
-.B mdnres.conf
-).  See mdnres.conf(5) for details.
+configuration file (
+.B mdn.conf
+).  See mdn.conf(5) for details.
 .\"
-.SH "BIND 9"
+.SH NOTE
+By default,
 .B runmdn
-is designed for BIND4 and BIND8 based resolver libraries.
-Since BIND9 introduces a completely different resolver called ``light-weight
-resolver'', runmdn cannot be used for applications using BIND9 based resolver.
+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 ``MDN_LOCAL_CODESET''.
+See the section ``LOCAL CODESET'' in mdn.conf(5) for details.
 .PP
-Since mDNkit also contains a patch to BIND9 source which makes BIND9
-multilingual-aware, use the patch to multilingualize your BIND9 based
-resolver.
-.SH NOTE
 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.
@@ -154,7 +160,7 @@ setuid programs in any sane systems.  So
 .B runmdn
 does not work for setuid programs such as ping or rsh.
 .PP
-If your system's resolver is an exotic one that does not use
-the functions libmdnresolv provides, you lose.
+If your application uses a function other than the ones runmdn supports for
+name resolution, you lose.
 .SH "SEE ALSO"
-mdnres.conf(5), runsocks(1)
+mdn.conf(5), runsocks(1)
diff --git a/contrib/idn/mdnkit/tools/runmdn/stub.c b/contrib/idn/mdnkit/tools/runmdn/stub.c
new file mode 100644 (file)
index 0000000..5264f61
--- /dev/null
@@ -0,0 +1,390 @@
+#ifndef lint
+static char *rcsid = "$Id: stub.c,v 1.1 2001/06/09 00:30:51 tale 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+ * Tokyo, 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) Japan Network Information Center.  All rights reserved."
+ * 
+ * 4. Neither the name of JPNIC may 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.
+ * 
+ * 6. Indemnification by Licensee
+ *    Any person or entities using and/or redistributing this Software under
+ *    this License Terms and Conditions shall defend indemnify and hold
+ *    harmless JPNIC from and against any and all judgements damages,
+ *    expenses, settlement liabilities, cost and other liabilities of any
+ *    kind as a result of use and redistribution of this Software or any
+ *    claim, suite, action, litigation or proceeding by any third party
+ *    arising out of or relates to this License Terms and Conditions.
+ * 
+ * 7. Governing Law, Jurisdiction and Venue
+ *    This License Terms and Conditions shall be governed by and and
+ *    construed in accordance with the law of Japan. Any person or entities
+ *    using and/or redistributing this Software under this License Terms and
+ *    Conditions hereby agrees and consent to the personal and exclusive
+ *    jurisdiction and venue of Tokyo District Court of Japan.
+ */
+
+#include <config.h>
+
+#include <stdarg.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netdb.h>
+#include <errno.h>
+#ifdef HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#include <mdn/logmacro.h>
+#include <mdn/debug.h>
+
+#include "stub.h"
+
+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 },
+};
+
+static void    *shared_obj_open(const char *path);
+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);
+
+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);
+}
+
+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] = '_';
+       name = strcpy(namebuf + 1, name);
+
+       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) {
+       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);
+                       }
+               }
+       }
+       TRACE(("stub: %s not found\n", name));
+       return (NULL);
+}
+
+#ifdef HAVE_GETHOSTBYNAME
+struct hostent *
+mdn_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 *
+mdn_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 *
+mdn_stub_gethostbyaddr(const char *addr, GHBA_ADDRLEN_T len, int type) {
+       static struct hostent *(*fp)(const char *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
+mdn_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
+mdn_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
+mdn_stub_gethostbyaddr_r(const char *addr, GHBA_ADDRLEN_T len, int type,
+                        struct hostent *result, char *buffer,
+                        size_t buflen, struct hostent **rp, int *errp)
+{
+       static int (*fp)(const char *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 *
+mdn_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 *
+mdn_stub_gethostbyaddr_r(const char *addr, int len, int type,
+                        struct hostent *result, char *buffer,
+                        int buflen, int *errp)
+{
+       static struct hostent *(*fp)(const char *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 *
+mdn_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 *
+mdn_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
+mdn_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
+mdn_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
+mdn_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
+mdn_stub_getnameinfo(const struct sockaddr *sa, socklen_t salen,
+                    char *host, size_t hostlen, char *serv, size_t servlen,
+                    int flags)
+{
+       static int (*fp)(const struct sockaddr *sa, socklen_t salen,
+                        char *host, size_t hostlen,
+                        char *serv, size_t servlen,
+                        int 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/mdnkit/tools/runmdn/stub.h b/contrib/idn/mdnkit/tools/runmdn/stub.h
new file mode 100644 (file)
index 0000000..ffe4177
--- /dev/null
@@ -0,0 +1,94 @@
+/* $Id: stub.h,v 1.1 2001/06/09 00:30:51 tale Exp $ */
+
+#ifndef STUB_H
+#define STUB_H
+
+#ifdef HAVE_GETHOSTBYNAME
+extern struct hostent *
+mdn_stub_gethostbyname(const char *name);
+#endif
+
+#ifdef GETHOST_R_GLIBC_FLAVOR
+#ifdef HAVE_GETHOSTBYNAME_R
+extern int
+mdn_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 *
+mdn_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 *
+mdn_stub_gethostbyname2(const char *name, int af);
+#endif
+
+#ifdef GETHOST_R_GLIBC_FLAVOR
+#ifdef HAVE_GETHOSTBYNAME2_R
+extern int
+mdn_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 *
+mdn_stub_gethostbyaddr(const char *addr, GHBA_ADDRLEN_T len, int type);
+#endif
+
+#ifdef GETHOST_R_GLIBC_FLAVOR
+#ifdef HAVE_GETHOSTBYADDR_R
+extern int
+mdn_stub_gethostbyaddr_r(const char *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 *
+mdn_stub_gethostbyaddr_r(const char *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 *
+mdn_stub_getipnodebyname(const char *name, int af, int flags, int *errp);
+#endif
+
+#ifdef HAVE_GETIPNODEBYADDR
+extern struct hostent *
+mdn_stub_getipnodebyaddr(const void *src, size_t len, int af, int *errp);
+#endif
+
+#ifdef HAVE_FREEHOSTENT
+extern void
+mdn_stub_freehostent(struct hostent *hp);
+#endif
+
+#ifdef HAVE_GETADDRINFO
+extern int
+mdn_stub_getaddrinfo(const char *nodename, const char *servname,
+                    const struct addrinfo *hints, struct addrinfo **res);
+#endif
+
+#ifdef HAVE_FREEADDRINFO
+extern void
+mdn_stub_freeaddrinfo(struct addrinfo *aip);
+#endif
+
+#ifdef HAVE_GETNAMEINFO
+extern int
+mdn_stub_getnameinfo(const struct sockaddr *sa, socklen_t salen,
+                    char *host, size_t hostlen, char *serv, size_t servlen,
+                    int flags);
+#endif
+
+#endif /* STUB_H */
diff --git a/contrib/idn/mdnkit/util/SparseMap.pm b/contrib/idn/mdnkit/util/SparseMap.pm
new file mode 100644 (file)
index 0000000..94742ab
--- /dev/null
@@ -0,0 +1,591 @@
+# $Id: SparseMap.pm,v 1.1 2001/06/09 00:30:51 tale 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+# Tokyo, Japan.
+# 
+# 1. Use, Modification and Redistribution (including distribution of any
+#    modified or derived work) in source and/or binary forms is 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) Japan Network Information Center.  All rights reserved."
+# 
+# 4. Neither the name of JPNIC may 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.
+# 
+# 6. Indemnification by Licensee
+#    Any person or entities using and/or redistributing this Software under
+#    this License Terms and Conditions shall defend indemnify and hold
+#    harmless JPNIC from and against any and all judgements damages,
+#    expenses, settlement liabilities, cost and other liabilities of any
+#    kind as a result of use and redistribution of this Software or any
+#    claim, suite, action, litigation or proceeding by any third party
+#    arising out of or relates to this License Terms and Conditions.
+# 
+# 7. Governing Law, Jurisdiction and Venue
+#    This License Terms and Conditions shall be governed by and and
+#    construed in accordance with the law of Japan. Any person or entities
+#    using and/or redistributing this Software under this License Terms and
+#    Conditions hereby agrees and consent to the personal and exclusive
+#    jurisdiction and venue of Tokyo District Court of Japan.
+#
+
+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 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 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 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/mdnkit/util/UCD.pm b/contrib/idn/mdnkit/util/UCD.pm
new file mode 100644 (file)
index 0000000..6307554
--- /dev/null
@@ -0,0 +1,210 @@
+# $Id: UCD.pm,v 1.1 2001/06/09 00:30:51 tale 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+# Tokyo, Japan.
+# 
+# 1. Use, Modification and Redistribution (including distribution of any
+#    modified or derived work) in source and/or binary forms is 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) Japan Network Information Center.  All rights reserved."
+# 
+# 4. Neither the name of JPNIC may 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.
+# 
+# 6. Indemnification by Licensee
+#    Any person or entities using and/or redistributing this Software under
+#    this License Terms and Conditions shall defend indemnify and hold
+#    harmless JPNIC from and against any and all judgements damages,
+#    expenses, settlement liabilities, cost and other liabilities of any
+#    kind as a result of use and redistribution of this Software or any
+#    claim, suite, action, litigation or proceeding by any third party
+#    arising out of or relates to this License Terms and Conditions.
+# 
+# 7. Governing Law, Jurisdiction and Venue
+#    This License Terms and Conditions shall be governed by and and
+#    construed in accordance with the law of Japan. Any person or entities
+#    using and/or redistributing this Software under this License Terms and
+#    Conditions hereby agrees and consent to the personal and exclusive
+#    jurisdiction and venue of Tokyo District Court of Japan.
+#
+
+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/mdnkit/util/generate_nameprep_data.pl b/contrib/idn/mdnkit/util/generate_nameprep_data.pl
new file mode 100644 (file)
index 0000000..96165b4
--- /dev/null
@@ -0,0 +1,319 @@
+#! /usr/local/bin/perl -w
+# $Id: generate_nameprep_data.pl,v 1.1 2001/06/09 00:30:51 tale 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+# Tokyo, Japan.
+# 
+# 1. Use, Modification and Redistribution (including distribution of any
+#    modified or derived work) in source and/or binary forms is 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) Japan Network Information Center.  All rights reserved."
+# 
+# 4. Neither the name of JPNIC may 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.
+# 
+# 6. Indemnification by Licensee
+#    Any person or entities using and/or redistributing this Software under
+#    this License Terms and Conditions shall defend indemnify and hold
+#    harmless JPNIC from and against any and all judgements damages,
+#    expenses, settlement liabilities, cost and other liabilities of any
+#    kind as a result of use and redistribution of this Software or any
+#    claim, suite, action, litigation or proceeding by any third party
+#    arising out of or relates to this License Terms and Conditions.
+# 
+# 7. Governing Law, Jurisdiction and Venue
+#    This License Terms and Conditions shall be governed by and and
+#    construed in accordance with the law of Japan. Any person or entities
+#    using and/or redistributing this Software under this License Terms and
+#    Conditions hereby agrees and consent to the personal and exclusive
+#    jurisdiction and venue of Tokyo District Court of Japan.
+#
+
+use v5.6.0;            # for pack('U')
+
+use lib qw(.);
+
+use SparseMap;
+use Getopt::Long;
+
+(my $myid = '$Id: generate_nameprep_data.pl,v 1.1 2001/06/09 00:30:51 tale Exp $') =~ s/\$([^\$]+)\$/\$-$1-\$/;
+
+my @map_bits = (9, 7, 5);
+my @proh_bits = (7, 7, 7);
+my @unas_bits = (7, 7, 7);
+
+my $dir = '.';
+
+GetOptions('dir=s', \$dir) or die usage();
+
+print_header();
+
+bits_definition("MAP", @map_bits);
+bits_definition("PROH", @proh_bits);
+bits_definition("UNAS", @unas_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 mapping data.
+#
+sub generate_mapdata {
+    my $version = shift;
+    my $file = shift;
+    my $top = 1;
+
+    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 ($top and /^%\s*SAME-AS\s+(\S+)/) {
+           generate_map_ref($version, $1);
+           close FILE;
+           return;
+       }
+       $top = 0;
+       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 $top = 1;
+
+    my $proh = SparseMap::Bit->new(BITS => [@proh_bits],
+                                  MAX => 0x110000);
+    open FILE, $file or die "cannot open $file: $!\n";
+    while (<FILE>) {
+       if ($top and /^%\s*SAME-AS\s+(\S+)/) {
+           generate_prohibited_ref($version, $1);
+           close FILE;
+           return;
+       }
+       $top = 0;
+       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 $top = 1;
+
+    my $unas = SparseMap::Bit->new(BITS => [@unas_bits],
+                                  MAX => 0x110000);
+    open FILE, $file or die "cannot open $file: $!\n";
+    while (<FILE>) {
+       if ($top and /^%\s*SAME-AS\s+(\S+)/) {
+           generate_unassigned_ref($version, $1);
+           close FILE;
+           return;
+       }
+       $top = 0;
+       next if /^\#/;
+       next if /^\s*$/;
+       register_unassigned($unas, $_);
+    }
+    close FILE;
+    generate_unassigned($version, $unas);
+}
+
+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 $utf8 = pack 'U*', @tcode;
+
+    my $offset;
+    if (exists $hashref->{$utf8}) {
+       $offset = $hashref->{$utf8};
+    } else {
+       $offset = length $$bufref;
+       $$bufref .= $utf8 . "\0";
+       $hashref->{$utf8} = $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 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 generate_prohibited {
+    my ($version, $proh) = @_;
+    generate_bitmap($proh, "nameprep_${version}_prohibited");
+}
+
+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");
+}
+
+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 register_bitmap {
+    my $bm = shift;
+    my $line = shift;
+
+    /^([0-9A-Fa-f]+)(?:-([0-9A-Fa-f]+))?/ or die "unrecognized line: $line";
+    my $v1 = hex($1);
+    my $v2 = defined($2) ? hex($2) : undef;
+    if (defined $v2) {
+       $bm->add($v1 .. $v2);
+    } else {
+       $bm->add($v1);
+    }
+}
+
+sub generate_bitmap {
+    my $bm = shift;
+    my $name = shift;
+    $bm->fix();
+    #$map->stat();
+    print $bm->cprog(NAME => $name);
+}
index 5e797a221d32eba8686313df5dd8935b917c8fa5..27d78452ea4be97e132010f07178e0d640a0e13e 100644 (file)
@@ -1,7 +1,8 @@
 #! /usr/local/bin/perl -w
-# $Id: generate_normalize_data.pl,v 1.4 2000/09/27 02:55:40 ishisone Exp $
+# $Id: generate_normalize_data.pl,v 1.5 2001/02/13 07:34:02 ishisone Exp $
 #
-# Copyright (c) 2000 Japan Network Information Center.  All rights reserved.
+# 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.
 # 
 #
 
 # 
-# Generate lib/unicodedata.c from UnicodeData.txt and
-# CompositionExclusions-1.txt, both available from
-# ftp://ftp.unicode.org/Public/UNIDATA/.
-#
-# Usage: generate_normalize_data.pl UnicodeData.txt CompositionExclusions-1.txt
+# 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/.
 #
 
-package Unicode::UnicodeData;
 use strict;
-use integer;
-use vars qw(@ISA @EXPORT_OK %EXPORT_TAGS);
-use Exporter;
-use Carp;
-
-@ISA = qw(Exporter);
-
-@EXPORT_OK = qw(code_value character_name general_category
-               canonical_combining_class bidirectional_category
-               character_decomposition_mapping
-               decimal_digit_value digit_value numeric_value
-               mirrored unicode_10_name iso10646_comment_field
-               uppercase_mapping lowercase_mapping
-               titlecase_mapping composition_exclusion
-               specialcasing_source specialcasing_type
-               specialcasing_mapping specialcasing_cond);
-
-%EXPORT_TAGS =
-    (accessor => [qw(code_value character_name general_category
-                    canonical_combining_class bidirectional_category
-                    character_decomposition_mapping
-                    decimal_digit_value digit_value numeric_value
-                    mirrored unicode_10_name iso10646_comment_field
-                    uppercase_mapping lowercase_mapping
-                    titlecase_mapping composition_exclusion
-                    specialcasing_source specialcasing_type
-                    specialcasing_mapping specialcasing_cond)]);
-
-my @unicode_data;
-my @composition_exclusion;
-my %composition_exclusion;
-my @unicode_bycode;
-my %unicode_byname;
-my @specialcasing_data;
-
-sub CODE {0;}
-sub NAME {1;}
-sub CATEGORY {2;}
-sub CLASS {3;}
-sub BIDIRECTIONAL {4;}
-sub DECOMPOSITION {5;}
-sub DECIMAL {6;}
-sub DIGIT {7;}
-sub NUMERIC {8;}
-sub MIRRORED {9;}
-sub OLDNAME {10;}
-sub COMMENT {11;}
-sub UPPERCASE {12;}
-sub LOWERCASE {13;}
-sub TITLECASE {14;}
-sub EXCLUSION {15;}
-
-sub code_value ($) {
-    hex((split /;/, $_[0], 2+CODE)[CODE]);
-}
-sub character_name ($) {
-    my $s = (split /;/, $_[0], 2+NAME)[NAME];
-}
-sub general_category ($) {
-    (split /;/, $_[0], 2+CATEGORY)[CATEGORY];
-}
-sub canonical_combining_class ($) {
-    (split /;/, $_[0], 2+CLASS)[CLASS] + 0;
-}
-sub bidirectional_category ($) {
-    (split /;/, $_[0], 2+BIDIRECTIONAL)[BIDIRECTIONAL];
-}
-sub character_decomposition_mapping ($) {
-    dcmap((split /;/, $_[0], 2+DECOMPOSITION)[DECOMPOSITION]);
-}
-sub decimal_digit_value ($) {
-    dvalue((split /;/, $_[0], 2+DECIMAL)[DECIMAL]);
-}
-sub digit_value ($) {
-    dvalue((split /;/, $_[0], 2+DIGIT)[DIGIT]);
-}
-sub numeric_value ($) {
-    dvalue((split /;/, $_[0], 2+NUMERIC)[NUMERIC]);
-}
-sub mirrored ($) {
-    (split /;/, $_[0], 2+MIRRORED)[MIRRORED] eq 'Y';
-}
-sub unicode_10_name ($) {
-    (split /;/, $_[0], 2+OLDNAME)[OLDNAME];
-}
-sub iso10646_comment_field ($) {
-    (split /;/, $_[0], 2+COMMENT)[COMMENT];
-}
-sub uppercase_mapping ($) {
-    ucode((split /;/, $_[0], 2+UPPERCASE)[UPPERCASE]);
-}
-sub lowercase_mapping ($) {
-    ucode((split /;/, $_[0], 2+LOWERCASE)[LOWERCASE]);
-}
-sub titlecase_mapping ($) {
-    ucode((split /;/, $_[0], 2+TITLECASE)[TITLECASE]);
-}
-sub composition_exclusion($) {
-    my $s = shift;
-    return 1 if exists $composition_exclusion{code_value($s)};
-    my @d = character_decomposition_mapping($s);
-    return 0 if @d == 0;       # no decomposition
-    return 1 if @d == 2;       # singleton
-    my $x = bycode($d[1]);
-    defined($x) and canonical_combining_class($x) != 0;        # non-starter
-}
-sub specialcasing_source($) {
-    my $r = shift;
-    $r->[0];
-}
-sub specialcasing_type($) {
-    my $r = shift;
-    $r->[1];
-}
-sub specialcasing_mapping($) {
-    my $r = shift;
-    @{$r->[2]};
-}
-sub specialcasing_cond($) {
-    my $r = shift;
-    $r->[3];
-}
+use lib qw(.);
 
-sub list () {
-    init();
-    @unicode_data;
-}
+use Getopt::Long;
+use UCD;
+use SparseMap;
 
-sub specialcasing_list() {
-    specialcasing_init();
-    @specialcasing_data;
-}
+use constant UCS_MAX => 0x110000;
+use constant END_BIT => 0x80000000;
 
-sub script_specific_exclusions () {
-    init();
-    @composition_exclusion;
-}
+my $DECOMP_COMPAT_BIT = 0x8000;
 
-sub bycode ($) {
-    my $code = shift;
-    init_bycode();
-    ${$unicode_bycode[$code]};
-}
+my $CASEMAP_FINAL_BIT = 0x1;
+my $CASEMAP_NONFINAL_BIT = 0x2;
+my $CASEMAP_LAST_BIT = 0x10;
 
-sub byname ($) {
-    my $name = shift;
-    init_byname();
-    ${$unicode_byname{$name}};
-}
+my $LETTER_BIT = 1;
+my $NSPMARK_BIT = 2;
 
-sub grep (&) {
-    my $prog = shift;
-    init();
-    grep {&$prog} @unicode_data;
-}
+(my $myid = '$Id: generate_normalize_data.pl,v 1.5 2001/02/13 07:34:02 ishisone Exp $') =~ s/\$([^\$]+)\$/\$-$1-\$/;
 
-sub init_bycode {
-    init();
-    return if @unicode_bycode > 0;
-    $#unicode_bycode = 65535;
-    foreach my $d (@unicode_data) {
-       $unicode_bycode[code_value($d)] = \$d;
-    }
-}
+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;
 
-sub init_byname {
-    init();
-    return if scalar(keys %unicode_byname);
-    keys %unicode_byname = 4000;
-    foreach my $d (@unicode_data) {
-       $unicode_byname{character_name($d)} = \$d;
-    }
-}
+my $dir = '.';
+my $unicodedatafile = 'UnicodeData.txt';
+my $exclusionfile = 'CompositionExclusions-1.txt';
+my $specialcasefile = 'SpecialCasing.txt';
+my $casefoldingfile = 'CaseFolding.txt';
+my $verbose;
 
-sub init {
-    @unicode_data > 0 or croak "Unicode::UnicodeData: not initialized\n";
-}
+GetOptions('dir|d=s' => \$dir,
+          'unicodedata|u=s' => \$unicodedatafile,
+          'exclude|e=s' => \$exclusionfile,    
+          'specialcase|s=s' => \$specialcasefile,
+          'casefold|c=s' => \$casefoldingfile,
+          'verbose|v' => \$verbose,
+) or usage();
 
-sub specialcasing_init {
-    @specialcasing_data > 0
-       or croak "Unicode::UnicodeData: not initialized\n";
+foreach my $r (\$unicodedatafile, \$exclusionfile,
+              \$specialcasefile, \$casefoldingfile) {
+    $$r = "$dir/$$r" unless $$r =~ m|^/|;
 }
 
-sub initialize {
-    my ($data_file, $exclusion_file, $specialcase_file) = @_;
-    local $_;
+my %exclusions;
+my %lower_special;
+my %upper_special;
 
-    @unicode_data = ();
-    @composition_exclusion = ();
-    %composition_exclusion = ();
-    @specialcasing_data = ();
+my @decomp_data;
+my @comp_data;
+my @toupper_data;
+my @tolower_data;
+my @folding_data;
 
-    open F, $data_file or croak "cannot open $data_file: $!\n";
-    while (<F>) {
-       chomp;
-       push @unicode_data, $_;
-    }
+#
+# Create Mapping/Bitmap objects.
+#
 
-    open F, $exclusion_file or croak "cannot open $exclusion_file: $!\n";
-    while (<F>) {
-       chomp;
-       next if /^#/;
-       next if /^\s*$/;
-       next unless /^([0-9A-Fa-f]+)/;
-       my $n = hex($1);
-       push @composition_exclusion, $n;
-       $composition_exclusion{$n} = 1;
-    }
+# 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);
 
-    open F, $specialcase_file or croak "cannot open $specialcase_file: $!\n";
-    while (<F>) {
-       chomp;
-       last if /\# Locale-sensitive/;  # no locale-dependent mapping
-       next if /^#/;
-       next if /^\s*$/;
-       s/#.*$//;                       # remove trailing comment
-       s/\s*;\s*/;/g;                  # remove spaces around semicolons
+#
+# Read datafiles.
+#
 
-       parse_specialcasing_data($_);
-    }
+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;
 }
 
-sub parse_specialcasing_data {
-    my $s = shift;
-    my @a = split /;/, $_;
-    my @cond = ();
-
-    # Check condition.
-    if (defined($a[4])) {
-       if ($a[4] eq 'FINAL' or $a[4] eq 'NON_FINAL') {
-           push @cond, $a[4];
-       } else {
-           croak "Unicode::UnicodeData: unknown special casing condition \"$a[4]\"\n";
-       }
+#
+# 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;
     }
-    if ($a[0] ne $a[1]) {
-       # mapping to lowercase
-       my $src = hex($a[0]);
-       my @dst = map(hex, split ' ', $a[1]);
-       unless (@dst == 1 and @cond == 0 and
-               lowercase_mapping(bycode($src)) == $dst[0]) {
-           push @specialcasing_data, [$src, 'L', \@dst, @cond];
+    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 ($a[0] ne $a[3]) {
-       # mapping to uppercase
-       my $src = hex($a[0]);
-       my @dst = map(hex, split ' ', $a[3]);
-       unless (@dst == 1 and @cond == 0 and
-           uppercase_mapping(bycode($src)) == $dst[0]) {
-           push @specialcasing_data, [$src, 'U', \@dst, @cond];
+       if (defined $cond && (@$upper > 1 || $upper->[0] != $code)
+           or @$upper > 1 or $upper->[0] != $code) {
+           $upper_special{$code} = [$upper, $cond];
        }
     }
+    close SPCASE;
 }
 
-sub dcmap {
-    my $v = shift;
-    return () if $v eq '';
-    $v =~ /^(?:(<[^>]+>)\s*)?(\S.*)/
-       or die "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+0;
-}
+#
+# 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);
 
-package main;
+    my @comp_cand;     # canonical composition candidates
+    my %nonstarter;
 
-use strict;
-use Data::Dumper;
+    while ($_ = UCD::UnicodeData::getline(\*UCD)) {
+       my %data = UCD::UnicodeData::parseline($_);
+       my $code = $data{CODE};
 
-#use Unicode::UnicodeData qw(:accessor);
-import Unicode::UnicodeData qw(:accessor);
+       # combining class
+       if ($data{CLASS} > 0) {
+           $nonstarter{$code} = 1;
+           $canon_class->add($code, $data{CLASS});
+       }
 
-my $canon_class_bits = 11;
-my $decomp_bits = 10;
-my $compose_bits = 11;
-my $casemap_bits = 11;
-my $context_secsize = 512;
+       # uppercasing
+       if (exists $upper_special{$code} or defined $data{UPPER}) {
+           my $offset = @toupper_data;
+           my @casedata;
 
-(my $myid = '$Id: generate_normalize_data.pl,v 1.4 2000/09/27 02:55:40 ishisone Exp $') =~ s/\$([^\$]+)\$/\$-$1-\$/;
+           $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);
+       }
 
-my $unicodedatafile = shift or usage();
-my $exclusionfile = shift or usage();
-my $specialcasefile = shift or usage();
+       # lowercasing
+       if (exists $lower_special{$code} or defined $data{LOWER}) {
+           my $offset = @tolower_data;
+           my @casedata;
 
-Unicode::UnicodeData::initialize($unicodedatafile, $exclusionfile,
-                                $specialcasefile);
+           $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);
+       }
 
-print <<"END";
-/* \$Id\$ */
-/* $myid */
-/*
- * Do not edit this file!
- * This file is generated from UnicodeData.txt and
- * CompositionExclusions-1.txt.
- *
- */
+       # composition/decomposition
+       if ($data{DECOMP}) {
+           my ($tag, @decomp) = @{$data{DECOMP}};
+           my $offset = @decomp_data;
 
-END
+           # composition
+           if ($tag eq '' and @decomp > 1 and not exists $exclusions{$code}) {
+               # canonical composition candidate
+               push @comp_cand, [$code, @decomp];
+           }
 
-# Actual data generation.
-canon_class();
-composition();
-decomposition();
-casemap();
-letter_context();
+           # decomposition
+           if ($tag ne '') {
+               # compatibility decomposition
+               $offset |= $DECOMP_COMPAT_BIT;
+           }
+           $decomp->add($code, $offset);
+           push @decomp_data, @decomp;
+           $decomp_data[-1] |= END_BIT;
 
-exit;
+       }
 
-sub usage {
-    die "Usage: $0 unicode-data-file compoisition-exclusion-file special-casing-file\n"
+       # 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;
 }
 
 #
-# composition -- generate data for canonical composition
+# read_casefolding_file -- read CaseFolding.txt
 #
-sub composition {
-    my @comp_data;
-    my $bm = create_bitmap($compose_bits);
+sub read_casefolding_file {
+    open FOLD, $casefoldingfile or die "cannto open $casefoldingfile: $!\n";
 
-    foreach my $r (Unicode::UnicodeData::list) {
-       my ($tag, @map) = character_decomposition_mapping($r);
-       next unless defined($tag) and $tag eq '';
-       next if composition_exclusion($r);
+    # dummy.
+    @folding_data = (0);
 
-       die "too long decomposition sequence for \"",
-           character_name($r), "\"\n" if @map != 2;
+    while ($_ = UCD::CaseFolding::getline(\*FOLD)) {
+       my %data = UCD::CaseFolding::parseline($_);
 
-       push @comp_data, [@map, code_value($r)];
-       set_bitmap($bm, $map[0]);
+       $folding->add($data{CODE}, scalar(@folding_data));
+       push @folding_data, @{$data{MAP}};
+       $folding_data[-1] |= END_BIT;
     }
+    close FOLD;
+}
 
-    # Hangul composition
-    if (0) {
-       my $lbase = 0x1100;
-       my $lcount = 19;
-       my $sbase = 0xac00;
-       my $scount = 19 * 21 * 28;
-       range_set($bm, $lbase, $lbase + $lcount - 1);
-       range_set($bm, $sbase, $sbase + $scount - 1);
-    }
-
-    my $bitmap_str = sprint_bitmap($bm);
-    my $hash_str = sprint_composition_hash(@comp_data);
-
+sub print_header {
     print <<"END";
-
+/* \$Id\$ */
+/* $myid */
 /*
- * Canonical Composition
+ * Do not edit this file!
+ * This file is generated from UnicodeData.txt, CompositionExclusions-1.txt,
+ * SpecialCasing.txt and CaseFolding.txt.
  */
 
-#define COMPOSE_BM_SHIFT       (16 - $compose_bits)
-
-static unsigned long compose_bitmap[] = {
-$bitmap_str
-};
-
-static struct composition compose_seq[] = {
-$hash_str
-};
-
 END
 }
 
 #
-# decomposition -- generate data for canonical/compatibility decomposition
+# print_canon_class -- generate data for canonical class
 #
-sub decomposition {
-    my @canon_data;
-    my @canon_buf;
-    my @compat_data;
-    my @compat_buf;
-    my $canon_bm = create_bitmap($decomp_bits);
-    my $compat_bm = create_bitmap($decomp_bits);
-
-    foreach my $r (Unicode::UnicodeData::list) {
-       my ($tag, @map) = character_decomposition_mapping($r);
-       next unless defined $tag;
-
-       my $n = code_value($r);
-       my $is_compat = $tag ne '';
-
-       if ($is_compat) {
-           # compatibility decomposition
-           set_bitmap($compat_bm, $n);
-           push @compat_data, [$n, scalar(@compat_buf), scalar(@map)];
-           push @compat_buf, @map;
-       } else {
-           # canonical composition
-           set_bitmap($canon_bm, $n);
-           push @canon_data, [$n, scalar(@canon_buf), scalar(@map)];
-           push @canon_buf, @map;
-       }
-    }
-    # Compatibility decomposition implies canonical decomposition
-    $compat_bm = or_bitmap($compat_bm, $canon_bm);
-
-    my $canon_bitmap_str = sprint_bitmap($canon_bm);
-    my $compat_bitmap_str = sprint_bitmap($compat_bm);
-    my $canon_decomp_hash = sprint_decomposition_hash(@canon_data);
-    my $compat_decomp_hash = sprint_decomposition_hash(@compat_data);
-    my $canon_data_str = sprint_decomposition_buf(@canon_buf);
-    my $compat_data_str = sprint_decomposition_buf(@compat_buf);
+sub print_canon_class {
+    $canon_class->fix();
+    print STDERR "** cannon_class\n", $canon_class->stat() if $verbose;
+
     print <<"END";
 
 /*
- * Canonical/Compatibility Decomposition
+ * Canonical Class
  */
 
-#define DECOMPOSE_BM_SHIFT     (16 - $decomp_bits)
-
-static unsigned long canon_decompose_bitmap[] = {
-$canon_bitmap_str
-};
-
-static struct decomposition canon_decompose_seq[] = {
-$canon_decomp_hash
-};
+END
+    print_bits("CANON_CLASS", @canon_class_bits);
+    print "\n";
+    print $canon_class->cprog(NAME => "canon_class");
+}
 
-static unicode_t canon_decompose_data[] = {
-$canon_data_str
-};
+#
+# print_composition -- generate data for canonical composition
+#
+sub print_composition {
+    $comp->fix();
+    print STDERR "** composition\n", $comp->stat() if $verbose;
 
-static unsigned long compat_decompose_bitmap[] = {
-$compat_bitmap_str
-};
+    print <<"END";
 
-static struct decomposition compat_decompose_seq[] = {
-$compat_decomp_hash
-};
+/*
+ * Canonical Composition
+ */
 
-static unicode_t compat_decompose_data[] = {
-$compat_data_str
-};
+END
+    print_bits("CANON_COMPOSE", @comp_bits);
+    print "\n";
+    print $comp->cprog(NAME => "compose");
+    print <<"END";
 
+static struct composition {
+       unsigned long c2;       /* 2nd character */
+       unsigned long comp;     /* composed character */
+} 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";
 }
 
 #
-# canon_class -- generate data for canonical class
+# print_decomposition -- generate data for canonical/compatibility
+# decomposition
 #
-sub canon_class {
-    my $bm = create_bitmap($canon_class_bits);
-    my @cldata;
-    my @classes;
-
-    foreach my $r (Unicode::UnicodeData::list) {
-       my $class = canonical_combining_class($r);
-       next unless $class > 0;
-       my $n = code_value($r);
-       set_bitmap($bm, $n);
-       push @cldata, $n, $class;
-    }
-
-    my $bitmap_str = sprint_bitmap($bm);
-    my $canon_hash_str = sprint_canon_class_hash(@cldata);
+sub print_decomposition {
+    $decomp->fix();
+    print STDERR "** decomposition\n", $decomp->stat() if $verbose;
 
     print <<"END";
 
 /*
- * Canonical Class
+ * Canonical/Compatibility Decomposition
  */
 
-#define CANON_CLASS_BM_SHIFT   (16 - $canon_class_bits)
-
-static unsigned long canon_class_bitmap[] = {
-$bitmap_str
-};
+END
+    print_bits("DECOMP", @decomp_bits);
+    print "#define DECOMP_COMPAT\t$DECOMP_COMPAT_BIT\n\n";
 
-static struct canon_class canon_class[] = {
-$canon_hash_str
-};
+    print $decomp->cprog(NAME => "decompose");
 
-END
+    print "static unsigned long decompose_seq[] = {\n";
+    print_ulseq(@decomp_data);
+    print "};\n\n";
 }
 
 #
-# casemap -- generate data for case mapping
+# print_casemap -- generate data for case mapping
 #
-sub casemap {
-    my (@toupper_data, @tolower_data);
-    my $toupper_bm = create_bitmap($casemap_bits);
-    my $tolower_bm = create_bitmap($casemap_bits);
-    my (@special_toupper_data, @special_tolower_data);
-    my @multi_mapping_data = ();
-
-    foreach my $r (Unicode::UnicodeData::list) {
-       if (defined uppercase_mapping($r)) {
-           my $n = code_value($r);
-           set_bitmap($toupper_bm, $n);
-           push @toupper_data, $n, uppercase_mapping($r);
-       }
-       if (defined lowercase_mapping($r)) {
-           my $n = code_value($r);
-           set_bitmap($tolower_bm, $n);
-           push @tolower_data, $n, lowercase_mapping($r);
-       }
-    }
-
-    foreach my $r (Unicode::UnicodeData::specialcasing_list) {
-       my $src = specialcasing_source($r);
-       my $type = specialcasing_type($r);
-       my @dst = specialcasing_mapping($r);
-       my $cond = specialcasing_cond($r);
-       my $dst;
-       my $len;
-
-       $len = scalar(@dst);
-       if ($len == 1) {
-           $dst = $dst[0];
-       } else {
-           $dst = scalar(@multi_mapping_data);
-           push @multi_mapping_data, @dst;
-       }
-       if ($type eq 'L') {
-           # tolower mapping
-           set_bitmap($tolower_bm, $src);
-           push @special_tolower_data, $src, $dst, $len, $cond;
-       } elsif ($type eq 'U') {
-           # toupper mapping
-           set_bitmap($toupper_bm, $src);
-           push @special_toupper_data, $src, $dst, $len, $cond;
-       } else {
-           die "unknown mapping type \"$type\"\n";
-       }
-    }
-
-    my $toupper_bitmap_str = sprint_bitmap($toupper_bm);
-    my $tolower_bitmap_str = sprint_bitmap($tolower_bm);
-    my $toupper_hash_str = sprint_casemap_hash(@toupper_data);
-    my $tolower_hash_str = sprint_casemap_hash(@tolower_data);
-    my $special_toupper_hash_str =
-       sprint_specialcasemap_hash(@special_toupper_data);
-    my $special_tolower_hash_str =
-       sprint_specialcasemap_hash(@special_tolower_data);
-    my $multichar_mapping_str = sprint_decomposition_buf(@multi_mapping_data);
+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";
 
 /*
- * Flags for special case mapping.
+ * Lowercase <-> Uppercase mapping
  */
-#define CMF_MULTICHAR  0x1
-#define CMF_FINAL      0x2
-#define CMF_NONFINAL   0x4
-#define CMF_CTXDEP     (CMF_FINAL|CMF_NONFINAL)
 
 /*
- * 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)
 
-#define CASEMAP_BM_SHIFT       (16 - $casemap_bits)
-
-static unsigned long toupper_bitmap[] = {
-$toupper_bitmap_str
-};
-
-static struct casemap toupper_map[] = {
-       /* non-conditional one-to-one mapping */
-$toupper_hash_str
-       /* conditional or one-to-many mapping */
-$special_toupper_hash_str
-};
-
-static unsigned long tolower_bitmap[] = {
-$tolower_bitmap_str
-};
-
-static struct casemap tolower_map[] = {
-       /* non-conditional one-to-one mapping */
-$tolower_hash_str
-       /* conditional or one-to-many mapping */
-$special_tolower_hash_str
-};
-
-static unicode_t multichar_casemap_data[] = {
-$multichar_mapping_str
-};
 END
+    print_bits("CASEMAP", @casemap_bits);
+    print "\n";
+    print $upper->cprog(NAME => "toupper");
+    print $lower->cprog(NAME => "tolower");
+
+    print "static unsigned long toupper_seq[] = {\n";
+    print_ulseq(@toupper_data);
+    print "};\n\n";
+
+    print "static unsigned long tolower_seq[] = {\n";
+    print_ulseq(@tolower_data);
+    print "};\n\n";
 }
 
 #
-# letter_context -- gerarate data for determining context (final/non-final)
+# print_casefolding -- generate data for case folding
 #
-sub letter_context {
-    my @ctx_data = ();
-    my $letter_bit = 1;
-    my $nspmark_bit = 2;
-    foreach my $r (Unicode::UnicodeData::list) {
-       my $cat = general_category($r);
-       if ($cat =~ /L[ult]/) {
-           push @ctx_data, code_value($r), $letter_bit;
-       } elsif ($cat eq 'Mn') {
-           push @ctx_data, code_value($r), $nspmark_bit;
-       }
-    }
-
-    my @sections;
-    while (@ctx_data >= 2) {
-       my $code = shift @ctx_data;
-       my $type = shift @ctx_data;
-       my $sec_idx = int($code / $context_secsize);
-       my $sec_off = $code % $context_secsize;
-
-       if (!defined $sections[$sec_idx]) {
-           my $bm = "\0" x ($context_secsize * 2 / 8);
-           $sections[$sec_idx] = \$bm;
-       }
-       vec(${$sections[$sec_idx]}, $sec_off, 2) = $type;
-    }
-
-    my $nsections = 65536 / $context_secsize;
+sub print_casefolding {
+    $folding->fix();
+    print STDERR "** case folding\n", $folding->stat() if $verbose;
 
     print <<"END";
 
 /*
- * Cased characters and non-spacing marks (for casemap context)
+ * Case Folding
  */
 
-#define CTX_BLOCK_SZ   $context_secsize
-#define CTX_CASED      $letter_bit     /* cased character */
-#define CTX_NSM                $nspmark_bit    /* non-spacing mark */
-
 END
+    print_bits("CASE_FOLDING", @folding_bits);
+    print "\n";
+    print $folding->cprog(NAME => "case_folding");
 
-    for (my $i = 0; $i < $nsections; $i++) {
-       if (defined $sections[$i]) {
-           my $bm_str = sprint_rawbitmap(${$sections[$i]});
-           print <<"END";
-static unsigned long casemap_ctx_section$i\[] = {
-$bm_str
-};
+    print "static unsigned long case_folding_seq[] = {\n";
+    print_ulseq(@folding_data);
+    print "};\n\n";
+}
 
-END
-       }
-    }
+#
+# 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";
-static unsigned long *casemap_ctx_sections[] = {
-END
 
-    for (my $i = 0; $i < $nsections; $i++) {
-       if (defined $sections[$i]) {
-           print "\tcasemap_ctx_section$i,\n";
-       } else {
-           print "\tNULL,\n";
-       }
-    }
+/*
+ * Cased characters and non-spacing marks (for casemap context)
+ */
+
+END
 
+    print_bits("CASEMAP_CTX", @casemap_ctx_bits);
     print <<"END";
-};
 
-END
-}
+#define CTX_CASED      $LETTER_BIT
+#define CTX_NSM                $NSPMARK_BIT
 
-sub sprint_canon_class_hash {
-    my $i = 0;
-    my $s = '';
-    while (@_ > 0) {
-       my $code = shift;
-       my $class = shift;
-       if ($i % 4 == 0) {
-           $s .= "\n" if $i != 0;
-           $s .= "\t";
-       }
-       $s .= sprintf "{0x%04x, %3d}, ", $code, $class;
-       $i++;
-    }
-    $s;
+END
+    print $casemap_ctx->cprog(NAME => "casemap_ctx");
 }
 
 sub sprint_composition_hash {
@@ -766,145 +580,24 @@ sub sprint_composition_hash {
     $s;
 }
 
-sub sprint_decomposition_hash {
-    my $i = 0;
-    my $s = '';
-    foreach my $r (@_) {
-       if ($i % 3 == 0) {
-           $s .= "\n" if $i != 0;
-           $s .= "\t";
-       }
-       $s .= sprintf "{0x%04x, %4d, %2d}, ", @{$r};
-       $i++;
-    }
-    $s;
-}
-
-sub sprint_casemap_hash {
+sub print_bits {
+    my $prefix = shift;
     my $i = 0;
-    my $s = '';
-    while (@_ > 0) {
-       my $org = shift;
-       my $map = shift;
-       if ($i % 4 == 0) {
-           $s .= "\n" if $i != 0;
-           $s .= "\t";
-       }
-       $s .= sprintf "{0x%04x, 0x%04x}, ", $org, $map;
+    foreach my $bit (@_) {
+       print "#define ${prefix}_BITS_$i\t$bit\n";
        $i++;
     }
-    $s;
 }
 
-sub sprint_specialcasemap_hash {
+sub print_ulseq {
     my $i = 0;
-    my $s = '';
-    while (@_ > 0) {
-       my $src = shift;
-       my $dst = shift;
-       my $len = shift;
-       my $cond = shift;
-       my @flags = ();
-
-       if ($i % 2 == 0) {
-           $s .= "\n" if $i != 0;
-           $s .= "\t";
-       }
-       $i++;
-
-       if ($len > 1) {
-           push @flags, 'CMF_MULTICHAR';
-       }
-       if (defined $cond) {
-           if ($cond eq 'FINAL') {
-               push @flags, 'CMF_FINAL';
-           } elsif ($cond eq 'NON_FINAL') {
-               push @flags, 'CMF_NONFINAL';
-           } else {
-               die "unknown case mapping condition \"$cond\"\n";
-           }
-       }
-       if ($len > 1) {
-           $s .= sprintf "{0x%04x, 0x%04x, %s, %d}, ", $src, $dst,
-               (@flags > 0) ? join('|', @flags) : '0', $len;
-       } else {
-           $s .= sprintf "{0x%04x, 0x%04x, %s}, ", $src, $dst,
-               (@flags > 0) ? join('|', @flags) : '0';
-       }
-    }
-    $s;
-}
-
-sub sprint_decomposition_buf {
-    my $i = 0;
-    my $s = '';
-    foreach my $d (@_) {
-       if ($i % 10 == 0) {
-           $s .= "\n" if $i != 0;
-           $s .= "\t";
-       }
-       $s .= sprintf "%5d, ", $d;
-       $i++;
-    }
-    $s;
-}
-
-sub create_bitmap {
-    my $bits = shift;
-    my $shift = 16 - $bits;
-    my $bmlen = 1 << ($bits - 3);
-    my $bitmap = "\0" x $bmlen;
-    [$bitmap, $shift];
-}
-
-sub set_bitmap {
-    my ($bm, $n) = @_;
-    vec($bm->[0], $n >> $bm->[1], 1) = 1;
-}
-
-sub range_set {
-    my ($bm, $start, $end) = @_;
-    my $shift = $bm->[1];
-    $start >>= $shift;
-    $end >>= $shift;
-    vec($bm->[0], $_, 1) = 1 foreach $start .. $end;
-}
-
-sub or_bitmap {
-    my ($bm1, $bm2) = @_;
-    die "incompatible bitmap\n"
-       if length($bm1->[0]) != length($bm2->[0]) or $bm1->[1] != $bm2->[1];
-    my $bitmap = $bm1->[0] | $bm2->[0];
-    [$bitmap, $bm1->[1]];
-}
-
-sub sprint_bitmap {
-    my $bm = shift;
-    my $data = $bm->[0];
-    my $i = 0;
-    my $s = '';
-    foreach my $v (unpack('V*', $data)) {
+    foreach my $v (@_) {
        if ($i % 4 == 0) {
-           $s .= "\n" if $i != 0;
-           $s .= "\t";
+           print "\n" if $i != 0;
+           print "\t";
        }
-       $s .= sprintf "0x%08x, ", $v;
+       printf "0x%08x, ", $v;
        $i++;
     }
-    $s;
-}
-
-sub sprint_rawbitmap {
-    my $data = shift;
-    my $i = 0;
-    my $s = '';
-    foreach my $v (unpack('V*', $data)) {
-       if ($i % 4 == 0) {
-           $s .= "\n" if $i != 0;
-           $s .= "\t";
-       }
-       $s .= sprintf "0x%08x, ", $v;
-       $i++;
-    }
-    $s;
+    print "\n";
 }
diff --git a/contrib/idn/mdnkit/win/README.WIN b/contrib/idn/mdnkit/win/README.WIN
new file mode 100644 (file)
index 0000000..663bcaa
--- /dev/null
@@ -0,0 +1,24 @@
+To build `mdnsproxy' for Windows, follow the instruction below.
+Please note that the Windows version is not officially supported.
+
+To build Windows version, you need `libiconv' library.  A LGPL
+implemenation is available from the following place.
+
+    http://clisp.cons.org/~haible/packages-libiconv.html
+
+Follow the instructions described in README.win32 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 to compile
+`mdnsproxy'.
+
+       nmake -f make.wnt
+
+* Running mdnsproxy
+
+On Windows NT you can run 'mdnsproxy' as a service, while on Windows
+95/98 'mdnsproxy' can be run but not as a service.
+
+; $Id: README.WIN,v 1.1 2001/06/09 00:30:53 tale Exp $
diff --git a/contrib/idn/mdnkit/wsock/README.txt b/contrib/idn/mdnkit/wsock/README.txt
new file mode 100644 (file)
index 0000000..29a81df
--- /dev/null
@@ -0,0 +1,642 @@
+
+    mDN Wrapper - Client Side mDN Conversion for Windows
+
+    Copyright (c) 2000,2001 Japan Network Information Center.
+                All rights reserved.
+
+    *** IMPORTANT NOTICE ********************************************
+    If you install a new version of mDN Wrapper to a machine where
+    older version is already installed, you need to rewrap all the
+    programs that has been wrapped when you first use the new version.
+    This can be done by pressing "Rewrap All" button from the
+    configuration GUI.
+    *****************************************************************
+
+
+1. Introduction
+
+    For supporting multi-lingual domain name on Windows, client 
+    application should convert domain names (their encodings) to that
+    DNS server accepts.  Ofcourse, this requires windows applications to
+    handle multi-lingualized domain names in its core, and it is maker's
+    responsibility to make program mDN compatible.
+
+    But now, there are still no acceptable standard for mDN, it is
+    difficult to expect software providers to create mDN version of the 
+    programs.  So, some tricks to make legacy application to do client 
+    side mDN conversions.  'mdnsproxy' in mDNkit is one of such solution,
+    and also this one, WINSOCK Wrapper is another solution.
+
+    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 mDN.
+
+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.
+
+    mDN 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
+
+    mDN 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
+    
+        WSALookupServiceBeginA
+       WSALookupServiceNextA
+       WSALookupServiceEnd
+
+    Some applications do not use these APIs to resolve domaimn names. 
+    'nslookup' is one of those program. 'nslookup' builds and parse DNS
+    messages internally and does not use WINSOCK's name resolve APIs.
+    mDN Wrapper cannot multi-ligualize those programs.
+    
+    NOTE:   You can use 'mdnsproxy' to multi-ligualize those program.
+            'mdnsproxy' intercepts DNS reqesut/response on the network
+            and convert encoding of domain names. 
+
+    NOTE:   WINSOCK 2.0 also contains WIDE-CHARACTER based name
+            resolution APIs,
+
+                WSALookupServiceBeginW
+                WSALookupServiceNextW
+
+            mDN Wrapper does not wrap these APIs.  These APIs are used
+            on microsoft's internartionalization, and used on their I18N
+            framework.  It should be dangerouse to convert to another
+            multi-ligualization frame work.
+    
+2.3. Other APIs in WINSOCK
+
+    For another APIs in WINSOCK, mDN wrapper does nothing, only calls
+    original DLL's entries.
+
+    mDN 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 installed with original DLL names. So after
+    install of mDN wrapper, WINSOCK DLLs should be
+
+        wsock32.dll         mDN Wrapper for WINSOCK V1.1
+       ws2_32.dll          mDN 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, mDN 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 should 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
+
+    But, replacing DLLs in window's system directory is very dangerous.
+
+    a)  If you want to re-install wrappers 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, mDN wrapper usually does not wrap on system, but wrap on
+    indivisual applications.
+
+    In Windows, DLL will be searched in the following places:
+    
+        Application's Load Directory
+       %SystemRoot%\System32
+       %SystemRoot%
+       Directories in PATH
+
+    and load & linked first found one.  So if installed wrapper DLLs on
+    application's load directory, application's call to WINSOCK will
+    wrapped.
+
+    But some applications or DLLs are binded to specific DLL, they does
+    not rely on above DLL's search path.  For those applcaitons or DLLs,
+    mDN 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 mDN 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 mDN 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, mDN
+    wrappper absolb OS/DLL variations.
+    
+    Registry values for mDN Wrapper will placed under
+
+        HKEY_LOCAL_MACHINE\SOFTWARE\JPNIC\MDN
+       HKEY_CURRENT_USER\SOFTWARE\JPNIC\MDN
+
+    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 mDN wrapper into application's directory, use "0".
+    If you install mDN wrapper into system directory, use "1".  If there
+    are no "Where" value, mDN 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 mDN wrapper, this registry will set to
+    some (yet undefined) DNS encoding.
+    
+    Registry values for mDN Wrapper will placed under
+
+        HKEY_LOCAL_MACHINE\SOFTWARE\JPNIC\MDN
+       HKEY_CURRENT_USER\SOFTWARE\JPNIC\MDN
+
+    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 mDN
+    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, mDN 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\MDN\PerProg
+       HKEY_CURRENT_USER\SOFTWARE\JPNIC\MDN\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\MDN\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
+
+    mDN Wrapper, as standard installation, wraps WINSOCK DLL on 
+    application's directory.  For this installation, mDN Wrapper
+    presents setup program and configuration program.
+    
+    NOTE:   You can also install mDN wrapper DLLs to wrap WINSOCK at
+            system directory.  But this installations is very dangerous.
+           You should try it at your own risk.
+
+3.1. Setup Program
+
+    To install mDN wrapper, run "setup.exe".  Setup program will do:
+    
+    Install Files
+    
+        Copy mDN wrapper files (DLL, Program EXE, etc) into diretory
+       
+           "\Program Files\JPONIC\mDN Wrapper"
+
+        This directory may be changed on setup sequence.
+
+    Registry setting
+
+        Setup program will create keys and values under registry:
+       
+           "HKEY_LOCAL_MACHINES\Software\JPNIC\MDN"
+
+        Encoding        REG_SZ  "RACE"
+       
+           Name of DNS encoding.  Default value is "RACE", which is
+            current candidate for DNS encoding.  This value may be
+            changed with registry editor.
+
+        PerProg         KEY
+       
+           Under this key, mDN wrapper set program specific values. mDN
+            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 mDN wrapper in system directory, chanage
+            "Where" values to fit your environment.
+
+    Creating ICON
+    
+        Setup program will create program icon for mDN 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
+    link this.
+
+    +---+-------------------------------------------------+---+---+---+
+    |   | mDN Wrapper - Configuration                     | _ | O | X |
+    +---+-------------------------------------------------+---+---+---+
+    |          mDN Wrapper Configuration Program version X.X          |
+    +-----------------------------------------------------------------+
+    |                  Wrapped Program                    +---------+ |
+    | +---------------------------------------------+---+ | Wrap..  | |
+    | |                                             | A | +---------+ |
+    | |                                             +---+ +---------+ |
+    | |                                             |   | | Unwrap..| |
+    | |                                             |   | +---------+ |
+    | |                                             |   | +---------+ |
+    | |                                             |   | |UnwrapAll| |
+    | |                                             |   | +---------+ |
+    | |                                             |   | +---------+ |
+    | |                                             |   | |RewrapAll| |
+    | |                                             |   | +---------+ |
+    | |                                             |   | +---------+ |
+    | |                                             |   | |  Log..  | |
+    | |                                             |   | +---------+ |
+    | |                                             |   | +---------+ |
+    | |                                             +---+ |Advanced.| |
+    | |                                             | V | +---------+ |
+    | +---+-------------------------------------+---+---+ +---------+ |
+    | | < |                                     | > |     |  Exit   | |
+    | +---+-------------------------------------+---+     +---------+ |
+    +-----------------------------------------------------------------+
+
+    Listbox contains list of current wrapped programs.  It initially
+    empty.  
+    
+    To wrap a program, press button "wrap".  You'll get following dialog.
+    
+    +---+-------------------------------------------------+---+---+---+
+    |   | mDN Wrapper - Wrap Executable                   | _ | O | X |
+    +---+-------------------------------------------------+---+---+---+
+    |           +----------------------------------------+ +--------+ |
+    |  Program: |                                        | |Browse..| |
+    |           +----------------------------------------+ +--------+ |
+    |           +----------+                                          |
+    | Encoding: |          |  o Default  o UTF-8                      |
+    |           +----------+                                          |
+    +-----------------------------------------------------------------+
+    |                                           +--------+ +--------+ |
+    |                                           |  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". 
+    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 mDN 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.
+    
+    +---+-------------------------------------------------+---+---+---+
+    |   | mDN 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.
+
+    +---+-------------------------------------------------+---+---+---+
+    |   | mDN 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 MDN library (libmdn).
+    mDN 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.
+
+    +---+-------------------------------------------------+---+---+---+
+    |   | mDN Wrapper - Advanced Configuration            | _ | O | X |
+    +---+-------------------------------------------------+---+---+---+
+    |                    MDN 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                              |
+    +-----------------------------------------------------------------+
+    |                       MDN 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.
+
+    MDN 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. Wrapper
+    DLL is expoected to export all entries including un-documented ones.
+    If WINSOCK DLL version changed, mDN wrapper may not work correctly.
+
+    Current mDN Wrapper is confirmed on
+    
+        WinNT4.0 SP6a   (WINSOCK 1.1 + 2.0)
+        Win98           (WINSOCK 1.1 + 2.0)
+       Win95 OSR2      (WINSOCK 1.1)
+
+    But there are no assuarance for feature version of windows.
+
+4.2. DNS, WINS, LMHOSTS
+
+    There are three name resolving methods in windows, DNS, WINS and
+    LMHOSTS. Using mDN 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
+    mDN 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.  mDN 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, mDN wrapper does not work.
+
+4.5. Applications bound to specific WINSOCK DLL
+
+    Some apllications are bound to specific DLL, not rely on standard
+    DLL search path. Netscape Communicator is one of such programs. mDN
+    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.
+
+4.6. But 'mdnsproxy' exist
+
+    If you have above problems with your environments, there is 
+    'mdnsproxy'.  It hooks on DNS transactions, so it is free from above
+    problems.  But of course, it is harder to setup, and also cannot work
+    with program specific encodings, such as IE, but sometimes, works
+    better than mDN Wrapper.
+
+5. Registry Setting - Summary
+
+5.1. Priority of Setting
+
+    Settings of mDN Wrapper is placed on registry 
+    
+        Software\JPNIC\MDN
+       
+    under HKEY_LOCAL_MACHINE or HKEY_CURRENT_USER.  mDN 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\\MDN\\Where         Where 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\\MDN\\Encoding      DNS Encoding Name
+        Software\\JPNIC\\MDN\\Normalize     Normalization Scheme
+        Software\\JPNIC\\MDN\\LogLevel      Log Level
+        Software\\JPNIC\\MDN\\LogFile       Log File
+
+_Per Program Settings
+
+    Converting position and program's local encoding may be set per
+    program bases.
+
+        Software\\JPNIC\\MDN\\PerProg\\<name>\\Where
+        Software\\JPNIC\\MDN\\PerProg\\<name>\\Encoding
+
+    If not specified,
+    
+        Where       0       both 1.1 DLL and 2.0 DLL
+       Encoding            process's code page
diff --git a/contrib/idn/mdnkit/wsock/README_j.txt b/contrib/idn/mdnkit/wsock/README_j.txt
new file mode 100644 (file)
index 0000000..a20545e
--- /dev/null
@@ -0,0 +1,707 @@
+
+    mDN Wrapper - \83E\83B\83\93\83h\83E\83Y\82É\82¨\82¯\82é\83N\83\89\83C\83A\83\93\83g\91¤\82Å\82Ì\95Ï\8a·
+
+    Copyright (c) 2000,2001 Japan Network Information Center.
+                All rights reserved.
+
+    *** \8fd\97v\82È\92\8d\88Ó ****************************************************
+    \82à\82µ\82à\82·\82Å\82É mDN Wrapper \82ª\83C\83\93\83X\83g\81[\83\8b\82³\82ê\82Ä\82¢\82é\83}\83V\83\93\82É\90V\82µ\82¢\83o\81[
+    \83W\83\87\83\93\82Ì mDN Wrapper \82ð\83C\83\93\83X\83g\81[\83\8b\82·\82é\8fê\8d\87\82É\82Í\81A\90V\82µ\82¢\83o\81[\83W\83\87\83\93\82ð
+    \8dÅ\8f\89\82É\8bN\93®\82·\82é\8dÛ\82É\81A\83\89\83b\83v\82³\82ê\82Ä\82¢\82é\82·\82×\82Ä\82Ì\83v\83\8d\83O\83\89\83\80\82ð\8dÄ\93x\83\89\83b\83v
+    \82·\82é\95K\97v\82ª\82 \82è\82Ü\82·\81B\82±\82ê\82Í\83R\83\93\83t\83B\83M\83\85\83\8c\81[\83V\83\87\83\93 GUI \82Å "Rewrap All"
+    \82Æ\82¢\82¤\83{\83^\83\93\82ð\89\9f\82·\82±\82Æ\82Å\8eÀ\8ds\82·\82é\82±\82Æ\82ª\82Å\82«\82Ü\82·\81B
+    *******************************************************************
+
+
+1. \82Í\82\82ß\82É
+
+    Windows \82Å\91½\8c¾\8cê\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Í\81A
+    Windows \8fã\82Ì\83A\83v\83\8a\83P\81[\83V\83\87\83\93\82ª\81A\82«\82¿\82ñ\82Æ\91½\8c¾\8cê\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
+    
+    \82µ\82©\82µ\81A\95W\8f\80\82ª\8c\88\82Ü\82Á\82Ä\82¢\82È\82¢\8c»\8fó\82Å\82Í\81A\83v\83\8d\83O\83\89\83\80\8dì\90¬\8eÒ\82É\82±\82Ì\82æ\82¤\82È\91Î
+    \89\9e\82ð\8aú\91Ò\82·\82é\82Ì\82Í\96³\97\9d\82È\82Ì\82Å\81A\8aù\91\82Ì\83A\83v\83\8a\83P\81[\83V\83\87\83\93\82ð\91½\8c¾\8cê\83h\83\81\83C\83\93\96¼
+    \91Î\89\9e\82³\82¹\82é\82½\82ß\82Ì\83g\83\8a\83b\83N\82ª\95K\97v\82É\82È\82è\82Ü\82·\81BmDNkit\82É\8aÜ\82Ü\82ê\82é mdnsproxy
+    \83T\81[\83o\82Í\82»\82Ì\82½\82ß\82Ì\88ê\82Â\82Ì\95û\96@\82Å\82·\81B\82±\82±\82Å\82Í\81A\82à\82¤\88ê\82Â\82Ì\95û\96@\81AWINSOCK 
+    Wrapper \82ð\92ñ\8e¦\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ð\91½\8c¾\8cê\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à\91½\8c¾\8cê\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. Wrapper 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[\82É\93n\82³\82ê\82Ü\82·\81B\83\89\83b\83p\81[
+    \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[\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
+
+    mDN 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\91½\8c¾\8cê\83h\83\81\83C\83\93\96¼\82Ì\96¼\91O\89ð\8c\88\82ª\82Å\82«\82é\82æ
+    \82¤\82É\82µ\82Ü\82·\81B
+    
+    \92\8d\81F16\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
+
+    mDN 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Í\81AmDN Wrapper \82Å\82Í\91½
+    \8c¾\8cê\89»\91Î\89\9e\82³\82¹\82é\82±\82Æ\82Í\82Å\82«\82Ü\82¹\82ñ\81B
+    
+    \92\8d\81Fmdnsproxy\82Í\83l\83b\83g\83\8f\81[\83N\8fã\82ÅDNS \82Ì\83\8a\83N\83G\83X\83g\81A\83\8c\83X\83|\83\93\83X\82É\82Â\82¢\82Ä\91½
+        \8c¾\8cê\89»\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à\91½\8c¾\8cê\89»\82³\82¹
+        \82é\82±\82Æ\82ª\82Å\82«\82Ü\82·\81B\95K\97v\82É\89\9e\82\82Ä\93K\8e\9e\8eg\82¢\95ª\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ÍmDN Kit \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©\81A\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Í\81AmDN Wrapper \82Í\82È\82É\82à\82µ\82È\82¢\82Å\81A\8c³\82Ì
+    WINSOCK API \82ð\8cÄ\82Ñ\8fo\82µ\82Ü\82·\81B
+
+    mDN 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ÄmDN
+    Wrapper \82ª\83C\83\93\83X\83g\81[\83\8b\82³\82ê\82½\8fó\91Ô\82Å\82Í\81A
+    
+        wsock32.dll         mDN Wrapper for WINSOCK V1.1
+       ws2_32.dll          mDN 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Í\81AmDN 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Å\81AmDN 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Í mDN 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
+    
+    mDN 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ÅmDN 
+    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
+    
+    mDN Wrapper \97p\82Ì\83\8c\83W\83X\83g\83\8a\90Ý\92è\82Í
+    
+        HKEY_LOCAL_MACHINE\SOFTWARE\JPNIC\MDN
+       HKEY_CURRENT_USER\SOFTWARE\JPNIC\MDN
+
+    \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Ì\91½\8c¾\8cê\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Í\81AmDN 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
+
+    mDN Wrapper \97p\82Ì\83\8c\83W\83X\83g\83\8a\90Ý\92è\82Í
+    
+        HKEY_LOCAL_MACHINE\SOFTWARE\JPNIC\MDN
+       HKEY_CURRENT_USER\SOFTWARE\JPNIC\MDN
+
+    \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Ì\91½\8c¾\8cê\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é\91½\8c¾\8cê\89»\95û\8e®\82Ì\82Ð
+    \82Æ\82Â\82Å\82·\82ª\81A\91½\8c¾\8cê\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ß\81AmDN \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
+
+    mDN 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\MDN\PerProg
+       HKEY_CURRENT_USER\SOFTWARE\JPNIC\MDN\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\MDN\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
+
+    mDN 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
+
+    mDN 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Í
+
+    \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\mDN Wrapper\81\81\83Z\83b\83g\83A\83b\83v
+       \8e\9e\93_\82Å\95Ï\8dX\89Â\94\\81j\88È\89º\82É\81AmDN 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\MDN \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
+       
+        Encoding    REG_SZ      "RACE"
+       
+           DNS \83T\81[\83o\91¤\82Ì\83G\83\93\83R\81[\83f\83B\83\93\83O\96¼\82Å\82·\81B\83f\83t\83H\83\8b\83g\92l\82Æ\82µ\82Ä\81A\8c»
+            \8e\9e\93_\82Å\82Ì\97L\97Í\8có\95â\82Å\82 \82éRACE\83G\83\93\83R\81[\83f\83B\83\93\83O\82ð\90Ý\92è\82µ\82Ü\82·\81B\82±\82ê
+           \82Í\81A\83\8c\83W\83X\83g\83\8a\83G\83f\83B\83^\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\81umDN 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 mDN 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           mDN 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 mDN 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¥\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\9f\84\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\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
+
+    mDN 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 mDN 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 mDN 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Í\81AMDN \83\89\83C\83u\83\89\83\8a (libmdn) \82ª\8fo\97Í\82·\82é
+    \83\8d\83O\82É\91Î\82µ\82Ä\82Ì\82Ý\97L\8cø\82Å\82·\81BmDN 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 mDN 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                     MDN 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                     MDN 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
+
+    MDN 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Æ\81AmDN 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½mDN Wrapper \82Í\81A
+    
+        WinNT4.0 SP6a   (WINSOCK 1.1 + 2.0)
+       Win98           (WINSOCK 1.1 + 2.0)
+       Win95 OSR2      (WINSOCK 1.1)
+
+    \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·\81BmDN 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Í\81AmDN 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
+
+    mDN 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Í\81AmDN 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
+
+4.6. \91ã\91Ö\8eè\92i\82Æ\82µ\82Ä\82Ì'mdnsproxy'
+
+    \82±\82ê\82ç\82Ì\90§\8cÀ\8e\96\8d\80\82ª\96â\91è\82É\82È\82é\8fê\8d\87\82É\82Í\81A\91ã\91Ö\8eè\92i\82Æ\82µ\82Ä'mdnsproxy'\82ð\8eg\82¤
+    \82±\82Æ\82à\82Å\82«\82Ü\82·\81B\82±\82ê\82Í\81ADNS \83T\81[\83o\82Æ\82Ì\83g\83\89\83\93\83U\83N\83V\83\87\83\93\82ð\92\86\8cp\82·\82é\82Ì\82Å\81A
+    \8fã\82Å\96â\91è\82É\82È\82Á\82½\82æ\82¤\82È\82±\82Æ\82ð\89ñ\94ð\82·\82é\82±\82Æ\82ª\82Å\82«\82Ü\82·\81B
+    
+    \82½\82¾\82µ\81A'mdnsproxy'\82Í\81A\83\89\83b\83p\81[\82æ\82è\82à\95¡\8eG\82È\90Ý\92è\82ª\95K\97v\82Å\82·\82µ\81A\82Ü\82½\81A\8cÄ
+    \82Ñ\8c³\82Ì\83v\83\8d\83O\83\89\83\80\82ð\93Á\92è\82·\82é\82±\82Æ\82ª\82Å\82«\82Ü\82¹\82ñ\82Ì\82Å\81A\83v\83\8d\83O\83\89\83\80\8cÅ\97L\82Ì\83\8d\81[
+    \83J\83\8b\83G\83\93\83R\81[\83f\83B\83\93\83O\82ð\8eæ\82è\88µ\82¤\82±\82Æ\82Í\82Å\82«\82Ü\82¹\82ñ\81B\82µ\82©\82µ\81A\8fã\8bL\82Ì\90§\8cÀ\8e\96
+    \8d\80\82ª\96â\91è\82É\82È\82é\82æ\82¤\82È\83P\81[\83X\82Å\82Í\81A\83\89\83b\83p\81[\82Ì\91ã\82í\82è\82É\8eg\97p\82·\82é\82Æ\82¢\82¢\82©\82à
+    \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Ê
+
+    mDN Wrapper \82Ì\90Ý\92è\8fî\95ñ\82Í\81AHKEY_LOCAL_MACHINE\81AHKEY_CURRENT_USER\82Ì
+
+        Software\JPNIC\MDN
+
+    \88È\89º\82É\8ai\94[\82³\82ê\82Ü\82·\81BmDN 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\\MDN\\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\\MDN\\Encoding      DNS\91¤\83G\83\93\83R\81[\83f\83B\83\93\83O\96¼
+        Software\\JPNIC\\MDN\\Normalize     \90³\8bK\89»\82Ì\95û\8e®
+        Software\\JPNIC\\MDN\\LogLevel      \83\8d\83O\83\8c\83x\83\8b
+        Software\\JPNIC\\MDN\\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\\MDN\\PerProg\\<name>\\Where
+        Software\\JPNIC\\MDN\\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/mdnkit/wsock/common/checkdll.c b/contrib/idn/mdnkit/wsock/common/checkdll.c
new file mode 100644 (file)
index 0000000..1f267eb
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * checkdll.c - checks DLL existence
+ */
+
+/*
+ * 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+ * Tokyo, 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) Japan Network Information Center.  All rights reserved."
+ * 
+ * 4. Neither the name of JPNIC may 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.
+ * 
+ * 6. Indemnification by Licensee
+ *    Any person or entities using and/or redistributing this Software under
+ *    this License Terms and Conditions shall defend indemnify and hold
+ *    harmless JPNIC from and against any and all judgements damages,
+ *    expenses, settlement liabilities, cost and other liabilities of any
+ *    kind as a result of use and redistribution of this Software or any
+ *    claim, suite, action, litigation or proceeding by any third party
+ *    arising out of or relates to this License Terms and Conditions.
+ * 
+ * 7. Governing Law, Jurisdiction and Venue
+ *    This License Terms and Conditions shall be governed by and and
+ *    construed in accordance with the law of Japan. Any person or entities
+ *    using and/or redistributing this Software under this License Terms and
+ *    Conditions hereby agrees and consent to the personal and exclusive
+ *    jurisdiction and venue of Tokyo District Court of Japan.
+ */
+
+#include <windows.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "jpnicmdn.h"
+
+/*
+ * Check if DLL exist
+ */
+
+BOOL    mdnCheckDll(PUCHAR name)
+{
+    HINSTANCE   hdll = NULL ;
+    
+    if ((hdll = LoadLibrary(name)) == NULL) {
+        return FALSE ;
+    }
+    FreeLibrary(hdll) ;
+    return TRUE ;
+}
diff --git a/contrib/idn/mdnkit/wsock/common/convert.c b/contrib/idn/mdnkit/wsock/common/convert.c
new file mode 100644 (file)
index 0000000..f4e565e
--- /dev/null
@@ -0,0 +1,195 @@
+/*
+ * convert.c - convert domain name
+ */
+
+/*
+ * 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+ * Tokyo, 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) Japan Network Information Center.  All rights reserved."
+ * 
+ * 4. Neither the name of JPNIC may 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.
+ * 
+ * 6. Indemnification by Licensee
+ *    Any person or entities using and/or redistributing this Software under
+ *    this License Terms and Conditions shall defend indemnify and hold
+ *    harmless JPNIC from and against any and all judgements damages,
+ *    expenses, settlement liabilities, cost and other liabilities of any
+ *    kind as a result of use and redistribution of this Software or any
+ *    claim, suite, action, litigation or proceeding by any third party
+ *    arising out of or relates to this License Terms and Conditions.
+ * 
+ * 7. Governing Law, Jurisdiction and Venue
+ *    This License Terms and Conditions shall be governed by and and
+ *    construed in accordance with the law of Japan. Any person or entities
+ *    using and/or redistributing this Software under this License Terms and
+ *    Conditions hereby agrees and consent to the personal and exclusive
+ *    jurisdiction and venue of Tokyo District Court of Japan.
+ */
+
+#include <windows.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "jpnicmdn.h"
+
+/*
+ * prepare/dispose conversion context
+ */
+void
+mdnConvDone(CONVPTR converter)
+{
+    if (converter == NULL) {
+        return;
+    }
+    mdn_resconf_destroy(converter->conf);
+    free(converter);
+}
+
+CONVPTR
+mdnConvInit(void)
+{
+    CONVPTR conv;
+    UCHAR confpath[256];
+    UCHAR encoding[100];
+    mdn_result_t r;
+    
+    mdnLogPrintf(mdn_log_level_info, "libmdn version: %s\n",
+                mdn_version_getstring());
+
+    if ((conv = malloc(sizeof(CONVREC))) == NULL) {
+        mdnPrintf("mdnConvInit: allocation failed\n");
+        return NULL;
+    }
+    conv->conf = NULL;
+
+    /*
+     * Initialize.
+     */
+    if ((r = mdn_resconf_initialize()) != mdn_success) {
+        mdnPrintf("mdnConvInit: cannot initialize mdn library: %s\n",
+                 mdn_result_tostring(r));
+        mdnConvDone(conv);
+       return NULL;
+    }
+    if ((r = mdn_resconf_create(&conv->conf)) != mdn_success) {
+        mdnPrintf("mdnConvInit: cannot create configuration context: %s\n",
+                 mdn_result_tostring(r));
+        mdnConvDone(conv);
+       return NULL;
+    }
+
+    /*
+     * load configuration file.
+     */
+    if (mdnGetConfFile(confpath) != TRUE) {
+        mdnPrintf("mdnConvInit: cannot find configuration file path\n");
+        mdnConvDone(conv);
+       return NULL;
+    }
+    if ((r = mdn_resconf_loadfile(conv->conf, confpath)) != mdn_success) {
+       mdnPrintf("mdnConvInit: cannot read configuration file %s: %s\n",
+                 confpath, mdn_result_tostring(r));
+       mdnConvDone(conv);
+       return NULL;
+    }
+
+    /*
+     * Set local codeset.
+     */
+    if (mdnGetPrgEncoding(encoding) == TRUE) {
+       mdnPrintf("Encoding PRG <%s>\n", encoding);
+       r = mdn_resconf_setlocalconvertername(conv->conf, encoding,
+                                             MDN_CONVERTER_RTCHECK);
+       if (r != mdn_success) {
+           mdnPrintf("mdnConvInit: cannot open converter for %s: %s\n",
+                     encoding, mdn_result_tostring(r));
+           mdnConvDone(conv);
+           return NULL;
+       }
+    }
+
+    return conv;
+}
+
+/*
+ * mdnConvReq - convert domain name in a DNS request
+ *
+ *      convert local encoding to DNS encoding
+ */
+BOOL
+mdnConvReq(CONVPTR converter, const char FAR *from, char FAR *to, size_t tolen)
+{
+    if (converter == NULL) {
+        if (strlen(from) >= tolen)
+           return FALSE;
+        strcpy(to, from);
+       return TRUE;
+    }
+        
+    if (mdn_res_nameconv(converter->conf, "ldMNI",
+                        from, to, tolen) == mdn_success)
+        return TRUE;
+    else
+        return FALSE;
+}
+
+/*
+ * mdnConvRsp - convert domain name in a DNS response
+ *
+ *      convert DNS encoding to local encoding
+ */
+
+BOOL
+mdnConvRsp(CONVPTR converter, const char FAR *from, char FAR *to, size_t tolen)
+{
+    if (converter == NULL) {
+        if (strlen(from) >= tolen)
+           return FALSE;
+        strcpy(to, from);
+       return TRUE;
+    }
+        
+    if (mdn_res_nameconv(converter->conf, "iL",
+                        from, to, tolen) == mdn_success)
+        return TRUE;
+    else
+        return FALSE;
+}
+
diff --git a/contrib/idn/mdnkit/wsock/common/dllmain.c b/contrib/idn/mdnkit/wsock/common/dllmain.c
new file mode 100644 (file)
index 0000000..c81f013
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * dllmain.c - entry for DLL
+ */
+
+#include <windows.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <process.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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+ * Tokyo, 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) Japan Network Information Center.  All rights reserved."
+ * 
+ * 4. Neither the name of JPNIC may 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.
+ * 
+ * 6. Indemnification by Licensee
+ *    Any person or entities using and/or redistributing this Software under
+ *    this License Terms and Conditions shall defend indemnify and hold
+ *    harmless JPNIC from and against any and all judgements damages,
+ *    expenses, settlement liabilities, cost and other liabilities of any
+ *    kind as a result of use and redistribution of this Software or any
+ *    claim, suite, action, litigation or proceeding by any third party
+ *    arising out of or relates to this License Terms and Conditions.
+ * 
+ * 7. Governing Law, Jurisdiction and Venue
+ *    This License Terms and Conditions shall be governed by and and
+ *    construed in accordance with the law of Japan. Any person or entities
+ *    using and/or redistributing this Software under this License Terms and
+ *    Conditions hereby agrees and consent to the personal and exclusive
+ *    jurisdiction and venue of Tokyo District Court of Japan.
+ */
+
+#include "jpnicmdn.h"
+
+/*
+ * DLL Entry
+ */
+
+BOOL    APIENTRY    DllMain(HMODULE hmod, DWORD reason, LPVOID *resv)
+{
+    return TRUE ;
+}
+
diff --git a/contrib/idn/mdnkit/wsock/common/dump.c b/contrib/idn/mdnkit/wsock/common/dump.c
new file mode 100644 (file)
index 0000000..94086ad
--- /dev/null
@@ -0,0 +1,119 @@
+/*
+ * 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+ * Tokyo, 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) Japan Network Information Center.  All rights reserved."
+ * 
+ * 4. Neither the name of JPNIC may 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.
+ * 
+ * 6. Indemnification by Licensee
+ *    Any person or entities using and/or redistributing this Software under
+ *    this License Terms and Conditions shall defend indemnify and hold
+ *    harmless JPNIC from and against any and all judgements damages,
+ *    expenses, settlement liabilities, cost and other liabilities of any
+ *    kind as a result of use and redistribution of this Software or any
+ *    claim, suite, action, litigation or proceeding by any third party
+ *    arising out of or relates to this License Terms and Conditions.
+ * 
+ * 7. Governing Law, Jurisdiction and Venue
+ *    This License Terms and Conditions shall be governed by and and
+ *    construed in accordance with the law of Japan. Any person or entities
+ *    using and/or redistributing this Software under this License Terms and
+ *    Conditions hereby agrees and consent to the personal and exclusive
+ *    jurisdiction and venue of Tokyo District Court of Japan.
+ */
+
+#include <windows.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "jpnicmdn.h"
+
+PUCHAR  dumpAddr(const char FAR *addr, int len, PUCHAR buff)
+{
+    int     i ;
+    PUCHAR  p ;
+    
+    for (i = 0, p = buff ; i < len ; i++, p += strlen(p)) {
+        sprintf(p, "%d", (addr[i] & 0xff)) ;
+       if (i + 1 < len) {
+           strcat(p, ".") ;
+       }
+    }
+    return buff ;
+}
+
+PUCHAR  dumpHost(struct hostent FAR *hp, PUCHAR buff)
+{
+    int     i ;
+    PUCHAR  p, a ;
+    
+    sprintf(buff, "%s ", hp->h_name) ;
+    p = buff + strlen(buff) ;
+    
+    for (i = 0, a = hp->h_addr_list[0] ; i < hp->h_length ; i++, p += strlen(p)) {
+        sprintf(p, "%d", (a[i] & 0xff)) ;
+       if (i + 1 < hp->h_length) {
+           strcat(p, ".") ;
+       }
+    }
+    return buff ;
+}
+
+PUCHAR  dumpName(PUCHAR name, PUCHAR buff)
+{
+    PUCHAR  sp, dp ;
+    
+    for (sp = name, dp = buff ; *sp != '\0' ; sp++) {
+        if (*sp >= 0x21 && *sp <= 0x7e) {
+           *dp++ = *sp ;
+       } else {
+           *dp++ = '\\' ;
+           *dp++ = 'x'  ;
+            sprintf(dp, "%02x", (*sp & 0xff)) ;
+           dp += 2 ;
+       }
+    }
+    *dp = '\0' ;
+    
+    return buff ;
+}
+
diff --git a/contrib/idn/mdnkit/wsock/common/encoding.c b/contrib/idn/mdnkit/wsock/common/encoding.c
new file mode 100644 (file)
index 0000000..92082e1
--- /dev/null
@@ -0,0 +1,325 @@
+/*
+ * encoding.c - get DNS/Local encodings
+ *
+ *      Software\\JPNIC\\MDN\\Where
+ *                          \\Encoding
+ *                          \\ConfFile
+ *                          \\LogFile
+ *                          \\PerProg\\<name>\\Where
+ *                          \\PerProg\\<name>\\Encoding
+ */
+
+/*
+ * 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+ * Tokyo, 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) Japan Network Information Center.  All rights reserved."
+ * 
+ * 4. Neither the name of JPNIC may 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.
+ * 
+ * 6. Indemnification by Licensee
+ *    Any person or entities using and/or redistributing this Software under
+ *    this License Terms and Conditions shall defend indemnify and hold
+ *    harmless JPNIC from and against any and all judgements damages,
+ *    expenses, settlement liabilities, cost and other liabilities of any
+ *    kind as a result of use and redistribution of this Software or any
+ *    claim, suite, action, litigation or proceeding by any third party
+ *    arising out of or relates to this License Terms and Conditions.
+ * 
+ * 7. Governing Law, Jurisdiction and Venue
+ *    This License Terms and Conditions shall be governed by and and
+ *    construed in accordance with the law of Japan. Any person or entities
+ *    using and/or redistributing this Software under this License Terms and
+ *    Conditions hereby agrees and consent to the personal and exclusive
+ *    jurisdiction and venue of Tokyo District Court of Japan.
+ */
+
+#include <windows.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+
+#include "jpnicmdn.h"
+
+#define MDN_GLOBAL     1
+#define MDN_PERPROG    2
+
+/*
+ * Registry of Encodings
+ */
+
+static  CHAR   MDNKEY_WRAPPER[] = "Software\\JPNIC\\MDN";
+static  CHAR   MDNKEY_PERPROG[] = "Software\\JPNIC\\MDN\\PerProg";
+static  CHAR   MDNVAL_WHERE[]   = "Where";
+static  CHAR   MDNVAL_ENCODE[]  = "Encoding";
+static  CHAR   MDNVAL_CONFFILE[]= "ConfFile";
+static  CHAR   MDNVAL_LOGLVL[]  = "LogLevel";
+static  CHAR   MDNVAL_LOGFILE[] = "LogFile";
+
+static int     GetRegistry(HKEY top, const char *key, const char *name,
+                           DWORD type, void *param, DWORD length);
+static char    *GetPerProgKey(char *buf);
+static int     GetIntFromRegistry(const char *name, int defvalue, int where);
+static BOOL    GetStringFromRegistry(const char *name, PUCHAR result,
+                                     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)
+{
+    UCHAR exename[256];
+    UCHAR prgname[256];
+    PUCHAR p, last;
+
+    GetModuleFileName(NULL, exename, 256);
+     
+    for (p = exename, last = NULL; *p != '\0'; p++) {
+        if (*p == '/' || *p == '\\') {
+            last = p;
+       }
+    }
+    if (last == NULL) {
+        strcpy(prgname, exename);
+    } else {
+        strcpy(prgname, last + 1);
+    }
+
+    if ((p = strrchr(prgname, '.')) != NULL) {
+        *p = '\0';
+    }
+
+    sprintf(buf, "%s\\%s", MDNKEY_PERPROG, prgname);
+    return buf;
+}
+
+static int
+GetIntFromRegistry(const char *name, int defvalue, int where)
+{
+    DWORD param;
+
+    if (where & MDN_PERPROG) {
+       /*
+        * First, try program specific setting.
+        */
+       UCHAR keyname[256];
+
+       (void)GetPerProgKey(keyname);
+
+       /*
+        * Try HKEY_CURRENT_USER and HKEY_LOCAL_MACHINE.
+        */
+       if (GetRegistry(HKEY_CURRENT_USER, keyname, name,
+                       REG_DWORD, &param, sizeof(param))) {
+           return (int)param;
+       }
+
+       if (GetRegistry(HKEY_LOCAL_MACHINE, keyname, name,
+                       REG_DWORD, &param, sizeof(param))) {
+           return (int)param;
+       }
+    }
+
+    if (where & MDN_GLOBAL) {
+       /*
+        * Try global setting.
+        */
+       if (GetRegistry(HKEY_CURRENT_USER, MDNKEY_WRAPPER, name,
+                       REG_DWORD, &param, sizeof(param))) {
+           return (int)param;
+       }
+       if (GetRegistry(HKEY_LOCAL_MACHINE, MDNKEY_WRAPPER, name,
+                       REG_DWORD, &param, sizeof(param))) {
+           return (int)param;
+       }
+    }
+
+    /*
+     * Not found.  Return default value.
+     */
+    return defvalue;
+}
+
+static BOOL
+GetStringFromRegistry(const char *name, PUCHAR result, int where)
+{
+    UCHAR param[256];
+
+    if (where & MDN_PERPROG) {
+       /*
+        * First, try program specific setting.
+        */
+       UCHAR keyname[256];
+
+       (void)GetPerProgKey(keyname);
+
+       /*
+        * Try HKEY_CURRENT_USER and HKEY_LOCAL_MACHINE.
+        */
+       if (GetRegistry(HKEY_CURRENT_USER, keyname, name,
+                       REG_SZ, param, sizeof(param))) {
+           strcpy(result, param);
+           return TRUE;
+       }
+       if (GetRegistry(HKEY_LOCAL_MACHINE, keyname, name,
+                       REG_SZ, param, sizeof(param))) {
+           strcpy(result, param);
+           return TRUE;
+       }
+    }
+
+    if (where & MDN_GLOBAL) {
+       /*
+        * Try global setting.
+        */
+       if (GetRegistry(HKEY_CURRENT_USER, MDNKEY_WRAPPER, name,
+                       REG_SZ, param, sizeof(param))) {
+           strcpy(result, param);
+           return TRUE;
+       }
+       if (GetRegistry(HKEY_LOCAL_MACHINE, MDNKEY_WRAPPER, name,
+                       REG_SZ, param, sizeof(param))) {
+           strcpy(result, param);
+           return TRUE;
+       }
+    }
+
+    /*
+     * Not found.
+     */
+    return FALSE;
+}
+
+/*
+ * mdnEncodeWhere - which module should convert domain name
+ */
+
+int     mdnEncodeWhere(void)
+{
+    int v;
+    v = GetIntFromRegistry(MDNVAL_WHERE, MDN_ENCODE_ALWAYS,
+                          MDN_GLOBAL|MDN_PERPROG);
+    mdnLogPrintf(mdn_log_level_trace, "mdnEncodeWhere: %d\n", v);
+    return v;
+}
+
+/*
+ * mdnGetConfFile - refer to Configuration file
+ */
+
+BOOL    mdnGetConfFile(PUCHAR file)
+{
+    BOOL v;
+
+    v = GetStringFromRegistry(MDNVAL_CONFFILE, file, MDN_GLOBAL);
+    if (v == TRUE) {
+       mdnLogPrintf(mdn_log_level_trace, "mdnGetConfFile: %s\n", file);
+    } else {
+       mdnLogPrintf(mdn_log_level_trace, "mdnGetConfFile: <none>\n");
+    }
+    return v;
+}
+
+/*
+ * mdnGetLogFile - refer to log file
+ */
+
+BOOL    mdnGetLogFile(PUCHAR file)
+{
+    BOOL v;
+
+    v = GetStringFromRegistry(MDNVAL_LOGFILE, file, MDN_GLOBAL);
+    if (v == TRUE) {
+       mdnLogPrintf(mdn_log_level_trace, "mdnGetLogFile: %s\n", file);
+    } else {
+       mdnLogPrintf(mdn_log_level_trace, "mdnGetLogFile: <none>\n");
+    }
+    return v;
+}
+
+/*
+ * mdnGetPrgEncoding - refer to Program's Local Encoding
+ *
+ *      use program name as registry key
+ */
+BOOL    mdnGetPrgEncoding(PUCHAR enc)
+{
+    if (GetStringFromRegistry(MDNVAL_ENCODE, enc, MDN_PERPROG) != TRUE ||
+       enc[0] == '\0') {
+       sprintf(enc, "CP%d", GetACP());
+    }
+    mdnLogPrintf(mdn_log_level_trace, "mdnGetPrgEncoding: %s\n", enc);
+    return TRUE;
+}
+
+/*
+ * mdnGetLogLevel
+ */
+
+int     mdnGetLogLevel(void)
+{
+    int v;
+
+    v = GetIntFromRegistry(MDNVAL_LOGLVL, 0, MDN_GLOBAL|MDN_PERPROG);
+    mdnLogPrintf(mdn_log_level_trace, "mdnGetLogLevel: %d\n", v);
+    return v;
+}
+
diff --git a/contrib/idn/mdnkit/wsock/common/hook.c b/contrib/idn/mdnkit/wsock/common/hook.c
new file mode 100644 (file)
index 0000000..9cf0956
--- /dev/null
@@ -0,0 +1,239 @@
+/*
+ * hook.c - Hooking Asynchronous Completion
+ */
+
+/*
+ * 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+ * Tokyo, 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) Japan Network Information Center.  All rights reserved."
+ * 
+ * 4. Neither the name of JPNIC may 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.
+ * 
+ * 6. Indemnification by Licensee
+ *    Any person or entities using and/or redistributing this Software under
+ *    this License Terms and Conditions shall defend indemnify and hold
+ *    harmless JPNIC from and against any and all judgements damages,
+ *    expenses, settlement liabilities, cost and other liabilities of any
+ *    kind as a result of use and redistribution of this Software or any
+ *    claim, suite, action, litigation or proceeding by any third party
+ *    arising out of or relates to this License Terms and Conditions.
+ * 
+ * 7. Governing Law, Jurisdiction and Venue
+ *    This License Terms and Conditions shall be governed by and and
+ *    construed in accordance with the law of Japan. Any person or entities
+ *    using and/or redistributing this Software under this License Terms and
+ *    Conditions hereby agrees and consent to the personal and exclusive
+ *    jurisdiction and venue of Tokyo District Court of Japan.
+ */
+
+#include <windows.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "jpnicmdn.h"
+
+/*
+ * Hook Managements
+ */
+
+static  HHOOK   hookHandle = NULL ;
+
+typedef struct _HOOK    *HOOKPTR ;
+
+typedef struct _HOOK {
+    HOOKPTR     prev  ;
+    HOOKPTR     next  ;
+    CONVPTR     pCnv  ;
+    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, CONVPTR pConv)
+{
+    HOOKPTR hp, prev, next ;
+    
+    if ((hp = (HOOKPTR) malloc(sizeof(HOOKREC))) == NULL) {
+        mdnPrintf("cannot create hook record\n") ;
+        return FALSE ;
+    }
+    memset(hp, 0, sizeof(HOOKREC)) ;
+    
+    hp->pCnv = pConv ;
+    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) ;
+    }
+}
+
+/*
+ * mdnHookInit - initialize Hook Management
+ */
+
+void    mdnHookInit(void)
+{
+    hookListInit() ;
+}
+
+/*
+ * mdnHookDone - finalize Hook Management
+ */
+
+void    mdnHookDone(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) ;
+    }
+    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 ;
+
+    mdnPrintf("AsyncComplete Resulting <%s>\n", dumpName(pHost->h_name, hbuff)) ;
+    mdnConvRsp(pHook->pCnv, pHost->h_name, nbuff, sizeof(nbuff)) ;
+    mdnPrintf("AsyncComplete Converted <%s>\n", dumpName(nbuff, hbuff)) ;
+    strcpy(pHost->h_name, nbuff) ;
+
+    /*
+     * Delete target
+     */
+
+    hookListDelete(pHook) ;
+
+    return 0 ;
+}
+
+/*
+ * mdnHook - hook async. completion message
+ */
+
+BOOL    mdnHook(HWND hWnd, u_int wMsg, char FAR *buf, CONVPTR pConv)
+{
+    if (hookHandle == NULL) {
+        hookHandle = SetWindowsHookEx(WH_GETMESSAGE, hookProc, NULL, GetCurrentThreadId()) ;
+    }
+    if (hookHandle == NULL) {
+        mdnPrintf("mdnHook: cannot set hook\n") ;
+        return FALSE ;
+    }
+    if (hookListAppend(hWnd, wMsg, buf, pConv) != TRUE) {
+        return FALSE ;
+    }
+    return TRUE ;
+}
diff --git a/contrib/idn/mdnkit/wsock/common/jpnicmdn.def b/contrib/idn/mdnkit/wsock/common/jpnicmdn.def
new file mode 100644 (file)
index 0000000..e824d6f
--- /dev/null
@@ -0,0 +1,21 @@
+;
+; EXPORTS in JPNICMDN
+;
+LIBRARY jpnicmdn
+DESCRIPTION "JPNICMDN - mMDNS Wrapper for WinSock by JPNIC"
+EXPORTS
+  mdnPrintf                 @1
+  mdnEncodeWhere            @2
+  mdnCheckDll               @6
+  mdnLogInit                @7
+  mdnLogPrintf              @8
+  mdnConvInit               @10
+  mdnConvDone               @11
+  mdnConvReq                @12
+  mdnConvRsp                @13
+  mdnHookInit               @15
+  mdnHookDone               @16
+  mdnHook                   @17
+  dumpAddr                  @20
+  dumpHost                  @21
+  dumpName                  @22
diff --git a/contrib/idn/mdnkit/wsock/common/jpnicmdn.h b/contrib/idn/mdnkit/wsock/common/jpnicmdn.h
new file mode 100644 (file)
index 0000000..63ea9b2
--- /dev/null
@@ -0,0 +1,133 @@
+/*
+ * jpnicmdn.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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+ * Tokyo, 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) Japan Network Information Center.  All rights reserved."
+ * 
+ * 4. Neither the name of JPNIC may 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.
+ * 
+ * 6. Indemnification by Licensee
+ *    Any person or entities using and/or redistributing this Software under
+ *    this License Terms and Conditions shall defend indemnify and hold
+ *    harmless JPNIC from and against any and all judgements damages,
+ *    expenses, settlement liabilities, cost and other liabilities of any
+ *    kind as a result of use and redistribution of this Software or any
+ *    claim, suite, action, litigation or proceeding by any third party
+ *    arising out of or relates to this License Terms and Conditions.
+ * 
+ * 7. Governing Law, Jurisdiction and Venue
+ *    This License Terms and Conditions shall be governed by and and
+ *    construed in accordance with the law of Japan. Any person or entities
+ *    using and/or redistributing this Software under this License Terms and
+ *    Conditions hereby agrees and consent to the personal and exclusive
+ *    jurisdiction and venue of Tokyo District Court of Japan.
+ */
+
+#ifndef _JPNICMDN_H
+#define _JPNICMDN_H
+
+extern void mdnPrintf(PUCHAR fmt, ...);
+extern void mdnLogPrintf(int level, PUCHAR fmt, ...);
+extern void mdnLogProc(int level, const char *msg);
+extern void mdnLogInit(void);
+
+extern PUCHAR dumpAddr(const char FAR *addr, int len, PUCHAR buff);
+extern PUCHAR dumpHost(struct hostent FAR *hp, PUCHAR buff);
+extern PUCHAR dumpName(PUCHAR name, PUCHAR buff);
+
+extern int mdnEncodeWhere(void);
+
+#define MDN_ENCODE_ALWAYS   0
+#define MDN_ENCODE_CHECK    1
+#define MDN_ENCODE_ONLY11   2
+#define MDN_ENCODE_ONLY20   3
+
+extern BOOL mdnGetPrgEncoding(PUCHAR enc);
+extern BOOL mdnGetConfFile(PUCHAR file);
+extern BOOL mdnGetLogFile(PUCHAR file);
+
+extern BOOL mdnCheckDll(PUCHAR name);
+
+extern int  mdnGetLogLevel(void) ;  /* 0 : fatal        */
+                                    /* 1 : error        */
+                                   /* 2 : warning      */
+                                   /* 3 : info         */
+                                   /* 4 : trace        */
+                                   /* 5 : dump         */
+
+/*
+ * Converter I/F, wrapper for libmdn
+ */
+
+#include <mdn/result.h>
+#include <mdn/log.h>
+#include <mdn/resconf.h>
+#include <mdn/res.h>
+#include <mdn/version.h>
+
+/*
+ * Conversion Context, determined when attached to process
+ */
+typedef struct _CONV {
+    mdn_resconf_t conf;
+} CONVREC, *CONVPTR;
+
+extern CONVPTR mdnConvInit(void);
+extern void mdnConvDone(CONVPTR converter);
+
+/*
+ * Converting Request/Response
+ */
+
+extern BOOL mdnConvReq(CONVPTR converter, const char FAR *from,
+                      char FAR *to, size_t tolen);
+extern BOOL mdnConvRsp(CONVPTR converter, const char FAR *from,
+                      char FAR *to, size_t tolen);
+
+/*
+ * Hook for Asynchronouse Query
+ */
+
+extern void mdnHookInit(void);
+extern void mdnHookDone(void);
+extern BOOL mdnHook(HWND hWnd, u_int wMsg, char FAR *buf, CONVPTR pConv);
+
+#endif  /* _JPNICMDN_H */
diff --git a/contrib/idn/mdnkit/wsock/common/make.wnt b/contrib/idn/mdnkit/wsock/common/make.wnt
new file mode 100644 (file)
index 0000000..17b0a10
--- /dev/null
@@ -0,0 +1,125 @@
+#
+# 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+# Tokyo, 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) Japan Network Information Center.  All rights reserved."
+# 
+# 4. Neither the name of JPNIC may 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.
+# 
+# 6. Indemnification by Licensee
+#    Any person or entities using and/or redistributing this Software under
+#    this License Terms and Conditions shall defend indemnify and hold
+#    harmless JPNIC from and against any and all judgements damages,
+#    expenses, settlement liabilities, cost and other liabilities of any
+#    kind as a result of use and redistribution of this Software or any
+#    claim, suite, action, litigation or proceeding by any third party
+#    arising out of or relates to this License Terms and Conditions.
+# 
+# 7. Governing Law, Jurisdiction and Venue
+#    This License Terms and Conditions shall be governed by and and
+#    construed in accordance with the law of Japan. Any person or entities
+#    using and/or redistributing this Software under this License Terms and
+#    Conditions hereby agrees and consent to the personal and exclusive
+#    jurisdiction and venue of Tokyo District Court of Japan.
+
+!include <win32.mak>
+
+SYSLIBS = $(libcdll) kernel32.lib advapi32.lib user32.lib
+
+#
+# Files to use
+#
+
+HDRS = jpnicmdn.h
+SRCS = dllmain.c   printf.c   dump.c   checkdll.c   encoding.c   convert.c   hook.c
+OBJS = dllmain.obj printf.obj dump.obj checkdll.obj encoding.obj convert.obj hook.obj
+LIBS = ..\..\lib\libmdn.lib ..\..\win\iconv.lib
+
+cflags = $(cflags) -I..\..\include
+
+#
+# Targets to Build
+#
+
+TARGETS = jpnicmdn.dll jpnicmdn.lib
+
+all : $(TARGETS)
+
+jpnicmdn.dll : jpnicmdn.def $(OBJS) $(LIBS)
+       $(link) $(dlllflags) /OUT:jpnicmdn.dll /DEF:jpnicmdn.def $(OBJS) $(LIBS) $(SYSLIBS)
+
+jpnicmdn.lib : jpnicmdn.def
+       LIB /DEF:jpnicmdn.def /MACHINE:IX86
+
+install : $(TARGETS)
+       copy jpnicmdn.dll ..\bin\jpnicmdn.dll
+
+clean : force
+       -del *.obj
+       -del *.lib
+       -del *.dll
+       -del *.exp
+
+#
+# Dependencies
+#
+
+dllmain.obj : dllmain.c $(HDRS)
+       $(cc) $(cflags) $(cvarsdll) -DDEBUG $*.c
+
+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/mdnkit/wsock/common/printf.c b/contrib/idn/mdnkit/wsock/common/printf.c
new file mode 100644 (file)
index 0000000..6c711a7
--- /dev/null
@@ -0,0 +1,137 @@
+/*
+ * printf.c - printf like debug print function
+ */
+
+/*
+ * 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+ * Tokyo, 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) Japan Network Information Center.  All rights reserved."
+ * 
+ * 4. Neither the name of JPNIC may 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.
+ * 
+ * 6. Indemnification by Licensee
+ *    Any person or entities using and/or redistributing this Software under
+ *    this License Terms and Conditions shall defend indemnify and hold
+ *    harmless JPNIC from and against any and all judgements damages,
+ *    expenses, settlement liabilities, cost and other liabilities of any
+ *    kind as a result of use and redistribution of this Software or any
+ *    claim, suite, action, litigation or proceeding by any third party
+ *    arising out of or relates to this License Terms and Conditions.
+ * 
+ * 7. Governing Law, Jurisdiction and Venue
+ *    This License Terms and Conditions shall be governed by and and
+ *    construed in accordance with the law of Japan. Any person or entities
+ *    using and/or redistributing this Software under this License Terms and
+ *    Conditions hereby agrees and consent to the personal and exclusive
+ *    jurisdiction and venue of Tokyo District Court of Japan.
+ */
+
+#include <windows.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "jpnicmdn.h"
+
+/*
+ * Debug Tracer for DLL
+ */
+
+static  UCHAR   logName[128] = { 0 } ;
+static int     logLevel = -1 ;
+
+void    mdnPrintf(PUCHAR fmt, ...)
+{
+    va_list arg_ptr ;
+    PUCHAR  ep  ;
+    FILE    *fp ;
+    UCHAR   msg[256] ;
+
+    if (logLevel < 0 || logName[0] == '\0') return;
+
+    va_start(arg_ptr, fmt) ;
+    vsprintf(msg, fmt, arg_ptr) ;
+    va_end(arg_ptr) ;
+    
+    if ((fp = fopen(logName, "a")) != NULL) {
+        fputs(msg, fp) ;
+       fclose(fp) ;
+    }
+}
+
+void    mdnLogPrintf(int level, PUCHAR fmt, ...)
+{
+    va_list arg_ptr ;
+    PUCHAR  ep  ;
+    FILE    *fp ;
+    UCHAR   msg[256] ;
+
+    if (level > logLevel || logName[0] == '\0') return;
+
+    va_start(arg_ptr, fmt) ;
+    vsprintf(msg, fmt, arg_ptr) ;
+    va_end(arg_ptr) ;
+    
+    if ((fp = fopen(logName, "a")) != NULL) {
+        fputs(msg, fp) ;
+       fclose(fp) ;
+    }
+}
+
+void    mdnLogProc(int level, const char *msg)
+{
+    PUCHAR  ep  ;
+    FILE    *fp ;
+
+    if (logLevel < 0 || logName[0] == '\0') return;
+
+    if ((fp = fopen(logName, "a")) != NULL) {
+        fputs(msg, fp) ;
+       fclose(fp) ;
+    }
+}
+
+void    mdnLogInit(void)
+{
+    logLevel = mdnGetLogLevel();
+    /* If log file is not stored in the registry, don't do logging. */
+    if (mdnGetLogFile(logName) == FALSE) {
+       logLevel = -1;
+    }
+    mdn_log_setproc(mdnLogProc) ;
+    mdn_log_setlevel(logLevel < 0 ? 0 : logLevel) ;
+}
diff --git a/contrib/idn/mdnkit/wsock/config/make.wnt b/contrib/idn/mdnkit/wsock/config/make.wnt
new file mode 100644 (file)
index 0000000..dd6e636
--- /dev/null
@@ -0,0 +1,74 @@
+#
+# 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+# Tokyo, 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) Japan Network Information Center.  All rights reserved."
+# 
+# 4. Neither the name of JPNIC may 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.
+# 
+# 6. Indemnification by Licensee
+#    Any person or entities using and/or redistributing this Software under
+#    this License Terms and Conditions shall defend indemnify and hold
+#    harmless JPNIC from and against any and all judgements damages,
+#    expenses, settlement liabilities, cost and other liabilities of any
+#    kind as a result of use and redistribution of this Software or any
+#    claim, suite, action, litigation or proceeding by any third party
+#    arising out of or relates to this License Terms and Conditions.
+# 
+# 7. Governing Law, Jurisdiction and Venue
+#    This License Terms and Conditions shall be governed by and and
+#    construed in accordance with the law of Japan. Any person or entities
+#    using and/or redistributing this Software under this License Terms and
+#    Conditions hereby agrees and consent to the personal and exclusive
+#    jurisdiction and venue of Tokyo District Court of Japan.
+
+TARGETS = mdnconf.exe
+
+all : $(TARGETS)
+
+mdnconf.exe : mdnconf.tcl
+       freewrap mdnconf.tcl
+
+install : $(TARGETS)
+       copy mdnconf.exe ..\bin
+
+clean : force
+       -del mdnconf.exe
+
+force :
diff --git a/contrib/idn/mdnkit/wsock/config/mdnconf.tcl b/contrib/idn/mdnkit/wsock/config/mdnconf.tcl
new file mode 100644 (file)
index 0000000..068aa16
--- /dev/null
@@ -0,0 +1,943 @@
+# $Id: mdnconf.tcl,v 1.1 2001/06/09 00:30:55 tale Exp $
+#
+# mdnconf.tcl - configure mDN 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+#  Tokyo, 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) Japan Network Information Center.  All rights reserved."
+#  
+#  4. Neither the name of JPNIC may 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.
+#  
+#  6. Indemnification by Licensee
+#     Any person or entities using and/or redistributing this Software under
+#     this License Terms and Conditions shall defend indemnify and hold
+#     harmless JPNIC from and against any and all judgements damages,
+#     expenses, settlement liabilities, cost and other liabilities of any
+#     kind as a result of use and redistribution of this Software or any
+#     claim, suite, action, litigation or proceeding by any third party
+#     arising out of or relates to this License Terms and Conditions.
+#  
+#  7. Governing Law, Jurisdiction and Venue
+#     This License Terms and Conditions shall be governed by and and
+#     construed in accordance with the law of Japan. Any person or entities
+#     using and/or redistributing this Software under this License Terms and
+#     Conditions hereby agrees and consent to the personal and exclusive
+#     jurisdiction and venue of Tokyo District Court of Japan.
+#############################################################################
+
+global  configFile configBack
+global  registryKey registryEnc registryDef
+global  filesCpy filesRen filesDel
+
+# mDNkit version
+set version    "2.1"
+
+set configFile  "mdnconf.lst"   ;# list of wrapped program
+set configBack  "mdnconf.bak"   ;# backup of previous data
+
+set serverKey          "HKEY_LOCAL_MACHINE\\Software\\JPNIC\\MDN"
+set serverLogLevel     LogLevel
+set serverLogLevelDef  -1
+set serverLogLevelNone -1
+set serverLogFile      LogFile
+set serverLogFileDef   {C:\mdn_wrapper.log}
+set serverConfFile     ConfFile
+
+set perprogKey         "HKEY_LOCAL_MACHINE\\Software\\JPNIC\\MDN\\PerProg\\"
+set perprogEnc         Encoding
+set perprogDef         Default
+
+set logFileNameDef     mdn_wrapper.log
+set confFileNameDef    mdn.conf
+
+set filesCpy11 { "jpnicmdn.dll" "iconv.dll" "wsock32.dll" }
+set filesCpy20 { "jpnicmdn.dll" "iconv.dll" "wsock32.dll" "ws2_32.dll" }
+set filesRen11 { { "wsock32.dll" "wsock32o.dll" } }
+set filesRen20 { { "wsock32.dll" "wsock32o.dll" } { "ws2_32.dll" "ws2_32o.dll" } }
+set filesDel11 { "jpnicmdn.dll" "iconv.dll" "wsock32.dll" "wsock32o.dll" }
+set filesDel20 { "jpnicmdn.dll" "iconv.dll" "wsock32.dll" "wsock32o.dll" "ws2_32.dll" "ws2_32o.dll" }
+
+########################################################################
+#
+# 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 } {
+    set dir [file dirname $prg]
+    return $dir
+}
+
+########################################################################
+#
+# 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 } {
+    return [$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
+    }
+
+    global tcl_platform
+    set os $tcl_platform(platform)
+    if { [string compare $os "windows"] != 0 } {
+        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
+
+    global tcl_platform
+    set os $tcl_platform(platform)
+    if { [string compare $os "windows"] != 0 } {
+        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 tcl_platform
+    global filesCpy11 filesCpy20 filesRen11 filesRen20
+    
+    set pl $tcl_platform(platform)
+    if { [string compare $pl "windows"] != 0 } {
+        return 1
+    }
+
+    set os $tcl_platform(os)
+    switch $os {
+        "Windows 95" {
+            set winDir $env(windir)
+           set sysDir $winDir/system
+           set filesCpy $filesCpy11
+           set filesRen $filesRen11
+       }
+        "Windows 98" {
+            set winDir $env(windir)
+            set sysDir $winDir/system
+           set filesCpy $filesCpy20
+           set filesRen $filesRen20
+        }
+       default {
+            set winDir $env(SystemRoot)
+            set sysDir $winDir/system32
+           set filesCpy $filesCpy20
+           set filesRen $filesRen20
+        }
+    }
+
+    set toDir [getDirName $prg ]
+
+    foreach n $filesCpy {
+        file copy -force $n $toDir
+    }
+    foreach n $filesRen {
+        set src [lindex $n 0]
+       set dst [lindex $n 1]
+        file copy -force $sysDir/$src $toDir/$dst
+    }
+    return 0
+}
+
+proc fileRemove { prg } {
+    
+    global tcl_platform
+    global filesDel11 filesDel20
+    
+    set pl $tcl_platform(platform)
+    if { [string compare $pl "windows"] != 0 } {
+        return 1
+    }
+
+    set os $tcl_platform(os)
+    switch $os {
+        "Windows 95" {
+           set filesDel $filesDel11
+       }
+        "Windows 98" {
+           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]
+
+    if {[string compare $prgName {}] == 0} {
+       confErrorDialog $dlg "Program must be specified.\nClick \"Browse..\" button for browsing."
+       return
+    }
+    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 { [checkList $lb $prgName] == 0 } {
+        appendList $lb $prgName
+    }
+    saveList [getList $lb]
+    destroy $dlg
+}
+
+proc execUnwrap { pw lb dlg prg } {
+
+    set prgName [$prg get]
+    
+    if { [checkList $lb $prgName] == 1 } {
+        fileRemove $prgName
+    }
+    deleteList $lb $prgName
+    saveList [getList $lb]
+    destroy $dlg
+}
+########################################################################
+#
+# 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
+
+    set idx [$lb curselection]
+    if { [llength $idx] == 1 } {
+        set prg [$lb get $idx]
+    } else {
+        set prg ""
+    }
+
+    set top .wrap
+    toplevel $top
+    grab     $top
+    wm title $top "mDN 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
+    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 "mDN 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 {mdnWrapper Configuration} \
+           -message {Really unwrap all programs?}]
+    if {[string compare $ans yes] != 0} {
+       return
+    }
+    foreach prog [$lb get 0 end] {
+       fileRemove $prog
+    }
+    $lb delete 0 end
+    saveList {}
+}
+
+proc rewrapAll {pw lb} {
+    set ans [tk_messageBox -type yesno -default yes -icon question \
+           -parent $pw -title {mdnWrapper 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 "mDN 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 "mDN 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 {mDN 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 "mdnWrapper Configuration" \
+           -message "Really delete $_logFile?"]
+    if {[string compare $ans yes] == 0} {
+       file delete $_logFile
+    }
+}
+
+########################################################################
+#
+# dialog for advanced configuration
+#
+
+proc advancedConf {pw} {
+    global normalizerList normalizerDef
+
+    set top .adv
+    catch {destroy $top}
+    toplevel $top
+    wm title $top "mDN 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 {MDN 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 {MDN 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 {mDN 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 {mDN Wrapper Configuration Error} -message $message
+}
+
+proc isWindows {} {
+    global tcl_platform
+    expr {[string compare $tcl_platform(platform) "windows"] == 0}
+}
+
+########################################################################
+#
+# config program start here
+#
+
+wm title    . "mDN Wrapper - Configuration"
+wm iconname . "mDN Wrapper - Configuration"
+
+
+label .title -bd 1 -relief raised -pady 5 \
+       -text "mDN 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/mdnkit/wsock/make.wnt b/contrib/idn/mdnkit/wsock/make.wnt
new file mode 100644 (file)
index 0000000..9608722
--- /dev/null
@@ -0,0 +1,106 @@
+#
+# Top Level Makefile for building WINSOCK mDNS 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+# Tokyo, 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) Japan Network Information Center.  All rights reserved."
+# 
+# 4. Neither the name of JPNIC may 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.
+# 
+# 6. Indemnification by Licensee
+#    Any person or entities using and/or redistributing this Software under
+#    this License Terms and Conditions shall defend indemnify and hold
+#    harmless JPNIC from and against any and all judgements damages,
+#    expenses, settlement liabilities, cost and other liabilities of any
+#    kind as a result of use and redistribution of this Software or any
+#    claim, suite, action, litigation or proceeding by any third party
+#    arising out of or relates to this License Terms and Conditions.
+# 
+# 7. Governing Law, Jurisdiction and Venue
+#    This License Terms and Conditions shall be governed by and and
+#    construed in accordance with the law of Japan. Any person or entities
+#    using and/or redistributing this Software under this License Terms and
+#    Conditions hereby agrees and consent to the personal and exclusive
+#    jurisdiction and venue of Tokyo District Court of Japan.
+
+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 ..\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 ..
+
+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/mdnkit/wsock/wsock11/dlldef.h b/contrib/idn/mdnkit/wsock/wsock11/dlldef.h
new file mode 100644 (file)
index 0000000..b66989e
--- /dev/null
@@ -0,0 +1,116 @@
+/*
+ * 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+ * Tokyo, 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) Japan Network Information Center.  All rights reserved."
+ * 
+ * 4. Neither the name of JPNIC may 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.
+ * 
+ * 6. Indemnification by Licensee
+ *    Any person or entities using and/or redistributing this Software under
+ *    this License Terms and Conditions shall defend indemnify and hold
+ *    harmless JPNIC from and against any and all judgements damages,
+ *    expenses, settlement liabilities, cost and other liabilities of any
+ *    kind as a result of use and redistribution of this Software or any
+ *    claim, suite, action, litigation or proceeding by any third party
+ *    arising out of or relates to this License Terms and Conditions.
+ * 
+ * 7. Governing Law, Jurisdiction and Venue
+ *    This License Terms and Conditions shall be governed by and and
+ *    construed in accordance with the law of Japan. Any person or entities
+ *    using and/or redistributing this Software under this License Terms and
+ *    Conditions hereby agrees and consent to the personal and exclusive
+ *    jurisdiction and venue of Tokyo District Court of Japan.
+ */
+
+#ifndef _DLLDEF_H
+#define _DLLDEF_H
+
+#include "../common/jpnicmdn.h"
+
+/*
+ * Execution Tracing
+ */
+extern  int     procPid   ;
+extern  UCHAR   procExe[] ;
+
+#ifdef  DEBUG
+#define TRACE   mdnPrintf("%04x ws11 : ",procPid) ; mdnPrintf
+#define FATAL   mdnPrintf("%04x ws11 : ",procPid) ; mdnPrintf
+#else
+#define TRACE
+#define FATAL   mdnPrintf("%04x ws11 : ",procPid) ; mdnPrintf
+#endif
+
+/*
+ * Encoding Names and Options
+ */
+
+extern  BOOL    encodeHere    ;
+extern  CONVPTR encodeCtx     ;
+
+/*
+ * 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);
+
+/*
+ * Original DLL loader/unloader.
+ */
+void    linkFree(void) ;
+BOOL    linkLoad(void) ;
+
+#endif  /* _DLLDEF_H */
diff --git a/contrib/idn/mdnkit/wsock/wsock11/dllfunc.c b/contrib/idn/mdnkit/wsock/wsock11/dllfunc.c
new file mode 100644 (file)
index 0000000..d5c7a57
--- /dev/null
@@ -0,0 +1,205 @@
+/*
+ * 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+ * Tokyo, 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) Japan Network Information Center.  All rights reserved."
+ * 
+ * 4. Neither the name of JPNIC may 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.
+ * 
+ * 6. Indemnification by Licensee
+ *    Any person or entities using and/or redistributing this Software under
+ *    this License Terms and Conditions shall defend indemnify and hold
+ *    harmless JPNIC from and against any and all judgements damages,
+ *    expenses, settlement liabilities, cost and other liabilities of any
+ *    kind as a result of use and redistribution of this Software or any
+ *    claim, suite, action, litigation or proceeding by any third party
+ *    arising out of or relates to this License Terms and Conditions.
+ * 
+ * 7. Governing Law, Jurisdiction and Venue
+ *    This License Terms and Conditions shall be governed by and and
+ *    construed in accordance with the law of Japan. Any person or entities
+ *    using and/or redistributing this Software under this License Terms and
+ *    Conditions hereby agrees and consent to the personal and exclusive
+ *    jurisdiction and venue of Tokyo District Court of Japan.
+ */
+
+#include <windows.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <process.h>
+
+#include "dlldef.h"
+
+int 
+PASCAL FAR gethostname(char FAR * name, int namelen)
+{
+    int     ret ;
+    
+    TRACE("ENTER gethostname\n") ;
+    ret = _org_gethostname(name, namelen) ;
+    TRACE("LEAVE gethostname %d <%s>\n", ret, name) ;
+
+    return ret ;
+}
+
+struct hostent FAR * 
+PASCAL FAR gethostbyname(const char FAR * name)
+{
+    struct hostent FAR *ret ;
+    char    nbuff[64]  ;
+    char    hbuff[256] ;
+    BOOL    stat ;
+    
+    TRACE("ENTER gethostbyname <%s>\n", (name != NULL ? name : "NULL")) ;
+
+    if (encodeHere != TRUE) {
+        ret = _org_gethostbyname(name) ;
+    } else if (name == NULL) {
+        ret = _org_gethostbyname(name) ;
+    } else {
+        stat = mdnConvReq(encodeCtx, name, nbuff, sizeof(nbuff)) ;
+       if (stat == FALSE) {
+           TRACE("mdnConvReq failed\n") ;
+           ret = NULL ;
+       } else {
+           TRACE("Converted Name <%s>\n", dumpName(nbuff, hbuff)) ;
+            ret = _org_gethostbyname(nbuff) ;
+        }
+    }
+
+    if (ret != NULL && encodeHere) {
+        TRACE("Resulting Name <%s>\n", dumpName(ret->h_name, hbuff)) ;
+        stat = mdnConvRsp(encodeCtx, ret->h_name, nbuff, sizeof(nbuff)) ;
+       if (stat == FALSE) {
+           TRACE("mdnConvRsp failed\n") ;
+           ret = NULL ;
+       } else {
+            TRACE("Converted Back <%s>\n", dumpName(nbuff, hbuff)) ;
+            strcpy(ret->h_name, nbuff) ;
+        }
+    }
+
+    if (ret == NULL) {
+        TRACE("LEAVE gethostbyname NULL\n") ;
+    } else {
+        TRACE("LEAVE gethostbyname <%s>\n", dumpHost(ret, hbuff)) ;
+    }
+    return ret ;
+}
+
+struct hostent FAR * 
+PASCAL FAR gethostbyaddr(const char FAR * addr, int len, int type)
+{
+    struct hostent FAR *ret ;
+    char    nbuff[64]  ;
+    char    abuff[256] ;
+    char    hbuff[256] ;
+    BOOL    stat ;
+    
+    TRACE("ENTER gethostbyaddr <%s>\n", dumpAddr(addr, len, abuff)) ;
+
+    ret = _org_gethostbyaddr(addr, len, type) ;
+
+    if (ret != NULL && encodeHere) {
+        TRACE("Resulting Name <%s>\n", dumpName(ret->h_name, hbuff)) ;
+        stat = mdnConvRsp(encodeCtx, ret->h_name, nbuff, sizeof(nbuff)) ;
+       if (stat == FALSE) {
+           TRACE("mdnConvRsp failed\n") ;
+           ret = NULL ;
+       } else {
+            TRACE("Converted Back <%s>\n", dumpName(nbuff, hbuff)) ;
+           strcpy(ret->h_name, nbuff) ;
+       }
+    }
+
+    if (ret == NULL) {
+        TRACE("LEAVE gethostbyaddr NULL\n") ;
+    } else {
+        TRACE("LEAVE gethostbyaddr <%s>\n", dumpHost(ret, hbuff)) ;
+    }    
+    return ret ;
+}
+
+HANDLE
+PASCAL FAR WSAAsyncGetHostByName(HWND hWnd, u_int wMsg, 
+        const char FAR * name, char FAR * buf, int buflen)
+{
+    HANDLE  ret ;
+    char    nbuff[64]  ;
+    char    hbuff[256] ;
+    
+    TRACE("ENTER WSAAsyncGetHostByName <%s>\n", name) ;
+
+    if (encodeHere != TRUE) {
+        ret = _org_WSAAsyncGetHostByName(hWnd, wMsg, name, buf, buflen) ;
+    } else if (name == NULL) {
+        ret = _org_WSAAsyncGetHostByName(hWnd, wMsg, name, buf, buflen) ;
+    } else {
+        mdnHook(hWnd, wMsg, buf, encodeCtx) ;
+       mdnConvReq(encodeCtx, name, nbuff, sizeof(nbuff)) ;
+       TRACE("Converted Name <%s>\n", dumpName(nbuff, hbuff)) ;
+        ret = _org_WSAAsyncGetHostByName(hWnd, wMsg, nbuff, buf, buflen) ;
+    }
+
+    TRACE("LEAVE WSAAsyncGetHostByName HANDLE %08x\n", ret) ;
+
+    return ret ;
+}
+
+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] ;
+    
+    if (encodeHere) {
+        mdnHook(hWnd, wMsg, buf, encodeCtx) ;
+    }
+
+    TRACE("ENTER WSAAsyncGetHostByAddr <%s>\n", dumpAddr(addr, len, 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/mdnkit/wsock/wsock11/dllload.c b/contrib/idn/mdnkit/wsock/wsock11/dllload.c
new file mode 100644 (file)
index 0000000..f01c20e
--- /dev/null
@@ -0,0 +1,114 @@
+/*
+ * 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+ * Tokyo, 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) Japan Network Information Center.  All rights reserved."
+ * 
+ * 4. Neither the name of JPNIC may 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.
+ * 
+ * 6. Indemnification by Licensee
+ *    Any person or entities using and/or redistributing this Software under
+ *    this License Terms and Conditions shall defend indemnify and hold
+ *    harmless JPNIC from and against any and all judgements damages,
+ *    expenses, settlement liabilities, cost and other liabilities of any
+ *    kind as a result of use and redistribution of this Software or any
+ *    claim, suite, action, litigation or proceeding by any third party
+ *    arising out of or relates to this License Terms and Conditions.
+ * 
+ * 7. Governing Law, Jurisdiction and Venue
+ *    This License Terms and Conditions shall be governed by and and
+ *    construed in accordance with the law of Japan. Any person or entities
+ *    using and/or redistributing this Software under this License Terms and
+ *    Conditions hereby agrees and consent to the personal and exclusive
+ *    jurisdiction and venue of Tokyo District Court of Japan.
+ */
+
+#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 
+ */
+static  HINSTANCE   dllHandle = NULL ;
+
+/*
+ * linkFree - dispose module
+ */
+
+void    linkFree(void)
+{
+    if (dllHandle != NULL) {
+        FreeLibrary(dllHandle) ;
+       dllHandle = NULL ;
+    }
+}
+
+/*
+ * linkLoad - load & link original DLL
+ */
+
+BOOL    linkLoad(void)
+{
+    PUCHAR  name ;
+    
+    /*
+     * Load Original DLL
+     */
+     
+    name = "WSOCK32O" ;
+    
+    if ((dllHandle = LoadLibrary(name)) == NULL) {
+        FATAL("linkLoad - no %s\n", name) ;
+       return FALSE ;
+    }
+    
+    return TRUE ;
+}
+
+#define DLLHANDLE      dllHandle
+#include "dllstub.c"
diff --git a/contrib/idn/mdnkit/wsock/wsock11/dllmain.c b/contrib/idn/mdnkit/wsock/wsock11/dllmain.c
new file mode 100644 (file)
index 0000000..5665b69
--- /dev/null
@@ -0,0 +1,144 @@
+/*
+ * 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+ * Tokyo, 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) Japan Network Information Center.  All rights reserved."
+ * 
+ * 4. Neither the name of JPNIC may 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.
+ * 
+ * 6. Indemnification by Licensee
+ *    Any person or entities using and/or redistributing this Software under
+ *    this License Terms and Conditions shall defend indemnify and hold
+ *    harmless JPNIC from and against any and all judgements damages,
+ *    expenses, settlement liabilities, cost and other liabilities of any
+ *    kind as a result of use and redistribution of this Software or any
+ *    claim, suite, action, litigation or proceeding by any third party
+ *    arising out of or relates to this License Terms and Conditions.
+ * 
+ * 7. Governing Law, Jurisdiction and Venue
+ *    This License Terms and Conditions shall be governed by and and
+ *    construed in accordance with the law of Japan. Any person or entities
+ *    using and/or redistributing this Software under this License Terms and
+ *    Conditions hereby agrees and consent to the personal and exclusive
+ *    jurisdiction and venue of Tokyo District Court of Japan.
+ */
+
+#include <windows.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <process.h>
+
+#include "dlldef.h"
+
+/*
+ * Control Variables
+ */
+int     procPid      =   0   ;
+UCHAR   procExe[256] = { 0 } ;
+
+BOOL    encodeHere = FALSE ;
+CONVPTR encodeCtx  = NULL  ;
+
+/*
+ * DLL Entry
+ */
+
+BOOL    APIENTRY    DllMain(HMODULE hmod, DWORD reason, LPVOID *resv)
+{
+    switch (reason) {
+
+    case DLL_PROCESS_ATTACH :
+        procPid = getpid() ;
+        GetModuleFileName(NULL, procExe, 256) ;
+
+        TRACE("Attached to Process <%s>\n", procExe) ;
+        
+       if (linkLoad() != TRUE) {
+            FATAL("cannot link to original DLL\n") ;
+           return FALSE ;
+       }
+
+        mdnLogInit() ;
+       mdnHookInit() ;
+
+        switch (mdnEncodeWhere()) {
+        case MDN_ENCODE_ALWAYS :
+       case MDN_ENCODE_ONLY11 :
+           encodeHere = TRUE ;
+           break ;
+       case MDN_ENCODE_CHECK :
+            if (mdnCheckDll("WS2_32")) {
+                encodeHere = FALSE ;
+            } else {
+               encodeHere = TRUE  ;
+           }
+           break ;
+       default :
+           encodeHere = FALSE ;
+           break ;
+        }
+
+       if (encodeHere == FALSE) {
+           TRACE("not encode here\n") ;
+       } else {
+           encodeCtx = mdnConvInit() ;
+           TRACE("Context %08x\n", encodeCtx) ;
+       }
+        break ;
+
+    case DLL_PROCESS_DETACH :
+        if (encodeCtx != NULL) {
+           mdnConvDone(encodeCtx) ;
+       }
+       mdnHookDone() ;
+        linkFree() ;
+        TRACE("Detached from Process\n") ;
+        break ;
+
+    case DLL_THREAD_ATTACH  :
+        break ;
+    case DLL_THREAD_DETACH  :
+        break ;
+    }
+    return TRUE ;
+}
+
diff --git a/contrib/idn/mdnkit/wsock/wsock11/dllstub.c b/contrib/idn/mdnkit/wsock/wsock11/dllstub.c
new file mode 100644 (file)
index 0000000..6fa21a1
--- /dev/null
@@ -0,0 +1,1541 @@
+/* $Id: dllstub.c,v 1.1 2001/06/09 00:30:55 tale 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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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/mdnkit/wsock/wsock11/make.wnt b/contrib/idn/mdnkit/wsock/wsock11/make.wnt
new file mode 100644 (file)
index 0000000..b634603
--- /dev/null
@@ -0,0 +1,114 @@
+#
+# 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+# Tokyo, 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) Japan Network Information Center.  All rights reserved."
+# 
+# 4. Neither the name of JPNIC may 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.
+# 
+# 6. Indemnification by Licensee
+#    Any person or entities using and/or redistributing this Software under
+#    this License Terms and Conditions shall defend indemnify and hold
+#    harmless JPNIC from and against any and all judgements damages,
+#    expenses, settlement liabilities, cost and other liabilities of any
+#    kind as a result of use and redistribution of this Software or any
+#    claim, suite, action, litigation or proceeding by any third party
+#    arising out of or relates to this License Terms and Conditions.
+# 
+# 7. Governing Law, Jurisdiction and Venue
+#    This License Terms and Conditions shall be governed by and and
+#    construed in accordance with the law of Japan. Any person or entities
+#    using and/or redistributing this Software under this License Terms and
+#    Conditions hereby agrees and consent to the personal and exclusive
+#    jurisdiction and venue of Tokyo District Court of Japan.
+
+!include <win32.mak>
+
+SYSLIBS = $(libcdll) kernel32.lib advapi32.lib
+
+#
+# Files to use
+#
+
+HDRS = dlldef.h ..\common\jpnicmdn.h
+SRCS = dllmain.c   dllload.c   dllfunc.c dllstub.c
+OBJS = dllmain.obj dllload.obj dllfunc.obj
+LIBS = ..\common\jpnicmdn.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/mdnkit/wsock/wsock11/wsock32.def b/contrib/idn/mdnkit/wsock/wsock11/wsock32.def
new file mode 100644 (file)
index 0000000..b37a5f7
--- /dev/null
@@ -0,0 +1,87 @@
+;
+; Library Defition for mDNS'd WSOCK32.DLL
+;
+LIBRARY wsock32
+DESCRIPTION "JPNIC/mDNS Wrapper 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/mdnkit/wsock/wsock11/wsock32o.def b/contrib/idn/mdnkit/wsock/wsock11/wsock32o.def
new file mode 100644 (file)
index 0000000..89443b1
--- /dev/null
@@ -0,0 +1,88 @@
+;
+; EXPORTS in WSOCK32
+;
+LIBRARY wsock32o
+DESCRIPTION "WSOCK32 original exports"
+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
+
similarity index 61%
rename from contrib/idn/mdnkit/include/config.h
rename to contrib/idn/mdnkit/wsock/wsock20/dlldef.h
index c87e3ffbf3abd90b66e98a6ea1f3c170ef814d0c..4c7496f47dd0be3851d1da3eacf5aea9eca12f69 100644 (file)
@@ -1,6 +1,7 @@
-/* include/config.h.  Generated automatically by configure.  */
-/* include/config.h.in.  Generated automatically from configure.in by autoheader.  */
-/* $Id: config.h.in,v 1.16 2000/11/17 06:51:36 ishisone Exp $ */
+/*
+ * dlldef.h
+ */
+
 /*
  * Copyright (c) 2000 Japan Network Information Center.  All rights reserved.
  *  
  *    jurisdiction and venue of Tokyo District Court of Japan.
  */
 
-/* Define to `int' if <sys/types.h> doesn't define.  */
-/* #undef gid_t */
-
-/* Define if you have the ANSI C header files.  */
-#define STDC_HEADERS 1
+#ifndef _DLLDEF_H
+#define _DLLDEF_H
 
-/* Define to `int' if <sys/types.h> doesn't define.  */
-/* #undef uid_t */
+#include "../common/jpnicmdn.h"
 
-/* Define if your iconv() does not accept "UTF-8" as the codeset name for utf-8. */
-/* #undef MDN_UTF8_ENCODING_NAME */
-
-/* Define if you want ZLD feature compiled in. */
-/* #undef MDN_SUPPORT_ZLD */
-
-/* Define if the prefix of RACE encoding differs from 'bq--'. */
-/* #undef MDN_RACE_PREFIX */
+/*
+ * Execution TRacing
+ */
+extern  int     procPid   ;
+extern  UCHAR   procExe[] ;
+
+#ifdef  DEBUG
+#define TRACE   mdnPrintf("%04x ws20 : ",procPid) ; mdnPrintf
+#define FATAL   mdnPrintf("%04x ws20 : ",procPid) ; mdnPrintf
+#else
+#define TRACE
+#define FATAL   mdnPrintf("%04x ws20 : ",procPid) ; mdnPrintf
+#endif
 
-/* Define if the suffix of BRACE encoding differs from '-8q9'. */
-/* #undef MDN_BRACE_SUFFIX */
+/*
+ * Encoding Names and Options
+ */
 
-/* Define if the prefix of LACE encoding differs from 'bq--'. */
-/* #undef MDN_LACE_PREFIX */
+extern  BOOL    encodeHere    ;
+extern  CONVPTR encodeCtx     ;
 
-/* Define as an appropriate type (ex. int) if your system doesn't have. */
-#define BOOL int
+/*
+ * entry points to wrap
+ */
 
-/* Define if you have the bcopy function.  */
-#define HAVE_BCOPY 1
+extern  int WSAAPI
+_org_gethostname(char FAR * name, int namelen) ;
 
-/* Define if you have the memmove function.  */
-#define HAVE_MEMMOVE 1
+extern  struct hostent FAR * WSAAPI
+_org_gethostbyaddr(const char FAR * addr, int len, int type) ;
 
-/* Define if you have the nl_langinfo function.  */
-#define HAVE_NL_LANGINFO 1
+extern  struct hostent FAR * WSAAPI
+_org_gethostbyname(const char FAR * name) ;
 
-/* Define if you have the setlocale function.  */
-#define HAVE_SETLOCALE 1
+extern  HANDLE WSAAPI
+_org_WSAAsyncGetHostByName(HWND hWnd, u_int wMsg, const char FAR * name,
+                          char FAR * buf,int buflen) ;
 
-/* Define if you have the setvbuf function.  */
-#define HAVE_SETVBUF 1
+extern  HANDLE WSAAPI
+_org_WSAAsyncGetHostByAddr(HWND hWnd, u_int wMsg, const char FAR * addr,
+                          int len, int type, char FAR * buf, int buflen) ;
 
-/* Define if you have the vsnprintf function.  */
-#define HAVE_VSNPRINTF 1
+extern  INT WSAAPI
+_org_WSALookupServiceBeginA(LPWSAQUERYSETA lpqsRestrictions,
+                           DWORD          dwControlFlags,
+                           LPHANDLE       lphLookup) ;
 
-/* Define if you have the <langinfo.h> header file.  */
-#define HAVE_LANGINFO_H 1
+extern  INT WSAAPI
+_org_WSALookupServiceBeginW(LPWSAQUERYSETW lpqsRestrictions,
+                           DWORD          dwControlFlags,
+                           LPHANDLE       lphLookup) ;
 
-/* Define if you have the <locale.h> header file.  */
-#define HAVE_LOCALE_H 1
+extern  INT WSAAPI
+_org_WSALookupServiceNextA(HANDLE           hLookup,
+                          DWORD            dwControlFlags,
+                          LPDWORD          lpdwBufferLength,
+                          LPWSAQUERYSETA   lpqsResults) ;
 
-/* Define if you have the <sys/select.h> header file.  */
-#define HAVE_SYS_SELECT_H 1
+extern  INT WSAAPI
+_org_WSALookupServiceNextW(HANDLE           hLookup,
+                          DWORD            dwControlFlags,
+                          LPDWORD          lpdwBufferLength,
+                          LPWSAQUERYSETW   lpqsResults) ;
 
-/* Define if you have the <unistd.h> header file.  */
-#define HAVE_UNISTD_H 1
+extern  INT WSAAPI
+_org_WSALookupServiceEnd(HANDLE  hLookup) ;
 
-/* Define if you have the nsl library (-lnsl).  */
-/* #undef HAVE_LIBNSL */
+/*
+ * link above entries
+ */
+void    linkFree(void) ;
+BOOL    linkLoad(void) ;
 
-/* Define if you have the socket library (-lsocket).  */
-/* #undef HAVE_LIBSOCKET */
+#endif  /* _DLLDEF_H */
diff --git a/contrib/idn/mdnkit/wsock/wsock20/dllfunc.c b/contrib/idn/mdnkit/wsock/wsock20/dllfunc.c
new file mode 100644 (file)
index 0000000..bb3fd1c
--- /dev/null
@@ -0,0 +1,308 @@
+/*
+ * 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+ * Tokyo, 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) Japan Network Information Center.  All rights reserved."
+ * 
+ * 4. Neither the name of JPNIC may 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.
+ * 
+ * 6. Indemnification by Licensee
+ *    Any person or entities using and/or redistributing this Software under
+ *    this License Terms and Conditions shall defend indemnify and hold
+ *    harmless JPNIC from and against any and all judgements damages,
+ *    expenses, settlement liabilities, cost and other liabilities of any
+ *    kind as a result of use and redistribution of this Software or any
+ *    claim, suite, action, litigation or proceeding by any third party
+ *    arising out of or relates to this License Terms and Conditions.
+ * 
+ * 7. Governing Law, Jurisdiction and Venue
+ *    This License Terms and Conditions shall be governed by and and
+ *    construed in accordance with the law of Japan. Any person or entities
+ *    using and/or redistributing this Software under this License Terms and
+ *    Conditions hereby agrees and consent to the personal and exclusive
+ *    jurisdiction and venue of Tokyo District Court of Japan.
+ */
+
+#include <windows.h>
+#include <svcguid.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <process.h>
+
+#include "dlldef.h"
+
+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)
+
+int 
+WSAAPI gethostname(char FAR * name, int namelen)
+{
+    int     ret ;
+    
+    TRACE("ENTER gethostname\n") ;
+    ret = _org_gethostname(name, namelen) ;
+    TRACE("LEAVE gethostname %d <%s>\n", ret, name) ;
+
+    return ret ;
+}
+
+struct hostent FAR *
+WSAAPI gethostbyname(const char FAR * name)
+{
+    struct hostent FAR *ret ;
+    char    nbuff[256]  ;
+    char    hbuff[256] ;
+    BOOL    stat ;
+    
+    TRACE("ENTER gethostbyname <%s>\n", (name != NULL ? name : "NULL")) ;
+    
+    if (encodeHere != TRUE || name == NULL) {
+        ret = _org_gethostbyname(name) ;
+    } else {    
+        stat = mdnConvReq(encodeCtx, name, nbuff, sizeof(nbuff)) ;
+       if (stat == FALSE) {
+           TRACE("mdnConvReq failed\n") ;
+           ret = NULL ;
+       } else {
+           TRACE("Converted Name <%s>\n", dumpName(nbuff, hbuff)) ;
+            ret = _org_gethostbyname(nbuff) ;
+        }
+    }
+
+    if (ret != NULL && encodeHere) {
+        TRACE("Resulting Name <%s>\n", dumpName(ret->h_name, hbuff)) ;
+        stat = mdnConvRsp(encodeCtx, ret->h_name, nbuff, sizeof(nbuff)) ;
+       if (stat == FALSE) {
+           TRACE("mdnConvRsp failed\n") ;
+           ret = NULL ;
+       } else {
+            TRACE("Converted Back <%s>\n", dumpName(nbuff, hbuff)) ;
+            strcpy(ret->h_name, nbuff) ;
+        }
+    }
+
+    if (ret == NULL) {
+        TRACE("LEAVE gethostbyname NULL\n") ;
+    } else {
+        TRACE("LEAVE gethostbyname <%s>\n", dumpHost(ret, hbuff)) ;
+    }
+    return ret ;
+}
+
+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 ;
+    
+    TRACE("ENTER gethostbyaddr <%s>\n", dumpAddr(addr, len, abuff)) ;
+
+    ret = _org_gethostbyaddr(addr, len, type) ;
+
+    if (ret != NULL && encodeHere) {
+        TRACE("Resulting Name <%s>\n", dumpName(ret->h_name, hbuff)) ;
+        stat = mdnConvRsp(encodeCtx, ret->h_name, nbuff, sizeof(nbuff)) ;
+       if (stat == FALSE) {
+           TRACE("mdnConvRsp failed\n") ;
+           ret = NULL ;
+       } else {
+            TRACE("Converted Back <%s>\n", dumpName(nbuff, hbuff)) ;
+            strcpy(ret->h_name, nbuff) ;
+        }
+    }
+    
+    if (ret == NULL) {
+        TRACE("LEAVE gethostbyaddr NULL\n") ;
+    } else {
+        TRACE("LEAVE gethostbyaddr <%s>\n", dumpHost(ret, hbuff)) ;
+    }    
+    return ret ;
+}
+
+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] ;
+    
+
+    TRACE("ENTER WSAAsyncGetHostByName <%s>\n", name) ;
+
+    if (encodeHere != TRUE || name == NULL) {
+        ret = _org_WSAAsyncGetHostByName(hWnd, wMsg, name, buf, buflen) ;
+    } else {
+        mdnHook(hWnd, wMsg, buf, encodeCtx) ;
+        mdnConvReq(encodeCtx, name, nbuff, sizeof(nbuff)) ;
+        TRACE("Converted Name <%s>\n", dumpName(nbuff, hbuff)) ;
+        ret = _org_WSAAsyncGetHostByName(hWnd, wMsg, nbuff, buf, buflen) ;
+    }
+
+    TRACE("LEAVE WSAAsyncGetHostByName HANDLE %08x\n", ret) ;
+    
+    return ret ;
+}
+
+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] ;
+    
+    if (encodeHere) {
+        mdnHook(hWnd, wMsg, buf, encodeCtx) ;
+    }
+    
+    TRACE("ENTER WSAAsyncGetHostByAddr <%s>\n", dumpAddr(addr, len, abuff)) ;
+    ret = _org_WSAAsyncGetHostByAddr(hWnd, wMsg, addr, len, type, buf, buflen) ;
+    TRACE("LEAVE WSAAsyncGetHostByAddr HANDLE %08x\n", ret) ;
+
+    return ret ;
+}
+
+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;
+    
+    TRACE("ENTER WSALookupServiceBeginA <%s>\n",
+         name == NULL ? "<NULL>" : name) ;
+
+    if (name != NULL &&
+       encodeHere &&
+       SVCID_IS_HABN(class) == 0) {
+        mdnConvReq(encodeCtx, name, nbuff, sizeof(nbuff)) ;
+        TRACE("Converted Name <%s>\n", dumpName(nbuff, hbuff)) ;
+       /* strcpy(lpqsRestrictions->lpszQueryString, nbuff) ; */
+       lpqsRestrictions->lpszServiceInstanceName = nbuff;
+    }
+    ret = _org_WSALookupServiceBeginA(lpqsRestrictions,
+                                     dwControlFlags, lphLookup) ;
+    TRACE("LEAVE WSALookupServiceBeginA %d\n", ret) ;
+
+    return ret ;
+}
+
+INT 
+WSAAPI WSALookupServiceNextA(HANDLE hLookup, DWORD dwControlFlags, 
+        LPDWORD lpdwBufferLength, LPWSAQUERYSETA lpqsResults)
+{
+    INT     ret ;
+    char    nbuff[256] ;
+    char    hbuff[256] ;
+    LPGUID  class;
+    
+    TRACE("ENTER WSALookupServiceNextA\n") ;
+    ret = _org_WSALookupServiceNextA(hLookup,
+                dwControlFlags, lpdwBufferLength, lpqsResults) ;
+    class = lpqsResults->lpServiceClassId;
+
+    if (ret == 0 &&
+       encodeHere &&
+       (dwControlFlags & LUP_RETURN_NAME) &&
+       (SVCID_IS_HABN(class) || SVCID_IS_HABIS(class))) {
+        TRACE("Resulting Name <%s>\n",
+             dumpName(lpqsResults->lpszServiceInstanceName, hbuff)) ;
+        mdnConvRsp(encodeCtx, 
+                  lpqsResults->lpszServiceInstanceName,
+                  nbuff, sizeof(nbuff)) ;
+        TRACE("Converted Back <%s>\n", dumpName(nbuff, hbuff)) ;
+       strcpy(lpqsResults->lpszServiceInstanceName, nbuff) ;
+    }
+    TRACE("LEAVE WSALookupServiceNextA %d <%s>\n", ret, nbuff) ;
+
+    return ret ;
+}         
+
+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 ;
+}         
+
+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 ;
+}         
+
+INT 
+WSAAPI WSALookupServiceEnd(HANDLE  hLookup)
+{
+    INT     ret ;
+    
+    TRACE("ENTER WSALookupServiceEnd\n") ;
+    ret = _org_WSALookupServiceEnd(hLookup) ;
+    TRACE("LEAVE WSALookupServiceEnd %d\n", ret) ;
+
+    return ret ;    
+}
+     
+
similarity index 80%
rename from contrib/idn/mdnkit/include/config.h.os2
rename to contrib/idn/mdnkit/wsock/wsock20/dllload.c
index fd7318dba34f0ed9adf67ca2c861d11ee6634ee3..7846c8c8a0589d52a884baf910cb255f855b4d48 100644 (file)
@@ -1,4 +1,7 @@
-/* $Id: config.h.os2,v 1.3 2000/08/07 08:20:40 ishisone Exp $ */
+/*
+ * dllload.c - load original entries
+ */
+
 /*
  * Copyright (c) 2000 Japan Network Information Center.  All rights reserved.
  *  
  *    jurisdiction and venue of Tokyo District Court of Japan.
  */
 
-/* Define if you have the vsnprintf function.  */
-#undef HAVE_VSNPRINTF
+#include <windows.h>
+#include <winsock2.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <process.h>
 
-/* Define if you have the setvbuf function.  */
-#undef HAVE_SETVBUF
+#include "dlldef.h"
 
-/* Define if you have the setlocale function.  */
-#undef HAVE_SETLOCALE
-
-/* Define if you have the nl_langinfo function.  */
-#undef HAVE_NL_LANGINFO
+/*
+ * Manages original DLL 
+ */
+static  HINSTANCE   dllHandle = NULL ;
 
-/* Define if you have the <langinfo.h> header file.  */
-#undef HAVE_LANGINFO_H
+/*
+ * linkFree - dispose module
+ */
 
-/* Define if you have the <locale.h> header file.  */
-#undef HAVE_LOCALE_H
+void    linkFree(void)
+{
+    if (dllHandle != NULL) {
+        FreeLibrary(dllHandle) ;
+       dllHandle = NULL ;
+    }
+}
 
-/* Define if you have the <unistd.h> header file.  */
-#undef HAVE_UNISTD_H
+/*
+ * linkLoad - load & link original DLL
+ */
 
-/* Define if your iconv() does not accept "UTF-8" as the codeset name for utf-8. */
-#undef MDN_UTF8_ENCODING_NAME
+BOOL    linkLoad(void)
+{
+    PUCHAR  name ;
+    
+    /*
+     * Load Original DLL
+     */
+     
+    name = "WS2_32O" ;
+    
+    if ((dllHandle = LoadLibrary(name)) == NULL) {
+        FATAL("linkLoad - no %s\n", name) ;
+       return FALSE ;
+    }
+    
+    return TRUE ;
+}
 
-/* Define if you want ZLD feature compiled in. */
-#undef MDN_SUPPORT_ZLD
+#define DLLHANDLE      dllHandle
+#include "dllstub.c"
diff --git a/contrib/idn/mdnkit/wsock/wsock20/dllmain.c b/contrib/idn/mdnkit/wsock/wsock20/dllmain.c
new file mode 100644 (file)
index 0000000..be0595b
--- /dev/null
@@ -0,0 +1,136 @@
+/*
+ * 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+ * Tokyo, 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) Japan Network Information Center.  All rights reserved."
+ * 
+ * 4. Neither the name of JPNIC may 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.
+ * 
+ * 6. Indemnification by Licensee
+ *    Any person or entities using and/or redistributing this Software under
+ *    this License Terms and Conditions shall defend indemnify and hold
+ *    harmless JPNIC from and against any and all judgements damages,
+ *    expenses, settlement liabilities, cost and other liabilities of any
+ *    kind as a result of use and redistribution of this Software or any
+ *    claim, suite, action, litigation or proceeding by any third party
+ *    arising out of or relates to this License Terms and Conditions.
+ * 
+ * 7. Governing Law, Jurisdiction and Venue
+ *    This License Terms and Conditions shall be governed by and and
+ *    construed in accordance with the law of Japan. Any person or entities
+ *    using and/or redistributing this Software under this License Terms and
+ *    Conditions hereby agrees and consent to the personal and exclusive
+ *    jurisdiction and venue of Tokyo District Court of Japan.
+ */
+
+#include <windows.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <process.h>
+
+#include "dlldef.h"
+
+/*
+ * Control Variables
+ */
+
+int     procPid      =   0   ;
+UCHAR   procExe[256] = { 0 } ;
+
+BOOL    encodeHere = FALSE ;
+CONVPTR encodeCtx  = NULL  ;
+
+/*
+ * DLL Entry
+ */
+BOOL    APIENTRY    DllMain(HMODULE hmod, DWORD reason, LPVOID *resv)
+{
+    switch (reason) {
+    case DLL_PROCESS_ATTACH :
+        procPid = getpid() ;
+        GetModuleFileName(NULL, procExe, 256) ;
+       
+       TRACE("Attached to Process <%s>\n", procExe) ;
+
+        if (linkLoad() != TRUE) {
+           FATAL("cannot link to original DLL\n") ;
+           return FALSE ;
+       }
+       
+        mdnLogInit() ;                 
+       mdnHookInit() ;
+
+        switch (mdnEncodeWhere()) {
+        case MDN_ENCODE_ALWAYS :
+       case MDN_ENCODE_ONLY20 :
+       case MDN_ENCODE_CHECK  :
+           encodeHere = TRUE ;
+           break ;
+       default :
+           encodeHere = FALSE ;
+           break ;
+        }
+
+       if (encodeHere == FALSE) {
+           TRACE("not encode here\n") ;
+       } else {
+           encodeCtx = mdnConvInit() ;
+            TRACE("Context %08x\n", encodeCtx) ;
+        }
+        break ;
+
+    case DLL_PROCESS_DETACH :
+        if (encodeCtx != NULL) {
+           mdnConvDone(encodeCtx) ;
+       }
+       mdnHookDone() ;
+        linkFree() ;
+       TRACE("Deatched from Process\n") ;
+        break ;
+
+    case DLL_THREAD_ATTACH  :
+        break ;
+    case DLL_THREAD_DETACH  :
+        break ;
+    }
+    return TRUE ;
+}
diff --git a/contrib/idn/mdnkit/wsock/wsock20/dllstub.c b/contrib/idn/mdnkit/wsock/wsock20/dllstub.c
new file mode 100644 (file)
index 0000000..b1d9967
--- /dev/null
@@ -0,0 +1,2035 @@
+/* $Id: dllstub.c,v 1.1 2001/06/09 00:30:55 tale 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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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
+    mdnLogPrintf(mdn_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)();
+}
+
diff --git a/contrib/idn/mdnkit/wsock/wsock20/make.wnt b/contrib/idn/mdnkit/wsock/wsock20/make.wnt
new file mode 100644 (file)
index 0000000..2c2a6e1
--- /dev/null
@@ -0,0 +1,113 @@
+#
+# 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, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
+# Tokyo, 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) Japan Network Information Center.  All rights reserved."
+# 
+# 4. Neither the name of JPNIC may 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.
+# 
+# 6. Indemnification by Licensee
+#    Any person or entities using and/or redistributing this Software under
+#    this License Terms and Conditions shall defend indemnify and hold
+#    harmless JPNIC from and against any and all judgements damages,
+#    expenses, settlement liabilities, cost and other liabilities of any
+#    kind as a result of use and redistribution of this Software or any
+#    claim, suite, action, litigation or proceeding by any third party
+#    arising out of or relates to this License Terms and Conditions.
+# 
+# 7. Governing Law, Jurisdiction and Venue
+#    This License Terms and Conditions shall be governed by and and
+#    construed in accordance with the law of Japan. Any person or entities
+#    using and/or redistributing this Software under this License Terms and
+#    Conditions hereby agrees and consent to the personal and exclusive
+#    jurisdiction and venue of Tokyo District Court of Japan.
+
+!include <win32.mak>
+
+SYSLIBS = $(libcdll) kernel32.lib advapi32.lib
+
+#
+# Files to use
+#
+
+HDRS = dlldef.h ..\common\jpnicmdn.h
+SRCS = dllmain.c   dllload.obj dllfunc.c dllstub.c
+OBJS = dllmain.obj dllload.obj dllfunc.obj
+LIBS = ..\common\jpnicmdn.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/mdnkit/wsock/wsock20/ws2_32.def b/contrib/idn/mdnkit/wsock/wsock20/ws2_32.def
new file mode 100644 (file)
index 0000000..c0527f2
--- /dev/null
@@ -0,0 +1,113 @@
+;
+; Library Defition for mDNS'd WS2_32.DLL
+;
+LIBRARY ws2_32
+DESCRIPTION "JPNIC/mDNS Warpper 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
+  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
diff --git a/contrib/idn/mdnkit/wsock/wsock20/ws2_32o.def b/contrib/idn/mdnkit/wsock/wsock20/ws2_32o.def
new file mode 100644 (file)
index 0000000..6a9be77
--- /dev/null
@@ -0,0 +1,115 @@
+;
+; EXPORTS in WS2_32
+;
+
+LIBRARY ws2_32o
+DESCRIPTION "WS2_32 original exports"
+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
+  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
+