[CONSRV]: Continuing code refactoring of revisions 63866, 63867, 63868 and 63874.
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Sun, 31 Aug 2014 14:04:03 +0000 (14:04 +0000)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Sun, 31 Aug 2014 14:04:03 +0000 (14:04 +0000)
svn path=/branches/condrv_restructure/; revision=64011

13 files changed:
win32ss/user/winsrv/consrv/alias.c
win32ss/user/winsrv/consrv/condrv/console.c
win32ss/user/winsrv/consrv/coninput.c
win32ss/user/winsrv/consrv/conoutput.c
win32ss/user/winsrv/consrv/console.c
win32ss/user/winsrv/consrv/console.h
win32ss/user/winsrv/consrv/consrv.h
win32ss/user/winsrv/consrv/frontendctl.c
win32ss/user/winsrv/consrv/frontends/terminal.c
win32ss/user/winsrv/consrv/frontends/tui/tuiterm.c
win32ss/user/winsrv/consrv/include/conio.h
win32ss/user/winsrv/consrv/include/conio_winsrv.h
win32ss/user/winsrv/consrv/init.c

index 6c67ee8..273c097 100644 (file)
@@ -34,7 +34,7 @@ typedef struct _ALIAS_HEADER
 
 
 BOOLEAN
-ConvertInputAnsiToUnicode(PCONSOLE Console,
+ConvertInputAnsiToUnicode(PCONSRV_CONSOLE Console,
                           PVOID    Source,
                           USHORT   SourceLength,
                           // BOOLEAN  IsUnicode,
@@ -61,7 +61,7 @@ ConvertInputAnsiToUnicode(PCONSOLE Console,
 }
 
 BOOLEAN
-ConvertInputUnicodeToAnsi(PCONSOLE Console,
+ConvertInputUnicodeToAnsi(PCONSRV_CONSOLE Console,
                           PVOID    Source,
                           USHORT   SourceLength,
                           // BOOLEAN  IsAnsi,
index 6f229c4..b0e4ba7 100644 (file)
@@ -460,7 +460,6 @@ ConDrvDeleteConsole(IN PCONSOLE Console)
 
     /* Discard all entries in the input event queue */
     PurgeInputBuffer(Console);
-    if (Console->LineBuffer) ConsoleFreeHeap(Console->LineBuffer);
 
     /* Delete the last screen buffer */
     ConioDeleteScreenBuffer(Console->ActiveBuffer);
index 430ef9f..9faaf52 100644 (file)
@@ -158,7 +158,7 @@ ConDrvWriteConsoleInput(IN PCONSOLE Console,
                         IN ULONG NumEventsToWrite,
                         OUT PULONG NumEventsWritten OPTIONAL);
 static NTSTATUS
-ConioAddInputEvents(PCONSOLE Console,
+ConioAddInputEvents(PCONSRV_CONSOLE Console,
                     PINPUT_RECORD InputRecords, // InputEvent
                     ULONG NumEventsToWrite,
                     PULONG NumEventsWritten,
@@ -177,7 +177,7 @@ ConioAddInputEvents(PCONSOLE Console,
                                   // NumEventsWritten,
                                   // AppendToEnd);
 
-    Status = ConDrvWriteConsoleInput(Console,
+    Status = ConDrvWriteConsoleInput((PCONSOLE)Console,
                                      &Console->InputBuffer,
                                      AppendToEnd,
                                      InputRecords,
@@ -192,7 +192,7 @@ ConioAddInputEvents(PCONSOLE Console,
 
 /* FIXME: This function can be called by CONDRV, in ConioResizeBuffer() in text.c */
 NTSTATUS
-ConioProcessInputEvent(PCONSOLE Console,
+ConioProcessInputEvent(PCONSRV_CONSOLE Console,
                        PINPUT_RECORD InputEvent)
 {
     ULONG NumEventsWritten;
@@ -213,13 +213,14 @@ WaitBeforeReading(IN PGET_INPUT_INFO InputInfo,
     if (CreateWaitBlock)
     {
         PGET_INPUT_INFO CapturedInputInfo;
+        PCONSRV_CONSOLE Console = (PCONSRV_CONSOLE)InputInfo->InputBuffer->Header.Console;
 
         CapturedInputInfo = ConsoleAllocHeap(0, sizeof(GET_INPUT_INFO));
         if (!CapturedInputInfo) return STATUS_NO_MEMORY;
 
         RtlMoveMemory(CapturedInputInfo, InputInfo, sizeof(GET_INPUT_INFO));
 
-        if (!CsrCreateWait(&InputInfo->InputBuffer->Header.Console->ReadWaitQueue,
+        if (!CsrCreateWait(&Console->ReadWaitQueue,
                            WaitFunction,
                            InputInfo->CallingThread,
                            ApiMessage,
@@ -728,7 +729,7 @@ CSR_API(SrvWriteConsoleInput)
 
     /* Now, add the events */
     NumEventsWritten = 0;
-    Status = ConioAddInputEvents(InputBuffer->Header.Console,
+    Status = ConioAddInputEvents((PCONSRV_CONSOLE)InputBuffer->Header.Console,
                                  // InputBuffer,
                                  InputRecord,
                                  WriteInputRequest->NumRecords,
index ab911f7..4c73eb1 100644 (file)
@@ -252,7 +252,7 @@ CSR_API(SrvCreateConsoleScreenBuffer)
     }
 
     Status = ConDrvCreateScreenBuffer(&Buff,
-                                      Console,
+                                      (PCONSOLE)Console,
                                       CreateScreenBufferRequest->ScreenBufferType,
                                       ScreenBufferInfo);
     if (!NT_SUCCESS(Status)) goto Quit;
@@ -417,7 +417,9 @@ DoWriteConsole(IN PCSR_API_MESSAGE ApiMessage,
     {
         if (CreateWaitBlock)
         {
-            if (!CsrCreateWait(&ScreenBuffer->Header.Console->WriteWaitQueue,
+            PCONSRV_CONSOLE Console = (PCONSRV_CONSOLE)ScreenBuffer->Header.Console;
+
+            if (!CsrCreateWait(&Console->WriteWaitQueue,
                                WriteConsoleThread,
                                ClientThread,
                                ApiMessage,
index 347caf6..25d4c71 100644 (file)
@@ -473,6 +473,9 @@ ConSrvDeleteConsole(PCONSRV_CONSOLE Console)
     /* Remove the console from the list */
     RemoveConsoleByPointer(Console);
 
+    /* Clean the Input Line Discipline */
+    if (Console->LineBuffer) ConsoleFreeHeap(Console->LineBuffer);
+
     /* Clean aliases and history */
     IntDeleteAllAliases(Console);
     HistoryDeleteBuffers(Console);
index a63754e..c70341c 100644 (file)
@@ -13,22 +13,22 @@ ConSrvInitConsoleSupport(VOID);
 
 NTSTATUS NTAPI
 ConSrvInitConsole(OUT PHANDLE NewConsoleHandle,
-                  OUT struct _CONSOLE** /* PCONSOLE* */ NewConsole,
+                  OUT struct _CONSRV_CONSOLE** /* PCONSRV_CONSOLE* */ NewConsole,
                   IN OUT PCONSOLE_START_INFO ConsoleStartInfo,
                   IN ULONG ConsoleLeaderProcessId);
-VOID NTAPI ConSrvDeleteConsole(struct _CONSOLE* /* PCONSOLE */ Console);
+VOID NTAPI ConSrvDeleteConsole(struct _CONSRV_CONSOLE* /* PCONSRV_CONSOLE */ Console);
 
 NTSTATUS
 ConSrvGetConsole(IN PCONSOLE_PROCESS_DATA ProcessData,
-                 OUT struct _CONSOLE** /* PCONSOLE* */ Console,
+                 OUT struct _CONSRV_CONSOLE** /* PCONSRV_CONSOLE* */ Console,
                  IN BOOLEAN LockConsole);
 VOID
-ConSrvReleaseConsole(IN struct _CONSOLE* /* PCONSOLE */ Console,
+ConSrvReleaseConsole(IN struct _CONSRV_CONSOLE* /* PCONSRV_CONSOLE */ Console,
                      IN BOOLEAN WasConsoleLocked);
 
 
 BOOLEAN NTAPI
-ConSrvValidateConsole(OUT struct _CONSOLE** /* PCONSOLE* */ Console,
+ConSrvValidateConsole(OUT struct _CONSRV_CONSOLE** /* PCONSRV_CONSOLE* */ Console,
                       IN HANDLE ConsoleHandle,
                       IN CONSOLE_STATE ExpectedState,
                       IN BOOLEAN LockConsole);
index 2c9c1e7..18aabfb 100644 (file)
@@ -66,8 +66,16 @@ typedef struct _CONSOLE_PROCESS_DATA
     LPTHREAD_START_ROUTINE PropDispatcher; // We hold the property dialog handler there, till all the GUI thingie moves out from CSRSS.
 } CONSOLE_PROCESS_DATA, *PCONSOLE_PROCESS_DATA;
 
+
+// Helper for code refactoring
+// #define USE_NEW_CONSOLE_WAY
+
+#ifndef USE_NEW_CONSOLE_WAY
 #include "include/conio.h"
-// #include "include/conio_winsrv.h"
+#else
+#include "include/conio_winsrv.h"
+#endif
+
 #include "include/console.h"
 #include "include/settings.h"
 #include "include/term.h"
index 24bef40..865a98e 100644 (file)
@@ -143,7 +143,7 @@ CSR_API(SrvSetConsoleDisplayMode)
                                    TRUE);
     if (!NT_SUCCESS(Status)) return Status;
 
-    Console = Buff->Header.Console;
+    Console = (PCONSRV_CONSOLE)Buff->Header.Console;
 
     if (TermSetDisplayMode(Console, SetDisplayModeRequest->DisplayMode))
     {
@@ -163,14 +163,14 @@ CSR_API(SrvGetLargestConsoleWindowSize)
 {
     NTSTATUS Status;
     PCONSOLE_GETLARGESTWINDOWSIZE GetLargestWindowSizeRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetLargestWindowSizeRequest;
+    PCONSOLE /*PCONSRV_CONSOLE*/ Console;
     PCONSOLE_SCREEN_BUFFER Buff;
-    PCONSRV_CONSOLE Console;
 
     Status = ConSrvGetTextModeBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
-                                   GetLargestWindowSizeRequest->OutputHandle,
-                                   &Buff,
-                                   GENERIC_READ,
-                                   TRUE);
+                                     GetLargestWindowSizeRequest->OutputHandle,
+                                     &Buff,
+                                     GENERIC_READ,
+                                     TRUE);
     if (!NT_SUCCESS(Status)) return Status;
 
     Console = Buff->Header.Console;
@@ -184,7 +184,7 @@ CSR_API(SrvShowConsoleCursor)
 {
     NTSTATUS Status;
     PCONSOLE_SHOWCURSOR ShowCursorRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ShowCursorRequest;
-    PCONSRV_CONSOLE Console;
+    PCONSOLE /*PCONSRV_CONSOLE*/ Console;
     PCONSOLE_SCREEN_BUFFER Buff;
 
     Status = ConSrvGetScreenBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
@@ -220,7 +220,7 @@ CSR_API(SrvSetConsoleCursor)
                                      TRUE);
     if (!NT_SUCCESS(Status)) return Status;
 
-    Console = Buff->Header.Console;
+    Console = (PCONSRV_CONSOLE)Buff->Header.Console;
 
     Success = TermSetMouseCursor(Console, SetCursorRequest->CursorHandle);
 
@@ -242,7 +242,7 @@ CSR_API(SrvConsoleMenuControl)
                                    TRUE);
     if (!NT_SUCCESS(Status)) return Status;
 
-    Console = Buff->Header.Console;
+    Console = (PCONSRV_CONSOLE)Buff->Header.Console;
 
     MenuControlRequest->MenuHandle = TermMenuControl(Console,
                                                      MenuControlRequest->CmdIdLow,
@@ -275,7 +275,8 @@ CSR_API(SrvGetConsoleWindow)
     PCONSOLE_GETWINDOW GetWindowRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetWindowRequest;
     PCONSRV_CONSOLE Console;
 
-    Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console, TRUE);
+    Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
+                              &Console, TRUE);
     if (!NT_SUCCESS(Status)) return Status;
 
     GetWindowRequest->WindowHandle = TermGetConsoleWindowHandle(Console);
@@ -290,7 +291,8 @@ CSR_API(SrvSetConsoleIcon)
     PCONSOLE_SETICON SetIconRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetIconRequest;
     PCONSRV_CONSOLE Console;
 
-    Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console, TRUE);
+    Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
+                              &Console, TRUE);
     if (!NT_SUCCESS(Status)) return Status;
 
     Status = (TermChangeIcon(Console, SetIconRequest->IconHandle)
@@ -307,7 +309,8 @@ CSR_API(SrvGetConsoleSelectionInfo)
     PCONSOLE_GETSELECTIONINFO GetSelectionInfoRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetSelectionInfoRequest;
     PCONSRV_CONSOLE Console;
 
-    Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console, TRUE);
+    Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
+                              &Console, TRUE);
     if (!NT_SUCCESS(Status)) return Status;
 
     Status = (TermGetSelectionInfo(Console, &GetSelectionInfoRequest->Info)
index e2484c7..c617322 100644 (file)
@@ -260,7 +260,7 @@ ConSrvDeinitTerminal(IN OUT PTERMINAL Terminal)
 
 static NTSTATUS NTAPI
 ConSrvTermInitTerminal(IN OUT PTERMINAL This,
-                  IN PCONSOLE Console)
+                       IN PCONSOLE Console)
 {
     NTSTATUS Status;
     PFRONTEND FrontEnd = This->Data;
index 3e2bed7..d03cf22 100644 (file)
@@ -12,7 +12,7 @@
 #ifdef TUITERM_COMPILE
 
 #include "consrv.h"
-#include "include/conio.h"
+// #include "include/conio.h"
 #include "include/console.h"
 #include "include/settings.h"
 #include "tuiterm.h"
index ccf21a7..81a6f9f 100644 (file)
 
 #include "rect.h"
 
+// This is ALMOST a HACK!!!!!!!
+// Helpers for code refactoring
+#ifdef USE_NEW_CONSOLE_WAY
+
+#define _CONSRV_CONSOLE  _WINSRV_CONSOLE
+#define  CONSRV_CONSOLE   WINSRV_CONSOLE
+#define PCONSRV_CONSOLE  PWINSRV_CONSOLE
+
+#else
+
+#define _CONSRV_CONSOLE  _CONSOLE
+#define  CONSRV_CONSOLE   CONSOLE
+#define PCONSRV_CONSOLE  PCONSOLE
+
+#endif
+
 /* Default attributes */
 #define DEFAULT_SCREEN_ATTRIB   (FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED)
 #define DEFAULT_POPUP_ATTRIB    (FOREGROUND_BLUE | FOREGROUND_RED   | \
@@ -277,7 +293,9 @@ typedef enum _CONSOLE_STATE
 // HACK!!
 struct _CONSOLE;
 /* HACK: */ typedef struct _CONSOLE *PCONSOLE;
+#ifndef USE_NEW_CONSOLE_WAY
 #include "conio_winsrv.h"
+#endif
 
 typedef struct _CONSOLE
 {
@@ -285,7 +303,9 @@ typedef struct _CONSOLE
     LONG ReferenceCount;                    /* Is incremented each time a handle to something in the console (a screen-buffer or the input buffer of this console) gets referenced */
     CRITICAL_SECTION Lock;
 
+#ifndef USE_NEW_CONSOLE_WAY
     /**/WINSRV_CONSOLE;/**/ // HACK HACK!!
+#endif
 
     CONSOLE_STATE State;                    /* State of the console */
     TERMINAL TermIFace;                     /* Frontend-specific interface */
@@ -325,8 +345,8 @@ ConSrvConsoleCtrlEvent(IN ULONG CtrlEvent,
 
 /* conoutput.c */
 PCHAR_INFO ConioCoordToPointer(PTEXTMODE_SCREEN_BUFFER Buff, ULONG X, ULONG Y);
-VOID ConioDrawConsole(PCONSOLE Console);
-NTSTATUS ConioResizeBuffer(PCONSOLE Console,
+VOID ConioDrawConsole(PCONSOLE /*PCONSRV_CONSOLE*/ Console);
+NTSTATUS ConioResizeBuffer(PCONSOLE /*PCONSRV_CONSOLE*/ Console,
                            PTEXTMODE_SCREEN_BUFFER ScreenBuffer,
                            COORD Size);
 
index 30185ec..1291a57 100644 (file)
 
 // This is ALMOST a HACK!!!!!!!
 // Helpers for code refactoring
+#ifdef USE_NEW_CONSOLE_WAY
+
+#define _CONSRV_CONSOLE  _WINSRV_CONSOLE
+#define  CONSRV_CONSOLE   WINSRV_CONSOLE
+#define PCONSRV_CONSOLE  PWINSRV_CONSOLE
+
+#else
+
 #define _CONSRV_CONSOLE  _CONSOLE
 #define  CONSRV_CONSOLE   CONSOLE
 #define PCONSRV_CONSOLE  PCONSOLE
 
-// #define _CONSRV_CONSOLE  _WINSRV_CONSOLE
-// #define  CONSRV_CONSOLE   WINSRV_CONSOLE
-// #define PCONSRV_CONSOLE  PWINSRV_CONSOLE
-
+#endif
 
 #define CSR_DEFAULT_CURSOR_SIZE 25
 
@@ -33,6 +38,12 @@ typedef struct _CHAR_CELL
 } CHAR_CELL, *PCHAR_CELL;
 C_ASSERT(sizeof(CHAR_CELL) == 2);
 
+// HACK!!
+struct _WINSRV_CONSOLE;
+/* HACK: */ typedef struct _WINSRV_CONSOLE *PWINSRV_CONSOLE;
+#ifdef USE_NEW_CONSOLE_WAY
+#include "conio.h"
+#endif
 
 typedef struct _FRONTEND FRONTEND, *PFRONTEND;
 /* HACK: */ typedef struct _CONSOLE_INFO *PCONSOLE_INFO;
@@ -118,8 +129,10 @@ typedef struct _WINSRV_CONSOLE
 {
 /******************************* Console Set-up *******************************/
     /* This **MUST** be FIRST!! */
-    // CONSOLE;
+#ifdef USE_NEW_CONSOLE_WAY
+    CONSOLE;
     // PCONSOLE Console;
+#endif
 
     // LONG ReferenceCount;                    /* Is incremented each time a handle to something in the console (a screen-buffer or the input buffer of this console) gets referenced */
     // CRITICAL_SECTION Lock;
@@ -172,7 +185,7 @@ typedef struct _WINSRV_CONSOLE
     LIST_ENTRY PopupWindows;                /*List of popup windows */
     COLORREF   Colors[16];                  /* Colour palette */
 
-} WINSRV_CONSOLE, *PWINSRV_CONSOLE;
+} WINSRV_CONSOLE; // , *PWINSRV_CONSOLE;
 
 /* console.c */
 VOID ConioPause(PCONSRV_CONSOLE Console, UINT Flags);
@@ -199,8 +212,8 @@ ConioProcessInputEvent(PCONSRV_CONSOLE Console,
 
 /* conoutput.c */
 PCHAR_INFO ConioCoordToPointer(PTEXTMODE_SCREEN_BUFFER Buff, ULONG X, ULONG Y);
-VOID ConioDrawConsole(PCONSRV_CONSOLE Console);
-NTSTATUS ConioResizeBuffer(PCONSRV_CONSOLE Console,
+VOID ConioDrawConsole(PCONSOLE /*PCONSRV_CONSOLE*/ Console);
+NTSTATUS ConioResizeBuffer(PCONSOLE /*PCONSRV_CONSOLE*/ Console,
                            PTEXTMODE_SCREEN_BUFFER ScreenBuffer,
                            COORD Size);
 
index 3f50c6b..db82eb9 100644 (file)
@@ -380,7 +380,7 @@ ConSrvNewProcess(PCSR_PROCESS SourceProcess,
     if (TargetProcessData->ConsoleApp /* && SourceProcessData->ConsoleApp */)
     {
         PCONSOLE_PROCESS_DATA SourceProcessData = ConsoleGetPerProcessData(SourceProcess);
-        PCONSOLE SourceConsole;
+        PCONSRV_CONSOLE SourceConsole;
 
         /* Validate and lock the parent's console */
         if (ConSrvValidateConsole(&SourceConsole,