xref: /titanic_52/usr/src/cmd/rpcgen/rpc_util.h (revision 61961e0f20c7637a3846bb39786bb9dffa91dfb9)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
22*61961e0fSrobinson 
237c478bd9Sstevel@tonic-gate /*
247c478bd9Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
257c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
267c478bd9Sstevel@tonic-gate  */
277c478bd9Sstevel@tonic-gate /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
287c478bd9Sstevel@tonic-gate /* All Rights Reserved */
297c478bd9Sstevel@tonic-gate /*
307c478bd9Sstevel@tonic-gate  * University Copyright- Copyright (c) 1982, 1986, 1988
317c478bd9Sstevel@tonic-gate  * The Regents of the University of California
327c478bd9Sstevel@tonic-gate  * All Rights Reserved
337c478bd9Sstevel@tonic-gate  *
347c478bd9Sstevel@tonic-gate  * University Acknowledgment- Portions of this document are derived from
357c478bd9Sstevel@tonic-gate  * software developed by the University of California, Berkeley, and its
367c478bd9Sstevel@tonic-gate  * contributors.
377c478bd9Sstevel@tonic-gate  */
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate #ifndef _RPC_UTIL_H
407c478bd9Sstevel@tonic-gate #define	_RPC_UTIL_H
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
437c478bd9Sstevel@tonic-gate 
447c478bd9Sstevel@tonic-gate #include <sys/types.h>
457c478bd9Sstevel@tonic-gate #include <stdlib.h>
46*61961e0fSrobinson #include "rpc_scan.h"
477c478bd9Sstevel@tonic-gate 
487c478bd9Sstevel@tonic-gate #ifdef __cplusplus
497c478bd9Sstevel@tonic-gate extern "C" {
507c478bd9Sstevel@tonic-gate #endif
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate /*
537c478bd9Sstevel@tonic-gate  * rpc_util.h, Useful definitions for the RPC protocol compiler
547c478bd9Sstevel@tonic-gate  */
557c478bd9Sstevel@tonic-gate 
567c478bd9Sstevel@tonic-gate 
577c478bd9Sstevel@tonic-gate /* Current version number of rpcgen. */
587c478bd9Sstevel@tonic-gate #define	RPCGEN_MAJOR 1
597c478bd9Sstevel@tonic-gate #define	RPCGEN_MINOR 1
607c478bd9Sstevel@tonic-gate 
617c478bd9Sstevel@tonic-gate #define	f_print (void) fprintf
627c478bd9Sstevel@tonic-gate 
637c478bd9Sstevel@tonic-gate struct list {
647c478bd9Sstevel@tonic-gate 	definition *val;
657c478bd9Sstevel@tonic-gate 	struct list *next;
667c478bd9Sstevel@tonic-gate };
677c478bd9Sstevel@tonic-gate typedef struct list list;
687c478bd9Sstevel@tonic-gate 
697c478bd9Sstevel@tonic-gate struct xdrfunc {
707c478bd9Sstevel@tonic-gate 	char *name;
717c478bd9Sstevel@tonic-gate 	int pointerp;
727c478bd9Sstevel@tonic-gate 	struct xdrfunc *next;
737c478bd9Sstevel@tonic-gate };
747c478bd9Sstevel@tonic-gate typedef struct xdrfunc xdrfunc;
757c478bd9Sstevel@tonic-gate 
767c478bd9Sstevel@tonic-gate struct commandline {
777c478bd9Sstevel@tonic-gate 	int cflag;		/* xdr C routines */
787c478bd9Sstevel@tonic-gate 	int hflag;		/* header file */
797c478bd9Sstevel@tonic-gate 	int lflag;		/* client side stubs */
807c478bd9Sstevel@tonic-gate 	int mflag;		/* server side stubs */
817c478bd9Sstevel@tonic-gate 	int nflag;		/* netid flag */
827c478bd9Sstevel@tonic-gate 	int sflag;		/* server stubs for the given transport */
837c478bd9Sstevel@tonic-gate 	int tflag;		/* dispatch Table file */
847c478bd9Sstevel@tonic-gate 	int Ssflag;		/* produce server sample code */
857c478bd9Sstevel@tonic-gate 	int Scflag;		/* produce client sample code */
867c478bd9Sstevel@tonic-gate 	int makefileflag;	/* Generate a template Makefile */
877c478bd9Sstevel@tonic-gate 	char *infile;		/* input module name */
887c478bd9Sstevel@tonic-gate 	char *outfile;		/* output module name */
897c478bd9Sstevel@tonic-gate };
907c478bd9Sstevel@tonic-gate 
917c478bd9Sstevel@tonic-gate #define	PUT 1
927c478bd9Sstevel@tonic-gate #define	GET 2
937c478bd9Sstevel@tonic-gate 
947c478bd9Sstevel@tonic-gate /*
957c478bd9Sstevel@tonic-gate  * Global variables
967c478bd9Sstevel@tonic-gate  */
977c478bd9Sstevel@tonic-gate #define	MAXLINESIZE 1024
987c478bd9Sstevel@tonic-gate extern char curline[MAXLINESIZE];
997c478bd9Sstevel@tonic-gate extern char *where;
1007c478bd9Sstevel@tonic-gate extern int linenum;
1017c478bd9Sstevel@tonic-gate 
1027c478bd9Sstevel@tonic-gate extern char *infilename;
1037c478bd9Sstevel@tonic-gate extern FILE *fout;
1047c478bd9Sstevel@tonic-gate extern FILE *fin;
1057c478bd9Sstevel@tonic-gate 
1067c478bd9Sstevel@tonic-gate extern list *defined;
1077c478bd9Sstevel@tonic-gate 
1087c478bd9Sstevel@tonic-gate extern bas_type *typ_list_h;
1097c478bd9Sstevel@tonic-gate extern bas_type *typ_list_t;
1107c478bd9Sstevel@tonic-gate extern xdrfunc *xdrfunc_head, *xdrfunc_tail;
1117c478bd9Sstevel@tonic-gate 
1127c478bd9Sstevel@tonic-gate /*
1137c478bd9Sstevel@tonic-gate  * All the option flags
1147c478bd9Sstevel@tonic-gate  */
1157c478bd9Sstevel@tonic-gate extern int inetdflag;
1167c478bd9Sstevel@tonic-gate extern int pmflag;
1177c478bd9Sstevel@tonic-gate extern int tblflag;
1187c478bd9Sstevel@tonic-gate extern int logflag;
1197c478bd9Sstevel@tonic-gate extern int newstyle;
1207c478bd9Sstevel@tonic-gate extern int Cflag;	/* ANSI-C/C++ flag */
1217c478bd9Sstevel@tonic-gate extern int CCflag;	/* C++ flag */
1227c478bd9Sstevel@tonic-gate extern int tirpcflag;	/* flag for generating tirpc code */
1237c478bd9Sstevel@tonic-gate extern int inlinelen;	/* if this is 0, then do not generate inline code */
1247c478bd9Sstevel@tonic-gate extern int mtflag;
1257c478bd9Sstevel@tonic-gate extern int mtauto;
1267c478bd9Sstevel@tonic-gate extern int rflag;
1277c478bd9Sstevel@tonic-gate 
1287c478bd9Sstevel@tonic-gate /*
1297c478bd9Sstevel@tonic-gate  * Other flags related with inetd jumpstart.
1307c478bd9Sstevel@tonic-gate  */
1317c478bd9Sstevel@tonic-gate extern int indefinitewait;
1327c478bd9Sstevel@tonic-gate extern int exitnow;
1337c478bd9Sstevel@tonic-gate extern int timerflag;
1347c478bd9Sstevel@tonic-gate 
1357c478bd9Sstevel@tonic-gate extern int nonfatalerrors;
1367c478bd9Sstevel@tonic-gate 
1377c478bd9Sstevel@tonic-gate extern pid_t childpid;
1387c478bd9Sstevel@tonic-gate 
1397c478bd9Sstevel@tonic-gate /*
1407c478bd9Sstevel@tonic-gate  * rpc_util routines
1417c478bd9Sstevel@tonic-gate  */
142*61961e0fSrobinson extern void storeval(list **, definition *);
1437c478bd9Sstevel@tonic-gate 
1447c478bd9Sstevel@tonic-gate #define	STOREVAL(list, item)	\
1457c478bd9Sstevel@tonic-gate 	storeval(list, item)
1467c478bd9Sstevel@tonic-gate 
147*61961e0fSrobinson extern definition *findval(list *, char *, int (*)());
1487c478bd9Sstevel@tonic-gate 
1497c478bd9Sstevel@tonic-gate #define	FINDVAL(list, item, finder) \
1507c478bd9Sstevel@tonic-gate 	findval(list, item, finder)
1517c478bd9Sstevel@tonic-gate 
152*61961e0fSrobinson extern char *fixtype(char *);
153*61961e0fSrobinson extern char *stringfix(char *);
154*61961e0fSrobinson extern char *locase(char *);
155*61961e0fSrobinson extern void pvname_svc(char *, char *);
156*61961e0fSrobinson extern void pvname(char *, char *);
157*61961e0fSrobinson extern void ptype(char *, char *, int);
158*61961e0fSrobinson extern int isvectordef(char *, relation);
159*61961e0fSrobinson extern int streq(char *, char *);
160*61961e0fSrobinson extern void error(char *);
161*61961e0fSrobinson extern void expected1(tok_kind);
162*61961e0fSrobinson extern void expected2(tok_kind, tok_kind);
163*61961e0fSrobinson extern void expected3(tok_kind, tok_kind, tok_kind);
164*61961e0fSrobinson extern void tabify(FILE *, int);
165*61961e0fSrobinson extern void record_open(char *);
166*61961e0fSrobinson extern bas_type *find_type(char *);
167*61961e0fSrobinson 
1687c478bd9Sstevel@tonic-gate /*
1697c478bd9Sstevel@tonic-gate  * rpc_cout routines
1707c478bd9Sstevel@tonic-gate  */
171*61961e0fSrobinson extern void emit(definition *);
1727c478bd9Sstevel@tonic-gate 
1737c478bd9Sstevel@tonic-gate /*
1747c478bd9Sstevel@tonic-gate  * rpc_hout routines
1757c478bd9Sstevel@tonic-gate  */
176*61961e0fSrobinson extern void print_datadef(definition *);
177*61961e0fSrobinson extern void print_funcdef(definition *);
178*61961e0fSrobinson extern void print_xdr_func_def(char *, int, int);
1797c478bd9Sstevel@tonic-gate 
1807c478bd9Sstevel@tonic-gate /*
1817c478bd9Sstevel@tonic-gate  * rpc_svcout routines
1827c478bd9Sstevel@tonic-gate  */
183*61961e0fSrobinson extern void write_most(char *, int, int);
184*61961e0fSrobinson extern void write_rest(void);
185*61961e0fSrobinson extern void write_inetd_register(char *);
186*61961e0fSrobinson extern void write_netid_register(char *);
187*61961e0fSrobinson extern void write_nettype_register(char *);
188*61961e0fSrobinson 
1897c478bd9Sstevel@tonic-gate /*
1907c478bd9Sstevel@tonic-gate  * rpc_clntout routines
1917c478bd9Sstevel@tonic-gate  */
192*61961e0fSrobinson extern void write_stubs(void);
1937c478bd9Sstevel@tonic-gate 
1947c478bd9Sstevel@tonic-gate /*
1957c478bd9Sstevel@tonic-gate  * rpc_tblout routines
1967c478bd9Sstevel@tonic-gate  */
197*61961e0fSrobinson extern void write_tables(void);
1987c478bd9Sstevel@tonic-gate 
1997c478bd9Sstevel@tonic-gate #ifdef __cplusplus
2007c478bd9Sstevel@tonic-gate }
2017c478bd9Sstevel@tonic-gate #endif
2027c478bd9Sstevel@tonic-gate 
2037c478bd9Sstevel@tonic-gate #endif	/* !_RPC_UTIL_H */
204