blob: 126057d66ffa46ec2a0f750ce59c559846652f23 [file] [log] [blame]
vlmfa67ddc2004-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 */
32typedef intmax_t asn1_integer_t;
vlm26759d72004-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
vlmfa67ddc2004-06-03 03:38:44 +000040
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 */
45#include <asn1p_param.h> /* Parametrization */
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 */
51
52/*
53 * Parser flags.
54 */
55enum asn1p_flags {
56 A1P_NOFLAGS,
57 /*
58 * Enable verbose debugging output from lexer.
59 */
60 A1P_LEXER_DEBUG = 0x0001,
61 /*
62 * Embedded types restricted to ASN.1:1988
63 */
64 A1P_TYPES_RESTRICT_TO_1988 = 0x0010,
65 /*
66 * Embedded constructs (concepts) restricted to ASN.1:1990
67 */
68 A1P_CONSTRUCTS_RESTRICT_TO_1990 = 0x0020,
69};
70
71/*
72 * Perform low-level parsing of ASN.1 module[s]
73 * and return a list of module trees.
74 */
75asn1p_t *asn1p_parse_file(const char *filename,
76 enum asn1p_flags);
77asn1p_t *asn1p_parse_buffer(const char *buffer, int size /* = -1 */,
78 enum asn1p_flags);
79
80#endif /* ASN1PARSER_H */