arpa_inet.in.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /* A GNU-like <arpa/inet.h>.
  2. Copyright (C) 2005-2006, 2008 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, write to the Free Software Foundation,
  13. Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
  14. #ifndef _GL_ARPA_INET_H
  15. /* Gnulib's sys/socket.h is responsible for pulling in winsock2.h etc
  16. under MinGW. */
  17. #include <sys/socket.h>
  18. #if @HAVE_ARPA_INET_H@
  19. # if __GNUC__ >= 3
  20. @PRAGMA_SYSTEM_HEADER@
  21. # endif
  22. /* The include_next requires a split double-inclusion guard. */
  23. # @INCLUDE_NEXT@ @NEXT_ARPA_INET_H@
  24. #endif
  25. #ifndef _GL_ARPA_INET_H
  26. #define _GL_ARPA_INET_H
  27. /* The definition of GL_LINK_WARNING is copied here. */
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. #if @GNULIB_INET_NTOP@
  32. # if !@HAVE_DECL_INET_NTOP@
  33. /* Converts an internet address from internal format to a printable,
  34. presentable format.
  35. AF is an internet address family, such as AF_INET or AF_INET6.
  36. SRC points to a 'struct in_addr' (for AF_INET) or 'struct in6_addr'
  37. (for AF_INET6).
  38. DST points to a buffer having room for CNT bytes.
  39. The printable representation of the address (in numeric form, not
  40. surrounded by [...], no reverse DNS is done) is placed in DST, and
  41. DST is returned. If an error occurs, the return value is NULL and
  42. errno is set. If CNT bytes are not sufficient to hold the result,
  43. the return value is NULL and errno is set to ENOSPC. A good value
  44. for CNT is 46.
  45. For more details, see the POSIX:2001 specification
  46. <http://www.opengroup.org/susv3xsh/inet_ntop.html>. */
  47. extern const char *inet_ntop (int af, const void *restrict src,
  48. char *restrict dst, socklen_t cnt);
  49. # endif
  50. #elif defined GNULIB_POSIXCHECK
  51. # undef inet_ntop
  52. # define inet_ntop(af,src,dst,cnt) \
  53. (GL_LINK_WARNING ("inet_ntop is unportable - " \
  54. "use gnulib module inet_ntop for portability"), \
  55. inet_ntop (af, src, dst, cnt))
  56. #endif
  57. #if @GNULIB_INET_PTON@
  58. # if !@HAVE_DECL_INET_PTON@
  59. extern int inet_pton (int af, const char *restrict src, void *restrict dst);
  60. # endif
  61. #elif defined GNULIB_POSIXCHECK
  62. # undef inet_pton
  63. # define inet_pton(af,src,dst) \
  64. (GL_LINK_WARNING ("inet_pton is unportable - " \
  65. "use gnulib module inet_pton for portability"), \
  66. inet_pton (af, src, dst))
  67. #endif
  68. #ifdef __cplusplus
  69. }
  70. #endif
  71. #endif /* _GL_ARPA_INET_H */
  72. #endif /* _GL_ARPA_INET_H */