2 * Asynchronous Call Support Functions
4 * Copyright 2007 Robert Shearman (for CodeWeavers)
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.
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.
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
24 WINE_DEFAULT_DEBUG_CHANNEL(rpc
);
26 #define RPC_ASYNC_SIGNATURE 0x43595341
28 static inline BOOL
valid_async_handle(PRPC_ASYNC_STATE pAsync
)
30 return pAsync
->Signature
== RPC_ASYNC_SIGNATURE
;
33 /***********************************************************************
34 * RpcAsyncInitializeHandle [RPCRT4.@]
36 * Initialises an asynchronous state so it can be used in other asynchronous
37 * functions and for use in asynchronous calls.
40 * pAsync [I] Asynchronous state to initialise.
41 * Size [I] Size of the memory pointed to by pAsync.
45 * Failure: Any error code.
47 RPC_STATUS WINAPI
RpcAsyncInitializeHandle(PRPC_ASYNC_STATE pAsync
, unsigned int Size
)
49 TRACE("(%p, %d)\n", pAsync
, Size
);
51 if (Size
!= sizeof(*pAsync
))
53 ERR("invalid Size %d\n", Size
);
54 return ERROR_INVALID_PARAMETER
;
57 pAsync
->Size
= sizeof(*pAsync
);
58 pAsync
->Signature
= RPC_ASYNC_SIGNATURE
;
61 pAsync
->StubInfo
= NULL
;
62 pAsync
->RuntimeInfo
= NULL
;
63 memset(pAsync
->Reserved
, 0, sizeof(*pAsync
) - FIELD_OFFSET(RPC_ASYNC_STATE
, Reserved
));
68 /***********************************************************************
69 * RpcAsyncGetCallStatus [RPCRT4.@]
71 * Retrieves the current status of the asynchronous call taking place.
74 * pAsync [I] Asynchronous state to initialise.
77 * RPC_S_OK - The call was successfully completed.
78 * RPC_S_INVALID_ASYNC_HANDLE - The asynchronous structure is not valid.
79 * RPC_S_ASYNC_CALL_PENDING - The call is still in progress and has not been completed.
80 * Any other error code - The call failed.
82 RPC_STATUS WINAPI
RpcAsyncGetCallStatus(PRPC_ASYNC_STATE pAsync
)
84 FIXME("(%p): stub\n", pAsync
);
85 return RPC_S_INVALID_ASYNC_HANDLE
;
88 /***********************************************************************
89 * RpcAsyncCompleteCall [RPCRT4.@]
91 * Completes a client or server asynchronous call.
94 * pAsync [I] Asynchronous state to initialise.
95 * Reply [I] The return value of the asynchronous function.
99 * Failure: Any error code.
101 RPC_STATUS WINAPI
RpcAsyncCompleteCall(PRPC_ASYNC_STATE pAsync
, void *Reply
)
103 TRACE("(%p, %p)\n", pAsync
, Reply
);
105 if (!valid_async_handle(pAsync
))
106 return RPC_S_INVALID_ASYNC_HANDLE
;
108 /* FIXME: check completed */
110 return NdrpCompleteAsyncClientCall(pAsync
, Reply
);
113 /***********************************************************************
114 * RpcAsyncAbortCall [RPCRT4.@]
116 * Aborts the asynchronous server call taking place.
119 * pAsync [I] Asynchronous server state to abort.
120 * ExceptionCode [I] Exception code to return to the client in a fault packet.
124 * Failure: Any error code.
126 RPC_STATUS WINAPI
RpcAsyncAbortCall(PRPC_ASYNC_STATE pAsync
, ULONG ExceptionCode
)
128 FIXME("(%p, %d/0x%x): stub\n", pAsync
, ExceptionCode
, ExceptionCode
);
129 return RPC_S_INVALID_ASYNC_HANDLE
;
132 /***********************************************************************
133 * RpcAsyncCancelCall [RPCRT4.@]
135 * Cancels the asynchronous client call taking place.
138 * pAsync [I] Asynchronous client state to abort.
139 * fAbortCall [I] If TRUE, then send a cancel to the server, otherwise
140 * just wait for the call to complete.
144 * Failure: Any error code.
146 RPC_STATUS WINAPI
RpcAsyncCancelCall(PRPC_ASYNC_STATE pAsync
, BOOL fAbortCall
)
148 FIXME("(%p, %s): stub\n", pAsync
, fAbortCall
? "TRUE" : "FALSE");
149 return RPC_S_INVALID_ASYNC_HANDLE
;