From 5d3f8776ed518cc1697d1c13fe46efd9afe73f97 Mon Sep 17 00:00:00 2001 From: JacobBarthelmeh Date: Wed, 6 Mar 2024 09:49:42 -0700 Subject: [PATCH] add macro guard on windows version for VT --- apps/wolfssh/wolfssh.c | 8 +++++++- examples/client/client.c | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/apps/wolfssh/wolfssh.c b/apps/wolfssh/wolfssh.c index 6a45ca6d5..d3b601786 100644 --- a/apps/wolfssh/wolfssh.c +++ b/apps/wolfssh/wolfssh.c @@ -412,7 +412,13 @@ static THREAD_RET readPeer(void* in) } /* depend on the terminal to process VT characters */ - wrd |= (ENABLE_VIRTUAL_TERMINAL_PROCESSING | ENABLE_PROCESSED_OUTPUT); + #ifndef _WIN32_WINNT_WIN10 + /* support for virtual terminal processing was introduced in windows 10 */ + #define _WIN32_WINNT_WIN10 0x0A00 + #endif + #if defined(WINVER) && (WINVER >= _WIN32_WINNT_WIN10) + wrd |= (ENABLE_VIRTUAL_TERMINAL_PROCESSING | ENABLE_PROCESSED_OUTPUT); + #endif if (SetConsoleMode(stdoutHandle, wrd) == FALSE) { err_sys("Unable to set console mode"); } diff --git a/examples/client/client.c b/examples/client/client.c index 8d683a8b5..974c321f7 100644 --- a/examples/client/client.c +++ b/examples/client/client.c @@ -375,7 +375,13 @@ static THREAD_RET readPeer(void* in) } /* depend on the terminal to process VT characters */ - wrd |= (ENABLE_VIRTUAL_TERMINAL_PROCESSING | ENABLE_PROCESSED_OUTPUT); + #ifndef _WIN32_WINNT_WIN10 + /* support for virtual terminal processing was introduced in windows 10 */ + #define _WIN32_WINNT_WIN10 0x0A00 + #endif + #if defined(WINVER) && (WINVER >= _WIN32_WINNT_WIN10) + wrd |= (ENABLE_VIRTUAL_TERMINAL_PROCESSING | ENABLE_PROCESSED_OUTPUT); + #endif if (SetConsoleMode(stdoutHandle, wrd) == FALSE) { err_sys("Unable to set console mode"); }