arpa_inet.in.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /* A GNU-like <arpa/inet.h>.
  2. Copyright (C) 2005-2006, 2008-2017 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 Lesser General Public License as published by
  5. the Free Software Foundation; either version 2, 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 Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public License
  12. along with this program; if not, see <http://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. /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
  39. /* The definition of _GL_ARG_NONNULL is copied here. */
  40. /* The definition of _GL_WARN_ON_USE is copied here. */
  41. #if @GNULIB_INET_NTOP@
  42. /* Converts an internet address from internal format to a printable,
  43. presentable format.
  44. AF is an internet address family, such as AF_INET or AF_INET6.
  45. SRC points to a 'struct in_addr' (for AF_INET) or 'struct in6_addr'
  46. (for AF_INET6).
  47. DST points to a buffer having room for CNT bytes.
  48. The printable representation of the address (in numeric form, not
  49. surrounded by [...], no reverse DNS is done) is placed in DST, and
  50. DST is returned. If an error occurs, the return value is NULL and
  51. errno is set. If CNT bytes are not sufficient to hold the result,
  52. the return value is NULL and errno is set to ENOSPC. A good value
  53. for CNT is 46.
  54. For more details, see the POSIX:2001 specification
  55. <http://www.opengroup.org/susv3xsh/inet_ntop.html>. */
  56. # if @REPLACE_INET_NTOP@
  57. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  58. # undef inet_ntop
  59. # define inet_ntop rpl_inet_ntop
  60. # endif
  61. _GL_FUNCDECL_RPL (inet_ntop, const char *,
  62. (int af, const void *restrict src,
  63. char *restrict dst, socklen_t cnt)
  64. _GL_ARG_NONNULL ((2, 3)));
  65. _GL_CXXALIAS_RPL (inet_ntop, const char *,
  66. (int af, const void *restrict src,
  67. char *restrict dst, socklen_t cnt));
  68. # else
  69. # if !@HAVE_DECL_INET_NTOP@
  70. _GL_FUNCDECL_SYS (inet_ntop, const char *,
  71. (int af, const void *restrict src,
  72. char *restrict dst, socklen_t cnt)
  73. _GL_ARG_NONNULL ((2, 3)));
  74. # endif
  75. /* Need to cast, because on NonStop Kernel, the fourth parameter is
  76. size_t cnt. */
  77. _GL_CXXALIAS_SYS_CAST (inet_ntop, const char *,
  78. (int af, const void *restrict src,
  79. char *restrict dst, socklen_t cnt));
  80. # endif
  81. _GL_CXXALIASWARN (inet_ntop);
  82. #elif defined GNULIB_POSIXCHECK
  83. # undef inet_ntop
  84. # if HAVE_RAW_DECL_INET_NTOP
  85. _GL_WARN_ON_USE (inet_ntop, "inet_ntop is unportable - "
  86. "use gnulib module inet_ntop for portability");
  87. # endif
  88. #endif
  89. #if @GNULIB_INET_PTON@
  90. # if @REPLACE_INET_PTON@
  91. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  92. # undef inet_pton
  93. # define inet_pton rpl_inet_pton
  94. # endif
  95. _GL_FUNCDECL_RPL (inet_pton, int,
  96. (int af, const char *restrict src, void *restrict dst)
  97. _GL_ARG_NONNULL ((2, 3)));
  98. _GL_CXXALIAS_RPL (inet_pton, int,
  99. (int af, const char *restrict src, void *restrict dst));
  100. # else
  101. # if !@HAVE_DECL_INET_PTON@
  102. _GL_FUNCDECL_SYS (inet_pton, int,
  103. (int af, const char *restrict src, void *restrict dst)
  104. _GL_ARG_NONNULL ((2, 3)));
  105. # endif
  106. _GL_CXXALIAS_SYS (inet_pton, int,
  107. (int af, const char *restrict src, void *restrict dst));
  108. # endif
  109. _GL_CXXALIASWARN (inet_pton);
  110. #elif defined GNULIB_POSIXCHECK
  111. # undef inet_pton
  112. # if HAVE_RAW_DECL_INET_PTON
  113. _GL_WARN_ON_USE (inet_pton, "inet_pton is unportable - "
  114. "use gnulib module inet_pton for portability");
  115. # endif
  116. #endif
  117. #endif /* _@GUARD_PREFIX@_ARPA_INET_H */
  118. #endif /* _@GUARD_PREFIX@_ARPA_INET_H */