1 /*
2  * COPYRIGHT:       See COPYING in the top level directory
3  * PROJECT:         ReactOS Console Server DLL
4  * FILE:            win32ss/user/winsrv/consrv/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 
29 
30 /************ Line discipline ***************/
31 
32 static NTSTATUS NTAPI
33 DummyReadStream(IN OUT PTERMINAL This,
34                 IN BOOLEAN Unicode,
35                 /**PWCHAR Buffer,**/
36                 OUT PVOID Buffer,
37                 IN OUT PCONSOLE_READCONSOLE_CONTROL ReadControl,
38                 IN PVOID Parameter OPTIONAL,
39                 IN ULONG NumCharsToRead,
40                 OUT PULONG NumCharsRead OPTIONAL)
41 {
42     /*
43      * We were called because the console was in cooked mode.
44      * There is nothing to read, wait until a real terminal
45      * is plugged into the console.
46      */
47     return STATUS_PENDING;
48 }
49 
50 static NTSTATUS NTAPI
51 DummyWriteStream(IN OUT PTERMINAL This,
52                  PTEXTMODE_SCREEN_BUFFER Buff,
53                  PWCHAR Buffer,
54                  DWORD Length,
55                  BOOL Attrib)
56 {
57     /*
58      * We were called because the console was in cooked mode.
59      * There is nothing to write, wait until a real terminal
60      * is plugged into the console.
61      */
62 
63     // /* Stop here if the console is paused */
64     // if (Console->ConsolePaused) return STATUS_PENDING;
65 
66     return STATUS_PENDING;
67 }
68 
69 /************ Line discipline ***************/
70 
71 
72 
73 static VOID NTAPI
74 DummyDrawRegion(IN OUT PTERMINAL This,
75                 SMALL_RECT* Region)
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 DummyGetLargestConsoleWindowSize(IN OUT PTERMINAL This,
113                                  PCOORD pSize)
114 {
115     /* Return a standard size */
116     if (!pSize) return;
117     pSize->X = 80;
118     pSize->Y = 25;
119 }
120 
121 static BOOL NTAPI
122 DummySetPalette(IN OUT PTERMINAL This,
123                 HPALETTE PaletteHandle,
124                 UINT PaletteUsage)
125 {
126     return TRUE;
127 }
128 
129 static INT NTAPI
130 DummyShowMouseCursor(IN OUT PTERMINAL This,
131                      BOOL Show)
132 {
133     return 0;
134 }
135 
136 static TERMINAL_VTBL DummyVtbl =
137 {
138     DummyInitTerminal,
139     DummyDeinitTerminal,
140 
141     DummyReadStream,
142     DummyWriteStream,
143 
144     DummyDrawRegion,
145     DummySetCursorInfo,
146     DummySetScreenInfo,
147     DummyResizeTerminal,
148     DummySetActiveScreenBuffer,
149     DummyReleaseScreenBuffer,
150     DummyGetLargestConsoleWindowSize,
151     DummySetPalette,
152     DummyShowMouseCursor,
153 };
154 
155 VOID
156 ResetTerminal(IN PCONSOLE Console)
157 {
158     if (!Console) return;
159 
160     /* Reinitialize the terminal interface */
161     RtlZeroMemory(&Console->TermIFace, sizeof(Console->TermIFace));
162     Console->TermIFace.Vtbl = &DummyVtbl;
163 }
164 
165 /* EOF */
166