summaryrefslogtreecommitdiff
path: root/usr.bin/rpcgen
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/rpcgen')
-rw-r--r--usr.bin/rpcgen/rpc_clntout.c178
-rw-r--r--usr.bin/rpcgen/rpc_cout.c30
-rw-r--r--usr.bin/rpcgen/rpc_hout.c21
-rw-r--r--usr.bin/rpcgen/rpc_main.c112
-rw-r--r--usr.bin/rpcgen/rpc_parse.c319
-rw-r--r--usr.bin/rpcgen/rpc_parse.h12
-rw-r--r--usr.bin/rpcgen/rpc_sample.c158
-rw-r--r--usr.bin/rpcgen/rpc_scan.c52
-rw-r--r--usr.bin/rpcgen/rpc_scan.h3
-rw-r--r--usr.bin/rpcgen/rpc_svcout.c177
-rw-r--r--usr.bin/rpcgen/rpc_tblout.c5
-rw-r--r--usr.bin/rpcgen/rpc_util.c56
-rw-r--r--usr.bin/rpcgen/rpc_util.h5
13 files changed, 582 insertions, 546 deletions
diff --git a/usr.bin/rpcgen/rpc_clntout.c b/usr.bin/rpcgen/rpc_clntout.c
index 2d704c12062..8a8e1d3f5bb 100644
--- a/usr.bin/rpcgen/rpc_clntout.c
+++ b/usr.bin/rpcgen/rpc_clntout.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rpc_clntout.c,v 1.10 2002/06/01 01:40:38 deraadt Exp $ */
+/* $OpenBSD: rpc_clntout.c,v 1.11 2002/07/05 05:39:42 deraadt Exp $ */
/* $NetBSD: rpc_clntout.c,v 1.4 1995/06/11 21:49:52 pk Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@@ -84,7 +84,7 @@ write_program(def)
ptype(proc->res_prefix, proc->res_type, 1);
fprintf(fout, "*\n");
pvname(proc->proc_name, vp->vers_num);
- printarglist( proc, "clnt", "CLIENT *" );
+ printarglist(proc, "clnt", "CLIENT *");
fprintf(fout, "{\n");
printbody(proc);
fprintf(fout, "}\n");
@@ -92,62 +92,60 @@ write_program(def)
}
}
-/* Writes out declarations of procedure's argument list.
- In either ANSI C style, in one of old rpcgen style (pass by reference),
- or new rpcgen style (multiple arguments, pass by value);
- */
+/*
+ * Writes out declarations of procedure's argument list.
+ * In either ANSI C style, in one of old rpcgen style (pass by reference),
+ * or new rpcgen style (multiple arguments, pass by value);
+ */
/* sample addargname = "clnt"; sample addargtype = "CLIENT * " */
-void printarglist( proc, addargname, addargtype )
- proc_list *proc;
- char *addargname, *addargtype;
+void printarglist(proc, addargname, addargtype)
+ proc_list *proc;
+ char *addargname, *addargtype;
{
+ decl_list *l;
+
+ if (!newstyle) { /* old style: always pass argument by reference */
+ if (Cflag) { /* C++ style heading */
+ fprintf(fout, "(");
+ ptype(proc->args.decls->decl.prefix,
+ proc->args.decls->decl.type, 1);
+ fprintf(fout, "*argp, %s%s)\n", addargtype, addargname);
+ } else {
+ fprintf(fout, "(argp, %s)\n", addargname);
+ fprintf(fout, "\t");
+ ptype(proc->args.decls->decl.prefix,
+ proc->args.decls->decl.type, 1);
+ fprintf(fout, "*argp;\n");
+ }
+ } else if (streq(proc->args.decls->decl.type, "void")) {
+ /* newstyle, 0 argument */
+ if (Cflag)
+ fprintf(fout, "(%s%s)\n", addargtype, addargname);
+ else
+ fprintf(fout, "(%s)\n", addargname);
+ } else {
+ /* new style, 1 or multiple arguments */
+ if (!Cflag) {
+ fprintf(fout, "(");
+ for (l = proc->args.decls; l != NULL; l = l->next)
+ fprintf(fout, "%s, ", l->decl.name);
+ fprintf(fout, "%s)\n", addargname);
+ for (l = proc->args.decls; l != NULL; l = l->next)
+ pdeclaration(proc->args.argname, &l->decl, 1, ";\n");
+ } else { /* C++ style header */
+ fprintf(fout, "(");
+ for (l = proc->args.decls; l != NULL; l = l->next)
+ pdeclaration(proc->args.argname, &l->decl, 0, ", ");
+ fprintf(fout, " %s%s)\n", addargtype, addargname);
+ }
+ }
- decl_list *l;
-
- if (!newstyle) { /* old style: always pass argument by reference */
- if (Cflag) { /* C++ style heading */
- fprintf(fout, "(");
- ptype(proc->args.decls->decl.prefix, proc->args.decls->decl.type, 1);
- fprintf(fout, "*argp, %s%s)\n", addargtype, addargname );
- } else {
- fprintf(fout, "(argp, %s)\n", addargname);
- fprintf(fout, "\t");
- ptype(proc->args.decls->decl.prefix, proc->args.decls->decl.type, 1);
- fprintf(fout, "*argp;\n");
- }
- } else if (streq( proc->args.decls->decl.type, "void")) {
- /* newstyle, 0 argument */
- if (Cflag)
- fprintf(fout, "(%s%s)\n", addargtype, addargname );
- else
- fprintf(fout, "(%s)\n", addargname);
- } else {
- /* new style, 1 or multiple arguments */
- if (!Cflag) {
- fprintf(fout, "(");
- for (l = proc->args.decls; l != NULL; l = l->next)
- fprintf(fout, "%s, ", l->decl.name);
- fprintf(fout, "%s)\n", addargname );
- for (l = proc->args.decls; l != NULL; l = l->next) {
- pdeclaration(proc->args.argname, &l->decl, 1, ";\n" );
- }
- } else { /* C++ style header */
- fprintf(fout, "(");
- for(l = proc->args.decls; l != NULL; l = l->next) {
- pdeclaration(proc->args.argname, &l->decl, 0, ", " );
- }
- fprintf(fout, " %s%s)\n", addargtype, addargname );
- }
- }
-
- if (!Cflag)
- fprintf(fout, "\t%s%s;\n", addargtype, addargname );
+ if (!Cflag)
+ fprintf(fout, "\t%s%s;\n", addargtype, addargname);
}
-
-
static char *
ampr(type)
char *type;
@@ -163,12 +161,14 @@ static void
printbody(proc)
proc_list *proc;
{
- decl_list *l;
- bool_t args2 = (proc->arg_num > 1);
-
- /* For new style with multiple arguments, need a structure in which
- to stuff the arguments. */
- if ( newstyle && args2) {
+ decl_list *l;
+ bool_t args2 = (proc->arg_num > 1);
+
+ /*
+ * For new style with multiple arguments, need a structure in which
+ * to stuff the arguments.
+ */
+ if (newstyle && args2) {
fprintf(fout, "\t%s", proc->args.argname);
fprintf(fout, " arg;\n");
}
@@ -180,44 +180,44 @@ printbody(proc)
}
fprintf(fout, "%s;\n",RESULT);
fprintf(fout, "\n");
- fprintf(fout, "\tmemset((char *)%s%s, 0, sizeof(%s));\n",
- ampr(proc->res_type ), RESULT, RESULT);
- if (newstyle && !args2 && (streq( proc->args.decls->decl.type, "void"))) {
- /* newstyle, 0 arguments */
- fprintf(fout,
+ fprintf(fout, "\tmemset((char *)%s%s, 0, sizeof(%s));\n",
+ ampr(proc->res_type), RESULT, RESULT);
+ if (newstyle && !args2 && (streq(proc->args.decls->decl.type, "void"))) {
+ /* newstyle, 0 arguments */
+ fprintf(fout,
"\tif (clnt_call(clnt, %s, xdr_void", proc->proc_name);
- fprintf(fout,
- ", NULL, xdr_%s, %s%s, TIMEOUT) != RPC_SUCCESS) {\n",
- stringfix(proc->res_type), ampr(proc->res_type), RESULT);
-
- } else if ( newstyle && args2) {
- /* newstyle, multiple arguments: stuff arguments into structure */
- for (l = proc->args.decls; l != NULL; l = l->next) {
- fprintf(fout, "\targ.%s = %s;\n",
- l->decl.name, l->decl.name);
- }
- fprintf(fout,
- "\tif (clnt_call(clnt, %s, xdr_%s", proc->proc_name,
- proc->args.argname);
- fprintf(fout,
- ", &arg, xdr_%s, %s%s, TIMEOUT) != RPC_SUCCESS) {\n",
- stringfix(proc->res_type),
- ampr(proc->res_type), RESULT);
+ fprintf(fout,
+ ", NULL, xdr_%s, %s%s, TIMEOUT) != RPC_SUCCESS) {\n",
+ stringfix(proc->res_type), ampr(proc->res_type), RESULT);
+ } else if (newstyle && args2) {
+ /* newstyle, multiple arguments: stuff arguments into structure */
+ for (l = proc->args.decls; l != NULL; l = l->next) {
+ fprintf(fout, "\targ.%s = %s;\n",
+ l->decl.name, l->decl.name);
+ }
+ fprintf(fout,
+ "\tif (clnt_call(clnt, %s, xdr_%s", proc->proc_name,
+ proc->args.argname);
+ fprintf(fout,
+ ", &arg, xdr_%s, %s%s, TIMEOUT) != RPC_SUCCESS) {\n",
+ stringfix(proc->res_type),
+ ampr(proc->res_type), RESULT);
} else { /* single argument, new or old style */
- fprintf(fout,
- "\tif (clnt_call(clnt, %s, xdr_%s, %s%s, xdr_%s, %s%s, TIMEOUT) != RPC_SUCCESS) {\n",
- proc->proc_name,
- stringfix(proc->args.decls->decl.type),
- (newstyle ? "&" : ""),
- (newstyle ? proc->args.decls->decl.name : "argp"),
- stringfix(proc->res_type),
- ampr(proc->res_type),RESULT);
- }
+ fprintf(fout,
+ "\tif (clnt_call(clnt, %s, xdr_%s, %s%s, xdr_%s, "
+ "%s%s, TIMEOUT) != RPC_SUCCESS) {\n",
+ proc->proc_name,
+ stringfix(proc->args.decls->decl.type),
+ (newstyle ? "&" : ""),
+ (newstyle ? proc->args.decls->decl.name : "argp"),
+ stringfix(proc->res_type),
+ ampr(proc->res_type),RESULT);
+ }
fprintf(fout, "\t\treturn (NULL);\n");
fprintf(fout, "\t}\n");
if (streq(proc->res_type, "void")) {
fprintf(fout, "\treturn ((void *)%s%s);\n",
- ampr(proc->res_type),RESULT);
+ ampr(proc->res_type),RESULT);
} else {
fprintf(fout, "\treturn (%s%s);\n", ampr(proc->res_type),RESULT);
}
diff --git a/usr.bin/rpcgen/rpc_cout.c b/usr.bin/rpcgen/rpc_cout.c
index 9b0915ed6a3..6430b78249f 100644
--- a/usr.bin/rpcgen/rpc_cout.c
+++ b/usr.bin/rpcgen/rpc_cout.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rpc_cout.c,v 1.12 2002/06/01 01:40:38 deraadt Exp $ */
+/* $OpenBSD: rpc_cout.c,v 1.13 2002/07/05 05:39:42 deraadt Exp $ */
/* $NetBSD: rpc_cout.c,v 1.6 1996/10/01 04:13:53 cgd Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@@ -356,6 +356,10 @@ emit_union(def)
if (!streq(cs->type, "void")) {
object = alloc(strlen(def->def_name) + strlen(format) +
strlen(cs->name) + 1);
+ if (object == NULL) {
+ fprintf(stderr, "Fatal error : no memory\n");
+ crash();
+ }
if (isvectordef(cs->type, cs->rel)) {
sprintf(object, vecformat, def->def_name,
cs->name);
@@ -375,6 +379,10 @@ emit_union(def)
fprintf(fout, "\tdefault:\n");
object = alloc(strlen(def->def_name) + strlen(format) +
strlen(dflt->name) + 1);
+ if (object == NULL) {
+ fprintf(stderr, "Fatal error : no memory\n");
+ crash();
+ }
if (isvectordef(dflt->type, dflt->rel)) {
sprintf(object, vecformat, def->def_name,
dflt->name);
@@ -487,17 +495,23 @@ emit_struct(def)
dl->decl.array_max);
/* now concatenate to sizestr !!!! */
- if (sizestr == NULL)
+ if (sizestr == NULL) {
sizestr = strdup(ptemp);
- else {
- sizestr = (char *)realloc(sizestr, strlen(sizestr) + strlen(ptemp) + 1);
if (sizestr == NULL) {
- fprintf(stderr, "Fatal error : no memory\n");
+ fprintf(stderr,
+ "Fatal error : no memory\n");
crash();
}
- sizestr = strcat(sizestr, ptemp); /* build up length of
- * array */
-
+ } else {
+ sizestr = (char *)realloc(sizestr,
+ strlen(sizestr) + strlen(ptemp) + 1);
+ if (sizestr == NULL) {
+ fprintf(stderr,
+ "Fatal error : no memory\n");
+ crash();
+ }
+ /* build up length of array */
+ sizestr = strcat(sizestr, ptemp);
}
}
diff --git a/usr.bin/rpcgen/rpc_hout.c b/usr.bin/rpcgen/rpc_hout.c
index ec293cc1036..8251bdc9dd5 100644
--- a/usr.bin/rpcgen/rpc_hout.c
+++ b/usr.bin/rpcgen/rpc_hout.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rpc_hout.c,v 1.11 2002/06/01 01:40:38 deraadt Exp $ */
+/* $OpenBSD: rpc_hout.c,v 1.12 2002/07/05 05:39:42 deraadt Exp $ */
/* $NetBSD: rpc_hout.c,v 1.4 1995/06/11 21:49:55 pk Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@@ -68,7 +68,7 @@ print_datadef(def)
{
if (def->def_kind == DEF_PROGRAM) /* handle data only */
- return;
+ return;
if (def->def_kind != DEF_CONST)
fprintf(fout, "\n");
@@ -93,7 +93,7 @@ print_datadef(def)
break;
}
if (def->def_kind != DEF_PROGRAM && def->def_kind != DEF_CONST) {
- pxdrfuncdecl( def->def_name,
+ pxdrfuncdecl(def->def_name,
def->def_kind != DEF_TYPEDEF ||
!isvectordef(def->def.ty.old_type, def->def.ty.rel));
}
@@ -137,9 +137,10 @@ pconstdef(def)
pdefine(def->def_name, def->def.co);
}
-/* print out the definitions for the arguments of functions in the
- header file
-*/
+/*
+ * print out the definitions for the arguments of functions in the
+ * header file
+ */
static void
pargdef(def)
definition *def;
@@ -150,7 +151,7 @@ pargdef(def)
proc_list *plist;
for (vers = def->def.pr.versions; vers != NULL; vers = vers->next) {
- for(plist = vers->procs; plist != NULL;
+ for (plist = vers->procs; plist != NULL;
plist = plist->next) {
if (!newstyle || plist->arg_num < 2) {
continue; /* old style or single args */
@@ -158,7 +159,7 @@ pargdef(def)
name = plist->args.argname;
fprintf(fout, "struct %s {\n", name);
for (l = plist->args.decls;
- l != NULL; l = l->next) {
+ l != NULL; l = l->next) {
pdeclaration(name, &l->decl, 1, ";\n");
}
fprintf(fout, "};\n");
@@ -274,7 +275,7 @@ pprogramdef(def)
* Print out 3 definitions, one for ANSI-C, another for C++,
* a third for old style C
*/
- for(i=0; i<3; i++) {
+ for (i=0; i<3; i++) {
if (i==0) {
fprintf(fout,"\n#ifdef __cplusplus\n");
ext = "extern \"C\" ";
@@ -431,7 +432,7 @@ pdeclaration(name, dec, tab, separator)
char *name;
declaration *dec;
int tab;
- char *separator;
+ char *separator;
{
char buf[8]; /* enough to hold "struct ", include NUL */
char *prefix;
diff --git a/usr.bin/rpcgen/rpc_main.c b/usr.bin/rpcgen/rpc_main.c
index 626eb7eb3cd..4b86a36078c 100644
--- a/usr.bin/rpcgen/rpc_main.c
+++ b/usr.bin/rpcgen/rpc_main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rpc_main.c,v 1.14 2002/06/01 01:40:38 deraadt Exp $ */
+/* $OpenBSD: rpc_main.c,v 1.15 2002/07/05 05:39:42 deraadt Exp $ */
/* $NetBSD: rpc_main.c,v 1.9 1996/02/19 11:12:43 pk Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@@ -32,7 +32,7 @@
#ifndef lint
static char sccsid[] = "@(#)rpc_main.c 1.30 89/03/30 (C) 1987 SMI";
-static char cvsid[] = "$OpenBSD: rpc_main.c,v 1.14 2002/06/01 01:40:38 deraadt Exp $";
+static char cvsid[] = "$OpenBSD: rpc_main.c,v 1.15 2002/07/05 05:39:42 deraadt Exp $";
#endif
/*
@@ -41,18 +41,15 @@ static char cvsid[] = "$OpenBSD: rpc_main.c,v 1.14 2002/06/01 01:40:38 deraa
#define RPCGEN_VERSION "199506"/* This program's version (year & month) */
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
#include <sys/types.h>
-#ifdef __TURBOC__
-#define MAXPATHLEN 80
-#include <process.h>
-#include <dir.h>
-#else
#include <sys/param.h>
#include <sys/file.h>
-#endif
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <ctype.h>
#include <sys/stat.h>
#include "rpc_parse.h"
#include "rpc_util.h"
@@ -130,21 +127,21 @@ int tirpcflag = 0; /* generating code for tirpc, by default */
static char *dos_cppfile = NULL;
#endif
-static c_output(char *, char *, int, char *);
-static h_output(char *, char *, int, char *);
-static s_output(int, char **, char *, char *, int, char *, int, int);
-static l_output(char *, char *, int, char *);
-static t_output(char *, char *, int, char *);
-static svc_output(char *, char *, int, char *);
-static clnt_output(char *, char *, int, char *);
-static do_registers(int, char **);
+static void c_output(char *, char *, int, char *);
+static void h_output(char *, char *, int, char *);
+static void s_output(int, char **, char *, char *, int, char *, int, int);
+static void l_output(char *, char *, int, char *);
+static void t_output(char *, char *, int, char *);
+static void svc_output(char *, char *, int, char *);
+static void clnt_output(char *, char *, int, char *);
+static int do_registers(int, char **);
static void addarg(char *);
static void putarg(int, char *);
static void clear_args(void);
static void checkfiles(char *, char *);
static int parseargs(int, char **, struct commandline *);
-static usage(void);
-
+static void usage(void);
+void c_initialize(void);
int
main(argc, argv)
@@ -234,8 +231,10 @@ extendfile(path, ext)
file++;
res = alloc(strlen(file) + strlen(ext) + 1);
- if (res == NULL)
- abort();
+ if (res == NULL) {
+ fprintf(stderr, "could not allocate memory\n");
+ exit(1);
+ }
p = strrchr(file, '.');
if (p == NULL)
p = file + strlen(file);
@@ -272,7 +271,7 @@ open_output(infile, outfile)
}
-static
+static void
add_warning()
{
fprintf(fout, "/*\n");
@@ -282,7 +281,7 @@ add_warning()
}
/* clear list of arguments */
-static void
+static void
clear_args()
{
int i;
@@ -292,7 +291,7 @@ clear_args()
}
/* make sure that a CPP exists */
-static void
+static void
find_cpp()
{
struct stat buf;
@@ -317,7 +316,7 @@ find_cpp()
/*
* Open input file with given define for C-preprocessor
*/
-static
+static void
open_input(infile, define)
char *infile;
char *define;
@@ -416,7 +415,7 @@ static char *valid_i_nettypes[] = {
NULL
};
-static int
+static int
check_nettype(name, list_to_check)
char *name;
char *list_to_check[];
@@ -434,7 +433,7 @@ check_nettype(name, list_to_check)
* Compile into an XDR routine output file
*/
-static
+static void
c_output(infile, define, extend, outfile)
char *infile;
char *define;
@@ -458,7 +457,7 @@ c_output(infile, define, extend, outfile)
} else
fprintf(fout, "#include <rpc/rpc.h>\n");
tell = ftell(fout);
- while (def = get_definition()) {
+ while ((def = get_definition())) {
emit(def);
}
if (extend && tell == ftell(fout)) {
@@ -467,7 +466,8 @@ c_output(infile, define, extend, outfile)
}
-c_initialize()
+void
+c_initialize(void)
{
/* add all the starting basic types */
@@ -492,7 +492,7 @@ char rpcgen_table_dcl[] = "struct rpcgen_table {\n\
};\n";
-char *
+char *
generate_guard(pathname)
char *pathname;
{
@@ -501,6 +501,11 @@ generate_guard(pathname)
filename = strrchr(pathname, '/'); /* find last component */
filename = ((filename == 0) ? pathname : filename + 1);
guard = strdup(filename);
+ if (guard == NULL) {
+ fprintf(stderr, "out of memory while processing %s\n", filename);
+ crash();
+ }
+
/* convert to upper case */
tmp = guard;
while (*tmp) {
@@ -517,7 +522,7 @@ generate_guard(pathname)
* Compile into an XDR header file
*/
-static
+static void
h_output(infile, define, extend, outfile)
char *infile;
char *define;
@@ -544,7 +549,7 @@ h_output(infile, define, extend, outfile)
tell = ftell(fout);
/* print data definitions */
- while (def = get_definition()) {
+ while ((def = get_definition())) {
print_datadef(def);
}
@@ -566,7 +571,7 @@ h_output(infile, define, extend, outfile)
/*
* Compile into an RPC service
*/
-static
+static void
s_output(argc, argv, infile, define, extend, outfile, nomain, netflag)
int argc;
char *argv[];
@@ -632,7 +637,7 @@ s_output(argc, argv, infile, define, extend, outfile, nomain, netflag)
if ((netflag || pmflag) && tirpcflag) {
fprintf(fout, "#include <netconfig.h>\n");
}
- if ( /* timerflag && */ tirpcflag)
+ if (/* timerflag && */ tirpcflag)
fprintf(fout, "#include <sys/resource.h> /* rlimit */\n");
if (logflag || inetdflag || pmflag) {
fprintf(fout, "#include <syslog.h>\n");
@@ -644,7 +649,7 @@ s_output(argc, argv, infile, define, extend, outfile, nomain, netflag)
fprintf(fout, "\n#ifdef DEBUG\n#define RPC_SVC_FG\n#endif\n");
if (timerflag)
fprintf(fout, "\n#define _RPCSVC_CLOSEDOWN %s\n", svcclosetime);
- while (def = get_definition()) {
+ while ((def = get_definition())) {
foundprogram |= (def->def_kind == DEF_PROGRAM);
}
if (extend && !foundprogram) {
@@ -667,7 +672,7 @@ s_output(argc, argv, infile, define, extend, outfile, nomain, netflag)
/*
* generate client side stubs
*/
-static
+static void
l_output(infile, define, extend, outfile)
char *infile;
char *define;
@@ -690,7 +695,7 @@ l_output(infile, define, extend, outfile)
free(include);
} else
fprintf(fout, "#include <rpc/rpc.h>\n");
- while (def = get_definition())
+ while ((def = get_definition()))
foundprogram |= (def->def_kind == DEF_PROGRAM);
if (extend && !foundprogram) {
@@ -703,7 +708,7 @@ l_output(infile, define, extend, outfile)
/*
* generate the dispatch table
*/
-static
+static void
t_output(infile, define, extend, outfile)
char *infile;
char *define;
@@ -718,7 +723,7 @@ t_output(infile, define, extend, outfile)
outfilename = extend ? extendfile(infile, outfile) : outfile;
open_output(infile, outfilename);
add_warning();
- while (def = get_definition())
+ while ((def = get_definition()))
foundprogram |= (def->def_kind == DEF_PROGRAM);
if (extend && !foundprogram) {
@@ -729,7 +734,7 @@ t_output(infile, define, extend, outfile)
}
/* sample routine for the server template */
-static
+static void
svc_output(infile, define, extend, outfile)
char *infile;
char *define;
@@ -756,7 +761,7 @@ svc_output(infile, define, extend, outfile)
fprintf(fout, "#include <rpc/rpc.h>\n");
tell = ftell(fout);
- while (def = get_definition())
+ while ((def = get_definition()))
write_sample_svc(def);
if (extend && tell == ftell(fout))
@@ -765,7 +770,7 @@ svc_output(infile, define, extend, outfile)
/* sample main routine for client */
-static
+static void
clnt_output(infile, define, extend, outfile)
char *infile;
char *define;
@@ -794,7 +799,7 @@ clnt_output(infile, define, extend, outfile)
} else
fprintf(fout, "#include <rpc/rpc.h>\n");
tell = ftell(fout);
- while (def = get_definition())
+ while ((def = get_definition()))
has_program += write_sample_clnt(def);
if (has_program)
@@ -808,8 +813,7 @@ clnt_output(infile, define, extend, outfile)
* Perform registrations for service output
* Return 0 if failed; 1 otherwise.
*/
-static
-int
+static int
do_registers(argc, argv)
int argc;
char *argv[];
@@ -952,9 +956,9 @@ parseargs(argc, argv, cmd)
case 'l':
case 'm':
case 't':
- if (flag[c])
+ if (flag[(unsigned char)c])
return (0);
- flag[c] = 1;
+ flag[(unsigned char)c] = 1;
break;
case 'S':
/*
@@ -970,9 +974,9 @@ parseargs(argc, argv, cmd)
else
return (0);
- if (flag[c])
+ if (flag[(unsigned char)c])
return (0);
- flag[c] = 1;
+ flag[(unsigned char)c] = 1;
break;
case 'C': /* ANSI C syntax */
Cflag = 1;
@@ -1014,7 +1018,7 @@ parseargs(argc, argv, cmd)
if (argv[i][j - 1] != '-' ||
argv[i][j + 1] != 0)
return (0);
- flag[c] = 1;
+ flag[(unsigned char)c] = 1;
if (++i == argc)
return (0);
if (c == 's') {
@@ -1097,8 +1101,8 @@ parseargs(argc, argv, cmd)
return (1);
}
-static
-usage()
+static void
+usage(void)
{
fprintf(stderr, "usage: %s [-abACILNT] [-Dname[=value]] [-i lines] "
"[-K seconds] infile\n", cmdname);
diff --git a/usr.bin/rpcgen/rpc_parse.c b/usr.bin/rpcgen/rpc_parse.c
index 8ce08bfb0de..4ba914b1ce6 100644
--- a/usr.bin/rpcgen/rpc_parse.c
+++ b/usr.bin/rpcgen/rpc_parse.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rpc_parse.c,v 1.10 2002/06/01 01:40:38 deraadt Exp $ */
+/* $OpenBSD: rpc_parse.c,v 1.11 2002/07/05 05:39:42 deraadt Exp $ */
/* $NetBSD: rpc_parse.c,v 1.5 1995/08/29 23:05:55 cgd Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@@ -48,17 +48,17 @@ static char sccsid[] = "@(#)rpc_parse.c 1.8 89/02/22 (C) 1987 SMI";
#define ARGNAME "arg"
-static isdefined(definition *);
-static def_struct(definition *);
-static def_program(definition *);
-static def_enum(definition *);
-static def_const(definition *);
-static def_union(definition *);
-static def_typedef(definition *);
-static get_declaration(declaration *, defkind);
-static get_prog_declaration(declaration *, defkind, int);
-static get_type(char **, char **, defkind);
-static unsigned_dec(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 def_typedef(definition *);
+static void get_declaration(declaration *, defkind);
+static void get_prog_declaration(declaration *, defkind, int);
+static void get_type(char **, char **, defkind);
+static void unsigned_dec(char **);
/*
* return the next definition you see
@@ -100,14 +100,14 @@ get_definition()
return (defp);
}
-static
+static void
isdefined(defp)
definition *defp;
{
STOREVAL(&defined, defp);
}
-static
+static void
def_struct(defp)
definition *defp;
{
@@ -135,7 +135,7 @@ def_struct(defp)
*tailp = NULL;
}
-static
+static void
def_program(defp)
definition *defp;
{
@@ -166,7 +166,7 @@ def_program(defp)
/* get result type */
plist = ALLOC(proc_list);
get_type(&plist->res_prefix, &plist->res_type,
- DEF_PROGRAM);
+ DEF_PROGRAM);
if (streq(plist->res_type, "opaque")) {
error("illegal result type");
}
@@ -182,29 +182,29 @@ def_program(defp)
*/
get_prog_declaration(&dec, DEF_PROGRAM, num_args);
if (streq(dec.type, "void"))
- isvoid = TRUE;
+ isvoid = TRUE;
decls = ALLOC(decl_list);
plist->args.decls = decls;
decls->decl = dec;
tailp = &decls->next;
/* get args */
while (peekscan(TOK_COMMA, &tok)) {
- num_args++;
- get_prog_declaration(&dec, DEF_STRUCT,
- num_args);
- decls = ALLOC(decl_list);
- decls->decl = dec;
- *tailp = decls;
- if (streq(dec.type, "void"))
- isvoid = TRUE;
- tailp = &decls->next;
+ num_args++;
+ get_prog_declaration(&dec, DEF_STRUCT,
+ num_args);
+ decls = ALLOC(decl_list);
+ decls->decl = dec;
+ *tailp = decls;
+ if (streq(dec.type, "void"))
+ isvoid = TRUE;
+ tailp = &decls->next;
}
/* multiple arguments are only allowed in newstyle */
- if( !newstyle && num_args > 1 ) {
- error("only one argument is allowed" );
+ if (!newstyle && num_args > 1) {
+ error("only one argument is allowed");
}
if (isvoid && num_args > 1) {
- error("illegal use of void in program definition");
+ error("illegal use of void in program definition");
}
*tailp = NULL;
scan(TOK_RPAREN, &tok);
@@ -225,10 +225,10 @@ def_program(defp)
scan_num(&tok);
vlist->vers_num = tok.str;
/* make the argument structure name for each arg*/
- for(plist = vlist->procs; plist != NULL;
+ for (plist = vlist->procs; plist != NULL;
plist = plist->next) {
plist->args.argname = make_argname(plist->proc_name,
- vlist->vers_num);
+ vlist->vers_num);
/* free the memory ??*/
}
scan(TOK_SEMICOLON, &tok);
@@ -241,7 +241,7 @@ def_program(defp)
}
-static
+static void
def_enum(defp)
definition *defp;
{
@@ -271,7 +271,7 @@ def_enum(defp)
*tailp = NULL;
}
-static
+static void
def_const(defp)
definition *defp;
{
@@ -285,78 +285,70 @@ def_const(defp)
defp->def.co = tok.str;
}
-static
+static void
def_union(defp)
definition *defp;
{
- token tok;
- declaration dec;
- case_list *cases,*tcase;
- case_list **tailp;
- int flag;
-
- defp->def_kind = DEF_UNION;
- scan(TOK_IDENT, &tok);
- defp->def_name = tok.str;
- scan(TOK_SWITCH, &tok);
- scan(TOK_LPAREN, &tok);
- get_declaration(&dec, DEF_UNION);
- defp->def.un.enum_decl = dec;
- tailp = &defp->def.un.cases;
- scan(TOK_RPAREN, &tok);
- scan(TOK_LBRACE, &tok);
- scan(TOK_CASE, &tok);
- while (tok.kind == TOK_CASE) {
- scan2(TOK_IDENT, TOK_CHARCONST, &tok);
- cases = ALLOC(case_list);
- cases->case_name = tok.str;
- scan(TOK_COLON, &tok);
- /* now peek at next token */
- flag=0;
- if(peekscan(TOK_CASE,&tok))
- {
-
- do
- {
- scan2(TOK_IDENT, TOK_CHARCONST, &tok);
- cases->contflag=1; /* continued case statement */
- *tailp = cases;
- tailp = &cases->next;
- cases = ALLOC(case_list);
- cases->case_name = tok.str;
- scan(TOK_COLON, &tok);
-
- } while (peekscan(TOK_CASE,&tok));
- }
- else
- if(flag)
- {
-
- *tailp = cases;
- tailp = &cases->next;
- cases = ALLOC(case_list);
+ token tok;
+ declaration dec;
+ case_list *cases;
+ case_list **tailp;
+ int flag;
+
+ defp->def_kind = DEF_UNION;
+ scan(TOK_IDENT, &tok);
+ defp->def_name = tok.str;
+ scan(TOK_SWITCH, &tok);
+ scan(TOK_LPAREN, &tok);
+ get_declaration(&dec, DEF_UNION);
+ defp->def.un.enum_decl = dec;
+ tailp = &defp->def.un.cases;
+ scan(TOK_RPAREN, &tok);
+ scan(TOK_LBRACE, &tok);
+ scan(TOK_CASE, &tok);
+ while (tok.kind == TOK_CASE) {
+ scan2(TOK_IDENT, TOK_CHARCONST, &tok);
+ cases = ALLOC(case_list);
+ cases->case_name = tok.str;
+ scan(TOK_COLON, &tok);
+ /* now peek at next token */
+ flag=0;
+ if (peekscan(TOK_CASE,&tok)) {
+ do {
+ scan2(TOK_IDENT, TOK_CHARCONST, &tok);
+ cases->contflag=1; /* continued case statement */
+ *tailp = cases;
+ tailp = &cases->next;
+ cases = ALLOC(case_list);
+ cases->case_name = tok.str;
+ scan(TOK_COLON, &tok);
+ } while (peekscan(TOK_CASE,&tok));
+ } else if (flag) {
+ *tailp = cases;
+ tailp = &cases->next;
+ cases = ALLOC(case_list);
+ }
+ get_declaration(&dec, DEF_UNION);
+ cases->case_decl = dec;
+ cases->contflag=0; /* no continued case statement */
+ *tailp = cases;
+ tailp = &cases->next;
+ scan(TOK_SEMICOLON, &tok);
+
+ scan3(TOK_CASE, TOK_DEFAULT, TOK_RBRACE, &tok);
}
+ *tailp = NULL;
- get_declaration(&dec, DEF_UNION);
- cases->case_decl = dec;
- cases->contflag=0; /* no continued case statement */
- *tailp = cases;
- tailp = &cases->next;
- scan(TOK_SEMICOLON, &tok);
-
- scan3(TOK_CASE, TOK_DEFAULT, TOK_RBRACE, &tok);
- }
- *tailp = NULL;
- if (tok.kind == TOK_DEFAULT) {
- scan(TOK_COLON, &tok);
- get_declaration(&dec, DEF_UNION);
- defp->def.un.default_decl = ALLOC(declaration);
- *defp->def.un.default_decl = dec;
- scan(TOK_SEMICOLON, &tok);
- scan(TOK_RBRACE, &tok);
- } else {
- defp->def.un.default_decl = NULL;
- }
+ if (tok.kind == TOK_DEFAULT) {
+ scan(TOK_COLON, &tok);
+ get_declaration(&dec, DEF_UNION);
+ defp->def.un.default_decl = ALLOC(declaration);
+ *defp->def.un.default_decl = dec;
+ scan(TOK_SEMICOLON, &tok);
+ scan(TOK_RBRACE, &tok);
+ } else {
+ defp->def.un.default_decl = NULL;
+ }
}
static char *reserved_words[] = {
@@ -383,32 +375,34 @@ static char *reserved_types[] = {
/* check that the given name is not one that would eventually result in
xdr routines that would conflict with internal XDR routines. */
-static check_type_name( name, new_type )
-int new_type;
-char *name;
+static void
+check_type_name(name, new_type)
+ int new_type;
+ char *name;
{
- int i;
- char tmp[100];
-
- for( i = 0; reserved_words[i] != NULL; i++ ) {
- if( strcmp( name, reserved_words[i] ) == 0 ) {
- snprintf(tmp, sizeof tmp,
- "illegal (reserved) name :\'%s\' in type definition", name );
- error(tmp);
- }
- }
- if( new_type ) {
- for( i = 0; reserved_types[i] != NULL; i++ ) {
- if( strcmp( name, reserved_types[i] ) == 0 ) {
- snprintf(tmp, sizeof tmp,
- "illegal (reserved) name :\'%s\' in type definition", name );
- error(tmp);
- }
- }
- }
+ int i;
+ char tmp[100];
+
+ for (i = 0; reserved_words[i] != NULL; i++) {
+ if (strcmp(name, reserved_words[i]) == 0) {
+ snprintf(tmp, sizeof tmp,
+ "illegal (reserved) name :\'%s\' in type definition", name);
+ error(tmp);
+ }
+ }
+ if (new_type) {
+ for (i = 0; reserved_types[i] != NULL; i++) {
+ if (strcmp(name, reserved_types[i]) == 0) {
+ snprintf(tmp, sizeof tmp,
+ "illegal (reserved) name :\'%s\' in"
+ " type definition", name);
+ error(tmp);
+ }
+ }
+ }
}
-static
+static void
def_typedef(defp)
definition *defp;
{
@@ -417,14 +411,14 @@ def_typedef(defp)
defp->def_kind = DEF_TYPEDEF;
get_declaration(&dec, DEF_TYPEDEF);
defp->def_name = dec.name;
- check_type_name( dec.name, 1 );
+ check_type_name(dec.name, 1);
defp->def.ty.old_prefix = dec.prefix;
defp->def.ty.old_type = dec.type;
defp->def.ty.rel = dec.rel;
defp->def.ty.array_max = dec.array_max;
}
-static
+static void
get_declaration(dec, dkind)
declaration *dec;
defkind dkind;
@@ -437,7 +431,7 @@ get_declaration(dec, dkind)
return;
}
- check_type_name( dec->type, 0 );
+ check_type_name(dec->type, 0);
scan2(TOK_STAR, TOK_IDENT, &tok);
if (tok.kind == TOK_STAR) {
@@ -477,53 +471,59 @@ get_declaration(dec, dkind)
}
}
-static
+static void
get_prog_declaration(dec, dkind, num)
declaration *dec;
defkind dkind;
- int num; /* arg number */
+ int num; /* arg number */
{
token tok;
char name[10]; /* argument name */
if (dkind == DEF_PROGRAM) {
- peek(&tok);
- if (tok.kind == TOK_RPAREN) { /* no arguments */
- dec->rel = REL_ALIAS;
- dec->type = "void";
- dec->prefix = NULL;
- dec->name = NULL;
- return;
- }
+ peek(&tok);
+ if (tok.kind == TOK_RPAREN) { /* no arguments */
+ dec->rel = REL_ALIAS;
+ dec->type = "void";
+ dec->prefix = NULL;
+ dec->name = NULL;
+ return;
+ }
}
get_type(&dec->prefix, &dec->type, dkind);
dec->rel = REL_ALIAS;
if (peekscan(TOK_IDENT, &tok)) /* optional name of argument */
strlcpy(name, tok.str, sizeof name);
- else
- snprintf(name, sizeof name, "%s%d", ARGNAME, num); /* default name of argument */
+ else {
+ /* default name of argument */
+ snprintf(name, sizeof name, "%s%d", ARGNAME, num);
+ }
dec->name = (char *)strdup(name);
+ if (dec->name == NULL)
+ error("out of memory");
- if (streq(dec->type, "void")) {
+ if (streq(dec->type, "void"))
return;
- }
- if (streq(dec->type, "opaque")) {
+ if (streq(dec->type, "opaque"))
error("opaque -- illegal argument type");
- }
+
if (peekscan(TOK_STAR, &tok)) {
- if (streq(dec->type, "string")) {
- error("pointer to string not allowed in program arguments\n");
- }
+ if (streq(dec->type, "string"))
+ error("pointer to string not allowed in program arguments\n");
+
dec->rel = REL_POINTER;
- if (peekscan(TOK_IDENT, &tok)) /* optional name of argument */
- dec->name = (char *)strdup(tok.str);
- }
- if (peekscan(TOK_LANGLE, &tok)) {
- if (!streq(dec->type, "string")) {
- error("arrays cannot be declared as arguments to procedures -- use typedef");
- }
+ if (peekscan(TOK_IDENT, &tok)) { /* optional name of argument */
+ dec->name = (char *)strdup(tok.str);
+ if (dec->name == NULL)
+ error("out of memory");
+ }
+ }
+ if (peekscan(TOK_LANGLE, &tok)) {
+ if (!streq(dec->type, "string"))
+ error("arrays cannot be declared as arguments to "
+ "procedures -- use typedef");
dec->rel = REL_ARRAY;
if (peekscan(TOK_RANGLE, &tok)) {
dec->array_max = "~0";/* unspecified size, use max */
@@ -534,19 +534,18 @@ get_prog_declaration(dec, dkind, num)
}
}
if (streq(dec->type, "string")) {
- if (dec->rel != REL_ARRAY) { /* .x specifies just string as
- * type of argument
- * - make it string<>
- */
+ /* .x specifies just string as
+ * type of argument
+ * - make it string<>
+ */
+ if (dec->rel != REL_ARRAY) {
dec->rel = REL_ARRAY;
dec->array_max = "~0";/* unspecified size, use max */
}
}
}
-
-
-static
+static void
get_type(prefixp, typep, dkind)
char **prefixp;
char **typep;
@@ -598,7 +597,7 @@ get_type(prefixp, typep, dkind)
}
}
-static
+static void
unsigned_dec(typep)
char **typep;
{
diff --git a/usr.bin/rpcgen/rpc_parse.h b/usr.bin/rpcgen/rpc_parse.h
index 0d47749f70b..3f3a6aeecd8 100644
--- a/usr.bin/rpcgen/rpc_parse.h
+++ b/usr.bin/rpcgen/rpc_parse.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rpc_parse.h,v 1.5 2001/12/05 09:50:31 deraadt Exp $ */
+/* $OpenBSD: rpc_parse.h,v 1.6 2002/07/05 05:39:42 deraadt Exp $ */
/* $NetBSD: rpc_parse.h,v 1.3 1995/06/11 21:50:00 pk Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@@ -159,12 +159,10 @@ typedef struct definition definition;
definition *get_definition();
-
-struct bas_type
-{
- char *name;
- int length;
- struct bas_type *next;
+struct bas_type {
+ char *name;
+ int length;
+ struct bas_type *next;
};
typedef struct bas_type bas_type;
diff --git a/usr.bin/rpcgen/rpc_sample.c b/usr.bin/rpcgen/rpc_sample.c
index b78114728ca..aded83167d5 100644
--- a/usr.bin/rpcgen/rpc_sample.c
+++ b/usr.bin/rpcgen/rpc_sample.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rpc_sample.c,v 1.12 2002/06/01 01:40:38 deraadt Exp $ */
+/* $OpenBSD: rpc_sample.c,v 1.13 2002/07/05 05:39:42 deraadt Exp $ */
/* $NetBSD: rpc_sample.c,v 1.2 1995/06/11 21:50:01 pk Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@@ -54,7 +54,7 @@ static void return_type(proc_list *);
void
write_sample_svc(def)
- definition *def;
+ definition *def;
{
if (def->def_kind != DEF_PROGRAM)
@@ -65,9 +65,9 @@ write_sample_svc(def)
int
write_sample_clnt(def)
- definition *def;
+ definition *def;
{
- version_list *vp;
+ version_list *vp;
int count = 0;
if (def->def_kind != DEF_PROGRAM)
@@ -83,85 +83,85 @@ write_sample_clnt(def)
static void
write_sample_client(program_name, vp)
- char *program_name;
- version_list *vp;
+ char *program_name;
+ version_list *vp;
{
- proc_list *proc;
- int i;
- decl_list *l;
-
- fprintf(fout, "\n\nvoid\n");
- pvname(program_name, vp->vers_num);
- if (Cflag)
- fprintf(fout,"(char *host)\n{\n");
- else
- fprintf(fout, "(host)\nchar *host;\n{\n");
- fprintf(fout, "\tCLIENT *clnt;\n");
-
- i = 0;
- for (proc = vp->procs; proc != NULL; proc = proc->next) {
- fprintf(fout, "\t");
- ptype(proc->res_prefix, proc->res_type, 1);
- fprintf(fout, " *result_%d;\n",++i);
- /* print out declarations for arguments */
- if (proc->arg_num < 2 && !newstyle) {
- fprintf(fout, "\t");
- if (!streq(proc->args.decls->decl.type, "void"))
- ptype(proc->args.decls->decl.prefix, proc->args.decls->decl.type, 1);
+ proc_list *proc;
+ int i;
+ decl_list *l;
+
+ fprintf(fout, "\n\nvoid\n");
+ pvname(program_name, vp->vers_num);
+ if (Cflag)
+ fprintf(fout,"(char *host)\n{\n");
else
- fprintf(fout, "char *"); /* cannot have "void" type */
- fprintf(fout, " ");
- pvname(proc->proc_name, vp->vers_num);
- fprintf(fout, "_arg;\n");
- } else if (!streq(proc->args.decls->decl.type, "void")) {
- for (l = proc->args.decls; l != NULL; l = l->next) {
- fprintf(fout, "\t");
- ptype(l->decl.prefix, l->decl.type, 1);
- fprintf(fout, " ");
- pvname(proc->proc_name, vp->vers_num);
- fprintf(fout, "_%s;\n", l->decl.name);
-/* pdeclaration(proc->args.argname, &l->decl, 1, ";\n");*/
+ fprintf(fout, "(host)\nchar *host;\n{\n");
+ fprintf(fout, "\tCLIENT *clnt;\n");
+
+ i = 0;
+ for (proc = vp->procs; proc != NULL; proc = proc->next) {
+ fprintf(fout, "\t");
+ ptype(proc->res_prefix, proc->res_type, 1);
+ fprintf(fout, " *result_%d;\n",++i);
+ /* print out declarations for arguments */
+ if (proc->arg_num < 2 && !newstyle) {
+ fprintf(fout, "\t");
+ if (!streq(proc->args.decls->decl.type, "void"))
+ ptype(proc->args.decls->decl.prefix,
+ proc->args.decls->decl.type, 1);
+ else
+ fprintf(fout, "char *"); /* cannot have "void" type */
+ fprintf(fout, " ");
+ pvname(proc->proc_name, vp->vers_num);
+ fprintf(fout, "_arg;\n");
+ } else if (!streq(proc->args.decls->decl.type, "void")) {
+ for (l = proc->args.decls; l != NULL; l = l->next) {
+ fprintf(fout, "\t");
+ ptype(l->decl.prefix, l->decl.type, 1);
+ fprintf(fout, " ");
+ pvname(proc->proc_name, vp->vers_num);
+ fprintf(fout, "_%s;\n", l->decl.name);
+ /* pdeclaration(proc->args.argname, &l->decl, 1, ";\n");*/
+ }
+ }
}
- }
- }
-
- /* generate creation of client handle */
- fprintf(fout, "\tclnt = clnt_create(host, %s, %s, \"%s\");\n",
- program_name, vp->vers_name, tirpcflag? "netpath" : "udp");
- fprintf(fout, "\tif (clnt == NULL) {\n");
- fprintf(fout, "\t\tclnt_pcreateerror(host);\n");
- fprintf(fout, "\t\texit(1);\n\t}\n");
-
- /* generate calls to procedures */
- i = 0;
- for (proc = vp->procs; proc != NULL; proc = proc->next) {
- fprintf(fout, "\tresult_%d = ",++i);
- pvname(proc->proc_name, vp->vers_num);
- if (proc->arg_num < 2 && !newstyle) {
- fprintf(fout, "(");
- if (streq(proc->args.decls->decl.type, "void")) /* cast to void* */
- fprintf(fout, "(void*)");
- fprintf(fout, "&");
- pvname(proc->proc_name, vp->vers_num);
- fprintf(fout, "_arg, clnt);\n");
- } else if (streq(proc->args.decls->decl.type, "void")) {
- fprintf(fout, "(clnt);\n");
- }
- else {
- fprintf(fout, "(");
- for (l = proc->args.decls; l != NULL; l = l->next) {
- pvname(proc->proc_name, vp->vers_num);
- fprintf(fout, "_%s, ", l->decl.name);
+
+ /* generate creation of client handle */
+ fprintf(fout, "\tclnt = clnt_create(host, %s, %s, \"%s\");\n",
+ program_name, vp->vers_name, tirpcflag? "netpath" : "udp");
+ fprintf(fout, "\tif (clnt == NULL) {\n");
+ fprintf(fout, "\t\tclnt_pcreateerror(host);\n");
+ fprintf(fout, "\t\texit(1);\n\t}\n");
+
+ /* generate calls to procedures */
+ i = 0;
+ for (proc = vp->procs; proc != NULL; proc = proc->next) {
+ fprintf(fout, "\tresult_%d = ",++i);
+ pvname(proc->proc_name, vp->vers_num);
+ if (proc->arg_num < 2 && !newstyle) {
+ fprintf(fout, "(");
+ if (streq(proc->args.decls->decl.type, "void"))
+ fprintf(fout, "(void*)");
+ fprintf(fout, "&");
+ pvname(proc->proc_name, vp->vers_num);
+ fprintf(fout, "_arg, clnt);\n");
+ } else if (streq(proc->args.decls->decl.type, "void")) {
+ fprintf(fout, "(clnt);\n");
+ } else {
+ fprintf(fout, "(");
+ for (l = proc->args.decls; l != NULL; l = l->next) {
+ pvname(proc->proc_name, vp->vers_num);
+ fprintf(fout, "_%s, ", l->decl.name);
+ }
+ fprintf(fout, "clnt);\n");
+ }
+ fprintf(fout, "\tif (result_%d == NULL) {\n", i);
+ fprintf(fout, "\t\tclnt_perror(clnt, \"call failed:\");\n");
+ fprintf(fout, "\t}\n");
}
- fprintf(fout, "clnt);\n");
- }
- fprintf(fout, "\tif (result_%d == NULL) {\n", i);
- fprintf(fout, "\t\tclnt_perror(clnt, \"call failed:\");\n");
- fprintf(fout, "\t}\n");
- }
-
- fprintf(fout, "\tclnt_destroy(clnt);\n");
- fprintf(fout, "}\n");
+
+ fprintf(fout, "\tclnt_destroy(clnt);\n");
+ fprintf(fout, "}\n");
}
static void
diff --git a/usr.bin/rpcgen/rpc_scan.c b/usr.bin/rpcgen/rpc_scan.c
index 8a0dd317686..9c75b6d10ba 100644
--- a/usr.bin/rpcgen/rpc_scan.c
+++ b/usr.bin/rpcgen/rpc_scan.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rpc_scan.c,v 1.9 2002/06/01 01:40:38 deraadt Exp $ */
+/* $OpenBSD: rpc_scan.c,v 1.10 2002/07/05 05:39:42 deraadt Exp $ */
/* $NetBSD: rpc_scan.c,v 1.4 1995/06/11 21:50:02 pk Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@@ -47,15 +47,15 @@ static char sccsid[] = "@(#)rpc_scan.c 1.11 89/02/22 (C) 1987 SMI";
#include "rpc_parse.h"
#include "rpc_util.h"
-static unget_token(token *tokp);
-static findstrconst(char **, char **);
-static findchrconst(char **, char **);
-static findconst(char **, char **);
-static findkind(char **, token *);
-static cppline(char *);
-static directive(char *);
-static printdirective(char *);
-static docppline(char *, int *, char **);
+static void unget_token(token *tokp);
+static void findstrconst(char **, char **);
+static void findchrconst(char **, char **);
+static void findconst(char **, char **);
+static void findkind(char **, token *);
+static int cppline(char *);
+static int directive(char *);
+static void printdirective(char *);
+static void docppline(char *, int *, char **);
#define startcomment(where) (where[0] == '/' && where[1] == '*')
#define endcomment(where) (where[-1] == '*' && where[0] == '/')
@@ -305,7 +305,7 @@ get_token(tokp)
}
}
-static
+static void
unget_token(tokp)
token *tokp;
{
@@ -313,7 +313,7 @@ unget_token(tokp)
pushed = 1;
}
-static
+static void
findstrconst(str, val)
char **str;
char **val;
@@ -323,7 +323,7 @@ findstrconst(str, val)
p = *str;
do {
- *p++;
+ p++;
} while (*p && *p != '"');
if (*p == 0) {
error("unterminated string constant");
@@ -331,12 +331,14 @@ findstrconst(str, val)
p++;
size = p - *str;
*val = alloc(size + 1);
+ if (val == NULL)
+ error("alloc failed");
(void) strncpy(*val, *str, size);
(*val)[size] = 0;
*str = p;
}
-static
+static void
findchrconst(str, val)
char **str;
char **val;
@@ -346,7 +348,7 @@ findchrconst(str, val)
p = *str;
do {
- *p++;
+ p++;
} while (*p && *p != '\'');
if (*p == 0) {
error("unterminated string constant");
@@ -357,12 +359,14 @@ findchrconst(str, val)
error("empty char string");
}
*val = alloc(size + 1);
+ if (val == NULL)
+ error("alloc failed");
(void) strncpy(*val, *str, size);
(*val)[size] = 0;
*str = p;
}
-static
+static void
findconst(str, val)
char **str;
char **val;
@@ -383,6 +387,8 @@ findconst(str, val)
}
size = p - *str;
*val = alloc(size + 1);
+ if (val == NULL)
+ error("alloc failed");
(void) strncpy(*val, *str, size);
(*val)[size] = 0;
*str = p;
@@ -413,7 +419,7 @@ static token symbols[] = {
{TOK_EOF, "??????"},
};
-static
+static void
findkind(mark, tokp)
char **mark;
token *tokp;
@@ -437,33 +443,35 @@ findkind(mark, tokp)
tokp->kind = TOK_IDENT;
for (len = 0; isalnum(str[len]) || str[len] == '_'; len++);
tokp->str = alloc(len + 1);
+ if (tokp->str == NULL)
+ error("alloc failed");
(void) strncpy(tokp->str, str, len);
tokp->str[len] = 0;
*mark = str + len;
}
-static
+static int
cppline(line)
char *line;
{
return (line == curline && *line == '#');
}
-static
+static int
directive(line)
char *line;
{
return (line == curline && *line == '%');
}
-static
+static void
printdirective(line)
char *line;
{
fprintf(fout, "%s", line + 1);
}
-static
+static void
docppline(line, lineno, fname)
char *line;
int *lineno;
@@ -489,6 +497,8 @@ docppline(line, lineno, fname)
}
line++;
p = file = alloc(strlen(line) + 1);
+ if (p == NULL)
+ error("alloc failed");
while (*line && *line != '"') {
*p++ = *line++;
}
diff --git a/usr.bin/rpcgen/rpc_scan.h b/usr.bin/rpcgen/rpc_scan.h
index 55df4778187..28892336d68 100644
--- a/usr.bin/rpcgen/rpc_scan.h
+++ b/usr.bin/rpcgen/rpc_scan.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rpc_scan.h,v 1.3 2002/02/16 21:27:51 millert Exp $ */
+/* $OpenBSD: rpc_scan.h,v 1.4 2002/07/05 05:39:42 deraadt Exp $ */
/* $NetBSD: rpc_scan.h,v 1.3 1995/06/11 21:50:04 pk Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@@ -101,6 +101,7 @@ void scan_num(token *);
void peek(token *);
int peekscan(tok_kind, token *);
void get_token(token *);
+void reinitialize(void);
void expected1(tok_kind);
void expected2(tok_kind, tok_kind);
diff --git a/usr.bin/rpcgen/rpc_svcout.c b/usr.bin/rpcgen/rpc_svcout.c
index 1760fadf00e..274598200b1 100644
--- a/usr.bin/rpcgen/rpc_svcout.c
+++ b/usr.bin/rpcgen/rpc_svcout.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rpc_svcout.c,v 1.14 2002/06/12 06:07:16 mpech Exp $ */
+/* $OpenBSD: rpc_svcout.c,v 1.15 2002/07/05 05:39:42 deraadt Exp $ */
/* $NetBSD: rpc_svcout.c,v 1.7 1995/06/24 14:59:59 pk Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@@ -52,21 +52,23 @@ static char ROUTINE[] = "local";
char _errbuf[256]; /* For all messages */
void internal_proctype(proc_list *);
-static write_real_program(definition *);
-static write_program(definition *, char *);
-static printerr(char *, char *);
-static printif(char *, char *, char *, char *);
-static write_inetmost(char *);
-static print_return(char *);
-static print_pmapunset(char *);
-static print_err_message(char *);
-static write_timeout_func(void);
-static write_pm_most(char *, int);
-static write_caller_func(void);
-static write_rpc_svc_fg(char *, char *);
-static open_log_file(char *, char *);
-
-static
+static void write_real_program(definition *);
+static void write_program(definition *, char *);
+static void printerr(char *, char *);
+static void printif(char *, char *, char *, char *);
+static void write_inetmost(char *);
+static void print_return(char *);
+static void print_pmapunset(char *);
+static void print_err_message(char *);
+static void write_timeout_func(void);
+static void write_pm_most(char *, int);
+static void write_caller_func(void);
+static void write_rpc_svc_fg(char *, char *);
+static void write_msg_out();
+static void open_log_file(char *, char *);
+int nullproc(proc_list *proc);
+
+static void
p_xdrfunc(rname, typename)
char *rname;
char *typename;
@@ -98,7 +100,7 @@ write_most(infile, netflag, nomain)
int nomain;
{
if (inetdflag || pmflag) {
- char *var_type;
+ char *var_type;
var_type = (nomain? "extern" : "static");
fprintf(fout, "%s int _rpcpmstart;", var_type);
fprintf(fout, "\t\t/* Started by a port monitor ? */\n");
@@ -113,7 +115,7 @@ write_most(infile, netflag, nomain)
/* write out dispatcher and stubs */
write_programs(nomain? (char *)NULL : "static");
- if (nomain)
+ if (nomain)
return;
fprintf(fout, "\nmain()\n");
@@ -121,23 +123,23 @@ write_most(infile, netflag, nomain)
if (inetdflag) {
write_inetmost(infile); /* Includes call to write_rpc_svc_fg() */
} else {
- if (tirpcflag) {
- if (netflag) {
+ if (tirpcflag) {
+ if (netflag) {
+ fprintf(fout, "\tSVCXPRT *%s;\n", TRANSP);
+ fprintf(fout, "\tstruct netconfig *nconf = NULL;\n");
+ }
+ fprintf(fout, "\tpid_t pid;\n");
+ fprintf(fout, "\tint i;\n");
+ fprintf(fout, "\tchar mname[FMNAMESZ + 1];\n\n");
+ write_pm_most(infile, netflag);
+ fprintf(fout, "\telse {\n");
+ write_rpc_svc_fg(infile, "\t\t");
+ fprintf(fout, "\t}\n");
+ } else {
fprintf(fout, "\tSVCXPRT *%s;\n", TRANSP);
- fprintf(fout, "\tstruct netconfig *nconf = NULL;\n");
+ fprintf(fout, "\n");
+ print_pmapunset("\t");
}
- fprintf(fout, "\tpid_t pid;\n");
- fprintf(fout, "\tint i;\n");
- fprintf(fout, "\tchar mname[FMNAMESZ + 1];\n\n");
- write_pm_most(infile, netflag);
- fprintf(fout, "\telse {\n");
- write_rpc_svc_fg(infile, "\t\t");
- fprintf(fout, "\t}\n");
- } else {
- fprintf(fout, "\tSVCXPRT *%s;\n", TRANSP);
- fprintf(fout, "\n");
- print_pmapunset("\t");
- }
}
if (logflag && !inetdflag) {
@@ -285,7 +287,7 @@ write_programs(storage)
which calls server's defintion of actual function (e.g. printmsg_1(...)).
Unpacks single user argument of printmsg_1 to call-by-value format
expected by printmsg_1. */
-static
+static void
write_real_program(def)
definition *def;
{
@@ -301,27 +303,28 @@ write_real_program(def)
fprintf(fout, "\n_");
pvname(proc->proc_name, vp->vers_num);
if (Cflag) {
- fprintf(fout, "(");
- /* arg name */
- if (proc->arg_num > 1)
- fprintf(fout, proc->args.argname);
- else
- ptype(proc->args.decls->decl.prefix,
- proc->args.decls->decl.type, 0);
- fprintf(fout, " *argp, struct svc_req *%s)\n",
- RQSTP);
+ fprintf(fout, "(");
+ /* arg name */
+ if (proc->arg_num > 1)
+ fprintf(fout, proc->args.argname);
+ else
+ ptype(proc->args.decls->decl.prefix,
+ proc->args.decls->decl.type, 0);
+ fprintf(fout, " *argp, struct svc_req *%s)\n",
+ RQSTP);
} else {
- fprintf(fout, "(argp, %s)\n", RQSTP);
- /* arg name */
- if (proc->arg_num > 1)
- fprintf(fout, "\t%s *argp;\n", proc->args.argname);
- else {
- fprintf(fout, "\t");
- ptype(proc->args.decls->decl.prefix,
- proc->args.decls->decl.type, 0);
- fprintf(fout, " *argp;\n");
- }
- fprintf(fout, " struct svc_req *%s;\n", RQSTP);
+ fprintf(fout, "(argp, %s)\n", RQSTP);
+ /* arg name */
+ if (proc->arg_num > 1)
+ fprintf(fout, "\t%s *argp;\n",
+ proc->args.argname);
+ else {
+ fprintf(fout, "\t");
+ ptype(proc->args.decls->decl.prefix,
+ proc->args.decls->decl.type, 0);
+ fprintf(fout, " *argp;\n");
+ }
+ fprintf(fout, " struct svc_req *%s;\n", RQSTP);
}
fprintf(fout, "{\n");
@@ -329,18 +332,18 @@ write_real_program(def)
pvname_svc(proc->proc_name, vp->vers_num);
fprintf(fout, "(");
if (proc->arg_num < 2) { /* single argument */
- if (!streq(proc->args.decls->decl.type, "void"))
- fprintf(fout, "*argp, "); /* non-void */
+ if (!streq(proc->args.decls->decl.type, "void"))
+ fprintf(fout, "*argp, "); /* non-void */
} else {
- for (l = proc->args.decls; l != NULL; l = l->next)
- fprintf(fout, "argp->%s, ", l->decl.name);
+ for (l = proc->args.decls; l != NULL; l = l->next)
+ fprintf(fout, "argp->%s, ", l->decl.name);
}
fprintf(fout, "%s));\n}\n", RQSTP);
}
}
}
-static
+static void
write_program(def, storage)
definition *def;
char *storage;
@@ -478,7 +481,7 @@ write_program(def, storage)
}
}
-static
+static void
printerr(err, transp)
char *err;
char *transp;
@@ -486,8 +489,8 @@ printerr(err, transp)
fprintf(fout, "\t\tsvcerr_%s(%s);\n", err, transp);
}
-static
-printif (proc, transp, prefix, arg)
+static void
+printif(proc, transp, prefix, arg)
char *proc;
char *transp;
char *prefix;
@@ -497,6 +500,7 @@ printif (proc, transp, prefix, arg)
proc, transp, arg, prefix, arg);
}
+int
nullproc(proc)
proc_list *proc;
{
@@ -507,7 +511,7 @@ nullproc(proc)
return (0);
}
-static
+static void
write_inetmost(infile)
char *infile;
{
@@ -536,7 +540,7 @@ write_inetmost(infile)
fprintf(fout, "\t}\n");
}
-static
+static void
print_return(space)
char *space;
{
@@ -549,7 +553,7 @@ print_return(space)
}
}
-static
+static void
print_pmapunset(space)
char *space;
{
@@ -569,7 +573,7 @@ print_pmapunset(space)
}
}
-static
+static void
print_err_message(space)
char *space;
{
@@ -586,7 +590,7 @@ print_err_message(space)
*/
void
write_svc_aux(nomain)
- int nomain;
+ int nomain;
{
if (!logflag)
write_msg_out();
@@ -600,6 +604,7 @@ write_svc_aux(nomain)
* Write the _msgout function
*/
+void
write_msg_out()
{
fprintf(fout, "\n");
@@ -627,7 +632,7 @@ write_msg_out()
/*
* Write the timeout function
*/
-static
+static void
write_timeout_func()
{
if (!timerflag)
@@ -659,7 +664,7 @@ write_timeout_func()
fprintf(fout, "}\n");
}
-static
+static void
write_caller_func() /*EVAS*/
{
#define P(s) fprintf(fout, s);
@@ -697,7 +702,7 @@ P("}\n");
/*
* Write the most of port monitor support
*/
-static
+static void
write_pm_most(infile, netflag)
char *infile;
int netflag;
@@ -715,7 +720,7 @@ write_pm_most(infile, netflag)
fprintf(fout, "\t\tSVCXPRT *%s;\n", TRANSP);
}
if (timerflag)
- fprintf(fout, "\t\tint pmclose;\n");
+ fprintf(fout, "\t\tint pmclose;\n");
/* not necessary, defined in /usr/include/stdlib */
/* fprintf(fout, "\t\textern char *getenv();\n");*/
fprintf(fout, "\n");
@@ -741,7 +746,7 @@ write_pm_most(infile, netflag)
fprintf(fout, "\t\t\t}\n");
fprintf(fout, "\t\t}\n");
if (timerflag)
- fprintf(fout, "\t\tpmclose = (t_getstate(0) != T_DATAXFER);\n");
+ fprintf(fout, "\t\tpmclose = (t_getstate(0) != T_DATAXFER);\n");
fprintf(fout, "\t\tif ((%s = svc_tli_create(0, nconf, NULL, 0, 0)) == NULL) {\n",
TRANSP);
snprintf(_errbuf, sizeof _errbuf, "cannot create server handle");
@@ -784,7 +789,7 @@ write_pm_most(infile, netflag)
/*
* Support for backgrounding the server if self started.
*/
-static
+static void
write_rpc_svc_fg(infile, sp)
char *infile;
char *sp;
@@ -792,7 +797,7 @@ write_rpc_svc_fg(infile, sp)
fprintf(fout, "#ifndef RPC_SVC_FG\n");
fprintf(fout, "%sint size;\n", sp);
if (tirpcflag)
- fprintf(fout, "%sstruct rlimit rl;\n", sp);
+ fprintf(fout, "%sstruct rlimit rl;\n", sp);
if (inetdflag) {
fprintf(fout, "%sint i;\n\n", sp);
fprintf(fout, "%spid_t pid;\n\n", sp);
@@ -806,12 +811,12 @@ write_rpc_svc_fg(infile, sp)
fprintf(fout, "%s\texit(0);\n", sp);
/* get number of file descriptors */
if (tirpcflag) {
- fprintf(fout, "%srl.rlim_max = 0;\n", sp);
- fprintf(fout, "%sgetrlimit(RLIMIT_NOFILE, &rl);\n", sp);
- fprintf(fout, "%sif ((size = rl.rlim_max) == 0)\n", sp);
- fprintf(fout, "%s\texit(1);\n", sp);
+ fprintf(fout, "%srl.rlim_max = 0;\n", sp);
+ fprintf(fout, "%sgetrlimit(RLIMIT_NOFILE, &rl);\n", sp);
+ fprintf(fout, "%sif ((size = rl.rlim_max) == 0)\n", sp);
+ fprintf(fout, "%s\texit(1);\n", sp);
} else {
- fprintf(fout, "%ssize = getdtablesize();\n", sp);
+ fprintf(fout, "%ssize = getdtablesize();\n", sp);
}
fprintf(fout, "%sfor (i = 0; i < size; i++)\n", sp);
@@ -822,13 +827,13 @@ write_rpc_svc_fg(infile, sp)
fprintf(fout, "%s(void) dup2(i, 2);\n", sp);
/* This removes control of the controlling terminal */
if (tirpcflag)
- fprintf(fout, "%ssetsid();\n", sp);
+ fprintf(fout, "%ssetsid();\n", sp);
else {
- fprintf(fout, "%si = open(\"/dev/tty\", 2);\n", sp);
- fprintf(fout, "%sif (i >= 0) {\n", sp);
- fprintf(fout, "%s\t(void) ioctl(i, TIOCNOTTY, (char *)NULL);\n", sp);;
- fprintf(fout, "%s\t(void) close(i);\n", sp);
- fprintf(fout, "%s}\n", sp);
+ fprintf(fout, "%si = open(\"/dev/tty\", 2);\n", sp);
+ fprintf(fout, "%sif (i >= 0) {\n", sp);
+ fprintf(fout, "%s\t(void) ioctl(i, TIOCNOTTY, (char *)NULL);\n", sp);;
+ fprintf(fout, "%s\t(void) close(i);\n", sp);
+ fprintf(fout, "%s}\n", sp);
}
if (!logflag)
open_log_file(infile, sp);
@@ -837,7 +842,7 @@ write_rpc_svc_fg(infile, sp)
open_log_file(infile, sp);
}
-static
+static void
open_log_file(infile, sp)
char *infile;
char *sp;
diff --git a/usr.bin/rpcgen/rpc_tblout.c b/usr.bin/rpcgen/rpc_tblout.c
index 8df03cfed8b..e2337cd79c1 100644
--- a/usr.bin/rpcgen/rpc_tblout.c
+++ b/usr.bin/rpcgen/rpc_tblout.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rpc_tblout.c,v 1.9 2002/06/01 01:40:38 deraadt Exp $ */
+/* $OpenBSD: rpc_tblout.c,v 1.10 2002/07/05 05:39:42 deraadt Exp $ */
/* $NetBSD: rpc_tblout.c,v 1.3 1995/06/24 15:00:15 pk Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@@ -39,6 +39,7 @@ static char sccsid[] = "@(#)rpc_tblout.c 1.4 89/02/22 (C) 1988 SMI";
*/
#include <sys/cdefs.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include "rpc_parse.h"
#include "rpc_util.h"
@@ -149,7 +150,7 @@ printit(prefix, type)
{
int len, tabs;
- len = fprintf(fout, "\txdr_%s,", stringfix(type));
+ len = fprintf(fout, "\txdr_%s,", stringfix(type));
/* account for leading tab expansion */
len += TABSIZE - 1;
/* round up to tabs required */
diff --git a/usr.bin/rpcgen/rpc_util.c b/usr.bin/rpcgen/rpc_util.c
index ee41487f56e..528ade2106c 100644
--- a/usr.bin/rpcgen/rpc_util.c
+++ b/usr.bin/rpcgen/rpc_util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rpc_util.c,v 1.9 2002/06/01 01:40:38 deraadt Exp $ */
+/* $OpenBSD: rpc_util.c,v 1.10 2002/07/05 05:39:42 deraadt Exp $ */
/* $NetBSD: rpc_util.c,v 1.6 1995/08/29 23:05:57 cgd Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@@ -119,8 +119,13 @@ storeval(lstp, val)
list **l;
list *lst;
- for (l = lstp; *l != NULL; l = (list **) & (*l)->next);
+ for (l = lstp; *l != NULL; l = (list **) & (*l)->next)
+ ;
lst = ALLOC(list);
+ if (lst == NULL) {
+ fprintf(stderr, "failed in alloc\n");
+ exit(1);
+ }
lst->val = val;
lst->next = NULL;
*l = lst;
@@ -200,11 +205,10 @@ typedefed(def, type)
definition *def;
char *type;
{
- if (def->def_kind != DEF_TYPEDEF || def->def.ty.old_prefix != NULL) {
+ if (def->def_kind != DEF_TYPEDEF || def->def.ty.old_prefix != NULL)
return (0);
- } else {
+ else
return (streq(def->def_name, type));
- }
}
int
@@ -224,9 +228,8 @@ isvectordef(type, rel)
return (0);
case REL_ALIAS:
def = (definition *) FINDVAL(defined, type, typedefed);
- if (def == NULL) {
+ if (def == NULL)
return (0);
- }
type = def->def.ty.old_type;
rel = def->def.ty.rel;
}
@@ -241,9 +244,8 @@ locase(str)
static char buf[100];
char *p = buf;
- while ((c = *str++)) {
+ while ((c = *str++))
*p++ = (c >= 'A' && c <= 'Z') ? (c - 'A' + 'a') : c;
- }
*p = 0;
return (buf);
}
@@ -315,7 +317,7 @@ expected1(exp1)
tok_kind exp1;
{
snprintf(expectbuf, sizeof expectbuf, "expected '%s'",
- toktostr(exp1));
+ toktostr(exp1));
error(expectbuf);
}
@@ -327,8 +329,7 @@ expected2(exp1, exp2)
tok_kind exp1, exp2;
{
snprintf(expectbuf, sizeof expectbuf, "expected '%s' or '%s'",
- toktostr(exp1),
- toktostr(exp2));
+ toktostr(exp1), toktostr(exp2));
error(expectbuf);
}
@@ -340,9 +341,7 @@ expected3(exp1, exp2, exp3)
tok_kind exp1, exp2, exp3;
{
snprintf(expectbuf, sizeof expectbuf, "expected '%s', '%s' or '%s'",
- toktostr(exp1),
- toktostr(exp2),
- toktostr(exp3));
+ toktostr(exp1), toktostr(exp2), toktostr(exp3));
error(expectbuf);
}
@@ -399,7 +398,8 @@ toktostr(kind)
{
token *sp;
- for (sp = tokstrings; sp->kind != TOK_EOF && sp->kind != kind; sp++);
+ for (sp = tokstrings; sp->kind != TOK_EOF && sp->kind != kind; sp++)
+ ;
return (sp->str);
}
@@ -457,7 +457,7 @@ make_argname(pname, vname)
name = (char *)malloc(len);
if (!name) {
- fprintf(stderr, "failed in malloc");
+ fprintf(stderr, "failed in malloc\n");
exit(1);
}
snprintf(name, len, "%s_%s_%s", locase(pname), vname, ARGEXT);
@@ -468,26 +468,26 @@ bas_type *typ_list_h;
bas_type *typ_list_t;
void
-add_type(len,type)
+add_type(len, type)
int len;
char *type;
{
bas_type *ptr;
if ((ptr = (bas_type *)malloc(sizeof(bas_type))) == (bas_type *)NULL) {
- fprintf(stderr, "failed in malloc");
+ fprintf(stderr, "failed in malloc\n");
exit(1);
}
- ptr->name=type;
- ptr->length=len;
- ptr->next=NULL;
+ ptr->name = type;
+ ptr->length = len;
+ ptr->next = NULL;
if (typ_list_t == NULL) {
- typ_list_t=ptr;
- typ_list_h=ptr;
+ typ_list_t = ptr;
+ typ_list_h = ptr;
} else {
- typ_list_t->next=ptr;
- typ_list_t=ptr;
+ typ_list_t->next = ptr;
+ typ_list_t = ptr;
}
}
@@ -500,10 +500,10 @@ find_type(type)
ptr = typ_list_h;
while (ptr != NULL) {
- if (strcmp(ptr->name,type) == 0)
+ if (strcmp(ptr->name, type) == 0)
return(ptr);
else
- ptr=ptr->next;
+ ptr = ptr->next;
}
return(NULL);
}
diff --git a/usr.bin/rpcgen/rpc_util.h b/usr.bin/rpcgen/rpc_util.h
index 2d2f8079278..a9cc50f12b2 100644
--- a/usr.bin/rpcgen/rpc_util.h
+++ b/usr.bin/rpcgen/rpc_util.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rpc_util.h,v 1.10 2002/06/01 01:40:38 deraadt Exp $ */
+/* $OpenBSD: rpc_util.h,v 1.11 2002/07/05 05:39:42 deraadt Exp $ */
/* $NetBSD: rpc_util.h,v 1.3 1995/06/11 21:50:10 pk Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@@ -154,3 +154,6 @@ void write_tables(void);
void write_sample_svc(definition *);
int write_sample_clnt(definition *);
void write_sample_clnt_main(void);
+
+void add_type(int len, char *type);
+