inet_pton: Support for MSVC on Windows Vista or newer.
[gnulib.git] / lib / arpa_inet.in.h
1 /* A GNU-like <arpa/inet.h>.
2
3    Copyright (C) 2005-2006, 2008-2011 Free Software Foundation, Inc.
4
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)
8    any later version.
9
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.
14
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.  */
18
19 #ifndef _@GUARD_PREFIX@_ARPA_INET_H
20
21 #if __GNUC__ >= 3
22 @PRAGMA_SYSTEM_HEADER@
23 #endif
24 @PRAGMA_COLUMNS@
25
26 #if @HAVE_FEATURES_H@
27 # include <features.h> /* for __GLIBC__ */
28 #endif
29
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.  */
33 #ifndef __GLIBC__
34 # include <sys/socket.h>
35 #endif
36
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__
40 # include <netdb.h>
41 #endif
42
43 #if @HAVE_ARPA_INET_H@
44
45 /* The include_next requires a split double-inclusion guard.  */
46 # @INCLUDE_NEXT@ @NEXT_ARPA_INET_H@
47
48 #endif
49
50 #ifndef _@GUARD_PREFIX@_ARPA_INET_H
51 #define _@GUARD_PREFIX@_ARPA_INET_H
52
53 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
54
55 /* The definition of _GL_ARG_NONNULL is copied here.  */
56
57 /* The definition of _GL_WARN_ON_USE is copied here.  */
58
59
60 #if @GNULIB_INET_NTOP@
61 /* Converts an internet address from internal format to a printable,
62    presentable format.
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'
65    (for AF_INET6).
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
72    for CNT is 46.
73
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)
78 #   undef inet_ntop
79 #   define inet_ntop rpl_inet_ntop
80 #  endif
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));
88 # else
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)));
94 #  endif
95 /* Need to cast, because on NonStop Kernel, the fourth parameter is
96                                             size_t cnt.  */
97 _GL_CXXALIAS_SYS_CAST (inet_ntop, const char *,
98                        (int af, const void *restrict src,
99                         char *restrict dst, socklen_t cnt));
100 # endif
101 _GL_CXXALIASWARN (inet_ntop);
102 #elif defined GNULIB_POSIXCHECK
103 # undef inet_ntop
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");
107 # endif
108 #endif
109
110 #if @GNULIB_INET_PTON@
111 # if @REPLACE_INET_PTON@
112 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
113 #   undef inet_pton
114 #   define inet_pton rpl_inet_pton
115 #  endif
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));
121 # else
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)));
126 #  endif
127 _GL_CXXALIAS_SYS (inet_pton, int,
128                   (int af, const char *restrict src, void *restrict dst));
129 # endif
130 _GL_CXXALIASWARN (inet_pton);
131 #elif defined GNULIB_POSIXCHECK
132 # undef inet_pton
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");
136 # endif
137 #endif
138
139
140 #endif /* _@GUARD_PREFIX@_ARPA_INET_H */
141 #endif /* _@GUARD_PREFIX@_ARPA_INET_H */