1 /*
2  * COPYRIGHT:       See COPYING in the top level directory
3  * PROJECT:         ReactOS Console Server DLL
4  * FILE:            condrv/dummyterm.c
5  * PURPOSE:         Dummy Terminal used when no terminal
6  *                  is attached to the specified console.
7  * PROGRAMMERS:     Hermes Belusca-Maito (hermes.belusca@sfr.fr)
8  */
9 
10 /* INCLUDES *******************************************************************/
11 
12 #include <consrv.h>
13 
14 /* DUMMY TERMINAL INTERFACE ***************************************************/
15 
16 static NTSTATUS NTAPI
17 DummyInitTerminal(IN OUT PTERMINAL This,
18                   IN PCONSOLE Console)
19 {
20     return STATUS_SUCCESS;
21 }
22 
23 static VOID NTAPI
24 DummyDeinitTerminal(IN OUT PTERMINAL This)
25 {
26 }
27 
28 static VOID NTAPI
29 DummyDrawRegion(IN OUT PTERMINAL This,
30                 SMALL_RECT* Region)
31 {
32 }
33 
34 
35 
36 /************ Line discipline ***************/
37 
38 static NTSTATUS NTAPI
39 DummyReadStream(IN OUT PTERMINAL This,
40                 /**/IN PUNICODE_STRING ExeName /**/OPTIONAL/**/,/**/
41                 IN BOOLEAN Unicode,
42                 /**PWCHAR Buffer,**/
43                 OUT PVOID Buffer,
44                 IN OUT PCONSOLE_READCONSOLE_CONTROL ReadControl,
45                 IN ULONG NumCharsToRead,
46                 OUT PULONG NumCharsRead OPTIONAL)
47 {
48     /*
49      * We were called because the console was in cooked mode.
50      * There is nothing to read, wait until a real terminal
51      * is plugged into the console.
52      */
53     return STATUS_PENDING;
54 }
55 
56 static NTSTATUS NTAPI
57 DummyWriteStream(IN OUT PTERMINAL This,
58                  PTEXTMODE_SCREEN_BUFFER Buff,
59                  PWCHAR Buffer,
60                  DWORD Length,
61                  BOOL Attrib)
62 {
63     /*
64      * We were called because the console was in cooked mode.
65      * There is nothing to write, wait until a real terminal
66      * is plugged into the console.
67      */
68 
69     // /* Stop here if the console is paused */
70     // if (Console->UnpauseEvent != NULL) return STATUS_PENDING;
71 
72     return STATUS_PENDING;
73 }
74 
75 /************ Line discipline ***************/
76 
77 
78 
79 static BOOL NTAPI
80 DummySetCursorInfo(IN OUT PTERMINAL This,
81                    PCONSOLE_SCREEN_BUFFER ScreenBuffer)
82 {
83     return TRUE;
84 }
85 
86 static BOOL NTAPI
87 DummySetScreenInfo(IN OUT PTERMINAL This,
88                    PCONSOLE_SCREEN_BUFFER ScreenBuffer,
89                    SHORT OldCursorX,
90                    SHORT OldCursorY)
91 {
92     return TRUE;
93 }
94 
95 static VOID NTAPI
96 DummyResizeTerminal(IN OUT PTERMINAL This)
97 {
98 }
99 
100 static VOID NTAPI
101 DummySetActiveScreenBuffer(IN OUT PTERMINAL This)
102 {
103 }
104 
105 static VOID NTAPI
106 DummyReleaseScreenBuffer(IN OUT PTERMINAL This,
107                          IN PCONSOLE_SCREEN_BUFFER ScreenBuffer)
108 {
109 }
110 
111 static VOID NTAPI
112 DummyChangeTitle(IN OUT PTERMINAL This)
113 {
114 }
115 
116 static VOID NTAPI
117 DummyGetLargestConsoleWindowSize(IN OUT PTERMINAL This,
118                                  PCOORD pSize)
119 {
120 }
121 
122 /*
123 static BOOL NTAPI
124 DummyGetSelectionInfo(IN OUT PTERMINAL This,
125                       PCONSOLE_SELECTION_INFO pSelectionInfo)
126 {
127     return TRUE;
128 }
129 */
130 
131 static BOOL NTAPI
132 DummySetPalette(IN OUT PTERMINAL This,
133                 HPALETTE PaletteHandle,
134                 UINT PaletteUsage)
135 {
136     return TRUE;
137 }
138 
139 static INT NTAPI
140 DummyShowMouseCursor(IN OUT PTERMINAL This,
141                      BOOL Show)
142 {
143     return 0;
144 }
145 
146 static TERMINAL_VTBL DummyVtbl =
147 {
148     DummyInitTerminal,
149     DummyDeinitTerminal,
150     DummyDrawRegion,
151 
152     DummyReadStream,
153     DummyWriteStream,
154 
155     DummySetCursorInfo,
156     DummySetScreenInfo,
157     DummyResizeTerminal,
158     DummySetActiveScreenBuffer,
159     DummyReleaseScreenBuffer,
160     DummyChangeTitle,
161     DummyGetLargestConsoleWindowSize,
162     // DummyGetSelectionInfo,
163     DummySetPalette,
164     DummyShowMouseCursor,
165 };
166 
167 VOID
168 ResetTerminal(IN PCONSOLE Console)
169 {
170     if (!Console) return;
171 
172     /* Reinitialize the terminal interface */
173     RtlZeroMemory(&Console->TermIFace, sizeof(Console->TermIFace));
174     Console->TermIFace.Vtbl = &DummyVtbl;
175 }
176 
177 /* EOF */
178