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