Index: ncftp3/README.v6
diff -u /dev/null ncftp3/README.v6:1.1
--- /dev/null	Mon Jan 20 08:18:31 2003
+++ ncftp3/README.v6	Tue Aug  6 14:06:35 2002
@@ -0,0 +1,2 @@
+If you have problem/trouble/suggestion for IPv6 related code,
+Please contact to core@kame.net
Index: ncftp3/config.h.in
diff -u ncftp3/config.h.in:1.1.1.9 ncftp3/config.h.in:1.11
--- ncftp3/config.h.in:1.1.1.9	Thu May 30 23:40:29 2002
+++ ncftp3/config.h.in	Mon Jun 17 03:02:32 2002
@@ -222,6 +222,9 @@
 /* Define if you have the doupdate function.  */
 #undef HAVE_DOUPDATE
 
+/* Define if you have the getaddrinfo function.  */
+#undef HAVE_GETADDRINFO
+
 /* Define if you have the fstat64 function.  */
 #undef HAVE_FSTAT64
 
@@ -243,6 +246,9 @@
 /* Define if you have the gethostname function.  */
 #undef HAVE_GETHOSTNAME
 
+/* Define if you have the getaddrname function.  */
+#undef HAVE_GETNAMEINFO
+
 /* Define if you have the getlogin_r function.  */
 #undef HAVE_GETLOGIN_R
 
@@ -342,6 +348,9 @@
 /* Define if you have the snprintf function.  */
 #undef HAVE_SNPRINTF
 
+/* Define if sockaddr has sa_len member */
+#undef HAVE_SOCKADDR_SA_LEN
+
 /* Define if you have the stat64 function.  */
 #undef HAVE_STAT64
 
@@ -488,3 +497,19 @@
 
 /* Define if you have the socket library (-lsocket).  */
 #undef HAVE_LIBSOCKET
+
+/* Define if you have the socks5 library (-lsocks5).  */
+#undef HAVE_LIBSOCKS5
+
+/* Define if you want IPv6 support. */
+#undef ENABLE_IPV6
+
+/* Define if sockaddr has sa_len member */
+#undef HAVE_SOCKADDR_SA_LEN
+
+/* Define if sockaddr_storage has ss_family member */
+#undef HAVE_SOCKADDR_STORAGE_SS_FAMILY
+
+/* Define if sockaddr_storage has __ss_family member */
+#undef HAVE_SOCKADDR_STORAGE___SS_FAMILY
+
Index: ncftp3/configure
diff -u ncftp3/configure:1.1.1.13 ncftp3/configure:1.26
--- ncftp3/configure:1.1.1.13	Sun Jan 12 11:25:55 2003
+++ ncftp3/configure	Sun Jan 12 11:45:18 2003
@@ -21,6 +21,9 @@
   --without-ncurses       do not try to find and use the ncurses library"
 ac_help="$ac_help
   --with-socks5           try to find and use the SOCKS5 library"
+ac_help="$ac_help
+  --enable-ipv6		Enable ipv6 (with ipv4) support
+  --disable-ipv6		Disable ipv6 support"
 
 # Initialize some variables set by options.
 # The variables have the same names as the options, with
@@ -38,6 +41,7 @@
 program_transform_name=s,x,x,
 silent=
 site=
+sitefile=
 srcdir=
 target=NONE
 verbose=
@@ -152,6 +156,7 @@
   --help                  print this message
   --no-create             do not create output files
   --quiet, --silent       do not print \`checking...' messages
+  --site-file=FILE        use FILE as the site file
   --version               print the version of autoconf that created configure
 Directory and file names:
   --prefix=PREFIX         install architecture-independent files in PREFIX
@@ -322,6 +327,11 @@
   -site=* | --site=* | --sit=*)
     site="$ac_optarg" ;;
 
+  -site-file | --site-file | --site-fil | --site-fi | --site-f)
+    ac_prev=sitefile ;;
+  -site-file=* | --site-file=* | --site-fil=* | --site-fi=* | --site-f=*)
+    sitefile="$ac_optarg" ;;
+
   -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
     ac_prev=srcdir ;;
   -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
@@ -487,12 +497,16 @@
 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"
+if test -z "$sitefile"; then
+  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
+else
+  CONFIG_SITE="$sitefile"
 fi
 for ac_site_file in $CONFIG_SITE; do
   if test -r "$ac_site_file"; then
@@ -595,30 +609,28 @@
 
 
 
-
-
 echo $ac_n "checking if you set and exported the environment variable CC""... $ac_c" 1>&6
-echo "configure:602: checking if you set and exported the environment variable CC" >&5
+echo "configure:614: checking if you set and exported the environment variable CC" >&5
 if test "x$CC" = x ; then
 	echo "$ac_t""no (you may want to do that since configure scripts look for gcc first)" 1>&6
 else
 	echo "$ac_t""$CC" 1>&6
 fi
 echo $ac_n "checking for environment variable CFLAGS""... $ac_c" 1>&6
-echo "configure:609: checking for environment variable CFLAGS" >&5
+echo "configure:621: checking for environment variable CFLAGS" >&5
 if test "x$CFLAGS" = x ; then
 	echo "$ac_t""no (we will choose a default set for you)" 1>&6
 else
 	echo "$ac_t""$CFLAGS" 1>&6
 fi
 echo $ac_n "checking for environment variable CPPFLAGS""... $ac_c" 1>&6
-echo "configure:616: checking for environment variable CPPFLAGS" >&5
+echo "configure:628: checking for environment variable CPPFLAGS" >&5
 echo "$ac_t""${CPPFLAGS-no}" 1>&6
 echo $ac_n "checking for environment variable LDFLAGS""... $ac_c" 1>&6
-echo "configure:619: checking for environment variable LDFLAGS" >&5
+echo "configure:631: checking for environment variable LDFLAGS" >&5
 echo "$ac_t""${LDFLAGS-no}" 1>&6
 echo $ac_n "checking for environment variable LIBS""... $ac_c" 1>&6
-echo "configure:622: checking for environment variable LIBS" >&5
+echo "configure:634: checking for environment variable LIBS" >&5
 echo "$ac_t""${LIBS-no}" 1>&6
 
 
@@ -1057,7 +1069,7 @@
 # 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:1061: checking for $ac_word" >&5
+echo "configure:1073: 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
@@ -1087,7 +1099,7 @@
   # 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:1091: checking for $ac_word" >&5
+echo "configure:1103: 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
@@ -1138,7 +1150,7 @@
       # 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:1142: checking for $ac_word" >&5
+echo "configure:1154: 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
@@ -1170,7 +1182,7 @@
 fi
 
 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:1174: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+echo "configure:1186: 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.
@@ -1181,12 +1193,12 @@
 
 cat > conftest.$ac_ext << EOF
 
-#line 1185 "configure"
+#line 1197 "configure"
 #include "confdefs.h"
 
 main(){return(0);}
 EOF
-if { (eval echo configure:1190: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1202: \"$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
@@ -1212,12 +1224,12 @@
   { 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:1216: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:1228: 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:1221: checking whether we are using GNU C" >&5
+echo "configure:1233: 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
@@ -1226,7 +1238,7 @@
   yes;
 #endif
 EOF
-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1230: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1242: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
   ac_cv_prog_gcc=yes
 else
   ac_cv_prog_gcc=no
@@ -1245,7 +1257,7 @@
 ac_save_CFLAGS="$CFLAGS"
 CFLAGS=
 echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
-echo "configure:1249: checking whether ${CC-cc} accepts -g" >&5
+echo "configure:1261: 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
@@ -1278,7 +1290,7 @@
 
 
 echo $ac_n "checking if the C compiler can use precompiled headers""... $ac_c" 1>&6
-echo "configure:1282: checking if the C compiler can use precompiled headers" >&5
+echo "configure:1294: checking if the C compiler can use precompiled headers" >&5
 if eval "test \"`echo '$''{'wi_cv_cc_precomp'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1301,14 +1313,14 @@
 	${CC-cc} $CPPFLAGS -precomp pchtest.h -o pchtest.p >&5 2>&5
 	if test -s pchtest.p ; then
 		cat > conftest.$ac_ext <<EOF
-#line 1305 "configure"
+#line 1317 "configure"
 #include "confdefs.h"
 #include "pchtest.h"
 int main() {
 if (FOOBAR == 33) exit(0)
 ; return 0; }
 EOF
