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

Last change on this file since 2308 was 2301, checked in by sandervl, 26 years ago

PB: Started with named pipe api implementation

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