#include <strings.h>
#endif
#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
#include "rpc_scan.h"
#include "rpc_parse.h"
#include "rpc_util.h"
list *defined; /* list of defined things */
-static printwhere();
+/* static prototypes */
+static int findit(definition *def, char *type);
+static char *fixit(char *type, char *orig);
+static int typedefed(definition *def, char *type);
+static char *locase(char *str);
+static char *toktostr(tok_kind kind);
+static void printbuf(void);
+static void printwhere(void);
+
/*
* Reinitialize the world
*/
-reinitialize()
+void reinitialize(void)
{
int i;
memset(curline, 0, MAXLINESIZE);
/*
* string equality
*/
-streq(a, b)
- char *a;
- char *b;
+int streq(char *a, char *b)
{
return (strcmp(a, b) == 0);
}
/*
* find a value in a list
*/
-char *
-findval(lst, val, cmp)
- list *lst;
- char *val;
- int (*cmp) ();
-
+char *findval(list *lst, char *val, int (*cmp)(definition *def, char *type))
{
for (; lst != NULL; lst = lst->next) {
- if ((*cmp) (lst->val, val)) {
+ if ((*cmp) ((definition *) lst->val, val)) {
return (lst->val);
}
}
/*
* store a value in a list
*/
-void
-storeval(lstp, val)
- list **lstp;
- char *val;
+void storeval(list **lstp, char *val)
{
list **l;
list *lst;
}
-static
-findit(def, type)
- definition *def;
- char *type;
+static int findit(definition *def, char *type)
{
return (streq(def->def_name, type));
}
-static char *
-fixit(type, orig)
- char *type;
- char *orig;
+static char *fixit(char *type, char *orig)
{
definition *def;
}
}
-char *
-fixtype(type)
- char *type;
+char *fixtype(char *type)
{
return (fixit(type, type));
}
-char *
-stringfix(type)
- char *type;
+char *stringfix(char *type)
{
if (streq(type, "string")) {
return ("wrapstring");
}
}
-void
-ptype(prefix, type, follow)
- char *prefix;
- char *type;
- int follow;
+void ptype(char *prefix, char *type, int follow)
{
if (prefix != NULL) {
if (streq(prefix, "enum")) {
}
-static
-typedefed(def, type)
- definition *def;
- char *type;
+static int typedefed(definition *def, char *type)
{
if (def->def_kind != DEF_TYPEDEF || def->def.ty.old_prefix != NULL) {
return (0);
}
}
-isvectordef(type, rel)
- char *type;
- relation rel;
+int isvectordef(char *type, relation rel)
{
definition *def;
}
-static char *
-locase(str)
- char *str;
+static char *locase(char *str)
{
char c;
static char buf[100];
char *p = buf;
- while (c = *str++) {
+ while ((c = *str++)) {
*p++ = (c >= 'A' && c <= 'Z') ? (c - 'A' + 'a') : c;
}
*p = 0;
}
-void
-pvname(pname, vnum)
- char *pname;
- char *vnum;
+void pvname(char *pname, char *vnum)
{
f_print(fout, "%s_%s", locase(pname), vnum);
}
/*
* print a useful (?) error message, and then die
*/
-void
-error(msg)
- char *msg;
+void error(char *msg)
{
printwhere();
f_print(stderr, "%s, line %d: ", infilename, linenum);
* Something went wrong, unlink any files that we may have created and then
* die.
*/
-crash()
+void crash(void)
{
int i;
}
-void
-record_open(file)
- char *file;
+void record_open(char *file)
{
if (nfiles < NFILES) {
outfiles[nfiles++] = file;
}
}
+/* buffer shared for all of the expected* routines */
static char expectbuf[100];
-static char *toktostr();
/*
* error, token encountered was not the expected one
*/
-void
-expected1(exp1)
- tok_kind exp1;
+void expected1(tok_kind exp1)
{
s_print(expectbuf, "expected '%s'",
toktostr(exp1));
/*
* error, token encountered was not one of two expected ones
*/
-void
-expected2(exp1, exp2)
- tok_kind exp1, exp2;
+void expected2(tok_kind exp1, tok_kind exp2)
{
s_print(expectbuf, "expected '%s' or '%s'",
toktostr(exp1),
/*
* error, token encountered was not one of 3 expected ones
*/
-void
-expected3(exp1, exp2, exp3)
- tok_kind exp1, exp2, exp3;
+void expected3(tok_kind exp1, tok_kind exp2, tok_kind exp3)
{
s_print(expectbuf, "expected '%s', '%s' or '%s'",
toktostr(exp1),
/*
* error, token encountered was not one of 4 expected ones
*/
-void
-expected4(exp1,exp2,exp3,exp4)
- tok_kind exp1,exp2,exp3,exp4;
+void expected4(tok_kind exp1, tok_kind exp2, tok_kind exp3, tok_kind exp4)
{
sprintf(expectbuf,"expected '%s', '%s', '%s', or '%s'",
toktostr(exp1),
error(expectbuf);
}
-void
-tabify(f, tab)
- FILE *f;
- int tab;
+void tabify(FILE *f, int tab)
{
if (scan_print)
while (tab--) {
}
}
-
-
static token tokstrings[] = {
- {TOK_IDENT, "identifier"},
- {TOK_CONST, "const"},
- {TOK_RPAREN, ")"},
- {TOK_LPAREN, "("},
- {TOK_RBRACE, "}"},
- {TOK_LBRACE, "{"},
- {TOK_LBRACKET, "["},
- {TOK_RBRACKET, "]"},
- {TOK_STAR, "*"},
- {TOK_COMMA, ","},
- {TOK_EQUAL, "="},
- {TOK_COLON, ":"},
- {TOK_SEMICOLON, ";"},
- {TOK_UNION, "union"},
- {TOK_STRUCT, "struct"},
- {TOK_SWITCH, "switch"},
- {TOK_CASE, "case"},
- {TOK_DEFAULT, "default"},
- {TOK_ENUM, "enum"},
- {TOK_TYPEDEF, "typedef"},
- {TOK_INT, "int"},
- {TOK_SHORT, "short"},
- {TOK_INT32, "afs_int32"}, /* XXX */
- {TOK_UNSIGNED, "unsigned"},
- {TOK_DOUBLE, "double"},
- {TOK_FLOAT, "float"},
- {TOK_CHAR, "char"},
- {TOK_STRING, "string"},
- {TOK_OPAQUE, "opaque"},
- {TOK_BOOL, "bool"},
- {TOK_VOID, "void"},
- {TOK_PROGRAM, "program"},
- {TOK_VERSION, "version"},
- { TOK_PACKAGE, "package" },
- { TOK_PREFIX, "prefix" },
- { TOK_STATINDEX, "statindex" },
- { TOK_SPECIAL, "special" },
- { TOK_STARTINGOPCODE, "startingopcode" },
- { TOK_CUSTOMIZED, "customized" },
- { TOK_PROC, "proc" },
- { TOK_SPLITPREFIX, "splitprefix" },
- { TOK_SPLIT, "split" },
- { TOK_MULTI, "multi" },
- { TOK_IN, "IN" },
- { TOK_OUT, "OUT" },
- { TOK_INOUT, "INOUT" },
- { TOK_AFSUUID, "afsUUID" },
- {TOK_EOF, "??????"}
+ { TOK_IDENT, "identifier"},
+ { TOK_CONST, "const"},
+ { TOK_RPAREN, ")"},
+ { TOK_LPAREN, "("},
+ { TOK_RBRACE, "}"},
+ { TOK_LBRACE, "{"},
+ { TOK_LBRACKET, "["},
+ { TOK_RBRACKET, "]"},
+ { TOK_STAR, "*"},
+ { TOK_COMMA, ","},
+ { TOK_EQUAL, "="},
+ { TOK_COLON, ":"},
+ { TOK_SEMICOLON, ";"},
+ { TOK_UNION, "union"},
+ { TOK_STRUCT, "struct"},
+ { TOK_SWITCH, "switch"},
+ { TOK_CASE, "case"},
+ { TOK_DEFAULT, "default"},
+ { TOK_ENUM, "enum"},
+ { TOK_TYPEDEF, "typedef"},
+ { TOK_INT, "int"},
+ { TOK_SHORT, "short"},
+ { TOK_INT32, "afs_int32"}, /* XXX */
+ { TOK_UNSIGNED, "unsigned"},
+ { TOK_DOUBLE, "double"},
+ { TOK_FLOAT, "float"},
+ { TOK_CHAR, "char"},
+ { TOK_STRING, "string"},
+ { TOK_OPAQUE, "opaque"},
+ { TOK_BOOL, "bool"},
+ { TOK_VOID, "void"},
+ { TOK_PROGRAM, "program"},
+ { TOK_VERSION, "version"},
+ { TOK_PACKAGE, "package" },
+ { TOK_PREFIX, "prefix" },
+ { TOK_STATINDEX, "statindex" },
+ { TOK_SPECIAL, "special" },
+ { TOK_STARTINGOPCODE, "startingopcode" },
+ { TOK_CUSTOMIZED, "customized" },
+ { TOK_PROC, "proc" },
+ { TOK_SPLITPREFIX, "splitprefix" },
+ { TOK_SPLIT, "split" },
+ { TOK_MULTI, "multi" },
+ { TOK_IN, "IN" },
+ { TOK_OUT, "OUT" },
+ { TOK_INOUT, "INOUT" },
+ { TOK_AFSUUID, "afsUUID" },
+ { TOK_EOF, "??????"}
};
-static char *
-toktostr(kind)
- tok_kind kind;
+static char *toktostr(tok_kind kind)
{
token *sp;
-static
-printbuf()
+static void printbuf(void)
{
char c;
int i;
# define TABSIZE 4
- for (i = 0; c = curline[i]; i++) {
+ for (i = 0; (c = curline[i]); i++) {
if (c == '\t') {
cnt = 8 - (i % TABSIZE);
c = ' ';
cnt = 1;
}
while (cnt--) {
- (void) fputc(c, stderr);
+ fputc(c, stderr);
}
}
}
-static
-printwhere()
+static void printwhere(void)
{
int i;
char c;
cnt = 1;
}
while (cnt--) {
- (void) fputc('^', stderr);
+ fputc('^', stderr);
}
}
- (void) fputc('\n', stderr);
+ fputc('\n', stderr);
}