-if { (eval echo configure:1312: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1324: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   result="yes" ; wi_cv_cc_precomp_type="gcc_dash_precomp"
 else
@@ -1375,7 +1387,7 @@
 	wi_request_no_y2k_warnings=yes
 
 echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:1379: checking how to run the C preprocessor" >&5
+echo "configure:1391: checking how to run the C preprocessor" >&5
 # On Suns, sometimes $CPP names a directory.
 if test -n "$CPP" && test -d "$CPP"; then
   CPP=
@@ -1390,13 +1402,13 @@
   # On the NeXT, cc -E runs the code through the compiler's parser,
   # not just through cpp.
   cat > conftest.$ac_ext <<EOF
-#line 1394 "configure"
+#line 1406 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1400: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1412: \"$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
   :
@@ -1407,13 +1419,13 @@
   rm -rf conftest*
   CPP="${CC-cc} -E -traditional-cpp"
   cat > conftest.$ac_ext <<EOF
-#line 1411 "configure"
+#line 1423 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1417: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1429: \"$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
   :
@@ -1424,13 +1436,13 @@
   rm -rf conftest*
   CPP="${CC-cc} -nologo -E"
   cat > conftest.$ac_ext <<EOF
-#line 1428 "configure"
+#line 1440 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1434: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1446: \"$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
   :
@@ -1461,7 +1473,7 @@
 
 if test "$ac_cv_prog_gcc" = yes ; then
 	echo $ac_n "checking the version of GCC""... $ac_c" 1>&6
-echo "configure:1465: checking the version of GCC" >&5
+echo "configure:1477: checking the version of GCC" >&5
 if eval "test \"`echo '$''{'wi_cv_gcc_version'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1484,7 +1496,7 @@
 	wi_cv_sunwspro_cc_version2="0"
 else
 	echo $ac_n "checking if the C compiler is Sun WorkShop C""... $ac_c" 1>&6
-echo "configure:1488: checking if the C compiler is Sun WorkShop C" >&5
+echo "configure:1500: checking if the C compiler is Sun WorkShop C" >&5
 if eval "test \"`echo '$''{'wi_cv_cc_is_sunwspro_cc'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1518,14 +1530,14 @@
 echo "$ac_t""$wi_cv_cc_is_sunwspro_cc" 1>&6
 	if test "$wi_cv_cc_is_sunwspro_cc" = yes ; then
 		echo $ac_n "checking output of "cc -V" to determine version of Sun WorkShop C""... $ac_c" 1>&6
-echo "configure:1522: checking output of "cc -V" to determine version of Sun WorkShop C" >&5
+echo "configure:1534: checking output of "cc -V" to determine version of Sun WorkShop C" >&5
 		echo "$ac_t"""version $wi_cv_sunwspro_cc_version"" 1>&6
 	fi
 fi
 
 	
 echo $ac_n "checking if we should customize your CFLAGS environment variable""... $ac_c" 1>&6
-echo "configure:1529: checking if we should customize your CFLAGS environment variable" >&5
+echo "configure:1541: checking if we should customize your CFLAGS environment variable" >&5
 wi_replace_O_with_g="no"
 case "$wi_orig_CFLAGS" in
 	"")
@@ -1713,14 +1725,14 @@
 				# accepts this flag...
 				#
 				cat > conftest.$ac_ext <<EOF
-#line 1717 "configure"
+#line 1729 "configure"
 #include "confdefs.h"
 
 int main() {
 int junk;
 ; return 0; }
 EOF
-if { (eval echo configure:1724: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1736: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   :
 else
   echo "configure: failed program was:" >&5
@@ -1746,7 +1758,7 @@
 	# Was it ./configure --enable-debug ?
 	#
 	echo $ac_n "checking if this is a debug build""... $ac_c" 1>&6
-echo "configure:1750: checking if this is a debug build" >&5
+echo "configure:1762: checking if this is a debug build" >&5
 	if test "$DEBUGBUILD" = yes ; then
 		echo "$ac_t""yes" 1>&6
 		CFLAGS="$DEBUGCFLAGS"
@@ -1754,19 +1766,19 @@
 		echo "$ac_t""no" 1>&6
 	fi
 	echo $ac_n "checking NOOPTCFLAGS""... $ac_c" 1>&6
-echo "configure:1758: checking NOOPTCFLAGS" >&5
+echo "configure:1770: checking NOOPTCFLAGS" >&5
 	echo "$ac_t""$NOOPTCFLAGS" 1>&6
 	echo $ac_n "checking DEBUGCFLAGS""... $ac_c" 1>&6
-echo "configure:1761: checking DEBUGCFLAGS" >&5
+echo "configure:1773: checking DEBUGCFLAGS" >&5
 	echo "$ac_t""$DEBUGCFLAGS" 1>&6
 	echo $ac_n "checking CFLAGS""... $ac_c" 1>&6
-echo "configure:1764: checking CFLAGS" >&5
+echo "configure:1776: checking CFLAGS" >&5
 	echo "$ac_t""$CFLAGS" 1>&6
 
 if test "os_${os}_gcc_${ac_cv_prog_gcc}" = os_hp-ux_gcc_yes ; then
 	
 echo $ac_n "checking if -D__STDC_EXT__ is needed with GCC on HP-UX""... $ac_c" 1>&6
-echo "configure:1770: checking if -D__STDC_EXT__ is needed with GCC on HP-UX" >&5
+echo "configure:1782: checking if -D__STDC_EXT__ is needed with GCC on HP-UX" >&5
 if test "$cross_compiling" = yes; then
   
 	# action if cross-compiling, guess
@@ -1775,7 +1787,7 @@
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 1779 "configure"
+#line 1791 "configure"
 #include "confdefs.h"
 
 #include <stdio.h>
@@ -1791,7 +1803,7 @@
 #endif
 }
 EOF
-if { (eval echo configure:1795: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1807: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
 	# action if true
@@ -1828,7 +1840,7 @@
 		;;
 esac
 echo $ac_n "checking if we should add to CFLAGS for LFS64 support""... $ac_c" 1>&6
-echo "configure:1832: checking if we should add to CFLAGS for LFS64 support" >&5
+echo "configure:1844: checking if we should add to CFLAGS for LFS64 support" >&5
 echo "$ac_t""$CFLAGS" 1>&6
 
 
@@ -1840,7 +1852,7 @@
 		;;
 esac
 echo $ac_n "checking if we should add -D_REENTRANT to CFLAGS""... $ac_c" 1>&6
-echo "configure:1844: checking if we should add -D_REENTRANT to CFLAGS" >&5
+echo "configure:1856: checking if we should add -D_REENTRANT to CFLAGS" >&5
 echo "$ac_t""$CFLAGS" 1>&6
 
 
@@ -1870,13 +1882,13 @@
 STRIPFLAG="$SFLAG"
 
 echo $ac_n "checking for object suffix""... $ac_c" 1>&6
-echo "configure:1874: checking for object suffix" >&5
+echo "configure:1886: checking for object suffix" >&5
 if eval "test \"`echo '$''{'ac_cv_objext'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   rm -f conftest*
 echo 'int i = 1;' > conftest.$ac_ext
-if { (eval echo configure:1880: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1892: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   for ac_file in conftest.*; do
     case $ac_file in
     *.c) ;;
@@ -1894,12 +1906,12 @@
 ac_objext=$ac_cv_objext
 
 echo $ac_n "checking for Cygwin environment""... $ac_c" 1>&6
-echo "configure:1898: checking for Cygwin environment" >&5
+echo "configure:1910: checking for Cygwin environment" >&5
 if eval "test \"`echo '$''{'ac_cv_cygwin'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1903 "configure"
+#line 1915 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -1910,7 +1922,7 @@
 return __CYGWIN__;
 ; return 0; }
 EOF
-if { (eval echo configure:1914: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1926: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_cygwin=yes
 else
@@ -1927,19 +1939,19 @@
 CYGWIN=
 test "$ac_cv_cygwin" = yes && CYGWIN=yes
 echo $ac_n "checking for mingw32 environment""... $ac_c" 1>&6
-echo "configure:1931: checking for mingw32 environment" >&5
+echo "configure:1943: checking for mingw32 environment" >&5
 if eval "test \"`echo '$''{'ac_cv_mingw32'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1936 "configure"
+#line 1948 "configure"
 #include "confdefs.h"
 
 int main() {
 return __MINGW32__;
 ; return 0; }
 EOF
-if { (eval echo configure:1943: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1955: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_mingw32=yes
 else
@@ -1958,7 +1970,7 @@
 
 
 echo $ac_n "checking for executable suffix""... $ac_c" 1>&6
-echo "configure:1962: checking for executable suffix" >&5
+echo "configure:1974: checking for executable suffix" >&5
 if eval "test \"`echo '$''{'ac_cv_exeext'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1968,10 +1980,10 @@
   rm -f conftest*
   echo 'int main () { return 0; }' > conftest.$ac_ext
   ac_cv_exeext=
-  if { (eval echo configure:1972: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
+  if { (eval echo configure:1984: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
     for file in conftest.*; do
       case $file in
-      *.c | *.o | *.obj) ;;
+      *.c | *.C | *.o | *.obj | *.ilk | *.pdb) ;;
       *) ac_cv_exeext=`echo $file | sed -e s/conftest//` ;;
       esac
     done
@@ -2002,7 +2014,7 @@
 
 if test "${SYS-sunos}" = sunos ; then
 	echo $ac_n "checking for System V compatibility directories""... $ac_c" 1>&6
-echo "configure:2006: checking for System V compatibility directories" >&5
+echo "configure:2018: checking for System V compatibility directories" >&5
 	echo "$ac_t""" 1>&6
 	
 incdir=""/usr/5include""
@@ -2045,12 +2057,12 @@
 
 
 echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:2049: checking for ANSI C header files" >&5
+echo "configure:2061: checking for ANSI C header files" >&5
 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2054 "configure"
+#line 2066 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 #include <stdarg.h>
@@ -2058,7 +2070,7 @@
 #include <float.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2062: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2074: \"$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*
@@ -2075,7 +2087,7 @@
 if test $ac_cv_header_stdc = yes; then
   # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 2079 "configure"
+#line 2091 "configure"
 #include "confdefs.h"
 #include <string.h>
 EOF
@@ -2093,7 +2105,7 @@
 if test $ac_cv_header_stdc = yes; then
   # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 2097 "configure"
+#line 2109 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 EOF
@@ -2114,7 +2126,7 @@
   :
 else
   cat > conftest.$ac_ext <<EOF
-#line 2118 "configure"
+#line 2130 "configure"
 #include "confdefs.h"
 #include <ctype.h>
 #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@@ -2125,7 +2137,7 @@
 exit (0); }
 
 EOF
-if { (eval echo configure:2129: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2141: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   :
 else
@@ -2152,17 +2164,17 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:2156: checking for $ac_hdr" >&5
+echo "configure:2168: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2161 "configure"
+#line 2173 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2166: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2178: \"$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*
@@ -2189,12 +2201,12 @@
 done
 
 echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
-echo "configure:2193: checking whether time.h and sys/time.h may both be included" >&5
+echo "configure:2205: checking whether time.h and sys/time.h may both be included" >&5
 if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2198 "configure"
+#line 2210 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/time.h>
@@ -2203,7 +2215,7 @@
 struct tm *tp;
 ; return 0; }
 EOF
-if { (eval echo configure:2207: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2219: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_header_time=yes
 else
@@ -2235,17 +2247,17 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:2239: checking for $ac_hdr" >&5
+echo "configure:2251: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2244 "configure"
+#line 2256 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2249: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2261: \"$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*
@@ -2272,7 +2284,7 @@
 done
 
 	echo $ac_n "checking for UNIX domain sockets""... $ac_c" 1>&6
-echo "configure:2276: checking for UNIX domain sockets" >&5
+echo "configure:2288: checking for UNIX domain sockets" >&5
 if eval "test \"`echo '$''{'wi_cv_unix_domain_sockets'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2284,7 +2296,7 @@
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 2288 "configure"
+#line 2300 "configure"
 #include "confdefs.h"
 
 #if defined(AIX) || defined(_AIX) || defined(__HOS_AIX__)
@@ -2310,7 +2322,7 @@
 	exit(0);			/* do have UNIX domain sockets */
 }
 EOF
-if { (eval echo configure:2314: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2326: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
 	# action if true
@@ -2340,13 +2352,13 @@
 	fi
 	
 echo $ac_n "checking for sun_len field in struct sockaddr_un""... $ac_c" 1>&6
-echo "configure:2344: checking for sun_len field in struct sockaddr_un" >&5
+echo "configure:2356: checking for sun_len field in struct sockaddr_un" >&5
 if eval "test \"`echo '$''{'wi_cv_sockaddr_un_sun_len'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
 cat > conftest.$ac_ext <<EOF
-#line 2350 "configure"
+#line 2362 "configure"
 #include "confdefs.h"
 
 	/* includes */
@@ -2365,7 +2377,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:2369: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2381: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   
 	wi_cv_sockaddr_un_sun_len=yes
@@ -2407,12 +2419,12 @@
 # Mostly for SunOS 4 -- needs to come first because other libs depend on it
 
 echo $ac_n "checking for strerror""... $ac_c" 1>&6
-echo "configure:2411: checking for strerror" >&5
+echo "configure:2423: checking for strerror" >&5
 if eval "test \"`echo '$''{'ac_cv_func_strerror'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2416 "configure"
+#line 2428 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char strerror(); below.  */
@@ -2435,7 +2447,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:2439: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2451: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_strerror=yes"
 else
@@ -2458,7 +2470,7 @@
 if test "$a" = no ; then
 	# Not in libc, try lib44bsd.
 	echo $ac_n "checking for strerror in -l44bsd""... $ac_c" 1>&6
-echo "configure:2462: checking for strerror in -l44bsd" >&5
+echo "configure:2474: checking for strerror in -l44bsd" >&5
 ac_lib_var=`echo 44bsd'_'strerror | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2466,7 +2478,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-l44bsd  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2470 "configure"
+#line 2482 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -2477,7 +2489,7 @@
 strerror()
 ; return 0; }
 EOF
-if { (eval echo configure:2481: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2493: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2509,12 +2521,12 @@
 
 
 echo $ac_n "checking for socket""... $ac_c" 1>&6
-echo "configure:2513: checking for socket" >&5
+echo "configure:2525: checking for socket" >&5
 if eval "test \"`echo '$''{'ac_cv_func_socket'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2518 "configure"
+#line 2530 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char socket(); below.  */
@@ -2537,7 +2549,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:2541: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2553: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_socket=yes"
 else
@@ -2560,7 +2572,7 @@
 if test "$a" = no ; then
 	# Not in libc, try libsocket.
 	echo $ac_n "checking for socket in -lsocket""... $ac_c" 1>&6
-echo "configure:2564: checking for socket in -lsocket" >&5
+echo "configure:2576: 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
@@ -2568,7 +2580,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2572 "configure"
+#line 2584 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -2579,7 +2591,7 @@
 socket()
 ; return 0; }
 EOF
-if { (eval echo configure:2583: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2595: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2614,7 +2626,7 @@
 		unixware2*)
 			# So far, only UnixWare needs this.
 			echo $ac_n "checking for syslog in -lgen""... $ac_c" 1>&6
-echo "configure:2618: checking for syslog in -lgen" >&5
+echo "configure:2630: checking for syslog in -lgen" >&5
 ac_lib_var=`echo gen'_'syslog | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2622,7 +2634,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lgen  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2626 "configure"
+#line 2638 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -2633,7 +2645,7 @@
 syslog()
 ; return 0; }
 EOF
-if { (eval echo configure:2637: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2649: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2680,12 +2692,12 @@
 			# AC_CHECK_FUNC(socket,[a=yes],[a=no])
 			#
 			echo $ac_n "checking for socket""... $ac_c" 1>&6
-echo "configure:2684: checking for socket" >&5
+echo "configure:2696: checking for socket" >&5
 if eval "test \"`echo '$''{'ac_cv_func_socket'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2689 "configure"
+#line 2701 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char socket(); below.  */
@@ -2708,7 +2720,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:2712: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2724: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_socket=yes"
 else
@@ -2741,7 +2753,7 @@
 	hpux1123456789*)
 		# HP-UX 11 uses NSL for YP services
 		echo $ac_n "checking for getpwent in -lnsl""... $ac_c" 1>&6
-echo "configure:2745: checking for getpwent in -lnsl" >&5
+echo "configure:2757: checking for getpwent in -lnsl" >&5
 ac_lib_var=`echo nsl'_'getpwent | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2749,7 +2761,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lnsl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2753 "configure"
+#line 2765 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -2760,7 +2772,7 @@
 getpwent()
 ; return 0; }
 EOF
-if { (eval echo configure:2764: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2776: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2791,12 +2803,12 @@
 
 	*)
 		echo $ac_n "checking for gethostbyname""... $ac_c" 1>&6
-echo "configure:2795: checking for gethostbyname" >&5
+echo "configure:2807: checking for gethostbyname" >&5
 if eval "test \"`echo '$''{'ac_cv_func_gethostbyname'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2800 "configure"
+#line 2812 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char gethostbyname(); below.  */
@@ -2819,7 +2831,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:2823: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2835: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_gethostbyname=yes"
 else
@@ -2842,7 +2854,7 @@
 		if test "$a" = no ; then
 			# Not in libc, try libnsl.
 			echo $ac_n "checking for gethostbyname in -lnsl""... $ac_c" 1>&6
-echo "configure:2846: checking for gethostbyname in -lnsl" >&5
+echo "configure:2858: checking for gethostbyname in -lnsl" >&5
 ac_lib_var=`echo nsl'_'gethostbyname | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2850,7 +2862,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lnsl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2854 "configure"
+#line 2866 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -2861,7 +2873,7 @@
 gethostbyname()
 ; return 0; }
 EOF
-if { (eval echo configure:2865: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2877: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2897,7 +2909,7 @@
 # See if we could access two well-known sites without help of any special
 # libraries, like resolv.
 echo $ac_n "checking if we need to look for -lresolv""... $ac_c" 1>&6
-echo "configure:2901: checking if we need to look for -lresolv" >&5
+echo "configure:2913: checking if we need to look for -lresolv" >&5
 if eval "test \"`echo '$''{'wi_cv_look_for_resolv'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2911,7 +2923,7 @@
   wi_cv_look_for_resolv=yes
 else
   cat > conftest.$ac_ext <<EOF
-#line 2915 "configure"
+#line 2927 "configure"
 #include "confdefs.h"
 
 #if defined(AIX) || defined(_AIX) || defined(__HOS_AIX__)
@@ -2938,7 +2950,7 @@
 	exit(0);
 }
 EOF
-if { (eval echo configure:2942: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2954: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   wi_cv_look_for_resolv=no
 else
@@ -2957,7 +2969,7 @@
 
 if test "$wi_cv_look_for_resolv" = yes ; then
 echo $ac_n "checking for main in -lresolv""... $ac_c" 1>&6
-echo "configure:2961: checking for main in -lresolv" >&5
+echo "configure:2973: checking for main in -lresolv" >&5
 ac_lib_var=`echo resolv'_'main | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2965,14 +2977,14 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lresolv  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2969 "configure"
+#line 2981 "configure"
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
-if { (eval echo configure:2976: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2988: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3023,7 +3035,7 @@
 		#
 		if test "x$ac_cv_lib_db_main" = "x" ; then
 			echo $ac_n "checking for main in -ldb""... $ac_c" 1>&6
-echo "configure:3027: checking for main in -ldb" >&5
+echo "configure:3039: checking for main in -ldb" >&5
 ac_lib_var=`echo db'_'main | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3031,14 +3043,14 @@
   ac_save_LIBS="$LIBS"
 LIBS="-ldb  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3035 "configure"
+#line 3047 "configure"
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
-if { (eval echo configure:3042: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3054: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3061,7 +3073,7 @@
 		fi
 		if test "x$ac_cv_lib_isode_main" = "x" ; then
 			echo $ac_n "checking for main in -lisode""... $ac_c" 1>&6
-echo "configure:3065: checking for main in -lisode" >&5
+echo "configure:3077: checking for main in -lisode" >&5
 ac_lib_var=`echo isode'_'main | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3069,14 +3081,14 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lisode  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3073 "configure"
+#line 3085 "configure"
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
-if { (eval echo configure:3080: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3092: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3099,7 +3111,7 @@
 		fi
 		if test "x$ac_cv_lib_com_err_main" = "x" ; then
 			echo $ac_n "checking for main in -lcom_err""... $ac_c" 1>&6
-echo "configure:3103: checking for main in -lcom_err" >&5
+echo "configure:3115: checking for main in -lcom_err" >&5
 ac_lib_var=`echo com_err'_'main | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3107,14 +3119,14 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lcom_err  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3111 "configure"
+#line 3123 "configure"
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
-if { (eval echo configure:3118: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3130: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3137,7 +3149,7 @@
 		fi
 		if test "x$ac_cv_lib_crypto_main" = "x" ; then
 			echo $ac_n "checking for main in -lcrypto""... $ac_c" 1>&6
-echo "configure:3141: checking for main in -lcrypto" >&5
+echo "configure:3153: checking for main in -lcrypto" >&5
 ac_lib_var=`echo crypto'_'main | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3145,14 +3157,14 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lcrypto  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3149 "configure"
+#line 3161 "configure"
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
-if { (eval echo configure:3156: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3168: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3175,7 +3187,7 @@
 		fi
 		if test "x$ac_cv_lib_krb5_main" = "x" ; then
 			echo $ac_n "checking for main in -lkrb5""... $ac_c" 1>&6
-echo "configure:3179: checking for main in -lkrb5" >&5
+echo "configure:3191: checking for main in -lkrb5" >&5
 ac_lib_var=`echo krb5'_'main | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3183,14 +3195,14 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lkrb5  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3187 "configure"
+#line 3199 "configure"
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
-if { (eval echo configure:3194: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3206: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3213,7 +3225,7 @@
 		fi
 		if test "x$ac_cv_lib_gssapi_krb5_main" = "x" ; then
 			echo $ac_n "checking for main in -lgssapi_krb5""... $ac_c" 1>&6
-echo "configure:3217: checking for main in -lgssapi_krb5" >&5
+echo "configure:3229: checking for main in -lgssapi_krb5" >&5
 ac_lib_var=`echo gssapi_krb5'_'main | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3221,14 +3233,14 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lgssapi_krb5  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3225 "configure"
+#line 3237 "configure"
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
-if { (eval echo configure:3232: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3244: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3251,7 +3263,7 @@
 		fi
 
 		echo $ac_n "checking for SOCKSinit in -lsocks5""... $ac_c" 1>&6
-echo "configure:3255: checking for SOCKSinit in -lsocks5" >&5
+echo "configure:3267: checking for SOCKSinit in -lsocks5" >&5
 ac_lib_var=`echo socks5'_'SOCKSinit | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3259,7 +3271,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lsocks5  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3263 "configure"
+#line 3275 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -3270,7 +3282,7 @@
 SOCKSinit()
 ; return 0; }
 EOF
-if { (eval echo configure:3274: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3286: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3294,17 +3306,17 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:3298: checking for $ac_hdr" >&5
+echo "configure:3310: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3303 "configure"
+#line 3315 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3308: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3320: \"$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*
@@ -3343,7 +3355,7 @@
 		fi
 	fi
 	echo $ac_n "checking if SOCKS5 will be used""... $ac_c" 1>&6
-echo "configure:3347: checking if SOCKS5 will be used" >&5
+echo "configure:3359: checking if SOCKS5 will be used" >&5
 	echo "$ac_t""$ac_cv_lib_socks5_SOCKSinit" 1>&6
 
 
@@ -3352,23 +3364,23 @@
 	
 
 echo $ac_n "checking for curses library headers""... $ac_c" 1>&6
-echo "configure:3356: checking for curses library headers" >&5
+echo "configure:3368: checking for curses library headers" >&5
 if test "$wi_cv_ncurses" != "no" ; then
 	for ac_hdr in ncurses.h curses.h termios.h termio.h sgtty.h sys/ioctl.h
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:3362: checking for $ac_hdr" >&5
+echo "configure:3374: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3367 "configure"
+#line 3379 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3372: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3384: \"$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*
@@ -3399,17 +3411,17 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:3403: checking for $ac_hdr" >&5
+echo "configure:3415: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3408 "configure"
+#line 3420 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3413: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3425: \"$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*
@@ -3447,7 +3459,7 @@
 fi
 
 echo $ac_n "checking for curses library""... $ac_c" 1>&6
-echo "configure:3451: checking for curses library" >&5
+echo "configure:3463: checking for curses library" >&5
 
 wi_cv_lib_curses=no
 wi_cv_lib_curses_result=no
@@ -3466,7 +3478,7 @@
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 3470 "configure"
+#line 3482 "configure"
 #include "confdefs.h"
 
 	/* program */
@@ -3491,7 +3503,7 @@
 }
 
 EOF
-if { (eval echo configure:3495: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3507: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
 	# action if true
@@ -3556,12 +3568,12 @@
 
 
 echo $ac_n "checking for working const""... $ac_c" 1>&6
-echo "configure:3560: checking for working const" >&5
+echo "configure:3572: checking for working const" >&5
 if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3565 "configure"
+#line 3577 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -3610,7 +3622,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:3614: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3626: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_const=yes
 else
@@ -3631,12 +3643,12 @@
 fi
 
 echo $ac_n "checking for size_t""... $ac_c" 1>&6
-echo "configure:3635: checking for size_t" >&5
+echo "configure:3647: checking for size_t" >&5
 if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3640 "configure"
+#line 3652 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -3664,12 +3676,12 @@
 fi
 
 echo $ac_n "checking for off_t""... $ac_c" 1>&6
-echo "configure:3668: checking for off_t" >&5
+echo "configure:3680: checking for off_t" >&5
 if eval "test \"`echo '$''{'ac_cv_type_off_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3673 "configure"
+#line 3685 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -3697,12 +3709,12 @@
 fi
 
 echo $ac_n "checking for mode_t""... $ac_c" 1>&6
-echo "configure:3701: checking for mode_t" >&5
+echo "configure:3713: checking for mode_t" >&5
 if eval "test \"`echo '$''{'ac_cv_type_mode_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3706 "configure"
+#line 3718 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -3730,12 +3742,12 @@
 fi
 
 echo $ac_n "checking for pid_t""... $ac_c" 1>&6
-echo "configure:3734: checking for pid_t" >&5
+echo "configure:3746: checking for pid_t" >&5
 if eval "test \"`echo '$''{'ac_cv_type_pid_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3739 "configure"
+#line 3751 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -3763,12 +3775,12 @@
 fi
 
 echo $ac_n "checking for uid_t in sys/types.h""... $ac_c" 1>&6
-echo "configure:3767: checking for uid_t in sys/types.h" >&5
+echo "configure:3779: checking for uid_t in sys/types.h" >&5
 if eval "test \"`echo '$''{'ac_cv_type_uid_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3772 "configure"
+#line 3784 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 EOF
@@ -3798,7 +3810,7 @@
 
 
 echo $ac_n "checking what type main() should return""... $ac_c" 1>&6
-echo "configure:3802: checking what type main() should return" >&5
+echo "configure:3814: checking what type main() should return" >&5
 if eval "test \"`echo '$''{'wi_cv_main_void_return_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -3825,7 +3837,7 @@
 	fi
 
 echo $ac_n "checking for 64-bit integral type: long long""... $ac_c" 1>&6
-echo "configure:3829: checking for 64-bit integral type: long long" >&5
+echo "configure:3841: checking for 64-bit integral type: long long" >&5
 LONGEST_INT="long"
 if test "$cross_compiling" = yes; then
   
@@ -3834,7 +3846,7 @@
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 3838 "configure"
+#line 3850 "configure"
 #include "confdefs.h"
 
 	/* program */
@@ -3862,7 +3874,7 @@
 
 
 EOF
-if { (eval echo configure:3866: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3878: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
 	# action if true
@@ -3886,7 +3898,7 @@
 if test "$wi_cv_type_long_long" = yes ; then
 	
 echo $ac_n "checking how to print a 64-bit integral type""... $ac_c" 1>&6
-echo "configure:3890: checking how to print a 64-bit integral type" >&5
+echo "configure:3902: checking how to print a 64-bit integral type" >&5
 wi_cv_printf_long_long=fail
 
 if test "$cross_compiling" = yes; then
@@ -3896,7 +3908,7 @@
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 3900 "configure"
+#line 3912 "configure"
 #include "confdefs.h"
 
 	/* program */
@@ -3925,7 +3937,7 @@
 }
 
 EOF
-if { (eval echo configure:3929: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3941: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
 	# action if true
@@ -3954,7 +3966,7 @@
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 3958 "configure"
+#line 3970 "configure"
 #include "confdefs.h"
 
 	/* program */
@@ -3983,7 +3995,7 @@
 }
 
 EOF
-if { (eval echo configure:3987: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3999: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
 	# action if true
@@ -4013,7 +4025,7 @@
 
 	
 echo $ac_n "checking how to scan a 64-bit integral type""... $ac_c" 1>&6
-echo "configure:4017: checking how to scan a 64-bit integral type" >&5
+echo "configure:4029: checking how to scan a 64-bit integral type" >&5
 wi_cv_scanf_long_long=fail
 
 if test "$cross_compiling" = yes; then
@@ -4023,7 +4035,7 @@
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 4027 "configure"
+#line 4039 "configure"
 #include "confdefs.h"
 
 	/* program */
@@ -4055,7 +4067,7 @@
 }
 
 EOF
-if { (eval echo configure:4059: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:4071: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
 	# action if true
@@ -4084,7 +4096,7 @@
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 4088 "configure"
+#line 4100 "configure"
 #include "confdefs.h"
 
 	/* program */
@@ -4116,7 +4128,7 @@
 }
 
 EOF
-if { (eval echo configure:4120: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:4132: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
 	# action if true
@@ -4147,7 +4159,7 @@
 fi
 
 echo $ac_n "checking if everything was available to use the 64-bit integral type""... $ac_c" 1>&6
-echo "configure:4151: checking if everything was available to use the 64-bit integral type" >&5
+echo "configure:4163: checking if everything was available to use the 64-bit integral type" >&5
 
 if test "$wi_cv_type_long_long" = no ; then
 	wi_cv_use_long_long_msg_result="no (long long type not available)"
@@ -4226,7 +4238,7 @@
 
 wi_struct_timeval_field_checks="cached"
 echo $ac_n "checking what type the tv_sec field of struct timeval is""... $ac_c" 1>&6
-echo "configure:4230: checking what type the tv_sec field of struct timeval is" >&5
+echo "configure:4242: checking what type the tv_sec field of struct timeval is" >&5
 if eval "test \"`echo '$''{'wi_cv_struct_timeval_tv_sec'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4245,7 +4257,7 @@
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 4249 "configure"
+#line 4261 "configure"
 #include "confdefs.h"
 
 	/* program */
@@ -4325,7 +4337,7 @@
 }
 
 EOF
-if { (eval echo configure:4329: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:4341: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
 	# action if true
@@ -4354,11 +4366,11 @@
 echo "$ac_t""$wi_cv_struct_timeval_tv_sec" 1>&6
 if test "$wi_struct_timeval_field_checks" = "uncached" ; then
 	echo $ac_n "checking what type the tv_usec field of struct timeval is""... $ac_c" 1>&6
-echo "configure:4358: checking what type the tv_usec field of struct timeval is" >&5
+echo "configure:4370: checking what type the tv_usec field of struct timeval is" >&5
 	echo "$ac_t""$wi_cv_struct_timeval_tv_usec" 1>&6
 else
 	echo $ac_n "checking what type the tv_usec field of struct timeval is""... $ac_c" 1>&6
-echo "configure:4362: checking what type the tv_usec field of struct timeval is" >&5
+echo "configure:4374: checking what type the tv_usec field of struct timeval is" >&5
 if eval "test \"`echo '$''{'wi_cv_struct_timeval_tv_usec'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4380,7 +4392,7 @@
 # Extract the first word of ""perl"", so it can be a program name with args.
 set dummy "perl"; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:4384: checking for $ac_word" >&5
+echo "configure:4396: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_PERL'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4418,7 +4430,7 @@
 # Extract the first word of ""mktemp"", so it can be a program name with args.
 set dummy "mktemp"; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:4422: checking for $ac_word" >&5
+echo "configure:4434: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_MKTEMP'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4463,7 +4475,7 @@
 	fi
 
 echo $ac_n "checking for return type from write""... $ac_c" 1>&6
-echo "configure:4467: checking for return type from write" >&5
+echo "configure:4479: checking for return type from write" >&5
 if eval "test \"`echo '$''{'wi_cv_write_return_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4774,35 +4786,35 @@
 echo "$ac_t""$wi_cv_write_return_t" 1>&6
 if test "x$used_cache_for_wi_unistd_fpt" = "xno" ; then
 	echo $ac_n "checking for size parameter to write""... $ac_c" 1>&6
-echo "configure:4778: checking for size parameter to write" >&5
+echo "configure:4790: checking for size parameter to write" >&5
 	echo "$ac_t""$wi_cv_write_size_t" 1>&6
 	echo $ac_n "checking for return type from send""... $ac_c" 1>&6
-echo "configure:4781: checking for return type from send" >&5
+echo "configure:4793: checking for return type from send" >&5
 	echo "$ac_t""$wi_cv_send_return_t" 1>&6
 	echo $ac_n "checking for size parameter to send""... $ac_c" 1>&6
-echo "configure:4784: checking for size parameter to send" >&5
+echo "configure:4796: checking for size parameter to send" >&5
 	echo "$ac_t""$wi_cv_send_size_t" 1>&6
 	echo $ac_n "checking for size parameter to connect""... $ac_c" 1>&6
-echo "configure:4787: checking for size parameter to connect" >&5
+echo "configure:4799: checking for size parameter to connect" >&5
 	echo "$ac_t""$wi_cv_sockaddr_size_t" 1>&6
 	echo $ac_n "checking for size parameter to setsockopt""... $ac_c" 1>&6
-echo "configure:4790: checking for size parameter to setsockopt" >&5
+echo "configure:4802: checking for size parameter to setsockopt" >&5
 	echo "$ac_t""$wi_cv_sockopt_size_t" 1>&6
 	echo $ac_n "checking for backlog parameter to listen""... $ac_c" 1>&6
-echo "configure:4793: checking for backlog parameter to listen" >&5
+echo "configure:4805: checking for backlog parameter to listen" >&5
 	echo "$ac_t""$wi_cv_listen_backlog_t" 1>&6
 	echo $ac_n "checking for seconds parameter to alarm""... $ac_c" 1>&6
-echo "configure:4796: checking for seconds parameter to alarm" >&5
+echo "configure:4808: checking for seconds parameter to alarm" >&5
 	echo "$ac_t""$wi_cv_alarm_time_t" 1>&6
 	echo $ac_n "checking for address parameter to gethostbyaddr""... $ac_c" 1>&6
-echo "configure:4799: checking for address parameter to gethostbyaddr" >&5
+echo "configure:4811: checking for address parameter to gethostbyaddr" >&5
 	echo "$ac_t""$wi_cv_gethost_addrptr_t" 1>&6
 	echo $ac_n "checking for size parameter to gethostname""... $ac_c" 1>&6
-echo "configure:4802: checking for size parameter to gethostname" >&5
+echo "configure:4814: checking for size parameter to gethostname" >&5
 	echo "$ac_t""$wi_cv_gethostname_size_t" 1>&6
 else
 	echo $ac_n "checking for size parameter to write""... $ac_c" 1>&6
-echo "configure:4806: checking for size parameter to write" >&5
+echo "configure:4818: checking for size parameter to write" >&5
 if eval "test \"`echo '$''{'wi_cv_write_size_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4811,7 +4823,7 @@
 
 echo "$ac_t""$wi_cv_write_size_t" 1>&6
 	echo $ac_n "checking for return type from send""... $ac_c" 1>&6
-echo "configure:4815: checking for return type from send" >&5
+echo "configure:4827: checking for return type from send" >&5
 if eval "test \"`echo '$''{'wi_cv_send_return_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4820,7 +4832,7 @@
 
 echo "$ac_t""$wi_cv_send_return_t" 1>&6
 	echo $ac_n "checking for size parameter to send""... $ac_c" 1>&6
-echo "configure:4824: checking for size parameter to send" >&5
+echo "configure:4836: checking for size parameter to send" >&5
 if eval "test \"`echo '$''{'wi_cv_send_size_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4829,7 +4841,7 @@
 
 echo "$ac_t""$wi_cv_send_size_t" 1>&6
 	echo $ac_n "checking for size parameter to connect""... $ac_c" 1>&6
-echo "configure:4833: checking for size parameter to connect" >&5
+echo "configure:4845: checking for size parameter to connect" >&5
 if eval "test \"`echo '$''{'wi_cv_sockaddr_size_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4838,7 +4850,7 @@
 
 echo "$ac_t""$wi_cv_sockaddr_size_t" 1>&6
 	echo $ac_n "checking for size parameter to setsockopt""... $ac_c" 1>&6
-echo "configure:4842: checking for size parameter to setsockopt" >&5
+echo "configure:4854: checking for size parameter to setsockopt" >&5
 if eval "test \"`echo '$''{'wi_cv_sockopt_size_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4847,7 +4859,7 @@
 
 echo "$ac_t""$wi_cv_sockopt_size_t" 1>&6
 	echo $ac_n "checking for backlog parameter to listen""... $ac_c" 1>&6
-echo "configure:4851: checking for backlog parameter to listen" >&5
+echo "configure:4863: checking for backlog parameter to listen" >&5
 if eval "test \"`echo '$''{'wi_cv_listen_backlog_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4856,7 +4868,7 @@
 
 echo "$ac_t""$wi_cv_listen_backlog_t" 1>&6
 	echo $ac_n "checking for seconds parameter to alarm""... $ac_c" 1>&6
-echo "configure:4860: checking for seconds parameter to alarm" >&5
+echo "configure:4872: checking for seconds parameter to alarm" >&5
 if eval "test \"`echo '$''{'wi_cv_alarm_time_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4865,7 +4877,7 @@
 
 echo "$ac_t""$wi_cv_alarm_time_t" 1>&6
 	echo $ac_n "checking for address parameter to gethostbyaddr""... $ac_c" 1>&6
-echo "configure:4869: checking for address parameter to gethostbyaddr" >&5
+echo "configure:4881: checking for address parameter to gethostbyaddr" >&5
 if eval "test \"`echo '$''{'wi_cv_gethost_addrptr_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4874,7 +4886,7 @@
 
 echo "$ac_t""$wi_cv_gethost_addrptr_t" 1>&6
 	echo $ac_n "checking for size parameter to gethostname""... $ac_c" 1>&6
-echo "configure:4878: checking for size parameter to gethostname" >&5
+echo "configure:4890: checking for size parameter to gethostname" >&5
 if eval "test \"`echo '$''{'wi_cv_gethostname_size_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4948,7 +4960,7 @@
 	fi
 
 echo $ac_n "checking types of arguments for select()""... $ac_c" 1>&6
-echo "configure:4952: checking types of arguments for select()" >&5
+echo "configure:4964: checking types of arguments for select()" >&5
  if eval "test \"`echo '$''{'ac_cv_func_select_arg234'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4962,7 +4974,7 @@
      for ac_cv_func_select_arg1 in 'int' 'size_t' 'unsigned long' 'unsigned'; do
       for ac_cv_func_select_arg5 in 'struct timeval *' 'const struct timeval *'; do
        cat > conftest.$ac_ext <<EOF
-#line 4966 "configure"
+#line 4978 "configure"
 #include "confdefs.h"
 #if defined(AIX) || defined(_AIX) || defined(__HOS_AIX__)	/* MG */
 #	define _ALL_SOURCE 1	/* MG */
@@ -4981,7 +4993,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:4985: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4997: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
           ac_not_found=no ; break 3
 else
@@ -5021,9 +5033,9 @@
 
 
 echo $ac_n "checking for struct stat64""... $ac_c" 1>&6
-echo "configure:5025: checking for struct stat64" >&5
+echo "configure:5037: checking for struct stat64" >&5
 cat > conftest.$ac_ext <<EOF
-#line 5027 "configure"
+#line 5039 "configure"
 #include "confdefs.h"
 
 	/* includes */
@@ -5040,7 +5052,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:5044: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5056: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   
 	wi_cv_struct_stat64=yes
@@ -5067,9 +5079,9 @@
 	fi
 
 echo $ac_n "checking for sig_atomic_t""... $ac_c" 1>&6
-echo "configure:5071: checking for sig_atomic_t" >&5
+echo "configure:5083: checking for sig_atomic_t" >&5
 cat > conftest.$ac_ext <<EOF
-#line 5073 "configure"
+#line 5085 "configure"
 #include "confdefs.h"
 
 	/* includes */
@@ -5094,7 +5106,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:5098: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5110: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   
 	ac_cv_type_sig_atomic_t=yes
@@ -5118,7 +5130,7 @@
 
 
 echo $ac_n "checking how to access getopt() global variables""... $ac_c" 1>&6
-echo "configure:5122: checking how to access getopt() global variables" >&5
+echo "configure:5134: checking how to access getopt() global variables" >&5
 if eval "test \"`echo '$''{'wi_cv_getopt_decl'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -5129,7 +5141,7 @@
 	fi
 
 cat > conftest.$ac_ext <<EOF
-#line 5133 "configure"
+#line 5145 "configure"
 #include "confdefs.h"
 
 /* includes */
@@ -5148,7 +5160,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:5152: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5164: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   wi_cv_getopt_decl="automatic"
 else
@@ -5160,7 +5172,7 @@
 rm -f conftest*
 if test "$wi_cv_getopt_decl" = unknown ; then
 cat > conftest.$ac_ext <<EOF
-#line 5164 "configure"
+#line 5176 "configure"
 #include "confdefs.h"
 
 /* includes */
@@ -5180,7 +5192,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:5184: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5196: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   wi_cv_getopt_decl="getopt.h"
 else
@@ -5209,9 +5221,9 @@
 
 
 echo $ac_n "checking for useable _res global variable""... $ac_c" 1>&6
-echo "configure:5213: checking for useable _res global variable" >&5
+echo "configure:5225: checking for useable _res global variable" >&5
 cat > conftest.$ac_ext <<EOF
-#line 5215 "configure"
+#line 5227 "configure"
 #include "confdefs.h"
 
 	/* includes */
@@ -5238,7 +5250,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:5242: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5254: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   
 	wi_cv__res_defdname=yes
@@ -5259,13 +5271,13 @@
 echo "$ac_t""$wi_cv__res_defdname" 1>&6
 	
 echo $ac_n "checking for struct cmsghdr""... $ac_c" 1>&6
-echo "configure:5263: checking for struct cmsghdr" >&5
+echo "configure:5275: checking for struct cmsghdr" >&5
 if eval "test \"`echo '$''{'wi_cv_struct_cmsghdr'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
 cat > conftest.$ac_ext <<EOF
-#line 5269 "configure"
+#line 5281 "configure"
 #include "confdefs.h"
 
 	/* includes */
@@ -5286,7 +5298,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:5290: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5302: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   
 	wi_cv_struct_cmsghdr=yes
@@ -5312,13 +5324,13 @@
 fi
 	
 echo $ac_n "checking for msg_control field in struct msghdr""... $ac_c" 1>&6
-echo "configure:5316: checking for msg_control field in struct msghdr" >&5
+echo "configure:5328: checking for msg_control field in struct msghdr" >&5
 if eval "test \"`echo '$''{'wi_cv_msghdr_control'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
 cat > conftest.$ac_ext <<EOF
-#line 5322 "configure"
+#line 5334 "configure"
 #include "confdefs.h"
 
 	/* includes */
@@ -5338,7 +5350,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:5342: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5354: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   
 	wi_cv_msghdr_control=yes
@@ -5364,13 +5376,13 @@
 fi
 	
 echo $ac_n "checking for msg_accrights field in struct msghdr""... $ac_c" 1>&6
-echo "configure:5368: checking for msg_accrights field in struct msghdr" >&5
+echo "configure:5380: checking for msg_accrights field in struct msghdr" >&5
 if eval "test \"`echo '$''{'wi_cv_msghdr_accrights'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
 cat > conftest.$ac_ext <<EOF
-#line 5374 "configure"
+#line 5386 "configure"
 #include "confdefs.h"
 
 	/* includes */
@@ -5390,7 +5402,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:5394: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5406: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   
 	wi_cv_msghdr_accrights=yes
@@ -5430,17 +5442,17 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:5434: checking for $ac_hdr" >&5
+echo "configure:5446: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5439 "configure"
+#line 5451 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5444: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5456: \"$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*
@@ -5468,11 +5480,11 @@
 
 if test "$ac_cv_header_sys_select_h" = yes ; then
 	echo $ac_n "checking if <sys/select.h> is compatible with <sys/time.h>""... $ac_c" 1>&6
-echo "configure:5472: checking if <sys/select.h> is compatible with <sys/time.h>" >&5
+echo "configure:5484: checking if <sys/select.h> is compatible with <sys/time.h>" >&5
 	selecth=yes
 	if test "$ac_cv_header_sys_time_h" = yes ; then
 		cat > conftest.$ac_ext <<EOF
-#line 5476 "configure"
+#line 5488 "configure"
 #include "confdefs.h"
 
 #if defined(AIX) || defined(_AIX) || defined(__HOS_AIX__)
@@ -5492,7 +5504,7 @@
 		tmval.tv_sec = 0;
 ; return 0; }
 EOF
-if { (eval echo configure:5496: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5508: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   selecth=yes
 else
@@ -5513,6 +5525,354 @@
 fi
 	
 
+echo $ac_n "checking whether to enable ipv6""... $ac_c" 1>&6
+echo "configure:5530: checking whether to enable ipv6" >&5
+# Check whether --enable-ipv6 or --disable-ipv6 was given.
+if test "${enable_ipv6+set}" = set; then
+  enableval="$enable_ipv6"
+   case "$enableval" in
+  no)
+       echo "$ac_t""no" 1>&6
+       ipv6=no
+       ;;
+  *)   echo "$ac_t""yes" 1>&6
+       cat >> confdefs.h <<\EOF
+#define ENABLE_IPV6 1
+EOF
+
+       ipv6=yes
+       ;;
+  esac 
+else
+  if test "$cross_compiling" = yes; then
+  echo "$ac_t""no" 1>&6
+  ipv6=no
+
+else
+  cat > conftest.$ac_ext <<EOF
+#line 5554 "configure"
+#include "confdefs.h"
+ /* AF_INET6 avalable check */
+#define INET6
+#include <sys/types.h>
+#include <sys/socket.h>
+main()
+{
+ if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
+   exit(1);
+ else
+   exit(0);
+}
+
+EOF
+if { (eval echo configure:5569: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+  echo "$ac_t""yes" 1>&6
+  cat >> confdefs.h <<\EOF
+#define ENABLE_IPV6 1
+EOF
+
+  ipv6=yes
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -fr conftest*
+  echo "$ac_t""no" 1>&6
+  ipv6=no
+fi
+rm -fr conftest*
+fi
+
+fi
+
+
+echo $ac_n "checking for getnameinfo""... $ac_c" 1>&6
+echo "configure:5591: checking for getnameinfo" >&5
+if eval "test \"`echo '$''{'ac_cv_func_getnameinfo'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 5596 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char getnameinfo(); below.  */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char getnameinfo();
+
+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_getnameinfo) || defined (__stub___getnameinfo)
+choke me
+#else
+getnameinfo();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:5619: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  rm -rf conftest*
+  eval "ac_cv_func_getnameinfo=yes"
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_func_getnameinfo=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'getnameinfo`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  
+  cat >> confdefs.h <<\EOF
+#define HAVE_GETNAMEINFO 1
+EOF
+
+else
+  echo "$ac_t""no" 1>&6
+
+  LIBOBJS="$LIBOBJS getnameinfo.o"
+  LIBSOBJS="$LIBSOBJS getnameinfo.so"
+
+fi
+
+
+echo $ac_n "checking for getaddrinfo""... $ac_c" 1>&6
+echo "configure:5648: checking for getaddrinfo" >&5
+if eval "test \"`echo '$''{'ac_cv_func_getaddrinfo'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 5653 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char getaddrinfo(); below.  */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char getaddrinfo();
+
+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_getaddrinfo) || defined (__stub___getaddrinfo)
+choke me
+#else
+getaddrinfo();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:5676: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  rm -rf conftest*
+  eval "ac_cv_func_getaddrinfo=yes"
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_func_getaddrinfo=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'getaddrinfo`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  
+echo $ac_n "checking getaddrinfo bug""... $ac_c" 1>&6
+echo "configure:5692: checking getaddrinfo bug" >&5
+if test "$cross_compiling" = yes; then
+    { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
+else
+  cat > conftest.$ac_ext <<EOF
+#line 5697 "configure"
+#include "confdefs.h"
+
+#include <sys/types.h>
+#include <netdb.h>
+#include <string.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+
+main()
+{
+  int passive, gaierr, inet4 = 0, inet6 = 0;
+  struct addrinfo hints, *ai, *aitop;
+  char straddr[INET6_ADDRSTRLEN], strport[16];
+
+  for (passive = 0; passive <= 1; passive++) {
+    memset(&hints, 0, sizeof(hints));
+    hints.ai_family = AF_UNSPEC;
+    hints.ai_flags = passive ? AI_PASSIVE : 0;
+    hints.ai_socktype = SOCK_STREAM;
+    if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
+      (void)gai_strerror(gaierr);
+      goto bad;
+    }
+    for (ai = aitop; ai; ai = ai->ai_next) {
+      if (ai->ai_addr == NULL ||
+          ai->ai_addrlen == 0 ||
+          getnameinfo(ai->ai_addr, ai->ai_addrlen,
+                      straddr, sizeof(straddr), strport, sizeof(strport),
+                      NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
+        goto bad;
+      }
+      switch (ai->ai_family) {
+      case AF_INET:
+        if (strcmp(strport, "54321") != 0) {
+	  goto bad;
+	}
+        if (passive) {
+          if (strcmp(straddr, "0.0.0.0") != 0) {
+            goto bad;
+          }
+        } else {
+          if (strcmp(straddr, "127.0.0.1") != 0) {
+            goto bad;
+          }
+        }
+        inet4++;
+        break;
+      case AF_INET6:
+        if (strcmp(strport, "54321") != 0) {
+	  goto bad;
+	}
+        if (passive) {
+          if (strcmp(straddr, "::") != 0) {
+            goto bad;
+          }
+        } else {
+          if (strcmp(straddr, "::1") != 0) {
+            goto bad;
+          }
+        }
+        inet6++;
+        break;
+      case AF_UNSPEC:
+        goto bad;
+        break;
+      default:
+        /* another family support? */
+        break;
+      }
+    }
+  }
+
+  if (!(inet4 == 0 || inet4 == 2))
+    goto bad;
+  if (!(inet6 == 0 || inet6 == 2))
+    goto bad;
+
+  if (aitop)
+    freeaddrinfo(aitop);
+  exit(0);
+
+ bad:
+  if (aitop)
+    freeaddrinfo(aitop);
+  exit(1);
+}
+
+EOF
+if { (eval echo configure:5786: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+  
+  echo "$ac_t""good" 1>&6
+  cat >> confdefs.h <<\EOF
+#define HAVE_GETADDRINFO 1
+EOF
+
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -fr conftest*
+  
+  echo "$ac_t""buggy" 1>&6
+  LIBOBJS="$LIBOBJS getaddrinfo.o"
+  LIBSOBJS="$LIBSOBJS getaddrinfo.so"
+fi
+rm -fr conftest*
+fi
+
+else
+  echo "$ac_t""no" 1>&6
+
+  LIBOBJS="$LIBOBJS getaddrinfo.o"
+  LIBSOBJS="$LIBSOBJS getaddrinfo.so"
+
+fi
+
+
+# check if sockaddr has sa_len member
+echo $ac_n "checking if sockaddr has sa_len member""... $ac_c" 1>&6
+echo "configure:5817: checking if sockaddr has sa_len member" >&5
+cat > conftest.$ac_ext <<EOF
+#line 5819 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#include <sys/socket.h>
+int main() {
+struct sockaddr x;
+x.sa_len = 0;
+; return 0; }
+EOF
+if { (eval echo configure:5828: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+  rm -rf conftest*
+  echo "$ac_t""yes" 1>&6
+       cat >> confdefs.h <<\EOF
+#define HAVE_SOCKADDR_SA_LEN 1
+EOF
+
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  echo "$ac_t""no" 1>&6
+fi
+rm -f conftest*
+
+# check if sockaddr_storage has ss_family member
+echo $ac_n "checking if sockaddr_storage has ss_family member""... $ac_c" 1>&6
+echo "configure:5845: checking if sockaddr_storage has ss_family member" >&5
+cat > conftest.$ac_ext <<EOF
+#line 5847 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#include <sys/socket.h>
+int main() {
+struct sockaddr_storage x;
+x.__ss_family = 0;
+; return 0; }
+EOF
+if { (eval echo configure:5856: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+  rm -rf conftest*
+  echo "$ac_t""yes" 1>&6
+	cat >> confdefs.h <<\EOF
+#define HAVE_SOCKADDR_STORAGE_SS_FAMILY 1
+EOF
+
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  echo "$ac_t""no" 1>&6
+	cat >> confdefs.h <<\EOF
+#define HAVE_SOCKADDR_STORAGE___SS_FAMILY 1
+EOF
+
+	CPPFLAGS="$CPPFLAGS -D__ss_family=ss_family -D__ss_len=ss_len"
+fi
+rm -f conftest*
+
+CPPFLAGS="-I$MAINDIR $CPPFLAGS"
 
 
 if test "${SYS}" = sunos ; then
@@ -5521,12 +5881,12 @@
 	for ac_func in getwd
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:5525: checking for $ac_func" >&5
+echo "configure:5885: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5530 "configure"
+#line 5890 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -5549,7 +5909,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:5553: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5913: \"$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
@@ -5577,12 +5937,12 @@
 	for ac_func in getcwd getwd
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:5581: checking for $ac_func" >&5
+echo "configure:5941: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5586 "configure"
+#line 5946 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -5605,7 +5965,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:5609: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5969: \"$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
@@ -5643,12 +6003,12 @@
 for ac_func in fstat64 getdomainname gethostname getpass getpassphrase gnu_get_libc_release gnu_get_libc_version inet_aton inet_ntop llseek lseek64 lstat64 memmove mktime open64 pathconf readlink res_init setlocale setpgid setpgrp setsid setvbuf sigaction stat64 strcasecmp strcoll strdup strerror strncoll strstr strtoq symlink sysconf sysctl sysinfo syslog uname waitpid
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:5647: checking for $ac_func" >&5
+echo "configure:6007: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5652 "configure"
+#line 6012 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -5671,7 +6031,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:5675: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6035: \"$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
@@ -5698,12 +6058,12 @@
 for ac_func in gethostbyaddr_r gethostbyname_r gethostbyname2_r getlogin_r getpwnam_r _posix_getpwnam_r getpwuid_r _posix_getpwuid_r getservbyname_r getservbyport_r gmtime_r localtime_r readdir_r
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:5702: checking for $ac_func" >&5
+echo "configure:6062: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5707 "configure"
+#line 6067 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -5726,7 +6086,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:5730: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6090: \"$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
@@ -5753,7 +6113,7 @@
 
 
 echo $ac_n "checking what sprintf() returns""... $ac_c" 1>&6
-echo "configure:5757: checking what sprintf() returns" >&5
+echo "configure:6117: checking what sprintf() returns" >&5
 if test "$cross_compiling" = yes; then
   
 	# action if cross compiling
@@ -5762,7 +6122,7 @@
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 5766 "configure"
+#line 6126 "configure"
 #include "confdefs.h"
 
 	/* program */
@@ -5782,7 +6142,7 @@
 }
 
 EOF
-if { (eval echo configure:5786: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:6146: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
 	# action if true
@@ -5814,12 +6174,12 @@
 for ac_func in snprintf vsnprintf
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:5818: checking for $ac_func" >&5
+echo "configure:6178: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5823 "configure"
+#line 6183 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -5842,7 +6202,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:5846: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6206: \"$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
@@ -5869,10 +6229,10 @@
 
 if test "$ac_cv_func_snprintf" != "no" ; then
 echo $ac_n "checking if snprintf works correctly""... $ac_c" 1>&6
-echo "configure:5873: checking if snprintf works correctly" >&5
+echo "configure:6233: checking if snprintf works correctly" >&5
 	if test "$ac_cv_func_snprintf" = "no" ; then
 		echo $ac_n "checking for snprintf in -lsnprintf""... $ac_c" 1>&6
-echo "configure:5876: checking for snprintf in -lsnprintf" >&5
+echo "configure:6236: checking for snprintf in -lsnprintf" >&5
 ac_lib_var=`echo snprintf'_'snprintf | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -5880,7 +6240,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lsnprintf  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 5884 "configure"
+#line 6244 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -5891,7 +6251,7 @@
 snprintf()
 ; return 0; }
 EOF
-if { (eval echo configure:5895: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6255: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5932,7 +6292,7 @@
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 5936 "configure"
+#line 6296 "configure"
 #include "confdefs.h"
 
 	/* program */
@@ -5967,7 +6327,7 @@
 }
 
 EOF
-if { (eval echo configure:5971: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:6331: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
 	# action if true
@@ -5997,7 +6357,7 @@
 
 if test "$ac_cv_func_snprintf" = "no" ; then
 	echo $ac_n "checking for snprintf in -lsnprintf""... $ac_c" 1>&6
-echo "configure:6001: checking for snprintf in -lsnprintf" >&5
+echo "configure:6361: checking for snprintf in -lsnprintf" >&5
 ac_lib_var=`echo snprintf'_'snprintf | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -6005,7 +6365,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lsnprintf  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 6009 "configure"
+#line 6369 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -6016,7 +6376,7 @@
 snprintf()
 ; return 0; }
 EOF
-if { (eval echo configure:6020: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6380: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6049,17 +6409,17 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:6053: checking for $ac_hdr" >&5
+echo "configure:6413: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 6058 "configure"
+#line 6418 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:6063: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:6423: \"$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*
@@ -6088,12 +6448,12 @@
 		for ac_func in snprintf
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:6092: checking for $ac_func" >&5
+echo "configure:6452: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 6097 "configure"
+#line 6457 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -6116,7 +6476,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:6120: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6480: \"$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
@@ -6151,14 +6511,14 @@
 	fi
 
 echo $ac_n "checking for sigsetjmp and siglongjmp""... $ac_c" 1>&6
-echo "configure:6155: checking for sigsetjmp and siglongjmp" >&5
+echo "configure:6515: checking for sigsetjmp and siglongjmp" >&5
 if eval "test \"`echo '$''{'wi_cv_func_sigsetjmp'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
 
 cat > conftest.$ac_ext <<EOF
-#line 6162 "configure"
+#line 6522 "configure"
 #include "confdefs.h"
 
 	/* includes */
@@ -6181,7 +6541,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:6185: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6545: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   
 	wi_cv_func_sigsetjmp=yes
@@ -6207,7 +6567,7 @@
 fi
 
 echo $ac_n "checking whether setpgrp takes no argument""... $ac_c" 1>&6
-echo "configure:6211: checking whether setpgrp takes no argument" >&5
+echo "configure:6571: checking whether setpgrp takes no argument" >&5
 if eval "test \"`echo '$''{'ac_cv_func_setpgrp_void'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -6215,7 +6575,7 @@
   { echo "configure: error: cannot check setpgrp if cross compiling" 1>&2; exit 1; }
 else
   cat > conftest.$ac_ext <<EOF
-#line 6219 "configure"
+#line 6579 "configure"
 #include "confdefs.h"
 
 #ifdef HAVE_UNISTD_H
@@ -6235,7 +6595,7 @@
 }
 
 EOF
-if { (eval echo configure:6239: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:6599: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_func_setpgrp_void=no
 else
@@ -6259,7 +6619,7 @@
 fi
 
 echo $ac_n "checking whether setvbuf arguments are reversed""... $ac_c" 1>&6
-echo "configure:6263: checking whether setvbuf arguments are reversed" >&5
+echo "configure:6623: checking whether setvbuf arguments are reversed" >&5
 if eval "test \"`echo '$''{'ac_cv_func_setvbuf_reversed'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -6267,7 +6627,7 @@
     { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
 else
   cat > conftest.$ac_ext <<EOF
-#line 6271 "configure"
+#line 6631 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 /* If setvbuf has the reversed format, exit 0. */
@@ -6281,7 +6641,7 @@
   exit(0);			/* Non-reversed systems segv here.  */
 }
 EOF
-if { (eval echo configure:6285: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:6645: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_func_setvbuf_reversed=yes
 else
@@ -6325,7 +6685,7 @@
 	fi
 
 echo $ac_n "checking string parameter to waddstr""... $ac_c" 1>&6
-echo "configure:6329: checking string parameter to waddstr" >&5
+echo "configure:6689: checking string parameter to waddstr" >&5
 if eval "test \"`echo '$''{'wi_cv_waddstr_str_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -6528,9 +6888,9 @@
 
 	# maxx or _maxx
 	echo $ac_n "checking whether curses structure has maxx or _maxx field""... $ac_c" 1>&6
-echo "configure:6532: checking whether curses structure has maxx or _maxx field" >&5
+echo "configure:6892: checking whether curses structure has maxx or _maxx field" >&5
 	cat > conftest.$ac_ext <<EOF
-#line 6534 "configure"
+#line 6894 "configure"
 #include "confdefs.h"
 
 	/* includes */
@@ -6560,7 +6920,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:6564: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6924: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
 echo "$ac_t""maxx" 1>&6
@@ -6583,12 +6943,12 @@
 	for ac_func in __getcurx __getcury __getmaxx __getmaxy __getbegx __getbegy
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:6587: checking for $ac_func" >&5
+echo "configure:6947: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 6592 "configure"
+#line 6952 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -6611,7 +6971,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:6615: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6975: \"$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
@@ -6639,9 +6999,9 @@
 
 	# getcurx
 	echo $ac_n "checking for getcurx() functionality in curses library""... $ac_c" 1>&6
-echo "configure:6643: checking for getcurx() functionality in curses library" >&5
+echo "configure:7003: checking for getcurx() functionality in curses library" >&5
 	cat > conftest.$ac_ext <<EOF
-#line 6645 "configure"
+#line 7005 "configure"
 #include "confdefs.h"
 
 	/* includes */
@@ -6671,7 +7031,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:6675: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7035: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   
 	cat >> confdefs.h <<\EOF
@@ -6692,9 +7052,9 @@
 
 	# getyx
 	echo $ac_n "checking for getyx() functionality in curses library""... $ac_c" 1>&6
-echo "configure:6696: checking for getyx() functionality in curses library" >&5
+echo "configure:7056: checking for getyx() functionality in curses library" >&5
 	cat > conftest.$ac_ext <<EOF
-#line 6698 "configure"
+#line 7058 "configure"
 #include "confdefs.h"
 
 	/* includes */
@@ -6724,7 +7084,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:6728: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7088: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   
 	cat >> confdefs.h <<\EOF
@@ -6745,9 +7105,9 @@
 
 	# getmaxx
 	echo $ac_n "checking for getmaxx() functionality in curses library""... $ac_c" 1>&6
-echo "configure:6749: checking for getmaxx() functionality in curses library" >&5
+echo "configure:7109: checking for getmaxx() functionality in curses library" >&5
 	cat > conftest.$ac_ext <<EOF
-#line 6751 "configure"
+#line 7111 "configure"
 #include "confdefs.h"
 
 	/* includes */
@@ -6776,7 +7136,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:6780: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7140: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   
 	cat >> confdefs.h <<\EOF
@@ -6797,9 +7157,9 @@
 
 	# getmaxyx
 	echo $ac_n "checking for getmaxyx() functionality in curses library""... $ac_c" 1>&6
-echo "configure:6801: checking for getmaxyx() functionality in curses library" >&5
+echo "configure:7161: checking for getmaxyx() functionality in curses library" >&5
 	cat > conftest.$ac_ext <<EOF
-#line 6803 "configure"
+#line 7163 "configure"
 #include "confdefs.h"
 
 	/* includes */
@@ -6828,7 +7188,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:6832: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7192: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   
 	cat >> confdefs.h <<\EOF
@@ -6849,9 +7209,9 @@
 
 	# getbegx
 	echo $ac_n "checking for getbegx() functionality in curses library""... $ac_c" 1>&6
-echo "configure:6853: checking for getbegx() functionality in curses library" >&5
+echo "configure:7213: checking for getbegx() functionality in curses library" >&5
 	cat > conftest.$ac_ext <<EOF
-#line 6855 "configure"
+#line 7215 "configure"
 #include "confdefs.h"
 
 	/* includes */
@@ -6881,7 +7241,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:6885: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7245: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   
 	cat >> confdefs.h <<\EOF
@@ -6902,9 +7262,9 @@
 
 	# getbegyx
 	echo $ac_n "checking for getbegyx() functionality in curses library""... $ac_c" 1>&6
-echo "configure:6906: checking for getbegyx() functionality in curses library" >&5
+echo "configure:7266: checking for getbegyx() functionality in curses library" >&5
 	cat > conftest.$ac_ext <<EOF
-#line 6908 "configure"
+#line 7268 "configure"
 #include "confdefs.h"
 
 	/* includes */
@@ -6933,7 +7293,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:6937: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7297: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   
 	cat >> confdefs.h <<\EOF
@@ -6954,9 +7314,9 @@
 
 	# touchwin
 	echo $ac_n "checking for touchwin() functionality in curses library""... $ac_c" 1>&6
-echo "configure:6958: checking for touchwin() functionality in curses library" >&5
+echo "configure:7318: checking for touchwin() functionality in curses library" >&5
 	cat > conftest.$ac_ext <<EOF
-#line 6960 "configure"
+#line 7320 "configure"
 #include "confdefs.h"
 
 	/* includes */
@@ -6983,7 +7343,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:6987: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7347: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   
 	cat >> confdefs.h <<\EOF
@@ -7004,9 +7364,9 @@
 
 	# beep
 	echo $ac_n "checking for beep() functionality in curses library""... $ac_c" 1>&6
-echo "configure:7008: checking for beep() functionality in curses library" >&5
+echo "configure:7368: checking for beep() functionality in curses library" >&5
 	cat > conftest.$ac_ext <<EOF
-#line 7010 "configure"
+#line 7370 "configure"
 #include "confdefs.h"
 
 	/* includes */
@@ -7032,7 +7392,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:7036: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7396: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   
 	cat >> confdefs.h <<\EOF
@@ -7054,12 +7414,12 @@
 	for ac_func in keypad nodelay curs_set doupdate wnoutrefresh
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:7058: checking for $ac_func" >&5
+echo "configure:7418: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 7063 "configure"
+#line 7423 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -7082,7 +7442,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:7086: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7446: \"$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
@@ -7119,7 +7479,7 @@
 
 
 echo $ac_n "checking for long file names""... $ac_c" 1>&6
-echo "configure:7123: checking for long file names" >&5
+echo "configure:7483: checking for long file names" >&5
 if eval "test \"`echo '$''{'ac_cv_sys_long_file_names'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -7163,7 +7523,7 @@
 fi
 
 echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
-echo "configure:7167: checking whether ${MAKE-make} sets \${MAKE}" >&5
+echo "configure:7527: checking whether ${MAKE-make} sets \${MAKE}" >&5
 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -7193,7 +7553,7 @@
 # Extract the first word of ""gtar"", so it can be a program name with args.
 set dummy "gtar"; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:7197: checking for $ac_word" >&5
+echo "configure:7557: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_TAR'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -7232,7 +7592,7 @@
 	# Extract the first word of ""tar"", so it can be a program name with args.
 set dummy "tar"; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:7236: checking for $ac_word" >&5
+echo "configure:7596: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_TAR'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -7280,7 +7640,7 @@
 
 
 echo $ac_n "checking how to create TAR files""... $ac_c" 1>&6
-echo "configure:7284: checking how to create TAR files" >&5
+echo "configure:7644: checking how to create TAR files" >&5
 x=""
 if [ -x /usr/bin/what ] ; then
 	x=`/usr/bin/what "$TAR" 2>&1 | sed -n 's/.*pax.*/pax/g;/pax/p'`
@@ -7307,7 +7667,7 @@
 # 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:7311: checking for $ac_word" >&5
+echo "configure:7671: 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
@@ -7346,7 +7706,7 @@
 # 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:7350: checking for a BSD compatible install" >&5
+echo "configure:7710: 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
@@ -7402,7 +7762,7 @@
 # Extract the first word of ""pwd"", so it can be a program name with args.
 set dummy "pwd"; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:7406: checking for $ac_word" >&5
+echo "configure:7766: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_wi_PWD'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -7439,13 +7799,13 @@
 
 if test "x$use_ccdv" = "xno" ; then
 	echo $ac_n "checking for ccdv""... $ac_c" 1>&6
-echo "configure:7443: checking for ccdv" >&5
+echo "configure:7803: checking for ccdv" >&5
 	echo "$ac_t""(disabled)" 1>&6
 else
 unset wi_cv_path_ccdv	# can't use cache if it was a temp prog last time
 wi_used_cache_path_ccdv="yes"
 echo $ac_n "checking for ccdv""... $ac_c" 1>&6
-echo "configure:7449: checking for ccdv" >&5
+echo "configure:7809: checking for ccdv" >&5
 if eval "test \"`echo '$''{'wi_cv_path_ccdv'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -7950,7 +8310,7 @@
 
 
 echo $ac_n "checking if shell can test for symlinks""... $ac_c" 1>&6
-echo "configure:7954: checking if shell can test for symlinks" >&5
+echo "configure:8314: checking if shell can test for symlinks" >&5
 if eval "test \"`echo '$''{'wi_cv_shell_test_symlinks'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -8414,6 +8774,8 @@
 
 
 
+
+
 trap '' 1 2 15
 cat > confcache <<\EOF
 # This file is a shell script that caches the results of configure
@@ -8580,6 +8942,8 @@
 s%@MAKE@%$MAKE%g
 s%@Z30@%$Z30%g
 s%@LIBSET@%$LIBSET%g
+s%@LIBOBJS@%$LIBOBJS%g
+s%@LIBSOBJS@%$LIBSOBJS%g
 s%@MAINDIR@%$MAINDIR%g
 s%@NCFTP_VERSION@%$NCFTP_VERSION%g
 s%@LIBNCFTP_VERSION@%$LIBNCFTP_VERSION%g
Index: ncftp3/configure.in
diff -u ncftp3/configure.in:1.1.1.9 ncftp3/configure.in:1.18
--- ncftp3/configure.in:1.1.1.9	Sat Jul  6 10:54:41 2002
+++ ncftp3/configure.in	Tue Jul  9 15:08:49 2002
@@ -10,8 +10,6 @@
 dnl AC_ARG_WITH(readline,[  --without-readline      do not try to find and use the readline library],nc_cv_readline=$withval,nc_cv_readline=yes)
 wi_ARG_WITH_SOCKS5
 
-
-
 dnl ---------------------------------------------------------------------------
 dnl Environment and compiler settings.
 dnl ---------------------------------------------------------------------------
@@ -98,6 +96,172 @@
 wi_HEADER_SYS_SELECT_H	dnl				# sio
 
 
+dnl ---------------------------------------------------------------------------
+dnl Checks for IPv6.
+dnl ---------------------------------------------------------------------------
+dnl
+AC_MSG_CHECKING([whether to enable ipv6])
+AC_ARG_ENABLE(ipv6,
+[  --enable-ipv6		Enable ipv6 (with ipv4) support
+  --disable-ipv6		Disable ipv6 support],
+[ case "$enableval" in
+  no)
+       AC_MSG_RESULT(no)
+       ipv6=no
+       ;;
+  *)   AC_MSG_RESULT(yes)
+       AC_DEFINE(ENABLE_IPV6)
+       ipv6=yes
+       ;;
+  esac ],
+
+  AC_TRY_RUN([ /* AF_INET6 avalable check */
+#define INET6
+#include <sys/types.h>
+#include <sys/socket.h>
+main()
+{
+ if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
+   exit(1);
+ else
+   exit(0);
+}
+],
+  AC_MSG_RESULT(yes)
+  AC_DEFINE(ENABLE_IPV6)
+  ipv6=yes,
+  AC_MSG_RESULT(no)
+  ipv6=no,
+  AC_MSG_RESULT(no)
+  ipv6=no
+))
+
+AC_CHECK_FUNC(getnameinfo, [
+  AC_DEFINE(HAVE_GETNAMEINFO)], [
+  LIBOBJS="$LIBOBJS getnameinfo.o"
+  LIBSOBJS="$LIBSOBJS getnameinfo.so"
+])
+
+AC_CHECK_FUNC(getaddrinfo, [
+AC_MSG_CHECKING(getaddrinfo bug)
+AC_TRY_RUN([
+#include <sys/types.h>
+#include <netdb.h>
+#include <string.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+
+main()
+{
+  int passive, gaierr, inet4 = 0, inet6 = 0;
+  struct addrinfo hints, *ai, *aitop;
+  char straddr[INET6_ADDRSTRLEN], strport[16];
+
+  for (passive = 0; passive <= 1; passive++) {
+    memset(&hints, 0, sizeof(hints));
+    hints.ai_family = AF_UNSPEC;
+    hints.ai_flags = passive ? AI_PASSIVE : 0;
+    hints.ai_socktype = SOCK_STREAM;
+    if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
+      (void)gai_strerror(gaierr);
+      goto bad;
+    }
+    for (ai = aitop; ai; ai = ai->ai_next) {
+      if (ai->ai_addr == NULL ||
+          ai->ai_addrlen == 0 ||
+          getnameinfo(ai->ai_addr, ai->ai_addrlen,
+                      straddr, sizeof(straddr), strport, sizeof(strport),
+                      NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
+        goto bad;
+      }
+      switch (ai->ai_family) {
+      case AF_INET:
+        if (strcmp(strport, "54321") != 0) {
+	  goto bad;
+	}
+        if (passive) {
+          if (strcmp(straddr, "0.0.0.0") != 0) {
+            goto bad;
+          }
+        } else {
+          if (strcmp(straddr, "127.0.0.1") != 0) {
+            goto bad;
+          }
+        }
+        inet4++;
+        break;
+      case AF_INET6:
+        if (strcmp(strport, "54321") != 0) {
+	  goto bad;
+	}
+        if (passive) {
+          if (strcmp(straddr, "::") != 0) {
+            goto bad;
+          }
+        } else {
+          if (strcmp(straddr, "::1") != 0) {
+            goto bad;
+          }
+        }
+        inet6++;
+        break;
+      case AF_UNSPEC:
+        goto bad;
+        break;
+      default:
+        /* another family support? */
+        break;
+      }
+    }
+  }
+
+  if (!(inet4 == 0 || inet4 == 2))
+    goto bad;
+  if (!(inet6 == 0 || inet6 == 2))
+    goto bad;
+
+  if (aitop)
+    freeaddrinfo(aitop);
+  exit(0);
+
+ bad:
+  if (aitop)
+    freeaddrinfo(aitop);
+  exit(1);
+}
+], [
+  AC_MSG_RESULT(good)
+  AC_DEFINE(HAVE_GETADDRINFO)], [
+  AC_MSG_RESULT(buggy)
+  LIBOBJS="$LIBOBJS getaddrinfo.o"
+  LIBSOBJS="$LIBSOBJS getaddrinfo.so"])], [
+  LIBOBJS="$LIBOBJS getaddrinfo.o"
+  LIBSOBJS="$LIBSOBJS getaddrinfo.so"
+])
+
+# check if sockaddr has sa_len member
+AC_MSG_CHECKING(if sockaddr has sa_len member)
+AC_TRY_COMPILE([#include <sys/types.h>
+#include <sys/socket.h>],
+[struct sockaddr x;
+x.sa_len = 0;],
+       AC_MSG_RESULT(yes)
+       AC_DEFINE(HAVE_SOCKADDR_SA_LEN),
+       AC_MSG_RESULT(no))
+
+# check if sockaddr_storage has ss_family member
+AC_MSG_CHECKING(if sockaddr_storage has ss_family member)
+AC_TRY_COMPILE([#include <sys/types.h>
+#include <sys/socket.h>],
+[struct sockaddr_storage x;
+x.__ss_family = 0;],
+	AC_MSG_RESULT(yes)
+	AC_DEFINE(HAVE_SOCKADDR_STORAGE_SS_FAMILY),
+	AC_MSG_RESULT(no)
+	AC_DEFINE(HAVE_SOCKADDR_STORAGE___SS_FAMILY)
+	CPPFLAGS="$CPPFLAGS -D__ss_family=ss_family -D__ss_len=ss_len")
+
+CPPFLAGS="-I$MAINDIR $CPPFLAGS"
 
 dnl ---------------------------------------------------------------------------
 dnl Checks for library functions.
@@ -218,6 +382,8 @@
 AC_SUBST(MAKE)
 AC_SUBST(Z30)
 AC_SUBST(LIBSET)
+AC_SUBST(LIBOBJS)
+AC_SUBST(LIBSOBJS)
 AC_SUBST(MAINDIR)
 AC_SUBST(NCFTP_VERSION)
 AC_SUBST(LIBNCFTP_VERSION)
Index: ncftp3/Strn/tester
Index: ncftp3/autoconf/acconfig.h
diff -u ncftp3/autoconf/acconfig.h:1.1.1.8 ncftp3/autoconf/acconfig.h:1.5
--- ncftp3/autoconf/acconfig.h:1.1.1.8	Sun Jan 12 11:26:09 2003
+++ ncftp3/autoconf/acconfig.h	Sun Jan 12 11:45:18 2003
@@ -224,6 +224,24 @@
 /* Define if you have the wait3 system call.  */
 #undef HAVE_WAIT3
 
+/* Define if you have the getaddrinfo function.  */
+#undef HAVE_GETADDRINFO
+
+/* Define if you have the getaddrname function.  */
+#undef HAVE_GETNAMEINFO
+
+/* Define if sockaddr has sa_len member */
+#undef HAVE_SOCKADDR_SA_LEN
+
+/* Define if sockaddr_storage has ss_family member */
+#undef HAVE_SOCKADDR_STORAGE_SS_FAMILY
+
+/* Define if sockaddr_storage has __ss_family member */
+#undef HAVE_SOCKADDR_STORAGE___SS_FAMILY
+
+/* Define if you want IPv6 support. */
+#undef ENABLE_IPV6
+
 /* Define as __inline if that's what the C compiler calls it.  */
 #undef inline
 
Index: ncftp3/libncftp/Makefile.in
diff -u ncftp3/libncftp/Makefile.in:1.1.1.11 ncftp3/libncftp/Makefile.in:1.6
--- ncftp3/libncftp/Makefile.in:1.1.1.11	Sat Jul  6 10:54:43 2002
+++ ncftp3/libncftp/Makefile.in	Tue Jul  9 15:08:50 2002
@@ -23,6 +23,8 @@
 CFILES=c_chdir.c c_chdir3.c c_chdirlist.c c_chmod.c c_delete.c c_exists.c c_filetype.c c_getcwd.c c_mkdir.c c_mlist1.c c_modtime.c c_opennologin.c c_rename.c c_rhelp.c c_rmdir.c c_rmdirr.c c_size.c c_sizemdtm.c c_symlink.c c_type.c c_umask.c c_utime.c errno.c ftp.c ftw.c io_get.c io_getfiles.c io_getonefile.c io_gettar.c io_list.c io_listmem.c io_put.c io_putfiles.c io_putmem.c io_putonefile.c io_util.c lglob.c lglobr.c linelist.c open.c rcmd.c rftw.c rglob.c rglobr.c u_close.c u_decodeurl.c u_error.c u_fileextn.c u_getcwd.c u_gethome.c u_getopt.c u_getpass.c u_getpw.c u_getusr.c u_getutc.c u_gmtime.c u_localtime.c u_misc.c u_mkdirs.c u_pathcat.c u_printf.c u_rebuildci.c u_scram.c u_shutdownci.c u_signal.c u_slash.c u_unmdtm.c unls.c
 
 OBJS=c_chdir.@OBJEXT@ c_chdir3.@OBJEXT@ c_chdirlist.@OBJEXT@ c_chmod.@OBJEXT@ c_delete.@OBJEXT@ c_exists.@OBJEXT@ c_filetype.@OBJEXT@ c_getcwd.@OBJEXT@ c_mkdir.@OBJEXT@ c_mlist1.@OBJEXT@ c_modtime.@OBJEXT@ c_opennologin.@OBJEXT@ c_rename.@OBJEXT@ c_rhelp.@OBJEXT@ c_rmdir.@OBJEXT@ c_rmdirr.@OBJEXT@ c_size.@OBJEXT@ c_sizemdtm.@OBJEXT@ c_symlink.@OBJEXT@ c_type.@OBJEXT@ c_umask.@OBJEXT@ c_utime.@OBJEXT@ errno.@OBJEXT@ ftp.@OBJEXT@ ftw.@OBJEXT@ io_get.@OBJEXT@ io_getfiles.@OBJEXT@ io_getonefile.@OBJEXT@ io_gettar.@OBJEXT@ io_list.@OBJEXT@ io_listmem.@OBJEXT@ io_put.@OBJEXT@ io_putfiles.@OBJEXT@ io_putmem.@OBJEXT@ io_putonefile.@OBJEXT@ io_util.@OBJEXT@ lglob.@OBJEXT@ lglobr.@OBJEXT@ linelist.@OBJEXT@ open.@OBJEXT@ rcmd.@OBJEXT@ rftw.@OBJEXT@ rglob.@OBJEXT@ rglobr.@OBJEXT@ u_close.@OBJEXT@ u_decodeurl.@OBJEXT@ u_error.@OBJEXT@ u_fileextn.@OBJEXT@ u_getcwd.@OBJEXT@ u_gethome.@OBJEXT@ u_getpass.@OBJEXT@ u_getopt.@OBJEXT@ u_getpw.@OBJEXT@ u_getusr.@OBJEXT@ u_getutc.@OBJEXT@ u_gmtime.@OBJEXT@ u_localtime.@OBJEXT@ u_misc.@OBJEXT@ u_mkdirs.@OBJEXT@ u_pathcat.@OBJEXT@ u_printf.@OBJEXT@ u_rebuildci.@OBJEXT@ u_scram.@OBJEXT@ u_shutdownci.@OBJEXT@ u_signal.@OBJEXT@ u_slash.@OBJEXT@ u_unmdtm.@OBJEXT@ unls.@OBJEXT@
+#OBJS+=@LIBOBJS@
+#SOBJS+=@LIBSOBJS@
 
 SOBJS=c_chdir.so c_chdir3.so c_chdirlist.so c_chmod.so c_delete.so c_exists.so c_filetype.so c_getcwd.so c_mkdir.so c_mlist1.so c_modtime.so c_opennologin.so c_rename.so c_rhelp.so c_rmdir.so c_rmdirr.so c_size.so c_sizemdtm.so c_symlink.so c_type.so c_umask.so c_utime.so errno.so ftp.so ftw.so io_get.so io_getfiles.so io_getonefile.so io_gettar.so io_list.so io_listmem.so io_put.so io_putfiles.so io_putmem.so io_putonefile.so io_util.so lglob.so lglobr.so linelist.so open.so rcmd.so rftw.so rglob.so rglobr.so u_close.so u_decodeurl.so u_error.so u_fileextn.so u_getcwd.so u_gethome.so u_getopt.so u_getpass.so u_getpw.so u_getusr.so u_getutc.so u_gmtime.so u_localtime.so u_misc.so u_mkdirs.so u_pathcat.so u_printf.so u_rebuildci.so u_scram.so u_shutdownci.so u_signal.so u_slash.so u_unmdtm.so unls.so
 
Index: ncftp3/libncftp/addrinfo.h
diff -u /dev/null ncftp3/libncftp/addrinfo.h:1.2
--- /dev/null	Mon Jan 20 08:18:32 2003
+++ ncftp3/libncftp/addrinfo.h	Tue Nov 20 02:53:11 2001
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project.
+ * 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. Neither the name of the project 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 PROJECT 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 PROJECT 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.
+ */
+
+#ifndef HAVE_GETADDRINFO
+
+/*
+ * Error return codes from getaddrinfo()
+ */
+#define	EAI_ADDRFAMILY	 1	/* address family for hostname not supported */
+#define	EAI_AGAIN	 2	/* temporary failure in name resolution */
+#define	EAI_BADFLAGS	 3	/* invalid value for ai_flags */
+#define	EAI_FAIL	 4	/* non-recoverable failure in name resolution */
+#define	EAI_FAMILY	 5	/* ai_family not supported */
+#define	EAI_MEMORY	 6	/* memory allocation failure */
+#define	EAI_NODATA	 7	/* no address associated with hostname */
+#define	EAI_NONAME	 8	/* hostname nor servname provided, or not known */
+#define	EAI_SERVICE	 9	/* servname not supported for ai_socktype */
+#define	EAI_SOCKTYPE	10	/* ai_socktype not supported */
+#define	EAI_SYSTEM	11	/* system error returned in errno */
+#define EAI_BADHINTS	12
+#define EAI_PROTOCOL	13
+#define EAI_MAX		14
+
+/*
+ * Flag values for getaddrinfo()
+ */
+#define	AI_PASSIVE	0x00000001 /* get address to use bind() */
+#define	AI_CANONNAME	0x00000002 /* fill ai_canonname */
+#define	AI_NUMERICHOST	0x00000004 /* prevent name resolution */
+/* valid flags for addrinfo */
+#define	AI_MASK		(AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST)
+
+#define	AI_ALL		0x00000100 /* IPv6 and IPv4-mapped (with AI_V4MAPPED) */
+#define	AI_V4MAPPED_CFG	0x00000200 /* accept IPv4-mapped if kernel supports */
+#define	AI_ADDRCONFIG	0x00000400 /* only if any address is assigned */
+#define	AI_V4MAPPED	0x00000800 /* accept IPv4-mapped IPv6 address */
+/* special recommended flags for getipnodebyname */
+#define	AI_DEFAULT	(AI_V4MAPPED_CFG | AI_ADDRCONFIG)
+
+/*
+ * Constants for getnameinfo()
+ */
+#define	NI_MAXHOST	1025
+#define	NI_MAXSERV	32
+
+/*
+ * Flag values for getnameinfo()
+ */
+#define	NI_NOFQDN	0x00000001
+#define	NI_NUMERICHOST	0x00000002
+#define	NI_NAMEREQD	0x00000004
+#define	NI_NUMERICSERV	0x00000008
+#define	NI_DGRAM	0x00000010
+
+struct addrinfo {
+	int	ai_flags;	/* AI_PASSIVE, AI_CANONNAME */
+	int	ai_family;	/* PF_xxx */
+	int	ai_socktype;	/* SOCK_xxx */
+	int	ai_protocol;	/* 0 or IPPROTO_xxx for IPv4 and IPv6 */
+	size_t	ai_addrlen;	/* length of ai_addr */
+	char	*ai_canonname;	/* canonical name for hostname */
+	struct sockaddr *ai_addr;	/* binary address */
+	struct addrinfo *ai_next;	/* next structure in linked list */
+};
+
+struct sockaddr_storage {
+#ifdef HAVE_SOCKADDR_SA_LEN
+	u_int8_t	ss_len;		/* address length */
+	u_int8_t	ss_family;	/* address family */
+#else
+	u_int16_t	ss_family;
+#endif
+	u_int8_t fill[126];
+};
+
+extern void freehostent __P((struct hostent *));
+extern char *gai_strerror __P((int));
+#endif
Index: ncftp3/libncftp/ftp.c
diff -u ncftp3/libncftp/ftp.c:1.1.1.12 ncftp3/libncftp/ftp.c:1.45
--- ncftp3/libncftp/ftp.c:1.1.1.12	Sat Jul  6 10:54:46 2002
+++ ncftp3/libncftp/ftp.c	Mon Jan 20 08:17:10 2003
@@ -48,6 +48,17 @@
 #	define DisposeSocket(a) close(a)
 #endif
 
+#ifndef HAVE_SOCKADDR_SA_LEN
+#ifndef SA_LEN
+#ifdef ENABLE_IPV6
+#define SA_LEN(x) (((x)->sa_family == AF_INET6) ? sizeof(struct sockaddr_in6) \
+		: (((x)->sa_family == AF_INET) ? sizeof(struct sockaddr_in) \
+		: -1))
+#else  /* ENABLE_IPV6 */
+#define SA_LEN(x) (((x)->sa_family == AF_INET) ? sizeof(struct sockaddr_in) : -1)
+#endif /* ENABLE_IPV6 */
+#endif /* SA_LEN */
+#endif /* HAVE_SOCKADDR_SA_LEN */
 
 void
 CloseControlConnection(const FTPCIPtr cip)
@@ -75,9 +86,9 @@
 
 
 static int
-GetSocketAddress(const FTPCIPtr cip, int sockfd, struct sockaddr_in *saddr)
+GetSocketAddress(const FTPCIPtr cip, int sockfd, struct sockaddr *saddr)
 {
-	sockaddr_size_t len = (sockaddr_size_t) sizeof (struct sockaddr_in);
+	sockaddr_size_t len = (sockaddr_size_t) sizeof (struct sockaddr_storage);
 	int result = 0;
 
 	if (getsockname(sockfd, (struct sockaddr *)saddr, &len) < 0) {
@@ -111,16 +122,16 @@
 int
 OpenControlConnection(const FTPCIPtr cip, char *host, unsigned int port)
 {
-	struct in_addr ip_address;
 	int err = 0;
 	int result;
 	int oerrno;
 	volatile int sockfd = -1;
 	volatile int sock2fd = -1;
 	ResponsePtr rp;
-	char **volatile curaddr;
-	int hpok;
-	struct hostent hp;
+	struct addrinfo hints;
+	struct addrinfo *res, *res0;
+	int error;
+	char buf[NI_MAXHOST];
 	char *volatile fhost;
 	unsigned int fport;
 #ifndef NO_SIGNALS
@@ -154,27 +165,17 @@
 	cip->cin = NULL;
 	cip->cout = NULL;
 
-	/* Make sure we use network byte-order. */
-	fport = (unsigned int) htons((unsigned short) fport);
-
-	cip->servCtlAddr.sin_port = (unsigned short) fport;
-
-	if (GetHostEntry(&hp, fhost, &ip_address, cip->buf, cip->bufSize) != 0) {
-		hpok = 0;
-		/* Okay, no Host entry, but maybe we have a numeric address
-		 * in ip_address we can try.
-		 */
-		if (ip_address.s_addr == INADDR_NONE) {
-			FTPLogError(cip, kDontPerror, "%s: unknown host.\n", fhost);
-			cip->errNo = kErrHostUnknown;
-			return (kErrHostUnknown);
-		}
-		cip->servCtlAddr.sin_family = AF_INET;
-		cip->servCtlAddr.sin_addr.s_addr = ip_address.s_addr;
-	} else {
-		hpok = 1;
-		cip->servCtlAddr.sin_family = hp.h_addrtype;
-		/* We'll fill in the rest of the structure below. */
+	memset(&hints, 0, sizeof(hints));
+	hints.ai_flags = AI_CANONNAME;
+	hints.ai_family = PF_UNSPEC;
+	hints.ai_socktype = SOCK_STREAM;
+	hints.ai_protocol = IPPROTO_TCP;
+	sprintf(buf, "%d\0", fport);
+	error = getaddrinfo(fhost, buf, &hints, &res0);
+	if (error) {
+		FTPLogError(cip, kDontPerror, "%s: %s.\n", fhost, gai_strerror(error));
+		cip->errNo = kErrHostUnknown;
+		return (kErrHostUnknown);
 	}
 	
 	/* After obtaining a socket, try to connect it to a remote
@@ -183,13 +184,14 @@
 	 * every address in the list from the host entry.
 	 */
 
-	if (hpok == 0) {
-		/* Since we're given a single raw address, and not a host entry,
-		 * we can only try this one address and not any other addresses
-		 * that could be present for a site with a host entry.
-		 */
-
-		if ((sockfd = socket(cip->servCtlAddr.sin_family, SOCK_STREAM, 0)) < 0) {
+	/* We can try each address in the list.  We'll quit when we
+	 * run out of addresses to try or get a successful connection.
+	 */
+	for (res = res0; res; res = res->ai_next) {
+		(void) memcpy(&cip->servCtlAddr, res->ai_addr, (size_t)res->ai_addrlen);
+		if ((sockfd = socket(cip->servCtlAddr.ss_family, SOCK_STREAM, 0)) < 0) {
+			if (res0->ai_next)
+				continue;
 			FTPLogError(cip, kDoPerror, "Could not get a socket.\n");
 			cip->errNo = kErrNewStreamSocket;
 			return (kErrNewStreamSocket);
@@ -203,14 +205,14 @@
 		(void) SetSocketBufSize(sockfd, cip->ctrlSocketRBufSize, cip->ctrlSocketSBufSize);
 
 #ifdef NO_SIGNALS
-		err = SConnect(sockfd, &cip->servCtlAddr, (int) cip->connTimeout);
+		err = SConnect(sockfd, (struct sockaddr *)&cip->servCtlAddr, (int) cip->connTimeout);
 
-		if (err < 0) {
-			oerrno = errno;
-			(void) SClose(sockfd, 3);
-			errno = oerrno;
-			sockfd = -1;
-		}
+		if (err == 0)
+			break;
+		oerrno = errno;
+		(void) SClose(sockfd, 3);
+		errno = oerrno;
+		sockfd = -1;
 #else	/* NO_SIGNALS */
 		osigint = (volatile FTPSigProc) signal(SIGINT, CancelConnect);
 		if (cip->connTimeout > 0) {
@@ -239,6 +241,8 @@
 				Error(vcip, kDontPerror, "Connection attempt canceled.\n");
 				(void) kill(getpid(), SIGINT);
 			} else if (gGotSig == SIGALRM) {
+				if (res0->ai_next)
+					continue;
 				result = vcip->errNo = kErrConnectRetryableErr;
 				Error(vcip, kDontPerror, "Connection attempt timed-out.\n");
 				(void) kill(getpid(), SIGALRM);
@@ -247,9 +251,14 @@
 				Error(vcip, kDontPerror, "Connection attempt failed due to an unexpected signal (%d).\n", gGotSig);
 			}
 			return (result);
-		} else  {
+		} else {
 			err = connect(sockfd, (struct sockaddr *) &cip->servCtlAddr,
-				      (int) sizeof (cip->servCtlAddr));
+#ifdef HAVE_SOCKADDR_SA_LEN
+				      cip->servCtlAddr.ss_len
+#else
+				      SA_LEN((struct sockaddr *)&cip->servCtlAddr)
+#endif
+				);
 			if (cip->connTimeout > 0) {
 				(void) alarm(0);
 				(void) signal(SIGALRM, (FTPSigProc) osigalrm);
@@ -257,99 +266,13 @@
 			(void) signal(SIGINT, (FTPSigProc) osigint);
 		}
 
-		if (err < 0) {
-			oerrno = errno;
-			(void) DisposeSocket(sockfd);
-			errno = oerrno;
-			sockfd = -1;
-		}
-#endif	/* NO_SIGNALS */
-	} else {
-		/* We can try each address in the list.  We'll quit when we
-		 * run out of addresses to try or get a successful connection.
-		 */
-		for (curaddr = hp.h_addr_list; *curaddr != NULL; curaddr++) {
-			if ((sockfd = socket(cip->servCtlAddr.sin_family, SOCK_STREAM, 0)) < 0) {
-				FTPLogError(cip, kDoPerror, "Could not get a socket.\n");
-				cip->errNo = kErrNewStreamSocket;
-				return (kErrNewStreamSocket);
-			}
-			/* This could overwrite the address field in the structure,
-			 * but this is okay because the structure has a junk field
-			 * just for this purpose.
-			 */
-			(void) memcpy(&cip->servCtlAddr.sin_addr, *curaddr, (size_t) hp.h_length);
-
-			/* This doesn't do anything if you left these
-			 * at their defaults (zero).  Otherwise it
-			 * tries to set the buffer size to the
-			 * size specified.
-			 */
-			(void) SetSocketBufSize(sockfd, cip->ctrlSocketRBufSize, cip->ctrlSocketSBufSize);
-
-#ifdef NO_SIGNALS
-			err = SConnect(sockfd, &cip->servCtlAddr, (int) cip->connTimeout);
-
-			if (err == 0)
-				break;
-			oerrno = errno;
-			(void) SClose(sockfd, 3);
-			errno = oerrno;
-			sockfd = -1;
-#else	/* NO_SIGNALS */
-
-			osigint = (volatile FTPSigProc) signal(SIGINT, CancelConnect);
-			if (cip->connTimeout > 0) {
-				osigalrm = (volatile FTPSigProc) signal(SIGALRM, CancelConnect);
-				(void) alarm(cip->connTimeout);
-			}
-
-			vcip = cip;
-#ifdef HAVE_SIGSETJMP
-			sj = sigsetjmp(gCancelConnectJmp, 1);
-#else
-			sj = setjmp(gCancelConnectJmp);
-#endif	/* HAVE_SIGSETJMP */
-
-			if (sj != 0) {
-				/* Interrupted by a signal. */
-				(void) DisposeSocket(sockfd);
-				(void) signal(SIGINT, (FTPSigProc) osigint);
-				if (vcip->connTimeout > 0) {
-					(void) alarm(0);
-					(void) signal(SIGALRM, (FTPSigProc) osigalrm);
-				}
-				if (gGotSig == SIGINT) {
-					result = vcip->errNo = kErrConnectMiscErr;
-					Error(vcip, kDontPerror, "Connection attempt canceled.\n");
-					(void) kill(getpid(), SIGINT);
-				} else if (gGotSig == SIGALRM) {
-					result = vcip->errNo = kErrConnectRetryableErr;
-					Error(vcip, kDontPerror, "Connection attempt timed-out.\n");
-					(void) kill(getpid(), SIGALRM);
-				} else {
-					result = vcip->errNo = kErrConnectMiscErr;
-					Error(vcip, kDontPerror, "Connection attempt failed due to an unexpected signal (%d).\n", gGotSig);
-				}
-				return (result);
-			} else {
-				err = connect(sockfd, (struct sockaddr *) &cip->servCtlAddr,
-					      (int) sizeof (cip->servCtlAddr));
-				if (cip->connTimeout > 0) {
-					(void) alarm(0);
-					(void) signal(SIGALRM, (FTPSigProc) osigalrm);
-				}
-				(void) signal(SIGINT, (FTPSigProc) osigint);
-			}
-
-			if (err == 0)
-				break;
-			oerrno = errno;
-			(void) DisposeSocket(sockfd);
-			errno = oerrno;
-			sockfd = -1;
+		if (err == 0)
+			break;
+		oerrno = errno;
+		(void) DisposeSocket(sockfd);
+		errno = oerrno;
+		sockfd = -1;
 #endif /* NO_SIGNALS */
-		}
 	}
 	
 	if (err < 0) {
@@ -408,7 +331,7 @@
 	}
 
 	/* Get our end of the socket address for later use. */
-	if ((result = GetSocketAddress(cip, sockfd, &cip->ourCtlAddr)) < 0)
+	if ((result = GetSocketAddress(cip, sockfd, (struct sockaddr *)&cip->ourCtlAddr)) < 0)
 		goto fatal;
 
 	/* We want Out-of-band data to appear in the regular stream,
@@ -479,11 +402,20 @@
 #endif
 #endif	/* NO_SIGNALS */
 
-	InetNtoA(cip->ip, &cip->servCtlAddr.sin_addr, sizeof(cip->ip));
-	if ((hpok == 0) || (hp.h_name == NULL))
+	getnameinfo((struct sockaddr*)&cip->servCtlAddr,
+#ifdef HAVE_SOCKADDR_SA_LEN
+		    cip->servCtlAddr.ss_len,
+#else
+		    SA_LEN((struct sockaddr *)&cip->servCtlAddr),
+#endif
+		     buf, sizeof(buf), NULL, 0, NI_NUMERICHOST);
+	(void) STRNCPY(cip->ip, buf);
+	if ((res0 == NULL) || (res0->ai_canonname == NULL))
 		(void) STRNCPY(cip->actualHost, fhost);
 	else
-		(void) STRNCPY(cip->actualHost, (char *) hp.h_name);
+		(void) STRNCPY(cip->actualHost, (char *) res0->ai_canonname);
+	freeaddrinfo(res0);
+	res0 = NULL;
 
 	/* Read the startup message from the server. */	
 	rp = InitResponse();
@@ -578,6 +510,10 @@
 	CloseFile(&cip->cout);
 	cip->ctrlSocketR = kClosedFileDescriptor;
 	cip->ctrlSocketW = kClosedFileDescriptor;
+	if (res0) {
+		freeaddrinfo(res0);
+		res0 = NULL;
+	}
 	return (result);
 }	/* OpenControlConnection */
 
@@ -664,11 +600,15 @@
 
 
 static int
-SendPort(const FTPCIPtr cip, struct sockaddr_in *saddr)
+SendPort(const FTPCIPtr cip, struct sockaddr *saddr)
 {
 	char *a, *p;
 	int result;
 	ResponsePtr rp;
+	struct sockaddr_in *saddr4;
+#ifdef ENABLE_IPV6
+	struct sockaddr_in6 *saddr6;
+#endif
 
 	rp = InitResponse();
 	if (rp == NULL) {
@@ -677,16 +617,46 @@
 		return (cip->errNo);
 	}
 
-	/* These will point to data in network byte order. */
-	a = (char *) &saddr->sin_addr;
-	p = (char *) &saddr->sin_port;
 #define UC(x) (int) (((int) x) & 0xff)
+#ifdef ENABLE_IPV6
+	if (saddr->sa_family == AF_INET6) {
+		char host[NI_MAXHOST];
+		char port[NI_MAXSERV];
+
+		getnameinfo(saddr, sizeof(struct sockaddr_in6), host, sizeof(host),
+			    port, sizeof(port), NI_NUMERICHOST | NI_NUMERICSERV);
+
+		saddr6 = (struct sockaddr_in6 *)saddr;
+		/* These will point to data in network byte order. */
+		a = (char *) &saddr6->sin6_addr;
+		p = (char *) &saddr6->sin6_port;
+		/* Need to tell the other side which host (the address) and
+		 * which process (port) on that host to send data to.
+		 */
+		result = RCmd(cip, rp, "EPRT |2|%s|%s|", host, port);
+		if (result != 2) {
+			result = RCmd(cip, rp, "LPRT 6,16,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,2,%d,%d",
+				      UC(a[ 0]), UC(a[ 1]), UC(a[ 2]), UC(a[ 3]),
+				      UC(a[ 4]), UC(a[ 5]), UC(a[ 6]), UC(a[ 7]),
+				      UC(a[ 8]), UC(a[ 9]), UC(a[10]), UC(a[11]),
+				      UC(a[12]), UC(a[13]), UC(a[14]), UC(a[15]),
+				      UC(p[0]), UC(p[1]));
+		}
+	} else {
+#endif
+		saddr4 = (struct sockaddr_in *)saddr;
+		/* These will point to data in network byte order. */
+		a = (char *) &saddr4->sin_addr;
+		p = (char *) &saddr4->sin_port;
 
-	/* Need to tell the other side which host (the address) and
-	 * which process (port) on that host to send data to.
-	 */
-	result = RCmd(cip, rp, "PORT %d,%d,%d,%d,%d,%d",
-		UC(a[0]), UC(a[1]), UC(a[2]), UC(a[3]), UC(p[0]), UC(p[1]));
+		/* Need to tell the other side which host (the address) and
+		 * which process (port) on that host to send data to.
+		 */
+		result = RCmd(cip, rp, "PORT %d,%d,%d,%d,%d,%d",
+			      UC(a[0]), UC(a[1]), UC(a[2]), UC(a[3]), UC(p[0]), UC(p[1]));
+#ifdef ENABLE_IPV6
+	}
+#endif
 
 	if (result < 0) {
 		return (result);
@@ -704,13 +674,18 @@
 
 
 static int
-Passive(const FTPCIPtr cip, struct sockaddr_in *saddr, int *weird)
+Passive(const FTPCIPtr cip, struct sockaddr *saddr, int *weird)
 {
 	ResponsePtr rp;
-	int i[6], j;
-	unsigned char n[6];
+	int i[18], j;
+	unsigned char n[18];
 	char *cp;
 	int result;
+	struct sockaddr_in *saddr4 = (struct sockaddr_in *)saddr;
+#ifdef ENABLE_IPV6
+	struct sockaddr_in6 *saddr6 = (struct sockaddr_in6 *)saddr;
+#endif
+	unsigned short port;
 
 	rp = InitResponse();
 	if (rp == NULL) {
@@ -719,53 +694,159 @@
 		return (cip->errNo);
 	}
 
-	result = RCmd(cip, rp, "PASV");
-	if (result < 0)
-		goto done;
-
-	if (rp->codeType != 2) {
-		/* Didn't understand or didn't want passive port selection. */
-		cip->errNo = result = kErrPASVFailed;
-		goto done;
-	}
-
-	/* The other side returns a specification in the form of
-	 * an internet address as the first four integers (each
-	 * integer stands for 8-bits of the real 32-bit address),
-	 * and two more integers for the port (16-bit port).
-	 *
-	 * It should give us something like:
-	 * "Entering Passive Mode (129,93,33,1,10,187)", so look for
-	 * digits with sscanf() starting 24 characters down the string.
-	 */
+	result = RCmd(cip, rp, "EPSV");
+	if (result != 2)
+		goto next;
+
+	if (rp->codeType != 2)
+		goto next;
+
 	for (cp = rp->msg.first->line; ; cp++) {
 		if (*cp == '\0') {
-			FTPLogError(cip, kDontPerror, "Cannot parse PASV response: %s\n", rp->msg.first->line);
-			goto done;
+			FTPLogError(cip, kDontPerror, "Cannot parse EPSV response: %s\n", rp->msg.first->line);
+			goto next;
 		}
 		if (isdigit((int) *cp))
 			break;
 	}
+	if (sscanf(cp, "%hd|", &port) != 1) {
+		FTPLogError(cip, kDontPerror, "Cannot parse EPSV response: %s\n", rp->msg.first->line);
+		goto next;
+	}
 
-	if (sscanf(cp, "%d,%d,%d,%d,%d,%d",
-			&i[0], &i[1], &i[2], &i[3], &i[4], &i[5]) != 6) {
-		FTPLogError(cip, kDontPerror, "Cannot parse PASV response: %s\n", rp->msg.first->line);
-		goto done;
+
+#ifdef ENABLE_IPV6
+	if (saddr->sa_family == AF_INET6) {
+		saddr6->sin6_addr =
+			((struct sockaddr_in6 *)&cip->servCtlAddr)->sin6_addr;
+		saddr6->sin6_port = htons(port);
+	} else {
+#endif
+		saddr4->sin_addr =
+			((struct sockaddr_in *)&cip->servCtlAddr)->sin_addr;
+		saddr4->sin_port = htons(port);
+#ifdef ENABLE_IPV6
 	}
+#endif
+	goto done;
 
-	for (j=0, *weird = 0; j<6; j++) {
-		/* Some ftp servers return bogus port octets, such as
-		 * boombox.micro.umn.edu.  Let the caller know if we got a
-		 * weird looking octet.
-		 */
-		if ((i[j] < 0) || (i[j] > 255))
-			*weird = *weird + 1;
-		n[j] = (unsigned char) (i[j] & 0xff);
+ next:
+	rp = InitResponse();
+	if (rp == NULL) {
+		FTPLogError(cip, kDontPerror, "Malloc failed.\n");
+		cip->errNo = kErrMallocFailed;
+		return (cip->errNo);
 	}
+	
+#ifdef ENABLE_IPV6
+	if (saddr->sa_family == AF_INET6) {
+		int af, hal, pal;
+
+		result = RCmd(cip, rp, "LPSV");
+		if (result < 0)
+			goto done;
+
+		if (rp->codeType != 2) {
+			/* Didn't understand or didn't want passive port selection. */
+			cip->errNo = result = kErrPASVFailed;
+			goto done;
+		}
+
+		/* The other side returns a specification in the form of
+		 * an internet address as the first four integers (each
+		 * integer stands for 8-bits of the real 32-bit address),
+		 * and two more integers for the port (16-bit port).
+		 *
+		 * It should give us something like:
+		 * "Entering Passive Mode (129,93,33,1,10,187)", so look for
+		 * digits with sscanf() starting 24 characters down the string.
+		 */
+		for (cp = rp->msg.first->line; ; cp++) {
+			if (*cp == '\0') {
+				FTPLogError(cip, kDontPerror, "Cannot parse LPSV response: %s\n", rp->msg.first->line);
+				goto done;
+			}
+			if (isdigit((int) *cp))
+				break;
+		}
+
+		if (sscanf(cp, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",
+			   &af, &hal,
+			   &i[ 0], &i[ 1], &i[ 2], &i[ 3],
+			   &i[ 4], &i[ 5], &i[ 6], &i[ 7],
+			   &i[ 8], &i[ 9], &i[10], &i[11],
+			   &i[12], &i[13], &i[14], &i[15],
+			   &pal,
+			   &i[16], &i[17]) != 21) {
+			FTPLogError(cip, kDontPerror, "Cannot parse LPSV response: %s\n", rp->msg.first->line);
+			goto done;
+		}
+		if (af != 6 || hal != 16 || pal != 2) {
+			FTPLogError(cip, kDontPerror, "Cannot parse LPSV response: %s\n", rp->msg.first->line);
+			goto done;
+		}
+
+		for (j=0, *weird = 0; j<18; j++) {
+			/* Some ftp servers return bogus port octets, such as
+			 * boombox.micro.umn.edu.  Let the caller know if we got a
+			 * weird looking octet.
+			 */
+			if ((i[j] < 0) || (i[j] > 255))
+				*weird = *weird + 1;
+			n[j] = (unsigned char) (i[j] & 0xff);
+		}
+		(void) memcpy(&saddr6->sin6_addr, &n[ 0], (size_t) 16);
+		(void) memcpy(&saddr6->sin6_port, &n[16], (size_t) 2);
+	} else {
+#endif
+		result = RCmd(cip, rp, "PASV");
+		if (result < 0)
+			goto done;
+
+		if (rp->codeType != 2) {
+			/* Didn't understand or didn't want passive port selection. */
+			cip->errNo = result = kErrPASVFailed;
+			goto done;
+		}
 
-	(void) memcpy(&saddr->sin_addr, &n[0], (size_t) 4);
-	(void) memcpy(&saddr->sin_port, &n[4], (size_t) 2);
+		/* The other side returns a specification in the form of
+		 * an internet address as the first four integers (each
+		 * integer stands for 8-bits of the real 32-bit address),
+		 * and two more integers for the port (16-bit port).
+		 *
+		 * It should give us something like:
+		 * "Entering Passive Mode (129,93,33,1,10,187)", so look for
+		 * digits with sscanf() starting 24 characters down the string.
+		 */
+		for (cp = rp->msg.first->line; ; cp++) {
+			if (*cp == '\0') {
+				FTPLogError(cip, kDontPerror, "Cannot parse PASV response: %s\n", rp->msg.first->line);
+				goto done;
+			}
+			if (isdigit((int) *cp))
+				break;
+		}
 
+		if (sscanf(cp, "%d,%d,%d,%d,%d,%d",
+			   &i[0], &i[1], &i[2], &i[3], &i[4], &i[5]) != 6) {
+			FTPLogError(cip, kDontPerror, "Cannot parse PASV response: %s\n", rp->msg.first->line);
+			goto done;
+		}
+
+		for (j=0, *weird = 0; j<6; j++) {
+			/* Some ftp servers return bogus port octets, such as
+			 * boombox.micro.umn.edu.  Let the caller know if we got a
+			 * weird looking octet.
+			 */
+			if ((i[j] < 0) || (i[j] > 255))
+				*weird = *weird + 1;
+			n[j] = (unsigned char) (i[j] & 0xff);
+		}
+		(void) memcpy(&saddr4->sin_addr, &n[0], (size_t) 4);
+		(void) memcpy(&saddr4->sin_port, &n[4], (size_t) 2);
+#ifdef ENABLE_IPV6
+	}
+#endif
 	result = kNoErr;
 done:
 	DoneWithResponse(cip, rp);
@@ -776,30 +857,45 @@
 
 
 static int
-BindToEphemeralPortNumber(int sockfd, struct sockaddr_in *addrp, int ephemLo, int ephemHi)
+BindToEphemeralPortNumber(int sockfd, struct sockaddr *addrp, int ephemLo, int ephemHi)
 {
 	int i;
 	int result;
 	int rangesize;
 	unsigned short port;
 
-	addrp->sin_family = AF_INET;
 	if (((int) ephemLo == 0) || ((int) ephemLo >= (int) ephemHi)) {
 		/* Do it the normal way.  System will
 		 * pick one, typically in the range
 		 * of 1024-4999.
 		 */
-		addrp->sin_port = 0;	/* Let system pick one. */
-
-		result = bind(sockfd, (struct sockaddr *) addrp, sizeof(struct sockaddr_in));
+#ifdef ENABLE_IPV6
+		if (addrp->sa_family == AF_INET6)
+			((struct sockaddr_in6 *)addrp)->sin6_port = 0;	/* Let system pick one. */
+		else
+#endif
+			((struct sockaddr_in *)addrp)->sin_port = 0;	/* Let system pick one. */
+#ifdef HAVE_SOCKADDR_SA_LEN
+		result = bind(sockfd, addrp, addrp->sa_len);
+#else
+		result = bind(sockfd, addrp, SA_LEN(addrp));
+#endif
 	} else {
 		rangesize = (int) ((int) ephemHi - (int) ephemLo);
 		result = 0;
 		for (i=0; i<10; i++) {
 			port = (unsigned short) (((int) rand() % rangesize) + (int) ephemLo);
-			addrp->sin_port = htons(port);
-
-			result = bind(sockfd, (struct sockaddr *) addrp, sizeof(struct sockaddr_in));
+#ifdef ENABLE_IPV6
+			if (addrp->sa_family == AF_INET6)
+				((struct sockaddr_in6 *)addrp)->sin6_port = htons(port);
+			else
+#endif
+				((struct sockaddr_in *)addrp)->sin_port = htons(port);
+#ifdef HAVE_SOCKADDR_SA_LEN
+			result = bind(sockfd, addrp, addrp->sa_len);
+#else
+			result = bind(sockfd, addrp, SA_LEN(addrp));
+#endif
 			if (result == 0)
 				break;
 			if ((errno != 999)
@@ -834,7 +930,11 @@
 	result = 0;
 	CloseDataConnection(cip);	/* In case we didn't before... */
 
+#ifdef ENABLE_IPV6
+	dataSocket = socket(cip->ourCtlAddr.ss_family, SOCK_STREAM, 0);
+#else
 	dataSocket = socket(AF_INET, SOCK_STREAM, 0);
+#endif
 	if (dataSocket < 0) {
 		FTPLogError(cip, kDoPerror, "Could not get a data socket.\n");
 		result = kErrNewStreamSocket;
@@ -852,7 +952,6 @@
 	if ((cip->hasPASV == kCommandNotAvailable) || (mode == kSendPortMode)) {
 tryPort:
 		cip->ourDataAddr = cip->ourCtlAddr;
-		cip->ourDataAddr.sin_family = AF_INET;
 
 #ifdef HAVE_LIBSOCKS
 		cip->ourDataAddr.sin_port = 0;
@@ -860,7 +959,7 @@
 			(int) sizeof (cip->ourDataAddr),
 			cip->servCtlAddr.sin_addr.s_addr) < 0) 
 #else
-		if (BindToEphemeralPortNumber(dataSocket, &cip->ourDataAddr, (int) cip->ephemLo, (int) cip->ephemHi) < 0)
+		if (BindToEphemeralPortNumber(dataSocket, (struct sockaddr *)&cip->ourDataAddr, (int) cip->ephemLo, (int) cip->ephemHi) < 0)
 #endif
 		{
 			FTPLogError(cip, kDoPerror, "Could not bind the data socket");
@@ -872,7 +971,7 @@
 		/* Need to do this so we can figure out which port the system
 		 * gave to us.
 		 */
-		if ((result = GetSocketAddress(cip, dataSocket, &cip->ourDataAddr)) < 0)
+		if ((result = GetSocketAddress(cip, dataSocket, (struct sockaddr *)&cip->ourDataAddr)) < 0)
 			goto bad;
 	
 		if (listen(dataSocket, 1) < 0) {
@@ -882,7 +981,7 @@
 			goto bad;
 		}
 	
-		if ((result = SendPort(cip, &cip->ourDataAddr)) < 0)
+		if ((result = SendPort(cip, (struct sockaddr *)&cip->ourDataAddr)) < 0)
 			goto bad;
 	
 		cip->dataPortMode = kSendPortMode;
@@ -890,11 +989,9 @@
 		/* Passive mode.  Let the other side decide where to send. */
 		
 		cip->servDataAddr = cip->servCtlAddr;
-		cip->servDataAddr.sin_family = AF_INET;
 		cip->ourDataAddr = cip->ourCtlAddr;
-		cip->ourDataAddr.sin_family = AF_INET;
 
-		if (Passive(cip, &cip->servDataAddr, &weirdPort) < 0) {
+		if (Passive(cip, (struct sockaddr *) &cip->servDataAddr, &weirdPort) < 0) {
 			FTPLogError(cip, kDontPerror, "Passive mode refused.\n");
 			cip->hasPASV = kCommandNotAvailable;
 			
@@ -918,7 +1015,7 @@
 			(int) sizeof (cip->ourDataAddr),
 			cip->servCtlAddr.sin_addr.s_addr) < 0) 
 #else
-		if (BindToEphemeralPortNumber(dataSocket, &cip->ourDataAddr, (int) cip->ephemLo, (int) cip->ephemHi) < 0)
+		if (BindToEphemeralPortNumber(dataSocket, (struct sockaddr *)&cip->ourDataAddr, (int) cip->ephemLo, (int) cip->ephemHi) < 0)
 #endif
 		{
 			FTPLogError(cip, kDoPerror, "Could not bind the data socket");
@@ -926,14 +1023,25 @@
 			cip->errNo = kErrBindDataSocket;
 			goto bad;
 		}
+	
+		/* Need to do this so we can figure out which port the system
+		 * gave to us.
+		 */
+		if ((result = GetSocketAddress(cip, dataSocket, (struct sockaddr *)&cip->ourDataAddr)) < 0)
+			goto bad;
 
 #ifdef NO_SIGNALS
-		result = SConnect(dataSocket, &cip->servDataAddr, (int) cip->connTimeout);
+		result = SConnect(dataSocket, (struct sockaddr *)&cip->servDataAddr, (int) cip->connTimeout);
 #else	/* NO_SIGNALS */
 		if (cip->connTimeout > 0)
 			(void) alarm(cip->connTimeout);
-
-		result = connect(dataSocket, (struct sockaddr *) &cip->servDataAddr, (int) sizeof(cip->servDataAddr));
+		result = connect(dataSocket, (struct sockaddr *) &cip->servDataAddr,
+#ifdef HAVE_SOCKADDR_SA_LEN
+				 cip->servDataAddr.ss_len
+#else
+				 SA_LEN((struct sockaddr*)&cip->servDataAddr)
+#endif
+			);
 		if (cip->connTimeout > 0)
 			(void) alarm(0);
 #endif	/* NO_SIGNALS */
@@ -985,7 +1093,7 @@
 		/* Need to do this so we can figure out which port the system
 		 * gave to us.
 		 */
-		if ((result = GetSocketAddress(cip, dataSocket, &cip->ourDataAddr)) < 0)
+		if ((result = GetSocketAddress(cip, dataSocket, (struct sockaddr *) &cip->ourDataAddr)) < 0)
 			goto bad;
 
 		cip->dataPortMode = kPassiveMode;
@@ -1031,7 +1139,7 @@
 		memset(&cip->servDataAddr, 0, sizeof(cip->servDataAddr));
 
 #ifdef NO_SIGNALS
-		newSocket = SAccept(cip->dataSocket, &cip->servDataAddr, (int) cip->connTimeout);
+		newSocket = SAccept(cip->dataSocket, (struct sockaddr *)&cip->servDataAddr, (int) cip->connTimeout);
 #else	/* NO_SIGNALS */
 		len = (int) sizeof(cip->servDataAddr);
 		if (cip->connTimeout > 0)
@@ -1048,11 +1156,16 @@
 			cip->errNo = kErrAcceptDataSocket;
 			return (kErrAcceptDataSocket);
 		}
-	
 		if (cip->allowProxyForPORT == 0) {
-			if (memcmp(&cip->servDataAddr.sin_addr.s_addr, &cip->servCtlAddr.sin_addr.s_addr, sizeof(cip->servDataAddr.sin_addr.s_addr)) != 0) {
-				AddrToAddrStr(ctrlAddrStr, sizeof(ctrlAddrStr), &cip->servCtlAddr, 0, NULL);
-				AddrToAddrStr(dataAddrStr, sizeof(dataAddrStr), &cip->servDataAddr, 0, NULL);
+			if (memcmp(&cip->servDataAddr, &cip->servCtlAddr,
+#ifdef HAVE_SOCKADDR_SA_LEN
+				   cip->servDataAddr.ss_len
+#else
+				   SA_LEN((struct sockaddr *)&cip->servDataAddr)
+#endif
+				    ) != 0) {
+				AddrToAddrStr(ctrlAddrStr, sizeof(ctrlAddrStr), (struct sockaddr *)&cip->servCtlAddr, 0, NULL);
+				AddrToAddrStr(dataAddrStr, sizeof(dataAddrStr), (struct sockaddr *)&cip->servDataAddr, 0, NULL);
 				FTPLogError(cip, kDontPerror, "Data connection from %s did not originate from remote server %s!\n", dataAddrStr, ctrlAddrStr);
 				(void) DisposeSocket(newSocket);
 				cip->dataSocket = kClosedFileDescriptor;
@@ -1060,21 +1173,57 @@
 				return (kErrAcceptDataSocket);
 			}
 		}
-
 		if (cip->require20 != 0) {
-			remoteDataPort = ntohs(cip->servDataAddr.sin_port);
-			remoteCtrlPort = ntohs(cip->servCtlAddr.sin_port);
-			if ((int) remoteDataPort != ((int) remoteCtrlPort - 1)) {
-				FTPLogError(cip, kDontPerror, "Data connection did not originate on correct port!\n");
-				(void) DisposeSocket(newSocket);
-				cip->dataSocket = kClosedFileDescriptor;
-				cip->errNo = kErrAcceptDataSocket;
-				return (kErrAcceptDataSocket);
+#ifdef ENABLE_IPV6
+			if (cip->servDataAddr.ss_family == AF_INET6) {
+				struct sockaddr_in6 *servDataAddr =
+					(struct sockaddr_in6 *) &cip->servDataAddr;
+				struct sockaddr_in6 *servCtlAddr =
+					(struct sockaddr_in6 *) &cip->servCtlAddr;
+
+				remoteDataPort = ntohs(servDataAddr->sin6_port);
+				remoteCtrlPort = ntohs(servCtlAddr->sin6_port);
+				if ((int) remoteDataPort != ((int) remoteCtrlPort - 1)) {
+					FTPLogError(cip, kDontPerror, "Data connection did not originate on correct port!\n");
+					(void) DisposeSocket(newSocket);
+					cip->dataSocket = kClosedFileDescriptor;
+					cip->errNo = kErrAcceptDataSocket;
+					return (kErrAcceptDataSocket);
+				} else if (memcmp(&servDataAddr->sin6_addr, &servCtlAddr->sin6_addr, sizeof(servDataAddr->sin6_addr)) != 0) {
+					FTPLogError(cip, kDontPerror, "Data connection did not originate from remote server!\n");
+					(void) DisposeSocket(newSocket);
+					cip->dataSocket = kClosedFileDescriptor;
+					cip->errNo = kErrAcceptDataSocket;
+					return (kErrAcceptDataSocket);
+				}
+			} else {
+#endif
+				struct sockaddr_in *servDataAddr =
+					(struct sockaddr_in *) &cip->servDataAddr;
+				struct sockaddr_in *servCtlAddr =
+					(struct sockaddr_in *) &cip->servCtlAddr;
+
+				remoteDataPort = ntohs(servDataAddr->sin_port);
+				remoteCtrlPort = ntohs(servCtlAddr->sin_port);
+				if ((int) remoteDataPort != ((int) remoteCtrlPort - 1)) {
+					FTPLogError(cip, kDontPerror, "Data connection did not originate on correct port!\n");
+					(void) DisposeSocket(newSocket);
+					cip->dataSocket = kClosedFileDescriptor;
+					cip->errNo = kErrAcceptDataSocket;
+					return (kErrAcceptDataSocket);
+				} else if (memcmp(&servDataAddr->sin_addr.s_addr, &servCtlAddr->sin_addr.s_addr, sizeof(servDataAddr->sin_addr.s_addr)) != 0) {
+					FTPLogError(cip, kDontPerror, "Data connection did not originate from remote server!\n");
+					(void) DisposeSocket(newSocket);
+					cip->dataSocket = kClosedFileDescriptor;
+					cip->errNo = kErrAcceptDataSocket;
+					return (kErrAcceptDataSocket);
+				}
+#ifdef ENABLE_IPV6
 			}
+#endif		
 		}
 		cip->dataSocket = newSocket;
 	}
-
 	return (0);
 }	/* AcceptDataConnection */
 
Index: ncftp3/libncftp/getaddrinfo.c
diff -u /dev/null ncftp3/libncftp/getaddrinfo.c:1.1
--- /dev/null	Mon Jan 20 08:18:32 2003
+++ ncftp3/libncftp/getaddrinfo.c	Tue Nov  6 23:50:46 2001
@@ -0,0 +1,607 @@
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * 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. Neither the name of the project 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 PROJECT 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 PROJECT 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.
+ */
+
+/*
+ * "#ifdef FAITH" part is local hack for supporting IPv4-v6 translator.
+ *
+ * Issues to be discussed:
+ * - Thread safe-ness must be checked.
+ * - Return values.  There are nonstandard return values defined and used
+ *   in the source code.  This is because RFC2133 is silent about which error
+ *   code must be returned for which situation.
+ * - PF_UNSPEC case would be handled in getipnodebyname() with the AI_ALL flag.
+ */
+
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/sysctl.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <arpa/nameser.h>
+#include <netdb.h>
+#include <resolv.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stddef.h>
+#include <ctype.h>
+#include <unistd.h>
+
+#include "addrinfo.h"
+
+#if defined(__KAME__) && defined(INET6)
+# define FAITH
+#endif
+
+#define SUCCESS 0
+#define ANY 0
+#define YES 1
+#define NO  0
+
+#ifdef FAITH
+static int translate = NO;
+static struct in6_addr faith_prefix = IN6ADDR_ANY_INIT;
+#endif
+
+static const char in_addrany[] = { 0, 0, 0, 0 };
+static const char in6_addrany[] = {
+	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+static const char in_loopback[] = { 127, 0, 0, 1 }; 
+static const char in6_loopback[] = {
+	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
+};
+
+struct sockinet {
+	u_char	si_len;
+	u_char	si_family;
+	u_short	si_port;
+};
+
+static struct afd {
+	int a_af;
+	int a_addrlen;
+	int a_socklen;
+	int a_off;
+	const char *a_addrany;
+	const char *a_loopback;	
+} afdl [] = {
+#ifdef INET6
+#define N_INET6 0
+	{PF_INET6, sizeof(struct in6_addr),
+	 sizeof(struct sockaddr_in6),
+	 offsetof(struct sockaddr_in6, sin6_addr),
+	 in6_addrany, in6_loopback},
+#define N_INET  1
+#else
+#define N_INET  0
+#endif
+	{PF_INET, sizeof(struct in_addr),
+	 sizeof(struct sockaddr_in),
+	 offsetof(struct sockaddr_in, sin_addr),
+	 in_addrany, in_loopback},
+	{0, 0, 0, 0, NULL, NULL},
+};
+
+#ifdef INET6
+#define PTON_MAX	16
+#else
+#define PTON_MAX	4
+#endif
+
+
+static int get_name __P((const char *, struct afd *,
+			  struct addrinfo **, char *, struct addrinfo *,
+			  int));
+static int get_addr __P((const char *, int, struct addrinfo **,
+			struct addrinfo *, int));
+static int str_isnumber __P((const char *));
+	
+static char *ai_errlist[] = {
+	"success.",
+	"address family for hostname not supported.",	/* EAI_ADDRFAMILY */
+	"temporary failure in name resolution.",	/* EAI_AGAIN      */
+	"invalid value for ai_flags.",		       	/* EAI_BADFLAGS   */
+	"non-recoverable failure in name resolution.", 	/* EAI_FAIL       */
+	"ai_family not supported.",			/* EAI_FAMILY     */
+	"memory allocation failure.", 			/* EAI_MEMORY     */
+	"no address associated with hostname.", 	/* EAI_NODATA     */
+	"hostname nor servname provided, or not known.",/* EAI_NONAME     */
+	"servname not supported for ai_socktype.",	/* EAI_SERVICE    */
+	"ai_socktype not supported.", 			/* EAI_SOCKTYPE   */
+	"system error returned in errno.", 		/* EAI_SYSTEM     */
+	"invalid value for hints.",			/* EAI_BADHINTS	  */
+	"resolved protocol is unknown.",		/* EAI_PROTOCOL   */
+	"unknown error.", 				/* EAI_MAX        */
+};
+
+#define GET_CANONNAME(ai, str) \
+if (pai->ai_flags & AI_CANONNAME) {\
+	if (((ai)->ai_canonname = (char *)malloc(strlen(str) + 1)) != NULL) {\
+		strcpy((ai)->ai_canonname, (str));\
+	} else {\
+		error = EAI_MEMORY;\
+		goto free;\
+	}\
+}
+
+#define GET_AI(ai, afd, addr, port) {\
+	char *p;\
+	if (((ai) = (struct addrinfo *)malloc(sizeof(struct addrinfo) +\
+					      ((afd)->a_socklen)))\
+	    == NULL) goto free;\
+	memcpy(ai, pai, sizeof(struct addrinfo));\
+	(ai)->ai_addr = (struct sockaddr *)((ai) + 1);\
+	memset((ai)->ai_addr, 0, (afd)->a_socklen);\
+	(ai)->ai_addr->sa_len = (ai)->ai_addrlen = (afd)->a_socklen;\
+	(ai)->ai_addr->sa_family = (ai)->ai_family = (afd)->a_af;\
+	((struct sockinet *)(ai)->ai_addr)->si_port = port;\
+	p = (char *)((ai)->ai_addr);\
+	memcpy(p + (afd)->a_off, (addr), (afd)->a_addrlen);\
+}
+
+#define ERR(err) { error = (err); goto bad; }
+
+char *
+gai_strerror(ecode)
+	int ecode;
+{
+	if (ecode < 0 || ecode > EAI_MAX)
+		ecode = EAI_MAX;
+	return ai_errlist[ecode];
+}
+
+void
+freeaddrinfo(ai)
+	struct addrinfo *ai;
+{
+	struct addrinfo *next;
+
+	do {
+		next = ai->ai_next;
+		if (ai->ai_canonname)
+			free(ai->ai_canonname);
+		/* no need to free(ai->ai_addr) */
+		free(ai);
+	} while ((ai = next) != NULL);
+}
+
+static int
+str_isnumber(p)
+	const char *p;
+{
+	char *q = (char *)p;
+	while (*q) {
+		if (! isdigit(*q))
+			return NO;
+		q++;
+	}
+	return YES;
+}
+
+int
+getaddrinfo(hostname, servname, hints, res)
+	const char *hostname, *servname;
+	const struct addrinfo *hints;
+	struct addrinfo **res;
+{
+	struct addrinfo sentinel;
+	struct addrinfo *top = NULL;
+	struct addrinfo *cur;
+	int i, error = 0;
+	char pton[PTON_MAX];
+	struct addrinfo ai;
+	struct addrinfo *pai;
+	u_short port;
+
+#ifdef FAITH
+	static int firsttime = 1;
+
+	if (firsttime) {
+		/* translator hack */
+		{
+			char *q = getenv("GAI");
+			if (q && inet_pton(AF_INET6, q, &faith_prefix) == 1)
+				translate = YES;
+		}
+		firsttime = 0;
+	}
+#endif
+
+	/* initialize file static vars */
+	sentinel.ai_next = NULL;
+	cur = &sentinel;
+	pai = &ai;
+	pai->ai_flags = 0;
+	pai->ai_family = PF_UNSPEC;
+	pai->ai_socktype = ANY;
+	pai->ai_protocol = ANY;
+	pai->ai_addrlen = 0;
+	pai->ai_canonname = NULL;
+	pai->ai_addr = NULL;
+	pai->ai_next = NULL;
+	port = ANY;
+	
+	if (hostname == NULL && servname == NULL)
+		return EAI_NONAME;
+	if (hints) {
+		/* error check for hints */
+		if (hints->ai_addrlen || hints->ai_canonname ||
+		    hints->ai_addr || hints->ai_next)
+			ERR(EAI_BADHINTS); /* xxx */
+		if (hints->ai_flags & ~AI_MASK)
+			ERR(EAI_BADFLAGS);
+		switch (hints->ai_family) {
+		case PF_UNSPEC:
+		case PF_INET:
+#ifdef INET6
+		case PF_INET6:
+#endif
+			break;
+		default:
+			ERR(EAI_FAMILY);
+		}
+		memcpy(pai, hints, sizeof(*pai));
+		switch (pai->ai_socktype) {
+		case ANY:
+			switch (pai->ai_protocol) {
+			case ANY:
+				break;
+			case IPPROTO_UDP:
+				pai->ai_socktype = SOCK_DGRAM;
+				break;
+			case IPPROTO_TCP:
+				pai->ai_socktype = SOCK_STREAM;
+				break;
+			default:
+				pai->ai_socktype = SOCK_RAW;
+				break;
+			}
+			break;
+		case SOCK_RAW:
+			break;
+		case SOCK_DGRAM:
+			if (pai->ai_protocol != IPPROTO_UDP &&
+			    pai->ai_protocol != ANY)
+				ERR(EAI_BADHINTS);	/*xxx*/
+			pai->ai_protocol = IPPROTO_UDP;
+			break;
+		case SOCK_STREAM:
+			if (pai->ai_protocol != IPPROTO_TCP &&
+			    pai->ai_protocol != ANY)
+				ERR(EAI_BADHINTS);	/*xxx*/
+			pai->ai_protocol = IPPROTO_TCP;
+			break;
+		default:
+			ERR(EAI_SOCKTYPE);
+			break;
+		}
+	}
+
+	/*
+	 * service port
+	 */
+	if (servname) {
+		if (str_isnumber(servname)) {
+			if (pai->ai_socktype == ANY) {
+				/* caller accept *ANY* socktype */
+				pai->ai_socktype = SOCK_DGRAM;
+				pai->ai_protocol = IPPROTO_UDP;
+			}
+			port = htons(atoi(servname));
+		} else {
+			struct servent *sp;
+			char *proto;
+
+			proto = NULL;
+			switch (pai->ai_socktype) {
+			case ANY:
+				proto = NULL;
+				break;
+			case SOCK_DGRAM:
+				proto = "udp";
+				break;
+			case SOCK_STREAM:
+				proto = "tcp";
+				break;
+			default:
+				fprintf(stderr, "panic!\n");
+				break;
+			}
+			if ((sp = getservbyname(servname, proto)) == NULL)
+				ERR(EAI_SERVICE);
+			port = sp->s_port;
+			if (pai->ai_socktype == ANY)
+				if (strcmp(sp->s_proto, "udp") == 0) {
+					pai->ai_socktype = SOCK_DGRAM;
+					pai->ai_protocol = IPPROTO_UDP;
+				} else if (strcmp(sp->s_proto, "tcp") == 0) {
+					pai->ai_socktype = SOCK_STREAM;
+					pai->ai_protocol = IPPROTO_TCP;
+				} else
+					ERR(EAI_PROTOCOL);	/*xxx*/
+		}
+	}
+	
+	/*
+	 * hostname == NULL.
+	 * passive socket -> anyaddr (0.0.0.0 or ::)
+	 * non-passive socket -> localhost (127.0.0.1 or ::1)
+	 */
+	if (hostname == NULL) {
+		struct afd *afd;
+
+		for (afd = &afdl[0]; afd->a_af; afd++) {
+			if (!(pai->ai_family == PF_UNSPEC
+			   || pai->ai_family == afd->a_af)) {
+				continue;
+			}
+
+			if (pai->ai_flags & AI_PASSIVE) {
+				GET_AI(cur->ai_next, afd, afd->a_addrany, port);
+				/* xxx meaningless?
+				 * GET_CANONNAME(cur->ai_next, "anyaddr");
+				 */
+			} else {
+				GET_AI(cur->ai_next, afd, afd->a_loopback,
+					port);
+				/* xxx meaningless?
+				 * GET_CANONNAME(cur->ai_next, "localhost");
+				 */
+			}
+			cur = cur->ai_next;
+		}
+		top = sentinel.ai_next;
+		if (top)
+			goto good;
+		else
+			ERR(EAI_FAMILY);
+	}
+	
+	/* hostname as numeric name */
+	for (i = 0; afdl[i].a_af; i++) {
+		if (inet_pton(afdl[i].a_af, hostname, pton)) {
+			u_long v4a;
+			u_char pfx;
+
+			switch (afdl[i].a_af) {
+			case AF_INET:
+				v4a = ((struct in_addr *)pton)->s_addr;
+				if (IN_MULTICAST(v4a) || IN_EXPERIMENTAL(v4a))
+					pai->ai_flags &= ~AI_CANONNAME;
+				v4a >>= IN_CLASSA_NSHIFT;
+				if (v4a == 0 || v4a == IN_LOOPBACKNET)
+					pai->ai_flags &= ~AI_CANONNAME;
+				break;
+#ifdef INET6
+			case AF_INET6:
+				pfx = ((struct in6_addr *)pton)->s6_addr8[0];
+				if (pfx == 0 || pfx == 0xfe || pfx == 0xff)
+					pai->ai_flags &= ~AI_CANONNAME;
+				break;
+#endif
+			}
+			
+			if (pai->ai_family == afdl[i].a_af ||
+			    pai->ai_family == PF_UNSPEC) {
+				if (! (pai->ai_flags & AI_CANONNAME)) {
+					GET_AI(top, &afdl[i], pton, port);
+					goto good;
+				}
+				/*
+				 * if AI_CANONNAME and if reverse lookup
+				 * fail, return ai anyway to pacify
+				 * calling application.
+				 *
+				 * XXX getaddrinfo() is a name->address
+				 * translation function, and it looks strange
+				 * that we do addr->name translation here.
+				 */
+				get_name(pton, &afdl[i], &top, pton, pai, port);
+				goto good;
+			} else 
+				ERR(EAI_FAMILY);	/*xxx*/
+		}
+	}
+
+	if (pai->ai_flags & AI_NUMERICHOST)
+		ERR(EAI_NONAME);
+
+	/* hostname as alphabetical name */
+	error = get_addr(hostname, pai->ai_family, &top, pai, port);
+	if (error == 0) {
+		if (top) {
+ good:
+			*res = top;
+			return SUCCESS;
+		} else
+			error = EAI_FAIL;
+	}
+ free:
+	if (top)
+		freeaddrinfo(top);
+ bad:
+	*res = NULL;
+	return error;
+}
+
+static int
+get_name(addr, afd, res, numaddr, pai, port0)
+	const char *addr;
+	struct afd *afd;
+	struct addrinfo **res;
+	char *numaddr;
+	struct addrinfo *pai;
+	int port0;
+{
+	u_short port = port0 & 0xffff;
+	struct hostent *hp;
+	struct addrinfo *cur;
+	int error = 0, h_error;
+	
+#ifdef INET6
+	hp = getipnodebyaddr(addr, afd->a_addrlen, afd->a_af, &h_error);
+#else
+	hp = gethostbyaddr(addr, afd->a_addrlen, AF_INET);
+#endif
+	if (hp && hp->h_name && hp->h_name[0] && hp->h_addr_list[0]) {
+		GET_AI(cur, afd, hp->h_addr_list[0], port);
+		GET_CANONNAME(cur, hp->h_name);
+	} else
+		GET_AI(cur, afd, numaddr, port);
+	
+#ifdef INET6
+	if (hp)
+		freehostent(hp);
+#endif
+	*res = cur;
+	return SUCCESS;
+ free:
+	if (cur)
+		freeaddrinfo(cur);
+#ifdef INET6
+	if (hp)
+		freehostent(hp);
+#endif
+ /* bad: */
+	*res = NULL;
+	return error;
+}
+
+static int
+get_addr(hostname, af, res, pai, port0)
+	const char *hostname;
+	int af;
+	struct addrinfo **res;
+	struct addrinfo *pai;
+	int port0;
+{
+	u_short port = port0 & 0xffff;
+	struct addrinfo sentinel;
+	struct hostent *hp;
+	struct addrinfo *top, *cur;
+	struct afd *afd;
+	int i, error = 0, h_error;
+	char *ap;
+#ifndef INET6
+	extern int h_errno;
+#endif
+
+	top = NULL;
+	sentinel.ai_next = NULL;
+	cur = &sentinel;
+#ifdef INET6
+	if (af == AF_UNSPEC) {
+		hp = getipnodebyname(hostname, AF_INET6,
+				AI_ADDRCONFIG|AI_ALL|AI_V4MAPPED, &h_error);
+	} else
+		hp = getipnodebyname(hostname, af, AI_ADDRCONFIG, &h_error);
+#else
+	hp = gethostbyname(hostname);
+	h_error = h_errno;
+#endif
+	if (hp == NULL) {
+		switch (h_error) {
+		case HOST_NOT_FOUND:
+		case NO_DATA:
+			error = EAI_NODATA;
+			break;
+		case TRY_AGAIN:
+			error = EAI_AGAIN;
+			break;
+		case NO_RECOVERY:
+		default:
+			error = EAI_FAIL;
+			break;
+		}
+		goto bad;
+	}
+
+	if ((hp->h_name == NULL) || (hp->h_name[0] == 0) ||
+	    (hp->h_addr_list[0] == NULL))
+		ERR(EAI_FAIL);
+	
+	for (i = 0; (ap = hp->h_addr_list[i]) != NULL; i++) {
+		switch (af) {
+#ifdef INET6
+		case AF_INET6:
+			afd = &afdl[N_INET6];
+			break;
+#endif
+#ifndef INET6
+		default:	/* AF_UNSPEC */
+#endif
+		case AF_INET:
+			afd = &afdl[N_INET];
+			break;
+#ifdef INET6
+		default:	/* AF_UNSPEC */
+			if (IN6_IS_ADDR_V4MAPPED((struct in6_addr *)ap)) {
+				ap += sizeof(struct in6_addr) -
+					sizeof(struct in_addr);
+				afd = &afdl[N_INET];
+			} else
+				afd = &afdl[N_INET6];
+			break;
+#endif
+		}
+#ifdef FAITH
+		if (translate && afd->a_af == AF_INET) {
+			struct in6_addr *in6;
+
+			GET_AI(cur->ai_next, &afdl[N_INET6], ap, port);
+			in6 = &((struct sockaddr_in6 *)cur->ai_next->ai_addr)->sin6_addr;
+			memcpy(&in6->s6_addr32[0], &faith_prefix,
+			    sizeof(struct in6_addr) - sizeof(struct in_addr));
+			memcpy(&in6->s6_addr32[3], ap, sizeof(struct in_addr));
+		} else
+#endif /* FAITH */
+		GET_AI(cur->ai_next, afd, ap, port);
+		if (cur == &sentinel) {
+			top = cur->ai_next;
+			GET_CANONNAME(top, hp->h_name);
+		}
+		cur = cur->ai_next;
+	}
+#ifdef INET6
+	freehostent(hp);
+#endif
+	*res = top;
+	return SUCCESS;
+ free:
+	if (top)
+		freeaddrinfo(top);
+#ifdef INET6
+	if (hp)
+		freehostent(hp);
+#endif
+ bad:
+	*res = NULL;
+	return error;
+}
Index: ncftp3/libncftp/getnameinfo.c
diff -u /dev/null ncftp3/libncftp/getnameinfo.c:1.1
--- /dev/null	Mon Jan 20 08:18:32 2003
+++ ncftp3/libncftp/getnameinfo.c	Tue Nov  6 23:50:47 2001
@@ -0,0 +1,203 @@
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * 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. Neither the name of the project 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 PROJECT 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 PROJECT 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.
+ */
+
+/*
+ * Issues to be discussed:
+ * - Thread safe-ness must be checked
+ * - Return values.  There seems to be no standard for return value (RFC2133)
+ *   but INRIA implementation returns EAI_xxx defined for getaddrinfo().
+ */
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <arpa/nameser.h>
+#include <netdb.h>
+#include <resolv.h>
+#include <string.h>
+#include <stddef.h>
+
+#include "addrinfo.h"
+
+#define SUCCESS 0
+#define ANY 0
+#define YES 1
+#define NO  0
+
+static struct afd {
+	int a_af;
+	int a_addrlen;
+	int a_socklen;
+	int a_off;
+} afdl [] = {
+#ifdef INET6
+	{PF_INET6, sizeof(struct in6_addr), sizeof(struct sockaddr_in6),
+		offsetof(struct sockaddr_in6, sin6_addr)},
+#endif
+	{PF_INET, sizeof(struct in_addr), sizeof(struct sockaddr_in),
+		offsetof(struct sockaddr_in, sin_addr)},
+	{0, 0, 0},
+};
+
+struct sockinet {
+	u_char	si_len;
+	u_char	si_family;
+	u_short	si_port;
+};
+
+#define ENI_NOSOCKET 	0
+#define ENI_NOSERVNAME	1
+#define ENI_NOHOSTNAME	2
+#define ENI_MEMORY	3
+#define ENI_SYSTEM	4
+#define ENI_FAMILY	5
+#define ENI_SALEN	6
+
+int
+getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
+	const struct sockaddr *sa;
+	size_t salen;
+	char *host;
+	size_t hostlen;
+	char *serv;
+	size_t servlen;
+	int flags;
+{
+	struct afd *afd;
+	struct servent *sp;
+	struct hostent *hp;
+	u_short port;
+	int family, len, i;
+	char *addr, *p;
+	u_long v4a;
+	u_char pfx;
+	int h_error;
+	char numserv[512];
+	char numaddr[512];
+
+	if (sa == NULL)
+		return ENI_NOSOCKET;
+
+	len = sa->sa_len;
+	if (len != salen) return ENI_SALEN;
+	
+	family = sa->sa_family;
+	for (i = 0; afdl[i].a_af; i++)
+		if (afdl[i].a_af == family) {
+			afd = &afdl[i];
+			goto found;
+		}
+	return ENI_FAMILY;
+	
+ found:
+	if (len != afd->a_socklen) return ENI_SALEN;
+	
+	port = ((struct sockinet *)sa)->si_port; /* network byte order */
+	addr = (char *)sa + afd->a_off;
+
+	if (serv == NULL || servlen == 0) {
+		/* what we should do? */
+	} else if (flags & NI_NUMERICSERV) {
+		snprintf(numserv, sizeof(numserv), "%d", ntohs(port));
+		if (strlen(numserv) > servlen)
+			return ENI_MEMORY;
+		strcpy(serv, numserv);
+	} else {
+		sp = getservbyport(port, (flags & NI_DGRAM) ? "udp" : "tcp");
+		if (sp) {
+			if (strlen(sp->s_name) > servlen)
+				return ENI_MEMORY;
+			strcpy(serv, sp->s_name);
+		} else
+			return ENI_NOSERVNAME;
+	}
+
+	switch (sa->sa_family) {
+	case AF_INET:
+		v4a = ((struct sockaddr_in *)sa)->sin_addr.s_addr;
+		if (IN_MULTICAST(v4a) || IN_EXPERIMENTAL(v4a))
+			flags |= NI_NUMERICHOST;
+		v4a >>= IN_CLASSA_NSHIFT;
+		if (v4a == 0 || v4a == IN_LOOPBACKNET)
+			flags |= NI_NUMERICHOST;			
+		break;
+#ifdef INET6
+	case AF_INET6:
+		pfx = ((struct sockaddr_in6 *)sa)->sin6_addr.s6_addr8[0];
+		if (pfx == 0 || pfx == 0xfe || pfx == 0xff)
+			flags |= NI_NUMERICHOST;
+		break;
+#endif
+	}
+	if (host == NULL || hostlen == 0) {
+		/* what should we do? */
+	} else if (flags & NI_NUMERICHOST) {
+		if (inet_ntop(afd->a_af, addr, numaddr, sizeof(numaddr))
+		    == NULL)
+			return ENI_SYSTEM;
+		if (strlen(numaddr) > hostlen)
+			return ENI_MEMORY;
+		strcpy(host, numaddr);
+	} else {
+#ifdef INET6
+		hp = getipnodebyaddr(addr, afd->a_addrlen, afd->a_af, &h_error);
+#else
+		hp = gethostbyaddr(addr, afd->a_addrlen, afd->a_af);
+		h_error = h_errno;
+#endif
+
+		if (hp) {
+			if (flags & NI_NOFQDN) {
+				p = strchr(hp->h_name, '.');
+				if (p) *p = '\0';
+			}
+			if (strlen(hp->h_name) > hostlen) {
+#ifdef INET6
+				freehostent(hp);
+#endif
+				return ENI_MEMORY;
+			}
+			strcpy(host, hp->h_name);
+#ifdef INET6
+			freehostent(hp);
+#endif
+		} else {
+			if (flags & NI_NAMEREQD)
+				return ENI_NOHOSTNAME;
+			if (inet_ntop(afd->a_af, addr, numaddr, sizeof(numaddr))
+			    == NULL)
+				return ENI_NOHOSTNAME;
+			if (strlen(numaddr) > hostlen)
+				return ENI_MEMORY;
+			strcpy(host, numaddr);
+		}
+	}
+	return SUCCESS;
+}
Index: ncftp3/libncftp/ncftp.h
diff -u ncftp3/libncftp/ncftp.h:1.1.1.14 ncftp3/libncftp/ncftp.h:1.18
--- ncftp3/libncftp/ncftp.h:1.1.1.14	Sun Jan 12 11:25:57 2003
+++ ncftp3/libncftp/ncftp.h	Sun Jan 12 11:45:18 2003
@@ -374,11 +374,10 @@
 	int mlsFeatures;			/* Do not modify this field. */
 	int STATfileParamWorks;			/* Do not modify this field. */
 	int NLSTfileParamWorks;			/* Do not modify this field. */
-
-	struct sockaddr_in servCtlAddr;		/* Do not modify this field. */
-	struct sockaddr_in servDataAddr;	/* Do not modify this field. */
-	struct sockaddr_in ourCtlAddr;		/* Do not modify this field. */
-	struct sockaddr_in ourDataAddr;		/* Do not modify this field. */
+	struct sockaddr_storage servCtlAddr;	/* Do not modify this field. */
+	struct sockaddr_storage servDataAddr;	/* Do not modify this field. */
+	struct sockaddr_storage ourCtlAddr;	/* Do not modify this field. */
+	struct sockaddr_storage ourDataAddr;	/* Do not modify this field. */
 	int netMode;				/* Do not use or modify. */
 	char *buf;				/* Do not modify this field. */
 	size_t bufSize;				/* Do not modify this field. */
@@ -735,9 +734,9 @@
 
 /* The following block may be changed by configure script */
 #ifndef Stat
-#define Stat stat64
-#define Lstat lstat64
-#define Fstat fstat64
+#define Stat stat
+#define Lstat lstat
+#define Fstat fstat
 #endif
 
 #define kFtwNoAutoGrowButContinue (-1)
Index: ncftp3/libncftp/syshdrs.h
diff -u ncftp3/libncftp/syshdrs.h:1.1.1.9 ncftp3/libncftp/syshdrs.h:1.8
--- ncftp3/libncftp/syshdrs.h:1.1.1.9	Thu May 30 23:40:31 2002
+++ ncftp3/libncftp/syshdrs.h	Thu May 30 23:49:39 2002
@@ -23,6 +23,10 @@
 #		define _WIN32_WINNT 0x0400
 #	endif
 #	include <windows.h>		/* includes <winsock2.h> if _WIN32_WINNT >= 0x400 */
+#	ifdef ENABLE_IPV6
+#	include <ws2tcpip.h>
+#	define INET6_ADDRSTRLEN 46
+#	endif /* ENABLE_IPV6 */
 #	include <shlobj.h>
 #	include <io.h>
 #	include <conio.h>
@@ -161,6 +165,9 @@
 #		include <resolv.h>
 #	endif
 
+#	ifndef HAVE_GETADDRINFO
+#	include "addrinfo.h"
+#	endif
 #	ifdef CAN_USE_SYS_SELECT_H
 #		include <sys/select.h>
 #	endif
Index: ncftp3/ncftp/cmds.c
diff -u ncftp3/ncftp/cmds.c:1.1.1.13 ncftp3/ncftp/cmds.c:1.12
--- ncftp3/ncftp/cmds.c:1.1.1.13	Sun Jan 12 11:26:06 2003
+++ ncftp3/ncftp/cmds.c	Sun Jan 12 11:45:18 2003
@@ -2253,8 +2253,7 @@
 			(void) printf("Unknown host \"%s\".\n", ohost);
 			return (-1);
 		}
-		(void) STRNCPY(gConn.host, ipstr);
-		OpenMsg("Connecting to %s...", ipstr);
+		OpenMsg("Connecting to %s...", gConn.host);
 	} else {
 		OpenMsg("Connecting to %s via %s...", gConn.host, gConn.firewallHost);
 		Trace(0, "Fw: %s  Type: %d  User: %s  Pass: %s  Port: %u\n", 
Index: ncftp3/ncftp/syshdrs.h
diff -u ncftp3/ncftp/syshdrs.h:1.1.1.10 ncftp3/ncftp/syshdrs.h:1.8
--- ncftp3/ncftp/syshdrs.h:1.1.1.10	Thu May 30 23:40:58 2002
+++ ncftp3/ncftp/syshdrs.h	Thu May 30 23:49:39 2002
@@ -32,6 +32,9 @@
 #		define _WIN32_WINNT 0x0400
 #	endif
 #	include <windows.h>		/* includes <winsock2.h> if _WIN32_WINNT >= 0x400 */
+#ifdef ENABLE_IPV6
+#	include <ws2tcpip.h>
+#endif /* ENABLE_IPV6 */
 #	include <shlobj.h>
 #	include <process.h>
 #	include <direct.h>
@@ -155,6 +158,9 @@
 #	include <time.h>
 #	include <pwd.h>
 #	include <fcntl.h>
+#	ifndef HAVE_GETADDRINFO
+#		include "addrinfo.h"
+#	endif
 #	if defined(HAVE_SYS_IOCTL_H) && defined(HAVE_TERMIOS_H)
 #		include <sys/ioctl.h>
 #		include <termios.h>
Index: ncftp3/ncftp/util.c
diff -u ncftp3/ncftp/util.c:1.1.1.11 ncftp3/ncftp/util.c:1.21
--- ncftp3/ncftp/util.c:1.1.1.11	Sat Jul  6 10:54:56 2002
+++ ncftp3/ncftp/util.c	Tue Jul  9 15:08:50 2002
@@ -643,44 +643,30 @@
 int
 MyGetHostByName(char *const volatile dst, size_t dsize, const char *const hn, int t)
 {
+	struct addrinfo hints;
+	struct addrinfo *res;
+	int error;
 #if (defined(WIN32) || defined(_WINDOWS)) && !defined(__CYGWIN__)
-	struct hostent *hp;
-	struct in_addr ina;
 
-	if (inet_addr(hn) != (unsigned long) 0xFFFFFFFF) {
-		/* Address is an IP address string, which is what we want. */
-		(void) Strncpy(dst, hn, dsize);
-		return (0);
-	}
-
-	hp = gethostbyname(hn);
-	if (hp != NULL) {
-		(void) memcpy(&ina.s_addr, hp->h_addr_list[0], (size_t) hp->h_length);
-		InetNtoA(dst, ((struct in_addr **) hp->h_addr_list)[0], dsize);
+	memset(&hints, 0, sizeof(hints));
+	hints.ai_family = PF_UNSPEC;
+	hints.ai_socktype = SOCK_STREAM;
+	error = getaddrinfo(hn, NULL, &hints, &res);
+
+	if (error == 0) {
+		char buf[NI_MAXHOST];
+
+		getnameinfo(res->ai_addr, res->ai_addrlen,
+			    buf, sizeof(buf),
+			    NULL, 0, NI_NUMERICHOST);
+		(void) Strncpy(dst, buf, dsize);
+		freeaddrinfo(res);
 		return (0);
 	}
 
 #else
 	int sj;
 	vsigproc_t osigpipe, osigint, osigalrm;
-	struct hostent *hp;
-#ifdef HAVE_INET_ATON
-	struct in_addr ina;
-#endif
-
-#ifdef HAVE_INET_ATON
-	if (inet_aton(hn, &ina) != 0) {
-		/* Address is an IP address string, which is what we want. */
-		(void) Strncpy(dst, hn, dsize);
-		return (0);
-	}
-#else
-	if (inet_addr(hn) != (unsigned long) 0xFFFFFFFF) {
-		/* Address is an IP address string, which is what we want. */
-		(void) Strncpy(dst, hn, dsize);
-		return (0);
-	}
-#endif
 
 #ifdef HAVE_SIGSETJMP
 	osigpipe = osigint = osigalrm = (sigproc_t) 0;
@@ -705,14 +691,25 @@
 		osigalrm = NcSignal(SIGALRM, CancelGetHostByName);
 		if (t > 0)
 			(void) alarm((unsigned int) t);
-		hp = gethostbyname(hn);
+		memset(&hints, 0, sizeof(hints));
+		hints.ai_flags = 0;
+		hints.ai_family = PF_UNSPEC;
+		hints.ai_socktype = SOCK_STREAM;
+		hints.ai_protocol = 0;
+		error = getaddrinfo(hn, NULL, &hints, &res);
 		if (t > 0)
 			(void) alarm(0);
 		(void) NcSignal(SIGPIPE, osigpipe);
 		(void) NcSignal(SIGINT, osigint);
 		(void) NcSignal(SIGALRM, osigalrm);
-		if (hp != NULL) {
-			InetNtoA(dst, ((struct in_addr **) hp->h_addr_list)[0], dsize);
+		if (error == 0) {
+			char buf[NI_MAXHOST];
+
+			getnameinfo(res->ai_addr, res->ai_addrlen,
+				    buf, sizeof(buf),
+				    NULL, 0, NI_NUMERICHOST);
+			(void) Strncpy(dst, buf, dsize);
+			freeaddrinfo(res);
 			return (0);
 		}
 	}
Index: ncftp3/sh_util/syshdrs.h
diff -u ncftp3/sh_util/syshdrs.h:1.1.1.8 ncftp3/sh_util/syshdrs.h:1.8
--- ncftp3/sh_util/syshdrs.h:1.1.1.8	Thu May 30 23:40:49 2002
+++ ncftp3/sh_util/syshdrs.h	Thu May 30 23:49:39 2002
@@ -32,6 +32,9 @@
 #		define _WIN32_WINNT 0x0400
 #	endif
 #	include <windows.h>		/* includes <winsock2.h> if _WIN32_WINNT >= 0x400 */
+#ifdef ENABLE_IPV6
+#	include <ws2tcpip.h>
+#endif /* ENABLE_IPV6 */
 #	include <shlobj.h>
 #	include <tchar.h>
 #	include <process.h>
@@ -162,6 +165,9 @@
 #	include <pwd.h>
 #	include <fcntl.h>
 #	include <dirent.h>
+#	ifndef HAVE_GETADDRINFO
+#		include "addrinfo.h"
+#	endif
 #	ifdef HAVE_LOCALE_H
 #		include <locale.h>
 #	endif
Index: ncftp3/sio/SAcceptA.c
diff -u ncftp3/sio/SAcceptA.c:1.1.1.2 ncftp3/sio/SAcceptA.c:1.3
--- ncftp3/sio/SAcceptA.c:1.1.1.2	Sun Feb  3 08:41:17 2002
+++ ncftp3/sio/SAcceptA.c	Wed Aug  7 01:15:29 2002
@@ -8,8 +8,20 @@
 extern Sjmp_buf gPipeJmp;
 #endif
 
+#ifndef HAVE_SOCKADDR_SA_LEN
+#ifndef SA_LEN
+#ifdef ENABLE_IPV6
+#define SA_LEN(x) (((x)->sa_family == AF_INET6) ? sizeof(struct sockaddr_in6) \
+		: (((x)->sa_family == AF_INET) ? sizeof(struct sockaddr_in) \
+		: -1))
+#else  /* ENABLE_IPV6 */
+#define SA_LEN(x) (((x)->sa_family == AF_INET) ? sizeof(struct sockaddr_in) : -1)
+#endif /* ENABLE_IPV6 */
+#endif /* SA_LEN */
+#endif /* HAVE_SOCKADDR_SA_LEN */
+
 int
-SAcceptA(int sfd, struct sockaddr_in *const addr, int tlen)
+SAcceptA(int sfd, struct sockaddr *const addr, int tlen)
 {
 	int result;
 #ifndef NO_SIGNALS
@@ -20,8 +32,12 @@
 	if (tlen < 0) {
 		errno = 0;
 		for (;;) {
-			size = (sockaddr_size_t) sizeof(struct sockaddr_in);
-			result = accept(sfd, (struct sockaddr *) addr, &size);
+#ifdef HAVE_SOCKADDR_SA_LEN
+			size = (sockaddr_size_t) (addr->sa_len);
+#else
+			size = (sockaddr_size_t) SA_LEN(addr);
+#endif
+			result = accept(sfd, addr, &size);
 			if ((result >= 0) || (errno != EINTR))
 				return (result);
 		}
@@ -41,8 +57,8 @@
 
 	errno = 0;
 	do {
-		size = (sockaddr_size_t) sizeof(struct sockaddr_in);
-		result = accept(sfd, (struct sockaddr *) addr, &size);
+		size = (sockaddr_size_t) (addr->psa_len);
+		result = accept(sfd, addr, &size);
 	} while ((result < 0) && (errno == EINTR));
 
 	alarm(0);
Index: ncftp3/sio/SAcceptS.c
diff -u ncftp3/sio/SAcceptS.c:1.1.1.2 ncftp3/sio/SAcceptS.c:1.4
--- ncftp3/sio/SAcceptS.c:1.1.1.2	Sun Feb  3 08:41:22 2002
+++ ncftp3/sio/SAcceptS.c	Wed Aug  7 01:58:12 2002
@@ -3,8 +3,20 @@
 #	pragma hdrstop
 #endif
 
+#ifndef HAVE_SOCKADDR_SA_LEN
+#ifndef SA_LEN
+#ifdef ENABLE_IPV6
+#define SA_LEN(x) (((x)->sa_family == AF_INET6) ? sizeof(struct sockaddr_in6) \
+		: (((x)->sa_family == AF_INET) ? sizeof(struct sockaddr_in) \
+		: -1))
+#else  /* ENABLE_IPV6 */
+#define SA_LEN(x) (((x)->sa_family == AF_INET) ? sizeof(struct sockaddr_in) : -1)
+#endif /* ENABLE_IPV6 */
+#endif /* SA_LEN */
+#endif /* HAVE_SOCKADDR_SA_LEN */
+
 int
-SAcceptS(int sfd, struct sockaddr_in *const addr, int tlen)
+SAcceptS(int sfd, struct sockaddr *const addr, int tlen)
 {
 	int result;
 	fd_set ss;
@@ -14,8 +26,12 @@
 	if (tlen <= 0) {
 		errno = 0;
 		for (;;) {
-			size = (sockaddr_size_t) sizeof(struct sockaddr_in);
-			result = accept(sfd, (struct sockaddr *) addr, &size);
+#ifdef HAVE_SOCKADDR_SA_LEN
+			size = (sockaddr_size_t) (addr->sa_len);
+#else
+			size = (sockaddr_size_t) SA_LEN(addr);
+#endif
+			result = accept(sfd, addr, &size);
 			if ((result >= 0) || (errno != EINTR))
 				return (result);
 		}
@@ -49,8 +65,12 @@
 	}
 
 	do {
-		size = (sockaddr_size_t) sizeof(struct sockaddr_in);
-		result = accept(sfd, (struct sockaddr *) addr, &size);
+#ifdef HAVE_SOCKADDR_SA_LEN
+		size = (sockaddr_size_t) (addr->sa_len);
+#else
+		size = (sockaddr_size_t) SA_LEN(addr);
+#endif
+		result = accept(sfd, addr, &size);
 	} while ((result < 0) && (errno == EINTR));
 
 	return (result);
Index: ncftp3/sio/SConnect.c
diff -u ncftp3/sio/SConnect.c:1.1.1.6 ncftp3/sio/SConnect.c:1.14
--- ncftp3/sio/SConnect.c:1.1.1.6	Sat Jul  6 10:54:59 2002
+++ ncftp3/sio/SConnect.c	Tue Jul  9 15:08:50 2002
@@ -8,14 +8,30 @@
 extern Sjmp_buf gPipeJmp;
 #endif
 
-int _SConnect(const int sfd, const struct sockaddr_in *const addr, const size_t saddrsiz, const int tlen);
+int _SConnect(const int sfd, const struct sockaddr *const addr, const size_t saddrsiz, const int tlen);
+
+#ifndef HAVE_SOCKADDR_SA_LEN
+#ifndef SA_LEN
+#ifdef ENABLE_IPV6
+#define SA_LEN(x) (((x)->sa_family == AF_INET6) ? sizeof(struct sockaddr_in6) \
+		: (((x)->sa_family == AF_INET) ? sizeof(struct sockaddr_in) \
+		: -1))
+#else  /* ENABLE_IPV6 */
+#define SA_LEN(x) (((x)->sa_family == AF_INET) ? sizeof(struct sockaddr_in) : -1)
+#endif /* ENABLE_IPV6 */
+#endif /* SA_LEN */
+#endif /* HAVE_SOCKADDR_SA_LEN */
 
 int
-SConnect(int sfd, const struct sockaddr_in *const addr, int tlen)
+SConnect(int sfd, const struct sockaddr *const addr, int tlen)
 {
 	int result;
 	
-	result = _SConnect(sfd, addr, (size_t) sizeof(struct sockaddr_in), tlen);
+#ifdef HAVE_SOCKADDR_SA_LEN
+	result = _SConnect(sfd, addr, addr->sa_len, tlen);
+#else
+	result = _SConnect(sfd, addr, SA_LEN(addr), tlen);
+#endif
 	return (result);
 }	/* SConnect */
 
@@ -59,7 +75,7 @@
 
 
 int
-_SConnect(const int sfd, const struct sockaddr_in *const addr, const size_t saddrsiz, const int tlen)
+_SConnect(const int sfd, const struct sockaddr *const addr, const size_t saddrsiz, const int tlen)
 {
 #ifndef NO_SIGNALS
 	int result;
Index: ncftp3/sio/SConnectByName.c
diff -u ncftp3/sio/SConnectByName.c:1.1.1.2 ncftp3/sio/SConnectByName.c:1.2
--- ncftp3/sio/SConnectByName.c:1.1.1.2	Sun Feb  3 08:41:15 2002
+++ ncftp3/sio/SConnectByName.c	Mon Feb 25 05:36:05 2002
@@ -7,10 +7,10 @@
 SConnectByName(int sfd, const char * const addrStr, const int tlen)
 {
 	int result;
-	struct sockaddr_in remoteAddr;
+	struct sockaddr_storage remoteAddr;
 
-	if ((result = AddrStrToAddr(addrStr, &remoteAddr, -1)) == 0) {
-		result = SConnect(sfd, &remoteAddr, tlen);
+	if ((result = AddrStrToAddr(addrStr, (struct sockaddr *)&remoteAddr, -1)) == 0) {
+		result = SConnect(sfd, (struct sockaddr *)&remoteAddr, tlen);
 	}
 	return (result);
 }	/* SConnectByName */
Index: ncftp3/sio/SRecvfrom.c
diff -u ncftp3/sio/SRecvfrom.c:1.1.1.3 ncftp3/sio/SRecvfrom.c:1.2
--- ncftp3/sio/SRecvfrom.c:1.1.1.3	Sun Feb  3 08:41:23 2002
+++ ncftp3/sio/SRecvfrom.c	Mon Jan 20 08:17:10 2003
@@ -70,7 +70,7 @@
 #else
 
 int
-SRecvfrom(int sfd, char *const buf, size_t size, int fl, struct sockaddr_in *const fromAddr, int tlen)
+SRecvfrom(int sfd, char *const buf, size_t size, int fl, struct sockaddr *const fromAddr, int tlen)
 {
 	recv_return_t nread;
 	int tleft;
@@ -115,7 +115,7 @@
 		}
 
 		nread = recvfrom(sfd, buf, (recv_size_t) size, fl,
-			(struct sockaddr *) fromAddr, &alen);
+			fromAddr, &alen);
 
 		if (nread >= 0)
 			break;
Index: ncftp3/sio/SSendto.c
diff -u ncftp3/sio/SSendto.c:1.1.1.3 ncftp3/sio/SSendto.c:1.2
--- ncftp3/sio/SSendto.c:1.1.1.3	Sun Feb  3 08:41:23 2002
+++ ncftp3/sio/SSendto.c	Mon Jan 20 08:17:10 2003
@@ -11,7 +11,7 @@
 #ifndef NO_SIGNALS
 
 int
-SSendto(int sfd, const char *const buf, size_t size, int fl, const struct sockaddr_in *const toAddr, int tlen)
+SSendto(int sfd, const char *const buf, size_t size, int fl, const struct sockaddr *const toAddr, int tlen)
 {
 	send_return_t nwrote;
 	alarm_time_t tleft;
@@ -43,8 +43,8 @@
 	forever {
 		(void) alarm(tleft);
 		nwrote = sendto(sfd, buf, (send_size_t) size, fl,
-			(const struct sockaddr *) toAddr,
-			(sockaddr_size_t) sizeof(struct sockaddr_in));
+			toAddr,
+			toAddr->sa_len);
 		(void) alarm(0);
 		if (nwrote >= 0)
 			break;
@@ -69,7 +69,7 @@
 #else
 
 int
-SSendto(int sfd, const char *const buf, size_t size, int fl, const struct sockaddr_in *const toAddr, int tlen)
+SSendto(int sfd, const char *const buf, size_t size, int fl, const struct sockaddr *const toAddr, int tlen)
 {
 	send_return_t nwrote;
 	int tleft;
@@ -117,8 +117,8 @@
 		}
 
 		nwrote = sendto(sfd, buf, (send_size_t) size, fl,
-			(const struct sockaddr *) toAddr,
-			(sockaddr_size_t) sizeof(struct sockaddr_in));
+			toAddr,
+			toAddr->sa_len);
 
 		if (nwrote >= 0)
 			break;
@@ -136,14 +136,14 @@
 
 
 int
-Sendto(int sfd, const char *const buf, size_t size, const struct sockaddr_in *const toAddr)
+Sendto(int sfd, const char *const buf, size_t size, const struct sockaddr *toAddr)
 {
 	int result;
 
 	do {
 		result = (int) sendto(sfd, buf, (send_size_t) size, 0,
-				(const struct sockaddr *) toAddr,
-				(sockaddr_size_t) sizeof(struct sockaddr_in));
+				toAddr,
+				toAddr->sa_len);
 	} while ((result < 0) && (errno == EINTR));
 	return (result);
 }	/* Sendto */
Index: ncftp3/sio/SSendtoByName.c
diff -u ncftp3/sio/SSendtoByName.c:1.1.1.3 ncftp3/sio/SSendtoByName.c:1.2
--- ncftp3/sio/SSendtoByName.c:1.1.1.3	Sun Feb  3 08:41:23 2002
+++ ncftp3/sio/SSendtoByName.c	Mon Feb 25 05:36:05 2002
@@ -82,9 +82,9 @@
 	time_t done, now;
 	fd_set ss;
 	struct timeval tv;
-	struct sockaddr_in toAddr;
+	struct sockaddr_storage toAddr;
 
-	if ((result = AddrStrToAddr(toAddrStr, &toAddr, -1)) < 0) {
+	if ((result = AddrStrToAddr(toAddrStr, (struct sockaddr *)&toAddr, -1)) < 0) {
 		return (result);
 	}
 
@@ -145,9 +145,9 @@
 SendtoByName(int sfd, const char *const buf, size_t size, const char *const toAddrStr)
 {
 	int result;
-	struct sockaddr_in toAddr;
+	struct sockaddr_storage toAddr;
 
-	if ((result = AddrStrToAddr(toAddrStr, &toAddr, -1)) < 0) {
+	if ((result = AddrStrToAddr(toAddrStr, (struct sockaddr *)&toAddr, -1)) < 0) {
 		return (result);
 	}
 
Index: ncftp3/sio/StrAddr.c
diff -u ncftp3/sio/StrAddr.c:1.1.1.5 ncftp3/sio/StrAddr.c:1.6
--- ncftp3/sio/StrAddr.c:1.1.1.5	Sun Jan 12 11:26:09 2003
+++ ncftp3/sio/StrAddr.c	Mon Jan 20 08:17:11 2003
@@ -200,15 +200,13 @@
 
 
 int
-AddrStrToAddr(const char * const s, struct sockaddr_in * const sa, const int defaultport)
+AddrStrToAddr(const char * const s, struct sockaddr * const sa, const int defaultport)
 {
-	char portstr[128];
-	unsigned int ipnum;
-	unsigned int port;
-	struct hostent *hp;
-	char *hostcp, *atsign, *colon, *cp, *p2;
+	char portstr[128], portstr2[128];
+	struct addrinfo hints, *res;
+	char *hostcp, *atsign, *colon, *cp, *p2, *portp;
+	int error;
 
-	memset(sa, 0, sizeof(struct sockaddr_in));
 	strncpy(portstr, s, sizeof(portstr));
 	portstr[sizeof(portstr) - 1] = '\0';
 
@@ -216,7 +214,6 @@
 		/* Does it look like a URL?  http://host ? */
 		if ((colon[1] == '/') && (colon[2] == '/')) {
 			*colon = '\0';
-			port = 0;
 			hostcp = colon + 3;
 			for (cp = hostcp; *cp != '\0'; cp++) {
 				if ((!ISALNUM(*cp)) && (*cp != '.')) {
@@ -227,29 +224,27 @@
 						while (isdigit((int) *cp))
 							cp++;
 						*cp = '\0';
-						port = atoi(p2);
 					}
 					*cp = '\0';
 					break;
 				}
 			}
-			if (port == 0)
-				port = ServiceNameToPortNumber(portstr, 0);
 		} else {
 			/* Look for host.name.domain:port */
 			*colon = '\0';
 			hostcp = portstr;
-			port = (unsigned int) atoi(colon + 1);
 		}
+		portp = portstr;
 	} else if ((atsign = strchr(portstr, '@')) != NULL) {
 		/* Look for port@host.name.domain */
 		*atsign = '\0';
 		hostcp = atsign + 1;
-		port = (unsigned int) atoi(portstr);
+		portp = portstr;
 	} else if (defaultport > 0) {
 		/* Have just host.name.domain, use that w/ default port. */
-		port = (unsigned int) defaultport;
+		sprintf(portstr2, "%d", defaultport);
 		hostcp = portstr;
+		portp = portstr2;
 	} else {
 		/* If defaultport <= 0, they must supply a port number
 		 * in the host/port string.
@@ -258,34 +253,28 @@
 		return (kAddrStrToAddrMiscErr);
 	}
 
-	sa->sin_port = htons((short) port);
-
-	ipnum = inet_addr(hostcp);
-	if (ipnum != INADDR_NONE) {
-		sa->sin_family = AF_INET;
-		sa->sin_addr.s_addr = ipnum;
-	} else {
-		errno = 0;
-		hp = gethostbyname(hostcp);
-		if (hp == NULL) {
-			if (errno == 0)
-				errno = ENOENT;
-			return (kAddrStrToAddrBadHost);
-		}
-		sa->sin_family = hp->h_addrtype;
-		memcpy(&sa->sin_addr.s_addr, hp->h_addr_list[0],
-			(size_t) hp->h_length);
-	}
+	memset(&hints, 0, sizeof(hints));
+	hints.ai_family = PF_UNSPEC;
+	hints.ai_socktype = SOCK_STREAM;
+	error = getaddrinfo(hostcp, portp, &hints, &res);
+	if (error != 0)
+		return (kAddrStrToAddrBadHost);
+	memcpy(sa, res->ai_addr, res->ai_addrlen);
+	freeaddrinfo(res);
 	return (0);
 }	/* AddrStrToAddr */
 
 
 
 char *
-AddrToAddrStr(char *const dst, size_t dsize, struct sockaddr_in * const saddrp, int dns, const char *fmt)
+AddrToAddrStr(char *const dst, size_t dsize, struct sockaddr * const saddrp, int dns, const char *fmt)
 {
 	char addrName[128];
 	char *addrNamePtr;
+	char portName[128];
+	char *portNamePtr;
+	char portNum[128];
+	char *portNumPtr;
 	struct hostent *hp;
 	char str[128];
 	char s_name[64];
@@ -293,18 +282,24 @@
 	const char *cp;
 
 	addrNamePtr = NULL;
-	if (dns == 0) {
-		InetNtoA(addrName, &saddrp->sin_addr, sizeof(addrName));
-		addrNamePtr = addrName;
-	} else {
-		hp = gethostbyaddr((gethost_addrptr_t) &saddrp->sin_addr, sizeof(struct in_addr), AF_INET);
-		if ((hp != NULL) && (hp->h_name != NULL) && (hp->h_name[0] != '\0')) {
-			addrNamePtr = hp->h_name;
-		} else {
-			InetNtoA(addrName, &saddrp->sin_addr, sizeof(addrName));
-			addrNamePtr = addrName;
-		}
-	}
+	if (dns == 0)
+		dns = NI_NUMERICHOST;
+	else
+		dns = 0;
+	getnameinfo(saddrp,
+#ifdef HAVE_SOCKADDR_SA_LEN
+		    saddrp->sa_len,
+#else
+		    SA_LEN(saddrp),
+#endif
+		    addrName, sizeof(addrName), portName, sizeof(portName), dns);
+	getnameinfo(saddrp,
+#ifdef HAVE_SOCKADDR_SA_LEN
+		    saddrp->sa_len,
+#else
+		    SA_LEN(saddrp),
+#endif
+		    NULL, 0, portNum, sizeof(portNum), NI_NUMERICSERV);
 	if (fmt == NULL)
 		fmt = "%h:%p";
 	for (dp = dst, dlim = dp + dsize - 1; ; fmt++) {
@@ -316,8 +311,7 @@
 				if (dp < dlim)
 					*dp++ = '%';
 			} else if (*fmt == 'p') {
-				sprintf(str, "%u", (unsigned int) ntohs(saddrp->sin_port));
-				for (cp = str; *cp != '\0'; cp++)
+				for (cp = portNum; *cp != '\0'; cp++)
 					if (dp < dlim)
 						*dp++ = *cp;
 				*dp = '\0';
@@ -332,13 +326,12 @@
 						*dp++ = *cp;
 				*dp = '\0';
 			} else if (*fmt == 's') {
-				cp = s_name;
-				(void) ServicePortNumberToName(ntohs(saddrp->sin_port), s_name, sizeof(s_name), 0);
-				for ( ; *cp != '\0'; cp++)
+				for (cp = portName ; *cp != '\0'; cp++)
 					if (dp < dlim)
 						*dp++ = *cp;
 				/* endservent(); */
 				*dp = '\0';
+#if 0
 			} else if ((*fmt == 't') || (*fmt == 'u')) {
 				cp = s_name;
 				(void) ServicePortNumberToName(ntohs(saddrp->sin_port), s_name, sizeof(s_name), (int) *fmt);
@@ -347,6 +340,7 @@
 						*dp++ = *cp;
 				/* endservent(); */
 				*dp = '\0';
+#endif
 			} else if (*fmt == '\0') {
 				break;
 			} else {
Index: ncftp3/sio/sio.h
diff -u ncftp3/sio/sio.h:1.1.1.6 ncftp3/sio/sio.h:1.10
--- ncftp3/sio/sio.h:1.1.1.6	Sat Jul  6 10:55:00 2002
+++ ncftp3/sio/sio.h	Mon Jan 20 08:17:11 2003
@@ -211,10 +211,10 @@
 int PWrite(int, const char *const, size_t);
 
 /* SAcceptA.c */
-int SAcceptA(int, struct sockaddr_in *const, int);
+int SAcceptA(int, struct sockaddr *const, int);
 
 /* SAcceptS.c */
-int SAcceptS(int, struct sockaddr_in *const, int);
+int SAcceptS(int, struct sockaddr *const, int);
 
 /* SBind.c */
 int SBind(int, const int, const int, const int);
@@ -224,7 +224,7 @@
 int SClose(int, int);
 
 /* SConnect.c */
-int SConnect(int, const struct sockaddr_in *const, int);
+int SConnect(int, const struct sockaddr *const, int);
 
 /* SConnectByName.c */
 int SConnectByName(int, const char *const, const int);
@@ -248,7 +248,7 @@
 int SRecv(int, char *const, size_t, int, int, int);
 
 /* SRecvfrom.c */
-int SRecvfrom(int, char *const, size_t, int, struct sockaddr_in *const, int);
+int SRecvfrom(int, char *const, size_t, int, struct sockaddr *const, int);
 
 /* SRecvmsg.c */
 int SRecvmsg(int, void *const, int, int);
@@ -264,8 +264,8 @@
 int SSend(int, char *, size_t, int, int);
 
 /* SSendto.c */
-int SSendto(int, const char *const, size_t, int, const struct sockaddr_in *const, int);
-int Sendto(int, const char *const, size_t, const struct sockaddr_in *const);
+int SSendto(int, const char *const, size_t, int, const struct sockaddr *const, int);
+int Sendto(int, const char *const, size_t, const struct sockaddr *const);
 
 /* SSendtoByName.c */
 int SSendtoByName(int, const char *const, size_t, int, const char *const, int);
@@ -296,8 +296,8 @@
 unsigned int ServiceNameToPortNumber(const char *const s, const int proto);
 int ServicePortNumberToName(unsigned short port, char *const dst, const size_t dsize, const int proto);
 void InetNtoA(char *dst, struct in_addr *ia, size_t siz);
-int AddrStrToAddr(const char *const, struct sockaddr_in *const, const int);
-char *AddrToAddrStr(char *const dst, size_t dsize, struct sockaddr_in * const saddrp, int dns, const char *fmt);
+int AddrStrToAddr(const char *const, struct sockaddr *const, const int);
+char *AddrToAddrStr(char *const dst, size_t dsize, struct sockaddr * const saddrp, int dns, const char *fmt);
 
 /* SError.c */
 const char *SError(int e);
Index: ncftp3/sio/syshdrs.h
diff -u ncftp3/sio/syshdrs.h:1.1.1.6 ncftp3/sio/syshdrs.h:1.7
--- ncftp3/sio/syshdrs.h:1.1.1.6	Thu May 30 23:41:04 2002
+++ ncftp3/sio/syshdrs.h	Thu May 30 23:49:39 2002
@@ -19,6 +19,9 @@
 #	define WINVER 0x0400
 #	define _WIN32_WINNT 0x0400
 #	include <windows.h>		/* includes <winsock2.h> if _WIN32_WINNT >= 0x400 */
+#ifdef ENABLE_IPV6
+#	include <ws2tcpip.h>
+#endif /* ENABLE_IPV6 */
 #	include <io.h>
 #	include <errno.h>
 #	include <stdio.h>
Index: ncftp3/vis/syshdrs.h
diff -u ncftp3/vis/syshdrs.h:1.1.1.7 ncftp3/vis/syshdrs.h:1.4
--- ncftp3/vis/syshdrs.h:1.1.1.7	Thu May 30 23:40:53 2002
+++ ncftp3/vis/syshdrs.h	Thu May 30 23:49:39 2002
@@ -94,6 +94,9 @@
 #include <time.h>
 #include <pwd.h>
 #include <fcntl.h>
+#ifndef HAVE_GETADDRINFO
+#	include "addrinfo.h"
+#endif
 
 #ifdef HAVE_LOCALE_H
 #	include <locale.h>
