From d4731b70505d308064e85bfa1ea1f88904442af2 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 23 Aug 2000 07:23:42 +0000 Subject: Albert Chin-A-Young's fixes --- lib/hostip.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'lib/hostip.c') diff --git a/lib/hostip.c b/lib/hostip.c index 3ae21cb1b..fe8a7743f 100644 --- a/lib/hostip.c +++ b/lib/hostip.c @@ -40,9 +40,12 @@ #include #include +#include #include "setup.h" +#define _REENTRANT + #if defined(WIN32) && !defined(__GNUC__) || defined(__MINGW32__) #include #else @@ -52,8 +55,12 @@ #ifdef HAVE_SYS_SOCKET_H #include #endif +#ifdef HAVE_NETINET_IN_H #include +#endif +#ifdef HAVE_NETDB_H #include +#endif #ifdef HAVE_ARPA_INET_H #include #endif @@ -62,9 +69,7 @@ #include "urldata.h" #include "sendf.h" -#define _REENTRANT - -#ifdef HAVE_INET_NTOA_R +#ifndef HAVE_INET_NTOA_R_DECL #include "inet_ntoa_r.h" #endif @@ -103,6 +108,7 @@ struct hostent *GetHost(struct UrlData *data, { struct hostent *h = NULL; unsigned long in; + int ret; if ( (in=inet_addr(hostname)) != INADDR_NONE ) { struct in_addr *addrentry; @@ -145,13 +151,17 @@ struct hostent *GetHost(struct UrlData *data, /* August 4th, 2000. I don't have any such system around so I write this blindly in hope it might work or that someone else will help me fix - this. */ + this. August 22nd, 2000: Albert Chin-A-Young brought an updated version + that should work! */ - h = gethostbyname_r(hostname, + ret = gethostbyname_r(hostname, (struct hostent *)buf, (struct hostent_data *)(buf + sizeof(struct hostent))); + + /* result expected in h */ + h = (struct hostent*)buf; h_errnop= errno; /* we don't deal with this, but set it anyway */ - if(NULL == h) + if(ret) #endif { infof(data, "gethostbyname_r(2) failed for %s\n", hostname); -- cgit v1.2.3