Module Name: src
Committed By: christos
Date: Sun Dec 15 00:40:17 UTC 2013
Modified Files:
src/usr.bin/rpcgen: rpc_clntout.c rpc_cout.c rpc_hout.c rpc_main.c
rpc_parse.c rpc_sample.c rpc_scan.c rpc_svcout.c rpc_tblout.c
rpc_util.c rpc_util.h rpcgen.1
Log Message:
- remove support for pre-ansi output
- add -B (BSD) support for c++ output macros
- group functions to make output better looking
To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/rpcgen/rpc_clntout.c
cvs rdiff -u -r1.32 -r1.33 src/usr.bin/rpcgen/rpc_cout.c
cvs rdiff -u -r1.21 -r1.22 src/usr.bin/rpcgen/rpc_hout.c
cvs rdiff -u -r1.37 -r1.38 src/usr.bin/rpcgen/rpc_main.c
cvs rdiff -u -r1.17 -r1.18 src/usr.bin/rpcgen/rpc_parse.c
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/rpcgen/rpc_sample.c \
src/usr.bin/rpcgen/rpc_scan.c src/usr.bin/rpcgen/rpc_util.c
cvs rdiff -u -r1.24 -r1.25 src/usr.bin/rpcgen/rpc_svcout.c
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/rpcgen/rpc_tblout.c
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/rpcgen/rpc_util.h
cvs rdiff -u -r1.22 -r1.23 src/usr.bin/rpcgen/rpcgen.1
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/rpcgen/rpc_clntout.c
diff -u src/usr.bin/rpcgen/rpc_clntout.c:1.14 src/usr.bin/rpcgen/rpc_clntout.c:1.15
--- src/usr.bin/rpcgen/rpc_clntout.c:1.14 Sun Aug 11 04:03:10 2013
+++ src/usr.bin/rpcgen/rpc_clntout.c Sat Dec 14 19:40:17 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: rpc_clntout.c,v 1.14 2013/08/11 08:03:10 dholland Exp $ */
+/* $NetBSD: rpc_clntout.c,v 1.15 2013/12/15 00:40:17 christos Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
* unrestricted use provided that this legend is included on all tape
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)rpc_clntout.c 1.11 89/02/22 (C) 1987 SMI";
#else
-__RCSID("$NetBSD: rpc_clntout.c,v 1.14 2013/08/11 08:03:10 dholland Exp $");
+__RCSID("$NetBSD: rpc_clntout.c,v 1.15 2013/12/15 00:40:17 christos Exp $");
#endif
#endif
@@ -53,10 +53,10 @@ __RCSID("$NetBSD: rpc_clntout.c,v 1.14 2
#include "rpc_parse.h"
#include "rpc_util.h"
-static void write_program __P((definition *));
-static const char *ampr __P((const char *));
-static const char *aster __P((const char *));
-static void printbody __P((proc_list *));
+static void write_program(definition *);
+static const char *ampr(const char *);
+static const char *aster(const char *);
+static void printbody(proc_list *);
#define DEFAULT_TIMEOUT 25 /* in seconds */
static char RESULT[] = "clnt_res";
@@ -119,84 +119,36 @@ printarglist(proc_list *proc, const char
if (!newstyle) { /* old style: always pass argument by
* reference */
- if (Cflag) { /* C++ style heading */
- f_print(fout, "(");
- ptype(proc->args.decls->decl.prefix, proc->args.decls->decl.type, 1);
- f_print(fout, "*argp, ");
- if (Mflag) {
- if (streq(proc->res_type, "void"))
- f_print(fout, "char ");
- else
- ptype(proc->res_prefix, proc->res_type, 0);
- f_print(fout, "%s%s, ", aster(proc->res_type),
- result);
- }
- f_print(fout, "%s%s)\n", addargtype, addargname);
- } else {
- f_print(fout, "(argp, ");
- if (Mflag)
- f_print(fout, "%s, ", result);
- f_print(fout, "%s)\n", addargname);
- f_print(fout, "\t");
- ptype(proc->args.decls->decl.prefix, proc->args.decls->decl.type, 1);
- f_print(fout, "*argp;\n");
- if (Mflag) {
- f_print(fout, "\t");
- if (streq(proc->res_type, "void"))
- f_print(fout, "char ");
- else
- ptype(proc->res_prefix, proc->res_type, 0);
- f_print(fout, "%s%s;\n", aster(proc->res_type),
- result);
- }
+ f_print(fout, "(");
+ ptype(proc->args.decls->decl.prefix, proc->args.decls->decl.type, 1);
+ f_print(fout, "*argp, ");
+ if (Mflag) {
+ if (streq(proc->res_type, "void"))
+ f_print(fout, "char ");
+ else
+ ptype(proc->res_prefix, proc->res_type, 0);
+ f_print(fout, "%s%s, ", aster(proc->res_type),
+ result);
}
+ f_print(fout, "%s%s)\n", addargtype, addargname);
} else {
f_print(fout, "(");
if (!streq(proc->args.decls->decl.type, "void")) {
/* new style, 1 or multiple arguments */
- if (!Cflag) {
- for (l = proc->args.decls; l != NULL;
- l = l->next)
- f_print(fout, "%s, ", l->decl.name);
- } else {/* C++ style header */
- for (l = proc->args.decls; l != NULL;
- l = l->next)
- pdeclaration(proc->args.argname,
- &l->decl, 0, ", ");
- }
+ for (l = proc->args.decls; l != NULL; l = l->next)
+ pdeclaration(proc->args.argname,
+ &l->decl, 0, ", ");
}
- if (!Cflag) {
- if (Mflag) {
- f_print(fout, "\t");
- if (streq(proc->res_type, "void"))
- f_print(fout, "char ");
- else
- ptype(proc->res_prefix, proc->res_type, 0);
- f_print(fout, "%s%s;\n", aster(proc->res_type),
- result);
- }
- f_print(fout, "%s)\n", addargname);
- if (!streq(proc->args.decls->decl.type, "void")) {
- for (l = proc->args.decls; l != NULL;
- l = l->next)
- pdeclaration(proc->args.argname,
- &l->decl, 1, ";\n");
- }
- } else {
- if (Mflag) {
- if (streq(proc->res_type, "void"))
- f_print(fout, "char ");
- else
- ptype(proc->res_prefix, proc->res_type, 0);
- f_print(fout, "%s%s, ", aster(proc->res_type),
- result);
- }
- f_print(fout, "%s%s)\n", addargtype, addargname);
+ if (Mflag) {
+ if (streq(proc->res_type, "void"))
+ f_print(fout, "char ");
+ else
+ ptype(proc->res_prefix, proc->res_type, 0);
+ f_print(fout, "%s%s, ", aster(proc->res_type),
+ result);
}
+ f_print(fout, "%s%s)\n", addargtype, addargname);
}
-
- if (!Cflag)
- f_print(fout, "\t%s%s;\n", addargtype, addargname);
}
Index: src/usr.bin/rpcgen/rpc_cout.c
diff -u src/usr.bin/rpcgen/rpc_cout.c:1.32 src/usr.bin/rpcgen/rpc_cout.c:1.33
--- src/usr.bin/rpcgen/rpc_cout.c:1.32 Mon Aug 12 16:36:30 2013
+++ src/usr.bin/rpcgen/rpc_cout.c Sat Dec 14 19:40:17 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: rpc_cout.c,v 1.32 2013/08/12 20:36:30 christos Exp $ */
+/* $NetBSD: rpc_cout.c,v 1.33 2013/12/15 00:40:17 christos Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
* unrestricted use provided that this legend is included on all tape
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)rpc_cout.c 1.13 89/02/22 (C) 1987 SMI";
#else
-__RCSID("$NetBSD: rpc_cout.c,v 1.32 2013/08/12 20:36:30 christos Exp $");
+__RCSID("$NetBSD: rpc_cout.c,v 1.33 2013/12/15 00:40:17 christos Exp $");
#endif
#endif
@@ -54,24 +54,24 @@ __RCSID("$NetBSD: rpc_cout.c,v 1.32 2013
#include "rpc_parse.h"
#include "rpc_util.h"
-static int findtype __P((definition *, const char *));
-static int undefined __P((const char *));
-static void print_generic_header __P((const char *, int));
-static void print_header __P((definition *));
-static void print_prog_header __P((proc_list *));
-static void print_trailer __P((void));
-static void print_ifopen __P((int, const char *));
-static void print_ifarg __P((const char *));
-static void print_ifsizeof __P((const char *, const char *));
-static void print_ifclose __P((int));
-static void print_ifstat __P((int, const char *, const char *, relation,
- const char *, const char *, const char *));
-static void emit_enum __P((definition *));
-static void emit_program __P((definition *));
-static void emit_union __P((definition *));
-static void emit_struct __P((definition *));
-static void emit_typedef __P((definition *));
-static void print_stat __P((int, declaration *));
+static int findtype(definition *, const char *);
+static int undefined(const char *);
+static void print_generic_header(const char *, int);
+static void print_header(definition *);
+static void print_prog_header(proc_list *);
+static void print_trailer(void);
+static void print_ifopen(int, const char *);
+static void print_ifarg(const char *);
+static void print_ifsizeof(const char *, const char *);
+static void print_ifclose(int);
+static void print_ifstat(int, const char *, const char *, relation,
+ const char *, const char *, const char *);
+static void emit_enum(definition *);
+static void emit_program(definition *);
+static void emit_union(definition *);
+static void emit_struct(definition *);
+static void emit_typedef(definition *);
+static void print_stat(int, declaration *);
/*
* Emit the C-routine for the given definition
@@ -146,21 +146,12 @@ print_generic_header(const char *procnam
{
f_print(fout, "\n");
f_print(fout, "bool_t\n");
- if (Cflag) {
- f_print(fout, "xdr_%s(", procname);
- f_print(fout, "XDR *xdrs, ");
- f_print(fout, "%s ", procname);
- if (pointerp)
- f_print(fout, "*");
- f_print(fout, "objp)\n{\n");
- } else {
- f_print(fout, "xdr_%s(xdrs, objp)\n", procname);
- f_print(fout, "\tXDR *xdrs;\n");
- f_print(fout, "\t%s ", procname);
- if (pointerp)
- f_print(fout, "*");
- f_print(fout, "objp;\n{\n");
- }
+ f_print(fout, "xdr_%s(", procname);
+ f_print(fout, "XDR *xdrs, ");
+ f_print(fout, "%s ", procname);
+ if (pointerp)
+ f_print(fout, "*");
+ f_print(fout, "objp)\n{\n");
}
static void
Index: src/usr.bin/rpcgen/rpc_hout.c
diff -u src/usr.bin/rpcgen/rpc_hout.c:1.21 src/usr.bin/rpcgen/rpc_hout.c:1.22
--- src/usr.bin/rpcgen/rpc_hout.c:1.21 Sun Aug 11 04:03:10 2013
+++ src/usr.bin/rpcgen/rpc_hout.c Sat Dec 14 19:40:17 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: rpc_hout.c,v 1.21 2013/08/11 08:03:10 dholland Exp $ */
+/* $NetBSD: rpc_hout.c,v 1.22 2013/12/15 00:40:17 christos Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
* unrestricted use provided that this legend is included on all tape
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)rpc_hout.c 1.12 89/02/22 (C) 1987 SMI";
#else
-__RCSID("$NetBSD: rpc_hout.c,v 1.21 2013/08/11 08:03:10 dholland Exp $");
+__RCSID("$NetBSD: rpc_hout.c,v 1.22 2013/12/15 00:40:17 christos Exp $");
#endif
#endif
@@ -52,17 +52,19 @@ __RCSID("$NetBSD: rpc_hout.c,v 1.21 2013
#include "rpc_parse.h"
#include "rpc_util.h"
-static void pconstdef __P((definition *));
-static void pargdef __P((definition *));
-static void pstructdef __P((definition *));
-static void puniondef __P((definition *));
-static void pdefine __P((const char *, const char *));
-static void puldefine __P((const char *, const char *));
-static int define_printed __P((proc_list *, version_list *));
-static void pprogramdef __P((definition *));
-static void penumdef __P((definition *));
-static void ptypedef __P((definition *));
-static int undefined2 __P((const char *, const char *));
+static void pconstdef(definition *);
+static void pargdef(definition *);
+static void pstructdef(definition *);
+static void puniondef(definition *);
+static void pdefine(const char *, const char *);
+static void puldefine(const char *, const char *);
+static int define_printed(proc_list *, version_list *);
+static void pprogramdef(definition *);
+static void penumdef(definition *);
+static void ptypedef(definition *);
+static int undefined2(const char *, const char *);
+static void cplusplusstart(void);
+static void cplusplusend(void);
/*
* Print the C-version of an xdr definition
@@ -97,17 +99,10 @@ print_datadef(definition *def)
pconstdef(def);
break;
}
- if (def->def_kind != DEF_PROGRAM && def->def_kind != DEF_CONST) {
- pxdrfuncdecl(def->def_name,
- def->def_kind != DEF_TYPEDEF ||
- !isvectordef(def->def.ty.old_type, def->def.ty.rel));
-
- }
}
-
void
-print_funcdef(definition *def)
+print_progdef(definition *def)
{
switch (def->def_kind) {
case DEF_PROGRAM:
@@ -124,20 +119,41 @@ print_funcdef(definition *def)
}
void
+print_funcdef(definition *def, int *did)
+{
+ switch (def->def_kind) {
+ case DEF_PROGRAM:
+ case DEF_CONST:
+ break;
+ case DEF_TYPEDEF:
+ case DEF_ENUM:
+ case DEF_UNION:
+ case DEF_STRUCT:
+ if (!*did) {
+ f_print(fout, "\n");
+ cplusplusstart();
+ *did = 1;
+ }
+ pxdrfuncdecl(def->def_name,
+ def->def_kind != DEF_TYPEDEF ||
+ !isvectordef(def->def.ty.old_type, def->def.ty.rel));
+ break;
+ }
+}
+
+void
+print_funcend(int did) {
+ if (did) {
+ cplusplusend();
+ }
+}
+
+void
pxdrfuncdecl(const char *name, int pointerp)
{
- f_print(fout, "#ifdef __cplusplus\n");
- f_print(fout, "extern \"C\" bool_t xdr_%s(XDR *, %s%s);\n",
- name,
- name, pointerp ? (" *") : "");
- f_print(fout, "#elif __STDC__\n");
- f_print(fout, "extern bool_t xdr_%s(XDR *, %s%s);\n",
- name,
+ f_print(fout, "bool_t xdr_%s(XDR *, %s%s);\n", name,
name, pointerp ? (" *") : "");
- f_print(fout, "#else /* Old Style C */\n");
- f_print(fout, "bool_t xdr_%s();\n", name);
- f_print(fout, "#endif /* Old Style C */\n\n");
}
@@ -157,12 +173,11 @@ pargdef(definition *def)
version_list *vers;
char *name;
proc_list *plist;
+ int did;
for (vers = def->def.pr.versions; vers != NULL; vers = vers->next) {
- for (plist = vers->procs; plist != NULL;
- plist = plist->next) {
-
+ for (plist = vers->procs; plist != NULL; plist = plist->next) {
if (!newstyle || plist->arg_num < 2) {
continue; /* old style or single args */
}
@@ -174,10 +189,24 @@ pargdef(definition *def)
}
f_print(fout, "};\n");
f_print(fout, "typedef struct %s %s;\n", name, name);
- pxdrfuncdecl(name, 1);
- f_print(fout, "\n");
}
}
+ did = 0;
+ for (vers = def->def.pr.versions; vers != NULL; vers = vers->next) {
+ if (!newstyle || plist->arg_num < 2) {
+ continue; /* old style or single args */
+ }
+ for (plist = vers->procs; plist != NULL; plist = plist->next) {
+ if (!did) {
+ cplusplusstart();
+ did = 1;
+ }
+ pxdrfuncdecl(plist->args.argname, 1);
+ }
+ }
+ if (did) {
+ cplusplusend();
+ }
}
@@ -258,12 +287,28 @@ define_printed(proc_list *stop, version_
}
static void
+cplusplusstart(void)
+{
+ if (BSDflag)
+ f_print(fout, "__BEGIN_DECLS\n");
+ else
+ f_print(fout, "#ifdef __cplusplus\nextern \"C\" {\n#endif\n");
+}
+
+static void
+cplusplusend(void)
+{
+ if (BSDflag)
+ f_print(fout, "__END_DECLS\n");
+ else
+ f_print(fout, "#ifdef __cplusplus\n};\n#endif\n");
+}
+
+static void
pprogramdef(definition *def)
{
version_list *vers;
proc_list *proc;
- int i;
- const char *ext;
pargdef(def);
@@ -276,43 +321,31 @@ pprogramdef(definition *def)
locase(def->def_name), vers->vers_num);
}
puldefine(vers->vers_name, vers->vers_num);
-
- /* Print out 3 definitions, one for ANSI-C, another for C++, a
- * third for old style C */
-
- for (i = 0; i < 3; i++) {
- if (i == 0) {
- f_print(fout, "\n#ifdef __cplusplus\n");
- ext = "extern \"C\" ";
- } else
- if (i == 1) {
- f_print(fout, "\n#elif __STDC__\n");
- ext = "extern ";
- } else {
- f_print(fout, "\n#else /* Old Style C */\n");
- ext = "extern ";
- }
-
-
- for (proc = vers->procs; proc != NULL; proc = proc->next) {
- if (!define_printed(proc, def->def.pr.versions)) {
- puldefine(proc->proc_name, proc->proc_num);
- }
- f_print(fout, "%s", ext);
- pprocdef(proc, vers, "CLIENT *", 0, i);
- f_print(fout, "%s", ext);
- pprocdef(proc, vers, "struct svc_req *", 1, i);
-
+ for (proc = vers->procs; proc != NULL; proc = proc->next) {
+ if (!define_printed(proc, def->def.pr.versions)) {
+ puldefine(proc->proc_name, proc->proc_num);
}
+ }
+ }
+ /*
+ * Print out 3 definitions, one for ANSI-C, another for C++, a
+ * third for old style C
+ */
+ f_print(fout, "\n");
+ cplusplusstart();
+ for (vers = def->def.pr.versions; vers != NULL; vers = vers->next) {
+ for (proc = vers->procs; proc != NULL; proc = proc->next) {
+ pprocdef(proc, vers, "CLIENT *", 0);
+ pprocdef(proc, vers, "struct svc_req *", 1);
}
- f_print(fout, "#endif /* Old Style C */\n");
}
+ cplusplusend();
}
void
pprocdef(proc_list *proc, version_list *vp, const char *addargtype,
- int server_p, int mode)
+ int server_p)
{
decl_list *dl;
@@ -330,35 +363,28 @@ pprocdef(proc_list *proc, version_list *
else
pvname(proc->proc_name, vp->vers_num);
- /*
- * mode 0 == cplusplus, mode 1 = ANSI-C, mode 2 = old style C
- */
- if (mode == 0 || mode == 1) {
- f_print(fout, "(");
- if (proc->arg_num < 2 && newstyle &&
- streq(proc->args.decls->decl.type, "void")) {
- /* 0 argument in new style: do nothing */
- } else {
- for (dl = proc->args.decls; dl != NULL; dl = dl->next) {
- ptype(dl->decl.prefix, dl->decl.type, 1);
- if (!newstyle)
- f_print(fout, "*");
- f_print(fout, ", ");
- }
- }
- if (Mflag) {
- if (streq(proc->res_type, "void"))
- f_print(fout, "char");
- else
- ptype(proc->res_prefix, proc->res_type, 0);
- if (!isvectordef(proc->res_type, REL_ALIAS))
+ f_print(fout, "(");
+ if (proc->arg_num < 2 && newstyle &&
+ streq(proc->args.decls->decl.type, "void")) {
+ /* 0 argument in new style: do nothing */
+ } else {
+ for (dl = proc->args.decls; dl != NULL; dl = dl->next) {
+ ptype(dl->decl.prefix, dl->decl.type, 1);
+ if (!newstyle)
f_print(fout, "*");
f_print(fout, ", ");
}
- f_print(fout, "%s);\n", addargtype);
}
- else
- f_print(fout, "();\n");
+ if (Mflag) {
+ if (streq(proc->res_type, "void"))
+ f_print(fout, "char");
+ else
+ ptype(proc->res_prefix, proc->res_type, 0);
+ if (!isvectordef(proc->res_type, REL_ALIAS))
+ f_print(fout, "*");
+ f_print(fout, ", ");
+ }
+ f_print(fout, "%s);\n", addargtype);
}
Index: src/usr.bin/rpcgen/rpc_main.c
diff -u src/usr.bin/rpcgen/rpc_main.c:1.37 src/usr.bin/rpcgen/rpc_main.c:1.38
--- src/usr.bin/rpcgen/rpc_main.c:1.37 Mon Aug 12 10:03:18 2013
+++ src/usr.bin/rpcgen/rpc_main.c Sat Dec 14 19:40:17 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: rpc_main.c,v 1.37 2013/08/12 14:03:18 joerg Exp $ */
+/* $NetBSD: rpc_main.c,v 1.38 2013/12/15 00:40:17 christos Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@@ -39,7 +39,7 @@
#if 0
static char sccsid[] = "@(#)rpc_main.c 1.30 89/03/30 (C) 1987 SMI";
#else
-__RCSID("$NetBSD: rpc_main.c,v 1.37 2013/08/12 14:03:18 joerg Exp $");
+__RCSID("$NetBSD: rpc_main.c,v 1.38 2013/12/15 00:40:17 christos Exp $");
#endif
#endif
@@ -126,6 +126,7 @@ int inetdflag /* = 1 */ ; /* Support
int pmflag; /* Support for port monitors */
int logflag; /* Use syslog instead of fprintf for errors */
int tblflag; /* Support for dispatch table file */
+int BSDflag; /* use BSD cplusplus macros */
int callerflag; /* Generate svc_caller() function */
#define INLINE 3
@@ -140,7 +141,6 @@ int exitnow; /* If started by port
* call */
int timerflag; /* TRUE if !indefinite && !exitnow */
int newstyle; /* newstyle of passing arguments (by value) */
-int Cflag = 0; /* ANSI C syntax */
int Mflag = 0; /* multithread safe */
static int allfiles; /* generate all files */
int tirpcflag = 1; /* generating code for tirpc, by default */
@@ -149,28 +149,27 @@ int tirpcflag = 1; /* generating co
static char *dos_cppfile = NULL;
#endif
-int main __P((int, char *[]));
-
-static char *extendfile __P((const char *, const char *));
-static void open_output __P((const char *, const char *));
-static void add_warning __P((void));
-static void clear_args __P((void));
-static void open_input __P((const char *, const char *));
-static int check_nettype __P((const char *, const char *[]));
-static void c_output __P((const char *, const char *, int, const char *));
-static void c_initialize __P((void));
-static char *generate_guard __P((const char *));
-static void h_output __P((const char *, const char *, int, const char *));
-static void s_output __P((int, char *[], char *, const char *, int, const char *, int, int));
-static void l_output __P((const char *, const char *, int, const char *));
-static void t_output __P((const char *, const char *, int, const char *));
-static void svc_output __P((const char *, const char *, int, const char *));
-static void clnt_output __P((const char *, const char *, int, const char *));
-static int do_registers __P((int, char *[]));
-static void addarg __P((const char *));
-static void putarg __P((int, const char *));
-static void checkfiles __P((const char *, const char *));
-static int parseargs __P((int, char *[], struct commandline *));
+static char *extendfile(const char *, const char *);
+static void open_output(const char *, const char *);
+static void add_warning(void);
+static void clear_args(void);
+static void open_input(const char *, const char *);
+static int check_nettype(const char *, const char *[]);
+static void c_output(const char *, const char *, int, const char *);
+static void c_initialize(void);
+static char *generate_guard(const char *);
+static void h_output(const char *, const char *, int, const char *);
+static void s_output(int, char *[], char *, const char *, int, const char *,
+ int, int);
+static void l_output(const char *, const char *, int, const char *);
+static void t_output(const char *, const char *, int, const char *);
+static void svc_output(const char *, const char *, int, const char *);
+static void clnt_output(const char *, const char *, int, const char *);
+static int do_registers(int, char *[]);
+static void addarg(const char *);
+static void putarg(int, const char *);
+static void checkfiles(const char *, const char *);
+static int parseargs(int, char *[], struct commandline *);
static void usage(void) __dead;
static void options_usage(void) __dead;
@@ -533,6 +532,7 @@ h_output(const char *infile, const char
long tell;
char *guard;
list *l;
+ int did;
open_input(infile, define);
outfilename = extend ? extendfile(infile, outfile) : outfile;
@@ -561,9 +561,16 @@ h_output(const char *infile, const char
/* print function declarations. Do this after data definitions
* because they might be used as arguments for functions */
+ did = 0;
for (l = defined; l != NULL; l = l->next) {
- print_funcdef(l->val);
+ print_funcdef(l->val, &did);
}
+ print_funcend(did);
+
+ for (l = defined; l != NULL; l = l->next) {
+ print_progdef(l->val);
+ }
+
if (extend && tell == ftell(fout)) {
(void) unlink(outfilename);
} else
@@ -602,12 +609,9 @@ s_output(int argc, char *argv[], char *i
f_print(fout, "#include <fcntl.h>\n");
f_print(fout, "#include <stdio.h>\n");
f_print(fout, "#include <stdlib.h>\n");
- if (Cflag) {
- f_print(fout, "#include <unistd.h>\n");
- f_print(fout,
- "#include <rpc/pmap_clnt.h>\n");
- f_print(fout, "#include <string.h>\n");
- }
+ f_print(fout, "#include <unistd.h>\n");
+ f_print(fout, "#include <rpc/pmap_clnt.h>\n");
+ f_print(fout, "#include <string.h>\n");
f_print(fout, "#include <netdb.h>\n");
if (strcmp(svcclosetime, "-1") == 0)
indefinitewait = 1;
@@ -621,7 +625,7 @@ s_output(int argc, char *argv[], char *i
}
if (!tirpcflag && inetdflag)
f_print(fout, "#include <sys/ttycom.h>\n");
- if (Cflag && (inetdflag || pmflag)) {
+ if (inetdflag || pmflag) {
f_print(fout, "#ifdef __cplusplus\n");
f_print(fout, "#include <sysent.h>\n");
f_print(fout, "#endif /* __cplusplus */\n");
@@ -643,8 +647,7 @@ s_output(int argc, char *argv[], char *i
if (logflag || inetdflag || pmflag)
f_print(fout, "#include <syslog.h>\n");
- /* for ANSI-C */
- f_print(fout, "\n#ifdef __STDC__\n#define SIG_PF void(*)(int)\n#endif\n");
+ f_print(fout, "\n#define SIG_PF void(*)(int)\n");
f_print(fout, "\n#ifdef DEBUG\n#define RPC_SVC_FG\n#endif\n");
if (timerflag)
@@ -684,8 +687,7 @@ l_output(const char *infile, const char
outfilename = extend ? extendfile(infile, outfile) : outfile;
open_output(infile, outfilename);
add_warning();
- if (Cflag)
- f_print(fout, "#include <memory.h>\n");
+ f_print(fout, "#include <memory.h>\n");
if (infile && (include = extendfile(infile, ".h"))) {
f_print(fout, "#include \"%s\"\n", include);
free(include);
@@ -777,8 +779,7 @@ clnt_output(const char *infile, const ch
open_output(infile, outfilename);
add_sample_msg();
- if (Cflag)
- f_print(fout, "#include <stdio.h>\n");
+ f_print(fout, "#include <stdio.h>\n");
if (infile && (include = extendfile(infile, ".h"))) {
f_print(fout, "#include \"%s\"\n", include);
free(include);
@@ -930,6 +931,9 @@ parseargs(int argc, char *argv[], struct
case 'a':
allfiles = 1;
break;
+ case 'B':
+ BSDflag = 1;
+ break;
case 'c':
case 'h':
case 'l':
@@ -957,8 +961,7 @@ parseargs(int argc, char *argv[], struct
}
flag[c] = 1;
break;
- case 'C': /* ANSI C syntax */
- Cflag = 1;
+ case 'C': /* deprecated ANSI C syntax */
break;
case 'b': /* turn TIRPC flag off for
@@ -1117,7 +1120,6 @@ options_usage(void)
f_print(stderr, "-a\t\tgenerate all files, including samples\n");
f_print(stderr, "-b\t\tbackward compatibility mode (generates code for SunOS 4.1)\n");
f_print(stderr, "-c\t\tgenerate XDR routines\n");
- f_print(stderr, "-C\t\tANSI C mode\n");
f_print(stderr, "-Dname[=value]\tdefine a symbol (same as #define)\n");
f_print(stderr, "-h\t\tgenerate header file\n");
f_print(stderr, "-i size\t\tsize at which to start generating inline code\n");
Index: src/usr.bin/rpcgen/rpc_parse.c
diff -u src/usr.bin/rpcgen/rpc_parse.c:1.17 src/usr.bin/rpcgen/rpc_parse.c:1.18
--- src/usr.bin/rpcgen/rpc_parse.c:1.17 Sun Aug 11 04:03:10 2013
+++ src/usr.bin/rpcgen/rpc_parse.c Sat Dec 14 19:40:17 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: rpc_parse.c,v 1.17 2013/08/11 08:03:10 dholland Exp $ */
+/* $NetBSD: rpc_parse.c,v 1.18 2013/12/15 00:40:17 christos Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
* unrestricted use provided that this legend is included on all tape
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)rpc_parse.c 1.8 89/02/22 (C) 1987 SMI";
#else
-__RCSID("$NetBSD: rpc_parse.c,v 1.17 2013/08/11 08:03:10 dholland Exp $");
+__RCSID("$NetBSD: rpc_parse.c,v 1.18 2013/12/15 00:40:17 christos Exp $");
#endif
#endif
@@ -56,18 +56,18 @@ __RCSID("$NetBSD: rpc_parse.c,v 1.17 201
#define ARGNAME "arg"
-static void isdefined __P((definition *));
-static void def_struct __P((definition *));
-static void def_program __P((definition *));
-static void def_enum __P((definition *));
-static void def_const __P((definition *));
-static void def_union __P((definition *));
-static void check_type_name __P((const char *, int));
-static void def_typedef __P((definition *));
-static void get_declaration __P((declaration *, defkind));
-static void get_prog_declaration __P((declaration *, defkind, int));
-static void get_type __P((const char **, const char **, defkind));
-static void unsigned_dec __P((const char **));
+static void isdefined(definition *);
+static void def_struct(definition *);
+static void def_program(definition *);
+static void def_enum(definition *);
+static void def_const(definition *);
+static void def_union(definition *);
+static void check_type_name(const char *, int);
+static void def_typedef(definition *);
+static void get_declaration(declaration *, defkind);
+static void get_prog_declaration(declaration *, defkind, int);
+static void get_type(const char **, const char **, defkind);
+static void unsigned_dec(const char **);
/*
* return the next definition you see
Index: src/usr.bin/rpcgen/rpc_sample.c
diff -u src/usr.bin/rpcgen/rpc_sample.c:1.12 src/usr.bin/rpcgen/rpc_sample.c:1.13
--- src/usr.bin/rpcgen/rpc_sample.c:1.12 Sun Aug 11 04:03:10 2013
+++ src/usr.bin/rpcgen/rpc_sample.c Sat Dec 14 19:40:17 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: rpc_sample.c,v 1.12 2013/08/11 08:03:10 dholland Exp $ */
+/* $NetBSD: rpc_sample.c,v 1.13 2013/12/15 00:40:17 christos Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
* unrestricted use provided that this legend is included on all tape
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)rpc_sample.c 1.1 90/08/30 (C) 1987 SMI";
#else
-__RCSID("$NetBSD: rpc_sample.c,v 1.12 2013/08/11 08:03:10 dholland Exp $");
+__RCSID("$NetBSD: rpc_sample.c,v 1.13 2013/12/15 00:40:17 christos Exp $");
#endif
#endif
@@ -54,9 +54,9 @@ __RCSID("$NetBSD: rpc_sample.c,v 1.12 20
static char RQSTP[] = "rqstp";
-static void write_sample_client __P((const char *, version_list *));
-static void write_sample_server __P((definition *));
-static void return_type __P((proc_list *));
+static void write_sample_client(const char *, version_list *);
+static void write_sample_server(definition *);
+static void return_type(proc_list *);
void
write_sample_svc(definition *def)
@@ -93,10 +93,7 @@ write_sample_client(const char *program_
f_print(fout, "\n\nvoid\n");
pvname(program_name, vp->vers_num);
- if (Cflag)
- f_print(fout, "(char *host)\n{\n");
- else
- f_print(fout, "(host)\n\tchar *host;\n{\n");
+ f_print(fout, "(char *host)\n{\n");
f_print(fout, "\tCLIENT *clnt;\n");
for (proc = vp->procs; proc != NULL; proc = proc->next) {
@@ -255,11 +252,7 @@ write_sample_clnt_main(void)
version_list *vp;
f_print(fout, "\n\n");
- if (Cflag)
- f_print(fout, "int\nmain(int argc, char *argv[])\n{\n");
- else
- f_print(fout, "int\nmain(argc, argv)\n\tint argc;\n\tchar *argv[];\n{\n");
-
+ f_print(fout, "int\nmain(int argc, char *argv[])\n{\n");
f_print(fout, "\tchar *host;");
f_print(fout, "\n\n\tif (argc < 2) {");
f_print(fout, "\n\t\tprintf(\"usage: %%s server_host\\n\", argv[0]);\n");
Index: src/usr.bin/rpcgen/rpc_scan.c
diff -u src/usr.bin/rpcgen/rpc_scan.c:1.12 src/usr.bin/rpcgen/rpc_scan.c:1.13
--- src/usr.bin/rpcgen/rpc_scan.c:1.12 Sun Aug 11 04:03:10 2013
+++ src/usr.bin/rpcgen/rpc_scan.c Sat Dec 14 19:40:17 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: rpc_scan.c,v 1.12 2013/08/11 08:03:10 dholland Exp $ */
+/* $NetBSD: rpc_scan.c,v 1.13 2013/12/15 00:40:17 christos Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
* unrestricted use provided that this legend is included on all tape
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)rpc_scan.c 1.11 89/02/22 (C) 1987 SMI";
#else
-__RCSID("$NetBSD: rpc_scan.c,v 1.12 2013/08/11 08:03:10 dholland Exp $");
+__RCSID("$NetBSD: rpc_scan.c,v 1.13 2013/12/15 00:40:17 christos Exp $");
#endif
#endif
@@ -57,15 +57,15 @@ __RCSID("$NetBSD: rpc_scan.c,v 1.12 2013
#define startcomment(where) (where[0] == '/' && where[1] == '*')
#define endcomment(where) (where[-1] == '*' && where[0] == '/')
-static void unget_token __P((token *));
-static void findstrconst __P((char **, const char **));
-static void findchrconst __P((char **, const char **));
-static void findconst __P((char **, const char **));
-static void findkind __P((char **, token *));
-static int cppline __P((const char *));
-static int directive __P((const char *));
-static void printdirective __P((const char *));
-static void docppline __P((char *, int *, const char **));
+static void unget_token(token *);
+static void findstrconst(char **, const char **);
+static void findchrconst(char **, const char **);
+static void findconst(char **, const char **);
+static void findkind(char **, token *);
+static int cppline(const char *);
+static int directive(const char *);
+static void printdirective(const char *);
+static void docppline(char *, int *, const char **);
static int pushed = 0; /* is a token pushed */
static token lasttok; /* last token, if pushed */
Index: src/usr.bin/rpcgen/rpc_util.c
diff -u src/usr.bin/rpcgen/rpc_util.c:1.12 src/usr.bin/rpcgen/rpc_util.c:1.13
--- src/usr.bin/rpcgen/rpc_util.c:1.12 Sun Aug 11 04:03:10 2013
+++ src/usr.bin/rpcgen/rpc_util.c Sat Dec 14 19:40:17 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: rpc_util.c,v 1.12 2013/08/11 08:03:10 dholland Exp $ */
+/* $NetBSD: rpc_util.c,v 1.13 2013/12/15 00:40:17 christos Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
* unrestricted use provided that this legend is included on all tape
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)rpc_util.c 1.11 89/02/22 (C) 1987 SMI";
#else
-__RCSID("$NetBSD: rpc_util.c,v 1.12 2013/08/11 08:03:10 dholland Exp $");
+__RCSID("$NetBSD: rpc_util.c,v 1.13 2013/12/15 00:40:17 christos Exp $");
#endif
#endif
@@ -56,7 +56,7 @@ __RCSID("$NetBSD: rpc_util.c,v 1.12 2013
#define ARGEXT "argument"
-static void printwhere __P((void));
+static void printwhere(void);
char curline[MAXLINESIZE]; /* current read line */
char *where = curline; /* current point in line */
@@ -73,12 +73,12 @@ FILE *fin; /* file pointer of curren
list *defined; /* list of defined things */
-static const char *toktostr __P((tok_kind));
-static void printbuf __P((void));
-static void printwhere __P((void));
-static int findit __P((definition *, const char *));
-static const char *fixit __P((const char *, const char *));
-static int typedefed __P((definition *, const char *));
+static const char *toktostr(tok_kind);
+static void printbuf(void);
+static void printwhere(void);
+static int findit(definition *, const char *);
+static const char *fixit(const char *, const char *);
+static int typedefed(definition *, const char *);
/*
* Reinitialize the world
Index: src/usr.bin/rpcgen/rpc_svcout.c
diff -u src/usr.bin/rpcgen/rpc_svcout.c:1.24 src/usr.bin/rpcgen/rpc_svcout.c:1.25
--- src/usr.bin/rpcgen/rpc_svcout.c:1.24 Sun Aug 11 04:03:10 2013
+++ src/usr.bin/rpcgen/rpc_svcout.c Sat Dec 14 19:40:17 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: rpc_svcout.c,v 1.24 2013/08/11 08:03:10 dholland Exp $ */
+/* $NetBSD: rpc_svcout.c,v 1.25 2013/12/15 00:40:17 christos Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
* unrestricted use provided that this legend is included on all tape
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)rpc_svcout.c 1.29 89/03/30 (C) 1987 SMI";
#else
-__RCSID("$NetBSD: rpc_svcout.c,v 1.24 2013/08/11 08:03:10 dholland Exp $");
+__RCSID("$NetBSD: rpc_svcout.c,v 1.25 2013/12/15 00:40:17 christos Exp $");
#endif
#endif
@@ -57,33 +57,30 @@ static char ARG[] = "argument";
static char RESULT[] = "result";
static char ROUTINE[] = "local";
-static void p_xdrfunc __P((const char *, const char *));
-static void internal_proctype __P((proc_list *));
-static void write_real_program __P((definition *));
-static void write_program __P((definition *, const char *));
-static void printerr __P((const char *, const char *));
-static void printif __P((const char *, const char *, const char *, const char *));
-static void write_inetmost __P((char *));
-static void print_return __P((const char *));
-static void print_pmapunset __P((const char *));
-static void print_err_message __P((const char *));
-static void write_timeout_func __P((void));
-static void write_caller_func __P((void));
-static void write_pm_most __P((char *, int));
-static void write_rpc_svc_fg __P((char *, const char *));
-static void open_log_file __P((char *, const char *));
-static const char *aster __P((const char *));
+static void p_xdrfunc(const char *, const char *);
+static void internal_proctype(proc_list *);
+static void write_real_program(definition *);
+static void write_program(definition *, const char *);
+static void printerr(const char *, const char *);
+static void printif(const char *, const char *, const char *, const char *);
+static void write_inetmost(char *);
+static void print_return(const char *);
+static void print_pmapunset(const char *);
+static void print_err_message(const char *);
+static void write_timeout_func(void);
+static void write_caller_func(void);
+static void write_pm_most(char *, int);
+static void write_rpc_svc_fg(char *, const char *);
+static void open_log_file(char *, const char *);
+static const char *aster(const char *);
char _errbuf[256]; /* For all messages */
static void
p_xdrfunc(const char *rname, const char *typename)
{
- if (Cflag)
- f_print(fout, "\t\txdr_%s = (xdrproc_t)xdr_%s;\n", rname,
- stringfix(typename));
- else
- f_print(fout, "\t\txdr_%s = xdr_%s;\n", rname, stringfix(typename));
+ f_print(fout, "\t\txdr_%s = (xdrproc_t)xdr_%s;\n", rname,
+ stringfix(typename));
}
static void
@@ -121,14 +118,8 @@ write_most(char *infile /* our name */,
if (nomain)
return;
- f_print(fout, "\n\n");
- if (Cflag)
- f_print(fout, "int main(int argc, char *argv[]);\n");
f_print(fout, "\nint\n");
- if (Cflag)
- f_print(fout, "main(int argc, char *argv[])\n");
- else
- f_print(fout, "main(argc, argv)\nint argc;\nchar *argv[];\n");
+ f_print(fout, "main(int argc, char *argv[])\n");
f_print(fout, "{\n");
if (inetdflag) {
write_inetmost(infile); /* Includes call to write_rpc_svc_fg() */
@@ -253,8 +244,7 @@ write_rest(void)
if (timerflag) {
f_print(fout, "\tif (_rpcpmstart) {\n");
f_print(fout,
- "\t\t(void) signal(SIGALRM, %s closedown);\n",
- Cflag ? "(SIG_PF)" : "(void(*)())");
+ "\t\t(void) signal(SIGALRM, (SIG_PF)closedown);\n");
f_print(fout, "\t\t(void) alarm(_RPCSVC_CLOSEDOWN);\n");
f_print(fout, "\t}\n");
}
@@ -310,52 +300,25 @@ write_real_program(definition *def)
internal_proctype(proc);
f_print(fout, "\n_");
pvname(proc->proc_name, vp->vers_num);
- if (Cflag) {
- f_print(fout, "(");
- /* arg name */
- if (proc->arg_num > 1)
- f_print(fout, "%s ",
- proc->args.argname);
- else
- ptype(proc->args.decls->decl.prefix,
- proc->args.decls->decl.type, 0);
- f_print(fout, "*argp, ");
- if (Mflag) {
- if (streq(proc->res_type, "void"))
- f_print(fout, "char ");
- else
- ptype(proc->res_prefix,
- proc->res_type, 0);
- f_print(fout, "%sresult, ",
- aster(proc->res_type));
- }
- f_print(fout, "struct svc_req *%s)\n", RQSTP);
- } else {
- f_print(fout, "(argp, ");
- if (Mflag)
- f_print(fout, "result, ");
- f_print(fout, "%s)\n", RQSTP);
- f_print(fout, "\t");
- if (proc->arg_num > 1)
- f_print(fout, "%s ",
- proc->args.argname);
+ f_print(fout, "(");
+ /* arg name */
+ if (proc->arg_num > 1)
+ f_print(fout, "%s ",
+ proc->args.argname);
+ else
+ ptype(proc->args.decls->decl.prefix,
+ proc->args.decls->decl.type, 0);
+ f_print(fout, "*argp, ");
+ if (Mflag) {
+ if (streq(proc->res_type, "void"))
+ f_print(fout, "char ");
else
- ptype(proc->args.decls->decl.prefix,
- proc->args.decls->decl.type, 0);
- f_print(fout, "*argp;\n");
- if (Mflag) {
- f_print(fout, "\t");
- if (streq(proc->res_type, "void"))
- f_print(fout, "char ");
- else
- ptype(proc->res_prefix,
- proc->res_type, 0);
- f_print(fout, "%sresult;\n",
- aster(proc->res_type));
- }
- f_print(fout, "\tstruct svc_req *%s;\n", RQSTP);
+ ptype(proc->res_prefix,
+ proc->res_type, 0);
+ f_print(fout, "%sresult, ",
+ aster(proc->res_type));
}
-
+ f_print(fout, "struct svc_req *%s)\n", RQSTP);
f_print(fout, "{\n");
f_print(fout, "\treturn (");
pvname_svc(proc->proc_name, vp->vers_num);
@@ -380,16 +343,14 @@ write_program(definition *def, const cha
int filled;
for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
- if (Cflag) {
- f_print(fout, "\n");
- if (storage != NULL) {
- f_print(fout, "%s ", storage);
- }
- f_print(fout, "void ");
- pvname(def->def_name, vp->vers_num);
- f_print(fout, "(struct svc_req *%s, ", RQSTP);
- f_print(fout, "SVCXPRT *%s);\n", TRANSP);
+ f_print(fout, "\n");
+ if (storage != NULL) {
+ f_print(fout, "%s ", storage);
}
+ f_print(fout, "void ");
+ pvname(def->def_name, vp->vers_num);
+ f_print(fout, "(struct svc_req *%s, ", RQSTP);
+ f_print(fout, "SVCXPRT *%s);\n", TRANSP);
f_print(fout, "\n");
if (storage != NULL) {
f_print(fout, "%s ", storage);
@@ -397,15 +358,8 @@ write_program(definition *def, const cha
f_print(fout, "void\n");
pvname(def->def_name, vp->vers_num);
- if (Cflag) {
- f_print(fout, "(struct svc_req *%s, ", RQSTP);
- f_print(fout, "SVCXPRT *%s)\n", TRANSP);
- } else {
- f_print(fout, "(%s, %s)\n", RQSTP, TRANSP);
- f_print(fout, " struct svc_req *%s;\n", RQSTP);
- f_print(fout, " SVCXPRT *%s;\n", TRANSP);
- }
-
+ f_print(fout, "(struct svc_req *%s, ", RQSTP);
+ f_print(fout, "SVCXPRT *%s)\n", TRANSP);
f_print(fout, "{\n");
filled = 0;
@@ -452,23 +406,15 @@ write_program(definition *def, const cha
} else
f_print(fout, "\tchar *%s;\n", RESULT);
- if (Cflag) {
- f_print(fout, "\txdrproc_t xdr_%s, xdr_%s;\n", ARG, RESULT);
- if (Mflag)
- f_print(fout,
- "\tbool_t (*%s)(char *, void *, struct svc_req *);\n",
- ROUTINE);
- else
- f_print(fout,
- "\tchar *(*%s)(char *, struct svc_req *);\n",
- ROUTINE);
- } else {
- f_print(fout, "\tbool_t (*xdr_%s)(), (*xdr_%s)();\n", ARG, RESULT);
- if (Mflag)
- f_print(fout, "\tbool_t (*%s)();\n", ROUTINE);
- else
- f_print(fout, "\tchar *(*%s)();\n", ROUTINE);
- }
+ f_print(fout, "\txdrproc_t xdr_%s, xdr_%s;\n", ARG, RESULT);
+ if (Mflag)
+ f_print(fout,
+ "\tbool_t (*%s)(char *, void *, struct svc_req *);\n",
+ ROUTINE);
+ else
+ f_print(fout,
+ "\tchar *(*%s)(char *, struct svc_req *);\n",
+ ROUTINE);
f_print(fout, "\n");
@@ -479,14 +425,8 @@ write_program(definition *def, const cha
f_print(fout, "\tswitch (%s->rq_proc) {\n", RQSTP);
if (!nullproc(vp->procs)) {
f_print(fout, "\tcase NULLPROC:\n");
- if (Cflag) {
- f_print(fout,
- "\t\t(void) svc_sendreply(%s, (xdrproc_t)xdr_void, NULL);\n", TRANSP);
- } else {
- f_print(fout,
- "\t\t(void) svc_sendreply(%s, xdr_void, NULL);\n",
- TRANSP);
- }
+ f_print(fout,
+ "\t\t(void) svc_sendreply(%s, (xdrproc_t)xdr_void, NULL);\n", TRANSP);
print_return("\t\t");
f_print(fout, "\n");
}
@@ -498,28 +438,18 @@ write_program(definition *def, const cha
p_xdrfunc(ARG, proc->args.argname);
}
p_xdrfunc(RESULT, proc->res_type);
- if (Cflag) {
- if (Mflag)
- f_print(fout,
- "\t\t%s = (bool_t (*)(char *, void *, struct svc_req *))",
- ROUTINE);
- else
- f_print(fout,
- "\t\t%s = (char *(*)(char *, struct svc_req *))",
- ROUTINE);
- } else {
- if (Mflag)
- f_print(fout, "\t\t%s = (bool_t (*)())", ROUTINE);
- else
- f_print(fout, "\t\t%s = (char *(*)())", ROUTINE);
- }
+ if (Mflag)
+ f_print(fout,
+ "\t\t%s = (bool_t (*)(char *, void *, struct svc_req *))",
+ ROUTINE);
+ else
+ f_print(fout,
+ "\t\t%s = (char *(*)(char *, struct svc_req *))",
+ ROUTINE);
if (newstyle) /* new style: calls internal routine */
f_print(fout, "_");
- if (Cflag)
- pvname_svc(proc->proc_name, vp->vers_num);
- else
- pvname(proc->proc_name, vp->vers_num);
+ pvname_svc(proc->proc_name, vp->vers_num);
f_print(fout, ";\n");
f_print(fout, "\t\tbreak;\n\n");
}
@@ -534,21 +464,12 @@ write_program(definition *def, const cha
print_return("\t\t");
f_print(fout, "\t}\n");
- if (Cflag) {
- if (Mflag)
- f_print(fout, "\tretval = (*%s)((char *)&%s, (void *)&%s, %s);\n",
- ROUTINE, ARG, RESULT, RQSTP);
- else
- f_print(fout, "\t%s = (*%s)((char *)&%s, %s);\n",
- RESULT, ROUTINE, ARG, RQSTP);
- } else {
- if (Mflag)
- f_print(fout, "\tretval = (*%s)(&%s, &%s, %s);\n",
- ROUTINE, ARG, RESULT, RQSTP);
- else
- f_print(fout, "\t%s = (*%s)(&%s, %s);\n",
- RESULT, ROUTINE, ARG, RQSTP);
- }
+ if (Mflag)
+ f_print(fout, "\tretval = (*%s)((char *)&%s, (void *)&%s, %s);\n",
+ ROUTINE, ARG, RESULT, RQSTP);
+ else
+ f_print(fout, "\t%s = (*%s)((char *)&%s, %s);\n",
+ RESULT, ROUTINE, ARG, RQSTP);
if (Mflag)
f_print(fout,
"\tif (retval > 0 && !svc_sendreply(%s, xdr_%s, (char *)&%s)) {\n",
@@ -698,12 +619,7 @@ write_msg_out(void)
{
f_print(fout, "\n");
f_print(fout, "static\n");
- if (!Cflag) {
- f_print(fout, "void _msgout(msg)\n");
- f_print(fout, "\tchar *msg;\n");
- } else {
- f_print(fout, "void _msgout(const char *msg)\n");
- }
+ f_print(fout, "void _msgout(const char *msg)\n");
f_print(fout, "{\n");
f_print(fout, "#ifdef RPC_SVC_FG\n");
if (inetdflag || pmflag)
@@ -724,10 +640,8 @@ write_timeout_func(void)
{
if (!timerflag)
return;
- if (Cflag) {
- f_print(fout, "\n");
- f_print(fout, "static void closedown(void);\n");
- }
+ f_print(fout, "\n");
+ f_print(fout, "static void closedown(void);\n");
f_print(fout, "\n");
f_print(fout, "static void\n");
f_print(fout, "closedown()\n");
@@ -872,8 +786,7 @@ write_pm_most(char *infile, int netflag)
}
if (timerflag) {
f_print(fout, "\t\tif (pmclose) {\n");
- f_print(fout, "\t\t\t(void) signal(SIGALRM, %s closedown);\n",
- Cflag ? "(SIG_PF)" : "(void(*)())");
+ f_print(fout, "\t\t\t(void) signal(SIGALRM, (SIGPF)closedown);\n");
f_print(fout, "\t\t\t(void) alarm(_RPCSVC_CLOSEDOWN);\n");
f_print(fout, "\t\t}\n");
}
Index: src/usr.bin/rpcgen/rpc_tblout.c
diff -u src/usr.bin/rpcgen/rpc_tblout.c:1.13 src/usr.bin/rpcgen/rpc_tblout.c:1.14
--- src/usr.bin/rpcgen/rpc_tblout.c:1.13 Sun Aug 11 04:03:10 2013
+++ src/usr.bin/rpcgen/rpc_tblout.c Sat Dec 14 19:40:17 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: rpc_tblout.c,v 1.13 2013/08/11 08:03:10 dholland Exp $ */
+/* $NetBSD: rpc_tblout.c,v 1.14 2013/12/15 00:40:17 christos Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
* unrestricted use provided that this legend is included on all tape
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)rpc_tblout.c 1.4 89/02/22 (C) 1988 SMI";
#else
-__RCSID("$NetBSD: rpc_tblout.c,v 1.13 2013/08/11 08:03:10 dholland Exp $");
+__RCSID("$NetBSD: rpc_tblout.c,v 1.14 2013/12/15 00:40:17 christos Exp $");
#endif
#endif
@@ -68,8 +68,8 @@ static const char null_entry[] = "\t(cha
static const char tbl_nproc[] =
"u_int %s_nproc =\n\t(u_int)(sizeof(%s_table)/sizeof(%s_table[0]));\n\n";
-static void write_table __P((definition *));
-static void printit __P((const char *, const char *));
+static void write_table(definition *);
+static void printit(const char *, const char *);
void
write_tables(void)
Index: src/usr.bin/rpcgen/rpc_util.h
diff -u src/usr.bin/rpcgen/rpc_util.h:1.7 src/usr.bin/rpcgen/rpc_util.h:1.8
--- src/usr.bin/rpcgen/rpc_util.h:1.7 Mon Aug 12 10:03:18 2013
+++ src/usr.bin/rpcgen/rpc_util.h Sat Dec 14 19:40:17 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: rpc_util.h,v 1.7 2013/08/12 14:03:18 joerg Exp $ */
+/* $NetBSD: rpc_util.h,v 1.8 2013/12/15 00:40:17 christos Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
* unrestricted use provided that this legend is included on all tape
@@ -74,9 +74,9 @@ extern bas_type *typ_list_t;
extern int inetdflag;
extern int pmflag;
extern int tblflag;
+extern int BSDflag;
extern int logflag;
extern int newstyle;
-extern int Cflag; /* C++ flag */
extern int Mflag; /* multithread flag */
extern int tirpcflag; /* flag for generating tirpc code */
extern int doinline; /* if this is 0, then do not generate inline code */
@@ -101,75 +101,77 @@ extern int nonfatalerrors;
#define FINDVAL(list,item,finder) \
findval(list, item, finder)
-void reinitialize __P((void));
-int streq __P((const char *, const char *));
-definition *findval __P((list *, const char *,
- int (*)(definition *, const char *)));
-void storeval __P((list **, definition *));
-const char *fixtype __P((const char *));
-const char *stringfix __P((const char *));
-void ptype __P((const char *, const char *, int));
-int isvectordef __P((const char *, relation));
-char *locase __P((const char *));
-void pvname_svc __P((const char *, const char *));
-void pvname __P((const char *, const char *));
+void reinitialize(void);
+int streq(const char *, const char *);
+definition *findval(list *, const char *,
+ int (*)(definition *, const char *));
+void storeval(list **, definition *);
+const char *fixtype(const char *);
+const char *stringfix(const char *);
+void ptype(const char *, const char *, int);
+int isvectordef(const char *, relation);
+char *locase(const char *);
+void pvname_svc(const char *, const char *);
+void pvname(const char *, const char *);
void error(const char *) __dead;
void crash(void) __dead;
-void record_open __P((const char *));
+void record_open(const char *);
void expected1(tok_kind) __dead;
void expected2(tok_kind, tok_kind) __dead;
void expected3(tok_kind, tok_kind, tok_kind) __dead;
-void tabify __P((FILE *, int));
-char *make_argname __P((const char *, const char *));
-void add_type __P((int, const char *));
-bas_type *find_type __P((const char *));
+void tabify(FILE *, int);
+char *make_argname(const char *, const char *);
+void add_type(int, const char *);
+bas_type *find_type(const char *);
/*
* rpc_cout routines
*/
-void emit __P((definition *));
-void emit_inline __P((declaration *, int));
-void emit_single_in_line __P((declaration *, int, relation));
-char *upcase __P((const char *));
+void emit(definition *);
+void emit_inline(declaration *, int);
+void emit_single_in_line(declaration *, int, relation);
+char *upcase(const char *);
/*
* rpc_hout routines
*/
-void print_datadef __P((definition *));
-void print_funcdef __P((definition *));
-void pxdrfuncdecl __P((const char *, int));
-void pprocdef __P((proc_list *, version_list *, const char *, int, int));
-void pdeclaration __P((const char *, declaration *, int, const char *));
+void print_datadef(definition *);
+void print_progdef(definition *);
+void print_funcdef(definition *, int *);
+void print_funcend(int);
+void pxdrfuncdecl(const char *, int);
+void pprocdef(proc_list *, version_list *, const char *, int);
+void pdeclaration(const char *, declaration *, int, const char *);
/*
* rpc_svcout routines
*/
-void write_most __P((char *, int, int));
-void write_netid_register __P((const char *));
-void write_nettype_register __P((const char *));
-void write_rest __P((void));
-void write_programs __P((const char *));
-int nullproc __P((proc_list *));
-void write_svc_aux __P((int));
-void write_msg_out __P((void));
-void write_inetd_register __P((const char *));
+void write_most(char *, int, int);
+void write_netid_register(const char *);
+void write_nettype_register(const char *);
+void write_rest(void);
+void write_programs(const char *);
+int nullproc(proc_list *);
+void write_svc_aux(int);
+void write_msg_out(void);
+void write_inetd_register(const char *);
/*
* rpc_clntout routines
*/
-void write_stubs __P((void));
-void printarglist __P((proc_list *, const char *, const char *, const char *));
+void write_stubs(void);
+void printarglist(proc_list *, const char *, const char *, const char *);
/*
* rpc_tblout routines
*/
-void write_tables __P((void));
+void write_tables(void);
/*
* rpc_sample routines
*/
-void write_sample_svc __P((definition *));
-int write_sample_clnt __P((definition *));
-void add_sample_msg __P((void));
-void write_sample_clnt_main __P((void));
+void write_sample_svc(definition *);
+int write_sample_clnt(definition *);
+void add_sample_msg(void);
+void write_sample_clnt_main(void);
Index: src/usr.bin/rpcgen/rpcgen.1
diff -u src/usr.bin/rpcgen/rpcgen.1:1.22 src/usr.bin/rpcgen/rpcgen.1:1.23
--- src/usr.bin/rpcgen/rpcgen.1:1.22 Wed Mar 11 09:57:53 2009
+++ src/usr.bin/rpcgen/rpcgen.1 Sat Dec 14 19:40:17 2013
@@ -1,7 +1,7 @@
-.\" $NetBSD: rpcgen.1,v 1.22 2009/03/11 13:57:53 joerg Exp $
+.\" $NetBSD: rpcgen.1,v 1.23 2013/12/15 00:40:17 christos Exp $
.\" from: @(#)rpcgen.new.1 1.1 90/11/09 TIRPC 1.0; from 40.10 of 10/10/89
.\" Copyright (c) 1988,1990 Sun Microsystems, Inc. - All Rights Reserved.
-.Dd January 19, 2008
+.Dd December 14, 2013
.Dt RPCGEN 1
.Os
.Sh NAME
@@ -13,8 +13,8 @@
.Nm
.Op Fl A
.Op Fl a
+.Op Fl B
.Op Fl b
-.Op Fl C
.Op Fl D Ar name Op =value
.Op Fl I
.Op Fl i Ar size
@@ -234,6 +234,8 @@ Generate all the files including sample
Generate an
.Fn svc_caller
function.
+.It Fl B
+Generate BSD cplusplus macros (__BEGIN_DECLS, __END_DECLS).
.It Fl b
Compile stubs in "backwards compatible" mode, disabling support for
transport-independent RPC.
@@ -247,12 +249,6 @@ since there is no transport-independent
Compile into
.Tn XDR
routines.
-.It Fl C
-Generate code in
-.Tn ANSI
-C.
-This option also generates code that could be compiled with the
-C++ compiler.
.It Fl D Ar name Ns Op Ar =value
Define a symbol
.Dv name .