From 39507b8b9007f6f92c2c336188c456d6a1c23a64 Mon Sep 17 00:00:00 2001 From: DeckerSU Date: Mon, 9 Oct 2017 15:44:28 +0400 Subject: [PATCH] Ugly fix problem with WinSock2.h and Windows.h included twice. warning C4005: 'AF_IPX': macro redefinition and same problems. TODO: Need to properly include windows.h and WinSock2.h in all project. --- OSlibs/win/mingw.h | 3 +++ iguana/exchanges/LP_socket.c | 37 +++++++++++++++++++++++++++++++----- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/OSlibs/win/mingw.h b/OSlibs/win/mingw.h index aa5ae5274..37e1ea879 100755 --- a/OSlibs/win/mingw.h +++ b/OSlibs/win/mingw.h @@ -5,6 +5,8 @@ #include #define _USE_W32_SOCKETS 1 +//#define WIN32_LEAN_AND_MEAN +//#define _WINSOCKAPI_ #include #define PTW32_STATIC_LIB #include "pthread.h" @@ -40,6 +42,7 @@ //TODO: need to update other values to match with WSAPoll() function #define POLLRDNORM 0x0100 #define POLLRDBAND 0x0200 +#define POLLWRNORM 0x0010 #define POLLIN POLLRDNORM | POLLRDBAND /* There is data to read */ #define POLLOUT POLLWRNORM /* Writing now will not block */ #else diff --git a/iguana/exchanges/LP_socket.c b/iguana/exchanges/LP_socket.c index e4727bada..30f6ce0b7 100644 --- a/iguana/exchanges/LP_socket.c +++ b/iguana/exchanges/LP_socket.c @@ -21,10 +21,12 @@ * @remarks - #if (defined(_M_X64) || defined(__amd64__)) && defined(WIN32) * is equivalent to #if defined(_M_X64) as _M_X64 is defined for MSVC only */ -#if defined(_M_X64) -#define WIN32_LEAN_AND_MEAN -#include -#endif + +//#if defined(_M_X64) +//#define WIN32_LEAN_AND_MEAN +//#define _WINSOCKAPI_ +//#include +//#endif #define ELECTRUM_TIMEOUT 5 @@ -42,6 +44,20 @@ int32_t LP_socket(int32_t bindflag,char *hostname,uint16_t port) * @author - fadedreamz@gmail.com */ #if defined(_M_X64) + + typedef struct addrinfo + { + int ai_flags; // AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST + int ai_family; // PF_xxx + int ai_socktype; // SOCK_xxx + int ai_protocol; // 0 or IPPROTO_xxx for IPv4 and IPv6 + size_t ai_addrlen; // Length of ai_addr + char * ai_canonname; // Canonical name for nodename + _Field_size_bytes_(ai_addrlen) struct sockaddr * ai_addr; // Binary address + struct addrinfo * ai_next; // Next structure in linked list + } + ADDRINFOA, *PADDRINFOA; + struct addrinfo *addrresult = NULL; struct addrinfo *returnptr = NULL; struct addrinfo hints; @@ -805,7 +821,18 @@ int32_t LP_recvfunc(struct electrum_info *ep,char *str,int32_t len) void LP_dedicatedloop(void *arg) { - struct pollfd fds; int32_t i,len,flag,timeout = 10; struct iguana_info *coin; cJSON *retjson; struct stritem *sitem; struct electrum_info *ep = arg; +#if defined(_M_X64) + typedef struct pollfd { + + SOCKET fd; + SHORT events; + SHORT revents; + + } WSAPOLLFD, *PWSAPOLLFD, FAR *LPWSAPOLLFD; +#endif + + struct pollfd fds; + int32_t i,len,flag,timeout = 10; struct iguana_info *coin; cJSON *retjson; struct stritem *sitem; struct electrum_info *ep = arg; if ( (coin= LP_coinfind(ep->symbol)) != 0 ) ep->heightp = &coin->height, ep->heighttimep = &coin->heighttime; if ( (retjson= electrum_headers_subscribe(ep->symbol,ep,0)) != 0 )