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

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

PB: Started with named pipe api implementation

File size: 20.5 KB
Line 
1/*
2 * Win32 Named pipes API
3 *
4 * Copyright 1998 Sander van Leeuwen
5 * Copyright 2000 Przemyslaw Dobrowolski
6 *
7 * Project Odin Software License can be found in LICENSE.TXT
8 */
9#include <odin.h>
10#include <odinwrap.h>
11#include <os2win.h>
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
19ODINDEBUGCHANNEL(KERNEL32-NPIPE)
20
21//******************************************************************************
22//******************************************************************************
23BOOL WIN32API PeekNamedPipe(HANDLE hPipe, LPVOID lpvBuffer, DWORD cbBuffer,
24 LPDWORD lpcbRead, LPDWORD lpcbAvail, LPDWORD lpcbMessage)
25{
26 dprintf(("PeekNamedPipe Not Implemented! - yet\n"));
27 return(FALSE);
28}
29//******************************************************************************
30//LPSECURITY_ATTRIBUTES lpsa; /* address of security attributes */
31//******************************************************************************
32BOOL WIN32API CreatePipe(PHANDLE phRead, PHANDLE phWrite, LPSECURITY_ATTRIBUTES lpsa, DWORD cbPipe)
33{
34 dprintf(("CreatePipe Not Implemented!\n"));
35 return(FALSE);
36}
37//******************************************************************************
38//******************************************************************************
39//HANDLE WIN32API
40// DWORD nMaxInstances, DWORD nOutBufferSize,
41// DWORD nInBufferSize, DWORD nDefaultTimeOut,
42// void *lpSecurityAttributes)
43ODINFUNCTION8(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//******************************************************************************
65ODINFUNCTION8(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
110ODINFUNCTION2(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
149BOOL 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
197BOOL 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
224BOOL 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
254BOOL 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
295BOOL 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
332BOOL 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
367BOOL 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
401DWORD 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
437BOOL 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
464BOOL 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}
Note: See TracBrowser for help on using the repository browser.