* Mozilla IDN patch -- builtin version --

To apply this patch,
	% cd mozilla_top_dir_where_README_file_resides
	% patch -p0 < this_patch_file

This patch doesn't contain a patch to `configure' script because even
the small version difference to the script may cause the patch to fail.
So after applying it, you have to re-generate `configure' by running
`autoconf'.
	% autoconf

Then run `configure' with `--with-mdnkit' option.
	% ./configure --with-mdnkit=/usr/local

The rest is the same as the standard compilation/installation process.

This patch modifies the following files:
    aclocal.m4
    config/autoconf.mk.in
    configure.in
    modules/libpref/src/init/all.js
    netwerk/dns/src/Makefile.in
    netwerk/build/nsNetModule.cpp
    netwerk/build/Makefile.in
and creates the following files:
    build/autoconf/mdnkit.m4
    netwerk/dns/src/nsIDNService.cpp
    netwerk/dns/src/nsIDNService.h

*** configure.in.orig	Wed Jan 30 11:40:06 2002
--- configure.in	Wed Jan 30 11:40:06 2002
***************
*** 4122,4127 ****
--- 4122,4132 ----
  AC_SUBST(MOZ_INTERNAL_LIBART_LGPL)
  
  dnl ========================================================
+ dnl Check for mDNkit
+ dnl ========================================================
+ AM_PATH_MDNKIT
+ 
+ dnl ========================================================
  dnl disable xul
  dnl ========================================================
  MOZ_XUL=1
*** aclocal.m4.orig	Wed Jan 30 11:40:06 2002
--- aclocal.m4	Wed Jan 30 11:40:06 2002
***************
*** 10,15 ****
--- 10,16 ----
  builtin(include, build/autoconf/libart.m4)dnl
  builtin(include, build/autoconf/pkg.m4)dnl
  builtin(include, build/autoconf/freetype2.m4)dnl
+ builtin(include, build/autoconf/mdnkit.m4)dnl
  dnl
  define(MOZ_TOPSRCDIR,.)dnl MOZ_TOPSRCDIR is used in altoptions.m4
  builtin(include, build/autoconf/altoptions.m4)dnl
*** build/autoconf/mdnkit.m4.orig	Wed Jan 30 11:41:42 2002
--- build/autoconf/mdnkit.m4	Wed Jan 30 11:40:42 2002
***************
*** 0 ****
--- 1,18 ----
+ # Configure paths for mDNkit (minimal version)
+ 
+ AC_DEFUN(AM_PATH_MDNKIT,
+ [dnl
+ mdnkit_prefix=no
+ AC_ARG_WITH(mdnkit,[  --with-mdnkit=PFX    Prefix where mDNkit is installed (default=/usr/local)],
+ 	mdnkit_prefix="$withval")
+   if test x$mdnkit_prefix = xyes ; then
+ 	mdnkit_prefix=/usr/local
+   fi
+   if test x$mdnkit_prefix != xno ; then
+       MDN_CFLAGS="-I$mdnkit_prefix/include"
+       MDN_LIBS="-L$mdnkit_prefix/lib -lmdnlite"
+   fi
+ 
+   AC_SUBST(MDN_CFLAGS)
+   AC_SUBST(MDN_LIBS)
+ ])
*** config/autoconf.mk.in.orig	Wed Jan 16 14:09:18 2002
--- config/autoconf.mk.in	Tue Jan 22 10:33:56 2002
***************
*** 145,151 ****
  OS_COMPILE_CFLAGS = $(OS_CPPFLAGS) @COMPILE_CFLAGS@
  OS_COMPILE_CXXFLAGS = $(OS_CPPFLAGS) @COMPILE_CXXFLAGS@
  
! OS_INCLUDES	= $(NSPR_CFLAGS) $(JPEG_CFLAGS) $(PNG_CFLAGS) $(MNG_CFLAGS) $(ZLIB_CFLAGS)
  OS_LIBS		= @LIBS@
  ACDEFINES	= @DEFS@
  
--- 145,151 ----
  OS_COMPILE_CFLAGS = $(OS_CPPFLAGS) @COMPILE_CFLAGS@
  OS_COMPILE_CXXFLAGS = $(OS_CPPFLAGS) @COMPILE_CXXFLAGS@
  
! OS_INCLUDES	= $(NSPR_CFLAGS) $(JPEG_CFLAGS) $(PNG_CFLAGS) $(MNG_CFLAGS) $(ZLIB_CFLAGS) $(MDN_CFLAGS)
  OS_LIBS		= @LIBS@
  ACDEFINES	= @DEFS@
  
***************
*** 271,276 ****
--- 271,279 ----
  
  LDAP_CFLAGS	= @LDAP_CFLAGS@
  LDAP_LIBS	= @LDAP_LIBS@
