blob: 9873e3b20cf103593797b98a84ae94c505bb92a1 [file] [log] [blame]
Lev Walkinb45e0672004-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. */
24 int extensible; /* Extension marker (...) present. */
25
26 int not_PER_visible; /* Contains non PER-visible components */
27} asn1cnst_range_t;
28
29/*
30 * Compute the PER-visible constraint range.
31 *
32 * (expr_type) must have the type of the top-level parent ASN.1 type.
33 * (required_type) must be one of ACT_EL_RANGE, ACT_CT_SIZE or ACT_CT_FROM.
34 * (minmax) and (expectation_met) should be 0.
35 * ERRORS:
36 * EINVAL: Mandatory arguments missing.
37 * ENOMEM: Memory allocation failure.
38 * EPERM: Invalid constraint reference.
39 */
40asn1cnst_range_t *asn1constraint_compute_PER_range(asn1p_expr_type_e expr_type,
41 const asn1p_constraint_t *ct,
42 enum asn1p_constraint_type_e required_type,
43 const asn1cnst_range_t *minmax,
44 int *expectation_met);
45void asn1constraint_range_free(asn1cnst_range_t *);
46
47/*
48 * Check that a specific constraint is compatible
49 * with the given expression type.
50 */
51int asn1constraint_compatible(asn1p_expr_type_e expr_type,
52 enum asn1p_constraint_type_e constr_type);
53
54/*
55 * Fetch a default alphabet for this type.
56 */
57asn1cnst_range_t *asn1constraint_default_alphabet(asn1p_expr_type_e expr_type);
58
59#endif /* ASN1FIX_CRANGE_H */