Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Type constraints. |
| 3 | */ |
| 4 | #ifndef ASN1_PARSER_CONSTRAINT_H |
| 5 | #define ASN1_PARSER_CONSTRAINT_H |
| 6 | |
| 7 | typedef 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 | |
| 62 | |
| 63 | /* |
| 64 | * Constructors and a recursive destructor. |
| 65 | */ |
| 66 | asn1p_constraint_t *asn1p_constraint_new(int _lineno); |
| 67 | void asn1p_constraint_free(asn1p_constraint_t *); |
| 68 | |
| 69 | /* |
| 70 | * Clone the constraint and all its children. |
| 71 | */ |
| 72 | asn1p_constraint_t *asn1p_constraint_clone(asn1p_constraint_t *source_to_clone); |
| 73 | |
| 74 | /* |
| 75 | * Insert additional element into the element array of a (to) constraint. |
| 76 | */ |
| 77 | int asn1p_constraint_insert(asn1p_constraint_t *into, asn1p_constraint_t *what); |
| 78 | |
| 79 | #endif /* ASN1_PARSER_CONSTRAINT_H */ |