home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / include / rpcasync.h < prev    next >
C/C++ Source or Header  |  1998-04-25  |  4KB  |  178 lines

  1. /*++
  2.  
  3. Copyright 1997 - 1998 Microsoft Corporation
  4.  
  5. Module Name:
  6.  
  7.     rpcasync.h
  8.  
  9. Abstract:
  10.  
  11.     This module contains the RPC runtime APIs needed to use
  12.     [async] RPC features.
  13.  
  14. --*/
  15.  
  16. #ifndef __RPCASYNC_H__
  17. #define __RPCASYNC_H__
  18.  
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22.  
  23. #define RPC_ASYNC_VERSION_1_0     sizeof(RPC_ASYNC_STATE)
  24.  
  25. typedef
  26. enum _RPC_NOTIFICATION_TYPES
  27. {
  28.     RpcNotificationTypeNone,
  29.     RpcNotificationTypeEvent,
  30.     RpcNotificationTypeApc, 
  31.     RpcNotificationTypeIoc,
  32.     RpcNotificationTypeHwnd,
  33.     RpcNotificationTypeCallback
  34. } RPC_NOTIFICATION_TYPES;
  35.  
  36. typedef
  37. enum _RPC_ASYNC_EVENT {
  38.     RpcCallComplete,
  39.     RpcSendComplete,
  40.     RpcReceiveComplete
  41.     } RPC_ASYNC_EVENT;
  42.  
  43. typedef void RPC_ENTRY
  44. RPCNOTIFICATION_ROUTINE (
  45.                   struct _RPC_ASYNC_STATE *pAsync,
  46.                   void *Context,                              
  47.                   RPC_ASYNC_EVENT Event);
  48. typedef RPCNOTIFICATION_ROUTINE *PFN_RPCNOTIFICATION_ROUTINE;
  49.     
  50. typedef struct _RPC_ASYNC_STATE {
  51.     unsigned int    Size; // size of this structure
  52.     unsigned long   Signature;
  53.     long   Lock;
  54.     unsigned long   Flags;
  55.     void           *StubInfo;
  56.     void           *UserInfo;
  57.     void           *RuntimeInfo;
  58.     RPC_ASYNC_EVENT Event;
  59.  
  60.     RPC_NOTIFICATION_TYPES NotificationType;
  61.     union {
  62.         //
  63.         // Notification by APC
  64.         //
  65.         struct {
  66.             PFN_RPCNOTIFICATION_ROUTINE NotificationRoutine;
  67.             HANDLE hThread;
  68.             } APC;
  69.  
  70.         //
  71.         // Notification by IO completion port
  72.         //
  73.         struct {
  74.             HANDLE hIOPort;
  75.             DWORD dwNumberOfBytesTransferred;
  76.             DWORD dwCompletionKey;
  77.             LPOVERLAPPED lpOverlapped;
  78.             } IOC;
  79.  
  80.         //
  81.         // Notification by window message
  82.         //
  83.         struct {
  84.             HWND hWnd;
  85.             UINT Msg;
  86.             } HWND;
  87.  
  88.  
  89.         //
  90.         // Notification by event
  91.         //
  92.         HANDLE hEvent;
  93.  
  94.         //
  95.         // Notification by callback function
  96.         //
  97.         // This option is available only to OLE
  98.         //
  99.         PFN_RPCNOTIFICATION_ROUTINE NotificationRoutine;
  100.         } u;
  101.  
  102.     long Reserved[4]; 
  103.     } RPC_ASYNC_STATE, *PRPC_ASYNC_STATE;
  104.  
  105. // Possible values for Flags
  106. #define RPC_C_NOTIFY_ON_SEND_COMPLETE      0x1
  107. #define RPC_C_INFINITE_TIMEOUT             INFINITE
  108.  
  109. #define RpcAsyncGetCallHandle(pAsync) (((PRPC_ASYNC_STATE) pAsync)->RuntimeInfo)
  110.  
  111. RPCRTAPI
  112. RPC_STATUS
  113. RPC_ENTRY
  114. RpcAsyncInitializeHandle (
  115.     PRPC_ASYNC_STATE pAsync,
  116.     unsigned int     Size
  117.     );
  118.                       
  119. RPCRTAPI
  120. RPC_STATUS
  121. RPC_ENTRY
  122. RpcAsyncRegisterInfo (
  123.     PRPC_ASYNC_STATE pAsync
  124.     ) ;
  125.  
  126. RPCRTAPI
  127. RPC_STATUS
  128. RPC_ENTRY
  129. RpcAsyncGetCallStatus (
  130.     PRPC_ASYNC_STATE pAsync
  131.     ) ;
  132.  
  133. RPCRTAPI
  134. RPC_STATUS
  135. RPC_ENTRY
  136. RpcAsyncCompleteCall (
  137.     PRPC_ASYNC_STATE pAsync,
  138.     void *Reply
  139.     ) ;
  140.  
  141. RPCRTAPI
  142. RPC_STATUS
  143. RPC_ENTRY
  144. RpcAsyncAbortCall (
  145.     PRPC_ASYNC_STATE pAsync,
  146.     unsigned long ExceptionCode
  147.     ) ;
  148.  
  149. RPCRTAPI
  150. RPC_STATUS
  151. RPC_ENTRY
  152. RpcAsyncCancelCall (
  153.     IN PRPC_ASYNC_STATE pAsync,
  154.     IN BOOL fAbort
  155.     ) ;
  156.  
  157. //
  158. // Internal APIs
  159. //
  160. RPC_STATUS RPC_ENTRY
  161. I_RpcAsyncSetHandle (
  162.     IN  PRPC_MESSAGE Message,
  163.     IN  PRPC_ASYNC_STATE pAsync
  164.     );
  165.  
  166. RPC_STATUS RPC_ENTRY
  167. I_RpcAsyncAbortCall (
  168.     IN PRPC_ASYNC_STATE pAsync,
  169.     IN unsigned long ExceptionCode
  170.     ) ;
  171.  
  172. #ifdef __cplusplus
  173. }
  174. #endif
  175.  
  176. #endif /* __RPCASYNC_H__ */
  177.  
  178.