diff --git a/base/shell/cmd/cmd.c b/base/shell/cmd/cmd.c index 2fa513c652e..bfa55221382 100644 --- a/base/shell/cmd/cmd.c +++ b/base/shell/cmd/cmd.c @@ -180,6 +180,38 @@ CON_STREAM_MODE OutputStreamMode = UTF8Text; // AnsiText; WORD wDefColor = 0; /* Default color */ #endif +/* Dynamic tracing */ +#ifdef FEATURE_DYNAMIC_TRACE + +BOOL g_bDynamicTracing = FALSE; + +VOID cmd_trace(LPCSTR pszFormat, ...) +{ + va_list va; + char szTextA[1024]; +#ifdef _UNICODE + wchar_t szTextW[1024]; +#endif + + if (!g_bDynamicTracing) + return; + + va_start(va, pszFormat); + StringCchVPrintfA(szTextA, _countof(szTextA), pszFormat, va); + +#ifdef _UNICODE + MultiByteToWideChar(OutputCodePage, 0, szTextA, -1, szTextW, _countof(szTextW)); + szTextW[_countof(szTextW) - 1] = UNICODE_NULL; /* Avoid buffer overrun */ + ConOutPuts(szTextW); +#else + ConOutPuts(szTextA); +#endif + + va_end(va); +} + +#endif + /* * convert * diff --git a/base/shell/cmd/config.h b/base/shell/cmd/config.h index 3a5b70b221a..09fb65d7e8e 100644 --- a/base/shell/cmd/config.h +++ b/base/shell/cmd/config.h @@ -18,26 +18,24 @@ /* Define to enable the alias command, and aliases.*/ #define FEATURE_ALIASES - /* Define to enable history */ #define FEATURE_HISTORY /*Define to enable history wrap (4nt's style)*/ #define WRAP_HISTORY - /* Define one of these to enable filename completion */ //#define FEATURE_UNIX_FILENAME_COMPLETION #define FEATURE_4NT_FILENAME_COMPLETION - /* Define to enable the directory stack */ #define FEATURE_DIRECTORY_STACK - /* Define to activate redirections and piping */ #define FEATURE_REDIRECTION +/* Define to enable dynamic switching of TRACE output in console */ +#define FEATURE_DYNAMIC_TRACE /* Define one of these to select the used locale. */ /* (date and time formats etc.) used in DATE, TIME, */ diff --git a/base/shell/cmd/precomp.h b/base/shell/cmd/precomp.h index 7c0e76dc3da..c902dc97f15 100644 --- a/base/shell/cmd/precomp.h +++ b/base/shell/cmd/precomp.h @@ -37,10 +37,24 @@ #include WINE_DEFAULT_DEBUG_CHANNEL(cmd); + #ifdef UNICODE #define debugstr_aw debugstr_w #else #define debugstr_aw debugstr_a #endif +#ifdef FEATURE_DYNAMIC_TRACE +extern BOOL g_bDynamicTracing; +void cmd_trace(LPCSTR pszFormat, ...); +#undef TRACE +#define TRACE cmd_trace +#undef ERR +#define ERR cmd_trace +#undef WARN +#define WARN cmd_trace +#undef FIXME +#define FIXME cmd_trace +#endif + #endif /* __CMD_PRECOMP_H */ diff --git a/base/shell/cmd/set.c b/base/shell/cmd/set.c index 1adf091ad84..7d026e31b43 100644 --- a/base/shell/cmd/set.c +++ b/base/shell/cmd/set.c @@ -175,6 +175,15 @@ INT cmd_set(LPTSTR param) } *p++ = _T('\0'); + +#ifdef FEATURE_DYNAMIC_TRACE + /* Check for dynamic TRACE ON/OFF */ + if (!_tcsicmp(param, _T("CMDTRACE"))) + { + g_bDynamicTracing = !_tcsicmp(p, _T("ON")); + } +#endif + if (!SetEnvironmentVariable(param, *p ? p : NULL)) { retval = 1;