Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1 | /* |
| 2 | * A generic value of different syntaxes. |
| 3 | */ |
| 4 | #ifndef ASN1_PARSER_VALUE_H |
| 5 | #define ASN1_PARSER_VALUE_H |
| 6 | |
| 7 | /* |
| 8 | * A wrapper around various kinds of values. |
| 9 | */ |
| 10 | typedef struct asn1p_value_s { |
| 11 | /* |
| 12 | * The value of the element. |
| 13 | */ |
| 14 | enum { |
| 15 | ATV_NOVALUE, |
| 16 | ATV_REFERENCED, |
| 17 | ATV_REAL, |
| 18 | ATV_INTEGER, |
| 19 | ATV_MIN, |
| 20 | ATV_MAX, |
| 21 | ATV_FALSE, |
| 22 | ATV_TRUE, |
| 23 | ATV_STRING, |
| 24 | ATV_UNPARSED, |
| 25 | ATV_BITVECTOR, |
| 26 | } type; /* Value type and location */ |
| 27 | |
| 28 | union { |
| 29 | asn1p_ref_t *reference; |
| 30 | asn1_integer_t v_integer; |
| 31 | double v_double; |
| 32 | /* |
| 33 | * Binary bits vector. |
| 34 | */ |
| 35 | struct { |
| 36 | uint8_t *buf; |
| 37 | int size; |
| 38 | } string; |
| 39 | struct { |
| 40 | uint8_t *bits; |
| 41 | int size_in_bits; |
| 42 | } binary_vector; |
| 43 | } value; |
| 44 | } asn1p_value_t; |
| 45 | |
| 46 | /* |
| 47 | * Constructors and destructor for value. |
| 48 | * If ref, bits or buffer are omitted, the corresponding function returns |
| 49 | * (asn1p_value_t *)0 with errno = EINVAL. |
| 50 | * Allocated value (where applicable) is guaranteed to be NUL-terminated. |
| 51 | */ |
| 52 | asn1p_value_t *asn1p_value_fromref(asn1p_ref_t *ref, int do_copy); |
| 53 | asn1p_value_t *asn1p_value_frombits(uint8_t *bits, int size_in_bits, int dc); |
| 54 | asn1p_value_t *asn1p_value_frombuf(char *buffer, int size, int do_copy); |
| 55 | asn1p_value_t *asn1p_value_fromdouble(double); |
| 56 | asn1p_value_t *asn1p_value_fromint(asn1_integer_t); |
| 57 | asn1p_value_t *asn1p_value_clone(asn1p_value_t *); |
| 58 | void asn1p_value_free(asn1p_value_t *); |
| 59 | |
| 60 | #endif /* ASN1_PARSER_VALUE_H */ |