+ 
+ MDN_CFLAGS	= @MDN_CFLAGS@
+ MDN_LIBS	= @MDN_LIBS@
  
  # MKSHLIB_FORCE_ALL is used to force the linker to include all object
  # files present in an archive. MKSHLIB_UNFORCE_ALL reverts the linker
*** netwerk/dns/src/Makefile.in.orig	Wed Jan 30 11:43:23 2002
--- netwerk/dns/src/Makefile.in	Thu Jan 31 10:47:32 2002
***************
*** 32,38 ****
  		  string \
  		  pref \
  		  $(NULL)
! CPPSRCS		= nsDnsService.cpp
  
  # we don't want the shared lib, but we want to force the creation of a
  # static lib.
--- 32,38 ----
  		  string \
  		  pref \
  		  $(NULL)
! CPPSRCS		= nsDnsService.cpp nsIDNService.cpp
  
  # we don't want the shared lib, but we want to force the creation of a
  # static lib.
*** netwerk/dns/src/nsIDNService.cpp.orig	Wed Jan 30 11:42:57 2002
--- netwerk/dns/src/nsIDNService.cpp	Wed Jan 30 17:09:14 2002
***************
*** 0 ****
--- 1,135 ----
+ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+ /*
+  * Copyright (c) 2002 Japan Network Information Center.  All rights reserved.
+  *  
+  * By using this file, you agree to the terms and conditions set forth bellow.
+  * 
+  * 			LICENSE TERMS AND CONDITIONS 
+  * 
+  * The following License Terms and Conditions apply, unless a different
+  * license is obtained from Japan Network Information Center ("JPNIC"),
+  * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
+  * Chiyoda-ku, Tokyo 101-0047, Japan.
+  * 
+  * 1. Use, Modification and Redistribution (including distribution of any
+  *    modified or derived work) in source and/or binary forms is permitted
+  *    under this License Terms and Conditions.
+  * 
+  * 2. Redistribution of source code must retain the copyright notices as they
+  *    appear in each source code file, this License Terms and Conditions.
+  * 
+  * 3. Redistribution in binary form must reproduce the Copyright Notice,
+  *    this License Terms and Conditions, in the documentation and/or other
+  *    materials provided with the distribution.  For the purposes of binary
+  *    distribution the "Copyright Notice" refers to the following language:
+  *    "Copyright (c) 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 "nsIDNService.h"
+ 
+ #include "nsMemory.h"
+ #include "nsError.h"
+ #include "nsCOMPtr.h"
+ #include "plstr.h"
+ 
+ extern "C" {
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <mdn/api.h>
+ }
+ 
+ /******************************************************************************
+  *  Platform specific defines and includes
+  *****************************************************************************/
+ 
+ /**
+  *  XP_MAC
+  */
+ 
+ /**
+  *  XP_UNIX
+  */
+ 
+ /**
+  *  XP_WIN
+  */
+ 
+ 
+ /******************************************************************************
+  *  nsIDNService
+  *****************************************************************************/
+ 
+ NS_IMPL_ISUPPORTS1(nsIDNService, nsIIDNService);
+ 
+ nsIDNService::nsIDNService()
+ {
+     NS_INIT_ISUPPORTS();
+ }
+ 
+ nsIDNService::~nsIDNService()
+ {
+ }
+ 
+ NS_IMETHODIMP
+ nsIDNService::UTF8ToIDNHostName(const char *utf8, char **idn)
+ {
+     NS_ENSURE_ARG_POINTER(idn);
+ 
+     char *buf = NULL;
+     PRUint32 utf8len = PL_strlen(utf8);
+     PRUint32 bufsize = utf8len * 4 + 8;  // usually large enough
+                                          // (+8 for ACE prefix and NUL)
+     *idn = NULL;
+ 
+     for (;;) {
+         char *newbuf = (char *) realloc(buf, bufsize);
+ 
+         if (newbuf == NULL)
+             return NS_ERROR_OUT_OF_MEMORY;
+         buf = newbuf;
+ 
+         mdn_result_t r = mdn_encodename(MDN_ENCODE_APP, utf8, buf, bufsize);
+         if (r == mdn_success)
+             break;
+         else if (r != mdn_buffer_overflow) {
+             PL_strcpy(buf, utf8);
+             break;
+         }
+         bufsize += utf8len;
+     }
+ 
+     *idn = buf;
+     return NS_OK;
+ }
*** netwerk/dns/src/nsIDNService.h.orig	Wed Jan 30 11:42:57 2002
--- netwerk/dns/src/nsIDNService.h	Wed Jan 30 14:43:00 2002
***************
*** 0 ****
--- 1,88 ----
+ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+ /*
+  * Copyright (c) 2002 Japan Network Information Center.  All rights reserved.
+  *  
+  * By using this file, you agree to the terms and conditions set forth bellow.
+  * 
+  * 			LICENSE TERMS AND CONDITIONS 
+  * 
+  * The following License Terms and Conditions apply, unless a different
+  * license is obtained from Japan Network Information Center ("JPNIC"),
+  * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
+  * Chiyoda-ku, Tokyo 101-0047, Japan.
+  * 
+  * 1. Use, Modification and Redistribution (including distribution of any
+  *    modified or derived work) in source and/or binary forms is permitted
+  *    under this License Terms and Conditions.
+  * 
+  * 2. Redistribution of source code must retain the copyright notices as they
+  *    appear in each source code file, this License Terms and Conditions.
+  * 
+  * 3. Redistribution in binary form must reproduce the Copyright Notice,
+  *    this License Terms and Conditions, in the documentation and/or other
+  *    materials provided with the distribution.  For the purposes of binary
+  *    distribution the "Copyright Notice" refers to the following language:
+  *    "Copyright (c) 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 nsIDNService_h__
+ #define nsIDNService_h__
+ 
+ #include "nsIIDNService.h"
+ #include "nsCOMPtr.h"
+ 
+ #define NS_IDNSERVICE_CID \
+ { /* 468C5EEA-1DC3-45c6-87AB-2992D03BB3A2 */         \
+     0x468c5eea,                                      \
+     0x1dc3,                                          \
+     0x45c6,                                          \
+     {0x87, 0xab, 0x29, 0x92, 0xd0, 0x3b, 0xb3, 0xa2} \
+ }
+ 
+ /******************************************************************************
+  *  nsIDNService
+  *****************************************************************************/
+ class nsIDNService : public nsIIDNService
+ {
+ public: 
+     NS_DECL_ISUPPORTS
+     NS_DECL_NSIIDNSERVICE
+ 
+     // nsIDNService methods:
+     nsIDNService();
+     virtual ~nsIDNService();
+ };
+ 
+ #endif /* nsIDNService_h__ */
*** netwerk/build/nsNetModule.cpp.orig	Fri Jan 11 09:07:34 2002
--- netwerk/build/nsNetModule.cpp	Wed Jan 30 12:00:24 2002
***************
*** 138,143 ****
--- 138,148 ----
  
  ///////////////////////////////////////////////////////////////////////////////
  
