xref: /netbsd-src/external/bsd/libbind/dist/inet/inet_ntoa.c (revision 5bbd2a12505d72a8177929a37b5cee489d0a1cfd)
1*5bbd2a12Schristos /*	$NetBSD: inet_ntoa.c,v 1.1.1.2 2012/09/09 16:07:50 christos Exp $	*/
2b5677b36Schristos 
3b5677b36Schristos /*
4b5677b36Schristos  * Copyright (c) 1983, 1993
5b5677b36Schristos  *	The Regents of the University of California.  All rights reserved.
6b5677b36Schristos  *
7b5677b36Schristos  * Redistribution and use in source and binary forms, with or without
8b5677b36Schristos  * modification, are permitted provided that the following conditions
9b5677b36Schristos  * are met:
10b5677b36Schristos  * 1. Redistributions of source code must retain the above copyright
11b5677b36Schristos  *    notice, this list of conditions and the following disclaimer.
12b5677b36Schristos  * 2. Redistributions in binary form must reproduce the above copyright
13b5677b36Schristos  *    notice, this list of conditions and the following disclaimer in the
14b5677b36Schristos  *    documentation and/or other materials provided with the distribution.
15b5677b36Schristos  * 3. All advertising materials mentioning features or use of this software
16b5677b36Schristos  *    must display the following acknowledgement:
17b5677b36Schristos  *	This product includes software developed by the University of
18b5677b36Schristos  *	California, Berkeley and its contributors.
19b5677b36Schristos  * 4. Neither the name of the University nor the names of its contributors
20b5677b36Schristos  *    may be used to endorse or promote products derived from this software
21b5677b36Schristos  *    without specific prior written permission.
22b5677b36Schristos  *
23b5677b36Schristos  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24b5677b36Schristos  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25b5677b36Schristos  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26b5677b36Schristos  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27b5677b36Schristos  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28b5677b36Schristos  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29b5677b36Schristos  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30b5677b36Schristos  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31b5677b36Schristos  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32b5677b36Schristos  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33b5677b36Schristos  * SUCH DAMAGE.
34b5677b36Schristos  */
35b5677b36Schristos 
36b5677b36Schristos #if defined(LIBC_SCCS) && !defined(lint)
37b5677b36Schristos static const char sccsid[] = "@(#)inet_ntoa.c	8.1 (Berkeley) 6/4/93";
38b5677b36Schristos static const char rcsid[] = "Id: inet_ntoa.c,v 1.2 2005/04/27 04:56:21 sra Exp ";
39b5677b36Schristos #endif /* LIBC_SCCS and not lint */
40b5677b36Schristos 
41b5677b36Schristos #include "port_before.h"
42b5677b36Schristos 
43b5677b36Schristos #include <sys/types.h>
44b5677b36Schristos #include <sys/socket.h>
45b5677b36Schristos #include <netinet/in.h>
46b5677b36Schristos #include <arpa/inet.h>
47b5677b36Schristos 
48b5677b36Schristos #include <stdio.h>
49b5677b36Schristos #include <string.h>
50b5677b36Schristos 
51b5677b36Schristos #include "port_after.h"
52b5677b36Schristos 
53b5677b36Schristos /*%
54b5677b36Schristos  * Convert network-format internet address
55b5677b36Schristos  * to base 256 d.d.d.d representation.
56b5677b36Schristos  */
57b5677b36Schristos /*const*/ char *
inet_ntoa(struct in_addr in)58b5677b36Schristos inet_ntoa(struct in_addr in) {
59b5677b36Schristos 	static char ret[18];
60b5677b36Schristos 
61b5677b36Schristos 	strcpy(ret, "[inet_ntoa error]");
62b5677b36Schristos 	(void) inet_ntop(AF_INET, &in, ret, sizeof ret);
63b5677b36Schristos 	return (ret);
64b5677b36Schristos }
65b5677b36Schristos 
66b5677b36Schristos /*! \file */
67