Use ANSI definitions.

Avoid using extern by declaring shared functions in header files.
Const poision.
This commit is contained in:
David Malone 2005-11-13 21:17:24 +00:00
parent 5bbc895db6
commit e390e3af7c
13 changed files with 352 additions and 574 deletions

View File

@ -48,8 +48,6 @@ __FBSDID("$FreeBSD$");
#include "rpc_scan.h" #include "rpc_scan.h"
#include "rpc_util.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 write_program( definition * );
static void printbody( proc_list * ); static void printbody( proc_list * );
@ -60,7 +58,7 @@ static char RESULT[] = "clnt_res";
void void
write_stubs() write_stubs(void)
{ {
list *l; list *l;
definition *def; definition *def;
@ -78,8 +76,7 @@ write_stubs()
} }
static void static void
write_program(def) write_program(definition *def)
definition *def;
{ {
version_list *vp; version_list *vp;
proc_list *proc; proc_list *proc;
@ -114,10 +111,9 @@ write_program(def)
/* sample addargname = "clnt"; sample addargtype = "CLIENT * " */ /* sample addargname = "clnt"; sample addargtype = "CLIENT * " */
void printarglist(proc, result, addargname, addargtype) void
proc_list *proc; printarglist(proc_list *proc, const char *result, const char *addargname,
char *result; const char *addargtype)
char* addargname, * addargtype;
{ {
decl_list *l; decl_list *l;
@ -161,9 +157,8 @@ void printarglist(proc, result, addargname, addargtype)
static char * static const char *
ampr(type) ampr(const char *type)
char *type;
{ {
if (isvectordef(type, REL_ALIAS)) { if (isvectordef(type, REL_ALIAS)) {
return (""); return ("");
@ -173,8 +168,7 @@ ampr(type)
} }
static void static void
printbody(proc) printbody(proc_list *proc)
proc_list *proc;
{ {
decl_list *l; decl_list *l;
bool_t args2 = (proc->arg_num > 1); bool_t args2 = (proc->arg_num > 1);

View File

@ -63,8 +63,7 @@ static void emit_single_in_line( int, declaration *, int, relation );
* Emit the C-routine for the given definition * Emit the C-routine for the given definition
*/ */
void void
emit(def) emit(definition *def)
definition *def;
{ {
if (def->def_kind == DEF_CONST) { if (def->def_kind == DEF_CONST) {
return; return;
@ -105,9 +104,7 @@ emit(def)
} }
static int static int
findtype(def, type) findtype(definition *def, const char *type)
definition *def;
char *type;
{ {
if (def->def_kind == DEF_PROGRAM || def->def_kind == DEF_CONST) { if (def->def_kind == DEF_PROGRAM || def->def_kind == DEF_CONST) {
@ -118,8 +115,7 @@ findtype(def, type)
} }
static int static int
undefined(type) undefined(const char *type)
char *type;
{ {
definition *def; definition *def;
@ -129,9 +125,7 @@ undefined(type)
static void static void
print_generic_header(procname, pointerp) print_generic_header(const char *procname, int pointerp)
char* procname;
int pointerp;
{ {
f_print(fout, "\n"); f_print(fout, "\n");
f_print(fout, "bool_t\n"); f_print(fout, "bool_t\n");
@ -144,8 +138,7 @@ print_generic_header(procname, pointerp)
} }
static void static void
print_header(def) print_header(definition *def)
definition *def;
{ {
print_generic_header(def->def_name, print_generic_header(def->def_name,
def->def_kind != DEF_TYPEDEF || def->def_kind != DEF_TYPEDEF ||
@ -160,14 +153,13 @@ print_header(def)
} }
static void static void
print_prog_header(plist) print_prog_header(proc_list *plist)
proc_list *plist;
{ {
print_generic_header(plist->args.argname, 1); print_generic_header(plist->args.argname, 1);
} }
static void static void
print_trailer() print_trailer(void)
{ {
f_print(fout, "\treturn (TRUE);\n"); f_print(fout, "\treturn (TRUE);\n");
f_print(fout, "}\n"); f_print(fout, "}\n");
@ -175,26 +167,20 @@ print_trailer()
static void static void
print_ifopen(indent, name) print_ifopen(int indent, const char *name)
int indent;
char *name;
{ {
tabify(fout, indent); tabify(fout, indent);
f_print(fout, "if (!xdr_%s(xdrs", name); f_print(fout, "if (!xdr_%s(xdrs", name);
} }
static void static void
print_ifarg(arg) print_ifarg(const char *arg)
char *arg;
{ {
f_print(fout, ", %s", arg); f_print(fout, ", %s", arg);
} }
static void static void
print_ifsizeof(indent, prefix, type) print_ifsizeof(int indent, const char *prefix, const char *type)
int indent;
char *prefix;
char *type;
{ {
if (indent) { if (indent) {
f_print(fout, ",\n"); f_print(fout, ",\n");
@ -214,8 +200,7 @@ print_ifsizeof(indent, prefix, type)
} }
static void static void
print_ifclose(indent) print_ifclose(int indent)
int indent;
{ {
f_print(fout, "))\n"); f_print(fout, "))\n");
tabify(fout, indent); tabify(fout, indent);
@ -223,16 +208,10 @@ print_ifclose(indent)
} }
static void static void
print_ifstat(indent, prefix, type, rel, amax, objname, name) print_ifstat(int indent, const char *prefix, const char *type, relation rel,
int indent; const char *amax, const char *objname, const char *name)
char *prefix;
char *type;
relation rel;
char *amax;
char *objname;
char *name;
{ {
char *alt = NULL; const char *alt = NULL;
switch (rel) { switch (rel) {
case REL_POINTER: case REL_POINTER:
@ -300,8 +279,7 @@ print_ifstat(indent, prefix, type, rel, amax, objname, name)
/* ARGSUSED */ /* ARGSUSED */
static void static void
emit_enum(def) emit_enum(definition *def __unused)
definition *def;
{ {
print_ifopen(1, "enum"); print_ifopen(1, "enum");
print_ifarg("(enum_t *)objp"); print_ifarg("(enum_t *)objp");
@ -309,8 +287,7 @@ emit_enum(def)
} }
static void static void
emit_program(def) emit_program(definition *def)
definition *def;
{ {
decl_list *dl; decl_list *dl;
version_list *vlist; version_list *vlist;
@ -330,15 +307,14 @@ emit_program(def)
static void static void
emit_union(def) emit_union(definition *def)
definition *def;
{ {
declaration *dflt; declaration *dflt;
case_list *cl; case_list *cl;
declaration *cs; declaration *cs;
char *object; char *object;
char *vecformat = "objp->%s_u.%s"; const char *vecformat = "objp->%s_u.%s";
char *format = "&objp->%s_u.%s"; const char *format = "&objp->%s_u.%s";
print_stat(1, &def->def.un.enum_decl); print_stat(1, &def->def.un.enum_decl);
f_print(fout, "\tswitch (objp->%s) {\n", def->def.un.enum_decl.name); f_print(fout, "\tswitch (objp->%s) {\n", def->def.un.enum_decl.name);
@ -395,15 +371,14 @@ emit_union(def)
} }
static void static void
inline_struct(def, flag) inline_struct(definition *def, int flag)
definition *def;
int flag;
{ {
decl_list *dl; decl_list *dl;
int i, size; int i, size;
decl_list *cur, *psav; decl_list *cur, *psav;
bas_type *ptr; bas_type *ptr;
char *sizestr, *plus; char *sizestr;
const char *plus;
char ptemp[256]; char ptemp[256];
int indent = 1; int indent = 1;
@ -554,8 +529,7 @@ int flag;
} }
static void static void
emit_struct(def) emit_struct(definition *def)
definition *def;
{ {
decl_list *dl; decl_list *dl;
int j, size, flag; int j, size, flag;
@ -624,25 +598,22 @@ emit_struct(def)
} }
static void static void
emit_typedef(def) emit_typedef(definition *def)
definition *def;
{ {
char *prefix = def->def.ty.old_prefix; const char *prefix = def->def.ty.old_prefix;
char *type = def->def.ty.old_type; const char *type = def->def.ty.old_type;
char *amax = def->def.ty.array_max; const char *amax = def->def.ty.array_max;
relation rel = def->def.ty.rel; relation rel = def->def.ty.rel;
print_ifstat(1, prefix, type, rel, amax, "objp", def->def_name); print_ifstat(1, prefix, type, rel, amax, "objp", def->def_name);
} }
static void static void
print_stat(indent, dec) print_stat(int indent, declaration *dec)
int indent;
declaration *dec;
{ {
char *prefix = dec->prefix; const char *prefix = dec->prefix;
char *type = dec->type; const char *type = dec->type;
char *amax = dec->array_max; const char *amax = dec->array_max;
relation rel = dec->rel; relation rel = dec->rel;
char name[256]; char name[256];
@ -655,13 +626,10 @@ print_stat(indent, dec)
} }
char *upcase (); char *upcase(const char *);
static void static void
emit_inline(indent, decl, flag) emit_inline(int indent, declaration *decl, int flag)
int indent;
declaration *decl;
int flag;
{ {
switch (decl->rel) { switch (decl->rel) {
case REL_ALIAS : case REL_ALIAS :
@ -689,14 +657,9 @@ int flag;
} }
static void static void
emit_single_in_line(indent, decl, flag, rel) emit_single_in_line(int indent, declaration *decl, int flag, relation rel)
int indent;
declaration *decl;
int flag;
relation rel;
{ {
char *upp_case; char *upp_case;
int freed = 0;
tabify(fout, indent); tabify(fout, indent);
if (flag == PUT) if (flag == PUT)
@ -713,15 +676,13 @@ relation rel;
if (strcmp(upp_case, "INT") == 0) if (strcmp(upp_case, "INT") == 0)
{ {
free(upp_case); free(upp_case);
freed = 1; upp_case = strdup("LONG");
upp_case = "LONG";
} }
if (strcmp(upp_case, "U_INT") == 0) if (strcmp(upp_case, "U_INT") == 0)
{ {
free(upp_case); free(upp_case);
freed = 1; upp_case = strdup("U_LONG");
upp_case = "U_LONG";
} }
if (flag == PUT) if (flag == PUT)
if (rel == REL_ALIAS) if (rel == REL_ALIAS)
@ -732,12 +693,11 @@ relation rel;
else else
f_print(fout, "%s(buf);\n", upp_case); f_print(fout, "%s(buf);\n", upp_case);
if (!freed) free(upp_case);
free(upp_case);
} }
char *upcase(str) char *
char *str; upcase(const char *str)
{ {
char *ptr, *hptr; char *ptr, *hptr;

View File

@ -47,19 +47,17 @@ __FBSDID("$FreeBSD$");
#include "rpc_scan.h" #include "rpc_scan.h"
#include "rpc_util.h" #include "rpc_util.h"
void storexdrfuncdecl( char *, int ); void storexdrfuncdecl(const char *, int );
static void pconstdef( definition * ); static void pconstdef( definition * );
static void pstructdef( definition * ); static void pstructdef( definition * );
static void puniondef( definition * ); static void puniondef( definition * );
static void pprogramdef( definition *, int ); static void pprogramdef( definition *, int );
static void pstructdef( definition * );
static void penumdef( definition * ); static void penumdef( definition * );
static void ptypedef( definition * ); static void ptypedef( definition * );
static void pdefine( char *, char * ); static void pdefine(const char *, const char *);
static int undefined2( char *, char * ); static int undefined2(const char *, const char *);
static void parglist( proc_list *, char * ); static void parglist(proc_list *, const char *);
static void pprocdef( proc_list *, version_list *, char *, int ); static void pprocdef(proc_list *, version_list *, const char *, int);
void pdeclaration( char *, declaration *, int, char * );
/* /*
* Print the C-version of an xdr definition * 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 */ out at the end of the file */
void void
storexdrfuncdecl(name, pointerp) storexdrfuncdecl(const char *name, int pointerp)
char *name;
int pointerp;
{ {
xdrfunc * xdrptr; xdrfunc * xdrptr;
@ -144,7 +140,7 @@ int pointerp;
} }
void 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, f_print(fout, "extern bool_t xdr_%s(XDR *, %s%s);\n", name,
name, pointerp ? "*" : ""); name, pointerp ? "*" : "");
@ -162,8 +158,7 @@ pconstdef(def)
header file header file
*/ */
static void static void
pargdef(def) pargdef(definition *def)
definition *def;
{ {
decl_list *l; decl_list *l;
version_list *vers; version_list *vers;
@ -196,11 +191,10 @@ pargdef(def)
static void static void
pstructdef(def) pstructdef(definition *def)
definition *def;
{ {
decl_list *l; decl_list *l;
char *name = def->def_name; const char *name = def->def_name;
f_print(fout, "struct %s {\n", name); f_print(fout, "struct %s {\n", name);
for (l = def->def.st.decls; l != NULL; l = l->next) { for (l = def->def.st.decls; l != NULL; l = l->next) {
@ -215,7 +209,7 @@ puniondef(def)
definition *def; definition *def;
{ {
case_list *l; case_list *l;
char *name = def->def_name; const char *name = def->def_name;
declaration *decl; declaration *decl;
f_print(fout, "struct %s {\n", name); f_print(fout, "struct %s {\n", name);
@ -240,25 +234,19 @@ puniondef(def)
} }
static void static void
pdefine(name, num) pdefine(const char *name, const char *num)
char *name;
char *num;
{ {
f_print(fout, "#define\t%s %s\n", name, num); f_print(fout, "#define\t%s %s\n", name, num);
} }
static void static void
puldefine(name, num) puldefine(const char *name, const char *num)
char *name;
char *num;
{ {
f_print(fout, "#define\t%s ((unsigned long)(%s))\n", name, num); f_print(fout, "#define\t%s ((unsigned long)(%s))\n", name, num);
} }
static int static int
define_printed(stop, start) define_printed(proc_list *stop, version_list *start)
proc_list *stop;
version_list *start;
{ {
version_list *vers; version_list *vers;
proc_list *proc; proc_list *proc;
@ -277,7 +265,7 @@ define_printed(stop, start)
} }
static void static void
pfreeprocdef(char * name, char *vers) pfreeprocdef(const char * name, const char *vers)
{ {
f_print(fout, "extern int "); f_print(fout, "extern int ");
pvname(name, vers); pvname(name, vers);
@ -285,7 +273,7 @@ pfreeprocdef(char * name, char *vers)
} }
static void static void
pdispatch(char * name, char *vers) pdispatch(const char * name, const char *vers)
{ {
f_print(fout, "void "); f_print(fout, "void ");
@ -298,7 +286,7 @@ pprogramdef(definition *def, int headeronly)
{ {
version_list *vers; version_list *vers;
proc_list *proc; proc_list *proc;
char *ext; const char *ext;
pargdef(def); pargdef(def);
@ -334,7 +322,7 @@ pprogramdef(definition *def, int headeronly)
} }
static void 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 (mtflag) {/* Print MT style stubs */
if (server_p) 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 */ /* print out argument list of procedure */
static void static void
parglist(proc, addargtype) parglist(proc_list *proc, const char *addargtype)
proc_list *proc;
char* addargtype;
{ {
decl_list *dl; decl_list *dl;
@ -391,9 +377,9 @@ static void
penumdef(def) penumdef(def)
definition *def; definition *def;
{ {
char *name = def->def_name; const char *name = def->def_name;
enumval_list *l; enumval_list *l;
char *last = NULL; const char *last = NULL;
int count = 0; int count = 0;
f_print(fout, "enum %s {\n", name); f_print(fout, "enum %s {\n", name);
@ -423,8 +409,8 @@ static void
ptypedef(def) ptypedef(def)
definition *def; definition *def;
{ {
char *name = def->def_name; const char *name = def->def_name;
char *old = def->def.ty.old_type; const char *old = def->def.ty.old_type;
char prefix[8]; /* enough to contain "struct ", including NUL */ char prefix[8]; /* enough to contain "struct ", including NUL */
relation rel = def->def.ty.rel; relation rel = def->def.ty.rel;
@ -467,15 +453,11 @@ ptypedef(def)
} }
void void
pdeclaration(name, dec, tab, separator) pdeclaration(const char *name, declaration *dec, int tab, const char *separator)
char *name;
declaration *dec;
int tab;
char *separator;
{ {
char buf[8]; /* enough to hold "struct ", include NUL */ char buf[8]; /* enough to hold "struct ", include NUL */
char *prefix; const char *prefix;
char *type; const char *type;
if (streq(dec->type, "void")) { if (streq(dec->type, "void")) {
return; return;
@ -526,9 +508,7 @@ pdeclaration(name, dec, tab, separator)
} }
static int static int
undefined2(type, stop) undefined2(const char *type, const char *stop)
char *type;
char *stop;
{ {
list *l; list *l;
definition *def; definition *def;

View File

@ -56,16 +56,13 @@ __FBSDID("$FreeBSD$");
#include "rpc_scan.h" #include "rpc_scan.h"
#include "rpc_util.h" #include "rpc_util.h"
extern void write_sample_svc( definition * ); static void c_output(const char *, const char *, int, const char *);
extern int write_sample_clnt( definition * ); static void h_output(const char *, const char *, int, const char *, int);
extern void write_sample_clnt_main( void ); static void l_output(const char *, const char *, int, const char *);
extern void add_sample_msg( void ); static void t_output(const char *, const char *, int, const char *);
static void c_output( char *, char *, int, char * ); static void clnt_output(const char *, const char *, int, const char * );
static void h_output( char *, char *, int, char *, int ); static char *generate_guard(const char *);
static void l_output( char *, char *, int, char * ); static void c_initialize(void);
static void t_output( char *, char *, int, char * );
static void clnt_output( char *, char *, int, char * );
void c_initialize( void );
#if !defined(__FreeBSD__) && !defined(__NetBSD__) #if !defined(__FreeBSD__) && !defined(__NetBSD__)
char * rindex(); char * rindex();
@ -73,11 +70,11 @@ char * rindex();
static void usage(void); static void usage(void);
static void options_usage(void); static void options_usage(void);
static int do_registers(int, char **); static int do_registers(int, const char **);
static int parseargs(int, char **, struct commandline *); static int parseargs(int, const char **, struct commandline *);
static void svc_output(char *, char *, int, char *); static void svc_output(const char *, const char *, int, const char *);
static void mkfile_output(struct commandline *); 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 EXTEND 1 /* alias for TRUE */
#define DONT_EXTEND 0 /* alias for FALSE */ #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 int cppDefined = 0; /* explicit path for C preprocessor */
static char *svcclosetime = "120"; static const char *svcclosetime = "120";
static char *CPP = SVR4_CPP; static const char *CPP = SVR4_CPP;
static char CPPFLAGS[] = "-C"; static const char CPPFLAGS[] = "-C";
static char pathbuf[MAXPATHLEN + 1]; static char pathbuf[MAXPATHLEN + 1];
static char *allv[] = { static const char *allv[] = {
"rpcgen", "-s", "udp", "-s", "tcp", "rpcgen", "-s", "udp", "-s", "tcp",
}; };
static int allc = sizeof (allv)/sizeof (allv[0]); static int allc = sizeof (allv)/sizeof (allv[0]);
static char *allnv[] = { static const char *allnv[] = {
"rpcgen", "-s", "netpath", "rpcgen", "-s", "netpath",
}; };
static int allnc = sizeof (allnv)/sizeof (allnv[0]); 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 * machinations for handling expanding argument list
*/ */
static void addarg(); /* add another argument to the list */ static void addarg(const char *); /* add another argument to the list */
static void putarg(); /* put argument at specified location */ static void putarg(int, const char *); /* put argument at specified location */
static void clear_args(); /* clear argument list */ static void clear_args(void); /* clear argument list */
static void checkfiles(); /* check if out file already exists */ static void checkfiles(const char *, const char *);
/* check if out file already exists */
#define ARGLISTLEN 20 #define ARGLISTLEN 20
#define FIXEDARGS 2 #define FIXEDARGS 2
static char *arglist[ARGLISTLEN]; static const char *arglist[ARGLISTLEN];
static int argcount = FIXEDARGS; static int argcount = FIXEDARGS;
@ -147,9 +145,7 @@ pid_t childpid;
int int
main(argc, argv) main(int argc, const char *argv[])
int argc;
char *argv[];
{ {
struct commandline cmd; struct commandline cmd;
@ -231,13 +227,11 @@ main(argc, argv)
* add extension to filename * add extension to filename
*/ */
static char * static char *
extendfile(path, ext) extendfile(const char *path, const char *ext)
char *path;
char *ext;
{ {
char *res; char *res;
char *p; const char *p;
char *file; const char *file;
if ((file = rindex(path, '/')) == NULL) if ((file = rindex(path, '/')) == NULL)
file = path; file = path;
@ -257,9 +251,7 @@ extendfile(path, ext)
* Open output file with given extension * Open output file with given extension
*/ */
static void static void
open_output(infile, outfile) open_output(const char *infile, const char *outfile)
char *infile;
char *outfile;
{ {
if (outfile == NULL) { if (outfile == NULL) {
@ -282,7 +274,7 @@ open_output(infile, outfile)
} }
static void static void
add_warning() add_warning(void)
{ {
f_print(fout, "/*\n"); f_print(fout, "/*\n");
f_print(fout, " * Please do not edit this file.\n"); f_print(fout, " * Please do not edit this file.\n");
@ -291,7 +283,8 @@ add_warning()
} }
/* clear list of arguments */ /* clear list of arguments */
static void clear_args() static void
clear_args(void)
{ {
int i; int i;
for (i = FIXEDARGS; i < ARGLISTLEN; i++) for (i = FIXEDARGS; i < ARGLISTLEN; i++)
@ -300,7 +293,8 @@ static void clear_args()
} }
/* make sure that a CPP exists */ /* make sure that a CPP exists */
static void find_cpp() static void
find_cpp(void)
{ {
struct stat buf; struct stat buf;
@ -322,9 +316,7 @@ static void find_cpp()
* Open input file with given define for C-preprocessor * Open input file with given define for C-preprocessor
*/ */
static void static void
open_input(infile, define) open_input(const char *infile, const char *define)
char *infile;
char *define;
{ {
int pd[2]; int pd[2];
@ -356,7 +348,7 @@ open_input(infile, define)
} }
/* valid tirpc nettypes */ /* valid tirpc nettypes */
static char* valid_ti_nettypes[] = static const char *valid_ti_nettypes[] =
{ {
"netpath", "netpath",
"visible", "visible",
@ -371,16 +363,15 @@ static char* valid_ti_nettypes[] =
}; };
/* valid inetd nettypes */ /* valid inetd nettypes */
static char* valid_i_nettypes[] = static const char *valid_i_nettypes[] =
{ {
"udp", "udp",
"tcp", "tcp",
NULL NULL
}; };
static int check_nettype(name, list_to_check) static int
char* name; check_nettype(const char *name, const char *list_to_check[])
char* list_to_check[];
{ {
int i; int i;
for (i = 0; list_to_check[i] != NULL; i++) { for (i = 0; list_to_check[i] != NULL; i++) {
@ -392,10 +383,8 @@ char* list_to_check[];
return (0); return (0);
} }
static char * static const char *
file_name(file, ext) file_name(const char *file, const char *ext)
char *file;
char *ext;
{ {
char *temp; char *temp;
temp = extendfile(file, ext); temp = extendfile(file, ext);
@ -403,21 +392,17 @@ char *ext;
if (access(temp, F_OK) != -1) if (access(temp, F_OK) != -1)
return (temp); return (temp);
else else
return ((char *)" "); return (" ");
} }
static void static void
c_output(infile, define, extend, outfile) c_output(const char *infile, const char *define, int extend, const char *outfile)
char *infile;
char *define;
int extend;
char *outfile;
{ {
definition *def; definition *def;
char *include; char *include;
char *outfilename; const char *outfilename;
long tell; long tell;
c_initialize(); c_initialize();
@ -442,7 +427,7 @@ c_output(infile, define, extend, outfile)
void void
c_initialize() c_initialize(void)
{ {
/* add all the starting basic types */ /* 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\ char *(*proc)(); \n\
xdrproc_t xdr_arg; \n\ xdrproc_t xdr_arg; \n\
unsigned len_arg; \n\ unsigned len_arg; \n\
@ -465,10 +450,11 @@ char rpcgen_table_dcl[] = "struct rpcgen_table {\n\
}; \n"; }; \n";
char *generate_guard(pathname) char *
char* pathname; generate_guard(const char *pathname)
{ {
char* filename, *guard, *tmp, *stopat; const char *filename;
char *guard, *tmp, *stopat;
filename = strrchr(pathname, '/'); /* find last component */ filename = strrchr(pathname, '/'); /* find last component */
filename = ((filename == 0) ? pathname : filename+1); filename = ((filename == 0) ? pathname : filename+1);
@ -514,12 +500,12 @@ char *generate_guard(pathname)
static void 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; definition *def;
char *outfilename; const char *outfilename;
long tell; long tell;
char *guard; const char *guard;
list *l; list *l;
xdrfunc *xdrfuncp; xdrfunc *xdrfuncp;
@ -600,20 +586,13 @@ h_output(char *infile, char *define, int extend, char *outfile, int headeronly)
* Compile into an RPC service * Compile into an RPC service
*/ */
static void static void
s_output(argc, argv, infile, define, extend, outfile, nomain, netflag) s_output(int argc, const char *argv[], const char *infile, const char *define,
int argc; int extend, const char *outfile, int nomain, int netflag)
char *argv[];
char *infile;
char *define;
int extend;
char *outfile;
int nomain;
int netflag;
{ {
char *include; char *include;
definition *def; definition *def;
int foundprogram = 0; int foundprogram = 0;
char *outfilename; const char *outfilename;
open_input(infile, define); open_input(infile, define);
outfilename = extend ? extendfile(infile, outfile) : outfile; outfilename = extend ? extendfile(infile, outfile) : outfile;
@ -694,16 +673,12 @@ s_output(argc, argv, infile, define, extend, outfile, nomain, netflag)
* generate client side stubs * generate client side stubs
*/ */
static void static void
l_output(infile, define, extend, outfile) l_output(const char *infile, const char *define, int extend, const char *outfile)
char *infile;
char *define;
int extend;
char *outfile;
{ {
char *include; char *include;
definition *def; definition *def;
int foundprogram = 0; int foundprogram = 0;
char *outfilename; const char *outfilename;
open_input(infile, define); open_input(infile, define);
outfilename = extend ? extendfile(infile, outfile) : outfile; outfilename = extend ? extendfile(infile, outfile) : outfile;
@ -729,15 +704,11 @@ l_output(infile, define, extend, outfile)
* generate the dispatch table * generate the dispatch table
*/ */
static void static void
t_output(infile, define, extend, outfile) t_output(const char *infile, const char *define, int extend, const char *outfile)
char *infile;
char *define;
int extend;
char *outfile;
{ {
definition *def; definition *def;
int foundprogram = 0; int foundprogram = 0;
char *outfilename; const char *outfilename;
open_input(infile, define); open_input(infile, define);
outfilename = extend ? extendfile(infile, outfile) : outfile; outfilename = extend ? extendfile(infile, outfile) : outfile;
@ -755,15 +726,11 @@ t_output(infile, define, extend, outfile)
/* sample routine for the server template */ /* sample routine for the server template */
static void static void
svc_output(infile, define, extend, outfile) svc_output(const char *infile, const char *define, int extend, const char *outfile)
char *infile;
char *define;
int extend;
char *outfile;
{ {
definition *def; definition *def;
char *include; char *include;
char *outfilename; const char *outfilename;
long tell; long tell;
open_input(infile, define); open_input(infile, define);
outfilename = extend ? extendfile(infile, outfile) : outfile; outfilename = extend ? extendfile(infile, outfile) : outfile;
@ -792,15 +759,11 @@ svc_output(infile, define, extend, outfile)
/* sample main routine for client */ /* sample main routine for client */
static void static void
clnt_output(infile, define, extend, outfile) clnt_output(const char *infile, const char *define, int extend, const char *outfile)
char *infile;
char *define;
int extend;
char *outfile;
{ {
definition *def; definition *def;
char *include; char *include;
char *outfilename; const char *outfilename;
long tell; long tell;
int has_program = 0; int has_program = 0;
@ -833,12 +796,11 @@ clnt_output(infile, define, extend, outfile)
} }
static void mkfile_output(cmd) static void mkfile_output(struct commandline *cmd)
struct commandline *cmd;
{ {
char *mkfilename, *clientname, *clntname, *xdrname, *hdrname; const char *mkfilename, *clientname, *clntname, *xdrname, *hdrname;
char *servername, *svcname, *servprogname, *clntprogname; const char *servername, *svcname, *servprogname, *clntprogname;
char *temp; char *temp, *mkftemp;
svcname = file_name(cmd->infile, "_svc.c"); svcname = file_name(cmd->infile, "_svc.c");
clntname = file_name(cmd->infile, "_clnt.c"); clntname = file_name(cmd->infile, "_clnt.c");
@ -857,12 +819,13 @@ struct commandline *cmd;
clntprogname = extendfile(cmd->infile, "_client"); clntprogname = extendfile(cmd->infile, "_client");
if (allfiles){ if (allfiles){
mkfilename = xmalloc(strlen("makefile.") + mkftemp = xmalloc(strlen("makefile.") +
strlen(cmd->infile) + 1); strlen(cmd->infile) + 1);
temp = (char *)rindex(cmd->infile, '.'); temp = (char *)rindex(cmd->infile, '.');
strcpy(mkfilename, "makefile."); strcpy(mkftemp, "makefile.");
(void) strncat(mkfilename, cmd->infile, (void) strncat(mkftemp, cmd->infile,
(temp - cmd->infile)); (temp - cmd->infile));
mkfilename = mkftemp;
} else } else
mkfilename = cmd->outfile; mkfilename = cmd->outfile;
@ -927,9 +890,7 @@ struct commandline *cmd;
* Return 0 if failed; 1 otherwise. * Return 0 if failed; 1 otherwise.
*/ */
static int static int
do_registers(argc, argv) do_registers(int argc, const char *argv[])
int argc;
char *argv[];
{ {
int i; int i;
@ -963,8 +924,7 @@ do_registers(argc, argv)
* Add another argument to the arg list * Add another argument to the arg list
*/ */
static void static void
addarg(cp) addarg(const char *cp)
char *cp;
{ {
if (argcount >= ARGLISTLEN) { if (argcount >= ARGLISTLEN) {
warnx("too many defines"); warnx("too many defines");
@ -976,16 +936,14 @@ addarg(cp)
} }
static void static void
putarg(where, cp) putarg(int place, const char *cp)
char *cp;
int where;
{ {
if (where >= ARGLISTLEN) { if (place >= ARGLISTLEN) {
warnx("arglist coding error"); warnx("arglist coding error");
crash(); crash();
/*NOTREACHED*/ /*NOTREACHED*/
} }
arglist[where] = cp; arglist[place] = cp;
} }
/* /*
@ -995,9 +953,7 @@ putarg(where, cp)
*/ */
static void static void
checkfiles(infile, outfile) checkfiles(const char *infile, const char *outfile)
char *infile;
char *outfile;
{ {
struct stat buf; struct stat buf;
@ -1022,10 +978,7 @@ char *outfile;
* Parse command line arguments * Parse command line arguments
*/ */
static int static int
parseargs(argc, argv, cmd) parseargs(int argc, const char *argv[], struct commandline *cmd)
int argc;
char *argv[];
struct commandline *cmd;
{ {
int i; int i;
int j; int j;

View File

@ -44,13 +44,12 @@ __FBSDID("$FreeBSD$");
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "rpc/types.h" #include "rpc/types.h"
#include "rpc_scan.h"
#include "rpc_parse.h" #include "rpc_parse.h"
#include "rpc_scan.h"
#include "rpc_util.h" #include "rpc_util.h"
#define ARGNAME "arg" #define ARGNAME "arg"
extern char *make_argname( char *, char * );
static void isdefined( definition * ); static void isdefined( definition * );
static void def_struct( definition * ); static void def_struct( definition * );
static void def_program( definition * ); static void def_program( definition * );
@ -60,14 +59,14 @@ static void def_union( definition * );
static void def_typedef( definition * ); static void def_typedef( definition * );
static void get_declaration( declaration *, defkind ); static void get_declaration( declaration *, defkind );
static void get_prog_declaration( declaration *, defkind, int ); static void get_prog_declaration( declaration *, defkind, int );
static void get_type( char **, char **, defkind ); static void get_type(const char **, const char **, defkind);
static void unsigned_dec( char ** ); static void unsigned_dec(const char ** );
/* /*
* return the next definition you see * return the next definition you see
*/ */
definition * definition *
get_definition() get_definition(void)
{ {
definition *defp; definition *defp;
token tok; token tok;
@ -104,15 +103,13 @@ get_definition()
} }
static void static void
isdefined(defp) isdefined(definition *defp)
definition *defp;
{ {
STOREVAL(&defined, defp); STOREVAL(&defined, defp);
} }
static void static void
def_struct(defp) def_struct(definition *defp)
definition *defp;
{ {
token tok; token tok;
declaration dec; declaration dec;
@ -139,8 +136,7 @@ def_struct(defp)
} }
static void static void
def_program(defp) def_program(definition *defp)
definition *defp;
{ {
token tok; token tok;
declaration dec; declaration dec;
@ -246,8 +242,7 @@ def_program(defp)
static void static void
def_enum(defp) def_enum(definition *defp)
definition *defp;
{ {
token tok; token tok;
enumval_list *elist; enumval_list *elist;
@ -276,8 +271,7 @@ def_enum(defp)
} }
static void static void
def_const(defp) def_const(definition *defp)
definition *defp;
{ {
token tok; token tok;
@ -290,8 +284,7 @@ def_const(defp)
} }
static void static void
def_union(defp) def_union(definition *defp)
definition *defp;
{ {
token tok; token tok;
declaration dec; declaration dec;
@ -360,7 +353,7 @@ def_union(defp)
} }
} }
static char* reserved_words[] = static const char *reserved_words[] =
{ {
"array", "array",
"bytes", "bytes",
@ -377,7 +370,7 @@ static char* reserved_words[] =
NULL NULL
}; };
static char* reserved_types[] = static const char *reserved_types[] =
{ {
"opaque", "opaque",
"string", "string",
@ -389,9 +382,7 @@ static char* reserved_types[] =
* xdr routines that would conflict with internal XDR routines. * xdr routines that would conflict with internal XDR routines.
*/ */
static void static void
check_type_name(name, new_type) check_type_name(const char *name, int new_type)
int new_type;
char* name;
{ {
int i; int i;
char tmp[100]; char tmp[100];
@ -419,8 +410,7 @@ char* name;
static void static void
def_typedef(defp) def_typedef(definition *defp)
definition *defp;
{ {
declaration dec; declaration dec;
@ -435,9 +425,7 @@ def_typedef(defp)
} }
static void static void
get_declaration(dec, dkind) get_declaration(declaration *dec, defkind dkind)
declaration *dec;
defkind dkind;
{ {
token tok; token tok;
@ -488,10 +476,7 @@ get_declaration(dec, dkind)
static void static void
get_prog_declaration(dec, dkind, num) get_prog_declaration(declaration *dec, defkind dkind, int num)
declaration *dec;
defkind dkind;
int num; /* arg number */
{ {
token tok; token tok;
char name[10]; /* argument name */ char name[10]; /* argument name */
@ -562,10 +547,7 @@ get_prog_declaration(dec, dkind, num)
static void static void
get_type(prefixp, typep, dkind) get_type(const char **prefixp, const char **typep, defkind dkind)
char **prefixp;
char **typep;
defkind dkind;
{ {
token tok; token tok;
@ -620,8 +602,7 @@ get_type(prefixp, typep, dkind)
} }
static void static void
unsigned_dec(typep) unsigned_dec(const char **typep)
char **typep;
{ {
token tok; token tok;

View File

@ -76,7 +76,7 @@ enum defkind {
}; };
typedef enum defkind defkind; typedef enum defkind defkind;
typedef char *const_def; typedef const char *const_def;
enum relation { enum relation {
REL_VECTOR, /* fixed length array */ REL_VECTOR, /* fixed length array */
@ -87,16 +87,16 @@ enum relation {
typedef enum relation relation; typedef enum relation relation;
struct typedef_def { struct typedef_def {
char *old_prefix; const char *old_prefix;
char *old_type; const char *old_type;
relation rel; relation rel;
char *array_max; const char *array_max;
}; };
typedef struct typedef_def typedef_def; typedef struct typedef_def typedef_def;
struct enumval_list { struct enumval_list {
char *name; const char *name;
char *assignment; const char *assignment;
struct enumval_list *next; struct enumval_list *next;
}; };
typedef struct enumval_list enumval_list; typedef struct enumval_list enumval_list;
@ -107,11 +107,11 @@ struct enum_def {
typedef struct enum_def enum_def; typedef struct enum_def enum_def;
struct declaration { struct declaration {
char *prefix; const char *prefix;
char *type; const char *type;
char *name; const char *name;
relation rel; relation rel;
char *array_max; const char *array_max;
}; };
typedef struct declaration declaration; typedef struct declaration declaration;
@ -127,7 +127,7 @@ struct struct_def {
typedef struct struct_def struct_def; typedef struct struct_def struct_def;
struct case_list { struct case_list {
char *case_name; const char *case_name;
int contflag; int contflag;
declaration case_decl; declaration case_decl;
struct case_list *next; struct case_list *next;
@ -149,32 +149,32 @@ struct arg_list {
typedef struct arg_list arg_list; typedef struct arg_list arg_list;
struct proc_list { struct proc_list {
char *proc_name; const char *proc_name;
char *proc_num; const char *proc_num;
arg_list args; arg_list args;
int arg_num; int arg_num;
char *res_type; const char *res_type;
char *res_prefix; const char *res_prefix;
struct proc_list *next; struct proc_list *next;
}; };
typedef struct proc_list proc_list; typedef struct proc_list proc_list;
struct version_list { struct version_list {
char *vers_name; const char *vers_name;
char *vers_num; const char *vers_num;
proc_list *procs; proc_list *procs;
struct version_list *next; struct version_list *next;
}; };
typedef struct version_list version_list; typedef struct version_list version_list;
struct program_def { struct program_def {
char *prog_num; const char *prog_num;
version_list *versions; version_list *versions;
}; };
typedef struct program_def program_def; typedef struct program_def program_def;
struct definition { struct definition {
char *def_name; const char *def_name;
defkind def_kind; defkind def_kind;
union { union {
const_def co; const_def co;
@ -192,7 +192,7 @@ definition *get_definition(void);
struct bas_type struct bas_type
{ {
char *name; const char *name;
int length; int length;
struct bas_type *next; struct bas_type *next;
}; };

View File

@ -46,14 +46,12 @@ __FBSDID("$FreeBSD$");
static char RQSTP[] = "rqstp"; static char RQSTP[] = "rqstp";
extern void printarglist( proc_list *, char *, char *, char *); static void write_sample_client(const char *, version_list * );
static void write_sample_client( char *, version_list * );
static void write_sample_server( definition * ); static void write_sample_server( definition * );
static void return_type( proc_list * ); static void return_type( proc_list * );
void void
write_sample_svc(def) write_sample_svc(definition *def)
definition *def;
{ {
if (def->def_kind != DEF_PROGRAM) if (def->def_kind != DEF_PROGRAM)
@ -63,8 +61,7 @@ write_sample_svc(def)
int int
write_sample_clnt(def) write_sample_clnt(definition *def)
definition *def;
{ {
version_list *vp; version_list *vp;
int count = 0; int count = 0;
@ -81,9 +78,7 @@ write_sample_clnt(def)
static void static void
write_sample_client(program_name, vp) write_sample_client(const char *program_name, version_list *vp)
char *program_name;
version_list *vp;
{ {
proc_list *proc; proc_list *proc;
int i; int i;
@ -194,8 +189,7 @@ write_sample_client(program_name, vp)
} }
static void static void
write_sample_server(def) write_sample_server(definition *def)
definition *def;
{ {
version_list *vp; version_list *vp;
proc_list *proc; proc_list *proc;
@ -253,14 +247,13 @@ write_sample_server(def)
static void static void
return_type(plist) return_type(proc_list *plist)
proc_list *plist;
{ {
ptype(plist->res_prefix, plist->res_type, 1); ptype(plist->res_prefix, plist->res_type, 1);
} }
void void
add_sample_msg() add_sample_msg(void)
{ {
f_print(fout, "/*\n"); f_print(fout, "/*\n");
f_print(fout, " * This is sample code generated by rpcgen.\n"); f_print(fout, " * This is sample code generated by rpcgen.\n");
@ -270,7 +263,7 @@ add_sample_msg()
} }
void void
write_sample_clnt_main() write_sample_clnt_main(void)
{ {
list *l; list *l;
definition *def; definition *def;

View File

@ -48,8 +48,8 @@ __FBSDID("$FreeBSD$");
#include <stdio.h> #include <stdio.h>
#include <ctype.h> #include <ctype.h>
#include <string.h> #include <string.h>
#include "rpc_scan.h"
#include "rpc_parse.h" #include "rpc_parse.h"
#include "rpc_scan.h"
#include "rpc_util.h" #include "rpc_util.h"
#define startcomment(where) (where[0] == '/' && where[1] == '*') #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 token lasttok; /* last token, if pushed */
static void unget_token( token * ); static void unget_token( token * );
static void findstrconst( char **, char **); static void findstrconst(char **, const char **);
static void findchrconst( char **, char **); static void findchrconst(char **, const char **);
static void findconst( char **, char **); static void findconst(char **, const char **);
static void findkind( char **, token * ); static void findkind( char **, token * );
static int cppline( char * ); static int cppline( char * );
static int directive( char * ); static int directive( char * );
static void printdirective( char * ); static void printdirective( char * );
static void docppline( char *, int *, char ** ); static void docppline(char *, int *, const char **);
/* /*
* scan expecting 1 given token * scan expecting 1 given token
*/ */
void void
scan(expect, tokp) scan(tok_kind expect, token *tokp)
tok_kind expect;
token *tokp;
{ {
get_token(tokp); get_token(tokp);
if (tokp->kind != expect) { if (tokp->kind != expect) {
@ -86,10 +84,7 @@ scan(expect, tokp)
* scan expecting any of the 2 given tokens * scan expecting any of the 2 given tokens
*/ */
void void
scan2(expect1, expect2, tokp) scan2(tok_kind expect1, tok_kind expect2, token *tokp)
tok_kind expect1;
tok_kind expect2;
token *tokp;
{ {
get_token(tokp); get_token(tokp);
if (tokp->kind != expect1 && tokp->kind != expect2) { if (tokp->kind != expect1 && tokp->kind != expect2) {
@ -101,11 +96,7 @@ scan2(expect1, expect2, tokp)
* scan expecting any of the 3 given token * scan expecting any of the 3 given token
*/ */
void void
scan3(expect1, expect2, expect3, tokp) scan3(tok_kind expect1, tok_kind expect2, tok_kind expect3, token *tokp)
tok_kind expect1;
tok_kind expect2;
tok_kind expect3;
token *tokp;
{ {
get_token(tokp); get_token(tokp);
if (tokp->kind != expect1 && tokp->kind != expect2 if (tokp->kind != expect1 && tokp->kind != expect2
@ -118,8 +109,7 @@ scan3(expect1, expect2, expect3, tokp)
* scan expecting a constant, possibly symbolic * scan expecting a constant, possibly symbolic
*/ */
void void
scan_num(tokp) scan_num(token *tokp)
token *tokp;
{ {
get_token(tokp); get_token(tokp);
switch (tokp->kind) { switch (tokp->kind) {
@ -134,8 +124,7 @@ scan_num(tokp)
* Peek at the next token * Peek at the next token
*/ */
void void
peek(tokp) peek(token *tokp)
token *tokp;
{ {
get_token(tokp); get_token(tokp);
unget_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 * Peek at the next token and scan it if it matches what you expect
*/ */
int int
peekscan(expect, tokp) peekscan(tok_kind expect, token *tokp)
tok_kind expect;
token *tokp;
{ {
peek(tokp); peek(tokp);
if (tokp->kind == expect) { if (tokp->kind == expect) {
@ -161,8 +148,7 @@ peekscan(expect, tokp)
* Get the next token, printing out any directive that are encountered. * Get the next token, printing out any directive that are encountered.
*/ */
void void
get_token(tokp) get_token(token *tokp)
token *tokp;
{ {
int commenting; int commenting;
int stat = 0; int stat = 0;
@ -322,19 +308,17 @@ get_token(tokp)
} }
static void static void
unget_token(tokp) unget_token(token *tokp)
token *tokp;
{ {
lasttok = *tokp; lasttok = *tokp;
pushed = 1; pushed = 1;
} }
static void static void
findstrconst(str, val) findstrconst(char **str, const char **val)
char **str;
char **val;
{ {
char *p; char *p;
char *tmp;
int size; int size;
p = *str; p = *str;
@ -346,18 +330,18 @@ findstrconst(str, val)
} }
p++; p++;
size = p - *str; size = p - *str;
*val = xmalloc(size + 1); tmp = xmalloc(size + 1);
(void) strncpy(*val, *str, size); (void) strncpy(tmp, *str, size);
(*val)[size] = 0; tmp[size] = 0;
*val = tmp;
*str = p; *str = p;
} }
static void static void
findchrconst(str, val) findchrconst(char **str, const char **val)
char **str;
char **val;
{ {
char *p; char *p;
char *tmp;
int size; int size;
p = *str; p = *str;
@ -372,18 +356,18 @@ findchrconst(str, val)
if (size != 3) { if (size != 3) {
error("empty char string"); error("empty char string");
} }
*val = xmalloc(size + 1); tmp = xmalloc(size + 1);
(void) strncpy(*val, *str, size); (void) strncpy(tmp, *str, size);
(*val)[size] = 0; tmp[size] = 0;
*val = tmp;
*str = p; *str = p;
} }
static void static void
findconst(str, val) findconst(char **str, const char **val)
char **str;
char **val;
{ {
char *p; char *p;
char *tmp;
int size; int size;
p = *str; p = *str;
@ -398,9 +382,10 @@ findconst(str, val)
} while (isdigit(*p)); } while (isdigit(*p));
} }
size = p - *str; size = p - *str;
*val = xmalloc(size + 1); tmp = xmalloc(size + 1);
(void) strncpy(*val, *str, size); (void) strncpy(tmp, *str, size);
(*val)[size] = 0; tmp[size] = 0;
*val = tmp;
*str = p; *str = p;
} }
@ -432,13 +417,11 @@ static token symbols[] = {
}; };
static void static void
findkind(mark, tokp) findkind(char **mark, token *tokp)
char **mark;
token *tokp;
{ {
int len; int len;
token *s; token *s;
char *str; char *str, *tmp;
str = *mark; str = *mark;
for (s = symbols; s->kind != TOK_EOF; s++) { for (s = symbols; s->kind != TOK_EOF; s++) {
@ -454,38 +437,33 @@ findkind(mark, tokp)
} }
tokp->kind = TOK_IDENT; tokp->kind = TOK_IDENT;
for (len = 0; isalnum(str[len]) || str[len] == '_'; len++); for (len = 0; isalnum(str[len]) || str[len] == '_'; len++);
tokp->str = xmalloc(len + 1); tmp = xmalloc(len + 1);
(void) strncpy(tokp->str, str, len); (void) strncpy(tmp, str, len);
tokp->str[len] = 0; tmp[len] = 0;
tokp->str = tmp;
*mark = str + len; *mark = str + len;
} }
static int static int
cppline(line) cppline(char *line)
char *line;
{ {
return (line == curline && *line == '#'); return (line == curline && *line == '#');
} }
static int static int
directive(line) directive(char *line)
char *line;
{ {
return (line == curline && *line == '%'); return (line == curline && *line == '%');
} }
static void static void
printdirective(line) printdirective(char *line)
char *line;
{ {
f_print(fout, "%s", line + 1); f_print(fout, "%s", line + 1);
} }
static void static void
docppline(line, lineno, fname) docppline(char *line, int *lineno, const char **fname)
char *line;
int *lineno;
char **fname;
{ {
char *file; char *file;
int num; int num;

View File

@ -119,7 +119,7 @@ typedef enum tok_kind tok_kind;
*/ */
struct token { struct token {
tok_kind kind; tok_kind kind;
char *str; const char *str;
}; };
typedef struct token token; typedef struct token token;

View File

@ -47,8 +47,6 @@ __FBSDID("$FreeBSD$");
#include "rpc_scan.h" #include "rpc_scan.h"
#include "rpc_util.h" #include "rpc_util.h"
extern int tirpc_socket;
static char RQSTP[] = "rqstp"; static char RQSTP[] = "rqstp";
static char TRANSP[] = "transp"; static char TRANSP[] = "transp";
static char ARG[] = "argument"; static char ARG[] = "argument";
@ -60,33 +58,29 @@ char _errbuf[256]; /* For all messages */
void internal_proctype( proc_list * ); void internal_proctype( proc_list * );
static void write_real_program( definition * ); static void write_real_program( definition * );
static void write_program( definition *, char * ); static void write_program(definition *, const char *);
static void printerr( char *, char * ); static void printerr(const char *, const char *);
static void printif( char *, char *, char *, char * ); static void printif(const char *, const char *, const char *, const char *);
static void write_inetmost( char * ); static void write_inetmost(const char *);
static void print_return( char * ); static void print_return(const char *);
static void print_pmapunset( char * ); static void print_pmapunset(const char *);
static void print_err_message( char * ); static void print_err_message(const char *);
static void write_timeout_func( void ); static void write_timeout_func( void );
static void write_pm_most( char *, int ); static void write_pm_most(const char *, int);
static void write_rpc_svc_fg( char *, char * ); static void write_rpc_svc_fg(const char *, const char *);
static void open_log_file( char *, char * ); static void open_log_file(const char *, const char *);
static void write_msg_out( void ); static void write_msg_out( void );
int nullproc( proc_list * );
static void static void
p_xdrfunc(rname, typename) p_xdrfunc(const char *rname, const char *typename)
char* rname;
char* typename;
{ {
f_print(fout, "\t\txdr_%s = (xdrproc_t) xdr_%s;\n", f_print(fout, "\t\txdr_%s = (xdrproc_t) xdr_%s;\n",
rname, stringfix(typename)); rname, stringfix(typename));
} }
void void
internal_proctype(plist) internal_proctype(proc_list *plist)
proc_list *plist;
{ {
f_print(fout, "static "); f_print(fout, "static ");
ptype(plist->res_prefix, plist->res_type, 1); 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. * write most of the service, that is, everything but the registrations.
*/ */
void void
write_most(infile, netflag, nomain) write_most(const char *infile, int netflag, int nomain)
char *infile; /* our name */
int netflag;
int nomain;
{ {
if (inetdflag || pmflag) { if (inetdflag || pmflag) {
char* var_type; const char *var_type;
var_type = (nomain? "extern" : "static"); var_type = (nomain? "extern" : "static");
f_print(fout, "%s int _rpcpmstart;", var_type); f_print(fout, "%s int _rpcpmstart;", var_type);
f_print(fout, "\t\t/* Started by a port monitor ? */\n"); f_print(fout, "\t\t/* Started by a port monitor ? */\n");
@ -195,13 +186,12 @@ serviced */\n");
* write a registration for the given transport * write a registration for the given transport
*/ */
void void
write_netid_register(transp) write_netid_register(const char *transp)
char *transp;
{ {
list *l; list *l;
definition *def; definition *def;
version_list *vp; version_list *vp;
char *sp; const char *sp;
char tmpbuf[32]; char tmpbuf[32];
sp = ""; sp = "";
@ -257,8 +247,7 @@ write_netid_register(transp)
* write a registration for the given transport for TLI * write a registration for the given transport for TLI
*/ */
void void
write_nettype_register(transp) write_nettype_register(const char *transp)
char *transp;
{ {
list *l; list *l;
definition *def; definition *def;
@ -292,7 +281,7 @@ write_nettype_register(transp)
* write the rest of the service * write the rest of the service
*/ */
void void
write_rest() write_rest(void)
{ {
f_print(fout, "\n"); f_print(fout, "\n");
if (inetdflag) { if (inetdflag) {
@ -319,8 +308,7 @@ alarm(_RPCSVC_CLOSEDOWN/2);\n");
} }
void void
write_programs(storage) write_programs(const char *storage)
char *storage;
{ {
list *l; list *l;
definition *def; definition *def;
@ -351,8 +339,7 @@ write_programs(storage)
* expected by printmsg_1. * expected by printmsg_1.
*/ */
static void static void
write_real_program(def) write_real_program(definition *def)
definition *def;
{ {
version_list *vp; version_list *vp;
proc_list *proc; proc_list *proc;
@ -406,9 +393,7 @@ write_real_program(def)
} }
static void static void
write_program(def, storage) write_program(definition *def, const char *storage)
definition *def;
char *storage;
{ {
version_list *vp; version_list *vp;
proc_list *proc; proc_list *proc;
@ -579,27 +564,21 @@ write_program(def, storage)
} }
static void static void
printerr(err, transp) printerr(const char *err, const char *transp)
char *err;
char *transp;
{ {
f_print(fout, "\t\tsvcerr_%s(%s);\n", err, transp); f_print(fout, "\t\tsvcerr_%s(%s);\n", err, transp);
} }
static void static void
printif(proc, transp, prefix, arg) printif(const char *proc, const char *transp, const char *prefix,
char *proc; const char *arg)
char *transp;
char *prefix;
char *arg;
{ {
f_print(fout, "\tif (!svc_%s(%s, xdr_%s, (char *)%s%s)) {\n", f_print(fout, "\tif (!svc_%s(%s, xdr_%s, (char *)%s%s)) {\n",
proc, transp, arg, prefix, arg); proc, transp, arg, prefix, arg);
} }
int int
nullproc(proc) nullproc(proc_list *proc)
proc_list *proc;
{ {
for (; proc != NULL; proc = proc->next) { for (; proc != NULL; proc = proc->next) {
if (streq(proc->proc_num, "0")) { if (streq(proc->proc_num, "0")) {
@ -610,8 +589,7 @@ nullproc(proc)
} }
static void static void
write_inetmost(infile) write_inetmost(const char *infile)
char *infile;
{ {
f_print(fout, "\tregister SVCXPRT *%s;\n", TRANSP); f_print(fout, "\tregister SVCXPRT *%s;\n", TRANSP);
f_print(fout, "\tint sock;\n"); f_print(fout, "\tint sock;\n");
@ -639,8 +617,7 @@ write_inetmost(infile)
} }
static void static void
print_return(space) print_return(const char *space)
char *space;
{ {
if (exitnow) if (exitnow)
f_print(fout, "%sexit(0);\n", space); f_print(fout, "%sexit(0);\n", space);
@ -657,8 +634,7 @@ print_return(space)
} }
static void static void
print_pmapunset(space) print_pmapunset(const char *space)
char *space;
{ {
list *l; list *l;
definition *def; definition *def;
@ -677,8 +653,7 @@ print_pmapunset(space)
} }
static void static void
print_err_message(space) print_err_message(const char *space)
char *space;
{ {
if (logflag) if (logflag)
f_print(fout, "%ssyslog(LOG_ERR, \"%s\");\n", space, _errbuf); 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) * Write the server auxiliary function (_msgout, timeout)
*/ */
void void
write_svc_aux(nomain) write_svc_aux(int nomain)
int nomain;
{ {
if (!logflag) if (!logflag)
write_msg_out(); write_msg_out();
@ -793,9 +767,7 @@ write_timeout_func(void)
* Write the most of port monitor support * Write the most of port monitor support
*/ */
static void static void
write_pm_most(infile, netflag) write_pm_most(const char *infile, int netflag)
char *infile;
int netflag;
{ {
list *l; list *l;
definition *def; definition *def;
@ -918,9 +890,7 @@ getenv(\"NLSPROVIDER\")) == NULL) {\n");
* Support for backgrounding the server if self started. * Support for backgrounding the server if self started.
*/ */
static void static void
write_rpc_svc_fg(infile, sp) write_rpc_svc_fg(const char *infile, const char *sp)
char *infile;
char *sp;
{ {
f_print(fout, "#ifndef RPC_SVC_FG\n"); f_print(fout, "#ifndef RPC_SVC_FG\n");
f_print(fout, "%sint size;\n", sp); f_print(fout, "%sint size;\n", sp);
@ -970,9 +940,7 @@ write_rpc_svc_fg(infile, sp)
} }
static void static void
open_log_file(infile, sp) open_log_file(const char *infile, const char *sp)
char *infile;
char *sp;
{ {
char *s; char *s;
@ -991,13 +959,12 @@ open_log_file(infile, sp)
* write a registration for the given transport for Inetd * write a registration for the given transport for Inetd
*/ */
void void
write_inetd_register(transp) write_inetd_register(const char *transp)
char *transp;
{ {
list *l; list *l;
definition *def; definition *def;
version_list *vp; version_list *vp;
char *sp; const char *sp;
int isudp; int isudp;
char tmpbuf[32]; char tmpbuf[32];

View File

@ -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"; 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 write_table( definition * );
static void printit( char *, char * ); static void printit(const char *, const char *);
void void
write_tables() write_tables(void)
{ {
list *l; list *l;
definition *def; definition *def;
@ -84,8 +83,7 @@ write_tables()
} }
static void static void
write_table(def) write_table(definition *def)
definition *def;
{ {
version_list *vp; version_list *vp;
proc_list *proc; proc_list *proc;
@ -149,9 +147,7 @@ write_table(def)
} }
static void static void
printit(prefix, type) printit(const char *prefix, const char *type)
char *prefix;
char *type;
{ {
int len; int len;
int tabs; int tabs;

View File

@ -46,8 +46,8 @@ __FBSDID("$FreeBSD$");
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include "rpc_scan.h"
#include "rpc_parse.h" #include "rpc_parse.h"
#include "rpc_scan.h"
#include "rpc_util.h" #include "rpc_util.h"
#define ARGEXT "argument" #define ARGEXT "argument"
@ -56,10 +56,10 @@ char curline[MAXLINESIZE]; /* current read line */
char *where = curline; /* current point in line */ char *where = curline; /* current point in line */
int linenum = 0; /* current line number */ int linenum = 0; /* current line number */
char *infilename; /* input filename */ const char *infilename; /* input filename */
#define NFILES 7 #define NFILES 7
char *outfiles[NFILES]; /* output file names */ const char *outfiles[NFILES]; /* output file names */
int nfiles; int nfiles;
FILE *fout; /* file pointer of current output */ FILE *fout; /* file pointer of current output */
@ -73,7 +73,7 @@ static void printwhere( void );
* Reinitialize the world * Reinitialize the world
*/ */
void void
reinitialize() reinitialize(void)
{ {
memset(curline, 0, MAXLINESIZE); memset(curline, 0, MAXLINESIZE);
where = curline; where = curline;
@ -85,9 +85,7 @@ reinitialize()
* string equality * string equality
*/ */
int int
streq(a, b) streq(const char *a, const char *b)
char *a;
char *b;
{ {
return (strcmp(a, b) == 0); return (strcmp(a, b) == 0);
} }
@ -96,11 +94,7 @@ streq(a, b)
* find a value in a list * find a value in a list
*/ */
definition * definition *
findval(lst, val, cmp) findval(list *lst, const char *val, int (*cmp)(definition *, const char *))
list *lst;
char *val;
int (*cmp) ();
{ {
for (; lst != NULL; lst = lst->next) { for (; lst != NULL; lst = lst->next) {
if ((*cmp) (lst->val, val)) { if ((*cmp) (lst->val, val)) {
@ -114,9 +108,7 @@ findval(lst, val, cmp)
* store a value in a list * store a value in a list
*/ */
void void
storeval(lstp, val) storeval(list **lstp, definition *val)
list **lstp;
definition *val;
{ {
list **l; list **l;
list *lst; list *lst;
@ -129,17 +121,13 @@ storeval(lstp, val)
} }
static int static int
findit(def, type) findit(definition *def, const char *type)
definition *def;
char *type;
{ {
return (streq(def->def_name, type)); return (streq(def->def_name, type));
} }
static char * static const char *
fixit(type, orig) fixit(const char *type, const char *orig)
char *type;
char *orig;
{ {
definition *def; definition *def;
@ -161,16 +149,14 @@ fixit(type, orig)
} }
} }
char * const char *
fixtype(type) fixtype(const char *type)
char *type;
{ {
return (fixit(type, type)); return (fixit(type, type));
} }
char * const char *
stringfix(type) stringfix(const char *type)
char *type;
{ {
if (streq(type, "string")) { if (streq(type, "string")) {
return ("wrapstring"); return ("wrapstring");
@ -180,10 +166,7 @@ stringfix(type)
} }
void void
ptype(prefix, type, follow) ptype(const char *prefix, const char *type, int follow)
char *prefix;
char *type;
int follow;
{ {
if (prefix != NULL) { if (prefix != NULL) {
if (streq(prefix, "enum")) { if (streq(prefix, "enum")) {
@ -202,9 +185,7 @@ ptype(prefix, type, follow)
} }
static int static int
typedefed(def, type) typedefed(definition *def, const char *type)
definition *def;
char *type;
{ {
if (def->def_kind != DEF_TYPEDEF || def->def.ty.old_prefix != NULL) { if (def->def_kind != DEF_TYPEDEF || def->def.ty.old_prefix != NULL) {
return (0); return (0);
@ -214,9 +195,7 @@ typedefed(def, type)
} }
int int
isvectordef(type, rel) isvectordef(const char *type, relation rel)
char *type;
relation rel;
{ {
definition *def; definition *def;
@ -242,8 +221,7 @@ isvectordef(type, rel)
} }
char * char *
locase(str) locase(const char *str)
char *str;
{ {
char c; char c;
static char buf[100]; static char buf[100];
@ -257,17 +235,13 @@ locase(str)
} }
void void
pvname_svc(pname, vnum) pvname_svc(const char *pname, const char *vnum)
char *pname;
char *vnum;
{ {
f_print(fout, "%s_%s_svc", locase(pname), vnum); f_print(fout, "%s_%s_svc", locase(pname), vnum);
} }
void void
pvname(pname, vnum) pvname(const char *pname, const char *vnum)
char *pname;
char *vnum;
{ {
f_print(fout, "%s_%s", locase(pname), vnum); f_print(fout, "%s_%s", locase(pname), vnum);
} }
@ -276,8 +250,7 @@ pvname(pname, vnum)
* print a useful (?) error message, and then die * print a useful (?) error message, and then die
*/ */
void void
error(msg) error(const char *msg)
char *msg;
{ {
printwhere(); printwhere();
warnx("%s, line %d: %s", infilename, linenum, msg); warnx("%s, line %d: %s", infilename, linenum, msg);
@ -289,7 +262,7 @@ error(msg)
* die. * die.
*/ */
void void
crash() crash(void)
{ {
int i; int i;
@ -300,8 +273,7 @@ crash()
} }
void void
record_open(file) record_open(const char *file)
char *file;
{ {
if (nfiles < NFILES) { if (nfiles < NFILES) {
outfiles[nfiles++] = file; outfiles[nfiles++] = file;
@ -312,14 +284,13 @@ record_open(file)
} }
static char expectbuf[100]; static char expectbuf[100];
static char *toktostr(); static const char *toktostr(tok_kind kind);
/* /*
* error, token encountered was not the expected one * error, token encountered was not the expected one
*/ */
void void
expected1(exp1) expected1(tok_kind exp1)
tok_kind exp1;
{ {
s_print(expectbuf, "expected '%s'", s_print(expectbuf, "expected '%s'",
toktostr(exp1)); toktostr(exp1));
@ -330,8 +301,7 @@ expected1(exp1)
* error, token encountered was not one of two expected ones * error, token encountered was not one of two expected ones
*/ */
void void
expected2(exp1, exp2) expected2(tok_kind exp1, tok_kind exp2)
tok_kind exp1, exp2;
{ {
s_print(expectbuf, "expected '%s' or '%s'", s_print(expectbuf, "expected '%s' or '%s'",
toktostr(exp1), toktostr(exp1),
@ -343,8 +313,7 @@ expected2(exp1, exp2)
* error, token encountered was not one of 3 expected ones * error, token encountered was not one of 3 expected ones
*/ */
void void
expected3(exp1, exp2, exp3) expected3(tok_kind exp1, tok_kind exp2, tok_kind exp3)
tok_kind exp1, exp2, exp3;
{ {
s_print(expectbuf, "expected '%s', '%s' or '%s'", s_print(expectbuf, "expected '%s', '%s' or '%s'",
toktostr(exp1), toktostr(exp1),
@ -354,9 +323,7 @@ expected3(exp1, exp2, exp3)
} }
void void
tabify(f, tab) tabify(FILE *f, int tab)
FILE *f;
int tab;
{ {
while (tab--) { while (tab--) {
(void) fputc('\t', f); (void) fputc('\t', f);
@ -401,9 +368,8 @@ static token tokstrings[] = {
{TOK_EOF, "??????"} {TOK_EOF, "??????"}
}; };
static char * static const char *
toktostr(kind) toktostr(tok_kind kind)
tok_kind kind;
{ {
token *sp; token *sp;
@ -412,7 +378,7 @@ toktostr(kind)
} }
static void static void
printbuf() printbuf(void)
{ {
char c; char c;
int i; int i;
@ -434,7 +400,7 @@ printbuf()
} }
static void static void
printwhere() printwhere(void)
{ {
int i; int i;
char c; char c;
@ -456,9 +422,7 @@ printwhere()
} }
char * char *
make_argname(pname, vname) make_argname(const char *pname, const char *vname)
char *pname;
char *vname;
{ {
char *name; char *name;
@ -471,9 +435,7 @@ bas_type *typ_list_h;
bas_type *typ_list_t; bas_type *typ_list_t;
void void
add_type(len, type) add_type(int len, const char *type)
int len;
char *type;
{ {
bas_type *ptr; bas_type *ptr;
@ -496,8 +458,8 @@ char *type;
} }
bas_type *find_type(type) bas_type *
char *type; find_type(const char *type)
{ {
bas_type * ptr; bas_type * ptr;

View File

@ -80,7 +80,7 @@ struct list {
typedef struct list list; typedef struct list list;
struct xdrfunc { struct xdrfunc {
char *name; const char *name;
int pointerp; int pointerp;
struct xdrfunc *next; struct xdrfunc *next;
}; };
@ -97,8 +97,8 @@ struct commandline {
int Ssflag; /* produce server sample code */ int Ssflag; /* produce server sample code */
int Scflag; /* produce client sample code */ int Scflag; /* produce client sample code */
int makefileflag; /* Generate a template Makefile */ int makefileflag; /* Generate a template Makefile */
char *infile; /* input module name */ const char *infile; /* input module name */
char *outfile; /* output module name */ const char *outfile; /* output module name */
}; };
#define PUT 1 #define PUT 1
@ -111,8 +111,9 @@ struct commandline {
extern char curline[MAXLINESIZE]; extern char curline[MAXLINESIZE];
extern char *where; extern char *where;
extern int linenum; extern int linenum;
extern int tirpc_socket;
extern char *infilename; extern const char *infilename;
extern FILE *fout; extern FILE *fout;
extern FILE *fin; extern FILE *fin;
@ -152,35 +153,36 @@ extern pid_t childpid;
*/ */
void reinitialize(void); void reinitialize(void);
void crash(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 storeval(list **lstp, definition *val);
void *xmalloc(size_t size); void *xmalloc(size_t size);
void *xrealloc(void *ptr, 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) \ #define STOREVAL(list,item) \
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) \ #define FINDVAL(list,item,finder) \
findval(list, item, finder) findval(list, item, finder)
char *fixtype(char *type); const char *fixtype(const char *type);
char *stringfix(char *type); const char *stringfix(const char *type);
char *locase(char *str); char *locase(const char *str);
void pvname_svc(char *pname, char *vnum); void pvname_svc(const char *pname, const char *vnum);
void pvname(char *pname, char *vnum); void pvname(const char *pname, const char *vnum);
void ptype(char *prefix, char *type, int follow); void ptype(const char *prefix, const char *type, int follow);
int isvectordef(char *type, relation rel); int isvectordef(const char *type, relation rel);
int streq(char *a, char *b); int streq(const char *a, const char *b);
void error(char *msg); void error(const char *msg);
void expected1(tok_kind exp1); void expected1(tok_kind exp1);
void expected2(tok_kind exp1, tok_kind exp2); void expected2(tok_kind exp1, tok_kind exp2);
void expected3(tok_kind exp1, tok_kind exp2, tok_kind exp3); void expected3(tok_kind exp1, tok_kind exp2, tok_kind exp3);
void tabify(FILE *f, int tab); void tabify(FILE *f, int tab);
void record_open(char *file); void record_open(const char *file);
bas_type *find_type(char *type); bas_type *find_type(const char *type);
/* /*
* rpc_cout routines * rpc_cout routines
@ -190,27 +192,39 @@ void emit(definition *def);
/* /*
* rpc_hout routines * rpc_hout routines
*/ */
void pdeclaration(const char *name, declaration *dec, int tab, const char *separator);
void print_datadef(definition *def, int headeronly); void print_datadef(definition *def, int headeronly);
void print_funcdef(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 * 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_rest(void);
void write_programs(char *storage); void write_programs(const char *storage);
void write_svc_aux(int nomain); void write_svc_aux(int nomain);
void write_inetd_register(char *transp); void write_inetd_register(const char *transp);
void write_netid_register(char *transp); void write_netid_register(const char *transp);
void write_nettype_register(char *transp); void write_nettype_register(const char *transp);
int nullproc(proc_list *proc);
/* /*
* rpc_clntout routines * rpc_clntout routines
*/ */
void write_stubs(void); void write_stubs(void);
void printarglist(proc_list *proc, const char *result, const char *addargname,
const char *addargtype);
/* /*
* rpc_tblout routines * rpc_tblout routines
*/ */
void write_tables(void); 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);