From c1c76d279ea825c4f7bf917d2229141ca24fbbf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Delanoy?= Date: Mon, 29 Aug 2011 21:45:14 +0200 Subject: [PATCH] cmd: Add WCMD_output_asis_stderr function. --- programs/cmd/wcmd.h | 1 + programs/cmd/wcmdmain.c | 37 ++++++++++++++++++++++++++++--------- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/programs/cmd/wcmd.h b/programs/cmd/wcmd.h index 885add42aca..27d9d9a0d80 100644 --- a/programs/cmd/wcmd.h +++ b/programs/cmd/wcmd.h @@ -72,6 +72,7 @@ void WCMD_more (WCHAR *); void WCMD_move (void); void WCMD_output (const WCHAR *format, ...); void WCMD_output_asis (const WCHAR *message); +void WCMD_output_asis_stderr (const WCHAR *message); void WCMD_pause (void); void WCMD_popd (void); void WCMD_print_error (void); diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c index b282e998f86..ce07111f07b 100644 --- a/programs/cmd/wcmdmain.c +++ b/programs/cmd/wcmdmain.c @@ -240,13 +240,15 @@ BOOL WCMD_ReadFile(const HANDLE hIn, WCHAR *intoBuf, const DWORD maxChars, } /******************************************************************* - * WCMD_output_asis - send output to current standard output device. - * without formatting eg. when message contains '%' + * WCMD_output_asis_handle + * + * Send output to specified handle without formatting e.g. when message contains '%' */ -void WCMD_output_asis (const WCHAR *message) { +static void WCMD_output_asis_handle (DWORD std_handle, const WCHAR *message) { DWORD count; const WCHAR* ptr; WCHAR string[1024]; + HANDLE handle = GetStdHandle(std_handle); if (paged_mode) { do { @@ -256,25 +258,42 @@ void WCMD_output_asis (const WCHAR *message) { ptr++; }; if (*ptr == '\n') ptr++; - WCMD_output_asis_len(message, (ptr) ? ptr - message : strlenW(message), - GetStdHandle(STD_OUTPUT_HANDLE)); + WCMD_output_asis_len(message, (ptr) ? ptr - message : strlenW(message), handle); if (ptr) { numChars = 0; if (++line_count >= max_height - 1) { line_count = 0; - WCMD_output_asis_len(pagedMessage, strlenW(pagedMessage), - GetStdHandle(STD_OUTPUT_HANDLE)); + WCMD_output_asis_len(pagedMessage, strlenW(pagedMessage), handle); WCMD_ReadFile (GetStdHandle(STD_INPUT_HANDLE), string, sizeof(string)/sizeof(WCHAR), &count, NULL); } } } while (((message = ptr) != NULL) && (*ptr)); } else { - WCMD_output_asis_len(message, lstrlenW(message), - GetStdHandle(STD_OUTPUT_HANDLE)); + WCMD_output_asis_len(message, lstrlenW(message), handle); } } +/******************************************************************* + * WCMD_output_asis + * + * Send output to current standard output device, without formatting + * e.g. when message contains '%' + */ +void WCMD_output_asis (const WCHAR *message) { + WCMD_output_asis_handle(STD_OUTPUT_HANDLE, message); +} + +/******************************************************************* + * WCMD_output_asis_stderr + * + * Send output to current standard error device, without formatting + * e.g. when message contains '%' + */ +void WCMD_output_asis_stderr (const WCHAR *message) { + WCMD_output_asis_handle(STD_ERROR_HANDLE, message); +} + /**************************************************************************** * WCMD_print_error *