Deleted Added
full compact
rpc_hout.c (149695) rpc_hout.c (149709)
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 *

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

30#if 0
31#ifndef lint
32#ident "@(#)rpc_hout.c 1.16 94/04/25 SMI"
33static char sccsid[] = "@(#)rpc_hout.c 1.12 89/02/22 (C) 1987 SMI";
34#endif
35#endif
36
37#include <sys/cdefs.h>
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 *

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

30#if 0
31#ifndef lint
32#ident "@(#)rpc_hout.c 1.16 94/04/25 SMI"
33static char sccsid[] = "@(#)rpc_hout.c 1.12 89/02/22 (C) 1987 SMI";
34#endif
35#endif
36
37#include <sys/cdefs.h>
38__FBSDID("$FreeBSD: head/usr.bin/rpcgen/rpc_hout.c 149695 2005-09-01 19:16:25Z stefanf $");
38__FBSDID("$FreeBSD: head/usr.bin/rpcgen/rpc_hout.c 149709 2005-09-02 10:23:26Z stefanf $");
39
40/*
41 * rpc_hout.c, Header file outputter for the RPC protocol compiler
42 * Copyright (C) 1987, Sun Microsystems, Inc.
43 */
44#include <stdio.h>
45#include <ctype.h>
46#include "rpc_parse.h"

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

53static void puniondef( definition * );
54static void pprogramdef( definition *, int );
55static void pstructdef( definition * );
56static void penumdef( definition * );
57static void ptypedef( definition * );
58static void pdefine( char *, char * );
59static int undefined2( char *, char * );
60static void parglist( proc_list *, char * );
39
40/*
41 * rpc_hout.c, Header file outputter for the RPC protocol compiler
42 * Copyright (C) 1987, Sun Microsystems, Inc.
43 */
44#include <stdio.h>
45#include <ctype.h>
46#include "rpc_parse.h"

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

