blob: 1b5bbeec42e197d132fe990574fc1cbfd74a3b72 [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
vlmdfbff8c2006-03-21 09:41:28 +00007struct asn1p_constraint_s; /* Forward declaration */
8
vlmfa67ddc2004-06-03 03:38:44 +00009/*
10 * A wrapper around various kinds of values.
11 */
12typedef struct asn1p_value_s {
13 /*
14 * The value of the element.
15 */
16 enum {
17 ATV_NOVALUE,
vlmc94e28f2004-09-15 11:59:51 +000018 ATV_NULL, /* A "NULL" value of type NULL. */
19 ATV_REAL, /* A constant floating-point value */
20 ATV_INTEGER, /* An integer constant */
vlmfa67ddc2004-06-03 03:38:44 +000021 ATV_MAX,
vlm39e5ed72004-09-05 10:40:41 +000022 ATV_MIN,
vlmfa67ddc2004-06-03 03:38:44 +000023 ATV_TRUE,
vlm39e5ed72004-09-05 10:40:41 +000024 ATV_FALSE,
vlme1e6ed82005-03-24 14:26:38 +000025 ATV_TUPLE, /* { 1, 15 } */
26 ATV_QUADRUPLE, /* { 0, 14, 0, 255 } */
27 ATV_STRING, /* "abcdef" */
vlmfa67ddc2004-06-03 03:38:44 +000028 ATV_UNPARSED,
29 ATV_BITVECTOR,
vlmdfbff8c2006-03-21 09:41:28 +000030 ATV_VALUESET, /* { 1 | 2 | 3 } */
vlmc94e28f2004-09-15 11:59:51 +000031 ATV_REFERENCED, /* Reference to a value defined elsewhere */
32 ATV_CHOICE_IDENTIFIER, /* ChoiceIdentifier value */
vlmfa67ddc2004-06-03 03:38:44 +000033 } type; /* Value type and location */
34
35 union {
vlmdfbff8c2006-03-21 09:41:28 +000036 struct asn1p_constraint_s *constraint; /* ValueSet */
vlmfa67ddc2004-06-03 03:38:44 +000037 asn1p_ref_t *reference;
vlmec6acd42004-09-29 13:18:09 +000038 asn1c_integer_t v_integer;
vlmfa67ddc2004-06-03 03:38:44 +000039 double v_double;
40 /*
41 * Binary bits vector.
42 */
43 struct {
44 uint8_t *buf;
45 int size;
46 } string;
47 struct {
48 uint8_t *bits;
49 int size_in_bits;
50 } binary_vector;
vlmc94e28f2004-09-15 11:59:51 +000051 struct {
52 char *identifier;
53 struct asn1p_value_s *value;
54 } choice_identifier;
vlmfa67ddc2004-06-03 03:38:44 +000055 } value;
56} asn1p_value_t;
57
58/*
vlm0c6d3812006-03-21 03:40:38 +000059 * Destructor and constructors for value.
vlmfa67ddc2004-06-03 03:38:44 +000060 * If ref, bits or buffer are omitted, the corresponding function returns
61 * (asn1p_value_t *)0 with errno = EINVAL.
62 * Allocated value (where applicable) is guaranteed to be NUL-terminated.
63 */
vlm0c6d3812006-03-21 03:40:38 +000064void asn1p_value_free(asn1p_value_t *);
vlmfa67ddc2004-06-03 03:38:44 +000065asn1p_value_t *asn1p_value_fromref(asn1p_ref_t *ref, int do_copy);
vlmdfbff8c2006-03-21 09:41:28 +000066asn1p_value_t *asn1p_value_fromconstr(struct asn1p_constraint_s *ct, int dc);
vlmfa67ddc2004-06-03 03:38:44 +000067asn1p_value_t *asn1p_value_frombits(uint8_t *bits, int size_in_bits, int dc);
68asn1p_value_t *asn1p_value_frombuf(char *buffer, int size, int do_copy);
69asn1p_value_t *asn1p_value_fromdouble(double);
vlmec6acd42004-09-29 13:18:09 +000070asn1p_value_t *asn1p_value_fromint(asn1c_integer_t);
vlmfa67ddc2004-06-03 03:38:44 +000071asn1p_value_t *asn1p_value_clone(asn1p_value_t *);
vlm0c6d3812006-03-21 03:40:38 +000072asn1p_value_t *asn1p_value_clone_with_resolver(asn1p_value_t *,
73 asn1p_value_t *(*resolver)(asn1p_value_t *, void *rarg),
74 void *rarg);
vlmfa67ddc2004-06-03 03:38:44 +000075
76#endif /* ASN1_PARSER_VALUE_H */