aboutsummaryrefslogtreecommitdiff
path: root/ares
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2005-12-16 18:18:00 +0000
committerYang Tse <yangsita@gmail.com>2005-12-16 18:18:00 +0000
commitd6ffb4c177615e766268bd4ab3afc9cef77aa7c9 (patch)
tree38fa71e0512e3ba13c86f988b71d31c63d3bd897 /ares
parent6dbfce1031a8dd177772e2ee356c712b2454f794 (diff)
TYPE_SOCKLEN_T completely replaced by CURL_CHECK_TYPE_SOCKLEN_T.
CURL_FUNC_GETNAMEINFO_ARGTYPES now also checks first argument. All related changes taken to cares configuration scripts.
Diffstat (limited to 'ares')
-rw-r--r--ares/acinclude.m4279
-rw-r--r--ares/configure.ac57
2 files changed, 320 insertions, 16 deletions
diff --git a/ares/acinclude.m4 b/ares/acinclude.m4
index 214c005e7..6d1835ecb 100644
--- a/ares/acinclude.m4
+++ b/ares/acinclude.m4
@@ -1,3 +1,282 @@
+
+
+dnl CURL_CHECK_HEADER_WINDOWS
+dnl -------------------------------------------------
+dnl Check for compilable and valid windows.h header
+
+AC_DEFUN([CURL_CHECK_HEADER_WINDOWS], [
+ AC_CACHE_CHECK([for windows.h], [ac_cv_header_windows_h], [
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([
+#undef inline
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+ ],[
+ int dummy=2*WINVER;
+ ])
+ ],[
+ ac_cv_header_windows_h="yes"
+ ],[
+ ac_cv_header_windows_h="no"
+ ])
+ ])
+ if test "x$ac_cv_header_windows_h" = "xyes"; then
+ AC_DEFINE_UNQUOTED(HAVE_WINDOWS_H, 1,
+ [Define to 1 if you have the windows.h header file.])
+ AC_DEFINE_UNQUOTED(WIN32_LEAN_AND_MEAN, 1,
+ [Define to avoid automatic inclusion of winsock.h])
+ fi
+])
+
+
+dnl CURL_CHECK_HEADER_WINSOCK
+dnl -------------------------------------------------
+dnl Check for compilable and valid winsock.h header
+
+AC_DEFUN([CURL_CHECK_HEADER_WINSOCK], [
+ AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
+ AC_CACHE_CHECK([for winsock.h], [ac_cv_header_winsock_h], [
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([
+#undef inline
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <winsock.h>
+ ],[
+ int dummy=WSACleanup();
+ ])
+ ],[
+ ac_cv_header_winsock_h="yes"
+ ],[
+ ac_cv_header_winsock_h="no"
+ ])
+ ])
+ if test "x$ac_cv_header_winsock_h" = "xyes"; then
+ AC_DEFINE_UNQUOTED(HAVE_WINSOCK_H, 1,
+ [Define to 1 if you have the winsock.h header file.])
+ fi
+])
+
+
+dnl CURL_CHECK_HEADER_WINSOCK2
+dnl -------------------------------------------------
+dnl Check for compilable and valid winsock2.h header
+
+AC_DEFUN([CURL_CHECK_HEADER_WINSOCK2], [
+ AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
+ AC_CACHE_CHECK([for winsock2.h], [ac_cv_header_winsock2_h], [
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([
+#undef inline
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <winsock2.h>
+ ],[
+ int dummy=2*IPPROTO_ESP;
+ ])
+ ],[
+ ac_cv_header_winsock2_h="yes"
+ ],[
+ ac_cv_header_winsock2_h="no"
+ ])
+ ])
+ if test "x$ac_cv_header_winsock2_h" = "xyes"; then
+ AC_DEFINE_UNQUOTED(HAVE_WINSOCK2_H, 1,
+ [Define to 1 if you have the winsock2.h header file.])
+ fi
+])
+
+
+dnl CURL_CHECK_HEADER_WS2TCPIP
+dnl -------------------------------------------------
+dnl Check for compilable and valid ws2tcpip.h header
+
+AC_DEFUN([CURL_CHECK_HEADER_WS2TCPIP], [
+ AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
+ AC_CACHE_CHECK([for ws2tcpip.h], [ac_cv_header_ws2tcpip_h], [
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([
+#undef inline
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <winsock2.h>
+#include <ws2tcpip.h>
+ ],[
+ int dummy=2*IP_PKTINFO;
+ ])
+ ],[
+ ac_cv_header_ws2tcpip_h="yes"
+ ],[
+ ac_cv_header_ws2tcpip_h="no"
+ ])
+ ])
+ if test "x$ac_cv_header_ws2tcpip_h" = "xyes"; then
+ AC_DEFINE_UNQUOTED(HAVE_WS2TCPIP_H, 1,
+ [Define to 1 if you have the ws2tcpip.h header file.])
+ fi
+])
+
+
+dnl CURL_CHECK_TYPE_SOCKLEN_T
+dnl -------------------------------------------------
+dnl Check for existing socklen_t type, and provide
+dnl an equivalent type if socklen_t not available
+
+AC_DEFUN([CURL_CHECK_TYPE_SOCKLEN_T], [
+ AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
+ AC_CHECK_TYPE([socklen_t], ,[
+ AC_CACHE_CHECK([for socklen_t equivalent],
+ [curl_cv_socklen_t_equiv], [
+ curl_cv_socklen_t_equiv="unknown"
+ for arg2 in "struct sockaddr" void; do
+ for t in int size_t unsigned long "unsigned long"; do
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([
+#undef inline
+#ifdef HAVE_WINDOWS_H
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#ifdef HAVE_WINSOCK2_H
+#include <winsock2.h>
+#else
+#ifdef HAVE_WINSOCK_H
+#include <winsock.h>
+#endif
+#endif
+#else
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+#endif
+ int getpeername (int, $arg2 *, $t *);
+ int getsockname (int, $arg2 *, $t *);
+ int bind (int, $arg2 *, $t);
+ int accept (int, $arg2 *, $t *);
+ ],[
+ $t len=0;
+ getpeername(0,0,&len);
+ getsockname(0,0,&len);
+ bind(0,0,len);
+ accept(0,0,&len);
+ ])
+ ],[
+ curl_cv_socklen_t_equiv="$t"
+ break 2
+ ])
+ done
+ done
+ ])
+ if test "$curl_cv_socklen_t_equiv" = "unknown"; then
+ AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
+ else
+ AC_DEFINE_UNQUOTED(socklen_t, $curl_cv_socklen_t_equiv,
+ [type to use in place of socklen_t if not defined])
+ fi
+ ],[
+#ifdef HAVE_WINDOWS_H
+#ifdef HAVE_WS2TCPIP_H
+#include <ws2tcpip.h>
+#endif
+#else
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+#endif
+ ])
+])
+
+
+dnl CURL_FUNC_GETNAMEINFO_ARGTYPES
+dnl -------------------------------------------------
+dnl Check the type to be passed to five of the arguments
+dnl of getnameinfo function, and define those types in
+dnl GETNAMEINFO_TYPE_ARG1, GETNAMEINFO_TYPE_ARG2,
+dnl GETNAMEINFO_TYPE_ARG46 and GETNAMEINFO_TYPE_ARG7.
+dnl This function is experimental and its results shall
+dnl not be trusted while this notice is in place ------
+
+AC_DEFUN([CURL_FUNC_GETNAMEINFO_ARGTYPES], [
+ AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
+ AC_REQUIRE([CURL_CHECK_TYPE_SOCKLEN_T])dnl
+ AC_CHECK_HEADERS(sys/types.h sys/socket.h netdb.h)
+ AC_CACHE_CHECK([types of arguments for getnameinfo],
+ [curl_cv_func_getnameinfo_args], [
+ curl_cv_func_getnameinfo_args="unknown"
+ for gni_arg1 in 'struct sockaddr *' 'void *'; do
+ for gni_arg2 in 'socklen_t' 'size_t' 'int'; do
+ for gni_arg46 in 'size_t' 'int' 'socklen_t'; do
+ for gni_arg7 in 'int' 'unsigned int'; do
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([
+#undef inline
+#ifdef HAVE_WINDOWS_H
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#ifdef HAVE_WINSOCK2_H
+#include <winsock2.h>
+#endif
+#ifdef HAVE_WS2TCPIP_H
+#include <ws2tcpip.h>
+#endif
+#else
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+#ifdef HAVE_NETDB_H
+#include <netdb.h>
+#endif
+#endif
+ extern int getnameinfo($gni_arg1, $gni_arg2,
+ char *, $gni_arg46,
+ char *, $gni_arg46,
+ $gni_arg7);
+ ],[
+ $gni_arg1 sa=0;
+ $gni_arg2 salen=0;
+ char *host=0;
+ $gni_arg46 hostlen=0;
+ char *serv=0;
+ $gni_arg46 servlen=0;
+ $gni_arg7 flags=0;
+ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags);
+ ])
+ ],[
+ curl_cv_func_getnameinfo_args="$gni_arg1,$gni_arg2,$gni_arg46,$gni_arg7"
+ break 4
+ ])
+ done
+ done
+ done
+ done
+ ])
+ if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
+ AC_MSG_ERROR([Cannot find proper types to use for getnameinfo args])
+ else
+ gni_prev_IFS=$IFS; IFS=','
+ set dummy `echo "$curl_cv_func_getnameinfo_args" | sed 's/\*/\*/g'`
+ IFS=$gni_prev_IFS
+ shift
+ AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG1, $[1],
+ [Define to the type of arg 1 for `getnameinfo'.])
+ AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG2, $[2],
+ [Define to the type of arg 2 for `getnameinfo'.])
+ AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG46, $[3],
+ [Define to the type of args 4 and 6 for `getnameinfo'.])
+ AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG7, $[4],
+ [Define to the type of arg 7 for `getnameinfo'.])
+ fi
+])
+
+
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,
diff --git a/ares/configure.ac b/ares/configure.ac
index 60436fb0a..5b3431a05 100644
--- a/ares/configure.ac
+++ b/ares/configure.ac
@@ -59,6 +59,18 @@ AC_HELP_STRING([--disable-debug],[Disable debug options]),
AC_PROG_LIBTOOL
+dnl **********************************************************************
+dnl Make sure that our checks for headers windows.h winsock.h winsock2.h
+dnl and ws2tcpip.h take precedence over any other further checks which
+dnl could be done later using AC_CHECK_HEADER or AC_CHECK_HEADERS for
+dnl this specific header files.
+dnl **********************************************************************
+
+CURL_CHECK_HEADER_WINDOWS
+CURL_CHECK_HEADER_WINSOCK
+CURL_CHECK_HEADER_WINSOCK2
+CURL_CHECK_HEADER_WS2TCPIP
+
dnl check for a few basic system headers we need
AC_CHECK_HEADERS(
sys/types.h \
@@ -67,8 +79,6 @@ AC_CHECK_HEADERS(
sys/socket.h \
sys/ioctl.h \
netdb.h \
- winsock2.h \
- ws2tcpip.h \
netinet/in.h \
net/if.h \
arpa/nameser.h \
@@ -95,19 +105,8 @@ dnl *Sigh* these are needed in order for net/if.h to get properly detected.
]
)
-AC_CHECK_TYPE(socklen_t, ,
- AC_DEFINE(socklen_t, int, [the length of a socket address]),
- [
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-#ifdef HAVE_WINSOCK2_H
-#include <winsock2.h>
-#endif
- ])
+# Check for socklen_t or equivalent
+CURL_CHECK_TYPE_SOCKLEN_T
dnl check for AF_INET6
CARES_CHECK_CONSTANT(
@@ -228,6 +227,26 @@ AC_CHECK_MEMBER(struct addrinfo.ai_flags,
]
)
+
+AC_CHECK_FUNCS( getnameinfo \
+ bitncmp \
+ if_indextoname,
+dnl if found
+[],
+dnl if not found, $ac_func is the name we check for
+func="$ac_func"
+AC_MSG_CHECKING([deeper for $func])
+AC_TRY_LINK( [],
+ [ $func ();],
+ AC_MSG_RESULT(yes!)
+ eval "ac_cv_func_$func=yes"
+ def=`echo "HAVE_$func" | tr 'a-z' 'A-Z'`
+ AC_DEFINE_UNQUOTED($def, 1, [If you have $func]),
+ AC_MSG_RESULT(but still no)
+ )
+)
+
+
dnl check for inet_pton
AC_CHECK_FUNCS(inet_pton)
dnl Some systems have it, but not IPv6
@@ -362,7 +381,13 @@ AC_CHECK_SIZEOF(struct in_addr, ,
]
)
-AC_CHECK_FUNCS([bitncmp if_indextoname])
+if test "x$ac_cv_func_getnameinfo" = "x"; then
+ AC_MSG_ERROR([Checking availability of function getnameinfo must be done previously])
+else
+ if test "x$ac_cv_func_getnameinfo" = "xyes"; then
+ CURL_FUNC_GETNAMEINFO_ARGTYPES
+ fi
+fi
dnl God bless non-standardized functions! We need to see which getservbyport_r variant is available
CARES_CHECK_GETSERVBYPORT_R