diff options
Diffstat (limited to 'lib/libc/net/inet_ntoa.c')
-rw-r--r-- | lib/libc/net/inet_ntoa.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/lib/libc/net/inet_ntoa.c b/lib/libc/net/inet_ntoa.c index a37b1db..4fdceee 100644 --- a/lib/libc/net/inet_ntoa.c +++ b/lib/libc/net/inet_ntoa.c @@ -35,25 +35,23 @@ static char sccsid[] = "@(#)inet_ntoa.c 8.1 (Berkeley) 6/4/93"; #endif /* LIBC_SCCS and not lint */ -/* - * Convert network-format internet address - * to base 256 d.d.d.d representation. - */ #include <sys/types.h> +#include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <stdio.h> +/* + * Convert network-format internet address + * to base 256 d.d.d.d representation. + */ char * inet_ntoa(in) struct in_addr in; { - static char b[18]; - register char *p; + static char ret[18]; - p = (char *)∈ -#define UC(b) (((int)b)&0xff) - (void)snprintf(b, sizeof(b), - "%d.%d.%d.%d", UC(p[0]), UC(p[1]), UC(p[2]), UC(p[3])); - return (b); + strcpy(ret, "[inet_ntoa error]"); + (void) inet_ntop(AF_INET, &in, ret, sizeof ret); + return (ret); } |