]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - usr.bin/rpcgen/rpc_util.h
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / usr.bin / rpcgen / rpc_util.h
1 /*
2  * $FreeBSD$
3  */
4 /*
5  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
6  * unrestricted use provided that this legend is included on all tape
7  * media and as a part of the software program in whole or part.  Users
8  * may copy or modify Sun RPC without charge, but are not authorized
9  * to license or distribute it to anyone else except as part of a product or
10  * program developed by the user.
11  *
12  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
13  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
14  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
15  *
16  * Sun RPC is provided with no support and without any obligation on the
17  * part of Sun Microsystems, Inc. to assist in its use, correction,
18  * modification or enhancement.
19  *
20  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
21  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
22  * OR ANY PART THEREOF.
23  *
24  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
25  * or profits or other special, indirect and consequential damages, even if
26  * Sun has been advised of the possibility of such damages.
27  *
28  * Sun Microsystems, Inc.
29  * 2550 Garcia Avenue
30  * Mountain View, California  94043
31  */
32 /* #pragma ident   "@(#)rpc_util.h 1.16     94/05/15 SMI" */
33
34 /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
35 /*        All Rights Reserved   */
36
37 /*      THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T     */
38 /*      The copyright notice above does not evidence any        */
39 /*      actual or intended publication of such source code.     */
40
41
42 /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
43 *       PROPRIETARY NOTICE (Combined)
44 *
45 * This source code is unpublished proprietary information
46 * constituting, or derived under license from AT&T's UNIX(r) System V.
47 * In addition, portions of such source code were derived from Berkeley
48 * 4.3 BSD under license from the Regents of the University of
49 * California.
50 *
51 *
52 *
53 *       Copyright Notice
54 *
55 * Notice of copyright on this source code product does not indicate
56 *  publication.
57 *
58 *       (c) 1986,1987,1988.1989  Sun Microsystems, Inc
59 *       (c) 1983,1984,1985,1986,1987,1988,1989  AT&T.
60 *          All rights reserved.
61 */
62
63 /*      @(#)rpc_util.h  1.5  90/08/29  (C) 1987 SMI   */
64
65 /*
66  * rpc_util.h, Useful definitions for the RPC protocol compiler
67  */
68 #include <sys/types.h>
69 #include <stdlib.h>
70
71 #define XALLOC(object)   (object *) xmalloc(sizeof(object))
72
73 #define s_print (void) sprintf
74 #define f_print (void) fprintf
75
76 struct list {
77         definition *val;
78         struct list *next;
79 };
80 typedef struct list list;
81
82 struct xdrfunc {
83         const char *name;
84         int pointerp;
85         struct xdrfunc *next;
86 };
87 typedef struct xdrfunc xdrfunc;
88
89 struct commandline {
90         int cflag;              /* xdr C routines */
91         int hflag;              /* header file */
92         int lflag;              /* client side stubs */
93         int mflag;              /* server side stubs */
94         int nflag;              /* netid flag */
95         int sflag;              /* server stubs for the given transport */
96         int tflag;              /* dispatch Table file */
97         int Ssflag;             /* produce server sample code */
98         int Scflag;             /* produce client sample code */
99         int makefileflag;       /* Generate a template Makefile */
100         const char *infile;     /* input module name */
101         const char *outfile;    /* output module name */
102 };
103
104 #define PUT 1
105 #define GET 2
106
107 /*
108  * Global variables
109  */
110 #define MAXLINESIZE 1024
111 extern char curline[MAXLINESIZE];
112 extern char *where;
113 extern int linenum;
114 extern int tirpc_socket;
115
116 extern const char *infilename;
117 extern FILE *fout;
118 extern FILE *fin;
119
120 extern list *defined;
121
122
123 extern bas_type *typ_list_h;
124 extern bas_type *typ_list_t;
125 extern xdrfunc *xdrfunc_head, *xdrfunc_tail;
126
127 /*
128  * All the option flags
129  */
130 extern int inetdflag;
131 extern int pmflag;
132 extern int tblflag;
133 extern int logflag;
134 extern int newstyle;
135 extern int CCflag;     /* C++ flag */
136 extern int tirpcflag; /* flag for generating tirpc code */
137 extern int inline_size; /* if this is 0, then do not generate inline code */
138 extern int mtflag;
139
140 /*
141  * Other flags related with inetd jumpstart.
142  */
143 extern int indefinitewait;
144 extern int exitnow;
145 extern int timerflag;
146
147 extern int nonfatalerrors;
148
149 extern pid_t childpid;
150
151 /*
152  * rpc_util routines
153  */
154 void reinitialize(void);
155 void crash(void);
156 void add_type(int len, const char *type);
157 void storeval(list **lstp, definition *val);
158 void *xmalloc(size_t size);
159 void *xrealloc(void *ptr, size_t size);
160 char *xstrdup(const char *);
161 char *make_argname(const char *pname, const char *vname);
162
163 #define STOREVAL(list,item)     \
164         storeval(list,item)
165
166 definition *findval(list *lst, const char *val, int (*cmp)(definition *, const char *));
167
168 #define FINDVAL(list,item,finder) \
169         findval(list, item, finder)
170
171 const char *fixtype(const char *type);
172 const char *stringfix(const char *type);
173 char *locase(const char *str);
174 void pvname_svc(const char *pname, const char *vnum);
175 void pvname(const char *pname, const char *vnum);
176 void ptype(const char *prefix, const char *type, int follow);
177 int isvectordef(const char *type, relation rel);
178 int streq(const char *a, const char *b);
179 void error(const char *msg);
180 void expected1(tok_kind exp1);
181 void expected2(tok_kind exp1, tok_kind exp2);
182 void expected3(tok_kind exp1, tok_kind exp2, tok_kind exp3);
183 void tabify(FILE *f, int tab);
184 void record_open(const char *file);
185 bas_type *find_type(const char *type);
186
187 /*
188  * rpc_cout routines
189  */
190 void emit(definition *def);
191
192 /*
193  * rpc_hout routines
194  */
195 void pdeclaration(const char *name, declaration *dec, int tab, const char *separator);
196 void print_datadef(definition *def, int headeronly);
197 void print_funcdef(definition *def, int headeronly);
198 void print_xdr_func_def(const char* name, int pointerp);
199
200 /*
201  * rpc_svcout routines
202  */
203 void write_most(const char *infile, int netflag, int nomain);
204 void write_rest(void);
205 void write_programs(const char *storage);
206 void write_svc_aux(int nomain);
207 void write_inetd_register(const char *transp);
208 void write_netid_register(const char *transp);
209 void write_nettype_register(const char *transp);
210 int nullproc(proc_list *proc);
211
212 /*
213  * rpc_clntout routines
214  */
215 void write_stubs(void);
216 void printarglist(proc_list *proc, const char *result, const char *addargname,
217     const char *addargtype);
218
219 /*
220  * rpc_tblout routines
221  */
222 void write_tables(void);
223
224 /*
225  * rpc_sample routines
226  */
227 void write_sample_svc(definition *);
228 int write_sample_clnt(definition *);
229 void write_sample_clnt_main(void);
230 void add_sample_msg(void);