[KERNEL32][CONSRV]
[reactos.git] / reactos / win32ss / user / winsrv / consrv / coninput.c
index 7143a32..ee383d7 100644 (file)
@@ -11,7 +11,7 @@
 
 #include "consrv.h"
 #include "include/conio.h"
-#include "include/conio2.h"
+#include "include/term.h"
 #include "handle.h"
 #include "lineinput.h"
 
@@ -45,7 +45,7 @@ static NTSTATUS
 WaitBeforeReading(IN PGET_INPUT_INFO InputInfo,
                   IN PCSR_API_MESSAGE ApiMessage,
                   IN CSR_WAIT_FUNCTION WaitFunction OPTIONAL,
-                  IN BOOL CreateWaitBlock OPTIONAL)
+                  IN BOOLEAN CreateWaitBlock OPTIONAL)
 {
     if (CreateWaitBlock)
     {
@@ -60,8 +60,7 @@ WaitBeforeReading(IN PGET_INPUT_INFO InputInfo,
                            WaitFunction,
                            InputInfo->CallingThread,
                            ApiMessage,
-                           CapturedInputInfo,
-                           NULL))
+                           CapturedInputInfo))
         {
             ConsoleFreeHeap(CapturedInputInfo);
             return STATUS_NO_MEMORY;
@@ -75,10 +74,11 @@ WaitBeforeReading(IN PGET_INPUT_INFO InputInfo,
 static NTSTATUS
 ReadChars(IN PGET_INPUT_INFO InputInfo,
           IN PCSR_API_MESSAGE ApiMessage,
-          IN BOOL CreateWaitBlock OPTIONAL);
+          IN BOOLEAN CreateWaitBlock OPTIONAL);
 
 // Wait function CSR_WAIT_FUNCTION
 static BOOLEAN
+NTAPI
 ReadCharsThread(IN PLIST_ENTRY WaitList,
                 IN PCSR_THREAD WaitThread,
                 IN PCSR_API_MESSAGE WaitApiMessage,
@@ -123,9 +123,7 @@ ReadCharsThread(IN PLIST_ENTRY WaitList,
      * If we go there, that means we are notified for some new input.
      * The console is therefore already locked.
      */
-    Status = ReadChars(InputInfo,
-                       WaitApiMessage,
-                       FALSE);
+    Status = ReadChars(InputInfo, WaitApiMessage, FALSE);
 
 Quit:
     if (Status != STATUS_PENDING)
@@ -148,7 +146,7 @@ ConDrvReadConsole(IN PCONSOLE Console,
 static NTSTATUS
 ReadChars(IN PGET_INPUT_INFO InputInfo,
           IN PCSR_API_MESSAGE ApiMessage,
-          IN BOOL CreateWaitBlock OPTIONAL)
+          IN BOOLEAN CreateWaitBlock OPTIONAL)
 {
     NTSTATUS Status;
     PCONSOLE_READCONSOLE ReadConsoleRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ReadConsoleRequest;
@@ -188,12 +186,12 @@ ReadChars(IN PGET_INPUT_INFO InputInfo,
 
 static NTSTATUS
 ReadInputBuffer(IN PGET_INPUT_INFO InputInfo,
-                IN BOOL Wait,
                 IN PCSR_API_MESSAGE ApiMessage,
-                IN BOOL CreateWaitBlock OPTIONAL);
+                IN BOOLEAN CreateWaitBlock OPTIONAL);
 
 // Wait function CSR_WAIT_FUNCTION
 static BOOLEAN
+NTAPI
 ReadInputBufferThread(IN PLIST_ENTRY WaitList,
                       IN PCSR_THREAD WaitThread,
                       IN PCSR_API_MESSAGE WaitApiMessage,
@@ -203,7 +201,6 @@ ReadInputBufferThread(IN PLIST_ENTRY WaitList,
                       IN ULONG WaitFlags)
 {
     NTSTATUS Status;
-    PCONSOLE_GETINPUT GetInputRequest = &((PCONSOLE_API_MESSAGE)WaitApiMessage)->Data.GetInputRequest;
     PGET_INPUT_INFO InputInfo = (PGET_INPUT_INFO)WaitContext;
 
     PVOID InputHandle = WaitArgument2;
@@ -239,10 +236,7 @@ ReadInputBufferThread(IN PLIST_ENTRY WaitList,
      * If we go there, that means we are notified for some new input.
      * The console is therefore already locked.
      */
-    Status = ReadInputBuffer(InputInfo,
-                             GetInputRequest->bRead,
-                             WaitApiMessage,
-                             FALSE);
+    Status = ReadInputBuffer(InputInfo, WaitApiMessage, FALSE);
 
 Quit:
     if (Status != STATUS_PENDING)
@@ -257,16 +251,16 @@ Quit:
 NTSTATUS NTAPI
 ConDrvGetConsoleInput(IN PCONSOLE Console,
                       IN PCONSOLE_INPUT_BUFFER InputBuffer,
+                      IN BOOLEAN KeepEvents,
                       IN BOOLEAN WaitForMoreEvents,
                       IN BOOLEAN Unicode,
                       OUT PINPUT_RECORD InputRecord,
                       IN ULONG NumEventsToRead,
-                      OUT PULONG NumEventsRead);
+                      OUT PULONG NumEventsRead OPTIONAL);
 static NTSTATUS
 ReadInputBuffer(IN PGET_INPUT_INFO InputInfo,
-                IN BOOL Wait,   // TRUE --> Read ; FALSE --> Peek
                 IN PCSR_API_MESSAGE ApiMessage,
-                IN BOOL CreateWaitBlock OPTIONAL)
+                IN BOOLEAN CreateWaitBlock OPTIONAL)
 {
     NTSTATUS Status;
     PCONSOLE_GETINPUT GetInputRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetInputRequest;
@@ -276,7 +270,8 @@ ReadInputBuffer(IN PGET_INPUT_INFO InputInfo,
 
     Status = ConDrvGetConsoleInput(InputBuffer->Header.Console,
                                    InputBuffer,
-                                   Wait,
+                                   (GetInputRequest->wFlags & CONSOLE_READ_KEEPEVENT) != 0,
+                                   (GetInputRequest->wFlags & CONSOLE_READ_CONTINUE ) == 0,
                                    GetInputRequest->Unicode,
                                    GetInputRequest->InputRecord,
                                    GetInputRequest->Length,
@@ -335,9 +330,7 @@ CSR_API(SrvReadConsole)
     InputInfo.HandleEntry   = HandleEntry;
     InputInfo.InputBuffer   = InputBuffer;
 
-    Status = ReadChars(&InputInfo,
-                       ApiMessage,
-                       TRUE);
+    Status = ReadChars(&InputInfo, ApiMessage, TRUE);
 
     ConSrvReleaseInputBuffer(InputBuffer, TRUE);
 
@@ -357,6 +350,9 @@ CSR_API(SrvGetConsoleInput)
 
     DPRINT("SrvGetConsoleInput\n");
 
+    if (GetInputRequest->wFlags & ~(CONSOLE_READ_KEEPEVENT | CONSOLE_READ_CONTINUE))
+        return STATUS_INVALID_PARAMETER;
+
     if (!CsrValidateMessageBuffer(ApiMessage,
                                   (PVOID*)&GetInputRequest->InputRecord,
                                   GetInputRequest->Length,
@@ -374,10 +370,7 @@ CSR_API(SrvGetConsoleInput)
     InputInfo.HandleEntry   = HandleEntry;
     InputInfo.InputBuffer   = InputBuffer;
 
-    Status = ReadInputBuffer(&InputInfo,
-                             GetInputRequest->bRead,
-                             ApiMessage,
-                             TRUE);
+    Status = ReadInputBuffer(&InputInfo, ApiMessage, TRUE);
 
     ConSrvReleaseInputBuffer(InputBuffer, TRUE);
 
@@ -390,6 +383,7 @@ NTSTATUS NTAPI
 ConDrvWriteConsoleInput(IN PCONSOLE Console,
                         IN PCONSOLE_INPUT_BUFFER InputBuffer,
                         IN BOOLEAN Unicode,
+                        IN BOOLEAN AppendToEnd,
                         IN PINPUT_RECORD InputRecord,
                         IN ULONG NumEventsToWrite,
                         OUT PULONG NumEventsWritten OPTIONAL);
@@ -419,6 +413,7 @@ CSR_API(SrvWriteConsoleInput)
     Status = ConDrvWriteConsoleInput(InputBuffer->Header.Console,
                                      InputBuffer,
                                      WriteInputRequest->Unicode,
+                                     WriteInputRequest->AppendToEnd,
                                      WriteInputRequest->InputRecord,
                                      WriteInputRequest->Length,
                                      &NumEventsWritten);