blob: 22dfdf143ea1e0db84f1aded3b88fd8fd5a59bd5 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
#define WIN32_ONLY
#include <posix/sys/types.h>
#include <posix/termios.h>
#include "psxses.h"
#include <io.h>
#include <stdio.h>
#include <memory.h>
#include <string.h>
DWORD InputModeFlags;
DWORD OutputModeFlags; /* Console Output Mode */
unsigned char AnsiNewMode;
struct termios SavedTermios;
BOOL
ServeTcRequest(
PSCTCREQUEST PReq,
PVOID PStatus
)
{
DWORD Rc = 0;
// BUGBUG! error code and returned Status are wrong
switch ( PReq->Request ) {
case TcGetAttr:
memcpy(&PReq->Termios, &SavedTermios, sizeof(struct termios));
break;
case TcSetAttr:
// Don't play this game if the tricky input stuff hasn't been
// enabled.
if (!DoTrickyIO)
return 0;
AnsiNewMode = TRUE;
memcpy(&SavedTermios, &PReq->Termios, sizeof(struct termios));
InputModeFlags = 0;
if (PReq->Termios.c_lflag & ICANON) {
InputModeFlags |= ENABLE_LINE_INPUT;
} else {
InputModeFlags &= ~ENABLE_LINE_INPUT;
}
if (PReq->Termios.c_lflag & ECHO) {
// If you want ECHO_INPUT, you need LINE_INPUT, too.
InputModeFlags |= (ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT);
} else {
InputModeFlags &= ~ENABLE_ECHO_INPUT;
}
if (PReq->Termios.c_lflag & ISIG)
InputModeFlags |= ENABLE_PROCESSED_INPUT;
else
InputModeFlags &= ~ENABLE_PROCESSED_INPUT;
if (!SetConsoleMode(hConsoleInput, InputModeFlags)) {
KdPrint(("PSXSES: SetConsoleMode: %d\n", GetLastError()));
*(PDWORD)PStatus = (DWORD)-1L;
return 1;
}
break;
default:
*(PDWORD)PStatus = (DWORD)-1L; //STATUS_INVALID_PARAMETER;
Rc = 1;
break;
}
#if 1
*(PDWORD) PStatus = (Rc) ? GetLastError() : 0;
#else
if ( !Rc ) {
*(PDWORD) PStatus = 0;
} else {
*(PDWORD) PStatus = GetLastError();
}
#endif
return(TRUE);
}
|