X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Finet_ntop.c;h=6b801747b014bd0af3909b0d0a113cb400a83851;hb=030dc7afa953442437474140ac98ab4f8db56bc8;hp=2251aaa05663d1137a2f14a947142438791b488a;hpb=b2e2010c7c902235b5efb5bd3c6529f61b093aa4;p=gnulib.git diff --git a/lib/inet_ntop.c b/lib/inet_ntop.c index 2251aaa05..6b801747b 100644 --- a/lib/inet_ntop.c +++ b/lib/inet_ntop.c @@ -1,6 +1,6 @@ /* inet_ntop.c -- convert IPv4 and IPv6 addresses from binary to text form - Copyright (C) 2005-2006, 2008-2010 Free Software Foundation, Inc. + Copyright (C) 2005-2006, 2008-2011 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -38,23 +38,36 @@ /* Specification. */ #include -#include -#include -#include +#if HAVE_DECL_INET_NTOP -#define NS_IN6ADDRSZ 16 -#define NS_INT16SZ 2 +# undef inet_ntop + +const char * +rpl_inet_ntop (int af, const void *restrict src, + char *restrict dst, socklen_t cnt) +{ + return inet_ntop (af, src, dst, cnt); +} + +#else + +# include +# include +# include + +# define NS_IN6ADDRSZ 16 +# define NS_INT16SZ 2 /* * WARNING: Don't even consider trying to compile this on a system where * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX. */ -typedef int verify_int_size[2 * sizeof (int) - 7]; +typedef int verify_int_size[4 <= sizeof (int) ? 1 : -1]; static const char *inet_ntop4 (const unsigned char *src, char *dst, socklen_t size); -#if HAVE_IPV6 +# if HAVE_IPV6 static const char *inet_ntop6 (const unsigned char *src, char *dst, socklen_t size); -#endif +# endif /* char * @@ -71,15 +84,15 @@ inet_ntop (int af, const void *restrict src, { switch (af) { -#if HAVE_IPV4 +# if HAVE_IPV4 case AF_INET: return (inet_ntop4 (src, dst, cnt)); -#endif +# endif -#if HAVE_IPV6 +# if HAVE_IPV6 case AF_INET6: return (inet_ntop6 (src, dst, cnt)); -#endif +# endif default: errno = EAFNOSUPPORT; @@ -118,7 +131,7 @@ inet_ntop4 (const unsigned char *src, char *dst, socklen_t size) return strcpy (dst, tmp); } -#if HAVE_IPV6 +# if HAVE_IPV6 /* const char * * inet_ntop6(src, dst, size) @@ -231,4 +244,6 @@ inet_ntop6 (const unsigned char *src, char *dst, socklen_t size) return strcpy (dst, tmp); } +# endif + #endif