Blob Blame History Raw
--- jwhois-3.2.3/configure.in.idn	2005-07-09 20:47:12.000000000 +0200
+++ jwhois-3.2.3/configure.in	2006-10-31 17:13:39.000000000 +0100
@@ -117,9 +117,32 @@
 AC_CHECK_FUNCS(memcpy strtol)
 AC_CHECK_FUNCS(strcasecmp strncasecmp getopt_long)
 AC_HEADER_STDC([])
-AC_CHECK_HEADERS(sys/types.h sys/socket.h netinet/in.h netdb.h sys/time.h sys/stat.h sys/fcntl.h malloc.h locale.h stdint.h inttypes.h)
+AC_CHECK_HEADERS(sys/types.h sys/socket.h netinet/in.h netdb.h sys/time.h sys/stat.h sys/fcntl.h malloc.h locale.h stdint.h inttypes.h idna.h)
 AC_HEADER_TIME
 
+
+AC_ARG_WITH(libidn, AC_HELP_STRING([--with-libidn=[DIR]],
+                                     [Support IDN (needs GNU Libidn)]),
+       libidn=$withval, libidn=yes)
+ if test "$libidn" != "no"; then
+   if test "$libidn" != "yes"; then
+     LDFLAGS="${LDFLAGS} -L$libidn/lib"
+     CPPFLAGS="${CPPFLAGS} -I$libidn/include"
+   fi
+   AC_CHECK_HEADER(idna.h,
+     AC_CHECK_LIB(idn, stringprep_check_version,
+       [libidn=yes LIBS="${LIBS} -lidn"], libidn=no),
+     libidn=no)
+ fi
+ if test "$libidn" != "no" ; then
+  AC_DEFINE(LIBIDN, 1, [Define to 1 if you want IDN support.])
+ else
+  AC_MSG_WARN([Libidn not found])
+fi
+AC_MSG_CHECKING([if Libidn should be used])
+AC_MSG_RESULT($libidn)
+
+
 found=no
 if test x$cache = xyes; then
   AC_CHECK_FUNC(dbm_open,
--- jwhois-3.2.3/src/jwhois.c.idn	2005-01-15 17:10:14.000000000 +0100
+++ jwhois-3.2.3/src/jwhois.c	2006-10-31 17:15:00.000000000 +0100
@@ -53,6 +53,10 @@
 
 #include <string.h>
 
+#ifdef LIBIDN
+# include <idna.h>
+#endif
+
 #ifdef ENABLE_NLS
 # include <libintl.h>
 # define _(s)  gettext(s)
@@ -65,8 +69,8 @@
 int
 main(int argc, char **argv)
 {
-  int optind, count = 0, ret;
-  char *qstring = NULL, *text, *cachestr;
+  int optind, count = 0, ret, rc = 0;
+  char *qstring = NULL, *text, *cachestr, *idn;
   struct s_whois_query wq;
 
 #ifdef ENABLE_NLS
@@ -106,7 +110,18 @@
       optind++;
     }
   qstring[strlen(qstring)-1] = '\0';
+#ifdef LIBIDN
+  rc = idna_to_ascii_lz(qstring, &idn, 0);
+  if (rc != IDNA_SUCCESS)
+    {
+      printf("[IDN encoding of '%s' failed with error code %d]\n", qstring, rc);
+      exit(1);
+    }
+  wq.query = strdup(idn);
+  free(idn);
+#else
   wq.query = qstring;
+#endif
 
   if (ghost)
     {
--- jwhois-3.2.3/src/Makefile.am.idn	2005-07-09 20:00:42.000000000 +0200
+++ jwhois-3.2.3/src/Makefile.am	2006-10-31 17:15:50.000000000 +0100
@@ -23,7 +23,7 @@
 	getopt.c getopt1.c jconfig.c string.c cache.c rwhois.c jwhois.c \
 	whois.c http.c
 
-jwhois_LIBS = @LIBINTL@ @LIBS@
+jwhois_LIBS = @LIBINTL@ @LIBICONV@ @LIBS@ 
 
 jwhois_CFLAGS = $(OLDCFLAGS) -DSYSCONFDIR="\"$(sysconfdir)\"" \
          -DLOCALSTATEDIR="\"$(localstatedir)\"" \