xref: /csrg-svn/lib/libc/net/inet_ntoa.c (revision 42626)
121371Sdist /*
221371Sdist  * Copyright (c) 1983 Regents of the University of California.
333676Sbostic  * All rights reserved.
433676Sbostic  *
5*42626Sbostic  * %sccs.include.redist.c%
621371Sdist  */
713031Sroot 
826615Sdonn #if defined(LIBC_SCCS) && !defined(lint)
9*42626Sbostic static char sccsid[] = "@(#)inet_ntoa.c	5.5 (Berkeley) 06/01/90";
1033676Sbostic #endif /* LIBC_SCCS and not lint */
1121371Sdist 
1213031Sroot /*
1313031Sroot  * Convert network-format internet address
1413031Sroot  * to base 256 d.d.d.d representation.
1513031Sroot  */
1613031Sroot #include <sys/types.h>
1713031Sroot #include <netinet/in.h>
1813031Sroot 
1913031Sroot char *
2013031Sroot inet_ntoa(in)
2113031Sroot 	struct in_addr in;
2213031Sroot {
2313031Sroot 	static char b[18];
2413031Sroot 	register char *p;
2513031Sroot 
2613031Sroot 	p = (char *)&in;
2713031Sroot #define	UC(b)	(((int)b)&0xff)
2813031Sroot 	sprintf(b, "%d.%d.%d.%d", UC(p[0]), UC(p[1]), UC(p[2]), UC(p[3]));
2913031Sroot 	return (b);
3013031Sroot }
31