blob: 8315bf43c417eb2c840a5616c01c9b179ab9702b [file] [log] [blame]
Lev Walkinf15320b2004-06-03 03:38:44 +00001/*
2 * A Module definition structure used by the ASN.1 parser.
3 */
4#ifndef ASN1_PARSER_MODULE_H
5#define ASN1_PARSER_MODULE_H
6
Lev Walkina9532f42006-09-17 04:52:50 +00007struct asn1p_module_s;
8
9/*
10 * A simple container for several modules.
11 */
12typedef struct asn1p_s {
13 TQ_HEAD(struct asn1p_module_s) modules;
14} asn1p_t;
15
16asn1p_t *asn1p_new(void);
17void asn1p_delete(asn1p_t *asn);
18
Lev Walkin1a49ced2017-11-06 00:07:00 -080019struct genhash_s; /* Forward declaration */
20
Lev Walkinf15320b2004-06-03 03:38:44 +000021/*
22 * Flags specific to a module.
23 */
24typedef enum asn1p_module_flags {
25 MSF_NOFLAGS,
Lev Walkinf59d0752004-08-18 04:59:12 +000026 MSF_unk_INSTRUCTIONS = 0x001,
27 MSF_TAG_INSTRUCTIONS = 0x002,
28 MSF_XER_INSTRUCTIONS = 0x004,
29 MSF_EXPLICIT_TAGS = 0x010,
30 MSF_IMPLICIT_TAGS = 0x020,
31 MSF_AUTOMATIC_TAGS = 0x040,
32 MSF_EXTENSIBILITY_IMPLIED = 0x100,
Lev Walkinf15320b2004-06-03 03:38:44 +000033} asn1p_module_flags_e;
Lev Walkinf59d0752004-08-18 04:59:12 +000034#define MSF_MASK_INSTRUCTIONS 0x0f
35#define MSF_MASK_TAGS 0xf0
Lev Walkinf15320b2004-06-03 03:38:44 +000036
37/*
38 * === EXAMPLE ===
39 * MySyntax DEFINITIONS AUTOMATIC TAGS ::=
40 * BEGIN
41 * ...
42 * END
43 * === EOF ===
44 */
45typedef struct asn1p_module_s {
46
47 /*
Lev Walkinc0e03b92017-08-22 01:48:23 -070048 * Human-readable module reference.
49 */
50 char *ModuleName; /* Must be the first field */
51
52 /*
Lev Walkinf15320b2004-06-03 03:38:44 +000053 * Name of the source file.
54 */
55 char *source_file_name;
56
57 /*
Lev Walkinf15320b2004-06-03 03:38:44 +000058 * Unique module identifier, OID.
59 */
60 asn1p_oid_t *module_oid; /* Optional OID of the module */
61
62 /*
63 * Module flags.
64 */
65 asn1p_module_flags_e module_flags; /* AUTOMATIC TAGS? */
66
67 /*
Lev Walkinf15320b2004-06-03 03:38:44 +000068 * List of everything that this module EXPORTS.
69 */
70 TQ_HEAD(struct asn1p_xports_s) exports;
71
72 /*
Lev Walkin866bd7f2006-09-14 10:35:20 +000073 * List of everything that this module IMPORTS.
74 */
75 TQ_HEAD(struct asn1p_xports_s) imports;
76
77 /*
Lev Walkinf15320b2004-06-03 03:38:44 +000078 * List of everything that this module defines itself.
79 */
Lev Walkin1a49ced2017-11-06 00:07:00 -080080 TQ_HEAD(struct asn1p_expr_s) members; /* Do not access directly */
81 struct genhash_s *members_hash;
Lev Walkinf15320b2004-06-03 03:38:44 +000082
83 /*
84 * Next module in the list.
85 */
86 TQ_ENTRY(struct asn1p_module_s)
87 mod_next;
88
Lev Walkina9532f42006-09-17 04:52:50 +000089 /* All modules */
90 asn1p_t *asn1p;
91
Lev Walkin46499872006-03-06 13:05:34 +000092 /*
93 * Internally useful properties.
94 */
95 enum {
96 MT_STANDARD_MODULE = 0x01, /* Module came from standard-modules */
97 } _tags;
Lev Walkinf15320b2004-06-03 03:38:44 +000098} asn1p_module_t;
99
100/*
101 * Constructor and destructor.
102 */
103asn1p_module_t *asn1p_module_new(void);
104void asn1p_module_free(asn1p_module_t *mod);
105
Lev Walkin1a49ced2017-11-06 00:07:00 -0800106void asn1p_module_move_members(asn1p_module_t *to, asn1p_module_t *from);
107void asn1p_module_member_add(asn1p_module_t *mod, struct asn1p_expr_s *expr);
108
109
Lev Walkinf15320b2004-06-03 03:38:44 +0000110#endif /* ASN1_PARSER_MODULE_H */