Support binary stdin/stdout on Windows

It's now possible to pipe files over standard input and standard output
in Windows.
pull/28/head
Christopher Wellons 2020-05-03 14:28:21 -04:00
parent b25af46615
commit f7c4b6ba55
2 changed files with 8 additions and 6 deletions

View File

@ -105,11 +105,6 @@ A purposeful design choice is that encrypted/archived files have no
distinguishing marks whatsoever (magic numbers, etc.), making them
indistinguishable from random data.
No effort is made to set stdin and stdout to binary mode. For Windows
this means passing data through Enchive using stdin/stdout isn't
useful. This is low priority because Microsoft's [UCRT file streams
are broken anyway][pipe] when pipes are involved.
### Frequently asked questions
> This tool will never achieve critical mass, so what's the point?
@ -291,6 +286,5 @@ Maximum passphrase size in bytes, including null terminator.
[getrandom]: https://manpages.debian.org/testing/manpages-dev/getrandom.2.en.html
[getentropy]: http://man.openbsd.org/OpenBSD-current/man2/getentropy.2
[csp]: https://msdn.microsoft.com/en-us/library/windows/desktop/aa380246(v=vs.85).aspx
[pipe]: https://radiance-online.org/pipermail/radiance-dev/2016-March/001576.html
[bw]: https://en.bitcoin.it/wiki/Brainwallet
[dw]: http://world.std.com/~reinhold/diceware.html

View File

@ -1593,6 +1593,14 @@ main(int argc, char **argv)
exit(EXIT_FAILURE);
}
#ifdef _WIN32
{ /* Set stdin/stdout to binary mode. */
int _setmode(int, int);
_setmode(0, 0x8000);
_setmode(1, 0x8000);
}
#endif
switch (parse_command(command)) {
case COMMAND_UNKNOWN:
case COMMAND_AMBIGUOUS: