blob: 3fd27ef5d09ba5781525dca33aa6066fd5f18d1c [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 Walkin8d35c462005-02-25 13:32:12 +00007#include "asn1p_ref.h"
Lev Walkinf15320b2004-06-03 03:38:44 +00008
Lev Walkind370e9f2006-03-16 10:03:35 +00009struct asn1p_expr_s; /* Forward declaration */
10
11typedef struct asn1p_ioc_row_s {
12 struct asn1p_ioc_cell_s {
13 struct asn1p_expr_s *field; /* may never be NULL */
14 struct asn1p_expr_s *value; /* may be left uninitialized */
Bi-Ruei, Chiu80fd3062017-05-07 21:00:51 +080015 int new_ref;
Lev Walkind370e9f2006-03-16 10:03:35 +000016 } *column;
Lev Walkin62d95d22017-08-06 23:41:11 -070017 size_t columns;
18 size_t max_identifier_length;
Lev Walkind370e9f2006-03-16 10:03:35 +000019} asn1p_ioc_row_t;
20
21asn1p_ioc_row_t *asn1p_ioc_row_new(struct asn1p_expr_s *oclass);
22void asn1p_ioc_row_delete(asn1p_ioc_row_t *);
Lev Walkinea6635b2017-08-06 23:23:04 -070023
24/*
25 * Match is similar to a comparison,
26 * but -1 means error and 1 means not equal. 0 is OK
27 */
28int asn1p_ioc_row_match(const asn1p_ioc_row_t *, const asn1p_ioc_row_t *);
29
Lev Walkind370e9f2006-03-16 10:03:35 +000030struct asn1p_ioc_cell_s *asn1p_ioc_row_cell_fetch(asn1p_ioc_row_t *,
31 const char *fieldname);
32
Lev Walkinf15320b2004-06-03 03:38:44 +000033/*
34 * WITH SYNTAX free-form chunks.
35 */
36typedef struct asn1p_wsyntx_chunk_s {
Lev Walkin9d542d22006-03-14 16:31:37 +000037 enum {
38 WC_LITERAL,
Lev Walkin57074f12006-03-16 05:11:14 +000039 WC_WHITESPACE,
Lev Walkind370e9f2006-03-16 10:03:35 +000040 WC_FIELD,
Lev Walkin9d542d22006-03-14 16:31:37 +000041 WC_OPTIONALGROUP
42 } type;
Lev Walkinf15320b2004-06-03 03:38:44 +000043 /*
Lev Walkin57074f12006-03-16 05:11:14 +000044 * WC_LITERAL -> {token}
45 * WC_WHITESPACE -> {token}
Lev Walkind370e9f2006-03-16 10:03:35 +000046 * WC_FIELD -> {token}
Lev Walkin9d542d22006-03-14 16:31:37 +000047 * WC_OPTIONALGROUP -> {syntax}
Lev Walkinf15320b2004-06-03 03:38:44 +000048 */
Lev Walkin9d542d22006-03-14 16:31:37 +000049 union {
Lev Walkind370e9f2006-03-16 10:03:35 +000050 char *token;
Lev Walkin9d542d22006-03-14 16:31:37 +000051 struct asn1p_wsyntx_s *syntax;
52 } content;
Lev Walkinf15320b2004-06-03 03:38:44 +000053
54 TQ_ENTRY(struct asn1p_wsyntx_chunk_s) next;
55} asn1p_wsyntx_chunk_t;
56
57typedef struct asn1p_wsyntx_s {
58
Bi-Ruei, Chiu80fd3062017-05-07 21:00:51 +080059 struct asn1p_wsyntx_chunk_s *parent;
60
Lev Walkinf15320b2004-06-03 03:38:44 +000061 TQ_HEAD(struct asn1p_wsyntx_chunk_s) chunks;
62
63} asn1p_wsyntx_t;
64
65
66/*
67 * Constructor, destructor and cloning function.
68 */
69asn1p_wsyntx_chunk_t *asn1p_wsyntx_chunk_new(void);
70void asn1p_wsyntx_chunk_free(asn1p_wsyntx_chunk_t *);
71asn1p_wsyntx_chunk_t *asn1p_wsyntx_chunk_clone(asn1p_wsyntx_chunk_t *);
72
73asn1p_wsyntx_t *asn1p_wsyntx_new(void);
74void asn1p_wsyntx_free(asn1p_wsyntx_t *);
75asn1p_wsyntx_t *asn1p_wsyntx_clone(asn1p_wsyntx_t *);
76
77/*
78 * RETURN VALUES:
79 * 0: Component has been added
80 * -1: Failure to add component (refer to errno)
81 */
Lev Walkinc46b7cb2006-08-18 02:27:55 +000082asn1p_wsyntx_chunk_t *asn1p_wsyntx_chunk_fromstring(char *token, int _copy);
Lev Walkin9d542d22006-03-14 16:31:37 +000083asn1p_wsyntx_chunk_t *asn1p_wsyntx_chunk_fromsyntax(asn1p_wsyntx_t *syntax);
Lev Walkinf15320b2004-06-03 03:38:44 +000084
85
86#endif /* ASN1_PARSER_CLASS_H */