Commit | Line | Data |
---|---|---|
bb0cfa24 DF |
1 | /* |
2 | * Copyright (c) 1983 Regents of the University of California. | |
140b4f5f KB |
3 | * All rights reserved. |
4 | * | |
269a7923 | 5 | * %sccs.include.redist.c% |
bb0cfa24 DF |
6 | */ |
7 | ||
2ce81398 | 8 | #if defined(LIBC_SCCS) && !defined(lint) |
24fac7d8 | 9 | static char sccsid[] = "@(#)inet_ntoa.c 5.6 (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 | |
21 | char * | |
22 | inet_ntoa(in) | |
23 | struct in_addr in; | |
24 | { | |
25 | static char b[18]; | |
26 | register char *p; | |
27 | ||
28 | p = (char *)∈ | |
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 | } |