dtcm/server/: just return NULL, not the address of a dummy local variable. Geez.
[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         return(NULL); /* for RPC reply */
58 }
59
60 /*      PROC #1         */
61 extern Table_Res_3 *
62 _DtCm_rtable_lookup_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_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 #2         */
82 extern Table_Res_3 *
83 _DtCm_rtable_lookup_next_larger_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_larger_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 #3         */
103 extern Table_Res_3 *
104 _DtCm_rtable_lookup_next_smaller_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_next_smaller_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 #4         */
124 extern Table_Res_3 *
125 _DtCm_rtable_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_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 #5         */
145 extern Table_Res_3 *
146 _DtCm_rtable_abbreviated_lookup_range_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_abbreviated_lookup_range_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 #6         */
166 extern Table_Res_3 *
167 _DtCm_rtable_insert_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_tableargs3_to_tableargs4(args);
178         newres = _DtCm_rtable_insert_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 #7 */
187 extern Table_Res_3 *
188 _DtCm_rtable_delete_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_all_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 #8         */
208 extern Table_Res_3 *
209 _DtCm_rtable_delete_instance_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_tabledelargs3_to_tabledelargs4(args, do_one_4);
220         newres = _DtCm_rtable_delete_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 /*      PROC #9 */
229 extern Table_Res_3 *
230 _DtCm_rtable_change_3_svc(args, svcrq)
231 Table_Args_3 *args;
232 struct svc_req *svcrq;
233 {
234         static Table_Res_3 *res = NULL;
235         Table_Args_4 *newargs; 
236         Table_Res_4 *newres;  
237
238         if (res!=NULL) xdr_free ((xdrproc_t)_DtCm_xdr_Table_Res_3, (char*)res); 
239
240         newargs = _DtCm_tableargs3_to_tableargs4(args); 
241         newres = _DtCm_rtable_change_4_svc(newargs, svcrq); 
242         res = _DtCm_tableres4_to_tableres3(newres);  
243
244         if (newargs!=NULL) xdr_free((xdrproc_t)_DtCm_xdr_Table_Args_4, (char*)newargs);  
245
246         return(res); 
247 }
248
249
250 /*      PROC #10        */
251 extern Table_Res_3 *
252 _DtCm_rtable_change_instance_3_svc(args, svcrq)
253 Table_Args_3 *args;
254 struct svc_req *svcrq;
255 {
256         static Table_Res_3 *res = NULL; 
257         Table_Args_4 *newargs;   
258         Table_Res_4 *newres;  
259
260         if (res!=NULL) xdr_free ((xdrproc_t)_DtCm_xdr_Table_Res_3, (char*)res); 
261
262         newargs = _DtCm_tableargs3_to_tableargs4(args);  
263         newargs->args.Args_4_u.apptid.option = do_one_4;
264         newres = _DtCm_rtable_change_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 #11        */
273 extern Table_Res_3 *
274 _DtCm_rtable_lookup_next_reminder_3_svc(args, svcrq)
275 Table_Args_3 *args;
276 struct svc_req *svcrq;
277 {
278         static Table_Res_3 *res = NULL; 
279         Table_Args_4 *newargs;    
280         Table_Res_4 *newres;   
281
282         if (res!=NULL) xdr_free ((xdrproc_t)_DtCm_xdr_Table_Res_3, (char*)res);  
283
284         newargs = _DtCm_tableargs3_to_tableargs4(args);   
285         newres = _DtCm_rtable_lookup_next_reminder_4_svc(newargs, svcrq);   
286         res = _DtCm_tableres4_to_tableres3(newres);   
287
288         if (newargs!=NULL) xdr_free((xdrproc_t)_DtCm_xdr_Table_Args_4, (char*)newargs);    
289
290         return(res); 
291 }
292
293 /*      PROC #12        */
294 extern Table_Status_3 *
295 _DtCm_rtable_check_3_svc(args, svcrq)
296 Table_Args_3 *args;
297 struct svc_req *svcrq;
298 {
299         static Table_Status_3 res; 
300         Table_Args_4 *newargs;     
301         Table_Status_4 *newres;    
302
303         newargs = _DtCm_tableargs3_to_tableargs4(args);    
304         newres = _DtCm_rtable_check_4_svc(newargs, svcrq);    
305         res = _DtCm_tablestat4_to_tablestat3(*newres);   
306
307         if (newargs!=NULL) xdr_free((xdrproc_t)_DtCm_xdr_Table_Args_4, (char*)newargs);     
308
309         return(&res); 
310 }
311
312 /*      PROC #13        */
313 extern Table_Status_3 *
314 _DtCm_rtable_flush_table_3_svc(args, svcrq)
315 Table_Args_3 *args;
316 struct svc_req *svcrq;
317 {
318         static Table_Status_3 res;  
319         Table_Args_4 *newargs;     
320         Table_Status_4 *newres;     
321
322         newargs = _DtCm_tableargs3_to_tableargs4(args);     
323         newres = _DtCm_rtable_flush_table_4_svc(newargs, svcrq);     
324         res = _DtCm_tablestat4_to_tablestat3(*newres);    
325
326         if (newargs!=NULL) xdr_free((xdrproc_t)_DtCm_xdr_Table_Args_4, (char*)newargs);      
327
328         return(&res);
329 }
330
331 /*      PROC #14        */
332 extern int *
333 _DtCm_rtable_size_3_svc(args, svcrq)
334 Table_Args_3 *args;
335 struct svc_req *svcrq;
336 {
337         static int size;   
338         Table_Args_4 *newargs;      
339
340         newargs = _DtCm_tableargs3_to_tableargs4(args);     
341         size = (*(_DtCm_rtable_size_4_svc(newargs, svcrq)));      
342
343         if (newargs!=NULL) xdr_free((xdrproc_t)_DtCm_xdr_Table_Args_4, (char*)newargs);       
344
345         return(&size);
346 }
347
348 /*      PROC #15        */
349 Registration_Status_3 *
350 _DtCm_register_callback_3_svc(r, svcrq)
351 Registration_3 *r;
352 struct svc_req *svcrq;
353 {
354         static Registration_Status_3 stat;    
355         Registration_4 *newreg;       
356         Registration_Status_4 *newstat;
357
358         newreg = _DtCm_reg3_to_reg4(r);      
359         newstat = _DtCm_register_callback_4_svc(newreg, svcrq);      
360         stat = _DtCm_regstat4_to_regstat3(*newstat);      
361
362         if (newreg!=NULL) xdr_free((xdrproc_t)_DtCm_xdr_Registration_4, (char*)newreg);        
363         return(&stat);
364 }
365
366 /*      PROC #16        */
367 Registration_Status_3 *
368 _DtCm_deregister_callback_3_svc(r, svcrq)
369 Registration_3 *r;
370 struct svc_req *svcrq;
371 {
372         static Registration_Status_3 stat;     
373         Registration_4 *newreg;          
374         Registration_Status_4 *newstat; 
375
376         newreg = _DtCm_reg3_to_reg4(r);       
377         newstat = _DtCm_deregister_callback_4_svc(newreg, svcrq);       
378         stat = _DtCm_regstat4_to_regstat3(*newstat);       
379
380         if (newreg!=NULL) xdr_free((xdrproc_t)_DtCm_xdr_Registration_4, (char*)newreg);        
381         return(&stat);
382 }
383
384 /*      PROC #17        */
385 extern Access_Status_3 *
386 _DtCm_rtable_set_access_3_svc(args, svcrq)
387 Access_Args_3 *args;
388 struct svc_req *svcrq;
389 {
390         static Access_Status_3 stat;
391         Access_Args_4 *newargs;
392         Access_Status_4 *newstat;
393
394         newargs = _DtCm_accargs3_to_accargs4(args);     
395         newstat = _DtCm_rtable_set_access_4_svc(newargs, svcrq);     
396         stat = _DtCm_accstat4_to_accstat3(*newstat);    
397
398         if (newargs!=NULL) xdr_free((xdrproc_t)_DtCm_xdr_Access_Args_4, (char*)newargs);      
399         return(&stat);
400 }
401
402 /*      PROC #18        */
403 extern Access_Args_3 *
404 _DtCm_rtable_get_access_3_svc(args, svcrq)
405 Access_Args_3 *args;
406 struct svc_req *svcrq;
407 {
408         static Access_Args_3 *res = NULL;
409         Access_Args_4 *newargs;
410         Access_Args_4 *newres;
411
412         if (res!=NULL) xdr_free((xdrproc_t)_DtCm_xdr_Access_Args_3, (char*)res);
413
414         newargs = _DtCm_accargs3_to_accargs4(args);
415         newres = _DtCm_rtable_get_access_4_svc(newargs, svcrq);
416         res = _DtCm_accargs4_to_accargs3(newres);
417
418         if (newargs!=NULL) xdr_free((xdrproc_t)_DtCm_xdr_Access_Args_4, (char*)newargs); 
419         return(res); 
420 }
421
422 /*      PROC #19        */
423 extern Table_Res_3 *
424 _DtCm_rtable_abbreviated_lookup_key_range_3_svc(args, svcrq)
425 Table_Args_3 *args;
426 struct svc_req *svcrq;
427 {
428         static Table_Res_3 *res = NULL;
429         Table_Args_4 *newargs;   
430         Table_Res_4 *newres;  
431
432         if (res!=NULL) xdr_free ((xdrproc_t)_DtCm_xdr_Table_Res_3, (char*)res);
433
434         newargs = _DtCm_tableargs3_to_tableargs4(args);
435         newres = _DtCm_rtable_abbreviated_lookup_key_range_4_svc(newargs, svcrq);
436         res = _DtCm_tableres4_to_tableres3(newres);
437
438         if (newargs!=NULL) xdr_free((xdrproc_t)_DtCm_xdr_Table_Args_4, (char*)newargs);
439         return(res); 
440 }
441
442 /*      PROC #20        */
443 extern long *
444 _DtCm_rtable_gmtoff_3_svc(args, svcrq)
445 void *args;
446 struct svc_req *svcrq;
447 {
448         static long gmtoff;
449
450         gmtoff = (*(_DtCm_rtable_gmtoff_4_svc(NULL, svcrq)));
451
452         return(&gmtoff);
453 }
454
455 void initrtable3(ph)
456         program_handle ph;
457 {
458         ph->program_num = TABLEPROG;
459         ph->prog[TABLEVERS_3].vers = &tableprog_3_table[0];
460         ph->prog[TABLEVERS_3].nproc = sizeof(tableprog_3_table)/sizeof(tableprog_3_table[0]);
461 }
462