Deleted Added
full compact
rpc_hout.c (12798) rpc_hout.c (17142)
1/*
2 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
3 * unrestricted use provided that this legend is included on all tape
4 * media and as a part of the software program in whole or part. Users
5 * may copy or modify Sun RPC without charge, but are not authorized
6 * to license or distribute it to anyone else except as part of a product or
7 * program developed by the user.
8 *

--- 29 unchanged lines hidden (view full) ---

38 * Copyright (C) 1987, Sun Microsystems, Inc.
39 */
40#include <stdio.h>
41#include <ctype.h>
42#include "rpc_parse.h"
43#include "rpc_util.h"
44
45void storexdrfuncdecl __P(( char *, int ));
1/*
2 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
3 * unrestricted use provided that this legend is included on all tape
4 * media and as a part of the software program in whole or part. Users
5 * may copy or modify Sun RPC without charge, but are not authorized
6 * to license or distribute it to anyone else except as part of a product or
7 * program developed by the user.
8 *

--- 29 unchanged lines hidden (view full) ---

38 * Copyright (C) 1987, Sun Microsystems, Inc.
39 */
40#include <stdio.h>
41#include <ctype.h>
42#include "rpc_parse.h"
43#include "rpc_util.h"
44
45void storexdrfuncdecl __P(( char *, int ));
46static int pconstdef __P(( definition * ));
47static int pstructdef __P(( definition * ));
48static int puniondef __P(( definition * ));
49static int pprogramdef __P(( definition * ));
50static int pstructdef __P(( definition * ));
51static int penumdef __P(( definition * ));
52static int ptypedef __P(( definition * ));
53static int pdefine __P(( char *, char * ));
46static void pconstdef __P(( definition * ));
47static void pstructdef __P(( definition * ));
48static void puniondef __P(( definition * ));
49static void pprogramdef __P(( definition * ));
50static void pstructdef __P(( definition * ));
51static void penumdef __P(( definition * ));
52static void ptypedef __P(( definition * ));
53static void pdefine __P(( char *, char * ));
54static int undefined2 __P(( char *, char * ));
54static int undefined2 __P(( char *, char * ));
55static int parglist __P(( proc_list *, char * ));
55static void parglist __P(( proc_list *, char * ));
56static void pprocdef __P(( proc_list *, version_list *, char *, int, int ));
57void pdeclaration __P(( char *, declaration *, int, char * ));
56
57static char RESULT[] = "clnt_res";
58
59
60/*
61 * Print the C-version of an xdr definition
62 */
63void

--- 40 unchanged lines hidden (view full) ---

104print_funcdef(def)
105 definition *def;
106{
107 switch (def->def_kind) {
108 case DEF_PROGRAM:
109 f_print(fout, "\n");
110 pprogramdef(def);
111 break;
58
59static char RESULT[] = "clnt_res";
60
61
62/*
63 * Print the C-version of an xdr definition
64 */
65void

--- 40 unchanged lines hidden (view full) ---

106print_funcdef(def)
107 definition *def;
108{
109 switch (def->def_kind) {
110 case DEF_PROGRAM:
111 f_print(fout, "\n");
112 pprogramdef(def);
113 break;
112 }
114 default:
115 }
113}
114
115/* store away enough information to allow the XDR functions to be spat
116 out at the end of the file */
117
118void
119storexdrfuncdecl(name, pointerp)
120char *name;

--- 31 unchanged lines hidden (view full) ---

152 else
153 f_print(fout, "extern bool_t xdr_%s(XDR *, %s%s);\n", name,
154 name, pointerp ? "*" : "");
155
156
157}
158
159
116}
117
118/* store away enough information to allow the XDR functions to be spat
119 out at the end of the file */
120
121void
122storexdrfuncdecl(name, pointerp)
123char *name;

--- 31 unchanged lines hidden (view full) ---

