Merge branch 'linux1'
[oweals/cde.git] / cde / programs / dtcm / server / rtable2.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: rtable2.c /main/4 1995/11/09 12:51:38 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 2 in terms of Version 4 types        
34  */
35
36
37
38 #include <EUSCompat.h>
39 #include <stdio.h>
40 #include "rtable4.h"
41 #include "rtable2.h"
42 #include <sys/param.h>
43 #include <sys/time.h>
44 #include <rpc/rpc.h>
45 #include "rpcextras.h"
46 #include "convert2-4.h"
47 #include "convert4-2.h"
48 #include "rtable2_tbl.i"
49
50
51 /*************** V2 PROTOCOL IMPLEMENTATION PROCS *****************/
52 extern void *
53 _DtCm_rtable_ping_2_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_2 *
63 _DtCm_rtable_lookup_2_svc (args, svcrq)
64 Table_Args_2 *args;
65 struct svc_req *svcrq;
66 {
67         static Table_Res_2 *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_2, (char*)res);
72
73         newargs = _DtCm_tableargs2_to_tableargs4(args);
74         newres = _DtCm_rtable_lookup_4_svc(newargs, svcrq); 
75         
76         res = _DtCm_tableres4_to_tableres2(newres);
77
78         if (newargs!=NULL) xdr_free((xdrproc_t)_DtCm_xdr_Table_Args_4, (char*)newargs);
79
80         return(res);
81 }
82
83 /*      PROC #2         */
84 extern Table_Res_2 *
85 _DtCm_rtable_lookup_next_larger_2_svc(args, svcrq)
86 Table_Args_2 *args;
87 struct svc_req *svcrq;
88 {
89         static Table_Res_2 *res = NULL;
90         Table_Args_4 *newargs;   
91         Table_Res_4 *newres; 
92  
93         if (res!=NULL) xdr_free ((xdrproc_t)_DtCm_xdr_Table_Res_2, (char*)res);
94  
95         newargs = _DtCm_tableargs2_to_tableargs4(args);
96         newres = _DtCm_rtable_lookup_next_larger_4_svc(newargs, svcrq);
97         
98         res = _DtCm_tableres4_to_tableres2(newres);
99  
100         if (newargs!=NULL) xdr_free((xdrproc_t)_DtCm_xdr_Table_Args_4, (char*)newargs);
101  
102         return(res);
103
104 }
105
106 /*      PROC #3         */
107 extern Table_Res_2 *
108 _DtCm_rtable_lookup_next_smaller_2_svc(args, svcrq)
109 Table_Args_2 *args;
110 struct svc_req *svcrq;
111 {
112         static Table_Res_2 *res = NULL; 
113         Table_Args_4 *newargs;    
114         Table_Res_4 *newres; 
115   
116         if (res!=NULL) xdr_free ((xdrproc_t)_DtCm_xdr_Table_Res_2, (char*)res);
117   
118         newargs = _DtCm_tableargs2_to_tableargs4(args);
119         newres = _DtCm_rtable_lookup_next_smaller_4_svc(newargs, svcrq); 
120          
121         res = _DtCm_tableres4_to_tableres2(newres);
122   
123         if (newargs!=NULL) xdr_free((xdrproc_t)_DtCm_xdr_Table_Args_4, (char*)newargs);
124  
125         return(res);
126
127 }
128
129 /*      PROC #4         */
130 extern Table_Res_2 *
131 _DtCm_rtable_lookup_range_2_svc(args, svcrq)
132 Table_Args_2 *args;
133 struct svc_req *svcrq;
134 {
135         static Table_Res_2 *res = NULL;  
136         Table_Args_4 *newargs;     
137         Table_Res_4 *newres; 
138    
139         if (res!=NULL) xdr_free ((xdrproc_t)_DtCm_xdr_Table_Res_2, (char*)res);
140    
141         newargs = _DtCm_tableargs2_to_tableargs4(args); 
142         newres = _DtCm_rtable_lookup_range_4_svc(newargs, svcrq);  
143           
144         res = _DtCm_tableres4_to_tableres2(newres); 
145    
146         if (newargs!=NULL) xdr_free((xdrproc_t)_DtCm_xdr_Table_Args_4, (char*)newargs); 
147    
148         return(res);
149 }
150
151 /*      PROC #5         */
152 extern Table_Res_2 *
153 _DtCm_rtable_abbreviated_lookup_range_2_svc(args, svcrq)
154 Table_Args_2 *args;
155 struct svc_req *svcrq;
156 {
157         static Table_Res_2 *res = NULL;   
158         Table_Args_4 *newargs;      
159         Table_Res_4 *newres; 
160     
161         if (res!=NULL) xdr_free ((xdrproc_t)_DtCm_xdr_Table_Res_2, (char*)res); 
162    
163         newargs = _DtCm_tableargs2_to_tableargs4(args);  
164         newres = _DtCm_rtable_abbreviated_lookup_range_4_svc(newargs, svcrq);  
165            
166         res = _DtCm_tableres4_to_tableres2(newres);  
167    
168         if (newargs!=NULL) xdr_free((xdrproc_t)_DtCm_xdr_Table_Args_4, (char*)newargs);  
169     
170         return(res);
171 }
172
173 /*      PROC #6         */
174 extern Table_Res_2 *
175 _DtCm_rtable_insert_2_svc(args, svcrq)
176 Table_Args_2 *args;
177 struct svc_req *svcrq;
178 {
179         static Table_Res_2 *res = NULL;
180         Table_Args_4 *newargs;
181         Table_Res_4 *newres;
182     
183         if (res!=NULL) xdr_free ((xdrproc_t)_DtCm_xdr_Table_Res_2, (char*)res);
184   
185         newargs = _DtCm_tableargs2_to_tableargs4(args);
186         newres = _DtCm_rtable_insert_4_svc(newargs, svcrq);
187          
188         res = _DtCm_tableres4_to_tableres2(newres);
189   
190         if (newargs!=NULL) xdr_free((xdrproc_t)_DtCm_xdr_Table_Args_4, (char*)newargs);
191     
192         return(res);
193 }
194
195 /*      PROC #7 */
196 extern Table_Res_2 *
197 _DtCm_rtable_delete_2_svc(args, svcrq)
198 Table_Args_2 *args;
199 struct svc_req *svcrq;
200 {
201         static Table_Res_2 *res = NULL; 
202         Table_Args_4 *newargs;
203         Table_Res_4 *newres; 
204      
205         if (res!=NULL) xdr_free ((xdrproc_t)_DtCm_xdr_Table_Res_2, (char*)res);
206    
207         newargs = _DtCm_tabledelargs2_to_tabledelargs4(args, do_all_4);
208         newres = _DtCm_rtable_delete_4_svc(newargs, svcrq); 
209         res = _DtCm_tableres4_to_tableres2(newres); 
210   
211         if (newargs!=NULL) xdr_free((xdrproc_t)_DtCm_xdr_Table_Args_4, (char*)newargs); 
212      
213         return(res); 
214 }
215
216 /*      PROC #8         */
217 extern Table_Res_2 *
218 _DtCm_rtable_delete_instance_2_svc(args, svcrq)
219 Table_Args_2 *args;
220 struct svc_req *svcrq;
221 {
222         static Table_Res_2 *res = NULL; 
223         Table_Args_4 *newargs;  
224         Table_Res_4 *newres;  
225        
226         if (res!=NULL) xdr_free ((xdrproc_t)_DtCm_xdr_Table_Res_2, (char*)res); 
227
228         newargs = _DtCm_tabledelargs2_to_tabledelargs4(args, do_one_4);
229         newres = _DtCm_rtable_delete_4_svc(newargs, svcrq);  
230         res = _DtCm_tableres4_to_tableres2(newres);   
231    
232         if (newargs!=NULL) xdr_free((xdrproc_t)_DtCm_xdr_Table_Args_4, (char*)newargs);   
233        
234         return(res);
235 }
236
237 /*      PROC #9 */
238 extern Table_Res_2 *
239 _DtCm_rtable_change_2_svc(args, svcrq)
240 Table_Args_2 *args;
241 struct svc_req *svcrq;
242 {
243         static Table_Res_2 *res = NULL;
244         Table_Args_4 *newargs; 
245         Table_Res_4 *newres;  
246       
247         if (res!=NULL) xdr_free ((xdrproc_t)_DtCm_xdr_Table_Res_2, (char*)res); 
248     
249         newargs = _DtCm_tableargs2_to_tableargs4(args); 
250         newres = _DtCm_rtable_change_4_svc(newargs, svcrq); 
251         res = _DtCm_tableres4_to_tableres2(newres);  
252   
253         if (newargs!=NULL) xdr_free((xdrproc_t)_DtCm_xdr_Table_Args_4, (char*)newargs);  
254       
255         return(res); 
256 }
257
258
259 /*      PROC #10        */
260 extern Table_Res_2 *
261 _DtCm_rtable_change_instance_2_svc(args, svcrq)
262 Table_Args_2 *args;
263 struct svc_req *svcrq;
264 {
265         static Table_Res_2 *res = NULL; 
266         Table_Args_4 *newargs;   
267         Table_Res_4 *newres;  
268        
269         if (res!=NULL) xdr_free ((xdrproc_t)_DtCm_xdr_Table_Res_2, (char*)res); 
270      
271         newargs = _DtCm_tableargs2_to_tableargs4(args);  
272         newargs->args.Args_4_u.apptid.option = do_one_4;
273         newres = _DtCm_rtable_change_4_svc(newargs, svcrq);  
274         res = _DtCm_tableres4_to_tableres2(newres);   
275    
276         if (newargs!=NULL) xdr_free((xdrproc_t)_DtCm_xdr_Table_Args_4, (char*)newargs);   
277        
278         return(res);
279 }
280
281 /*      PROC #11        */
282 extern Table_Res_2 *
283 _DtCm_rtable_lookup_next_reminder_2_svc(args, svcrq)
284 Table_Args_2 *args;
285 struct svc_req *svcrq;
286 {
287         static Table_Res_2 *res = NULL; 
288         Table_Args_4 *newargs;    
289         Table_Res_4 *newres;   
290         
291         if (res!=NULL) xdr_free ((xdrproc_t)_DtCm_xdr_Table_Res_2, (char*)res);  
292       
293         newargs = _DtCm_tableargs2_to_tableargs4(args);   
294         newres = _DtCm_rtable_lookup_next_reminder_4_svc(newargs, svcrq);   
295              
296         res = _DtCm_tableres4_to_tableres2(newres);   
297     
298         if (newargs!=NULL) xdr_free((xdrproc_t)_DtCm_xdr_Table_Args_4, (char*)newargs);    
299         
300         return(res); 
301 }
302
303 /*      PROC #12        */
304 extern Table_Status_2 *
305 _DtCm_rtable_check_2_svc(args, svcrq)
306 Table_Args_2 *args;
307 struct svc_req *svcrq;
308 {
309         static Table_Status_2 res; 
310         Table_Args_4 *newargs;     
311         Table_Status_4 *newres;    
312        
313         newargs = _DtCm_tableargs2_to_tableargs4(args);    
314         newres = _DtCm_rtable_check_4_svc(newargs, svcrq);    
315               
316         res = _DtCm_tablestat4_to_tablestat2(*newres);   
317      
318         if (newargs!=NULL) xdr_free((xdrproc_t)_DtCm_xdr_Table_Args_4, (char*)newargs);     
319          
320         return(&res); 
321 }
322
323 /*      PROC #13        */
324 extern Table_Status_2 *
325 _DtCm_rtable_flush_table_2_svc(args, svcrq)
326 Table_Args_2 *args;
327 struct svc_req *svcrq;
328 {
329         static Table_Status_2 res;  
330         Table_Args_4 *newargs;     
331         Table_Status_4 *newres;     
332         
333         newargs = _DtCm_tableargs2_to_tableargs4(args);     
334         newres = _DtCm_rtable_flush_table_4_svc(newargs, svcrq);     
335                
336         res = _DtCm_tablestat4_to_tablestat2(*newres);    
337      
338         if (newargs!=NULL) xdr_free((xdrproc_t)_DtCm_xdr_Table_Args_4, (char*)newargs);      
339           
340         return(&res);
341 }
342
343 /*      PROC #14        */
344 extern int *
345 _DtCm_rtable_size_2_svc(args, svcrq)
346 Table_Args_2 *args;
347 struct svc_req *svcrq;
348 {
349         static int size;   
350         Table_Args_4 *newargs;      
351          
352         newargs = _DtCm_tableargs2_to_tableargs4(args);     
353         size = (*(_DtCm_rtable_size_4_svc(newargs, svcrq)));      
354       
355         if (newargs!=NULL) xdr_free((xdrproc_t)_DtCm_xdr_Table_Args_4, (char*)newargs);       
356            
357         return(&size);
358 }
359
360 /*      PROC #15        */
361 Registration_Status_2 *
362 _DtCm_register_callback_2_svc(r, svcrq)
363 Registration_2 *r;
364 struct svc_req *svcrq;
365 {
366         static Registration_Status_2 stat;    
367         Registration_4 *newreg;       
368         Registration_Status_4 *newstat;
369           
370         newreg = _DtCm_reg2_to_reg4(r);      
371         newstat = _DtCm_register_callback_4_svc(newreg, svcrq);      
372                  
373         stat = _DtCm_regstat4_to_regstat2(*newstat);      
374       
375         if (newreg!=NULL) xdr_free((xdrproc_t)_DtCm_xdr_Registration_4, (char*)newreg);        
376         return(&stat);
377 }
378
379 /*      PROC #16        */
380 Registration_Status_2 *
381 _DtCm_deregister_callback_2_svc(r, svcrq)
382 Registration_2 *r;
383 struct svc_req *svcrq;
384 {
385         static Registration_Status_2 stat;     
386         Registration_4 *newreg;          
387         Registration_Status_4 *newstat; 
388            
389         newreg = _DtCm_reg2_to_reg4(r);       
390         newstat = _DtCm_deregister_callback_4_svc(newreg, svcrq);       
391                   
392         stat = _DtCm_regstat4_to_regstat2(*newstat);       
393        
394         if (newreg!=NULL) xdr_free((xdrproc_t)_DtCm_xdr_Registration_4, (char*)newreg);        
395         return(&stat);
396 }
397
398 /*      PROC #17        */
399 extern Access_Status_2 *
400 _DtCm_rtable_set_access_2_svc(args, svcrq)
401 Access_Args_2 *args;
402 struct svc_req *svcrq;
403 {
404         static Access_Status_2 stat;
405         Access_Args_4 *newargs;
406         Access_Status_4 *newstat;
407         
408         newargs = _DtCm_accargs2_to_accargs4(args);     
409         newstat = _DtCm_rtable_set_access_4_svc(newargs, svcrq);     
410                
411         stat = _DtCm_accstat4_to_accstat2(*newstat);    
412      
413         if (newargs!=NULL) xdr_free((xdrproc_t)_DtCm_xdr_Access_Args_4, (char*)newargs);      
414         return(&stat);
415 }
416
417 /*      PROC #18        */
418 extern Access_Args_2 *
419 _DtCm_rtable_get_access_2_svc(args, svcrq)
420 Access_Args_2 *args;
421 struct svc_req *svcrq;
422 {
423         static Access_Args_2 *res = NULL;
424         Access_Args_4 *newargs;
425         Access_Args_4 *newres;
426         
427         if (res!=NULL) xdr_free((xdrproc_t)_DtCm_xdr_Access_Args_2, (char*)res);
428
429         newargs = _DtCm_accargs2_to_accargs4(args);
430         newres = _DtCm_rtable_get_access_4_svc(newargs, svcrq);
431                
432         res = _DtCm_accargs4_to_accargs2(newres);
433         
434         if (newargs!=NULL) xdr_free((xdrproc_t)_DtCm_xdr_Access_Args_4, (char*)newargs); 
435
436         return(res); 
437 }
438
439 void initrtable2(ph)
440         program_handle ph;
441 {
442         int ver = TABLEVERS_2;
443         ph->program_num = TABLEPROG;
444         ph->prog[TABLEVERS_2].vers = &tableprog_2_table[0];
445         ph->prog[TABLEVERS_2].nproc = sizeof(tableprog_2_table)/sizeof(tableprog_2_table[0]);
446 }
447