aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2008-09-17 16:03:49 +0000
committerYang Tse <yangsita@gmail.com>2008-09-17 16:03:49 +0000
commitd84440d53b70923f6d201f6a17c26814e45f160e (patch)
tree4c32c81ddf4eb4e004015cbf854abad2e2efc08b
parent0c1ae21c110454413f0a19ef8134e024f4c5c6ef (diff)
improve detection of gethostbyaddr_r() and gethostbyname_r()
-rw-r--r--acinclude.m4418
-rw-r--r--configure.ac6
-rw-r--r--m4/curl-functions.m4284
3 files changed, 288 insertions, 420 deletions
diff --git a/acinclude.m4 b/acinclude.m4
index c21ca89f3..90afe8545 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -2623,424 +2623,6 @@ AC_DEFUN([CURL_CHECK_INET_NTOA_R],
])
-dnl CURL_CHECK_GETHOSTBYADDR_R
-dnl -------------------------------------------------
-dnl check number of arguments for gethostbyaddr_r, it
-dnl might take either 5, 7, or 8 arguments.
-
-AC_DEFUN([CURL_CHECK_GETHOSTBYADDR_R], [
- #
- AC_MSG_CHECKING([for gethostbyaddr_r])
- AC_LINK_IFELSE([
- AC_LANG_FUNC_LINK_TRY([gethostbyaddr_r])
- ],[
- AC_MSG_RESULT([yes])
- tmp_cv_gethostbyaddr_r="yes"
- ],[
- AC_MSG_RESULT([no])
- tmp_cv_gethostbyaddr_r="no"
- ])
- #
- if test "$tmp_cv_gethostbyaddr_r" != "yes"; then
- AC_MSG_CHECKING([deeper for gethostbyaddr_r])
- AC_LINK_IFELSE([
- AC_LANG_PROGRAM([[
- ]],[[
- gethostbyaddr_r();
- ]])
- ],[
- AC_MSG_RESULT([yes])
- tmp_cv_gethostbyaddr_r="yes"
- ],[
- AC_MSG_RESULT([but still no])
- tmp_cv_gethostbyaddr_r="no"
- ])
- fi
- #
- if test "$tmp_cv_gethostbyaddr_r" = "yes"; then
-
- ac_cv_gethostbyaddr_r_args="unknown"
-
- AC_MSG_CHECKING([if gethostbyaddr_r takes 5 arguments])
- AC_COMPILE_IFELSE([
- AC_LANG_PROGRAM([[
-#undef _REENTRANT
-#include <sys/types.h>
-#include <netdb.h>
- ]],[[
- char * address;
- int length;
- int type;
- struct hostent h;
- struct hostent_data hdata;
- int rc;
- rc = gethostbyaddr_r(address, length, type, &h, &hdata);
- ]])
- ],[
- AC_MSG_RESULT([yes])
- AC_DEFINE(HAVE_GETHOSTBYADDR_R_5, 1, [gethostbyaddr_r() takes 5 args])
- ac_cv_gethostbyaddr_r_args="5"
- ],[
- AC_MSG_RESULT([no])
- ])
-
- if test "$ac_cv_gethostbyaddr_r_args" = "unknown"; then
- AC_MSG_CHECKING([if gethostbyaddr_r with -D_REENTRANT takes 5 arguments])
- AC_COMPILE_IFELSE([
- AC_LANG_PROGRAM([[
-#undef _REENTRANT
-#define _REENTRANT
-#include <sys/types.h>
-#include <netdb.h>
- ]],[[
- char * address;
- int length;
- int type;
- struct hostent h;
- struct hostent_data hdata;
- int rc;
- rc = gethostbyaddr_r(address, length, type, &h, &hdata);
- ]])
- ],[
- AC_MSG_RESULT([yes])
- AC_DEFINE(HAVE_GETHOSTBYADDR_R_5, 1, [gethostbyaddr_r() takes 5 args])
- ac_cv_gethostbyaddr_r_args="5"
- ],[
- AC_MSG_RESULT([no])
- ])
- fi
-
- if test "$ac_cv_gethostbyaddr_r_args" = "unknown"; then
- AC_MSG_CHECKING([if gethostbyaddr_r takes 7 arguments])
- AC_COMPILE_IFELSE([
- AC_LANG_PROGRAM([[
-#undef _REENTRANT
-#include <sys/types.h>
-#include <netdb.h>
- ]],[[
- char * address;
- int length;
- int type;
- struct hostent h;
- char buffer[8192];
- int h_errnop;
- struct hostent * hp;
- hp = gethostbyaddr_r(address, length, type, &h,
- buffer, 8192, &h_errnop);
- ]])
- ],[
- AC_MSG_RESULT([yes])
- AC_DEFINE(HAVE_GETHOSTBYADDR_R_7, 1, [gethostbyaddr_r() takes 7 args])
- ac_cv_gethostbyaddr_r_args="7"
- ],[
- AC_MSG_RESULT([no])
- ])
- fi
-
- if test "$ac_cv_gethostbyaddr_r_args" = "unknown"; then
- AC_MSG_CHECKING([if gethostbyaddr_r with -D_REENTRANT takes 7 arguments])
- AC_COMPILE_IFELSE([
- AC_LANG_PROGRAM([[
-#undef _REENTRANT
-#define _REENTRANT
-#include <sys/types.h>
-#include <netdb.h>
- ]],[[
- char * address;
- int length;
- int type;
- struct hostent h;
- char buffer[8192];
- int h_errnop;
- struct hostent * hp;
- hp = gethostbyaddr_r(address, length, type, &h,
- buffer, 8192, &h_errnop);
- ]])
- ],[
- AC_MSG_RESULT([yes])
- AC_DEFINE(HAVE_GETHOSTBYADDR_R_7, 1, [gethostbyaddr_r() takes 7 args])
- ac_cv_gethostbyaddr_r_args="7"
- ],[
- AC_MSG_RESULT([no])
- ])
- fi
-
- if test "$ac_cv_gethostbyaddr_r_args" = "unknown"; then
- AC_MSG_CHECKING([if gethostbyaddr_r takes 8 arguments])
- AC_COMPILE_IFELSE([
- AC_LANG_PROGRAM([[
-#undef _REENTRANT
-#include <sys/types.h>
-#include <netdb.h>
- ]],[[
- char * address;
- int length;
- int type;
- struct hostent h;
- char buffer[8192];
- int h_errnop;
- struct hostent * hp;
- int rc;
- rc = gethostbyaddr_r(address, length, type, &h,
- buffer, 8192, &hp, &h_errnop);
- ]])
- ],[
- AC_MSG_RESULT([yes])
- AC_DEFINE(HAVE_GETHOSTBYADDR_R_8, 1, [gethostbyaddr_r() takes 8 args])
- ac_cv_gethostbyaddr_r_args="8"
- ],[
- AC_MSG_RESULT([no])
- ])
- fi
-
- if test "$ac_cv_gethostbyaddr_r_args" = "unknown"; then
- AC_MSG_CHECKING([if gethostbyaddr_r with -D_REENTRANT takes 8 arguments])
- AC_COMPILE_IFELSE([
- AC_LANG_PROGRAM([[
-#undef _REENTRANT
-#define _REENTRANT
-#include <sys/types.h>
-#include <netdb.h>
- ]],[[
- char * address;
- int length;
- int type;
- struct hostent h;
- char buffer[8192];
- int h_errnop;
- struct hostent * hp;
- int rc;
- rc = gethostbyaddr_r(address, length, type, &h,
- buffer, 8192, &hp, &h_errnop);
- ]])
- ],[
- AC_MSG_RESULT([yes])
- AC_DEFINE(HAVE_GETHOSTBYADDR_R_8, 1, [gethostbyaddr_r() takes 8 args])
- ac_cv_gethostbyaddr_r_args="8"
- ],[
- AC_MSG_RESULT([no])
- ])
- fi
-
- if test "$ac_cv_gethostbyaddr_r_args" = "unknown"; then
- AC_MSG_WARN([Cannot find out how to use gethostbyaddr_r])
- AC_MSG_WARN([HAVE_GETHOSTBYADDR_R will not be defined])
- ac_cv_func_gethostbyaddr_r="no"
- else
- AC_DEFINE_UNQUOTED(HAVE_GETHOSTBYADDR_R, 1,
- [Define to 1 if you have the gethostbyaddr_r function.])
- ac_cv_func_gethostbyaddr_r="yes"
- fi
-
- else
- ac_cv_func_gethostbyaddr_r="no"
- fi
-])
-
-
-dnl CURL_CHECK_GETHOSTBYNAME_R
-dnl -------------------------------------------------
-dnl check number of arguments for gethostbyname_r, it
-dnl might take either 3, 5, or 6 arguments.
-
-AC_DEFUN([CURL_CHECK_GETHOSTBYNAME_R], [
- #
- AC_MSG_CHECKING([for gethostbyname_r])
- AC_LINK_IFELSE([
- AC_LANG_FUNC_LINK_TRY([gethostbyname_r])
- ],[
- AC_MSG_RESULT([yes])
- tmp_cv_gethostbyname_r="yes"
- ],[
- AC_MSG_RESULT([no])
- tmp_cv_gethostbyname_r="no"
- ])
- #
- if test "$tmp_cv_gethostbyname_r" != "yes"; then
- AC_MSG_CHECKING([deeper for gethostbyname_r])
- AC_LINK_IFELSE([
- AC_LANG_PROGRAM([[
- ]],[[
- gethostbyname_r();
- ]])
- ],[
- AC_MSG_RESULT([yes])
- tmp_cv_gethostbyname_r="yes"
- ],[
- AC_MSG_RESULT([but still no])
- tmp_cv_gethostbyname_r="no"
- ])
- fi
- #
- if test "$tmp_cv_gethostbyname_r" = "yes"; then
-
- ac_cv_gethostbyname_r_args="unknown"
-
- AC_MSG_CHECKING([if gethostbyname_r takes 3 arguments])
- AC_COMPILE_IFELSE([
- AC_LANG_PROGRAM([[
-#undef _REENTRANT
-#include <string.h>
-#include <sys/types.h>
-#include <netdb.h>
-#undef NULL
-#define NULL (void *)0
- int
- gethostbyname_r(const char *, struct hostent *,
- struct hostent_data *);
- ]],[[
- struct hostent_data data;
- gethostbyname_r(NULL, NULL, NULL);
- ]])
- ],[
- AC_MSG_RESULT([yes])
- AC_DEFINE(HAVE_GETHOSTBYNAME_R_3, 1, [gethostbyname_r() takes 3 args])
- ac_cv_gethostbyname_r_args="3"
- ],[
- AC_MSG_RESULT([no])
- ])
-
- if test "$ac_cv_gethostbyname_r_args" = "unknown"; then
- AC_MSG_CHECKING([if gethostbyname_r with -D_REENTRANT takes 3 arguments])
- AC_COMPILE_IFELSE([
- AC_LANG_PROGRAM([[
-#undef _REENTRANT
-#define _REENTRANT
-#include <string.h>
-#include <sys/types.h>
-#include <netdb.h>
-#undef NULL
-#define NULL (void *)0
- int
- gethostbyname_r(const char *, struct hostent *,
- struct hostent_data *);
- ]],[[
- struct hostent_data data;
- gethostbyname_r(NULL, NULL, NULL);
- ]])
- ],[
- AC_MSG_RESULT([yes])
- AC_DEFINE(HAVE_GETHOSTBYNAME_R_3, 1, [gethostbyname_r() takes 3 args])
- ac_cv_gethostbyname_r_args="3"
- ],[
- AC_MSG_RESULT([no])
- ])
- fi
-
- if test "$ac_cv_gethostbyname_r_args" = "unknown"; then
- AC_MSG_CHECKING([if gethostbyname_r takes 5 arguments])
- AC_COMPILE_IFELSE([
- AC_LANG_PROGRAM([[
-#undef _REENTRANT
-#include <sys/types.h>
-#include <netdb.h>
-#undef NULL
-#define NULL (void *)0
- struct hostent *
- gethostbyname_r(const char *, struct hostent *,
- char *, int, int *);
- ]],[[
- gethostbyname_r(NULL, NULL, NULL, 0, NULL);
- ]])
- ],[
- AC_MSG_RESULT([yes])
- AC_DEFINE(HAVE_GETHOSTBYNAME_R_5, 1, [gethostbyname_r() takes 5 args])
- ac_cv_gethostbyname_r_args="5"
- ],[
- AC_MSG_RESULT([no])
- ])
- fi
-
- if test "$ac_cv_gethostbyname_r_args" = "unknown"; then
- AC_MSG_CHECKING([if gethostbyname_r with -D_REENTRANT takes 5 arguments])
- AC_COMPILE_IFELSE([
- AC_LANG_PROGRAM([[
-#undef _REENTRANT
-#define _REENTRANT
-#include <sys/types.h>
-#include <netdb.h>
-#undef NULL
-#define NULL (void *)0
- struct hostent *
- gethostbyname_r(const char *, struct hostent *,
- char *, int, int *);
- ]],[[
- gethostbyname_r(NULL, NULL, NULL, 0, NULL);
- ]])
- ],[
- AC_MSG_RESULT([yes])
- AC_DEFINE(HAVE_GETHOSTBYNAME_R_5, 1, [gethostbyname_r() takes 5 args])
- ac_cv_gethostbyname_r_args="5"
- ],[
- AC_MSG_RESULT([no])
- ])
- fi
-
- if test "$ac_cv_gethostbyname_r_args" = "unknown"; then
- AC_MSG_CHECKING([if gethostbyname_r takes 6 arguments])
- AC_COMPILE_IFELSE([
- AC_LANG_PROGRAM([[
-#undef _REENTRANT
-#include <sys/types.h>
-#include <netdb.h>
-#undef NULL
-#define NULL (void *)0
- int
- gethostbyname_r(const char *, struct hostent *,
- char *, size_t, struct hostent **, int *);
- ]],[[
- gethostbyname_r(NULL, NULL, NULL, 0, NULL, NULL);
- ]])
- ],[
- AC_MSG_RESULT([yes])
- AC_DEFINE(HAVE_GETHOSTBYNAME_R_6, 1, [gethostbyname_r() takes 6 args])
- ac_cv_gethostbyname_r_args="6"
- ],[
- AC_MSG_RESULT([no])
- ])
- fi
-
- if test "$ac_cv_gethostbyname_r_args" = "unknown"; then
- AC_MSG_CHECKING([if gethostbyname_r with -D_REENTRANT takes 6 arguments])
- AC_COMPILE_IFELSE([
- AC_LANG_PROGRAM([[
-#undef _REENTRANT
-#define _REENTRANT
-#include <sys/types.h>
-#include <netdb.h>
-#undef NULL
-#define NULL (void *)0
- int
- gethostbyname_r(const char *, struct hostent *,
- char *, size_t, struct hostent **, int *);
- ]],[[
- gethostbyname_r(NULL, NULL, NULL, 0, NULL, NULL);
- ]])
- ],[
- AC_MSG_RESULT([yes])
- AC_DEFINE(HAVE_GETHOSTBYNAME_R_6, 1, [gethostbyname_r() takes 6 args])
- ac_cv_gethostbyname_r_args="6"
- ],[
- AC_MSG_RESULT([no])
- ])
- fi
-
- if test "$ac_cv_gethostbyname_r_args" = "unknown"; then
- AC_MSG_WARN([Cannot find out how to use gethostbyname_r])
- AC_MSG_WARN([HAVE_GETHOSTBYNAME_R will not be defined])
- ac_cv_func_gethostbyname_r="no"
- else
- AC_DEFINE_UNQUOTED(HAVE_GETHOSTBYNAME_R, 1,
- [Define to 1 if you have the gethostbyname_r function.])
- ac_cv_func_gethostbyname_r="yes"
- fi
-
- else
- ac_cv_func_gethostbyname_r="no"
- fi
-])
-
-
dnl **********************************************************************
dnl CURL_DETECT_ICC ([ACTION-IF-YES])
dnl
diff --git a/configure.ac b/configure.ac
index d4462e32d..228b686e9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1842,10 +1842,10 @@ then
else
if test "$ipv6" != "yes"; then
dnl dig around for gethostbyname_r()
- CURL_CHECK_GETHOSTBYNAME_R()
+ dnl the old gethostbyname_r check was done here
dnl dig around for gethostbyaddr_r()
- dnl CURL_CHECK_GETHOSTBYADDR_R()
+ dnl the old gethostbyaddr_r check was here BUT COMMENTED OUT
fi
dnl poke around for inet_ntoa_r()
@@ -2037,6 +2037,8 @@ CURL_CHECK_MSG_NOSIGNAL
CURL_CHECK_FUNC_FDOPEN
CURL_CHECK_FUNC_FTRUNCATE
+CURL_CHECK_FUNC_GETHOSTBYADDR_R
+CURL_CHECK_FUNC_GETHOSTBYNAME_R
CURL_CHECK_FUNC_GETHOSTNAME
CURL_CHECK_FUNC_GETSERVBYPORT_R
CURL_CHECK_FUNC_GMTIME_R
diff --git a/m4/curl-functions.m4 b/m4/curl-functions.m4
index e6e1c9939..f349bf6f4 100644
--- a/m4/curl-functions.m4
+++ b/m4/curl-functions.m4
@@ -374,6 +374,290 @@ AC_DEFUN([CURL_CHECK_FUNC_FTRUNCATE], [
])
+dnl CURL_CHECK_FUNC_GETHOSTBYADDR_R
+dnl -------------------------------------------------
+dnl Verify if gethostbyaddr_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 curl_disallow_gethostbyaddr_r, then
+dnl HAVE_GETHOSTBYADDR_R will be defined.
+
+AC_DEFUN([CURL_CHECK_FUNC_GETHOSTBYADDR_R], [
+ AC_REQUIRE([CURL_INCLUDES_SYS_UIO])dnl
+ #
+ tst_links_gethostbyaddr_r="unknown"
+ tst_proto_gethostbyaddr_r="unknown"
+ tst_compi_gethostbyaddr_r="unknown"
+ tst_allow_gethostbyaddr_r="unknown"
+ tst_nargs_gethostbyaddr_r="unknown"
+ #
+ AC_MSG_CHECKING([if gethostbyaddr_r can be linked])
+ AC_LINK_IFELSE([
+ AC_LANG_FUNC_LINK_TRY([gethostbyaddr_r])
+ ],[
+ AC_MSG_RESULT([yes])
+ tst_links_gethostbyaddr_r="yes"
+ ],[
+ AC_MSG_RESULT([no])
+ tst_links_gethostbyaddr_r="no"
+ ])
+ #
+ if test "$tst_links_gethostbyaddr_r" = "yes"; then
+ AC_MSG_CHECKING([if gethostbyaddr_r is prototyped])
+ AC_EGREP_CPP([gethostbyaddr_r],[
+ $curl_includes_netdb
+ ],[
+ AC_MSG_RESULT([yes])
+ tst_proto_gethostbyaddr_r="yes"
+ ],[
+ AC_MSG_RESULT([no])
+ tst_proto_gethostbyaddr_r="no"
+ ])
+ fi
+ #
+ if test "$tst_proto_gethostbyaddr_r" = "yes"; then
+ if test "$tst_nargs_gethostbyaddr_r" = "unknown"; then
+ AC_MSG_CHECKING([if gethostbyaddr_r takes 5 args.])
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([[
+ $curl_includes_netdb
+ ]],[[
+ if(0 != gethostbyaddr_r(0, 0, 0, 0, 0))
+ return 1;
+ ]])
+ ],[
+ AC_MSG_RESULT([yes])
+ tst_compi_gethostbyaddr_r="yes"
+ tst_nargs_gethostbyaddr_r="5"
+ ],[
+ AC_MSG_RESULT([no])
+ tst_compi_gethostbyaddr_r="no"
+ ])
+ fi
+ if test "$tst_nargs_gethostbyaddr_r" = "unknown"; then
+ AC_MSG_CHECKING([if gethostbyaddr_r takes 7 args.])
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([[
+ $curl_includes_netdb
+ ]],[[
+ if(0 != gethostbyaddr_r(0, 0, 0, 0, 0, 0, 0))
+ return 1;
+ ]])
+ ],[
+ AC_MSG_RESULT([yes])
+ tst_compi_gethostbyaddr_r="yes"
+ tst_nargs_gethostbyaddr_r="7"
+ ],[
+ AC_MSG_RESULT([no])
+ tst_compi_gethostbyaddr_r="no"
+ ])
+ fi
+ if test "$tst_nargs_gethostbyaddr_r" = "unknown"; then
+ AC_MSG_CHECKING([if gethostbyaddr_r takes 8 args.])
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([[
+ $curl_includes_netdb
+ ]],[[
+ if(0 != gethostbyaddr_r(0, 0, 0, 0, 0, 0, 0, 0))
+ return 1;
+ ]])
+ ],[
+ AC_MSG_RESULT([yes])
+ tst_compi_gethostbyaddr_r="yes"
+ tst_nargs_gethostbyaddr_r="8"
+ ],[
+ AC_MSG_RESULT([no])
+ tst_compi_gethostbyaddr_r="no"
+ ])
+ fi
+ AC_MSG_CHECKING([if gethostbyaddr_r is compilable])
+ if test "$tst_compi_gethostbyaddr_r" = "yes"; then
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+ fi
+ fi
+ #
+ if test "$tst_compi_gethostbyaddr_r" = "yes"; then
+ AC_MSG_CHECKING([if gethostbyaddr_r usage allowed])
+ if test "x$curl_disallow_gethostbyaddr_r" != "xyes"; then
+ AC_MSG_RESULT([yes])
+ tst_allow_gethostbyaddr_r="yes"
+ else
+ AC_MSG_RESULT([no])
+ tst_allow_gethostbyaddr_r="no"
+ fi
+ fi
+ #
+ AC_MSG_CHECKING([if gethostbyaddr_r might be used])
+ if test "$tst_links_gethostbyaddr_r" = "yes" &&
+ test "$tst_proto_gethostbyaddr_r" = "yes" &&
+ test "$tst_compi_gethostbyaddr_r" = "yes" &&
+ test "$tst_allow_gethostbyaddr_r" = "yes"; then
+ AC_MSG_RESULT([yes])
+ AC_DEFINE_UNQUOTED(HAVE_GETHOSTBYADDR_R, 1,
+ [Define to 1 if you have the gethostbyaddr_r function.])
+ dnl AC_DEFINE_UNQUOTED(GETHOSTBYADDR_R_ARGS, $tst_nargs_gethostbyaddr_r,
+ dnl [Specifies the number of arguments to gethostbyaddr_r])
+ #
+ if test "$tst_nargs_getservbyport_r" -eq "5"; then
+ AC_DEFINE(HAVE_GETHOSTBYADDR_R_5, 1, [gethostbyaddr_r() takes 5 args])
+ elif test "$tst_nargs_getservbyport_r" -eq "7"; then
+ AC_DEFINE(HAVE_GETHOSTBYADDR_R_7, 1, [gethostbyaddr_r() takes 7 args])
+ elif test "$tst_nargs_getservbyport_r" -eq "6"; then
+ AC_DEFINE(HAVE_GETHOSTBYADDR_R_8, 1, [gethostbyaddr_r() takes 8 args])
+ fi
+ #
+ ac_cv_func_gethostbyaddr_r="yes"
+ else
+ AC_MSG_RESULT([no])
+ ac_cv_func_gethostbyaddr_r="no"
+ fi
+])
+
+
+dnl CURL_CHECK_FUNC_GETHOSTBYNAME_R
+dnl -------------------------------------------------
+dnl Verify if gethostbyname_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 curl_disallow_gethostbyname_r, then
+dnl HAVE_GETHOSTBYNAME_R will be defined.
+
+AC_DEFUN([CURL_CHECK_FUNC_GETHOSTBYNAME_R], [
+ AC_REQUIRE([CURL_INCLUDES_SYS_UIO])dnl
+ #
+ tst_links_gethostbyname_r="unknown"
+ tst_proto_gethostbyname_r="unknown"
+ tst_compi_gethostbyname_r="unknown"
+ tst_allow_gethostbyname_r="unknown"
+ tst_nargs_gethostbyname_r="unknown"
+ #
+ AC_MSG_CHECKING([if gethostbyname_r can be linked])
+ AC_LINK_IFELSE([
+ AC_LANG_FUNC_LINK_TRY([gethostbyname_r])
+ ],[
+ AC_MSG_RESULT([yes])
+ tst_links_gethostbyname_r="yes"
+ ],[
+ AC_MSG_RESULT([no])
+ tst_links_gethostbyname_r="no"
+ ])
+ #
+ if test "$tst_links_gethostbyname_r" = "yes"; then
+ AC_MSG_CHECKING([if gethostbyname_r is prototyped])
+ AC_EGREP_CPP([gethostbyname_r],[
+ $curl_includes_netdb
+ ],[
+ AC_MSG_RESULT([yes])
+ tst_proto_gethostbyname_r="yes"
+ ],[
+ AC_MSG_RESULT([no])
+ tst_proto_gethostbyname_r="no"
+ ])
+ fi
+ #
+ if test "$tst_proto_gethostbyname_r" = "yes"; then
+ if test "$tst_nargs_gethostbyname_r" = "unknown"; then
+ AC_MSG_CHECKING([if gethostbyname_r takes 3 args.])
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([[
+ $curl_includes_netdb
+ ]],[[
+ if(0 != gethostbyname_r(0, 0, 0))
+ return 1;
+ ]])
+ ],[
+ AC_MSG_RESULT([yes])
+ tst_compi_gethostbyname_r="yes"
+ tst_nargs_gethostbyname_r="3"
+ ],[
+ AC_MSG_RESULT([no])
+ tst_compi_gethostbyname_r="no"
+ ])
+ fi
+ if test "$tst_nargs_gethostbyname_r" = "unknown"; then
+ AC_MSG_CHECKING([if gethostbyname_r takes 5 args.])
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([[
+ $curl_includes_netdb
+ ]],[[
+ if(0 != gethostbyname_r(0, 0, 0, 0, 0))
+ return 1;
+ ]])
+ ],[
+ AC_MSG_RESULT([yes])
+ tst_compi_gethostbyname_r="yes"
+ tst_nargs_gethostbyname_r="5"
+ ],[
+ AC_MSG_RESULT([no])
+ tst_compi_gethostbyname_r="no"
+ ])
+ fi
+ if test "$tst_nargs_gethostbyname_r" = "unknown"; then
+ AC_MSG_CHECKING([if gethostbyname_r takes 6 args.])
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([[
+ $curl_includes_netdb
+ ]],[[
+ if(0 != gethostbyname_r(0, 0, 0, 0, 0, 0))
+ return 1;
+ ]])
+ ],[
+ AC_MSG_RESULT([yes])
+ tst_compi_gethostbyname_r="yes"
+ tst_nargs_gethostbyname_r="6"
+ ],[
+ AC_MSG_RESULT([no])
+ tst_compi_gethostbyname_r="no"
+ ])
+ fi
+ AC_MSG_CHECKING([if gethostbyname_r is compilable])
+ if test "$tst_compi_gethostbyname_r" = "yes"; then
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+ fi
+ fi
+ #
+ if test "$tst_compi_gethostbyname_r" = "yes"; then
+ AC_MSG_CHECKING([if gethostbyname_r usage allowed])
+ if test "x$curl_disallow_gethostbyname_r" != "xyes"; then
+ AC_MSG_RESULT([yes])
+ tst_allow_gethostbyname_r="yes"
+ else
+ AC_MSG_RESULT([no])
+ tst_allow_gethostbyname_r="no"
+ fi
+ fi
+ #
+ AC_MSG_CHECKING([if gethostbyname_r might be used])
+ if test "$tst_links_gethostbyname_r" = "yes" &&
+ test "$tst_proto_gethostbyname_r" = "yes" &&
+ test "$tst_compi_gethostbyname_r" = "yes" &&
+ test "$tst_allow_gethostbyname_r" = "yes"; then
+ AC_MSG_RESULT([yes])
+ AC_DEFINE_UNQUOTED(HAVE_GETHOSTBYNAME_R, 1,
+ [Define to 1 if you have the gethostbyname_r function.])
+ dnl AC_DEFINE_UNQUOTED(GETHOSTBYNAME_R_ARGS, $tst_nargs_gethostbyname_r,
+ dnl [Specifies the number of arguments to gethostbyname_r])
+ #
+ if test "$tst_nargs_getservbyport_r" -eq "3"; then
+ AC_DEFINE(HAVE_GETHOSTBYNAME_R_3, 1, [gethostbyname_r() takes 3 args])
+ elif test "$tst_nargs_getservbyport_r" -eq "5"; then
+ AC_DEFINE(HAVE_GETHOSTBYNAME_R_5, 1, [gethostbyname_r() takes 5 args])
+ elif test "$tst_nargs_getservbyport_r" -eq "6"; then
+ AC_DEFINE(HAVE_GETHOSTBYNAME_R_6, 1, [gethostbyname_r() takes 6 args])
+ fi
+ #
+ ac_cv_func_gethostbyname_r="yes"
+ else
+ AC_MSG_RESULT([no])
+ ac_cv_func_gethostbyname_r="no"
+ fi
+])
+
+
dnl CURL_CHECK_FUNC_GETHOSTNAME
dnl -------------------------------------------------
dnl Verify if gethostname is available, prototyped, and