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 / play.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-06-12  |  3.6 KB  |  89 lines

  1. /*************************************************************/
  2. /**                                                         **/
  3. /**                 Microsoft RPC Examples                  **/
  4. /**                 Dictionary Application                  **/
  5. /**          Copyright(c) Microsoft Corp. 1992-1996         **/
  6. /**                                                         **/
  7. /*************************************************************/
  8.  
  9. #include "rpc.h"
  10. #include "rpcndr.h"
  11.  
  12. #define IN
  13. #define OUT
  14. #define STRING
  15. #define CONTEXT_HANDLE
  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. /*
  34.  ************************************************************************
  35.  * The following definitions (RDict, RecordTreeNode) are required
  36.  * for marshalling a complete dictionary, binary tree, respectively.
  37.  * All pointers are based on RPC-able types, replacing "void*"
  38.  * pointers in the local dictionary (dict0) which are non-transmissible.
  39.  ************************************************************************
  40. */
  41.  
  42. typedef struct _RecordTreeNode {
  43.     struct _RecordTreeNode *left;   // left child pointer
  44.     struct _RecordTreeNode *right;  // right child pointer
  45.     Record *item;                   // pointer to a Record structure
  46. } RecordTreeNode;
  47.  
  48. typedef struct _DictState {
  49.     short ref_count;                // for shared dictionaries
  50.     Record * curr_record;           // for global iterators
  51. } DictState;
  52.  
  53. typedef struct _RDict {
  54.     RecordTreeNode *root;           // pointer to the root of a SAT
  55.     long size;                      // number of records in dictionary
  56.     DictState * state;              // pointer to state info
  57. } RDict;
  58.  
  59. /*
  60.  * VDict is a "virtual dictionary" object.  It is used in the client
  61.  * application as a handle on a dictionary maintained by a server
  62. */
  63. typedef CONTEXT_HANDLE void * VDict;
  64.  
  65. typedef enum {
  66.     DICT_SUCCESS,
  67.     DICT_ITEM_ALREADY_PRESENT,
  68.     DICT_ITEM_NOT_FOUND,
  69.     DICT_FIRST_ITEM,
  70.     DICT_LAST_ITEM,
  71.     DICT_EMPTY_DICTIONARY,
  72.     DICT_NULL_ITEM
  73. } VDict_Status;
  74.  
  75.  
  76. /*************************************************************************/
  77. /***    Generic Dictionary Operations: (From dict0.h)                  ***/
  78. /***                                                                   ***/
  79. /***    Dictionary *Dict_New(Cmp_rec*, Splay*, print_rec*)             ***/
  80. /***                                                                   ***/
  81. /***    Dict_Status Dict_Find(Dictionary*, Item*)                      ***/
  82. /***    Dict_Status Dict_Next(Dictionary*, Item*)                      ***/
  83. /***    Dict_Status Dict_Prev(Dictionary*, Item*)                      ***/
  84. /***    Dict_Status Dict_Insert(Dictionary*, Item*)                    ***/
  85. /***    Dict_Status Dict_Delete(Dictionary*, Item**)                   ***/
  86. /***                                                                   ***/
  87. /***    Item* DICT_CURR_ITEM(Dict*)                                    ***/
  88. /*************************************************************************/
  89.