home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / netds / rpc / dict / replay.idl < prev    next >
Encoding:
Text File  |  1996-06-12  |  10.0 KB  |  277 lines

  1. /*************************************************************/
  2. /**                                                         **/
  3. /**                 Microsoft RPC Examples                  **/
  4. /**                 Dictionary Application                  **/
  5. /**           Copyright(c) Microsoft Corp. 1992-1996        **/
  6. /**                                                         **/
  7. /*************************************************************/
  8.  
  9. [ uuid (12345678-1234-ABCD-EF00-0123456789AB),
  10.   version(1.0),
  11. //  endpoint("msc_np:[\\pipe\\splay]"),
  12.   pointer_default(unique)
  13. ]
  14. interface dict
  15. {
  16.  
  17. /*************************************************************************/
  18. /***            Strongly typed tree nodes and dictionaries             ***/
  19. /*************************************************************************/
  20.  
  21. /*
  22.  ************************************************************************
  23.  * Record type - previously imported from util1.idl
  24.  * This is the type of items stored in the remote dictionary.
  25.  ************************************************************************
  26. */
  27.  
  28. typedef struct _Record {
  29.     short key;                      // RPC "generation"
  30.     [string] char* name;            // contributor
  31. } Record;
  32.  
  33. typedef Record * PRecord;
  34.  
  35. /*
  36.  ************************************************************************
  37.  * The following definitions (RDict, RecordTreeNode) are required
  38.  * for marshalling a complete dictionary, binary tree, respectively.
  39.  * All pointers are based on RPC-able types, replacing "void*"
  40.  * pointers in the local dictionary (dict0) which are non-transmissible.
  41.  ************************************************************************
  42. */
  43.  
  44. typedef struct _RecordTreeNode {
  45.     struct _RecordTreeNode *left;   // left child pointer
  46.     struct _RecordTreeNode *right;  // right child pointer
  47.     Record *item;                   // pointer to a Record structure
  48. } RecordTreeNode;
  49.  
  50. typedef struct _DictState {
  51.     short ref_count;                // for shared dictionaries
  52.     Record * curr_record;           // for global iterators
  53. } DictState;
  54.  
  55. typedef struct _RDict {
  56.     RecordTreeNode *root;           // pointer to the root of a SAT
  57.     long size;                      // number of records in dictionary
  58.     DictState * state;              // pointer to state info
  59. } RDict;
  60.  
  61. /*
  62.  * VDict is a "virtual dictionary" object.  It is used in the client
  63.  * application as a handle on a dictionary maintained by a server
  64. */
  65. typedef [context_handle] void * VDict;
  66.  
  67. typedef enum {
  68.     DICT_SUCCESS,
  69.     DICT_ITEM_ALREADY_PRESENT,
  70.     DICT_ITEM_NOT_FOUND,
  71.     DICT_FIRST_ITEM,
  72.     DICT_LAST_ITEM,
  73.     DICT_EMPTY_DICTIONARY,
  74.     DICT_NULL_ITEM
  75. } VDict_Status;
  76.  
  77. /*************************************************************************/
  78. /***    Generic Dictionary Operations: (From dict0.h)                  ***/
  79. /***                                                                   ***/
  80. /***    Dictionary *Dict_New(Cmp_rec*, Splay*, print_rec*)             ***/
  81. /***                                                                   ***/
  82. /***    Dict_Status Dict_Find(Dictionary*, Item*)                      ***/
  83. /***    Dict_Status Dict_Next(Dictionary*, Item*)                      ***/
  84. /***    Dict_Status Dict_Prev(Dictionary*, Item*)                      ***/
  85. /***    Dict_Status Dict_Insert(Dictionary*, Item*)                    ***/
  86. /***    Dict_Status Dict_Delete(Dictionary*, Item**)                   ***/
  87. /***                                                                   ***/
  88. /***    Item* DICT_CURR_ITEM(Dict*)                                    ***/
  89. /*************************************************************************/
  90.  
  91. /*************************************************************************/
  92. /***    Virtual Dictionary Operations (on remote dictionaries)         ***/
  93. /***                                                                   ***/
  94. /***    VDict_Status VDict_New(OUT VDict *)                            ***/
  95. /***                                                                   ***/
  96. /***    VDict_Status VDict_Find(IN VDict, IN OUT Record**)             ***/
  97. /***    VDict_Status VDict_Next(IN VDict, IN OUT Record**)             ***/
  98. /***    VDict_Status VDict_Prev(IN VDict, IN OUT Record**)             ***/
  99. /***    VDict_Status VDict_Insert(IN VDict, IN Record*)                ***/
  100. /***    VDict_Status VDict_Delete(IN VDict, IN OUT Record**)           ***/
  101. /***                                                                   ***/
  102. /***    VDict_Status VDict_Get_Dict(IN VDict, OUT RDict**)             ***/
  103. /***    VDict_Status VDict_Curr_Item(IN VDict, OUT Record**);          ***/
  104. /***    VDict_Status VDict_Delete_Curr(IN VDict, OUT Record**);        ***/
  105. /***    VDict_Status VDict_Curr_Next(IN VDict, OUT Record**);          ***/
  106. /***    VDict_Status VDict_Curr_Prev(IN VDict, OUT Record**);          ***/
  107. /***                                                                   ***/
  108. /*************************************************************************/
  109.  
  110. /*
  111.  ************************************************************************
  112.  * Most of the remote operations interfacing to a remote dictionary
  113.  * are very close to operations on local dictionaries, with the
  114.  * following noted exceptions.  To compansate for the fact that it is
  115.  * possible to "peek" and get the current item of a local dictionary,
  116.  * some interfaces had to be added, and others have to be changed to
  117.  * closely match the capabilities of a local dictionaries by a remote
  118.  * dictionary.  In particular the item (Record) argument became an OUT
  119.  * or an IN OUT argument, returning the value of the "current_item"
  120.  * following an operation (VDict_Find, VDict_Next, VDict_Prev).
  121.  * The operations VDict_Curr_Item, VDict_Delete_Curr, VDict_Curr_Next,
  122.  * and VDict_Curr_Prev were added to get functionality obtained in
  123.  * local dictionaries by the DICT_CURR_ITEM macro, and by passing the
  124.  * current item as an IN argument to Dict_Delete, Dict_Next
  125.  * and Dict_Prev.  The basic return [IN] OUT parameter was changed
  126.  * from (Item*) to (Record**), partly to further test the pointer
  127.  * handling capabilities of the MIDL compiler.
  128.  *************************************************************************
  129. */
  130.  
  131. /*
  132.  *************************************************************************
  133.  * In non-shared mode: Creates and initializes a new (private copy of
  134.  * the) dictionary.
  135.  *
  136.  * In shared mode: If there is an existing shared dictionary, return
  137.  * it, otherwise Creates and initializes a new (shared copy of
  138.  * the) dictionary.
  139.  *************************************************************************
  140. */
  141.  
  142. VDict_Status
  143. VDict_New(
  144.   [in] short shared_dict,
  145.   [out] VDict * v_dict
  146.   );
  147.  
  148. /*
  149.  *************************************************************************
  150.  * Find *item in the dictionary.  If *item was not present a "neighbor"
  151.  * of *item will be returned instead
  152.  *************************************************************************
  153. */
  154.  
  155. VDict_Status
  156. VDict_Find(
  157.     [in] VDict  v_dict,
  158.     [in, out] Record ** item
  159.     );
  160.  
  161. /*
  162.  *************************************************************************
  163.  * Get successor / predecessor of *item, and update *item to point to it
  164.  *************************************************************************
  165. */
  166.  
  167. VDict_Status
  168. VDict_Next(
  169.     [in] VDict  v_dict,
  170.     [in, out] Record ** item
  171.     );
  172.  
  173. VDict_Status
  174. VDict_Prev(
  175.     [in] VDict  v_dict,
  176.     [in, out] Record ** item
  177.     );
  178.  
  179. /*
  180.  *************************************************************************
  181.  * Get successor / predecessor of RDICT_CURR_RECORD(v_dict),
  182.  * and update *item to point to it (global iterator prev)
  183.  *************************************************************************
  184. */
  185.  
  186. VDict_Status
  187. VDict_Curr_Next(
  188.     [in] VDict  v_dict,
  189.     [out] Record ** item
  190.     );
  191.  
  192. VDict_Status
  193. VDict_Curr_Prev(
  194.     [in] VDict  v_dict,
  195.     [out] Record ** item
  196.     );
  197.  
  198. /*
  199.  *************************************************************************
  200.  * Insert *item into the dictionary
  201.  *************************************************************************
  202. */
  203.  
  204. VDict_Status
  205. VDict_Insert(
  206.     [in] VDict  v_dict,
  207.     [in] Record * item
  208.     );
  209.  
  210. /*
  211.  *************************************************************************
  212.  * Delete *item from the dictionary.  (It is the callers responsibility
  213.  * to free the storage allocated for the returned record)
  214.  *************************************************************************
  215. */
  216.  
  217. VDict_Status
  218. VDict_Delete(
  219.     [in] VDict  v_dict,
  220.     [in, out] Record ** item
  221.     );
  222.  
  223. /*
  224.  *************************************************************************
  225.  * Return a local copy of the whole dictionary
  226.  *************************************************************************
  227. */
  228.  
  229. VDict_Status
  230. VDict_Get_Dict(
  231.     [in] VDict  v_dict,
  232.     [out] RDict ** r_dict
  233.     );
  234.  
  235. /*
  236.  *************************************************************************
  237.  * Return DICT_CURR_ITEM(v_dict)
  238.  *************************************************************************
  239. */
  240.  
  241. VDict_Status
  242. VDict_Curr_Item(
  243.     [in] VDict  v_dict,
  244.     [out] Record ** item
  245.     );
  246.  
  247. /*
  248.  *************************************************************************
  249.  * Delete RDICT_CURR_RECORD(v_dict) from the dictionary.
  250.  * (It is the callers responsibility to free the storage
  251.  * allocated for the returned record)
  252.  *************************************************************************
  253. */
  254.  
  255. VDict_Status
  256. VDict_Curr_Delete(
  257.     [in] VDict  v_dict,
  258.     [out] Record ** item
  259.     );
  260.  
  261. /*************************************************************************/
  262. /***                        Play oriented Functions ...                ***/
  263. /*************************************************************************/
  264.  
  265. VDict_Status
  266. VDict_X_Dict(
  267.     [in] VDict  v_dict
  268.     );
  269.  
  270. VDict_Status
  271. VDict_I_Dict(
  272.     [in] VDict  v_dict,
  273.     [in] short  size
  274.     );
  275.  
  276. }
  277.