diff --git a/contrib/idn/mdnkit/ChangeLog b/contrib/idn/mdnkit/ChangeLog new file mode 100644 index 0000000000..9a0bb236e4 --- /dev/null +++ b/contrib/idn/mdnkit/ChangeLog @@ -0,0 +1,192 @@ +2000-11-27 + * wsock/config/mdnconf.tcl: implement "unwrap all" button. + * wsock/README.txt, wsock/README_j.txt: add description on "unwrap + all" button. add important notice on installing a new version + to the top of each file. + * Makefile.in, tools/rpm/mdnkit.spec: update for version 1.2. + * wsock/bin/README_e.txt, wsock/bind/README_j.txt: updated. + * version 1.2 release. + +2000-11-22 + * lib/brace.c, lib/lace.c, lib/race.c: keep lint happy. + * lib/brace.c: fix a bug that the encoder outputs a broken string. + * dnsproxy/dnsproxy.conf.sample, lib/mdnres.conf.sample: add + description of new normalization schemes. + +2000-11-21 + * lib/translator.c, include/mdn/translator.h: add new parameter + "local_alternate_converter" to mdn_translator_translate(), to + accept and correctly process names encoded in alternate-encoding. + * lib/msgtrans.c, include/mdn/msgtrans.h: add a new parameter + to mdn_msgtrans_param_t which is required for the new + mdn_translator_translate() above. + * dnsproxy/translate.c, wsock/common/convert.c: according to the + changes above. + * DISTFILES: replace patch/bind8/bind-8.2.2-P5-patch with + patch/bind8/bind-8.2.2-P7-patch. + * lib/Makefile.in, tools/runmdn/Makefile.in: increase version + number. + * lib/brace.c, lib/lace.c, lib/race.c: fix buffer overrun bugs. + * wsock/README.txt, wsock/README_j.txt: updated. + * README, README.ja: updated for version 1.2 release. + * Makefile.in: updated for version 1.2-rc1. + +2000-11-20 + * lib/race.c: fix a buffer overrun bug. + * patch/bind8/bind-8.2.2-P5-patch: removed. + * patch/bind8/bind-8.2.2-P7-patch: created. + +2000-11-17 + * lib/normalizer.c: add normalize scheme "ja-kana-fullwidth" + as an alias of "ja-fullwidth". also add new scheme + "ja-alnum-halfwidth". + * lib/normalizer.c: make the size of intermediate buffer used for + normalization grow dynamically. previously, the size was a fixed + value based on the size of the input string and overflow was + possible. + * lib/brace.c: add internal error checking. keep lint happy. + * dnsproxy/config.c, dnsproxy/config.h: removed (renamed to + proxycnf.[ch], in order to avoid confusion with include/config.h). + * dnsproxy/proxycnf.c, dnsproxy/proxycnf.h: created. + * DISTFILES, dnsproxy/Makefile.in, dnsproxy/make.os2, + dnsproxy/make.wnt: remove dnsproxy/config.[ch], add + dnsproxy/proxycnf.[ch] + * dnsproxy/logging.c, dnsproxy/message.c dnsproxy/proxycnf.c: + include . + * configure.in, configure, acconfig.h, include/config.h.in: + add checking whether the system defines BOOL type or not. + add configuration option --with-brace-suffix and --with-lace-prefix. + * README, README.ja: mention about new configuration options above. + * dnsproxy/dnsproxy.h: take the definition of BOOL out. use own + version of TRUE/FALSE, instead of system-supplied ones. + * wsock/config/mdnconf.tcl: add log configuration feature (log level + and log file). implement log file operation (view/delete). + change widgets layout so that they look neater. + * wsock/common/encoding.c, wsock/common/jpnicmdn.h: add new + function for retrieving the pathname of the log file from the + registry. + * wsock/common/printf.c: retrieve log file pathname from the + registry. stop writing log if the log level is negative. + * tools/mdnconv/Makefile.in: add dependency to libmdn.la. + * man/mdnres.conf.5.in, tools/mdnconv/mdnconv.1: add description + on the new encodings and normalization schemes. + * dnsproxy/dnsproxy.8: removed. + * dnsproxy/dnsproxy.8.in: created. + * dnsproxy/Makefile.in: generate dnsproxy.8 from dnsproxy.8.in, + reflecting correct path. + * DISTFILES: replace dnsproxy/dnsproxy.8 with dnsproxy/dnsproxy.8.in. + +2000-11-16 + * lib/brace.c: fix buffer-overrun bugs. + +2000-11-14 + * include/mdn/brace.h, lib/mdn/brace.c: created. (for BRACE encoding) + * include/mdn/lace.h, lib/mdn/lace.c: created. (for LACE encoding) + * include/mdn/util.h, lib/util.c: incorporate some functionalities + from race.c, such as UTF-8 <-> UTF-16 conversion. + * lib/race.c: move some functionalities shared with brace.c and + lace.c out to util.c. + * lib/converter.c: add BRACE and LACE converters. + * include/mdn/Makefile.in: add brace.h and lace.h to the intall files. + * lib/Makefile.in: add brace.c and lace.c. + * DISTFILES: add include/mdn/{brace,lace}.h, lib/{brace,lace}.c. + +2000-11-10 + * lib/normalizer.c: add normalize scheme + "ja-compose-voiced-sound". + +2000-11-06 + * wsock/common/printf.c: mDN Wrapper enable libmdn trace + * wsock/wsock11/dllmain.c: mDN Wrapper enable libmdn trace + * wsock/wsock20/dllmain.c: mDN Wrapper enable libmdn trace + * wsock/common/jpnicmdn.h: mDN Wrapper enable libmdn trace + * wsock/common/jpnicmdn.def: mDN Wrapper enable libmdn trace + * wsock/wsock11/dllfunc.c: check status of conversion + * wsock/wsock20/dllfunc.c: check status of conversion + * wsock/common/encoding.c: Fixed query on program side encoding + * wsock/common/convert.c : Fixed setting program side encoding + +2000-11-02 + * lib/util.c, include/mdn/util.h: created. + * lib/race.c, tools/mdnconv/util.c: make use of the above util + module. + * DISTFILES, include/mdn/Makefile.in, lib/Makefile.in, + tools/runmdn/Makefile.in, lib/make.wnt, lib/make.os2: add + util.[ch]. + * lib/Makefile.in, tools/runmdn/Makefile.in: increase revision + number. + * tools/runmdn/Makefile.in: use INSTALL_SCRIPT rather than + INSTALL_PROGRAM for shell script installation. + * tools/rpm/mdnkit.spec: increase version and serial. + * Makefile.in: change package name to mdnkit-1.1-src. add patch + target. + * DISTFILES: add ChangeLog and NEWS. + * lib/msgtrans.c: remove extra semicolon at the end of #undef + line. + * tools/rpm/mdnkit.spec: update for version 1.1. + * README, README.ja: update for version 1.1. + * version 1.1 release. + +2000-11-01 + * lib/race.c, tools/mdnconv/util.c: fix race prefix matching bug. + Previously, matching failed if the prefix contains any uppercase + letters (such as Bq--), + +2000-10-31 + * dnsproxy/dnsproxy.8: fix typo. + * dnsproxy/dnsproxy.conf.sample: add log-level entry. correct + description of the behavior when log-file is not specified. + * NEWS: created. + +2000-10-30 + * patch/bind9/bind-9.0.0-patch (lib/dns/config/confparser.y): + typo fixed. + +2000-10-27 + * dnsproxy/Makefile.in: remove -DDEBUG. + * dnsproxy/logging.c: supply default log file if not specfied. + * dnsproxy/translate.c: make the log correctly display "tcp" or + "udp" instead of "unknown". fix typo. + * dnsproxy/winserv.c: comment out message logging code because + they are also recorded in event logger. + +2000-10-26 + * dnsproxy/config.c: stop redefining logging macros (since it's + not needed). use fprintf instead of log_printf for logging (since + log file is not yet determined at this stage). + * dnsproxy/dnsproxy.8: add description on log-level entry. + mention about SIGHUP feature. + * dnsproxy/dnsproxy.h: add log-level constants. change log macro + definitions. add prototypes for new logging functions. + * dnsproxy/logging.c: add log-level setting feature, including new + logging interface functions and log-level entry in the + configuration file. add log file turnover support + (close and reopen the file when receiving SIGHUP) + * dnsproxy/server.c: ignore transient errors such as EAGAIN or + EINTR. do not quit server process even if recvfrom returns + ECONNREFUSED, which seems to happen on Linux. Same for + ENETUNREACH and EHOSTUNREACH. + * dnsproxy/translate.c: make mdn_log_level_info messages are + logged at 'warn' level instead of 'trace' level. + * dnsproxy/unxmain.c: add handler for SIGHUP. + +2000-10-25 + * lib/utf8.c: fix mdn_utf8_getmb so that it returns correct + value. + +2000-10-24 + * dnsproxy/server.c: don't terminate server process even if + recvfrom (on UDP socket) returns 0. + * tools/mdnconv/mdnconv.1: correct syntax of -noconf option. + +2000-10-23 + * dnsproxy/message.c: fix DNS message ID allocation bug (only + 4096 IDs out of 65536 could be used before). release internal + data structure for each request when receiving reply (previously + it is kept for 10 minutes, causing large memory footprint for + busy servers). add some debug statements. + * dnsproxy/server.c: increase interval for calling timer dispatch + routine (1sec -> 10sec). + +2000-10-08 + * version 1.0 release diff --git a/contrib/idn/mdnkit/LICENSE.txt b/contrib/idn/mdnkit/LICENSE.txt new file mode 100644 index 0000000000..0e33381338 --- /dev/null +++ b/contrib/idn/mdnkit/LICENSE.txt @@ -0,0 +1,55 @@ +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. diff --git a/contrib/idn/mdnkit/Makefile.in b/contrib/idn/mdnkit/Makefile.in new file mode 100644 index 0000000000..8d85c8eb51 --- /dev/null +++ b/contrib/idn/mdnkit/Makefile.in @@ -0,0 +1,87 @@ +# $Id: Makefile.in,v 1.31 2000/11/27 01:58:31 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. + +srcdir = @srcdir@ +VPATH = @srcdir@ + +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +SUBDIRS = include lib dnsproxy man tools + +CUR_VERSION = 1.2 +PREV_VERSION = 1.1 +PREV_TAG = REL_1_1 + +DISTFILE = mdnkit-$(CUR_VERSION)-src +PATCHFILE = mdnkit-$(PREV_VERSION)-$(CUR_VERSION)-src-patch + +all: + for d in $(SUBDIRS); do (cd $$d; $(MAKE) all); done + +install: + for d in $(SUBDIRS); do (cd $$d; $(MAKE) install); done + +clean: + for d in $(SUBDIRS); do (cd $$d; $(MAKE) clean); done + +dist: + cd $(srcdir); mktarpkg --gzip=9 $(DISTFILE) + +patch: + cd $(srcdir); mkcvspatch --gzip=9 --header=patch.header \ + --from=$(PREV_TAG) $(PATCHFILE) diff --git a/contrib/idn/mdnkit/NEWS b/contrib/idn/mdnkit/NEWS new file mode 100644 index 0000000000..68e13bd36d --- /dev/null +++ b/contrib/idn/mdnkit/NEWS @@ -0,0 +1,58 @@ +; $Id: NEWS,v 1.5 2000/11/21 09:03:23 ishisone Exp $ + +Major changes in version 1.2: + +* New encoding converters for `BRACE' and `LACE' are implemented. + +* New normalize schemes `ja-compose-voiced-sound', 'ja-kana-fullwidth' + and 'ja-alnum-halfwidth' introduced. + +* mDN Wrapper is thoroughly overhauled. + - Log level can be specified by using GUI (or directly editing the + registry Software\JPNIC\MDN\LogLevel). Note that fine grain + control over logging is supported only by the MDN library (libmdn). + Log output from mDN Wrapper itself can be turned on or off, but + no log level support. + - Log file can also specified. + - Some serious bugs are fixed, including incorrect program-side + encoding (codeset) detection. + - Advanced configuration feature implemented. Now DNS encoding and + normalization can be customizable. Also you can configure which + winsock DLL to be wrapped. + +* dnsproxy and mDN Wrapper now correctly accept and process client- + supplied domain names encoded in the alternate encoding. Previously + worked correctly only when the alternate encoding happened to be the + same as the server encoding. + +* 8bit-through patch for BIND-8.2.2-P5 is replaced by a new patch + for BIND-8.2.2-P7. + +* A buffer overrun bug in RACE converter is fixed. + + +Major changes in version 1.1: + +* Log level of dnsproxy can be specified with ``log-level'' entry. + available levels are `none', `fatal', `warning' and `trace'. See + dnsproxy.8 or dnsproxy.conf.sample for details. + +* Sending SIGHUP to dnsproxy causes it to close and re-open the log file. + Useful for log file turnover. + +* If log file is not specified, dnsproxy uses the default log file + /tmp/dnsproxy.log. Previously behavior was that no logging was done + at all, conflicting with what document says. + +* dnsproxy won't terminate even if recvfrom() returns unexpected + errors such as `connection refused (ECONNREFUSED)'. On Linux, it is + reported that it sometimes returns this error even for + connection-less (ie UDP) sockets. + +* DNS message ID allocation/release bugs in dnsproxy are fixed. + Previously dnsproxy seems to stop working if it receives more than + 4096 requests in 10 minutes. + +* RACE conversion bug is fixed. Previously, if the prefix part contains + any uppercase letters (such as "Bq--"), it is not recognized as a + RACE prefix. diff --git a/contrib/idn/mdnkit/README b/contrib/idn/mdnkit/README new file mode 100644 index 0000000000..ae57a16bdf --- /dev/null +++ b/contrib/idn/mdnkit/README @@ -0,0 +1,304 @@ + + mDNkit + -- multilingual domain name evaluation kit -- + version 1.2 + 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 provides several ways for adding these features. + +This kit consists of following components. + + + DNS proxy server (dnsproxy) + 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. + + + 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. + + + 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. + + + mDN wrapper for Windows applications + On windows, name resolving request is passed to WINSOCK DLL. So, + replacing WINSOCK DLL with multi-lingual domain name version + makes legacy windows applications compatible with mDN. This is + wrapper DLL for WINSOCK's name resolving functions. See + ``4. using mDN wrapper'' below. + + + a codeset converter for named.conf/zone master files (mdnconv) + 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. + + + a patch that makes BIND-8 8-bit through + This is needed in order for named and resolver to handle + non-ascii domain names encoded in local encoding or UTF-8. + The patch is rudimentary; it makes almost any byte sequence + legal as a domain name (which is what 8-bit through is for). + + + a patch for making Squid cache server 8-bit through + This is a simple patch that disables Squid's validity check + for host name part in URLs. Without this patch, Squid rejects + URLs containing multilingual domain name (correctly). + + +This kit provides several ways to handle multilingual domain names +using above components. + + ** 1. using dnsproxy + + domain name encoding domain name + in local conversion and in encoding + +------------+ encoding normalization on DNS + | client | +----------------+ protocol +----------+ + |application |------------>| dnsproxy |------------>|DNS server| + | with |<------------| |<------------| | + |8bit through| +----------------+ +----------+ + | resolver | + +------------+ + + ** 2. using runmdn + + encoding domain name + conversion and in encoding + normalization on DNS + +-----------+-------------+ protocol + | client | dynamically | +----------+ + |application| attached |---------------->|DNS server| + |with normal| library |<----------------| | + | resolver | (libmdnres) | +----------+ + +-----------+-------------+ + + ** 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 + + domain name normalization domain name + in local and encoding in ecnoding + +-----------+ encoding conversion on DNS + | legacy | +---------+---------+ protocol +----------+ + | windows |------------>| mDN | orignal |---------->|DNS server| + | network |<------------| wrapper | winsock |<----------| | + |application| +---------+---------+ +----------+ + +-----------+ + +* Directory structure of this distribution + +Below is a directory structure of this distribution with some +important files and their brief description. + + +README this file + +README.ja .. in Japanese + +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 + +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 + +patch/ various patch files + | +bind8/ bind-8 patch directory + | +bind9/ bind-9 patch directory + | +squid/ squid patch directory + +util/ utilities + + +* Compilation and installation + +0. Prerequisite + +If your system's library does not have iconv() function, which is a +general codeset conversion utility, install it as an external library. +You also need external library if the system's implementation cannot +handle UTF-8 encoding, or it doesn't support some encodings which your +client applications uses. + +You can get a free version of iconv() implementation (under LGPL +license), from: + + http://clisp.cons.org/~haible/packages-libiconv.html + +1. Running configure script + +Run `configure' script in the top directory. This checks various +characteristics of your system and it will create Makefiles and +config.h appropriate for your system. + + % ./configure + +`configure' accepts many options. Here is a list of some important +options. + + --with-iconv=LIB + If your libc doesn't contain iconv(), specify the library + that contains iconv(). For example, if iconv() is libiconv + in /usr/local/lib, you should specify: + + --with-iconv="-L/usr/local/lib -liconv" + + Note that if the library is a shared one, you might also want to + specify -R option, like: + + --with-iconv="-L/usr/local/lib -R/usr/local/lib -liconv" + + If the header file "iconv.h" has installed in a non-standard + directory like /usr/local/include, you should specify CFLAGS + environment variable. See below. + + --with-iconv-sofile=PATH + ``runmdn'' command in this kit needs to know the pathname of + shared library file that contains iconv(), if iconv() is not + part of libc. mDNkit tries to find out the pathname from the + informaiton provided by ``--with-iconv'' option described + above. But when it fails, you have to specify it with this + option, like: + + --with-iconv-sofile=/usr/local/lib/libiconv.so.2.0 + + --with-utf8=NAME + If your iconv() (precisely, iconv_open()) does not accept + "UTF-8" as the name of UTF-8 encoding, specify the name for + it. For example if your iconv() uses "utf8" instead, you + should specify: + + --with-utf8=utf8 + + --with-race-prefix=PREFIX + --with-brace-suffix=SUFFIX + --with-lace-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. + + --sbindir=DIR + Specifies the install directory for dnsproxy. Default is + /usr/local/sbin. + + --bindir=DIR + Specifies the install directory for mdnconv and runmdn. + Default is /usr/local/bin. + + --sysconfdir=DIR + Specifies the install directory for sample files of dnsproxy + configuration and mDNkit's resolver configuration. Default is + /usr/local/etc. + + --mandir=DIR + Specifies the base install directory for online manuals. + Default is /usr/local/man. + +`configure' has many more options. To see the list of available +options, you should run it with --help option. + + % ./configure --help + +If you want to specify extra compiler options, like adding non-standard +directory to include file search path, use environment variable CFLAGS. + + % CFLAGS="-I/usr/local/include -O2" ./configure ... (for sh) + % setenv CFLAGS "-I/usr/local/include -g"; ./configure ... (for csh) + +2. Compiling + +Run `make' for compilation. + + % make + +3. Installation + +Run `make install' to install binaries and manuals. Don't forget to +become a super-user before the installation. + + % su + # make install + +4. Configuration and usage + +Please consult online manuals for configuration and usage of `dnsproxy' +`mdnconv', and `runmdn'. Also for `mdnconv' and `runmdn', please refer +the manual of mDNkit's resolver configuration file `mdnres.conf'. + + % man dnsproxy + % man mdnconv + % man runmdn + % man mdnres.conf + + +* Applying patches + +This distribution also contains patches for BIND 8.2.2-P7, +BIND 8.2.3-T6B, BIND 9.0.0 and Squid 2.3.STABLE3. The top of these +patch files describe how to apply the patch and (re)install. + +Note that on Solaris, "patch" command that comes with the system +sometimes doesn't work correctly. You may want to install the GNU +version of the command (http://www.gnu.org/software/patch/) and use +it. + + +* Contact information + +Please see http//www.nic.ad.jp/jp/research/idn/ for the latest news +about this kit. + +Bug reports and comments on this kit should be sent to +mdnkit-bugs@nic.ad.jp and idn-cmt@nic.ad.jp, respectively. + + +; $Id: README,v 1.15 2000/11/21 07:54:13 ishisone Exp $ diff --git a/contrib/idn/mdnkit/README.ja b/contrib/idn/mdnkit/README.ja new file mode 100644 index 0000000000..9f8201a805 --- /dev/null +++ b/contrib/idn/mdnkit/README.ja @@ -0,0 +1,300 @@ + + mDNkit + -- 多言語ドメイン名評価キット -- + バージョン 1.2 + (社) 日本ネットワークインフォメーションセンター (JPNIC) + + +* 概要 + +mDNkit とは DNS で多言語ドメイン名を扱うために提案されている各種の方式 +を評価するためのキットです。多言語ドメイン名を扱うためには、次のような +機能が要求されます。 + +・アプリケーションが使用するエンコーディング (ローカルエンコーディング) + と DNS プロトコル上のエンコーディングとの間の、ドメイン名のエンコー + ディング変換。 +・ドメイン名の正規化。 + +mDNkit では、これらの機能を追加するための各種の方法を提供しています。 + +この配布キットには次のようなものが含まれます。 + +・DNSプロキシサーバ (dnsproxy) + ドメイン名変換機能をもつ DNS のプロキシサーバです。クライアントから + 受信した DNS メッセージ中のドメイン名をクライアントのローカルエンコー + ディングから DNS サーバの使用する DNS プロトコル上のエンコーディング + へと変換して DNS サーバに送信します。また DNS サーバから返されたDNS + メッセージ中のドメイン名をクライアントのローカルエンコーディングに戻 + してクライアントに返します。詳しくは、後述の「1. dnsproxy を使う」を + 御覧ください。 + +・UNIX アプリケーションに MDN 機能を動的に追加するコマンド (runmdn) + UNIX の通常のアプリケーションで多言語ドメイン名を取り扱うために、特 + 別なライブラリを動的にリンクするためのコマンドです。詳しくは、後述の + 「2. runmdn を使う」を御覧ください。 + +・bind-9 に MDN 機能を追加するパッチ + bind-9 に MDN の機能を追加するパッチです。bind-9 では、クライアント + 側のライブラリ (liblwres) と、新しい名前解決用デーモン (lwresd) から + 成る、ライトウエイトリゾルバという全く新しい名前解決の方法が使われて + います。このパッチは、これらに MDN の機能を追加します。詳しくは、後 + 述の「3. bind9 にパッチを当てて使う」を御覧ください。 + +・Windows アプリケーション用の mDN ラッパー + WINSOCK の名前解決機能に対するラッパー DLL です。Windows 上では、名 + 前解決の要求は、WINSOCK DLL を通して行われます。そこで、これを多言語 + ドメイン用の WINSOCK DLL に置き換えることで、従来の Windows アプリケー + ションでも mDN 機能を使用できるようにします。詳しくは、後述の + 「4. mDN ラッパーを使う」を御覧ください。 + +・named.conf およびゾーンマスタファイル用コードセットコンバータ (mdnconv) + named.conf およびゾーンマスタファイルを対象としたコードセット (エン + コーディング)変換用ツールです。SJIS などのローカルエンコーディングで + 書かれたこれらのファイルを、多言語化 DNS で使用するエンコーディング + (例えばUTF-8) へと変換します。 + +・多言語ドメイン名を処理するためのライブラリ (libmdn, libmdnres) + dnsproxy や mdnconv が利用しているライブラリです。エンコーディング変 + 換や正規化、ZLD (zero-level domain) の処理等の機能を提供します。 + +・bind-8 を 8 ビットスルー化するパッチ + named やリゾルバでローカルエンコーディングや UTF-8 エンコーディング + のドメイン名を使用可能にするためのパッチです。8ビットスルーなのでほ + とんどどんなコードでも通ってしまいます。 + +・squid を 8 ビットスルー化するパッチ + URL 中のホスト名に関する正当性チェックを外すためのパッチです。このパッ + チを当てないと Squid は多言語ドメイン名を含む URL をエラーとしてはじ + いてしまいます。 + + +この配布キットは、以上のものを用いて、多言語ドメイン名を扱うための複数 +の方法を提供しています。 + + ** 1. dnsproxy を使う + + ローカルエン エンコーディン DNS プロトコル上の + コードィング グ変換および正 エンコーディングの + +----------------+のドメイン名 規化 ドメイン名 + |クライアント | +--------------+ +------+ + |アプリケーション|------------>| dnsproxy |------------>| DNS | + |と 8ビットスルー|<------------| |<------------|サーバ| + |化したリゾルバ | +--------------+ +------+ + +----------------+ + + ** 2. runmdn を使う + + エンコーディング変換 DNS プロトコル上の + および正規化 エンコーディングの + +----------------+------------------+ ドメイン名 + |クライアント |動的にリンクされた| +------+ + |アプリケーション| ライブラリ |---------------->| DNS | + |と通常のリゾルバ| (libmdnres) |<----------------|サーバ| + +----------------+------------------+ +------+ + + ** 3. bind9 にパッチを当てて使う + + UTF-8 のド エンコーディ DNS プロトコル上の + メイン名 ング変換およ エンコーディングの + +----------------+ び正規化 ドメイン名 + |クライアント | +----------------+ +------+ + |アプリケーション|---------->| ライトウェイト |------------>| DNS | + |と bind9のライト|-----------| リゾルバ |<------------|サーバ| + |ウェイトリゾルバ| | デーモン | +------+ + +----------------+ +----------------+ + + ** 4. mDN ラッパーを使う + + ローカルエ 正規化および DNS プロトコル上の + ンコーディ エンコーディ エンコーディングの + +----------------+ ングのドメ ング変換 ドメイン名 + |従来の Windows | イン名 +---------+------------+ +------+ + |ネットワーク |---------->| mDN | オリジナル |---------->| DNS | + |アプリケーション|<----------| ラッパー| winsock |<----------|サーバ| + +----------------+ +---------+------------+ +------+ + + +* ディレクトリ構成 + +配布キットのディレクトリ構成と、主要なファイルを示します。 + + README 英語版の README + README.ja このファイル + DISTFILES 配布されるファイル一覧 + NEWS 主な変更 + ChangeLog 変更詳細 + configure configure スクリプト + Makefile.in トップレベルの Makefile のテンプレート + include/ インクルードファイルディレクトリ + config.h.in config.h のテンプレート + mdn/ mdn ライブラリ用インクルードファイル + dnsproxy/ DNS プロキシサーバソース + lib/ mdn ライブラリソース + wsock/ mDN ラッパーソース + tools/ 周辺ツール + mdnconv/ コードセットコンバータソース + runmdn/ runmdn コマンドソース + patch/ 各種パッチファイル + bind8/ bind8 用パッチ + bind9/ bind9 用パッチ + squid/ squid 用パッチ + util/ ユーティリティ + + +* コンパイルおよびインストール + +0. 前準備 + +もしあなたの使用しているシステムのライブラリに iconv() がない場合、あ +るいはあっても UTF-8 を扱うことができない場合にはあらかじめ iconv() を +インストールしておいてください。iconv() の実装は、例えば LGPL のものが + + http://clisp.cons.org/~haible/packages-libiconv.html + +から入手可能です。 + +1. configure スクリプトの実行 + +トップディレクトリにある configure スクリプトを実行してください。 + + % ./configure + +configure スクリプトにはいくつかのオプションを指定することができます。 +mdn に直接関係するものは次の通りです。 + + --with-iconv=LIB + libc に iconv が入っていない場合 (上記のパッケージを入れた + 場合など) に、iconv のライブラリを指定します。例えば + + --with-iconv="-L/usr/local/lib -liconv" + + のように指定します。もし iconv が共有ライブラリになっている + 場合には、-R オプションも指定して + + --with-iconv="-L/usr/local/lib -R/usr/local/lib -liconv" + + とする必要があるかもしれません。 + + --with-iconv-sofile=PATH + mDNkit に含まれている runmdn コマンドは、iconv() が libc の一 + 部として提供されないときに、iconv() を含む共有ライブラリへのパ + ス名を知る必要があります。mDNkit は、--with-iconv オプションの + 記述を基にパス名を検索しますが、これに失敗したときに、以下のよ + うに共有ライブラリを指定することができます。 + + --with-iconv-sofile=/usr/local/lib/libiconvv.so.2.0 + + --with-utf8=NAME + iconv に utf-8 エンコーディングを指定する場合、本ライブラリは + デフォルトでは "UTF-8" という名前を指定します。もしあなたの + システムの iconv が "UTF-8" という名前を受け付けない場合には、 + 代りの名前を指定します。例えば "UTF-8" ではなく "utf8" の + 場合には次のように指定します。 + + --with-utf8=utf8 + + --with-race-prefix=PREFIX + --with-brace-suffix=SUFFIX + --with-lace-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 の場合 + には接尾辞) が用いられます。 + + mDNkit では現在のインターネットドラフトで定義されている接頭辞 + あるいは接尾辞を使用するようになっていますが、今後のドラフトで + 変わるかもしれません。そこで、これらのオプションを用いて指定で + きるようになっています。 + + --enable-zld + ZLD (zero level domain) は、デフォルトでは使用できません。この + 機能を使用したいときに、このオプションを指定します。 + + --sbindir=DIR + DNS プロキシサーバをインストールするディレクトリを指定します。 + デフォルトでは /usr/local/sbin です。 + + --bindir=DIR + コードセットコンバータ mdnconv をインストールするディレクトリを + 指定します。デフォルトでは /usr/local/bin です。 + + --sysconfdir=DIR + DNS プロキシサーバの設定ファイルをインストールするディレクトリを + 指定します。デフォルトでは /usr/local/etc です。 + + --mandir=DIR + オンラインマニュアルのインストールディレクトリを指定します。 + デフォルトでは /usr/local/man です。 + +--with-iconv オプションではライブラリだけを指定します。もしインクルー +ドファイル iconv.h がデフォルトのインクルードファイルのパスにインストー +ルされていない場合、あるいは他に C コンパイラへのオプションを指定した +い場合には環境変数 CFLAGS を使用してください。例えば + + % CFLAGS=-I/usr/local/include ./configure ... + (sh 系のシェルの場合) + % setenv CFLAGS -I/usr/local/include; ./configure ... + (csh 系のシェルの場合) + +とします。 + +configure には他にも多くのオプションがありますが、残りは一般的なオプショ +ンなので説明は省きます。 + + % ./configure --help + +を実行するとオプションの一覧が表示されます。 + +2. コンパイル + +configure を実行すると Makefile などが生成されますので、続けて makeを +実行してコンパイルします。 + + % make + +3. インストール + +スーパユーザになってインストールします。 + + % su + # make install + +4. Configuration and usage + +インストールされるツール (dnsproxy、mdnconv、runmdn) の使い方、設定方 +法に関してはオンラインマニュアルをご覧ください。mdnconv と runmdn につ +いては、mDNkit のリゾルバ設定ファイル mdnres.conf のマニュアルも参照し +てください。 + + % man dnsproxy + % man mdnconv + % man runmdn + % man mdnres.conf + + +* パッチの当て方 + +この配布キットには、bind-8.2.2-P7、bind-8.2.3-T6B、bind-9.0.0、および +squid-2.3-STABLE3 に対するパッチが含まれています。パッチの当て方は、パッ +チファイルの先頭に書かれていますのでそちらを参照してください。 + +Solaris では、システム付属の patch コマンドが正常に動作しないことがあ +ります。そのような場合には、GNU バージョンの patch +(http://www.gnu.org/software/patch/) をインストールして、これを使用し +てください。 + + +* 本キットに関する最新情報、問い合わせについて + +本キットに関する最新情報については、 +http://www.nic.ad.jp/jp/research/idn/ を参照してください + +本キットに関するバグレポートおよびコメントは、それぞれ +mdnkit-bugs@nic.ad.jp および idn-cmt@nic.ad.jp へお願いします。 + + +; $Id: README.ja,v 1.18 2000/11/21 07:54:13 ishisone Exp $ diff --git a/contrib/idn/mdnkit/acconfig.h b/contrib/idn/mdnkit/acconfig.h new file mode 100644 index 0000000000..f1fdd3cac3 --- /dev/null +++ b/contrib/idn/mdnkit/acconfig.h @@ -0,0 +1,77 @@ +/* $Id: acconfig.h,v 1.4 2000/11/17 06:51:11 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. + */ +@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 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 'bq--'. */ +#undef MDN_LACE_PREFIX + +/* Define as an appropriate type (ex. int) if your system doesn't have. */ +#undef BOOL diff --git a/contrib/idn/mdnkit/aclocal.m4 b/contrib/idn/mdnkit/aclocal.m4 new file mode 100644 index 0000000000..c41d84aa47 --- /dev/null +++ b/contrib/idn/mdnkit/aclocal.m4 @@ -0,0 +1,434 @@ +## libtool.m4 - Configure libtool for the target system. -*-Shell-script-*- +## Copyright (C) 1996-1999, 2000 Free Software Foundation, Inc. +## Originally by Gordon Matzigkeit , 1996 +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2 of the License, or +## (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program; if not, write to the Free Software +## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +## +## As a special exception to the GNU General Public License, if you +## distribute this file as part of a program that contains a +## configuration script generated by Autoconf, you may include it under +## the same distribution terms that you use for the rest of that program. + +# serial 40 AC_PROG_LIBTOOL +AC_DEFUN(AC_PROG_LIBTOOL, +[AC_REQUIRE([AC_LIBTOOL_SETUP])dnl + +# Save cache, so that ltconfig can load it +AC_CACHE_SAVE + +# Actually configure libtool. ac_aux_dir is where install-sh is found. +CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \ +LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \ +LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" \ +DLLTOOL="$DLLTOOL" AS="$AS" OBJDUMP="$OBJDUMP" \ +${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \ +$libtool_flags --no-verify $ac_aux_dir/ltmain.sh $lt_target \ +|| AC_MSG_ERROR([libtool configure failed]) + +# Reload cache, that may have been modified by ltconfig +AC_CACHE_LOAD + +# This can be used to rebuild libtool when needed +LIBTOOL_DEPS="$ac_aux_dir/ltconfig $ac_aux_dir/ltmain.sh" + +# Always use our own libtool. +LIBTOOL='$(SHELL) $(top_builddir)/libtool' +AC_SUBST(LIBTOOL)dnl + +# Redirect the config.log output again, so that the ltconfig log is not +# clobbered by the next message. +exec 5>>./config.log +]) + +AC_DEFUN(AC_LIBTOOL_SETUP, +[AC_PREREQ(2.13)dnl +AC_REQUIRE([AC_ENABLE_SHARED])dnl +AC_REQUIRE([AC_ENABLE_STATIC])dnl +AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl +AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +AC_REQUIRE([AC_PROG_RANLIB])dnl +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_PROG_LD])dnl +AC_REQUIRE([AC_PROG_NM])dnl +AC_REQUIRE([AC_PROG_LN_S])dnl +dnl + +case "$target" in +NONE) lt_target="$host" ;; +*) lt_target="$target" ;; +esac + +# Check for any special flags to pass to ltconfig. +libtool_flags="--cache-file=$cache_file" +test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared" +test "$enable_static" = no && libtool_flags="$libtool_flags --disable-static" +test "$enable_fast_install" = no && libtool_flags="$libtool_flags --disable-fast-install" +test "$ac_cv_prog_gcc" = yes && libtool_flags="$libtool_flags --with-gcc" +test "$ac_cv_prog_gnu_ld" = yes && libtool_flags="$libtool_flags --with-gnu-ld" +ifdef([AC_PROVIDE_AC_LIBTOOL_DLOPEN], +[libtool_flags="$libtool_flags --enable-dlopen"]) +ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL], +[libtool_flags="$libtool_flags --enable-win32-dll"]) +AC_ARG_ENABLE(libtool-lock, + [ --disable-libtool-lock avoid locking (might break parallel builds)]) +test "x$enable_libtool_lock" = xno && libtool_flags="$libtool_flags --disable-lock" +test x"$silent" = xyes && libtool_flags="$libtool_flags --silent" + +# Some flags need to be propagated to the compiler or linker for good +# libtool support. +case "$lt_target" in +*-*-irix6*) + # Find out which ABI we are using. + echo '[#]line __oline__ "configure"' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case "`/usr/bin/file conftest.o`" in + *32-bit*) + LD="${LD-ld} -32" + ;; + *N32*) + LD="${LD-ld} -n32" + ;; + *64-bit*) + LD="${LD-ld} -64" + ;; + esac + fi + rm -rf conftest* + ;; + +*-*-sco3.2v5*) + # On SCO OpenServer 5, we need -belf to get full-featured binaries. + SAVE_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -belf" + AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, + [AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])]) + if test x"$lt_cv_cc_needs_belf" != x"yes"; then + # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf + CFLAGS="$SAVE_CFLAGS" + fi + ;; + +ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL], +[*-*-cygwin* | *-*-mingw*) + AC_CHECK_TOOL(DLLTOOL, dlltool, false) + AC_CHECK_TOOL(AS, as, false) + AC_CHECK_TOOL(OBJDUMP, objdump, false) + ;; +]) +esac +]) + +# AC_LIBTOOL_DLOPEN - enable checks for dlopen support +AC_DEFUN(AC_LIBTOOL_DLOPEN, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])]) + +# AC_LIBTOOL_WIN32_DLL - declare package support for building win32 dll's +AC_DEFUN(AC_LIBTOOL_WIN32_DLL, [AC_BEFORE([$0], [AC_LIBTOOL_SETUP])]) + +# AC_ENABLE_SHARED - implement the --enable-shared flag +# Usage: AC_ENABLE_SHARED[(DEFAULT)] +# Where DEFAULT is either `yes' or `no'. If omitted, it defaults to +# `yes'. +AC_DEFUN(AC_ENABLE_SHARED, [dnl +define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl +AC_ARG_ENABLE(shared, +changequote(<<, >>)dnl +<< --enable-shared[=PKGS] build shared libraries [default=>>AC_ENABLE_SHARED_DEFAULT], +changequote([, ])dnl +[p=${PACKAGE-default} +case "$enableval" in +yes) enable_shared=yes ;; +no) enable_shared=no ;; +*) + enable_shared=no + # Look at the argument we got. We use all the common list separators. + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," + for pkg in $enableval; do + if test "X$pkg" = "X$p"; then + enable_shared=yes + fi + done + IFS="$ac_save_ifs" + ;; +esac], +enable_shared=AC_ENABLE_SHARED_DEFAULT)dnl +]) + +# AC_DISABLE_SHARED - set the default shared flag to --disable-shared +AC_DEFUN(AC_DISABLE_SHARED, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +AC_ENABLE_SHARED(no)]) + +# AC_ENABLE_STATIC - implement the --enable-static flag +# Usage: AC_ENABLE_STATIC[(DEFAULT)] +# Where DEFAULT is either `yes' or `no'. If omitted, it defaults to +# `yes'. +AC_DEFUN(AC_ENABLE_STATIC, [dnl +define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl +AC_ARG_ENABLE(static, +changequote(<<, >>)dnl +<< --enable-static[=PKGS] build static libraries [default=>>AC_ENABLE_STATIC_DEFAULT], +changequote([, ])dnl +[p=${PACKAGE-default} +case "$enableval" in +yes) enable_static=yes ;; +no) enable_static=no ;; +*) + enable_static=no + # Look at the argument we got. We use all the common list separators. + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," + for pkg in $enableval; do + if test "X$pkg" = "X$p"; then + enable_static=yes + fi + done + IFS="$ac_save_ifs" + ;; +esac], +enable_static=AC_ENABLE_STATIC_DEFAULT)dnl +]) + +# AC_DISABLE_STATIC - set the default static flag to --disable-static +AC_DEFUN(AC_DISABLE_STATIC, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +AC_ENABLE_STATIC(no)]) + + +# AC_ENABLE_FAST_INSTALL - implement the --enable-fast-install flag +# Usage: AC_ENABLE_FAST_INSTALL[(DEFAULT)] +# Where DEFAULT is either `yes' or `no'. If omitted, it defaults to +# `yes'. +AC_DEFUN(AC_ENABLE_FAST_INSTALL, [dnl +define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl +AC_ARG_ENABLE(fast-install, +changequote(<<, >>)dnl +<< --enable-fast-install[=PKGS] optimize for fast installation [default=>>AC_ENABLE_FAST_INSTALL_DEFAULT], +changequote([, ])dnl +[p=${PACKAGE-default} +case "$enableval" in +yes) enable_fast_install=yes ;; +no) enable_fast_install=no ;; +*) + enable_fast_install=no + # Look at the argument we got. We use all the common list separators. + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," + for pkg in $enableval; do + if test "X$pkg" = "X$p"; then + enable_fast_install=yes + fi + done + IFS="$ac_save_ifs" + ;; +esac], +enable_fast_install=AC_ENABLE_FAST_INSTALL_DEFAULT)dnl +]) + +# AC_ENABLE_FAST_INSTALL - set the default to --disable-fast-install +AC_DEFUN(AC_DISABLE_FAST_INSTALL, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +AC_ENABLE_FAST_INSTALL(no)]) + +# AC_PROG_LD - find the path to the GNU or non-GNU linker +AC_DEFUN(AC_PROG_LD, +[AC_ARG_WITH(gnu-ld, +[ --with-gnu-ld assume the C compiler uses GNU ld [default=no]], +test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no) +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +ac_prog=ld +if test "$ac_cv_prog_gcc" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + AC_MSG_CHECKING([for ld used by GCC]) + ac_prog=`($CC -print-prog-name=ld) 2>&5` + case "$ac_prog" in + # Accept absolute paths. +changequote(,)dnl + [\\/]* | [A-Za-z]:[\\/]*) + re_direlt='/[^/][^/]*/\.\./' +changequote([,])dnl + # Canonicalize the path of ld + ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` + while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do + ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test "$with_gnu_ld" = yes; then + AC_MSG_CHECKING([for GNU ld]) +else + AC_MSG_CHECKING([for non-GNU ld]) +fi +AC_CACHE_VAL(ac_cv_path_LD, +[if test -z "$LD"; then + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + ac_cv_path_LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some GNU ld's only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + if "$ac_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then + test "$with_gnu_ld" != no && break + else + test "$with_gnu_ld" != yes && break + fi + fi + done + IFS="$ac_save_ifs" +else + ac_cv_path_LD="$LD" # Let the user override the test with a path. +fi]) +LD="$ac_cv_path_LD" +if test -n "$LD"; then + AC_MSG_RESULT($LD) +else + AC_MSG_RESULT(no) +fi +test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH]) +AC_PROG_LD_GNU +]) + +AC_DEFUN(AC_PROG_LD_GNU, +[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], ac_cv_prog_gnu_ld, +[# I'd rather use --version here, but apparently some GNU ld's only accept -v. +if $LD -v 2>&1 &5; then + ac_cv_prog_gnu_ld=yes +else + ac_cv_prog_gnu_ld=no +fi]) +]) + +# AC_PROG_NM - find the path to a BSD-compatible name lister +AC_DEFUN(AC_PROG_NM, +[AC_MSG_CHECKING([for BSD-compatible nm]) +AC_CACHE_VAL(ac_cv_path_NM, +[if test -n "$NM"; then + # Let the user override the test. + ac_cv_path_NM="$NM" +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" + for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/nm || test -f $ac_dir/nm$ac_exeext ; then + # Check to see if the nm accepts a BSD-compat flag. + # Adding the `sed 1q' prevents false positives on HP-UX, which says: + # nm: unknown option "B" ignored + if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then + ac_cv_path_NM="$ac_dir/nm -B" + break + elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then + ac_cv_path_NM="$ac_dir/nm -p" + break + else + ac_cv_path_NM=${ac_cv_path_NM="$ac_dir/nm"} # keep the first match, but + continue # so that we can try to find one that supports BSD flags + fi + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_path_NM" && ac_cv_path_NM=nm +fi]) +NM="$ac_cv_path_NM" +AC_MSG_RESULT([$NM]) +]) + +# AC_CHECK_LIBM - check for math library +AC_DEFUN(AC_CHECK_LIBM, +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +LIBM= +case "$lt_target" in +*-*-beos* | *-*-cygwin*) + # These system don't have libm + ;; +*-ncr-sysv4.3*) + AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw") + AC_CHECK_LIB(m, main, LIBM="$LIBM -lm") + ;; +*) + AC_CHECK_LIB(m, main, LIBM="-lm") + ;; +esac +]) + +# AC_LIBLTDL_CONVENIENCE[(dir)] - sets LIBLTDL to the link flags for +# the libltdl convenience library and INCLTDL to the include flags for +# the libltdl header and adds --enable-ltdl-convenience to the +# configure arguments. Note that LIBLTDL and INCLTDL are not +# AC_SUBSTed, nor is AC_CONFIG_SUBDIRS called. If DIR is not +# provided, it is assumed to be `libltdl'. LIBLTDL will be prefixed +# with '${top_builddir}/' and INCLTDL will be prefixed with +# '${top_srcdir}/' (note the single quotes!). If your package is not +# flat and you're not using automake, define top_builddir and +# top_srcdir appropriately in the Makefiles. +AC_DEFUN(AC_LIBLTDL_CONVENIENCE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl + case "$enable_ltdl_convenience" in + no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;; + "") enable_ltdl_convenience=yes + ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;; + esac + LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdlc.la + INCLTDL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl']) +]) + +# AC_LIBLTDL_INSTALLABLE[(dir)] - sets LIBLTDL to the link flags for +# the libltdl installable library and INCLTDL to the include flags for +# the libltdl header and adds --enable-ltdl-install to the configure +# arguments. Note that LIBLTDL and INCLTDL are not AC_SUBSTed, nor is +# AC_CONFIG_SUBDIRS called. If DIR is not provided and an installed +# libltdl is not found, it is assumed to be `libltdl'. LIBLTDL will +# be prefixed with '${top_builddir}/' and INCLTDL will be prefixed +# with '${top_srcdir}/' (note the single quotes!). If your package is +# not flat and you're not using automake, define top_builddir and +# top_srcdir appropriately in the Makefiles. +# In the future, this macro may have to be called after AC_PROG_LIBTOOL. +AC_DEFUN(AC_LIBLTDL_INSTALLABLE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl + AC_CHECK_LIB(ltdl, main, + [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no], + [if test x"$enable_ltdl_install" = xno; then + AC_MSG_WARN([libltdl not installed, but installation disabled]) + else + enable_ltdl_install=yes + fi + ]) + if test x"$enable_ltdl_install" = x"yes"; then + ac_configure_args="$ac_configure_args --enable-ltdl-install" + LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdl.la + INCLTDL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl']) + else + ac_configure_args="$ac_configure_args --enable-ltdl-install=no" + LIBLTDL="-lltdl" + INCLTDL= + fi +]) + +dnl old names +AC_DEFUN(AM_PROG_LIBTOOL, [indir([AC_PROG_LIBTOOL])])dnl +AC_DEFUN(AM_ENABLE_SHARED, [indir([AC_ENABLE_SHARED], $@)])dnl +AC_DEFUN(AM_ENABLE_STATIC, [indir([AC_ENABLE_STATIC], $@)])dnl +AC_DEFUN(AM_DISABLE_SHARED, [indir([AC_DISABLE_SHARED], $@)])dnl +AC_DEFUN(AM_DISABLE_STATIC, [indir([AC_DISABLE_STATIC], $@)])dnl +AC_DEFUN(AM_PROG_LD, [indir([AC_PROG_LD])])dnl +AC_DEFUN(AM_PROG_NM, [indir([AC_PROG_NM])])dnl + +dnl This is just to silence aclocal about the macro not being used +ifelse([AC_DISABLE_FAST_INSTALL])dnl diff --git a/contrib/idn/mdnkit/config.guess b/contrib/idn/mdnkit/config.guess new file mode 100644 index 0000000000..0ce538bb85 --- /dev/null +++ b/contrib/idn/mdnkit/config.guess @@ -0,0 +1,1183 @@ +#! /bin/sh +# Attempt to guess a canonical system name. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000 +# Free Software Foundation, Inc. +# +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Written by Per Bothner . +# Please send patches to . +# +# This script attempts to guess a canonical system name similar to +# config.sub. If it succeeds, it prints the system name on stdout, and +# exits with 0. Otherwise, it exits with 1. +# +# The plan is that this can be called by configure scripts if you +# don't specify an explicit system type (host/target name). +# +# Only a few systems have been added to this list; please add others +# (but try to keep the structure clean). +# + +# Use $HOST_CC if defined. $CC may point to a cross-compiler +if test x"$CC_FOR_BUILD" = x; then + if test x"$HOST_CC" != x; then + CC_FOR_BUILD="$HOST_CC" + else + if test x"$CC" != x; then + CC_FOR_BUILD="$CC" + else + CC_FOR_BUILD=cc + fi + fi +fi + + +# This is needed to find uname on a Pyramid OSx when run in the BSD universe. +# (ghazi@noc.rutgers.edu 8/24/94.) +if (test -f /.attbin/uname) >/dev/null 2>&1 ; then + PATH=$PATH:/.attbin ; export PATH +fi + +UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown +UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown + +dummy=dummy-$$ +trap 'rm -f $dummy.c $dummy.o $dummy; exit 1' 1 2 15 + +# Note: order is significant - the case branches are not exclusive. + +case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in + *:NetBSD:*:*) + # Netbsd (nbsd) targets should (where applicable) match one or + # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, + # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently + # switched to ELF, *-*-netbsd* would select the old + # object file format. This provides both forward + # compatibility and a consistent mechanism for selecting the + # object file format. + # Determine the machine/vendor (is the vendor relevant). + case "${UNAME_MACHINE}" in + amiga) machine=m68k-cbm ;; + arm32) machine=arm-unknown ;; + atari*) machine=m68k-atari ;; + sun3*) machine=m68k-sun ;; + mac68k) machine=m68k-apple ;; + macppc) machine=powerpc-apple ;; + hp3[0-9][05]) machine=m68k-hp ;; + ibmrt|romp-ibm) machine=romp-ibm ;; + *) machine=${UNAME_MACHINE}-unknown ;; + esac + # The Operating System including object format. + if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep __ELF__ >/dev/null + then + # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). + # Return netbsd for either. FIX? + os=netbsd + else + os=netbsdelf + fi + # The OS release + release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: + # contains redundant information, the shorter form: + # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. + echo "${machine}-${os}${release}" + exit 0 ;; + alpha:OSF1:*:*) + if test $UNAME_RELEASE = "V4.0"; then + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` + fi + # A Vn.n version is a released version. + # A Tn.n version is a released field test version. + # A Xn.n version is an unreleased experimental baselevel. + # 1.2 uses "1.2" for uname -r. + cat <$dummy.s + .data +\$Lformat: + .byte 37,100,45,37,120,10,0 # "%d-%x\n" + + .text + .globl main + .align 4 + .ent main +main: + .frame \$30,16,\$26,0 + ldgp \$29,0(\$27) + .prologue 1 + .long 0x47e03d80 # implver \$0 + lda \$2,-1 + .long 0x47e20c21 # amask \$2,\$1 + lda \$16,\$Lformat + mov \$0,\$17 + not \$1,\$18 + jsr \$26,printf + ldgp \$29,0(\$26) + mov 0,\$16 + jsr \$26,exit + .end main +EOF + $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null + if test "$?" = 0 ; then + case `./$dummy` in + 0-0) + UNAME_MACHINE="alpha" + ;; + 1-0) + UNAME_MACHINE="alphaev5" + ;; + 1-1) + UNAME_MACHINE="alphaev56" + ;; + 1-101) + UNAME_MACHINE="alphapca56" + ;; + 2-303) + UNAME_MACHINE="alphaev6" + ;; + 2-307) + UNAME_MACHINE="alphaev67" + ;; + esac + fi + rm -f $dummy.s $dummy + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + exit 0 ;; + Alpha\ *:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # Should we change UNAME_MACHINE based on the output of uname instead + # of the specific Alpha model? + echo alpha-pc-interix + exit 0 ;; + 21064:Windows_NT:50:3) + echo alpha-dec-winnt3.5 + exit 0 ;; + Amiga*:UNIX_System_V:4.0:*) + echo m68k-cbm-sysv4 + exit 0;; + amiga:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + *:[Aa]miga[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-amigaos + exit 0 ;; + arc64:OpenBSD:*:*) + echo mips64el-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + arc:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + hkmips:OpenBSD:*:*) + echo mips-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + pmax:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + sgi:OpenBSD:*:*) + echo mips-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + wgrisc:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + *:OS/390:*:*) + echo i370-ibm-openedition + exit 0 ;; + arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) + echo arm-acorn-riscix${UNAME_RELEASE} + exit 0;; + SR2?01:HI-UX/MPP:*:*) + echo hppa1.1-hitachi-hiuxmpp + exit 0;; + Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) + # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. + if test "`(/bin/universe) 2>/dev/null`" = att ; then + echo pyramid-pyramid-sysv3 + else + echo pyramid-pyramid-bsd + fi + exit 0 ;; + NILE*:*:*:dcosx) + echo pyramid-pyramid-svr4 + exit 0 ;; + sun4H:SunOS:5.*:*) + echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) + echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + i86pc:SunOS:5.*:*) + echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + sun4*:SunOS:6*:*) + # According to config.sub, this is the proper way to canonicalize + # SunOS6. Hard to guess exactly what SunOS6 will be like, but + # it's likely to be more like Solaris than SunOS4. + echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + sun4*:SunOS:*:*) + case "`/usr/bin/arch -k`" in + Series*|S4*) + UNAME_RELEASE=`uname -v` + ;; + esac + # Japanese Language versions have a version number like `4.1.3-JL'. + echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` + exit 0 ;; + sun3*:SunOS:*:*) + echo m68k-sun-sunos${UNAME_RELEASE} + exit 0 ;; + sun*:*:4.2BSD:*) + UNAME_RELEASE=`(head -1 /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 + case "`/bin/arch`" in + sun3) + echo m68k-sun-sunos${UNAME_RELEASE} + ;; + sun4) + echo sparc-sun-sunos${UNAME_RELEASE} + ;; + esac + exit 0 ;; + aushp:SunOS:*:*) + echo sparc-auspex-sunos${UNAME_RELEASE} + exit 0 ;; + atari*:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + # The situation for MiNT is a little confusing. The machine name + # can be virtually everything (everything which is not + # "atarist" or "atariste" at least should have a processor + # > m68000). The system name ranges from "MiNT" over "FreeMiNT" + # to the lowercase version "mint" (or "freemint"). Finally + # the system name "TOS" denotes a system which is actually not + # MiNT. But MiNT is downward compatible to TOS, so this should + # be no problem. + atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit 0 ;; + atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit 0 ;; + *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit 0 ;; + milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) + echo m68k-milan-mint${UNAME_RELEASE} + exit 0 ;; + hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) + echo m68k-hades-mint${UNAME_RELEASE} + exit 0 ;; + *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) + echo m68k-unknown-mint${UNAME_RELEASE} + exit 0 ;; + sun3*:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mac68k:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mvme68k:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mvme88k:OpenBSD:*:*) + echo m88k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + powerpc:machten:*:*) + echo powerpc-apple-machten${UNAME_RELEASE} + exit 0 ;; + RISC*:Mach:*:*) + echo mips-dec-mach_bsd4.3 + exit 0 ;; + RISC*:ULTRIX:*:*) + echo mips-dec-ultrix${UNAME_RELEASE} + exit 0 ;; + VAX*:ULTRIX*:*:*) + echo vax-dec-ultrix${UNAME_RELEASE} + exit 0 ;; + 2020:CLIX:*:* | 2430:CLIX:*:*) + echo clipper-intergraph-clix${UNAME_RELEASE} + exit 0 ;; + mips:*:*:UMIPS | mips:*:*:RISCos) + sed 's/^ //' << EOF >$dummy.c +#ifdef __cplusplus +#include /* for printf() prototype */ + int main (int argc, char *argv[]) { +#else + int main (argc, argv) int argc; char *argv[]; { +#endif + #if defined (host_mips) && defined (MIPSEB) + #if defined (SYSTYPE_SYSV) + printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_SVR4) + printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) + printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + #endif + #endif + exit (-1); + } +EOF + $CC_FOR_BUILD $dummy.c -o $dummy \ + && ./$dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ + && rm $dummy.c $dummy && exit 0 + rm -f $dummy.c $dummy + echo mips-mips-riscos${UNAME_RELEASE} + exit 0 ;; + Night_Hawk:Power_UNIX:*:*) + echo powerpc-harris-powerunix + exit 0 ;; + m88k:CX/UX:7*:*) + echo m88k-harris-cxux7 + exit 0 ;; + m88k:*:4*:R4*) + echo m88k-motorola-sysv4 + exit 0 ;; + m88k:*:3*:R3*) + echo m88k-motorola-sysv3 + exit 0 ;; + AViiON:dgux:*:*) + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` + if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] + then + if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ + [ ${TARGET_BINARY_INTERFACE}x = x ] + then + echo m88k-dg-dgux${UNAME_RELEASE} + else + echo m88k-dg-dguxbcs${UNAME_RELEASE} + fi + else + echo i586-dg-dgux${UNAME_RELEASE} + fi + exit 0 ;; + M88*:DolphinOS:*:*) # DolphinOS (SVR3) + echo m88k-dolphin-sysv3 + exit 0 ;; + M88*:*:R3*:*) + # Delta 88k system running SVR3 + echo m88k-motorola-sysv3 + exit 0 ;; + XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) + echo m88k-tektronix-sysv3 + exit 0 ;; + Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) + echo m68k-tektronix-bsd + exit 0 ;; + *:IRIX*:*:*) + echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` + exit 0 ;; + ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. + echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id + exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + i?86:AIX:*:*) + echo i386-ibm-aix + exit 0 ;; + *:AIX:2:3) + if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then + sed 's/^ //' << EOF >$dummy.c + #include + + main() + { + if (!__power_pc()) + exit(1); + puts("powerpc-ibm-aix3.2.5"); + exit(0); + } +EOF + $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm $dummy.c $dummy && exit 0 + rm -f $dummy.c $dummy + echo rs6000-ibm-aix3.2.5 + elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then + echo rs6000-ibm-aix3.2.4 + else + echo rs6000-ibm-aix3.2 + fi + exit 0 ;; + *:AIX:*:4) + IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | head -1 | awk '{ print $1 }'` + if /usr/sbin/lsattr -EHl ${IBM_CPU_ID} | grep POWER >/dev/null 2>&1; then + IBM_ARCH=rs6000 + else + IBM_ARCH=powerpc + fi + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=4.${UNAME_RELEASE} + fi + echo ${IBM_ARCH}-ibm-aix${IBM_REV} + exit 0 ;; + *:AIX:*:*) + echo rs6000-ibm-aix + exit 0 ;; + ibmrt:4.4BSD:*|romp-ibm:BSD:*) + echo romp-ibm-bsd4.4 + exit 0 ;; + ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and + echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + exit 0 ;; # report: romp-ibm BSD 4.3 + *:BOSX:*:*) + echo rs6000-bull-bosx + exit 0 ;; + DPX/2?00:B.O.S.:*:*) + echo m68k-bull-sysv3 + exit 0 ;; + 9000/[34]??:4.3bsd:1.*:*) + echo m68k-hp-bsd + exit 0 ;; + hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) + echo m68k-hp-bsd4.4 + exit 0 ;; + 9000/[34678]??:HP-UX:*:*) + case "${UNAME_MACHINE}" in + 9000/31? ) HP_ARCH=m68000 ;; + 9000/[34]?? ) HP_ARCH=m68k ;; + 9000/[678][0-9][0-9]) + sed 's/^ //' << EOF >$dummy.c + + #define _HPUX_SOURCE + #include + #include + + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); + + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } +EOF + (CCOPTS= $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null ) && HP_ARCH=`./$dummy` + rm -f $dummy.c $dummy + esac + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + echo ${HP_ARCH}-hp-hpux${HPUX_REV} + exit 0 ;; + 3050*:HI-UX:*:*) + sed 's/^ //' << EOF >$dummy.c + #include + int + main () + { + long cpu = sysconf (_SC_CPU_VERSION); + /* The order matters, because CPU_IS_HP_MC68K erroneously returns + true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct + results, however. */ + if (CPU_IS_PA_RISC (cpu)) + { + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; + case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; + default: puts ("hppa-hitachi-hiuxwe2"); break; + } + } + else if (CPU_IS_HP_MC68K (cpu)) + puts ("m68k-hitachi-hiuxwe2"); + else puts ("unknown-hitachi-hiuxwe2"); + exit (0); + } +EOF + $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm $dummy.c $dummy && exit 0 + rm -f $dummy.c $dummy + echo unknown-hitachi-hiuxwe2 + exit 0 ;; + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) + echo hppa1.1-hp-bsd + exit 0 ;; + 9000/8??:4.3bsd:*:*) + echo hppa1.0-hp-bsd + exit 0 ;; + *9??*:MPE/iX:*:*) + echo hppa1.0-hp-mpeix + exit 0 ;; + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) + echo hppa1.1-hp-osf + exit 0 ;; + hp8??:OSF1:*:*) + echo hppa1.0-hp-osf + exit 0 ;; + i?86:OSF1:*:*) + if [ -x /usr/sbin/sysversion ] ; then + echo ${UNAME_MACHINE}-unknown-osf1mk + else + echo ${UNAME_MACHINE}-unknown-osf1 + fi + exit 0 ;; + parisc*:Lites*:*:*) + echo hppa1.1-hp-lites + exit 0 ;; + hppa*:OpenBSD:*:*) + echo hppa-unknown-openbsd + exit 0 ;; + C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) + echo c1-convex-bsd + exit 0 ;; + C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit 0 ;; + C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) + echo c34-convex-bsd + exit 0 ;; + C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) + echo c38-convex-bsd + exit 0 ;; + C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) + echo c4-convex-bsd + exit 0 ;; + CRAY*X-MP:*:*:*) + echo xmp-cray-unicos + exit 0 ;; + CRAY*Y-MP:*:*:*) + echo ymp-cray-unicos${UNAME_RELEASE} + exit 0 ;; + CRAY*[A-Z]90:*:*:*) + echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ + -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ + exit 0 ;; + CRAY*TS:*:*:*) + echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*T3E:*:*:*) + echo alpha-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*SV1:*:*:*) + echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY-2:*:*:*) + echo cray2-cray-unicos + exit 0 ;; + F300:UNIX_System_V:*:*) + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + echo "f300-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit 0 ;; + F301:UNIX_System_V:*:*) + echo f301-fujitsu-uxpv`echo $UNAME_RELEASE | sed 's/ .*//'` + exit 0 ;; + hp300:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + i?86:BSD/386:*:* | i?86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) + echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} + exit 0 ;; + sparc*:BSD/OS:*:*) + echo sparc-unknown-bsdi${UNAME_RELEASE} + exit 0 ;; + *:BSD/OS:*:*) + echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} + exit 0 ;; + *:FreeBSD:*:*) + echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + exit 0 ;; + *:OpenBSD:*:*) + echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + exit 0 ;; + i*:CYGWIN*:*) + echo ${UNAME_MACHINE}-pc-cygwin + exit 0 ;; + i*:MINGW*:*) + echo ${UNAME_MACHINE}-pc-mingw32 + exit 0 ;; + i*:Windows_NT*:* | Pentium*:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we + # UNAME_MACHINE based on the output of uname instead of i386? + echo i386-pc-interix + exit 0 ;; + i*:UWIN*:*) + echo ${UNAME_MACHINE}-pc-uwin + exit 0 ;; + p*:CYGWIN*:*) + echo powerpcle-unknown-cygwin + exit 0 ;; + prep*:SunOS:5.*:*) + echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + *:GNU:*:*) + echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + exit 0 ;; + *:Linux:*:*) + + # The BFD linker knows what the default object file format is, so + # first see if it will tell us. cd to the root directory to prevent + # problems with other programs or directories called `ld' in the path. + ld_help_string=`cd /; ld --help 2>&1` + ld_supported_emulations=`echo $ld_help_string \ + | sed -ne '/supported emulations:/!d + s/[ ][ ]*/ /g + s/.*supported emulations: *// + s/ .*// + p'` + case "$ld_supported_emulations" in + *ia64) + echo "${UNAME_MACHINE}-unknown-linux" + exit 0 + ;; + i?86linux) + echo "${UNAME_MACHINE}-pc-linux-gnuaout" + exit 0 + ;; + elf_i?86) + echo "${UNAME_MACHINE}-pc-linux" + exit 0 + ;; + i?86coff) + echo "${UNAME_MACHINE}-pc-linux-gnucoff" + exit 0 + ;; + sparclinux) + echo "${UNAME_MACHINE}-unknown-linux-gnuaout" + exit 0 + ;; + armlinux) + echo "${UNAME_MACHINE}-unknown-linux-gnuaout" + exit 0 + ;; + elf32arm*) + echo "${UNAME_MACHINE}-unknown-linux-gnuoldld" + exit 0 + ;; + armelf_linux*) + echo "${UNAME_MACHINE}-unknown-linux-gnu" + exit 0 + ;; + m68klinux) + echo "${UNAME_MACHINE}-unknown-linux-gnuaout" + exit 0 + ;; + elf32ppc | elf32ppclinux) + # Determine Lib Version + cat >$dummy.c < +#if defined(__GLIBC__) +extern char __libc_version[]; +extern char __libc_release[]; +#endif +main(argc, argv) + int argc; + char *argv[]; +{ +#if defined(__GLIBC__) + printf("%s %s\n", __libc_version, __libc_release); +#else + printf("unkown\n"); +#endif + return 0; +} +EOF + LIBC="" + $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null + if test "$?" = 0 ; then + ./$dummy | grep 1\.99 > /dev/null + if test "$?" = 0 ; then + LIBC="libc1" + fi + fi + rm -f $dummy.c $dummy + echo powerpc-unknown-linux-gnu${LIBC} + exit 0 + ;; + esac + + if test "${UNAME_MACHINE}" = "alpha" ; then + cat <$dummy.s + .data + \$Lformat: + .byte 37,100,45,37,120,10,0 # "%d-%x\n" + + .text + .globl main + .align 4 + .ent main + main: + .frame \$30,16,\$26,0 + ldgp \$29,0(\$27) + .prologue 1 + .long 0x47e03d80 # implver \$0 + lda \$2,-1 + .long 0x47e20c21 # amask \$2,\$1 + lda \$16,\$Lformat + mov \$0,\$17 + not \$1,\$18 + jsr \$26,printf + ldgp \$29,0(\$26) + mov 0,\$16 + jsr \$26,exit + .end main +EOF + LIBC="" + $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null + if test "$?" = 0 ; then + case `./$dummy` in + 0-0) + UNAME_MACHINE="alpha" + ;; + 1-0) + UNAME_MACHINE="alphaev5" + ;; + 1-1) + UNAME_MACHINE="alphaev56" + ;; + 1-101) + UNAME_MACHINE="alphapca56" + ;; + 2-303) + UNAME_MACHINE="alphaev6" + ;; + 2-307) + UNAME_MACHINE="alphaev67" + ;; + esac + + objdump --private-headers $dummy | \ + grep ld.so.1 > /dev/null + if test "$?" = 0 ; then + LIBC="libc1" + fi + fi + rm -f $dummy.s $dummy + echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} ; exit 0 + elif test "${UNAME_MACHINE}" = "mips" ; then + cat >$dummy.c < /* for printf() prototype */ + int main (int argc, char *argv[]) { +#else + int main (argc, argv) int argc; char *argv[]; { +#endif +#ifdef __MIPSEB__ + printf ("%s-unknown-linux-gnu\n", argv[1]); +#endif +#ifdef __MIPSEL__ + printf ("%sel-unknown-linux-gnu\n", argv[1]); +#endif + return 0; +} +EOF + $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm $dummy.c $dummy && exit 0 + rm -f $dummy.c $dummy + elif test "${UNAME_MACHINE}" = "s390"; then + echo s390-ibm-linux && exit 0 + else + # Either a pre-BFD a.out linker (linux-gnuoldld) + # or one that does not give us useful --help. + # GCC wants to distinguish between linux-gnuoldld and linux-gnuaout. + # If ld does not provide *any* "supported emulations:" + # that means it is gnuoldld. + echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations:" + test $? != 0 && echo "${UNAME_MACHINE}-pc-linux-gnuoldld" && exit 0 + + case "${UNAME_MACHINE}" in + i?86) + VENDOR=pc; + ;; + *) + VENDOR=unknown; + ;; + esac + # Determine whether the default compiler is a.out or elf + cat >$dummy.c < +#ifdef __cplusplus +#include /* for printf() prototype */ + int main (int argc, char *argv[]) { +#else + int main (argc, argv) int argc; char *argv[]; { +#endif +#ifdef __ELF__ +# ifdef __GLIBC__ +# if __GLIBC__ >= 2 + printf ("%s-${VENDOR}-linux-gnu\n", argv[1]); +# else + printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]); +# endif +# else + printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]); +# endif +#else + printf ("%s-${VENDOR}-linux-gnuaout\n", argv[1]); +#endif + return 0; +} +EOF + $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm $dummy.c $dummy && exit 0 + rm -f $dummy.c $dummy + fi ;; +# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. earlier versions +# are messed up and put the nodename in both sysname and nodename. + i?86:DYNIX/ptx:4*:*) + echo i386-sequent-sysv4 + exit 0 ;; + i?86:UNIX_SV:4.2MP:2.*) + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, + # I just have to hope. -- rms. + # Use sysv4.2uw... so that sysv4* matches it. + echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} + exit 0 ;; + i?86:*:4.*:* | i?86:SYSTEM_V:4.*:*) + UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` + if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then + echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} + else + echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} + fi + exit 0 ;; + i?86:*:5:7*) + # Fixed at (any) Pentium or better + UNAME_MACHINE=i586 + if [ ${UNAME_SYSTEM} = "UnixWare" ] ; then + echo ${UNAME_MACHINE}-sco-sysv${UNAME_RELEASE}uw${UNAME_VERSION} + else + echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE} + fi + exit 0 ;; + i?86:*:3.2:*) + if test -f /usr/options/cb.name; then + UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then + UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')` + (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486 + (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \ + && UNAME_MACHINE=i586 + (/bin/uname -X|egrep '^Machine.*Pent ?II' >/dev/null) \ + && UNAME_MACHINE=i686 + (/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) \ + && UNAME_MACHINE=i686 + echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + else + echo ${UNAME_MACHINE}-pc-sysv32 + fi + exit 0 ;; + i?86:*DOS:*:*) + echo ${UNAME_MACHINE}-pc-msdosdjgpp + exit 0 ;; + pc:*:*:*) + # Left here for compatibility: + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i386. + echo i386-pc-msdosdjgpp + exit 0 ;; + Intel:Mach:3*:*) + echo i386-pc-mach3 + exit 0 ;; + paragon:*:*:*) + echo i860-intel-osf1 + exit 0 ;; + i860:*:4.*:*) # i860-SVR4 + if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then + echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + else # Add other i860-SVR4 vendors below as they are discovered. + echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + fi + exit 0 ;; + mini*:CTIX:SYS*5:*) + # "miniframe" + echo m68010-convergent-sysv + exit 0 ;; + M68*:*:R3V[567]*:*) + test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; + 3[34]??:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0) + OS_REL='' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && echo i486-ncr-sysv4.3${OS_REL} && exit 0 + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; + 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && echo i486-ncr-sysv4 && exit 0 ;; + m68*:LynxOS:2.*:*) + echo m68k-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + mc68030:UNIX_System_V:4.*:*) + echo m68k-atari-sysv4 + exit 0 ;; + i?86:LynxOS:2.*:* | i?86:LynxOS:3.[01]*:*) + echo i386-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + TSUNAMI:LynxOS:2.*:*) + echo sparc-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + rs6000:LynxOS:2.*:* | PowerPC:LynxOS:2.*:*) + echo rs6000-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + SM[BE]S:UNIX_SV:*:*) + echo mips-dde-sysv${UNAME_RELEASE} + exit 0 ;; + RM*:ReliantUNIX-*:*:*) + echo mips-sni-sysv4 + exit 0 ;; + RM*:SINIX-*:*:*) + echo mips-sni-sysv4 + exit 0 ;; + *:SINIX-*:*:*) + if uname -p 2>/dev/null >/dev/null ; then + UNAME_MACHINE=`(uname -p) 2>/dev/null` + echo ${UNAME_MACHINE}-sni-sysv4 + else + echo ns32k-sni-sysv + fi + exit 0 ;; + PENTIUM:CPunix:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says + echo i586-unisys-sysv4 + exit 0 ;; + *:UNIX_System_V:4*:FTX*) + # From Gerald Hewes . + # How about differentiating between stratus architectures? -djm + echo hppa1.1-stratus-sysv4 + exit 0 ;; + *:*:*:FTX*) + # From seanf@swdc.stratus.com. + echo i860-stratus-sysv4 + exit 0 ;; + mc68*:A/UX:*:*) + echo m68k-apple-aux${UNAME_RELEASE} + exit 0 ;; + news*:NEWS-OS:*:6*) + echo mips-sony-newsos6 + exit 0 ;; + R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) + if [ -d /usr/nec ]; then + echo mips-nec-sysv${UNAME_RELEASE} + else + echo mips-unknown-sysv${UNAME_RELEASE} + fi + exit 0 ;; + BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. + echo powerpc-be-beos + exit 0 ;; + BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. + echo powerpc-apple-beos + exit 0 ;; + BePC:BeOS:*:*) # BeOS running on Intel PC compatible. + echo i586-pc-beos + exit 0 ;; + SX-4:SUPER-UX:*:*) + echo sx4-nec-superux${UNAME_RELEASE} + exit 0 ;; + SX-5:SUPER-UX:*:*) + echo sx5-nec-superux${UNAME_RELEASE} + exit 0 ;; + Power*:Rhapsody:*:*) + echo powerpc-apple-rhapsody${UNAME_RELEASE} + exit 0 ;; + *:Rhapsody:*:*) + echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} + exit 0 ;; + *:Darwin:*:*) + echo `uname -p`-apple-darwin${UNAME_RELEASE} + exit 0 ;; + *:procnto*:*:* | *:QNX:[0123456789]*:*) + if test "${UNAME_MACHINE}" = "x86pc"; then + UNAME_MACHINE=pc + fi + echo `uname -p`-${UNAME_MACHINE}-nto-qnx + exit 0 ;; + *:QNX:*:4*) + echo i386-pc-qnx + exit 0 ;; + NSR-W:NONSTOP_KERNEL:*:*) + echo nsr-tandem-nsk${UNAME_RELEASE} + exit 0 ;; + BS2000:POSIX*:*:*) + echo bs2000-siemens-sysv + exit 0 ;; + DS/*:UNIX_System_V:*:*) + echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} + exit 0 ;; +esac + +#echo '(No uname command or uname output not recognized.)' 1>&2 +#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 + +cat >$dummy.c < +# include +#endif +main () +{ +#if defined (sony) +#if defined (MIPSEB) + /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, + I don't know.... */ + printf ("mips-sony-bsd\n"); exit (0); +#else +#include + printf ("m68k-sony-newsos%s\n", +#ifdef NEWSOS4 + "4" +#else + "" +#endif + ); exit (0); +#endif +#endif + +#if defined (__arm) && defined (__acorn) && defined (__unix) + printf ("arm-acorn-riscix"); exit (0); +#endif + +#if defined (hp300) && !defined (hpux) + printf ("m68k-hp-bsd\n"); exit (0); +#endif + +#if defined (NeXT) +#if !defined (__ARCHITECTURE__) +#define __ARCHITECTURE__ "m68k" +#endif + int version; + version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; + if (version < 4) + printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); + else + printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); + exit (0); +#endif + +#if defined (MULTIMAX) || defined (n16) +#if defined (UMAXV) + printf ("ns32k-encore-sysv\n"); exit (0); +#else +#if defined (CMU) + printf ("ns32k-encore-mach\n"); exit (0); +#else + printf ("ns32k-encore-bsd\n"); exit (0); +#endif +#endif +#endif + +#if defined (__386BSD__) + printf ("i386-pc-bsd\n"); exit (0); +#endif + +#if defined (sequent) +#if defined (i386) + printf ("i386-sequent-dynix\n"); exit (0); +#endif +#if defined (ns32000) + printf ("ns32k-sequent-dynix\n"); exit (0); +#endif +#endif + +#if defined (_SEQUENT_) + struct utsname un; + + uname(&un); + + if (strncmp(un.version, "V2", 2) == 0) { + printf ("i386-sequent-ptx2\n"); exit (0); + } + if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ + printf ("i386-sequent-ptx1\n"); exit (0); + } + printf ("i386-sequent-ptx\n"); exit (0); + +#endif + +#if defined (vax) +#if !defined (ultrix) + printf ("vax-dec-bsd\n"); exit (0); +#else + printf ("vax-dec-ultrix\n"); exit (0); +#endif +#endif + +#if defined (alliant) && defined (i860) + printf ("i860-alliant-bsd\n"); exit (0); +#endif + + exit (1); +} +EOF + +$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm $dummy.c $dummy && exit 0 +rm -f $dummy.c $dummy + +# Apollos put the system type in the environment. + +test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } + +# Convex versions that predate uname can use getsysinfo(1) + +if [ -x /usr/convex/getsysinfo ] +then + case `getsysinfo -f cpu_type` in + c1*) + echo c1-convex-bsd + exit 0 ;; + c2*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit 0 ;; + c34*) + echo c34-convex-bsd + exit 0 ;; + c38*) + echo c38-convex-bsd + exit 0 ;; + c4*) + echo c4-convex-bsd + exit 0 ;; + esac +fi + +#echo '(Unable to guess system type)' 1>&2 + +exit 1 diff --git a/contrib/idn/mdnkit/config.sub b/contrib/idn/mdnkit/config.sub new file mode 100644 index 0000000000..c8e77851e6 --- /dev/null +++ b/contrib/idn/mdnkit/config.sub @@ -0,0 +1,1268 @@ +#! /bin/sh +# Configuration validation subroutine script, version 1.1. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000 +# Free Software Foundation, Inc. +# +# This file is (in principle) common to ALL GNU software. +# The presence of a machine in this file suggests that SOME GNU software +# can handle that machine. It does not imply ALL GNU software can. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Written by Per Bothner . +# Please send patches to . +# +# Configuration subroutine to validate and canonicalize a configuration type. +# Supply the specified configuration type as an argument. +# If it is invalid, we print an error message on stderr and exit with code 1. +# Otherwise, we print the canonical config type on stdout and succeed. + +# This file is supposed to be the same for all GNU packages +# and recognize all the CPU types, system types and aliases +# that are meaningful with *any* GNU software. +# Each package is responsible for reporting which valid configurations +# it does not support. The user should be able to distinguish +# a failure to support a valid configuration from a meaningless +# configuration. + +# The goal of this file is to map all the various variations of a given +# machine specification into a single specification in the form: +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or in some cases, the newer four-part form: +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# It is wrong to echo any other type of specification. + +if [ x$1 = x ] +then + echo Configuration name missing. 1>&2 + echo "Usage: $0 CPU-MFR-OPSYS" 1>&2 + echo "or $0 ALIAS" 1>&2 + echo where ALIAS is a recognized configuration type. 1>&2 + exit 1 +fi + +# First pass through any local machine types. +case $1 in + *local*) + echo $1 + exit 0 + ;; + *) + ;; +esac + +# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). +# Here we must recognize all the valid KERNEL-OS combinations. +maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` +case $maybe_os in + nto-qnx* | linux-gnu*) + os=-$maybe_os + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` + ;; + *) + basic_machine=`echo $1 | sed 's/-[^-]*$//'` + if [ $basic_machine != $1 ] + then os=`echo $1 | sed 's/.*-/-/'` + else os=; fi + ;; +esac + +### Let's recognize common machines as not being operating systems so +### that things like config.sub decstation-3100 work. We also +### recognize some manufacturers as not being operating systems, so we +### can provide default operating systems below. +case $os in + -sun*os*) + # Prevent following clause from handling this invalid input. + ;; + -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ + -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ + -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ + -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ + -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ + -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ + -apple) + os= + basic_machine=$1 + ;; + -sim | -cisco | -oki | -wec | -winbond) + os= + basic_machine=$1 + ;; + -scout) + ;; + -wrs) + os=-vxworks + basic_machine=$1 + ;; + -hiux*) + os=-hiuxwe2 + ;; + -sco5) + os=-sco3.2v5 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco4) + os=-sco3.2v4 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2.[4-9]*) + os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2v[4-9]*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco*) + os=-sco3.2v2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -udk*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -isc) + os=-isc2.2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -clix*) + basic_machine=clipper-intergraph + ;; + -isc*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -lynx*) + os=-lynxos + ;; + -ptx*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` + ;; + -windowsnt*) + os=`echo $os | sed -e 's/windowsnt/winnt/'` + ;; + -psos*) + os=-psos + ;; + -mint | -mint[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; +esac + +# Decode aliases for certain CPU-COMPANY combinations. +case $basic_machine in + # Recognize the basic CPU types without company name. + # Some are omitted here because they have special meanings below. + tahoe | i860 | ia64 | m32r | m68k | m68000 | m88k | ns32k | arc | arm \ + | arme[lb] | pyramid | mn10200 | mn10300 | tron | a29k \ + | 580 | i960 | h8300 \ + | x86 | ppcbe | mipsbe | mipsle | shbe | shle | armbe | armle \ + | hppa | hppa1.0 | hppa1.1 | hppa2.0 | hppa2.0w | hppa2.0n \ + | hppa64 \ + | alpha | alphaev[4-8] | alphaev56 | alphapca5[67] \ + | alphaev6[78] \ + | we32k | ns16k | clipper | i370 | sh | powerpc | powerpcle \ + | 1750a | dsp16xx | pdp11 | mips16 | mips64 | mipsel | mips64el \ + | mips64orion | mips64orionel | mipstx39 | mipstx39el \ + | mips64vr4300 | mips64vr4300el | mips64vr4100 | mips64vr4100el \ + | mips64vr5000 | miprs64vr5000el | mcore \ + | sparc | sparclet | sparclite | sparc64 | sparcv9 | v850 | c4x \ + | thumb | d10v | fr30 | avr) + basic_machine=$basic_machine-unknown + ;; + m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | z8k | v70 | h8500 | w65 | pj | pjl) + ;; + + # We use `pc' rather than `unknown' + # because (1) that's what they normally are, and + # (2) the word "unknown" tends to confuse beginning users. + i[34567]86) + basic_machine=$basic_machine-pc + ;; + # Object if more than one company name word. + *-*-*) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; + # Recognize the basic CPU types with company name. + # FIXME: clean up the formatting here. + vax-* | tahoe-* | i[34567]86-* | i860-* | ia64-* | m32r-* | m68k-* | m68000-* \ + | m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | arm-* | c[123]* \ + | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \ + | power-* | none-* | 580-* | cray2-* | h8300-* | h8500-* | i960-* \ + | xmp-* | ymp-* \ + | x86-* | ppcbe-* | mipsbe-* | mipsle-* | shbe-* | shle-* | armbe-* | armle-* \ + | hppa-* | hppa1.0-* | hppa1.1-* | hppa2.0-* | hppa2.0w-* \ + | hppa2.0n-* | hppa64-* \ + | alpha-* | alphaev[4-8]-* | alphaev56-* | alphapca5[67]-* \ + | alphaev6[78]-* \ + | we32k-* | cydra-* | ns16k-* | pn-* | np1-* | xps100-* \ + | clipper-* | orion-* \ + | sparclite-* | pdp11-* | sh-* | powerpc-* | powerpcle-* \ + | sparc64-* | sparcv9-* | sparc86x-* | mips16-* | mips64-* | mipsel-* \ + | mips64el-* | mips64orion-* | mips64orionel-* \ + | mips64vr4100-* | mips64vr4100el-* | mips64vr4300-* | mips64vr4300el-* \ + | mipstx39-* | mipstx39el-* | mcore-* \ + | f301-* | armv*-* | s390-* | sv1-* | t3e-* \ + | m88110-* | m680[01234]0-* | m683?2-* | m68360-* | z8k-* | d10v-* \ + | thumb-* | v850-* | d30v-* | tic30-* | c30-* | fr30-* \ + | bs2000-*) + ;; + # Recognize the various machine names and aliases which stand + # for a CPU type and a company and sometimes even an OS. + 386bsd) + basic_machine=i386-unknown + os=-bsd + ;; + 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) + basic_machine=m68000-att + ;; + 3b*) + basic_machine=we32k-att + ;; + a29khif) + basic_machine=a29k-amd + os=-udi + ;; + adobe68k) + basic_machine=m68010-adobe + os=-scout + ;; + alliant | fx80) + basic_machine=fx80-alliant + ;; + altos | altos3068) + basic_machine=m68k-altos + ;; + am29k) + basic_machine=a29k-none + os=-bsd + ;; + amdahl) + basic_machine=580-amdahl + os=-sysv + ;; + amiga | amiga-*) + basic_machine=m68k-cbm + ;; + amigaos | amigados) + basic_machine=m68k-cbm + os=-amigaos + ;; + amigaunix | amix) + basic_machine=m68k-cbm + os=-sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + os=-sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + os=-bsd + ;; + aux) + basic_machine=m68k-apple + os=-aux + ;; + balance) + basic_machine=ns32k-sequent + os=-dynix + ;; + convex-c1) + basic_machine=c1-convex + os=-bsd + ;; + convex-c2) + basic_machine=c2-convex + os=-bsd + ;; + convex-c32) + basic_machine=c32-convex + os=-bsd + ;; + convex-c34) + basic_machine=c34-convex + os=-bsd + ;; + convex-c38) + basic_machine=c38-convex + os=-bsd + ;; + cray | ymp) + basic_machine=ymp-cray + os=-unicos + ;; + cray2) + basic_machine=cray2-cray + os=-unicos + ;; + [ctj]90-cray) + basic_machine=c90-cray + os=-unicos + ;; + crds | unos) + basic_machine=m68k-crds + ;; + da30 | da30-*) + basic_machine=m68k-da30 + ;; + decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) + basic_machine=mips-dec + ;; + delta | 3300 | motorola-3300 | motorola-delta \ + | 3300-motorola | delta-motorola) + basic_machine=m68k-motorola + ;; + delta88) + basic_machine=m88k-motorola + os=-sysv3 + ;; + dpx20 | dpx20-*) + basic_machine=rs6000-bull + os=-bosx + ;; + dpx2* | dpx2*-bull) + basic_machine=m68k-bull + os=-sysv3 + ;; + ebmon29k) + basic_machine=a29k-amd + os=-ebmon + ;; + elxsi) + basic_machine=elxsi-elxsi + os=-bsd + ;; + encore | umax | mmax) + basic_machine=ns32k-encore + ;; + es1800 | OSE68k | ose68k | ose | OSE) + basic_machine=m68k-ericsson + os=-ose + ;; + fx2800) + basic_machine=i860-alliant + ;; + genix) + basic_machine=ns32k-ns + ;; + gmicro) + basic_machine=tron-gmicro + os=-sysv + ;; + h3050r* | hiux*) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + h8300hms) + basic_machine=h8300-hitachi + os=-hms + ;; + h8300xray) + basic_machine=h8300-hitachi + os=-xray + ;; + h8500hms) + basic_machine=h8500-hitachi + os=-hms + ;; + harris) + basic_machine=m88k-harris + os=-sysv3 + ;; + hp300-*) + basic_machine=m68k-hp + ;; + hp300bsd) + basic_machine=m68k-hp + os=-bsd + ;; + hp300hpux) + basic_machine=m68k-hp + os=-hpux + ;; + hp3k9[0-9][0-9] | hp9[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k2[0-9][0-9] | hp9k31[0-9]) + basic_machine=m68000-hp + ;; + hp9k3[2-9][0-9]) + basic_machine=m68k-hp + ;; + hp9k6[0-9][0-9] | hp6[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k7[0-79][0-9] | hp7[0-79][0-9]) + basic_machine=hppa1.1-hp + ;; + hp9k78[0-9] | hp78[0-9]) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][13679] | hp8[0-9][13679]) + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][0-9] | hp8[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hppa-next) + os=-nextstep3 + ;; + hppaosf) + basic_machine=hppa1.1-hp + os=-osf + ;; + hppro) + basic_machine=hppa1.1-hp + os=-proelf + ;; + i370-ibm* | ibm*) + basic_machine=i370-ibm + ;; +# I'm not sure what "Sysv32" means. Should this be sysv3.2? + i[34567]86v32) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv32 + ;; + i[34567]86v4*) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv4 + ;; + i[34567]86v) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv + ;; + i[34567]86sol2) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-solaris2 + ;; + i386mach) + basic_machine=i386-mach + os=-mach + ;; + i386-vsta | vsta) + basic_machine=i386-unknown + os=-vsta + ;; + i386-go32 | go32) + basic_machine=i386-unknown + os=-go32 + ;; + i386-mingw32 | mingw32) + basic_machine=i386-unknown + os=-mingw32 + ;; + iris | iris4d) + basic_machine=mips-sgi + case $os in + -irix*) + ;; + *) + os=-irix4 + ;; + esac + ;; + isi68 | isi) + basic_machine=m68k-isi + os=-sysv + ;; + m88k-omron*) + basic_machine=m88k-omron + ;; + magnum | m3230) + basic_machine=mips-mips + os=-sysv + ;; + merlin) + basic_machine=ns32k-utek + os=-sysv + ;; + miniframe) + basic_machine=m68000-convergent + ;; + *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; + mipsel*-linux*) + basic_machine=mipsel-unknown + os=-linux-gnu + ;; + mips*-linux*) + basic_machine=mips-unknown + os=-linux-gnu + ;; + mips3*-*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` + ;; + mips3*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown + ;; + mmix*) + basic_machine=mmix-knuth + os=-mmixware + ;; + monitor) + basic_machine=m68k-rom68k + os=-coff + ;; + msdos) + basic_machine=i386-unknown + os=-msdos + ;; + mvs) + basic_machine=i370-ibm + os=-mvs + ;; + ncr3000) + basic_machine=i486-ncr + os=-sysv4 + ;; + netbsd386) + basic_machine=i386-unknown + os=-netbsd + ;; + netwinder) + basic_machine=armv4l-rebel + os=-linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + os=-newsos + ;; + news1000) + basic_machine=m68030-sony + os=-newsos + ;; + news-3600 | risc-news) + basic_machine=mips-sony + os=-newsos + ;; + necv70) + basic_machine=v70-nec + os=-sysv + ;; + next | m*-next ) + basic_machine=m68k-next + case $os in + -nextstep* ) + ;; + -ns2*) + os=-nextstep2 + ;; + *) + os=-nextstep3 + ;; + esac + ;; + nh3000) + basic_machine=m68k-harris + os=-cxux + ;; + nh[45]000) + basic_machine=m88k-harris + os=-cxux + ;; + nindy960) + basic_machine=i960-intel + os=-nindy + ;; + mon960) + basic_machine=i960-intel + os=-mon960 + ;; + np1) + basic_machine=np1-gould + ;; + nsr-tandem) + basic_machine=nsr-tandem + ;; + op50n-* | op60c-*) + basic_machine=hppa1.1-oki + os=-proelf + ;; + OSE68000 | ose68000) + basic_machine=m68000-ericsson + os=-ose + ;; + os68k) + basic_machine=m68k-none + os=-os68k + ;; + pa-hitachi) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + paragon) + basic_machine=i860-intel + os=-osf + ;; + pbd) + basic_machine=sparc-tti + ;; + pbb) + basic_machine=m68k-tti + ;; + pc532 | pc532-*) + basic_machine=ns32k-pc532 + ;; + pentium | p5 | k5 | k6 | nexen) + basic_machine=i586-pc + ;; + pentiumpro | p6 | 6x86) + basic_machine=i686-pc + ;; + pentiumii | pentium2) + basic_machine=i786-pc + ;; + pentium-* | p5-* | k5-* | k6-* | nexen-*) + basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumpro-* | p6-* | 6x86-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumii-* | pentium2-*) + basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pn) + basic_machine=pn-gould + ;; + power) basic_machine=rs6000-ibm + ;; + ppc) basic_machine=powerpc-unknown + ;; + ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppcle | powerpclittle | ppc-le | powerpc-little) + basic_machine=powerpcle-unknown + ;; + ppcle-* | powerpclittle-*) + basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ps2) + basic_machine=i386-ibm + ;; + rom68k) + basic_machine=m68k-rom68k + os=-coff + ;; + rm[46]00) + basic_machine=mips-siemens + ;; + rtpc | rtpc-*) + basic_machine=romp-ibm + ;; + sa29200) + basic_machine=a29k-amd + os=-udi + ;; + sequent) + basic_machine=i386-sequent + ;; + sh) + basic_machine=sh-hitachi + os=-hms + ;; + sparclite-wrs) + basic_machine=sparclite-wrs + os=-vxworks + ;; + sps7) + basic_machine=m68k-bull + os=-sysv2 + ;; + spur) + basic_machine=spur-unknown + ;; + st2000) + basic_machine=m68k-tandem + ;; + stratus) + basic_machine=i860-stratus + os=-sysv4 + ;; + sun2) + basic_machine=m68000-sun + ;; + sun2os3) + basic_machine=m68000-sun + os=-sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + os=-sunos4 + ;; + sun3os3) + basic_machine=m68k-sun + os=-sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + os=-sunos4 + ;; + sun4os3) + basic_machine=sparc-sun + os=-sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + os=-sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + os=-solaris2 + ;; + sun3 | sun3-*) + basic_machine=m68k-sun + ;; + sun4) + basic_machine=sparc-sun + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + ;; + sv1) + basic_machine=sv1-cray + os=-unicos + ;; + symmetry) + basic_machine=i386-sequent + os=-dynix + ;; + t3e) + basic_machine=t3e-cray + os=-unicos + ;; + tx39) + basic_machine=mipstx39-unknown + ;; + tx39el) + basic_machine=mipstx39el-unknown + ;; + tower | tower-32) + basic_machine=m68k-ncr + ;; + udi29k) + basic_machine=a29k-amd + os=-udi + ;; + ultra3) + basic_machine=a29k-nyu + os=-sym1 + ;; + v810 | necv810) + basic_machine=v810-nec + os=-none + ;; + vaxv) + basic_machine=vax-dec + os=-sysv + ;; + vms) + basic_machine=vax-dec + os=-vms + ;; + vpp*|vx|vx-*) + basic_machine=f301-fujitsu + ;; + vxworks960) + basic_machine=i960-wrs + os=-vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + os=-vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + os=-vxworks + ;; + w65*) + basic_machine=w65-wdc + os=-none + ;; + w89k-*) + basic_machine=hppa1.1-winbond + os=-proelf + ;; + xmp) + basic_machine=xmp-cray + os=-unicos + ;; + xps | xps100) + basic_machine=xps100-honeywell + ;; + z8k-*-coff) + basic_machine=z8k-unknown + os=-sim + ;; + none) + basic_machine=none-none + os=-none + ;; + +# Here we handle the default manufacturer of certain CPU types. It is in +# some cases the only manufacturer, in others, it is the most popular. + w89k) + basic_machine=hppa1.1-winbond + ;; + op50n) + basic_machine=hppa1.1-oki + ;; + op60c) + basic_machine=hppa1.1-oki + ;; + mips) + if [ x$os = x-linux-gnu ]; then + basic_machine=mips-unknown + else + basic_machine=mips-mips + fi + ;; + romp) + basic_machine=romp-ibm + ;; + rs6000) + basic_machine=rs6000-ibm + ;; + vax) + basic_machine=vax-dec + ;; + pdp11) + basic_machine=pdp11-dec + ;; + we32k) + basic_machine=we32k-att + ;; + sparc | sparcv9) + basic_machine=sparc-sun + ;; + cydra) + basic_machine=cydra-cydrome + ;; + orion) + basic_machine=orion-highlevel + ;; + orion105) + basic_machine=clipper-highlevel + ;; + mac | mpw | mac-mpw) + basic_machine=m68k-apple + ;; + pmac | pmac-mpw) + basic_machine=powerpc-apple + ;; + c4x*) + basic_machine=c4x-none + os=-coff + ;; + *) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; +esac + +# Here we canonicalize certain aliases for manufacturers. +case $basic_machine in + *-digital*) + basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` + ;; + *-commodore*) + basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + ;; + *) + ;; +esac + +# Decode manufacturer-specific aliases for certain operating systems. + +if [ x"$os" != x"" ] +then +case $os in + # First match some system type aliases + # that might get confused with valid system types. + # -solaris* is a basic system type, with this one exception. + -solaris1 | -solaris1.*) + os=`echo $os | sed -e 's|solaris1|sunos4|'` + ;; + -solaris) + os=-solaris2 + ;; + -svr4*) + os=-sysv4 + ;; + -unixware*) + os=-sysv4.2uw + ;; + -gnu/linux*) + os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` + ;; + # First accept the basic system types. + # The portable systems comes first. + # Each alternative MUST END IN A *, to match a version number. + # -sysv* is not here because it comes later, after sysvr4. + -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ + | -aos* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \ + | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ + | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ + | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ + | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \ + | -interix* | -uwin* | -rhapsody* | -darwin* | -opened* \ + | -openstep* | -oskit*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; + -qnx*) + case $basic_machine in + x86-* | i[34567]86-*) + ;; + *) + os=-nto$os + ;; + esac + ;; + -nto*) + os=-nto-qnx + ;; + -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ + | -windows* | -osx | -abug | -netware* | -os9* | -beos* \ + | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) + ;; + -mac*) + os=`echo $os | sed -e 's|mac|macos|'` + ;; + -linux*) + os=`echo $os | sed -e 's|linux|linux-gnu|'` + ;; + -sunos5*) + os=`echo $os | sed -e 's|sunos5|solaris2|'` + ;; + -sunos6*) + os=`echo $os | sed -e 's|sunos6|solaris3|'` + ;; + -opened*) + os=-openedition + ;; + -wince*) + os=-wince + ;; + -osfrose*) + os=-osfrose + ;; + -osf*) + os=-osf + ;; + -utek*) + os=-bsd + ;; + -dynix*) + os=-bsd + ;; + -acis*) + os=-aos + ;; + -386bsd) + os=-bsd + ;; + -ctix* | -uts*) + os=-sysv + ;; + -ns2 ) + os=-nextstep2 + ;; + -nsk) + os=-nsk + ;; + # Preserve the version number of sinix5. + -sinix5.*) + os=`echo $os | sed -e 's|sinix|sysv|'` + ;; + -sinix*) + os=-sysv4 + ;; + -triton*) + os=-sysv3 + ;; + -oss*) + os=-sysv3 + ;; + -svr4) + os=-sysv4 + ;; + -svr3) + os=-sysv3 + ;; + -sysvr4) + os=-sysv4 + ;; + # This must come after -sysvr4. + -sysv*) + ;; + -ose*) + os=-ose + ;; + -es1800*) + os=-ose + ;; + -xenix) + os=-xenix + ;; + -*mint | -*MiNT) + os=-mint + ;; + -none) + ;; + *) + # Get rid of the `-' at the beginning of $os. + os=`echo $os | sed 's/[^-]*-//'` + echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 + exit 1 + ;; +esac +else + +# Here we handle the default operating systems that come with various machines. +# The value should be what the vendor currently ships out the door with their +# machine or put another way, the most popular os provided with the machine. + +# Note that if you're going to try to match "-MANUFACTURER" here (say, +# "-sun"), then you have to tell the case statement up towards the top +# that MANUFACTURER isn't an operating system. Otherwise, code above +# will signal an error saying that MANUFACTURER isn't an operating +# system, and we'll never get to this point. + +case $basic_machine in + *-acorn) + os=-riscix1.2 + ;; + arm*-rebel) + os=-linux + ;; + arm*-semi) + os=-aout + ;; + pdp11-*) + os=-none + ;; + *-dec | vax-*) + os=-ultrix4.2 + ;; + m68*-apollo) + os=-domain + ;; + i386-sun) + os=-sunos4.0.2 + ;; + m68000-sun) + os=-sunos3 + # This also exists in the configure program, but was not the + # default. + # os=-sunos4 + ;; + m68*-cisco) + os=-aout + ;; + mips*-cisco) + os=-elf + ;; + mips*-*) + os=-elf + ;; + *-tti) # must be before sparc entry or we get the wrong os. + os=-sysv3 + ;; + sparc-* | *-sun) + os=-sunos4.1.1 + ;; + *-be) + os=-beos + ;; + *-ibm) + os=-aix + ;; + *-wec) + os=-proelf + ;; + *-winbond) + os=-proelf + ;; + *-oki) + os=-proelf + ;; + *-hp) + os=-hpux + ;; + *-hitachi) + os=-hiux + ;; + i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) + os=-sysv + ;; + *-cbm) + os=-amigaos + ;; + *-dg) + os=-dgux + ;; + *-dolphin) + os=-sysv3 + ;; + m68k-ccur) + os=-rtu + ;; + m88k-omron*) + os=-luna + ;; + *-next ) + os=-nextstep + ;; + *-sequent) + os=-ptx + ;; + *-crds) + os=-unos + ;; + *-ns) + os=-genix + ;; + i370-*) + os=-mvs + ;; + *-next) + os=-nextstep3 + ;; + *-gould) + os=-sysv + ;; + *-highlevel) + os=-bsd + ;; + *-encore) + os=-bsd + ;; + *-sgi) + os=-irix + ;; + *-siemens) + os=-sysv4 + ;; + *-masscomp) + os=-rtu + ;; + f301-fujitsu) + os=-uxpv + ;; + *-rom68k) + os=-coff + ;; + *-*bug) + os=-coff + ;; + *-apple) + os=-macos + ;; + *-atari*) + os=-mint + ;; + *) + os=-none + ;; +esac +fi + +# Here we handle the case where we know the os, and the CPU type, but not the +# manufacturer. We pick the logical manufacturer. +vendor=unknown +case $basic_machine in + *-unknown) + case $os in + -riscix*) + vendor=acorn + ;; + -sunos*) + vendor=sun + ;; + -aix*) + vendor=ibm + ;; + -beos*) + vendor=be + ;; + -hpux*) + vendor=hp + ;; + -mpeix*) + vendor=hp + ;; + -hiux*) + vendor=hitachi + ;; + -unos*) + vendor=crds + ;; + -dgux*) + vendor=dg + ;; + -luna*) + vendor=omron + ;; + -genix*) + vendor=ns + ;; + -mvs* | -opened*) + vendor=ibm + ;; + -ptx*) + vendor=sequent + ;; + -vxsim* | -vxworks*) + vendor=wrs + ;; + -aux*) + vendor=apple + ;; + -hms*) + vendor=hitachi + ;; + -mpw* | -macos*) + vendor=apple + ;; + -*mint | -*MiNT) + vendor=atari + ;; + esac + basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` + ;; +esac + +echo $basic_machine$os diff --git a/contrib/idn/mdnkit/configure b/contrib/idn/mdnkit/configure new file mode 100644 index 0000000000..b3dbdccb09 --- /dev/null +++ b/contrib/idn/mdnkit/configure @@ -0,0 +1,2411 @@ +#! /bin/sh + +# Guess values for system-dependent variables and create Makefiles. +# Generated automatically using autoconf version 2.13 +# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. +# +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. + +# Defaults: +ac_help= +ac_default_prefix=/usr/local +# Any additions from configure.in: +ac_help="$ac_help + --enable-zld enable ZLD support. [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--]" +ac_help="$ac_help + --with-brace-suffix=PREFIX suffix for BRACE encoding [-8q9]" +ac_help="$ac_help + --with-lace-prefix=PREFIX prefix for LACE encoding [bq--]" +ac_help="$ac_help + --with-iconv=LIB special library for iconv []" +ac_help="$ac_help + --with-iconv-sofile=PATH shared library file for libiconv []" +ac_help="$ac_help + --enable-shared[=PKGS] build shared libraries [default=yes]" +ac_help="$ac_help + --enable-static[=PKGS] build static libraries [default=yes]" +ac_help="$ac_help + --enable-fast-install[=PKGS] optimize for fast installation [default=yes]" +ac_help="$ac_help + --with-gnu-ld assume the C compiler uses GNU ld [default=no]" +ac_help="$ac_help + --disable-libtool-lock avoid locking (might break parallel builds)" + +# Initialize some variables set by options. +# The variables have the same names as the options, with +# dashes changed to underlines. +build=NONE +cache_file=./config.cache +exec_prefix=NONE +host=NONE +no_create= +nonopt=NONE +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +target=NONE +verbose= +x_includes=NONE +x_libraries=NONE +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datadir='${prefix}/share' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +libdir='${exec_prefix}/lib' +includedir='${prefix}/include' +oldincludedir='/usr/include' +infodir='${prefix}/info' +mandir='${prefix}/man' + +# Initialize some other variables. +subdirs= +MFLAGS= MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} +# Maximum number of lines to put in a shell here document. +ac_max_here_lines=12 + +ac_prev= +for ac_option +do + + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval "$ac_prev=\$ac_option" + ac_prev= + continue + fi + + case "$ac_option" in + -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; + *) ac_optarg= ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case "$ac_option" in + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir="$ac_optarg" ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build="$ac_optarg" ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file="$ac_optarg" ;; + + -datadir | --datadir | --datadi | --datad | --data | --dat | --da) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ + | --da=*) + datadir="$ac_optarg" ;; + + -disable-* | --disable-*) + ac_feature=`echo $ac_option|sed -e 's/-*disable-//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then + { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } + fi + ac_feature=`echo $ac_feature| sed 's/-/_/g'` + eval "enable_${ac_feature}=no" ;; + + -enable-* | --enable-*) + ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then + { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } + fi + ac_feature=`echo $ac_feature| sed 's/-/_/g'` + case "$ac_option" in + *=*) ;; + *) ac_optarg=yes ;; + esac + eval "enable_${ac_feature}='$ac_optarg'" ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix="$ac_optarg" ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he) + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat << EOF +Usage: configure [options] [host] +Options: [defaults in brackets after descriptions] +Configuration: + --cache-file=FILE cache test results in FILE + --help print this message + --no-create do not create output files + --quiet, --silent do not print \`checking...' messages + --version print the version of autoconf that created configure +Directory and file names: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [same as prefix] + --bindir=DIR user executables in DIR [EPREFIX/bin] + --sbindir=DIR system admin executables in DIR [EPREFIX/sbin] + --libexecdir=DIR program executables in DIR [EPREFIX/libexec] + --datadir=DIR read-only architecture-independent data in DIR + [PREFIX/share] + --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data in DIR + [PREFIX/com] + --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var] + --libdir=DIR object code libraries in DIR [EPREFIX/lib] + --includedir=DIR C header files in DIR [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include] + --infodir=DIR info documentation in DIR [PREFIX/info] + --mandir=DIR man documentation in DIR [PREFIX/man] + --srcdir=DIR find the sources in DIR [configure dir or ..] + --program-prefix=PREFIX prepend PREFIX to installed program names + --program-suffix=SUFFIX append SUFFIX to installed program names + --program-transform-name=PROGRAM + run sed PROGRAM on installed program names +EOF + cat << EOF +Host type: + --build=BUILD configure for building on BUILD [BUILD=HOST] + --host=HOST configure for HOST [guessed] + --target=TARGET configure for TARGET [TARGET=HOST] +Features and packages: + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --x-includes=DIR X include files are in DIR + --x-libraries=DIR X library files are in DIR +EOF + if test -n "$ac_help"; then + echo "--enable and --with options recognized:$ac_help" + fi + exit 0 ;; + + -host | --host | --hos | --ho) + ac_prev=host ;; + -host=* | --host=* | --hos=* | --ho=*) + host="$ac_optarg" ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir="$ac_optarg" ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir="$ac_optarg" ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir="$ac_optarg" ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir="$ac_optarg" ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst \ + | --locals | --local | --loca | --loc | --lo) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* \ + | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) + localstatedir="$ac_optarg" ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir="$ac_optarg" ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir="$ac_optarg" ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix="$ac_optarg" ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix="$ac_optarg" ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix="$ac_optarg" ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name="$ac_optarg" ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir="$ac_optarg" ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir="$ac_optarg" ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site="$ac_optarg" ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir="$ac_optarg" ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir="$ac_optarg" ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target="$ac_optarg" ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers) + echo "configure generated by autoconf version 2.13" + exit 0 ;; + + -with-* | --with-*) + ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then + { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } + fi + ac_package=`echo $ac_package| sed 's/-/_/g'` + case "$ac_option" in + *=*) ;; + *) ac_optarg=yes ;; + esac + eval "with_${ac_package}='$ac_optarg'" ;; + + -without-* | --without-*) + ac_package=`echo $ac_option|sed -e 's/-*without-//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then + { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } + fi + ac_package=`echo $ac_package| sed 's/-/_/g'` + eval "with_${ac_package}=no" ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes="$ac_optarg" ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries="$ac_optarg" ;; + + -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; } + ;; + + *) + if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then + echo "configure: warning: $ac_option: invalid host type" 1>&2 + fi + if test "x$nonopt" != xNONE; then + { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } + fi + nonopt="$ac_option" + ;; + + esac +done + +if test -n "$ac_prev"; then + { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; } +fi + +trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 + +# File descriptor usage: +# 0 standard input +# 1 file creation +# 2 errors and warnings +# 3 some systems may open it to /dev/tty +# 4 used on the Kubota Titan +# 6 checking for... messages and results +# 5 compiler messages saved in config.log +if test "$silent" = yes; then + exec 6>/dev/null +else + exec 6>&1 +fi +exec 5>./config.log + +echo "\ +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. +" 1>&5 + +# Strip out --no-create and --no-recursion so they do not pile up. +# Also quote any args containing shell metacharacters. +ac_configure_args= +for ac_arg +do + case "$ac_arg" in + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c) ;; + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;; + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) + ac_configure_args="$ac_configure_args '$ac_arg'" ;; + *) ac_configure_args="$ac_configure_args $ac_arg" ;; + esac +done + +# NLS nuisances. +# Only set these to C if already set. These must not be set unconditionally +# because not all systems understand e.g. LANG=C (notably SCO). +# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'! +# Non-C LC_CTYPE values break the ctype check. +if test "${LANG+set}" = set; then LANG=C; export LANG; fi +if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi +if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi +if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -rf conftest* confdefs.h +# AIX cpp loses on an empty file, so make sure it contains at least a newline. +echo > confdefs.h + +# A filename unique to this package, relative to the directory that +# configure is in, which we can look for to find out if srcdir is correct. +ac_unique_file=include/mdn/converter.h + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then its parent. + ac_prog=$0 + ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'` + test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. + srcdir=$ac_confdir + if test ! -r $srcdir/$ac_unique_file; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r $srcdir/$ac_unique_file; then + if test "$ac_srcdir_defaulted" = yes; then + { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; } + else + { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; } + fi +fi +srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'` + +# Prefer explicitly selected file to automatically selected ones. +if test -z "$CONFIG_SITE"; then + if test "x$prefix" != xNONE; then + CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" + else + CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" + fi +fi +for ac_site_file in $CONFIG_SITE; do + if test -r "$ac_site_file"; then + echo "loading site script $ac_site_file" + . "$ac_site_file" + fi +done + +if test -r "$cache_file"; then + echo "loading cache $cache_file" + . $cache_file +else + echo "creating cache $cache_file" + > $cache_file +fi + +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +ac_exeext= +ac_objext=o +if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then + # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. + if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then + ac_n= ac_c=' +' ac_t=' ' + else + ac_n=-n ac_c= ac_t= + fi +else + ac_n= ac_c='\c' ac_t= +fi + + + +ac_aux_dir= +for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do + if test -f $ac_dir/install-sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f $ac_dir/install.sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + fi +done +if test -z "$ac_aux_dir"; then + { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; } +fi +ac_config_guess=$ac_aux_dir/config.guess +ac_config_sub=$ac_aux_dir/config.sub +ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. + + +# Make sure we can run config.sub. +if ${CONFIG_SHELL-/bin/sh} $ac_config_sub sun4 >/dev/null 2>&1; then : +else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; } +fi + +echo $ac_n "checking host system type""... $ac_c" 1>&6 +echo "configure:576: checking host system type" >&5 + +host_alias=$host +case "$host_alias" in +NONE) + case $nonopt in + NONE) + if host_alias=`${CONFIG_SHELL-/bin/sh} $ac_config_guess`; then : + else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; } + fi ;; + *) host_alias=$nonopt ;; + esac ;; +esac + +host=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $host_alias` +host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` +echo "$ac_t""$host" 1>&6 + + +zld=no +# Check whether --enable-zld or --disable-zld was given. +if test "${enable_zld+set}" = set; then + enableval="$enable_zld" + zld=$enableval +fi + +case "$zld" in +no) + ;; +yes) + cat >> confdefs.h <<\EOF +#define MDN_SUPPORT_ZLD 1 +EOF + + ;; +*) + { echo "configure: error: You must specify yes or no to --enable-zld option." 1>&2; exit 1; } + ;; +esac + +utf8name=no +# Check whether --with-utf8 or --without-utf8 was given. +if test "${with_utf8+set}" = set; then + withval="$with_utf8" + utf8name=$withval +fi + +case "$utf8name" in +no) + ;; +yes) + { echo "configure: error: You must specify NAME to --with-utf8 option." 1>&2; exit 1; } + ;; +*) + cat >> confdefs.h <&2; exit 1; } + ;; +*) + cat >> confdefs.h <&2; exit 1; } + ;; +*) + cat >> confdefs.h <&2; exit 1; } + ;; +*) + cat >> confdefs.h <&6 +echo "configure:704: checking for iconv in -liconv" >&5 +ac_lib_var=`echo iconv'_'iconv | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-liconv $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_lib=HAVE_LIB`echo iconv | sed -e 's/[^a-zA-Z0-9_]/_/g' \ + -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` + cat >> confdefs.h <&6 +fi + +# Check whether --with-iconv or --without-iconv was given. +if test "${with_iconv+set}" = set; then + withval="$with_iconv" + iconv=$withval +fi + +case "$iconv" in +no) + ICONVLIB= + ;; +yes) + echo "configure: warning: You must supply LIB to --with-iconv option. + -liconv is assumed." 1>&2 + ICONVLIB=-liconv + ;; +*) + ICONVLIB=$iconv + ;; +esac + + +# Check whether --with-iconv-sofile or --without-iconv-sofile was given. +if test "${with_iconv_sofile+set}" = set; then + withval="$with_iconv_sofile" + iconv_file=$withval +else + iconv_file=guess +fi + +ICONVSOFILE= +case "$iconv_file" in +no) + ICONVSOFILE=none + ;; +yes) + { echo "configure: error: You must supply PATH to --with-iconv-sofile option." 1>&2; exit 1; } + ;; +guess) + if test "$ICONVLIB" = ""; then + ICONVSOFILE=none + else + echo $ac_n "checking pathname of iconv shared library""... $ac_c" 1>&6 +echo "configure:792: checking pathname of iconv shared library" >&5 + ic_libdir= + ic_libname= + case "$host" in + *-hpux*) + SO=sl + ;; + *) + SO=so + ;; + esac + for arg in $ICONVLIB; do + case "$arg" in + -L*) ic_libdir="$ic_libdir `echo $arg | sed s/-L//`" ;; + -l*) ic_libname=`echo $arg | sed s/-l//` ;; + /*.$SO*) ICONVSOFILE=$arg ;; + esac + done + if test "$ICONVSOFILE" = ""; then + if test "$ic_libname" = ""; then + echo "$ac_t""unknown" 1>&6 + echo "configure: warning: use --with-iconv-sofile for specifying iconv shared library file" 1>&2 + ICONVSOFILE=none + else + if test "$ic_libdir" = ""; then + # Standard (and semi-standard) library directories + ic_libdir="/lib /usr/lib /usr/local/lib" + fi + for dir in $ic_libdir; do + ICONVSOFILE=`ls -r $dir/lib$ic_libname.$SO* 2>/dev/null | head -1` + if test "$ICONVSOFILE" != ""; then + break + fi + done + if test "$ICONVSOFILE" != ""; then + echo "$ac_t""$ICONVSOFILE" 1>&6 + else + echo "$ac_t""unknown" 1>&6 + echo "configure: warning: use --with-iconv-sofile for specifying iconv shared library file" 1>&2 + ICONVSOFILE=none + fi + fi + fi + fi + ;; +*) + ICONVSOFILE=$iconv_file + ;; +esac + + +PRELOAD_VAR="LD_PRELOAD" +PRELOAD_SEP=":" +PRELOAD_LAST="" +case "$host" in +*-solaris*) + PRELOAD_SEP=" " + ;; +*-osf*) + PRELOAD_VAR="_RLD_LIST" + PRELOAD_LAST=":DEFAULT" + ;; +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:862: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_CC="gcc" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:892: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_prog_rejected=no + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + break + fi + done + IFS="$ac_save_ifs" +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# -gt 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + set dummy "$ac_dir/$ac_word" "$@" + shift + ac_cv_prog_CC="$@" + fi +fi +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + if test -z "$CC"; then + case "`uname -s`" in + *win32* | *WIN32*) + # Extract the first word of "cl", so it can be a program name with args. +set dummy cl; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:943: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_CC="cl" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + ;; + esac + fi + test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } +fi + +echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 +echo "configure:975: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 + +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +cat > conftest.$ac_ext << EOF + +#line 986 "configure" +#include "confdefs.h" + +main(){return(0);} +EOF +if { (eval echo configure:991: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + ac_cv_prog_cc_works=yes + # If we can't run a trivial program, we are probably using a cross compiler. + if (./conftest; exit) 2>/dev/null; then + ac_cv_prog_cc_cross=no + else + ac_cv_prog_cc_cross=yes + fi +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + ac_cv_prog_cc_works=no +fi +rm -fr conftest* +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +echo "$ac_t""$ac_cv_prog_cc_works" 1>&6 +if test $ac_cv_prog_cc_works = no; then + { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } +fi +echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 +echo "configure:1017: 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:1022: checking whether we are using GNU C" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.c <&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then + ac_cv_prog_gcc=yes +else + ac_cv_prog_gcc=no +fi +fi + +echo "$ac_t""$ac_cv_prog_gcc" 1>&6 + +if test $ac_cv_prog_gcc = yes; then + GCC=yes +else + GCC= +fi + +ac_test_CFLAGS="${CFLAGS+set}" +ac_save_CFLAGS="$CFLAGS" +CFLAGS= +echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 +echo "configure:1050: checking whether ${CC-cc} accepts -g" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + echo 'void f(){}' > conftest.c +if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then + ac_cv_prog_cc_g=yes +else + ac_cv_prog_cc_g=no +fi +rm -f conftest* + +fi + +echo "$ac_t""$ac_cv_prog_cc_g" 1>&6 +if test "$ac_test_CFLAGS" = set; then + CFLAGS="$ac_save_CFLAGS" +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi + +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# ./install, which can be erroneously created by make from ./install.sh. +echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 +echo "configure:1093: checking for a BSD compatible install" >&5 +if test -z "$INSTALL"; then +if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":" + for ac_dir in $PATH; do + # Account for people who put trailing slashes in PATH elements. + case "$ac_dir/" in + /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + if test -f $ac_dir/$ac_prog; then + if test $ac_prog = install && + grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + else + ac_cv_path_install="$ac_dir/$ac_prog -c" + break 2 + fi + fi + done + ;; + esac + done + IFS="$ac_save_IFS" + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL="$ac_cv_path_install" + else + # As a last resort, use the slow shell script. We don't cache a + # path for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the path is relative. + INSTALL="$ac_install_sh" + fi +fi +echo "$ac_t""$INSTALL" 1>&6 + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + +# Check whether --enable-shared or --disable-shared was given. +if test "${enable_shared+set}" = set; then + enableval="$enable_shared" + p=${PACKAGE-default} +case "$enableval" in +yes) enable_shared=yes ;; +no) enable_shared=no ;; +*) + enable_shared=no + # Look at the argument we got. We use all the common list separators. + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," + for pkg in $enableval; do + if test "X$pkg" = "X$p"; then + enable_shared=yes + fi + done + IFS="$ac_save_ifs" + ;; +esac +else + enable_shared=yes +fi + +# Check whether --enable-static or --disable-static was given. +if test "${enable_static+set}" = set; then + enableval="$enable_static" + p=${PACKAGE-default} +case "$enableval" in +yes) enable_static=yes ;; +no) enable_static=no ;; +*) + enable_static=no + # Look at the argument we got. We use all the common list separators. + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," + for pkg in $enableval; do + if test "X$pkg" = "X$p"; then + enable_static=yes + fi + done + IFS="$ac_save_ifs" + ;; +esac +else + enable_static=yes +fi + +# Check whether --enable-fast-install or --disable-fast-install was given. +if test "${enable_fast_install+set}" = set; then + enableval="$enable_fast_install" + p=${PACKAGE-default} +case "$enableval" in +yes) enable_fast_install=yes ;; +no) enable_fast_install=no ;; +*) + enable_fast_install=no + # Look at the argument we got. We use all the common list separators. + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," + for pkg in $enableval; do + if test "X$pkg" = "X$p"; then + enable_fast_install=yes + fi + done + IFS="$ac_save_ifs" + ;; +esac +else + enable_fast_install=yes +fi + +echo $ac_n "checking build system type""... $ac_c" 1>&6 +echo "configure:1215: checking build system type" >&5 + +build_alias=$build +case "$build_alias" in +NONE) + case $nonopt in + NONE) build_alias=$host_alias ;; + *) build_alias=$nonopt ;; + esac ;; +esac + +build=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $build_alias` +build_cpu=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +build_vendor=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +build_os=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` +echo "$ac_t""$build" 1>&6 + +# Extract the first word of "ranlib", so it can be a program name with args. +set dummy ranlib; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:1235: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_RANLIB="ranlib" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":" +fi +fi +RANLIB="$ac_cv_prog_RANLIB" +if test -n "$RANLIB"; then + echo "$ac_t""$RANLIB" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +# Check whether --with-gnu-ld or --without-gnu-ld was given. +if test "${with_gnu_ld+set}" = set; then + withval="$with_gnu_ld" + test "$withval" = no || with_gnu_ld=yes +else + with_gnu_ld=no +fi + +ac_prog=ld +if test "$ac_cv_prog_gcc" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + echo $ac_n "checking for ld used by GCC""... $ac_c" 1>&6 +echo "configure:1274: checking for ld used by GCC" >&5 + ac_prog=`($CC -print-prog-name=ld) 2>&5` + case "$ac_prog" in + # Accept absolute paths. + [\\/]* | [A-Za-z]:[\\/]*) + re_direlt='/[^/][^/]*/\.\./' + # Canonicalize the path of ld + ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` + while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do + ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test "$with_gnu_ld" = yes; then + echo $ac_n "checking for GNU ld""... $ac_c" 1>&6 +echo "configure:1298: checking for GNU ld" >&5 +else + echo $ac_n "checking for non-GNU ld""... $ac_c" 1>&6 +echo "configure:1301: checking for non-GNU ld" >&5 +fi +if eval "test \"`echo '$''{'ac_cv_path_LD'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -z "$LD"; then + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + ac_cv_path_LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some GNU ld's only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + if "$ac_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then + test "$with_gnu_ld" != no && break + else + test "$with_gnu_ld" != yes && break + fi + fi + done + IFS="$ac_save_ifs" +else + ac_cv_path_LD="$LD" # Let the user override the test with a path. +fi +fi + +LD="$ac_cv_path_LD" +if test -n "$LD"; then + echo "$ac_t""$LD" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi +test -z "$LD" && { echo "configure: error: no acceptable ld found in \$PATH" 1>&2; exit 1; } +echo $ac_n "checking if the linker ($LD) is GNU ld""... $ac_c" 1>&6 +echo "configure:1336: checking if the linker ($LD) is GNU ld" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_gnu_ld'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + # I'd rather use --version here, but apparently some GNU ld's only accept -v. +if $LD -v 2>&1 &5; then + ac_cv_prog_gnu_ld=yes +else + ac_cv_prog_gnu_ld=no +fi +fi + +echo "$ac_t""$ac_cv_prog_gnu_ld" 1>&6 + + +echo $ac_n "checking for BSD-compatible nm""... $ac_c" 1>&6 +echo "configure:1352: checking for BSD-compatible nm" >&5 +if eval "test \"`echo '$''{'ac_cv_path_NM'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$NM"; then + # Let the user override the test. + ac_cv_path_NM="$NM" +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" + for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/nm || test -f $ac_dir/nm$ac_exeext ; then + # Check to see if the nm accepts a BSD-compat flag. + # Adding the `sed 1q' prevents false positives on HP-UX, which says: + # nm: unknown option "B" ignored + if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then + ac_cv_path_NM="$ac_dir/nm -B" + break + elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then + ac_cv_path_NM="$ac_dir/nm -p" + break + else + ac_cv_path_NM=${ac_cv_path_NM="$ac_dir/nm"} # keep the first match, but + continue # so that we can try to find one that supports BSD flags + fi + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_path_NM" && ac_cv_path_NM=nm +fi +fi + +NM="$ac_cv_path_NM" +echo "$ac_t""$NM" 1>&6 + +echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6 +echo "configure:1388: checking whether ln -s works" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_LN_S'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + rm -f conftestdata +if ln -s X conftestdata 2>/dev/null +then + rm -f conftestdata + ac_cv_prog_LN_S="ln -s" +else + ac_cv_prog_LN_S=ln +fi +fi +LN_S="$ac_cv_prog_LN_S" +if test "$ac_cv_prog_LN_S" = "ln -s"; then + echo "$ac_t""yes" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + +case "$target" in +NONE) lt_target="$host" ;; +*) lt_target="$target" ;; +esac + +# Check for any special flags to pass to ltconfig. +libtool_flags="--cache-file=$cache_file" +test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared" +test "$enable_static" = no && libtool_flags="$libtool_flags --disable-static" +test "$enable_fast_install" = no && libtool_flags="$libtool_flags --disable-fast-install" +test "$ac_cv_prog_gcc" = yes && libtool_flags="$libtool_flags --with-gcc" +test "$ac_cv_prog_gnu_ld" = yes && libtool_flags="$libtool_flags --with-gnu-ld" + + +# Check whether --enable-libtool-lock or --disable-libtool-lock was given. +if test "${enable_libtool_lock+set}" = set; then + enableval="$enable_libtool_lock" + : +fi + +test "x$enable_libtool_lock" = xno && libtool_flags="$libtool_flags --disable-lock" +test x"$silent" = xyes && libtool_flags="$libtool_flags --silent" + +# Some flags need to be propagated to the compiler or linker for good +# libtool support. +case "$lt_target" in +*-*-irix6*) + # Find out which ABI we are using. + echo '#line 1437 "configure"' > conftest.$ac_ext + if { (eval echo configure:1438: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + case "`/usr/bin/file conftest.o`" in + *32-bit*) + LD="${LD-ld} -32" + ;; + *N32*) + LD="${LD-ld} -n32" + ;; + *64-bit*) + LD="${LD-ld} -64" + ;; + esac + fi + rm -rf conftest* + ;; + +*-*-sco3.2v5*) + # On SCO OpenServer 5, we need -belf to get full-featured binaries. + SAVE_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -belf" + echo $ac_n "checking whether the C compiler needs -belf""... $ac_c" 1>&6 +echo "configure:1459: 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 <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + lt_cv_cc_needs_belf=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + lt_cv_cc_needs_belf=no +fi +rm -f conftest* +fi + +echo "$ac_t""$lt_cv_cc_needs_belf" 1>&6 + if test x"$lt_cv_cc_needs_belf" != x"yes"; then + # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf + CFLAGS="$SAVE_CFLAGS" + fi + ;; + + +esac + + +# Save cache, so that ltconfig can load it +cat > confcache <<\EOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs. It is not useful on other systems. +# If it contains results you don't want to keep, you may remove or edit it. +# +# By default, configure uses ./config.cache as the cache file, +# creating it if it does not exist already. You can give configure +# the --cache-file=FILE option to use a different cache file; that is +# what configure does when it calls configure scripts in +# subdirectories, so they share the cache. +# Giving --cache-file=/dev/null disables caching, for debugging configure. +# config.status only pays attention to the cache file if you give it the +# --recheck option to rerun configure. +# +EOF +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, don't put newlines in cache variables' values. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +(set) 2>&1 | + case `(ac_space=' '; set | grep ac_space) 2>&1` in + *ac_space=\ *) + # `set' does not quote correctly, so add quotes (double-quote substitution + # turns \\\\ into \\, and sed turns \\ into \). + sed -n \ + -e "s/'/'\\\\''/g" \ + -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p" + ;; + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p' + ;; + esac >> confcache +if cmp -s $cache_file confcache; then + : +else + if test -w $cache_file; then + echo "updating cache $cache_file" + cat confcache > $cache_file + else + echo "not updating unwritable cache $cache_file" + fi +fi +rm -f confcache + + +# Actually configure libtool. ac_aux_dir is where install-sh is found. +CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \ +LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \ +LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" \ +DLLTOOL="$DLLTOOL" AS="$AS" OBJDUMP="$OBJDUMP" \ +${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \ +$libtool_flags --no-verify $ac_aux_dir/ltmain.sh $lt_target \ +|| { echo "configure: error: libtool configure failed" 1>&2; exit 1; } + +# Reload cache, that may have been modified by ltconfig +if test -r "$cache_file"; then + echo "loading cache $cache_file" + . $cache_file +else + echo "creating cache $cache_file" + > $cache_file +fi + + +# This can be used to rebuild libtool when needed +LIBTOOL_DEPS="$ac_aux_dir/ltconfig $ac_aux_dir/ltmain.sh" + +# Always use our own libtool. +LIBTOOL='$(SHELL) $(top_builddir)/libtool' + +# Redirect the config.log output again, so that the ltconfig log is not +# clobbered by the next message. +exec 5>>./config.log + + +echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 +echo "configure:1574: checking how to run the C preprocessor" >&5 +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then +if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + # This must be in double quotes, not single quotes, because CPP may get + # substituted into the Makefile and "${CC-cc}" will confuse make. + CPP="${CC-cc} -E" + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. + cat > conftest.$ac_ext < +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1595: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP="${CC-cc} -E -traditional-cpp" + cat > conftest.$ac_ext < +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 + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP="${CC-cc} -nologo -E" + cat > conftest.$ac_ext < +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 + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP=/lib/cpp +fi +rm -f conftest* +fi +rm -f conftest* +fi +rm -f conftest* + ac_cv_prog_CPP="$CPP" +fi + CPP="$ac_cv_prog_CPP" +else + ac_cv_prog_CPP="$CPP" +fi +echo "$ac_t""$CPP" 1>&6 + +for ac_hdr in unistd.h locale.h langinfo.h sys/select.h iconv.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "configure:1657: 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 +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1667: \"$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 <&6 +fi +done + + +echo $ac_n "checking for uid_t in sys/types.h""... $ac_c" 1>&6 +echo "configure:1695: 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 +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "uid_t" >/dev/null 2>&1; then + rm -rf conftest* + ac_cv_type_uid_t=yes +else + rm -rf conftest* + ac_cv_type_uid_t=no +fi +rm -f conftest* + +fi + +echo "$ac_t""$ac_cv_type_uid_t" 1>&6 +if test $ac_cv_type_uid_t = no; then + cat >> confdefs.h <<\EOF +#define uid_t int +EOF + + cat >> confdefs.h <<\EOF +#define gid_t int +EOF + +fi + +echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 +echo "configure:1729: 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 < +#include +#include +#include +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1742: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + ac_cv_header_stdc=yes +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. +cat > conftest.$ac_ext < +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "memchr" >/dev/null 2>&1; then + : +else + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. +cat > conftest.$ac_ext < +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "free" >/dev/null 2>&1; then + : +else + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. +if test "$cross_compiling" = yes; then + : +else + cat > conftest.$ac_ext < +#define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int main () { int i; for (i = 0; i < 256; i++) +if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); +exit (0); } + +EOF +if { (eval echo configure:1809: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + : +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_header_stdc=no +fi +rm -fr conftest* +fi + +fi +fi + +echo "$ac_t""$ac_cv_header_stdc" 1>&6 +if test $ac_cv_header_stdc = yes; then + cat >> confdefs.h <<\EOF +#define STDC_HEADERS 1 +EOF + +fi + +echo $ac_n "checking for BOOL""... $ac_c" 1>&6 +echo "configure:1833: 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 < +#if STDC_HEADERS +#include +#include +#endif +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "(^|[^a-zA-Z_0-9])BOOL[^a-zA-Z_0-9]" >/dev/null 2>&1; then + rm -rf conftest* + ac_cv_type_BOOL=yes +else + rm -rf conftest* + ac_cv_type_BOOL=no +fi +rm -f conftest* + +fi +echo "$ac_t""$ac_cv_type_BOOL" 1>&6 +if test $ac_cv_type_BOOL = no; then + cat >> confdefs.h <<\EOF +#define BOOL int +EOF + +fi + + +echo $ac_n "checking for socket in -lsocket""... $ac_c" 1>&6 +echo "configure:1867: checking for socket in -lsocket" >&5 +ac_lib_var=`echo socket'_'socket | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lsocket $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_lib=HAVE_LIB`echo socket | sed -e 's/[^a-zA-Z0-9_]/_/g' \ + -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` + cat >> confdefs.h <&6 +fi + +echo $ac_n "checking for inet_addr in -lnsl""... $ac_c" 1>&6 +echo "configure:1914: checking for inet_addr in -lnsl" >&5 +ac_lib_var=`echo nsl'_'inet_addr | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lnsl $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_lib=HAVE_LIB`echo nsl | sed -e 's/[^a-zA-Z0-9_]/_/g' \ + -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` + cat >> confdefs.h <&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:1964: 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 < +/* 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:1992: \"$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 <&6 +fi +done + + + +trap '' 1 2 15 +cat > confcache <<\EOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs. It is not useful on other systems. +# If it contains results you don't want to keep, you may remove or edit it. +# +# By default, configure uses ./config.cache as the cache file, +# creating it if it does not exist already. You can give configure +# the --cache-file=FILE option to use a different cache file; that is +# what configure does when it calls configure scripts in +# subdirectories, so they share the cache. +# Giving --cache-file=/dev/null disables caching, for debugging configure. +# config.status only pays attention to the cache file if you give it the +# --recheck option to rerun configure. +# +EOF +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, don't put newlines in cache variables' values. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +(set) 2>&1 | + case `(ac_space=' '; set | grep ac_space) 2>&1` in + *ac_space=\ *) + # `set' does not quote correctly, so add quotes (double-quote substitution + # turns \\\\ into \\, and sed turns \\ into \). + sed -n \ + -e "s/'/'\\\\''/g" \ + -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p" + ;; + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p' + ;; + esac >> confcache +if cmp -s $cache_file confcache; then + : +else + if test -w $cache_file; then + echo "updating cache $cache_file" + cat confcache > $cache_file + else + echo "not updating unwritable cache $cache_file" + fi +fi +rm -f confcache + +trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +# Any assignment to VPATH causes Sun make to only execute +# the first set of double-colon rules, so remove it if not needed. +# If there is a colon in the path, we need to keep it. +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d' +fi + +trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15 + +DEFS=-DHAVE_CONFIG_H + +# Without the "./", some shells look in PATH for config.status. +: ${CONFIG_STATUS=./config.status} + +echo creating $CONFIG_STATUS +rm -f $CONFIG_STATUS +cat > $CONFIG_STATUS </dev/null | sed 1q`: +# +# $0 $ac_configure_args +# +# Compiler output produced by configure, useful for debugging +# configure, is in ./config.log if it exists. + +ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]" +for ac_option +do + case "\$ac_option" in + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" + exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; + -version | --version | --versio | --versi | --vers | --ver | --ve | --v) + echo "$CONFIG_STATUS generated by autoconf version 2.13" + exit 0 ;; + -help | --help | --hel | --he | --h) + echo "\$ac_cs_usage"; exit 0 ;; + *) echo "\$ac_cs_usage"; exit 1 ;; + esac +done + +ac_given_srcdir=$srcdir +ac_given_INSTALL="$INSTALL" + +trap 'rm -fr `echo "Makefile + include/Makefile + include/mdn/Makefile + lib/Makefile + dnsproxy/Makefile + man/Makefile + tools/Makefile + tools/mdnconv/Makefile + tools/runmdn/Makefile + tools/runmdn/runmdn + include/config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 +EOF +cat >> $CONFIG_STATUS < conftest.subs <<\\CEOF +$ac_vpsub +$extrasub +s%@SHELL@%$SHELL%g +s%@CFLAGS@%$CFLAGS%g +s%@CPPFLAGS@%$CPPFLAGS%g +s%@CXXFLAGS@%$CXXFLAGS%g +s%@FFLAGS@%$FFLAGS%g +s%@DEFS@%$DEFS%g +s%@LDFLAGS@%$LDFLAGS%g +s%@LIBS@%$LIBS%g +s%@exec_prefix@%$exec_prefix%g +s%@prefix@%$prefix%g +s%@program_transform_name@%$program_transform_name%g +s%@bindir@%$bindir%g +s%@sbindir@%$sbindir%g +s%@libexecdir@%$libexecdir%g +s%@datadir@%$datadir%g +s%@sysconfdir@%$sysconfdir%g +s%@sharedstatedir@%$sharedstatedir%g +s%@localstatedir@%$localstatedir%g +s%@libdir@%$libdir%g +s%@includedir@%$includedir%g +s%@oldincludedir@%$oldincludedir%g +s%@infodir@%$infodir%g +s%@mandir@%$mandir%g +s%@host@%$host%g +s%@host_alias@%$host_alias%g +s%@host_cpu@%$host_cpu%g +s%@host_vendor@%$host_vendor%g +s%@host_os@%$host_os%g +s%@ICONVLIB@%$ICONVLIB%g +s%@ICONVSOFILE@%$ICONVSOFILE%g +s%@PRELOAD_VAR@%$PRELOAD_VAR%g +s%@PRELOAD_SEP@%$PRELOAD_SEP%g +s%@PRELOAD_LAST@%$PRELOAD_LAST%g +s%@CC@%$CC%g +s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g +s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g +s%@INSTALL_DATA@%$INSTALL_DATA%g +s%@build@%$build%g +s%@build_alias@%$build_alias%g +s%@build_cpu@%$build_cpu%g +s%@build_vendor@%$build_vendor%g +s%@build_os@%$build_os%g +s%@RANLIB@%$RANLIB%g +s%@LN_S@%$LN_S%g +s%@LIBTOOL@%$LIBTOOL%g +s%@CPP@%$CPP%g + +CEOF +EOF + +cat >> $CONFIG_STATUS <<\EOF + +# Split the substitutions into bite-sized pieces for seds with +# small command number limits, like on Digital OSF/1 and HP-UX. +ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script. +ac_file=1 # Number of current file. +ac_beg=1 # First line for current file. +ac_end=$ac_max_sed_cmds # Line after last line for current file. +ac_more_lines=: +ac_sed_cmds="" +while $ac_more_lines; do + if test $ac_beg -gt 1; then + sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file + else + sed "${ac_end}q" conftest.subs > conftest.s$ac_file + fi + if test ! -s conftest.s$ac_file; then + ac_more_lines=false + rm -f conftest.s$ac_file + else + if test -z "$ac_sed_cmds"; then + ac_sed_cmds="sed -f conftest.s$ac_file" + else + ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file" + fi + ac_file=`expr $ac_file + 1` + ac_beg=$ac_end + ac_end=`expr $ac_end + $ac_max_sed_cmds` + fi +done +if test -z "$ac_sed_cmds"; then + ac_sed_cmds=cat +fi +EOF + +cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF +for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case "$ac_file" in + *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` + ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; + *) ac_file_in="${ac_file}.in" ;; + esac + + # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories. + + # Remove last slash and all that follows it. Not all systems have dirname. + ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` + if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then + # The file is in a subdirectory. + test ! -d "$ac_dir" && mkdir "$ac_dir" + ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`" + # A "../" for each directory in $ac_dir_suffix. + ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` + else + ac_dir_suffix= ac_dots= + fi + + case "$ac_given_srcdir" in + .) srcdir=. + if test -z "$ac_dots"; then top_srcdir=. + else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;; + /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;; + *) # Relative path. + srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix" + top_srcdir="$ac_dots$ac_given_srcdir" ;; + esac + + case "$ac_given_INSTALL" in + [/$]*) INSTALL="$ac_given_INSTALL" ;; + *) INSTALL="$ac_dots$ac_given_INSTALL" ;; + esac + + echo creating "$ac_file" + rm -f "$ac_file" + configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." + case "$ac_file" in + *Makefile*) ac_comsub="1i\\ +# $configure_input" ;; + *) ac_comsub= ;; + esac + + ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` + sed -e "$ac_comsub +s%@configure_input@%$configure_input%g +s%@srcdir@%$srcdir%g +s%@top_srcdir@%$top_srcdir%g +s%@INSTALL@%$INSTALL%g +" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file +fi; done +rm -f conftest.s* + +# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where +# NAME is the cpp macro being defined and VALUE is the value it is being given. +# +# ac_d sets the value in "#define NAME VALUE" lines. +ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)' +ac_dB='\([ ][ ]*\)[^ ]*%\1#\2' +ac_dC='\3' +ac_dD='%g' +# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE". +ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' +ac_uB='\([ ]\)%\1#\2define\3' +ac_uC=' ' +ac_uD='\4%g' +# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE". +ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' +ac_eB='$%\1#\2define\3' +ac_eC=' ' +ac_eD='%g' + +if test "${CONFIG_HEADERS+set}" != set; then +EOF +cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF +fi +for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case "$ac_file" in + *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` + ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; + *) ac_file_in="${ac_file}.in" ;; + esac + + echo creating $ac_file + + rm -f conftest.frag conftest.in conftest.out + ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` + cat $ac_file_inputs > conftest.in + +EOF + +# Transform confdefs.h into a sed script conftest.vals that substitutes +# the proper values into config.h.in to produce config.h. And first: +# Protect against being on the right side of a sed subst in config.status. +# Protect against being in an unquoted here document in config.status. +rm -f conftest.vals +cat > conftest.hdr <<\EOF +s/[\\&%]/\\&/g +s%[\\$`]%\\&%g +s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp +s%ac_d%ac_u%gp +s%ac_u%ac_e%gp +EOF +sed -n -f conftest.hdr confdefs.h > conftest.vals +rm -f conftest.hdr + +# This sed command replaces #undef with comments. This is necessary, for +# example, in the case of _POSIX_SOURCE, which is predefined and required +# on some systems where configure will not decide to define it. +cat >> conftest.vals <<\EOF +s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */% +EOF + +# Break up conftest.vals because some shells have a limit on +# the size of here documents, and old seds have small limits too. + +rm -f conftest.tail +while : +do + ac_lines=`grep -c . conftest.vals` + # grep -c gives empty output for an empty file on some AIX systems. + if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi + # Write a limited-size here document to conftest.frag. + echo ' cat > conftest.frag <> $CONFIG_STATUS + sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS + echo 'CEOF + sed -f conftest.frag conftest.in > conftest.out + rm -f conftest.in + mv conftest.out conftest.in +' >> $CONFIG_STATUS + sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail + rm -f conftest.vals + mv conftest.tail conftest.vals +done +rm -f conftest.vals + +cat >> $CONFIG_STATUS <<\EOF + rm -f conftest.frag conftest.h + echo "/* $ac_file. Generated automatically by configure. */" > conftest.h + cat conftest.in >> conftest.h + rm -f conftest.in + if cmp -s $ac_file conftest.h 2>/dev/null; then + echo "$ac_file is unchanged" + rm -f conftest.h + else + # Remove last slash and all that follows it. Not all systems have dirname. + ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` + if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then + # The file is in a subdirectory. + test ! -d "$ac_dir" && mkdir "$ac_dir" + fi + rm -f $ac_file + mv conftest.h $ac_file + fi +fi; done + +EOF +cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF + +exit 0 +EOF +chmod +x $CONFIG_STATUS +rm -fr confdefs* $ac_clean_files +test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1 + diff --git a/contrib/idn/mdnkit/configure.in b/contrib/idn/mdnkit/configure.in new file mode 100644 index 0000000000..362231343e --- /dev/null +++ b/contrib/idn/mdnkit/configure.in @@ -0,0 +1,274 @@ +dnl $Id: configure.in,v 1.25 2000/11/17 06:51:11 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. +dnl +dnl By using this file, you agree to the terms and conditions set forth bellow. +dnl +dnl LICENSE TERMS AND CONDITIONS +dnl +dnl The following License Terms and Conditions apply, unless a different +dnl license is obtained from Japan Network Information Center ("JPNIC"), +dnl a Japanese association, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku, +dnl Tokyo, Japan. +dnl +dnl 1. Use, Modification and Redistribution (including distribution of any +dnl modified or derived work) in source and/or binary forms is permitted +dnl under this License Terms and Conditions. +dnl +dnl 2. Redistribution of source code must retain the copyright notices as they +dnl appear in each source code file, this License Terms and Conditions. +dnl +dnl 3. Redistribution in binary form must reproduce the Copyright Notice, +dnl this License Terms and Conditions, in the documentation and/or other +dnl materials provided with the distribution. For the purposes of binary +dnl distribution the "Copyright Notice" refers to the following language: +dnl "Copyright (c) Japan Network Information Center. All rights reserved." +dnl +dnl 4. Neither the name of JPNIC may be used to endorse or promote products +dnl derived from this Software without specific prior written approval of +dnl JPNIC. +dnl +dnl 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC +dnl "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +dnl LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +dnl PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE +dnl FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +dnl CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +dnl SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +dnl BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +dnl WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +dnl OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +dnl ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +dnl +dnl 6. Indemnification by Licensee +dnl Any person or entities using and/or redistributing this Software under +dnl this License Terms and Conditions shall defend indemnify and hold +dnl harmless JPNIC from and against any and all judgements damages, +dnl expenses, settlement liabilities, cost and other liabilities of any +dnl kind as a result of use and redistribution of this Software or any +dnl claim, suite, action, litigation or proceeding by any third party +dnl arising out of or relates to this License Terms and Conditions. +dnl +dnl 7. Governing Law, Jurisdiction and Venue +dnl This License Terms and Conditions shall be governed by and and +dnl construed in accordance with the law of Japan. Any person or entities +dnl using and/or redistributing this Software under this License Terms and +dnl Conditions hereby agrees and consent to the personal and exclusive +dnl jurisdiction and venue of Tokyo District Court of Japan. + +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 +no) + ;; +yes) + AC_DEFINE(MDN_SUPPORT_ZLD) + ;; +*) + AC_MSG_ERROR([You must specify yes or no to --enable-zld option.]) + ;; +esac + +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 NAME to --with-utf8 option.]) + ;; +*) + AC_DEFINE_UNQUOTED(MDN_UTF8_ENCODING_NAME, "$utf8name") + ;; +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 +no) + ;; +yes) + AC_MSG_ERROR([You must specify SUFFIX to --with-brace-suffix option.]) + ;; +*) + AC_DEFINE_UNQUOTED(MDN_BRACE_SUFFIX, "$bracesuffix") + ;; +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 + +iconv=no +AC_ARG_WITH(iconv, +[ --with-iconv=LIB special library for iconv []], + iconv=$withval) +case "$iconv" in +no) + ICONVLIB= + ;; +yes) + AC_MSG_WARN([You must supply LIB to --with-iconv option. + -liconv is assumed.]) + ICONVLIB=-liconv + ;; +*) + ICONVLIB=$iconv + ;; +esac +AC_SUBST(ICONVLIB) + +AC_ARG_WITH(iconv-sofile, +[ --with-iconv-sofile=PATH shared library file for libiconv []], + iconv_file=$withval, iconv_file=guess) +ICONVSOFILE= +case "$iconv_file" in +no) + ICONVSOFILE=none + ;; +yes) + AC_MSG_ERROR([You must supply PATH to --with-iconv-sofile option.]) + ;; +guess) + if test "$ICONVLIB" = ""; then + ICONVSOFILE=none + else + AC_MSG_CHECKING(pathname of iconv shared library) + ic_libdir= + ic_libname= + case "$host" in + *-hpux*) + SO=sl + ;; + *) + SO=so + ;; + esac + for arg in $ICONVLIB; do + case "$arg" in + -L*) ic_libdir="$ic_libdir `echo $arg | sed s/-L//`" ;; + -l*) ic_libname=`echo $arg | sed s/-l//` ;; + /*.$SO*) ICONVSOFILE=$arg ;; + esac + done + if test "$ICONVSOFILE" = ""; then + if test "$ic_libname" = ""; then + AC_MSG_RESULT(unknown) + AC_MSG_WARN([use --with-iconv-sofile for specifying iconv shared library file]) + ICONVSOFILE=none + else + if test "$ic_libdir" = ""; then + # Standard (and semi-standard) library directories + ic_libdir="/lib /usr/lib /usr/local/lib" + fi + for dir in $ic_libdir; do + ICONVSOFILE=`ls -r $dir/lib$ic_libname.$SO* 2>/dev/null | head -1` + if test "$ICONVSOFILE" != ""; then + break + fi + done + if test "$ICONVSOFILE" != ""; then + AC_MSG_RESULT($ICONVSOFILE) + else + AC_MSG_RESULT(unknown) + AC_MSG_WARN([use --with-iconv-sofile for specifying iconv shared library file]) + ICONVSOFILE=none + fi + fi + fi + fi + ;; +*) + ICONVSOFILE=$iconv_file + ;; +esac +AC_SUBST(ICONVSOFILE) + +dnl Figure out preload stuff. +PRELOAD_VAR="LD_PRELOAD" +PRELOAD_SEP=":" +PRELOAD_LAST="" +case "$host" in +*-solaris*) + PRELOAD_SEP=" " + ;; +*-osf*) + PRELOAD_VAR="_RLD_LIST" + PRELOAD_LAST=":DEFAULT" + ;; +esac +AC_SUBST(PRELOAD_VAR) +AC_SUBST(PRELOAD_SEP) +AC_SUBST(PRELOAD_LAST) + +dnl Checks for standard tools. +AC_PROG_CC +AC_PROG_INSTALL +AM_PROG_LIBTOOL + +dnl Checks for header files. +AC_CHECK_HEADERS(unistd.h locale.h langinfo.h sys/select.h iconv.h) + +dnl Checks for data types. +AC_TYPE_UID_T +dnl for dnsproxy. +AC_CHECK_TYPE(BOOL, int) + +dnl Checks for libraries. +AC_CHECK_LIB(socket, socket) +AC_CHECK_LIB(nsl, inet_addr) + +dnl Checks for library functions. +AC_CHECK_FUNCS(vsnprintf setvbuf setlocale nl_langinfo memmove bcopy) + +dnl Output. +AC_CONFIG_HEADER(include/config.h) +AC_OUTPUT( + Makefile + include/Makefile + include/mdn/Makefile + lib/Makefile + dnsproxy/Makefile + man/Makefile + tools/Makefile + tools/mdnconv/Makefile + tools/runmdn/Makefile + tools/runmdn/runmdn +) diff --git a/contrib/idn/mdnkit/dnsproxy/Makefile.in b/contrib/idn/mdnkit/dnsproxy/Makefile.in new file mode 100644 index 0000000000..c95879eb97 --- /dev/null +++ b/contrib/idn/mdnkit/dnsproxy/Makefile.in @@ -0,0 +1,158 @@ +# $Id: Makefile.in,v 1.18 2000/11/17 07:36:37 ishisone Exp $ +# Makefile for mDNS Proxy Server +# +# 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@ + +SBINDIR = @sbindir@ +ETCDIR = @sysconfdir@ +CONFIG_PATH = $(ETCDIR) +MANDIR = @mandir@ + +CC = @CC@ +PURIFY = purify +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +SHELL = @SHELL@ +LIBTOOL = @LIBTOOL@ + +OPTS = +INCS = -I$(srcdir)/../include -I../include +DEFS = -DUNIX -DCONFIG_PATH="\"$(CONFIG_PATH)/\"" +CFLAGS = $(OPTS) $(INCS) $(DEFS) @CFLAGS@ +LDFLAGS = $(OPTS) @LDFLAGS@ + +LIBS = ../lib/libmdn.la +SYSLIBS = @LIBS@ @ICONVLIB@ + +# +# 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 + +# +# Target to build +# + +TARGETS = dnsproxy dnsproxy.8 + +all : $(TARGETS) + +dnsproxy : $(OBJS) $(LIBS) + $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ \ + $(OBJS) $(LIBS) $(SYSLIBS) + +dnsproxy.purify : $(OBJS) $(LIBS) + $(LIBTOOL) --mode=link $(PURIFY) $(CC) $(LDFLAGS) -o $@ \ + $(OBJS) $(LIBS) $(SYSLIBS) + +# +# Installation +# + +install: install-program install-config install-man + +install-program: dnsproxy + [ -d $(SBINDIR) ] || mkdir $(SBINDIR) + $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) dnsproxy $(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 > $@ + +clean: + rm -f $(TARGETS) *.o core *.core *~ + +# +# 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 diff --git a/contrib/idn/mdnkit/dnsproxy/dnsproxy.8.in b/contrib/idn/mdnkit/dnsproxy/dnsproxy.8.in new file mode 100644 index 0000000000..0606b7a68e --- /dev/null +++ b/contrib/idn/mdnkit/dnsproxy/dnsproxy.8.in @@ -0,0 +1,282 @@ +.\" $Id: dnsproxy.8.in,v 1.10 2000/11/17 07:36:37 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 DNSPROXY 8 +.SH NAME +dnsproxy \- DNS proxy server for multi-lingual DNS + +.SH SYNOPSIS +.B dnsproxy +[ \-daemon ] [ \-config ] [ \-logfile ] + +.SH DESCRIPTION +.B dnsproxy +resides between application (resolver) and DNS server. +.PP +It accepts DNS requests from application (resolver) and converting +domain names in those requests into DNS server's acceptable encoding, +and forward those converted requests. It also accepts responses from +DNS server and converting domain names in those resopnses into +application's acceptable encoding and forward those responses to +applications. + +.SH OPTIONS +.TP +.B \-daemon +Run dnsproxy as daemon. Otherwise, dnsproxy will run as normal +console program. +.TP +.B \-config +Specifies configuration file (see later). If not specified, +dnsproxy uses default configuration file. +See +.B FILES +section for default configuration file. +.TP +.B \-logfile +Specifies logging file. If not specified. +dnsproxy uses default logging file. +See +.B FILES +section for default configuration file. + +.SH CONFIGURATION +Configuration file is simple text file which defines several +configuration data. +.IP "listen
" +.RS +Defines listening port (both TCP and UDP).
is one of +.RS +.PP +: +.br +: +.br + +.PP +.RE +If omitted, dnsproxy uses default value shown below. +.RS +.PP +IP Address INADDR_ANY (0.0.0.0) +.br +port number 53 +.PP +.RE +.RE +.IP "forward
[ bind4compat ]" +.RS +Defines forwarding server's address. Format is same as 'listen'. +.PP +example: +.RS +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 +port > 1024 as forwading UDP's source. +.RE +.IP "log-file " +.RS +Defines log file name. It may be overridden with command line +option '-logfile '. 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 " +.RS +Defines client side character encoding scheme. Some clients +locally encode domain name and add (Zero Level Domain) to +it. In those cases, use 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. +.PP +example: +.RS +.nf +client-translation .i-dns.net UTF-5 # accept ZLDs +client-translation . Shift_JIS +.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 " +.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 ..." +.RS +Defines domain name normalization schemes. You can specify +several normalizations and they are applied left to right. +.PP +example: +.RS +normalize ja-fullwidth unicode-form-c +.RE +.PP +Acceptable normalizations depend on 'libmdn' library. Check +documents for 'libmdn' for more detail. +.RE +.IP "server-translation " +.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. +.PP +example: +.RS +server-translation . UTF-8 +.RE +.RE +.IP "user-id " +.RS +Defines a user ID in which dnsproxy operates. +Dnsproxy tries to change the user ID of its process to the specified one, +soon after initialization. +.PP +example: +.RS +.nf +user-id\ \ nobody +user-id\ \ 9999 +.fi +.RE +.PP +It is strongly recommended to use this option for security reasons. +.RE +.IP "group-id " +.RS +Defines a group ID in which dnsproxy operates. +Dnsproxy tries to change the group ID of its process to the specified one, +soon after initialization. +.PP +example: +.RS +.nf +group-id\ \ nobody +group-id\ \ 9999 +.fi +.RE +.RE +.IP "root-directory " +.RS +Defines the pathname of the root directory for the dnsproxy 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 +.fi +.RE +.RE +.IP "log-level " +.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. +.RE + +.SH NOTES +Some applications locally mangles domain names. In those cases, +dnsproxy cannot works correctly. +.PP +For 'nslookup', it generally reject non-ascii domain names. +You need 8bit through patched version of nslookup. +.PP +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" +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. + +.SH FILES +.PD 0 +.TP 30 +.B @ETCDIR@/dnsproxy.conf +Default configuration file. +.TP +.B /tmp/dnsproxy.log +Default logging file. +.PD + +.SH SLL ALSO +.BR named(8), +.BR libmdn(3), +.BR iconv(3) diff --git a/contrib/idn/mdnkit/dnsproxy/dnsproxy.conf.sample b/contrib/idn/mdnkit/dnsproxy/dnsproxy.conf.sample new file mode 100755 index 0000000000..4425d72a51 --- /dev/null +++ b/contrib/idn/mdnkit/dnsproxy/dnsproxy.conf.sample @@ -0,0 +1,170 @@ +# $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 [][:] +# +# 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 [:] [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 +# +# 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 +# +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 ... +# +# 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 +# +# 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 +# +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 +# group-id +# +# 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 +# +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 +# +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 +# +# mdn-log-level 1 diff --git a/contrib/idn/mdnkit/dnsproxy/dnsproxy.def b/contrib/idn/mdnkit/dnsproxy/dnsproxy.def new file mode 100644 index 0000000000..abdcb93e38 --- /dev/null +++ b/contrib/idn/mdnkit/dnsproxy/dnsproxy.def @@ -0,0 +1,3 @@ +NAME dnsproxy WINDOWCOMPAT NEWFILES +EXETYPE OS2 +STACKSIZE 32768 diff --git a/contrib/idn/mdnkit/dnsproxy/dnsproxy.h b/contrib/idn/mdnkit/dnsproxy/dnsproxy.h new file mode 100644 index 0000000000..8b0500edaf --- /dev/null +++ b/contrib/idn/mdnkit/dnsproxy/dnsproxy.h @@ -0,0 +1,192 @@ +/* + * dnsproxy.h - mDNS Proxy, Common Definitions + */ + +/* + * 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. + */ + +/* $Id: dnsproxy.h,v 1.13 2000/11/17 05:57:56 ishisone Exp $ */ + +#ifndef DNSPROXY_H +#define DNSPROXY_H 1 + +#include + +#ifdef WIN32 +#include +#include +#else /* for normal systems */ +#include +#include +#endif + +/* + * Redefine TRUE and FALSE. + */ +#undef TRUE +#undef FALSE +#define TRUE 1 +#define FALSE 0 + +/* + * Macro for Error Logging + */ + +enum { + LOGLEVEL_NONE = 0, + LOGLEVEL_FATAL = 1, + LOGLEVEL_WARN = 2, + LOGLEVEL_TRACE = 3 +}; + +void log_configure(int ac, char *av[]) ; +void log_terminate(void) ; +void log_turnover_request(void) ; +void log_turnover(void) ; +void log_setlevel(int level) ; +int log_strtolevel(char *s) ; +void log_fatal_printf(char *fmt, ...) ; +void log_warn_printf(char *fmt, ...) ; +void log_trace_printf(char *fmt, ...) ; + +#define TRACE log_trace_printf +#define WARN log_warn_printf +#define FATAL log_fatal_printf + +/* + * Server's Control Entries + */ + +BOOL server_init(int ac, char *av[]) ; +void server_stop(void) ; +void server_loop(void) ; +void server_done(void) ; + +/* + * Server calls following callback when received message + */ + +void notify_message(struct sockaddr *from, int proto, + u_char *msg, int len) ; + +void notify_timer(void) ; + +/* + * To send messages, call following entires in server module + */ + +void server_forward(struct sockaddr *to, int proto, + u_char *msg, int len) ; +void server_response(struct sockaddr *to, int proto, + u_char *msg, int len) ; + +/* + * load/dump/dispose configuration data + */ + +BOOL config_load(int ac, char *av[]) ; +void config_free(void) ; +void config_dump(FILE *ofp) ; + +/* + * query configuration data + */ + +BOOL config_query_value(char *key, int *count, char ***array) ; +BOOL config_query_listen(struct sockaddr *addr) ; +BOOL config_query_forward(struct sockaddr *addr) ; +BOOL config_query_restrict(BOOL *restrict) ; + +/* + * Message (domain name) translation + */ + +typedef struct translation_context { + struct sockaddr *client; /* address family/IP address/port */ + 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) ; +int translate_request(translation_context_t *ctx, + const char *msg, size_t msglen, + char *translated, size_t bufsize, size_t *translatedlenp) ; +int translate_reply(translation_context_t *ctx, + const char *msg, size_t msglen, + char *translated, size_t bufsize, size_t *translatedlenp) ; + +/* + * query configuration having multiple entries (with same key) + * + * ctx = config_query_open(key, ...) ; + * while (ctx != NULL) { + * ctx = config_query_more(ctx, ...) ; + * } + * config_query_close(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) ; +void config_query_close(config_ctx_t ctx) ; + +#endif /* DNSPROXY_H */ diff --git a/contrib/idn/mdnkit/dnsproxy/logging.c b/contrib/idn/mdnkit/dnsproxy/logging.c new file mode 100644 index 0000000000..78c6137dda --- /dev/null +++ b/contrib/idn/mdnkit/dnsproxy/logging.c @@ -0,0 +1,294 @@ +/* + * 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 + +#include +#include +#include +#include +#include + +#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/make.os2 b/contrib/idn/mdnkit/dnsproxy/make.os2 new file mode 100644 index 0000000000..79d659e209 --- /dev/null +++ b/contrib/idn/mdnkit/dnsproxy/make.os2 @@ -0,0 +1,113 @@ +# +# Makefile for mDNS Proxy Server, OS2 version (for EMX/GCC) +# +# $Id: make.os2,v 1.1 2000/12/07 00:52:19 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. +# + +ICONVDIR = ../os2 +MDNDIR = ../lib +BINDIR = ../../bin/os2 + +CC = gcc -c +CFLAGS = -Wall -Zmtd -I../include -I$(ICONVDIR) -DOS2 -DHAVE_UNISTD_H -DDEBUG +LD = gcc +LDFLAGS = -Zmtd + +LIBS = $(MDNDIR)/libmdn.a $(ICONVDIR)/iconv.a +SYSLIBS = -lsocket + +# +# Files to build mDNS Proxy +# + +SRCS = os2main.c server.c message.c translate.c logging.c proxycnf.c +OBJS = os2main.o server.o message.o translate.o logging.o proxycnf.o + +# +# Target to build +# + +TARGETS = dnsproxy.exe $(ICONVDIR)/iconv.dll + +all : $(TARGETS) + +install : $(TARGETS) + cp -p $(TARGETS) $(BINDIR) + +dnsproxy.exe : $(OBJS) $(LIBS) dnsproxy.def + $(LD) $(LDFLAGS) -o dnsproxy.exe dnsproxy.def $(OBJS) $(LIBS) $(SYSLIBS) + +# +# Dependecnies +# + +.c.o : + $(CC) $(CFLAGS) $*.c + +os2main.o : os2main.c dnsproxy.h + +server.o : server.c dnsproxy.h + +message.o : message.c dnsproxy.h + +traslate.o : translate.c dnsproxy.h + +logging.o : logging.c dnsproxy.h + +proxycnf.o : proxycnf.c dnsproxy.h proxycnf.h diff --git a/contrib/idn/mdnkit/dnsproxy/make.wnt b/contrib/idn/mdnkit/dnsproxy/make.wnt new file mode 100644 index 0000000000..86bd2cd4a0 --- /dev/null +++ b/contrib/idn/mdnkit/dnsproxy/make.wnt @@ -0,0 +1,125 @@ +# +# Makefile for mDNS Proxy Server, WINNT version +# +# $Id: make.wnt,v 1.1 2000/12/07 00:52:19 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 + +ICONVDIR = ..\win +MDNDIR = ..\lib +BINDIR = ..\..\bin\win + +INCDIR = ..\include +LIBS = $(MDNDIR)\libmdn.lib $(ICONVDIR)\iconv.lib +SYSLIBS = $(conlibsdll) + +# +# Files to build mDNS Proxy +# + +HDRS = dnsproxy.h winserv.h + +SRCS = winmain.c winserv.c server.c message.c translate.c \ + logging.c proxycnf.c +OBJS = winmain.obj winserv.obj server.obj message.obj translate.obj \ + logging.obj proxycnf.obj + +# +# Target to build +# + +TARGETS = dnsproxy.exe $(ICONVDIR)\iconv.dll + +all : $(TARGETS) + +install : $(TARGETS) + copy dnsproxy.exe $(BINDIR) + copy $(ICONVDIR)\iconv.dll $(BINDIR) + +dnsproxy.exe : $(OBJS) $(LIBS) + $(link) $(conflags) -out:dnsproxy.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 diff --git a/contrib/idn/mdnkit/dnsproxy/message.c b/contrib/idn/mdnkit/dnsproxy/message.c new file mode 100644 index 0000000000..ab83c9e9ca --- /dev/null +++ b/contrib/idn/mdnkit/dnsproxy/message.c @@ -0,0 +1,627 @@ +/* + * message.c - mDNS Proxy, message handling + * + * message will passed with callback 'notify_message'. + * this module parse received message and forward request, + * or reply to originator + */ + +/* + * 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: message.c,v 1.18 2000/11/17 05:46:23 ishisone Exp $"; +#endif + +#include + +#include +#include +#include +#include + +#ifdef WIN32 +#include +#include +#else /* for normal systems */ +#include +#include +#include +#include +#endif + +#include "dnsproxy.h" + +/* + * address handling utilities + * + * addrEq check same addresses + * addrFmt format address, port & protocol + * + * these functions are same with those in 'server.c'. + * may be put in another 'utility' module. + */ + +static BOOL addrEq(struct sockaddr *a1, struct sockaddr *a2) +{ + struct sockaddr_in *ip1 = (struct sockaddr_in *) a1 ; + struct sockaddr_in *ip2 = (struct sockaddr_in *) a2 ; + + if (ip1->sin_addr.s_addr != ip2->sin_addr.s_addr) { + return FALSE ; + } + if (ip1->sin_port != ip2->sin_port) { + return FALSE ; + } + return TRUE ; +} + +static u_char fmtbuff[64] ; + +static u_char *addrFmt(struct sockaddr *addr, int proto) +{ + struct sockaddr_in *iaddr = (struct sockaddr_in *) addr ; + u_char *ap ; + u_char *pp ; + + ap = (u_char *) &iaddr->sin_addr ; + pp = (u_char *) &iaddr->sin_port ; + + sprintf(fmtbuff, "%s:%d.%d.%d.%d:%d", + (proto == SOCK_STREAM ? "TCP" : "UDP"), + (ap[0] & 0xff), (ap[1] & 0xff), (ap[2] & 0xff), (ap[3] & 0xff), + ((pp[0] & 0xff) * 256 + (pp[1] & 0xff)) ) ; + + return fmtbuff ; +} + +/* + * Managing Message ID + */ + +static u_short msgidLast = 0xffff ; +static u_short msgidMap[4096] = { 0 } ; + +#define ID_INDEX(x) (((x) & 0xfff0) >> 4) +#define ID_MASK(x) (1 << ((x) & 0x000f)) + +#define ID_CHECK(x) (msgidMap[ID_INDEX((x))] & ID_MASK((x))) +#define ID_USEIT(x) (msgidMap[ID_INDEX((x))] |= ID_MASK((x))) +#define ID_CLEAR(x) (msgidMap[ID_INDEX((x))] &= ~ID_MASK((x))) + +static BOOL idAlloc(u_short *id) +{ + u_short newid ; + + for (newid = (msgidLast + 1) & 0xffff ; + newid != msgidLast ; + newid = (newid + 1) & 0xffff) { + if (ID_CHECK(newid) == 0) { + ID_USEIT(newid) ; + msgidLast = newid ; + *id = newid ; + return TRUE ; + } + } + WARN("idAlloc - no more ID\n") ; + return FALSE ; +} + +static void idFree(u_short id) +{ + if (ID_CHECK(id) == 0) { + WARN("idAlloc - %04x is not in use\n", id) ; + return ; + } + ID_CLEAR(id) ; +} + +/* + * Message Managements + * + * Request from client is identified with its ID word. It is unique + * on one client, but proxy accepts requests from multiple clients, + * proxy cannot distinguish request with ID only, and cannot forward + * request with such ID word. + * + * So, proxy will identify requests with combination of address, port, + * (which identified client) and ID word. Then forwarding request, + * proxy allocate unique ID, and change request's ID with new one. + * + * Response from DNS server will identified with newly allocated ID. + * For responding such response to originator, replace response's + * ID with original one, and send response to marked address/port. + */ + +typedef struct _MSG *MSGPTR ; + +typedef struct _MSG { + MSGPTR prev ; + MSGPTR next ; + time_t last ; + struct sockaddr from ; + int proto ; + u_short orgId ; + u_short newId ; + translation_context_t trctx ; +} MSGREC ; + +static MSGREC listMsg = { 0 } ; + +/* + * searchReq - search request in message list, search on original ID + */ + +static MSGPTR searchReq(u_short id, int proto, struct sockaddr *addr) +{ + MSGPTR p ; + + if (listMsg.prev == NULL || listMsg.next == NULL) { + listMsg.prev = &listMsg ; + listMsg.next = &listMsg ; + } + for (p = listMsg.next ; p != &listMsg ; p = p->next) { + if (p->orgId != id || p->proto != proto) { + continue ; + } + if (addrEq(&p->from, addr) != TRUE) { + continue ; + } + p->last = time(NULL) ; + return p ; + } + return NULL ; +} + +/* + * searchOrg - search original request matching to new ID + */ + +static MSGPTR searchOrg(u_short id, int proto) +{ + MSGPTR p ; + + if (listMsg.prev == NULL || listMsg.next == NULL) { + listMsg.prev = &listMsg ; + listMsg.next = &listMsg ; + } + for (p = listMsg.next ; p != &listMsg ; p = p->next) { + if (p->newId != id || p->proto != proto) { + continue ; + } + p->last = time(NULL) ; + return p ; + } + return NULL ; +} + +/* + * createReq - create new message record for new request + * + * it also allocate new ID for this request, used for + * forwarding this request + */ + +static MSGPTR createReq(u_short id, int proto, struct sockaddr *addr) +{ + u_short newid ; + MSGPTR pMsg, prev, next ; + + if (listMsg.prev == NULL || listMsg.next == NULL) { + listMsg.prev = &listMsg ; + listMsg.next = &listMsg ; + } + + if (idAlloc(&newid) != TRUE) { + WARN("createReq - no more ID\n") ; + return NULL ; + } + if ((pMsg = (MSGPTR) malloc(sizeof(MSGREC))) == NULL) { + WARN("createReq - cannot allocate message record\n") ; + idFree(newid) ; + return NULL ; + } + + memset(pMsg, 0, sizeof(MSGREC)) ; + + memcpy(&pMsg->from, addr, sizeof(struct sockaddr)) ; + pMsg->proto = proto ; + pMsg->orgId = id ; + pMsg->newId = newid ; + pMsg->last = time(NULL) ; + + pMsg->trctx.client = &pMsg->from ; + pMsg->trctx.protocol = pMsg->proto ; + pMsg->trctx.old_id = pMsg->orgId ; + pMsg->trctx.new_id = pMsg->newId ; + + prev = listMsg.prev ; + next = prev->next ; + + prev->next = pMsg ; + next->prev = pMsg ; + pMsg->prev = prev ; + pMsg->next = next ; + + return pMsg ; +} + +/* + * disposeReq - dispose message record + */ + +static void disposeReq(MSGPTR pMsg) +{ + MSGPTR p ; + + if (listMsg.prev == NULL || listMsg.next == NULL) { + listMsg.prev = &listMsg ; + listMsg.next = &listMsg ; + } + + for (p = listMsg.next ; p != &listMsg ; p = p->next) { + if (p == pMsg) { + break ; + } + } + if (p == pMsg) { /* safe to unlink it */ + pMsg->prev->next = pMsg->next ; + pMsg->next->prev = pMsg->prev ; + } + idFree(pMsg->newId) ; + free(pMsg) ; +} + +/* + * messageForward - forward the request + */ + +static void errorOnRequest(MSGPTR pMsg, u_char *msg, int len, size_t err) +{ + u_short errmsg[6] ; + u_short flags ; + u_short *ps ; + + TRACE("errorOnRequest %d\n", err) ; + + ps = (u_short *) msg ; + flags = ntohs(ps[1]) ; + flags = ((flags & 0x7fff) | 0x8000) ; /* QR to response */ + flags = ((flags & 0xfff8) | (err & 0x0007)) ; /* set RCODE */ + + memset(errmsg, 0, sizeof(errmsg)) ; + errmsg[0] = htons(pMsg->orgId) ; + errmsg[1] = htons(flags) ; + + server_response(&pMsg->from, pMsg->proto, (u_char *) errmsg, sizeof(errmsg)) ; +} + +static void messageForward(MSGPTR pMsg, u_char *msg, int len) +{ + u_short *p ; + u_char buff[1024] ; + u_char *bbase ; + size_t bleng ; + size_t cleng = 0 ; /* avoid un-expected length on xlate error */ + size_t cstat = 0 ; /* avoid un-expected status on xlate error */ + + TRACE("messageForward - %04x -> %04x\n", pMsg->orgId, pMsg->newId) ; + + /* + * prepare conversion buffer + */ + + if (len < sizeof(buff) / 2) { + bbase = buff ; + bleng = sizeof(buff) ; + } else { + bbase = malloc(len * 2) ; + bleng = len * 2 ; + } + if (bbase == NULL) { + WARN("messageForward - cannot prepare conversion buffer\n") ; + return ; + } + + /* + * translate message (domain names) + */ + + TRACE("messageForward - translate request\n") ; + + cstat = translate_request(&pMsg->trctx, msg, len, bbase, bleng, &cleng) ; + + TRACE("messageForward - translated status %d length %d\n", cstat, cleng) ; + + if (cstat != 0) { /* error on conversion */ + WARN("messageForward - translation error %d\n", cstat) ; + errorOnRequest(pMsg, msg, len, cstat) ; + return ; + } + if (pMsg->proto == SOCK_DGRAM && cleng > 512) { + WARN("messageForward - translation overflow %d\n", cleng) ; + errorOnRequest(pMsg, msg, len, 2) ; + return ; + } + + /* + * forward the request + */ + + p = (u_short *) bbase ; + p[0] = htons(pMsg->newId) ; + + server_forward(NULL, pMsg->proto, bbase, cleng) ; + + /* + * cleanup buffer + */ + + if (bbase != buff) { + free(bbase) ; + } +} + +/* + * messageResponse - response to originating client + */ + +static void errorOnResponse(MSGPTR pMsg, u_char *msg, int len, size_t err) +{ + u_short errmsg[6] ; + u_short flags ; + u_short *ps ; + + TRACE("errorOnResponse %d\n", err) ; + + ps = (u_short *) msg ; + flags = ntohs(ps[1]) ; + flags = ((flags & 0x7fff) | 0x8000) ; /* QR to response */ + flags = ((flags & 0xfff8) | (err & 0x0007)) ; /* set RCODE */ + + memset(errmsg, 0, sizeof(errmsg)) ; + errmsg[0] = htons(pMsg->orgId) ; + errmsg[1] = htons(flags) ; + + server_response(&pMsg->from, pMsg->proto, (u_char *) errmsg, sizeof(errmsg)) ; +} + +static void messageResponse(MSGPTR pMsg, u_char *msg, int len) +{ + u_short *p ; + u_char buff[1024] ; + u_char *bbase ; + size_t bleng ; + size_t cleng ; + size_t cstat ; + + TRACE("messageResponse - %04x <- %04x\n", pMsg->orgId, pMsg->newId) ; + + /* + * prepare conversion buffer + */ + + if (len < sizeof(buff) / 2) { + bbase = buff ; + bleng = sizeof(buff) ; + } else { + bbase = malloc(len * 2) ; + bleng = len * 2 ; + } + if (bbase == NULL) { + WARN("messageResponse - cannot prepare conversion buffer\n") ; + return ; + } + + /* + * translate message (domain names) + */ + + TRACE("messageResponse - translate response\n") ; + + cstat = translate_reply(&pMsg->trctx, msg, len, bbase, bleng, &cleng) ; + + TRACE("messageResponse - translated status %d length %d\n", cstat, cleng) ; + + if (cstat != 0) { /* error on conversion */ + WARN("messageResponse - translation error %d\n", cstat) ; + errorOnResponse(pMsg, msg, len, cstat) ; + return ; + } + if (pMsg->proto == SOCK_DGRAM && cleng > 512) { + WARN("messageResponse - translation overflow %d\n", cleng) ; + errorOnResponse(pMsg, msg, len, 2) ; + return ; + } + + /* + * reply back to requester + */ + + p = (u_short *) bbase ; + p[0] = htons(pMsg->orgId) ; + + server_response(&pMsg->from, pMsg->proto, bbase, cleng) ; + + /* + * cleanup buffer + */ + + if (bbase != buff) { + free(bbase) ; + } +} + +/* + * notify_message - callback from server loop + */ + +void notify_message(struct sockaddr *from, int proto, u_char *msg, int len) +{ + u_short *p = (u_short *) msg ; + u_short msgid, flags ; + MSGPTR pMsg ; +#ifdef DEBUG + char logbuf[256] ; +#endif + + msgid = ntohs(p[0]) ; + flags = ntohs(p[1]) ; + +#ifdef DEBUG + if ((flags & 0x8000) == 0) { + sprintf(logbuf, "Request %04x (%04x) from %s, %d bytes", + msgid, flags, addrFmt(from, proto), len) ; + } else { + sprintf(logbuf, "Response %04x (%04x) from %s %d bytes", + msgid, flags, addrFmt(from, proto), len) ; + } + TRACE("%s\n", logbuf) ; + + strcpy(logbuf, " ") ; + + switch ((flags & 0x7800) >> 11) { + case 0 : strcat(logbuf, "QUERY ") ; break ; + case 1 : strcat(logbuf, "IQUERY ") ; break ; + case 2 : strcat(logbuf, "STATUS ") ; break ; + default : strcat(logbuf, "UNKNOWN") ; break ; + } + if ((flags & 0x0400) != 0) { + strcat(logbuf, ",AA") ; + } + if ((flags & 0x0200) != 0) { + strcat(logbuf, ",TC") ; + } + if ((flags & 0x0100) != 0) { + strcat(logbuf, ",RD") ; + } + if ((flags & 0x0080) != 0) { + strcat(logbuf, ",RA") ; + } + switch (flags & 0x00f) { + case 0 : strcat(logbuf, ",No Error ") ; break ; + case 1 : strcat(logbuf, ",Format Error ") ; break ; + case 2 : strcat(logbuf, ",Server Failure ") ; break ; + case 3 : strcat(logbuf, ",Name Error ") ; break ; + case 4 : strcat(logbuf, ",Not Implemented") ; break ; + case 5 : strcat(logbuf, ",Refused ") ; break ; + default : strcat(logbuf, ",Unknown Error ") ; break ; + } + TRACE("%s\n", logbuf) ; +#endif + + if ((flags & 0x8000) == 0) { /* request from client */ + + if ((pMsg = searchReq(msgid, proto, from)) == NULL) { + pMsg = createReq(msgid, proto, from) ; + } + if (pMsg == NULL) { + WARN("notify_message - cannot create message record\n") ; + return ; + } + messageForward(pMsg, msg, len) ; + + } else { /* response from server */ + + if ((pMsg = searchOrg(msgid, proto)) == NULL) { + WARN("notify_message - no corresponding request\n") ; + return ; + } + messageResponse(pMsg, msg, len) ; + disposeReq(pMsg); + } +} + +/* + * notify_timer - timer callback + */ + +static time_t timeLastCheck = 0 ; +static time_t timeInterval = 60 ; +static time_t timeTimeout = (60 * 10) ; + +void notify_timer(void) +{ + time_t t = time(NULL) ; + MSGPTR p, np ; +#ifdef DEBUG + int ndiscarded = 0; +#endif + + if (listMsg.prev == NULL || listMsg.next == NULL) { + listMsg.prev = &listMsg ; + listMsg.next = &listMsg ; + } + + if ((t - timeLastCheck) < timeInterval) { + return ; + } + for (p = listMsg.next ; p != &listMsg ; p = np) { + np = p->next ; + if ((t - p->last) > timeTimeout) { + disposeReq(p) ; +#ifdef DEBUG + ndiscarded++; +#endif + } + } +#ifdef DEBUG + TRACE("notify_timer: %d discarded\n", ndiscarded); +#endif + timeLastCheck = t; +} diff --git a/contrib/idn/mdnkit/dnsproxy/os2main.c b/contrib/idn/mdnkit/dnsproxy/os2main.c new file mode 100644 index 0000000000..93a8fda53f --- /dev/null +++ b/contrib/idn/mdnkit/dnsproxy/os2main.c @@ -0,0 +1,138 @@ +/* + * os2main.c - mDNS Proxy, entry for OS2 + * + * For OS/2, there are no daemon, nor service. Simply + * start server program with + * + * RUN in config.sys + * START in startup.cmd + * put server program (object) into startup folder + */ + +/* + * 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: os2main.c,v 1.12 2000/07/04 03:52:28 ishisone Exp $"; +#endif + +#ifdef OS2 + +#include +#include +#include +#include + +#include "dnsproxy.h" /* Common definitions for mDNS proxy */ + +/* + * signal handler to catch signal to terminate server + */ + +static void handler(int signo) +{ + server_stop() ; + signal(signo, SIG_DFL) ; +} + +/* + * main - entry of os2 version + */ + +int main(int ac, char *av[]) +{ + if (config_load(ac, av) != TRUE) { + printf("cannot load configurations\n") ; + return 1 ; + } + log_configure(ac, av) ; + + if (server_init(ac, av) != TRUE) { + printf("cannot initialize server\n") ; + log_terminate() ; + return 1 ; + } + + signal(SIGINT, handler) ; + signal(SIGKILL, handler) ; + signal(SIGTERM, handler) ; + signal(SIGBREAK, handler) ; + +#ifdef DEBUG + printf("Service Started\n") ; +#endif + + server_loop() ; + +#ifdef DEBUG + printf("Service Termiating...\n") ; +#endif + + server_done() ; + + log_terminate() ; + +#ifdef DEBUG + printf("Service Terminated\n") ; +#endif + + return 0 ; +} + +#endif /* OS2 */ + diff --git a/contrib/idn/mdnkit/dnsproxy/proxycnf.c b/contrib/idn/mdnkit/dnsproxy/proxycnf.c new file mode 100644 index 0000000000..da5bd140ef --- /dev/null +++ b/contrib/idn/mdnkit/dnsproxy/proxycnf.c @@ -0,0 +1,776 @@ +/* + * proxycnf.c - mDNS Proxy, configuration + */ + +/* + * 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: proxycnf.c,v 1.16 2000/11/17 05:46:23 ishisone Exp $"; +#endif + +#include + +#include +#include +#include +#include + +#ifdef WIN32 +#include +#include +#else /* for normal systems */ +#include +#include +#include +#include +#endif + +#include "dnsproxy.h" /* Common definitions for mDNS proxy */ +#include "proxycnf.h" /* Machine/Env specific configuration */ + +/* + * Note that logging macros (FATAL, WARN and TRACE) cannot be used + * until logging file is configured, i.e. log_configure() is called. + * Be careful. + */ + +/* + * default config file (path & basename), depend on MACHINE + */ + +#ifndef CONFIG_PATH +#warning "no \"CONFIG_PATH\", use "\"./\" as default" +#define CONFIG_PATH "./" +#endif +#ifndef CONFIG_FILE +#warning "no \"CONFIG_FILE\", use "dnsproxy.ini" as default" +#define CONFIG_FILE "dnsproxy.ini" +#endif +#ifndef CONFIG_HOME +#warning "no \"CONFIG_HOME\", use "\"./\" as default" +#define CONFIG_HOME "./" +#endif + +static u_char *confFile = CONFIG_FILE ; + +static u_char *confPath[] = { +#ifdef DEBUG + "./", + CONFIG_HOME, +#endif + CONFIG_PATH, + NULL +} ; + +static u_char *expandName(u_char *name, u_char *buff) +{ + int inEnv = FALSE ; + u_char *bp, *ep ; + u_char env[512] ; + + for (bp = buff, ep = env ; *name != '\0' ; name++) { + if (inEnv == FALSE) { + if (*name == '$') { + inEnv = TRUE ; + ep = env ; + } else { + *bp++ = *name ; + *bp = '\0' ; + } + } else { + if (*name == '(') { + /* skip this */ + } else if (*name != ')') { + *ep++ = *name ; + *ep = '\0' ; + } else if ((ep = getenv(env)) == NULL) { + return NULL ; + } else { + while (*ep != '\0') { + *bp++ = *ep++ ; + } + *bp = '\0' ; + inEnv = FALSE ; + } + } + } + return buff ; +} + +static FILE *openConfig(u_char *fname) +{ + int i ; + FILE *fp = NULL ; + u_char path[512] ; + u_char name[512] ; + + /* + * if coinfiguration file specified, open it + */ + + if (fname != NULL) { + if (expandName(fname, name) == NULL) { + return NULL ; + } + if ((fp = fopen(name, "r")) == NULL) { + return NULL ; + } + return fp ; + } + + /* + * otherwise, look for configuration file in search path + */ + + for (i = 0 ; confPath[i] != NULL ; i++) { + + if (expandName(confPath[i], path) == NULL) { + continue ; + } + + sprintf(name, "%s%s", path, confFile) ; + + if ((fp = fopen(name, "r")) != NULL) { + return fp ; + } + } + return NULL ; +} + +/* + * configuration data in file consists of + * + * key value ... + * + * lines. This module hold them as following list. + */ + +typedef struct _CONF *CNFPTR ; + +typedef struct _CONF { + CNFPTR prev ; + CNFPTR next ; + u_char *key ; /* really, buffer for key & val */ + int nVal ; + u_char *aVal[1] ; /* really, follows 'nVal' entries */ +} CNFREC ; + +static CNFREC confList = { 0 } ; + +static void disposeData(void) +{ + CNFPTR p ; + + if (confList.prev == NULL || confList.next == NULL) { + return ; + } + while ((p = confList.next) != &confList) { + confList.next = p->next ; + free(p->key) ; + free(p) ; + } +} + +static u_char *getString(u_char *p, CNFPTR pCnf) +{ + /* + * mark start of value string + */ + + pCnf->aVal[pCnf->nVal++] = p ; + + /* + * look for end of string, any space + */ + + for ( ; *p != '\0' ; p++) { + if (isspace(*p)) { + break ; + } + } + if (*p != '\0') { + *p++ = '\0' ; + } + return p ; +} + +static u_char *getQuoted(u_char *p, CNFPTR pCnf) +{ + if (*p != '"') { /* Oh, something wrong !! */ + return p ; + } + p++ ; /* skip leading '"' */ + + /* + * mark start of value string + */ + + pCnf->aVal[pCnf->nVal++] = p ; + + /* + * look for terminating '"', may be escaped with '\' + */ + + while (*p != '\0' && *p != '\n' && *p != '\r') { + if (*p == '"') { + break ; + } else if (*p == '\\') { /* quoted pair */ + p += 2 ; + } else { + p += 1 ; + } + } + if (*p != '\0') { + *p++ = '\0' ; + } + return p ; +} + +static BOOL appendData(u_char *line) +{ + int len ; + u_char *pStr, *p ; + CNFPTR pCnf, pNew ; + CNFPTR prev, next ; + + /* + * list is not initialized, initialize it + */ + + if (confList.prev == NULL || confList.next == NULL) { + confList.prev = &confList ; + confList.next = &confList ; + } + + /* + * prepare buffers + */ + + len = strlen(line) ; + + pCnf = (CNFPTR) malloc(sizeof(CNFREC) + sizeof(u_char *) * len) ; + pStr = malloc(len + 2) ; + + if (pStr == NULL || pCnf == NULL) { + fprintf(stderr, "configure - cannot allocate parsing buffer\n") ; + if (pStr != NULL) free(pStr) ; + if (pCnf != NULL) free(pCnf) ; + return FALSE ; + } + + memset(pCnf, 0, sizeof(CNFREC)) ; + + for (p = pStr ; *line != '\0' ; ) { + if (*line == '\n' || *line == '\r') { + break ; + } + *p++ = *line++ ; + } + *p = '\0' ; + + /* + * parse line (save results into pCnf) + * + * term may be string or quoted-string + */ + + for (p = pStr ; *p != '\0' ; ) { + if (isspace(*p)) { + p += 1 ; + } else if (*p == '#') { + break ; + } else if (*p == '"') { + p = getQuoted(p, pCnf) ; + } else { + p = getString(p, pCnf) ; + } + } + + /* + * if no term found, skip the line + */ + + if (pCnf->nVal == 0) { + free(pStr) ; + free(pCnf) ; + return TRUE ; + } + + /* + * create resulting CNF record + */ + + pNew = (CNFPTR) malloc(sizeof(CNFREC) + sizeof(u_char *) * pCnf->nVal) ; + + if (pNew == NULL) { + fprintf(stderr, "configure - cannot allocate parsed record\n") ; + free(pStr) ; + free(pCnf) ; + return FALSE ; + } + + memset(pNew, 0, sizeof(CNFREC)) ; + + pNew->key = pStr ; + pNew->nVal = pCnf->nVal ; + memcpy(pNew->aVal, pCnf->aVal, sizeof(u_char *) * pCnf->nVal) ; + + free(pCnf) ; + + /* + * link to list + */ + + prev = confList.prev ; + next = prev->next ; + pNew->prev = confList.prev ; + pNew->next = &confList ; + prev->next = pNew ; + next->prev = pNew ; + + return TRUE ; +} + +/* + * config_load - load mDNS Proxy configuration data + */ + +BOOL config_load(int ac, char *av[]) +{ + int i ; + u_char *conf ; + FILE *fp ; + u_char line[512] ; + + /* + * check if alternate config file specified + */ + + for (i = 1, conf = NULL ; i < ac ; i++) { + if (strcmp(av[i], "-config") == 0) { + if ((i + 1) < ac) { + conf = av[i+=1] ; + } + } + } + + /* + * open configuration file + */ + + if ((fp = openConfig(conf)) == NULL) { + fprintf(stderr, "config - cannot locate config file\n") ; + return FALSE ; + } + + /* + * read and parse configuration data (per line) + */ + + while (fgets(line, 512, fp) != NULL) { + if (appendData(line) != TRUE) { + fprintf(stderr, "config - cannot load data %s\n", line) ; + fclose(fp) ; + return FALSE ; + } + } + + fclose(fp) ; + return TRUE ; +} + +/* + * config_dump - dump contents of mDNS Proxy configuration data + */ + +static BOOL haveSpace(u_char *str) +{ + for ( ; *str != '\0' ; str++) { + if (isspace(*str)) { + return TRUE ; + } + } + return FALSE ; +} + +void config_dump(FILE *ofp) +{ + CNFPTR p ; + int i ; + + if (confList.next == NULL || confList.prev == NULL) { + return ; + } + for (p = confList.next ; p != &confList ; p = p->next) { + if (haveSpace(p->key)) { + fprintf(ofp, "<%s>", p->key) ; + } else { + fprintf(ofp, "<%s>", p->key) ; + } + for (i = 0 ; i < p->nVal ; i++) { + if (haveSpace(p->aVal[i])) { + fprintf(ofp, " \"%s\"", p->aVal[i]) ; + } else { + fprintf(ofp, " %s", p->aVal[i]) ; + } + } + fprintf(ofp, "\n") ; + } +} + +/* + * config_free - dispose mDNS configuration data + */ + +void config_free(void) +{ + disposeData() ; +} + +/* + * config_query_value - query configuration data + * + * this is generic interface to access configuration data + * but note, this function cannot work with multiple + * configuration data, such as client-translation + */ + +BOOL config_query_value(char *key, int *count, char ***array) +{ + CNFPTR p ; + + for (p = confList.next ; p != &confList ; p = p->next) { + if (strcmp(p->key, key) != 0) { + continue ; + } + *count = p->nVal ; + *array = (char **) p->aVal ; + return TRUE ; + } + return FALSE ; +} + +/* + * config_query_listen, config_query_forward + * + * queries sockaddr (really sockaddr_in) of proxy to listen, + * and DNS server to which proxy forwards the requests. + * These function set + * + * addr->sin_family <- AF_INET + * addr->sin_addr <- specified/default + * addr->sin_port <- specified/default + * + * for 'listen' address, both sin_addr/sin_port have default values, + * but for 'forward' address, there is no default for 'sin_addr', + * and result error on such case. + * + * NOTE: for DNS proxy, both listen/forward address should be + * specified with xx.xx.xx.xx notation, never be host name + */ + +#define DEFAULT_ADDR INADDR_ANY +#define DEFAULT_PORT 53 + +static CNFPTR queryData(u_char *key) +{ + CNFPTR p ; + + for (p = confList.next ; p != &confList ; p = p->next) { + if (strcmp(p->key, key) == 0) { + return p ; + } + } + return NULL ; +} + +static void getHostPort(u_char *arg, u_char *host, u_char *port) +{ + for (*host = '\0' ; *arg != '\0' ; arg++) { + if (*arg == ':') { + arg += 1 ; + break ; + } + *host++ = *arg ; + *host = '\0' ; + } + for (*port = '\0' ; *arg != '\0' ; arg++) { + *port++ = *arg ; + *port = '\0' ; + } +} + +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) { + 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 ; + } + + 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) ; + } + 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 ; + + if ((pForward = queryData("forward")) == NULL) { + WARN("config - no \"forward\" record\n") ; + return FALSE ; + } + if (pForward->nVal < 2) { + WARN("config - no \"forward\" value\n") ; + 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) ; + } + iaddr->sin_family = AF_INET ; + + return TRUE ; +} + +/* + * config_query_restrict - query 'source-restrict' flag + */ + +BOOL config_query_restrict(BOOL *restrict) +{ + CNFPTR pForward ; + + if ((pForward = queryData("forward")) == NULL) { + *restrict = FALSE ; + } else if (pForward->nVal < 3) { + *restrict = FALSE ; + } else if (strcmp(pForward->aVal[2], "bind4compat") != 0) { + *restrict = FALSE ; + } else { + *restrict = TRUE ; + } + return TRUE ; +} + +/* + * config_query_open, config_query_more, config_query_close + * + * this is generic interface to access configuration data + * for multiple entires for same key value. + */ + +config_ctx_t config_query_open(char *key, int *count, char ***array) +{ + CNFPTR p ; + + for (p = confList.next ; p != &confList ; p = p->next) { + if (strcmp(p->key, key) != 0) { + continue ; + } + *count = p->nVal ; + *array = (char **) p->aVal ; + return (config_ctx_t) p ; + } + return NULL ; +} + +config_ctx_t config_query_more(config_ctx_t ctx, int *count, char ***array) +{ + CNFPTR p = (CNFPTR) ctx ; + CNFPTR np ; + + for (np = p->next ; np != &confList ; np = np->next) { + if (strcmp(np->key, p->key) != 0) { + continue ; + } + *count = np->nVal ; + *array = (char **) np->aVal ; + return (config_ctx_t) np ; + } + return NULL ; +} + +void config_query_close(config_ctx_t ctx) +{ + /* nothing to do */ +} + +#ifdef TEST +/* + * test driver for 'config' module + */ + +static void dumpaddr(u_char *str, struct sockaddr *addr) +{ + u_char *p ; + struct sockaddr_in *iaddr = (struct sockaddr_in *) addr ; + + printf("%s ", str) ; + + p = (u_char *) &iaddr->sin_addr ; + printf("address %d.%d.%d.%d", + (p[0] & 0xff), (p[1] & 0xff), (p[2] & 0xff), (p[3] & 0xff)) ; + + p = (u_char *) &iaddr->sin_port ; + printf(" port %d", ((p[0] & 0xff) * 256 + (p[1] & 0xff))) ; + + printf("\n") ; +} + +static void dumpvalue(char *key, int count, char **array) +{ + int i ; + + for (i = 0 ; i < count ; i++) { + printf("%s ", array[i]) ; + } + printf("\n") ; fflush(stdout) ; +} + +int main(int ac, char *av[]) +{ + int stat ; + struct sockaddr addr ; + int count ; + char **array ; + config_ctx_t ctx ; + + 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) { + dumpvalue("listen", count, array) ; + } + if (config_query_value("forward", &count, &array) == 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) ; + while (ctx != NULL) { + dumpvalue("client-translation", count, array) ; + ctx = config_query_more(ctx, &count, &array) ; + } + config_query_close(ctx) ; + + if (config_query_listen(&addr) != TRUE) { + printf("no \"listen\" data\n") ; + } else { + dumpaddr("listen", &addr) ; + } + + if (config_query_forward(&addr) != TRUE) { + printf("no \"forward\" data\n") ; + } else { + dumpaddr("forward", &addr) ; + } + + config_free() ; + return 0 ; +} +#endif /* TEST */ diff --git a/contrib/idn/mdnkit/dnsproxy/proxycnf.h b/contrib/idn/mdnkit/dnsproxy/proxycnf.h new file mode 100644 index 0000000000..44197b47d2 --- /dev/null +++ b/contrib/idn/mdnkit/dnsproxy/proxycnf.h @@ -0,0 +1,119 @@ +/* + * proxycnf.h - mDNS Proxy, Configure Proxy Server + */ + +/* + * 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. + */ + +/* $Id: proxycnf.h,v 1.9 2000/11/17 05:42:09 ishisone Exp $ */ + +#ifndef PROXYCNF_H +#define PROXYCNF_H 1 + +/* + * CONFIG_PATH + * where configuration file placed + */ + +#ifndef CONFIG_PATH +#ifdef UNIX +#define CONFIG_PATH "/usr/local/etc/" +#endif +#ifdef WIN32 +#define CONFIG_PATH "$(SystemRoot)/" +#endif +#ifdef OS2 +#define CONFIG_PATH "$(ETC)/" +#endif +#endif /* CONFIG_PATH */ + +/* + * CONFIG_FILE + * name of configuration file + */ + +#ifndef CONFIG_FILE +#ifdef UNIX +#define CONFIG_FILE "dnsproxy.conf" +#endif +#ifdef WIN32 +#define CONFIG_FILE "dnsproxy.cnf" +#endif +#ifdef OS2 +#define CONFIG_FILE "dnsproxy.cnf" +#endif +#endif /* CONFIG_FILE */ + +/* + * CONFIG_HOME + * debugging support, $HOME environment name + */ + +#ifndef CONFIG_HOME +#ifdef UNIX +#define CONFIG_HOME "$(HOME)/" +#endif +#ifdef WIN32 +#define CONFIG_HOME "$(HOMEPATH)/" +#endif +#ifdef OS2 +#define CONFIG_HOME "$(HOME)/" +#endif +#endif /* CONFIG_HOME */ + +#endif /* PROXYCNF_H */ diff --git a/contrib/idn/mdnkit/dnsproxy/server.c b/contrib/idn/mdnkit/dnsproxy/server.c new file mode 100644 index 0000000000..d4b1ea7497 --- /dev/null +++ b/contrib/idn/mdnkit/dnsproxy/server.c @@ -0,0 +1,1409 @@ +/* + * server.c - mDNS Proxy, proxy server core + */ + +/* + * 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: server.c,v 1.23 2000/11/17 05:46:23 ishisone Exp $"; +#endif + +#include + +#include +#include +#include +#include + +#ifdef HAVE_UNISTD_H +#include +#endif + +#ifdef WIN32 +#include +#include +#else /* for normal systems */ +#include +#include +#include +#ifdef HAVE_SYS_SELECT_H +#include +#endif +#include +#include +#endif + +#include "dnsproxy.h" + +#ifdef WIN32 +#define close(s) closesocket(s) +#define EWOULDBLOCK WSAEWOULDBLOCK +#endif + +#ifndef max +#define max(x, y) ((x) > (y) ? (x) : (y)) +#endif + +/* + * send buffer for TCP + * hold sending data when sending socket blocked + */ + +typedef struct _SNDBUF { + struct _SNDBUF *prev ; + struct _SNDBUF *next ; + int leng ; /* data length in the buffer */ + int sent ; /* data have been sent */ + int size ; /* size of this bufefr */ + u_char buff[1] ; /* 'size' array follows */ +} SNDREC, *SNDPTR ; + +/* + * recv buffer for TCP + * hold incomplete message + */ + +typedef struct _RCVBUF { + int stat ; /* what data receiving now */ + int leng ; /* length of the message */ + int recv ; /* message have been received */ + int size ; /* size of this buffer */ + u_char *buff ; /* points 'size' array of char */ +} RCVREC, *RCVPTR ; + +#define RCV_STAT_LEN1 0 /* waiting 1st byte of length */ +#define RCV_STAT_LEN2 1 /* waiting 2nd byte of length */ +#define RCV_STAT_DATA 2 /* waiting message data */ + +/* + * transport control block + * is used to handle pending recv/send data of the socket + */ + +typedef struct _NETREC { + struct _NETREC *prev ; + struct _NETREC *next ; + int sock ; /* socket to do network I/O */ + int proto ; /* TCP or UDP */ + int type ; /* see below */ + struct sockaddr peer ; /* peer of this transoport */ + SNDREC send ; /* pending send data (TPC) */ + RCVREC recv ; /* pending recv message */ +} NETREC, *NETPTR ; + +#define NET_LISTEN 1 /* is proxy's listening socket */ +#define NET_CLIENT 2 /* is connection from client */ +#define NET_SERVER 3 /* is transport to server */ + +static NETREC listNet = { 0 } ; /* list of transports */ + +/* + * allocate/dispose buffer for SND/RCV buffer managements + * simply mapped to malloc/free, but may be + * re-maped to spceific function if speed required + */ + +#define xalloc(x) malloc((x)) +#define xfree(p) free((p)) + +/* + * transientError - utility for handling "soft" errors + */ + +static BOOL transientError(int eno) +{ + if ( +#ifdef EAGAIN + eno == EAGAIN || +#endif +#ifdef EWOULDBLOCK + eno == EWOULDBLOCK || +#endif +#ifdef EINTR + eno == EINTR || +#endif + eno == 0) + return TRUE ; + else + return FALSE ; +} + +/* + * addrEq, addrFmt - utilities for handling address + */ + +static BOOL addrEq(struct sockaddr *a1, struct sockaddr *a2) +{ + struct sockaddr_in *ip1 = (struct sockaddr_in *) a1 ; + struct sockaddr_in *ip2 = (struct sockaddr_in *) a2 ; + + if (ip1->sin_addr.s_addr != ip2->sin_addr.s_addr) { + return FALSE ; + } + if (ip1->sin_port != ip2->sin_port) { + return FALSE ; + } + return TRUE ; +} + +static u_char fmtbuff[64] ; + +static u_char *addrFmt(struct sockaddr *addr, int proto) +{ + struct sockaddr_in *iaddr = (struct sockaddr_in *) addr ; + u_char *ap ; + u_char *pp ; + + ap = (u_char *) &iaddr->sin_addr ; + pp = (u_char *) &iaddr->sin_port ; + + sprintf(fmtbuff, "%s:%d.%d.%d.%d:%d", + (proto == SOCK_STREAM ? "TCP" : "UDP"), + (ap[0] & 0xff), (ap[1] & 0xff), (ap[2] & 0xff), (ap[3] & 0xff), + ((pp[0] & 0xff) * 256 + (pp[1] & 0xff)) ) ; + + return fmtbuff ; +} + +/* + * netCreate, netDispose - create/dispose transport control block + */ + +#define SZRCVBUF 1024 + +static NETPTR netCreate(int sock, struct sockaddr *peer, int proto, int type) +{ + NETPTR pNet, prev, next ; + u_char *pBuf ; + + if (listNet.prev == NULL || listNet.next == NULL) { + WARN("netCreate - transport list is not initialized\n") ; + listNet.prev = &listNet ; + listNet.next = &listNet ; + } + + pNet = (NETPTR) xalloc(sizeof(NETREC)) ; + pBuf = (u_char *) xalloc(SZRCVBUF) ; + + if (pNet == NULL || pBuf == NULL) { + WARN("netCreate - cannot allocate buffer\n") ; + if (pNet != NULL) xfree(pNet) ; + if (pBuf != NULL) xfree(pBuf) ; + return NULL ; + } + memset(pNet, 0, sizeof(NETREC)) ; + + pNet->sock = sock ; + pNet->proto = proto ; + pNet->type = type ; + + if (peer != NULL) { + memcpy(&pNet->peer, peer, sizeof(struct sockaddr)) ; + } + + pNet->send.prev = &pNet->send ; + pNet->send.next = &pNet->send ; + pNet->recv.stat = RCV_STAT_LEN1 ; + pNet->recv.leng = 0 ; + pNet->recv.recv = 0 ; + pNet->recv.size = SZRCVBUF ; + pNet->recv.buff = pBuf ; + + prev = listNet.prev ; + next = prev->next ; + + prev->next = pNet ; + next->prev = pNet ; + pNet->prev = prev ; + pNet->next = next ; + + return pNet ; +} + +static void netDispose(NETPTR pNet) +{ + NETPTR p ; + SNDPTR pSnd ; + + if (listNet.prev == NULL || listNet.next == NULL) { + WARN("netCreate - transport list is not initialized\n") ; + listNet.prev = &listNet ; + listNet.next = &listNet ; + } + + /* + * unlink from transport list + */ + + for (p = listNet.next ; p != &listNet ; p = p->next) { + if (p == pNet) { + break ; + } + } + if (p == pNet) { /* safe to unlink it */ + pNet->prev->next = pNet->next ; + pNet->next->prev = pNet->prev ; + } + + /* + * dispose control block resources + */ + + if (pNet->send.prev == NULL || pNet->send.next == NULL) { + WARN("netDispose - un-initialized SNDREC\n") ; + pNet->send.prev = &pNet->send ; + pNet->send.next = &pNet->send ; + } + while ((pSnd = pNet->send.next) != &pNet->send) { + pSnd->prev->next = pSnd->next ; + pSnd->next->prev = pSnd->prev ; + xfree(pSnd) ; + } + if (pNet->recv.buff != NULL) { + xfree(pNet->recv.buff) ; + } + close(pNet->sock) ; + xfree(pNet) ; +} + +/* + * netExpand - expand receive buffer + */ + +static BOOL netExpand(NETPTR p) +{ + int len ; + u_char *np ; + + if (p->recv.size > p->recv.leng) { + return TRUE ; + } + + len = 1024 * ((p->recv.leng + 1023) / 1024) ; + + TRACE("netExpand %d -> %d\n", p->recv.size, len) ; + + if ((np = xalloc(len)) == NULL) { + WARN("netExpand - cannot allocate memory\n") ; + return FALSE ; + } + if (p->recv.recv > 0) { + memcpy(np, p->recv.buff, p->recv.recv) ; + } + xfree(p->recv.buff) ; + p->recv.buff = np ; + p->recv.size = len ; + + return TRUE ; +} + +/* + * tcpSend, tcpQueue, tcpFlush - send message over stream socket + * + * tcpSend - send message over TCP socket + * tcpQueue - en-queue message if stream blocked + * tcpFlush - flush pending messages + */ + +static int tcpSend(int sock, u_char *msg, int len) +{ + int n, cnt = 0 ; + + while (len > 0) { + if ((n = send(sock, msg, len, 0)) > 0) { + msg += n ; + len -= n ; + cnt += n ; + continue ; + } + if (!transientError(errno)) { + WARN("tcpSend - send error %d\n", errno) ; + return -1 ; + } + break ; + } + return cnt ; +} + +static BOOL tcpQueue(NETPTR p, u_char *msg, int len) +{ + SNDPTR sp, prev, next ; + + if ((sp = (SNDPTR) xalloc(sizeof(SNDREC) + len)) == NULL) { + WARN("tcpQueue - cannot allocate buffer\n") ; + return FALSE ; + } + + sp->sent = 0 ; + sp->leng = len ; + sp->size = len ; + memcpy(sp->buff, msg, len) ; + + prev = p->send.prev ; + next = prev->next ; + prev->next = sp ; + next->prev = sp ; + sp->next = next ; + sp->prev = prev ; + + return TRUE ; +} + +static BOOL tcpFlush(NETPTR p) +{ + SNDPTR sp ; + int n, len ; + + if (p->proto != SOCK_STREAM) { + WARN("tcpFlush - flushing on non-stream socket\n") ; + return FALSE ; + } + if (p->send.prev == NULL || p->send.prev == NULL) { + WARN("tcpFlush - send buffer is not initialized\n") ; + p->send.prev = &p->send ; + p->send.next = &p->send ; + } + + while ((sp = p->send.next) != &p->send) { + + /* + * try to send data + */ + + if ((len = sp->leng - sp->sent) > 0) { + if ((n = tcpSend(p->sock, &sp->buff[sp->sent], len)) < 0) { + WARN("tcpFlush - send error %d\n", errno) ; + return FALSE ; + } + if (n == 0) { + TRACE("tcpFlush - blocked\n") ; + return TRUE ; + } + sp->sent += n ; + } + + /* + * if no more data in send buffer, unlink and free + */ + + if ((len = sp->leng - sp->sent) <= 0) { + sp->prev->next = sp->next ; + sp->next->prev = sp->prev ; + xfree(sp) ; + } + } + return TRUE ; +} + +/* + * Server Control Variables + */ + +static BOOL servActive = FALSE ; + +static NETPTR listenTcp = NULL ; /* proxy's listening socket */ +static NETPTR listenUdp = NULL ; /* proxy's listening socket */ + +static struct sockaddr serverDefaultAddr = { 0 } ; +static BOOL serverRestrictPort = FALSE ; + +/* + * server_done - finalize server + * + * is also used when 'server_init' failed in initialization sequence + * + * using module level utilities + * + * netDispose dispose transport control block + */ + +void server_done(void) +{ + NETPTR p ; + + if (listNet.prev == NULL || listNet.next == NULL) { + listNet.prev = &listNet ; + listNet.next = &listNet ; + } + while ((p = listNet.next) != &listNet) { + netDispose(p) ; + } +} + +/* + * server_init - initialize server + * + * using sub-functions + * + * initTcp create socket to listening TCP connection + * initUdp create socket to listening UDP message + * + * and also using module level utilities + * + * netCreate create transport control block + * + * also use 'server_done' to cleanup resources + */ + +static NETPTR initTcp(void) +{ + NETPTR p ; + int sock ; + int one = 1 ; + struct sockaddr addr ; + + if (config_query_listen(&addr) != TRUE) { + WARN("initTcp - no listen address\n") ; + return NULL ; + } + + if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) { + WARN("initTcp - cannot create TCP socket\n") ; + return NULL ; + } + + setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)) ; + + if (bind(sock, &addr, sizeof(addr)) < 0) { + WARN("initTcp - cannot bind TCP socket\n") ; + close(sock) ; + return NULL ; + } + if (listen(sock, 5) < 0) { + WARN("initTcp - cannot listen on TCP socket\n") ; + close(sock) ; + return NULL ; + } + if ((p = netCreate(sock, &addr, SOCK_STREAM, NET_LISTEN)) == NULL) { + WARN("initTcp - cannot create control block\n") ; + close(sock) ; + return NULL ; + } + return p ; +} + +static NETPTR initUdp(void) +{ + NETPTR p ; + int sock ; + int one = 1 ; + struct sockaddr addr ; + + if (config_query_listen(&addr) != TRUE) { + WARN("initUdp - no listen address\n") ; + return NULL ; + } + + if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { + WARN("initUdp - cannot create UDP socket\n") ; + return NULL ; + } + + setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)) ; + + if (bind(sock, &addr, sizeof(addr)) < 0) { + WARN("initUdp- cannot bind UDP socket\n") ; + close(sock) ; + return NULL ; + } + if ((p = netCreate(sock, &addr, SOCK_DGRAM, NET_LISTEN)) == NULL) { + WARN("initUdp - cannot create control block\n") ; + close(sock) ; + return NULL ; + } + return p ; +} + +/* + * server_init - initialize proxy server + */ + +BOOL server_init(int ac, char *av[]) +{ + /* + * initialize transport list + */ + + listNet.prev = &listNet ; + listNet.next = &listNet ; + + /* + * setup transports + */ + + listenTcp = initTcp() ; + listenUdp = initUdp() ; + + if (listenTcp == NULL || listenUdp == NULL) { + WARN("server_init - cannot create proxy's listening port\n") ; + server_done() ; + return FALSE ; + } + + if (config_query_forward(&serverDefaultAddr) != TRUE) { + WARN("server_init - no DNS server address\n") ; + server_done() ; + return FALSE ; + } + if (config_query_restrict(&serverRestrictPort) != TRUE) { + WARN("server_init - cannot query 'serverRestrictPort' flag\n") ; + server_done() ; + return FALSE ; + } + + /* + * also initialize translator + */ + + if (translate_initialize() != TRUE) { + WARN("server_init - translation configuration failed\n") ; + server_done() ; + return FALSE ; + } + + /* + * now server is ready, turn on active flags now + */ + + servActive = TRUE ; + + return TRUE ; +} + +/* + * server_stop - request to stop server + * + * simply turn off 'servActive' control flag. + * then 'server_loop' terminate + */ + +void server_stop(void) +{ + servActive = FALSE ; +} + +/* + * server_loop - proxy server's message loop + * + * using sub-funcstions + * + * setRdFds listup sockets to check read ready + * setWtFds listup sockets to check write ready + * sockAccept accept connection from client + * sockRecvTcp receive message over TCP + * sockRecvUdp receive message over UDP + * sockDispatch dispatch on ready sockets + * sockValidate validate sockets + * timerDispatch entry of timer processing + * + * and also using module level utilities + * + * netCreate create transport control block + * netDispose dispose transport control block + * tcpFlush send pending message + * addrFmt formatting address (& proto) + */ + +/* + * setRdFds, setWtFds - listup socket to check if ready + */ + +static int setRdFds(fd_set *rfds) +{ + int maxfd = 0 ; + NETPTR p ; + + /* + * listup sockets to check read ready + */ + + if (listNet.prev == NULL || listNet.next == NULL) { + WARN("setRdFds - listNet is not initialized\n") ; + listNet.prev = &listNet ; + listNet.next = &listNet ; + } + for (p = listNet.next ; p != &listNet ; p = p->next) { + FD_SET(p->sock, rfds) ; + maxfd = max(maxfd, p->sock) ; + } + return maxfd ; +} + +static int setWtFds(fd_set *wfds) +{ + int maxfd = 0 ; + NETPTR p ; + + /* + * listup sockets to check read ready + */ + + if (listNet.prev == NULL || listNet.next == NULL) { + WARN("setRdFds - listNet is not initialized\n") ; + listNet.prev = &listNet ; + listNet.next = &listNet ; + } + for (p = listNet.next ; p != &listNet ; p = p->next) { + if (p->send.prev == NULL || p->send.next == NULL) { + WARN("setWtFds - send buffer is not initialized\n") ; + p->send.prev = &p->send ; + p->send.next = &p->send ; + } + if (p->send.next != &p->send) { + FD_SET(p->sock, wfds) ; + maxfd = max(maxfd, p->sock) ; + } + } + return maxfd ; +} + +/* + * sockAccept - accept connection from client + */ + +static BOOL sockAccept(NETPTR p) +{ + NETPTR np ; + int ns, addrlen ; + struct sockaddr addr ; + struct sockaddr peer ; + + memset(&addr, 0, sizeof(addr)) ; + memset(&peer, 0, sizeof(peer)) ; + + addrlen = sizeof(addr) ; + + if ((ns = accept(p->sock, &addr, &addrlen)) < 0) { + WARN("sockAccept - cannot accept connection %d\n", errno) ; + return FALSE ; + } + + addrlen = sizeof(peer) ; + getpeername(ns, &peer, &addrlen) ; + + if ((np = netCreate(ns, &peer, SOCK_STREAM, NET_CLIENT)) == NULL) { + WARN("sockAccept - cannot create control block\n") ; + close(ns) ; + return FALSE ; + } + + TRACE("sockAccept - accept connection from %s on socket %d\n", addrFmt(&peer, SOCK_STREAM), ns) ; + + return TRUE ; +} + +/* + * sockRecvTcp, sockRecvUdp - receive message + * + * when message complete, call 'notify_message' to + * notify message arrival. + */ + +static BOOL sockRecvTcp(NETPTR p) +{ + int n, len ; + u_char buff[2] ; + u_char *bp ; + + /* + * validate transport + */ + + if (p == NULL || p->proto != SOCK_STREAM) { + WARN("sockRecvTcp - bad parameter\n") ; + return FALSE ; + } + if (p->recv.buff == NULL || p->recv.size == 0) { + WARN("sockRecvTcp - no receiver buffer\n") ; + return FALSE ; + } + + /* + * when receiving message over TCP, constuct state machine with + * RCVBUF's status. + */ + + if (p->recv.stat == RCV_STAT_LEN1) { + if ((n = recv(p->sock, buff, 2, 0)) <= 0) { + if (errno == EWOULDBLOCK) { + return TRUE ; + } + WARN("sockRecvTcp - recv error %d on socket %d, STAT_LEN1\n", errno, p->sock) ; + return FALSE ; + } + if (n == 1) { + p->recv.leng = ((int) (buff[0] & 0xff)) * 256 ; + p->recv.stat = RCV_STAT_LEN2 ; + return TRUE ; /* blocked, try later */ + } + p->recv.leng = ((int) (buff[0] & 0xff)) * 256 + ((int) (buff[1] & 0xff)) ; + p->recv.stat = RCV_STAT_DATA ; + /* then fall through */ + } + + if (p->recv.stat == RCV_STAT_LEN2) { + if ((n = recv(p->sock, buff, 1, 0)) <= 0) { + if (errno == EWOULDBLOCK) { + return TRUE ; + } + WARN("sockRecvTcp - recv error %d on socket %d, STAT_LEN2\n", errno, p->sock) ; + return FALSE ; + } + p->recv.leng += ((int) (buff[0] & 0xff)) ; + p->recv.stat = RCV_STAT_DATA ; + /* then fall through */ + } + + if (p->recv.stat == RCV_STAT_DATA) { + if (p->recv.size < p->recv.leng) { + if (netExpand(p) != TRUE) { + WARN("sockRecvTcp - cannot expand recv buffer\n") ; + return FALSE ; + } + } + + bp = &p->recv.buff[p->recv.recv] ; + len = p->recv.leng - p->recv.recv ; + + if ((n = recv(p->sock, bp, len, 0)) <= 0) { + if (errno == EWOULDBLOCK) { + return TRUE ; + } + 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 ; + } + if ((p->recv.recv += n) < p->recv.leng) { + return TRUE ; /* still in-complete */ + } + + /* + * message complete, notify it + */ + + notify_message(&p->peer, SOCK_STREAM, p->recv.buff, p->recv.leng) ; + + /* + * reset recv buffer + */ + + p->recv.stat = RCV_STAT_LEN1 ; + p->recv.leng = 0 ; + p->recv.recv = 0 ; + + return TRUE ; + } + WARN("sockRecvTcp - something wrong\n") ; + return FALSE ; +} + +static BOOL sockRecvUdp(NETPTR p) +{ + int n, fromlen ; + struct sockaddr fromaddr ; + + /* + * validate transport + */ + + if (p == NULL || p->proto != SOCK_DGRAM) { + WARN("sockRecvUdp - bad parameter\n") ; + return FALSE ; + } + if (p->recv.buff == NULL || p->recv.size == 0) { + WARN("sockRecvUdp - no receiver buffer\n") ; + return FALSE ; + } + + /* + * receive over UDP + */ + + 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 ; + } else if (n < 0) { + if (transientError(errno)) + return TRUE ; + switch (errno) { +#ifdef ECONNREFUSED + case ECONNREFUSED: +#endif +#ifdef ENETUNREACH + case ENETUNREACH: +#endif +#ifdef EHOSTUNREACH + case EHOSTUNREACH: +#endif + WARN("sockRecvUdp - recv error %d (ignored)\n", errno) ; + return TRUE ; + default: + WARN("sockRecvUdp - recv error %d\n", errno) ; + return FALSE ; + } + } + + /* + * notify message arrival + */ + + notify_message(&fromaddr, SOCK_DGRAM, p->recv.buff, n) ; + + return TRUE ; +} + +/* + * sockDispatch - process on ready sockets + */ + +static void sockDispatch(int nfds, fd_set *rfds, fd_set *wfds) +{ + NETPTR p, np ; + BOOL stat ; + + /* + * process on ready sockets + */ + + if (listNet.prev == NULL || listNet.next == NULL) { + WARN("sockDispatch - listNet is not initialized\n") ; + listNet.prev = &listNet ; + listNet.next = &listNet ; + } + for (p = listNet.next ; p != &listNet ; p = np) { + + np = p->next ; + stat = TRUE ; /* assume no problem */ + + /* + * if receiving socket ready, then + * + * LISTEN TCP accept connection + * LISTEN UDP receive message + * CLIENT receive message + * SERVER receive message + */ + + if (stat == TRUE && FD_ISSET(p->sock, rfds)) { + if (p->type != NET_LISTEN) { + if (p->proto == SOCK_STREAM) { + stat = sockRecvTcp(p) ; + } else { + stat = sockRecvUdp(p) ; + } + } else if (p->proto == SOCK_DGRAM) { + stat = sockRecvUdp(p) ; + } else { /* connect request on listening TCP socket */ + stat = sockAccept(p) ; + } + } + + /* + * if send socket ready, then send pending message + * + * don't check transport type, protocol, but + * this happens only for TCP socket to CLIENT/SERVER + */ + + if (stat == TRUE && FD_ISSET(p->sock, wfds)) { + tcpFlush(p) ; + } + + /* + * if something wrong on socket, dispose it + */ + + if (stat != TRUE) { + if (p->type == NET_LISTEN || p->proto == SOCK_DGRAM) { + WARN("sockDispatch - error on listening socket\n") ; + server_stop() ; + } else { + WARN("sockDispatch - error on socket %d\n", p->sock) ; + } + netDispose(p) ; + } + } +} + +/* + * sockValidate - validate socket when select error + */ + +static void sockValidate(int nfds, fd_set *rfds, fd_set *wfds) +{ + NETPTR p, np ; + fd_set fds ; + struct timeval tm ; + + TRACE("sockValidate\n") ; + + FD_ZERO(&fds) ; + tm.tv_sec = 0 ; + tm.tv_usec = 0 ; + + if (listNet.prev == NULL || listNet.next == NULL) { + WARN("sockValidate - listNet is not initialized\n") ; + listNet.prev = &listNet ; + listNet.next = &listNet ; + } + + for (p = listNet.next ; p != &listNet ; p = np) { + + np = p->next ; + + /* + * check if socket is still available + */ + + FD_SET(p->sock, &fds) ; + + if (!FD_ISSET(p->sock, rfds) && !FD_ISSET(p->sock, wfds)) { + FD_CLR(p->sock, &fds) ; + continue ; + } + if (select(p->sock + 1, &fds, NULL, NULL, &tm) >= 0) { + FD_CLR(p->sock, &fds) ; + continue ; + } + FD_CLR(p->sock, &fds) ; + + /* + * something wrong on socket + */ + + if (p->type == NET_LISTEN) { + WARN("sockValidate - closed listening socket\n") ; + server_stop() ; + } else { + WARN("sockValidate - closed socket %d\n", p->sock) ; + } + netDispose(p) ; + } +} + +/* + * timerDispatch - entry of timer processing + */ + +static time_t timeLast = 0 ; /* last time of timer process */ +static time_t timeWait = 10 ; /* wait till next timer process */ + +static void timerDispatch(void) +{ + time_t t = time(NULL) ; + + /* + * do timer process every 'timeWait' interval + */ + + if ((t - timeLast) < timeWait) { + return ; + } + + /* + * call timer processes here + */ + + notify_timer() ; + + /* + * update timer + */ + + timeLast = t ; +} + +/* + * server_loop - proxy's main, select loop + */ + +void server_loop(void) +{ + struct timeval tm ; + fd_set rfds, wfds ; + int maxrfd, maxwfd ; + int n, nfds ; + + while (servActive) { + + FD_ZERO(&rfds) ; + FD_ZERO(&wfds) ; + + maxrfd = setRdFds(&rfds) ; + maxwfd = setWtFds(&wfds) ; + nfds = max(maxrfd, maxwfd) + 1 ; + + tm.tv_sec = 10 ; + tm.tv_usec = 0 ; + + if (maxwfd == 0) { + n = select(nfds, &rfds, NULL, NULL, &tm) ; + } else { + n = select(nfds, &rfds, &wfds, NULL, &tm) ; + } + + if (n > 0) { + sockDispatch(nfds, &rfds, &wfds) ; + } else if (n < 0) { + if (!transientError(errno)) { + sockValidate(nfds, &rfds, &wfds) ; + } + } + timerDispatch() ; +#ifdef DEBUG + fflush(stdout) ; + fflush(stderr) ; +#endif + log_turnover(); + } +} + +/* + * Server's entries for send message (forward or response) + * + * server_forward forward request to DNS server + * server_response send back response to client + * + * using sub-functions, + * + * openTcp open TCP connection to the upstream server + * openUdp open UDP transport to the upstream server + * getServer get transport to the upstream server + * getClient get transport to responding client + * sendTcp send message via TCP + * sendUdp send message via UDP + * + * and also using module level utilities, + * + * netCreate create transport control block + * tcpSend send message over TCP socket + * tcpQueue enqueue if TCP blocked + * addrEq check if addresses are same + * addrFmt formatting address (& proto) + */ + +/* + * openTcp, openUdp - create TCP/UDP transport to DNS server + */ + +static NETPTR openTcp(struct sockaddr *to) +{ + int sock ; + NETPTR p ; + + TRACE("openTcp - creating transport to %s\n", addrFmt(to, SOCK_STREAM)) ; + + if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) { + WARN("openTcp - cannote create socket %d\n", errno) ; + return NULL ; + } + if (connect(sock, to, sizeof(struct sockaddr)) < 0) { + WARN("openTcp - cannot connect to server %d\n", errno) ; + close(sock) ; + return NULL ; + } + if ((p = netCreate(sock, to, SOCK_STREAM, NET_SERVER)) == NULL) { + WARN("openTcp - cannot create control block\n") ; + close(sock) ; + return NULL ; + } + return p ; +} + +static NETPTR openUdp(struct sockaddr *to) +{ + int sock ; + NETPTR p ; + struct sockaddr_in saddr ; /* source port */ + + TRACE("openUdp - creating transport to %s\n", addrFmt(to, SOCK_DGRAM)) ; + + memset(&saddr, 0, sizeof(saddr)) ; + saddr.sin_family = AF_INET ; + saddr.sin_addr.s_addr = htonl(INADDR_ANY) ; + saddr.sin_port = htons(0) ; + + if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { + WARN("openUdp - cannote create socket %d\n", errno) ; + return NULL ; + } + if (bind(sock, (struct sockaddr *) &saddr, sizeof(saddr)) < 0) { + WARN("openUdp - cannot bind source port\n") ; + close(sock) ; + return NULL ; + } + if (connect(sock, to, sizeof(struct sockaddr)) < 0) { + WARN("openUdp - cannot connect to server\n") ; + close(sock) ; + return NULL ; + } + if ((p = netCreate(sock, to, SOCK_DGRAM, NET_SERVER)) == NULL) { + WARN("openUdp - cannot create control block\n") ; + close(sock) ; + return NULL ; + } + return p ; +} + +/* + * getServer - search/create transport to the DNS server + */ + +static NETPTR getServer(struct sockaddr *to, int proto) +{ + NETPTR p ; + + /* + * if proxy should use DNS port to communicate DNS server, + * use proxy's listen port to forward request to the server + */ + + if (proto == SOCK_DGRAM && serverRestrictPort) { + return listenUdp ; + } + + /* + * search transport to specified DNS server + */ + + if (listNet.prev == NULL || listNet.next == NULL) { + WARN("getServer - listNet is not initialized\n") ; + listNet.prev = &listNet ; + listNet.next = &listNet ; + } + for (p = listNet.next ; p != &listNet ; p = p->next) { + if (p->proto != proto || p->type != NET_SERVER) { + continue ; + } + if (addrEq(&p->peer, to)) { + return p ; + } + } + + /* + * if not exist, create new one + */ + + if (proto == SOCK_STREAM) { + p = openTcp(to) ; + } else { + p = openUdp(to) ; + } + return p ; +} + +/* + * getClient - search transport to the client + */ + +static NETPTR getClient(struct sockaddr *to, int proto) +{ + NETPTR p ; + + /* + * for response using UDP, use proxy's UDP socket + */ + + if (proto == SOCK_DGRAM) { + return listenUdp ; + } + + /* + * otherwise (TCP), use existing transport to the client + */ + + if (listNet.prev == NULL || listNet.next == NULL) { + WARN("getClient - listNet is not initialized\n") ; + listNet.prev = &listNet ; + listNet.next = &listNet ; + } + for (p = listNet.next ; p != &listNet ; p = p->next) { + if (p->proto != proto || p->type != NET_CLIENT) { + continue ; + } + if (addrEq(&p->peer, to)) { + return p ; + } + } + return NULL ; +} + +/* + * sendTcp, sendUdp - send message over TCP/UDP + */ + +static void sendTcp(NETPTR p, u_char *msg, int len) +{ + int n ; + u_char buff[1024] ; + u_char *bp ; + + /* + * insert 2 bytes message length field before the message + */ + + if (len < (1024 - 2)) { + bp = buff ; + } else { + bp = malloc(len + 2) ; + } + if (bp == NULL) { + WARN("sendTcp - cannot alocate send buffer\n") ; + return ; + } + bp[0] = len / 256 ; + bp[1] = len % 256 ; + memcpy(&bp[2], msg, len) ; + len += 2 ; + + /* + * if there is pending data, enqueue sending message + */ + + if (p->send.prev == NULL || p->send.next == NULL) { + WARN("sendTcp - send buffer is not initialized\n") ; + p->send.prev = &p->send ; + p->send.next = &p->send ; + } + if (p->send.next != &p->send) { + tcpQueue(p, bp, len) ; + if (bp != buff) free(bp) ; + return ; + } + + /* + * then, try to send message + */ + + if ((n = tcpSend(p->sock, bp, len)) < 0) { + WARN("sendTcp - cannot send message\n") ; + if (bp != buff) free(bp) ; + return ; + } + if (n != len) { + tcpQueue(p, (bp + n), (len - n)) ; + } + if (bp != buff) free(bp) ; +} + +static void sendUdp(NETPTR p, u_char *msg, int len, struct sockaddr *to) +{ + int n ; + + if (p->type == NET_SERVER) { /* target is binded */ + n = send(p->sock, msg, len, 0) ; + } else { /* need to specify target */ + n = sendto(p->sock, msg, len, 0, to, sizeof(struct sockaddr)) ; + } + if (n < 0) { + if (!transientError(errno)) { + WARN("sendUdp - cannot send message %d\n", errno) ; + } + return ; + } + if (n != len) { + WARN("sendUdp - cannot send entire message %d/%d\n", n, len) ; + return ; + } +} + +/* + * server_forward - forward request to the DNS server + */ + +void server_forward(struct sockaddr *to, int proto, u_char *msg, int len) +{ + NETPTR p ; + + if (to == NULL) { + to = &serverDefaultAddr ; + } + if ((p = getServer(to, proto)) == NULL) { + WARN("server_forward - no transport to server %s\n", addrFmt(to, proto)) ; + return ; + } + if (proto == SOCK_STREAM) { + sendTcp(p, msg, len) ; + } else { + sendUdp(p, msg, len, to) ; + } +} + +/* + * server_response - response to cllient + */ + +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)) ; + return ; + } + if (proto == SOCK_STREAM) { + sendTcp(p, msg, len) ; + } else { + sendUdp(p, msg, len, to) ; + } +} diff --git a/contrib/idn/mdnkit/dnsproxy/translate.c b/contrib/idn/mdnkit/dnsproxy/translate.c new file mode 100644 index 0000000000..c4ce242cca --- /dev/null +++ b/contrib/idn/mdnkit/dnsproxy/translate.c @@ -0,0 +1,521 @@ +/* + * 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 + +#include +#include +#include + +#ifdef WIN32 +#include +#include +#else /* for normal systems */ +#include +#include +#include +#include +#endif + +#include +#include +#include +#include +#include +#include +#include + +#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(¶m, 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(¶m, 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; + } +} diff --git a/contrib/idn/mdnkit/dnsproxy/unxmain.c b/contrib/idn/mdnkit/dnsproxy/unxmain.c new file mode 100644 index 0000000000..8ae42db74f --- /dev/null +++ b/contrib/idn/mdnkit/dnsproxy/unxmain.c @@ -0,0 +1,288 @@ +/* + * unxmain.c - mDNS Proxy, entry for UNIX + */ + +/* + * 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: unxmain.c,v 1.16 2000/11/17 05:46:23 ishisone Exp $"; +#endif + +#ifdef UNIX + +#include + +#include +#include +#include +#include +#include +#include +#ifdef HAVE_UNISTD_H +#include +#endif +#include +#include +#include +#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" + +static uid_t uid; +static gid_t gid; +static char *root_dir; +static BOOL uid_specified = FALSE; +static BOOL gid_specified = FALSE; + +/* + * signal handler to catch signal to terminate server + */ + +static void handler(int signo) +{ + server_stop() ; + signal(signo, SIG_DFL) ; +} + +/* + * signal handler to turn over the log file + */ + +static void hup_handler(int signo) +{ + log_turnover_request(); + signal(signo, hup_handler) ; +} + +/* + * Set root directory. + */ + +static void change_root(void) +{ + int err; + + if (root_dir != NULL && chroot(root_dir) < 0) { + err = errno; + FATAL("cannot change root directory: %s\n", strerror(err)); + exit(1); + } +} + +/* + * Set user/group ID. + */ + +static void set_id(void) +{ + int err; + + if (uid_specified && setuid(uid) < 0) { + err = errno; + FATAL("cannot set user ID: %s\n", strerror(err)); + exit(1); + } + + if (gid_specified && setgid(gid) < 0) { + err = errno; + FATAL("cannot set group ID: %s\n", strerror(err)); + exit(1); + } +} + +/* + * Load configuration parameter related to security. + */ + +static void get_security_conf(void) +{ + int ac; + char **av; + + if (config_query_value(KW_ROOT_DIR, &ac, &av)) { + if (ac != 2) { + WARN("syntax error at %s line\n", KW_ROOT_DIR); + exit(1); + } + root_dir = malloc(strlen(av[1]) + 1); + if (root_dir == NULL) { + FATAL("malloc failed\n"); + exit(1); + } + (void)strcpy(root_dir, av[1]); + } + + if (config_query_value(KW_USER_ID, &ac, &av)) { + struct passwd *pwd; + + if (ac != 2) { + WARN("syntax error at %s line\n", KW_USER_ID); + exit(1); + } else if ((pwd = getpwnam(av[1])) != NULL) { + uid = pwd->pw_uid; + uid_specified = TRUE; + } else if (isdigit((unsigned char)(av[1][0]))) { + uid = atoi(av[1]); + uid_specified = TRUE; + } else { + FATAL("unknown user %s\n", av[1]); + exit(1); + } + } + + if (config_query_value(KW_GROUP_ID, &ac, &av)) { + struct group *gr; + + if (ac != 2) { + WARN("syntax error at %s line\n", KW_GROUP_ID); + exit(1); + } else if ((gr = getgrnam(av[1])) != NULL) { + gid = gr->gr_gid; + gid_specified = TRUE; + } else if (isdigit((unsigned char)(av[1][0]))) { + gid = atoi(av[1]); + gid_specified = TRUE; + } else { + FATAL("unknown group %s\n", av[1]); + exit(1); + } + } +} + +/* + * main - entry of UNIX version + */ + +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) { + as_daemon = TRUE ; + } + } + if (config_load(ac, av) != TRUE) { + printf("cannot load configurations\n") ; + return 1 ; + } + log_configure(ac, av) ; + + get_security_conf(); + + if (server_init(ac, av) != TRUE) { + printf("cannot initialize server\n") ; + log_terminate() ; + return 1 ; + } + + if (as_daemon) { + switch (pid = fork()) { + case -1 : + printf("cannot start daemon %d\n", errno) ; + server_done() ; + log_terminate() ; + return 2 ; + case 0 : /* children, as daemon */ + setsid() ; + close(0) ; + close(1) ; + close(2) ; + break ; + default : + printf("start daemon PID %d\n", pid) ; + return 0 ; + } + } + + /* + * Change root directory/user ID/group ID if specified. + */ + change_root(); + set_id(); + + signal(SIGHUP, hup_handler) ; + signal(SIGINT, handler) ; + signal(SIGKILL, handler) ; + signal(SIGTERM, handler) ; + +#ifdef DEBUG + printf("Service Started\n") ; +#endif + + server_loop() ; + +#ifdef DEBUG + printf("Service Terminating...\n") ; +#endif + + server_done() ; + + log_terminate() ; + +#ifdef DEBUG + printf("Service Terminated\n") ; +#endif + + return 0 ; +} +#endif /* UNIX */ diff --git a/contrib/idn/mdnkit/dnsproxy/winmain.c b/contrib/idn/mdnkit/dnsproxy/winmain.c new file mode 100644 index 0000000000..75e65226d7 --- /dev/null +++ b/contrib/idn/mdnkit/dnsproxy/winmain.c @@ -0,0 +1,174 @@ +/* + * winmain.c - mDNS Proxy, entry for WIN32 + * + * Windows version works as + * + * Service Program, as mDNS Proxy Server + * Service Configuration Program, Install/Remove mDNS Proxy + * + * or simply as + * + * Application Program, for debugging + * + * with single executable, switched with first option + * + * -service as Service Program + * -install as Configuration, install serivce + * -remove as Configuration, remove service + * + * Otherwise, it runs as simple console apllication. + */ + +/* + * 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: winmain.c,v 1.10 2000/07/04 03:52:29 ishisone Exp $"; +#endif + +#ifdef WIN32 + +#include +#include +#include +#include +#include + +#include "dnsproxy.h" /* Common definitions for mDNS proxy */ +#include "winserv.h" /* WIN32 Service Related Functions */ + +/* + * signal handler to catch signal to terminate server + */ + +static void handler(int signo) +{ + server_stop() ; + signal(signo, SIG_DFL) ; +} + +/* + * main - entry of windows version + */ + +int main(int ac, char *av[]) +{ + WORD version = MAKEWORD(2, 0) ; + WSADATA wsaData ; + + /* + * check 1st option + */ + + if (ac >= 2) { + if (strcmp(av[1], "-service") == 0) { + serviceRun(ac, av) ; + return 0 ; + } + if (strcmp(av[1], "-install") == 0) { + serviceInstall(ac, av) ; + return 0 ; + } + if (strcmp(av[1], "-remove") == 0) { + serviceRemove(ac, av) ; + return 0 ; + } + } + + /* + * otherwise run as normal application + */ + + if (config_load(ac, av) != TRUE) { + printf("cannot load configration\n") ; + return 1 ; + } + log_configure(ac, av) ; + + if (WSAStartup(version, &wsaData) != 0) { + printf("cannot startup WinSock\n") ; + return FALSE ; + } + if (server_init(ac, av) != TRUE) { + printf("cannot initialize server\n") ; + WSACleanup() ; + return 1 ; + } + + signal(SIGINT, handler) ; + signal(SIGTERM, handler) ; + signal(SIGBREAK, handler) ; + + printf("Service Started\n") ; + + server_loop() ; + + printf("Service Termiating...\n") ; + + server_done() ; + + printf("Service Terminated\n") ; + + WSACleanup() ; + + log_terminate() ; + + return 0 ; +} + +#endif /* WIN32 */ diff --git a/contrib/idn/mdnkit/dnsproxy/winserv.c b/contrib/idn/mdnkit/dnsproxy/winserv.c new file mode 100644 index 0000000000..122c19257a --- /dev/null +++ b/contrib/idn/mdnkit/dnsproxy/winserv.c @@ -0,0 +1,446 @@ +/* + * winserv.c - mDNS Proxy, WIN32 Service Specific 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. + */ + +#ifndef lint +static char *rcsid = "$Id: winserv.c,v 1.10 2000/10/27 03:09:58 ishisone Exp $"; +#endif + +#ifdef WIN32 + +#include +#include +#include +#include +#include + +#include "dnsproxy.h" /* Common definitions for mDNS proxy */ +#include "winserv.h" /* Windows's Service Specific */ + +/* + * Parameters for WIN32 Service + */ + +#define SERVICENAME "dnsproxy" +#define DISPLAYNAME "mDNS Proxy" + +static UCHAR pathService[1024] ; + +/* + * getFileName - get fullpath and split it + */ + +static UCHAR p_ful[256] ; +static UCHAR p_drv[256] ; +static UCHAR p_dir[256] ; +static UCHAR p_nam[256] ; +static UCHAR p_ext[256] ; + +static void getFileName(void) +{ + GetModuleFileName(NULL, p_ful, 256) ; + _splitpath(p_ful, p_drv, p_dir, p_nam, p_ext) ; +} + +/* + * Service management Varibales + */ + +SERVICE_STATUS_HANDLE ServiceStatusHandle = 0 ; +SERVICE_STATUS ServiceStatusRecord = { 0 } ; +int ServiceErrorCode = 0 ; + +void serviceLogTrace(PUCHAR msg) +{ + char msgbuff[256] ; + HANDLE hEventSrc ; + char *strings[2] ; + + ServiceErrorCode = GetLastError() ; + + sprintf(msgbuff, "%s trace: %d", SERVICENAME, ServiceErrorCode) ; + strings[0] = msgbuff ; + strings[1] = msg ; + + hEventSrc = RegisterEventSource(NULL, TEXT(SERVICENAME)) ; + + if (hEventSrc != NULL) { + ReportEvent( + hEventSrc, + EVENTLOG_INFORMATION_TYPE, + 0, + 0, + NULL, + 2, + 0, + (const char **) strings, + NULL) ; + DeregisterEventSource(hEventSrc) ; + } + /* TRACE("%s %s\n", msgbuff, msg) ; */ +} + +void serviceLogError(PUCHAR msg) +{ + char msgbuff[256] ; + HANDLE hEventSrc ; + char *strings[2] ; + + ServiceErrorCode = GetLastError() ; + + sprintf(msgbuff, "%s error: %d", SERVICENAME, ServiceErrorCode) ; + strings[0] = msgbuff ; + strings[1] = msg ; + + hEventSrc = RegisterEventSource(NULL, TEXT(SERVICENAME)) ; + + if (hEventSrc != NULL) { + ReportEvent( + hEventSrc, + EVENTLOG_ERROR_TYPE, + 0, + 0, + NULL, + 2, + 0, + (const char **) strings, + NULL) ; + DeregisterEventSource(hEventSrc) ; + } + /* FATAL("%s %s\n", msgbuff, msg) ; */ +} + +/* + * serviceReport - report service status + */ + +VOID serviceReport(DWORD state, DWORD exitcode, DWORD waithint) +{ + static DWORD checkpoint = 1 ; + + if (state == SERVICE_START_PENDING) { + ServiceStatusRecord.dwControlsAccepted = 0 ; + } else { + ServiceStatusRecord.dwControlsAccepted = SERVICE_ACCEPT_STOP ; + } + ServiceStatusRecord.dwCurrentState = state ; + ServiceStatusRecord.dwWin32ExitCode = exitcode ; + ServiceStatusRecord.dwWaitHint = waithint ; + + if (state == SERVICE_RUNNING || state == SERVICE_STOPPED) { + ServiceStatusRecord.dwCheckPoint = 0 ; + } else { + ServiceStatusRecord.dwCheckPoint = checkpoint++ ; + } + + SetServiceStatus(ServiceStatusHandle, &ServiceStatusRecord) ; +} + +/* + * ServiceCtrl - service control handler + */ + +VOID ServiceCtrl(DWORD opcode) +{ + switch (opcode) { + + case SERVICE_CONTROL_STOP : + serviceLogTrace("ServiceCtrl STOP") ; + ServiceStatusRecord.dwCurrentState = SERVICE_STOP_PENDING ; + /* nofity later, so set status only */ + server_stop() ; /* stop server loop */ + break ; + + case SERVICE_CONTROL_INTERROGATE : + /* query, report later */ + serviceLogTrace("ServiceCtrl INTERROGATE") ; + break ; + + default : + break ; + } + serviceReport(ServiceStatusRecord.dwCurrentState, NO_ERROR, 0) ; +} + +/* + * ServiceMain - as name describes + */ + +static UCHAR cmdline[1024] ; + +VOID ServiceMain(DWORD dwArgc, LPTSTR *lpszArgv) +{ + WORD version = MAKEWORD(2, 0) ; + WSADATA wsaData ; + + /* + * initialize service status + */ + + ServiceStatusRecord.dwServiceType = SERVICE_WIN32 | SERVICE_INTERACTIVE_PROCESS ; + ServiceStatusRecord.dwServiceSpecificExitCode = 0 ; + + /* + * register Service Control Handler + */ + + ServiceStatusHandle = RegisterServiceCtrlHandler( + TEXT(SERVICENAME), + (LPHANDLER_FUNCTION) ServiceCtrl) ; + if (ServiceStatusHandle == (SERVICE_STATUS_HANDLE) 0) { + serviceLogError("RegisterServiceCtrlHandler failed") ; + return ; + } + + serviceReport(SERVICE_START_PENDING, NO_ERROR, (30 * 1000)) ; + + /* + * Initialize & Run service + */ + + serviceLogTrace("start initializing") ; + + if (config_load((int) dwArgc, (char **) lpszArgv) != TRUE) { + serviceLogError("cannot initialize server") ; + serviceReport(SERVICE_STOPPED, 0, 0) ; + return ; + } + log_configure((int) dwArgc, (char **) lpszArgv) ; + + if (WSAStartup(version, &wsaData) != 0) { + serviceLogError("cannot initialize WinSock") ; + serviceReport(SERVICE_STOPPED, 0, 0) ; + return ; + } + if (server_init((int) dwArgc, (char **) lpszArgv) != TRUE) { + serviceLogError("cannot initialize server") ; + serviceReport(SERVICE_STOPPED, 0, 0) ; + WSACleanup() ; + return ; + } + + serviceReport(SERVICE_RUNNING, NO_ERROR, 0) ; + + serviceLogTrace("initialization done, running now") ; + + server_loop() ; /* do service here */ + + serviceLogTrace("service loop finished, closing") ; + + serviceReport(SERVICE_STOP_PENDING, NO_ERROR, (10 * 1000)) ; + + server_done() ; /* cleaup */ + WSACleanup() ; + + serviceLogTrace("service finised") ; + + serviceReport(SERVICE_STOPPED, NO_ERROR, 0) ; + + log_terminate() ; +} + +/* + * serviceRun - run Service + */ + +static SERVICE_TABLE_ENTRY ServiceTable[] = { + { TEXT(SERVICENAME), (LPSERVICE_MAIN_FUNCTION) ServiceMain } , + { NULL, NULL } +} ; + +void serviceRun(int ac, char *av[]) +{ + serviceLogTrace("serviceRun - start") ; + + if (StartServiceCtrlDispatcher(ServiceTable) == 0) { + serviceLogError("StartServiceCtrlDispatcher failed") ; + } +} + +/* + * serviceInstall - install service + */ + +void serviceInstall(int ac, char *av[]) +{ + SC_HANDLE hSCManager = NULL ; + SC_HANDLE hService = NULL ; + + getFileName() ; + +#ifdef DEBUG + printf("Install Service %s \"%s\"\n", SERVICENAME, p_ful) ; +#endif + + /* + * open Service Manager + */ + + hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS) ; + + if (hSCManager == NULL) { + printf("cannot open SCManager %d\n", GetLastError()) ; + return ; + } + +#ifdef DEBUG + printf("open SCManager\n") ; fflush(stdout) ; +#endif + + /* + * prepare service path (exe path with arguments) + */ + + sprintf(pathService, "\"%s\" -service", p_ful) ; + +#ifdef DEBUG + printf("Installing %s\n", pathService) ; +#endif + + /* + * create service entry + */ + + hService = CreateService( + hSCManager, /* SCManager database */ + TEXT(SERVICENAME), /* name of service */ + TEXT(DISPLAYNAME), /* its display name */ + SERVICE_ALL_ACCESS, /* desired access */ + SERVICE_WIN32_OWN_PROCESS, /* service type */ + SERVICE_DEMAND_START, /* start type */ + SERVICE_ERROR_IGNORE, /* error control type */ + TEXT(pathService), /* service image */ + NULL, /* no load order */ + NULL, /* no tag identifier */ + NULL, /* no dependencies */ + NULL, /* LocalSystem account */ + NULL) ; /* no password */ + + CloseServiceHandle(hSCManager) ; + + if (hService == NULL) { + printf("cannot create service %d\n", GetLastError()) ; + return ; + } + + CloseServiceHandle(hSCManager) ; + + printf("Installed Service %s\n", pathService) ; +} + +/* + * serviceRemove - remove service + */ + +void serviceRemove(int ac, char *av[]) +{ + SC_HANDLE hSCManager = NULL ; + SC_HANDLE hService = NULL ; + + getFileName() ; + +#ifdef DEBUG + printf("Removing Service %s\n", SERVICENAME) ; +#endif + + /* + * open Service Manager + */ + + hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS) ; + + if (hSCManager == NULL) { + printf("cannot open SCManager %d\n", GetLastError()) ; + return ; + } + +#ifdef DEBUG + printf("open SCManager\n") ; fflush(stdout) ; +#endif + + /* + * delete service + */ + + hService = OpenService( + hSCManager, /* SCManager database */ + TEXT(SERVICENAME), /* name of service */ + DELETE) ; /* type of access */ + + if (hService == NULL) { + printf("cannot open service %s %d\n", SERVICENAME, GetLastError()) ; + CloseServiceHandle(hSCManager) ; + return ; + } + if (DeleteService(hService) == 0) { + printf("cannot remove service %s %d\n", SERVICENAME, GetLastError()) ; + CloseServiceHandle(hService) ; + CloseServiceHandle(hSCManager) ; + return ; + } + + CloseServiceHandle(hService) ; + CloseServiceHandle(hSCManager) ; + + printf("Removed Service %s\n", SERVICENAME) ; +} + +#endif /* WIN32 */ diff --git a/contrib/idn/mdnkit/dnsproxy/winserv.h b/contrib/idn/mdnkit/dnsproxy/winserv.h new file mode 100644 index 0000000000..ded129aec8 --- /dev/null +++ b/contrib/idn/mdnkit/dnsproxy/winserv.h @@ -0,0 +1,72 @@ +/* + * winserv.h - mDNS Proxy, WIN32 Service Specific 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. + */ + +/* $Id: winserv.h,v 1.6 2000/07/04 03:52:29 ishisone Exp $ */ + +#ifndef WINSERV_H +#define WINSERV_H 1 + +void serviceRun(int ac, char *av[]) ; +void serviceInstall(int ac, char *av[]) ; +void serviceRemove(int ac, char *av[]) ; + +#endif /* WINSERV_H */ diff --git a/contrib/idn/mdnkit/include/Makefile.in b/contrib/idn/mdnkit/include/Makefile.in new file mode 100644 index 0000000000..a5c3ad607e --- /dev/null +++ b/contrib/idn/mdnkit/include/Makefile.in @@ -0,0 +1,73 @@ +# $Id: Makefile.in,v 1.1 2000/08/09 07:10:31 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. + +srcdir = @srcdir@ +VPATH = @srcdir@ + +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +SUBDIRS = mdn + +all: + for d in $(SUBDIRS); do (cd $$d; $(MAKE) all); done + +install: + for d in $(SUBDIRS); do (cd $$d; $(MAKE) install); done + +clean: + for d in $(SUBDIRS); do (cd $$d; $(MAKE) clean); done diff --git a/contrib/idn/mdnkit/include/config.h b/contrib/idn/mdnkit/include/config.h new file mode 100644 index 0000000000..c87e3ffbf3 --- /dev/null +++ b/contrib/idn/mdnkit/include/config.h @@ -0,0 +1,123 @@ +/* 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 $ */ +/* + * 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. + */ + +/* Define to `int' if doesn't define. */ +/* #undef gid_t */ + +/* Define if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define to `int' if 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 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 */ + +/* Define if the suffix of BRACE encoding differs from '-8q9'. */ +/* #undef MDN_BRACE_SUFFIX */ + +/* Define if the prefix of LACE encoding differs from 'bq--'. */ +/* #undef MDN_LACE_PREFIX */ + +/* Define as an appropriate type (ex. int) if your system doesn't have. */ +#define BOOL int + +/* Define if you have the bcopy function. */ +#define HAVE_BCOPY 1 + +/* Define if you have the memmove function. */ +#define HAVE_MEMMOVE 1 + +/* Define if you have the nl_langinfo function. */ +#define HAVE_NL_LANGINFO 1 + +/* Define if you have the setlocale function. */ +#define HAVE_SETLOCALE 1 + +/* Define if you have the setvbuf function. */ +#define HAVE_SETVBUF 1 + +/* Define if you have the vsnprintf function. */ +#define HAVE_VSNPRINTF 1 + +/* Define if you have the header file. */ +#define HAVE_LANGINFO_H 1 + +/* Define if you have the header file. */ +#define HAVE_LOCALE_H 1 + +/* Define if you have the header file. */ +#define HAVE_SYS_SELECT_H 1 + +/* Define if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define if you have the nsl library (-lnsl). */ +/* #undef HAVE_LIBNSL */ + +/* Define if you have the socket library (-lsocket). */ +/* #undef HAVE_LIBSOCKET */ diff --git a/contrib/idn/mdnkit/include/config.h.in b/contrib/idn/mdnkit/include/config.h.in new file mode 100644 index 0000000000..4cd1d25505 --- /dev/null +++ b/contrib/idn/mdnkit/include/config.h.in @@ -0,0 +1,122 @@ +/* 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 $ */ +/* + * 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. + */ + +/* Define to `int' if doesn't define. */ +#undef gid_t + +/* Define if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Define to `int' if 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 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 + +/* Define if the suffix of BRACE encoding differs from '-8q9'. */ +#undef MDN_BRACE_SUFFIX + +/* Define if the prefix of LACE encoding differs from 'bq--'. */ +#undef MDN_LACE_PREFIX + +/* Define as an appropriate type (ex. int) if your system doesn't have. */ +#undef BOOL + +/* Define if you have the bcopy function. */ +#undef HAVE_BCOPY + +/* Define if you have the memmove function. */ +#undef HAVE_MEMMOVE + +/* Define if you have the nl_langinfo function. */ +#undef HAVE_NL_LANGINFO + +/* Define if you have the setlocale function. */ +#undef HAVE_SETLOCALE + +/* Define if you have the setvbuf function. */ +#undef HAVE_SETVBUF + +/* Define if you have the vsnprintf function. */ +#undef HAVE_VSNPRINTF + +/* Define if you have the header file. */ +#undef HAVE_LANGINFO_H + +/* Define if you have the header file. */ +#undef HAVE_LOCALE_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_SELECT_H + +/* Define if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Define if you have the nsl library (-lnsl). */ +#undef HAVE_LIBNSL + +/* Define if you have the socket library (-lsocket). */ +#undef HAVE_LIBSOCKET diff --git a/contrib/idn/mdnkit/include/config.h.os2 b/contrib/idn/mdnkit/include/config.h.os2 new file mode 100644 index 0000000000..fd7318dba3 --- /dev/null +++ b/contrib/idn/mdnkit/include/config.h.os2 @@ -0,0 +1,85 @@ +/* $Id: config.h.os2,v 1.3 2000/08/07 08:20:40 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. + */ + +/* Define if you have the vsnprintf function. */ +#undef HAVE_VSNPRINTF + +/* Define if you have the setvbuf function. */ +#undef HAVE_SETVBUF + +/* Define if you have the setlocale function. */ +#undef HAVE_SETLOCALE + +/* Define if you have the nl_langinfo function. */ +#undef HAVE_NL_LANGINFO + +/* Define if you have the header file. */ +#undef HAVE_LANGINFO_H + +/* Define if you have the header file. */ +#undef HAVE_LOCALE_H + +/* Define if you have the header file. */ +#undef HAVE_UNISTD_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 diff --git a/contrib/idn/mdnkit/include/config.h.win b/contrib/idn/mdnkit/include/config.h.win new file mode 100644 index 0000000000..1e18141540 --- /dev/null +++ b/contrib/idn/mdnkit/include/config.h.win @@ -0,0 +1,85 @@ +/* $Id: config.h.win,v 1.3 2000/08/07 08:20:40 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. + */ + +/* Define if you have the vsnprintf function. */ +#undef HAVE_VSNPRINTF + +/* Define if you have the setvbuf function. */ +#undef HAVE_SETVBUF + +/* Define if you have the setlocale function. */ +#undef HAVE_SETLOCALE + +/* Define if you have the nl_langinfo function. */ +#undef HAVE_NL_LANGINFO + +/* Define if you have the header file. */ +#undef HAVE_LANGINFO_H + +/* Define if you have the header file. */ +#undef HAVE_LOCALE_H + +/* Define if you have the header file. */ +#undef HAVE_UNISTD_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 diff --git a/contrib/idn/mdnkit/include/mdn/Makefile.in b/contrib/idn/mdnkit/include/mdn/Makefile.in new file mode 100644 index 0000000000..a7306db1f9 --- /dev/null +++ b/contrib/idn/mdnkit/include/mdn/Makefile.in @@ -0,0 +1,110 @@ +# $Id: Makefile.in,v 1.4 2000/11/14 00:13:29 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. + +srcdir = @srcdir@ +VPATH = @srcdir@ + +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +BINDIR = @bindir@ +LIBDIR = @libdir@ +INCDIR = @includedir@ +MDNINCDIR = $(INCDIR)/mdn + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ + +HDRS = \ + assert.h \ + brace.h \ + converter.h \ + debug.h \ + dn.h \ + lace.h \ + localencoding.h \ + log.h \ + logmacro.h \ + msgheader.h \ + msgtrans.h \ + normalizer.h \ + race.h \ + res.h \ + resconf.h \ + result.h \ + selectiveencode.h \ + strhash.h \ + translator.h \ + unicode.h \ + unormalize.h \ + utf5.h \ + utf8.h \ + util.h \ + zldrule.h + +all: + +install: + [ -d $(INCDIR) ] || mkdir $(INCDIR) + [ -d $(MDNINCDIR) ] || mkdir $(MDNINCDIR) + for hdr in $(HDRS); \ + do $(INSTALL_DATA) $(srcdir)/$$hdr $(MDNINCDIR); done + +clean: + rm -f *~ + diff --git a/contrib/idn/mdnkit/include/mdn/assert.h b/contrib/idn/mdnkit/include/mdn/assert.h new file mode 100644 index 0000000000..6463f1664b --- /dev/null +++ b/contrib/idn/mdnkit/include/mdn/assert.h @@ -0,0 +1,69 @@ +/* $Id: assert.h,v 1.5 2000/07/04 03:52:31 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. + */ + +#ifndef MDN_ASSERT_H +#define MDN_ASSERT_H 1 + +#ifndef DEBUG +#define NDEBUG +#endif + +#include + +# endif /* MDN_ASSERT_H */ diff --git a/contrib/idn/mdnkit/include/mdn/brace.h b/contrib/idn/mdnkit/include/mdn/brace.h new file mode 100644 index 0000000000..da93bc3f3f --- /dev/null +++ b/contrib/idn/mdnkit/include/mdn/brace.h @@ -0,0 +1,82 @@ +/* $Id: brace.h,v 1.1 2000/11/14 00:13:29 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. + */ + +#ifndef MDN_BRACE_H +#define MDN_BRACE_H 1 + +/* + * BRACE Converter. + * + * See Internet Draft draft-ietf-idn-brace-00.txt for details. + */ + +#include +#include + +extern mdn_result_t +mdn__brace_open(mdn_converter_t ctx, mdn_converter_dir_t dir); + +extern mdn_result_t +mdn__brace_close(mdn_converter_t ctx, 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); + +#endif /* MDN_BRACE_H */ diff --git a/contrib/idn/mdnkit/include/mdn/converter.h b/contrib/idn/mdnkit/include/mdn/converter.h new file mode 100644 index 0000000000..dc9705fcf1 --- /dev/null +++ b/contrib/idn/mdnkit/include/mdn/converter.h @@ -0,0 +1,234 @@ +/* $Id: converter.h,v 1.13 2000/08/02 02:06:40 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. + */ + +#ifndef MDN_CONVERTER_H +#define MDN_CONVERTER_H 1 + +/* + * Codeset converter. + * + * This module provides conversions from some local codeset to UTF-8 + * and vice versa. + */ + +#include + +/* + * Converter context type (opaque). + */ +typedef struct mdn_converter *mdn_converter_t; + +/* + * Conversion direction (local codeset -> UTF-8 or the opposite) + */ +typedef enum { + mdn_converter_l2u, /* local-to-utf8 */ + mdn_converter_u2l /* utf8-to-local */ +} mdn_converter_dir_t; + +/* + * Conversion flags. + */ +#define MDN_CONVERTER_DELAYEDOPEN 1 +#define MDN_CONVERTER_RTCHECK 2 + +/* + * 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_converter_initialize(void); + +/* + * Create a conversion context. + * + * Returns: + * mdn_success -- ok. + * mdn_invalid_name -- specified codeset is not supported. + * mdn_nomemory -- malloc failed. + * mdn_failure -- other failure (unknown cause). + */ +extern mdn_result_t +mdn_converter_create(const char *name, mdn_converter_t *ctxp, + int flags); + +/* + * Destroy the conversion context created by mdn_converter_create. + */ +extern void +mdn_converter_destroy(mdn_converter_t ctx); + +/* + * Convert between local codeset and UTF-8. Note that each conversion + * is started with initial state. + * + * Returns: + * mdn_success -- ok. + * mdn_buffer_overflow -- output buffer is too small. + * mdn_invalid_encoding -- the input string has invalid/illegal + * byte sequence. + * mdn_invalid_name -- codeset is not supported (this error + * should happen only if 'delayedopen' + * flag was set when mdn_converter_create + * was called) + * mdn_failure -- other failure. + */ +extern mdn_result_t +mdn_converter_convert(mdn_converter_t ctx, mdn_converter_dir_t dir, + const char *from, char *to, size_t tolen); + +/* + * Macros for convenience. + */ +#define mdn_converter_localtoutf8(ctx, from, to, tolen) \ + mdn_converter_convert((ctx), mdn_converter_l2u, (from), (to), (tolen)) + +#define mdn_converter_utf8tolocal(ctx, from, to, tolen) \ + mdn_converter_convert((ctx), mdn_converter_u2l, (from), (to), (tolen)) + +/* + * Get the name of local codeset. The returned name may be different from + * the one specified to mdn_converter_create, if the specified one was an + * alias. + * + * Returns: + * the local codeset name. + */ +extern char * +mdn_converter_localencoding(mdn_converter_t ctx); + +/* + * Return if this local encoding is a special one that a string in this + * encoding just looks like an ordinary ASCII string. + * A few types of encoding designed specially for domain name conversion + * (such as UTF-5) fall into this category. + * + * Returns: + * 1 -- yes, it is special. + * 0 -- no. + */ +extern int +mdn_converter_isasciicompatible(mdn_converter_t ctx); + +/* + * Register an alias for a codeset name. + * + * Returns: + * mdn_success -- ok. + * mdn_nomemory -- malloc failed. + */ +extern mdn_result_t +mdn_converter_addalias(const char *alias_name, const char *real_name); + +/* + * Register aliases defined by the specified file. + * + * Returns: + * mdn_success -- ok. + * mdn_nofile -- no such file. + * mdn_invalid_syntax -- file is malformed. + * mdn_nomemory -- malloc failed. + */ +extern mdn_result_t +mdn_converter_aliasfile(const char *path); + +/* + * Unregister all the aliases. + */ +extern mdn_result_t +mdn_converter_resetalias(void); + + +/* + * New converter registration. + */ + +/* + * Conversion operation functions. + */ +typedef mdn_result_t (*mdn_converter_openproc_t)(mdn_converter_t ctx, + mdn_converter_dir_t dir); +typedef mdn_result_t (*mdn_converter_closeproc_t)(mdn_converter_t ctx, + mdn_converter_dir_t dir); +typedef mdn_result_t (*mdn_converter_convertproc_t)(mdn_converter_t ctx, + mdn_converter_dir_t dir, + const char *from, + char *to, size_t tolen); + +/* + * Register a new converter. + * 'ascii_compatible' is a boolean flag indicating this encoding is + * an `ascii-compatible encoding'. + * + * Returns: + * mdn_success -- ok. + * mdn_nomemory -- malloc failed. + */ +extern mdn_result_t +mdn_converter_register(const char *name, + mdn_converter_openproc_t open, + mdn_converter_closeproc_t close, + mdn_converter_convertproc_t convert, + int ascii_compatible); + +#endif /* MDN_CONVERTER_H */ diff --git a/contrib/idn/mdnkit/include/mdn/debug.h b/contrib/idn/mdnkit/include/mdn/debug.h new file mode 100644 index 0000000000..e043179be0 --- /dev/null +++ b/contrib/idn/mdnkit/include/mdn/debug.h @@ -0,0 +1,72 @@ +/* $Id: debug.h,v 1.7 2000/07/04 03:52:32 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. + */ + +#ifndef MDN_DEBUG_H +#define MDN_DEBUG_H 1 + +/* + * Debug utility + */ + +extern char *mdn_debug_hexstring(const char *s, int maxbytes); +extern char *mdn_debug_xstring(const char *s, int maxbytes); +extern char *mdn_debug_hexdata(const char *s, int length, int maxlength); +extern void mdn_debug_hexdump(const char *s, int length); + +#endif /* MDN_DEBUG_H */ diff --git a/contrib/idn/mdnkit/include/mdn/dn.h b/contrib/idn/mdnkit/include/mdn/dn.h new file mode 100644 index 0000000000..b275b50b65 --- /dev/null +++ b/contrib/idn/mdnkit/include/mdn/dn.h @@ -0,0 +1,117 @@ +/* $Id: dn.h,v 1.7 2000/08/02 02:06:40 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. + */ + +#ifndef MDN_DN_H +#define MDN_DN_H 1 + +#define MDN_DN_NPTRS 64 + +/* + * Domain name compression/expansion. + * + * The interface this module provides is similar to the standard + * dn_comp and dn_expand, but with a twist. + */ + +#include + +/* + * Compression context. + */ +typedef struct { + const unsigned char *msg; + int cur; + int offset[MDN_DN_NPTRS]; +} mdn__dn_t; + +/* + * Expand a compressed domain name. + * + * It is similar to dn_expand in resolver library. + * + * Returns: + * mdn_success -- ok. + * mdn_buffer_overflow -- 'buflen' is too small. + * mdn_invalid_message -- the specified message is not valid. + */ +extern mdn_result_t +mdn__dn_expand(const char *msg, size_t msglen, const char *compressed, + char *expanded, size_t buflen, size_t *complenp); + +/* + * Initialize compression context. + */ +extern void +mdn__dn_initcompress(mdn__dn_t *ctx, const char *msg); + +/* + * Compress a domain name. + * + * It is similar to dn_comp. + * + * Returns: + * mdn_success -- ok. + * mdn_buffer_overflow -- 'length' is too small. + * mdn_invalid_name -- the specified name is invalid. + */ +extern mdn_result_t +mdn__dn_compress(const char *name, char *sptr, size_t length, + mdn__dn_t *ctx, size_t *complenp); + +#endif /* MDN_DN_H */ diff --git a/contrib/idn/mdnkit/include/mdn/lace.h b/contrib/idn/mdnkit/include/mdn/lace.h new file mode 100644 index 0000000000..1c0e792343 --- /dev/null +++ b/contrib/idn/mdnkit/include/mdn/lace.h @@ -0,0 +1,82 @@ +/* $Id: lace.h,v 1.1 2000/11/14 00:13:29 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. + */ + +#ifndef MDN_LACE_H +#define MDN_LACE_H 1 + +/* + * LACE Converter. + * + * See Internet Draft draft-ietf-idn-lace-00.txt for details. + */ + +#include +#include + +extern mdn_result_t +mdn__lace_open(mdn_converter_t ctx, mdn_converter_dir_t dir); + +extern mdn_result_t +mdn__lace_close(mdn_converter_t ctx, mdn_converter_dir_t dir); + +extern mdn_result_t +mdn__lace_convert(mdn_converter_t ctx, 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/localencoding.h b/contrib/idn/mdnkit/include/mdn/localencoding.h new file mode 100644 index 0000000000..3cefe4818a --- /dev/null +++ b/contrib/idn/mdnkit/include/mdn/localencoding.h @@ -0,0 +1,85 @@ +/* $Id: localencoding.h,v 1.7 2000/08/02 02:06:40 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. + */ + +#ifndef MDN_LOCALENCODING_H +#define MDN_LOCALENCODING_H 1 + +/* + * Local codeset detection. + * + * Determine the local codeset (the codeset used by the current application), + * based on the locale information. + */ + +#define MDN_LOCALCS_ENV "MDN_LOCAL_CODESET" + +/* + * Get the codeset name corresponding to the current locale, + * suitable for passing to 'mdn_converter_create'. + * + * If the codeset cannot be determined, the locale name itself + * will be returned in the hope that codeset alias file translates it + * to the right name. + * + * If it cannot retrieve the current locale name, NULL will be + * returned. + */ +extern const char *mdn_localencoding_name(void); + +#endif /* MDN_LOCALENCODING_H */ diff --git a/contrib/idn/mdnkit/include/mdn/log.h b/contrib/idn/mdnkit/include/mdn/log.h new file mode 100644 index 0000000000..2360fcc94f --- /dev/null +++ b/contrib/idn/mdnkit/include/mdn/log.h @@ -0,0 +1,113 @@ +/* $Id: log.h,v 1.9 2000/10/16 05:00:17 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. + */ + +#ifndef MDN_LOG_H +#define MDN_LOG_H 1 + +/* + * MDN library logging facility. + */ + +/* + * Log level definition. + */ +enum { + mdn_log_level_fatal = 0, + mdn_log_level_error = 1, + mdn_log_level_warning = 2, + mdn_log_level_info = 3, + mdn_log_level_trace = 4, + mdn_log_level_dump = 5 +}; + +/* + * Log handler type. + */ +typedef void (*mdn_log_proc_t)(int level, const char *msg); + +/* + * Log routines. + */ +extern void mdn_log_fatal(const char *fmt, ...); +extern void mdn_log_error(const char *fmt, ...); +extern void mdn_log_warning(const char *fmt, ...); +extern void mdn_log_info(const char *fmt, ...); +extern void mdn_log_trace(const char *fmt, ...); +extern void mdn_log_dump(const char *fmt, ...); + +/* + * Set/get log level. + * + * If log level has not been explicitly defined by 'mdn_log_setlevel', + * the default level is determined by the value of enrironment + * variable 'MDN_LOG_LEVEL'. + */ +extern void mdn_log_setlevel(int level); +extern int mdn_log_getlevel(void); + +/* + * Set log handler. + * + * If no log handler is set, log goes to stderr by default. + * You can reset the handler to the default one by specifying + * NULL. + */ +extern void mdn_log_setproc(mdn_log_proc_t proc); + +#endif /* MDN_LOG_H */ diff --git a/contrib/idn/mdnkit/include/mdn/logmacro.h b/contrib/idn/mdnkit/include/mdn/logmacro.h new file mode 100644 index 0000000000..df4385effc --- /dev/null +++ b/contrib/idn/mdnkit/include/mdn/logmacro.h @@ -0,0 +1,80 @@ +/* $Id: logmacro.h,v 1.9 2000/09/20 02:47:29 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. + */ + +#ifndef MDN_LOGMACRO_H +#define MDN_LOGMACRO_H 1 + +#include + +#define FATAL(x) mdn_log_fatal x +#define ERROR(x) mdn_log_error x +#define WARNING(x) mdn_log_warning x +#define INFO(x) mdn_log_info x + +#ifdef DEBUG +#define TRACE(x) mdn_log_trace x +#define DUMP(x) mdn_log_dump x +#else +#define TRACE(x) +#define DUMP(x) +#endif /* DEBUG */ + +#define LOGLEVEL mdn_log_getlevel() + +#endif /* MDN_LOGMACRO_H */ diff --git a/contrib/idn/mdnkit/include/mdn/msgheader.h b/contrib/idn/mdnkit/include/mdn/msgheader.h new file mode 100644 index 0000000000..1135970026 --- /dev/null +++ b/contrib/idn/mdnkit/include/mdn/msgheader.h @@ -0,0 +1,113 @@ +/* $Id: msgheader.h,v 1.7 2000/08/02 02:06:40 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. + */ + +#ifndef MDN_MSGHEADER_H +#define MDN_MSGHEADER_H 1 + +/* + * DNS message header parsing/construction. + */ + +#include + +/* + * Parsed DNS message header. + */ +typedef struct mdn_msgheader { + unsigned int id; + int qr; + int opcode; + int flags; + int rcode; + unsigned int qdcount; + unsigned int ancount; + unsigned int nscount; + unsigned int arcount; +} mdn_msgheader_t; + +/* + * Parse DNS message header into mdn_msgheader_t type. + * + * Returns: + * mdn_success -- ok. + * mdn_invalid_message -- message is too short. + */ +extern mdn_result_t +mdn_msgheader_parse(const char *msg, size_t msglen, mdn_msgheader_t *parsed); + +/* + * Pack mdn_msgheader_t data. + * + * Returns: + * mdn_success -- ok. + * mdn_buffer_overflow -- output buffer is too small. + */ +extern mdn_result_t +mdn_msgheader_unparse(mdn_msgheader_t *parsed, char *msg, size_t msglen); + +/* + * Convenient functions. + * + * They do not check the length of the message. Caller must make sure + * the message is not smaller than the header size (12 octets). + */ +extern unsigned int mdn_msgheader_getid(const char *msg); +extern void mdn_msgheader_setid(char *msg, unsigned int id); + +#endif /* MDN_MSGHEADER_H */ diff --git a/contrib/idn/mdnkit/include/mdn/msgtrans.h b/contrib/idn/mdnkit/include/mdn/msgtrans.h new file mode 100644 index 0000000000..f99f511c6c --- /dev/null +++ b/contrib/idn/mdnkit/include/mdn/msgtrans.h @@ -0,0 +1,130 @@ +/* $Id: msgtrans.h,v 1.11 2000/11/21 02:09:04 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. + */ + +#ifndef MDN_MSGTRANS_H +#define MDN_MSGTRANS_H 1 + +/* + * DNS message translator. + * + * Parse a DNS message, translate each domain name in it according + * to a rule, and rebuild a message with the translated domain names. + */ + +#include +#include +#include +#include + +/* + * 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; + +/* + * Translate DNS message according to the parameters given. + * + * 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, + const char *msg, size_t msglen, + char *outbuf, size_t outbufsize, size_t *outmsglenp); + +#endif /* MDN_MSGTRANS_H */ diff --git a/contrib/idn/mdnkit/include/mdn/normalizer.h b/contrib/idn/mdnkit/include/mdn/normalizer.h new file mode 100644 index 0000000000..07b9cfdc20 --- /dev/null +++ b/contrib/idn/mdnkit/include/mdn/normalizer.h @@ -0,0 +1,151 @@ +/* $Id: normalizer.h,v 1.11 2000/08/23 05:52:40 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. + */ + +#ifndef MDN_NORMALIZER_H +#define MDN_NORMALIZER_H 1 + +/* + * Domain name normalizer. + * + * Perform normalization on the specified strings. String must be + * in UTF-8 encoding. + */ + +#include + +/* + * Normalizer type (opaque). + */ +typedef struct mdn_normalizer *mdn_normalizer_t; + +/* + * Normalizer procedure type. + */ +typedef mdn_result_t (*mdn_normalizer_proc_t)(const char *from, + char *to, size_t tolen); + +/* + * Initialize this module. + * + * Returns: + * mdn_success -- ok. + * mdn_nomemory -- malloc failed. + */ +extern mdn_result_t +mdn_normalizer_initialize(void); + +/* + * Create a empty normalizer. + * + * Returns: + * mdn_success -- ok. + * mdn_nomemory -- malloc failed. + */ +extern mdn_result_t +mdn_normalizer_create(mdn_normalizer_t *ctxp); + +/* + * Release all the memory allocated for a normalizer created by + * 'mdn_normalizer_create'. + */ +extern void +mdn_normalizer_destroy(mdn_normalizer_t ctx); + +/* + * Add a normalization scheme to a normalizer. + * + * Multiple shemes can be added to a normalizer, and they will be + * applied in order. + * + * Returns: + * mdn_success -- ok. + * mdn_invalid_name -- unknown scheme was specified. + * mdn_nomemory -- malloc failed. + */ +extern mdn_result_t +mdn_normalizer_add(mdn_normalizer_t ctx, const char *scheme_name); + +/* + * Perform normalization(s) defined by a normalizer to the specified string, + * If the normalizer has two or more normalization schemes, they are + * applied in order. + * + * Returns: + * 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. + */ +extern mdn_result_t +mdn_normalizer_normalize(mdn_normalizer_t ctx, const char *from, + char *to, size_t tolen); + +/* + * Register a new normalization scheme. + * + * You can override the default normalization schemes, if you want. + * + * Returns: + * mdn_success -- ok. + * mdn_nomemory -- malloc failed. + */ +extern mdn_result_t +mdn_normalizer_register(const char *scheme_name, mdn_normalizer_proc_t proc); + +#endif /* MDN_NORMALIZER_H */ diff --git a/contrib/idn/mdnkit/include/mdn/race.h b/contrib/idn/mdnkit/include/mdn/race.h new file mode 100644 index 0000000000..9b83d9aa18 --- /dev/null +++ b/contrib/idn/mdnkit/include/mdn/race.h @@ -0,0 +1,82 @@ +/* $Id: race.h,v 1.8 2000/10/18 02:15:28 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. + */ + +#ifndef MDN_RACE_H +#define MDN_RACE_H 1 + +/* + * RACE Converter. + * + * See Internet Draft draft-ietf-idn-race-02.txt for details. + */ + +#include +#include + +extern mdn_result_t +mdn__race_open(mdn_converter_t ctx, mdn_converter_dir_t dir); + +extern mdn_result_t +mdn__race_close(mdn_converter_t ctx, 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); + +#endif /* MDN_RACE_H */ diff --git a/contrib/idn/mdnkit/include/mdn/res.h b/contrib/idn/mdnkit/include/mdn/res.h new file mode 100644 index 0000000000..011b1f0e71 --- /dev/null +++ b/contrib/idn/mdnkit/include/mdn/res.h @@ -0,0 +1,203 @@ +/* $Id: res.h,v 1.3 2000/08/23 06:56:58 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. + */ + +#ifndef MDN_RES_H +#define MDN_RES_H 1 + +/* + * Resolver library support. + * + * All the functions provided by this module requires MDN resolver + * configuration context of type 'mdn_resconf_t' as an argument. + * This context holds information described in the configuration file + * (mdnres.conf). See mdn_resconf module for details. + * + * All functions also accept NULL as the context, but since + * no conversion/normalization will be done in this case, it is + * pretty useless. + */ + +#include +#include + +/* + * 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. + * + * 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. + */ +extern mdn_result_t +mdn_res_localtoucs(mdn_resconf_t conf, const char *local_name, + char *ucs_name, size_t ucs_name_len); + +/* + * 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. + */ +extern mdn_result_t +mdn_res_ucstolocal(mdn_resconf_t conf, const char *ucs_name, + char *local_name, size_t local_name_len); + +/* + * 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. + */ +extern mdn_result_t +mdn_res_normalize(mdn_resconf_t conf, const char *name, + char *normalized_name, size_t normalized_name_len); + +/* + * 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. + */ +extern mdn_result_t +mdn_res_ucstodns(mdn_resconf_t conf, const char *ucs_name, char *dns_name, + size_t dns_name_len); + +/* + * 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. + */ +extern mdn_result_t +mdn_res_dnstoucs(mdn_resconf_t conf, const char *dns_name, char *ucs_name, + size_t ucs_name_len); + +#endif diff --git a/contrib/idn/mdnkit/include/mdn/resconf.h b/contrib/idn/mdnkit/include/mdn/resconf.h new file mode 100644 index 0000000000..1f9747becc --- /dev/null +++ b/contrib/idn/mdnkit/include/mdn/resconf.h @@ -0,0 +1,173 @@ +/* $Id: resconf.h,v 1.4 2000/08/23 05:53:23 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. + */ + +#ifndef MDN_RESCONF_H +#define MDN_RESCONF_H 1 + +/* + * MDN resolver configuration. + */ + +#include +#include +#include + +/* + * Configuration type (opaque). + */ +typedef struct mdn_resconf *mdn_resconf_t; + +/* + * Initialize. + * + * Initialize this module and underlying ones. Must be called before + * any other functions of this module. + * + * Returns: + * mdn_success -- ok. + * mdn_nomemory -- malloc failed. + */ +extern mdn_result_t +mdn_resconf_initialize(void); + +/* + * Create a configuration context. + * + * Create an empty context and store it in '*ctxp'. + * + * Returns: + * mdn_success -- ok. + * mdn_nomemory -- malloc failed. + */ +extern mdn_result_t +mdn_resconf_create(mdn_resconf_t *ctxp); + +/* + * Destroy the configuration context. + * + * Destroy the configuration context created by 'mdn_resconf_create', + * and release memory for it. + */ +extern void +mdn_resconf_destroy(mdn_resconf_t ctx); + +/* + * Load configuration file. + * + * Parse an MDN configuration file whose name is specified by 'file', + * store the result in 'ctx'. If 'file' is NULL, the default file is + * loaded. + * + * Returns: + * mdn_success -- ok. + * mdn_nofile -- couldn't open specified file. + * mdn_invalid_syntax -- syntax error found. + * mdn_invalid_name -- invalid encoding/nomalization name is + * specified. + * mdn_nomemory -- malloc failed. + */ +extern mdn_result_t +mdn_resconf_loadfile(mdn_resconf_t ctx, const char *file); + +/* + * Get the pathname of the default configuration file. + * + * Returns: + * the pathname of the default MDN configuration file. + */ +extern char * +mdn_resconf_defaultfile(void); + +/* + * Get codeset converters. + * + * + for local encoding, + * + for DNS protocol 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) + * In case of error, NULL will be returned. + */ + +extern mdn_converter_t +mdn_resconf_localconverter(mdn_resconf_t ctx); + +extern mdn_converter_t +mdn_resconf_serverconverter(mdn_resconf_t ctx); + +extern mdn_converter_t +mdn_resconf_alternateconverter(mdn_resconf_t ctx); + +/* + * Get Zero-Level-Domain name. + * + * If there's no ZLD, NULL will be returned. + */ +extern const char * +mdn_resconf_zld(mdn_resconf_t ctx); + +/* + * Get domain name normalizer. + * + * In case of error, NULL will be returned. + */ +extern mdn_normalizer_t +mdn_resconf_normalizer(mdn_resconf_t ctx); + +#endif diff --git a/contrib/idn/mdnkit/include/mdn/result.h b/contrib/idn/mdnkit/include/mdn/result.h new file mode 100644 index 0000000000..47a2f8c38a --- /dev/null +++ b/contrib/idn/mdnkit/include/mdn/result.h @@ -0,0 +1,88 @@ +/* $Id: result.h,v 1.10 2000/09/27 02:55:37 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. + */ + +#ifndef MDN_RESULT_H +#define MDN_RESULT_H 1 + +/* + * MDN library result code. + */ +typedef enum { + mdn_success, + mdn_notfound, + mdn_invalid_encoding, + mdn_invalid_syntax, + mdn_invalid_name, + mdn_invalid_message, + mdn_buffer_overflow, + mdn_noentry, + mdn_nomemory, + mdn_nofile, + mdn_nomapping, + mdn_context_required, + mdn_failure /* !!This must be the last one!! */ +} mdn_result_t; + +/* + * Get the string description of a result code. + */ +extern char * +mdn_result_tostring(mdn_result_t result); + +#endif /* MDN_RESULT_H */ diff --git a/contrib/idn/mdnkit/include/mdn/selectiveencode.h b/contrib/idn/mdnkit/include/mdn/selectiveencode.h new file mode 100644 index 0000000000..47b4efd522 --- /dev/null +++ b/contrib/idn/mdnkit/include/mdn/selectiveencode.h @@ -0,0 +1,85 @@ +/* $Id: selectiveencode.h,v 1.8 2000/08/02 02:06:40 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. + */ + +#ifndef MDN_SELECTIVENCODE_H +#define MDN_SELECTIVENCODE_H 1 + +/* + * Find where to convert. + * + * Find a substring for which MDN domain name codeset conversion is necessary. + */ + +#include + +/* + * Scan the given string 's' (in UTF-8 encoding) looking for a substring + * made of + * + at least one non-ascii character and + * + zero or more legitimate domain-name characters (i.e. ascii alphabets, + * digits and hyphens) and periods. + * + * Returns: + * mdn_success -- ok, found. + * mdn_notfound -- not found. + */ +extern mdn_result_t +mdn_selectiveencode_findregion(const char *s, char **startp, char **endp); + +#endif /* MDN_SELECTIVENCODE_H */ diff --git a/contrib/idn/mdnkit/include/mdn/strhash.h b/contrib/idn/mdnkit/include/mdn/strhash.h new file mode 100644 index 0000000000..3fd7ef8ede --- /dev/null +++ b/contrib/idn/mdnkit/include/mdn/strhash.h @@ -0,0 +1,131 @@ +/* $Id: strhash.h,v 1.9 2000/08/02 02:06:40 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. + */ + +#ifndef MDN_STRHASH_H +#define MDN_STRHASH_H 1 + +/* + * String-keyed hash table + * + * Just a hash table. Nothing special. Number of hash buckets + * grows automatically. + */ + +#include + +/* + * Hash table type, which is opaque. + */ +typedef struct mdn_strhash *mdn_strhash_t; + +/* + * Hash value free proc. + */ +typedef void (*mdn_strhash_freeproc_t)(void *value); + +/* + * Create a hash table. + * + * Returns: + * mdn_success -- ok. + * mdn_nomemory -- malloc failed. + */ +extern mdn_result_t +mdn_strhash_create(mdn_strhash_t *hashp); + +/* + * Delete a hash table created by 'mdn_strhash_create'. + * If 'proc' is not NULL, it is called for each value in the + * hash to release memory for them. + */ +extern void +mdn_strhash_destroy(mdn_strhash_t hash, mdn_strhash_freeproc_t proc); + +/* + * Register an item to the hash table. This function makes a + * private copy of the key string. + * + * Returns: + * mdn_success -- ok. + * mdn_nomemory -- malloc failed. + */ +extern mdn_result_t +mdn_strhash_put(mdn_strhash_t hash, const char *key, void *value); + +/* + * Find an item with the specified key. + * + * Returns: + * mdn_success -- ok. found. + * mdn_noentry -- not found. + */ +extern mdn_result_t +mdn_strhash_get(mdn_strhash_t hash, const char *key, void **valuep); + +/* + * Check if an item with the specified key exists. + * + * Returns: + * 1 -- yes. + * 0 -- no. + */ +extern int +mdn_strhash_exists(mdn_strhash_t hash, const char *key); + +#endif /* MDN_STRHASH_H */ diff --git a/contrib/idn/mdnkit/include/mdn/translator.h b/contrib/idn/mdnkit/include/mdn/translator.h new file mode 100644 index 0000000000..cdb5c4e402 --- /dev/null +++ b/contrib/idn/mdnkit/include/mdn/translator.h @@ -0,0 +1,127 @@ +/* $Id: translator.h,v 1.10 2000/11/21 02:09:04 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. + */ + +#ifndef MDN_TRANSLATOR_H +#define MDN_TRANSLATOR_H 1 + +/* + * Domain name ZLD/codeset translator. + */ + +#include +#include +#include + +/* + * 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); + +/* + * 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); + +/* + * 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); + +#endif /* MDN_TRANSLATOR_H */ diff --git a/contrib/idn/mdnkit/include/mdn/unicode.h b/contrib/idn/mdnkit/include/mdn/unicode.h new file mode 100644 index 0000000000..ff3a76cb03 --- /dev/null +++ b/contrib/idn/mdnkit/include/mdn/unicode.h @@ -0,0 +1,193 @@ +/* $Id: unicode.h,v 1.9 2000/09/27 02:55:37 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. + */ + +#ifndef MDN_UNICODE_H +#define MDN_UNICODE_H 1 + +/* + * Unicode attributes retriever. + * + * All the information this module provides is based on UnicodeData.txt, + * CompositionExclusions-1.txt and SpecialCasing.txt, all of which can be + * obtained from unicode.org. + * + * Unicode characters are represented as 'unsigned long'. + */ + +#include + +/* + * Context information for case conversion. + */ +typedef enum { + mdn__unicode_context_unknown, + mdn__unicode_context_final, + mdn__unicode_context_nonfinal +} mdn__unicode_context_t; + +/* + * Get canonical class. + * + * For characters out of unicode range (i.e. above 0xffff), 0 will + * be returned. + */ +extern int +mdn__unicode_canonicalclass(unsigned long c); + +/* + * Decompose a character. + * + * Decompose character given by 'c', and put the result into 'v', + * which can hold 'vlen' characters. The number of decomposed characters + * will be stored in '*decomp_lenp'. + * + * If 'compat' is true, compatibility decomposition is performed. + * Otherwise canonical decomposition is done. + * + * Since decomposition is done recursively, no further decomposition + * will be needed. + * + * Returns: + * mdn_success -- ok, decomposed. + * mdn_notfound -- no decomposition possible. + * mdn_buffer_overflow -- 'vlen' is too small. + */ +extern mdn_result_t +mdn__unicode_decompose(int compat, unsigned long *v, size_t vlen, + unsigned long c, int *decomp_lenp); + +/* + * Perform canonical composition. + * + * Do canonical composition to the character sequence 'c1' and 'c2', put the + * result into '*compp'. + * + * Since Unicode Nomalization Froms requires only canonical composition, + * compatibility composition is not supported. + * + * Returns: + * mdn_success -- ok, composed. + * mdn_notfound -- no composition possible. + */ +extern mdn_result_t +mdn__unicode_compose(unsigned long c1, unsigned long c2, unsigned long *compp); + +/* + * Returns if there may be a canonical composition sequence which starts + * with the given character. + * + * Returns: + * 1 -- there may be a composition sequence + * (maybe not). + * 0 -- no, there is definitely no such sequences. + */ +extern int +mdn__unicode_iscompositecandidate(unsigned long c); + +/* + * Translate lowercase character to uppercase, and vice versa, according + * to Unicode Technical Report #21 "Case Mappings". + * + * Both functions perform conversion on the given unicode character 'c', + * put the result into 'v', whose size is specified by 'vlen'. The actual + * number of characters stored in 'v' are returned as '*convlenp'. + * In case 'c' has no mapping, 'v[0]' will contain 'c', and '*convlenp' + * will be 1. + * + * Note that these functions perform locale-independent case conversion. + * + * There are some characters whose case mapping depends on the context. + * 'ctx' specifies the context, which can be obtained by + * 'mdn__unicode_getcontext'. Most of the time you can just specify + * 'mdn__unicode_context_unknown' as 'ctx', and if those functions + * return 'mdn_context_required', you can get the context using + * 'mdn__unicode_getcontext' and try again. + * + * Returns: + * mdn_success -- successfully converted. + * mdn_context_required -- context information is needed to + * perform case conversion on 'c'. + * mdn_buffer_overflow -- 'vlen' is too small. + */ +extern mdn_result_t +mdn__unicode_toupper(unsigned long c, mdn__unicode_context_t ctx, + unsigned long *v, size_t vlen, int *convlenp); +extern mdn_result_t +mdn__unicode_tolower(unsigned long c, mdn__unicode_context_t ctx, + unsigned long *v, size_t vlen, int *convlenp); + +/* + * Determine the context needed by the case conversion functions. + * + * Case conversion functions above needs context information for some + * characters. To get the context, you should call this function with + * the next character as the parameter. If you get final or nonfinal, + * you're done. If you get unknown, move on to the next character until + * you get final or nonfinal. + * + * Returns: + * mdn__unicode_context_final -- context is 'FINAL'. + * mdn__unicode_context_nonfinal -- context is 'NON_FINAL'. + * mdn__unicode_context_unknown -- context cannot be determined, + * try the next character. + */ +extern mdn__unicode_context_t +mdn__unicode_getcontext(unsigned long c); + +#endif diff --git a/contrib/idn/mdnkit/include/mdn/unormalize.h b/contrib/idn/mdnkit/include/mdn/unormalize.h new file mode 100644 index 0000000000..c5d2f39370 --- /dev/null +++ b/contrib/idn/mdnkit/include/mdn/unormalize.h @@ -0,0 +1,100 @@ +/* $Id: unormalize.h,v 1.9 2000/08/02 02:06:41 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. + */ + +#ifndef MDN_UNORMALIZE_H +#define MDN_UNORMALIZE_H 1 + +/* + * Unicode Normalizations. + * + * Perform 4 normalizations defined by 'Unicode Normalization Forms' + * (http://www.unicode.org/unicode/reports/tr15) + * + * All of the functions use UTF-8 encoding for input/output. + */ + +#include + +/* + * Perform Unicode Normalication Form C, D, KC and KD. + * + * They take NUL-terminated UTF-8 encoded string 'from', perform + * the normalization, put the result (also a NUL-terminated UTF-8 + * encoded string) to 'to', which must be able to hold at least + * 'tolen' bytes. + * + * Returns: + * mdn_success -- ok. + * mdn_nomemory -- malloc failed. + * mdn_invalid_encoding -- input text is not a valid UTF-8 string. + * mdn_buffer_overflow -- 'tolen' is too small. + */ +extern mdn_result_t +mdn__unormalize_formc(const char *from, char *to, size_t tolen); + +extern mdn_result_t +mdn__unormalize_formd(const char *from, char *to, size_t tolen); + +extern mdn_result_t +mdn__unormalize_formkc(const char *from, char *to, size_t tolen); + +extern mdn_result_t +mdn__unormalize_formkd(const char *from, char *to, size_t tolen); + +#endif /* MDN_UNORMALIZE_H */ diff --git a/contrib/idn/mdnkit/include/mdn/utf5.h b/contrib/idn/mdnkit/include/mdn/utf5.h new file mode 100644 index 0000000000..79974720c9 --- /dev/null +++ b/contrib/idn/mdnkit/include/mdn/utf5.h @@ -0,0 +1,96 @@ +/* $Id: utf5.h,v 1.7 2000/07/04 03:52:33 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. + */ + +#ifndef MDN_UTF5_H +#define MDN_UTF5_H 1 + +/* + * UTF-5 encoded string facility. + */ + +/* + * Get one character. + * + * Get the first character of the UTF-5 string pointed by 's', translate + * it into UCS-4 (an unsigned log value), and store it to '*vp'. + * + * It returns the number of bytes read, or zero if the encoding is invalid. + * + * This routine treats period (".") specially, that is, "." is recognized + * as a valid UTF-5 sequence which translated into itself. This is very + * convenient when converting domain names, but you should note that + * "." is NOT a valid byte in UTF-5 encoded sequece. + */ +extern int +mdn_utf5_getwc(const char *s, size_t len, unsigned long *vp); + +/* + * Put one character. + * + * This function is an opposite of 'mdn_utf8_getwc'. It takes a UCS-4 + * value 'v', convert it to UTF-5 encoded sequence, and store it to 's', + * whose length is 'len'. It returns the number of bytes written, or + * zero 'v' is out of range or 'len' is too small. + * + * The above note regarding "." also applies to this function. + */ +extern int +mdn_utf5_putwc(char *s, size_t len, unsigned long v); + +#endif /* MDN_UTF5_H */ diff --git a/contrib/idn/mdnkit/include/mdn/utf8.h b/contrib/idn/mdnkit/include/mdn/utf8.h new file mode 100644 index 0000000000..48c090fbba --- /dev/null +++ b/contrib/idn/mdnkit/include/mdn/utf8.h @@ -0,0 +1,143 @@ +/* $Id: utf8.h,v 1.8 2000/08/14 07:26:59 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. + */ + +#ifndef MDN_UTF8_H +#define MDN_UTF8_H 1 + +/* + * UTF-8 encoded string facility. + */ + +/* + * Get the length of a character. + * + * Get the length (in bytes) of a character whose first byte is pointed + * by 's'. Since this function only looks one first byte to determine the + * length, it is possible some of the following bytes are invalid. + */ +extern int +mdn_utf8_mblen(const char *s); + +/* + * Get one character. + * + * Get the first character of the string pointed by 's', and copy it + * to 'buf', whose length is 'len'. Returns the number of bytes copied, + * or zero if the encoding is invalid or len is too small. + * + * The area pointed by 'buf' must be large enough to store any UTF-8 encoded + * character. + * + * Note that the copied string is not NUL-terminated. + */ +extern int +mdn_utf8_getmb(const char *s, size_t len, char *buf); + +/* + * Get one character in UCS-4. + * + * Similar to 'mdn_utf8_getmb', except that the result is not in UTF-8 + * encoding, but in UCS-4 format (plain 32bit integer value). + */ +extern int +mdn_utf8_getwc(const char *s, size_t len, unsigned long *vp); + +/* + * Put one character. + * + * This function is an opposite of 'mdn_utf8_getwc'. It takes a UCS-4 + * value 'v', convert it to UTF-8 encoded sequence, and store it to 's', + * whose length is 'len'. It returns the number of bytes written, or + * zero 'v' is out of range or 'len' is too small. + */ +extern int +mdn_utf8_putwc(char *s, size_t len, unsigned long v); + +/* + * Check the validity of UTF-8 encoded character. + * + * Check if the character pointed by 's' is a valid UTF-8 encoded + * character. Return the length of the character (in bytes) if it is valid, + * 0 otherwise. + */ +extern int +mdn_utf8_isvalidchar(const char *s); + +/* + * Check the validity of UTF-8 encoded string. + * + * Check if the NUL-terminated string 's' is valid as a UTF-8 encoded + * string. Return 1 if it is valid, 0 otherwise. + */ +extern int +mdn_utf8_isvalidstring(const char *s); + +/* + * Find first byte of a character. + * + * Find the first byte of a character 's' points to. 's' may point + * the 2nd or later byte of a character. 'known_top' is a pointer to + * a string which contains 's', and is known to be the first byte of + * a character. If it couldn't find the first byte between 'known_top' + * and 's', NULL will be returned. + */ +extern char * +mdn_utf8_findfirstbyte(const char *s, const char *known_top); + +#endif /* MDN_UTF8_H */ diff --git a/contrib/idn/mdnkit/include/mdn/util.h b/contrib/idn/mdnkit/include/mdn/util.h new file mode 100644 index 0000000000..41b0826360 --- /dev/null +++ b/contrib/idn/mdnkit/include/mdn/util.h @@ -0,0 +1,101 @@ +/* $Id: util.h,v 1.2 2000/11/14 00:15:35 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. + */ + +#ifndef MDN_UTIL_H +#define MDN_UTIL_H 1 + +/* + * Utility functions. + */ + +/* + * Case-insensitive string match. + * + * This function compares two strings in case-insensitive way, like + * strcasencmp() function which can be found in many systems. + * However, this function only disregards the case difference of ASCII + * letters ([A-Za-z]), so it is locale independent. + * The result is 1 if 's1' and 's2' match, 0 otherwise. + */ +extern int +mdn_util_casematch(const char *s1, const char *s2, size_t n); + +/* + * Get a range of valid domain name characters. + * + * This function sees each character in string 's' until 'end', + * and checks if it is valid as a character in ASCII domain names. + * It returns a pointer to the first invalid character, or 'end' + * if all characters are valid. + */ +extern const char * +mdn_util_domainspan(const char *s, const char *end); + +/* + * UTF-8 to UTF-16 conversion and vice versa. + */ +extern mdn_result_t +mdn_util_utf8toutf16(const char *utf8, size_t fromlen, + unsigned short *utf16, size_t tolen, size_t *reslenp); + +extern mdn_result_t +mdn_util_utf16toutf8(const unsigned short *utf16, size_t fromlen, + char *utf8, size_t tolen, size_t *reslenp); + +#endif /* MDN_UTIL_H */ diff --git a/contrib/idn/mdnkit/include/mdn/zldrule.h b/contrib/idn/mdnkit/include/mdn/zldrule.h new file mode 100644 index 0000000000..3a5de7563c --- /dev/null +++ b/contrib/idn/mdnkit/include/mdn/zldrule.h @@ -0,0 +1,128 @@ +/* $Id: zldrule.h,v 1.8 2000/08/02 02:06:41 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. + */ + +#ifndef MDN_ZLDRULE_H +#define MDN_ZLDRULE_H 1 + +/* + * ZLD matcher. + * + * 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. + */ + +#include +#include + +/* + * 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); + +/* + * 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); + +/* + * 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); + +#endif /* MDN_ZLDRULE_H */ diff --git a/contrib/idn/mdnkit/install-sh b/contrib/idn/mdnkit/install-sh new file mode 100644 index 0000000000..ebc66913e9 --- /dev/null +++ b/contrib/idn/mdnkit/install-sh @@ -0,0 +1,250 @@ +#! /bin/sh +# +# install - install a program, script, or datafile +# This comes from X11R5 (mit/util/scripts/install.sh). +# +# Copyright 1991 by the Massachusetts Institute of Technology +# +# Permission to use, copy, modify, distribute, and sell this software and its +# documentation for any purpose is hereby granted without fee, provided that +# the above copyright notice appear in all copies and that both that +# copyright notice and this permission notice appear in supporting +# documentation, and that the name of M.I.T. not be used in advertising or +# publicity pertaining to distribution of the software without specific, +# written prior permission. M.I.T. makes no representations about the +# suitability of this software for any purpose. It is provided "as is" +# without express or implied warranty. +# +# Calling this script install-sh is preferred over install.sh, to prevent +# `make' implicit rules from creating a file called install from it +# when there is no Makefile. +# +# This script is compatible with the BSD install script, but was written +# from scratch. It can only install one file at a time, a restriction +# shared with many OS's install programs. + + +# set DOITPROG to echo to test this script + +# Don't use :- since 4.3BSD and earlier shells don't like it. +doit="${DOITPROG-}" + + +# put in absolute paths if you don't have them in your path; or use env. vars. + +mvprog="${MVPROG-mv}" +cpprog="${CPPROG-cp}" +chmodprog="${CHMODPROG-chmod}" +chownprog="${CHOWNPROG-chown}" +chgrpprog="${CHGRPPROG-chgrp}" +stripprog="${STRIPPROG-strip}" +rmprog="${RMPROG-rm}" +mkdirprog="${MKDIRPROG-mkdir}" + +transformbasename="" +transform_arg="" +instcmd="$mvprog" +chmodcmd="$chmodprog 0755" +chowncmd="" +chgrpcmd="" +stripcmd="" +rmcmd="$rmprog -f" +mvcmd="$mvprog" +src="" +dst="" +dir_arg="" + +while [ x"$1" != x ]; do + case $1 in + -c) instcmd="$cpprog" + shift + continue;; + + -d) dir_arg=true + shift + continue;; + + -m) chmodcmd="$chmodprog $2" + shift + shift + continue;; + + -o) chowncmd="$chownprog $2" + shift + shift + continue;; + + -g) chgrpcmd="$chgrpprog $2" + shift + shift + continue;; + + -s) stripcmd="$stripprog" + shift + continue;; + + -t=*) transformarg=`echo $1 | sed 's/-t=//'` + shift + continue;; + + -b=*) transformbasename=`echo $1 | sed 's/-b=//'` + shift + continue;; + + *) if [ x"$src" = x ] + then + src=$1 + else + # this colon is to work around a 386BSD /bin/sh bug + : + dst=$1 + fi + shift + continue;; + esac +done + +if [ x"$src" = x ] +then + echo "install: no input file specified" + exit 1 +else + true +fi + +if [ x"$dir_arg" != x ]; then + dst=$src + src="" + + if [ -d $dst ]; then + instcmd=: + else + instcmd=mkdir + fi +else + +# Waiting for this to be detected by the "$instcmd $src $dsttmp" command +# might cause directories to be created, which would be especially bad +# if $src (and thus $dsttmp) contains '*'. + + if [ -f $src -o -d $src ] + then + true + else + echo "install: $src does not exist" + exit 1 + fi + + if [ x"$dst" = x ] + then + echo "install: no destination specified" + exit 1 + else + true + fi + +# If destination is a directory, append the input filename; if your system +# does not like double slashes in filenames, you may need to add some logic + + if [ -d $dst ] + then + dst="$dst"/`basename $src` + else + true + fi +fi + +## this sed command emulates the dirname command +dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` + +# Make sure that the destination directory exists. +# this part is taken from Noah Friedman's mkinstalldirs script + +# Skip lots of stat calls in the usual case. +if [ ! -d "$dstdir" ]; then +defaultIFS=' +' +IFS="${IFS-${defaultIFS}}" + +oIFS="${IFS}" +# Some sh's can't handle IFS=/ for some reason. +IFS='%' +set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` +IFS="${oIFS}" + +pathcomp='' + +while [ $# -ne 0 ] ; do + pathcomp="${pathcomp}${1}" + shift + + if [ ! -d "${pathcomp}" ] ; + then + $mkdirprog "${pathcomp}" + else + true + fi + + pathcomp="${pathcomp}/" +done +fi + +if [ x"$dir_arg" != x ] +then + $doit $instcmd $dst && + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi +else + +# If we're going to rename the final executable, determine the name now. + + if [ x"$transformarg" = x ] + then + dstfile=`basename $dst` + else + dstfile=`basename $dst $transformbasename | + sed $transformarg`$transformbasename + fi + +# don't allow the sed command to completely eliminate the filename + + if [ x"$dstfile" = x ] + then + dstfile=`basename $dst` + else + true + fi + +# Make a temp file name in the proper directory. + + dsttmp=$dstdir/#inst.$$# + +# Move or copy the file name to the temp name + + $doit $instcmd $src $dsttmp && + + trap "rm -f ${dsttmp}" 0 && + +# and set any options; do chmod last to preserve setuid bits + +# If any of these fail, we abort the whole thing. If we want to +# ignore errors from any of these, just make sure not to ignore +# errors from the above "$doit $instcmd $src $dsttmp" command. + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && + +# Now rename the file to the real destination. + + $doit $rmcmd -f $dstdir/$dstfile && + $doit $mvcmd $dsttmp $dstdir/$dstfile + +fi && + + +exit 0 diff --git a/contrib/idn/mdnkit/lib/Makefile.in b/contrib/idn/mdnkit/lib/Makefile.in new file mode 100644 index 0000000000..9ede1350be --- /dev/null +++ b/contrib/idn/mdnkit/lib/Makefile.in @@ -0,0 +1,163 @@ +# $Id: Makefile.in,v 1.23 2000/11/21 02:29:52 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. + +LIB_CURRENT = 4 +LIB_REVISION = 0 + +.SUFFIXES: .lo + +top_builddir = .. + +srcdir = @srcdir@ +VPATH = @srcdir@ + +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +BINDIR = @bindir@ +LIBDIR = @libdir@ +ETCDIR = @sysconfdir@ + +CC = @CC@ +RANLIB = @RANLIB@ +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +SHELL = @SHELL@ +LIBTOOL = @LIBTOOL@ + +OPTS = +INCS = -I$(srcdir)/../include -I../include +DEFS = -DMDN_RESCONF_DIR="\"$(ETCDIR)\"" + +CFLAGS = $(OPTS) $(INCS) $(DEFS) @CFLAGS@ +LDFLAGS = @LDFLAGS@ + +ICONVLIB = @ICONVLIB@ + +SRCS = \ + brace.c \ + converter.c \ + debug.c \ + dn.c \ + lace.c \ + localencoding.c \ + log.c \ + msgheader.c \ + msgtrans.c \ + normalizer.c \ + race.c \ + res.c \ + resconf.c \ + result.c \ + selectiveencode.c \ + strhash.c \ + translator.c \ + unicode.c \ + unicodedata.c \ + unormalize.c \ + utf5.c \ + utf8.c \ + util.c \ + zldrule.c + +OBJS = \ + brace.lo \ + converter.lo \ + debug.lo \ + dn.lo \ + lace.lo \ + localencoding.lo \ + log.lo \ + msgheader.lo \ + msgtrans.lo \ + normalizer.lo \ + race.lo \ + res.lo \ + resconf.lo \ + result.lo \ + selectiveencode.lo \ + strhash.lo \ + translator.lo \ + unicode.lo \ + unormalize.lo \ + utf5.lo \ + utf8.lo \ + util.lo \ + zldrule.lo + +LIB = libmdn + +.c.lo: + $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c $< + +all: $(LIB).la + +$(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) + +clean: + rm -f *.o *.lo *.la *.a core *.core *~ diff --git a/contrib/idn/mdnkit/lib/README b/contrib/idn/mdnkit/lib/README new file mode 100644 index 0000000000..63d0d7d91a --- /dev/null +++ b/contrib/idn/mdnkit/lib/README @@ -0,0 +1,82 @@ +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/brace.c b/contrib/idn/mdnkit/lib/brace.c new file mode 100644 index 0000000000..4fa22f2cf8 --- /dev/null +++ b/contrib/idn/mdnkit/lib/brace.c @@ -0,0 +1,775 @@ +#ifndef lint +static char *rcsid = "$Id: brace.c,v 1.11 2000/11/22 06:33:33 m-kasahr 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 + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#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)) + +#define IS_LDH(c) \ + (('a' <= (c) && (c) <= 'z') || ('A' <= (c) && (c) <= 'Z') || \ + ('0' <= (c) && (c) <= '9') || (c) == '-') + +/* + * Encoding Styles. + */ +enum { + half_row_style, /* all non-LDH characters are in a single half row */ + full_row_style, /* all non-LDH characters are in a single row */ + mixed_style, + no_row_style +}; + +/* + * Base-32 encoding array. + */ +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, + size_t fromlen, + unsigned short *buf, + size_t *lenp); +static mdn_result_t brace_encode(const char *from, size_t fromlen, + char *to, size_t tolen); +static mdn_result_t brace_encode_utf16(const unsigned short *p, size_t len, + char *to, size_t tolen, + int encoding_style, + unsigned short row); +static mdn_result_t get_encoding_style(unsigned short *p, size_t len, + int *stylep, unsigned short *rowp); +static int brace_rbase32(int c); + +/* ARGSUSED */ +mdn_result_t +mdn__brace_open(mdn_converter_t ctx, mdn_converter_dir_t dir) { + return (mdn_success); +} + +/* ARGSUSED */ +mdn_result_t +mdn__brace_close(mdn_converter_t ctx, 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) +{ + char *to = toorg; + + assert(ctx != NULL && + (dir == mdn_converter_l2u || dir == mdn_converter_u2l)); + + TRACE(("mdn__brace_convert(dir=%s,from=\"%s\")\n", + 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); + + len = t + suflen; + } else { + /* + * Conversion is NOT necessary. + * Copy verbatim. + */ + if (tolen < len) + return (mdn_buffer_overflow); + + (void)memcpy(to, from, len); + } + *clenp = len; + return (mdn_success); +} + +static mdn_result_t +brace_decode(const char *from, size_t fromlen, char *to, size_t tolen) { + unsigned short *buf; + unsigned short local_buf[BRACE_BUF_SIZE]; + size_t len, reslen; + mdn_result_t r; + + /* + * Allocate sufficient buffer. + */ + if (fromlen > BRACE_BUF_SIZE) { + if ((buf = malloc(sizeof(*buf) * fromlen)) == NULL) + return (mdn_nomemory); + } else { + /* Use local buffer. */ + buf = local_buf; + } + + /* + * Decode into UTF-16 string. + */ + r = brace_decode_utf16(from, fromlen, buf, &len); + if (r != mdn_success) + goto ret; + + /* + * Now 'buf' points the decompressed string, which must contain + * UTF-16 characters. + */ + + /* + * Convert to utf-8. + */ + r = mdn_util_utf16toutf8(buf, len, to, tolen, &reslen); + if (r != mdn_success) + goto ret; + if (reslen >= tolen) { + r = mdn_buffer_overflow; + goto ret; + } + to[reslen] = '\0'; + + r = mdn_success; + +ret: + if (buf != local_buf) + free(buf); + return (r); +} + +static mdn_result_t +brace_decode_utf16(const char *from, size_t fromlen, + unsigned short *buf, size_t *lenp) +{ + int encoding_style; + unsigned short row; + unsigned long bitbuf = 0; + int bitlen = 0; + int literal_mode; + int i; + +#define READ_BITS(n) \ + do { \ + int len = (n); \ + while (bitlen < len) { \ + int x; \ + if (fromlen-- <= 0) \ + return (mdn_invalid_encoding); \ + if ((x = BRACE_RBASE32(*from++)) < 0) \ + return (mdn_invalid_encoding); \ + bitbuf = (bitbuf << 5) | x; \ + bitlen += 5; \ + } \ + } while (0) +#define EXTRACT_BITS(n) \ + (bitlen -= (n), ((bitbuf >> bitlen) & ((1<<(n)) - 1))) + + READ_BITS(2); + switch (EXTRACT_BITS(2)) { + case 0: + encoding_style = half_row_style; + READ_BITS(9); + row = EXTRACT_BITS(9) << 7; + break; + case 1: + encoding_style = full_row_style; + READ_BITS(8); + row = EXTRACT_BITS(8) << 8; + break; + case 2: + encoding_style = mixed_style; + READ_BITS(9); + row = EXTRACT_BITS(9) << 7; + break; + case 3: + encoding_style = no_row_style; + row = 0; /* to keep lint happy */ + break; + default: + FATAL(("brace_decode_utf16: internal error\n")); + abort(); + return (mdn_failure); /* to keep lint happy */ + } + + i = 0; + literal_mode = 0; + while (fromlen > 0) { + int c = *from; /* peek */ + + if (c == '-') { + if (fromlen > 0 && from[1] == '-') { + buf[i++] = '-'; + from += 2; + fromlen -= 2; + } else { + literal_mode = !literal_mode; + from++; + fromlen--; + } + } else if (literal_mode) { + buf[i++] = c; + from++; + fromlen--; + } else { + switch (encoding_style) { + case half_row_style: + READ_BITS(7); + buf[i++] = row | EXTRACT_BITS(7); + break; + case full_row_style: + READ_BITS(8); + buf[i++] = row | EXTRACT_BITS(8); + break; + case mixed_style: + READ_BITS(2); + if (EXTRACT_BITS(1)) { + if (EXTRACT_BITS(1)) { + READ_BITS(16); + buf[i++] = EXTRACT_BITS(16); + } else { + READ_BITS(7); + buf[i++] = (row ^ 0x80) | + EXTRACT_BITS(7); + } + } else { + READ_BITS(7); + buf[i++] = row | EXTRACT_BITS(7); + } + break; + case no_row_style: + READ_BITS(16); + buf[i++] = EXTRACT_BITS(16); + break; + } + } + } + + if (bitlen > 4) + return (mdn_invalid_encoding); + + *lenp = i; + return (mdn_success); +#undef READ_BITS +#undef EXTRACT_BITS +} + +static mdn_result_t +brace_encode(const char *from, size_t fromlen, char *to, size_t tolen) { + unsigned short *buf; + unsigned short local_buf[BRACE_BUF_SIZE]; /* UTF-16 */ + unsigned short row; + mdn_result_t r; + size_t buflen, len; + int encoding_style; + + /* + * Convert to UTF-16. + */ + buf = local_buf; + buflen = BRACE_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 finish; + } + } + + /* + * Now 'buf' contains UTF-16 encoded string consisting of + * 'len' characters. + */ + + /* + * Choose encoding style. + */ + r = get_encoding_style(buf, len, &encoding_style, &row); + if (r != mdn_success) + goto finish; + + r = brace_encode_utf16(buf, len, to, tolen, encoding_style, row); + +finish: + if (buf != local_buf) + free(buf); + return (r); +} + +static mdn_result_t +brace_encode_utf16(const unsigned short *p, size_t len, + char *to, size_t tolen, + int encoding_style, unsigned short row) +{ + unsigned long bitbuf = 0; /* bit stream buffer */ + char *save_to; + int bitlen = 0; /* # of bits in 'bitbuf' */ + int nonhyphen; + int i; + +#define FLUSH_BITS_1(p) \ + do { \ + int x = (bitbuf >> (bitlen - 5)) & 0x1f; \ + bitlen -= 5; \ + *p = BRACE_BASE32(x); \ + } while (0) +#define FLUSH_BITS \ + do { \ + while (bitlen >= 5) { \ + if (tolen < 1) \ + return (mdn_buffer_overflow); \ + FLUSH_BITS_1(to); \ + to++, tolen--; \ + } \ + } while (0) +#define PUT(c) \ + do { \ + if (tolen-- < 1) \ + return (mdn_buffer_overflow); \ + *to++ = c; \ + } while (0) + + switch (encoding_style) { + case half_row_style: + /* 00xxxxxxxxx */ + bitbuf = row >> 7; + bitlen = 2 + 9; + break; + case full_row_style: + /* 01xxxxxxxx */ + bitbuf = (1 << 8) | (row >> 8); + bitlen = 2 + 8; + break; + case mixed_style: + /* 10xxxxxxxxx */ + bitbuf = (1 << 10) | (row >> 7); + bitlen = 2 + 9; + break; + case no_row_style: + /* 11 */ + bitbuf = 3; + bitlen = 2; + break; + default: + FATAL(("brace_compress_encode: internal error " + "invalid encoding_style\n")); + abort(); + break; + } + + FLUSH_BITS; + + if (bitlen > 0) { + save_to = to++; + if (tolen-- < 1) + return (mdn_buffer_overflow); + } else { + save_to = NULL; + } + + nonhyphen = 0; + for (i = 0; i < len; i++) { + if (p[i] == 0x2d) { + PUT('-'); + PUT('-'); + } else if (IS_LDH(p[i])) { + if (!nonhyphen) + PUT('-'); + PUT(p[i]); + nonhyphen = 1; + } else { + if (nonhyphen) { + PUT('-'); + } + nonhyphen = 0; + switch (encoding_style) { + case half_row_style: + bitlen += 7; + bitbuf = (bitbuf << 7) | (p[i] & 0x7f); + break; + case full_row_style: + bitlen += 8; + bitbuf = (bitbuf << 8) | (p[i] & 0xff); + break; + case mixed_style: + if ((p[i] & 0xff80) == row) { + bitlen += 8; + bitbuf = (bitbuf << 8) | (p[i] & 0x7f); + } else if ((p[i] & 0xff80) == (row ^ 0x80)) { + bitlen += 9; + bitbuf = (bitbuf << 9) | (1 << 8) | + (p[i] & 0x7f); + } else { + bitlen += 18; + bitbuf = (bitbuf << 18) | (3 << 16) | + p[i]; + } + break; + case no_row_style: + bitlen += 16; + bitbuf = (bitbuf << 16) | p[i]; + break; + } + if (save_to != NULL) + FLUSH_BITS_1(save_to); + FLUSH_BITS; + if (bitlen > 0) { + save_to = to++; + if (tolen-- < 1) + return (mdn_buffer_overflow); + } else { + save_to = NULL; + } + } + } + if (bitlen > 0) { + assert(save_to != NULL && bitlen < 5); + bitbuf <<= 5 - bitlen; + bitlen = 5; + FLUSH_BITS_1(save_to); + } + + if (tolen <= 0) + return (mdn_buffer_overflow); + + *to = '\0'; + return (mdn_success); +#undef FLUSH_BITS_1 +#undef FLUSH_BITS +#undef PUT +} + +static mdn_result_t +get_encoding_style(unsigned short *p, size_t len, + int *stylep, unsigned short *rowp) +{ + struct row { + unsigned short upper; + unsigned short num; + unsigned short cmpl; + } *row_cands, row_cands_buf[64]; /* usually 64 is enough */ + int cands_size = 64; + int num_cands = 0; + int num_nonldh = 0; + int style = no_row_style; /* to keep lint happy */ + int best; + int m, m_prime; + int i, j; + + row_cands = row_cands_buf; + + for (i = 0; i < len; i++) { + unsigned int upper; + + /* Ignore LDH characters. */ + if (IS_LDH(p[i])) + continue; + + num_nonldh++; + upper = p[i] & 0xff80; /* upper 9bits */ + + for (j = 0; j < num_cands; j++) { + if (upper == row_cands[j].upper) { + row_cands[j].num++; + goto found; + } + } + if (num_cands >= cands_size) { + /* Make the row buffer bigger. */ + cands_size *= 2; + if (row_cands == row_cands_buf) + row_cands = malloc(sizeof(struct row) * + cands_size); + else + row_cands = realloc(row_cands, + sizeof(struct row) * + cands_size); + if (row_cands == NULL) + return (mdn_nomemory); + } + row_cands[num_cands].upper = upper; + row_cands[num_cands].num = 1; + row_cands[num_cands].cmpl = 0; + num_cands++; + found: + ; + } + + if (num_cands == 0) { + /* + * There is no non-LDH characters. Draft is not clear on + * this case, but the sample implementation uses no-row style. + */ + style = no_row_style; + goto ret; + } + if (num_cands == 1) { + /* + * Choose half-row style. + */ + *rowp = row_cands[0].upper; + style = half_row_style; + goto ret; + } + if (num_cands == 2 && + (row_cands[0].upper ^ row_cands[1].upper) == 0x80) { + /* + * All the non-LDH characters are in the same row. + * Choose full-row style. + */ + *rowp = row_cands[0].upper & ~0x80; + style = full_row_style; + goto ret; + } + + /* + * Get the number of characters in the complementary half-row. + */ + for (i = 1; i < num_cands; i++) { + unsigned int upper = row_cands[i].upper; + + for (j = 0; j < i; j++) { + if ((row_cands[j].upper ^ upper) == 0x80) { + row_cands[i].cmpl = row_cands[j].num; + row_cands[j].cmpl = row_cands[i].num; + break; + } + } + } + + /* + * Choose the best M. + */ +#define M(i) \ + (3 + (num_nonldh * 18 - row_cands[i].num * 10 - row_cands[i].cmpl * 9) / 5) + for (best = 0, m = M(0), i = 1; i < num_cands; i++) { + int m_i = M(i); + if (m_i < m || + (m_i == m && row_cands[i].upper < row_cands[best].upper)) { + best = i; + m = m_i; + } + } +#undef M + m_prime = (6 + num_nonldh * 16) / 5; + if (m_prime <= m) { + style = no_row_style; + } else { + *rowp = row_cands[best].upper; + style = mixed_style; + } + ret: + if (row_cands != row_cands_buf) + free(row_cands); + *stylep = style; + return (mdn_success); +} + +static int +brace_rbase32(int c) { + if ('A' <= c && c <= 'Z') + c = 'a' + (c - 'A'); + if ('2' <= c && c <= '9') + return (c - '2'); + else if ('a' <= c && c <= 'k') + return (c - 'a' + 8); + else if ('m' <= c && c <= 'n') + return (c - 'm' + 19); + else if ('p' <= c && c <= 'z') + return (c - 'p' + 21); + else + return (-1); +} diff --git a/contrib/idn/mdnkit/lib/converter.c b/contrib/idn/mdnkit/lib/converter.c new file mode 100644 index 0000000000..0e9a2bfbf6 --- /dev/null +++ b/contrib/idn/mdnkit/lib/converter.c @@ -0,0 +1,994 @@ +#ifndef lint +static char *rcsid = "$Id: converter.c,v 1.23 2000/11/14 00:13:31 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 + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef MDN_UTF8_ENCODING_NAME +#define MDN_UTF8_ENCODING_NAME "UTF-8" /* by IANA */ +#endif +#ifndef MDN_UTF5_ENCODING_NAME +#define MDN_UTF5_ENCODING_NAME "UTF-5" +#endif +#ifndef MDN_RACE_ENCODING_NAME +#define MDN_RACE_ENCODING_NAME "RACE" +#endif +#ifndef MDN_BRACE_ENCODING_NAME +#define MDN_BRACE_ENCODING_NAME "BRACE" +#endif +#ifndef MDN_LACE_ENCODING_NAME +#define MDN_LACE_ENCODING_NAME "LACE" +#endif + +#define MAX_RECURSE 20 + +typedef struct { + mdn_converter_openproc_t open; + mdn_converter_closeproc_t close; + mdn_converter_convertproc_t convert; + int ascii_compatible; +} converter_ops_t; + +struct mdn_converter { + char *local_encoding_name; + converter_ops_t *ops; + int flags; + int opened[2]; + iconv_t ictx[2]; +}; + +static mdn_strhash_t encoding_name_hash; +static mdn_strhash_t encoding_alias_hash; + +static mdn_result_t converter_open(mdn_converter_t ctx, + mdn_converter_dir_t dir); +static mdn_result_t converter_close(mdn_converter_t ctx, + mdn_converter_dir_t dir); +static mdn_result_t register_standard_encoding(void); +static const char *get_realname(const char *name); +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); +static mdn_result_t converter_none_close(mdn_converter_t ctx, + mdn_converter_dir_t dir); +static mdn_result_t converter_none_convert(mdn_converter_t ctx, + 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); +static mdn_result_t converter_iconv_close(mdn_converter_t ctx, + mdn_converter_dir_t dir); +static mdn_result_t converter_iconv_convert(mdn_converter_t ctx, + 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); +static mdn_result_t converter_utf5_close(mdn_converter_t ctx, + mdn_converter_dir_t dir); +static mdn_result_t converter_utf5_convert(mdn_converter_t ctx, + 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); +static mdn_result_t converter_uescape_close(mdn_converter_t ctx, + 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); +#endif + +static converter_ops_t none_converter_ops = { + converter_none_open, + converter_none_close, + converter_none_convert, + 0, +}; + +static converter_ops_t iconv_converter_ops = { + converter_iconv_open, + converter_iconv_close, + converter_iconv_convert, + 0, +}; + +/* + * Initialize. + */ + +mdn_result_t +mdn_converter_initialize(void) { + mdn_result_t r = mdn_success; + mdn_strhash_t hash; + + if (encoding_alias_hash == NULL) { + if ((r = mdn_strhash_create(&hash)) != mdn_success) + return (r); + encoding_alias_hash = hash; + } + if (encoding_name_hash == NULL) { + if ((r = mdn_strhash_create(&hash)) != mdn_success) + return (r); + encoding_name_hash = hash; + r = register_standard_encoding(); + } + return (r); +} + +mdn_result_t +mdn_converter_create(const char *name, mdn_converter_t *ctxp, int flags) { + const char *realname; + mdn_converter_t ctx; + mdn_result_t r; + void *v; + + assert(name != NULL && ctxp != NULL); + + TRACE(("mdn_converter_create(%s)\n", name)); + + realname = get_realname(name); +#ifdef DEBUG + if (strcmp(name, realname) != 0) { + TRACE(("mdn_converter_create: realname=%s\n", realname)); + } +#endif + + *ctxp = NULL; + + /* Allocate memory for a converter context and the name. */ + ctx = malloc(sizeof(struct mdn_converter) + strlen(realname) + 1); + if (ctx == NULL) { + WARNING(("mdn_converter_create: malloc failed\n")); + return (mdn_nomemory); + } + (void)memset(ctx, 0, sizeof(*ctx)); + ctx->local_encoding_name = (char *)(ctx + 1); + (void)strcpy(ctx->local_encoding_name, realname); + ctx->flags = flags; + + assert(encoding_name_hash != NULL); + + if (strcmp(realname, MDN_UTF8_ENCODING_NAME) == 0) { + /* No conversion needed */ + ctx->ops = &none_converter_ops; + } else if ((r = mdn_strhash_get(encoding_name_hash, realname, &v)) + == mdn_success) { + /* Special converter found */ + ctx->ops = (converter_ops_t *)v; + } else { + /* General case */ + ctx->ops = &iconv_converter_ops; + } + + if ((flags & MDN_CONVERTER_DELAYEDOPEN) == 0) { + mdn_result_t r; + + if ((r = converter_open(ctx, + mdn_converter_l2u)) != mdn_success) { + WARNING(("mdn_converter_create: open failed " + "(local->utf8)\n")); + return (r); + } + if ((r = converter_open(ctx, + mdn_converter_u2l)) != mdn_success) { + WARNING(("mdn_converter_create: open failed " + "(utf8->local)\n")); + return (r); + } + } + + *ctxp = ctx; + return (mdn_success); +} + +static mdn_result_t +converter_open(mdn_converter_t ctx, mdn_converter_dir_t dir) { + mdn_result_t st = mdn_success; + + assert(ctx != NULL && + (dir == mdn_converter_l2u || dir == mdn_converter_u2l)); + + if (!ctx->opened[dir]) { + st = (*ctx->ops->open)(ctx, dir); + if (st == mdn_success) + ctx->opened[dir] = 1; + } + return (st); +} + +void +mdn_converter_destroy(mdn_converter_t ctx) { + assert(ctx != NULL); + + TRACE(("mdn_converter_destroy()\n")); + + (void)converter_close(ctx, mdn_converter_l2u); + (void)converter_close(ctx, mdn_converter_u2l); + free(ctx); +} + +static mdn_result_t +converter_close(mdn_converter_t ctx, mdn_converter_dir_t dir) { + mdn_result_t st = mdn_success; + + assert(ctx != NULL && + (dir == mdn_converter_l2u || dir == mdn_converter_u2l)); + + if (ctx->opened[dir]) { + st = (*ctx->ops->close)(ctx, dir); + if (st == mdn_success) + ctx->opened[dir] = 0; + } + return (st); +} + +char * +mdn_converter_localencoding(mdn_converter_t ctx) { + assert(ctx != NULL); + TRACE(("mdn_converter_localencoding()\n")); + return (ctx->local_encoding_name); +} + +int +mdn_converter_isasciicompatible(mdn_converter_t ctx) { + assert(ctx != NULL); + TRACE(("mdn_converter_isasciicompatible()\n")); + return (ctx->ops->ascii_compatible); +} + +mdn_result_t +mdn_converter_convert(mdn_converter_t ctx, 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_converter_convert(dir=%s,from=\"%s\")\n", + dir == mdn_converter_l2u ? "l2u" : "u2l", + from == NULL ? "(null)" : mdn_debug_xstring(from, 20))); + + if (!ctx->opened[dir]) { + mdn_result_t st = converter_open(ctx, dir); + if (st != mdn_success) + return (st); + } + + if (from == NULL) { + /* for compatibility */ + INFO(("mdn_converter_convert: " + "obsolete feature (reset) invoked\n")); + return (mdn_success); + } + + r = (*ctx->ops->convert)(ctx, 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)); + } + + return (r); +} + +/* + * Encoding registration. + */ + +mdn_result_t +mdn_converter_register(const char *name, + mdn_converter_openproc_t open, + mdn_converter_closeproc_t close, + mdn_converter_convertproc_t convert, + int ascii_compatible) { + converter_ops_t *ops; + mdn_result_t r; + + assert(name != NULL && open != NULL && close != NULL && + convert != NULL); + + TRACE(("mdn_converter_register(name=%s)\n", name)); + + if ((ops = malloc(sizeof(*ops))) == NULL) { + WARNING(("mdn_converter_register: malloc failed\n")); + return (mdn_nomemory); + } + ops->open = open; + ops->close = close; + ops->convert = convert; + ops->ascii_compatible = ascii_compatible; + + r = mdn_strhash_put(encoding_name_hash, name, ops); + if (r != mdn_success) + free(ops); + + return (r); +} + +static mdn_result_t +register_standard_encoding(void) { + mdn_result_t r; + + r = mdn_converter_register(MDN_UTF5_ENCODING_NAME, + converter_utf5_open, + converter_utf5_close, + converter_utf5_convert, + 1); + if (r != mdn_success) + return (r); + + r = mdn_converter_register(MDN_RACE_ENCODING_NAME, + mdn__race_open, + mdn__race_close, + mdn__race_convert, + 1); + if (r != mdn_success) + return (r); + + r = mdn_converter_register(MDN_BRACE_ENCODING_NAME, + mdn__brace_open, + mdn__brace_close, + mdn__brace_convert, + 1); + if (r != mdn_success) + return (r); + + r = mdn_converter_register(MDN_LACE_ENCODING_NAME, + mdn__lace_open, + mdn__lace_close, + mdn__lace_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", + converter_uescape_open, + converter_uescape_close, + converter_uescape_convert, + 0); + if (r != mdn_success) + return (r); +#endif /* DEBUG */ + + return (r); +} + +/* + * Encoding alias support. + */ + +mdn_result_t +mdn_converter_addalias(const char *alias_name, const char *real_name) { + char *rn_copy; + + assert(alias_name != NULL && real_name != NULL); + + TRACE(("mdn_converter_addalias(alias_name=%s,real_name=%s)\n", + alias_name, real_name)); + + if (strcmp(alias_name, real_name) == 0) + return (mdn_success); + + if (encoding_alias_hash == NULL) + return (mdn_failure); + + if ((rn_copy = malloc(strlen(real_name) + 1)) == NULL) { + WARNING(("mdn_converter_addalias: malloc failed\n")); + return (mdn_nomemory); + } + (void)strcpy(rn_copy, real_name); + (void)mdn_strhash_put(encoding_alias_hash, alias_name, rn_copy); + + return (mdn_success); +} + +mdn_result_t +mdn_converter_aliasfile(const char *path) { + FILE *fp; + int line_no; + mdn_result_t st = mdn_success; + char line[200], alias[200], real[200]; + + assert(path != NULL); + + TRACE(("mdn_converter_aliasfile(path=%s)\n", path)); + + if ((fp = fopen(path, "r")) == NULL) { + return (mdn_nofile); + } + for (line_no = 1; fgets(line, sizeof(line), fp) != NULL; line_no++) { + unsigned char *p = (unsigned char *)line; + + while (isascii(*p) && isspace(*p)) + p++; + if (*p == '#' || *p == '\n') + continue; + if (sscanf((char *)p, "%s %s", alias, real) == 2) { + st = mdn_converter_addalias(alias, real); + if (st != mdn_success) + break; + } else { + WARNING(("mdn_converter_aliasfile: file %s has " + "invalid contents at line %d\n", + path, line_no)); + st = mdn_invalid_syntax; + break; + } + } + fclose(fp); + return st; +} + +mdn_result_t +mdn_converter_resetalias(void) { + mdn_strhash_t hash; + mdn_result_t r; + + TRACE(("mdn_converter_resetalias()\n")); + + hash = encoding_alias_hash; + encoding_alias_hash = NULL; + mdn_strhash_destroy(hash, free_alias_value); + hash = NULL; + r = mdn_strhash_create(&hash); + encoding_alias_hash = hash; + return (r); +} + +static const char * +get_realname(const char *name) { + if (encoding_alias_hash != NULL) { + char *realname; + int recurse = 0; + + while (recurse < MAX_RECURSE) { + mdn_result_t r; + + r = mdn_strhash_get(encoding_alias_hash, + name, (void **)&realname); + if (r != mdn_success) + break; + + name = realname; + recurse++; + } + if (recurse >= MAX_RECURSE) { + WARNING(("mdn_converter: encoding alias table has " + "cyclic reference\n")); + } + } + return (name); +} + +static void +free_alias_value(void *value) { + free(value); +} + +/* + * Round trip check. + */ + +static mdn_result_t +roundtrip_check(mdn_converter_t ctx, mdn_converter_dir_t dir, + const char *from, const char *to) +{ + /* + * One problem with iconv() convertion is that + * iconv() doesn't signal an error if the input + * string contains characters which are valid but + * do not have mapping to the output codeset. + * (the behavior of iconv() for that case is defined as + * `implementation dependent') + * One way to check this case is to perform round-trip + * conversion and see if it is same as the original string. + */ + mdn_result_t r; + char *back_converted; + char buf[256]; + size_t len; + + TRACE(("mdn_converter_convert: round-trip checking (" + " from=\"%s\")\n", mdn_debug_xstring(from, 20))); + + /* Allocate enough buffer. */ + len = strlen(from) + 1; + if (len <= sizeof(buf)) { + back_converted = buf; + len = sizeof(buf); + } else { + back_converted = malloc(len); + if (back_converted == NULL) + return (mdn_nomemory); + } + + /* + * Perform backward conversion. + */ + if (dir == mdn_converter_l2u) + dir = mdn_converter_u2l; + else + dir = mdn_converter_l2u; + r = mdn_converter_convert(ctx, dir, to, back_converted, len); + + switch (r) { + case mdn_success: + if (strcmp(back_converted, from) != 0) + r = mdn_nomapping; + break; + case mdn_invalid_encoding: + case mdn_buffer_overflow: + r = mdn_nomapping; + break; + default: + break; + } + + if (back_converted != buf) + free(back_converted); + + if (r != mdn_success) { + TRACE(("round-trip check failed: %s\n", + mdn_result_tostring(r))); + } + + return (r); +} + +/* + * Identity conversion (or, no conversion at all). + */ + +/* ARGSUSED */ +static mdn_result_t +converter_none_open(mdn_converter_t ctx, mdn_converter_dir_t dir) { + return (mdn_success); +} + +/* ARGSUSED */ +static mdn_result_t +converter_none_close(mdn_converter_t ctx, 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) +{ + size_t fromlen; + + assert(ctx != NULL && + (dir == mdn_converter_l2u || dir == mdn_converter_u2l)); + + /* + * Just copying is not enough. We should at least check + * the validity of 'from'. + */ + if (!mdn_utf8_isvalidstring(from)) + return (mdn_invalid_encoding); + + fromlen = strlen(from) + 1; /* including NUL */ + if (fromlen > tolen) + return (mdn_buffer_overflow); + + (void)memcpy(to, from, fromlen); /* including NUL */ + return (mdn_success); +} + + +/* + * Conversion using iconv() interface. + */ + +static mdn_result_t +converter_iconv_open(mdn_converter_t ctx, mdn_converter_dir_t dir) { + iconv_t ictx; + + if (dir == mdn_converter_l2u) { + ictx = iconv_open(MDN_UTF8_ENCODING_NAME, + ctx->local_encoding_name); + } else { + ictx = iconv_open(ctx->local_encoding_name, + MDN_UTF8_ENCODING_NAME); + } + ctx->ictx[dir] = ictx; + if (ictx == (iconv_t)(-1)) { + switch (errno) { + case ENOMEM: + return (mdn_nomemory); + case EINVAL: + return (mdn_invalid_name); + default: + WARNING(("iconv_open failed with errno %d\n", errno)); + return (mdn_failure); + } + } + return (mdn_success); +} + +static mdn_result_t +converter_iconv_close(mdn_converter_t ctx, mdn_converter_dir_t dir) { + assert(ctx != NULL && + (dir == mdn_converter_l2u || dir == mdn_converter_u2l)); + + if (ctx->opened[dir]) + (void)iconv_close(ctx->ictx[dir]); + 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) +{ + char *toorg = to; + size_t sz; + size_t fromsz; + size_t tosz; + char *p; + + assert(ctx != NULL && + (dir == mdn_converter_l2u || dir == mdn_converter_u2l)); + + if (tolen <= 0) + return (mdn_buffer_overflow); /* need space for NUL */ + + /* + * For utf-8 -> local conversion, check the validity of + * the input string. + */ + if (dir == mdn_converter_u2l && !mdn_utf8_isvalidstring(from)) { + WARNING(("mdn_converter_convert: " + "input is not a valid UTF-8 string\n")); + return (mdn_invalid_encoding); + } + + /* + * Reset internal state. + */ +#if 0 + (void)iconv(ctx->ictx[dir], (const char **)NULL, (size_t *)NULL, + (char **)NULL, (size_t *)NULL); +#else + /* + * Above code should work according to the spec, but causes + * segmentation fault with Solaris 2.6. + * So.. a work-around. + */ + fromsz = tosz = 0; + p = NULL; + (void)iconv(ctx->ictx[dir], (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); + + if (sz == (size_t)(-1) || fromsz > 0) { + switch (errno) { + case EILSEQ: + case EINVAL: + if (dir == mdn_converter_u2l) { + /* + * We already checked the validity of the + * input string. So we assume a mapping + * error. + */ + return (mdn_nomapping); + } else { + /* + * We assume all the characters in the local + * codeset are included in UCS. This means + * mapping error is not possible, so the + * input string must have some problem. + */ + return (mdn_invalid_encoding); + } + case E2BIG: + return (mdn_buffer_overflow); + default: + 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); + } + + return (mdn_success); +} + +/* + * Conversion to/from UTF-5. + */ + +/* ARGSUSED */ +static mdn_result_t +converter_utf5_open(mdn_converter_t ctx, mdn_converter_dir_t dir) { + return (mdn_success); +} + +/* ARGSUSED */ +static mdn_result_t +converter_utf5_close(mdn_converter_t ctx, 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) +{ + size_t fromlen = strlen(from); + + if (dir == mdn_converter_l2u) { + unsigned long v; + int flen, tlen; + + while (fromlen > 0) { + flen = mdn_utf5_getwc(from, fromlen, &v); + if (flen == 0) { + WARNING(("mdn_converter_convert: " + "invalid character\n")); + return (mdn_invalid_encoding); + } + from += flen; + fromlen -= flen; + + tlen = mdn_utf8_putwc(to, tolen, v); + if (tlen == 0) + goto overflow; + to += tlen; + tolen -= tlen; + } + } else { /* mdn_converter_u2l */ + unsigned long v; + int flen, tlen; + + while (fromlen > 0) { + flen = mdn_utf8_getwc(from, fromlen, &v); + if (flen == 0) { + WARNING(("mdn_converter_convert: " + "invalid character\n")); + return (mdn_invalid_encoding); + } + from += flen; + fromlen -= flen; + + tlen = mdn_utf5_putwc(to, tolen, v); + if (tlen == 0) + goto overflow; + to += tlen; + tolen -= tlen; + } + } + if (tolen <= 0) + goto overflow; + + *to = '\0'; + return (mdn_success); + +overflow: + WARNING(("mdn_converter_convert: buffer overflow\n")); + return (mdn_buffer_overflow); +} + +#ifdef DEBUG +/* + * Conversion to/from unicode escape string. + * Arbitrary UCS-4 character can be specified by a special sequence + * \u{XXXXXX} + * where XXXXX denotes any hexadecimal string up to FFFFFFFF. + * This is designed for debugging. + */ + +static int uescape_getwc(const char *from, size_t fromlen, + unsigned long *vp); +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) { + return (mdn_success); +} + +/* ARGSUSED */ +static mdn_result_t +converter_uescape_close(mdn_converter_t ctx, 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) +{ + size_t fromlen = strlen(from); + + if (dir == mdn_converter_l2u) { + unsigned long v; + int flen, tlen; + + while (fromlen > 0) { + flen = uescape_getwc(from, fromlen, &v); + if (flen == 0) { + WARNING(("mdn_converter_convert: " + "invalid character\n")); + return (mdn_invalid_encoding); + } + from += flen; + fromlen -= flen; + + tlen = mdn_utf8_putwc(to, tolen, v); + if (tlen == 0) + goto overflow; + to += tlen; + tolen -= tlen; + } + } else { /* mdn_converter_u2l */ + unsigned long v; + int flen, tlen; + + while (fromlen > 0) { + flen = mdn_utf8_getwc(from, fromlen, &v); + if (flen == 0) { + WARNING(("mdn_converter_convert: " + "invalid character\n")); + return (mdn_invalid_encoding); + } + from += flen; + fromlen -= flen; + + tlen = uescape_putwc(to, tolen, v); + if (tlen == 0) + goto overflow; + to += tlen; + tolen -= tlen; + } + } + if (tolen <= 0) + goto overflow; + + *to = '\0'; + return (mdn_success); + +overflow: + WARNING(("mdn_converter_convert: buffer overflow\n")); + return (mdn_buffer_overflow); +} + +static int +uescape_getwc(const char *from, size_t fromlen, unsigned long *vp) { + char *end; + if (fromlen >= 4 && strncmp(from, "\\u{", 3) == 0 && + (end = memchr(from, '}', fromlen)) != NULL && + end - from <= 3 + 8) { /* '\u{' + 'xxxxxxxx' */ + int len = end - from - 3; + char tmp[9]; + + (void)memcpy(tmp, from + 3, len); + tmp[len] = '\0'; + *vp = strtoul(tmp, NULL, 16); + return (end + 1 - from); + } else if (fromlen > 0) { + *vp = (unsigned char)from[0]; + return (1); + } else { + return (0); + } +} + +static int +uescape_putwc(char *to, size_t tolen, unsigned long v) { + if (v <= 0x7f) { + if (tolen < 1) + return (0); + *to = v; + return (1); + } else if (v <= 0xffffffff) { + char tmp[20]; + int len; + + (void)sprintf(tmp, "\\u{%lx}", v); + len = strlen(tmp); + if (tolen < len) + return (0); + (void)memcpy(to, tmp, len); + return (len); + } else { + return (0); + } +} +#endif diff --git a/contrib/idn/mdnkit/lib/debug.c b/contrib/idn/mdnkit/lib/debug.c new file mode 100644 index 0000000000..967b718951 --- /dev/null +++ b/contrib/idn/mdnkit/lib/debug.c @@ -0,0 +1,180 @@ +#ifndef lint +static char *rcsid = "$Id: debug.c,v 1.6 2000/07/04 03:52:36 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 + +#include +#include +#include + +#include + +static char *hex = "0123456789abcdef"; + +char * +mdn_debug_hexstring(const char *s, int maxbytes) { + int i; + char *p; + static char buf[256 * 3 + 3 + 1]; /* +3 for "..." */ + + if (maxbytes > 256) + maxbytes = 256; + + for (i = 0, p = buf; i < maxbytes; i++) { + int c = ((unsigned char *)s)[i]; + + if (c == '\0') + break; + *p++ = hex[c >> 4]; + *p++ = hex[c & 15]; + *p++ = ' '; + } + + if (i >= maxbytes) + (void)strcpy(p, "..."); + else + *p = '\0'; + + return (buf); +} + +char * +mdn_debug_xstring(const char *s, int maxbytes) { + int i; + char *p; + static char buf[256 * 4 + 3 + 1]; /* +3 for "..." */ + + if (maxbytes > 256) + maxbytes = 256; + + for (i = 0, p = buf; i < maxbytes; i++) { + int c = ((unsigned char *)s)[i]; + + if (c == '\0') { + break; + } else if (c < 0x20 || c > 0x7e) { + *p++ = '\\'; + *p++ = 'x'; + *p++ = hex[c >> 4]; + *p++ = hex[c & 15]; + } else { + *p++ = c; + } + } + + if (i >= maxbytes) + (void)strcpy(p, "..."); + else + *p = '\0'; + + return (buf); +} + +char * +mdn_debug_hexdata(const char *s, int length, int maxlength) { + int i; + const unsigned char *p = (const unsigned char *)s; + char *q; + static char buf[256 * 3 + 3 + 1]; /* +3 for "..." */ + char *cont = NULL; + + if (maxlength > 256) + maxlength = 256; + + if (length > maxlength) { + length = maxlength; + cont = "..."; + } + + for (i = 0, q = buf; i < length; i++) { + int c = p[i]; + + *q++ = hex[c >> 4]; + *q++ = hex[c & 15]; + *q++ = ' '; + } + + if (cont != NULL) + (void)strcpy(q, "..."); + else + *q = '\0'; + + return (buf); +} + +void +mdn_debug_hexdump(const char *s, int length) { + int i; + const unsigned char *p = (const unsigned char *)s; + + i = 0; + while (length-- > 0) { + if (i % 16 == 0) { + if (i > 0) + fprintf(stderr, "\n"); + fprintf(stderr, "%4x:", i); + } + fprintf(stderr, " %02x", p[i]); + i++; + } + fprintf(stderr, "\n"); +} diff --git a/contrib/idn/mdnkit/lib/dn.c b/contrib/idn/mdnkit/lib/dn.c new file mode 100644 index 0000000000..2ef844254f --- /dev/null +++ b/contrib/idn/mdnkit/lib/dn.c @@ -0,0 +1,341 @@ +#ifndef lint +static char *rcsid = "$Id: dn.c,v 1.8 2000/09/20 02:47:31 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. + */ + +/* + * Domain name compression/expansion. + * + * Similar to the functionality of dn_comp/dn_expand in the resolv library. + * In fact, the loop detection in mdn__dn_expand is borrowed from + * ns_name_unpack. + */ + +#include + +#include +#include +#include + +#include +#include +#include +#include + +#define COMPRESS_MASK 0xc0 +#define COMPRESS_FLAG 0xc0 +#define MAX_OFFSET 0x3fff + +#define MAXNAMELEN 1024 +#define MAXLABEL 63 +#define MAXCOMPRESS 255 + +/* + * uppercase -> lowercase conversion table, to be initialized + * by init_lcase(). + */ +static char lcase[128]; + +static mdn_result_t split_name(const char *name, unsigned char *namebuf); +static int find_label(const unsigned char *p, int limit, + mdn__dn_t *ctx); +static int match(const unsigned char *p, const unsigned char *q, + mdn__dn_t *ctx); +static void append_ptr(mdn__dn_t *ctx, unsigned char *ptr); +static int get_offset(const unsigned char *p); +static void init_lcase(void); + + +mdn_result_t +mdn__dn_expand(const char *msg, size_t msglen, const char *compressed, + char *expanded, size_t buflen, size_t *complenp) +{ + const unsigned char *p = (const unsigned char *)compressed; + const unsigned char *ueom = (const unsigned char *)(msg + msglen); + int compress_len = 0; + size_t checked = 0; + + assert(msg != NULL && expanded != NULL && complenp != NULL); + + /* + * Sanity check. + */ + if (compressed < msg || msg + msglen <= compressed) + return (mdn_invalid_message); + + if (*p == 0) { + /* Root label */ + if (buflen < 2) + return (mdn_buffer_overflow); + (void)strcpy(expanded, "."); + *complenp = 1; + return (mdn_success); + } + + while (p < ueom) { + int c = *p++; + size_t len; + + len = c & ~COMPRESS_MASK; + + if (c == 0) { + if (compress_len == 0) + compress_len = (const char *)p - compressed; + *complenp = compress_len; + return (mdn_success); + } else if ((c & COMPRESS_MASK) == 0) { + if (p + len > ueom) + return (mdn_invalid_message); + if (buflen < len + 2) + return (mdn_buffer_overflow); + (void)memcpy(expanded, p, len); + (void)strcpy(expanded + len, "."); /* dot and NUL */ + p += len; + checked += len + 1; + expanded += len + 1; + buflen -= len + 1; + } else if ((c & COMPRESS_MASK) == COMPRESS_FLAG) { + if (p >= ueom) + return (mdn_invalid_message); + len = (len << 8) + *p++; + if (compress_len == 0) + compress_len = (const char *)p - compressed; + p = (const unsigned char *)(msg + len); + + /* + * Loop detection. + */ + checked += 2; + if (checked >= msglen) { + WARNING(("mdn__dn_expand: loop detected\n")); + return (mdn_invalid_message); + } + } else { + return (mdn_invalid_message); + } + } + return (mdn_invalid_message); +} + +void +mdn__dn_initcompress(mdn__dn_t *ctx, const char *msg) { + ctx->msg = (const unsigned char *)msg; + ctx->cur = 0; +} + +mdn_result_t +mdn__dn_compress(const char *name, char *sptr, size_t length, + mdn__dn_t *ctx, size_t *complenp) +{ + unsigned char namebuf[MAXNAMELEN+1]; + unsigned char *ptr, *p; + mdn_result_t r; + int offset_limit; + static int initialized = 0; + + if (!initialized) { + init_lcase(); + initialized = 1; + } + + /* + * Split domain name into labels. + */ + if ((r = split_name(name, namebuf)) != mdn_success) + return (r); + + p = namebuf; + ptr = (unsigned char *)sptr; + offset_limit = ctx->cur; + while (*p != 0) { + int off; + + if ((off = find_label(p, offset_limit, ctx)) >= 0) { + if (length < 2) + return (mdn_buffer_overflow); + + ptr[0] = COMPRESS_FLAG | (off >> 8); + ptr[1] = off & 0xff; + ptr += 2; + if ((*complenp = (char *)ptr - sptr) > MAXCOMPRESS) + return (mdn_invalid_name); + return (mdn_success); + } else { + int l = *p + 1; + + if (length < l) + return (mdn_buffer_overflow); + + (void)memcpy(ptr, p, l); + append_ptr(ctx, ptr); + + ptr += l; + length -= l; + } + p += *p + 1; + } + if (length < 1) + return (mdn_buffer_overflow); + *ptr++ = 0; + if ((*complenp = (char *)ptr - sptr) > MAXCOMPRESS) + return (mdn_invalid_name); + return (mdn_success); +} + +static mdn_result_t +split_name(const char *name, unsigned char *namebuf) { + const unsigned char *p = (const unsigned char *)name; + const unsigned char *end = p + MAXNAMELEN; + unsigned char *q, *qtop; + + q = namebuf; + qtop = q++; + while (p < end) { + if (*p == '.' || *p == '\0') { + int len = q - qtop - 1; + if (len > MAXLABEL) + return (mdn_invalid_name); + *qtop = len; + qtop = q++; + if (*p == '\0') { + *qtop = 0; + return (mdn_success); + } + p++; + } else { + *q++ = *p++; + } + } + /* Name too long. */ + return (mdn_invalid_name); +} + +static int +find_label(const unsigned char *p, int limit, mdn__dn_t *ctx) { + int i; + + assert(limit <= ctx->cur); + + if (ctx == NULL) + return (-1); + + for (i = 0; i < limit; i++) { + if (match(p, ctx->msg + ctx->offset[i], ctx)) + return (ctx->offset[i]); + } + return (-1); +} + +static int +match(const unsigned char *p, const unsigned char *q, mdn__dn_t *ctx) { + for (;;) { + int len, l; + + /* Dereference 'q'. */ + while ((*q & COMPRESS_FLAG) != 0) { + int offset = get_offset(q); + + if (offset < 0 || offset > MAX_OFFSET) + return (0); + q = ctx->msg + offset; + } + + /* Check length. */ + len = *p++; + if (*q++ != len) + return (0); + + if (len == 0) + return (1); + + /* Compare labels. */ + for (l = 0; l < len; l++, p++, q++) { + if (*p == *q) + continue; + else if (*p < 128 && *q < 128 && + lcase[*p] == lcase[*q]) + continue; + else + return (0); + } + } +} + +static void +append_ptr(mdn__dn_t *ctx, unsigned char *ptr) { + if (ctx != NULL && ctx->cur < MDN_DN_NPTRS && + ptr >= ctx->msg && (ptr - ctx->msg) <= MAX_OFFSET) + ctx->offset[ctx->cur++] = ptr - ctx->msg; +} + +static int +get_offset(const unsigned char *p) { + return (((p[0] & ~COMPRESS_MASK) << 8) | p[1]); +} + +static void +init_lcase(void) { + int i; + + for (i = 0; i < 128; i++) + lcase[i] = i; + for (i = 'A'; i <= 'Z'; i++) + lcase[i] += 'a' - 'A'; +} diff --git a/contrib/idn/mdnkit/lib/lace.c b/contrib/idn/mdnkit/lib/lace.c new file mode 100644 index 0000000000..9d643a2532 --- /dev/null +++ b/contrib/idn/mdnkit/lib/lace.c @@ -0,0 +1,570 @@ +#ifndef lint +static char *rcsid = "$Id: lace.c,v 1.4 2000/11/22 01:52:18 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 + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef DEBUG +/* Be paranoid. */ +#define PARANOID +#endif + +#ifndef MDN_LACE_PREFIX +#define MDN_LACE_PREFIX "bq--" +#endif +#define LACE_PREFIX_LEN (strlen(MDN_LACE_PREFIX)) + +#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, + unsigned short *buf, size_t *lenp); +static mdn_result_t lace_encode(const char *from, size_t fromlen, + char *to, size_t tolen); +static mdn_result_t lace_encode_utf16(const unsigned short *p, + size_t len, char *to, size_t tolen, + int compress); +static int is_compress_effective(unsigned short *p, size_t len); + +/* ARGSUSED */ +mdn_result_t +mdn__lace_open(mdn_converter_t ctx, mdn_converter_dir_t dir) { + return (mdn_success); +} + +/* ARGSUSED */ +mdn_result_t +mdn__lace_close(mdn_converter_t ctx, 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) +{ + char *to = toorg; + + assert(ctx != NULL && + (dir == mdn_converter_l2u || dir == mdn_converter_u2l)); + + TRACE(("mdn__lace_convert(dir=%s,from=\"%s\")\n", + 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); + + len = prefix_len + strlen(to); + } else { + /* + * Conversion is NOT necessary. + * Copy verbatim. + */ + if (tolen < len) + return (mdn_buffer_overflow); + + (void)memcpy(to, from, len); + } + *clenp = len; + return (mdn_success); +} + +static mdn_result_t +lace_decode(const char *from, size_t fromlen, char *to, size_t tolen) { + unsigned short *buf; + unsigned short local_buf[LACE_BUF_SIZE]; + size_t len, reslen; + mdn_result_t r; + + /* + * Allocate sufficient buffer. + */ + if (fromlen > LACE_BUF_SIZE) { + if ((buf = malloc(sizeof(*buf) * fromlen)) == NULL) + return (mdn_nomemory); + } else { + /* Use local buffer. */ + buf = local_buf; + } + + /* + * Decode base32 and decompress. + */ + r = lace_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 +lace_decode_utf16(const char *from, size_t fromlen, + unsigned short *buf, size_t *lenp) +{ + unsigned short *p, *q; + unsigned int bitbuf = 0; + int bitlen = 0; + size_t len; + + /* + * 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. + */ + p = buf; + while (fromlen-- > 0) { + int c = *from++; + int x; + + if ('a' <= c && c <= 'z') + x = c - 'a'; + else if ('A' <= c && c <= 'Z') + x = c - 'A'; + else if ('2' <= c && c <= '7') + x = c - '2' + 26; + else + return (mdn_invalid_encoding); + + bitbuf = (bitbuf << 5) + x; + bitlen += 5; + if (bitlen >= 8) { + *p++ = (bitbuf >> (bitlen - 8)) & 0xff; + 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); + + /* + * Now 'buf' holds the decoded bytes. Rebuild the + * original UTF-16 string. + */ + if (buf[0] == 0xff) { + /* + * Not compressed. + */ + len--; /* skip first byte (0xff) */ + if (len % 2 != 0) { + /* number of bytes must be even. */ + return (mdn_invalid_encoding); + } + 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. + */ + int count = 0; + unsigned short high = 0; /* initialize for lint */ + + for (p = q = buf; len > 0; p++, q++, len--) { + if (count == 0) { + if (len < 3 || p[0] == 0) + return (mdn_invalid_encoding); + /* Get COUNT and HIGH. */ + count = p[0]; + high = p[1] << 8; + p += 2; + len -= 2; + } + *q = high | *p; + count--; + } + 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; + return (mdn_success); +} + +static mdn_result_t +lace_encode(const char *from, size_t fromlen, char *to, size_t tolen) { + unsigned short *buf; + unsigned short local_buf[LACE_BUF_SIZE]; /* UTF-16 */ + mdn_result_t r; + size_t buflen, len; + + /* + * Convert to UTF-16. + */ + buf = local_buf; + buflen = LACE_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 = lace_encode_utf16(buf, len, to, tolen, + is_compress_effective(buf, len)); + +ret: + if (buf != local_buf) + free(buf); + return (r); +} + +static mdn_result_t +lace_encode_utf16(const unsigned short *p, size_t len, + char *to, size_t tolen, int compress) +{ + unsigned long bitbuf = 0; /* bit stream buffer */ + int bitlen = 0; /* # of bits in 'bitbuf' */ + int compress_count = 0; + int i, j; + + if (!compress) { + /* prepend non-compression mark */ + bitbuf = 0xff; + bitlen = 8; + } + + for (i = 0; i <= len; i++) { + if (i == len) { + /* + * End of data. Flush. The current draft (-00) + * doesn't seem to define which value to use for + * padding (which it should). We assume zero. + */ + if (bitlen % 5 == 0) + break; + bitbuf <<= 5 - (bitlen % 5); /* padding with zero */ + bitlen += 5 - (bitlen % 5); + } else if (compress) { + if (compress_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++) { + if ((p[j] & 0xff00) != high) + break; + compress_count++; + } + bitbuf = (bitbuf << 16) | + (compress_count << 8) | + (high >> 8); + bitlen += 16; + } + bitbuf = (bitbuf << 8) | (p[i] & 0xff); + bitlen += 8; + compress_count--; + } else { + bitbuf = (bitbuf << 16) | p[i]; + bitlen += 16; + } + + /* + * Output bits in 'bitbuf' in 5-bit unit. + */ + while (bitlen >= 5) { + int x; + + /* Get top 5 bits. */ + x = (bitbuf >> (bitlen - 5)) & 0x1f; + bitlen -= 5; + + /* Encode. */ + if (x < 26) + x += 'a'; + else + x = (x - 26) + '2'; + + if (tolen < 1) + return (mdn_buffer_overflow); + + *to++ = x; + tolen--; + } + } + + if (tolen <= 0) + return (mdn_buffer_overflow); + + *to = '\0'; + return (mdn_success); +} + +static int +is_compress_effective(unsigned short *p, size_t len) { + unsigned short last_high = 0x1; /* initialize with an invalid value */ + int nhigh = 0; + int i; + + /* + * Find the number of HIGH value in the compressed string. + */ + for (i = 0; i < len; i++) { + unsigned short high = p[i] & 0xff00; + if (high != last_high) + nhigh++; + last_high = high; + } + + /* + * Compressed string would take 2 * 'nhigh' + 'len' bytes, + * while the original (uncomressed) string would take 2 * 'len'. + * So the difference is 2 * 'nhigh' - len. + */ + if (2 * nhigh <= len) + return (1); /* Compression is effective. */ + else + return (0); /* Nope. */ +} diff --git a/contrib/idn/mdnkit/lib/localencoding.c b/contrib/idn/mdnkit/lib/localencoding.c new file mode 100644 index 0000000000..d61a898739 --- /dev/null +++ b/contrib/idn/mdnkit/lib/localencoding.c @@ -0,0 +1,195 @@ +#ifndef lint +static char *rcsid = "$Id: localencoding.c,v 1.8 2000/09/20 02:47:31 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 + +#include +#include +#include +#include + +#ifdef HAVE_LOCALE_H +#include +#endif +#ifdef HAVE_LANGINFO_H +#include +#endif + +#include +#include +#include + +#if defined(HAVE_NL_LANGINFO) && defined(CODESET) + +/* + * This is the correct method to get the codeset name + * corresponding to the current locale. + */ +const char * +mdn_localencoding_name(void) { + char *name; + + TRACE(("mdn_localencoding_name()\n")); + if ((name = getenv(MDN_LOCALCS_ENV)) == NULL) + name = nl_langinfo(CODESET); + TRACE(("local encoding=\"%-.30s\"\n", name == NULL ? "" : name)); + return (name); +} + +#else + +typedef struct locale2encoding { + char *locale_pattern; /* locale name pattern */ + char *encoding; /* MIME-preferred charset name */ +} locale2encoding_t; + +static locale2encoding_t l2e[] = { + { "*.ISO_8859-1", "ISO-8859-1" }, + { "*.ISO_8859-2", "ISO-8859-2" }, + { "*.SJIS", "Shift_JIS" }, + { "*.Shift_JIS", "Shift_JIS" }, + { "ja_JP.EUC", "EUC-JP" }, + { "ko_KR.EUC", "EUC-KR" }, + { "*.big5" "Big5" }, + { "*.Big5" "Big5" }, + { "*.KOI8-R", "KOI8-R" }, + { "*.GB2312", "GB2312" }, +#ifdef hpux + { "japanese", "Shift_JIS" }, +#else + { "japanese", "EUC-JP" }, +#endif + { "ja", "EUC-JP" }, + { NULL, NULL }, +}; + +static const char *locale_to_encoding(const char *name); +static int match(const char *pattern, const char *str); + +const char * +mdn_localencoding_name(void) { + char *name; + + TRACE(("mdn_localencoding_name()\n")); + + if ((name = getenv(MDN_LOCALCS_ENV)) != NULL) { + TRACE(("local encoding=\"%-.30s\"\n", + name == NULL ? "" : name)); + return (name); + } + (void)( +#if HAVE_SETLOCALE + (name = setlocale(LC_CTYPE, NULL)) || +#endif + (name = getenv("LC_ALL")) || + (name = getenv("LC_CTYPE")) || + (name = getenv("LANG"))); + name = (char *)locale_to_encoding(name); + TRACE(("local encoding=\"%-.30s\"\n", name == NULL ? "" : name)); + return (name); +} + +/* + * Locale name to encoding name. + */ +static const char * +locale_to_encoding(const char *name) { + int i; + + if (name == NULL) + return (NULL); + + for (i = 0; l2e[i].locale_pattern != NULL; i++) { + if (match(l2e[i].locale_pattern, name)) + return (l2e[i].encoding); + } + return name; +} + +/* + * Wild card matching function that supports only '*'. + */ +static int +match(const char *pattern, const char *str) { + for (;;) { + int c; + + switch (c = *pattern++) { + case '\0': + return (*str == '\0'); + case '*': + while (!match(pattern, str)) { + if (*str == '\0') + return (0); + str++; + } + return (1); + break; + default: + if (*str++ != c) + return (0); + break; + } + } +} + +#endif diff --git a/contrib/idn/mdnkit/lib/log.c b/contrib/idn/mdnkit/lib/log.c new file mode 100644 index 0000000000..badea85d1e --- /dev/null +++ b/contrib/idn/mdnkit/lib/log.c @@ -0,0 +1,230 @@ +#ifndef lint +static char *rcsid = "$Id: log.c,v 1.12 2000/10/16 05:00:18 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 + +#include +#include +#include +#ifdef HAVE_UNISTD_H +#include +#endif + +#include + +#define LOGLEVEL_ENV "MDN_LOG_LEVEL" + +#ifdef DEBUG +#define DEFAULT_LOG_LEVEL mdn_log_level_info +#else +#define DEFAULT_LOG_LEVEL mdn_log_level_error +#endif + +static int log_level = -1; +static mdn_log_proc_t log_proc; + +static void initialize(void); +static void log(int level, const char *fmt, va_list args); +static void log_to_stderr(int level, const char *buf); + +void +mdn_log_fatal(const char *fmt, ...) { + va_list args; + + va_start(args, fmt); + log(mdn_log_level_fatal, fmt, args); + va_end(args); + exit(1); +} + +void +mdn_log_error(const char *fmt, ...) { + va_list args; + + va_start(args, fmt); + log(mdn_log_level_error, fmt, args); + va_end(args); +} + +void +mdn_log_warning(const char *fmt, ...) { + va_list args; + + va_start(args, fmt); + log(mdn_log_level_warning, fmt, args); + va_end(args); +} + +void +mdn_log_info(const char *fmt, ...) { + va_list args; + + va_start(args, fmt); + log(mdn_log_level_info, fmt, args); + va_end(args); +} + +void +mdn_log_trace(const char *fmt, ...) { + va_list args; + + va_start(args, fmt); + log(mdn_log_level_trace, fmt, args); + va_end(args); +} + +void +mdn_log_dump(const char *fmt, ...) { + va_list args; + + va_start(args, fmt); + log(mdn_log_level_dump, fmt, args); + va_end(args); +} + +void +mdn_log_setlevel(int level) { + if (level >= 0) + log_level = level; +} + +int +mdn_log_getlevel(void) { + initialize(); + return log_level; +} + +void +mdn_log_setproc(mdn_log_proc_t proc) { + if (proc == NULL) + log_proc = log_to_stderr; + else + log_proc = proc; +} + +static void +initialize(void) { + char *s; + + if (log_level < 0) { + if ((s = getenv(LOGLEVEL_ENV)) != NULL) { + int level = atoi(s); + if (level >= 0) + log_level = level; + } + if (log_level < 0) + log_level = DEFAULT_LOG_LEVEL; + } + + if (log_proc == NULL) + log_proc = log_to_stderr; +} + +static void +log(int level, const char *fmt, va_list args) { + char buf[1024]; + + initialize(); + + if (log_level < level) + return; + +#if HAVE_VSNPRINTF + (void)vsnprintf(buf, sizeof(buf), fmt, args); +#else + /* Let's hope 1024 is enough.. */ + (void)vsprintf(buf, fmt, args); +#endif + (*log_proc)(level, buf); +} + +static void +log_to_stderr(int level, const char *buf) { + char *title; + char tmp[20]; + + switch (level) { + case mdn_log_level_fatal: + title = "FATAL"; + break; + case mdn_log_level_error: + title = "ERROR"; + break; + case mdn_log_level_warning: + title = "WARNING"; + break; + case mdn_log_level_info: + title = "INFO"; + break; + case mdn_log_level_trace: + title = "TRACE"; + break; + case mdn_log_level_dump: + title = "DUMP"; + break; + default: + (void)sprintf(tmp, "LEVEL%d", level); + title = tmp; + break; + } + fprintf(stderr, "%u: [%s] %s", (unsigned int)getpid(), title, buf); +} diff --git a/contrib/idn/mdnkit/lib/make.os2 b/contrib/idn/mdnkit/lib/make.os2 new file mode 100644 index 0000000000..81c970551f --- /dev/null +++ b/contrib/idn/mdnkit/lib/make.os2 @@ -0,0 +1,113 @@ +# $Id: make.os2,v 1.1 2000/12/07 00:52:24 tale Exp $ +# Makefile for MDN library, manually configured for OS2 (for EMX/GCC) +# +# 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. + +ICONVDIR = ../os2 +INCDIR = ../include +CC = gcc -c +CFLAGS = -Wall -Zmtd -I$(INCDIR) -I$(ICONVDIR) -DOS2 -DHAVE_UNISTD_H -DDEBUG +LD = gcc +LDFLAGS = -Zmtd + +LIBS = +SYSLIBS = + +# +# Files to build MDN library +# + +HDRS = $(ICONVDIR)/iconv.h \ + $(INCDIR)/config.h \ + $(INCDIR)/mdn/assert.h $(INCDIR)/mdn/converter.h \ + $(INCDIR)/mdn/debug.h $(INCDIR)/mdn/localencoding.h \ + $(INCDIR)/mdn/log.h $(INCDIR)/mdn/logmacro.h \ + $(INCDIR)/mdn/msgheader.h $(INCDIR)/mdn/msgtrans.h \ + $(INCDIR)/mdn/normalizer.h $(INCDIR)/mdn/result.h \ + $(INCDIR)/mdn/selectiveencode.h $(INCDIR)/mdn/strhash.h \ + $(INCDIR)/mdn/translator.h $(INCDIR)/mdn/unicode.h \ + $(INCDIR)/mdn/unormalize.h $(INCDIR)/mdn/utf5.h \ + $(INCDIR)/mdn/utf8.h $(INCDIR)/mdn/util.h $(INCDIR)/mdn/zldrule.h + +SRCS = converter.c debug.c dn.c localencoding.c log.c \ + msgheader.c msgtrans.c normalizer.c race.c result.c \ + selectiveencode.c strhash.c translator.c \ + unicode.c unicodedata.c unormalize.c \ + utf5.c utf8.c util.c zldrule.c + +OBJS = converter.o debug.o dn.o localencoding.o log.o \ + msgheader.o msgtrans.o normalizer.o race.o result.o \ + selectiveencode.o strhash.o translator.o \ + unicode.o unormalize.o \ + utf5.o utf8.o util.o zldrule.o + +LIB = libmdn.a + +all: $(LIB) + +libmdn.a: $(OBJS) + ar d $@ __.SYMDEF + ar rs $@ $(OBJS) + +generate: + generate_normalize_data.pl > unicodedata.c + +install: + +clean: + rm -f *.o *.a core *.core *~ + diff --git a/contrib/idn/mdnkit/lib/make.wnt b/contrib/idn/mdnkit/lib/make.wnt new file mode 100644 index 0000000000..33aac1bc81 --- /dev/null +++ b/contrib/idn/mdnkit/lib/make.wnt @@ -0,0 +1,192 @@ +# $Id: make.wnt,v 1.1 2000/12/07 00:52:24 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 + +INCDIR = ..\include +ICONVDIR = ..\win +LIBS = +SYSLIBS = $(conlibsdll) + +# +# Files to build MDN library +# + +HDRS = $(ICONVDIR)\iconv.h \ + $(INCDIR)\config.h \ + $(INCDIR)\mdn\assert.h $(INCDIR)\mdn\converter.h \ + $(INCDIR)\mdn\debug.h $(INCDIR)\mdn\localencoding.h \ + $(INCDIR)\mdn\log.h $(INCDIR)\mdn\logmacro.h \ + $(INCDIR)\mdn\msgheader.h $(INCDIR)\mdn\msgtrans.h \ + $(INCDIR)\mdn\normalizer.h $(INCDIR)\mdn\result.h \ + $(INCDIR)\mdn\selectiveencode.h $(INCDIR)\mdn\strhash.h \ + $(INCDIR)\mdn\translator.h $(INCDIR)\mdn\unicode.h \ + $(INCDIR)\mdn\unormalize.h $(INCDIR)\mdn\utf5.h \ + $(INCDIR)\mdn\utf8.h $(INCDIR)\mdn\util.h $(INCDIR)\mdn\zldrule.h + +SRCS = brace.c converter.c debug.c dn.c lace.c localencoding.c log.c \ + msgheader.c msgtrans.c normalizer.c race.c \ + res.c resconf.c result.c \ + selectiveencode.c strhash.c translator.c \ + unicode.c unicodedata.c unormalize.c \ + utf5.c utf8.c util.c zldrule.c + +OBJS = brace.obj converter.obj debug.obj dn.obj lace.obj localencoding.obj log.obj \ + msgheader.obj msgtrans.obj normalizer.obj race.obj \ + res.obj resconf.obj result.obj \ + selectiveencode.obj strhash.obj translator.obj \ + unicode.obj unormalize.obj \ + utf5.obj utf8.obj util.obj zldrule.obj + +LIB = libmdn.lib + +# +# Target to build +# + +all: $(LIB) + +libmdn.lib: $(OBJS) + -del libmdn.lib + lib /out:libmdn.lib $(OBJS) + +# +# Dependencies +# + +brace.obj : brace.c $(HDRS) + $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) -DDEBUG $*.c + +converter.obj : converter.c $(HDRS) + $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) -DDEBUG $*.c + +debug.obj : debug.c $(HDRS) + $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) -DDEBUG $*.c + +dn.obj : dn.c $(HDRS) + $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) -DDEBUG $*.c + +lace.obj : lace.c $(HDRS) + $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) -DDEBUG $*.c + +localencoding.obj : localencoding.c $(HDRS) + $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) -DDEBUG $*.c + +log.obj : log.c $(HDRS) + $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) -DDEBUG $*.c + +msgheader.obj : msgheader.c $(HDRS) + $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) -DDEBUG $*.c + +msgtrans.obj : msgtrans.c $(HDRS) + $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) -DDEBUG $*.c + +normalizer.obj : normalizer.c $(HDRS) + $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) -DDEBUG $*.c + +race.obj : race.c $(HDRS) + $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) -DDEBUG $*.c + +res.obj : res.c $(HDRS) + $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) -DDEBUG $*.c + +resconf.obj : resconf.c $(HDRS) + $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) -DDEBUG $*.c + +result.obj : result.c $(HDRS) + $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) -DDEBUG $*.c + +selectiveencode.obj : selectiveencode.c $(HDRS) + $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) -DDEBUG $*.c + +strhash.obj : strhash.c $(HDRS) + $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) -DDEBUG $*.c + +translator.obj : translator.c $(HDRS) + $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) -DDEBUG $*.c + +unicode.obj : unicode.c $(HDRS) + $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) -DDEBUG $*.c + +unormalize.obj : unormalize.c $(HDRS) + $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) -DDEBUG $*.c + +utf5.obj : utf5.c $(HDRS) + $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) -DDEBUG $*.c + +utf8.obj : utf8.c $(HDRS) + $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) -DDEBUG $*.c + +util.obj : util.c $(HDRS) + $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) -DDEBUG $*.c + +zldrule.obj : zldrule.c $(HDRS) + $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -I$(ICONVDIR) -DDEBUG $*.c + +# +# mics. +# +generate: + generate_normalize_data.pl > unicodedata.c + +install: + +clean: + del *.obj *.lib core *.core *~ + diff --git a/contrib/idn/mdnkit/lib/mdnres.conf.sample b/contrib/idn/mdnkit/lib/mdnres.conf.sample new file mode 100644 index 0000000000..78a141b6df --- /dev/null +++ b/contrib/idn/mdnkit/lib/mdnres.conf.sample @@ -0,0 +1,53 @@ +# $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 diff --git a/contrib/idn/mdnkit/lib/msgheader.c b/contrib/idn/mdnkit/lib/msgheader.c new file mode 100644 index 0000000000..9eb7dcedf7 --- /dev/null +++ b/contrib/idn/mdnkit/lib/msgheader.c @@ -0,0 +1,147 @@ +#ifndef lint +static char *rcsid = "$Id: msgheader.c,v 1.7 2000/09/20 02:47:31 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 + +#include +#include + +#include +#include +#include +#include +#include + +#define DNS_HEADER_SIZE 12 + +mdn_result_t +mdn_msgheader_parse(const char *msg, size_t msglen, mdn_msgheader_t *parsed) { + const unsigned char *p = (const unsigned char *)msg; + unsigned int v; + + assert(msg != NULL && parsed != NULL); + + TRACE(("mdn_msgheader_parse(msg=<%s>, msglen=%d)\n", + mdn_debug_hexdata(msg, msglen, 12), msglen)); + + if (msglen < DNS_HEADER_SIZE) + return (mdn_invalid_message); + +#define GET16(off) ((p[off]<<8)+p[(off)+1]) + parsed->id = GET16(0); + v = GET16(2); + parsed->qr = (v & 0x8000) != 0; + parsed->opcode = (v >> 11) & 0xf; + parsed->flags = (v >> 4) & 0x7f; + parsed->rcode = v & 0xf; + parsed->qdcount = GET16(4); + parsed->ancount = GET16(6); + parsed->nscount = GET16(8); + parsed->arcount = GET16(10); +#undef GET16 + + return (mdn_success); +} + +mdn_result_t +mdn_msgheader_unparse(mdn_msgheader_t *parsed, char *msg, size_t msglen) { + unsigned char *p = (unsigned char *)msg; + unsigned int v; + + assert(parsed != NULL && msg != NULL); + + TRACE(("mdn_msgheader_unparse()\n")); + + if (msglen < DNS_HEADER_SIZE) + return (mdn_buffer_overflow); + + v = ((parsed->qr & 1) << 15) + + ((parsed->opcode & 0xf) << 11) + + ((parsed->flags & 0x7f) << 4) + + (parsed->rcode & 0xf); + +#define PUT16(off, v) p[off] = ((v)>>8) & 0xff; p[(off)+1] = (v) & 0xff + PUT16(0, parsed->id); + PUT16(2, v); + PUT16(4, parsed->qdcount); + PUT16(6, parsed->ancount); + PUT16(8, parsed->nscount); + PUT16(10, parsed->arcount); +#undef PUT16 + + return (mdn_success); +} + +unsigned int +mdn_msgheader_getid(const char *msg) { + const unsigned char *p = (const unsigned char *)msg; + + return ((p[0] << 8) + p[1]); +} + +void +mdn_msgheader_setid(char *msg, unsigned int id) { + unsigned char *p = (unsigned char *)msg; + + p[0] = (id >> 8) & 0xff; + p[1] = id & 0xff; +} diff --git a/contrib/idn/mdnkit/lib/msgtrans.c b/contrib/idn/mdnkit/lib/msgtrans.c new file mode 100644 index 0000000000..55dd8be0dc --- /dev/null +++ b/contrib/idn/mdnkit/lib/msgtrans.c @@ -0,0 +1,633 @@ +#ifndef lint +static char *rcsid = "$Id: msgtrans.c,v 1.22 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 + +#include +#include +#include +#ifdef WIN32 +#include +#include +#else /* for normal systems */ +#include +#include +#include +#include +#include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DNS_HEADER_SIZE 12 +#define DNAME_SIZE 512 +#define RRFORMAT_HASH_SIZE 47 + +/* + * DNS opcodes. + */ +enum { + opcode_query = 0, + opcode_iquery = 1, + opcode_status = 2, + opcode_notify = 4, + opcode_update = 5 +}; + +/* + * Resource record types. + */ +enum { + rrtype_A = 1, + rrtype_NS = 2, + rrtype_MD = 3, + rrtype_MF = 4, + rrtype_CNAME = 5, + rrtype_SOA = 6, + rrtype_MB = 7, + rrtype_MG = 8, + rrtype_MR = 9, + rrtype_NULL = 10, + rrtype_WKS = 11, + rrtype_PTR = 12, + rrtype_HINFO = 13, + rrtype_MINFO = 14, + rrtype_MX = 15, + rrtype_TXT = 16, + rrtype_RP = 17, + rrtype_AFSDB = 18, + rrtype_X25 = 19, + rrtype_ISDN = 20, + rrtype_RT = 21, + rrtype_AAAA = 28 +}; + +/* + * Resource record classes. + */ +enum { + rrclass_IN = 1, + rrclass_CS = 2, + rrclass_CH = 3, + rrclass_ANY = 255 +}; + +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 */ +} msgtrans_ctx_t; + +static struct rrformat { + unsigned int type; /* RR type */ + unsigned int class; /* RR class */ + const char *format; /* RDATA format */ + struct rrformat *next; /* hash chain */ +} rrformats[] = { + { rrtype_CNAME, rrclass_ANY, "D" }, + { rrtype_HINFO, rrclass_ANY, "TT" }, + { rrtype_MB, rrclass_ANY, "D" }, + { rrtype_MD, rrclass_ANY, "D" }, + { rrtype_MF, rrclass_ANY, "D" }, + { rrtype_MG, rrclass_ANY, "D" }, + { rrtype_MINFO, rrclass_ANY, "DD" }, + { rrtype_MR, rrclass_ANY, "D" }, + { rrtype_MX, rrclass_ANY, "SD" }, + { rrtype_NULL, rrclass_ANY, "R" }, + { rrtype_NS, rrclass_ANY, "D" }, + { rrtype_PTR, rrclass_ANY, "D" }, + { rrtype_SOA, rrclass_ANY, "DDLLLLL" }, + { rrtype_TXT, rrclass_ANY, "T" }, + { rrtype_A, rrclass_IN, "L" }, + { rrtype_WKS, rrclass_IN, "LCR" }, + { rrtype_RP, rrclass_ANY, "DD" }, + { rrtype_AFSDB, rrclass_ANY, "SD" }, + { rrtype_X25, rrclass_ANY, "T" }, + { rrtype_ISDN, rrclass_ANY, "TT" }, + { rrtype_RT, rrclass_ANY, "SD" }, + { rrtype_AAAA, rrclass_IN, "H" }, + { 0, 0, NULL }, +}; +static struct rrformat *rrformathash[RRFORMAT_HASH_SIZE]; + +static mdn_result_t copy_header(msgtrans_ctx_t *ctx); +static mdn_result_t translate_question(msgtrans_ctx_t *ctx); +static mdn_result_t translate_rr(msgtrans_ctx_t *ctx); +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 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 put_domainname(msgtrans_ctx_t *ctx, char *name); +static void ctx_init(msgtrans_ctx_t *ctx, + mdn_msgtrans_param_t *param, + const char *msg, size_t msglen, + char *outbuf, size_t outbufsize); +static mdn_result_t copy_rest(msgtrans_ctx_t *ctx); +static mdn_result_t copy_message(msgtrans_ctx_t *ctx, size_t len); +static size_t output_length(msgtrans_ctx_t *ctx); +static void dump_message(const char *title, const char *p, + size_t length); + + +mdn_result_t +mdn_msgtrans_translate(mdn_msgtrans_param_t *param, + 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; + + assert(param != 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)); + + if (LOGLEVEL >= mdn_log_level_dump) + dump_message("before translation", msg, msglen); + + /* + * Check message length. + */ + if (msglen < DNS_HEADER_SIZE) { + INFO(("mdn_msgtrans_translate: incoming packet too short " + "(%d octets)\n", msglen)); + return (mdn_invalid_message); + } + + /* + * Parse message header. + */ + if ((r = mdn_msgheader_parse(msg, msglen, &header)) != mdn_success) { + WARNING(("mdn_msgtrans_translate: message header " + "parsing failed: %s\n", + mdn_result_tostring(r))); + return (r); + } + + /* + * Create translation context. + */ + ctx_init(&ctx, param, msg, msglen, outbuf, outbufsize); + + /* + * We handle only query, notify and update messages. + * Do not process others. + */ + switch (header.opcode) { + case opcode_query: + case opcode_notify: + case opcode_update: + break; + default: + INFO(("mdn_msgtrans_translate: pass through message " + "whose opcode is %d", header.opcode)); + if ((r = copy_rest(&ctx)) == mdn_success) + *outmsglenp = output_length(&ctx); + return (mdn_success); + } + + /* + * Copy header part verbatim. + */ + (void)copy_header(&ctx); + + /* + * Parse question/zone section. + */ + for (i = 0; i < header.qdcount; i++) { + if ((r = translate_question(&ctx)) != mdn_success) + return (r); + } + + /* + * Translate other sections. + */ + for (i = 0; + i < header.ancount + header.nscount + header.arcount; + i++) { + if ((r = translate_rr(&ctx)) != mdn_success) + return (r); + } + + if (LOGLEVEL >= mdn_log_level_dump) + dump_message("after translation", + ctx.out, output_length(&ctx)); + + /* + * Is there anything left out? + */ + if (ctx.in_remain != 0) { + WARNING(("mdn_msgtrans_translate: garbage at the end " + "(%d octets)\n", ctx.in_remain)); + /* don't consider this as an error. */ + /* return (mdn_invalid_message); */ + } + + *outmsglenp = output_length(&ctx); + return (mdn_success); +} + +static mdn_result_t +copy_header(msgtrans_ctx_t *ctx) { + return (copy_message(ctx, DNS_HEADER_SIZE)); +} + +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, + ¶m->local_zld, + ¶m->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)); + if (r != mdn_success) + return (r); + + if ((r = put_domainname(ctx, qname_translated)) != mdn_success) + return (r); + + /* Copy QTYPE and QCLASS */ + return (copy_message(ctx, 4)); +} + +static mdn_result_t +translate_rr(msgtrans_ctx_t *ctx) { + mdn_result_t r; + unsigned char *p; + unsigned int rr_type, rr_class, rr_length; + char dname[DNAME_SIZE], dname_translated[DNAME_SIZE]; + size_t length_before; + + /* Get NAME. */ + if ((r = get_domainname(ctx, dname, sizeof(dname))) != mdn_success) + return (r); + + /* Translate NAME. */ + r = translate_name(ctx->param, dname, dname_translated, + sizeof(dname_translated)); + if (r != mdn_success) + return (r); + + if ((r = put_domainname(ctx, dname_translated)) != mdn_success) + return (r); + + /* Get TYPE and CLASS */ + if (ctx->in_remain < 10) + return (mdn_invalid_message); + p = (unsigned char *)ctx->in_ptr; +#define GET16(off) ((p[off]<<8)+p[(off)+1]) + rr_type = GET16(0); + rr_class = GET16(2); + rr_length = GET16(8); +#undef GET16 + + /* Copy TYPE, CLASS, TTL and RDLENGTH. */ + if ((r = copy_message(ctx, 10)) != mdn_success) + return (r); + + /* Remember the current output length. */ + length_before = output_length(ctx); + + /* Translate RDATA. */ + r = translate_rdata(ctx, rr_type, rr_class, rr_length); + + if (r == mdn_success) { + /* Reset RDLENGTH */ + rr_length = output_length(ctx) - length_before; + ctx->out[length_before - 2] = (rr_length >> 8) & 0xff; + ctx->out[length_before - 1] = rr_length & 0xff; + } + + return (r); +} + +static mdn_result_t +translate_rdata(msgtrans_ctx_t *ctx, unsigned int rr_type, + unsigned int rr_class, unsigned int rr_length) +{ + const char *format; + int c; + + if ((format = rdata_format(rr_type, rr_class)) == NULL) { + INFO(("mdn_msgtrans: unknown resource record type %d " + "pass through\n", rr_type)); + return (copy_message(ctx, rr_length)); + } + + while ((c = *format++) != '\0') { + int copy_len; + mdn_result_t r; + + switch (c) { + case 'D': /* domain name */ + { + int remain_org = ctx->in_remain; + + if ((r = translate_domain(ctx)) != mdn_success) + return (r); + rr_length -= remain_org - ctx->in_remain; + continue; + } + case 'T': /* character string */ + copy_len = *((unsigned char *)ctx->in_ptr) + 1; + break; + case 'C': /* 1-octet value */ + copy_len = 1; + break; + case 'S': /* 2-octet value */ + copy_len = 2; + break; + case 'L': /* 4-octet value */ + copy_len = 4; + break; + case 'H': /* 16-octet value (AAAA) */ + copy_len = 16; + break; + case 'R': /* the rest */ + copy_len = rr_length; + break; + default: + copy_len = 0; /* for gcc -Wall */ + FATAL(("mdn_msgtrans: internal error -- " + "unknown format character %c", c)); + /* NOTREACHED */ + break; + } + if ((r = copy_message(ctx, copy_len)) != mdn_success) + return (r); + rr_length -= copy_len; + } + return (mdn_success); +} + +static const char * +rdata_format(unsigned int rr_type, unsigned int rr_class) { + static int initialized; + struct rrformat *rp; + int h; + + if (!initialized) { + /* + * Build hash table. + */ + for (rp = rrformats; rp->format != NULL; rp++) { + h = rp->type % RRFORMAT_HASH_SIZE; + rp->next = rrformathash[h]; + rrformathash[h] = rp; + } + initialized = 1; + } + + /* + * Find the element with the specified type and class. + */ + h = rr_type % RRFORMAT_HASH_SIZE; + for (rp = rrformathash[h]; rp != NULL; rp = rp->next) { + if (rp->type == rr_type && + (rp->class == rr_class || rp->class == rrclass_ANY)) + return (rp->format); + } + return (NULL); +} + +static mdn_result_t +translate_domain(msgtrans_ctx_t *ctx) { + mdn_result_t r; + char dname[DNAME_SIZE], dname_translated[DNAME_SIZE]; + + /* Get NAME. */ + if ((r = get_domainname(ctx, dname, sizeof(dname))) != mdn_success) + return (r); + + /* Translate NAME. */ + r = translate_name(ctx->param, dname, dname_translated, + sizeof(dname_translated)); + if (r != mdn_success) + return (r); + + if ((r = put_domainname(ctx, dname_translated)) != mdn_success) + return (r); + + 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; + size_t n; + + r = mdn__dn_expand(ctx->in, ctx->in_len, ctx->in_ptr, + buf, bufsize, &n); + if (r == mdn_success) { + ctx->in_ptr += n; + ctx->in_remain -= n; + } + return (r); +} + +static mdn_result_t +put_domainname(msgtrans_ctx_t *ctx, char *name) { + mdn_result_t r; + size_t n; + + r = mdn__dn_compress(name, ctx->out_ptr, ctx->out_remain, + &ctx->dn_ctx, &n); + if (r == mdn_success) { + ctx->out_ptr += n; + ctx->out_remain -= n; + } + return (r); +} + +static void +ctx_init(msgtrans_ctx_t *ctx, mdn_msgtrans_param_t *param, + const char *msg, size_t msglen, char *outbuf, size_t outbufsize) +{ + 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); +} + +static mdn_result_t +copy_rest(msgtrans_ctx_t *ctx) { + return (copy_message(ctx, ctx->in_remain)); +} + +static mdn_result_t +copy_message(msgtrans_ctx_t *ctx, size_t len) { + assert(ctx != NULL); + + if (ctx->in_remain < len) + return (mdn_invalid_message); + + if (ctx->out_remain < len) + return (mdn_buffer_overflow); + + (void)memcpy(ctx->out_ptr, ctx->in_ptr, len); + + ctx->in_ptr += len; + ctx->in_remain -= len; + ctx->out_ptr += len; + ctx->out_remain -= len; + + return (mdn_success); +} + +static size_t +output_length(msgtrans_ctx_t *ctx) { + return (ctx->out_ptr - ctx->out); +} + +static void +dump_message(const char *title, const char *p, size_t length) { + DUMP(("message (%s): length %d\n", title, length)); + while (length > 0) { + int len = length < 16 ? length : 16; + DUMP((" %s\n", mdn_debug_hexdata(p, len, 16))); + p += len; + length -= len; + } +} diff --git a/contrib/idn/mdnkit/lib/normalizer.c b/contrib/idn/mdnkit/lib/normalizer.c new file mode 100644 index 0000000000..b48ce5a3e3 --- /dev/null +++ b/contrib/idn/mdnkit/lib/normalizer.c @@ -0,0 +1,867 @@ +#ifndef lint +static char *rcsid = "$Id: normalizer.c,v 1.16 2000/11/17 06:00:02 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 + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#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) + +typedef struct { + char *name; + mdn_normalizer_proc_t proc; +} normalize_scheme_t; + +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 }, +}; + +static mdn_strhash_t scheme_hash; + +static mdn_result_t expand_schemes(mdn_normalizer_t ctx); +static mdn_result_t register_standard_normalizers(void); +static mdn_result_t normalizer_ascii_lowercase(const char *from, + char *to, size_t tolen); +static mdn_result_t normalizer_ascii_uppercase(const char *from, + char *to, size_t tolen); +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)(), + 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 struct standard_normalizer { + char *name; + mdn_normalizer_proc_t proc; +} standard_normalizer[] = { + { "ascii-lowercase", normalizer_ascii_lowercase }, + { "ascii-uppercase", normalizer_ascii_uppercase }, + { "unicode-lowercase", normalizer_unicode_lowercase }, + { "unicode-uppercase", normalizer_unicode_uppercase }, + { "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 }, + { NULL, NULL }, +}; + +mdn_result_t +mdn_normalizer_initialize(void) { + mdn_strhash_t hash; + mdn_result_t r; + + if (scheme_hash != NULL) + return (mdn_success); /* already initialized */ + + if ((r = mdn_strhash_create(&hash)) != mdn_success) { + WARNING(("mdn_normalizer_initialize: " + "hash table creation failed\n")); + return (r); + } + scheme_hash = hash; + + /* Register standard normalizers */ + return (register_standard_normalizers()); +} + +mdn_result_t +mdn_normalizer_create(mdn_normalizer_t *ctxp) { + mdn_normalizer_t ctx; + + assert(ctxp != NULL); + TRACE(("mdn_normalizer_create()\n")); + + if ((ctx = malloc(sizeof(struct mdn_normalizer))) == NULL) { + WARNING(("mdn_normalizer_create: malloc failed\n")); + return (mdn_nomemory); + } + + ctx->nschemes = 0; + ctx->scheme_size = MAX_LOCAL_SCHEME; + ctx->schemes = ctx->local_buf; + *ctxp = ctx; + + return (mdn_success); +} + +void +mdn_normalizer_destroy(mdn_normalizer_t ctx) { + assert(ctx != NULL); + + TRACE(("mdn_normalizer_destroy()\n")); + + if (ctx->schemes != ctx->local_buf) + free(ctx->schemes); + + free(ctx); +} + +mdn_result_t +mdn_normalizer_add(mdn_normalizer_t ctx, const char *scheme_name) { + mdn_result_t r; + void *v; + normalize_scheme_t *scheme; + + assert(ctx != NULL && scheme_name != NULL); + + TRACE(("mdn_normalizer_add(scheme_name=%s)\n", scheme_name)); + + assert(INITIALIZED); + + if (mdn_strhash_get(scheme_hash, scheme_name, &v) != mdn_success) { + WARNING(("mdn_normalizer_add: invalid scheme %s\n", + scheme_name)); + return (mdn_invalid_name); + } + + scheme = v; + + assert(ctx->nschemes <= ctx->scheme_size); + + if (ctx->nschemes == ctx->scheme_size && + (r = expand_schemes(ctx)) != mdn_success) { + WARNING(("mdn_normalizer_add: malloc failed\n")); + return (r); + } + + ctx->schemes[ctx->nschemes++] = scheme; + return (mdn_success); +} + + +mdn_result_t +mdn_normalizer_normalize(mdn_normalizer_t ctx, const char *from, + char *to, size_t tolen) +{ + assert(ctx != NULL && from != NULL && to != NULL); + + TRACE(("mdn_normalizer_normalize(from=\"%s\")\n", + mdn_debug_xstring(from, 20))); + + if (ctx->nschemes == 0) { + /* No normalization needed. */ + size_t flen = strlen(from); + + if (tolen < flen + 1) + return (mdn_buffer_overflow); + memcpy(to, from, flen + 1); /* +1 for NUL */ + return (mdn_success); + } else if (ctx->nschemes == 1) { + /* No temporary buffer needed. */ + TRACE(("mdn_normalizer_normalize: nomalization %s\n", + ctx->schemes[0]->name)); + return ((*ctx->schemes[0]->proc)(from, to, tolen)); + } else { + /* + * Allocate two intermediate buffers. + */ + char *buffer[2]; + char local_buf[2][1024]; /* usually big enough */ + size_t buffer_size[2]; + mdn_result_t r = mdn_success; + int i; + + /* + * Initialize the buffers to use the local + * storage (stack memory). + */ + buffer[0] = local_buf[0]; + buffer[1] = local_buf[1]; + buffer_size[0] = sizeof(local_buf[0]); + buffer_size[1] = sizeof(local_buf[1]); + + for (i = 0; i < ctx->nschemes; i++) { + const char *f; + char *t; + size_t len; + int f_idx = i % 2; + int t_idx = !f_idx; + + TRACE(("mdn_normalizer_normalize: nomalization %s\n", + ctx->schemes[i]->name)); + + /* + * Set up from/to buffers. + */ + retry: + if (i == 0) + f = from; + else + f = buffer[f_idx]; + if (i == ctx->nschemes - 1) { + t = to; + len = tolen; + } else { + t = buffer[t_idx]; + len = buffer_size[t_idx]; + } + + /* + * Call the normalize procedure. + */ + r = (*ctx->schemes[i]->proc)(f, t, len); + + if (r == mdn_buffer_overflow && t != to) { + /* + * Temporary buffer is too small. + * Make it bigger. + */ + char *p; + + TRACE(("mdn_normalizer_normalize: " + "allocating temporary buffer\n")); + + /* Make it double. */ + buffer_size[t_idx] *= 2; + + if (buffer[t_idx] == local_buf[t_idx]) { + size_t flen = strlen(f) + 100; + if (buffer_size[t_idx] < flen) + buffer_size[t_idx] = flen; + p = malloc(buffer_size[t_idx]); + } else { + p = realloc(buffer[t_idx], + buffer_size[t_idx]); + } + if (p == NULL) { + WARNING(("mdn_normalizer_normalize: " + "malloc failed\n")); + r = mdn_nomemory; + goto ret; + } + buffer[t_idx] = p; + /* Start it over again. */ + goto retry; + } else if (r != mdn_success) { + break; + } + } + + ret: + if (buffer[0] != local_buf[0]) + free(buffer[0]); + if (buffer[1] != local_buf[1]) + free(buffer[1]); + + return (r); + } +} + +mdn_result_t +mdn_normalizer_register(const char *scheme_name, mdn_normalizer_proc_t proc) { + mdn_result_t r; + normalize_scheme_t *scheme; + + assert(scheme_name != NULL && proc != NULL); + + TRACE(("mdn_normalizer_register(scheme_name=%s)\n", scheme_name)); + + assert(INITIALIZED); + + scheme = malloc(sizeof(*scheme) + strlen(scheme_name) + 1); + if (scheme == NULL) { + WARNING(("mdn_normalizer_register: malloc failed\n")); + return (mdn_nomemory); + } + scheme->name = (char *)(scheme + 1); + (void)strcpy(scheme->name, scheme_name); + scheme->proc = proc; + + r = mdn_strhash_put(scheme_hash, scheme_name, scheme); + if (r != mdn_success) + WARNING(("mdn_normalizer_register: registration failed\n")); + + return (r); +} + +static mdn_result_t +expand_schemes(mdn_normalizer_t ctx) { + normalize_scheme_t **new_schemes; + int new_size = ctx->scheme_size * 2; + + if (ctx->schemes == ctx->local_buf) { + new_schemes = malloc(sizeof(normalize_scheme_t) * new_size); + } else { + new_schemes = realloc(ctx->schemes, + sizeof(normalize_scheme_t) * new_size); + } + if (new_schemes == NULL) + return (mdn_nomemory); + + if (ctx->schemes == ctx->local_buf) + memcpy(new_schemes, ctx->local_buf, sizeof(ctx->local_buf)); + + ctx->schemes = new_schemes; + ctx->scheme_size = new_size; + + return (mdn_success); +} + +static mdn_result_t +register_standard_normalizers(void) { + int i; + int failed = 0; + + for (i = 0; standard_normalizer[i].name != NULL; i++) { + mdn_result_t r; + r = mdn_normalizer_register(standard_normalizer[i].name, + standard_normalizer[i].proc); + if (r != mdn_success) { + WARNING(("mdn_normalizer_initialize: " + "failed to register \"%-.100s\"\n", + standard_normalizer[i].name)); + failed++; + } + } + if (failed > 0) + return (mdn_failure); + else + return (mdn_success); +} + +/* + * Standard Normalizer + */ + +static mdn_result_t +normalizer_ascii_lowercase(const char *from, char *to, size_t tolen) { + size_t fromlen = strlen(from); + + while (fromlen > 0 && tolen > 0) { + int w = mdn_utf8_mblen(from); + + if (w == 0 || fromlen < w) + return (mdn_invalid_encoding); + else if (tolen < w) + return (mdn_buffer_overflow); + + if (w == 1 && isupper((unsigned char)*from)) { + *to++ = tolower((unsigned char)(*from++)); + } else { + int i = w; + while (i-- > 0) + *to++ = *from++; + } + fromlen -= w; + tolen -= w; + } + if (tolen <= 0) + return (mdn_buffer_overflow); + + *to = '\0'; + return (mdn_success); +} + +static mdn_result_t +normalizer_ascii_uppercase(const char *from, char *to, size_t tolen) { + size_t fromlen = strlen(from); + + while (fromlen > 0 && tolen > 0) { + int w = mdn_utf8_mblen(from); + + if (w == 0 || fromlen < w) + return (mdn_invalid_encoding); + else if (tolen < w) + return (mdn_buffer_overflow); + + if (w == 1 && islower((unsigned char)*from)) { + *to++ = toupper((unsigned char)(*from++)); + } else { + int i = w; + while (i-- > 0) + *to++ = *from++; + } + fromlen -= w; + tolen -= w; + } + if (tolen <= 0) + return (mdn_buffer_overflow); + + *to = '\0'; + return (mdn_success); +} + +static mdn_result_t +normalizer_unicode_lowercase(const char *from, char *to, size_t tolen) { + return (normalizer_unicode_caseconv(mdn__unicode_tolower, + from, to, tolen)); +} + +static mdn_result_t +normalizer_unicode_uppercase(const char *from, char *to, size_t tolen) { + return (normalizer_unicode_caseconv(mdn__unicode_toupper, + from, to, tolen)); +} + +static mdn_result_t +normalizer_unicode_caseconv(mdn_result_t (*caseconv)(), + const char *from, char *to, size_t tolen) +{ + size_t fromlen = strlen(from); + + while (fromlen > 0 && tolen > 0) { +#define CASEMAPBUFSZ 4 + unsigned long c; + unsigned long v[CASEMAPBUFSZ]; + mdn_result_t r; + mdn__unicode_context_t ctx = mdn__unicode_context_unknown; + size_t vlen; + int w; + int i; + + if ((w = mdn_utf8_getwc(from, fromlen, &c)) == 0) + return (mdn_invalid_encoding); + from += w; + fromlen -= w; + + redo: + r = (*caseconv)(c, ctx, v, CASEMAPBUFSZ, &vlen); + switch (r) { + case mdn_success: + break; + case mdn_context_required: + ctx = get_casemap_context(from, fromlen); + goto redo; + case mdn_buffer_overflow: + FATAL(("mdn_normalizer_normalize: " + "internal buffer overflow\n")); + break; + default: + return (r); + } + + 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 (tolen <= 0) + return (mdn_buffer_overflow); + + *to = '\0'; + return (mdn_success); +} + +static mdn__unicode_context_t +get_casemap_context(const char *from, size_t fromlen) { + while (fromlen > 0) { + unsigned long v; + mdn__unicode_context_t ctx; + int w; + + if ((w = mdn_utf8_getwc(from, fromlen, &v)) == 0) + return (mdn_invalid_encoding); + from += w; + fromlen -= w; + ctx = mdn__unicode_getcontext(v); + if (ctx == mdn__unicode_context_nonfinal || + ctx == mdn__unicode_context_final) + return (ctx); + } + return (mdn__unicode_context_final); +} + +static mdn_result_t +normalizer_ja_minus_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_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; + + if ((width = mdn_utf8_getwc(from, fromlen, &ucs)) == 0) + return (mdn_invalid_encoding); + from += width; + fromlen -= width; + + 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]; + } + + 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 = '-'; + } + + 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_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); +} diff --git a/contrib/idn/mdnkit/lib/race.c b/contrib/idn/mdnkit/lib/race.c new file mode 100644 index 0000000000..fbc2842393 --- /dev/null +++ b/contrib/idn/mdnkit/lib/race.c @@ -0,0 +1,539 @@ +#ifndef lint +static char *rcsid = "$Id: race.c,v 1.14 2000/11/22 01:52:18 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 + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#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 + +#define RACE_BUF_SIZE 128 /* more than enough */ + +/* + * Unicode surrogate pair. + */ +#define IS_SURROGATE_HIGH(v) (0xd800 <= (v) && (v) <= 0xdbff) +#define IS_SURROGATE_LOW(v) (0xdc00 <= (v) && (v) <= 0xdfff) +#define SURROGATE_HIGH(v) (SURROGATE_H_OFF + (((v) - 0x10000) >> 10)) +#define SURROGATE_LOW(v) (SURROGATE_L_OFF + ((v) & 0x3ff)) +#define SURROGATE_BASE 0x10000 +#define SURROGATE_H_OFF 0xd800 +#define SURROGATE_L_OFF 0xdc00 +#define COMBINE_SURROGATE(h, l) \ + (SURROGATE_BASE + (((h)-SURROGATE_H_OFF)<<10) + ((l)-SURROGATE_L_OFF)) + +/* + * Compression type. + */ +enum { + compress_one, /* all characters are in a single row */ + compress_two, /* row 0 and another row */ + compress_none, /* nope */ +}; + +static 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, + size_t fromlen, + unsigned short *buf, + size_t *lenp); +static mdn_result_t race_encode(const char *from, size_t fromlen, + char *to, size_t tolen); +static mdn_result_t race_compress_encode(const unsigned short *p, + size_t len, int compress_mode, + char *to, size_t tolen); +static int get_compress_mode(unsigned short *p, size_t len); + +/* ARGSUSED */ +mdn_result_t +mdn__race_open(mdn_converter_t ctx, mdn_converter_dir_t dir) { + return (mdn_success); +} + +/* ARGSUSED */ +mdn_result_t +mdn__race_close(mdn_converter_t ctx, 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) +{ + char *to = toorg; + + assert(ctx != NULL && + (dir == mdn_converter_l2u || dir == mdn_converter_u2l)); + + TRACE(("mdn__race_convert(dir=%s,from=\"%s\")\n", + 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); + } 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. + */ + + if (tolen < len) + return (mdn_buffer_overflow); + + (void)memcpy(to, from, len); + } + *clenp = len; + return (mdn_success); +} + +static mdn_result_t +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; + mdn_result_t r; + + /* + * Allocate sufficient buffer. + */ + if (fromlen > RACE_BUF_SIZE) { + if ((buf = malloc(sizeof(*buf) * fromlen)) == NULL) + return (mdn_nomemory); + } else { + /* Use local buffer. */ + buf = local_buf; + } + + /* + * Decode base32 and decompress. + */ + r = race_decode_decompress(from, fromlen, buf, &len); + if (r != mdn_success) + goto ret; + + /* + * Now 'buf' points the decompressed string, which must contain + * UTF-16 characters. + */ + + /* + * Convert to UTF-8. + */ + r = mdn_util_utf16toutf8(buf, len, to, tolen, &reslen); + if (r != mdn_success) + goto ret; + + 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 +race_decode_decompress(const char *from, size_t fromlen, + unsigned short *buf, size_t *lenp) +{ + unsigned short *p = buf; + unsigned int bitbuf = 0; + int bitlen = 0; + int i, j; + size_t len; + + while (fromlen-- > 0) { + int c = *from++; + int x; + + if ('a' <= c && c <= 'z') + x = c - 'a'; + else if ('A' <= c && c <= 'Z') + x = c - 'A'; + else if ('2' <= c && c <= '7') + x = c - '2' + 26; + else + return (mdn_invalid_encoding); + + bitbuf = (bitbuf << 5) + x; + bitlen += 5; + if (bitlen >= 8) { + *p++ = (bitbuf >> (bitlen - 8)) & 0xff; + bitlen -= 8; + } + } + len = p - buf; + + /* + * Now 'buf' holds the decoded string. + */ + + /* + * Decompress. + */ + if (buf[0] == RACE_2OCTET_MODE) { + if ((len - 1) % 2 != 0) + return (mdn_invalid_encoding); + for (i = 1, j = 0; i < len; i += 2, j++) + buf[j] = (buf[i] << 8) + buf[i + 1]; + len = j; + } else { + unsigned short c = buf[0] << 8; /* higher octet */ + + for (i = 1, j = 0; i < len; j++) { + if (buf[i] == RACE_ESCAPE) { + if (i + 1 >= len) + return (mdn_invalid_encoding); + else if (buf[i + 1] == RACE_ESCAPE_2ND) + buf[j] = c | 0xff; + else + buf[j] = buf[i + 1]; + i += 2; + } else { + buf[j] = c | buf[i++]; + } + } + len = j; + } + *lenp = len; + return (mdn_success); +} + +static mdn_result_t +race_encode(const char *from, size_t fromlen, char *to, size_t tolen) { + unsigned short *p, *buf; + unsigned short local_buf[RACE_BUF_SIZE]; /* UTF-16 */ + mdn_result_t r; + size_t len, buflen; + int compress_mode; + + /* + * Convert to UTF-16. + * Preserve space for a character at the top of the buffer. + */ + buf = local_buf; + buflen = RACE_BUF_SIZE; + for (;;) { + r = mdn_util_utf8toutf16(from, fromlen, + buf + 1, buflen - 1, &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; + } + } + p = buf + 1; + + /* + * Now 'p' contains UTF-16 encoded string. + */ + + /* + * Compress, encode in base-32 and output. + */ + compress_mode = get_compress_mode(p, len); + r = race_compress_encode(buf, len + 1, compress_mode, to, tolen); + +ret: + if (buf != local_buf) + free(buf); + return (r); +} + +static mdn_result_t +race_compress_encode(const unsigned short *p, size_t len, int compress_mode, + char *to, size_t tolen) +{ + unsigned long bitbuf = 0; /* bit stream buffer */ + int bitlen = 0; /* # of bits in 'bitbuf' */ + int i; + + for (i = 0; i <= len; i++) { + if (i == len) { + /* End of data. Flush. */ + if (bitlen == 0) + break; + bitbuf <<= (5 - bitlen); + bitlen = 5; + } else if (i == 0 || compress_mode == compress_one) { + /* Push 8 bit data into bitbuf. */ + bitbuf = (bitbuf << 8) | (p[i] & 0xff); + bitlen += 8; + } else if (compress_mode == compress_two) { + /* Push 8 or 16 bit data. */ + if ((p[i] & 0xff00) == 0) { + /* Upper octet is zero. */ + bitbuf = (bitbuf << 16) | 0xff00 | p[i]; + bitlen += 16; + } else if ((p[i] & 0xff) == 0xff) { + /* Lower octet is 0xff. */ + bitbuf = (bitbuf << 16) | + (RACE_ESCAPE << 8) | RACE_ESCAPE_2ND; + bitlen += 16; + } else { + bitbuf = (bitbuf << 8) | (p[i] & 0xff); + bitlen += 8; + } + } else { /* compresss_mode == compress_none */ + /* Push 16 bit data. */ + bitbuf = (bitbuf << 16) | p[i]; + bitlen += 16; + } + + /* + * Output bits in 'bitbuf' in 5-bit unit. + */ + while (bitlen >= 5) { + int x; + + /* Get top 5 bits. */ + x = (bitbuf >> (bitlen - 5)) & 0x1f; + bitlen -= 5; + + /* Encode. */ + if (x < 26) + x += 'a'; + else + x = (x - 26) + '2'; + + if (tolen < 1) + return (mdn_buffer_overflow); + + *to++ = x; + tolen--; + } + } + + if (tolen <= 0) + return (mdn_buffer_overflow); + + *to = '\0'; + return (mdn_success); +} + +static int +get_compress_mode(unsigned short *p, size_t len) { + int zero = 0; + unsigned int upper = 0; + int i; + + for (i = 0; i < len; i++) { + unsigned int hi = p[i] & 0xff00; + + if (hi == 0) { + zero++; + } else if (hi == upper) { + ; + } else if (upper == 0) { + upper = hi; + } else { + p[-1] = RACE_2OCTET_MODE; + return (compress_none); + } + } + p[-1] = upper >> 8; + if (upper > 0 && zero > 0) + return (compress_two); + else + return (compress_one); +} diff --git a/contrib/idn/mdnkit/lib/res.c b/contrib/idn/mdnkit/lib/res.c new file mode 100644 index 0000000000..f0a5362844 --- /dev/null +++ b/contrib/idn/mdnkit/lib/res.c @@ -0,0 +1,285 @@ +#ifndef lint +static char *rcsid = "$Id: res.c,v 1.5 2000/09/20 02:47:32 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 + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +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_converter_t conv; + mdn_result_t r; + + assert(local_name != NULL && ucs_name != NULL); + + TRACE(("mdn_res_localtoucs(local_name=\"%-.20s\")\n", local_name)); + + if (conf == NULL) + return (copy_verbatim(local_name, ucs_name, ucs_name_len)); + + 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) + return (r); + } + + if ((conv = mdn_resconf_localconverter(conf)) == NULL) + return (copy_verbatim(local_name, ucs_name, ucs_name_len)); + + TRACE(("mdn_res_localtoucs: using local converter..\n")); + return (mdn_converter_convert(conv, mdn_converter_l2u, + local_name, ucs_name, ucs_name_len)); +} + +mdn_result_t +mdn_res_ucstolocal(mdn_resconf_t conf, const char *ucs_name, + char *local_name, size_t local_name_len) +{ + mdn_converter_t conv; + mdn_result_t r; + + assert(ucs_name != NULL && local_name != NULL); + + TRACE(("mdn_res_ucstolocal(ucs_name=\"%s\")\n", + mdn_debug_xstring(ucs_name, 20))); + + if (conf == NULL || + (conv = mdn_resconf_localconverter(conf)) == NULL) + return (copy_verbatim(ucs_name, local_name, local_name_len)); + + r = mdn_converter_convert(conv, mdn_converter_u2l, + ucs_name, local_name, local_name_len); + + 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); + } + return (r); +} + +mdn_result_t +mdn_res_normalize(mdn_resconf_t conf, const char *name, + char *normalized_name, size_t normalized_name_len) +{ + mdn_normalizer_t norm; + + assert(name != NULL && normalized_name != NULL); + + TRACE(("mdn_res_normalize(name=\"%s\")\n", + mdn_debug_xstring(name, 20))); + + 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)); +} + +mdn_result_t +mdn_res_ucstodns(mdn_resconf_t conf, const char *ucs_name, char *dns_name, + size_t dns_name_len) +{ + mdn_converter_t conv; + mdn_result_t r; + const char *zld; + + assert(ucs_name != NULL && dns_name != NULL); + + TRACE(("mdn_res_ucstodns(ucs_name=\"%s\")\n", + mdn_debug_xstring(ucs_name, 20))); + + if (conf == NULL || + (conv = mdn_resconf_serverconverter(conf)) == NULL || + !contain_invalid_char(ucs_name)) + return (copy_verbatim(ucs_name, dns_name, dns_name_len)); + + r = mdn_converter_convert(conv, mdn_converter_u2l, + ucs_name, dns_name, dns_name_len); + if (r != mdn_success) + return (r); + + if ((zld = mdn_resconf_zld(conf)) != NULL) { + size_t len; + + 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 (len + strlen(zld) >= dns_name_len) + return (mdn_buffer_overflow); + (void)strcat(dns_name, zld); + } + return (mdn_success); +} + +mdn_result_t +mdn_res_dnstoucs(mdn_resconf_t conf, const char *dns_name, char *ucs_name, + size_t ucs_name_len) +{ + 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); + } else { + convert = 0; + } + } else if (!mdn_converter_isasciicompatible(conv) && + !contain_invalid_char(dns_name)) { + convert = 0; + } else { + convert = 1; + } + + 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)); + } else { + return (copy_verbatim(dns_name, ucs_name, ucs_name_len)); + } +} + +static mdn_result_t +copy_verbatim(const char *from, char *to, size_t tolen) { + size_t fromlen = strlen(from) + 1; + + if (tolen < fromlen) + return (mdn_buffer_overflow); + (void)memcpy(to, from, fromlen); + 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); +} diff --git a/contrib/idn/mdnkit/lib/resconf.c b/contrib/idn/mdnkit/lib/resconf.c new file mode 100644 index 0000000000..ae56fc0769 --- /dev/null +++ b/contrib/idn/mdnkit/lib/resconf.c @@ -0,0 +1,468 @@ +#ifndef lint +static char *rcsid = "$Id: resconf.c,v 1.4 2000/09/20 02:47:32 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 + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef MDN_RESCONF_DIR +#define MDN_RESCONF_DIR "/etc" +#endif +#define MDN_RESCONF_FILE MDN_RESCONF_DIR "/mdnres.conf" + +struct mdn_resconf { + char *local_encoding; + mdn_converter_t local_converter; + mdn_converter_t alternate_converter; + mdn_converter_t server_converter; + mdn_normalizer_t normalizer; + char *zld; + int edns0; +}; + +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 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); + +mdn_result_t +mdn_resconf_initialize(void) { + mdn_result_t r; + + TRACE(("mdn_resconf_initialize()\n")); + + if ((r = mdn_converter_initialize()) != mdn_success) + return (r); + if ((r = mdn_normalizer_initialize()) != mdn_success) + return (r); + return (r); +} + +mdn_result_t +mdn_resconf_create(mdn_resconf_t *ctxp) { + mdn_resconf_t ctx = NULL; + + assert(ctxp != NULL); + + TRACE(("mdn_resconf_create()\n")); + + if ((ctx = malloc(sizeof(*ctx))) == NULL) + return (mdn_nomemory); + ctx->local_encoding = NULL; + ctx->local_converter = NULL; + ctx->server_converter = NULL; + ctx->alternate_converter = NULL; + ctx->normalizer = NULL; + ctx->zld = NULL; + ctx->edns0 = 0; + *ctxp = ctx; + return (mdn_success); +} + +char * +mdn_resconf_defaultfile() { + return MDN_RESCONF_FILE; +} + +mdn_result_t +mdn_resconf_loadfile(mdn_resconf_t ctx, const char *file) { + FILE *fp; + mdn_result_t r; + + assert(ctx != NULL); + + TRACE(("mdn_resconf_loadfile(file=%s)\n", + file == NULL ? "" : file)); + + if ((r = mdn_converter_resetalias()) != mdn_success) + return (r); + + resetconf(ctx); + + if (file == NULL) + file = mdn_resconf_defaultfile(); + if ((fp = fopen(file, "r")) == NULL) { + TRACE(("mdn_resconf_loadfile: cannot open %-.40s\n", file)); + return (mdn_nofile); + } + + r = parse_conf(ctx, fp); + fclose(fp); + + return (r); +} + +void +mdn_resconf_destroy(mdn_resconf_t ctx) { + TRACE(("mdn_resconf_destroy()\n")); + resetconf(ctx); + free(ctx); +} + +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_converter_t +mdn_resconf_serverconverter(mdn_resconf_t ctx) { + TRACE(("mdn_resconf_serverconverter()\n")); + return (ctx->server_converter); +} + +mdn_converter_t +mdn_resconf_alternateconverter(mdn_resconf_t ctx) { + TRACE(("mdn_resconf_alternateconverter()\n")); + return (ctx->alternate_converter); +} + +const char * +mdn_resconf_zld(mdn_resconf_t ctx) { + TRACE(("mdn_resconf_zld()\n")); + return (ctx->zld); +} + +mdn_normalizer_t +mdn_resconf_normalizer(mdn_resconf_t ctx) { + TRACE(("mdn_resconf_normalizer()\n")); + return (ctx->normalizer); +} + +static mdn_result_t +parse_conf(mdn_resconf_t ctx, FILE *fp) { + char line[256]; + char *argv[20]; + int argc; + mdn_result_t r; + char *sencoding_line = NULL; + char *fencoding_line = NULL; + + /* + * Parse config file. parsing of 'server-encoding' and + * 'alternate-encoding' lines are postponed because + * 'alias-file' line must be processed before them. + */ + while (fgets(line, sizeof(line), fp) != NULL) { + char buf[256]; + + if (line[0] == '\n') + continue; + + (void)strcpy(buf, line); + argc = split_args(buf, argv, 20); + 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 { + mdn_log_error("mdnres: unrecognized command " + "\"%-.30s\"\n", argv[0]); + 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); + 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 (r != mdn_success) + return (r); + } + + return (mdn_success); +} + +static mdn_result_t +parse_normalize(mdn_resconf_t ctx, int argc, char **argv) { + mdn_result_t r; + int i; + + if (ctx->normalizer == NULL) { + r = mdn_normalizer_create(&ctx->normalizer); + if (r != mdn_success) + return (r); + } + for (i = 1; i < argc; i++) { + r = mdn_normalizer_add(ctx->normalizer, argv[i]); + if (r != mdn_success) { + if (r == mdn_invalid_name) + mdn_log_error("mdnres: unknown " + "normalization scheme %-.30s\n", + argv[i]); + 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]); + return (mdn_invalid_syntax); + } + return (mdn_converter_aliasfile(argv[1])); +} + +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]); + return (mdn_invalid_syntax); + } + return (mdn_converter_create(argv[1], &ctx->server_converter, + MDN_CONVERTER_DELAYEDOPEN)); +} + +static mdn_result_t +parse_server_zld(mdn_resconf_t ctx, int argc, char **argv) { +#ifdef MDN_SUPPORT_ZLD + mdn_result_t r; + + if (argc != 2) { + mdn_log_error("mdnres: wrong # of args for %s\n", argv[0]); + return (mdn_invalid_syntax); + } + r = mdn_translator_canonicalzld(argv[1], &ctx->zld); + if (r != mdn_success) + return (r); + + return (mdn_success); +#else + mdn_log_warning("mdnres: ZLD support is disabled -- ignored\n"); + return (mdn_success); +#endif /* MDN_SUPPORT_ZLD */ +} + +static mdn_result_t +parse_alternate_encoding(mdn_resconf_t ctx, int argc, char **argv) { + mdn_result_t r; + + if (argc != 2) { + mdn_log_error("mdnres: wrong # of args for %s\n", argv[0]); + 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); + } + return (r); +} + +static int +split_args(char *s, char **av, int nav) { + int i; + + for (i = 0; i < nav; i++) { + while (isspace((unsigned char)*s)) + s++; + if (*s == '\0') + break; + if (*s == '"' || *s == '\'') { + int qc = *s++; + av[i] = s; + while (*s != '\0' && *s != qc) + s++; + } else { + av[i] = s; + while (*s != '\0' && !isspace((unsigned char)*s)) + s++; + } + if (*s == '\0') + return (i + 1); + *s++ = '\0'; + } + return (i); +} + +static void +resetconf(mdn_resconf_t ctx) { + if (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->alternate_converter != NULL) { + mdn_converter_destroy(ctx->alternate_converter); + ctx->alternate_converter = NULL; + } + if (ctx->normalizer != NULL) { + mdn_normalizer_destroy(ctx->normalizer); + ctx->normalizer = NULL; + } + if (ctx->zld != NULL) { + free(ctx->zld); + ctx->zld = 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(); + + if (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) { + return (mdn_success); + } + + if (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); + if (r != mdn_success) + return (r); + r = mdn_converter_create(ctx->local_encoding, + &ctx->local_converter, + MDN_CONVERTER_RTCHECK); + return (r); +} + +static mdn_result_t +mystrdup(const char *from, char **top) { + char *s = malloc(strlen(from) + 1); + + if (*top != NULL) { + free(*top); + *top = NULL; + } + + if (s == NULL) + return (mdn_nomemory); + (void)strcpy(s, from); + *top = s; + return (mdn_success); +} diff --git a/contrib/idn/mdnkit/lib/result.c b/contrib/idn/mdnkit/lib/result.c new file mode 100644 index 0000000000..eb66ca59c4 --- /dev/null +++ b/contrib/idn/mdnkit/lib/result.c @@ -0,0 +1,88 @@ +#ifndef lint +static char *rcsid = "$Id: result.c,v 1.9 2000/09/27 02:55:38 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 +#include + +static char *result_string[] = { + "success", + "not found", + "invalid encoding found", + "syntax error", + "invalid name", + "invalid message", + "buffer overflow", + "no such entry", + "out of memory", + "no such file", + "no mapping to output codeset", + "context information required", + "generic failure", +}; + +char * +mdn_result_tostring(mdn_result_t result) { + if (result < 0 || result > mdn_failure) + return ("unknown result code"); + + return (result_string[result]); +} diff --git a/contrib/idn/mdnkit/lib/selectiveencode.c b/contrib/idn/mdnkit/lib/selectiveencode.c new file mode 100644 index 0000000000..683dfe4452 --- /dev/null +++ b/contrib/idn/mdnkit/lib/selectiveencode.c @@ -0,0 +1,140 @@ +#ifndef lint +static char *rcsid = "$Id: selectiveencode.c,v 1.7 2000/09/20 02:47:32 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 + +#include + +#include +#include +#include +#include +#include + +static int is_domain_delimiter(char c); +static char *find_nonascii(const char *s); + +mdn_result_t +mdn_selectiveencode_findregion(const char *s, + char **startp, char **endp) +{ + char *non_ascii; + char *start, *end; + + assert(s != NULL && startp != NULL && endp != NULL); + + TRACE(("mdn_selectiveencode_findregion(s=\"%s\")\n", + mdn_debug_xstring(s, 20))); + + /* + * Scan the specified string looking for non-ascii character. + */ + if ((non_ascii = find_nonascii(s)) == NULL) + return (mdn_notfound); + + /* + * Non-ascii character found. + * Determine the region to encode. + */ + + /* + * First, we scan backwards to find the beginning of the region + * that should be converted. + */ + start = non_ascii; + while (start > s) { + char *prev = mdn_utf8_findfirstbyte(start - 1, s); + if (is_domain_delimiter(*prev)) + break; /* Found */ + start = prev; + } + *startp = start; + + /* + * Next we scan forwards looking for the end of the region. + */ + end = non_ascii + mdn_utf8_mblen(non_ascii); + while (!is_domain_delimiter(*end)) + end += mdn_utf8_mblen(end); + *endp = end; + + return (mdn_success); +} + +static int +is_domain_delimiter(char c) { + return ((unsigned char)c < 0x80 && + !('A' <= c && c <= 'Z') && + !('a' <= c && c <= 'z') && + !('0' <= c && c <= '9') && + c != '-' && c != '.'); +} + +static char * +find_nonascii(const char *s) { + while (*s != '\0' && (unsigned char)*s < 0x80) + s++; + if (*s == '\0') + return (NULL); + else + return ((char *)s); +} diff --git a/contrib/idn/mdnkit/lib/strhash.c b/contrib/idn/mdnkit/lib/strhash.c new file mode 100644 index 0000000000..9353db05e1 --- /dev/null +++ b/contrib/idn/mdnkit/lib/strhash.c @@ -0,0 +1,299 @@ +#ifndef lint +static char *rcsid = "$Id: strhash.c,v 1.8 2000/09/20 02:47:32 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 + +#include +#include +#include + +#include +#include +#include +#include + +/* + * Initially, the number of hash buckets is INITIAL_HASH_SIZE. + * As the more elements are put in the hash, the number of elements + * per bucket will exceed THRESHOLD eventually. When it happens, + * the number of buckets will be multiplied by FACTOR. + */ +#define INITIAL_HASH_SIZE 67 +#define FACTOR 7 +#define THRESHOLD 5 + +#define HASH_MULT 31 + +typedef struct strhash_entry { + struct strhash_entry *next; + unsigned long hash_value; + char *key; + void *value; +} strhash_entry_t; + +struct mdn_strhash { + int nbins; + int nelements; + strhash_entry_t **bins; +}; + +static unsigned long hash_value(const char *key); +static strhash_entry_t *find_entry(strhash_entry_t *entry, const char *key, + unsigned long hash); +static strhash_entry_t *new_entry(const char *key, void *value); +static mdn_result_t expand_bins(mdn_strhash_t hash, int new_size); + +mdn_result_t +mdn_strhash_create(mdn_strhash_t *hashp) { + mdn_strhash_t hash; + mdn_result_t r; + + TRACE(("mdn_strhash_create()\n")); + + assert(hashp != NULL); + + *hashp = NULL; + + if ((hash = malloc(sizeof(struct mdn_strhash))) == NULL) { + WARNING(("mdn_strhash_create: malloc failed (hash)\n")); + return (mdn_nomemory); + } + hash->nbins = 0; + hash->nelements = 0; + hash->bins = NULL; + if ((r = expand_bins(hash, INITIAL_HASH_SIZE)) != mdn_success) { + WARNING(("mdn_strhash_create: malloc failed (bins)\n")); + free(hash); + return (r); + } + + *hashp = hash; + + return (mdn_success); +} + +void +mdn_strhash_destroy(mdn_strhash_t hash, mdn_strhash_freeproc_t proc) { + int i; + + assert(hash != NULL && hash->bins != NULL); + + for (i = 0; i < hash->nbins; i++) { + strhash_entry_t *bin = hash->bins[i]; + strhash_entry_t *next; + + while (bin != NULL) { + next = bin->next; + if (proc != NULL) + (*proc)(bin->value); + free(bin); + bin = next; + } + } + free(hash->bins); + free(hash); +} + +mdn_result_t +mdn_strhash_put(mdn_strhash_t hash, const char *key, void *value) { + unsigned long h, h_index; + strhash_entry_t *entry; + + assert(hash != NULL && key != NULL); + + h = hash_value(key); + h_index = h % hash->nbins; + + if ((entry = find_entry(hash->bins[h_index], key, h)) != NULL) { + /* Entry exists. Replace the value. */ + entry->value = value; + } else { + /* Create new entry. */ + if ((entry = new_entry(key, value)) == NULL) { + return (mdn_nomemory); + } + /* Insert it to the list. */ + entry->next = hash->bins[h_index]; + hash->bins[h_index] = entry; + hash->nelements++; + + if (hash->nelements > hash->nbins * THRESHOLD) { + mdn_result_t r; + r = expand_bins(hash, hash->nbins * FACTOR); + if (r != mdn_success) { + TRACE(("mdn_strhash_put: hash table " + "expansion failed\n")); + } + } + } + + return (mdn_success); +} + +mdn_result_t +mdn_strhash_get(mdn_strhash_t hash, const char *key, void **valuep) { + unsigned long h; + strhash_entry_t *entry; + + assert(hash != NULL && key != NULL && valuep != NULL); + + h = hash_value(key); + entry = find_entry(hash->bins[h % hash->nbins], key, h); + if (entry == NULL) + return (mdn_noentry); + + *valuep = entry->value; + return (mdn_success); +} + +int +mdn_strhash_exists(mdn_strhash_t hash, const char *key) { + unsigned long h; + + assert(hash != NULL && key != NULL); + + h = hash_value(key); + return (find_entry(hash->bins[h % hash->nbins], key, h) != NULL); +} + +static unsigned long +hash_value(const char *key) { + unsigned long h = 0; + unsigned char *p = (unsigned char *)key; + int c; + + while ((c = *p++) != '\0') { + h = h * HASH_MULT + c; + } + return (h); +} + +static strhash_entry_t * +find_entry(strhash_entry_t *entry, const char *key, unsigned long hash) { + assert(key != NULL); + + while (entry != NULL) { + if (entry->hash_value == hash && strcmp(key, entry->key) == 0) + return (entry); + entry = entry->next; + } + return (NULL); +} + +static strhash_entry_t * +new_entry(const char *key, void *value) { + strhash_entry_t *entry; + int len; + + assert(key != NULL); + + len = strlen(key) + 1; + if ((entry = malloc(sizeof(strhash_entry_t) + len)) == NULL) { + return (NULL); + } + entry->next = NULL; + entry->hash_value = hash_value(key); + entry->key = (char *)(entry + 1); + (void)strcpy(entry->key, key); + entry->value = value; + + return (entry); +} + +static mdn_result_t +expand_bins(mdn_strhash_t hash, int new_size) { + strhash_entry_t **old_bins, **new_bins; + int old_size; + int old_index, new_index; + + new_bins = malloc(sizeof(strhash_entry_t *) * new_size); + if (new_bins == NULL) + return (mdn_nomemory); + + memset(new_bins, 0, sizeof(strhash_entry_t *) * new_size); + + old_bins = hash->bins; + old_size = hash->nbins; + for (old_index = 0; old_index < old_size; old_index++) { + strhash_entry_t *entries = old_bins[old_index]; + + while (entries != NULL) { + strhash_entry_t *e = entries; + + /* Remove the top element from the linked list. */ + entries = entries->next; + + /* ..and move to the new hash. */ + new_index = e->hash_value % new_size; + e->next = new_bins[new_index]; + new_bins[new_index] = e; + } + } + + hash->nbins = new_size; + hash->bins = new_bins; + + if (old_bins != NULL) + free(old_bins); + + return (mdn_success); +} diff --git a/contrib/idn/mdnkit/lib/translator.c b/contrib/idn/mdnkit/lib/translator.c new file mode 100644 index 0000000000..cdd22d233e --- /dev/null +++ b/contrib/idn/mdnkit/lib/translator.c @@ -0,0 +1,376 @@ +#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 + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +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/unicode.c b/contrib/idn/mdnkit/lib/unicode.c new file mode 100644 index 0000000000..4f405827ce --- /dev/null +++ b/contrib/idn/mdnkit/lib/unicode.c @@ -0,0 +1,625 @@ +#ifndef lint +static char *rcsid = "$Id: unicode.c,v 1.11 2000/10/16 07:50:53 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 + +#include +#include +#ifdef DEBUG_HASHSTAT +#include +#endif + +#include +#include +#include +#include + +#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 + +/* + * Some constants for Hangul decomposition/composition. + */ +#define SBase 0xac00 +#define LBase 0x1100 +#define VBase 0x1161 +#define TBase 0x11a7 +#define LCount 19 +#define VCount 21 +#define TCount 28 +#define SLast (SBase + LCount * VCount * TCount) + +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. + */ + +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]; + +static int initialized = 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); +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 CHECKBIT(v, bitmap, shift) \ + (((bitmap)[((v)>>(shift)) / 32] & (1 << (((v)>>(shift)) & 31))) != 0) + +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) + 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; +} + +mdn_result_t +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; + + assert(v != NULL && vlen >= 0 && decomp_lenp != NULL); + +#if 0 + TRACE(("mdn__unicode_decompose(compat=%d,vlen=%d,c=%lx)\n", + compat, vlen, c)); +#endif + + initialize(); + + /* + * First, check for Hangul. + */ + if (SBase <= c && c < SLast) { + int idx, t_offset, v_offset, l_offset; + + idx = c - SBase; + t_offset = idx % TCount; + idx /= TCount; + v_offset = idx % VCount; + l_offset = idx / VCount; + if ((t_offset == 0 && vlen < 2) || (t_offset > 0 && vlen < 3)) + return (mdn_buffer_overflow); + *v++ = LBase + l_offset; + *v++ = VBase + v_offset; + if (t_offset > 0) + *v++ = TBase + t_offset; + *decomp_lenp = v - vorg; + return (mdn_success); + } + + /* + * Check bitmap. + */ + if (c > 0xffff || + (compat && + !CHECKBIT(c, compat_decompose_bitmap, DECOMPOSE_BM_SHIFT)) || + (!compat && + !CHECKBIT(c, canon_decompose_bitmap, DECOMPOSE_BM_SHIFT))) + return (mdn_notfound); + + /* + * Now, C is a decomposition candidate. + * Search the hash tables. + */ + h = decomposition_hashval((unicode_t)c); + + /* + * First, look for canonical decomposition. + */ + 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++) { + mdn_result_t r; + int len; + + /* Decompose recursively. */ + r = mdn__unicode_decompose(compat, v, vlen, base[i], &len); + + if (r == mdn_success) { + v += len; + vlen -= len; + } else { + *v++ = base[i]; + vlen--; + } + } + *decomp_lenp = v - vorg; + + return (mdn_success); +} + +int +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))); +} + +mdn_result_t +mdn__unicode_compose(unsigned long c1, unsigned long c2, unsigned long *compp) +{ + struct composition *hp; + + assert(compp != NULL); + +#if 0 + TRACE(("mdn__unicode_compose(c1=%lx,c2=%lx)\n", c1, c2)); +#endif + + initialize(); + + /* + * Check for Hangul. + */ + if (LBase <= c1 && c1 < LBase + LCount && + VBase <= c2 && c2 < VBase + VCount) { + /* + * Hangul L and V. + */ + *compp = SBase + + ((c1 - LBase) * VCount + (c2 - VBase)) * TCount; + return (mdn_success); + } else if (SBase <= c1 && c1 < SLast && + TBase <= c2 && c2 < TBase + TCount && + (c1 - SBase) % TCount == 0) { + /* + * Hangul LV and T. + */ + *compp = c1 + (c2 - TBase); + return (mdn_success); + } + + /* + * Check bitmap. + */ + if (c1 > 0xffff || c2 > 0xffff || + !CHECKBIT(c1, compose_bitmap, COMPOSE_BM_SHIFT)) + return (mdn_notfound); + + /* + * Composition candidate. Search the hash table. + */ + hp = composition_hash[composition_hashval((unicode_t)c1, + (unicode_t)c2)]; + while (hp != NULL) { + if (hp->c1 == c1 && hp->c2 == c2) { + *compp = hp->composed; + return (mdn_success); + } + hp = hp->next; + } + return (mdn_notfound); +} + +mdn_result_t +mdn__unicode_toupper(unsigned long c, mdn__unicode_context_t ctx, + unsigned long *v, size_t vlen, int *convlenp) +{ +#if 0 + TRACE(("mdn__unicode_toupper(c=%lx)\n", c)); +#endif + initialize(); + return (casemap(c, ctx, v, vlen, convlenp, + toupper_bitmap, toupper_hash)); +} + +mdn_result_t +mdn__unicode_tolower(unsigned long c, mdn__unicode_context_t ctx, + unsigned long *v, size_t vlen, int *convlenp) +{ +#if 0 + TRACE(("mdn__unicode_tolower(c=%lx)\n", c)); +#endif + initialize(); + return (casemap(c, ctx, v, vlen, convlenp, + tolower_bitmap, tolower_hash)); +} + +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) +{ + struct casemap *hp; + + 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) { + 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; + } + } + hp = hp->next; + } + + one_to_one: + *convlenp = 1; + *v = c; + return (mdn_success); +} + +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) { + 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) + return (mdn__unicode_context_nonfinal); + else + 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 + +#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 + +#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); +#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 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 +} + +int +main(int ac, char **av) { + initialize(); + print_hash_stat(); +} +#endif /* DEBUG_HASHSTAT */ diff --git a/contrib/idn/mdnkit/lib/unicodedata.c b/contrib/idn/mdnkit/lib/unicodedata.c new file mode 100644 index 0000000000..9e7f17573e --- /dev/null +++ b/contrib/idn/mdnkit/lib/unicodedata.c @@ -0,0 +1,3209 @@ +/* $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 -$ */ +/* + * Do not edit this file! + * This file is generated from UnicodeData.txt and + * CompositionExclusions-1.txt. + * + */ + + +/* + * Canonical Class + */ + +#define CANON_CLASS_BM_SHIFT (16 - 11) + +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 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}, +}; + + +/* + * Canonical Composition + */ + +#define COMPOSE_BM_SHIFT (16 - 11) + +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 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}, +}; + + +/* + * Canonical/Compatibility Decomposition + */ + +#define DECOMPOSE_BM_SHIFT (16 - 10) + +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 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 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 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) + */ + +#define CTX_BLOCK_SZ 512 +#define CTX_CASED 1 /* cased character */ +#define CTX_NSM 2 /* non-spacing mark */ + +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 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 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 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 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 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 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, +}; + +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, +}; + +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, +}; + +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 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 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, +}; + +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, +}; + +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 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 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, +}; + diff --git a/contrib/idn/mdnkit/lib/unormalize.c b/contrib/idn/mdnkit/lib/unormalize.c new file mode 100644 index 0000000000..32f9f87f65 --- /dev/null +++ b/contrib/idn/mdnkit/lib/unormalize.c @@ -0,0 +1,459 @@ +#ifndef lint +static char *rcsid = "$Id: unormalize.c,v 1.14 2000/10/13 05:34:48 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 + +#include +#include +#include +#ifdef DEBUG_HASHSTAT +#include +#endif + +#include +#include +#include +#include +#include +#include +#include + +#if !defined(HAVE_MEMMOVE) && defined(HAVE_BCOPY) +#define memmove(a,b,c) bcopy((char *)(b),(char *)(a),(int)(c)) +#endif + +#define WORKBUF_SIZE 128 +#define WORKBUF_SIZE_MAX 10000 + +typedef struct { + int cur; /* pointing now processing character */ + int last; /* pointing just after the last character */ + int size; /* size of UCS and CLASS array */ + unsigned long *ucs; /* UCS-4 characters */ + int *class; /* and their canonical classes */ + unsigned long ucs_buf[WORKBUF_SIZE]; /* local buffer */ + int class_buf[WORKBUF_SIZE]; /* ditto */ +} workbuf_t; + +static mdn_result_t normalize(int do_composition, int compat, + const char *from, char *to, size_t tolen); +static mdn_result_t decompose(workbuf_t *wb, unsigned long c, int compat); +static void get_class(workbuf_t *wb); +static void reorder(workbuf_t *wb); +static void compose(workbuf_t *wb); +static mdn_result_t flush_before_cur(workbuf_t *wb, + char **top, size_t *tolenp); +static void workbuf_init(workbuf_t *wb); +static void workbuf_free(workbuf_t *wb); +static mdn_result_t workbuf_extend(workbuf_t *wb); +static mdn_result_t workbuf_append(workbuf_t *wb, unsigned long c); +static void workbuf_shift(workbuf_t *wb, int shift); +static void workbuf_removevoid(workbuf_t *wb); + + +mdn_result_t +mdn__unormalize_formc(const char *from, char *to, size_t tolen) { + assert(from != NULL && to != NULL && tolen >= 0); + TRACE(("mdn__unormalize_formc(from=\"%s\", tolen=%d)\n", + mdn_debug_xstring(from, 20), tolen)); + return (normalize(1, 0, from, to, tolen)); +} + +mdn_result_t +mdn__unormalize_formd(const char *from, char *to, size_t tolen) { + assert(from != NULL && to != NULL && tolen >= 0); + TRACE(("mdn__unormalize_formd(from=\"%s\", tolen=%d)\n", + mdn_debug_xstring(from, 20), tolen)); + return (normalize(0, 0, from, to, tolen)); +} + +mdn_result_t +mdn__unormalize_formkc(const char *from, char *to, size_t tolen) { + assert(from != NULL && to != NULL && tolen >= 0); + TRACE(("mdn__unormalize_formkc(from=\"%s\", tolen=%d)\n", + mdn_debug_xstring(from, 20), tolen)); + return (normalize(1, 1, from, to, tolen)); +} + +mdn_result_t +mdn__unormalize_formkd(const char *from, char *to, size_t tolen) { + assert(from != NULL && to != NULL && tolen >= 0); + TRACE(("mdn__unormalize_formkd(from=\"%s\", tolen=%d)\n", + mdn_debug_xstring(from, 20), tolen)); + return (normalize(0, 1, from, to, tolen)); +} + +static mdn_result_t +normalize(int do_composition, int compat, + const char *from, char *to, size_t tolen) +{ + workbuf_t wb; + size_t fromlen = strlen(from); + mdn_result_t r = mdn_success; + + /* + * Initialize working buffer. + */ + workbuf_init(&wb); + + while (fromlen > 0) { + unsigned long c; + int mblen; + + assert(wb.cur == wb.last); + + /* + * Get one character from 'from'. + */ + if ((mblen = mdn_utf8_getwc(from, fromlen, &c)) == 0) { + r = mdn_invalid_encoding; + break; + } + from += mblen; + fromlen -= mblen; + + /* + * Decompose it. + */ + if ((r = decompose(&wb, c, compat)) != mdn_success) + break; + + /* + * Get canonical class. + */ + get_class(&wb); + + /* + * Reorder & compose. + */ + for (; wb.cur < wb.last; wb.cur++) { + if (wb.cur == 0) { + continue; + } else if (wb.class[wb.cur] > 0) { + /* + * This is not a starter. Try reordering. + * Note that characters up to it are + * already in canonical order. + */ + reorder(&wb); + continue; + } + + /* + * This is a starter character, and there are + * some characters before it. Those characters + * have been reordered properly, and + * ready for composition. + */ + if (do_composition && wb.class[0] == 0) + compose(&wb); + + /* + * If CUR points to a starter character, + * then process of characters before CUR are + * already finished, because any further + * reordering/composition for them are blocked + * by the starter CUR points. + */ + if (wb.cur > 0 && wb.class[wb.cur] == 0) { + /* Flush everything before CUR. */ + r = flush_before_cur(&wb, &to, &tolen); + if (r != mdn_success) + break; + } + } + } + + if (r == mdn_success) { + if (do_composition && wb.cur > 0 && wb.class[0] == 0) { + /* + * There is some characters left in WB. + * They are ordered, but not composed yet. + * Now CUR points just after the last character in WB, + * and since compose() tries to compose characters + * between top and CUR inclusive, we must make CUR + * one character back during compose(). + */ + wb.cur--; + compose(&wb); + wb.cur++; + } + /* + * Call this even when WB.CUR == 0, to make TO + * NUL-terminated. + */ + r = flush_before_cur(&wb, &to, &tolen); + } + + workbuf_free(&wb); + return (r); +} + +static mdn_result_t +decompose(workbuf_t *wb, unsigned long c, int compat) { + mdn_result_t r; + int dec_len; + +again: + r = mdn__unicode_decompose(compat, wb->ucs + wb->last, + wb->size - wb->last, + c, &dec_len); + switch (r) { + case mdn_success: + wb->last += dec_len; + return (mdn_success); + case mdn_notfound: + return (workbuf_append(wb, c)); + case mdn_buffer_overflow: + if ((r = workbuf_extend(wb)) != mdn_success) + return (r); + if (wb->size > WORKBUF_SIZE_MAX) { + WARNING(("mdn__unormalize_form*: " + "working buffer too large\n")); + return (mdn_nomemory); + } + goto again; + default: + return (r); + } + /* NOTREACHED */ +} + +static void +get_class(workbuf_t *wb) { + int i; + + for (i = wb->cur; i < wb->last; i++) + wb->class[i] = mdn__unicode_canonicalclass(wb->ucs[i]); +} + +static void +reorder(workbuf_t *wb) { + unsigned long c; + int i; + int class; + + assert(wb != NULL); + + i = wb->cur; + c = wb->ucs[i]; + class = wb->class[i]; + + while (i > 0 && wb->class[i - 1] > class) { + wb->ucs[i] = wb->ucs[i - 1]; + wb->class[i] =wb->class[i - 1]; + i--; + wb->ucs[i] = c; + wb->class[i] = class; + } +} + +static void +compose(workbuf_t *wb) { + int cur; + unsigned long *ucs; + int *class; + int last_class; + int nvoids; + int i; + + assert(wb != NULL && wb->class[0] == 0); + + cur = wb->cur; + ucs = wb->ucs; + class = wb->class; + + /* + * If there are no decomposition sequence that begins with + * the top character, composition is impossible. + */ + if (!mdn__unicode_iscompositecandidate(ucs[0])) + return; + + last_class = 0; + nvoids = 0; + for (i = 1; i <= cur; i++) { + unsigned long c; + int cl = class[i]; + + if ((last_class < cl || cl == 0) && + mdn__unicode_compose(ucs[0], ucs[i], &c) == mdn_success) { + /* + * Replace the top character with the composed one. + */ + ucs[0] = c; + class[0] = mdn__unicode_canonicalclass(c); + + class[i] = -1; /* void this character */ + nvoids++; + } else { + last_class = cl; + } + } + + /* Purge void characters, if any. */ + if (nvoids > 0) + workbuf_removevoid(wb); +} + +static mdn_result_t +flush_before_cur(workbuf_t *wb, char **top, size_t *tolenp) { + int cur = wb->cur; + char *to = *top; + size_t tolen = *tolenp; + int i; + + for (i = 0; i < cur; i++) { + int len = mdn_utf8_putwc(to, tolen, wb->ucs[i]); + if (len == 0) + return (mdn_buffer_overflow); + to += len; + tolen -= len; + } + if (tolen < 1) + return (mdn_buffer_overflow); + *to = '\0'; + + *top = to; + *tolenp = tolen; + + workbuf_shift(wb, cur); + + return (mdn_success); +} + +static void +workbuf_init(workbuf_t *wb) { + wb->cur = 0; + wb->last = 0; + wb->size = WORKBUF_SIZE; + wb->ucs = wb->ucs_buf; + wb->class = wb->class_buf; +} + +static void +workbuf_free(workbuf_t *wb) { + if (wb->ucs != wb->ucs_buf) { + free(wb->ucs); + free(wb->class); + } +} + +static mdn_result_t +workbuf_extend(workbuf_t *wb) { + int newsize = wb->size * 3; + + if (wb->ucs == wb->ucs_buf) { + wb->ucs = malloc(sizeof(wb->ucs[0]) * newsize); + wb->class = malloc(sizeof(wb->class[0]) * newsize); + } else { + wb->ucs = realloc(wb->ucs, sizeof(wb->ucs[0]) * newsize); + wb->class = realloc(wb->class, sizeof(wb->class[0]) * newsize); + } + if (wb->ucs == NULL || wb->class == NULL) + return (mdn_nomemory); + else + return (mdn_success); +} + +static mdn_result_t +workbuf_append(workbuf_t *wb, unsigned long c) { + mdn_result_t r; + + if (wb->last >= wb->size && (r = workbuf_extend(wb)) != mdn_success) + return (r); + wb->ucs[wb->last++] = c; + return (mdn_success); +} + +static void +workbuf_shift(workbuf_t *wb, int shift) { + int nmove; + + assert(wb != NULL && wb->cur >= shift); + + nmove = wb->last - shift; + (void)memmove(&wb->ucs[0], &wb->ucs[shift], + nmove * sizeof(wb->ucs[0])); + (void)memmove(&wb->class[0], &wb->class[shift], + nmove * sizeof(wb->class[0])); + wb->cur -= shift; + wb->last -= shift; +} + +static void +workbuf_removevoid(workbuf_t *wb) { + int i, j; + int last = wb->last; + + for (i = j = 0; i < last; i++) { + if (wb->class[i] >= 0) { + if (j < i) { + wb->ucs[j] = wb->ucs[i]; + wb->class[j] = wb->class[i]; + } + j++; + } + } + wb->cur -= last - j; + wb->last = j; +} diff --git a/contrib/idn/mdnkit/lib/utf5.c b/contrib/idn/mdnkit/lib/utf5.c new file mode 100644 index 0000000000..76db9e7c73 --- /dev/null +++ b/contrib/idn/mdnkit/lib/utf5.c @@ -0,0 +1,175 @@ +#ifndef lint +static char *rcsid = "$Id: utf5.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 + +#include + +#include +#include +#include +#include + +int +mdn_utf5_getwc(const char *s, size_t len, unsigned long *vp) { + int top = 1; + size_t orglen = len; + unsigned long v = 0; + + assert(s != NULL && len >= 0 && vp != NULL); + +#if 0 + TRACE(("mdn_utf5_getwc(s=<%s>,len=%d)\n", + mdn_debug_hexstring(s, 10), len)); +#endif + + if (len == 0) + return (0); + + /* Special case for domain name handling. */ + if (*s == '.') { + *vp = '.'; + return (1); + } + + while (len > 0) { + int c = *s++; + + if (top) { + if ('G' <= c && c <= 'V') + v = c - 'G'; + else if ('g' <= c && c <= 'v') + v = c - 'g'; + else + return (0); + top = 0; + } else { + if ('0' <= c && c <= '9') + v = (v << 4) + (c - '0'); + else if ('A' <= c && c <= 'F') + v = (v << 4) + (c - 'A' + 10); + else if ('a' <= c && c <= 'f') + v = (v << 4) + (c - 'a' + 10); + else + break; + } + len--; + } + *vp = v; + return (orglen - len); +} + +int +mdn_utf5_putwc(char *s, size_t len, unsigned long v) { + int w; + int off; + + assert(s != NULL); + +#if 0 + TRACE(("mdn_utf5_putwc(v=%lx)\n", v)); +#endif + + /* Special handling for domain delimiter '.' */ + if (v == '.') { + if (len < 1) + return (0); + *s = v; + return (1); + } + + if (v < 0x10) { + w = 1; + } else if (v < 0x100) { + w = 2; + } else if (v < 0x1000) { + w = 3; + } else if (v < 0x10000) { + w = 4; + } else if (v < 0x100000) { + w = 5; + } else if (v < 0x1000000) { + w = 6; + } else if (v < 0x10000000) { + w = 7; + } else if (v < 0x80000000) { + w = 8; + } else { + return (0); + } + + if (len < w) + return (0); + + off = (w - 1) * 4; + *s++ = 'G' + ((v >> off) & 0xf); + off -= 4; + while (off >= 0) { + int x = (v >> off) & 0xf; + if (x < 10) + *s++ = '0' + x; + else + *s++ = 'A' + x - 10; + off -= 4; + } + return (w); +} diff --git a/contrib/idn/mdnkit/lib/utf8.c b/contrib/idn/mdnkit/lib/utf8.c new file mode 100644 index 0000000000..2f7c353b17 --- /dev/null +++ b/contrib/idn/mdnkit/lib/utf8.c @@ -0,0 +1,292 @@ +#ifndef lint +static char *rcsid = "$Id: utf8.c,v 1.12 2000/10/25 06:43:00 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 + +#include + +#include +#include +#include +#include + +#define UTF8_WIDTH(c) \ + (((c) < 0x80) ? 1 : \ + ((c) < 0xc0) ? 0 : \ + ((c) < 0xe0) ? 2 : \ + ((c) < 0xf0) ? 3 : \ + ((c) < 0xf8) ? 4 : \ + ((c) < 0xfc) ? 5 : \ + ((c) < 0xfe) ? 6 : 0) + +#define VALID_CONT_BYTE(c) (0x80 <= (c) && (c) < 0xc0) + +int +mdn_utf8_mblen(const char *s) { + int c = *(unsigned char *)s; + + assert(s != NULL); + +#if 0 + TRACE(("mdn_utf8_mblen(s=<%s>)\n", mdn_debug_hexstring(s, 6))); +#endif + + return UTF8_WIDTH(c); +} + +int +mdn_utf8_getmb(const char *s, size_t len, char *buf) { + /* buf must be at least 7-bytes long */ + const unsigned char *p = (const unsigned char *)s; + unsigned char *q = (unsigned char *)buf; + int width = UTF8_WIDTH(*p); + int w; + + assert(s != NULL); + +#if 0 + TRACE(("mdn_utf8_getmb(s=<%s>,len=%d)\n", + mdn_debug_hexstring(s, 6), len)); +#endif + + if (width == 0 || len < width) + return (0); + + /* Copy the first byte. */ + *q++ = *p++; + + /* .. and the rest. */ + w = width; + while (--w > 0) { + if (!VALID_CONT_BYTE(*p)) + return (0); + *q++ = *p++; + } + return (width); +} + +extern int +mdn_utf8_getwc(const char *s, size_t len, unsigned long *vp) { + unsigned long v; + unsigned long min; + const unsigned char *p = (const unsigned char *)s; + int c; + int width; + int rest; + + assert(s != NULL); + +#if 0 + TRACE(("mdn_utf8_getwc(s=<%s>,len=%d)\n", + mdn_debug_hexstring(s, 10), len)); +#endif + + c = *p++; + width = UTF8_WIDTH(c); + + switch (width) { + case 0: + return (0); + case 1: + v = c; + min = 0; + break; + case 2: + v = c & 0x1f; + min = 0x80; + break; + case 3: + v = c & 0xf; + min = 0x800; + break; + case 4: + v = c & 0x7; + min = 0x10000; + break; + case 5: + v = c & 3; + min = 0x200000; + break; + case 6: + v = c & 1; + min = 0x4000000; + break; + default: + FATAL(("mdn_utf8_getint: internal error\n")); + return (0); + } + + if (len < width) + return (0); + + rest = width - 1; + while (rest-- > 0) { + if (!VALID_CONT_BYTE(*p)) + return (0); + v = (v << 6) | (*p & 0x3f); + p++; + } + + if (v < min) + return (0); + + *vp = v; + return (width); +} + +extern int +mdn_utf8_putwc(char *s, size_t len, unsigned long v) { + unsigned char *p = (unsigned char *)s; + int mask; + int off; + int l; + + assert(s != NULL); + +#if 0 + TRACE(("mdn_utf8_putwc(v=%lx)\n", v)); +#endif + + if (v < 0x80) { + mask = 0; + l = 1; + } else if (v < 0x800) { + mask = 0xc0; + l = 2; + } else if (v < 0x10000) { + mask = 0xe0; + l = 3; + } else if (v < 0x200000) { + mask = 0xf0; + l = 4; + } else if (v < 0x4000000) { + mask = 0xf8; + l = 5; + } else if (v < 0x80000000) { + mask = 0xfc; + l = 6; + } else { + return (0); + } + + if (len < l) + return (0); + + off = 6 * (l - 1); + *p++ = (v >> off) | mask; + mask = 0x80; + while (off > 0) { + off -= 6; + *p++ = ((v >> off) & 0x3f) | mask; + } + return l; +} + +int +mdn_utf8_isvalidchar(const char *s) { + unsigned long dummy; + + TRACE(("mdn_utf8_isvalidchar(s=<%s>)\n", + mdn_debug_hexstring(s, 6))); + + return (mdn_utf8_getwc(s, 6, &dummy) > 0); +} + +int +mdn_utf8_isvalidstring(const char *s) { + unsigned long dummy; + int width; + + assert(s != NULL); + + TRACE(("mdn_utf8_isvalidstring(s=<%s>)\n", + mdn_debug_hexstring(s, 20))); + + while (*s != '\0') { + width = mdn_utf8_getwc(s, 6, &dummy); + if (width == 0) + return (0); + s += width; + } + return (1); +} + +char * +mdn_utf8_findfirstbyte(const char *s, const char *known_top) { + const unsigned char *p = (const unsigned char *)s; + const unsigned char *t = (const unsigned char *)known_top; + + assert(s != NULL && known_top != NULL && known_top <= s); + + TRACE(("mdn_utf8_findfirstbyte(s=<%s>)\n", + mdn_debug_hexstring(s, 8))); + + while (p >= t) { + if (!VALID_CONT_BYTE(*p)) + break; + p--; + } + if (p < t || UTF8_WIDTH(*p) == 0) + return (NULL); + + return ((char *)p); +} diff --git a/contrib/idn/mdnkit/lib/util.c b/contrib/idn/mdnkit/lib/util.c new file mode 100644 index 0000000000..2302b026f0 --- /dev/null +++ b/contrib/idn/mdnkit/lib/util.c @@ -0,0 +1,193 @@ +#ifndef lint +static char *rcsid = "$Id: util.c,v 1.2 2000/11/14 00:15:36 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 + +#include + +#include +#include +#include +#include + +/* + * ASCII tolower() macro. + * Note that this macro evaluates the argument multiple times. Be careful. + */ +#define ASCII_TOLOWER(c) \ + (('A' <= (c) && (c) <= 'Z') ? ((c) - 'A' + 'a') : (c)) + +/* + * Unicode surrogate pair. + */ +#define IS_SURROGATE_HIGH(v) (0xd800 <= (v) && (v) <= 0xdbff) +#define IS_SURROGATE_LOW(v) (0xdc00 <= (v) && (v) <= 0xdfff) +#define SURROGATE_HIGH(v) (SURROGATE_H_OFF + (((v) - 0x10000) >> 10)) +#define SURROGATE_LOW(v) (SURROGATE_L_OFF + ((v) & 0x3ff)) +#define SURROGATE_BASE 0x10000 +#define SURROGATE_H_OFF 0xd800 +#define SURROGATE_L_OFF 0xdc00 +#define COMBINE_SURROGATE(h, l) \ + (SURROGATE_BASE + (((h)-SURROGATE_H_OFF)<<10) + ((l)-SURROGATE_L_OFF)) + +int +mdn_util_casematch(const char *s1, const char *s2, size_t n) { + assert(s1 != NULL && s2 != NULL); + + while (n-- > 0) { + if (*s1 != *s2 && ASCII_TOLOWER(*s1) != ASCII_TOLOWER(*s2)) + return (0); + else if (*s1 == '\0') + break; + s1++; + s2++; + } + return (1); +} + +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 == '-')) + s++; + return (s); +} + +mdn_result_t +mdn_util_utf8toutf16(const char *utf8, size_t fromlen, + unsigned short *utf16, size_t tolen, size_t *reslenp) +{ + int i = 0; + + while (fromlen > 0) { + unsigned long v; + int flen; + + flen = mdn_utf8_getwc(utf8, fromlen, &v); + if (flen == 0) { + WARNING(("mdn_util_utf8toutf16: " + "invalid character\n")); + return (mdn_invalid_encoding); + } + utf8 += flen; + fromlen -= flen; + + if (tolen < 1) + return (mdn_buffer_overflow); + + if (IS_SURROGATE_LOW(v) || IS_SURROGATE_HIGH(v)) { + WARNING(("mdn_util_utf8toutf16: UTF-8 string contains " + "surrogate pair\n")); + return (mdn_invalid_encoding); + } else if (v > 0xffff) { + /* Convert to surrogate pair */ + if (v >= 0x110000) + return (mdn_invalid_encoding); + if (tolen < 2) + return (mdn_buffer_overflow); + utf16[i++] = SURROGATE_HIGH(v); + utf16[i++] = SURROGATE_LOW(v); + tolen -= 2; + } else { + utf16[i++] = v; + tolen--; + } + } + *reslenp = i; + return (mdn_success); +} + +mdn_result_t +mdn_util_utf16toutf8(const unsigned short *utf16, size_t fromlen, + char *utf8, size_t tolen, size_t *reslenp) +{ + int i; + char *org = utf8; + + for (i = 0; i < fromlen; i++) { + unsigned long v; + int w; + + if (IS_SURROGATE_HIGH(utf16[i])) { + if (i + 1 >= fromlen || + !IS_SURROGATE_LOW(utf16[i + 1])) { + WARNING(("mdn_util_utf16toutf8: " + "corrupted surrogate pair\n")); + return (mdn_invalid_encoding); + } + v = COMBINE_SURROGATE(utf16[i], utf16[i + 1]); + i++; + } else { + v = utf16[i]; + } + w = mdn_utf8_putwc(utf8, tolen, v); + if (w == 0) + return (mdn_buffer_overflow); + utf8 += w; + tolen -= w; + } + *reslenp = utf8 - org; + return (mdn_success); +} diff --git a/contrib/idn/mdnkit/lib/zldrule.c b/contrib/idn/mdnkit/lib/zldrule.c new file mode 100644 index 0000000000..1b451a41bd --- /dev/null +++ b/contrib/idn/mdnkit/lib/zldrule.c @@ -0,0 +1,262 @@ +#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 + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +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 new file mode 100755 index 0000000000..e41c013d19 --- /dev/null +++ b/contrib/idn/mdnkit/libtool @@ -0,0 +1,4284 @@ +#! /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 , 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 , 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 <&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 +# #undef WIN32_LEAN_AND_MEAN +# #include +# +# #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 +# 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 /* for printf() */ +# #include /* for open(), lseek(), read() */ +# #include /* for O_RDONLY, O_BINARY */ +# #include /* 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&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 </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*) + case "$compile_command " in + *" -static "*) ;; + *) pic_flag_for_symtable=" $pic_flag -DPIC -DFREEBSD_WORKAROUND";; + esac;; + *-*-hpux*) + case "$compile_command " in + *" -static "*) ;; + *) pic_flag_for_symtable=" $pic_flag -DPIC";; + esac + esac + + # Now compile the dynamic symbol file. + $show "(cd $output_objdir && $CC -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")" + $run eval '(cd $output_objdir && $CC -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $? + + # Clean up the generated files. + $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T" + $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T" + + # Transform the symbol file into the correct name. + compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"` + finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"` + ;; + *) + $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2 + exit 1 + ;; + esac + else + # We keep going just in case the user didn't refer to + # lt_preloaded_symbols. The linker will fail if global_symbol_pipe + # really was required. + + # Nullify the symbol file. + compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"` + finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"` + fi + + if test -z "$link_against_libtool_libs" || test "$build_libtool_libs" != yes; then + # Replace the output file specification. + compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` + link_command="$compile_command$compile_rpath" + + # We have no uninstalled library dependencies, so finalize right now. + $show "$link_command" + $run eval "$link_command" + status=$? + + # Delete the generated files. + if test -n "$dlsyms"; then + $show "$rm $output_objdir/${outputname}S.${objext}" + $run $rm "$output_objdir/${outputname}S.${objext}" + fi + + exit $status + fi + + if test -n "$shlibpath_var"; then + # We should set the shlibpath_var + rpath= + for dir in $temp_rpath; do + case "$dir" in + [\\/]* | [A-Za-z]:[\\/]*) + # Absolute path. + rpath="$rpath$dir:" + ;; + *) + # Relative path: add a thisdir entry. + rpath="$rpath\$thisdir/$dir:" + ;; + esac + done + temp_rpath="$rpath" + fi + + if test -n "$compile_shlibpath$finalize_shlibpath"; then + compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" + fi + if test -n "$finalize_shlibpath"; then + finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" + fi + + compile_var= + finalize_var= + if test -n "$runpath_var"; then + if test -n "$perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $perm_rpath; do + rpath="$rpath$dir:" + done + compile_var="$runpath_var=\"$rpath\$$runpath_var\" " + fi + if test -n "$finalize_perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $finalize_perm_rpath; do + rpath="$rpath$dir:" + done + finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " + fi + fi + + if test "$hardcode_action" = relink; then + # Fast installation is not supported + link_command="$compile_var$compile_command$compile_rpath" + relink_command="$finalize_var$finalize_command$finalize_rpath" + + $echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2 + $echo "$modename: \`$output' will be relinked during installation" 1>&2 + else + if test "$fast_install" != no; then + link_command="$finalize_var$compile_command$finalize_rpath" + if test "$fast_install" = yes; then + relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'` + else + # fast_install is set to needless + relink_command= + fi + else + link_command="$compile_var$compile_command$compile_rpath" + relink_command="$finalize_var$finalize_command$finalize_rpath" + fi + fi + + # Replace the output file specification. + link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` + + # Delete the old output files. + $run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname + + $show "$link_command" + $run eval "$link_command" || exit $? + + # Now create the wrapper script. + $show "creating $output" + + # Quote the relink command for shipping. + if test -n "$relink_command"; then + relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"` + fi + + # Quote $echo for shipping. + if test "X$echo" = "X$SHELL $0 --fallback-echo"; then + case "$0" in + [\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $0 --fallback-echo";; + *) qecho="$SHELL `pwd`/$0 --fallback-echo";; + esac + qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"` + else + qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"` + fi + + # Only actually do things if our run command is non-null. + if test -z "$run"; then + # win32 will think the script is a binary if it has + # a .exe suffix, so we strip it off here. + case $output in + *.exe) output=`echo $output|sed 's,.exe$,,'` ;; + esac + $rm $output + trap "$rm $output; exit 1" 1 2 15 + + $echo > $output "\ +#! $SHELL + +# $output - temporary wrapper script for $objdir/$outputname +# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP +# +# The $output program cannot be directly executed until all the libtool +# libraries that it depends on are installed. +# +# This wrapper script should never be moved out of the build directory. +# If it is, it will not operate correctly. + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +Xsed='sed -e 1s/^X//' +sed_quote_subst='$sed_quote_subst' + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +if test \"\${CDPATH+set}\" = set; then CDPATH=:; export CDPATH; fi + +relink_command=\"$relink_command\" + +# This environment variable determines our operation mode. +if test \"\$libtool_install_magic\" = \"$magic\"; then + # install mode needs the following variable: + link_against_libtool_libs='$link_against_libtool_libs' +else + # When we are sourced in execute mode, \$file and \$echo are already set. + if test \"\$libtool_execute_magic\" != \"$magic\"; then + echo=\"$qecho\" + file=\"\$0\" + # Make sure echo works. + if test \"X\$1\" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift + elif test \"X\`(\$echo '\t') 2>/dev/null\`\" = 'X\t'; then + # Yippee, \$echo works! + : + else + # Restart under the correct shell, and then maybe \$echo will work. + exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"} + fi + fi\ +" + $echo >> $output "\ + + # Find the directory that this script lives in. + thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\` + test \"x\$thisdir\" = \"x\$file\" && thisdir=. + + # Follow symbolic links until we get to the real thisdir. + file=\`ls -ld \"\$file\" | sed -n 's/.*-> //p'\` + while test -n \"\$file\"; do + destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\` + + # If there was a directory component, then change thisdir. + if test \"x\$destdir\" != \"x\$file\"; then + case \"\$destdir\" in + [\\/]* | [A-Za-z]:[\\/]*) thisdir=\"\$destdir\" ;; + *) thisdir=\"\$thisdir/\$destdir\" ;; + esac + fi + + file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\` + file=\`ls -ld \"\$thisdir/\$file\" | sed -n 's/.*-> //p'\` + done + + # Try to get the absolute directory name. + absdir=\`cd \"\$thisdir\" && pwd\` + test -n \"\$absdir\" && thisdir=\"\$absdir\" +" + + if test "$fast_install" = yes; then + echo >> $output "\ + program=lt-'$outputname' + progdir=\"\$thisdir/$objdir\" + + if test ! -f \"\$progdir/\$program\" || \\ + { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | sed 1q\`; \\ + test \"X\$file\" != \"X\$progdir/\$program\"; }; then + + file=\"\$\$-\$program\" + + if test ! -d \"\$progdir\"; then + $mkdir \"\$progdir\" + else + $rm \"\$progdir/\$file\" + fi" + + echo >> $output "\ + + # relink executable if necessary + if test -n \"\$relink_command\"; then + if (cd \"\$thisdir\" && eval \$relink_command); then : + else + $rm \"\$progdir/\$file\" + exit 1 + fi + fi + + $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || + { $rm \"\$progdir/\$program\"; + $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; } + $rm \"\$progdir/\$file\" + fi" + else + echo >> $output "\ + program='$outputname' + progdir=\"\$thisdir/$objdir\" +" + fi + + echo >> $output "\ + + if test -f \"\$progdir/\$program\"; then" + + # Export our shlibpath_var if we have one. + if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then + $echo >> $output "\ + # Add our own library path to $shlibpath_var + $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" + + # Some systems cannot cope with colon-terminated $shlibpath_var + # The second colon is a workaround for a bug in BeOS R4 sed + $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\` + + export $shlibpath_var +" + fi + + # fixup the dll searchpath if we need to. + if test -n "$dllsearchpath"; then + $echo >> $output "\ + # Add the dll search path components to the executable PATH + PATH=$dllsearchpath:\$PATH +" + fi + + $echo >> $output "\ + if test \"\$libtool_execute_magic\" != \"$magic\"; then + # Run the actual program with our arguments. +" + case $host in + # win32 systems need to use the prog path for dll + # lookup to work + *-*-cygwin*) + $echo >> $output "\ + exec \$progdir/\$program \${1+\"\$@\"} +" + ;; + + # Backslashes separate directories on plain windows + *-*-mingw | *-*-os2*) + $echo >> $output "\ + exec \$progdir\\\\\$program \${1+\"\$@\"} +" + ;; + + *) + $echo >> $output "\ + # Export the path to the program. + PATH=\"\$progdir:\$PATH\" + export PATH + + exec \$program \${1+\"\$@\"} +" + ;; + esac + $echo >> $output "\ + \$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\" + exit 1 + fi + else + # The program doesn't exist. + \$echo \"\$0: error: \$progdir/\$program does not exist\" 1>&2 + \$echo \"This script is just a wrapper for \$program.\" 1>&2 + echo \"See the $PACKAGE documentation for more information.\" 1>&2 + exit 1 + fi +fi\ +" + chmod +x $output + fi + exit 0 + ;; + esac + + # See if we need to build an old-fashioned archive. + for oldlib in $oldlibs; do + + if test "$build_libtool_libs" = convenience; then + oldobjs="$libobjs_save" + addlibs="$convenience" + build_libtool_libs=no + else + if test "$build_libtool_libs" = module; then + oldobjs="$libobjs_save" + build_libtool_libs=no + else + oldobjs="$objs "`$echo "X$libobjs_save" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP` + fi + addlibs="$old_convenience" + fi + + if test -n "$addlibs"; then + gentop="$output_objdir/${outputname}x" + $show "${rm}r $gentop" + $run ${rm}r "$gentop" + $show "mkdir $gentop" + $run mkdir "$gentop" + status=$? + if test $status -ne 0 && test ! -d "$gentop"; then + exit $status + fi + generated="$generated $gentop" + + # Add in members from convenience archives. + for xlib in $addlibs; do + # Extract the objects. + case "$xlib" in + [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;; + *) xabs=`pwd`"/$xlib" ;; + esac + xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'` + xdir="$gentop/$xlib" + + $show "${rm}r $xdir" + $run ${rm}r "$xdir" + $show "mkdir $xdir" + $run mkdir "$xdir" + status=$? + if test $status -ne 0 && test ! -d "$xdir"; then + exit $status + fi + $show "(cd $xdir && $AR x $xabs)" + $run eval "(cd \$xdir && $AR x \$xabs)" || exit $? + + oldobjs="$oldobjs "`find $xdir -name \*.${objext} -print -o -name \*.lo -print | $NL2SP` + done + fi + + # Do each command in the archive commands. + if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then + eval cmds=\"$old_archive_from_new_cmds\" + else + # Ensure that we have .o objects in place in case we decided + # not to build a shared library, and have fallen back to building + # static libs even though --disable-static was passed! + for oldobj in $oldobjs; do + if test ! -f $oldobj; then + xdir=`$echo "X$oldobj" | $Xsed -e 's%/[^/]*$%%'` + if test "X$xdir" = "X$oldobj"; then + xdir="." + else + xdir="$xdir" + fi + baseobj=`$echo "X$oldobj" | $Xsed -e 's%^.*/%%'` + obj=`$echo "X$baseobj" | $Xsed -e "$o2lo"` + $show "(cd $xdir && ${LN_S} $obj $baseobj)" + $run eval '(cd $xdir && ${LN_S} $obj $baseobj)' || exit $? + fi + done + + eval cmds=\"$old_archive_cmds\" + fi + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + done + + if test -n "$generated"; then + $show "${rm}r$generated" + $run ${rm}r$generated + fi + + # Now create the libtool archive. + case "$output" in + *.la) + old_library= + test "$build_old_libs" = yes && old_library="$libname.$libext" + $show "creating $output" + + if test -n "$xrpath"; then + temp_xrpath= + for libdir in $xrpath; do + temp_xrpath="$temp_xrpath -R$libdir" + done + dependency_libs="$temp_xrpath $dependency_libs" + fi + + # Only create the output if not a dry run. + if test -z "$run"; then + for installed in no yes; do + if test "$installed" = yes; then + if test -z "$install_libdir"; then + break + fi + output="$output_objdir/$outputname"i + fi + $rm $output + $echo > $output "\ +# $outputname - a libtool library file +# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# The name that we can dlopen(3). +dlname='$dlname' + +# Names of this library. +library_names='$library_names' + +# The name of the static archive. +old_library='$old_library' + +# Libraries that this one depends upon. +dependency_libs='$dependency_libs' + +# Version information for $libname. +current=$current +age=$age +revision=$revision + +# Is this an already installed library? +installed=$installed + +# Directory that this library needs to be installed in: +libdir='$install_libdir'\ +" + done + fi + + # Do a symbolic link so that the libtool archive can be found in + # LD_LIBRARY_PATH before the program is installed. + $show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)" + $run eval "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)" || exit $? + ;; + esac + exit 0 + ;; + + # libtool install mode + install) + modename="$modename: install" + + # There may be an optional sh(1) argument at the beginning of + # install_prog (especially on Windows NT). + if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh; then + # Aesthetically quote it. + arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"` + case "$arg" in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) + arg="\"$arg\"" + ;; + esac + install_prog="$arg " + arg="$1" + shift + else + install_prog= + arg="$nonopt" + fi + + # The real first argument should be the name of the installation program. + # Aesthetically quote it. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case "$arg" in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) + arg="\"$arg\"" + ;; + esac + install_prog="$install_prog$arg" + + # We need to accept at least all the BSD install flags. + dest= + files= + opts= + prev= + install_type= + isdir=no + stripme= + for arg + do + if test -n "$dest"; then + files="$files $dest" + dest="$arg" + continue + fi + + case "$arg" in + -d) isdir=yes ;; + -f) prev="-f" ;; + -g) prev="-g" ;; + -m) prev="-m" ;; + -o) prev="-o" ;; + -s) + stripme=" -s" + continue + ;; + -*) ;; + + *) + # If the previous option needed an argument, then skip it. + if test -n "$prev"; then + prev= + else + dest="$arg" + continue + fi + ;; + esac + + # Aesthetically quote the argument. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case "$arg" in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) + arg="\"$arg\"" + ;; + esac + install_prog="$install_prog $arg" + done + + if test -z "$install_prog"; then + $echo "$modename: you must specify an install program" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + if test -n "$prev"; then + $echo "$modename: the \`$prev' option requires an argument" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + if test -z "$files"; then + if test -z "$dest"; then + $echo "$modename: no file or destination specified" 1>&2 + else + $echo "$modename: you must specify a destination" 1>&2 + fi + $echo "$help" 1>&2 + exit 1 + fi + + # Strip any trailing slash from the destination. + dest=`$echo "X$dest" | $Xsed -e 's%/$%%'` + + # Check to see that the destination is a directory. + test -d "$dest" && isdir=yes + if test "$isdir" = yes; then + destdir="$dest" + destname= + else + destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'` + test "X$destdir" = "X$dest" && destdir=. + destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'` + + # Not a directory, so check to see that there is only one file specified. + set dummy $files + if test $# -gt 2; then + $echo "$modename: \`$dest' is not a directory" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + fi + case "$destdir" in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + for file in $files; do + case "$file" in + *.lo) ;; + *) + $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2 + $echo "$help" 1>&2 + exit 1 + ;; + esac + done + ;; + esac + + # This variable tells wrapper scripts just to set variables rather + # than running their programs. + libtool_install_magic="$magic" + + staticlibs= + future_libdirs= + current_libdirs= + for file in $files; do + + # Do each installation. + case "$file" in + *.a | *.lib) + # Do the static libraries later. + staticlibs="$staticlibs $file" + ;; + + *.la) + # Check to see that this really is a libtool archive. + if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : + else + $echo "$modename: \`$file' is not a valid libtool archive" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + library_names= + old_library= + # If there is no directory component, then add one. + case "$file" in + */* | *\\*) . $file ;; + *) . ./$file ;; + esac + + # Add the libdir to current_libdirs if it is the destination. + if test "X$destdir" = "X$libdir"; then + case "$current_libdirs " in + *" $libdir "*) ;; + *) current_libdirs="$current_libdirs $libdir" ;; + esac + else + # Note the libdir as a future libdir. + case "$future_libdirs " in + *" $libdir "*) ;; + *) future_libdirs="$future_libdirs $libdir" ;; + esac + fi + + dir="`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/" + test "X$dir" = "X$file/" && dir= + dir="$dir$objdir" + + # See the names of the shared library. + set dummy $library_names + if test -n "$2"; then + realname="$2" + shift + shift + + # Install the shared library and build the symlinks. + $show "$install_prog $dir/$realname $destdir/$realname" + $run eval "$install_prog $dir/$realname $destdir/$realname" || exit $? + + if test $# -gt 0; then + # Delete the old symlinks, and create new ones. + for linkname + do + if test "$linkname" != "$realname"; then + $show "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)" + $run eval "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)" + fi + done + fi + + # Do each command in the postinstall commands. + lib="$destdir/$realname" + eval cmds=\"$postinstall_cmds\" + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + fi + + # Install the pseudo-library for information purposes. + name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + instname="$dir/$name"i + $show "$install_prog $instname $destdir/$name" + $run eval "$install_prog $instname $destdir/$name" || exit $? + + # Maybe install the static library, too. + test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library" + ;; + + *.lo) + # Install (i.e. copy) a libtool object. + + # Figure out destination file name, if it wasn't already specified. + if test -n "$destname"; then + destfile="$destdir/$destname" + else + destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + destfile="$destdir/$destfile" + fi + + # Deduce the name of the destination old-style object file. + case "$destfile" in + *.lo) + staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"` + ;; + *.o | *.obj) + staticdest="$destfile" + destfile= + ;; + *) + $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2 + $echo "$help" 1>&2 + exit 1 + ;; + esac + + # Install the libtool object if requested. + if test -n "$destfile"; then + $show "$install_prog $file $destfile" + $run eval "$install_prog $file $destfile" || exit $? + fi + + # Install the old object if enabled. + if test "$build_old_libs" = yes; then + # Deduce the name of the old-style object file. + staticobj=`$echo "X$file" | $Xsed -e "$lo2o"` + + $show "$install_prog $staticobj $staticdest" + $run eval "$install_prog \$staticobj \$staticdest" || exit $? + fi + exit 0 + ;; + + *) + # Figure out destination file name, if it wasn't already specified. + if test -n "$destname"; then + destfile="$destdir/$destname" + else + destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + destfile="$destdir/$destfile" + fi + + # Do a test to see if this is really a libtool program. + if (sed -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + link_against_libtool_libs= + relink_command= + + # If there is no directory component, then add one. + case "$file" in + */* | *\\*) . $file ;; + *) . ./$file ;; + esac + + # Check the variables that should have been set. + if test -z "$link_against_libtool_libs"; then + $echo "$modename: invalid libtool wrapper script \`$file'" 1>&2 + exit 1 + fi + + finalize=yes + for lib in $link_against_libtool_libs; do + # Check to see that each library is installed. + libdir= + if test -f "$lib"; then + # If there is no directory component, then add one. + case "$lib" in + */* | *\\*) . $lib ;; + *) . ./$lib ;; + esac + fi + libfile="$libdir/`$echo "X$lib" | $Xsed -e 's%^.*/%%g'`" + if test -n "$libdir" && test ! -f "$libfile"; then + $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2 + finalize=no + fi + done + + outputname= + if test "$fast_install" = no && test -n "$relink_command"; then + if test "$finalize" = yes && test -z "$run"; then + tmpdir="/tmp" + test -n "$TMPDIR" && tmpdir="$TMPDIR" + tmpdir="$tmpdir/libtool-$$" + if $mkdir -p "$tmpdir" && chmod 700 "$tmpdir"; then : + else + $echo "$modename: error: cannot create temporary directory \`$tmpdir'" 1>&2 + continue + fi + outputname="$tmpdir/$file" + # Replace the output file specification. + relink_command=`$echo "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'` + + $show "$relink_command" + if $run eval "$relink_command"; then : + else + $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2 + ${rm}r "$tmpdir" + continue + fi + file="$outputname" + else + $echo "$modename: warning: cannot relink \`$file'" 1>&2 + fi + else + # Install the binary that we compiled earlier. + file=`$echo "X$file" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"` + fi + fi + + $show "$install_prog$stripme $file $destfile" + $run eval "$install_prog\$stripme \$file \$destfile" || exit $? + test -n "$outputname" && ${rm}r "$tmpdir" + ;; + esac + done + + for file in $staticlibs; do + name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + + # Set up the ranlib parameters. + oldlib="$destdir/$name" + + $show "$install_prog $file $oldlib" + $run eval "$install_prog \$file \$oldlib" || exit $? + + # Do each command in the postinstall commands. + eval cmds=\"$old_postinstall_cmds\" + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + done + + if test -n "$future_libdirs"; then + $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2 + fi + + if test -n "$current_libdirs"; then + # Maybe just do a dry run. + test -n "$run" && current_libdirs=" -n$current_libdirs" + exec $SHELL $0 --finish$current_libdirs + exit 1 + fi + + exit 0 + ;; + + # libtool finish mode + finish) + modename="$modename: finish" + libdirs="$nonopt" + admincmds= + + if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then + for dir + do + libdirs="$libdirs $dir" + done + + for libdir in $libdirs; do + if test -n "$finish_cmds"; then + # Do each command in the finish commands. + eval cmds=\"$finish_cmds\" + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || admincmds="$admincmds + $cmd" + done + IFS="$save_ifs" + fi + if test -n "$finish_eval"; then + # Do the single finish_eval. + eval cmds=\"$finish_eval\" + $run eval "$cmds" || admincmds="$admincmds + $cmds" + fi + done + fi + + # Exit here if they wanted silent mode. + test "$show" = : && exit 0 + + echo "----------------------------------------------------------------------" + echo "Libraries have been installed in:" + for libdir in $libdirs; do + echo " $libdir" + done + echo + echo "If you ever happen to want to link against installed libraries" + echo "in a given directory, LIBDIR, you must either use libtool, and" + echo "specify the full pathname of the library, or use \`-LLIBDIR'" + echo "flag during linking and do at least one of the following:" + if test -n "$shlibpath_var"; then + echo " - add LIBDIR to the \`$shlibpath_var' environment variable" + echo " during execution" + fi + if test -n "$runpath_var"; then + echo " - add LIBDIR to the \`$runpath_var' environment variable" + echo " during linking" + fi + if test -n "$hardcode_libdir_flag_spec"; then + libdir=LIBDIR + eval flag=\"$hardcode_libdir_flag_spec\" + + echo " - use the \`$flag' linker flag" + fi + if test -n "$admincmds"; then + echo " - have your system administrator run these commands:$admincmds" + fi + if test -f /etc/ld.so.conf; then + echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" + fi + echo + echo "See any operating system documentation about shared libraries for" + echo "more information, such as the ld(1) and ld.so(8) manual pages." + echo "----------------------------------------------------------------------" + exit 0 + ;; + + # libtool execute mode + execute) + modename="$modename: execute" + + # The first argument is the command name. + cmd="$nonopt" + if test -z "$cmd"; then + $echo "$modename: you must specify a COMMAND" 1>&2 + $echo "$help" + exit 1 + fi + + # Handle -dlopen flags immediately. + for file in $execute_dlfiles; do + if test ! -f "$file"; then + $echo "$modename: \`$file' is not a file" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + dir= + case "$file" in + *.la) + # Check to see that this really is a libtool archive. + if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : + else + $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + # Read the libtool library. + dlname= + library_names= + + # If there is no directory component, then add one. + case "$file" in + */* | *\\*) . $file ;; + *) . ./$file ;; + esac + + # Skip this library if it cannot be dlopened. + if test -z "$dlname"; then + # Warn if it was a shared library. + test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'" + continue + fi + + dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + test "X$dir" = "X$file" && dir=. + + if test -f "$dir/$objdir/$dlname"; then + dir="$dir/$objdir" + else + $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2 + exit 1 + fi + ;; + + *.lo) + # Just add the directory containing the .lo file. + dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + test "X$dir" = "X$file" && dir=. + ;; + + *) + $echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2 + continue + ;; + esac + + # Get the absolute pathname. + absdir=`cd "$dir" && pwd` + test -n "$absdir" && dir="$absdir" + + # Now add the directory to shlibpath_var. + if eval "test -z \"\$$shlibpath_var\""; then + eval "$shlibpath_var=\"\$dir\"" + else + eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" + fi + done + + # This variable tells wrapper scripts just to set shlibpath_var + # rather than running their programs. + libtool_execute_magic="$magic" + + # Check if any of the arguments is a wrapper script. + args= + for file + do + case "$file" in + -*) ;; + *) + # Do a test to see if this is really a libtool program. + if (sed -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + # If there is no directory component, then add one. + case "$file" in + */* | *\\*) . $file ;; + *) . ./$file ;; + esac + + # Transform arg to wrapped name. + file="$progdir/$program" + fi + ;; + esac + # Quote arguments (to preserve shell metacharacters). + file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"` + args="$args \"$file\"" + done + + if test -z "$run"; then + if test -n "$shlibpath_var"; then + # Export the shlibpath_var. + eval "export $shlibpath_var" + fi + + # Restore saved enviroment variables + if test "${save_LC_ALL+set}" = set; then + LC_ALL="$save_LC_ALL"; export LC_ALL + fi + if test "${save_LANG+set}" = set; then + LANG="$save_LANG"; export LANG + fi + + # Now actually exec the command. + eval "exec \$cmd$args" + + $echo "$modename: cannot exec \$cmd$args" + exit 1 + else + # Display what would be done. + if test -n "$shlibpath_var"; then + eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\"" + $echo "export $shlibpath_var" + fi + $echo "$cmd$args" + exit 0 + fi + ;; + + # libtool uninstall mode + uninstall) + modename="$modename: uninstall" + rm="$nonopt" + files= + + for arg + do + case "$arg" in + -*) rm="$rm $arg" ;; + *) files="$files $arg" ;; + esac + done + + if test -z "$rm"; then + $echo "$modename: you must specify an RM program" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + for file in $files; do + dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + test "X$dir" = "X$file" && dir=. + name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + + rmfiles="$file" + + case "$name" in + *.la) + # Possibly a libtool archive, so verify it. + if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + . $dir/$name + + # Delete the libtool libraries and symlinks. + for n in $library_names; do + rmfiles="$rmfiles $dir/$n" + done + test -n "$old_library" && rmfiles="$rmfiles $dir/$old_library" + + $show "$rm $rmfiles" + $run $rm $rmfiles + + if test -n "$library_names"; then + # Do each command in the postuninstall commands. + eval cmds=\"$postuninstall_cmds\" + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" + done + IFS="$save_ifs" + fi + + if test -n "$old_library"; then + # Do each command in the old_postuninstall commands. + eval cmds=\"$old_postuninstall_cmds\" + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" + done + IFS="$save_ifs" + fi + + # FIXME: should reinstall the best remaining shared library. + fi + ;; + + *.lo) + if test "$build_old_libs" = yes; then + oldobj=`$echo "X$name" | $Xsed -e "$lo2o"` + rmfiles="$rmfiles $dir/$oldobj" + fi + $show "$rm $rmfiles" + $run $rm $rmfiles + ;; + + *) + $show "$rm $rmfiles" + $run $rm $rmfiles + ;; + esac + done + exit 0 + ;; + + "") + $echo "$modename: you must specify a MODE" 1>&2 + $echo "$generic_help" 1>&2 + exit 1 + ;; + esac + + $echo "$modename: invalid operation mode \`$mode'" 1>&2 + $echo "$generic_help" 1>&2 + exit 1 +fi # test -z "$show_help" + +# We need to display help for each of the modes. +case "$mode" in +"") $echo \ +"Usage: $modename [OPTION]... [MODE-ARG]... + +Provide generalized library-building support services. + + --config show all configuration variables + --debug enable verbose shell tracing +-n, --dry-run display commands without modifying any files + --features display basic configuration information and exit + --finish same as \`--mode=finish' + --help display this help message and exit + --mode=MODE use operation mode MODE [default=inferred from MODE-ARGS] + --quiet same as \`--silent' + --silent don't print informational messages + --version print version information + +MODE must be one of the following: + + compile compile a source file into a libtool object + execute automatically set library path, then run a program + finish complete the installation of libtool libraries + install install libraries or executables + link create a library or an executable + uninstall remove libraries from an installed directory + +MODE-ARGS vary depending on the MODE. Try \`$modename --help --mode=MODE' for +a more detailed description of MODE." + exit 0 + ;; + +compile) + $echo \ +"Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE + +Compile a source file into a libtool library object. + +This mode accepts the following additional options: + + -o OUTPUT-FILE set the output file name to OUTPUT-FILE + -static always build a \`.o' file suitable for static linking + +COMPILE-COMMAND is a command to be used in creating a \`standard' object file +from the given SOURCEFILE. + +The output file name is determined by removing the directory component from +SOURCEFILE, then substituting the C source code suffix \`.c' with the +library object suffix, \`.lo'." + ;; + +execute) + $echo \ +"Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]... + +Automatically set library path, then run a program. + +This mode accepts the following additional options: + + -dlopen FILE add the directory containing FILE to the library path + +This mode sets the library path environment variable according to \`-dlopen' +flags. + +If any of the ARGS are libtool executable wrappers, then they are translated +into their corresponding uninstalled binary, and any of their required library +directories are added to the library path. + +Then, COMMAND is executed, with ARGS as arguments." + ;; + +finish) + $echo \ +"Usage: $modename [OPTION]... --mode=finish [LIBDIR]... + +Complete the installation of libtool libraries. + +Each LIBDIR is a directory that contains libtool libraries. + +The commands that this mode executes may require superuser privileges. Use +the \`--dry-run' option if you just want to see what would be executed." + ;; + +install) + $echo \ +"Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND... + +Install executables or libraries. + +INSTALL-COMMAND is the installation command. The first component should be +either the \`install' or \`cp' program. + +The rest of the components are interpreted as arguments to that command (only +BSD-compatible install options are recognized)." + ;; + +link) + $echo \ +"Usage: $modename [OPTION]... --mode=link LINK-COMMAND... + +Link object files or libraries together to form another library, or to +create an executable program. + +LINK-COMMAND is a command using the C compiler that you would use to create +a program from several object files. + +The following components of LINK-COMMAND are treated specially: + + -all-static do not do any dynamic linking at all + -avoid-version do not add a version suffix if possible + -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime + -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols + -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) + -export-symbols SYMFILE + try to export only the symbols listed in SYMFILE + -export-symbols-regex REGEX + try to export only the symbols matching REGEX + -LLIBDIR search LIBDIR for required installed libraries + -lNAME OUTPUT-FILE requires the installed library libNAME + -module build a library that can dlopened + -no-undefined declare that a library does not refer to external symbols + -o OUTPUT-FILE create OUTPUT-FILE from the specified objects + -release RELEASE specify package release information + -rpath LIBDIR the created library will eventually be installed in LIBDIR + -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries + -static do not do any dynamic linking of libtool libraries + -version-info CURRENT[:REVISION[:AGE]] + specify library version info [each variable defaults to 0] + +All other options (arguments beginning with \`-') are ignored. + +Every other argument is treated as a filename. Files ending in \`.la' are +treated as uninstalled libtool libraries, other files are standard or library +object files. + +If the OUTPUT-FILE ends in \`.la', then a libtool library is created, +only library objects (\`.lo' files) may be specified, and \`-rpath' is +required, except when creating a convenience library. + +If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created +using \`ar' and \`ranlib', or on Windows using \`lib'. + +If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file +is created, otherwise an executable program is created." + ;; + +uninstall) + $echo \ +"Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... + +Remove libraries from an installation directory. + +RM is the name of the program to use to delete files associated with each FILE +(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed +to RM. + +If FILE is a libtool library, all the files associated with it are deleted. +Otherwise, only FILE itself is deleted using RM." + ;; + +*) + $echo "$modename: invalid operation mode \`$mode'" 1>&2 + $echo "$help" 1>&2 + exit 1 + ;; +esac + +echo +$echo "Try \`$modename --help' for more information about other modes." + +exit 0 + +# Local Variables: +# mode:shell-script +# sh-indentation:2 +# End: diff --git a/contrib/idn/mdnkit/ltconfig b/contrib/idn/mdnkit/ltconfig new file mode 100644 index 0000000000..c14d83c169 --- /dev/null +++ b/contrib/idn/mdnkit/ltconfig @@ -0,0 +1,3114 @@ +#! /bin/sh + +# ltconfig - Create a system-specific libtool. +# Copyright (C) 1996-1999 Free Software Foundation, Inc. +# Originally by Gordon Matzigkeit , 1996 +# +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# A lot of this script is taken from autoconf-2.10. + +# Check that we are running under the correct shell. +SHELL=${CONFIG_SHELL-/bin/sh} +echo=echo +if test "X$1" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift +elif test "X$1" = X--fallback-echo; then + # Avoid inline document here, it may be left over + : +elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then + # Yippee, $echo works! + : +else + # Restart under the correct shell. + exec "$SHELL" "$0" --no-reexec ${1+"$@"} +fi + +if test "X$1" = X--fallback-echo; then + # used as fallback echo + shift + cat </dev/null`} + case X$UNAME in + *-DOS) PATH_SEPARATOR=';' ;; + *) PATH_SEPARATOR=':' ;; + esac +fi + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +if test "X${CDPATH+set}" = Xset; then CDPATH=:; export CDPATH; fi + +if test "X${echo_test_string+set}" != Xset; then + # find a string as large as possible, as long as the shell can cope with it + for cmd in 'sed 50q "$0"' 'sed 20q "$0"' 'sed 10q "$0"' 'sed 2q "$0"' 'echo test'; do + # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ... + if (echo_test_string="`eval $cmd`") 2>/dev/null && + echo_test_string="`eval $cmd`" && + (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null; then + break + fi + done +fi + +if test "X`($echo '\t') 2>/dev/null`" != 'X\t' || + test "X`($echo "$echo_test_string") 2>/dev/null`" != X"$echo_test_string"; then + # The Solaris, AIX, and Digital Unix default echo programs unquote + # backslashes. This makes it impossible to quote backslashes using + # echo "$something" | sed 's/\\/\\\\/g' + # + # So, first we look for a working echo in the user's PATH. + + IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}" + for dir in $PATH /usr/ucb; do + if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && + test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && + test "X`($dir/echo "$echo_test_string") 2>/dev/null`" = X"$echo_test_string"; then + echo="$dir/echo" + break + fi + done + IFS="$save_ifs" + + if test "X$echo" = Xecho; then + # We didn't find a better echo, so look for alternatives. + if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' && + test "X`(print -r "$echo_test_string") 2>/dev/null`" = X"$echo_test_string"; then + # This shell has a builtin print -r that does the trick. + echo='print -r' + elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) && + test "X$CONFIG_SHELL" != X/bin/ksh; then + # If we have ksh, try running ltconfig again with it. + ORIGINAL_CONFIG_SHELL="${CONFIG_SHELL-/bin/sh}" + export ORIGINAL_CONFIG_SHELL + CONFIG_SHELL=/bin/ksh + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$0" --no-reexec ${1+"$@"} + else + # Try using printf. + echo='printf "%s\n"' + if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && + test "X`($echo "$echo_test_string") 2>/dev/null`" = X"$echo_test_string"; then + # Cool, printf works + : + elif test "X`("$ORIGINAL_CONFIG_SHELL" "$0" --fallback-echo '\t') 2>/dev/null`" = 'X\t' && + test "X`("$ORIGINAL_CONFIG_SHELL" "$0" --fallback-echo "$echo_test_string") 2>/dev/null`" = X"$echo_test_string"; then + CONFIG_SHELL="$ORIGINAL_CONFIG_SHELL" + export CONFIG_SHELL + SHELL="$CONFIG_SHELL" + export SHELL + echo="$CONFIG_SHELL $0 --fallback-echo" + elif test "X`("$CONFIG_SHELL" "$0" --fallback-echo '\t') 2>/dev/null`" = 'X\t' && + test "X`("$CONFIG_SHELL" "$0" --fallback-echo "$echo_test_string") 2>/dev/null`" = X"$echo_test_string"; then + echo="$CONFIG_SHELL $0 --fallback-echo" + else + # maybe with a smaller string... + prev=: + + for cmd in 'echo test' 'sed 2q "$0"' 'sed 10q "$0"' 'sed 20q "$0"' 'sed 50q "$0"'; do + if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null; then + break + fi + prev="$cmd" + done + + if test "$prev" != 'sed 50q "$0"'; then + echo_test_string=`eval $prev` + export echo_test_string + exec "${ORIGINAL_CONFIG_SHELL}" "$0" ${1+"$@"} + else + # Oops. We lost completely, so just stick with echo. + echo=echo + fi + fi + fi + fi +fi + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +Xsed='sed -e s/^X//' +sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g' + +# Same as above, but do not quote variable references. +double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g' + +# Sed substitution to delay expansion of an escaped shell variable in a +# double_quote_subst'ed string. +delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' + +# The name of this program. +progname=`$echo "X$0" | $Xsed -e 's%^.*/%%'` + +# Constants: +PROGRAM=ltconfig +PACKAGE=libtool +VERSION=1.3.5 +TIMESTAMP=" (1.385.2.206 2000/05/27 11:12:27)" +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +rm="rm -f" + +help="Try \`$progname --help' for more information." + +# Global variables: +default_ofile=libtool +can_build_shared=yes +enable_shared=yes +# All known linkers require a `.a' archive for static linking (except M$VC, +# which needs '.lib'). +enable_static=yes +enable_fast_install=yes +enable_dlopen=unknown +enable_win32_dll=no +ltmain= +silent= +srcdir= +ac_config_guess= +ac_config_sub= +host= +nonopt= +ofile="$default_ofile" +verify_host=yes +with_gcc=no +with_gnu_ld=no +need_locks=yes +ac_ext=c +objext=o +libext=a +exeext= +cache_file= + +old_AR="$AR" +old_CC="$CC" +old_CFLAGS="$CFLAGS" +old_CPPFLAGS="$CPPFLAGS" +old_LDFLAGS="$LDFLAGS" +old_LD="$LD" +old_LN_S="$LN_S" +old_LIBS="$LIBS" +old_NM="$NM" +old_RANLIB="$RANLIB" +old_DLLTOOL="$DLLTOOL" +old_OBJDUMP="$OBJDUMP" +old_AS="$AS" + +# Parse the command line options. +args= +prev= +for option +do + case "$option" in + -*=*) optarg=`echo "$option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; + *) optarg= ;; + esac + + # If the previous option needs an argument, assign it. + if test -n "$prev"; then + eval "$prev=\$option" + prev= + continue + fi + + case "$option" in + --help) cat <&2 + echo "$help" 1>&2 + exit 1 + ;; + + *) + if test -z "$ltmain"; then + ltmain="$option" + elif test -z "$host"; then +# This generates an unnecessary warning for sparc-sun-solaris4.1.3_U1 +# if test -n "`echo $option| sed 's/[-a-z0-9.]//g'`"; then +# echo "$progname: warning \`$option' is not a valid host type" 1>&2 +# fi + host="$option" + else + echo "$progname: too many arguments" 1>&2 + echo "$help" 1>&2 + exit 1 + fi ;; + esac +done + +if test -z "$ltmain"; then + echo "$progname: you must specify a LTMAIN file" 1>&2 + echo "$help" 1>&2 + exit 1 +fi + +if test ! -f "$ltmain"; then + echo "$progname: \`$ltmain' does not exist" 1>&2 + echo "$help" 1>&2 + exit 1 +fi + +# Quote any args containing shell metacharacters. +ltconfig_args= +for arg +do + case "$arg" in + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) + ltconfig_args="$ltconfig_args '$arg'" ;; + *) ltconfig_args="$ltconfig_args $arg" ;; + esac +done + +# A relevant subset of AC_INIT. + +# File descriptor usage: +# 0 standard input +# 1 file creation +# 2 errors and warnings +# 3 some systems may open it to /dev/tty +# 4 used on the Kubota Titan +# 5 compiler messages saved in config.log +# 6 checking for... messages and results +if test "$silent" = yes; then + exec 6>/dev/null +else + exec 6>&1 +fi +exec 5>>./config.log + +# NLS nuisances. +# Only set LANG and LC_ALL to C if already set. +# These must not be set unconditionally because not all systems understand +# e.g. LANG=C (notably SCO). +if test "X${LC_ALL+set}" = Xset; then LC_ALL=C; export LC_ALL; fi +if test "X${LANG+set}" = Xset; then LANG=C; export LANG; fi + +if test -n "$cache_file" && test -r "$cache_file"; then + echo "loading cache $cache_file within ltconfig" + . $cache_file +fi + +if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then + # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. + if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then + ac_n= ac_c=' +' ac_t=' ' + else + ac_n=-n ac_c= ac_t= + fi +else + ac_n= ac_c='\c' ac_t= +fi + +if test -z "$srcdir"; then + # Assume the source directory is the same one as the path to LTMAIN. + srcdir=`$echo "X$ltmain" | $Xsed -e 's%/[^/]*$%%'` + test "$srcdir" = "$ltmain" && srcdir=. +fi + +trap "$rm conftest*; exit 1" 1 2 15 +if test "$verify_host" = yes; then + # Check for config.guess and config.sub. + ac_aux_dir= + for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do + if test -f $ac_dir/config.guess; then + ac_aux_dir=$ac_dir + break + fi + done + if test -z "$ac_aux_dir"; then + echo "$progname: cannot find config.guess in $srcdir $srcdir/.. $srcdir/../.." 1>&2 + echo "$help" 1>&2 + exit 1 + fi + ac_config_guess=$ac_aux_dir/config.guess + ac_config_sub=$ac_aux_dir/config.sub + + # Make sure we can run config.sub. + if $SHELL $ac_config_sub sun4 >/dev/null 2>&1; then : + else + echo "$progname: cannot run $ac_config_sub" 1>&2 + echo "$help" 1>&2 + exit 1 + fi + + echo $ac_n "checking host system type""... $ac_c" 1>&6 + + host_alias=$host + case "$host_alias" in + "") + if host_alias=`$SHELL $ac_config_guess`; then : + else + echo "$progname: cannot guess host type; you must specify one" 1>&2 + echo "$help" 1>&2 + exit 1 + fi ;; + esac + host=`$SHELL $ac_config_sub $host_alias` + echo "$ac_t$host" 1>&6 + + # Make sure the host verified. + test -z "$host" && exit 1 + +elif test -z "$host"; then + echo "$progname: you must specify a host type if you use \`--no-verify'" 1>&2 + echo "$help" 1>&2 + exit 1 +else + host_alias=$host +fi + +# Transform linux* to *-*-linux-gnu*, to support old configure scripts. +case "$host_os" in +linux-gnu*) ;; +linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'` +esac + +host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` + +case "$host_os" in +aix3*) + # AIX sometimes has problems with the GCC collect2 program. For some + # reason, if we set the COLLECT_NAMES environment variable, the problems + # vanish in a puff of smoke. + if test "X${COLLECT_NAMES+set}" != Xset; then + COLLECT_NAMES= + export COLLECT_NAMES + fi + ;; +esac + +# Determine commands to create old-style static archives. +old_archive_cmds='$AR cru $oldlib$oldobjs' +old_postinstall_cmds='chmod 644 $oldlib' +old_postuninstall_cmds= + +# Set a sane default for `AR'. +test -z "$AR" && AR=ar + +# Set a sane default for `OBJDUMP'. +test -z "$OBJDUMP" && OBJDUMP=objdump + +# If RANLIB is not set, then run the test. +if test "${RANLIB+set}" != "set"; then + result=no + + echo $ac_n "checking for ranlib... $ac_c" 1>&6 + IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}" + for dir in $PATH; do + test -z "$dir" && dir=. + if test -f $dir/ranlib || test -f $dir/ranlib$ac_exeext; then + RANLIB="ranlib" + result="ranlib" + break + fi + done + IFS="$save_ifs" + + echo "$ac_t$result" 1>&6 +fi + +if test -n "$RANLIB"; then + old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" + old_postinstall_cmds="\$RANLIB \$oldlib~$old_postinstall_cmds" +fi + +# Set sane defaults for `DLLTOOL', `OBJDUMP', and `AS', used on cygwin. +test -z "$DLLTOOL" && DLLTOOL=dlltool +test -z "$OBJDUMP" && OBJDUMP=objdump +test -z "$AS" && AS=as + +# Check to see if we are using GCC. +if test "$with_gcc" != yes || test -z "$CC"; then + # If CC is not set, then try to find GCC or a usable CC. + if test -z "$CC"; then + echo $ac_n "checking for gcc... $ac_c" 1>&6 + IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}" + for dir in $PATH; do + test -z "$dir" && dir=. + if test -f $dir/gcc || test -f $dir/gcc$ac_exeext; then + CC="gcc" + break + fi + done + IFS="$save_ifs" + + if test -n "$CC"; then + echo "$ac_t$CC" 1>&6 + else + echo "$ac_t"no 1>&6 + fi + fi + + # Not "gcc", so try "cc", rejecting "/usr/ucb/cc". + if test -z "$CC"; then + echo $ac_n "checking for cc... $ac_c" 1>&6 + IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}" + cc_rejected=no + for dir in $PATH; do + test -z "$dir" && dir=. + if test -f $dir/cc || test -f $dir/cc$ac_exeext; then + if test "$dir/cc" = "/usr/ucb/cc"; then + cc_rejected=yes + continue + fi + CC="cc" + break + fi + done + IFS="$save_ifs" + if test $cc_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $CC + shift + if test $# -gt 0; then + # We chose a different compiler from the bogus one. + # However, it has the same name, so the bogon will be chosen + # first if we set CC to just the name; use the full file name. + shift + set dummy "$dir/cc" "$@" + shift + CC="$@" + fi + fi + + if test -n "$CC"; then + echo "$ac_t$CC" 1>&6 + else + echo "$ac_t"no 1>&6 + fi + + if test -z "$CC"; then + echo "$progname: error: no acceptable cc found in \$PATH" 1>&2 + exit 1 + fi + fi + + # Now see if the compiler is really GCC. + with_gcc=no + echo $ac_n "checking whether we are using GNU C... $ac_c" 1>&6 + echo "$progname:581: checking whether we are using GNU C" >&5 + + $rm conftest.c + cat > conftest.c <&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then + with_gcc=yes + fi + $rm conftest.c + echo "$ac_t$with_gcc" 1>&6 +fi + +# Allow CC to be a program name with arguments. +set dummy $CC +compiler="$2" + +echo $ac_n "checking for object suffix... $ac_c" 1>&6 +$rm conftest* +echo 'int i = 1;' > conftest.c +echo "$progname:603: checking for object suffix" >& 5 +if { (eval echo $progname:604: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>conftest.err; }; then + # Append any warnings to the config.log. + cat conftest.err 1>&5 + + for ac_file in conftest.*; do + case $ac_file in + *.c) ;; + *) objext=`echo $ac_file | sed -e s/conftest.//` ;; + esac + done +else + cat conftest.err 1>&5 + echo "$progname: failed program was:" >&5 + cat conftest.c >&5 +fi +$rm conftest* +echo "$ac_t$objext" 1>&6 + +echo $ac_n "checking for executable suffix... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_exeext'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_cv_exeext="no" + $rm conftest* + echo 'main () { return 0; }' > conftest.c + echo "$progname:629: checking for executable suffix" >& 5 + if { (eval echo $progname:630: \"$ac_link\") 1>&5; (eval $ac_link) 2>conftest.err; }; then + # Append any warnings to the config.log. + cat conftest.err 1>&5 + + for ac_file in conftest.*; do + case $ac_file in + *.c | *.err | *.$objext ) ;; + *) ac_cv_exeext=.`echo $ac_file | sed -e s/conftest.//` ;; + esac + done + else + cat conftest.err 1>&5 + echo "$progname: failed program was:" >&5 + cat conftest.c >&5 + fi + $rm conftest* +fi +if test "X$ac_cv_exeext" = Xno; then + exeext="" +else + exeext="$ac_cv_exeext" +fi +echo "$ac_t$ac_cv_exeext" 1>&6 + +echo $ac_n "checking for $compiler option to produce PIC... $ac_c" 1>&6 +pic_flag= +special_shlib_compile_flags= +wl= +link_static_flag= +no_builtin_flag= + +if test "$with_gcc" = yes; then + wl='-Wl,' + link_static_flag='-static' + + case "$host_os" in + beos* | irix5* | irix6* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + aix*) + # Below there is a dirty hack to force normal static linking with -ldl + # The problem is because libdl dynamically linked with both libc and + # libC (AIX C++ library), which obviously doesn't included in libraries + # list by gcc. This cause undefined symbols with -static flags. + # This hack allows C programs to be linked with "-static -ldl", but + # we not sure about C++ programs. + link_static_flag="$link_static_flag ${wl}-lC" + ;; + cygwin* | mingw* | os2*) + # We can build DLLs from non-PIC. + ;; + amigaos*) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the `-m68020' flag to GCC prevents building anything better, + # like `-m68040'. + pic_flag='-m68020 -resident32 -malways-restore-a4' + ;; + sysv4*MP*) + if test -d /usr/nec; then + pic_flag=-Kconform_pic + fi + ;; + *) + pic_flag='-fPIC' + ;; + esac +else + # PORTME Check for PIC flags for the system compiler. + case "$host_os" in + aix3* | aix4*) + # All AIX code is PIC. + link_static_flag='-bnso -bI:/lib/syscalls.exp' + ;; + + hpux9* | hpux10* | hpux11*) + # Is there a better link_static_flag that works with the bundled CC? + wl='-Wl,' + link_static_flag="${wl}-a ${wl}archive" + pic_flag='+Z' + ;; + + irix5* | irix6*) + wl='-Wl,' + link_static_flag='-non_shared' + # PIC (with -KPIC) is the default. + ;; + + cygwin* | mingw* | os2*) + # We can build DLLs from non-PIC. + ;; + + osf3* | osf4* | osf5*) + # All OSF/1 code is PIC. + wl='-Wl,' + link_static_flag='-non_shared' + ;; + + sco3.2v5*) + pic_flag='-Kpic' + link_static_flag='-dn' + special_shlib_compile_flags='-belf' + ;; + + solaris*) + pic_flag='-KPIC' + link_static_flag='-Bstatic' + wl='-Wl,' + ;; + + sunos4*) + pic_flag='-PIC' + link_static_flag='-Bstatic' + wl='-Qoption ld ' + ;; + + sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + pic_flag='-KPIC' + link_static_flag='-Bstatic' + wl='-Wl,' + ;; + + uts4*) + pic_flag='-pic' + link_static_flag='-Bstatic' + ;; + sysv4*MP*) + if test -d /usr/nec ;then + pic_flag='-Kconform_pic' + link_static_flag='-Bstatic' + fi + ;; + *) + can_build_shared=no + ;; + esac +fi + +if test -n "$pic_flag"; then + echo "$ac_t$pic_flag" 1>&6 + + # Check to make sure the pic_flag actually works. + echo $ac_n "checking if $compiler PIC flag $pic_flag works... $ac_c" 1>&6 + $rm conftest* + echo "int some_variable = 0;" > conftest.c + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $pic_flag -DPIC" + echo "$progname:776: checking if $compiler PIC flag $pic_flag works" >&5 + if { (eval echo $progname:777: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>conftest.err; } && test -s conftest.$objext; then + # Append any warnings to the config.log. + cat conftest.err 1>&5 + + case "$host_os" in + hpux9* | hpux10* | hpux11*) + # On HP-UX, both CC and GCC only warn that PIC is supported... then they + # create non-PIC objects. So, if there were any warnings, we assume that + # PIC is not supported. + if test -s conftest.err; then + echo "$ac_t"no 1>&6 + can_build_shared=no + pic_flag= + else + echo "$ac_t"yes 1>&6 + pic_flag=" $pic_flag" + fi + ;; + *) + echo "$ac_t"yes 1>&6 + pic_flag=" $pic_flag" + ;; + esac + else + # Append any errors to the config.log. + cat conftest.err 1>&5 + can_build_shared=no + pic_flag= + echo "$ac_t"no 1>&6 + fi + CFLAGS="$save_CFLAGS" + $rm conftest* +else + echo "$ac_t"none 1>&6 +fi + +# Check to see if options -o and -c are simultaneously supported by compiler +echo $ac_n "checking if $compiler supports -c -o file.o... $ac_c" 1>&6 +$rm -r conftest 2>/dev/null +mkdir conftest +cd conftest +$rm conftest* +echo "int some_variable = 0;" > conftest.c +mkdir out +# According to Tom Tromey, Ian Lance Taylor reported there are C compilers +# that will create temporary files in the current directory regardless of +# the output directory. Thus, making CWD read-only will cause this test +# to fail, enabling locking or at least warning the user not to do parallel +# builds. +chmod -w . +save_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -o out/conftest2.o" +echo "$progname:829: checking if $compiler supports -c -o file.o" >&5 +if { (eval echo $progname:830: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>out/conftest.err; } && test -s out/conftest2.o; then + + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s out/conftest.err; then + echo "$ac_t"no 1>&6 + compiler_c_o=no + else + echo "$ac_t"yes 1>&6 + compiler_c_o=yes + fi +else + # Append any errors to the config.log. + cat out/conftest.err 1>&5 + compiler_c_o=no + echo "$ac_t"no 1>&6 +fi +CFLAGS="$save_CFLAGS" +chmod u+w . +$rm conftest* out/* +rmdir out +cd .. +rmdir conftest +$rm -r conftest 2>/dev/null + +if test x"$compiler_c_o" = x"yes"; then + # Check to see if we can write to a .lo + echo $ac_n "checking if $compiler supports -c -o file.lo... $ac_c" 1>&6 + $rm conftest* + echo "int some_variable = 0;" > conftest.c + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -c -o conftest.lo" + echo "$progname:862: checking if $compiler supports -c -o file.lo" >&5 +if { (eval echo $progname:863: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>conftest.err; } && test -s conftest.lo; then + + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + echo "$ac_t"no 1>&6 + compiler_o_lo=no + else + echo "$ac_t"yes 1>&6 + compiler_o_lo=yes + fi + else + # Append any errors to the config.log. + cat conftest.err 1>&5 + compiler_o_lo=no + echo "$ac_t"no 1>&6 + fi + CFLAGS="$save_CFLAGS" + $rm conftest* +else + compiler_o_lo=no +fi + +# Check to see if we can do hard links to lock some files if needed +hard_links="nottested" +if test "$compiler_c_o" = no && test "$need_locks" != no; then + # do not overwrite the value of need_locks provided by the user + echo $ac_n "checking if we can lock with hard links... $ac_c" 1>&6 + hard_links=yes + $rm conftest* + ln conftest.a conftest.b 2>/dev/null && hard_links=no + touch conftest.a + ln conftest.a conftest.b 2>&5 || hard_links=no + ln conftest.a conftest.b 2>/dev/null && hard_links=no + echo "$ac_t$hard_links" 1>&6 + $rm conftest* + if test "$hard_links" = no; then + echo "*** WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2 + need_locks=warn + fi +else + need_locks=no +fi + +if test "$with_gcc" = yes; then + # Check to see if options -fno-rtti -fno-exceptions are supported by compiler + echo $ac_n "checking if $compiler supports -fno-rtti -fno-exceptions ... $ac_c" 1>&6 + $rm conftest* + echo "int some_variable = 0;" > conftest.c + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -fno-rtti -fno-exceptions -c conftest.c" + echo "$progname:914: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 + if { (eval echo $progname:915: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>conftest.err; } && test -s conftest.o; then + + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + echo "$ac_t"no 1>&6 + compiler_rtti_exceptions=no + else + echo "$ac_t"yes 1>&6 + compiler_rtti_exceptions=yes + fi + else + # Append any errors to the config.log. + cat conftest.err 1>&5 + compiler_rtti_exceptions=no + echo "$ac_t"no 1>&6 + fi + CFLAGS="$save_CFLAGS" + $rm conftest* + + if test "$compiler_rtti_exceptions" = "yes"; then + no_builtin_flag=' -fno-builtin -fno-rtti -fno-exceptions' + else + no_builtin_flag=' -fno-builtin' + fi + +fi + +# Check for any special shared library compilation flags. +if test -n "$special_shlib_compile_flags"; then + echo "$progname: warning: \`$CC' requires \`$special_shlib_compile_flags' to build shared libraries" 1>&2 + if echo "$old_CC $old_CFLAGS " | egrep -e "[ ]$special_shlib_compile_flags[ ]" >/dev/null; then : + else + echo "$progname: add \`$special_shlib_compile_flags' to the CC or CFLAGS env variable and reconfigure" 1>&2 + can_build_shared=no + fi +fi + +echo $ac_n "checking if $compiler static flag $link_static_flag works... $ac_c" 1>&6 +$rm conftest* +echo 'main(){return(0);}' > conftest.c +save_LDFLAGS="$LDFLAGS" +LDFLAGS="$LDFLAGS $link_static_flag" +echo "$progname:958: checking if $compiler static flag $link_static_flag works" >&5 +if { (eval echo $progname:959: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then + echo "$ac_t$link_static_flag" 1>&6 +else + echo "$ac_t"none 1>&6 + link_static_flag= +fi +LDFLAGS="$save_LDFLAGS" +$rm conftest* + +if test -z "$LN_S"; then + # Check to see if we can use ln -s, or we need hard links. + echo $ac_n "checking whether ln -s works... $ac_c" 1>&6 + $rm conftest.dat + if ln -s X conftest.dat 2>/dev/null; then + $rm conftest.dat + LN_S="ln -s" + else + LN_S=ln + fi + if test "$LN_S" = "ln -s"; then + echo "$ac_t"yes 1>&6 + else + echo "$ac_t"no 1>&6 + fi +fi + +# Make sure LD is an absolute path. +if test -z "$LD"; then + ac_prog=ld + if test "$with_gcc" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + echo $ac_n "checking for ld used by GCC... $ac_c" 1>&6 + echo "$progname:991: checking for ld used by GCC" >&5 + ac_prog=`($CC -print-prog-name=ld) 2>&5` + case "$ac_prog" in + # Accept absolute paths. + [\\/]* | [A-Za-z]:[\\/]*) + re_direlt='/[^/][^/]*/\.\./' + # Canonicalize the path of ld + ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` + while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do + ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we are not using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac + elif test "$with_gnu_ld" = yes; then + echo $ac_n "checking for GNU ld... $ac_c" 1>&6 + echo "$progname:1015: checking for GNU ld" >&5 + else + echo $ac_n "checking for non-GNU ld""... $ac_c" 1>&6 + echo "$progname:1018: checking for non-GNU ld" >&5 + fi + + if test -z "$LD"; then + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}" + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some GNU ld's only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + if "$LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then + test "$with_gnu_ld" != no && break + else + test "$with_gnu_ld" != yes && break + fi + fi + done + IFS="$ac_save_ifs" + fi + + if test -n "$LD"; then + echo "$ac_t$LD" 1>&6 + else + echo "$ac_t"no 1>&6 + fi + + if test -z "$LD"; then + echo "$progname: error: no acceptable ld found in \$PATH" 1>&2 + exit 1 + fi +fi + +# Check to see if it really is or is not GNU ld. +echo $ac_n "checking if the linker ($LD) is GNU ld... $ac_c" 1>&6 +# I'd rather use --version here, but apparently some GNU ld's only accept -v. +if $LD -v 2>&1 &5; then + with_gnu_ld=yes +else + with_gnu_ld=no +fi +echo "$ac_t$with_gnu_ld" 1>&6 + +# See if the linker supports building shared libraries. +echo $ac_n "checking whether the linker ($LD) supports shared libraries... $ac_c" 1>&6 + +allow_undefined_flag= +no_undefined_flag= +need_lib_prefix=unknown +need_version=unknown +# when you set need_version to no, make sure it does not cause -set_version +# flags to be left without arguments +archive_cmds= +archive_expsym_cmds= +old_archive_from_new_cmds= +export_dynamic_flag_spec= +whole_archive_flag_spec= +thread_safe_flag_spec= +hardcode_libdir_flag_spec= +hardcode_libdir_separator= +hardcode_direct=no +hardcode_minus_L=no +hardcode_shlibpath_var=unsupported +runpath_var= +always_export_symbols=no +export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | sed '\''s/.* //'\'' | sort | uniq > $export_symbols' +# include_expsyms should be a list of space-separated symbols to be *always* +# included in the symbol list +include_expsyms= +# exclude_expsyms can be an egrep regular expression of symbols to exclude +# it will be wrapped by ` (' and `)$', so one must not match beginning or +# end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', +# as well as any symbol that contains `d'. +exclude_expsyms="_GLOBAL_OFFSET_TABLE_" +# Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out +# platforms (ab)use it in PIC code, but their linkers get confused if +# the symbol is explicitly referenced. Since portable code cannot +# rely on this symbol name, it's probably fine to never include it in +# preloaded symbol tables. + +case "$host_os" in +cygwin* | mingw*) + # FIXME: the MSVC++ port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + if test "$with_gcc" != yes; then + with_gnu_ld=no + fi + ;; + +esac + +ld_shlibs=yes +if test "$with_gnu_ld" = yes; then + # If archive_cmds runs LD, not CC, wlarc should be empty + wlarc='${wl}' + + # See if GNU ld supports shared libraries. + case "$host_os" in + aix3* | aix4*) + # On AIX, the GNU linker is very broken + ld_shlibs=no + cat <&2 + +*** Warning: the GNU linker, at least up to release 2.9.1, is reported +*** to be unable to reliably create shared libraries on AIX. +*** Therefore, libtool is disabling shared libraries support. If you +*** really care for shared libraries, you may want to modify your PATH +*** so that a non-GNU linker is found, and then restart. + +EOF + ;; + + amigaos*) + archive_cmds='$rm $objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $objdir/a2ixlibrary.data~$AR cru $lib $libobjs~$RANLIB $lib~(cd $objdir && a2ixlibrary -32)' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + + # Samuel A. Falvo II reports + # that the semantics of dynamic libraries on AmigaOS, at least up + # to version 4, is to share data among multiple programs linked + # with the same dynamic library. Since this doesn't match the + # behavior of shared libraries on other platforms, we can use + # them. + ld_shlibs=no + ;; + + beos*) + if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then + allow_undefined_flag=unsupported + # Joseph Beckenbach says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + archive_cmds='$CC -nostart $libobjs $deplibs $linkopts ${wl}-soname $wl$soname -o $lib' + else + ld_shlibs=no + fi + ;; + + cygwin* | mingw*) + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + hardcode_libdir_flag_spec='-L$libdir' + allow_undefined_flag=unsupported + always_export_symbols=yes + + # Extract the symbol export list from an `--export-all' def file, + # then regenerate the def file from the symbol export list, so that + # the compiled dll only exports the symbol export list. + # Be careful not to strip the DATA tag left by newer dlltools. + export_symbols_cmds='test -f $objdir/$soname-ltdll.c || sed -e "/^# \/\* ltdll\.c starts here \*\//,/^# \/\* ltdll.c ends here \*\// { s/^# //; p; }" -e d < $0 > $objdir/$soname-ltdll.c~ + test -f $objdir/$soname-ltdll.$objext || (cd $objdir && $CC -c $soname-ltdll.c)~ + $DLLTOOL --export-all --exclude-symbols DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12 --output-def $objdir/$soname-def $objdir/$soname-ltdll.$objext $libobjs $convenience~ + sed -e "1,/EXPORTS/d" -e "s/ @ [0-9]*//" -e "s/ *;.*$//" < $objdir/$soname-def > $export_symbols' + + # If DATA tags from a recent dlltool are present, honour them! + archive_expsym_cmds='echo EXPORTS > $objdir/$soname-def~ + _lt_hint=1; + cat $export_symbols | while read symbol; do + set dummy \$symbol; + case \$# in + 2) echo " \$2 @ \$_lt_hint ; " >> $objdir/$soname-def;; + *) echo " \$2 @ \$_lt_hint \$3 ; " >> $objdir/$soname-def;; + esac; + _lt_hint=`expr 1 + \$_lt_hint`; + done~ + test -f $objdir/$soname-ltdll.c || sed -e "/^# \/\* ltdll\.c starts here \*\//,/^# \/\* ltdll.c ends here \*\// { s/^# //; p; }" -e d < $0 > $objdir/$soname-ltdll.c~ + test -f $objdir/$soname-ltdll.$objext || (cd $objdir && $CC -c $soname-ltdll.c)~ + $CC -Wl,--base-file,$objdir/$soname-base -Wl,--dll -nostartfiles -Wl,-e,__cygwin_dll_entry@12 -o $lib $objdir/$soname-ltdll.$objext $libobjs $deplibs $linkopts~ + $DLLTOOL --as=$AS --dllname $soname --exclude-symbols DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12 --def $objdir/$soname-def --base-file $objdir/$soname-base --output-exp $objdir/$soname-exp~ + $CC -Wl,--base-file,$objdir/$soname-base $objdir/$soname-exp -Wl,--dll -nostartfiles -Wl,-e,__cygwin_dll_entry@12 -o $lib $objdir/$soname-ltdll.$objext $libobjs $deplibs $linkopts~ + $DLLTOOL --as=$AS --dllname $soname --exclude-symbols DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12 --def $objdir/$soname-def --base-file $objdir/$soname-base --output-exp $objdir/$soname-exp~ + $CC $objdir/$soname-exp -Wl,--dll -nostartfiles -Wl,-e,__cygwin_dll_entry@12 -o $lib $objdir/$soname-ltdll.$objext $libobjs $deplibs $linkopts' + + old_archive_from_new_cmds='$DLLTOOL --as=$AS --dllname $soname --def $objdir/$soname-def --output-lib $objdir/$libname.a' + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + archive_cmds='$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 + ;; + + solaris* | sysv5*) + if $LD -v 2>&1 | egrep 'BFD 2\.8' > /dev/null; then + ld_shlibs=no + cat <&2 + +*** Warning: The releases 2.8.* of the GNU linker cannot reliably +*** create shared libraries on Solaris systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.9.1 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +EOF + elif $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then + archive_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs=no + fi + ;; + + sunos4*) + archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linkopts' + wlarc= + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + *) + if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then + archive_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs=no + fi + ;; + esac + + if test "$ld_shlibs" = yes; then + runpath_var=LD_RUN_PATH + hardcode_libdir_flag_spec='${wl}--rpath ${wl}$libdir' + export_dynamic_flag_spec='${wl}--export-dynamic' + case $host_os in + cygwin* | mingw*) + # dlltool doesn't understand --whole-archive et. al. + whole_archive_flag_spec= + ;; + *) + # ancient GNU ld didn't support --whole-archive et. al. + if $LD --help 2>&1 | egrep 'no-whole-archive' > /dev/null; then + whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + else + whole_archive_flag_spec= + fi + ;; + esac + fi +else + # PORTME fill in a description of your system's linker (not GNU ld) + case "$host_os" in + aix3*) + allow_undefined_flag=unsupported + always_export_symbols=yes + archive_expsym_cmds='$LD -o $objdir/$soname $libobjs $deplibs $linkopts -bE:$export_symbols -T512 -H512 -bM:SRE~$AR cru $lib $objdir/$soname' + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + hardcode_minus_L=yes + if test "$with_gcc" = yes && test -z "$link_static_flag"; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + hardcode_direct=unsupported + fi + ;; + + aix4*) + hardcode_libdir_flag_spec='${wl}-b ${wl}nolibpath ${wl}-b ${wl}libpath:$libdir:/usr/lib:/lib' + hardcode_libdir_separator=':' + if test "$with_gcc" = yes; then + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && \ + strings "$collect2name" | grep resolve_lib_name >/dev/null + then + # We have reworked collect2 + hardcode_direct=yes + else + # We have old collect2 + hardcode_direct=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + hardcode_minus_L=yes + hardcode_libdir_flag_spec='-L$libdir' + hardcode_libdir_separator= + fi + shared_flag='-shared' + else + shared_flag='${wl}-bM:SRE' + hardcode_direct=yes + fi + allow_undefined_flag=' ${wl}-berok' + archive_cmds="\$CC $shared_flag"' -o $objdir/$soname $libobjs $deplibs $linkopts ${wl}-bexpall ${wl}-bnoentry${allow_undefined_flag}' + archive_expsym_cmds="\$CC $shared_flag"' -o $objdir/$soname $libobjs $deplibs $linkopts ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}' + case "$host_os" in aix4.[01]|aix4.[01].*) + # According to Greg Wooledge, -bexpall is only supported from AIX 4.2 on + always_export_symbols=yes ;; + esac + ;; + + amigaos*) + archive_cmds='$rm $objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $objdir/a2ixlibrary.data~$AR cru $lib $libobjs~$RANLIB $lib~(cd $objdir && a2ixlibrary -32)' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + # see comment about different semantics on the GNU ld section + ld_shlibs=no + ;; + + cygwin* | mingw*) + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + hardcode_libdir_flag_spec=' ' + allow_undefined_flag=unsupported + # Tell ltmain to make .lib files, not .a files. + libext=lib + # FIXME: Setting linknames here is a bad hack. + archive_cmds='$CC -o $lib $libobjs $linkopts `echo "$deplibs" | sed -e '\''s/ -lc$//'\''` -link -dll~linknames=' + # The linker will automatically build a .lib file if we build a DLL. + old_archive_from_new_cmds='true' + # FIXME: Should let the user specify the lib program. + old_archive_cmds='lib /OUT:$oldlib$oldobjs' + fix_srcfile_path='`cygpath -w $srcfile`' + ;; + + freebsd1*) + ld_shlibs=no + ;; + + # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor + # support. Future versions do this automatically, but an explicit c++rt0.o + # does not break anything, and helps significantly (at the cost of a little + # extra space). + freebsd2.2*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linkopts /usr/lib/c++rt0.o' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + # Unfortunately, older versions of FreeBSD 2 do not have this feature. + freebsd2*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linkopts' + hardcode_direct=yes + hardcode_minus_L=yes + hardcode_shlibpath_var=no + ;; + + # FreeBSD 3 and greater uses gcc -shared to do shared libraries. + freebsd*) + archive_cmds='$CC -shared -o $lib $libobjs $deplibs $linkopts' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + hpux9* | hpux10* | hpux11*) + case "$host_os" in + hpux9*) archive_cmds='$rm $objdir/$soname~$LD -b +b $install_libdir -o $objdir/$soname $libobjs $deplibs $linkopts~test $objdir/$soname = $lib || mv $objdir/$soname $lib' ;; + *) archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linkopts' ;; + esac + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + hardcode_direct=yes + hardcode_minus_L=yes # Not in the search PATH, but as the default + # location of the library. + export_dynamic_flag_spec='${wl}-E' + ;; + + irix5* | irix6*) + if test "$with_gcc" = yes; then + archive_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib' + else + archive_cmds='$LD -shared $libobjs $deplibs $linkopts -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib' + fi + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linkopts' # a.out + else + archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linkopts' # ELF + fi + hardcode_libdir_flag_spec='${wl}-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + openbsd*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linkopts' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + os2*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + allow_undefined_flag=unsupported + archive_cmds='$echo "LIBRARY $libname INITINSTANCE" > $objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $objdir/$libname.def~$echo DATA >> $objdir/$libname.def~$echo " SINGLE NONSHARED" >> $objdir/$libname.def~$echo EXPORTS >> $objdir/$libname.def~emxexp $libobjs >> $objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $linkopts $objdir/$libname.def' + old_archive_from_new_cmds='emximp -o $objdir/$libname.a $objdir/$libname.def' + ;; + + osf3*) + if test "$with_gcc" = yes; then + allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $linkopts ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib' + else + allow_undefined_flag=' -expect_unresolved \*' + archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linkopts -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib' + fi + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + + osf4* | osf5*) # As osf3* with the addition of the -msym flag + if test "$with_gcc" = yes; then + allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $linkopts ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib' + else + allow_undefined_flag=' -expect_unresolved \*' + archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linkopts -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib' + fi + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + rhapsody*) + archive_cmds='$CC -bundle -undefined suppress -o $lib $libobjs $deplibs $linkopts' + hardcode_libdir_flags_spec='-L$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + sco3.2v5*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts' + hardcode_shlibpath_var=no + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + ;; + + solaris*) + no_undefined_flag=' -z text' + # $CC -shared without GNU ld will not create a library from C++ + # object files and a static libstdc++, better avoid it by now + archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linkopts' + archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linkopts~$rm $lib.exp' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_shlibpath_var=no + case "$host_os" in + solaris2.[0-5] | solaris2.[0-5].*) ;; + *) # Supported since Solaris 2.6 (maybe 2.5.1?) + whole_archive_flag_spec='-z allextract$convenience -z defaultextract' ;; + esac + ;; + + sunos4*) + archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linkopts' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_direct=yes + hardcode_minus_L=yes + hardcode_shlibpath_var=no + ;; + + sysv4) + if test "x$host_vendor" = xsequent; then + # Use $CC to link under sequent, because it throws in some extra .o + # files that make .init and .fini sections work. + archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $linkopts' + else + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts' + fi + runpath_var='LD_RUN_PATH' + hardcode_shlibpath_var=no + hardcode_direct=no #Motorola manual says yes, but my tests say they lie + ;; + + sysv4.3*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts' + hardcode_shlibpath_var=no + export_dynamic_flag_spec='-Bexport' + ;; + + sysv5*) + no_undefined_flag=' -z text' + # $CC -shared without GNU ld will not create a library from C++ + # object files and a static libstdc++, better avoid it by now + archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linkopts' + archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linkopts~$rm $lib.exp' + hardcode_libdir_flag_spec= + hardcode_shlibpath_var=no + runpath_var='LD_RUN_PATH' + ;; + + uts4*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_shlibpath_var=no + ;; + + dgux*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_shlibpath_var=no + ;; + + sysv4*MP*) + if test -d /usr/nec; then + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts' + hardcode_shlibpath_var=no + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + ld_shlibs=yes + fi + ;; + + sysv4.2uw2*) + archive_cmds='$LD -G -o $lib $libobjs $deplibs $linkopts' + hardcode_direct=yes + hardcode_minus_L=no + hardcode_shlibpath_var=no + hardcode_runpath_var=yes + runpath_var=LD_RUN_PATH + ;; + + unixware7*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts' + runpath_var='LD_RUN_PATH' + hardcode_shlibpath_var=no + ;; + + *) + ld_shlibs=no + ;; + esac +fi +echo "$ac_t$ld_shlibs" 1>&6 +test "$ld_shlibs" = no && can_build_shared=no + +if test -z "$NM"; then + echo $ac_n "checking for BSD-compatible nm... $ac_c" 1>&6 + case "$NM" in + [\\/]* | [A-Za-z]:[\\/]*) ;; # Let the user override the test with a path. + *) + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}" + for ac_dir in $PATH /usr/ucb /usr/ccs/bin /bin; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/nm || test -f $ac_dir/nm$ac_exeext; then + # Check to see if the nm accepts a BSD-compat flag. + # Adding the `sed 1q' prevents false positives on HP-UX, which says: + # nm: unknown option "B" ignored + if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then + NM="$ac_dir/nm -B" + break + elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then + NM="$ac_dir/nm -p" + break + else + NM=${NM="$ac_dir/nm"} # keep the first match, but + continue # so that we can try to find one that supports BSD flags + fi + fi + done + IFS="$ac_save_ifs" + test -z "$NM" && NM=nm + ;; + esac + echo "$ac_t$NM" 1>&6 +fi + +# Check for command to grab the raw symbol name followed by C symbol from nm. +echo $ac_n "checking command to parse $NM output... $ac_c" 1>&6 + +# These are sane defaults that work on at least a few old systems. +# [They come from Ultrix. What could be older than Ultrix?!! ;)] + +# Character class describing NM global symbol codes. +symcode='[BCDEGRST]' + +# Regexp to match symbols that can be accessed directly from C. +sympat='\([_A-Za-z][_A-Za-z0-9]*\)' + +# Transform the above into a raw symbol and a C symbol. +symxfrm='\1 \2\3 \3' + +# Transform an extracted symbol line into a proper C declaration +global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern char \1;/p'" + +# Define system-specific variables. +case "$host_os" in +aix*) + symcode='[BCDT]' + ;; +cygwin* | mingw*) + symcode='[ABCDGISTW]' + ;; +hpux*) # Its linker distinguishes data from code symbols + global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern char \1();/p' -e 's/^. .* \(.*\)$/extern char \1;/p'" + ;; +irix*) + symcode='[BCDEGRST]' + ;; +solaris*) + symcode='[BDT]' + ;; +sysv4) + symcode='[DFNSTU]' + ;; +esac + +# If we're using GNU nm, then use its standard symbol codes. +if $NM -V 2>&1 | egrep '(GNU|with BFD)' > /dev/null; then + symcode='[ABCDGISTW]' +fi + +# Try without a prefix undercore, then with it. +for ac_symprfx in "" "_"; do + + # Write the raw and C identifiers. + global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode\)[ ][ ]*\($ac_symprfx\)$sympat$/$symxfrm/p'" + + # Check to see that the pipe works correctly. + pipe_works=no + $rm conftest* + cat > conftest.c <&5 + if { (eval echo $progname:1654: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; } && test -s conftest.$objext; then + # Now try to grab the symbols. + nlist=conftest.nm + if { echo "$progname:1657: eval \"$NM conftest.$objext | $global_symbol_pipe > $nlist\"" >&5; eval "$NM conftest.$objext | $global_symbol_pipe > $nlist 2>&5"; } && test -s "$nlist"; then + + # Try sorting and uniquifying the output. + if sort "$nlist" | uniq > "$nlist"T; then + mv -f "$nlist"T "$nlist" + else + rm -f "$nlist"T + fi + + # Make sure that we snagged all the symbols we need. + if egrep ' nm_test_var$' "$nlist" >/dev/null; then + if egrep ' nm_test_func$' "$nlist" >/dev/null; then + cat < conftest.c +#ifdef __cplusplus +extern "C" { +#endif + +EOF + # Now generate the symbol file. + eval "$global_symbol_to_cdecl"' < "$nlist" >> conftest.c' + + cat <> conftest.c +#if defined (__STDC__) && __STDC__ +# define lt_ptr_t void * +#else +# define lt_ptr_t char * +# define const +#endif + +/* The mapping between symbol names and symbols. */ +const struct { + const char *name; + lt_ptr_t address; +} +lt_preloaded_symbols[] = +{ +EOF + sed 's/^. \(.*\) \(.*\)$/ {"\2", (lt_ptr_t) \&\2},/' < "$nlist" >> conftest.c + cat <<\EOF >> conftest.c + {0, (lt_ptr_t) 0} +}; + +#ifdef __cplusplus +} +#endif +EOF + # Now try linking the two files. + mv conftest.$objext conftstm.$objext + save_LIBS="$LIBS" + save_CFLAGS="$CFLAGS" + LIBS="conftstm.$objext" + CFLAGS="$CFLAGS$no_builtin_flag" + if { (eval echo $progname:1709: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then + pipe_works=yes + else + echo "$progname: failed program was:" >&5 + cat conftest.c >&5 + fi + LIBS="$save_LIBS" + else + echo "cannot find nm_test_func in $nlist" >&5 + fi + else + echo "cannot find nm_test_var in $nlist" >&5 + fi + else + echo "cannot run $global_symbol_pipe" >&5 + fi + else + echo "$progname: failed program was:" >&5 + cat conftest.c >&5 + fi + $rm conftest* conftst* + + # Do not use the global_symbol_pipe unless it works. + if test "$pipe_works" = yes; then + break + else + global_symbol_pipe= + fi +done +if test "$pipe_works" = yes; then + echo "${ac_t}ok" 1>&6 +else + echo "${ac_t}failed" 1>&6 +fi + +if test -z "$global_symbol_pipe"; then + global_symbol_to_cdecl= +fi + +# Check hardcoding attributes. +echo $ac_n "checking how to hardcode library paths into programs... $ac_c" 1>&6 +hardcode_action= +if test -n "$hardcode_libdir_flag_spec" || \ + test -n "$runpath_var"; then + + # We can hardcode non-existant directories. + if test "$hardcode_direct" != no && + # If the only mechanism to avoid hardcoding is shlibpath_var, we + # have to relink, otherwise we might link with an installed library + # when we should be linking with a yet-to-be-installed one + ## test "$hardcode_shlibpath_var" != no && + test "$hardcode_minus_L" != no; then + # Linking always hardcodes the temporary library directory. + hardcode_action=relink + else + # We can link without hardcoding, and we can hardcode nonexisting dirs. + hardcode_action=immediate + fi +else + # We cannot hardcode anything, or else we can only hardcode existing + # directories. + hardcode_action=unsupported +fi +echo "$ac_t$hardcode_action" 1>&6 + + +reload_flag= +reload_cmds='$LD$reload_flag -o $output$reload_objs' +echo $ac_n "checking for $LD option to reload object files... $ac_c" 1>&6 +# PORTME Some linkers may need a different reload flag. +reload_flag='-r' +echo "$ac_t$reload_flag" 1>&6 +test -n "$reload_flag" && reload_flag=" $reload_flag" + +# PORTME Fill in your ld.so characteristics +library_names_spec= +libname_spec='lib$name' +soname_spec= +postinstall_cmds= +postuninstall_cmds= +finish_cmds= +finish_eval= +shlibpath_var= +shlibpath_overrides_runpath=unknown +version_type=none +dynamic_linker="$host_os ld.so" +sys_lib_dlsearch_path_spec="/lib /usr/lib" +sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" +file_magic_cmd= +file_magic_test_file= +deplibs_check_method='unknown' +# Need to set the preceding variable on all platforms that support +# interlibrary dependencies. +# 'none' -- dependencies not supported. +# `unknown' -- same as none, but documents that we really don't know. +# 'pass_all' -- all dependencies passed with no checks. +# 'test_compile' -- check by making test program. +# 'file_magic [regex]' -- check by looking for files in library path +# which responds to the $file_magic_cmd with a given egrep regex. +# If you have `file' or equivalent on your system and you're not sure +# whether `pass_all' will *always* work, you probably want this one. +echo $ac_n "checking dynamic linker characteristics... $ac_c" 1>&6 +case "$host_os" in +aix3*) + version_type=linux + library_names_spec='${libname}${release}.so$versuffix $libname.a' + shlibpath_var=LIBPATH + + # AIX has no versioning support, so we append a major version to the name. + soname_spec='${libname}${release}.so$major' + ;; + +aix4*) + version_type=linux + # AIX has no versioning support, so currently we can not hardcode correct + # soname into executable. Probably we can add versioning support to + # collect2, so additional links can be useful in future. + # We preserve .a as extension for shared libraries though AIX4.2 + # and later linker supports .so + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.a' + shlibpath_var=LIBPATH + deplibs_check_method=pass_all + ;; + +amigaos*) + library_names_spec='$libname.ixlibrary $libname.a' + # Create ${libname}_ixlibrary.a entries in /sys/libs. + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "(cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a)"; (cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a) || exit 1; done' + ;; + +beos*) + library_names_spec='${libname}.so' + dynamic_linker="$host_os ld.so" + shlibpath_var=LIBRARY_PATH + deplibs_check_method=pass_all + lt_cv_dlopen="load_add_on" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + ;; + +bsdi4*) + version_type=linux + need_version=no + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + soname_spec='${libname}${release}.so$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' + file_magic_cmd=/usr/bin/file + file_magic_test_file=/shlib/libc.so + sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" + sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" + export_dynamic_flag_spec=-rdynamic + # the default ld.so.conf also contains /usr/contrib/lib and + # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow + # libtool to hard-code these into programs + ;; + +cygwin* | mingw*) + version_type=windows + need_version=no + need_lib_prefix=no + if test "$with_gcc" = yes; then + library_names_spec='${libname}`echo ${release} | sed -e 's/[.]/-/g'`${versuffix}.dll $libname.a' + else + library_names_spec='${libname}`echo ${release} | sed -e 's/[.]/-/g'`${versuffix}.dll $libname.lib' + fi + dynamic_linker='Win32 ld.exe' + deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?' + file_magic_cmd='${OBJDUMP} -f' + # FIXME: first we should search . and the directory the executable is in + shlibpath_var=PATH + lt_cv_dlopen="LoadLibrary" + lt_cv_dlopen_libs= + ;; + +freebsd1*) + dynamic_linker=no + ;; + +freebsd*) + objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout` + version_type=freebsd-$objformat + case "$version_type" in + freebsd-elf*) + deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB shared object' + file_magic_cmd=/usr/bin/file + file_magic_test_file=`echo /usr/lib/libc.so*` + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so $libname.so' + need_version=no + need_lib_prefix=no + ;; + freebsd-*) + deplibs_check_method=unknown + library_names_spec='${libname}${release}.so$versuffix $libname.so$versuffix' + need_version=yes + ;; + esac + shlibpath_var=LD_LIBRARY_PATH + case "$host_os" in + freebsd2* | freebsd3.[01]* | freebsdelf3.[01]*) + shlibpath_overrides_runpath=yes + ;; + *) # from 3.2 on + shlibpath_overrides_runpath=no + ;; + esac + ;; + +gnu*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so${major} ${libname}.so' + soname_spec='${libname}${release}.so$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +hpux9* | hpux10* | hpux11*) + # Give a soname corresponding to the major version so that dld.sl refuses to + # link against other versions. + dynamic_linker="$host_os dld.sl" + version_type=sunos + need_lib_prefix=no + need_version=no + shlibpath_var=SHLIB_PATH + shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH + library_names_spec='${libname}${release}.sl$versuffix ${libname}${release}.sl$major $libname.sl' + soname_spec='${libname}${release}.sl$major' + # HP-UX runs *really* slowly unless shared libraries are mode 555. + postinstall_cmds='chmod 555 $lib' + case "$host_os" in + hpux10.20*) + # TODO: Does this work for hpux-11 too? + deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9].[0-9]) shared library' + file_magic_cmd=/usr/bin/file + file_magic_test_file=/usr/lib/libc.sl + ;; + esac + ;; + +irix5* | irix6*) + version_type=irix + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}.so.$major' + library_names_spec='${libname}${release}.so.$versuffix ${libname}${release}.so.$major ${libname}${release}.so $libname.so' + case "$host_os" in + irix5*) + libsuff= shlibsuff= + # this will be overridden with pass_all, but let us keep it just in case + deplibs_check_method="file_magic ELF 32-bit MSB dynamic lib MIPS - version 1" + ;; + *) + case "$LD" in # libtool.m4 will add one of these switches to LD + *-32|*"-32 ") libsuff= shlibsuff= libmagic=32-bit;; + *-n32|*"-n32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; + *-64|*"-64 ") libsuff=64 shlibsuff=64 libmagic=64-bit;; + *) libsuff= shlibsuff= libmagic=never-match;; + esac + ;; + esac + shlibpath_var=LD_LIBRARY${shlibsuff}_PATH + shlibpath_overrides_runpath=no + sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" + sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" + file_magic_cmd=/usr/bin/file + file_magic_test_file=`echo /lib${libsuff}/libc.so*` + deplibs_check_method='pass_all' + ;; + +# No shared lib support for Linux oldld, aout, or coff. +linux-gnuoldld* | linux-gnuaout* | linux-gnucoff*) + dynamic_linker=no + ;; + +# This must be Linux ELF. +linux-gnu*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + soname_spec='${libname}${release}.so$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + deplibs_check_method=pass_all + + if test -f /lib/ld.so.1; then + dynamic_linker='GNU ld.so' + else + # Only the GNU ld.so supports shared libraries on MkLinux. + case "$host_cpu" in + powerpc*) dynamic_linker=no ;; + *) dynamic_linker='Linux ld.so' ;; + esac + fi + ;; + +netbsd*) + version_type=sunos + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + dynamic_linker='NetBSD (a.out) ld.so' + else + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major ${libname}${release}.so ${libname}.so' + soname_spec='${libname}${release}.so$major' + dynamic_linker='NetBSD ld.elf_so' + fi + shlibpath_var=LD_LIBRARY_PATH + ;; + +openbsd*) + version_type=sunos + if test "$with_gnu_ld" = yes; then + need_lib_prefix=no + need_version=no + fi + library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + shlibpath_var=LD_LIBRARY_PATH + ;; + +os2*) + libname_spec='$name' + need_lib_prefix=no + library_names_spec='$libname.dll $libname.a' + dynamic_linker='OS/2 ld.exe' + shlibpath_var=LIBPATH + ;; + +osf3* | osf4* | osf5*) + version_type=osf + need_version=no + soname_spec='${libname}${release}.so' + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so $libname.so' + shlibpath_var=LD_LIBRARY_PATH + # this will be overridden with pass_all, but let us keep it just in case + deplibs_check_method='file_magic COFF format alpha shared library' + file_magic_cmd=/usr/bin/file + file_magic_test_file=/shlib/libc.so + deplibs_check_method='pass_all' + sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" + sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" + ;; + +rhapsody*) + version_type=sunos + library_names_spec='${libname}.so' + soname_spec='${libname}.so' + shlibpath_var=DYLD_LIBRARY_PATH + deplibs_check_method=pass_all + ;; + +sco3.2v5*) + version_type=osf + soname_spec='${libname}${release}.so$major' + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + shlibpath_var=LD_LIBRARY_PATH + ;; + +solaris*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + soname_spec='${libname}${release}.so$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + # ldd complains unless libraries are executable + postinstall_cmds='chmod +x $lib' + deplibs_check_method="file_magic ELF [0-9][0-9]-bit [LM]SB dynamic lib" + file_magic_cmd=/usr/bin/file + file_magic_test_file=/lib/libc.so + ;; + +sunos4*) + version_type=sunos + library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix' + finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + if test "$with_gnu_ld" = yes; then + need_lib_prefix=no + fi + need_version=yes + ;; + +sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + version_type=linux + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + soname_spec='${libname}${release}.so$major' + shlibpath_var=LD_LIBRARY_PATH + case "$host_vendor" in + sequent) + file_magic_cmd='/bin/file' + deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' + ;; + ncr) + deplibs_check_method='pass_all' + ;; + motorola) + need_lib_prefix=no + need_version=no + shlibpath_overrides_runpath=no + sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' + deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]' + file_magic_cmd=/usr/bin/file + file_magic_test_file=`echo /usr/lib/libc.so*` + ;; + esac + ;; + +uts4*) + version_type=linux + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + soname_spec='${libname}${release}.so$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +dgux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + soname_spec='${libname}${release}.so$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +sysv4*MP*) + if test -d /usr/nec ;then + version_type=linux + library_names_spec='$libname.so.$versuffix $libname.so.$major $libname.so' + soname_spec='$libname.so.$major' + shlibpath_var=LD_LIBRARY_PATH + fi + ;; + +*) + dynamic_linker=no + ;; +esac +echo "$ac_t$dynamic_linker" 1>&6 +test "$dynamic_linker" = no && can_build_shared=no + +# Report the final consequences. +echo "checking if libtool supports shared libraries... $can_build_shared" 1>&6 + +# Only try to build win32 dlls if AC_LIBTOOL_WIN32_DLL was used in +# configure.in, otherwise build static only libraries. +case "$host_os" in +cygwin* | mingw* | os2*) + if test x$can_build_shared = xyes; then + test x$enable_win32_dll = xno && can_build_shared=no + echo "checking if package supports dlls... $can_build_shared" 1>&6 + fi +;; +esac + +if test -n "$file_magic_test_file" && test -n "$file_magic_cmd"; then + case "$deplibs_check_method" in + "file_magic "*) + file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`" + if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | + egrep "$file_magic_regex" > /dev/null; then + : + else + cat <&2 + +*** Warning: the command libtool uses to detect shared libraries, +*** $file_magic_cmd, produces output that libtool cannot recognize. +*** The result is that libtool may fail to recognize shared libraries +*** as such. This will affect the creation of libtool libraries that +*** depend on shared libraries, but programs linked with such libtool +*** libraries will work regardless of this problem. Nevertheless, you +*** may want to report the problem to your system manager and/or to +*** bug-libtool@gnu.org + +EOF + fi ;; + esac +fi + +echo $ac_n "checking whether to build shared libraries... $ac_c" 1>&6 +test "$can_build_shared" = "no" && enable_shared=no + +# On AIX, shared libraries and static libraries use the same namespace, and +# are all built from PIC. +case "$host_os" in +aix3*) + test "$enable_shared" = yes && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + +aix4*) + test "$enable_shared" = yes && enable_static=no + ;; +esac + +echo "$ac_t$enable_shared" 1>&6 + +# Make sure either enable_shared or enable_static is yes. +test "$enable_shared" = yes || enable_static=yes + +echo "checking whether to build static libraries... $enable_static" 1>&6 + +if test "$hardcode_action" = relink; then + # Fast installation is not supported + enable_fast_install=no +elif test "$shlibpath_overrides_runpath" = yes || + test "$enable_shared" = no; then + # Fast installation is not necessary + enable_fast_install=needless +fi + +echo $ac_n "checking for objdir... $ac_c" 1>&6 +rm -f .libs 2>/dev/null +mkdir .libs 2>/dev/null +if test -d .libs; then + objdir=.libs +else + # MS-DOS does not allow filenames that begin with a dot. + objdir=_libs +fi +rmdir .libs 2>/dev/null +echo "$ac_t$objdir" 1>&6 + +if test "x$enable_dlopen" != xyes; then + enable_dlopen=unknown + enable_dlopen_self=unknown + enable_dlopen_self_static=unknown +else +if eval "test \"`echo '$''{'lt_cv_dlopen'+set}'`\" != set"; then + lt_cv_dlopen=no lt_cv_dlopen_libs= +echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6 +echo "$progname:2248: checking for dlopen in -ldl" >&5 +ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-ldl $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "$progname: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" +else + echo "$ac_t""no" 1>&6 +echo $ac_n "checking for dlopen""... $ac_c" 1>&6 +echo "$progname:2288: checking for dlopen" >&5 +if eval "test \"`echo '$''{'ac_cv_func_dlopen'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char dlopen(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_dlopen) || defined (__stub___dlopen) +choke me +#else +dlopen(); +#endif + +; return 0; } +EOF +if { (eval echo $progname:2318: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_dlopen=yes" +else + echo "$progname: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_dlopen=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_func_'dlopen`\" = yes"; then + echo "$ac_t""yes" 1>&6 + lt_cv_dlopen="dlopen" +else + echo "$ac_t""no" 1>&6 +echo $ac_n "checking for dld_link in -ldld""... $ac_c" 1>&6 +echo "$progname:2335: checking for dld_link in -ldld" >&5 +ac_lib_var=`echo dld'_'dld_link | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-ldld $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "$progname: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld" +else + echo "$ac_t""no" 1>&6 +echo $ac_n "checking for shl_load""... $ac_c" 1>&6 +echo "$progname:2375: checking for shl_load" >&5 +if eval "test \"`echo '$''{'ac_cv_func_shl_load'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char shl_load(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_shl_load) || defined (__stub___shl_load) +choke me +#else +shl_load(); +#endif + +; return 0; } +EOF +if { (eval echo $progname:2405: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_shl_load=yes" +else + echo "$progname: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_shl_load=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'shl_load`\" = yes"; then + echo "$ac_t""yes" 1>&6 + lt_cv_dlopen="shl_load" +else + echo "$ac_t""no" 1>&6 +echo $ac_n "checking for shl_load in -ldld""... $ac_c" 1>&6 +echo "$progname:2423: checking for shl_load in -ldld" >&5 +ac_lib_var=`echo dld'_'shl_load | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-ldld $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "$progname: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld" +else + echo "$ac_t""no" 1>&6 +fi + + +fi + + +fi + + +fi + + +fi + +fi + + if test "x$lt_cv_dlopen" != xno; then + enable_dlopen=yes + fi + + case "$lt_cv_dlopen" in + dlopen) +for ac_hdr in dlfcn.h; do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "$progname:2488: checking for $ac_hdr" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +int fnord = 0; +EOF +ac_try="$ac_compile >/dev/null 2>conftest.out" +{ (eval echo $progname:2498: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "$progname: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi +done + + if test "x$ac_cv_header_dlfcn_h" = xyes; then + CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" + fi + eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" + LIBS="$lt_cv_dlopen_libs $LIBS" + + echo $ac_n "checking whether a program can dlopen itself""... $ac_c" 1>&6 +echo "$progname:2526: checking whether a program can dlopen itself" >&5 +if test "${lt_cv_dlopen_self+set}" = set; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + lt_cv_dlopen_self=cross + else + cat > conftest.c < +#endif + +#include + +#ifdef RTLD_GLOBAL +# define LTDL_GLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LTDL_GLOBAL DL_GLOBAL +# else +# define LTDL_GLOBAL 0 +# endif +#endif + +/* We may have to define LTDL_LAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LTDL_LAZY_OR_NOW +# ifdef RTLD_LAZY +# define LTDL_LAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LTDL_LAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LTDL_LAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LTDL_LAZY_OR_NOW DL_NOW +# else +# define LTDL_LAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +fnord() { int i=42;} +main() { void *self, *ptr1, *ptr2; self=dlopen(0,LTDL_GLOBAL|LTDL_LAZY_OR_NOW); + if(self) { ptr1=dlsym(self,"fnord"); ptr2=dlsym(self,"_fnord"); + if(ptr1 || ptr2) { dlclose(self); exit(0); } } exit(1); } + +EOF +if { (eval echo $progname:2580: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +then + lt_cv_dlopen_self=yes +else + echo "$progname: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + lt_cv_dlopen_self=no +fi +rm -fr conftest* +fi + +fi + +echo "$ac_t""$lt_cv_dlopen_self" 1>&6 + + if test "$lt_cv_dlopen_self" = yes; then + LDFLAGS="$LDFLAGS $link_static_flag" + echo $ac_n "checking whether a statically linked program can dlopen itself""... $ac_c" 1>&6 +echo "$progname:2599: checking whether a statically linked program can dlopen itself" >&5 +if test "${lt_cv_dlopen_self_static+set}" = set; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + lt_cv_dlopen_self_static=cross + else + cat > conftest.c < +#endif + +#include + +#ifdef RTLD_GLOBAL +# define LTDL_GLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LTDL_GLOBAL DL_GLOBAL +# else +# define LTDL_GLOBAL 0 +# endif +#endif + +/* We may have to define LTDL_LAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LTDL_LAZY_OR_NOW +# ifdef RTLD_LAZY +# define LTDL_LAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LTDL_LAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LTDL_LAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LTDL_LAZY_OR_NOW DL_NOW +# else +# define LTDL_LAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +fnord() { int i=42;} +main() { void *self, *ptr1, *ptr2; self=dlopen(0,LTDL_GLOBAL|LTDL_LAZY_OR_NOW); + if(self) { ptr1=dlsym(self,"fnord"); ptr2=dlsym(self,"_fnord"); + if(ptr1 || ptr2) { dlclose(self); exit(0); } } exit(1); } + +EOF +if { (eval echo $progname:2653: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +then + lt_cv_dlopen_self_static=yes +else + echo "$progname: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + lt_cv_dlopen_self_static=no +fi +rm -fr conftest* +fi + +fi + +echo "$ac_t""$lt_cv_dlopen_self_static" 1>&6 +fi + ;; + esac + + case "$lt_cv_dlopen_self" in + yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; + *) enable_dlopen_self=unknown ;; + esac + + case "$lt_cv_dlopen_self_static" in + yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; + *) enable_dlopen_self_static=unknown ;; + esac +fi + +# Copy echo and quote the copy, instead of the original, because it is +# used later. +ltecho="$echo" +if test "X$ltecho" = "X$CONFIG_SHELL $0 --fallback-echo"; then + ltecho="$CONFIG_SHELL \$0 --fallback-echo" +fi +LTSHELL="$SHELL" + +LTCONFIG_VERSION="$VERSION" + +# Only quote variables if we're using ltmain.sh. +case "$ltmain" in +*.sh) + # Now quote all the things that may contain metacharacters. + for var in ltecho old_CC old_CFLAGS old_CPPFLAGS \ + old_LD old_LDFLAGS old_LIBS \ + old_NM old_RANLIB old_LN_S old_DLLTOOL old_OBJDUMP old_AS \ + AR CC LD LN_S NM LTSHELL LTCONFIG_VERSION \ + reload_flag reload_cmds wl \ + pic_flag link_static_flag no_builtin_flag export_dynamic_flag_spec \ + thread_safe_flag_spec whole_archive_flag_spec libname_spec \ + library_names_spec soname_spec \ + RANLIB old_archive_cmds old_archive_from_new_cmds old_postinstall_cmds \ + old_postuninstall_cmds archive_cmds archive_expsym_cmds postinstall_cmds postuninstall_cmds \ + file_magic_cmd export_symbols_cmds deplibs_check_method allow_undefined_flag no_undefined_flag \ + finish_cmds finish_eval global_symbol_pipe global_symbol_to_cdecl \ + hardcode_libdir_flag_spec hardcode_libdir_separator \ + sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ + compiler_c_o compiler_o_lo need_locks exclude_expsyms include_expsyms; do + + case "$var" in + reload_cmds | old_archive_cmds | old_archive_from_new_cmds | \ + old_postinstall_cmds | old_postuninstall_cmds | \ + export_symbols_cmds | archive_cmds | archive_expsym_cmds | \ + postinstall_cmds | postuninstall_cmds | \ + finish_cmds | sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) + # Double-quote double-evaled strings. + eval "$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" + ;; + *) + eval "$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" + ;; + esac + done + + case "$ltecho" in + *'\$0 --fallback-echo"') + ltecho=`$echo "X$ltecho" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'` + ;; + esac + + trap "$rm \"$ofile\"; exit 1" 1 2 15 + echo "creating $ofile" + $rm "$ofile" + cat < "$ofile" +#! $SHELL + +# `$echo "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. +# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP) +# NOTE: Changes made to this file will be lost: look at ltconfig or ltmain.sh. +# +# Copyright (C) 1996-1999 Free Software Foundation, Inc. +# Originally by Gordon Matzigkeit , 1996 +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Sed that helps us avoid accidentally triggering echo(1) options like -n. +Xsed="sed -e s/^X//" + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +if test "X\${CDPATH+set}" = Xset; then CDPATH=:; export CDPATH; fi + +### BEGIN LIBTOOL CONFIG +EOF + cfgfile="$ofile" + ;; + +*) + # Double-quote the variables that need it (for aesthetics). + for var in old_CC old_CFLAGS old_CPPFLAGS \ + old_LD old_LDFLAGS old_LIBS \ + old_NM old_RANLIB old_LN_S old_DLLTOOL old_OBJDUMP old_AS; do + eval "$var=\\\"\$var\\\"" + done + + # Just create a config file. + cfgfile="$ofile.cfg" + trap "$rm \"$cfgfile\"; exit 1" 1 2 15 + echo "creating $cfgfile" + $rm "$cfgfile" + cat < "$cfgfile" +# `$echo "$cfgfile" | sed 's%^.*/%%'` - Libtool configuration file. +# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP) +EOF + ;; +esac + +cat <> "$cfgfile" +# Libtool was configured as follows, on host `(hostname || uname -n) 2>/dev/null | sed 1q`: +# +# CC=$old_CC CFLAGS=$old_CFLAGS CPPFLAGS=$old_CPPFLAGS \\ +# LD=$old_LD LDFLAGS=$old_LDFLAGS LIBS=$old_LIBS \\ +# NM=$old_NM RANLIB=$old_RANLIB LN_S=$old_LN_S \\ +# DLLTOOL=$old_DLLTOOL OBJDUMP=$old_OBJDUMP AS=$old_AS \\ +# $0$ltconfig_args +# +# Compiler and other test output produced by $progname, useful for +# debugging $progname, is in ./config.log if it exists. + +# The version of $progname that generated this script. +LTCONFIG_VERSION=$LTCONFIG_VERSION + +# Shell to use when invoking shell scripts. +SHELL=$LTSHELL + +# Whether or not to build shared libraries. +build_libtool_libs=$enable_shared + +# Whether or not to build static libraries. +build_old_libs=$enable_static + +# Whether or not to optimize for fast installation. +fast_install=$enable_fast_install + +# The host system. +host_alias=$host_alias +host=$host + +# An echo program that does not interpret backslashes. +echo=$ltecho + +# The archiver. +AR=$AR + +# The default C compiler. +CC=$CC + +# The linker used to build libraries. +LD=$LD + +# Whether we need hard or soft links. +LN_S=$LN_S + +# A BSD-compatible nm program. +NM=$NM + +# Used on cygwin: DLL creation program. +DLLTOOL="$DLLTOOL" + +# Used on cygwin: object dumper. +OBJDUMP="$OBJDUMP" + +# Used on cygwin: assembler. +AS="$AS" + +# The name of the directory that contains temporary libtool files. +objdir=$objdir + +# How to create reloadable object files. +reload_flag=$reload_flag +reload_cmds=$reload_cmds + +# How to pass a linker flag through the compiler. +wl=$wl + +# Object file suffix (normally "o"). +objext="$objext" + +# Old archive suffix (normally "a"). +libext="$libext" + +# Executable file suffix (normally ""). +exeext="$exeext" + +# Additional compiler flags for building library objects. +pic_flag=$pic_flag + +# Does compiler simultaneously support -c and -o options? +compiler_c_o=$compiler_c_o + +# Can we write directly to a .lo ? +compiler_o_lo=$compiler_o_lo + +# Must we lock files when doing compilation ? +need_locks=$need_locks + +# Do we need the lib prefix for modules? +need_lib_prefix=$need_lib_prefix + +# Do we need a version for libraries? +need_version=$need_version + +# Whether dlopen is supported. +dlopen=$enable_dlopen + +# Whether dlopen of programs is supported. +dlopen_self=$enable_dlopen_self + +# Whether dlopen of statically linked programs is supported. +dlopen_self_static=$enable_dlopen_self_static + +# Compiler flag to prevent dynamic linking. +link_static_flag=$link_static_flag + +# Compiler flag to turn off builtin functions. +no_builtin_flag=$no_builtin_flag + +# Compiler flag to allow reflexive dlopens. +export_dynamic_flag_spec=$export_dynamic_flag_spec + +# Compiler flag to generate shared objects directly from archives. +whole_archive_flag_spec=$whole_archive_flag_spec + +# Compiler flag to generate thread-safe objects. +thread_safe_flag_spec=$thread_safe_flag_spec + +# Library versioning type. +version_type=$version_type + +# Format of library name prefix. +libname_spec=$libname_spec + +# List of archive names. First name is the real one, the rest are links. +# The last name is the one that the linker finds with -lNAME. +library_names_spec=$library_names_spec + +# The coded name of the library, if different from the real name. +soname_spec=$soname_spec + +# Commands used to build and install an old-style archive. +RANLIB=$RANLIB +old_archive_cmds=$old_archive_cmds +old_postinstall_cmds=$old_postinstall_cmds +old_postuninstall_cmds=$old_postuninstall_cmds + +# Create an old-style archive from a shared archive. +old_archive_from_new_cmds=$old_archive_from_new_cmds + +# Commands used to build and install a shared archive. +archive_cmds=$archive_cmds +archive_expsym_cmds=$archive_expsym_cmds +postinstall_cmds=$postinstall_cmds +postuninstall_cmds=$postuninstall_cmds + +# Method to check whether dependent libraries are shared objects. +deplibs_check_method=$deplibs_check_method + +# Command to use when deplibs_check_method == file_magic. +file_magic_cmd=$file_magic_cmd + +# Flag that allows shared libraries with undefined symbols to be built. +allow_undefined_flag=$allow_undefined_flag + +# Flag that forces no undefined symbols. +no_undefined_flag=$no_undefined_flag + +# Commands used to finish a libtool library installation in a directory. +finish_cmds=$finish_cmds + +# Same as above, but a single script fragment to be evaled but not shown. +finish_eval=$finish_eval + +# Take the output of nm and produce a listing of raw symbols and C names. +global_symbol_pipe=$global_symbol_pipe + +# Transform the output of nm in a proper C declaration +global_symbol_to_cdecl=$global_symbol_to_cdecl + +# This is the shared library runtime path variable. +runpath_var=$runpath_var + +# This is the shared library path variable. +shlibpath_var=$shlibpath_var + +# Is shlibpath searched before the hard-coded library search path? +shlibpath_overrides_runpath=$shlibpath_overrides_runpath + +# How to hardcode a shared library path into an executable. +hardcode_action=$hardcode_action + +# Flag to hardcode \$libdir into a binary during linking. +# This must work even if \$libdir does not exist. +hardcode_libdir_flag_spec=$hardcode_libdir_flag_spec + +# Whether we need a single -rpath flag with a separated argument. +hardcode_libdir_separator=$hardcode_libdir_separator + +# Set to yes if using DIR/libNAME.so during linking hardcodes DIR into the +# resulting binary. +hardcode_direct=$hardcode_direct + +# Set to yes if using the -LDIR flag during linking hardcodes DIR into the +# resulting binary. +hardcode_minus_L=$hardcode_minus_L + +# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into +# the resulting binary. +hardcode_shlibpath_var=$hardcode_shlibpath_var + +# Compile-time system search path for libraries +sys_lib_search_path_spec=$sys_lib_search_path_spec + +# Run-time system search path for libraries +sys_lib_dlsearch_path_spec=$sys_lib_dlsearch_path_spec + +# Fix the shell variable \$srcfile for the compiler. +fix_srcfile_path="$fix_srcfile_path" + +# Set to yes if exported symbols are required. +always_export_symbols=$always_export_symbols + +# The commands to list exported symbols. +export_symbols_cmds=$export_symbols_cmds + +# Symbols that should not be listed in the preloaded symbols. +exclude_expsyms=$exclude_expsyms + +# Symbols that must always be exported. +include_expsyms=$include_expsyms + +EOF + +case "$ltmain" in +*.sh) + echo '### END LIBTOOL CONFIG' >> "$ofile" + echo >> "$ofile" + case "$host_os" in + aix3*) + cat <<\EOF >> "$ofile" + +# AIX sometimes has problems with the GCC collect2 program. For some +# reason, if we set the COLLECT_NAMES environment variable, the problems +# vanish in a puff of smoke. +if test "X${COLLECT_NAMES+set}" != Xset; then + COLLECT_NAMES= + export COLLECT_NAMES +fi +EOF + ;; + esac + + # Append the ltmain.sh script. + sed '$q' "$ltmain" >> "$ofile" || (rm -f "$ofile"; exit 1) + # We use sed instead of cat because bash on DJGPP gets confused if + # if finds mixed CR/LF and LF-only lines. Since sed operates in + # text mode, it properly converts lines to CR/LF. This bash problem + # is reportedly fixed, but why not run on old versions too? + + chmod +x "$ofile" + ;; + +*) + # Compile the libtool program. + echo "FIXME: would compile $ltmain" + ;; +esac + +test -n "$cache_file" || exit 0 + +# AC_CACHE_SAVE +trap '' 1 2 15 +cat > confcache <<\EOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs. It is not useful on other systems. +# If it contains results you don't want to keep, you may remove or edit it. +# +# By default, configure uses ./config.cache as the cache file, +# creating it if it does not exist already. You can give configure +# the --cache-file=FILE option to use a different cache file; that is +# what configure does when it calls configure scripts in +# subdirectories, so they share the cache. +# Giving --cache-file=/dev/null disables caching, for debugging configure. +# config.status only pays attention to the cache file if you give it the +# --recheck option to rerun configure. +# +EOF +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, don't put newlines in cache variables' values. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +(set) 2>&1 | + case `(ac_space=' '; set | grep ac_space) 2>&1` in + *ac_space=\ *) + # `set' does not quote correctly, so add quotes (double-quote substitution + # turns \\\\ into \\, and sed turns \\ into \). + sed -n \ + -e "s/'/'\\\\''/g" \ + -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p" + ;; + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p' + ;; + esac >> confcache +if cmp -s $cache_file confcache; then + : +else + if test -w $cache_file; then + echo "updating cache $cache_file" + cat confcache > $cache_file + else + echo "not updating unwritable cache $cache_file" + fi +fi +rm -f confcache + +exit 0 + +# Local Variables: +# mode:shell-script +# sh-indentation:2 +# End: diff --git a/contrib/idn/mdnkit/ltmain.sh b/contrib/idn/mdnkit/ltmain.sh new file mode 100644 index 0000000000..766732da84 --- /dev/null +++ b/contrib/idn/mdnkit/ltmain.sh @@ -0,0 +1,4024 @@ +# ltmain.sh - Provide generalized library-building support services. +# NOTE: Changing this file will not affect anything until you rerun ltconfig. +# +# Copyright (C) 1996-1999 Free Software Foundation, Inc. +# Originally by Gordon Matzigkeit , 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 <&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 +# #undef WIN32_LEAN_AND_MEAN +# #include +# +# #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 +# 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 /* for printf() */ +# #include /* for open(), lseek(), read() */ +# #include /* for O_RDONLY, O_BINARY */ +# #include /* 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&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 </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*) + case "$compile_command " in + *" -static "*) ;; + *) pic_flag_for_symtable=" $pic_flag -DPIC -DFREEBSD_WORKAROUND";; + esac;; + *-*-hpux*) + case "$compile_command " in + *" -static "*) ;; + *) pic_flag_for_symtable=" $pic_flag -DPIC";; + esac + esac + + # Now compile the dynamic symbol file. + $show "(cd $output_objdir && $CC -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")" + $run eval '(cd $output_objdir && $CC -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $? + + # Clean up the generated files. + $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T" + $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T" + + # Transform the symbol file into the correct name. + compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"` + finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"` + ;; + *) + $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2 + exit 1 + ;; + esac + else + # We keep going just in case the user didn't refer to + # lt_preloaded_symbols. The linker will fail if global_symbol_pipe + # really was required. + + # Nullify the symbol file. + compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"` + finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"` + fi + + if test -z "$link_against_libtool_libs" || test "$build_libtool_libs" != yes; then + # Replace the output file specification. + compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` + link_command="$compile_command$compile_rpath" + + # We have no uninstalled library dependencies, so finalize right now. + $show "$link_command" + $run eval "$link_command" + status=$? + + # Delete the generated files. + if test -n "$dlsyms"; then + $show "$rm $output_objdir/${outputname}S.${objext}" + $run $rm "$output_objdir/${outputname}S.${objext}" + fi + + exit $status + fi + + if test -n "$shlibpath_var"; then + # We should set the shlibpath_var + rpath= + for dir in $temp_rpath; do + case "$dir" in + [\\/]* | [A-Za-z]:[\\/]*) + # Absolute path. + rpath="$rpath$dir:" + ;; + *) + # Relative path: add a thisdir entry. + rpath="$rpath\$thisdir/$dir:" + ;; + esac + done + temp_rpath="$rpath" + fi + + if test -n "$compile_shlibpath$finalize_shlibpath"; then + compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" + fi + if test -n "$finalize_shlibpath"; then + finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" + fi + + compile_var= + finalize_var= + if test -n "$runpath_var"; then + if test -n "$perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $perm_rpath; do + rpath="$rpath$dir:" + done + compile_var="$runpath_var=\"$rpath\$$runpath_var\" " + fi + if test -n "$finalize_perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $finalize_perm_rpath; do + rpath="$rpath$dir:" + done + finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " + fi + fi + + if test "$hardcode_action" = relink; then + # Fast installation is not supported + link_command="$compile_var$compile_command$compile_rpath" + relink_command="$finalize_var$finalize_command$finalize_rpath" + + $echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2 + $echo "$modename: \`$output' will be relinked during installation" 1>&2 + else + if test "$fast_install" != no; then + link_command="$finalize_var$compile_command$finalize_rpath" + if test "$fast_install" = yes; then + relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'` + else + # fast_install is set to needless + relink_command= + fi + else + link_command="$compile_var$compile_command$compile_rpath" + relink_command="$finalize_var$finalize_command$finalize_rpath" + fi + fi + + # Replace the output file specification. + link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` + + # Delete the old output files. + $run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname + + $show "$link_command" + $run eval "$link_command" || exit $? + + # Now create the wrapper script. + $show "creating $output" + + # Quote the relink command for shipping. + if test -n "$relink_command"; then + relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"` + fi + + # Quote $echo for shipping. + if test "X$echo" = "X$SHELL $0 --fallback-echo"; then + case "$0" in + [\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $0 --fallback-echo";; + *) qecho="$SHELL `pwd`/$0 --fallback-echo";; + esac + qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"` + else + qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"` + fi + + # Only actually do things if our run command is non-null. + if test -z "$run"; then + # win32 will think the script is a binary if it has + # a .exe suffix, so we strip it off here. + case $output in + *.exe) output=`echo $output|sed 's,.exe$,,'` ;; + esac + $rm $output + trap "$rm $output; exit 1" 1 2 15 + + $echo > $output "\ +#! $SHELL + +# $output - temporary wrapper script for $objdir/$outputname +# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP +# +# The $output program cannot be directly executed until all the libtool +# libraries that it depends on are installed. +# +# This wrapper script should never be moved out of the build directory. +# If it is, it will not operate correctly. + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +Xsed='sed -e 1s/^X//' +sed_quote_subst='$sed_quote_subst' + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +if test \"\${CDPATH+set}\" = set; then CDPATH=:; export CDPATH; fi + +relink_command=\"$relink_command\" + +# This environment variable determines our operation mode. +if test \"\$libtool_install_magic\" = \"$magic\"; then + # install mode needs the following variable: + link_against_libtool_libs='$link_against_libtool_libs' +else + # When we are sourced in execute mode, \$file and \$echo are already set. + if test \"\$libtool_execute_magic\" != \"$magic\"; then + echo=\"$qecho\" + file=\"\$0\" + # Make sure echo works. + if test \"X\$1\" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift + elif test \"X\`(\$echo '\t') 2>/dev/null\`\" = 'X\t'; then + # Yippee, \$echo works! + : + else + # Restart under the correct shell, and then maybe \$echo will work. + exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"} + fi + fi\ +" + $echo >> $output "\ + + # Find the directory that this script lives in. + thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\` + test \"x\$thisdir\" = \"x\$file\" && thisdir=. + + # Follow symbolic links until we get to the real thisdir. + file=\`ls -ld \"\$file\" | sed -n 's/.*-> //p'\` + while test -n \"\$file\"; do + destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\` + + # If there was a directory component, then change thisdir. + if test \"x\$destdir\" != \"x\$file\"; then + case \"\$destdir\" in + [\\/]* | [A-Za-z]:[\\/]*) thisdir=\"\$destdir\" ;; + *) thisdir=\"\$thisdir/\$destdir\" ;; + esac + fi + + file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\` + file=\`ls -ld \"\$thisdir/\$file\" | sed -n 's/.*-> //p'\` + done + + # Try to get the absolute directory name. + absdir=\`cd \"\$thisdir\" && pwd\` + test -n \"\$absdir\" && thisdir=\"\$absdir\" +" + + if test "$fast_install" = yes; then + echo >> $output "\ + program=lt-'$outputname' + progdir=\"\$thisdir/$objdir\" + + if test ! -f \"\$progdir/\$program\" || \\ + { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | sed 1q\`; \\ + test \"X\$file\" != \"X\$progdir/\$program\"; }; then + + file=\"\$\$-\$program\" + + if test ! -d \"\$progdir\"; then + $mkdir \"\$progdir\" + else + $rm \"\$progdir/\$file\" + fi" + + echo >> $output "\ + + # relink executable if necessary + if test -n \"\$relink_command\"; then + if (cd \"\$thisdir\" && eval \$relink_command); then : + else + $rm \"\$progdir/\$file\" + exit 1 + fi + fi + + $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || + { $rm \"\$progdir/\$program\"; + $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; } + $rm \"\$progdir/\$file\" + fi" + else + echo >> $output "\ + program='$outputname' + progdir=\"\$thisdir/$objdir\" +" + fi + + echo >> $output "\ + + if test -f \"\$progdir/\$program\"; then" + + # Export our shlibpath_var if we have one. + if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then + $echo >> $output "\ + # Add our own library path to $shlibpath_var + $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" + + # Some systems cannot cope with colon-terminated $shlibpath_var + # The second colon is a workaround for a bug in BeOS R4 sed + $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\` + + export $shlibpath_var +" + fi + + # fixup the dll searchpath if we need to. + if test -n "$dllsearchpath"; then + $echo >> $output "\ + # Add the dll search path components to the executable PATH + PATH=$dllsearchpath:\$PATH +" + fi + + $echo >> $output "\ + if test \"\$libtool_execute_magic\" != \"$magic\"; then + # Run the actual program with our arguments. +" + case $host in + # win32 systems need to use the prog path for dll + # lookup to work + *-*-cygwin*) + $echo >> $output "\ + exec \$progdir/\$program \${1+\"\$@\"} +" + ;; + + # Backslashes separate directories on plain windows + *-*-mingw | *-*-os2*) + $echo >> $output "\ + exec \$progdir\\\\\$program \${1+\"\$@\"} +" + ;; + + *) + $echo >> $output "\ + # Export the path to the program. + PATH=\"\$progdir:\$PATH\" + export PATH + + exec \$program \${1+\"\$@\"} +" + ;; + esac + $echo >> $output "\ + \$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\" + exit 1 + fi + else + # The program doesn't exist. + \$echo \"\$0: error: \$progdir/\$program does not exist\" 1>&2 + \$echo \"This script is just a wrapper for \$program.\" 1>&2 + echo \"See the $PACKAGE documentation for more information.\" 1>&2 + exit 1 + fi +fi\ +" + chmod +x $output + fi + exit 0 + ;; + esac + + # See if we need to build an old-fashioned archive. + for oldlib in $oldlibs; do + + if test "$build_libtool_libs" = convenience; then + oldobjs="$libobjs_save" + addlibs="$convenience" + build_libtool_libs=no + else + if test "$build_libtool_libs" = module; then + oldobjs="$libobjs_save" + build_libtool_libs=no + else + oldobjs="$objs "`$echo "X$libobjs_save" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP` + fi + addlibs="$old_convenience" + fi + + if test -n "$addlibs"; then + gentop="$output_objdir/${outputname}x" + $show "${rm}r $gentop" + $run ${rm}r "$gentop" + $show "mkdir $gentop" + $run mkdir "$gentop" + status=$? + if test $status -ne 0 && test ! -d "$gentop"; then + exit $status + fi + generated="$generated $gentop" + + # Add in members from convenience archives. + for xlib in $addlibs; do + # Extract the objects. + case "$xlib" in + [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;; + *) xabs=`pwd`"/$xlib" ;; + esac + xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'` + xdir="$gentop/$xlib" + + $show "${rm}r $xdir" + $run ${rm}r "$xdir" + $show "mkdir $xdir" + $run mkdir "$xdir" + status=$? + if test $status -ne 0 && test ! -d "$xdir"; then + exit $status + fi + $show "(cd $xdir && $AR x $xabs)" + $run eval "(cd \$xdir && $AR x \$xabs)" || exit $? + + oldobjs="$oldobjs "`find $xdir -name \*.${objext} -print -o -name \*.lo -print | $NL2SP` + done + fi + + # Do each command in the archive commands. + if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then + eval cmds=\"$old_archive_from_new_cmds\" + else + # Ensure that we have .o objects in place in case we decided + # not to build a shared library, and have fallen back to building + # static libs even though --disable-static was passed! + for oldobj in $oldobjs; do + if test ! -f $oldobj; then + xdir=`$echo "X$oldobj" | $Xsed -e 's%/[^/]*$%%'` + if test "X$xdir" = "X$oldobj"; then + xdir="." + else + xdir="$xdir" + fi + baseobj=`$echo "X$oldobj" | $Xsed -e 's%^.*/%%'` + obj=`$echo "X$baseobj" | $Xsed -e "$o2lo"` + $show "(cd $xdir && ${LN_S} $obj $baseobj)" + $run eval '(cd $xdir && ${LN_S} $obj $baseobj)' || exit $? + fi + done + + eval cmds=\"$old_archive_cmds\" + fi + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + done + + if test -n "$generated"; then + $show "${rm}r$generated" + $run ${rm}r$generated + fi + + # Now create the libtool archive. + case "$output" in + *.la) + old_library= + test "$build_old_libs" = yes && old_library="$libname.$libext" + $show "creating $output" + + if test -n "$xrpath"; then + temp_xrpath= + for libdir in $xrpath; do + temp_xrpath="$temp_xrpath -R$libdir" + done + dependency_libs="$temp_xrpath $dependency_libs" + fi + + # Only create the output if not a dry run. + if test -z "$run"; then + for installed in no yes; do + if test "$installed" = yes; then + if test -z "$install_libdir"; then + break + fi + output="$output_objdir/$outputname"i + fi + $rm $output + $echo > $output "\ +# $outputname - a libtool library file +# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# The name that we can dlopen(3). +dlname='$dlname' + +# Names of this library. +library_names='$library_names' + +# The name of the static archive. +old_library='$old_library' + +# Libraries that this one depends upon. +dependency_libs='$dependency_libs' + +# Version information for $libname. +current=$current +age=$age +revision=$revision + +# Is this an already installed library? +installed=$installed + +# Directory that this library needs to be installed in: +libdir='$install_libdir'\ +" + done + fi + + # Do a symbolic link so that the libtool archive can be found in + # LD_LIBRARY_PATH before the program is installed. + $show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)" + $run eval "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)" || exit $? + ;; + esac + exit 0 + ;; + + # libtool install mode + install) + modename="$modename: install" + + # There may be an optional sh(1) argument at the beginning of + # install_prog (especially on Windows NT). + if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh; then + # Aesthetically quote it. + arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"` + case "$arg" in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) + arg="\"$arg\"" + ;; + esac + install_prog="$arg " + arg="$1" + shift + else + install_prog= + arg="$nonopt" + fi + + # The real first argument should be the name of the installation program. + # Aesthetically quote it. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case "$arg" in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) + arg="\"$arg\"" + ;; + esac + install_prog="$install_prog$arg" + + # We need to accept at least all the BSD install flags. + dest= + files= + opts= + prev= + install_type= + isdir=no + stripme= + for arg + do + if test -n "$dest"; then + files="$files $dest" + dest="$arg" + continue + fi + + case "$arg" in + -d) isdir=yes ;; + -f) prev="-f" ;; + -g) prev="-g" ;; + -m) prev="-m" ;; + -o) prev="-o" ;; + -s) + stripme=" -s" + continue + ;; + -*) ;; + + *) + # If the previous option needed an argument, then skip it. + if test -n "$prev"; then + prev= + else + dest="$arg" + continue + fi + ;; + esac + + # Aesthetically quote the argument. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case "$arg" in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) + arg="\"$arg\"" + ;; + esac + install_prog="$install_prog $arg" + done + + if test -z "$install_prog"; then + $echo "$modename: you must specify an install program" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + if test -n "$prev"; then + $echo "$modename: the \`$prev' option requires an argument" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + if test -z "$files"; then + if test -z "$dest"; then + $echo "$modename: no file or destination specified" 1>&2 + else + $echo "$modename: you must specify a destination" 1>&2 + fi + $echo "$help" 1>&2 + exit 1 + fi + + # Strip any trailing slash from the destination. + dest=`$echo "X$dest" | $Xsed -e 's%/$%%'` + + # Check to see that the destination is a directory. + test -d "$dest" && isdir=yes + if test "$isdir" = yes; then + destdir="$dest" + destname= + else + destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'` + test "X$destdir" = "X$dest" && destdir=. + destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'` + + # Not a directory, so check to see that there is only one file specified. + set dummy $files + if test $# -gt 2; then + $echo "$modename: \`$dest' is not a directory" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + fi + case "$destdir" in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + for file in $files; do + case "$file" in + *.lo) ;; + *) + $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2 + $echo "$help" 1>&2 + exit 1 + ;; + esac + done + ;; + esac + + # This variable tells wrapper scripts just to set variables rather + # than running their programs. + libtool_install_magic="$magic" + + staticlibs= + future_libdirs= + current_libdirs= + for file in $files; do + + # Do each installation. + case "$file" in + *.a | *.lib) + # Do the static libraries later. + staticlibs="$staticlibs $file" + ;; + + *.la) + # Check to see that this really is a libtool archive. + if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : + else + $echo "$modename: \`$file' is not a valid libtool archive" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + library_names= + old_library= + # If there is no directory component, then add one. + case "$file" in + */* | *\\*) . $file ;; + *) . ./$file ;; + esac + + # Add the libdir to current_libdirs if it is the destination. + if test "X$destdir" = "X$libdir"; then + case "$current_libdirs " in + *" $libdir "*) ;; + *) current_libdirs="$current_libdirs $libdir" ;; + esac + else + # Note the libdir as a future libdir. + case "$future_libdirs " in + *" $libdir "*) ;; + *) future_libdirs="$future_libdirs $libdir" ;; + esac + fi + + dir="`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/" + test "X$dir" = "X$file/" && dir= + dir="$dir$objdir" + + # See the names of the shared library. + set dummy $library_names + if test -n "$2"; then + realname="$2" + shift + shift + + # Install the shared library and build the symlinks. + $show "$install_prog $dir/$realname $destdir/$realname" + $run eval "$install_prog $dir/$realname $destdir/$realname" || exit $? + + if test $# -gt 0; then + # Delete the old symlinks, and create new ones. + for linkname + do + if test "$linkname" != "$realname"; then + $show "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)" + $run eval "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)" + fi + done + fi + + # Do each command in the postinstall commands. + lib="$destdir/$realname" + eval cmds=\"$postinstall_cmds\" + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + fi + + # Install the pseudo-library for information purposes. + name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + instname="$dir/$name"i + $show "$install_prog $instname $destdir/$name" + $run eval "$install_prog $instname $destdir/$name" || exit $? + + # Maybe install the static library, too. + test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library" + ;; + + *.lo) + # Install (i.e. copy) a libtool object. + + # Figure out destination file name, if it wasn't already specified. + if test -n "$destname"; then + destfile="$destdir/$destname" + else + destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + destfile="$destdir/$destfile" + fi + + # Deduce the name of the destination old-style object file. + case "$destfile" in + *.lo) + staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"` + ;; + *.o | *.obj) + staticdest="$destfile" + destfile= + ;; + *) + $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2 + $echo "$help" 1>&2 + exit 1 + ;; + esac + + # Install the libtool object if requested. + if test -n "$destfile"; then + $show "$install_prog $file $destfile" + $run eval "$install_prog $file $destfile" || exit $? + fi + + # Install the old object if enabled. + if test "$build_old_libs" = yes; then + # Deduce the name of the old-style object file. + staticobj=`$echo "X$file" | $Xsed -e "$lo2o"` + + $show "$install_prog $staticobj $staticdest" + $run eval "$install_prog \$staticobj \$staticdest" || exit $? + fi + exit 0 + ;; + + *) + # Figure out destination file name, if it wasn't already specified. + if test -n "$destname"; then + destfile="$destdir/$destname" + else + destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + destfile="$destdir/$destfile" + fi + + # Do a test to see if this is really a libtool program. + if (sed -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + link_against_libtool_libs= + relink_command= + + # If there is no directory component, then add one. + case "$file" in + */* | *\\*) . $file ;; + *) . ./$file ;; + esac + + # Check the variables that should have been set. + if test -z "$link_against_libtool_libs"; then + $echo "$modename: invalid libtool wrapper script \`$file'" 1>&2 + exit 1 + fi + + finalize=yes + for lib in $link_against_libtool_libs; do + # Check to see that each library is installed. + libdir= + if test -f "$lib"; then + # If there is no directory component, then add one. + case "$lib" in + */* | *\\*) . $lib ;; + *) . ./$lib ;; + esac + fi + libfile="$libdir/`$echo "X$lib" | $Xsed -e 's%^.*/%%g'`" + if test -n "$libdir" && test ! -f "$libfile"; then + $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2 + finalize=no + fi + done + + outputname= + if test "$fast_install" = no && test -n "$relink_command"; then + if test "$finalize" = yes && test -z "$run"; then + tmpdir="/tmp" + test -n "$TMPDIR" && tmpdir="$TMPDIR" + tmpdir="$tmpdir/libtool-$$" + if $mkdir -p "$tmpdir" && chmod 700 "$tmpdir"; then : + else + $echo "$modename: error: cannot create temporary directory \`$tmpdir'" 1>&2 + continue + fi + outputname="$tmpdir/$file" + # Replace the output file specification. + relink_command=`$echo "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'` + + $show "$relink_command" + if $run eval "$relink_command"; then : + else + $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2 + ${rm}r "$tmpdir" + continue + fi + file="$outputname" + else + $echo "$modename: warning: cannot relink \`$file'" 1>&2 + fi + else + # Install the binary that we compiled earlier. + file=`$echo "X$file" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"` + fi + fi + + $show "$install_prog$stripme $file $destfile" + $run eval "$install_prog\$stripme \$file \$destfile" || exit $? + test -n "$outputname" && ${rm}r "$tmpdir" + ;; + esac + done + + for file in $staticlibs; do + name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + + # Set up the ranlib parameters. + oldlib="$destdir/$name" + + $show "$install_prog $file $oldlib" + $run eval "$install_prog \$file \$oldlib" || exit $? + + # Do each command in the postinstall commands. + eval cmds=\"$old_postinstall_cmds\" + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + done + + if test -n "$future_libdirs"; then + $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2 + fi + + if test -n "$current_libdirs"; then + # Maybe just do a dry run. + test -n "$run" && current_libdirs=" -n$current_libdirs" + exec $SHELL $0 --finish$current_libdirs + exit 1 + fi + + exit 0 + ;; + + # libtool finish mode + finish) + modename="$modename: finish" + libdirs="$nonopt" + admincmds= + + if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then + for dir + do + libdirs="$libdirs $dir" + done + + for libdir in $libdirs; do + if test -n "$finish_cmds"; then + # Do each command in the finish commands. + eval cmds=\"$finish_cmds\" + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || admincmds="$admincmds + $cmd" + done + IFS="$save_ifs" + fi + if test -n "$finish_eval"; then + # Do the single finish_eval. + eval cmds=\"$finish_eval\" + $run eval "$cmds" || admincmds="$admincmds + $cmds" + fi + done + fi + + # Exit here if they wanted silent mode. + test "$show" = : && exit 0 + + echo "----------------------------------------------------------------------" + echo "Libraries have been installed in:" + for libdir in $libdirs; do + echo " $libdir" + done + echo + echo "If you ever happen to want to link against installed libraries" + echo "in a given directory, LIBDIR, you must either use libtool, and" + echo "specify the full pathname of the library, or use \`-LLIBDIR'" + echo "flag during linking and do at least one of the following:" + if test -n "$shlibpath_var"; then + echo " - add LIBDIR to the \`$shlibpath_var' environment variable" + echo " during execution" + fi + if test -n "$runpath_var"; then + echo " - add LIBDIR to the \`$runpath_var' environment variable" + echo " during linking" + fi + if test -n "$hardcode_libdir_flag_spec"; then + libdir=LIBDIR + eval flag=\"$hardcode_libdir_flag_spec\" + + echo " - use the \`$flag' linker flag" + fi + if test -n "$admincmds"; then + echo " - have your system administrator run these commands:$admincmds" + fi + if test -f /etc/ld.so.conf; then + echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" + fi + echo + echo "See any operating system documentation about shared libraries for" + echo "more information, such as the ld(1) and ld.so(8) manual pages." + echo "----------------------------------------------------------------------" + exit 0 + ;; + + # libtool execute mode + execute) + modename="$modename: execute" + + # The first argument is the command name. + cmd="$nonopt" + if test -z "$cmd"; then + $echo "$modename: you must specify a COMMAND" 1>&2 + $echo "$help" + exit 1 + fi + + # Handle -dlopen flags immediately. + for file in $execute_dlfiles; do + if test ! -f "$file"; then + $echo "$modename: \`$file' is not a file" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + dir= + case "$file" in + *.la) + # Check to see that this really is a libtool archive. + if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : + else + $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + # Read the libtool library. + dlname= + library_names= + + # If there is no directory component, then add one. + case "$file" in + */* | *\\*) . $file ;; + *) . ./$file ;; + esac + + # Skip this library if it cannot be dlopened. + if test -z "$dlname"; then + # Warn if it was a shared library. + test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'" + continue + fi + + dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + test "X$dir" = "X$file" && dir=. + + if test -f "$dir/$objdir/$dlname"; then + dir="$dir/$objdir" + else + $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2 + exit 1 + fi + ;; + + *.lo) + # Just add the directory containing the .lo file. + dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + test "X$dir" = "X$file" && dir=. + ;; + + *) + $echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2 + continue + ;; + esac + + # Get the absolute pathname. + absdir=`cd "$dir" && pwd` + test -n "$absdir" && dir="$absdir" + + # Now add the directory to shlibpath_var. + if eval "test -z \"\$$shlibpath_var\""; then + eval "$shlibpath_var=\"\$dir\"" + else + eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" + fi + done + + # This variable tells wrapper scripts just to set shlibpath_var + # rather than running their programs. + libtool_execute_magic="$magic" + + # Check if any of the arguments is a wrapper script. + args= + for file + do + case "$file" in + -*) ;; + *) + # Do a test to see if this is really a libtool program. + if (sed -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + # If there is no directory component, then add one. + case "$file" in + */* | *\\*) . $file ;; + *) . ./$file ;; + esac + + # Transform arg to wrapped name. + file="$progdir/$program" + fi + ;; + esac + # Quote arguments (to preserve shell metacharacters). + file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"` + args="$args \"$file\"" + done + + if test -z "$run"; then + if test -n "$shlibpath_var"; then + # Export the shlibpath_var. + eval "export $shlibpath_var" + fi + + # Restore saved enviroment variables + if test "${save_LC_ALL+set}" = set; then + LC_ALL="$save_LC_ALL"; export LC_ALL + fi + if test "${save_LANG+set}" = set; then + LANG="$save_LANG"; export LANG + fi + + # Now actually exec the command. + eval "exec \$cmd$args" + + $echo "$modename: cannot exec \$cmd$args" + exit 1 + else + # Display what would be done. + if test -n "$shlibpath_var"; then + eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\"" + $echo "export $shlibpath_var" + fi + $echo "$cmd$args" + exit 0 + fi + ;; + + # libtool uninstall mode + uninstall) + modename="$modename: uninstall" + rm="$nonopt" + files= + + for arg + do + case "$arg" in + -*) rm="$rm $arg" ;; + *) files="$files $arg" ;; + esac + done + + if test -z "$rm"; then + $echo "$modename: you must specify an RM program" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + for file in $files; do + dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + test "X$dir" = "X$file" && dir=. + name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + + rmfiles="$file" + + case "$name" in + *.la) + # Possibly a libtool archive, so verify it. + if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + . $dir/$name + + # Delete the libtool libraries and symlinks. + for n in $library_names; do + rmfiles="$rmfiles $dir/$n" + done + test -n "$old_library" && rmfiles="$rmfiles $dir/$old_library" + + $show "$rm $rmfiles" + $run $rm $rmfiles + + if test -n "$library_names"; then + # Do each command in the postuninstall commands. + eval cmds=\"$postuninstall_cmds\" + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" + done + IFS="$save_ifs" + fi + + if test -n "$old_library"; then + # Do each command in the old_postuninstall commands. + eval cmds=\"$old_postuninstall_cmds\" + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" + done + IFS="$save_ifs" + fi + + # FIXME: should reinstall the best remaining shared library. + fi + ;; + + *.lo) + if test "$build_old_libs" = yes; then + oldobj=`$echo "X$name" | $Xsed -e "$lo2o"` + rmfiles="$rmfiles $dir/$oldobj" + fi + $show "$rm $rmfiles" + $run $rm $rmfiles + ;; + + *) + $show "$rm $rmfiles" + $run $rm $rmfiles + ;; + esac + done + exit 0 + ;; + + "") + $echo "$modename: you must specify a MODE" 1>&2 + $echo "$generic_help" 1>&2 + exit 1 + ;; + esac + + $echo "$modename: invalid operation mode \`$mode'" 1>&2 + $echo "$generic_help" 1>&2 + exit 1 +fi # test -z "$show_help" + +# We need to display help for each of the modes. +case "$mode" in +"") $echo \ +"Usage: $modename [OPTION]... [MODE-ARG]... + +Provide generalized library-building support services. + + --config show all configuration variables + --debug enable verbose shell tracing +-n, --dry-run display commands without modifying any files + --features display basic configuration information and exit + --finish same as \`--mode=finish' + --help display this help message and exit + --mode=MODE use operation mode MODE [default=inferred from MODE-ARGS] + --quiet same as \`--silent' + --silent don't print informational messages + --version print version information + +MODE must be one of the following: + + compile compile a source file into a libtool object + execute automatically set library path, then run a program + finish complete the installation of libtool libraries + install install libraries or executables + link create a library or an executable + uninstall remove libraries from an installed directory + +MODE-ARGS vary depending on the MODE. Try \`$modename --help --mode=MODE' for +a more detailed description of MODE." + exit 0 + ;; + +compile) + $echo \ +"Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE + +Compile a source file into a libtool library object. + +This mode accepts the following additional options: + + -o OUTPUT-FILE set the output file name to OUTPUT-FILE + -static always build a \`.o' file suitable for static linking + +COMPILE-COMMAND is a command to be used in creating a \`standard' object file +from the given SOURCEFILE. + +The output file name is determined by removing the directory component from +SOURCEFILE, then substituting the C source code suffix \`.c' with the +library object suffix, \`.lo'." + ;; + +execute) + $echo \ +"Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]... + +Automatically set library path, then run a program. + +This mode accepts the following additional options: + + -dlopen FILE add the directory containing FILE to the library path + +This mode sets the library path environment variable according to \`-dlopen' +flags. + +If any of the ARGS are libtool executable wrappers, then they are translated +into their corresponding uninstalled binary, and any of their required library +directories are added to the library path. + +Then, COMMAND is executed, with ARGS as arguments." + ;; + +finish) + $echo \ +"Usage: $modename [OPTION]... --mode=finish [LIBDIR]... + +Complete the installation of libtool libraries. + +Each LIBDIR is a directory that contains libtool libraries. + +The commands that this mode executes may require superuser privileges. Use +the \`--dry-run' option if you just want to see what would be executed." + ;; + +install) + $echo \ +"Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND... + +Install executables or libraries. + +INSTALL-COMMAND is the installation command. The first component should be +either the \`install' or \`cp' program. + +The rest of the components are interpreted as arguments to that command (only +BSD-compatible install options are recognized)." + ;; + +link) + $echo \ +"Usage: $modename [OPTION]... --mode=link LINK-COMMAND... + +Link object files or libraries together to form another library, or to +create an executable program. + +LINK-COMMAND is a command using the C compiler that you would use to create +a program from several object files. + +The following components of LINK-COMMAND are treated specially: + + -all-static do not do any dynamic linking at all + -avoid-version do not add a version suffix if possible + -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime + -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols + -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) + -export-symbols SYMFILE + try to export only the symbols listed in SYMFILE + -export-symbols-regex REGEX + try to export only the symbols matching REGEX + -LLIBDIR search LIBDIR for required installed libraries + -lNAME OUTPUT-FILE requires the installed library libNAME + -module build a library that can dlopened + -no-undefined declare that a library does not refer to external symbols + -o OUTPUT-FILE create OUTPUT-FILE from the specified objects + -release RELEASE specify package release information + -rpath LIBDIR the created library will eventually be installed in LIBDIR + -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries + -static do not do any dynamic linking of libtool libraries + -version-info CURRENT[:REVISION[:AGE]] + specify library version info [each variable defaults to 0] + +All other options (arguments beginning with \`-') are ignored. + +Every other argument is treated as a filename. Files ending in \`.la' are +treated as uninstalled libtool libraries, other files are standard or library +object files. + +If the OUTPUT-FILE ends in \`.la', then a libtool library is created, +only library objects (\`.lo' files) may be specified, and \`-rpath' is +required, except when creating a convenience library. + +If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created +using \`ar' and \`ranlib', or on Windows using \`lib'. + +If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file +is created, otherwise an executable program is created." + ;; + +uninstall) + $echo \ +"Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... + +Remove libraries from an installation directory. + +RM is the name of the program to use to delete files associated with each FILE +(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed +to RM. + +If FILE is a libtool library, all the files associated with it are deleted. +Otherwise, only FILE itself is deleted using RM." + ;; + +*) + $echo "$modename: invalid operation mode \`$mode'" 1>&2 + $echo "$help" 1>&2 + exit 1 + ;; +esac + +echo +$echo "Try \`$modename --help' for more information about other modes." + +exit 0 + +# Local Variables: +# mode:shell-script +# sh-indentation:2 +# End: diff --git a/contrib/idn/mdnkit/man/Makefile.in b/contrib/idn/mdnkit/man/Makefile.in new file mode 100644 index 0000000000..5ceb6fa961 --- /dev/null +++ b/contrib/idn/mdnkit/man/Makefile.in @@ -0,0 +1,90 @@ +# $Id: Makefile.in,v 1.1 2000/09/08 03:17:31 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. + +top_builddir = .. + +srcdir = @srcdir@ +VPATH = @srcdir@ + +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +ETCDIR = @sysconfdir@ +MANDIR = @mandir@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ + +GEN_FILES = mdnres.conf.5 +MAN5 = mdnres.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 + +mdnres.conf.5: mdnres.conf.5.in + sed 's%@ETCDIR@%$(ETCDIR)%' < $(srcdir)/mdnres.conf.5.in > $@ + +clean: + rm -f *~ $(GEN_FILES) diff --git a/contrib/idn/mdnkit/man/mdnres.conf.5.in b/contrib/idn/mdnkit/man/mdnres.conf.5.in new file mode 100644 index 0000000000..b4924b3489 --- /dev/null +++ b/contrib/idn/mdnkit/man/mdnres.conf.5.in @@ -0,0 +1,296 @@ +.\" $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/patch/bind9/patch.most b/contrib/idn/mdnkit/patch/bind9/patch.most new file mode 100644 index 0000000000..20a171a735 --- /dev/null +++ b/contrib/idn/mdnkit/patch/bind9/patch.most @@ -0,0 +1,2173 @@ +--- ./README.mdnkit.orig Fri Dec 1 16:47:34 2000 ++++ ./README.mdnkit Fri Dec 1 16:47:34 2000 +@@ -0,0 +1,110 @@ ++ ++ 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 light weight resolver and ++dig/host/nslookup commands. ++ ++ + multilingualized version of light weight resolver ++ The following APIs accept non-ASCII host name encoded in the ++ local codeset (such as Shift JIS, Big5 or ISO8859-1) ++ determined by the application's current locale, and return ++ host names in the local codeset. ++ lwres_gethostbyname ++ lwres_gethostbyname_r ++ lwres_gethostbyname2 ++ lwres_getipnodebyname ++ lwres_getaddrinfo ++ lwres_gethostbyaddr ++ lwres_gethostbyaddr_r ++ lwres_getipnodebyaddr ++ lwres_getnameinfo ++ ++ + mulltilingualized dig/host/nslookup ++ dig/host/nslookup accepts non-ASCII domain names in the local ++ codeset. 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 schemes ++These properties are specified by the mDNkit's resolver configuration ++file, "mdnres.conf". You have to create and set up the file properly. ++The pathname of the file and contents are described in the manual ++"mdnres.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: README.mdnkit,v 1.5 2000/10/18 04:54:57 ishisone Exp $ +--- ./acconfig.h.orig Fri Dec 1 16:47:10 2000 ++++ ./acconfig.h Fri Dec 1 16:47:34 2000 +@@ -110,4 +110,7 @@ + #endif /* SHUTUP_STDARG_CAST && __GNUC__ */ + ++/* define if mDNkit support is to be included. */ ++#undef WITH_MDN ++ + /* define if the system has a random number generating device */ + #undef PATH_RANDOMDEV +--- ./config.h.in.orig Fri Dec 1 16:47:33 2000 ++++ ./config.h.in Fri Dec 1 16:47:34 2000 +@@ -124,4 +124,10 @@ + #undef PATH_RANDOMDEV + ++/* define if mDNkit support is to be included. */ ++#undef WITH_MDN ++ ++/* Define if you have the setlocale function. */ ++#undef HAVE_SETLOCALE ++ + /* Define if you have the header file. */ + #undef HAVE_FCNTL_H +@@ -132,4 +138,7 @@ + /* Define if you have the header file. */ + #undef HAVE_LINUX_PRCTL_H ++ ++/* Define if you have the header file. */ ++#undef HAVE_LOCALE_H + + /* Define if you have the header file. */ +--- ./configure.in.orig Fri Dec 1 16:47:34 2000 ++++ ./configure.in Fri Dec 1 16:47:34 2000 +@@ -1159,4 +1159,52 @@ + + # ++# 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) ++ 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 + # +--- ./lib/dns/config/confctx.c.orig Fri Dec 1 16:46:16 2000 ++++ ./lib/dns/config/confctx.c Fri Dec 1 16:47:34 2000 +@@ -1003,4 +1003,7 @@ + PRINT_AS_BOOLEAN(maintain_ixfr_base, "maintain-ixfr-base"); + PRINT_AS_BOOLEAN(has_old_clients, "has-old-clients"); ++#ifdef WITH_MDN ++ PRINT_AS_BOOLEAN(allow_utf8, "allow-utf8"); ++#endif + PRINT_AS_BOOLEAN(auth_nx_domain, "auth-nxdomain"); + PRINT_AS_BOOLEAN(multiple_cnames, "multiple-cnames"); +@@ -1537,4 +1540,7 @@ + opts->maintain_ixfr_base = NULL; + opts->has_old_clients = NULL; ++#ifdef WITH_MDN ++ opts->allow_utf8 = NULL; ++#endif + opts->auth_nx_domain = NULL; + opts->multiple_cnames = NULL; +@@ -1649,4 +1655,7 @@ + FREEFIELD(maintain_ixfr_base); + FREEFIELD(has_old_clients); ++#ifdef WITH_MDN ++ FREEFIELD(allow_utf8); ++#endif + FREEFIELD(auth_nx_domain); + FREEFIELD(multiple_cnames); +@@ -1825,4 +1834,7 @@ + BOOL_FUNCS(maintainixfrbase, maintain_ixfr_base) + BOOL_FUNCS(hasoldclients, has_old_clients) ++#ifdef WITH_MDN ++BOOL_FUNCS(allowutf8, allow_utf8) ++#endif + BOOL_FUNCS(authnxdomain, auth_nx_domain) + BOOL_FUNCS(multiplecnames, multiple_cnames) +--- ./lib/dns/config/confparser.y.orig Fri Dec 1 17:13:00 2000 ++++ ./lib/dns/config/confparser.y Fri Dec 1 17:16:36 2000 +@@ -269,4 +269,5 @@ + %token L_ALLOW_UPDATE + %token L_ALLOW_UPDATE_FORWARDING ++%token L_ALLOW_UTF8 + %token L_ALSO_NOTIFY + %token L_AUTH_NXDOMAIN +@@ -1677,4 +1678,19 @@ + } + } ++ | L_ALLOW_UTF8 yea_or_nay ++ { ++#ifdef WITH_MDN ++ tmpres = dns_c_ctx_setallowutf8(currcfg, $2); ++ if (tmpres == ISC_R_EXISTS) { ++ parser_error(ISC_FALSE, ++ "cannot redefine allow-utf8"); ++ YYABORT; ++ } ++#else ++ parser_error(ISC_FALSE, "must be configured with MDN" ++ "to use allow-utf8"); ++ YYABORT; ++#endif ++ } + | L_ADDITIONAL_DATA additional_data + { +@@ -5949,4 +5965,7 @@ + { "allow-update", L_ALLOW_UPDATE }, + { "allow-update-forwarding", L_ALLOW_UPDATE_FORWARDING }, ++#ifdef WITH_MDN ++ { "allow-utf8", L_ALLOW_UTF8 }, ++#endif + { "also-notify", L_ALSO_NOTIFY }, + { "auth-nxdomain", L_AUTH_NXDOMAIN }, +--- ./lib/dns/include/dns/confctx.h.orig Fri Dec 1 16:45:40 2000 ++++ ./lib/dns/include/dns/confctx.h Fri Dec 1 16:47:35 2000 +@@ -185,4 +185,7 @@ + isc_sockaddr_t *transfer_source_v6; + isc_sockaddr_t *query_source; ++#ifdef WITH_MDN ++ isc_boolean_t *allow_utf8; ++#endif + isc_sockaddr_t *query_source_v6; + +@@ -625,4 +628,11 @@ + isc_result_t dns_c_ctx_gettreatcrasspace(dns_c_ctx_t *cfg, + isc_boolean_t *retval); ++#ifdef WITH_MDN ++isc_result_t dns_c_ctx_setallowutf8(dns_c_ctx_t *cfg, ++ isc_boolean_t newval); ++isc_result_t dns_c_ctx_getallowutf8(dns_c_ctx_t *cfg, ++ isc_boolean_t *retval); ++isc_result_t dns_c_ctx_unsetallowutf8(dns_c_ctx_t *cfg); ++#endif + + +--- ./lib/dns/include/dns/name.h.orig Fri Dec 1 16:45:32 2000 ++++ ./lib/dns/include/dns/name.h Fri Dec 1 16:47:35 2000 +@@ -220,4 +220,15 @@ + #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 +@@ -1219,4 +1230,24 @@ + * + */ ++ ++#ifdef WITH_MDN ++void ++dns_name_allowutf8(isc_boolean_t allowutf8); ++/* ++ * If 'allowutf8' is true, UTF-8 characters are not translated into ++ * backslash escape format (\DDD) by dns_name_totext(). ++ * ++ * XXX: ++ * Setting this modifies the global state. Maybe there should be ++ * a way to set this for each name. ++ */ ++ ++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) +--- ./lib/dns/name.c.orig Fri Dec 1 16:46:51 2000 ++++ ./lib/dns/name.c Fri Dec 1 16:47:35 2000 +@@ -32,4 +32,8 @@ + #include + ++#ifdef WITH_MDN ++#include ++#endif ++ + #define VALID_NAME(n) ISC_MAGIC_VALID(n, DNS_NAME_MAGIC) + +@@ -206,4 +210,17 @@ + dns_name_t *dns_wildcardname = &wild.name; + ++#ifdef WITH_MDN ++/* ++ * If this flag is true, dns_name_totext() copies UTF-8 characters ++ * as is (ie not backslash-escaped form). ++ */ ++static isc_boolean_t allow_utf8 = ISC_FALSE; ++ ++/* ++ * 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, +@@ -1707,4 +1724,8 @@ + isc_boolean_t saw_root = ISC_FALSE; + char num[4]; ++#ifdef WITH_MDN ++ unsigned int oused = target->used; ++ int u8len; ++#endif + + /* +@@ -1802,4 +1823,18 @@ + trem--; + nlen--; ++#ifdef WITH_MDN ++ } else if (c >= 0x80 && ++ allow_utf8 && ++ (u8len = ++ mdn_utf8_isvalidchar(ndata)) ++ > 0 && ++ u8len <= trem) { ++ memcpy(tdata, ndata, u8len); ++ ndata += u8len; ++ tdata += u8len; ++ trem -= u8len; ++ nlen -= u8len; ++ count -= u8len - 1; ++#endif + } else { + if (trem < 4) +@@ -1883,4 +1918,8 @@ + 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); + } +@@ -3169,2 +3208,14 @@ + snprintf(cp, size, ""); + } ++ ++#ifdef WITH_MDN ++void ++dns_name_allowutf8(isc_boolean_t allowutf8) { ++ allow_utf8 = allowutf8; ++} ++ ++void ++dns_name_settotextfilter(dns_name_totextfilter_t proc) { ++ totext_filter_proc = proc; ++} ++#endif +--- ./lib/lwres/getaddrinfo.c.orig Fri Dec 1 16:45:29 2000 ++++ ./lib/lwres/getaddrinfo.c Fri Dec 1 16:57:06 2000 +@@ -54,4 +54,12 @@ + #endif + ++#ifdef WITH_MDN /* Add 'encodeflag' parameter to 3 functions. */ ++static int add_ipv4(const char *hostname, int flags, struct addrinfo **aip, ++ int socktype, int port, int encodeflg); ++static int add_ipv6(const char *hostname, int flags, struct addrinfo **aip, ++ int socktype, int port, int encodeflg); ++static void set_order(int, int (**)(const char *, int, struct addrinfo **, ++ int, int, int)); ++#else + static int add_ipv4(const char *hostname, int flags, struct addrinfo **aip, + int socktype, int port); +@@ -60,4 +68,5 @@ + static void set_order(int, int (**)(const char *, int, struct addrinfo **, + int, int)); ++#endif /* WITH_MDN */ + + #define FOUND_IPV4 0x1 +@@ -67,7 +76,22 @@ + #define ISC_AI_MASK (AI_PASSIVE|AI_CANONNAME|AI_NUMERICHOST) + ++#ifdef WITH_MDN + int + lwres_getaddrinfo(const char *hostname, const char *servname, ++ const struct addrinfo *hints, struct addrinfo **res) ++{ ++ /* The last parameter is a encoding type. Default is local encoding. */ ++ return (lwres_getaddrinfo_enc(hostname, servname, hints, res, 0)); ++} ++#endif /* WITH_MDN */ ++ ++int ++#ifdef WITH_MDN ++lwres_getaddrinfo_enc(const char *hostname, const char *servname, ++ const struct addrinfo *hints, struct addrinfo **res, int encodeflg) ++#else ++lwres_getaddrinfo(const char *hostname, const char *servname, + const struct addrinfo *hints, struct addrinfo **res) ++#endif /* WITH_MDN */ + { + struct servent *sp; +@@ -76,6 +100,11 @@ + struct addrinfo *ai, *ai_list; + int port, err, i; ++#ifdef WITH_MDN ++ int (*net_order[FOUND_MAX+1])(const char *, int, struct addrinfo **, ++ int, int, int); ++#else + int (*net_order[FOUND_MAX+1])(const char *, int, struct addrinfo **, + int, int); ++#endif /* WITH_MDN */ + + if (hostname == NULL && servname == NULL) +@@ -354,5 +383,9 @@ + break; + err = (net_order[i])(hostname, flags, &ai_list, ++#ifdef WITH_MDN ++ socktype, port, encodeflg); ++#else + socktype, port); ++#endif + if (err != 0) + return (err); +@@ -393,6 +426,11 @@ + + static void ++#ifdef WITH_MDN ++set_order(int family, int (**net_order)(const char *, int, struct addrinfo **, ++ int, int, int)) ++#else + set_order(int family, int (**net_order)(const char *, int, struct addrinfo **, + int, int)) ++#endif /* WITH_MDN */ + { + char *order, *tok; +@@ -452,6 +490,11 @@ + + static int ++#ifdef WITH_MDN ++add_ipv4(const char *hostname, int flags, struct addrinfo **aip, ++ int socktype, int port, int encodeflg) ++#else + add_ipv4(const char *hostname, int flags, struct addrinfo **aip, + int socktype, int port) ++#endif /* WITH_MDN */ + { + struct addrinfo *ai; +@@ -477,6 +520,12 @@ + SIN(ai->ai_addr)->sin_port = port; + memcpy(&SIN(ai->ai_addr)->sin_addr, v4_loop, 4); ++#ifdef WITH_MDN ++ } else if (lwres_getaddrsbyname_enc(lwrctx, hostname, ++ LWRES_ADDRTYPE_V4, ++ &by, encodeflg) == 0) { ++#else + } else if (lwres_getaddrsbyname(lwrctx, hostname, + LWRES_ADDRTYPE_V4, &by) == 0) { ++#endif /* WITH_MDN */ + addr = LWRES_LIST_HEAD(by->addrs); + while (addr != NULL) { +@@ -512,6 +561,11 @@ + + static int ++#ifdef WITH_MDN ++add_ipv6(const char *hostname, int flags, struct addrinfo **aip, ++ int socktype, int port, int encodeflg) ++#else + add_ipv6(const char *hostname, int flags, struct addrinfo **aip, + int socktype, int port) ++#endif /* WITH_MDN */ + { + struct addrinfo *ai; +@@ -538,6 +592,12 @@ + SIN6(ai->ai_addr)->sin6_port = port; + memcpy(&SIN6(ai->ai_addr)->sin6_addr, v6_loop, 16); ++#ifdef WITH_MDN ++ } else if (lwres_getaddrsbyname_enc(lwrctx, hostname, ++ LWRES_ADDRTYPE_V6, ++ &by, encodeflg) == 0) { ++#else + } else if (lwres_getaddrsbyname(lwrctx, hostname, + LWRES_ADDRTYPE_V6, &by) == 0) { ++#endif /* WITH_MDN */ + addr = LWRES_LIST_HEAD(by->addrs); + while (addr != NULL) { +--- ./lib/lwres/gethost.c.orig Fri Dec 1 16:45:28 2000 ++++ ./lib/lwres/gethost.c Fri Dec 1 16:47:35 2000 +@@ -26,4 +26,7 @@ + #include + ++#ifdef WITH_MDN ++#include ++#endif /* WITH_MDN */ + #include + +@@ -37,30 +40,81 @@ + static int copytobuf(struct hostent *, struct hostent *, char *, int); + ++#ifdef WITH_MDN + struct hostent * + lwres_gethostbyname(const char *name) { ++ /* The last parameter is a encoding type. Default is local encoding. */ ++ return (lwres_gethostbyname_enc(name, LWRES_ENCODING_LOCAL)); ++} ++#endif /* WITH_MDN */ ++ ++struct hostent * ++#ifdef WITH_MDN ++lwres_gethostbyname_enc(const char *name, int encodeflg) { ++#else ++lwres_gethostbyname(const char *name) { ++#endif /* WITH_MDN */ + + if (he != NULL) + lwres_freehostent(he); + ++#ifdef WITH_MDN ++ he = lwres_getipnodebyname_enc(name, AF_INET, 0, &lwres_h_errno, ++ encodeflg); ++#else + he = lwres_getipnodebyname(name, AF_INET, 0, &lwres_h_errno); ++#endif /* WITH_MDN */ + return (he); + } + ++#ifdef WITH_MDN + struct hostent * + lwres_gethostbyname2(const char *name, int af) { ++ /* The last parameter is a encoding type. Default is local encoding. */ ++ return (lwres_gethostbyname2_enc(name, af, LWRES_ENCODING_LOCAL)); ++} ++#endif /* WITH_MDN */ ++ ++struct hostent * ++#ifdef WITH_MDN ++lwres_gethostbyname2_enc(const char *name, int af, int encodeflg) { ++#else ++lwres_gethostbyname2(const char *name, int af) { ++#endif /* WITH_MDN */ + if (he != NULL) + lwres_freehostent(he); + ++#ifdef WITH_MDN ++ he = lwres_getipnodebyname_enc(name, af, 0, &lwres_h_errno, encodeflg); ++#else + he = lwres_getipnodebyname(name, af, 0, &lwres_h_errno); ++#endif /* WITH_MDN */ + return (he); + } + ++#ifdef WITH_MDN ++struct hostent * ++lwres_gethostbyaddr(const char *addr, int len, int type) { ++ /* The last parameter is a encoding type. Default is local encoding. */ ++ return (lwres_gethostbyaddr_enc(addr, len, type, ++ LWRES_ENCODING_LOCAL)); ++} ++#endif /* WITH_MDN */ ++ + struct hostent * ++#ifdef WITH_MDN ++lwres_gethostbyaddr_enc(const char *addr, int len, int type, int encodeflg) { ++#else + lwres_gethostbyaddr(const char *addr, int len, int type) { ++#endif /* WITH_MDN */ + + if (he != NULL) + lwres_freehostent(he); + ++#ifdef WITH_MDN ++ he = lwres_getipnodebyaddr_enc(addr, len, type, &lwres_h_errno, ++ encodeflg); ++#else + he = lwres_getipnodebyaddr(addr, len, type, &lwres_h_errno); ++#endif /* WITH_MDN */ + return (he); + } +@@ -89,12 +143,32 @@ + } + ++#ifdef WITH_MDN + struct hostent * + lwres_gethostbyname_r(const char *name, struct hostent *resbuf, + char *buf, int buflen, int *error) + { ++ /* The last parameter is a encoding type. Default is local encoding. */ ++ return (lwres_gethostbyname_r_enc(name, resbuf, buf, buflen, error, ++ LWRES_ENCODING_LOCAL)); ++} ++#endif /* WITH_MDN */ ++ ++struct hostent * ++#ifdef WITH_MDN ++lwres_gethostbyname_r_enc(const char *name, struct hostent *resbuf, ++ char *buf, int buflen, int *error, int encodeflg) ++#else ++lwres_gethostbyname_r(const char *name, struct hostent *resbuf, ++ char *buf, int buflen, int *error) ++#endif /* WITH_MDN */ ++{ + struct hostent *he; + int res; + ++#ifdef WITH_MDN ++ he = lwres_getipnodebyname_enc(name, AF_INET, 0, error, encodeflg); ++#else + he = lwres_getipnodebyname(name, AF_INET, 0, error); ++#endif /* WITH_MDN */ + if (he == NULL) + return (NULL); +@@ -108,13 +182,35 @@ + } + ++#ifdef WITH_MDN ++struct hostent * ++lwres_gethostbyaddr_r(const char *addr, int len, int type, ++ struct hostent *resbuf, char *buf, int buflen, ++ int *error) ++{ ++ /* The last parameter is a encoding type. Default is local encoding. */ ++ return (lwres_gethostbyaddr_r_enc(addr, len, type, resbuf, buf, buflen, ++ error, LWRES_ENCODING_LOCAL)); ++} ++#endif /* WITH_MDN */ ++ + struct hostent * ++#ifdef WITH_MDN ++lwres_gethostbyaddr_r_enc(const char *addr, int len, int type, ++ struct hostent *resbuf, char *buf, int buflen, ++ int *error, int encodeflg) ++#else + lwres_gethostbyaddr_r(const char *addr, int len, int type, + struct hostent *resbuf, char *buf, int buflen, + int *error) ++#endif /* WITH_MDN */ + { + struct hostent *he; + int res; + ++#ifdef WITH_MDN ++ he = lwres_getipnodebyaddr_enc(addr, len, type, error, encodeflg); ++#else + he = lwres_getipnodebyaddr(addr, len, type, error); ++#endif /* WITH_MDN */ + if (he == NULL) + return (NULL); +--- ./lib/lwres/getipnode.c.orig Fri Dec 1 16:45:28 2000 ++++ ./lib/lwres/getipnode.c Fri Dec 1 16:47:40 2000 +@@ -99,6 +99,22 @@ + */ + ++#ifdef WITH_MDN + struct hostent * ++lwres_getipnodebyname(const char *name, int af, int flags, int *error_num) ++{ ++ /* The last parameter is a encoding type. Default is local encoding. */ ++ return (lwres_getipnodebyname_enc(name, af, flags, error_num, ++ LWRES_ENCODING_LOCAL)); ++} ++#endif /* WITH_MDN */ ++ ++struct hostent * ++#ifdef WITH_MDN ++lwres_getipnodebyname_enc(const char *name, int af, int flags, int *error_num, ++ int encodeflg) ++{ ++#else + lwres_getipnodebyname(const char *name, int af, int flags, int *error_num) { ++#endif /* WITH_MDN */ + int have_v4 = 1, have_v6 = 1; + struct in_addr in4; +@@ -171,5 +187,10 @@ + if (have_v6 && af == AF_INET6) { + ++#ifdef WITH_MDN ++ n = lwres_getaddrsbyname_enc(lwrctx, name, LWRES_ADDRTYPE_V6, ++ &by, encodeflg); ++#else + n = lwres_getaddrsbyname(lwrctx, name, LWRES_ADDRTYPE_V6, &by); ++#endif /* WITH_MDN */ + if (n == 0) { + he1 = hostfromname(by, AF_INET6); +@@ -188,5 +209,10 @@ + (af == AF_INET6 && (flags & AI_V4MAPPED) != 0 && + (he1 == NULL || (flags & AI_ALL) != 0)))) { ++#ifdef WITH_MDN ++ n = lwres_getaddrsbyname_enc(lwrctx, name, LWRES_ADDRTYPE_V4, ++ &by, encodeflg); ++#else + n = lwres_getaddrsbyname(lwrctx, name, LWRES_ADDRTYPE_V4, &by); ++#endif /* WITH_MDN */ + if (n == 0) { + he2 = hostfromname(by, AF_INET); +@@ -220,6 +246,20 @@ + } + ++#ifdef WITH_MDN ++struct hostent * ++lwres_getipnodebyaddr(const void *src, size_t len, int af, int *error_num) { ++ /* The last parameter is a encoding type. Default is local encoding. */ ++ return (lwres_getipnodebyaddr_enc(src, len, af, error_num, ++ LWRES_ENCODING_LOCAL)); ++} ++#endif /* WITH_MDN */ + struct hostent * ++#ifdef WITH_MDN ++lwres_getipnodebyaddr_enc(const void *src, size_t len, int af, int *error_num, ++ int encodeflg) ++{ ++#else + lwres_getipnodebyaddr(const void *src, size_t len, int af, int *error_num) { ++#endif /* WITH_MDN */ + struct hostent *he1, *he2; + lwres_context_t *lwrctx = NULL; +@@ -282,6 +322,12 @@ + (void) lwres_conf_parse(lwrctx, lwres_resolv_conf); + if (n == LWRES_R_SUCCESS) ++#ifdef WITH_MDN ++ n = lwres_getnamebyaddr_enc(lwrctx, LWRES_ADDRTYPE_V4, ++ INADDRSZ, cp, &by, ++ encodeflg); ++#else + n = lwres_getnamebyaddr(lwrctx, LWRES_ADDRTYPE_V4, + INADDRSZ, cp, &by); ++#endif /* WITH_MDN */ + if (n != LWRES_R_SUCCESS) { + lwres_conf_clear(lwrctx); +@@ -326,6 +372,11 @@ + (void) lwres_conf_parse(lwrctx, lwres_resolv_conf); + if (n == LWRES_R_SUCCESS) ++#ifdef WITH_MDN ++ n = lwres_getnamebyaddr_enc(lwrctx, LWRES_ADDRTYPE_V6, ++ IN6ADDRSZ, src, &by, encodeflg); ++#else + n = lwres_getnamebyaddr(lwrctx, LWRES_ADDRTYPE_V6, IN6ADDRSZ, + src, &by); ++#endif /* WITH_MDN */ + if (n != 0) { + *error_num = HOST_NOT_FOUND; +--- ./lib/lwres/getnameinfo.c.orig Fri Dec 1 16:45:29 2000 ++++ ./lib/lwres/getnameinfo.c Fri Dec 1 16:47:40 2000 +@@ -106,8 +106,24 @@ + } while (0) + ++#ifdef WITH_MDN + int + lwres_getnameinfo(const struct sockaddr *sa, size_t salen, char *host, + size_t hostlen, char *serv, size_t servlen, int flags) + { ++ /* The last parameter is a encoding type. Default is local encoding. */ ++ return (lwres_getnameinfo_enc(sa, salen, host, hostlen, serv, servlen, ++ flags, LWRES_ENCODING_LOCAL)); ++} ++#endif /* WITH_MDN */ ++int ++#ifdef WITH_MDN ++lwres_getnameinfo_enc(const struct sockaddr *sa, size_t salen, char *host, ++ size_t hostlen, char *serv, size_t servlen, int flags, ++ int encodeflg) ++#else ++lwres_getnameinfo(const struct sockaddr *sa, size_t salen, char *host, ++ size_t hostlen, char *serv, size_t servlen, int flags) ++#endif /* WITH_MDN */ ++{ + struct afd *afd; + struct servent *sp; +@@ -259,6 +275,12 @@ + + if (n == 0) ++#ifdef WITH_MDN ++ n = lwres_getnamebyaddr_enc(lwrctx, lwf, ++ afd->a_addrlen, addr, &by, ++ encodeflg); ++#else + n = lwres_getnamebyaddr(lwrctx, lwf, afd->a_addrlen, + addr, &by); ++#endif /* WITH_MDN */ + if (n == 0) { + if (flags & NI_NOFQDN) { +--- ./lib/lwres/include/lwres/lwres.h.orig Fri Dec 1 16:45:27 2000 ++++ ./lib/lwres/include/lwres/lwres.h Fri Dec 1 16:47:40 2000 +@@ -27,4 +27,7 @@ + #include + #include ++#ifdef WITH_MDN ++#include ++#endif /* WITH_MDN */ + + /* +@@ -248,4 +251,7 @@ + lwres_uint8_t ndots; /* set to n in 'options ndots:n' */ + lwres_uint8_t no_tld_query; /* non-zero if 'options no_tld_query' */ ++#ifdef WITH_MDN ++ mdn_resconf_t mdnctx; /* structure for mdn configuration */ ++#endif /* WITH_MDN */ + } lwres_conf_t; + +@@ -256,4 +262,10 @@ + #define LWRES_MAX_ADDRS 64 /* max # of addrs */ + ++#ifdef WITH_MDN ++/* These are used for specifying encoding of the domain names */ ++#define LWRES_ENCODING_LOCAL 0 /* local encoding */ ++#define LWRES_ENCODING_UCS 1 /* UTF-8 encoding */ ++#endif /* WITH_MDN */ ++ + LWRES_LANG_BEGINDECLS + +@@ -265,4 +277,30 @@ + extern const char *lwres_resolv_conf; + ++#ifdef WITH_MDN ++/* ++ * Forward declarations ++ */ ++struct addrinfo; ++struct sockaddr; ++ ++int lwres_getaddrinfo_enc(const char *, const char *, ++ const struct addrinfo *, ++ struct addrinfo **, ++ int encodeflg); ++int lwres_getnameinfo_enc(const struct sockaddr *, size_t, char *, ++ size_t, char *, size_t, int, int); ++struct hostent *lwres_gethostbyaddr_enc(const char *, int, int, int); ++struct hostent *lwres_gethostbyname_enc(const char *, int); ++struct hostent *lwres_gethostbyname2_enc(const char *, int, int); ++struct hostent *lwres_getipnodebyname_enc(const char *, int, int, int *, int); ++struct hostent *lwres_getipnodebyaddr_enc(const void *, size_t, int, int *, ++ int); ++struct hostent *lwres_gethostbyaddr_r_enc(const char *, int, int, ++ struct hostent *, char *, int, ++ int *, int); ++struct hostent *lwres_gethostbyname_r_enc(const char *, struct hostent *, ++ char *, int, int *, int); ++#endif /* WITH_MDN */ ++ + lwres_result_t + lwres_gabnrequest_render(lwres_context_t *ctx, lwres_gabnrequest_t *req, +@@ -278,7 +316,13 @@ + + lwres_result_t ++#ifdef WITH_MDN ++lwres_gabnresponse_parse(lwres_context_t *ctx, lwres_buffer_t *b, ++ lwres_lwpacket_t *pkt, ++ lwres_gabnresponse_t **structp, int encodeflg); ++#else + lwres_gabnresponse_parse(lwres_context_t *ctx, lwres_buffer_t *b, + lwres_lwpacket_t *pkt, + lwres_gabnresponse_t **structp); ++#endif /* WITH_MDN */ + + void +@@ -333,8 +377,15 @@ + lwres_lwpacket_t *pkt, lwres_gnbarequest_t **structp); + ++#ifdef WITH_MDN ++lwres_result_t ++lwres_gnbaresponse_parse(lwres_context_t *ctx, lwres_buffer_t *b, ++ lwres_lwpacket_t *pkt, ++ lwres_gnbaresponse_t **structp, int encodeflg); ++#else + lwres_result_t + lwres_gnbaresponse_parse(lwres_context_t *ctx, lwres_buffer_t *b, + lwres_lwpacket_t *pkt, + lwres_gnbaresponse_t **structp); ++#endif /* WITH_MDN */ + + void +@@ -571,4 +622,10 @@ + lwres_getaddrsbyname(lwres_context_t *ctx, const char *name, + lwres_uint32_t addrtypes, lwres_gabnresponse_t **structp); ++#ifdef WITH_MDN ++lwres_result_t ++lwres_getaddrsbyname_enc(lwres_context_t *ctx, const char *name, ++ lwres_uint32_t addrtypes, ++ lwres_gabnresponse_t **structp, int encodeflg); ++#endif /* WITH_MDN */ + + lwres_result_t +@@ -576,4 +633,10 @@ + lwres_uint16_t addrlen, const unsigned char *addr, + lwres_gnbaresponse_t **structp); ++#ifdef WITH_MDN ++lwres_result_t ++lwres_getnamebyaddr_enc(lwres_context_t *ctx, lwres_uint32_t addrtype, ++ lwres_uint16_t addrlen, const unsigned char *addr, ++ lwres_gnbaresponse_t **structp, int encodeflg); ++#endif /* WITH_MDN */ + + lwres_result_t +@@ -581,4 +644,9 @@ + lwres_uint16_t rdclass, lwres_uint16_t rdtype, + lwres_uint32_t flags, lwres_grbnresponse_t **structp); ++ ++#ifdef WITH_MDN ++lwres_result_t ++lwres_result_frommdn(mdn_result_t r); ++#endif + + LWRES_LANG_ENDDECLS +--- ./lib/lwres/lwconfig.c.orig Fri Dec 1 16:45:30 2000 ++++ ./lib/lwres/lwconfig.c Fri Dec 1 16:47:41 2000 +@@ -56,4 +56,7 @@ + #include + #include ++#ifdef WITH_MDN ++#include ++#endif /* WITH_MDN */ + + #include "assert_p.h" +@@ -241,4 +244,13 @@ + lwres_resetaddr(&confdata->sortlist[i].mask); + } ++#ifdef WITH_MDN ++ /* ++ * Initialize the context for MDN. ++ */ ++ confdata->mdnctx = NULL; ++ if (mdn_resconf_initialize() == mdn_success) { ++ (void)mdn_resconf_create(&confdata->mdnctx); ++ } ++#endif /* WITH_MDN */ + } + +@@ -602,4 +614,9 @@ + fclose(fp); + ++#ifdef WITH_MDN ++ /* Read mdn configuration file. */ ++ if (confdata->mdnctx != NULL) ++ (void)mdn_resconf_loadfile(confdata->mdnctx, NULL); ++#endif + return (ret); + } +--- ./lib/lwres/lwres_gabn.c.orig Fri Dec 1 16:45:29 2000 ++++ ./lib/lwres/lwres_gabn.c Fri Dec 1 16:47:41 2000 +@@ -28,4 +28,7 @@ + #include + #include ++#ifdef WITH_MDN ++#include ++#endif /* WITH_MDN */ + + #include "context_p.h" +@@ -245,6 +248,12 @@ + + lwres_result_t ++#ifdef WITH_MDN ++lwres_gabnresponse_parse(lwres_context_t *ctx, lwres_buffer_t *b, ++ lwres_lwpacket_t *pkt, lwres_gabnresponse_t **structp, ++ int encodeflg) ++#else + lwres_gabnresponse_parse(lwres_context_t *ctx, lwres_buffer_t *b, + lwres_lwpacket_t *pkt, lwres_gabnresponse_t **structp) ++#endif /* WITH_MDN */ + { + lwres_result_t ret; +@@ -256,4 +265,9 @@ + lwres_addrlist_t addrlist; + lwres_addr_t *addr; ++#ifdef WITH_MDN ++ char *tmp_realname; ++ char *tmp_aliases; ++ mdn_result_t r; ++#endif /* WITH_MDN */ + + REQUIRE(ctx != NULL); +@@ -319,4 +333,26 @@ + if (ret != LWRES_R_SUCCESS) + goto out; ++#ifdef WITH_MDN ++ /* ++ * Convert from UCS to local encoding if needed. ++ */ ++ tmp_realname = (char *)malloc(1024); ++ switch (encodeflg) { ++ case LWRES_ENCODING_LOCAL: /* from UCS to local encoding */ ++ r = mdn_res_ucstolocal(ctx->confdata.mdnctx, gabn->realname, ++ tmp_realname, 1024); ++ if (r != mdn_success) { ++ free(tmp_realname); ++ tmp_realname = NULL; ++ ret = lwres_result_frommdn(r); ++ goto out; ++ } ++ break; ++ default: ++ strcpy(tmp_realname, gabn->realname); ++ break; ++ } ++ gabn->realname = tmp_realname; ++#endif /* WITH_MDN */ + + /* +@@ -328,4 +364,27 @@ + if (ret != LWRES_R_SUCCESS) + goto out; ++#ifdef WITH_MDN ++ /* ++ * Convert from UCS to local encoding. ++ */ ++ tmp_aliases = (char *)malloc(1024); ++ switch (encodeflg) { ++ case LWRES_ENCODING_LOCAL: /* from UCS to local encoding */ ++ r = mdn_res_ucstolocal(ctx->confdata.mdnctx, ++ gabn->aliases[x], ++ tmp_aliases, 1024); ++ if (r != mdn_success) { ++ free(tmp_aliases); ++ tmp_aliases = NULL; ++ ret = lwres_result_frommdn(r); ++ goto out; ++ } ++ break; ++ default: /* When encoding on DNS protocol */ ++ strcpy(tmp_aliases, gabn->aliases[x]); ++ break; ++ } ++ gabn->aliases[x] = tmp_aliases; ++#endif /* WITH_MDN */ + } + +@@ -391,4 +450,7 @@ + lwres_gabnresponse_t *gabn; + lwres_addr_t *addr; ++#ifdef WITH_MDN ++ unsigned int x; ++#endif /* WITH_MDN */ + + REQUIRE(ctx != NULL); +@@ -398,4 +460,12 @@ + *structp = NULL; + ++#ifdef WITH_MDN ++ free(gabn->realname); ++ gabn->realname = NULL; ++ for (x = 0 ; x < gabn->naliases ; x++) { ++ free(gabn->aliases[x]); ++ gabn->aliases[x] = NULL; ++ } ++#endif /* WITH_MDN */ + if (gabn->naliases > 0) { + CTXFREE(gabn->aliases, sizeof(char *) * gabn->naliases); +--- ./lib/lwres/lwres_gnba.c.orig Fri Dec 1 16:45:29 2000 ++++ ./lib/lwres/lwres_gnba.c Fri Dec 1 16:47:41 2000 +@@ -28,4 +28,7 @@ + #include + #include ++#ifdef WITH_MDN ++#include ++#endif /* WITH_MDN */ + + #include "context_p.h" +@@ -204,6 +207,12 @@ + + lwres_result_t ++#ifdef WITH_MDN ++lwres_gnbaresponse_parse(lwres_context_t *ctx, lwres_buffer_t *b, ++ lwres_lwpacket_t *pkt, lwres_gnbaresponse_t **structp, ++ int encodeflg) ++#else + lwres_gnbaresponse_parse(lwres_context_t *ctx, lwres_buffer_t *b, + lwres_lwpacket_t *pkt, lwres_gnbaresponse_t **structp) ++#endif /* WITH_MDN */ + { + int ret; +@@ -212,4 +221,9 @@ + lwres_uint16_t naliases; + lwres_gnbaresponse_t *gnba; ++#ifdef WITH_MDN ++ char *tmp_realname; ++ char *tmp_aliases; ++ mdn_result_t r; ++#endif /* WITH_MDN */ + + REQUIRE(ctx != NULL); +@@ -261,4 +275,26 @@ + if (ret != LWRES_R_SUCCESS) + goto out; ++#ifdef WITH_MDN ++ /* ++ * Convert from UCS to local encoding if needed. ++ */ ++ tmp_realname = (char *)malloc(1024); ++ switch (encodeflg) { ++ case LWRES_ENCODING_LOCAL: /* from UCS to local encoding */ ++ r = mdn_res_ucstolocal(ctx->confdata.mdnctx, gnba->realname, ++ tmp_realname, 1024); ++ if (r != mdn_success) { ++ free(tmp_realname); ++ tmp_realname = NULL; ++ ret = lwres_result_frommdn(r); ++ goto out; ++ } ++ break; ++ default: ++ strcpy(tmp_realname, gnba->realname); ++ break; ++ } ++ gnba->realname = tmp_realname; ++#endif /* WITH_MDN */ + + /* +@@ -270,4 +306,27 @@ + if (ret != LWRES_R_SUCCESS) + goto out; ++#ifdef WITH_MDN ++ /* ++ * Convert from UCS to local encoding. ++ */ ++ tmp_aliases = (char *)malloc(1024); ++ switch (encodeflg) { ++ case LWRES_ENCODING_LOCAL: /* from UCS to local encoding */ ++ r = mdn_res_ucstolocal(ctx->confdata.mdnctx, ++ gnba->aliases[x], ++ tmp_aliases, 1024); ++ if (r != mdn_success) { ++ free(tmp_aliases); ++ tmp_aliases = NULL; ++ ret = lwres_result_frommdn(r); ++ goto out; ++ } ++ break; ++ default: /* When encoding on DNS protocol */ ++ strcpy(tmp_aliases, gnba->aliases[x]); ++ break; ++ } ++ gnba->aliases[x] = tmp_aliases; ++#endif /* WITH_MDN */ + } + +@@ -311,4 +370,7 @@ + { + lwres_gnbaresponse_t *gnba; ++#ifdef WITH_MDN ++ unsigned int x; ++#endif /* WITH_MDN */ + + REQUIRE(ctx != NULL); +@@ -318,4 +380,12 @@ + *structp = NULL; + ++#ifdef WITH_MDN ++ free(gnba->realname); ++ gnba->realname = NULL; ++ for (x = 0 ; x < gnba->naliases ; x++) { ++ free(gnba->aliases[x]); ++ gnba->aliases[x] = NULL; ++ } ++#endif /* WITH_MDN */ + if (gnba->naliases > 0) { + CTXFREE(gnba->aliases, sizeof(char *) * gnba->naliases); +--- ./lib/lwres/lwresutil.c.orig Fri Dec 1 16:45:30 2000 ++++ ./lib/lwres/lwresutil.c Fri Dec 1 16:47:41 2000 +@@ -33,4 +33,7 @@ + #include + #include ++#ifdef WITH_MDN ++#include ++#endif /* WITH_MDN */ + + #include "assert_p.h" +@@ -160,8 +163,24 @@ + } + ++#ifdef WITH_MDN + lwres_result_t + lwres_getaddrsbyname(lwres_context_t *ctx, const char *name, + lwres_uint32_t addrtypes, lwres_gabnresponse_t **structp) + { ++ /* The last parameter is a encoding type. Default is local encoding. */ ++ return (lwres_getaddrsbyname_enc(ctx, name, addrtypes, structp, 0)); ++} ++#endif /* WITH_MDN */ ++ ++lwres_result_t ++#ifdef WITH_MDN ++lwres_getaddrsbyname_enc(lwres_context_t *ctx, const char *name, ++ lwres_uint32_t addrtypes, lwres_gabnresponse_t **structp, ++ int encodeflg) ++#else ++lwres_getaddrsbyname(lwres_context_t *ctx, const char *name, ++ lwres_uint32_t addrtypes, lwres_gabnresponse_t **structp) ++#endif /* WITH_MDN */ ++{ + lwres_gabnrequest_t request; + lwres_gabnresponse_t *response; +@@ -174,4 +193,8 @@ + char target_name[1024]; + unsigned int target_length; ++#ifdef WITH_MDN ++ mdn_result_t r; ++ char request_name[1024]; ++#endif /* WITH_MDN */ + + REQUIRE(ctx != NULL); +@@ -201,6 +224,35 @@ + */ + request.addrtypes = addrtypes; ++#ifdef WITH_MDN ++ /* ++ * Convert from local encoding to UCS, then perform normalization. ++ */ ++ switch (encodeflg) { ++ case LWRES_ENCODING_LOCAL: /* from local encoding */ ++ r = mdn_res_localtoucs(ctx->confdata.mdnctx, target_name, ++ request_name, sizeof(request_name)); ++ if (r == mdn_success) { ++ r = mdn_res_normalize(ctx->confdata.mdnctx, ++ request_name, ++ target_name, ++ sizeof(target_name)); ++ } ++ request.name = target_name; ++ break; ++ default: ++ r = mdn_res_normalize(ctx->confdata.mdnctx, target_name, ++ request_name, sizeof(request_name)); ++ request.name = request_name; ++ break; ++ } ++ if (r != mdn_success) { ++ ret = lwres_result_frommdn(r); ++ goto out; ++ } ++ request.namelen = strlen(request.name); ++#else + request.name = target_name; + request.namelen = target_length; ++#endif /* WITH_MDN */ + pkt.pktflags = 0; + pkt.serial = serial; +@@ -251,5 +303,9 @@ + * Parse the response. + */ ++#ifdef WITH_MDN ++ ret = lwres_gabnresponse_parse(ctx, &b_in, &pkt, &response, encodeflg); ++#else + ret = lwres_gabnresponse_parse(ctx, &b_in, &pkt, &response); ++#endif /* WITH_MDN */ + if (ret != LWRES_R_SUCCESS) + goto out; +@@ -273,8 +329,25 @@ + + ++#ifdef WITH_MDN ++lwres_result_t ++lwres_getnamebyaddr(lwres_context_t *ctx, lwres_uint32_t addrtype, ++ lwres_uint16_t addrlen, const unsigned char *addr, ++ lwres_gnbaresponse_t **structp) ++{ ++ /* The last parameter is a encoding type. Default is local encoding. */ ++ return (lwres_getnamebyaddr_enc(ctx, addrtype, addrlen, addr, structp, ++ LWRES_ENCODING_LOCAL)); ++} ++#endif /* WITH_MDN */ + lwres_result_t ++#ifdef WITH_MDN ++lwres_getnamebyaddr_enc(lwres_context_t *ctx, lwres_uint32_t addrtype, ++ lwres_uint16_t addrlen, const unsigned char *addr, ++ lwres_gnbaresponse_t **structp, int encodeflg) ++#else + lwres_getnamebyaddr(lwres_context_t *ctx, lwres_uint32_t addrtype, + lwres_uint16_t addrlen, const unsigned char *addr, + lwres_gnbaresponse_t **structp) ++#endif /* WITH_MDN */ + { + lwres_gnbarequest_t request; +@@ -359,5 +432,9 @@ + * Parse the response. + */ ++#ifdef WITH_MDN ++ ret = lwres_gnbaresponse_parse(ctx, &b_in, &pkt, &response, encodeflg); ++#else + ret = lwres_gnbaresponse_parse(ctx, &b_in, &pkt, &response); ++#endif /* WITH_MDN */ + if (ret != LWRES_R_SUCCESS) + goto out; +@@ -379,4 +456,21 @@ + return (ret); + } ++ ++#ifdef WITH_MDN ++lwres_result_t ++lwres_result_frommdn(mdn_result_t r) { ++ /* ++ * Convert mDNkit's result code to lwres's one. ++ */ ++ switch (r) { ++ case mdn_success: ++ return (LWRES_R_SUCCESS); ++ case mdn_nomemory: ++ return (LWRES_R_NOMEMORY); ++ default: ++ return (LWRES_R_FAILURE); ++ } ++} ++#endif + + lwres_result_t +--- ./bin/dig/dighost.c.orig Fri Dec 1 16:45:10 2000 ++++ ./bin/dig/dighost.c Fri Dec 1 16:47:41 2000 +@@ -33,8 +33,18 @@ + #include + #include ++#ifdef HAVE_LOCALE_H ++#include ++#endif + #if (!(defined(HAVE_ADDRINFO) && defined(HAVE_GETADDRINFO))) + extern int h_errno; + #endif + ++#ifdef WITH_MDN ++#include ++#include ++#include ++#include ++#endif ++ + #include + #include +@@ -129,4 +139,18 @@ + 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. +@@ -690,4 +714,8 @@ + } + ++#ifdef WITH_MDN ++ initialize_mdn(); ++#endif ++ + if (keyfile[0] != 0) + setup_file_key(); +@@ -1241,4 +1269,9 @@ + isc_buffer_t b; + char store[MXNAME]; ++ char *textname; ++#ifdef WITH_MDN ++ mdn_result_t mr; ++ char ucs_name[MXNAME], ucs_tmp[MXNAME]; ++#endif + + REQUIRE(lookup != NULL); +@@ -1277,5 +1310,14 @@ + */ + /* XXX New search here? */ +- if ((count_dots(lookup->textname) >= ndots) || lookup->defname) ++#ifdef WITH_MDN ++ mr = mdn_res_localtoucs(mdnconf, lookup->textname, ucs_name, ++ sizeof(ucs_name)); ++ mdn_check_result(mr, "local to UCS conversion"); ++ textname = ucs_name; ++#else ++ textname = lookup->textname; ++#endif ++ ++ if ((count_dots(textname) >= ndots) || lookup->defname) + lookup->origin = NULL; /* Force abs lookup */ + else if (lookup->origin == NULL && lookup->new_search && +@@ -1299,4 +1341,22 @@ + 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 = append_textname(ucs_name, lookup->origin->origin, ++ sizeof(ucs_name)); ++ mdn_check_result(mr, "concatenation with origin"); ++ mr = mdn_res_normalize(mdnconf, ucs_name, ucs_tmp, ++ sizeof(ucs_tmp)); ++ mdn_check_result(mr, "normalization"); ++ mr = mdn_res_ucstodns(mdnconf, ucs_tmp, ucs_name, ++ sizeof(ucs_name)); ++ mdn_check_result(mr, "UCS to DNS encoding conversion"); ++ goto no_origin; ++#else + result = dns_message_gettempname(lookup->sendmsg, + &lookup->oname); +@@ -1337,7 +1397,26 @@ + } + dns_message_puttempname(lookup->sendmsg, &lookup->oname); ++#endif + } else { + debug("using root origin"); ++#ifdef WITH_MDN ++ no_origin: ++#endif + if (!lookup->trace_root) { ++#ifdef WITH_MDN ++ mr = mdn_res_normalize(mdnconf, ucs_name, ucs_tmp, ++ sizeof(ucs_tmp)); ++ mdn_check_result(mr, "normalization"); ++ mr = mdn_res_ucstodns(mdnconf, ucs_tmp, ucs_name, ++ sizeof(ucs_name)); ++ mdn_check_result(mr, "UCS to DNS encoding conversion"); ++ len = strlen(ucs_name); ++ isc_buffer_init(&b, ucs_name, len); ++ isc_buffer_add(&b, len); ++ result = dns_name_fromtext(lookup->name, &b, ++ dns_rootname, ++ ISC_FALSE, ++ &lookup->namebuf); ++#else + len = strlen(lookup->textname); + isc_buffer_init(&b, lookup->textname, len); +@@ -1347,4 +1426,5 @@ + ISC_FALSE, + &lookup->namebuf); ++#endif + } else { + dns_name_clone(dns_rootname, lookup->name); +@@ -2819,2 +2899,123 @@ + 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)); ++ ++ /* Allow utf-8 characters in domain names if necessary. */ ++ if ((conv = mdn_resconf_serverconverter(mdnconf)) != NULL && ++ !mdn_converter_isasciicompatible(conv)) { ++ debug("allowing UTF-8 characters in domain names"); ++ dns_name_allowutf8(ISC_TRUE); ++ } ++ /* 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_dnstoucs(mdnconf, tmp1, tmp2, MAXDLEN) ++ != mdn_success || ++ mdn_res_ucstolocal(mdnconf, tmp2, tmp1, MAXDLEN) ++ != mdn_success) ++ return (ISC_R_SUCCESS); ++ ++ /* ++ * 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 */ +--- ./bin/named/Makefile.in.orig Fri Dec 1 16:47:28 2000 ++++ ./bin/named/Makefile.in Fri Dec 1 16:59:08 2000 +@@ -49,8 +49,10 @@ + LWRESDEPLIBS = ../../lib/lwres/liblwres.@A@ + ++ICONVLIB = @ICONVLIB@ ++ + DEPLIBS = ${LWRESDEPLIBS} ${OMAPIDEPLIBS} ${DNSDEPLIBS} ${ISCDEPLIBS} + + LIBS = ${LWRESLIBS} ${OMAPILIBS} ${DNSLIBS} ${ISCLIBS} \ +- ${DBDRIVER_LIBS} @LIBS@ ++ ${DBDRIVER_LIBS} ${ICONVLIB} @LIBS@ + + SUBDIRS = unix +@@ -64,5 +66,5 @@ + zoneconf.@O@ \ + lwaddr.@O@ lwresd.@O@ lwdclient.@O@ lwderror.@O@ lwdgabn.@O@ \ +- lwdgnba.@O@ lwdgrbn.@O@ lwdnoop.@O@ lwsearch.@O@ \ ++ lwdgnba.@O@ lwdgrbn.@O@ lwdmdn.@O@ lwdnoop.@O@ lwsearch.@O@ \ + $(DBDRIVER_OBJS) + +@@ -75,5 +77,5 @@ + zoneconf.c \ + lwaddr.c lwresd.c lwdclient.c lwderror.c lwdgabn.c \ +- lwdgnba.c lwdgrbn.c lwdnoop.c lwsearch.c \ ++ lwdgnba.c lwdgrbn.c lwdmdn.c lwdnoop.c lwsearch.c \ + $(DBDRIVER_SRCS) + +--- ./bin/named/include/named/globals.h.orig Fri Dec 1 16:45:11 2000 ++++ ./bin/named/include/named/globals.h Fri Dec 1 16:47:41 2000 +@@ -109,4 +109,12 @@ + EXTERN const char * ns_g_cachefile INIT(NULL); + ++#ifdef WITH_MDN ++/* ++ * MDN configuration. ++ */ ++EXTERN char * lwresd_g_mdnconffile; ++EXTERN isc_boolean_t lwresd_g_mdnreloadwanted; ++#endif ++ + #undef EXTERN + #undef INIT +--- ./bin/named/include/named/lwdmdn.h.orig Fri Dec 1 16:47:41 2000 ++++ ./bin/named/include/named/lwdmdn.h Fri Dec 1 16:47:41 2000 +@@ -0,0 +1,23 @@ ++/* $Id: lwdmdn.h,v 1.1 2000/08/16 08:55:32 ishisone Exp $ */ ++ ++#ifndef NAMED_LWDMDN_H ++#define NAMED_LWDMDN_H ++ ++#include ++#include ++ ++ISC_LANG_BEGINDECLS ++ ++void ++ns_lwdmdn_initialize(void); ++ ++isc_result_t ++ns_lwdmdn_convertfromutf8(isc_buffer_t *from_buffer, isc_buffer_t *to_buffer); ++ ++isc_result_t ++ns_lwdmdn_converttoutf8(isc_buffer_t *from_buffer, isc_buffer_t *to_buffer); ++ ++ISC_LANG_ENDDECLS ++ ++#endif /* NAMED_LWDMDN_H */ ++ +--- ./bin/named/lwdgabn.c.orig Fri Dec 1 16:45:17 2000 ++++ ./bin/named/lwdgabn.c Fri Dec 1 16:47:41 2000 +@@ -35,4 +35,7 @@ + #include + #include ++#ifdef WITH_MDN ++#include ++#endif + #include + #include +@@ -277,4 +280,7 @@ + isc_result_t result; + isc_uint16_t naliases; ++#ifdef WITH_MDN ++ isc_buffer_t *tbufp; ++#endif + + b = client->recv_buffer; +@@ -283,8 +289,25 @@ + * Render the new name to the buffer. + */ ++#ifdef WITH_MDN ++ tbufp = NULL; ++ result = isc_buffer_allocate(client->clientmgr->mctx, &tbufp, 256); ++ if (result != ISC_R_SUCCESS) ++ return (result); ++ result = dns_name_totext(dns_fixedname_name(&client->target_name), ++ ISC_TRUE, tbufp); ++ if (result != ISC_R_SUCCESS) { ++ isc_buffer_free(&tbufp); ++ return (result); ++ } ++ result = ns_lwdmdn_converttoutf8(tbufp, &client->recv_buffer); ++ isc_buffer_free(&tbufp); ++ if (result != ISC_R_SUCCESS) ++ return (result); ++#else + result = dns_name_totext(dns_fixedname_name(&client->target_name), + ISC_TRUE, &client->recv_buffer); + if (result != ISC_R_SUCCESS) + return (result); ++#endif + + /* +@@ -312,4 +335,7 @@ + isc_result_t result; + dns_name_t *tname; ++#ifdef WITH_MDN ++ isc_buffer_t *tbufp; ++#endif + + b = client->recv_buffer; +@@ -323,5 +349,19 @@ + * Render the new name to the buffer. + */ ++#ifdef WITH_MDN ++ tbufp = NULL; ++ result = isc_buffer_allocate(client->clientmgr->mctx, &tbufp, 256); ++ if (result != ISC_R_SUCCESS) ++ return (result); ++ result = dns_name_totext(tname, ISC_TRUE, tbufp); ++ if (result != ISC_R_SUCCESS) { ++ isc_buffer_free(&tbufp); ++ return (result); ++ } ++ result = ns_lwdmdn_converttoutf8(tbufp, &client->recv_buffer); ++ isc_buffer_free(&tbufp); ++#else + result = dns_name_totext(tname, ISC_TRUE, &client->recv_buffer); ++#endif + if (result != ISC_R_SUCCESS) + return (result); +@@ -599,4 +639,7 @@ + ns_lwdclientmgr_t *cm; + isc_buffer_t namebuf; ++#ifdef WITH_MDN ++ isc_buffer_t *tnamebufp; ++#endif + + REQUIRE(NS_LWDCLIENT_ISRECVDONE(client)); +@@ -610,11 +653,39 @@ + goto out; + ++#ifdef WITH_MDN ++ /* ++ * XXX Assuming allocation size for req->name is larger than ++ * req->namelen by at least one, which is true in the current ++ * implementation. ++ */ ++ isc_buffer_init(&namebuf, req->name, req->namelen + 1); ++ isc_buffer_add(&namebuf, req->namelen); ++ tnamebufp = NULL; ++ result = isc_buffer_allocate(client->clientmgr->mctx, &tnamebufp, 256); ++ if (result != ISC_R_SUCCESS) ++ goto out; ++ /* ++ * Convert UTF-8 string in namebuf into DNS protocol encoding. ++ */ ++ result = ns_lwdmdn_convertfromutf8(&namebuf, tnamebufp); ++ if (result != ISC_R_SUCCESS) { ++ isc_buffer_free(&tnamebufp); ++ goto out; ++ } ++#else + isc_buffer_init(&namebuf, req->name, req->namelen); + isc_buffer_add(&namebuf, req->namelen); ++#endif + + dns_fixedname_init(&client->target_name); + dns_fixedname_init(&client->query_name); ++#ifdef WITH_MDN ++ result = dns_name_fromtext(dns_fixedname_name(&client->query_name), ++ tnamebufp, dns_rootname, ISC_FALSE, NULL); ++ isc_buffer_free(&tnamebufp); ++#else + result = dns_name_fromtext(dns_fixedname_name(&client->query_name), + &namebuf, NULL, ISC_FALSE, NULL); ++#endif + if (result != ISC_R_SUCCESS) + goto out; +--- ./bin/named/lwdgnba.c.orig Fri Dec 1 16:45:17 2000 ++++ ./bin/named/lwdgnba.c Fri Dec 1 16:47:41 2000 +@@ -30,4 +30,7 @@ + #include + #include ++#ifdef WITH_MDN ++#include ++#endif + + static void start_byaddr(ns_lwdclient_t *); +@@ -48,4 +51,7 @@ + isc_uint16_t naliases; + isc_stdtime_t now; ++#ifdef WITH_MDN ++ isc_buffer_t *tbufp; ++#endif + + UNUSED(task); +@@ -110,7 +116,23 @@ + b = client->recv_buffer; + ++#ifdef WITH_MDN ++ tbufp = NULL; ++ result = isc_buffer_allocate(cm->mctx, &tbufp, 256); ++ if (result != ISC_R_SUCCESS) ++ goto out; ++ result = dns_name_totext(name, ISC_TRUE, tbufp); ++ if (result != ISC_R_SUCCESS) { ++ isc_buffer_free(&tbufp); ++ goto out; ++ } ++ result = ns_lwdmdn_converttoutf8(tbufp, &client->recv_buffer); ++ isc_buffer_free(&tbufp); ++ if (result != ISC_R_SUCCESS) ++ goto out; ++#else + result = dns_name_totext(name, ISC_TRUE, &client->recv_buffer); + if (result != ISC_R_SUCCESS) + goto out; ++#endif + ns_lwdclient_log(50, "found name '%.*s'", + client->recv_buffer.used - b.used, +--- ./bin/named/lwdmdn.c.orig Fri Dec 1 16:47:41 2000 ++++ ./bin/named/lwdmdn.c Fri Dec 1 16:47:41 2000 +@@ -0,0 +1,281 @@ ++/* $Id: lwdmdn.c,v 1.6 2000/09/07 06:27:40 ishisone Exp $ */ ++ ++#include ++ ++#include ++#include ++#include ++ ++#ifdef WITH_MDN ++#include ++#include ++#include ++#include ++#endif ++ ++#include ++#include ++#include ++ ++#include ++#include ++#include ++#include ++#include ++ ++#ifdef WITH_MDN ++ ++typedef enum { ++ convert_from_utf8, ++ convert_to_utf8 ++} convert_direction_t; ++ ++static isc_logmodule_t modules[] = { ++ { "mdn", 0 }, ++ { NULL, 0 } ++}; ++#define NS_LOGMODULE_MDN (&modules[0]) ++ ++static isc_rwlock_t mdnconflock; ++static mdn_resconf_t mdnconf = NULL; ++ ++static isc_result_t convert_buffer(isc_buffer_t *from_buffer, ++ isc_buffer_t *to_buffer, ++ convert_direction_t dir); ++static isc_result_t load_mdnconfiguration(const char *filename); ++static isc_result_t mdnresult_to_iscresult(mdn_result_t r); ++static void set_log_level(int level); ++static void logger(int level, const char *msg); ++static void logwrite(int level, const char *fmt, ...); ++ ++void ++ns_lwdmdn_initialize(void) { ++ mdn_result_t r; ++ isc_result_t result; ++ ++ logwrite(ISC_LOG_DEBUG(50), "initializing mdn"); ++ ++ /* Register MDN module for logging. */ ++ isc_log_registermodules(ns_g_lctx, modules); ++ ++ /* Set libmdn log hander. */ ++ mdn_log_setproc(logger); ++ ++ /* Set log level. */ ++ set_log_level(ns_g_debuglevel); ++ ++ /* General initialization. */ ++ r = mdn_resconf_initialize(); ++ RUNTIME_CHECK(r == mdn_success); ++ ++ /* Create configuration context. */ ++ r = mdn_resconf_create(&mdnconf); ++ RUNTIME_CHECK(r == mdn_success); ++ ++ /* Initialize configuration lock variable. */ ++ result = isc_rwlock_init(&mdnconflock, 1, 1); ++ RUNTIME_CHECK(result == ISC_R_SUCCESS); ++ ++ /* Load configuration file. */ ++ lwresd_g_mdnreloadwanted = 1; ++ (void)load_mdnconfiguration(lwresd_g_mdnconffile); ++} ++ ++isc_result_t ++ns_lwdmdn_convertfromutf8(isc_buffer_t *from_buffer, isc_buffer_t *to_buffer) { ++ return convert_buffer(from_buffer, to_buffer, convert_from_utf8); ++} ++ ++isc_result_t ++ns_lwdmdn_converttoutf8(isc_buffer_t *from_buffer, isc_buffer_t *to_buffer) { ++ return convert_buffer(from_buffer, to_buffer, convert_to_utf8); ++} ++ ++static isc_result_t ++convert_buffer(isc_buffer_t *from_buffer, isc_buffer_t *to_buffer, ++ convert_direction_t dir) ++{ ++ isc_result_t result; ++ mdn_result_t r; ++ char *fromstr, *tostr; ++ char tmp[256]; ++ size_t tolen; ++ ++ /* ++ * Reload MDN configuration file, if necessary. ++ */ ++ if (lwresd_g_mdnreloadwanted) { ++ result = load_mdnconfiguration(lwresd_g_mdnconffile); ++ } ++ ++ /* ++ * Since libmdn assumes all the strings are NUL-terminated, ++ * teminate the input string. If the buffer has some free space, ++ * utilize it. Otherwise, make a local copy. ++ */ ++ if (isc_buffer_remaininglength(from_buffer) > 0) { ++ fromstr = isc_buffer_used(from_buffer); /* temporary */ ++ *fromstr = '\0'; ++ fromstr = isc_buffer_base(from_buffer); ++ } else { ++ size_t fromlen = isc_buffer_usedlength(from_buffer); ++ ++ if (fromlen >= sizeof(tmp)) ++ fromlen = sizeof(tmp) - 1; ++ fromstr = tmp; ++ memcpy(fromstr, isc_buffer_base(from_buffer), fromlen); ++ fromstr[fromlen] = '\0'; ++ } ++ tostr = isc_buffer_used(to_buffer); ++ tolen = isc_buffer_availablelength(to_buffer); ++ ++ RWLOCK(&mdnconflock, isc_rwlocktype_read); ++ ++ if (dir == convert_from_utf8) ++ r = mdn_res_ucstodns(mdnconf, fromstr, tostr, tolen); ++ else ++ r = mdn_res_dnstoucs(mdnconf, fromstr, tostr, tolen); ++ ++ RWUNLOCK(&mdnconflock, isc_rwlocktype_read); ++ ++ if (r != mdn_success) ++ return (mdnresult_to_iscresult(r)); ++ ++ isc_buffer_add(to_buffer, strlen(tostr)); ++ ++ return (ISC_R_SUCCESS); ++} ++ ++static isc_result_t ++load_mdnconfiguration(const char *filename) { ++ isc_result_t result = ISC_R_SUCCESS; ++ mdn_result_t r; ++ mdn_converter_t conv; ++ isc_boolean_t loaded = ISC_FALSE; ++ isc_boolean_t allow_utf8; ++ ++ RWLOCK(&mdnconflock, isc_rwlocktype_write); ++ ++ logwrite(ISC_LOG_DEBUG(50), "loading mdn configuration %s", ++ filename == NULL ? mdn_resconf_defaultfile() : filename); ++ ++ if (lwresd_g_mdnreloadwanted) { ++ r = mdn_resconf_loadfile(mdnconf, filename); ++ if (r == mdn_success) ++ loaded = ISC_TRUE; ++ else ++ result = mdnresult_to_iscresult(r); ++ } ++ lwresd_g_mdnreloadwanted = 0; ++ logwrite(ISC_LOG_DEBUG(100), "finish loading mdn configuration"); ++ ++ RWUNLOCK(&mdnconflock, isc_rwlocktype_write); ++ ++ if (loaded) { ++ if ((conv = mdn_resconf_serverconverter(mdnconf)) != NULL && ++ !mdn_converter_isasciicompatible(conv)) { ++ logwrite(ISC_LOG_DEBUG(50), ++ "allowing UTF-8 domain names"); ++ allow_utf8 = ISC_TRUE; ++ } else { ++ allow_utf8 = ISC_FALSE; ++ } ++ dns_name_allowutf8(allow_utf8); ++ } ++ ++ return (result); ++} ++ ++static isc_result_t ++mdnresult_to_iscresult(mdn_result_t r) { ++ switch (r) { ++ case mdn_success: ++ return (ISC_R_SUCCESS); ++ case mdn_notfound: ++ case mdn_noentry: ++ case mdn_invalid_name: ++ return (ISC_R_NOTFOUND); ++ case mdn_buffer_overflow: ++ return (ISC_R_NOSPACE); ++ case mdn_nomemory: ++ return (ISC_R_NOMEMORY); ++ case mdn_nofile: ++ return (ISC_R_FILENOTFOUND); ++ default: ++ return (ISC_R_FAILURE); ++ } ++} ++ ++static void ++set_log_level(int level) { ++ int loglevel; ++ ++ if (level < ISC_LOG_ERROR) { ++ loglevel = mdn_log_level_fatal; ++ } else if (level < ISC_LOG_WARNING) { ++ loglevel = mdn_log_level_error; ++ } else if (level < ISC_LOG_INFO) { ++ loglevel = mdn_log_level_warning; ++ } else if (level < ISC_LOG_DEBUG(50)) { ++ loglevel = mdn_log_level_info; ++ } else if (level < ISC_LOG_DEBUG(100)) { ++ loglevel = mdn_log_level_trace; ++ } else { ++ loglevel = mdn_log_level_dump; ++ } ++ mdn_log_setlevel(loglevel); ++} ++ ++static void ++logger(int level, const char *msg) { ++ int loglevel; ++ int msglen; ++ ++ /* ++ * Convert libmdn's log level to bind's log level. ++ */ ++ switch (level) { ++ case mdn_log_level_fatal: ++ loglevel = ISC_LOG_CRITICAL; ++ break; ++ case mdn_log_level_error: ++ loglevel = ISC_LOG_ERROR; ++ break; ++ case mdn_log_level_warning: ++ loglevel = ISC_LOG_WARNING; ++ break; ++ case mdn_log_level_info: ++ loglevel = ISC_LOG_INFO; ++ break; ++ case mdn_log_level_trace: ++ loglevel = ISC_LOG_DEBUG(50); /* XXX */ ++ break; ++ case mdn_log_level_dump: ++ default: ++ loglevel = ISC_LOG_DEBUG(100); /* XXX */ ++ break; ++ } ++ ++ /* ++ * Since libmdn's messages are end with newline, we have to ++ * remove it. ++ */ ++ msglen = strlen(msg); ++ if (msglen > 0 && msg[msglen - 1] == '\n') ++ msglen--; ++ ++ isc_log_write(ns_g_lctx, NS_LOGCATEGORY_CLIENT, NS_LOGMODULE_MDN, ++ loglevel, "%.*s", msglen, msg); ++} ++ ++static void ++logwrite(int level, const char *fmt, ...) { ++ va_list args; ++ ++ va_start(args, fmt); ++ isc_log_vwrite(ns_g_lctx, NS_LOGCATEGORY_CLIENT, NS_LOGMODULE_MDN, ++ level, fmt, args); ++ va_end(args); ++} ++ ++#endif /* WITH_MDN */ +--- ./bin/named/lwresd.c.orig Fri Dec 1 16:45:17 2000 ++++ ./bin/named/lwresd.c Fri Dec 1 16:47:41 2000 +@@ -47,4 +47,7 @@ + #include + #include ++#ifdef WITH_MDN ++#include ++#endif + #include + #include +@@ -351,4 +354,11 @@ + goto fail; + } ++ ++#ifdef WITH_MDN ++ /* ++ * Initialize MDN stuff. ++ */ ++ ns_lwdmdn_initialize(); ++#endif + + if (lwres->searchlist != NULL) { +--- ./bin/named/main.c.orig Fri Dec 1 16:45:13 2000 ++++ ./bin/named/main.c Fri Dec 1 16:47:42 2000 +@@ -277,5 +277,9 @@ + isc_commandline_errprint = ISC_FALSE; + while ((ch = isc_commandline_parse(argc, argv, ++#ifdef WITH_MDN /* Additional option 'M'. */ ++ "c:C:d:fgi:lM:n:N:p:P:st:u:vx:")) != ++#else + "c:C:d:fgi:ln:N:p:P:st:u:vx:")) != ++#endif + -1) { + switch (ch) { +@@ -311,4 +315,9 @@ + ns_g_lwresdonly = ISC_TRUE; + break; ++#ifdef WITH_MDN ++ case 'M': ++ lwresd_g_mdnconffile = isc_commandline_argument; ++ break; ++#endif + case 'N': /* Deprecated. */ + case 'n': diff --git a/contrib/idn/mdnkit/tools/Makefile.in b/contrib/idn/mdnkit/tools/Makefile.in new file mode 100644 index 0000000000..dfee66b8e1 --- /dev/null +++ b/contrib/idn/mdnkit/tools/Makefile.in @@ -0,0 +1,73 @@ +# $Id: Makefile.in,v 1.6 2000/07/19 05:00:16 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. + +srcdir = @srcdir@ +VPATH = @srcdir@ + +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +SUBDIRS = mdnconv runmdn + +all: + for d in $(SUBDIRS); do (cd $$d; $(MAKE) all); done + +install: + for d in $(SUBDIRS); do (cd $$d; $(MAKE) install); done + +clean: + for d in $(SUBDIRS); do (cd $$d; $(MAKE) clean); done diff --git a/contrib/idn/mdnkit/tools/mdnconv/Makefile.in b/contrib/idn/mdnkit/tools/mdnconv/Makefile.in new file mode 100644 index 0000000000..ac101b8b57 --- /dev/null +++ b/contrib/idn/mdnkit/tools/mdnconv/Makefile.in @@ -0,0 +1,109 @@ +# $Id: Makefile.in,v 1.11 2000/11/17 06:53:23 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. + +top_builddir = ../.. + +srcdir = @srcdir@ +VPATH = @srcdir@ + +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +BINDIR = @bindir@ +LIBDIR = @libdir@ +MANDIR = @mandir@ + +CC = @CC@ +RANLIB = @RANLIB@ +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +SHELL = @SHELL@ +LIBTOOL = @LIBTOOL@ + +OPTS = +INCS = -I$(srcdir)/../../include -I../../include +DEFS = + +CFLAGS = $(OPTS) $(INCS) $(DEFS) @CFLAGS@ + +SRCS = mdnconv.c util.c +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) + +install: install-prog install-man + +install-prog: mdnconv + [ -d $(BINDIR) ] || mkdir $(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 + +clean: + rm -f *.o mdnconv *.core core *~ diff --git a/contrib/idn/mdnkit/tools/mdnconv/README.ja b/contrib/idn/mdnkit/tools/mdnconv/README.ja new file mode 100644 index 0000000000..93cabdde51 --- /dev/null +++ b/contrib/idn/mdnkit/tools/mdnconv/README.ja @@ -0,0 +1,117 @@ + + 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 $ diff --git a/contrib/idn/mdnkit/tools/mdnconv/mdnconv.1 b/contrib/idn/mdnkit/tools/mdnconv/mdnconv.1 new file mode 100644 index 0000000000..1ef431ba63 --- /dev/null +++ b/contrib/idn/mdnkit/tools/mdnconv/mdnconv.1 @@ -0,0 +1,304 @@ +.\" $Id: mdnconv.1,v 1.11 2000/11/17 07:18:58 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 MDNCONV 1 "June 30, 2000" +.\" +.SH NAME +mdnconv \- codeset converter for named.conf and zone master files +.\" +.SH SYNOPSIS +\fBmdnconv\fP [\fIoptions..\fP] [\fIfile\fP...] +.\" +.SH DESCRIPTION +.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, +and writes the converted text to stdout. +If file name is specified, +.B mdnconv +converts the contents of the file. Otherwise, +.B mdnconv +converts stdin. +.PP +.B mdnconv +is specifically designed for converting internatinalized domain names, +and may not be suitable as a general codeset converter. +.SH OPTIONS +.TP 4 +\fB\-in\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 +.IP "\(bu" 2 +``UTF-5'' +.IP "\(bu" 2 +``RACE'' +.IP "\(bu" 2 +``BRACE'' +.IP "\(bu" 2 +``LACE'' +.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. +.TP 4 +\fB\-out\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). +.TP 4 +\fB\-normalize\fP \fIscheme\fP +Perform normalization specified by \fIscheme\fP. +Currently, following \fIscheme\fPs are available: +.RS 4 +.IP ``ascii-uppercase'' +ASCII lowercase to uppercase mapping. +.IP ``ascii-lowercase'' +ASCII uppercase to lowercase mapping. +.IP ``unicode-uppercase'' +Unicode lowercase to uppercase mapping, which is described in +``Unicode Technical Report #21: Case Mappings'', +available from unicode.org. +.IP ``unicode-lowercase'' +Unicode uppercase to lowercase mapping, according ``Case Mappings''. +.IP ``unicode-form-c'' +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 +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. +.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. +.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. +.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). +.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. +.TP 4 +\fB\-whole\fP +Perform normalization 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. +See ``CONVERSION MECHANISM'' for details. +.TP 4 +\fB\-alias\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 + +.ft P +.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. +.SH CONVERSION MECHANISM +Here is a brief step-by-step description of how +.B mdnconv +does its job. +.IP "1. input-side convnersion" 4 +.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. +.IP "2. finding where to process" 4 +Then +.B mdnconv +looks for (part of) internationalized domain name in the converted line, +and picks them up for further processing. +.br +.B mdnconv +recognizes the character sequence having the following property as +the internationalized domain name. +.RS 4 +.IP "\(bu" 2 +containing at least one non-ASCII character, and +.IP "\(bu" 2 +consisting of legal domain name characters (alphabets, digits, hypens), +non-ASCII characters and period. +.RE +.IP "" 4 +If you are not quite sure what this means (as I), +the following regular expression may help you. +.nf +.ft CW + + [-A-Za-z0-9.]*([-A-Za-z0-9.]|)* + +.ft P +.fi +For example, only ``www.###.com'' will be picked up from +the following lines (`#' denotes non-ASCII character). +.nf +.ft CW + + www.###.com. IN CNAME serv.xyz.com. + serv.xyz.com. IN A 10.0.0.1 + +.ft P +.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 +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. +.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. + +`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'. +.RS 4 +.nf +.ft CW + +\&.SUFFIXES: .lc .utf8 +\&.lc.utf8: + mdnconv -in $(LOCALCODE) -out UTF-8 $(MDNCONVOPT) $< > $@ + +LOCALCODE = EUC-JP +MDNCONVOPT = -normalize unicode-form-c + +DESTFILES = db.zone1.utf8 db.zone2.utf8 + +all: $(DESTFILES) +.ft +.fi +.RE +.\" +.SH SEE ALSO +mdnres.conf(5), +iconv(3) (if your system has one) +.\" +.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. diff --git a/contrib/idn/mdnkit/tools/mdnconv/mdnconv.c b/contrib/idn/mdnkit/tools/mdnconv/mdnconv.c new file mode 100644 index 0000000000..49ad838f1b --- /dev/null +++ b/contrib/idn/mdnkit/tools/mdnconv/mdnconv.c @@ -0,0 +1,397 @@ +#ifndef lint +static char *rcsid = "$Id: mdnconv.c,v 1.19 2000/09/13 05:55:55 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. + */ + +/* + * mdnconv -- Codeset converter for named.conf and zone files + */ + +#include + +#include +#include +#include +#include +#include +#include +#ifdef HAVE_LOCALE_H +#include +#endif + +#include +#include +#include +#include +#include +#include + +#include "util.h" + +/* Maxmum number of normalizers */ +#define MAX_NORMALIZER 10 + +#ifndef MDN_UTF8_ENCODING_NAME +#define MDN_UTF8_ENCODING_NAME "UTF-8" +#endif + +#ifndef MDN_RACE_ENCODING_NAME +#define MDN_RACE_ENCODING_NAME "RACE" +#endif + +#ifndef MDN_RACE_PREFIX +#define MDN_RACE_PREFIX "bq--" +#endif + +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 */ + +void errormsg(const char *fmt, ...); +static int convert_file(FILE *fp, char *zld, int auto_zld, + int selective); +static void usage(char *cmd); + +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 *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; + FILE *fp; + mdn_resconf_t resconf; + +#ifdef HAVE_SETLOCALE + (void)setlocale(LC_ALL, ""); +#endif + + zld[0] = '\0'; + + ac--; + av++; + while (ac > 0 && **av == '-') { + +#define MUST_HAVE_ARG if (ac < 2) usage(cmd) + if (strcmp(*av, "-in") == 0) { + MUST_HAVE_ARG; + in_code = av[1]; + ac--; + av++; + } else if (strcmp(*av, "-out") == 0) { + MUST_HAVE_ARG; + out_code = av[1]; + ac--; + av++; + } else if (strcmp(*av, "-conf") == 0) { + MUST_HAVE_ARG; + resconf_file = av[1]; + ac--; + av++; + } else if (strcmp(*av, "-noconf") == 0) { + no_resconf = 1; + } else if (strcmp(*av, "-zld") == 0) { + MUST_HAVE_ARG; + canonical_zld(zld, av[1]); + zld_specified = 1; + ac--; + av++; + } else if (strcmp(*av, "-auto") == 0) { + auto_zld = 1; + } else if (strcmp(*av, "-normalize") == 0) { + MUST_HAVE_ARG; + if (nnormalizer >= MAX_NORMALIZER) { + errormsg("too many normalizers\n"); + exit(1); + } + normalizer[nnormalizer++] = av[1]; + ac--; + av++; + } else if (strcmp(*av, "-alias") == 0) { + MUST_HAVE_ARG; + encoding_alias = *av; + } else if (strcmp(*av, "-flush") == 0) { + flush_every_line = 1; + } else if (strcmp(*av, "-whole") == 0) { + selective = 0; + } else { + usage(cmd); + } +#undef MUST_HAVE_ARG + + ac--; + av++; + } + + if (ac > 1) + usage(cmd); + + /* + * Load configuration file. + */ + resconf = NULL; + if (!no_resconf) { + mdn_result_t r; + + r = mdn_resconf_initialize(); + if (r == mdn_success) + r = mdn_resconf_create(&resconf); + if (r == mdn_success) + r = mdn_resconf_loadfile(resconf, resconf_file); + if (r != mdn_success) { + errormsg("error reading configuration file: %s\n", + mdn_result_tostring(r)); + return (1); + } + } + + /* + * 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); + } + + 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); + } + + /* + * Initialize codeset converter. + */ + if (!initialize_converter(in_code, out_code, encoding_alias)) + return (1); + + /* + * Initialize normalizer. + */ + if (nnormalizer == 0 && resconf != NULL) + norm_ctx = mdn_resconf_normalizer(resconf); + if (norm_ctx == NULL && + !initialize_normalizer(normalizer, nnormalizer)) + return (1); + + /* + * Default ZLD. + */ + if (!zld_specified && resconf != NULL) { + const char *conf_zld = mdn_resconf_zld(resconf); + if (conf_zld != NULL) + canonical_zld(zld, conf_zld); + } + + /* + * Open input file. + */ + if (ac > 0) { + if ((fp = fopen(av[0], "r")) == NULL) { + errormsg("cannot open file %s: %s\n", + av[0], strerror(errno)); + return (1); + } + } else { + fp = stdin; + } + + /* + * Do the conversion. + */ + return convert_file(fp, zld, auto_zld, selective); +} + +static int +convert_file(FILE *fp, char *zld, int auto_zld, int selective) { + mdn_result_t r; + char line1[1024]; + char line2[1024]; + int nl_trimmed; + int race_hack; + + if (strcmp(mdn_converter_localencoding(conv_in_ctx), + MDN_RACE_ENCODING_NAME) == 0) + race_hack = 1; + else + race_hack = 0; + + line_number = 1; + while (fgets(line1, sizeof(line1), fp) != NULL) { + /* + * Trim newline at the end. This is needed for + * those ascii-comatible encodings such as UTF-5 or RACE + * not to try converting newlines, which will result + * in `invalid encoding' error. + */ + if (line1[strlen(line1) - 1] == '\n') { + line1[strlen(line1) - 1] = '\0'; + nl_trimmed = 1; + } else { + nl_trimmed = 0; + } + + /* + * Convert input line to UTF-8. + */ + if (race_hack) { + /* + * Find portions encoded in RACE using RACE's prefix + * "bq--", and selectively decode those portions. + */ + r = selective_decode(MDN_RACE_PREFIX, + line1, line2, 1024); + } else { + r = mdn_converter_localtoutf8(conv_in_ctx, + line1, line2, 1024); + } + if (r != mdn_success) { + errormsg("conversion failed at line %d: %s\n", + line_number, + mdn_result_tostring(r)); + return (1); + } + if (!mdn_utf8_isvalidstring(line2)) { + errormsg("conversion to utf-8 failed at line %d\n", + line_number); + return (1); + } + + /* + * Normalize and convert to the output codeset. + */ + if (selective) { + r = selective_encode(line2, line1, sizeof(line1), + zld, auto_zld); + } else { + r = encode_region(line2, line1, sizeof(line1), + zld, auto_zld); + } + if (r != mdn_success) + return (1); + + fputs(line1, stdout); + if (nl_trimmed) + putc('\n', stdout); + + if (flush_every_line) + fflush(stdout); + + line_number++; + } + return (0); +} + +void +errormsg(const char *fmt, ...) { + va_list args; + + va_start(args, fmt); + vfprintf(stderr, fmt, args); + va_end(args); +} + +static void +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); + + for (i = 0; options[i] != NULL; i++) + fprintf(stderr, "\t%s\n", options[i]); + + exit(1); +} diff --git a/contrib/idn/mdnkit/tools/mdnconv/util.c b/contrib/idn/mdnkit/tools/mdnconv/util.c new file mode 100644 index 0000000000..47f6fe1d01 --- /dev/null +++ b/contrib/idn/mdnkit/tools/mdnconv/util.c @@ -0,0 +1,424 @@ +#ifndef lint +static char *rcsid = "$Id: util.c,v 1.7 2000/11/02 00:45:18 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 + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#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 char *find_prefix(const char *str, const char *prefix); +static int ascii_tolower(int c); + +mdn_result_t +selective_encode(char *from, char *to, int tolen, + const char *zld, int auto_zld) +{ + for (;;) { + int len; + char *region_start, *region_end; + mdn_result_t r; + char save; + + /* + * Find the region that needs conversion. + */ + r = mdn_selectiveencode_findregion(from, ®ion_start, + ®ion_end); + if (r == mdn_notfound) { + /* + * Not found. Just copy the whole thing. + */ + if (tolen <= strlen(from)) + return (mdn_buffer_overflow); + (void)strcpy(to, from); + return (mdn_success); + } else if (r != mdn_success) { + /* This should not happen.. */ + errormsg("internal error at line %d: %s\n", + line_number, mdn_result_tostring(r)); + return (r); + } + + /* + * We have found a region to convert. + * First, copy the prefix part verbatim. + */ + len = region_start - from; + if (tolen < len) { + errormsg("internal buffer overflow at line %d\n", + line_number); + return (mdn_buffer_overflow); + } + (void)memcpy(to, from, len); + to += len; + tolen -= len; + + /* + * Terminate the region with NUL. + */ + save = *region_end; + *region_end = '\0'; + + /* + * Encode the region. + */ + r = encode_region(region_start, to, tolen, zld, auto_zld); + + /* + * Restore character. + */ + *region_end = save; + + if (r != mdn_success) + return (r); + + len = strlen(to); + to += len; + tolen -= len; + + from = region_end; + } +} + +mdn_result_t +encode_region(const char *region, char *to, int tolen, + const char *zld, int auto_zld) +{ + 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(const char *prefix, char *from, char *to, int tolen) { + char *p; + char save; + int len; + mdn_result_t r; + + while ((p = find_prefix(from, prefix)) != NULL) { + /* + * Copy up to the prefix. + */ + len = p - from; + if (tolen < len) + return (mdn_buffer_overflow); + (void)memcpy(to, from, len); + from = p; + to += len; + tolen -= len; + + /* + * Determine the extent. + */ + p += strlen(prefix); + while (('a' <= *p && *p <= 'z') || + ('A' <= *p && *p <= 'Z') || + ('0' <= *p && *p <= '9') || + *p == '-' || *p == '.') + p++; + + /* + * Convert selected area to UTF-8. + */ + save = *p; + *p = '\0'; + r = mdn_converter_localtoutf8(conv_in_ctx, from, to, tolen); + if (r != mdn_success) + return (r); + *p = save; + from = p; + len = strlen(to); + to += len; + tolen -= len; + } + + /* + * Copy the rest verbatim. + */ + len = strlen(from); + if (tolen < len + 1) /* +1 for NUL */ + return (mdn_buffer_overflow); + (void)strcpy(to, from); + + return (mdn_success); +} + +int +initialize_converter(const char *in_code, const char *out_code, + const char *encoding_alias) +{ + mdn_result_t r; + + if (encoding_alias != NULL && + (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); + } + if ((r = mdn_converter_create(in_code, &conv_in_ctx, 0)) + != mdn_success) { + errormsg("cannot create converter for codeset %s: %s\n", + in_code, mdn_result_tostring(r)); + return (0); + } + if ((r = mdn_converter_create(out_code, &conv_out_ctx, 0)) + != mdn_success) { + errormsg("cannot create converter for codeset %s: %s\n", + out_code, mdn_result_tostring(r)); + return (0); + } + return (1); +} + +int +initialize_normalizer(char **normalizer, int nnormalizer) { + mdn_result_t r; + int i; + + if ((r = mdn_normalizer_initialize()) != mdn_success) { + errormsg("normalizer initialization failed: %s\n", + mdn_result_tostring(r)); + return (0); + } + if ((r = mdn_normalizer_create(&norm_ctx)) != mdn_success) { + errormsg("cannot create normalizer: %s\n", + mdn_result_tostring(r)); + return (0); + } + 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); + } + } + return (1); +} + +static int +ascii_tolower(int c) { + if ('A' <= c && c <= 'Z') + return (c - 'A' + 'a'); + else + return (c); +} + +static char * +find_prefix(const char *str, const char *prefix) { + int top = ascii_tolower(prefix[0]); + size_t plen = strlen(prefix); + + while (*str != '\0') { + if ((*str == top || ascii_tolower(*str) == top) && + mdn_util_casematch(str, prefix, plen)) + return ((char *)str); + str++; + } + return (NULL); +} diff --git a/contrib/idn/mdnkit/tools/mdnconv/util.h b/contrib/idn/mdnkit/tools/mdnconv/util.h new file mode 100644 index 0000000000..f32c51ea62 --- /dev/null +++ b/contrib/idn/mdnkit/tools/mdnconv/util.h @@ -0,0 +1,72 @@ +/* $Id: util.h,v 1.2 2000/08/23 07:01:05 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. + */ + +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(const char *prefix, + 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); diff --git a/contrib/idn/mdnkit/tools/rpm/dnsproxy.init b/contrib/idn/mdnkit/tools/rpm/dnsproxy.init new file mode 100644 index 0000000000..fd0edefe16 --- /dev/null +++ b/contrib/idn/mdnkit/tools/rpm/dnsproxy.init @@ -0,0 +1,42 @@ +#!/bin/sh +# +# chkconfig: 345 60 10 +# description: This shell script takes care of starting and stopping +# dnsproxy (DNS proxy server). +# + +# Source function library. +. /etc/rc.d/init.d/functions + +# Source networking configuration. +. /etc/sysconfig/network + +# Check that networking is up. +[ ${NETWORKING} = "no" ] && exit 0 + +[ -f /usr/sbin/dnsproxy ] || exit 0 + +[ -f /etc/dnsproxy.conf ] || exit 0 + +# See how we were called. +case "$1" in + start) + # Start daemons. + echo -n "Starting dnsproxy: " + daemon dnsproxy -daemon + echo + touch /var/lock/subsys/dnsproxy + ;; + stop) + # Stop daemons. + echo -n "Shutting down dnsproxy: " + killproc dnsproxy + echo "done" + rm -f /var/lock/subsys/dnsproxy + ;; + *) + echo "Usage: dnsproxy {start|stop}" + exit 1 +esac + +exit 0 diff --git a/contrib/idn/mdnkit/tools/rpm/mdnkit.spec b/contrib/idn/mdnkit/tools/rpm/mdnkit.spec new file mode 100644 index 0000000000..592e8b9af7 --- /dev/null +++ b/contrib/idn/mdnkit/tools/rpm/mdnkit.spec @@ -0,0 +1,116 @@ +%define name mdnkit +%define version 1.2 +%define disttop %{name}-%{version}-src +%define bind_version 8.2.2-P7 +%define serial 2000112701 + +Name: %{name} +Version: %{version} +Release: 1 +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: dnsproxy.patch1 +BuildRoot: /var/tmp/%{name}-root +Serial: %{serial} +Summary: multilingual Domain Name evaluation kit (mDNkit/JPNIC) +Vendor: JPNIC +Packager: Japan Network Information Center + +%description +mDNkit is a kit for evaluating various proposed methods regarding +multilingualized/internationalized DNS. + +%package devel +Group: Development/Libraries +Summary: The development files for mDNkit + +%description devel +The header files and library(libmdn.a) to develop applications +that use MDN library. + +%prep +%setup -n %{disttop} +#%patch0 -p0 -b .patch1 + +%build +if [ -f /usr/lib/libiconv.a -o -f /usr/lib/libiconv.so ] +then + ICONV="--with-iconv=yes" +fi + +CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=/usr --sysconfdir=/etc $ICONV +make + +%install +rm -fr $RPM_BUILD_ROOT +mkdir -p $RPM_BUILD_ROOT +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/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 + +install -c -m 755 tools/rpm/dnsproxy.init $RPM_BUILD_ROOT/etc/rc.d/init.d/dnsproxy + +# devel kit +#install -c lib/libmdn.a $RPM_BUILD_ROOT/usr/lib +#cp -r include/mdn $RPM_BUILD_ROOT/usr/include + +# 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 -r patch rpm_docs + +%clean +rm -fr $RPM_BUILD_ROOT + +%changelog +* Mon Nov 27 2000 Makoto Ishisone +- 1.2 release + +* Thu Nov 2 2000 MANABE Takashi +- 1.1 release + +* Fri Oct 27 2000 MANABE Takashi +- dnsproxy.patch1 +- move libmdnresolv.{la,so} from mdnkit-devel to mdnkit package + +* Wed Oct 18 2000 MANABE Takashi +- 1.0 release + +%files +%defattr(-, root, root) +/usr/sbin/dnsproxy +/usr/bin/mdnconv +/usr/bin/runmdn +/etc/rc.d/init.d/dnsproxy +/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 +%attr(0644, root, man) /usr/man/man1/mdnconv.1 +%attr(0644, root, man) /usr/man/man1/runmdn.1 +%attr(0644, root, man) /usr/man/man5/mdnres.conf.5 +%attr(0644, root, man) /usr/man/man8/dnsproxy.8 +%doc rpm_docs/* + +%files devel +%defattr(-, root, root) +/usr/lib/libmdn.a +/usr/lib/libmdn.la +/usr/lib/libmdn.so +/usr/lib/libmdnresolv.a +/usr/include/mdn/* +%doc lib/README diff --git a/contrib/idn/mdnkit/tools/runmdn/Makefile.in b/contrib/idn/mdnkit/tools/runmdn/Makefile.in new file mode 100644 index 0000000000..895b4b24fb --- /dev/null +++ b/contrib/idn/mdnkit/tools/runmdn/Makefile.in @@ -0,0 +1,146 @@ +# $Id: Makefile.in,v 1.12 2000/11/21 02:29:53 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. + +LIB_CURRENT=4 +LIB_REVISION=0 + +.SUFFIXES: .lo + +top_builddir = ../.. + +srcdir = @srcdir@ +VPATH = @srcdir@ + +prefix = @prefix@ +exec_prefix = @exec_prefix@ +bindir = @bindir@ +libdir = @libdir@ +mandir = @mandir@ + +CC = @CC@ +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_DATA = @INSTALL_DATA@ +SHELL = @SHELL@ +LIBTOOL = @LIBTOOL@ + +OPTS = +INCS = -I$(srcdir)/../../include -I../../include +DEFS = +CFLAGS = $(INCS) $(OPTS) $(DEFS) @CFLAGS@ +LDFLAGS = @LDFLAGS@ + +LIB = libmdnresolv +OBJS = res_comp.lo ns_name.lo $(MDNOBJS) +SCRIPT = runmdn + +MDNDIR = ../../lib +MDNOBJS = \ + $(MDNDIR)/converter.lo \ + $(MDNDIR)/debug.lo \ + $(MDNDIR)/dn.lo \ + $(MDNDIR)/localencoding.lo \ + $(MDNDIR)/log.lo \ + $(MDNDIR)/normalizer.lo \ + $(MDNDIR)/race.lo \ + $(MDNDIR)/res.lo \ + $(MDNDIR)/resconf.lo \ + $(MDNDIR)/result.lo \ + $(MDNDIR)/strhash.lo \ + $(MDNDIR)/translator.lo \ + $(MDNDIR)/unicode.lo \ + $(MDNDIR)/unormalize.lo \ + $(MDNDIR)/utf5.lo \ + $(MDNDIR)/utf8.lo \ + $(MDNDIR)/util.lo \ + $(MDNDIR)/zldrule.lo + +ICONVLIB = @ICONVLIB@ + +.c.lo: + $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c $< + +all: $(LIB).la + +$(LIB).la: $(OBJS) + $(LIBTOOL) --mode=link $(LD) $(LDFLAGS) -o $@ \ + -version-info $(LIB_CURRENT):$(LIB_REVISION) \ + -module -rpath $(libdir) $(OBJS) + +install: install-lib install-script install-man + +install-script: + [ -d $(bindir) ] || mkdir $(bindir) + $(INSTALL_SCRIPT) $(SCRIPT) $(bindir) + +install-lib: + [ -d $(libdir) ] || mkdir $(libdir) + $(LIBTOOL) --mode=install $(INSTALL_DATA) libmdnresolv.la $(libdir) + +install-man: + [ -d $(mandir) ] || mkdir $(mandir) + [ -d $(mandir)/man1 ] || mkdir $(mandir)/man1 + $(INSTALL_DATA) $(srcdir)/runmdn.1 $(mandir)/man1 + +clean: + rm -f *.lo *.la *.o + +realclean: + rm -f Makefile runmdn config.cache config.log config.status libtool + rm -f *.lo *.la *.o *~ + rm -fr .libs/ diff --git a/contrib/idn/mdnkit/tools/runmdn/ns_name.c b/contrib/idn/mdnkit/tools/runmdn/ns_name.c new file mode 100644 index 0000000000..2781302f99 --- /dev/null +++ b/contrib/idn/mdnkit/tools/runmdn/ns_name.c @@ -0,0 +1,695 @@ +/* + * 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 + +#include +#include + +#include +#include +#include +#include + +#include +#include + +#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 new file mode 100644 index 0000000000..6382dc68f6 --- /dev/null +++ b/contrib/idn/mdnkit/tools/runmdn/res_comp.c @@ -0,0 +1,238 @@ +/* + * 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 +#include +#include +#include +#include +#include +#include + +/* + * 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