diff options
author | Lev Walkin <vlm@lionet.info> | 2006-03-16 10:03:35 +0000 |
---|---|---|
committer | Lev Walkin <vlm@lionet.info> | 2006-03-16 10:03:35 +0000 |
commit | d370e9f57ecc00836b18bee44af026421bd9d63a (patch) | |
tree | aa0270b48a6b915337d34cb1664eac0ab017d5a0 /libasn1print | |
parent | 57074f10d3e9b089582dde25e0d3ae33be913302 (diff) |
parsing WITH SYNTAX clauses
Diffstat (limited to 'libasn1print')
-rw-r--r-- | libasn1print/asn1print.c | 43 | ||||
-rw-r--r-- | libasn1print/asn1print.h | 7 |
2 files changed, 42 insertions, 8 deletions
diff --git a/libasn1print/asn1print.c b/libasn1print/asn1print.c index 865d90b1..ced31db3 100644 --- a/libasn1print/asn1print.c +++ b/libasn1print/asn1print.c @@ -106,7 +106,7 @@ asn1print_module(asn1p_t *asn, asn1p_module_t *mod, enum asn1print_flags flags) TQ_FOR(tc, &(mod->members), next) { asn1print_expr(asn, mod, tc, flags, 0); - if(flags & APF_DEBUG_CONSTRAINTS) + if(flags & APF_PRINT_CONSTRAINTS) printf("\n"); else printf("\n\n"); @@ -416,11 +416,9 @@ asn1print_with_syntax(asn1p_wsyntx_t *wx, enum asn1print_flags flags) { switch(wc->type) { case WC_LITERAL: case WC_WHITESPACE: + case WC_FIELD: printf("%s", wc->content.token); break; - case WC_REFERENCE: - asn1print_ref(wc->content.ref, flags); - break; case WC_OPTIONALGROUP: printf("["); asn1print_with_syntax(wc->content.syntax,flags); @@ -690,7 +688,7 @@ asn1print_expr(asn1p_t *asn, asn1p_module_t *mod, asn1p_expr_t *tc, enum asn1pri /* * The following section exists entirely for debugging. */ - if(flags & APF_DEBUG_CONSTRAINTS + if(flags & APF_PRINT_CONSTRAINTS && tc->expr_type != A1TC_EXTENSIBLE) { asn1p_expr_t *top_parent; @@ -713,6 +711,41 @@ asn1print_expr(asn1p_t *asn, asn1p_module_t *mod, asn1p_expr_t *tc, enum asn1pri printf("\n"); } + if(flags & APF_PRINT_CLASS_MATRIX + && tc->expr_type == A1TC_CLASSDEF) do { + int r, col, maxidlen; + if(tc->object_class_matrix.rows == 0) { + printf("\n-- Class matrix is empty"); + break; + } + printf("\n-- Class matrix has %d entr%s:\n", + tc->object_class_matrix.rows, + tc->object_class_matrix.rows==1 ? "y" : "ies"); + maxidlen = tc->object_class_matrix.max_identifier_length; + for(r = -1; r < tc->object_class_matrix.rows; r++) { + struct asn1p_ioc_row_s *row; + row = tc->object_class_matrix.row[r<0?0:r]; + if(r < 0) printf("-- %s", r > 9 ? " " : ""); + else printf("-- [%*d]", r > 9 ? 2 : 1, r+1); + for(col = 0; col < row->columns; col++) { + struct asn1p_ioc_cell_s *cell; + cell = &row->column[col]; + if(r < 0) { + printf("[%*s]", maxidlen, + cell->field->Identifier); + continue; + } + if(!cell->value) { + printf(" %*s ", maxidlen, "<no entry>"); + continue; + } + printf(" %*s ", maxidlen, + cell->value->Identifier); + } + printf("\n"); + } + } while(0); + return 0; } diff --git a/libasn1print/asn1print.h b/libasn1print/asn1print.h index 336ba1eb..c24fa0cb 100644 --- a/libasn1print/asn1print.h +++ b/libasn1print/asn1print.h @@ -3,10 +3,11 @@ enum asn1print_flags { APF_NOFLAGS, - APF_LINE_COMMENTS = 0x01, /* Include line comments */ - APF_DEBUG_CONSTRAINTS = 0x02, /* Explain constraints */ + APF_NOINDENT = 0x01, /* Disable indentation */ + APF_LINE_COMMENTS = 0x02, /* Include line comments */ APF_PRINT_XML_DTD = 0x04, /* Generate XML DTD */ - APF_NOINDENT = 0x08, /* Disable indentation */ + APF_PRINT_CONSTRAINTS = 0x08, /* Explain constraints */ + APF_PRINT_CLASS_MATRIX = 0x10, /* Dump class matrix */ }; /* |