7 #if (NTDDI_VERSION >= NTDDI_WIN2K) 14 #if defined(__GOT_SECURE_LIB__) && __GOT_SECURE_LIB__ >= 200402L 16 #define _WSPIAPI_STRCPY_S strcpy_s 17 #define _WSPIAPI_STRCAT_S strcat_s 21 #define _WSPIAPI_STRCPY_S(_Dst, _Size, _Src) strcpy((_Dst), (_Src)) 22 #define _WSPIAPI_STRCAT_S(_Dst, _Size, _Src) strcat((_Dst), (_Src)) 26 #define _WSPIAPI_STRNCPY_S(_Dst, _Size, _Src, _Count) strncpy((_Dst), (_Src), (_Count)); (_Dst)[(_Size) - 1] = 0 //FIXME 27 #define _WSPIAPI_SPRINTF_S_1(_Dst, _Size, _Format, _Arg1) sprintf((_Dst), (_Format), (_Arg1)) //FIXME 29 #if !defined(_WSPIAPI_COUNTOF) 31 #if !defined(__cplusplus) 32 #define _WSPIAPI_COUNTOF(_Array) (sizeof(_Array) / sizeof(_Array[0])) 34 template <
typename __CountofType,
size_t _N>
35 char (&__wspiapi_countof_helper(__CountofType (&_Array)[
_N]))[
_N];
36 #define _WSPIAPI_COUNTOF(_Array) sizeof(__wspiapi_countof_helper(_Array)) 41 #define WspiapiMalloc(tSize) calloc(1, (tSize)) 42 #define WspiapiFree(p) free(p) 43 #define WspiapiSwap(a, b, c) {(c) = (a); (a) = (b); (b) = (c);} 44 #define getaddrinfo WspiapiGetAddrInfo 45 #define getnameinfo WspiapiGetNameInfo 46 #define freeaddrinfo WspiapiFreeAddrInfo 49 #define WSPIAPI_INLINE __inline 51 #define WSPIAPI_INLINE static inline 56 IN const char *nodename,
87 if (!pszMemory)
return(
NULL);
96 IN const char *pszAddress,
100 const char *pcNext =
NULL;
103 for (pcNext = pszAddress; *pcNext !=
'\0'; pcNext++)
104 if (*pcNext ==
'.') iCount++;
105 if (iCount != 3)
return FALSE;
108 *pdwAddress = dwAddress;
125 if (!ptNew)
return NULL;
133 ptAddress->
sin_addr.s_addr = dwAddress;
147 IN const char *pszNodeName,
154 struct addrinfo **pptNext = pptResult;
164 for (ppAddresses = ptHost->
h_addr_list; *ppAddresses !=
NULL; ppAddresses++) {
167 pptNext = &((*pptNext)->ai_next);
186 IN const char *pszNodeName,
197 char *pszName = szFQDN1;
198 char *pszAlias = szFQDN2;
199 char *pszScratch =
NULL;
203 iError =
WspiapiQueryDNS(pszNodeName, iSocketType, iProtocol, wPort, pszAlias, pptResult);
205 if (*pptResult)
break;
206 if ((!
strlen(pszAlias)) || (!
strcmp(pszName, pszAlias)) || (++iAliasCount == 16)) {
212 if (!iError && bAI_CANONNAME) {
214 if (!(*pptResult)->ai_canonname) iError =
EAI_MEMORY;
232 for (ptNext = ptResult; ptNext !=
NULL; ) {
253 for (ptNext = ptHead; ptNext !=
NULL; ptNext = ptHead) {
265 IN const char *pszNodeName,
266 IN const char *pszServiceName,
284 if ((!pszNodeName) && (!pszServiceName))
return EAI_NONAME;
286 if ((ptHints->ai_addrlen != 0) ||
287 (ptHints->ai_canonname !=
NULL) ||
288 (ptHints->ai_addr !=
NULL) ||
289 (ptHints->ai_next !=
NULL)) {
292 iFlags = ptHints->ai_flags;
294 iFamily = ptHints->ai_family;
296 iSocketType = ptHints->ai_socktype;
297 if ((iSocketType != 0) &&
302 iProtocol = ptHints->ai_protocol;
304 if (pszServiceName) {
307 wPort = wTcpPort = wUdpPort =
htons(wPort);
308 if (iSocketType == 0) {
314 if ((iSocketType == 0) || (iSocketType ==
SOCK_DGRAM)) {
316 if (ptService) wPort = wUdpPort = ptService->
s_port;
318 if ((iSocketType == 0) || (iSocketType ==
SOCK_STREAM)) {
320 if (ptService) wPort = wTcpPort = ptService->
s_port;
323 if (iSocketType == 0) {
325 bClone = (wTcpPort && wUdpPort);
333 if (!iError && pszNodeName) {
337 if (!(*pptResult)->ai_canonname) iError =
EAI_MEMORY;
350 if (!iError && bClone) {
367 OUT char *pszNodeName,
368 IN size_t tNodeLength,
369 OUT char *pszServiceName,
370 IN size_t tServiceLength,
375 char szBuffer[] =
"65535";
376 char *pszService = szBuffer;
379 char *pszNode =
NULL;
382 if ((!ptSocketAddress) || (tSocketLength <
sizeof(
struct sockaddr)))
return EAI_FAIL;
385 if (!(pszNodeName && tNodeLength) && !(pszServiceName && tServiceLength)) {
391 if (pszServiceName && tServiceLength) {
392 wPort = ((
struct sockaddr_in *) ptSocketAddress)->sin_port;
398 if (ptService && ptService->
s_name) {
399 pszService = ptService->
s_name;
405 if (tServiceLength >
strlen(pszService))
409 if (pszNodeName && tNodeLength) {
410 tAddress = ((
struct sockaddr_in *) ptSocketAddress)->sin_addr;
416 if (ptHost && ptHost->
h_name) {
444 #define WSPIAPI_FUNCTION_ARRAY { \ 445 {"getaddrinfo", (FARPROC) WspiapiLegacyGetAddrInfo}, \ 446 {"getnameinfo", (FARPROC) WspiapiLegacyGetNameInfo}, \ 447 {"freeaddrinfo", (FARPROC) WspiapiLegacyFreeAddrInfo} \ 460 static const int iNumGlobal = (
sizeof(rgtGlobal) /
sizeof(
WSPIAPI_FUNCTION));
465 if (
bInitialized)
return (rgtGlobal[wFunction].pfAddress);
475 if (fScratch ==
NULL) {
486 if (fScratch ==
NULL) {
494 for (
i = 0;
i < iNumGlobal;
i++) {
496 if (rgtLocal[
i].pfAddress ==
NULL) {
503 for (
i = 0;
i < iNumGlobal;
i++)
504 rgtGlobal[
i].pfAddress = rgtLocal[
i].pfAddress;
509 return (rgtGlobal[wFunction].pfAddress);
547 iError = (*pfGetNameInfo)(
sa, salen,
host, hostlen, serv, servlen,
flags);
562 (*pfFreeAddrInfo)(ai);
namespace GUID const ADDRINFOEXW * hints
UINT32 strtoul(const char *String, char **Terminator, UINT32 Base)
#define WSAHOST_NOT_FOUND
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
ACPI_SIZE strlen(const char *String)
WSPIAPI_INLINE int WINAPI WspiapiGetNameInfo(IN const struct sockaddr *sa, IN socklen_t salen, OUT char *host, IN size_t hostlen, OUT char *serv, IN size_t servlen, IN int flags)
static __inline int WINAPI WspiapiLegacyGetAddrInfo(IN const char *pszNodeName, IN const char *pszServiceName, IN const struct addrinfo *ptHints, OUT struct addrinfo **pptResult)
UINT WINAPI GetSystemDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
#define _WSPIAPI_STRCPY_S(_Dst, _Size, _Src)
FORCEINLINE struct addrinfo *WINAPI WspiapiNewAddrInfo(IN int iSocketType, IN int iProtocol, IN WORD wPort, IN DWORD dwAddress)
#define _WSPIAPI_COUNTOF(_Array)
#define WspiapiMalloc(tSize)
PHOSTENT WSAAPI gethostbyaddr(IN const char FAR *addr, IN int len, IN int type)
FORCEINLINE int WINAPI WspiapiClone(IN WORD wPort, IN struct addrinfo *ptResult)
static const ADDRINFOW PADDRINFOW *static const WCHAR * servname
void(WINAPI * WSPIAPI_PFREEADDRINFO)(IN struct addrinfo *ai)
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
#define _WSPIAPI_SPRINTF_S_1(_Dst, _Size, _Format, _Arg1)
VOID WSAAPI WSASetLastError(IN INT iError)
WSPIAPI_INLINE int WINAPI WspiapiGetAddrInfo(IN const char *nodename OPTIONAL, IN const char *servname OPTIONAL, IN const struct addrinfo *hints OPTIONAL, OUT struct addrinfo **res)
PHOSTENT WSAAPI gethostbyname(IN const char FAR *name)
#define WspiapiSwap(a, b, c)
INT WSAAPI WSAGetLastError(VOID)
PSERVENT WSAAPI getservbyname(IN const char FAR *name, IN const char FAR *proto)
FORCEINLINE int WINAPI WspiapiLookupNode(IN const char *pszNodeName, IN int iSocketType, IN int iProtocol, IN WORD wPort, IN BOOL bAI_CANONNAME, OUT struct addrinfo **pptResult)
#define _WSPIAPI_STRNCPY_S(_Dst, _Size, _Src, _Count)
FORCEINLINE BOOL WINAPI WspiapiParseV4Address(IN const char *pszAddress, OUT PDWORD pdwAddress)
#define _WSPIAPI_STRCAT_S(_Dst, _Size, _Src)
FORCEINLINE char *WINAPI WspiapiStrdup(IN const char *pszString)
int(WINAPI * WSPIAPI_PGETADDRINFO)(IN const char *nodename, IN const char *servname, IN const struct addrinfo *hints, OUT struct addrinfo **res)
WSPIAPI_INLINE FARPROC WINAPI WspiapiLoad(IN WORD wFunction)
int(WINAPI * WSPIAPI_PGETNAMEINFO)(IN const struct sockaddr *sa, IN socklen_t salen, OUT char *host, IN size_t hostlen, OUT char *serv, IN size_t servlen, IN int flags)
WSPIAPI_INLINE void WINAPI WspiapiFreeAddrInfo(IN struct addrinfo *ai)
PRTL_UNICODE_STRING_BUFFER Path
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
char * strchr(const char *String, int ch)
#define WSPIAPI_FUNCTION_ARRAY
struct addrinfo * ai_next
int strcmp(const char *String1, const char *String2)
#define GetProcAddress(x, y)
static __inline int WINAPI WspiapiLegacyGetNameInfo(IN const struct sockaddr *ptSocketAddress, IN socklen_t tSocketLength, OUT char *pszNodeName, IN size_t tNodeLength, OUT char *pszServiceName, IN size_t tServiceLength, IN int iFlags)
PSERVENT WSAAPI getservbyport(IN int port, IN const char FAR *proto)
struct sockaddr * ai_addr
static struct sockaddr_in sa
static __inline void WINAPI WspiapiLegacyFreeAddrInfo(IN struct addrinfo *ptHead)
_In_ DWORD _In_ DWORD _Out_writes_to_opt_ pcchString LPSTR pszString
FORCEINLINE int WINAPI WspiapiQueryDNS(IN const char *pszNodeName, IN int iSocketType, IN int iProtocol, IN WORD wPort, OUT char pszAlias[NI_MAXHOST], OUT struct addrinfo **pptResult)
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
PULONG MinorVersion OPTIONAL