xref: /freebsd/usr.bin/rpcgen/rpc_util.h (revision ff49530f45dc674ce45ec75d7d33218f97c79b42)
14e115012SGarrett Wollman /*
24e115012SGarrett Wollman  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
34e115012SGarrett Wollman  * unrestricted use provided that this legend is included on all tape
44e115012SGarrett Wollman  * media and as a part of the software program in whole or part.  Users
54e115012SGarrett Wollman  * may copy or modify Sun RPC without charge, but are not authorized
64e115012SGarrett Wollman  * to license or distribute it to anyone else except as part of a product or
74e115012SGarrett Wollman  * program developed by the user.
84e115012SGarrett Wollman  *
94e115012SGarrett Wollman  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
104e115012SGarrett Wollman  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
114e115012SGarrett Wollman  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
124e115012SGarrett Wollman  *
134e115012SGarrett Wollman  * Sun RPC is provided with no support and without any obligation on the
144e115012SGarrett Wollman  * part of Sun Microsystems, Inc. to assist in its use, correction,
154e115012SGarrett Wollman  * modification or enhancement.
164e115012SGarrett Wollman  *
174e115012SGarrett Wollman  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
184e115012SGarrett Wollman  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
194e115012SGarrett Wollman  * OR ANY PART THEREOF.
204e115012SGarrett Wollman  *
214e115012SGarrett Wollman  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
224e115012SGarrett Wollman  * or profits or other special, indirect and consequential damages, even if
234e115012SGarrett Wollman  * Sun has been advised of the possibility of such damages.
244e115012SGarrett Wollman  *
254e115012SGarrett Wollman  * Sun Microsystems, Inc.
264e115012SGarrett Wollman  * 2550 Garcia Avenue
274e115012SGarrett Wollman  * Mountain View, California  94043
284e115012SGarrett Wollman  */
29ff49530fSBill Paul #pragma ident   "@(#)rpc_util.h 1.16     94/05/15 SMI"
30ff49530fSBill Paul 
31ff49530fSBill Paul /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
32ff49530fSBill Paul /*	  All Rights Reserved  	*/
33ff49530fSBill Paul 
34ff49530fSBill Paul /*	THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T	*/
35ff49530fSBill Paul /*	The copyright notice above does not evidence any   	*/
36ff49530fSBill Paul /*	actual or intended publication of such source code.	*/
37ff49530fSBill Paul 
38ff49530fSBill Paul 
39ff49530fSBill Paul /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
40ff49530fSBill Paul *	PROPRIETARY NOTICE (Combined)
41ff49530fSBill Paul *
42ff49530fSBill Paul * This source code is unpublished proprietary information
43ff49530fSBill Paul * constituting, or derived under license from AT&T's UNIX(r) System V.
44ff49530fSBill Paul * In addition, portions of such source code were derived from Berkeley
45ff49530fSBill Paul * 4.3 BSD under license from the Regents of the University of
46ff49530fSBill Paul * California.
47ff49530fSBill Paul *
48ff49530fSBill Paul *
49ff49530fSBill Paul *
50ff49530fSBill Paul *	Copyright Notice
51ff49530fSBill Paul *
52ff49530fSBill Paul * Notice of copyright on this source code product does not indicate
53ff49530fSBill Paul *  publication.
54ff49530fSBill Paul *
55ff49530fSBill Paul *	(c) 1986,1987,1988.1989  Sun Microsystems, Inc
56ff49530fSBill Paul *	(c) 1983,1984,1985,1986,1987,1988,1989  AT&T.
57ff49530fSBill Paul *          All rights reserved.
58ff49530fSBill Paul */
59ff49530fSBill Paul 
60ff49530fSBill Paul /*      @(#)rpc_util.h  1.5  90/08/29  (C) 1987 SMI   */
614e115012SGarrett Wollman 
624e115012SGarrett Wollman /*
634e115012SGarrett Wollman  * rpc_util.h, Useful definitions for the RPC protocol compiler
644e115012SGarrett Wollman  */
65ff49530fSBill Paul #include <sys/types.h>
66ff49530fSBill Paul #include <stdlib.h>
674e115012SGarrett Wollman 
684e115012SGarrett Wollman #define	alloc(size)		malloc((unsigned)(size))
694e115012SGarrett Wollman #define	ALLOC(object)   (object *) malloc(sizeof(object))
704e115012SGarrett Wollman 
714e115012SGarrett Wollman #define	s_print	(void) sprintf
724e115012SGarrett Wollman #define	f_print (void) fprintf
734e115012SGarrett Wollman 
744e115012SGarrett Wollman struct list {
75ff49530fSBill Paul 	definition *val;
764e115012SGarrett Wollman 	struct list *next;
774e115012SGarrett Wollman };
784e115012SGarrett Wollman typedef struct list list;
794e115012SGarrett Wollman 
80ff49530fSBill Paul struct xdrfunc {
81ff49530fSBill Paul 	char *name;
82ff49530fSBill Paul 	int pointerp;
83ff49530fSBill Paul 	struct xdrfunc *next;
84ff49530fSBill Paul };
85ff49530fSBill Paul typedef struct xdrfunc xdrfunc;
86ff49530fSBill Paul 
87ff49530fSBill Paul struct commandline {
88ff49530fSBill Paul 	int cflag;		/* xdr C routines */
89ff49530fSBill Paul 	int hflag;		/* header file */
90ff49530fSBill Paul 	int lflag;		/* client side stubs */
91ff49530fSBill Paul 	int mflag;		/* server side stubs */
92ff49530fSBill Paul 	int nflag;		/* netid flag */
93ff49530fSBill Paul 	int sflag;		/* server stubs for the given transport */
94ff49530fSBill Paul 	int tflag;		/* dispatch Table file */
95ff49530fSBill Paul 	int Ssflag;		/* produce server sample code */
96ff49530fSBill Paul 	int Scflag;		/* produce client sample code */
97ff49530fSBill Paul 	int makefileflag;       /* Generate a template Makefile */
98ff49530fSBill Paul 	char *infile;		/* input module name */
99ff49530fSBill Paul 	char *outfile;		/* output module name */
100ff49530fSBill Paul };
101ff49530fSBill Paul 
102ff49530fSBill Paul #define	PUT 1
103ff49530fSBill Paul #define	GET 2
104ff49530fSBill Paul 
1054e115012SGarrett Wollman /*
1064e115012SGarrett Wollman  * Global variables
1074e115012SGarrett Wollman  */
1084e115012SGarrett Wollman #define	MAXLINESIZE 1024
1094e115012SGarrett Wollman extern char curline[MAXLINESIZE];
1104e115012SGarrett Wollman extern char *where;
1114e115012SGarrett Wollman extern int linenum;
1124e115012SGarrett Wollman 
1134e115012SGarrett Wollman extern char *infilename;
1144e115012SGarrett Wollman extern FILE *fout;
1154e115012SGarrett Wollman extern FILE *fin;
1164e115012SGarrett Wollman 
1174e115012SGarrett Wollman extern list *defined;
1184e115012SGarrett Wollman 
119ff49530fSBill Paul 
120ff49530fSBill Paul extern bas_type *typ_list_h;
121ff49530fSBill Paul extern bas_type *typ_list_t;
122ff49530fSBill Paul extern xdrfunc *xdrfunc_head, *xdrfunc_tail;
123ff49530fSBill Paul 
124ff49530fSBill Paul /*
125ff49530fSBill Paul  * All the option flags
126ff49530fSBill Paul  */
127ff49530fSBill Paul extern int inetdflag;
128ff49530fSBill Paul extern int pmflag;
129ff49530fSBill Paul extern int tblflag;
130ff49530fSBill Paul extern int logflag;
131ff49530fSBill Paul extern int newstyle;
132ff49530fSBill Paul extern int Cflag;     /* ANSI-C/C++ flag */
133ff49530fSBill Paul extern int CCflag;     /* C++ flag */
134ff49530fSBill Paul extern int tirpcflag; /* flag for generating tirpc code */
135ff49530fSBill Paul extern int inline; /* if this is 0, then do not generate inline code */
136ff49530fSBill Paul extern int mtflag;
137ff49530fSBill Paul 
138ff49530fSBill Paul /*
139ff49530fSBill Paul  * Other flags related with inetd jumpstart.
140ff49530fSBill Paul  */
141ff49530fSBill Paul extern int indefinitewait;
142ff49530fSBill Paul extern int exitnow;
143ff49530fSBill Paul extern int timerflag;
144ff49530fSBill Paul 
145ff49530fSBill Paul extern int nonfatalerrors;
146ff49530fSBill Paul 
147ff49530fSBill Paul extern pid_t childpid;
148ff49530fSBill Paul 
1494e115012SGarrett Wollman /*
1504e115012SGarrett Wollman  * rpc_util routines
1514e115012SGarrett Wollman  */
1524e115012SGarrett Wollman void storeval();
1534e115012SGarrett Wollman 
1544e115012SGarrett Wollman #define	STOREVAL(list,item)	\
155ff49530fSBill Paul 	storeval(list,item)
1564e115012SGarrett Wollman 
157ff49530fSBill Paul definition *findval();
1584e115012SGarrett Wollman 
1594e115012SGarrett Wollman #define	FINDVAL(list,item,finder) \
160ff49530fSBill Paul 	findval(list, item, finder)
1614e115012SGarrett Wollman 
1624e115012SGarrett Wollman char *fixtype();
1634e115012SGarrett Wollman char *stringfix();
164ff49530fSBill Paul char *locase();
165ff49530fSBill Paul void pvname_svc();
1664e115012SGarrett Wollman void pvname();
1674e115012SGarrett Wollman void ptype();
1684e115012SGarrett Wollman int isvectordef();
1694e115012SGarrett Wollman int streq();
1704e115012SGarrett Wollman void error();
1714e115012SGarrett Wollman void expected1();
1724e115012SGarrett Wollman void expected2();
1734e115012SGarrett Wollman void expected3();
1744e115012SGarrett Wollman void tabify();
1754e115012SGarrett Wollman void record_open();
176ff49530fSBill Paul bas_type *find_type();
1774e115012SGarrett Wollman /*
1784e115012SGarrett Wollman  * rpc_cout routines
1794e115012SGarrett Wollman  */
1804e115012SGarrett Wollman void cprint();
1814e115012SGarrett Wollman void emit();
1824e115012SGarrett Wollman 
1834e115012SGarrett Wollman /*
1844e115012SGarrett Wollman  * rpc_hout routines
1854e115012SGarrett Wollman  */
1864e115012SGarrett Wollman void print_datadef();
187ff49530fSBill Paul void print_funcdef();
188ff49530fSBill Paul void print_xdr_func_def();
1894e115012SGarrett Wollman 
1904e115012SGarrett Wollman /*
1914e115012SGarrett Wollman  * rpc_svcout routines
1924e115012SGarrett Wollman  */
1934e115012SGarrett Wollman void write_most();
1944e115012SGarrett Wollman void write_register();
1954e115012SGarrett Wollman void write_rest();
196ff49530fSBill Paul void write_programs();
197ff49530fSBill Paul void write_svc_aux();
198ff49530fSBill Paul void write_inetd_register();
199ff49530fSBill Paul void write_netid_register();
200ff49530fSBill Paul void write_nettype_register();
2014e115012SGarrett Wollman /*
2024e115012SGarrett Wollman  * rpc_clntout routines
2034e115012SGarrett Wollman  */
2044e115012SGarrett Wollman void write_stubs();
205ff49530fSBill Paul 
206ff49530fSBill Paul /*
207ff49530fSBill Paul  * rpc_tblout routines
208ff49530fSBill Paul  */
209ff49530fSBill Paul void write_tables();
210