blob: fa622d7fb71d637564d00d6138b654526bcac5b7 [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,
vlmfa67ddc2004-06-03 03:38:44 +000023 ATV_STRING,
24 ATV_UNPARSED,
25 ATV_BITVECTOR,
vlmc94e28f2004-09-15 11:59:51 +000026 ATV_REFERENCED, /* Reference to a value defined elsewhere */
27 ATV_CHOICE_IDENTIFIER, /* ChoiceIdentifier value */
vlmfa67ddc2004-06-03 03:38:44 +000028 } type; /* Value type and location */
29
30 union {
31 asn1p_ref_t *reference;
vlmec6acd42004-09-29 13:18:09 +000032 asn1c_integer_t v_integer;
vlmfa67ddc2004-06-03 03:38:44 +000033 double v_double;
34 /*
35 * Binary bits vector.
36 */
37 struct {
38 uint8_t *buf;
39 int size;
40 } string;
41 struct {
42 uint8_t *bits;
43 int size_in_bits;
44 } binary_vector;
vlmc94e28f2004-09-15 11:59:51 +000045 struct {
46 char *identifier;
47 struct asn1p_value_s *value;
48 } choice_identifier;
vlmfa67ddc2004-06-03 03:38:44 +000049 } value;
50} asn1p_value_t;
51
52/*
53 * Constructors and destructor for value.
54 * If ref, bits or buffer are omitted, the corresponding function returns
55 * (asn1p_value_t *)0 with errno = EINVAL.
56 * Allocated value (where applicable) is guaranteed to be NUL-terminated.
57 */
58asn1p_value_t *asn1p_value_fromref(asn1p_ref_t *ref, int do_copy);
59asn1p_value_t *asn1p_value_frombits(uint8_t *bits, int size_in_bits, int dc);
60asn1p_value_t *asn1p_value_frombuf(char *buffer, int size, int do_copy);
61asn1p_value_t *asn1p_value_fromdouble(double);
vlmec6acd42004-09-29 13:18:09 +000062asn1p_value_t *asn1p_value_fromint(asn1c_integer_t);
vlmfa67ddc2004-06-03 03:38:44 +000063asn1p_value_t *asn1p_value_clone(asn1p_value_t *);
64void asn1p_value_free(asn1p_value_t *);
65
66#endif /* ASN1_PARSER_VALUE_H */