xref: /netbsd-src/usr.bin/rpcgen/rpc_util.h (revision 6a493d6bc668897c91594964a732d38505b70cbb)
1 /*	$NetBSD: rpc_util.h,v 1.8 2013/12/15 00:40:17 christos Exp $	*/
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 or with the express written consent of
9  * Sun Microsystems, Inc.
10  *
11  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
12  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
13  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
14  *
15  * Sun RPC is provided with no support and without any obligation on the
16  * part of Sun Microsystems, Inc. to assist in its use, correction,
17  * modification or enhancement.
18  *
19  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
20  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
21  * OR ANY PART THEREOF.
22  *
23  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
24  * or profits or other special, indirect and consequential damages, even if
25  * Sun has been advised of the possibility of such damages.
26  *
27  * Sun Microsystems, Inc.
28  * 2550 Garcia Avenue
29  * Mountain View, California  94043
30  */
31 
32 /*      @(#)rpc_util.h  1.5  90/08/29  (C) 1987 SMI   */
33 
34 /*
35  * rpc_util.h, Useful definitions for the RPC protocol compiler
36  */
37 
38 #define alloc(size)		(void *)malloc((unsigned)(size))
39 #define ALLOC(object)   (object *) malloc(sizeof(object))
40 
41 #define s_print	(void) sprintf
42 #define f_print (void) fprintf
43 
44 struct list {
45 	definition *val;
46 	struct list *next;
47 };
48 typedef struct list list;
49 
50 #define PUT 1
51 #define GET 2
52 
53 /*
54  * Global variables
55  */
56 #define MAXLINESIZE 1024
57 extern char curline[MAXLINESIZE];
58 extern char *where;
59 extern int linenum;
60 
61 extern const char *infilename;
62 extern FILE *fout;
63 extern FILE *fin;
64 
65 extern list *defined;
66 
67 
68 extern bas_type *typ_list_h;
69 extern bas_type *typ_list_t;
70 
71 /*
72  * All the option flags
73  */
74 extern int inetdflag;
75 extern int pmflag;
76 extern int tblflag;
77 extern int BSDflag;
78 extern int logflag;
79 extern int newstyle;
80 extern int Mflag;     /* multithread flag */
81 extern int tirpcflag; /* flag for generating tirpc code */
82 extern int doinline; /* if this is 0, then do not generate inline code */
83 extern int callerflag;
84 
85 /*
86  * Other flags related with inetd jumpstart.
87  */
88 extern int indefinitewait;
89 extern int exitnow;
90 extern int timerflag;
91 
92 extern int nonfatalerrors;
93 
94 /*
95  * rpc_util routines
96  */
97 
98 #define STOREVAL(list,item)	\
99 	storeval(list,item)
100 
101 #define FINDVAL(list,item,finder) \
102 	findval(list, item, finder)
103 
104 void reinitialize(void);
105 int streq(const char *, const char *);
106 definition *findval(list *, const char *,
107 			 int (*)(definition *, const char *));
108 void storeval(list **, definition *);
109 const char *fixtype(const char *);
110 const char *stringfix(const char *);
111 void ptype(const char *, const char *, int);
112 int isvectordef(const char *, relation);
113 char *locase(const char *);
114 void pvname_svc(const char *, const char *);
115 void pvname(const char *, const char *);
116 void error(const char *) __dead;
117 void crash(void) __dead;
118 void record_open(const char *);
119 void expected1(tok_kind) __dead;
120 void expected2(tok_kind, tok_kind) __dead;
121 void expected3(tok_kind, tok_kind, tok_kind) __dead;
122 void tabify(FILE *, int);
123 char *make_argname(const char *, const char *);
124 void add_type(int, const char *);
125 bas_type *find_type(const char *);
126 /*
127  * rpc_cout routines
128  */
129 void emit(definition *);
130 void emit_inline(declaration *, int);
131 void emit_single_in_line(declaration *, int, relation);
132 char *upcase(const char *);
133 
134 /*
135  * rpc_hout routines
136  */
137 
138 void print_datadef(definition *);
139 void print_progdef(definition *);
140 void print_funcdef(definition *, int *);
141 void print_funcend(int);
142 void pxdrfuncdecl(const char *, int);
143 void pprocdef(proc_list *, version_list *, const char *, int);
144 void pdeclaration(const char *, declaration *, int, const char *);
145 
146 /*
147  * rpc_svcout routines
148  */
149 void write_most(char *, int, int);
150 void write_netid_register(const char *);
151 void write_nettype_register(const char *);
152 void write_rest(void);
153 void write_programs(const char *);
154 int nullproc(proc_list *);
155 void write_svc_aux(int);
156 void write_msg_out(void);
157 void write_inetd_register(const char *);
158 
159 /*
160  * rpc_clntout routines
161  */
162 void write_stubs(void);
163 void printarglist(proc_list *, const char *, const char *, const char *);
164 
165 
166 /*
167  * rpc_tblout routines
168  */
169 void write_tables(void);
170 
171 /*
172  * rpc_sample routines
173  */
174 void write_sample_svc(definition *);
175 int write_sample_clnt(definition *);
176 void add_sample_msg(void);
177 void write_sample_clnt_main(void);
178