curl: limit Windows-specific code to Windows builds, other tidy-ups
No binary (build failed)
—
(log yok)
| @@ -113,13 +113,14 @@ size_t tool_read_cb(char *buffer, size_t sz, size_t nmemb, void *userdata) | |
| #endif | |
| } | |
| + | #ifdef _WIN32 |
| /* If we are on Windows, and using `-T .`, then per->infd points to a socket | |
| connected to stdin via a reader thread, and needs to be read with recv() | |
| Make sure we are in non-blocking mode and infd is not regular stdin | |
| On Linux per->infd should be stdin (0) and the block below should not | |
| execute */ | |
| if(per->uploadfile && !strcmp(per->uploadfile, ".") && per->infd > 0) { | |
| - | #if defined(_WIN32) && !defined(CURL_WINDOWS_UWP) |
| + | #ifndef CURL_WINDOWS_UWP |
| rc = recv(per->infd, buffer, curlx_uztosi(sz * nmemb), 0); | |
| if(rc < 0) { | |
| if(SOCKERRNO == SOCKEWOULDBLOCK) { | |
| @@ -131,11 +132,13 @@ size_t tool_read_cb(char *buffer, size_t sz, size_t nmemb, void *userdata) | |
| rc = 0; | |
| } | |
| #else | |
| - | warnf("per->infd != 0: FD == %d. This behavior" |
| - | " is only supported on desktop Windows", per->infd); |
| + | warnf("per->infd != 0: FD == %d. " |
| + | "This behavior is only supported on desktop Windows", per->infd); |
| #endif | |
| } | |
| - | else { |
| + | else |
| + | #endif |
| + | { |
| rc = read(per->infd, buffer, sz * nmemb); | |
| if(rc < 0) { | |
| if(errno == EAGAIN) { | |
| @@ -147,6 +150,7 @@ size_t tool_read_cb(char *buffer, size_t sz, size_t nmemb, void *userdata) | |
| rc = 0; | |
| } | |
| } | |
| + | |
| if((per->uploadfilesize != -1) && | |
| (per->uploadedsofar + rc > per->uploadfilesize)) { | |
| /* do not allow uploading more than originally set out to do */ | |
| @@ -607,22 +607,21 @@ static CURLcode post_per_transfer(struct per_transfer *per, | |
| if(!curl || !config) | |
| return result; | |
| + | #ifdef _WIN32 |
| if(per->uploadfile) { | |
| if(!strcmp(per->uploadfile, ".") && per->infd > 0) { | |
| - | #if defined(_WIN32) && !defined(CURL_WINDOWS_UWP) |
| + | #ifndef CURL_WINDOWS_UWP |
| sclose(per->infd); | |
| #else | |
| - | warnf("Closing per->infd != 0: FD == " |
| - | "%d. This behavior is only supported on desktop " |
| - | " Windows", per->infd); |
| + | warnf("Closing per->infd != 0: FD == %d. " |
| + | "This behavior is only supported on desktop Windows", per->infd); |
| #endif | |
| } | |
| } | |
| - | else { |
| - | if(per->infdopen) { |
| + | else |
| + | #endif |
| + | if(per->infdopen) |
| close(per->infd); | |
| - | } |
| - | } |
| if(per->skip) | |
| goto skip; | |