blob: 5705f74554656640c657e8638b7a8b0151b2769b [file] [log] [blame]
vlmfa67ddc2004-06-03 03:38:44 +00001/*
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 */
10typedef struct asn1p_value_s {
11 /*
12 * The value of the element.
13 */
14 enum {
15 ATV_NOVALUE,
vlmc94e28f2004-09-15 11:59:51 +000016 ATV_NULL, /* A "NULL" value of type NULL. */
17 ATV_REAL, /* A constant floating-point value */
18 ATV_INTEGER, /* An integer constant */
vlmfa67ddc2004-06-03 03:38:44 +000019 ATV_MAX,
vlm39e5ed72004-09-05 10:40:41 +000020 ATV_MIN,
vlmfa67ddc2004-06-03 03:38:44 +000021 ATV_TRUE,
vlm39e5ed72004-09-05 10:40:41 +000022 ATV_FALSE,
vlme1e6ed82005-03-24 14:26:38 +000023 ATV_TUPLE, /* { 1, 15 } */
24 ATV_QUADRUPLE, /* { 0, 14, 0, 255 } */
25 ATV_STRING, /* "abcdef" */
vlmfa67ddc2004-06-03 03:38:44 +000026 ATV_UNPARSED,
27 ATV_BITVECTOR,
vlmc94e28f2004-09-15 11:59:51 +000028 ATV_REFERENCED, /* Reference to a value defined elsewhere */
29 ATV_CHOICE_IDENTIFIER, /* ChoiceIdentifier value */
vlmfa67ddc2004-06-03 03:38:44 +000030 } type; /* Value type and location */
31
32 union {
33 asn1p_ref_t *reference;
vlmec6acd42004-09-29 13:18:09 +000034 asn1c_integer_t v_integer;
vlmfa67ddc2004-06-03 03:38:44 +000035 double v_double;
36 /*
37 * Binary bits vector.
38 */
39 struct {
40 uint8_t *buf;
41 int size;
42 } string;
43 struct {
44 uint8_t *bits;
45 int size_in_bits;
46 } binary_vector;
vlmc94e28f2004-09-15 11:59:51 +000047 struct {
48 char *identifier;
49 struct asn1p_value_s *value;
50 } choice_identifier;
vlmfa67ddc2004-06-03 03:38:44 +000051 } value;
52} asn1p_value_t;
53
54/*
vlm0c6d3812006-03-21 03:40:38 +000055 * Destructor and constructors for value.
vlmfa67ddc2004-06-03 03:38:44 +000056 * If ref, bits or buffer are omitted, the corresponding function returns
57 * (asn1p_value_t *)0 with errno = EINVAL.
58 * Allocated value (where applicable) is guaranteed to be NUL-terminated.
59 */
vlm0c6d3812006-03-21 03:40:38 +000060void asn1p_value_free(asn1p_value_t *);
vlmfa67ddc2004-06-03 03:38:44 +000061asn1p_value_t *asn1p_value_fromref(asn1p_ref_t *ref, int do_copy);
62asn1p_value_t *asn1p_value_frombits(uint8_t *bits, int size_in_bits, int dc);
63asn1p_value_t *asn1p_value_frombuf(char *buffer, int size, int do_copy);
64asn1p_value_t *asn1p_value_fromdouble(double);
vlmec6acd42004-09-29 13:18:09 +000065asn1p_value_t *asn1p_value_fromint(asn1c_integer_t);
vlmfa67ddc2004-06-03 03:38:44 +000066asn1p_value_t *asn1p_value_clone(asn1p_value_t *);
vlm0c6d3812006-03-21 03:40:38 +000067asn1p_value_t *asn1p_value_clone_with_resolver(asn1p_value_t *,
68 asn1p_value_t *(*resolver)(asn1p_value_t *, void *rarg),
69 void *rarg);
vlmfa67ddc2004-06-03 03:38:44 +000070
71#endif /* ASN1_PARSER_VALUE_H */