Commit | Line | Data |
---|---|---|
8912421c LC |
1 | /* A GNU-like <arpa/inet.h>. |
2 | ||
1cd4fffc | 3 | Copyright (C) 2005-2006, 2008-2009 Free Software Foundation, Inc. |
8912421c LC |
4 | |
5 | This program is free software; you can redistribute it and/or modify | |
6 | it under the terms of the GNU Lesser 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 Lesser General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU Lesser 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 | /* Gnulib's sys/socket.h is responsible for pulling in winsock2.h etc | |
22 | under MinGW. */ | |
23 | #include <sys/socket.h> | |
24 | ||
25 | #if @HAVE_ARPA_INET_H@ | |
26 | ||
27 | # if __GNUC__ >= 3 | |
28 | @PRAGMA_SYSTEM_HEADER@ | |
29 | # endif | |
30 | ||
31 | /* The include_next requires a split double-inclusion guard. */ | |
32 | # @INCLUDE_NEXT@ @NEXT_ARPA_INET_H@ | |
33 | ||
34 | #endif | |
35 | ||
36 | #ifndef _GL_ARPA_INET_H | |
37 | #define _GL_ARPA_INET_H | |
38 | ||
39 | /* The definition of GL_LINK_WARNING is copied here. */ | |
40 | ||
1cd4fffc LC |
41 | /* The definition of _GL_ARG_NONNULL is copied here. */ |
42 | ||
8912421c LC |
43 | #ifdef __cplusplus |
44 | extern "C" { | |
45 | #endif | |
46 | ||
47 | #if @GNULIB_INET_NTOP@ | |
48 | # if !@HAVE_DECL_INET_NTOP@ | |
49 | /* Converts an internet address from internal format to a printable, | |
50 | presentable format. | |
51 | AF is an internet address family, such as AF_INET or AF_INET6. | |
52 | SRC points to a 'struct in_addr' (for AF_INET) or 'struct in6_addr' | |
53 | (for AF_INET6). | |
54 | DST points to a buffer having room for CNT bytes. | |
55 | The printable representation of the address (in numeric form, not | |
56 | surrounded by [...], no reverse DNS is done) is placed in DST, and | |
57 | DST is returned. If an error occurs, the return value is NULL and | |
58 | errno is set. If CNT bytes are not sufficient to hold the result, | |
59 | the return value is NULL and errno is set to ENOSPC. A good value | |
60 | for CNT is 46. | |
61 | ||
62 | For more details, see the POSIX:2001 specification | |
63 | <http://www.opengroup.org/susv3xsh/inet_ntop.html>. */ | |
64 | extern const char *inet_ntop (int af, const void *restrict src, | |
1cd4fffc LC |
65 | char *restrict dst, socklen_t cnt) |
66 | _GL_ARG_NONNULL ((2, 3)); | |
8912421c LC |
67 | # endif |
68 | #elif defined GNULIB_POSIXCHECK | |
69 | # undef inet_ntop | |
70 | # define inet_ntop(af,src,dst,cnt) \ | |
71 | (GL_LINK_WARNING ("inet_ntop is unportable - " \ | |
72 | "use gnulib module inet_ntop for portability"), \ | |
73 | inet_ntop (af, src, dst, cnt)) | |
74 | #endif | |
75 | ||
76 | #if @GNULIB_INET_PTON@ | |
77 | # if !@HAVE_DECL_INET_PTON@ | |
1cd4fffc LC |
78 | extern int inet_pton (int af, const char *restrict src, void *restrict dst) |
79 | _GL_ARG_NONNULL ((2, 3)); | |
8912421c LC |
80 | # endif |
81 | #elif defined GNULIB_POSIXCHECK | |
82 | # undef inet_pton | |
83 | # define inet_pton(af,src,dst) \ | |
84 | (GL_LINK_WARNING ("inet_pton is unportable - " \ | |
1cd4fffc | 85 | "use gnulib module inet_pton for portability"), \ |
8912421c LC |
86 | inet_pton (af, src, dst)) |
87 | #endif | |
88 | ||
89 | #ifdef __cplusplus | |
90 | } | |
91 | #endif | |
92 | ||
93 | #endif /* _GL_ARPA_INET_H */ | |
94 | #endif /* _GL_ARPA_INET_H */ |