xref: /titanic_51/usr/src/cmd/rpcgen/rpc_parse.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
27*7c478bd9Sstevel@tonic-gate /* All Rights Reserved */
28*7c478bd9Sstevel@tonic-gate /*
29*7c478bd9Sstevel@tonic-gate  * University Copyright- Copyright (c) 1982, 1986, 1988
30*7c478bd9Sstevel@tonic-gate  * The Regents of the University of California
31*7c478bd9Sstevel@tonic-gate  * All Rights Reserved
32*7c478bd9Sstevel@tonic-gate  *
33*7c478bd9Sstevel@tonic-gate  * University Acknowledgment- Portions of this document are derived from
34*7c478bd9Sstevel@tonic-gate  * software developed by the University of California, Berkeley, and its
35*7c478bd9Sstevel@tonic-gate  * contributors.
36*7c478bd9Sstevel@tonic-gate  */
37*7c478bd9Sstevel@tonic-gate 
38*7c478bd9Sstevel@tonic-gate #ifndef _RPC_PARSE_H
39*7c478bd9Sstevel@tonic-gate #define	_RPC_PARSE_H
40*7c478bd9Sstevel@tonic-gate 
41*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
42*7c478bd9Sstevel@tonic-gate 
43*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus
44*7c478bd9Sstevel@tonic-gate extern "C" {
45*7c478bd9Sstevel@tonic-gate #endif
46*7c478bd9Sstevel@tonic-gate 
47*7c478bd9Sstevel@tonic-gate /*
48*7c478bd9Sstevel@tonic-gate  * rpc_parse.h, Definitions for the RPCL parser
49*7c478bd9Sstevel@tonic-gate  */
50*7c478bd9Sstevel@tonic-gate 
51*7c478bd9Sstevel@tonic-gate enum defkind {
52*7c478bd9Sstevel@tonic-gate 	DEF_CONST,
53*7c478bd9Sstevel@tonic-gate 	DEF_STRUCT,
54*7c478bd9Sstevel@tonic-gate 	DEF_UNION,
55*7c478bd9Sstevel@tonic-gate 	DEF_ENUM,
56*7c478bd9Sstevel@tonic-gate 	DEF_TYPEDEF,
57*7c478bd9Sstevel@tonic-gate 	DEF_PROGRAM,
58*7c478bd9Sstevel@tonic-gate 	DEF_RESULT
59*7c478bd9Sstevel@tonic-gate };
60*7c478bd9Sstevel@tonic-gate typedef enum defkind defkind;
61*7c478bd9Sstevel@tonic-gate 
62*7c478bd9Sstevel@tonic-gate typedef char *const_def;
63*7c478bd9Sstevel@tonic-gate 
64*7c478bd9Sstevel@tonic-gate enum relation {
65*7c478bd9Sstevel@tonic-gate 	REL_VECTOR,	/* fixed length array */
66*7c478bd9Sstevel@tonic-gate 	REL_ARRAY,	/* variable length array */
67*7c478bd9Sstevel@tonic-gate 	REL_POINTER,	/* pointer */
68*7c478bd9Sstevel@tonic-gate 	REL_ALIAS,	/* simple */
69*7c478bd9Sstevel@tonic-gate };
70*7c478bd9Sstevel@tonic-gate typedef enum relation relation;
71*7c478bd9Sstevel@tonic-gate 
72*7c478bd9Sstevel@tonic-gate struct typedef_def {
73*7c478bd9Sstevel@tonic-gate 	char *old_prefix;
74*7c478bd9Sstevel@tonic-gate 	char *old_type;
75*7c478bd9Sstevel@tonic-gate 	relation rel;
76*7c478bd9Sstevel@tonic-gate 	char *array_max;
77*7c478bd9Sstevel@tonic-gate };
78*7c478bd9Sstevel@tonic-gate typedef struct typedef_def typedef_def;
79*7c478bd9Sstevel@tonic-gate 
80*7c478bd9Sstevel@tonic-gate struct enumval_list {
81*7c478bd9Sstevel@tonic-gate 	char *name;
82*7c478bd9Sstevel@tonic-gate 	char *assignment;
83*7c478bd9Sstevel@tonic-gate 	struct enumval_list *next;
84*7c478bd9Sstevel@tonic-gate };
85*7c478bd9Sstevel@tonic-gate typedef struct enumval_list enumval_list;
86*7c478bd9Sstevel@tonic-gate 
87*7c478bd9Sstevel@tonic-gate struct enum_def {
88*7c478bd9Sstevel@tonic-gate 	enumval_list *vals;
89*7c478bd9Sstevel@tonic-gate };
90*7c478bd9Sstevel@tonic-gate typedef struct enum_def enum_def;
91*7c478bd9Sstevel@tonic-gate 
92*7c478bd9Sstevel@tonic-gate struct declaration {
93*7c478bd9Sstevel@tonic-gate 	char *prefix;
94*7c478bd9Sstevel@tonic-gate 	char *type;
95*7c478bd9Sstevel@tonic-gate 	char *name;
96*7c478bd9Sstevel@tonic-gate 	relation rel;
97*7c478bd9Sstevel@tonic-gate 	char *array_max;
98*7c478bd9Sstevel@tonic-gate };
99*7c478bd9Sstevel@tonic-gate typedef struct declaration declaration;
100*7c478bd9Sstevel@tonic-gate 
101*7c478bd9Sstevel@tonic-gate struct decl_list {
102*7c478bd9Sstevel@tonic-gate 	declaration decl;
103*7c478bd9Sstevel@tonic-gate 	struct decl_list *next;
104*7c478bd9Sstevel@tonic-gate };
105*7c478bd9Sstevel@tonic-gate typedef struct decl_list decl_list;
106*7c478bd9Sstevel@tonic-gate 
107*7c478bd9Sstevel@tonic-gate struct struct_def {
108*7c478bd9Sstevel@tonic-gate 	decl_list *decls;
109*7c478bd9Sstevel@tonic-gate 	decl_list *tail;
110*7c478bd9Sstevel@tonic-gate 	char self_pointer;
111*7c478bd9Sstevel@tonic-gate };
112*7c478bd9Sstevel@tonic-gate typedef struct struct_def struct_def;
113*7c478bd9Sstevel@tonic-gate 
114*7c478bd9Sstevel@tonic-gate struct case_list {
115*7c478bd9Sstevel@tonic-gate 	char *case_name;
116*7c478bd9Sstevel@tonic-gate 	int contflag;
117*7c478bd9Sstevel@tonic-gate 	declaration case_decl;
118*7c478bd9Sstevel@tonic-gate 	struct case_list *next;
119*7c478bd9Sstevel@tonic-gate };
120*7c478bd9Sstevel@tonic-gate typedef struct case_list case_list;
121*7c478bd9Sstevel@tonic-gate 
122*7c478bd9Sstevel@tonic-gate struct union_def {
123*7c478bd9Sstevel@tonic-gate 	declaration enum_decl;
124*7c478bd9Sstevel@tonic-gate 	case_list *cases;
125*7c478bd9Sstevel@tonic-gate 	declaration *default_decl;
126*7c478bd9Sstevel@tonic-gate };
127*7c478bd9Sstevel@tonic-gate typedef struct union_def union_def;
128*7c478bd9Sstevel@tonic-gate 
129*7c478bd9Sstevel@tonic-gate struct arg_list {
130*7c478bd9Sstevel@tonic-gate 	char *argname; /* name of struct for arg */
131*7c478bd9Sstevel@tonic-gate 	decl_list *decls;
132*7c478bd9Sstevel@tonic-gate };
133*7c478bd9Sstevel@tonic-gate 
134*7c478bd9Sstevel@tonic-gate typedef struct arg_list arg_list;
135*7c478bd9Sstevel@tonic-gate 
136*7c478bd9Sstevel@tonic-gate struct proc_list {
137*7c478bd9Sstevel@tonic-gate 	char *proc_name;
138*7c478bd9Sstevel@tonic-gate 	char *proc_num;
139*7c478bd9Sstevel@tonic-gate 	arg_list args;
140*7c478bd9Sstevel@tonic-gate 	int arg_num;
141*7c478bd9Sstevel@tonic-gate 	char *res_type;
142*7c478bd9Sstevel@tonic-gate 	char *res_prefix;
143*7c478bd9Sstevel@tonic-gate 	struct proc_list *next;
144*7c478bd9Sstevel@tonic-gate };
145*7c478bd9Sstevel@tonic-gate typedef struct proc_list proc_list;
146*7c478bd9Sstevel@tonic-gate 
147*7c478bd9Sstevel@tonic-gate struct version_list {
148*7c478bd9Sstevel@tonic-gate 	char *vers_name;
149*7c478bd9Sstevel@tonic-gate 	char *vers_num;
150*7c478bd9Sstevel@tonic-gate 	proc_list *procs;
151*7c478bd9Sstevel@tonic-gate 	struct version_list *next;
152*7c478bd9Sstevel@tonic-gate };
153*7c478bd9Sstevel@tonic-gate typedef struct version_list version_list;
154*7c478bd9Sstevel@tonic-gate 
155*7c478bd9Sstevel@tonic-gate struct program_def {
156*7c478bd9Sstevel@tonic-gate 	char *prog_num;
157*7c478bd9Sstevel@tonic-gate 	version_list *versions;
158*7c478bd9Sstevel@tonic-gate };
159*7c478bd9Sstevel@tonic-gate typedef struct program_def program_def;
160*7c478bd9Sstevel@tonic-gate 
161*7c478bd9Sstevel@tonic-gate struct definition {
162*7c478bd9Sstevel@tonic-gate 	char *def_name;
163*7c478bd9Sstevel@tonic-gate 	defkind def_kind;
164*7c478bd9Sstevel@tonic-gate 	union {
165*7c478bd9Sstevel@tonic-gate 		const_def co;
166*7c478bd9Sstevel@tonic-gate 		struct_def st;
167*7c478bd9Sstevel@tonic-gate 		union_def un;
168*7c478bd9Sstevel@tonic-gate 		enum_def en;
169*7c478bd9Sstevel@tonic-gate 		typedef_def ty;
170*7c478bd9Sstevel@tonic-gate 		program_def pr;
171*7c478bd9Sstevel@tonic-gate 	} def;
172*7c478bd9Sstevel@tonic-gate };
173*7c478bd9Sstevel@tonic-gate typedef struct definition definition;
174*7c478bd9Sstevel@tonic-gate 
175*7c478bd9Sstevel@tonic-gate definition *get_definition();
176*7c478bd9Sstevel@tonic-gate 
177*7c478bd9Sstevel@tonic-gate 
178*7c478bd9Sstevel@tonic-gate struct bas_type
179*7c478bd9Sstevel@tonic-gate {
180*7c478bd9Sstevel@tonic-gate 	char *name;
181*7c478bd9Sstevel@tonic-gate 	int length;
182*7c478bd9Sstevel@tonic-gate 	struct bas_type *next;
183*7c478bd9Sstevel@tonic-gate };
184*7c478bd9Sstevel@tonic-gate 
185*7c478bd9Sstevel@tonic-gate typedef struct bas_type bas_type;
186*7c478bd9Sstevel@tonic-gate 
187*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus
188*7c478bd9Sstevel@tonic-gate }
189*7c478bd9Sstevel@tonic-gate #endif
190*7c478bd9Sstevel@tonic-gate 
191*7c478bd9Sstevel@tonic-gate #endif	/* !_RPC_PARSE_H */
192