Refactor configure script detection of functions used to set sockets into
authorYang Tse <yangsita@gmail.com>
Thu, 13 Nov 2008 18:56:55 +0000 (18:56 +0000)
committerYang Tse <yangsita@gmail.com>
Thu, 13 Nov 2008 18:56:55 +0000 (18:56 +0000)
non-blocking mode, and decouple function detection from function capability.

28 files changed:
CHANGES
acinclude.m4
ares/Makefile.dj
ares/Makefile.netware
ares/acinclude.m4
ares/ares_process.c
ares/config-win32.h
ares/configure.ac
ares/m4/cares-confopts.m4
ares/m4/cares-functions.m4
configure.ac
lib/Makefile.netware
lib/config-amigaos.h
lib/config-mac.h
lib/config-os400.h
lib/config-riscos.h
lib/config-symbian.h
lib/config-tpf.h
lib/config-win32.h
lib/config-win32ce.h
lib/config.dos
lib/connect.c
m4/curl-confopts.m4
m4/curl-functions.m4
packages/vms/config-vms.h
src/Makefile.netware
src/config-riscos.h
src/config-win32.h

diff --git a/CHANGES b/CHANGES
index 0f0cd74..beda69b 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -6,6 +6,10 @@
 
                                   Changelog
 
+Yang Tse (13 Nov 2008)
+- Refactored configure script detection of functions used to set sockets into
+  non-blocking mode, and decouple function detection from function capability.
+
 Version 7.19.2 (13 November 2008)
 
 Michal Marek (13 Nov 2008)
index 93b47c8..bfe5b18 100644 (file)
@@ -1965,154 +1965,6 @@ AC_DEFUN([TYPE_SIG_ATOMIC_T], [
 ])
 
 
-dnl CURL_CHECK_NONBLOCKING_SOCKET
-dnl -------------------------------------------------
-dnl Check for how to set a socket to non-blocking state. There seems to exist
-dnl four known different ways, with the one used almost everywhere being POSIX
-dnl and XPG3, while the other different ways for different systems (old BSD,
-dnl Windows and Amiga).
-dnl
-dnl There are two known platforms (AIX 3.x and SunOS 4.1.x) where the
-dnl O_NONBLOCK define is found but does not work. This condition is attempted
-dnl to get caught in this script by using an excessive number of #ifdefs...
-
-AC_DEFUN([CURL_CHECK_NONBLOCKING_SOCKET], [
-  AC_MSG_CHECKING([non-blocking sockets style])
-  nonblock="unknown"
-  #
-  AC_COMPILE_IFELSE([
-    AC_LANG_PROGRAM([[
-/* headers for O_NONBLOCK test */
-#include <sys/types.h>
-#include <unistd.h>
-#include <fcntl.h>
-/* */
-#if defined(sun) || defined(__sun__) || \
-    defined(__SUNPRO_C) || defined(__SUNPRO_CC)
-# if defined(__SVR4) || defined(__srv4__)
-#  define PLATFORM_SOLARIS
-# else
-#  define PLATFORM_SUNOS4
-# endif
-#endif
-#if (defined(_AIX) || defined(__xlC__)) && !defined(_AIX41)
-# define PLATFORM_AIX_V3
-#endif
-/* */
-#if defined(PLATFORM_SUNOS4) || defined(PLATFORM_AIX_V3) || defined(__BEOS__)
-#error "O_NONBLOCK does not work on this platform"
-#endif
-    ]],[[
-      /* O_NONBLOCK source test */
-      int socket;
-      int flags = fcntl(socket, F_SETFL, flags | O_NONBLOCK);
-    ]])
-  ],[
-    dnl the O_NONBLOCK test was fine
-    nonblock="O_NONBLOCK"
-    AC_DEFINE(HAVE_O_NONBLOCK, 1,
-      [use O_NONBLOCK for non-blocking sockets])
-  ])
-  #
-  if test "$nonblock" = "unknown"; then
-    AC_COMPILE_IFELSE([
-      AC_LANG_PROGRAM([[
-/* headers for FIONBIO test */
-#include <unistd.h>
-#include <stropts.h>
-      ]],[[
-        /* FIONBIO source test (old-style unix) */
-        int socket;
-        int flags = ioctl(socket, FIONBIO, &flags);
-      ]])
-    ],[
-      dnl FIONBIO test was good
-      nonblock="FIONBIO"
-      AC_DEFINE(HAVE_FIONBIO, 1,
-        [use FIONBIO for non-blocking sockets])
-    ])
-  fi
-  #
-  if test "$nonblock" = "unknown"; then
-    AC_COMPILE_IFELSE([
-      AC_LANG_PROGRAM([[
-/* headers for ioctlsocket test (Windows) */
-#undef inline
-#ifdef HAVE_WINDOWS_H
-#ifndef WIN32_LEAN_AND_MEAN
-#define WIN32_LEAN_AND_MEAN
-#endif
-#include <windows.h>
-#ifdef HAVE_WINSOCK2_H
-#include <winsock2.h>
-#else
-#ifdef HAVE_WINSOCK_H
-#include <winsock.h>
-#endif
-#endif
-#endif
-      ]],[[
-        /* ioctlsocket source code (Windows) */
-        SOCKET sd;
-        unsigned long flags = 0;
-        sd = socket(0, 0, 0);
-        ioctlsocket(sd, FIONBIO, &flags);
-      ]])
-    ],[
-      dnl ioctlsocket test was good
-      nonblock="ioctlsocket"
-      AC_DEFINE(HAVE_IOCTLSOCKET, 1,
-        [use ioctlsocket() for non-blocking sockets])
-    ])
-  fi
-  #
-  if test "$nonblock" = "unknown"; then
-    AC_LINK_IFELSE([
-      AC_LANG_PROGRAM([[
-/* headers for IoctlSocket test (Amiga?) */
-#include <sys/ioctl.h>
-      ]],[[
-        /* IoctlSocket source code (Amiga?) */
-        int socket;
-        int flags = IoctlSocket(socket, FIONBIO, (long)1);
-      ]])
-    ],[
-      dnl Ioctlsocket test was good
-      nonblock="IoctlSocket"
-      AC_DEFINE(HAVE_IOCTLSOCKET_CASE, 1,
-        [use Ioctlsocket() for non-blocking sockets])
-    ])
-  fi
-  #
-  if test "$nonblock" = "unknown"; then
-    AC_COMPILE_IFELSE([
-      AC_LANG_PROGRAM([[
-/* headers for SO_NONBLOCK test (BeOS) */
-#include <socket.h>
-      ]],[[
-        /* SO_NONBLOCK source code (BeOS) */
-        long b = 1;
-        int socket;
-        int flags = setsockopt(socket, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b));
-      ]])
-    ],[
-      dnl the SO_NONBLOCK test was good
-      nonblock="SO_NONBLOCK"
-      AC_DEFINE(HAVE_SO_NONBLOCK, 1,
-        [use SO_NONBLOCK for non-blocking sockets])
-    ])
-  fi
-  #
-  AC_MSG_RESULT($nonblock)
-  #
-  if test "$nonblock" = "unknown"; then
-    AC_DEFINE(HAVE_DISABLED_NONBLOCKING, 1,
-      [disabled non-blocking sockets])
-    AC_MSG_WARN([non-block sockets disabled])
-  fi
-])
-
-
 dnl TYPE_IN_ADDR_T
 dnl -------------------------------------------------
 dnl Check for in_addr_t: it is used to receive the return code of inet_addr()
index 7ee6e04..26a32fb 100644 (file)
@@ -11,6 +11,7 @@ include ../packages/DOS/common.dj
 include Makefile.inc
 
 CFLAGS += -DWATT32 -DHAVE_AF_INET6 -DHAVE_PF_INET6 -DHAVE_IOCTLSOCKET \
+          -DHAVE_IOCTLSOCKET_FIONBIO \
           -DHAVE_STRUCT_IN6_ADDR -DHAVE_SOCKADDR_IN6_SIN6_SCOPE_ID \
           -DHAVE_SYS_TIME_H -DHAVE_STRUCT_SOCKADDR_IN6 -DHAVE_STRUCT_ADDRINFO \
           -DHAVE_SIGNAL_H -DHAVE_SIG_ATOMIC_T -DRETSIGTYPE='void' \
index 9ed7ba0..0a908f0 100644 (file)
@@ -350,12 +350,13 @@ endif
        @echo $(DL)#define HAVE_ASSERT_H 1$(DL) >> $@
        @echo $(DL)#define HAVE_ERR_H 1$(DL) >> $@
        @echo $(DL)#define HAVE_FCNTL_H 1$(DL) >> $@
-       @echo $(DL)#define HAVE_FIONBIO 1$(DL) >> $@
        @echo $(DL)#define HAVE_GETHOSTBYADDR 1$(DL) >> $@
        @echo $(DL)#define HAVE_GETHOSTBYNAME 1$(DL) >> $@
        @echo $(DL)#define HAVE_GETPROTOBYNAME 1$(DL) >> $@
        @echo $(DL)#define HAVE_GMTIME_R 1$(DL) >> $@
        @echo $(DL)#define HAVE_INET_ADDR 1$(DL) >> $@
+       @echo $(DL)#define HAVE_IOCTL 1$(DL) >> $@
+       @echo $(DL)#define HAVE_IOCTL_FIONBIO 1$(DL) >> $@
        @echo $(DL)#define HAVE_LL 1$(DL) >> $@
        @echo $(DL)#define HAVE_LOCALTIME_R 1$(DL) >> $@
        @echo $(DL)#define HAVE_MALLOC_H 1$(DL) >> $@
index abe10d7..879643d 100644 (file)
@@ -1433,154 +1433,6 @@ AC_DEFUN([TYPE_SIG_ATOMIC_T], [
 ])
 
 
-dnl CURL_CHECK_NONBLOCKING_SOCKET
-dnl -------------------------------------------------
-dnl Check for how to set a socket to non-blocking state. There seems to exist
-dnl four known different ways, with the one used almost everywhere being POSIX
-dnl and XPG3, while the other different ways for different systems (old BSD,
-dnl Windows and Amiga).
-dnl
-dnl There are two known platforms (AIX 3.x and SunOS 4.1.x) where the
-dnl O_NONBLOCK define is found but does not work. This condition is attempted
-dnl to get caught in this script by using an excessive number of #ifdefs...
-
-AC_DEFUN([CURL_CHECK_NONBLOCKING_SOCKET], [
-  AC_MSG_CHECKING([non-blocking sockets style])
-  nonblock="unknown"
-  #
-  AC_COMPILE_IFELSE([
-    AC_LANG_PROGRAM([[
-/* headers for O_NONBLOCK test */
-#include <sys/types.h>
-#include <unistd.h>
-#include <fcntl.h>
-/* */
-#if defined(sun) || defined(__sun__) || \
-    defined(__SUNPRO_C) || defined(__SUNPRO_CC)
-# if defined(__SVR4) || defined(__srv4__)
-#  define PLATFORM_SOLARIS
-# else
-#  define PLATFORM_SUNOS4
-# endif
-#endif
-#if (defined(_AIX) || defined(__xlC__)) && !defined(_AIX41)
-# define PLATFORM_AIX_V3
-#endif
-/* */
-#if defined(PLATFORM_SUNOS4) || defined(PLATFORM_AIX_V3) || defined(__BEOS__)
-#error "O_NONBLOCK does not work on this platform"
-#endif
-    ]],[[
-      /* O_NONBLOCK source test */
-      int socket;
-      int flags = fcntl(socket, F_SETFL, flags | O_NONBLOCK);
-    ]])
-  ],[
-    dnl the O_NONBLOCK test was fine
-    nonblock="O_NONBLOCK"
-    AC_DEFINE(HAVE_O_NONBLOCK, 1,
-      [use O_NONBLOCK for non-blocking sockets])
-  ])
-  #
-  if test "$nonblock" = "unknown"; then
-    AC_COMPILE_IFELSE([
-      AC_LANG_PROGRAM([[
-/* headers for FIONBIO test */
-#include <unistd.h>
-#include <stropts.h>
-      ]],[[
-        /* FIONBIO source test (old-style unix) */
-        int socket;
-        int flags = ioctl(socket, FIONBIO, &flags);
-      ]])
-    ],[
-      dnl FIONBIO test was good
-      nonblock="FIONBIO"
-      AC_DEFINE(HAVE_FIONBIO, 1,
-        [use FIONBIO for non-blocking sockets])
-    ])
-  fi
-  #
-  if test "$nonblock" = "unknown"; then
-    AC_COMPILE_IFELSE([
-      AC_LANG_PROGRAM([[
-/* headers for ioctlsocket test (Windows) */
-#undef inline
-#ifdef HAVE_WINDOWS_H
-#ifndef WIN32_LEAN_AND_MEAN
-#define WIN32_LEAN_AND_MEAN
-#endif
-#include <windows.h>
-#ifdef HAVE_WINSOCK2_H
-#include <winsock2.h>
-#else
-#ifdef HAVE_WINSOCK_H
-#include <winsock.h>
-#endif
-#endif
-#endif
-      ]],[[
-        /* ioctlsocket source code (Windows) */
-        SOCKET sd;
-        unsigned long flags = 0;
-        sd = socket(0, 0, 0);
-        ioctlsocket(sd, FIONBIO, &flags);
-      ]])
-    ],[
-      dnl ioctlsocket test was good
-      nonblock="ioctlsocket"
-      AC_DEFINE(HAVE_IOCTLSOCKET, 1,
-        [use ioctlsocket() for non-blocking sockets])
-    ])
-  fi
-  #
-  if test "$nonblock" = "unknown"; then
-    AC_LINK_IFELSE([
-      AC_LANG_PROGRAM([[
-/* headers for IoctlSocket test (Amiga?) */
-#include <sys/ioctl.h>
-      ]],[[
-        /* IoctlSocket source code (Amiga?) */
-        int socket;
-        int flags = IoctlSocket(socket, FIONBIO, (long)1);
-      ]])
-    ],[
-      dnl Ioctlsocket test was good
-      nonblock="IoctlSocket"
-      AC_DEFINE(HAVE_IOCTLSOCKET_CASE, 1,
-        [use Ioctlsocket() for non-blocking sockets])
-    ])
-  fi
-  #
-  if test "$nonblock" = "unknown"; then
-    AC_COMPILE_IFELSE([
-      AC_LANG_PROGRAM([[
-/* headers for SO_NONBLOCK test (BeOS) */
-#include <socket.h>
-      ]],[[
-        /* SO_NONBLOCK source code (BeOS) */
-        long b = 1;
-        int socket;
-        int flags = setsockopt(socket, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b));
-      ]])
-    ],[
-      dnl the SO_NONBLOCK test was good
-      nonblock="SO_NONBLOCK"
-      AC_DEFINE(HAVE_SO_NONBLOCK, 1,
-        [use SO_NONBLOCK for non-blocking sockets])
-    ])
-  fi
-  #
-  AC_MSG_RESULT($nonblock)
-  #
-  if test "$nonblock" = "unknown"; then
-    AC_DEFINE(HAVE_DISABLED_NONBLOCKING, 1,
-      [disabled non-blocking sockets])
-    AC_MSG_WARN([non-block sockets disabled])
-  fi
-])
-
-
 dnl TYPE_IN_ADDR_T
 dnl -------------------------------------------------
 dnl Check for in_addr_t: it is used to receive the return code of inet_addr()
