Index: python/README.v6
diff -c /dev/null python/README.v6:1.9
*** /dev/null	Tue Aug 15 11:44:26 2000
--- python/README.v6	Tue Aug 15 11:40:38 2000
***************
*** 0 ****
--- 1,185 ----
+ IPv6-ready python 1.6
+ KAME Project
+ $KAME: README.v6,v 1.9 2000/08/15 02:40:38 itojun Exp $
+ 
+ 
+ This patchkit enables python 1.6 to perform AF_INET6 socket operations.
+ The only affected module is Modules/socketmodule.c.
+ 
+ Modules/socketmodule.c
+ 	In most cases, IPv6 address can be placed where IPv4 address fits.
+ 
+     sockaddr
+ 	sockaddr tuple is formatted as follows:
+ 	    IPv4: (host, port)
+ 	    IPv6: socket class methods always generate
+ 		    (host, port, flowinfo, scopeid).
+ 		  socket class methods will accept 2, 3, or 4 tuple
+ 		  (for backward compatibility).
+ 
+ 	Compatibility warning: Some of the scripts assume that the sockaddr
+ 	structure is 2 tuple, like:
+ 	    host, port = sock.getpeername()
+ 	this will fail if you are connected to IPv6 node.
+ 
+     socket.getaddrinfo(host, port [, family, socktype, proto, flags])
+ 	host: String or None
+ 	port: String, Int or None
+ 	family, socktype, proto, flags: Int, can be omitted
+ 
+ 	Perform getaddrinfo(3).  Returns List of the following 5 tuple:
+ 	    (family, socktype, proto, canonname, sockaddr)
+ 	    family: Int
+ 	    socktype: Int
+ 	    proto: Int
+ 	    canonname: String
+ 	    sockaddr: sockaddr (see above)
+ 
+ 	See Lib/httplib.py for typical usage on the client side.
+ 
+     socket.getnameinfo(sockaddr, flags)
+ 	sockaddr: sockaddr
+ 	flags: Int
+ 
+ 	Perform getnameinfo(3).  Returns the following 2 tuple:
+ 	    host: String, numeric or hostname depending on flgags
+ 	    port: String, numeric or portname depending on flgags
+ 
+     socket.gethostbyname2(host, af)
+ 	host: String
+ 	af: Int
+ 
+ 	Performs gethostbyname2(3).  Returns numeric address representation
+ 	for "host".
+ 
+     socket.gethostbyaddr(addr) (behavior change if IPv6 support is compiled in)
+ 	addr: String
+ 
+ 	Performs gethostbyaddr(3).  Returns string address representation for
+ 	"addr".
+ 
+ 	The function can take IPv6 numeric address as well.  This behavior
+ 	is not problematical, because
+ 	- if you pass numeric "addr" parameter, we can always identify address
+ 	  family for it
+ 	- return value is string address reprsentation, where IPv6 and IPv4
+ 	  are not distinguishable.
+ 
+      socket.bind(sa), socket.connect(sa) and others.
+ 	(No behavior change, but be careful)
+ 
+ 	See above for sockaddr format change.
+ 
+ 	With Python "addr" portion of sockaddr (first element) can be string
+ 	hostname.  When the string hostname resolved to numeric address, it
+ 	will obey address family of the socket (which was specified when
+ 	socket.socket() was called).
+ 	If you give some string that does not give matching address family,
+ 	you will get some error.
+ 		s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ 		# this is okay, if 'localhost' resolves to both IPv4/v6
+ 		s.connect('localhost', 80)
+ 		# this is not okay, of course
+ 		s.connect('::1', 80)
+ 		# this is not okay, as v6only.kame.net will not resolve to IPv4
+ 		s.connect('v6only.kame.net', 80)
+ 
+ Lib/httplib.py
+ 	IPv6 ready.  "host" in HTTP(host) will accept the following 3 forms:
+ 		[host]:port
+ 		host:port	there must be only single colon
+ 		host
+ 	This is to allow IPv6 numeric URL (http://[host]:port/) in documents.
+ 
+ 	IMHO "host:port" parsing should be implemented in urllib.py, not here.
+ 
+ Lib/ftplib.py
+ 	IPv6 ready.  This uses EPSV/EPRT on IPv6 ftp.  See RFC2428 for
+ 	protocol details.
+ 
+ Lib/SocketServer.py
+ 	IPv6 ready.  Wildcard bind on TCPServer, i.e. TCPServer(('', port)),
+ 	will bind to wildcard socket on TCPServer.address_family.
+ 	TCPServer.addresss_family is set to AF_INET by default, so ('', port)
+ 	will usually bind AF_INET.
+ 
+ Lib/smtplib.py, Lib/telnetlib.py, Lib/poplib.py
+ 	IPv6 ready.  Not much to say about protocol details - they just use
+ 	TCP over IPv6.
+ 
+ configure
+ 	Configure has extra option, --enable-ipv6 and --disable-ipv6.
+ 	The option controls IPv6 support feature.
+ 
+ dynamic link issues in Modules/socketmodule.c
+ 	Modules/socketmodule.c can be dynamically loaded only in the following
+ 	situations:
+ 	- getaddrinfo(3) and getnameinfo(3) are supplied by OS vendor in
+ 	  libc, and libc is dynamic link library.
+ 	- OS vendor is NOT supplying getaddrinfo(3) nor getnameinfo(3), and
+ 	  You are configuring this package with --disable-ipv6.  In this case,
+ 	  you'll be using missing/get{addr,name}info.c and they will refer to
+ 	  gethostby{name,addr}.  gethostnameby{name,addr} can usually be found
+ 	  in dynamic-linking libc.
+ 
+ 	In other situations, such as the following, please link
+ 	Modules/socketmodule.c into python itself.
+ 	- getaddrinfo(3) and getnameinfo(3) are supplied by OS vendor, but
+ 	  they are in statically linked library like libinet6.a.
+ 	  (KAME falls into this category)
+ 
+ 	python usually links Modules/socketmodule.c into python itself
+ 	(due to its popularity) so there should be no problem.
+ 
+ restrictions
+ 	- The patched tree will not use gethostbyname_r and other
+ 	  thread-ready libraries.  Instead, it will use getaddrinfo() and
+ 	  getnameinfo() throughout the operation.
+ 
+ todo
+ 	- Patch bunch of library files in Lib/*.py.
+ 
+ compatibility issues with existing scripts
+ 	If you disable IPv6 support (./configure --disable-ipv6), the
+ 	patched code is mostly compatible with original Python
+ 	(except files in "Lib" directory modified for dual stack support).
+ 
+ 	User script may choke if:
+ 	- IPv4/v6 dualstack libc is supplied, python is compiled for dual
+ 	  stack, and script assumes some of IPv4-only behavior (especially
+ 	  sockaddr)
+ 	- IPv4/v6 dualstack libc is supplied, python is compiled for IPv4 only,
+ 	  and script assumes some of IPv4-only behavior.
+ 	  In this case, Python socket class itself does not support IPv6,
+ 	  however, name resolution functions can return IPv6 names since
+ 	  they use IPv6-ready libc functions!  I do not recommend this
+ 	  configuration.
+ 	- script assumes certain IPv4-only version behavior in Lib/*.py.
+ 
+ compilation
+ 	If you use IPv6 features, it is assumed that you have working
+ 	getaddrinfo() and getnameinfo() library functions.  We have noticed
+ 	that some of IPv6 stack is shipped with broken getaddrinfo().  In
+ 	such cases, use missing/get{addr,name}info.c instead (but then, you
+ 	need to have working getipnodeby{name,addr}).
+ 
+ 	If you compile this on IPv4-only machine without get{addr,name}info,
+ 	missing/get{addr,name}info.c will be used.  They are from KAME IPv6
+ 	distribution and is #ifdef'ed for IPv4 only support.  They are
+ 	fairly complete implementation and you don't need to bother with
+ 	bind 8.2 (bind 8.2 get{addr,name}info() has bugs).
+ 
+ 	When compiling this kit on IPv6 node, you may need to specify some
+ 	additional library paths or cpp defs. (like -linet6 or -DINET6)
+ 	--enable-ipv6 will give you some warning, if the IPv6 stack is unknown
+ 	to the "configure" script.  Currently, the following IPv6 stacks
+ 	are officially supported (i.e. we've checked that the package works
+ 	well):
+ 	- KAME IPv6 stack, http://www.kame.net/
+ 
+ References
+ 	RFC2553, for getaddrinfo(3) and getnameinfo(3).
+ 
+ Author contacts
+ 	http://www.kame.net/
+ 	mailto:core@kame.net
Index: python/acconfig.h
diff -c python/acconfig.h:1.1.1.3 python/acconfig.h:1.6
*** python/acconfig.h:1.1.1.3	Mon Aug 14 21:49:49 2000
--- python/acconfig.h	Tue Aug 15 11:40:39 2000
***************
*** 160,165 ****
--- 160,177 ----
  */
  #undef HAVE_LARGEFILE_SUPPORT
  
+ /* Define if --enable-ipv6 is specified */
+ #undef ENABLE_IPV6
+ 
+ /* Define if sockaddr has sa_len member */
+ #undef HAVE_SOCKADDR_SA_LEN
+ 
+ /* struct addrinfo (netdb.h) */
+ #undef HAVE_ADDRINFO
+ 
+ /* struct sockaddr_storage (sys/socket.h) */
+ #undef HAVE_SOCKADDR_STORAGE
+ 
  /* Defined when any dynamic module loading is enabled */
  #undef HAVE_DYNAMIC_LOADING
  
Index: python/config.h.in
diff -c python/config.h.in:1.1.1.3 python/config.h.in:1.6
*** python/config.h.in:1.1.1.3	Mon Aug 14 21:49:50 2000
--- python/config.h.in	Tue Aug 15 11:40:39 2000
***************
*** 222,227 ****
--- 222,239 ----
  */
  #undef HAVE_LARGEFILE_SUPPORT
  
+ /* Define if --enable-ipv6 is specified */
+ #undef ENABLE_IPV6
+ 
+ /* Define if sockaddr has sa_len member */
+ #undef HAVE_SOCKADDR_SA_LEN
+ 
+ /* struct addrinfo (netdb.h) */
+ #undef HAVE_ADDRINFO
+ 
+ /* struct sockaddr_storage (sys/socket.h) */
+ #undef HAVE_SOCKADDR_STORAGE
+ 
  /* Defined when any dynamic module loading is enabled */
  #undef HAVE_DYNAMIC_LOADING
  
***************
*** 312,317 ****
--- 324,332 ----
  /* Define if you have the ftruncate function.  */
  #undef HAVE_FTRUNCATE
  
+ /* Define if you have the getaddrinfo function.  */
+ #undef HAVE_GETADDRINFO
+ 
  /* Define if you have the getcwd function.  */
  #undef HAVE_GETCWD
  
***************
*** 320,325 ****
--- 335,343 ----
  
  /* Define if you have the getlogin function.  */
  #undef HAVE_GETLOGIN
+ 
+ /* Define if you have the getnameinfo function.  */
+ #undef HAVE_GETNAMEINFO
  
  /* Define if you have the getpeername function.  */
  #undef HAVE_GETPEERNAME
Index: python/configure
diff -c python/configure:1.1.1.3 python/configure:1.11
*** python/configure:1.1.1.3	Mon Aug 14 21:50:00 2000
--- python/configure	Tue Aug 15 11:40:39 2000
***************
*** 24,29 ****
--- 24,32 ----
  ac_help="$ac_help
  --with-cxx=<compiler>     enable C++ support"
  ac_help="$ac_help
+   --enable-ipv6		Enable ipv6 (with ipv4) support
+   --disable-ipv6		Disable ipv6 support"
+ ac_help="$ac_help
  --with-libs='lib1 ...'    link against additional libs"
  ac_help="$ac_help
  --with(out)-readline      obsolete, edit Modules/Setup instead"
***************
*** 565,571 ****
  if test -f /usr/lib/NextStep/software_version -o -f /System/Library/CoreServices/software_version ; then
  
  	echo $ac_n "checking for --with-next-archs""... $ac_c" 1>&6
! echo "configure:569: checking for --with-next-archs" >&5
  	# Check whether --with-next-archs or --without-next-archs was given.
  if test "${with_next_archs+set}" = set; then
    withval="$with_next_archs"
--- 568,574 ----
  if test -f /usr/lib/NextStep/software_version -o -f /System/Library/CoreServices/software_version ; then
  
  	echo $ac_n "checking for --with-next-archs""... $ac_c" 1>&6
! echo "configure:572: checking for --with-next-archs" >&5
  	# Check whether --with-next-archs or --without-next-archs was given.
  if test "${with_next_archs+set}" = set; then
    withval="$with_next_archs"
***************
*** 608,614 ****
  # Set name for machine-dependent library files
  
  echo $ac_n "checking MACHDEP""... $ac_c" 1>&6
! echo "configure:612: checking MACHDEP" >&5
  if test -z "$MACHDEP"
  then
  	ac_sys_system=`uname -s`
--- 611,617 ----
  # Set name for machine-dependent library files
  
  echo $ac_n "checking MACHDEP""... $ac_c" 1>&6
! echo "configure:615: checking MACHDEP" >&5
  if test -z "$MACHDEP"
  then
  	ac_sys_system=`uname -s`
***************
*** 668,674 ****
  
  # checks for alternative programs
  echo $ac_n "checking for --without-gcc""... $ac_c" 1>&6
! echo "configure:672: checking for --without-gcc" >&5
  # Check whether --with-gcc or --without-gcc was given.
  if test "${with_gcc+set}" = set; then
    withval="$with_gcc"
--- 671,677 ----
  
  # checks for alternative programs
  echo $ac_n "checking for --without-gcc""... $ac_c" 1>&6
! echo "configure:675: checking for --without-gcc" >&5
  # Check whether --with-gcc or --without-gcc was given.
  if test "${with_gcc+set}" = set; then
    withval="$with_gcc"
***************
*** 739,745 ****
  
  MAINOBJ=python.o
  echo $ac_n "checking for --with-cxx=<compiler>""... $ac_c" 1>&6
! echo "configure:743: checking for --with-cxx=<compiler>" >&5
  # Check whether --with-cxx or --without-cxx was given.
  if test "${with_cxx+set}" = set; then
    withval="$with_cxx"
--- 742,748 ----
  
  MAINOBJ=python.o
  echo $ac_n "checking for --with-cxx=<compiler>""... $ac_c" 1>&6
! echo "configure:746: checking for --with-cxx=<compiler>" >&5
  # Check whether --with-cxx or --without-cxx was given.
  if test "${with_cxx+set}" = set; then
    withval="$with_cxx"
***************
*** 783,789 ****
  # 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:787: 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
--- 786,792 ----
  # 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:790: 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
***************
*** 813,819 ****
    # 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:817: 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
--- 816,822 ----
    # 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:820: 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
***************
*** 864,870 ****
        # 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:868: 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
--- 867,873 ----
        # 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:871: 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
***************
*** 896,902 ****
  fi
  
  echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
! echo "configure:900: 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.
--- 899,905 ----
  fi
  
  echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
! echo "configure:903: 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.
***************
*** 907,918 ****
  
  cat > conftest.$ac_ext << EOF
  
! #line 911 "configure"
  #include "confdefs.h"
  
  main(){return(0);}
  EOF
! if { (eval echo configure:916: \"$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
--- 910,921 ----
  
  cat > conftest.$ac_ext << EOF
  
! #line 914 "configure"
  #include "confdefs.h"
  
  main(){return(0);}
  EOF
! if { (eval echo configure:919: \"$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
***************
*** 938,949 ****
    { 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:942: 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:947: 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
--- 941,952 ----
    { 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:945: 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:950: 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
***************
*** 952,958 ****
    yes;
  #endif
  EOF
! if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:956: \"$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
--- 955,961 ----
    yes;
  #endif
  EOF
! if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:959: \"$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
***************
*** 971,977 ****
  ac_save_CFLAGS="$CFLAGS"
  CFLAGS=
  echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
! echo "configure:975: 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
--- 974,980 ----
  ac_save_CFLAGS="$CFLAGS"
  CFLAGS=
  echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
! echo "configure:978: 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
***************
*** 1034,1040 ****
  # linking.
  
  echo $ac_n "checking LINKCC""... $ac_c" 1>&6
! echo "configure:1038: checking LINKCC" >&5
  if test -z "$LINKCC" -a ! -z "$CXX"
  then
      LINKCC="$CXX"
--- 1037,1043 ----
  # linking.
  
  echo $ac_n "checking LINKCC""... $ac_c" 1>&6
! echo "configure:1041: checking LINKCC" >&5
  if test -z "$LINKCC" -a ! -z "$CXX"
  then
      LINKCC="$CXX"
***************
*** 1055,1061 ****
  echo "$ac_t""$LINKCC" 1>&6
  
  echo $ac_n "checking LDLIBRARY""... $ac_c" 1>&6
! echo "configure:1059: checking LDLIBRARY" >&5
  
  # NeXT framework builds require that the 'ar' library be converted into
  # a bundle using libtool.
--- 1058,1064 ----
  echo "$ac_t""$LINKCC" 1>&6
  
  echo $ac_n "checking LDLIBRARY""... $ac_c" 1>&6
! echo "configure:1062: checking LDLIBRARY" >&5
  
  # NeXT framework builds require that the 'ar' library be converted into
  # a bundle using libtool.
***************
*** 1084,1090 ****
  # 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:1088: 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
--- 1087,1093 ----
  # 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:1091: 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
***************
*** 1117,1123 ****
  # Extract the first word of "$ac_prog", so it can be a program name with args.
  set dummy $ac_prog; ac_word=$2
  echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
! echo "configure:1121: checking for $ac_word" >&5
  if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
--- 1120,1126 ----
  # Extract the first word of "$ac_prog", so it can be a program name with args.
  set dummy $ac_prog; ac_word=$2
  echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
! echo "configure:1124: checking for $ac_word" >&5
  if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
***************
*** 1191,1197 ****
  fi
  # checks for UNIX variants that set C preprocessor variables
  echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
! echo "configure:1195: checking how to run the C preprocessor" >&5
  # On Suns, sometimes $CPP names a directory.
  if test -n "$CPP" && test -d "$CPP"; then
    CPP=
--- 1194,1200 ----
  fi
  # checks for UNIX variants that set C preprocessor variables
  echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
! echo "configure:1198: checking how to run the C preprocessor" >&5
  # On Suns, sometimes $CPP names a directory.
  if test -n "$CPP" && test -d "$CPP"; then
    CPP=
***************
*** 1206,1218 ****
    # On the NeXT, cc -E runs the code through the compiler's parser,
    # not just through cpp.
    cat > conftest.$ac_ext <<EOF
! #line 1210 "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:1216: \"$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
    :
--- 1209,1221 ----
    # On the NeXT, cc -E runs the code through the compiler's parser,
    # not just through cpp.
    cat > conftest.$ac_ext <<EOF
! #line 1213 "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:1219: \"$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
    :
***************
*** 1223,1235 ****
    rm -rf conftest*
    CPP="${CC-cc} -E -traditional-cpp"
    cat > conftest.$ac_ext <<EOF
! #line 1227 "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:1233: \"$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
    :
--- 1226,1238 ----
    rm -rf conftest*
    CPP="${CC-cc} -E -traditional-cpp"
    cat > conftest.$ac_ext <<EOF
! #line 1230 "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:1236: \"$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
    :
***************
*** 1240,1252 ****
    rm -rf conftest*
    CPP="${CC-cc} -nologo -E"
    cat > conftest.$ac_ext <<EOF
! #line 1244 "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:1250: \"$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
    :
--- 1243,1255 ----
    rm -rf conftest*
    CPP="${CC-cc} -nologo -E"
    cat > conftest.$ac_ext <<EOF
! #line 1247 "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:1253: \"$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
    :
***************
*** 1271,1279 ****
  echo "$ac_t""$CPP" 1>&6
  
  echo $ac_n "checking for AIX""... $ac_c" 1>&6
! echo "configure:1275: checking for AIX" >&5
  cat > conftest.$ac_ext <<EOF
! #line 1277 "configure"
  #include "confdefs.h"
  #ifdef _AIX
    yes
--- 1274,1282 ----
  echo "$ac_t""$CPP" 1>&6
  
  echo $ac_n "checking for AIX""... $ac_c" 1>&6
! echo "configure:1278: checking for AIX" >&5
  cat > conftest.$ac_ext <<EOF
! #line 1280 "configure"
  #include "confdefs.h"
  #ifdef _AIX
    yes
***************
*** 1296,1312 ****
  
  ac_safe=`echo "minix/config.h" | sed 'y%./+-%__p_%'`
  echo $ac_n "checking for minix/config.h""... $ac_c" 1>&6
! echo "configure:1300: checking for minix/config.h" >&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 1305 "configure"
  #include "confdefs.h"
  #include <minix/config.h>
  EOF
  ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
! { (eval echo configure:1310: \"$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*
--- 1299,1315 ----
  
  ac_safe=`echo "minix/config.h" | sed 'y%./+-%__p_%'`
  echo $ac_n "checking for minix/config.h""... $ac_c" 1>&6
! echo "configure:1303: checking for minix/config.h" >&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 1308 "configure"
  #include "confdefs.h"
  #include <minix/config.h>
  EOF
  ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
! { (eval echo configure:1313: \"$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*
***************
*** 1345,1351 ****
  
  
  echo $ac_n "checking whether $CC accepts -OPT:Olimit=0""... $ac_c" 1>&6
! echo "configure:1349: checking whether $CC accepts -OPT:Olimit=0" >&5
  if eval "test \"`echo '$''{'ac_cv_opt_olimit_ok'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
--- 1348,1354 ----
  
  
  echo $ac_n "checking whether $CC accepts -OPT:Olimit=0""... $ac_c" 1>&6
! echo "configure:1352: checking whether $CC accepts -OPT:Olimit=0" >&5
  if eval "test \"`echo '$''{'ac_cv_opt_olimit_ok'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
***************
*** 1355,1365 ****
      { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
  else
    cat > conftest.$ac_ext <<EOF
! #line 1359 "configure"
  #include "confdefs.h"
  int main() { return 0; }
  EOF
! if { (eval echo configure:1363: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
  then
    ac_cv_opt_olimit_ok=yes
  else
--- 1358,1368 ----
      { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
  else
    cat > conftest.$ac_ext <<EOF
! #line 1362 "configure"
  #include "confdefs.h"
  int main() { return 0; }
  EOF
! if { (eval echo configure:1366: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
  then
    ac_cv_opt_olimit_ok=yes
  else
***************
*** 1379,1385 ****
    OPT="$OPT -OPT:Olimit=0"
  else
    echo $ac_n "checking whether $CC accepts -Olimit 1500""... $ac_c" 1>&6
! echo "configure:1383: checking whether $CC accepts -Olimit 1500" >&5
    if eval "test \"`echo '$''{'ac_cv_olimit_ok'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
--- 1382,1388 ----
    OPT="$OPT -OPT:Olimit=0"
  else
    echo $ac_n "checking whether $CC accepts -Olimit 1500""... $ac_c" 1>&6
! echo "configure:1386: checking whether $CC accepts -Olimit 1500" >&5
    if eval "test \"`echo '$''{'ac_cv_olimit_ok'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
***************
*** 1389,1399 ****
      { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
  else
    cat > conftest.$ac_ext <<EOF
! #line 1393 "configure"
  #include "confdefs.h"
  int main() { return 0; }
  EOF
! if { (eval echo configure:1397: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
  then
    ac_cv_olimit_ok=yes
  else
--- 1392,1402 ----
      { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
  else
    cat > conftest.$ac_ext <<EOF
! #line 1396 "configure"
  #include "confdefs.h"
  int main() { return 0; }
  EOF
! if { (eval echo configure:1400: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
  then
    ac_cv_olimit_ok=yes
  else
***************
*** 1414,1424 ****
    fi
  fi
  
  # check for ANSI or K&R ("traditional") preprocessor
  echo $ac_n "checking for C preprocessor type""... $ac_c" 1>&6
! echo "configure:1420: checking for C preprocessor type" >&5
  cat > conftest.$ac_ext <<EOF
! #line 1422 "configure"
  #include "confdefs.h"
  
  #define spam(name, doc) {#name, &name, #name "() -- " doc}
--- 1417,1656 ----
    fi
  fi
  
+ # Check for enable-ipv6
+ OPT="$OPT -Dss_family=__ss_family -Dss_len=__ss_len"
+ echo $ac_n "checking whether to enable ipv6""... $ac_c" 1>&6
+ echo "configure:1424: 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 1448 "configure"
+ #include "confdefs.h"
+  /* AF_INET6 avalable check */
+ #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:1462: \"$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
+ 
+ 
+ ipv6type=unknown
+ ipv6lib=none
+ ipv6trylibc=no
+ 
+ if test "$ipv6" = "yes"; then
+ 	echo $ac_n "checking ipv6 stack type""... $ac_c" 1>&6
+ echo "configure:1489: checking ipv6 stack type" >&5
+ 	for i in inria kame linux-glibc linux-inet6 toshiba v6d zeta; do
+ 		case $i in
+ 		inria)
+ 						cat > conftest.$ac_ext <<EOF
+ #line 1494 "configure"
+ #include "confdefs.h"
+ dnl
+ #include <netinet/in.h>
+ #ifdef IPV6_INRIA_VERSION
+ yes
+ #endif
+ EOF
+ if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+   egrep "yes" >/dev/null 2>&1; then
+   rm -rf conftest*
+   ipv6type=$i;
+ 				OPT="-DINET6 $OPT"
+ fi
+ rm -f conftest*
+ 
+ 			;;
+ 		kame)
+ 						cat > conftest.$ac_ext <<EOF
+ #line 1513 "configure"
+ #include "confdefs.h"
+ dnl
+ #include <netinet/in.h>
+ #ifdef __KAME__
+ yes
+ #endif
+ EOF
+ if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+   egrep "yes" >/dev/null 2>&1; then
+   rm -rf conftest*
+   ipv6type=$i;
+ 				ipv6lib=inet6
+ 				ipv6libdir=/usr/local/v6/lib
+ 				ipv6trylibc=yes
+ 				OPT="-DINET6 $OPT"
+ fi
+ rm -f conftest*
+ 
+ 			;;
+ 		linux-glibc)
+ 						cat > conftest.$ac_ext <<EOF
+ #line 1535 "configure"
+ #include "confdefs.h"
+ dnl
+ #include <features.h>
+ #if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2))
+ yes
+ #endif
+ EOF
+ if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+   egrep "yes" >/dev/null 2>&1; then
+   rm -rf conftest*
+   ipv6type=$i;
+ 				ipv6lib=
+ 				ipv6libdir=
+ 				ipv6trylibc=yes
+ 				OPT="-DINET6 $OPT"
+ fi
+ rm -f conftest*
+ 
+ 			;;
+ 		linux-inet6)
+ 						if test -d /usr/inet6; then
+ 				ipv6type=$i
+ 				ipv6lib=inet6
+ 				ipv6libdir=/usr/inet6/lib
+ 				OPT="-DINET6 -I/usr/inet6/include $OPT"
+ 			fi
+ 			;;
+ 		toshiba)
+ 			cat > conftest.$ac_ext <<EOF
+ #line 1565 "configure"
+ #include "confdefs.h"
+ dnl
+ #include <sys/param.h>
+ #ifdef _TOSHIBA_INET6
+ yes
+ #endif
+ EOF
+ if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+   egrep "yes" >/dev/null 2>&1; then
+   rm -rf conftest*
+   ipv6type=$i;
+ 				ipv6lib=inet6;
+ 				ipv6libdir=/usr/local/v6/lib;
+ 				OPT="-DINET6 $OPT"
+ fi
+ rm -f conftest*
+ 
+ 			;;
+ 		v6d)
+ 			cat > conftest.$ac_ext <<EOF
+ #line 1586 "configure"
+ #include "confdefs.h"
+ dnl
+ #include </usr/local/v6/include/sys/v6config.h>
+ #ifdef __V6D__
+ yes
+ #endif
+ EOF
+ if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+   egrep "yes" >/dev/null 2>&1; then
+   rm -rf conftest*
+   ipv6type=$i;
+ 				ipv6lib=v6;
+ 				ipv6libdir=/usr/local/v6/lib;
+ 				OPT="-I/usr/local/v6/include $OPT"
+ fi
+ rm -f conftest*
+ 
+ 			;;
+ 		zeta)
+ 			cat > conftest.$ac_ext <<EOF
+ #line 1607 "configure"
+ #include "confdefs.h"
+ dnl
+ #include <sys/param.h>
+ #ifdef _ZETA_MINAMI_INET6
+ yes
+ #endif
+ EOF
+ if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+   egrep "yes" >/dev/null 2>&1; then
+   rm -rf conftest*
+   ipv6type=$i;
+ 				ipv6lib=inet6;
+ 				ipv6libdir=/usr/local/v6/lib;
+ 				OPT="-DINET6 $OPT"
+ fi
+ rm -f conftest*
+ 
+ 			;;
+ 		esac
+ 		if test "$ipv6type" != "unknown"; then
+ 			break
+ 		fi
+ 	done
+ 	echo "$ac_t""$ipv6type" 1>&6
+ fi
+ 
+ if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
+ 	if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
+ 		LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
+ 		echo "using lib$ipv6lib"
+ 	else
+ 		if test $ipv6trylibc = "yes"; then
+ 			echo "using libc"
+ 		else
+ 			echo 'Fatal: no $ipv6lib library found.  cannot continue.'
+ 			echo "You need to fetch lib$ipv6lib.a from appropriate"
+ 			echo 'ipv6 kit and compile beforehand.'
+ 			exit 1
+ 		fi
+ 	fi
+ fi
+ 
  # check for ANSI or K&R ("traditional") preprocessor
  echo $ac_n "checking for C preprocessor type""... $ac_c" 1>&6
! echo "configure:1652: checking for C preprocessor type" >&5
  cat > conftest.$ac_ext <<EOF
! #line 1654 "configure"
  #include "confdefs.h"
  
  #define spam(name, doc) {#name, &name, #name "() -- " doc}
***************
*** 1429,1435 ****
  ;
  ; return 0; }
  EOF
! if { (eval echo configure:1433: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
    rm -rf conftest*
    cpp_type=ansi
  else
--- 1661,1667 ----
  ;
  ; return 0; }
  EOF
! if { (eval echo configure:1665: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
    rm -rf conftest*
    cpp_type=ansi
  else
***************
*** 1446,1457 ****
  
  # checks for header files
  echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
! echo "configure:1450: 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 1455 "configure"
  #include "confdefs.h"
  #include <stdlib.h>
  #include <stdarg.h>
--- 1678,1689 ----
  
  # checks for header files
  echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
! echo "configure:1682: checking for ANSI C header files" >&5
  if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
    cat > conftest.$ac_ext <<EOF
! #line 1687 "configure"
  #include "confdefs.h"
  #include <stdlib.h>
  #include <stdarg.h>
***************
*** 1459,1465 ****
  #include <float.h>
  EOF
  ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
! { (eval echo configure:1463: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
  ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
  if test -z "$ac_err"; then
    rm -rf conftest*
--- 1691,1697 ----
  #include <float.h>
  EOF
  ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
! { (eval echo configure:1695: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
  ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
  if test -z "$ac_err"; then
    rm -rf conftest*
***************
*** 1476,1482 ****
  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 1480 "configure"
  #include "confdefs.h"
  #include <string.h>
  EOF
--- 1708,1714 ----
  if test $ac_cv_header_stdc = yes; then
    # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
  cat > conftest.$ac_ext <<EOF
! #line 1712 "configure"
  #include "confdefs.h"
  #include <string.h>
  EOF
***************
*** 1494,1500 ****
  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 1498 "configure"
  #include "confdefs.h"
  #include <stdlib.h>
  EOF
--- 1726,1732 ----
  if test $ac_cv_header_stdc = yes; then
    # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
  cat > conftest.$ac_ext <<EOF
! #line 1730 "configure"
  #include "confdefs.h"
  #include <stdlib.h>
  EOF
***************
*** 1515,1521 ****
    :
  else
    cat > conftest.$ac_ext <<EOF
! #line 1519 "configure"
  #include "confdefs.h"
  #include <ctype.h>
  #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
--- 1747,1753 ----
    :
  else
    cat > conftest.$ac_ext <<EOF
! #line 1751 "configure"
  #include "confdefs.h"
  #include <ctype.h>
  #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
***************
*** 1526,1532 ****
  exit (0); }
  
  EOF
! if { (eval echo configure:1530: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
  then
    :
  else
--- 1758,1764 ----
  exit (0); }
  
  EOF
! if { (eval echo configure:1762: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
  then
    :
  else
***************
*** 1557,1573 ****
  do
  ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
  echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
! echo "configure:1561: 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 1566 "configure"
  #include "confdefs.h"
  #include <$ac_hdr>
  EOF
  ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
! { (eval echo configure:1571: \"$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*
--- 1789,1805 ----
  do
  ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
  echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
! echo "configure:1793: 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 1798 "configure"
  #include "confdefs.h"
  #include <$ac_hdr>
  EOF
  ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
! { (eval echo configure:1803: \"$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*
***************
*** 1598,1609 ****
  do
  ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
  echo $ac_n "checking for $ac_hdr that defines DIR""... $ac_c" 1>&6
! echo "configure:1602: checking for $ac_hdr that defines DIR" >&5
  if eval "test \"`echo '$''{'ac_cv_header_dirent_$ac_safe'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
    cat > conftest.$ac_ext <<EOF
! #line 1607 "configure"
  #include "confdefs.h"
  #include <sys/types.h>
  #include <$ac_hdr>
--- 1830,1841 ----
  do
  ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
  echo $ac_n "checking for $ac_hdr that defines DIR""... $ac_c" 1>&6
! echo "configure:1834: checking for $ac_hdr that defines DIR" >&5
  if eval "test \"`echo '$''{'ac_cv_header_dirent_$ac_safe'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
    cat > conftest.$ac_ext <<EOF
! #line 1839 "configure"
  #include "confdefs.h"
  #include <sys/types.h>
  #include <$ac_hdr>
***************
*** 1611,1617 ****
  DIR *dirp = 0;
  ; return 0; }
  EOF
! if { (eval echo configure:1615: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
    rm -rf conftest*
    eval "ac_cv_header_dirent_$ac_safe=yes"
  else
--- 1843,1849 ----
  DIR *dirp = 0;
  ; return 0; }
  EOF
! if { (eval echo configure:1847: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
    rm -rf conftest*
    eval "ac_cv_header_dirent_$ac_safe=yes"
  else
***************
*** 1636,1642 ****
  # Two versions of opendir et al. are in -ldir and -lx on SCO Xenix.
  if test $ac_header_dirent = dirent.h; then
  echo $ac_n "checking for opendir in -ldir""... $ac_c" 1>&6
! echo "configure:1640: checking for opendir in -ldir" >&5
  ac_lib_var=`echo dir'_'opendir | sed 'y%./+-%__p_%'`
  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
--- 1868,1874 ----
  # Two versions of opendir et al. are in -ldir and -lx on SCO Xenix.
  if test $ac_header_dirent = dirent.h; then
  echo $ac_n "checking for opendir in -ldir""... $ac_c" 1>&6
! echo "configure:1872: checking for opendir in -ldir" >&5
  ac_lib_var=`echo dir'_'opendir | sed 'y%./+-%__p_%'`
  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
***************
*** 1644,1650 ****
    ac_save_LIBS="$LIBS"
  LIBS="-ldir  $LIBS"
  cat > conftest.$ac_ext <<EOF
! #line 1648 "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
--- 1876,1882 ----
    ac_save_LIBS="$LIBS"
  LIBS="-ldir  $LIBS"
  cat > conftest.$ac_ext <<EOF
! #line 1880 "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
***************
*** 1655,1661 ****
  opendir()
  ; return 0; }
  EOF
! if { (eval echo configure:1659: \"$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
--- 1887,1893 ----
  opendir()
  ; return 0; }
  EOF
! if { (eval echo configure:1891: \"$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
***************
*** 1677,1683 ****
  
  else
  echo $ac_n "checking for opendir in -lx""... $ac_c" 1>&6
! echo "configure:1681: checking for opendir in -lx" >&5
  ac_lib_var=`echo x'_'opendir | sed 'y%./+-%__p_%'`
  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
--- 1909,1915 ----
  
  else
  echo $ac_n "checking for opendir in -lx""... $ac_c" 1>&6
! echo "configure:1913: checking for opendir in -lx" >&5
  ac_lib_var=`echo x'_'opendir | sed 'y%./+-%__p_%'`
  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
***************
*** 1685,1691 ****
    ac_save_LIBS="$LIBS"
  LIBS="-lx  $LIBS"
  cat > conftest.$ac_ext <<EOF
! #line 1689 "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
--- 1917,1923 ----
    ac_save_LIBS="$LIBS"
  LIBS="-lx  $LIBS"
  cat > conftest.$ac_ext <<EOF
! #line 1921 "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
***************
*** 1696,1702 ****
  opendir()
  ; return 0; }
  EOF
! if { (eval echo configure:1700: \"$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
--- 1928,1934 ----
  opendir()
  ; return 0; }
  EOF
! if { (eval echo configure:1932: \"$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
***************
*** 1722,1730 ****
  # checks for typedefs
  was_it_defined=no
  echo $ac_n "checking for clock_t in time.h""... $ac_c" 1>&6
! echo "configure:1726: checking for clock_t in time.h" >&5
  cat > conftest.$ac_ext <<EOF
! #line 1728 "configure"
  #include "confdefs.h"
  #include <time.h>
  EOF
--- 1954,1962 ----
  # checks for typedefs
  was_it_defined=no
  echo $ac_n "checking for clock_t in time.h""... $ac_c" 1>&6
! echo "configure:1958: checking for clock_t in time.h" >&5
  cat > conftest.$ac_ext <<EOF
! #line 1960 "configure"
  #include "confdefs.h"
  #include <time.h>
  EOF
***************
*** 1752,1763 ****
  
  # Type availability checks
  echo $ac_n "checking for mode_t""... $ac_c" 1>&6
! echo "configure:1756: 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 1761 "configure"
  #include "confdefs.h"
  #include <sys/types.h>
  #if STDC_HEADERS
--- 1984,1995 ----
  
  # Type availability checks
  echo $ac_n "checking for mode_t""... $ac_c" 1>&6
! echo "configure:1988: 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 1993 "configure"
  #include "confdefs.h"
  #include <sys/types.h>
  #if STDC_HEADERS
***************
*** 1785,1796 ****
  fi
  
  echo $ac_n "checking for off_t""... $ac_c" 1>&6
! echo "configure:1789: 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 1794 "configure"
  #include "confdefs.h"
  #include <sys/types.h>
  #if STDC_HEADERS
--- 2017,2028 ----
  fi
  
  echo $ac_n "checking for off_t""... $ac_c" 1>&6
! echo "configure:2021: 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 2026 "configure"
  #include "confdefs.h"
  #include <sys/types.h>
  #if STDC_HEADERS
***************
*** 1818,1829 ****
  fi
  
  echo $ac_n "checking for pid_t""... $ac_c" 1>&6
! echo "configure:1822: 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 1827 "configure"
  #include "confdefs.h"
  #include <sys/types.h>
  #if STDC_HEADERS
--- 2050,2061 ----
  fi
  
  echo $ac_n "checking for pid_t""... $ac_c" 1>&6
! echo "configure:2054: 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 2059 "configure"
  #include "confdefs.h"
  #include <sys/types.h>
  #if STDC_HEADERS
***************
*** 1851,1862 ****
  fi
  
  echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6
! echo "configure:1855: checking return type of signal handlers" >&5
  if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
    cat > conftest.$ac_ext <<EOF
! #line 1860 "configure"
  #include "confdefs.h"
  #include <sys/types.h>
  #include <signal.h>
--- 2083,2094 ----
  fi
  
  echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6
! echo "configure:2087: checking return type of signal handlers" >&5
  if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
    cat > conftest.$ac_ext <<EOF
! #line 2092 "configure"
  #include "confdefs.h"
  #include <sys/types.h>
  #include <signal.h>
***************
*** 1873,1879 ****
  int i;
  ; return 0; }
  EOF
! if { (eval echo configure:1877: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
    rm -rf conftest*
    ac_cv_type_signal=void
  else
--- 2105,2111 ----
  int i;
  ; return 0; }
  EOF
! if { (eval echo configure:2109: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
    rm -rf conftest*
    ac_cv_type_signal=void
  else
***************
*** 1892,1903 ****
  
  
  echo $ac_n "checking for size_t""... $ac_c" 1>&6
! echo "configure:1896: 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 1901 "configure"
  #include "confdefs.h"
  #include <sys/types.h>
  #if STDC_HEADERS
--- 2124,2135 ----
  
  
  echo $ac_n "checking for size_t""... $ac_c" 1>&6
! echo "configure:2128: 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 2133 "configure"
  #include "confdefs.h"
  #include <sys/types.h>
  #if STDC_HEADERS
***************
*** 1925,1936 ****
  fi
  
  echo $ac_n "checking for uid_t in sys/types.h""... $ac_c" 1>&6
! echo "configure:1929: 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 1934 "configure"
  #include "confdefs.h"
  #include <sys/types.h>
  EOF
--- 2157,2168 ----
  fi
  
  echo $ac_n "checking for uid_t in sys/types.h""... $ac_c" 1>&6
! echo "configure:2161: 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 2166 "configure"
  #include "confdefs.h"
  #include <sys/types.h>
  EOF
***************
*** 1959,1970 ****
  fi
  
  echo $ac_n "checking for socklen_t""... $ac_c" 1>&6
! echo "configure:1963: checking for socklen_t" >&5
  if eval "test \"`echo '$''{'ac_cv_type_socklen_t'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
    cat > conftest.$ac_ext <<EOF
! #line 1968 "configure"
  #include "confdefs.h"
  #include <sys/types.h>
  #if STDC_HEADERS
--- 2191,2202 ----
  fi
  
  echo $ac_n "checking for socklen_t""... $ac_c" 1>&6
! echo "configure:2195: checking for socklen_t" >&5
  if eval "test \"`echo '$''{'ac_cv_type_socklen_t'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
    cat > conftest.$ac_ext <<EOF
! #line 2200 "configure"
  #include "confdefs.h"
  #include <sys/types.h>
  #if STDC_HEADERS
***************
*** 1994,2000 ****
  
  # Sizes of various common basic types
  echo $ac_n "checking size of int""... $ac_c" 1>&6
! echo "configure:1998: checking size of int" >&5
  if eval "test \"`echo '$''{'ac_cv_sizeof_int'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
--- 2226,2232 ----
  
  # Sizes of various common basic types
  echo $ac_n "checking size of int""... $ac_c" 1>&6
! echo "configure:2230: checking size of int" >&5
  if eval "test \"`echo '$''{'ac_cv_sizeof_int'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
***************
*** 2002,2008 ****
      { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
  else
    cat > conftest.$ac_ext <<EOF
! #line 2006 "configure"
  #include "confdefs.h"
  #include <stdio.h>
  main()
--- 2234,2240 ----
      { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
  else
    cat > conftest.$ac_ext <<EOF
! #line 2238 "configure"
  #include "confdefs.h"
  #include <stdio.h>
  main()
***************
*** 2013,2019 ****
    exit(0);
  }
  EOF
! if { (eval echo configure:2017: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
  then
    ac_cv_sizeof_int=`cat conftestval`
  else
--- 2245,2251 ----
    exit(0);
  }
  EOF
! if { (eval echo configure:2249: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
  then
    ac_cv_sizeof_int=`cat conftestval`
  else
***************
*** 2033,2039 ****
  
  
  echo $ac_n "checking size of long""... $ac_c" 1>&6
! echo "configure:2037: checking size of long" >&5
  if eval "test \"`echo '$''{'ac_cv_sizeof_long'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
--- 2265,2271 ----
  
  
  echo $ac_n "checking size of long""... $ac_c" 1>&6
! echo "configure:2269: checking size of long" >&5
  if eval "test \"`echo '$''{'ac_cv_sizeof_long'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
***************
*** 2041,2047 ****
      { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
  else
    cat > conftest.$ac_ext <<EOF
! #line 2045 "configure"
  #include "confdefs.h"
  #include <stdio.h>
  main()
--- 2273,2279 ----
      { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
  else
    cat > conftest.$ac_ext <<EOF
! #line 2277 "configure"
  #include "confdefs.h"
  #include <stdio.h>
  main()
***************
*** 2052,2058 ****
    exit(0);
  }
  EOF
! if { (eval echo configure:2056: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
  then
    ac_cv_sizeof_long=`cat conftestval`
  else
--- 2284,2290 ----
    exit(0);
  }
  EOF
! if { (eval echo configure:2288: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
  then
    ac_cv_sizeof_long=`cat conftestval`
  else
***************
*** 2072,2078 ****
  
  
  echo $ac_n "checking size of void *""... $ac_c" 1>&6
! echo "configure:2076: checking size of void *" >&5
  if eval "test \"`echo '$''{'ac_cv_sizeof_void_p'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
--- 2304,2310 ----
  
  
  echo $ac_n "checking size of void *""... $ac_c" 1>&6
! echo "configure:2308: checking size of void *" >&5
  if eval "test \"`echo '$''{'ac_cv_sizeof_void_p'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
***************
*** 2080,2086 ****
      { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
  else
    cat > conftest.$ac_ext <<EOF
! #line 2084 "configure"
  #include "confdefs.h"
  #include <stdio.h>
  main()
--- 2312,2318 ----
      { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
  else
    cat > conftest.$ac_ext <<EOF
! #line 2316 "configure"
  #include "confdefs.h"
  #include <stdio.h>
  main()
***************
*** 2091,2097 ****
    exit(0);
  }
  EOF
! if { (eval echo configure:2095: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
  then
    ac_cv_sizeof_void_p=`cat conftestval`
  else
--- 2323,2329 ----
    exit(0);
  }
  EOF
! if { (eval echo configure:2327: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
  then
    ac_cv_sizeof_void_p=`cat conftestval`
  else
***************
*** 2111,2117 ****
  
  
  echo $ac_n "checking size of char""... $ac_c" 1>&6
! echo "configure:2115: checking size of char" >&5
  if eval "test \"`echo '$''{'ac_cv_sizeof_char'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
--- 2343,2349 ----
  
  
  echo $ac_n "checking size of char""... $ac_c" 1>&6
! echo "configure:2347: checking size of char" >&5
  if eval "test \"`echo '$''{'ac_cv_sizeof_char'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
***************
*** 2119,2125 ****
      { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
  else
    cat > conftest.$ac_ext <<EOF
! #line 2123 "configure"
  #include "confdefs.h"
  #include <stdio.h>
  main()
--- 2351,2357 ----
      { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
  else
    cat > conftest.$ac_ext <<EOF
! #line 2355 "configure"
  #include "confdefs.h"
  #include <stdio.h>
  main()
***************
*** 2130,2136 ****
    exit(0);
  }
  EOF
! if { (eval echo configure:2134: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
  then
    ac_cv_sizeof_char=`cat conftestval`
  else
--- 2362,2368 ----
    exit(0);
  }
  EOF
! if { (eval echo configure:2366: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
  then
    ac_cv_sizeof_char=`cat conftestval`
  else
***************
*** 2150,2156 ****
  
  
  echo $ac_n "checking size of short""... $ac_c" 1>&6
! echo "configure:2154: checking size of short" >&5
  if eval "test \"`echo '$''{'ac_cv_sizeof_short'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
--- 2382,2388 ----
  
  
  echo $ac_n "checking size of short""... $ac_c" 1>&6
! echo "configure:2386: checking size of short" >&5
  if eval "test \"`echo '$''{'ac_cv_sizeof_short'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
***************
*** 2158,2164 ****
      { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
  else
    cat > conftest.$ac_ext <<EOF
! #line 2162 "configure"
  #include "confdefs.h"
  #include <stdio.h>
  main()
--- 2390,2396 ----
      { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
  else
    cat > conftest.$ac_ext <<EOF
! #line 2394 "configure"
  #include "confdefs.h"
  #include <stdio.h>
  main()
***************
*** 2169,2175 ****
    exit(0);
  }
  EOF
! if { (eval echo configure:2173: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
  then
    ac_cv_sizeof_short=`cat conftestval`
  else
--- 2401,2407 ----
    exit(0);
  }
  EOF
! if { (eval echo configure:2405: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
  then
    ac_cv_sizeof_short=`cat conftestval`
  else
***************
*** 2189,2195 ****
  
  
  echo $ac_n "checking size of float""... $ac_c" 1>&6
! echo "configure:2193: checking size of float" >&5
  if eval "test \"`echo '$''{'ac_cv_sizeof_float'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
--- 2421,2427 ----
  
  
  echo $ac_n "checking size of float""... $ac_c" 1>&6
! echo "configure:2425: checking size of float" >&5
  if eval "test \"`echo '$''{'ac_cv_sizeof_float'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
***************
*** 2197,2203 ****
      { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
  else
    cat > conftest.$ac_ext <<EOF
! #line 2201 "configure"
  #include "confdefs.h"
  #include <stdio.h>
  main()
--- 2429,2435 ----
      { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
  else
    cat > conftest.$ac_ext <<EOF
! #line 2433 "configure"
  #include "confdefs.h"
  #include <stdio.h>
  main()
***************
*** 2208,2214 ****
    exit(0);
  }
  EOF
! if { (eval echo configure:2212: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
  then
    ac_cv_sizeof_float=`cat conftestval`
  else
--- 2440,2446 ----
    exit(0);
  }
  EOF
! if { (eval echo configure:2444: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
  then
    ac_cv_sizeof_float=`cat conftestval`
  else
***************
*** 2228,2234 ****
  
  
  echo $ac_n "checking size of double""... $ac_c" 1>&6
! echo "configure:2232: checking size of double" >&5
  if eval "test \"`echo '$''{'ac_cv_sizeof_double'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
--- 2460,2466 ----
  
  
  echo $ac_n "checking size of double""... $ac_c" 1>&6
! echo "configure:2464: checking size of double" >&5
  if eval "test \"`echo '$''{'ac_cv_sizeof_double'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
***************
*** 2236,2242 ****
      { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
  else
    cat > conftest.$ac_ext <<EOF
! #line 2240 "configure"
  #include "confdefs.h"
  #include <stdio.h>
  main()
--- 2468,2474 ----
      { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
  else
    cat > conftest.$ac_ext <<EOF
! #line 2472 "configure"
  #include "confdefs.h"
  #include <stdio.h>
  main()
***************
*** 2247,2253 ****
    exit(0);
  }
  EOF
! if { (eval echo configure:2251: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
  then
    ac_cv_sizeof_double=`cat conftestval`
  else
--- 2479,2485 ----
    exit(0);
  }
  EOF
! if { (eval echo configure:2483: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
  then
    ac_cv_sizeof_double=`cat conftestval`
  else
***************
*** 2268,2284 ****
  
  
  echo $ac_n "checking for long long support""... $ac_c" 1>&6
! echo "configure:2272: checking for long long support" >&5
  have_long_long=no
  cat > conftest.$ac_ext <<EOF
! #line 2275 "configure"
  #include "confdefs.h"
  
  int main() {
  long long x; x = (long long)0;
  ; return 0; }
  EOF
! if { (eval echo configure:2282: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
    rm -rf conftest*
    cat >> confdefs.h <<\EOF
  #define HAVE_LONG_LONG 1
--- 2500,2516 ----
  
  
  echo $ac_n "checking for long long support""... $ac_c" 1>&6
! echo "configure:2504: checking for long long support" >&5
  have_long_long=no
  cat > conftest.$ac_ext <<EOF
! #line 2507 "configure"
  #include "confdefs.h"
  
  int main() {
  long long x; x = (long long)0;
  ; return 0; }
  EOF
! if { (eval echo configure:2514: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
    rm -rf conftest*
    cat >> confdefs.h <<\EOF
  #define HAVE_LONG_LONG 1
***************
*** 2292,2298 ****
  echo "$ac_t""$have_long_long" 1>&6
  if test "$have_long_long" = yes ; then
  echo $ac_n "checking size of long long""... $ac_c" 1>&6
! echo "configure:2296: checking size of long long" >&5
  if eval "test \"`echo '$''{'ac_cv_sizeof_long_long'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
--- 2524,2530 ----
  echo "$ac_t""$have_long_long" 1>&6
  if test "$have_long_long" = yes ; then
  echo $ac_n "checking size of long long""... $ac_c" 1>&6
! echo "configure:2528: checking size of long long" >&5
  if eval "test \"`echo '$''{'ac_cv_sizeof_long_long'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
***************
*** 2300,2306 ****
      { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
  else
    cat > conftest.$ac_ext <<EOF
! #line 2304 "configure"
  #include "confdefs.h"
  #include <stdio.h>
  main()
--- 2532,2538 ----
      { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
  else
    cat > conftest.$ac_ext <<EOF
! #line 2536 "configure"
  #include "confdefs.h"
  #include <stdio.h>
  main()
***************
*** 2311,2317 ****
    exit(0);
  }
  EOF
! if { (eval echo configure:2315: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
  then
    ac_cv_sizeof_long_long=`cat conftestval`
  else
--- 2543,2549 ----
    exit(0);
  }
  EOF
! if { (eval echo configure:2547: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
  then
    ac_cv_sizeof_long_long=`cat conftestval`
  else
***************
*** 2334,2340 ****
  
  # Hmph. AC_CHECK_SIZEOF() doesn't include <sys/types.h>.
  echo $ac_n "checking size of off_t""... $ac_c" 1>&6
! echo "configure:2338: checking size of off_t" >&5
  if eval "test \"`echo '$''{'ac_cv_sizeof_off_t'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
--- 2566,2572 ----
  
  # Hmph. AC_CHECK_SIZEOF() doesn't include <sys/types.h>.
  echo $ac_n "checking size of off_t""... $ac_c" 1>&6
! echo "configure:2570: checking size of off_t" >&5
  if eval "test \"`echo '$''{'ac_cv_sizeof_off_t'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
***************
*** 2342,2348 ****
      { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
  else
    cat > conftest.$ac_ext <<EOF
! #line 2346 "configure"
  #include "confdefs.h"
  #include <stdio.h>
  #include <sys/types.h>
--- 2574,2580 ----
      { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
  else
    cat > conftest.$ac_ext <<EOF
! #line 2578 "configure"
  #include "confdefs.h"
  #include <stdio.h>
  #include <sys/types.h>
***************
*** 2354,2360 ****
    exit(0);
  }
  EOF
! if { (eval echo configure:2358: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
  then
    ac_cv_sizeof_off_t=`cat conftestval`
  else
--- 2586,2592 ----
    exit(0);
  }
  EOF
! if { (eval echo configure:2590: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
  then
    ac_cv_sizeof_off_t=`cat conftestval`
  else
***************
*** 2376,2382 ****
  
  
  echo $ac_n "checking whether to enable large file support""... $ac_c" 1>&6
! echo "configure:2380: checking whether to enable large file support" >&5
  if test "$have_long_long" = yes -a \
  	"$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
  	"$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
--- 2608,2614 ----
  
  
  echo $ac_n "checking whether to enable large file support""... $ac_c" 1>&6
! echo "configure:2612: checking whether to enable large file support" >&5
  if test "$have_long_long" = yes -a \
  	"$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
  	"$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
***************
*** 2402,2408 ****
  esac
  
  echo $ac_n "checking for --with-next-framework""... $ac_c" 1>&6
! echo "configure:2406: checking for --with-next-framework" >&5
  if test "$with_next_framework"
  then
  	OPT="$OPT -fno-common"
--- 2634,2640 ----
  esac
  
  echo $ac_n "checking for --with-next-framework""... $ac_c" 1>&6
! echo "configure:2638: checking for --with-next-framework" >&5
  if test "$with_next_framework"
  then
  	OPT="$OPT -fno-common"
***************
*** 2419,2425 ****
  fi
  
  echo $ac_n "checking for --with-dyld""... $ac_c" 1>&6
! echo "configure:2423: checking for --with-dyld" >&5
  if test "$with_next_framework" -o "$with_dyld"
  then
  	if test "$with_dyld"
--- 2651,2657 ----
  fi
  
  echo $ac_n "checking for --with-dyld""... $ac_c" 1>&6
! echo "configure:2655: checking for --with-dyld" >&5
  if test "$with_next_framework" -o "$with_dyld"
  then
  	if test "$with_dyld"
***************
*** 2445,2451 ****
  # SO is the extension of shared libraries `(including the dot!)
  # -- usually .so, .sl on HP-UX
  echo $ac_n "checking SO""... $ac_c" 1>&6
! echo "configure:2449: checking SO" >&5
  if test -z "$SO"
  then
  	case $ac_sys_system in
--- 2677,2683 ----
  # SO is the extension of shared libraries `(including the dot!)
  # -- usually .so, .sl on HP-UX
  echo $ac_n "checking SO""... $ac_c" 1>&6
! echo "configure:2681: checking SO" >&5
  if test -z "$SO"
  then
  	case $ac_sys_system in
***************
*** 2459,2465 ****
  # (Shared libraries in this instance are shared modules to be loaded into
  # Python, as opposed to building Python itself as a shared library.)
  echo $ac_n "checking LDSHARED""... $ac_c" 1>&6
! echo "configure:2463: checking LDSHARED" >&5
  if test -z "$LDSHARED"
  then
  	case $ac_sys_system/$ac_sys_release in
--- 2691,2697 ----
  # (Shared libraries in this instance are shared modules to be loaded into
  # Python, as opposed to building Python itself as a shared library.)
  echo $ac_n "checking LDSHARED""... $ac_c" 1>&6
! echo "configure:2695: checking LDSHARED" >&5
  if test -z "$LDSHARED"
  then
  	case $ac_sys_system/$ac_sys_release in
***************
*** 2500,2506 ****
  # CCSHARED are the C *flags* used to create objects to go into a shared
  # library (module) -- this is only needed for a few systems
  echo $ac_n "checking CCSHARED""... $ac_c" 1>&6
! echo "configure:2504: checking CCSHARED" >&5
  if test -z "$CCSHARED"
  then
  	case $ac_sys_system/$ac_sys_release in
--- 2732,2738 ----
  # CCSHARED are the C *flags* used to create objects to go into a shared
  # library (module) -- this is only needed for a few systems
  echo $ac_n "checking CCSHARED""... $ac_c" 1>&6
! echo "configure:2736: checking CCSHARED" >&5
  if test -z "$CCSHARED"
  then
  	case $ac_sys_system/$ac_sys_release in
***************
*** 2523,2529 ****
  # LINKFORSHARED are the flags passed to the $(CC) command that links
  # the python executable -- this is only needed for a few systems
  echo $ac_n "checking LINKFORSHARED""... $ac_c" 1>&6
! echo "configure:2527: checking LINKFORSHARED" >&5
  if test -z "$LINKFORSHARED"
  then
  	case $ac_sys_system/$ac_sys_release in
--- 2755,2761 ----
  # LINKFORSHARED are the flags passed to the $(CC) command that links
  # the python executable -- this is only needed for a few systems
  echo $ac_n "checking LINKFORSHARED""... $ac_c" 1>&6
! echo "configure:2759: checking LINKFORSHARED" >&5
  if test -z "$LINKFORSHARED"
  then
  	case $ac_sys_system/$ac_sys_release in
***************
*** 2559,2565 ****
  
  # checks for libraries
  echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6
! echo "configure:2563: checking for dlopen in -ldl" >&5
  ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'`
  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
--- 2791,2797 ----
  
  # checks for libraries
  echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6
! echo "configure:2795: checking for dlopen in -ldl" >&5
  ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'`
  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
***************
*** 2567,2573 ****
    ac_save_LIBS="$LIBS"
  LIBS="-ldl  $LIBS"
  cat > conftest.$ac_ext <<EOF
! #line 2571 "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
--- 2799,2805 ----
    ac_save_LIBS="$LIBS"
  LIBS="-ldl  $LIBS"
  cat > conftest.$ac_ext <<EOF
! #line 2803 "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
***************
*** 2578,2584 ****
  dlopen()
  ; return 0; }
  EOF
! if { (eval echo configure:2582: \"$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
--- 2810,2816 ----
  dlopen()
  ; return 0; }
  EOF
! if { (eval echo configure:2814: \"$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
***************
*** 2606,2612 ****
  fi
  	# Dynamic linking for SunOS/Solaris and SYSV
  echo $ac_n "checking for shl_load in -ldld""... $ac_c" 1>&6
! echo "configure:2610: checking for shl_load in -ldld" >&5
  ac_lib_var=`echo dld'_'shl_load | sed 'y%./+-%__p_%'`
  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
--- 2838,2844 ----
  fi
  	# Dynamic linking for SunOS/Solaris and SYSV
  echo $ac_n "checking for shl_load in -ldld""... $ac_c" 1>&6
! echo "configure:2842: checking for shl_load in -ldld" >&5
  ac_lib_var=`echo dld'_'shl_load | sed 'y%./+-%__p_%'`
  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
***************
*** 2614,2620 ****
    ac_save_LIBS="$LIBS"
  LIBS="-ldld  $LIBS"
  cat > conftest.$ac_ext <<EOF
! #line 2618 "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
--- 2846,2852 ----
    ac_save_LIBS="$LIBS"
  LIBS="-ldld  $LIBS"
  cat > conftest.$ac_ext <<EOF
! #line 2850 "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
***************
*** 2625,2631 ****
  shl_load()
  ; return 0; }
  EOF
! if { (eval echo configure:2629: \"$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
--- 2857,2863 ----
  shl_load()
  ; return 0; }
  EOF
! if { (eval echo configure:2861: \"$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
***************
*** 2656,2671 ****
  # checks for system dependent C++ extensions support
  case "$ac_sys_system" in
  	AIX*)	echo $ac_n "checking for genuine AIX C++ extensions support""... $ac_c" 1>&6
! echo "configure:2660: checking for genuine AIX C++ extensions support" >&5
  		cat > conftest.$ac_ext <<EOF
! #line 2662 "configure"
  #include "confdefs.h"
  #include "/usr/lpp/xlC/include/load.h"
  int main() {
  loadAndInit("", 0, "")
  ; return 0; }
  EOF
! if { (eval echo configure:2669: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
    rm -rf conftest*
    cat >> confdefs.h <<\EOF
  #define AIX_GENUINE_CPLUSPLUS 1
--- 2888,2903 ----
  # checks for system dependent C++ extensions support
  case "$ac_sys_system" in
  	AIX*)	echo $ac_n "checking for genuine AIX C++ extensions support""... $ac_c" 1>&6
! echo "configure:2892: checking for genuine AIX C++ extensions support" >&5
  		cat > conftest.$ac_ext <<EOF
! #line 2894 "configure"
  #include "confdefs.h"
  #include "/usr/lpp/xlC/include/load.h"
  int main() {
  loadAndInit("", 0, "")
  ; return 0; }
  EOF
! if { (eval echo configure:2901: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
    rm -rf conftest*
    cat >> confdefs.h <<\EOF
  #define AIX_GENUINE_CPLUSPLUS 1
***************
*** 2689,2695 ****
  IRIX*) ;;
  *)
  echo $ac_n "checking for t_open in -lnsl""... $ac_c" 1>&6
! echo "configure:2693: checking for t_open in -lnsl" >&5
  ac_lib_var=`echo nsl'_'t_open | sed 'y%./+-%__p_%'`
  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
--- 2921,2927 ----
  IRIX*) ;;
  *)
  echo $ac_n "checking for t_open in -lnsl""... $ac_c" 1>&6
! echo "configure:2925: checking for t_open in -lnsl" >&5
  ac_lib_var=`echo nsl'_'t_open | sed 'y%./+-%__p_%'`
  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
***************
*** 2697,2703 ****
    ac_save_LIBS="$LIBS"
  LIBS="-lnsl  $LIBS"
  cat > conftest.$ac_ext <<EOF
! #line 2701 "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
--- 2929,2935 ----
    ac_save_LIBS="$LIBS"
  LIBS="-lnsl  $LIBS"
  cat > conftest.$ac_ext <<EOF
! #line 2933 "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
***************
*** 2708,2714 ****
  t_open()
  ; return 0; }
  EOF
! if { (eval echo configure:2712: \"$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
--- 2940,2946 ----
  t_open()
  ; return 0; }
  EOF
! if { (eval echo configure:2944: \"$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
***************
*** 2729,2735 ****
  fi
   # SVR4
  echo $ac_n "checking for socket in -lsocket""... $ac_c" 1>&6
! echo "configure:2733: 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
--- 2961,2967 ----
  fi
   # SVR4
  echo $ac_n "checking for socket in -lsocket""... $ac_c" 1>&6
! echo "configure:2965: 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
***************
*** 2737,2743 ****
    ac_save_LIBS="$LIBS"
  LIBS="-lsocket $LIBS $LIBS"
  cat > conftest.$ac_ext <<EOF
! #line 2741 "configure"
  #include "confdefs.h"
  /* Override any gcc2 internal prototype to avoid an error.  */
  /* We use char because int might match the return type of a gcc2
--- 2969,2975 ----
    ac_save_LIBS="$LIBS"
  LIBS="-lsocket $LIBS $LIBS"
  cat > conftest.$ac_ext <<EOF
! #line 2973 "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
***************
*** 2748,2754 ****
  socket()
  ; return 0; }
  EOF
! if { (eval echo configure:2752: \"$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
--- 2980,2986 ----
  socket()
  ; return 0; }
  EOF
! if { (eval echo configure:2984: \"$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
***************
*** 2769,2775 ****
  fi
   # SVR4 sockets
  echo $ac_n "checking for socket in -lnet""... $ac_c" 1>&6
! echo "configure:2773: checking for socket in -lnet" >&5
  ac_lib_var=`echo net'_'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
--- 3001,3007 ----
  fi
   # SVR4 sockets
  echo $ac_n "checking for socket in -lnet""... $ac_c" 1>&6
! echo "configure:3005: checking for socket in -lnet" >&5
  ac_lib_var=`echo net'_'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
***************
*** 2777,2783 ****
    ac_save_LIBS="$LIBS"
  LIBS="-lnet $LIBS $LIBS"
  cat > conftest.$ac_ext <<EOF
! #line 2781 "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
--- 3009,3015 ----
    ac_save_LIBS="$LIBS"
  LIBS="-lnet $LIBS $LIBS"
  cat > conftest.$ac_ext <<EOF
! #line 3013 "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
***************
*** 2788,2794 ****
  socket()
  ; return 0; }
  EOF
! if { (eval echo configure:2792: \"$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
--- 3020,3026 ----
  socket()
  ; return 0; }
  EOF
! if { (eval echo configure:3024: \"$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
***************
*** 2812,2818 ****
  esac
  
  echo $ac_n "checking for --with-libs""... $ac_c" 1>&6
! echo "configure:2816: checking for --with-libs" >&5
  # Check whether --with-libs or --without-libs was given.
  if test "${with_libs+set}" = set; then
    withval="$with_libs"
--- 3044,3050 ----
  esac
  
  echo $ac_n "checking for --with-libs""... $ac_c" 1>&6
! echo "configure:3048: checking for --with-libs" >&5
  # Check whether --with-libs or --without-libs was given.
  if test "${with_libs+set}" = set; then
    withval="$with_libs"
***************
*** 2826,2832 ****
  
  
  echo $ac_n "checking for --with(out)-readline""... $ac_c" 1>&6
! echo "configure:2830: checking for --with(out)-readline" >&5
  # Check whether --with-readline or --without-readline was given.
  if test "${with_readline+set}" = set; then
    withval="$with_readline"
--- 3058,3064 ----
  
  
  echo $ac_n "checking for --with(out)-readline""... $ac_c" 1>&6
! echo "configure:3062: checking for --with(out)-readline" >&5
  # Check whether --with-readline or --without-readline was given.
  if test "${with_readline+set}" = set; then
    withval="$with_readline"
***************
*** 2841,2847 ****
  USE_THREAD_MODULE="#"
  
  echo $ac_n "checking for --with-dec-threads""... $ac_c" 1>&6
! echo "configure:2845: checking for --with-dec-threads" >&5
  
  # Check whether --with-dec-threads or --without-dec-threads was given.
  if test "${with_dec_threads+set}" = set; then
--- 3073,3079 ----
  USE_THREAD_MODULE="#"
  
  echo $ac_n "checking for --with-dec-threads""... $ac_c" 1>&6
! echo "configure:3077: checking for --with-dec-threads" >&5
  
  # Check whether --with-dec-threads or --without-dec-threads was given.
  if test "${with_dec_threads+set}" = set; then
***************
*** 2857,2863 ****
  
  
  echo $ac_n "checking for --with-threads""... $ac_c" 1>&6
! echo "configure:2861: checking for --with-threads" >&5
  # Check whether --with-threads or --without-threads was given.
  if test "${with_threads+set}" = set; then
    withval="$with_threads"
--- 3089,3095 ----
  
  
  echo $ac_n "checking for --with-threads""... $ac_c" 1>&6
! echo "configure:3093: checking for --with-threads" >&5
  # Check whether --with-threads or --without-threads was given.
  if test "${with_threads+set}" = set; then
    withval="$with_threads"
***************
*** 2871,2877 ****
  
  
  echo $ac_n "checking for --with-thread""... $ac_c" 1>&6
! echo "configure:2875: checking for --with-thread" >&5
  # Check whether --with-thread or --without-thread was given.
  if test "${with_thread+set}" = set; then
    withval="$with_thread"
--- 3103,3109 ----
  
  
  echo $ac_n "checking for --with-thread""... $ac_c" 1>&6
! echo "configure:3107: checking for --with-thread" >&5
  # Check whether --with-thread or --without-thread was given.
  if test "${with_thread+set}" = set; then
    withval="$with_thread"
***************
*** 2887,2903 ****
  
  ac_safe=`echo "mach/cthreads.h" | sed 'y%./+-%__p_%'`
  echo $ac_n "checking for mach/cthreads.h""... $ac_c" 1>&6
! echo "configure:2891: checking for mach/cthreads.h" >&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 2896 "configure"
  #include "confdefs.h"
  #include <mach/cthreads.h>
  EOF
  ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
! { (eval echo configure:2901: \"$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*
--- 3119,3135 ----
  
  ac_safe=`echo "mach/cthreads.h" | sed 'y%./+-%__p_%'`
  echo $ac_n "checking for mach/cthreads.h""... $ac_c" 1>&6
! echo "configure:3123: checking for mach/cthreads.h" >&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 3128 "configure"
  #include "confdefs.h"
  #include <mach/cthreads.h>
  EOF
  ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
! { (eval echo configure:3133: \"$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*
***************
*** 2926,2932 ****
    echo "$ac_t""no" 1>&6
  
  echo $ac_n "checking for pth_init in -lpth""... $ac_c" 1>&6
! echo "configure:2930: checking for pth_init in -lpth" >&5
  ac_lib_var=`echo pth'_'pth_init | sed 'y%./+-%__p_%'`
  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
--- 3158,3164 ----
    echo "$ac_t""no" 1>&6
  
  echo $ac_n "checking for pth_init in -lpth""... $ac_c" 1>&6
! echo "configure:3162: checking for pth_init in -lpth" >&5
  ac_lib_var=`echo pth'_'pth_init | sed 'y%./+-%__p_%'`
  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
***************
*** 2934,2940 ****
    ac_save_LIBS="$LIBS"
  LIBS="-lpth  $LIBS"
  cat > conftest.$ac_ext <<EOF
! #line 2938 "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
--- 3166,3172 ----
    ac_save_LIBS="$LIBS"
  LIBS="-lpth  $LIBS"
  cat > conftest.$ac_ext <<EOF
! #line 3170 "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
***************
*** 2945,2951 ****
  pth_init()
  ; return 0; }
  EOF
! if { (eval echo configure:2949: \"$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
--- 3177,3183 ----
  pth_init()
  ; return 0; }
  EOF
! if { (eval echo configure:3181: \"$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
***************
*** 2974,2980 ****
    echo "$ac_t""no" 1>&6
  
  echo $ac_n "checking for pthread_create in -lpthread""... $ac_c" 1>&6
! echo "configure:2978: checking for pthread_create in -lpthread" >&5
  ac_lib_var=`echo pthread'_'pthread_create | sed 'y%./+-%__p_%'`
  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
--- 3206,3212 ----
    echo "$ac_t""no" 1>&6
  
  echo $ac_n "checking for pthread_create in -lpthread""... $ac_c" 1>&6
! echo "configure:3210: checking for pthread_create in -lpthread" >&5
  ac_lib_var=`echo pthread'_'pthread_create | sed 'y%./+-%__p_%'`
  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
***************
*** 2982,2988 ****
    ac_save_LIBS="$LIBS"
  LIBS="-lpthread  $LIBS"
  cat > conftest.$ac_ext <<EOF
! #line 2986 "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
--- 3214,3220 ----
    ac_save_LIBS="$LIBS"
  LIBS="-lpthread  $LIBS"
  cat > conftest.$ac_ext <<EOF
! #line 3218 "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
***************
*** 2993,2999 ****
  pthread_create()
  ; return 0; }
  EOF
! if { (eval echo configure:2997: \"$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
--- 3225,3231 ----
  pthread_create()
  ; return 0; }
  EOF
! if { (eval echo configure:3229: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
    rm -rf conftest*
    eval "ac_cv_lib_$ac_lib_var=yes"
  else
***************
*** 3022,3033 ****
    echo "$ac_t""no" 1>&6
  
  echo $ac_n "checking for pthread_detach""... $ac_c" 1>&6
! echo "configure:3026: checking for pthread_detach" >&5
  if eval "test \"`echo '$''{'ac_cv_func_pthread_detach'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
    cat > conftest.$ac_ext <<EOF
! #line 3031 "configure"
  #include "confdefs.h"
  /* System header to define __stub macros and hopefully few prototypes,
      which can conflict with char pthread_detach(); below.  */
--- 3254,3265 ----
    echo "$ac_t""no" 1>&6
  
  echo $ac_n "checking for pthread_detach""... $ac_c" 1>&6
! echo "configure:3258: checking for pthread_detach" >&5
  if eval "test \"`echo '$''{'ac_cv_func_pthread_detach'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
    cat > conftest.$ac_ext <<EOF
! #line 3263 "configure"
  #include "confdefs.h"
  /* System header to define __stub macros and hopefully few prototypes,
      which can conflict with char pthread_detach(); below.  */
***************
*** 3050,3056 ****
  
  ; return 0; }
  EOF
! 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_func_pthread_detach=yes"
  else
--- 3282,3288 ----
  
  ; return 0; }
  EOF
! 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_func_pthread_detach=yes"
  else
***************
*** 3078,3094 ****
  
  ac_safe=`echo "kernel/OS.h" | sed 'y%./+-%__p_%'`
  echo $ac_n "checking for kernel/OS.h""... $ac_c" 1>&6
! echo "configure:3082: checking for kernel/OS.h" >&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 3087 "configure"
  #include "confdefs.h"
  #include <kernel/OS.h>
  EOF
  ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
! { (eval echo configure:3092: \"$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*
--- 3310,3326 ----
  
  ac_safe=`echo "kernel/OS.h" | sed 'y%./+-%__p_%'`
  echo $ac_n "checking for kernel/OS.h""... $ac_c" 1>&6
! echo "configure:3314: checking for kernel/OS.h" >&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 3319 "configure"
  #include "confdefs.h"
  #include <kernel/OS.h>
  EOF
  ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
! { (eval echo configure:3324: \"$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*
***************
*** 3117,3123 ****
    echo "$ac_t""no" 1>&6
  
  echo $ac_n "checking for pthread_create in -lpthreads""... $ac_c" 1>&6
! echo "configure:3121: checking for pthread_create in -lpthreads" >&5
  ac_lib_var=`echo pthreads'_'pthread_create | sed 'y%./+-%__p_%'`
  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
--- 3349,3355 ----
    echo "$ac_t""no" 1>&6
  
  echo $ac_n "checking for pthread_create in -lpthreads""... $ac_c" 1>&6
! echo "configure:3353: checking for pthread_create in -lpthreads" >&5
  ac_lib_var=`echo pthreads'_'pthread_create | sed 'y%./+-%__p_%'`
  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
***************
*** 3125,3131 ****
    ac_save_LIBS="$LIBS"
  LIBS="-lpthreads  $LIBS"
  cat > conftest.$ac_ext <<EOF
! #line 3129 "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
--- 3357,3363 ----
    ac_save_LIBS="$LIBS"
  LIBS="-lpthreads  $LIBS"
  cat > conftest.$ac_ext <<EOF
! #line 3361 "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
***************
*** 3136,3142 ****
  pthread_create()
  ; return 0; }
  EOF
! if { (eval echo configure:3140: \"$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
--- 3368,3374 ----
  pthread_create()
  ; return 0; }
  EOF
! if { (eval echo configure:3372: \"$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
***************
*** 3165,3171 ****
    echo "$ac_t""no" 1>&6
  
  echo $ac_n "checking for pthread_create in -lc_r""... $ac_c" 1>&6
! echo "configure:3169: checking for pthread_create in -lc_r" >&5
  ac_lib_var=`echo c_r'_'pthread_create | sed 'y%./+-%__p_%'`
  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
--- 3397,3403 ----
    echo "$ac_t""no" 1>&6
  
  echo $ac_n "checking for pthread_create in -lc_r""... $ac_c" 1>&6
! echo "configure:3401: checking for pthread_create in -lc_r" >&5
  ac_lib_var=`echo c_r'_'pthread_create | sed 'y%./+-%__p_%'`
  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
***************
*** 3173,3179 ****
    ac_save_LIBS="$LIBS"
  LIBS="-lc_r  $LIBS"
  cat > conftest.$ac_ext <<EOF
! #line 3177 "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
--- 3405,3411 ----
    ac_save_LIBS="$LIBS"
  LIBS="-lc_r  $LIBS"
  cat > conftest.$ac_ext <<EOF
! #line 3409 "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
***************
*** 3184,3190 ****
  pthread_create()
  ; return 0; }
  EOF
! if { (eval echo configure:3188: \"$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
--- 3416,3422 ----
  pthread_create()
  ; return 0; }
  EOF
! if { (eval echo configure:3420: \"$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,3219 ****
    echo "$ac_t""no" 1>&6
  
  echo $ac_n "checking for __d6_pthread_create in -lthread""... $ac_c" 1>&6
! echo "configure:3217: checking for __d6_pthread_create in -lthread" >&5
  ac_lib_var=`echo thread'_'__d6_pthread_create | sed 'y%./+-%__p_%'`
  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
--- 3445,3451 ----
    echo "$ac_t""no" 1>&6
  
  echo $ac_n "checking for __d6_pthread_create in -lthread""... $ac_c" 1>&6
! echo "configure:3449: checking for __d6_pthread_create in -lthread" >&5
  ac_lib_var=`echo thread'_'__d6_pthread_create | sed 'y%./+-%__p_%'`
  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
***************
*** 3221,3227 ****
    ac_save_LIBS="$LIBS"
  LIBS="-lthread  $LIBS"
  cat > conftest.$ac_ext <<EOF
! #line 3225 "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
--- 3453,3459 ----
    ac_save_LIBS="$LIBS"
  LIBS="-lthread  $LIBS"
  cat > conftest.$ac_ext <<EOF
! #line 3457 "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
***************
*** 3232,3238 ****
  __d6_pthread_create()
  ; return 0; }
  EOF
! if { (eval echo configure:3236: \"$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
--- 3464,3470 ----
  __d6_pthread_create()
  ; return 0; }
  EOF
! if { (eval echo configure:3468: \"$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
***************
*** 3261,3267 ****
    echo "$ac_t""no" 1>&6
  
  echo $ac_n "checking for pthread_create in -lcma""... $ac_c" 1>&6
! echo "configure:3265: checking for pthread_create in -lcma" >&5
  ac_lib_var=`echo cma'_'pthread_create | sed 'y%./+-%__p_%'`
  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
--- 3493,3499 ----
    echo "$ac_t""no" 1>&6
  
  echo $ac_n "checking for pthread_create in -lcma""... $ac_c" 1>&6
! echo "configure:3497: checking for pthread_create in -lcma" >&5
  ac_lib_var=`echo cma'_'pthread_create | sed 'y%./+-%__p_%'`
  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
***************
*** 3269,3275 ****
    ac_save_LIBS="$LIBS"
  LIBS="-lcma  $LIBS"
  cat > conftest.$ac_ext <<EOF
! #line 3273 "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
--- 3501,3507 ----
    ac_save_LIBS="$LIBS"
  LIBS="-lcma  $LIBS"
  cat > conftest.$ac_ext <<EOF
! #line 3505 "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
***************
*** 3280,3286 ****
  pthread_create()
  ; return 0; }
  EOF
! if { (eval echo configure:3284: \"$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
--- 3512,3518 ----
  pthread_create()
  ; return 0; }
  EOF
! if { (eval echo configure:3516: \"$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
***************
*** 3328,3334 ****
  
  
  echo $ac_n "checking for usconfig in -lmpc""... $ac_c" 1>&6
! echo "configure:3332: checking for usconfig in -lmpc" >&5
  ac_lib_var=`echo mpc'_'usconfig | sed 'y%./+-%__p_%'`
  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
--- 3560,3566 ----
  
  
  echo $ac_n "checking for usconfig in -lmpc""... $ac_c" 1>&6
! echo "configure:3564: checking for usconfig in -lmpc" >&5
  ac_lib_var=`echo mpc'_'usconfig | sed 'y%./+-%__p_%'`
  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
***************
*** 3336,3342 ****
    ac_save_LIBS="$LIBS"
  LIBS="-lmpc  $LIBS"
  cat > conftest.$ac_ext <<EOF
! #line 3340 "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
--- 3568,3574 ----
    ac_save_LIBS="$LIBS"
  LIBS="-lmpc  $LIBS"
  cat > conftest.$ac_ext <<EOF
! #line 3572 "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
***************
*** 3347,3353 ****
  usconfig()
  ; return 0; }
  EOF
! if { (eval echo configure:3351: \"$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
--- 3579,3585 ----
  usconfig()
  ; return 0; }
  EOF
! if { (eval echo configure:3583: \"$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
***************
*** 3373,3379 ****
  fi
  
  echo $ac_n "checking for thr_create in -lthread""... $ac_c" 1>&6
! echo "configure:3377: checking for thr_create in -lthread" >&5
  ac_lib_var=`echo thread'_'thr_create | sed 'y%./+-%__p_%'`
  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
--- 3605,3611 ----
  fi
  
  echo $ac_n "checking for thr_create in -lthread""... $ac_c" 1>&6
! echo "configure:3609: checking for thr_create in -lthread" >&5
  ac_lib_var=`echo thread'_'thr_create | sed 'y%./+-%__p_%'`
  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
***************
*** 3381,3387 ****
    ac_save_LIBS="$LIBS"
  LIBS="-lthread  $LIBS"
  cat > conftest.$ac_ext <<EOF
! #line 3385 "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
--- 3613,3619 ----
    ac_save_LIBS="$LIBS"
  LIBS="-lthread  $LIBS"
  cat > conftest.$ac_ext <<EOF
! #line 3617 "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
***************
*** 3392,3398 ****
  thr_create()
  ; return 0; }
  EOF
! if { (eval echo configure:3396: \"$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
--- 3624,3630 ----
  thr_create()
  ; return 0; }
  EOF
! if { (eval echo configure:3628: \"$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
***************
*** 3428,3434 ****
  DLINCLDIR=/
  
  echo $ac_n "checking for --with-sgi-dl""... $ac_c" 1>&6
! echo "configure:3432: checking for --with-sgi-dl" >&5
  # Check whether --with-sgi-dl or --without-sgi-dl was given.
  if test "${with_sgi_dl+set}" = set; then
    withval="$with_sgi_dl"
--- 3660,3666 ----
  DLINCLDIR=/
  
  echo $ac_n "checking for --with-sgi-dl""... $ac_c" 1>&6
! echo "configure:3664: checking for --with-sgi-dl" >&5
  # Check whether --with-sgi-dl or --without-sgi-dl was given.
  if test "${with_sgi_dl+set}" = set; then
    withval="$with_sgi_dl"
***************
*** 3452,3458 ****
  
  
  echo $ac_n "checking for --with-dl-dld""... $ac_c" 1>&6
! echo "configure:3456: checking for --with-dl-dld" >&5
  # Check whether --with-dl-dld or --without-dl-dld was given.
  if test "${with_dl_dld+set}" = set; then
    withval="$with_dl_dld"
--- 3684,3690 ----
  
  
  echo $ac_n "checking for --with-dl-dld""... $ac_c" 1>&6
! echo "configure:3688: checking for --with-dl-dld" >&5
  # Check whether --with-dl-dld or --without-dl-dld was given.
  if test "${with_dl_dld+set}" = set; then
    withval="$with_dl_dld"
***************
*** 3479,3490 ****
  # the dlopen() function means we might want to use dynload_shlib.o. some
  # platforms, such as AIX, have dlopen(), but don't want to use it.
  echo $ac_n "checking for dlopen""... $ac_c" 1>&6
! echo "configure:3483: checking for dlopen" >&5
  if eval "test \"`echo '$''{'ac_cv_func_dlopen'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
    cat > conftest.$ac_ext <<EOF
! #line 3488 "configure"
  #include "confdefs.h"
  /* System header to define __stub macros and hopefully few prototypes,
      which can conflict with char dlopen(); below.  */
--- 3711,3722 ----
  # the dlopen() function means we might want to use dynload_shlib.o. some
  # platforms, such as AIX, have dlopen(), but don't want to use it.
  echo $ac_n "checking for dlopen""... $ac_c" 1>&6
! echo "configure:3715: checking for dlopen" >&5
  if eval "test \"`echo '$''{'ac_cv_func_dlopen'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
    cat > conftest.$ac_ext <<EOF
! #line 3720 "configure"
  #include "confdefs.h"
  /* System header to define __stub macros and hopefully few prototypes,
      which can conflict with char dlopen(); below.  */
***************
*** 3507,3513 ****
  
  ; return 0; }
  EOF
! if { (eval echo configure:3511: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
    rm -rf conftest*
    eval "ac_cv_func_dlopen=yes"
  else
--- 3739,3745 ----
  
  ; return 0; }
  EOF
! if { (eval echo configure:3743: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
    rm -rf conftest*
    eval "ac_cv_func_dlopen=yes"
  else
***************
*** 3531,3537 ****
  # loading of modules.
  
  echo $ac_n "checking DYNLOADFILE""... $ac_c" 1>&6
! echo "configure:3535: checking DYNLOADFILE" >&5
  if test -z "$DYNLOADFILE"
  then
  	case $ac_sys_system/$ac_sys_release in
--- 3763,3769 ----
  # loading of modules.
  
  echo $ac_n "checking DYNLOADFILE""... $ac_c" 1>&6
! echo "configure:3767: checking DYNLOADFILE" >&5
  if test -z "$DYNLOADFILE"
  then
  	case $ac_sys_system/$ac_sys_release in
***************
*** 3570,3581 ****
   truncate uname waitpid
  do
  echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
! echo "configure:3574: 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 3579 "configure"
  #include "confdefs.h"
  /* System header to define __stub macros and hopefully few prototypes,
      which can conflict with char $ac_func(); below.  */
--- 3802,3813 ----
   truncate uname waitpid
  do
  echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
! echo "configure:3806: 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 3811 "configure"
  #include "confdefs.h"
  /* System header to define __stub macros and hopefully few prototypes,
      which can conflict with char $ac_func(); below.  */
***************
*** 3598,3604 ****
  
  ; return 0; }
  EOF
! if { (eval echo configure:3602: \"$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
--- 3830,3836 ----
  
  ; return 0; }
  EOF
! if { (eval echo configure:3834: \"$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
***************
*** 3627,3638 ****
  for ac_func in fseek64 fseeko fstatvfs ftell64 ftello statvfs
  do
  echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
! echo "configure:3631: 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 3636 "configure"
  #include "confdefs.h"
  /* System header to define __stub macros and hopefully few prototypes,
      which can conflict with char $ac_func(); below.  */
--- 3859,3870 ----
  for ac_func in fseek64 fseeko fstatvfs ftell64 ftello statvfs
  do
  echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
! echo "configure:3863: 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 3868 "configure"
  #include "confdefs.h"
  /* System header to define __stub macros and hopefully few prototypes,
      which can conflict with char $ac_func(); below.  */
***************
*** 3655,3661 ****
  
  ; return 0; }
  EOF
! if { (eval echo configure:3659: \"$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
--- 3887,3893 ----
  
  ; return 0; }
  EOF
! if { (eval echo configure:3891: \"$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
***************
*** 3683,3694 ****
  for ac_func in dup2 getcwd strdup strerror memmove
  do
  echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
! echo "configure:3687: 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 3692 "configure"
  #include "confdefs.h"
  /* System header to define __stub macros and hopefully few prototypes,
      which can conflict with char $ac_func(); below.  */
--- 3915,3926 ----
  for ac_func in dup2 getcwd strdup strerror memmove
  do
  echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
! echo "configure:3919: 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 3924 "configure"
  #include "confdefs.h"
  /* System header to define __stub macros and hopefully few prototypes,
      which can conflict with char $ac_func(); below.  */
***************
*** 3711,3717 ****
  
  ; return 0; }
  EOF
! if { (eval echo configure:3715: \"$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
--- 3943,3949 ----
  
  ; return 0; }
  EOF
! if { (eval echo configure:3947: \"$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
***************
*** 3738,3749 ****
  
  
  echo $ac_n "checking for getpgrp""... $ac_c" 1>&6
! echo "configure:3742: checking for getpgrp" >&5
  if eval "test \"`echo '$''{'ac_cv_func_getpgrp'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
    cat > conftest.$ac_ext <<EOF
! #line 3747 "configure"
  #include "confdefs.h"
  /* System header to define __stub macros and hopefully few prototypes,
      which can conflict with char getpgrp(); below.  */
--- 3970,3981 ----
  
  
  echo $ac_n "checking for getpgrp""... $ac_c" 1>&6
! echo "configure:3974: checking for getpgrp" >&5
  if eval "test \"`echo '$''{'ac_cv_func_getpgrp'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
    cat > conftest.$ac_ext <<EOF
! #line 3979 "configure"
  #include "confdefs.h"
  /* System header to define __stub macros and hopefully few prototypes,
      which can conflict with char getpgrp(); below.  */
***************
*** 3766,3772 ****
  
  ; return 0; }
  EOF
! if { (eval echo configure:3770: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
    rm -rf conftest*
    eval "ac_cv_func_getpgrp=yes"
  else
--- 3998,4004 ----
  
  ; return 0; }
  EOF
! if { (eval echo configure:4002: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
    rm -rf conftest*
    eval "ac_cv_func_getpgrp=yes"
  else
***************
*** 3781,3794 ****
  if eval "test \"`echo '$ac_cv_func_'getpgrp`\" = yes"; then
    echo "$ac_t""yes" 1>&6
    cat > conftest.$ac_ext <<EOF
! #line 3785 "configure"
  #include "confdefs.h"
  #include <unistd.h>
  int main() {
  getpgrp(0);
  ; return 0; }
  EOF
! if { (eval echo configure:3792: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
    rm -rf conftest*
    cat >> confdefs.h <<\EOF
  #define GETPGRP_HAVE_ARG 1
--- 4013,4026 ----
  if eval "test \"`echo '$ac_cv_func_'getpgrp`\" = yes"; then
    echo "$ac_t""yes" 1>&6
    cat > conftest.$ac_ext <<EOF
! #line 4017 "configure"
  #include "confdefs.h"
  #include <unistd.h>
  int main() {
  getpgrp(0);
  ; return 0; }
  EOF
! if { (eval echo configure:4024: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
    rm -rf conftest*
    cat >> confdefs.h <<\EOF
  #define GETPGRP_HAVE_ARG 1
***************
*** 3804,3815 ****
  fi
  
  echo $ac_n "checking for setpgrp""... $ac_c" 1>&6
! echo "configure:3808: checking for setpgrp" >&5
  if eval "test \"`echo '$''{'ac_cv_func_setpgrp'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
    cat > conftest.$ac_ext <<EOF
! #line 3813 "configure"
  #include "confdefs.h"
  /* System header to define __stub macros and hopefully few prototypes,
      which can conflict with char setpgrp(); below.  */
--- 4036,4047 ----
  fi
  
  echo $ac_n "checking for setpgrp""... $ac_c" 1>&6
! echo "configure:4040: checking for setpgrp" >&5
  if eval "test \"`echo '$''{'ac_cv_func_setpgrp'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
    cat > conftest.$ac_ext <<EOF
! #line 4045 "configure"
  #include "confdefs.h"
  /* System header to define __stub macros and hopefully few prototypes,
      which can conflict with char setpgrp(); below.  */
***************
*** 3832,3838 ****
  
  ; return 0; }
  EOF
! if { (eval echo configure:3836: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
    rm -rf conftest*
    eval "ac_cv_func_setpgrp=yes"
  else
--- 4064,4070 ----
  
  ; return 0; }
  EOF
! if { (eval echo configure:4068: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
    rm -rf conftest*
    eval "ac_cv_func_setpgrp=yes"
  else
***************
*** 3847,3860 ****
  if eval "test \"`echo '$ac_cv_func_'setpgrp`\" = yes"; then
    echo "$ac_t""yes" 1>&6
    cat > conftest.$ac_ext <<EOF
! #line 3851 "configure"
  #include "confdefs.h"
  #include <unistd.h>
  int main() {
  setpgrp(0,0);
  ; return 0; }
  EOF
! if { (eval echo configure:3858: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
    rm -rf conftest*
    cat >> confdefs.h <<\EOF
  #define SETPGRP_HAVE_ARG 1
--- 4079,4092 ----
  if eval "test \"`echo '$ac_cv_func_'setpgrp`\" = yes"; then
    echo "$ac_t""yes" 1>&6
    cat > conftest.$ac_ext <<EOF
! #line 4083 "configure"
  #include "confdefs.h"
  #include <unistd.h>
  int main() {
  setpgrp(0,0);
  ; return 0; }
  EOF
! if { (eval echo configure:4090: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
    rm -rf conftest*
    cat >> confdefs.h <<\EOF
  #define SETPGRP_HAVE_ARG 1
***************
*** 3870,3881 ****
  fi
  
  echo $ac_n "checking for gettimeofday""... $ac_c" 1>&6
! echo "configure:3874: checking for gettimeofday" >&5
  if eval "test \"`echo '$''{'ac_cv_func_gettimeofday'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
    cat > conftest.$ac_ext <<EOF
! #line 3879 "configure"
  #include "confdefs.h"
  /* System header to define __stub macros and hopefully few prototypes,
      which can conflict with char gettimeofday(); below.  */
--- 4102,4113 ----
  fi
  
  echo $ac_n "checking for gettimeofday""... $ac_c" 1>&6
! echo "configure:4106: checking for gettimeofday" >&5
  if eval "test \"`echo '$''{'ac_cv_func_gettimeofday'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
    cat > conftest.$ac_ext <<EOF
! #line 4111 "configure"
  #include "confdefs.h"
  /* System header to define __stub macros and hopefully few prototypes,
      which can conflict with char gettimeofday(); below.  */
***************
*** 3898,3904 ****
  
  ; return 0; }
  EOF
! if { (eval echo configure:3902: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
    rm -rf conftest*
    eval "ac_cv_func_gettimeofday=yes"
  else
--- 4130,4136 ----
  
  ; return 0; }
  EOF
! if { (eval echo configure:4134: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
    rm -rf conftest*
    eval "ac_cv_func_gettimeofday=yes"
  else
***************
*** 3913,3926 ****
  if eval "test \"`echo '$ac_cv_func_'gettimeofday`\" = yes"; then
    echo "$ac_t""yes" 1>&6
    cat > conftest.$ac_ext <<EOF
! #line 3917 "configure"
  #include "confdefs.h"
  #include <sys/time.h>
  int main() {
  gettimeofday((struct timeval*)0,(struct timezone*)0);
  ; return 0; }
  EOF
! if { (eval echo configure:3924: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
    :
  else
    echo "configure: failed program was:" >&5
--- 4145,4158 ----
  if eval "test \"`echo '$ac_cv_func_'gettimeofday`\" = yes"; then
    echo "$ac_t""yes" 1>&6
    cat > conftest.$ac_ext <<EOF
! #line 4149 "configure"
  #include "confdefs.h"
  #include <sys/time.h>
  int main() {
  gettimeofday((struct timeval*)0,(struct timezone*)0);
  ; return 0; }
  EOF
! if { (eval echo configure:4156: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
    :
  else
    echo "configure: failed program was:" >&5
***************
*** 3937,3950 ****
  fi
  
  
  # checks for structures
  echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
! echo "configure:3943: 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 3948 "configure"
  #include "confdefs.h"
  #include <sys/types.h>
  #include <sys/time.h>
--- 4169,4411 ----
  fi
  
  
+ for ac_func in getaddrinfo
+ do
+ echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+ echo "configure:4176: 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 4181 "configure"
+ #include "confdefs.h"
+ /* System header to define __stub macros and hopefully few prototypes,
+     which can conflict with char $ac_func(); below.  */
+ #include <assert.h>
+ /* Override any gcc2 internal prototype to avoid an error.  */
+ /* We use char because int might match the return type of a gcc2
+     builtin and then its argument prototype would still apply.  */
+ char $ac_func();
+ 
+ int main() {
+ 
+ /* The GNU C library defines this for functions which it implements
+     to always fail with ENOSYS.  Some functions are actually named
+     something starting with __ and the normal name is an alias.  */
+ #if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+ choke me
+ #else
+ $ac_func();
+ #endif
+ 
+ ; return 0; }
+ EOF
+ if { (eval echo configure:4204: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   rm -rf conftest*
+   eval "ac_cv_func_$ac_func=yes"
+ else
+   echo "configure: failed program was:" >&5
+   cat conftest.$ac_ext >&5
+   rm -rf conftest*
+   eval "ac_cv_func_$ac_func=no"
+ fi
+ rm -f conftest*
+ fi
+ 
+ if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+   echo "$ac_t""yes" 1>&6
+     ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+   cat >> confdefs.h <<EOF
+ #define $ac_tr_func 1
+ EOF
+  echo $ac_n "checking getaddrinfo bug""... $ac_c" 1>&6
+ echo "configure:4223: checking getaddrinfo bug" >&5
+ if test "$cross_compiling" = yes; then
+   echo "$ac_t""buggy" 1>&6
+ buggygetaddrinfo=yes
+ else
+   cat > conftest.$ac_ext <<EOF
+ #line 4229 "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:4318: \"$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
+ buggygetaddrinfo=no
+ else
+   echo "configure: failed program was:" >&5
+   cat conftest.$ac_ext >&5
+   rm -fr conftest*
+   echo "$ac_t""buggy" 1>&6
+ buggygetaddrinfo=yes
+ fi
+ rm -fr conftest*
+ fi
+ 
+ else
+   echo "$ac_t""no" 1>&6
+ buggygetaddrinfo=yes
+ fi
+ done
+ 
+ 
+ if test "$buggygetaddrinfo" = "yes"; then
+ 	if test "$ipv6" = "yes"; then
+ 		echo 'Fatal: You must get working getaddrinfo() function.'
+ 		echo '       or you can specify "--disable-ipv6"'.
+ 		exit 1
+ 	fi
+ fi
+ for ac_func in getaddrinfo getnameinfo
+ do
+ echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+ echo "configure:4349: 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 4354 "configure"
+ #include "confdefs.h"
+ /* System header to define __stub macros and hopefully few prototypes,
+     which can conflict with char $ac_func(); below.  */
+ #include <assert.h>
+ /* Override any gcc2 internal prototype to avoid an error.  */
+ /* We use char because int might match the return type of a gcc2
+     builtin and then its argument prototype would still apply.  */
+ char $ac_func();
+ 
+ int main() {
+ 
+ /* The GNU C library defines this for functions which it implements
+     to always fail with ENOSYS.  Some functions are actually named
+     something starting with __ and the normal name is an alias.  */
+ #if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+ choke me
+ #else
+ $ac_func();
+ #endif
+ 
+ ; return 0; }
+ EOF
+ if { (eval echo configure:4377: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   rm -rf conftest*
+   eval "ac_cv_func_$ac_func=yes"
+ else
+   echo "configure: failed program was:" >&5
+   cat conftest.$ac_ext >&5
+   rm -rf conftest*
+   eval "ac_cv_func_$ac_func=no"
+ fi
+ rm -f conftest*
+ fi
+ 
+ if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+   echo "$ac_t""yes" 1>&6
+     ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+   cat >> confdefs.h <<EOF
+ #define $ac_tr_func 1
+ EOF
+  
+ else
+   echo "$ac_t""no" 1>&6
+ fi
+ done
+ 
+ 
  # checks for structures
  echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
! echo "configure:4404: 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 4409 "configure"
  #include "confdefs.h"
  #include <sys/types.h>
  #include <sys/time.h>
***************
*** 3953,3959 ****
  struct tm *tp;
  ; return 0; }
  EOF
! if { (eval echo configure:3957: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
    rm -rf conftest*
    ac_cv_header_time=yes
  else
--- 4414,4420 ----
  struct tm *tp;
  ; return 0; }
  EOF
! if { (eval echo configure:4418: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
    rm -rf conftest*
    ac_cv_header_time=yes
  else
***************
*** 3974,3985 ****
  fi
  
  echo $ac_n "checking whether struct tm is in sys/time.h or time.h""... $ac_c" 1>&6
! echo "configure:3978: checking whether struct tm is in sys/time.h or time.h" >&5
  if eval "test \"`echo '$''{'ac_cv_struct_tm'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
    cat > conftest.$ac_ext <<EOF
! #line 3983 "configure"
  #include "confdefs.h"
  #include <sys/types.h>
  #include <time.h>
--- 4435,4446 ----
  fi
  
  echo $ac_n "checking whether struct tm is in sys/time.h or time.h""... $ac_c" 1>&6
! echo "configure:4439: checking whether struct tm is in sys/time.h or time.h" >&5
  if eval "test \"`echo '$''{'ac_cv_struct_tm'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
    cat > conftest.$ac_ext <<EOF
! #line 4444 "configure"
  #include "confdefs.h"
  #include <sys/types.h>
  #include <time.h>
***************
*** 3987,3993 ****
  struct tm *tp; tp->tm_sec;
  ; return 0; }
  EOF
! if { (eval echo configure:3991: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
    rm -rf conftest*
    ac_cv_struct_tm=time.h
  else
--- 4448,4454 ----
  struct tm *tp; tp->tm_sec;
  ; return 0; }
  EOF
! if { (eval echo configure:4452: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
    rm -rf conftest*
    ac_cv_struct_tm=time.h
  else
***************
*** 4008,4019 ****
  fi
  
  echo $ac_n "checking for tm_zone in struct tm""... $ac_c" 1>&6
! echo "configure:4012: checking for tm_zone in struct tm" >&5
  if eval "test \"`echo '$''{'ac_cv_struct_tm_zone'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
    cat > conftest.$ac_ext <<EOF
! #line 4017 "configure"
  #include "confdefs.h"
  #include <sys/types.h>
  #include <$ac_cv_struct_tm>
--- 4469,4480 ----
  fi
  
  echo $ac_n "checking for tm_zone in struct tm""... $ac_c" 1>&6
! echo "configure:4473: checking for tm_zone in struct tm" >&5
  if eval "test \"`echo '$''{'ac_cv_struct_tm_zone'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
    cat > conftest.$ac_ext <<EOF
! #line 4478 "configure"
  #include "confdefs.h"
  #include <sys/types.h>
  #include <$ac_cv_struct_tm>
***************
*** 4021,4027 ****
  struct tm tm; tm.tm_zone;
  ; return 0; }
  EOF
! if { (eval echo configure:4025: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
    rm -rf conftest*
    ac_cv_struct_tm_zone=yes
  else
--- 4482,4488 ----
  struct tm tm; tm.tm_zone;
  ; return 0; }
  EOF
! if { (eval echo configure:4486: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
    rm -rf conftest*
    ac_cv_struct_tm_zone=yes
  else
***************
*** 4041,4052 ****
  
  else
    echo $ac_n "checking for tzname""... $ac_c" 1>&6
! echo "configure:4045: checking for tzname" >&5
  if eval "test \"`echo '$''{'ac_cv_var_tzname'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
    cat > conftest.$ac_ext <<EOF
! #line 4050 "configure"
  #include "confdefs.h"
  #include <time.h>
  #ifndef tzname /* For SGI.  */
--- 4502,4513 ----
  
  else
    echo $ac_n "checking for tzname""... $ac_c" 1>&6
! echo "configure:4506: checking for tzname" >&5
  if eval "test \"`echo '$''{'ac_cv_var_tzname'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
    cat > conftest.$ac_ext <<EOF
! #line 4511 "configure"
  #include "confdefs.h"
  #include <time.h>
  #ifndef tzname /* For SGI.  */
***************
*** 4056,4062 ****
  atoi(*tzname);
  ; return 0; }
  EOF
! if { (eval echo configure:4060: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
    rm -rf conftest*
    ac_cv_var_tzname=yes
  else
--- 4517,4523 ----
  atoi(*tzname);
  ; return 0; }
  EOF
! if { (eval echo configure:4521: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
    rm -rf conftest*
    ac_cv_var_tzname=yes
  else
***************
*** 4079,4097 ****
  
  
  echo $ac_n "checking for time.h that defines altzone""... $ac_c" 1>&6
! echo "configure:4083: checking for time.h that defines altzone" >&5
  if eval "test \"`echo '$''{'ac_cv_header_time_altzone'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
    cat > conftest.$ac_ext <<EOF
! #line 4088 "configure"
  #include "confdefs.h"
  #include <time.h>
  int main() {
  return altzone;
  ; return 0; }
  EOF
! if { (eval echo configure:4095: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
    rm -rf conftest*
    ac_cv_header_time_altzone=yes
  else
--- 4540,4558 ----
  
  
  echo $ac_n "checking for time.h that defines altzone""... $ac_c" 1>&6
! echo "configure:4544: checking for time.h that defines altzone" >&5
  if eval "test \"`echo '$''{'ac_cv_header_time_altzone'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
    cat > conftest.$ac_ext <<EOF
! #line 4549 "configure"
  #include "confdefs.h"
  #include <time.h>
  int main() {
  return altzone;
  ; return 0; }
  EOF
! if { (eval echo configure:4556: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
    rm -rf conftest*
    ac_cv_header_time_altzone=yes
  else
***************
*** 4113,4121 ****
  
  was_it_defined=no
  echo $ac_n "checking whether sys/select.h and sys/time.h may both be included""... $ac_c" 1>&6
! echo "configure:4117: checking whether sys/select.h and sys/time.h may both be included" >&5
  cat > conftest.$ac_ext <<EOF
! #line 4119 "configure"
  #include "confdefs.h"
  
  #include <sys/types.h>
--- 4574,4582 ----
  
  was_it_defined=no
  echo $ac_n "checking whether sys/select.h and sys/time.h may both be included""... $ac_c" 1>&6
! echo "configure:4578: checking whether sys/select.h and sys/time.h may both be included" >&5
  cat > conftest.$ac_ext <<EOF
! #line 4580 "configure"
  #include "confdefs.h"
  
  #include <sys/types.h>
***************
*** 4126,4132 ****
  ;
  ; return 0; }
  EOF
! if { (eval echo configure:4130: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
    rm -rf conftest*
    cat >> confdefs.h <<\EOF
  #define SYS_SELECT_WITH_SYS_TIME 1
--- 4587,4593 ----
  ;
  ; return 0; }
  EOF
! if { (eval echo configure:4591: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
    rm -rf conftest*
    cat >> confdefs.h <<\EOF
  #define SYS_SELECT_WITH_SYS_TIME 1
***************
*** 4139,4155 ****
  rm -f conftest*
  echo "$ac_t""$was_it_defined" 1>&6
  
  # checks for compiler characteristics
  
  echo $ac_n "checking whether char is unsigned""... $ac_c" 1>&6
! echo "configure:4146: checking whether char is unsigned" >&5
  if eval "test \"`echo '$''{'ac_cv_c_char_unsigned'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
    if test "$GCC" = yes; then
    # GCC predefines this symbol on systems where it applies.
  cat > conftest.$ac_ext <<EOF
! #line 4153 "configure"
  #include "confdefs.h"
  #ifdef __CHAR_UNSIGNED__
    yes
--- 4600,4685 ----
  rm -f conftest*
  echo "$ac_t""$was_it_defined" 1>&6
  
+ echo $ac_n "checking for addrinfo""... $ac_c" 1>&6
+ echo "configure:4605: checking for addrinfo" >&5
+ if eval "test \"`echo '$''{'ac_cv_struct_addrinfo'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+   cat > conftest.$ac_ext <<EOF
+ #line 4610 "configure"
+ #include "confdefs.h"
+ 
+ #		include <netdb.h>
+ int main() {
+ struct addrinfo a
+ ; return 0; }
+ EOF
+ if { (eval echo configure:4618: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+   rm -rf conftest*
+   ac_cv_struct_addrinfo=yes
+ else
+   echo "configure: failed program was:" >&5
+   cat conftest.$ac_ext >&5
+   rm -rf conftest*
+   ac_cv_struct_addrinfo=no
+ fi
+ rm -f conftest*
+ fi
+ 
+ echo "$ac_t""$ac_cv_struct_addrinfo" 1>&6
+ if test $ac_cv_struct_addrinfo = yes; then
+ 	cat >> confdefs.h <<\EOF
+ #define HAVE_ADDRINFO 1
+ EOF
+ 
+ fi
+ 
+ echo $ac_n "checking for sockaddr_storage""... $ac_c" 1>&6
+ echo "configure:4639: checking for sockaddr_storage" >&5
+ if eval "test \"`echo '$''{'ac_cv_struct_sockaddr_storage'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+   cat > conftest.$ac_ext <<EOF
+ #line 4644 "configure"
+ #include "confdefs.h"
+ 
+ #		include <sys/types.h>
+ #		include <sys/socket.h>
+ int main() {
+ struct sockaddr_storage s
+ ; return 0; }
+ EOF
+ if { (eval echo configure:4653: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+   rm -rf conftest*
+   ac_cv_struct_sockaddr_storage=yes
+ else
+   echo "configure: failed program was:" >&5
+   cat conftest.$ac_ext >&5
+   rm -rf conftest*
+   ac_cv_struct_sockaddr_storage=no
+ fi
+ rm -f conftest*
+ fi
+ 
+ echo "$ac_t""$ac_cv_struct_sockaddr_storage" 1>&6
+ if test $ac_cv_struct_sockaddr_storage = yes; then
+ 	cat >> confdefs.h <<\EOF
+ #define HAVE_SOCKADDR_STORAGE 1
+ EOF
+ 
+ fi
+ 
  # checks for compiler characteristics
  
  echo $ac_n "checking whether char is unsigned""... $ac_c" 1>&6
! echo "configure:4676: checking whether char is unsigned" >&5
  if eval "test \"`echo '$''{'ac_cv_c_char_unsigned'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
    if test "$GCC" = yes; then
    # GCC predefines this symbol on systems where it applies.
  cat > conftest.$ac_ext <<EOF
! #line 4683 "configure"
  #include "confdefs.h"
  #ifdef __CHAR_UNSIGNED__
    yes
***************
*** 4171,4177 ****
      { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
  else
    cat > conftest.$ac_ext <<EOF
! #line 4175 "configure"
  #include "confdefs.h"
  /* volatile prevents gcc2 from optimizing the test away on sparcs.  */
  #if !defined(__STDC__) || __STDC__ != 1
--- 4701,4707 ----
      { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
  else
    cat > conftest.$ac_ext <<EOF
! #line 4705 "configure"
  #include "confdefs.h"
  /* volatile prevents gcc2 from optimizing the test away on sparcs.  */
  #if !defined(__STDC__) || __STDC__ != 1
***************
*** 4181,4187 ****
    volatile char c = 255; exit(c < 0);
  }
  EOF
! if { (eval echo configure:4185: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
  then
    ac_cv_c_char_unsigned=yes
  else
--- 4711,4717 ----
    volatile char c = 255; exit(c < 0);
  }
  EOF
! if { (eval echo configure:4715: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
  then
    ac_cv_c_char_unsigned=yes
  else
***************
*** 4205,4216 ****
  fi
  
  echo $ac_n "checking for working const""... $ac_c" 1>&6
! echo "configure:4209: 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 4214 "configure"
  #include "confdefs.h"
  
  int main() {
--- 4735,4746 ----
  fi
  
  echo $ac_n "checking for working const""... $ac_c" 1>&6
! echo "configure:4739: 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 4744 "configure"
  #include "confdefs.h"
  
  int main() {
***************
*** 4259,4265 ****
  
  ; return 0; }
  EOF
! if { (eval echo configure:4263: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
    rm -rf conftest*
    ac_cv_c_const=yes
  else
--- 4789,4795 ----
  
  ; return 0; }
  EOF
! if { (eval echo configure:4793: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
    rm -rf conftest*
    ac_cv_c_const=yes
  else
***************
*** 4280,4300 ****
  fi
  
  echo $ac_n "checking for inline""... $ac_c" 1>&6
! echo "configure:4284: checking for inline" >&5
  if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
    ac_cv_c_inline=no
  for ac_kw in inline __inline__ __inline; do
    cat > conftest.$ac_ext <<EOF
! #line 4291 "configure"
  #include "confdefs.h"
  
  int main() {
  } $ac_kw foo() {
  ; return 0; }
  EOF
! if { (eval echo configure:4298: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
    rm -rf conftest*
    ac_cv_c_inline=$ac_kw; break
  else
--- 4810,4830 ----
  fi
  
  echo $ac_n "checking for inline""... $ac_c" 1>&6
! echo "configure:4814: checking for inline" >&5
  if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
    ac_cv_c_inline=no
  for ac_kw in inline __inline__ __inline; do
    cat > conftest.$ac_ext <<EOF
! #line 4821 "configure"
  #include "confdefs.h"
  
  int main() {
  } $ac_kw foo() {
  ; return 0; }
  EOF
! if { (eval echo configure:4828: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
    rm -rf conftest*
    ac_cv_c_inline=$ac_kw; break
  else
***************
*** 4322,4337 ****
  
  works=no
  echo $ac_n "checking for working volatile""... $ac_c" 1>&6
! echo "configure:4326: checking for working volatile" >&5
  cat > conftest.$ac_ext <<EOF
! #line 4328 "configure"
  #include "confdefs.h"
  
  int main() {
  volatile int x; x = 0;
  ; return 0; }
  EOF
! if { (eval echo configure:4335: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
    rm -rf conftest*
    works=yes
  else
--- 4852,4867 ----
  
  works=no
  echo $ac_n "checking for working volatile""... $ac_c" 1>&6
! echo "configure:4856: checking for working volatile" >&5
  cat > conftest.$ac_ext <<EOF
! #line 4858 "configure"
  #include "confdefs.h"
  
  int main() {
  volatile int x; x = 0;
  ; return 0; }
  EOF
! if { (eval echo configure:4865: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
    rm -rf conftest*
    works=yes
  else
***************
*** 4348,4363 ****
  
  works=no
  echo $ac_n "checking for working signed char""... $ac_c" 1>&6
! echo "configure:4352: checking for working signed char" >&5
  cat > conftest.$ac_ext <<EOF
! #line 4354 "configure"
  #include "confdefs.h"
  
  int main() {
  signed char c;
  ; return 0; }
  EOF
! if { (eval echo configure:4361: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
    rm -rf conftest*
    works=yes
  else
--- 4878,4893 ----
  
  works=no
  echo $ac_n "checking for working signed char""... $ac_c" 1>&6
! echo "configure:4882: checking for working signed char" >&5
  cat > conftest.$ac_ext <<EOF
! #line 4884 "configure"
  #include "confdefs.h"
  
  int main() {
  signed char c;
  ; return 0; }
  EOF
! if { (eval echo configure:4891: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
    rm -rf conftest*
    works=yes
  else
***************
*** 4374,4389 ****
  
  have_prototypes=no
  echo $ac_n "checking for prototypes""... $ac_c" 1>&6
! echo "configure:4378: checking for prototypes" >&5
  cat > conftest.$ac_ext <<EOF
! #line 4380 "configure"
  #include "confdefs.h"
  int foo(int x) { return 0; }
  int main() {
  return foo(10);
  ; return 0; }
  EOF
! if { (eval echo configure:4387: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
    rm -rf conftest*
    cat >> confdefs.h <<\EOF
  #define HAVE_PROTOTYPES 1
--- 4904,4919 ----
  
  have_prototypes=no
  echo $ac_n "checking for prototypes""... $ac_c" 1>&6
! echo "configure:4908: checking for prototypes" >&5
  cat > conftest.$ac_ext <<EOF
! #line 4910 "configure"
  #include "confdefs.h"
  int foo(int x) { return 0; }
  int main() {
  return foo(10);
  ; return 0; }
  EOF
! if { (eval echo configure:4917: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
    rm -rf conftest*
    cat >> confdefs.h <<\EOF
  #define HAVE_PROTOTYPES 1
***************
*** 4398,4406 ****
  
  works=no
  echo $ac_n "checking for variable length prototypes and stdarg.h""... $ac_c" 1>&6
! echo "configure:4402: checking for variable length prototypes and stdarg.h" >&5
  cat > conftest.$ac_ext <<EOF
! #line 4404 "configure"
  #include "confdefs.h"
  
  #include <stdarg.h>
--- 4928,4936 ----
  
  works=no
  echo $ac_n "checking for variable length prototypes and stdarg.h""... $ac_c" 1>&6
! echo "configure:4932: checking for variable length prototypes and stdarg.h" >&5
  cat > conftest.$ac_ext <<EOF
! #line 4934 "configure"
  #include "confdefs.h"
  
  #include <stdarg.h>
***************
*** 4417,4423 ****
  return foo(10, "", 3.14);
  ; return 0; }
  EOF
! if { (eval echo configure:4421: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
    rm -rf conftest*
    cat >> confdefs.h <<\EOF
  #define HAVE_STDARG_PROTOTYPES 1
--- 4947,4953 ----
  return foo(10, "", 3.14);
  ; return 0; }
  EOF
! if { (eval echo configure:4951: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
    rm -rf conftest*
    cat >> confdefs.h <<\EOF
  #define HAVE_STDARG_PROTOTYPES 1
***************
*** 4433,4448 ****
  if test "$have_prototypes" = yes; then
  bad_prototypes=no
  echo $ac_n "checking for bad exec* prototypes""... $ac_c" 1>&6
! echo "configure:4437: checking for bad exec* prototypes" >&5
  cat > conftest.$ac_ext <<EOF
! #line 4439 "configure"
  #include "confdefs.h"
  #include <unistd.h>
  int main() {
  char **t;execve("@",t,t);
  ; return 0; }
  EOF
! if { (eval echo configure:4446: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
    :
  else
    echo "configure: failed program was:" >&5
--- 4963,4978 ----
  if test "$have_prototypes" = yes; then
  bad_prototypes=no
  echo $ac_n "checking for bad exec* prototypes""... $ac_c" 1>&6
! echo "configure:4967: checking for bad exec* prototypes" >&5
  cat > conftest.$ac_ext <<EOF
! #line 4969 "configure"
  #include "confdefs.h"
  #include <unistd.h>
  int main() {
  char **t;execve("@",t,t);
  ; return 0; }
  EOF
! if { (eval echo configure:4976: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
    :
  else
    echo "configure: failed program was:" >&5
***************
*** 4459,4470 ****
  
  bad_forward=no
  echo $ac_n "checking for bad static forward""... $ac_c" 1>&6
! echo "configure:4463: checking for bad static forward" >&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 4468 "configure"
  #include "confdefs.h"
  
  struct s { int a; int b; };
--- 4989,5000 ----
  
  bad_forward=no
  echo $ac_n "checking for bad static forward""... $ac_c" 1>&6
! echo "configure:4993: checking for bad static forward" >&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 4998 "configure"
  #include "confdefs.h"
  
  struct s { int a; int b; };
***************
*** 4480,4486 ****
  }
  
  EOF
! if { (eval echo configure:4484: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
  then
    :
  else
--- 5010,5016 ----
  }
  
  EOF
! if { (eval echo configure:5014: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
  then
    :
  else
***************
*** 4499,4507 ****
  
  va_list_is_array=no
  echo $ac_n "checking whether va_list is an array""... $ac_c" 1>&6
! echo "configure:4503: checking whether va_list is an array" >&5
  cat > conftest.$ac_ext <<EOF
! #line 4505 "configure"
  #include "confdefs.h"
  
  #ifdef HAVE_STDARG_PROTOTYPES
--- 5029,5037 ----
  
  va_list_is_array=no
  echo $ac_n "checking whether va_list is an array""... $ac_c" 1>&6
! echo "configure:5033: checking whether va_list is an array" >&5
  cat > conftest.$ac_ext <<EOF
! #line 5035 "configure"
  #include "confdefs.h"
  
  #ifdef HAVE_STDARG_PROTOTYPES
***************
*** 4514,4520 ****
  va_list list1, list2; list1 = list2;
  ; return 0; }
  EOF
! if { (eval echo configure:4518: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
    :
  else
    echo "configure: failed program was:" >&5
--- 5044,5050 ----
  va_list list1, list2; list1 = list2;
  ; return 0; }
  EOF
! if { (eval echo configure:5048: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
    :
  else
    echo "configure: failed program was:" >&5
***************
*** 4530,4541 ****
  
  # sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
  echo $ac_n "checking for gethostbyname_r""... $ac_c" 1>&6
! echo "configure:4534: checking for gethostbyname_r" >&5
  if eval "test \"`echo '$''{'ac_cv_func_gethostbyname_r'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
    cat > conftest.$ac_ext <<EOF
! #line 4539 "configure"
  #include "confdefs.h"
  /* System header to define __stub macros and hopefully few prototypes,
      which can conflict with char gethostbyname_r(); below.  */
--- 5060,5071 ----
  
  # sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
  echo $ac_n "checking for gethostbyname_r""... $ac_c" 1>&6
! echo "configure:5064: checking for gethostbyname_r" >&5
  if eval "test \"`echo '$''{'ac_cv_func_gethostbyname_r'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
    cat > conftest.$ac_ext <<EOF
! #line 5069 "configure"
  #include "confdefs.h"
  /* System header to define __stub macros and hopefully few prototypes,
      which can conflict with char gethostbyname_r(); below.  */
***************
*** 4558,4564 ****
  
  ; return 0; }
  EOF
! if { (eval echo configure:4562: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
    rm -rf conftest*
    eval "ac_cv_func_gethostbyname_r=yes"
  else
--- 5088,5094 ----
  
  ; return 0; }
  EOF
! if { (eval echo configure:5092: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
    rm -rf conftest*
    eval "ac_cv_func_gethostbyname_r=yes"
  else
***************
*** 4578,4588 ****
  EOF
  
    echo $ac_n "checking gethostbyname_r with 6 args""... $ac_c" 1>&6
! echo "configure:4582: checking gethostbyname_r with 6 args" >&5
    OLD_CFLAGS=$CFLAGS
    CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
    cat > conftest.$ac_ext <<EOF
! #line 4586 "configure"
  #include "confdefs.h"
  
  #   include <netdb.h>
--- 5108,5118 ----
  EOF
  
    echo $ac_n "checking gethostbyname_r with 6 args""... $ac_c" 1>&6
! echo "configure:5112: checking gethostbyname_r with 6 args" >&5
    OLD_CFLAGS=$CFLAGS
    CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
    cat > conftest.$ac_ext <<EOF
! #line 5116 "configure"
  #include "confdefs.h"
  
  #   include <netdb.h>
***************
*** 4599,4605 ****
    
  ; return 0; }
  EOF
! if { (eval echo configure:4603: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
    rm -rf conftest*
    
      cat >> confdefs.h <<\EOF
--- 5129,5135 ----
    
  ; return 0; }
  EOF
! if { (eval echo configure:5133: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
    rm -rf conftest*
    
      cat >> confdefs.h <<\EOF
***************
*** 4619,4627 ****
    
      echo "$ac_t""no" 1>&6
      echo $ac_n "checking gethostbyname_r with 5 args""... $ac_c" 1>&6
! echo "configure:4623: checking gethostbyname_r with 5 args" >&5
      cat > conftest.$ac_ext <<EOF
! #line 4625 "configure"
  #include "confdefs.h"
  
  #     include <netdb.h>
--- 5149,5157 ----
    
      echo "$ac_t""no" 1>&6
      echo $ac_n "checking gethostbyname_r with 5 args""... $ac_c" 1>&6
! echo "configure:5153: checking gethostbyname_r with 5 args" >&5
      cat > conftest.$ac_ext <<EOF
! #line 5155 "configure"
  #include "confdefs.h"
  
  #     include <netdb.h>
***************
*** 4638,4644 ****
      
  ; return 0; }
  EOF
! if { (eval echo configure:4642: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
    rm -rf conftest*
    
        cat >> confdefs.h <<\EOF
--- 5168,5174 ----
      
  ; return 0; }
  EOF
! if { (eval echo configure:5172: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
    rm -rf conftest*
    
        cat >> confdefs.h <<\EOF
***************
*** 4658,4666 ****
    
        echo "$ac_t""no" 1>&6
        echo $ac_n "checking gethostbyname_r with 3 args""... $ac_c" 1>&6
! echo "configure:4662: checking gethostbyname_r with 3 args" >&5
        cat > conftest.$ac_ext <<EOF
! #line 4664 "configure"
  #include "confdefs.h"
  
  #       include <netdb.h>
--- 5188,5196 ----
    
        echo "$ac_t""no" 1>&6
        echo $ac_n "checking gethostbyname_r with 3 args""... $ac_c" 1>&6
! echo "configure:5192: checking gethostbyname_r with 3 args" >&5
        cat > conftest.$ac_ext <<EOF
! #line 5194 "configure"
  #include "confdefs.h"
  
  #       include <netdb.h>
***************
*** 4675,4681 ****
        
  ; return 0; }
  EOF
! if { (eval echo configure:4679: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
    rm -rf conftest*
    
          cat >> confdefs.h <<\EOF
--- 5205,5211 ----
        
  ; return 0; }
  EOF
! if { (eval echo configure:5209: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
    rm -rf conftest*
    
          cat >> confdefs.h <<\EOF
***************
*** 4709,4720 ****
    echo "$ac_t""no" 1>&6
  
    echo $ac_n "checking for gethostbyname""... $ac_c" 1>&6
! echo "configure:4713: 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 4718 "configure"
  #include "confdefs.h"
  /* System header to define __stub macros and hopefully few prototypes,
      which can conflict with char gethostbyname(); below.  */
--- 5239,5250 ----
    echo "$ac_t""no" 1>&6
  
    echo $ac_n "checking for gethostbyname""... $ac_c" 1>&6
! echo "configure:5243: 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 5248 "configure"
  #include "confdefs.h"
  /* System header to define __stub macros and hopefully few prototypes,
      which can conflict with char gethostbyname(); below.  */
***************
*** 4737,4743 ****
  
  ; return 0; }
  EOF
! if { (eval echo configure:4741: \"$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
--- 5267,5273 ----
  
  ; return 0; }
  EOF
! if { (eval echo configure:5271: \"$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
***************
*** 4773,4779 ****
  
  # Linux requires this for correct f.p. operations
  echo $ac_n "checking for __fpu_control in -lieee""... $ac_c" 1>&6
! echo "configure:4777: checking for __fpu_control in -lieee" >&5
  ac_lib_var=`echo ieee'_'__fpu_control | sed 'y%./+-%__p_%'`
  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
--- 5303,5309 ----
  
  # Linux requires this for correct f.p. operations
  echo $ac_n "checking for __fpu_control in -lieee""... $ac_c" 1>&6
! echo "configure:5307: checking for __fpu_control in -lieee" >&5
  ac_lib_var=`echo ieee'_'__fpu_control | sed 'y%./+-%__p_%'`
  if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
***************
*** 4781,4787 ****
    ac_save_LIBS="$LIBS"
  LIBS="-lieee  $LIBS"
  cat > conftest.$ac_ext <<EOF
! #line 4785 "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
--- 5311,5317 ----
    ac_save_LIBS="$LIBS"
  LIBS="-lieee  $LIBS"
  cat > conftest.$ac_ext <<EOF
! #line 5315 "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
***************
*** 4792,4798 ****
  __fpu_control()
  ; return 0; }
  EOF
! if { (eval echo configure:4796: \"$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
--- 5322,5328 ----
  __fpu_control()
  ; return 0; }
  EOF
! if { (eval echo configure:5326: \"$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
***************
*** 4822,4828 ****
  
  # Check for --with-fpectl
  echo $ac_n "checking for --with-fpectl""... $ac_c" 1>&6
! echo "configure:4826: checking for --with-fpectl" >&5
  # Check whether --with-fpectl or --without-fpectl was given.
  if test "${with_fpectl+set}" = set; then
    withval="$with_fpectl"
--- 5352,5358 ----
  
  # Check for --with-fpectl
  echo $ac_n "checking for --with-fpectl""... $ac_c" 1>&6
! echo "configure:5356: checking for --with-fpectl" >&5
  # Check whether --with-fpectl or --without-fpectl was given.
  if test "${with_fpectl+set}" = set; then
    withval="$with_fpectl"
***************
*** 4847,4853 ****
  *) LIBM=-lm
  esac
  echo $ac_n "checking for --with-libm=STRING""... $ac_c" 1>&6
! echo "configure:4851: checking for --with-libm=STRING" >&5
  # Check whether --with-libm or --without-libm was given.
  if test "${with_libm+set}" = set; then
    withval="$with_libm"
--- 5377,5383 ----
  *) LIBM=-lm
  esac
  echo $ac_n "checking for --with-libm=STRING""... $ac_c" 1>&6
! echo "configure:5381: checking for --with-libm=STRING" >&5
  # Check whether --with-libm or --without-libm was given.
  if test "${with_libm+set}" = set; then
    withval="$with_libm"
***************
*** 4868,4874 ****
  # check for --with-libc=...
  
  echo $ac_n "checking for --with-libc=STRING""... $ac_c" 1>&6
! echo "configure:4872: checking for --with-libc=STRING" >&5
  # Check whether --with-libc or --without-libc was given.
  if test "${with_libc+set}" = set; then
    withval="$with_libc"
--- 5398,5404 ----
  # check for --with-libc=...
  
  echo $ac_n "checking for --with-libc=STRING""... $ac_c" 1>&6
! echo "configure:5402: checking for --with-libc=STRING" >&5
  # Check whether --with-libc or --without-libc was given.
  if test "${with_libc+set}" = set; then
    withval="$with_libc"
***************
*** 4892,4903 ****
  for ac_func in hypot
  do
  echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
! echo "configure:4896: 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 4901 "configure"
  #include "confdefs.h"
  /* System header to define __stub macros and hopefully few prototypes,
      which can conflict with char $ac_func(); below.  */
--- 5422,5433 ----
  for ac_func in hypot
  do
  echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
! echo "configure:5426: 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 5431 "configure"
  #include "confdefs.h"
  /* System header to define __stub macros and hopefully few prototypes,
      which can conflict with char $ac_func(); below.  */
***************
*** 4920,4926 ****
  
  ; return 0; }
  EOF
! if { (eval echo configure:4924: \"$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
--- 5450,5456 ----
  
  ; return 0; }
  EOF
! if { (eval echo configure:5454: \"$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
***************
*** 4947,4958 ****
  for ac_func in hypot
  do
  echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
! echo "configure:4951: 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 4956 "configure"
  #include "confdefs.h"
  /* System header to define __stub macros and hopefully few prototypes,
      which can conflict with char $ac_func(); below.  */
--- 5477,5488 ----
  for ac_func in hypot
  do
  echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
! echo "configure:5481: 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 5486 "configure"
  #include "confdefs.h"
  /* System header to define __stub macros and hopefully few prototypes,
      which can conflict with char $ac_func(); below.  */
***************
*** 4975,4981 ****
  
  ; return 0; }
  EOF
! if { (eval echo configure:4979: \"$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
--- 5505,5511 ----
  
  ; return 0; }
  EOF
! if { (eval echo configure:5509: \"$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
***************
*** 5009,5020 ****
  for ac_func in rint
  do
  echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
! echo "configure:5013: 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 5018 "configure"
  #include "confdefs.h"
  /* System header to define __stub macros and hopefully few prototypes,
      which can conflict with char $ac_func(); below.  */
--- 5539,5550 ----
  for ac_func in rint
  do
  echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
! echo "configure:5543: 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 5548 "configure"
  #include "confdefs.h"
  /* System header to define __stub macros and hopefully few prototypes,
      which can conflict with char $ac_func(); below.  */
***************
*** 5037,5043 ****
  
  ; return 0; }
  EOF
! if { (eval echo configure:5041: \"$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
--- 5567,5573 ----
  
  ; return 0; }
  EOF
! if { (eval echo configure:5571: \"$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
***************
*** 5065,5071 ****
  
  # check for getopt
  echo $ac_n "checking for genuine getopt""... $ac_c" 1>&6
! echo "configure:5069: checking for genuine getopt" >&5
  if eval "test \"`echo '$''{'ac_cv_func_getopt'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
--- 5595,5601 ----
  
  # check for getopt
  echo $ac_n "checking for genuine getopt""... $ac_c" 1>&6
! echo "configure:5599: checking for genuine getopt" >&5
  if eval "test \"`echo '$''{'ac_cv_func_getopt'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
***************
*** 5073,5079 ****
    ac_cv_func_getopt=no
  else
    cat > conftest.$ac_ext <<EOF
! #line 5077 "configure"
  #include "confdefs.h"
  #include <stdio.h>
  extern int optind, opterr, getopt();
--- 5603,5609 ----
    ac_cv_func_getopt=no
  else
    cat > conftest.$ac_ext <<EOF
! #line 5607 "configure"
  #include "confdefs.h"
  #include <stdio.h>
  extern int optind, opterr, getopt();
***************
*** 5085,5091 ****
  	exit(0);
  }
  EOF
! if { (eval echo configure:5089: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
  then
    ac_cv_func_getopt=yes
  else
--- 5615,5621 ----
  	exit(0);
  }
  EOF
! if { (eval echo configure:5619: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
  then
    ac_cv_func_getopt=yes
  else
***************
*** 5103,5109 ****
  
  # check whether malloc(0) returns NULL or not
  echo $ac_n "checking what malloc(0) returns""... $ac_c" 1>&6
! echo "configure:5107: checking what malloc(0) returns" >&5
  if eval "test \"`echo '$''{'ac_cv_malloc_zero'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
--- 5633,5639 ----
  
  # check whether malloc(0) returns NULL or not
  echo $ac_n "checking what malloc(0) returns""... $ac_c" 1>&6
! echo "configure:5637: checking what malloc(0) returns" >&5
  if eval "test \"`echo '$''{'ac_cv_malloc_zero'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
***************
*** 5111,5117 ****
      { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
  else
    cat > conftest.$ac_ext <<EOF
! #line 5115 "configure"
  #include "confdefs.h"
  #include <stdio.h>
  #ifdef HAVE_STDLIB
--- 5641,5647 ----
      { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
  else
    cat > conftest.$ac_ext <<EOF
! #line 5645 "configure"
  #include "confdefs.h"
  #include <stdio.h>
  #ifdef HAVE_STDLIB
***************
*** 5130,5136 ****
  	exit(0);
  }
  EOF
! if { (eval echo configure:5134: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
  then
    ac_cv_malloc_zero=nonnull
  else
--- 5660,5666 ----
  	exit(0);
  }
  EOF
! if { (eval echo configure:5664: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
  then
    ac_cv_malloc_zero=nonnull
  else
***************
*** 5153,5172 ****
  
  fi
  
  # check for wchar.h
  ac_safe=`echo "wchar.h" | sed 'y%./+-%__p_%'`
  echo $ac_n "checking for wchar.h""... $ac_c" 1>&6
! echo "configure:5160: checking for wchar.h" >&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 5165 "configure"
  #include "confdefs.h"
  #include <wchar.h>
  EOF
  ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
! { (eval echo configure:5170: \"$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*
--- 5683,5730 ----
  
  fi
  
+ # check if sockaddr has sa_len member
+ echo $ac_n "checking if sockaddr has sa_len member""... $ac_c" 1>&6
+ echo "configure:5689: checking if sockaddr has sa_len member" >&5
+ cat > conftest.$ac_ext <<EOF
+ #line 5691 "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:5700: \"$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 for wchar.h
  ac_safe=`echo "wchar.h" | sed 'y%./+-%__p_%'`
  echo $ac_n "checking for wchar.h""... $ac_c" 1>&6
! echo "configure:5718: checking for wchar.h" >&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 5723 "configure"
  #include "confdefs.h"
  #include <wchar.h>
  EOF
  ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
! { (eval echo configure:5728: \"$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*
***************
*** 5196,5207 ****
  # check for usable wchar_t
  usable_wchar_t="unkown"
  echo $ac_n "checking for usable wchar_t""... $ac_c" 1>&6
! echo "configure:5200: checking for usable wchar_t" >&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 5205 "configure"
  #include "confdefs.h"
  
  #include "wchar.h"
--- 5754,5765 ----
  # check for usable wchar_t
  usable_wchar_t="unkown"
  echo $ac_n "checking for usable wchar_t""... $ac_c" 1>&6
! echo "configure:5758: checking for usable wchar_t" >&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 5763 "configure"
  #include "confdefs.h"
  
  #include "wchar.h"
***************
*** 5215,5221 ****
  }
  
  EOF
! if { (eval echo configure:5219: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
  then
    cat >> confdefs.h <<\EOF
  #define HAVE_USABLE_WCHAR_T 1
--- 5773,5779 ----
  }
  
  EOF
! if { (eval echo configure:5777: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
  then
    cat >> confdefs.h <<\EOF
  #define HAVE_USABLE_WCHAR_T 1
***************
*** 5234,5247 ****
  
  # check for endianness
  echo $ac_n "checking whether byte ordering is bigendian""... $ac_c" 1>&6
! echo "configure:5238: checking whether byte ordering is bigendian" >&5
  if eval "test \"`echo '$''{'ac_cv_c_bigendian'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
    ac_cv_c_bigendian=unknown
  # See if sys/param.h defines the BYTE_ORDER macro.
  cat > conftest.$ac_ext <<EOF
! #line 5245 "configure"
  #include "confdefs.h"
  #include <sys/types.h>
  #include <sys/param.h>
--- 5792,5805 ----
  
  # check for endianness
  echo $ac_n "checking whether byte ordering is bigendian""... $ac_c" 1>&6
! echo "configure:5796: checking whether byte ordering is bigendian" >&5
  if eval "test \"`echo '$''{'ac_cv_c_bigendian'+set}'`\" = set"; then
    echo $ac_n "(cached) $ac_c" 1>&6
  else
    ac_cv_c_bigendian=unknown
  # See if sys/param.h defines the BYTE_ORDER macro.
  cat > conftest.$ac_ext <<EOF
! #line 5803 "configure"
  #include "confdefs.h"
  #include <sys/types.h>
  #include <sys/param.h>
***************
*** 5252,5262 ****
  #endif
  ; return 0; }
  EOF
! if { (eval echo configure:5256: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
    rm -rf conftest*
    # It does; now see whether it defined to BIG_ENDIAN or not.
  cat > conftest.$ac_ext <<EOF
! #line 5260 "configure"
  #include "confdefs.h"
  #include <sys/types.h>
  #include <sys/param.h>
--- 5810,5820 ----
  #endif
  ; return 0; }
  EOF
! if { (eval echo configure:5814: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
    rm -rf conftest*
    # It does; now see whether it defined to BIG_ENDIAN or not.
  cat > conftest.$ac_ext <<EOF
! #line 5818 "configure"
  #include "confdefs.h"
  #include <sys/types.h>
  #include <sys/param.h>
***************
*** 5267,5273 ****
  #endif
  ; return 0; }
  EOF
! if { (eval echo configure:5271: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
    rm -rf conftest*
    ac_cv_c_bigendian=yes
  else
--- 5825,5831 ----
  #endif
  ; return 0; }
  EOF
! if { (eval echo configure:5829: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
    rm -rf conftest*
    ac_cv_c_bigendian=yes
  else
***************
*** 5287,5293 ****
      { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
  else
    cat > conftest.$ac_ext <<EOF
! #line 5291 "configure"
  #include "confdefs.h"
  main () {
    /* Are we little or big endian?  From Harbison&Steele.  */
--- 5845,5851 ----
      { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
  else
    cat > conftest.$ac_ext <<EOF
! #line 5849 "configure"
  #include "confdefs.h"
  main () {
    /* Are we little or big endian?  From Harbison&Steele.  */
***************
*** 5300,5306 ****
    exit (u.c[sizeof (long) - 1] == 1);
  }
  EOF
! if { (eval echo configure:5304: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
  then
    ac_cv_c_bigendian=no
  else
--- 5858,5864 ----
    exit (u.c[sizeof (long) - 1] == 1);
  }
  EOF
! if { (eval echo configure:5862: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
  then
    ac_cv_c_bigendian=no
  else
***************
*** 5326,5332 ****
  
  # Check for --with-wctype-functions
  echo $ac_n "checking for --with-wctype-functions""... $ac_c" 1>&6
! echo "configure:5330: checking for --with-wctype-functions" >&5
  # Check whether --with-wctype-functions or --without-wctype-functions was given.
  if test "${with_wctype_functions+set}" = set; then
    withval="$with_wctype_functions"
--- 5884,5890 ----
  
  # Check for --with-wctype-functions
  echo $ac_n "checking for --with-wctype-functions""... $ac_c" 1>&6
! echo "configure:5888: checking for --with-wctype-functions" >&5
  # Check whether --with-wctype-functions or --without-wctype-functions was given.
  if test "${with_wctype_functions+set}" = set; then
    withval="$with_wctype_functions"
Index: python/configure.in
diff -c python/configure.in:1.1.1.3 python/configure.in:1.11
*** python/configure.in:1.1.1.3	Mon Aug 14 21:50:02 2000
--- python/configure.in	Tue Aug 15 11:40:39 2000
***************
*** 342,347 ****
--- 342,494 ----
    fi
  fi
  
+ # Check for enable-ipv6
+ OPT="$OPT -Dss_family=__ss_family -Dss_len=__ss_len"
+ 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 */
+ #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
+ ))
+ 
+ ipv6type=unknown
+ ipv6lib=none
+ ipv6trylibc=no
+ 
+ if test "$ipv6" = "yes"; then
+ 	AC_MSG_CHECKING([ipv6 stack type])
+ 	for i in inria kame linux-glibc linux-inet6 toshiba v6d zeta; do
+ 		case $i in
+ 		inria)
+ 			dnl http://www.kame.net/
+ 			AC_EGREP_CPP(yes, [dnl
+ #include <netinet/in.h>
+ #ifdef IPV6_INRIA_VERSION
+ yes
+ #endif],
+ 				[ipv6type=$i;
+ 				OPT="-DINET6 $OPT"])
+ 			;;
+ 		kame)
+ 			dnl http://www.kame.net/
+ 			AC_EGREP_CPP(yes, [dnl
+ #include <netinet/in.h>
+ #ifdef __KAME__
+ yes
+ #endif],
+ 				[ipv6type=$i;
+ 				ipv6lib=inet6
+ 				ipv6libdir=/usr/local/v6/lib
+ 				ipv6trylibc=yes
+ 				OPT="-DINET6 $OPT"])
+ 			;;
+ 		linux-glibc)
+ 			dnl http://www.v6.linux.or.jp/
+ 			AC_EGREP_CPP(yes, [dnl
+ #include <features.h>
+ #if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2))
+ yes
+ #endif],
+ 				[ipv6type=$i;
+ 				ipv6lib=
+ 				ipv6libdir=
+ 				ipv6trylibc=yes
+ 				OPT="-DINET6 $OPT"])
+ 			;;
+ 		linux-inet6)
+ 			dnl http://www.v6.linux.or.jp/
+ 			if test -d /usr/inet6; then
+ 				ipv6type=$i
+ 				ipv6lib=inet6
+ 				ipv6libdir=/usr/inet6/lib
+ 				OPT="-DINET6 -I/usr/inet6/include $OPT"
+ 			fi
+ 			;;
+ 		toshiba)
+ 			AC_EGREP_CPP(yes, [dnl
+ #include <sys/param.h>
+ #ifdef _TOSHIBA_INET6
+ yes
+ #endif],
+ 				[ipv6type=$i;
+ 				ipv6lib=inet6;
+ 				ipv6libdir=/usr/local/v6/lib;
+ 				OPT="-DINET6 $OPT"])
+ 			;;
+ 		v6d)
+ 			AC_EGREP_CPP(yes, [dnl
+ #include </usr/local/v6/include/sys/v6config.h>
+ #ifdef __V6D__
+ yes
+ #endif],
+ 				[ipv6type=$i;
+ 				ipv6lib=v6;
+ 				ipv6libdir=/usr/local/v6/lib;
+ 				OPT="-I/usr/local/v6/include $OPT"])
+ 			;;
+ 		zeta)
+ 			AC_EGREP_CPP(yes, [dnl
+ #include <sys/param.h>
+ #ifdef _ZETA_MINAMI_INET6
+ yes
+ #endif],
+ 				[ipv6type=$i;
+ 				ipv6lib=inet6;
+ 				ipv6libdir=/usr/local/v6/lib;
+ 				OPT="-DINET6 $OPT"])
+ 			;;
+ 		esac
+ 		if test "$ipv6type" != "unknown"; then
+ 			break
+ 		fi
+ 	done
+ 	AC_MSG_RESULT($ipv6type)
+ fi
+ 
+ if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
+ 	if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
+ 		LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
+ 		echo "using lib$ipv6lib"
+ 	else
+ 		if test $ipv6trylibc = "yes"; then
+ 			echo "using libc"
+ 		else
+ 			echo 'Fatal: no $ipv6lib library found.  cannot continue.'
+ 			echo "You need to fetch lib$ipv6lib.a from appropriate"
+ 			echo 'ipv6 kit and compile beforehand.'
+ 			exit 1
+ 		fi
+ 	fi
+ fi
+ 
  # check for ANSI or K&R ("traditional") preprocessor
  AC_MSG_CHECKING(for C preprocessor type)
  AC_TRY_COMPILE([
***************
*** 775,780 ****
--- 922,1031 ----
  AC_CHECK_FUNC(setpgrp, AC_TRY_COMPILE([#include <unistd.h>], [setpgrp(0,0);], AC_DEFINE(SETPGRP_HAVE_ARG)))
  AC_CHECK_FUNC(gettimeofday, AC_TRY_COMPILE([#include <sys/time.h>], [gettimeofday((struct timeval*)0,(struct timezone*)0);], ,AC_DEFINE(GETTIMEOFDAY_NO_TZ)))
  
+ AC_CHECK_FUNCS(getaddrinfo, [dnl
+ 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)
+ buggygetaddrinfo=no,
+ AC_MSG_RESULT(buggy)
+ buggygetaddrinfo=yes,
+ AC_MSG_RESULT(buggy)
+ buggygetaddrinfo=yes)], [buggygetaddrinfo=yes])
+ 
+ if test "$buggygetaddrinfo" = "yes"; then
+ 	if test "$ipv6" = "yes"; then
+ 		echo 'Fatal: You must get working getaddrinfo() function.'
+ 		echo '       or you can specify "--disable-ipv6"'.
+ 		exit 1
+ 	fi
+ fi
+ AC_CHECK_FUNCS(getaddrinfo getnameinfo)
+ 
  # checks for structures
  AC_HEADER_TIME
  AC_STRUCT_TM
***************
*** 799,804 ****
--- 1050,1080 ----
  ], [;], [AC_DEFINE(SYS_SELECT_WITH_SYS_TIME) was_it_defined=yes])
  AC_MSG_RESULT($was_it_defined)
  
+ AC_MSG_CHECKING(for addrinfo)
+ AC_CACHE_VAL(ac_cv_struct_addrinfo,
+ AC_TRY_COMPILE([
+ #		include <netdb.h>],
+ 	[struct addrinfo a],
+ 	ac_cv_struct_addrinfo=yes,
+ 	ac_cv_struct_addrinfo=no))
+ AC_MSG_RESULT($ac_cv_struct_addrinfo)
+ if test $ac_cv_struct_addrinfo = yes; then
+ 	AC_DEFINE(HAVE_ADDRINFO)
+ fi
+ 
+ AC_MSG_CHECKING(for sockaddr_storage)
+ AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
+ AC_TRY_COMPILE([
+ #		include <sys/types.h>
+ #		include <sys/socket.h>],
+ 	[struct sockaddr_storage s],
+ 	ac_cv_struct_sockaddr_storage=yes,
+ 	ac_cv_struct_sockaddr_storage=no))
+ AC_MSG_RESULT($ac_cv_struct_sockaddr_storage)
+ if test $ac_cv_struct_sockaddr_storage = yes; then
+ 	AC_DEFINE(HAVE_SOCKADDR_STORAGE)
+ fi
+ 
  # checks for compiler characteristics
  
  AC_C_CHAR_UNSIGNED
***************
*** 1042,1047 ****
--- 1318,1333 ----
  then
    AC_DEFINE(MALLOC_ZERO_RETURNS_NULL)
  fi
+ 
+ # 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 for wchar.h
  AC_CHECK_HEADER(wchar.h,
Index: python/Demo/sockets/finger.py
diff -c python/Demo/sockets/finger.py:1.1.1.1 python/Demo/sockets/finger.py:1.2
*** python/Demo/sockets/finger.py:1.1.1.1	Tue Apr 13 19:01:42 1999
--- python/Demo/sockets/finger.py	Tue Aug 15 11:40:44 2000
***************
*** 23,29 ****
  #
  def finger(host, args):
  	s = socket(AF_INET, SOCK_STREAM)
! 	s.connect(host, FINGER_PORT)
  	s.send(args + '\n')
  	while 1:
  		buf = s.recv(1024)
--- 23,29 ----
  #
  def finger(host, args):
  	s = socket(AF_INET, SOCK_STREAM)
! 	s.connect((host, FINGER_PORT))
  	s.send(args + '\n')
  	while 1:
  		buf = s.recv(1024)
Index: python/Demo/sockets/ftp.py
diff -c python/Demo/sockets/ftp.py:1.1.1.1 python/Demo/sockets/ftp.py:1.2
*** python/Demo/sockets/ftp.py:1.1.1.1	Tue Apr 13 19:01:42 1999
--- python/Demo/sockets/ftp.py	Tue Aug 15 11:40:44 2000
***************
*** 48,54 ****
  	# Create control connection
  	#
  	s = socket(AF_INET, SOCK_STREAM)
! 	s.connect(hostname, FTP_PORT)
  	f = s.makefile('r') # Reading the replies is easier from a file...
  	#
  	# Control loop
--- 48,54 ----
  	# Create control connection
  	#
  	s = socket(AF_INET, SOCK_STREAM)
! 	s.connect((hostname, FTP_PORT))
  	f = s.makefile('r') # Reading the replies is easier from a file...
  	#
  	# Control loop
***************
*** 79,85 ****
  	port = nextport + FTP_DATA_PORT
  	nextport = (nextport+1) % 16
  	r = socket(AF_INET, SOCK_STREAM)
! 	r.bind(gethostbyname(gethostname()), port)
  	r.listen(1)
  	sendportcmd(s, f, port)
  	return r
--- 79,85 ----
  	port = nextport + FTP_DATA_PORT
  	nextport = (nextport+1) % 16
  	r = socket(AF_INET, SOCK_STREAM)
! 	r.bind((gethostbyname(gethostname()), port))
  	r.listen(1)
  	sendportcmd(s, f, port)
  	return r
Index: python/Demo/sockets/telnet.py
diff -c python/Demo/sockets/telnet.py:1.1.1.1 python/Demo/sockets/telnet.py:1.2
*** python/Demo/sockets/telnet.py:1.1.1.1	Tue Apr 13 19:01:42 1999
--- python/Demo/sockets/telnet.py	Tue Aug 15 11:40:44 2000
***************
*** 51,57 ****
  	s = socket(AF_INET, SOCK_STREAM)
  	#
  	try:
! 		s.connect(host, port)
  	except error, msg:
  		sys.stderr.write('connect failed: ' + `msg` + '\n')
  		sys.exit(1)
--- 51,57 ----
  	s = socket(AF_INET, SOCK_STREAM)
  	#
  	try:
! 		s.connect((host, port))
  	except error, msg:
  		sys.stderr.write('connect failed: ' + `msg` + '\n')
  		sys.exit(1)
Index: python/Demo/sockets/throughput.py
diff -c python/Demo/sockets/throughput.py:1.1.1.1 python/Demo/sockets/throughput.py:1.2
*** python/Demo/sockets/throughput.py:1.1.1.1	Tue Apr 13 19:01:42 1999
--- python/Demo/sockets/throughput.py	Tue Aug 15 11:40:44 2000
***************
*** 72,78 ****
  	t1 = time.time()
  	s = socket(AF_INET, SOCK_STREAM)
  	t2 = time.time()
! 	s.connect(host, port)
  	t3 = time.time()
  	i = 0
  	while i < count:
--- 72,78 ----
  	t1 = time.time()
  	s = socket(AF_INET, SOCK_STREAM)
  	t2 = time.time()
! 	s.connect((host, port))
  	t3 = time.time()
  	i = 0
  	while i < count:
Index: python/Include/addrinfo.h
diff -c /dev/null python/Include/addrinfo.h:1.7
*** /dev/null	Tue Aug 15 11:44:34 2000
--- python/Include/addrinfo.h	Thu Feb 10 10:07:57 2000
***************
*** 0 ****
--- 1,140 ----
+ /*
+  * 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()
+  */
+ #ifndef EAI_ADDRFAMILY
+ #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
+ #endif
+ 
+ /*
+  * Flag values for getaddrinfo()
+  */
+ #ifndef AI_PASSIVE
+ #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)
+ #endif
+ 
+ /*
+  * Constants for getnameinfo()
+  */
+ #ifndef NI_MAXHOST
+ #define	NI_MAXHOST	1025
+ #define	NI_MAXSERV	32
+ #endif
+ 
+ /*
+  * Flag values for getnameinfo()
+  */
+ #ifndef NI_NOFQDN
+ #define	NI_NOFQDN	0x00000001
+ #define	NI_NUMERICHOST	0x00000002
+ #define	NI_NAMEREQD	0x00000004
+ #define	NI_NUMERICSERV	0x00000008
+ #define	NI_DGRAM	0x00000010
+ #endif
+ 
+ #ifndef HAVE_ADDRINFO
+ 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 */
+ };
+ #endif
+ 
+ #ifndef HAVE_SOCKADDR_STORAGE
+ /*
+  * RFC 2553: protocol-independent placeholder for socket addresses
+  */
+ #define _SS_MAXSIZE	128
+ #ifdef HAVE_LONG_LONG
+ #define _SS_ALIGNSIZE	(sizeof(long long))
+ #else
+ #define _SS_ALIGNSIZE	(sizeof(double))
+ #endif
+ #define _SS_PAD1SIZE	(_SS_ALIGNSIZE - sizeof(u_char) * 2)
+ #define _SS_PAD2SIZE	(_SS_MAXSIZE - sizeof(u_char) * 2 - \
+ 				_SS_PAD1SIZE - _SS_ALIGNSIZE)
+ 
+ struct sockaddr_storage {
+ #ifdef HAVE_SOCKADDR_SA_LEN
+ 	unsigned char ss_len;		/* address length */
+ 	unsigned char ss_family;	/* address family */
+ #else
+ 	unsigned short ss_family;	/* address family */
+ #endif
+ 	char	__ss_pad1[_SS_PAD1SIZE];
+ #ifdef HAVE_LONG_LONG
+ 	long long __ss_align;	/* force desired structure storage alignment */
+ #else
+ 	double __ss_align;	/* force desired structure storage alignment */
+ #endif
+ 	char	__ss_pad2[_SS_PAD2SIZE];
+ };
+ #endif
+ 
+ #ifdef __cplusplus
+ extern "C" {
+ #endif
+ extern void freehostent Py_PROTO((struct hostent *));
+ #ifdef __cplusplus
+ }
+ #endif
+ #endif
Index: python/Lib/BaseHTTPServer.py
diff -c python/Lib/BaseHTTPServer.py:1.1.1.3 python/Lib/BaseHTTPServer.py:1.5
*** python/Lib/BaseHTTPServer.py:1.1.1.3	Mon Aug 14 21:53:44 2000
--- python/Lib/BaseHTTPServer.py	Tue Aug 15 11:40:52 2000
***************
*** 66,75 ****
  
  import sys
  import time
! import socket # For gethostbyaddr()
  import string
  import mimetools
  import SocketServer
  
  # Default error message
  DEFAULT_ERROR_MESSAGE = """\
--- 66,76 ----
  
  import sys
  import time
! import socket
  import string
  import mimetools
  import SocketServer
+ import re
  
  # Default error message
  DEFAULT_ERROR_MESSAGE = """\
***************
*** 92,112 ****
      def server_bind(self):
          """Override server_bind to store the server name."""
          SocketServer.TCPServer.server_bind(self)
!         host, port = self.socket.getsockname()
!         if not host or host == '0.0.0.0':
!             host = socket.gethostname()
!         try:
!             hostname, hostnames, hostaddrs = socket.gethostbyaddr(host)
!         except socket.error:
!             hostname = host
!         else:
!             if '.' not in hostname:
!                 for host in hostnames:
!                     if '.' in host:
!                         hostname = host
!                         break
!         self.server_name = hostname
!         self.server_port = port
  
  
  class BaseHTTPRequestHandler(SocketServer.StreamRequestHandler):
--- 93,106 ----
      def server_bind(self):
          """Override server_bind to store the server name."""
          SocketServer.TCPServer.server_bind(self)
!         sa = self.socket.getsockname()
! 	host = socket.gethostname()
!         hostname, portname = socket.getnameinfo(sa, socket.NI_NUMERICSERV)
! 	if re.compile('^\d+\.\d+\.\d+\.\d+$').match(hostname):
! 	    hostname = host
! 	if re.compile('^[0-9a-fA-f:]+$').match(hostname):
! 	    hostname = host
!         self.server_port = portname
  
  
  class BaseHTTPRequestHandler(SocketServer.StreamRequestHandler):
***************
*** 411,432 ****
                   'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
  
      def address_string(self):
!         """Return the client address formatted for logging.
! 
!         This version looks up the full hostname using gethostbyaddr(),
!         and tries to find a name that contains at least one dot.
! 
!         """
  
-         (host, port) = self.client_address
          try:
!             name, names, addresses = socket.gethostbyaddr(host)
          except socket.error, msg:
!             return host
!         names.insert(0, name)
!         for name in names:
!             if '.' in name: return name
!         return names[0]
  
  
      # Essentially static class variables
--- 405,417 ----
                   'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
  
      def address_string(self):
!         """Return the client address formatted for logging."""
  
          try:
! 	    n = socket.getnameinfo(self.client_address, socket.NI_NUMERICSERV)
          except socket.error, msg:
! 	    return self.client_address[0]
! 	return n[0]
  
  
      # Essentially static class variables
***************
*** 494,500 ****
  
      httpd = ServerClass(server_address, HandlerClass)
  
!     print "Serving HTTP on port", port, "..."
      httpd.serve_forever()
  
  
--- 479,486 ----
  
      httpd = ServerClass(server_address, HandlerClass)
  
!     sa = httpd.socket.getsockname()
!     print "Serving HTTP on", sa[0], "port", sa[1], "..."
      httpd.serve_forever()
  
  
Index: python/Lib/SocketServer.py
diff -c python/Lib/SocketServer.py:1.1.1.3 python/Lib/SocketServer.py:1.4
*** python/Lib/SocketServer.py:1.1.1.3	Mon Aug 14 21:53:47 2000
--- python/Lib/SocketServer.py	Tue Aug 15 11:40:52 2000
***************
*** 3,9 ****
  This module tries to capture the various aspects of defining a server:
  
  - address family:
!         - AF_INET: IP (Internet Protocol) sockets (default)
          - AF_UNIX: Unix domain sockets
          - others, e.g. AF_DECNET are conceivable (see <socket.h>
  - socket type:
--- 3,9 ----
  This module tries to capture the various aspects of defining a server:
  
  - address family:
!         - AF_INET{,6}: IP (Internet Protocol) sockets (default)
          - AF_UNIX: Unix domain sockets
          - others, e.g. AF_DECNET are conceivable (see <socket.h>
  - socket type:
Index: python/Lib/ftplib.py
diff -c python/Lib/ftplib.py:1.1.1.3 python/Lib/ftplib.py:1.6
*** python/Lib/ftplib.py:1.1.1.3	Mon Aug 14 21:54:08 2000
--- python/Lib/ftplib.py	Tue Aug 15 11:40:53 2000
***************
*** 102,107 ****
--- 102,108 ----
  		self.sock = None
  		self.file = None
  		self.welcome = None
+ 		self.af = None
  		resp = None
  		if host:
  			resp = self.connect(host)
***************
*** 114,125 ****
  		if host: self.host = host
  		if port: self.port = port
  		self.passiveserver = 0
! 		self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
! 		self.sock.connect((self.host, self.port))
  		self.file = self.sock.makefile('rb')
  		self.welcome = self.getresp()
  		return self.welcome
  
  	def getwelcome(self):
  		'''Get the welcome message from the server.
  		(this is read and squirreled away by connect())'''
--- 115,138 ----
  		if host: self.host = host
  		if port: self.port = port
  		self.passiveserver = 0
! 		for res in socket.getaddrinfo(self.host, self.port, 0, socket.SOCK_STREAM):
! 			af, socktype, proto, canonname, sa = res
! 			try:
! 				self.sock = socket.socket(af, socktype, proto)
! 				self.sock.connect(sa)
! 			except socket.error, msg:
! 				self.sock.close()
! 				self.sock = None
! 				continue
! 			break
! 		if not self.sock:
! 			raise socket.error, msg
! 		self.af = af
  		self.file = self.sock.makefile('rb')
  		self.welcome = self.getresp()
  		return self.welcome
  
+ 
  	def getwelcome(self):
  		'''Get the welcome message from the server.
  		(this is read and squirreled away by connect())'''
***************
*** 241,257 ****
  		cmd = 'PORT ' + string.joinfields(bytes, ',')
  		return self.voidcmd(cmd)
  
  	def makeport(self):
  		'''Create a new socket and send a PORT command for it.'''
  		global nextport
! 		sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
! 		sock.bind(('', 0))
  		sock.listen(1)
! 		dummyhost, port = sock.getsockname() # Get proper port
! 		host, dummyport = self.sock.getsockname() # Get proper host
! 		resp = self.sendport(host, port)
  		return sock
  
  	def ntransfercmd(self, cmd):
  		'''Initiate a transfer over the data connection.
  		If the transfer is active, send a port command and
--- 254,304 ----
  		cmd = 'PORT ' + string.joinfields(bytes, ',')
  		return self.voidcmd(cmd)
  
+ 	def sendeprt(self, host, port):
+ 		'''Send a EPRT command with the current host and the given port number.'''
+ 		af = 0
+ 		if self.af == socket.AF_INET:
+ 			af = 1
+ 		if self.af == socket.AF_INET6:
+ 			af = 2
+ 		if af == 0:
+ 			raise error_proto, 'unsupported address family'
+ 		fields = ['', `af`, host, `port`, '']
+ 		cmd = 'EPRT ' + string.joinfields(fields, '|')
+ 		return self.voidcmd(cmd)
+ 
  	def makeport(self):
  		'''Create a new socket and send a PORT command for it.'''
  		global nextport
! 		for res in socket.getaddrinfo(None, 0, self.af, socket.SOCK_STREAM, 0, socket.AI_PASSIVE):
! 			af, socktype, proto, canonname, sa = res
! 			try:
! 				sock = socket.socket(af, socktype, proto)
! 				sock.bind(sa)
! 			except socket.error, msg:
! 				sock.close()
! 				sock = None
! 				continue
! 			break
! 		if not sock:
! 			raise socket.error, msg
  		sock.listen(1)
! 		port = sock.getsockname()[1] # Get proper port
! 		host = self.sock.getsockname()[0] # Get proper host
! 		if self.af == socket.AF_INET:
! 			resp = self.sendport(host, port)
! 		else:
! 			resp = self.sendeprt(host, port)
  		return sock
  
+ 
+ 	def makepasv(self):
+ 		if self.af == socket.AF_INET:
+ 			host, port = parse227(self.sendcmd('PASV'))
+ 		else:
+ 			host, port = parse229(self.sendcmd('EPSV'), self.sock.getpeername())
+ 		return host, port
+ 
  	def ntransfercmd(self, cmd):
  		'''Initiate a transfer over the data connection.
  		If the transfer is active, send a port command and
***************
*** 263,271 ****
  		may be None if it could not be determined.'''
  		size = None
  		if self.passiveserver:
! 			host, port = parse227(self.sendcmd('PASV'))
! 			conn = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
! 			conn.connect((host, port))
  			resp = self.sendcmd(cmd)
  			if resp[0] <> '1':
  				raise error_reply, resp
--- 310,319 ----
  		may be None if it could not be determined.'''
  		size = None
  		if self.passiveserver:
! 			host, port = self.makepasv()
! 			af, socktype, proto, canon, sa = socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM)[0]
! 			conn = socket.socket(af, socktype, proto)
! 			conn.connect(sa)
  			resp = self.sendcmd(cmd)
  			if resp[0] <> '1':
  				raise error_reply, resp
***************
*** 293,298 ****
--- 341,347 ----
  		if user == 'anonymous' and passwd in ('', '-'):
  			thishost = socket.gethostname()
  			# Make sure it is fully qualified
+ 			# XXX IPv4 only
  			if not '.' in thishost:
  				thisaddr = socket.gethostbyname(thishost)
  				firstname, names, unused = \
***************
*** 513,518 ****
--- 562,589 ----
  		raise error_proto, resp
  	host = string.join(numbers[:4], '.')
  	port = (string.atoi(numbers[4]) << 8) + string.atoi(numbers[5])
+ 	return host, port
+ 
+ 
+ def parse229(resp, peer):
+ 	'''Parse the '229' response for a EPSV request.
+ 	Raises error_proto if it does not contain '(|||port|)'
+ 	Return ('host.addr.as.numbers', port#) tuple.'''
+ 
+ 	if resp[:3] <> '229':
+ 		raise error_reply, resp
+ 	left = string.find(resp, '(')
+ 	if left < 0: raise error_proto, resp
+ 	right = string.find(resp, ')', left + 1)
+ 	if right < 0:
+ 		raise error_proto, resp	# should contain '(|||port|)'
+ 	if resp[left + 1] <> resp[right - 1]:
+ 		raise error_proto, resp
+ 	parts = string.split(resp[left + 1:right], resp[left+1])
+ 	if len(parts) <> 5:
+ 		raise error_proto, resp
+ 	host = peer[0]
+ 	port = string.atoi(parts[3])
  	return host, port
  
  
Index: python/Lib/httplib.py
diff -c python/Lib/httplib.py:1.1.1.2 python/Lib/httplib.py:1.5
*** python/Lib/httplib.py:1.1.1.2	Mon Aug 14 21:54:12 2000
--- python/Lib/httplib.py	Tue Aug 15 11:40:53 2000
***************
*** 94,116 ****
  
      def connect(self, host, port = 0):
          """Connect to a host on a given port.
! 
          Note:  This method is automatically invoked by __init__,
          if a host is specified during instantiation.
  
          """
!         if not port:
!             i = string.find(host, ':')
!             if i >= 0:
!                 host, port = host[:i], host[i+1:]
!                 try: port = string.atoi(port)
!                 except string.atoi_error:
!                     raise socket.error, "nonnumeric port"
          if not port: port = HTTP_PORT
!         self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
!         if self.debuglevel > 0: print 'connect:', (host, port)
!         self.sock.connect((host, port))
! 
      def send(self, str):
          """Send `str' to the server."""
          if self.debuglevel > 0: print 'send:', `str`
--- 94,139 ----
  
      def connect(self, host, port = 0):
          """Connect to a host on a given port.
! 	Variable 'host' accepts the following forms:
! 	    [host]:port
! 	    host:port		but there has to be only single colon
! 	    host
!         
          Note:  This method is automatically invoked by __init__,
          if a host is specified during instantiation.
  
          """
! 	if host[0] == '[' and string.rfind(host, ']:') != 0:
! 	    i = string.rfind(host, ']:')
! 	    host, port = host[1:i], host[i + 2:]
! 	    try: port = string.atoi(port)
! 	    except string.atoi_error:
! 		raise socket.error, "nonnumeric port"
! 	else:
! 	    if not port and (string.find(host, ':') == string.rfind(host, ':')):
! 		i = string.rfind(host, ':')
! 		if i >= 0:
! 		    host, port = host[:i], host[i+1:]
! 		    try: port = string.atoi(port)
! 		    except string.atoi_error:
! 			raise socket.error, "nonnumeric port"
          if not port: port = HTTP_PORT
! 	if self.debuglevel > 0: print 'connect:', (host, port)
! 	for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM):
! 	    af, socktype, proto, canonname, sa = res
! 	    try:
! 		self.sock = socket.socket(af, socktype, proto)
! 		if self.debuglevel > 0: print 'connect:', (host, port)
! 		self.sock.connect(sa)
! 	    except socket.error, msg:
! 		if self.debuglevel > 0: print 'connect fail:', (host, port)
! 		self.sock.close()
! 		self.sock = None
! 		continue
! 	    break
!         if not self.sock:
! 	    raise socket.error, msg
!     
      def send(self, str):
          """Send `str' to the server."""
          if self.debuglevel > 0: print 'send:', `str`
Index: python/Lib/poplib.py
diff -c python/Lib/poplib.py:1.1.1.3 python/Lib/poplib.py:1.4
*** python/Lib/poplib.py:1.1.1.3	Mon Aug 14 21:54:32 2000
--- python/Lib/poplib.py	Tue Aug 15 11:40:54 2000
***************
*** 76,83 ****
  	def __init__(self, host, port = POP3_PORT):
  		self.host = host
  		self.port = port
! 		self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
! 		self.sock.connect((self.host, self.port))
  		self.file = self.sock.makefile('rb')
  		self._debugging = 0
  		self.welcome = self._getresp()
--- 76,93 ----
  	def __init__(self, host, port = POP3_PORT):
  		self.host = host
  		self.port = port
! 		for res in socket.getaddrinfo(self.host, self.port, 0, socket.SOCK_STREAM):
! 			af, socktype, proto, canonname, sa = res
! 			try:
! 				self.sock = socket.socket(af, socktype, proto)
! 				self.sock.connect(sa)
! 			except socket.error, msg:
! 				self.sock.close()
! 				self.sock = None
! 				continue
! 			break
! 		if not self.sock:
! 			raise socket.error, msg
  		self.file = self.sock.makefile('rb')
  		self._debugging = 0
  		self.welcome = self._getresp()
Index: python/Lib/smtplib.py
diff -c python/Lib/smtplib.py:1.1.1.3 python/Lib/smtplib.py:1.5
*** python/Lib/smtplib.py:1.1.1.3	Mon Aug 14 21:54:49 2000
--- python/Lib/smtplib.py	Tue Aug 15 11:40:54 2000
***************
*** 203,219 ****
          specified during instantiation.
  
          """
!         if not port:
!             i = string.find(host, ':')
              if i >= 0:
                  host, port = host[:i], host[i+1:]
                  try: port = string.atoi(port)
                  except string.atoi_error:
                      raise socket.error, "nonnumeric port"
          if not port: port = SMTP_PORT
!         self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
!         if self.debuglevel > 0: print 'connect:', (host, port)
!         self.sock.connect((host, port))
          (code,msg)=self.getreply()
          if self.debuglevel >0 : print "connect:", msg
          return (code,msg)
--- 203,231 ----
          specified during instantiation.
  
          """
! 	if not port and (string.find(host, ':') == string.rfind(host, ':')):
!             i = string.rfind(host, ':')
              if i >= 0:
                  host, port = host[:i], host[i+1:]
                  try: port = string.atoi(port)
                  except string.atoi_error:
                      raise socket.error, "nonnumeric port"
          if not port: port = SMTP_PORT
! 	if self.debuglevel > 0: print 'connect:', (host, port)
! 	for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM):
! 	    af, socktype, proto, canonname, sa = res
! 	    try:
! 		self.sock = socket.socket(af, socktype, proto)
! 		if self.debuglevel > 0: print 'connect:', (host, port)
! 		self.sock.connect(sa)
! 	    except socket.error, msg:
! 		if self.debuglevel > 0: print 'connect fail:', (host, port)
! 		self.sock.close()
! 		self.sock = None
! 		continue
! 	    break
!         if not self.sock:
! 	    raise socket.error, msg
          (code,msg)=self.getreply()
          if self.debuglevel >0 : print "connect:", msg
          return (code,msg)
***************
*** 290,300 ****
          """
          name=string.strip(name)
          if len(name)==0:
!             name = socket.gethostname()
!             try:
!                 name = socket.gethostbyaddr(name)[0]
!             except socket.error:
!                 pass
          self.putcmd("helo",name)
          (code,msg)=self.getreply()
          self.helo_resp=msg
--- 302,308 ----
          """
          name=string.strip(name)
          if len(name)==0:
! 	    name=socket.getnameinfo((socket.gethostname(), 0), socket.NI_NUMERICSERV)[0]
          self.putcmd("helo",name)
          (code,msg)=self.getreply()
          self.helo_resp=msg
Index: python/Lib/telnetlib.py
diff -c python/Lib/telnetlib.py:1.1.1.3 python/Lib/telnetlib.py:1.4
*** python/Lib/telnetlib.py:1.1.1.3	Mon Aug 14 21:54:58 2000
--- python/Lib/telnetlib.py	Tue Aug 15 11:40:54 2000
***************
*** 135,142 ****
              port = TELNET_PORT
          self.host = host
          self.port = port
!         self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
!         self.sock.connect((self.host, self.port))
  
      def __del__(self):
          """Destructor -- close the connection."""
--- 135,152 ----
              port = TELNET_PORT
          self.host = host
          self.port = port
! 	for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM):
! 	    af, socktype, proto, canonname, sa = res
! 	    try:
! 		self.sock = socket.socket(af, socktype, proto)
! 		self.sock.connect(sa)
! 	    except socket.error, msg:
! 		self.sock.close()
! 		self.sock = None
! 		continue
! 	    break
!         if not self.sock:
! 	    raise socket.error, msg
  
      def __del__(self):
          """Destructor -- close the connection."""
Index: python/Modules/socketmodule.c
diff -c python/Modules/socketmodule.c:1.1.1.3 python/Modules/socketmodule.c:1.17
*** python/Modules/socketmodule.c:1.1.1.3	Mon Aug 14 22:00:43 2000
--- python/Modules/socketmodule.c	Tue Aug 15 11:41:01 2000
***************
*** 7,13 ****
  
  Limitations:
  
! - only AF_INET and AF_UNIX address families are supported
  - no read/write operations (use send/recv or makefile instead)
  - additional restrictions apply on Windows
  
--- 7,13 ----
  
  Limitations:
  
! - only AF_INET, AF_INET6 and AF_UNIX address families are supported
  - no read/write operations (use send/recv or makefile instead)
  - additional restrictions apply on Windows
  
***************
*** 15,20 ****
--- 15,21 ----
  
  - socket.error: exception raised for socket specific errors
  - socket.gethostbyname(hostname) --> host IP address (string: 'dd.dd.dd.dd')
+ - socket.gethostbyname2(hostname, af) --> host IP address (string)
  - socket.gethostbyaddr(IP address) --> (hostname, [alias, ...], [IP addr, ...])
  - socket.gethostname() --> host name (string: 'spam' or 'spam.domain.com')
  - socket.getprotobyname(protocolname) --> protocol number
***************
*** 24,29 ****
--- 25,33 ----
  - socket.ntohl(32 bit value) --> new int object
  - socket.htons(16 bit value) --> new int object
  - socket.htonl(32 bit value) --> new int object
+ - socket.getaddrinfo(host, port [, family, socktype, proto, flags])
+ 	--> List of (family, socktype, proto, canonname, sockaddr)
+ - socket.getnameinfo(sockaddr, flags) --> (host, port)
  - socket.AF_INET, socket.SOCK_STREAM, etc.: constants from <socket.h>
  - socket.inet_aton(IP address) -> 32-bit packed IP representation
  - socket.inet_ntoa(packed IP) -> IP address string
***************
*** 146,151 ****
--- 150,159 ----
  #undef AF_UNIX
  #endif
  
+ #ifndef offsetof
+ #define	offsetof(type, member)	((size_t)(&((type *)0)->member))
+ #endif
+ 
  #ifndef O_NDELAY
  #define O_NDELAY O_NONBLOCK	/* For QNX only? */
  #endif
***************
*** 155,160 ****
--- 163,170 ----
  #include <GUSI.h>
  #endif
  
+ #include "addrinfo.h"
+ 
  #ifdef USE_SSL
  #include "rsa.h"
  #include "crypto.h"
***************
*** 164,169 ****
--- 174,187 ----
  #include "err.h"
  #endif /* USE_SSL */
  
+ /* I know this is a bad practice, but it is the easiest... */
+ #ifndef HAVE_GETADDRINFO
+ #include "Python/getaddrinfo.c"
+ #endif
+ #ifndef HAVE_GETNAMEINFO
+ #include "Python/getnameinfo.c"
+ #endif
+ 
  #if defined(MS_WINDOWS) || defined(__BEOS__)
  /* BeOS suffers from the same socket dichotomy as Win32... - [cjh] */
  /* seem to be a few differences in the API */
***************
*** 347,352 ****
--- 365,374 ----
  #ifdef AF_UNIX
  		struct sockaddr_un un;
  #endif
+ #ifdef INET6
+ 		struct sockaddr_in6 in6;
+ #endif
+ 		struct sockaddr_storage storage;
  	} sock_addr;
  } PySocketSockObject;
  
***************
*** 412,496 ****
  /* Convert a string specifying a host name or one of a few symbolic
     names to a numeric IP address.  This usually calls gethostbyname()
     to do the work; the names "" and "<broadcast>" are special.
!    Return the length (should always be 4 bytes), or negative if
     an error occurred; then an exception is raised. */
  
  static int
! setipaddr(char* name, struct sockaddr_in * addr_ret)
  {
! 	struct hostent *hp;
! 	int d1, d2, d3, d4;
! 	int h_length;
! 	char ch;
! #ifdef HAVE_GETHOSTBYNAME_R
! 	struct hostent hp_allocated;
! #ifdef HAVE_GETHOSTBYNAME_R_3_ARG
! 	struct hostent_data data;
! #else
! 	char buf[1001];
! 	int buf_len = (sizeof buf) - 1;
! 	int errnop;
! #endif
! #if defined(HAVE_GETHOSTBYNAME_R_3_ARG) || defined(HAVE_GETHOSTBYNAME_R_6_ARG)
! 	int result;
! #endif
! #endif /* HAVE_GETHOSTBYNAME_R */
  
  	memset((void *) addr_ret, '\0', sizeof(*addr_ret));
  	if (name[0] == '\0') {
! 		addr_ret->sin_addr.s_addr = INADDR_ANY;
! 		return 4;
  	}
  	if (name[0] == '<' && strcmp(name, "<broadcast>") == 0) {
! 		addr_ret->sin_addr.s_addr = INADDR_BROADCAST;
! 		return 4;
  	}
! 	if (sscanf(name, "%d.%d.%d.%d%c", &d1, &d2, &d3, &d4, &ch) == 4 &&
! 	    0 <= d1 && d1 <= 255 && 0 <= d2 && d2 <= 255 &&
! 	    0 <= d3 && d3 <= 255 && 0 <= d4 && d4 <= 255) {
! 		addr_ret->sin_addr.s_addr = htonl(
! 			((long) d1 << 24) | ((long) d2 << 16) |
! 			((long) d3 << 8) | ((long) d4 << 0));
  		return 4;
! 	}
! 	Py_BEGIN_ALLOW_THREADS
! #ifdef HAVE_GETHOSTBYNAME_R
! #if    defined(HAVE_GETHOSTBYNAME_R_6_ARG)
! 	result = gethostbyname_r(name, &hp_allocated, buf, buf_len, &hp, &errnop);
! #elif  defined(HAVE_GETHOSTBYNAME_R_5_ARG)
! 	hp = gethostbyname_r(name, &hp_allocated, buf, buf_len, &errnop);
! #else  /* HAVE_GETHOSTBYNAME_R_3_ARG */
! 	memset((void *) &data, '\0', sizeof(data));
! 	result = gethostbyname_r(name, &hp_allocated, &data);
! 	hp = (result != 0) ? NULL : &hp_allocated;
! #endif
! #else /* not HAVE_GETHOSTBYNAME_R */
! #ifdef USE_GETHOSTBYNAME_LOCK
! 	PyThread_acquire_lock(gethostbyname_lock, 1);
  #endif
! 	hp = gethostbyname(name);
! #endif /* HAVE_GETHOSTBYNAME_R */
! 	Py_END_ALLOW_THREADS
! 
! 	if (hp == NULL) {
! #ifdef HAVE_HSTRERROR
! 	        /* Let's get real error message to return */
! 	        extern int h_errno;
! 		PyErr_SetString(PySocket_Error, (char *)hstrerror(h_errno));
! #else
! 		PyErr_SetString(PySocket_Error, "host not found");
! #endif
! #ifdef USE_GETHOSTBYNAME_LOCK
! 		PyThread_release_lock(gethostbyname_lock);
! #endif
  		return -1;
  	}
- 	memcpy((char *) &addr_ret->sin_addr, hp->h_addr, hp->h_length);
- 	h_length = hp->h_length;
- #ifdef USE_GETHOSTBYNAME_LOCK
- 	PyThread_release_lock(gethostbyname_lock);
- #endif
- 	return h_length;
  }
  
  
--- 434,519 ----
  /* Convert a string specifying a host name or one of a few symbolic
     names to a numeric IP address.  This usually calls gethostbyname()
     to do the work; the names "" and "<broadcast>" are special.
!    Return the length (IPv4 should be 4 bytes), or negative if
     an error occurred; then an exception is raised. */
  
  static int
! setipaddr(char* name, struct sockaddr * addr_ret, int af)
  {
! 	struct addrinfo hints, *res;
! 	int error;
  
  	memset((void *) addr_ret, '\0', sizeof(*addr_ret));
  	if (name[0] == '\0') {
! 		int siz;
! 		memset(&hints, 0, sizeof(hints));
! 		hints.ai_family = af;
! 		hints.ai_flags = AI_PASSIVE;
! 		error = getaddrinfo(NULL, "0", &hints, &res);
! 		if (error) {
! 			PyErr_SetString(PySocket_Error, gai_strerror(error));
! 			return -1;
! 		}
! 		switch (res->ai_family) {
! 		case AF_INET:
! 			siz = 4;
! 			break;
! #ifdef INET6
! 		case AF_INET6:
! 			siz = 16;
! 			break;
! #endif
! 		default:
! 			freeaddrinfo(res);
! 			PyErr_SetString(PySocket_Error,
! 				"unsupported address family");
! 			return -1;
! 		}
! 		if (res->ai_next) {
! 			PyErr_SetString(PySocket_Error,
! 				"wildcard resolved to multiple address");
! 			return -1;
! 		}
! 		memcpy(addr_ret, res->ai_addr, res->ai_addrlen);
! 		freeaddrinfo(res);
! 		return siz;
  	}
  	if (name[0] == '<' && strcmp(name, "<broadcast>") == 0) {
! 		struct sockaddr_in *sin;
! 		if (af != PF_INET && af != PF_UNSPEC) {
! 			PyErr_SetString(PySocket_Error,
! 				"address family mismatched");
! 			return -1;
! 		}
! 		sin = (struct sockaddr_in *)addr_ret;
! 		memset((void *) sin, '\0', sizeof(*sin));
! 		sin->sin_family = AF_INET;
! #ifdef HAVE_SOCKADDR_SA_LEN
! 		sin->sin_len = sizeof(*sin);
! #endif
! 		sin->sin_addr.s_addr = INADDR_BROADCAST;
! 		return sizeof(sin->sin_addr);
! 	}
! 	memset(&hints, 0, sizeof(hints));
! 	hints.ai_family = af;
! 	error = getaddrinfo(name, NULL, &hints, &res);
! 	if (error) {
! 		PyErr_SetString(PySocket_Error, gai_strerror(error));
! 		return -1;
  	}
! 	memcpy((char *) addr_ret, res->ai_addr, res->ai_addrlen);
! 	freeaddrinfo(res);
! 	switch (addr_ret->sa_family) {
! 	case AF_INET:
  		return 4;
! #ifdef INET6
! 	case AF_INET6:
! 		return 16;
  #endif
! 	default:
! 		PyErr_SetString(PySocket_Error, "unknown address family");
  		return -1;
  	}
  }
  
  
***************
*** 499,511 ****
     size numbers). */
  
  static PyObject *
! makeipaddr(struct sockaddr_in *addr)
  {
! 	long x = ntohl(addr->sin_addr.s_addr);
! 	char buf[100];
! 	sprintf(buf, "%d.%d.%d.%d",
! 		(int) (x>>24) & 0xff, (int) (x>>16) & 0xff,
! 		(int) (x>> 8) & 0xff, (int) (x>> 0) & 0xff);
  	return PyString_FromString(buf);
  }
  
--- 522,538 ----
     size numbers). */
  
  static PyObject *
! makeipaddr(struct sockaddr *addr, int addrlen)
  {
! 	char buf[NI_MAXHOST];
! 	int error;
! 
! 	error = getnameinfo(addr, addrlen, buf, sizeof(buf), NULL, 0,
! 		NI_NUMERICHOST);
! 	if (error) {
! 		PyErr_SetString(PySocket_Error, gai_strerror(error));
! 		return NULL;
! 	}
  	return PyString_FromString(buf);
  }
  
***************
*** 534,543 ****
  
  	case AF_INET:
  	{
! 		struct sockaddr_in *a = (struct sockaddr_in *) addr;
! 		PyObject *addrobj = makeipaddr(a);
  		PyObject *ret = NULL;
  		if (addrobj) {
  			ret = Py_BuildValue("Oi", addrobj, ntohs(a->sin_port));
  			Py_DECREF(addrobj);
  		}
--- 561,571 ----
  
  	case AF_INET:
  	{
! 		struct sockaddr_in *a;
! 		PyObject *addrobj = makeipaddr(addr, sizeof(*a));
  		PyObject *ret = NULL;
  		if (addrobj) {
+ 			a = (struct sockaddr_in *)addr;
  			ret = Py_BuildValue("Oi", addrobj, ntohs(a->sin_port));
  			Py_DECREF(addrobj);
  		}
***************
*** 552,557 ****
--- 580,601 ----
  	}
  #endif /* AF_UNIX */
  
+ #ifdef INET6
+ 	case AF_INET6:
+ 	{
+ 		struct sockaddr_in6 *a;
+ 		PyObject *addrobj = makeipaddr(addr, sizeof(*a));
+ 		PyObject *ret = NULL;
+ 		if (addrobj) {
+ 			a = (struct sockaddr_in6 *)addr;
+ 			ret = Py_BuildValue("Oiii", addrobj, ntohs(a->sin6_port),
+ 				a->sin6_flowinfo, a->sin6_scope_id);
+ 			Py_DECREF(addrobj);
+ 		}
+ 		return ret;
+ 	}
+ #endif
+ 
  	/* More cases here... */
  
  	default:
***************
*** 590,596 ****
  					"AF_UNIX path too long");
  			return 0;
  		}
! 		addr->sun_family = AF_UNIX;
  		memcpy(addr->sun_path, path, len);
  		addr->sun_path[len] = 0;
  		*addr_ret = (struct sockaddr *) addr;
--- 634,640 ----
  					"AF_UNIX path too long");
  			return 0;
  		}
! 		addr->sun_family = s->sock_family;
  		memcpy(addr->sun_path, path, len);
  		addr->sun_path[len] = 0;
  		*addr_ret = (struct sockaddr *) addr;
***************
*** 604,621 ****
  		struct sockaddr_in* addr;
  		char *host;
  		int port;
!  		addr=(struct sockaddr_in*)&(s->sock_addr).in;
  		if (!PyArg_Parse(args, "(si)", &host, &port))
  			return 0;
! 		if (setipaddr(host, addr) < 0)
  			return 0;
! 		addr->sin_family = AF_INET;
  		addr->sin_port = htons((short)port);
  		*addr_ret = (struct sockaddr *) addr;
  		*len_ret = sizeof *addr;
  		return 1;
  	}
  
  	/* More cases here... */
  
  	default:
--- 648,689 ----
  		struct sockaddr_in* addr;
  		char *host;
  		int port;
!  		addr = (struct sockaddr_in*)&(s->sock_addr).in;
  		if (!PyArg_Parse(args, "(si)", &host, &port))
  			return 0;
! 		if (setipaddr(host, (struct sockaddr *)addr, AF_INET) < 0)
  			return 0;
! 		addr->sin_family = s->sock_family;
  		addr->sin_port = htons((short)port);
  		*addr_ret = (struct sockaddr *) addr;
  		*len_ret = sizeof *addr;
  		return 1;
  	}
  
+ #ifdef INET6
+ 	case AF_INET6:
+ 	{
+ 		struct sockaddr_in6* addr;
+ 		char *host;
+ 		int port, flowinfo, scope_id;
+  		addr = (struct sockaddr_in6*)&(s->sock_addr).in6;
+ 		flowinfo = scope_id = 0;
+ 		if (!PyArg_ParseTuple(args, "si|ii", &host, &port, &flowinfo,
+ 				&scope_id)) {
+ 			return 0;
+ 		}
+ 		if (setipaddr(host, (struct sockaddr *)addr, AF_INET6) < 0)
+ 			return 0;
+ 		addr->sin6_family = s->sock_family;
+ 		addr->sin6_port = htons((short)port);
+ 		addr->sin6_flowinfo = flowinfo;
+ 		addr->sin6_scope_id = scope_id;
+ 		*addr_ret = (struct sockaddr *) addr;
+ 		*len_ret = sizeof *addr;
+ 		return 1;
+ 	}
+ #endif
+ 
  	/* More cases here... */
  
  	default:
***************
*** 649,654 ****
--- 717,730 ----
  		return 1;
  	}
  
+ #ifdef INET6
+ 	case AF_INET6:
+ 	{
+ 		*len_ret = sizeof (struct sockaddr_in6);
+ 		return 1;
+ 	}
+ #endif
+ 
  	/* More cases here... */
  
  	default:
***************
*** 1469,1474 ****
--- 1545,1596 ----
  Return the current host name.";
  
  
+ /* Python interface to gethostbyname2(name, af). */
+ 
+ /*ARGSUSED*/
+ static PyObject *
+ PySocket_gethostbyname2_common(char *name, int af)
+ {
+ 	struct sockaddr_storage addrbuf;
+ 
+ 	if (setipaddr(name, (struct sockaddr *)&addrbuf, af) < 0)
+ 		return NULL;
+ 	switch (addrbuf.ss_family) {
+ 	case AF_INET:
+ 		return makeipaddr((struct sockaddr *)&addrbuf,
+ 			sizeof(struct sockaddr_in));
+ #ifdef INET6
+ 	case AF_INET6:
+ 		return makeipaddr((struct sockaddr *)&addrbuf,
+ 			sizeof(struct sockaddr_in6));
+ #endif
+ 	case AF_UNIX:
+ 		return makeipaddr((struct sockaddr *)&addrbuf,
+ 			sizeof(struct sockaddr_un));
+ 	default:
+ 		return makeipaddr((struct sockaddr *)&addrbuf,
+ 			sizeof(struct sockaddr));
+ 	}
+ }
+ 
+ /*ARGSUSED*/
+ static PyObject *
+ PySocket_gethostbyname2(PyObject *self, PyObject *args)
+ {
+ 	char *name;
+ 	int af;
+ 
+ 	if (!PyArg_ParseTuple(args, "si:gethostbyname2", &name, &af))
+ 		return NULL;
+ 	return PySocket_gethostbyname2_common(name, af);
+ }
+ 
+ static char gethostbyname2_doc[] =
+ "gethostbyname2(host, af) -> address\n\
+ \n\
+ Return the IP address (a string) for a host.";
+ 
+ 
  /* Python interface to gethostbyname(name). */
  
  /*ARGSUSED*/
***************
*** 1476,1487 ****
  PySocket_gethostbyname(PyObject *self, PyObject *args)
  {
  	char *name;
! 	struct sockaddr_in addrbuf;
  	if (!PyArg_ParseTuple(args, "s:gethostbyname", &name))
- 		return NULL;
- 	if (setipaddr(name, &addrbuf) < 0)
  		return NULL;
! 	return makeipaddr(&addrbuf);
  }
  
  static char gethostbyname_doc[] =
--- 1598,1607 ----
  PySocket_gethostbyname(PyObject *self, PyObject *args)
  {
  	char *name;
! 
  	if (!PyArg_ParseTuple(args, "s:gethostbyname", &name))
  		return NULL;
! 	return PySocket_gethostbyname2_common(name, AF_INET);
  }
  
  static char gethostbyname_doc[] =
***************
*** 1493,1505 ****
  /* Convenience function common to gethostbyname_ex and gethostbyaddr */
  
  static PyObject *
! gethost_common(struct hostent *h, struct sockaddr_in *addr)
  {
  	char **pch;
  	PyObject *rtn_tuple = (PyObject *)NULL;
  	PyObject *name_list = (PyObject *)NULL;
  	PyObject *addr_list = (PyObject *)NULL;
  	PyObject *tmp;
  	if (h == NULL) {
  #ifdef HAVE_HSTRERROR
  	        /* Let's get real error message to return */
--- 1613,1626 ----
  /* Convenience function common to gethostbyname_ex and gethostbyaddr */
  
  static PyObject *
! gethost_common(struct hostent *h, struct sockaddr *addr, int alen, int af)
  {
  	char **pch;
  	PyObject *rtn_tuple = (PyObject *)NULL;
  	PyObject *name_list = (PyObject *)NULL;
  	PyObject *addr_list = (PyObject *)NULL;
  	PyObject *tmp;
+ 
  	if (h == NULL) {
  #ifdef HAVE_HSTRERROR
  	        /* Let's get real error message to return */
***************
*** 1510,1515 ****
--- 1631,1658 ----
  #endif
  		return NULL;
  	}
+ 	if (h->h_addrtype != af) {
+ #ifdef HAVE_STRERROR
+ 	        /* Let's get real error message to return */
+ 		PyErr_SetString(PySocket_Error, (char *)strerror(EAFNOSUPPORT));
+ #else
+ 		PyErr_SetString(PySocket_Error,
+ 		    "Address family not supported by protocol family");
+ #endif
+ 		return NULL;
+ 	}
+ 	switch (af) {
+ 	case AF_INET:
+ 		if (alen < sizeof(struct sockaddr_in))
+ 			return NULL;
+ 		break;
+ #ifdef INET6
+ 	case AF_INET6:
+ 		if (alen < sizeof(struct sockaddr_in6))
+ 			return NULL;
+ 		break;
+ #endif
+ 	}
  	if ((name_list = PyList_New(0)) == NULL)
  		goto err;
  	if ((addr_list = PyList_New(0)) == NULL)
***************
*** 1526,1533 ****
  	}
  	for (pch = h->h_addr_list; *pch != NULL; pch++) {
  		int status;
! 		memcpy((char *) &addr->sin_addr, *pch, h->h_length);
! 		tmp = makeipaddr(addr);
  		if (tmp == NULL)
  			goto err;
  		status = PyList_Append(addr_list, tmp);
--- 1669,1711 ----
  	}
  	for (pch = h->h_addr_list; *pch != NULL; pch++) {
  		int status;
! 		switch (af) {
! 		case AF_INET:
! 		    {
! 			struct sockaddr_in sin;
! 			memset(&sin, 0, sizeof(sin));
! 			sin.sin_family = af;
! #ifdef HAVE_SOCKADDR_SA_LEN
! 			sin.sin_len = sizeof(sin);
! #endif
! 			memcpy(&sin.sin_addr, *pch, sizeof(sin.sin_addr));
! 			tmp = makeipaddr((struct sockaddr *)&sin, sizeof(sin));
! 			if (pch == h->h_addr_list && alen >= sizeof(sin))
! 				memcpy((char *) addr, &sin, sizeof(sin));
! 			break;
! 		    }
! #ifdef INET6
! 		case AF_INET6:
! 		    {
! 			struct sockaddr_in6 sin6;
! 			memset(&sin6, 0, sizeof(sin6));
! 			sin6.sin6_family = af;
! #ifdef HAVE_SOCKADDR_SA_LEN
! 			sin6.sin6_len = sizeof(sin6);
! #endif
! 			memcpy(&sin6.sin6_addr, *pch, sizeof(sin6.sin6_addr));
! 			tmp = makeipaddr((struct sockaddr *)&sin6,
! 				sizeof(sin6));
! 			if (pch == h->h_addr_list && alen >= sizeof(sin6))
! 				memcpy((char *) addr, &sin6, sizeof(sin6));
! 			break;
! 		    }
! #endif
! 		default:	/* can't happen */
! 			PyErr_SetString(PySocket_Error,
! 				"unsupported address family");
! 			return NULL;
! 		}
  		if (tmp == NULL)
  			goto err;
  		status = PyList_Append(addr_list, tmp);
***************
*** 1551,1557 ****
  {
  	char *name;
  	struct hostent *h;
! 	struct sockaddr_in addr;
  	PyObject *ret;
  #ifdef HAVE_GETHOSTBYNAME_R
  	struct hostent hp_allocated;
--- 1729,1735 ----
  {
  	char *name;
  	struct hostent *h;
! 	struct sockaddr_storage addr;
  	PyObject *ret;
  #ifdef HAVE_GETHOSTBYNAME_R
  	struct hostent hp_allocated;
***************
*** 1566,1574 ****
  	int result;
  #endif
  #endif /* HAVE_GETHOSTBYNAME_R */
  	if (!PyArg_ParseTuple(args, "s:gethostbyname_ex", &name))
  		return NULL;
! 	if (setipaddr(name, &addr) < 0)
  		return NULL;
  	Py_BEGIN_ALLOW_THREADS
  #ifdef HAVE_GETHOSTBYNAME_R
--- 1744,1758 ----
  	int result;
  #endif
  #endif /* HAVE_GETHOSTBYNAME_R */
+ #ifdef INET6
+ 	int af = PF_UNSPEC;
+ #else
+ 	int af = PF_INET;
+ #endif
+ 
  	if (!PyArg_ParseTuple(args, "s:gethostbyname_ex", &name))
  		return NULL;
! 	if (setipaddr(name, (struct sockaddr *)&addr, af) < 0)
  		return NULL;
  	Py_BEGIN_ALLOW_THREADS
  #ifdef HAVE_GETHOSTBYNAME_R
***************
*** 1588,1594 ****
  	h = gethostbyname(name);
  #endif /* HAVE_GETHOSTBYNAME_R */
  	Py_END_ALLOW_THREADS
! 	ret = gethost_common(h, &addr);
  #ifdef USE_GETHOSTBYNAME_LOCK
  	PyThread_release_lock(gethostbyname_lock);
  #endif
--- 1772,1778 ----
  	h = gethostbyname(name);
  #endif /* HAVE_GETHOSTBYNAME_R */
  	Py_END_ALLOW_THREADS
! 	ret = gethost_common(h, (struct sockaddr *)&addr, sizeof(addr), addr.ss_family);
  #ifdef USE_GETHOSTBYNAME_LOCK
  	PyThread_release_lock(gethostbyname_lock);
  #endif
***************
*** 1608,1614 ****
  static PyObject *
  PySocket_gethostbyaddr(PyObject *self, PyObject *args)
  {
!         struct sockaddr_in addr;
  	char *ip_num;
  	struct hostent *h;
  	PyObject *ret;
--- 1792,1798 ----
  static PyObject *
  PySocket_gethostbyaddr(PyObject *self, PyObject *args)
  {
!         struct sockaddr_storage addr;
  	char *ip_num;
  	struct hostent *h;
  	PyObject *ret;
***************
*** 1625,1664 ****
  	int result;
  #endif
  #endif /* HAVE_GETHOSTBYNAME_R */
! 
! 	if (!PyArg_ParseTuple(args, "s:gethostbyaddr", &ip_num))
! 		return NULL;
! 	if (setipaddr(ip_num, &addr) < 0)
  		return NULL;
  	Py_BEGIN_ALLOW_THREADS
  #ifdef HAVE_GETHOSTBYNAME_R
  #if   defined(HAVE_GETHOSTBYNAME_R_6_ARG)
! 	result = gethostbyaddr_r((char *)&addr.sin_addr,
! 		sizeof(addr.sin_addr),
! 		AF_INET, &hp_allocated, buf, buf_len,
  		&h, &errnop);
  #elif defined(HAVE_GETHOSTBYNAME_R_5_ARG)
! 	h = gethostbyaddr_r((char *)&addr.sin_addr,
! 			    sizeof(addr.sin_addr),
! 			    AF_INET, 
  			    &hp_allocated, buf, buf_len, &errnop);
  #else /* HAVE_GETHOSTBYNAME_R_3_ARG */
  	memset((void *) &data, '\0', sizeof(data));
! 	result = gethostbyaddr_r((char *)&addr.sin_addr,
! 		sizeof(addr.sin_addr),
! 		AF_INET, &hp_allocated, &data);
  	h = (result != 0) ? NULL : &hp_allocated;
  #endif
  #else /* not HAVE_GETHOSTBYNAME_R */
  #ifdef USE_GETHOSTBYNAME_LOCK
  	PyThread_acquire_lock(gethostbyname_lock, 1);
  #endif
! 	h = gethostbyaddr((char *)&addr.sin_addr,
! 			  sizeof(addr.sin_addr),
! 			  AF_INET);
  #endif /* HAVE_GETHOSTBYNAME_R */
  	Py_END_ALLOW_THREADS
! 	ret = gethost_common(h, &addr);
  #ifdef USE_GETHOSTBYNAME_LOCK
  	PyThread_release_lock(gethostbyname_lock);
  #endif
--- 1809,1863 ----
  	int result;
  #endif
  #endif /* HAVE_GETHOSTBYNAME_R */
! 	char *ap;
! 	int al;
! 	int af;
! 
! 	if (!PyArg_Parse(args, "s:gethostbyaddr", &ip_num))
! 		return NULL;
! 	af = PF_UNSPEC;
! 	if (setipaddr(ip_num, (struct sockaddr *)&addr, af) < 0)
! 		return NULL;
! 	af = addr.ss_family;
! 	ap = NULL;
! 	al = 0;
! 	switch (af) {
! 	case AF_INET:
! 		ap = (char *)&((struct sockaddr_in *)&addr)->sin_addr;
! 		al = sizeof(((struct sockaddr_in *)&addr)->sin_addr);
! 		break;
! #ifdef INET6
! 	case AF_INET6:
! 		ap = (char *)&((struct sockaddr_in6 *)&addr)->sin6_addr;
! 		al = sizeof(((struct sockaddr_in6 *)&addr)->sin6_addr);
! 		break;
! #endif
! 	default:
! 		PyErr_SetString(PySocket_Error, "unsupported address family");
  		return NULL;
+ 	}
  	Py_BEGIN_ALLOW_THREADS
  #ifdef HAVE_GETHOSTBYNAME_R
  #if   defined(HAVE_GETHOSTBYNAME_R_6_ARG)
! 	result = gethostbyaddr_r(ap, al, af,
! 		&hp_allocated, buf, buf_len,
  		&h, &errnop);
  #elif defined(HAVE_GETHOSTBYNAME_R_5_ARG)
! 	h = gethostbyaddr_r(ap, al, af,
  			    &hp_allocated, buf, buf_len, &errnop);
  #else /* HAVE_GETHOSTBYNAME_R_3_ARG */
  	memset((void *) &data, '\0', sizeof(data));
! 	result = gethostbyaddr_r(ap, al, af, &hp_allocated, &data);
  	h = (result != 0) ? NULL : &hp_allocated;
  #endif
  #else /* not HAVE_GETHOSTBYNAME_R */
  #ifdef USE_GETHOSTBYNAME_LOCK
  	PyThread_acquire_lock(gethostbyname_lock, 1);
  #endif
! 	h = gethostbyaddr(ap, al, af);
  #endif /* HAVE_GETHOSTBYNAME_R */
  	Py_END_ALLOW_THREADS
! 	ret = gethost_common(h, (struct sockaddr *)&addr, sizeof(addr), af);
  #ifdef USE_GETHOSTBYNAME_LOCK
  	PyThread_release_lock(gethostbyname_lock);
  #endif
***************
*** 1958,1964 ****
--- 2157,2312 ----
  	return PyString_FromString(inet_ntoa(packed_addr));
  }
  
+ /* Python interface to getaddrinfo(host, port). */
+ 
+ /*ARGSUSED*/
+ static PyObject *
+ PySocket_getaddrinfo(PyObject *self, PyObject *args)
+ {
+ 	struct addrinfo hints, *res0, *res;
+ 	PyObject *pobj = (PyObject *)NULL;
+ 	char pbuf[10];
+ 	char *hptr, *pptr;
+ 	int family, socktype, protocol, flags;
+ 	int error;
+ 	PyObject *all = (PyObject *)NULL;
+ 	PyObject *single = (PyObject *)NULL;
+ 
+ 	family = socktype = protocol = flags = 0;
+ 	family = PF_UNSPEC;
+ 	if (!PyArg_ParseTuple(args, "zO|iiii", &hptr, &pobj, &family, &socktype,
+ 			&protocol, &flags)) {
+ 		return NULL;
+ 	}
+ 	if (PyInt_Check(pobj)) {
+ 		snprintf(pbuf, sizeof(pbuf), "%ld", PyInt_AsLong(pobj));
+ 		pptr = pbuf;
+ 	} else if (PyString_Check(pobj)) {
+ 		pptr = PyString_AsString(pobj);
+ 	} else if (pobj == Py_None) {
+ 		pptr = (char *)NULL;
+ 	} else {
+ 		PyErr_SetString(PySocket_Error, "Int or String expected");
+ 		return NULL;
+ 	}
+ 	memset(&hints, 0, sizeof(hints));
+ 	hints.ai_family = family;
+ 	hints.ai_socktype = socktype;
+ 	hints.ai_protocol = protocol;
+ 	hints.ai_flags = flags;
+ 	error = getaddrinfo(hptr, pptr, &hints, &res0);
+ 	if (error) {
+ 		PyErr_SetString(PySocket_Error, gai_strerror(error));
+ 		return NULL;
+ 	}
+ 
+ 	if ((all = PyList_New(0)) == NULL)
+ 		goto err;
+ 	for (res = res0; res; res = res->ai_next) {
+ 		single = Py_BuildValue("iiisO", res->ai_family,
+ 			res->ai_socktype, res->ai_protocol,
+ 			res->ai_canonname ? res->ai_canonname : "",
+ 			makesockaddr(res->ai_addr, res->ai_addrlen));
+ 		if (single == NULL)
+ 			goto err;
+ 
+ 		if (PyList_Append(all, single))
+ 			goto err;
+ 		Py_XDECREF(single);
+ 	}
+ 	Py_XDECREF(pobj);
+ 	return all;
+  err:
+ 	Py_XDECREF(single);
+ 	Py_XDECREF(all);
+ 	Py_XDECREF(pobj);
+ 	return (PyObject *)NULL;
+ }
+ 
+ static char getaddrinfo_doc[] =
+ "socket.getaddrinfo(host, port [, family, socktype, proto, flags])\n\
+ 	--> List of (family, socktype, proto, canonname, sockaddr)\n\
+ \n\
+ Resolve host and port into addrinfo struct.";
+ 
+ /* Python interface to getnameinfo(sa, flags). */
  
+ /*ARGSUSED*/
+ static PyObject *
+ PySocket_getnameinfo(PyObject *self, PyObject *args)
+ {
+ 	PyObject *sa = (PyObject *)NULL;
+ 	int flags;
+ 	char *hostp;
+ 	int n, port, flowinfo, scope_id;
+ 	char hbuf[NI_MAXHOST], pbuf[NI_MAXSERV];
+ 	struct addrinfo hints, *res = NULL;
+ 	int error;
+ 	PyObject *ret = (PyObject *)NULL;
+ 
+ 	flags = flowinfo = scope_id = 0;
+ 	if (PyArg_ParseTuple(args, "Oi", &sa, &flags) == 0)
+ 		return NULL;
+ 	n = PyArg_ParseTuple(sa, "si|ii", &hostp, &port, &flowinfo, scope_id);
+ 	if (n == 0)
+ 		goto fail;
+ 	snprintf(pbuf, sizeof(pbuf), "%d", port);
+ 	memset(&hints, 0, sizeof(hints));
+ 	hints.ai_family = PF_UNSPEC;
+ 	error = getaddrinfo(hostp, pbuf, &hints, &res);
+ 	if (error) {
+ 		PyErr_SetString(PySocket_Error, gai_strerror(error));
+ 		goto fail;
+ 	}
+ 	if (res->ai_next) {
+ 		PyErr_SetString(PySocket_Error,
+ 			"sockaddr resolved to multiple addresses");
+ 		goto fail;
+ 	}
+ 	switch (res->ai_family) {
+ 	case AF_INET:
+ 	    {
+ 		char *t1;
+ 		int t2;
+ 		if (PyArg_ParseTuple(sa, "si", &t1, &t2) == 0) {
+ 			PyErr_SetString(PySocket_Error,
+ 				"IPv4 sockaddr must be 2 tuple");
+ 			goto fail;
+ 		}
+ 		break;
+ 	    }
+ #ifdef INET6
+ 	case AF_INET6:
+ 	    {
+ 		struct sockaddr_in6 *sin6;
+ 		sin6 = (struct sockaddr_in6 *)res->ai_addr;
+ 		sin6->sin6_flowinfo = flowinfo;
+ 		sin6->sin6_scope_id = scope_id;
+ 		break;
+ 	    }
+ #endif
+ 	}
+ 	error = getnameinfo(res->ai_addr, res->ai_addrlen,
+ 			hbuf, sizeof(hbuf), pbuf, sizeof(pbuf), flags);
+ 	if (error) {
+ 		PyErr_SetString(PySocket_Error, gai_strerror(error));
+ 		goto fail;
+ 	}
+ 	ret = Py_BuildValue("ss", hbuf, pbuf);
+ 
+ fail:
+ 	if (res)
+ 		freeaddrinfo(res);
+ 	Py_XDECREF(sa);
+ 	return ret;
+ }
+ 
+ static char getnameinfo_doc[] =
+ "socket.getnameinfo(sockaddr, flags) --> (host, port)\n\
+ \n\
+ Get host and port for a sockaddr.";
+ 
+ 
  #ifdef USE_SSL
  
  /* This is a C function to be called for new object initialization */
***************
*** 2191,2196 ****
--- 2539,2546 ----
  static PyMethodDef PySocket_methods[] = {
  	{"gethostbyname",	PySocket_gethostbyname, 
  	 METH_VARARGS, gethostbyname_doc},
+ 	{"gethostbyname2",	PySocket_gethostbyname2, 
+ 	 METH_VARARGS, gethostbyname2_doc},
  	{"gethostbyname_ex",	PySocket_gethostbyname_ex, 
  	 METH_VARARGS, ghbn_ex_doc},
  	{"gethostbyaddr",	PySocket_gethostbyaddr, 
***************
*** 2219,2224 ****
--- 2569,2578 ----
  	 METH_VARARGS, inet_aton_doc},
  	{"inet_ntoa",		PySocket_inet_ntoa, 
  	 METH_VARARGS, inet_ntoa_doc},
+ 	{"getaddrinfo",		PySocket_getaddrinfo,
+ 	 METH_VARARGS, getaddrinfo_doc},
+ 	{"getnameinfo",		PySocket_getnameinfo,
+ 	 METH_VARARGS, getnameinfo_doc},
  #ifdef USE_SSL
  	{"ssl",			PySocket_ssl, 
  	 METH_VARARGS, ssl_doc},
***************
*** 2447,2452 ****
--- 2801,2809 ----
  	insint(d, "AF_UNSPEC", AF_UNSPEC);
  #endif
  	insint(d, "AF_INET", AF_INET);
+ #ifdef AF_INET6
+ 	insint(d, "AF_INET6", AF_INET6);
+ #endif /* AF_INET6 */
  #ifdef AF_UNIX
  	insint(d, "AF_UNIX", AF_UNIX);
  #endif /* AF_UNIX */
***************
*** 2789,2794 ****
--- 3146,3243 ----
  	/* IPX options */
  #ifdef	IPX_TYPE
  	insint(d, "IPX_TYPE", IPX_TYPE);
+ #endif
+ 
+ 	/* get{addr,name}info parameters */
+ #ifdef EAI_ADDRFAMILY
+ 	insint(d, "EAI_ADDRFAMILY", EAI_ADDRFAMILY);
+ #endif
+ #ifdef EAI_AGAIN
+ 	insint(d, "EAI_AGAIN", EAI_AGAIN);
+ #endif
+ #ifdef EAI_BADFLAGS
+ 	insint(d, "EAI_BADFLAGS", EAI_BADFLAGS);
+ #endif
+ #ifdef EAI_FAIL
+ 	insint(d, "EAI_FAIL", EAI_FAIL);
+ #endif
+ #ifdef EAI_FAMILY
+ 	insint(d, "EAI_FAMILY", EAI_FAMILY);
+ #endif
+ #ifdef EAI_MEMORY
+ 	insint(d, "EAI_MEMORY", EAI_MEMORY);
+ #endif
+ #ifdef EAI_NODATA
+ 	insint(d, "EAI_NODATA", EAI_NODATA);
+ #endif
+ #ifdef EAI_NONAME
+ 	insint(d, "EAI_NONAME", EAI_NONAME);
+ #endif
+ #ifdef EAI_SERVICE
+ 	insint(d, "EAI_SERVICE", EAI_SERVICE);
+ #endif
+ #ifdef EAI_SOCKTYPE
+ 	insint(d, "EAI_SOCKTYPE", EAI_SOCKTYPE);
+ #endif
+ #ifdef EAI_SYSTEM
+ 	insint(d, "EAI_SYSTEM", EAI_SYSTEM);
+ #endif
+ #ifdef EAI_BADHINTS
+ 	insint(d, "EAI_BADHINTS", EAI_BADHINTS);
+ #endif
+ #ifdef EAI_PROTOCOL
+ 	insint(d, "EAI_PROTOCOL", EAI_PROTOCOL);
+ #endif
+ #ifdef EAI_MAX
+ 	insint(d, "EAI_MAX", EAI_MAX);
+ #endif
+ #ifdef AI_PASSIVE
+ 	insint(d, "AI_PASSIVE", AI_PASSIVE);
+ #endif
+ #ifdef AI_CANONNAME
+ 	insint(d, "AI_CANONNAME", AI_CANONNAME);
+ #endif
+ #ifdef AI_NUMERICHOST
+ 	insint(d, "AI_NUMERICHOST", AI_NUMERICHOST);
+ #endif
+ #ifdef AI_MASK
+ 	insint(d, "AI_MASK", AI_MASK);
+ #endif
+ #ifdef AI_ALL
+ 	insint(d, "AI_ALL", AI_ALL);
+ #endif
+ #ifdef AI_V4MAPPED_CFG
+ 	insint(d, "AI_V4MAPPED_CFG", AI_V4MAPPED_CFG);
+ #endif
+ #ifdef AI_ADDRCONFIG
+ 	insint(d, "AI_ADDRCONFIG", AI_ADDRCONFIG);
+ #endif
+ #ifdef AI_V4MAPPED
+ 	insint(d, "AI_V4MAPPED", AI_V4MAPPED);
+ #endif
+ #ifdef AI_DEFAULT
+ 	insint(d, "AI_DEFAULT", AI_DEFAULT);
+ #endif
+ #ifdef NI_MAXHOST
+ 	insint(d, "NI_MAXHOST", NI_MAXHOST);
+ #endif
+ #ifdef NI_MAXSERV
+ 	insint(d, "NI_MAXSERV", NI_MAXSERV);
+ #endif
+ #ifdef NI_NOFQDN
+ 	insint(d, "NI_NOFQDN", NI_NOFQDN);
+ #endif
+ #ifdef NI_NUMERICHOST
+ 	insint(d, "NI_NUMERICHOST", NI_NUMERICHOST);
+ #endif
+ #ifdef NI_NAMEREQD
+ 	insint(d, "NI_NAMEREQD", NI_NAMEREQD);
+ #endif
+ #ifdef NI_NUMERICSERV
+ 	insint(d, "NI_NUMERICSERV", NI_NUMERICSERV);
+ #endif
+ #ifdef NI_DGRAM
+ 	insint(d, "NI_DGRAM", NI_DGRAM);
  #endif
  
  	/* Initialize gethostbyname lock */
Index: python/Python/getaddrinfo.c
diff -c /dev/null python/Python/getaddrinfo.c:1.6
*** /dev/null	Tue Aug 15 11:44:41 2000
--- python/Python/getaddrinfo.c	Thu Feb 10 10:07:58 2000
***************
*** 0 ****
--- 1,625 ----
+ /*
+  * 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
+  * GAI_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 GAI_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 GAI_ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN GAI_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.
+  */
+ 
+ #if 0
+ #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"
+ #endif
+ 
+ #if defined(__KAME__) && defined(INET6)
+ # define FAITH
+ #endif
+ 
+ #define SUCCESS 0
+ #define GAI_ANY 0
+ #define YES 1
+ #define NO  0
+ 
+ #ifdef FAITH
+ static int translate = NO;
+ static struct in6_addr faith_prefix = IN6ADDR_GAI_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 gai_afd {
+ 	int a_af;
+ 	int a_addrlen;
+ 	int a_socklen;
+ 	int a_off;
+ 	const char *a_addrany;
+ 	const char *a_loopback;	
+ } gai_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 Py_PROTO((const char *, struct gai_afd *,
+ 			  struct addrinfo **, char *, struct addrinfo *,
+ 			  int));
+ static int get_addr Py_PROTO((const char *, int, struct addrinfo **,
+ 			struct addrinfo *, int));
+ static int str_isnumber Py_PROTO((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;\
+ 	}\
+ }
+ 
+ #ifdef HAVE_SOCKADDR_SA_LEN
+ #define GET_AI(ai, gai_afd, addr, port) {\
+ 	char *p;\
+ 	if (((ai) = (struct addrinfo *)malloc(sizeof(struct addrinfo) +\
+ 					      ((gai_afd)->a_socklen)))\
+ 	    == NULL) goto free;\
+ 	memcpy(ai, pai, sizeof(struct addrinfo));\
+ 	(ai)->ai_addr = (struct sockaddr *)((ai) + 1);\
+ 	memset((ai)->ai_addr, 0, (gai_afd)->a_socklen);\
+ 	(ai)->ai_addr->sa_len = (ai)->ai_addrlen = (gai_afd)->a_socklen;\
+ 	(ai)->ai_addr->sa_family = (ai)->ai_family = (gai_afd)->a_af;\
+ 	((struct sockinet *)(ai)->ai_addr)->si_port = port;\
+ 	p = (char *)((ai)->ai_addr);\
+ 	memcpy(p + (gai_afd)->a_off, (addr), (gai_afd)->a_addrlen);\
+ }
+ #else
+ #define GET_AI(ai, gai_afd, addr, port) {\
+ 	char *p;\
+ 	if (((ai) = (struct addrinfo *)malloc(sizeof(struct addrinfo) +\
+ 					      ((gai_afd)->a_socklen)))\
+ 	    == NULL) goto free;\
+ 	memcpy(ai, pai, sizeof(struct addrinfo));\
+ 	(ai)->ai_addr = (struct sockaddr *)((ai) + 1);\
+ 	memset((ai)->ai_addr, 0, (gai_afd)->a_socklen);\
+ 	(ai)->ai_addr->sa_family = (ai)->ai_family = (gai_afd)->a_af;\
+ 	((struct sockinet *)(ai)->ai_addr)->si_port = port;\
+ 	p = (char *)((ai)->ai_addr);\
+ 	memcpy(p + (gai_afd)->a_off, (addr), (gai_afd)->a_addrlen);\
+ }
+ #endif
+ 
+ #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 = GAI_ANY;
+ 	pai->ai_protocol = GAI_ANY;
+ 	pai->ai_addrlen = 0;
+ 	pai->ai_canonname = NULL;
+ 	pai->ai_addr = NULL;
+ 	pai->ai_next = NULL;
+ 	port = GAI_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 GAI_ANY:
+ 			switch (pai->ai_protocol) {
+ 			case GAI_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 != GAI_ANY)
+ 				ERR(EAI_BADHINTS);	/*xxx*/
+ 			pai->ai_protocol = IPPROTO_UDP;
+ 			break;
+ 		case SOCK_STREAM:
+ 			if (pai->ai_protocol != IPPROTO_TCP &&
+ 			    pai->ai_protocol != GAI_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 == GAI_ANY) {
+ 				/* caller accept *GAI_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 GAI_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 == GAI_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 gai_afd *gai_afd;
+ 
+ 		for (gai_afd = &gai_afdl[0]; gai_afd->a_af; gai_afd++) {
+ 			if (!(pai->ai_family == PF_UNSPEC
+ 			   || pai->ai_family == gai_afd->a_af)) {
+ 				continue;
+ 			}
+ 
+ 			if (pai->ai_flags & AI_PASSIVE) {
+ 				GET_AI(cur->ai_next, gai_afd, gai_afd->a_addrany, port);
+ 				/* xxx meaningless?
+ 				 * GET_CANONNAME(cur->ai_next, "anyaddr");
+ 				 */
+ 			} else {
+ 				GET_AI(cur->ai_next, gai_afd, gai_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; gai_afdl[i].a_af; i++) {
+ 		if (inet_pton(gai_afdl[i].a_af, hostname, pton)) {
+ 			u_long v4a;
+ 			u_char pfx;
+ 
+ 			switch (gai_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 == gai_afdl[i].a_af ||
+ 			    pai->ai_family == PF_UNSPEC) {
+ 				if (! (pai->ai_flags & AI_CANONNAME)) {
+ 					GET_AI(top, &gai_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, &gai_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, gai_afd, res, numaddr, pai, port0)
+ 	const char *addr;
+ 	struct gai_afd *gai_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, gai_afd->a_addrlen, gai_afd->a_af, &h_error);
+ #else
+ 	hp = gethostbyaddr(addr, gai_afd->a_addrlen, AF_INET);
+ #endif
+ 	if (hp && hp->h_name && hp->h_name[0] && hp->h_addr_list[0]) {
+ 		GET_AI(cur, gai_afd, hp->h_addr_list[0], port);
+ 		GET_CANONNAME(cur, hp->h_name);
+ 	} else
+ 		GET_AI(cur, gai_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 gai_afd *gai_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:
+ 			gai_afd = &gai_afdl[N_INET6];
+ 			break;
+ #endif
+ #ifndef INET6
+ 		default:	/* AF_UNSPEC */
+ #endif
+ 		case AF_INET:
+ 			gai_afd = &gai_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);
+ 				gai_afd = &gai_afdl[N_INET];
+ 			} else
+ 				gai_afd = &gai_afdl[N_INET6];
+ 			break;
+ #endif
+ 		}
+ #ifdef FAITH
+ 		if (translate && gai_afd->a_af == AF_INET) {
+ 			struct in6_addr *in6;
+ 
+ 			GET_AI(cur->ai_next, &gai_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, gai_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: python/Python/getnameinfo.c
diff -c /dev/null python/Python/getnameinfo.c:1.5
*** /dev/null	Tue Aug 15 11:44:41 2000
--- python/Python/getnameinfo.c	Thu Apr 22 20:30:18 1999
***************
*** 0 ****
--- 1,208 ----
+ /*
+  * 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().
+  */
+ 
+ #if 0
+ #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"
+ #endif
+ 
+ #define SUCCESS 0
+ #define YES 1
+ #define NO  0
+ 
+ static struct gni_afd {
+ 	int a_af;
+ 	int a_addrlen;
+ 	int a_socklen;
+ 	int a_off;
+ } gni_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 gni_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 gni_afd *gni_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;
+ 
+ #ifdef HAVE_SOCKADDR_SA_LEN
+ 	len = sa->sa_len;
+ 	if (len != salen) return ENI_SALEN;
+ #else
+ 	len = salen;
+ #endif
+ 	
+ 	family = sa->sa_family;
+ 	for (i = 0; gni_afdl[i].a_af; i++)
+ 		if (gni_afdl[i].a_af == family) {
+ 			gni_afd = &gni_afdl[i];
+ 			goto found;
+ 		}
+ 	return ENI_FAMILY;
+ 	
+  found:
+ 	if (len != gni_afd->a_socklen) return ENI_SALEN;
+ 	
+ 	port = ((struct gni_sockinet *)sa)->si_port; /* network byte order */
+ 	addr = (char *)sa + gni_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(gni_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, gni_afd->a_addrlen, gni_afd->a_af, &h_error);
+ #else
+ 		hp = gethostbyaddr(addr, gni_afd->a_addrlen, gni_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(gni_afd->a_af, addr, numaddr, sizeof(numaddr))
+ 			    == NULL)
+ 				return ENI_NOHOSTNAME;
+ 			if (strlen(numaddr) > hostlen)
+ 				return ENI_MEMORY;
+ 			strcpy(host, numaddr);
+ 		}
+ 	}
+ 	return SUCCESS;
+ }
