vlm | b5be8c3 | 2004-08-18 05:42:05 +0000 | [diff] [blame] | 1 | #ifndef ASN1FIX_CRANGE_H |
| 2 | #define ASN1FIX_CRANGE_H |
| 3 | |
| 4 | typedef struct asn1cnst_edge_s { |
| 5 | enum asn1cnst_range_edge { |
| 6 | ARE_MIN, |
| 7 | ARE_MAX, |
| 8 | ARE_VALUE, |
| 9 | } type; |
| 10 | int lineno; /* Line where the corresponding token was found */ |
vlm | d5b3bf3 | 2004-09-29 13:17:17 +0000 | [diff] [blame] | 11 | asn1c_integer_t value; /* Value when type is ARE_VALUE */ |
vlm | b5be8c3 | 2004-08-18 05:42:05 +0000 | [diff] [blame] | 12 | } asn1cnst_edge_t; |
| 13 | |
| 14 | typedef struct asn1cnst_range_s { |
| 15 | asn1cnst_edge_t left; /* MIN from (MIN..10) */ |
| 16 | asn1cnst_edge_t right; /* 10 from (MIN..10) */ |
| 17 | |
| 18 | /* If range is split in parts, these are the parts */ |
| 19 | struct asn1cnst_range_s **elements; |
| 20 | int el_count; |
| 21 | int el_size; |
| 22 | |
| 23 | int empty_constraint; /* If yes, too bad. */ |
vlm | ee8b06f | 2004-08-25 02:05:28 +0000 | [diff] [blame] | 24 | int extensible; /* Extension marker (...) is in effect. */ |
vlm | b5be8c3 | 2004-08-18 05:42:05 +0000 | [diff] [blame] | 25 | |
vlm | ee8b06f | 2004-08-25 02:05:28 +0000 | [diff] [blame] | 26 | int incompatible; /* Constraint incompatible with argument */ |
| 27 | int not_PER_visible; /* Contains not PER-visible components */ |
vlm | b5be8c3 | 2004-08-18 05:42:05 +0000 | [diff] [blame] | 28 | } asn1cnst_range_t; |
| 29 | |
| 30 | /* |
vlm | ee8b06f | 2004-08-25 02:05:28 +0000 | [diff] [blame] | 31 | * Compute the constraint range with variable PER visibility restrictions. |
vlm | b5be8c3 | 2004-08-18 05:42:05 +0000 | [diff] [blame] | 32 | * |
| 33 | * (expr_type) must have the type of the top-level parent ASN.1 type. |
| 34 | * (required_type) must be one of ACT_EL_RANGE, ACT_CT_SIZE or ACT_CT_FROM. |
| 35 | * (minmax) and (expectation_met) should be 0. |
| 36 | * ERRORS: |
| 37 | * EINVAL: Mandatory arguments missing. |
| 38 | * ENOMEM: Memory allocation failure. |
| 39 | * EPERM: Invalid constraint reference. |
| 40 | */ |
| 41 | asn1cnst_range_t *asn1constraint_compute_PER_range(asn1p_expr_type_e expr_type, |
| 42 | const asn1p_constraint_t *ct, |
| 43 | enum asn1p_constraint_type_e required_type, |
| 44 | const asn1cnst_range_t *minmax, |
vlm | ee8b06f | 2004-08-25 02:05:28 +0000 | [diff] [blame] | 45 | int *expectation_met, |
| 46 | int strict_PER_visibility); |
vlm | b5be8c3 | 2004-08-18 05:42:05 +0000 | [diff] [blame] | 47 | void asn1constraint_range_free(asn1cnst_range_t *); |
| 48 | |
| 49 | /* |
| 50 | * Check that a specific constraint is compatible |
| 51 | * with the given expression type. |
| 52 | */ |
| 53 | int asn1constraint_compatible(asn1p_expr_type_e expr_type, |
| 54 | enum asn1p_constraint_type_e constr_type); |
| 55 | |
| 56 | /* |
| 57 | * Fetch a default alphabet for this type. |
| 58 | */ |
| 59 | asn1cnst_range_t *asn1constraint_default_alphabet(asn1p_expr_type_e expr_type); |
| 60 | |
| 61 | #endif /* ASN1FIX_CRANGE_H */ |