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