rpc_util.h revision 149695
11897Swollman/*
299979Salfred * $FreeBSD: head/usr.bin/rpcgen/rpc_util.h 149695 2005-09-01 19:16:25Z stefanf $
399979Salfred */
499979Salfred/*
51897Swollman * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
61897Swollman * unrestricted use provided that this legend is included on all tape
71897Swollman * media and as a part of the software program in whole or part.  Users
81897Swollman * may copy or modify Sun RPC without charge, but are not authorized
91897Swollman * to license or distribute it to anyone else except as part of a product or
101897Swollman * program developed by the user.
11100441Scharnier *
121897Swollman * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
131897Swollman * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
141897Swollman * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
15100441Scharnier *
161897Swollman * Sun RPC is provided with no support and without any obligation on the
171897Swollman * part of Sun Microsystems, Inc. to assist in its use, correction,
181897Swollman * modification or enhancement.
19100441Scharnier *
201897Swollman * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
211897Swollman * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
221897Swollman * OR ANY PART THEREOF.
23100441Scharnier *
241897Swollman * In no event will Sun Microsystems, Inc. be liable for any lost revenue
251897Swollman * or profits or other special, indirect and consequential damages, even if
261897Swollman * Sun has been advised of the possibility of such damages.
27100441Scharnier *
281897Swollman * Sun Microsystems, Inc.
291897Swollman * 2550 Garcia Avenue
301897Swollman * Mountain View, California  94043
311897Swollman */
3299979Salfred/* #pragma ident   "@(#)rpc_util.h 1.16     94/05/15 SMI" */
331897Swollman
3412798Swpaul/*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
3512798Swpaul/*	  All Rights Reserved  	*/
3612798Swpaul
3712798Swpaul/*	THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T	*/
3812798Swpaul/*	The copyright notice above does not evidence any   	*/
3912798Swpaul/*	actual or intended publication of such source code.	*/
4012798Swpaul
4112798Swpaul
4212798Swpaul/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4312798Swpaul*	PROPRIETARY NOTICE (Combined)
4412798Swpaul*
4512798Swpaul* This source code is unpublished proprietary information
4612798Swpaul* constituting, or derived under license from AT&T's UNIX(r) System V.
4712798Swpaul* In addition, portions of such source code were derived from Berkeley
4812798Swpaul* 4.3 BSD under license from the Regents of the University of
4912798Swpaul* California.
5012798Swpaul*
5112798Swpaul*
5212798Swpaul*
53100441Scharnier*	Copyright Notice
5412798Swpaul*
55100441Scharnier* Notice of copyright on this source code product does not indicate
5612798Swpaul*  publication.
5712798Swpaul*
5812798Swpaul*	(c) 1986,1987,1988.1989  Sun Microsystems, Inc
5912798Swpaul*	(c) 1983,1984,1985,1986,1987,1988,1989  AT&T.
6012798Swpaul*          All rights reserved.
61100441Scharnier*/
6212798Swpaul
6312798Swpaul/*      @(#)rpc_util.h  1.5  90/08/29  (C) 1987 SMI   */
6412798Swpaul
651897Swollman/*
66100441Scharnier * rpc_util.h, Useful definitions for the RPC protocol compiler
671897Swollman */
6812798Swpaul#include <sys/types.h>
6912798Swpaul#include <stdlib.h>
701897Swollman
71100441Scharnier#define	XALLOC(object)   (object *) xmalloc(sizeof(object))
721897Swollman
7312798Swpaul#define	s_print	(void) sprintf
7412798Swpaul#define	f_print (void) fprintf
751897Swollman
761897Swollmanstruct list {
7712798Swpaul	definition *val;
781897Swollman	struct list *next;
791897Swollman};
801897Swollmantypedef struct list list;
811897Swollman
8212798Swpaulstruct xdrfunc {
8312798Swpaul	char *name;
8412798Swpaul	int pointerp;
8512798Swpaul	struct xdrfunc *next;
8612798Swpaul};
8712798Swpaultypedef struct xdrfunc xdrfunc;
8812798Swpaul
8912798Swpaulstruct commandline {
9012798Swpaul	int cflag;		/* xdr C routines */
9112798Swpaul	int hflag;		/* header file */
9212798Swpaul	int lflag;		/* client side stubs */
9312798Swpaul	int mflag;		/* server side stubs */
9412798Swpaul	int nflag;		/* netid flag */
9512798Swpaul	int sflag;		/* server stubs for the given transport */
9612798Swpaul	int tflag;		/* dispatch Table file */
9712798Swpaul	int Ssflag;		/* produce server sample code */
9812798Swpaul	int Scflag;		/* produce client sample code */
9912798Swpaul	int makefileflag;       /* Generate a template Makefile */
10012798Swpaul	char *infile;		/* input module name */
10112798Swpaul	char *outfile;		/* output module name */
10212798Swpaul};
10312798Swpaul
10412798Swpaul#define	PUT 1
10512798Swpaul#define	GET 2
10612798Swpaul
1071897Swollman/*
108100441Scharnier * Global variables
1091897Swollman */
11012798Swpaul#define	MAXLINESIZE 1024
1111897Swollmanextern char curline[MAXLINESIZE];
1121897Swollmanextern char *where;
1131897Swollmanextern int linenum;
1141897Swollman
1151897Swollmanextern char *infilename;
1161897Swollmanextern FILE *fout;
1171897Swollmanextern FILE *fin;
1181897Swollman
1191897Swollmanextern list *defined;
1201897Swollman
12112798Swpaul
12212798Swpaulextern bas_type *typ_list_h;
12312798Swpaulextern bas_type *typ_list_t;
12412798Swpaulextern xdrfunc *xdrfunc_head, *xdrfunc_tail;
12512798Swpaul
1261897Swollman/*
12712798Swpaul * All the option flags
1281897Swollman */
12912798Swpaulextern int inetdflag;
130100441Scharnierextern int pmflag;
13112798Swpaulextern int tblflag;
13212798Swpaulextern int logflag;
13312798Swpaulextern int newstyle;
13412798Swpaulextern int Cflag;     /* ANSI-C/C++ flag */
13512798Swpaulextern int CCflag;     /* C++ flag */
13612798Swpaulextern int tirpcflag; /* flag for generating tirpc code */
137149680Sstefanfextern int inline_size; /* if this is 0, then do not generate inline code */
13812798Swpaulextern int mtflag;
13912798Swpaul
14012798Swpaul/*
14112798Swpaul * Other flags related with inetd jumpstart.
14212798Swpaul */
14312798Swpaulextern int indefinitewait;
14412798Swpaulextern int exitnow;
14512798Swpaulextern int timerflag;
14612798Swpaul
14712798Swpaulextern int nonfatalerrors;
14812798Swpaul
14912798Swpaulextern pid_t childpid;
15012798Swpaul
15112798Swpaul/*
152100441Scharnier * rpc_util routines
15312798Swpaul */
154149682Sstefanfvoid reinitialize(void);
155149682Sstefanfvoid crash(void);
15617142Sjkhvoid add_type(int len, char *type);
157149682Sstefanfvoid storeval(list **lstp, definition *val);
158100441Scharniervoid *xmalloc(size_t size);
159100441Scharniervoid *xrealloc(void *ptr, size_t size);
160100441Scharnierchar *xstrdup(const char *str);
1611897Swollman
16212798Swpaul#define	STOREVAL(list,item)	\
16312798Swpaul	storeval(list,item)
1641897Swollman
165149682Sstefanfdefinition *findval(list *lst, char *val, int (*cmp)(char *, char *));
1661897Swollman
16712798Swpaul#define	FINDVAL(list,item,finder) \
16812798Swpaul	findval(list, item, finder)
1691897Swollman
170149682Sstefanfchar *fixtype(char *type);
171149682Sstefanfchar *stringfix(char *type);
172149682Sstefanfchar *locase(char *str);
173149682Sstefanfvoid pvname_svc(char *pname, char *vnum);
174149682Sstefanfvoid pvname(char *pname, char *vnum);
175149682Sstefanfvoid ptype(char *prefix, char *type, int follow);
176149682Sstefanfint isvectordef(char *type, relation rel);
177149682Sstefanfint streq(char *a, char *b);
178149682Sstefanfvoid error(char *msg);
179149682Sstefanfvoid expected1(tok_kind exp1);
180149682Sstefanfvoid expected2(tok_kind exp1, tok_kind exp2);
181149682Sstefanfvoid expected3(tok_kind exp1, tok_kind exp2, tok_kind exp3);
182149682Sstefanfvoid tabify(FILE *f, int tab);
183149682Sstefanfvoid record_open(char *file);
184149682Sstefanfbas_type *find_type(char *type);
185149682Sstefanf
1861897Swollman/*
187100441Scharnier * rpc_cout routines
1881897Swollman */
189149682Sstefanfvoid emit(definition *def);
1901897Swollman
1911897Swollman/*
192100441Scharnier * rpc_hout routines
1931897Swollman */
194149695Sstefanfvoid print_datadef(definition *def, int headeronly);
195149695Sstefanfvoid print_funcdef(definition *def, int headeronly);
196149682Sstefanfvoid print_xdr_func_def(char* name, int pointerp, int i);
1971897Swollman
1981897Swollman/*
199100441Scharnier * rpc_svcout routines
2001897Swollman */
201149682Sstefanfvoid write_most(char *infile, int netflag, int nomain);
202149682Sstefanfvoid write_rest(void);
203149682Sstefanfvoid write_programs(char *storage);
204149682Sstefanfvoid write_svc_aux(int nomain);
205149682Sstefanfvoid write_inetd_register(char *transp);
206149682Sstefanfvoid write_netid_register(char *transp);
207149682Sstefanfvoid write_nettype_register(char *transp);
208149682Sstefanf
2091897Swollman/*
2101897Swollman * rpc_clntout routines
2111897Swollman */
212149682Sstefanfvoid write_stubs(void);
21312798Swpaul
21412798Swpaul/*
21512798Swpaul * rpc_tblout routines
21612798Swpaul */
217149682Sstefanfvoid write_tables(void);
218