1 | /* $Id: async.cpp,v 1.4 1999-06-17 18:21:37 phaller Exp $ */
|
---|
2 |
|
---|
3 | /*
|
---|
4 | * Win32 Asynchronous I/O Subsystem for OS/2
|
---|
5 | *
|
---|
6 | * 1998/04/10 PH Patrick Haller (haller@zebra.fh-weingarten.de)
|
---|
7 | *
|
---|
8 | * @(#) Async.Cpp 1.0.0 1998/04/10 PH start
|
---|
9 | *
|
---|
10 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
11 | *
|
---|
12 | */
|
---|
13 |
|
---|
14 | #ifndef _ASYNCIOSUBSYSTEM_H_
|
---|
15 | #define _ASYNCIOSUBSYSTEM_H_
|
---|
16 |
|
---|
17 |
|
---|
18 | /*****************************************************************************
|
---|
19 | * Remark *
|
---|
20 | *****************************************************************************
|
---|
21 |
|
---|
22 | ReadFileEx
|
---|
23 |
|
---|
24 | */
|
---|
25 |
|
---|
26 |
|
---|
27 |
|
---|
28 | /*****************************************************************************
|
---|
29 | * Includes *
|
---|
30 | *****************************************************************************/
|
---|
31 |
|
---|
32 | #define INCL_WIN
|
---|
33 | #define INCL_DOSMEMMGR
|
---|
34 | #define INCL_DOSSEMAPHORES
|
---|
35 | #define INCL_DOSERRORS
|
---|
36 | #define INCL_DOSPROCESS
|
---|
37 | #define INCL_DOSMODULEMGR
|
---|
38 | #define INCL_VIO
|
---|
39 | #define INCL_AVIO
|
---|
40 | #include <os2.h>
|
---|
41 | #include <builtin.h>
|
---|
42 |
|
---|
43 | #include <stdlib.h>
|
---|
44 | #include <string.h>
|
---|
45 | #include "win32type.h"
|
---|
46 | #include "misc.h"
|
---|
47 | #include "unicode.h"
|
---|
48 |
|
---|
49 | // PH: to soothe the compiler
|
---|
50 | #define BY_HANDLE_FILE_INFORMATION void
|
---|
51 | #define LPFILETIME void*
|
---|
52 | #define OFSTRUCT void
|
---|
53 |
|
---|
54 | #include "handlemanager.h"
|
---|
55 |
|
---|
56 |
|
---|
57 | /*****************************************************************************
|
---|
58 | * Defines & Macros *
|
---|
59 | *****************************************************************************/
|
---|
60 |
|
---|
61 |
|
---|
62 | /*****************************************************************************
|
---|
63 | * Structures *
|
---|
64 | *****************************************************************************/
|
---|
65 |
|
---|
66 | typedef struct _IORequest
|
---|
67 | {
|
---|
68 | struct _IORequest *pNext; /* pointer to next I/O request */
|
---|
69 |
|
---|
70 | APIRET rc; /* result code of I/O request */
|
---|
71 |
|
---|
72 | } IOREQUEST, *PIOREQUEST;
|
---|
73 |
|
---|
74 |
|
---|
75 | typedef struct _Globals
|
---|
76 | {
|
---|
77 | HEV hevIOEvent; /* asynchronous I/O event completed ! */
|
---|
78 | TID tidIO; /* I/O thread */
|
---|
79 | } GLOBALS, *PGLOBALS;
|
---|
80 |
|
---|
81 | static GLOBALS Globals;
|
---|
82 |
|
---|
83 |
|
---|
84 | /*****************************************************************************
|
---|
85 | * Name :
|
---|
86 | * Purpose :
|
---|
87 | * Parameters:
|
---|
88 | * Variables :
|
---|
89 | * Result :
|
---|
90 | * Remark :
|
---|
91 | * Status :
|
---|
92 | *
|
---|
93 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
94 | *****************************************************************************/
|
---|
95 |
|
---|
96 | DWORD WIN32API SleepEx(DWORD dwTimeout,
|
---|
97 | BOOL fAlertable)
|
---|
98 | {
|
---|
99 |
|
---|
100 | dprintf(("KERNEL32: SleepEx(%u,%u)\n",
|
---|
101 | dwTimeout,
|
---|
102 | fAlertable));
|
---|
103 |
|
---|
104 | /* @@@PH could be implemented as a timed wait on a event semaphore */
|
---|
105 | /* for the WAIT_IO_COMPLETION flag */
|
---|
106 |
|
---|
107 | if (fAlertable == FALSE)
|
---|
108 | DosSleep(dwTimeout);
|
---|
109 | else {
|
---|
110 | dprintf(("SleepEx: Wait for io completion not supported!"));
|
---|
111 | DosSleep(1);
|
---|
112 | }
|
---|
113 |
|
---|
114 | return (0);
|
---|
115 | }
|
---|
116 |
|
---|
117 |
|
---|
118 | /*****************************************************************************
|
---|
119 | * Name : BOOL ReadFileEx
|
---|
120 | * Purpose : The ReadFileEx function reads data from a file asynchronously.
|
---|
121 | * It is designed solely for asynchronous operation, unlike the
|
---|
122 | * ReadFile function, which is designed for both synchronous and
|
---|
123 | * asynchronous operation. ReadFileEx lets an application perform
|
---|
124 | * other processing during a file read operation.
|
---|
125 | * The ReadFileEx function reports its completion status asynchronously,
|
---|
126 | * calling a specified completion routine when reading is completed
|
---|
127 | * and the calling thread is in an alertable wait state.
|
---|
128 | * Parameters: HANDLE hFile handle of file to read
|
---|
129 | * LPVOID lpBuffer address of buffer
|
---|
130 | * DWORD nNumberOfBytesToRead number of bytes to read
|
---|
131 | * LPOVERLAPPED lpOverlapped address of offset
|
---|
132 | * LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine address of completion routine
|
---|
133 | * Variables :
|
---|
134 | * Result : TRUE / FALSE
|
---|
135 | * Remark :
|
---|
136 | * Status : UNTESTED STUB
|
---|
137 | *
|
---|
138 | * Author : Patrick Haller [Mon, 1998/06/15 08:00]
|
---|
139 | *****************************************************************************/
|
---|
140 |
|
---|
141 | #define LPOVERLAPPED_COMPLETION_ROUTINE LPVOID
|
---|
142 |
|
---|
143 | DWORD WIN32API ReadFileEx(HANDLE hFile,
|
---|
144 | LPVOID lpBuffer,
|
---|
145 | DWORD nNumberOfBytesToRead,
|
---|
146 | LPOVERLAPPED lpOverlapped,
|
---|
147 | LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
|
---|
148 | {
|
---|
149 | dprintf(("Kernel32: ReadFileEx(%08xh,%08xh,%08xh,%08xh,%08xh) not implemented.\n",
|
---|
150 | hFile,
|
---|
151 | lpBuffer,
|
---|
152 | nNumberOfBytesToRead,
|
---|
153 | lpOverlapped,
|
---|
154 | lpCompletionRoutine));
|
---|
155 |
|
---|
156 |
|
---|
157 | return (FALSE);
|
---|
158 | }
|
---|
159 |
|
---|
160 |
|
---|
161 | /*****************************************************************************
|
---|
162 | * Name : BOOL WriteFileEx
|
---|
163 | * Purpose : The WriteFileEx function writes data to a file. It is designed
|
---|
164 | * solely for asynchronous operation, unlike WriteFile, which is
|
---|
165 | * designed for both synchronous and asynchronous operation.
|
---|
166 | * WriteFileEx reports its completion status asynchronously,
|
---|
167 | * calling a specified completion routine when writing is completed
|
---|
168 | * and the calling thread is in an alertable wait state.
|
---|
169 | * Parameters: HANDLE hFile handle of file to write
|
---|
170 | * LPVOID lpBuffer address of buffer
|
---|
171 | * DWORD nNumberOfBytesToRead number of bytes to write
|
---|
172 | * LPOVERLAPPED lpOverlapped address of offset
|
---|
173 | * LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine address of completion routine
|
---|
174 | * Variables :
|
---|
175 | * Result : TRUE / FALSE
|
---|
176 | * Remark :
|
---|
177 | * Status : UNTESTED STUB
|
---|
178 | *
|
---|
179 | * Author : Patrick Haller [Mon, 1998/06/15 08:00]
|
---|
180 | *****************************************************************************/
|
---|
181 |
|
---|
182 | DWORD WIN32API WriteFileEx(HANDLE hFile,
|
---|
183 | LPVOID lpBuffer,
|
---|
184 | DWORD nNumberOfBytesToWrite,
|
---|
185 | LPOVERLAPPED lpOverlapped,
|
---|
186 | LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
|
---|
187 | {
|
---|
188 | dprintf(("Kernel32: WriteFileEx(%08xh,%08xh,%08xh,%08xh,%08xh) not implemented.\n",
|
---|
189 | hFile,
|
---|
190 | lpBuffer,
|
---|
191 | nNumberOfBytesToWrite,
|
---|
192 | lpOverlapped,
|
---|
193 | lpCompletionRoutine));
|
---|
194 |
|
---|
195 |
|
---|
196 | return (FALSE);
|
---|
197 | }
|
---|
198 |
|
---|
199 |
|
---|
200 | #endif /* _ASYNCIOSUBSYSTEM_H_ */
|
---|