reindent-20030715
[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;
60 extern char zflag;
61 extern char xflag;
62 extern char yflag;
63 extern int debug;
64
65
66 /* rpc_util.c */
67 extern char curline[];
68 extern char *where;
69 extern int linenum;
70 extern char *infilename;
71 extern char *outfiles[];
72 extern int nfiles;
73 extern FILE *fout;
74 extern FILE *fin;
75 extern list *defined;
76
77 extern void reinitialize(void);
78 extern int streq(char *a, char *b);
79 extern char *findval(list * lst, char *val,
80                      int (*cmp) (definition * def, char *type));
81 extern void storeval(list ** lstp, char *val);
82 extern char *fixtype(char *type);
83 extern char *stringfix(char *type);
84 extern void ptype(char *prefix, char *type, int follow);
85 extern int isvectordef(char *type, relation rel);
86 extern void pvname(char *pname, char *vnum);
87 extern void error(char *msg);
88 extern void crash(void);
89 extern void record_open(char *file);
90 extern void expected1(tok_kind exp1);
91 extern void expected2(tok_kind exp1, tok_kind exp2);
92 extern void expected3(tok_kind exp1, tok_kind exp2, tok_kind exp3);
93 extern void expected4(tok_kind exp1, tok_kind exp2, tok_kind exp3,
94                       tok_kind exp4);
95 extern void tabify(FILE * f, int tab);
96
97 #define STOREVAL(list,item)     \
98         storeval(list,(char *)item)
99
100 #define FINDVAL(list,item,finder) \
101         findval(list, (char *) item, finder)
102
103 /* rpc_clntout.c */
104 extern void write_stubs(void);
105
106 /* rpc_cout.c */
107 extern void emit(definition * def);
108 extern void print_param(declaration * dec);
109
110 /* rpc_hout.c */
111 extern void print_datadef(definition * def);
112 extern void pdefine(char *name, char *num);
113 extern void pprocdef(proc_list * proc, version_list * vp);
114
115 /* rpc_parse.c */
116 extern list *proc_defined[MAX_PACKAGES], *special_defined, *typedef_defined,
117     *uniondef_defined;
118 extern char *SplitStart;
119 extern char *SplitEnd;
120 extern char *MasterPrefix;
121 extern char *ServerPrefix;
122 extern char *PackagePrefix[];
123 extern char *PackageStatIndex[];
124 extern int no_of_stat_funcs;
125 extern int no_of_stat_funcs_header[];
126 extern int no_of_opcodes[], master_no_of_opcodes;
127 extern int lowest_opcode[], master_lowest_opcode;
128 extern int highest_opcode[], master_highest_opcode;
129 extern int master_opcodenumber;
130 extern int opcodesnotallowed[];
131 extern int combinepackages;
132 extern int PackageIndex;
133 extern int PerProcCounter;
134 extern int Multi_Init;
135 extern char function_list[MAX_PACKAGES]
136     [MAX_FUNCTIONS_PER_PACKAGE]
137     [MAX_FUNCTION_NAME_LEN];
138 extern int function_list_index;
139
140 extern definition *get_definition(void);
141
142 extern void er_Proc_CodeGeneration(void);
143 extern void h_opcode_stats(void);
144 extern void generate_multi_macros(definition * defp);
145 extern int IsRxgenToken(token * tokp);
146 extern int IsRxgenDefinition(definition * def);
147
148
149
150
151 extern proc1_list *Proc_list, **Proc_listp;
152
153
154 /* rpc_svcout.c */
155 extern int nullproc(proc_list * proc);
156 extern void write_programs(char *storage);
157 extern void write_rest(void);
158 extern void write_most(void);
159 extern void write_register(char *transp);
160
161 /* rpc_scan.c */
162 extern int pushed;
163 extern token lasttok;
164 extern int scan_print;
165
166 extern void scan(tok_kind expect, token * tokp);
167 extern void scan2(tok_kind expect1, tok_kind expect2, token * tokp);
168 extern void scan3(tok_kind expect1, tok_kind expect2, tok_kind expect3,
169                   token * tokp);
170 extern void scan4(tok_kind expect1, tok_kind expect2, tok_kind expect3,
171                   tok_kind expect4, token * tokp);
172 extern void scan_num(token * tokp);
173 extern void peek(token * tokp);
174 extern int peekscan(tok_kind expect, token * tokp);
175 extern void get_token(token * tokp);
176 extern void unget_token(token * tokp);
177 extern void findkind(char **mark, token * tokp);
178 extern void printdirective(char *line);