xref: /csrg-svn/lib/libc/net/inet_ntoa.c (revision 61150)
121371Sdist /*
2*61150Sbostic  * Copyright (c) 1983, 1993
3*61150Sbostic  *	The Regents of the University of California.  All rights reserved.
433676Sbostic  *
542626Sbostic  * %sccs.include.redist.c%
621371Sdist  */
713031Sroot 
826615Sdonn #if defined(LIBC_SCCS) && !defined(lint)
9*61150Sbostic static char sccsid[] = "@(#)inet_ntoa.c	8.1 (Berkeley) 06/04/93";
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>
1846604Sbostic #include <arpa/inet.h>
1946604Sbostic #include <stdio.h>
2013031Sroot 
2113031Sroot char *
inet_ntoa(in)2213031Sroot inet_ntoa(in)
2313031Sroot 	struct in_addr in;
2413031Sroot {
2513031Sroot 	static char b[18];
2613031Sroot 	register char *p;
2713031Sroot 
2813031Sroot 	p = (char *)&in;
2913031Sroot #define	UC(b)	(((int)b)&0xff)
3046604Sbostic 	(void)snprintf(b, sizeof(b),
3146604Sbostic 	    "%d.%d.%d.%d", UC(p[0]), UC(p[1]), UC(p[2]), UC(p[3]));
3213031Sroot 	return (b);
3313031Sroot }
34