index b7f375e..05341aa 100644 (file)
@@ -805,68 +805,51 @@ void ares__send_query(ares_channel channel, struct query *query,
 static int setsocknonblock(ares_socket_t sockfd,    /* operate on this */
                     int nonblock   /* TRUE or FALSE */)
 {
-#undef SETBLOCK
-#define SETBLOCK 0
-#ifdef HAVE_O_NONBLOCK
+#if defined(USE_BLOCKING_SOCKETS)
+
+  return 0; /* returns success */
+
+#elif defined(HAVE_FCNTL_O_NONBLOCK)
+
   /* most recent unix versions */
   int flags;
-
   flags = fcntl(sockfd, F_GETFL, 0);
   if (FALSE != nonblock)
     return fcntl(sockfd, F_SETFL, flags | O_NONBLOCK);
   else
     return fcntl(sockfd, F_SETFL, flags & (~O_NONBLOCK));
-#undef SETBLOCK
-#define SETBLOCK 1
-#endif
 
-#if defined(HAVE_FIONBIO) && (SETBLOCK == 0)
+#elif defined(HAVE_IOCTL_FIONBIO)
+
   /* older unix versions */
   int flags;
-
   flags = nonblock;
   return ioctl(sockfd, FIONBIO, &flags);
-#undef SETBLOCK
-#define SETBLOCK 2
-#endif
 
-#if defined(HAVE_IOCTLSOCKET) && (SETBLOCK == 0)
+#elif defined(HAVE_IOCTLSOCKET_FIONBIO)
+
 #ifdef WATT32
   char flags;
 #else
-  /* Windows? */
+  /* Windows */
   unsigned long flags;
 #endif
   flags = nonblock;
-
   return ioctlsocket(sockfd, FIONBIO, &flags);
-#undef SETBLOCK
-#define SETBLOCK 3
-#endif
 
-#if defined(HAVE_IOCTLSOCKET_CASE) && (SETBLOCK == 0)
-  /* presumably for Amiga */
+#elif defined(HAVE_IOCTLSOCKET_CAMEL_FIONBIO)
+
+  /* Amiga */
   return IoctlSocket(sockfd, FIONBIO, (long)nonblock);
-#undef SETBLOCK
-#define SETBLOCK 4
-#endif
 
-#if defined(HAVE_SO_NONBLOCK) && (SETBLOCK == 0)
+#elif defined(HAVE_SETSOCKOPT_SO_NONBLOCK)
+
   /* BeOS */
   long b = nonblock ? 1 : 0;
   return setsockopt(sockfd, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b));
-#undef SETBLOCK
-#define SETBLOCK 5
-#endif
 
-#ifdef HAVE_DISABLED_NONBLOCKING
-  return 0; /* returns success */
-#undef SETBLOCK
-#define SETBLOCK 6
-#endif
-
-#if (SETBLOCK == 0)
-#error "no non-blocking method was found/used/set"
+#else
+#  error "no non-blocking method was found/used/set"
 #endif
 }
 
index 9e8f10c..2245b03 100644 (file)
 /*                             FUNCTIONS                            */
 /* ---------------------------------------------------------------- */
 
-/* Define if you have the ioctlsocket function.  */
+/* Define if you have the ioctlsocket function. */
 #define HAVE_IOCTLSOCKET 1
 
+/* Define if you have a working ioctlsocket FIONBIO function. */
+#define HAVE_IOCTLSOCKET_FIONBIO 1
+
 /* Define if you have the strcasecmp function. */
 /* #define HAVE_STRCASECMP 1 */
 
index 641a83e..1b1b20d 100644 (file)
@@ -553,12 +553,17 @@ CURL_CHECK_FUNC_RECVFROM
 CURL_CHECK_FUNC_SEND
 CURL_CHECK_MSG_NOSIGNAL
 
+CARES_CHECK_FUNC_FCNTL
 CARES_CHECK_FUNC_FREEADDRINFO
 CARES_CHECK_FUNC_GETADDRINFO
 CARES_CHECK_FUNC_GETHOSTNAME
 CARES_CHECK_FUNC_GETSERVBYPORT_R
 CARES_CHECK_FUNC_INET_NTOP
 CARES_CHECK_FUNC_INET_PTON
+CARES_CHECK_FUNC_IOCTL
+CARES_CHECK_FUNC_IOCTLSOCKET
+CARES_CHECK_FUNC_IOCTLSOCKET_CAMEL
+CARES_CHECK_FUNC_SETSOCKOPT
 CARES_CHECK_FUNC_STRCASECMP
 CARES_CHECK_FUNC_STRCMPI
 CARES_CHECK_FUNC_STRDUP
@@ -851,8 +856,6 @@ dnl and get the types of five of its arguments.
 CURL_CHECK_FUNC_GETNAMEINFO
 
 
-CURL_CHECK_NONBLOCKING_SOCKET
-
 AC_C_BIGENDIAN(
     [AC_DEFINE(ARES_BIG_ENDIAN, 1,
       [define this if ares is built for a big endian system])],
@@ -883,6 +886,9 @@ if test -n "$RANDOM_FILE" && test X"$RANDOM_FILE" != Xno ; then
         [a suitable file/device to read random data from])
 fi
 
+CARES_CHECK_OPTION_NONBLOCKING
+CARES_CHECK_NONBLOCKING_SOCKET
+
 CARES_PRIVATE_LIBS="$LIBS"
 AC_SUBST(CARES_PRIVATE_LIBS)
 
index 17a6875..c34197a 100644 (file)
@@ -16,7 +16,7 @@
 #***************************************************************************
 
 # File version for 'aclocal' use. Keep it a single number.
-# serial 2
+# serial 3
 
 
 dnl CARES_CHECK_OPTION_DEBUG
@@ -52,6 +52,38 @@ AC_HELP_STRING([--disable-debug],[Disable debug build options]),
 ])
 
 
+dnl CARES_CHECK_OPTION_NONBLOCKING
+dnl -------------------------------------------------
+dnl Verify if configure has been invoked with option
+dnl --enable-nonblocking or --disable-nonblocking, and
+dnl set shell variable want_nonblocking as appropriate.
+
+AC_DEFUN([CARES_CHECK_OPTION_NONBLOCKING], [
+  AC_BEFORE([$0],[CARES_CHECK_NONBLOCKING_SOCKET])dnl
+  AC_MSG_CHECKING([whether to enable non-blocking communications])
+  OPT_NONBLOCKING="default"
+  AC_ARG_ENABLE(nonblocking,
+AC_HELP_STRING([--enable-nonblocking],[Enable non-blocking communications])
+AC_HELP_STRING([--disable-nonblocking],[Disable non-blocking communications]),
+  OPT_NONBLOCKING=$enableval)
+  case "$OPT_NONBLOCKING" in
+    no)
+      dnl --disable-nonblocking option used
+      want_nonblocking="no"
+      ;;
+    default)
+      dnl configure option not specified
+      want_nonblocking="yes"
+      ;;
+    *)
+      dnl --enable-nonblocking option used
+      want_nonblocking="yes"
+      ;;
+  esac
+  AC_MSG_RESULT([$want_nonblocking])
+])
+
+
 dnl CARES_CHECK_OPTION_OPTIMIZE
 dnl -------------------------------------------------
 dnl Verify if configure has been invoked with option
@@ -140,3 +172,43 @@ AC_HELP_STRING([--disable-warnings],[Disable strict compiler warnings]),
   esac
   AC_MSG_RESULT([$want_warnings])
 ])
+
+
+dnl CARES_CHECK_NONBLOCKING_SOCKET
+dnl -------------------------------------------------
+dnl Check for how to set a socket into non-blocking state.
+
+AC_DEFUN([CARES_CHECK_NONBLOCKING_SOCKET], [
+  AC_REQUIRE([CARES_CHECK_OPTION_NONBLOCKING])dnl
+  AC_REQUIRE([CARES_CHECK_FUNC_FCNTL])dnl
+  AC_REQUIRE([CARES_CHECK_FUNC_IOCTL])dnl
+  AC_REQUIRE([CARES_CHECK_FUNC_IOCTLSOCKET])dnl
+  AC_REQUIRE([CARES_CHECK_FUNC_IOCTLSOCKET_CAMEL])dnl
+  AC_REQUIRE([CARES_CHECK_FUNC_SETSOCKOPT])dnl
+  #
+  tst_method="unknown"
+  if test "$want_nonblocking" = "yes"; then
+    AC_MSG_CHECKING([how to set a socket into non-blocking mode])
+    if test "x$ac_cv_func_fcntl_o_nonblock" = "xyes"; then
+      tst_method="fcntl O_NONBLOCK"
+    elif test "x$ac_cv_func_ioctl_fionbio" = "xyes"; then
+      tst_method="ioctl FIONBIO"
+    elif test "x$ac_cv_func_ioctlsocket_fionbio" = "xyes"; then
+      tst_method="ioctlsocket FIONBIO"
+    elif test "x$ac_cv_func_ioctlsocket_camel_fionbio" = "xyes"; then
+      tst_method="IoctlSocket FIONBIO"
+    elif test "x$ac_cv_func_setsockopt_so_nonblock" = "xyes"; then
+      tst_method="setsockopt SO_NONBLOCK"
+    fi
+    AC_MSG_RESULT([$tst_method])
+    if test "$tst_method" = "unknown"; then
+      AC_MSG_WARN([cannot determine non-blocking socket method.])
+    fi
+  fi
+  if test "$tst_method" = "unknown"; then
+    AC_DEFINE_UNQUOTED(USE_BLOCKING_SOCKETS, 1,
+      [Define to disable non-blocking sockets.])
+    AC_MSG_WARN([non-blocking sockets disabled.])
+  fi
+])
+
index 98bd070..66bf9ca 100644 (file)
@@ -16,7 +16,7 @@
 #***************************************************************************
 
 # File version for 'aclocal' use. Keep it a single number.
-# serial 18
+# serial 19
 
 
 dnl CARES_INCLUDES_ARPA_INET
@@ -46,6 +46,30 @@ cares_includes_arpa_inet="\
 ])
 
 
+dnl CARES_INCLUDES_FCNTL
+dnl -------------------------------------------------
+dnl Set up variable with list of headers that must be
+dnl included when fcntl.h is to be included.
+
+AC_DEFUN([CARES_INCLUDES_FCNTL], [
+cares_includes_fcntl="\
+/* includes start */
+#ifdef HAVE_SYS_TYPES_H
+#  include <sys/types.h>
+#endif
+#ifdef HAVE_UNISTD_H
+#  include <unistd.h>
+#endif
+#ifdef HAVE_STROPTS_H
+#  include <fcntl.h>
+#endif
+/* includes end */"
+  AC_CHECK_HEADERS(
+    sys/types.h unistd.h fcntl.h,
+    [], [], [$cares_includes_fcntl])
+])
+
+
 dnl CARES_INCLUDES_NETDB
 dnl -------------------------------------------------
 dnl Set up variable with list of headers that must be
@@ -112,6 +136,36 @@ cares_includes_string="\
 ])
 
 
+dnl CARES_INCLUDES_STROPTS
+dnl -------------------------------------------------
+dnl Set up variable with list of headers that must be
+dnl included when stropts.h is to be included.
+
+AC_DEFUN([CARES_INCLUDES_STROPTS], [
+cares_includes_stropts="\
+/* includes start */
+#ifdef HAVE_SYS_TYPES_H
+#  include <sys/types.h>
+#endif
+#ifdef HAVE_UNISTD_H
+#  include <unistd.h>
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+#  include <sys/socket.h>
+#endif
+#ifdef HAVE_SYS_IOCTL_H
+#  include <sys/ioctl.h>
+#endif
+#ifdef HAVE_STROPTS_H
+#  include <stropts.h>
+#endif
+/* includes end */"
+  AC_CHECK_HEADERS(
+    sys/types.h unistd.h sys/socket.h sys/ioctl.h stropts.h,
+    [], [], [$cares_includes_stropts])
+])
+
+
 dnl CARES_INCLUDES_SYS_SOCKET
 dnl -------------------------------------------------
 dnl Set up variable with list of headers that must be
@@ -230,6 +284,155 @@ cares_includes_ws2tcpip="\
 ])
 
 
