xref: /illumos-gate/usr/src/cmd/rpcgen/rpc_parse.h (revision 8119dad84d6416f13557b0ba8e2aaf9064cbcfd3)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2009 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_PARSE_H
39 #define	_RPC_PARSE_H
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
45 /*
46  * rpc_parse.h, Definitions for the RPCL parser
47  */
48 
49 enum defkind {
50 	DEF_CONST,
51 	DEF_STRUCT,
52 	DEF_UNION,
53 	DEF_ENUM,
54 	DEF_TYPEDEF,
55 	DEF_PROGRAM,
56 	DEF_RESULT
57 };
58 typedef enum defkind defkind;
59 
60 typedef char *const_def;
61 
62 enum relation {
63 	REL_VECTOR,	/* fixed length array */
64 	REL_ARRAY,	/* variable length array */
65 	REL_POINTER,	/* pointer */
66 	REL_ALIAS	/* simple */
67 };
68 typedef enum relation relation;
69 
70 struct typedef_def {
71 	char *old_prefix;
72 	char *old_type;
73 	relation rel;
74 	char *array_max;
75 };
76 typedef struct typedef_def typedef_def;
77 
78 struct enumval_list {
79 	char *name;
80 	char *assignment;
81 	struct enumval_list *next;
82 };
83 typedef struct enumval_list enumval_list;
84 
85 struct enum_def {
86 	enumval_list *vals;
87 };
88 typedef struct enum_def enum_def;
89 
90 struct declaration {
91 	char *prefix;
92 	char *type;
93 	char *name;
94 	relation rel;
95 	char *array_max;
96 };
97 typedef struct declaration declaration;
98 
99 struct decl_list {
100 	declaration decl;
101 	struct decl_list *next;
102 };
103 typedef struct decl_list decl_list;
104 
105 struct struct_def {
106 	decl_list *decls;
107 	decl_list *tail;
108 	char self_pointer;
109 };
110 typedef struct struct_def struct_def;
111 
112 struct case_list {
113 	char *case_name;
114 	int contflag;
115 	declaration case_decl;
116 	struct case_list *next;
117 };
118 typedef struct case_list case_list;
119 
120 struct union_def {
121 	declaration enum_decl;
122 	case_list *cases;
123 	declaration *default_decl;
124 };
125 typedef struct union_def union_def;
126 
127 struct arg_list {
128 	char *argname; /* name of struct for arg */
129 	decl_list *decls;
130 };
131 
132 typedef struct arg_list arg_list;
133 
134 struct proc_list {
135 	char *proc_name;
136 	char *proc_num;
137 	arg_list args;
138 	int arg_num;
139 	char *res_type;
140 	char *res_prefix;
141 	struct proc_list *next;
142 };
143 typedef struct proc_list proc_list;
144 
145 struct version_list {
146 	char *vers_name;
147 	char *vers_num;
148 	proc_list *procs;
149 	struct version_list *next;
150 };
151 typedef struct version_list version_list;
152 
153 struct program_def {
154 	char *prog_num;
155 	version_list *versions;
156 };
157 typedef struct program_def program_def;
158 
159 struct definition {
160 	char *def_name;
161 	defkind def_kind;
162 	union {
163 		const_def co;
164 		struct_def st;
165 		union_def un;
166 		enum_def en;
167 		typedef_def ty;
168 		program_def pr;
169 	} def;
170 };
171 typedef struct definition definition;
172 
173 definition *get_definition();
174 
175 
176 struct bas_type
177 {
178 	char *name;
179 	int length;
180 	struct bas_type *next;
181 };
182 
183 typedef struct bas_type bas_type;
184 
185 #ifdef __cplusplus
186 }
187 #endif
188 
189 #endif	/* !_RPC_PARSE_H */
190