summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>2001-11-24 19:19:59 +0000
committerderaadt <deraadt@openbsd.org>2001-11-24 19:19:59 +0000
commitba80c6ddc9cdd09f02951d75a5ce96ed0c834157 (patch)
tree6050eea33378c51712dd83cb5024bedb5d8c1ee2
parenthalf finished KNF (diff)
downloadwireguard-openbsd-ba80c6ddc9cdd09f02951d75a5ce96ed0c834157.tar.xz
wireguard-openbsd-ba80c6ddc9cdd09f02951d75a5ce96ed0c834157.zip
argh! i messed something up!
-rw-r--r--usr.bin/rpcgen/rpc_clntout.c33
-rw-r--r--usr.bin/rpcgen/rpc_cout.c129
-rw-r--r--usr.bin/rpcgen/rpc_hout.c205
-rw-r--r--usr.bin/rpcgen/rpc_main.c80
-rw-r--r--usr.bin/rpcgen/rpc_parse.c14
-rw-r--r--usr.bin/rpcgen/rpc_parse.h4
-rw-r--r--usr.bin/rpcgen/rpc_sample.c143
-rw-r--r--usr.bin/rpcgen/rpc_scan.c81
-rw-r--r--usr.bin/rpcgen/rpc_svcout.c251
-rw-r--r--usr.bin/rpcgen/rpc_tblout.c49
-rw-r--r--usr.bin/rpcgen/rpc_util.c24
-rw-r--r--usr.bin/rpcgen/rpc_util.h3
12 files changed, 540 insertions, 476 deletions
diff --git a/usr.bin/rpcgen/rpc_clntout.c b/usr.bin/rpcgen/rpc_clntout.c
index d3367a58c80..35498981b92 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.6 2001/11/24 19:17:47 deraadt Exp $ */
+/* $OpenBSD: rpc_clntout.c,v 1.7 2001/11/24 19:19:59 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
@@ -44,10 +44,10 @@ static char sccsid[] = "@(#)rpc_clntout.c 1.11 89/02/22 (C) 1987 SMI";
#include "rpc_parse.h"
#include "rpc_util.h"
-static void write_program __P((definition *));
+static write_program __P((definition *));
static void printbody __P((proc_list *));
-extern void pdeclaration();
+extern pdeclaration();
#define DEFAULT_TIMEOUT 25 /* in seconds */
static char RESULT[] = "clnt_res";
@@ -59,7 +59,7 @@ write_stubs()
list *l;
definition *def;
- f_print(fout,
+ f_print(fout,
"\n/* Default timeout can be changed using clnt_control() */\n");
f_print(fout, "static struct timeval TIMEOUT = { %d, 0 };\n",
DEFAULT_TIMEOUT);
@@ -71,7 +71,7 @@ write_stubs()
}
}
-static void
+static
write_program(def)
definition *def;
{
@@ -117,17 +117,17 @@ void printarglist( proc, addargname, addargtype )
ptype(proc->args.decls->decl.prefix, proc->args.decls->decl.type, 1);
f_print(fout, "*argp;\n");
}
- } else if (streq( proc->args.decls->decl.type, "void")) {
+ } else if (streq( proc->args.decls->decl.type, "void")) {
/* newstyle, 0 argument */
- if (Cflag)
+ if( Cflag )
f_print(fout, "(%s%s)\n", addargtype, addargname );
else
f_print(fout, "(%s)\n", addargname);
} else {
/* new style, 1 or multiple arguments */
- if (!Cflag) {
+ if( !Cflag ) {
f_print(fout, "(");
- for (l = proc->args.decls; l != NULL; l = l->next)
+ for (l = proc->args.decls; l != NULL; l = l->next)
f_print(fout, "%s, ", l->decl.name);
f_print(fout, "%s)\n", addargname );
for (l = proc->args.decls; l != NULL; l = l->next) {
@@ -142,7 +142,7 @@ void printarglist( proc, addargname, addargtype )
}
}
- if (!Cflag)
+ if( !Cflag )
f_print(fout, "\t%s%s;\n", addargtype, addargname );
}
@@ -165,12 +165,13 @@ printbody(proc)
{
decl_list *l;
bool_t args2 = (proc->arg_num > 1);
+ int i;
/* For new style with multiple arguments, need a structure in which
to stuff the arguments. */
if ( newstyle && args2) {
f_print(fout, "\t%s", proc->args.argname);
- f_print(fout, " arg;\n");
+ f_print(fout, " arg;\n");
}
f_print(fout, "\tstatic ");
if (streq(proc->res_type, "void")) {
@@ -186,7 +187,7 @@ printbody(proc)
/* newstyle, 0 arguments */
f_print(fout,
"\tif (clnt_call(clnt, %s, xdr_void", proc->proc_name);
- f_print(fout,
+ f_print(fout,
", NULL, xdr_%s, %s%s, TIMEOUT) != RPC_SUCCESS) {\n",
stringfix(proc->res_type), ampr(proc->res_type), RESULT);
@@ -199,15 +200,15 @@ printbody(proc)
f_print(fout,
"\tif (clnt_call(clnt, %s, xdr_%s", proc->proc_name,
proc->args.argname);
- f_print(fout,
+ f_print(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 */
f_print(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),
+ proc->proc_name,
+ stringfix(proc->args.decls->decl.type),
(newstyle ? "&" : ""),
(newstyle ? proc->args.decls->decl.name : "argp"),
stringfix(proc->res_type),
@@ -216,7 +217,7 @@ printbody(proc)
f_print(fout, "\t\treturn (NULL);\n");
f_print(fout, "\t}\n");
if (streq(proc->res_type, "void")) {
- f_print(fout, "\treturn ((void *)%s%s);\n",
+ f_print(fout, "\treturn ((void *)%s%s);\n",
ampr(proc->res_type),RESULT);
} else {
f_print(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 e7993338607..403b8e33103 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.8 2001/11/24 19:17:47 deraadt Exp $ */
+/* $OpenBSD: rpc_cout.c,v 1.9 2001/11/24 19:19:59 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
@@ -41,30 +41,28 @@ static char sccsid[] = "@(#)rpc_cout.c 1.13 89/02/22 (C) 1987 SMI";
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <ctype.h>
#include "rpc_parse.h"
#include "rpc_util.h"
-static int findtype __P((definition *, char *));
-static int undefined __P((char *));
-static void print_generic_header __P((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, char *));
-static void print_ifarg __P((char *));
-static void print_ifsizeof __P((char *, char *));
-static void print_ifclose __P((int));
-static void print_ifstat __P((int, char *, char *, relation, char *, char *, char *));
-static void emit_num __P((definition *));
-static void emit_program __P((definition *));
-static void emit_enum __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 *));
-void emit_inline __P((declaration *, int));
-void emit_single_in_line __P((declaration *, int, relation));
+static findtype __P((definition *, char *));
+static undefined __P((char *));
+static print_generic_header __P((char *, int));
+static print_header __P((definition *));
+static print_prog_header __P((proc_list *));
+static print_trailer __P((void));
+static print_ifopen __P((int, char *));
+static print_ifarg __P((char *));
+static print_ifsizeof __P((char *, char *));
+static print_ifclose __P((int));
+static print_ifstat __P((int, char *, char *, relation, char *, char *, char *));
+static emit_num __P((definition *));
+static emit_program __P((definition *));
+static emit_enum __P((definition *));
+static emit_union __P((definition *));
+static emit_struct __P((definition *));
+static emit_typedef __P((definition *));
+static print_stat __P((int, declaration *));
+
/*
* Emit the C-routine for the given definition
@@ -107,10 +105,10 @@ emit(def)
print_trailer();
}
-static int
+static
findtype(def, type)
definition *def;
- char *type;
+ char *type;
{
if (def->def_kind == DEF_PROGRAM || def->def_kind == DEF_CONST) {
@@ -120,20 +118,22 @@ findtype(def, type)
}
}
-static int
+static
undefined(type)
- char *type;
+ char *type;
{
definition *def;
def = (definition *) FINDVAL(defined, type, findtype);
+
+
return (def == NULL);
}
-static void
+static
print_generic_header(procname, pointerp)
- char *procname;
- int pointerp;
+ char *procname;
+ int pointerp;
{
f_print(fout, "\n");
f_print(fout, "bool_t\n");
@@ -154,37 +154,46 @@ print_generic_header(procname, pointerp)
}
}
-static void
+static
print_header(def)
definition *def;
{
+
+ decl_list *dl;
+ bas_type *ptr;
+ int i;
+
+
print_generic_header(def->def_name,
def->def_kind != DEF_TYPEDEF ||
!isvectordef(def->def.ty.old_type, def->def.ty.rel));
/* Now add Inline support */
+
if (doinline == 0)
return;
/* May cause lint to complain. but ... */
f_print(fout, "\tint32_t *buf;\n\n");
+
}
-static void
+static
print_prog_header(plist)
proc_list *plist;
{
print_generic_header(plist->args.argname, 1);
}
-static void
+static
print_trailer()
{
f_print(fout, "\treturn (TRUE);\n");
f_print(fout, "}\n");
}
-static void
+
+static
print_ifopen(indent, name)
int indent;
char *name;
@@ -193,14 +202,14 @@ print_ifopen(indent, name)
f_print(fout, "if (!xdr_%s(xdrs", name);
}
-static void
+static
print_ifarg(arg)
char *arg;
{
f_print(fout, ", %s", arg);
}
-static void
+static
print_ifsizeof(prefix, type)
char *prefix;
char *type;
@@ -216,7 +225,7 @@ print_ifsizeof(prefix, type)
}
}
-static void
+static
print_ifclose(indent)
int indent;
{
@@ -227,7 +236,7 @@ print_ifclose(indent)
f_print(fout, "}\n");
}
-static void
+static
print_ifstat(indent, prefix, type, rel, amax, objname, name)
int indent;
char *prefix;
@@ -305,7 +314,7 @@ print_ifstat(indent, prefix, type, rel, amax, objname, name)
}
/* ARGSUSED */
-static void
+static
emit_enum(def)
definition *def;
{
@@ -314,7 +323,7 @@ emit_enum(def)
print_ifclose(1);
}
-static void
+static
emit_program(def)
definition *def;
{
@@ -335,7 +344,8 @@ emit_program(def)
}
}
-static void
+
+static
emit_union(def)
definition *def;
{
@@ -349,6 +359,7 @@ emit_union(def)
print_stat(1, &def->def.un.enum_decl);
f_print(fout, "\tswitch (objp->%s) {\n", def->def.un.enum_decl.name);
for (cl = def->def.un.cases; cl != NULL; cl = cl->next) {
+
f_print(fout, "\tcase %s:\n", cl->case_name);
if (cl->contflag == 1) /* a continued case statement */
continue;
@@ -396,7 +407,7 @@ emit_union(def)
f_print(fout, "\t}\n");
}
-static void
+static
emit_struct(def)
definition *def;
{
@@ -408,6 +419,7 @@ emit_struct(def)
char ptemp[256];
int can_inline;
+
if (doinline == 0) {
for (dl = def->def.st.decls; dl != NULL; dl = dl->next)
print_stat(1, &dl->decl);
@@ -424,6 +436,7 @@ emit_struct(def)
if ((dl->decl.prefix == NULL) &&
((ptr = find_type(dl->decl.type)) != NULL) &&
((dl->decl.rel == REL_ALIAS) || (dl->decl.rel == REL_VECTOR))) {
+
if (dl->decl.rel == REL_ALIAS)
size += ptr->length;
else {
@@ -446,13 +459,18 @@ emit_struct(def)
return;
}
+
+
+
flag = PUT;
for (j = 0; j < 2; j++) {
+
if (flag == PUT)
f_print(fout, "\n\tif (xdrs->x_op == XDR_ENCODE) {\n");
else
f_print(fout, "\t\treturn (TRUE);\n\t} else if (xdrs->x_op == XDR_DECODE) {\n");
+
i = 0;
size = 0;
sizestr = NULL;
@@ -485,6 +503,7 @@ emit_struct(def)
else {
sizestr = (char *)realloc(sizestr, strlen(sizestr) + strlen(ptemp) + 1);
if (sizestr == NULL) {
+
f_print(stderr, "Fatal error : no memory\n");
crash();
}
@@ -495,7 +514,7 @@ emit_struct(def)
}
} else {
- if (i > 0) {
+ if (i > 0)
if (sizestr == NULL && size < doinline) {
/* don't expand into inline
* code if size < doinline */
@@ -504,6 +523,9 @@ emit_struct(def)
cur = cur->next;
}
} else {
+
+
+
/* were already looking at a
* xdr_inlineable structure */
if (sizestr == NULL)
@@ -537,7 +559,6 @@ emit_struct(def)
f_print(fout, "\t\t}\n");
}
- }
size = 0;
i = 0;
sizestr = NULL;
@@ -545,7 +566,7 @@ emit_struct(def)
}
}
- if (i > 0) {
+ if (i > 0)
if (sizestr == NULL && size < doinline) {
/* don't expand into inline code if size <
* doinline */
@@ -554,6 +575,7 @@ emit_struct(def)
cur = cur->next;
}
} else {
+
/* were already looking at a xdr_inlineable
* structure */
if (sizestr == NULL)
@@ -588,7 +610,6 @@ emit_struct(def)
}
flag = GET;
- }
}
f_print(fout, "\t\treturn (TRUE);\n\t}\n\n");
@@ -598,7 +619,7 @@ emit_struct(def)
print_stat(1, &dl->decl);
}
-static void
+static
emit_typedef(def)
definition *def;
{
@@ -607,10 +628,11 @@ emit_typedef(def)
char *amax = def->def.ty.array_max;
relation rel = def->def.ty.rel;
+
print_ifstat(1, prefix, type, rel, amax, "objp", def->def_name);
}
-static void
+static
print_stat(indent, dec)
declaration *dec;
int indent;
@@ -629,14 +651,16 @@ print_stat(indent, dec)
print_ifstat(indent, prefix, type, rel, amax, name, dec->name);
}
+
char *upcase __P((char *));
-void
+
emit_inline(decl, flag)
declaration *decl;
int flag;
{
- /*check whether an array or not */
+
+/*check whether an array or not */
switch (decl->rel) {
case REL_ALIAS:
@@ -653,7 +677,6 @@ emit_inline(decl, flag)
}
}
-void
emit_single_in_line(decl, flag, rel)
declaration *decl;
int flag;
@@ -662,6 +685,8 @@ emit_single_in_line(decl, flag, rel)
char *upp_case;
int freed = 0;
+
+
if (flag == PUT)
f_print(fout, "\t\tIXDR_PUT_");
else
@@ -693,14 +718,17 @@ emit_single_in_line(decl, flag, rel)
f_print(fout, "%s(buf);\n", upp_case);
if (!freed)
free(upp_case);
+
}
+
char *
upcase(str)
char *str;
{
char *ptr, *hptr;
+
ptr = (char *) malloc(strlen(str)+1);
if (ptr == (char *) NULL) {
f_print(stderr, "malloc failed\n");
@@ -713,4 +741,5 @@ upcase(str)
*ptr = '\0';
return (hptr);
+
}
diff --git a/usr.bin/rpcgen/rpc_hout.c b/usr.bin/rpcgen/rpc_hout.c
index fc76b6e9a9d..bf180536c9c 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.7 2001/11/24 19:17:47 deraadt Exp $ */
+/* $OpenBSD: rpc_hout.c,v 1.8 2001/11/24 19:19:59 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
@@ -43,21 +43,18 @@ static char sccsid[] = "@(#)rpc_hout.c 1.12 89/02/22 (C) 1987 SMI";
#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 pprogramdef __P((definition *));
-static void penumdef __P((definition *));
-static void ptypedef __P((definition *));
-static void pdefine __P((char *, char *));
-static void puldefine __P((char *, char *));
-static int define_printed __P((proc_list *, version_list *));
-static int undefined2 __P((char *, char *));
-static void parglist __P((proc_list *, char *));
-void pxdrfuncdecl(char *, int);
-void pprocdef(proc_list *, version_list *, char *, int, int);
-void pdeclaration(char *, declaration *, int, char *);
+static pconstdef __P((definition *));
+static pargdef __P((definition *));
+static pstructdef __P((definition *));
+static puniondef __P((definition *));
+static pprogramdef __P((definition *));
+static penumdef __P((definition *));
+static ptypedef __P((definition *));
+static pdefine __P((char *, char *));
+static puldefine __P((char *, char *));
+static define_printed __P((proc_list *, version_list *));
+static undefined2 __P((char *, char *));
+static parglist __P((proc_list *, char *));
/*
* Print the C-version of an xdr definition
@@ -67,11 +64,12 @@ print_datadef(def)
definition *def;
{
- if (def->def_kind == DEF_PROGRAM) /* handle data only */
+ if (def->def_kind == DEF_PROGRAM ) /* handle data only */
return;
- if (def->def_kind != DEF_CONST)
+ if (def->def_kind != DEF_CONST) {
f_print(fout, "\n");
+ }
switch (def->def_kind) {
case DEF_STRUCT:
pstructdef(def);
@@ -93,9 +91,10 @@ print_datadef(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));
+ pxdrfuncdecl( def->def_name,
+ def->def_kind != DEF_TYPEDEF ||
+ !isvectordef(def->def.ty.old_type, def->def.ty.rel));
+
}
}
@@ -109,28 +108,29 @@ print_funcdef(def)
f_print(fout, "\n");
pprogramdef(def);
break;
- }
+ }
}
-void
-pxdrfuncdecl(name, pointerp)
- char *name;
- int pointerp;
+pxdrfuncdecl( name, pointerp )
+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 defined(__STDC__)\n");
- f_print(fout, "extern 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");
+ 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 defined(__STDC__)\n");
+ f_print(fout, "extern 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");
}
-static void
+static
pconstdef(def)
definition *def;
{
@@ -140,7 +140,7 @@ pconstdef(def)
/* print out the definitions for the arguments of functions in the
header file
*/
-static void
+static
pargdef(def)
definition *def;
{
@@ -149,41 +149,46 @@ pargdef(def)
char *name;
proc_list *plist;
+
for (vers = def->def.pr.versions; vers != NULL; vers = vers->next) {
- for(plist = vers->procs; plist != NULL;
- plist = plist->next) {
- if (!newstyle || plist->arg_num < 2) {
- continue; /* old style or single args */
- }
- name = plist->args.argname;
- f_print(fout, "struct %s {\n", name);
- for (l = plist->args.decls;
- l != NULL; l = l->next) {
- pdeclaration(name, &l->decl, 1, ";\n");
+ for(plist = vers->procs; plist != NULL;
+ plist = plist->next) {
+
+ if (!newstyle || plist->arg_num < 2) {
+ continue; /* old style or single args */
+ }
+ name = plist->args.argname;
+ f_print(fout, "struct %s {\n", name);
+ for (l = plist->args.decls;
+ l != NULL; l = l->next) {
+ pdeclaration(name, &l->decl, 1, ";\n" );
+ }
+ f_print(fout, "};\n");
+ f_print(fout, "typedef struct %s %s;\n", name, name);
+ pxdrfuncdecl( name,NULL );
+ f_print( fout, "\n" );
}
- f_print(fout, "};\n");
- f_print(fout, "typedef struct %s %s;\n", name, name);
- pxdrfuncdecl(name, NULL);
- f_print(fout, "\n");
}
- }
+
}
-static void
+
+static
pstructdef(def)
definition *def;
{
- char *name = def->def_name;
decl_list *l;
+ char *name = def->def_name;
f_print(fout, "struct %s {\n", name);
- for (l = def->def.st.decls; l != NULL; l = l->next)
+ for (l = def->def.st.decls; l != NULL; l = l->next) {
pdeclaration(name, &l->decl, 1, ";\n");
+ }
f_print(fout, "};\n");
f_print(fout, "typedef struct %s %s;\n", name, name);
}
-static void
+static
puniondef(def)
definition *def;
{
@@ -200,19 +205,19 @@ puniondef(def)
}
f_print(fout, "\tunion {\n");
for (l = def->def.un.cases; l != NULL; l = l->next) {
- if (l->contflag == 0)
- pdeclaration(name, &l->case_decl, 2, ";\n");
+ if(l->contflag == 0)
+ pdeclaration(name, &l->case_decl, 2, ";\n" );
}
decl = def->def.un.default_decl;
if (decl && !streq(decl->type, "void")) {
- pdeclaration(name, decl, 2, ";\n");
+ pdeclaration(name, decl, 2, ";\n" );
}
f_print(fout, "\t} %s_u;\n", name);
f_print(fout, "};\n");
f_print(fout, "typedef struct %s %s;\n", name, name);
}
-static void
+static
pdefine(name, num)
char *name;
char *num;
@@ -220,7 +225,7 @@ pdefine(name, num)
f_print(fout, "#define %s %s\n", name, num);
}
-static void
+static
puldefine(name, num)
char *name;
char *num;
@@ -228,7 +233,7 @@ puldefine(name, num)
f_print(fout, "#define %s ((u_long)%s)\n", name, num);
}
-static int
+static
define_printed(stop, start)
proc_list *stop;
version_list *start;
@@ -249,7 +254,7 @@ define_printed(stop, start)
/* NOTREACHED */
}
-static void
+static
pprogramdef(def)
definition *def;
{
@@ -257,16 +262,16 @@ pprogramdef(def)
proc_list *proc;
int i;
char *ext;
-
+
pargdef(def);
puldefine(def->def_name, def->def.pr.prog_num);
for (vers = def->def.pr.versions; vers != NULL; vers = vers->next) {
if (tblflag) {
f_print(fout, "extern struct rpcgen_table %s_%s_table[];\n",
- locase(def->def_name), vers->vers_num);
+ locase(def->def_name), vers->vers_num);
f_print(fout, "extern %s_%s_nproc;\n",
- locase(def->def_name), vers->vers_num);
+ locase(def->def_name), vers->vers_num);
}
puldefine(vers->vers_name, vers->vers_num);
@@ -274,43 +279,47 @@ 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++) {
- if (i==0) {
+
+ for(i=0;i<3;i++){
+ if(i==0){
f_print(fout,"\n#ifdef __cplusplus\n");
- ext = "extern \"C\" ";
- } else if (i==1) {
+ ext="extern \"C\" ";
+ }else if ( i== 1){
f_print(fout,"\n#elif defined(__STDC__)\n");
- ext = "extern ";
- } else {
+ ext="extern " ;
+ }else{
f_print(fout,"\n#else /* Old Style C */\n");
- ext = "extern ";
+ ext="extern ";
}
-
+
+
for (proc = vers->procs; proc != NULL; proc = proc->next) {
- if (!define_printed(proc, def->def.pr.versions))
+ 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);
+
}
+
}
f_print(fout,"#endif /* Old Style C */\n");
}
}
-void
pprocdef(proc, vp, addargtype, server_p,mode)
proc_list *proc;
version_list *vp;
- char *addargtype;
+ char* addargtype;
int server_p;
int mode;
{
- ptype(proc->res_prefix, proc->res_type, 1);
- f_print(fout, "* ");
- if (server_p)
+ ptype( proc->res_prefix, proc->res_type, 1 );
+ f_print( fout, "* " );
+ if( server_p )
pvname_svc(proc->proc_name, vp->vers_num);
else
pvname(proc->proc_name, vp->vers_num);
@@ -318,37 +327,40 @@ pprocdef(proc, vp, addargtype, server_p,mode)
/*
* mode 0 == cplusplus, mode 1 = ANSI-C, mode 2 = old style C
*/
- if (mode == 0 || mode == 1)
- parglist(proc, addargtype);
+ if(mode == 0 || mode ==1)
+ parglist( proc, addargtype );
else
f_print(fout, "();\n");
}
+
/* print out argument list of procedure */
-static void
+static
parglist(proc, addargtype)
proc_list *proc;
- char *addargtype;
+ char* addargtype;
{
decl_list *dl;
f_print(fout,"(");
- if (proc->arg_num < 2 && newstyle &&
- streq(proc->args.decls->decl.type, "void")) {
+ 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, "*"); /* old style passes by reference */
- f_print(fout, ", ");
+ ptype( dl->decl.prefix, dl->decl.type, 1 );
+ if( !newstyle )
+ f_print( fout, "*" ); /* old style passes by reference */
+
+ f_print( fout, ", " );
}
}
+
f_print(fout, "%s);\n", addargtype);
}
-static void
+static
penumdef(def)
definition *def;
{
@@ -380,7 +392,7 @@ penumdef(def)
f_print(fout, "typedef enum %s %s;\n", name, name);
}
-static void
+static
ptypedef(def)
definition *def;
{
@@ -389,6 +401,7 @@ ptypedef(def)
char prefix[8]; /* enough to contain "struct ", including NUL */
relation rel = def->def.ty.rel;
+
if (!streq(name, old)) {
if (streq(old, "string")) {
old = "char";
@@ -426,7 +439,6 @@ ptypedef(def)
}
}
-void
pdeclaration(name, dec, tab, separator)
char *name;
declaration *dec;
@@ -437,8 +449,9 @@ pdeclaration(name, dec, tab, separator)
char *prefix;
char *type;
- if (streq(dec->type, "void"))
+ if (streq(dec->type, "void")) {
return;
+ }
tabify(fout, tab);
if (streq(dec->type, name) && !dec->prefix) {
f_print(fout, "struct ");
@@ -480,10 +493,10 @@ pdeclaration(name, dec, tab, separator)
break;
}
}
- f_print(fout, separator);
+ f_print(fout, separator );
}
-static int
+static
undefined2(type, stop)
char *type;
char *stop;
diff --git a/usr.bin/rpcgen/rpc_main.c b/usr.bin/rpcgen/rpc_main.c
index ec39fac49c1..df5c8aa4ed8 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.9 2001/11/24 19:17:47 deraadt Exp $ */
+/* $OpenBSD: rpc_main.c,v 1.10 2001/11/24 19:19:59 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.9 2001/11/24 19:17:47 deraadt Exp $";
+static char cvsid[] = "$OpenBSD: rpc_main.c,v 1.10 2001/11/24 19:19:59 deraadt Exp $";
#endif
/*
@@ -203,7 +203,7 @@ main(argc, argv)
if (allfiles) {
reinitialize();
clnt_output(cmd.infile, "-DRPC_CLIENT", EXTEND, "_client.c");
- }
+ }
}
#ifdef __MSDOS__
if (dos_cppfile != NULL) {
@@ -297,13 +297,13 @@ static void find_cpp()
{
struct stat buf;
- if (stat(CPP, &buf) < 0 ) { /* SVR4 or explicit cpp does not exist */
+ if( stat(CPP, &buf) < 0 ) { /* SVR4 or explicit cpp does not exist */
if (cppDefined) {
fprintf( stderr, "cannot find C preprocessor: %s \n", CPP );
crash();
} else { /* try the other one */
CPP = SUNOS_CPP;
- if (stat( CPP, &buf ) < 0 ) { /* can't find any cpp */
+ if( stat( CPP, &buf ) < 0 ) { /* can't find any cpp */
fprintf( stderr, "cannot find any C preprocessor: %s\n", CPP );
crash();
}
@@ -392,7 +392,7 @@ open_input(infile, define)
}
/* valid tirpc nettypes */
-static char *valid_ti_nettypes[] =
+static char* valid_ti_nettypes[] =
{
"netpath",
"visible",
@@ -407,7 +407,7 @@ static char *valid_ti_nettypes[] =
};
/* valid inetd nettypes */
-static char *valid_i_nettypes[] =
+static char* valid_i_nettypes[] =
{
"udp",
"tcp",
@@ -415,16 +415,17 @@ static char *valid_i_nettypes[] =
};
static int check_nettype( name, list_to_check )
-char *name;
-char *list_to_check[];
+char* name;
+char* list_to_check[];
{
- int i;
- for( i = 0; list_to_check[i] != NULL; i++ ) {
- if (strcmp( name, list_to_check[i] ) == 0)
- return 1;
- }
- f_print(stderr, "illegal nettype :\'%s\'\n", name);
- return 0;
+ int i;
+ for( i = 0; list_to_check[i] != NULL; i++ ) {
+ if( strcmp( name, list_to_check[i] ) == 0 ) {
+ return 1;
+ }
+ }
+ f_print( stderr, "illegal nettype :\'%s\'\n", name );
+ return 0;
}
/*
@@ -444,7 +445,7 @@ c_output(infile, define, extend, outfile)
long tell;
c_initialize();
- open_input(infile, define);
+ open_input(infile, define);
outfilename = extend ? extendfile(infile, outfile) : outfile;
open_output(infile, outfilename);
add_warning();
@@ -489,10 +490,10 @@ char rpcgen_table_dcl[] = "struct rpcgen_table {\n\
};\n";
-char *generate_guard( pathname )
- char *pathname;
+char* generate_guard( pathname )
+ char* pathname;
{
- char *filename, *guard, *tmp;
+ char* filename, *guard, *tmp;
filename = strrchr(pathname, '/' ); /* find last component */
filename = ((filename == 0) ? pathname : filename+1);
@@ -504,7 +505,7 @@ char *generate_guard( pathname )
*tmp = toupper(*tmp);
tmp++;
}
-
+
guard = extendfile(guard, "_H_RPCGEN");
return( guard );
}
@@ -604,17 +605,17 @@ s_output(argc, argv, infile, define, extend, outfile, nomain, netflag)
timerflag = 1;
}
- if (!tirpcflag && inetdflag)
+ if( !tirpcflag && inetdflag )
f_print(fout, "#include <sys/ttycom.h>/* TIOCNOTTY */\n");
- if (Cflag && (inetdflag || pmflag )) {
+ if( Cflag && (inetdflag || pmflag ) ) {
f_print(fout, "#ifdef __cplusplus\n");
f_print(fout, "#include <sysent.h> /* getdtablesize, open */\n");
f_print(fout, "#endif /* __cplusplus */\n");
- if (tirpcflag)
+ if( tirpcflag )
f_print(fout, "#include <unistd.h> /* setsid */\n");
}
- if (tirpcflag)
+ if( tirpcflag )
f_print(fout, "#include <sys/types.h>\n");
f_print(fout, "#include <memory.h>\n");
@@ -653,7 +654,7 @@ s_output(argc, argv, infile, define, extend, outfile, nomain, netflag)
f_print(fout, "\nstatic SVCXPRT *caller;\n"); /*EVAS*/
write_most(infile, netflag, nomain);
if (!nomain) {
- if (!do_registers(argc, argv)) {
+ if( !do_registers(argc, argv) ) {
if (outfilename)
(void) unlink(outfilename);
usage();
@@ -739,7 +740,7 @@ svc_output(infile, define, extend, outfile)
char *outfilename;
long tell;
- open_input(infile, define);
+ open_input(infile, define);
outfilename = extend ? extendfile(infile, outfile) : outfile;
checkfiles(infile,outfilename); /*check if outfile already exists.
if so, print an error message and exit*/
@@ -776,7 +777,7 @@ clnt_output(infile, define, extend, outfile)
long tell;
int has_program = 0;
- open_input(infile, define);
+ open_input(infile, define);
outfilename = extend ? extendfile(infile, outfile) : outfile;
checkfiles(infile,outfilename); /*check if outfile already exists.
if so, print an error message and exit*/
@@ -793,7 +794,7 @@ clnt_output(infile, define, extend, outfile)
has_program += write_sample_clnt(def);
}
- if (has_program)
+ if( has_program )
write_sample_clnt_main();
if (extend && tell == ftell(fout)) {
@@ -815,7 +816,7 @@ int do_registers(argc, argv)
if ( inetdflag || !tirpcflag) {
for (i = 1; i < argc; i++) {
if (streq(argv[i], "-s")) {
- if (!check_nettype( argv[i + 1], valid_i_nettypes ))
+ if(!check_nettype( argv[i + 1], valid_i_nettypes ))
return 0;
write_inetd_register(argv[i + 1]);
i++;
@@ -824,7 +825,7 @@ int do_registers(argc, argv)
} else {
for (i = 1; i < argc; i++)
if (streq(argv[i], "-s")) {
- if (!check_nettype( argv[i + 1], valid_ti_nettypes ))
+ if(!check_nettype( argv[i + 1], valid_ti_nettypes ))
return 0;
write_nettype_register(argv[i + 1]);
i++;
@@ -863,6 +864,7 @@ putarg(where, cp)
/*NOTREACHED*/
}
arglist[where] = cp;
+
}
/*
@@ -879,8 +881,8 @@ char *outfile;
struct stat buf;
- if (infile) /* infile ! = NULL */
- if (stat(infile,&buf) < 0)
+ if(infile) /* infile ! = NULL */
+ if(stat(infile,&buf) < 0)
{
perror(infile);
crash();
@@ -962,9 +964,9 @@ parseargs(argc, argv, cmd)
Ss means set flag['S'];
Sc means set flag['C']; */
c = argv[i][++j]; /* get next char */
- if(c == 's')
+ if( c == 's' )
c = 'S';
- else if(c == 'c')
+ else if( c == 'c' )
c = 'C';
else
return( 0 );
@@ -1069,22 +1071,22 @@ parseargs(argc, argv, cmd)
cmd->Ssflag = flag['S'];
cmd->Scflag = flag['C'];
- if(tirpcflag) {
+ if( tirpcflag ) {
pmflag = inetdflag ? 0 : 1; /* pmflag or inetdflag is always TRUE */
- if((inetdflag && cmd->nflag)) { /* netid not allowed with inetdflag */
+ if( (inetdflag && cmd->nflag)) { /* netid not allowed with inetdflag */
f_print(stderr, "Cannot use netid flag with inetd flag!\n");
return (0);
}
} else { /* 4.1 mode */
pmflag = 0; /* set pmflag only in tirpcmode */
inetdflag = 1; /* inetdflag is TRUE by default */
- if (cmd->nflag) { /* netid needs TIRPC */
+ if( cmd->nflag ) { /* netid needs TIRPC */
f_print( stderr, "Cannot use netid flag without TIRPC!\n");
return( 0 );
}
}
- if (newstyle && ( tblflag || cmd->tflag)) {
+ if( newstyle && ( tblflag || cmd->tflag) ) {
f_print( stderr, "Cannot use table flags with newstyle!\n");
return( 0 );
}
diff --git a/usr.bin/rpcgen/rpc_parse.c b/usr.bin/rpcgen/rpc_parse.c
index 01fdd4ad672..475745b320e 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.6 2001/11/24 19:17:47 deraadt Exp $ */
+/* $OpenBSD: rpc_parse.c,v 1.7 2001/11/24 19:19:59 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
@@ -188,7 +188,7 @@ def_program(defp)
decls->decl = dec;
tailp = &decls->next;
/* get args */
- while (peekscan(TOK_COMMA, &tok)) {
+ while(peekscan(TOK_COMMA, &tok)) {
num_args++;
get_prog_declaration(&dec, DEF_STRUCT,
num_args);
@@ -326,7 +326,7 @@ def_union(defp)
cases->case_name = tok.str;
scan(TOK_COLON, &tok);
- } while (peekscan(TOK_CASE,&tok));
+ }while(peekscan(TOK_CASE,&tok));
}
else
if(flag)
@@ -359,7 +359,7 @@ def_union(defp)
}
}
-static char *reserved_words[] = {
+static char* reserved_words[] = {
"array",
"bytes",
"destroy",
@@ -375,7 +375,7 @@ static char *reserved_words[] = {
NULL
};
-static char *reserved_types[] = {
+static char* reserved_types[] = {
"opaque",
"string",
NULL
@@ -385,7 +385,7 @@ static char *reserved_types[] = {
xdr routines that would conflict with internal XDR routines. */
static check_type_name( name, new_type )
int new_type;
-char *name;
+char* name;
{
int i;
char tmp[100];
@@ -504,7 +504,7 @@ get_prog_declaration(dec, dkind, num)
sprintf(name, "%s%d", ARGNAME, num); /* default name of argument */
dec->name = (char *)strdup(name);
-
+
if (streq(dec->type, "void")) {
return;
}
diff --git a/usr.bin/rpcgen/rpc_parse.h b/usr.bin/rpcgen/rpc_parse.h
index 1c580b1493e..1685e875047 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.3 2001/11/24 19:17:47 deraadt Exp $ */
+/* $OpenBSD: rpc_parse.h,v 1.4 2001/11/24 19:19:59 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
@@ -115,7 +115,7 @@ struct arg_list {
char *argname; /* name of struct for arg*/
decl_list *decls;
};
-
+
typedef struct arg_list arg_list;
struct proc_list {
diff --git a/usr.bin/rpcgen/rpc_sample.c b/usr.bin/rpcgen/rpc_sample.c
index 485bab0d05f..8951c9b79a1 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.8 2001/11/24 19:17:47 deraadt Exp $ */
+/* $OpenBSD: rpc_sample.c,v 1.9 2001/11/24 19:19:59 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
@@ -48,9 +48,9 @@ static char sccsid[] = "@(#)rpc_sample.c 1.1 90/08/30 (C) 1987 SMI";
static char RQSTP[] = "rqstp";
void printarglist();
-static void write_sample_client __P((char *, version_list *));
-static void write_sample_server __P((definition *));
-static void return_type __P((proc_list *));
+static write_sample_client __P((char *, version_list *));
+static write_sample_server __P((definition *));
+static return_type __P((proc_list *));
void
write_sample_svc(def)
@@ -58,7 +58,7 @@ write_sample_svc(def)
{
if (def->def_kind != DEF_PROGRAM)
- return;
+ return;
write_sample_server(def);
}
@@ -71,31 +71,31 @@ write_sample_clnt(def)
int count = 0;
if (def->def_kind != DEF_PROGRAM)
- return(0);
+ return( 0 );
/* generate sample code for each version */
for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
- write_sample_client(def->def_name, vp);
- ++count;
+ write_sample_client(def->def_name, vp );
+ ++count;
}
- return(count);
+ return( count );
}
-static void
-write_sample_client(program_name, vp)
- char *program_name;
+static
+write_sample_client(program_name, vp )
+ char* program_name;
version_list *vp;
{
proc_list *proc;
int i;
decl_list *l;
- f_print(fout, "\n\nvoid\n");
- pvname(program_name, vp->vers_num);
- if (Cflag)
- f_print(fout,"(char *host)\n{\n");
+ 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)\nchar *host;\n{\n");
+ f_print(fout, "(host)\nchar *host;\n{\n" );
f_print(fout, "\tCLIENT *clnt;\n");
i = 0;
@@ -104,23 +104,23 @@ write_sample_client(program_name, vp)
ptype(proc->res_prefix, proc->res_type, 1);
f_print(fout, " *result_%d;\n",++i);
/* print out declarations for arguments */
- if (proc->arg_num < 2 && !newstyle) {
- f_print(fout, "\t");
- if (!streq(proc->args.decls->decl.type, "void"))
+ if( proc->arg_num < 2 && !newstyle) {
+ f_print( fout, "\t" );
+ if( !streq( proc->args.decls->decl.type, "void") )
ptype(proc->args.decls->decl.prefix, proc->args.decls->decl.type, 1);
else
- f_print(fout, "char *"); /* cannot have "void" type */
+ f_print(fout, "char* "); /* cannot have "void" type */
f_print(fout, " ");
- pvname(proc->proc_name, vp->vers_num);
+ pvname( proc->proc_name, vp->vers_num );
f_print(fout, "_arg;\n");
- } else if (!streq(proc->args.decls->decl.type, "void")) {
+ } else if (!streq( proc->args.decls->decl.type, "void")) {
for (l = proc->args.decls; l != NULL; l = l->next) {
- f_print(fout, "\t");
+ f_print( fout, "\t" );
ptype(l->decl.prefix, l->decl.type, 1);
- f_print(fout, " ");
- pvname(proc->proc_name, vp->vers_num);
- f_print(fout, "_%s;\n", l->decl.name);
-/* pdeclaration(proc->args.argname, &l->decl, 1, ";\n");*/
+ f_print( fout, " ");
+ pvname( proc->proc_name, vp->vers_num );
+ f_print(fout, "_%s;\n", l->decl.name );
+/* pdeclaration(proc->args.argname, &l->decl, 1, ";\n" );*/
}
}
}
@@ -138,19 +138,19 @@ write_sample_client(program_name, vp)
f_print(fout, "\tresult_%d = ",++i);
pvname(proc->proc_name, vp->vers_num);
if (proc->arg_num < 2 && !newstyle) {
- f_print(fout, "(");
- if (streq(proc->args.decls->decl.type, "void")) /* cast to void* */
+ f_print(fout, "(" );
+ if( streq( proc->args.decls->decl.type, "void") ) /* cast to void* */
f_print(fout, "(void*)");
- f_print(fout, "&");
- pvname(proc->proc_name, vp->vers_num);
+ f_print(fout, "&" );
+ pvname(proc->proc_name, vp->vers_num );
f_print(fout, "_arg, clnt);\n");
- } else if (streq(proc->args.decls->decl.type, "void")) {
+ } else if (streq( proc->args.decls->decl.type, "void")) {
f_print(fout, "(clnt);\n");
}
else {
f_print(fout, "(");
for (l = proc->args.decls; l != NULL; l = l->next) {
- pvname(proc->proc_name, vp->vers_num);
+ pvname( proc->proc_name, vp->vers_num );
f_print(fout, "_%s, ", l->decl.name);
}
f_print(fout, "clnt);\n");
@@ -160,11 +160,11 @@ write_sample_client(program_name, vp)
f_print(fout, "\t}\n");
}
- f_print(fout, "\tclnt_destroy(clnt);\n");
+ f_print(fout, "\tclnt_destroy( clnt );\n" );
f_print(fout, "}\n");
}
-static void
+static
write_sample_server(def)
definition *def;
{
@@ -174,42 +174,42 @@ write_sample_server(def)
for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
for (proc = vp->procs; proc != NULL; proc = proc->next) {
f_print(fout, "\n");
-/* if (Cflag)
- f_print(fout, "extern \"C\"{\n");
+/* if( Cflag )
+ f_print( fout, "extern \"C\"{\n");
*/
return_type(proc);
f_print(fout, "* \n");
pvname_svc(proc->proc_name, vp->vers_num);
- printarglist(proc, RQSTP, "struct svc_req *");
+ printarglist( proc, RQSTP, "struct svc_req *" );
f_print(fout, "{\n");
f_print(fout, "\n\tstatic ");
- if (!streq(proc->res_type, "void"))
- return_type(proc);
+ if( !streq( proc->res_type, "void") )
+ return_type(proc);
else
- f_print(fout, "char*"); /* cannot have void type */
+ f_print(fout, "char*" ); /* cannot have void type */
f_print(fout, " result;\n");
f_print(fout,
- "\n\t/*\n\t * insert server code here\n\t */\n\n");
- if (!streq(proc->res_type, "void"))
- f_print(fout, "\treturn(&result);\n}\n");
+ "\n\t/*\n\t * insert server code here\n\t */\n\n");
+ if( !streq( proc->res_type, "void") )
+ f_print(fout, "\treturn(&result);\n}\n");
else /* cast back to void * */
- f_print(fout, "\treturn((void*) &result);\n}\n");
-/* if (Cflag)
- f_print(fout, "}\n");
+ f_print(fout, "\treturn((void*) &result);\n}\n");
+/* if( Cflag)
+ f_print( fout, "}\n");
*/
- }
+
+ }
}
}
-static void
+static
return_type(plist)
proc_list *plist;
{
- ptype(plist->res_prefix, plist->res_type, 1);
+ ptype( plist->res_prefix, plist->res_type, 1 );
}
-void
add_sample_msg()
{
f_print(fout, "/*\n");
@@ -222,31 +222,32 @@ add_sample_msg()
void
write_sample_clnt_main()
{
- list *l;
- definition *def;
- version_list *vp;
+ list *l;
+ definition *def;
+ version_list *vp;
- f_print(fout, "\n\n");
- if (Cflag)
- f_print(fout,"main(int argc, char *argv[])\n{\n");
- else
- f_print(fout, "main(argc, argv)\nint argc;\nchar *argv[];\n{\n");
+ f_print(fout, "\n\n" );
+ if( Cflag )
+ f_print(fout,"main( int argc, char* argv[] )\n{\n" );
+ else
+ f_print(fout, "main(argc, argv)\nint argc;\nchar *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");
- f_print(fout, "\t\texit(1);\n\t}");
- f_print(fout, "\n\thost = argv[1];\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" );
+ f_print(fout, "\t\texit(1);\n\t}");
+ f_print(fout, "\n\thost = argv[1];\n");
- for (l = defined; l != NULL; l = l->next) {
+ for (l = defined; l != NULL; l = l->next) {
def = l->val;
- if (def->def_kind != DEF_PROGRAM)
+ if (def->def_kind != DEF_PROGRAM) {
continue;
+ }
for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
- f_print(fout, "\t");
+ f_print( fout, "\t" );
pvname(def->def_name, vp->vers_num);
- f_print(fout, "(host);\n");
+ f_print( fout, "( host );\n" );
+ }
}
- }
- f_print(fout, "}\n");
+ f_print(fout, "}\n");
}
diff --git a/usr.bin/rpcgen/rpc_scan.c b/usr.bin/rpcgen/rpc_scan.c
index 5f2f6a963e4..66c9c123beb 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.5 2001/11/24 19:17:47 deraadt Exp $ */
+/* $OpenBSD: rpc_scan.c,v 1.6 2001/11/24 19:19:59 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
@@ -35,8 +35,8 @@ static char sccsid[] = "@(#)rpc_scan.c 1.11 89/02/22 (C) 1987 SMI";
#endif
/*
- * rpc_scan.c, Scanner for the RPC protocol compiler
- * Copyright (C) 1987, Sun Microsystems, Inc.
+ * rpc_scan.c, Scanner for the RPC protocol compiler
+ * Copyright (C) 1987, Sun Microsystems, Inc.
*/
#include <sys/cdefs.h>
#include <stdlib.h>
@@ -64,7 +64,7 @@ static int pushed = 0; /* is a token pushed */
static token lasttok; /* last token, if pushed */
/*
- * scan expecting 1 given token
+ * scan expecting 1 given token
*/
void
scan(expect, tokp)
@@ -72,12 +72,13 @@ scan(expect, tokp)
token *tokp;
{
get_token(tokp);
- if (tokp->kind != expect)
+ if (tokp->kind != expect) {
expected1(expect);
+ }
}
/*
- * scan expecting any of the 2 given tokens
+ * scan expecting any of the 2 given tokens
*/
void
scan2(expect1, expect2, tokp)
@@ -86,12 +87,13 @@ scan2(expect1, expect2, tokp)
token *tokp;
{
get_token(tokp);
- if (tokp->kind != expect1 && tokp->kind != expect2)
+ if (tokp->kind != expect1 && tokp->kind != expect2) {
expected2(expect1, expect2);
+ }
}
/*
- * scan expecting any of the 3 given token
+ * scan expecting any of the 3 given token
*/
void
scan3(expect1, expect2, expect3, tokp)
@@ -101,13 +103,14 @@ scan3(expect1, expect2, expect3, tokp)
token *tokp;
{
get_token(tokp);
- if (tokp->kind != expect1 && tokp->kind != expect2 &&
- tokp->kind != expect3)
+ if (tokp->kind != expect1 && tokp->kind != expect2
+ && tokp->kind != expect3) {
expected3(expect1, expect2, expect3);
+ }
}
/*
- * scan expecting a constant, possibly symbolic
+ * scan expecting a constant, possibly symbolic
*/
void
scan_num(tokp)
@@ -123,7 +126,7 @@ scan_num(tokp)
}
/*
- * Peek at the next token
+ * Peek at the next token
*/
void
peek(tokp)
@@ -134,7 +137,7 @@ peek(tokp)
}
/*
- * Peek at the next token and scan it if it matches what you expect
+ * Peek at the next token and scan it if it matches what you expect
*/
int
peekscan(expect, tokp)
@@ -150,7 +153,7 @@ peekscan(expect, tokp)
}
/*
- * Get the next token, printing out any directive that are encountered.
+ * Get the next token, printing out any directive that are encountered.
*/
void
get_token(tokp)
@@ -176,8 +179,8 @@ get_token(tokp)
if (commenting) {
break;
} else if (cppline(curline)) {
- docppline(curline, &linenum,
- &infilename);
+ docppline(curline, &linenum,
+ &infilename);
} else if (directive(curline)) {
printdirective(curline);
} else {
@@ -206,7 +209,7 @@ get_token(tokp)
}
/*
- * 'where' is not whitespace, comment or directive Must be a token!
+ * 'where' is not whitespace, comment or directive Must be a token!
*/
switch (*where) {
case ':':
@@ -389,28 +392,28 @@ findconst(str, val)
}
static token symbols[] = {
- {TOK_CONST, "const"},
- {TOK_UNION, "union"},
- {TOK_SWITCH, "switch"},
- {TOK_CASE, "case"},
- {TOK_DEFAULT, "default"},
- {TOK_STRUCT, "struct"},
- {TOK_TYPEDEF, "typedef"},
- {TOK_ENUM, "enum"},
- {TOK_OPAQUE, "opaque"},
- {TOK_BOOL, "bool"},
- {TOK_VOID, "void"},
- {TOK_CHAR, "char"},
- {TOK_INT, "int"},
- {TOK_UNSIGNED, "unsigned"},
- {TOK_SHORT, "short"},
- {TOK_LONG, "long"},
- {TOK_FLOAT, "float"},
- {TOK_DOUBLE, "double"},
- {TOK_STRING, "string"},
- {TOK_PROGRAM, "program"},
- {TOK_VERSION, "version"},
- {TOK_EOF, "??????"},
+ {TOK_CONST, "const"},
+ {TOK_UNION, "union"},
+ {TOK_SWITCH, "switch"},
+ {TOK_CASE, "case"},
+ {TOK_DEFAULT, "default"},
+ {TOK_STRUCT, "struct"},
+ {TOK_TYPEDEF, "typedef"},
+ {TOK_ENUM, "enum"},
+ {TOK_OPAQUE, "opaque"},
+ {TOK_BOOL, "bool"},
+ {TOK_VOID, "void"},
+ {TOK_CHAR, "char"},
+ {TOK_INT, "int"},
+ {TOK_UNSIGNED, "unsigned"},
+ {TOK_SHORT, "short"},
+ {TOK_LONG, "long"},
+ {TOK_FLOAT, "float"},
+ {TOK_DOUBLE, "double"},
+ {TOK_STRING, "string"},
+ {TOK_PROGRAM, "program"},
+ {TOK_VERSION, "version"},
+ {TOK_EOF, "??????"},
};
static
diff --git a/usr.bin/rpcgen/rpc_svcout.c b/usr.bin/rpcgen/rpc_svcout.c
index 47beaf93e3b..9fdfc45d1bb 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.8 2001/11/24 19:17:47 deraadt Exp $ */
+/* $OpenBSD: rpc_svcout.c,v 1.9 2001/11/24 19:19:59 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
@@ -67,61 +67,61 @@ static write_rpc_svc_fg __P((char *, char *));
static open_log_file __P((char *, char *));
static
-p_xdrfunc(rname, typename)
-char *rname;
-char *typename;
+p_xdrfunc( rname, typename )
+char* rname;
+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));
-}
+ 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) );
+}
void
internal_proctype(plist)
proc_list *plist;
{
f_print(fout, "static ");
- ptype(plist->res_prefix, plist->res_type, 1);
- f_print(fout, "*");
+ ptype( plist->res_prefix, plist->res_type, 1 );
+ f_print( fout, "*" );
}
+
/*
- * write most of the service, that is, everything but the registrations.
+ * write most of the service, that is, everything but the registrations.
*/
void
write_most(infile, netflag, nomain)
char *infile; /* our name */
int netflag;
- int nomain;
+ int nomain;
{
if (inetdflag || pmflag) {
- char *var_type;
+ char* var_type;
var_type = (nomain? "extern" : "static");
- f_print(fout, "%s int _rpcpmstart;", var_type);
- f_print(fout, "\t\t/* Started by a port monitor ? */\n");
- f_print(fout, "%s int _rpcfdtype;", var_type);
+ f_print(fout, "%s int _rpcpmstart;", var_type );
+ f_print(fout, "\t\t/* Started by a port monitor ? */\n");
+ f_print(fout, "%s int _rpcfdtype;", var_type );
f_print(fout, "\t\t/* Whether Stream or Datagram ? */\n");
if (timerflag) {
- f_print(fout, "%s int _rpcsvcdirty;", var_type);
+ f_print(fout, "%s int _rpcsvcdirty;", var_type );
f_print(fout, "\t/* Still serving ? */\n");
}
- write_svc_aux(nomain);
+ write_svc_aux( nomain );
}
/* write out dispatcher and stubs */
- write_programs(nomain? (char *)NULL : "static");
+ write_programs( nomain? (char *)NULL : "static" );
- if (nomain)
- return;
+ if( nomain )
+ return;
f_print(fout, "\nmain()\n");
f_print(fout, "{\n");
if (inetdflag) {
write_inetmost(infile); /* Includes call to write_rpc_svc_fg() */
} else {
- if (tirpcflag) {
+ if( tirpcflag ) {
if (netflag) {
f_print(fout, "\tSVCXPRT *%s;\n", TRANSP);
f_print(fout, "\tstruct netconfig *nconf = NULL;\n");
@@ -146,7 +146,7 @@ write_most(infile, netflag, nomain)
}
/*
- * write a registration for the given transport
+ * write a registration for the given transport
*/
void
write_netid_register(transp)
@@ -163,12 +163,12 @@ write_netid_register(transp)
f_print(fout, "%s\tnconf = getnetconfigent(\"%s\");\n", sp, transp);
f_print(fout, "%s\tif (nconf == NULL) {\n", sp);
(void) sprintf(_errbuf, "cannot find %s netid.", transp);
- snprintf(tmpbuf, sizeof tmpbuf, "%s\t\t", sp);
+ sprintf(tmpbuf, "%s\t\t", sp);
print_err_message(tmpbuf);
f_print(fout, "%s\t\texit(1);\n", sp);
f_print(fout, "%s\t}\n", sp);
f_print(fout, "%s\t%s = svc_tli_create(RPC_ANYFD, nconf, 0, 0, 0);\n",
- sp, TRANSP);
+ sp, TRANSP);
f_print(fout, "%s\tif (%s == NULL) {\n", sp, TRANSP);
(void) sprintf(_errbuf, "cannot create %s service.", transp);
print_err_message(tmpbuf);
@@ -177,19 +177,20 @@ write_netid_register(transp)
for (l = defined; l != NULL; l = l->next) {
def = (definition *) l->val;
- if (def->def_kind != DEF_PROGRAM)
+ if (def->def_kind != DEF_PROGRAM) {
continue;
+ }
for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
f_print(fout,
- "%s\t(void) rpcb_unset(%s, %s, nconf);\n",
- sp, def->def_name, vp->vers_name);
+ "%s\t(void) rpcb_unset(%s, %s, nconf);\n",
+ sp, def->def_name, vp->vers_name);
f_print(fout,
- "%s\tif (!svc_reg(%s, %s, %s, ",
- sp, TRANSP, def->def_name, vp->vers_name);
+ "%s\tif (!svc_reg(%s, %s, %s, ",
+ sp, TRANSP, def->def_name, vp->vers_name);
pvname(def->def_name, vp->vers_num);
f_print(fout, ", nconf)) {\n");
(void) sprintf(_errbuf, "unable to register (%s, %s, %s).",
- def->def_name, vp->vers_name, transp);
+ def->def_name, vp->vers_name, transp);
print_err_message(tmpbuf);
f_print(fout, "%s\t\texit(1);\n", sp);
f_print(fout, "%s\t}\n", sp);
@@ -211,16 +212,17 @@ write_nettype_register(transp)
for (l = defined; l != NULL; l = l->next) {
def = (definition *) l->val;
- if (def->def_kind != DEF_PROGRAM)
+ if (def->def_kind != DEF_PROGRAM) {
continue;
+ }
for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
f_print(fout, "\tif (!svc_create(");
pvname(def->def_name, vp->vers_num);
f_print(fout, ", %s, %s, \"%s\")) {\n",
- def->def_name, vp->vers_name, transp);
+ def->def_name, vp->vers_name, transp);
(void) sprintf(_errbuf,
- "unable to create (%s, %s) for %s.",
- def->def_name, vp->vers_name, transp);
+ "unable to create (%s, %s) for %s.",
+ def->def_name, vp->vers_name, transp);
print_err_message("\t\t");
f_print(fout, "\t\texit(1);\n");
f_print(fout, "\t}\n");
@@ -229,7 +231,7 @@ write_nettype_register(transp)
}
/*
- * write the rest of the service
+ * write the rest of the service
*/
void
write_rest()
@@ -243,9 +245,9 @@ write_rest()
f_print(fout, "\t}\n");
if (timerflag) {
f_print(fout, "\tif (_rpcpmstart) {\n");
- f_print(fout,
- "\t\t(void) signal(SIGALRM, %s closedown);\n",
- Cflag? "(SIG_PF)" : "(void(*)())");
+ f_print(fout,
+ "\t\t(void) signal(SIGALRM, %s closedown);\n",
+ Cflag? "(SIG_PF)" : "(void(*)())" );
f_print(fout, "\t\t(void) alarm(_RPCSVC_CLOSEDOWN);\n");
f_print(fout, "\t}\n");
}
@@ -262,22 +264,26 @@ void
write_programs(storage)
char *storage;
{
- definition *def;
list *l;
+ definition *def;
/* write out stubs for procedure definitions */
for (l = defined; l != NULL; l = l->next) {
def = (definition *) l->val;
- if (def->def_kind == DEF_PROGRAM)
+ if (def->def_kind == DEF_PROGRAM) {
write_real_program(def);
+ }
}
/* write out dispatcher for each program */
for (l = defined; l != NULL; l = l->next) {
def = (definition *) l->val;
- if (def->def_kind == DEF_PROGRAM)
+ if (def->def_kind == DEF_PROGRAM) {
write_program(def, storage);
+ }
}
+
+
}
/* write out definition of internal function (e.g. _printmsg_1(...))
@@ -292,31 +298,31 @@ write_real_program(def)
proc_list *proc;
decl_list *l;
- if (!newstyle) return; /* not needed for old style */
+ if( !newstyle ) return; /* not needed for old style */
for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
for (proc = vp->procs; proc != NULL; proc = proc->next) {
f_print(fout, "\n");
internal_proctype(proc);
f_print(fout, "\n_");
pvname(proc->proc_name, vp->vers_num);
- if (Cflag) {
- f_print(fout, "(");
+ if( Cflag ) {
+ f_print(fout, "(" );
/* arg name */
if (proc->arg_num > 1)
f_print(fout, proc->args.argname);
else
- ptype(proc->args.decls->decl.prefix,
+ ptype(proc->args.decls->decl.prefix,
proc->args.decls->decl.type, 0);
- f_print(fout, " *argp, struct svc_req *%s)\n",
+ f_print(fout, " *argp, struct svc_req *%s)\n",
RQSTP);
} else {
- f_print(fout, "(argp, %s)\n", RQSTP);
+ f_print(fout, "(argp, %s)\n", RQSTP );
/* arg name */
if (proc->arg_num > 1)
f_print(fout, "\t%s *argp;\n", proc->args.argname);
else {
f_print(fout, "\t");
- ptype(proc->args.decls->decl.prefix,
+ ptype(proc->args.decls->decl.prefix,
proc->args.decls->decl.type, 0);
f_print(fout, " *argp;\n");
}
@@ -328,18 +334,18 @@ write_real_program(def)
pvname_svc(proc->proc_name, vp->vers_num);
f_print(fout, "(");
if (proc->arg_num < 2) { /* single argument */
- if (!streq(proc->args.decls->decl.type, "void"))
+ if (!streq( proc->args.decls->decl.type, "void"))
f_print(fout, "*argp, "); /* non-void */
} else {
- for (l = proc->args.decls; l != NULL; l = l->next)
+ for (l = proc->args.decls; l != NULL; l = l->next)
f_print(fout, "argp->%s, ", l->decl.name);
}
f_print(fout, "%s));\n}\n", RQSTP);
- }
+ }
}
}
-static
+static
write_program(def, storage)
definition *def;
char *storage;
@@ -350,36 +356,40 @@ write_program(def, storage)
for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
f_print(fout, "\n");
- if (storage != NULL)
+ if (storage != NULL) {
f_print(fout, "%s ", storage);
+ }
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, "register SVCXPRT *%s)\n", TRANSP);
+ f_print(fout, "(struct svc_req *%s, ", RQSTP);
+ f_print(fout, "register 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, " register SVCXPRT *%s;\n", TRANSP);
+ f_print(fout, "(%s, %s)\n", RQSTP, TRANSP);
+ f_print(fout, " struct svc_req *%s;\n", RQSTP);
+ f_print(fout, " register SVCXPRT *%s;\n", TRANSP);
}
+
f_print(fout, "{\n");
filled = 0;
f_print(fout, "\tunion {\n");
for (proc = vp->procs; proc != NULL; proc = proc->next) {
if (proc->arg_num < 2) { /* single argument */
- if (streq(proc->args.decls->decl.type,
- "void"))
+ if (streq(proc->args.decls->decl.type,
+ "void")) {
continue;
+ }
filled = 1;
f_print(fout, "\t\t");
- ptype(proc->args.decls->decl.prefix,
- proc->args.decls->decl.type, 0);
+ ptype(proc->args.decls->decl.prefix,
+ proc->args.decls->decl.type, 0);
pvname(proc->proc_name, vp->vers_num);
f_print(fout, "_arg;\n");
- } else {
+ }
+ else {
filled = 1;
f_print(fout, "\t\t%s", proc->args.argname);
f_print(fout, " ");
@@ -387,24 +397,25 @@ write_program(def, storage)
f_print(fout, "_arg;\n");
}
}
- if (!filled)
+ if (!filled) {
f_print(fout, "\t\tint fill;\n");
+ }
f_print(fout, "\t} %s;\n", ARG);
f_print(fout, "\tchar *%s;\n", RESULT);
if (Cflag) {
- f_print(fout, "\txdrproc_t xdr_%s, xdr_%s;\n", ARG, RESULT);
- f_print(fout,
+ f_print(fout, "\txdrproc_t xdr_%s, xdr_%s;\n", ARG, RESULT);
+ f_print(fout,
"\tchar *(*%s)(char *, struct svc_req *);\n",
ROUTINE);
} else {
- f_print(fout, "\tbool_t (*xdr_%s)(), (*xdr_%s)();\n",
- ARG, RESULT);
- f_print(fout, "\tchar *(*%s)();\n", ROUTINE);
+ f_print(fout, "\tbool_t (*xdr_%s)(), (*xdr_%s)();\n", ARG, RESULT);
+ f_print(fout, "\tchar *(*%s)();\n", ROUTINE);
}
+
f_print(fout, "\n");
- if (callerflag)
+ if (callerflag)
f_print(fout, "\tcaller = transp;\n"); /*EVAS*/
if (timerflag)
f_print(fout, "\t_rpcsvcdirty = 1;\n");
@@ -412,35 +423,35 @@ write_program(def, storage)
if (!nullproc(vp->procs)) {
f_print(fout, "\tcase NULLPROC:\n");
f_print(fout,
- Cflag
- ? "\t\t(void) svc_sendreply(%s, (xdrproc_t) xdr_void, (char *)NULL);\n"
- : "\t\t(void) svc_sendreply(%s, xdr_void, (char *)NULL);\n",
- TRANSP);
+ Cflag
+ ? "\t\t(void) svc_sendreply(%s, (xdrproc_t) xdr_void, (char *)NULL);\n"
+ : "\t\t(void) svc_sendreply(%s, xdr_void, (char *)NULL);\n",
+ TRANSP);
print_return("\t\t");
f_print(fout, "\n");
}
for (proc = vp->procs; proc != NULL; proc = proc->next) {
f_print(fout, "\tcase %s:\n", proc->proc_name);
if (proc->arg_num < 2) { /* single argument */
- p_xdrfunc(ARG, proc->args.decls->decl.type);
+ p_xdrfunc( ARG, proc->args.decls->decl.type);
} else {
- p_xdrfunc(ARG, proc->args.argname);
+ p_xdrfunc( ARG, proc->args.argname);
}
- p_xdrfunc(RESULT, proc->res_type);
- if (Cflag)
- f_print(fout,
+ p_xdrfunc( RESULT, proc->res_type);
+ if( Cflag )
+ f_print(fout,
"\t\t%s = (char *(*)(char *, struct svc_req *)) ",
ROUTINE);
else
- f_print(fout, "\t\t%s = (char *(*)()) ", ROUTINE);
+ f_print(fout, "\t\t%s = (char *(*)()) ", ROUTINE);
if (newstyle) { /* new style: calls internal routine */
f_print(fout,"_");
}
- if (!newstyle)
- pvname_svc(proc->proc_name, vp->vers_num);
+ if (!newstyle )
+ pvname_svc(proc->proc_name, vp->vers_num);
else
- pvname(proc->proc_name, vp->vers_num);
+ pvname(proc->proc_name, vp->vers_num);
f_print(fout, ";\n");
f_print(fout, "\t\tbreak;\n\n");
}
@@ -450,24 +461,24 @@ write_program(def, storage)
f_print(fout, "\t}\n");
f_print(fout, "\t(void) memset((char *)&%s, 0, sizeof (%s));\n", ARG, ARG);
- printif ("getargs", TRANSP, "(caddr_t) &", ARG);
+ printif("getargs", TRANSP, "(caddr_t) &", ARG);
printerr("decode", TRANSP);
print_return("\t\t");
f_print(fout, "\t}\n");
if (Cflag)
- f_print(fout, "\t%s = (*%s)((char *)&%s, %s);\n",
+ f_print(fout, "\t%s = (*%s)((char *)&%s, %s);\n",
RESULT, ROUTINE, ARG, RQSTP);
else
- f_print(fout, "\t%s = (*%s)(&%s, %s);\n",
+ f_print(fout, "\t%s = (*%s)(&%s, %s);\n",
RESULT, ROUTINE, ARG, RQSTP);
- f_print(fout,
- "\tif (%s != NULL && !svc_sendreply(%s, xdr_%s, %s)) {\n",
- RESULT, TRANSP, RESULT, RESULT);
+ f_print(fout,
+ "\tif (%s != NULL && !svc_sendreply(%s, xdr_%s, %s)) {\n",
+ RESULT, TRANSP, RESULT, RESULT);
printerr("systemerr", TRANSP);
f_print(fout, "\t}\n");
- printif ("freeargs", TRANSP, "(caddr_t) &", ARG);
+ printif("freeargs", TRANSP, "(caddr_t) &", ARG);
(void) sprintf(_errbuf, "unable to free arguments");
print_err_message("\t\t");
f_print(fout, "\t\texit(1);\n");
@@ -486,22 +497,23 @@ printerr(err, transp)
}
static
-printif (proc, transp, prefix, arg)
+printif(proc, transp, prefix, arg)
char *proc;
char *transp;
char *prefix;
char *arg;
{
f_print(fout, "\tif (!svc_%s(%s, xdr_%s, %s%s)) {\n",
- proc, transp, arg, prefix, arg);
+ proc, transp, arg, prefix, arg);
}
nullproc(proc)
proc_list *proc;
{
for (; proc != NULL; proc = proc->next) {
- if (streq(proc->proc_num, "0"))
+ if (streq(proc->proc_num, "0")) {
return (1);
+ }
}
return (0);
}
@@ -516,7 +528,7 @@ write_inetmost(infile)
f_print(fout, "\tstruct sockaddr_in saddr;\n");
f_print(fout, "\tint asize = sizeof (saddr);\n");
f_print(fout, "\n");
- f_print(fout,
+ f_print(fout,
"\tif (getsockname(0, (struct sockaddr *)&saddr, &asize) == 0) {\n");
f_print(fout, "\t\tint ssize = sizeof (int);\n\n");
f_print(fout, "\t\tif (saddr.sin_family != AF_INET)\n");
@@ -552,17 +564,17 @@ static
print_pmapunset(space)
char *space;
{
- version_list *vp;
- definition *def;
list *l;
+ definition *def;
+ version_list *vp;
for (l = defined; l != NULL; l = l->next) {
def = (definition *) l->val;
if (def->def_kind == DEF_PROGRAM) {
for (vp = def->def.pr.versions; vp != NULL;
- vp = vp->next) {
+ vp = vp->next) {
f_print(fout, "%s(void) pmap_unset(%s, %s);\n",
- space, def->def_name, vp->vers_name);
+ space, def->def_name, vp->vers_name);
}
}
}
@@ -581,16 +593,16 @@ print_err_message(space)
}
/*
- * Write the server auxiliary function (_msgout, timeout)
+ * Write the server auxiliary function ( _msgout, timeout)
*/
void
-write_svc_aux(nomain)
+write_svc_aux( nomain )
int nomain;
{
if (!logflag)
write_msg_out();
- if (!nomain)
- write_timeout_func();
+ if( !nomain )
+ write_timeout_func();
if (callerflag) /*EVAS*/
write_caller_func(); /*EVAS*/
}
@@ -603,11 +615,11 @@ write_msg_out()
{
f_print(fout, "\n");
f_print(fout, "static\n");
- if (!Cflag) {
- f_print(fout, "void _msgout(msg)\n");
- f_print(fout, "\tchar *msg;\n");
+ if( !Cflag ) {
+ f_print(fout, "void _msgout(msg)\n");
+ f_print(fout, "\tchar *msg;\n");
} else {
- f_print(fout, "void _msgout(char *msg)\n");
+ f_print(fout, "void _msgout(char* msg)\n");
}
f_print(fout, "{\n");
f_print(fout, "#ifdef RPC_SVC_FG\n");
@@ -713,7 +725,7 @@ write_pm_most(infile, netflag)
f_print(fout, "\t\tstruct netconfig *nconf = NULL;\n");
f_print(fout, "\t\tSVCXPRT *%s;\n", TRANSP);
}
- if (timerflag)
+ if( timerflag )
f_print(fout, "\t\tint pmclose;\n");
/* not necessary, defined in /usr/include/stdlib */
/* f_print(fout, "\t\textern char *getenv();\n");*/
@@ -739,7 +751,7 @@ write_pm_most(infile, netflag)
f_print(fout, "\t\t\t\texit(1);\n");
f_print(fout, "\t\t\t}\n");
f_print(fout, "\t\t}\n");
- if (timerflag)
+ if( timerflag )
f_print(fout, "\t\tpmclose = (t_getstate(0) != T_DATAXFER);\n");
f_print(fout, "\t\tif ((%s = svc_tli_create(0, nconf, NULL, 0, 0)) == NULL) {\n",
TRANSP);
@@ -770,7 +782,7 @@ write_pm_most(infile, 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(*)())");
+ Cflag? "(SIG_PF)" : "(void(*)())" );
f_print(fout, "\t\t\t(void) alarm(_RPCSVC_CLOSEDOWN);\n");
f_print(fout, "\t\t}\n");
}
@@ -790,7 +802,7 @@ write_rpc_svc_fg(infile, sp)
{
f_print(fout, "#ifndef RPC_SVC_FG\n");
f_print(fout, "%sint size;\n", sp);
- if (tirpcflag)
+ if( tirpcflag )
f_print(fout, "%sstruct rlimit rl;\n", sp);
if (inetdflag)
f_print(fout, "%sint pid, i;\n\n", sp);
@@ -802,7 +814,7 @@ write_rpc_svc_fg(infile, sp)
f_print(fout, "%sif (pid)\n", sp);
f_print(fout, "%s\texit(0);\n", sp);
/* get number of file descriptors */
- if (tirpcflag) {
+ if( tirpcflag ) {
f_print(fout, "%srl.rlim_max = 0;\n", sp);
f_print(fout, "%sgetrlimit(RLIMIT_NOFILE, &rl);\n", sp);
f_print(fout, "%sif ((size = rl.rlim_max) == 0)\n", sp);
@@ -818,7 +830,7 @@ write_rpc_svc_fg(infile, sp)
f_print(fout, "%s(void) dup2(i, 1);\n", sp);
f_print(fout, "%s(void) dup2(i, 2);\n", sp);
/* This removes control of the controlling terminal */
- if (tirpcflag)
+ if( tirpcflag )
f_print(fout, "%ssetsid();\n", sp);
else {
f_print(fout, "%si = open(\"/dev/tty\", 2);\n", sp);
@@ -842,13 +854,16 @@ open_log_file(infile, sp)
char *s;
s = strrchr(infile, '.');
- if (s)
+ if (s)
*s = '\0';
f_print(fout,"%sopenlog(\"%s\", LOG_PID, LOG_DAEMON);\n", sp, infile);
if (s)
*s = '.';
}
+
+
+
/*
* write a registration for the given transport for Inetd
*/
@@ -923,7 +938,7 @@ write_inetd_register(transp)
pvname(def->def_name, vp->vers_num);
if (inetdflag)
f_print(fout, ", proto)) {\n");
- else
+ else
f_print(fout, ", IPPROTO_%s)) {\n",
isudp ? "UDP": "TCP");
(void) sprintf(_errbuf, "unable to register (%s, %s, %s).",
diff --git a/usr.bin/rpcgen/rpc_tblout.c b/usr.bin/rpcgen/rpc_tblout.c
index 4de0d822a76..ec9f529f0c7 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.5 2001/11/24 19:17:47 deraadt Exp $ */
+/* $OpenBSD: rpc_tblout.c,v 1.6 2001/11/24 19:19:59 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
@@ -53,29 +53,30 @@ static char tbl_hdr[] = "struct rpcgen_table %s_table[] = {\n";
static char tbl_end[] = "};\n";
static char null_entry[] = "\n\t(char *(*)())0,\n\
-\t(xdrproc_t) xdr_void,\t\t\t0,\n\
-\t(xdrproc_t) xdr_void,\t\t\t0,\n";
+ \t(xdrproc_t) xdr_void,\t\t\t0,\n\
+ \t(xdrproc_t) xdr_void,\t\t\t0,\n";
static char tbl_nproc[] = "int %s_nproc =\n\tsizeof(%s_table)/sizeof(%s_table[0]);\n\n";
-static void write_table __P((definition *));
-static void printit __P((char *, char *));
+static write_table __P((definition *));
+static printit __P((char *, char *));
void
write_tables()
{
- definition *def;
list *l;
+ definition *def;
f_print(fout, "\n");
for (l = defined; l != NULL; l = l->next) {
def = (definition *) l->val;
- if (def->def_kind == DEF_PROGRAM)
+ if (def->def_kind == DEF_PROGRAM) {
write_table(def);
+ }
}
}
-static void
+static
write_table(def)
definition *def;
{
@@ -103,10 +104,10 @@ write_table(def)
current = atoi(proc->proc_num);
if (current != expected++) {
f_print(fout,
- "\n/*\n * WARNING: table out of order\n */\n");
+ "\n/*\n * WARNING: table out of order\n */\n");
if (warning == 0) {
f_print(stderr,
- "WARNING %s table is out of order\n",
+ "WARNING %s table is out of order\n",
progvers);
warning = 1;
nonfatalerrors = 1;
@@ -116,22 +117,22 @@ write_table(def)
f_print(fout, "\n\t(char *(*)())RPCGEN_ACTION(");
/* routine to invoke */
- if (!newstyle)
- pvname_svc(proc->proc_name, vp->vers_num);
+ if ( !newstyle)
+ pvname_svc(proc->proc_name, vp->vers_num);
else {
- if (newstyle)
- f_print(fout, "_"); /* calls internal func */
- pvname(proc->proc_name, vp->vers_num);
+ if( newstyle )
+ f_print( fout, "_"); /* calls internal func */
+ pvname(proc->proc_name, vp->vers_num);
}
f_print(fout, "),\n");
/* argument info */
- if (proc->arg_num > 1)
- printit((char*) NULL, proc->args.argname);
+ if( proc->arg_num > 1 )
+ printit((char*) NULL, proc->args.argname );
else
- /* do we have to do something special for newstyle */
- printit(proc->args.decls->decl.prefix,
- proc->args.decls->decl.type);
+ /* do we have to do something special for newstyle */
+ printit( proc->args.decls->decl.prefix,
+ proc->args.decls->decl.type );
/* result info */
printit(proc->res_prefix, proc->res_type);
}
@@ -142,12 +143,14 @@ write_table(def)
}
}
-static void
+static
printit(prefix, type)
char *prefix;
char *type;
{
- int len, tabs;
+ int len;
+ int tabs;
+
len = fprintf(fout, "\txdr_%s,", stringfix(type));
/* account for leading tab expansion */
@@ -159,7 +162,7 @@ printit(prefix, type)
if (streq(type, "void")) {
f_print(fout, "0");
} else {
- f_print(fout, "sizeof (");
+ f_print(fout, "sizeof ( ");
/* XXX: should "follow" be 1 ??? */
ptype(prefix, type, 0);
f_print(fout, ")");
diff --git a/usr.bin/rpcgen/rpc_util.c b/usr.bin/rpcgen/rpc_util.c
index 3b0ddbea456..4871545f917 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.5 2001/11/24 19:17:47 deraadt Exp $ */
+/* $OpenBSD: rpc_util.c,v 1.6 2001/11/24 19:19:59 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
@@ -42,7 +42,6 @@ static char sccsid[] = "@(#)rpc_util.c 1.11 89/02/22 (C) 1987 SMI";
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
-#include <unistd.h>
#include "rpc_scan.h"
#include "rpc_parse.h"
#include "rpc_util.h"
@@ -69,7 +68,6 @@ list *defined; /* list of defined things */
/*
* Reinitialize the world
*/
-void
reinitialize()
{
memset(curline, 0, MAXLINESIZE);
@@ -81,7 +79,6 @@ reinitialize()
/*
* string equality
*/
-int
streq(a, b)
char *a;
char *b;
@@ -119,6 +116,7 @@ storeval(lstp, val)
list **l;
list *lst;
+
for (l = lstp; *l != NULL; l = (list **) & (*l)->next);
lst = ALLOC(list);
lst->val = val;
@@ -126,7 +124,7 @@ storeval(lstp, val)
*l = lst;
}
-static int
+static
findit(def, type)
definition *def;
char *type;
@@ -195,7 +193,7 @@ ptype(prefix, type, follow)
}
}
-static int
+static
typedefed(def, type)
definition *def;
char *type;
@@ -207,7 +205,6 @@ typedefed(def, type)
}
}
-int
isvectordef(type, rel)
char *type;
relation rel;
@@ -241,7 +238,7 @@ 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;
@@ -281,7 +278,6 @@ error(msg)
* Something went wrong, unlink any files that we may have created and then
* die.
*/
-void
crash()
{
int i;
@@ -356,6 +352,7 @@ tabify(f, tab)
}
}
+
static token tokstrings[] = {
{TOK_IDENT, "identifier"},
{TOK_CONST, "const"},
@@ -403,7 +400,7 @@ toktostr(kind)
return (sp->str);
}
-static void
+static
printbuf()
{
char c;
@@ -412,7 +409,7 @@ printbuf()
# define TABSIZE 4
- for (i = 0; (c = curline[i]); i++) {
+ for (i = 0; c = curline[i]; i++) {
if (c == '\t') {
cnt = 8 - (i % TABSIZE);
c = ' ';
@@ -453,7 +450,7 @@ make_argname(pname, vname)
char *vname;
{
char *name;
-
+
name = (char *)malloc(strlen(pname) + strlen(vname) + strlen(ARGEXT) + 3);
if (!name) {
fprintf(stderr, "failed in malloc");
@@ -496,7 +493,8 @@ find_type(type)
{
bas_type * ptr;
- ptr = typ_list_h;
+ ptr=typ_list_h;
+
while (ptr != NULL) {
if (strcmp(ptr->name,type) == 0)
diff --git a/usr.bin/rpcgen/rpc_util.h b/usr.bin/rpcgen/rpc_util.h
index 055018f5175..d725648241f 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.6 2001/11/24 19:17:47 deraadt Exp $ */
+/* $OpenBSD: rpc_util.h,v 1.7 2001/11/24 19:19:59 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
@@ -104,7 +104,6 @@ definition *findval();
#define FINDVAL(list,item,finder) \
findval(list, item, finder)
-void crash __P((void));
char *fixtype __P((char *));
char *stringfix __P((char *));
char *locase __P((char *));