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