summaryrefslogtreecommitdiff
path: root/m4/cares-functions.m4
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2008-09-17 11:31:37 +0000
committerYang Tse <yangsita@gmail.com>2008-09-17 11:31:37 +0000
commit898e10bd60c2fb6c228c42b5940b4d17816cb1b1 (patch)
tree93a6c2a7c6f184ee1d0e507a78ff7e43ecb57be0 /m4/cares-functions.m4
parent8c3c80526930605155d0e9b23db4b8eddf974941 (diff)
downloadc-ares-898e10bd60c2fb6c228c42b5940b4d17816cb1b1.tar.gz
c-ares-898e10bd60c2fb6c228c42b5940b4d17816cb1b1.tar.bz2
c-ares-898e10bd60c2fb6c228c42b5940b4d17816cb1b1.zip
improve detection of getservbyport_r()
Diffstat (limited to 'm4/cares-functions.m4')
-rw-r--r--m4/cares-functions.m4163
1 files changed, 162 insertions, 1 deletions
diff --git a/m4/cares-functions.m4 b/m4/cares-functions.m4
index e1ba240..0ba0324 100644
--- a/m4/cares-functions.m4
+++ b/m4/cares-functions.m4
@@ -16,7 +16,28 @@
#***************************************************************************
# File version for 'aclocal' use. Keep it a single number.
-# serial 1
+# serial 5
+
+
+dnl CARES_INCLUDES_NETDB
+dnl -------------------------------------------------
+dnl Set up variable with list of headers that must be
+dnl included when netdb.h is to be included.
+
+AC_DEFUN([CARES_INCLUDES_NETDB], [
+cares_includes_netdb="\
+/* includes start */
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#ifdef HAVE_NETDB_H
+# include <netdb.h>
+#endif
+/* includes end */"
+ AC_CHECK_HEADERS(
+ sys/types.h netdb.h,
+ [], [], [$cares_includes_netdb])
+])
dnl CARES_INCLUDES_STRING
@@ -170,6 +191,146 @@ AC_DEFUN([CARES_CHECK_FUNC_GETHOSTNAME], [
])
+dnl CARES_CHECK_FUNC_GETSERVBYPORT_R
+dnl -------------------------------------------------
+dnl Verify if getservbyport_r is available, prototyped,
+dnl and can be compiled. If all of these are true, and
+dnl usage has not been previously disallowed with
+dnl shell variable cares_disallow_getservbyport_r, then
+dnl HAVE_GETSERVBYPORT_R will be defined.
+
+AC_DEFUN([CARES_CHECK_FUNC_GETSERVBYPORT_R], [
+ AC_REQUIRE([CARES_INCLUDES_SYS_UIO])dnl
+ #
+ tst_links_getservbyport_r="unknown"
+ tst_proto_getservbyport_r="unknown"
+ tst_compi_getservbyport_r="unknown"
+ tst_allow_getservbyport_r="unknown"
+ tst_nargs_getservbyport_r="unknown"
+ #
+ AC_MSG_CHECKING([if getservbyport_r can be linked])
+ AC_LINK_IFELSE([
+ AC_LANG_FUNC_LINK_TRY([getservbyport_r])
+ ],[
+ AC_MSG_RESULT([yes])
+ tst_links_getservbyport_r="yes"
+ ],[
+ AC_MSG_RESULT([no])
+ tst_links_getservbyport_r="no"
+ ])
+ #
+ if test "$tst_links_getservbyport_r" = "yes"; then
+ AC_MSG_CHECKING([if getservbyport_r is prototyped])
+ AC_EGREP_CPP([getservbyport_r],[
+ $cares_includes_netdb
+ ],[
+ AC_MSG_RESULT([yes])
+ tst_proto_getservbyport_r="yes"
+ ],[
+ AC_MSG_RESULT([no])
+ tst_proto_getservbyport_r="no"
+ ])
+ fi
+ #
+ if test "$tst_proto_getservbyport_r" = "yes"; then
+ if test "$tst_nargs_getservbyport_r" = "unknown"; then
+ AC_MSG_CHECKING([if getservbyport_r takes 4 args.])
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([[
+ $cares_includes_netdb
+ ]],[[
+ if(0 != getservbyport_r(0, 0, 0, 0))
+ return 1;
+ ]])
+ ],[
+ AC_MSG_RESULT([yes])
+ tst_compi_getservbyport_r="yes"
+ tst_nargs_getservbyport_r="4"
+ ],[
+ AC_MSG_RESULT([no])
+ tst_compi_getservbyport_r="no"
+ ])
+ fi
+ if test "$tst_nargs_getservbyport_r" = "unknown"; then
+ AC_MSG_CHECKING([if getservbyport_r takes 5 args.])
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([[
+ $cares_includes_netdb
+ ]],[[
+ if(0 != getservbyport_r(0, 0, 0, 0, 0))
+ return 1;
+ ]])
+ ],[
+ AC_MSG_RESULT([yes])
+ tst_compi_getservbyport_r="yes"
+ tst_nargs_getservbyport_r="5"
+ ],[
+ AC_MSG_RESULT([no])
+ tst_compi_getservbyport_r="no"
+ ])
+ fi
+ if test "$tst_nargs_getservbyport_r" = "unknown"; then
+ AC_MSG_CHECKING([if getservbyport_r takes 6 args.])
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([[
+ $cares_includes_netdb
+ ]],[[
+ if(0 != getservbyport_r(0, 0, 0, 0, 0, 0))
+ return 1;
+ ]])
+ ],[
+ AC_MSG_RESULT([yes])
+ tst_compi_getservbyport_r="yes"
+ tst_nargs_getservbyport_r="6"
+ ],[
+ AC_MSG_RESULT([no])
+ tst_compi_getservbyport_r="no"
+ ])
+ fi
+ AC_MSG_CHECKING([if getservbyport_r is compilable])
+ if test "$tst_compi_getservbyport_r" = "yes"; then
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+ fi
+ fi
+ #
+ if test "$tst_compi_getservbyport_r" = "yes"; then
+ AC_MSG_CHECKING([if getservbyport_r usage allowed])
+ if test "x$cares_disallow_getservbyport_r" != "xyes"; then
+ AC_MSG_RESULT([yes])
+ tst_allow_getservbyport_r="yes"
+ else
+ AC_MSG_RESULT([no])
+ tst_allow_getservbyport_r="no"
+ fi
+ fi
+ #
+ AC_MSG_CHECKING([if getservbyport_r might be used])
+ if test "$tst_links_getservbyport_r" = "yes" &&
+ test "$tst_proto_getservbyport_r" = "yes" &&
+ test "$tst_compi_getservbyport_r" = "yes" &&
+ test "$tst_allow_getservbyport_r" = "yes"; then
+ AC_MSG_RESULT([yes])
+ AC_DEFINE_UNQUOTED(HAVE_GETSERVBYPORT_R, 1,
+ [Define to 1 if you have the getservbyport_r function.])
+ AC_DEFINE_UNQUOTED(GETSERVBYPORT_R_ARGS, $tst_nargs_getservbyport_r,
+ [Specifies the number of arguments to getservbyport_r])
+ if test "$tst_nargs_getservbyport_r" -eq "4"; then
+ AC_DEFINE(GETSERVBYPORT_R_BUFSIZE, sizeof(struct servent_data),
+ [Specifies the size of the buffer to pass to getservbyport_r])
+ else
+ AC_DEFINE(GETSERVBYPORT_R_BUFSIZE, 4096,
+ [Specifies the size of the buffer to pass to getservbyport_r])
+ fi
+ ac_cv_func_getservbyport_r="yes"
+ else
+ AC_MSG_RESULT([no])
+ ac_cv_func_getservbyport_r="no"
+ fi
+])
+
+
dnl CARES_CHECK_FUNC_STRCASECMP
dnl -------------------------------------------------
dnl Verify if strcasecmp is available, prototyped, and