4.4BSD snapshot (revision 8.1); add 1993 to copyright
[unix-history] / usr / src / lib / libc / net / inet_ntoa.c
CommitLineData
bb0cfa24 1/*
67039e6d
KB
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
140b4f5f 4 *
269a7923 5 * %sccs.include.redist.c%
bb0cfa24
DF
6 */
7
2ce81398 8#if defined(LIBC_SCCS) && !defined(lint)
67039e6d 9static char sccsid[] = "@(#)inet_ntoa.c 8.1 (Berkeley) %G%";
140b4f5f 10#endif /* LIBC_SCCS and not lint */
5c70ba72
BJ
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>
24fac7d8
KB
18#include <arpa/inet.h>
19#include <stdio.h>
5c70ba72
BJ
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)
24fac7d8
KB
30 (void)snprintf(b, sizeof(b),
31 "%d.%d.%d.%d", UC(p[0]), UC(p[1]), UC(p[2]), UC(p[3]));
5c70ba72
BJ
32 return (b);
33}