]> sjero.net Git - wget/blobdiff - src/host.c
[svn] Remove duplicate initialization.
[wget] / src / host.c
index b77c1170bd0835e48caf46d58951c1d5818c8379..9d83e038119c9c4f946d51fec0f4e8a2b7b7178d 100644 (file)
@@ -67,6 +67,7 @@ so, delete this exception statement from your version.  */
 #include "host.h"
 #include "url.h"
 #include "hash.h"
+#include "connect.h"           /* for socket_has_inet6 */
 
 #ifndef errno
 extern int errno;
@@ -112,10 +113,10 @@ address_list_address_at (const struct address_list *al, int pos)
   return al->addresses + pos;
 }
 
-/* Return 1 if IP is one of the addresses in AL. */
+/* Return non-zero if AL contains IP, zero otherwise.  */
 
 int
-address_list_find (const struct address_list *al, const ip_address *ip)
+address_list_contains (const struct address_list *al, const ip_address *ip)
 {
   int i;
   switch (ip->type)
@@ -148,7 +149,7 @@ address_list_find (const struct address_list *al, const ip_address *ip)
 #endif /* ENABLE_IPV6 */
     default:
       abort ();
-      return 1;
+      return 0;
     }
 }
 
@@ -210,9 +211,9 @@ address_list_from_addrinfo (const struct addrinfo *ai)
     return NULL;
 
   al = xnew0 (struct address_list);
-  al->addresses  = xnew_array (ip_address, cnt);
-  al->count      = cnt;
-  al->refcount   = 1;
+  al->addresses = xnew_array (ip_address, cnt);
+  al->count     = cnt;
+  al->refcount  = 1;
 
   ip = al->addresses;
   for (ptr = ai; ptr != NULL; ptr = ptr->ai_next)
@@ -517,7 +518,7 @@ cache_remove (const char *host)
 struct address_list *
 lookup_host (const char *host, int flags)
 {
-  struct address_list *al = NULL;
+  struct address_list *al;
   int silent = flags & LH_SILENT;
   int use_cache;
 
@@ -575,17 +576,20 @@ lookup_host (const char *host, int flags)
 
     xzero (hints);
     hints.ai_socktype = SOCK_STREAM;
-    if (opt.ipv4_only && !opt.ipv6_only)
+    if (opt.ipv4_only)
       hints.ai_family = AF_INET;
-    else if (opt.ipv6_only && !opt.ipv4_only)
+    else if (opt.ipv6_only)
       hints.ai_family = AF_INET6;
     else
       {
        hints.ai_family = AF_UNSPEC;
 #ifdef HAVE_GETADDRINFO_AI_ADDRCONFIG
-       /* Use AI_ADDRCONFIG if available and if specific family isn't
-          explicitly requested.  See init.c:defaults().  */
        hints.ai_flags |= AI_ADDRCONFIG;
+#else
+       /* On systems without AI_ADDRCONFIG, emulate it by manually
+          checking whether the system supports IPv6 sockets.  */
+       if (!socket_has_inet6 ())
+         hints.ai_family = AF_INET;
 #endif
       }
     if (flags & LH_BIND)