windows: `USE_WINSOCK` to guard winsock2 code (where missing)
No binary (build failed)
—
(log yok)
| @@ -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 | |
| @@ -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 * | |
| @@ -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 <winsock2.h> |
| + | # include <ws2tcpip.h> |
| #endif | |
| /* | |
| @@ -77,8 +79,6 @@ | |
| # if defined(_UNICODE) && !defined(UNICODE) | |
| # error "_UNICODE is defined but UNICODE is not defined" | |
| # endif | |
| - | # include <winsock2.h> |
| - | # include <ws2tcpip.h> |
| # include <windows.h> | |
| # include <winerror.h> | |
| # include <tchar.h> | |
| @@ -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 <wincrypt.h> /* workaround for old mingw-w64 missing to include it */ | |
| #endif | |
| @@ -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 */ | |
| @@ -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 */ | |