source: trunk/src/kernel32/hmstd.cpp@ 6666

Last change on this file since 6666 was 6511, checked in by sandervl, 24 years ago

minor updates

File size: 9.4 KB
Line 
1/* $Id: hmstd.cpp,v 1.5 2001-08-10 19:32:28 sandervl Exp $ */
2
3/*
4 * Handle Manager class for standard in, out & error handles
5 *
6 * Project Odin Software License can be found in LICENSE.TXT
7 * Win32 Unified Handle Manager for OS/2
8 * Copyright 1999 Patrick Haller (haller@zebra.fh-weingarten.de)
9 */
10
11
12/*****************************************************************************
13 * Remark *
14 *****************************************************************************
15
16 */
17
18
19/*****************************************************************************
20 * Includes *
21 *****************************************************************************/
22
23#include <os2win.h>
24#include <stdlib.h>
25#include <string.h>
26#include <unicode.h>
27#include <misc.h>
28
29#include "HandleManager.H"
30#include "hmstd.h"
31#include "winexebase.h"
32
33#define DBG_LOCALLOG DBG_hmstd
34#include "dbglocal.h"
35
36/*****************************************************************************
37 * Defines *
38 *****************************************************************************/
39
40/*****************************************************************************
41 * Structures *
42 *****************************************************************************/
43
44/*****************************************************************************
45 * Local Prototypes *
46 *****************************************************************************/
47
48
49
50/*****************************************************************************
51 * Name : BOOL HMDeviceStandardClass::ReadFile
52 * Purpose : read data from handle / device
53 * Parameters: PHMHANDLEDATA pHMHandleData,
54 * LPCVOID lpBuffer,
55 * DWORD nNumberOfBytesToRead,
56 * LPDWORD lpNumberOfBytesRead,
57 * LPOVERLAPPED lpOverlapped
58 * Variables :
59 * Result : Boolean
60 * Remark :
61 * Status :
62 *
63 * Author : Patrick Haller [Wed, 1998/02/11 20:44]
64 *****************************************************************************/
65
66BOOL HMDeviceStandardClass::ReadFile(PHMHANDLEDATA pHMHandleData,
67 LPCVOID lpBuffer,
68 DWORD nNumberOfBytesToRead,
69 LPDWORD lpNumberOfBytesRead,
70 LPOVERLAPPED lpOverlapped)
71{
72 BOOL bRC;
73 DWORD bytesread;
74
75 dprintf2(("KERNEL32: HMDeviceStandardClass::ReadFile %s(%08x,%08x,%08x,%08x,%08x) - NOT IMPLEMENTED\n",
76 lpHMDeviceName,
77 pHMHandleData,
78 lpBuffer,
79 nNumberOfBytesToRead,
80 lpNumberOfBytesRead,
81 lpOverlapped));
82
83
84 if(lpNumberOfBytesRead == NULL) {
85 lpNumberOfBytesRead = &bytesread;
86 }
87 if(pHMHandleData->dwUserData != STD_INPUT_HANDLE) {
88 return FALSE;
89 }
90 return O32_ReadFile(pHMHandleData->hHMHandle, (LPVOID)lpBuffer, nNumberOfBytesToRead,
91 lpNumberOfBytesRead, lpOverlapped);
92}
93
94/*****************************************************************************
95 * Name : BOOL ReadFileEx
96 * Purpose : The ReadFileEx function reads data from a file asynchronously.
97 * It is designed solely for asynchronous operation, unlike the
98 * ReadFile function, which is designed for both synchronous and
99 * asynchronous operation. ReadFileEx lets an application perform
100 * other processing during a file read operation.
101 * The ReadFileEx function reports its completion status asynchronously,
102 * calling a specified completion routine when reading is completed
103 * and the calling thread is in an alertable wait state.
104 * Parameters: HANDLE hFile handle of file to read
105 * LPVOID lpBuffer address of buffer
106 * DWORD nNumberOfBytesToRead number of bytes to read
107 * LPOVERLAPPED lpOverlapped address of offset
108 * LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine address of completion routine
109 * Variables :
110 * Result : TRUE / FALSE
111 * Remark :
112 * Status : UNTESTED STUB
113 *
114 * Author : Patrick Haller [Mon, 1998/06/15 08:00]
115 *****************************************************************************/
116BOOL HMDeviceStandardClass::ReadFileEx(PHMHANDLEDATA pHMHandleData,
117 LPVOID lpBuffer,
118 DWORD nNumberOfBytesToRead,
119 LPOVERLAPPED lpOverlapped,
120 LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
121{
122 dprintf(("ERROR: ReadFileEx(%08xh,%08xh,%08xh,%08xh,%08xh) not implemented.\n",
123 pHMHandleData->hHMHandle,
124 lpBuffer,
125 nNumberOfBytesToRead,
126 lpOverlapped,
127 lpCompletionRoutine));
128
129 return FALSE;
130}
131
132
133/*****************************************************************************
134 * Name : BOOL HMDeviceStandardClass::WriteFile
135 * Purpose : write data to handle / device
136 * Parameters: PHMHANDLEDATA pHMHandleData,
137 * LPCVOID lpBuffer,
138 * DWORD nNumberOfBytesToWrite,
139 * LPDWORD lpNumberOfBytesWritten,
140 * LPOVERLAPPED lpOverlapped
141 * Variables :
142 * Result : Boolean
143 * Remark :
144 * Status :
145 *
146 * Author : Patrick Haller [Wed, 1998/02/11 20:44]
147 *****************************************************************************/
148
149BOOL HMDeviceStandardClass::WriteFile(PHMHANDLEDATA pHMHandleData,
150 LPCVOID lpBuffer,
151 DWORD nNumberOfBytesToWrite,
152 LPDWORD lpNumberOfBytesWritten,
153 LPOVERLAPPED lpOverlapped)
154{
155 DWORD byteswritten;
156 LPVOID lpLowMemBuffer;
157
158 dprintf(("KERNEL32: HMDeviceStandardClass::WriteFile %s(%08x,%08x,%08x,%08x,%08x)",
159 lpHMDeviceName,
160 pHMHandleData,
161 lpBuffer,
162 nNumberOfBytesToWrite,
163 lpNumberOfBytesWritten,
164 lpOverlapped));
165 if(lpNumberOfBytesWritten == NULL) {
166 lpNumberOfBytesWritten = &byteswritten;
167 }
168 if(pHMHandleData->dwUserData == STD_INPUT_HANDLE) {
169 return FALSE;
170 }
171 lpLowMemBuffer = alloca(nNumberOfBytesToWrite);
172 if(lpLowMemBuffer == NULL) {
173 DebugInt3();
174 return FALSE;
175 }
176 memcpy(lpLowMemBuffer, lpBuffer, nNumberOfBytesToWrite);
177 if(pHMHandleData->dwUserData == STD_ERROR_HANDLE) {
178 dprintf(("STDERR: %s", lpLowMemBuffer));
179 return TRUE;
180 }
181 if(WinExe && !WinExe->isConsoleApp()) {
182 //DosWrite returns error 436 when PM apps try to write to std out
183 dprintf(("STDOUT (GUI): %s", lpLowMemBuffer));
184 return TRUE;
185 }
186 return O32_WriteFile(pHMHandleData->hHMHandle, lpLowMemBuffer, nNumberOfBytesToWrite,
187 lpNumberOfBytesWritten, lpOverlapped);
188}
189
190/*****************************************************************************
191 * Name : BOOL WriteFileEx
192 * Purpose : The WriteFileEx function writes data to a file. It is designed
193 * solely for asynchronous operation, unlike WriteFile, which is
194 * designed for both synchronous and asynchronous operation.
195 * WriteFileEx reports its completion status asynchronously,
196 * calling a specified completion routine when writing is completed
197 * and the calling thread is in an alertable wait state.
198 * Parameters: HANDLE hFile handle of file to write
199 * LPVOID lpBuffer address of buffer
200 * DWORD nNumberOfBytesToRead number of bytes to write
201 * LPOVERLAPPED lpOverlapped address of offset
202 * LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine address of completion routine
203 * Variables :
204 * Result : TRUE / FALSE
205 * Remark :
206 * Status : UNTESTED STUB
207 *
208 * Author : Patrick Haller [Mon, 1998/06/15 08:00]
209 *****************************************************************************/
210
211BOOL HMDeviceStandardClass::WriteFileEx(PHMHANDLEDATA pHMHandleData,
212 LPVOID lpBuffer,
213 DWORD nNumberOfBytesToWrite,
214 LPOVERLAPPED lpOverlapped,
215 LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
216{
217 dprintf(("ERROR: WriteFileEx(%08xh,%08xh,%08xh,%08xh,%08xh) not implemented.\n",
218 pHMHandleData->hHMHandle,
219 lpBuffer,
220 nNumberOfBytesToWrite,
221 lpOverlapped,
222 lpCompletionRoutine));
223 return FALSE;
224}
225
226/*****************************************************************************
227 * Name : DWORD HMDeviceStandardClass::GetFileType
228 * Purpose : determine the handle type
229 * Parameters: PHMHANDLEDATA pHMHandleData
230 * Variables :
231 * Result : API returncode
232 * Remark :
233 * Status :
234 *
235 * Author : Patrick Haller [Wed, 1998/02/11 20:44]
236 *****************************************************************************/
237
238DWORD HMDeviceStandardClass::GetFileType(PHMHANDLEDATA pHMHandleData)
239{
240 dprintf2(("KERNEL32: HMDeviceStandardClass::GetFileType %s(%08x)\n",
241 lpHMDeviceName,
242 pHMHandleData));
243
244 return FILE_TYPE_CHAR;
245}
Note: See TracBrowser for help on using the repository browser.