+ #include "nsIDNService.h"
+ NS_GENERIC_FACTORY_CONSTRUCTOR(nsIDNService)
+ 
+ ///////////////////////////////////////////////////////////////////////////////
+ 
  static NS_METHOD
  RegisterBuiltInURLParsers(nsIComponentManager *aCompMgr, 
                            nsIFile *aPath,
***************
*** 604,609 ****
--- 609,618 ----
        NS_DNSSERVICE_CID,
        "@mozilla.org/network/dns-service;1",
        nsDNSService::Create },
+      { "IDN Service",
+        NS_IDNSERVICE_CID,
+        NS_IDNSERVICE_CONTRACTID,
+        nsIDNServiceConstructor },
      { NS_SIMPLEURI_CLASSNAME,
        NS_SIMPLEURI_CID,
        NS_SIMPLEURI_CONTRACTID,
*** netwerk/build/Makefile.in.orig	Wed Dec 19 07:19:21 2001
--- netwerk/build/Makefile.in	Tue Jan 22 10:28:36 2002
***************
*** 94,99 ****
--- 94,100 ----
  		$(MOZ_COMPONENT_LIBS) \
  		$(MOZ_UNICHARUTIL_LIBS) \
  		$(ZLIB_LIBS) \
+ 		$(MDN_LIBS) \
  		$(NULL)
  
  include $(topsrcdir)/config/rules.mk
*** modules/libpref/src/init/all.js.orig	Tue Jan 22 10:47:05 2002
--- modules/libpref/src/init/all.js	Tue Jan 22 10:47:19 2002
***************
*** 452,458 ****
  pref("signon.rememberSignons",              true);
  pref("signon.expireMasterPassword",         false);
  pref("network.enablePad",                   false); // Allow client to do proxy autodiscovery
! pref("network.enableIDN",                   false); // Turn on/off IDN (Internationalized Domain Name) resolution
  pref("converter.html2txt.structs",          true); // Output structured phrases (strong, em, code, sub, sup, b, i, u)
  pref("converter.html2txt.header_strategy",  1); // 0 = no indention; 1 = indention, increased with header level; 2 = numbering and slight indention
  pref("wallet.captureForms",                 true);
--- 452,458 ----
  pref("signon.rememberSignons",              true);
  pref("signon.expireMasterPassword",         false);
  pref("network.enablePad",                   false); // Allow client to do proxy autodiscovery
! pref("network.enableIDN",                   true); // Turn on/off IDN (Internationalized Domain Name) resolution
  pref("converter.html2txt.structs",          true); // Output structured phrases (strong, em, code, sub, sup, b, i, u)
  pref("converter.html2txt.header_strategy",  1); // 0 = no indention; 1 = indention, increased with header level; 2 = numbering and slight indention
  pref("wallet.captureForms",                 true);