]> granicus.if.org Git - curl/commitdiff
Adjusted to the GETHOSTBYADDR_R_NARGS style
authorDaniel Stenberg <daniel@haxx.se>
Tue, 30 May 2000 22:27:39 +0000 (22:27 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 30 May 2000 22:27:39 +0000 (22:27 +0000)
lib/ftp.c
lib/hostip.c

index 3fd782de07ac45aaf31dd50972720c6d6c0a1178..13ea3b9a0deabce661af423b21afdfd5c30be80b 100644 (file)
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -692,20 +692,34 @@ CURLcode _ftp(struct connectdata *conn)
 
 #if defined(HAVE_INET_ADDR)
         unsigned long address;
-#if defined(HAVE_GETHOSTBYADDR_R)
+# if defined(HAVE_GETHOSTBYADDR_R)
         int h_errnop;
-#endif
+# endif
 
         address = inet_addr(newhost);
-#if defined(HAVE_GETHOSTBYADDR_R)
+# if defined(HAVE_GETHOSTBYADDR_R)
+
+#  if (GETHOSTBYADDR_R_NARGS < 8)
+        /* Solaris and IRIX */
         answer = gethostbyaddr_r((char *) &address, sizeof(address), AF_INET,
                                  (struct hostent *)hostent_buf,
                                  hostent_buf + sizeof(*answer),
                                  sizeof(hostent_buf) - sizeof(*answer),
                                  &h_errnop);
-#else
+#  else
+        /* Linux style */
+        if(gethostbyaddr_r((char *) &address, sizeof(address), AF_INET,
+                           (struct hostent *)hostent_buf,
+                           hostent_buf + sizeof(*answer),
+                           sizeof(hostent_buf) - sizeof(*answer),
+                           &answer,
+                           &h_errnop))
+           answer=NULL; /* error */
+#  endif
+        
+# else
         answer = gethostbyaddr((char *) &address, sizeof(address), AF_INET);
-#endif
+# endif
 #else
         answer = NULL;
 #endif
index ca8bf916aa85c91e5a6efbb49f7a26e96ca1f76c..76a781148f2db27cb802b6e6f0a48eb50b836484 100644 (file)
@@ -120,10 +120,22 @@ struct hostent *GetHost(struct UrlData *data,
   else {
     int h_errnop;
     memset(buf,0,buf_size);    /* workaround for gethostbyname_r bug in qnx nto */
+#if (GETHOSTBYNAME_R_NARGS < 6)
+    /* Solaris, IRIX and more */
     if ((h = gethostbyname_r(hostname,
                              (struct hostent *)buf,buf +
                              sizeof(struct hostent),buf_size -
-                             sizeof(struct hostent),&h_errnop)) == NULL ) {
+                             sizeof(struct hostent),&h_errnop)) == NULL )
+#else
+      /* Linux */
+      if( gethostbyname_r(hostname,
+                          (struct hostent *)buf,buf +
+                          sizeof(struct hostent),buf_size -
+                          sizeof(struct hostent),
+                          &h, /* DIFFERENCE */
+                          &h_errnop))
+#endif
+      {
       infof(data, "gethostbyname_r(2) failed for %s\n", hostname);
     }
 #else