xref: /illumos-gate/usr/src/cmd/rpcgen/rpc_parse.h (revision bdfc6d18da790deeec2e0eb09c625902defe2498)
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_PARSE_H
40 #define	_RPC_PARSE_H
41 
42 #pragma ident	"%Z%%M%	%I%	%E% SMI"
43 
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47 
48 /*
49  * rpc_parse.h, Definitions for the RPCL parser
50  */
51 
52 enum defkind {
53 	DEF_CONST,
54 	DEF_STRUCT,
55 	DEF_UNION,
56 	DEF_ENUM,
57 	DEF_TYPEDEF,
58 	DEF_PROGRAM,
59 	DEF_RESULT
60 };
61 typedef enum defkind defkind;
62 
63 typedef char *const_def;
64 
65 enum relation {
66 	REL_VECTOR,	/* fixed length array */
67 	REL_ARRAY,	/* variable length array */
68 	REL_POINTER,	/* pointer */
69 	REL_ALIAS	/* simple */
70 };
71 typedef enum relation relation;
72 
73 struct typedef_def {
74 	char *old_prefix;
75 	char *old_type;
76 	relation rel;
77 	char *array_max;
78 };
79 typedef struct typedef_def typedef_def;
80 
81 struct enumval_list {
82 	char *name;
83 	char *assignment;
84 	struct enumval_list *next;
85 };
86 typedef struct enumval_list enumval_list;
87 
88 struct enum_def {
89 	enumval_list *vals;
90 };
91 typedef struct enum_def enum_def;
92 
93 struct declaration {
94 	char *prefix;
95 	char *type;
96 	char *name;
97 	relation rel;
98 	char *array_max;
99 };
100 typedef struct declaration declaration;
101 
102 struct decl_list {
103 	declaration decl;
104 	struct decl_list *next;
105 };
106 typedef struct decl_list decl_list;
107 
108 struct struct_def {
109 	decl_list *decls;
110 	decl_list *tail;
111 	char self_pointer;
112 };
113 typedef struct struct_def struct_def;
114 
115 struct case_list {
116 	char *case_name;
117 	int contflag;
118 	declaration case_decl;
119 	struct case_list *next;
120 };
121 typedef struct case_list case_list;
122 
123 struct union_def {
124 	declaration enum_decl;
125 	case_list *cases;
126 	declaration *default_decl;
127 };
128 typedef struct union_def union_def;
129 
130 struct arg_list {
131 	char *argname; /* name of struct for arg */
132 	decl_list *decls;
133 };
134 
135 typedef struct arg_list arg_list;
136 
137 struct proc_list {
138 	char *proc_name;
139 	char *proc_num;
140 	arg_list args;
141 	int arg_num;
142 	char *res_type;
143 	char *res_prefix;
144 	struct proc_list *next;
145 };
146 typedef struct proc_list proc_list;
147 
148 struct version_list {
149 	char *vers_name;
150 	char *vers_num;
151 	proc_list *procs;
152 	struct version_list *next;
153 };
154 typedef struct version_list version_list;
155 
156 struct program_def {
157 	char *prog_num;
158 	version_list *versions;
159 };
160 typedef struct program_def program_def;
161 
162 struct definition {
163 	char *def_name;
164 	defkind def_kind;
165 	union {
166 		const_def co;
167 		struct_def st;
168 		union_def un;
169 		enum_def en;
170 		typedef_def ty;
171 		program_def pr;
172 	} def;
173 };
174 typedef struct definition definition;
175 
176 definition *get_definition();
177 
178 
179 struct bas_type
180 {
181 	char *name;
182 	int length;
183 	struct bas_type *next;
184 };
185 
186 typedef struct bas_type bas_type;
187 
188 #ifdef __cplusplus
189 }
190 #endif
191 
192 #endif	/* !_RPC_PARSE_H */
193