blob: ef1941b7fbcd1cc056853f496cf28e7e729d182e [file] [log] [blame]
Lev Walkinf15320b2004-06-03 03:38:44 +00001/*
2 * A collection of data members of unspecified types.
3 */
4#ifndef ASN1_PARSER_EXPR_H
5#define ASN1_PARSER_EXPR_H
6
7/*
8 * Meta type of the ASN expression.
9 */
10typedef enum asn1p_expr_meta {
11 AMT_INVALID,
12 AMT_TYPE, /* Type1 ::= INTEGER */
13 AMT_TYPEREF, /* Type2 ::= Type1 */
14 AMT_PARAMTYPE, /* Type3{Parameter} ::= SET { ... } */
15 AMT_VALUE, /* value1 Type1 ::= 1 */
16 AMT_VALUESET, /* ValueSet Type1 ::= { value1 } */
17 AMT_OBJECT, /* FUNCTION ::= CLASS {...} */
18 AMT_OBJECTSET, /* Functions FUNCTION ::= {...} */
19 AMT_OBJECTFIELD, /* ... */
20 AMT_EXPR_META_MAX
21} asn1p_expr_meta_e;
22
23/*
24 * ASN type of the expression.
25 */
26typedef enum asn1p_expr_type {
27 /*
28 * Internal types.
29 */
30 A1TC_INVALID, /* Invalid type */
31 A1TC_REFERENCE, /* Reference to the type defined elsewhere */
32 A1TC_EXPORTVAR, /* We're exporting this definition */
33 A1TC_UNIVERVAL, /* A value of an ENUMERATED, INTEGER or BS */
34 A1TC_BOOLBITPOS, /* A bit position in a BIT STRING */
35 A1TC_BITVECTOR, /* A plain collection of bits */
36 A1TC_OPAQUE, /* Opaque data encoded as a bitvector */
37 A1TC_EXTENSIBLE, /* An extension marker "..." */
38 A1TC_PARAMETRIZED, /* A parametrized type declaration */
39 A1TC_VALUESET, /* Value set definition */
40 A1TC_CLASSDEF, /* Information Object Class */
41 A1TC_CLASSFIELD, /* Information Object Class field */
42 A1TC_INSTANCE, /* Instance of Object Class */
43 A1TC_TYPEID, /* Type identifier */
44 /*
45 * ASN.1 Constructed types
46 */
47#define ASN_CONSTR_MASK 0x10 /* Every constructed type */
48 ASN_CONSTR_SEQUENCE = ASN_CONSTR_MASK, /* SEQUENCE */
49 ASN_CONSTR_CHOICE, /* CHOICE */
50 ASN_CONSTR_SET, /* SET */
51 ASN_CONSTR_SEQUENCE_OF, /* SEQUENCE OF */
52 ASN_CONSTR_SET_OF, /* SET OF */
53 ASN_CONSTR_ANY, /* ANY (deprecated) */
54 /*
55 * ASN.1 Basic types
56 */
57#define ASN_BASIC_MASK 0x20 /* Every basic type */
58 ASN_BASIC_BOOLEAN = ASN_BASIC_MASK,
59 ASN_BASIC_NULL,
60 ASN_BASIC_INTEGER,
61 ASN_BASIC_REAL,
62 ASN_BASIC_ENUMERATED,
63 ASN_BASIC_BIT_STRING,
64 ASN_BASIC_OCTET_STRING,
65 ASN_BASIC_OBJECT_IDENTIFIER,
66 ASN_BASIC_RELATIVE_OID,
67 ASN_BASIC_EXTERNAL,
68 ASN_BASIC_EMBEDDED_PDV,
69 ASN_BASIC_CHARACTER_STRING,
70 ASN_BASIC_UTCTime,
71 ASN_BASIC_GeneralizedTime,
72 /*
73 * ASN.1 String types
74 */
75#define ASN_STRING_MASK 0x40 /* Every string type */
76 ASN_STRING_BMPString = ASN_STRING_MASK,
77 ASN_STRING_GeneralString,
78 ASN_STRING_GraphicString,
79 ASN_STRING_IA5String,
80 ASN_STRING_ISO646String,
81 ASN_STRING_NumericString,
82 ASN_STRING_PrintableString,
83 ASN_STRING_TeletexString,
84 ASN_STRING_T61String,
85 ASN_STRING_UniversalString,
86 ASN_STRING_UTF8String,
87 ASN_STRING_VideotexString,
88 ASN_STRING_VisibleString,
89 ASN_STRING_ObjectDescriptor,
90 ASN_EXPR_TYPE_MAX
91} asn1p_expr_type_e;
92
93#include "asn1p_expr_str.h"
94#include "asn1p_expr2uclass.h"
95
96/*
97 * A named collection of types.
98 */
99typedef struct asn1p_expr_s {
100
101 /*
102 * Human readable name.
103 */
104 char *Identifier;
105
106 /*
107 * Meta type of the expression (type, value, value set, etc).
108 */
109 asn1p_expr_meta_e meta_type;
110
111 /*
112 * ASN type of the expression.
113 */
114 asn1p_expr_type_e expr_type;
115
116 /*
117 * Referenced type, if defined elsewhere.
118 * (If expr_type == A1TC_REFERENCE)
119 */
120 asn1p_ref_t *reference;
121
122 /*
123 * Constraints for the type.
124 */
125 asn1p_constraint_t *constraints;
126
127 /*
Lev Walkinf59d0752004-08-18 04:59:12 +0000128 * This field is holding the transformed constraints, with all the
129 * parent constraints taken into account.
130 */
131 asn1p_constraint_t *combined_constraints;
132
133 /*
Lev Walkinf15320b2004-06-03 03:38:44 +0000134 * A list of parameters for parametrized type declaration
135 * (AMT_PARAMTYPE).
136 */
137 asn1p_paramlist_t *params;
138
139 /*
140 * The actual value (DefinedValue or inlined value).
141 */
142 asn1p_value_t *value;
143
144 /*
145 * The WITH SYHTAX clause.
146 */
147 asn1p_wsyntx_t *with_syntax;
148
149 /*
150 * A tag.
151 */
152 struct asn1p_type_tag_s {
153 enum {
154 TC_NOCLASS,
155 TC_UNIVERSAL,
156 TC_APPLICATION,
157 TC_CONTEXT_SPECIFIC,
158 TC_PRIVATE,
159 } tag_class;
160 enum {
161 TM_DEFAULT,
162 TM_IMPLICIT,
163 TM_EXPLICIT,
164 } tag_mode;
165 asn1_integer_t tag_value;
166 } tag;
167
168 /*
169 * Whether automatic tagging is applicable for subtypes.
170 */
171 int auto_tags_OK;
172
173 enum asn1p_expr_marker_e {
174 EM_NOMARK,
175 EM_OPTIONAL,
176 EM_DEFAULT, /* FIXME: store the value somewhere. */
177 } marker;
178 int unique; /* UNIQUE */
179
180 /*
181 * Members of the constructed type.
182 */
183 TQ_HEAD(struct asn1p_expr_s) members;
184
185 /*
186 * Next expression in the list.
187 */
188 TQ_ENTRY(struct asn1p_expr_s) next;
189
190 /*
191 * Line number where this structure is defined in the original
192 * grammar source.
193 */
194 int _lineno;
195 /*
196 * Marks are used for various purposes.
197 * Here are some predefined ones.
198 */
199 enum {
200 TM_NOMARK,
201 TM_RECURSION, /* Used to break recursion */
202 } _mark;
203
204 /*
205 * Opaque data may be attached to this structure,
206 * probably by compiler.
207 */
208 void *data;
209 void (*data_free)(void *data);
210} asn1p_expr_t;
211
212
213/*
214 * Constructor and destructor.
215 */
216asn1p_expr_t *asn1p_expr_new(int _lineno);
217asn1p_expr_t *asn1p_expr_clone(asn1p_expr_t *);
218void asn1p_expr_free(asn1p_expr_t *expr);
219
220#endif /* ASN1_PARSER_EXPR_H */