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