1 | /* $Id: conin.cpp,v 1.12 2000-10-03 17:28:28 sandervl Exp $ */
|
---|
2 |
|
---|
3 | /*
|
---|
4 | * Win32 Console API Translation for OS/2
|
---|
5 | * 1998/02/10 Patrick Haller (haller@zebra.fh-weingarten.de)
|
---|
6 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
7 | */
|
---|
8 |
|
---|
9 |
|
---|
10 | #ifdef DEBUG
|
---|
11 | #define DEBUG_LOCAL
|
---|
12 | #define DEBUG_LOCAL2
|
---|
13 | #endif
|
---|
14 |
|
---|
15 |
|
---|
16 | /*****************************************************************************
|
---|
17 | * Remark *
|
---|
18 | *****************************************************************************
|
---|
19 | */
|
---|
20 |
|
---|
21 |
|
---|
22 | /*****************************************************************************
|
---|
23 | * Includes *
|
---|
24 | *****************************************************************************/
|
---|
25 |
|
---|
26 | #define INCL_WIN
|
---|
27 | #define INCL_DOSMEMMGR
|
---|
28 | #define INCL_DOSSEMAPHORES
|
---|
29 | #define INCL_DOSERRORS
|
---|
30 | #define INCL_DOSPROCESS
|
---|
31 | #define INCL_DOSMODULEMGR
|
---|
32 | #define INCL_VIO
|
---|
33 | #define INCL_AVIO
|
---|
34 | #include <os2wrap.h> //Odin32 OS/2 api wrappers
|
---|
35 |
|
---|
36 | #include <win32api.h>
|
---|
37 | #include <misc.h>
|
---|
38 | #include <string.h>
|
---|
39 |
|
---|
40 | #include "conwin.h" // Windows Header for console only
|
---|
41 | #include "HandleManager.h"
|
---|
42 | #include "HMDevice.h"
|
---|
43 | #include "Conin.H"
|
---|
44 | #include "Console2.h"
|
---|
45 | #include <heapstring.h>
|
---|
46 |
|
---|
47 | #define DBG_LOCALLOG DBG_conin
|
---|
48 | #include "dbglocal.h"
|
---|
49 |
|
---|
50 |
|
---|
51 | /*****************************************************************************
|
---|
52 | * Name : DWORD HMDeviceConsoleInClass::CreateFile
|
---|
53 | * Purpose : this is called from the handle manager if a CreateFile() is
|
---|
54 | * performed on a handle
|
---|
55 | * Parameters: LPCSTR lpFileName name of the file / device
|
---|
56 | * PHMHANDLEDATA pHMHandleData data of the NEW handle
|
---|
57 | * PVOID lpSecurityAttributes ignored
|
---|
58 | * PHMHANDLEDATA pHMHandleDataTemplate data of the template handle
|
---|
59 | * Variables :
|
---|
60 | * Result :
|
---|
61 | * Remark : @@@PH CONIN$ handles should be exclusive
|
---|
62 | * reject other requests to this device
|
---|
63 | * Status : NO_ERROR - API succeeded
|
---|
64 | * other - what is to be set in SetLastError
|
---|
65 | *
|
---|
66 | * Author : Patrick Haller [Wed, 1998/02/11 20:44]
|
---|
67 | *****************************************************************************/
|
---|
68 |
|
---|
69 | DWORD HMDeviceConsoleInClass::CreateFile (LPCSTR lpFileName,
|
---|
70 | PHMHANDLEDATA pHMHandleData,
|
---|
71 | PVOID lpSecurityAttributes,
|
---|
72 | PHMHANDLEDATA pHMHandleDataTemplate)
|
---|
73 | {
|
---|
74 | #ifdef DEBUG_LOCAL
|
---|
75 | WriteLog("KERNEL32/CONSOLE:HMDeviceConsoleInClass::CreateFile %s(%s,%08x,%08x,%08x)\n",
|
---|
76 | lpHMDeviceName,
|
---|
77 | lpFileName,
|
---|
78 | pHMHandleData->hHMHandle,
|
---|
79 | lpSecurityAttributes,
|
---|
80 | pHMHandleDataTemplate);
|
---|
81 | #endif
|
---|
82 |
|
---|
83 | pHMHandleData->dwType = FILE_TYPE_CHAR; /* we're a character device */
|
---|
84 |
|
---|
85 | return(NO_ERROR);
|
---|
86 | }
|
---|
87 |
|
---|
88 |
|
---|
89 | /*****************************************************************************
|
---|
90 | * Name :
|
---|
91 | * Purpose :
|
---|
92 | * Parameters:
|
---|
93 | * Variables :
|
---|
94 | * Result :
|
---|
95 | * Remark :
|
---|
96 | * Status :
|
---|
97 | *
|
---|
98 | * Author : Patrick Haller [Wed, 1998/02/11 20:44]
|
---|
99 | *****************************************************************************/
|
---|
100 |
|
---|
101 | BOOL HMDeviceConsoleInClass::ReadFile(PHMHANDLEDATA pHMHandleData,
|
---|
102 | LPCVOID lpBuffer,
|
---|
103 | DWORD nNumberOfBytesToRead,
|
---|
104 | LPDWORD lpNumberOfBytesRead,
|
---|
105 | LPOVERLAPPED lpOverlapped)
|
---|
106 | {
|
---|
107 | ULONG ulCounter; /* character counter for the queue loop */
|
---|
108 | PSZ pszTarget; /* pointer to target buffer */
|
---|
109 | APIRET rc; /* API returncode */
|
---|
110 | INPUT_RECORD InputRecord; /* buffer for the event to be read */
|
---|
111 | ULONG ulPostCounter; /* semaphore post counter */
|
---|
112 | BOOL fLoop = TRUE; /* set to false if function may return to caller */
|
---|
113 |
|
---|
114 | #ifdef DEBUG_LOCAL
|
---|
115 | WriteLog("KERNEL32/CONSOLE:HMDeviceConsoleInClass::ReadFile %s(%08x,%08x,%08x,%08x,%08x)\n",
|
---|
116 | lpHMDeviceName,
|
---|
117 | pHMHandleData->hHMHandle,
|
---|
118 | lpBuffer,
|
---|
119 | nNumberOfBytesToRead,
|
---|
120 | lpNumberOfBytesRead,
|
---|
121 | lpOverlapped);
|
---|
122 | #endif
|
---|
123 |
|
---|
124 | ulCounter = 0; /* read ascii chars from queue */
|
---|
125 | pszTarget = (PSZ)lpBuffer;
|
---|
126 |
|
---|
127 | /* block if no key events are in the queue */
|
---|
128 | for (;fLoop;) /* until we got some characters */
|
---|
129 | {
|
---|
130 | if (iConsoleInputQueryEvents() == 0) /* if queue is currently empty */
|
---|
131 | {
|
---|
132 | rc = DosWaitEventSem(pConsoleInput->hevInputQueue, /* wait for input */
|
---|
133 | SEM_INDEFINITE_WAIT);
|
---|
134 | DosResetEventSem(pConsoleInput->hevInputQueue, /* reset semaphore */
|
---|
135 | &ulPostCounter); /* post counter - ignored */
|
---|
136 | }
|
---|
137 |
|
---|
138 | do
|
---|
139 | {
|
---|
140 | rc = iConsoleInputEventPop(&InputRecord); /* get event from queue */
|
---|
141 | if (rc == NO_ERROR) /* if we've got a valid event in the queue */
|
---|
142 | {
|
---|
143 | //@@@PH other events are discarded!
|
---|
144 | if ( (InputRecord.EventType == KEY_EVENT) && /* check event type */
|
---|
145 | (InputRecord.Event.KeyEvent.bKeyDown == TRUE) )
|
---|
146 | {
|
---|
147 | // console in line input mode ?
|
---|
148 | if (pConsoleInput->dwConsoleMode & ENABLE_LINE_INPUT)
|
---|
149 | {
|
---|
150 | // continue until buffer full or CR entered
|
---|
151 | // Note: CRLF is actually returned at the end of the buffer!
|
---|
152 | if (InputRecord.Event.KeyEvent.uChar.AsciiChar == 0x0d)
|
---|
153 | fLoop = FALSE;
|
---|
154 | }
|
---|
155 | else
|
---|
156 | // return on any single key in buffer :)
|
---|
157 | // fLoop = FALSE;
|
---|
158 | // @@@PH 2000/08/10 changed behaviour to return ALL input events
|
---|
159 | // recorded in the console.
|
---|
160 | fLoop = (iConsoleInputQueryEvents() != 0);
|
---|
161 |
|
---|
162 | // record key stroke
|
---|
163 | if (pConsoleInput->dwConsoleMode & ENABLE_PROCESSED_INPUT)
|
---|
164 | {
|
---|
165 | // filter special characters first
|
---|
166 | switch (InputRecord.Event.KeyEvent.uChar.AsciiChar)
|
---|
167 | {
|
---|
168 | case 0x00:
|
---|
169 | // Ascii values of 0x00 are sent e.g. for SHIFT-DOWN
|
---|
170 | // key events, etc.
|
---|
171 | break;
|
---|
172 |
|
---|
173 | case 0x03: // ctrl-c is filtered!
|
---|
174 | // @@@PH we're supposed to call a ctrl-c break handler here!
|
---|
175 | break;
|
---|
176 |
|
---|
177 | case 0x0d: // CR
|
---|
178 | // CR is automatically expanded to CRLF if in line input mode!
|
---|
179 | if (pConsoleInput->dwConsoleMode & ENABLE_LINE_INPUT)
|
---|
180 | {
|
---|
181 | *pszTarget = 0x0d; // CR
|
---|
182 | pszTarget++;
|
---|
183 | ulCounter++;
|
---|
184 | if (ulCounter < nNumberOfBytesToRead) // check for room
|
---|
185 | {
|
---|
186 | *pszTarget = 0x0a; // LF
|
---|
187 | pszTarget++;
|
---|
188 | ulCounter++;
|
---|
189 | }
|
---|
190 |
|
---|
191 | if (pConsoleInput->dwConsoleMode & ENABLE_ECHO_INPUT)
|
---|
192 | HMWriteFile(pConsoleGlobals->hConsoleBuffer,
|
---|
193 | pszTarget-2,
|
---|
194 | 2,
|
---|
195 | &ulPostCounter, /* dummy result */
|
---|
196 | NULL);
|
---|
197 |
|
---|
198 | }
|
---|
199 |
|
---|
200 | break;
|
---|
201 |
|
---|
202 | case 0x08: // backspace
|
---|
203 | if (ulCounter > 0)
|
---|
204 | {
|
---|
205 | //@@@PH erase character on screen!
|
---|
206 | ulCounter--;
|
---|
207 | pszTarget--;
|
---|
208 | /* local echo enabled ? */
|
---|
209 | if (pConsoleInput->dwConsoleMode & ENABLE_ECHO_INPUT)
|
---|
210 | HMWriteFile(pConsoleGlobals->hConsoleBuffer,
|
---|
211 | &InputRecord.Event.KeyEvent.uChar.AsciiChar,
|
---|
212 | 1,
|
---|
213 | &ulPostCounter, /* dummy result */
|
---|
214 | NULL);
|
---|
215 | }
|
---|
216 | break;
|
---|
217 |
|
---|
218 | default:
|
---|
219 | // OK, for the rest ...
|
---|
220 | *pszTarget = InputRecord.Event.KeyEvent.uChar.AsciiChar;
|
---|
221 | dprintf(("KERNEL32:CONIN$: Debug: recorded key (%c - %02xh)\n",
|
---|
222 | *pszTarget,
|
---|
223 | *pszTarget));
|
---|
224 |
|
---|
225 | pszTarget++;
|
---|
226 | ulCounter++;
|
---|
227 | /* local echo enabled ? */
|
---|
228 | if (pConsoleInput->dwConsoleMode & ENABLE_ECHO_INPUT)
|
---|
229 | HMWriteFile(pConsoleGlobals->hConsoleBuffer,
|
---|
230 | &InputRecord.Event.KeyEvent.uChar.AsciiChar,
|
---|
231 | 1,
|
---|
232 | &ulPostCounter, /* dummy result */
|
---|
233 | NULL);
|
---|
234 |
|
---|
235 |
|
---|
236 | }
|
---|
237 | }
|
---|
238 | else
|
---|
239 | {
|
---|
240 | *pszTarget = InputRecord.Event.KeyEvent.uChar.AsciiChar;
|
---|
241 | dprintf(("KERNEL32:CONIN$: Debug: recorded key (%c - %02xh)\n",
|
---|
242 | *pszTarget,
|
---|
243 | *pszTarget));
|
---|
244 |
|
---|
245 | pszTarget++;
|
---|
246 | ulCounter++;
|
---|
247 |
|
---|
248 | /* local echo enabled ? */
|
---|
249 | if (pConsoleInput->dwConsoleMode & ENABLE_ECHO_INPUT)
|
---|
250 | HMWriteFile(pConsoleGlobals->hConsoleBuffer,
|
---|
251 | &InputRecord.Event.KeyEvent.uChar.AsciiChar,
|
---|
252 | 1,
|
---|
253 | &ulPostCounter, /* dummy result */
|
---|
254 | NULL);
|
---|
255 | }
|
---|
256 |
|
---|
257 | // buffer filled?
|
---|
258 | if (ulCounter >= nNumberOfBytesToRead) /* at buffer's end ? */
|
---|
259 | fLoop = FALSE;
|
---|
260 | }
|
---|
261 | /* Note: other events are discarded */
|
---|
262 | }
|
---|
263 | }
|
---|
264 | while (rc == NO_ERROR);
|
---|
265 | }
|
---|
266 |
|
---|
267 | *lpNumberOfBytesRead = ulCounter; /* write result */
|
---|
268 |
|
---|
269 | return(TRUE); /* OK */
|
---|
270 | }
|
---|
271 |
|
---|
272 |
|
---|
273 | /*****************************************************************************
|
---|
274 | * Name :
|
---|
275 | * Purpose :
|
---|
276 | * Parameters:
|
---|
277 | * Variables :
|
---|
278 | * Result :
|
---|
279 | * Remark :
|
---|
280 | * Status :
|
---|
281 | *
|
---|
282 | * Author : Patrick Haller [Wed, 1998/02/11 20:44]
|
---|
283 | *****************************************************************************/
|
---|
284 |
|
---|
285 | BOOL HMDeviceConsoleInClass::WriteFile(PHMHANDLEDATA pHMHandleData,
|
---|
286 | LPCVOID lpBuffer,
|
---|
287 | DWORD nNumberOfBytesToWrite,
|
---|
288 | LPDWORD lpNumberOfBytesWritten,
|
---|
289 | LPOVERLAPPED lpOverlapped)
|
---|
290 | {
|
---|
291 |
|
---|
292 | #ifdef DEBUG_LOCAL
|
---|
293 | WriteLog("KERNEL32/CONSOLE:HMDeviceConsoleInClass:WriteFile %s(%08x,%08x,%08x,%08x,%08x)\n",
|
---|
294 | lpHMDeviceName,
|
---|
295 | pHMHandleData->hHMHandle,
|
---|
296 | lpBuffer,
|
---|
297 | nNumberOfBytesToWrite,
|
---|
298 | lpNumberOfBytesWritten,
|
---|
299 | lpOverlapped);
|
---|
300 | #endif
|
---|
301 |
|
---|
302 | SetLastError(ERROR_ACCESS_DENIED_W);
|
---|
303 | return FALSE;
|
---|
304 | }
|
---|
305 |
|
---|
306 |
|
---|
307 | /*****************************************************************************
|
---|
308 | * Name :
|
---|
309 | * Purpose :
|
---|
310 | * Parameters:
|
---|
311 | * Variables :
|
---|
312 | * Result :
|
---|
313 | * Remark :
|
---|
314 | * Status :
|
---|
315 | *
|
---|
316 | * Author : Patrick Haller [Wed, 1998/02/11 20:44]
|
---|
317 | *****************************************************************************/
|
---|
318 |
|
---|
319 | DWORD HMDeviceConsoleInClass::_DeviceRequest (PHMHANDLEDATA pHMHandleData,
|
---|
320 | ULONG ulRequestCode,
|
---|
321 | ULONG arg1,
|
---|
322 | ULONG arg2,
|
---|
323 | ULONG arg3,
|
---|
324 | ULONG arg4)
|
---|
325 | {
|
---|
326 | switch (ulRequestCode)
|
---|
327 | {
|
---|
328 | case DRQ_FLUSHCONSOLEINPUTBUFFER:
|
---|
329 | return (HMDeviceConsoleInClass::
|
---|
330 | FlushConsoleInputBuffer(pHMHandleData));
|
---|
331 |
|
---|
332 | case DRQ_GETCONSOLEMODE:
|
---|
333 | return (HMDeviceConsoleInClass
|
---|
334 | ::GetConsoleMode(pHMHandleData,
|
---|
335 | (LPDWORD)arg1));
|
---|
336 |
|
---|
337 | case DRQ_GETNUMBEROFCONSOLEINPUTEVENTS:
|
---|
338 | return (HMDeviceConsoleInClass::
|
---|
339 | GetNumberOfConsoleInputEvents(pHMHandleData,
|
---|
340 | (LPDWORD)arg1));
|
---|
341 |
|
---|
342 | case DRQ_PEEKCONSOLEINPUTA:
|
---|
343 | return (HMDeviceConsoleInClass::
|
---|
344 | PeekConsoleInputA(pHMHandleData,
|
---|
345 | (PINPUT_RECORD)arg1,
|
---|
346 | (DWORD) arg2,
|
---|
347 | (LPDWORD) arg3));
|
---|
348 |
|
---|
349 | case DRQ_PEEKCONSOLEINPUTW:
|
---|
350 | return (HMDeviceConsoleInClass::
|
---|
351 | PeekConsoleInputW(pHMHandleData,
|
---|
352 | (PINPUT_RECORD)arg1,
|
---|
353 | (DWORD) arg2,
|
---|
354 | (LPDWORD) arg3));
|
---|
355 |
|
---|
356 |
|
---|
357 | case DRQ_READCONSOLEA:
|
---|
358 | return (HMDeviceConsoleInClass::
|
---|
359 | ReadConsoleA(pHMHandleData,
|
---|
360 | (CONST VOID*) arg1,
|
---|
361 | (DWORD) arg2,
|
---|
362 | (LPDWORD) arg3,
|
---|
363 | (LPVOID) arg4));
|
---|
364 |
|
---|
365 | case DRQ_READCONSOLEW:
|
---|
366 | return (HMDeviceConsoleInClass::
|
---|
367 | ReadConsoleW(pHMHandleData,
|
---|
368 | (CONST VOID*) arg1,
|
---|
369 | (DWORD) arg2,
|
---|
370 | (LPDWORD) arg3,
|
---|
371 | (LPVOID) arg4));
|
---|
372 |
|
---|
373 | case DRQ_READCONSOLEINPUTA:
|
---|
374 | return (HMDeviceConsoleInClass::
|
---|
375 | ReadConsoleInputA(pHMHandleData,
|
---|
376 | (PINPUT_RECORD)arg1,
|
---|
377 | (DWORD)arg2,
|
---|
378 | (LPDWORD)arg3));
|
---|
379 |
|
---|
380 | case DRQ_READCONSOLEINPUTW:
|
---|
381 | return (HMDeviceConsoleInClass::
|
---|
382 | ReadConsoleInputW(pHMHandleData,
|
---|
383 | (PINPUT_RECORD)arg1,
|
---|
384 | (DWORD)arg2,
|
---|
385 | (LPDWORD)arg3));
|
---|
386 |
|
---|
387 | case DRQ_SETCONSOLEMODE:
|
---|
388 | return (HMDeviceConsoleInClass
|
---|
389 | ::SetConsoleMode(pHMHandleData,
|
---|
390 | (DWORD)arg1));
|
---|
391 |
|
---|
392 | case DRQ_WRITECONSOLEINPUTA:
|
---|
393 | return (HMDeviceConsoleInClass::
|
---|
394 | WriteConsoleInputA(pHMHandleData,
|
---|
395 | (PINPUT_RECORD)arg1,
|
---|
396 | (DWORD)arg2,
|
---|
397 | (LPDWORD)arg3));
|
---|
398 |
|
---|
399 | case DRQ_WRITECONSOLEINPUTW:
|
---|
400 | return (HMDeviceConsoleInClass::
|
---|
401 | WriteConsoleInputW(pHMHandleData,
|
---|
402 | (PINPUT_RECORD)arg1,
|
---|
403 | (DWORD)arg2,
|
---|
404 | (LPDWORD)arg3));
|
---|
405 |
|
---|
406 | }
|
---|
407 |
|
---|
408 | #ifdef DEBUG_LOCAL
|
---|
409 | WriteLog("KERNEL32/CONSOLE:HMDeviceConsoleInClass:_DeviceRequest %s(%08x,%08x,%08x,%08x,%08x,%08x) unknown request\n",
|
---|
410 | lpHMDeviceName,
|
---|
411 | pHMHandleData->hHMHandle,
|
---|
412 | ulRequestCode,
|
---|
413 | arg1,
|
---|
414 | arg2,
|
---|
415 | arg3,
|
---|
416 | arg4);
|
---|
417 | #endif
|
---|
418 |
|
---|
419 | SetLastError(ERROR_INVALID_FUNCTION_W); /* request not implemented */
|
---|
420 | return(FALSE); /* we assume this indicates API call failed */
|
---|
421 | }
|
---|
422 |
|
---|
423 |
|
---|
424 | /*****************************************************************************
|
---|
425 | * Name : BOOL HMDeviceConsoleInClass::FlushConsoleInputBuffer
|
---|
426 | * Purpose : flushes all events from the input queue
|
---|
427 | * Parameters: PHMHANDLEDATA pHMHandleData - handle specific data
|
---|
428 | * Variables :
|
---|
429 | * Result :
|
---|
430 | * Remark :
|
---|
431 | * Status : UNTESTED
|
---|
432 | *
|
---|
433 | * Author : Patrick Haller [Wed, 1998/02/16 11:46]
|
---|
434 | *****************************************************************************/
|
---|
435 |
|
---|
436 | BOOL HMDeviceConsoleInClass::FlushConsoleInputBuffer(PHMHANDLEDATA pHMHandleData)
|
---|
437 | {
|
---|
438 | ULONG ulCounter; /* loop counter */
|
---|
439 |
|
---|
440 | #ifdef DEBUG_LOCAL2
|
---|
441 | WriteLog("KERNEL32/CONSOLE: CONIN$::FlushConsoleInputBuffer(%08x).\n",
|
---|
442 | pHMHandleData);
|
---|
443 | #endif
|
---|
444 |
|
---|
445 | pConsoleInput->ulIndexFree = 0;
|
---|
446 | pConsoleInput->ulIndexEvent = 0;
|
---|
447 | pConsoleInput->ulEvents = 0;
|
---|
448 |
|
---|
449 | for (ulCounter = 0;
|
---|
450 | ulCounter < CONSOLE_INPUTQUEUESIZE;
|
---|
451 | ulCounter++)
|
---|
452 | pConsoleInput->arrInputRecord[ulCounter].EventType = 0x0000; /* free event */
|
---|
453 |
|
---|
454 | return (TRUE);
|
---|
455 | }
|
---|
456 |
|
---|
457 |
|
---|
458 | /*****************************************************************************
|
---|
459 | * Name : DWORD HMDeviceConsoleInClass::GetConsoleMode
|
---|
460 | * Purpose : queries the current console mode
|
---|
461 | * Parameters: PHMHANDLEDATA pHMHandleData - handle specific data
|
---|
462 | * LPDWORD lpMode
|
---|
463 | * Variables :
|
---|
464 | * Result :
|
---|
465 |
|
---|
466 | * Remark :
|
---|
467 | * Status : UNTESTED
|
---|
468 | *
|
---|
469 | * Author : Patrick Haller [Wed, 1998/02/16 11:46]
|
---|
470 | *****************************************************************************/
|
---|
471 |
|
---|
472 | DWORD HMDeviceConsoleInClass::GetConsoleMode(PHMHANDLEDATA pHMHandleData,
|
---|
473 | LPDWORD lpMode)
|
---|
474 | {
|
---|
475 | #ifdef DEBUG_LOCAL2
|
---|
476 | WriteLog("KERNEL32/CONSOLE: CONIN$::GetConsoleMode(%08x,%08x).\n",
|
---|
477 | pHMHandleData,
|
---|
478 | lpMode);
|
---|
479 | #endif
|
---|
480 |
|
---|
481 | *lpMode = pConsoleInput->dwConsoleMode; /* return current console mode */
|
---|
482 |
|
---|
483 | return (TRUE);
|
---|
484 | }
|
---|
485 |
|
---|
486 |
|
---|
487 | /*****************************************************************************
|
---|
488 | * Name : DWORD HMDeviceConsoleInClass::GetNumberOfConsoleInputEvents
|
---|
489 | * Purpose : queries the current number of events in the input queue
|
---|
490 | * Parameters: PHMHANDLEDATA pHMHandleData - handle specific data
|
---|
491 | * LPDWORD lpNumberOfEvents - return number of events
|
---|
492 | * Variables :
|
---|
493 | * Result :
|
---|
494 | * Remark :
|
---|
495 | * Status : UNTESTED
|
---|
496 | *
|
---|
497 | * Author : Patrick Haller [Wed, 1998/02/16 11:46]
|
---|
498 | *****************************************************************************/
|
---|
499 |
|
---|
500 | BOOL HMDeviceConsoleInClass::GetNumberOfConsoleInputEvents(PHMHANDLEDATA pHMHandleData,
|
---|
501 | LPDWORD lpNumberOfEvents)
|
---|
502 | {
|
---|
503 | #ifdef DEBUG_LOCAL2
|
---|
504 | WriteLog("KERNEL32/CONSOLE: CONIN$::GetNumberOfConsoleInputEvents(%08x,%08x).\n",
|
---|
505 | pHMHandleData,
|
---|
506 | lpNumberOfEvents);
|
---|
507 | #endif
|
---|
508 |
|
---|
509 | *lpNumberOfEvents = pConsoleInput->ulEvents; /* return number of events */
|
---|
510 |
|
---|
511 | return (TRUE);
|
---|
512 | }
|
---|
513 |
|
---|
514 |
|
---|
515 | /*****************************************************************************
|
---|
516 | * Name : DWORD HMDeviceConsoleInClass::PeekConsoleInputA
|
---|
517 | * Purpose : peeks events placed in the console input queue
|
---|
518 | * Parameters: PHMHANDLEDATA pHMHandleData - current handle data
|
---|
519 | * PINPUT_RECORD pirBuffer - target buffer for events
|
---|
520 | * DWORD cInRecords - number of input records
|
---|
521 | * LPDWORD lpcRead - returns number of events stored
|
---|
522 | * Variables :
|
---|
523 | * Result : TRUE if successful, FALSE otherwise
|
---|
524 | * Remark : if queue is completely filled and no event is free,
|
---|
525 | * loop will scan over queue multiple times, until target
|
---|
526 | * buffer is filled. It does not check ulCounter to stop
|
---|
527 | * when one scan of the queue is complete.
|
---|
528 | * Status : UNTESTED
|
---|
529 | *
|
---|
530 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
531 | *****************************************************************************/
|
---|
532 |
|
---|
533 | DWORD HMDeviceConsoleInClass::PeekConsoleInputA(PHMHANDLEDATA pHMHandleData,
|
---|
534 | PINPUT_RECORD pirBuffer,
|
---|
535 | DWORD cInRecords,
|
---|
536 | LPDWORD lpcRead)
|
---|
537 | {
|
---|
538 | ULONG ulCounter; /* loop counter */
|
---|
539 | ULONG ulCurrentEvent; /* index of current event in the queue */
|
---|
540 | PINPUT_RECORD pirEvent; /* pointer to current queue element */
|
---|
541 |
|
---|
542 | #ifdef DEBUG_LOCAL2
|
---|
543 | WriteLog("KERNEL32/CONSOLE: HMDeviceConsoleInClass::PeekConsoleInputA(%08x,%08x,%08x,%08x).\n",
|
---|
544 | pHMHandleData,
|
---|
545 | pirBuffer,
|
---|
546 | cInRecords,
|
---|
547 | lpcRead);
|
---|
548 | #endif
|
---|
549 |
|
---|
550 | if (iConsoleInputQueryEvents() == 0) /* if queue is currently empty */
|
---|
551 | {
|
---|
552 | *lpcRead = 0; /* no events read from queue */
|
---|
553 | return (TRUE); /* OK, we're done */
|
---|
554 | }
|
---|
555 |
|
---|
556 |
|
---|
557 | for (ulCounter = 0,
|
---|
558 | ulCurrentEvent = pConsoleInput->ulIndexEvent,
|
---|
559 | pirEvent = &pConsoleInput->arrInputRecord[pConsoleInput->ulIndexEvent];
|
---|
560 |
|
---|
561 | ulCounter < cInRecords;
|
---|
562 |
|
---|
563 | ulCounter++,
|
---|
564 | ulCurrentEvent++,
|
---|
565 | pirEvent++,
|
---|
566 | pirBuffer++)
|
---|
567 | {
|
---|
568 | if (ulCurrentEvent > CONSOLE_INPUTQUEUESIZE) /* reaching after end of que*/
|
---|
569 | {
|
---|
570 | ulCurrentEvent = 0; /* then start over from beginning of queue */
|
---|
571 | pirEvent = pConsoleInput->arrInputRecord;
|
---|
572 | }
|
---|
573 |
|
---|
574 | if (pirEvent->EventType == 0x0000) /* no more events ? */
|
---|
575 | break; /* leave loop then */
|
---|
576 |
|
---|
577 | memcpy(pirEvent, /* copy event data */
|
---|
578 | pirBuffer,
|
---|
579 | sizeof(INPUT_RECORD));
|
---|
580 | }
|
---|
581 |
|
---|
582 | *lpcRead = ulCounter; /* return number of events read */
|
---|
583 | return (TRUE); /* OK, we're done */
|
---|
584 | }
|
---|
585 |
|
---|
586 |
|
---|
587 | /*****************************************************************************
|
---|
588 | * Name : DWORD HMDeviceConsoleInClass::PeekConsoleInputW
|
---|
589 | * Purpose : peeks events placed in the console input queue
|
---|
590 | * Parameters: PHMHANDLEDATA pHMHandleData - current handle data
|
---|
591 | * PINPUT_RECORD pirBuffer - target buffer for events
|
---|
592 | * DWORD cInRecords - number of input records
|
---|
593 | * LPDWORD lpcRead - returns number of events stored
|
---|
594 | * Variables :
|
---|
595 | * Result : TRUE if successful, FALSE otherwise
|
---|
596 | * Remark : if queue is completely filled and no event is free,
|
---|
597 | * loop will scan over queue multiple times, until target
|
---|
598 | * buffer is filled. It does not check ulCounter to stop
|
---|
599 | * when one scan of the queue is complete.
|
---|
600 | * Status : UNTESTED
|
---|
601 | *
|
---|
602 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
603 | *****************************************************************************/
|
---|
604 |
|
---|
605 | DWORD HMDeviceConsoleInClass::PeekConsoleInputW(PHMHANDLEDATA pHMHandleData,
|
---|
606 | PINPUT_RECORD pirBuffer,
|
---|
607 | DWORD cInRecords,
|
---|
608 | LPDWORD lpcRead)
|
---|
609 | {
|
---|
610 | ULONG ulCounter; /* loop counter */
|
---|
611 | ULONG ulCurrentEvent; /* index of current event in the queue */
|
---|
612 | PINPUT_RECORD pirEvent; /* pointer to current queue element */
|
---|
613 |
|
---|
614 | #ifdef DEBUG_LOCAL2
|
---|
615 | WriteLog("KERNEL32/CONSOLE: HMDeviceConsoleInClass::PeekConsoleInputW(%08x,%08x,%08x,%08x).\n",
|
---|
616 | pHMHandleData,
|
---|
617 | pirBuffer,
|
---|
618 | cInRecords,
|
---|
619 | lpcRead);
|
---|
620 | #endif
|
---|
621 |
|
---|
622 | if (iConsoleInputQueryEvents() == 0) /* if queue is currently empty */
|
---|
623 | {
|
---|
624 | *lpcRead = 0; /* no events read from queue */
|
---|
625 | return (TRUE); /* OK, we're done */
|
---|
626 | }
|
---|
627 |
|
---|
628 |
|
---|
629 | for (ulCounter = 0,
|
---|
630 | ulCurrentEvent = pConsoleInput->ulIndexEvent,
|
---|
631 | pirEvent = &pConsoleInput->arrInputRecord[pConsoleInput->ulIndexEvent];
|
---|
632 |
|
---|
633 | ulCounter < cInRecords;
|
---|
634 |
|
---|
635 | ulCounter++,
|
---|
636 | ulCurrentEvent++,
|
---|
637 | pirEvent++,
|
---|
638 | pirBuffer++)
|
---|
639 | {
|
---|
640 | if (ulCurrentEvent > CONSOLE_INPUTQUEUESIZE) /* reaching after end of que*/
|
---|
641 | {
|
---|
642 | ulCurrentEvent = 0; /* then start over from beginning of queue */
|
---|
643 | pirEvent = pConsoleInput->arrInputRecord;
|
---|
644 | }
|
---|
645 |
|
---|
646 | if (pirEvent->EventType == 0x0000) /* no more events ? */
|
---|
647 | break; /* leave loop then */
|
---|
648 |
|
---|
649 | memcpy(pirEvent, /* copy event data */
|
---|
650 | pirBuffer,
|
---|
651 | sizeof(INPUT_RECORD));
|
---|
652 | }
|
---|
653 |
|
---|
654 | *lpcRead = ulCounter; /* return number of events read */
|
---|
655 | return (TRUE); /* OK, we're done */
|
---|
656 | }
|
---|
657 |
|
---|
658 |
|
---|
659 | /*****************************************************************************
|
---|
660 | * Name : DWORD HMDeviceConsoleInClass::ReadConsoleA
|
---|
661 | * Purpose : read a string from the console
|
---|
662 | * Parameters: PHMHANDLEDATA pHMHandleData - handle specific data
|
---|
663 | * LPWORD lpwAttribute
|
---|
664 | * DWORD cWriteCells
|
---|
665 | * COORD dwWriteCoord
|
---|
666 | * LPDWORD lpcWritten
|
---|
667 | * Variables :
|
---|
668 | * Result :
|
---|
669 | * Remark :
|
---|
670 | * Status : UNTESTED
|
---|
671 | *
|
---|
672 | * Author : Patrick Haller [Wed, 1998/02/16 11:46]
|
---|
673 | *****************************************************************************/
|
---|
674 |
|
---|
675 | DWORD HMDeviceConsoleInClass::ReadConsoleA(PHMHANDLEDATA pHMHandleData,
|
---|
676 | CONST VOID* lpvBuffer,
|
---|
677 | DWORD cchToRead,
|
---|
678 | LPDWORD lpcchRead,
|
---|
679 | LPVOID lpvReserved)
|
---|
680 | {
|
---|
681 | PCONSOLEBUFFER pConsoleBuffer = (PCONSOLEBUFFER)pHMHandleData->lpHandlerData;
|
---|
682 |
|
---|
683 | #ifdef DEBUG_LOCAL2
|
---|
684 | WriteLog("KERNEL32/CONSOLE: CONIN$::ReadConsoleA(%08x,%08x,%u,%08x,%08x).\n",
|
---|
685 | pHMHandleData,
|
---|
686 | lpvBuffer,
|
---|
687 | cchToRead,
|
---|
688 | lpcchRead,
|
---|
689 | lpvReserved);
|
---|
690 | #endif
|
---|
691 |
|
---|
692 | /* simply forward the request to that routine */
|
---|
693 | return (HMDeviceConsoleInClass::ReadFile(pHMHandleData,
|
---|
694 | lpvBuffer,
|
---|
695 | cchToRead,
|
---|
696 | lpcchRead,
|
---|
697 | NULL));
|
---|
698 | }
|
---|
699 |
|
---|
700 |
|
---|
701 | /*****************************************************************************
|
---|
702 | * Name : DWORD HMDeviceConsoleInClass::ReadConsoleW
|
---|
703 | * Purpose : write a string to the console
|
---|
704 | * Parameters: PHMHANDLEDATA pHMHandleData - handle specific data
|
---|
705 | * LPWORD lpwAttribute
|
---|
706 | * DWORD cWriteCells
|
---|
707 | * COORD dwWriteCoord
|
---|
708 | * LPDWORD lpcWritten
|
---|
709 | * Variables :
|
---|
710 | * Result :
|
---|
711 | * Remark :
|
---|
712 | * Status : UNTESTED
|
---|
713 | *
|
---|
714 | * Author : Patrick Haller [Wed, 1998/02/16 11:46]
|
---|
715 | *****************************************************************************/
|
---|
716 |
|
---|
717 | DWORD HMDeviceConsoleInClass::ReadConsoleW(PHMHANDLEDATA pHMHandleData,
|
---|
718 | CONST VOID* lpvBuffer,
|
---|
719 | DWORD cchToRead,
|
---|
720 | LPDWORD lpcchRead,
|
---|
721 | LPVOID lpvReserved)
|
---|
722 | {
|
---|
723 | PCONSOLEBUFFER pConsoleBuffer = (PCONSOLEBUFFER)pHMHandleData->lpHandlerData;
|
---|
724 | DWORD dwResult;
|
---|
725 | LPSTR lpstrAscii;
|
---|
726 |
|
---|
727 | #ifdef DEBUG_LOCAL2
|
---|
728 | WriteLog("KERNEL32/CONSOLE: CONIN$::ReadConsoleW(%08x,%08x,%u,%08x,%08x).\n",
|
---|
729 | pHMHandleData,
|
---|
730 | lpvBuffer,
|
---|
731 | cchToRead,
|
---|
732 | lpcchRead,
|
---|
733 | lpvReserved);
|
---|
734 | #endif
|
---|
735 |
|
---|
736 | // create ascii buffer
|
---|
737 | lpstrAscii = (LPSTR)HEAP_malloc(cchToRead);
|
---|
738 | if (lpstrAscii == NULL)
|
---|
739 | return ERROR_NOT_ENOUGH_MEMORY;
|
---|
740 |
|
---|
741 | /* simply forward the request to that routine */
|
---|
742 | dwResult = HMDeviceConsoleInClass::ReadFile(pHMHandleData,
|
---|
743 | lpstrAscii,
|
---|
744 | cchToRead,
|
---|
745 | lpcchRead,
|
---|
746 | NULL);
|
---|
747 | /* Ascii -> unicode translation */
|
---|
748 | if (dwResult == TRUE)
|
---|
749 | lstrcpynAtoW((LPWSTR)lpvBuffer, lpstrAscii, *lpcchRead);
|
---|
750 |
|
---|
751 | HEAP_free(lpstrAscii);
|
---|
752 |
|
---|
753 | return (dwResult); /* deliver return code */
|
---|
754 | }
|
---|
755 |
|
---|
756 |
|
---|
757 | /*****************************************************************************
|
---|
758 | * Name : DWORD HMDeviceConsoleInClass::ReadConsoleInputA
|
---|
759 | * Purpose : read events placed in the console input queue
|
---|
760 | * Parameters: PHMHANDLEDATA pHMHandleData - current handle data
|
---|
761 | * PINPUT_RECORD pirBuffer - target buffer for events
|
---|
762 | * DWORD cInRecords - number of input records
|
---|
763 | * LPDWORD lpcRead - returns number of events stored
|
---|
764 | * Variables :
|
---|
765 | * Result : TRUE if successful, FALSE otherwise
|
---|
766 | * Remark :
|
---|
767 | * Status : UNTESTED
|
---|
768 | *
|
---|
769 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
770 | *****************************************************************************/
|
---|
771 |
|
---|
772 | DWORD HMDeviceConsoleInClass::ReadConsoleInputA(PHMHANDLEDATA pHMHandleData,
|
---|
773 | PINPUT_RECORD pirBuffer,
|
---|
774 | DWORD cInRecords,
|
---|
775 | LPDWORD lpcRead)
|
---|
776 | {
|
---|
777 | ULONG ulPostCounter; /* semaphore post counter - ignored */
|
---|
778 | APIRET rc; /* API returncode */
|
---|
779 |
|
---|
780 | #ifdef DEBUG_LOCAL2
|
---|
781 | WriteLog("KERNEL32/CONSOLE: HMDeviceConsoleInClass::ReadConsoleInputA(%08x,%08x,%08x,%08x).\n",
|
---|
782 | pHMHandleData,
|
---|
783 | pirBuffer,
|
---|
784 | cInRecords,
|
---|
785 | lpcRead);
|
---|
786 | #endif
|
---|
787 |
|
---|
788 | if (iConsoleInputQueryEvents() == 0) /* if queue is currently empty */
|
---|
789 | {
|
---|
790 | rc = DosWaitEventSem(pConsoleInput->hevInputQueue, /* wait for input */
|
---|
791 | SEM_INDEFINITE_WAIT);
|
---|
792 | DosResetEventSem(pConsoleInput->hevInputQueue, /* reset semaphore */
|
---|
793 | &ulPostCounter); /* post counter - ignored */
|
---|
794 | }
|
---|
795 |
|
---|
796 |
|
---|
797 | /* now read events into target buffer */
|
---|
798 | for (ulPostCounter = 0;
|
---|
799 | ulPostCounter < cInRecords;
|
---|
800 | ulPostCounter++,
|
---|
801 | pirBuffer++)
|
---|
802 | {
|
---|
803 | rc = iConsoleInputEventPop(pirBuffer); /* get event from queue */
|
---|
804 | if (rc != NO_ERROR) /* if read error occurs, break look */
|
---|
805 | break;
|
---|
806 | }
|
---|
807 |
|
---|
808 | *lpcRead = ulPostCounter; /* return number of records read */
|
---|
809 | return (TRUE); /* OK */
|
---|
810 | }
|
---|
811 |
|
---|
812 |
|
---|
813 | /*****************************************************************************
|
---|
814 | * Name : DWORD HMDeviceConsoleInClass::ReadConsoleInputW
|
---|
815 | * Purpose : read events placed in the console input queue
|
---|
816 | * Parameters: PHMHANDLEDATA pHMHandleData - current handle data
|
---|
817 | * PINPUT_RECORD pirBuffer - target buffer for events
|
---|
818 | * DWORD cInRecords - number of input records
|
---|
819 | * LPDWORD lpcRead - returns number of events stored
|
---|
820 | * Variables :
|
---|
821 | * Result : TRUE if successful, FALSE otherwise
|
---|
822 | * Remark :
|
---|
823 | * Status : UNTESTED
|
---|
824 | *
|
---|
825 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
826 | *****************************************************************************/
|
---|
827 |
|
---|
828 | DWORD HMDeviceConsoleInClass::ReadConsoleInputW(PHMHANDLEDATA pHMHandleData,
|
---|
829 | PINPUT_RECORD pirBuffer,
|
---|
830 | DWORD cInRecords,
|
---|
831 | LPDWORD lpcRead)
|
---|
832 | {
|
---|
833 | ULONG ulPostCounter; /* semaphore post counter - ignored */
|
---|
834 | APIRET rc; /* API returncode */
|
---|
835 |
|
---|
836 | #ifdef DEBUG_LOCAL2
|
---|
837 | WriteLog("KERNEL32/CONSOLE: HMDeviceConsoleInClass::ReadConsoleInputW(%08x,%08x,%08x,%08x).\n",
|
---|
838 | pHMHandleData,
|
---|
839 | pirBuffer,
|
---|
840 | cInRecords,
|
---|
841 | lpcRead);
|
---|
842 | #endif
|
---|
843 |
|
---|
844 | if (iConsoleInputQueryEvents() == 0) /* if queue is currently empty */
|
---|
845 | {
|
---|
846 | rc = DosWaitEventSem(pConsoleInput->hevInputQueue, /* wait for input */
|
---|
847 | SEM_INDEFINITE_WAIT);
|
---|
848 | DosResetEventSem(pConsoleInput->hevInputQueue, /* reset semaphore */
|
---|
849 | &ulPostCounter); /* post counter - ignored */
|
---|
850 | }
|
---|
851 |
|
---|
852 |
|
---|
853 | /* now read events into target buffer */
|
---|
854 | for (ulPostCounter = 0;
|
---|
855 | ulPostCounter < cInRecords;
|
---|
856 | ulPostCounter++,
|
---|
857 | pirBuffer++)
|
---|
858 | {
|
---|
859 | rc = iConsoleInputEventPop(pirBuffer); /* get event from queue */
|
---|
860 | if (rc != NO_ERROR) /* if read error occurs, break look */
|
---|
861 | break;
|
---|
862 | }
|
---|
863 |
|
---|
864 | *lpcRead = ulPostCounter; /* return number of records read */
|
---|
865 | return (TRUE); /* OK */
|
---|
866 | }
|
---|
867 |
|
---|
868 |
|
---|
869 | /*****************************************************************************
|
---|
870 | * Name : DWORD HMDeviceConsoleInClass::SetConsoleMode
|
---|
871 | * Purpose : sets the current console mode
|
---|
872 | * Parameters: PHMHANDLEDATA pHMHandleData - handle specific data
|
---|
873 | * DWORD dwMode - console mode
|
---|
874 | * Variables :
|
---|
875 | * Result :
|
---|
876 | * Remark :
|
---|
877 | * Status : UNTESTED
|
---|
878 | *
|
---|
879 | * Author : Patrick Haller [Wed, 1998/02/16 11:46]
|
---|
880 | *****************************************************************************/
|
---|
881 |
|
---|
882 | DWORD HMDeviceConsoleInClass::SetConsoleMode(PHMHANDLEDATA pHMHandleData,
|
---|
883 | DWORD dwMode)
|
---|
884 | {
|
---|
885 | PCONSOLEBUFFER pConsoleBuffer = (PCONSOLEBUFFER)pHMHandleData->lpHandlerData;
|
---|
886 |
|
---|
887 | #ifdef DEBUG_LOCAL2
|
---|
888 | WriteLog("KERNEL32/CONSOLE: CONIN$::SetConsoleMode(%08x,%08x).\n",
|
---|
889 | pHMHandleData,
|
---|
890 | dwMode);
|
---|
891 | #endif
|
---|
892 |
|
---|
893 | pConsoleInput->dwConsoleMode = dwMode; /* set current console mode */
|
---|
894 |
|
---|
895 | return (TRUE);
|
---|
896 | }
|
---|
897 |
|
---|
898 |
|
---|
899 | /*****************************************************************************
|
---|
900 | * Name : DWORD HMDeviceConsoleInClass::WriteConsoleInputA
|
---|
901 | * Purpose : this writes event records directly into the queue
|
---|
902 | * Parameters: PHMHANDLEDATA pHMHandleData
|
---|
903 | * PINPUT_RECORD pirBuffer
|
---|
904 | * DWORD cInRecords
|
---|
905 | * LPDWORD lpcWritten
|
---|
906 | * Variables :
|
---|
907 | * Result :
|
---|
908 | * Remark :
|
---|
909 | * Status : NO_ERROR - API succeeded
|
---|
910 | * other - what is to be set in SetLastError
|
---|
911 | *
|
---|
912 | * Author : Patrick Haller [Wed, 1998/02/11 20:44]
|
---|
913 | *****************************************************************************/
|
---|
914 |
|
---|
915 | DWORD HMDeviceConsoleInClass::WriteConsoleInputA (PHMHANDLEDATA pHMHandleData,
|
---|
916 | PINPUT_RECORD pirBuffer,
|
---|
917 | DWORD cInRecords,
|
---|
918 | LPDWORD lpcWritten)
|
---|
919 | {
|
---|
920 | PCONSOLEBUFFER pConsoleBuffer = (PCONSOLEBUFFER)pHMHandleData->lpHandlerData;
|
---|
921 | APIRET rc; /* API returncode */
|
---|
922 | ULONG ulCounter; /* loop counter */
|
---|
923 |
|
---|
924 | #ifdef DEBUG_LOCAL2
|
---|
925 | WriteLog("KERNEL32/CONSOLE: CONIN$::WriteConsoleInputA(%08x,%08x,%u,%08x).\n",
|
---|
926 | pHMHandleData,
|
---|
927 | pirBuffer,
|
---|
928 | cInRecords,
|
---|
929 | lpcWritten);
|
---|
930 | #endif
|
---|
931 |
|
---|
932 | for (ulCounter = 0;
|
---|
933 | ulCounter < cInRecords;
|
---|
934 | ulCounter++,
|
---|
935 | pirBuffer++)
|
---|
936 | {
|
---|
937 | rc = iConsoleInputEventPush(pirBuffer); /* push current event */
|
---|
938 | if (rc != NO_ERROR) /* oops ? queue full ? problem ? */
|
---|
939 | break;
|
---|
940 | }
|
---|
941 |
|
---|
942 | *lpcWritten = ulCounter; /* return number of events written */
|
---|
943 | return (TRUE); /* OK */
|
---|
944 | }
|
---|
945 |
|
---|
946 |
|
---|
947 | /*****************************************************************************
|
---|
948 | * Name : DWORD HMDeviceConsoleInClass::WriteConsoleInputW
|
---|
949 | * Purpose : this writes event records directly into the queue
|
---|
950 | * Parameters: PHMHANDLEDATA pHMHandleData
|
---|
951 | * PINPUT_RECORD pirBuffer
|
---|
952 | * DWORD cInRecords
|
---|
953 | * LPDWORD lpcWritten
|
---|
954 | * Variables :
|
---|
955 | * Result :
|
---|
956 | * Remark :
|
---|
957 | * Status : NO_ERROR - API succeeded
|
---|
958 | * other - what is to be set in SetLastError
|
---|
959 | *
|
---|
960 | * Author : Patrick Haller [Wed, 1998/02/11 20:44]
|
---|
961 | *****************************************************************************/
|
---|
962 |
|
---|
963 | DWORD HMDeviceConsoleInClass::WriteConsoleInputW (PHMHANDLEDATA pHMHandleData,
|
---|
964 | PINPUT_RECORD pirBuffer,
|
---|
965 | DWORD cInRecords,
|
---|
966 | LPDWORD lpcWritten)
|
---|
967 | {
|
---|
968 | PCONSOLEBUFFER pConsoleBuffer = (PCONSOLEBUFFER)pHMHandleData->lpHandlerData;
|
---|
969 | APIRET rc; /* API returncode */
|
---|
970 | ULONG ulCounter; /* loop counter */
|
---|
971 |
|
---|
972 | #ifdef DEBUG_LOCAL2
|
---|
973 | WriteLog("KERNEL32/CONSOLE: CONIN$::WriteConsoleInputW(%08x,%08x,%u,%08x).\n",
|
---|
974 | pHMHandleData,
|
---|
975 | pirBuffer,
|
---|
976 | cInRecords,
|
---|
977 | lpcWritten);
|
---|
978 | #endif
|
---|
979 |
|
---|
980 | for (ulCounter = 0;
|
---|
981 | ulCounter < cInRecords;
|
---|
982 | ulCounter++,
|
---|
983 | pirBuffer++)
|
---|
984 | {
|
---|
985 | rc = iConsoleInputEventPush(pirBuffer); /* push current event */
|
---|
986 | if (rc != NO_ERROR) /* oops ? queue full ? problem ? */
|
---|
987 | break;
|
---|
988 | }
|
---|
989 |
|
---|
990 | *lpcWritten = ulCounter; /* return number of events written */
|
---|
991 | return (TRUE); /* OK */
|
---|
992 | }
|
---|
993 |
|
---|
994 |
|
---|
995 | DWORD HMDeviceConsoleInClass::GetFileType (PHMHANDLEDATA pHMHandleData)
|
---|
996 | {
|
---|
997 | return FILE_TYPE_CHAR;
|
---|
998 | }
|
---|