From 059831534c7e884f0a607ed86b582fd00d821731 Mon Sep 17 00:00:00 2001 From: Christoph Berg Date: Sat, 26 Sep 2026 23:24:03 +0200 Subject: New upstream version 3.2.0~rc1+dfsg --- lib/stream_setmode.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 lib/stream_setmode.c (limited to 'lib/stream_setmode.c') diff --git a/lib/stream_setmode.c b/lib/stream_setmode.c new file mode 100644 index 00000000..f70b29e7 --- /dev/null +++ b/lib/stream_setmode.c @@ -0,0 +1,24 @@ +/* stream_setmode.c — put stdin into binary mode on Windows. + * + * jt9 --stream / jt9stream read a framed binary byte stream (PCM audio + + * control frames) from stdin. On Windows, stdin defaults to text mode, which + * translates CR/LF and stops at a 0x1A (^Z) byte — both corrupt binary data. + * This helper forces binary mode once, before the stream is opened. + * + * On POSIX (Linux, macOS) there is no text/binary distinction for stdin, so + * this compiles to a no-op. Called via a bind(C) interface from + * lib/streaming_io.f90. C linkage gives the exact symbol name (no Fortran + * trailing-underscore mangling), matched by bind(C, name="..."). + */ +#ifdef _WIN32 +#include +#include +#include +#endif + +void stream_set_stdin_binary(void) +{ +#ifdef _WIN32 + _setmode(_fileno(stdin), _O_BINARY); +#endif +} -- cgit v1.2.3