+dnl CARES_CHECK_FUNC_FCNTL
+dnl -------------------------------------------------
+dnl Verify if fcntl is available, prototyped, and
+dnl can be compiled. If all of these are true, and
+dnl usage has not been previously disallowed with
+dnl shell variable cares_disallow_fcntl, then
+dnl HAVE_FCNTL will be defined.
+
+AC_DEFUN([CARES_CHECK_FUNC_FCNTL], [
+  AC_REQUIRE([CARES_INCLUDES_FCNTL])dnl
+  #
+  tst_links_fcntl="unknown"
+  tst_proto_fcntl="unknown"
+  tst_compi_fcntl="unknown"
+  tst_allow_fcntl="unknown"
+  #
+  AC_MSG_CHECKING([if fcntl can be linked])
+  AC_LINK_IFELSE([
+    AC_LANG_FUNC_LINK_TRY([fcntl])
+  ],[
+    AC_MSG_RESULT([yes])
+    tst_links_fcntl="yes"
+  ],[
+    AC_MSG_RESULT([no])
+    tst_links_fcntl="no"
+  ])
+  #
+  if test "$tst_links_fcntl" = "yes"; then
+    AC_MSG_CHECKING([if fcntl is prototyped])
+    AC_EGREP_CPP([fcntl],[
+      $cares_includes_fcntl
+    ],[
+      AC_MSG_RESULT([yes])
+      tst_proto_fcntl="yes"
+    ],[
+      AC_MSG_RESULT([no])
+      tst_proto_fcntl="no"
+    ])
+  fi
+  #
+  if test "$tst_proto_fcntl" = "yes"; then
+    AC_MSG_CHECKING([if fcntl is compilable])
+    AC_COMPILE_IFELSE([
+      AC_LANG_PROGRAM([[
+        $cares_includes_fcntl
+      ]],[[
+        if(0 != fcntl(0, 0, 0))
+          return 1;
+      ]])
+    ],[
+      AC_MSG_RESULT([yes])
+      tst_compi_fcntl="yes"
+    ],[
+      AC_MSG_RESULT([no])
+      tst_compi_fcntl="no"
+    ])
+  fi
+  #
+  if test "$tst_compi_fcntl" = "yes"; then
+    AC_MSG_CHECKING([if fcntl usage allowed])
+    if test "x$cares_disallow_fcntl" != "xyes"; then
+      AC_MSG_RESULT([yes])
+      tst_allow_fcntl="yes"
+    else
+      AC_MSG_RESULT([no])
+      tst_allow_fcntl="no"
+    fi
+  fi
+  #
+  AC_MSG_CHECKING([if fcntl might be used])
+  if test "$tst_links_fcntl" = "yes" &&
+     test "$tst_proto_fcntl" = "yes" &&
+     test "$tst_compi_fcntl" = "yes" &&
+     test "$tst_allow_fcntl" = "yes"; then
+    AC_MSG_RESULT([yes])
+    AC_DEFINE_UNQUOTED(HAVE_FCNTL, 1,
+      [Define to 1 if you have the fcntl function.])
+    ac_cv_func_fcntl="yes"
+    CARES_CHECK_FUNC_FCNTL_O_NONBLOCK
+  else
+    AC_MSG_RESULT([no])
+    ac_cv_func_fcntl="no"
+  fi
+])
+
+
+dnl CARES_CHECK_FUNC_FCNTL_O_NONBLOCK
+dnl -------------------------------------------------
+dnl Verify if fcntl with status flag O_NONBLOCK is
+dnl available, can be compiled, and seems to work. If
+dnl all of these are true, then HAVE_FCNTL_O_NONBLOCK
+dnl will be defined.
+
+AC_DEFUN([CARES_CHECK_FUNC_FCNTL_O_NONBLOCK], [
+  #
+  tst_compi_fcntl_o_nonblock="unknown"
+  tst_allow_fcntl_o_nonblock="unknown"
+  #
+  case $host_os in
+    sunos4* | aix3* | beos*)
+      dnl O_NONBLOCK does not work on these platforms
+      cares_disallow_fcntl_o_nonblock="yes"
+      ;;
+  esac
+  #
+  if test "$ac_cv_func_fcntl" = "yes"; then
+    AC_MSG_CHECKING([if fcntl O_NONBLOCK is compilable])
+    AC_COMPILE_IFELSE([
+      AC_LANG_PROGRAM([[
+        $cares_includes_fcntl
+      ]],[[
+        int flags = 0;
+        if(0 != fcntl(0, F_SETFL, flags | O_NONBLOCK))
+          return 1;
+      ]])
+    ],[
+      AC_MSG_RESULT([yes])
+      tst_compi_fcntl_o_nonblock="yes"
+    ],[
+      AC_MSG_RESULT([no])
+      tst_compi_fcntl_o_nonblock="no"
+    ])
+  fi
+  #
+  if test "$tst_compi_fcntl_o_nonblock" = "yes"; then
+    AC_MSG_CHECKING([if fcntl O_NONBLOCK usage allowed])
+    if test "x$cares_disallow_fcntl_o_nonblock" != "xyes"; then
+      AC_MSG_RESULT([yes])
+      tst_allow_fcntl_o_nonblock="yes"
+    else
+      AC_MSG_RESULT([no])
+      tst_allow_fcntl_o_nonblock="no"
+    fi
+  fi
+  #
+  AC_MSG_CHECKING([if fcntl O_NONBLOCK might be used])
+  if test "$tst_compi_fcntl_o_nonblock" = "yes" &&
+     test "$tst_allow_fcntl_o_nonblock" = "yes"; then
+    AC_MSG_RESULT([yes])
+    AC_DEFINE_UNQUOTED(HAVE_FCNTL_O_NONBLOCK, 1,
+      [Define to 1 if you have a working fcntl O_NONBLOCK function.])
+    ac_cv_func_fcntl_o_nonblock="yes"
+  else
+    AC_MSG_RESULT([no])
+    ac_cv_func_fcntl_o_nonblock="no"
+  fi
+])
+
+
 dnl CARES_CHECK_FUNC_FREEADDRINFO
 dnl -------------------------------------------------
 dnl Verify if freeaddrinfo is available, prototyped,
@@ -1018,6 +1221,587 @@ AC_DEFUN([CARES_CHECK_FUNC_INET_PTON], [
 ])
 
 
