diff options
| author | hibby <d@vehibberd.com> | 2026-10-06 21:24:40 +0100 |
|---|---|---|
| committer | hibby <d@vehibberd.com> | 2026-10-06 21:24:40 +0100 |
| commit | c25cbdf6fb6d946175f4335fab77bfea601b56db (patch) | |
| tree | 6f7a94b7b81f999e434f61b73d47e337dfd26bf2 /lib/stream_setmode.c | |
| parent | 71f5689252c9f13e70e1c24856904475b2307809 (diff) | |
| parent | 0685fcada9f95fe90f70b387cd7d757da8209624 (diff) | |
Merge tag 'debian/3.2.0_rc1+dfsg-2' into debian/trixie-backportsdebian/trixie-backports
tagging wsjtx 3.2.0~rc1+dfsg-2
Diffstat (limited to 'lib/stream_setmode.c')
| -rw-r--r-- | lib/stream_setmode.c | 24 |
1 files changed, 24 insertions, 0 deletions
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 <io.h> +#include <fcntl.h> +#include <stdio.h> +#endif + +void stream_set_stdin_binary(void) +{ +#ifdef _WIN32 + _setmode(_fileno(stdin), _O_BINARY); +#endif +} |
