diff options
author | dwmalone <dwmalone@FreeBSD.org> | 2005-11-13 21:17:24 +0000 |
---|---|---|
committer | dwmalone <dwmalone@FreeBSD.org> | 2005-11-13 21:17:24 +0000 |
commit | 6a5a7b72907b572a1303984c78ec91d10d86c3c1 (patch) | |
tree | 4bf46d50853a8d9b6bab2df1457113956a446b54 /usr.bin/rpcgen/rpc_util.c | |
parent | c55cb46497a04d7bb2ce10f34883f9f546d05d86 (diff) | |
download | FreeBSD-src-6a5a7b72907b572a1303984c78ec91d10d86c3c1.zip FreeBSD-src-6a5a7b72907b572a1303984c78ec91d10d86c3c1.tar.gz |
Use ANSI definitions.
Avoid using extern by declaring shared functions in header files.
Const poision.
Diffstat (limited to 'usr.bin/rpcgen/rpc_util.c')
-rw-r--r-- | usr.bin/rpcgen/rpc_util.c | 110 |
1 files changed, 36 insertions, 74 deletions
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; |