summaryrefslogtreecommitdiff
path: root/usr.bin/rpcgen
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2001-12-05 09:50:32 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2001-12-05 09:50:32 +0000
commit5013881a89e4a7796fbad098e2abba4eb3fb2856 (patch)
tree2abb9c5308d4c812188be53f110fa9c683ba93ba /usr.bin/rpcgen
parent4107f58e89e1963f07b66da353523f87570b65e5 (diff)
KNF, and remove part of the TLI garbage
Diffstat (limited to 'usr.bin/rpcgen')
-rw-r--r--usr.bin/rpcgen/rpc_clntout.c33
-rw-r--r--usr.bin/rpcgen/rpc_cout.c139
-rw-r--r--usr.bin/rpcgen/rpc_hout.c221
-rw-r--r--usr.bin/rpcgen/rpc_main.c930
-rw-r--r--usr.bin/rpcgen/rpc_parse.c46
-rw-r--r--usr.bin/rpcgen/rpc_parse.h4
-rw-r--r--usr.bin/rpcgen/rpc_sample.c153
-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.c51
-rw-r--r--usr.bin/rpcgen/rpc_util.c50
-rw-r--r--usr.bin/rpcgen/rpc_util.h3
-rw-r--r--usr.bin/rpcgen/rpcgen.137
13 files changed, 936 insertions, 1063 deletions
diff --git a/usr.bin/rpcgen/rpc_clntout.c b/usr.bin/rpcgen/rpc_clntout.c
index 35498981b92..aabe048f71d 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.7 2001/11/24 19:19:59 deraadt Exp $ */
+/* $OpenBSD: rpc_clntout.c,v 1.8 2001/12/05 09:50:31 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 write_program __P((definition *));
+static void write_program __P((definition *));
static void printbody __P((proc_list *));
-extern pdeclaration();
+extern void 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
+static void
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,13 +165,12 @@ 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")) {
@@ -187,7 +186,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);
@@ -200,15 +199,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),
@@ -217,7 +216,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 403b8e33103..7c241055a84 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.9 2001/11/24 19:19:59 deraadt Exp $ */
+/* $OpenBSD: rpc_cout.c,v 1.10 2001/12/05 09:50:31 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,28 +41,30 @@ 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 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 *));
-
+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));
/*
* Emit the C-routine for the given definition
@@ -105,10 +107,10 @@ emit(def)
print_trailer();
}
-static
+static int
findtype(def, type)
definition *def;
- char *type;
+ char *type;
{
if (def->def_kind == DEF_PROGRAM || def->def_kind == DEF_CONST) {
@@ -118,22 +120,20 @@ findtype(def, type)
}
}
-static
+static int
undefined(type)
- char *type;
+ char *type;
{
definition *def;
def = (definition *) FINDVAL(defined, type, findtype);
-
-
return (def == NULL);
}
-static
+static void
print_generic_header(procname, pointerp)
- char *procname;
- int pointerp;
+ char *procname;
+ int pointerp;
{
f_print(fout, "\n");
f_print(fout, "bool_t\n");
@@ -154,46 +154,37 @@ print_generic_header(procname, pointerp)
}
}
-static
+static void
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
+static void
print_prog_header(plist)
proc_list *plist;
{
print_generic_header(plist->args.argname, 1);
}
-static
+static void
print_trailer()
{
f_print(fout, "\treturn (TRUE);\n");
f_print(fout, "}\n");
}
-
-static
+static void
print_ifopen(indent, name)
int indent;
char *name;
@@ -202,14 +193,14 @@ print_ifopen(indent, name)
f_print(fout, "if (!xdr_%s(xdrs", name);
}
-static
+static void
print_ifarg(arg)
char *arg;
{
f_print(fout, ", %s", arg);
}
-static
+static void
print_ifsizeof(prefix, type)
char *prefix;
char *type;
@@ -225,7 +216,7 @@ print_ifsizeof(prefix, type)
}
}
-static
+static void
print_ifclose(indent)
int indent;
{
@@ -236,7 +227,7 @@ print_ifclose(indent)
f_print(fout, "}\n");
}
-static
+static void
print_ifstat(indent, prefix, type, rel, amax, objname, name)
int indent;
char *prefix;
@@ -314,7 +305,7 @@ print_ifstat(indent, prefix, type, rel, amax, objname, name)
}
/* ARGSUSED */
-static
+static void
emit_enum(def)
definition *def;
{
@@ -323,7 +314,7 @@ emit_enum(def)
print_ifclose(1);
}
-static
+static void
emit_program(def)
definition *def;
{
@@ -344,8 +335,7 @@ emit_program(def)
}
}
-
-static
+static void
emit_union(def)
definition *def;
{
@@ -359,7 +349,6 @@ 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;
@@ -407,7 +396,7 @@ emit_union(def)
f_print(fout, "\t}\n");
}
-static
+static void
emit_struct(def)
definition *def;
{
@@ -419,7 +408,6 @@ 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);
@@ -433,10 +421,9 @@ emit_struct(def)
size = 0;
can_inline = 0;
for (dl = def->def.st.decls; dl != NULL; dl = dl->next)
- 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.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 {
@@ -459,25 +446,22 @@ 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;
for (dl = def->def.st.decls; dl != NULL; dl = dl->next) { /* xxx */
/* now walk down the list and check for basic types */
- 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.prefix == NULL &&
+ (ptr = find_type(dl->decl.type)) != NULL &&
+ (dl->decl.rel == REL_ALIAS || dl->decl.rel == REL_VECTOR)) {
if (i == 0)
cur = dl;
i++;
@@ -503,7 +487,6 @@ 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();
}
@@ -514,7 +497,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 */
@@ -523,9 +506,6 @@ emit_struct(def)
cur = cur->next;
}
} else {
-
-
-
/* were already looking at a
* xdr_inlineable structure */
if (sizestr == NULL)
@@ -559,6 +539,7 @@ emit_struct(def)
f_print(fout, "\t\t}\n");
}
+ }
size = 0;
i = 0;
sizestr = NULL;
@@ -566,7 +547,7 @@ emit_struct(def)
}
}
- if (i > 0)
+ if (i > 0) {
if (sizestr == NULL && size < doinline) {
/* don't expand into inline code if size <
* doinline */
@@ -575,7 +556,6 @@ emit_struct(def)
cur = cur->next;
}
} else {
-
/* were already looking at a xdr_inlineable
* structure */
if (sizestr == NULL)
@@ -609,6 +589,7 @@ emit_struct(def)
f_print(fout, "\t\t}\n");
}
+ }
flag = GET;
}
f_print(fout, "\t\treturn (TRUE);\n\t}\n\n");
@@ -619,7 +600,7 @@ emit_struct(def)
print_stat(1, &dl->decl);
}
-static
+static void
emit_typedef(def)
definition *def;
{
@@ -628,11 +609,10 @@ 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
+static void
print_stat(indent, dec)
declaration *dec;
int indent;
@@ -651,16 +631,14 @@ 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:
@@ -677,6 +655,7 @@ emit_inline(decl, flag)
}
}
+void
emit_single_in_line(decl, flag, rel)
declaration *decl;
int flag;
@@ -685,8 +664,6 @@ emit_single_in_line(decl, flag, rel)
char *upp_case;
int freed = 0;
-
-
if (flag == PUT)
f_print(fout, "\t\tIXDR_PUT_");
else
@@ -718,17 +695,14 @@ 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");
@@ -741,5 +715,4 @@ upcase(str)
*ptr = '\0';
return (hptr);
-
}
diff --git a/usr.bin/rpcgen/rpc_hout.c b/usr.bin/rpcgen/rpc_hout.c
index bf180536c9c..8bbc81fe6ba 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.8 2001/11/24 19:19:59 deraadt Exp $ */
+/* $OpenBSD: rpc_hout.c,v 1.9 2001/12/05 09:50:31 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
@@ -35,7 +35,7 @@ static char sccsid[] = "@(#)rpc_hout.c 1.12 89/02/22 (C) 1987 SMI";
#endif
/*
- * rpc_hout.c, Header file outputter for the RPC protocol compiler
+ * rpc_hout.c, Header file outputter for the RPC protocol compiler
*/
#include <sys/cdefs.h>
#include <stdio.h>
@@ -43,33 +43,35 @@ static char sccsid[] = "@(#)rpc_hout.c 1.12 89/02/22 (C) 1987 SMI";
#include "rpc_parse.h"
#include "rpc_util.h"
-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 *));
+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 *);
/*
- * Print the C-version of an xdr definition
+ * Print the C-version of an xdr definition
*/
void
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);
@@ -91,10 +93,9 @@ 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));
}
}
@@ -108,39 +109,38 @@ print_funcdef(def)
f_print(fout, "\n");
pprogramdef(def);
break;
- }
+ }
}
-pxdrfuncdecl( name, pointerp )
-char* name;
-int pointerp;
+void
+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
+static void
pconstdef(def)
definition *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
+static void
pargdef(def)
definition *def;
{
@@ -149,46 +149,41 @@ 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" );
- }
- f_print(fout, "};\n");
- f_print(fout, "typedef struct %s %s;\n", name, name);
- pxdrfuncdecl( name,NULL );
- f_print( fout, "\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");
}
-
+ }
}
-
-static
+static void
pstructdef(def)
definition *def;
{
- decl_list *l;
char *name = def->def_name;
+ decl_list *l;
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
+static void
puniondef(def)
definition *def;
{
@@ -205,19 +200,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
+static void
pdefine(name, num)
char *name;
char *num;
@@ -225,7 +220,7 @@ pdefine(name, num)
f_print(fout, "#define %s %s\n", name, num);
}
-static
+static void
puldefine(name, num)
char *name;
char *num;
@@ -233,7 +228,7 @@ puldefine(name, num)
f_print(fout, "#define %s ((u_long)%s)\n", name, num);
}
-static
+static int
define_printed(stop, start)
proc_list *stop;
version_list *start;
@@ -254,7 +249,7 @@ define_printed(stop, start)
/* NOTREACHED */
}
-static
+static void
pprogramdef(def)
definition *def;
{
@@ -262,105 +257,98 @@ 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);
- /*
- * Print out 3 definitions, one for ANSI-C, another for C++,
- * a third for old style C
+ /*
+ * 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);
/*
- * mode 0 == cplusplus, mode 1 = ANSI-C, mode 2 = old style C
+ * 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
+static void
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
+static void
penumdef(def)
definition *def;
{
@@ -392,7 +380,7 @@ penumdef(def)
f_print(fout, "typedef enum %s %s;\n", name, name);
}
-static
+static void
ptypedef(def)
definition *def;
{
@@ -401,7 +389,6 @@ 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";
@@ -439,6 +426,7 @@ ptypedef(def)
}
}
+void
pdeclaration(name, dec, tab, separator)
char *name;
declaration *dec;
@@ -449,9 +437,8 @@ 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 ");
@@ -493,10 +480,10 @@ pdeclaration(name, dec, tab, separator)
break;
}
}
- f_print(fout, separator );
+ f_print(fout, separator);
}
-static
+static int
undefined2(type, stop)
char *type;
char *stop;
diff --git a/usr.bin/rpcgen/rpc_main.c b/usr.bin/rpcgen/rpc_main.c
index df5c8aa4ed8..9a006c4711c 100644
--- a/usr.bin/rpcgen/rpc_main.c
+++ b/usr.bin/rpcgen/rpc_main.c
@@ -1,5 +1,5 @@
-/* $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 $ */
+/* $OpenBSD: rpc_main.c,v 1.11 2001/12/05 09:50:31 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
* unrestricted use provided that this legend is included on all tape
@@ -31,15 +31,15 @@
*/
#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.10 2001/11/24 19:19:59 deraadt Exp $";
+static char sccsid[] = "@(#)rpc_main.c 1.30 89/03/30 (C) 1987 SMI";
+static char cvsid[] = "$OpenBSD: rpc_main.c,v 1.11 2001/12/05 09:50:31 deraadt Exp $";
#endif
/*
- * rpc_main.c, Top level of the RPC protocol compiler.
+ * rpc_main.c, Top level of the RPC protocol compiler.
*/
-#define RPCGEN_VERSION "199506" /* This program's version (year & month) */
+#define RPCGEN_VERSION "199506"/* This program's version (year & month) */
#include <stdio.h>
#include <stdlib.h>
@@ -59,72 +59,75 @@ static char cvsid[] = "$OpenBSD: rpc_main.c,v 1.10 2001/11/24 19:19:59 deraadt E
#include "rpc_scan.h"
#define EXTEND 1 /* alias for TRUE */
-#define DONT_EXTEND 0 /* alias for FALSE */
+#define DONT_EXTEND 0 /* alias for FALSE */
#define SVR4_CPP "/usr/ccs/lib/cpp"
#define SUNOS_CPP "/lib/cpp"
-static int cppDefined = 0; /* explicit path for C preprocessor */
+static int cppDefined = 0; /* explicit path for C preprocessor */
struct commandline {
- int cflag; /* xdr C routines */
- int hflag; /* header file */
- int lflag; /* client side stubs */
- int mflag; /* server side stubs */
- int nflag; /* netid flag */
- int sflag; /* server stubs for the given transport */
- int tflag; /* dispatch Table file */
- int Ssflag; /* produce server sample code */
- int Scflag; /* produce client sample code */
- char *infile; /* input module name */
- char *outfile; /* output module name */
+ int cflag; /* xdr C routines */
+ int hflag; /* header file */
+ int lflag; /* client side stubs */
+ int mflag; /* server side stubs */
+ int nflag; /* netid flag */
+ int sflag; /* server stubs for the given transport */
+ int tflag; /* dispatch Table file */
+ int Ssflag; /* produce server sample code */
+ int Scflag; /* produce client sample code */
+ char *infile; /* input module name */
+ char *outfile;/* output module name */
};
+static char *cmdname;
-static char *cmdname;
-
-static char *svcclosetime = "120";
-static char *CPP = "/usr/bin/cpp";
-static char CPPFLAGS[] = "-C";
-static char pathbuf[MAXPATHLEN];
-static char *allv[] = {
+static char *svcclosetime = "120";
+static char *CPP = "/usr/bin/cpp";
+static char CPPFLAGS[] = "-C";
+static char pathbuf[MAXPATHLEN];
+static char *allv[] = {
"rpcgen", "-s", "udp", "-s", "tcp",
};
-static int allc = sizeof(allv)/sizeof(allv[0]);
-static char *allnv[] = {
+static int allc = sizeof(allv) / sizeof(allv[0]);
+static char *allnv[] = {
"rpcgen", "-s", "netpath",
};
-static int allnc = sizeof(allnv)/sizeof(allnv[0]);
+static int allnc = sizeof(allnv) / sizeof(allnv[0]);
#define ARGLISTLEN 20
#define FIXEDARGS 2
-static char *arglist[ARGLISTLEN];
-static int argcount = FIXEDARGS;
+static char *arglist[ARGLISTLEN];
+static int argcount = FIXEDARGS;
-int nonfatalerrors; /* errors */
-int inetdflag/* = 1*/; /* Support for inetd */ /* is now the default */
-int pmflag; /* Support for port monitors */
-int logflag; /* Use syslog instead of fprintf for errors */
-int tblflag; /* Support for dispatch table file */
-int callerflag; /* Generate svc_caller() function */
+int nonfatalerrors; /* errors */
+int inetdflag /* = 1 */ ; /* Support for inetd *//* is now the
+ * default */
+int pmflag; /* Support for port monitors */
+int logflag; /* Use syslog instead of fprintf for errors */
+int tblflag; /* Support for dispatch table file */
+int callerflag; /* Generate svc_caller() function */
#define INLINE 3
-/*length at which to start doing an inline */
-
-int doinline=INLINE; /* length at which to start doing an inline. 3 = default
- if 0, no xdr_inline code */
-
-int indefinitewait; /* If started by port monitors, hang till it wants */
-int exitnow; /* If started by port monitors, exit after the call */
-int timerflag; /* TRUE if !indefinite && !exitnow */
-int newstyle; /* newstyle of passing arguments (by value) */
-int Cflag = 0 ; /* ANSI C syntax */
-static int allfiles; /* generate all files */
-int tirpcflag = 0; /* generating code for tirpc, by default */
+/* length at which to start doing an inline */
+
+int doinline = INLINE; /* length at which to start doing an
+ * inline. 3 = default if 0, no
+ * xdr_inline code */
+
+int indefinitewait; /* If started by port monitors, hang till it
+ * wants */
+int exitnow; /* If started by port monitors, exit after
+ * the call */
+int timerflag; /* TRUE if !indefinite && !exitnow */
+int newstyle; /* newstyle of passing arguments (by value) */
+int Cflag = 0; /* ANSI C syntax */
+static int allfiles; /* generate all files */
+int tirpcflag = 0; /* generating code for tirpc, by default */
#ifdef __MSDOS__
-static char *dos_cppfile = NULL;
+static char *dos_cppfile = NULL;
#endif
static c_output __P((char *, char *, int, char *));
@@ -140,28 +143,26 @@ static void putarg __P((int, char *));
static void clear_args __P((void));
static void checkfiles __P((char *, char *));
static int parseargs __P((int, char **, struct commandline *));
-static usage __P((void));
-static options_usage __P((void));
-
+static usage __P((void));
+int
main(argc, argv)
int argc;
char *argv[];
{
struct commandline cmd;
- (void) memset((char *)&cmd, 0, sizeof (struct commandline));
+ (void) memset((char *) &cmd, 0, sizeof(struct commandline));
clear_args();
if (!parseargs(argc, argv, &cmd))
usage();
- if (cmd.cflag || cmd.hflag || cmd.lflag || cmd.tflag || cmd.sflag ||
- cmd.mflag || cmd.nflag || cmd.Ssflag || cmd.Scflag ) {
- checkfiles(cmd.infile, cmd.outfile);
- }
- else
- checkfiles(cmd.infile,NULL);
+ if (cmd.cflag || cmd.hflag || cmd.lflag || cmd.tflag || cmd.sflag ||
+ cmd.mflag || cmd.nflag || cmd.Ssflag || cmd.Scflag) {
+ checkfiles(cmd.infile, cmd.outfile);
+ } else
+ checkfiles(cmd.infile, NULL);
if (cmd.cflag) {
c_output(cmd.infile, "-DRPC_XDR", DONT_EXTEND, cmd.outfile);
@@ -170,14 +171,14 @@ main(argc, argv)
} else if (cmd.lflag) {
l_output(cmd.infile, "-DRPC_CLNT", DONT_EXTEND, cmd.outfile);
} else if (cmd.sflag || cmd.mflag || (cmd.nflag)) {
- s_output(argc, argv, cmd.infile, "-DRPC_SVC", DONT_EXTEND,
+ s_output(argc, argv, cmd.infile, "-DRPC_SVC", DONT_EXTEND,
cmd.outfile, cmd.mflag, cmd.nflag);
} else if (cmd.tflag) {
t_output(cmd.infile, "-DRPC_TBL", DONT_EXTEND, cmd.outfile);
- } else if (cmd.Ssflag) {
- svc_output(cmd.infile, "-DRPC_SERVER", DONT_EXTEND, cmd.outfile);
+ } else if (cmd.Ssflag) {
+ svc_output(cmd.infile, "-DRPC_SERVER", DONT_EXTEND, cmd.outfile);
} else if (cmd.Scflag) {
- clnt_output(cmd.infile, "-DRPC_CLIENT", DONT_EXTEND, cmd.outfile);
+ clnt_output(cmd.infile, "-DRPC_CLIENT", DONT_EXTEND, cmd.outfile);
} else {
/* the rescans are required, since cpp may effect input */
c_output(cmd.infile, "-DRPC_XDR", EXTEND, "_xdr.c");
@@ -186,24 +187,24 @@ main(argc, argv)
reinitialize();
l_output(cmd.infile, "-DRPC_CLNT", EXTEND, "_clnt.c");
reinitialize();
- if (inetdflag || !tirpcflag )
- s_output(allc, allv, cmd.infile, "-DRPC_SVC", EXTEND,
- "_svc.c", cmd.mflag, cmd.nflag);
+ if (inetdflag || !tirpcflag)
+ s_output(allc, allv, cmd.infile, "-DRPC_SVC", EXTEND,
+ "_svc.c", cmd.mflag, cmd.nflag);
else
- s_output(allnc, allnv, cmd.infile, "-DRPC_SVC",
- EXTEND, "_svc.c", cmd.mflag, cmd.nflag);
+ s_output(allnc, allnv, cmd.infile, "-DRPC_SVC",
+ EXTEND, "_svc.c", cmd.mflag, cmd.nflag);
if (tblflag) {
reinitialize();
t_output(cmd.infile, "-DRPC_TBL", EXTEND, "_tbl.i");
}
if (allfiles) {
- reinitialize();
- svc_output(cmd.infile, "-DRPC_SERVER", EXTEND, "_server.c");
+ reinitialize();
+ svc_output(cmd.infile, "-DRPC_SERVER", EXTEND, "_server.c");
}
if (allfiles) {
- reinitialize();
- clnt_output(cmd.infile, "-DRPC_CLIENT", EXTEND, "_client.c");
- }
+ reinitialize();
+ clnt_output(cmd.infile, "-DRPC_CLIENT", EXTEND, "_client.c");
+ }
}
#ifdef __MSDOS__
if (dos_cppfile != NULL) {
@@ -216,7 +217,7 @@ main(argc, argv)
}
/*
- * add extension to filename
+ * add extension to filename
*/
static char *
extendfile(path, ext)
@@ -233,22 +234,20 @@ extendfile(path, ext)
file++;
res = alloc(strlen(file) + strlen(ext) + 1);
- if (res == NULL) {
+ if (res == NULL)
abort();
- }
p = strrchr(file, '.');
- if (p == NULL) {
+ if (p == NULL)
p = file + strlen(file);
- }
(void) strcpy(res, file);
(void) strcpy(res + (p - file), ext);
return (res);
}
/*
- * Open output file with given extension
+ * Open output file with given extension
*/
-static
+static void
open_output(infile, outfile)
char *infile;
char *outfile;
@@ -258,10 +257,9 @@ open_output(infile, outfile)
fout = stdout;
return;
}
-
if (infile != NULL && streq(outfile, infile)) {
f_print(stderr, "%s: output would overwrite %s\n", cmdname,
- infile);
+ infile);
crash();
}
fout = fopen(outfile, "w");
@@ -284,82 +282,88 @@ add_warning()
}
/* clear list of arguments */
-static void clear_args()
+static void
+clear_args()
{
- int i;
- for( i=FIXEDARGS; i<ARGLISTLEN; i++ )
- arglist[i] = NULL;
- argcount = FIXEDARGS;
+ int i;
+ for (i = FIXEDARGS; i < ARGLISTLEN; i++)
+ arglist[i] = NULL;
+ argcount = FIXEDARGS;
}
/* make sure that a CPP exists */
-static void find_cpp()
+static void
+find_cpp()
{
- struct stat buf;
-
- 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 */
- fprintf( stderr, "cannot find any C preprocessor: %s\n", CPP );
- crash();
- }
- }
- }
+ struct stat buf;
+
+ /* SVR4 or explicit cpp does not exist */
+ if (stat(CPP, &buf) < 0) {
+ 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 */
+ fprintf(stderr,
+ "cannot find any C preprocessor: %s\n", CPP);
+ crash();
+ }
+ }
+ }
}
/*
- * Open input file with given define for C-preprocessor
+ * Open input file with given define for C-preprocessor
*/
static
open_input(infile, define)
- char *infile;
- char *define;
+ char *infile;
+ char *define;
{
- int pd[2];
+ int pd[2];
infilename = (infile == NULL) ? "<stdin>" : infile;
#ifdef __MSDOS__
#define DOSCPP "\\prog\\bc31\\bin\\cpp.exe"
- { int retval;
- char drive[MAXDRIVE], dir[MAXDIR], name[MAXFILE], ext[MAXEXT];
- char cppfile[MAXPATH];
- char *cpp;
-
- if ((cpp = searchpath("cpp.exe")) == NULL
- && (cpp = getenv("RPCGENCPP")) == NULL)
- cpp = DOSCPP;
-
- putarg(0, cpp);
- putarg(1, "-P-");
- putarg(2, CPPFLAGS);
- addarg(define);
- addarg(infile);
- addarg(NULL);
-
- retval = spawnvp(P_WAIT, arglist[0], arglist);
- if (retval != 0) {
- fprintf(stderr, "%s: C PreProcessor failed\n", cmdname);
- crash();
- }
-
- fnsplit(infile, drive, dir, name, ext);
- fnmerge(cppfile, drive, dir, name, ".i");
+ {
+ int retval;
+ char drive[MAXDRIVE], dir[MAXDIR], name[MAXFILE],
+ ext[MAXEXT];
+ char cppfile[MAXPATH];
+ char *cpp;
+
+ if ((cpp = searchpath("cpp.exe")) == NULL &&
+ (cpp = getenv("RPCGENCPP")) == NULL)
+ cpp = DOSCPP;
+
+ putarg(0, cpp);
+ putarg(1, "-P-");
+ putarg(2, CPPFLAGS);
+ addarg(define);
+ addarg(infile);
+ addarg(NULL);
- fin = fopen(cppfile, "r");
- if (fin == NULL) {
- f_print(stderr, "%s: ", cmdname);
- perror(cppfile);
- crash();
- }
- dos_cppfile = strdup(cppfile);
- if (dos_cppfile == NULL) {
- fprintf(stderr, "%s: out of memory\n", cmdname);
- crash();
- }
+ retval = spawnvp(P_WAIT, arglist[0], arglist);
+ if (retval != 0) {
+ fprintf(stderr, "%s: C PreProcessor failed\n", cmdname);
+ crash();
+ }
+ fnsplit(infile, drive, dir, name, ext);
+ fnmerge(cppfile, drive, dir, name, ".i");
+
+ fin = fopen(cppfile, "r");
+ if (fin == NULL) {
+ f_print(stderr, "%s: ", cmdname);
+ perror(cppfile);
+ crash();
+ }
+ dos_cppfile = strdup(cppfile);
+ if (dos_cppfile == NULL) {
+ fprintf(stderr, "%s: out of memory\n", cmdname);
+ crash();
+ }
}
#else
(void) pipe(pd);
@@ -370,7 +374,7 @@ open_input(infile, define)
putarg(1, CPPFLAGS);
addarg(define);
addarg(infile);
- addarg((char *)NULL);
+ addarg((char *) NULL);
(void) close(1);
(void) dup2(pd[1], 1);
(void) close(pd[0]);
@@ -392,40 +396,38 @@ open_input(infile, define)
}
/* valid tirpc nettypes */
-static char* valid_ti_nettypes[] =
-{
- "netpath",
- "visible",
- "circuit_v",
- "datagram_v",
- "circuit_n",
- "datagram_n",
- "udp",
- "tcp",
- "raw",
- NULL
- };
+static char *valid_ti_nettypes[] = {
+ "netpath",
+ "visible",
+ "circuit_v",
+ "datagram_v",
+ "circuit_n",
+ "datagram_n",
+ "udp",
+ "tcp",
+ "raw",
+ NULL
+};
/* valid inetd nettypes */
-static char* valid_i_nettypes[] =
-{
- "udp",
- "tcp",
- NULL
+static char *valid_i_nettypes[] = {
+ "udp",
+ "tcp",
+ NULL
};
-static int check_nettype( name, list_to_check )
-char* name;
-char* list_to_check[];
+static int
+check_nettype(name, 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;
}
/*
@@ -434,18 +436,18 @@ char* list_to_check[];
static
c_output(infile, define, extend, outfile)
- char *infile;
- char *define;
- int extend;
- char *outfile;
+ char *infile;
+ char *define;
+ int extend;
+ char *outfile;
{
- definition *def;
- char *include;
- char *outfilename;
- long tell;
+ definition *def;
+ char *include;
+ char *outfilename;
+ long tell;
c_initialize();
- open_input(infile, define);
+ open_input(infile, define);
outfilename = extend ? extendfile(infile, outfile) : outfile;
open_output(infile, outfilename);
add_warning();
@@ -454,7 +456,7 @@ c_output(infile, define, extend, outfile)
free(include);
/* .h file already contains rpc/rpc.h */
} else
- f_print(fout, "#include <rpc/rpc.h>\n");
+ f_print(fout, "#include <rpc/rpc.h>\n");
tell = ftell(fout);
while (def = get_definition()) {
emit(def);
@@ -468,20 +470,20 @@ c_output(infile, define, extend, outfile)
c_initialize()
{
- /* add all the starting basic types */
+ /* add all the starting basic types */
- add_type(1,"int");
- add_type(1,"long");
- add_type(1,"short");
- add_type(1,"bool");
+ add_type(1, "int");
+ add_type(1, "long");
+ add_type(1, "short");
+ add_type(1, "bool");
- add_type(1,"u_int");
- add_type(1,"u_long");
- add_type(1,"u_short");
+ add_type(1, "u_int");
+ add_type(1, "u_long");
+ add_type(1, "u_short");
}
-char rpcgen_table_dcl[] = "struct rpcgen_table {\n\
+char rpcgen_table_dcl[] = "struct rpcgen_table {\n\
char *(*proc)();\n\
xdrproc_t xdr_arg;\n\
unsigned len_arg;\n\
@@ -490,13 +492,14 @@ 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);
+ filename = strrchr(pathname, '/'); /* find last component */
+ filename = ((filename == 0) ? pathname : filename + 1);
guard = strdup(filename);
/* convert to upper case */
tmp = guard;
@@ -505,9 +508,9 @@ char* generate_guard( pathname )
*tmp = toupper(*tmp);
tmp++;
}
-
+
guard = extendfile(guard, "_H_RPCGEN");
- return( guard );
+ return (guard);
}
/*
@@ -516,24 +519,24 @@ char* generate_guard( pathname )
static
h_output(infile, define, extend, outfile)
- char *infile;
- char *define;
- int extend;
- char *outfile;
+ char *infile;
+ char *define;
+ int extend;
+ char *outfile;
{
- definition *def;
- char *outfilename;
- long tell;
- char *guard;
- list *l;
+ definition *def;
+ char *outfilename;
+ long tell;
+ char *guard;
+ list *l;
open_input(infile, define);
- outfilename = extend ? extendfile(infile, outfile) : outfile;
+ outfilename = extend ? extendfile(infile, outfile) : outfile;
open_output(infile, outfilename);
add_warning();
- guard = generate_guard( outfilename ? outfilename: infile );
+ guard = generate_guard(outfilename ? outfilename : infile);
- f_print(fout,"#ifndef _%s\n#define _%s\n\n", guard,
+ f_print(fout, "#ifndef _%s\n#define _%s\n\n", guard,
guard);
f_print(fout, "#define RPCGEN_VERSION\t%s\n\n", RPCGEN_VERSION);
@@ -545,9 +548,10 @@ h_output(infile, define, extend, outfile)
print_datadef(def);
}
- /* print function declarations.
- Do this after data definitions because they might be used as
- arguments for functions */
+ /*
+ * print function declarations. Do this after data definitions
+ * because they might be used as arguments for functions
+ */
for (l = defined; l != NULL; l = l->next) {
print_funcdef(l->val);
}
@@ -564,19 +568,19 @@ h_output(infile, define, extend, outfile)
*/
static
s_output(argc, argv, infile, define, extend, outfile, nomain, netflag)
- int argc;
- char *argv[];
- char *infile;
- char *define;
- int extend;
- char *outfile;
- int nomain;
- int netflag;
+ int argc;
+ char *argv[];
+ char *infile;
+ char *define;
+ int extend;
+ char *outfile;
+ int nomain;
+ int netflag;
{
- char *include;
- definition *def;
- int foundprogram = 0;
- char *outfilename;
+ char *include;
+ definition *def;
+ int foundprogram = 0;
+ char *outfilename;
open_input(infile, define);
outfilename = extend ? extendfile(infile, outfile) : outfile;
@@ -586,57 +590,54 @@ s_output(argc, argv, infile, define, extend, outfile, nomain, netflag)
f_print(fout, "#include \"%s\"\n", include);
free(include);
} else
- f_print(fout, "#include <rpc/rpc.h>\n");
+ f_print(fout, "#include <rpc/rpc.h>\n");
f_print(fout, "#include <stdio.h>\n");
- f_print(fout, "#include <stdlib.h>/* getenv, exit */\n");
+ f_print(fout, "#include <stdlib.h>/* getenv, exit */\n");
if (Cflag) {
- f_print (fout,
+ f_print(fout,
"#include <rpc/pmap_clnt.h> /* for pmap_unset */\n");
- f_print (fout, "#include <string.h> /* strcmp */ \n");
+ f_print(fout, "#include <string.h> /* strcmp */ \n");
}
- f_print(fout, "#include <netdb.h>\n"); /*evas*/
+ f_print(fout, "#include <netdb.h>\n"); /* evas */
if (strcmp(svcclosetime, "-1") == 0)
indefinitewait = 1;
else if (strcmp(svcclosetime, "0") == 0)
exitnow = 1;
else if (inetdflag || pmflag) {
f_print(fout, "#include <signal.h>\n");
- timerflag = 1;
+ timerflag = 1;
}
-
- if( !tirpcflag && inetdflag )
- f_print(fout, "#include <sys/ttycom.h>/* TIOCNOTTY */\n");
- 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 )
- f_print(fout, "#include <unistd.h> /* setsid */\n");
+ if (!tirpcflag && inetdflag)
+ f_print(fout, "#include <sys/ttycom.h>/* TIOCNOTTY */\n");
+ 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)
+ f_print(fout, "#include <unistd.h> /* setsid */\n");
}
- if( tirpcflag )
- f_print(fout, "#include <sys/types.h>\n");
+ if (tirpcflag)
+ f_print(fout, "#include <sys/types.h>\n");
f_print(fout, "#include <memory.h>\n");
if (tirpcflag)
f_print(fout, "#include <stropts.h>\n");
- if (inetdflag || !tirpcflag ) {
+ if (inetdflag || !tirpcflag) {
f_print(fout, "#include <sys/socket.h>\n");
f_print(fout, "#include <netinet/in.h>\n");
- }
-
- if ( (netflag || pmflag) && tirpcflag ) {
+ }
+ if ((netflag || pmflag) && tirpcflag) {
f_print(fout, "#include <netconfig.h>\n");
}
- if (/*timerflag &&*/ tirpcflag)
+ if ( /* timerflag && */ tirpcflag)
f_print(fout, "#include <sys/resource.h> /* rlimit */\n");
if (logflag || inetdflag || pmflag) {
f_print(fout, "#include <syslog.h>\n");
f_print(fout, "#include <errno.h>\n");
}
-
/* for ANSI-C */
f_print(fout, "\n#ifdef __STDC__\n#define SIG_PF void(*)(int)\n#endif\n");
@@ -650,14 +651,14 @@ s_output(argc, argv, infile, define, extend, outfile, nomain, netflag)
(void) unlink(outfilename);
return;
}
- if (callerflag) /*EVAS*/
- f_print(fout, "\nstatic SVCXPRT *caller;\n"); /*EVAS*/
+ if (callerflag) /* EVAS */
+ f_print(fout, "\nstatic SVCXPRT *caller;\n"); /* EVAS */
write_most(infile, netflag, nomain);
if (!nomain) {
- if( !do_registers(argc, argv) ) {
- if (outfilename)
- (void) unlink(outfilename);
- usage();
+ if (!do_registers(argc, argv)) {
+ if (outfilename)
+ (void) unlink(outfilename);
+ usage();
}
write_rest();
}
@@ -668,30 +669,30 @@ s_output(argc, argv, infile, define, extend, outfile, nomain, netflag)
*/
static
l_output(infile, define, extend, outfile)
- char *infile;
- char *define;
- int extend;
- char *outfile;
+ char *infile;
+ char *define;
+ int extend;
+ char *outfile;
{
- char *include;
- definition *def;
- int foundprogram = 0;
- char *outfilename;
+ char *include;
+ definition *def;
+ int foundprogram = 0;
+ char *outfilename;
open_input(infile, define);
outfilename = extend ? extendfile(infile, outfile) : outfile;
open_output(infile, outfilename);
add_warning();
if (Cflag)
- f_print (fout, "#include <memory.h> /* for memset */\n");
+ f_print(fout, "#include <memory.h> /* for memset */\n");
if (infile && (include = extendfile(infile, ".h"))) {
f_print(fout, "#include \"%s\"\n", include);
free(include);
} else
- f_print(fout, "#include <rpc/rpc.h>\n");
- while (def = get_definition()) {
+ f_print(fout, "#include <rpc/rpc.h>\n");
+ while (def = get_definition())
foundprogram |= (def->def_kind == DEF_PROGRAM);
- }
+
if (extend && !foundprogram) {
(void) unlink(outfilename);
return;
@@ -704,22 +705,22 @@ l_output(infile, define, extend, outfile)
*/
static
t_output(infile, define, extend, outfile)
- char *infile;
- char *define;
- int extend;
- char *outfile;
+ char *infile;
+ char *define;
+ int extend;
+ char *outfile;
{
- definition *def;
- int foundprogram = 0;
- char *outfilename;
+ definition *def;
+ int foundprogram = 0;
+ char *outfilename;
open_input(infile, define);
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) {
(void) unlink(outfilename);
return;
@@ -728,105 +729,107 @@ t_output(infile, define, extend, outfile)
}
/* sample routine for the server template */
-static
+static
svc_output(infile, define, extend, outfile)
- char *infile;
- char *define;
- int extend;
- char *outfile;
+ char *infile;
+ char *define;
+ int extend;
+ char *outfile;
{
- definition *def;
- char *include;
- char *outfilename;
- long tell;
-
- 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*/
- open_output(infile, outfilename);
- add_sample_msg();
-
- if (infile && (include = extendfile(infile, ".h"))) {
- f_print(fout, "#include \"%s\"\n", include);
- free(include);
- } else
- f_print(fout, "#include <rpc/rpc.h>\n");
-
- tell = ftell(fout);
- while (def = get_definition()) {
- write_sample_svc(def);
- }
- if (extend && tell == ftell(fout)) {
- (void) unlink(outfilename);
- }
+ definition *def;
+ char *include;
+ char *outfilename;
+ long tell;
+
+ 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 */
+ open_output(infile, outfilename);
+ add_sample_msg();
+
+ if (infile && (include = extendfile(infile, ".h"))) {
+ f_print(fout, "#include \"%s\"\n", include);
+ free(include);
+ } else
+ f_print(fout, "#include <rpc/rpc.h>\n");
+
+ tell = ftell(fout);
+ while (def = get_definition())
+ write_sample_svc(def);
+
+ if (extend && tell == ftell(fout))
+ (void) unlink(outfilename);
}
/* sample main routine for client */
-static
+static
clnt_output(infile, define, extend, outfile)
- char *infile;
- char *define;
- int extend;
- char *outfile;
+ char *infile;
+ char *define;
+ int extend;
+ char *outfile;
{
- definition *def;
- char *include;
- char *outfilename;
- long tell;
- int has_program = 0;
-
- 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*/
-
- open_output(infile, outfilename);
- add_sample_msg();
- if (infile && (include = extendfile(infile, ".h"))) {
- f_print(fout, "#include \"%s\"\n", include);
- free(include);
- } else
- f_print(fout, "#include <rpc/rpc.h>\n");
- tell = ftell(fout);
- while (def = get_definition()) {
- has_program += write_sample_clnt(def);
- }
-
- if( has_program )
- write_sample_clnt_main();
-
- if (extend && tell == ftell(fout)) {
- (void) unlink(outfilename);
- }
+ definition *def;
+ char *include, *outfilename;
+ long tell;
+ int has_program = 0;
+
+ open_input(infile, define);
+ outfilename = extend ? extendfile(infile, outfile) : outfile;
+
+ /*
+ * check if outfile already exists. if so,
+ * print an error message and exit
+ */
+ checkfiles(infile, outfilename);
+
+ open_output(infile, outfilename);
+ add_sample_msg();
+ if (infile && (include = extendfile(infile, ".h"))) {
+ f_print(fout, "#include \"%s\"\n", include);
+ free(include);
+ } else
+ f_print(fout, "#include <rpc/rpc.h>\n");
+ tell = ftell(fout);
+ while (def = get_definition())
+ has_program += write_sample_clnt(def);
+
+ if (has_program)
+ write_sample_clnt_main();
+
+ if (extend && tell == ftell(fout))
+ (void) unlink(outfilename);
}
/*
- * Perform registrations for service output
+ * Perform registrations for service output
* Return 0 if failed; 1 otherwise.
*/
static
-int do_registers(argc, argv)
- int argc;
- char *argv[];
+int
+do_registers(argc, argv)
+ int argc;
+ char *argv[];
{
- int i;
+ int i;
- if ( inetdflag || !tirpcflag) {
+ if (inetdflag || !tirpcflag) {
for (i = 1; i < argc; i++) {
if (streq(argv[i], "-s")) {
- if(!check_nettype( argv[i + 1], valid_i_nettypes ))
- return 0;
+ if (!check_nettype(argv[i + 1], valid_i_nettypes))
+ return 0;
write_inetd_register(argv[i + 1]);
i++;
}
}
} else {
for (i = 1; i < argc; i++)
- if (streq(argv[i], "-s")) {
- if(!check_nettype( argv[i + 1], valid_ti_nettypes ))
- return 0;
+ if (streq(argv[i], "-s")) {
+ if (!check_nettype(argv[i + 1], valid_ti_nettypes))
+ return 0;
write_nettype_register(argv[i + 1]);
i++;
} else if (streq(argv[i], "-n")) {
@@ -842,12 +845,12 @@ int do_registers(argc, argv)
*/
static void
addarg(cp)
- char *cp;
+ char *cp;
{
if (argcount >= ARGLISTLEN) {
f_print(stderr, "rpcgen: too many defines\n");
crash();
- /*NOTREACHED*/
+ /* NOTREACHED */
}
arglist[argcount++] = cp;
@@ -855,53 +858,51 @@ addarg(cp)
static void
putarg(where, cp)
- char *cp;
- int where;
+ char *cp;
+ int where;
{
if (where >= ARGLISTLEN) {
f_print(stderr, "rpcgen: arglist coding error\n");
crash();
- /*NOTREACHED*/
+ /* NOTREACHED */
}
arglist[where] = cp;
-
}
/*
* if input file is stdin and an output file is specified then complain
* if the file already exists. Otherwise the file may get overwritten
- * If input file does not exist, exit with an error
+ * If input file does not exist, exit with an error
*/
-
static void
-checkfiles(infile, outfile)
-char *infile;
-char *outfile;
+checkfiles(infile, outfile)
+ char *infile;
+ char *outfile;
{
- struct stat buf;
+ struct stat buf;
- if(infile) /* infile ! = NULL */
- if(stat(infile,&buf) < 0)
- {
- perror(infile);
- crash();
- }
+ if (infile) /* infile ! = NULL */
+ if (stat(infile, &buf) < 0) {
+ perror(infile);
+ crash();
+ }
#if 0
- if (outfile) {
- if (stat(outfile, &buf) < 0)
- return; /* file does not exist */
- else {
- f_print(stderr,
- "file '%s' already exists and may be overwritten\n", outfile);
- crash();
- }
- }
+ if (outfile) {
+ if (stat(outfile, &buf) < 0)
+ return; /* file does not exist */
+ else {
+ f_print(stderr,
+ "file '%s' already exists and may be overwritten\n",
+ outfile);
+ crash();
+ }
+ }
#endif
}
/*
- * Parse command line arguments
+ * Parse command line arguments
*/
static int
parseargs(argc, argv, cmd)
@@ -909,17 +910,14 @@ parseargs(argc, argv, cmd)
char *argv[];
struct commandline *cmd;
{
- int i;
- int j;
- char c;
- char flag[(1 << 8 * sizeof(char))];
- int nflags;
+ int i, j, nflags;
+ char c, flag[(1 << 8 * sizeof(char))];
cmdname = argv[0];
cmd->infile = cmd->outfile = NULL;
- if (argc < 2) {
+ if (argc < 2)
return (0);
- }
+
allfiles = 0;
flag['c'] = 0;
flag['h'] = 0;
@@ -934,8 +932,8 @@ parseargs(argc, argv, cmd)
for (i = 1; i < argc; i++) {
if (argv[i][0] != '-') {
if (cmd->infile) {
- f_print( stderr, "Cannot specify more than one input file!\n");
-
+ f_print(stderr,
+ "Cannot specify more than one input file!\n");
return (0);
}
cmd->infile = argv[i];
@@ -954,35 +952,37 @@ parseargs(argc, argv, cmd)
case 'l':
case 'm':
case 't':
- if (flag[c]) {
+ if (flag[c])
return (0);
- }
flag[c] = 1;
break;
- case 'S':
- /* sample flag: Ss or Sc.
- Ss means set flag['S'];
- Sc means set flag['C']; */
- c = argv[i][++j]; /* get next char */
- if( c == 's' )
- c = 'S';
- else if( c == 'c' )
- c = 'C';
+ case 'S':
+ /*
+ * sample flag: Ss or Sc. Ss means
+ * set flag['S']; Sc means set
+ * flag['C'];
+ */
+ c = argv[i][++j]; /* get next char */
+ if (c == 's')
+ c = 'S';
+ else if (c == 'c')
+ c = 'C';
else
- return( 0 );
+ return (0);
- if (flag[c]) {
+ if (flag[c])
return (0);
- }
flag[c] = 1;
break;
- case 'C': /* ANSI C syntax */
+ case 'C': /* ANSI C syntax */
Cflag = 1;
break;
- case 'b': /* turn TIRPC flag off for
- generating backward compatible
- */
+ case 'b':
+ /*
+ * turn TIRPC flag off for
+ * generating backward compatible
+ */
tirpcflag = 0;
break;
@@ -996,62 +996,51 @@ parseargs(argc, argv, cmd)
logflag = 1;
break;
case 'K':
- if (++i == argc) {
+ if (++i == argc)
return (0);
- }
svcclosetime = argv[i];
goto nextarg;
case 'T':
tblflag = 1;
break;
- case 'i' :
- if (++i == argc) {
+ case 'i':
+ if (++i == argc)
return (0);
- }
doinline = atoi(argv[i]);
goto nextarg;
case 'n':
case 'o':
case 's':
- if (argv[i][j - 1] != '-' ||
- argv[i][j + 1] != 0) {
+ if (argv[i][j - 1] != '-' ||
+ argv[i][j + 1] != 0)
return (0);
- }
flag[c] = 1;
- if (++i == argc) {
+ if (++i == argc)
return (0);
- }
if (c == 's') {
if (!streq(argv[i], "udp") &&
- !streq(argv[i], "tcp")) {
+ !streq(argv[i], "tcp"))
return (0);
- }
} else if (c == 'o') {
- if (cmd->outfile) {
+ if (cmd->outfile)
return (0);
- }
cmd->outfile = argv[i];
}
goto nextarg;
case 'D':
- if (argv[i][j - 1] != '-') {
+ if (argv[i][j - 1] != '-')
return (0);
- }
(void) addarg(argv[i]);
goto nextarg;
case 'Y':
- if (++i == argc) {
+ if (++i == argc)
return (0);
- }
if (snprintf(pathbuf, sizeof pathbuf,
"%s/cpp", argv[i]) >= sizeof pathbuf)
usage();
CPP = pathbuf;
cppDefined = 1;
goto nextarg;
-
-
-
default:
return (0);
}
@@ -1071,36 +1060,38 @@ parseargs(argc, argv, cmd)
cmd->Ssflag = flag['S'];
cmd->Scflag = flag['C'];
- if( tirpcflag ) {
- pmflag = inetdflag ? 0 : 1; /* pmflag or inetdflag is always TRUE */
- 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 */
- f_print( stderr, "Cannot use netid flag without TIRPC!\n");
- return( 0 );
- }
+ if (tirpcflag) {
+ pmflag = inetdflag ? 0 : 1; /* pmflag or inetdflag is
+ * always TRUE */
+ 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 */
+ f_print(stderr, "Cannot use netid flag without TIRPC!\n");
+ return (0);
+ }
}
- if( newstyle && ( tblflag || cmd->tflag) ) {
- f_print( stderr, "Cannot use table flags with newstyle!\n");
- return( 0 );
+ if (newstyle && (tblflag || cmd->tflag)) {
+ f_print(stderr, "Cannot use table flags with newstyle!\n");
+ return (0);
}
-
/* check no conflicts with file generation flags */
nflags = cmd->cflag + cmd->hflag + cmd->lflag + cmd->mflag +
- cmd->sflag + cmd->nflag + cmd->tflag + cmd->Ssflag + cmd->Scflag;
+ cmd->sflag + cmd->nflag + cmd->tflag + cmd->Ssflag + cmd->Scflag;
if (nflags == 0) {
- if (cmd->outfile != NULL || cmd->infile == NULL) {
+ if (cmd->outfile != NULL || cmd->infile == NULL)
return (0);
- }
} else if (nflags > 1) {
- f_print( stderr, "Cannot have more than one file generation flag!\n");
+ f_print(stderr, "Cannot have more than one file generation flag!\n");
return (0);
}
return (1);
@@ -1109,43 +1100,10 @@ parseargs(argc, argv, cmd)
static
usage()
{
- f_print(stderr, "usage: %s infile\n", cmdname);
- f_print(stderr, "\t%s [-a][-b][-C][-Dname[=value]] -i size [-I [-K seconds]] [-A][-L][-M toolkit][-N][-T] infile\n",
- cmdname);
- f_print(stderr, "\t%s [-c | -h | -l | -m | -t | -Sc | -Ss] [-o outfile] [infile]\n",
- cmdname);
- f_print(stderr, "\t%s [-s nettype]* [-o outfile] [infile]\n", cmdname);
- f_print(stderr, "\t%s [-n netid]* [-o outfile] [infile]\n", cmdname);
- options_usage();
- exit(1);
-}
-
-static
-options_usage()
-{
- f_print(stderr, "options:\n");
- f_print(stderr, "-A\t\tgenerate svc_caller() function\n");
- f_print(stderr, "-a\t\tgenerate all files, including samples\n");
- f_print(stderr, "-b\t\tbackward compatibility mode (generates code for SunOS 4.1)\n");
- f_print(stderr, "-c\t\tgenerate XDR routines\n");
- f_print(stderr, "-C\t\tANSI C mode\n");
- f_print(stderr, "-Dname[=value]\tdefine a symbol (same as #define)\n");
- f_print(stderr, "-h\t\tgenerate header file\n");
- f_print(stderr, "-i size\t\tsize at which to start generating inline code\n");
- f_print(stderr, "-I\t\tgenerate code for inetd support in server (for SunOS 4.1)\n");
- f_print(stderr, "-K seconds\tserver exits after K seconds of inactivity\n");
- f_print(stderr, "-l\t\tgenerate client side stubs\n");
- f_print(stderr, "-L\t\tserver errors will be printed to syslog\n");
- f_print(stderr, "-m\t\tgenerate server side stubs\n");
- f_print(stderr, "-n netid\tgenerate server code that supports named netid\n");
- f_print(stderr, "-N\t\tsupports multiple arguments and call-by-value\n");
- f_print(stderr, "-o outfile\tname of the output file\n");
- f_print(stderr, "-s nettype\tgenerate server code that supports named nettype\n");
- f_print(stderr, "-Sc\t\tgenerate sample client code that uses remote procedures\n");
- f_print(stderr, "-Ss\t\tgenerate sample server code that defines remote procedures\n");
- f_print(stderr, "-t\t\tgenerate RPC dispatch table\n");
- f_print(stderr, "-T\t\tgenerate code to support RPC dispatch tables\n");
- f_print(stderr, "-Y path\t\tdirectory name to find C preprocessor (cpp)\n");
-
+ f_print(stderr, "usage: %s [-abACILNT] [-Dname[=value]] [-i lines] "
+ "[-K seconds] infile\n", cmdname);
+ f_print(stderr, " %s [-c | -h | -l | -m | -t | -Sc | -Ss] "
+ "[-o outfile] [infile]\n", cmdname);
+ f_print(stderr, " %s [-s nettype]* [-o outfile] [infile]\n", cmdname);
exit(1);
}
diff --git a/usr.bin/rpcgen/rpc_parse.c b/usr.bin/rpcgen/rpc_parse.c
index 475745b320e..d5ab9cd0072 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.7 2001/11/24 19:19:59 deraadt Exp $ */
+/* $OpenBSD: rpc_parse.c,v 1.8 2001/12/05 09:50:31 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
@@ -35,7 +35,7 @@ static char sccsid[] = "@(#)rpc_parse.c 1.8 89/02/22 (C) 1987 SMI";
#endif
/*
- * rpc_parse.c, Parser for the RPC protocol compiler
+ * rpc_parse.c, Parser for the RPC protocol compiler
* Copyright (C) 1987 Sun Microsystems, Inc.
*/
#include <stdio.h>
@@ -165,7 +165,7 @@ def_program(defp)
do {
/* get result type */
plist = ALLOC(proc_list);
- get_type(&plist->res_prefix, &plist->res_type,
+ get_type(&plist->res_prefix, &plist->res_type,
DEF_PROGRAM);
if (streq(plist->res_type, "opaque")) {
error("illegal result type");
@@ -176,7 +176,7 @@ def_program(defp)
/* get args - first one*/
num_args = 1;
isvoid = FALSE;
- /* type of DEF_PROGRAM in the first
+ /* type of DEF_PROGRAM in the first
* get_prog_declaration and DEF_STURCT in the next
* allows void as argument if it is the only argument
*/
@@ -188,9 +188,9 @@ 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,
+ get_prog_declaration(&dec, DEF_STRUCT,
num_args);
decls = ALLOC(decl_list);
decls->decl = dec;
@@ -203,7 +203,7 @@ def_program(defp)
if( !newstyle && num_args > 1 ) {
error("only one argument is allowed" );
}
- if (isvoid && num_args > 1) {
+ if (isvoid && num_args > 1) {
error("illegal use of void in program definition");
}
*tailp = NULL;
@@ -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);
@@ -316,7 +316,7 @@ def_union(defp)
if(peekscan(TOK_CASE,&tok))
{
- do
+ do
{
scan2(TOK_IDENT, TOK_CHARCONST, &tok);
cases->contflag=1; /* continued case statement */
@@ -325,8 +325,8 @@ def_union(defp)
cases = ALLOC(case_list);
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,14 +385,14 @@ 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];
for( i = 0; reserved_words[i] != NULL; i++ ) {
if( strcmp( name, reserved_words[i] ) == 0 ) {
- sprintf(tmp,
+ sprintf(tmp,
"illegal (reserved) name :\'%s\' in type definition", name );
error(tmp);
}
@@ -400,7 +400,7 @@ char* name;
if( new_type ) {
for( i = 0; reserved_types[i] != NULL; i++ ) {
if( strcmp( name, reserved_types[i] ) == 0 ) {
- sprintf(tmp,
+ sprintf(tmp,
"illegal (reserved) name :\'%s\' in type definition", name );
error(tmp);
}
@@ -486,7 +486,7 @@ get_prog_declaration(dec, dkind, num)
token tok;
char name[10]; /* argument name */
- if (dkind == DEF_PROGRAM) {
+ if (dkind == DEF_PROGRAM) {
peek(&tok);
if (tok.kind == TOK_RPAREN) { /* no arguments */
dec->rel = REL_ALIAS;
@@ -500,11 +500,11 @@ get_prog_declaration(dec, dkind, num)
dec->rel = REL_ALIAS;
if (peekscan(TOK_IDENT, &tok)) /* optional name of argument */
strcpy(name, tok.str);
- else
+ else
sprintf(name, "%s%d", ARGNAME, num); /* default name of argument */
- dec->name = (char *)strdup(name);
-
+ dec->name = (char *)strdup(name);
+
if (streq(dec->type, "void")) {
return;
}
@@ -512,7 +512,7 @@ get_prog_declaration(dec, dkind, num)
if (streq(dec->type, "opaque")) {
error("opaque -- illegal argument type");
}
- if (peekscan(TOK_STAR, &tok)) {
+ if (peekscan(TOK_STAR, &tok)) {
if (streq(dec->type, "string")) {
error("pointer to string not allowed in program arguments\n");
}
@@ -535,7 +535,7 @@ get_prog_declaration(dec, dkind, num)
}
if (streq(dec->type, "string")) {
if (dec->rel != REL_ARRAY) { /* .x specifies just string as
- * type of argument
+ * type of argument
* - make it string<>
*/
dec->rel = REL_ARRAY;
diff --git a/usr.bin/rpcgen/rpc_parse.h b/usr.bin/rpcgen/rpc_parse.h
index 1685e875047..0d47749f70b 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.4 2001/11/24 19:19:59 deraadt Exp $ */
+/* $OpenBSD: rpc_parse.h,v 1.5 2001/12/05 09:50:31 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 8951c9b79a1..a4a41fe0cfc 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.9 2001/11/24 19:19:59 deraadt Exp $ */
+/* $OpenBSD: rpc_sample.c,v 1.10 2001/12/05 09:50:31 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,17 +48,17 @@ static char sccsid[] = "@(#)rpc_sample.c 1.1 90/08/30 (C) 1987 SMI";
static char RQSTP[] = "rqstp";
void printarglist();
-static write_sample_client __P((char *, version_list *));
-static write_sample_server __P((definition *));
-static return_type __P((proc_list *));
+static void write_sample_client __P((char *, version_list *));
+static void write_sample_server __P((definition *));
+static void return_type __P((proc_list *));
void
write_sample_svc(def)
definition *def;
{
- if (def->def_kind != DEF_PROGRAM)
- return;
+ if (def->def_kind != DEF_PROGRAM)
+ return;
write_sample_server(def);
}
@@ -70,32 +70,32 @@ write_sample_clnt(def)
version_list *vp;
int count = 0;
- if (def->def_kind != DEF_PROGRAM)
- return( 0 );
+ if (def->def_kind != DEF_PROGRAM)
+ 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
-write_sample_client(program_name, vp )
- char* program_name;
+static void
+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,29 +104,29 @@ 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");*/
}
}
}
/* generate creation of client handle */
- f_print(fout, "\tclnt = clnt_create(host, %s, %s, \"%s\");\n",
+ f_print(fout, "\tclnt = clnt_create(host, %s, %s, \"%s\");\n",
program_name, vp->vers_name, tirpcflag? "netpath" : "udp");
f_print(fout, "\tif (clnt == NULL) {\n");
f_print(fout, "\t\tclnt_pcreateerror(host);\n");
@@ -135,22 +135,22 @@ write_sample_client(program_name, vp )
/* generate calls to procedures */
i = 0;
for (proc = vp->procs; proc != NULL; proc = proc->next) {
- f_print(fout, "\tresult_%d = ",++i);
+ 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
+static void
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");
+ 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");
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
+static void
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,32 +222,31 @@ 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 66c9c123beb..08cb93305f9 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.6 2001/11/24 19:19:59 deraadt Exp $ */
+/* $OpenBSD: rpc_scan.c,v 1.7 2001/12/05 09:50:31 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,13 +72,12 @@ 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)
@@ -87,13 +86,12 @@ 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)
@@ -103,14 +101,13 @@ 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)
@@ -126,7 +123,7 @@ scan_num(tokp)
}
/*
- * Peek at the next token
+ * Peek at the next token
*/
void
peek(tokp)
@@ -137,7 +134,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)
@@ -153,7 +150,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)
@@ -179,8 +176,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 {
@@ -209,7 +206,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 ':':
@@ -392,28 +389,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 9fdfc45d1bb..b5def6125a9 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.9 2001/11/24 19:19:59 deraadt Exp $ */
+/* $OpenBSD: rpc_svcout.c,v 1.10 2001/12/05 09:50:31 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);
- sprintf(tmpbuf, "%s\t\t", sp);
+ snprintf(tmpbuf, sizeof 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,20 +177,19 @@ 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);
@@ -212,17 +211,16 @@ 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");
@@ -231,7 +229,7 @@ write_nettype_register(transp)
}
/*
- * write the rest of the service
+ * write the rest of the service
*/
void
write_rest()
@@ -245,9 +243,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");
}
@@ -264,26 +262,22 @@ void
write_programs(storage)
char *storage;
{
- list *l;
definition *def;
+ list *l;
/* 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(...))
@@ -298,31 +292,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");
}
@@ -334,18 +328,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;
@@ -356,40 +350,36 @@ 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, " ");
@@ -397,25 +387,24 @@ 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");
@@ -423,35 +412,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");
}
@@ -461,24 +450,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");
@@ -497,23 +486,22 @@ 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);
}
@@ -528,7 +516,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");
@@ -564,17 +552,17 @@ static
print_pmapunset(space)
char *space;
{
- list *l;
- definition *def;
version_list *vp;
+ definition *def;
+ list *l;
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);
}
}
}
@@ -593,16 +581,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*/
}
@@ -615,11 +603,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");
@@ -725,7 +713,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");*/
@@ -751,7 +739,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);
@@ -782,7 +770,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");
}
@@ -802,7 +790,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);
@@ -814,7 +802,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);
@@ -830,7 +818,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);
@@ -854,16 +842,13 @@ 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
*/
@@ -938,7 +923,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 ec9f529f0c7..3bf257ba556 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.6 2001/11/24 19:19:59 deraadt Exp $ */
+/* $OpenBSD: rpc_tblout.c,v 1.7 2001/12/05 09:50:31 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,30 +53,29 @@ 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 write_table __P((definition *));
-static printit __P((char *, char *));
+static void write_table __P((definition *));
+static void printit __P((char *, char *));
void
write_tables()
{
- list *l;
definition *def;
+ list *l;
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
+static void
write_table(def)
definition *def;
{
@@ -104,10 +103,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;
@@ -117,22 +116,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 );
- else
- /* do we have to do something special for newstyle */
- printit( proc->args.decls->decl.prefix,
- proc->args.decls->decl.type );
+ 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);
/* result info */
printit(proc->res_prefix, proc->res_type);
}
@@ -143,14 +142,12 @@ write_table(def)
}
}
-static
+static void
printit(prefix, type)
char *prefix;
char *type;
{
- int len;
- int tabs;
-
+ int len, tabs;
len = fprintf(fout, "\txdr_%s,", stringfix(type));
/* account for leading tab expansion */
@@ -162,7 +159,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 4871545f917..4751e9e3c81 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.6 2001/11/24 19:19:59 deraadt Exp $ */
+/* $OpenBSD: rpc_util.c,v 1.7 2001/12/05 09:50:31 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
@@ -35,13 +35,14 @@ static char sccsid[] = "@(#)rpc_util.c 1.11 89/02/22 (C) 1987 SMI";
#endif
/*
- * rpc_util.c, Utility routines for the RPC protocol compiler
+ * rpc_util.c, Utility routines for the RPC protocol compiler
*/
#include <sys/cdefs.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
+#include <unistd.h>
#include "rpc_scan.h"
#include "rpc_parse.h"
#include "rpc_util.h"
@@ -66,8 +67,9 @@ FILE *fin; /* file pointer of current input */
list *defined; /* list of defined things */
/*
- * Reinitialize the world
+ * Reinitialize the world
*/
+void
reinitialize()
{
memset(curline, 0, MAXLINESIZE);
@@ -77,8 +79,9 @@ reinitialize()
}
/*
- * string equality
+ * string equality
*/
+int
streq(a, b)
char *a;
char *b;
@@ -87,7 +90,7 @@ streq(a, b)
}
/*
- * find a value in a list
+ * find a value in a list
*/
definition *
findval(lst, val, cmp)
@@ -96,7 +99,7 @@ findval(lst, val, cmp)
int (*cmp) ();
{
-
+
for (; lst != NULL; lst = lst->next) {
if ((*cmp) (lst->val, val)) {
return (lst->val);
@@ -106,7 +109,7 @@ findval(lst, val, cmp)
}
/*
- * store a value in a list
+ * store a value in a list
*/
void
storeval(lstp, val)
@@ -116,7 +119,6 @@ storeval(lstp, val)
list **l;
list *lst;
-
for (l = lstp; *l != NULL; l = (list **) & (*l)->next);
lst = ALLOC(list);
lst->val = val;
@@ -124,7 +126,7 @@ storeval(lstp, val)
*l = lst;
}
-static
+static int
findit(def, type)
definition *def;
char *type;
@@ -193,7 +195,7 @@ ptype(prefix, type, follow)
}
}
-static
+static int
typedefed(def, type)
definition *def;
char *type;
@@ -205,6 +207,7 @@ typedefed(def, type)
}
}
+int
isvectordef(type, rel)
char *type;
relation rel;
@@ -238,7 +241,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;
@@ -262,7 +265,7 @@ pvname(pname, vnum)
}
/*
- * print a useful (?) error message, and then die
+ * print a useful (?) error message, and then die
*/
void
error(msg)
@@ -276,8 +279,9 @@ error(msg)
/*
* Something went wrong, unlink any files that we may have created and then
- * die.
+ * die.
*/
+void
crash()
{
int i;
@@ -304,7 +308,7 @@ static char expectbuf[100];
static char *toktostr();
/*
- * error, token encountered was not the expected one
+ * error, token encountered was not the expected one
*/
void
expected1(exp1)
@@ -316,7 +320,7 @@ expected1(exp1)
}
/*
- * error, token encountered was not one of two expected ones
+ * error, token encountered was not one of two expected ones
*/
void
expected2(exp1, exp2)
@@ -329,7 +333,7 @@ expected2(exp1, exp2)
}
/*
- * error, token encountered was not one of 3 expected ones
+ * error, token encountered was not one of 3 expected ones
*/
void
expected3(exp1, exp2, exp3)
@@ -352,7 +356,6 @@ tabify(f, tab)
}
}
-
static token tokstrings[] = {
{TOK_IDENT, "identifier"},
{TOK_CONST, "const"},
@@ -400,7 +403,7 @@ toktostr(kind)
return (sp->str);
}
-static
+static void
printbuf()
{
char c;
@@ -409,7 +412,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 = ' ';
@@ -444,13 +447,13 @@ printwhere()
(void) fputc('\n', stderr);
}
-char *
-make_argname(pname, vname)
+char *
+make_argname(pname, vname)
char *pname;
char *vname;
{
char *name;
-
+
name = (char *)malloc(strlen(pname) + strlen(vname) + strlen(ARGEXT) + 3);
if (!name) {
fprintf(stderr, "failed in malloc");
@@ -493,8 +496,7 @@ 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 d725648241f..6d8b95e8c82 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.7 2001/11/24 19:19:59 deraadt Exp $ */
+/* $OpenBSD: rpc_util.h,v 1.8 2001/12/05 09:50:31 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,6 +104,7 @@ 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 *));
diff --git a/usr.bin/rpcgen/rpcgen.1 b/usr.bin/rpcgen/rpcgen.1
index 7c4908ccf89..7ccb5e8e542 100644
--- a/usr.bin/rpcgen/rpcgen.1
+++ b/usr.bin/rpcgen/rpcgen.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: rpcgen.1,v 1.8 2000/11/10 05:10:39 aaron Exp $
+.\" $OpenBSD: rpcgen.1,v 1.9 2001/12/05 09:50:31 deraadt Exp $
.\" $NetBSD: rpcgen.1,v 1.5.2.1 1995/12/05 02:51:02 jtc Exp $
.\" from: @(#)rpcgen.new.1 1.1 90/11/09 TIRPC 1.0; from 40.10 of 10/10/89
.\" Copyright (c) 1988,1990 Sun Microsystems, Inc. - All Rights Reserved.
@@ -10,13 +10,10 @@
.Nd RPC protocol compiler
.Sh SYNOPSIS
.Nm rpcgen
-.Ar infile
-.Nm rpcgen
-.Op Fl D Op Ar name=value
-.Op Fl A
-.Op Fl M
-.Op Fl T
+.Op Fl aALTNbC
+.Op Fl D Op Ar name Ns Op =value
.Op Fl K Ar secs
+.Op Fl i Ar lines
.Ar infile
.Nm rpcgen
.Fl c Li |
@@ -33,11 +30,6 @@
.Ar nettype
.Op Fl o Ar outfile
.Op Ar infile
-.Nm rpcgen
-.Fl s Li |
-.Ar netid
-.Op Fl o Ar outfile
-.Op Ar infile
.Sh DESCRIPTION
.Nm
is a tool that generates C code to implement an
@@ -88,29 +80,12 @@ This code would be created in
.Pp
The server created can be started both by the port monitors
(for example,
-.Em inetd
-or
-.Em listen )
+.Xr inetd 8 Ns )
or by itself.
When it is started by a port monitor,
it creates servers only for the transport for which
the file descriptor 0 was passed.
-The name of the transport must be specified
-by setting up the environment variable
-.Ev PM_TRANSPORT .
-When the server generated by
-.Nm
-is executed,
-it creates server handles for all the transports
-specified in
-.Ev NETPATH
-environment variable,
-or if it is unset,
-it creates server handles for all the visible transports from
-.Pa /etc/netconfig
-file.
-Note:
-the transports are chosen at run time and not at compile time.
+The transports are chosen at run time and not at compile time.
When the server is self-started,
it backgrounds itself by default.
A special define symbol