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