| 1 | /* $Id: npipe.cpp,v 1.9 2000-07-12 18:21:44 sandervl Exp $ */ | 
|---|
| 2 | /* | 
|---|
| 3 | * Win32 Named pipes API | 
|---|
| 4 | * | 
|---|
| 5 | * Copyright 1998 Sander van Leeuwen | 
|---|
| 6 | * Copyright 2000 Przemyslaw Dobrowolski | 
|---|
| 7 | * | 
|---|
| 8 | * Project Odin Software License can be found in LICENSE.TXT | 
|---|
| 9 | */ | 
|---|
| 10 | #include <odin.h> | 
|---|
| 11 | #include <odinwrap.h> | 
|---|
| 12 | #include <os2win.h> | 
|---|
| 13 | #include <stdlib.h> | 
|---|
| 14 | #include <unicode.h> | 
|---|
| 15 | #include <heapstring.h> | 
|---|
| 16 | #include <options.h> | 
|---|
| 17 | #include <HandleManager.h> | 
|---|
| 18 | #include "debugtools.h" | 
|---|
| 19 | #include "oslibdos.h" | 
|---|
| 20 |  | 
|---|
| 21 |  | 
|---|
| 22 | #define DBG_LOCALLOG    DBG_npipe | 
|---|
| 23 | #include "dbglocal.h" | 
|---|
| 24 |  | 
|---|
| 25 | ODINDEBUGCHANNEL(KERNEL32-NPIPE) | 
|---|
| 26 |  | 
|---|
| 27 | //****************************************************************************** | 
|---|
| 28 | //****************************************************************************** | 
|---|
| 29 | ODINFUNCTION6(BOOL,PeekNamedPipe,HANDLE ,hPipe, | 
|---|
| 30 | LPVOID ,lpvBuffer, | 
|---|
| 31 | DWORD  ,cbBuffer, | 
|---|
| 32 | LPDWORD,lpcbRead, | 
|---|
| 33 | LPDWORD,lpcbAvail, | 
|---|
| 34 | LPDWORD,lpcbMessage) | 
|---|
| 35 | { | 
|---|
| 36 | return (HMPeekNamedPipe(hPipe,lpvBuffer,cbBuffer,lpcbRead,lpcbAvail,lpcbMessage)); | 
|---|
| 37 | } | 
|---|
| 38 | //****************************************************************************** | 
|---|
| 39 | //LPSECURITY_ATTRIBUTES lpsa;   /* address of security attributes   */ | 
|---|
| 40 | //****************************************************************************** | 
|---|
| 41 | ODINFUNCTION4(BOOL,                 CreatePipe, | 
|---|
| 42 | PHANDLE,              phRead, | 
|---|
| 43 | PHANDLE,              phWrite, | 
|---|
| 44 | LPSECURITY_ATTRIBUTES,lpsa, | 
|---|
| 45 | DWORD,                cbPipe) | 
|---|
| 46 | { | 
|---|
| 47 | return (HMCreatePipe(phRead,phWrite,lpsa,cbPipe)); | 
|---|
| 48 | } | 
|---|
| 49 |  | 
|---|
| 50 |  | 
|---|
| 51 | //****************************************************************************** | 
|---|
| 52 | //****************************************************************************** | 
|---|
| 53 | ODINFUNCTION8(HANDLE,CreateNamedPipeA,LPCTSTR,lpName, DWORD,dwOpenMode, DWORD,dwPipeMode, | 
|---|
| 54 | DWORD, nMaxInstances, DWORD, nOutBufferSize, | 
|---|
| 55 | DWORD, nInBufferSize, DWORD, nDefaultTimeOut, | 
|---|
| 56 | LPSECURITY_ATTRIBUTES, lpSecurityAttributes) | 
|---|
| 57 |  | 
|---|
| 58 | { | 
|---|
| 59 | return (HMCreateNamedPipe(lpName, | 
|---|
| 60 | dwOpenMode, | 
|---|
| 61 | dwPipeMode, | 
|---|
| 62 | nMaxInstances, | 
|---|
| 63 | nOutBufferSize, | 
|---|
| 64 | nInBufferSize, | 
|---|
| 65 | nDefaultTimeOut, | 
|---|
| 66 | lpSecurityAttributes)); | 
|---|
| 67 |  | 
|---|
| 68 | } | 
|---|
| 69 | //****************************************************************************** | 
|---|
| 70 | //****************************************************************************** | 
|---|
| 71 | ODINFUNCTION8(HANDLE,CreateNamedPipeW,LPCWSTR,lpName, DWORD,dwOpenMode, DWORD,dwPipeMode, | 
|---|
| 72 | DWORD, nMaxInstances, DWORD, nOutBufferSize, | 
|---|
| 73 | DWORD, nInBufferSize, DWORD, nDefaultTimeOut, | 
|---|
| 74 | LPSECURITY_ATTRIBUTES,lpSecurityAttributes) | 
|---|
| 75 | { | 
|---|
| 76 | char *asciiname; | 
|---|
| 77 | HANDLE hPipe; | 
|---|
| 78 |  | 
|---|
| 79 | asciiname  = UnicodeToAsciiString((LPWSTR)lpName); | 
|---|
| 80 |  | 
|---|
| 81 | hPipe=HMCreateNamedPipe(asciiname, | 
|---|
| 82 | dwOpenMode, | 
|---|
| 83 | dwPipeMode, | 
|---|
| 84 | nMaxInstances, | 
|---|
| 85 | nOutBufferSize, | 
|---|
| 86 | nInBufferSize, | 
|---|
| 87 | nDefaultTimeOut, | 
|---|
| 88 | lpSecurityAttributes); | 
|---|
| 89 |  | 
|---|
| 90 | FreeAsciiString(asciiname); | 
|---|
| 91 |  | 
|---|
| 92 | return(hPipe); | 
|---|
| 93 | } | 
|---|
| 94 | //****************************************************************************** | 
|---|
| 95 | //****************************************************************************** | 
|---|
| 96 |  | 
|---|
| 97 |  | 
|---|
| 98 | /***************************************************************************** | 
|---|
| 99 | * Name      : BOOL WIN32API ConnectNamedPipe | 
|---|
| 100 | * Purpose   : The ConnectNamedPipe function enables a named pipe server process | 
|---|
| 101 | *             to wait for a client process to connect to an instance of a | 
|---|
| 102 | *             named pipe. A client process connects by calling either the | 
|---|
| 103 | *             CreateFile or CallNamedPipe function. | 
|---|
| 104 | * Parameters:  HANDLE hNamedPipe      handle to named pipe to connect | 
|---|
| 105 | *              LPOVERLAPPED lpOverlapped  pointer to overlapped structure | 
|---|
| 106 | * Variables : | 
|---|
| 107 | * Result    : If the function succeeds, the return value is nonzero. | 
|---|
| 108 | *             If the function fails, the return value is zero. | 
|---|
| 109 | *             To get extended error information, call GetLastError. | 
|---|
| 110 | * Remark    : | 
|---|
| 111 | * Status    : NOT FULLY TESTED | 
|---|
| 112 | * | 
|---|
| 113 | * Author    : Przemyslaw Dobrowolski [Sun, 2000/01/02 12:48] | 
|---|
| 114 | *****************************************************************************/ | 
|---|
| 115 | ODINFUNCTION2(BOOL,ConnectNamedPipe,HANDLE,hNamedPipe, LPOVERLAPPED,lpOverlapped) | 
|---|
| 116 | { | 
|---|
| 117 | return (HMConnectNamedPipe(hNamedPipe,lpOverlapped)); | 
|---|
| 118 | } | 
|---|
| 119 |  | 
|---|
| 120 | /***************************************************************************** | 
|---|
| 121 | * Name      : BOOL WIN32AOI CallNamedPipeA | 
|---|
| 122 | * Purpose   : The CallNamedPipe function connects to a message-type pipe | 
|---|
| 123 | *             (and waits if an instance of the pipe is not available), | 
|---|
| 124 | *             writes to and reads from the pipe, and then closes the pipe. | 
|---|
| 125 | * Parameters:  LPCSTR lpNamedPipeName pointer to pipe name | 
|---|
| 126 | *              LPVOID lpInBuffer      pointer to write buffer | 
|---|
| 127 | *              DWORD nInBufferSize    size, in bytes, of write buffer | 
|---|
| 128 | *              LPVOID lpOutBuffer     pointer to read buffer | 
|---|
| 129 | *              DWORD nOutBufferSize   size, in bytes, of read buffer | 
|---|
| 130 | *              LPDWORD lpBytesRead    pointer to number of bytes read | 
|---|
| 131 | *              DWORD nTimeOut         time-out time, in milliseconds | 
|---|
| 132 | * Variables : | 
|---|
| 133 | * Result    : If the function succeeds, the return value is nonzero. | 
|---|
| 134 | *             If the function fails, the return value is zero. | 
|---|
| 135 | *             To get extended error information, call GetLastError. | 
|---|
| 136 | * Remark    : Calling CallNamedPipe is equivalent to calling the CreateFile | 
|---|
| 137 | *             (or WaitNamedPipe, if CreateFile cannot open the pipe immediately), | 
|---|
| 138 | *             TransactNamedPipe, and CloseHandle functions. CreateFile is called | 
|---|
| 139 | *             with an access flag of GENERIC_READ | GENERIC_WRITE, an inherit | 
|---|
| 140 | *             handle flag of FALSE, and a share mode of zero (indicating no | 
|---|
| 141 | *             sharing of this pipe instance). | 
|---|
| 142 | *             If the message written to the pipe by the server process is | 
|---|
| 143 | *             longer than nOutBufferSize, CallNamedPipe returns FALSE, and | 
|---|
| 144 | *             GetLastError returns ERROR_MORE_DATA. The remainder of the | 
|---|
| 145 | *             message is discarded, because CallNamedPipe closes the handle | 
|---|
| 146 | *             to the pipe before returning. | 
|---|
| 147 | * | 
|---|
| 148 | *             CallNamedPipe fails if the pipe is a byte-type pipe. | 
|---|
| 149 | * Status    : NOT FULLY TESTED | 
|---|
| 150 | * | 
|---|
| 151 | * Author    : Przemyslaw Dobrowolski [Mon, 2000/01/03 13:32] | 
|---|
| 152 | *****************************************************************************/ | 
|---|
| 153 |  | 
|---|
| 154 | ODINFUNCTION7(BOOL,CallNamedPipeA,LPCSTR , lpNamedPipeName, | 
|---|
| 155 | LPVOID , lpInBuffer, | 
|---|
| 156 | DWORD  , nInBufferSize, | 
|---|
| 157 | LPVOID , lpOutBuffer, | 
|---|
| 158 | DWORD  , nOutBufferSize, | 
|---|
| 159 | LPDWORD, lpBytesRead, | 
|---|
| 160 | DWORD  , nTimeOut) | 
|---|
| 161 | { | 
|---|
| 162 | return(OSLibDosCallNamedPipe(lpNamedPipeName, | 
|---|
| 163 | lpInBuffer, | 
|---|
| 164 | nInBufferSize, | 
|---|
| 165 | lpOutBuffer, | 
|---|
| 166 | nOutBufferSize, | 
|---|
| 167 | lpBytesRead, | 
|---|
| 168 | nTimeOut )); | 
|---|
| 169 | } | 
|---|
| 170 |  | 
|---|
| 171 | /***************************************************************************** | 
|---|
| 172 | * Name      : BOOL WIN32AOI CallNamedPipeW | 
|---|
| 173 | * Purpose   : The CallNamedPipe function connects to a message-type pipe | 
|---|
| 174 | *             (and waits if an instance of the pipe is not available), | 
|---|
| 175 | *             writes to and reads from the pipe, and then closes the pipe. | 
|---|
| 176 | * Parameters:  LPCWSTR lpNamedPipeName pointer to pipe name | 
|---|
| 177 | *              LPVOID lpInBuffer      pointer to write buffer | 
|---|
| 178 | *              DWORD nInBufferSize    size, in bytes, of write buffer | 
|---|
| 179 | *              LPVOID lpOutBuffer     pointer to read buffer | 
|---|
| 180 | *              DWORD nOutBufferSize   size, in bytes, of read buffer | 
|---|
| 181 | *              LPDWORD lpBytesRead    pointer to number of bytes read | 
|---|
| 182 | *              DWORD nTimeOut         time-out time, in milliseconds | 
|---|
| 183 | * Variables : | 
|---|
| 184 | * Result    : If the function succeeds, the return value is nonzero. | 
|---|
| 185 | *             If the function fails, the return value is zero. | 
|---|
| 186 | *             To get extended error information, call GetLastError. | 
|---|
| 187 | * Remark    : Calling CallNamedPipe is equivalent to calling the CreateFile | 
|---|
| 188 | *             (or WaitNamedPipe, if CreateFile cannot open the pipe immediately), | 
|---|
| 189 | *             TransactNamedPipe, and CloseHandle functions. CreateFile is called | 
|---|
| 190 | *             with an access flag of GENERIC_READ | GENERIC_WRITE, an inherit | 
|---|
| 191 | *             handle flag of FALSE, and a share mode of zero (indicating no | 
|---|
| 192 | *             sharing of this pipe instance). | 
|---|
| 193 | *             If the message written to the pipe by the server process is | 
|---|
| 194 | *             longer than nOutBufferSize, CallNamedPipe returns FALSE, and | 
|---|
| 195 | *             GetLastError returns ERROR_MORE_DATA. The remainder of the | 
|---|
| 196 | *             message is discarded, because CallNamedPipe closes the handle | 
|---|
| 197 | *             to the pipe before returning. | 
|---|
| 198 | * | 
|---|
| 199 | *             CallNamedPipe fails if the pipe is a byte-type pipe. | 
|---|
| 200 | * Status    : NOT FULLY TESTED | 
|---|
| 201 | * | 
|---|
| 202 | * Author    : Przemyslaw Dobrowolski [Mon, 2000/01/03 13:33] | 
|---|
| 203 | *****************************************************************************/ | 
|---|
| 204 | ODINFUNCTION7(BOOL,CallNamedPipeW,LPCWSTR , lpNamedPipeName, | 
|---|
| 205 | LPVOID , lpInBuffer, | 
|---|
| 206 | DWORD  , nInBufferSize, | 
|---|
| 207 | LPVOID , lpOutBuffer, | 
|---|
| 208 | DWORD  , nOutBufferSize, | 
|---|
| 209 | LPDWORD, lpBytesRead, | 
|---|
| 210 | DWORD  , nTimeOut) | 
|---|
| 211 | { | 
|---|
| 212 | char *asciiname; | 
|---|
| 213 | BOOL rc; | 
|---|
| 214 |  | 
|---|
| 215 | asciiname  = UnicodeToAsciiString((LPWSTR)lpNamedPipeName); | 
|---|
| 216 |  | 
|---|
| 217 | rc=OSLibDosCallNamedPipe(asciiname, | 
|---|
| 218 | lpInBuffer, | 
|---|
| 219 | nInBufferSize, | 
|---|
| 220 | lpOutBuffer, | 
|---|
| 221 | nOutBufferSize, | 
|---|
| 222 | lpBytesRead, | 
|---|
| 223 | nTimeOut ); | 
|---|
| 224 |  | 
|---|
| 225 | FreeAsciiString(asciiname); | 
|---|
| 226 |  | 
|---|
| 227 | return(rc); | 
|---|
| 228 | } | 
|---|
| 229 |  | 
|---|
| 230 | /***************************************************************************** | 
|---|
| 231 | * Name      : BOOL WIN32API DisconnectNamedPipe | 
|---|
| 232 | * Purpose   : The DisconnectNamedPipe function disconnects the server end | 
|---|
| 233 | *             of a named pipe instance from a client process. | 
|---|
| 234 | * Parameters: HANDLE hNamedPipe    handle to named pipe | 
|---|
| 235 | * Variables : | 
|---|
| 236 | * Result    : If the function succeeds, the return value is nonzero. | 
|---|
| 237 | *             If the function fails, the return value is zero | 
|---|
| 238 | * Remark    : | 
|---|
| 239 | * Status    : NOT FULLY TESTED | 
|---|
| 240 | * | 
|---|
| 241 | * Author    : Przemyslaw Dobrowolski [Mon, 2000/01/03 13:34] | 
|---|
| 242 | *****************************************************************************/ | 
|---|
| 243 |  | 
|---|
| 244 | ODINFUNCTION1(BOOL,DisconnectNamedPipe,HANDLE,hNamedPipe) | 
|---|
| 245 | { | 
|---|
| 246 | return (HMDisconnectNamedPipe(hNamedPipe)); | 
|---|
| 247 | } | 
|---|
| 248 |  | 
|---|
| 249 | /***************************************************************************** | 
|---|
| 250 | * Name      : BOOL GetNamedPipeHandleStateA | 
|---|
| 251 | * Purpose   : The GetNamedPipeHandleStateA function retrieves information about | 
|---|
| 252 | *             a specified named pipe. The information returned can vary during | 
|---|
| 253 | *             the lifetime of an instance of the named pipe. | 
|---|
| 254 | * Parameters: HANDLE  hNamedPipe           handle of named pipe | 
|---|
| 255 | *             LPDWORD lpState              address of flags indicating pipe state | 
|---|
| 256 | *             LPDWORD lpCurInstances       address of number of current pipe instances | 
|---|
| 257 | *             LPDWORD lpMaxCollectionCount address of max. bytes before remote transmission | 
|---|
| 258 | *             LPDWORD lpCollectDataTimeout address of max. time before remote transmission | 
|---|
| 259 | *             LPTSTR  lpUserName           address of user name of client process | 
|---|
| 260 | *             DWORD   nMaxUserNameSize     size, in characters, of user name buffer | 
|---|
| 261 | * Variables : | 
|---|
| 262 | * Result    : TRUE / FALSE | 
|---|
| 263 | * Remark    : | 
|---|
| 264 | * Status    : UNTESTED STUB | 
|---|
| 265 | * | 
|---|
| 266 | * Author    : Patrick Haller [Mon, 1998/06/15 08:00] | 
|---|
| 267 | *****************************************************************************/ | 
|---|
| 268 |  | 
|---|
| 269 | BOOL WIN32API GetNamedPipeHandleStateA(HANDLE  hNamedPipe, | 
|---|
| 270 | LPDWORD lpState, | 
|---|
| 271 | LPDWORD lpCurInstances, | 
|---|
| 272 | LPDWORD lpMaxCollectionCount, | 
|---|
| 273 | LPDWORD lpCollectDataTimeout, | 
|---|
| 274 | LPTSTR  lpUserName, | 
|---|
| 275 | DWORD   nMaxUserNameSize) | 
|---|
| 276 | { | 
|---|
| 277 | // Not implemented but waiting to implementation in hmnpipe.cpp | 
|---|
| 278 | return ( HMGetNamedPipeHandleState( hNamedPipe, | 
|---|
| 279 | lpState, | 
|---|
| 280 | lpCurInstances, | 
|---|
| 281 | lpMaxCollectionCount, | 
|---|
| 282 | lpCollectDataTimeout, | 
|---|
| 283 | lpUserName, | 
|---|
| 284 | nMaxUserNameSize)); | 
|---|
| 285 | } | 
|---|
| 286 |  | 
|---|
| 287 |  | 
|---|
| 288 | /***************************************************************************** | 
|---|
| 289 | * Name      : BOOL GetNamedPipeHandleStateW | 
|---|
| 290 | * Purpose   : The GetNamedPipeHandleStateW function retrieves information about | 
|---|
| 291 | *             a specified named pipe. The information returned can vary during | 
|---|
| 292 | *             the lifetime of an instance of the named pipe. | 
|---|
| 293 | * Parameters: HANDLE  hNamedPipe           handle of named pipe | 
|---|
| 294 | *             LPDWORD lpState              address of flags indicating pipe state | 
|---|
| 295 | *             LPDWORD lpCurInstances       address of number of current pipe instances | 
|---|
| 296 | *             LPDWORD lpMaxCollectionCount address of max. bytes before remote transmission | 
|---|
| 297 | *             LPDWORD lpCollectDataTimeout address of max. time before remote transmission | 
|---|
| 298 | *             LPWSTR  lpUserName           address of user name of client process | 
|---|
| 299 | *             DWORD   nMaxUserNameSize     size, in characters, of user name buffer | 
|---|
| 300 | * Variables : | 
|---|
| 301 | * Result    : TRUE / FALSE | 
|---|
| 302 | * Remark    : | 
|---|
| 303 | * Status    : UNTESTED STUB | 
|---|
| 304 | * | 
|---|
| 305 | * Author    : Patrick Haller [Mon, 1998/06/15 08:00] | 
|---|
| 306 | *****************************************************************************/ | 
|---|
| 307 |  | 
|---|
| 308 | BOOL WIN32API GetNamedPipeHandleStateW(HANDLE  hNamedPipe, | 
|---|
| 309 | LPDWORD lpState, | 
|---|
| 310 | LPDWORD lpCurInstances, | 
|---|
| 311 | LPDWORD lpMaxCollectionCount, | 
|---|
| 312 | LPDWORD lpCollectDataTimeout, | 
|---|
| 313 | LPWSTR  lpUserName, | 
|---|
| 314 | DWORD   nMaxUserNameSize) | 
|---|
| 315 | { | 
|---|
| 316 | char *asciiname; | 
|---|
| 317 | BOOL rc; | 
|---|
| 318 |  | 
|---|
| 319 | asciiname  = UnicodeToAsciiString((LPWSTR)lpUserName); | 
|---|
| 320 |  | 
|---|
| 321 | // Not implemented but waiting to implementation in hmnpipe.cpp | 
|---|
| 322 | rc= HMGetNamedPipeHandleState( hNamedPipe, | 
|---|
| 323 | lpState, | 
|---|
| 324 | lpCurInstances, | 
|---|
| 325 | lpMaxCollectionCount, | 
|---|
| 326 | lpCollectDataTimeout, | 
|---|
| 327 | asciiname, | 
|---|
| 328 | nMaxUserNameSize); | 
|---|
| 329 |  | 
|---|
| 330 |  | 
|---|
| 331 | FreeAsciiString(asciiname); | 
|---|
| 332 |  | 
|---|
| 333 | return (rc); | 
|---|
| 334 | } | 
|---|
| 335 |  | 
|---|
| 336 |  | 
|---|
| 337 | /***************************************************************************** | 
|---|
| 338 | * Name      : BOOL GetNamedPipeInfo | 
|---|
| 339 | * Purpose   : The GetNamedPipeInfo function retrieves information about the specified named pipe. | 
|---|
| 340 | * Parameters: HANDLE  hNamedPipe      handle of named pipe | 
|---|
| 341 | *             LPDWORD lpFlags         address of flags indicating type of pipe | 
|---|
| 342 | *             LPDWORD lpOutBufferSize address of size, in bytes, of pipe's output buffer | 
|---|
| 343 | *             LPDWORD lpInBufferSize  address of size, in bytes, of pipe's input buffer | 
|---|
| 344 | *             LPDWORD lpMaxInstances  address of max. number of pipe instances | 
|---|
| 345 | * Variables : | 
|---|
| 346 | * Result    : TRUE / FALSE | 
|---|
| 347 | * Remark    : | 
|---|
| 348 | * Status    : UNTESTED STUB | 
|---|
| 349 | * | 
|---|
| 350 | * Author    : Patrick Haller [Mon, 1998/06/15 08:00] | 
|---|
| 351 | *****************************************************************************/ | 
|---|
| 352 |  | 
|---|
| 353 | BOOL WIN32API GetNamedPipeInfo(HANDLE  hNamedPipe, | 
|---|
| 354 | LPDWORD lpFlags, | 
|---|
| 355 | LPDWORD lpOutBufferSize, | 
|---|
| 356 | LPDWORD lpInBufferSize, | 
|---|
| 357 | LPDWORD lpMaxInstances) | 
|---|
| 358 | { | 
|---|
| 359 | // Not implemented but waiting to implementation in hmnpipe.cpp | 
|---|
| 360 | return ( HMGetNamedPipeInfo( hNamedPipe, | 
|---|
| 361 | lpFlags, | 
|---|
| 362 | lpOutBufferSize, | 
|---|
| 363 | lpInBufferSize, | 
|---|
| 364 | lpMaxInstances)); | 
|---|
| 365 |  | 
|---|
| 366 | } | 
|---|
| 367 |  | 
|---|
| 368 | /***************************************************************************** | 
|---|
| 369 | * Name      : BOOL SetNamedPipeHandleState | 
|---|
| 370 | * Purpose   : The SetNamedPipeHandleState function sets the read mode and the | 
|---|
| 371 | *             blocking mode of the specified named pipe. If the specified handle | 
|---|
| 372 | *             is to the client end of a named pipe and if the named pipe server | 
|---|
| 373 | *             process is on a remote computer, the function can also be used to | 
|---|
| 374 | *             control local buffering. | 
|---|
| 375 | * Parameters: HANDLE  hNamedPipe     handle of named pipe | 
|---|
| 376 | *             LPDWORD lpdwMode       address of new pipe mode | 
|---|
| 377 | *             LPDWORD lpcbMaxCollect address of max. bytes before remote transmission | 
|---|
| 378 | *             LPDWORD lpdwCollectDataTimeout address of max. time before remote transmission | 
|---|
| 379 | * Variables : | 
|---|
| 380 | * Result    : TRUE / FALSE | 
|---|
| 381 | * Remark    : | 
|---|
| 382 | * Status    : UNTESTED STUB | 
|---|
| 383 | * | 
|---|
| 384 | * Author    : Patrick Haller [Mon, 1998/06/15 08:00] | 
|---|
| 385 | *****************************************************************************/ | 
|---|
| 386 |  | 
|---|
| 387 | BOOL WIN32API SetNamedPipeHandleState(HANDLE  hNamedPipe, | 
|---|
| 388 | LPDWORD lpdwMode, | 
|---|
| 389 | LPDWORD lpcbMaxCollect, | 
|---|
| 390 | LPDWORD lpdwCollectDataTimeout) | 
|---|
| 391 | { | 
|---|
| 392 | // Not implemented but waiting to implementation in hmnpipe.cpp | 
|---|
| 393 | return ( HMSetNamedPipeHandleState( hNamedPipe, | 
|---|
| 394 | lpdwMode, | 
|---|
| 395 | lpcbMaxCollect, | 
|---|
| 396 | lpdwCollectDataTimeout)); | 
|---|
| 397 | } | 
|---|
| 398 |  | 
|---|
| 399 | /***************************************************************************** | 
|---|
| 400 | * Name      : DWORD TransactNamedPipe | 
|---|
| 401 | * Purpose   : The TransactNamedPipe function combines into a single network | 
|---|
| 402 | *             operation the functions that write a message to and read a | 
|---|
| 403 | *             message from the specified named pipe. | 
|---|
| 404 | * Parameters: HANDLE       hNamedPipe  handle of named pipe | 
|---|
| 405 | *             LPVOID       lpvWriteBuf address of write buffer | 
|---|
| 406 | *             DWORD        cbWriteBuf  size of the write buffer, in bytes | 
|---|
| 407 | *             LPVOID       lpvReadBuf  address of read buffer | 
|---|
| 408 | *             DWORD        cbReadBuf   size of read buffer, in bytes | 
|---|
| 409 | *             LPDWORD      lpcbRead    address of variable for bytes actually read | 
|---|
| 410 | *             LPOVERLAPPED lpo         address of overlapped structure | 
|---|
| 411 | * Variables : | 
|---|
| 412 | * Result    : TRUE / FALSE | 
|---|
| 413 | * Remark    : | 
|---|
| 414 | * Status    : NOT FULLY TESTED (YET!) | 
|---|
| 415 | * | 
|---|
| 416 | * Author    : Przemyslaw Dobrowolski [Mon, 2000/01/03 08:48] | 
|---|
| 417 | *****************************************************************************/ | 
|---|
| 418 |  | 
|---|
| 419 | ODINFUNCTION7(DWORD,TransactNamedPipe,HANDLE,hNamedPipe, | 
|---|
| 420 | LPVOID,lpvWriteBuf, | 
|---|
| 421 | DWORD,cbWriteBuf, | 
|---|
| 422 | LPVOID,lpvReadBuf, | 
|---|
| 423 | DWORD,cbReadBuf, | 
|---|
| 424 | LPDWORD,lpcbRead, | 
|---|
| 425 | LPOVERLAPPED,lpo) | 
|---|
| 426 | { | 
|---|
| 427 | return(HMTransactNamedPipe( hNamedPipe, | 
|---|
| 428 | lpvWriteBuf, | 
|---|
| 429 | cbWriteBuf, | 
|---|
| 430 | lpvReadBuf, | 
|---|
| 431 | cbReadBuf, | 
|---|
| 432 | lpcbRead, | 
|---|
| 433 | lpo)); | 
|---|
| 434 | } | 
|---|
| 435 |  | 
|---|
| 436 | /***************************************************************************** | 
|---|
| 437 | * Name      : BOOL WaitNamedPipeA | 
|---|
| 438 | * Purpose   : The WaitNamedPipe function waits until either a time-out interval | 
|---|
| 439 | *             elapses or an instance of the specified named pipe is available | 
|---|
| 440 | *             to be connected to (that is, the pipe's server process has a | 
|---|
| 441 | *             pending ConnectNamedPipe operation on the pipe). | 
|---|
| 442 | * Parameters: LPCTSTR lpszNamedPipeName | 
|---|
| 443 | *             DWORD   dwTimeout | 
|---|
| 444 | * Variables : | 
|---|
| 445 | * Result    : TRUE / FALSE | 
|---|
| 446 | * Remark    : | 
|---|
| 447 | * Status    : UNTESTED (YET) | 
|---|
| 448 | * | 
|---|
| 449 | * Author    : Przemyslaw Dobrowolski [Mon, 2000/01/03 13:52] | 
|---|
| 450 | *****************************************************************************/ | 
|---|
| 451 |  | 
|---|
| 452 | ODINFUNCTION2(BOOL,WaitNamedPipeA,LPCSTR,lpszNamedPipeName, DWORD, dwTimeout) | 
|---|
| 453 | { | 
|---|
| 454 | return(OSLibDosWaitNamedPipe(lpszNamedPipeName, dwTimeout)); | 
|---|
| 455 | } | 
|---|
| 456 |  | 
|---|
| 457 |  | 
|---|
| 458 | /***************************************************************************** | 
|---|
| 459 | * Name      : BOOL WaitNamedPipeW | 
|---|
| 460 | * Purpose   : The WaitNamedPipe function waits until either a time-out interval | 
|---|
| 461 | *             elapses or an instance of the specified named pipe is available | 
|---|
| 462 | *             to be connected to (that is, the pipe's server process has a | 
|---|
| 463 | *             pending ConnectNamedPipe operation on the pipe). | 
|---|
| 464 | * Parameters: LPCWSTR lpszNamedPipeName | 
|---|
| 465 | *             DWORD   dwTimeout | 
|---|
| 466 | * Variables : | 
|---|
| 467 | * Result    : TRUE / FALSE | 
|---|
| 468 | * Remark    : | 
|---|
| 469 | * Status    : UNTESTED (YET) | 
|---|
| 470 | * | 
|---|
| 471 | * Author    : Przemyslaw Dobrowolski [Mon, 2000/01/03 13:44] | 
|---|
| 472 | *****************************************************************************/ | 
|---|
| 473 |  | 
|---|
| 474 | ODINFUNCTION2(BOOL,WaitNamedPipeW,LPCWSTR,lpszNamedPipeName, DWORD, dwTimeout) | 
|---|
| 475 | { | 
|---|
| 476 | char  *asciiname; | 
|---|
| 477 | DWORD rc; | 
|---|
| 478 |  | 
|---|
| 479 | asciiname  = UnicodeToAsciiString((LPWSTR)lpszNamedPipeName); | 
|---|
| 480 |  | 
|---|
| 481 | rc=OSLibDosWaitNamedPipe(asciiname, dwTimeout); | 
|---|
| 482 |  | 
|---|
| 483 | FreeAsciiString(asciiname); | 
|---|
| 484 |  | 
|---|
| 485 | return(rc); | 
|---|
| 486 | } | 
|---|