diff --git a/bin/base64.c b/bin/base64.c index f419056..42689d3 100644 --- a/bin/base64.c +++ b/bin/base64.c @@ -359,41 +359,13 @@ encode_inner (const struct config *config, struct buffer *buf) static bool encode (const struct config *config, struct buffer *buf) { -#ifdef WIN - DWORD dwMode; - - // Get the standard output handle. - HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE); - - // Check for errors. - if (hOut == INVALID_HANDLE_VALUE) { - fprintf(stderr, "GetStdHandle: err#%d\n", GetLastError()); - return false; - } - - // Save the current output mode. - if (!GetConsoleMode(hOut, &dwMode)) { - fprintf(stderr, "GetConsoleMode: err#%d\n", GetLastError()); + if (freopen(NULL, "wb", stdout) == 0) { + fprintf(stderr, "freopen(stdout)\n"); return false; } - // Disable newline mangling. - if (!SetConsoleMode(hOut, dwMode | DISABLE_NEWLINE_AUTO_RETURN)) { - fprintf(stderr, "SetConsoleMode: err#%d\n", GetLastError()); - return false; - } -#endif - const bool ret = encode_inner(config, buf); -#ifdef WIN - - // Restore the original console settings. - if (!SetConsoleMode(hOut, dwMode)) { - fprintf(stderr, "SetConsoleMode: err#%d\n", GetLastError()); - } -#endif - return ret; }