1 | /* $Id: async.cpp,v 1.5 1999-06-17 18:25:22 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 | #include "conwin.h" // Windows Header for console only
|
---|
50 | #include "handlemanager.h"
|
---|
51 |
|
---|
52 |
|
---|
53 | /*****************************************************************************
|
---|
54 | * Defines & Macros *
|
---|
55 | *****************************************************************************/
|
---|
56 |
|
---|
57 |
|
---|
58 | /*****************************************************************************
|
---|
59 | * Structures *
|
---|
60 | *****************************************************************************/
|
---|
61 |
|
---|
62 | typedef struct _IORequest
|
---|
63 | {
|
---|
64 | struct _IORequest *pNext; /* pointer to next I/O request */
|
---|
65 |
|
---|
66 | APIRET rc; /* result code of I/O request */
|
---|
67 |
|
---|
68 | } IOREQUEST, *PIOREQUEST;
|
---|
69 |
|
---|
70 |
|
---|
71 | typedef struct _Globals
|
---|
72 | {
|
---|
73 | HEV hevIOEvent; /* asynchronous I/O event completed ! */
|
---|
74 | TID tidIO; /* I/O thread */
|
---|
75 | } GLOBALS, *PGLOBALS;
|
---|
76 |
|
---|
77 | static GLOBALS Globals;
|
---|
78 |
|
---|
79 |
|
---|
80 | /*****************************************************************************
|
---|
81 | * Name :
|
---|
82 | * Purpose :
|
---|
83 | * Parameters:
|
---|
84 | * Variables :
|
---|
85 | * Result :
|
---|
86 | * Remark :
|
---|
87 | * Status :
|
---|
88 | *
|
---|
89 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
90 | *****************************************************************************/
|
---|
91 |
|
---|
92 | DWORD WIN32API SleepEx(DWORD dwTimeout,
|
---|
93 | BOOL fAlertable)
|
---|
94 | {
|
---|
95 |
|
---|
96 | dprintf(("KERNEL32: SleepEx(%u,%u)\n",
|
---|
97 | dwTimeout,
|
---|
98 | fAlertable));
|
---|
99 |
|
---|
100 | /* @@@PH could be implemented as a timed wait on a event semaphore */
|
---|
101 | /* for the WAIT_IO_COMPLETION flag */
|
---|
102 |
|
---|
103 | if (fAlertable == FALSE)
|
---|
104 | DosSleep(dwTimeout);
|
---|
105 | else {
|
---|
106 | dprintf(("SleepEx: Wait for io completion not supported!"));
|
---|
107 | DosSleep(1);
|
---|
108 | }
|
---|
109 |
|
---|
110 | return (0);
|
---|
111 | }
|
---|
112 |
|
---|
113 |
|
---|
114 | /*****************************************************************************
|
---|
115 | * Name : BOOL ReadFileEx
|
---|
116 | * Purpose : The ReadFileEx function reads data from a file asynchronously.
|
---|
117 | * It is designed solely for asynchronous operation, unlike the
|
---|
118 | * ReadFile function, which is designed for both synchronous and
|
---|
119 | * asynchronous operation. ReadFileEx lets an application perform
|
---|
120 | * other processing during a file read operation.
|
---|
121 | * The ReadFileEx function reports its completion status asynchronously,
|
---|
122 | * calling a specified completion routine when reading is completed
|
---|
123 | * and the calling thread is in an alertable wait state.
|
---|
124 | * Parameters: HANDLE hFile handle of file to read
|
---|
125 | * LPVOID lpBuffer address of buffer
|
---|
126 | * DWORD nNumberOfBytesToRead number of bytes to read
|
---|
127 | * LPOVERLAPPED lpOverlapped address of offset
|
---|
128 | * LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine address of completion routine
|
---|
129 | * Variables :
|
---|
130 | * Result : TRUE / FALSE
|
---|
131 | * Remark :
|
---|
132 | * Status : UNTESTED STUB
|
---|
133 | *
|
---|
134 | * Author : Patrick Haller [Mon, 1998/06/15 08:00]
|
---|
135 | *****************************************************************************/
|
---|
136 |
|
---|
137 | #define LPOVERLAPPED_COMPLETION_ROUTINE LPVOID
|
---|
138 |
|
---|
139 | DWORD WIN32API ReadFileEx(HANDLE hFile,
|
---|
140 | LPVOID lpBuffer,
|
---|
141 | DWORD nNumberOfBytesToRead,
|
---|
142 | LPOVERLAPPED lpOverlapped,
|
---|
143 | LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
|
---|
144 | {
|
---|
145 | dprintf(("Kernel32: ReadFileEx(%08xh,%08xh,%08xh,%08xh,%08xh) not implemented.\n",
|
---|
146 | hFile,
|
---|
147 | lpBuffer,
|
---|
148 | nNumberOfBytesToRead,
|
---|
149 | lpOverlapped,
|
---|
150 | lpCompletionRoutine));
|
---|
151 |
|
---|
152 |
|
---|
153 | return (FALSE);
|
---|
154 | }
|
---|
155 |
|
---|
156 |
|
---|
157 | /*****************************************************************************
|
---|
158 | * Name : BOOL WriteFileEx
|
---|
159 | * Purpose : The WriteFileEx function writes data to a file. It is designed
|
---|
160 | * solely for asynchronous operation, unlike WriteFile, which is
|
---|
161 | * designed for both synchronous and asynchronous operation.
|
---|
162 | * WriteFileEx reports its completion status asynchronously,
|
---|
163 | * calling a specified completion routine when writing is completed
|
---|
164 | * and the calling thread is in an alertable wait state.
|
---|
165 | * Parameters: HANDLE hFile handle of file to write
|
---|
166 | * LPVOID lpBuffer address of buffer
|
---|
167 | * DWORD nNumberOfBytesToRead number of bytes to write
|
---|
168 | * LPOVERLAPPED lpOverlapped address of offset
|
---|
169 | * LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine address of completion routine
|
---|
170 | * Variables :
|
---|
171 | * Result : TRUE / FALSE
|
---|
172 | * Remark :
|
---|
173 | * Status : UNTESTED STUB
|
---|
174 | *
|
---|
175 | * Author : Patrick Haller [Mon, 1998/06/15 08:00]
|
---|
176 | *****************************************************************************/
|
---|
177 |
|
---|
178 | DWORD WIN32API WriteFileEx(HANDLE hFile,
|
---|
179 | LPVOID lpBuffer,
|
---|
180 | DWORD nNumberOfBytesToWrite,
|
---|
181 | LPOVERLAPPED lpOverlapped,
|
---|
182 | LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
|
---|
183 | {
|
---|
184 | dprintf(("Kernel32: WriteFileEx(%08xh,%08xh,%08xh,%08xh,%08xh) not implemented.\n",
|
---|
185 | hFile,
|
---|
186 | lpBuffer,
|
---|
187 | nNumberOfBytesToWrite,
|
---|
188 | lpOverlapped,
|
---|
189 | lpCompletionRoutine));
|
---|
190 |
|
---|
191 |
|
---|
192 | return (FALSE);
|
---|
193 | }
|
---|
194 |
|
---|
195 |
|
---|
196 | #endif /* _ASYNCIOSUBSYSTEM_H_ */
|
---|