+dnl CARES_CHECK_FUNC_IOCTL
+dnl -------------------------------------------------
+dnl Verify if ioctl is available, prototyped, and
+dnl can be compiled. If all of these are true, and
+dnl usage has not been previously disallowed with
+dnl shell variable cares_disallow_ioctl, then
+dnl HAVE_IOCTL will be defined.
+
+AC_DEFUN([CARES_CHECK_FUNC_IOCTL], [
+  AC_REQUIRE([CARES_INCLUDES_STROPTS])dnl
+  #
+  tst_links_ioctl="unknown"
+  tst_proto_ioctl="unknown"
+  tst_compi_ioctl="unknown"
+  tst_allow_ioctl="unknown"
+  #
+  AC_MSG_CHECKING([if ioctl can be linked])
+  AC_LINK_IFELSE([
+    AC_LANG_FUNC_LINK_TRY([ioctl])
+  ],[
+    AC_MSG_RESULT([yes])
+    tst_links_ioctl="yes"
+  ],[
+    AC_MSG_RESULT([no])
+    tst_links_ioctl="no"
+  ])
+  #
+  if test "$tst_links_ioctl" = "yes"; then
+    AC_MSG_CHECKING([if ioctl is prototyped])
+    AC_EGREP_CPP([ioctl],[
+      $cares_includes_stropts
+    ],[
+      AC_MSG_RESULT([yes])
+      tst_proto_ioctl="yes"
+    ],[
+      AC_MSG_RESULT([no])
+      tst_proto_ioctl="no"
+    ])
+  fi
+  #
+  if test "$tst_proto_ioctl" = "yes"; then
+    AC_MSG_CHECKING([if ioctl is compilable])
+    AC_COMPILE_IFELSE([
+      AC_LANG_PROGRAM([[
+        $cares_includes_stropts
+      ]],[[
+        if(0 != ioctl(0, 0, 0))
+          return 1;
+      ]])
+    ],[
+      AC_MSG_RESULT([yes])
+      tst_compi_ioctl="yes"
+    ],[
+      AC_MSG_RESULT([no])
+      tst_compi_ioctl="no"
+    ])
+  fi
+  #
+  if test "$tst_compi_ioctl" = "yes"; then
+    AC_MSG_CHECKING([if ioctl usage allowed])
+    if test "x$cares_disallow_ioctl" != "xyes"; then
+      AC_MSG_RESULT([yes])
+      tst_allow_ioctl="yes"
+    else
+      AC_MSG_RESULT([no])
+      tst_allow_ioctl="no"
+    fi
+  fi
+  #
+  AC_MSG_CHECKING([if ioctl might be used])
+  if test "$tst_links_ioctl" = "yes" &&
+     test "$tst_proto_ioctl" = "yes" &&
+     test "$tst_compi_ioctl" = "yes" &&
+     test "$tst_allow_ioctl" = "yes"; then
+    AC_MSG_RESULT([yes])
+    AC_DEFINE_UNQUOTED(HAVE_IOCTL, 1,
+      [Define to 1 if you have the ioctl function.])
+    ac_cv_func_ioctl="yes"
+    CARES_CHECK_FUNC_IOCTL_FIONBIO
+  else
+    AC_MSG_RESULT([no])
+    ac_cv_func_ioctl="no"
+  fi
+])
+
+
+dnl CARES_CHECK_FUNC_IOCTL_FIONBIO
+dnl -------------------------------------------------
+dnl Verify if ioctl with the FIONBIO command is
+dnl available, can be compiled, and seems to work. If
+dnl all of these are true, then HAVE_IOCTL_FIONBIO
+dnl will be defined.
+
+AC_DEFUN([CARES_CHECK_FUNC_IOCTL_FIONBIO], [
+  #
+  tst_compi_ioctl_fionbio="unknown"
+  tst_allow_ioctl_fionbio="unknown"
+  #
+  if test "$ac_cv_func_ioctl" = "yes"; then
+    AC_MSG_CHECKING([if ioctl FIONBIO is compilable])
+    AC_COMPILE_IFELSE([
+      AC_LANG_PROGRAM([[
+        $cares_includes_stropts
+      ]],[[
+        int flags = 0;
+        if(0 != ioctl(0, FIONBIO, &flags))
+          return 1;
+      ]])
+    ],[
+      AC_MSG_RESULT([yes])
+      tst_compi_ioctl_fionbio="yes"
+    ],[
+      AC_MSG_RESULT([no])
+      tst_compi_ioctl_fionbio="no"
+    ])
+  fi
+  #
+  if test "$tst_compi_ioctl_fionbio" = "yes"; then
+    AC_MSG_CHECKING([if ioctl FIONBIO usage allowed])
+    if test "x$cares_disallow_ioctl_fionbio" != "xyes"; then
+      AC_MSG_RESULT([yes])
+      tst_allow_ioctl_fionbio="yes"
+    else
+      AC_MSG_RESULT([no])
+      tst_allow_ioctl_fionbio="no"
+    fi
+  fi
+  #
+  AC_MSG_CHECKING([if ioctl FIONBIO might be used])
+  if test "$tst_compi_ioctl_fionbio" = "yes" &&
+     test "$tst_allow_ioctl_fionbio" = "yes"; then
+    AC_MSG_RESULT([yes])
+    AC_DEFINE_UNQUOTED(HAVE_IOCTL_FIONBIO, 1,
+      [Define to 1 if you have a working ioctl FIONBIO function.])
+    ac_cv_func_ioctl_fionbio="yes"
+  else
+    AC_MSG_RESULT([no])
+    ac_cv_func_ioctl_fionbio="no"
+  fi
+])
+
+
+dnl CARES_CHECK_FUNC_IOCTLSOCKET
+dnl -------------------------------------------------
+dnl Verify if ioctlsocket is available, prototyped, and
+dnl can be compiled. If all of these are true, and
+dnl usage has not been previously disallowed with
+dnl shell variable cares_disallow_ioctlsocket, then
+dnl HAVE_IOCTLSOCKET will be defined.
+
+AC_DEFUN([CARES_CHECK_FUNC_IOCTLSOCKET], [
+  AC_REQUIRE([CARES_INCLUDES_WINSOCK2])dnl
+  #
+  tst_links_ioctlsocket="unknown"
+  tst_proto_ioctlsocket="unknown"
+  tst_compi_ioctlsocket="unknown"
+  tst_allow_ioctlsocket="unknown"
+  #
+  AC_MSG_CHECKING([if ioctlsocket can be linked])
+  AC_LINK_IFELSE([
+    AC_LANG_PROGRAM([[
+      $cares_includes_winsock2
+    ]],[[
+      if(0 != ioctlsocket(0, 0, 0))
+        return 1;
+    ]])
+  ],[
+    AC_MSG_RESULT([yes])
+    tst_links_ioctlsocket="yes"
+  ],[
+    AC_MSG_RESULT([no])
+    tst_links_ioctlsocket="no"
+  ])
+  #
+  if test "$tst_links_ioctlsocket" = "yes"; then
+    AC_MSG_CHECKING([if ioctlsocket is prototyped])
+    AC_EGREP_CPP([ioctlsocket],[
+      $cares_includes_winsock2
+    ],[
+      AC_MSG_RESULT([yes])
+      tst_proto_ioctlsocket="yes"
+    ],[
+      AC_MSG_RESULT([no])
+      tst_proto_ioctlsocket="no"
+    ])
+  fi
+  #
+  if test "$tst_proto_ioctlsocket" = "yes"; then
+    AC_MSG_CHECKING([if ioctlsocket is compilable])
+    AC_COMPILE_IFELSE([
+      AC_LANG_PROGRAM([[
+        $cares_includes_winsock2
+      ]],[[
+        if(0 != ioctlsocket(0, 0, 0))
+          return 1;
+      ]])
+    ],[
+      AC_MSG_RESULT([yes])
+      tst_compi_ioctlsocket="yes"
+    ],[
+      AC_MSG_RESULT([no])
+      tst_compi_ioctlsocket="no"
+    ])
+  fi
+  #
+  if test "$tst_compi_ioctlsocket" = "yes"; then
+    AC_MSG_CHECKING([if ioctlsocket usage allowed])
+    if test "x$cares_disallow_ioctlsocket" != "xyes"; then
+      AC_MSG_RESULT([yes])
+      tst_allow_ioctlsocket="yes"
+    else
+      AC_MSG_RESULT([no])
+      tst_allow_ioctlsocket="no"
+    fi
+  fi
+  #
+  AC_MSG_CHECKING([if ioctlsocket might be used])
+  if test "$tst_links_ioctlsocket" = "yes" &&
+     test "$tst_proto_ioctlsocket" = "yes" &&
+     test "$tst_compi_ioctlsocket" = "yes" &&
+     test "$tst_allow_ioctlsocket" = "yes"; then
+    AC_MSG_RESULT([yes])
+    AC_DEFINE_UNQUOTED(HAVE_IOCTLSOCKET, 1,
+      [Define to 1 if you have the ioctlsocket function.])
+    ac_cv_func_ioctlsocket="yes"
+    CARES_CHECK_FUNC_IOCTLSOCKET_FIONBIO
+  else
+    AC_MSG_RESULT([no])
+    ac_cv_func_ioctlsocket="no"
+  fi
+])
+
+
+dnl CARES_CHECK_FUNC_IOCTLSOCKET_FIONBIO
+dnl -------------------------------------------------
+dnl Verify if ioctlsocket with the FIONBIO command is
+dnl available, can be compiled, and seems to work. If
+dnl all of these are true, then HAVE_IOCTLSOCKET_FIONBIO
+dnl will be defined.
+
+AC_DEFUN([CARES_CHECK_FUNC_IOCTLSOCKET_FIONBIO], [
+  #
+  tst_compi_ioctlsocket_fionbio="unknown"
+  tst_allow_ioctlsocket_fionbio="unknown"
+  #
+  if test "$ac_cv_func_ioctlsocket" = "yes"; then
+    AC_MSG_CHECKING([if ioctlsocket FIONBIO is compilable])
+    AC_COMPILE_IFELSE([
+      AC_LANG_PROGRAM([[
+        $cares_includes_winsock2
+      ]],[[
+        int flags = 0;
+        if(0 != ioctlsocket(0, FIONBIO, &flags))
+          return 1;
+      ]])
+    ],[
+      AC_MSG_RESULT([yes])
+      tst_compi_ioctlsocket_fionbio="yes"
+    ],[
+      AC_MSG_RESULT([no])
+      tst_compi_ioctlsocket_fionbio="no"
+    ])
+  fi
+  #
+  if test "$tst_compi_ioctlsocket_fionbio" = "yes"; then
+    AC_MSG_CHECKING([if ioctlsocket FIONBIO usage allowed])
+    if test "x$cares_disallow_ioctlsocket_fionbio" != "xyes"; then
+      AC_MSG_RESULT([yes])
+      tst_allow_ioctlsocket_fionbio="yes"
+    else
+      AC_MSG_RESULT([no])
+      tst_allow_ioctlsocket_fionbio="no"
+    fi
+  fi
+  #
+  AC_MSG_CHECKING([if ioctlsocket FIONBIO might be used])
+  if test "$tst_compi_ioctlsocket_fionbio" = "yes" &&
+     test "$tst_allow_ioctlsocket_fionbio" = "yes"; then
+    AC_MSG_RESULT([yes])
+    AC_DEFINE_UNQUOTED(HAVE_IOCTLSOCKET_FIONBIO, 1,
+      [Define to 1 if you have a working ioctlsocket FIONBIO function.])
+    ac_cv_func_ioctlsocket_fionbio="yes"
+  else
+    AC_MSG_RESULT([no])
+    ac_cv_func_ioctlsocket_fionbio="no"
+  fi
+])
+
+
+dnl CARES_CHECK_FUNC_IOCTLSOCKET_CAMEL
+dnl -------------------------------------------------
+dnl Verify if IoctlSocket is available, prototyped, and
+dnl can be compiled. If all of these are true, and
+dnl usage has not been previously disallowed with
+dnl shell variable cares_disallow_ioctlsocket_camel,
+dnl then HAVE_IOCTLSOCKET_CAMEL will be defined.
+
+AC_DEFUN([CARES_CHECK_FUNC_IOCTLSOCKET_CAMEL], [
+  AC_REQUIRE([CARES_INCLUDES_STROPTS])dnl
+  #
+  tst_links_ioctlsocket_camel="unknown"
+  tst_proto_ioctlsocket_camel="unknown"
+  tst_compi_ioctlsocket_camel="unknown"
+  tst_allow_ioctlsocket_camel="unknown"
+  #
+  AC_MSG_CHECKING([if IoctlSocket can be linked])
+  AC_LINK_IFELSE([
+    AC_LANG_FUNC_LINK_TRY([IoctlSocket])
+  ],[
+    AC_MSG_RESULT([yes])
+    tst_links_ioctlsocket_camel="yes"
+  ],[
+    AC_MSG_RESULT([no])
+    tst_links_ioctlsocket_camel="no"
+  ])
+  #
+  if test "$tst_links_ioctlsocket_camel" = "yes"; then
+    AC_MSG_CHECKING([if IoctlSocket is prototyped])
+    AC_EGREP_CPP([IoctlSocket],[
+      $cares_includes_stropts
+    ],[
+      AC_MSG_RESULT([yes])
+      tst_proto_ioctlsocket_camel="yes"
+    ],[
+      AC_MSG_RESULT([no])
+      tst_proto_ioctlsocket_camel="no"
+    ])
+  fi
+  #
+  if test "$tst_proto_ioctlsocket_camel" = "yes"; then
+    AC_MSG_CHECKING([if IoctlSocket is compilable])
+    AC_COMPILE_IFELSE([
+      AC_LANG_PROGRAM([[
+        $cares_includes_stropts
+      ]],[[
+        if(0 != IoctlSocket(0, 0, 0))
+          return 1;
+      ]])
+    ],[
+      AC_MSG_RESULT([yes])
+      tst_compi_ioctlsocket_camel="yes"
+    ],[
+      AC_MSG_RESULT([no])
+      tst_compi_ioctlsocket_camel="no"
+    ])
+  fi
+  #
+  if test "$tst_compi_ioctlsocket_camel" = "yes"; then
+    AC_MSG_CHECKING([if IoctlSocket usage allowed])
+    if test "x$cares_disallow_ioctlsocket_camel" != "xyes"; then
+      AC_MSG_RESULT([yes])
+      tst_allow_ioctlsocket_camel="yes"
+    else
+      AC_MSG_RESULT([no])
+      tst_allow_ioctlsocket_camel="no"
+    fi
+  fi
+  #
+  AC_MSG_CHECKING([if IoctlSocket might be used])
+  if test "$tst_links_ioctlsocket_camel" = "yes" &&
+     test "$tst_proto_ioctlsocket_camel" = "yes" &&
+     test "$tst_compi_ioctlsocket_camel" = "yes" &&
+     test "$tst_allow_ioctlsocket_camel" = "yes"; then
+    AC_MSG_RESULT([yes])
+    AC_DEFINE_UNQUOTED(HAVE_IOCTLSOCKET_CAMEL, 1,
+      [Define to 1 if you have the IoctlSocket camel case function.])
+    ac_cv_func_ioctlsocket_camel="yes"
+    CARES_CHECK_FUNC_IOCTLSOCKET_CAMEL_FIONBIO
+  else
+    AC_MSG_RESULT([no])
+    ac_cv_func_ioctlsocket_camel="no"
+  fi
+])
+
+
+dnl CARES_CHECK_FUNC_IOCTLSOCKET_CAMEL_FIONBIO
+dnl -------------------------------------------------
+dnl Verify if IoctlSocket with FIONBIO command is available,
+dnl can be compiled, and seems to work. If all of these are
+dnl true, then HAVE_IOCTLSOCKET_CAMEL_FIONBIO will be defined.
+
+AC_DEFUN([CARES_CHECK_FUNC_IOCTLSOCKET_CAMEL_FIONBIO], [
+  #
+  tst_compi_ioctlsocket_camel_fionbio="unknown"
+  tst_allow_ioctlsocket_camel_fionbio="unknown"
+  #
+  if test "$ac_cv_func_ioctlsocket_camel" = "yes"; then
+    AC_MSG_CHECKING([if IoctlSocket FIONBIO is compilable])
+    AC_COMPILE_IFELSE([
+      AC_LANG_PROGRAM([[
+        $cares_includes_stropts
+      ]],[[
+        long flags = 0;
+        if(0 != ioctlsocket(0, FIONBIO, &flags))
+          return 1;
+      ]])
+    ],[
+      AC_MSG_RESULT([yes])
+      tst_compi_ioctlsocket_camel_fionbio="yes"
+    ],[
+      AC_MSG_RESULT([no])
+      tst_compi_ioctlsocket_camel_fionbio="no"
+    ])
+  fi
+  #
+  if test "$tst_compi_ioctlsocket_camel_fionbio" = "yes"; then
+    AC_MSG_CHECKING([if IoctlSocket FIONBIO usage allowed])
+    if test "x$cares_disallow_ioctlsocket_camel_fionbio" != "xyes"; then
+      AC_MSG_RESULT([yes])
+      tst_allow_ioctlsocket_camel_fionbio="yes"
+    else
+      AC_MSG_RESULT([no])
+      tst_allow_ioctlsocket_camel_fionbio="no"
+    fi
+  fi
+  #
+  AC_MSG_CHECKING([if IoctlSocket FIONBIO might be used])
+  if test "$tst_compi_ioctlsocket_camel_fionbio" = "yes" &&
+     test "$tst_allow_ioctlsocket_camel_fionbio" = "yes"; then
+    AC_MSG_RESULT([yes])
+    AC_DEFINE_UNQUOTED(HAVE_IOCTLSOCKET_CAMEL_FIONBIO, 1,
+      [Define to 1 if you have a working IoctlSocket camel case FIONBIO function.])
+    ac_cv_func_ioctlsocket_camel_fionbio="yes"
+  else
+    AC_MSG_RESULT([no])
+    ac_cv_func_ioctlsocket_camel_fionbio="no"
+  fi
+])
+
+
+dnl CARES_CHECK_FUNC_SETSOCKOPT
+dnl -------------------------------------------------
+dnl Verify if setsockopt is available, prototyped, and
+dnl can be compiled. If all of these are true, and
+dnl usage has not been previously disallowed with
+dnl shell variable cares_disallow_setsockopt, then
+dnl HAVE_SETSOCKOPT will be defined.
+
+AC_DEFUN([CARES_CHECK_FUNC_SETSOCKOPT], [
+  AC_REQUIRE([CARES_INCLUDES_WINSOCK2])dnl
+  AC_REQUIRE([CARES_INCLUDES_SYS_SOCKET])dnl
+  #
+  tst_links_setsockopt="unknown"
+  tst_proto_setsockopt="unknown"
+  tst_compi_setsockopt="unknown"
+  tst_allow_setsockopt="unknown"
+  #
+  AC_MSG_CHECKING([if setsockopt can be linked])
+  AC_LINK_IFELSE([
+    AC_LANG_PROGRAM([[
+      $cares_includes_winsock2
+      $cares_includes_sys_socket
+    ]],[[
+      if(0 != setsockopt(0, 0, 0, 0, 0))
+        return 1;
+    ]])
+  ],[
+    AC_MSG_RESULT([yes])
+    tst_links_setsockopt="yes"
+  ],[
+    AC_MSG_RESULT([no])
+    tst_links_setsockopt="no"
+  ])
+  #
+  if test "$tst_links_setsockopt" = "yes"; then
+    AC_MSG_CHECKING([if setsockopt is prototyped])
+    AC_EGREP_CPP([setsockopt],[
+      $cares_includes_winsock2
+      $cares_includes_sys_socket
+    ],[
+      AC_MSG_RESULT([yes])
+      tst_proto_setsockopt="yes"
+    ],[
+      AC_MSG_RESULT([no])
+      tst_proto_setsockopt="no"
+    ])
+  fi
+  #
+  if test "$tst_proto_setsockopt" = "yes"; then
+    AC_MSG_CHECKING([if setsockopt is compilable])
+    AC_COMPILE_IFELSE([
+      AC_LANG_PROGRAM([[
+        $cares_includes_winsock2
+        $cares_includes_sys_socket
+      ]],[[
+        if(0 != setsockopt(0, 0, 0, 0, 0))
+          return 1;
+      ]])
+    ],[
+      AC_MSG_RESULT([yes])
+      tst_compi_setsockopt="yes"
+    ],[
+      AC_MSG_RESULT([no])
+      tst_compi_setsockopt="no"
+    ])
+  fi
+  #
+  if test "$tst_compi_setsockopt" = "yes"; then
+    AC_MSG_CHECKING([if setsockopt usage allowed])
+    if test "x$cares_disallow_setsockopt" != "xyes"; then
+      AC_MSG_RESULT([yes])
+      tst_allow_setsockopt="yes"
+    else
+      AC_MSG_RESULT([no])
+      tst_allow_setsockopt="no"
+    fi
+  fi
+  #
+  AC_MSG_CHECKING([if setsockopt might be used])
+  if test "$tst_links_setsockopt" = "yes" &&
+     test "$tst_proto_setsockopt" = "yes" &&
+     test "$tst_compi_setsockopt" = "yes" &&
+     test "$tst_allow_setsockopt" = "yes"; then
+    AC_MSG_RESULT([yes])
+    AC_DEFINE_UNQUOTED(HAVE_SETSOCKOPT, 1,
+      [Define to 1 if you have the setsockopt function.])
+    ac_cv_func_setsockopt="yes"
+    CARES_CHECK_FUNC_SETSOCKOPT_SO_NONBLOCK
+  else
+    AC_MSG_RESULT([no])
+    ac_cv_func_setsockopt="no"
+  fi
+])
+
+
+dnl CARES_CHECK_FUNC_SETSOCKOPT_SO_NONBLOCK
+dnl -------------------------------------------------
+dnl Verify if setsockopt with the SO_NONBLOCK command is
+dnl available, can be compiled, and seems to work. If
+dnl all of these are true, then HAVE_SETSOCKOPT_SO_NONBLOCK
+dnl will be defined.
+
+AC_DEFUN([CARES_CHECK_FUNC_SETSOCKOPT_SO_NONBLOCK], [
+  #
+  tst_compi_setsockopt_so_nonblock="unknown"
+  tst_allow_setsockopt_so_nonblock="unknown"
+  #
+  if test "$ac_cv_func_setsockopt" = "yes"; then
+    AC_MSG_CHECKING([if setsockopt SO_NONBLOCK is compilable])
+    AC_COMPILE_IFELSE([
+      AC_LANG_PROGRAM([[
+        $cares_includes_winsock2
+        $cares_includes_sys_socket
+      ]],[[
+        if(0 != setsockopt(0, SOL_SOCKET, SO_NONBLOCK, 0, 0))
+          return 1;
+      ]])
+    ],[
+      AC_MSG_RESULT([yes])
+      tst_compi_setsockopt_so_nonblock="yes"
+    ],[
+      AC_MSG_RESULT([no])
+      tst_compi_setsockopt_so_nonblock="no"
+    ])
+  fi
+  #
+  if test "$tst_compi_setsockopt_so_nonblock" = "yes"; then
+    AC_MSG_CHECKING([if setsockopt SO_NONBLOCK usage allowed])
+    if test "x$cares_disallow_setsockopt_so_nonblock" != "xyes"; then
+      AC_MSG_RESULT([yes])
+      tst_allow_setsockopt_so_nonblock="yes"
+    else
+      AC_MSG_RESULT([no])
+      tst_allow_setsockopt_so_nonblock="no"
+    fi
+  fi
+  #
+  AC_MSG_CHECKING([if setsockopt SO_NONBLOCK might be used])
+  if test "$tst_compi_setsockopt_so_nonblock" = "yes" &&
+     test "$tst_allow_setsockopt_so_nonblock" = "yes"; then
+    AC_MSG_RESULT([yes])
+    AC_DEFINE_UNQUOTED(HAVE_SETSOCKOPT_SO_NONBLOCK, 1,
+      [Define to 1 if you have a working setsockopt SO_NONBLOCK function.])
+    ac_cv_func_setsockopt_so_nonblock="yes"
+  else
+    AC_MSG_RESULT([no])
+    ac_cv_func_setsockopt_so_nonblock="no"
+  fi
+])
+
+
 dnl CARES_CHECK_FUNC_STRCASECMP
 dnl -------------------------------------------------
 dnl Verify if strcasecmp is available, prototyped, and
index 67a4c3a..ada25fc 100644 (file)
@@ -833,25 +833,6 @@ if test "$ipv6" = "yes"; then
 fi
 
 dnl **********************************************************************
