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 BOOL NTAPI
130 DummySetCodePage(IN OUT PTERMINAL This,
131                  UINT CodePage)
132 {
133     return TRUE;
134 }
135 
136 static INT NTAPI
137 DummyShowMouseCursor(IN OUT PTERMINAL This,
138                      BOOL Show)
139 {
140     return 0;
141 }
142 
143 static TERMINAL_VTBL DummyVtbl =
144 {
145     DummyInitTerminal,
146     DummyDeinitTerminal,
147 
148     DummyReadStream,
149     DummyWriteStream,
150 
151     DummyDrawRegion,
152     DummySetCursorInfo,
153     DummySetScreenInfo,
154     DummyResizeTerminal,
155     DummySetActiveScreenBuffer,
156     DummyReleaseScreenBuffer,
157     DummyGetLargestConsoleWindowSize,
158     DummySetPalette,
159     DummySetCodePage,
160     DummyShowMouseCursor,
161 };
162 
163 VOID
164 ResetTerminal(IN PCONSOLE Console)
165 {
166     if (!Console) return;
167 
168     /* Reinitialize the terminal interface */
169     RtlZeroMemory(&Console->TermIFace, sizeof(Console->TermIFace));
170     Console->TermIFace.Vtbl = &DummyVtbl;
171 }
172 
173 /* EOF */
174