Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1 | /* |
| 2 | * CLASS-related stuff. |
| 3 | */ |
| 4 | #ifndef ASN1_PARSER_CLASS_H |
| 5 | #define ASN1_PARSER_CLASS_H |
| 6 | |
Lev Walkin | d370e9f | 2006-03-16 10:03:35 +0000 | [diff] [blame] | 7 | struct asn1p_expr_s; /* Forward declaration */ |
| 8 | |
| 9 | typedef 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, Chiu | 80fd306 | 2017-05-07 21:00:51 +0800 | [diff] [blame] | 13 | int new_ref; |
Lev Walkin | d370e9f | 2006-03-16 10:03:35 +0000 | [diff] [blame] | 14 | } *column; |
Lev Walkin | 62d95d2 | 2017-08-06 23:41:11 -0700 | [diff] [blame] | 15 | size_t columns; |
Lev Walkin | d370e9f | 2006-03-16 10:03:35 +0000 | [diff] [blame] | 16 | } asn1p_ioc_row_t; |
| 17 | |
| 18 | asn1p_ioc_row_t *asn1p_ioc_row_new(struct asn1p_expr_s *oclass); |
Bi-Ruei, Chiu | 5bdb555 | 2017-10-23 15:20:55 +0800 | [diff] [blame] | 19 | asn1p_ioc_row_t *asn1p_ioc_row_clone(asn1p_ioc_row_t *src, int base_idx); |
Lev Walkin | 4dcf836 | 2017-08-07 20:10:05 -0700 | [diff] [blame] | 20 | size_t asn1p_ioc_row_max_identifier_length(asn1p_ioc_row_t *); |
Lev Walkin | d370e9f | 2006-03-16 10:03:35 +0000 | [diff] [blame] | 21 | void asn1p_ioc_row_delete(asn1p_ioc_row_t *); |
Lev Walkin | ea6635b | 2017-08-06 23:23:04 -0700 | [diff] [blame] | 22 | |
Lev Walkin | 4dcf836 | 2017-08-07 20:10:05 -0700 | [diff] [blame] | 23 | typedef struct asn1p_ioc_table_s { |
| 24 | asn1p_ioc_row_t **row; |
| 25 | size_t rows; |
Lev Walkin | bc40726 | 2017-08-23 10:03:22 -0700 | [diff] [blame] | 26 | int extensible; /* 0 if non-extensible (sealed). Otherwise, extensible. */ |
Lev Walkin | 4dcf836 | 2017-08-07 20:10:05 -0700 | [diff] [blame] | 27 | } asn1p_ioc_table_t; |
| 28 | |
| 29 | asn1p_ioc_table_t *asn1p_ioc_table_new(void); |
| 30 | void asn1p_ioc_table_add(asn1p_ioc_table_t *, asn1p_ioc_row_t *row); |
Bi-Ruei, Chiu | 50934ba | 2017-09-11 08:50:59 +0800 | [diff] [blame] | 31 | void asn1p_ioc_table_append(asn1p_ioc_table_t *it, asn1p_ioc_table_t *src); |
Lev Walkin | 4dcf836 | 2017-08-07 20:10:05 -0700 | [diff] [blame] | 32 | size_t asn1p_ioc_table_max_identifier_length(asn1p_ioc_table_t *); |
| 33 | void asn1p_ioc_table_free(asn1p_ioc_table_t *); |
| 34 | |
Lev Walkin | ea6635b | 2017-08-06 23:23:04 -0700 | [diff] [blame] | 35 | /* |
| 36 | * Match is similar to a comparison, |
| 37 | * but -1 means error and 1 means not equal. 0 is OK |
| 38 | */ |
| 39 | int asn1p_ioc_row_match(const asn1p_ioc_row_t *, const asn1p_ioc_row_t *); |
| 40 | |
Lev Walkin | d370e9f | 2006-03-16 10:03:35 +0000 | [diff] [blame] | 41 | struct asn1p_ioc_cell_s *asn1p_ioc_row_cell_fetch(asn1p_ioc_row_t *, |
| 42 | const char *fieldname); |
| 43 | |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 44 | /* |
| 45 | * WITH SYNTAX free-form chunks. |
| 46 | */ |
| 47 | typedef struct asn1p_wsyntx_chunk_s { |
Lev Walkin | 9d542d2 | 2006-03-14 16:31:37 +0000 | [diff] [blame] | 48 | enum { |
| 49 | WC_LITERAL, |
Lev Walkin | 57074f1 | 2006-03-16 05:11:14 +0000 | [diff] [blame] | 50 | WC_WHITESPACE, |
Lev Walkin | d370e9f | 2006-03-16 10:03:35 +0000 | [diff] [blame] | 51 | WC_FIELD, |
Lev Walkin | 9d542d2 | 2006-03-14 16:31:37 +0000 | [diff] [blame] | 52 | WC_OPTIONALGROUP |
| 53 | } type; |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 54 | /* |
Lev Walkin | 57074f1 | 2006-03-16 05:11:14 +0000 | [diff] [blame] | 55 | * WC_LITERAL -> {token} |
| 56 | * WC_WHITESPACE -> {token} |
Lev Walkin | d370e9f | 2006-03-16 10:03:35 +0000 | [diff] [blame] | 57 | * WC_FIELD -> {token} |
Lev Walkin | 9d542d2 | 2006-03-14 16:31:37 +0000 | [diff] [blame] | 58 | * WC_OPTIONALGROUP -> {syntax} |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 59 | */ |
Lev Walkin | 9d542d2 | 2006-03-14 16:31:37 +0000 | [diff] [blame] | 60 | union { |
Lev Walkin | d370e9f | 2006-03-16 10:03:35 +0000 | [diff] [blame] | 61 | char *token; |
Lev Walkin | 9d542d2 | 2006-03-14 16:31:37 +0000 | [diff] [blame] | 62 | struct asn1p_wsyntx_s *syntax; |
| 63 | } content; |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 64 | |
| 65 | TQ_ENTRY(struct asn1p_wsyntx_chunk_s) next; |
| 66 | } asn1p_wsyntx_chunk_t; |
| 67 | |
| 68 | typedef struct asn1p_wsyntx_s { |
| 69 | |
Bi-Ruei, Chiu | 80fd306 | 2017-05-07 21:00:51 +0800 | [diff] [blame] | 70 | struct asn1p_wsyntx_chunk_s *parent; |
| 71 | |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 72 | TQ_HEAD(struct asn1p_wsyntx_chunk_s) chunks; |
| 73 | |
| 74 | } asn1p_wsyntx_t; |
| 75 | |
| 76 | |
| 77 | /* |
| 78 | * Constructor, destructor and cloning function. |
| 79 | */ |
| 80 | asn1p_wsyntx_chunk_t *asn1p_wsyntx_chunk_new(void); |
| 81 | void asn1p_wsyntx_chunk_free(asn1p_wsyntx_chunk_t *); |
| 82 | asn1p_wsyntx_chunk_t *asn1p_wsyntx_chunk_clone(asn1p_wsyntx_chunk_t *); |
| 83 | |
| 84 | asn1p_wsyntx_t *asn1p_wsyntx_new(void); |
| 85 | void asn1p_wsyntx_free(asn1p_wsyntx_t *); |
| 86 | asn1p_wsyntx_t *asn1p_wsyntx_clone(asn1p_wsyntx_t *); |
| 87 | |
| 88 | /* |
| 89 | * RETURN VALUES: |
| 90 | * 0: Component has been added |
| 91 | * -1: Failure to add component (refer to errno) |
| 92 | */ |
Lev Walkin | c46b7cb | 2006-08-18 02:27:55 +0000 | [diff] [blame] | 93 | asn1p_wsyntx_chunk_t *asn1p_wsyntx_chunk_fromstring(char *token, int _copy); |
Lev Walkin | 9d542d2 | 2006-03-14 16:31:37 +0000 | [diff] [blame] | 94 | asn1p_wsyntx_chunk_t *asn1p_wsyntx_chunk_fromsyntax(asn1p_wsyntx_t *syntax); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 95 | |
| 96 | |
| 97 | #endif /* ASN1_PARSER_CLASS_H */ |