xref: /titanic_44/usr/src/cmd/rpcgen/rpc_util.h (revision b7f45089ccbe01bab3d7c7377b49d80d2ae18a69)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 
23 /*
24  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
25  * Use is subject to license terms.
26  */
27 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
29 /*
30  * University Copyright- Copyright (c) 1982, 1986, 1988
31  * The Regents of the University of California
32  * All Rights Reserved
33  *
34  * University Acknowledgment- Portions of this document are derived from
35  * software developed by the University of California, Berkeley, and its
36  * contributors.
37  */
38 
39 #ifndef _RPC_UTIL_H
40 #define	_RPC_UTIL_H
41 
42 #pragma ident	"%Z%%M%	%I%	%E% SMI"
43 
44 #include <sys/types.h>
45 #include <stdlib.h>
46 #include "rpc_scan.h"
47 
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51 
52 /*
53  * rpc_util.h, Useful definitions for the RPC protocol compiler
54  */
55 
56 
57 /* Current version number of rpcgen. */
58 #define	RPCGEN_MAJOR 1
59 #define	RPCGEN_MINOR 1
60 
61 #define	f_print (void) fprintf
62 
63 struct list {
64 	definition *val;
65 	struct list *next;
66 };
67 typedef struct list list;
68 
69 struct xdrfunc {
70 	char *name;
71 	int pointerp;
72 	struct xdrfunc *next;
73 };
74 typedef struct xdrfunc xdrfunc;
75 
76 struct commandline {
77 	int cflag;		/* xdr C routines */
78 	int hflag;		/* header file */
79 	int lflag;		/* client side stubs */
80 	int mflag;		/* server side stubs */
81 	int nflag;		/* netid flag */
82 	int sflag;		/* server stubs for the given transport */
83 	int tflag;		/* dispatch Table file */
84 	int Ssflag;		/* produce server sample code */
85 	int Scflag;		/* produce client sample code */
86 	int makefileflag;	/* Generate a template Makefile */
87 	char *infile;		/* input module name */
88 	char *outfile;		/* output module name */
89 };
90 
91 #define	PUT 1
92 #define	GET 2
93 
94 /*
95  * Global variables
96  */
97 #define	MAXLINESIZE 1024
98 extern char curline[MAXLINESIZE];
99 extern char *where;
100 extern int linenum;
101 
102 extern char *infilename;
103 extern FILE *fout;
104 extern FILE *fin;
105 
106 extern list *defined;
107 
108 extern bas_type *typ_list_h;
109 extern bas_type *typ_list_t;
110 extern xdrfunc *xdrfunc_head, *xdrfunc_tail;
111 
112 /*
113  * All the option flags
114  */
115 extern int inetdflag;
116 extern int pmflag;
117 extern int tblflag;
118 extern int logflag;
119 extern int newstyle;
120 extern int Cflag;	/* ANSI-C/C++ flag */
121 extern int CCflag;	/* C++ flag */
122 extern int tirpcflag;	/* flag for generating tirpc code */
123 extern int inlinelen;	/* if this is 0, then do not generate inline code */
124 extern int mtflag;
125 extern int mtauto;
126 extern int rflag;
127 
128 /*
129  * Other flags related with inetd jumpstart.
130  */
131 extern int indefinitewait;
132 extern int exitnow;
133 extern int timerflag;
134 
135 extern int nonfatalerrors;
136 
137 extern pid_t childpid;
138 
139 /*
140  * rpc_util routines
141  */
142 extern void storeval(list **, definition *);
143 
144 #define	STOREVAL(list, item)	\
145 	storeval(list, item)
146 
147 extern definition *findval(list *, char *, int (*)());
148 
149 #define	FINDVAL(list, item, finder) \
150 	findval(list, item, finder)
151 
152 extern char *fixtype(char *);
153 extern char *stringfix(char *);
154 extern char *locase(char *);
155 extern void pvname_svc(char *, char *);
156 extern void pvname(char *, char *);
157 extern void ptype(char *, char *, int);
158 extern int isvectordef(char *, relation);
159 extern int streq(char *, char *);
160 extern void error(char *);
161 extern void expected1(tok_kind);
162 extern void expected2(tok_kind, tok_kind);
163 extern void expected3(tok_kind, tok_kind, tok_kind);
164 extern void tabify(FILE *, int);
165 extern void record_open(char *);
166 extern bas_type *find_type(char *);
167 
168 /*
169  * rpc_cout routines
170  */
171 extern void emit(definition *);
172 
173 /*
174  * rpc_hout routines
175  */
176 extern void print_datadef(definition *);
177 extern void print_funcdef(definition *);
178 extern void print_xdr_func_def(char *, int, int);
179 
180 /*
181  * rpc_svcout routines
182  */
183 extern void write_most(char *, int, int);
184 extern void write_rest(void);
185 extern void write_inetd_register(char *);
186 extern void write_netid_register(char *);
187 extern void write_nettype_register(char *);
188 
189 /*
190  * rpc_clntout routines
191  */
192 extern void write_stubs(void);
193 
194 /*
195  * rpc_tblout routines
196  */
197 extern void write_tables(void);
198 
199 #ifdef __cplusplus
200 }
201 #endif
202 
203 #endif	/* !_RPC_UTIL_H */
204