1 /* A GNU-like <arpa/inet.h>.
3 Copyright (C) 2005-2006, 2008-2011 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 2, 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 _@GUARD_PREFIX@_ARPA_INET_H
22 @PRAGMA_SYSTEM_HEADER@
27 # include <features.h> /* for __GLIBC__ */
30 /* Gnulib's sys/socket.h is responsible for defining socklen_t (used below) and
31 for pulling in winsock2.h etc. under MinGW.
32 But avoid namespace pollution on glibc systems. */
34 # include <sys/socket.h>
37 /* On NonStop Kernel, inet_ntop and inet_pton are declared in <netdb.h>.
38 But avoid namespace pollution on glibc systems. */
39 #if defined __TANDEM && !defined __GLIBC__
43 #if @HAVE_ARPA_INET_H@
45 /* The include_next requires a split double-inclusion guard. */
46 # @INCLUDE_NEXT@ @NEXT_ARPA_INET_H@
50 #ifndef _@GUARD_PREFIX@_ARPA_INET_H
51 #define _@GUARD_PREFIX@_ARPA_INET_H
53 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
55 /* The definition of _GL_ARG_NONNULL is copied here. */
57 /* The definition of _GL_WARN_ON_USE is copied here. */
60 #if @GNULIB_INET_NTOP@
61 /* Converts an internet address from internal format to a printable,
63 AF is an internet address family, such as AF_INET or AF_INET6.
64 SRC points to a 'struct in_addr' (for AF_INET) or 'struct in6_addr'
66 DST points to a buffer having room for CNT bytes.
67 The printable representation of the address (in numeric form, not
68 surrounded by [...], no reverse DNS is done) is placed in DST, and
69 DST is returned. If an error occurs, the return value is NULL and
70 errno is set. If CNT bytes are not sufficient to hold the result,
71 the return value is NULL and errno is set to ENOSPC. A good value
74 For more details, see the POSIX:2001 specification
75 <http://www.opengroup.org/susv3xsh/inet_ntop.html>. */
76 # if @REPLACE_INET_NTOP@
77 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
79 # define inet_ntop rpl_inet_ntop
81 _GL_FUNCDECL_RPL (inet_ntop, const char *,
82 (int af, const void *restrict src,
83 char *restrict dst, socklen_t cnt)
84 _GL_ARG_NONNULL ((2, 3)));
85 _GL_CXXALIAS_RPL (inet_ntop, const char *,
86 (int af, const void *restrict src,
87 char *restrict dst, socklen_t cnt));
89 # if !@HAVE_DECL_INET_NTOP@
90 _GL_FUNCDECL_SYS (inet_ntop, const char *,
91 (int af, const void *restrict src,
92 char *restrict dst, socklen_t cnt)
93 _GL_ARG_NONNULL ((2, 3)));
95 /* Need to cast, because on NonStop Kernel, the fourth parameter is
97 _GL_CXXALIAS_SYS_CAST (inet_ntop, const char *,
98 (int af, const void *restrict src,
99 char *restrict dst, socklen_t cnt));
101 _GL_CXXALIASWARN (inet_ntop);
102 #elif defined GNULIB_POSIXCHECK
104 # if HAVE_RAW_DECL_INET_NTOP
105 _GL_WARN_ON_USE (inet_ntop, "inet_ntop is unportable - "
106 "use gnulib module inet_ntop for portability");
110 #if @GNULIB_INET_PTON@
111 # if @REPLACE_INET_PTON@
112 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
114 # define inet_pton rpl_inet_pton
116 _GL_FUNCDECL_RPL (inet_pton, int,
117 (int af, const char *restrict src, void *restrict dst)
118 _GL_ARG_NONNULL ((2, 3)));
119 _GL_CXXALIAS_RPL (inet_pton, int,
120 (int af, const char *restrict src, void *restrict dst));
122 # if !@HAVE_DECL_INET_PTON@
123 _GL_FUNCDECL_SYS (inet_pton, int,
124 (int af, const char *restrict src, void *restrict dst)
125 _GL_ARG_NONNULL ((2, 3)));
127 _GL_CXXALIAS_SYS (inet_pton, int,
128 (int af, const char *restrict src, void *restrict dst));
130 _GL_CXXALIASWARN (inet_pton);
131 #elif defined GNULIB_POSIXCHECK
133 # if HAVE_RAW_DECL_INET_PTON
134 _GL_WARN_ON_USE (inet_pton, "inet_pton is unportable - "
135 "use gnulib module inet_pton for portability");
140 #endif /* _@GUARD_PREFIX@_ARPA_INET_H */
141 #endif /* _@GUARD_PREFIX@_ARPA_INET_H */