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