aboutsummaryrefslogtreecommitdiffstats
path: root/libasn1parser/asn1p_class.c
diff options
context:
space:
mode:
Diffstat (limited to 'libasn1parser/asn1p_class.c')
-rw-r--r--libasn1parser/asn1p_class.c81
1 files changed, 57 insertions, 24 deletions
diff --git a/libasn1parser/asn1p_class.c b/libasn1parser/asn1p_class.c
index c9065f66..585ec93c 100644
--- a/libasn1parser/asn1p_class.c
+++ b/libasn1parser/asn1p_class.c
@@ -6,6 +6,61 @@
#include "asn1parser.h"
+asn1p_ioc_row_t *
+asn1p_ioc_row_new(asn1p_expr_t *oclass) {
+ asn1p_ioc_row_t *row;
+ asn1p_expr_t *field;
+ int columns = 0;
+
+ assert(oclass->expr_type == A1TC_CLASSDEF);
+
+ row = calloc(1, sizeof *row);
+ if(!row) return NULL;
+
+ TQ_FOR(field, &oclass->members, next)
+ columns++;
+
+ row->column = calloc(columns, sizeof *row->column);
+ if(!row->column) {
+ free(row);
+ return NULL;
+ }
+ row->columns = columns;
+
+ columns = 0;
+ TQ_FOR(field, &oclass->members, next) {
+ int fieldIdLen = strlen(field->Identifier);
+ if(fieldIdLen > row->max_identifier_length)
+ row->max_identifier_length = fieldIdLen;
+ row->column[columns].field = field;
+ row->column[columns].value = NULL;
+ columns++;
+ }
+
+ return row;
+}
+
+void
+asn1p_ioc_row_delete(asn1p_ioc_row_t *row) {
+ if(row) {
+ if(row->column) {
+ free(row->column);
+ }
+ free(row);
+ }
+}
+
+struct asn1p_ioc_cell_s *
+asn1p_ioc_row_cell_fetch(asn1p_ioc_row_t *row, const char *fieldname) {
+ int i;
+ for(i = 0; i < row->columns; i++) {
+ if(strcmp(row->column[i].field->Identifier, fieldname) == 0)
+ return &row->column[i];
+ }
+ errno = ESRCH;
+ return NULL;
+}
+
asn1p_wsyntx_chunk_t *
asn1p_wsyntx_chunk_new() {
asn1p_wsyntx_chunk_t *wc;
@@ -21,8 +76,8 @@ asn1p_wsyntx_chunk_free(asn1p_wsyntx_chunk_t *wc) {
switch(wc->type) {
case WC_LITERAL:
case WC_WHITESPACE:
+ case WC_FIELD:
free(wc->content.token); break;
- case WC_REFERENCE: asn1p_ref_free(wc->content.ref); break;
case WC_OPTIONALGROUP:
asn1p_wsyntx_free(wc->content.syntax);
break;
@@ -41,12 +96,10 @@ asn1p_wsyntx_chunk_clone(asn1p_wsyntx_chunk_t *wc) {
switch(wc->type) {
case WC_LITERAL:
case WC_WHITESPACE:
+ case WC_FIELD:
nc->content.token = malloc(strlen(wc->content.token)+1);
strcpy(nc->content.token, wc->content.token);
break;
- case WC_REFERENCE:
- nc->content.ref = asn1p_ref_clone(wc->content.ref);
- break;
case WC_OPTIONALGROUP:
nc->content.syntax = asn1p_wsyntx_clone(wc->content.syntax);
break;
@@ -101,26 +154,6 @@ asn1p_wsyntx_clone(asn1p_wsyntx_t *wx) {
}
asn1p_wsyntx_chunk_t *
-asn1p_wsyntx_chunk_fromref(asn1p_ref_t *ref, int do_copy) {
- asn1p_wsyntx_chunk_t *wc;
-
- if(do_copy) {
- static asn1p_wsyntx_chunk_t tmp;
- tmp.type = WC_REFERENCE;
- tmp.content.ref = ref;
- wc = asn1p_wsyntx_chunk_clone(&tmp);
- } else {
- wc = asn1p_wsyntx_chunk_new();
- if(wc) {
- wc->type = WC_REFERENCE;
- wc->content.ref = ref;
- }
- }
-
- return wc;
-}
-
-asn1p_wsyntx_chunk_t *
asn1p_wsyntx_chunk_frombuf(char *buf, int len, int do_copy) {
asn1p_wsyntx_chunk_t *wc;