4 #ifndef ASN1_PARSER_CONSTRAINT_H
5 #define ASN1_PARSER_CONSTRAINT_H
7 typedef struct asn1p_constraint_s {
9 enum asn1p_constraint_type_e {
10 ACT_INVALID, /* for assertions */
12 * Constraint elements.
14 ACT_EL_TYPE, /* T (contained subtype) */
15 ACT_EL_VALUE, /* 123, "A", (elementary value) */
16 ACT_EL_RANGE, /* 1..2 (elementary range) */
17 ACT_EL_LLRANGE, /* 1<..2 (elementary range) */
18 ACT_EL_RLRANGE, /* 1..<2 (elementary range) */
19 ACT_EL_ULRANGE, /* 1<..<2 (elementary range) */
20 ACT_EL_EXT, /* ... (extensibility mark) */
24 ACT_CT_SIZE, /* SIZE constraint type */
25 ACT_CT_FROM, /* FROM constraint type */
26 ACT_CT_WCOMP, /* WITH COMPONENT */
27 ACT_CT_WCOMPS, /* WITH COMPONENTS */
28 ACT_CT_CTDBY, /* CONSTRAINED BY */
29 ACT_CT_CTNG, /* CONTAINING Type */
30 ACT_CT_PATTERN, /* PATTERN Value */
32 * Arrays of constraints.
34 ACT_CA_SET, /* A set of constraints: (c1)(c2) */
35 ACT_CA_CRC, /* Comp. relation c-t: ({a}{@b}) */
36 ACT_CA_CSV, /* Comma-separated constraints array */
37 ACT_CA_UNI, /* UNION (|) */
38 ACT_CA_INT, /* INTERSECTION (^) */
39 ACT_CA_EXC, /* EXCEPT */
40 ACT_CA_AEX, /* ALL EXCEPT */
43 enum asn1p_constr_pres_e {
50 struct asn1p_constraint_s *parent_ct; /* optional */
53 * Separate types and values.
55 asn1p_value_t *containedSubtype;
57 asn1p_value_t *range_start;
58 asn1p_value_t *range_stop;
61 * A collection of constraint elements.
63 struct asn1p_constraint_s **elements;
64 unsigned int el_count; /* Number of meaningful elements */
65 unsigned int el_size; /* Size of the allocated (elements) */
67 struct asn1p_module_s *module; /* Defined in module */
68 int _lineno; /* Position in a source file */
71 /* Human-readable constraint type description */
72 const char *asn1p_constraint_type2str(enum asn1p_constraint_type_e);
74 const asn1p_constraint_t *asn1p_get_component_relation_constraint(
75 asn1p_constraint_t *);
77 int asn1p_constraint_compare(const asn1p_constraint_t *,
78 const asn1p_constraint_t *);
79 void asn1p_constraint_set_source(asn1p_constraint_t *,
80 struct asn1p_module_s *module, int lineno);
83 * Constructors and a recursive destructor.
85 asn1p_constraint_t *asn1p_constraint_new(int _lineno, asn1p_module_t *mod);
86 void asn1p_constraint_free(asn1p_constraint_t *);
89 * Clone the constraint and all its children.
91 asn1p_constraint_t *asn1p_constraint_clone(asn1p_constraint_t *source_to_clone);
92 asn1p_constraint_t *asn1p_constraint_clone_with_resolver(
93 asn1p_constraint_t *source_to_clone,
94 asn1p_value_t *(*resolver)(asn1p_value_t *, void *), void *);
97 * Insert additional element into the element array of a (to) constraint.
99 int asn1p_constraint_insert(asn1p_constraint_t *into, asn1p_constraint_t *what);
100 int asn1p_constraint_prepend(asn1p_constraint_t *before, asn1p_constraint_t *what);
102 #endif /* ASN1_PARSER_CONSTRAINT_H */