- Timestamp:
- Jan 2, 2000, 11:51:12 PM (26 years ago)
- Location:
- trunk/src/kernel32
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/makefile
r2298 r2300 1 # $Id: makefile,v 1.7 7 2000-01-02 22:09:01 sandervl Exp $1 # $Id: makefile,v 1.78 2000-01-02 22:51:11 sandervl Exp $ 2 2 3 3 # … … 240 240 $(PDWIN32_INCLUDE)\win32util.h 241 241 242 npipe.OBJ: \243 .\npipe.cpp \244 $(PDWIN32_INCLUDE)\misc.h245 246 242 unicode.OBJ: \ 247 243 .\unicode.cpp \ … … 418 414 debug.obj: debug.cpp oslibdebug.h 419 415 oslibdebug.obj: oslibdebug.cpp oslibdebug.h 416 npipe.obj: npipe.cpp oslibdos.h $(PDWIN32_INCLUDE)\misc.h 420 417 421 418 clean: -
trunk/src/kernel32/npipe.cpp
r100 r2300 1 /* $Id: npipe.cpp,v 1.2 1999-06-10 20:48:01 phaller Exp $ */2 3 1 /* 2 * Win32 Named pipes API 3 * 4 * Copyright 1998 Sander van Leeuwen 5 * Copyright 2000 Przemyslaw Dobrowolski 4 6 * 5 7 * Project Odin Software License can be found in LICENSE.TXT 6 *7 8 */ 8 /* 9 * Win32 Named pipes API stub functions 10 * 11 * Copyright 1998 Sander van Leeuwen 12 * 13 */ 9 #include <odin.h> 10 #include <odinwrap.h> 14 11 #include <os2win.h> 15 16 //TODO: Not done!! 12 #include <stdlib.h> 13 #include <unicode.h> 14 #include <heapstring.h> 15 #include <options.h> 16 #include "debugtools.h" 17 #include "oslibdos.h" 18 19 ODINDEBUGCHANNEL(KERNEL32-NPIPE) 17 20 18 21 //****************************************************************************** 19 22 //****************************************************************************** 20 23 BOOL WIN32API PeekNamedPipe(HANDLE hPipe, LPVOID lpvBuffer, DWORD cbBuffer, 21 22 { 23 dprintf(("PeekNamedPipe Not Implemented! \n"));24 LPDWORD lpcbRead, LPDWORD lpcbAvail, LPDWORD lpcbMessage) 25 { 26 dprintf(("PeekNamedPipe Not Implemented! - yet\n")); 24 27 return(FALSE); 25 28 } … … 34 37 //****************************************************************************** 35 38 //****************************************************************************** 36 HANDLE WIN32API CreateNamedPipeA(LPCTSTR lpName, DWORD dwOpenMode, DWORD dwPipeMode, 37 DWORD nMaxInstances, DWORD nOutBufferSize, 38 DWORD nInBufferSize, DWORD nDefaultTimeOut, 39 void *lpSecurityAttributes) 40 { 41 dprintf(("CreateNamedPipe Not Implemented!\n")); 42 return(0); 43 } 44 //****************************************************************************** 45 //****************************************************************************** 46 HANDLE WIN32API CreateNamedPipeW(LPCWSTR lpName, DWORD dwOpenMode, DWORD dwPipeMode, 47 DWORD nMaxInstances, DWORD nOutBufferSize, 48 DWORD nInBufferSize, DWORD nDefaultTimeOut, 49 void *lpSecurityAttributes) 50 { 51 dprintf(("CreateNamedPipe Not Implemented!\n")); 52 return(0); 53 } 54 //****************************************************************************** 55 //****************************************************************************** 39 //HANDLE WIN32API 40 // DWORD nMaxInstances, DWORD nOutBufferSize, 41 // DWORD nInBufferSize, DWORD nDefaultTimeOut, 42 // void *lpSecurityAttributes) 43 ODINFUNCTION8(HANDLE,CreateNamedPipeA,LPCTSTR,lpName, DWORD,dwOpenMode, DWORD,dwPipeMode, 44 DWORD, nMaxInstances, DWORD, nOutBufferSize, 45 DWORD, nInBufferSize, DWORD, nDefaultTimeOut, 46 void*, lpSecurityAttributes) 47 48 { 49 HANDLE hPipe; 50 51 hPipe = OSLibDosCreateNamedPipe(lpName, 52 dwOpenMode, 53 dwPipeMode, 54 nMaxInstances, 55 nOutBufferSize, 56 nInBufferSize, 57 nDefaultTimeOut, 58 lpSecurityAttributes); 59 60 return hPipe; 61 62 } 63 //****************************************************************************** 64 //****************************************************************************** 65 ODINFUNCTION8(HANDLE,CreateNamedPipeW,LPCWSTR,lpName, DWORD,dwOpenMode, DWORD,dwPipeMode, 66 DWORD, nMaxInstances, DWORD, nOutBufferSize, 67 DWORD, nInBufferSize, DWORD, nDefaultTimeOut, 68 void *,lpSecurityAttributes) 69 { 70 char *asciiname; 71 HANDLE hPipe; 72 73 asciiname = UnicodeToAsciiString((LPWSTR)lpName); 74 75 hPipe=OSLibDosCreateNamedPipe(asciiname, 76 dwOpenMode, 77 dwPipeMode, 78 nMaxInstances, 79 nOutBufferSize, 80 nInBufferSize, 81 nDefaultTimeOut, 82 lpSecurityAttributes); 83 84 FreeAsciiString(asciiname); 85 86 return(hPipe); 87 } 88 //****************************************************************************** 89 //****************************************************************************** 90 91 92 /***************************************************************************** 93 * Name : BOOL WIN32API ConnectNamedPipe 94 * Purpose : The ConnectNamedPipe function enables a named pipe server process 95 * to wait for a client process to connect to an instance of a 96 * named pipe. A client process connects by calling either the 97 * CreateFile or CallNamedPipe function. 98 * Parameters: HANDLE hNamedPipe handle to named pipe to connect 99 * LPOVERLAPPED lpOverlapped pointer to overlapped structure 100 * Variables : 101 * Result : If the function succeeds, the return value is nonzero. 102 * If the function fails, the return value is zero. 103 * To get extended error information, call GetLastError. 104 * Remark : 105 * Status : NOT FULLY TESTED 106 * 107 * Author : Przemyslaw Dobrowolski [Thu, 2000/01/02 12:48] 108 *****************************************************************************/ 109 110 ODINFUNCTION2(BOOL,ConnectNamedPipe,HANDLE,hNamedPipe, LPOVERLAPPED,lpOverlapped) 111 { 112 return (OSLibDosConnectNamedPipe(hNamedPipe,lpOverlapped)); 113 } 114 115 /***************************************************************************** 116 * Name : BOOL WIN32AOI CallNamedPipeA 117 * Purpose : The CallNamedPipe function connects to a message-type pipe 118 * (and waits if an instance of the pipe is not available), 119 * writes to and reads from the pipe, and then closes the pipe. 120 * Parameters: LPCSTR lpNamedPipeName pointer to pipe name 121 * LPVOID lpInBuffer pointer to write buffer 122 * DWORD nInBufferSize size, in bytes, of write buffer 123 * LPVOID lpOutBuffer pointer to read buffer 124 * DWORD nOutBufferSize size, in bytes, of read buffer 125 * LPDWORD lpBytesRead pointer to number of bytes read 126 * DWORD nTimeOut time-out time, in milliseconds 127 * Variables : 128 * Result : If the function succeeds, the return value is nonzero. 129 * If the function fails, the return value is zero. 130 * To get extended error information, call GetLastError. 131 * Remark : Calling CallNamedPipe is equivalent to calling the CreateFile 132 * (or WaitNamedPipe, if CreateFile cannot open the pipe immediately), 133 * TransactNamedPipe, and CloseHandle functions. CreateFile is called 134 * with an access flag of GENERIC_READ | GENERIC_WRITE, an inherit 135 * handle flag of FALSE, and a share mode of zero (indicating no 136 * sharing of this pipe instance). 137 * If the message written to the pipe by the server process is 138 * longer than nOutBufferSize, CallNamedPipe returns FALSE, and 139 * GetLastError returns ERROR_MORE_DATA. The remainder of the 140 * message is discarded, because CallNamedPipe closes the handle 141 * to the pipe before returning. 142 * 143 * CallNamedPipe fails if the pipe is a byte-type pipe. 144 * Status : UNTESTED STUB 145 * 146 * Author : Markus Montkowski [Thu, 1998/05/19 11:46] 147 *****************************************************************************/ 148 149 BOOL WIN32API CallNamedPipeA( LPCSTR lpNamedPipeName, 150 LPVOID lpInBuffer, DWORD nInBufferSize, 151 LPVOID lpOutBuffer, DWORD nOutBufferSize, 152 LPDWORD lpBytesRead, DWORD nTimeOut) 153 { 154 155 dprintf(("KERNEL32: CallNamedPipeA(%08x,%08x,%08x,%08x,%08x,%08x) not implemented\n", 156 lpNamedPipeName, lpInBuffer, nInBufferSize, 157 lpOutBuffer, nOutBufferSize, lpBytesRead, nTimeOut 158 )); 159 160 return (FALSE); 161 } 162 163 /***************************************************************************** 164 * Name : BOOL WIN32AOI CallNamedPipeA 165 * Purpose : The CallNamedPipe function connects to a message-type pipe 166 * (and waits if an instance of the pipe is not available), 167 * writes to and reads from the pipe, and then closes the pipe. 168 * Parameters: LPCWSTR lpNamedPipeName pointer to pipe name 169 * LPVOID lpInBuffer pointer to write buffer 170 * DWORD nInBufferSize size, in bytes, of write buffer 171 * LPVOID lpOutBuffer pointer to read buffer 172 * DWORD nOutBufferSize size, in bytes, of read buffer 173 * LPDWORD lpBytesRead pointer to number of bytes read 174 * DWORD nTimeOut time-out time, in milliseconds 175 * Variables : 176 * Result : If the function succeeds, the return value is nonzero. 177 * If the function fails, the return value is zero. 178 * To get extended error information, call GetLastError. 179 * Remark : Calling CallNamedPipe is equivalent to calling the CreateFile 180 * (or WaitNamedPipe, if CreateFile cannot open the pipe immediately), 181 * TransactNamedPipe, and CloseHandle functions. CreateFile is called 182 * with an access flag of GENERIC_READ | GENERIC_WRITE, an inherit 183 * handle flag of FALSE, and a share mode of zero (indicating no 184 * sharing of this pipe instance). 185 * If the message written to the pipe by the server process is 186 * longer than nOutBufferSize, CallNamedPipe returns FALSE, and 187 * GetLastError returns ERROR_MORE_DATA. The remainder of the 188 * message is discarded, because CallNamedPipe closes the handle 189 * to the pipe before returning. 190 * 191 * CallNamedPipe fails if the pipe is a byte-type pipe. 192 * Status : UNTESTED STUB 193 * 194 * Author : Markus Montkowski [Thu, 1998/05/19 11:46] 195 *****************************************************************************/ 196 197 BOOL WIN32API CallNamedPipeW( LPCWSTR lpNamedPipeName, 198 LPVOID lpInBuffer, DWORD nInBufferSize, 199 LPVOID lpOutBuffer, DWORD nOutBufferSize, 200 LPDWORD lpBytesRead, DWORD nTimeOut) 201 { 202 203 dprintf(("KERNEL32: CallNamedPipeA(%08x,%08x,%08x,%08x,%08x,%08x) not implemented\n", 204 lpNamedPipeName, lpInBuffer, nInBufferSize, 205 lpOutBuffer, nOutBufferSize, lpBytesRead, nTimeOut 206 )); 207 208 return (FALSE); 209 } 210 /***************************************************************************** 211 * Name : BOOL WIN32API DisconnectNamedPipe 212 * Purpose : The DisconnectNamedPipe function disconnects the server end 213 * of a named pipe instance from a client process. 214 * Parameters: HANDLE hNamedPipe handle to named pipe 215 * Variables : 216 * Result : If the function succeeds, the return value is nonzero. 217 * If the function fails, the return value is zero 218 * Remark : 219 * Status : UNTESTED STUB 220 * 221 * Author : Markus Montkowski [Tha, 1998/05/21 17:46] 222 *****************************************************************************/ 223 224 BOOL WIN32API DisconnectNamedPipe(HANDLE hNamedPipe) 225 { 226 227 dprintf(("KERNEL32: DisconnectNamedPipe(%08x) not implemented\n", 228 hNamedPipe 229 )); 230 231 return (FALSE); 232 } 233 234 /***************************************************************************** 235 * Name : BOOL GetNamedPipeHandleStateA 236 * Purpose : The GetNamedPipeHandleStateA function retrieves information about 237 * a specified named pipe. The information returned can vary during 238 * the lifetime of an instance of the named pipe. 239 * Parameters: HANDLE hNamedPipe handle of named pipe 240 * LPDWORD lpState address of flags indicating pipe state 241 * LPDWORD lpCurInstances address of number of current pipe instances 242 * LPDWORD lpMaxCollectionCount address of max. bytes before remote transmission 243 * LPDWORD lpCollectDataTimeout address of max. time before remote transmission 244 * LPTSTR lpUserName address of user name of client process 245 * DWORD nMaxUserNameSize size, in characters, of user name buffer 246 * Variables : 247 * Result : TRUE / FALSE 248 * Remark : 249 * Status : UNTESTED STUB 250 * 251 * Author : Patrick Haller [Mon, 1998/06/15 08:00] 252 *****************************************************************************/ 253 254 BOOL WIN32API GetNamedPipeHandleStateA(HANDLE hNamedPipe, 255 LPDWORD lpState, 256 LPDWORD lpCurInstances, 257 LPDWORD lpMaxCollectionCount, 258 LPDWORD lpCollectDataTimeout, 259 LPTSTR lpUserName, 260 DWORD nMaxUserNameSize) 261 { 262 dprintf(("KERNEL32: GetNamedPipeHandleStateA(%08xh,%08xh,%08xh,%08xh,%08xh,%08xh,%08xh) not implemented\n", 263 hNamedPipe, 264 lpState, 265 lpCurInstances, 266 lpMaxCollectionCount, 267 lpCollectDataTimeout, 268 lpUserName, 269 nMaxUserNameSize)); 270 271 return (FALSE); 272 } 273 274 275 /***************************************************************************** 276 * Name : BOOL GetNamedPipeHandleStateW 277 * Purpose : The GetNamedPipeHandleStateW function retrieves information about 278 * a specified named pipe. The information returned can vary during 279 * the lifetime of an instance of the named pipe. 280 * Parameters: HANDLE hNamedPipe handle of named pipe 281 * LPDWORD lpState address of flags indicating pipe state 282 * LPDWORD lpCurInstances address of number of current pipe instances 283 * LPDWORD lpMaxCollectionCount address of max. bytes before remote transmission 284 * LPDWORD lpCollectDataTimeout address of max. time before remote transmission 285 * LPWSTR lpUserName address of user name of client process 286 * DWORD nMaxUserNameSize size, in characters, of user name buffer 287 * Variables : 288 * Result : TRUE / FALSE 289 * Remark : 290 * Status : UNTESTED STUB 291 * 292 * Author : Patrick Haller [Mon, 1998/06/15 08:00] 293 *****************************************************************************/ 294 295 BOOL WIN32API GetNamedPipeHandleStateW(HANDLE hNamedPipe, 296 LPDWORD lpState, 297 LPDWORD lpCurInstances, 298 LPDWORD lpMaxCollectionCount, 299 LPDWORD lpCollectDataTimeout, 300 LPWSTR lpUserName, 301 DWORD nMaxUserNameSize) 302 { 303 dprintf(("KERNEL32: GetNamedPipeHandleStateW(%08xh,%08xh,%08xh,%08xh,%08xh,%08xh,%08xh) not implemented\n", 304 hNamedPipe, 305 lpState, 306 lpCurInstances, 307 lpMaxCollectionCount, 308 lpCollectDataTimeout, 309 lpUserName, 310 nMaxUserNameSize)); 311 312 return (FALSE); 313 } 314 315 316 /***************************************************************************** 317 * Name : BOOL GetNamedPipeInfo 318 * Purpose : The GetNamedPipeInfo function retrieves information about the specified named pipe. 319 * Parameters: HANDLE hNamedPipe handle of named pipe 320 * LPDWORD lpFlags address of flags indicating type of pipe 321 * LPDWORD lpOutBufferSize address of size, in bytes, of pipe's output buffer 322 * LPDWORD lpInBufferSize address of size, in bytes, of pipe's input buffer 323 * LPDWORD lpMaxInstances address of max. number of pipe instances 324 * Variables : 325 * Result : TRUE / FALSE 326 * Remark : 327 * Status : UNTESTED STUB 328 * 329 * Author : Patrick Haller [Mon, 1998/06/15 08:00] 330 *****************************************************************************/ 331 332 BOOL WIN32API GetNamedPipeInfo(HANDLE hNamedPipe, 333 LPDWORD lpFlags, 334 LPDWORD lpOutBufferSize, 335 LPDWORD lpInBufferSize, 336 LPDWORD lpMaxInstances) 337 { 338 dprintf(("KERNEL32: GetNamedPipeInfo(%08xh,%08xh,%08xh,%08xh,%08xh) not implemented\n", 339 hNamedPipe, 340 lpFlags, 341 lpOutBufferSize, 342 lpInBufferSize, 343 lpMaxInstances)); 344 345 return (FALSE); 346 } 347 348 /***************************************************************************** 349 * Name : BOOL SetNamedPipeHandleState 350 * Purpose : The SetNamedPipeHandleState function sets the read mode and the 351 * blocking mode of the specified named pipe. If the specified handle 352 * is to the client end of a named pipe and if the named pipe server 353 * process is on a remote computer, the function can also be used to 354 * control local buffering. 355 * Parameters: HANDLE hNamedPipe handle of named pipe 356 * LPDWORD lpdwMode address of new pipe mode 357 * LPDWORD lpcbMaxCollect address of max. bytes before remote transmission 358 * LPDWORD lpdwCollectDataTimeout address of max. time before remote transmission 359 * Variables : 360 * Result : TRUE / FALSE 361 * Remark : 362 * Status : UNTESTED STUB 363 * 364 * Author : Patrick Haller [Mon, 1998/06/15 08:00] 365 *****************************************************************************/ 366 367 BOOL WIN32API SetNamedPipeHandleState(HANDLE hNamedPipe, 368 LPDWORD lpdwMode, 369 LPDWORD lpcbMaxCollect, 370 LPDWORD lpdwCollectDataTimeout) 371 { 372 dprintf(("KERNEL32: SetNamedPipeHandleState(%08xh,%08xh,%08xh,%08xh) not implemented.\n", 373 hNamedPipe, 374 lpdwMode, 375 lpcbMaxCollect, 376 lpdwCollectDataTimeout)); 377 378 return (FALSE); 379 } 380 381 /***************************************************************************** 382 * Name : DWORD TransactNamedPipe 383 * Purpose : The TransactNamedPipe function combines into a single network 384 * operation the functions that write a message to and read a 385 * message from the specified named pipe. 386 * Parameters: HANDLE hNamedPipe handle of named pipe 387 * LPVOID lpvWriteBuf address of write buffer 388 * DWORD cbWriteBuf size of the write buffer, in bytes 389 * LPVOID lpvReadBuf address of read buffer 390 * DWORD cbReadBuf size of read buffer, in bytes 391 * LPDWORD lpcbRead address of variable for bytes actually read 392 * LPOVERLAPPED lpo address of overlapped structure 393 * Variables : 394 * Result : TRUE / FALSE 395 * Remark : 396 * Status : UNTESTED STUB 397 * 398 * Author : Patrick Haller [Mon, 1998/06/15 08:00] 399 *****************************************************************************/ 400 401 DWORD WIN32API TransactNamedPipe(HANDLE hNamedPipe, 402 LPVOID lpvWriteBuf, 403 DWORD cbWriteBuf, 404 LPVOID lpvReadBuf, 405 DWORD cbReadBuf, 406 LPDWORD lpcbRead, 407 LPOVERLAPPED lpo) 408 { 409 dprintf(("KERNEL32: TransactNamedPipe(%08x,%08x,%08x,%08x,%08x,%08x,%08x) not implemented.\n", 410 hNamedPipe, 411 lpvWriteBuf, 412 cbWriteBuf, 413 lpvReadBuf, 414 cbReadBuf, 415 lpcbRead, 416 lpo)); 417 418 return (FALSE); 419 } 420 421 /***************************************************************************** 422 * Name : BOOL WaitNamedPipeA 423 * Purpose : The WaitNamedPipe function waits until either a time-out interval 424 * elapses or an instance of the specified named pipe is available 425 * to be connected to (that is, the pipe's server process has a 426 * pending ConnectNamedPipe operation on the pipe). 427 * Parameters: LPCTSTR lpszNamedPipeName 428 * DWORD dwTimeout 429 * Variables : 430 * Result : TRUE / FALSE 431 * Remark : 432 * Status : UNTESTED STUB 433 * 434 * Author : Patrick Haller [Mon, 1998/06/15 08:00] 435 *****************************************************************************/ 436 437 BOOL WIN32API WaitNamedPipeA(LPCTSTR lpszNamedPipeName, 438 DWORD dwTimeout) 439 { 440 dprintf(("KERNEL32: WaitNamedPipeA(%s, %u) not implemented.\n", 441 lpszNamedPipeName, 442 dwTimeout)); 443 444 return (FALSE); 445 } 446 447 448 /***************************************************************************** 449 * Name : BOOL WaitNamedPipeW 450 * Purpose : The WaitNamedPipe function waits until either a time-out interval 451 * elapses or an instance of the specified named pipe is available 452 * to be connected to (that is, the pipe's server process has a 453 * pending ConnectNamedPipe operation on the pipe). 454 * Parameters: LPCWSTR lpszNamedPipeName 455 * DWORD dwTimeout 456 * Variables : 457 * Result : TRUE / FALSE 458 * Remark : 459 * Status : UNTESTED STUB 460 * 461 * Author : Patrick Haller [Mon, 1998/06/15 08:00] 462 *****************************************************************************/ 463 464 BOOL WIN32API WaitNamedPipeW(LPCWSTR lpszNamedPipeName, 465 DWORD dwTimeout) 466 { 467 dprintf(("KERNEL32: WaitNamedPipeW(%s, %u) not implemented.\n", 468 lpszNamedPipeName, 469 dwTimeout)); 470 471 return (FALSE); 472 } -
trunk/src/kernel32/oslibdos.cpp
r1924 r2300 1 /* $Id: oslibdos.cpp,v 1.12 1999-12-01 18:40:48 sandervl Exp $ */2 3 1 /* 4 2 * Wrappers for OS/2 Dos* API 5 3 * 6 * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl) 7 * 4 * Copyright 1998-2000 Sander van Leeuwen (sandervl@xs4all.nl) 5 * Copyright 1999-2000 Edgar Buerkle <Edgar.Buerkle@gmx.net> 6 * Copyright 2000 Przemyslaw Dobrowolski <dobrawka@asua.org.pl> 8 7 * 9 8 * Project Odin Software License can be found in LICENSE.TXT … … 15 14 #define INCL_DOSPROCESS 16 15 #define INCL_DOSERRORS 16 #define INCL_NPIPES 17 17 #include <os2wrap.h> //Odin32 OS/2 api wrappers 18 18 #include <stdlib.h> … … 20 20 #include <string.h> 21 21 #include <win32type.h> 22 #include <winconst.h> 22 23 #include <misc.h> 23 24 #include "initterm.h" 24 25 #include "oslibdos.h" 25 26 #include "dosqss.h" 27 28 /*********************************** 29 * PH: fixups for missing os2win.h * 30 ***********************************/ 31 32 void _System SetLastError(ULONG ulError); 26 33 27 34 APIRET APIENTRY DosAliasMem(PVOID pb, ULONG cb, PPVOID ppbAlias, ULONG fl); … … 403 410 DWORD os2Open=0; 404 411 405 #define GENERIC_READ 0x80000000 406 #define GENERIC_WRITE 0x40000000 407 if(dwAccess == (GENERIC_READ | GENERIC_WRITE)) 412 if(dwAccess == (GENERIC_READ_W | GENERIC_WRITE_W)) 408 413 os2Flags |= OPEN_ACCESS_READWRITE; 409 else if(dwAccess & GENERIC_WRITE )414 else if(dwAccess & GENERIC_WRITE_W) 410 415 os2Flags |= OPEN_ACCESS_WRITEONLY; 411 else if(dwAccess & GENERIC_READ )416 else if(dwAccess & GENERIC_READ_W) 412 417 os2Flags |= OPEN_ACCESS_READONLY; 413 418 414 #define FILE_SHARE_READ 0x00000001L415 #define FILE_SHARE_WRITE 0x00000002L416 419 if(dwShare == 0) 417 420 os2Flags |= OPEN_SHARE_DENYREADWRITE; 418 else if(dwShare == (FILE_SHARE_READ | FILE_SHARE_WRITE))421 else if(dwShare == (FILE_SHARE_READ_W | FILE_SHARE_WRITE_W)) 419 422 os2Flags |= OPEN_SHARE_DENYNONE; 420 else if(dwShare & FILE_SHARE_READ )423 else if(dwShare & FILE_SHARE_READ_W) 421 424 os2Flags |= OPEN_SHARE_DENYWRITE; 422 else if(dwShare & FILE_SHARE_WRITE )425 else if(dwShare & FILE_SHARE_WRITE_W) 423 426 os2Flags |= OPEN_SHARE_DENYREAD; 424 427 425 #define CREATE_NEW 1 426 #define CREATE_ALWAYS 2 427 #define OPEN_EXISTING 3 428 #define OPEN_ALWAYS 4 429 #define TRUNCATE_EXISTING 5 430 if(dwCreation == CREATE_NEW) 428 if(dwCreation == CREATE_NEW_W) 431 429 os2Open = OPEN_ACTION_FAIL_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW; 432 else if(dwCreation == CREATE_ALWAYS )430 else if(dwCreation == CREATE_ALWAYS_W) 433 431 os2Open = OPEN_ACTION_REPLACE_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW; 434 else if(dwCreation == OPEN_EXISTING )432 else if(dwCreation == OPEN_EXISTING_W) 435 433 os2Open = OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_FAIL_IF_NEW; 436 else if(dwCreation == OPEN_ALWAYS )434 else if(dwCreation == OPEN_ALWAYS_W) 437 435 os2Open = OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW; 438 else if(dwCreation == TRUNCATE_EXISTING )436 else if(dwCreation == TRUNCATE_EXISTING_W) 439 437 os2Open = OPEN_ACTION_REPLACE_IF_EXISTS;// |OPEN_ACTION_FAIL_IF_NEW; 440 438 441 #define FILE_ATTRIBUTE_READONLY 0x00000001L 442 #define FILE_ATTRIBUTE_HIDDEN 0x00000002L 443 #define FILE_ATTRIBUTE_SYSTEM 0x00000004L 444 #define FILE_ATTRIBUTE_DIRECTORY 0x00000010L 445 #define FILE_ATTRIBUTE_ARCHIVE 0x00000020L 446 #define FILE_ATTRIBUTE_NORMAL 0x00000080L 447 #define FILE_ATTRIBUTE_TEMPORARY 0x00000100L 448 if(dwFlags & FILE_ATTRIBUTE_READONLY) 439 if(dwFlags & FILE_ATTRIBUTE_READONLY_W) 449 440 os2Attrib |= FILE_READONLY; 450 if(dwFlags & FILE_ATTRIBUTE_HIDDEN )441 if(dwFlags & FILE_ATTRIBUTE_HIDDEN_W) 451 442 os2Attrib |= FILE_HIDDEN; 452 if(dwFlags & FILE_ATTRIBUTE_SYSTEM )443 if(dwFlags & FILE_ATTRIBUTE_SYSTEM_W) 453 444 os2Attrib |= FILE_SYSTEM; 454 if(dwFlags & FILE_ATTRIBUTE_DIRECTORY )445 if(dwFlags & FILE_ATTRIBUTE_DIRECTORY_W) 455 446 os2Attrib |= FILE_DIRECTORY; 456 if(dwFlags & FILE_ATTRIBUTE_ARCHIVE )447 if(dwFlags & FILE_ATTRIBUTE_ARCHIVE_W) 457 448 os2Attrib |= FILE_ARCHIVED; 458 if(dwFlags & FILE_ATTRIBUTE_NORMAL )449 if(dwFlags & FILE_ATTRIBUTE_NORMAL_W) 459 450 os2Attrib |= FILE_NORMAL; 460 451 461 #define FILE_FLAG_WRITE_THROUGH 0x80000000UL 462 #define FILE_FLAG_OVERLAPPED 0x40000000L 463 #define FILE_FLAG_NO_BUFFERING 0x20000000L 464 #define FILE_FLAG_RANDOM_ACCESS 0x10000000L 465 #define FILE_FLAG_SEQUENTIAL_SCAN 0x08000000L 466 #define FILE_FLAG_DELETE_ON_CLOSE 0x04000000L 467 #define FILE_FLAG_BACKUP_SEMANTICS 0x02000000L 468 #define FILE_FLAG_POSIX_SEMANTICS 0x01000000L 469 if(dwFlags & FILE_FLAG_WRITE_THROUGH) 452 if(dwFlags & FILE_FLAG_WRITE_THROUGH_W) 470 453 os2Flags |= OPEN_FLAGS_WRITE_THROUGH; 471 if(dwFlags & FILE_FLAG_NO_BUFFERING )454 if(dwFlags & FILE_FLAG_NO_BUFFERING_W) 472 455 os2Flags |= OPEN_FLAGS_NO_CACHE; 473 if(dwFlags & FILE_FLAG_RANDOM_ACCESS )456 if(dwFlags & FILE_FLAG_RANDOM_ACCESS_W) 474 457 os2Flags |= OPEN_FLAGS_RANDOM; 475 if(dwFlags & FILE_FLAG_SEQUENTIAL_SCAN )458 if(dwFlags & FILE_FLAG_SEQUENTIAL_SCAN_W) 476 459 os2Flags |= OPEN_FLAGS_SEQUENTIAL; 477 460 478 461 // TODO: 479 // if(dwFlags & FILE_FLAG_OVERLAPPED )480 // if(dwFlags & FILE_FLAG_DELETE_ON_CLOSE 462 // if(dwFlags & FILE_FLAG_OVERLAPPED_W) 463 // if(dwFlags & FILE_FLAG_DELETE_ON_CLOSE_W 481 464 482 465 rc = DosOpen(lpFileName, &hFile, &ulAction, 0, … … 486 469 { 487 470 // TODO: TEST TEST 488 dprintf(("DosOpen Error rc:%d, try without GENERIC_WRITE ", rc));489 if(dwAccess & GENERIC_WRITE )471 dprintf(("DosOpen Error rc:%d, try without GENERIC_WRITE_W", rc)); 472 if(dwAccess & GENERIC_WRITE_W) 490 473 os2Flags &= ~(OPEN_ACCESS_READWRITE | OPEN_ACCESS_WRITEONLY); 491 474 rc = DosOpen(lpFileName, &hFile, &ulAction, 0, … … 584 567 //****************************************************************************** 585 568 //****************************************************************************** 569 // TODO: implement SecurityAttributes parameter 570 DWORD OSLibDosCreateNamedPipe(LPCTSTR lpName, 571 DWORD dwOpenMode, 572 DWORD dwPipeMode, 573 DWORD nMaxInstances, 574 DWORD nOutBufferSize, 575 DWORD nInBufferSize, 576 DWORD nDefaultTimeOut, 577 void* lpSecurityAttributes) 578 { DWORD dwOS2Mode = 0; 579 DWORD dwOS2PipeMode = 0; 580 LPSTR lpOS2Name; 581 DWORD hPipe; 582 DWORD rc; 583 584 if (dwOpenMode & PIPE_ACCESS_DUPLEX_W) 585 dwOS2Mode |= NP_ACCESS_DUPLEX; 586 else 587 if (dwOpenMode & PIPE_ACCESS_INBOUND_W) 588 dwOS2Mode |= NP_ACCESS_INBOUND; 589 else 590 if (dwOpenMode & PIPE_ACCESS_OUTBOUND_W) 591 dwOS2Mode |= NP_ACCESS_OUTBOUND; 592 // TODO: 593 // if(dwOpenMode & FILE_FLAG_OVERLAPPED) 594 // if(dwOpenMode & WRITE_DAC) 595 // if(dwOpenMode & WRITE_OWNER) 596 // if(dwOpenMode & ACCESS_SYSTEM_SECURITY) 597 if(dwOpenMode & FILE_FLAG_WRITE_THROUGH_W) 598 dwOS2Mode |= NP_WRITEBEHIND; // FIXME: I'm not sure! 599 600 if (dwPipeMode & PIPE_WAIT_W) 601 dwOS2PipeMode |= NP_WAIT; 602 if (dwPipeMode & PIPE_NOWAIT_W) 603 dwOS2PipeMode |= NP_NOWAIT; 604 if (dwPipeMode & PIPE_READMODE_BYTE_W) 605 dwOS2PipeMode |= NP_READMODE_BYTE; 606 if (dwPipeMode & PIPE_READMODE_MESSAGE_W) 607 dwOS2PipeMode |= NP_READMODE_MESSAGE; 608 if (dwPipeMode & PIPE_TYPE_BYTE_W) 609 dwOS2PipeMode |= NP_TYPE_BYTE; 610 if (dwPipeMode & PIPE_TYPE_MESSAGE_W) 611 dwOS2PipeMode |= NP_TYPE_MESSAGE; 612 613 if (nMaxInstances>0xff) 614 { 615 SetLastError(87); // ERROR_INVALID_PARAMETER 616 return -1; // INVALID_HANDLE_VALUE 617 } 618 dwOS2PipeMode |= nMaxInstances; 619 620 // we must delete string \.\ because 621 // in Windows named pipes scheme is a \.\PIPE\pipename 622 // but in OS/2 only \PIPE\pipename 623 lpOS2Name = (LPSTR)lpName + 3; 624 625 626 dprintf(("DosCreateNPipe(%s,%x,%x,%x,%x,%x)",lpOS2Name,dwOS2Mode,dwOS2PipeMode,nInBufferSize,nOutBufferSize,nDefaultTimeOut)); 627 rc=DosCreateNPipe(lpOS2Name, 628 &hPipe, 629 dwOS2Mode, 630 dwOS2PipeMode, 631 nInBufferSize, 632 nInBufferSize, 633 nDefaultTimeOut); // Timeouts must be tested! 634 635 dprintf(("DosCreateNPipe rc=%d",rc)); 636 if (rc) 637 { 638 if ( rc == ERROR_PIPE_BUSY ) SetLastError(ERROR_PIPE_BUSY_W); 639 else 640 if ( rc == ERROR_PATH_NOT_FOUND ) SetLastError(ERROR_PATH_NOT_FOUND_W); 641 else 642 if ( rc == ERROR_NOT_ENOUGH_MEMORY ) SetLastError(ERROR_NOT_ENOUGH_MEMORY_W); 643 else 644 if ( rc == ERROR_INVALID_PARAMETER ) SetLastError(ERROR_INVALID_PARAMETER_W); 645 else 646 if ( rc == ERROR_OUT_OF_STRUCTURES ) SetLastError(ERROR_OUT_OF_STRUCTURES_W); 647 else 648 // Unknown error 649 SetLastError(ERROR_INVALID_PARAMETER_W); // fixme! 650 return -1; // INVALID_HANDLE_VALUE 651 } 652 return hPipe; 653 } 654 655 //****************************************************************************** 656 //****************************************************************************** 657 // TODO: implement lpOverlapped parameter! 658 BOOL OSLibDosConnectNamedPipe(DWORD hNamedPipe, LPOVERLAPPED lpOverlapped) 659 { 660 DWORD rc; 661 662 rc=DosConnectNPipe(hNamedPipe); 663 dprintf(("DosConnectNPipe rc=%d",rc)); 664 665 if (!rc) return (TRUE); 666 else 667 if (rc==ERROR_BROKEN_PIPE) SetLastError(ERROR_BROKEN_PIPE_W); 668 else 669 if (rc==ERROR_BAD_PIPE) SetLastError(ERROR_BAD_PIPE_W); 670 else 671 if (rc==ERROR_PIPE_NOT_CONNECTED) SetLastError(ERROR_PIPE_NOT_CONNECTED_W); 672 else 673 // TODO: Implemnt this using Windows Errors 674 // if (rc==ERROR_INTERRUPT) 675 SetLastError(ERROR_PIPE_NOT_CONNECTED_W); 676 677 return (FALSE); 678 } 679 680 //****************************************************************************** 681 //****************************************************************************** 682 BOOL OSLibDosCallNamedPipe( LPCTSTR lpNamedPipeName, 683 LPVOID lpInBuffer, 684 DWORD nInBufferSize, 685 LPVOID lpOutBuffer, 686 DWORD nOutBufferSize, 687 LPDWORD lpBytesRead, 688 DWORD nTimeOut ) 689 { 690 LPSTR lpOS2Name; 691 DWORD rc; 692 // we must delete string \.\ because 693 // in Windows named pipes scheme is a \.\PIPE\pipename 694 // but in OS/2 only \PIPE\pipename 695 lpOS2Name = (LPSTR)lpNamedPipeName + 3; 696 697 rc=DosCallNPipe(lpOS2Name, 698 lpInBuffer, 699 nInBufferSize, 700 lpOutBuffer, 701 nOutBufferSize, 702 lpBytesRead, 703 nTimeOut ); 704 705 706 if (!rc) return (TRUE); 707 else 708 if ( rc==ERROR_FILE_NOT_FOUND ) SetLastError(ERROR_FILE_NOT_FOUND_W); 709 else 710 if ( rc==ERROR_PATH_NOT_FOUND ) SetLastError(ERROR_PATH_NOT_FOUND_W); 711 else 712 if ( rc==ERROR_ACCESS_DENIED ) SetLastError(ERROR_ACCESS_DENIED_W); 713 else 714 if ( rc==ERROR_MORE_DATA ) SetLastError(ERROR_MORE_DATA_W); 715 else 716 if ( rc==ERROR_PIPE_BUSY ) SetLastError(ERROR_PIPE_BUSY_W); 717 else 718 if ( rc==ERROR_BAD_FORMAT ) SetLastError(ERROR_BAD_FORMAT_W); 719 else 720 if ( rc==ERROR_BROKEN_PIPE ) SetLastError(ERROR_BROKEN_PIPE_W); 721 else 722 if ( rc==ERROR_BAD_PIPE ) SetLastError(ERROR_BAD_PIPE_W); 723 else 724 if ( rc==ERROR_PIPE_NOT_CONNECTED ) SetLastError(ERROR_PIPE_NOT_CONNECTED_W); 725 else 726 // TODO: Implemnt this using Windows Errors 727 // if (rc==ERROR_INTERRUPT) 728 SetLastError(233); 729 730 return (FALSE); 731 } 732 733 //****************************************************************************** 734 //****************************************************************************** 735 BOOL OSLibDosTransactNamedPipe( DWORD hNamedPipe, 736 LPVOID lpInBuffer, 737 DWORD nInBufferSize, 738 LPVOID lpOutBuffer, 739 DWORD nOutBufferSize, 740 LPDWORD lpBytesRead, 741 LPOVERLAPPED lpOverlapped) 742 { 743 DWORD rc; 744 745 rc=DosTransactNPipe(hNamedPipe, 746 lpOutBuffer, 747 nOutBufferSize, 748 lpInBuffer, 749 nInBufferSize, 750 lpBytesRead); 751 752 if (!rc) return (TRUE); 753 else 754 if ( rc==ERROR_ACCESS_DENIED ) SetLastError(ERROR_ACCESS_DENIED_W); 755 else 756 if ( rc==ERROR_MORE_DATA ) SetLastError(ERROR_MORE_DATA_W); 757 else 758 if ( rc==ERROR_PIPE_BUSY ) SetLastError(ERROR_PIPE_BUSY_W); 759 else 760 if ( rc==ERROR_BAD_FORMAT ) SetLastError(ERROR_BAD_FORMAT_W); 761 else 762 if ( rc==ERROR_BROKEN_PIPE ) SetLastError(ERROR_BROKEN_PIPE_W); 763 else 764 if ( rc==ERROR_BAD_PIPE ) SetLastError(ERROR_BAD_PIPE_W); 765 else 766 if ( rc==ERROR_PIPE_NOT_CONNECTED ) SetLastError(ERROR_PIPE_NOT_CONNECTED_W); 767 else 768 // Unknown error 769 SetLastError(ERROR_PIPE_NOT_CONNECTED_W); 770 771 return FALSE; 772 }
Note:
See TracChangeset
for help on using the changeset viewer.