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