diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2002-06-01 01:40:39 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2002-06-01 01:40:39 +0000 |
commit | d37e31b7a32d5f1ce6af4bf8d561608226266d8a (patch) | |
tree | 939b9932adaafbbf6f3fdc53d25b8b79090f1db7 | |
parent | f4c0cad0edf2f0e459707cc36180dbd427e668eb (diff) |
cleanups
-rw-r--r-- | usr.bin/rpcgen/rpc_clntout.c | 74 | ||||
-rw-r--r-- | usr.bin/rpcgen/rpc_cout.c | 151 | ||||
-rw-r--r-- | usr.bin/rpcgen/rpc_hout.c | 140 | ||||
-rw-r--r-- | usr.bin/rpcgen/rpc_main.c | 124 | ||||
-rw-r--r-- | usr.bin/rpcgen/rpc_parse.c | 10 | ||||
-rw-r--r-- | usr.bin/rpcgen/rpc_sample.c | 118 | ||||
-rw-r--r-- | usr.bin/rpcgen/rpc_scan.c | 10 | ||||
-rw-r--r-- | usr.bin/rpcgen/rpc_svcout.c | 579 | ||||
-rw-r--r-- | usr.bin/rpcgen/rpc_tblout.c | 34 | ||||
-rw-r--r-- | usr.bin/rpcgen/rpc_util.c | 33 | ||||
-rw-r--r-- | usr.bin/rpcgen/rpc_util.h | 5 |
11 files changed, 641 insertions, 637 deletions
diff --git a/usr.bin/rpcgen/rpc_clntout.c b/usr.bin/rpcgen/rpc_clntout.c index d2be67e1e3a..2d704c12062 100644 --- a/usr.bin/rpcgen/rpc_clntout.c +++ b/usr.bin/rpcgen/rpc_clntout.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rpc_clntout.c,v 1.9 2002/02/16 21:27:51 millert Exp $ */ +/* $OpenBSD: rpc_clntout.c,v 1.10 2002/06/01 01:40:38 deraadt Exp $ */ /* $NetBSD: rpc_clntout.c,v 1.4 1995/06/11 21:49:52 pk Exp $ */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for @@ -59,9 +59,9 @@ write_stubs() list *l; definition *def; - f_print(fout, + fprintf(fout, "\n/* Default timeout can be changed using clnt_control() */\n"); - f_print(fout, "static struct timeval TIMEOUT = { %d, 0 };\n", + fprintf(fout, "static struct timeval TIMEOUT = { %d, 0 };\n", DEFAULT_TIMEOUT); for (l = defined; l != NULL; l = l->next) { def = (definition *) l->val; @@ -80,14 +80,14 @@ write_program(def) for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) { for (proc = vp->procs; proc != NULL; proc = proc->next) { - f_print(fout, "\n"); + fprintf(fout, "\n"); ptype(proc->res_prefix, proc->res_type, 1); - f_print(fout, "*\n"); + fprintf(fout, "*\n"); pvname(proc->proc_name, vp->vers_num); printarglist( proc, "clnt", "CLIENT *" ); - f_print(fout, "{\n"); + fprintf(fout, "{\n"); printbody(proc); - f_print(fout, "}\n"); + fprintf(fout, "}\n"); } } } @@ -108,42 +108,42 @@ void printarglist( proc, addargname, addargtype ) if (!newstyle) { /* old style: always pass argument by reference */ if (Cflag) { /* C++ style heading */ - f_print(fout, "("); + fprintf(fout, "("); ptype(proc->args.decls->decl.prefix, proc->args.decls->decl.type, 1); - f_print(fout, "*argp, %s%s)\n", addargtype, addargname ); + fprintf(fout, "*argp, %s%s)\n", addargtype, addargname ); } else { - f_print(fout, "(argp, %s)\n", addargname); - f_print(fout, "\t"); + fprintf(fout, "(argp, %s)\n", addargname); + fprintf(fout, "\t"); ptype(proc->args.decls->decl.prefix, proc->args.decls->decl.type, 1); - f_print(fout, "*argp;\n"); + fprintf(fout, "*argp;\n"); } } else if (streq( proc->args.decls->decl.type, "void")) { /* newstyle, 0 argument */ if (Cflag) - f_print(fout, "(%s%s)\n", addargtype, addargname ); + fprintf(fout, "(%s%s)\n", addargtype, addargname ); else - f_print(fout, "(%s)\n", addargname); + fprintf(fout, "(%s)\n", addargname); } else { /* new style, 1 or multiple arguments */ if (!Cflag) { - f_print(fout, "("); + fprintf(fout, "("); for (l = proc->args.decls; l != NULL; l = l->next) - f_print(fout, "%s, ", l->decl.name); - f_print(fout, "%s)\n", addargname ); + fprintf(fout, "%s, ", l->decl.name); + fprintf(fout, "%s)\n", addargname ); for (l = proc->args.decls; l != NULL; l = l->next) { pdeclaration(proc->args.argname, &l->decl, 1, ";\n" ); } } else { /* C++ style header */ - f_print(fout, "("); + fprintf(fout, "("); for(l = proc->args.decls; l != NULL; l = l->next) { pdeclaration(proc->args.argname, &l->decl, 0, ", " ); } - f_print(fout, " %s%s)\n", addargtype, addargname ); + fprintf(fout, " %s%s)\n", addargtype, addargname ); } } if (!Cflag) - f_print(fout, "\t%s%s;\n", addargtype, addargname ); + fprintf(fout, "\t%s%s;\n", addargtype, addargname ); } @@ -169,42 +169,42 @@ printbody(proc) /* For new style with multiple arguments, need a structure in which to stuff the arguments. */ if ( newstyle && args2) { - f_print(fout, "\t%s", proc->args.argname); - f_print(fout, " arg;\n"); + fprintf(fout, "\t%s", proc->args.argname); + fprintf(fout, " arg;\n"); } - f_print(fout, "\tstatic "); + fprintf(fout, "\tstatic "); if (streq(proc->res_type, "void")) { - f_print(fout, "char "); + fprintf(fout, "char "); } 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", + fprintf(fout, "%s;\n",RESULT); + fprintf(fout, "\n"); + fprintf(fout, "\tmemset((char *)%s%s, 0, sizeof(%s));\n", ampr(proc->res_type ), RESULT, RESULT); if (newstyle && !args2 && (streq( proc->args.decls->decl.type, "void"))) { /* newstyle, 0 arguments */ - f_print(fout, + fprintf(fout, "\tif (clnt_call(clnt, %s, xdr_void", proc->proc_name); - f_print(fout, + fprintf(fout, ", NULL, xdr_%s, %s%s, TIMEOUT) != RPC_SUCCESS) {\n", stringfix(proc->res_type), ampr(proc->res_type), RESULT); } else if ( newstyle && args2) { /* newstyle, multiple arguments: stuff arguments into structure */ for (l = proc->args.decls; l != NULL; l = l->next) { - f_print(fout, "\targ.%s = %s;\n", + fprintf(fout, "\targ.%s = %s;\n", l->decl.name, l->decl.name); } - f_print(fout, + fprintf(fout, "\tif (clnt_call(clnt, %s, xdr_%s", proc->proc_name, proc->args.argname); - f_print(fout, + fprintf(fout, ", &arg, xdr_%s, %s%s, TIMEOUT) != RPC_SUCCESS) {\n", stringfix(proc->res_type), ampr(proc->res_type), RESULT); } else { /* single argument, new or old style */ - f_print(fout, + fprintf(fout, "\tif (clnt_call(clnt, %s, xdr_%s, %s%s, xdr_%s, %s%s, TIMEOUT) != RPC_SUCCESS) {\n", proc->proc_name, stringfix(proc->args.decls->decl.type), @@ -213,13 +213,13 @@ printbody(proc) stringfix(proc->res_type), ampr(proc->res_type),RESULT); } - f_print(fout, "\t\treturn (NULL);\n"); - f_print(fout, "\t}\n"); + fprintf(fout, "\t\treturn (NULL);\n"); + fprintf(fout, "\t}\n"); if (streq(proc->res_type, "void")) { - f_print(fout, "\treturn ((void *)%s%s);\n", + fprintf(fout, "\treturn ((void *)%s%s);\n", ampr(proc->res_type),RESULT); } else { - f_print(fout, "\treturn (%s%s);\n", ampr(proc->res_type),RESULT); + fprintf(fout, "\treturn (%s%s);\n", ampr(proc->res_type),RESULT); } } diff --git a/usr.bin/rpcgen/rpc_cout.c b/usr.bin/rpcgen/rpc_cout.c index c15cee08fb2..9b0915ed6a3 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.11 2002/02/16 21:27:51 millert Exp $ */ +/* $OpenBSD: rpc_cout.c,v 1.12 2002/06/01 01:40:38 deraadt Exp $ */ /* $NetBSD: rpc_cout.c,v 1.6 1996/10/01 04:13:53 cgd Exp $ */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for @@ -135,22 +135,22 @@ print_generic_header(procname, pointerp) char *procname; int pointerp; { - f_print(fout, "\n"); - f_print(fout, "bool_t\n"); + fprintf(fout, "\n"); + fprintf(fout, "bool_t\n"); if (Cflag) { - f_print(fout, "xdr_%s(", procname); - f_print(fout, "XDR *xdrs, "); - f_print(fout, "%s ", procname); + fprintf(fout, "xdr_%s(", procname); + fprintf(fout, "XDR *xdrs, "); + fprintf(fout, "%s ", procname); if (pointerp) - f_print(fout, "*"); - f_print(fout, "objp)\n{\n"); + fprintf(fout, "*"); + fprintf(fout, "objp)\n{\n"); } else { - f_print(fout, "xdr_%s(xdrs, objp)\n", procname); - f_print(fout, "\tXDR *xdrs;\n"); - f_print(fout, "\t%s ", procname); + fprintf(fout, "xdr_%s(xdrs, objp)\n", procname); + fprintf(fout, "\tXDR *xdrs;\n"); + fprintf(fout, "\t%s ", procname); if (pointerp) - f_print(fout, "*"); - f_print(fout, "objp;\n{\n"); + fprintf(fout, "*"); + fprintf(fout, "objp;\n{\n"); } } @@ -167,7 +167,7 @@ print_header(def) if (doinline == 0) return; /* May cause lint to complain. but ... */ - f_print(fout, "\tint32_t *buf;\n\n"); + fprintf(fout, "\tint32_t *buf;\n\n"); } static void @@ -180,8 +180,8 @@ print_prog_header(plist) static void print_trailer() { - f_print(fout, "\treturn (TRUE);\n"); - f_print(fout, "}\n"); + fprintf(fout, "\treturn (TRUE);\n"); + fprintf(fout, "}\n"); } static void @@ -190,14 +190,14 @@ print_ifopen(indent, name) char *name; { tabify(fout, indent); - f_print(fout, "if (!xdr_%s(xdrs", name); + fprintf(fout, "if (!xdr_%s(xdrs", name); } static void print_ifarg(arg) char *arg; { - f_print(fout, ", %s", arg); + fprintf(fout, ", %s", arg); } static void @@ -206,13 +206,13 @@ print_ifsizeof(prefix, type) char *type; { if (streq(type, "bool")) { - f_print(fout, ", sizeof(bool_t), (xdrproc_t)xdr_bool"); + fprintf(fout, ", sizeof(bool_t), (xdrproc_t)xdr_bool"); } else { - f_print(fout, ", sizeof("); + fprintf(fout, ", sizeof("); if (undefined(type) && prefix) { - f_print(fout, "%s ", prefix); + fprintf(fout, "%s ", prefix); } - f_print(fout, "%s), (xdrproc_t)xdr_%s", type, type); + fprintf(fout, "%s), (xdrproc_t)xdr_%s", type, type); } } @@ -220,11 +220,11 @@ static void print_ifclose(indent) int indent; { - f_print(fout, ")) {\n"); + fprintf(fout, ")) {\n"); tabify(fout, indent); - f_print(fout, "\treturn (FALSE);\n"); + fprintf(fout, "\treturn (FALSE);\n"); tabify(fout, indent); - f_print(fout, "}\n"); + fprintf(fout, "}\n"); } static void @@ -243,7 +243,7 @@ print_ifstat(indent, prefix, type, rel, amax, objname, name) case REL_POINTER: print_ifopen(indent, "pointer"); print_ifarg("(char **)"); - f_print(fout, "%s", objname); + fprintf(fout, "%s", objname); print_ifsizeof(prefix, type); break; case REL_VECTOR: @@ -259,7 +259,7 @@ print_ifstat(indent, prefix, type, rel, amax, objname, name) } else { print_ifopen(indent, "vector"); print_ifarg("(char *)"); - f_print(fout, "%s", objname); + fprintf(fout, "%s", objname); } print_ifarg(amax); if (!alt) { @@ -284,10 +284,10 @@ print_ifstat(indent, prefix, type, rel, amax, objname, name) } print_ifarg("(char **)"); if (*objname == '&') { - f_print(fout, "%s.%s_val, (u_int *)%s.%s_len", + fprintf(fout, "%s.%s_val, (u_int *)%s.%s_len", objname, name, objname, name); } else { - f_print(fout, "&%s->%s_val, (u_int *)&%s->%s_len", + fprintf(fout, "&%s->%s_val, (u_int *)&%s->%s_len", objname, name, objname, name); } } @@ -347,9 +347,9 @@ emit_union(def) char *format = "&objp->%s_u.%s"; print_stat(1, &def->def.un.enum_decl); - f_print(fout, "\tswitch (objp->%s) {\n", def->def.un.enum_decl.name); + fprintf(fout, "\tswitch (objp->%s) {\n", def->def.un.enum_decl.name); for (cl = def->def.un.cases; cl != NULL; cl = cl->next) { - f_print(fout, "\tcase %s:\n", cl->case_name); + fprintf(fout, "\tcase %s:\n", cl->case_name); if (cl->contflag == 1) /* a continued case statement */ continue; cs = &cl->case_decl; @@ -357,43 +357,43 @@ emit_union(def) object = alloc(strlen(def->def_name) + strlen(format) + strlen(cs->name) + 1); if (isvectordef(cs->type, cs->rel)) { - s_print(object, vecformat, def->def_name, + sprintf(object, vecformat, def->def_name, cs->name); } else { - s_print(object, format, def->def_name, + sprintf(object, format, def->def_name, cs->name); } print_ifstat(2, cs->prefix, cs->type, cs->rel, cs->array_max, object, cs->name); free(object); } - f_print(fout, "\t\tbreak;\n"); + fprintf(fout, "\t\tbreak;\n"); } dflt = def->def.un.default_decl; if (dflt != NULL) { if (!streq(dflt->type, "void")) { - f_print(fout, "\tdefault:\n"); + fprintf(fout, "\tdefault:\n"); object = alloc(strlen(def->def_name) + strlen(format) + strlen(dflt->name) + 1); if (isvectordef(dflt->type, dflt->rel)) { - s_print(object, vecformat, def->def_name, + sprintf(object, vecformat, def->def_name, dflt->name); } else { - s_print(object, format, def->def_name, + sprintf(object, format, def->def_name, dflt->name); } print_ifstat(2, dflt->prefix, dflt->type, dflt->rel, dflt->array_max, object, dflt->name); free(object); - f_print(fout, "\t\tbreak;\n"); + fprintf(fout, "\t\tbreak;\n"); } } else { - f_print(fout, "\tdefault:\n"); - f_print(fout, "\t\treturn (FALSE);\n"); + fprintf(fout, "\tdefault:\n"); + fprintf(fout, "\t\treturn (FALSE);\n"); } - f_print(fout, "\t}\n"); + fprintf(fout, "\t}\n"); } static void @@ -415,7 +415,7 @@ emit_struct(def) } for (dl = def->def.st.decls; dl != NULL; dl = dl->next) if (dl->decl.rel == REL_VECTOR) { - f_print(fout, "\tint i;\n"); + fprintf(fout, "\tint i;\n"); break; } size = 0; @@ -449,9 +449,9 @@ emit_struct(def) flag = PUT; for (j = 0; j < 2; j++) { if (flag == PUT) - f_print(fout, "\n\tif (xdrs->x_op == XDR_ENCODE) {\n"); + fprintf(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"); + fprintf(fout, "\t\treturn (TRUE);\n\t} else if (xdrs->x_op == XDR_DECODE) {\n"); i = 0; size = 0; @@ -477,9 +477,14 @@ emit_struct(def) plus = "+"; if (ptr->length != 1) - s_print(ptemp, " %s %s * %d", plus, dl->decl.array_max, ptr->length); + snprintf(ptemp, sizeof ptemp, + " %s %s * %d", plus, + dl->decl.array_max, + ptr->length); else - s_print(ptemp, " %s %s ", plus, dl->decl.array_max); + snprintf(ptemp, sizeof ptemp, + " %s %s ", plus, + dl->decl.array_max); /* now concatenate to sizestr !!!! */ if (sizestr == NULL) @@ -487,7 +492,7 @@ emit_struct(def) else { sizestr = (char *)realloc(sizestr, strlen(sizestr) + strlen(ptemp) + 1); if (sizestr == NULL) { - f_print(stderr, "Fatal error : no memory\n"); + fprintf(stderr, "Fatal error : no memory\n"); crash(); } sizestr = strcat(sizestr, ptemp); /* build up length of @@ -509,19 +514,19 @@ emit_struct(def) /* were already looking at a * xdr_inlineable structure */ if (sizestr == NULL) - f_print(fout, "\t\tbuf = (int32_t *)XDR_INLINE(xdrs, %d * BYTES_PER_XDR_UNIT);", + fprintf(fout, "\t\tbuf = (int32_t *)XDR_INLINE(xdrs, %d * BYTES_PER_XDR_UNIT);", size); else if (size == 0) - f_print(fout, + fprintf(fout, "\t\tbuf = (int32_t *)XDR_INLINE(xdrs, %s * BYTES_PER_XDR_UNIT);", sizestr); else - f_print(fout, + fprintf(fout, "\t\tbuf = (int32_t *)XDR_INLINE(xdrs, (%d + %s)* BYTES_PER_XDR_UNIT);", size, sizestr); - f_print(fout, "\n\t\tif (buf == NULL) {\n"); + fprintf(fout, "\n\t\tif (buf == NULL) {\n"); psav = cur; while (cur != dl) { @@ -529,7 +534,7 @@ emit_struct(def) cur = cur->next; } - f_print(fout, "\t\t} else {\n"); + fprintf(fout, "\t\t} else {\n"); cur = psav; while (cur != dl) { @@ -537,7 +542,7 @@ emit_struct(def) cur = cur->next; } - f_print(fout, "\t\t}\n"); + fprintf(fout, "\t\t}\n"); } } size = 0; @@ -559,26 +564,26 @@ emit_struct(def) /* were already looking at a xdr_inlineable * structure */ if (sizestr == NULL) - f_print(fout, "\t\tbuf = (int32_t *)XDR_INLINE(xdrs, %d * BYTES_PER_XDR_UNIT);", + fprintf(fout, "\t\tbuf = (int32_t *)XDR_INLINE(xdrs, %d * BYTES_PER_XDR_UNIT);", size); else if (size == 0) - f_print(fout, + fprintf(fout, "\t\tbuf = (int32_t *)XDR_INLINE(xdrs, %s * BYTES_PER_XDR_UNIT);", sizestr); else - f_print(fout, + fprintf(fout, "\t\tbuf = (int32_t *)XDR_INLINE(xdrs, (%d + %s)* BYTES_PER_XDR_UNIT);", size, sizestr); - f_print(fout, "\n\t\tif (buf == NULL) {\n"); + fprintf(fout, "\n\t\tif (buf == NULL) {\n"); psav = cur; while (cur != NULL) { print_stat(3, &cur->decl); cur = cur->next; } - f_print(fout, "\t\t} else {\n"); + fprintf(fout, "\t\t} else {\n"); cur = psav; while (cur != dl) { @@ -586,13 +591,13 @@ emit_struct(def) cur = cur->next; } - f_print(fout, "\t\t}\n"); + fprintf(fout, "\t\t}\n"); } } flag = GET; } - f_print(fout, "\t\treturn (TRUE);\n\t}\n\n"); + fprintf(fout, "\t\treturn (TRUE);\n\t}\n\n"); /* now take care of XDR_FREE case */ @@ -624,9 +629,9 @@ print_stat(indent, dec) char name[256]; if (isvectordef(type, rel)) { - s_print(name, "objp->%s", dec->name); + snprintf(name, sizeof name, "objp->%s", dec->name); } else { - s_print(name, "&objp->%s", dec->name); + snprintf(name, sizeof name, "&objp->%s", dec->name); } print_ifstat(indent, prefix, type, rel, amax, name, dec->name); } @@ -642,15 +647,15 @@ emit_inline(decl, flag) switch (decl->rel) { case REL_ALIAS: - f_print(fout, "\t"); + fprintf(fout, "\t"); emit_single_in_line(decl, flag, REL_ALIAS); break; case REL_VECTOR: - f_print(fout, "\t\t\t{\n\t\t\t\t%s *genp;\n\n", decl->type); - f_print(fout, "\t\t\t\tfor (i = 0, genp = objp->%s;\n\t\t\t\t i < %s; i++) {\n\t\t\t", + fprintf(fout, "\t\t\t{\n\t\t\t\t%s *genp;\n\n", decl->type); + fprintf(fout, "\t\t\t\tfor (i = 0, genp = objp->%s;\n\t\t\t\t i < %s; i++) {\n\t\t\t", decl->name, decl->array_max); emit_single_in_line(decl, flag, REL_VECTOR); - f_print(fout, "\t\t\t\t}\n\t\t\t}\n"); + fprintf(fout, "\t\t\t\t}\n\t\t\t}\n"); } } @@ -665,12 +670,12 @@ emit_single_in_line(decl, flag, rel) int freed = 0; if (flag == PUT) - f_print(fout, "\t\tIXDR_PUT_"); + fprintf(fout, "\t\tIXDR_PUT_"); else if (rel == REL_ALIAS) - f_print(fout, "\t\tobjp->%s = IXDR_GET_", decl->name); + fprintf(fout, "\t\tobjp->%s = IXDR_GET_", decl->name); else - f_print(fout, "\t\t*genp++ = IXDR_GET_"); + fprintf(fout, "\t\t*genp++ = IXDR_GET_"); upp_case = upcase(decl->type); @@ -687,12 +692,12 @@ emit_single_in_line(decl, flag, rel) } if (flag == PUT) if (rel == REL_ALIAS) - f_print(fout, "%s(buf, objp->%s);\n", upp_case, decl->name); + fprintf(fout, "%s(buf, objp->%s);\n", upp_case, decl->name); else - f_print(fout, "%s(buf, *genp++);\n", upp_case); + fprintf(fout, "%s(buf, *genp++);\n", upp_case); else - f_print(fout, "%s(buf);\n", upp_case); + fprintf(fout, "%s(buf);\n", upp_case); if (!freed) free(upp_case); } @@ -705,7 +710,7 @@ upcase(str) ptr = (char *) malloc(strlen(str)+1); if (ptr == (char *) NULL) { - f_print(stderr, "malloc failed\n"); + fprintf(stderr, "malloc failed\n"); exit(1); } diff --git a/usr.bin/rpcgen/rpc_hout.c b/usr.bin/rpcgen/rpc_hout.c index 39760647361..ec293cc1036 100644 --- a/usr.bin/rpcgen/rpc_hout.c +++ b/usr.bin/rpcgen/rpc_hout.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rpc_hout.c,v 1.10 2002/02/16 21:27:51 millert Exp $ */ +/* $OpenBSD: rpc_hout.c,v 1.11 2002/06/01 01:40:38 deraadt Exp $ */ /* $NetBSD: rpc_hout.c,v 1.4 1995/06/11 21:49:55 pk Exp $ */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for @@ -71,7 +71,7 @@ print_datadef(def) return; if (def->def_kind != DEF_CONST) - f_print(fout, "\n"); + fprintf(fout, "\n"); switch (def->def_kind) { case DEF_STRUCT: pstructdef(def); @@ -106,7 +106,7 @@ print_funcdef(def) { switch (def->def_kind) { case DEF_PROGRAM: - f_print(fout, "\n"); + fprintf(fout, "\n"); pprogramdef(def); break; } @@ -118,15 +118,15 @@ pxdrfuncdecl(name, pointerp) int pointerp; { - f_print(fout,"#ifdef __cplusplus\n"); - f_print(fout, "extern \"C\" bool_t xdr_%s(XDR *, %s%s);\n", + fprintf(fout,"#ifdef __cplusplus\n"); + fprintf(fout, "extern \"C\" bool_t xdr_%s(XDR *, %s%s);\n", name, name, pointerp ? ("*") : ""); - f_print(fout,"#elif defined(__STDC__)\n"); - f_print(fout, "extern bool_t xdr_%s(XDR *, %s%s);\n", + fprintf(fout,"#elif defined(__STDC__)\n"); + fprintf(fout, "extern bool_t xdr_%s(XDR *, %s%s);\n", name, name, pointerp ? ("*") : ""); - f_print(fout,"#else /* Old Style C */\n"); - f_print(fout, "bool_t xdr_%s();\n", name); - f_print(fout,"#endif /* Old Style C */\n\n"); + fprintf(fout,"#else /* Old Style C */\n"); + fprintf(fout, "bool_t xdr_%s();\n", name); + fprintf(fout,"#endif /* Old Style C */\n\n"); } @@ -156,15 +156,15 @@ pargdef(def) continue; /* old style or single args */ } name = plist->args.argname; - f_print(fout, "struct %s {\n", name); + fprintf(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); + fprintf(fout, "};\n"); + fprintf(fout, "typedef struct %s %s;\n", name, name); pxdrfuncdecl(name, NULL); - f_print(fout, "\n"); + fprintf(fout, "\n"); } } } @@ -176,11 +176,11 @@ pstructdef(def) char *name = def->def_name; decl_list *l; - f_print(fout, "struct %s {\n", name); + fprintf(fout, "struct %s {\n", name); 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); + fprintf(fout, "};\n"); + fprintf(fout, "typedef struct %s %s;\n", name, name); } static void @@ -191,14 +191,14 @@ puniondef(def) char *name = def->def_name; declaration *decl; - f_print(fout, "struct %s {\n", name); + fprintf(fout, "struct %s {\n", name); decl = &def->def.un.enum_decl; if (streq(decl->type, "bool")) { - f_print(fout, "\tbool_t %s;\n", decl->name); + fprintf(fout, "\tbool_t %s;\n", decl->name); } else { - f_print(fout, "\t%s %s;\n", decl->type, decl->name); + fprintf(fout, "\t%s %s;\n", decl->type, decl->name); } - f_print(fout, "\tunion {\n"); + fprintf(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"); @@ -207,9 +207,9 @@ puniondef(def) if (decl && !streq(decl->type, "void")) { pdeclaration(name, decl, 2, ";\n"); } - f_print(fout, "\t} %s_u;\n", name); - f_print(fout, "};\n"); - f_print(fout, "typedef struct %s %s;\n", name, name); + fprintf(fout, "\t} %s_u;\n", name); + fprintf(fout, "};\n"); + fprintf(fout, "typedef struct %s %s;\n", name, name); } static void @@ -217,7 +217,7 @@ pdefine(name, num) char *name; char *num; { - f_print(fout, "#define %s %s\n", name, num); + fprintf(fout, "#define %s %s\n", name, num); } static void @@ -225,7 +225,7 @@ puldefine(name, num) char *name; char *num; { - f_print(fout, "#define %s ((u_long)%s)\n", name, num); + fprintf(fout, "#define %s ((u_long)%s)\n", name, num); } static int @@ -263,9 +263,9 @@ pprogramdef(def) puldefine(def->def_name, def->def.pr.prog_num); for (vers = def->def.pr.versions; vers != NULL; vers = vers->next) { if (tblflag) { - f_print(fout, "extern struct rpcgen_table %s_%s_table[];\n", + fprintf(fout, "extern struct rpcgen_table %s_%s_table[];\n", locase(def->def_name), vers->vers_num); - f_print(fout, "extern %s_%s_nproc;\n", + fprintf(fout, "extern %s_%s_nproc;\n", locase(def->def_name), vers->vers_num); } puldefine(vers->vers_name, vers->vers_num); @@ -276,26 +276,26 @@ pprogramdef(def) */ for(i=0; i<3; i++) { if (i==0) { - f_print(fout,"\n#ifdef __cplusplus\n"); + fprintf(fout,"\n#ifdef __cplusplus\n"); ext = "extern \"C\" "; } else if (i==1) { - f_print(fout,"\n#elif defined(__STDC__)\n"); + fprintf(fout,"\n#elif defined(__STDC__)\n"); ext = "extern "; } else { - f_print(fout,"\n#else /* Old Style C */\n"); + fprintf(fout,"\n#else /* Old Style C */\n"); ext = "extern "; } for (proc = vers->procs; proc != NULL; proc = proc->next) { if (!define_printed(proc, def->def.pr.versions)) puldefine(proc->proc_name, proc->proc_num); - f_print(fout,"%s",ext); + fprintf(fout,"%s",ext); pprocdef(proc, vers, "CLIENT *", 0,i); - f_print(fout,"%s",ext); + fprintf(fout,"%s",ext); pprocdef(proc, vers, "struct svc_req *", 1,i); } } - f_print(fout,"#endif /* Old Style C */\n"); + fprintf(fout,"#endif /* Old Style C */\n"); } } @@ -309,7 +309,7 @@ pprocdef(proc, vp, addargtype, server_p,mode) { ptype(proc->res_prefix, proc->res_type, 1); - f_print(fout, "* "); + fprintf(fout, "* "); if (server_p) pvname_svc(proc->proc_name, vp->vers_num); else @@ -321,7 +321,7 @@ pprocdef(proc, vp, addargtype, server_p,mode) if (mode == 0 || mode == 1) parglist(proc, addargtype); else - f_print(fout, "();\n"); + fprintf(fout, "();\n"); } /* print out argument list of procedure */ @@ -332,7 +332,7 @@ parglist(proc, addargtype) { decl_list *dl; - f_print(fout,"("); + fprintf(fout,"("); if (proc->arg_num < 2 && newstyle && streq(proc->args.decls->decl.type, "void")) { @@ -341,11 +341,11 @@ parglist(proc, addargtype) for (dl = proc->args.decls; dl != NULL; dl = dl->next) { ptype(dl->decl.prefix, dl->decl.type, 1); if (!newstyle) - f_print(fout, "*"); /* old style passes by reference */ - f_print(fout, ", "); + fprintf(fout, "*"); /* old style passes by reference */ + fprintf(fout, ", "); } } - f_print(fout, "%s);\n", addargtype); + fprintf(fout, "%s);\n", addargtype); } static void @@ -357,27 +357,27 @@ penumdef(def) char *last = NULL; int count = 0; - f_print(fout, "enum %s {\n", name); + fprintf(fout, "enum %s {\n", name); for (l = def->def.en.vals; l != NULL; l = l->next) { - f_print(fout, "\t%s", l->name); + fprintf(fout, "\t%s", l->name); if (l->assignment) { - f_print(fout, " = %s", l->assignment); + fprintf(fout, " = %s", l->assignment); last = l->assignment; count = 1; } else { if (last == NULL) { - f_print(fout, " = %d", count++); + fprintf(fout, " = %d", count++); } else { - f_print(fout, " = %s + %d", last, count++); + fprintf(fout, " = %s + %d", last, count++); } } if (l->next) - f_print(fout, ",\n"); + fprintf(fout, ",\n"); else - f_print(fout, "\n"); + fprintf(fout, "\n"); } - f_print(fout, "};\n"); - f_print(fout, "typedef enum %s %s;\n", name, name); + fprintf(fout, "};\n"); + fprintf(fout, "typedef enum %s %s;\n", name, name); } static void @@ -399,30 +399,30 @@ ptypedef(def) old = "bool_t"; } if (undefined2(old, name) && def->def.ty.old_prefix) { - s_print(prefix, "%s ", def->def.ty.old_prefix); + snprintf(prefix, sizeof prefix, "%s ", def->def.ty.old_prefix); } else { prefix[0] = 0; } - f_print(fout, "typedef "); + fprintf(fout, "typedef "); switch (rel) { case REL_ARRAY: - f_print(fout, "struct {\n"); - f_print(fout, "\tu_int %s_len;\n", name); - f_print(fout, "\t%s%s *%s_val;\n", prefix, old, name); - f_print(fout, "} %s", name); + fprintf(fout, "struct {\n"); + fprintf(fout, "\tu_int %s_len;\n", name); + fprintf(fout, "\t%s%s *%s_val;\n", prefix, old, name); + fprintf(fout, "} %s", name); break; case REL_POINTER: - f_print(fout, "%s%s *%s", prefix, old, name); + fprintf(fout, "%s%s *%s", prefix, old, name); break; case REL_VECTOR: - f_print(fout, "%s%s %s[%s]", prefix, old, name, + fprintf(fout, "%s%s %s[%s]", prefix, old, name, def->def.ty.array_max); break; case REL_ALIAS: - f_print(fout, "%s%s %s", prefix, old, name); + fprintf(fout, "%s%s %s", prefix, old, name); break; } - f_print(fout, ";\n"); + fprintf(fout, ";\n"); } } @@ -441,10 +441,10 @@ pdeclaration(name, dec, tab, separator) return; tabify(fout, tab); if (streq(dec->type, name) && !dec->prefix) { - f_print(fout, "struct "); + fprintf(fout, "struct "); } if (streq(dec->type, "string")) { - f_print(fout, "char *%s", dec->name); + fprintf(fout, "char *%s", dec->name); } else { prefix = ""; if (streq(dec->type, "bool")) { @@ -453,34 +453,34 @@ pdeclaration(name, dec, tab, separator) type = "char"; } else { if (dec->prefix) { - s_print(buf, "%s ", dec->prefix); + snprintf(buf, sizeof buf, "%s ", dec->prefix); prefix = buf; } type = dec->type; } switch (dec->rel) { case REL_ALIAS: - f_print(fout, "%s%s %s", prefix, type, dec->name); + fprintf(fout, "%s%s %s", prefix, type, dec->name); break; case REL_VECTOR: - f_print(fout, "%s%s %s[%s]", prefix, type, dec->name, + fprintf(fout, "%s%s %s[%s]", prefix, type, dec->name, dec->array_max); break; case REL_POINTER: - f_print(fout, "%s%s *%s", prefix, type, dec->name); + fprintf(fout, "%s%s *%s", prefix, type, dec->name); break; case REL_ARRAY: - f_print(fout, "struct {\n"); + fprintf(fout, "struct {\n"); tabify(fout, tab); - f_print(fout, "\tu_int %s_len;\n", dec->name); + fprintf(fout, "\tu_int %s_len;\n", dec->name); tabify(fout, tab); - f_print(fout, "\t%s%s *%s_val;\n", prefix, type, dec->name); + fprintf(fout, "\t%s%s *%s_val;\n", prefix, type, dec->name); tabify(fout, tab); - f_print(fout, "} %s", dec->name); + fprintf(fout, "} %s", dec->name); break; } } - f_print(fout, separator); + fprintf(fout, separator); } static int diff --git a/usr.bin/rpcgen/rpc_main.c b/usr.bin/rpcgen/rpc_main.c index 4cd435f2f75..626eb7eb3cd 100644 --- a/usr.bin/rpcgen/rpc_main.c +++ b/usr.bin/rpcgen/rpc_main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rpc_main.c,v 1.13 2002/05/27 03:14:22 deraadt Exp $ */ +/* $OpenBSD: rpc_main.c,v 1.14 2002/06/01 01:40:38 deraadt Exp $ */ /* $NetBSD: rpc_main.c,v 1.9 1996/02/19 11:12:43 pk Exp $ */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for @@ -32,7 +32,7 @@ #ifndef lint static char sccsid[] = "@(#)rpc_main.c 1.30 89/03/30 (C) 1987 SMI"; -static char cvsid[] = "$OpenBSD: rpc_main.c,v 1.13 2002/05/27 03:14:22 deraadt Exp $"; +static char cvsid[] = "$OpenBSD: rpc_main.c,v 1.14 2002/06/01 01:40:38 deraadt Exp $"; #endif /* @@ -258,13 +258,13 @@ open_output(infile, outfile) return; } if (infile != NULL && streq(outfile, infile)) { - f_print(stderr, "%s: output would overwrite %s\n", cmdname, + fprintf(stderr, "%s: output would overwrite %s\n", cmdname, infile); crash(); } fout = fopen(outfile, "w"); if (fout == NULL) { - f_print(stderr, "%s: unable to open ", cmdname); + fprintf(stderr, "%s: unable to open ", cmdname); perror(outfile); crash(); } @@ -275,10 +275,10 @@ open_output(infile, outfile) static add_warning() { - f_print(fout, "/*\n"); - f_print(fout, " * Please do not edit this file.\n"); - f_print(fout, " * It was generated using rpcgen.\n"); - f_print(fout, " */\n\n"); + fprintf(fout, "/*\n"); + fprintf(fout, " * Please do not edit this file.\n"); + fprintf(fout, " * It was generated using rpcgen.\n"); + fprintf(fout, " */\n\n"); } /* clear list of arguments */ @@ -355,7 +355,7 @@ open_input(infile, define) fin = fopen(cppfile, "r"); if (fin == NULL) { - f_print(stderr, "%s: ", cmdname); + fprintf(stderr, "%s: ", cmdname); perror(cppfile); crash(); } @@ -389,7 +389,7 @@ open_input(infile, define) fin = fdopen(pd[0], "r"); #endif if (fin == NULL) { - f_print(stderr, "%s: ", cmdname); + fprintf(stderr, "%s: ", cmdname); perror(infilename); crash(); } @@ -426,7 +426,7 @@ check_nettype(name, list_to_check) if (strcmp(name, list_to_check[i]) == 0) return 1; } - f_print(stderr, "illegal nettype :\'%s\'\n", name); + fprintf(stderr, "illegal nettype :\'%s\'\n", name); return 0; } @@ -452,11 +452,11 @@ c_output(infile, define, extend, outfile) open_output(infile, outfilename); add_warning(); if (infile && (include = extendfile(infile, ".h"))) { - f_print(fout, "#include \"%s\"\n", include); + fprintf(fout, "#include \"%s\"\n", include); free(include); /* .h file already contains rpc/rpc.h */ } else - f_print(fout, "#include <rpc/rpc.h>\n"); + fprintf(fout, "#include <rpc/rpc.h>\n"); tell = ftell(fout); while (def = get_definition()) { emit(def); @@ -536,11 +536,11 @@ h_output(infile, define, extend, outfile) add_warning(); guard = generate_guard(outfilename ? outfilename : infile); - f_print(fout, "#ifndef _%s\n#define _%s\n\n", guard, + fprintf(fout, "#ifndef _%s\n#define _%s\n\n", guard, guard); - f_print(fout, "#define RPCGEN_VERSION\t%s\n\n", RPCGEN_VERSION); - f_print(fout, "#include <rpc/rpc.h>\n\n"); + fprintf(fout, "#define RPCGEN_VERSION\t%s\n\n", RPCGEN_VERSION); + fprintf(fout, "#include <rpc/rpc.h>\n\n"); tell = ftell(fout); /* print data definitions */ @@ -558,9 +558,9 @@ h_output(infile, define, extend, outfile) if (extend && tell == ftell(fout)) { (void) unlink(outfilename); } else if (tblflag) { - f_print(fout, rpcgen_table_dcl); + fprintf(fout, rpcgen_table_dcl); } - f_print(fout, "\n#endif /* !_%s */\n", guard); + fprintf(fout, "\n#endif /* !_%s */\n", guard); } /* @@ -587,63 +587,63 @@ s_output(argc, argv, infile, define, extend, outfile, nomain, netflag) open_output(infile, outfilename); add_warning(); if (infile && (include = extendfile(infile, ".h"))) { - f_print(fout, "#include \"%s\"\n", include); + fprintf(fout, "#include \"%s\"\n", include); free(include); } else - f_print(fout, "#include <rpc/rpc.h>\n"); + fprintf(fout, "#include <rpc/rpc.h>\n"); - f_print(fout, "#include <stdio.h>\n"); - f_print(fout, "#include <stdlib.h>/* getenv, exit */\n"); + fprintf(fout, "#include <stdio.h>\n"); + fprintf(fout, "#include <stdlib.h>/* getenv, exit */\n"); if (Cflag) { - f_print(fout, + fprintf(fout, "#include <rpc/pmap_clnt.h> /* for pmap_unset */\n"); - f_print(fout, "#include <string.h> /* strcmp */ \n"); + fprintf(fout, "#include <string.h> /* strcmp */ \n"); } - f_print(fout, "#include <netdb.h>\n"); /* evas */ + fprintf(fout, "#include <netdb.h>\n"); /* evas */ if (strcmp(svcclosetime, "-1") == 0) indefinitewait = 1; else if (strcmp(svcclosetime, "0") == 0) exitnow = 1; else if (inetdflag || pmflag) { - f_print(fout, "#include <signal.h>\n"); + fprintf(fout, "#include <signal.h>\n"); timerflag = 1; } if (!tirpcflag && inetdflag) - f_print(fout, "#include <sys/ttycom.h>/* TIOCNOTTY */\n"); + fprintf(fout, "#include <sys/ttycom.h>/* TIOCNOTTY */\n"); if (Cflag && (inetdflag || pmflag)) { - f_print(fout, "#ifdef __cplusplus\n"); - f_print(fout, "#include <sysent.h> /* getdtablesize, open */\n"); - f_print(fout, "#endif /* __cplusplus */\n"); + fprintf(fout, "#ifdef __cplusplus\n"); + fprintf(fout, "#include <sysent.h> /* getdtablesize, open */\n"); + fprintf(fout, "#endif /* __cplusplus */\n"); if (tirpcflag) - f_print(fout, "#include <unistd.h> /* setsid */\n"); + fprintf(fout, "#include <unistd.h> /* setsid */\n"); } if (tirpcflag) - f_print(fout, "#include <sys/types.h>\n"); + fprintf(fout, "#include <sys/types.h>\n"); - f_print(fout, "#include <memory.h>\n"); + fprintf(fout, "#include <memory.h>\n"); if (tirpcflag) - f_print(fout, "#include <stropts.h>\n"); + fprintf(fout, "#include <stropts.h>\n"); if (inetdflag || !tirpcflag) { - f_print(fout, "#include <sys/socket.h>\n"); - f_print(fout, "#include <netinet/in.h>\n"); + fprintf(fout, "#include <sys/socket.h>\n"); + fprintf(fout, "#include <netinet/in.h>\n"); } if ((netflag || pmflag) && tirpcflag) { - f_print(fout, "#include <netconfig.h>\n"); + fprintf(fout, "#include <netconfig.h>\n"); } if ( /* timerflag && */ tirpcflag) - f_print(fout, "#include <sys/resource.h> /* rlimit */\n"); + fprintf(fout, "#include <sys/resource.h> /* rlimit */\n"); if (logflag || inetdflag || pmflag) { - f_print(fout, "#include <syslog.h>\n"); - f_print(fout, "#include <errno.h>\n"); + fprintf(fout, "#include <syslog.h>\n"); + fprintf(fout, "#include <errno.h>\n"); } /* for ANSI-C */ - f_print(fout, "\n#ifdef __STDC__\n#define SIG_PF void(*)(int)\n#endif\n"); + fprintf(fout, "\n#ifdef __STDC__\n#define SIG_PF void(*)(int)\n#endif\n"); - f_print(fout, "\n#ifdef DEBUG\n#define RPC_SVC_FG\n#endif\n"); + fprintf(fout, "\n#ifdef DEBUG\n#define RPC_SVC_FG\n#endif\n"); if (timerflag) - f_print(fout, "\n#define _RPCSVC_CLOSEDOWN %s\n", svcclosetime); + fprintf(fout, "\n#define _RPCSVC_CLOSEDOWN %s\n", svcclosetime); while (def = get_definition()) { foundprogram |= (def->def_kind == DEF_PROGRAM); } @@ -652,7 +652,7 @@ s_output(argc, argv, infile, define, extend, outfile, nomain, netflag) return; } if (callerflag) /* EVAS */ - f_print(fout, "\nstatic SVCXPRT *caller;\n"); /* EVAS */ + fprintf(fout, "\nstatic SVCXPRT *caller;\n"); /* EVAS */ write_most(infile, netflag, nomain); if (!nomain) { if (!do_registers(argc, argv)) { @@ -684,12 +684,12 @@ l_output(infile, define, extend, outfile) open_output(infile, outfilename); add_warning(); if (Cflag) - f_print(fout, "#include <memory.h> /* for memset */\n"); + fprintf(fout, "#include <memory.h> /* for memset */\n"); if (infile && (include = extendfile(infile, ".h"))) { - f_print(fout, "#include \"%s\"\n", include); + fprintf(fout, "#include \"%s\"\n", include); free(include); } else - f_print(fout, "#include <rpc/rpc.h>\n"); + fprintf(fout, "#include <rpc/rpc.h>\n"); while (def = get_definition()) foundprogram |= (def->def_kind == DEF_PROGRAM); @@ -750,10 +750,10 @@ svc_output(infile, define, extend, outfile) add_sample_msg(); if (infile && (include = extendfile(infile, ".h"))) { - f_print(fout, "#include \"%s\"\n", include); + fprintf(fout, "#include \"%s\"\n", include); free(include); } else - f_print(fout, "#include <rpc/rpc.h>\n"); + fprintf(fout, "#include <rpc/rpc.h>\n"); tell = ftell(fout); while (def = get_definition()) @@ -789,10 +789,10 @@ clnt_output(infile, define, extend, outfile) open_output(infile, outfilename); add_sample_msg(); if (infile && (include = extendfile(infile, ".h"))) { - f_print(fout, "#include \"%s\"\n", include); + fprintf(fout, "#include \"%s\"\n", include); free(include); } else - f_print(fout, "#include <rpc/rpc.h>\n"); + fprintf(fout, "#include <rpc/rpc.h>\n"); tell = ftell(fout); while (def = get_definition()) has_program += write_sample_clnt(def); @@ -848,7 +848,7 @@ addarg(cp) char *cp; { if (argcount >= ARGLISTLEN) { - f_print(stderr, "rpcgen: too many defines\n"); + fprintf(stderr, "rpcgen: too many defines\n"); crash(); /* NOTREACHED */ } @@ -862,7 +862,7 @@ putarg(where, cp) int where; { if (where >= ARGLISTLEN) { - f_print(stderr, "rpcgen: arglist coding error\n"); + fprintf(stderr, "rpcgen: arglist coding error\n"); crash(); /* NOTREACHED */ } @@ -892,7 +892,7 @@ checkfiles(infile, outfile) if (stat(outfile, &buf) < 0) return; /* file does not exist */ else { - f_print(stderr, + fprintf(stderr, "file '%s' already exists and may be overwritten\n", outfile); crash(); @@ -932,7 +932,7 @@ parseargs(argc, argv, cmd) for (i = 1; i < argc; i++) { if (argv[i][0] != '-') { if (cmd->infile) { - f_print(stderr, + fprintf(stderr, "Cannot specify more than one input file!\n"); return (0); } @@ -1065,7 +1065,7 @@ parseargs(argc, argv, cmd) * always TRUE */ if (inetdflag && cmd->nflag) { /* netid not allowed with inetdflag */ - f_print(stderr, "Cannot use netid flag with inetd flag!\n"); + fprintf(stderr, "Cannot use netid flag with inetd flag!\n"); return (0); } } else { @@ -1074,13 +1074,13 @@ parseargs(argc, argv, cmd) inetdflag = 1; /* inetdflag is TRUE by default */ if (cmd->nflag) { /* netid needs TIRPC */ - f_print(stderr, "Cannot use netid flag without TIRPC!\n"); + fprintf(stderr, "Cannot use netid flag without TIRPC!\n"); return (0); } } if (newstyle && (tblflag || cmd->tflag)) { - f_print(stderr, "Cannot use table flags with newstyle!\n"); + fprintf(stderr, "Cannot use table flags with newstyle!\n"); return (0); } /* check no conflicts with file generation flags */ @@ -1091,7 +1091,7 @@ parseargs(argc, argv, cmd) if (cmd->outfile != NULL || cmd->infile == NULL) return (0); } else if (nflags > 1) { - f_print(stderr, "Cannot have more than one file generation flag!\n"); + fprintf(stderr, "Cannot have more than one file generation flag!\n"); return (0); } return (1); @@ -1100,10 +1100,10 @@ parseargs(argc, argv, cmd) static usage() { - f_print(stderr, "usage: %s [-abACILNT] [-Dname[=value]] [-i lines] " + fprintf(stderr, "usage: %s [-abACILNT] [-Dname[=value]] [-i lines] " "[-K seconds] infile\n", cmdname); - f_print(stderr, " %s [-c | -h | -l | -m | -t | -Sc | -Ss] " + fprintf(stderr, " %s [-c | -h | -l | -m | -t | -Sc | -Ss] " "[-o outfile] [infile]\n", cmdname); - f_print(stderr, " %s [-s nettype]* [-o outfile] [infile]\n", cmdname); + fprintf(stderr, " %s [-s nettype]* [-o outfile] [infile]\n", cmdname); exit(1); } diff --git a/usr.bin/rpcgen/rpc_parse.c b/usr.bin/rpcgen/rpc_parse.c index 84c2882dc80..8ce08bfb0de 100644 --- a/usr.bin/rpcgen/rpc_parse.c +++ b/usr.bin/rpcgen/rpc_parse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rpc_parse.c,v 1.9 2002/02/16 21:27:51 millert Exp $ */ +/* $OpenBSD: rpc_parse.c,v 1.10 2002/06/01 01:40:38 deraadt Exp $ */ /* $NetBSD: rpc_parse.c,v 1.5 1995/08/29 23:05:55 cgd Exp $ */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for @@ -392,7 +392,7 @@ char *name; for( i = 0; reserved_words[i] != NULL; i++ ) { if( strcmp( name, reserved_words[i] ) == 0 ) { - sprintf(tmp, + snprintf(tmp, sizeof tmp, "illegal (reserved) name :\'%s\' in type definition", name ); error(tmp); } @@ -400,7 +400,7 @@ char *name; if( new_type ) { for( i = 0; reserved_types[i] != NULL; i++ ) { if( strcmp( name, reserved_types[i] ) == 0 ) { - sprintf(tmp, + snprintf(tmp, sizeof tmp, "illegal (reserved) name :\'%s\' in type definition", name ); error(tmp); } @@ -499,9 +499,9 @@ get_prog_declaration(dec, dkind, num) get_type(&dec->prefix, &dec->type, dkind); dec->rel = REL_ALIAS; if (peekscan(TOK_IDENT, &tok)) /* optional name of argument */ - strcpy(name, tok.str); + strlcpy(name, tok.str, sizeof name); else - sprintf(name, "%s%d", ARGNAME, num); /* default name of argument */ + snprintf(name, sizeof name, "%s%d", ARGNAME, num); /* default name of argument */ dec->name = (char *)strdup(name); diff --git a/usr.bin/rpcgen/rpc_sample.c b/usr.bin/rpcgen/rpc_sample.c index 50d31758dd6..b78114728ca 100644 --- a/usr.bin/rpcgen/rpc_sample.c +++ b/usr.bin/rpcgen/rpc_sample.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rpc_sample.c,v 1.11 2002/02/16 21:27:51 millert Exp $ */ +/* $OpenBSD: rpc_sample.c,v 1.12 2002/06/01 01:40:38 deraadt Exp $ */ /* $NetBSD: rpc_sample.c,v 1.2 1995/06/11 21:50:01 pk Exp $ */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for @@ -90,78 +90,78 @@ write_sample_client(program_name, vp) int i; decl_list *l; - f_print(fout, "\n\nvoid\n"); + fprintf(fout, "\n\nvoid\n"); pvname(program_name, vp->vers_num); if (Cflag) - f_print(fout,"(char *host)\n{\n"); + fprintf(fout,"(char *host)\n{\n"); else - f_print(fout, "(host)\nchar *host;\n{\n"); - f_print(fout, "\tCLIENT *clnt;\n"); + fprintf(fout, "(host)\nchar *host;\n{\n"); + fprintf(fout, "\tCLIENT *clnt;\n"); i = 0; for (proc = vp->procs; proc != NULL; proc = proc->next) { - f_print(fout, "\t"); + fprintf(fout, "\t"); ptype(proc->res_prefix, proc->res_type, 1); - f_print(fout, " *result_%d;\n",++i); + fprintf(fout, " *result_%d;\n",++i); /* print out declarations for arguments */ if (proc->arg_num < 2 && !newstyle) { - f_print(fout, "\t"); + fprintf(fout, "\t"); if (!streq(proc->args.decls->decl.type, "void")) ptype(proc->args.decls->decl.prefix, proc->args.decls->decl.type, 1); else - f_print(fout, "char *"); /* cannot have "void" type */ - f_print(fout, " "); + fprintf(fout, "char *"); /* cannot have "void" type */ + fprintf(fout, " "); pvname(proc->proc_name, vp->vers_num); - f_print(fout, "_arg;\n"); + fprintf(fout, "_arg;\n"); } else if (!streq(proc->args.decls->decl.type, "void")) { for (l = proc->args.decls; l != NULL; l = l->next) { - f_print(fout, "\t"); + fprintf(fout, "\t"); ptype(l->decl.prefix, l->decl.type, 1); - f_print(fout, " "); + fprintf(fout, " "); pvname(proc->proc_name, vp->vers_num); - f_print(fout, "_%s;\n", l->decl.name); + fprintf(fout, "_%s;\n", l->decl.name); /* pdeclaration(proc->args.argname, &l->decl, 1, ";\n");*/ } } } /* generate creation of client handle */ - f_print(fout, "\tclnt = clnt_create(host, %s, %s, \"%s\");\n", + fprintf(fout, "\tclnt = clnt_create(host, %s, %s, \"%s\");\n", program_name, vp->vers_name, tirpcflag? "netpath" : "udp"); - f_print(fout, "\tif (clnt == NULL) {\n"); - f_print(fout, "\t\tclnt_pcreateerror(host);\n"); - f_print(fout, "\t\texit(1);\n\t}\n"); + fprintf(fout, "\tif (clnt == NULL) {\n"); + fprintf(fout, "\t\tclnt_pcreateerror(host);\n"); + fprintf(fout, "\t\texit(1);\n\t}\n"); /* generate calls to procedures */ i = 0; for (proc = vp->procs; proc != NULL; proc = proc->next) { - f_print(fout, "\tresult_%d = ",++i); + fprintf(fout, "\tresult_%d = ",++i); pvname(proc->proc_name, vp->vers_num); if (proc->arg_num < 2 && !newstyle) { - f_print(fout, "("); + fprintf(fout, "("); if (streq(proc->args.decls->decl.type, "void")) /* cast to void* */ - f_print(fout, "(void*)"); - f_print(fout, "&"); + fprintf(fout, "(void*)"); + fprintf(fout, "&"); pvname(proc->proc_name, vp->vers_num); - f_print(fout, "_arg, clnt);\n"); + fprintf(fout, "_arg, clnt);\n"); } else if (streq(proc->args.decls->decl.type, "void")) { - f_print(fout, "(clnt);\n"); + fprintf(fout, "(clnt);\n"); } else { - f_print(fout, "("); + fprintf(fout, "("); for (l = proc->args.decls; l != NULL; l = l->next) { pvname(proc->proc_name, vp->vers_num); - f_print(fout, "_%s, ", l->decl.name); + fprintf(fout, "_%s, ", l->decl.name); } - f_print(fout, "clnt);\n"); + fprintf(fout, "clnt);\n"); } - f_print(fout, "\tif (result_%d == NULL) {\n", i); - f_print(fout, "\t\tclnt_perror(clnt, \"call failed:\");\n"); - f_print(fout, "\t}\n"); + fprintf(fout, "\tif (result_%d == NULL) {\n", i); + fprintf(fout, "\t\tclnt_perror(clnt, \"call failed:\");\n"); + fprintf(fout, "\t}\n"); } - f_print(fout, "\tclnt_destroy(clnt);\n"); - f_print(fout, "}\n"); + fprintf(fout, "\tclnt_destroy(clnt);\n"); + fprintf(fout, "}\n"); } static void @@ -173,30 +173,30 @@ write_sample_server(def) for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) { for (proc = vp->procs; proc != NULL; proc = proc->next) { - f_print(fout, "\n"); + fprintf(fout, "\n"); /* if (Cflag) - f_print(fout, "extern \"C\"{\n"); + fprintf(fout, "extern \"C\"{\n"); */ return_type(proc); - f_print(fout, "* \n"); + fprintf(fout, "* \n"); pvname_svc(proc->proc_name, vp->vers_num); printarglist(proc, RQSTP, "struct svc_req *"); - f_print(fout, "{\n"); - f_print(fout, "\n\tstatic "); + fprintf(fout, "{\n"); + fprintf(fout, "\n\tstatic "); if (!streq(proc->res_type, "void")) return_type(proc); else - f_print(fout, "char*"); /* cannot have void type */ - f_print(fout, " result;\n"); - f_print(fout, + fprintf(fout, "char*"); /* cannot have void type */ + fprintf(fout, " result;\n"); + fprintf(fout, "\n\t/*\n\t * insert server code here\n\t */\n\n"); if (!streq(proc->res_type, "void")) - f_print(fout, "\treturn(&result);\n}\n"); + fprintf(fout, "\treturn(&result);\n}\n"); else /* cast back to void * */ - f_print(fout, "\treturn((void*) &result);\n}\n"); + fprintf(fout, "\treturn((void*) &result);\n}\n"); /* if (Cflag) - f_print(fout, "}\n"); + fprintf(fout, "}\n"); */ } } @@ -212,11 +212,11 @@ return_type(plist) void add_sample_msg() { - f_print(fout, "/*\n"); - f_print(fout, " * This is sample code generated by rpcgen.\n"); - f_print(fout, " * These are only templates and you can use them\n"); - f_print(fout, " * as a guideline for developing your own functions.\n"); - f_print(fout, " */\n\n"); + fprintf(fout, "/*\n"); + fprintf(fout, " * This is sample code generated by rpcgen.\n"); + fprintf(fout, " * These are only templates and you can use them\n"); + fprintf(fout, " * as a guideline for developing your own functions.\n"); + fprintf(fout, " */\n\n"); } void @@ -226,27 +226,27 @@ write_sample_clnt_main() definition *def; version_list *vp; - f_print(fout, "\n\n"); + fprintf(fout, "\n\n"); if (Cflag) - f_print(fout,"main(int argc, char *argv[])\n{\n"); + fprintf(fout,"main(int argc, char *argv[])\n{\n"); else - f_print(fout, "main(argc, argv)\nint argc;\nchar *argv[];\n{\n"); + fprintf(fout, "main(argc, argv)\nint argc;\nchar *argv[];\n{\n"); - f_print(fout, "\tchar *host;"); - f_print(fout, "\n\n\tif (argc < 2) {"); - f_print(fout, "\n\t\tprintf(\"usage: %%s server_host\\n\", argv[0]);\n"); - f_print(fout, "\t\texit(1);\n\t}"); - f_print(fout, "\n\thost = argv[1];\n"); + fprintf(fout, "\tchar *host;"); + fprintf(fout, "\n\n\tif (argc < 2) {"); + fprintf(fout, "\n\t\tprintf(\"usage: %%s server_host\\n\", argv[0]);\n"); + fprintf(fout, "\t\texit(1);\n\t}"); + fprintf(fout, "\n\thost = argv[1];\n"); for (l = defined; l != NULL; l = l->next) { def = l->val; if (def->def_kind != DEF_PROGRAM) continue; for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) { - f_print(fout, "\t"); + fprintf(fout, "\t"); pvname(def->def_name, vp->vers_num); - f_print(fout, "(host);\n"); + fprintf(fout, "(host);\n"); } } - f_print(fout, "}\n"); + fprintf(fout, "}\n"); } diff --git a/usr.bin/rpcgen/rpc_scan.c b/usr.bin/rpcgen/rpc_scan.c index 70f00549750..8a0dd317686 100644 --- a/usr.bin/rpcgen/rpc_scan.c +++ b/usr.bin/rpcgen/rpc_scan.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rpc_scan.c,v 1.8 2002/02/16 21:27:51 millert Exp $ */ +/* $OpenBSD: rpc_scan.c,v 1.9 2002/06/01 01:40:38 deraadt Exp $ */ /* $NetBSD: rpc_scan.c,v 1.4 1995/06/11 21:50:02 pk Exp $ */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for @@ -291,12 +291,12 @@ get_token(tokp) char buf[100]; char *p; - s_print(buf, "illegal character in file: "); + snprintf(buf, sizeof buf, "illegal character in file: "); p = buf + strlen(buf); if (isprint(*where)) { - s_print(p, "%c", *where); + sprintf(p, "%c", *where); } else { - s_print(p, "%d", *where); + sprintf(p, "%d", *where); } error(buf); } @@ -460,7 +460,7 @@ static printdirective(line) char *line; { - f_print(fout, "%s", line + 1); + fprintf(fout, "%s", line + 1); } static diff --git a/usr.bin/rpcgen/rpc_svcout.c b/usr.bin/rpcgen/rpc_svcout.c index c626ddf02d4..2d0292a83cb 100644 --- a/usr.bin/rpcgen/rpc_svcout.c +++ b/usr.bin/rpcgen/rpc_svcout.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rpc_svcout.c,v 1.11 2002/02/16 21:27:51 millert Exp $ */ +/* $OpenBSD: rpc_svcout.c,v 1.12 2002/06/01 01:40:38 deraadt Exp $ */ /* $NetBSD: rpc_svcout.c,v 1.7 1995/06/24 14:59:59 pk Exp $ */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for @@ -72,10 +72,10 @@ char *rname; char *typename; { if (Cflag) - f_print(fout, "\t\txdr_%s = (xdrproc_t) xdr_%s;\n", + fprintf(fout, "\t\txdr_%s = (xdrproc_t) xdr_%s;\n", rname, stringfix(typename)); else - f_print(fout, "\t\txdr_%s = xdr_%s;\n", rname, + fprintf(fout, "\t\txdr_%s = xdr_%s;\n", rname, stringfix(typename)); } @@ -83,9 +83,9 @@ void internal_proctype(plist) proc_list *plist; { - f_print(fout, "static "); + fprintf(fout, "static "); ptype(plist->res_prefix, plist->res_type, 1); - f_print(fout, "*"); + fprintf(fout, "*"); } /* @@ -100,13 +100,13 @@ write_most(infile, netflag, nomain) if (inetdflag || pmflag) { char *var_type; var_type = (nomain? "extern" : "static"); - f_print(fout, "%s int _rpcpmstart;", var_type); - f_print(fout, "\t\t/* Started by a port monitor ? */\n"); - f_print(fout, "%s int _rpcfdtype;", var_type); - f_print(fout, "\t\t/* Whether Stream or Datagram ? */\n"); + fprintf(fout, "%s int _rpcpmstart;", var_type); + fprintf(fout, "\t\t/* Started by a port monitor ? */\n"); + fprintf(fout, "%s int _rpcfdtype;", var_type); + fprintf(fout, "\t\t/* Whether Stream or Datagram ? */\n"); if (timerflag) { - f_print(fout, "%s int _rpcsvcdirty;", var_type); - f_print(fout, "\t/* Still serving ? */\n"); + fprintf(fout, "%s int _rpcsvcdirty;", var_type); + fprintf(fout, "\t/* Still serving ? */\n"); } write_svc_aux(nomain); } @@ -116,26 +116,26 @@ write_most(infile, netflag, nomain) if (nomain) return; - f_print(fout, "\nmain()\n"); - f_print(fout, "{\n"); + fprintf(fout, "\nmain()\n"); + fprintf(fout, "{\n"); if (inetdflag) { write_inetmost(infile); /* Includes call to write_rpc_svc_fg() */ } else { if (tirpcflag) { if (netflag) { - f_print(fout, "\tSVCXPRT *%s;\n", TRANSP); - f_print(fout, "\tstruct netconfig *nconf = NULL;\n"); + fprintf(fout, "\tSVCXPRT *%s;\n", TRANSP); + fprintf(fout, "\tstruct netconfig *nconf = NULL;\n"); } - f_print(fout, "\tpid_t pid;\n"); - f_print(fout, "\tint i;\n"); - f_print(fout, "\tchar mname[FMNAMESZ + 1];\n\n"); + fprintf(fout, "\tpid_t pid;\n"); + fprintf(fout, "\tint i;\n"); + fprintf(fout, "\tchar mname[FMNAMESZ + 1];\n\n"); write_pm_most(infile, netflag); - f_print(fout, "\telse {\n"); + fprintf(fout, "\telse {\n"); write_rpc_svc_fg(infile, "\t\t"); - f_print(fout, "\t}\n"); + fprintf(fout, "\t}\n"); } else { - f_print(fout, "\tSVCXPRT *%s;\n", TRANSP); - f_print(fout, "\n"); + fprintf(fout, "\tSVCXPRT *%s;\n", TRANSP); + fprintf(fout, "\n"); print_pmapunset("\t"); } } @@ -159,43 +159,44 @@ write_netid_register(transp) char tmpbuf[32]; sp = ""; - 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); + fprintf(fout, "\n"); + fprintf(fout, "%s\tnconf = getnetconfigent(\"%s\");\n", sp, transp); + fprintf(fout, "%s\tif (nconf == NULL) {\n", sp); + (void) snprintf(_errbuf, sizeof _errbuf, "cannot find %s netid.", transp); snprintf(tmpbuf, sizeof tmpbuf, "%s\t\t", sp); print_err_message(tmpbuf); - f_print(fout, "%s\t\texit(1);\n", sp); - f_print(fout, "%s\t}\n", sp); - f_print(fout, "%s\t%s = svc_tli_create(RPC_ANYFD, nconf, 0, 0, 0);\n", + fprintf(fout, "%s\t\texit(1);\n", sp); + fprintf(fout, "%s\t}\n", sp); + fprintf(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); + fprintf(fout, "%s\tif (%s == NULL) {\n", sp, TRANSP); + (void) snprintf(_errbuf, sizeof _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); + fprintf(fout, "%s\t\texit(1);\n", sp); + fprintf(fout, "%s\t}\n", sp); for (l = defined; l != NULL; l = l->next) { def = (definition *) l->val; if (def->def_kind != DEF_PROGRAM) continue; for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) { - f_print(fout, + fprintf(fout, "%s\t(void) rpcb_unset(%s, %s, nconf);\n", sp, def->def_name, vp->vers_name); - f_print(fout, + fprintf(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).", + fprintf(fout, ", nconf)) {\n"); + (void) snprintf(_errbuf, sizeof _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); - f_print(fout, "%s\t}\n", sp); + fprintf(fout, "%s\t\texit(1);\n", sp); + fprintf(fout, "%s\t}\n", sp); } } - f_print(fout, "%s\tfreenetconfigent(nconf);\n", sp); + fprintf(fout, "%s\tfreenetconfigent(nconf);\n", sp); } /* @@ -214,16 +215,16 @@ write_nettype_register(transp) if (def->def_kind != DEF_PROGRAM) continue; for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) { - f_print(fout, "\tif (!svc_create("); + fprintf(fout, "\tif (!svc_create("); pvname(def->def_name, vp->vers_num); - f_print(fout, ", %s, %s, \"%s\")) {\n", + fprintf(fout, ", %s, %s, \"%s\")) {\n", def->def_name, vp->vers_name, transp); - (void) sprintf(_errbuf, + (void) snprintf(_errbuf, sizeof _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"); - f_print(fout, "\t}\n"); + fprintf(fout, "\t\texit(1);\n"); + fprintf(fout, "\t}\n"); } } } @@ -234,28 +235,28 @@ write_nettype_register(transp) void write_rest() { - f_print(fout, "\n"); + fprintf(fout, "\n"); if (inetdflag) { - f_print(fout, "\tif (%s == (SVCXPRT *)NULL) {\n", TRANSP); - (void) sprintf(_errbuf, "could not create a handle"); + fprintf(fout, "\tif (%s == (SVCXPRT *)NULL) {\n", TRANSP); + (void) snprintf(_errbuf, sizeof _errbuf, "could not create a handle"); print_err_message("\t\t"); - f_print(fout, "\t\texit(1);\n"); - f_print(fout, "\t}\n"); + fprintf(fout, "\t\texit(1);\n"); + fprintf(fout, "\t}\n"); if (timerflag) { - f_print(fout, "\tif (_rpcpmstart) {\n"); - f_print(fout, + fprintf(fout, "\tif (_rpcpmstart) {\n"); + fprintf(fout, "\t\t(void) signal(SIGALRM, %s closedown);\n", Cflag? "(SIG_PF)" : "(void(*)())"); - f_print(fout, "\t\t(void) alarm(_RPCSVC_CLOSEDOWN);\n"); - f_print(fout, "\t}\n"); + fprintf(fout, "\t\t(void) alarm(_RPCSVC_CLOSEDOWN);\n"); + fprintf(fout, "\t}\n"); } } - f_print(fout, "\tsvc_run();\n"); - (void) sprintf(_errbuf, "svc_run returned"); + fprintf(fout, "\tsvc_run();\n"); + (void) snprintf(_errbuf, sizeof _errbuf, "svc_run returned"); print_err_message("\t"); - f_print(fout, "\texit(1);\n"); - f_print(fout, "\t/* NOTREACHED */\n"); - f_print(fout, "}\n"); + fprintf(fout, "\texit(1);\n"); + fprintf(fout, "\t/* NOTREACHED */\n"); + fprintf(fout, "}\n"); } void @@ -295,46 +296,46 @@ write_real_program(def) 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"); + fprintf(fout, "\n"); internal_proctype(proc); - f_print(fout, "\n_"); + fprintf(fout, "\n_"); pvname(proc->proc_name, vp->vers_num); if (Cflag) { - f_print(fout, "("); + fprintf(fout, "("); /* arg name */ if (proc->arg_num > 1) - f_print(fout, proc->args.argname); + fprintf(fout, proc->args.argname); else ptype(proc->args.decls->decl.prefix, proc->args.decls->decl.type, 0); - f_print(fout, " *argp, struct svc_req *%s)\n", + fprintf(fout, " *argp, struct svc_req *%s)\n", RQSTP); } else { - f_print(fout, "(argp, %s)\n", RQSTP); + fprintf(fout, "(argp, %s)\n", RQSTP); /* arg name */ if (proc->arg_num > 1) - f_print(fout, "\t%s *argp;\n", proc->args.argname); + fprintf(fout, "\t%s *argp;\n", proc->args.argname); else { - f_print(fout, "\t"); + fprintf(fout, "\t"); ptype(proc->args.decls->decl.prefix, proc->args.decls->decl.type, 0); - f_print(fout, " *argp;\n"); + fprintf(fout, " *argp;\n"); } - f_print(fout, " struct svc_req *%s;\n", RQSTP); + fprintf(fout, " struct svc_req *%s;\n", RQSTP); } - f_print(fout, "{\n"); - f_print(fout, "\treturn("); + fprintf(fout, "{\n"); + fprintf(fout, "\treturn("); pvname_svc(proc->proc_name, vp->vers_num); - f_print(fout, "("); + fprintf(fout, "("); if (proc->arg_num < 2) { /* single argument */ if (!streq(proc->args.decls->decl.type, "void")) - f_print(fout, "*argp, "); /* non-void */ + fprintf(fout, "*argp, "); /* non-void */ } else { for (l = proc->args.decls; l != NULL; l = l->next) - f_print(fout, "argp->%s, ", l->decl.name); + fprintf(fout, "argp->%s, ", l->decl.name); } - f_print(fout, "%s));\n}\n", RQSTP); + fprintf(fout, "%s));\n}\n", RQSTP); } } } @@ -349,78 +350,78 @@ write_program(def, storage) int filled; for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) { - f_print(fout, "\n"); + fprintf(fout, "\n"); if (storage != NULL) - f_print(fout, "%s ", storage); - f_print(fout, "void\n"); + fprintf(fout, "%s ", storage); + fprintf(fout, "void\n"); pvname(def->def_name, vp->vers_num); if (Cflag) { - f_print(fout, "(struct svc_req *%s, ", RQSTP); - f_print(fout, "register SVCXPRT *%s)\n", TRANSP); + fprintf(fout, "(struct svc_req *%s, ", RQSTP); + fprintf(fout, "register SVCXPRT *%s)\n", TRANSP); } else { - f_print(fout, "(%s, %s)\n", RQSTP, TRANSP); - f_print(fout, " struct svc_req *%s;\n", RQSTP); - f_print(fout, " register SVCXPRT *%s;\n", TRANSP); + fprintf(fout, "(%s, %s)\n", RQSTP, TRANSP); + fprintf(fout, " struct svc_req *%s;\n", RQSTP); + fprintf(fout, " register SVCXPRT *%s;\n", TRANSP); } - f_print(fout, "{\n"); + fprintf(fout, "{\n"); filled = 0; - f_print(fout, "\tunion {\n"); + fprintf(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")) continue; filled = 1; - f_print(fout, "\t\t"); + fprintf(fout, "\t\t"); ptype(proc->args.decls->decl.prefix, proc->args.decls->decl.type, 0); pvname(proc->proc_name, vp->vers_num); - f_print(fout, "_arg;\n"); + fprintf(fout, "_arg;\n"); } else { filled = 1; - f_print(fout, "\t\t%s", proc->args.argname); - f_print(fout, " "); + fprintf(fout, "\t\t%s", proc->args.argname); + fprintf(fout, " "); pvname(proc->proc_name, vp->vers_num); - f_print(fout, "_arg;\n"); + fprintf(fout, "_arg;\n"); } } if (!filled) - f_print(fout, "\t\tint fill;\n"); - f_print(fout, "\t} %s;\n", ARG); - f_print(fout, "\tchar *%s;\n", RESULT); + fprintf(fout, "\t\tint fill;\n"); + fprintf(fout, "\t} %s;\n", ARG); + fprintf(fout, "\tchar *%s;\n", RESULT); if (Cflag) { - f_print(fout, "\txdrproc_t xdr_%s, xdr_%s;\n", ARG, RESULT); - f_print(fout, + fprintf(fout, "\txdrproc_t xdr_%s, xdr_%s;\n", ARG, RESULT); + fprintf(fout, "\tchar *(*%s)(char *, struct svc_req *);\n", ROUTINE); } else { - f_print(fout, "\tbool_t (*xdr_%s)(), (*xdr_%s)();\n", + fprintf(fout, "\tbool_t (*xdr_%s)(), (*xdr_%s)();\n", ARG, RESULT); - f_print(fout, "\tchar *(*%s)();\n", ROUTINE); + fprintf(fout, "\tchar *(*%s)();\n", ROUTINE); } - f_print(fout, "\n"); + fprintf(fout, "\n"); if (callerflag) - f_print(fout, "\tcaller = transp;\n"); /*EVAS*/ + fprintf(fout, "\tcaller = transp;\n"); /*EVAS*/ if (timerflag) - f_print(fout, "\t_rpcsvcdirty = 1;\n"); - f_print(fout, "\tswitch (%s->rq_proc) {\n", RQSTP); + fprintf(fout, "\t_rpcsvcdirty = 1;\n"); + fprintf(fout, "\tswitch (%s->rq_proc) {\n", RQSTP); if (!nullproc(vp->procs)) { - f_print(fout, "\tcase NULLPROC:\n"); - f_print(fout, + fprintf(fout, "\tcase NULLPROC:\n"); + fprintf(fout, Cflag ? "\t\t(void) svc_sendreply(%s, (xdrproc_t) xdr_void, (char *)NULL);\n" : "\t\t(void) svc_sendreply(%s, xdr_void, (char *)NULL);\n", TRANSP); print_return("\t\t"); - f_print(fout, "\n"); + fprintf(fout, "\n"); } for (proc = vp->procs; proc != NULL; proc = proc->next) { - f_print(fout, "\tcase %s:\n", proc->proc_name); + fprintf(fout, "\tcase %s:\n", proc->proc_name); if (proc->arg_num < 2) { /* single argument */ p_xdrfunc(ARG, proc->args.decls->decl.type); } else { @@ -428,52 +429,52 @@ write_program(def, storage) } p_xdrfunc(RESULT, proc->res_type); if (Cflag) - f_print(fout, + fprintf(fout, "\t\t%s = (char *(*)(char *, struct svc_req *)) ", ROUTINE); else - f_print(fout, "\t\t%s = (char *(*)()) ", ROUTINE); + fprintf(fout, "\t\t%s = (char *(*)()) ", ROUTINE); if (newstyle) { /* new style: calls internal routine */ - f_print(fout,"_"); + fprintf(fout,"_"); } if (!newstyle) pvname_svc(proc->proc_name, vp->vers_num); else pvname(proc->proc_name, vp->vers_num); - f_print(fout, ";\n"); - f_print(fout, "\t\tbreak;\n\n"); + fprintf(fout, ";\n"); + fprintf(fout, "\t\tbreak;\n\n"); } - f_print(fout, "\tdefault:\n"); + fprintf(fout, "\tdefault:\n"); printerr("noproc", TRANSP); print_return("\t\t"); - f_print(fout, "\t}\n"); + fprintf(fout, "\t}\n"); - f_print(fout, "\t(void) memset((char *)&%s, 0, sizeof (%s));\n", ARG, ARG); + fprintf(fout, "\t(void) memset((char *)&%s, 0, sizeof (%s));\n", ARG, ARG); printif ("getargs", TRANSP, "(caddr_t) &", ARG); printerr("decode", TRANSP); print_return("\t\t"); - f_print(fout, "\t}\n"); + fprintf(fout, "\t}\n"); if (Cflag) - f_print(fout, "\t%s = (*%s)((char *)&%s, %s);\n", + fprintf(fout, "\t%s = (*%s)((char *)&%s, %s);\n", RESULT, ROUTINE, ARG, RQSTP); else - f_print(fout, "\t%s = (*%s)(&%s, %s);\n", + fprintf(fout, "\t%s = (*%s)(&%s, %s);\n", RESULT, ROUTINE, ARG, RQSTP); - f_print(fout, + fprintf(fout, "\tif (%s != NULL && !svc_sendreply(%s, xdr_%s, %s)) {\n", RESULT, TRANSP, RESULT, RESULT); printerr("systemerr", TRANSP); - f_print(fout, "\t}\n"); + fprintf(fout, "\t}\n"); printif ("freeargs", TRANSP, "(caddr_t) &", ARG); - (void) sprintf(_errbuf, "unable to free arguments"); + (void) snprintf(_errbuf, sizeof _errbuf, "unable to free arguments"); print_err_message("\t\t"); - f_print(fout, "\t\texit(1);\n"); - f_print(fout, "\t}\n"); + fprintf(fout, "\t\texit(1);\n"); + fprintf(fout, "\t}\n"); print_return("\t"); - f_print(fout, "}\n"); + fprintf(fout, "}\n"); } } @@ -482,7 +483,7 @@ printerr(err, transp) char *err; char *transp; { - f_print(fout, "\t\tsvcerr_%s(%s);\n", err, transp); + fprintf(fout, "\t\tsvcerr_%s(%s);\n", err, transp); } static @@ -492,7 +493,7 @@ printif (proc, transp, prefix, arg) char *prefix; char *arg; { - f_print(fout, "\tif (!svc_%s(%s, xdr_%s, %s%s)) {\n", + fprintf(fout, "\tif (!svc_%s(%s, xdr_%s, %s%s)) {\n", proc, transp, arg, prefix, arg); } @@ -510,29 +511,29 @@ static write_inetmost(infile) char *infile; { - f_print(fout, "\tregister SVCXPRT *%s;\n", TRANSP); - f_print(fout, "\tint sock;\n"); - f_print(fout, "\tint proto;\n"); - f_print(fout, "\tstruct sockaddr_in saddr;\n"); - f_print(fout, "\tint asize = sizeof (saddr);\n"); - f_print(fout, "\n"); - f_print(fout, + fprintf(fout, "\tregister SVCXPRT *%s;\n", TRANSP); + fprintf(fout, "\tint sock;\n"); + fprintf(fout, "\tint proto;\n"); + fprintf(fout, "\tstruct sockaddr_in saddr;\n"); + fprintf(fout, "\tint asize = sizeof (saddr);\n"); + fprintf(fout, "\n"); + fprintf(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"); - f_print(fout, "\t\tif (getsockopt(0, SOL_SOCKET, SO_TYPE,\n"); - f_print(fout, "\t\t (char *)&_rpcfdtype, &ssize) == -1)\n"); - f_print(fout, "\t\t\texit(1);\n"); - f_print(fout, "\t\tsock = 0;\n"); - f_print(fout, "\t\t_rpcpmstart = 1;\n"); - f_print(fout, "\t\tproto = 0;\n"); + fprintf(fout, "\t\tint ssize = sizeof (int);\n\n"); + fprintf(fout, "\t\tif (saddr.sin_family != AF_INET)\n"); + fprintf(fout, "\t\t\texit(1);\n"); + fprintf(fout, "\t\tif (getsockopt(0, SOL_SOCKET, SO_TYPE,\n"); + fprintf(fout, "\t\t (char *)&_rpcfdtype, &ssize) == -1)\n"); + fprintf(fout, "\t\t\texit(1);\n"); + fprintf(fout, "\t\tsock = 0;\n"); + fprintf(fout, "\t\t_rpcpmstart = 1;\n"); + fprintf(fout, "\t\tproto = 0;\n"); open_log_file(infile, "\t\t"); - f_print(fout, "\t} else {\n"); + fprintf(fout, "\t} else {\n"); write_rpc_svc_fg(infile, "\t\t"); - f_print(fout, "\t\tsock = RPC_ANYSOCK;\n"); + fprintf(fout, "\t\tsock = RPC_ANYSOCK;\n"); print_pmapunset("\t\t"); - f_print(fout, "\t}\n"); + fprintf(fout, "\t}\n"); } static @@ -540,11 +541,11 @@ print_return(space) char *space; { if (exitnow) - f_print(fout, "%sexit(0);\n", space); + fprintf(fout, "%sexit(0);\n", space); else { if (timerflag) - f_print(fout, "%s_rpcsvcdirty = 0;\n", space); - f_print(fout, "%sreturn;\n", space); + fprintf(fout, "%s_rpcsvcdirty = 0;\n", space); + fprintf(fout, "%sreturn;\n", space); } } @@ -561,7 +562,7 @@ print_pmapunset(space) if (def->def_kind == DEF_PROGRAM) { for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) { - f_print(fout, "%s(void) pmap_unset(%s, %s);\n", + fprintf(fout, "%s(void) pmap_unset(%s, %s);\n", space, def->def_name, vp->vers_name); } } @@ -573,11 +574,11 @@ print_err_message(space) char *space; { if (logflag) - f_print(fout, "%ssyslog(LOG_ERR, \"%s\");\n", space, _errbuf); + fprintf(fout, "%ssyslog(LOG_ERR, \"%s\");\n", space, _errbuf); else if (inetdflag || pmflag) - f_print(fout, "%s_msgout(\"%s\");\n", space, _errbuf); + fprintf(fout, "%s_msgout(\"%s\");\n", space, _errbuf); else - f_print(fout, "%sfprintf(stderr, \"%s\");\n", space, _errbuf); + fprintf(fout, "%sfprintf(stderr, \"%s\");\n", space, _errbuf); } /* @@ -601,26 +602,26 @@ write_svc_aux(nomain) write_msg_out() { - f_print(fout, "\n"); - f_print(fout, "static\n"); + fprintf(fout, "\n"); + fprintf(fout, "static\n"); if (!Cflag) { - f_print(fout, "void _msgout(msg)\n"); - f_print(fout, "\tchar *msg;\n"); + fprintf(fout, "void _msgout(msg)\n"); + fprintf(fout, "\tchar *msg;\n"); } else { - f_print(fout, "void _msgout(char *msg)\n"); + fprintf(fout, "void _msgout(char *msg)\n"); } - f_print(fout, "{\n"); - f_print(fout, "#ifdef RPC_SVC_FG\n"); + fprintf(fout, "{\n"); + fprintf(fout, "#ifdef RPC_SVC_FG\n"); if (inetdflag || pmflag) - f_print(fout, "\tif (_rpcpmstart)\n"); - f_print(fout, "\t\tsyslog(LOG_ERR, msg);\n"); - f_print(fout, "\telse {\n"); - f_print(fout, "\t\t(void) write(STDERR_FILENO, msg, strlen(msg));\n"); - f_print(fout, "\t\t(void) write(STDERR_FILENO, \"\\n\", 1);\n"); - f_print(fout, "\t}\n#else\n"); - f_print(fout, "\tsyslog(LOG_ERR, msg);\n"); - f_print(fout, "#endif\n"); - f_print(fout, "}\n"); + fprintf(fout, "\tif (_rpcpmstart)\n"); + fprintf(fout, "\t\tsyslog(LOG_ERR, msg);\n"); + fprintf(fout, "\telse {\n"); + fprintf(fout, "\t\t(void) write(STDERR_FILENO, msg, strlen(msg));\n"); + fprintf(fout, "\t\t(void) write(STDERR_FILENO, \"\\n\", 1);\n"); + fprintf(fout, "\t}\n#else\n"); + fprintf(fout, "\tsyslog(LOG_ERR, msg);\n"); + fprintf(fout, "#endif\n"); + fprintf(fout, "}\n"); } /* @@ -631,37 +632,37 @@ write_timeout_func() { if (!timerflag) return; - f_print(fout, "\n"); - f_print(fout, "static void\n"); - f_print(fout, "closedown()\n"); - f_print(fout, "{\n"); - f_print(fout, "\tint save_errno = errno;\n\n"); - f_print(fout, "\tif (_rpcsvcdirty == 0) {\n"); - f_print(fout, "\t\textern fd_set *__svc_fdset;\n"); - f_print(fout, "\t\textern int __svc_fdsetsize;\n"); - f_print(fout, "\t\tint i, openfd;\n"); + fprintf(fout, "\n"); + fprintf(fout, "static void\n"); + fprintf(fout, "closedown()\n"); + fprintf(fout, "{\n"); + fprintf(fout, "\tint save_errno = errno;\n\n"); + fprintf(fout, "\tif (_rpcsvcdirty == 0) {\n"); + fprintf(fout, "\t\textern fd_set *__svc_fdset;\n"); + fprintf(fout, "\t\textern int __svc_fdsetsize;\n"); + fprintf(fout, "\t\tint i, openfd;\n"); if (tirpcflag && pmflag) { - f_print(fout, "\t\tstruct t_info tinfo;\n\n"); - f_print(fout, "\t\tif (!t_getinfo(0, &tinfo) && (tinfo.servtype == T_CLTS))\n"); + fprintf(fout, "\t\tstruct t_info tinfo;\n\n"); + fprintf(fout, "\t\tif (!t_getinfo(0, &tinfo) && (tinfo.servtype == T_CLTS))\n"); } else { - f_print(fout, "\n\t\tif (_rpcfdtype == SOCK_DGRAM)\n"); + fprintf(fout, "\n\t\tif (_rpcfdtype == SOCK_DGRAM)\n"); } - f_print(fout, "\t\t\t_exit(0);\n"); - f_print(fout, "\t\tfor (i = 0, openfd = 0; i < __svc_fdsetsize && openfd < 2; i++)\n"); - f_print(fout, "\t\t\tif (FD_ISSET(i, __svc_fdset))\n"); - f_print(fout, "\t\t\t\topenfd++;\n"); - f_print(fout, "\t\tif (openfd <= (_rpcpmstart?0:1))\n"); - f_print(fout, "\t\t\t_exit(0);\n"); - f_print(fout, "\t}\n"); - f_print(fout, "\t(void) alarm(_RPCSVC_CLOSEDOWN);\n"); - f_print(fout, "\terrno = save_errno;\n"); - f_print(fout, "}\n"); + fprintf(fout, "\t\t\t_exit(0);\n"); + fprintf(fout, "\t\tfor (i = 0, openfd = 0; i < __svc_fdsetsize && openfd < 2; i++)\n"); + fprintf(fout, "\t\t\tif (FD_ISSET(i, __svc_fdset))\n"); + fprintf(fout, "\t\t\t\topenfd++;\n"); + fprintf(fout, "\t\tif (openfd <= (_rpcpmstart?0:1))\n"); + fprintf(fout, "\t\t\t_exit(0);\n"); + fprintf(fout, "\t}\n"); + fprintf(fout, "\t(void) alarm(_RPCSVC_CLOSEDOWN);\n"); + fprintf(fout, "\terrno = save_errno;\n"); + fprintf(fout, "}\n"); } static write_caller_func() /*EVAS*/ { -#define P(s) f_print(fout, s); +#define P(s) fprintf(fout, s); P("\n"); P("char *svc_caller()\n"); @@ -669,7 +670,7 @@ P("{\n"); P(" struct sockaddr_in actual;\n"); P(" struct hostent *hp;\n"); P(" static struct in_addr prev;\n"); -P(" static char cname[128];\n\n"); +P(" static char cname[256];\n\n"); P(" actual = *svc_getcaller(caller);\n\n"); @@ -682,9 +683,9 @@ P(" prev = actual.sin_addr;\n\n"); P(" hp = gethostbyaddr((char *) &actual.sin_addr, sizeof(actual.sin_addr), AF_INET);\n"); P(" if (hp == NULL) { /* dummy one up */\n"); P(" extern char *inet_ntoa();\n"); -P(" strcpy(cname, inet_ntoa(actual.sin_addr));\n"); +P(" strlcpy(cname, inet_ntoa(actual.sin_addr), sizeof cname);\n"); P(" } else {\n"); -P(" strcpy(cname, hp->h_name);\n"); +P(" strlcpy(cname, hp->h_name, sizeof cname);\n"); P(" }\n\n"); P(" return (cname);\n"); @@ -705,79 +706,79 @@ write_pm_most(infile, netflag) definition *def; version_list *vp; - f_print(fout, "\tif (!ioctl(0, I_LOOK, mname) &&\n"); - f_print(fout, "\t\t(!strcmp(mname, \"sockmod\") ||"); - f_print(fout, " !strcmp(mname, \"timod\"))) {\n"); - f_print(fout, "\t\tchar *netid;\n"); + fprintf(fout, "\tif (!ioctl(0, I_LOOK, mname) &&\n"); + fprintf(fout, "\t\t(!strcmp(mname, \"sockmod\") ||"); + fprintf(fout, " !strcmp(mname, \"timod\"))) {\n"); + fprintf(fout, "\t\tchar *netid;\n"); if (!netflag) { /* Not included by -n option */ - f_print(fout, "\t\tstruct netconfig *nconf = NULL;\n"); - f_print(fout, "\t\tSVCXPRT *%s;\n", TRANSP); + fprintf(fout, "\t\tstruct netconfig *nconf = NULL;\n"); + fprintf(fout, "\t\tSVCXPRT *%s;\n", TRANSP); } if (timerflag) - f_print(fout, "\t\tint pmclose;\n"); + fprintf(fout, "\t\tint pmclose;\n"); /* not necessary, defined in /usr/include/stdlib */ -/* f_print(fout, "\t\textern char *getenv();\n");*/ - f_print(fout, "\n"); - f_print(fout, "\t\t_rpcpmstart = 1;\n"); +/* fprintf(fout, "\t\textern char *getenv();\n");*/ + fprintf(fout, "\n"); + fprintf(fout, "\t\t_rpcpmstart = 1;\n"); if (logflag) open_log_file(infile, "\t\t"); - f_print(fout, "\t\tif ((netid = getenv(\"NLSPROVIDER\")) == NULL) {\n"); - sprintf(_errbuf, "cannot get transport name"); + fprintf(fout, "\t\tif ((netid = getenv(\"NLSPROVIDER\")) == NULL) {\n"); + snprintf(_errbuf, sizeof _errbuf, "cannot get transport name"); print_err_message("\t\t\t"); - f_print(fout, "\t\t} else if ((nconf = getnetconfigent(netid)) == NULL) {\n"); - sprintf(_errbuf, "cannot get transport info"); + fprintf(fout, "\t\t} else if ((nconf = getnetconfigent(netid)) == NULL) {\n"); + snprintf(_errbuf, sizeof _errbuf, "cannot get transport info"); print_err_message("\t\t\t"); - f_print(fout, "\t\t}\n"); + fprintf(fout, "\t\t}\n"); /* * A kludgy support for inetd services. Inetd only works with * sockmod, and RPC works only with timod, hence all this jugglery */ - f_print(fout, "\t\tif (strcmp(mname, \"sockmod\") == 0) {\n"); - f_print(fout, "\t\t\tif (ioctl(0, I_POP, 0) || ioctl(0, I_PUSH, \"timod\")) {\n"); - sprintf(_errbuf, "could not get the right module"); + fprintf(fout, "\t\tif (strcmp(mname, \"sockmod\") == 0) {\n"); + fprintf(fout, "\t\t\tif (ioctl(0, I_POP, 0) || ioctl(0, I_PUSH, \"timod\")) {\n"); + snprintf(_errbuf, sizeof _errbuf, "could not get the right module"); print_err_message("\t\t\t\t"); - f_print(fout, "\t\t\t\texit(1);\n"); - f_print(fout, "\t\t\t}\n"); - f_print(fout, "\t\t}\n"); + fprintf(fout, "\t\t\t\texit(1);\n"); + fprintf(fout, "\t\t\t}\n"); + fprintf(fout, "\t\t}\n"); if (timerflag) - f_print(fout, "\t\tpmclose = (t_getstate(0) != T_DATAXFER);\n"); - f_print(fout, "\t\tif ((%s = svc_tli_create(0, nconf, NULL, 0, 0)) == NULL) {\n", + fprintf(fout, "\t\tpmclose = (t_getstate(0) != T_DATAXFER);\n"); + fprintf(fout, "\t\tif ((%s = svc_tli_create(0, nconf, NULL, 0, 0)) == NULL) {\n", TRANSP); - sprintf(_errbuf, "cannot create server handle"); + snprintf(_errbuf, sizeof _errbuf, "cannot create server handle"); print_err_message("\t\t\t"); - f_print(fout, "\t\t\texit(1);\n"); - f_print(fout, "\t\t}\n"); - f_print(fout, "\t\tif (nconf)\n"); - f_print(fout, "\t\t\tfreenetconfigent(nconf);\n"); + fprintf(fout, "\t\t\texit(1);\n"); + fprintf(fout, "\t\t}\n"); + fprintf(fout, "\t\tif (nconf)\n"); + fprintf(fout, "\t\t\tfreenetconfigent(nconf);\n"); for (l = defined; l != NULL; l = l->next) { def = (definition *) l->val; if (def->def_kind != DEF_PROGRAM) { continue; } for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) { - f_print(fout, + fprintf(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).", + fprintf(fout, ", 0)) {\n"); + (void) snprintf(_errbuf, sizeof _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"); + fprintf(fout, "\t\t\texit(1);\n"); + fprintf(fout, "\t\t}\n"); } } if (timerflag) { - f_print(fout, "\t\tif (pmclose) {\n"); - f_print(fout, "\t\t\t(void) signal(SIGALRM, %s closedown);\n", + fprintf(fout, "\t\tif (pmclose) {\n"); + fprintf(fout, "\t\t\t(void) signal(SIGALRM, %s closedown);\n", Cflag? "(SIG_PF)" : "(void(*)())"); - f_print(fout, "\t\t\t(void) alarm(_RPCSVC_CLOSEDOWN);\n"); - f_print(fout, "\t\t}\n"); + fprintf(fout, "\t\t\t(void) alarm(_RPCSVC_CLOSEDOWN);\n"); + fprintf(fout, "\t\t}\n"); } - f_print(fout, "\t\tsvc_run();\n"); - f_print(fout, "\t\texit(1);\n"); - f_print(fout, "\t\t/* NOTREACHED */\n"); - f_print(fout, "\t}\n"); + fprintf(fout, "\t\tsvc_run();\n"); + fprintf(fout, "\t\texit(1);\n"); + fprintf(fout, "\t\t/* NOTREACHED */\n"); + fprintf(fout, "\t}\n"); } /* @@ -788,48 +789,48 @@ write_rpc_svc_fg(infile, sp) char *infile; char *sp; { - f_print(fout, "#ifndef RPC_SVC_FG\n"); - f_print(fout, "%sint size;\n", sp); + fprintf(fout, "#ifndef RPC_SVC_FG\n"); + fprintf(fout, "%sint size;\n", sp); if (tirpcflag) - f_print(fout, "%sstruct rlimit rl;\n", sp); + fprintf(fout, "%sstruct rlimit rl;\n", sp); if (inetdflag) - f_print(fout, "%sint pid, i;\n\n", sp); - f_print(fout, "%spid = fork();\n", sp); - f_print(fout, "%sif (pid < 0) {\n", sp); - f_print(fout, "%s\tperror(\"cannot fork\");\n", sp); - f_print(fout, "%s\texit(1);\n", sp); - f_print(fout, "%s}\n", sp); - f_print(fout, "%sif (pid)\n", sp); - f_print(fout, "%s\texit(0);\n", sp); + fprintf(fout, "%sint pid, i;\n\n", sp); + fprintf(fout, "%spid = fork();\n", sp); + fprintf(fout, "%sif (pid < 0) {\n", sp); + fprintf(fout, "%s\tperror(\"cannot fork\");\n", sp); + fprintf(fout, "%s\texit(1);\n", sp); + fprintf(fout, "%s}\n", sp); + fprintf(fout, "%sif (pid)\n", sp); + fprintf(fout, "%s\texit(0);\n", sp); /* get number of file descriptors */ if (tirpcflag) { - f_print(fout, "%srl.rlim_max = 0;\n", sp); - f_print(fout, "%sgetrlimit(RLIMIT_NOFILE, &rl);\n", sp); - f_print(fout, "%sif ((size = rl.rlim_max) == 0)\n", sp); - f_print(fout, "%s\texit(1);\n", sp); + fprintf(fout, "%srl.rlim_max = 0;\n", sp); + fprintf(fout, "%sgetrlimit(RLIMIT_NOFILE, &rl);\n", sp); + fprintf(fout, "%sif ((size = rl.rlim_max) == 0)\n", sp); + fprintf(fout, "%s\texit(1);\n", sp); } else { - f_print(fout, "%ssize = getdtablesize();\n", sp); + fprintf(fout, "%ssize = getdtablesize();\n", sp); } - f_print(fout, "%sfor (i = 0; i < size; i++)\n", sp); - f_print(fout, "%s\t(void) close(i);\n", sp); + fprintf(fout, "%sfor (i = 0; i < size; i++)\n", sp); + fprintf(fout, "%s\t(void) close(i);\n", sp); /* Redirect stderr and stdout to console */ - f_print(fout, "%si = open(\"/dev/console\", 2);\n", sp); - f_print(fout, "%s(void) dup2(i, 1);\n", sp); - f_print(fout, "%s(void) dup2(i, 2);\n", sp); + fprintf(fout, "%si = open(\"/dev/console\", 2);\n", sp); + fprintf(fout, "%s(void) dup2(i, 1);\n", sp); + fprintf(fout, "%s(void) dup2(i, 2);\n", sp); /* This removes control of the controlling terminal */ if (tirpcflag) - f_print(fout, "%ssetsid();\n", sp); + fprintf(fout, "%ssetsid();\n", sp); else { - f_print(fout, "%si = open(\"/dev/tty\", 2);\n", sp); - f_print(fout, "%sif (i >= 0) {\n", sp); - f_print(fout, "%s\t(void) ioctl(i, TIOCNOTTY, (char *)NULL);\n", sp);; - f_print(fout, "%s\t(void) close(i);\n", sp); - f_print(fout, "%s}\n", sp); + fprintf(fout, "%si = open(\"/dev/tty\", 2);\n", sp); + fprintf(fout, "%sif (i >= 0) {\n", sp); + fprintf(fout, "%s\t(void) ioctl(i, TIOCNOTTY, (char *)NULL);\n", sp);; + fprintf(fout, "%s\t(void) close(i);\n", sp); + fprintf(fout, "%s}\n", sp); } if (!logflag) open_log_file(infile, sp); - f_print(fout, "#endif\n"); + fprintf(fout, "#endif\n"); if (logflag) open_log_file(infile, sp); } @@ -844,7 +845,7 @@ open_log_file(infile, sp) s = strrchr(infile, '.'); if (s) *s = '\0'; - f_print(fout,"%sopenlog(\"%s\", LOG_PID, LOG_DAEMON);\n", sp, infile); + fprintf(fout,"%sopenlog(\"%s\", LOG_PID, LOG_DAEMON);\n", sp, infile); if (s) *s = '.'; } @@ -871,45 +872,45 @@ write_inetd_register(transp) isudp = 1; else isudp = 0; - f_print(fout, "\n"); + fprintf(fout, "\n"); if (inetdflag) { - f_print(fout, "\tif (_rpcfdtype == 0 || _rpcfdtype == %s) {\n", + fprintf(fout, "\tif (_rpcfdtype == 0 || _rpcfdtype == %s) {\n", isudp ? "SOCK_DGRAM" : "SOCK_STREAM"); } if (inetdflag && streq(transp, "tcp")) { - f_print(fout, "%s\tif (_rpcpmstart)\n", sp); + fprintf(fout, "%s\tif (_rpcpmstart)\n", sp); - f_print(fout, "%s\t\t%s = svc%s_create(%s", + fprintf(fout, "%s\t\t%s = svc%s_create(%s", sp, TRANSP, "fd", inetdflag? "sock": "RPC_ANYSOCK"); if (!isudp) - f_print(fout, ", 0, 0"); - f_print(fout, ");\n"); + fprintf(fout, ", 0, 0"); + fprintf(fout, ");\n"); - f_print(fout, "%s\telse\n", sp); + fprintf(fout, "%s\telse\n", sp); - f_print(fout, "%s\t\t%s = svc%s_create(%s", + fprintf(fout, "%s\t\t%s = svc%s_create(%s", sp, TRANSP, transp, inetdflag? "sock": "RPC_ANYSOCK"); if (!isudp) - f_print(fout, ", 0, 0"); - f_print(fout, ");\n"); + fprintf(fout, ", 0, 0"); + fprintf(fout, ");\n"); } else { - f_print(fout, "%s\t%s = svc%s_create(%s", + fprintf(fout, "%s\t%s = svc%s_create(%s", sp, TRANSP, transp, inetdflag? "sock": "RPC_ANYSOCK"); if (!isudp) - f_print(fout, ", 0, 0"); - f_print(fout, ");\n"); + fprintf(fout, ", 0, 0"); + fprintf(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); + fprintf(fout, "%s\tif (%s == NULL) {\n", sp, TRANSP); + (void) snprintf(_errbuf, sizeof _errbuf, "cannot create %s service.", transp); + (void) snprintf(tmpbuf, sizeof tmpbuf, "%s\t\t", sp); print_err_message(tmpbuf); - f_print(fout, "%s\t\texit(1);\n", sp); - f_print(fout, "%s\t}\n", sp); + fprintf(fout, "%s\t\texit(1);\n", sp); + fprintf(fout, "%s\t}\n", sp); if (inetdflag) { - f_print(fout, "%s\tif (!_rpcpmstart)\n\t", sp); - f_print(fout, "%s\tproto = IPPROTO_%s;\n", + fprintf(fout, "%s\tif (!_rpcpmstart)\n\t", sp); + fprintf(fout, "%s\tproto = IPPROTO_%s;\n", sp, isudp ? "UDP": "TCP"); } for (l = defined; l != NULL; l = l->next) { @@ -918,21 +919,21 @@ write_inetd_register(transp) continue; } for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) { - f_print(fout, "%s\tif (!svc_register(%s, %s, %s, ", + fprintf(fout, "%s\tif (!svc_register(%s, %s, %s, ", sp, TRANSP, def->def_name, vp->vers_name); pvname(def->def_name, vp->vers_num); if (inetdflag) - f_print(fout, ", proto)) {\n"); + fprintf(fout, ", proto)) {\n"); else - f_print(fout, ", IPPROTO_%s)) {\n", + fprintf(fout, ", IPPROTO_%s)) {\n", isudp ? "UDP": "TCP"); - (void) sprintf(_errbuf, "unable to register (%s, %s, %s).", + (void) snprintf(_errbuf, sizeof _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); - f_print(fout, "%s\t}\n", sp); + fprintf(fout, "%s\t\texit(1);\n", sp); + fprintf(fout, "%s\t}\n", sp); } } if (inetdflag) - f_print(fout, "\t}\n"); + fprintf(fout, "\t}\n"); } diff --git a/usr.bin/rpcgen/rpc_tblout.c b/usr.bin/rpcgen/rpc_tblout.c index d2eeb4140ff..8df03cfed8b 100644 --- a/usr.bin/rpcgen/rpc_tblout.c +++ b/usr.bin/rpcgen/rpc_tblout.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rpc_tblout.c,v 1.8 2002/02/16 21:27:51 millert Exp $ */ +/* $OpenBSD: rpc_tblout.c,v 1.9 2002/06/01 01:40:38 deraadt Exp $ */ /* $NetBSD: rpc_tblout.c,v 1.3 1995/06/24 15:00:15 pk Exp $ */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for @@ -67,7 +67,7 @@ write_tables() definition *def; list *l; - f_print(fout, "\n"); + fprintf(fout, "\n"); for (l = defined; l != NULL; l = l->next) { def = (definition *) l->val; if (def->def_kind == DEF_PROGRAM) @@ -88,24 +88,24 @@ write_table(def) for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) { warning = 0; - s_print(progvers, "%s_%s", + snprintf(progvers, sizeof progvers, "%s_%s", locase(def->def_name), vp->vers_num); /* print the table header */ - f_print(fout, tbl_hdr, progvers); + fprintf(fout, tbl_hdr, progvers); if (nullproc(vp->procs)) { expected = 0; } else { expected = 1; - f_print(fout, null_entry); + fprintf(fout, null_entry); } for (proc = vp->procs; proc != NULL; proc = proc->next) { current = atoi(proc->proc_num); if (current != expected++) { - f_print(fout, + fprintf(fout, "\n/*\n * WARNING: table out of order\n */\n"); if (warning == 0) { - f_print(stderr, + fprintf(stderr, "WARNING %s table is out of order\n", progvers); warning = 1; @@ -113,17 +113,17 @@ write_table(def) } expected = current + 1; } - f_print(fout, "\n\t(char *(*)())RPCGEN_ACTION("); + fprintf(fout, "\n\t(char *(*)())RPCGEN_ACTION("); /* routine to invoke */ if (!newstyle) pvname_svc(proc->proc_name, vp->vers_num); else { if (newstyle) - f_print(fout, "_"); /* calls internal func */ + fprintf(fout, "_"); /* calls internal func */ pvname(proc->proc_name, vp->vers_num); } - f_print(fout, "),\n"); + fprintf(fout, "),\n"); /* argument info */ if (proc->arg_num > 1) @@ -137,8 +137,8 @@ write_table(def) } /* print the table trailer */ - f_print(fout, tbl_end); - f_print(fout, tbl_nproc, progvers, progvers, progvers); + fprintf(fout, tbl_end); + fprintf(fout, tbl_nproc, progvers, progvers, progvers); } } @@ -154,15 +154,15 @@ printit(prefix, type) len += TABSIZE - 1; /* round up to tabs required */ tabs = (TABSTOP - len + TABSIZE - 1)/TABSIZE; - f_print(fout, "%s", &tabstr[TABCOUNT-tabs]); + fprintf(fout, "%s", &tabstr[TABCOUNT-tabs]); if (streq(type, "void")) { - f_print(fout, "0"); + fprintf(fout, "0"); } else { - f_print(fout, "sizeof ("); + fprintf(fout, "sizeof ("); /* XXX: should "follow" be 1 ??? */ ptype(prefix, type, 0); - f_print(fout, ")"); + fprintf(fout, ")"); } - f_print(fout, ",\n"); + fprintf(fout, ",\n"); } diff --git a/usr.bin/rpcgen/rpc_util.c b/usr.bin/rpcgen/rpc_util.c index 527590c07fc..ee41487f56e 100644 --- a/usr.bin/rpcgen/rpc_util.c +++ b/usr.bin/rpcgen/rpc_util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rpc_util.c,v 1.8 2002/02/16 21:27:51 millert Exp $ */ +/* $OpenBSD: rpc_util.c,v 1.9 2002/06/01 01:40:38 deraadt Exp $ */ /* $NetBSD: rpc_util.c,v 1.6 1995/08/29 23:05:57 cgd Exp $ */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for @@ -181,17 +181,17 @@ ptype(prefix, type, follow) { if (prefix != NULL) { if (streq(prefix, "enum")) { - f_print(fout, "enum "); + fprintf(fout, "enum "); } else { - f_print(fout, "struct "); + fprintf(fout, "struct "); } } if (streq(type, "bool")) { - f_print(fout, "bool_t "); + fprintf(fout, "bool_t "); } else if (streq(type, "string")) { - f_print(fout, "char *"); + fprintf(fout, "char *"); } else { - f_print(fout, "%s ", follow ? fixtype(type) : type); + fprintf(fout, "%s ", follow ? fixtype(type) : type); } } @@ -253,7 +253,7 @@ pvname_svc(pname, vnum) char *pname; char *vnum; { - f_print(fout, "%s_%s_svc", locase(pname), vnum); + fprintf(fout, "%s_%s_svc", locase(pname), vnum); } void @@ -261,7 +261,7 @@ pvname(pname, vnum) char *pname; char *vnum; { - f_print(fout, "%s_%s", locase(pname), vnum); + fprintf(fout, "%s_%s", locase(pname), vnum); } /* @@ -272,8 +272,8 @@ error(msg) char *msg; { printwhere(); - f_print(stderr, "%s, line %d: ", infilename, linenum); - f_print(stderr, "%s\n", msg); + fprintf(stderr, "%s, line %d: ", infilename, linenum); + fprintf(stderr, "%s\n", msg); crash(); } @@ -299,7 +299,7 @@ record_open(file) if (nfiles < NFILES) { outfiles[nfiles++] = file; } else { - f_print(stderr, "too many files!\n"); + fprintf(stderr, "too many files!\n"); crash(); } } @@ -314,7 +314,7 @@ void expected1(exp1) tok_kind exp1; { - s_print(expectbuf, "expected '%s'", + snprintf(expectbuf, sizeof expectbuf, "expected '%s'", toktostr(exp1)); error(expectbuf); } @@ -326,7 +326,7 @@ void expected2(exp1, exp2) tok_kind exp1, exp2; { - s_print(expectbuf, "expected '%s' or '%s'", + snprintf(expectbuf, sizeof expectbuf, "expected '%s' or '%s'", toktostr(exp1), toktostr(exp2)); error(expectbuf); @@ -339,7 +339,7 @@ void expected3(exp1, exp2, exp3) tok_kind exp1, exp2, exp3; { - s_print(expectbuf, "expected '%s', '%s' or '%s'", + snprintf(expectbuf, sizeof expectbuf, "expected '%s', '%s' or '%s'", toktostr(exp1), toktostr(exp2), toktostr(exp3)); @@ -453,13 +453,14 @@ make_argname(pname, vname) char *vname; { char *name; + int len = strlen(pname) + strlen(vname) + strlen(ARGEXT) + 3; - name = (char *)malloc(strlen(pname) + strlen(vname) + strlen(ARGEXT) + 3); + name = (char *)malloc(len); if (!name) { fprintf(stderr, "failed in malloc"); exit(1); } - sprintf(name, "%s_%s_%s", locase(pname), vname, ARGEXT); + snprintf(name, len, "%s_%s_%s", locase(pname), vname, ARGEXT); return(name); } diff --git a/usr.bin/rpcgen/rpc_util.h b/usr.bin/rpcgen/rpc_util.h index e1ad01fad29..2d2f8079278 100644 --- a/usr.bin/rpcgen/rpc_util.h +++ b/usr.bin/rpcgen/rpc_util.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rpc_util.h,v 1.9 2002/02/16 21:27:51 millert Exp $ */ +/* $OpenBSD: rpc_util.h,v 1.10 2002/06/01 01:40:38 deraadt Exp $ */ /* $NetBSD: rpc_util.h,v 1.3 1995/06/11 21:50:10 pk Exp $ */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for @@ -39,9 +39,6 @@ #define alloc(size) (void *)malloc((unsigned)(size)) #define ALLOC(object) (object *) malloc(sizeof(object)) -#define s_print (void) sprintf -#define f_print (void) fprintf - struct list { definition *val; struct list *next; |