arpa_inet.in.h 4.9 KB

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