[SACDRV]:

- Tabs vs. spaces fix;
- Less hardcoded values;
- Consistency in members names.

No functional changes.

svn path=/trunk/; revision=60642
This commit is contained in:
Hermès Bélusca-Maïto 2013-10-13 19:40:34 +00:00
parent 87bf71a722
commit e9b9e8be78
13 changed files with 417 additions and 421 deletions

View file

@ -6,11 +6,11 @@
* PROGRAMMERS: ReactOS Portable Systems Group * PROGRAMMERS: ReactOS Portable Systems Group
*/ */
/* INCLUDES ******************************************************************/ /* INCLUDES *******************************************************************/
#include "sacdrv.h" #include "sacdrv.h"
/* GLOBALS *******************************************************************/ /* GLOBALS ********************************************************************/
SAC_CHANNEL_LOCK ChannelCreateLock; SAC_CHANNEL_LOCK ChannelCreateLock;
BOOLEAN ChannelCreateEnabled; BOOLEAN ChannelCreateEnabled;
@ -21,7 +21,7 @@ SAC_CHANNEL_LOCK ChannelSlotLock[SAC_MAX_CHANNELS];
LONG CurrentChannelRefCount; LONG CurrentChannelRefCount;
KMUTEX CurrentChannelLock; KMUTEX CurrentChannelLock;
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS ******************************************************************/
#define MAX_REF_COUNT 100 #define MAX_REF_COUNT 100

View file

