xref: /csrg-svn/lib/libc/net/inet_ntoa.c (revision 21371)
1*21371Sdist /*
2*21371Sdist  * Copyright (c) 1983 Regents of the University of California.
3*21371Sdist  * All rights reserved.  The Berkeley software License Agreement
4*21371Sdist  * specifies the terms and conditions for redistribution.
5*21371Sdist  */
613031Sroot 
7*21371Sdist #ifndef lint
8*21371Sdist static char sccsid[] = "@(#)inet_ntoa.c	5.1 (Berkeley) 05/30/85";
9*21371Sdist #endif not lint
10*21371Sdist 
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