diff --git a/lib/curl_setup.h b/lib/curl_setup.h index f4640b922f..900264b8ff 100644 --- a/lib/curl_setup.h +++ b/lib/curl_setup.h @@ -515,7 +515,7 @@ #ifndef SIZEOF_CURL_SOCKET_T /* configure and cmake check and set the define */ -# ifdef _WIN64 +# if defined(USE_WINSOCK) && defined(_WIN64) # define SIZEOF_CURL_SOCKET_T 8 # else /* default guess */ @@ -524,12 +524,12 @@ #endif #if SIZEOF_CURL_SOCKET_T < 8 -#ifdef _WIN32 +#ifdef USE_WINSOCK # define FMT_SOCKET_T "u" #else # define FMT_SOCKET_T "d" #endif -#elif defined(_WIN32) +#elif defined(USE_WINSOCK) # define FMT_SOCKET_T "zu" #else # define FMT_SOCKET_T "qd" @@ -898,7 +898,7 @@ endings either CRLF or LF so 't' is appropriate. /* for systems that do not detect this in configure */ #ifndef CURL_SA_FAMILY_T -# ifdef _WIN32 +# ifdef USE_WINSOCK # define CURL_SA_FAMILY_T ADDRESS_FAMILY # elif defined(HAVE_SA_FAMILY_T) # define CURL_SA_FAMILY_T sa_family_t diff --git a/lib/functypes.h b/lib/functypes.h index ba754f99b6..12dfe17906 100644 --- a/lib/functypes.h +++ b/lib/functypes.h @@ -37,7 +37,7 @@ 2. For systems with config-*.h files, define them there. */ -#ifdef _WIN32 +#ifdef USE_WINSOCK /* int recv(SOCKET, char *, int, int) */ #define RECV_TYPE_ARG1 SOCKET #define RECV_TYPE_ARG2 char * diff --git a/lib/setup-win32.h b/lib/setup-win32.h index 7aada6a826..3ac8c6d512 100644 --- a/lib/setup-win32.h +++ b/lib/setup-win32.h @@ -45,20 +45,22 @@ /* Define to use BSD-style lwIP TCP/IP stack. */ /* #define USE_LWIPSOCK 1 */ # undef HAVE_GETHOSTNAME -# undef LWIP_POSIX_SOCKETS_IO_NAMES -# undef RECV_TYPE_ARG1 -# undef RECV_TYPE_ARG3 -# undef SEND_TYPE_ARG1 -# undef SEND_TYPE_ARG3 # define HAVE_GETHOSTBYNAME_R # define HAVE_GETHOSTBYNAME_R_6 +# undef LWIP_POSIX_SOCKETS_IO_NAMES # define LWIP_POSIX_SOCKETS_IO_NAMES 0 +# undef RECV_TYPE_ARG1 # define RECV_TYPE_ARG1 int +# undef RECV_TYPE_ARG3 # define RECV_TYPE_ARG3 size_t +# undef SEND_TYPE_ARG1 # define SEND_TYPE_ARG1 int +# undef SEND_TYPE_ARG3 # define SEND_TYPE_ARG3 size_t #elif defined(_WIN32) # define USE_WINSOCK 2 +# include +# include #endif /* @@ -77,8 +79,6 @@ # if defined(_UNICODE) && !defined(UNICODE) # error "_UNICODE is defined but UNICODE is not defined" # endif -# include -# include # include # include # include diff --git a/lib/url.c b/lib/url.c index 943ae6ad62..40a3f2ce66 100644 --- a/lib/url.c +++ b/lib/url.c @@ -58,7 +58,7 @@ #error "We cannot compile without socket() support!" #endif -#if defined(HAVE_IF_NAMETOINDEX) && defined(_WIN32) +#if defined(HAVE_IF_NAMETOINDEX) && defined(USE_WINSOCK) #if defined(__MINGW32__) && (__MINGW64_VERSION_MAJOR <= 5) #include /* workaround for old mingw-w64 missing to include it */ #endif diff --git a/src/tool_doswin.c b/src/tool_doswin.c index 5cc885137f..27593c6636 100644 --- a/src/tool_doswin.c +++ b/src/tool_doswin.c @@ -693,6 +693,7 @@ static void init_terminal(void) } } +#ifdef USE_WINSOCK /* The following STDIN non - blocking read techniques are heavily inspired by nmap and ncat (https://nmap.org/ncat/) */ struct win_thread_data { @@ -895,6 +896,7 @@ curl_socket_t win32_stdin_read_thread(void) assert(socket_r != CURL_SOCKET_BAD); return socket_r; } +#endif /* USE_WINSOCK */ #endif /* !CURL_WINDOWS_UWP */ diff --git a/src/tool_operate.c b/src/tool_operate.c index 0998303774..300826ef26 100644 --- a/src/tool_operate.c +++ b/src/tool_operate.c @@ -1119,7 +1119,7 @@ static void check_stdin_upload(struct OperationConfig *config, CURLX_SET_BINMODE(stdin); if(!strcmp(per->uploadfile, ".")) { -#if defined(_WIN32) && !defined(CURL_WINDOWS_UWP) +#if defined(USE_WINSOCK) && !defined(CURL_WINDOWS_UWP) /* non-blocking stdin behavior on Windows is challenging Spawn a new thread that will read from stdin and write out to a socket */