@ -6,13 +6,13 @@
* PROGRAMMERS: ReactOS Portable Systems Group * PROGRAMMERS: ReactOS Portable Systems Group
*/ */
/* INCLUDES ******************************************************************/ /* INCLUDES *******************************************************************/
#include "sacdrv.h" #include "sacdrv.h"
/* GLOBALS *******************************************************************/ /* GLOBALS ********************************************************************/
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS ******************************************************************/
BOOLEAN BOOLEAN
NTAPI NTAPI
@ -310,7 +310,7 @@ ChannelGetName(IN PSAC_CHANNEL Channel,
ChannelLockAttributes(Channel); ChannelLockAttributes(Channel);
/* Copy the name and null-terminate it */ /* Copy the name and null-terminate it */
ASSERT(((wcslen(Channel->NameBuffer) + 1) * sizeof(WCHAR)) <= ((64 + 1) * sizeof(WCHAR))); ASSERT(((wcslen(Channel->NameBuffer) + 1) * sizeof(WCHAR)) <= ((SAC_CHANNEL_NAME_SIZE + 1) * sizeof(WCHAR)));
wcsncpy(*Name, Channel->NameBuffer, RTL_NUMBER_OF(Channel->NameBuffer)); // bug wcsncpy(*Name, Channel->NameBuffer, RTL_NUMBER_OF(Channel->NameBuffer)); // bug
(*Name)[SAC_CHANNEL_NAME_SIZE] = UNICODE_NULL; (*Name)[SAC_CHANNEL_NAME_SIZE] = UNICODE_NULL;
@ -331,7 +331,7 @@ ChannelSetName(IN PSAC_CHANNEL Channel,
ChannelLockAttributes(Channel); ChannelLockAttributes(Channel);
/* Copy the name and null-terminate it */ /* Copy the name and null-terminate it */
ASSERT(((wcslen(Name) + 1) * sizeof(WCHAR)) <= ((64 + 1) * sizeof(WCHAR))); ASSERT(((wcslen(Name) + 1) * sizeof(WCHAR)) <= ((SAC_CHANNEL_NAME_SIZE + 1) * sizeof(WCHAR)));
wcsncpy(Channel->NameBuffer, Name, RTL_NUMBER_OF(Channel->NameBuffer)); // bug wcsncpy(Channel->NameBuffer, Name, RTL_NUMBER_OF(Channel->NameBuffer)); // bug
Channel->NameBuffer[SAC_CHANNEL_NAME_SIZE] = UNICODE_NULL; Channel->NameBuffer[SAC_CHANNEL_NAME_SIZE] = UNICODE_NULL;
@ -356,7 +356,7 @@ ChannelGetDescription(IN PSAC_CHANNEL Channel,
ChannelLockAttributes(Channel); ChannelLockAttributes(Channel);
/* Copy the name and null-terminate it */ /* Copy the name and null-terminate it */
ASSERT(((wcslen(Channel->DescriptionBuffer) + 1) * sizeof(WCHAR)) <= ((256 + 1) * sizeof(WCHAR))); ASSERT(((wcslen(Channel->DescriptionBuffer) + 1) * sizeof(WCHAR)) <= ((SAC_CHANNEL_DESCRIPTION_SIZE + 1) * sizeof(WCHAR)));
wcsncpy(*Description, Channel->DescriptionBuffer, RTL_NUMBER_OF(Channel->DescriptionBuffer)); // bug wcsncpy(*Description, Channel->DescriptionBuffer, RTL_NUMBER_OF(Channel->DescriptionBuffer)); // bug
(*Description)[SAC_CHANNEL_DESCRIPTION_SIZE] = UNICODE_NULL; (*Description)[SAC_CHANNEL_DESCRIPTION_SIZE] = UNICODE_NULL;
@ -377,7 +377,7 @@ ChannelSetDescription(IN PSAC_CHANNEL Channel,
ChannelLockAttributes(Channel); ChannelLockAttributes(Channel);
/* Copy the name and null-terminate it */ /* Copy the name and null-terminate it */
ASSERT(((wcslen(Description) + 1) * sizeof(WCHAR)) <= ((64 + 1) * sizeof(WCHAR))); ASSERT(((wcslen(Description) + 1) * sizeof(WCHAR)) <= ((SAC_CHANNEL_NAME_SIZE + 1) * sizeof(WCHAR)));
wcsncpy(Channel->DescriptionBuffer, Description, RTL_NUMBER_OF(Channel->DescriptionBuffer)); // bug wcsncpy(Channel->DescriptionBuffer, Description, RTL_NUMBER_OF(Channel->DescriptionBuffer)); // bug
Channel->DescriptionBuffer[SAC_CHANNEL_DESCRIPTION_SIZE] = UNICODE_NULL; Channel->DescriptionBuffer[SAC_CHANNEL_DESCRIPTION_SIZE] = UNICODE_NULL;

View file

@ -1,5 +1,5 @@
/* /*
* PROJECT: ReactOS Boot Loader * PROJECT: ReactOS Drivers
* LICENSE: BSD - See COPYING.ARM in the top level directory * LICENSE: BSD - See COPYING.ARM in the top level directory
* FILE: drivers/sac/driver/cmdchan.c * FILE: drivers/sac/driver/cmdchan.c
* PURPOSE: Driver for the Server Administration Console (SAC) for EMS * PURPOSE: Driver for the Server Administration Console (SAC) for EMS

View file

@ -6,16 +6,16 @@
* PROGRAMMERS: ReactOS Portable Systems Group * PROGRAMMERS: ReactOS Portable Systems Group
*/ */
/* INCLUDES ******************************************************************/ /* INCLUDES *******************************************************************/
#include "sacdrv.h" #include "sacdrv.h"
/* GLOBALS *******************************************************************/ /* GLOBALS ********************************************************************/
PVOID GlobalBuffer; PVOID GlobalBuffer;
ULONG GlobalBufferSize; ULONG GlobalBufferSize;
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS ******************************************************************/
NTSTATUS NTSTATUS
DoChannelListCommand( DoChannelListCommand(

View file

@ -6,11 +6,11 @@
* PROGRAMMERS: ReactOS Portable Systems Group * PROGRAMMERS: ReactOS Portable Systems Group
*/ */
/* INCLUDES ******************************************************************/ /* INCLUDES *******************************************************************/
#include "sacdrv.h" #include "sacdrv.h"
/* GLOBALS *******************************************************************/ /* GLOBALS ********************************************************************/
DEFINE_GUID(PRIMARY_SAC_CHANNEL_APPLICATION_GUID, DEFINE_GUID(PRIMARY_SAC_CHANNEL_APPLICATION_GUID,
0x63D02270, 0x63D02270,
@ -32,7 +32,7 @@ CHAR InputBuffer[80];
BOOLEAN GlobalPagingNeeded, GlobalDoThreads; BOOLEAN GlobalPagingNeeded, GlobalDoThreads;
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS ******************************************************************/
VOID VOID
NTAPI NTAPI

View file

@ -6,11 +6,11 @@
* PROGRAMMERS: ReactOS Portable Systems Group * PROGRAMMERS: ReactOS Portable Systems Group
*/ */
/* INCLUDES ******************************************************************/ /* INCLUDES *******************************************************************/
#include "sacdrv.h" #include "sacdrv.h"
/* GLOBALS *******************************************************************/ /* GLOBALS ********************************************************************/
ULONG SACDebug = 0xFFFFFFFF; ULONG SACDebug = 0xFFFFFFFF;
BOOLEAN CommandConsoleLaunchingEnabled; BOOLEAN CommandConsoleLaunchingEnabled;
@ -21,7 +21,7 @@ ULONG ProcessingType;
PKEVENT SACEvent; PKEVENT SACEvent;
HANDLE SACEventHandle; HANDLE SACEventHandle;
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS ******************************************************************/
VOID VOID
NTAPI NTAPI

View file

@ -6,15 +6,15 @@
* PROGRAMMERS: ReactOS Portable Systems Group * PROGRAMMERS: ReactOS Portable Systems Group
*/ */
/* INCLUDES ******************************************************************/ /* INCLUDES *******************************************************************/
#include "sacdrv.h" #include "sacdrv.h"
/* GLOBALS *******************************************************************/ /* GLOBALS ********************************************************************/
LONG TimerDpcCount; LONG TimerDpcCount;
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS ******************************************************************/
NTSTATUS NTSTATUS
NTAPI NTAPI

View file

@ -6,13 +6,13 @@
* PROGRAMMERS: ReactOS Portable Systems Group * PROGRAMMERS: ReactOS Portable Systems Group
*/ */
/* INCLUDES ******************************************************************/ /* INCLUDES *******************************************************************/
#include "sacdrv.h" #include "sacdrv.h"
/* GLOBALS *******************************************************************/ /* GLOBALS ********************************************************************/
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS ******************************************************************/
NTSTATUS NTSTATUS
NTAPI NTAPI

View file

@ -6,17 +6,17 @@
* PROGRAMMERS: ReactOS Portable Systems Group * PROGRAMMERS: ReactOS Portable Systems Group
*/ */
/* INCLUDES ******************************************************************/ /* INCLUDES *******************************************************************/
#include "sacdrv.h" #include "sacdrv.h"
/* GLOBALS *******************************************************************/ /* GLOBALS ********************************************************************/
LONG TotalFrees, TotalBytesFreed, TotalAllocations, TotalBytesAllocated; LONG TotalFrees, TotalBytesFreed, TotalAllocations, TotalBytesAllocated;
KSPIN_LOCK MemoryLock; KSPIN_LOCK MemoryLock;
PSAC_MEMORY_LIST GlobalMemoryList; PSAC_MEMORY_LIST GlobalMemoryList;
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS ******************************************************************/
BOOLEAN BOOLEAN
NTAPI NTAPI
@ -152,8 +152,7 @@ MyAllocatePool(IN SIZE_T PoolSize,
SAC_DBG(SAC_DBG_MM, "Allocating new space.\n"); SAC_DBG(SAC_DBG_MM, "Allocating new space.\n");
NewDescriptor = ExAllocatePoolWithTagPriority( NewDescriptor = ExAllocatePoolWithTagPriority(NonPagedPool,
0,
ActualSize, ActualSize,
ALLOC_BLOCK_TAG, ALLOC_BLOCK_TAG,
HighPoolPriority); HighPoolPriority);

View file

@ -6,13 +6,13 @@
* PROGRAMMERS: ReactOS Portable Systems Group * PROGRAMMERS: ReactOS Portable Systems Group
*/ */
/* INCLUDES ******************************************************************/ /* INCLUDES *******************************************************************/
#include "sacdrv.h" #include "sacdrv.h"
/* GLOBALS *******************************************************************/ /* GLOBALS ********************************************************************/
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS ******************************************************************/
NTSTATUS NTSTATUS
NTAPI NTAPI

View file

@ -6,7 +6,7 @@
* PROGRAMMERS: ReactOS Portable Systems Group * PROGRAMMERS: ReactOS Portable Systems Group
*/ */
/* INCLUDES ******************************************************************/ /* INCLUDES *******************************************************************/
#include <ntifs.h> #include <ntifs.h>
#include <intrin.h> #include <intrin.h>
@ -19,7 +19,7 @@
#include <initguid.h> #include <initguid.h>
#include <sacmsg.h> #include <sacmsg.h>
/* DEFINES *******************************************************************/ /* DEFINES ********************************************************************/
// //
// SAC Heap Allocator Macros // SAC Heap Allocator Macros
@ -177,11 +177,11 @@
#define SAC_CHANNEL_FLAG_APPLICATION 0x20 #define SAC_CHANNEL_FLAG_APPLICATION 0x20
// //
// Cursor Flags // Cell Flags
// //
#define SAC_CURSOR_FLAG_BLINK 1 #define SAC_CELL_FLAG_BLINK 1
#define SAC_CURSOR_FLAG_BOLD 2 #define SAC_CELL_FLAG_BOLD 2
#define SAC_CURSOR_FLAG_INVERTED 4 #define SAC_CELL_FLAG_INVERTED 4
// //
// Forward definitions // Forward definitions
@ -312,21 +312,21 @@ typedef struct _SAC_CHANNEL_LOCK
// //
// Structure of the cell-buffer when in VT-UTF8 Mode // Structure of the cell-buffer when in VT-UTF8 Mode
// //
typedef struct _SAC_CURSOR_DATA typedef struct _SAC_CELL_DATA
{ {
UCHAR CursorBackColor; UCHAR CellBackColor;
UCHAR CursorColor; UCHAR CellForeColor;
UCHAR CursorFlags; UCHAR CellFlags;
WCHAR CursorValue; WCHAR Char;
} SAC_CURSOR_DATA, *PSAC_CURSOR_DATA; } SAC_CELL_DATA, *PSAC_CELL_DATA;
C_ASSERT(sizeof(SAC_CURSOR_DATA) == 6); C_ASSERT(sizeof(SAC_CELL_DATA) == 6);
// //
// Screen buffer when in VT-UTF8 Mode // Screen buffer when in VT-UTF8 Mode
// //
typedef struct _SAC_VTUTF8_SCREEN typedef struct _SAC_VTUTF8_SCREEN
{ {
SAC_CURSOR_DATA Cell[SAC_VTUTF8_ROW_HEIGHT][SAC_VTUTF8_COL_WIDTH]; SAC_CELL_DATA Cell[SAC_VTUTF8_ROW_HEIGHT][SAC_VTUTF8_COL_WIDTH];
} SAC_VTUTF8_SCREEN, *PSAC_VTUTF8_SCREEN; } SAC_VTUTF8_SCREEN, *PSAC_VTUTF8_SCREEN;
// //
@ -453,9 +453,9 @@ typedef struct _SAC_CHANNEL
LONG ChannelHasNewIBufferData; LONG ChannelHasNewIBufferData;
UCHAR CursorRow; UCHAR CursorRow;
UCHAR CursorCol; UCHAR CursorCol;
UCHAR CursorColor; UCHAR CellForeColor;
UCHAR CursorBackColor; UCHAR CellBackColor;
UCHAR CursorFlags; UCHAR CellFlags;
PCHAR OBuffer; PCHAR OBuffer;
ULONG OBufferIndex; ULONG OBufferIndex;
ULONG OBufferFirstGoodIndex; ULONG OBufferFirstGoodIndex;
@ -479,8 +479,8 @@ typedef struct _SAC_CHANNEL
typedef struct _SAC_CHANNEL_ATTRIBUTES typedef struct _SAC_CHANNEL_ATTRIBUTES
{ {
SAC_CHANNEL_TYPE ChannelType; SAC_CHANNEL_TYPE ChannelType;
WCHAR NameBuffer[64 + 1]; WCHAR NameBuffer[SAC_CHANNEL_NAME_SIZE + 1];
WCHAR DescriptionBuffer[256 + 1]; WCHAR DescriptionBuffer[SAC_CHANNEL_DESCRIPTION_SIZE + 1];
ULONG Flag; ULONG Flag;
HANDLE CloseEvent; HANDLE CloseEvent;
HANDLE HasNewDataEvent; HANDLE HasNewDataEvent;

View file

@ -6,11 +6,11 @@
* PROGRAMMERS: ReactOS Portable Systems Group * PROGRAMMERS: ReactOS Portable Systems Group
*/ */
/* INCLUDES ******************************************************************/ /* INCLUDES *******************************************************************/
#include "sacdrv.h" #include "sacdrv.h"
/* GLOBALS *******************************************************************/ /* GLOBALS ********************************************************************/
PCHAR Utf8ConversionBuffer; PCHAR Utf8ConversionBuffer;
ULONG Utf8ConversionBufferSize = PAGE_SIZE; ULONG Utf8ConversionBufferSize = PAGE_SIZE;
@ -32,7 +32,7 @@ ULONG GlobalMessageTableCount;
LONG SerialPortConsumerIndex, SerialPortProducerIndex; LONG SerialPortConsumerIndex, SerialPortProducerIndex;
PCHAR SerialPortBuffer; PCHAR SerialPortBuffer;
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS ******************************************************************/
BOOLEAN BOOLEAN
NTAPI NTAPI

View file

@ -6,11 +6,11 @@
* PROGRAMMERS: ReactOS Portable Systems Group * PROGRAMMERS: ReactOS Portable Systems Group
*/ */
/* INCLUDES ******************************************************************/ /* INCLUDES *******************************************************************/
#include "sacdrv.h" #include "sacdrv.h"
/* GLOBALS *******************************************************************/ /* GLOBALS ********************************************************************/
CHAR IncomingUtf8ConversionBuffer[4]; CHAR IncomingUtf8ConversionBuffer[4];
WCHAR IncomingUnicodeValue; WCHAR IncomingUnicodeValue;
@ -30,7 +30,7 @@ SAC_STATIC_ESCAPE_STRING SacStaticEscapeStrings [] =
{ VT_ANSI_ERASE_ENTIRE_SCREEN, 3, SacEraseScreen }, { VT_ANSI_ERASE_ENTIRE_SCREEN, 3, SacEraseScreen },
}; };
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS ******************************************************************/
FORCEINLINE FORCEINLINE
VOID VOID
@ -114,7 +114,7 @@ VTUTF8ChannelAnsiDispatch(IN PSAC_CHANNEL Channel,
Tmp = LocalBuffer; Tmp = LocalBuffer;
break; break;
/* Send the [#;#H (Cursor Positio) sequence */ /* Send the [#;#H (Cursor Position) sequence */
case SacAnsiSetPosition: case SacAnsiSetPosition:
/* Allocate a small local buffer for it */ /* Allocate a small local buffer for it */
@ -203,7 +203,7 @@ VTUTF8ChannelProcessAttributes(IN PSAC_CHANNEL Channel,
/* Set bold if needed */ /* Set bold if needed */
Status = VTUTF8ChannelAnsiDispatch(Channel, Status = VTUTF8ChannelAnsiDispatch(Channel,
Attribute & SAC_CURSOR_FLAG_BOLD ? Attribute & SAC_CELL_FLAG_BOLD ?
SacAnsiSetBoldAttribute : SacAnsiSetBoldAttribute :
SacAnsiClearBoldAttribute, SacAnsiClearBoldAttribute,
NULL, NULL,
@ -212,7 +212,7 @@ VTUTF8ChannelProcessAttributes(IN PSAC_CHANNEL Channel,
/* Set blink if needed */ /* Set blink if needed */
Status = VTUTF8ChannelAnsiDispatch(Channel, Status = VTUTF8ChannelAnsiDispatch(Channel,
Attribute & SAC_CURSOR_FLAG_BLINK ? Attribute & SAC_CELL_FLAG_BLINK ?
SacAnsiSetBlinkAttribute : SacAnsiSetBlinkAttribute :
SacAnsiClearBlinkAttribute, SacAnsiClearBlinkAttribute,
NULL, NULL,
@ -221,7 +221,7 @@ VTUTF8ChannelProcessAttributes(IN PSAC_CHANNEL Channel,
/* Set inverse if needed */ /* Set inverse if needed */
return VTUTF8ChannelAnsiDispatch(Channel, return VTUTF8ChannelAnsiDispatch(Channel,
Attribute & SAC_CURSOR_FLAG_INVERTED ? Attribute & SAC_CELL_FLAG_INVERTED ?
SacAnsiSetInverseAttribute : SacAnsiSetInverseAttribute :
SacAnsiClearInverseAttribute, SacAnsiClearInverseAttribute,
NULL, NULL,
@ -244,7 +244,7 @@ VTUTF8ChannelConsumeEscapeSequence(IN PSAC_CHANNEL Channel,
{ {
ULONG Number, Number2, Number3, i, Action, Result; ULONG Number, Number2, Number3, i, Action, Result;
PWCHAR Sequence; PWCHAR Sequence;
PSAC_VTUTF8_SCREEN Cursor; PSAC_VTUTF8_SCREEN Screen;
ASSERT(String[0] == VT_ANSI_ESCAPE); ASSERT(String[0] == VT_ANSI_ESCAPE);
/* Microsoft's driver does this after the O(n) check below. Be smarter. */ /* Microsoft's driver does this after the O(n) check below. Be smarter. */
@ -441,7 +441,7 @@ ProcessString:
if (!Result) Result = Sequence - String + 1; if (!Result) Result = Sequence - String + 1;
/* Get the current cell buffer */ /* Get the current cell buffer */
Cursor = (PSAC_VTUTF8_SCREEN)Channel->OBuffer; Screen = (PSAC_VTUTF8_SCREEN)Channel->OBuffer;
VTUTF8ChannelAssertCursor(Channel); VTUTF8ChannelAssertCursor(Channel);
/* Handle all the supported SAC ANSI commands */ /* Handle all the supported SAC ANSI commands */
@ -516,40 +516,40 @@ ProcessString:
break; break;
case SacFontNormal: case SacFontNormal:
/* Reset the cursor attributes */ /* Reset the cell attributes */
Channel->CursorFlags = 0; Channel->CellFlags = 0;
Channel->CursorBackColor = SetBackColorBlack; Channel->CellBackColor = SetBackColorBlack;
Channel->CursorColor = SetColorWhite; Channel->CellForeColor = SetColorWhite;
break; break;
case SacFontBlink: case SacFontBlink:
/* Set the appropriate flag */ /* Set the appropriate flag */
Channel->CursorFlags |= SAC_CURSOR_FLAG_BLINK; Channel->CellFlags |= SAC_CELL_FLAG_BLINK;
break; break;
case SacFontBlinkOff: case SacFontBlinkOff:
/* Clear the appropriate flag */ /* Clear the appropriate flag */
Channel->CursorFlags &= ~SAC_CURSOR_FLAG_BLINK; Channel->CellFlags &= ~SAC_CELL_FLAG_BLINK;
break; break;
case SacFontBold: case SacFontBold:
/* Set the appropriate flag */ /* Set the appropriate flag */
Channel->CursorFlags |= SAC_CURSOR_FLAG_BOLD; Channel->CellFlags |= SAC_CELL_FLAG_BOLD;
break; break;
case SacFontBoldOff: case SacFontBoldOff:
/* Clear the appropriate flag */ /* Clear the appropriate flag */
Channel->CursorFlags &= ~SAC_CURSOR_FLAG_BOLD; Channel->CellFlags &= ~SAC_CELL_FLAG_BOLD;
break; break;
case SacFontInverse: case SacFontInverse:
/* Set the appropriate flag */ /* Set the appropriate flag */
Channel->CursorFlags |= SAC_CURSOR_FLAG_INVERTED; Channel->CellFlags |= SAC_CELL_FLAG_INVERTED;
break; break;
case SacFontInverseOff: case SacFontInverseOff:
/* Clear the appropriate flag */ /* Clear the appropriate flag */
Channel->CursorFlags &= ~SAC_CURSOR_FLAG_INVERTED; Channel->CellFlags &= ~SAC_CELL_FLAG_INVERTED;
break; break;
case SacEraseEndOfLine: case SacEraseEndOfLine:
@ -557,10 +557,10 @@ ProcessString:
for (i = Channel->CursorCol; i < SAC_VTUTF8_COL_WIDTH; i++) for (i = Channel->CursorCol; i < SAC_VTUTF8_COL_WIDTH; i++)
{ {
/* Replace everything after the current position with blanks */ /* Replace everything after the current position with blanks */
Cursor->Cell[Channel->CursorRow][i].CursorFlags = Channel->CursorFlags; Screen->Cell[Channel->CursorRow][i].CellFlags = Channel->CellFlags;
Cursor->Cell[Channel->CursorRow][i].CursorBackColor = Channel->CursorColor; Screen->Cell[Channel->CursorRow][i].CellBackColor = Channel->CellForeColor;
Cursor->Cell[Channel->CursorRow][i].CursorColor = Channel->CursorBackColor; Screen->Cell[Channel->CursorRow][i].CellForeColor = Channel->CellBackColor;
Cursor->Cell[Channel->CursorRow][i].CursorValue = ' '; Screen->Cell[Channel->CursorRow][i].Char = L' ';
} }
break; break;
@ -569,10 +569,10 @@ ProcessString:
for (i = 0; i < (Channel->CursorCol + 1); i++) for (i = 0; i < (Channel->CursorCol + 1); i++)
{ {
/* Replace everything after the current position with blanks */ /* Replace everything after the current position with blanks */
Cursor->Cell[Channel->CursorRow][i].CursorFlags = Channel->CursorFlags; Screen->Cell[Channel->CursorRow][i].CellFlags = Channel->CellFlags;
Cursor->Cell[Channel->CursorRow][i].CursorBackColor = Channel->CursorColor; Screen->Cell[Channel->CursorRow][i].CellBackColor = Channel->CellForeColor;
Cursor->Cell[Channel->CursorRow][i].CursorColor = Channel->CursorBackColor; Screen->Cell[Channel->CursorRow][i].CellForeColor = Channel->CellBackColor;
Cursor->Cell[Channel->CursorRow][i].CursorValue = ' '; Screen->Cell[Channel->CursorRow][i].Char = L' ';
} }
break; break;
@ -581,10 +581,10 @@ ProcessString:
for (i = 0; i < SAC_VTUTF8_COL_WIDTH; i++) for (i = 0; i < SAC_VTUTF8_COL_WIDTH; i++)
{ {
/* Replace them all with blanks */ /* Replace them all with blanks */
Cursor->Cell[Channel->CursorRow][i].CursorFlags = Channel->CursorFlags; Screen->Cell[Channel->CursorRow][i].CellFlags = Channel->CellFlags;
Cursor->Cell[Channel->CursorRow][i].CursorBackColor = Channel->CursorColor; Screen->Cell[Channel->CursorRow][i].CellBackColor = Channel->CellForeColor;
Cursor->Cell[Channel->CursorRow][i].CursorColor = Channel->CursorBackColor; Screen->Cell[Channel->CursorRow][i].CellForeColor = Channel->CellBackColor;
Cursor->Cell[Channel->CursorRow][i].CursorValue = ' '; Screen->Cell[Channel->CursorRow][i].Char = L' ';
} }
break; break;
@ -609,26 +609,26 @@ ProcessString:
break; break;
case SacSetColors: case SacSetColors:
/* Set the cursor colors */ /* Set the cell colors */
Channel->CursorColor = Number; Channel->CellForeColor = Number;
Channel->CursorBackColor = Number2; Channel->CellBackColor = Number2;
break; break;
case SacSetBackgroundColor: case SacSetBackgroundColor:
/* Set the cursor back color */ /* Set the cell back color */
Channel->CursorBackColor = Number; Channel->CellBackColor = Number;
break; break;
case SacSetFontColor: case SacSetFontColor:
/* Set the cursor text color */ /* Set the cell text color */
Channel->CursorColor = Number; Channel->CellForeColor = Number;
break; break;
case SacSetColorsAndAttributes: case SacSetColorsAndAttributes:
/* Set the cursor flag and colors */ /* Set the cell flag and colors */
Channel->CursorFlags = Number; Channel->CellFlags = Number;
Channel->CursorColor = Number2; Channel->CellForeColor = Number2;
Channel->CursorBackColor = Number3; Channel->CellBackColor = Number3;
break; break;
default: default:
@ -644,32 +644,29 @@ NTSTATUS
NTAPI NTAPI
VTUTF8ChannelOInit(IN PSAC_CHANNEL Channel) VTUTF8ChannelOInit(IN PSAC_CHANNEL Channel)
{ {
PSAC_CURSOR_DATA Cursor; PSAC_VTUTF8_SCREEN Screen;
ULONG x, y; ULONG R, C;
CHECK_PARAMETER(Channel); CHECK_PARAMETER(Channel);
/* Set the current channel cursor parameters */ /* Set the current channel cell parameters */
Channel->CursorFlags = 0; Channel->CellFlags = 0;
Channel->CursorBackColor = SetBackColorBlack; Channel->CellBackColor = SetBackColorBlack;
Channel->CursorColor = SetColorWhite; Channel->CellForeColor = SetColorWhite;
/* Set the cell buffer position */
Screen = (PSAC_VTUTF8_SCREEN)Channel->OBuffer;
/* Loop the output buffer height by width */ /* Loop the output buffer height by width */
Cursor = (PSAC_CURSOR_DATA)Channel->OBuffer; for (R = 0; R < SAC_VTUTF8_ROW_HEIGHT; R++)
y = SAC_VTUTF8_ROW_HEIGHT;
do
{ {
x = SAC_VTUTF8_COL_WIDTH; for (C = 0; C < SAC_VTUTF8_COL_WIDTH; C++)
do
{ {
/* For every character, set the defaults */ /* For every character, set the defaults */
Cursor->CursorValue = ' '; Screen->Cell[R][C].Char = L' ';
Cursor->CursorBackColor = SetBackColorBlack; Screen->Cell[R][C].CellBackColor = SetBackColorBlack;
Cursor->CursorColor = SetColorWhite; Screen->Cell[R][C].CellForeColor = SetColorWhite;
}
/* Move to the next character */ }
Cursor++;
} while (--x);
} while (--y);
/* All done */ /* All done */
return STATUS_SUCCESS; return STATUS_SUCCESS;
@ -728,7 +725,7 @@ NTAPI
VTUTF8ChannelOFlush(IN PSAC_CHANNEL Channel) VTUTF8ChannelOFlush(IN PSAC_CHANNEL Channel)
{ {
NTSTATUS Status; NTSTATUS Status;
PSAC_VTUTF8_SCREEN Cursor; PSAC_VTUTF8_SCREEN Screen;
INT Color[2], Position[2]; INT Color[2], Position[2];
ULONG Utf8ProcessedCount, Utf8Count, R, C, ForeColor, BackColor, Attribute; ULONG Utf8ProcessedCount, Utf8Count, R, C, ForeColor, BackColor, Attribute;
PWCHAR TmpBuffer; PWCHAR TmpBuffer;
@ -736,7 +733,7 @@ VTUTF8ChannelOFlush(IN PSAC_CHANNEL Channel)
CHECK_PARAMETER(Channel); CHECK_PARAMETER(Channel);
/* Set the cell buffer position */ /* Set the cell buffer position */
Cursor = (PSAC_VTUTF8_SCREEN)Channel->OBuffer; Screen = (PSAC_VTUTF8_SCREEN)Channel->OBuffer;
/* Allocate a temporary buffer */ /* Allocate a temporary buffer */
TmpBuffer = SacAllocatePool(40, GLOBAL_BLOCK_TAG); TmpBuffer = SacAllocatePool(40, GLOBAL_BLOCK_TAG);
@ -769,14 +766,14 @@ VTUTF8ChannelOFlush(IN PSAC_CHANNEL Channel)
0); 0);
if (!NT_SUCCESS(Status)) goto Quickie; if (!NT_SUCCESS(Status)) goto Quickie;
/* Now set the current cursor attributes */ /* Now set the current cell attributes */
Attribute = Channel->CursorFlags; Attribute = Channel->CellFlags;
Status = VTUTF8ChannelProcessAttributes(Channel, Attribute); Status = VTUTF8ChannelProcessAttributes(Channel, Attribute);
if (!NT_SUCCESS(Status)) goto Quickie; if (!NT_SUCCESS(Status)) goto Quickie;
/* And set the current cursor colors */ /* And set the current cell colors */
ForeColor = Channel->CursorColor; ForeColor = Channel->CellForeColor;
BackColor = Channel->CursorBackColor; BackColor = Channel->CellBackColor;
Color[1] = BackColor; Color[1] = BackColor;
Color[0] = ForeColor; Color[0] = ForeColor;
Status = VTUTF8ChannelAnsiDispatch(Channel, Status = VTUTF8ChannelAnsiDispatch(Channel,
@ -788,12 +785,12 @@ VTUTF8ChannelOFlush(IN PSAC_CHANNEL Channel)
/* Now loop all the characters in the cell buffer */ /* Now loop all the characters in the cell buffer */
for (R = 0; R < SAC_VTUTF8_ROW_HEIGHT; R++) for (R = 0; R < SAC_VTUTF8_ROW_HEIGHT; R++)
{ {
/* Accross every row */ /* Across every row */
for (C = 0; C < SAC_VTUTF8_COL_WIDTH; C++) for (C = 0; C < SAC_VTUTF8_COL_WIDTH; C++)
{ {
/* Check if there's been a change in colors */ /* Check if there's been a change in colors */
if ((Cursor->Cell[R][C].CursorBackColor != BackColor) || if ((Screen->Cell[R][C].CellBackColor != BackColor) ||
(Cursor->Cell[R][C].CursorColor != ForeColor)) (Screen->Cell[R][C].CellForeColor != ForeColor))
{ {
/* New colors are being drawn -- are we also on a new row now? */ /* New colors are being drawn -- are we also on a new row now? */
if (Overflow) if (Overflow)
@ -810,8 +807,8 @@ VTUTF8ChannelOFlush(IN PSAC_CHANNEL Channel)
} }
/* Cache the new colors */ /* Cache the new colors */
ForeColor = Cursor->Cell[R][C].CursorColor; ForeColor = Screen->Cell[R][C].CellForeColor;
BackColor = Cursor->Cell[R][C].CursorBackColor; BackColor = Screen->Cell[R][C].CellBackColor;
/* Set them on the screen */ /* Set them on the screen */
Color[1] = BackColor; Color[1] = BackColor;
@ -824,7 +821,7 @@ VTUTF8ChannelOFlush(IN PSAC_CHANNEL Channel)
} }
/* Check if there's been a change in attributes */ /* Check if there's been a change in attributes */
if (Cursor->Cell[R][C].CursorFlags != Attribute) if (Screen->Cell[R][C].CellFlags != Attribute)
{ {
/* Yep! Are we also on a new row now? */ /* Yep! Are we also on a new row now? */
if (Overflow) if (Overflow)
@ -841,7 +838,7 @@ VTUTF8ChannelOFlush(IN PSAC_CHANNEL Channel)
} }
/* Set the new attributes on screen */ /* Set the new attributes on screen */
Attribute = Cursor->Cell[R][C].CursorFlags; Attribute = Screen->Cell[R][C].CellFlags;
Status = VTUTF8ChannelProcessAttributes(Channel, Attribute); Status = VTUTF8ChannelProcessAttributes(Channel, Attribute);
if (!NT_SUCCESS(Status)) goto Quickie; if (!NT_SUCCESS(Status)) goto Quickie;
} }
@ -861,7 +858,7 @@ VTUTF8ChannelOFlush(IN PSAC_CHANNEL Channel)
} }
/* Write the character into our temporary buffer */ /* Write the character into our temporary buffer */
*TmpBuffer = Cursor->Cell[R][C].CursorValue; *TmpBuffer = Screen->Cell[R][C].Char;
TmpBuffer[1] = UNICODE_NULL; TmpBuffer[1] = UNICODE_NULL;
/* Convert it to UTF-8 */ /* Convert it to UTF-8 */
@ -900,12 +897,12 @@ VTUTF8ChannelOFlush(IN PSAC_CHANNEL Channel)
if (!NT_SUCCESS(Status)) goto Quickie; if (!NT_SUCCESS(Status)) goto Quickie;
/* Set the current attribute one last time */ /* Set the current attribute one last time */
Status = VTUTF8ChannelProcessAttributes(Channel, Channel->CursorFlags); Status = VTUTF8ChannelProcessAttributes(Channel, Channel->CellFlags);
if (!NT_SUCCESS(Status)) goto Quickie; if (!NT_SUCCESS(Status)) goto Quickie;
/* Set the current colors one last time */ /* Set the current colors one last time */
Color[1] = Channel->CursorBackColor; Color[1] = Channel->CellBackColor;
Color[0] = Channel->CursorColor; Color[0] = Channel->CellForeColor;
Status = VTUTF8ChannelAnsiDispatch(Channel, Status = VTUTF8ChannelAnsiDispatch(Channel,
SacAnsiSetColors, SacAnsiSetColors,
Color, Color,
@ -935,7 +932,7 @@ VTUTF8ChannelOWrite2(IN PSAC_CHANNEL Channel,
IN PWCHAR String, IN PWCHAR String,
IN ULONG Size) IN ULONG Size)
{ {
PSAC_VTUTF8_SCREEN Cursor; PSAC_VTUTF8_SCREEN Screen;
ULONG i, EscapeSize, R, C; ULONG i, EscapeSize, R, C;
PWSTR pwch; PWSTR pwch;
CHECK_PARAMETER1(Channel); CHECK_PARAMETER1(Channel);
@ -943,7 +940,7 @@ VTUTF8ChannelOWrite2(IN PSAC_CHANNEL Channel,
VTUTF8ChannelAssertCursor(Channel); VTUTF8ChannelAssertCursor(Channel);
/* Loop every character */ /* Loop every character */
Cursor = (PSAC_VTUTF8_SCREEN) Channel->OBuffer; Screen = (PSAC_VTUTF8_SCREEN)Channel->OBuffer;
for (i = 0; i < Size; i++) for (i = 0; i < Size; i++)
{ {
/* Check what the character is */ /* Check what the character is */
@ -995,13 +992,13 @@ VTUTF8ChannelOWrite2(IN PSAC_CHANNEL Channel,
for (C = 0; C < SAC_VTUTF8_COL_WIDTH; C++) for (C = 0; C < SAC_VTUTF8_COL_WIDTH; C++)
{ {
/* And replace it with one from the row below */ /* And replace it with one from the row below */
Cursor->Cell[R][C] = Cursor->Cell[R + 1][C]; Screen->Cell[R][C] = Screen->Cell[R + 1][C];
} }
} }
/* Now we're left with the before-last row, zero it out */ /* Now we're left with the before-last row, zero it out */
ASSERT(R == (SAC_VTUTF8_ROW_HEIGHT - 1)); ASSERT(R == (SAC_VTUTF8_ROW_HEIGHT - 1));
RtlZeroMemory(&Cursor->Cell[R], sizeof(Cursor->Cell[R])); RtlZeroMemory(&Screen->Cell[R], sizeof(Screen->Cell[R]));
/* Reset the row back by one */ /* Reset the row back by one */
Channel->CursorRow--; Channel->CursorRow--;
@ -1018,10 +1015,10 @@ VTUTF8ChannelOWrite2(IN PSAC_CHANNEL Channel,
{ {
/* Fill each remaining character with a space */ /* Fill each remaining character with a space */
VTUTF8ChannelAssertCursor(Channel); VTUTF8ChannelAssertCursor(Channel);
Cursor->Cell[Channel->CursorRow][Channel->CursorCol].CursorFlags = Channel->CursorFlags; Screen->Cell[Channel->CursorRow][Channel->CursorCol].CellFlags = Channel->CellFlags;
Cursor->Cell[Channel->CursorRow][Channel->CursorCol].CursorBackColor = Channel->CursorBackColor; Screen->Cell[Channel->CursorRow][Channel->CursorCol].CellBackColor = Channel->CellBackColor;
Cursor->Cell[Channel->CursorRow][Channel->CursorCol].CursorColor = Channel->CursorColor; Screen->Cell[Channel->CursorRow][Channel->CursorCol].CellForeColor = Channel->CellForeColor;
Cursor->Cell[Channel->CursorRow][Channel->CursorCol].CursorValue = ' '; Screen->Cell[Channel->CursorRow][Channel->CursorCol].Char = L' ';
/* Move to the next character position, but don't overflow */ /* Move to the next character position, but don't overflow */
Channel->CursorCol++; Channel->CursorCol++;
@ -1052,10 +1049,10 @@ VTUTF8ChannelOWrite2(IN PSAC_CHANNEL Channel,
/* Otherwise, print it out with the current attributes */ /* Otherwise, print it out with the current attributes */
VTUTF8ChannelAssertCursor(Channel); VTUTF8ChannelAssertCursor(Channel);
Cursor->Cell[Channel->CursorRow][Channel->CursorCol].CursorFlags = Channel->CursorFlags; Screen->Cell[Channel->CursorRow][Channel->CursorCol].CellFlags = Channel->CellFlags;
Cursor->Cell[Channel->CursorRow][Channel->CursorCol].CursorBackColor = Channel->CursorBackColor; Screen->Cell[Channel->CursorRow][Channel->CursorCol].CellBackColor = Channel->CellBackColor;
Cursor->Cell[Channel->CursorRow][Channel->CursorCol].CursorColor = Channel->CursorColor; Screen->Cell[Channel->CursorRow][Channel->CursorCol].CellForeColor = Channel->CellForeColor;
Cursor->Cell[Channel->CursorRow][Channel->CursorCol].CursorValue = *pwch; Screen->Cell[Channel->CursorRow][Channel->CursorCol].Char = *pwch;
/* Move forward one character, but make sure not to overflow */ /* Move forward one character, but make sure not to overflow */
Channel->CursorCol++; Channel->CursorCol++;