summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordwmalone <dwmalone@FreeBSD.org>2005-11-13 21:17:24 +0000
committerdwmalone <dwmalone@FreeBSD.org>2005-11-13 21:17:24 +0000
commit6a5a7b72907b572a1303984c78ec91d10d86c3c1 (patch)
tree4bf46d50853a8d9b6bab2df1457113956a446b54
parentc55cb46497a04d7bb2ce10f34883f9f546d05d86 (diff)
downloadFreeBSD-src-6a5a7b72907b572a1303984c78ec91d10d86c3c1.zip
FreeBSD-src-6a5a7b72907b572a1303984c78ec91d10d86c3c1.tar.gz
Use ANSI definitions.
Avoid using extern by declaring shared functions in header files. Const poision.
-rw-r--r--usr.bin/rpcgen/rpc_clntout.c22
-rw-r--r--usr.bin/rpcgen/rpc_cout.c118
-rw-r--r--usr.bin/rpcgen/rpc_hout.c74
-rw-r--r--usr.bin/rpcgen/rpc_main.c201
-rw-r--r--usr.bin/rpcgen/rpc_parse.c55
-rw-r--r--usr.bin/rpcgen/rpc_parse.h40
-rw-r--r--usr.bin/rpcgen/rpc_sample.c23
-rw-r--r--usr.bin/rpcgen/rpc_scan.c104
-rw-r--r--usr.bin/rpcgen/rpc_scan.h2
-rw-r--r--usr.bin/rpcgen/rpc_svcout.c103
-rw-r--r--usr.bin/rpcgen/rpc_tblout.c12
-rw-r--r--usr.bin/rpcgen/rpc_util.c110
-rw-r--r--usr.bin/rpcgen/rpc_util.h62
13 files changed, 352 insertions, 574 deletions
diff --git a/usr.bin/rpcgen/rpc_clntout.c b/usr.bin/rpcgen/rpc_clntout.c
index 14e97fc..713cba1 100644
--- a/usr.bin/rpcgen/rpc_clntout.c
+++ b/usr.bin/rpcgen/rpc_clntout.c
@@ -48,8 +48,6 @@ __FBSDID("$FreeBSD$");
#include "rpc_scan.h"
#include "rpc_util.h"
-extern void pdeclaration( char *, declaration *, int, char * );
-void printarglist( proc_list *, char *, char *, char *);
static void write_program( definition * );
static void printbody( proc_list * );
@@ -60,7 +58,7 @@ static char RESULT[] = "clnt_res";
void
-write_stubs()
+write_stubs(void)
{
list *l;
definition *def;
@@ -78,8 +76,7 @@ write_stubs()
}
static void
-write_program(def)
- definition *def;
+write_program(definition *def)
{
version_list *vp;
proc_list *proc;
@@ -114,10 +111,9 @@ write_program(def)
/* sample addargname = "clnt"; sample addargtype = "CLIENT * " */
-void printarglist(proc, result, addargname, addargtype)
- proc_list *proc;
- char *result;
- char* addargname, * addargtype;
+void
+printarglist(proc_list *proc, const char *result, const char *addargname,
+ const char *addargtype)
{
decl_list *l;
@@ -161,9 +157,8 @@ void printarglist(proc, result, addargname, addargtype)
-static char *
-ampr(type)
- char *type;
+static const char *
+ampr(const char *type)
{
if (isvectordef(type, REL_ALIAS)) {
return ("");
@@ -173,8 +168,7 @@ ampr(type)
}
static void
-printbody(proc)
- proc_list *proc;
+printbody(proc_list *proc)
{
decl_list *l;
bool_t args2 = (proc->arg_num > 1);
diff --git a/usr.bin/rpcgen/rpc_cout.c b/usr.bin/rpcgen/rpc_cout.c
index 5c7d615..c72edc6 100644
--- a/usr.bin/rpcgen/rpc_cout.c
+++ b/usr.bin/rpcgen/rpc_cout.c
@@ -63,8 +63,7 @@ static void emit_single_in_line( int, declaration *, int, relation );
* Emit the C-routine for the given definition
*/
void
-emit(def)
- definition *def;
+emit(definition *def)
{
if (def->def_kind == DEF_CONST) {
return;
@@ -105,9 +104,7 @@ emit(def)
}
static int
-findtype(def, type)
- definition *def;
- char *type;
+findtype(definition *def, const char *type)
{
if (def->def_kind == DEF_PROGRAM || def->def_kind == DEF_CONST) {
@@ -118,8 +115,7 @@ findtype(def, type)
}
static int
-undefined(type)
- char *type;
+undefined(const char *type)
{
definition *def;
@@ -129,9 +125,7 @@ undefined(type)
static void
-print_generic_header(procname, pointerp)
- char* procname;
- int pointerp;
+print_generic_header(const char *procname, int pointerp)
{
f_print(fout, "\n");
f_print(fout, "bool_t\n");
@@ -144,8 +138,7 @@ print_generic_header(procname, pointerp)
}
static void
-print_header(def)
- definition *def;
+print_header(definition *def)
{
print_generic_header(def->def_name,
def->def_kind != DEF_TYPEDEF ||
@@ -160,14 +153,13 @@ print_header(def)
}
static void
-print_prog_header(plist)
- proc_list *plist;
+print_prog_header(proc_list *plist)
{
print_generic_header(plist->args.argname, 1);
}
static void
-print_trailer()
+print_trailer(void)
{
f_print(fout, "\treturn (TRUE);\n");
f_print(fout, "}\n");
@@ -175,26 +167,20 @@ print_trailer()
static void
-print_ifopen(indent, name)
- int indent;
- char *name;
+print_ifopen(int indent, const char *name)
{
tabify(fout, indent);
f_print(fout, "if (!xdr_%s(xdrs", name);
}
static void
-print_ifarg(arg)
- char *arg;
+print_ifarg(const char *arg)
{
f_print(fout, ", %s", arg);
}
static void
-print_ifsizeof(indent, prefix, type)
- int indent;
- char *prefix;
- char *type;
+print_ifsizeof(int indent, const char *prefix, const char *type)
{
if (indent) {
f_print(fout, ",\n");
@@ -214,8 +200,7 @@ print_ifsizeof(indent, prefix, type)
}
static void
-print_ifclose(indent)
- int indent;
+print_ifclose(int indent)
{
f_print(fout, "))\n");
tabify(fout, indent);
@@ -223,16 +208,10 @@ print_ifclose(indent)
}
static void
-print_ifstat(indent, prefix, type, rel, amax, objname, name)
- int indent;
- char *prefix;
- char *type;
- relation rel;
- char *amax;
- char *objname;
- char *name;
+print_ifstat(int indent, const char *prefix, const char *type, relation rel,
+ const char *amax, const char *objname, const char *name)
{
- char *alt = NULL;
+ const char *alt = NULL;
switch (rel) {
case REL_POINTER:
@@ -300,8 +279,7 @@ print_ifstat(indent, prefix, type, rel, amax, objname, name)
/* ARGSUSED */
static void
-emit_enum(def)
- definition *def;
+emit_enum(definition *def __unused)
{
print_ifopen(1, "enum");
print_ifarg("(enum_t *)objp");
@@ -309,8 +287,7 @@ emit_enum(def)
}
static void
-emit_program(def)
- definition *def;
+emit_program(definition *def)
{
decl_list *dl;
version_list *vlist;
@@ -330,15 +307,14 @@ emit_program(def)
static void
-emit_union(def)
- definition *def;
+emit_union(definition *def)
{
declaration *dflt;
case_list *cl;
declaration *cs;
char *object;
- char *vecformat = "objp->%s_u.%s";
- char *format = "&objp->%s_u.%s";
+ const char *vecformat = "objp->%s_u.%s";
+ const 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);
@@ -395,15 +371,14 @@ emit_union(def)
}
static void
-inline_struct(def, flag)
-definition *def;
-int flag;
+inline_struct(definition *def, int flag)
{
decl_list *dl;
int i, size;
decl_list *cur, *psav;
bas_type *ptr;
- char *sizestr, *plus;
+ char *sizestr;
+ const char *plus;
char ptemp[256];
int indent = 1;
@@ -554,8 +529,7 @@ int flag;
}
static void
-emit_struct(def)
- definition *def;
+emit_struct(definition *def)
{
decl_list *dl;
int j, size, flag;
@@ -624,25 +598,22 @@ emit_struct(def)
}
static void
-emit_typedef(def)
- definition *def;
+emit_typedef(definition *def)
{
- char *prefix = def->def.ty.old_prefix;
- char *type = def->def.ty.old_type;
- char *amax = def->def.ty.array_max;
+ const char *prefix = def->def.ty.old_prefix;
+ const char *type = def->def.ty.old_type;
+ const char *amax = def->def.ty.array_max;
relation rel = def->def.ty.rel;
print_ifstat(1, prefix, type, rel, amax, "objp", def->def_name);
}
static void
-print_stat(indent, dec)
- int indent;
- declaration *dec;
+print_stat(int indent, declaration *dec)
{
- char *prefix = dec->prefix;
- char *type = dec->type;
- char *amax = dec->array_max;
+ const char *prefix = dec->prefix;
+ const char *type = dec->type;
+ const char *amax = dec->array_max;
relation rel = dec->rel;
char name[256];
@@ -655,13 +626,10 @@ print_stat(indent, dec)
}
-char *upcase ();
+char *upcase(const char *);
static void
-emit_inline(indent, decl, flag)
-int indent;
-declaration *decl;
-int flag;
+emit_inline(int indent, declaration *decl, int flag)
{
switch (decl->rel) {
case REL_ALIAS :
@@ -689,14 +657,9 @@ int flag;
}
static void
-emit_single_in_line(indent, decl, flag, rel)
-int indent;
-declaration *decl;
-int flag;
-relation rel;
+emit_single_in_line(int indent, declaration *decl, int flag, relation rel)
{
char *upp_case;
- int freed = 0;
tabify(fout, indent);
if (flag == PUT)
@@ -713,15 +676,13 @@ relation rel;
if (strcmp(upp_case, "INT") == 0)
{
free(upp_case);
- freed = 1;
- upp_case = "LONG";
+ upp_case = strdup("LONG");
}
if (strcmp(upp_case, "U_INT") == 0)
{
free(upp_case);
- freed = 1;
- upp_case = "U_LONG";
+ upp_case = strdup("U_LONG");
}
if (flag == PUT)
if (rel == REL_ALIAS)
@@ -732,12 +693,11 @@ relation rel;
else
f_print(fout, "%s(buf);\n", upp_case);
- if (!freed)
- free(upp_case);
+ free(upp_case);
}
-char *upcase(str)
-char *str;
+char *
+upcase(const char *str)
{
char *ptr, *hptr;
diff --git a/usr.bin/rpcgen/rpc_hout.c b/usr.bin/rpcgen/rpc_hout.c
index 2bb320c..7068363 100644
--- a/usr.bin/rpcgen/rpc_hout.c
+++ b/usr.bin/rpcgen/rpc_hout.c
@@ -47,19 +47,17 @@ __FBSDID("$FreeBSD$");
#include "rpc_scan.h"
#include "rpc_util.h"
-void storexdrfuncdecl( char *, int );
+void storexdrfuncdecl(const char *, int );
static void pconstdef( definition * );
static void pstructdef( definition * );
static void puniondef( definition * );
static void pprogramdef( definition *, int );
-static void pstructdef( definition * );
static void penumdef( definition * );
static void ptypedef( definition * );
-static void pdefine( char *, char * );
-static int undefined2( char *, char * );
-static void parglist( proc_list *, char * );
-static void pprocdef( proc_list *, version_list *, char *, int );
-void pdeclaration( char *, declaration *, int, char * );
+static void pdefine(const char *, const char *);
+static int undefined2(const char *, const char *);
+static void parglist(proc_list *, const char *);
+static void pprocdef(proc_list *, version_list *, const char *, int);
/*
* Print the C-version of an xdr definition
@@ -120,9 +118,7 @@ print_funcdef(definition *def, int headeronly)
out at the end of the file */
void
-storexdrfuncdecl(name, pointerp)
-char *name;
-int pointerp;
+storexdrfuncdecl(const char *name, int pointerp)
{
xdrfunc * xdrptr;
@@ -144,7 +140,7 @@ int pointerp;
}
void
-print_xdr_func_def(char *name, int pointerp)
+print_xdr_func_def(const char *name, int pointerp)
{
f_print(fout, "extern bool_t xdr_%s(XDR *, %s%s);\n", name,
name, pointerp ? "*" : "");
@@ -162,8 +158,7 @@ pconstdef(def)
header file
*/
static void
-pargdef(def)
- definition *def;
+pargdef(definition *def)
{
decl_list *l;
version_list *vers;
@@ -196,11 +191,10 @@ pargdef(def)
static void
-pstructdef(def)
- definition *def;
+pstructdef(definition *def)
{
decl_list *l;
- char *name = def->def_name;
+ const char *name = def->def_name;
f_print(fout, "struct %s {\n", name);
for (l = def->def.st.decls; l != NULL; l = l->next) {
@@ -215,7 +209,7 @@ puniondef(def)
definition *def;
{
case_list *l;
- char *name = def->def_name;
+ const char *name = def->def_name;
declaration *decl;
f_print(fout, "struct %s {\n", name);
@@ -240,25 +234,19 @@ puniondef(def)
}
static void
-pdefine(name, num)
- char *name;
- char *num;
+pdefine(const char *name, const char *num)
{
f_print(fout, "#define\t%s %s\n", name, num);
}
static void
-puldefine(name, num)
- char *name;
- char *num;
+puldefine(const char *name, const char *num)
{
f_print(fout, "#define\t%s ((unsigned long)(%s))\n", name, num);
}
static int
-define_printed(stop, start)
- proc_list *stop;
- version_list *start;
+define_printed(proc_list *stop, version_list *start)
{
version_list *vers;
proc_list *proc;
@@ -277,7 +265,7 @@ define_printed(stop, start)
}
static void
-pfreeprocdef(char * name, char *vers)
+pfreeprocdef(const char * name, const char *vers)
{
f_print(fout, "extern int ");
pvname(name, vers);
@@ -285,7 +273,7 @@ pfreeprocdef(char * name, char *vers)
}
static void
-pdispatch(char * name, char *vers)
+pdispatch(const char * name, const char *vers)
{
f_print(fout, "void ");
@@ -298,7 +286,7 @@ pprogramdef(definition *def, int headeronly)
{
version_list *vers;
proc_list *proc;
- char *ext;
+ const char *ext;
pargdef(def);
@@ -334,7 +322,7 @@ pprogramdef(definition *def, int headeronly)
}
static void
-pprocdef(proc_list *proc, version_list *vp, char *addargtype, int server_p)
+pprocdef(proc_list *proc, version_list *vp, const char *addargtype, int server_p)
{
if (mtflag) {/* Print MT style stubs */
if (server_p)
@@ -357,9 +345,7 @@ pprocdef(proc_list *proc, version_list *vp, char *addargtype, int server_p)
/* print out argument list of procedure */
static void
-parglist(proc, addargtype)
- proc_list *proc;
- char* addargtype;
+parglist(proc_list *proc, const char *addargtype)
{
decl_list *dl;
@@ -391,9 +377,9 @@ static void
penumdef(def)
definition *def;
{
- char *name = def->def_name;
+ const char *name = def->def_name;
enumval_list *l;
- char *last = NULL;
+ const char *last = NULL;
int count = 0;
f_print(fout, "enum %s {\n", name);
@@ -423,8 +409,8 @@ static void
ptypedef(def)
definition *def;
{
- char *name = def->def_name;
- char *old = def->def.ty.old_type;
+ const char *name = def->def_name;
+ const char *old = def->def.ty.old_type;
char prefix[8]; /* enough to contain "struct ", including NUL */
relation rel = def->def.ty.rel;
@@ -467,15 +453,11 @@ ptypedef(def)
}
void
-pdeclaration(name, dec, tab, separator)
- char *name;
- declaration *dec;
- int tab;
- char *separator;
+pdeclaration(const char *name, declaration *dec, int tab, const char *separator)
{
char buf[8]; /* enough to hold "struct ", include NUL */
- char *prefix;
- char *type;
+ const char *prefix;
+ const char *type;
if (streq(dec->type, "void")) {
return;
@@ -526,9 +508,7 @@ pdeclaration(name, dec, tab, separator)
}
static int
-undefined2(type, stop)
- char *type;
- char *stop;
+undefined2(const char *type, const char *stop)
{
list *l;
definition *def;
diff --git a/usr.bin/rpcgen/rpc_main.c b/usr.bin/rpcgen/rpc_main.c
index 1bf4938..5b35f54 100644
--- a/usr.bin/rpcgen/rpc_main.c
+++ b/usr.bin/rpcgen/rpc_main.c
@@ -56,16 +56,13 @@ __FBSDID("$FreeBSD$");
#include "rpc_scan.h"
#include "rpc_util.h"
-extern void write_sample_svc( definition * );
-extern int write_sample_clnt( definition * );
-extern void write_sample_clnt_main( void );
-extern void add_sample_msg( void );
-static void c_output( char *, char *, int, char * );
-static void h_output( char *, char *, int, char *, int );
-static void l_output( char *, char *, int, char * );
-static void t_output( char *, char *, int, char * );
-static void clnt_output( char *, char *, int, char * );
-void c_initialize( void );
+static void c_output(const char *, const char *, int, const char *);
+static void h_output(const char *, const char *, int, const char *, int);
+static void l_output(const char *, const char *, int, const char *);
+static void t_output(const char *, const char *, int, const char *);
+static void clnt_output(const char *, const char *, int, const char * );
+static char *generate_guard(const char *);
+static void c_initialize(void);
#if !defined(__FreeBSD__) && !defined(__NetBSD__)
char * rindex();
@@ -73,11 +70,11 @@ char * rindex();
static void usage(void);
static void options_usage(void);
-static int do_registers(int, char **);
-static int parseargs(int, char **, struct commandline *);
-static void svc_output(char *, char *, int, char *);
+static int do_registers(int, const char **);
+static int parseargs(int, const char **, struct commandline *);
+static void svc_output(const char *, const char *, int, const char *);
static void mkfile_output(struct commandline *);
-static void s_output(int, char **, char *, char *, int, char *, int, int);
+static void s_output(int, const char **, const char *, const char *, int, const char *, int, int);
#define EXTEND 1 /* alias for TRUE */
#define DONT_EXTEND 0 /* alias for FALSE */
@@ -87,15 +84,15 @@ static void s_output(int, char **, char *, char *, int, char *, int, int);
static int cppDefined = 0; /* explicit path for C preprocessor */
-static char *svcclosetime = "120";
-static char *CPP = SVR4_CPP;
-static char CPPFLAGS[] = "-C";
+static const char *svcclosetime = "120";
+static const char *CPP = SVR4_CPP;
+static const char CPPFLAGS[] = "-C";
static char pathbuf[MAXPATHLEN + 1];
-static char *allv[] = {
+static const char *allv[] = {
"rpcgen", "-s", "udp", "-s", "tcp",
};
static int allc = sizeof (allv)/sizeof (allv[0]);
-static char *allnv[] = {
+static const char *allnv[] = {
"rpcgen", "-s", "netpath",
};
static int allnc = sizeof (allnv)/sizeof (allnv[0]);
@@ -103,17 +100,18 @@ static int allnc = sizeof (allnv)/sizeof (allnv[0]);
/*
* machinations for handling expanding argument list
*/
-static void addarg(); /* add another argument to the list */
-static void putarg(); /* put argument at specified location */
-static void clear_args(); /* clear argument list */
-static void checkfiles(); /* check if out file already exists */
+static void addarg(const char *); /* add another argument to the list */
+static void putarg(int, const char *); /* put argument at specified location */
+static void clear_args(void); /* clear argument list */
+static void checkfiles(const char *, const char *);
+ /* check if out file already exists */
#define ARGLISTLEN 20
#define FIXEDARGS 2
-static char *arglist[ARGLISTLEN];
+static const char *arglist[ARGLISTLEN];
static int argcount = FIXEDARGS;
@@ -147,9 +145,7 @@ pid_t childpid;
int
-main(argc, argv)
- int argc;
- char *argv[];
+main(int argc, const char *argv[])
{
struct commandline cmd;
@@ -231,13 +227,11 @@ main(argc, argv)
* add extension to filename
*/
static char *
-extendfile(path, ext)
- char *path;
- char *ext;
+extendfile(const char *path, const char *ext)
{
char *res;
- char *p;
- char *file;
+ const char *p;
+ const char *file;
if ((file = rindex(path, '/')) == NULL)
file = path;
@@ -257,9 +251,7 @@ extendfile(path, ext)
* Open output file with given extension
*/
static void
-open_output(infile, outfile)
- char *infile;
- char *outfile;
+open_output(const char *infile, const char *outfile)
{
if (outfile == NULL) {
@@ -282,7 +274,7 @@ open_output(infile, outfile)
}
static void
-add_warning()
+add_warning(void)
{
f_print(fout, "/*\n");
f_print(fout, " * Please do not edit this file.\n");
@@ -291,7 +283,8 @@ add_warning()
}
/* clear list of arguments */
-static void clear_args()
+static void
+clear_args(void)
{
int i;
for (i = FIXEDARGS; i < ARGLISTLEN; i++)
@@ -300,7 +293,8 @@ static void clear_args()
}
/* make sure that a CPP exists */
-static void find_cpp()
+static void
+find_cpp(void)
{
struct stat buf;
@@ -322,9 +316,7 @@ static void find_cpp()
* Open input file with given define for C-preprocessor
*/
static void
-open_input(infile, define)
- char *infile;
- char *define;
+open_input(const char *infile, const char *define)
{
int pd[2];
@@ -356,7 +348,7 @@ open_input(infile, define)
}
/* valid tirpc nettypes */
-static char* valid_ti_nettypes[] =
+static const char *valid_ti_nettypes[] =
{
"netpath",
"visible",
@@ -371,16 +363,15 @@ static char* valid_ti_nettypes[] =
};
/* valid inetd nettypes */
-static char* valid_i_nettypes[] =
+static const char *valid_i_nettypes[] =
{
"udp",
"tcp",
NULL
};
-static int check_nettype(name, list_to_check)
-char* name;
-char* list_to_check[];
+static int
+check_nettype(const char *name, const char *list_to_check[])
{
int i;
for (i = 0; list_to_check[i] != NULL; i++) {
@@ -392,10 +383,8 @@ char* list_to_check[];
return (0);
}
-static char *
-file_name(file, ext)
-char *file;
-char *ext;
+static const char *
+file_name(const char *file, const char *ext)
{
char *temp;
temp = extendfile(file, ext);
@@ -403,21 +392,17 @@ char *ext;
if (access(temp, F_OK) != -1)
return (temp);
else
- return ((char *)" ");
+ return (" ");
}
static void
-c_output(infile, define, extend, outfile)
- char *infile;
- char *define;
- int extend;
- char *outfile;
+c_output(const char *infile, const char *define, int extend, const char *outfile)
{
definition *def;
char *include;
- char *outfilename;
+ const char *outfilename;
long tell;
c_initialize();
@@ -442,7 +427,7 @@ c_output(infile, define, extend, outfile)
void
-c_initialize()
+c_initialize(void)
{
/* add all the starting basic types */
@@ -456,7 +441,7 @@ c_initialize()
}
-char rpcgen_table_dcl[] = "struct rpcgen_table {\n\
+const char rpcgen_table_dcl[] = "struct rpcgen_table {\n\
char *(*proc)(); \n\
xdrproc_t xdr_arg; \n\
unsigned len_arg; \n\
@@ -465,10 +450,11 @@ char rpcgen_table_dcl[] = "struct rpcgen_table {\n\
}; \n";
-char *generate_guard(pathname)
- char* pathname;
+char *
+generate_guard(const char *pathname)
{
- char* filename, *guard, *tmp, *stopat;
+ const char *filename;
+ char *guard, *tmp, *stopat;
filename = strrchr(pathname, '/'); /* find last component */
filename = ((filename == 0) ? pathname : filename+1);
@@ -514,12 +500,12 @@ char *generate_guard(pathname)
static void
-h_output(char *infile, char *define, int extend, char *outfile, int headeronly)
+h_output(const char *infile, const char *define, int extend, const char *outfile, int headeronly)
{
definition *def;
- char *outfilename;
+ const char *outfilename;
long tell;
- char *guard;
+ const char *guard;
list *l;
xdrfunc *xdrfuncp;
@@ -600,20 +586,13 @@ h_output(char *infile, char *define, int extend, char *outfile, int headeronly)
* Compile into an RPC service
*/
static void
-s_output(argc, argv, infile, define, extend, outfile, nomain, netflag)
- int argc;
- char *argv[];
- char *infile;
- char *define;
- int extend;
- char *outfile;
- int nomain;
- int netflag;
+s_output(int argc, const char *argv[], const char *infile, const char *define,
+ int extend, const char *outfile, int nomain, int netflag)
{
char *include;
definition *def;
int foundprogram = 0;
- char *outfilename;
+ const char *outfilename;
open_input(infile, define);
outfilename = extend ? extendfile(infile, outfile) : outfile;
@@ -694,16 +673,12 @@ s_output(argc, argv, infile, define, extend, outfile, nomain, netflag)
* generate client side stubs
*/
static void
-l_output(infile, define, extend, outfile)
- char *infile;
- char *define;
- int extend;
- char *outfile;
+l_output(const char *infile, const char *define, int extend, const char *outfile)
{
char *include;
definition *def;
int foundprogram = 0;
- char *outfilename;
+ const char *outfilename;
open_input(infile, define);
outfilename = extend ? extendfile(infile, outfile) : outfile;
@@ -729,15 +704,11 @@ l_output(infile, define, extend, outfile)
* generate the dispatch table
*/
static void
-t_output(infile, define, extend, outfile)
- char *infile;
- char *define;
- int extend;
- char *outfile;
+t_output(const char *infile, const char *define, int extend, const char *outfile)
{
definition *def;
int foundprogram = 0;
- char *outfilename;
+ const char *outfilename;
open_input(infile, define);
outfilename = extend ? extendfile(infile, outfile) : outfile;
@@ -755,15 +726,11 @@ t_output(infile, define, extend, outfile)
/* sample routine for the server template */
static void
-svc_output(infile, define, extend, outfile)
- char *infile;
- char *define;
- int extend;
- char *outfile;
+svc_output(const char *infile, const char *define, int extend, const char *outfile)
{
definition *def;
char *include;
- char *outfilename;
+ const char *outfilename;
long tell;
open_input(infile, define);
outfilename = extend ? extendfile(infile, outfile) : outfile;
@@ -792,15 +759,11 @@ svc_output(infile, define, extend, outfile)
/* sample main routine for client */
static void
-clnt_output(infile, define, extend, outfile)
- char *infile;
- char *define;
- int extend;
- char *outfile;
+clnt_output(const char *infile, const char *define, int extend, const char *outfile)
{
definition *def;
char *include;
- char *outfilename;
+ const char *outfilename;
long tell;
int has_program = 0;
@@ -833,12 +796,11 @@ clnt_output(infile, define, extend, outfile)
}
-static void mkfile_output(cmd)
-struct commandline *cmd;
+static void mkfile_output(struct commandline *cmd)
{
- char *mkfilename, *clientname, *clntname, *xdrname, *hdrname;
- char *servername, *svcname, *servprogname, *clntprogname;
- char *temp;
+ const char *mkfilename, *clientname, *clntname, *xdrname, *hdrname;
+ const char *servername, *svcname, *servprogname, *clntprogname;
+ char *temp, *mkftemp;
svcname = file_name(cmd->infile, "_svc.c");
clntname = file_name(cmd->infile, "_clnt.c");
@@ -857,12 +819,13 @@ struct commandline *cmd;
clntprogname = extendfile(cmd->infile, "_client");
if (allfiles){
- mkfilename = xmalloc(strlen("makefile.") +
+ mkftemp = xmalloc(strlen("makefile.") +
strlen(cmd->infile) + 1);
temp = (char *)rindex(cmd->infile, '.');
- strcpy(mkfilename, "makefile.");
- (void) strncat(mkfilename, cmd->infile,
+ strcpy(mkftemp, "makefile.");
+ (void) strncat(mkftemp, cmd->infile,
(temp - cmd->infile));
+ mkfilename = mkftemp;
} else
mkfilename = cmd->outfile;
@@ -927,9 +890,7 @@ $(OBJECTS_SVC) $(CLIENT) $(SERVER)\n\n");
* Return 0 if failed; 1 otherwise.
*/
static int
-do_registers(argc, argv)
- int argc;
- char *argv[];
+do_registers(int argc, const char *argv[])
{
int i;
@@ -963,8 +924,7 @@ do_registers(argc, argv)
* Add another argument to the arg list
*/
static void
-addarg(cp)
- char *cp;
+addarg(const char *cp)
{
if (argcount >= ARGLISTLEN) {
warnx("too many defines");
@@ -976,16 +936,14 @@ addarg(cp)
}
static void
-putarg(where, cp)
- char *cp;
- int where;
+putarg(int place, const char *cp)
{
- if (where >= ARGLISTLEN) {
+ if (place >= ARGLISTLEN) {
warnx("arglist coding error");
crash();
/*NOTREACHED*/
}
- arglist[where] = cp;
+ arglist[place] = cp;
}
/*
@@ -995,9 +953,7 @@ putarg(where, cp)
*/
static void
-checkfiles(infile, outfile)
-char *infile;
-char *outfile;
+checkfiles(const char *infile, const char *outfile)
{
struct stat buf;
@@ -1022,10 +978,7 @@ char *outfile;
* Parse command line arguments
*/
static int
-parseargs(argc, argv, cmd)
- int argc;
- char *argv[];
- struct commandline *cmd;
+parseargs(int argc, const char *argv[], struct commandline *cmd)
{
int i;
int j;
diff --git a/usr.bin/rpcgen/rpc_parse.c b/usr.bin/rpcgen/rpc_parse.c
index a87e8a9..f7f857a 100644
--- a/usr.bin/rpcgen/rpc_parse.c
+++ b/usr.bin/rpcgen/rpc_parse.c
@@ -44,13 +44,12 @@ __FBSDID("$FreeBSD$");
#include <stdio.h>
#include <string.h>
#include "rpc/types.h"
-#include "rpc_scan.h"
#include "rpc_parse.h"
+#include "rpc_scan.h"
#include "rpc_util.h"
#define ARGNAME "arg"
-extern char *make_argname( char *, char * );
static void isdefined( definition * );
static void def_struct( definition * );
static void def_program( definition * );
@@ -60,14 +59,14 @@ static void def_union( definition * );
static void def_typedef( definition * );
static void get_declaration( declaration *, defkind );
static void get_prog_declaration( declaration *, defkind, int );
-static void get_type( char **, char **, defkind );
-static void unsigned_dec( char ** );
+static void get_type(const char **, const char **, defkind);
+static void unsigned_dec(const char ** );
/*
* return the next definition you see
*/
definition *
-get_definition()
+get_definition(void)
{
definition *defp;
token tok;
@@ -104,15 +103,13 @@ get_definition()
}
static void
-isdefined(defp)
- definition *defp;
+isdefined(definition *defp)
{
STOREVAL(&defined, defp);
}
static void
-def_struct(defp)
- definition *defp;
+def_struct(definition *defp)
{
token tok;
declaration dec;
@@ -139,8 +136,7 @@ def_struct(defp)
}
static void
-def_program(defp)
- definition *defp;
+def_program(definition *defp)
{
token tok;
declaration dec;
@@ -246,8 +242,7 @@ def_program(defp)
static void
-def_enum(defp)
- definition *defp;
+def_enum(definition *defp)
{
token tok;
enumval_list *elist;
@@ -276,8 +271,7 @@ def_enum(defp)
}
static void
-def_const(defp)
- definition *defp;
+def_const(definition *defp)
{
token tok;
@@ -290,8 +284,7 @@ def_const(defp)
}
static void
-def_union(defp)
- definition *defp;
+def_union(definition *defp)
{
token tok;
declaration dec;
@@ -360,7 +353,7 @@ def_union(defp)
}
}
-static char* reserved_words[] =
+static const char *reserved_words[] =
{
"array",
"bytes",
@@ -377,7 +370,7 @@ static char* reserved_words[] =
NULL
};
-static char* reserved_types[] =
+static const char *reserved_types[] =
{
"opaque",
"string",
@@ -389,9 +382,7 @@ static char* reserved_types[] =
* xdr routines that would conflict with internal XDR routines.
*/
static void
-check_type_name(name, new_type)
-int new_type;
-char* name;
+check_type_name(const char *name, int new_type)
{
int i;
char tmp[100];
@@ -419,8 +410,7 @@ char* name;
static void
-def_typedef(defp)
- definition *defp;
+def_typedef(definition *defp)
{
declaration dec;
@@ -435,9 +425,7 @@ def_typedef(defp)
}
static void
-get_declaration(dec, dkind)
- declaration *dec;
- defkind dkind;
+get_declaration(declaration *dec, defkind dkind)
{
token tok;
@@ -488,10 +476,7 @@ get_declaration(dec, dkind)
static void
-get_prog_declaration(dec, dkind, num)
- declaration *dec;
- defkind dkind;
- int num; /* arg number */
+get_prog_declaration(declaration *dec, defkind dkind, int num)
{
token tok;
char name[10]; /* argument name */
@@ -562,10 +547,7 @@ get_prog_declaration(dec, dkind, num)
static void
-get_type(prefixp, typep, dkind)
- char **prefixp;
- char **typep;
- defkind dkind;
+get_type(const char **prefixp, const char **typep, defkind dkind)
{
token tok;
@@ -620,8 +602,7 @@ get_type(prefixp, typep, dkind)
}
static void
-unsigned_dec(typep)
- char **typep;
+unsigned_dec(const char **typep)
{
token tok;
diff --git a/usr.bin/rpcgen/rpc_parse.h b/usr.bin/rpcgen/rpc_parse.h
index 1ddad6d..3ca874e 100644
--- a/usr.bin/rpcgen/rpc_parse.h
+++ b/usr.bin/rpcgen/rpc_parse.h
@@ -76,7 +76,7 @@ enum defkind {
};
typedef enum defkind defkind;
-typedef char *const_def;
+typedef const char *const_def;
enum relation {
REL_VECTOR, /* fixed length array */
@@ -87,16 +87,16 @@ enum relation {
typedef enum relation relation;
struct typedef_def {
- char *old_prefix;
- char *old_type;
+ const char *old_prefix;
+ const char *old_type;
relation rel;
- char *array_max;
+ const char *array_max;
};
typedef struct typedef_def typedef_def;
struct enumval_list {
- char *name;
- char *assignment;
+ const char *name;
+ const char *assignment;
struct enumval_list *next;
};
typedef struct enumval_list enumval_list;
@@ -107,11 +107,11 @@ struct enum_def {
typedef struct enum_def enum_def;
struct declaration {
- char *prefix;
- char *type;
- char *name;
+ const char *prefix;
+ const char *type;
+ const char *name;
relation rel;
- char *array_max;
+ const char *array_max;
};
typedef struct declaration declaration;
@@ -127,7 +127,7 @@ struct struct_def {
typedef struct struct_def struct_def;
struct case_list {
- char *case_name;
+ const char *case_name;
int contflag;
declaration case_decl;
struct case_list *next;
@@ -149,32 +149,32 @@ struct arg_list {
typedef struct arg_list arg_list;
struct proc_list {
- char *proc_name;
- char *proc_num;
+ const char *proc_name;
+ const char *proc_num;
arg_list args;
int arg_num;
- char *res_type;
- char *res_prefix;
+ const char *res_type;
+ const char *res_prefix;
struct proc_list *next;
};
typedef struct proc_list proc_list;
struct version_list {
- char *vers_name;
- char *vers_num;
+ const char *vers_name;
+ const char *vers_num;
proc_list *procs;
struct version_list *next;
};
typedef struct version_list version_list;
struct program_def {
- char *prog_num;
+ const char *prog_num;
version_list *versions;
};
typedef struct program_def program_def;
struct definition {
- char *def_name;
+ const char *def_name;
defkind def_kind;
union {
const_def co;
@@ -192,7 +192,7 @@ definition *get_definition(void);
struct bas_type
{
- char *name;
+ const char *name;
int length;
struct bas_type *next;
};
diff --git a/usr.bin/rpcgen/rpc_sample.c b/usr.bin/rpcgen/rpc_sample.c
index b5371b9..3a4e392 100644
--- a/usr.bin/rpcgen/rpc_sample.c
+++ b/usr.bin/rpcgen/rpc_sample.c
@@ -46,14 +46,12 @@ __FBSDID("$FreeBSD$");
static char RQSTP[] = "rqstp";
-extern void printarglist( proc_list *, char *, char *, char *);
-static void write_sample_client( char *, version_list * );
+static void write_sample_client(const char *, version_list * );
static void write_sample_server( definition * );
static void return_type( proc_list * );
void
-write_sample_svc(def)
- definition *def;
+write_sample_svc(definition *def)
{
if (def->def_kind != DEF_PROGRAM)
@@ -63,8 +61,7 @@ write_sample_svc(def)
int
-write_sample_clnt(def)
- definition *def;
+write_sample_clnt(definition *def)
{
version_list *vp;
int count = 0;
@@ -81,9 +78,7 @@ write_sample_clnt(def)
static void
-write_sample_client(program_name, vp)
- char *program_name;
- version_list *vp;
+write_sample_client(const char *program_name, version_list *vp)
{
proc_list *proc;
int i;
@@ -194,8 +189,7 @@ write_sample_client(program_name, vp)
}
static void
-write_sample_server(def)
- definition *def;
+write_sample_server(definition *def)
{
version_list *vp;
proc_list *proc;
@@ -253,14 +247,13 @@ write_sample_server(def)
static void
-return_type(plist)
- proc_list *plist;
+return_type(proc_list *plist)
{
ptype(plist->res_prefix, plist->res_type, 1);
}
void
-add_sample_msg()
+add_sample_msg(void)
{
f_print(fout, "/*\n");
f_print(fout, " * This is sample code generated by rpcgen.\n");
@@ -270,7 +263,7 @@ add_sample_msg()
}
void
-write_sample_clnt_main()
+write_sample_clnt_main(void)
{
list *l;
definition *def;
diff --git a/usr.bin/rpcgen/rpc_scan.c b/usr.bin/rpcgen/rpc_scan.c
index bea0773..421b055 100644
--- a/usr.bin/rpcgen/rpc_scan.c
+++ b/usr.bin/rpcgen/rpc_scan.c
@@ -48,8 +48,8 @@ __FBSDID("$FreeBSD$");
#include <stdio.h>
#include <ctype.h>
#include <string.h>
-#include "rpc_scan.h"
#include "rpc_parse.h"
+#include "rpc_scan.h"
#include "rpc_util.h"
#define startcomment(where) (where[0] == '/' && where[1] == '*')
@@ -59,22 +59,20 @@ static int pushed = 0; /* is a token pushed */
static token lasttok; /* last token, if pushed */
static void unget_token( token * );
-static void findstrconst( char **, char **);
-static void findchrconst( char **, char **);
-static void findconst( char **, char **);
+static void findstrconst(char **, const char **);
+static void findchrconst(char **, const char **);
+static void findconst(char **, const char **);
static void findkind( char **, token * );
static int cppline( char * );
static int directive( char * );
static void printdirective( char * );
-static void docppline( char *, int *, char ** );
+static void docppline(char *, int *, const char **);
/*
* scan expecting 1 given token
*/
void
-scan(expect, tokp)
- tok_kind expect;
- token *tokp;
+scan(tok_kind expect, token *tokp)
{
get_token(tokp);
if (tokp->kind != expect) {
@@ -86,10 +84,7 @@ scan(expect, tokp)
* scan expecting any of the 2 given tokens
*/
void
-scan2(expect1, expect2, tokp)
- tok_kind expect1;
- tok_kind expect2;
- token *tokp;
+scan2(tok_kind expect1, tok_kind expect2, token *tokp)
{
get_token(tokp);
if (tokp->kind != expect1 && tokp->kind != expect2) {
@@ -101,11 +96,7 @@ scan2(expect1, expect2, tokp)
* scan expecting any of the 3 given token
*/
void
-scan3(expect1, expect2, expect3, tokp)
- tok_kind expect1;
- tok_kind expect2;
- tok_kind expect3;
- token *tokp;
+scan3(tok_kind expect1, tok_kind expect2, tok_kind expect3, token *tokp)
{
get_token(tokp);
if (tokp->kind != expect1 && tokp->kind != expect2
@@ -118,8 +109,7 @@ scan3(expect1, expect2, expect3, tokp)
* scan expecting a constant, possibly symbolic
*/
void
-scan_num(tokp)
- token *tokp;
+scan_num(token *tokp)
{
get_token(tokp);
switch (tokp->kind) {
@@ -134,8 +124,7 @@ scan_num(tokp)
* Peek at the next token
*/
void
-peek(tokp)
- token *tokp;
+peek(token *tokp)
{
get_token(tokp);
unget_token(tokp);
@@ -145,9 +134,7 @@ peek(tokp)
* Peek at the next token and scan it if it matches what you expect
*/
int
-peekscan(expect, tokp)
- tok_kind expect;
- token *tokp;
+peekscan(tok_kind expect, token *tokp)
{
peek(tokp);
if (tokp->kind == expect) {
@@ -161,8 +148,7 @@ peekscan(expect, tokp)
* Get the next token, printing out any directive that are encountered.
*/
void
-get_token(tokp)
- token *tokp;
+get_token(token *tokp)
{
int commenting;
int stat = 0;
@@ -322,19 +308,17 @@ get_token(tokp)
}
static void
-unget_token(tokp)
- token *tokp;
+unget_token(token *tokp)
{
lasttok = *tokp;
pushed = 1;
}
static void
-findstrconst(str, val)
- char **str;
- char **val;
+findstrconst(char **str, const char **val)
{
char *p;
+ char *tmp;
int size;
p = *str;
@@ -346,18 +330,18 @@ findstrconst(str, val)
}
p++;
size = p - *str;
- *val = xmalloc(size + 1);
- (void) strncpy(*val, *str, size);
- (*val)[size] = 0;
+ tmp = xmalloc(size + 1);
+ (void) strncpy(tmp, *str, size);
+ tmp[size] = 0;
+ *val = tmp;
*str = p;
}
static void
-findchrconst(str, val)
- char **str;
- char **val;
+findchrconst(char **str, const char **val)
{
char *p;
+ char *tmp;
int size;
p = *str;
@@ -372,18 +356,18 @@ findchrconst(str, val)
if (size != 3) {
error("empty char string");
}
- *val = xmalloc(size + 1);
- (void) strncpy(*val, *str, size);
- (*val)[size] = 0;
+ tmp = xmalloc(size + 1);
+ (void) strncpy(tmp, *str, size);
+ tmp[size] = 0;
+ *val = tmp;
*str = p;
}
static void
-findconst(str, val)
- char **str;
- char **val;
+findconst(char **str, const char **val)
{
char *p;
+ char *tmp;
int size;
p = *str;
@@ -398,9 +382,10 @@ findconst(str, val)
} while (isdigit(*p));
}
size = p - *str;
- *val = xmalloc(size + 1);
- (void) strncpy(*val, *str, size);
- (*val)[size] = 0;
+ tmp = xmalloc(size + 1);
+ (void) strncpy(tmp, *str, size);
+ tmp[size] = 0;
+ *val = tmp;
*str = p;
}
@@ -432,13 +417,11 @@ static token symbols[] = {
};
static void
-findkind(mark, tokp)
- char **mark;
- token *tokp;
+findkind(char **mark, token *tokp)
{
int len;
token *s;
- char *str;
+ char *str, *tmp;
str = *mark;
for (s = symbols; s->kind != TOK_EOF; s++) {
@@ -454,38 +437,33 @@ findkind(mark, tokp)
}
tokp->kind = TOK_IDENT;
for (len = 0; isalnum(str[len]) || str[len] == '_'; len++);
- tokp->str = xmalloc(len + 1);
- (void) strncpy(tokp->str, str, len);
- tokp->str[len] = 0;
+ tmp = xmalloc(len + 1);
+ (void) strncpy(tmp, str, len);
+ tmp[len] = 0;
+ tokp->str = tmp;
*mark = str + len;
}
static int
-cppline(line)
- char *line;
+cppline(char *line)
{
return (line == curline && *line == '#');
}
static int
-directive(line)
- char *line;
+directive(char *line)
{
return (line == curline && *line == '%');
}
static void
-printdirective(line)
- char *line;
+printdirective(char *line)
{
f_print(fout, "%s", line + 1);
}
static void
-docppline(line, lineno, fname)
- char *line;
- int *lineno;
- char **fname;
+docppline(char *line, int *lineno, const char **fname)
{
char *file;
int num;
diff --git a/usr.bin/rpcgen/rpc_scan.h b/usr.bin/rpcgen/rpc_scan.h
index 71f995c..a57eb3b 100644
--- a/usr.bin/rpcgen/rpc_scan.h
+++ b/usr.bin/rpcgen/rpc_scan.h
@@ -119,7 +119,7 @@ typedef enum tok_kind tok_kind;
*/
struct token {
tok_kind kind;
- char *str;
+ const char *str;
};
typedef struct token token;
diff --git a/usr.bin/rpcgen/rpc_svcout.c b/usr.bin/rpcgen/rpc_svcout.c
index 5b6d0c7..b8fcbd7 100644
--- a/usr.bin/rpcgen/rpc_svcout.c
+++ b/usr.bin/rpcgen/rpc_svcout.c
@@ -47,8 +47,6 @@ __FBSDID("$FreeBSD$");
#include "rpc_scan.h"
#include "rpc_util.h"
-extern int tirpc_socket;
-
static char RQSTP[] = "rqstp";
static char TRANSP[] = "transp";
static char ARG[] = "argument";
@@ -60,33 +58,29 @@ char _errbuf[256]; /* For all messages */
void internal_proctype( proc_list * );
static void write_real_program( definition * );
-static void write_program( definition *, char * );
-static void printerr( char *, char * );
-static void printif( char *, char *, char *, char * );
-static void write_inetmost( char * );
-static void print_return( char * );
-static void print_pmapunset( char * );
-static void print_err_message( char * );
+static void write_program(definition *, const char *);
+static void printerr(const char *, const char *);
+static void printif(const char *, const char *, const char *, const char *);
+static void write_inetmost(const char *);
+static void print_return(const char *);
+static void print_pmapunset(const char *);
+static void print_err_message(const char *);
static void write_timeout_func( void );
-static void write_pm_most( char *, int );
-static void write_rpc_svc_fg( char *, char * );
-static void open_log_file( char *, char * );
+static void write_pm_most(const char *, int);
+static void write_rpc_svc_fg(const char *, const char *);
+static void open_log_file(const char *, const char *);
static void write_msg_out( void );
-int nullproc( proc_list * );
static void
-p_xdrfunc(rname, typename)
-char* rname;
-char* typename;
+p_xdrfunc(const char *rname, const char *typename)
{
f_print(fout, "\t\txdr_%s = (xdrproc_t) xdr_%s;\n",
rname, stringfix(typename));
}
void
-internal_proctype(plist)
- proc_list *plist;
+internal_proctype(proc_list *plist)
{
f_print(fout, "static ");
ptype(plist->res_prefix, plist->res_type, 1);
@@ -98,13 +92,10 @@ internal_proctype(plist)
* write most of the service, that is, everything but the registrations.
*/
void
-write_most(infile, netflag, nomain)
- char *infile; /* our name */
- int netflag;
- int nomain;
+write_most(const char *infile, int netflag, int nomain)
{
if (inetdflag || pmflag) {
- char* var_type;
+ const 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");
@@ -195,13 +186,12 @@ serviced */\n");
* write a registration for the given transport
*/
void
-write_netid_register(transp)
- char *transp;
+write_netid_register(const char *transp)
{
list *l;
definition *def;
version_list *vp;
- char *sp;
+ const char *sp;
char tmpbuf[32];
sp = "";
@@ -257,8 +247,7 @@ write_netid_register(transp)
* write a registration for the given transport for TLI
*/
void
-write_nettype_register(transp)
- char *transp;
+write_nettype_register(const char *transp)
{
list *l;
definition *def;
@@ -292,7 +281,7 @@ write_nettype_register(transp)
* write the rest of the service
*/
void
-write_rest()
+write_rest(void)
{
f_print(fout, "\n");
if (inetdflag) {
@@ -319,8 +308,7 @@ alarm(_RPCSVC_CLOSEDOWN/2);\n");
}
void
-write_programs(storage)
- char *storage;
+write_programs(const char *storage)
{
list *l;
definition *def;
@@ -351,8 +339,7 @@ write_programs(storage)
* expected by printmsg_1.
*/
static void
-write_real_program(def)
- definition *def;
+write_real_program(definition *def)
{
version_list *vp;
proc_list *proc;
@@ -406,9 +393,7 @@ write_real_program(def)
}
static void
-write_program(def, storage)
- definition *def;
- char *storage;
+write_program(definition *def, const char *storage)
{
version_list *vp;
proc_list *proc;
@@ -579,27 +564,21 @@ write_program(def, storage)
}
static void
-printerr(err, transp)
- char *err;
- char *transp;
+printerr(const char *err, const char *transp)
{
f_print(fout, "\t\tsvcerr_%s(%s);\n", err, transp);
}
static void
-printif(proc, transp, prefix, arg)
- char *proc;
- char *transp;
- char *prefix;
- char *arg;
+printif(const char *proc, const char *transp, const char *prefix,
+ const char *arg)
{
f_print(fout, "\tif (!svc_%s(%s, xdr_%s, (char *)%s%s)) {\n",
proc, transp, arg, prefix, arg);
}
int
-nullproc(proc)
- proc_list *proc;
+nullproc(proc_list *proc)
{
for (; proc != NULL; proc = proc->next) {
if (streq(proc->proc_num, "0")) {
@@ -610,8 +589,7 @@ nullproc(proc)
}
static void
-write_inetmost(infile)
- char *infile;
+write_inetmost(const char *infile)
{
f_print(fout, "\tregister SVCXPRT *%s;\n", TRANSP);
f_print(fout, "\tint sock;\n");
@@ -639,8 +617,7 @@ write_inetmost(infile)
}
static void
-print_return(space)
- char *space;
+print_return(const char *space)
{
if (exitnow)
f_print(fout, "%sexit(0);\n", space);
@@ -657,8 +634,7 @@ print_return(space)
}
static void
-print_pmapunset(space)
- char *space;
+print_pmapunset(const char *space)
{
list *l;
definition *def;
@@ -677,8 +653,7 @@ print_pmapunset(space)
}
static void
-print_err_message(space)
- char *space;
+print_err_message(const char *space)
{
if (logflag)
f_print(fout, "%ssyslog(LOG_ERR, \"%s\");\n", space, _errbuf);
@@ -692,8 +667,7 @@ print_err_message(space)
* Write the server auxiliary function (_msgout, timeout)
*/
void
-write_svc_aux(nomain)
- int nomain;
+write_svc_aux(int nomain)
{
if (!logflag)
write_msg_out();
@@ -793,9 +767,7 @@ write_timeout_func(void)
* Write the most of port monitor support
*/
static void
-write_pm_most(infile, netflag)
- char *infile;
- int netflag;
+write_pm_most(const char *infile, int netflag)
{
list *l;
definition *def;
@@ -918,9 +890,7 @@ getenv(\"NLSPROVIDER\")) == NULL) {\n");
* Support for backgrounding the server if self started.
*/
static void
-write_rpc_svc_fg(infile, sp)
- char *infile;
- char *sp;
+write_rpc_svc_fg(const char *infile, const char *sp)
{
f_print(fout, "#ifndef RPC_SVC_FG\n");
f_print(fout, "%sint size;\n", sp);
@@ -970,9 +940,7 @@ write_rpc_svc_fg(infile, sp)
}
static void
-open_log_file(infile, sp)
- char *infile;
- char *sp;
+open_log_file(const char *infile, const char *sp)
{
char *s;
@@ -991,13 +959,12 @@ open_log_file(infile, sp)
* write a registration for the given transport for Inetd
*/
void
-write_inetd_register(transp)
- char *transp;
+write_inetd_register(const char *transp)
{
list *l;
definition *def;
version_list *vp;
- char *sp;
+ const char *sp;
int isudp;
char tmpbuf[32];
diff --git a/usr.bin/rpcgen/rpc_tblout.c b/usr.bin/rpcgen/rpc_tblout.c
index a84facd..f96bdfc 100644
--- a/usr.bin/rpcgen/rpc_tblout.c
+++ b/usr.bin/rpcgen/rpc_tblout.c
@@ -64,12 +64,11 @@ static char null_entry[] = "\n\t(char *(*)())0,\n\
static char tbl_nproc[] = "int %s_nproc =\n\tsizeof(%s_table)/sizeof(%s_table[0]);\n\n";
-extern int nullproc( proc_list * );
static void write_table( definition * );
-static void printit( char *, char * );
+static void printit(const char *, const char *);
void
-write_tables()
+write_tables(void)
{
list *l;
definition *def;
@@ -84,8 +83,7 @@ write_tables()
}
static void
-write_table(def)
- definition *def;
+write_table(definition *def)
{
version_list *vp;
proc_list *proc;
@@ -149,9 +147,7 @@ write_table(def)
}
static void
-printit(prefix, type)
- char *prefix;
- char *type;
+printit(const char *prefix, const char *type)
{
int len;
int tabs;
diff --git a/usr.bin/rpcgen/rpc_util.c b/usr.bin/rpcgen/rpc_util.c
index 0d3fdaf..9d1c85b 100644
--- a/usr.bin/rpcgen/rpc_util.c
+++ b/usr.bin/rpcgen/rpc_util.c
@@ -46,8 +46,8 @@ __FBSDID("$FreeBSD$");
#include <stdio.h>
#include <string.h>
#include <unistd.h>
-#include "rpc_scan.h"
#include "rpc_parse.h"
+#include "rpc_scan.h"
#include "rpc_util.h"
#define ARGEXT "argument"
@@ -56,10 +56,10 @@ char curline[MAXLINESIZE]; /* current read line */
char *where = curline; /* current point in line */
int linenum = 0; /* current line number */
-char *infilename; /* input filename */
+const char *infilename; /* input filename */
#define NFILES 7
-char *outfiles[NFILES]; /* output file names */
+const char *outfiles[NFILES]; /* output file names */
int nfiles;
FILE *fout; /* file pointer of current output */
@@ -73,7 +73,7 @@ static void printwhere( void );
* Reinitialize the world
*/
void
-reinitialize()
+reinitialize(void)
{
memset(curline, 0, MAXLINESIZE);
where = curline;
@@ -85,9 +85,7 @@ reinitialize()
* string equality
*/
int
-streq(a, b)
- char *a;
- char *b;
+streq(const char *a, const char *b)
{
return (strcmp(a, b) == 0);
}
@@ -96,11 +94,7 @@ streq(a, b)
* find a value in a list
*/
definition *
-findval(lst, val, cmp)
- list *lst;
- char *val;
- int (*cmp) ();
-
+findval(list *lst, const char *val, int (*cmp)(definition *, const char *))
{
for (; lst != NULL; lst = lst->next) {
if ((*cmp) (lst->val, val)) {
@@ -114,9 +108,7 @@ findval(lst, val, cmp)
* store a value in a list
*/
void
-storeval(lstp, val)
- list **lstp;
- definition *val;
+storeval(list **lstp, definition *val)
{
list **l;
list *lst;
@@ -129,17 +121,13 @@ storeval(lstp, val)
}
static int
-findit(def, type)
- definition *def;
- char *type;
+findit(definition *def, const char *type)
{
return (streq(def->def_name, type));
}
-static char *
-fixit(type, orig)
- char *type;
- char *orig;
+static const char *
+fixit(const char *type, const char *orig)
{
definition *def;
@@ -161,16 +149,14 @@ fixit(type, orig)
}
}
-char *
-fixtype(type)
- char *type;
+const char *
+fixtype(const char *type)
{
return (fixit(type, type));
}
-char *
-stringfix(type)
- char *type;
+const char *
+stringfix(const char *type)
{
if (streq(type, "string")) {
return ("wrapstring");
@@ -180,10 +166,7 @@ stringfix(type)
}
void
-ptype(prefix, type, follow)
- char *prefix;
- char *type;
- int follow;
+ptype(const char *prefix, const char *type, int follow)
{
if (prefix != NULL) {
if (streq(prefix, "enum")) {
@@ -202,9 +185,7 @@ ptype(prefix, type, follow)
}
static int
-typedefed(def, type)
- definition *def;
- char *type;
+typedefed(definition *def, const char *type)
{
if (def->def_kind != DEF_TYPEDEF || def->def.ty.old_prefix != NULL) {
return (0);
@@ -214,9 +195,7 @@ typedefed(def, type)
}
int
-isvectordef(type, rel)
- char *type;
- relation rel;
+isvectordef(const char *type, relation rel)
{
definition *def;
@@ -242,8 +221,7 @@ isvectordef(type, rel)
}
char *
-locase(str)
- char *str;
+locase(const char *str)
{
char c;
static char buf[100];
@@ -257,17 +235,13 @@ locase(str)
}
void
-pvname_svc(pname, vnum)
- char *pname;
- char *vnum;
+pvname_svc(const char *pname, const char *vnum)
{
f_print(fout, "%s_%s_svc", locase(pname), vnum);
}
void
-pvname(pname, vnum)
- char *pname;
- char *vnum;
+pvname(const char *pname, const char *vnum)
{
f_print(fout, "%s_%s", locase(pname), vnum);
}
@@ -276,8 +250,7 @@ pvname(pname, vnum)
* print a useful (?) error message, and then die
*/
void
-error(msg)
- char *msg;
+error(const char *msg)
{
printwhere();
warnx("%s, line %d: %s", infilename, linenum, msg);
@@ -289,7 +262,7 @@ error(msg)
* die.
*/
void
-crash()
+crash(void)
{
int i;
@@ -300,8 +273,7 @@ crash()
}
void
-record_open(file)
- char *file;
+record_open(const char *file)
{
if (nfiles < NFILES) {
outfiles[nfiles++] = file;
@@ -312,14 +284,13 @@ record_open(file)
}
static char expectbuf[100];
-static char *toktostr();
+static const char *toktostr(tok_kind kind);
/*
* error, token encountered was not the expected one
*/
void
-expected1(exp1)
- tok_kind exp1;
+expected1(tok_kind exp1)
{
s_print(expectbuf, "expected '%s'",
toktostr(exp1));
@@ -330,8 +301,7 @@ expected1(exp1)
* error, token encountered was not one of two expected ones
*/
void
-expected2(exp1, exp2)
- tok_kind exp1, exp2;
+expected2(tok_kind exp1, tok_kind exp2)
{
s_print(expectbuf, "expected '%s' or '%s'",
toktostr(exp1),
@@ -343,8 +313,7 @@ expected2(exp1, exp2)
* error, token encountered was not one of 3 expected ones
*/
void
-expected3(exp1, exp2, exp3)
- tok_kind exp1, exp2, exp3;
+expected3(tok_kind exp1, tok_kind exp2, tok_kind exp3)
{
s_print(expectbuf, "expected '%s', '%s' or '%s'",
toktostr(exp1),
@@ -354,9 +323,7 @@ expected3(exp1, exp2, exp3)
}
void
-tabify(f, tab)
- FILE *f;
- int tab;
+tabify(FILE *f, int tab)
{
while (tab--) {
(void) fputc('\t', f);
@@ -401,9 +368,8 @@ static token tokstrings[] = {
{TOK_EOF, "??????"}
};
-static char *
-toktostr(kind)
- tok_kind kind;
+static const char *
+toktostr(tok_kind kind)
{
token *sp;
@@ -412,7 +378,7 @@ toktostr(kind)
}
static void
-printbuf()
+printbuf(void)
{
char c;
int i;
@@ -434,7 +400,7 @@ printbuf()
}
static void
-printwhere()
+printwhere(void)
{
int i;
char c;
@@ -456,9 +422,7 @@ printwhere()
}
char *
-make_argname(pname, vname)
- char *pname;
- char *vname;
+make_argname(const char *pname, const char *vname)
{
char *name;
@@ -471,9 +435,7 @@ bas_type *typ_list_h;
bas_type *typ_list_t;
void
-add_type(len, type)
-int len;
-char *type;
+add_type(int len, const char *type)
{
bas_type *ptr;
@@ -496,8 +458,8 @@ char *type;
}
-bas_type *find_type(type)
-char *type;
+bas_type *
+find_type(const char *type)
{
bas_type * ptr;
diff --git a/usr.bin/rpcgen/rpc_util.h b/usr.bin/rpcgen/rpc_util.h
index 11a040c..644cbea 100644
--- a/usr.bin/rpcgen/rpc_util.h
+++ b/usr.bin/rpcgen/rpc_util.h
@@ -80,7 +80,7 @@ struct list {
typedef struct list list;
struct xdrfunc {
- char *name;
+ const char *name;
int pointerp;
struct xdrfunc *next;
};
@@ -97,8 +97,8 @@ struct commandline {
int Ssflag; /* produce server sample code */
int Scflag; /* produce client sample code */
int makefileflag; /* Generate a template Makefile */
- char *infile; /* input module name */
- char *outfile; /* output module name */
+ const char *infile; /* input module name */
+ const char *outfile; /* output module name */
};
#define PUT 1
@@ -111,8 +111,9 @@ struct commandline {
extern char curline[MAXLINESIZE];
extern char *where;
extern int linenum;
+extern int tirpc_socket;
-extern char *infilename;
+extern const char *infilename;
extern FILE *fout;
extern FILE *fin;
@@ -152,35 +153,36 @@ extern pid_t childpid;
*/
void reinitialize(void);
void crash(void);
-void add_type(int len, char *type);
+void add_type(int len, const char *type);
void storeval(list **lstp, definition *val);
void *xmalloc(size_t size);
void *xrealloc(void *ptr, size_t size);
-char *xstrdup(const char *str);
+char *xstrdup(const char *);
+char *make_argname(const char *pname, const char *vname);
#define STOREVAL(list,item) \
storeval(list,item)
-definition *findval(list *lst, char *val, int (*cmp)(definition *, char *));
+definition *findval(list *lst, const char *val, int (*cmp)(definition *, const char *));
#define FINDVAL(list,item,finder) \
findval(list, item, finder)
-char *fixtype(char *type);
-char *stringfix(char *type);
-char *locase(char *str);
-void pvname_svc(char *pname, char *vnum);
-void pvname(char *pname, char *vnum);
-void ptype(char *prefix, char *type, int follow);
-int isvectordef(char *type, relation rel);
-int streq(char *a, char *b);
-void error(char *msg);
+const char *fixtype(const char *type);
+const char *stringfix(const char *type);
+char *locase(const char *str);
+void pvname_svc(const char *pname, const char *vnum);
+void pvname(const char *pname, const char *vnum);
+void ptype(const char *prefix, const char *type, int follow);
+int isvectordef(const char *type, relation rel);
+int streq(const char *a, const char *b);
+void error(const char *msg);
void expected1(tok_kind exp1);
void expected2(tok_kind exp1, tok_kind exp2);
void expected3(tok_kind exp1, tok_kind exp2, tok_kind exp3);
void tabify(FILE *f, int tab);
-void record_open(char *file);
-bas_type *find_type(char *type);
+void record_open(const char *file);
+bas_type *find_type(const char *type);
/*
* rpc_cout routines
@@ -190,27 +192,39 @@ void emit(definition *def);
/*
* rpc_hout routines
*/
+void pdeclaration(const char *name, declaration *dec, int tab, const char *separator);
void print_datadef(definition *def, int headeronly);
void print_funcdef(definition *def, int headeronly);
-void print_xdr_func_def(char* name, int pointerp);
+void print_xdr_func_def(const char* name, int pointerp);
/*
* rpc_svcout routines
*/
-void write_most(char *infile, int netflag, int nomain);
+void write_most(const char *infile, int netflag, int nomain);
void write_rest(void);
-void write_programs(char *storage);
+void write_programs(const char *storage);
void write_svc_aux(int nomain);
-void write_inetd_register(char *transp);
-void write_netid_register(char *transp);
-void write_nettype_register(char *transp);
+void write_inetd_register(const char *transp);
+void write_netid_register(const char *transp);
+void write_nettype_register(const char *transp);
+int nullproc(proc_list *proc);
/*
* rpc_clntout routines
*/
void write_stubs(void);
+void printarglist(proc_list *proc, const char *result, const char *addargname,
+ const char *addargtype);
/*
* rpc_tblout routines
*/
void write_tables(void);
+
+/*
+ * rpc_sample routines
+ */
+void write_sample_svc(definition *);
+int write_sample_clnt(definition *);
+void write_sample_clnt_main(void);
+void add_sample_msg(void);
OpenPOWER on IntegriCloud