blob: 908f35f0335c17fadfb5d31d8e4308738a197460 [file] [log] [blame]
Lev Walkinf15320b2004-06-03 03:38:44 +00001/*
2 * CLASS-related stuff.
3 */
4#ifndef ASN1_PARSER_CLASS_H
5#define ASN1_PARSER_CLASS_H
6
Lev Walkind370e9f2006-03-16 10:03:35 +00007struct asn1p_expr_s; /* Forward declaration */
8
9typedef struct asn1p_ioc_row_s {
10 struct asn1p_ioc_cell_s {
11 struct asn1p_expr_s *field; /* may never be NULL */
12 struct asn1p_expr_s *value; /* may be left uninitialized */
Bi-Ruei, Chiu80fd3062017-05-07 21:00:51 +080013 int new_ref;
Lev Walkind370e9f2006-03-16 10:03:35 +000014 } *column;
Lev Walkin62d95d22017-08-06 23:41:11 -070015 size_t columns;
Lev Walkind370e9f2006-03-16 10:03:35 +000016} asn1p_ioc_row_t;
17
18asn1p_ioc_row_t *asn1p_ioc_row_new(struct asn1p_expr_s *oclass);
Lev Walkin4dcf8362017-08-07 20:10:05 -070019size_t asn1p_ioc_row_max_identifier_length(asn1p_ioc_row_t *);
Lev Walkind370e9f2006-03-16 10:03:35 +000020void asn1p_ioc_row_delete(asn1p_ioc_row_t *);
Lev Walkinea6635b2017-08-06 23:23:04 -070021
Lev Walkin4dcf8362017-08-07 20:10:05 -070022typedef struct asn1p_ioc_table_s {
23 asn1p_ioc_row_t **row;
24 size_t rows;
Lev Walkinbc407262017-08-23 10:03:22 -070025 int extensible; /* 0 if non-extensible (sealed). Otherwise, extensible. */
Lev Walkin4dcf8362017-08-07 20:10:05 -070026} asn1p_ioc_table_t;
27
28asn1p_ioc_table_t *asn1p_ioc_table_new(void);
29void asn1p_ioc_table_add(asn1p_ioc_table_t *, asn1p_ioc_row_t *row);
30size_t asn1p_ioc_table_max_identifier_length(asn1p_ioc_table_t *);
31void asn1p_ioc_table_free(asn1p_ioc_table_t *);
32
Lev Walkinea6635b2017-08-06 23:23:04 -070033/*
34 * Match is similar to a comparison,
35 * but -1 means error and 1 means not equal. 0 is OK
36 */
37int asn1p_ioc_row_match(const asn1p_ioc_row_t *, const asn1p_ioc_row_t *);
38
Lev Walkind370e9f2006-03-16 10:03:35 +000039struct asn1p_ioc_cell_s *asn1p_ioc_row_cell_fetch(asn1p_ioc_row_t *,
40 const char *fieldname);
41
Lev Walkinf15320b2004-06-03 03:38:44 +000042/*
43 * WITH SYNTAX free-form chunks.
44 */
45typedef struct asn1p_wsyntx_chunk_s {
Lev Walkin9d542d22006-03-14 16:31:37 +000046 enum {
47 WC_LITERAL,
Lev Walkin57074f12006-03-16 05:11:14 +000048 WC_WHITESPACE,
Lev Walkind370e9f2006-03-16 10:03:35 +000049 WC_FIELD,
Lev Walkin9d542d22006-03-14 16:31:37 +000050 WC_OPTIONALGROUP
51 } type;
Lev Walkinf15320b2004-06-03 03:38:44 +000052 /*
Lev Walkin57074f12006-03-16 05:11:14 +000053 * WC_LITERAL -> {token}
54 * WC_WHITESPACE -> {token}
Lev Walkind370e9f2006-03-16 10:03:35 +000055 * WC_FIELD -> {token}
Lev Walkin9d542d22006-03-14 16:31:37 +000056 * WC_OPTIONALGROUP -> {syntax}
Lev Walkinf15320b2004-06-03 03:38:44 +000057 */
Lev Walkin9d542d22006-03-14 16:31:37 +000058 union {
Lev Walkind370e9f2006-03-16 10:03:35 +000059 char *token;
Lev Walkin9d542d22006-03-14 16:31:37 +000060 struct asn1p_wsyntx_s *syntax;
61 } content;
Lev Walkinf15320b2004-06-03 03:38:44 +000062
63 TQ_ENTRY(struct asn1p_wsyntx_chunk_s) next;
64} asn1p_wsyntx_chunk_t;
65
66typedef struct asn1p_wsyntx_s {
67
Bi-Ruei, Chiu80fd3062017-05-07 21:00:51 +080068 struct asn1p_wsyntx_chunk_s *parent;
69
Lev Walkinf15320b2004-06-03 03:38:44 +000070 TQ_HEAD(struct asn1p_wsyntx_chunk_s) chunks;
71
72} asn1p_wsyntx_t;
73
74
75/*
76 * Constructor, destructor and cloning function.
77 */
78asn1p_wsyntx_chunk_t *asn1p_wsyntx_chunk_new(void);
79void asn1p_wsyntx_chunk_free(asn1p_wsyntx_chunk_t *);
80asn1p_wsyntx_chunk_t *asn1p_wsyntx_chunk_clone(asn1p_wsyntx_chunk_t *);
81
82asn1p_wsyntx_t *asn1p_wsyntx_new(void);
83void asn1p_wsyntx_free(asn1p_wsyntx_t *);
84asn1p_wsyntx_t *asn1p_wsyntx_clone(asn1p_wsyntx_t *);
85
86/*
87 * RETURN VALUES:
88 * 0: Component has been added
89 * -1: Failure to add component (refer to errno)
90 */
Lev Walkinc46b7cb2006-08-18 02:27:55 +000091asn1p_wsyntx_chunk_t *asn1p_wsyntx_chunk_fromstring(char *token, int _copy);
Lev Walkin9d542d22006-03-14 16:31:37 +000092asn1p_wsyntx_chunk_t *asn1p_wsyntx_chunk_fromsyntax(asn1p_wsyntx_t *syntax);
Lev Walkinf15320b2004-06-03 03:38:44 +000093
94
95#endif /* ASN1_PARSER_CLASS_H */