Initial import of the CDE 2.1.30 sources from the Open Group.
[oweals/cde.git] / cde / programs / dtcm / server / rtable3.c
1 /* $XConsortium: rtable3.c /main/4 1995/11/09 12:51:59 rswiston $ */
2 /*
3  *  (c) Copyright 1993, 1994 Hewlett-Packard Company
4  *  (c) Copyright 1993, 1994 International Business Machines Corp.
5  *  (c) Copyright 1993, 1994 Novell, Inc.
6  *  (c) Copyright 1993, 1994 Sun Microsystems, Inc.
7  */
8
9 /*
10   veneer layered on top of the real data structures for abstraction.
11         implements Version 3 in terms of Version 4 types        
12  */
13
14
15
16 #include <EUSCompat.h>
17 #include <stdio.h>
18 #include "rtable4.h"
19 #include "rtable3.h"
20 #include <sys/param.h>
21 #include <sys/time.h>
22 #include <rpc/rpc.h>
23 #include "rpcextras.h"
24 #include "convert3-4.h"
25 #include "convert4-3.h"
26 #include "rtable3_tbl.i"
27
28
29 /*************** V3 PROTOCOL IMPLEMENTATION PROCS *****************/
30 extern void *
31 _DtCm_rtable_ping_3_svc(args, svcrq)
32 void *args;
33 struct svc_req *svcrq;
34 {
35         char dummy;     
36         return((void *)&dummy); /* for RPC reply */
37 }
38
39 /*      PROC #1         */
40 extern Table_Res_3 *
41 _DtCm_rtable_lookup_3_svc (args, svcrq)
42 Table_Args_3 *args;
43 struct svc_req *svcrq;
44 {
45         static Table_Res_3 *res = NULL;
46         Table_Args_4 *newargs;
47         Table_Res_4 *newres;
48
49         if (res!=NULL) xdr_free ((xdrproc_t)_DtCm_xdr_Table_Res_3, (char*)res);
50
51         newargs = _DtCm_tableargs3_to_tableargs4(args);
52         newres = _DtCm_rtable_lookup_4_svc(newargs, svcrq); 
53         res = _DtCm_tableres4_to_tableres3(newres);
54
55         if (newargs!=NULL) xdr_free((xdrproc_t)_DtCm_xdr_Table_Args_4, (char*)newargs);
56
57         return(res);
58 }
59
60 /*      PROC #2         */
61 extern Table_Res_3 *
62 _DtCm_rtable_lookup_next_larger_3_svc(args, svcrq)
63 Table_Args_3 *args;
64 struct svc_req *svcrq;
65 {
66         static Table_Res_3 *res = NULL;
67         Table_Args_4 *newargs;   
68         Table_Res_4 *newres; 
69  
70         if (res!=NULL) xdr_free ((xdrproc_t)_DtCm_xdr_Table_Res_3, (char*)res);
71  
72         newargs = _DtCm_tableargs3_to_tableargs4(args);
73         newres = _DtCm_rtable_lookup_next_larger_4_svc(newargs, svcrq);
74         res = _DtCm_tableres4_to_tableres3(newres);
75  
76         if (newargs!=NULL) xdr_free((xdrproc_t)_DtCm_xdr_Table_Args_4, (char*)newargs);
77  
78         return(res);
79 }
80
81 /*      PROC #3         */
82 extern Table_Res_3 *
83 _DtCm_rtable_lookup_next_smaller_3_svc(args, svcrq)
84 Table_Args_3 *args;
85 struct svc_req *svcrq;
86 {
87         static Table_Res_3 *res = NULL; 
88         Table_Args_4 *newargs;    
89         Table_Res_4 *newres; 
90   
91         if (res!=NULL) xdr_free ((xdrproc_t)_DtCm_xdr_Table_Res_3, (char*)res);
92
93         newargs = _DtCm_tableargs3_to_tableargs4(args);
94         newres = _DtCm_rtable_lookup_next_smaller_4_svc(newargs, svcrq); 
95         res = _DtCm_tableres4_to_tableres3(newres);
96
97         if (newargs!=NULL) xdr_free((xdrproc_t)_DtCm_xdr_Table_Args_4, (char*)newargs);
98
99         return(res);
100 }
101
102 /*      PROC #4         */
103 extern Table_Res_3 *
104 _DtCm_rtable_lookup_range_3_svc(args, svcrq)
105 Table_Args_3 *args;
106 struct svc_req *svcrq;
107 {
108         static Table_Res_3 *res = NULL;  
109         Table_Args_4 *newargs;     
110         Table_Res_4 *newres; 
111    
112         if (res!=NULL) xdr_free ((xdrproc_t)_DtCm_xdr_Table_Res_3, (char*)res);
113
114         newargs = _DtCm_tableargs3_to_tableargs4(args); 
115         newres = _DtCm_rtable_lookup_range_4_svc(newargs, svcrq);  
116         res = _DtCm_tableres4_to_tableres3(newres); 
117
118         if (newargs!=NULL) xdr_free((xdrproc_t)_DtCm_xdr_Table_Args_4, (char*)newargs); 
119
120         return(res);
121 }
122
123 /*      PROC #5         */
124 extern Table_Res_3 *
125 _DtCm_rtable_abbreviated_lookup_range_3_svc(args, svcrq)
126 Table_Args_3 *args;
127 struct svc_req *svcrq;
128 {
129         static Table_Res_3 *res = NULL;   
130         Table_Args_4 *newargs;      
131         Table_Res_4 *newres; 
132
133         if (res!=NULL) xdr_free ((xdrproc_t)_DtCm_xdr_Table_Res_3, (char*)res); 
134
135         newargs = _DtCm_tableargs3_to_tableargs4(args);  
136         newres = _DtCm_rtable_abbreviated_lookup_range_4_svc(newargs, svcrq);  
137         res = _DtCm_tableres4_to_tableres3(newres);  
138
139         if (newargs!=NULL) xdr_free((xdrproc_t)_DtCm_xdr_Table_Args_4, (char*)newargs);  
140
141         return(res);
142 }
143
144 /*      PROC #6         */
145 extern Table_Res_3 *
146 _DtCm_rtable_insert_3_svc(args, svcrq)
147 Table_Args_3 *args;
148 struct svc_req *svcrq;
149 {
150         static Table_Res_3 *res = NULL;
151         Table_Args_4 *newargs;
152         Table_Res_4 *newres;
153
154         if (res!=NULL) xdr_free ((xdrproc_t)_DtCm_xdr_Table_Res_3, (char*)res);
155
156         newargs = _DtCm_tableargs3_to_tableargs4(args);
157         newres = _DtCm_rtable_insert_4_svc(newargs, svcrq);
158         res = _DtCm_tableres4_to_tableres3(newres);
159
160         if (newargs!=NULL) xdr_free((xdrproc_t)_DtCm_xdr_Table_Args_4, (char*)newargs);
161
162         return(res);
163 }
164
165 /*      PROC #7 */
166 extern Table_Res_3 *
167 _DtCm_rtable_delete_3_svc(args, svcrq)
168 Table_Args_3 *args;
169 struct svc_req *svcrq;
170 {
171         static Table_Res_3 *res = NULL; 
172         Table_Args_4 *newargs;
173         Table_Res_4 *newres; 
174
175         if (res!=NULL) xdr_free ((xdrproc_t)_DtCm_xdr_Table_Res_3, (char*)res);
176
177         newargs = _DtCm_tabledelargs3_to_tabledelargs4(args, do_all_4);
178         newres = _DtCm_rtable_delete_4_svc(newargs, svcrq); 
179         res = _DtCm_tableres4_to_tableres3(newres); 
180
181         if (newargs!=NULL) xdr_free((xdrproc_t)_DtCm_xdr_Table_Args_4, (char*)newargs); 
182
183         return(res); 
184 }
185
186 /*      PROC #8         */
187 extern Table_Res_3 *
188 _DtCm_rtable_delete_instance_3_svc(args, svcrq)
189 Table_Args_3 *args;
190 struct svc_req *svcrq;
191 {
192         static Table_Res_3 *res = NULL; 
193         Table_Args_4 *newargs;  
194         Table_Res_4 *newres;  
195
196         if (res!=NULL) xdr_free ((xdrproc_t)_DtCm_xdr_Table_Res_3, (char*)res); 
197
198         newargs = _DtCm_tabledelargs3_to_tabledelargs4(args, do_one_4);
199         newres = _DtCm_rtable_delete_4_svc(newargs, svcrq);  
200         res = _DtCm_tableres4_to_tableres3(newres);   
201
202         if (newargs!=NULL) xdr_free((xdrproc_t)_DtCm_xdr_Table_Args_4, (char*)newargs);   
203        
204         return(res);
205 }
206
207 /*      PROC #9 */
208 extern Table_Res_3 *
209 _DtCm_rtable_change_3_svc(args, svcrq)
210 Table_Args_3 *args;
211 struct svc_req *svcrq;
212 {
213         static Table_Res_3 *res = NULL;
214         Table_Args_4 *newargs; 
215         Table_Res_4 *newres;  
216
217         if (res!=NULL) xdr_free ((xdrproc_t)_DtCm_xdr_Table_Res_3, (char*)res); 
218
219         newargs = _DtCm_tableargs3_to_tableargs4(args); 
220         newres = _DtCm_rtable_change_4_svc(newargs, svcrq); 
221         res = _DtCm_tableres4_to_tableres3(newres);  
222
223         if (newargs!=NULL) xdr_free((xdrproc_t)_DtCm_xdr_Table_Args_4, (char*)newargs);  
224
225         return(res); 
226 }
227
228
229 /*      PROC #10        */
230 extern Table_Res_3 *
231 _DtCm_rtable_change_instance_3_svc(args, svcrq)
232 Table_Args_3 *args;
233 struct svc_req *svcrq;
234 {
235         static Table_Res_3 *res = NULL; 
236         Table_Args_4 *newargs;   
237         Table_Res_4 *newres;  
238
239         if (res!=NULL) xdr_free ((xdrproc_t)_DtCm_xdr_Table_Res_3, (char*)res); 
240
241         newargs = _DtCm_tableargs3_to_tableargs4(args);  
242         newargs->args.Args_4_u.apptid.option = do_one_4;
243         newres = _DtCm_rtable_change_4_svc(newargs, svcrq);  
244         res = _DtCm_tableres4_to_tableres3(newres);   
245
246         if (newargs!=NULL) xdr_free((xdrproc_t)_DtCm_xdr_Table_Args_4, (char*)newargs);   
247
248         return(res);
249 }
250
251 /*      PROC #11        */
252 extern Table_Res_3 *
253 _DtCm_rtable_lookup_next_reminder_3_svc(args, svcrq)
254 Table_Args_3 *args;
255 struct svc_req *svcrq;
256 {
257         static Table_Res_3 *res = NULL; 
258         Table_Args_4 *newargs;    
259         Table_Res_4 *newres;   
260
261         if (res!=NULL) xdr_free ((xdrproc_t)_DtCm_xdr_Table_Res_3, (char*)res);  
262
263         newargs = _DtCm_tableargs3_to_tableargs4(args);   
264         newres = _DtCm_rtable_lookup_next_reminder_4_svc(newargs, svcrq);   
265         res = _DtCm_tableres4_to_tableres3(newres);   
266
267         if (newargs!=NULL) xdr_free((xdrproc_t)_DtCm_xdr_Table_Args_4, (char*)newargs);    
268
269         return(res); 
270 }
271
272 /*      PROC #12        */
273 extern Table_Status_3 *
274 _DtCm_rtable_check_3_svc(args, svcrq)
275 Table_Args_3 *args;
276 struct svc_req *svcrq;
277 {
278         static Table_Status_3 res; 
279         Table_Args_4 *newargs;     
280         Table_Status_4 *newres;    
281
282         newargs = _DtCm_tableargs3_to_tableargs4(args);    
283         newres = _DtCm_rtable_check_4_svc(newargs, svcrq);    
284         res = _DtCm_tablestat4_to_tablestat3(*newres);   
285
286         if (newargs!=NULL) xdr_free((xdrproc_t)_DtCm_xdr_Table_Args_4, (char*)newargs);     
287
288         return(&res); 
289 }
290
291 /*      PROC #13        */
292 extern Table_Status_3 *
293 _DtCm_rtable_flush_table_3_svc(args, svcrq)
294 Table_Args_3 *args;
295 struct svc_req *svcrq;
296 {
297         static Table_Status_3 res;  
298         Table_Args_4 *newargs;     
299         Table_Status_4 *newres;     
300
301         newargs = _DtCm_tableargs3_to_tableargs4(args);     
302         newres = _DtCm_rtable_flush_table_4_svc(newargs, svcrq);     
303         res = _DtCm_tablestat4_to_tablestat3(*newres);    
304
305         if (newargs!=NULL) xdr_free((xdrproc_t)_DtCm_xdr_Table_Args_4, (char*)newargs);      
306
307         return(&res);
308 }
309
310 /*      PROC #14        */
311 extern int *
312 _DtCm_rtable_size_3_svc(args, svcrq)
313 Table_Args_3 *args;
314 struct svc_req *svcrq;
315 {
316         static int size;   
317         Table_Args_4 *newargs;      
318
319         newargs = _DtCm_tableargs3_to_tableargs4(args);     
320         size = (*(_DtCm_rtable_size_4_svc(newargs, svcrq)));      
321
322         if (newargs!=NULL) xdr_free((xdrproc_t)_DtCm_xdr_Table_Args_4, (char*)newargs);       
323
324         return(&size);
325 }
326
327 /*      PROC #15        */
328 Registration_Status_3 *
329 _DtCm_register_callback_3_svc(r, svcrq)
330 Registration_3 *r;
331 struct svc_req *svcrq;
332 {
333         static Registration_Status_3 stat;    
334         Registration_4 *newreg;       
335         Registration_Status_4 *newstat;
336
337         newreg = _DtCm_reg3_to_reg4(r);      
338         newstat = _DtCm_register_callback_4_svc(newreg, svcrq);      
339         stat = _DtCm_regstat4_to_regstat3(*newstat);      
340
341         if (newreg!=NULL) xdr_free((xdrproc_t)_DtCm_xdr_Registration_4, (char*)newreg);        
342         return(&stat);
343 }
344
345 /*      PROC #16        */
346 Registration_Status_3 *
347 _DtCm_deregister_callback_3_svc(r, svcrq)
348 Registration_3 *r;
349 struct svc_req *svcrq;
350 {
351         static Registration_Status_3 stat;     
352         Registration_4 *newreg;          
353         Registration_Status_4 *newstat; 
354
355         newreg = _DtCm_reg3_to_reg4(r);       
356         newstat = _DtCm_deregister_callback_4_svc(newreg, svcrq);       
357         stat = _DtCm_regstat4_to_regstat3(*newstat);       
358
359         if (newreg!=NULL) xdr_free((xdrproc_t)_DtCm_xdr_Registration_4, (char*)newreg);        
360         return(&stat);
361 }
362
363 /*      PROC #17        */
364 extern Access_Status_3 *
365 _DtCm_rtable_set_access_3_svc(args, svcrq)
366 Access_Args_3 *args;
367 struct svc_req *svcrq;
368 {
369         static Access_Status_3 stat;
370         Access_Args_4 *newargs;
371         Access_Status_4 *newstat;
372
373         newargs = _DtCm_accargs3_to_accargs4(args);     
374         newstat = _DtCm_rtable_set_access_4_svc(newargs, svcrq);     
375         stat = _DtCm_accstat4_to_accstat3(*newstat);    
376
377         if (newargs!=NULL) xdr_free((xdrproc_t)_DtCm_xdr_Access_Args_4, (char*)newargs);      
378         return(&stat);
379 }
380
381 /*      PROC #18        */
382 extern Access_Args_3 *
383 _DtCm_rtable_get_access_3_svc(args, svcrq)
384 Access_Args_3 *args;
385 struct svc_req *svcrq;
386 {
387         static Access_Args_3 *res = NULL;
388         Access_Args_4 *newargs;
389         Access_Args_4 *newres;
390
391         if (res!=NULL) xdr_free((xdrproc_t)_DtCm_xdr_Access_Args_3, (char*)res);
392
393         newargs = _DtCm_accargs3_to_accargs4(args);
394         newres = _DtCm_rtable_get_access_4_svc(newargs, svcrq);
395         res = _DtCm_accargs4_to_accargs3(newres);
396
397         if (newargs!=NULL) xdr_free((xdrproc_t)_DtCm_xdr_Access_Args_4, (char*)newargs); 
398         return(res); 
399 }
400
401 /*      PROC #19        */
402 extern Table_Res_3 *
403 _DtCm_rtable_abbreviated_lookup_key_range_3_svc(args, svcrq)
404 Table_Args_3 *args;
405 struct svc_req *svcrq;
406 {
407         static Table_Res_3 *res = NULL;
408         Table_Args_4 *newargs;   
409         Table_Res_4 *newres;  
410
411         if (res!=NULL) xdr_free ((xdrproc_t)_DtCm_xdr_Table_Res_3, (char*)res);
412
413         newargs = _DtCm_tableargs3_to_tableargs4(args);
414         newres = _DtCm_rtable_abbreviated_lookup_key_range_4_svc(newargs, svcrq);
415         res = _DtCm_tableres4_to_tableres3(newres);
416
417         if (newargs!=NULL) xdr_free((xdrproc_t)_DtCm_xdr_Table_Args_4, (char*)newargs);
418         return(res); 
419 }
420
421 /*      PROC #20        */
422 extern long *
423 _DtCm_rtable_gmtoff_3_svc(args, svcrq)
424 void *args;
425 struct svc_req *svcrq;
426 {
427         static long gmtoff;
428
429         gmtoff = (*(_DtCm_rtable_gmtoff_4_svc(NULL, svcrq)));
430
431         return(&gmtoff);
432 }
433
434 void initrtable3(ph)
435         program_handle ph;
436 {
437         ph->program_num = TABLEPROG;
438         ph->prog[TABLEVERS_3].vers = &tableprog_3_table[0];
439         ph->prog[TABLEVERS_3].nproc = sizeof(tableprog_3_table)/sizeof(tableprog_3_table[0]);
440 }
441