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