PageRenderTime 26ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

/tcpreen-1.4.4/libsolve/getaddrinfo.h

#
C Header | 163 lines | 112 code | 18 blank | 33 comment | 6 complexity | 5f33a2778744eeec29a6adcd6009c875 MD5 | raw file
Possible License(s): GPL-2.0
  1. /*
  2. * Convenience header for <netdb.h> getaddrinfo() & co modern resolution
  3. * functions.
  4. * $Id: getaddrinfo.h 172 2005-06-16 20:08:53Z rdenisc $
  5. *
  6. * Feel free to reuse in other GPL programs.
  7. */
  8. /***********************************************************************
  9. * Copyright (C) 2002-2004 Remi Denis-Courmont. *
  10. * This program is free software; you can redistribute and/or modify *
  11. * it under the terms of the GNU General Public License as published *
  12. * by the Free Software Foundation; version 2 of the license. *
  13. * *
  14. * This program is distributed in the hope that it will be useful, *
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
  17. * See the GNU General Public License for more details. *
  18. * *
  19. * You should have received a copy of the GNU General Public License *
  20. * along with this program; if not, you can get it from: *
  21. * http://www.gnu.org/copyleft/gpl.html *
  22. ***********************************************************************/
  23. #ifndef __TCPREEN_GETADDRINFO_H
  24. # define __TCPREEN_GETADDRINFO_H
  25. # include <stddef.h>
  26. # include <sys/types.h>
  27. # ifdef HAVE_SYS_SOCKET_H
  28. # include <sys/socket.h>
  29. # endif
  30. # ifdef HAVE_NETDB_H
  31. # include <netdb.h>
  32. # endif
  33. # ifdef WIN32
  34. # ifdef HAVE_GETADDRINFO
  35. # define __KLUDGE_STRUCT_ADDRINFO
  36. # undef HAVE_GETADDRINFO
  37. # endif
  38. # undef HAVE_GETNAMEINFO
  39. # endif
  40. # if !(defined(HAVE_GAI_STRERROR) && defined(HAVE_GETNAMEINFO) \
  41. && defined(HAVE_GETADDRINFO))
  42. /* GAI error codes */
  43. # ifndef EAI_BADFLAGS
  44. # define EAI_BADFLAGS -1
  45. # endif
  46. # ifndef EAI_NONAME
  47. # define EAI_NONAME -2
  48. # endif
  49. # ifndef EAI_AGAIN
  50. # define EAI_AGAIN -3
  51. # endif
  52. # ifndef EAI_FAIL
  53. # define EAI_FAIL -4
  54. # endif
  55. # ifndef EAI_NODATA
  56. # define EAI_NODATA -5
  57. # endif
  58. # ifndef EAI_FAMILY
  59. # define EAI_FAMILY -6
  60. # endif
  61. # ifndef EAI_SOCKTYPE
  62. # define EAI_SOCKTYPE -7
  63. # endif
  64. # ifndef EAI_SERVICE
  65. # define EAI_SERVICE -8
  66. # endif
  67. # ifndef EAI_ADDRFAMILY
  68. # define EAI_ADDRFAMILY -9
  69. # endif
  70. # ifndef EAI_MEMORY
  71. # define EAI_MEMORY -10
  72. # endif
  73. # ifndef EAI_SYSTEM
  74. # define EAI_SYSTEM -11
  75. # endif
  76. # if !HAVE_GETNAMEINFO
  77. /*
  78. * Replacement for getnameinfo().
  79. */
  80. # ifndef NI_MAXHOST
  81. # define NI_MAXHOST 1025
  82. # define NI_MAXSERV 32
  83. # endif
  84. # ifndef NI_NUMERICHOST
  85. # define NI_NUMERICHOST 0x01
  86. # define NI_NUMERICSERV 0x02
  87. # define NI_NOFQDN 0x04
  88. # define NI_NAMEREQD 0x08
  89. # define NI_DGRAM 0x10
  90. # endif
  91. # define _NI_MASK (NI_NUMERICHOST|NI_NUMERICSERV|NI_NOFQDN|\
  92. NI_NAMEREQD|NI_DGRAM)
  93. # ifdef __cplusplus
  94. extern "C"
  95. # endif
  96. int getnameinfo(const struct sockaddr *sa, int salen,
  97. char *host, int hostlen, char *serv, int servlen, int flags);
  98. # endif /* if !HAVE_GETNAMEINFO */
  99. # if !HAVE_GAI_STRERROR
  100. /*
  101. * Replacement for gai_strerror().
  102. */
  103. # ifdef __cplusplus
  104. extern "C"
  105. # endif
  106. const char *gai_strerror(int errnum);
  107. # endif /* if !HAVE_GAI_STRERROR */
  108. # if !HAVE_GETADDRINFO
  109. /*
  110. * Replacement for getaddrinfo() and freeaddrinfo().
  111. */
  112. # ifndef __KLUDGE_STRUCT_ADDRINFO
  113. struct addrinfo
  114. {
  115. int ai_flags;
  116. int ai_family;
  117. int ai_socktype;
  118. int ai_protocol;
  119. size_t ai_addrlen;
  120. struct sockaddr *ai_addr;
  121. char *ai_canonname;
  122. struct addrinfo *ai_next;
  123. };
  124. # define AI_PASSIVE 1
  125. # define AI_CANONNAME 2
  126. # define AI_NUMERICHOST 4
  127. # endif
  128. # define _AI_MASK 7
  129. # ifdef __cplusplus
  130. extern "C" {
  131. # endif
  132. void freeaddrinfo(struct addrinfo *res);
  133. int getaddrinfo(const char *node, const char *serv,
  134. const struct addrinfo *hints, struct addrinfo **res);
  135. # ifdef __cplusplus
  136. }
  137. # endif
  138. # endif /* if !HAVE_GETADDRINFO */
  139. # endif
  140. /*** libidn support ***/
  141. # ifndef AI_IDN
  142. # define AI_IDN 0
  143. # define AI_CANONIDN 0
  144. # endif
  145. #endif /* ifndef __RDC_GETADDRINFO_H */