blob: d3756780b1c46ea0c830d9b5b1a13d6c215a6203 [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;
56 int el_count; /* Number of meaningful elements */
57 int el_size; /* Size of the allocated (elements) */
58
59 int _lineno; /* Position in a source file */
60} asn1p_constraint_t;
61
Lev Walkinf59d0752004-08-18 04:59:12 +000062/* Human-readable constraint type description */
63char *asn1p_constraint_type2str(enum asn1p_constraint_type_e);
Lev Walkinf15320b2004-06-03 03:38:44 +000064
65/*
66 * Constructors and a recursive destructor.
67 */
68asn1p_constraint_t *asn1p_constraint_new(int _lineno);
69void asn1p_constraint_free(asn1p_constraint_t *);
70
71/*
72 * Clone the constraint and all its children.
73 */
74asn1p_constraint_t *asn1p_constraint_clone(asn1p_constraint_t *source_to_clone);
75
76/*
77 * Insert additional element into the element array of a (to) constraint.
78 */
79int asn1p_constraint_insert(asn1p_constraint_t *into, asn1p_constraint_t *what);
80
81#endif /* ASN1_PARSER_CONSTRAINT_H */