-dnl Check how non-blocking sockets are set
-dnl **********************************************************************
-AC_ARG_ENABLE(nonblocking,
-AC_HELP_STRING([--enable-nonblocking],[Enable detecting how to do it])
-AC_HELP_STRING([--disable-nonblocking],[Disable non-blocking socket detection]),
-[
-  if test "$enableval" = "no" ; then
-    AC_MSG_WARN([non-blocking sockets disabled])
-    AC_DEFINE(HAVE_DISABLED_NONBLOCKING, 1,
-    [to disable NON-BLOCKING connections])
-  else
-    CURL_CHECK_NONBLOCKING_SOCKET
-  fi
-],
-[
-  CURL_CHECK_NONBLOCKING_SOCKET
-])
-
-dnl **********************************************************************
 dnl Check if the operating system allows programs to write to their own argv[]
 dnl **********************************************************************
 
@@ -2014,6 +1995,7 @@ CURL_CHECK_FUNC_SEND
 CURL_CHECK_MSG_NOSIGNAL
 
 CURL_CHECK_FUNC_ALARM
+CURL_CHECK_FUNC_FCNTL
 CURL_CHECK_FUNC_FDOPEN
 CURL_CHECK_FUNC_FREEADDRINFO
 CURL_CHECK_FUNC_FREEIFADDRS
@@ -2028,7 +2010,11 @@ CURL_CHECK_FUNC_GMTIME_R
 CURL_CHECK_FUNC_INET_NTOA_R
 CURL_CHECK_FUNC_INET_NTOP
 CURL_CHECK_FUNC_INET_PTON
+CURL_CHECK_FUNC_IOCTL
+CURL_CHECK_FUNC_IOCTLSOCKET
+CURL_CHECK_FUNC_IOCTLSOCKET_CAMEL
 CURL_CHECK_FUNC_LOCALTIME_R
+CURL_CHECK_FUNC_SETSOCKOPT
 CURL_CHECK_FUNC_SIGACTION
 CURL_CHECK_FUNC_SIGINTERRUPT
 CURL_CHECK_FUNC_SIGNAL
@@ -2170,6 +2156,15 @@ if test "$disable_poll" = "no"; then
   fi dnl poll() was found
 fi dnl poll()-check is not disabled
 
+dnl ************************************************************
+dnl enable non-blocking communications
+dnl
+CURL_CHECK_OPTION_NONBLOCKING
+CURL_CHECK_NONBLOCKING_SOCKET
+
+dnl ************************************************************
+dnl nroff tool stuff
+dnl
 
 AC_PATH_PROG( PERL, perl, ,
   $PATH:/usr/local/bin/perl:/usr/bin/:/usr/local/bin )
index 80476ef..a5e0345 100644 (file)
@@ -461,12 +461,13 @@ endif
        @echo $(DL)#define HAVE_ASSERT_H 1$(DL) >> $@
        @echo $(DL)#define HAVE_ERR_H 1$(DL) >> $@
        @echo $(DL)#define HAVE_FCNTL_H 1$(DL) >> $@
-       @echo $(DL)#define HAVE_FIONBIO 1$(DL) >> $@
        @echo $(DL)#define HAVE_GETHOSTBYADDR 1$(DL) >> $@
        @echo $(DL)#define HAVE_GETHOSTBYNAME 1$(DL) >> $@
        @echo $(DL)#define HAVE_GETPROTOBYNAME 1$(DL) >> $@
        @echo $(DL)#define HAVE_GMTIME_R 1$(DL) >> $@
        @echo $(DL)#define HAVE_INET_ADDR 1$(DL) >> $@
+       @echo $(DL)#define HAVE_IOCTL 1$(DL) >> $@
+       @echo $(DL)#define HAVE_IOCTL_FIONBIO 1$(DL) >> $@
        @echo $(DL)#define HAVE_LL 1$(DL) >> $@
        @echo $(DL)#define HAVE_LOCALE_H 1$(DL) >> $@
        @echo $(DL)#define HAVE_LOCALTIME_R 1$(DL) >> $@
index f8dc3a3..6a871d0 100644 (file)
@@ -29,7 +29,8 @@
 #define HAVE_GETHOSTBYADDR 1
 #define HAVE_INET_ADDR 1
 #define HAVE_INTTYPES_H 1
-#define HAVE_IOCTLSOCKET_CASE 1
+#define HAVE_IOCTLSOCKET_CAMEL 1
+#define HAVE_IOCTLSOCKET_CAMEL_FIONBIO 1
 #define HAVE_LIBCRYPTO 1
 #define HAVE_LIBSSL 1
 #define HAVE_LIBZ 1
index 2f4c2fb..0547aea 100644 (file)
@@ -54,7 +54,8 @@
 #define HAVE_RAND_STATUS        1
 #define HAVE_RAND_EGD           1
 
-#define HAVE_FIONBIO            1
+#define HAVE_IOCTL              1
+#define HAVE_IOCTL_FIONBIO      1
 
 #define RETSIGTYPE void
 
index 647893d..e562b3c 100644 (file)
 
 #define IOCTL_3_ARGS
 
-#define HAVE_FIONBIO
+/* Define if you have the ioctl function. */
+#define HAVE_IOCTL
+
+/* Define if you have a working ioctl FIONBIO function. */
+#define HAVE_IOCTL_FIONBIO
 
 /* to disable LDAP */
 #undef CURL_DISABLE_LDAP
index f863f63..fb1bb52 100644 (file)
 
 #define IOCTL_3_ARGS
 
-#define HAVE_FIONBIO
+/* Define if you have the ioctl function. */
+#define HAVE_IOCTL
+
+/* Define if you have a working ioctl FIONBIO function. */
+#define HAVE_IOCTL_FIONBIO
 
 /* to disable LDAP */
 #define CURL_DISABLE_LDAP
index 70c2a58..fb5dd23 100644 (file)
 /* Define to 1 if you have the <des.h> header file. */
 /* #undef HAVE_DES_H */
 
-/* disabled non-blocking sockets */
-/* #undef HAVE_DISABLED_NONBLOCKING */
-
 /* Define to 1 if you have the <dlfcn.h> header file. */
 #define HAVE_DLFCN_H 1
 
 /* Define to 1 if you have the <fcntl.h> header file. */
 #define HAVE_FCNTL_H 1
 
-/* use FIONBIO for non-blocking sockets */
-#define HAVE_FIONBIO 1
+/* Define to 1 if you have the fcntl function. */
+#define HAVE_FCNTL 1
+
+/* Define to 1 if you have a working fcntl O_NONBLOCK function. */
+#define HAVE_FCNTL_O_NONBLOCK 1
 
 /* Define to 1 if you have the `fork' function. */
 /*#define HAVE_FORK 1*/
 /* Define to 1 if you have the <inttypes.h> header file. */
 #define HAVE_INTTYPES_H 1
 
-/* use ioctlsocket() for non-blocking sockets */
+/* Define to 1 if you have the ioctl function. */
+#define HAVE_IOCTL 1
+
+/* Define to 1 if you have a working ioctl FIONBIO function. */
+#define HAVE_IOCTL_FIONBIO 1
+
+/* Define to 1 if you have the ioctlsocket function. */
 /* #undef HAVE_IOCTLSOCKET */
 
-/* use Ioctlsocket() for non-blocking sockets */
-/* #undef HAVE_IOCTLSOCKET_CASE */
+/* Define to 1 if you have a working ioctlsocket FIONBIO function. */
+/* #undef HAVE_IOCTLSOCKET_FIONBIO */
+
+/* Define to 1 if you have the IoctlSocket camel case function. */
+/* #undef HAVE_IOCTLSOCKET_CAMEL */
+
+/* Define to 1 if you have a working IoctlSocket camel case FIONBIO function. */
+/* #undef HAVE_IOCTLSOCKET_CAMEL_FIONBIO */
 
 /* Define to 1 if you have the <io.h> header file. */
 /* #undef HAVE_IO_H */
 /* Define to 1 if you have the <openssl/x509.h> header file. */
 /*#define HAVE_OPENSSL_X509_H 1*/
 
-/* use O_NONBLOCK for non-blocking sockets */
-#define HAVE_O_NONBLOCK 1
-
 /* Define to 1 if you have the <pem.h> header file. */
 /* #undef HAVE_PEM_H */
 
 /* Define to 1 if you have the `setrlimit' function. */
 /*#define HAVE_SETRLIMIT 1*/
 
+/* Define to 1 if you have the setsockopt function. */
+/* #undef HAVE_SETSOCKOPT */
+
+/* Define to 1 if you have a working setsockopt SO_NONBLOCK function. */
+/* #undef HAVE_SETSOCKOPT_SO_NONBLOCK */
+
 /* Define to 1 if you have the <sgtty.h> header file. */
 /*#define HAVE_SGTTY_H 1*/
 
 /* Define to 1 if you have the `socket' function. */
 #define HAVE_SOCKET 1
 
-/* use SO_NONBLOCK for non-blocking sockets */
-/* #undef HAVE_SO_NONBLOCK */
-
 /* Define this if you have the SPNEGO library fbopenssl */
 /* #undef HAVE_SPNEGO */
 
 /* Define if you want to enable c-ares support */
 /* #undef USE_ARES */
 
+/* Define to disable non-blocking sockets */
+/* #undef USE_BLOCKING_SOCKETS */
+
 /* if GnuTLS is enabled */
 /* #undef USE_GNUTLS */
 
index 35c44ed..67f9cbf 100644 (file)
 /* #undef HAVE_DES_H */
 #define HAVE_DES_H 1
 
-/* disabled non-blocking sockets */
-/* #undef HAVE_DISABLED_NONBLOCKING */
-
 /* Define to 1 if you have the `ENGINE_load_builtin_engines' function. */
 /* #undef HAVE_ENGINE_LOAD_BUILTIN_ENGINES */
 #define HAVE_ENGINE_LOAD_BUILTIN_ENGINES 1
 /* Define to 1 if you have the <fcntl.h> header file. */
 #define HAVE_FCNTL_H 1
 
-/* use FIONBIO for non-blocking sockets */
-/* #undef HAVE_FIONBIO */
-#define HAVE_FIONBIO 1
+/* Define to 1 if you have the fcntl function. */
+#define HAVE_FCNTL 1
+
+/* Define to 1 if you have a working fcntl O_NONBLOCK function. */
+#define HAVE_FCNTL_O_NONBLOCK 1
 
 /* Define to 1 if you have the `fork' function. */
 /* #undef HAVE_FORK */
 /* Define to 1 if you have the <inttypes.h> header file. */
 #define HAVE_INTTYPES_H 1
 
-/* use ioctlsocket() for non-blocking sockets */
+/* Define to 1 if you have the ioctl function. */
+#define HAVE_IOCTL 1
+
+/* Define to 1 if you have a working ioctl FIONBIO function. */
+#define HAVE_IOCTL_FIONBIO 1
+
+/* Define to 1 if you have the ioctlsocket function. */
 /* #undef HAVE_IOCTLSOCKET */
 
-/* use Ioctlsocket() for non-blocking sockets */
-/* #undef HAVE_IOCTLSOCKET_CASE */
+/* Define to 1 if you have a working ioctlsocket FIONBIO function. */
+/* #undef HAVE_IOCTLSOCKET_FIONBIO */
+
+/* Define to 1 if you have the IoctlSocket camel case function. */
+/* #undef HAVE_IOCTLSOCKET_CAMEL */
+
+/* Define to 1 if you have a working IoctlSocket camel case FIONBIO function. */
+/* #undef HAVE_IOCTLSOCKET_CAMEL_FIONBIO */
 
 /* Define to 1 if you have the <io.h> header file. */
 /* #undef HAVE_IO_H */
 /* #undef HAVE_OPENSSL_X509_H */
 #define HAVE_OPENSSL_X509_H 1
 
-/* use O_NONBLOCK for non-blocking sockets */
-/* #undef HAVE_O_NONBLOCK 1 */
-
 /* Define to 1 if you have the <pem.h> header file. */
 /* #undef HAVE_PEM_H */
 #define HAVE_PEM_H 1
 /* Define to 1 if you have the `setrlimit' function. */
 #define HAVE_SETRLIMIT 1
 
+/* Define to 1 if you have the setsockopt function. */
+/* #undef HAVE_SETSOCKOPT */
+
+/* Define to 1 if you have a working setsockopt SO_NONBLOCK function. */
+/* #undef HAVE_SETSOCKOPT_SO_NONBLOCK */
+
 /* Define to 1 if you have the <sgtty.h> header file. */
 /* #undef HAVE_SGTTY_H 1 */
 
 /* Define to 1 if you have the `socket' function. */
 #define HAVE_SOCKET 1
 
-/* use SO_NONBLOCK for non-blocking sockets */
-/* #undef HAVE_SO_NONBLOCK */
-
 /* Define this if you have the SPNEGO library fbopenssl */
 /* #undef HAVE_SPNEGO */
 
 /* Define if you want to enable ares support */
 /* #undef USE_ARES */
 
+/* Define to disable non-blocking sockets */
+/* #undef USE_BLOCKING_SOCKETS */
+
 /* if GnuTLS is enabled */
 /* #undef USE_GNUTLS */
 
index 88d0118..dc359d6 100644 (file)
 /* Define if you have the inet_addr function.  */
 #define HAVE_INET_ADDR 1
 
-/* Define if you have the ioctlsocket function.  */
+/* Define if you have the ioctlsocket function. */
 #define HAVE_IOCTLSOCKET 1
 
+/* Define if you have a working ioctlsocket FIONBIO function. */
+#define HAVE_IOCTLSOCKET_FIONBIO 1
+
 /* Define if you have the perror function.  */
 #define HAVE_PERROR 1
 
index b770a44..cd793d6 100644 (file)
 /* Define if you have the inet_addr function.  */
 #define HAVE_INET_ADDR 1
 
-/* Define if you have the ioctlsocket function.  */
+/* Define if you have the ioctlsocket function. */
 #define HAVE_IOCTLSOCKET 1
 
+/* Define if you have a working ioctlsocket FIONBIO function. */
+#define HAVE_IOCTLSOCKET_FIONBIO 1
+
 /* Define if you have the perror function.  */
 #define HAVE_PERROR 1
 
index 16ed9d6..361daba 100644 (file)
 
 #define HAVE_ARPA_INET_H       1
 #define HAVE_FCNTL_H           1
-#define HAVE_FIONBIO           1
 #define HAVE_GETADDRINFO       1
 #define HAVE_GETNAMEINFO       1
 #define HAVE_GETPROTOBYNAME    1
 #define HAVE_GETTIMEOFDAY      1
 #define HAVE_IO_H              1
+#define HAVE_IOCTL             1
+#define HAVE_IOCTL_FIONBIO     1
 #define HAVE_IOCTLSOCKET       1
+#define HAVE_IOCTLSOCKET_FIONBIO   1
 #define HAVE_LOCALE_H          1
 #define HAVE_LONGLONG          1
 #define HAVE_MEMORY_H          1
