blob: e83b747ff1a2f707d3904aae5d57f61bc1c48698 [file] [log] [blame]
Lev Walkinf15320b2004-06-03 03:38:44 +00001/*
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 */
Lev Walkind21c5052004-09-29 13:18:09 +000032typedef intmax_t asn1c_integer_t;
Lev Walkinf9a2c3e2004-09-24 20:54:08 +000033#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
Lev Walkinf15320b2004-06-03 03:38:44 +000040
Lev Walkin4efbfb72005-02-25 14:20:30 +000041#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 */
Lev Walkina00d6b32006-03-21 03:40:38 +000045#include "asn1p_param.h" /* Parameterization */
Lev Walkin4efbfb72005-02-25 14:20:30 +000046#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 */
Lev Walkinf15320b2004-06-03 03:38:44 +000051
52/*
53 * Parser flags.
54 */
55enum asn1p_flags {
56 A1P_NOFLAGS,
57 /*
58 * Enable verbose debugging output from lexer.
59 */
Lev Walkin70853052005-11-26 11:21:55 +000060 A1P_LEXER_DEBUG = 0x0001
Lev Walkinf15320b2004-06-03 03:38:44 +000061};
62
63/*
64 * Perform low-level parsing of ASN.1 module[s]
65 * and return a list of module trees.
66 */
67asn1p_t *asn1p_parse_file(const char *filename,
68 enum asn1p_flags);
69asn1p_t *asn1p_parse_buffer(const char *buffer, int size /* = -1 */,
70 enum asn1p_flags);
71
Lev Walkind370e9f2006-03-16 10:03:35 +000072int asn1p_atoi(const char *ptr, asn1c_integer_t *r_value);
73
Lev Walkinf15320b2004-06-03 03:38:44 +000074#endif /* ASN1PARSER_H */