1 /* A GNU-like <arpa/inet.h>.
3 Copyright (C) 2005-2006, 2008-2012 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, see <http://www.gnu.org/licenses/>. */
18 #ifndef _@GUARD_PREFIX@_ARPA_INET_H
21 @PRAGMA_SYSTEM_HEADER@
26 # include <features.h> /* for __GLIBC__ */
29 /* Gnulib's sys/socket.h is responsible for defining socklen_t (used below) and
30 for pulling in winsock2.h etc. under MinGW.
31 But avoid namespace pollution on glibc systems. */
33 # include <sys/socket.h>
36 /* On NonStop Kernel, inet_ntop and inet_pton are declared in <netdb.h>.
37 But avoid namespace pollution on glibc systems. */
38 #if defined __TANDEM && !defined __GLIBC__
42 #if @HAVE_ARPA_INET_H@
44 /* The include_next requires a split double-inclusion guard. */
45 # @INCLUDE_NEXT@ @NEXT_ARPA_INET_H@
49 #ifndef _@GUARD_PREFIX@_ARPA_INET_H
50 #define _@GUARD_PREFIX@_ARPA_INET_H
52 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
54 /* The definition of _GL_ARG_NONNULL is copied here. */
56 /* The definition of _GL_WARN_ON_USE is copied here. */
59 #if @GNULIB_INET_NTOP@
60 /* Converts an internet address from internal format to a printable,
62 AF is an internet address family, such as AF_INET or AF_INET6.
63 SRC points to a 'struct in_addr' (for AF_INET) or 'struct in6_addr'
65 DST points to a buffer having room for CNT bytes.
66 The printable representation of the address (in numeric form, not
67 surrounded by [...], no reverse DNS is done) is placed in DST, and
68 DST is returned. If an error occurs, the return value is NULL and
69 errno is set. If CNT bytes are not sufficient to hold the result,
70 the return value is NULL and errno is set to ENOSPC. A good value
73 For more details, see the POSIX:2001 specification
74 <http://www.opengroup.org/susv3xsh/inet_ntop.html>. */
75 # if @REPLACE_INET_NTOP@
76 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
78 # define inet_ntop rpl_inet_ntop
80 _GL_FUNCDECL_RPL (inet_ntop
, const char *,
81 (int af
, const void *restrict src
,
82 char *restrict dst
, socklen_t cnt
)
83 _GL_ARG_NONNULL ((2, 3)));
84 _GL_CXXALIAS_RPL (inet_ntop
, const char *,
85 (int af
, const void *restrict src
,
86 char *restrict dst
, socklen_t cnt
));
88 # if !@HAVE_DECL_INET_NTOP@
89 _GL_FUNCDECL_SYS (inet_ntop
, const char *,
90 (int af
, const void *restrict src
,
91 char *restrict dst
, socklen_t cnt
)
92 _GL_ARG_NONNULL ((2, 3)));
94 /* Need to cast, because on NonStop Kernel, the fourth parameter is
96 _GL_CXXALIAS_SYS_CAST (inet_ntop
, const char *,
97 (int af
, const void *restrict src
,
98 char *restrict dst
, socklen_t cnt
));
100 _GL_CXXALIASWARN (inet_ntop
);
101 #elif defined GNULIB_POSIXCHECK
103 # if HAVE_RAW_DECL_INET_NTOP
104 _GL_WARN_ON_USE (inet_ntop
, "inet_ntop is unportable - "
105 "use gnulib module inet_ntop for portability");
109 #if @GNULIB_INET_PTON@
110 # if @REPLACE_INET_PTON@
111 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
113 # define inet_pton rpl_inet_pton
115 _GL_FUNCDECL_RPL (inet_pton
, int,
116 (int af
, const char *restrict src
, void *restrict dst
)
117 _GL_ARG_NONNULL ((2, 3)));
118 _GL_CXXALIAS_RPL (inet_pton
, int,
119 (int af
, const char *restrict src
, void *restrict dst
));
121 # if !@HAVE_DECL_INET_PTON@
122 _GL_FUNCDECL_SYS (inet_pton
, int,
123 (int af
, const char *restrict src
, void *restrict dst
)
124 _GL_ARG_NONNULL ((2, 3)));
126 _GL_CXXALIAS_SYS (inet_pton
, int,
127 (int af
, const char *restrict src
, void *restrict dst
));
129 _GL_CXXALIASWARN (inet_pton
);
130 #elif defined GNULIB_POSIXCHECK
132 # if HAVE_RAW_DECL_INET_PTON
133 _GL_WARN_ON_USE (inet_pton
, "inet_pton is unportable - "
134 "use gnulib module inet_pton for portability");
139 #endif /* _@GUARD_PREFIX@_ARPA_INET_H */
140 #endif /* _@GUARD_PREFIX@_ARPA_INET_H */