53static void puniondef( definition * );
54static void pprogramdef( definition *, int );
55static void pstructdef( definition * );
56static void penumdef( definition * );
57static void ptypedef( definition * );
58static void pdefine( char *, char * );
59static int undefined2( char *, char * );
60static void parglist( proc_list *, char * );
61static void pprocdef( proc_list *, version_list *, char *, int, int );
61static void pprocdef( proc_list *, version_list *, char *, int );
62void pdeclaration( char *, declaration *, int, char * );
63
64/*
65 * Print the C-version of an xdr definition
66 */
67void
68print_datadef(definition *def, int headeronly)
69{

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

139 xdrfunc_tail->next = xdrptr;
140 xdrfunc_tail = xdrptr;
141 }
142
143
144}
145
146void
62void pdeclaration( char *, declaration *, int, char * );
63
64/*
65 * Print the C-version of an xdr definition
66 */
67void
68print_datadef(definition *def, int headeronly)
69{

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

139 xdrfunc_tail->next = xdrptr;
140 xdrfunc_tail = xdrptr;
141 }
142
143
144}
145
146void
147print_xdr_func_def(name, pointerp, i)
148char* name;
149int pointerp;
150int i;
147print_xdr_func_def(char *name, int pointerp)
151{
148{
152 if (i == 2) {
153 f_print(fout, "extern bool_t xdr_%s();\n", name);
154 return;
155 }
156 else
157 f_print(fout, "extern bool_t xdr_%s(XDR *, %s%s);\n", name,
158 name, pointerp ? "*" : "");
159
160
149 f_print(fout, "extern bool_t xdr_%s(XDR *, %s%s);\n", name,
150 name, pointerp ? "*" : "");
161}
162
163
164static void
165pconstdef(def)
166 definition *def;
167{
168 pdefine(def->def_name, def->def.co);

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

282 }
283 }
284 }
285 abort();
286 /* NOTREACHED */
287}
288
289static void
151}
152
153
154static void
155pconstdef(def)
156 definition *def;
157{
158 pdefine(def->def_name, def->def.co);

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

272 }
273 }
274 }
275 abort();
276 /* NOTREACHED */
277}
278
279static void
290pfreeprocdef(char * name, char *vers, int mode)
280pfreeprocdef(char * name, char *vers)
291{
292 f_print(fout, "extern int ");
293 pvname(name, vers);
281{
282 f_print(fout, "extern int ");
283 pvname(name, vers);
294 if (mode == 1)
295 f_print(fout,"_freeresult(SVCXPRT *, xdrproc_t, caddr_t);\n");
296 else
297 f_print(fout,"_freeresult();\n");
298
299
284 f_print(fout, "_freeresult(SVCXPRT *, xdrproc_t, caddr_t);\n");
300}
301
302static void
285}
286
287static void
303pdispatch(char * name, char *vers, int mode)
288pdispatch(char * name, char *vers)
304{
305
306 f_print(fout, "void ");
307 pvname(name, vers);
289{
290
291 f_print(fout, "void ");
292 pvname(name, vers);
308 if (mode == 1)
309 f_print(fout,
310 "(struct svc_req *rqstp, register SVCXPRT *transp);\n");
311 else
312 f_print(fout,"();\n");
313
293 f_print(fout, "(struct svc_req *rqstp, register SVCXPRT *transp);\n");
314}
315
316static void
317pprogramdef(definition *def, int headeronly)
318{
319 version_list *vers;
320 proc_list *proc;
294}
295
296static void
297pprogramdef(definition *def, int headeronly)
298{
299 version_list *vers;
300 proc_list *proc;
321 int i;
322 char *ext;
323
324 pargdef(def);
325
326 puldefine(def->def_name, def->def.pr.prog_num);
327 for (vers = def->def.pr.versions; vers != NULL; vers = vers->next) {
328 if (tblflag) {
329 f_print(fout,
330 "extern struct rpcgen_table %s_%s_table[];\n",
331 locase(def->def_name), vers->vers_num);
332 f_print(fout,
333 "extern %s_%s_nproc;\n",
334 locase(def->def_name), vers->vers_num);
335 }
336 puldefine(vers->vers_name, vers->vers_num);
337
301 char *ext;
302
303 pargdef(def);
304
305 puldefine(def->def_name, def->def.pr.prog_num);
306 for (vers = def->def.pr.versions; vers != NULL; vers = vers->next) {
307 if (tblflag) {
308 f_print(fout,
309 "extern struct rpcgen_table %s_%s_table[];\n",
310 locase(def->def_name), vers->vers_num);
311 f_print(fout,
312 "extern %s_%s_nproc;\n",
313 locase(def->def_name), vers->vers_num);
314 }
315 puldefine(vers->vers_name, vers->vers_num);
316
338 /*
339 * Print out 2 definitions, one for ANSI-C, another for
340 * old K & R C
341 */
342
343 if(!Cflag){
344 ext = "extern ";
345 if (headeronly) {
346 f_print(fout, "%s", ext);
347 pdispatch(def->def_name, vers->vers_num, 2);
317 f_print(fout, "\n");
318 ext = "extern ";
319 if (headeronly) {
320 f_print(fout, "%s", ext);
321 pdispatch(def->def_name, vers->vers_num);
322 }
323 for (proc = vers->procs; proc != NULL; proc = proc->next) {
324 if (!define_printed(proc, def->def.pr.versions)) {
325 puldefine(proc->proc_name, proc->proc_num);
348 }
326 }
349 for (proc = vers->procs; proc != NULL;
350 proc = proc->next) {
351 if (!define_printed(proc,
352 def->def.pr.versions)) {
353 puldefine(proc->proc_name,
354 proc->proc_num);
355 }
356 f_print(fout, "%s", ext);
357 pprocdef(proc, vers, NULL, 0, 2);
358
359 if (mtflag) {
360 f_print(fout, "%s", ext);
361 pprocdef(proc, vers, NULL, 1, 2);
362 }
363 }
364 pfreeprocdef(def->def_name, vers->vers_num, 2);
365
366 } else {
367 for (i = 1; i < 3; i++){
368 if (i == 1){
369 f_print(fout, "\n#if defined(__STDC__) || defined(__cplusplus)\n");
370 ext = "extern ";
371 }else{
372 f_print(fout, "\n#else /* K&R C */\n");
373 ext = "extern ";
374 }
375
376 if (headeronly) {
377 f_print(fout, "%s", ext);
378 pdispatch(def->def_name, vers->vers_num,
379 i);
380 }
381 for (proc = vers->procs; proc != NULL;
382 proc = proc->next) {
383 if (!define_printed(proc,
384 def->def.pr.versions)) {
385 puldefine(proc->proc_name,
386 proc->proc_num);
387 }
388 f_print(fout, "%s", ext);
389 pprocdef(proc, vers, "CLIENT *", 0, i);
390 f_print(fout, "%s", ext);
391 pprocdef(proc, vers, "struct svc_req *", 1, i);
392 }
393 pfreeprocdef(def->def_name, vers->vers_num, i);
394 }
395 f_print(fout, "#endif /* K&R C */\n");
327 f_print(fout, "%s", ext);
328 pprocdef(proc, vers, "CLIENT *", 0);
329 f_print(fout, "%s", ext);
330 pprocdef(proc, vers, "struct svc_req *", 1);
396 }
331 }
332 pfreeprocdef(def->def_name, vers->vers_num);
397 }
398}
399
400static void
333 }
334}
335
336static void
401pprocdef(proc, vp, addargtype, server_p, mode)
402 proc_list *proc;
403 version_list *vp;
404 char* addargtype;
405 int server_p;
406 int mode;
337pprocdef(proc_list *proc, version_list *vp, char *addargtype, int server_p)
407{
408 if (mtflag) {/* Print MT style stubs */
409 if (server_p)
410 f_print(fout, "bool_t ");
411 else
412 f_print(fout, "enum clnt_stat ");
413 } else {
414 ptype(proc->res_prefix, proc->res_type, 1);
415 f_print(fout, "* ");
416 }
417 if (server_p)
418 pvname_svc(proc->proc_name, vp->vers_num);
419 else
420 pvname(proc->proc_name, vp->vers_num);
421
338{
339 if (mtflag) {/* Print MT style stubs */
340 if (server_p)
341 f_print(fout, "bool_t ");
342 else
343 f_print(fout, "enum clnt_stat ");
344 } else {
345 ptype(proc->res_prefix, proc->res_type, 1);
346 f_print(fout, "* ");
347 }
348 if (server_p)
349 pvname_svc(proc->proc_name, vp->vers_num);
350 else
351 pvname(proc->proc_name, vp->vers_num);
352
422 /*
423 * mode 1 = ANSI-C, mode 2 = K&R C
424 */
425 if ( mode == 1)
426 parglist(proc, addargtype);
427 else
428 f_print(fout, "();\n");
353 parglist(proc, addargtype);
429}
430
431
432
433/* print out argument list of procedure */
434static void
435parglist(proc, addargtype)
436 proc_list *proc;

--- 186 unchanged lines hidden ---
354}
355
356
357
358/* print out argument list of procedure */
359static void
360parglist(proc, addargtype)
361 proc_list *proc;

--- 186 unchanged lines hidden ---