From abe58c387ac6be4e958d913efed42b53dbf210b6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Sun, 31 Aug 2014 11:24:23 +0000 Subject: [PATCH] [CONSRV]: Code cleaning. svn path=/branches/condrv_restructure/; revision=64005 --- win32ss/user/winsrv/consrv/condrv/coninput.c | 25 +++++++++++------- win32ss/user/winsrv/consrv/condrv/text.c | 26 ++++++++++++++----- win32ss/user/winsrv/consrv/coninput.c | 20 ++++++-------- win32ss/user/winsrv/consrv/include/conio.h | 15 ----------- .../user/winsrv/consrv/include/conio_winsrv.h | 15 ----------- 5 files changed, 43 insertions(+), 58 deletions(-) diff --git a/win32ss/user/winsrv/consrv/condrv/coninput.c b/win32ss/user/winsrv/consrv/condrv/coninput.c index 35d2dfcfabb..a28a20742c7 100644 --- a/win32ss/user/winsrv/consrv/condrv/coninput.c +++ b/win32ss/user/winsrv/consrv/condrv/coninput.c @@ -25,12 +25,13 @@ typedef struct ConsoleInput_t /* PRIVATE FUNCTIONS **********************************************************/ +// ConDrvAddInputEvents static NTSTATUS -ConDrvAddInputEvents(PCONSOLE Console, - PINPUT_RECORD InputRecords, // InputEvent - ULONG NumEventsToWrite, - PULONG NumEventsWritten, - BOOLEAN AppendToEnd) +AddInputEvents(PCONSOLE Console, + PINPUT_RECORD InputRecords, // InputEvent + ULONG NumEventsToWrite, + PULONG NumEventsWritten, + BOOLEAN AppendToEnd) { NTSTATUS Status = STATUS_SUCCESS; ULONG i = 0; @@ -288,6 +289,8 @@ ConDrvGetConsoleInput(IN PCONSOLE Console, ResetEvent(InputBuffer->ActiveEvent); } + // FIXME: If we add back UNICODE support, it's here that we need to do the translation. + /* We read all the inputs available, we return success */ return STATUS_SUCCESS; } @@ -310,11 +313,13 @@ ConDrvWriteConsoleInput(IN PCONSOLE Console, /* Now, add the events */ if (NumEventsWritten) *NumEventsWritten = 0; - return ConDrvAddInputEvents(Console, - InputRecord, - NumEventsToWrite, - NumEventsWritten, - AppendToEnd); + // FIXME: If we add back UNICODE support, it's here that we need to do the translation. + + return AddInputEvents(Console, + InputRecord, + NumEventsToWrite, + NumEventsWritten, + AppendToEnd); } NTSTATUS NTAPI diff --git a/win32ss/user/winsrv/consrv/condrv/text.c b/win32ss/user/winsrv/consrv/condrv/text.c index 179ff1aa25e..72e62c121af 100644 --- a/win32ss/user/winsrv/consrv/condrv/text.c +++ b/win32ss/user/winsrv/consrv/condrv/text.c @@ -16,6 +16,20 @@ /* GLOBALS ********************************************************************/ +/* + * From MSDN: + * "The lpMultiByteStr and lpWideCharStr pointers must not be the same. + * If they are the same, the function fails, and GetLastError returns + * ERROR_INVALID_PARAMETER." + */ +#define ConsoleOutputUnicodeToAnsiChar(Console, dChar, sWChar) \ + ASSERT((ULONG_PTR)dChar != (ULONG_PTR)sWChar); \ + WideCharToMultiByte((Console)->OutputCodePage, 0, (sWChar), 1, (dChar), 1, NULL, NULL) + +#define ConsoleOutputAnsiToUnicodeChar(Console, dWChar, sChar) \ + ASSERT((ULONG_PTR)dWChar != (ULONG_PTR)sChar); \ + MultiByteToWideChar((Console)->OutputCodePage, 0, (sChar), 1, (dWChar), 1) + /* PRIVATE FUNCTIONS **********************************************************/ CONSOLE_IO_OBJECT_TYPE @@ -500,7 +514,7 @@ ConDrvReadConsoleOutput(IN PCONSOLE Console, } else { - // ConsoleUnicodeCharToAnsiChar(Console, &CurCharInfo->Char.AsciiChar, &Ptr->Char.UnicodeChar); + // ConsoleOutputUnicodeToAnsiChar(Console, &CurCharInfo->Char.AsciiChar, &Ptr->Char.UnicodeChar); WideCharToMultiByte(Console->OutputCodePage, 0, &Ptr->Char.UnicodeChar, 1, &CurCharInfo->Char.AsciiChar, 1, NULL, NULL); } @@ -563,7 +577,7 @@ ConDrvWriteConsoleOutput(IN PCONSOLE Console, } else { - ConsoleAnsiCharToUnicodeChar(Console, &Ptr->Char.UnicodeChar, &CurCharInfo->Char.AsciiChar); + ConsoleOutputAnsiToUnicodeChar(Console, &Ptr->Char.UnicodeChar, &CurCharInfo->Char.AsciiChar); } Ptr->Attributes = CurCharInfo->Attributes; ++Ptr; @@ -626,7 +640,7 @@ ConDrvWriteConsoleOutputVDM(IN PCONSOLE Console, Ptr = ConioCoordToPointer(Buffer, CapturedWriteRegion.Left, Y); for (X = CapturedWriteRegion.Left; X <= CapturedWriteRegion.Right; ++X) { - ConsoleAnsiCharToUnicodeChar(Console, &Ptr->Char.UnicodeChar, &CurCharInfo->Char); + ConsoleOutputAnsiToUnicodeChar(Console, &Ptr->Char.UnicodeChar, &CurCharInfo->Char); Ptr->Attributes = CurCharInfo->Attributes; ++Ptr; ++CurCharInfo; @@ -787,7 +801,7 @@ ConDrvReadConsoleOutputString(IN PCONSOLE Console, switch (CodeType) { case CODE_ASCII: - ConsoleUnicodeCharToAnsiChar(Console, (PCHAR)ReadBuffer, &Ptr->Char.UnicodeChar); + ConsoleOutputUnicodeToAnsiChar(Console, (PCHAR)ReadBuffer, &Ptr->Char.UnicodeChar); break; case CODE_UNICODE: @@ -993,7 +1007,7 @@ ConDrvFillConsoleOutput(IN PCONSOLE Console, { /* Conversion from the ASCII char to the UNICODE char */ CODE_ELEMENT tmp; - ConsoleAnsiCharToUnicodeChar(Console, &tmp.UnicodeChar, &Code.AsciiChar); + ConsoleOutputAnsiToUnicodeChar(Console, &tmp.UnicodeChar, &Code.AsciiChar); Code = tmp; } @@ -1178,7 +1192,7 @@ ConDrvScrollConsoleScreenBuffer(IN PCONSOLE Console, if (!Unicode) { WCHAR tmp; - ConsoleAnsiCharToUnicodeChar(Console, &tmp, &FillChar.Char.AsciiChar); + ConsoleOutputAnsiToUnicodeChar(Console, &tmp, &FillChar.Char.AsciiChar); FillChar.Char.UnicodeChar = tmp; } diff --git a/win32ss/user/winsrv/consrv/coninput.c b/win32ss/user/winsrv/consrv/coninput.c index 247d72abc83..430ef9f744f 100644 --- a/win32ss/user/winsrv/consrv/coninput.c +++ b/win32ss/user/winsrv/consrv/coninput.c @@ -26,25 +26,21 @@ ConSrvReleaseObject(&(Buff)->Header, (IsConsoleLocked)) - - /* * From MSDN: * "The lpMultiByteStr and lpWideCharStr pointers must not be the same. * If they are the same, the function fails, and GetLastError returns * ERROR_INVALID_PARAMETER." */ -#define ConsoleInputUnicodeCharToAnsiChar(Console, dChar, sWChar) \ +#define ConsoleInputUnicodeToAnsiChar(Console, dChar, sWChar) \ ASSERT((ULONG_PTR)dChar != (ULONG_PTR)sWChar); \ WideCharToMultiByte((Console)->InputCodePage, 0, (sWChar), 1, (dChar), 1, NULL, NULL) -#define ConsoleInputAnsiCharToUnicodeChar(Console, dWChar, sChar) \ +#define ConsoleInputAnsiToUnicodeChar(Console, dWChar, sChar) \ ASSERT((ULONG_PTR)dWChar != (ULONG_PTR)sChar); \ MultiByteToWideChar((Console)->InputCodePage, 0, (sChar), 1, (dWChar), 1) - - typedef struct _GET_INPUT_INFO { PCSR_THREAD CallingThread; // The thread which called the input API. @@ -62,9 +58,9 @@ ConioInputEventToAnsi(PCONSOLE Console, PINPUT_RECORD InputEvent) { WCHAR UnicodeChar = InputEvent->Event.KeyEvent.uChar.UnicodeChar; InputEvent->Event.KeyEvent.uChar.UnicodeChar = 0; - ConsoleInputUnicodeCharToAnsiChar(Console, - &InputEvent->Event.KeyEvent.uChar.AsciiChar, - &UnicodeChar); + ConsoleInputUnicodeToAnsiChar(Console, + &InputEvent->Event.KeyEvent.uChar.AsciiChar, + &UnicodeChar); } } @@ -75,9 +71,9 @@ ConioInputEventToUnicode(PCONSOLE Console, PINPUT_RECORD InputEvent) { CHAR AsciiChar = InputEvent->Event.KeyEvent.uChar.AsciiChar; InputEvent->Event.KeyEvent.uChar.AsciiChar = 0; - ConsoleInputAnsiCharToUnicodeChar(Console, - &InputEvent->Event.KeyEvent.uChar.UnicodeChar, - &AsciiChar); + ConsoleInputAnsiToUnicodeChar(Console, + &InputEvent->Event.KeyEvent.uChar.UnicodeChar, + &AsciiChar); } } diff --git a/win32ss/user/winsrv/consrv/include/conio.h b/win32ss/user/winsrv/consrv/include/conio.h index da5554ccef1..b425fc99187 100644 --- a/win32ss/user/winsrv/consrv/include/conio.h +++ b/win32ss/user/winsrv/consrv/include/conio.h @@ -327,21 +327,6 @@ ConSrvConsoleCtrlEvent(IN ULONG CtrlEvent, IN PCONSOLE_PROCESS_DATA ProcessData); /* conoutput.c */ - -/* - * From MSDN: - * "The lpMultiByteStr and lpWideCharStr pointers must not be the same. - * If they are the same, the function fails, and GetLastError returns - * ERROR_INVALID_PARAMETER." - */ -#define ConsoleUnicodeCharToAnsiChar(Console, dChar, sWChar) \ - ASSERT((ULONG_PTR)dChar != (ULONG_PTR)sWChar); \ - WideCharToMultiByte((Console)->OutputCodePage, 0, (sWChar), 1, (dChar), 1, NULL, NULL) - -#define ConsoleAnsiCharToUnicodeChar(Console, dWChar, sChar) \ - ASSERT((ULONG_PTR)dWChar != (ULONG_PTR)sChar); \ - MultiByteToWideChar((Console)->OutputCodePage, 0, (sChar), 1, (dWChar), 1) - PCHAR_INFO ConioCoordToPointer(PTEXTMODE_SCREEN_BUFFER Buff, ULONG X, ULONG Y); VOID ConioDrawConsole(PCONSOLE Console); NTSTATUS ConioResizeBuffer(PCONSOLE Console, diff --git a/win32ss/user/winsrv/consrv/include/conio_winsrv.h b/win32ss/user/winsrv/consrv/include/conio_winsrv.h index 4b1904e7a12..e35306662ac 100644 --- a/win32ss/user/winsrv/consrv/include/conio_winsrv.h +++ b/win32ss/user/winsrv/consrv/include/conio_winsrv.h @@ -197,21 +197,6 @@ ConioProcessInputEvent(PCONSRV_CONSOLE Console, PINPUT_RECORD InputEvent); /* conoutput.c */ - -/* - * From MSDN: - * "The lpMultiByteStr and lpWideCharStr pointers must not be the same. - * If they are the same, the function fails, and GetLastError returns - * ERROR_INVALID_PARAMETER." - */ -#define ConsoleUnicodeCharToAnsiChar(Console, dChar, sWChar) \ - ASSERT((ULONG_PTR)dChar != (ULONG_PTR)sWChar); \ - WideCharToMultiByte((Console)->OutputCodePage, 0, (sWChar), 1, (dChar), 1, NULL, NULL) - -#define ConsoleAnsiCharToUnicodeChar(Console, dWChar, sChar) \ - ASSERT((ULONG_PTR)dWChar != (ULONG_PTR)sChar); \ - MultiByteToWideChar((Console)->OutputCodePage, 0, (sChar), 1, (dWChar), 1) - PCHAR_INFO ConioCoordToPointer(PTEXTMODE_SCREEN_BUFFER Buff, ULONG X, ULONG Y); VOID ConioDrawConsole(PCONSRV_CONSOLE Console); NTSTATUS ConioResizeBuffer(PCONSRV_CONSOLE Console, -- 2.17.1