source: trunk/src/kernel32/npipe.cpp@ 22018

Last change on this file since 22018 was 21302, checked in by ydario, 16 years ago

Kernel32 updates.

File size: 28.6 KB
Line 
1/* $Id: npipe.cpp,v 1.12 2003-06-02 16:25:18 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#include "hmhandle.h"
22#include "hmnpipe.h"
23
24#define DBG_LOCALLOG DBG_npipe
25#include "dbglocal.h"
26
27ODINDEBUGCHANNEL(KERNEL32-NPIPE)
28
29//******************************************************************************
30//******************************************************************************
31BOOL WIN32API CreatePipe(PHANDLE phRead, PHANDLE phWrite,
32 LPSECURITY_ATTRIBUTES lpsa, DWORD cbPipe)
33{
34 char szPipeName[64];
35 HANDLE hPipeRead, hPipeWrite;
36
37 // create a unique pipe name
38 for(int i=0;i<16;i++)
39 {
40 sprintf(szPipeName, "\\\\.\\pipe\\Win32.Pipes.%08x.%08x", GetCurrentProcessId(), GetCurrentTime());
41 hPipeRead = ::CreateNamedPipeA(szPipeName, PIPE_ACCESS_INBOUND,
42 PIPE_TYPE_BYTE | PIPE_WAIT, 1, cbPipe, cbPipe,
43 NMPWAIT_USE_DEFAULT_WAIT, lpsa);
44 if(hPipeRead != INVALID_HANDLE_VALUE) break;
45
46 Sleep(10);
47 }
48
49 if (hPipeRead == INVALID_HANDLE_VALUE) {
50 dprintf(("ERROR: Unable to create named pipe with unique name!! (%s)", szPipeName));
51 return FALSE;
52 }
53
54 ULONG mode = PIPE_NOWAIT|PIPE_READMODE_BYTE;
55
56 //Set pipe in non-blocking mode
57 SetNamedPipeHandleState(hPipeRead, &mode, NULL, NULL);
58
59 //Set pipe in listening mode (so the next CreateFile will succeed)
60 ConnectNamedPipe(hPipeRead, NULL);
61
62 //Put pipe back in blocking mode
63 mode = PIPE_WAIT|PIPE_READMODE_BYTE;
64 SetNamedPipeHandleState(hPipeRead, &mode, NULL, NULL);
65
66 //Create write pipe
67 hPipeWrite = CreateFileA(szPipeName, GENERIC_WRITE, 0, lpsa, OPEN_EXISTING, 0, 0);
68 if (hPipeWrite == INVALID_HANDLE_VALUE)
69 {
70 dprintf(("ERROR: Unable to create write handle for anonymous pipe!!"));
71 CloseHandle(hPipeRead);
72 return FALSE;
73 }
74
75 dprintf(("Created pipe with handles %x and %x", hPipeRead, hPipeWrite));
76 *phRead = hPipeRead;
77 *phWrite = hPipeWrite;
78 return TRUE;
79}
80
81/*****************************************************************************
82 * Name : CreateNamedPipe
83 * Purpose :
84 * Parameters:
85 * Variables :
86 * Result :
87 * Remark :
88 * Status :
89 *
90 * Author : Przemyslaw Dobrowolski
91 *****************************************************************************/
92HANDLE WIN32API CreateNamedPipeA(LPCTSTR lpName,
93 DWORD dwOpenMode,
94 DWORD dwPipeMode,
95 DWORD nMaxInstances,
96 DWORD nOutBufferSize,
97 DWORD nInBufferSize,
98 DWORD nDefaultTimeOut,
99 LPSECURITY_ATTRIBUTES lpSecurityAttributes)
100{
101 PHMHANDLE pHandle;
102 HANDLE rc; /* API return code */
103
104 SetLastError(ERROR_SUCCESS);
105
106 pHandle = HMHandleGetFreePtr(HMTYPE_PIPE); /* get free handle */
107 if (pHandle == NULL) /* oops, no free handles ! */
108 {
109 SetLastError(ERROR_NOT_ENOUGH_MEMORY); /* use this as error message */
110 return INVALID_HANDLE_VALUE;
111 }
112
113 /* call the device handler */
114 rc = pHandle->pDeviceHandler->CreateNamedPipe(&pHandle->hmHandleData,
115 lpName,dwOpenMode,
116 dwPipeMode,nMaxInstances,
117 nOutBufferSize,nInBufferSize,
118 nDefaultTimeOut,lpSecurityAttributes);
119
120 if (rc == INVALID_HANDLE_VALUE)
121 {
122 HMHandleFree(pHandle->hmHandleData.hWin32Handle);
123 return INVALID_HANDLE_VALUE; /* signal error */
124 }
125
126 dprintf(("Named pipe %x", pHandle->hmHandleData.hWin32Handle));
127 if(lpSecurityAttributes && lpSecurityAttributes->bInheritHandle) {
128 dprintf(("Set inheritance for child processes"));
129 HMSetHandleInformation(pHandle->hmHandleData.hWin32Handle, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT);
130 }
131
132 return pHandle->hmHandleData.hWin32Handle;
133}
134/*****************************************************************************
135 * Name : BOOL WIN32API ConnectNamedPipe
136 * Purpose : The ConnectNamedPipe function enables a named pipe server process
137 * to wait for a client process to connect to an instance of a
138 * named pipe. A client process connects by calling either the
139 * CreateFile or CallNamedPipe function.
140 * Parameters: HANDLE hNamedPipe handle to named pipe to connect
141 * LPOVERLAPPED lpOverlapped pointer to overlapped structure
142 * Variables :
143 * Result : If the function succeeds, the return value is nonzero.
144 * If the function fails, the return value is zero.
145 * To get extended error information, call GetLastError.
146 * Remark :
147 * Status : NOT FULLY TESTED
148 *
149 * Author : Przemyslaw Dobrowolski [Sun, 2000/01/02 12:48]
150 *****************************************************************************/
151
152BOOL WIN32API ConnectNamedPipe(HANDLE hPipe, LPOVERLAPPED lpOverlapped)
153{
154 BOOL lpResult; /* result from the device handler's API */
155 PHMHANDLE pHMHandle; /* pointer to the handle structure in the table */
156
157 SetLastError(ERROR_SUCCESS);
158 /* validate handle */
159 pHMHandle = HMHandleQueryPtr(hPipe); /* get the index */
160 if (pHMHandle == NULL) /* error ? */
161 {
162 return FALSE; //last error set by HMHandleQueryPtr (ERROR_INVALID_HANDLE)
163 }
164
165 lpResult = pHMHandle->pDeviceHandler->ConnectNamedPipe(&pHMHandle->hmHandleData,
166 lpOverlapped);
167
168 return (lpResult); /* deliver return code */
169}
170
171/*****************************************************************************
172 * Name : BOOL WIN32API DisconnectNamedPipe
173 * Purpose : The DisconnectNamedPipe function disconnects the server end
174 * of a named pipe instance from a client process.
175 * Parameters: HANDLE hNamedPipe handle to named pipe
176 * Variables :
177 * Result : If the function succeeds, the return value is nonzero.
178 * If the function fails, the return value is zero
179 * Remark :
180 * Status : NOT FULLY TESTED
181 *
182 * Author : Przemyslaw Dobrowolski [Mon, 2000/01/03 13:34]
183 *****************************************************************************/
184
185BOOL WIN32API DisconnectNamedPipe(HANDLE hPipe)
186{
187 BOOL lpResult; /* result from the device handler's API */
188 PHMHANDLE pHMHandle; /* pointer to the handle structure in the table */
189
190 SetLastError(ERROR_SUCCESS);
191 /* validate handle */
192 pHMHandle = HMHandleQueryPtr(hPipe); /* get the index */
193 if (pHMHandle == NULL) /* error ? */
194 {
195 return FALSE; //last error set by HMHandleQueryPtr (ERROR_INVALID_HANDLE)
196 }
197
198 lpResult = pHMHandle->pDeviceHandler->DisconnectNamedPipe(&pHMHandle->hmHandleData);
199
200 return (lpResult); /* deliver return code */
201}
202
203/*****************************************************************************
204 * Name : PeekNamedPipe
205 * Purpose :
206 * Parameters:
207 * Variables :
208 * Result :
209 * Remark :
210 * Status :
211 *
212 * Author : Przemyslaw Dobrowolski
213 *****************************************************************************/
214BOOL WIN32API PeekNamedPipe(HANDLE hPipe,
215 LPVOID lpvBuffer,
216 DWORD cbBuffer,
217 LPDWORD lpcbRead,
218 LPDWORD lpcbAvail,
219 LPDWORD lpcbMessage)
220{
221 BOOL lpResult; /* result from the device handler's API */
222 PHMHANDLE pHMHandle; /* pointer to the handle structure in the table */
223
224 SetLastError(ERROR_SUCCESS);
225 /* validate handle */
226 pHMHandle = HMHandleQueryPtr(hPipe); /* get the index */
227 if (pHMHandle == NULL) /* error ? */
228 {
229 return FALSE; //last error set by HMHandleQueryPtr (ERROR_INVALID_HANDLE)
230 }
231
232 lpResult = pHMHandle->pDeviceHandler->PeekNamedPipe(&pHMHandle->hmHandleData,
233 lpvBuffer,
234 cbBuffer,
235 lpcbRead,
236 lpcbAvail,
237 lpcbMessage);
238
239 return (lpResult); /* deliver return code */
240}
241
242/*****************************************************************************
243 * Name : BOOL GetNamedPipeHandleStateA
244 * Purpose : The GetNamedPipeHandleStateA function retrieves information about
245 * a specified named pipe. The information returned can vary during
246 * the lifetime of an instance of the named pipe.
247 * Parameters: HANDLE hNamedPipe handle of named pipe
248 * LPDWORD lpState address of flags indicating pipe state
249 * LPDWORD lpCurInstances address of number of current pipe instances
250 * LPDWORD lpMaxCollectionCount address of max. bytes before remote transmission
251 * LPDWORD lpCollectDataTimeout address of max. time before remote transmission
252 * LPTSTR lpUserName address of user name of client process
253 * DWORD nMaxUserNameSize size, in characters, of user name buffer
254 * Variables :
255 * Result : TRUE / FALSE
256 * Remark :
257 * Status : UNTESTED STUB
258 *
259 * Author : Patrick Haller [Mon, 1998/06/15 08:00]
260 *****************************************************************************/
261
262BOOL WIN32API GetNamedPipeHandleStateA(HANDLE hPipe,
263 LPDWORD lpState,
264 LPDWORD lpCurInstances,
265 LPDWORD lpMaxCollectionCount,
266 LPDWORD lpCollectDataTimeout,
267 LPTSTR lpUserName,
268 DWORD nMaxUserNameSize)
269{
270 BOOL lpResult; /* result from the device handler's API */
271 PHMHANDLE pHMHandle; /* pointer to the handle structure in the table */
272
273 SetLastError(ERROR_SUCCESS);
274 /* validate handle */
275 pHMHandle = HMHandleQueryPtr(hPipe); /* get the index */
276 if (pHMHandle == NULL) /* error ? */
277 {
278 return FALSE; //last error set by HMHandleQueryPtr (ERROR_INVALID_HANDLE)
279 }
280
281 lpResult = pHMHandle->pDeviceHandler->GetNamedPipeHandleState(&pHMHandle->hmHandleData,
282 lpState,
283 lpCurInstances,
284 lpMaxCollectionCount,
285 lpCollectDataTimeout,
286 lpUserName,
287 nMaxUserNameSize);
288
289
290 return (lpResult); /* deliver return code */
291}
292
293/*****************************************************************************
294 * Name : BOOL GetNamedPipeInfo
295 * Purpose : The GetNamedPipeInfo function retrieves information about the specified named pipe.
296 * Parameters: HANDLE hNamedPipe handle of named pipe
297 * LPDWORD lpFlags address of flags indicating type of pipe
298 * LPDWORD lpOutBufferSize address of size, in bytes, of pipe's output buffer
299 * LPDWORD lpInBufferSize address of size, in bytes, of pipe's input buffer
300 * LPDWORD lpMaxInstances address of max. number of pipe instances
301 * Variables :
302 * Result : TRUE / FALSE
303 * Remark :
304 * Status :
305 *
306 * Author : Przemyslaw Dobrowolski
307 *****************************************************************************/
308
309BOOL WIN32API GetNamedPipeInfo(HANDLE hPipe,
310 LPDWORD lpFlags,
311 LPDWORD lpOutBufferSize,
312 LPDWORD lpInBufferSize,
313 LPDWORD lpMaxInstances)
314{
315 BOOL lpResult; /* result from the device handler's API */
316 PHMHANDLE pHMHandle; /* pointer to the handle structure in the table */
317
318 SetLastError(ERROR_SUCCESS);
319 /* validate handle */
320 pHMHandle = HMHandleQueryPtr(hPipe); /* get the index */
321 if (pHMHandle == NULL) /* error ? */
322 {
323 return FALSE; //last error set by HMHandleQueryPtr (ERROR_INVALID_HANDLE)
324 }
325
326 lpResult = pHMHandle->pDeviceHandler->GetNamedPipeInfo(&pHMHandle->hmHandleData,
327 lpFlags,
328 lpOutBufferSize,
329 lpInBufferSize,
330 lpMaxInstances);
331
332 return (lpResult); /* deliver return code */
333}
334
335/*****************************************************************************
336 * Name : BOOL TransactNamedPipe
337 * Purpose : The TransactNamedPipe function combines into a single network
338 * operation the functions that write a message to and read a
339 * message from the specified named pipe.
340 * Parameters: HANDLE hNamedPipe handle of named pipe
341 * LPVOID lpvWriteBuf address of write buffer
342 * DWORD cbWriteBuf size of the write buffer, in bytes
343 * LPVOID lpvReadBuf address of read buffer
344 * DWORD cbReadBuf size of read buffer, in bytes
345 * LPDWORD lpcbRead address of variable for bytes actually read
346 * LPOVERLAPPED lpo address of overlapped structure
347 * Variables :
348 * Result : TRUE / FALSE
349 * Remark :
350 * Status : NOT FULLY TESTED (YET!)
351 *
352 * Author : Przemyslaw Dobrowolski [Mon, 2000/01/03 08:48]
353 *****************************************************************************/
354BOOL WIN32API TransactNamedPipe(HANDLE hPipe,
355 LPVOID lpvWriteBuf,
356 DWORD cbWriteBuf,
357 LPVOID lpvReadBuf,
358 DWORD cbReadBuf,
359 LPDWORD lpcbRead,
360 LPOVERLAPPED lpo)
361{
362 BOOL lpResult; /* result from the device handler's API */
363 PHMHANDLE pHMHandle; /* pointer to the handle structure in the table */
364
365 SetLastError(ERROR_SUCCESS);
366 /* validate handle */
367 pHMHandle = HMHandleQueryPtr(hPipe); /* get the index */
368 if (pHMHandle == NULL) /* error ? */
369 {
370 return FALSE; //last error set by HMHandleQueryPtr (ERROR_INVALID_HANDLE)
371 }
372
373 lpResult = pHMHandle->pDeviceHandler->TransactNamedPipe(&pHMHandle->hmHandleData,
374 lpvWriteBuf,
375 cbWriteBuf,
376 lpvReadBuf,
377 cbReadBuf,
378 lpcbRead,
379 lpo);
380
381 return (lpResult); /* deliver return code */
382}
383
384/*****************************************************************************
385 * Name : BOOL SetNamedPipeHandleState
386 * Purpose : The SetNamedPipeHandleState function sets the read mode and the
387 * blocking mode of the specified named pipe. If the specified handle
388 * is to the client end of a named pipe and if the named pipe server
389 * process is on a remote computer, the function can also be used to
390 * control local buffering.
391 * Parameters: HANDLE hNamedPipe handle of named pipe
392 * LPDWORD lpdwMode address of new pipe mode
393 * LPDWORD lpcbMaxCollect address of max. bytes before remote transmission
394 * LPDWORD lpdwCollectDataTimeout address of max. time before remote transmission
395 * Variables :
396 * Result : TRUE / FALSE
397 * Remark :
398 * Status :
399 *
400 * Author : Przemyslaw Dobrowolski
401 *****************************************************************************/
402
403BOOL WIN32API SetNamedPipeHandleState(HANDLE hPipe,
404 LPDWORD lpdwMode,
405 LPDWORD lpcbMaxCollect,
406 LPDWORD lpdwCollectDataTimeout)
407{
408 BOOL lpResult; /* result from the device handler's API */
409 PHMHANDLE pHMHandle; /* pointer to the handle structure in the table */
410
411 SetLastError(ERROR_SUCCESS);
412 /* validate handle */
413 pHMHandle = HMHandleQueryPtr(hPipe); /* get the index */
414 if (pHMHandle == NULL) /* error ? */
415 {
416 return FALSE; //last error set by HMHandleQueryPtr (ERROR_INVALID_HANDLE)
417 }
418
419 lpResult = pHMHandle->pDeviceHandler->SetNamedPipeHandleState(&pHMHandle->hmHandleData,
420 lpdwMode,
421 lpcbMaxCollect,
422 lpdwCollectDataTimeout);
423
424 return (lpResult); /* deliver return code */
425}
426
427
428//******************************************************************************
429//******************************************************************************
430HANDLE WIN32API CreateNamedPipeW(LPCWSTR lpName, DWORD dwOpenMode, DWORD dwPipeMode,
431 DWORD nMaxInstances, DWORD nOutBufferSize,
432 DWORD nInBufferSize, DWORD nDefaultTimeOut,
433 LPSECURITY_ATTRIBUTES lpSecurityAttributes)
434{
435 char *asciiname;
436 HANDLE hPipe;
437
438 asciiname = UnicodeToAsciiString((LPWSTR)lpName);
439
440 hPipe=CreateNamedPipeA(asciiname,
441 dwOpenMode,
442 dwPipeMode,
443 nMaxInstances,
444 nOutBufferSize,
445 nInBufferSize,
446 nDefaultTimeOut,
447 lpSecurityAttributes);
448
449 FreeAsciiString(asciiname);
450
451 return(hPipe);
452}
453
454/*****************************************************************************
455 * Name : BOOL WIN32AOI CallNamedPipeA
456 * Purpose : The CallNamedPipe function connects to a message-type pipe
457 * (and waits if an instance of the pipe is not available),
458 * writes to and reads from the pipe, and then closes the pipe.
459 * Parameters: LPCSTR lpNamedPipeName pointer to pipe name
460 * LPVOID lpInBuffer pointer to write buffer
461 * DWORD nInBufferSize size, in bytes, of write buffer
462 * LPVOID lpOutBuffer pointer to read buffer
463 * DWORD nOutBufferSize size, in bytes, of read buffer
464 * LPDWORD lpBytesRead pointer to number of bytes read
465 * DWORD nTimeOut time-out time, in milliseconds
466 * Variables :
467 * Result : If the function succeeds, the return value is nonzero.
468 * If the function fails, the return value is zero.
469 * To get extended error information, call GetLastError.
470 * Remark : Calling CallNamedPipe is equivalent to calling the CreateFile
471 * (or WaitNamedPipe, if CreateFile cannot open the pipe immediately),
472 * TransactNamedPipe, and CloseHandle functions. CreateFile is called
473 * with an access flag of GENERIC_READ | GENERIC_WRITE, an inherit
474 * handle flag of FALSE, and a share mode of zero (indicating no
475 * sharing of this pipe instance).
476 * If the message written to the pipe by the server process is
477 * longer than nOutBufferSize, CallNamedPipe returns FALSE, and
478 * GetLastError returns ERROR_MORE_DATA. The remainder of the
479 * message is discarded, because CallNamedPipe closes the handle
480 * to the pipe before returning.
481 *
482 * CallNamedPipe fails if the pipe is a byte-type pipe.
483 * Status : NOT FULLY TESTED
484 *
485 * Author : Przemyslaw Dobrowolski [Mon, 2000/01/03 13:32]
486 *****************************************************************************/
487
488BOOL WIN32API CallNamedPipeA(LPCSTR lpNamedPipeName,
489 LPVOID lpInBuffer,
490 DWORD nInBufferSize,
491 LPVOID lpOutBuffer,
492 DWORD nOutBufferSize,
493 LPDWORD lpBytesRead,
494 DWORD nTimeOut)
495{
496 return(OSLibDosCallNamedPipe(lpNamedPipeName,
497 lpInBuffer,
498 nInBufferSize,
499 lpOutBuffer,
500 nOutBufferSize,
501 lpBytesRead,
502 nTimeOut ));
503}
504
505/*****************************************************************************
506 * Name : BOOL WIN32AOI CallNamedPipeW
507 * Purpose : The CallNamedPipe function connects to a message-type pipe
508 * (and waits if an instance of the pipe is not available),
509 * writes to and reads from the pipe, and then closes the pipe.
510 * Parameters: LPCWSTR lpNamedPipeName pointer to pipe name
511 * LPVOID lpInBuffer pointer to write buffer
512 * DWORD nInBufferSize size, in bytes, of write buffer
513 * LPVOID lpOutBuffer pointer to read buffer
514 * DWORD nOutBufferSize size, in bytes, of read buffer
515 * LPDWORD lpBytesRead pointer to number of bytes read
516 * DWORD nTimeOut time-out time, in milliseconds
517 * Variables :
518 * Result : If the function succeeds, the return value is nonzero.
519 * If the function fails, the return value is zero.
520 * To get extended error information, call GetLastError.
521 * Remark : Calling CallNamedPipe is equivalent to calling the CreateFile
522 * (or WaitNamedPipe, if CreateFile cannot open the pipe immediately),
523 * TransactNamedPipe, and CloseHandle functions. CreateFile is called
524 * with an access flag of GENERIC_READ | GENERIC_WRITE, an inherit
525 * handle flag of FALSE, and a share mode of zero (indicating no
526 * sharing of this pipe instance).
527 * If the message written to the pipe by the server process is
528 * longer than nOutBufferSize, CallNamedPipe returns FALSE, and
529 * GetLastError returns ERROR_MORE_DATA. The remainder of the
530 * message is discarded, because CallNamedPipe closes the handle
531 * to the pipe before returning.
532 *
533 * CallNamedPipe fails if the pipe is a byte-type pipe.
534 * Status : NOT FULLY TESTED
535 *
536 * Author : Przemyslaw Dobrowolski [Mon, 2000/01/03 13:33]
537 *****************************************************************************/
538BOOL WIN32API CallNamedPipeW(LPCWSTR lpNamedPipeName,
539 LPVOID lpInBuffer,
540 DWORD nInBufferSize,
541 LPVOID lpOutBuffer,
542 DWORD nOutBufferSize,
543 LPDWORD lpBytesRead,
544 DWORD nTimeOut)
545{
546 char *asciiname;
547 BOOL rc;
548
549 asciiname = UnicodeToAsciiString((LPWSTR)lpNamedPipeName);
550
551 rc=OSLibDosCallNamedPipe(asciiname,
552 lpInBuffer,
553 nInBufferSize,
554 lpOutBuffer,
555 nOutBufferSize,
556 lpBytesRead,
557 nTimeOut );
558
559 FreeAsciiString(asciiname);
560
561 return(rc);
562}
563
564
565/*****************************************************************************
566 * Name : BOOL GetNamedPipeHandleStateW
567 * Purpose : The GetNamedPipeHandleStateW function retrieves information about
568 * a specified named pipe. The information returned can vary during
569 * the lifetime of an instance of the named pipe.
570 * Parameters: HANDLE hNamedPipe handle of named pipe
571 * LPDWORD lpState address of flags indicating pipe state
572 * LPDWORD lpCurInstances address of number of current pipe instances
573 * LPDWORD lpMaxCollectionCount address of max. bytes before remote transmission
574 * LPDWORD lpCollectDataTimeout address of max. time before remote transmission
575 * LPWSTR lpUserName address of user name of client process
576 * DWORD nMaxUserNameSize size, in characters, of user name buffer
577 * Variables :
578 * Result : TRUE / FALSE
579 * Remark :
580 * Status : UNTESTED STUB
581 *
582 * Author : Patrick Haller [Mon, 1998/06/15 08:00]
583 *****************************************************************************/
584
585BOOL WIN32API GetNamedPipeHandleStateW(HANDLE hNamedPipe,
586 LPDWORD lpState,
587 LPDWORD lpCurInstances,
588 LPDWORD lpMaxCollectionCount,
589 LPDWORD lpCollectDataTimeout,
590 LPWSTR lpUserName,
591 DWORD nMaxUserNameSize)
592{
593 char *asciiname;
594 BOOL rc;
595
596 asciiname = UnicodeToAsciiString((LPWSTR)lpUserName);
597
598 // Not implemented but waiting to implementation in hmnpipe.cpp
599 rc= GetNamedPipeHandleStateA( hNamedPipe,
600 lpState,
601 lpCurInstances,
602 lpMaxCollectionCount,
603 lpCollectDataTimeout,
604 asciiname,
605 nMaxUserNameSize);
606
607
608 FreeAsciiString(asciiname);
609
610 return (rc);
611}
612
613/*****************************************************************************
614 * Name : BOOL WaitNamedPipeA
615 * Purpose : The WaitNamedPipe function waits until either a time-out interval
616 * elapses or an instance of the specified named pipe is available
617 * to be connected to (that is, the pipe's server process has a
618 * pending ConnectNamedPipe operation on the pipe).
619 * Parameters: LPCTSTR lpszNamedPipeName
620 * DWORD dwTimeout
621 * Variables :
622 * Result : TRUE / FALSE
623 * Remark :
624 * Status : UNTESTED (YET)
625 *
626 * Author : Przemyslaw Dobrowolski [Mon, 2000/01/03 13:52]
627 *****************************************************************************/
628
629BOOL WIN32API WaitNamedPipeA(LPCSTR lpszNamedPipeName, DWORD dwTimeout)
630{
631 return(OSLibDosWaitNamedPipe(lpszNamedPipeName, dwTimeout));
632}
633
634
635/*****************************************************************************
636 * Name : BOOL WaitNamedPipeW
637 * Purpose : The WaitNamedPipe function waits until either a time-out interval
638 * elapses or an instance of the specified named pipe is available
639 * to be connected to (that is, the pipe's server process has a
640 * pending ConnectNamedPipe operation on the pipe).
641 * Parameters: LPCWSTR lpszNamedPipeName
642 * DWORD dwTimeout
643 * Variables :
644 * Result : TRUE / FALSE
645 * Remark :
646 * Status : UNTESTED (YET)
647 *
648 * Author : Przemyslaw Dobrowolski [Mon, 2000/01/03 13:44]
649 *****************************************************************************/
650
651BOOL WIN32API WaitNamedPipeW(LPCWSTR lpszNamedPipeName, DWORD dwTimeout)
652{
653 char *asciiname;
654 DWORD rc;
655
656 asciiname = UnicodeToAsciiString((LPWSTR)lpszNamedPipeName);
657
658 rc=OSLibDosWaitNamedPipe(asciiname, dwTimeout);
659
660 FreeAsciiString(asciiname);
661
662 return(rc);
663}
Note: See TracBrowser for help on using the repository browser.