Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef GETADDRINFO_H
00023 #define GETADDRINFO_H
00024
00025 #include <sys/socket.h>
00026 #include <netdb.h>
00027
00028
00029
00030
00031 #ifndef EAI_FAIL
00032 #ifndef WIN32
00033 #define EAI_BADFLAGS (-1)
00034 #define EAI_NONAME (-2)
00035 #define EAI_AGAIN (-3)
00036 #define EAI_FAIL (-4)
00037 #define EAI_FAMILY (-6)
00038 #define EAI_SOCKTYPE (-7)
00039 #define EAI_SERVICE (-8)
00040 #define EAI_MEMORY (-10)
00041 #define EAI_SYSTEM (-11)
00042 #else
00043 #ifdef WIN32_ONLY_COMPILER
00044 #ifndef WSA_NOT_ENOUGH_MEMORY
00045 #define WSA_NOT_ENOUGH_MEMORY (WSAENOBUFS)
00046 #endif
00047 #ifndef __BORLANDC__
00048 #define WSATYPE_NOT_FOUND (WSABASEERR+109)
00049 #endif
00050 #endif
00051 #define EAI_AGAIN WSATRY_AGAIN
00052 #define EAI_BADFLAGS WSAEINVAL
00053 #define EAI_FAIL WSANO_RECOVERY
00054 #define EAI_FAMILY WSAEAFNOSUPPORT
00055 #define EAI_MEMORY WSA_NOT_ENOUGH_MEMORY
00056 #define EAI_NODATA WSANO_DATA
00057 #define EAI_NONAME WSAHOST_NOT_FOUND
00058 #define EAI_SERVICE WSATYPE_NOT_FOUND
00059 #define EAI_SOCKTYPE WSAESOCKTNOSUPPORT
00060 #endif
00061 #endif
00062
00063 #ifndef AI_PASSIVE
00064 #define AI_PASSIVE 0x0001
00065 #endif
00066
00067 #ifndef AI_NUMERICHOST
00068
00069
00070
00071
00072 #if defined(HAVE_STRUCT_ADDRINFO) && defined(HAVE_GETADDRINFO)
00073 #define AI_NUMERICHOST 0
00074 #else
00075 #define AI_NUMERICHOST 0x0004
00076 #endif
00077 #endif
00078
00079 #ifndef NI_NUMERICHOST
00080 #define NI_NUMERICHOST 1
00081 #endif
00082 #ifndef NI_NUMERICSERV
00083 #define NI_NUMERICSERV 2
00084 #endif
00085
00086 #ifndef NI_MAXHOST
00087 #define NI_MAXHOST 1025
00088 #endif
00089 #ifndef NI_MAXSERV
00090 #define NI_MAXSERV 32
00091 #endif
00092
00093
00094 #ifndef HAVE_STRUCT_ADDRINFO
00095
00096 #ifndef WIN32
00097 struct addrinfo
00098 {
00099 int ai_flags;
00100 int ai_family;
00101 int ai_socktype;
00102 int ai_protocol;
00103 size_t ai_addrlen;
00104 struct sockaddr *ai_addr;
00105 char *ai_canonname;
00106 struct addrinfo *ai_next;
00107 };
00108 #else
00109
00110
00111
00112
00113
00114 struct addrinfo
00115 {
00116 int ai_flags;
00117 int ai_family;
00118 int ai_socktype;
00119 int ai_protocol;
00120 size_t ai_addrlen;
00121 char *ai_canonname;
00122 struct sockaddr *ai_addr;
00123 struct addrinfo *ai_next;
00124 };
00125 #endif
00126 #endif
00127
00128
00129 #ifndef HAVE_GETADDRINFO
00130
00131
00132 #ifdef getaddrinfo
00133 #undef getaddrinfo
00134 #endif
00135 #define getaddrinfo pg_getaddrinfo
00136
00137 #ifdef freeaddrinfo
00138 #undef freeaddrinfo
00139 #endif
00140 #define freeaddrinfo pg_freeaddrinfo
00141
00142 #ifdef gai_strerror
00143 #undef gai_strerror
00144 #endif
00145 #define gai_strerror pg_gai_strerror
00146
00147 #ifdef getnameinfo
00148 #undef getnameinfo
00149 #endif
00150 #define getnameinfo pg_getnameinfo
00151
00152 extern int getaddrinfo(const char *node, const char *service,
00153 const struct addrinfo * hints, struct addrinfo ** res);
00154 extern void freeaddrinfo(struct addrinfo * res);
00155 extern const char *gai_strerror(int errcode);
00156 extern int getnameinfo(const struct sockaddr * sa, int salen,
00157 char *node, int nodelen,
00158 char *service, int servicelen, int flags);
00159 #endif
00160
00161 #endif