summaryrefslogtreecommitdiffstats
path: root/usr.bin/rpcgen
diff options
context:
space:
mode:
authorstefanf <stefanf@FreeBSD.org>2005-09-01 19:16:25 +0000
committerstefanf <stefanf@FreeBSD.org>2005-09-01 19:16:25 +0000
commitcd3615cae726ef8f1ea81f8af4d25a8ff2fa6ab7 (patch)
tree811d253fa6dd9c7130a1eb6b03d8f45fd9ce7485 /usr.bin/rpcgen
parent1d9944c7c9dd7c2690c4a21182e65394409b2015 (diff)
downloadFreeBSD-src-cd3615cae726ef8f1ea81f8af4d25a8ff2fa6ab7.zip
FreeBSD-src-cd3615cae726ef8f1ea81f8af4d25a8ff2fa6ab7.tar.gz
Only write the dispatch table function prototypes to the header if the -h
flag was specified. If all files are generated at once, those functions are static and shouldn't appear in the header. PR: 84450 Reviewed by: alfred
Diffstat (limited to 'usr.bin/rpcgen')
-rw-r--r--usr.bin/rpcgen/rpc_hout.c28
-rw-r--r--usr.bin/rpcgen/rpc_main.c17
-rw-r--r--usr.bin/rpcgen/rpc_util.h4
3 files changed, 24 insertions, 25 deletions
diff --git a/usr.bin/rpcgen/rpc_hout.c b/usr.bin/rpcgen/rpc_hout.c
index c4f089e..eb4e4bf 100644
--- a/usr.bin/rpcgen/rpc_hout.c
+++ b/usr.bin/rpcgen/rpc_hout.c
@@ -51,7 +51,7 @@ void storexdrfuncdecl( char *, int );
static void pconstdef( definition * );
static void pstructdef( definition * );
static void puniondef( definition * );
-static void pprogramdef( definition * );
+static void pprogramdef( definition *, int );
static void pstructdef( definition * );
static void penumdef( definition * );
static void ptypedef( definition * );
@@ -65,8 +65,7 @@ void pdeclaration( char *, declaration *, int, char * );
* Print the C-version of an xdr definition
*/
void
-print_datadef(def)
- definition *def;
+print_datadef(definition *def, int headeronly)
{
if (def->def_kind == DEF_PROGRAM) /* handle data only */
@@ -89,7 +88,7 @@ print_datadef(def)
ptypedef(def);
break;
case DEF_PROGRAM:
- pprogramdef(def);
+ pprogramdef(def, headeronly);
break;
case DEF_CONST:
pconstdef(def);
@@ -105,13 +104,12 @@ print_datadef(def)
void
-print_funcdef(def)
- definition *def;
+print_funcdef(definition *def, int headeronly)
{
switch (def->def_kind) {
case DEF_PROGRAM:
f_print(fout, "\n");
- pprogramdef(def);
+ pprogramdef(def, headeronly);
break;
default:
break;
@@ -316,8 +314,7 @@ pdispatch(char * name, char *vers, int mode)
}
static void
-pprogramdef(def)
- definition *def;
+pprogramdef(definition *def, int headeronly)
{
version_list *vers;
proc_list *proc;
@@ -345,8 +342,10 @@ pprogramdef(def)
if(!Cflag){
ext = "extern ";
- f_print(fout, "%s", ext);
- pdispatch(def->def_name, vers->vers_num, 2);
+ if (headeronly) {
+ f_print(fout, "%s", ext);
+ pdispatch(def->def_name, vers->vers_num, 2);
+ }
for (proc = vers->procs; proc != NULL;
proc = proc->next) {
if (!define_printed(proc,
@@ -374,8 +373,11 @@ pprogramdef(def)
ext = "extern ";
}
- f_print(fout, "%s", ext);
- pdispatch(def->def_name, vers->vers_num, i);
+ if (headeronly) {
+ f_print(fout, "%s", ext);
+ pdispatch(def->def_name, vers->vers_num,
+ i);
+ }
for (proc = vers->procs; proc != NULL;
proc = proc->next) {
if (!define_printed(proc,
diff --git a/usr.bin/rpcgen/rpc_main.c b/usr.bin/rpcgen/rpc_main.c
index f2b30e8..a712ee0 100644
--- a/usr.bin/rpcgen/rpc_main.c
+++ b/usr.bin/rpcgen/rpc_main.c
@@ -61,7 +61,7 @@ extern int write_sample_clnt( definition * );
extern void write_sample_clnt_main( void );
extern void add_sample_msg( void );
static void c_output( char *, char *, int, char * );
-static void h_output( char *, char *, int, char * );
+static void h_output( char *, char *, int, char *, int );
static void l_output( char *, char *, int, char * );
static void t_output( char *, char *, int, char * );
static void clnt_output( char *, char *, int, char * );
@@ -172,7 +172,8 @@ main(argc, argv)
if (cmd.cflag) {
c_output(cmd.infile, "-DRPC_XDR", DONT_EXTEND, cmd.outfile);
} else if (cmd.hflag) {
- h_output(cmd.infile, "-DRPC_HDR", DONT_EXTEND, cmd.outfile);
+ h_output(cmd.infile, "-DRPC_HDR", DONT_EXTEND, cmd.outfile,
+ cmd.hflag);
} else if (cmd.lflag) {
l_output(cmd.infile, "-DRPC_CLNT", DONT_EXTEND, cmd.outfile);
} else if (cmd.sflag || cmd.mflag || (cmd.nflag)) {
@@ -192,7 +193,7 @@ main(argc, argv)
/* the rescans are required, since cpp may effect input */
c_output(cmd.infile, "-DRPC_XDR", EXTEND, "_xdr.c");
reinitialize();
- h_output(cmd.infile, "-DRPC_HDR", EXTEND, ".h");
+ h_output(cmd.infile, "-DRPC_HDR", EXTEND, ".h", cmd.hflag);
reinitialize();
l_output(cmd.infile, "-DRPC_CLNT", EXTEND, "_clnt.c");
reinitialize();
@@ -514,11 +515,7 @@ char *generate_guard(pathname)
static void
-h_output(infile, define, extend, outfile)
- char *infile;
- char *define;
- int extend;
- char *outfile;
+h_output(char *infile, char *define, int extend, char *outfile, int headeronly)
{
definition *def;
char *outfilename;
@@ -558,7 +555,7 @@ h_output(infile, define, extend, outfile)
/* print data definitions */
while ( (def = get_definition()) ) {
- print_datadef(def);
+ print_datadef(def, headeronly);
}
/*
@@ -567,7 +564,7 @@ h_output(infile, define, extend, outfile)
* arguments for functions
*/
for (l = defined; l != NULL; l = l->next) {
- print_funcdef(l->val);
+ print_funcdef(l->val, headeronly);
}
/* Now print all xdr func declarations */
if (xdrfunc_head != NULL){
diff --git a/usr.bin/rpcgen/rpc_util.h b/usr.bin/rpcgen/rpc_util.h
index 3e53a51..f32099e 100644
--- a/usr.bin/rpcgen/rpc_util.h
+++ b/usr.bin/rpcgen/rpc_util.h
@@ -191,8 +191,8 @@ void emit(definition *def);
/*
* rpc_hout routines
*/
-void print_datadef(definition *def);
-void print_funcdef(definition *def);
+void print_datadef(definition *def, int headeronly);
+void print_funcdef(definition *def, int headeronly);
void print_xdr_func_def(char* name, int pointerp, int i);
/*
OpenPOWER on IntegriCloud