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

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

preliminary changes for new overlapped io framework

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