windows: USE_WINSOCK to guard winsock2 code (where missing)

Replacing `_WIN32`.

Also:
- tool_doswin: guard possibly non-portable socket code with
  `USE_WINSOCK`. The socket is cast to `HANDLE` and passed to
  win32 API `SetStdHandle(STD_INPUT_HANDLE, ...)`.
- lib/setup-win32.h: move `#undef`s before their `#define` pair.

Closes #20455
This commit is contained in:
Viktor Szakats 2026-01-27 23:53:05 +01:00
parent a4e2232c43
commit 2f7d37f54a
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
6 changed files with 16 additions and 14 deletions

View file

@ -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 */

View file

@ -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 */