Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1 | /* |
| 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 Walkin | a9532f4 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 7 | struct asn1p_module_s; |
| 8 | |
| 9 | /* |
| 10 | * A simple container for several modules. |
| 11 | */ |
| 12 | typedef struct asn1p_s { |
| 13 | TQ_HEAD(struct asn1p_module_s) modules; |
| 14 | } asn1p_t; |
| 15 | |
| 16 | asn1p_t *asn1p_new(void); |
| 17 | void asn1p_delete(asn1p_t *asn); |
| 18 | |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 19 | /* |
| 20 | * Flags specific to a module. |
| 21 | */ |
| 22 | typedef enum asn1p_module_flags { |
| 23 | MSF_NOFLAGS, |
Lev Walkin | f59d075 | 2004-08-18 04:59:12 +0000 | [diff] [blame] | 24 | MSF_unk_INSTRUCTIONS = 0x001, |
| 25 | MSF_TAG_INSTRUCTIONS = 0x002, |
| 26 | MSF_XER_INSTRUCTIONS = 0x004, |
| 27 | MSF_EXPLICIT_TAGS = 0x010, |
| 28 | MSF_IMPLICIT_TAGS = 0x020, |
| 29 | MSF_AUTOMATIC_TAGS = 0x040, |
| 30 | MSF_EXTENSIBILITY_IMPLIED = 0x100, |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 31 | } asn1p_module_flags_e; |
Lev Walkin | f59d075 | 2004-08-18 04:59:12 +0000 | [diff] [blame] | 32 | #define MSF_MASK_INSTRUCTIONS 0x0f |
| 33 | #define MSF_MASK_TAGS 0xf0 |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 34 | |
| 35 | /* |
| 36 | * === EXAMPLE === |
| 37 | * MySyntax DEFINITIONS AUTOMATIC TAGS ::= |
| 38 | * BEGIN |
| 39 | * ... |
| 40 | * END |
| 41 | * === EOF === |
| 42 | */ |
| 43 | typedef struct asn1p_module_s { |
| 44 | |
| 45 | /* |
Lev Walkin | c0e03b9 | 2017-08-22 01:48:23 -0700 | [diff] [blame] | 46 | * Human-readable module reference. |
| 47 | */ |
| 48 | char *ModuleName; /* Must be the first field */ |
| 49 | |
| 50 | /* |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 51 | * Name of the source file. |
| 52 | */ |
| 53 | char *source_file_name; |
| 54 | |
| 55 | /* |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 56 | * Unique module identifier, OID. |
| 57 | */ |
| 58 | asn1p_oid_t *module_oid; /* Optional OID of the module */ |
| 59 | |
| 60 | /* |
| 61 | * Module flags. |
| 62 | */ |
| 63 | asn1p_module_flags_e module_flags; /* AUTOMATIC TAGS? */ |
| 64 | |
| 65 | /* |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 66 | * List of everything that this module EXPORTS. |
| 67 | */ |
| 68 | TQ_HEAD(struct asn1p_xports_s) exports; |
| 69 | |
| 70 | /* |
Lev Walkin | 866bd7f | 2006-09-14 10:35:20 +0000 | [diff] [blame] | 71 | * List of everything that this module IMPORTS. |
| 72 | */ |
| 73 | TQ_HEAD(struct asn1p_xports_s) imports; |
| 74 | |
| 75 | /* |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 76 | * List of everything that this module defines itself. |
| 77 | */ |
| 78 | TQ_HEAD(struct asn1p_expr_s) members; |
| 79 | |
| 80 | /* |
| 81 | * Next module in the list. |
| 82 | */ |
| 83 | TQ_ENTRY(struct asn1p_module_s) |
| 84 | mod_next; |
| 85 | |
Lev Walkin | a9532f4 | 2006-09-17 04:52:50 +0000 | [diff] [blame] | 86 | /* All modules */ |
| 87 | asn1p_t *asn1p; |
| 88 | |
Lev Walkin | 4649987 | 2006-03-06 13:05:34 +0000 | [diff] [blame] | 89 | /* |
| 90 | * Internally useful properties. |
| 91 | */ |
| 92 | enum { |
| 93 | MT_STANDARD_MODULE = 0x01, /* Module came from standard-modules */ |
| 94 | } _tags; |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 95 | } asn1p_module_t; |
| 96 | |
| 97 | /* |
| 98 | * Constructor and destructor. |
| 99 | */ |
| 100 | asn1p_module_t *asn1p_module_new(void); |
| 101 | void asn1p_module_free(asn1p_module_t *mod); |
| 102 | |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 103 | #endif /* ASN1_PARSER_MODULE_H */ |