diff options
Diffstat (limited to 'usr.bin/rpcgen/rpc_cout.c')
-rw-r--r-- | usr.bin/rpcgen/rpc_cout.c | 95 |
1 files changed, 52 insertions, 43 deletions
diff --git a/usr.bin/rpcgen/rpc_cout.c b/usr.bin/rpcgen/rpc_cout.c index a3112016981..48f14d9c151 100644 --- a/usr.bin/rpcgen/rpc_cout.c +++ b/usr.bin/rpcgen/rpc_cout.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rpc_cout.c,v 1.4 1997/10/11 21:10:41 deraadt Exp $ */ +/* $OpenBSD: rpc_cout.c,v 1.5 2001/07/17 02:23:59 pvalchev Exp $ */ /* $NetBSD: rpc_cout.c,v 1.6 1996/10/01 04:13:53 cgd Exp $ */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for @@ -41,27 +41,28 @@ static char sccsid[] = "@(#)rpc_cout.c 1.13 89/02/22 (C) 1987 SMI"; #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <ctype.h> +#include <err.h> #include "rpc_parse.h" #include "rpc_util.h" -static findtype __P((definition *, char *)); -static undefined __P((char *)); -static print_generic_header __P((char *, int)); -static print_header __P((definition *)); -static print_prog_header __P((proc_list *)); -static print_trailer __P((void)); -static print_ifopen __P((int, char *)); -static print_ifarg __P((char *)); -static print_ifsizeof __P((char *, char *)); -static print_ifclose __P((int)); -static print_ifstat __P((int, char *, char *, relation, char *, char *, char *)); -static emit_num __P((definition *)); -static emit_program __P((definition *)); -static emit_enum __P((definition *)); -static emit_union __P((definition *)); -static emit_struct __P((definition *)); -static emit_typedef __P((definition *)); -static print_stat __P((int, declaration *)); +static int findtype __P((definition *, char *)); +static int undefined __P((char *)); +static void print_generic_header __P((char *, int)); +static void print_header __P((definition *)); +static void print_prog_header __P((proc_list *)); +static void print_trailer __P((void)); +static void print_ifopen __P((int, char *)); +static void print_ifarg __P((char *)); +static void print_ifsizeof __P((char *, char *)); +static void print_ifclose __P((int)); +static void print_ifstat __P((int, char *, char *, relation, char *, char *, char *)); +static void emit_program __P((definition *)); +static void emit_enum __P((definition *)); +static void emit_union __P((definition *)); +static void emit_struct __P((definition *)); +static void emit_typedef __P((definition *)); +static void print_stat __P((int, declaration *)); /* @@ -101,11 +102,16 @@ emit(def) case DEF_TYPEDEF: emit_typedef(def); break; + case DEF_CONST: + case DEF_PROGRAM: + errx(1, "Internal error %s, %d: Case %d not handled\n", + __FILE__, __LINE__, def->def_kind); + break; } print_trailer(); } -static +static int findtype(def, type) definition *def; char *type; @@ -118,7 +124,7 @@ findtype(def, type) } } -static +static int undefined(type) char *type; { @@ -130,7 +136,7 @@ undefined(type) return (def == NULL); } -static +static void print_generic_header(procname, pointerp) char *procname; int pointerp; @@ -154,16 +160,11 @@ print_generic_header(procname, pointerp) } } -static +static void print_header(def) definition *def; { - decl_list *dl; - bas_type *ptr; - int i; - - print_generic_header(def->def_name, def->def_kind != DEF_TYPEDEF || !isvectordef(def->def.ty.old_type, def->def.ty.rel)); @@ -178,14 +179,14 @@ print_header(def) } -static +static void print_prog_header(plist) proc_list *plist; { print_generic_header(plist->args.argname, 1); } -static +static void print_trailer() { f_print(fout, "\treturn (TRUE);\n"); @@ -193,7 +194,7 @@ print_trailer() } -static +static void print_ifopen(indent, name) int indent; char *name; @@ -202,14 +203,14 @@ print_ifopen(indent, name) f_print(fout, " if (!xdr_%s(xdrs", name); } -static +static void print_ifarg(arg) char *arg; { f_print(fout, ", %s", arg); } -static +static void print_ifsizeof(prefix, type) char *prefix; char *type; @@ -225,7 +226,7 @@ print_ifsizeof(prefix, type) } } -static +static void print_ifclose(indent) int indent; { @@ -236,7 +237,7 @@ print_ifclose(indent) f_print(fout, " }\n"); } -static +static void print_ifstat(indent, prefix, type, rel, amax, objname, name) int indent; char *prefix; @@ -314,7 +315,7 @@ print_ifstat(indent, prefix, type, rel, amax, objname, name) } /* ARGSUSED */ -static +static void emit_enum(def) definition *def; { @@ -323,7 +324,7 @@ emit_enum(def) print_ifclose(1); } -static +static void emit_program(def) definition *def; { @@ -345,7 +346,7 @@ emit_program(def) } -static +static void emit_union(def) definition *def; { @@ -407,7 +408,7 @@ emit_union(def) f_print(fout, "\t}\n"); } -static +static void emit_struct(def) definition *def; { @@ -514,7 +515,7 @@ emit_struct(def) } } else { - if (i > 0) + if (i > 0) { if (sizestr == NULL && size < doinline) { /* don't expand into inline * code if size < doinline */ @@ -559,6 +560,7 @@ emit_struct(def) f_print(fout, "\t }\n"); } + } size = 0; i = 0; sizestr = NULL; @@ -566,7 +568,7 @@ emit_struct(def) } } - if (i > 0) + if (i > 0) { if (sizestr == NULL && size < doinline) { /* don't expand into inline code if size < * doinline */ @@ -610,6 +612,7 @@ emit_struct(def) } flag = GET; + } } f_print(fout, "\t return(TRUE);\n\t}\n\n"); @@ -619,7 +622,7 @@ emit_struct(def) print_stat(1, &dl->decl); } -static +static void emit_typedef(def) definition *def; { @@ -632,7 +635,7 @@ emit_typedef(def) print_ifstat(1, prefix, type, rel, amax, "objp", def->def_name); } -static +static void print_stat(indent, dec) declaration *dec; int indent; @@ -655,6 +658,7 @@ print_stat(indent, dec) char *upcase __P((char *)); +void emit_inline(decl, flag) declaration *decl; int flag; @@ -672,10 +676,15 @@ emit_inline(decl, flag) decl->name, decl->array_max); emit_single_in_line(decl, flag, REL_VECTOR); f_print(fout, "\t\t }\n\t\t };\n"); + case REL_ARRAY: + case REL_POINTER: + errx(1, "Internal error %s, %d: Case %d not handled\n", + __FILE__, __LINE__, decl->rel); } } +void emit_single_in_line(decl, flag, rel) declaration *decl; int flag; |