blob: 7c425b45afcd77b32f89cbebb149c607090fbc6d [file] [log] [blame]
Lev Walkinf15320b2004-06-03 03:38:44 +00001/*
2 * Type constraints.
3 */
4#ifndef ASN1_PARSER_CONSTRAINT_H
5#define ASN1_PARSER_CONSTRAINT_H
6
7typedef struct asn1p_constraint_s {
8
9 enum asn1p_constraint_type_e {
10 ACT_INVALID, /* for assertions */
11 /*
12 * Constraint elements.
13 */
14 ACT_EL_VALUE, /* 123, "A", T (elementary value) */
15 ACT_EL_RANGE, /* 1..2 (elementary range) */
16 ACT_EL_LLRANGE, /* 1<..2 (elementary range) */
17 ACT_EL_RLRANGE, /* 1..<2 (elementary range) */
18 ACT_EL_ULRANGE, /* 1<..<2 (elementary range) */
19 ACT_EL_EXT, /* ... (extensibility mark) */
20 /*
21 * Constraint types.
22 */
23 ACT_CT_SIZE, /* SIZE constraint type */
24 ACT_CT_FROM, /* FROM constraint type */
25 ACT_CT_WCOMP, /* WITH COMPONENT */
26 ACT_CT_WCOMPS, /* WITH COMPONENTS */
27 /*
28 * Arrays of constraints.
29 */
30 ACT_CA_SET, /* A set of constraints: (c1)(c2) */
31 ACT_CA_CRC, /* Comp. relation c-t: ({a})({@b}) */
32 ACT_CA_CSV, /* Comma-separated constraints array */
33 ACT_CA_UNI, /* UNION (|) */
34 ACT_CA_INT, /* INTERSECTION (^) */
35 ACT_CA_EXC, /* EXCEPT */
36 } type;
37
38 enum asn1p_constr_pres_e {
39 ACPRES_DEFAULT,
40 ACPRES_PRESENT,
41 ACPRES_ABSENT,
42 ACPRES_OPTIONAL,
43 } presence;
44
45 /*
46 * A single values.
47 */
48 asn1p_value_t *value;
49 asn1p_value_t *range_start;
50 asn1p_value_t *range_stop;
51
52 /*
53 * A collection of constraint elements.
54 */
55 struct asn1p_constraint_s **elements;
Lev Walkine972d932004-09-05 10:40:28 +000056 unsigned int el_count; /* Number of meaningful elements */
57 unsigned int el_size; /* Size of the allocated (elements) */
Lev Walkinf15320b2004-06-03 03:38:44 +000058
59 int _lineno; /* Position in a source file */
Lev Walkin04d7be42004-08-19 13:32:17 +000060 int _compile_mark; /* Marker used by the compiler */
Lev Walkinf15320b2004-06-03 03:38:44 +000061} asn1p_constraint_t;
62
Lev Walkinf59d0752004-08-18 04:59:12 +000063/* Human-readable constraint type description */
64char *asn1p_constraint_type2str(enum asn1p_constraint_type_e);
Lev Walkinf15320b2004-06-03 03:38:44 +000065
66/*
67 * Constructors and a recursive destructor.
68 */
69asn1p_constraint_t *asn1p_constraint_new(int _lineno);
70void asn1p_constraint_free(asn1p_constraint_t *);
71
72/*
73 * Clone the constraint and all its children.
74 */
75asn1p_constraint_t *asn1p_constraint_clone(asn1p_constraint_t *source_to_clone);
76
77/*
78 * Insert additional element into the element array of a (to) constraint.
79 */
80int asn1p_constraint_insert(asn1p_constraint_t *into, asn1p_constraint_t *what);
81
82#endif /* ASN1_PARSER_CONSTRAINT_H */