]> sjero.net Git - wget/commitdiff
[svn] Provide the support for int32_t and u_int32_t.
authorhniksic <devnull@localhost>
Sat, 11 Oct 2003 02:27:41 +0000 (19:27 -0700)
committerhniksic <devnull@localhost>
Sat, 11 Oct 2003 02:27:41 +0000 (19:27 -0700)
ChangeLog
configure.in
src/ChangeLog
src/config.h.in
src/host.c
src/sysdep.h

index c22d34799c2dfabbab327209b8b6b96bcd473753..bcf3f8ba3602e441f548561575d9b0ec3a3318e2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2003-10-11  Hrvoje Niksic  <hniksic@xemacs.org>
+
+       * configure.in: Check for int32_t and u_int32_t.  Check for
+       SIZEOF_INT.
+
 2003-10-10  Hrvoje Niksic  <hniksic@xemacs.org>
 
        * aclocal.m4 (WGET_WITH_NLS): First check for gettext in libintl,
index 8e46ff6506199bee64ef93fea27b11d540d57f5c..d5f3ffd7f84c92de717c799b252055315f88726c 100644 (file)
@@ -157,9 +157,14 @@ AC_TYPE_SIZE_T
 AC_TYPE_PID_T
 AC_C_BIGENDIAN
 
-# Check size of long.
+dnl
+dnl Check integral type sizes.
+dnl
+AC_CHECK_SIZEOF(int)
 AC_CHECK_SIZEOF(long)
 AC_CHECK_SIZEOF(long long)
+AC_CHECK_TYPES(int32_t)
+AC_CHECK_TYPES(u_int32_t)
 
 dnl
 dnl Checks for headers
index 23b5dae18abb9e401c50f0c227aefb7c574065af..2e7fc75083e2ad61343cb46620b4a46ebc6c5db3 100644 (file)
@@ -1,3 +1,11 @@
+2003-10-11  Hrvoje Niksic  <hniksic@xemacs.org>
+
+       * host.c (lookup_host): Use u_int32_t to store the result of
+       inet_addr().  That removes the need for offset fiddling, caring
+       about endian-ness, etc.
+
+       * sysdep.h: Define int32_t and u_int32_t if not available.
+
 2003-10-11  Hrvoje Niksic  <hniksic@xemacs.org>
 
        * ftp-basic.c (ftp_epsv): Use socklen_t * as the third argument to
index eb811e3b900020c93f2f79d6fcdaea4822d1c52d..c05f00c35a034819232c929f000ebb3e8e788caf 100644 (file)
@@ -80,6 +80,9 @@ char *alloca ();
    significant byte first).  */
 #undef WORDS_BIGENDIAN
 
+/* Define to the length of int. */
+#undef SIZEOF_INT
+
 /* Define to the length of long. */
 #undef SIZEOF_LONG
 
@@ -271,9 +274,15 @@ char *alloca ();
 /* Define if you want to enable the IPv6 support.  */
 #undef ENABLE_IPV6
 
-/* Define if you don't have socklen_t.  */
+/* Defined to int or size_t on systems without socklen_t.  */
 #undef socklen_t
 
+/* Define if you have int32_t.  */
+#undef HAVE_INT32_T
+
+/* Define if you have u_int32_t.  */
+#undef HAVE_U_INT32_T
+
 /* First a gambit to see whether we're on Solaris.  We'll
    need it below.  */
 #ifdef __sun
index 652edacfb2d81d645b11d0fc0da458908ee7d794..d0ec76752f3dc4f5a7b830d7400a44714c0df019 100644 (file)
@@ -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. */
+  u_int32_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 = (u_int32_t)inet_addr (host);
+  if (addr_ipv4 != (u_int32_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));
index a42cfa8aef31698ef950d00d48b7e991687e65ab..2defc65a349676a9445d31ff1561bde52de27906 100644 (file)
@@ -243,4 +243,30 @@ void *memcpy ();
 int fnmatch ();
 #endif
 
+/* Provide 32-bit types for the code that really needs it.  */
+
+#ifndef HAVE_INT32_T
+# if SIZEOF_INT == 4
+typedef int int32_t;
+# else
+#  if SIZEOF_LONG == 4
+typedef long int32_t;
+#  else
+     "Cannot determine a 32-bit type"
+#  endif
+# endif
+#endif
+
+#ifndef HAVE_U_INT32_T
+# if SIZEOF_INT == 4
+typedef unsigned int u_int32_t;
+# else
+#  if SIZEOF_LONG == 4
+typedef unsigned long u_int32_t;
+#  else
+     "Cannot determine a 32-bit type"
+#  endif
+# endif
+#endif
+
 #endif /* SYSDEP_H */