index 65e9be4..f2b15da 100644 (file)
@@ -59,7 +59,7 @@
 #include <stdlib.h> /* required for free() prototype, without it, this crashes */
 #endif              /* on macos 68K */
 
-#if (defined(HAVE_FIONBIO) && defined(NETWARE))
+#if (defined(HAVE_IOCTL_FIONBIO) && defined(NETWARE))
 #include <sys/filio.h>
 #endif
 #ifdef NETWARE
@@ -189,64 +189,47 @@ long Curl_timeleft(struct connectdata *conn,
 int Curl_nonblock(curl_socket_t sockfd,    /* operate on this */
                   int nonblock   /* TRUE or FALSE */)
 {
-#undef SETBLOCK
-#define SETBLOCK 0
-#ifdef HAVE_O_NONBLOCK
+#if defined(USE_BLOCKING_SOCKETS)
+
+  return 0; /* returns success */
+
+#elif defined(HAVE_FCNTL_O_NONBLOCK)
+
   /* most recent unix versions */
   int flags;
-
   flags = fcntl(sockfd, F_GETFL, 0);
   if(FALSE != nonblock)
     return fcntl(sockfd, F_SETFL, flags | O_NONBLOCK);
   else
     return fcntl(sockfd, F_SETFL, flags & (~O_NONBLOCK));
-#undef SETBLOCK
-#define SETBLOCK 1
-#endif
 
-#if defined(HAVE_FIONBIO) && (SETBLOCK == 0)
+#elif defined(HAVE_IOCTL_FIONBIO)
+
   /* older unix versions */
   int flags;
-
   flags = nonblock;
   return ioctl(sockfd, FIONBIO, &flags);
-#undef SETBLOCK
-#define SETBLOCK 2
-#endif
 
-#if defined(HAVE_IOCTLSOCKET) && (SETBLOCK == 0)
-  /* Windows? */
+#elif defined(HAVE_IOCTLSOCKET_FIONBIO)
+
+  /* Windows */
   unsigned long flags;
   flags = nonblock;
-
   return ioctlsocket(sockfd, FIONBIO, &flags);
-#undef SETBLOCK
-#define SETBLOCK 3
-#endif
 
-#if defined(HAVE_IOCTLSOCKET_CASE) && (SETBLOCK == 0)
-  /* presumably for Amiga */
+#elif defined(HAVE_IOCTLSOCKET_CAMEL_FIONBIO)
+
+  /* Amiga */
   return IoctlSocket(sockfd, FIONBIO, (long)nonblock);
-#undef SETBLOCK
-#define SETBLOCK 4
-#endif
 
-#if defined(HAVE_SO_NONBLOCK) && (SETBLOCK == 0)
+#elif defined(HAVE_SETSOCKOPT_SO_NONBLOCK)
+
   /* BeOS */
   long b = nonblock ? 1 : 0;
   return setsockopt(sockfd, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b));
-#undef SETBLOCK
-#define SETBLOCK 5
-#endif
 
-#ifdef HAVE_DISABLED_NONBLOCKING
-  return 0; /* returns success */
-#undef SETBLOCK
-#define SETBLOCK 6
-#endif
-
-#if(SETBLOCK == 0)
-#error "no non-blocking method was found/used/set"
+#else
+#  error "no non-blocking method was found/used/set"
 #endif
 }
 
index b0c1f3c..5ad3e18 100644 (file)
@@ -22,7 +22,7 @@
 #***************************************************************************
 
 # File version for 'aclocal' use. Keep it a single number.
-# serial 3
+# serial 4
 
 
 dnl CURL_CHECK_OPTION_DEBUG
@@ -58,6 +58,38 @@ AC_HELP_STRING([--disable-debug],[Disable debug build options]),
 ])
 
 
+dnl CURL_CHECK_OPTION_NONBLOCKING
+dnl -------------------------------------------------
+dnl Verify if configure has been invoked with option
+dnl --enable-nonblocking or --disable-nonblocking, and
+dnl set shell variable want_nonblocking as appropriate.
+
+AC_DEFUN([CURL_CHECK_OPTION_NONBLOCKING], [
+  AC_BEFORE([$0],[CURL_CHECK_NONBLOCKING_SOCKET])dnl
+  AC_MSG_CHECKING([whether to enable non-blocking communications])
+  OPT_NONBLOCKING="default"
+  AC_ARG_ENABLE(nonblocking,
+AC_HELP_STRING([--enable-nonblocking],[Enable non-blocking communications])
+AC_HELP_STRING([--disable-nonblocking],[Disable non-blocking communications]),
+  OPT_NONBLOCKING=$enableval)
+  case "$OPT_NONBLOCKING" in
+    no)
+      dnl --disable-nonblocking option used
+      want_nonblocking="no"
+      ;;
+    default)
+      dnl configure option not specified
+      want_nonblocking="yes"
+      ;;
+    *)
+      dnl --enable-nonblocking option used
+      want_nonblocking="yes"
+      ;;
+  esac
+  AC_MSG_RESULT([$want_nonblocking])
+])
+
+
 dnl CURL_CHECK_OPTION_OPTIMIZE
 dnl -------------------------------------------------
 dnl Verify if configure has been invoked with option
@@ -147,3 +179,42 @@ AC_HELP_STRING([--disable-warnings],[Disable strict compiler warnings]),
   AC_MSG_RESULT([$want_warnings])
 ])
 
+
+dnl CURL_CHECK_NONBLOCKING_SOCKET
+dnl -------------------------------------------------
+dnl Check for how to set a socket into non-blocking state.
+
+AC_DEFUN([CURL_CHECK_NONBLOCKING_SOCKET], [
+  AC_REQUIRE([CURL_CHECK_OPTION_NONBLOCKING])dnl
+  AC_REQUIRE([CURL_CHECK_FUNC_FCNTL])dnl
+  AC_REQUIRE([CURL_CHECK_FUNC_IOCTL])dnl
+  AC_REQUIRE([CURL_CHECK_FUNC_IOCTLSOCKET])dnl
+  AC_REQUIRE([CURL_CHECK_FUNC_IOCTLSOCKET_CAMEL])dnl
+  AC_REQUIRE([CURL_CHECK_FUNC_SETSOCKOPT])dnl
+  #
+  tst_method="unknown"
+  if test "$want_nonblocking" = "yes"; then
+    AC_MSG_CHECKING([how to set a socket into non-blocking mode])
+    if test "x$ac_cv_func_fcntl_o_nonblock" = "xyes"; then
+      tst_method="fcntl O_NONBLOCK"
+    elif test "x$ac_cv_func_ioctl_fionbio" = "xyes"; then
+      tst_method="ioctl FIONBIO"
+    elif test "x$ac_cv_func_ioctlsocket_fionbio" = "xyes"; then
+      tst_method="ioctlsocket FIONBIO"
+    elif test "x$ac_cv_func_ioctlsocket_camel_fionbio" = "xyes"; then
+      tst_method="IoctlSocket FIONBIO"
+    elif test "x$ac_cv_func_setsockopt_so_nonblock" = "xyes"; then
+      tst_method="setsockopt SO_NONBLOCK"
+    fi
+    AC_MSG_RESULT([$tst_method])
+    if test "$tst_method" = "unknown"; then
+      AC_MSG_WARN([cannot determine non-blocking socket method.])
+    fi
+  fi
+  if test "$tst_method" = "unknown"; then
+    AC_DEFINE_UNQUOTED(USE_BLOCKING_SOCKETS, 1,
+      [Define to disable non-blocking sockets.])
+    AC_MSG_WARN([non-blocking sockets disabled.])
+  fi
+])
+
index 9b0d080..118b557 100644 (file)
@@ -22,7 +22,7 @@
 #***************************************************************************
 
 # File version for 'aclocal' use. Keep it a single number.
-# serial 34
+# serial 35
 
 
 dnl CURL_INCLUDES_ARPA_INET
@@ -52,6 +52,30 @@ curl_includes_arpa_inet="\
 ])
 
 
+dnl CURL_INCLUDES_FCNTL
+dnl -------------------------------------------------
+dnl Set up variable with list of headers that must be
+dnl included when fcntl.h is to be included.
+
+AC_DEFUN([CURL_INCLUDES_FCNTL], [
+curl_includes_fcntl="\
+/* includes start */
+#ifdef HAVE_SYS_TYPES_H
+#  include <sys/types.h>
+#endif
+#ifdef HAVE_UNISTD_H
+#  include <unistd.h>
+#endif
+#ifdef HAVE_STROPTS_H
+#  include <fcntl.h>
+#endif
+/* includes end */"
+  AC_CHECK_HEADERS(
+    sys/types.h unistd.h fcntl.h,
+    [], [], [$curl_includes_fcntl])
+])
+
+
 dnl CURL_INCLUDES_IFADDRS
 dnl -------------------------------------------------
 dnl Set up variable with list of headers that must be
@@ -208,6 +232,36 @@ curl_includes_string="\
 ])
 
 
+dnl CURL_INCLUDES_STROPTS
+dnl -------------------------------------------------
+dnl Set up variable with list of headers that must be
+dnl included when stropts.h is to be included.
+
+AC_DEFUN([CURL_INCLUDES_STROPTS], [
+curl_includes_stropts="\
+/* includes start */
+#ifdef HAVE_SYS_TYPES_H
+#  include <sys/types.h>
+#endif
+#ifdef HAVE_UNISTD_H
+#  include <unistd.h>
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+#  include <sys/socket.h>
+#endif
+#ifdef HAVE_SYS_IOCTL_H
+#  include <sys/ioctl.h>
+#endif
+#ifdef HAVE_STROPTS_H
+#  include <stropts.h>
+#endif
+/* includes end */"
+  AC_CHECK_HEADERS(
+    sys/types.h unistd.h sys/socket.h sys/ioctl.h stropts.h,
+    [], [], [$curl_includes_stropts])
+])
+
+
 dnl CURL_INCLUDES_SYS_SOCKET
 dnl -------------------------------------------------
 dnl Set up variable with list of headers that must be
@@ -440,6 +494,155 @@ AC_DEFUN([CURL_CHECK_FUNC_ALARM], [
 ])
 
 
+dnl CURL_CHECK_FUNC_FCNTL
+dnl -------------------------------------------------
+dnl Verify if fcntl is available, prototyped, and
+dnl can be compiled. If all of these are true, and
+dnl usage has not been previously disallowed with
+dnl shell variable curl_disallow_fcntl, then
+dnl HAVE_FCNTL will be defined.
+
+AC_DEFUN([CURL_CHECK_FUNC_FCNTL], [
+  AC_REQUIRE([CURL_INCLUDES_FCNTL])dnl
+  #
+  tst_links_fcntl="unknown"
+  tst_proto_fcntl="unknown"
+  tst_compi_fcntl="unknown"
+  tst_allow_fcntl="unknown"
+  #
+  AC_MSG_CHECKING([if fcntl can be linked])
+  AC_LINK_IFELSE([
+    AC_LANG_FUNC_LINK_TRY([fcntl])
+  ],[
+    AC_MSG_RESULT([yes])
+    tst_links_fcntl="yes"
+  ],[
+    AC_MSG_RESULT([no])
+    tst_links_fcntl="no"
+  ])
+  #
+  if test "$tst_links_fcntl" = "yes"; then
+    AC_MSG_CHECKING([if fcntl is prototyped])
+    AC_EGREP_CPP([fcntl],[
+      $curl_includes_fcntl
+    ],[
+      AC_MSG_RESULT([yes])
+      tst_proto_fcntl="yes"
+    ],[
+      AC_MSG_RESULT([no])
+      tst_proto_fcntl="no"
+    ])
+  fi
+  #
+  if test "$tst_proto_fcntl" = "yes"; then
+    AC_MSG_CHECKING([if fcntl is compilable])
+    AC_COMPILE_IFELSE([
+      AC_LANG_PROGRAM([[
+        $curl_includes_fcntl
+      ]],[[
+        if(0 != fcntl(0, 0, 0))
+          return 1;
+      ]])
+    ],[
+      AC_MSG_RESULT([yes])
+      tst_compi_fcntl="yes"
+    ],[
+      AC_MSG_RESULT([no])
+      tst_compi_fcntl="no"
+    ])
+  fi
+  #
+  if test "$tst_compi_fcntl" = "yes"; then
+    AC_MSG_CHECKING([if fcntl usage allowed])
+    if test "x$curl_disallow_fcntl" != "xyes"; then
+      AC_MSG_RESULT([yes])
+      tst_allow_fcntl="yes"
+    else
+      AC_MSG_RESULT([no])
+      tst_allow_fcntl="no"
+    fi
+  fi
+  #
+  AC_MSG_CHECKING([if fcntl might be used])
+  if test "$tst_links_fcntl" = "yes" &&
+     test "$tst_proto_fcntl" = "yes" &&
+     test "$tst_compi_fcntl" = "yes" &&
+     test "$tst_allow_fcntl" = "yes"; then
+    AC_MSG_RESULT([yes])
+    AC_DEFINE_UNQUOTED(HAVE_FCNTL, 1,
+      [Define to 1 if you have the fcntl function.])
+    ac_cv_func_fcntl="yes"
+    CURL_CHECK_FUNC_FCNTL_O_NONBLOCK
+  else
+    AC_MSG_RESULT([no])
+    ac_cv_func_fcntl="no"
+  fi
+])
+
+
+dnl CURL_CHECK_FUNC_FCNTL_O_NONBLOCK
+dnl -------------------------------------------------
+dnl Verify if fcntl with status flag O_NONBLOCK is
+dnl available, can be compiled, and seems to work. If
+dnl all of these are true, then HAVE_FCNTL_O_NONBLOCK
+dnl will be defined.
+
+AC_DEFUN([CURL_CHECK_FUNC_FCNTL_O_NONBLOCK], [
+  #
+  tst_compi_fcntl_o_nonblock="unknown"
+  tst_allow_fcntl_o_nonblock="unknown"
+  #
+  case $host_os in
+    sunos4* | aix3* | beos*)
+      dnl O_NONBLOCK does not work on these platforms
+      curl_disallow_fcntl_o_nonblock="yes"
+      ;;
+  esac
+  #
+  if test "$ac_cv_func_fcntl" = "yes"; then
+    AC_MSG_CHECKING([if fcntl O_NONBLOCK is compilable])
+    AC_COMPILE_IFELSE([
+      AC_LANG_PROGRAM([[
+        $curl_includes_fcntl
+      ]],[[
+        int flags = 0;
+        if(0 != fcntl(0, F_SETFL, flags | O_NONBLOCK))
+          return 1;
+      ]])
+    ],[
+      AC_MSG_RESULT([yes])
+      tst_compi_fcntl_o_nonblock="yes"
+    ],[
+      AC_MSG_RESULT([no])
+      tst_compi_fcntl_o_nonblock="no"
+    ])
+  fi
+  #
+  if test "$tst_compi_fcntl_o_nonblock" = "yes"; then
+    AC_MSG_CHECKING([if fcntl O_NONBLOCK usage allowed])
+    if test "x$curl_disallow_fcntl_o_nonblock" != "xyes"; then
+      AC_MSG_RESULT([yes])
+      tst_allow_fcntl_o_nonblock="yes"
+    else
+      AC_MSG_RESULT([no])
+      tst_allow_fcntl_o_nonblock="no"
+    fi
+  fi
+  #
+  AC_MSG_CHECKING([if fcntl O_NONBLOCK might be used])
+  if test "$tst_compi_fcntl_o_nonblock" = "yes" &&
+     test "$tst_allow_fcntl_o_nonblock" = "yes"; then
+    AC_MSG_RESULT([yes])
+    AC_DEFINE_UNQUOTED(HAVE_FCNTL_O_NONBLOCK, 1,
+      [Define to 1 if you have a working fcntl O_NONBLOCK function.])
+    ac_cv_func_fcntl_o_nonblock="yes"
+  else
+    AC_MSG_RESULT([no])
+    ac_cv_func_fcntl_o_nonblock="no"
+  fi
+])
+
+
 dnl CURL_CHECK_FUNC_FDOPEN
 dnl -------------------------------------------------
 dnl Verify if fdopen is available, prototyped, and
