blob: 331285c719fa3f2e2b659178fafcfeed0dc5d835 [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 /*
128 * A list of parameters for parametrized type declaration
129 * (AMT_PARAMTYPE).
130 */
131 asn1p_paramlist_t *params;
132
133 /*
134 * The actual value (DefinedValue or inlined value).
135 */
136 asn1p_value_t *value;
137
138 /*
139 * The WITH SYHTAX clause.
140 */
141 asn1p_wsyntx_t *with_syntax;
142
143 /*
144 * A tag.
145 */
146 struct asn1p_type_tag_s {
147 enum {
148 TC_NOCLASS,
149 TC_UNIVERSAL,
150 TC_APPLICATION,
151 TC_CONTEXT_SPECIFIC,
152 TC_PRIVATE,
153 } tag_class;
154 enum {
155 TM_DEFAULT,
156 TM_IMPLICIT,
157 TM_EXPLICIT,
158 } tag_mode;
159 asn1_integer_t tag_value;
160 } tag;
161
162 /*
163 * Whether automatic tagging is applicable for subtypes.
164 */
165 int auto_tags_OK;
166
167 enum asn1p_expr_marker_e {
168 EM_NOMARK,
169 EM_OPTIONAL,
170 EM_DEFAULT, /* FIXME: store the value somewhere. */
171 } marker;
172 int unique; /* UNIQUE */
173
174 /*
175 * Members of the constructed type.
176 */
177 TQ_HEAD(struct asn1p_expr_s) members;
178
179 /*
180 * Next expression in the list.
181 */
182 TQ_ENTRY(struct asn1p_expr_s) next;
183
184 /*
185 * Line number where this structure is defined in the original
186 * grammar source.
187 */
188 int _lineno;
189 /*
190 * Marks are used for various purposes.
191 * Here are some predefined ones.
192 */
193 enum {
194 TM_NOMARK,
195 TM_RECURSION, /* Used to break recursion */
196 } _mark;
197
198 /*
199 * Opaque data may be attached to this structure,
200 * probably by compiler.
201 */
202 void *data;
203 void (*data_free)(void *data);
204} asn1p_expr_t;
205
206
207/*
208 * Constructor and destructor.
209 */
210asn1p_expr_t *asn1p_expr_new(int _lineno);
211asn1p_expr_t *asn1p_expr_clone(asn1p_expr_t *);
212void asn1p_expr_free(asn1p_expr_t *expr);
213
214#endif /* ASN1_PARSER_EXPR_H */