Remove the evil inline ==> rpcgen_inline CPP hack, rename the variable
authorJoerg Sonnenberger <joerg@dragonflybsd.org>
Sat, 19 Jun 2004 16:40:36 +0000 (16:40 +0000)
committerJoerg Sonnenberger <joerg@dragonflybsd.org>
Sat, 19 Jun 2004 16:40:36 +0000 (16:40 +0000)
properly. Use ISO C prototyps. Remove useless void casts. Do some other
style updates. Remove !defined(__DragonFly__) cases, one was checking for
__Dragonfly__, which broke buildworld with GCC 3.4. Add a break after
default: in switch statements, which is not portable and an error with
GCC 3.4 and later.

14 files changed:
usr.bin/rpcgen/Makefile
usr.bin/rpcgen/rpc_clntout.c
usr.bin/rpcgen/rpc_cout.c
usr.bin/rpcgen/rpc_hout.c
usr.bin/rpcgen/rpc_main.c
usr.bin/rpcgen/rpc_parse.c
usr.bin/rpcgen/rpc_parse.h
usr.bin/rpcgen/rpc_sample.c
usr.bin/rpcgen/rpc_scan.c
usr.bin/rpcgen/rpc_scan.h
usr.bin/rpcgen/rpc_svcout.c
usr.bin/rpcgen/rpc_tblout.c
usr.bin/rpcgen/rpc_util.c
usr.bin/rpcgen/rpc_util.h

index 9f293b0..57baf09 100644 (file)
@@ -1,14 +1,8 @@
 # $FreeBSD: src/usr.bin/rpcgen/Makefile,v 1.5.6.1 2001/04/25 11:29:34 ru Exp $
-# $DragonFly: src/usr.bin/rpcgen/Makefile,v 1.2 2003/06/17 04:29:31 dillon Exp $
+# $DragonFly: src/usr.bin/rpcgen/Makefile,v 1.3 2004/06/19 16:40:36 joerg Exp $
 
 PROG=  rpcgen
 SRCS=  rpc_main.c  rpc_clntout.c rpc_cout.c rpc_hout.c rpc_parse.c \
        rpc_sample.c rpc_scan.c rpc_svcout.c rpc_tblout.c rpc_util.c
 
-#
-# This is a kludge to work around the fact that this program
-# uses 'inline' as a variable name.
-#
-CFLAGS+=-Dinline=rpcgen_inline
-
 .include <bsd.prog.mk>
index a289d89..a5748c4 100644 (file)
@@ -27,7 +27,7 @@
  * Mountain View, California  94043
  *
  * @(#)rpc_clntout.c 1.11 89/02/22 (C) 1987 SMI
- * $DragonFly: src/usr.bin/rpcgen/rpc_clntout.c,v 1.4 2003/11/03 19:31:32 eirikn Exp $
+ * $DragonFly: src/usr.bin/rpcgen/rpc_clntout.c,v 1.5 2004/06/19 16:40:36 joerg Exp $
  */
 
 #ident "@(#)rpc_clntout.c      1.15    94/04/25 SMI"
 #include "rpc_parse.h"
 #include "rpc_util.h"
 
-extern void pdeclaration( char *, declaration *, int, char * );
-void printarglist( proc_list *, char *, char *, char *);
-static void write_program( definition * );
-static void printbody( proc_list * );
+extern void    pdeclaration(char *, declaration *, int, char *);
+void           printarglist(proc_list *, char *, char *, char *);
+static void    write_program(definition *);
+static void    printbody(proc_list *);
 
 static char RESULT[] = "clnt_res";
 
-
 #define DEFAULT_TIMEOUT 25     /* in seconds */
 
-
 void
-write_stubs()
+write_stubs(void)
 {
        list *l;
        definition *def;
@@ -65,15 +63,13 @@ write_stubs()
                DEFAULT_TIMEOUT);
        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);
-               }
        }
 }
 
 static void