@@ -2120,6 +2323,436 @@ AC_DEFUN([CURL_CHECK_FUNC_INET_PTON], [
 ])
 
 
+dnl CURL_CHECK_FUNC_IOCTL
+dnl -------------------------------------------------
+dnl Verify if ioctl is available, prototyped, and
+dnl can be compiled. If all of these are true, and
+dnl usage has not been previously disallowed with
+dnl shell variable curl_disallow_ioctl, then
+dnl HAVE_IOCTL will be defined.
+
+AC_DEFUN([CURL_CHECK_FUNC_IOCTL], [
+  AC_REQUIRE([CURL_INCLUDES_STROPTS])dnl
+  #
+  tst_links_ioctl="unknown"
+  tst_proto_ioctl="unknown"
+  tst_compi_ioctl="unknown"
+  tst_allow_ioctl="unknown"
+  #
+  AC_MSG_CHECKING([if ioctl can be linked])
+  AC_LINK_IFELSE([
+    AC_LANG_FUNC_LINK_TRY([ioctl])
+  ],[
+    AC_MSG_RESULT([yes])
+    tst_links_ioctl="yes"
+  ],[
+    AC_MSG_RESULT([no])
+    tst_links_ioctl="no"
+  ])
+  #
+  if test "$tst_links_ioctl" = "yes"; then
+    AC_MSG_CHECKING([if ioctl is prototyped])
+    AC_EGREP_CPP([ioctl],[
+      $curl_includes_stropts
+    ],[
+      AC_MSG_RESULT([yes])
+      tst_proto_ioctl="yes"
+    ],[
+      AC_MSG_RESULT([no])
+      tst_proto_ioctl="no"
+    ])
+  fi
+  #
+  if test "$tst_proto_ioctl" = "yes"; then
+    AC_MSG_CHECKING([if ioctl is compilable])
+    AC_COMPILE_IFELSE([
+      AC_LANG_PROGRAM([[
+        $curl_includes_stropts
+      ]],[[
+        if(0 != ioctl(0, 0, 0))
+          return 1;
+      ]])
+    ],[
+      AC_MSG_RESULT([yes])
+      tst_compi_ioctl="yes"
+    ],[
+      AC_MSG_RESULT([no])
+      tst_compi_ioctl="no"
+    ])
+  fi
+  #
+  if test "$tst_compi_ioctl" = "yes"; then
+    AC_MSG_CHECKING([if ioctl usage allowed])
+    if test "x$curl_disallow_ioctl" != "xyes"; then
+      AC_MSG_RESULT([yes])
+      tst_allow_ioctl="yes"
+    else
+      AC_MSG_RESULT([no])
+      tst_allow_ioctl="no"
+    fi
+  fi
+  #
+  AC_MSG_CHECKING([if ioctl might be used])
+  if test "$tst_links_ioctl" = "yes" &&
+     test "$tst_proto_ioctl" = "yes" &&
+     test "$tst_compi_ioctl" = "yes" &&
+     test "$tst_allow_ioctl" = "yes"; then
+    AC_MSG_RESULT([yes])
+    AC_DEFINE_UNQUOTED(HAVE_IOCTL, 1,
+      [Define to 1 if you have the ioctl function.])
+    ac_cv_func_ioctl="yes"
+    CURL_CHECK_FUNC_IOCTL_FIONBIO
+  else
+    AC_MSG_RESULT([no])
+    ac_cv_func_ioctl="no"
+  fi
+])
+
+
+dnl CURL_CHECK_FUNC_IOCTL_FIONBIO
+dnl -------------------------------------------------
+dnl Verify if ioctl with the FIONBIO command is
+dnl available, can be compiled, and seems to work. If
+dnl all of these are true, then HAVE_IOCTL_FIONBIO
+dnl will be defined.
+
+AC_DEFUN([CURL_CHECK_FUNC_IOCTL_FIONBIO], [
+  #
+  tst_compi_ioctl_fionbio="unknown"
+  tst_allow_ioctl_fionbio="unknown"
+  #
+  if test "$ac_cv_func_ioctl" = "yes"; then
+    AC_MSG_CHECKING([if ioctl FIONBIO is compilable])
+    AC_COMPILE_IFELSE([
+      AC_LANG_PROGRAM([[
+        $curl_includes_stropts
+      ]],[[
+        int flags = 0;
+        if(0 != ioctl(0, FIONBIO, &flags))
+          return 1;
+      ]])
+    ],[
+      AC_MSG_RESULT([yes])
+      tst_compi_ioctl_fionbio="yes"
+    ],[
+      AC_MSG_RESULT([no])
+      tst_compi_ioctl_fionbio="no"
+    ])
+  fi
+  #
+  if test "$tst_compi_ioctl_fionbio" = "yes"; then
+    AC_MSG_CHECKING([if ioctl FIONBIO usage allowed])
+    if test "x$curl_disallow_ioctl_fionbio" != "xyes"; then
+      AC_MSG_RESULT([yes])
+      tst_allow_ioctl_fionbio="yes"
+    else
+      AC_MSG_RESULT([no])
+      tst_allow_ioctl_fionbio="no"
+    fi
+  fi
+  #
+  AC_MSG_CHECKING([if ioctl FIONBIO might be used])
+  if test "$tst_compi_ioctl_fionbio" = "yes" &&
+     test "$tst_allow_ioctl_fionbio" = "yes"; then
+    AC_MSG_RESULT([yes])
+    AC_DEFINE_UNQUOTED(HAVE_IOCTL_FIONBIO, 1,
+      [Define to 1 if you have a working ioctl FIONBIO function.])
+    ac_cv_func_ioctl_fionbio="yes"
+  else
+    AC_MSG_RESULT([no])
+    ac_cv_func_ioctl_fionbio="no"
+  fi
+])
+
+
+dnl CURL_CHECK_FUNC_IOCTLSOCKET
+dnl -------------------------------------------------
+dnl Verify if ioctlsocket is available, prototyped, and
+dnl can be compiled. If all of these are true, and
+dnl usage has not been previously disallowed with
+dnl shell variable curl_disallow_ioctlsocket, then
+dnl HAVE_IOCTLSOCKET will be defined.
+
+AC_DEFUN([CURL_CHECK_FUNC_IOCTLSOCKET], [
+  AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
+  #
+  tst_links_ioctlsocket="unknown"
+  tst_proto_ioctlsocket="unknown"
+  tst_compi_ioctlsocket="unknown"
+  tst_allow_ioctlsocket="unknown"
+  #
+  AC_MSG_CHECKING([if ioctlsocket can be linked])
+  AC_LINK_IFELSE([
+    AC_LANG_PROGRAM([[
+      $curl_includes_winsock2
+    ]],[[
+      if(0 != ioctlsocket(0, 0, 0))
+        return 1;
+    ]])
+  ],[
+    AC_MSG_RESULT([yes])
+    tst_links_ioctlsocket="yes"
+  ],[
+    AC_MSG_RESULT([no])
+    tst_links_ioctlsocket="no"
+  ])
+  #
+  if test "$tst_links_ioctlsocket" = "yes"; then
+    AC_MSG_CHECKING([if ioctlsocket is prototyped])
+    AC_EGREP_CPP([ioctlsocket],[
+      $curl_includes_winsock2
+    ],[
+      AC_MSG_RESULT([yes])
+      tst_proto_ioctlsocket="yes"
+    ],[
+      AC_MSG_RESULT([no])
+      tst_proto_ioctlsocket="no"
+    ])
+  fi
+  #
+  if test "$tst_proto_ioctlsocket" = "yes"; then
+    AC_MSG_CHECKING([if ioctlsocket is compilable])
+    AC_COMPILE_IFELSE([
+      AC_LANG_PROGRAM([[
+        $curl_includes_winsock2
+      ]],[[
+        if(0 != ioctlsocket(0, 0, 0))
+          return 1;
+      ]])
+    ],[
+      AC_MSG_RESULT([yes])
+      tst_compi_ioctlsocket="yes"
+    ],[
+      AC_MSG_RESULT([no])
+      tst_compi_ioctlsocket="no"
+    ])
+  fi
+  #
+  if test "$tst_compi_ioctlsocket" = "yes"; then
+    AC_MSG_CHECKING([if ioctlsocket usage allowed])
+    if test "x$curl_disallow_ioctlsocket" != "xyes"; then
+      AC_MSG_RESULT([yes])
+      tst_allow_ioctlsocket="yes"
+    else
+      AC_MSG_RESULT([no])
+      tst_allow_ioctlsocket="no"
+    fi
+  fi
+  #
+  AC_MSG_CHECKING([if ioctlsocket might be used])
+  if test "$tst_links_ioctlsocket" = "yes" &&
+     test "$tst_proto_ioctlsocket" = "yes" &&
+     test "$tst_compi_ioctlsocket" = "yes" &&
+     test "$tst_allow_ioctlsocket" = "yes"; then
+    AC_MSG_RESULT([yes])
+    AC_DEFINE_UNQUOTED(HAVE_IOCTLSOCKET, 1,
+      [Define to 1 if you have the ioctlsocket function.])
+    ac_cv_func_ioctlsocket="yes"
+    CURL_CHECK_FUNC_IOCTLSOCKET_FIONBIO
+  else
+    AC_MSG_RESULT([no])
+    ac_cv_func_ioctlsocket="no"
+  fi
+])
+
+
+dnl CURL_CHECK_FUNC_IOCTLSOCKET_FIONBIO
+dnl -------------------------------------------------
+dnl Verify if ioctlsocket with the FIONBIO command is
+dnl available, can be compiled, and seems to work. If
+dnl all of these are true, then HAVE_IOCTLSOCKET_FIONBIO
+dnl will be defined.
+
+AC_DEFUN([CURL_CHECK_FUNC_IOCTLSOCKET_FIONBIO], [
+  #
+  tst_compi_ioctlsocket_fionbio="unknown"
+  tst_allow_ioctlsocket_fionbio="unknown"
+  #
+  if test "$ac_cv_func_ioctlsocket" = "yes"; then
+    AC_MSG_CHECKING([if ioctlsocket FIONBIO is compilable])
+    AC_COMPILE_IFELSE([
+      AC_LANG_PROGRAM([[
+        $curl_includes_winsock2
+      ]],[[
+        int flags = 0;
+        if(0 != ioctlsocket(0, FIONBIO, &flags))
+          return 1;
+      ]])
+    ],[
+      AC_MSG_RESULT([yes])
+      tst_compi_ioctlsocket_fionbio="yes"
+    ],[
+      AC_MSG_RESULT([no])
+      tst_compi_ioctlsocket_fionbio="no"
+    ])
+  fi
+  #
+  if test "$tst_compi_ioctlsocket_fionbio" = "yes"; then
+    AC_MSG_CHECKING([if ioctlsocket FIONBIO usage allowed])
+    if test "x$curl_disallow_ioctlsocket_fionbio" != "xyes"; then
+      AC_MSG_RESULT([yes])
+      tst_allow_ioctlsocket_fionbio="yes"
+    else
+      AC_MSG_RESULT([no])
+      tst_allow_ioctlsocket_fionbio="no"
+    fi
+  fi
+  #
+  AC_MSG_CHECKING([if ioctlsocket FIONBIO might be used])
+  if test "$tst_compi_ioctlsocket_fionbio" = "yes" &&
+     test "$tst_allow_ioctlsocket_fionbio" = "yes"; then
+    AC_MSG_RESULT([yes])
+    AC_DEFINE_UNQUOTED(HAVE_IOCTLSOCKET_FIONBIO, 1,
+      [Define to 1 if you have a working ioctlsocket FIONBIO function.])
+    ac_cv_func_ioctlsocket_fionbio="yes"
+  else
+    AC_MSG_RESULT([no])
+    ac_cv_func_ioctlsocket_fionbio="no"
+  fi
+])
+
+
+dnl CURL_CHECK_FUNC_IOCTLSOCKET_CAMEL
+dnl -------------------------------------------------
+dnl Verify if IoctlSocket is available, prototyped, and
+dnl can be compiled. If all of these are true, and
+dnl usage has not been previously disallowed with
+dnl shell variable curl_disallow_ioctlsocket_camel,
+dnl then HAVE_IOCTLSOCKET_CAMEL will be defined.
+
+AC_DEFUN([CURL_CHECK_FUNC_IOCTLSOCKET_CAMEL], [
+  AC_REQUIRE([CURL_INCLUDES_STROPTS])dnl
+  #
+  tst_links_ioctlsocket_camel="unknown"
+  tst_proto_ioctlsocket_camel="unknown"
+  tst_compi_ioctlsocket_camel="unknown"
+  tst_allow_ioctlsocket_camel="unknown"
+  #
+  AC_MSG_CHECKING([if IoctlSocket can be linked])
+  AC_LINK_IFELSE([
+    AC_LANG_FUNC_LINK_TRY([IoctlSocket])
+  ],[
+    AC_MSG_RESULT([yes])
+    tst_links_ioctlsocket_camel="yes"
+  ],[
+    AC_MSG_RESULT([no])
+    tst_links_ioctlsocket_camel="no"
+  ])
+  #
+  if test "$tst_links_ioctlsocket_camel" = "yes"; then
+    AC_MSG_CHECKING([if IoctlSocket is prototyped])
+    AC_EGREP_CPP([IoctlSocket],[
+      $curl_includes_stropts
+    ],[
+      AC_MSG_RESULT([yes])
+      tst_proto_ioctlsocket_camel="yes"
+    ],[
+      AC_MSG_RESULT([no])
+      tst_proto_ioctlsocket_camel="no"
+    ])
+  fi
+  #
+  if test "$tst_proto_ioctlsocket_camel" = "yes"; then
+    AC_MSG_CHECKING([if IoctlSocket is compilable])
+    AC_COMPILE_IFELSE([
+      AC_LANG_PROGRAM([[
+        $curl_includes_stropts
+      ]],[[
+        if(0 != IoctlSocket(0, 0, 0))
+          return 1;
+      ]])
+    ],[
+      AC_MSG_RESULT([yes])
+      tst_compi_ioctlsocket_camel="yes"
+    ],[
+      AC_MSG_RESULT([no])
+      tst_compi_ioctlsocket_camel="no"
+    ])
+  fi
+  #
+  if test "$tst_compi_ioctlsocket_camel" = "yes"; then
+    AC_MSG_CHECKING([if IoctlSocket usage allowed])
+    if test "x$curl_disallow_ioctlsocket_camel" != "xyes"; then
+      AC_MSG_RESULT([yes])
+      tst_allow_ioctlsocket_camel="yes"
+    else
+      AC_MSG_RESULT([no])
+      tst_allow_ioctlsocket_camel="no"
+    fi
+  fi
+  #
+  AC_MSG_CHECKING([if IoctlSocket might be used])
+  if test "$tst_links_ioctlsocket_camel" = "yes" &&
+     test "$tst_proto_ioctlsocket_camel" = "yes" &&
+     test "$tst_compi_ioctlsocket_camel" = "yes" &&
+     test "$tst_allow_ioctlsocket_camel" = "yes"; then
+    AC_MSG_RESULT([yes])
+    AC_DEFINE_UNQUOTED(HAVE_IOCTLSOCKET_CAMEL, 1,
+      [Define to 1 if you have the IoctlSocket camel case function.])
+    ac_cv_func_ioctlsocket_camel="yes"
+    CURL_CHECK_FUNC_IOCTLSOCKET_CAMEL_FIONBIO
+  else
+    AC_MSG_RESULT([no])
+    ac_cv_func_ioctlsocket_camel="no"
+  fi
+])
+
+
+dnl CURL_CHECK_FUNC_IOCTLSOCKET_CAMEL_FIONBIO
+dnl -------------------------------------------------
+dnl Verify if IoctlSocket with FIONBIO command is available,
+dnl can be compiled, and seems to work. If all of these are
+dnl true, then HAVE_IOCTLSOCKET_CAMEL_FIONBIO will be defined.
+
+AC_DEFUN([CURL_CHECK_FUNC_IOCTLSOCKET_CAMEL_FIONBIO], [
+  #
+  tst_compi_ioctlsocket_camel_fionbio="unknown"
+  tst_allow_ioctlsocket_camel_fionbio="unknown"
+  #
+  if test "$ac_cv_func_ioctlsocket_camel" = "yes"; then
+    AC_MSG_CHECKING([if IoctlSocket FIONBIO is compilable])
+    AC_COMPILE_IFELSE([
+      AC_LANG_PROGRAM([[
+        $curl_includes_stropts
+      ]],[[
+        long flags = 0;
+        if(0 != ioctlsocket(0, FIONBIO, &flags))
+          return 1;
+      ]])
+    ],[
+      AC_MSG_RESULT([yes])
+      tst_compi_ioctlsocket_camel_fionbio="yes"
+    ],[
+      AC_MSG_RESULT([no])
+      tst_compi_ioctlsocket_camel_fionbio="no"
+    ])
+  fi
+  #
+  if test "$tst_compi_ioctlsocket_camel_fionbio" = "yes"; then
+    AC_MSG_CHECKING([if IoctlSocket FIONBIO usage allowed])
+    if test "x$curl_disallow_ioctlsocket_camel_fionbio" != "xyes"; then
+      AC_MSG_RESULT([yes])
+      tst_allow_ioctlsocket_camel_fionbio="yes"
+    else
+      AC_MSG_RESULT([no])
+      tst_allow_ioctlsocket_camel_fionbio="no"
+    fi
+  fi
+  #
+  AC_MSG_CHECKING([if IoctlSocket FIONBIO might be used])
+  if test "$tst_compi_ioctlsocket_camel_fionbio" = "yes" &&
+     test "$tst_allow_ioctlsocket_camel_fionbio" = "yes"; then
+    AC_MSG_RESULT([yes])
+    AC_DEFINE_UNQUOTED(HAVE_IOCTLSOCKET_CAMEL_FIONBIO, 1,
+      [Define to 1 if you have a working IoctlSocket camel case FIONBIO function.])
+    ac_cv_func_ioctlsocket_camel_fionbio="yes"
+  else
+    AC_MSG_RESULT([no])
+    ac_cv_func_ioctlsocket_camel_fionbio="no"
+  fi
+])
+
+
 dnl CURL_CHECK_FUNC_LOCALTIME_R
 dnl -------------------------------------------------
 dnl Verify if localtime_r is available, prototyped, can
