xref: /csrg-svn/lib/libc/net/inet_ntoa.c (revision 33676)
1 /*
2  * Copyright (c) 1983 Regents of the University of California.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms are permitted
6  * provided that this notice is preserved and that due credit is given
7  * to the University of California at Berkeley. The name of the University
8  * may not be used to endorse or promote products derived from this
9  * software without specific prior written permission. This software
10  * is provided ``as is'' without express or implied warranty.
11  */
12 
13 #if defined(LIBC_SCCS) && !defined(lint)
14 static char sccsid[] = "@(#)inet_ntoa.c	5.3 (Berkeley) 03/07/88";
15 #endif /* LIBC_SCCS and not lint */
16 
17 /*
18  * Convert network-format internet address
19  * to base 256 d.d.d.d representation.
20  */
21 #include <sys/types.h>
22 #include <netinet/in.h>
23 
24 char *
25 inet_ntoa(in)
26 	struct in_addr in;
27 {
28 	static char b[18];
29 	register char *p;
30 
31 	p = (char *)&in;
32 #define	UC(b)	(((int)b)&0xff)
33 	sprintf(b, "%d.%d.%d.%d", UC(p[0]), UC(p[1]), UC(p[2]), UC(p[3]));
34 	return (b);
35 }
36