s4:torture: Adapt KDC canon test to Heimdal upstream changes
[samba.git] / source4 / heimdal / lib / asn1 / symbol.h
1 /*
2  * Copyright (c) 1997 - 2005 Kungliga Tekniska Högskolan
3  * (Royal Institute of Technology, Stockholm, Sweden).
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  *
17  * 3. Neither the name of the Institute nor the names of its contributors
18  *    may be used to endorse or promote products derived from this software
19  *    without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
22  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31  * SUCH DAMAGE.
32  */
33
34 /* $Id$ */
35
36 #ifndef _SYMBOL_H
37 #define _SYMBOL_H
38
39 #include <heimqueue.h>
40
41 enum typetype {
42     TBitString,
43     TBoolean,
44     TChoice,
45     TEnumerated,
46     TGeneralString,
47     TTeletexString,
48     TGeneralizedTime,
49     TIA5String,
50     TInteger,
51     TNull,
52     TOID,
53     TOctetString,
54     TPrintableString,
55     TSequence,
56     TSequenceOf,
57     TSet,
58     TSetOf,
59     TTag,
60     TType,
61     TUTCTime,
62     TUTF8String,
63     TBMPString,
64     TUniversalString,
65     TVisibleString
66 };
67
68 typedef enum typetype Typetype;
69
70 struct type;
71 struct value;
72 struct typereference;
73
74 struct value {
75     enum { booleanvalue,
76            nullvalue,
77            integervalue,
78            stringvalue,
79            objectidentifiervalue
80     } type;
81     union {
82         int booleanvalue;
83         int64_t integervalue;
84         char *stringvalue;
85         struct objid *objectidentifiervalue;
86     } u;
87     struct symbol *s;
88 };
89
90 struct member {
91     char *name;
92     char *gen_name;
93     char *label;
94     int val;
95     int optional;
96     int ellipsis;
97     struct type *type;
98     HEIM_TAILQ_ENTRY(member) members;
99     struct value *defval;
100 };
101
102 typedef struct member Member;
103
104 HEIM_TAILQ_HEAD(memhead, member);
105
106 struct symbol;
107
108 struct tagtype {
109     int tagclass;
110     int tagvalue;
111     enum { TE_IMPLICIT, TE_EXPLICIT } tagenv;
112 };
113
114 struct range {
115     /*
116      * We can't represent unsigned 64-bit ranges because max might be
117      * negative...
118      */
119     int64_t min;
120     int64_t max;
121 };
122
123 enum ctype { CT_CONTENTS, CT_USER, CT_TABLE_CONSTRAINT } ;
124
125 struct constraint_spec;
126
127 struct iosclassfield {
128     char *name;
129     struct type *type;
130     struct value *defval;
131     HEIM_TAILQ_ENTRY(iosclassfield) fields;
132     unsigned long id;
133     unsigned int optional:1;
134     unsigned int unique:1;
135 };
136
137 typedef struct iosclassfield Field;
138 HEIM_TAILQ_HEAD(fieldhead, iosclassfield);
139
140 struct iosobjectfield {
141     char *name;
142     struct type *type;
143     struct value *value;
144     HEIM_TAILQ_ENTRY(iosobjectfield) objfields;
145     unsigned long id;
146 };
147
148 typedef struct iosobjectfield ObjectField;
149 HEIM_TAILQ_HEAD(objfieldhead, iosobjectfield);
150
151 struct iosclass {
152     struct symbol *symbol;
153     struct fieldhead *fields;
154     unsigned long id;
155 };
156
157 typedef struct iosclass IOSClass;
158
159 struct iosobject {
160     struct symbol *symbol;
161     struct objfieldhead *objfields;
162     ObjectField *typeidf;
163     IOSClass *iosclass;
164     HEIM_TAILQ_ENTRY(iosobject) objects;
165     unsigned long id;
166     unsigned int ellipsis:1;
167     unsigned int optional:1;
168 };
169
170 typedef struct iosobject IOSObject;
171 HEIM_TAILQ_HEAD(objectshead, iosobject);
172
173 struct iosobjectset {
174     struct symbol *symbol;
175     IOSClass *iosclass;
176     struct objectshead *objects;
177     unsigned long id;
178 };
179
180 typedef struct iosobjectset IOSObjectSet;
181
182 struct typereference {
183     /*
184      * For now we don't support link fields, so we don't support chains of more
185      * than one field.
186      */
187     IOSClass *iosclass;
188     Field *field;
189 };
190
191 struct type {
192     Typetype type;
193     struct memhead *members;
194     struct symbol *symbol;
195     struct type *subtype;
196     struct typereference typeref; /* For type fields */
197     IOSClass *formal_parameter;
198     IOSObjectSet *actual_parameter;
199     struct tagtype tag;
200     struct range *range;
201     struct constraint_spec *constraint;
202     unsigned long id;
203 };
204
205 typedef struct type Type;
206
207 struct component_relation_constraint {
208     char *objectname;
209     char *membername;
210 };
211
212 struct constraint_spec {
213     enum ctype ctype;
214     union {
215         struct {
216             Type *type;
217             struct value *encoding;
218             struct component_relation_constraint crel;
219         } content;
220     } u;
221 };
222
223 struct objid {
224     const char *label;
225     int value;
226     struct objid *next;
227 };
228
229 struct symbol {
230     char *name;
231     char *gen_name;
232     enum { SUndefined, SValue, Stype, Sparamtype, Sclass, Sobj, Sobjset } stype;
233     struct value *value;
234     Type *type;
235     IOSClass *iosclass;
236     IOSObject *object;
237     IOSObjectSet *objectset;
238     HEIM_TAILQ_ENTRY(symbol) symlist;
239     unsigned int emitted_declaration:1;
240     unsigned int emitted_definition:1;
241     unsigned int emitted_tag_enums:1;
242     unsigned int emitted_template:1;
243 };
244
245 typedef struct symbol Symbol;
246
247 //HEIM_TAILQ_HEAD(symhead, symbol);
248 struct symhead {
249     struct symbol *tqh_first;
250     struct symbol **tqh_last;
251 };
252
253 extern struct symhead symbols;
254
255 void initsym (void);
256 Symbol *addsym (char *);
257 Symbol *getsym(char *name);
258 void output_name (char *);
259 int checkundefined(void);
260 void generate_types(void);
261 void emitted_declaration(const Symbol *);
262 void emitted_definition(const Symbol *);
263 void emitted_tag_enums(const Symbol *);
264 #endif