blob: c5a99c1f01adc5db304898af6ed7fc51683aaaf2 [file] [log] [blame]
Lev Walkinf15320b2004-06-03 03:38:44 +00001/*
2 * Generic reference to the yet unknown type defined elsewhere.
3 */
4#ifndef ASN1_PARSER_REFERENCE_H
5#define ASN1_PARSER_REFERENCE_H
6
7typedef struct asn1p_ref_s {
8
9 /*
10 * A set of reference name components.
11 * A reference name consists of several components separated by dots:
12 * "OBJECT-CLASS.&Algorithm.&id"
13 */
14 struct asn1p_ref_component_s {
15 enum asn1p_ref_lex_type_e {
16 RLT_UNKNOWN, /* Invalid? */
17 /*
18 * Object class reference "OCLASS1",
19 * type reference "Type1",
20 * value reference "id",
21 * type field reference "&Type1",
22 * value field reference "&id",
23 * "OBJECT-CLASS"
24 */
25 RLT_CAPITALS,
26 RLT_Uppercase,
27 RLT_lowercase,
28 RLT_AmpUppercase,
29 RLT_Amplowercase,
30 RLT_Atlowercase,
31 RLT_AtDotlowercase,
32 RLT_MAX
33 } lex_type; /* Inferred lexical type of the identifier */
34 char *name; /* An identifier */
35 } *components;
36
Lev Walkin62d95d22017-08-06 23:41:11 -070037 size_t comp_count; /* Number of the components in the reference name. */
38 size_t comp_size; /* Number of allocated structures */
Lev Walkinf15320b2004-06-03 03:38:44 +000039
Bi-Ruei, Chiu80fd3062017-05-07 21:00:51 +080040 struct asn1p_module_s *module; /* Defined in module */
Lev Walkinf15320b2004-06-03 03:38:44 +000041 int _lineno; /* Number of line in the file */
42} asn1p_ref_t;
43
44/*
45 * Constructor and destructor.
46 */
Bi-Ruei, Chiu80fd3062017-05-07 21:00:51 +080047asn1p_ref_t *asn1p_ref_new(int _lineno, asn1p_module_t *mod);
Lev Walkinf15320b2004-06-03 03:38:44 +000048void asn1p_ref_free(asn1p_ref_t *);
49
50asn1p_ref_t *asn1p_ref_clone(asn1p_ref_t *ref);
51
Lev Walkinea6635b2017-08-06 23:23:04 -070052void asn1p_ref_set_source(asn1p_ref_t *, asn1p_module_t *module, int lineno);
53
54
55/*
56 * Lexicographically compare references.
57 */
58int asn1p_ref_compare(const asn1p_ref_t *, const asn1p_ref_t *);
59
60/*
61 * Return a pointer to a statically allocated buffer representing the
62 * complete reference.
63 */
64const char *asn1p_ref_string(const asn1p_ref_t *);
65
Lev Walkinf15320b2004-06-03 03:38:44 +000066/*
67 * Add a new reference component to the existing reference structure.
68 *
69 * RETURN VALUES:
70 * 0: All clear.
71 * -1/EINVAL: Invalid arguments
72 * -1/ENOMEM: Memory allocation failed
73 */
74int asn1p_ref_add_component(asn1p_ref_t *,
Lev Walkinecbb8ff2017-08-06 15:01:00 -070075 const char *name, enum asn1p_ref_lex_type_e);
Lev Walkinf15320b2004-06-03 03:38:44 +000076
77#endif /* ASN1_PARSER_REFERENCE_H */