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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
|
/*++
Copyright (c) 1989 Microsoft Corporation
Module Name:
conrqust.c
Abstract:
This module contains the handler for console requests.
Author:
Avi Nathan (avin) 17-Jul-1991
Environment:
User Mode Only
Revision History:
--*/
#define WIN32_ONLY
#include "os2ses.h"
#include "event.h"
#include "trans.h"
#include "os2win.h"
#include <io.h>
#include <stdio.h>
#if DBG
BYTE Ow2ConReadFileStr[] = "Ow2ConReadFile";
BYTE Ow2ConWriteFileStr[] = "Ow2ConWriteFile";
BYTE Ow2ConCloseHandleStr[] = "Ow2ConCloseHandle";
BYTE Ow2ConBeepStr[] = "Ow2ConBeep";
#endif
DWORD
Ow2ConReadFile(
IN HANDLE hFile,
IN ULONG Length,
OUT PVOID Buffer,
OUT PULONG BytesRead
)
{
DWORD Rc;
if (Or2WinReadFile(
#if DBG
Ow2ConReadFileStr,
#endif
hFile,
Buffer,
Length,
BytesRead,
NULL
)) {
#if DBG
if (Length != *BytesRead)
{
IF_OD2_DEBUG( OS2_EXE )
KdPrint(("OS2SES(ConRqust-Ow2ConReadFile): partial data: %lu from %lu\n",
*BytesRead, Length));
}
#endif
return(NO_ERROR);
} else {
Rc = GetLastError();
if (Rc == ERROR_BROKEN_PIPE) {
//
// This is a special case. It's returned if we're reading
// from a pipe, and the other side closed the pipe. In this
// case, we simulate a closed file
//
*BytesRead = 0;
return(NO_ERROR);
}
#if DBG
KdPrint(( "OS2SES(ConRqust-Ow2ConReadFile): ReadFile: Rc %lu\n", Rc));
#endif
*BytesRead = 0;
return(Rc);
}
}
DWORD
Ow2ConWriteFile(
IN HANDLE hFile,
IN ULONG Length,
IN PVOID Buffer,
OUT PULONG BytesWritten
)
{
DWORD Rc;
if (Or2WinWriteFile(
#if DBG
Ow2ConWriteFileStr,
#endif
hFile,
Buffer,
Length,
BytesWritten,
NULL))
{
#if DBG
if (Length != *BytesWritten)
{
IF_OD2_DEBUG( OS2_EXE )
KdPrint(("OS2SES(ConRqust-Ow2ConWriteFile): partial data: %lu from %lu\n",
*BytesWritten, Length));
}
#endif
return(NO_ERROR);
} else
{
Rc = GetLastError();
#if DBG
KdPrint(( "OS2SES(ConRqust-Ow2ConWriteFile): WriteFile: Rc %lu\n", Rc));
#endif
*BytesWritten = 0;
return(Rc);
}
}
DWORD
Ow2ConCloseHandle(
IN HANDLE hFile
)
{
DWORD Rc;
if ((hFile == hConsoleOutput) ||
(hFile == hConsoleInput))
{
#if DBG
KdPrint(("OS2SES(ConRqust-ScCloseHandle): Std-handle\n"));
#endif
return(NO_ERROR);
}else
{
if (Or2WinCloseHandle(
#if DBG
Ow2ConCloseHandleStr,
#endif
hFile))
{
return(NO_ERROR);
} else
{
Rc = GetLastError();
#if DBG
KdPrint(( "OS2SES(ConRqust-Ow2ConCloseHandle): CloseHandle: Rc %lu\n", Rc));
#endif
return(Rc);
}
}
}
DWORD
Ow2ConBeep(
IN ULONG dwFreq,
IN ULONG dwDuration
)
{
DWORD Rc;
if(Or2WinBeep(
#if DBG
Ow2ConBeepStr,
#endif
dwFreq,
dwDuration
))
{
return(NO_ERROR);
} else
{
Rc = GetLastError();
#if DBG
KdPrint(( "OS2SES(ConRqust-Ow2ConBeep): Beep: Rc %lu\n", Rc));
#endif
return(Rc);
}
}
|