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

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

overlapped io updates

File size: 6.3 KB
Line 
1/* $Id: hmstd.cpp,v 1.7 2001-12-05 18:06:02 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 LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
72{
73 BOOL bRC;
74 DWORD bytesread;
75
76 dprintf2(("KERNEL32: HMDeviceStandardClass::ReadFile %s(%08x,%08x,%08x,%08x,%08x) - NOT IMPLEMENTED\n",
77 lpHMDeviceName,
78 pHMHandleData,
79 lpBuffer,
80 nNumberOfBytesToRead,
81 lpNumberOfBytesRead,
82 lpOverlapped));
83
84 if(lpCompletionRoutine) {
85 dprintf(("!WARNING!: lpCompletionRoutine not supported -> fall back to sync IO"));
86 }
87
88 if(lpNumberOfBytesRead == NULL) {
89 lpNumberOfBytesRead = &bytesread;
90 }
91 if(pHMHandleData->dwUserData != STD_INPUT_HANDLE) {
92 return FALSE;
93 }
94 return O32_ReadFile(pHMHandleData->hHMHandle, (LPVOID)lpBuffer, nNumberOfBytesToRead,
95 lpNumberOfBytesRead, lpOverlapped);
96}
97
98
99/*****************************************************************************
100 * Name : BOOL HMDeviceStandardClass::WriteFile
101 * Purpose : write data to handle / device
102 * Parameters: PHMHANDLEDATA pHMHandleData,
103 * LPCVOID lpBuffer,
104 * DWORD nNumberOfBytesToWrite,
105 * LPDWORD lpNumberOfBytesWritten,
106 * LPOVERLAPPED lpOverlapped
107 * Variables :
108 * Result : Boolean
109 * Remark :
110 * Status :
111 *
112 * Author : Patrick Haller [Wed, 1998/02/11 20:44]
113 *****************************************************************************/
114
115BOOL HMDeviceStandardClass::WriteFile(PHMHANDLEDATA pHMHandleData,
116 LPCVOID lpBuffer,
117 DWORD nNumberOfBytesToWrite,
118 LPDWORD lpNumberOfBytesWritten,
119 LPOVERLAPPED lpOverlapped,
120 LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
121{
122 DWORD byteswritten;
123 LPVOID lpLowMemBuffer;
124
125 dprintf(("KERNEL32: HMDeviceStandardClass::WriteFile %s(%08x,%08x,%08x,%08x,%08x)",
126 lpHMDeviceName,
127 pHMHandleData,
128 lpBuffer,
129 nNumberOfBytesToWrite,
130 lpNumberOfBytesWritten,
131 lpOverlapped));
132 if(lpNumberOfBytesWritten == NULL) {
133 lpNumberOfBytesWritten = &byteswritten;
134 }
135 if(lpCompletionRoutine) {
136 dprintf(("!WARNING!: lpCompletionRoutine not supported -> fall back to sync IO"));
137 }
138
139 if(pHMHandleData->dwUserData == STD_INPUT_HANDLE) {
140 return FALSE;
141 }
142 lpLowMemBuffer = alloca(nNumberOfBytesToWrite);
143 if(lpLowMemBuffer == NULL) {
144 DebugInt3();
145 return FALSE;
146 }
147 memcpy(lpLowMemBuffer, lpBuffer, nNumberOfBytesToWrite);
148 if(pHMHandleData->dwUserData == STD_ERROR_HANDLE) {
149 dprintf(("STDERR: %s", lpLowMemBuffer));
150 return TRUE;
151 }
152 if(WinExe && !WinExe->isConsoleApp()) {
153 //DosWrite returns error 436 when PM apps try to write to std out
154 dprintf(("STDOUT (GUI): %s", lpLowMemBuffer));
155 return TRUE;
156 }
157 return O32_WriteFile(pHMHandleData->hHMHandle, lpLowMemBuffer, nNumberOfBytesToWrite,
158 lpNumberOfBytesWritten, lpOverlapped);
159}
160
161
162/*****************************************************************************
163 * Name : DWORD HMDeviceStandardClass::GetFileType
164 * Purpose : determine the handle type
165 * Parameters: PHMHANDLEDATA pHMHandleData
166 * Variables :
167 * Result : API returncode
168 * Remark :
169 * Status :
170 *
171 * Author : Patrick Haller [Wed, 1998/02/11 20:44]
172 *****************************************************************************/
173
174DWORD HMDeviceStandardClass::GetFileType(PHMHANDLEDATA pHMHandleData)
175{
176 dprintf2(("KERNEL32: HMDeviceStandardClass::GetFileType %s(%08x)\n",
177 lpHMDeviceName,
178 pHMHandleData));
179
180 return FILE_TYPE_CHAR;
181}
Note: See TracBrowser for help on using the repository browser.