1 /* A GNU-like <arpa/inet.h>. 2 3 Copyright (C) 2005-2006, 2008-2021 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 3, 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, see <https://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 /* Get all possible declarations of inet_ntop() and inet_pton(). */ 53 #if (@GNULIB_INET_NTOP@ || @GNULIB_INET_PTON@ || defined GNULIB_POSIXCHECK) \ 54 && @HAVE_WS2TCPIP_H@ 55 # include <ws2tcpip.h> 56 #endif 57 58 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ 59 60 /* The definition of _GL_ARG_NONNULL is copied here. */ 61 62 /* The definition of _GL_WARN_ON_USE is copied here. */ 63 64 65 #if @GNULIB_INET_NTOP@ 66 /* Converts an internet address from internal format to a printable, 67 presentable format. 68 AF is an internet address family, such as AF_INET or AF_INET6. 69 SRC points to a 'struct in_addr' (for AF_INET) or 'struct in6_addr' 70 (for AF_INET6). 71 DST points to a buffer having room for CNT bytes. 72 The printable representation of the address (in numeric form, not 73 surrounded by [...], no reverse DNS is done) is placed in DST, and 74 DST is returned. If an error occurs, the return value is NULL and 75 errno is set. If CNT bytes are not sufficient to hold the result, 76 the return value is NULL and errno is set to ENOSPC. A good value 77 for CNT is 46. 78 79 For more details, see the POSIX:2008 specification 80 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/inet_ntop.html>. */ 81 # if @REPLACE_INET_NTOP@ 82 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 83 # undef inet_ntop 84 # define inet_ntop rpl_inet_ntop 85 # endif 86 _GL_FUNCDECL_RPL (inet_ntop, const char *, 87 (int af, const void *restrict src, 88 char *restrict dst, socklen_t cnt) 89 _GL_ARG_NONNULL ((2, 3))); 90 _GL_CXXALIAS_RPL (inet_ntop, const char *, 91 (int af, const void *restrict src, 92 char *restrict dst, socklen_t cnt)); 93 # else 94 # if !@HAVE_DECL_INET_NTOP@ 95 _GL_FUNCDECL_SYS (inet_ntop, const char *, 96 (int af, const void *restrict src, 97 char *restrict dst, socklen_t cnt) 98 _GL_ARG_NONNULL ((2, 3))); 99 # endif 100 /* Need to cast, because on NonStop Kernel, the fourth parameter is 101 size_t cnt. */ 102 _GL_CXXALIAS_SYS_CAST (inet_ntop, const char *, 103 (int af, const void *restrict src, 104 char *restrict dst, socklen_t cnt)); 105 # endif 106 # if __GLIBC__ >= 2 107 _GL_CXXALIASWARN (inet_ntop); 108 # endif 109 #elif defined GNULIB_POSIXCHECK 110 # undef inet_ntop 111 # if HAVE_RAW_DECL_INET_NTOP 112 _GL_WARN_ON_USE (inet_ntop, "inet_ntop is unportable - " 113 "use gnulib module inet_ntop for portability"); 114 # endif 115 #endif 116 117 #if @GNULIB_INET_PTON@ 118 # if @REPLACE_INET_PTON@ 119 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 120 # undef inet_pton 121 # define inet_pton rpl_inet_pton 122 # endif 123 _GL_FUNCDECL_RPL (inet_pton, int, 124 (int af, const char *restrict src, void *restrict dst) 125 _GL_ARG_NONNULL ((2, 3))); 126 _GL_CXXALIAS_RPL (inet_pton, int, 127 (int af, const char *restrict src, void *restrict dst)); 128 # else 129 # if !@HAVE_DECL_INET_PTON@ 130 _GL_FUNCDECL_SYS (inet_pton, int, 131 (int af, const char *restrict src, void *restrict dst) 132 _GL_ARG_NONNULL ((2, 3))); 133 # endif 134 _GL_CXXALIAS_SYS (inet_pton, int, 135 (int af, const char *restrict src, void *restrict dst)); 136 # endif 137 # if __GLIBC__ >= 2 138 _GL_CXXALIASWARN (inet_pton); 139 # endif 140 #elif defined GNULIB_POSIXCHECK 141 # undef inet_pton 142 # if HAVE_RAW_DECL_INET_PTON 143 _GL_WARN_ON_USE (inet_pton, "inet_pton is unportable - " 144 "use gnulib module inet_pton for portability"); 145 # endif 146 #endif 147 148 149 #endif /* _@GUARD_PREFIX@_ARPA_INET_H */ 150 #endif /* _@GUARD_PREFIX@_ARPA_INET_H */ 151