arpa_inet: Use the common idioms with C++ support.
[pspp] / lib / arpa_inet.in.h
1 /* A GNU-like <arpa/inet.h>.
2
3    Copyright (C) 2005-2006, 2008-2010 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 _GL_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 pulling in winsock2.h etc
31    under MinGW.
32    But avoid namespace pollution on glibc systems.  */
33 #ifndef __GLIBC__
34 # include <sys/socket.h>
35 #endif
36
37 #if @HAVE_ARPA_INET_H@
38
39 /* The include_next requires a split double-inclusion guard.  */
40 # @INCLUDE_NEXT@ @NEXT_ARPA_INET_H@
41
42 #endif
43
44 #ifndef _GL_ARPA_INET_H
45 #define _GL_ARPA_INET_H
46
47 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
48
49 /* The definition of _GL_ARG_NONNULL is copied here.  */
50
51 /* The definition of _GL_WARN_ON_USE is copied here.  */
52
53
54 #if @GNULIB_INET_NTOP@
55 # if !@HAVE_DECL_INET_NTOP@
56 /* Converts an internet address from internal format to a printable,
57    presentable format.
58    AF is an internet address family, such as AF_INET or AF_INET6.
59    SRC points to a 'struct in_addr' (for AF_INET) or 'struct in6_addr'
60    (for AF_INET6).
61    DST points to a buffer having room for CNT bytes.
62    The printable representation of the address (in numeric form, not
63    surrounded by [...], no reverse DNS is done) is placed in DST, and
64    DST is returned.  If an error occurs, the return value is NULL and
65    errno is set.  If CNT bytes are not sufficient to hold the result,
66    the return value is NULL and errno is set to ENOSPC.  A good value
67    for CNT is 46.
68
69    For more details, see the POSIX:2001 specification
70    <http://www.opengroup.org/susv3xsh/inet_ntop.html>.  */
71 _GL_FUNCDECL_SYS (inet_ntop, const char *,
72                   (int af, const void *restrict src,
73                    char *restrict dst, socklen_t cnt)
74                   _GL_ARG_NONNULL ((2, 3)));
75 # endif
76 _GL_CXXALIAS_SYS (inet_ntop, const char *,
77                   (int af, const void *restrict src,
78                    char *restrict dst, socklen_t cnt));
79 _GL_CXXALIASWARN (inet_ntop);
80 #elif defined GNULIB_POSIXCHECK
81 # undef inet_ntop
82 # if HAVE_RAW_DECL_INET_NTOP
83 _GL_WARN_ON_USE (inet_ntop, "inet_ntop is unportable - "
84                  "use gnulib module inet_ntop for portability");
85 # endif
86 #endif
87
88 #if @GNULIB_INET_PTON@
89 # if !@HAVE_DECL_INET_PTON@
90 _GL_FUNCDECL_SYS (inet_pton, int,
91                   (int af, const char *restrict src, void *restrict dst)
92                   _GL_ARG_NONNULL ((2, 3)));
93 # endif
94 _GL_CXXALIAS_SYS (inet_pton, int,
95                   (int af, const char *restrict src, void *restrict dst));
96 _GL_CXXALIASWARN (inet_pton);
97 #elif defined GNULIB_POSIXCHECK
98 # undef inet_pton
99 # if HAVE_RAW_DECL_INET_PTON
100 _GL_WARN_ON_USE (inet_pton, "inet_pton is unportable - "
101                  "use gnulib module inet_pton for portability");
102 # endif
103 #endif
104
105
106 #endif /* _GL_ARPA_INET_H */
107 #endif /* _GL_ARPA_INET_H */