xref: /openbsd/usr.bin/rpcgen/rpc_parse.h (revision cb7760d1)
1 /*	$OpenBSD: rpc_parse.h,v 1.9 2010/09/01 14:43:34 millert Exp $	*/
2 /*	$NetBSD: rpc_parse.h,v 1.3 1995/06/11 21:50:00 pk Exp $	*/
3 
4 /*
5  * Copyright (c) 2010, Oracle America, Inc.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are
9  * met:
10  *
11  *     * Redistributions of source code must retain the above copyright
12  *       notice, this list of conditions and the following disclaimer.
13  *     * Redistributions in binary form must reproduce the above
14  *       copyright notice, this list of conditions and the following
15  *       disclaimer in the documentation and/or other materials
16  *       provided with the distribution.
17  *     * Neither the name of the "Oracle America, Inc." nor the names of its
18  *       contributors may be used to endorse or promote products derived
19  *       from this software without specific prior written permission.
20  *
21  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  *   FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  *   COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
26  *   INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27  *   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
28  *   GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29  *   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
30  *   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31  *   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  */
34 
35 /*      @(#)rpc_parse.h  1.3  90/08/29  (C) 1987 SMI   */
36 
37 /*
38  * rpc_parse.h, Definitions for the RPCL parser
39  */
40 
41 enum defkind {
42 	DEF_CONST,
43 	DEF_STRUCT,
44 	DEF_UNION,
45 	DEF_ENUM,
46 	DEF_TYPEDEF,
47 	DEF_PROGRAM
48 };
49 typedef enum defkind defkind;
50 
51 typedef char *const_def;
52 
53 enum relation {
54 	REL_VECTOR,	/* fixed length array */
55 	REL_ARRAY,	/* variable length array */
56 	REL_POINTER,	/* pointer */
57 	REL_ALIAS	/* simple */
58 };
59 typedef enum relation relation;
60 
61 struct typedef_def {
62 	char *old_prefix;
63 	char *old_type;
64 	relation rel;
65 	char *array_max;
66 };
67 typedef struct typedef_def typedef_def;
68 
69 struct enumval_list {
70 	char *name;
71 	char *assignment;
72 	struct enumval_list *next;
73 };
74 typedef struct enumval_list enumval_list;
75 
76 struct enum_def {
77 	enumval_list *vals;
78 };
79 typedef struct enum_def enum_def;
80 
81 struct declaration {
82 	char *prefix;
83 	char *type;
84 	char *name;
85 	relation rel;
86 	char *array_max;
87 };
88 typedef struct declaration declaration;
89 
90 struct decl_list {
91 	declaration decl;
92 	struct decl_list *next;
93 };
94 typedef struct decl_list decl_list;
95 
96 struct struct_def {
97 	decl_list *decls;
98 };
99 typedef struct struct_def struct_def;
100 
101 struct case_list {
102 	char *case_name;
103 	int contflag;
104 	declaration case_decl;
105 	struct case_list *next;
106 };
107 typedef struct case_list case_list;
108 
109 struct union_def {
110 	declaration enum_decl;
111 	case_list *cases;
112 	declaration *default_decl;
113 };
114 typedef struct union_def union_def;
115 
116 struct arg_list {
117 	char *argname; /* name of struct for arg*/
118 	decl_list *decls;
119 };
120 
121 typedef struct arg_list arg_list;
122 
123 struct proc_list {
124 	char *proc_name;
125 	char *proc_num;
126 	arg_list args;
127 	int arg_num;
128 	char *res_type;
129 	char *res_prefix;
130 	struct proc_list *next;
131 };
132 typedef struct proc_list proc_list;
133 
134 struct version_list {
135 	char *vers_name;
136 	char *vers_num;
137 	proc_list *procs;
138 	struct version_list *next;
139 };
140 typedef struct version_list version_list;
141 
142 struct program_def {
143 	char *prog_num;
144 	version_list *versions;
145 };
146 typedef struct program_def program_def;
147 
148 struct definition {
149 	char *def_name;
150 	defkind def_kind;
151 	union {
152 		const_def co;
153 		struct_def st;
154 		union_def un;
155 		enum_def en;
156 		typedef_def ty;
157 		program_def pr;
158 	} def;
159 };
160 typedef struct definition definition;
161 
162 definition *get_definition(void);
163 
164 struct bas_type {
165 	char *name;
166 	int length;
167 	struct bas_type *next;
168 };
169 
170 typedef struct bas_type bas_type;
171