vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This is a parser of the ASN.1 grammar. |
| 3 | */ |
| 4 | #ifndef ASN1PARSER_H |
| 5 | #define ASN1PARSER_H |
| 6 | |
| 7 | #ifdef HAVE_CONFIG_H |
| 8 | #include "config.h" |
| 9 | #endif /* HAVE_CONFIG_H */ |
| 10 | |
| 11 | #ifdef HAVE_SYS_TYPES_H |
| 12 | #include <sys/types.h> |
| 13 | #endif /* HAVE_SYS_TYPES_H */ |
| 14 | #ifdef HAVE_INTTYPES_H |
| 15 | #include <inttypes.h> /* POSIX 1003.1-2001, C99 */ |
| 16 | #else /* HAVE_INTTYPES_H */ |
| 17 | #ifdef HAVE_STDINT_H |
| 18 | #include <stdint.h> /* SUSv2+ */ |
| 19 | #endif /* HAVE_STDINT_H */ |
| 20 | #endif /* HAVE_INTTYPES_H */ |
| 21 | |
| 22 | /* |
| 23 | * Basic integer type used in numerous places. |
| 24 | * ASN.1 does not define any limits on this number, so it must be sufficiently |
| 25 | * large to accomodate typical inputs. It does not have to be a dynamically |
| 26 | * allocated type with potentially unlimited width: consider the width of |
| 27 | * an integer defined here as one of the "compiler limitations". |
| 28 | * NOTE: this is NOT a type for ASN.1 "INTEGER" type representation, this |
| 29 | * type is used by the compiler itself to handle large integer values |
| 30 | * specified inside ASN.1 grammar. |
| 31 | */ |
vlm | ec6acd4 | 2004-09-29 13:18:09 +0000 | [diff] [blame] | 32 | typedef intmax_t asn1c_integer_t; |
vlm | 26759d7 | 2004-09-24 20:54:08 +0000 | [diff] [blame] | 33 | #ifdef PRIdMAX |
| 34 | #define PRIdASN PRIdMAX |
| 35 | #define PRIuASN PRIuMAX |
| 36 | #else |
| 37 | #define PRIdASN "lld" /* Or j? */ |
| 38 | #define PRIuASN "llu" /* Or j? */ |
| 39 | #endif |
vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 40 | |
vlm | 8a09e0f | 2005-02-25 14:20:30 +0000 | [diff] [blame] | 41 | #include "asn1p_list.h" |
| 42 | #include "asn1p_oid.h" /* Object identifiers (OIDs) */ |
| 43 | #include "asn1p_ref.h" /* References to custom types */ |
| 44 | #include "asn1p_value.h" /* Value definition */ |
vlm | 0c6d381 | 2006-03-21 03:40:38 +0000 | [diff] [blame] | 45 | #include "asn1p_param.h" /* Parameterization */ |
vlm | 8a09e0f | 2005-02-25 14:20:30 +0000 | [diff] [blame] | 46 | #include "asn1p_constr.h" /* Type Constraints */ |
| 47 | #include "asn1p_xports.h" /* IMports/EXports */ |
| 48 | #include "asn1p_module.h" /* ASN.1 definition module */ |
| 49 | #include "asn1p_class.h" /* CLASS-related stuff */ |
| 50 | #include "asn1p_expr.h" /* A single ASN.1 expression */ |
vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 51 | |
| 52 | /* |
| 53 | * Parser flags. |
| 54 | */ |
| 55 | enum asn1p_flags { |
| 56 | A1P_NOFLAGS, |
| 57 | /* |
| 58 | * Enable verbose debugging output from lexer. |
| 59 | */ |
vlm | 1ac75e7 | 2005-11-26 11:21:55 +0000 | [diff] [blame] | 60 | A1P_LEXER_DEBUG = 0x0001 |
vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 61 | }; |
| 62 | |
| 63 | /* |
| 64 | * Perform low-level parsing of ASN.1 module[s] |
| 65 | * and return a list of module trees. |
| 66 | */ |
| 67 | asn1p_t *asn1p_parse_file(const char *filename, |
| 68 | enum asn1p_flags); |
| 69 | asn1p_t *asn1p_parse_buffer(const char *buffer, int size /* = -1 */, |
| 70 | enum asn1p_flags); |
| 71 | |
vlm | a6a84d7 | 2006-03-16 10:03:35 +0000 | [diff] [blame] | 72 | int asn1p_atoi(const char *ptr, asn1c_integer_t *r_value); |
| 73 | |
vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 74 | #endif /* ASN1PARSER_H */ |