| 1 | /* $Id: hmstd.cpp,v 1.1 2001-01-23 18:31:26 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 |
|
|---|
| 32 | #define DBG_LOCALLOG DBG_hmstd
|
|---|
| 33 | #include "dbglocal.h"
|
|---|
| 34 |
|
|---|
| 35 | /*****************************************************************************
|
|---|
| 36 | * Defines *
|
|---|
| 37 | *****************************************************************************/
|
|---|
| 38 |
|
|---|
| 39 | /*****************************************************************************
|
|---|
| 40 | * Structures *
|
|---|
| 41 | *****************************************************************************/
|
|---|
| 42 |
|
|---|
| 43 | /*****************************************************************************
|
|---|
| 44 | * Local Prototypes *
|
|---|
| 45 | *****************************************************************************/
|
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 |
|
|---|
| 49 | /*****************************************************************************
|
|---|
| 50 | * Name : BOOL HMDeviceStandardClass::ReadFile
|
|---|
| 51 | * Purpose : read data from handle / device
|
|---|
| 52 | * Parameters: PHMHANDLEDATA pHMHandleData,
|
|---|
| 53 | * LPCVOID lpBuffer,
|
|---|
| 54 | * DWORD nNumberOfBytesToRead,
|
|---|
| 55 | * LPDWORD lpNumberOfBytesRead,
|
|---|
| 56 | * LPOVERLAPPED lpOverlapped
|
|---|
| 57 | * Variables :
|
|---|
| 58 | * Result : Boolean
|
|---|
| 59 | * Remark :
|
|---|
| 60 | * Status :
|
|---|
| 61 | *
|
|---|
| 62 | * Author : Patrick Haller [Wed, 1998/02/11 20:44]
|
|---|
| 63 | *****************************************************************************/
|
|---|
| 64 |
|
|---|
| 65 | BOOL HMDeviceStandardClass::ReadFile(PHMHANDLEDATA pHMHandleData,
|
|---|
| 66 | LPCVOID lpBuffer,
|
|---|
| 67 | DWORD nNumberOfBytesToRead,
|
|---|
| 68 | LPDWORD lpNumberOfBytesRead,
|
|---|
| 69 | LPOVERLAPPED lpOverlapped)
|
|---|
| 70 | {
|
|---|
| 71 | BOOL bRC;
|
|---|
| 72 |
|
|---|
| 73 | dprintf2(("KERNEL32: HMDeviceStandardClass::ReadFile %s(%08x,%08x,%08x,%08x,%08x) - NOT IMPLEMENTED\n",
|
|---|
| 74 | lpHMDeviceName,
|
|---|
| 75 | pHMHandleData,
|
|---|
| 76 | lpBuffer,
|
|---|
| 77 | nNumberOfBytesToRead,
|
|---|
| 78 | lpNumberOfBytesRead,
|
|---|
| 79 | lpOverlapped));
|
|---|
| 80 |
|
|---|
| 81 |
|
|---|
| 82 | return FALSE;
|
|---|
| 83 | }
|
|---|
| 84 |
|
|---|
| 85 | /*****************************************************************************
|
|---|
| 86 | * Name : BOOL ReadFileEx
|
|---|
| 87 | * Purpose : The ReadFileEx function reads data from a file asynchronously.
|
|---|
| 88 | * It is designed solely for asynchronous operation, unlike the
|
|---|
| 89 | * ReadFile function, which is designed for both synchronous and
|
|---|
| 90 | * asynchronous operation. ReadFileEx lets an application perform
|
|---|
| 91 | * other processing during a file read operation.
|
|---|
| 92 | * The ReadFileEx function reports its completion status asynchronously,
|
|---|
| 93 | * calling a specified completion routine when reading is completed
|
|---|
| 94 | * and the calling thread is in an alertable wait state.
|
|---|
| 95 | * Parameters: HANDLE hFile handle of file to read
|
|---|
| 96 | * LPVOID lpBuffer address of buffer
|
|---|
| 97 | * DWORD nNumberOfBytesToRead number of bytes to read
|
|---|
| 98 | * LPOVERLAPPED lpOverlapped address of offset
|
|---|
| 99 | * LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine address of completion routine
|
|---|
| 100 | * Variables :
|
|---|
| 101 | * Result : TRUE / FALSE
|
|---|
| 102 | * Remark :
|
|---|
| 103 | * Status : UNTESTED STUB
|
|---|
| 104 | *
|
|---|
| 105 | * Author : Patrick Haller [Mon, 1998/06/15 08:00]
|
|---|
| 106 | *****************************************************************************/
|
|---|
| 107 | BOOL HMDeviceStandardClass::ReadFileEx(PHMHANDLEDATA pHMHandleData,
|
|---|
| 108 | LPVOID lpBuffer,
|
|---|
| 109 | DWORD nNumberOfBytesToRead,
|
|---|
| 110 | LPOVERLAPPED lpOverlapped,
|
|---|
| 111 | LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
|
|---|
| 112 | {
|
|---|
| 113 | dprintf(("ERROR: ReadFileEx(%08xh,%08xh,%08xh,%08xh,%08xh) not implemented.\n",
|
|---|
| 114 | pHMHandleData->hHMHandle,
|
|---|
| 115 | lpBuffer,
|
|---|
| 116 | nNumberOfBytesToRead,
|
|---|
| 117 | lpOverlapped,
|
|---|
| 118 | lpCompletionRoutine));
|
|---|
| 119 |
|
|---|
| 120 | return FALSE;
|
|---|
| 121 | }
|
|---|
| 122 |
|
|---|
| 123 |
|
|---|
| 124 | /*****************************************************************************
|
|---|
| 125 | * Name : BOOL HMDeviceStandardClass::WriteFile
|
|---|
| 126 | * Purpose : write data to handle / device
|
|---|
| 127 | * Parameters: PHMHANDLEDATA pHMHandleData,
|
|---|
| 128 | * LPCVOID lpBuffer,
|
|---|
| 129 | * DWORD nNumberOfBytesToWrite,
|
|---|
| 130 | * LPDWORD lpNumberOfBytesWritten,
|
|---|
| 131 | * LPOVERLAPPED lpOverlapped
|
|---|
| 132 | * Variables :
|
|---|
| 133 | * Result : Boolean
|
|---|
| 134 | * Remark :
|
|---|
| 135 | * Status :
|
|---|
| 136 | *
|
|---|
| 137 | * Author : Patrick Haller [Wed, 1998/02/11 20:44]
|
|---|
| 138 | *****************************************************************************/
|
|---|
| 139 |
|
|---|
| 140 | BOOL HMDeviceStandardClass::WriteFile(PHMHANDLEDATA pHMHandleData,
|
|---|
| 141 | LPCVOID lpBuffer,
|
|---|
| 142 | DWORD nNumberOfBytesToWrite,
|
|---|
| 143 | LPDWORD lpNumberOfBytesWritten,
|
|---|
| 144 | LPOVERLAPPED lpOverlapped)
|
|---|
| 145 | {
|
|---|
| 146 | DWORD byteswritten;
|
|---|
| 147 |
|
|---|
| 148 | dprintf2(("KERNEL32: HMDeviceStandardClass::WriteFile %s(%08x,%08x,%08x,%08x,%08x) - stub?\n",
|
|---|
| 149 | lpHMDeviceName,
|
|---|
| 150 | pHMHandleData,
|
|---|
| 151 | lpBuffer,
|
|---|
| 152 | nNumberOfBytesToWrite,
|
|---|
| 153 | lpNumberOfBytesWritten,
|
|---|
| 154 | lpOverlapped));
|
|---|
| 155 | if(lpNumberOfBytesWritten == NULL) {
|
|---|
| 156 | lpNumberOfBytesWritten = &byteswritten;
|
|---|
| 157 | }
|
|---|
| 158 | if(pHMHandleData->dwUserData == STD_INPUT_HANDLE) {
|
|---|
| 159 | return FALSE;
|
|---|
| 160 | }
|
|---|
| 161 | return O32_WriteFile(pHMHandleData->hHMHandle, lpBuffer, nNumberOfBytesToWrite,
|
|---|
| 162 | lpNumberOfBytesWritten, lpOverlapped);
|
|---|
| 163 | }
|
|---|
| 164 |
|
|---|
| 165 | /*****************************************************************************
|
|---|
| 166 | * Name : BOOL WriteFileEx
|
|---|
| 167 | * Purpose : The WriteFileEx function writes data to a file. It is designed
|
|---|
| 168 | * solely for asynchronous operation, unlike WriteFile, which is
|
|---|
| 169 | * designed for both synchronous and asynchronous operation.
|
|---|
| 170 | * WriteFileEx reports its completion status asynchronously,
|
|---|
| 171 | * calling a specified completion routine when writing is completed
|
|---|
| 172 | * and the calling thread is in an alertable wait state.
|
|---|
| 173 | * Parameters: HANDLE hFile handle of file to write
|
|---|
| 174 | * LPVOID lpBuffer address of buffer
|
|---|
| 175 | * DWORD nNumberOfBytesToRead number of bytes to write
|
|---|
| 176 | * LPOVERLAPPED lpOverlapped address of offset
|
|---|
| 177 | * LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine address of completion routine
|
|---|
| 178 | * Variables :
|
|---|
| 179 | * Result : TRUE / FALSE
|
|---|
| 180 | * Remark :
|
|---|
| 181 | * Status : UNTESTED STUB
|
|---|
| 182 | *
|
|---|
| 183 | * Author : Patrick Haller [Mon, 1998/06/15 08:00]
|
|---|
| 184 | *****************************************************************************/
|
|---|
| 185 |
|
|---|
| 186 | BOOL HMDeviceStandardClass::WriteFileEx(PHMHANDLEDATA pHMHandleData,
|
|---|
| 187 | LPVOID lpBuffer,
|
|---|
| 188 | DWORD nNumberOfBytesToWrite,
|
|---|
| 189 | LPOVERLAPPED lpOverlapped,
|
|---|
| 190 | LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
|
|---|
| 191 | {
|
|---|
| 192 | dprintf(("ERROR: WriteFileEx(%08xh,%08xh,%08xh,%08xh,%08xh) not implemented.\n",
|
|---|
| 193 | pHMHandleData->hHMHandle,
|
|---|
| 194 | lpBuffer,
|
|---|
| 195 | nNumberOfBytesToWrite,
|
|---|
| 196 | lpOverlapped,
|
|---|
| 197 | lpCompletionRoutine));
|
|---|
| 198 | return FALSE;
|
|---|
| 199 | }
|
|---|
| 200 |
|
|---|
| 201 | /*****************************************************************************
|
|---|
| 202 | * Name : DWORD HMDeviceStandardClass::GetFileType
|
|---|
| 203 | * Purpose : determine the handle type
|
|---|
| 204 | * Parameters: PHMHANDLEDATA pHMHandleData
|
|---|
| 205 | * Variables :
|
|---|
| 206 | * Result : API returncode
|
|---|
| 207 | * Remark :
|
|---|
| 208 | * Status :
|
|---|
| 209 | *
|
|---|
| 210 | * Author : Patrick Haller [Wed, 1998/02/11 20:44]
|
|---|
| 211 | *****************************************************************************/
|
|---|
| 212 |
|
|---|
| 213 | DWORD HMDeviceStandardClass::GetFileType(PHMHANDLEDATA pHMHandleData)
|
|---|
| 214 | {
|
|---|
| 215 | dprintf2(("KERNEL32: HMDeviceStandardClass::GetFileType %s(%08x)\n",
|
|---|
| 216 | lpHMDeviceName,
|
|---|
| 217 | pHMHandleData));
|
|---|
| 218 |
|
|---|
| 219 | return FILE_TYPE_CHAR;
|
|---|
| 220 | }
|
|---|