-write_program(def)
-       definition *def;
+write_program(definition *def)
 {
        version_list *vp;
        proc_list *proc;
@@ -108,12 +104,9 @@ write_program(def)
 
 /* sample addargname = "clnt"; sample addargtype = "CLIENT * " */
 
-void printarglist(proc, result, addargname, addargtype)
-       proc_list *proc;
-       char *result;
-       char* addargname, * addargtype;
+void
+printarglist(proc_list *proc, char *result, char *addargname, char *addargtype)
 {
-
        decl_list *l;
 
        if (!newstyle) {
@@ -129,7 +122,8 @@ void printarglist(proc, result, addargname, addargtype)
                                f_print(fout, "*%s, %s%s)\n",
                                        result, addargtype, addargname);
                        } else
-                               f_print(fout, "*argp, %s%s)\n", addargtype, addargname);
+                               f_print(fout, "*argp, %s%s)\n", addargtype,
+                                       addargname);
                } else {
                        if (!mtflag)
                                f_print(fout, "(argp, %s)\n", addargname);
@@ -149,22 +143,21 @@ void printarglist(proc, result, addargname, addargtype)
        } else if (streq(proc->args.decls->decl.type, "void")) {
                /* newstyle, 0 argument */
                if (mtflag) {
-                               f_print(fout, "(");
-
+                       f_print(fout, "(");
                                
                        if (Cflag) {
                                ptype(proc->res_prefix, proc->res_type, 1);
                                f_print(fout, "*%s, %s%s)\n",
                                        result, addargtype, addargname);
                        }
-                       else
+                       else {
                                f_print(fout, "(%s)\n", addargname);                    
-
-               } else
-               if (Cflag)
+                       }
+               } else if (Cflag) {
                        f_print(fout, "(%s%s)\n", addargtype, addargname);
-               else
+               } else {
                        f_print(fout, "(%s)\n", addargname);
+               }
        } else {
                /* new style, 1 or multiple arguments */
                if (!Cflag) {
@@ -207,19 +200,16 @@ void printarglist(proc, result, addargname, addargtype)
 
 
 static char *
-ampr(type)
-       char *type;
+ampr(char *type)
 {
-       if (isvectordef(type, REL_ALIAS)) {
+       if (isvectordef(type, REL_ALIAS))
                return ("");
-       } else {
+       else
                return ("&");
-       }
 }
 
 static void
-printbody(proc)
-       proc_list *proc;
+printbody(proc_list *proc)
 {
        decl_list *l;
        bool_t args2 = (proc->arg_num > 1);
@@ -236,16 +226,14 @@ printbody(proc)
        }
        if (!mtflag) {
                f_print(fout, "\tstatic ");
-               if (streq(proc->res_type, "void")) {
+               if (streq(proc->res_type, "void"))
                        f_print(fout, "char ");
-               } else {
+               else
                        ptype(proc->res_prefix, proc->res_type, 0);
-               }
                f_print(fout, "%s;\n", RESULT);
                f_print(fout, "\n");
                f_print(fout, "\tmemset((char *)%s%s, 0, sizeof (%s));\n",
                        ampr(proc->res_type), RESULT, RESULT);
-
        }
        if (newstyle && !args2 &&
            (streq(proc->args.decls->decl.type, "void"))) {
@@ -259,10 +247,9 @@ printbody(proc)
                f_print(fout,
                        "(clnt_call(clnt, %s,\n\t\t(xdrproc_t) xdr_void, ", 
                        proc->proc_name);
-               f_print(fout,
-                       "(caddr_t) NULL,\n\t\t(xdrproc_t) xdr_%s, (caddr_t) %s%s,",
-                       stringfix(proc->res_type), (mtflag)?"":ampr(proc->res_type),
-                       RESULT);
+               f_print(fout, "(caddr_t) NULL,\n\t\t(xdrproc_t) xdr_%s, "
+                       "(caddr_t) %s%s,", stringfix(proc->res_type),
+                       (mtflag) ? "" : ampr(proc->res_type), RESULT);
 
                if (mtflag)
                        f_print(fout, "\n\t\tTIMEOUT));\n");
@@ -282,37 +269,37 @@ printbody(proc)
                        f_print(fout, "\treturn ");
                else
                        f_print(fout, "\tif ");                 
-               f_print(fout,
-                       "(clnt_call(clnt, %s,\n\t\t(xdrproc_t) xdr_%s",
+               f_print(fout, "(clnt_call(clnt, %s,\n\t\t(xdrproc_t) xdr_%s",
                        proc->proc_name,proc->args.argname);
-               f_print(fout,
-                       ", (caddr_t) &arg,\n\t\t(xdrproc_t) xdr_%s, (caddr_t) %s%s,",
-                       stringfix(proc->res_type), (mtflag)?"":ampr(proc->res_type),
-                       RESULT);
+               f_print(fout, ", (caddr_t) &arg,\n\t\t(xdrproc_t) xdr_%s, "
+                       "(caddr_t) %s%s,", stringfix(proc->res_type),
+                       (mtflag) ? "" : ampr(proc->res_type), RESULT);
                if (mtflag)
                        f_print(fout, "\n\t\tTIMEOUT));\n");
                else
                        f_print(fout, "\n\t\tTIMEOUT) != RPC_SUCCESS) {\n");
        } else {                /* single argument, new or old style */
-               if (!mtflag)
-                       f_print(fout,
-                       "\tif (clnt_call(clnt, %s,\n\t\t(xdrproc_t) xdr_%s, (caddr_t) %s%s,\n\t\t(xdrproc_t) xdr_%s, (caddr_t) %s%s,\n\t\tTIMEOUT) != RPC_SUCCESS) {\n",
-                       proc->proc_name,
-                       stringfix(proc->args.decls->decl.type),
-                       (newstyle ? "&" : ""),
-                       (newstyle ? proc->args.decls->decl.name : "argp"),
-                       stringfix(proc->res_type), ampr(proc->res_type),
-                       RESULT);
-               else
-                       
-               f_print(fout,
-                       "\treturn (clnt_call(clnt, %s,\n\t\t(xdrproc_t) xdr_%s, (caddr_t) %s%s,\n\t\t(xdrproc_t) xdr_%s, (caddr_t) %s%s,\n\t\tTIMEOUT));\n",
-                       proc->proc_name,
-                       stringfix(proc->args.decls->decl.type),
-                       (newstyle ? "&" : ""),
-                       (newstyle ? proc->args.decls->decl.name : "argp"),
-                       stringfix(proc->res_type), "",
-                       RESULT);
+               if (!mtflag) {
+                       f_print(fout, "\tif (clnt_call(clnt, %s,\n"
+                               "\t\t(xdrproc_t) xdr_%s, (caddr_t) %s%s,\n"
+                               "\t\t(xdrproc_t) xdr_%s, (caddr_t) %s%s,\n"
+                               "\t\tTIMEOUT) != RPC_SUCCESS) {\n",
+                               proc->proc_name,
+                               stringfix(proc->args.decls->decl.type),
+                               (newstyle ? "&" : ""),
+                               (newstyle) ? proc->args.decls->decl.name : "argp",
+                               stringfix(proc->res_type),
+                               ampr(proc->res_type), RESULT);
+               } else {
+                       f_print(fout, "\treturn (clnt_call(clnt, %s,\n"
+                               "\t\t(xdrproc_t) xdr_%s, (caddr_t) %s%s,\n"
+                               "\t\t(xdrproc_t) xdr_%s, (caddr_t) %s%s,\n"
+                               "\t\tTIMEOUT));\n", proc->proc_name,
+                               stringfix(proc->args.decls->decl.type),
+                               (newstyle ? "&" : ""),
+                               (newstyle) ? proc->args.decls->decl.name : "argp",
+                               stringfix(proc->res_type), "", RESULT);
+               }
        }
        if (!mtflag) {
                f_print(fout, "\t\treturn (NULL);\n");
index 2e87c86..47a63c5 100644 (file)
@@ -28,7 +28,7 @@
  *
  * @(#)rpc_cout.c 1.13 89/02/22 (C) 1987 SMI
  * $FreeBSD: src/usr.bin/rpcgen/rpc_cout.c,v 1.7 1999/08/28 01:05:16 peter Exp $
- * $DragonFly: src/usr.bin/rpcgen/rpc_cout.c,v 1.3 2003/11/03 19:31:32 eirikn Exp $
+ * $DragonFly: src/usr.bin/rpcgen/rpc_cout.c,v 1.4 2004/06/19 16:40:36 joerg Exp $
  */
 
 #ident "@(#)rpc_cout.c 1.14    93/07/05 SMI" 
 #include "rpc_parse.h"
 #include "rpc_util.h"
 
-static void print_header( definition * );
-static void print_trailer( void );
-static void print_stat( int , declaration * );
-static void emit_enum( definition * );
-static void emit_program( definition * );
-static void emit_union( definition * );
-static void emit_struct( definition * );
-static void emit_typedef( definition * );
-static void emit_inline( int, declaration *, int );
-static void emit_single_in_line( int, declaration *, int, relation );
+static void    print_header(definition *);
+static void    print_trailer(void);
+static void    print_stat(int , declaration *);
+static void    emit_enum(definition *);
+static void    emit_program(definition *);
+static void    emit_union(definition *);
+static void    emit_struct(definition *);
+static void    emit_typedef(definition *);
+static void    emit_inline(int, declaration *, int);
+static void    emit_single_in_line(int, declaration *, int, relation);
+static char    *upcase(char *str);
 
 /*
  * Emit the C-routine for the given definition
  */
 void
-emit(def)
-       definition *def;
+emit(definition *def)
 {
-       if (def->def_kind == DEF_CONST) {
+       if (def->def_kind == DEF_CONST)
                return;
-       }
        if (def->def_kind == DEF_PROGRAM) {
                emit_program(def);
                return;
@@ -95,38 +94,33 @@ emit(def)
                break;
                /* DEF_CONST and DEF_PROGRAM have already been handled */
        default: 
+               break;
        }
        print_trailer();
 }
 
 static int
-findtype(def, type)
-       definition *def;
-       char *type;
+findtype(definition *def, char *type)
 {
 
-       if (def->def_kind == DEF_PROGRAM || def->def_kind == DEF_CONST) {
-               return (0);
-       } else {
-               return (streq(def->def_name, type));
-       }
+       if (def->def_kind == DEF_PROGRAM || def->def_kind == DEF_CONST)
+               return(0);
+       else
+               return(streq(def->def_name, type));
 }
 
 static int
-undefined(type)
-       char *type;
+undefined(char *type)
 {
        definition *def;
 
        def = (definition *) FINDVAL(defined, type, findtype);
-       return (def == NULL);
+       return(def == NULL);
 }
 
 
 static void
-print_generic_header(procname, pointerp)
-    char* procname;
-    int pointerp;
+print_generic_header(char *procname, int pointerp)
 {
        f_print(fout, "\n");
        f_print(fout, "bool_t\n");
@@ -148,30 +142,27 @@ print_generic_header(procname, pointerp)
 }
 
 static void
-print_header(def)
-       definition *def;
+print_header(definition *def)
 {
        print_generic_header(def->def_name,
-                           def->def_kind != DEF_TYPEDEF ||
-                           !isvectordef(def->def.ty.old_type,
-                                        def->def.ty.rel));
+           def->def_kind != DEF_TYPEDEF || !isvectordef(def->def.ty.old_type,
+           def->def.ty.rel));
        /* Now add Inline support */
 
-       if (inline == 0)
+       if (rpcgen_inline == 0)
                return;
        /* May cause lint to complain. but  ... */
        f_print(fout, "\tregister long *buf;\n\n");
 }
 
 static void
-print_prog_header(plist)
-       proc_list *plist;
+print_prog_header(proc_list *plist)
 {
        print_generic_header(plist->args.argname, 1);
 }
 
 static void
-print_trailer()
+print_trailer(void)
 {
        f_print(fout, "\treturn (TRUE);\n");
        f_print(fout, "}\n");
@@ -179,26 +170,20 @@ print_trailer()
 
 
 static void
-print_ifopen(indent, name)
-       int indent;
-       char *name;
+print_ifopen(int indent, char *name)
 {
        tabify(fout, indent);
        f_print(fout, "if (!xdr_%s(xdrs", name);
 }
 
 static void
-print_ifarg(arg)
-       char *arg;
+print_ifarg(char *arg)
 {
        f_print(fout, ", %s", arg);
 }
 
 static void
-print_ifsizeof(indent, prefix, type)
-       int indent;
-       char *prefix;
-       char *type;
+print_ifsizeof(int indent, char *prefix, char *type)
 {
        if (indent) {
                f_print(fout, ",\n");
@@ -210,16 +195,14 @@ print_ifsizeof(indent, prefix, type)
                f_print(fout, "sizeof (bool_t), (xdrproc_t) xdr_bool");
        } else {
                f_print(fout, "sizeof (");
-               if (undefined(type) && prefix) {
+               if (undefined(type) && prefix)
                        f_print(fout, "%s ", prefix);
-               }
                f_print(fout, "%s), (xdrproc_t) xdr_%s", type, type);
        }
 }
 
 static void
-print_ifclose(indent)
-       int indent;
+print_ifclose(int indent)
 {
        f_print(fout, "))\n");
        tabify(fout, indent);
@@ -227,14 +210,8 @@ print_ifclose(indent)
 }
 
 static void
-print_ifstat(indent, prefix, type, rel, amax, objname, name)
-       int indent;
-       char *prefix;
-       char *type;
-       relation rel;
-       char *amax;
-       char *objname;
-       char *name;
+print_ifstat(int indent, char *prefix, char *type, relation rel, char *amax,
+            char *objname, char *name)
 {
        char *alt = NULL;
 
@@ -246,11 +223,11 @@ print_ifstat(indent, prefix, type, rel, amax, objname, name)
                print_ifsizeof(0, prefix, type);
                break;
        case REL_VECTOR:
-               if (streq(type, "string")) {
+               if (streq(type, "string"))
                        alt = "string";
-               } else if (streq(type, "opaque")) {
+               else if (streq(type, "opaque"))
                        alt = "opaque";
-               }
+
                if (alt) {
                        print_ifopen(indent, alt);
                        print_ifarg(objname);
@@ -260,25 +237,23 @@ print_ifstat(indent, prefix, type, rel, amax, objname, name)
                        f_print(fout, "%s", objname);
                }
                print_ifarg(amax);
-               if (!alt) {
+               if (!alt)
                        print_ifsizeof(indent + 1, prefix, type);
-               }
                break;
        case REL_ARRAY:
-               if (streq(type, "string")) {
+               if (streq(type, "string"))
                        alt = "string";
-               } else if (streq(type, "opaque")) {
+               else if (streq(type, "opaque"))
                        alt = "bytes";
-               }
+
                if (streq(type, "string")) {
                        print_ifopen(indent, alt);
                        print_ifarg(objname);
                } else {
-                       if (alt) {
+                       if (alt)
                                print_ifopen(indent, alt);
-                       } else {
+                       else
                                print_ifopen(indent, "array");
-                       }
                        print_ifarg("(char **)");
                        if (*objname == '&') {
                                f_print(fout, "%s.%s_val, (u_int *) %s.%s_len",
@@ -290,9 +265,8 @@ print_ifstat(indent, prefix, type, rel, amax, objname, name)
                        }
                }
                print_ifarg(amax);
-               if (!alt) {
+               if (!alt)
                        print_ifsizeof(indent + 1, prefix, type);
-               }
                break;
        case REL_ALIAS:
                print_ifopen(indent, type);
@@ -304,8 +278,7 @@ print_ifstat(indent, prefix, type, rel, amax, objname, name)
 
 /* ARGSUSED */
 static void
-emit_enum(def)
-       definition *def;
+emit_enum(definition *def)
 {
        print_ifopen(1, "enum");
        print_ifarg("(enum_t *)objp");
@@ -313,8 +286,7 @@ emit_enum(def)
 }
 
 static void
-emit_program(def)
-       definition *def;
+emit_program(definition *def)
 {
        decl_list *dl;
        version_list *vlist;
@@ -334,8 +306,7 @@ emit_program(def)
 
 
 static void
-emit_union(def)
-       definition *def;
+emit_union(definition *def)
 {
        declaration *dflt;
        case_list *cl;
@@ -373,7 +344,7 @@ emit_union(def)
                if (!streq(dflt->type, "void")) {
                        f_print(fout, "\tdefault:\n");
                        object = alloc(strlen(def->def_name) + strlen(format) +
-strlen(dflt->name) + 1);
+                                      strlen(dflt->name) + 1);
                        if (isvectordef (dflt->type, dflt->rel)) {
                                s_print(object, vecformat, def->def_name,
                                        dflt->name);
@@ -399,9 +370,7 @@ strlen(dflt->name) + 1);
 }
 
 static void
-inline_struct(def, flag)
-definition *def;
-int flag;
+inline_struct(definition *def, int flag)
 {
        decl_list *dl;
        int i, size;
@@ -414,7 +383,8 @@ int flag;
        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");
+               f_print(fout, "\t\treturn (TRUE);\n"
+                       "\t} else if (xdrs->x_op == XDR_DECODE) {\n");
 
        i = 0;
        size = 0;
@@ -429,9 +399,9 @@ int flag;
                                cur = dl;
                        i++;
 
-                       if (dl->decl.rel == REL_ALIAS)
+                       if (dl->decl.rel == REL_ALIAS) {
                                size += ptr->length;
-                       else {
+                       else {
                                /* this code is required to handle arrays */
                                if (sizestr == NULL)
                                        plus = "";
@@ -447,9 +417,9 @@ int flag;
                                                dl->decl.array_max);
 
                                /* now concatenate to sizestr !!!! */
-                               if (sizestr == NULL)
+                               if (sizestr == NULL) {
                                        sizestr = strdup(ptemp);
-                               else{
+                               } else {
                                        sizestr = realloc(sizestr,
                                                          strlen(sizestr)
                                                          +strlen(ptemp)+1);
@@ -463,13 +433,14 @@ int flag;
                        }
                } else {
                        if (i > 0) {
-                               if (sizestr == NULL && size < inline){
+                               if (sizestr == NULL && size < rpcgen_inline){
                                        /*
                                         * don't expand into inline code
-                                        * if size < inline
+                                        * if size < rpcgen_inline
                                         */
                                        while (cur != dl){
-                                               print_stat(indent + 1, &cur->decl);
+                                               print_stat(indent + 1,
+                                                          &cur->decl);
                                                cur = cur->next;
                                        }
                                } else {
@@ -495,7 +466,7 @@ int flag;
                                                "if (buf == NULL) {\n");
 
                                        psav = cur;
-                                       while (cur != dl){
+                                       while (cur != dl) {
                                                print_stat(indent + 2, &cur->decl);
                                                cur = cur->next;
                                        }
@@ -503,7 +474,7 @@ int flag;
                                        f_print(fout, "\n\t\t} else {\n");
 
                                        cur = psav;
-                                       while (cur != dl){
+                                       while (cur != dl) {
                                                emit_inline(indent + 2, &cur->decl, flag);
                                                cur = cur->next;
                                        }
@@ -520,9 +491,9 @@ int flag;
        }
 
        if (i > 0)
-               if (sizestr == NULL && size < inline){
-                       /* don't expand into inline code if size < inline */
-                       while (cur != dl){
+               if (sizestr == NULL && size < rpcgen_inline) {
+                       /* don't expand into inline code if size < rpcgen_inline */
+                       while (cur != dl) {
                                print_stat(indent + 1, &cur->decl);
                                cur = cur->next;
                        }
@@ -531,7 +502,7 @@ int flag;
                        if (sizestr == NULL)
                                f_print(fout, "\t\tbuf = XDR_INLINE(xdrs, %d * BYTES_PER_XDR_UNIT);",
                                        size);
-                       else
+                       else {
                                if (size == 0)
                                        f_print(fout,
                                                "\t\tbuf = XDR_INLINE(xdrs, (%s) * BYTES_PER_XDR_UNIT);",
@@ -540,17 +511,18 @@ int flag;
                                        f_print(fout,
                                                "\t\tbuf = XDR_INLINE(xdrs, (%d + (%s)) * BYTES_PER_XDR_UNIT);",
                                                size, sizestr);
+                       }
 
                        f_print(fout, "\n\t\tif (buf == NULL) {\n");
                        psav = cur;
-                       while (cur != NULL){
+                       while (cur != NULL) {
                                print_stat(indent + 2, &cur->decl);
                                cur = cur->next;
                        }
                        f_print(fout, "\t\t} else {\n");
 
                        cur = psav;
-                       while (cur != dl){
+                       while (cur != dl) {
                                emit_inline(indent + 2, &cur->decl, flag);
                                cur = cur->next;
                        }
@@ -567,29 +539,30 @@ emit_struct(def)
        bas_type *ptr;
        int can_inline;
 
-       if (inline == 0) {
+       if (rpcgen_inline == 0) {
                /* No xdr_inlining at all */
                for (dl = def->def.st.decls; dl != NULL; dl = dl->next)
                        print_stat(1, &dl->decl);
                return;
        }
 
-       for (dl = def->def.st.decls; dl != NULL; dl = dl->next)
+       for (dl = def->def.st.decls; dl != NULL; dl = dl->next) {
                if (dl->decl.rel == REL_VECTOR){
                        f_print(fout, "\tint i;\n");
                        break;
                }
+       }
 
        size = 0;
        can_inline = 0;
        /*
         * Make a first pass and see if inling is possible.
         */
-       for (dl = def->def.st.decls; dl != NULL; dl = dl->next)
+       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))){
+                    (dl->decl.rel == REL_VECTOR))) {
                        if (dl->decl.rel == REL_ALIAS)
                                size += ptr->length;
                        else {
@@ -597,16 +570,17 @@ emit_struct(def)
                                break; /* can be inlined */
                        }
                } else {
-                       if (size >= inline){
+                       if (size >= rpcgen_inline) {
                                can_inline = 1;
                                break; /* can be inlined */
                        }
                        size = 0;
                }
-       if (size >= inline)
+       }
+       if (size >= rpcgen_inline)
                can_inline = 1;
 
-       if (can_inline == 0)  /* can not inline, drop back to old mode */
+       if (can_inline == 0) {  /* can not inline, drop back to old mode */
                for (dl = def->def.st.decls; dl != NULL; dl = dl->next)
                        print_stat(1, &dl->decl);
                return;
@@ -629,8 +603,7 @@ emit_struct(def)
 }
 
 static void
-emit_typedef(def)
-       definition *def;
+emit_typedef(definition *def)
 {
        char *prefix = def->def.ty.old_prefix;
        char *type = def->def.ty.old_type;
@@ -641,9 +614,7 @@ emit_typedef(def)
 }
 
 static void
-print_stat(indent, dec)
-       int indent;
-       declaration *dec;
+print_stat(int indent, declaration *dec)
 {
        char *prefix = dec->prefix;
        char *type = dec->type;
@@ -651,25 +622,20 @@ print_stat(indent, dec)
        relation rel = dec->rel;
        char name[256];
 
-       if (isvectordef(type, rel)) {
+       if (isvectordef(type, rel))
                s_print(name, "objp->%s", dec->name);
-       } else {
+       else
                s_print(name, "&objp->%s", dec->name);
-       }
        print_ifstat(indent, prefix, type, rel, amax, name, dec->name);
 }
 
 
-char *upcase ();
 
 static void
-emit_inline(indent, decl, flag)
-int indent;
-declaration *decl;
-int flag;
+emit_inline(int indent, declaration *decl, int flag)
 {
        switch (decl->rel) {
-       case  REL_ALIAS :
+       case REL_ALIAS :
                emit_single_in_line(indent, decl, flag, REL_ALIAS);
                break;
        case REL_VECTOR :
@@ -678,8 +644,7 @@ int flag;
                tabify(fout, indent + 1);
                f_print(fout, "register %s *genp;\n\n", decl->type);
                tabify(fout, indent + 1);
-               f_print(fout,
-                       "for (i = 0, genp = objp->%s;\n", decl->name);
+               f_print(fout, "for (i = 0, genp = objp->%s;\n", decl->name);
                tabify(fout, indent + 2);
                f_print(fout, "i < %s; i++) {\n", decl->array_max);
                emit_single_in_line(indent + 2, decl, flag, REL_VECTOR);
@@ -688,15 +653,12 @@ int flag;
                tabify(fout, indent);
                f_print(fout, "}\n");
        default:
+               break;
        }
 }
 
 static void
-emit_single_in_line(indent, decl, flag, rel)
-int indent;
-declaration *decl;
-int flag;
-relation rel;
+emit_single_in_line(int indent, declaration *decl, int flag, relation rel)
 {
        char *upp_case;
        int freed = 0;
@@ -704,11 +666,10 @@ relation rel;
        tabify(fout, indent);
        if (flag == PUT)
                f_print(fout, "IXDR_PUT_");
+       else if (rel == REL_ALIAS)
+               f_print(fout, "objp->%s = IXDR_GET_", decl->name);
        else
-               if (rel == REL_ALIAS)
-                       f_print(fout, "objp->%s = IXDR_GET_", decl->name);
-               else
-                       f_print(fout, "*genp++ = IXDR_GET_");
+               f_print(fout, "*genp++ = IXDR_GET_");
 
        upp_case = upcase(decl->type);
 
@@ -726,26 +687,26 @@ relation rel;
                freed = 1;
                upp_case = "U_LONG";
        }
-       if (flag == PUT)
+       if (flag == PUT) {
                if (rel == REL_ALIAS)
-                       f_print(fout,
-                               "%s(buf, objp->%s);\n", upp_case, decl->name);
+                       f_print(fout, "%s(buf, objp->%s);\n", upp_case,
+                               decl->name);
                else
                        f_print(fout, "%s(buf, *genp++);\n", upp_case);
-
-       else
+       } else {
                f_print(fout, "%s(buf);\n", upp_case);
+       }
        if (!freed)
                free(upp_case);
 }
 
-char *upcase(str)
-char *str;
+static char *
+upcase(char *str)
 {
        char *ptr, *hptr;
 
-       ptr =  (char *)malloc(strlen(str)+1);
-       if (ptr == (char *) NULL)
+       ptr =  malloc(strlen(str)+1);
+       if (ptr == NULL)
                errx(1, "malloc failed");
 
        hptr = ptr;
@@ -753,5 +714,5 @@ char *str;
                *ptr++ = toupper(*str++);
 
        *ptr = '\0';
-       return (hptr);
+       return(hptr);
 }
index 39947a8..e48e6de 100644 (file)
@@ -27,7 +27,7 @@
  * Mountain View, California  94043
  *
  * @(#)rpc_hout.c 1.12 89/02/22 (C) 1987 SMI
- * $DragonFly: src/usr.bin/rpcgen/rpc_hout.c,v 1.4 2003/11/03 19:31:32 eirikn Exp $
+ * $DragonFly: src/usr.bin/rpcgen/rpc_hout.c,v 1.5 2004/06/19 16:40:36 joerg Exp $
  */
 
 #ident "@(#)rpc_hout.c 1.16    94/04/25 SMI"
 #include "rpc_parse.h"
 #include "rpc_util.h"
 
-void storexdrfuncdecl( char *, int );
-static void pconstdef( definition * );
-static void pstructdef( definition * );
-static void puniondef( definition * );
-static void pprogramdef( definition * );
-static void pstructdef( definition * );
-static void penumdef( definition * );
-static void ptypedef( definition * );
-static void pdefine( char *, char * );
-static int undefined2( char *, char * );
-static void parglist( proc_list *, char * );
-static void pprocdef( proc_list *, version_list *, char *, int, int );
-void pdeclaration( char *, declaration *, int, char * );
+void           storexdrfuncdecl(char *, int);
+static void    pconstdef(definition *);
+static void    pstructdef(definition *);
+static void    puniondef(definition *);
+static void    pprogramdef(definition *);
+static void    pstructdef(definition *);
+static void    penumdef(definition *);
+static void    ptypedef(definition *);
+static void    pdefine(char *, char *);
+static int     undefined2(char *, char *);
+static void    parglist(proc_list *, char *);
+static void    pprocdef(proc_list *, version_list *, char *, int, int);
+void           pdeclaration(char *, declaration *, int, char *);
 
 static char RESULT[] = "clnt_res";
 
-
 /*
  * Print the C-version of an xdr definition
  */
 void
-print_datadef(def)
-       definition *def;
+print_datadef(definition *def)
 {
-
        if (def->def_kind == DEF_PROGRAM)  /* handle data only */
                return;
 
-       if (def->def_kind != DEF_CONST) {
+       if (def->def_kind != DEF_CONST)
                f_print(fout, "\n");
-       }
+
        switch (def->def_kind) {
        case DEF_STRUCT:
                pstructdef(def);
@@ -93,17 +90,17 @@ print_datadef(def)
                break;
        }
        if (def->def_kind != DEF_PROGRAM && def->def_kind != DEF_CONST) {
-           storexdrfuncdecl(def->def_name,
-                            def->def_kind != DEF_TYPEDEF ||
-                            !isvectordef(def->def.ty.old_type,
-                                         def->def.ty.rel));
+               if (def->def_kind != DEF_TYPEDEF ||
+                   !isvectordef(def->def.ty.old_type, def->def.ty.rel))
+                       storexdrfuncdecl(def->def_name, 1);
+               else
+                       storexdrfuncdecl(def->def_name, 0);
        }
 }
 
 
 void
-print_funcdef(def)
-       definition *def;
+print_funcdef(definition *def)
 {
        switch (def->def_kind) {
        case DEF_PROGRAM:
@@ -111,6 +108,7 @@ print_funcdef(def)
                pprogramdef(def);
                break;
        default:
+               break;
        }
 }
 
@@ -118,50 +116,37 @@ print_funcdef(def)
     out at the end of the file */
 
 void
-storexdrfuncdecl(name, pointerp)
-char *name;
-int pointerp;
+storexdrfuncdecl(char *name, int pointerp)
 {
        xdrfunc * xdrptr;
 
-       xdrptr = (xdrfunc *) malloc(sizeof (struct xdrfunc));
+       xdrptr = malloc(sizeof(struct xdrfunc));
 
        xdrptr->name = name;
        xdrptr->pointerp = pointerp;
        xdrptr->next = NULL;
 
-       if (xdrfunc_tail == NULL){
+       if (xdrfunc_tail == NULL)
                xdrfunc_head = xdrptr;
-               xdrfunc_tail = xdrptr;
-       } else {
+       else
                xdrfunc_tail->next = xdrptr;
-               xdrfunc_tail = xdrptr;
-       }
-
+       xdrfunc_tail = xdrptr;
 
 }
 
 void
-print_xdr_func_def(name, pointerp, i)
-char* name;
-int pointerp;
-int i;
+print_xdr_func_def(char *name, int pointerp, int i)
 {
-       if (i == 2) {
+       if (i == 2)
                f_print(fout, "extern bool_t xdr_%s();\n", name);
-               return; 
-       }
        else  
                f_print(fout, "extern  bool_t xdr_%s(XDR *, %s%s);\n", name,
                        name, pointerp ? "*" : "");
-
-
 }
 
 
 static void
-pconstdef(def)
-       definition *def;
+pconstdef(definition *def)
 {
        pdefine(def->def_name, def->def.co);
 }
@@ -170,57 +155,47 @@ pconstdef(def)
     header file
 */
 static void
-pargdef(def)
-       definition *def;
+pargdef(definition *def)
 {
        decl_list *l;
        version_list *vers;
        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);
-                               storexdrfuncdecl(name, 1);
-                               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);
+                       storexdrfuncdecl(name, 1);
+                       f_print(fout, "\n");
                }
+       }
 }
 
 
 static void
-pstructdef(def)
-       definition *def;
+pstructdef(definition *def)
 {
        decl_list *l;
        char *name = def->def_name;
 
        f_print(fout, "struct %s {\n", name);
-       for (l = def->def.st.decls; l != NULL; l = l->next) {
+       for (l = def->def.st.decls; l != NULL; l = l->next)
                pdeclaration(name, &l->decl, 1, ";\n");
-       }
+
        f_print(fout, "};\n");
        f_print(fout, "typedef struct %s %s;\n", name, name);
 }
 
 static void
-puniondef(def)
-       definition *def;
+puniondef(definition *def)
 {
        case_list *l;
        char *name = def->def_name;
@@ -228,15 +203,15 @@ puniondef(def)
 
        f_print(fout, "struct %s {\n", name);
        decl = &def->def.un.enum_decl;
-       if (streq(decl->type, "bool")) {
+       if (streq(decl->type, "bool"))
                f_print(fout, "\tbool_t %s;\n", decl->name);
-       } else {
+       else
                f_print(fout, "\t%s %s;\n", decl->type, decl->name);
-       }
+
        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")) {
@@ -248,36 +223,29 @@ puniondef(def)
 }
 
 static void
-pdefine(name, num)
-       char *name;
-       char *num;
+pdefine(char *name, char *num)
 {
        f_print(fout, "#define\t%s %s\n", name, num);
 }
 
 static void
-puldefine(name, num)
-       char *name;
-       char *num;
+puldefine(char *name, char *num)
 {
        f_print(fout, "#define\t%s ((unsigned long)(%s))\n", name, num);
 }
 
 static int
-define_printed(stop, start)
-       proc_list *stop;
-       version_list *start;
+define_printed(proc_list *stop, version_list *start)
 {
        version_list *vers;
        proc_list *proc;
 
        for (vers = start; vers != NULL; vers = vers->next) {
                for (proc = vers->procs; proc != NULL; proc = proc->next) {
-                       if (proc == stop) {
-                               return (0);
-                       } else if (streq(proc->proc_name, stop->proc_name)) {
-                               return (1);
-                       }
+                       if (proc == stop)
+                               return(0);
+                       else if (streq(proc->proc_name, stop->proc_name))
+                               return(1);
                }
        }
        abort();
@@ -293,13 +261,10 @@ pfreeprocdef(char * name, char *vers, int mode)
                f_print(fout,"_freeresult(SVCXPRT *, xdrproc_t, caddr_t);\n");
        else
                f_print(fout,"_freeresult();\n");
-
-
 }
 
 static void
-pprogramdef(def)
-       definition *def;
+pprogramdef(definition *def)
 {
        version_list *vers;
        proc_list *proc;
@@ -314,8 +279,7 @@ pprogramdef(def)
                        f_print(fout,
                                "extern struct rpcgen_table %s_%s_table[];\n",
                                locase(def->def_name), vers->vers_num);
-                       f_print(fout,
-                               "extern %s_%s_nproc;\n",
+                       f_print(fout, "extern %s_%s_nproc;\n",
                                locase(def->def_name), vers->vers_num);
                }
                puldefine(vers->vers_name, vers->vers_num);
@@ -343,13 +307,12 @@ pprogramdef(def)
                                }
                        }
                        pfreeprocdef(def->def_name, vers->vers_num, 2);
-                       
                } else {
-                       for (i = 1; i < 3; i++){
-                               if (i == 1){
+                       for (i = 1; i < 3; i++) {
+                               if (i == 1) {
                                        f_print(fout, "\n#if defined(__STDC__) || defined(__cplusplus)\n");
                                        ext = "extern  ";
-                               }else{
+                               } else {
                                        f_print(fout, "\n#else /* K&R C */\n");
                                        ext = "extern  ";
                                }
@@ -366,7 +329,7 @@ pprogramdef(def)
                                        f_print(fout, "%s", ext);
                                        pprocdef(proc, vers, "struct svc_req *", 1, i);
                                }
-                       pfreeprocdef(def->def_name, vers->vers_num, i);
+                           pfreeprocdef(def->def_name, vers->vers_num, i);
                        }
                        f_print(fout, "#endif /* K&R C */\n");
                }
@@ -374,14 +337,11 @@ pprogramdef(def)
 }
 
 static void
-pprocdef(proc, vp, addargtype, server_p, mode)
-       proc_list *proc;
-       version_list *vp;
-       char* addargtype;
-       int server_p;
-       int mode;
+pprocdef(proc_list *proc, version_list *vp, char* addargtype, int server_p,
+       int mode)
 {
-       if (mtflag) {/* Print MT style stubs */
+       if (mtflag) {
+               /* Print MT style stubs */
                if (server_p)
                        f_print(fout, "bool_t ");
                else
@@ -408,9 +368,7 @@ pprocdef(proc, vp, addargtype, server_p, mode)
 
 /* print out argument list of procedure */
 static void
-parglist(proc, addargtype)
-       proc_list *proc;
-    char* addargtype;
+parglist(proc_list *proc, char* addargtype)
 {
        decl_list *dl;
 
@@ -435,12 +393,10 @@ parglist(proc, addargtype)
        }
 
        f_print(fout, "%s);\n", addargtype);
-
 }
 
 static void
-penumdef(def)
-       definition *def;
+penumdef(definition *def)
 {
        char *name = def->def_name;
        enumval_list *l;
@@ -455,11 +411,10 @@ penumdef(def)
                        last = l->assignment;
                        count = 1;
                } else {
-                       if (last == NULL) {
+                       if (last == NULL)
                                f_print(fout, " = %d", count++);
-                       } else {
+                       else
                                f_print(fout, " = %s + %d", last, count++);
-                       }
                }
                if (l->next)
                        f_print(fout, ",\n");
@@ -471,15 +426,13 @@ penumdef(def)
 }
 
 static void
-ptypedef(def)
-       definition *def;
+ptypedef(definition *def)
 {
        char *name = def->def_name;
        char *old = def->def.ty.old_type;
        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";
@@ -489,11 +442,10 @@ ptypedef(def)
                } else if (streq(old, "bool")) {
                        old = "bool_t";
                }
-               if (undefined2(old, name) && def->def.ty.old_prefix) {
+               if (undefined2(old, name) && def->def.ty.old_prefix)
                        s_print(prefix, "%s ", def->def.ty.old_prefix);
-               } else {
+               else
                        prefix[0] = 0;
-               }
                f_print(fout, "typedef ");
                switch (rel) {
                case REL_ARRAY:
@@ -518,23 +470,19 @@ ptypedef(def)
 }
 
 void
-pdeclaration(name, dec, tab, separator)
-       char *name;
-       declaration *dec;
-       int tab;
-       char *separator;
+pdeclaration(char *name, declaration *dec, int tab, char *separator)
 {
        char buf[8];    /* enough to hold "struct ", include NUL */
        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) {
+       if (streq(dec->type, name) && !dec->prefix)
                f_print(fout, "struct ");
-       }
+
        if (streq(dec->type, "string")) {
                f_print(fout, "char *%s", dec->name);
        } else {
@@ -577,9 +525,7 @@ pdeclaration(name, dec, tab, separator)
 }
 
 static int
-undefined2(type, stop)
-       char *type;
-       char *stop;
+undefined2(char *type, char *stop)
 {
        list *l;
        definition *def;
@@ -587,12 +533,11 @@ undefined2(type, stop)
        for (l = defined; l != NULL; l = l->next) {
                def = (definition *) l->val;
                if (def->def_kind != DEF_PROGRAM) {
-                       if (streq(def->def_name, stop)) {
-                               return (1);
-                       } else if (streq(def->def_name, type)) {
-                               return (0);
-                       }
+                       if (streq(def->def_name, stop))
+                               return(1);
+                       else if (streq(def->def_name, type))
+                               return(0);
                }
        }
-       return (1);
+       return(1);
 }
index 0563113..7619465 100644 (file)
@@ -28,7 +28,7 @@
  *
  * @(#)rpc_main.c 1.30 89/03/30 (C) 1987 SMI
  * $FreeBSD: src/usr.bin/rpcgen/rpc_main.c,v 1.11 1999/08/28 01:05:16 peter Exp $
- * $DragonFly: src/usr.bin/rpcgen/rpc_main.c,v 1.8 2004/02/02 05:43:16 dillon Exp $
+ * $DragonFly: src/usr.bin/rpcgen/rpc_main.c,v 1.9 2004/06/19 16:40:36 joerg Exp $
  */
 
 
 #include "rpc_util.h"
 #include "rpc_scan.h"
 
-extern void write_sample_svc( definition * );
-extern int write_sample_clnt( definition * );
-extern void write_sample_clnt_main( void );
-extern void add_sample_msg( void );
-static void c_output( char *, char *, int, char * );
-static void h_output( char *, char *, int, char * );
-static void l_output( char *, char *, int, char * );
-static void t_output( char *, char *, int, char * );
-static void clnt_output( char *, char *, int, char * );
-
-void c_initialize( void );
-
-#if !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__DragonFly__)
-char * rindex();
-#endif
-
-static void usage( void );
-static void options_usage( void );
-static int do_registers( int, char ** );
-static int parseargs( int, char **, struct commandline * );
-static void svc_output( char *, char *, int, char * );
-static void mkfile_output( struct commandline * );
-static void s_output( int, char **, char *, char *, int, char *, int, int );
-
-#define        EXTEND  1               /* alias for TRUE */
+extern void    write_sample_svc(definition *);
+extern int     write_sample_clnt(definition *);
+extern void    write_sample_clnt_main(void);
+extern void    add_sample_msg(void);
+static void    c_output(char *, char *, int, char *);
+static void    h_output(char *, char *, int, char *);
+static void    l_output(char *, char *, int, char *);
+static void    t_output(char *, char *, int, char *);
+static void    clnt_output(char *, char *, int, char *);
+
+void           c_initialize(void);
+
+static void    usage(void);
+static void    options_usage(void);
+static int     do_registers(int, char **);
+static int     parseargs(int, char **, struct commandline *);
+static void    svc_output(char *, char *, int, char *);
+static void    mkfile_output(struct commandline *);
+static void    s_output(int, char **, char *, char *, int, char *, int, int);
+
+#define        EXTEND          1               /* alias for TRUE */
 #define        DONT_EXTEND     0               /* alias for FALSE */
 
 static int cppDefined = 0;     /* explicit path for C preprocessor */
@@ -97,10 +93,10 @@ static int allnc = sizeof (allnv)/sizeof (allnv[0]);
 /*
  * machinations for handling expanding argument list
  */
-static void addarg();          /* add another argument to the list */
-static void putarg();          /* put argument at specified location  */
-static void clear_args();      /* clear argument list */
-static void checkfiles();      /* check if out file already exists */
+static void    addarg();       /* add another argument to the list */
+static void    putarg();       /* put argument at specified location  */
+static void    clear_args();   /* clear argument list */
+static void    checkfiles();   /* check if out file already exists */
 
 
 
@@ -112,23 +108,15 @@ static int argcount = FIXEDARGS;
 
 
 int nonfatalerrors;    /* errors */
-#if defined(__FreeBSD__) || defined(__NetBSD__) || defined (__DragonFly__)
 int inetdflag = 0;     /* Support for inetd  is now the default */
-#else
-int inetdflag; /* Support for inetd  is now the default */
-#endif
 int pmflag;            /* Support for port monitors */
 int logflag;           /* Use syslog instead of fprintf for errors */
 int tblflag;           /* Support for dispatch table file */
 int mtflag = 0;                /* Support for MT */
-#if defined(__FreeBSD__) || defined(__NetBSD__) || defined (__DragonFly__)
 #define INLINE 0
-#else
-#define        INLINE 5
-#endif
 /* length at which to start doing an inline */
 
-int inline = INLINE;
+int rpcgen_inline = INLINE;
 /*
  * Length at which to start doing an inline. INLINE = default
  * if 0, no xdr_inline code
@@ -141,24 +129,18 @@ int newstyle;             /* newstyle of passing arguments (by value) */
 int Cflag = 0;         /* ANSI C syntax */
 int CCflag = 0;                /* C++ files */
 static int allfiles;   /* generate all files */
-#if defined(__FreeBSD__) || defined(__NetBSD__) || defined (__DragonFly__)
 int tirpcflag = 0;    /* generating code for tirpc, by default */
-#else
-int tirpcflag = 1;    /* generating code for tirpc, by default */
-#endif
 xdrfunc *xdrfunc_head = NULL; /* xdr function list */
 xdrfunc *xdrfunc_tail = NULL; /* xdr function list */
 pid_t childpid;
 
 
 int
-main(argc, argv)
-       int argc;
-       char *argv[];
+main(int argc, char **argv)
 {
        struct commandline cmd;
 
-       (void) memset((char *)&cmd, 0, sizeof (struct commandline));
+       memset(&cmd, 0, sizeof (struct commandline));
        clear_args();
        if (!parseargs(argc, argv, &cmd))
                usage();
@@ -167,9 +149,8 @@ main(argc, argv)
         *  so in that case only, check if the outfile exists, and if so,
         *  print an error message and exit.
         */
-       if (cmd.Ssflag || cmd.Scflag || cmd.makefileflag) {
+       if (cmd.Ssflag || cmd.Scflag || cmd.makefileflag)
                checkfiles(cmd.infile, cmd.outfile);
-       }
        else
                checkfiles(cmd.infile, NULL);
 
@@ -224,8 +205,8 @@ main(argc, argv)
                        reinitialize();
                        mkfile_output(&cmd);
                }
-
        }
+
        exit(nonfatalerrors);
        /* NOTREACHED */
 }
@@ -235,47 +216,33 @@ main(argc, argv)
  * add extension to filename
  */
 static char *
-#if defined(__FreeBSD__) || defined(__NetBSD__) || defined (__DragonFly__)
-extendfile(path, ext)
-       char *path;
-#else
-extendfile(file, ext)
-       char *file;
-#endif
-       char *ext;
+extendfile(char *path, char *ext)
 {
        char *res;
        char *p;
-#if defined(__FreeBSD__) || defined(__NetBSD__) || defined (__DragonFly__)
        char *file;
 
        if ((file = rindex(path, '/')) == NULL)
                file = path;
        else
                file++;
-#endif
        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);
+       strcpy(res, file);
+       strcpy(res + (p - file), ext);
+       return(res);
 }
 
 /*
  * Open output file with given extension
  */
 static void
-open_output(infile, outfile)
-       char *infile;
-       char *outfile;
+open_output(char *infile, char *outfile)
 {
-
        if (outfile == NULL) {
                fout = stdout;
                return;
@@ -291,12 +258,10 @@ open_output(infile, outfile)
                crash();
        }
        record_open(outfile);
-
-       return;
 }
 
 static void
-add_warning()
+add_warning(void)
 {
        f_print(fout, "/*\n");
        f_print(fout, " * Please do not edit this file.\n");
@@ -305,16 +270,19 @@ add_warning()
 }
 
 /* clear list of arguments */
-static void clear_args()
+static void
+clear_args(void)
 {
        int i;
+
        for (i = FIXEDARGS; i < ARGLISTLEN; i++)
                arglist[i] = NULL;
        argcount = FIXEDARGS;
 }
 
 /* make sure that a CPP exists */
-static int find_cpp()
+static int
+find_cpp(void)
 {
        if (CPP)
                return(0);
@@ -326,15 +294,13 @@ static int find_cpp()
  * Open input file with given define for C-preprocessor
  */
 static void
-open_input(infile, define)
-       char *infile;
-       char *define;
+open_input(char *infile, char *define)
 {
        int pd[2];
        int usevp;
 
        infilename = (infile == NULL) ? "<stdin>" : infile;
-       (void) pipe(pd);
+       pipe(pd);
        switch (childpid = fork()) {
        case 0:
                usevp = find_cpp();
@@ -344,9 +310,9 @@ open_input(infile, define)
                if (infile)
                        addarg(infile);
                addarg((char *)NULL);
-               (void) close(1);
-               (void) dup2(pd[1], 1);
-               (void) close(pd[0]);
+               close(1);
+               dup2(pd[1], 1);
+               close(pd[0]);
                if (usevp)
                    execvp(arglist[0], arglist);
                else
@@ -357,7 +323,7 @@ open_input(infile, define)
                warn("fork");
                exit(1);
        }
-       (void) close(pd[1]);
+       close(pd[1]);
        fin = fdopen(pd[0], "r");
        if (fin == NULL) {
                warn("%s", infilename);
@@ -378,7 +344,7 @@ static char* valid_ti_nettypes[] =
        "tcp",
        "raw",
        NULL
-       };
+};
 
 /* valid inetd nettypes */
 static char* valid_i_nettypes[] =
@@ -386,7 +352,7 @@ static char* valid_i_nettypes[] =
        "udp",
        "tcp",
        NULL
-       };
+};
 
 static int check_nettype(name, list_to_check)
 char* name;
@@ -394,36 +360,28 @@ 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);
-               }
+               if (strcmp(name, list_to_check[i]) == 0)
+                       return(1);
        }
        warnx("illegal nettype :\'%s\'", name);
-       return (0);
+       return(0);
 }
 
 static char *
-file_name(file, ext)
-char *file;
-char *ext;
+file_name(char *file, char *ext)
 {
        char *temp;
        temp = extendfile(file, ext);
 
        if (access(temp, F_OK) != -1)
-               return (temp);
+               return(temp);
        else
-               return ((char *)" ");
+               return((char *)" ");
 
 }
 
-
 static void
-c_output(infile, define, extend, outfile)
-       char *infile;
-       char *define;
-       int extend;
-       char *outfile;
+c_output(char *infile, char *define, int extend, char *outfile)
 {
        definition *def;
        char *include;
@@ -442,19 +400,15 @@ c_output(infile, define, extend, outfile)
        } else
                f_print(fout, "#include <rpc/rpc.h>\n");
        tell = ftell(fout);
-       while ( (def = get_definition()) ) {
+       while ( (def = get_definition()) )
                emit(def);
-       }
-       if (extend && tell == ftell(fout)) {
-               (void) unlink(outfilename);
-       }
+       if (extend && tell == ftell(fout))
+               unlink(outfilename);
 }
 
-
 void
-c_initialize()
+c_initialize(void)
 {
-
        /* add all the starting basic types */
        add_type(1, "int");
        add_type(1, "long");
@@ -463,7 +417,6 @@ c_initialize()
        add_type(1, "u_int");
        add_type(1, "u_long");
        add_type(1, "u_short");
-
 }
 
 char rpcgen_table_dcl[] = "struct rpcgen_table {\n\
@@ -474,9 +427,7 @@ char rpcgen_table_dcl[] = "struct rpcgen_table {\n\
        unsigned        len_res; \n\
 }; \n";
 
-
-char *generate_guard(pathname)
-       char* pathname;
+char *generate_guard(char *pathname)
 {
        char* filename, *guard, *tmp;
 
@@ -491,20 +442,15 @@ char *generate_guard(pathname)
                tmp++;
        }
        guard = extendfile(guard, "_H_RPCGEN");
-       return (guard);
+       return(guard);
 }
 
 /*
  * Compile into an XDR header file
  */
 
-
 static void
-h_output(infile, define, extend, outfile)
-       char *infile;
-       char *define;
-       int extend;
-       char *outfile;
+h_output(char *infile, char *define, int extend, char *outfile)
 {
        definition *def;
        char *outfilename;
@@ -528,14 +474,8 @@ h_output(infile, define, extend, outfile)
 
        f_print(fout, "#include <rpc/rpc.h>\n");
 
-       if (mtflag) {
-#if !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__DragonFly__)
-               f_print(fout, "#include <synch.h>\n");
-               f_print(fout, "#include <thread.h>\n");
-#else
+       if (mtflag)
                f_print(fout, "#include <pthread.h>\n");
-#endif
-       };
 
        /* put the C++ support */
        if (Cflag && !CCflag){
@@ -549,64 +489,58 @@ h_output(infile, define, extend, outfile)
        tell = ftell(fout);
 
        /* print data definitions */
-       while ( (def = get_definition()) ) {
+       while ((def = get_definition()) != 0)
                print_datadef(def);
-       }
 
        /*
         * 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) {
+       for (l = defined; l != NULL; l = l->next)
                print_funcdef(l->val);
-       }
-       /* Now  print all xdr func declarations */
-       if (xdrfunc_head != NULL){
 
-               f_print(fout,
-                       "\n/* the xdr functions */\n");
+       /* Now  print all xdr func declarations */
+       if (xdrfunc_head != NULL) {
+               f_print(fout, "\n/* the xdr functions */\n");
 
-               if (CCflag){
-               f_print(fout, "\n#ifdef __cplusplus\n");
-               f_print(fout, "extern \"C\" {\n");
-               f_print(fout, "#endif\n");
-       }
+               if (CCflag) {
+                   f_print(fout, "\n#ifdef __cplusplus\n");
+                   f_print(fout, "extern \"C\" {\n");
+                   f_print(fout, "#endif\n");
+               }
 
-               if (!Cflag){
+               if (!Cflag) {
                        xdrfuncp = xdrfunc_head;
-                       while (xdrfuncp != NULL){
+                       while (xdrfuncp != NULL) {
                                print_xdr_func_def(xdrfuncp->name,
                                xdrfuncp->pointerp, 2);
                                xdrfuncp = xdrfuncp->next;
                        }
                } else {
-
-                       for (i = 1; i < 3; i++){
+                       for (i = 1; i < 3; i++) {
                                if (i == 1)
        f_print(fout, "\n#if defined(__STDC__) || defined(__cplusplus)\n");
-
                                else
                                        f_print(fout, "\n#else /* K&R C */\n");
 
                                xdrfuncp = xdrfunc_head;
-                               while (xdrfuncp != NULL){
+                               while (xdrfuncp != NULL) {
                                        print_xdr_func_def(xdrfuncp->name,
-       xdrfuncp->pointerp, i);
+                                           xdrfuncp->pointerp, i);
                                        xdrfuncp = xdrfuncp->next;
                                }
                        }
-               f_print(fout, "\n#endif /* K&R C */\n");
+                       f_print(fout, "\n#endif /* K&R C */\n");
                }
        }
 
-       if (extend && tell == ftell(fout)) {
-               (void) unlink(outfilename);
-       } else if (tblflag) {
+       if (extend && tell == ftell(fout))
+               unlink(outfilename);
+       else if (tblflag)
                f_print(fout, rpcgen_table_dcl);
-       }
 
-       if (Cflag){
+       if (Cflag) {
                f_print(fout, "\n#ifdef __cplusplus\n");
                f_print(fout, "}\n");
                f_print(fout, "#endif\n");
@@ -619,15 +553,8 @@ h_output(infile, define, extend, outfile)
  * Compile into an RPC service
  */
 static void
-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;
+s_output(int argc, char **argv, char *infile, char *define, int extend,
+        char *outfile, int nomain, int netflag)
 {
        char *include;
        definition *def;
@@ -647,9 +574,9 @@ s_output(argc, argv, infile, define, extend, outfile, nomain, netflag)
        f_print(fout, "#include <stdio.h>\n");
        f_print(fout, "#include <stdlib.h> /* getenv, exit */\n");
        if (Cflag) {
-               f_print (fout,
-               "#include <rpc/pmap_clnt.h> /* for pmap_unset */\n");
-               f_print (fout, "#include <string.h> /* strcmp */\n");
+               f_print(fout,
+                   "#include <rpc/pmap_clnt.h> /* for pmap_unset */\n");
+               f_print(fout, "#include <string.h> /* strcmp */\n");
        }
        if (strcmp(svcclosetime, "-1") == 0)
                indefinitewait = 1;
@@ -665,7 +592,7 @@ s_output(argc, argv, infile, define, extend, outfile, nomain, netflag)
        if (Cflag && (inetdflag || pmflag)) {
                f_print(fout, "#ifdef __cplusplus\n");
                f_print(fout,
-                       "#include <sysent.h> /* getdtablesize, open */\n");
+                   "#include <sysent.h> /* getdtablesize, open */\n");
                f_print(fout, "#endif /* __cplusplus */\n");
                if (tirpcflag)
                        f_print(fout, "#include <unistd.h> /* setsid */\n");
@@ -674,18 +601,15 @@ s_output(argc, argv, infile, define, extend, outfile, nomain, netflag)
                f_print(fout, "#include <sys/types.h>\n");
 
        f_print(fout, "#include <memory.h>\n");
-#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
        if (tirpcflag)
-#endif
-       f_print(fout, "#include <stropts.h>\n");
+           f_print(fout, "#include <stropts.h>\n");
        if (inetdflag || !tirpcflag) {
                f_print(fout, "#include <sys/socket.h>\n");
                f_print(fout, "#include <netinet/in.h>\n");
        }
 
-       if ((netflag || pmflag) && tirpcflag && !nomain) {
+       if ((netflag || pmflag) && tirpcflag && !nomain)
                f_print(fout, "#include <netconfig.h>\n");
-       }
        if (tirpcflag)
                f_print(fout, "#include <sys/resource.h> /* rlimit */\n");
        if (logflag || inetdflag || pmflag)
@@ -701,18 +625,17 @@ s_output(argc, argv, infile, define, extend, outfile, nomain, netflag)
        if (timerflag)
                f_print(fout, "\n#define        _RPCSVC_CLOSEDOWN %s\n",
                        svcclosetime);
-       while ( (def = get_definition()) ) {
+       while ((def = get_definition()) != 0)
                foundprogram |= (def->def_kind == DEF_PROGRAM);
-       }
        if (extend && !foundprogram) {
-               (void) unlink(outfilename);
+               unlink(outfilename);
                return;
        }
        write_most(infile, netflag, nomain);
        if (!nomain) {
                if (!do_registers(argc, argv)) {
                        if (outfilename)
-                               (void) unlink(outfilename);
+                               unlink(outfilename);
                        usage();
                }
                write_rest();
@@ -723,11 +646,7 @@ s_output(argc, argv, infile, define, extend, outfile, nomain, netflag)
  * generate client side stubs
  */
 static void
-l_output(infile, define, extend, outfile)
-       char *infile;
-       char *define;
-       int extend;
-       char *outfile;
+l_output(char *infile, char *define, int extend, char *outfile)
 {
        char *include;
        definition *def;
@@ -745,25 +664,19 @@ l_output(infile, define, extend, outfile)
                free(include);
        } else
                f_print(fout, "#include <rpc/rpc.h>\n");
-       while ( (def = get_definition()) ) {
+       while ((def = get_definition()) != 0)
                foundprogram |= (def->def_kind == DEF_PROGRAM);
-       }
-       if (extend && !foundprogram) {
-               (void) unlink(outfilename);
-               return;
-       }
-       write_stubs();
+       if (extend && !foundprogram)
+               unlink(outfilename);
+       else
+               write_stubs();
 }
 
 /*
  * generate the dispatch table
  */
 static void
-t_output(infile, define, extend, outfile)
-       char *infile;
-       char *define;
-       int extend;
-       char *outfile;
+t_output(char *infile, char *define, int extend, char *outfile)
 {
        definition *def;
        int foundprogram = 0;
@@ -773,23 +686,17 @@ t_output(infile, define, extend, outfile)
        outfilename = extend ? extendfile(infile, outfile) : outfile;
        open_output(infile, outfilename);
        add_warning();
-       while ( (def = get_definition()) ) {
+       while ((def = get_definition()) != 0)
                foundprogram |= (def->def_kind == DEF_PROGRAM);
-       }
-       if (extend && !foundprogram) {
-               (void) unlink(outfilename);
-               return;
-       }
-       write_tables();
+       if (extend && !foundprogram)
+               unlink(outfilename);
+       else
+               write_tables();
 }
 
 /* sample routine for the server template */
 static void
-svc_output(infile, define, extend, outfile)
-       char *infile;
-       char *define;
-       int extend;
-       char *outfile;
+svc_output(char *infile, char *define, int extend, char *outfile)
 {
        definition *def;
        char *include;
@@ -812,21 +719,15 @@ svc_output(infile, define, extend, outfile)
                f_print(fout, "#include <rpc/rpc.h>\n");
 
        tell = ftell(fout);
-       while ( (def = get_definition()) ) {
+       while ((def = get_definition()) != 0)
                write_sample_svc(def);
-       }
-       if (extend && tell == ftell(fout)) {
-               (void) unlink(outfilename);
-       }
+       if (extend && tell == ftell(fout))
+               unlink(outfilename);
 }
 
 /* sample main routine for client */
 static void
-clnt_output(infile, define, extend, outfile)
-       char *infile;
-       char *define;
-       int extend;
-       char *outfile;
+clnt_output(char *infile, char *define, int extend, char *outfile)
 {
        definition *def;
        char *include;
@@ -850,16 +751,14 @@ clnt_output(infile, define, extend, outfile)
        } else
                f_print(fout, "#include <rpc/rpc.h>\n");
        tell = ftell(fout);
-       while ( (def = get_definition()) ) {
+       while ((def = get_definition()) != 0)
                has_program += write_sample_clnt(def);
-       }
 
        if (has_program)
                write_sample_clnt_main();
 
-       if (extend && tell == ftell(fout)) {
-               (void) unlink(outfilename);
-       }
+       if (extend && tell == ftell(fout))
+               unlink(outfilename);
 }
 
 
@@ -875,33 +774,30 @@ struct commandline *cmd;
        xdrname = file_name(cmd->infile, "_xdr.c");
        hdrname = file_name(cmd->infile, ".h");
 
-
-       if (allfiles){
+       if (allfiles) {
                servername = extendfile(cmd->infile, "_server.c");
                clientname = extendfile(cmd->infile, "_client.c");
-       }else{
+       } else {
                servername = " ";
                clientname = " ";
        }
        servprogname = extendfile(cmd->infile, "_server");
        clntprogname = extendfile(cmd->infile, "_client");
 
-       if (allfiles){
+       if (allfiles) {
                mkfilename = alloc(strlen("makefile.") +
                        strlen(cmd->infile) + 1);
-               temp = (char *)rindex(cmd->infile, '.');
+               temp = rindex(cmd->infile, '.');
                strcat(mkfilename, "makefile.");
-               (void) strncat(mkfilename, cmd->infile,
-                       (temp - cmd->infile));
+               strncat(mkfilename, cmd->infile, (temp - cmd->infile));
        } else
                mkfilename = cmd->outfile;
 
-
        checkfiles(NULL, mkfilename);
        open_output(NULL, mkfilename);
 
-       f_print(fout, "\n# This is a template makefile generated\
-               by rpcgen \n");
+       f_print(fout, "\n# This is a template makefile generated "
+               "by rpcgen \n");
 
        f_print(fout, "\n# Parameters \n\n");
 
@@ -918,22 +814,19 @@ struct commandline *cmd;
                hdrname, xdrname, clntname,
                svcname, clientname, servername);
 
-       f_print(fout, "OBJECTS_CLNT = $(SOURCES_CLNT.c:%%.c=%%.o) \
-$(TARGETS_CLNT.c:%%.c=%%.o) ");
+       f_print(fout, "OBJECTS_CLNT = $(SOURCES_CLNT.c:%%.c=%%.o) "
+               "$(TARGETS_CLNT.c:%%.c=%%.o) ");
 
-       f_print(fout, "\nOBJECTS_SVC = $(SOURCES_SVC.c:%%.c=%%.o) \
-$(TARGETS_SVC.c:%%.c=%%.o) ");
+       f_print(fout, "\nOBJECTS_SVC = $(SOURCES_SVC.c:%%.c=%%.o) "
+               "$(TARGETS_SVC.c:%%.c=%%.o) ");
 
 
        f_print(fout, "\n# Compiler flags \n");
        if (mtflag)
-               f_print(fout, "\nCPPFLAGS += -D_REENTRANT\nCFLAGS += -g \nLDLIBS += -lnsl -lthread\n");
+               f_print(fout, "\nCPPFLAGS += -D_REENTRANT\n"
+                       "CFLAGS += -g \nLDLIBS += -lnsl -lthread\n");
        else
-#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
                f_print(fout, "\nCFLAGS += -g \nLDLIBS +=\n");
-#else
-               f_print(fout, "\nCFLAGS += -g \nLDLIBS += -lnsl\n");
-#endif
        f_print(fout, "RPCGENFLAGS = \n");
 
        f_print(fout, "\n# Targets \n\n");
@@ -941,29 +834,17 @@ $(TARGETS_SVC.c:%%.c=%%.o) ");
        f_print(fout, "all : $(CLIENT) $(SERVER)\n\n");
        f_print(fout, "$(TARGETS) : $(SOURCES.x) \n");
        f_print(fout, "\trpcgen $(RPCGENFLAGS) $(SOURCES.x)\n\n");
-       f_print(fout, "$(OBJECTS_CLNT) : $(SOURCES_CLNT.c) $(SOURCES_CLNT.h) \
-$(TARGETS_CLNT.c) \n\n");
+       f_print(fout, "$(OBJECTS_CLNT) : $(SOURCES_CLNT.c) $(SOURCES_CLNT.h) "
+               "$(TARGETS_CLNT.c) \n\n");
 
-       f_print(fout, "$(OBJECTS_SVC) : $(SOURCES_SVC.c) $(SOURCES_SVC.h) \
-$(TARGETS_SVC.c) \n\n");
+       f_print(fout, "$(OBJECTS_SVC) : $(SOURCES_SVC.c) $(SOURCES_SVC.h) "
+               "$(TARGETS_SVC.c) \n\n");
        f_print(fout, "$(CLIENT) : $(OBJECTS_CLNT) \n");
-#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
-       f_print(fout, "\t$(CC) -o $(CLIENT) $(OBJECTS_CLNT) \
-$(LDLIBS) \n\n");
-#else
-       f_print(fout, "\t$(LINK.c) -o $(CLIENT) $(OBJECTS_CLNT) \
-$(LDLIBS) \n\n");
-#endif
+       f_print(fout, "\t$(CC) -o $(CLIENT) $(OBJECTS_CLNT) $(LDLIBS) \n\n");
        f_print(fout, "$(SERVER) : $(OBJECTS_SVC) \n");
-#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
        f_print(fout, "\t$(CC) -o $(SERVER) $(OBJECTS_SVC) $(LDLIBS)\n\n ");
-       f_print(fout, "clean:\n\t $(RM) -f core $(TARGETS) $(OBJECTS_CLNT) \
-$(OBJECTS_SVC) $(CLIENT) $(SERVER)\n\n");
-#else
-       f_print(fout, "\t$(LINK.c) -o $(SERVER) $(OBJECTS_SVC) $(LDLIBS)\n\n ");
-       f_print(fout, "clean:\n\t $(RM) core $(TARGETS) $(OBJECTS_CLNT) \
-$(OBJECTS_SVC) $(CLIENT) $(SERVER)\n\n");
-#endif
+       f_print(fout, "clean:\n\t $(RM) -f core $(TARGETS) $(OBJECTS_CLNT) "
+               "$(OBJECTS_SVC) $(CLIENT) $(SERVER)\n\n");
 }
 
 
@@ -973,9 +854,7 @@ $(OBJECTS_SVC) $(CLIENT) $(SERVER)\n\n");
  * Return 0 if failed; 1 otherwise.
  */
 static int
-do_registers(argc, argv)
-       int argc;
-       char *argv[];
+do_registers(int argc, char **argv)
 {
        int i;
 
@@ -984,7 +863,7 @@ do_registers(argc, argv)
                        if (streq(argv[i], "-s")) {
                                if (!check_nettype(argv[i + 1],
                                                    valid_i_nettypes))
-                                       return (0);
+                                       return(0);
                                write_inetd_register(argv[i + 1]);
                                i++;
                        }
@@ -994,7 +873,7 @@ do_registers(argc, argv)
                        if (streq(argv[i], "-s")) {
                                if (!check_nettype(argv[i + 1],
                                                    valid_ti_nettypes))
-                                       return (0);
+                                       return(0);
                                write_nettype_register(argv[i + 1]);
                                i++;
                        } else if (streq(argv[i], "-n")) {
@@ -1002,15 +881,14 @@ do_registers(argc, argv)
                                i++;
                        }
        }
-       return (1);
+       return(1);
 }
 
 /*
  * Add another argument to the arg list
  */
 static void
-addarg(cp)
-       char *cp;
+addarg(char *cp)
 {
        if (argcount >= ARGLISTLEN) {
                warnx("too many defines");
@@ -1041,19 +919,14 @@ putarg(where, cp)
  */
 
 static void
-checkfiles(infile, outfile)
-char *infile;
-char *outfile;
+checkfiles(char *infile, char *outfile)
 {
-
        struct stat buf;
 
-       if (infile)             /* infile ! = NULL */
-               if (stat(infile, &buf) < 0)
-               {
-                       warn("%s", infile);
-                       crash();
-               };
+       if (infile != NULL && stat(infile, &buf) < 0) {
+               warn("%s", infile);
+               crash();
+       }
        if (outfile) {
                if (stat(outfile, &buf) < 0)
                        return; /* file does not exist */
@@ -1068,10 +941,7 @@ char *outfile;
  * Parse command line arguments
  */
 static int
-parseargs(argc, argv, cmd)
-       int argc;
-       char *argv[];
-       struct commandline *cmd;
+parseargs(int argc, char **argv,struct commandline *cmd)
 {
        int i;
        int j;
@@ -1080,9 +950,9 @@ parseargs(argc, argv, cmd)
        int nflags;
 
        cmd->infile = cmd->outfile = NULL;
-       if (argc < 2) {
-               return (0);
-       }
+       if (argc < 2)
+               return(0);
+
        allfiles = 0;
        flag['c'] = 0;
        flag['h'] = 0;
@@ -1100,7 +970,7 @@ parseargs(argc, argv, cmd)
                if (argv[i][0] != '-') {
                        if (cmd->infile) {
                                warnx("cannot specify more than one input file");
-                               return (0);
+                               return(0);
                        }
                        cmd->infile = argv[i];
                } else {
@@ -1115,9 +985,8 @@ parseargs(argc, argv, cmd)
                                case 'l':
                                case 'm':
                                case 't':
-                                       if (flag[(int)c]) {
-                                               return (0);
-                                       }
+                                       if (flag[(int)c])
+                                               return(0);
                                        flag[(int)c] = 1;
                                        break;
                                case 'S':
@@ -1135,11 +1004,10 @@ parseargs(argc, argv, cmd)
                                        else if (ch == 'm')
                                                ch = 'M';
                                        else
-                                               return (0);
+                                               return(0);
 
-                                       if (flag[(int)ch]) {
-                                               return (0);
-                                       }
+                                       if (flag[(int)ch])
+                                               return(0);
                                        flag[(int)ch] = 1;
                                        break;
                                case 'C': /* ANSI C syntax */
@@ -1151,16 +1019,7 @@ parseargs(argc, argv, cmd)
                                        CCflag = 1;
                                        break;
                                case 'b':
-                                       /*
-                                        *  Turn TIRPC flag off for
-                                        *  generating backward compatible
-                                        *  code
-                                        */
-#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
                                        tirpcflag = 1;
-#else
-                                       tirpcflag = 0;
-#endif
                                        break;
 
                                case 'I':
@@ -1173,9 +1032,8 @@ parseargs(argc, argv, cmd)
                                        logflag = 1;
                                        break;
                                case 'K':
-                                       if (++i == argc) {
-                                               return (0);
-                                       }
+                                       if (++i == argc)
+                                               return(0);
                                        svcclosetime = argv[i];
                                        goto nextarg;
                                case 'T':
@@ -1185,49 +1043,41 @@ parseargs(argc, argv, cmd)
                                        mtflag = 1;
                                        break;
                                case 'i' :
-                                       if (++i == argc) {
-                                               return (0);
-                                       }
-                                       inline = atoi(argv[i]);
+                                       if (++i == argc)
+                                               return(0);
+                                       rpcgen_inline = atoi(argv[i]);
                                        goto nextarg;
                                case 'n':
                                case 'o':
                                case 's':
                                        if (argv[i][j - 1] != '-' ||
-                                           argv[i][j + 1] != 0) {
-                                               return (0);
-                                       }
+                                           argv[i][j + 1] != 0)
+                                               return(0);
                                        flag[(int)c] = 1;
-                                       if (++i == argc) {
-                                               return (0);
-                                       }
+                                       if (++i == argc)
+                                               return(0);
                                        if (c == 'o') {
-                                               if (cmd->outfile) {
-                                                       return (0);
-                                               }
+                                               if (cmd->outfile)
+                                                       return(0);
                                                cmd->outfile = argv[i];
                                        }
                                        goto nextarg;
                                case 'D':
-                                       if (argv[i][j - 1] != '-') {
-                                               return (0);
-                                       }
-                                       (void) addarg(argv[i]);
+                                       if (argv[i][j - 1] != '-')
+                                               return(0);
+                                       addarg(argv[i]);
                                        goto nextarg;
                                case 'Y':
-                                       if (++i == argc) {
-                                               return (0);
-                                       }
-                                       (void) strcpy(pathbuf, argv[i]);
-                                       (void) strcat(pathbuf, "/cpp");
+                                       if (++i == argc)
+                                               return(0);
+                                       strcpy(pathbuf, argv[i]);
+                                       strcat(pathbuf, "/cpp");
                                        CPP = pathbuf;
                                        cppDefined = 1;
                                        goto nextarg;
 
-
-
                                default:
-                                       return (0);
+                                       return(0);
                                }
                        }
                nextarg:
@@ -1252,22 +1102,19 @@ parseargs(argc, argv, cmd)
                if ((inetdflag && cmd->nflag)) {
                        /* netid not allowed with inetdflag */
                        warnx("cannot use netid flag with inetd flag");
-                       return (0);
+                       return(0);
                }
        } else {                /* 4.1 mode */
                pmflag = 0;     /* set pmflag only in tirpcmode */
-#if !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__DragonFly__)
-               inetdflag = 1;  /* inetdflag is TRUE by default */
-#endif
                if (cmd->nflag) { /* netid needs TIRPC */
                        warnx("cannot use netid flag without TIRPC");
-                       return (0);
+                       return(0);
                }
        }
 
        if (newstyle && (tblflag || cmd->tflag)) {
                warnx("cannot use table flags with newstyle");
-               return (0);
+               return(0);
        }
 
        /* check no conflicts with file generation flags */
@@ -1276,29 +1123,28 @@ parseargs(argc, argv, cmd)
                        cmd->Scflag + cmd->makefileflag;
 
        if (nflags == 0) {
-               if (cmd->outfile != NULL || cmd->infile == NULL) {
-                       return (0);
-               }
+               if (cmd->outfile != NULL || cmd->infile == NULL)
+                       return(0);
        } else if (cmd->infile == NULL &&
            (cmd->Ssflag || cmd->Scflag || cmd->makefileflag)) {
                warnx("\"infile\" is required for template generation flags");
-               return (0);
+               return(0);
        } if (nflags > 1) {
                warnx("cannot have more than one file generation flag");
-               return (0);
+               return(0);
        }
-       return (1);
+       return(1);
 }
 
 static void
-usage()
+usage(void)
 {
        f_print(stderr, "%s\n%s\n%s\n%s\n%s\n", 
                "usage: rpcgen infile",
-               "       rpcgen [-abCLNTM] [-Dname[=value]] [-i size]\
-[-I [-K seconds]] [-Y path] infile",
-               "       rpcgen [-c | -h | -l | -m | -t | -Sc | -Ss | -Sm]\
-[-o outfile] [infile]",
+               "       rpcgen [-abCLNTM] [-Dname[=value]] [-i size]"
+               "[-I [-K seconds]] [-Y path] infile",
+               "       rpcgen [-c | -h | -l | -m | -t | -Sc | -Ss | -Sm]"
+               "[-o outfile] [infile]",
                "       rpcgen [-s nettype]* [-o outfile] [infile]",
                "       rpcgen [-n netid]* [-o outfile] [infile]");
        options_usage();
@@ -1306,37 +1152,37 @@ usage()
 }
 
 static void
-options_usage()
+options_usage(void)
 {
        f_print(stderr, "options:\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.X)\n");
+       f_print(stderr, "-b\t\tbackward compatibility mode (generates code"
+               "for SunOS 4.X)\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.X)\n");
-       f_print(stderr, "-K seconds\tserver exits after K seconds of\
-inactivity\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.X)\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, "-M\t\tgenerate MT-safe code\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, "-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, "-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, "-Sm \t\tgenerate makefile template \n");
 
        f_print(stderr, "-t\t\tgenerate RPC dispatch table\n");
@@ -1344,19 +1190,3 @@ remote procedures\n");
        f_print(stderr, "-Y path\t\tpath where cpp is found\n");
        exit(1);
 }
-
-#if !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__Dragonfly__)
-char *
-rindex(sp, c)
-       register char *sp, c;
-{
-       register char *r;
-
-       r = NULL;
-       do {
-               if (*sp == c)
-                       r = sp;
-       } while (*sp++);
-       return (r);
-}
-#endif
index c1ad18d..a189b68 100644 (file)
@@ -27,7 +27,7 @@
  * Mountain View, California  94043
  *
  * @(#)rpc_parse.c 1.8 89/02/22 (C) 1987 SMI
- * $DragonFly: src/usr.bin/rpcgen/rpc_parse.c,v 1.6 2004/01/22 03:22:53 rob Exp $
+ * $DragonFly: src/usr.bin/rpcgen/rpc_parse.c,v 1.7 2004/06/19 16:40:36 joerg Exp $
  */
 
 #ident "@(#)rpc_parse.c        1.12    93/07/05 SMI"
 
 #define ARGNAME "arg"
 
-extern char *make_argname( char *, char * );
-static void isdefined( definition * );
-static void def_struct( definition * );
-static void def_program( definition * );
-static void def_enum( definition * );
-static void def_const( definition * );
-static void def_union( definition * );
-static void def_typedef( definition * );
-static void get_declaration( declaration *, defkind );
-static void get_prog_declaration( declaration *, defkind, int );
-static void get_type( char **, char **, defkind );
-static void unsigned_dec( char ** );
-
-#if !defined(__DragonFly__)
-extern char *strdup();
-#endif
+extern char    *make_argname(char *, char *);
+static void    isdefined(definition *);
+static void    def_struct(definition *);
+static void    def_program(definition *);
+static void    def_enum(definition *);
+static void    def_const(definition *);
+static void    def_union(definition *);
+static void    def_typedef( definition *);
+static void    get_declaration( declaration *, defkind);
+static void    get_prog_declaration( declaration *, defkind, int);
+static void    get_type(char **, char **, defkind);
+static void    unsigned_dec(char **);
 
 /*
  * return the next definition you see
  */
 definition *
-get_definition()
+get_definition(void)
 {
        definition *defp;
        token tok;
@@ -93,25 +89,23 @@ get_definition()
                def_const(defp);
                break;
        case TOK_EOF:
-               return (NULL);
+               return(NULL);
        default:
                error("definition keyword expected");
        }
        scan(TOK_SEMICOLON, &tok);
        isdefined(defp);
-       return (defp);
+       return(defp);
 }
 
 static void
-isdefined(defp)
-       definition *defp;
+isdefined(definition *defp)
 {
        STOREVAL(&defined, defp);
 }
 
 static void
-def_struct(defp)
-       definition *defp;
+def_struct(definition *defp)
 {
        token tok;
        declaration dec;
@@ -138,8 +132,7 @@ def_struct(defp)
 }
 
 static void
-def_program(defp)
-       definition *defp;
+def_program(definition *defp)
 {
        token tok;
        declaration dec;
@@ -169,9 +162,8 @@ def_program(defp)
                        plist = ALLOC(proc_list);
                        get_type(&plist->res_prefix, &plist->res_type,
                                 DEF_PROGRAM);
-                       if (streq(plist->res_type, "opaque")) {
+                       if (streq(plist->res_type, "opaque"))
                                error("illegal result type");
-                       }
                        scan(TOK_IDENT, &tok);
                        plist->proc_name = tok.str;
                        scan(TOK_LPAREN, &tok);
@@ -203,12 +195,10 @@ def_program(defp)
                                tailp = &decls->next;
                        }
                        /* multiple arguments are only allowed in newstyle */
-                       if (!newstyle && num_args > 1) {
+                       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;
                        scan(TOK_RPAREN, &tok);
                        scan(TOK_EQUAL, &tok);
@@ -228,8 +218,7 @@ 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;
-                    plist = plist->next) {
+               for (plist = vlist->procs; plist != NULL; plist = plist->next) {
                        plist->args.argname = make_argname(plist->proc_name,
                                                           vlist->vers_num);
                        /* free the memory ?? */
@@ -245,8 +234,7 @@ def_program(defp)
 
 
 static void
-def_enum(defp)
-       definition *defp;
+def_enum(definition *defp)
 {
        token tok;
        enumval_list *elist;
@@ -275,8 +263,7 @@ def_enum(defp)
 }
 
 static void
-def_const(defp)
-       definition *defp;
+def_const(definition *defp)
 {
        token tok;
 
@@ -289,8 +276,7 @@ def_const(defp)
 }
 
 static void
-def_union(defp)
-       definition *defp;
+def_union(definition *defp)
 {
        token tok;
        declaration dec;
@@ -328,14 +314,11 @@ def_union(defp)
                                scan(TOK_COLON, &tok);
                        } while (peekscan(TOK_CASE, &tok));
                }
-               else
-                       if (flag)
-                       {
-
-                               *tailp = cases;
-                               tailp = &cases->next;
-                               cases = ALLOC(case_list);
-                       };
+               else if (flag) {
+                       *tailp = cases;
+                       tailp = &cases->next;
+                       cases = ALLOC(case_list);
+               }
 
                get_declaration(&dec, DEF_UNION);
                cases->case_decl = dec;
@@ -381,16 +364,14 @@ static char* reserved_types[] =
        "opaque",
        "string",
        NULL
-       };
+};
 
 /*
  * check that the given name is not one that would eventually result in
  * xdr routines that would conflict with internal XDR routines.
  */
 static void
-check_type_name(name, new_type)
-int new_type;
-char* name;
+check_type_name(char* name, int new_type)
 {
        int i;
        char tmp[100];
@@ -418,8 +399,7 @@ char* name;
 
 
 static void
-def_typedef(defp)
-       definition *defp;
+def_typedef(definition *defp)
 {
        declaration dec;
 
@@ -434,17 +414,14 @@ def_typedef(defp)
 }
 
 static void
-get_declaration(dec, dkind)
-       declaration *dec;
-       defkind dkind;
+get_declaration(declaration *dec, defkind dkind)
 {
        token tok;
 
        get_type(&dec->prefix, &dec->type, dkind);
        dec->rel = REL_ALIAS;
-       if (streq(dec->type, "void")) {
+       if (streq(dec->type, "void"))
                return;
-       }
 
        check_type_name(dec->type, 0);
        scan2(TOK_STAR, TOK_IDENT, &tok);
@@ -454,17 +431,15 @@ get_declaration(dec, dkind)
        }
        dec->name = tok.str;
        if (peekscan(TOK_LBRACKET, &tok)) {
-               if (dec->rel == REL_POINTER) {
+               if (dec->rel == REL_POINTER)
                        error("no array-of-pointer declarations -- use typedef");
-               }
                dec->rel = REL_VECTOR;
                scan_num(&tok);
                dec->array_max = tok.str;
                scan(TOK_RBRACKET, &tok);
        } else if (peekscan(TOK_LANGLE, &tok)) {
-               if (dec->rel == REL_POINTER) {
+               if (dec->rel == REL_POINTER)
                        error("no array-of-pointer declarations -- use typedef");
-               }
                dec->rel = REL_ARRAY;
                if (peekscan(TOK_RANGLE, &tok)) {
                        dec->array_max = "~0";  /* unspecified size, use max */
@@ -487,10 +462,7 @@ get_declaration(dec, dkind)
 
 
 static void
-get_prog_declaration(dec, dkind, num)
-       declaration *dec;
-       defkind dkind;
-       int num;  /* arg number */
+get_prog_declaration(declaration *dec, defkind dkind, int num)
 {
        token tok;
        char name[10];          /* argument name */
@@ -518,22 +490,20 @@ get_prog_declaration(dec, dkind, num)
                return;
        }
 
-       if (streq(dec->type, "opaque")) {
+       if (streq(dec->type, "opaque"))
                error("opaque -- illegal argument type");
-       }
        if (peekscan(TOK_STAR, &tok)) {
-               if (streq(dec->type, "string")) {
+               if (streq(dec->type, "string"))
                        error("pointer to string not allowed in program arguments\n");
-               }
                dec->rel = REL_POINTER;
-               if (peekscan(TOK_IDENT, &tok))
+               if (peekscan(TOK_IDENT, &tok)) {
                        /* optional name of argument */
                        dec->name = strdup(tok.str);
+               }
        }
        if (peekscan(TOK_LANGLE, &tok)) {
-               if (!streq(dec->type, "string")) {
+               if (!streq(dec->type, "string"))
                        error("arrays cannot be declared as arguments to procedures -- use typedef");
-               }
                dec->rel = REL_ARRAY;
                if (peekscan(TOK_RANGLE, &tok)) {
                        dec->array_max = "~0";
@@ -557,13 +527,8 @@ get_prog_declaration(dec, dkind, num)
        }
 }
 
-
-
 static void
-get_type(prefixp, typep, dkind)
-       char **prefixp;
-       char **typep;
-       defkind dkind;
+get_type(char **prefixp, char **typep, defkind dkind)
 {
        token tok;
 
@@ -585,21 +550,20 @@ get_type(prefixp, typep, dkind)
                break;
        case TOK_SHORT:
                *typep = "short";
-               (void) peekscan(TOK_INT, &tok);
+               peekscan(TOK_INT, &tok);
                break;
        case TOK_LONG:
                *typep = "long";
-               (void) peekscan(TOK_INT, &tok);
+               peekscan(TOK_INT, &tok);
                break;
        case TOK_HYPER:
                *typep = "int64_t";
-               (void) peekscan(TOK_INT, &tok);
+               peekscan(TOK_INT, &tok);
                break;
 
        case TOK_VOID:
-               if (dkind != DEF_UNION && dkind != DEF_PROGRAM) {
+               if (dkind != DEF_UNION && dkind != DEF_PROGRAM)
                        error("voids allowed only inside union and program definitions with one argument");
-               }
                *typep = tok.str;
                break;
        case TOK_STRING:
@@ -618,8 +582,7 @@ get_type(prefixp, typep, dkind)
 }
 
 static void
-unsigned_dec(typep)
-       char **typep;
+unsigned_dec(char **typep)
 {
        token tok;
 
@@ -632,17 +595,17 @@ unsigned_dec(typep)
        case TOK_SHORT:
                get_token(&tok);
                *typep = "u_short";
-               (void) peekscan(TOK_INT, &tok);
+               peekscan(TOK_INT, &tok);
                break;
        case TOK_LONG:
                get_token(&tok);
                *typep = "u_long";
-               (void) peekscan(TOK_INT, &tok);
+               peekscan(TOK_INT, &tok);
                break;
        case TOK_HYPER:
                get_token(&tok);
                *typep = "u_int64_t";
-               (void) peekscan(TOK_INT, &tok);
+               peekscan(TOK_INT, &tok);
                break;
        case TOK_INT:
                get_token(&tok);
index b61db9d..b96091a 100644 (file)
@@ -58,6 +58,7 @@
 */ 
 
 /*      @(#)rpc_parse.h  1.3  90/08/29  (C) 1987 SMI   */
+/* $DragonFly: src/usr.bin/rpcgen/rpc_parse.h,v 1.2 2004/06/19 16:40:36 joerg Exp $ */
 
 /*
  * rpc_parse.h, Definitions for the RPCL parser 
@@ -184,8 +185,7 @@ struct definition {
 };
 typedef struct definition definition;
 
-definition *get_definition();
-
+definition *get_definition(void);
 
 struct bas_type
 {
index 30209b9..d61d057 100644 (file)
@@ -25,7 +25,7 @@
  * Sun Microsystems, Inc.
  * 2550 Garcia Avenue
  * Mountain View, California  94043
- * $DragonFly: src/usr.bin/rpcgen/rpc_sample.c,v 1.3 2003/11/03 19:31:32 eirikn Exp $
+ * $DragonFly: src/usr.bin/rpcgen/rpc_sample.c,v 1.4 2004/06/19 16:40:36 joerg Exp $
  */
 
 #pragma ident  "@(#)rpc_sample.c       1.9     94/04/25 SMI" 
 #include "rpc_parse.h"
 #include "rpc_util.h"
 
-
 static char RQSTP[] = "rqstp";
 
-extern void printarglist( proc_list *, char *, char *, char *);
-static void write_sample_client( char *, version_list * );
-static void write_sample_server( definition * );
-static void return_type( proc_list * );
+extern void    printarglist(proc_list *, char *, char *, char *);
+static void    write_sample_client(char *, version_list *);
+static void    write_sample_server(definition *);
+static void    return_type(proc_list *);
 
 void
-write_sample_svc(def)
-     definition *def;
+write_sample_svc(definition *def)
 {
-
        if (def->def_kind != DEF_PROGRAM) 
-         return;
+               return;
        write_sample_server(def);
 }
 
 
 int
-write_sample_clnt(def)
-     definition *def;
+write_sample_clnt(definition *def)
 {
         version_list *vp;
        int count = 0;
 
        if (def->def_kind != DEF_PROGRAM) 
-         return(0);
+               return(0);
        /* generate sample code for each version */
        for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
-         write_sample_client(def->def_name, vp);
-         ++count;
+               write_sample_client(def->def_name, vp);
+               ++count;
        }
        return(count);
 }
 
 
 static void
-write_sample_client(program_name, vp)
-     char *program_name;
-     version_list *vp;
+write_sample_client(char *program_name, version_list *vp)
 {
        proc_list *proc;
        int i;
@@ -147,17 +141,16 @@ write_sample_client(program_name, vp)
                pvname(proc->proc_name, vp->vers_num);
                if (proc->arg_num < 2 && !newstyle) {
                        f_print(fout, "(");
-                       if(streq(proc->args.decls->decl.type, "void")) 
+                       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);
                        if (mtflag)
-                               f_print(fout, "_arg, &result_%d, clnt);\n",
-                                       i);
+                               f_print(fout, "_arg, &result_%d, clnt);\n", i);
                        else
                                f_print(fout, "_arg, clnt);\n");
-
                } else if (streq(proc->args.decls->decl.type, "void")) {
                        if (mtflag)
                                f_print(fout, "(&result_%d, clnt);\n", i);
@@ -177,7 +170,6 @@ write_sample_client(program_name, vp)
                }
                if (mtflag) {
                        f_print(fout, "\tif (retval_%d != RPC_SUCCESS) {\n", i);
-
                } else {
                        f_print(fout, "\tif (result_%d == (", i);
                        ptype(proc->res_prefix, proc->res_type, 1);
@@ -194,8 +186,7 @@ write_sample_client(program_name, vp)
 }
 
 static void
-write_sample_server(def)
-       definition *def;
+write_sample_server(definition *def)
 {
        version_list *vp;
        proc_list *proc;
@@ -224,53 +215,52 @@ write_sample_server(def)
                                /* cannot have void type */
                                f_print(fout, " result;\n");
                        }
-                       else
+                       else {
                                f_print(fout, "\tbool_t retval;\n");
+                       }
                        f_print(fout, 
                                "\n\t/*\n\t * insert server code here\n\t */\n\n");
 
-                       if (!mtflag)
+                       if (!mtflag) {
                                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"); 
-                       else
+                       } else {
                                f_print(fout, "\treturn (retval);\n}\n");
+                       }
                }
                /* put in sample freeing routine */
                if (mtflag) {
-               f_print(fout, "\nint\n");
-               pvname(def->def_name, vp->vers_num);
-               if (Cflag) 
-                       f_print(fout,"_freeresult(SVCXPRT *transp, xdrproc_t xdr_result, caddr_t result)\n");
-               else {
-                       f_print(fout,"_freeresult(transp, xdr_result, result)\n");
-                       f_print(fout,"\tSVCXPRT *transp;\n");
-                       f_print(fout,"\txdrproc_t xdr_result;\n");
-                       f_print(fout,"\tcaddr_t result;\n");
+                       f_print(fout, "\nint\n");
+                       pvname(def->def_name, vp->vers_num);
+                       if (Cflag) {
+                               f_print(fout,"_freeresult(SVCXPRT *transp, xdrproc_t xdr_result, caddr_t result)\n");
+                       } else {
+                               f_print(fout,"_freeresult(transp, xdr_result, result)\n");
+                               f_print(fout,"\tSVCXPRT *transp;\n");
+                               f_print(fout,"\txdrproc_t xdr_result;\n");
+                               f_print(fout,"\tcaddr_t result;\n");
+                       }
+                       f_print(fout, "{\n");
+                       f_print(fout, "\t(void) xdr_free(xdr_result, result);\n");
+                       f_print(fout, 
+                               "\n\t/*\n\t * Insert additional freeing code here, if needed\n\t */\n");
+                       f_print(fout, "\n}\n");
                }
-               f_print(fout, "{\n");
-               f_print(fout, "\t(void) xdr_free(xdr_result, result);\n");
-               f_print(fout, 
-                       "\n\t/*\n\t * Insert additional freeing code here, if needed\n\t */\n");
-               f_print(fout, "\n}\n");
-
-               
-       }
        }
 }
 
 
 
 static void
-return_type(plist)
-       proc_list *plist;
+return_type(proc_list *plist)
 {
-  ptype(plist->res_prefix, plist->res_type, 1);
+       ptype(plist->res_prefix, plist->res_type, 1);
 }
 
 void
-add_sample_msg()
+add_sample_msg(void)
 {
        f_print(fout, "/*\n");
        f_print(fout, " * This is sample code generated by rpcgen.\n");
@@ -280,7 +270,7 @@ add_sample_msg()
 }
 
 void
-write_sample_clnt_main()
+write_sample_clnt_main(void)
 {
        list *l;
        definition *def;
@@ -290,7 +280,8 @@ write_sample_clnt_main()
        if(Cflag)
                f_print(fout,"main(int argc, char *argv[])\n{\n");
        else
-               f_print(fout, "main(argc, argv)\n\tint argc;\n\tchar *argv[];\n{\n");
+               f_print(fout, "main(argc, argv)\n\tint argc;\n"
+                       "\tchar *argv[];\n{\n");
 
        f_print(fout, "\tchar *host;");
        f_print(fout, "\n\n\tif (argc < 2) {");
@@ -300,9 +291,8 @@ write_sample_clnt_main()
 
        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");
                        pvname(def->def_name, vp->vers_num);
index d326362..e6cae49 100644 (file)
@@ -27,7 +27,7 @@
  * Mountain View, California  94043
  *
  * $FreeBSD: src/usr.bin/rpcgen/rpc_scan.c,v 1.4.8.1 2001/03/04 08:59:50 kris Exp $
- * $DragonFly: src/usr.bin/rpcgen/rpc_scan.c,v 1.3 2003/11/03 19:31:32 eirikn Exp $
+ * $DragonFly: src/usr.bin/rpcgen/rpc_scan.c,v 1.4 2004/06/19 16:40:36 joerg Exp $
  *
  * @(#)rpc_scan.c 1.11 89/02/22 (C) 1987 SMI
  */
 static int pushed = 0; /* is a token pushed */
 static token lasttok;  /* last token, if pushed */
 
-static void unget_token( token * );
-static void findstrconst( char **, char **);
-static void findchrconst( char **, char **);
-static void findconst( char **, char **);
-static void findkind( char **, token * );
-static int cppline( char * );
-static int directive( char * );
-static void printdirective( char * );
-static void docppline( char *, int *, char ** );
+static void    unget_token(token *);
+static void    findstrconst(char **, char **);
+static void    findchrconst(char **, char **);
+static void    findconst(char **, char **);
+static void    findkind(char **, token *);
+static int     cppline(char *);
+static int     directive(char *);
+static void    printdirective(char *);
+static void    docppline(char *, int *, char **);
 
 /*
  * scan expecting 1 given token 
  */
 void
-scan(expect, tokp)
-       tok_kind expect;
-       token *tokp;
+scan(tok_kind expect, token *tokp)
 {
        get_token(tokp);
-       if (tokp->kind != expect) {
+       if (tokp->kind != expect)
                expected1(expect);
-       }
 }
 
 /*
  * scan expecting any of the 2 given tokens 
  */
 void
-scan2(expect1, expect2, tokp)
-       tok_kind expect1;
-       tok_kind expect2;
-       token *tokp;
+scan2(tok_kind expect1, tok_kind expect2, 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 
  */
 void
-scan3(expect1, expect2, expect3, tokp)
-       tok_kind expect1;
-       tok_kind expect2;
-       tok_kind expect3;
-       token *tokp;
+scan3(tok_kind expect1, tok_kind expect2, tok_kind expect3, 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 
  */
 void
-scan_num(tokp)
-       token *tokp;
+scan_num(token *tokp)
 {
        get_token(tokp);
        switch (tokp->kind) {
@@ -131,8 +118,7 @@ scan_num(tokp)
  * Peek at the next token 
  */
 void
-peek(tokp)
-       token *tokp;
+peek(token *tokp)
 {
        get_token(tokp);
        unget_token(tokp);
@@ -142,29 +128,25 @@ peek(tokp)
  * Peek at the next token and scan it if it matches what you expect 
  */
 int
-peekscan(expect, tokp)
-       tok_kind expect;
-       token *tokp;
+peekscan(tok_kind expect, token *tokp)
 {
        peek(tokp);
        if (tokp->kind == expect) {
                get_token(tokp);
-               return (1);
+               return(1);
        }
-       return (0);
+       return(0);
 }
 
 /*
  * Get the next token, printing out any directive that are encountered. 
  */
 void
-get_token(tokp)
-       token *tokp;
+get_token(token *tokp)
 {
        int commenting;
        int stat = 0;
        
-       
        if (pushed) {
                pushed = 0;
                *tokp = lasttok;
@@ -176,32 +158,35 @@ get_token(tokp)
                        for (;;) {
                                if (!fgets(curline, MAXLINESIZE, fin)) {
                                        tokp->kind = TOK_EOF;
-                                       /* now check if cpp returned non NULL value */
+                                       /*
+                                        * now check if cpp returned
+                                        * non NULL value
+                                        */
                                        waitpid(childpid, &stat, WUNTRACED);
                                        if (stat > 0) {
-                                       /* Set return value from rpcgen */
+                                               /*
+                                                * Set return value from rpcgen
+                                                */
                                                nonfatalerrors = stat >> 8;
                                        }
                                        *where = 0;
                                        return;
                                }
                                linenum++;
-                               if (commenting) {
+                               if (commenting)
                                        break;
-                               } else if (cppline(curline)) {
-                                       docppline(curline, &linenum, 
+                               else if (cppline(curline))
+                                       docppline(curline, &linenum,
                                                  &infilename);
-                               } else if (directive(curline)) {
+                               else if (directive(curline))
                                        printdirective(curline);
-                               } else {
+                               else
                                        break;
-                               }
                        }
                        where = curline;
                } else if (isspace(*where)) {
-                       while (isspace(*where)) {
+                       while (isspace(*where))
                                where++;        /* eat */
-                       }
                } else if (commenting) {
                        for (where++; *where; where++) {
                                if (endcomment(where)) {
@@ -319,17 +304,14 @@ get_token(tokp)
 }
 
 static void
-unget_token(tokp)
-       token *tokp;
+unget_token(token *tokp)
 {
        lasttok = *tokp;
        pushed = 1;
 }
 
 static void
-findstrconst(str, val)
-       char **str;
-       char **val;
+findstrconst(char **str, char **val)
 {
        char *p;
        int size;
@@ -338,9 +320,8 @@ findstrconst(str, val)
        do {
                p++;
        } while (*p && *p != '"');
-       if (*p == 0) {
+       if (*p == 0)
                error("unterminated string constant");
-       }
        p++;
        size = p - *str;
        *val = alloc(size + 1);
@@ -350,9 +331,7 @@ findstrconst(str, val)
 }
 
 static void
-findchrconst(str, val)
-       char **str;
-       char **val;
+findchrconst(char **str, char **val)
 {
        char *p;
        int size;
@@ -361,16 +340,14 @@ findchrconst(str, val)
        do {
                p++;
        } while (*p && *p != '\'');
-       if (*p == 0) {
+       if (*p == 0)
                error("unterminated string constant");
-       }
        p++;
        size = p - *str;
-       if (size != 3) {
+       if (size != 3)
                error("empty char string");
-       }
        *val = alloc(size + 1);
-       (void) strncpy(*val, *str, size);
+       strncpy(*val, *str, size);
        (*val)[size] = 0;
        *str = p;
 }
@@ -396,7 +373,7 @@ findconst(str, val)
        }
        size = p - *str;
        *val = alloc(size + 1);
-       (void) strncpy(*val, *str, size);
+       strncpy(*val, *str, size);
        (*val)[size] = 0;
        *str = p;
 }
@@ -429,9 +406,7 @@ static token symbols[] = {
 };
 
 static void
-findkind(mark, tokp)
-       char **mark;
-       token *tokp;
+findkind(char **mark, token *tokp)
 {
        int len;
        token *s;
@@ -452,69 +427,56 @@ findkind(mark, tokp)
        tokp->kind = TOK_IDENT;
        for (len = 0; isalnum(str[len]) || str[len] == '_'; len++);
        tokp->str = alloc(len + 1);
-       (void) strncpy(tokp->str, str, len);
+       strncpy(tokp->str, str, len);
        tokp->str[len] = 0;
        *mark = str + len;
 }
 
 static int
-cppline(line)
-       char *line;
+cppline(char *line)
 {
-       return (line == curline && *line == '#');
+       return(line == curline && *line == '#');
 }
 
 static int
-directive(line)
-       char *line;
+directive(char *line)
 {
-       return (line == curline && *line == '%');
+       return(line == curline && *line == '%');
 }
 
 static void
-printdirective(line)
-       char *line;
+printdirective(char *line)
 {
        f_print(fout, "%s", line + 1);
 }
 
 static void
-docppline(line, lineno, fname)
-       char *line;
-       int *lineno;
-       char **fname;
+docppline(char *line, int *lineno, char **fname)
 {
        char *file;
        int num;
        char *p;
 
        line++;
-       while (isspace(*line)) {
+       while (isspace(*line))
                line++;
-       }
        num = atoi(line);
-       while (isdigit(*line)) {
+       while (isdigit(*line))
                line++;
-       }
-       while (isspace(*line)) {
+       while (isspace(*line))
                line++;
-       }
-       if (*line != '"') {
+       if (*line != '"')
                error("preprocessor error");
-       }
        line++;
        p = file = alloc(strlen(line) + 1);
-       while (*line && *line != '"') {
+       while (*line && *line != '"')
                *p++ = *line++;
-       }
-       if (*line == 0) {
+       if (*line == 0)
                error("preprocessor error");
-       }
        *p = 0;
-       if (*file == 0) {
+       if (*file == 0)
                *fname = NULL;
-       } else {
+       else
                *fname = file;
-       }
        *lineno = num - 1;
 }
index cf042d0..32a5bb6 100644 (file)
 */ 
 
 /*      @(#)rpc_scan.h  1.3  90/08/29  (C) 1987 SMI   */
+/* $DragonFly: src/usr.bin/rpcgen/rpc_scan.h,v 1.2 2004/06/19 16:40:36 joerg Exp $ */
 
 /*
  * rpc_scan.h, Definitions for the RPCL scanner 
  */
 
+#ifndef        RPC_SCAN
+#define        RPC_SCAN
+
 /*
  * kinds of tokens 
  */
@@ -131,3 +135,5 @@ void scan_num();
 void peek();
 int peekscan();
 void get_token();
+
+#endif
index 21b4365..5ecd8ec 100644 (file)
@@ -28,7 +28,7 @@
  *
  * @(#)rpc_svcout.c 1.29 89/03/30 (C) 1987 SMI
  * $FreeBSD: src/usr.bin/rpcgen/rpc_svcout.c,v 1.6.6.1 2001/07/19 01:38:22 kris Exp $
- * $DragonFly: src/usr.bin/rpcgen/rpc_svcout.c,v 1.3 2003/11/03 19:31:32 eirikn Exp $
+ * $DragonFly: src/usr.bin/rpcgen/rpc_svcout.c,v 1.4 2004/06/19 16:40:36 joerg Exp $
  */
 
 #ident "@(#)rpc_svcout.c       1.4     90/04/13 SMI"
@@ -51,27 +51,24 @@ static char RETVAL[] = "retval";
 
 char _errbuf[256];     /* For all messages */
 
-void internal_proctype( proc_list * );
-static void write_real_program( definition * );
-static void write_program( definition *, char * );
-static void printerr( char *, char * );
-static void printif( char *, char *, char *, char * );
-static void write_inetmost( char * );
-static void print_return( char * );
-static void print_pmapunset( char * );
-static void print_err_message( char * );
-static void write_timeout_func( void );
-static void write_pm_most( char *, int );
-static void write_rpc_svc_fg( char *, char * );
-static void open_log_file( char *, char * );
-static void write_msg_out( void );
-int nullproc( proc_list * );
-
+void           internal_proctype(proc_list *);
+static void    write_real_program(definition *);
+static void    write_program(definition *, char *);
+static void    printerr(char *, char *);
+static void    printif(char *, char *, char *, char *);
+static void    write_inetmost(char *);
+static void    print_return(char *);
+static void    print_pmapunset(char *);
+static void    print_err_message(char *);
+static void    write_timeout_func(void);
+static void    write_pm_most(char *, int);
+static void    write_rpc_svc_fg(char *, char *);
+static void    open_log_file(char *, char *);
+static void    write_msg_out(void);
+int            nullpro(proc_list *);
 
 static void
-p_xdrfunc(rname, typename)
-char* rname;
-char* typename;
+p_xdrfunc(char* rname, char* typename)
 {
        if (Cflag)
                f_print(fout, "\t\txdr_%s = (xdrproc_t) xdr_%s;\n",
@@ -82,8 +79,7 @@ char* typename;
 }
 
 void
-internal_proctype(plist)
-       proc_list *plist;
+internal_proctype(proc_list *plist)
 {
        f_print(fout, "static ");
        ptype(plist->res_prefix, plist->res_type, 1);
@@ -95,10 +91,7 @@ internal_proctype(plist)
  * 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;
+write_most(char *infile, int netflag, int nomain)
 {
        if (inetdflag || pmflag) {
                char* var_type;
@@ -107,24 +100,24 @@ write_most(infile, netflag, nomain)
                f_print(fout, "\t\t/* Started by a port monitor ? */\n");
                if (!tirpcflag) {
                        f_print(fout, "%s int _rpcfdtype;", var_type);
-                       f_print(fout, "\n\t\t /* Whether Stream or \
-Datagram ? */\n");
+                       f_print(fout, "\n\t\t /* Whether Stream or "
+                               "Datagram ? */\n");
                }
 
                if (timerflag) {
-                       f_print(fout, " /* States a server can be in \
-wrt request */\n\n");
+                       f_print(fout, " /* States a server can be in "
+                               "wrt request */\n\n");
                        f_print(fout, "#define\t_IDLE 0\n");
                        f_print(fout, "#define\t_SERVED 1\n");
                        f_print(fout, "#define\t_SERVING 2\n\n");
                        f_print(fout, "static int _rpcsvcstate = _IDLE;");
-                       f_print(fout, "\t /* Set when a request is \
-serviced */\n");
+                       f_print(fout, "\t /* Set when a request is "
+                               "serviced */\n");
 
                        if (mtflag) {
                                f_print(fout, "mutex_t _svcstate_lock;");
-                               f_print(fout, "\t\t\t/* Mutex lock for variable _rpcsvcstate */\n");
-
+                               f_print(fout, "\t\t\t/* Mutex lock for "
+                                       "variable _rpcsvcstate */\n");
                        }
                                
                }
@@ -155,7 +148,8 @@ serviced */\n");
                        f_print(fout, "\tchar mname[FMNAMESZ + 1];\n\n");
 
                        if (mtflag & timerflag)
-                               f_print(fout, "\tmutex_init(&_svcstate_lock, USYNC_THREAD, NULL);\n");
+                               f_print(fout, "\tmutex_init(&_svcstate_lock, "
+                                       "USYNC_THREAD, NULL);\n");
 
                        write_pm_most(infile, netflag);
                        f_print(fout, "\telse {\n");
@@ -168,17 +162,15 @@ serviced */\n");
                }
        }
 
-       if (logflag && !inetdflag) {
+       if (logflag && !inetdflag)
                open_log_file(infile, "\t");
-       }
 }
 
 /*
  * write a registration for the given transport
  */
 void
-write_netid_register(transp)
-       char *transp;
+write_netid_register(char *transp)
 {
        list *l;
        definition *def;
@@ -190,7 +182,7 @@ write_netid_register(transp)
        f_print(fout, "\n");
        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(_errbuf, "cannot find %s netid.", transp);
        sprintf(tmpbuf, "%s\t\t", sp);
        print_err_message(tmpbuf);
        f_print(fout, "%s\t\texit(1);\n", sp);
@@ -198,27 +190,23 @@ write_netid_register(transp)
        f_print(fout, "%s\t%s = svc_tli_create(RPC_ANYFD, nconf, 0, 0, 0);\n",
                sp, TRANSP);
        f_print(fout, "%s\tif (%s == NULL) {\n", sp, TRANSP);
-       (void) sprintf(_errbuf, "cannot create %s service.", transp);
+       sprintf(_errbuf, "cannot create %s service.", transp);
        print_err_message(tmpbuf);
        f_print(fout, "%s\t\texit(1);\n", sp);
        f_print(fout, "%s\t}\n", sp);
 
        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",
+                       f_print(fout, "%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, ",
+                       f_print(fout, "%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).",
+                       sprintf(_errbuf, "unable to register (%s, %s, %s).",
                                def->def_name, vp->vers_name, transp);
                        print_err_message(tmpbuf);
                        f_print(fout, "%s\t\texit(1);\n", sp);
@@ -232,8 +220,7 @@ write_netid_register(transp)
  * write a registration for the given transport for TLI
  */
 void
-write_nettype_register(transp)
-       char *transp;
+write_nettype_register(char *transp)
 {
        list *l;
        definition *def;
@@ -241,16 +228,14 @@ 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);
-                       (void) sprintf(_errbuf,
-                               "unable to create (%s, %s) for %s.",
+                       sprintf(_errbuf, "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");
@@ -263,27 +248,26 @@ write_nettype_register(transp)
  * write the rest of the service
  */
 void
-write_rest()
+write_rest(void)
 {
        f_print(fout, "\n");
        if (inetdflag) {
                f_print(fout, "\tif (%s == (SVCXPRT *)NULL) {\n", TRANSP);
-               (void) sprintf(_errbuf, "could not create a handle");
+               sprintf(_errbuf, "could not create a handle");
                print_err_message("\t\t");
                f_print(fout, "\t\texit(1);\n");
                f_print(fout, "\t}\n");
                if (timerflag) {
                        f_print(fout, "\tif (_rpcpmstart) {\n");
                        f_print(fout,
-                               "\t\t(void) signal(SIGALRM, %s closedown);\n",
+                               "\t\tsignal(SIGALRM, %s closedown);\n",
                                Cflag? "(SIG_PF)":"(void(*)())");
-                       f_print(fout, "\t\t(void) \
-alarm(_RPCSVC_CLOSEDOWN/2);\n");
+                       f_print(fout, "\t\talarm(_RPCSVC_CLOSEDOWN/2);\n");
                        f_print(fout, "\t}\n");
                }
        }
        f_print(fout, "\tsvc_run();\n");
-       (void) sprintf(_errbuf, "svc_run returned");
+       sprintf(_errbuf, "svc_run returned");
        print_err_message("\t");
        f_print(fout, "\texit(1);\n");
        f_print(fout, "\t/* NOTREACHED */\n");
@@ -291,8 +275,7 @@ alarm(_RPCSVC_CLOSEDOWN/2);\n");
 }
 
 void
-write_programs(storage)
-       char *storage;
+write_programs(char *storage)
 {
        list *l;
        definition *def;
@@ -300,20 +283,16 @@ write_programs(storage)
        /* 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);
-               }
        }
-
-
 }
 
 /*
@@ -323,14 +302,14 @@ write_programs(storage)
  *  expected by printmsg_1.
  */
 static void
-write_real_program(def)
-       definition *def;
+write_real_program(definition *def)
 {
        version_list *vp;
        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");
@@ -351,8 +330,6 @@ write_real_program(def)
                                if (mtflag) {
                                        f_print(fout, " *argp, void *%s, struct svc_req *%s)\n",
                                                RESULT, RQSTP);
-
-
                                }
                                else
                                        f_print(fout, " *argp, struct svc_req *%s)\n",
@@ -402,9 +379,7 @@ write_real_program(def)
 }
 
 static void
-write_program(def, storage)
-       definition *def;
-       char *storage;
+write_program(definition *def, char *storage)
 {
        version_list *vp;
        proc_list *proc;
@@ -412,9 +387,8 @@ 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);
 
@@ -433,10 +407,8 @@ write_program(def, storage)
                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,
@@ -452,9 +424,8 @@ 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);
        
                if (mtflag) {
@@ -468,8 +439,9 @@ write_program(def, storage)
                        f_print(fout, "\t} %s;\n", RESULT);
                        f_print(fout, "\tbool_t %s;\n", RETVAL);
                        
-               } else 
+               } else {
                        f_print(fout, "\tchar *%s;\n", RESULT);
+               }
 
                if (Cflag) {
                        f_print(fout, "\txdrproc_t xdr_%s, xdr_%s;\n",
@@ -517,7 +489,8 @@ write_program(def, storage)
                }
                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 */
+                       if (proc->arg_num < 2) {
+                               /* single argument */
                                p_xdrfunc(ARG, proc->args.decls->decl.type);
                        } else {
                                p_xdrfunc(ARG, proc->args.argname);
@@ -541,7 +514,8 @@ write_program(def, storage)
 
                                        f_print(fout, "\t\t%s = (char *(*)()) ",
                                                ROUTINE);
-                       if (newstyle) { /* new style: calls internal routine */
+                       if (newstyle) {
+                               /* new style: calls internal routine */
                                f_print(fout, "_");
                        }
                        if ((Cflag || mtflag) && !newstyle)
@@ -556,8 +530,7 @@ write_program(def, storage)
                print_return("\t\t");
                f_print(fout, "\t}\n");
 
-               f_print(fout,
-                       "\t(void) memset((char *)&%s, 0, sizeof (%s));\n",
+               f_print(fout, "\t(void) memset((char *)&%s, 0, sizeof (%s));\n",
                        ARG, ARG);
                if (Cflag)
                        printif("getargs", TRANSP, "(caddr_t) &", ARG);
@@ -601,7 +574,7 @@ write_program(def, storage)
                        printif("freeargs", TRANSP, "(caddr_t) &", ARG);
                else
                        printif("freeargs", TRANSP, "&", ARG);
-               (void) sprintf(_errbuf, "unable to free arguments");
+               sprintf(_errbuf, "unable to free arguments");
                print_err_message("\t\t");
                f_print(fout, "\t\texit(1);\n");
                f_print(fout, "\t}\n");
@@ -611,7 +584,7 @@ write_program(def, storage)
                        pvname(def->def_name, vp->vers_num);
                        f_print(fout,"_freeresult(%s, xdr_%s, (caddr_t) &%s))\n",
                                TRANSP, RESULT, RESULT);
-                       (void) sprintf(_errbuf, "unable to free results");
+                       sprintf(_errbuf, "unable to free results");
                        print_err_message("\t\t");
                        f_print(fout, "\n");
                };
@@ -621,39 +594,30 @@ write_program(def, storage)
 }
 
 static void
-printerr(err, transp)
-       char *err;
-       char *transp;
+printerr(char *err, char *transp)
 {
        f_print(fout, "\t\tsvcerr_%s(%s);\n", err, transp);
 }
 
 static void
-printif(proc, transp, prefix, arg)
-       char *proc;
-       char *transp;
-       char *prefix;
-       char *arg;
+printif(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);
 }
 
 int
-nullproc(proc)
-       proc_list *proc;
+nullproc(proc_list *proc)
 {
        for (; proc != NULL; proc = proc->next) {
-               if (streq(proc->proc_num, "0")) {
-                       return (1);
-               }
+               if (streq(proc->proc_num, "0"))
+                       return(1);
        }
-       return (0);
+       return(0);
 }
 
 static void
-write_inetmost(infile)
-       char *infile;
+write_inetmost(char *infile)
 {
        f_print(fout, "\tregister SVCXPRT *%s;\n", TRANSP);
        f_print(fout, "\tint sock;\n");
@@ -661,8 +625,8 @@ 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,
-       "\tif (getsockname(0, (struct sockaddr *)&saddr, &asize) == 0) {\n");
+       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");
        f_print(fout, "\t\t\texit(1);\n");
@@ -699,8 +663,7 @@ print_return(space)
 }
 
 static void
-print_pmapunset(space)
-       char *space;
+print_pmapunset(char *space)
 {
        list *l;
        definition *def;
@@ -719,8 +682,7 @@ print_pmapunset(space)
 }
 
 static void
-print_err_message(space)
-       char *space;
+print_err_message(char *space)
 {
        if (logflag)
                f_print(fout, "%ssyslog(LOG_ERR, \"%s\");\n", space, _errbuf);
@@ -734,8 +696,7 @@ print_err_message(space)
  * Write the server auxiliary function (_msgout, timeout)
  */
 void
-write_svc_aux(nomain)
-       int nomain;
+write_svc_aux(int nomain)
 {
        if (!logflag)
                write_msg_out();
@@ -791,8 +752,9 @@ write_timeout_func(void)
        if (!Cflag) {
                f_print(fout, "closedown(sig)\n");
                f_print(fout, "\tint sig;\n");
-       } else
+       } else {
                 f_print(fout, "closedown(int sig)\n");
+       }
        f_print(fout, "{\n");
        if (mtflag)
                f_print(fout, "\tmutex_lock(&_svcstate_lock);\n");
@@ -846,9 +808,7 @@ write_timeout_func(void)
  * Write the most of port monitor support
  */
 static void
-write_pm_most(infile, netflag)
-       char *infile;
-       int netflag;
+write_pm_most(char *infile, int netflag)
 {
        list *l;
        definition *def;
@@ -912,17 +872,15 @@ ioctl(0, I_PUSH, \"timod\")) {\n");
        f_print(fout, "\t\t\tfreenetconfigent(nconf);\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)
                        continue;
-               }
                for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
-                       f_print(fout,
-                               "\t\tif (!svc_reg(%s, %s, %s, ",
+                       f_print(fout, "\t\tif (!svc_reg(%s, %s, %s, ",
                                TRANSP, def->def_name, vp->vers_name);
                        pvname(def->def_name, vp->vers_num);
                        f_print(fout, ", 0)) {\n");
-                       (void) sprintf(_errbuf, "unable to register (%s, %s).",
-                                       def->def_name, vp->vers_name);
+                       sprintf(_errbuf, "unable to register (%s, %s).",
+                               def->def_name, vp->vers_name);
                        print_err_message("\t\t\t");
                        f_print(fout, "\t\t\texit(1);\n");
                        f_print(fout, "\t\t}\n");
@@ -945,9 +903,7 @@ ioctl(0, I_PUSH, \"timod\")) {\n");
  * Support for backgrounding the server if self started.
  */
 static void
-write_rpc_svc_fg(infile, sp)
-       char *infile;
-       char *sp;
+write_rpc_svc_fg(char *infile, char *sp)
 {
        f_print(fout, "#ifndef RPC_SVC_FG\n");
        f_print(fout, "%sint size;\n", sp);
@@ -979,9 +935,9 @@ 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 {
+       else {
                f_print(fout, "%si = open(\"/dev/tty\", 2);\n", sp);
                f_print(fout, "%sif (i >= 0) {\n", sp);
                f_print(fout,
@@ -997,9 +953,7 @@ write_rpc_svc_fg(infile, sp)
 }
 
 static void
-open_log_file(infile, sp)
-       char *infile;
-       char *sp;
+open_log_file(char *infile, char *sp)
 {
        char *s;
 
@@ -1011,15 +965,11 @@ open_log_file(infile, sp)
                *s = '.';
 }
 
-
-
-
 /*
  * write a registration for the given transport for Inetd
  */
 void
-write_inetd_register(transp)
-       char *transp;
+write_inetd_register(char *transp)
 {
        list *l;
        definition *def;
@@ -1048,22 +998,21 @@ write_inetd_register(transp)
                f_print(fout, ", 0, 0");
        f_print(fout, ");\n");
        f_print(fout, "%s\tif (%s == NULL) {\n", sp, TRANSP);
-       (void) sprintf(_errbuf, "cannot create %s service.", transp);
-       (void) sprintf(tmpbuf, "%s\t\t", sp);
+       sprintf(_errbuf, "cannot create %s service.", transp);
+       sprintf(tmpbuf, "%s\t\t", sp);
        print_err_message(tmpbuf);
        f_print(fout, "%s\t\texit(1);\n", sp);
        f_print(fout, "%s\t}\n", sp);
 
        if (inetdflag) {
                f_print(fout, "%s\tif (!_rpcpmstart)\n\t", sp);
-               f_print(fout, "%s\tproto = IPPROTO_%s;\n",
-                               sp, isudp ? "UDP": "TCP");
+               f_print(fout, "%s\tproto = IPPROTO_%s;\n", sp,
+                       isudp ? "UDP": "TCP");
        }
        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\tif (!svc_register(%s, %s, %s, ",
                                sp, TRANSP, def->def_name, vp->vers_name);
@@ -1073,8 +1022,7 @@ write_inetd_register(transp)
                        else
                                f_print(fout, ", IPPROTO_%s)) {\n",
                                        isudp ? "UDP": "TCP");
-                       (void) sprintf(_errbuf,
-                               "unable to register (%s, %s, %s).",
+                       sprintf(_errbuf, "unable to register (%s, %s, %s).",
                                def->def_name, vp->vers_name, transp);
                        print_err_message(tmpbuf);
                        f_print(fout, "%s\t\texit(1);\n", sp);
index a241bff..4284199 100644 (file)
@@ -28,7 +28,7 @@
  *
  * @(#)rpc_tblout.c 1.4 89/02/22 (C) 1988 SMI
  * $FreeBSD: src/usr.bin/rpcgen/rpc_tblout.c,v 1.4 1999/08/28 01:05:17 peter Exp $
- * $DragonFly: src/usr.bin/rpcgen/rpc_tblout.c,v 1.3 2003/11/03 19:31:32 eirikn Exp $
+ * $DragonFly: src/usr.bin/rpcgen/rpc_tblout.c,v 1.4 2004/06/19 16:40:36 joerg Exp $
  */
 
 #ident "@(#)rpc_tblout.c       1.11    93/07/05 SMI" 
@@ -43,9 +43,9 @@
 #include "rpc_parse.h"
 #include "rpc_util.h"
 
-#define TABSIZE                8
-#define TABCOUNT       5
-#define TABSTOP                (TABSIZE*TABCOUNT)
+#define        TABSIZE         8
+#define        TABCOUNT        5
+#define        TABSTOP         (TABSIZE*TABCOUNT)
 
 static char tabstr[TABCOUNT+1] = "\t\t\t\t\t";
 
@@ -59,12 +59,12 @@ static char null_entry[] = "\n\t(char *(*)())0,\n\
 
 static char tbl_nproc[] = "int %s_nproc =\n\tsizeof(%s_table)/sizeof(%s_table[0]);\n\n";
 
-extern int nullproc( proc_list * );
-static void write_table( definition * );
-static void printit( char *, char * );
+extern int     nullproc(proc_list *);
+static void    write_table(definition *);
+static void    printit(char *, char *);
 
 void
-write_tables()
+write_tables(void)
 {
        list *l;
        definition *def;
@@ -79,8 +79,7 @@ write_tables()
 }
 
 static void
-write_table(def)
-       definition *def;
+write_table(definition *def)
 {
        version_list *vp;
        proc_list *proc;
@@ -117,22 +116,26 @@ write_table(def)
                        f_print(fout, "\n\t(char *(*)())RPCGEN_ACTION(");
 
                        /* routine to invoke */
-                       if( Cflag && !newstyle )
-                         pvname_svc(proc->proc_name, vp->vers_num);
+                       if (Cflag && !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(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);
                }
@@ -144,9 +147,7 @@ write_table(def)
 }
 
 static void
-printit(prefix, type)
-       char *prefix;
-       char *type;
+printit(char *prefix, char *type)
 {
        int len;
        int tabs;
index d7fde18..62c7464 100644 (file)
@@ -28,7 +28,7 @@
  *
  * @(#)rpc_util.c 1.11 89/02/22 (C) 1987 SMI
  * $FreeBSD: src/usr.bin/rpcgen/rpc_util.c,v 1.6 1999/08/28 01:05:17 peter Exp $
- * $DragonFly: src/usr.bin/rpcgen/rpc_util.c,v 1.3 2003/11/03 19:31:32 eirikn Exp $
+ * $DragonFly: src/usr.bin/rpcgen/rpc_util.c,v 1.4 2004/06/19 16:40:36 joerg Exp $
  */
 
 #ident "@(#)rpc_util.c 1.14    93/07/05 SMI"
@@ -63,13 +63,13 @@ FILE *fin;                  /* file pointer of current input */
 
 list *defined;                 /* list of defined things */
 
-static void printwhere( void );
+static void    printwhere(void);
 
 /*
  * Reinitialize the world
  */
 void
-reinitialize()
+reinitialize(void)
 {
        memset(curline, 0, MAXLINESIZE);
        where = curline;
@@ -81,43 +81,35 @@ reinitialize()
  * string equality
  */
 int
-streq(a, b)
-       char *a;
-       char *b;
+streq(char *a, char *b)
 {
-       return (strcmp(a, b) == 0);
+       return(strcmp(a, b) == 0);
 }
 
 /*
  * find a value in a list
  */
 definition *
-findval(lst, val, cmp)
-       list *lst;
-       char *val;
-       int (*cmp) ();
-
+findval(list *lst, char *val, int (*cmp) (definition *, char *))
 {
        for (; lst != NULL; lst = lst->next) {
-               if ((*cmp) (lst->val, val)) {
-                       return (lst->val);
-               }
+               if ((*cmp) (lst->val, val))
+                       return(lst->val);
        }
-       return (NULL);
+       return(NULL);
 }
 
 /*
  * store a value in a list
  */
 void
-storeval(lstp, val)
-       list **lstp;
-       definition *val;
+storeval(list **lstp, definition *val)
 {
        list **l;
        list *lst;
 
-       for (l = lstp; *l != NULL; l = (list **) & (*l)->next);
+       for (l = lstp; *l != NULL; l = (list **) & (*l)->next)
+               ;
        lst = ALLOC(list);
        lst->val = val;
        lst->next = NULL;
@@ -125,145 +117,121 @@ storeval(lstp, val)
 }
 
 static int
-findit(def, type)
-       definition *def;
-       char *type;
+findit(definition *def, char *type)
 {
-       return (streq(def->def_name, type));
+       return(streq(def->def_name, type));
 }
 
 static char *
-fixit(type, orig)
-       char *type;
-       char *orig;
+fixit(char *type, char *orig)
 {
        definition *def;
 
        def = (definition *) FINDVAL(defined, type, findit);
-       if (def == NULL || def->def_kind != DEF_TYPEDEF) {
-               return (orig);
-       }
+       if (def == NULL || def->def_kind != DEF_TYPEDEF)
+               return(orig);
        switch (def->def.ty.rel) {
        case REL_VECTOR:
                if (streq(def->def.ty.old_type, "opaque"))
-                       return ("char");
+                       return("char");
                else
-                       return (def->def.ty.old_type);
+                       return(def->def.ty.old_type);
 
        case REL_ALIAS:
-               return (fixit(def->def.ty.old_type, orig));
+               return(fixit(def->def.ty.old_type, orig));
        default:
-               return (orig);
+               return(orig);
        }
 }
 
 char *
-fixtype(type)
-       char *type;
+fixtype(char *type)
 {
-       return (fixit(type, type));
+       return(fixit(type, type));
 }
 
 char *
-stringfix(type)
-       char *type;
+stringfix(char *type)
 {
-       if (streq(type, "string")) {
-               return ("wrapstring");
-       } else {
-               return (type);
-       }
+       if (streq(type, "string"))
+               return("wrapstring");
+       else
+               return(type);
 }
 
 void
-ptype(prefix, type, follow)
-       char *prefix;
-       char *type;
-       int follow;
+ptype(char *prefix, char *type, int follow)
 {
        if (prefix != NULL) {
-               if (streq(prefix, "enum")) {
+               if (streq(prefix, "enum"))
                        f_print(fout, "enum ");
-               } else {
+               else
                        f_print(fout, "struct ");
-               }
        }
-       if (streq(type, "bool")) {
+       if (streq(type, "bool"))
                f_print(fout, "bool_t ");
-       } else if (streq(type, "string")) {
+       else if (streq(type, "string"))
                f_print(fout, "char *");
-       } else {
+       else
                f_print(fout, "%s ", follow ? fixtype(type) : type);
-       }
 }
 
 static int
-typedefed(def, type)
-       definition *def;
-       char *type;
+typedefed(definition *def, char *type)
 {
-       if (def->def_kind != DEF_TYPEDEF || def->def.ty.old_prefix != NULL) {
-               return (0);
-       } else {
-               return (streq(def->def_name, type));
-       }
+       if (def->def_kind != DEF_TYPEDEF || def->def.ty.old_prefix != NULL)
+               return(0);
+       else
+               return(streq(def->def_name, type));
 }
 
 int
-isvectordef(type, rel)
-       char *type;
-       relation rel;
+isvectordef(char *type, relation rel)
 {
        definition *def;
 
        for (;;) {
                switch (rel) {
                case REL_VECTOR:
-                       return (!streq(type, "string"));
+                       return(!streq(type, "string"));
                case REL_ARRAY:
-                       return (0);
+                       return(0);
                case REL_POINTER:
-                       return (0);
+                       return(0);
                case REL_ALIAS:
                        def = (definition *) FINDVAL(defined, type, typedefed);
                        if (def == NULL) {
-                               return (0);
+                               return(0);
                        }
                        type = def->def.ty.old_type;
                        rel = def->def.ty.rel;
                }
        }
 
-       return (0);
+       return(0);
 }
 
 char *
-locase(str)
-       char *str;
+locase(char *str)
 {
        char c;
        static char buf[100];
        char *p = buf;
 
-       while ( (c = *str++) ) {
+       while ((c = *str++) != 0)
                *p++ = (c >= 'A' && c <= 'Z') ? (c - 'A' + 'a') : c;
-       }
        *p = 0;
-       return (buf);
+       return(buf);
 }
 
 void
-pvname_svc(pname, vnum)
-       char *pname;
-       char *vnum;
+pvname_svc(char *pname, char *vnum)
 {
        f_print(fout, "%s_%s_svc", locase(pname), vnum);
 }
 
 void
-pvname(pname, vnum)
-       char *pname;
-       char *vnum;
+pvname(char *pname, char *vnum)
 {
        f_print(fout, "%s_%s", locase(pname), vnum);
 }
@@ -272,8 +240,7 @@ pvname(pname, vnum)
  * print a useful (?) error message, and then die
  */
 void
-error(msg)
-       char *msg;
+error(char *msg)
 {
        printwhere();
        warnx("%s, line %d: %s", infilename, linenum, msg);
@@ -285,19 +252,17 @@ error(msg)
  * die.
  */
 void
-crash()
+crash(void)
 {
        int i;
 
-       for (i = 0; i < nfiles; i++) {
-               (void) unlink(outfiles[i]);
-       }
+       for (i = 0; i < nfiles; i++)
+               unlink(outfiles[i]);
        exit(1);
 }
 
 void
-record_open(file)
-       char *file;
+record_open(char *file)
 {
        if (nfiles < NFILES) {
                outfiles[nfiles++] = file;
@@ -314,11 +279,9 @@ static char *toktostr();
  * error, token encountered was not the expected one
  */
 void
-expected1(exp1)
-       tok_kind exp1;
+expected1(tok_kind exp1)
 {
-       s_print(expectbuf, "expected '%s'",
-               toktostr(exp1));
+       s_print(expectbuf, "expected '%s'", toktostr(exp1));
        error(expectbuf);
 }
 
@@ -326,11 +289,9 @@ expected1(exp1)
  * error, token encountered was not one of two expected ones
  */
 void
-expected2(exp1, exp2)
-       tok_kind exp1, exp2;
+expected2(tok_kind exp1, tok_kind exp2)
 {
-       s_print(expectbuf, "expected '%s' or '%s'",
-               toktostr(exp1),
+       s_print(expectbuf, "expected '%s' or '%s'", toktostr(exp1),
                toktostr(exp2));
        error(expectbuf);
 }
@@ -339,24 +300,18 @@ expected2(exp1, exp2)
  * error, token encountered was not one of 3 expected ones
  */
 void
-expected3(exp1, exp2, exp3)
-       tok_kind exp1, exp2, exp3;
+expected3(tok_kind exp1, tok_kind exp2, tok_kind exp3)
 {
-       s_print(expectbuf, "expected '%s', '%s' or '%s'",
-               toktostr(exp1),
-               toktostr(exp2),
-               toktostr(exp3));
+       s_print(expectbuf, "expected '%s', '%s' or '%s'", toktostr(exp1),
+               toktostr(exp2), toktostr(exp3));
        error(expectbuf);
 }
 
 void
-tabify(f, tab)
-       FILE *f;
-       int tab;
+tabify(FILE *f, int tab)
 {
-       while (tab--) {
-               (void) fputc('\t', f);
-       }
+       while (tab--)
+               fputc('\t', f);
 }
 
 
@@ -398,17 +353,17 @@ static token tokstrings[] = {
 };
 
 static char *
-toktostr(kind)
-       tok_kind kind;
+toktostr(tok_kind kind)
 {
        token *sp;
 
-       for (sp = tokstrings; sp->kind != TOK_EOF && sp->kind != kind; sp++);
-       return (sp->str);
+       for (sp = tokstrings; sp->kind != TOK_EOF && sp->kind != kind; sp++)
+               ;
+       return(sp->str);
 }
 
 static void
-printbuf()
+printbuf(void)
 {
        char c;
        int i;
@@ -423,14 +378,13 @@ printbuf()
                } else {
                        cnt = 1;
                }
-               while (cnt--) {
-                       (void) fputc(c, stderr);
-               }
+               while (cnt--)
+                       fputc(c, stderr);
        }
 }
 
 static void
-printwhere()
+printwhere(void)
 {
        int i;
        char c;
@@ -439,22 +393,19 @@ printwhere()
        printbuf();
        for (i = 0; i < where - curline; i++) {
                c = curline[i];
-               if (c == '\t') {
+               if (c == '\t')
                        cnt = 8 - (i % TABSIZE);
-               } else {
+               else
                        cnt = 1;
-               }
                while (cnt--) {
-                       (void) fputc('^', stderr);
+                       fputc('^', stderr);
                }
        }
-       (void) fputc('\n', stderr);
+       fputc('\n', stderr);
 }
 
 char *
-make_argname(pname, vname)
-    char *pname;
-    char *vname;
+make_argname(char *pname, char *vname)
 {
        char *name;
 
@@ -462,41 +413,35 @@ make_argname(pname, vname)
        if (!name)
                errx(1, "failed in malloc");
        sprintf(name, "%s_%s_%s", locase(pname), vname, ARGEXT);
-       return (name);
+       return(name);
 }
 
 bas_type *typ_list_h;
 bas_type *typ_list_t;
 
 void
-add_type(len, type)
-int len;
-char *type;
+add_type(int len, char *type)
 {
        bas_type *ptr;
 
-       if ((ptr = (bas_type *) malloc(sizeof (bas_type))) == (bas_type *)NULL)
+       if ((ptr = (bas_type *) malloc(sizeof (bas_type))) == NULL)
                errx(1, "failed in malloc");
 
        ptr->name = type;
        ptr->length = len;
        ptr->next = NULL;
-       if (typ_list_t == NULL)
-       {
-
+       if (typ_list_t == NULL) {
                typ_list_t = ptr;
                typ_list_h = ptr;
-       }
-       else
-       {
+       } else {
                typ_list_t->next = ptr;
                typ_list_t = ptr;
-       };
+       }
 }
 
 
-bas_type *find_type(type)
-char *type;
+bas_type *
+find_type(char *type)
 {
        bas_type * ptr;
 
@@ -504,9 +449,9 @@ char *type;
        while (ptr != NULL)
        {
                if (strcmp(ptr->name, type) == 0)
-                       return (ptr);
+                       return(ptr);
                else
                        ptr = ptr->next;
-       };
-       return (NULL);
+       }
+       return(NULL);
 }
index f465bfc..d56e5c0 100644 (file)
@@ -58,6 +58,7 @@
 */ 
 
 /*      @(#)rpc_util.h  1.5  90/08/29  (C) 1987 SMI   */
+/* $DragonFly: src/usr.bin/rpcgen/rpc_util.h,v 1.2 2004/06/19 16:40:36 joerg Exp $ */
 
 /*
  * rpc_util.h, Useful definitions for the RPC protocol compiler 
@@ -65,6 +66,8 @@
 #include <sys/types.h>
 #include <stdlib.h>
 
+#include "rpc_scan.h"
+
 #define        alloc(size)             malloc((unsigned)(size))
 #define        ALLOC(object)   (object *) malloc(sizeof(object))
 
@@ -132,7 +135,7 @@ extern int newstyle;
 extern int Cflag;     /* ANSI-C/C++ flag */
 extern int CCflag;     /* C++ flag */
 extern int tirpcflag; /* flag for generating tirpc code */
-extern int inline; /* if this is 0, then do not generate inline code */
+extern int rpcgen_inline; /* if this is 0, then do not generate inline code */
 extern int mtflag;
 
 /*
@@ -149,65 +152,64 @@ extern pid_t childpid;
 /*
  * rpc_util routines 
  */
-void reinitialize();
-void crash();
-void add_type(int len, char *type);
+void           reinitialize(void);
+void           crash(void );
+void           add_type(int len, char *type);
 
-void storeval();
+void           storeval(list **, definition *);
 
 #define        STOREVAL(list,item)     \
        storeval(list,item)
 
-definition *findval();
+definition     *findval(list *, char *, int (*)(definition *, char *));
 
 #define        FINDVAL(list,item,finder) \
        findval(list, item, finder)
 
-char *fixtype();
-char *stringfix();
-char *locase();
-void pvname_svc();
-void pvname();
-void ptype();
-int isvectordef();
-int streq();
-void error();
-void expected1();
-void expected2();
-void expected3();
-void tabify();
-void record_open();
-bas_type *find_type();
+char           *fixtype(char *);
+char           *stringfix(char *);
+char           *locase(char *);
+void           pvname_svc(char *, char *);
+void           pvname(char *, char *);
+void           ptype(char *, char *, int);
+int            isvectordef(char *, relation);
+int            streq(char *, char *);
+void           error(char *);
+void           expected1(tok_kind);
+void           expected2(tok_kind, tok_kind);
+void           expected3(tok_kind, tok_kind, tok_kind);
+void           tabify(FILE *, int);
+void           record_open(char *);
+bas_type       *find_type(char *);
 /*
  * rpc_cout routines 
  */
-void cprint();
-void emit();
+void           cprint(void);
+void           emit(definition *);
 
 /*
  * rpc_hout routines 
  */
-void print_datadef();
-void print_funcdef();
-void print_xdr_func_def();
+void           print_datadef(definition *);
+void           print_funcdef(definition *);
+void           print_xdr_func_def(char *, int, int);
 
 /*
  * rpc_svcout routines 
  */
-void write_most();
-void write_register();
-void write_rest();
-void write_programs();
-void write_svc_aux();
-void write_inetd_register();
-void write_netid_register();
-void write_nettype_register();
+void           write_most(char *, int, int);
+void           write_rest(void);
+void           write_programs(char *);
+void           write_svc_aux(int);
+void           write_inetd_register(char *);
+void           write_netid_register(char *);
+void           write_nettype_register(char *);
 /*
  * rpc_clntout routines
  */
-void write_stubs();
+void           write_stubs(void);
 
 /*
  * rpc_tblout routines
  */
-void write_tables();
+void           write_tables(void);