Sync with trunk (r48545)
[reactos.git] / dll / win32 / rpcrt4 / rpc_async.c
1 /*
2 * Asynchronous Call Support Functions
3 *
4 * Copyright 2007 Robert Shearman (for CodeWeavers)
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
22 #include <stdarg.h>
23
24 #include "rpc.h"
25 #include "rpcndr.h"
26 #include "rpcasync.h"
27
28 #include "wine/debug.h"
29
30 #include "rpc_binding.h"
31 #include "rpc_message.h"
32
33 WINE_DEFAULT_DEBUG_CHANNEL(rpc);
34
35 #define RPC_ASYNC_SIGNATURE 0x43595341
36
37 /***********************************************************************
38 * RpcAsyncInitializeHandle [RPCRT4.@]
39 *
40 * Initialises an asynchronous state so it can be used in other asynchronous
41 * functions and for use in asynchronous calls.
42 *
43 * PARAMS
44 * pAsync [I] Asynchronous state to initialise.
45 * Size [I] Size of the memory pointed to by pAsync.
46 *
47 * RETURNS
48 * Success: RPC_S_OK.
49 * Failure: Any error code.
50 */
51 RPC_STATUS WINAPI RpcAsyncInitializeHandle(PRPC_ASYNC_STATE pAsync, unsigned int Size)
52 {
53 TRACE("(%p, %d)\n", pAsync, Size);
54
55 if (Size != sizeof(*pAsync))
56 {
57 ERR("invalid Size %d\n", Size);
58 return ERROR_INVALID_PARAMETER;
59 }
60
61 pAsync->Size = sizeof(*pAsync);
62 pAsync->Signature = RPC_ASYNC_SIGNATURE;
63 pAsync->Lock = 0;
64 pAsync->Flags = 0;
65 pAsync->StubInfo = NULL;
66 pAsync->RuntimeInfo = NULL;
67 memset(pAsync->Reserved, 0, sizeof(*pAsync) - FIELD_OFFSET(RPC_ASYNC_STATE, Reserved));
68
69 return RPC_S_OK;
70 }
71
72 /***********************************************************************
73 * RpcAsyncGetCallStatus [RPCRT4.@]
74 *
75 * Retrieves the current status of the asynchronous call taking place.
76 *
77 * PARAMS
78 * pAsync [I] Asynchronous state to initialise.
79 *
80 * RETURNS
81 * RPC_S_OK - The call was successfully completed.
82 * RPC_S_INVALID_ASYNC_HANDLE - The asynchronous structure is not valid.
83 * RPC_S_ASYNC_CALL_PENDING - The call is still in progress and has not been completed.
84 * Any other error code - The call failed.
85 */
86 RPC_STATUS WINAPI RpcAsyncGetCallStatus(PRPC_ASYNC_STATE pAsync)
87 {
88 FIXME("(%p): stub\n", pAsync);
89 return RPC_S_INVALID_ASYNC_HANDLE;
90 }
91
92 /***********************************************************************
93 * RpcAsyncCompleteCall [RPCRT4.@]
94 *
95 * Completes a client or server asynchronous call.
96 *
97 * PARAMS
98 * pAsync [I] Asynchronous state to initialise.
99 * Reply [I] The return value of the asynchronous function.
100 *
101 * RETURNS
102 * Success: RPC_S_OK.
103 * Failure: Any error code.
104 */
105 RPC_STATUS WINAPI RpcAsyncCompleteCall(PRPC_ASYNC_STATE pAsync, void *Reply)
106 {
107 FIXME("(%p, %p): stub\n", pAsync, Reply);
108 return RPC_S_INVALID_ASYNC_HANDLE;
109 }
110
111 /***********************************************************************
112 * RpcAsyncAbortCall [RPCRT4.@]
113 *
114 * Aborts the asynchronous server call taking place.
115 *
116 * PARAMS
117 * pAsync [I] Asynchronous server state to abort.
118 * ExceptionCode [I] Exception code to return to the client in a fault packet.
119 *
120 * RETURNS
121 * Success: RPC_S_OK.
122 * Failure: Any error code.
123 */
124 RPC_STATUS WINAPI RpcAsyncAbortCall(PRPC_ASYNC_STATE pAsync, ULONG ExceptionCode)
125 {
126 FIXME("(%p, %d/0x%x): stub\n", pAsync, ExceptionCode, ExceptionCode);
127 return RPC_S_INVALID_ASYNC_HANDLE;
128 }
129
130 /***********************************************************************
131 * RpcAsyncCancelCall [RPCRT4.@]
132 *
133 * Cancels the asynchronous client call taking place.
134 *
135 * PARAMS
136 * pAsync [I] Asynchronous client state to abort.
137 * fAbortCall [I] If TRUE, then send a cancel to the server, otherwise
138 * just wait for the call to complete.
139 *
140 * RETURNS
141 * Success: RPC_S_OK.
142 * Failure: Any error code.
143 */
144 RPC_STATUS WINAPI RpcAsyncCancelCall(PRPC_ASYNC_STATE pAsync, BOOL fAbortCall)
145 {
146 FIXME("(%p, %s): stub\n", pAsync, fAbortCall ? "TRUE" : "FALSE");
147 return RPC_S_INVALID_ASYNC_HANDLE;
148 }