4.4BSD snapshot (revision 8.1); add 1993 to copyright
[unix-history] / usr / src / lib / libc / net / inet_ntoa.c
... / ...
CommitLineData
1/*
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * %sccs.include.redist.c%
6 */
7
8#if defined(LIBC_SCCS) && !defined(lint)
9static char sccsid[] = "@(#)inet_ntoa.c 8.1 (Berkeley) %G%";
10#endif /* LIBC_SCCS and not lint */
11
12/*
13 * Convert network-format internet address
14 * to base 256 d.d.d.d representation.
15 */
16#include <sys/types.h>
17#include <netinet/in.h>
18#include <arpa/inet.h>
19#include <stdio.h>
20
21char *
22inet_ntoa(in)
23 struct in_addr in;
24{
25 static char b[18];
26 register char *p;
27
28 p = (char *)&in;
29#define UC(b) (((int)b)&0xff)
30 (void)snprintf(b, sizeof(b),
31 "%d.%d.%d.%d", UC(p[0]), UC(p[1]), UC(p[2]), UC(p[3]));
32 return (b);
33}