1 /* A GNU-like <arpa/inet.h>.
3 Copyright (C) 2005-2006, 2008 Free Software Foundation, Inc.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3, or (at your option)
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software Foundation,
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
19 #ifndef _GL_ARPA_INET_H
21 /* Gnulib's sys/socket.h is responsible for pulling in winsock2.h etc
23 #include <sys/socket.h>
25 #if @HAVE_ARPA_INET_H@
28 @PRAGMA_SYSTEM_HEADER@
31 /* The include_next requires a split double-inclusion guard. */
32 # @INCLUDE_NEXT@ @NEXT_ARPA_INET_H@
36 #ifndef _GL_ARPA_INET_H
37 #define _GL_ARPA_INET_H
39 /* The definition of GL_LINK_WARNING is copied here. */
45 #if @GNULIB_INET_NTOP@
46 # if !@HAVE_DECL_INET_NTOP@
47 /* Converts an internet address from internal format to a printable,
49 AF is an internet address family, such as AF_INET or AF_INET6.
50 SRC points to a 'struct in_addr' (for AF_INET) or 'struct in6_addr'
52 DST points to a buffer having room for CNT bytes.
53 The printable representation of the address (in numeric form, not
54 surrounded by [...], no reverse DNS is done) is placed in DST, and
55 DST is returned. If an error occurs, the return value is NULL and
56 errno is set. If CNT bytes are not sufficient to hold the result,
57 the return value is NULL and errno is set to ENOSPC. A good value
60 For more details, see the POSIX:2001 specification
61 <http://www.opengroup.org/susv3xsh/inet_ntop.html>. */
62 extern const char *inet_ntop (int af
, const void *restrict src
,
63 char *restrict dst
, socklen_t cnt
);
65 #elif defined GNULIB_POSIXCHECK
67 # define inet_ntop(af,src,dst,cnt) \
68 (GL_LINK_WARNING ("inet_ntop is unportable - " \
69 "use gnulib module inet_ntop for portability"), \
70 inet_ntop (af, src, dst, cnt))
73 #if @GNULIB_INET_PTON@
74 # if !@HAVE_DECL_INET_PTON@
75 extern int inet_pton (int af
, const char *restrict src
, void *restrict dst
);
77 #elif defined GNULIB_POSIXCHECK
79 # define inet_pton(af,src,dst) \
80 (GL_LINK_WARNING ("inet_pton is unportable - " \
81 "use gnulib module inet_pton for portability"), \
82 inet_pton (af, src, dst))
89 #endif /* _GL_ARPA_INET_H */
90 #endif /* _GL_ARPA_INET_H */