@@ -2236,6 +2869,157 @@ AC_DEFUN([CURL_CHECK_FUNC_LOCALTIME_R], [
 ])
 
 
+dnl CURL_CHECK_FUNC_SETSOCKOPT
+dnl -------------------------------------------------
+dnl Verify if setsockopt is available, prototyped, and
+dnl can be compiled. If all of these are true, and
+dnl usage has not been previously disallowed with
+dnl shell variable curl_disallow_setsockopt, then
+dnl HAVE_SETSOCKOPT will be defined.
+
+AC_DEFUN([CURL_CHECK_FUNC_SETSOCKOPT], [
+  AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
+  AC_REQUIRE([CURL_INCLUDES_SYS_SOCKET])dnl
+  #
+  tst_links_setsockopt="unknown"
+  tst_proto_setsockopt="unknown"
+  tst_compi_setsockopt="unknown"
+  tst_allow_setsockopt="unknown"
+  #
+  AC_MSG_CHECKING([if setsockopt can be linked])
+  AC_LINK_IFELSE([
+    AC_LANG_PROGRAM([[
+      $curl_includes_winsock2
+      $curl_includes_sys_socket
+    ]],[[
+      if(0 != setsockopt(0, 0, 0, 0, 0))
+        return 1;
+    ]])
+  ],[
+    AC_MSG_RESULT([yes])
+    tst_links_setsockopt="yes"
+  ],[
+    AC_MSG_RESULT([no])
+    tst_links_setsockopt="no"
+  ])
+  #
+  if test "$tst_links_setsockopt" = "yes"; then
+    AC_MSG_CHECKING([if setsockopt is prototyped])
+    AC_EGREP_CPP([setsockopt],[
+      $curl_includes_winsock2
+      $curl_includes_sys_socket
+    ],[
+      AC_MSG_RESULT([yes])
+      tst_proto_setsockopt="yes"
+    ],[
+      AC_MSG_RESULT([no])
+      tst_proto_setsockopt="no"
+    ])
+  fi
+  #
+  if test "$tst_proto_setsockopt" = "yes"; then
+    AC_MSG_CHECKING([if setsockopt is compilable])
+    AC_COMPILE_IFELSE([
+      AC_LANG_PROGRAM([[
+        $curl_includes_winsock2
+        $curl_includes_sys_socket
+      ]],[[
+        if(0 != setsockopt(0, 0, 0, 0, 0))
+          return 1;
+      ]])
+    ],[
+      AC_MSG_RESULT([yes])
+      tst_compi_setsockopt="yes"
+    ],[
+      AC_MSG_RESULT([no])
+      tst_compi_setsockopt="no"
+    ])
+  fi
+  #
+  if test "$tst_compi_setsockopt" = "yes"; then
+    AC_MSG_CHECKING([if setsockopt usage allowed])
+    if test "x$curl_disallow_setsockopt" != "xyes"; then
+      AC_MSG_RESULT([yes])
+      tst_allow_setsockopt="yes"
+    else
+      AC_MSG_RESULT([no])
+      tst_allow_setsockopt="no"
+    fi
+  fi
+  #
+  AC_MSG_CHECKING([if setsockopt might be used])
+  if test "$tst_links_setsockopt" = "yes" &&
+     test "$tst_proto_setsockopt" = "yes" &&
+     test "$tst_compi_setsockopt" = "yes" &&
+     test "$tst_allow_setsockopt" = "yes"; then
+    AC_MSG_RESULT([yes])
+    AC_DEFINE_UNQUOTED(HAVE_SETSOCKOPT, 1,
+      [Define to 1 if you have the setsockopt function.])
+    ac_cv_func_setsockopt="yes"
+    CURL_CHECK_FUNC_SETSOCKOPT_SO_NONBLOCK
+  else
+    AC_MSG_RESULT([no])
+    ac_cv_func_setsockopt="no"
+  fi
+])
+
+
+dnl CURL_CHECK_FUNC_SETSOCKOPT_SO_NONBLOCK
+dnl -------------------------------------------------
+dnl Verify if setsockopt with the SO_NONBLOCK command is
+dnl available, can be compiled, and seems to work. If
+dnl all of these are true, then HAVE_SETSOCKOPT_SO_NONBLOCK
+dnl will be defined.
+
+AC_DEFUN([CURL_CHECK_FUNC_SETSOCKOPT_SO_NONBLOCK], [
+  #
+  tst_compi_setsockopt_so_nonblock="unknown"
+  tst_allow_setsockopt_so_nonblock="unknown"
+  #
+  if test "$ac_cv_func_setsockopt" = "yes"; then
+    AC_MSG_CHECKING([if setsockopt SO_NONBLOCK is compilable])
+    AC_COMPILE_IFELSE([
+      AC_LANG_PROGRAM([[
+        $curl_includes_winsock2
+        $curl_includes_sys_socket
+      ]],[[
+        if(0 != setsockopt(0, SOL_SOCKET, SO_NONBLOCK, 0, 0))
+          return 1;
+      ]])
+    ],[
+      AC_MSG_RESULT([yes])
+      tst_compi_setsockopt_so_nonblock="yes"
+    ],[
+      AC_MSG_RESULT([no])
+      tst_compi_setsockopt_so_nonblock="no"
+    ])
+  fi
+  #
+  if test "$tst_compi_setsockopt_so_nonblock" = "yes"; then
+    AC_MSG_CHECKING([if setsockopt SO_NONBLOCK usage allowed])
+    if test "x$curl_disallow_setsockopt_so_nonblock" != "xyes"; then
+      AC_MSG_RESULT([yes])
+      tst_allow_setsockopt_so_nonblock="yes"
+    else
+      AC_MSG_RESULT([no])
+      tst_allow_setsockopt_so_nonblock="no"
+    fi
+  fi
+  #
+  AC_MSG_CHECKING([if setsockopt SO_NONBLOCK might be used])
+  if test "$tst_compi_setsockopt_so_nonblock" = "yes" &&
+     test "$tst_allow_setsockopt_so_nonblock" = "yes"; then
+    AC_MSG_RESULT([yes])
+    AC_DEFINE_UNQUOTED(HAVE_SETSOCKOPT_SO_NONBLOCK, 1,
+      [Define to 1 if you have a working setsockopt SO_NONBLOCK function.])
+    ac_cv_func_setsockopt_so_nonblock="yes"
+  else
+    AC_MSG_RESULT([no])
+    ac_cv_func_setsockopt_so_nonblock="no"
+  fi
+])
+
+
 dnl CURL_CHECK_FUNC_SIGACTION
 dnl -------------------------------------------------
 dnl Verify if sigaction is available, prototyped, and
index 7efbc3c..fe51c9a 100644 (file)
 /* Define if you have the inet_addr function.  */
 #define HAVE_INET_ADDR 1
 
+/* Define if you have the ioctl function. */
+#define HAVE_IOCTL 1
+
+/* Define if you have a working ioctl FIONBIO function. */
+#define HAVE_IOCTL_FIONBIO 1
+
 /* Define if you have the perror function.  */
 #define HAVE_PERROR 1
 
 /* Define if you have the <memory.h> header file. */
 #define HAVE_MEMORY_H   1
 
-#define HAVE_FIONBIO   1
-
 /* Define if you have the `sigsetjmp' function. */
 #define HAVE_SIGSETJMP 1
 
index 1ec0b82..6b02935 100644 (file)
@@ -449,12 +449,13 @@ endif
        @echo $(DL)#define HAVE_ASSERT_H 1$(DL) >> $@
        @echo $(DL)#define HAVE_ERR_H 1$(DL) >> $@
        @echo $(DL)#define HAVE_FCNTL_H 1$(DL) >> $@
-       @echo $(DL)#define HAVE_FIONBIO 1$(DL) >> $@
        @echo $(DL)#define HAVE_GETHOSTBYADDR 1$(DL) >> $@
        @echo $(DL)#define HAVE_GETHOSTBYNAME 1$(DL) >> $@
        @echo $(DL)#define HAVE_GETPROTOBYNAME 1$(DL) >> $@
        @echo $(DL)#define HAVE_GMTIME_R 1$(DL) >> $@
        @echo $(DL)#define HAVE_INET_ADDR 1$(DL) >> $@
+       @echo $(DL)#define HAVE_IOCTL 1$(DL) >> $@
+       @echo $(DL)#define HAVE_IOCTL_FIONBIO 1$(DL) >> $@
        @echo $(DL)#define HAVE_LL 1$(DL) >> $@
        @echo $(DL)#define HAVE_LOCALE_H 1$(DL) >> $@
        @echo $(DL)#define HAVE_LOCALTIME_R 1$(DL) >> $@
index bb27a0d..dc5a4c7 100644 (file)
 
 #define IOCTL_3_ARGS
 
-#define HAVE_FIONBIO
+/* Define if you have the ioctl function. */
+#define HAVE_IOCTL
 
+/* Define if you have a working ioctl FIONBIO function. */
+#define HAVE_IOCTL_FIONBIO
index 8b18bd5..337d4e7 100644 (file)
 /*                             FUNCTIONS                            */
 /* ---------------------------------------------------------------- */
 
-/* Define if you have the setmode function. */
-#define HAVE_SETMODE 1
-
 /* Define if you have the ftruncate function.  */
 #define HAVE_FTRUNCATE 1
 
+/* Define if you have the ioctlsocket function. */
+#define HAVE_IOCTLSOCKET 1
+
+/* Define if you have a working ioctlsocket FIONBIO function. */
+#define HAVE_IOCTLSOCKET_FIONBIO 1
+
 /* Define if you have the setlocale function.  */
 #define HAVE_SETLOCALE 1
 
+/* Define if you have the setmode function. */
+#define HAVE_SETMODE 1
+
 /* Define if you have the strcasecmp function. */
 /* #define HAVE_STRCASECMP 1 */