2e316eaf90fccba53b559d6392662816ef3ccbc2
[openafs.git] / src / rxgen / rpc_util.h
1 /* @(#)rpc_util.h       1.2 87/11/24 3.9 RPCSRC */
2 /*
3  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
4  * unrestricted use provided that this legend is included on all tape
5  * media and as a part of the software program in whole or part.  Users
6  * may copy or modify Sun RPC without charge, but are not authorized
7  * to license or distribute it to anyone else except as part of a product or
8  * program developed by the user.
9  *
10  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
11  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
12  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
13  *
14  * Sun RPC is provided with no support and without any obligation on the
15  * part of Sun Microsystems, Inc. to assist in its use, correction,
16  * modification or enhancement.
17  *
18  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
19  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
20  * OR ANY PART THEREOF.
21  *
22  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
23  * or profits or other special, indirect and consequential damages, even if
24  * Sun has been advised of the possibility of such damages.
25  *
26  * Sun Microsystems, Inc.
27  * 2550 Garcia Avenue
28  * Mountain View, California  94043
29  */
30
31 /*
32  * rpc_util.h, Useful definitions for the RPC protocol compiler
33  * Copyright (C) 1987, Sun Microsystems, Inc.
34  */
35
36 #include "rxgen_consts.h"
37 #define alloc(size)             malloc((unsigned)(size))
38 #define ALLOC(object)   (object *) malloc(sizeof(object))
39
40 #define s_print (void) sprintf
41 #define f_print if (scan_print) (void) fprintf
42
43 struct list {
44     char *val;
45     struct list *next;
46 };
47 typedef struct list list;
48
49 #define MAXLINESIZE 1024
50
51
52 /* PROTOTYPES */
53
54 /* rpc_main.c */
55 extern char *prefix;
56 extern int nincludes;
57 extern char *OutFileFlag;
58 extern char OutFile[];
59 extern char Sflag, Cflag, hflag, cflag, kflag, uflag;
60 extern char ansic_flag;
61 extern char brief_flag;
62 extern char zflag;
63 extern char xflag;
64 extern char yflag;
65 extern int debug;
66
67
68 /* rpc_util.c */
69 extern char curline[];
70 extern char *where;
71 extern int linenum;
72 extern char *infilename;
73 extern char *outfiles[];
74 extern int nfiles;
75 extern FILE *fout;
76 extern FILE *fin;
77 extern list *defined;
78
79 extern void reinitialize(void);
80 extern int streq(char *a, char *b);
81 extern char *findval(list * lst, char *val,
82                      int (*cmp) (definition * def, char *type));
83 extern void storeval(list ** lstp, char *val);
84 extern char *fixtype(char *type);
85 extern char *stringfix(char *type);
86 extern void ptype(char *prefix, char *type, int follow);
87 extern int isvectordef(char *type, relation rel);
88 extern void pvname(char *pname, char *vnum);
89 extern void error(char *msg);
90 extern void crash(void);
91 extern void record_open(char *file);
92 extern void expected1(tok_kind exp1);
93 extern void expected2(tok_kind exp1, tok_kind exp2);
94 extern void expected3(tok_kind exp1, tok_kind exp2, tok_kind exp3);
95 extern void expected4(tok_kind exp1, tok_kind exp2, tok_kind exp3,
96                       tok_kind exp4);
97 extern void tabify(FILE * f, int tab);
98
99 #define STOREVAL(list,item)     \
100         storeval(list,(char *)item)
101
102 #define FINDVAL(list,item,finder) \
103         findval(list, (char *) item, finder)
104
105 /* rpc_clntout.c */
106 extern void write_stubs(void);
107
108 /* rpc_cout.c */
109 extern void emit(definition * def);
110 extern void print_param(declaration * dec);
111
112 /* rpc_hout.c */
113 extern void print_datadef(definition * def);
114 extern void pdefine(char *name, char *num);
115 extern void pprocdef(proc_list * proc, version_list * vp);
116
117 /* rpc_parse.c */
118 extern list *proc_defined[MAX_PACKAGES], *special_defined, *typedef_defined,
119     *uniondef_defined;
120 extern char *SplitStart;
121 extern char *SplitEnd;
122 extern char *MasterPrefix;
123 extern char *ServerPrefix;
124 extern char *PackagePrefix[];
125 extern char *PackageStatIndex[];
126 extern int no_of_stat_funcs;
127 extern int no_of_stat_funcs_header[];
128 extern int no_of_opcodes[], master_no_of_opcodes;
129 extern int lowest_opcode[], master_lowest_opcode;
130 extern int highest_opcode[], master_highest_opcode;
131 extern int master_opcodenumber;
132 extern int opcodesnotallowed[];
133 extern int combinepackages;
134 extern int PackageIndex;
135 extern int PerProcCounter;
136 extern int Multi_Init;
137 extern char function_list[MAX_PACKAGES]
138     [MAX_FUNCTIONS_PER_PACKAGE]
139     [MAX_FUNCTION_NAME_LEN];
140 extern int function_list_index;
141
142 extern definition *get_definition(void);
143
144 extern void er_Proc_CodeGeneration(void);
145 extern void h_Proc_CodeGeneration(void);
146 extern void h_opcode_stats(void);
147 extern void generate_multi_macros(definition * defp);
148 extern int IsRxgenToken(token * tokp);
149 extern int IsRxgenDefinition(definition * def);
150
151
152
153
154 extern proc1_list *Proc_list, **Proc_listp;
155
156
157 /* rpc_svcout.c */
158 extern int nullproc(proc_list * proc);
159 extern void write_programs(char *storage);
160 extern void write_rest(void);
161 extern void write_most(void);
162 extern void write_register(char *transp);
163
164 /* rpc_scan.c */
165 extern int pushed;
166 extern token lasttok;
167 extern int scan_print;
168
169 extern void scan(tok_kind expect, token * tokp);
170 extern void scan2(tok_kind expect1, tok_kind expect2, token * tokp);
171 extern void scan3(tok_kind expect1, tok_kind expect2, tok_kind expect3,
172                   token * tokp);
173 extern void scan4(tok_kind expect1, tok_kind expect2, tok_kind expect3,
174                   tok_kind expect4, token * tokp);
175 extern void scan_num(token * tokp);
176 extern void peek(token * tokp);
177 extern int peekscan(tok_kind expect, token * tokp);
178 extern void get_token(token * tokp);
179 extern void unget_token(token * tokp);
180 extern void findkind(char **mark, token * tokp);
181 extern void printdirective(char *line);