+dnl CURL_CHECK_LIBS_CONNECT
+dnl -------------------------------------------------
+dnl Verify if network connect function is already available
+dnl using current libraries or if another one is required.
+
+AC_DEFUN([CURL_CHECK_LIBS_CONNECT], [
+ AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
+ AC_MSG_CHECKING([for connect in libraries])
+ tst_connect_save_LIBS="$LIBS"
+ tst_connect_need_LIBS="unknown"
+ for tst_lib in '' '-lsocket' ; do
+ if test "$tst_connect_need_LIBS" = "unknown"; then
+ LIBS="$tst_lib $tst_connect_save_LIBS"
+ AC_LINK_IFELSE([
+ AC_LANG_PROGRAM([[
+ $curl_includes_winsock2
+ #ifndef HAVE_WINDOWS_H
+ int connect(int, void*, int);
+ #endif
+ ]],[[
+ if(0 != connect(0, 0, 0))
+ return 1;
+ ]])
+ ],[
+ tst_connect_need_LIBS="$tst_lib"
+ ])
+ fi
+ done
+ LIBS="$tst_connect_save_LIBS"
+ #
+ case X-"$tst_connect_need_LIBS" in
+ X-unknown)
+ AC_MSG_RESULT([cannot find connect])
+ AC_MSG_ERROR([cannot find connect function in libraries.])
+ ;;
+ X-)
+ AC_MSG_RESULT([yes])
+ ;;
+ *)
+ AC_MSG_RESULT([$tst_connect_need_LIBS])
+ LIBS="$tst_connect_need_LIBS $tst_connect_save_LIBS"
+ ;;
+ esac
+])
+
+
+dnl CURL_DEFINE_UNQUOTED (VARIABLE, [VALUE])
+dnl -------------------------------------------------
+dnl Like AC_DEFINE_UNQUOTED this macro will define a C preprocessor
+dnl symbol that can be further used in custom template configuration
+dnl files. This macro, unlike AC_DEFINE_UNQUOTED, does not use a third
+dnl argument for the description. Symbol definitions done with this
+dnl macro are intended to be exclusively used in handcrafted *.h.in
+dnl template files. Contrary to what AC_DEFINE_UNQUOTED does, this one
+dnl prevents autoheader generation and insertion of symbol template
+dnl stub and definition into the first configuration header file. Do
+dnl not use this macro as a replacement for AC_DEFINE_UNQUOTED, each
+dnl one serves different functional needs.
+
+AC_DEFUN([CURL_DEFINE_UNQUOTED], [
+cat >>confdefs.h <<_EOF
+[@%:@define] $1 ifelse($#, 2, [$2], 1)
+_EOF
+])
+
+
+dnl CURL_CONFIGURE_LONG
+dnl -------------------------------------------------
+dnl Find out the size of long as reported by sizeof() and define
+dnl CURL_SIZEOF_LONG as appropriate to be used in template file
+dnl include/curl/curlbuild.h.in to properly configure the library.
+dnl The size of long is a build time characteristic and as such
+dnl must be recorded in curlbuild.h
+
+AC_DEFUN([CURL_CONFIGURE_LONG], [
+ if test -z "$ac_cv_sizeof_long" ||
+ test "$ac_cv_sizeof_long" -eq "0"; then
+ AC_MSG_ERROR([cannot find out size of long.])
+ fi
+ CURL_DEFINE_UNQUOTED([CURL_SIZEOF_LONG], [$ac_cv_sizeof_long])
+])
+
+
+dnl CURL_CONFIGURE_CURL_SOCKLEN_T
+dnl -------------------------------------------------
+dnl Find out suitable curl_socklen_t data type definition and size, making
+dnl appropriate definitions for template file include/curl/curlbuild.h.in
+dnl to properly configure and use the library.
+dnl
+dnl The need for the curl_socklen_t definition arises mainly to properly
+dnl interface HP-UX systems which on one hand have a typedef'ed socklen_t
+dnl data type which is 32 or 64-Bit wide depending on the data model being
+dnl used, and that on the other hand is only actually used when interfacing
+dnl the X/Open sockets provided in the xnet library.
+
+AC_DEFUN([CURL_CONFIGURE_CURL_SOCKLEN_T], [
+ AC_REQUIRE([CURL_INCLUDES_WS2TCPIP])dnl
+ AC_REQUIRE([CURL_INCLUDES_SYS_SOCKET])dnl
+ AC_REQUIRE([CURL_PREPROCESS_CALLCONV])dnl
+ #
+ AC_BEFORE([$0], [CURL_CONFIGURE_PULL_SYS_POLL])dnl
+ #
+ AC_MSG_CHECKING([for curl_socklen_t data type])
+ curl_typeof_curl_socklen_t="unknown"
+ for arg1 in int SOCKET; do
+ for arg2 in 'struct sockaddr' void; do
+ for t in socklen_t int size_t 'unsigned int' long 'unsigned long' void; do
+ if test "$curl_typeof_curl_socklen_t" = "unknown"; then
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([[
+ $curl_includes_ws2tcpip
+ $curl_includes_sys_socket
+ $curl_preprocess_callconv
+ extern int FUNCALLCONV getpeername($arg1, $arg2 *, $t *);
+ ]],[[
+ $t *lenptr = 0;
+ if(0 != getpeername(0, 0, lenptr))
+ return 1;
+ ]])
+ ],[
+ curl_typeof_curl_socklen_t="$t"
+ ])
+ fi
+ done
+ done
+ done
+ for t in socklen_t int; do
+ if test "$curl_typeof_curl_socklen_t" = "void"; then
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([[
+ $curl_includes_sys_socket
+ typedef $t curl_socklen_t;
+ ]],[[
+ curl_socklen_t dummy;
+ ]])
+ ],[
+ curl_typeof_curl_socklen_t="$t"
+ ])
+ fi
+ done
+ AC_MSG_RESULT([$curl_typeof_curl_socklen_t])
+ if test "$curl_typeof_curl_socklen_t" = "void" ||
+ test "$curl_typeof_curl_socklen_t" = "unknown"; then
+ AC_MSG_ERROR([cannot find data type for curl_socklen_t.])
+ fi
+ #
+ AC_MSG_CHECKING([size of curl_socklen_t])
+ curl_sizeof_curl_socklen_t="unknown"
+ curl_pull_headers_socklen_t="unknown"
+ if test "$curl_cv_header_ws2tcpip_h" = "yes"; then
+ tst_pull_header_checks='none ws2tcpip'
+ tst_size_checks='4'
+ else
+ tst_pull_header_checks='none systypes syssocket'
+ tst_size_checks='4 8 2'
+ fi
+ for tst_size in $tst_size_checks; do
+ for tst_pull_headers in $tst_pull_header_checks; do
+ if test "$curl_sizeof_curl_socklen_t" = "unknown"; then
+ case $tst_pull_headers in
+ ws2tcpip)
+ tmp_includes="$curl_includes_ws2tcpip"
+ ;;
+ systypes)
+ tmp_includes="$curl_includes_sys_types"
+ ;;
+ syssocket)
+ tmp_includes="$curl_includes_sys_socket"
+ ;;
+ *)
+ tmp_includes=""
+ ;;
+ esac
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([[
+ $tmp_includes
+ typedef $curl_typeof_curl_socklen_t curl_socklen_t;
+ typedef char dummy_arr[sizeof(curl_socklen_t) == $tst_size ? 1 : -1];
+ ]],[[
+ curl_socklen_t dummy;
+ ]])
+ ],[
+ curl_sizeof_curl_socklen_t="$tst_size"
+ curl_pull_headers_socklen_t="$tst_pull_headers"
+ ])
+ fi
+ done
+ done
+ AC_MSG_RESULT([$curl_sizeof_curl_socklen_t])
+ if test "$curl_sizeof_curl_socklen_t" = "unknown"; then
+ AC_MSG_ERROR([cannot find out size of curl_socklen_t.])
+ fi
+ #
+ case $curl_pull_headers_socklen_t in
+ ws2tcpip)
+ CURL_DEFINE_UNQUOTED([CURL_PULL_WS2TCPIP_H])
+ ;;
+ systypes)
+ CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_TYPES_H])
+ ;;
+ syssocket)
+ CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_TYPES_H])
+ CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_SOCKET_H])
+ ;;
+ esac
+ CURL_DEFINE_UNQUOTED([CURL_TYPEOF_CURL_SOCKLEN_T], [$curl_typeof_curl_socklen_t])
+ CURL_DEFINE_UNQUOTED([CURL_SIZEOF_CURL_SOCKLEN_T], [$curl_sizeof_curl_socklen_t])
+])
+
+
+dnl CURL_CONFIGURE_PULL_SYS_POLL
+dnl -------------------------------------------------
+dnl Find out if system header file sys/poll.h must be included by the
+dnl external interface, making appropriate definitions for template file
+dnl include/curl/curlbuild.h.in to properly configure and use the library.
+dnl
+dnl The need for the sys/poll.h inclusion arises mainly to properly
+dnl interface AIX systems which define macros 'events' and 'revents'.
+
+AC_DEFUN([CURL_CONFIGURE_PULL_SYS_POLL], [
+ AC_REQUIRE([CURL_INCLUDES_POLL])dnl
+ #
+ tst_poll_events_macro_defined="unknown"
+ #
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([[
+ $curl_includes_poll
+ ]],[[
+#if defined(events) || defined(revents)
+ return 0;
+#else
+ force compilation error
+#endif
+ ]])
+ ],[
+ tst_poll_events_macro_defined="yes"
+ ],[
+ tst_poll_events_macro_defined="no"
+ ])
+ #
+ if test "$tst_poll_events_macro_defined" = "yes"; then
+ if test "x$ac_cv_header_sys_poll_h" = "xyes"; then
+ CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_POLL_H])
+ fi
+ fi
+ #
+])
+
+