binmode: convert to macro and use it from tests

And use it from src and tests.

Syncing this functionality between platforms and build targets.

Also: Stop redefining `O_BINARY` in src, and use a local macro with
the same effect. `O_BINARY` is used in `CURL_SET_BINMODE()` to decide
if this functionality is supported, and redefining it makes this check
pass always in unity builds. The check is required for Apple OS, because
it offers a `setmode()` function, successfully detected by both CMake
and autotools, but that function has a different functionality and
signature than that expected by `CURL_SET_BINMODE()`.

Also:
- drop MetaWare High C (MS-DOS) support for set binmode.
- tests/libtest/Makefile.inc: dedupe comments.
- lib/curl_setup_once.h: tidy up feature guards for `io.h`, `fcntl.h`.

Ref: #15652
Closes #15787
This commit is contained in:
Viktor Szakats 2024-11-27 13:52:30 +01:00
parent 3428b8ad1c
commit 250d613763
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
18 changed files with 63 additions and 125 deletions

View file

@ -106,7 +106,7 @@ static struct tool_mime *tool_mime_new_filedata(struct tool_mime *parent,
curl_off_t origin;
struct_stat sbuf;
set_binmode(stdin);
CURL_SET_BINMODE(stdin);
origin = ftell(stdin);
/* If stdin is a regular file, do not buffer data but read it
when needed. */