]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Make IPv6 code more portable.
authorBruno Haible <bruno@clisp.org>
Tue, 5 Mar 2002 21:14:43 +0000 (21:14 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:07:47 +0000 (12:07 +0200)
src/ChangeLog
src/hostname.c

index 078fcd344e13c042cff38d97393709f0893dfec1..6c2d20b8ccbf963f30997758a451e87a7f155e5c 100644 (file)
@@ -1,3 +1,8 @@
+2002-03-05  Bruno Haible  <bruno@clisp.org>
+
+       * hostname.c (s6_addr16): Define if not defined by the system.
+       (ipv6_ntop): Use s6_addr16 instead of in6_u.u6_addr16.
+
 2002-03-05  Bruno Haible  <bruno@clisp.org>
 
        * xgettext.c (usage): Mention languages Python, awk, Tcl, RST, Glade.
index 7208f53b765c23bdfa46a6f0e1e176da46c16288..88bff6f2545ea2742ec787f29f40d25b2430cddf 100644 (file)
@@ -1,5 +1,5 @@
 /* Display hostname in various forms.
-   Copyright (C) 2001 Free Software Foundation, Inc.
+   Copyright (C) 2001-2002 Free Software Foundation, Inc.
    Written by Bruno Haible <haible@clisp.cons.org>, 2001.
 
    This program is free software; you can redistribute it and/or modify
 #  if defined(__APPLE__) && defined(__MACH__) /* MacOS X */
 #   define in6_u __u6_addr
 #   define u6_addr16 __u6_addr16
+#  endif
+   /* Use s6_addr16 for portability.  See RFC 2553.  */
+#  ifndef s6_addr16
+#   define s6_addr16 in6_u.u6_addr16
 #  endif
 # endif
 # include <netdb.h> /* defines struct hostent, declares gethostbyname() */
@@ -252,7 +256,7 @@ xgethostname ()
 }
 
 /* Converts an AF_INET address to a printable, presentable format.
-   BUFFER is an array with at least 15+1 bytes.  ADDR is sockaddr_in.  */
+   BUFFER is an array with at least 15+1 bytes.  ADDR is 'struct in_addr'.  */
 #if HAVE_INET_NTOP
 # define ipv4_ntop(buffer,addr) \
     inet_ntop (AF_INET, &addr, buffer, 15+1)
@@ -263,21 +267,21 @@ xgethostname ()
 
 #if HAVE_IPV6
 /* Converts an AF_INET6 address to a printable, presentable format.
-   BUFFER is an array with at least 45+1 bytes.  ADDR is sockaddr_in6.  */
+   BUFFER is an array with at least 45+1 bytes.  ADDR is 'struct in6_addr'.  */
 # if HAVE_INET_NTOP
 #  define ipv6_ntop(buffer,addr) \
      inet_ntop (AF_INET6, &addr, buffer, 45+1)
 # else
 #  define ipv6_ntop(buffer,addr) \
      sprintf (buffer, "%x:%x:%x:%x:%x:%x:%x:%x", \
-             ntohs ((addr).in6_u.u6_addr16[0]), \
-             ntohs ((addr).in6_u.u6_addr16[1]), \
-             ntohs ((addr).in6_u.u6_addr16[2]), \
-             ntohs ((addr).in6_u.u6_addr16[3]), \
-             ntohs ((addr).in6_u.u6_addr16[4]), \
-             ntohs ((addr).in6_u.u6_addr16[5]), \
-             ntohs ((addr).in6_u.u6_addr16[6]), \
-             ntohs ((addr).in6_u.u6_addr16[7]))
+             ntohs ((addr).s6_addr16[0]), \
+             ntohs ((addr).s6_addr16[1]), \
+             ntohs ((addr).s6_addr16[2]), \
+             ntohs ((addr).s6_addr16[3]), \
+             ntohs ((addr).s6_addr16[4]), \
+             ntohs ((addr).s6_addr16[5]), \
+             ntohs ((addr).s6_addr16[6]), \
+             ntohs ((addr).s6_addr16[7]))
 # endif
 #endif