arpa_inet.in.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /* A GNU-like <arpa/inet.h>.
  2. Copyright (C) 2005-2006, 2008-2021 Free Software Foundation, Inc.
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 3, or (at your option)
  6. any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, see <https://www.gnu.org/licenses/>. */
  13. #ifndef _@GUARD_PREFIX@_ARPA_INET_H
  14. #if __GNUC__ >= 3
  15. @PRAGMA_SYSTEM_HEADER@
  16. #endif
  17. @PRAGMA_COLUMNS@
  18. #if @HAVE_FEATURES_H@
  19. # include <features.h> /* for __GLIBC__ */
  20. #endif
  21. /* Gnulib's sys/socket.h is responsible for defining socklen_t (used below) and
  22. for pulling in winsock2.h etc. under MinGW.
  23. But avoid namespace pollution on glibc systems. */
  24. #ifndef __GLIBC__
  25. # include <sys/socket.h>
  26. #endif
  27. /* On NonStop Kernel, inet_ntop and inet_pton are declared in <netdb.h>.
  28. But avoid namespace pollution on glibc systems. */
  29. #if defined __TANDEM && !defined __GLIBC__
  30. # include <netdb.h>
  31. #endif
  32. #if @HAVE_ARPA_INET_H@
  33. /* The include_next requires a split double-inclusion guard. */
  34. # @INCLUDE_NEXT@ @NEXT_ARPA_INET_H@
  35. #endif
  36. #ifndef _@GUARD_PREFIX@_ARPA_INET_H
  37. #define _@GUARD_PREFIX@_ARPA_INET_H
  38. /* Get all possible declarations of inet_ntop() and inet_pton(). */
  39. #if (@GNULIB_INET_NTOP@ || @GNULIB_INET_PTON@ || defined GNULIB_POSIXCHECK) \
  40. && @HAVE_WS2TCPIP_H@
  41. # include <ws2tcpip.h>
  42. #endif
  43. /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
  44. /* The definition of _GL_ARG_NONNULL is copied here. */
  45. /* The definition of _GL_WARN_ON_USE is copied here. */
  46. #if @GNULIB_INET_NTOP@
  47. /* Converts an internet address from internal format to a printable,
  48. presentable format.
  49. AF is an internet address family, such as AF_INET or AF_INET6.
  50. SRC points to a 'struct in_addr' (for AF_INET) or 'struct in6_addr'
  51. (for AF_INET6).
  52. DST points to a buffer having room for CNT bytes.
  53. The printable representation of the address (in numeric form, not
  54. surrounded by [...], no reverse DNS is done) is placed in DST, and
  55. DST is returned. If an error occurs, the return value is NULL and
  56. errno is set. If CNT bytes are not sufficient to hold the result,
  57. the return value is NULL and errno is set to ENOSPC. A good value
  58. for CNT is 46.
  59. For more details, see the POSIX:2008 specification
  60. <https://pubs.opengroup.org/onlinepubs/9699919799/functions/inet_ntop.html>. */
  61. # if @REPLACE_INET_NTOP@
  62. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  63. # undef inet_ntop
  64. # define inet_ntop rpl_inet_ntop
  65. # endif
  66. _GL_FUNCDECL_RPL (inet_ntop, const char *,
  67. (int af, const void *restrict src,
  68. char *restrict dst, socklen_t cnt)
  69. _GL_ARG_NONNULL ((2, 3)));
  70. _GL_CXXALIAS_RPL (inet_ntop, const char *,
  71. (int af, const void *restrict src,
  72. char *restrict dst, socklen_t cnt));
  73. # else
  74. # if !@HAVE_DECL_INET_NTOP@
  75. _GL_FUNCDECL_SYS (inet_ntop, const char *,
  76. (int af, const void *restrict src,
  77. char *restrict dst, socklen_t cnt)
  78. _GL_ARG_NONNULL ((2, 3)));
  79. # endif
  80. /* Need to cast, because on NonStop Kernel, the fourth parameter is
  81. size_t cnt. */
  82. _GL_CXXALIAS_SYS_CAST (inet_ntop, const char *,
  83. (int af, const void *restrict src,
  84. char *restrict dst, socklen_t cnt));
  85. # endif
  86. # if __GLIBC__ >= 2
  87. _GL_CXXALIASWARN (inet_ntop);
  88. # endif
  89. #elif defined GNULIB_POSIXCHECK
  90. # undef inet_ntop
  91. # if HAVE_RAW_DECL_INET_NTOP
  92. _GL_WARN_ON_USE (inet_ntop, "inet_ntop is unportable - "
  93. "use gnulib module inet_ntop for portability");
  94. # endif
  95. #endif
  96. #if @GNULIB_INET_PTON@
  97. # if @REPLACE_INET_PTON@
  98. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  99. # undef inet_pton
  100. # define inet_pton rpl_inet_pton
  101. # endif
  102. _GL_FUNCDECL_RPL (inet_pton, int,
  103. (int af, const char *restrict src, void *restrict dst)
  104. _GL_ARG_NONNULL ((2, 3)));
  105. _GL_CXXALIAS_RPL (inet_pton, int,
  106. (int af, const char *restrict src, void *restrict dst));
  107. # else
  108. # if !@HAVE_DECL_INET_PTON@
  109. _GL_FUNCDECL_SYS (inet_pton, int,
  110. (int af, const char *restrict src, void *restrict dst)
  111. _GL_ARG_NONNULL ((2, 3)));
  112. # endif
  113. _GL_CXXALIAS_SYS (inet_pton, int,
  114. (int af, const char *restrict src, void *restrict dst));
  115. # endif
  116. # if __GLIBC__ >= 2
  117. _GL_CXXALIASWARN (inet_pton);
  118. # endif
  119. #elif defined GNULIB_POSIXCHECK
  120. # undef inet_pton
  121. # if HAVE_RAW_DECL_INET_PTON
  122. _GL_WARN_ON_USE (inet_pton, "inet_pton is unportable - "
  123. "use gnulib module inet_pton for portability");
  124. # endif
  125. #endif
  126. #endif /* _@GUARD_PREFIX@_ARPA_INET_H */
  127. #endif /* _@GUARD_PREFIX@_ARPA_INET_H */