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