155 else
156 f_print(fout, "extern bool_t xdr_%s(XDR *, %s%s);\n", name,
157 name, pointerp ? "*" : "");
158
159
160}
161
162
160static
163static void
161pconstdef(def)
162 definition *def;
163{
164 pdefine(def->def_name, def->def.co);
165}
166
167/* print out the definitions for the arguments of functions in the
168 header file
169*/
164pconstdef(def)
165 definition *def;
166{
167 pdefine(def->def_name, def->def.co);
168}
169
170/* print out the definitions for the arguments of functions in the
171 header file
172*/
170static
173static void
171pargdef(def)
172 definition *def;
173{
174 decl_list *l;
175 version_list *vers;
176 char *name;
177 proc_list *plist;
178

--- 17 unchanged lines hidden (view full) ---

196 name, name);
197 storexdrfuncdecl(name, 1);
198 f_print(fout, "\n");
199 }
200 }
201}
202
203
174pargdef(def)
175 definition *def;
176{
177 decl_list *l;
178 version_list *vers;
179 char *name;
180 proc_list *plist;
181

--- 17 unchanged lines hidden (view full) ---

199 name, name);
200 storexdrfuncdecl(name, 1);
201 f_print(fout, "\n");
202 }
203 }
204}
205
206
204static
207static void
205pstructdef(def)
206 definition *def;
207{
208 decl_list *l;
209 char *name = def->def_name;
210
211 f_print(fout, "struct %s {\n", name);
212 for (l = def->def.st.decls; l != NULL; l = l->next) {
213 pdeclaration(name, &l->decl, 1, ";\n");
214 }
215 f_print(fout, "};\n");
216 f_print(fout, "typedef struct %s %s;\n", name, name);
217}
218
208pstructdef(def)
209 definition *def;
210{
211 decl_list *l;
212 char *name = def->def_name;
213
214 f_print(fout, "struct %s {\n", name);
215 for (l = def->def.st.decls; l != NULL; l = l->next) {
216 pdeclaration(name, &l->decl, 1, ";\n");
217 }
218 f_print(fout, "};\n");
219 f_print(fout, "typedef struct %s %s;\n", name, name);
220}
221
219static
222static void
220puniondef(def)
221 definition *def;
222{
223 case_list *l;
224 char *name = def->def_name;
225 declaration *decl;
226
227 f_print(fout, "struct %s {\n", name);

--- 12 unchanged lines hidden (view full) ---

240 if (decl && !streq(decl->type, "void")) {
241 pdeclaration(name, decl, 2, ";\n");
242 }
243 f_print(fout, "\t} %s_u;\n", name);
244 f_print(fout, "};\n");
245 f_print(fout, "typedef struct %s %s;\n", name, name);
246}
247
223puniondef(def)
224 definition *def;
225{
226 case_list *l;
227 char *name = def->def_name;
228 declaration *decl;
229
230 f_print(fout, "struct %s {\n", name);

--- 12 unchanged lines hidden (view full) ---

243 if (decl && !streq(decl->type, "void")) {
244 pdeclaration(name, decl, 2, ";\n");
245 }
246 f_print(fout, "\t} %s_u;\n", name);
247 f_print(fout, "};\n");
248 f_print(fout, "typedef struct %s %s;\n", name, name);
249}
250
248static
251static void
249pdefine(name, num)
250 char *name;
251 char *num;
252{
253 f_print(fout, "#define\t%s %s\n", name, num);
254}
255
252pdefine(name, num)
253 char *name;
254 char *num;
255{
256 f_print(fout, "#define\t%s %s\n", name, num);
257}
258
256static
259static void
257puldefine(name, num)
258 char *name;
259 char *num;
260{
261 f_print(fout, "#define\t%s ((unsigned long)(%s))\n", name, num);
262}
263
260puldefine(name, num)
261 char *name;
262 char *num;
263{
264 f_print(fout, "#define\t%s ((unsigned long)(%s))\n", name, num);
265}
266
264static
267static int
265define_printed(stop, start)
266 proc_list *stop;
267 version_list *start;
268{
269 version_list *vers;
270 proc_list *proc;
271
272 for (vers = start; vers != NULL; vers = vers->next) {

--- 4 unchanged lines hidden (view full) ---

277 return (1);
278 }
279 }
280 }
281 abort();
282 /* NOTREACHED */
283}
284
268define_printed(stop, start)
269 proc_list *stop;
270 version_list *start;
271{
272 version_list *vers;
273 proc_list *proc;
274
275 for (vers = start; vers != NULL; vers = vers->next) {

--- 4 unchanged lines hidden (view full) ---

280 return (1);
281 }
282 }
283 }
284 abort();
285 /* NOTREACHED */
286}
287
285static
288static void
286pfreeprocdef(char * name, char *vers, int mode)
287{
288 f_print(fout, "extern int ");
289 pvname(name, vers);
290 if (mode == 1)
291 f_print(fout,"_freeresult(SVCXPRT *, xdrproc_t, caddr_t);\n");
292 else
293 f_print(fout,"_freeresult();\n");
294
295
296}
297
289pfreeprocdef(char * name, char *vers, int mode)
290{
291 f_print(fout, "extern int ");
292 pvname(name, vers);
293 if (mode == 1)
294 f_print(fout,"_freeresult(SVCXPRT *, xdrproc_t, caddr_t);\n");
295 else
296 f_print(fout,"_freeresult();\n");
297
298
299}
300
298static
301static void
299pprogramdef(def)
300 definition *def;
301{
302 version_list *vers;
303 proc_list *proc;
304 int i;
305 char *ext;
306

--- 59 unchanged lines hidden (view full) ---

366 }
367 pfreeprocdef(def->def_name, vers->vers_num, i);
368 }
369 f_print(fout, "#endif /* K&R C */\n");
370 }
371 }
372}
373
302pprogramdef(def)
303 definition *def;
304{
305 version_list *vers;
306 proc_list *proc;
307 int i;
308 char *ext;
309

--- 59 unchanged lines hidden (view full) ---

369 }
370 pfreeprocdef(def->def_name, vers->vers_num, i);
371 }
372 f_print(fout, "#endif /* K&R C */\n");
373 }
374 }
375}
376
377static void
374pprocdef(proc, vp, addargtype, server_p, mode)
375 proc_list *proc;
376 version_list *vp;
377 char* addargtype;
378 int server_p;
379 int mode;
380{
381 if (mtflag) {/* Print MT style stubs */

--- 12 unchanged lines hidden (view full) ---

394
395 /*
396 * mode 1 = ANSI-C, mode 2 = K&R C
397 */
398 if ( mode == 1)
399 parglist(proc, addargtype);
400 else
401 f_print(fout, "();\n");
378pprocdef(proc, vp, addargtype, server_p, mode)
379 proc_list *proc;
380 version_list *vp;
381 char* addargtype;
382 int server_p;
383 int mode;
384{
385 if (mtflag) {/* Print MT style stubs */

--- 12 unchanged lines hidden (view full) ---

398
399 /*
400 * mode 1 = ANSI-C, mode 2 = K&R C
401 */
402 if ( mode == 1)
403 parglist(proc, addargtype);
404 else
405 f_print(fout, "();\n");
402
403
404
405}
406
407
408
409/* print out argument list of procedure */
406}
407
408
409
410/* print out argument list of procedure */
410static
411static void
411parglist(proc, addargtype)
412 proc_list *proc;
413 char* addargtype;
414{
415 decl_list *dl;
416
417 f_print(fout, "(");
418 if (proc->arg_num < 2 && newstyle &&

--- 14 unchanged lines hidden (view full) ---

433 ptype(proc->res_prefix, proc->res_type, 1);
434 f_print(fout, "*, ");
435 }
436
437 f_print(fout, "%s);\n", addargtype);
438
439}
440
412parglist(proc, addargtype)
413 proc_list *proc;
414 char* addargtype;
415{
416 decl_list *dl;
417
418 f_print(fout, "(");
419 if (proc->arg_num < 2 && newstyle &&

--- 14 unchanged lines hidden (view full) ---

434 ptype(proc->res_prefix, proc->res_type, 1);
435 f_print(fout, "*, ");
436 }
437
438 f_print(fout, "%s);\n", addargtype);
439
440}
441
441static
442static void
442penumdef(def)
443 definition *def;
444{
445 char *name = def->def_name;
446 enumval_list *l;
447 char *last = NULL;
448 int count = 0;
449

--- 15 unchanged lines hidden (view full) ---

465 f_print(fout, ",\n");
466 else
467 f_print(fout, "\n");
468 }
469 f_print(fout, "};\n");
470 f_print(fout, "typedef enum %s %s;\n", name, name);
471}
472
443penumdef(def)
444 definition *def;
445{
446 char *name = def->def_name;
447 enumval_list *l;
448 char *last = NULL;
449 int count = 0;
450

--- 15 unchanged lines hidden (view full) ---

466 f_print(fout, ",\n");
467 else
468 f_print(fout, "\n");
469 }
470 f_print(fout, "};\n");
471 f_print(fout, "typedef enum %s %s;\n", name, name);
472}
473
473static
474static void
474ptypedef(def)
475 definition *def;
476{
477 char *name = def->def_name;
478 char *old = def->def.ty.old_type;
479 char prefix[8]; /* enough to contain "struct ", including NUL */
480 relation rel = def->def.ty.rel;
481

--- 30 unchanged lines hidden (view full) ---

512 case REL_ALIAS:
513 f_print(fout, "%s%s %s", prefix, old, name);
514 break;
515 }
516 f_print(fout, ";\n");
517 }
518}
519
475ptypedef(def)
476 definition *def;
477{
478 char *name = def->def_name;
479 char *old = def->def.ty.old_type;
480 char prefix[8]; /* enough to contain "struct ", including NUL */
481 relation rel = def->def.ty.rel;
482

--- 30 unchanged lines hidden (view full) ---

513 case REL_ALIAS:
514 f_print(fout, "%s%s %s", prefix, old, name);
515 break;
516 }
517 f_print(fout, ";\n");
518 }
519}
520
521void
520pdeclaration(name, dec, tab, separator)
521 char *name;
522 declaration *dec;
523 int tab;
524 char *separator;
525{
526 char buf[8]; /* enough to hold "struct ", include NUL */
527 char *prefix;

--- 42 unchanged lines hidden (view full) ---

570 tabify(fout, tab);
571 f_print(fout, "} %s", dec->name);
572 break;
573 }
574 }
575 f_print(fout, separator);
576}
577
522pdeclaration(name, dec, tab, separator)
523 char *name;
524 declaration *dec;
525 int tab;
526 char *separator;
527{
528 char buf[8]; /* enough to hold "struct ", include NUL */
529 char *prefix;

--- 42 unchanged lines hidden (view full) ---

572 tabify(fout, tab);
573 f_print(fout, "} %s", dec->name);
574 break;
575 }
576 }
577 f_print(fout, separator);
578}
579
578static
580static int
579undefined2(type, stop)
580 char *type;
581 char *stop;
582{
583 list *l;
584 definition *def;
585
586 for (l = defined; l != NULL; l = l->next) {
587 def = (definition *) l->val;
588 if (def->def_kind != DEF_PROGRAM) {
589 if (streq(def->def_name, stop)) {
590 return (1);
591 } else if (streq(def->def_name, type)) {
592 return (0);
593 }
594 }
595 }
596 return (1);
597}
581undefined2(type, stop)
582 char *type;
583 char *stop;
584{
585 list *l;
586 definition *def;
587
588 for (l = defined; l != NULL; l = l->next) {
589 def = (definition *) l->val;
590 if (def->def_kind != DEF_PROGRAM) {
591 if (streq(def->def_name, stop)) {
592 return (1);
593 } else if (streq(def->def_name, type)) {
594 return (0);
595 }
596 }
597 }
598 return (1);
599}