blob: 9d4763acefede112c753c8cb4bdd457242de00bb [file] [log] [blame]
vlmb5be8c32004-08-18 05:42:05 +00001#ifndef ASN1FIX_CRANGE_H
2#define ASN1FIX_CRANGE_H
3
4typedef 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 */
11 asn1_integer_t value; /* Value when type is ARE_VALUE */
12} asn1cnst_edge_t;
13
14typedef 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. */
vlmee8b06f2004-08-25 02:05:28 +000024 int extensible; /* Extension marker (...) is in effect. */
vlmb5be8c32004-08-18 05:42:05 +000025
vlmee8b06f2004-08-25 02:05:28 +000026 int incompatible; /* Constraint incompatible with argument */
27 int not_PER_visible; /* Contains not PER-visible components */
vlmb5be8c32004-08-18 05:42:05 +000028} asn1cnst_range_t;
29
30/*
vlmee8b06f2004-08-25 02:05:28 +000031 * Compute the constraint range with variable PER visibility restrictions.
vlmb5be8c32004-08-18 05:42:05 +000032 *
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 */
41asn1cnst_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,
vlmee8b06f2004-08-25 02:05:28 +000045 int *expectation_met,
46 int strict_PER_visibility);
vlmb5be8c32004-08-18 05:42:05 +000047void asn1constraint_range_free(asn1cnst_range_t *);
48
49/*
50 * Check that a specific constraint is compatible
51 * with the given expression type.
52 */
53int 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 */
59asn1cnst_range_t *asn1constraint_default_alphabet(asn1p_expr_type_e expr_type);
60
61#endif /* ASN1FIX_CRANGE_H */