[CONSRV]
[reactos.git] / win32ss / user / winsrv / consrv / condrv / coninput.c
index 7b67130..83428a9 100644 (file)
 
 /* 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 ConsoleInputUnicodeCharToAnsiChar(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) \
+    ASSERT((ULONG_PTR)dWChar != (ULONG_PTR)sChar); \
     MultiByteToWideChar((Console)->InputCodePage, 0, (sChar), 1, (dWChar), 1)
 
 typedef struct ConsoleInput_t
@@ -170,8 +178,7 @@ ConDrvReadConsole(IN PCONSOLE Console,
 
     /* Validity checks */
     ASSERT(Console == InputBuffer->Header.Console);
-    ASSERT( (Buffer != NULL && NumCharsToRead >  0) ||
-            (Buffer == NULL && NumCharsToRead == 0) );
+    ASSERT((Buffer != NULL) || (Buffer == NULL && NumCharsToRead == 0));
 
     /* We haven't read anything (yet) */
 
@@ -316,11 +323,9 @@ ConDrvGetConsoleInput(IN PCONSOLE Console,
 
     /* Validity checks */
     ASSERT(Console == InputBuffer->Header.Console);
-    ASSERT( (InputRecord != NULL && NumEventsToRead >  0) ||
-            (InputRecord == NULL && NumEventsToRead == 0) );
+    ASSERT((InputRecord != NULL) || (InputRecord == NULL && NumEventsToRead == 0));
 
-    // Do NOT do that !! Use the existing number of events already read, if any...
-    // if (NumEventsRead) *NumEventsRead = 0;
+    if (NumEventsRead) *NumEventsRead = 0;
 
     if (IsListEmpty(&InputBuffer->InputEvents))
     {
@@ -333,8 +338,7 @@ ConDrvGetConsoleInput(IN PCONSOLE Console,
 
     /* Only get input if there is any */
     CurrentInput = InputBuffer->InputEvents.Flink;
-    if (NumEventsRead) i = *NumEventsRead; // We will read the remaining events...
-
+    i = 0;
     while ((CurrentInput != &InputBuffer->InputEvents) && (i < NumEventsToRead))
     {
         Input = CONTAINING_RECORD(CurrentInput, ConsoleInput, ListEntry);
@@ -386,13 +390,12 @@ ConDrvWriteConsoleInput(IN PCONSOLE Console,
 
     /* Validity checks */
     ASSERT(Console == InputBuffer->Header.Console);
-    ASSERT( (InputRecord != NULL && NumEventsToWrite >  0) ||
-            (InputRecord == NULL && NumEventsToWrite == 0) );
+    ASSERT((InputRecord != NULL) || (InputRecord == NULL && NumEventsToWrite == 0));
 
-    // Do NOT do that !! Use the existing number of events already written, if any...
     // if (NumEventsWritten) *NumEventsWritten = 0;
+    // Status = ConioAddInputEvents(Console, InputRecord, NumEventsToWrite, NumEventsWritten, AppendToEnd);
 
-    for (i = (NumEventsWritten ? *NumEventsWritten : 0); i < NumEventsToWrite && NT_SUCCESS(Status); ++i)
+    for (i = 0; i < NumEventsToWrite && NT_SUCCESS(Status); ++i)
     {
         if (!Unicode)
         {