cURL / Mailing Lists / curl-users / Single Mail

curl-users

TESTERS NEEDED: autoconf change

From: <curl_at_thewrittenword.com>
Date: Thu, 4 Oct 2001 07:44:47 -0500

Some moons ago, I contributed autoconf macros to determine the number
of arguments to gethostbyname_r() and gethostbyaddr_r(). The major
downside to the implementation of gethostbyname_r() was that it
required "localhost" to be resolvable, a problem on Windows. Using the
same tact in TYPE_SOCKLEN_T to determine the socklen_t type, I've
modified the gethostbyname_r macro to remove the requirement for
"localhost". The gethostbyaddr_r macro has been left alone. This is
done by looping through custom prototypes for both functions until the
compilers does not complain. This means that this will work only with
an ANSI C compiler.

Attached are patches to curl 7.9. I have tested on Solaris, HP-UX,
IRIX, Tru64 UNIX, AIX, and Debian GNU/Linux 2.2. Additional testers on
Linux would be greatly appreciated. The number of arguments detected
to gethostbyname_r and gethostbyaddr_r by configure.in for curl 7.8.1
should match that of 7.9. If not, we have a problem. Please report
success/failure to me.

After applying the patch, you need to do the following before running
configure:
  $ aclocal
  $ autoconf

Daniel, you ok with this?

-- 
albert chin (china_at_thewrittenword.com)
-- snip snip
--- acinclude.m4.orig	Thu Oct  4 06:39:21 2001
+++ acinclude.m4	Thu Oct  4 07:39:24 2001
@@ -142,7 +142,6 @@
 	AC_DEFINE(NEED_REENTRANT)
 	AC_MSG_RESULT(yes)],
 	AC_MSG_RESULT(no))])])
-
 ])
 
 AC_DEFUN(CURL_CHECK_GETHOSTBYADDR_R,
@@ -220,8 +219,6 @@
 	    ac_cv_gethostbyaddr_args=8],[
 	    AC_MSG_RESULT(no)
 	    have_missing_r_funcs="$have_missing_r_funcs gethostbyaddr_r"])])])])])
-
-
 ])
 
 AC_DEFUN(CURL_CHECK_GETHOSTBYNAME_R,
@@ -229,28 +226,21 @@
   dnl check for number of arguments to gethostbyname_r. it might take
   dnl either 3, 5, or 6 arguments.
   AC_CHECK_FUNCS(gethostbyname_r,[
-    AC_MSG_CHECKING(if gethostbyname_r takes 3 arguments)
-    AC_TRY_RUN([
+    AC_MSG_CHECKING([if gethostbyname_r takes 3 arguments])
+    AC_TRY_COMPILE([
 #include <string.h>
 #include <sys/types.h>
 #include <netdb.h>
 
 int
-main () {
-struct hostent h;
-struct hostent_data hdata;
-char *name = "localhost";
-int rc;
-memset(&h, 0, sizeof(struct hostent));
-memset(&hdata, 0, sizeof(struct hostent_data));
-rc = gethostbyname_r(name, &h, &hdata);
-exit (rc != 0 ? 1 : 0); }],[
+gethostbyname_r(const char *, struct hostent *, struct hostent_data *);],[
+gethostbyname_r(NULL, NULL, NULL);],[
       AC_MSG_RESULT(yes)
       AC_DEFINE(HAVE_GETHOSTBYNAME_R_3)
       ac_cv_gethostbyname_args=3],[
       AC_MSG_RESULT(no)
-      AC_MSG_CHECKING(if gethostbyname_r with -D_REENTRANT takes 3 arguments)
-      AC_TRY_RUN([
+      AC_MSG_CHECKING([if gethostbyname_r with -D_REENTRANT takes 3 arguments])
+      AC_TRY_COMPILE([
 #define _REENTRANT
 
 #include <string.h>
@@ -258,53 +248,34 @@
 #include <netdb.h>
 
 int
-main () {
-struct hostent h;
-struct hostent_data hdata;
-char *name = "localhost";
-int rc;
-memset(&h, 0, sizeof(struct hostent));
-memset(&hdata, 0, sizeof(struct hostent_data));
-rc = gethostbyname_r(name, &h, &hdata);
-exit (rc != 0 ? 1 : 0); }],[
+gethostbyname_r(const char *,struct hostent *, struct hostent_data *);],[
+gethostbyname_r(NULL, NULL, NULL);],[
 	AC_MSG_RESULT(yes)
 	AC_DEFINE(HAVE_GETHOSTBYNAME_R_3)
 	AC_DEFINE(NEED_REENTRANT)
 	ac_cv_gethostbyname_args=3],[
 	AC_MSG_RESULT(no)
-	AC_MSG_CHECKING(if gethostbyname_r takes 5 arguments)
-	AC_TRY_RUN([
+	AC_MSG_CHECKING([if gethostbyname_r takes 5 arguments])
+	AC_TRY_COMPILE([
 #include <sys/types.h>
 #include <netdb.h>
 
-int
-main () {
-struct hostent *hp;
-struct hostent h;
-char *name = "localhost";
-char buffer[8192];
-int h_errno;
-hp = gethostbyname_r(name, &h, buffer, 8192, &h_errno);
-exit (hp == NULL ? 1 : 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)
           ac_cv_gethostbyname_args=5],[
 	  AC_MSG_RESULT(no)
-	  AC_MSG_CHECKING(if gethostbyname_r takes 6 arguments)
-	  AC_TRY_RUN([
+	  AC_MSG_CHECKING([if gethostbyname_r takes 6 arguments])
+	  AC_TRY_COMPILE([
 #include <sys/types.h>
 #include <netdb.h>
 
 int
-main () {
-struct hostent h;
-struct hostent *hp;
-char *name = "localhost";
-char buf[8192];
-int rc;
-int h_errno;
-rc = gethostbyname_r(name, &h, buf, 8192, &hp, &h_errno);
-exit (rc != 0 ? 1 : 0); }],[
+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)
             ac_cv_gethostbyname_args=6],[
--- configure.in.orig	Thu Oct  4 06:39:18 2001
+++ configure.in	Thu Oct  4 07:10:38 2001
@@ -428,9 +428,6 @@
 Set to explicitly specify we don't want to use thread-safe functions)
 else
 
-  dnl check that 'localhost' resolves first
-  CURL_CHECK_WORKING_RESOLVER
-
   dnl dig around for gethostbyname_r()
   CURL_CHECK_GETHOSTBYNAME_R()
 
Received on 2001-10-04