NativeEnumerated.c vars NULL init and check
[com/asn1c.git] / libasn1common / asn1_ref.h
1 /*
2  * Generic reference to the yet unknown type defined elsewhere.
3  */
4 #ifndef ASN1_REFERENCE_H
5 #define ASN1_REFERENCE_H
6
7 struct asn1p_module_s;
8
9 typedef struct asn1p_ref_s {
10
11         /*
12          * A set of reference name components.
13          * A reference name consists of several components separated by dots:
14          * "OBJECT-CLASS.&Algorithm.&id"
15          */
16         struct asn1p_ref_component_s {
17                 enum asn1p_ref_lex_type_e {
18                         RLT_UNKNOWN,            /* Invalid? */
19                         /*
20                          * Object class reference "OCLASS1",
21                          * type reference "Type1",
22                          * value reference "id",
23                          * type field reference "&Type1",
24                          * value field reference "&id",
25                          * "OBJECT-CLASS"
26                          */
27                         RLT_CAPITALS,
28                         RLT_Uppercase,
29                         RLT_lowercase,
30                         RLT_AmpUppercase,
31                         RLT_Amplowercase,
32                         RLT_Atlowercase,
33                         RLT_AtDotlowercase,
34                         RLT_MAX
35                 } lex_type;     /* Inferred lexical type of the identifier */
36                 char *name;     /* An identifier */
37         } *components;
38
39         size_t comp_count;      /* Number of the components in the reference name. */
40         size_t comp_size;       /* Number of allocated structures */
41
42         struct asn1p_module_s *module;  /* Defined in module */
43         int _lineno;    /* Number of line in the file */
44 } asn1p_ref_t;
45
46 /*
47  * Constructor and destructor.
48  */
49 asn1p_ref_t *asn1p_ref_new(int _lineno, struct asn1p_module_s *mod);
50 void asn1p_ref_free(asn1p_ref_t *);
51
52 asn1p_ref_t *asn1p_ref_clone(asn1p_ref_t *ref);
53
54 void asn1p_ref_set_source(asn1p_ref_t *, struct asn1p_module_s *module,
55                           int lineno);
56
57
58 /*
59  * Lexicographically compare references.
60  */
61 int asn1p_ref_compare(const asn1p_ref_t *, const asn1p_ref_t *);
62
63 /*
64  * Return a pointer to a statically allocated buffer representing the
65  * complete reference.
66  */
67 const char *asn1p_ref_string(const asn1p_ref_t *);
68
69 /*
70  * Add a new reference component to the existing reference structure.
71  *
72  * RETURN VALUES:
73  *  0:          All clear.
74  * -1/EINVAL:   Invalid arguments
75  * -1/ENOMEM:   Memory allocation failed
76  */
77 int asn1p_ref_add_component(asn1p_ref_t *,
78         const char *name, enum asn1p_ref_lex_type_e);
79
80 #endif  /* ASN1_REFERENCE_H */