Add some information to the man page and README file.
[wine/multimedia.git] / scheduler / pipe.c
blob0847ec5794f4fd3530d5aa12b7a64b3ac75f0282
1 /*
2 * Win32 pipes
4 * Copyright 1998 Alexandre Julliard
5 */
7 #include <assert.h>
8 #include "windows.h"
9 #include "winerror.h"
10 #include "k32obj.h"
11 #include "process.h"
12 #include "thread.h"
13 #include "heap.h"
14 #include "server/request.h"
15 #include "server.h"
17 typedef struct _PIPE
19 K32OBJ header;
20 } PIPE;
23 /***********************************************************************
24 * CreatePipe (KERNEL32.170)
26 BOOL32 WINAPI CreatePipe( PHANDLE hReadPipe, PHANDLE hWritePipe,
27 LPSECURITY_ATTRIBUTES sa, DWORD size )
29 struct create_pipe_request req;
30 struct create_pipe_reply reply;
31 PIPE *read_pipe, *write_pipe;
32 int len;
34 req.inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
35 CLIENT_SendRequest( REQ_CREATE_PIPE, -1, 1, &req, sizeof(req) );
36 if (CLIENT_WaitReply( &len, NULL, 1, &reply, sizeof(reply) ) != ERROR_SUCCESS)
37 return FALSE;
39 SYSTEM_LOCK();
40 if (!(read_pipe = (PIPE *)K32OBJ_Create( K32OBJ_PIPE, sizeof(*read_pipe),
41 NULL, reply.handle_read,
42 STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|GENERIC_READ,
43 sa, hReadPipe )))
45 CLIENT_CloseHandle( reply.handle_write );
46 /* handle_read already closed by K32OBJ_Create */
47 SYSTEM_UNLOCK();
48 return FALSE;
50 K32OBJ_DecCount( &read_pipe->header );
51 if (!(write_pipe = (PIPE *)K32OBJ_Create( K32OBJ_PIPE, sizeof(*write_pipe),
52 NULL, reply.handle_write,
53 STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|GENERIC_WRITE,
54 sa, hWritePipe )))
56 CloseHandle( *hReadPipe );
57 *hReadPipe = INVALID_HANDLE_VALUE32;
58 SYSTEM_UNLOCK();
59 return FALSE;
61 /* everything OK */
62 K32OBJ_DecCount( &write_pipe->header );
63 SetLastError(0); /* FIXME */
64 SYSTEM_UNLOCK();
65 return TRUE;