xref: /csrg-svn/lib/libc/net/inet_ntoa.c (revision 26615)
121371Sdist /*
221371Sdist  * Copyright (c) 1983 Regents of the University of California.
321371Sdist  * All rights reserved.  The Berkeley software License Agreement
421371Sdist  * specifies the terms and conditions for redistribution.
521371Sdist  */
613031Sroot 
7*26615Sdonn #if defined(LIBC_SCCS) && !defined(lint)
8*26615Sdonn static char sccsid[] = "@(#)inet_ntoa.c	5.2 (Berkeley) 03/09/86";
9*26615Sdonn #endif LIBC_SCCS and not lint
1021371Sdist 
1113031Sroot /*
1213031Sroot  * Convert network-format internet address
1313031Sroot  * to base 256 d.d.d.d representation.
1413031Sroot  */
1513031Sroot #include <sys/types.h>
1613031Sroot #include <netinet/in.h>
1713031Sroot 
1813031Sroot char *
1913031Sroot inet_ntoa(in)
2013031Sroot 	struct in_addr in;
2113031Sroot {
2213031Sroot 	static char b[18];
2313031Sroot 	register char *p;
2413031Sroot 
2513031Sroot 	p = (char *)&in;
2613031Sroot #define	UC(b)	(((int)b)&0xff)
2713031Sroot 	sprintf(b, "%d.%d.%d.%d", UC(p[0]), UC(p[1]), UC(p[2]), UC(p[3]));
2813031Sroot 	return (b);
2913031Sroot }
30