900f7f340e60226c04ddc09c2e587c23d375d285
[gnulib.git] / lib / arpa_inet.in.h
1 /* Provide a arpa/inet header file for systems lacking it (read: MinGW)
2    Copyright (C) 2008 Free Software Foundation, Inc.
3
4    This program is free software; you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation; either version 2, or (at your option)
7    any later version.
8
9    This program is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU General Public License for more details.
13
14    You should have received a copy of the GNU General Public License
15    along with this program; if not, write to the Free Software Foundation,
16    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
17
18 #ifndef _GL_ARPA_INET_H
19 #define _GL_ARPA_INET_H
20
21 /* Gnulib's sys/socket.h is responsible for pulling in winsock2.h etc
22    under MinGW. */
23 #include <sys/socket.h>
24
25 #if @GNULIB_INET_NTOP@
26 # if !@HAVE_DECL_INET_NTOP@
27 /* Converts an internet address from internal format to a printable,
28    presentable format.
29    AF is an internet address family, such as AF_INET or AF_INET6.
30    SRC points to a 'struct in_addr' (for AF_INET) or 'struct in6_addr'
31    (for AF_INET6).
32    DST points to a buffer having room for CNT bytes.
33    The printable representation of the address (in numeric form, not
34    surrounded by [...], no reverse DNS is done) is placed in DST, and
35    DST is returned.  If an error occurs, the return value is NULL and
36    errno is set.  If CNT bytes are not sufficient to hold the result,
37    the return value is NULL and errno is set to ENOSPC.  A good value
38    for CNT is 46.
39
40    For more details, see the POSIX:2001 specification
41    <http://www.opengroup.org/susv3xsh/inet_ntop.html>.  */
42 extern const char *inet_ntop (int af, const void *restrict src,
43                               char *restrict dst, socklen_t cnt);
44 # endif
45 #elif defined GNULIB_POSIXCHECK
46 # undef inet_ntop
47 # define inet_ntop(af,src,dst,cnt)                                      \
48     (GL_LINK_WARNING ("inet_ntop doesn't exist on mingw - " \
49                       "use gnulib module inet_ntop for portability"), \
50      inet_ntop (af, src, dst, cnt))
51 #endif
52
53 #if @GNULIB_INET_PTON@
54 # if !@HAVE_DECL_INET_PTON@
55 extern int inet_pton (int af, const char *restrict src, void *restrict dst);
56 # endif
57 #elif defined GNULIB_POSIXCHECK
58 # undef inet_pton
59 # define inet_pton(af,src,dst)                      \
60   (GL_LINK_WARNING ("inet_pton doesn't exist on mingw - "         \
61                     "use gnulib module inet_pton for portability"),       \
62    inet_pton (af, src, dst))
63 #endif
64
65 #endif /* _GL_ARPA_INET_H */