arpa_inet.in.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. #if @GNULIB_INET_NTOP@
  29. # if !@HAVE_DECL_INET_NTOP@
  30. /* Converts an internet address from internal format to a printable,
  31. presentable format.
  32. AF is an internet address family, such as AF_INET or AF_INET6.
  33. SRC points to a 'struct in_addr' (for AF_INET) or 'struct in6_addr'
  34. (for AF_INET6).
  35. DST points to a buffer having room for CNT bytes.
  36. The printable representation of the address (in numeric form, not
  37. surrounded by [...], no reverse DNS is done) is placed in DST, and
  38. DST is returned. If an error occurs, the return value is NULL and
  39. errno is set. If CNT bytes are not sufficient to hold the result,
  40. the return value is NULL and errno is set to ENOSPC. A good value
  41. for CNT is 46.
  42. For more details, see the POSIX:2001 specification
  43. <http://www.opengroup.org/susv3xsh/inet_ntop.html>. */
  44. extern const char *inet_ntop (int af, const void *restrict src,
  45. char *restrict dst, socklen_t cnt);
  46. # endif
  47. #elif defined GNULIB_POSIXCHECK
  48. # undef inet_ntop
  49. # define inet_ntop(af,src,dst,cnt) \
  50. (GL_LINK_WARNING ("inet_ntop is unportable - " \
  51. "use gnulib module inet_ntop for portability"), \
  52. inet_ntop (af, src, dst, cnt))
  53. #endif
  54. #if @GNULIB_INET_PTON@
  55. # if !@HAVE_DECL_INET_PTON@
  56. extern int inet_pton (int af, const char *restrict src, void *restrict dst);
  57. # endif
  58. #elif defined GNULIB_POSIXCHECK
  59. # undef inet_pton
  60. # define inet_pton(af,src,dst) \
  61. (GL_LINK_WARNING ("inet_pton is unportable - " \
  62. "use gnulib module inet_pton for portability"), \
  63. inet_pton (af, src, dst))
  64. #endif
  65. #endif /* _GL_ARPA_INET_H */
  66. #endif /* _GL_ARPA_INET_H */