sync with trunk r47227
[reactos.git] / dll / win32 / rpcrt4 / rpc_server.h
1 /*
2 * RPC server API
3 *
4 * Copyright 2001 Ove Kåven, TransGaming Technologies
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21 #ifndef __WINE_RPC_SERVER_H
22 #define __WINE_RPC_SERVER_H
23
24 #include "rpc_binding.h"
25 #include "wine/list.h"
26
27 struct protseq_ops;
28
29 typedef struct _RpcServerProtseq
30 {
31 const struct protseq_ops *ops; /* RO */
32 struct list entry; /* CS ::server_cs */
33 LPSTR Protseq; /* RO */
34 UINT MaxCalls; /* RO */
35 /* list of listening connections */
36 RpcConnection* conn; /* CS cs */
37 CRITICAL_SECTION cs;
38
39 /* is the server currently listening? */
40 BOOL is_listening; /* CS ::listen_cs */
41 /* mutex for ensuring only one thread can change state at a time */
42 HANDLE mgr_mutex;
43 /* set when server thread has finished opening connections */
44 HANDLE server_ready_event;
45 } RpcServerProtseq;
46
47 struct protseq_ops
48 {
49 const char *name;
50 RpcServerProtseq *(*alloc)(void);
51 void (*signal_state_changed)(RpcServerProtseq *protseq);
52 /* previous array is passed in to allow reuse of memory */
53 void *(*get_wait_array)(RpcServerProtseq *protseq, void *prev_array, unsigned int *count);
54 void (*free_wait_array)(RpcServerProtseq *protseq, void *array);
55 /* returns -1 for failure, 0 for server state changed and 1 to indicate a
56 * new connection was established */
57 int (*wait_for_new_connection)(RpcServerProtseq *protseq, unsigned int count, void *wait_array);
58 /* opens the endpoint and optionally begins listening */
59 RPC_STATUS (*open_endpoint)(RpcServerProtseq *protseq, LPSTR endpoint);
60 };
61
62 typedef struct _RpcServerInterface
63 {
64 struct list entry;
65 RPC_SERVER_INTERFACE* If;
66 UUID MgrTypeUuid;
67 RPC_MGR_EPV* MgrEpv;
68 UINT Flags;
69 UINT MaxCalls;
70 UINT MaxRpcSize;
71 RPC_IF_CALLBACK_FN* IfCallbackFn;
72 LONG CurrentCalls; /* number of calls currently executing */
73 /* set when unregistering interface to let the caller of
74 * RpcServerUnregisterIf* know that all calls have finished */
75 HANDLE CallsCompletedEvent;
76 BOOL Delete; /* delete when the last call finishes */
77 } RpcServerInterface;
78
79 void RPCRT4_new_client(RpcConnection* conn);
80 const struct protseq_ops *rpcrt4_get_protseq_ops(const char *protseq);
81
82 #endif /* __WINE_RPC_SERVER_H */