]> sjero.net Git - wget/blobdiff - src/host.c
[svn] Change u_int32_t to uint32_t.
[wget] / src / host.c
index 12b80602146f4b615c761ae2fea3106a650d3200..5297d0f34347bc5b926d3d35192bf958f48e60c9 100644 (file)
@@ -419,9 +419,9 @@ wget_sockaddr_get_port (const wget_sockaddr *sa)
   * -          Public IP-Family Information
   *
   * Output:
-  * int                structure length for socket options
+  * socklen_t  structure length for socket options
   */
-int 
+socklen_t
 sockaddr_len () 
 {
   if (ip_default_family == AF_INET) 
@@ -494,7 +494,7 @@ gethostbyname_with_timeout_callback (void *arg)
    other than timeout, errno is reset.  */
 
 static struct hostent *
-gethostbyname_with_timeout (const char *host_name, int timeout)
+gethostbyname_with_timeout (const char *host_name, double timeout)
 {
   struct ghbnwt_context ctx;
   ctx.host_name = host_name;
@@ -533,7 +533,7 @@ getaddrinfo_with_timeout_callback (void *arg)
 static int
 getaddrinfo_with_timeout (const char *node, const char *service,
                          const struct addrinfo *hints, struct addrinfo **res,
-                         int timeout)
+                         double timeout)
 {
   struct gaiwt_context ctx;
   ctx.node = node;
@@ -585,7 +585,7 @@ cache_host_lookup (const char *host, struct address_list *al)
   ++al->refcount;
   hash_table_put (host_name_addresses_map, xstrdup_lower (host), al);
 
-#ifdef DEBUG
+#ifdef ENABLE_DEBUG
   if (opt.debug)
     {
       int i;
@@ -601,7 +601,7 @@ struct address_list *
 lookup_host (const char *host, int silent)
 {
   struct address_list *al = NULL;
-  unsigned long addr_ipv4;     /* #### use a 32-bit type here. */
+  uint32_t addr_ipv4;
   ip_address addr;
 
   /* First, try to check whether the address is already a numeric
@@ -612,26 +612,18 @@ lookup_host (const char *host, int silent)
     return address_list_from_single (&addr);
 #endif
 
-  addr_ipv4 = (unsigned long)inet_addr (host);
-  if ((int)addr_ipv4 != -1)
+  addr_ipv4 = (uint32_t)inet_addr (host);
+  if (addr_ipv4 != (uint32_t)-1)
     {
       /* ADDR is defined to be in network byte order, which is what
-        this returns, so we can just copy it to STORE_IP.  However,
-        on big endian 64-bit architectures the value will be stored
-        in the *last*, not first four bytes.  OFFSET makes sure that
-        we copy the correct four bytes.  */
-      int offset = 0;
-#ifdef WORDS_BIGENDIAN
-      offset = sizeof (unsigned long) - sizeof (ip4_address);
-#endif
-      map_ipv4_to_ip ((ip4_address *)((char *)&addr_ipv4 + offset), &addr);
+        this returns, so we can just copy it to STORE_IP.  */
+      map_ipv4_to_ip ((ip4_address *)&addr_ipv4, &addr);
       return address_list_from_single (&addr);
     }
 
   if (host_name_addresses_map)
     {
       al = hash_table_get (host_name_addresses_map, host);
-
       if (al)
        {
          DEBUGP (("Found %s in host_name_addresses_map (%p)\n", host, al));
@@ -656,7 +648,7 @@ lookup_host (const char *host, int silent)
     else
       hints.ai_family   = PF_UNSPEC;
     hints.ai_socktype = SOCK_STREAM;
-    err = getaddrinfo_with_timeout (host, NULL, &hints, &ai, opt.timeout);
+    err = getaddrinfo_with_timeout (host, NULL, &hints, &ai, opt.dns_timeout);
 
     if (err != 0 || ai == NULL)
       {
@@ -670,7 +662,8 @@ lookup_host (const char *host, int silent)
   }
 #else
   {
-    struct hostent *hptr = gethostbyname_with_timeout (host, opt.timeout);
+    struct hostent *hptr;
+    hptr = gethostbyname_with_timeout (host, opt.dns_timeout);
     if (!hptr)
       {
        if (!silent)