| 1 | #ifndef WIN32_LEAN_AND_MEAN |
| 2 | #define WIN32_LEAN_AND_MEAN |
| 3 | #endif |
| 4 | #undef __CRT__NO_INLINE |
| 5 | #define __CRT__NO_INLINE |
| 6 | #include <winsock2.h> |
| 7 | #include <wspiapi.h> |
| 8 | |
| 9 | struct addrinfo * WINAPI |
| 10 | WspiapiNewAddrInfo (int iSocketType, int iProtocol, WORD wPort, DWORD dwAddress) |
| 11 | { |
| 12 | struct addrinfo *n; |
| 13 | struct sockaddr_in *pa; |
| 14 | |
| 15 | if ((n = (struct addrinfo *) WspiapiMalloc (sizeof (struct addrinfo))) == NULL) |
| 16 | return NULL; |
| 17 | if ((pa = (struct sockaddr_in *) WspiapiMalloc (sizeof(struct sockaddr_in))) == NULL) |
| 18 | { |
| 19 | 	WspiapiFree(n); |
| 20 | 	return NULL; |
| 21 | } |
| 22 | pa->sin_family = AF_INET; |
| 23 | pa->sin_port = wPort; |
| 24 | pa->sin_addr.s_addr = dwAddress; |
| 25 | n->ai_family = PF_INET; |
| 26 | n->ai_socktype = iSocketType; |
| 27 | n->ai_protocol = iProtocol; |
| 28 | n->ai_addrlen = sizeof (struct sockaddr_in); |
| 29 | n->ai_addr = (struct sockaddr *) pa; |
| 30 | return n; |
| 31 | } |