7 #include <asn1_buffer.h>
8 #include <asn1_namespace.h>
9 #include <asn1parser.h>
10 #include <asn1fix_export.h>
11 #include <asn1fix_crange.h>
13 #include "asn1print.h"
15 static abuf all_output_;
21 static print_method_e print_method_;
23 #define INDENT(fmt, args...) do { \
24 if(!(flags & APF_NOINDENT)) { \
26 while(tmp_i--) safe_printf(" "); \
28 safe_printf(fmt, ##args); \
31 static int asn1print_module(asn1p_t *asn, asn1p_module_t *mod, enum asn1print_flags flags);
32 static int asn1print_oid(int prior_len, asn1p_oid_t *oid, enum asn1print_flags flags);
33 static int asn1print_ref(const asn1p_ref_t *ref, enum asn1print_flags flags);
34 static int asn1print_tag(const asn1p_expr_t *tc, enum asn1print_flags flags);
35 static int asn1print_params(const asn1p_paramlist_t *pl,enum asn1print_flags flags);
36 static int asn1print_with_syntax(const asn1p_wsyntx_t *wx, enum asn1print_flags flags);
37 static int asn1print_constraint(const asn1p_constraint_t *, enum asn1print_flags);
38 static int asn1print_value(const asn1p_value_t *val, enum asn1print_flags flags);
39 static int asn1print_expr(asn1p_t *asn, asn1p_module_t *mod, asn1p_expr_t *tc, enum asn1print_flags flags, int level);
40 static int asn1print_expr_dtd(asn1p_t *asn, asn1p_module_t *mod, asn1p_expr_t *tc, enum asn1print_flags flags, int level);
42 /* Check printf's error code, to be pedantic. */
43 static int safe_printf(const char *fmt, ...) {
48 switch(print_method_) {
50 ret = vprintf(fmt, ap);
53 ret = abuf_vprintf(&all_output_, fmt, ap);
62 /* Pedantically check fwrite's return value. */
63 static size_t safe_fwrite(const void *ptr, size_t size) {
66 switch(print_method_) {
68 ret = fwrite(ptr, 1, size, stdout);
72 abuf_add_bytes(&all_output_, ptr, size);
81 * Print the contents of the parsed ASN tree.
84 asn1print(asn1p_t *asn, enum asn1print_flags flags) {
93 if(flags & APF_PRINT_XML_DTD)
94 safe_printf("<!-- XML DTD generated by asn1c-" VERSION " -->\n\n");
96 TQ_FOR(mod, &(asn->modules), mod_next) {
97 if(mod->_tags & MT_STANDARD_MODULE)
98 return 0; /* Ignore modules imported from skeletons */
99 if(modno++) safe_printf("\n");
100 asn1print_module(asn, mod, flags);
103 if(flags & APF_PRINT_XML_DTD) {
104 /* Values for BOOLEAN */
105 safe_printf("<!ELEMENT true EMPTY>\n");
106 safe_printf("<!ELEMENT false EMPTY>\n");
113 asn1print_module(asn1p_t *asn, asn1p_module_t *mod, enum asn1print_flags flags) {
116 if(flags & APF_PRINT_XML_DTD)
117 safe_printf("<!-- ASN.1 module\n");
119 safe_printf("%s ", mod->ModuleName);
120 if(mod->module_oid) {
121 asn1print_oid(strlen(mod->ModuleName), mod->module_oid, flags);
125 if(flags & APF_PRINT_XML_DTD) {
126 if(mod->source_file_name
127 && strcmp(mod->source_file_name, "-"))
128 safe_printf("found in %s", mod->source_file_name);
129 safe_printf(" -->\n\n");
131 TQ_FOR(tc, &(mod->members), next) {
132 asn1print_expr_dtd(asn, mod, tc, flags, 0);
138 safe_printf("DEFINITIONS");
140 if(mod->module_flags & MSF_TAG_INSTRUCTIONS)
141 safe_printf(" TAG INSTRUCTIONS");
142 if(mod->module_flags & MSF_XER_INSTRUCTIONS)
143 safe_printf(" XER INSTRUCTIONS");
144 if(mod->module_flags & MSF_EXPLICIT_TAGS)
145 safe_printf(" EXPLICIT TAGS");
146 if(mod->module_flags & MSF_IMPLICIT_TAGS)
147 safe_printf(" IMPLICIT TAGS");
148 if(mod->module_flags & MSF_AUTOMATIC_TAGS)
149 safe_printf(" AUTOMATIC TAGS");
150 if(mod->module_flags & MSF_EXTENSIBILITY_IMPLIED)
151 safe_printf(" EXTENSIBILITY IMPLIED");
153 safe_printf(" ::=\n");
154 safe_printf("BEGIN\n\n");
156 TQ_FOR(tc, &(mod->members), next) {
157 asn1print_expr(asn, mod, tc, flags, 0);
158 if(flags & APF_PRINT_CONSTRAINTS)
164 safe_printf("END\n");
170 asn1print_oid(int prior_len, asn1p_oid_t *oid, enum asn1print_flags flags) {
171 size_t accum = prior_len;
174 (void)flags; /* Unused argument */
177 for(ac = 0; ac < oid->arcs_count; ac++) {
178 const char *arcname = oid->arcs[ac].name;
180 if(accum + strlen(arcname ? arcname : "") > 72) {
184 accum += safe_printf(" ");
188 accum += safe_printf("%s", arcname);
189 if(oid->arcs[ac].number >= 0) {
190 accum += safe_printf("(%s)",
191 asn1p_itoa(oid->arcs[ac].number));
194 accum += safe_printf("%s", asn1p_itoa(oid->arcs[ac].number));
203 asn1print_ref(const asn1p_ref_t *ref, enum asn1print_flags flags) {
205 (void)flags; /* Unused argument */
207 for(size_t cc = 0; cc < ref->comp_count; cc++) {
208 if(cc) safe_printf(".");
209 safe_printf("%s", ref->components[cc].name);
216 asn1print_tag(const asn1p_expr_t *tc, enum asn1print_flags flags) {
217 const struct asn1p_type_tag_s *tag = &tc->tag;
219 (void)flags; /* Unused argument */
221 safe_printf("%s", asn1p_tag2string(tag, 0));
227 asn1print_value(const asn1p_value_t *val, enum asn1print_flags flags) {
239 safe_printf("%f", val->value.v_double);
242 asn1print_expr(val->value.v_type->module->asn1p,
243 val->value.v_type->module,
244 val->value.v_type, flags, 0);
247 safe_printf("%s", asn1p_itoa(val->value.v_integer));
249 case ATV_MIN: safe_printf("MIN"); return 0;
250 case ATV_MAX: safe_printf("MAX"); return 0;
251 case ATV_FALSE: safe_printf("FALSE"); return 0;
252 case ATV_TRUE: safe_printf("TRUE"); return 0;
254 safe_printf("{%d, %d}",
255 (int)(val->value.v_integer >> 4),
256 (int)(val->value.v_integer & 0x0f));
259 safe_printf("{%d, %d, %d, %d}",
260 (int)((val->value.v_integer >> 24) & 0xff),
261 (int)((val->value.v_integer >> 16) & 0xff),
262 (int)((val->value.v_integer >> 8) & 0xff),
263 (int)((val->value.v_integer >> 0) & 0xff)
268 char *p = (char *)val->value.string.buf;
274 safe_printf("%c", *p);
275 safe_printf("%c", *p);
278 safe_printf("%s", p);
284 safe_printf("%s", (char *)val->value.string.buf);
292 bitvector = val->value.binary_vector.bits;
293 bits = val->value.binary_vector.size_in_bits;
297 for(i = 0; i < bits; i++) {
299 uc = bitvector[i>>3];
300 safe_printf("%c", ((uc >> (7-(i%8)))&1)?'1':'0');
304 char hextable[16] = "0123456789ABCDEF";
305 for(i = 0; i < (bits>>3); i++) {
306 safe_printf("%c", hextable[bitvector[i] >> 4]);
307 safe_printf("%c", hextable[bitvector[i] & 0x0f]);
314 return asn1print_ref(val->value.reference, flags);
316 return asn1print_constraint(val->value.constraint, flags);
317 case ATV_CHOICE_IDENTIFIER:
318 safe_printf("%s: ", val->value.choice_identifier.identifier);
319 return asn1print_value(val->value.choice_identifier.value, flags);
322 assert(val->type || !"Unknown");
328 asn1p_constraint_string(const asn1p_constraint_t *ct) {
329 size_t old_len = all_output_.length;
330 print_method_e old_method = print_method_;
331 print_method_ = GLOBAL_BUFFER;
332 asn1print_constraint(ct, APF_NOINDENT);
333 print_method_ = old_method;
334 return &all_output_.buffer[old_len];
338 asn1print_constraint(const asn1p_constraint_t *ct, enum asn1print_flags flags) {
340 int perhaps_subconstraints = 0;
342 if(ct == 0) return 0;
346 asn1print_value(ct->containedSubtype, flags);
347 perhaps_subconstraints = 1;
350 asn1print_value(ct->value, flags);
351 perhaps_subconstraints = 1;
357 asn1print_value(ct->range_start, flags);
359 case ACT_EL_RANGE: safe_printf(".."); break;
360 case ACT_EL_LLRANGE: safe_printf("<.."); break;
361 case ACT_EL_RLRANGE: safe_printf("..<"); break;
362 case ACT_EL_ULRANGE: safe_printf("<..<"); break;
363 default: safe_printf("?..?"); break;
365 asn1print_value(ct->range_stop, flags);
373 case ACT_CT_SIZE: safe_printf("SIZE"); break;
374 case ACT_CT_FROM: safe_printf("FROM"); break;
375 default: safe_printf("??? "); break;
377 assert(ct->el_count != 0);
378 assert(ct->el_count == 1);
379 asn1print_constraint(ct->elements[0], flags);
382 assert(ct->el_count != 0);
383 assert(ct->el_count == 1);
384 safe_printf("WITH COMPONENT");
385 perhaps_subconstraints = 1;
387 case ACT_CT_WCOMPS: {
389 safe_printf("WITH COMPONENTS { ");
390 for(i = 0; i < ct->el_count; i++) {
391 asn1p_constraint_t *cel = ct->elements[i];
392 if(i) safe_printf(", ");
393 asn1print_constraint(cel, flags);
394 switch(cel->presence) {
395 case ACPRES_DEFAULT: break;
396 case ACPRES_PRESENT: safe_printf(" PRESENT"); break;
397 case ACPRES_ABSENT: safe_printf(" ABSENT"); break;
398 case ACPRES_OPTIONAL: safe_printf(" OPTIONAL");break;
405 safe_printf("CONSTRAINED BY ");
406 assert(ct->value->type == ATV_UNPARSED);
407 safe_fwrite(ct->value->value.string.buf, ct->value->value.string.size);
410 safe_printf("CONTAINING ");
411 asn1print_expr(ct->value->value.v_type->module->asn1p,
412 ct->value->value.v_type->module,
413 ct->value->value.v_type,
417 safe_printf("PATTERN ");
418 asn1print_value(ct->value, flags);
420 case ACT_CA_SET: symno++; /* Fall through */
421 case ACT_CA_CRC: symno++; /* Fall through */
422 case ACT_CA_CSV: symno++; /* Fall through */
423 case ACT_CA_UNI: symno++; /* Fall through */
424 case ACT_CA_INT: symno++; /* Fall through */
427 char *symtable[] = { " EXCEPT ", " ^ ", " | ", ",",
430 if(ct->type == ACT_CA_SET) safe_printf("(");
431 for(i = 0; i < ct->el_count; i++) {
432 if(i) safe_printf("%s", symtable[symno]);
433 if(ct->type == ACT_CA_CRC) safe_printf("{");
434 asn1print_constraint(ct->elements[i], flags);
435 if(ct->type == ACT_CA_CRC) safe_printf("}");
436 if(ct->type == ACT_CA_SET && i+1 < ct->el_count)
439 if(ct->type == ACT_CA_SET) safe_printf(")");
443 assert(ct->el_count == 1);
444 safe_printf("ALL EXCEPT");
445 perhaps_subconstraints = 1;
448 assert(ct->type != ACT_INVALID);
452 if(perhaps_subconstraints && ct->el_count) {
454 assert(ct->el_count == 1);
455 asn1print_constraint(ct->elements[0], flags);
462 asn1print_params(const asn1p_paramlist_t *pl, enum asn1print_flags flags) {
466 for(i = 0; i < pl->params_count; i++) {
467 if(i) safe_printf(", ");
468 if(pl->params[i].governor) {
469 asn1print_ref(pl->params[i].governor, flags);
472 safe_printf("%s", pl->params[i].argument);
481 asn1print_with_syntax(const asn1p_wsyntx_t *wx, enum asn1print_flags flags) {
483 const asn1p_wsyntx_chunk_t *wc;
484 TQ_FOR(wc, &(wx->chunks), next) {
489 safe_printf("%s", wc->content.token);
491 case WC_OPTIONALGROUP:
493 asn1print_with_syntax(wc->content.syntax,flags);
504 asn1print_crange_value(const asn1cnst_edge_t *edge, int as_char) {
506 case ARE_MIN: safe_printf("MIN"); break;
507 case ARE_MAX: safe_printf("MAX"); break;
510 safe_printf("\"%c\"", (unsigned char)edge->value);
512 safe_printf("%s", asn1p_itoa(edge->value));
519 asn1print_constraint_explain_type(const char *dbg_name, asn1p_expr_type_e expr_type, asn1p_constraint_t *ct, enum asn1p_constraint_type_e type, enum cpr_flags cpr) {
520 asn1cnst_range_t *range;
521 int as_char = (type==ACT_CT_FROM);
524 range = asn1constraint_compute_constraint_range(dbg_name, expr_type, ct, type, 0, 0, cpr);
525 if(!range) return -1;
527 if(range->incompatible) return 0;
529 if((cpr & CPR_strict_OER_visibility) && range->not_OER_visible) {
530 asn1constraint_range_free(range);
534 if((cpr & CPR_strict_PER_visibility) && range->not_PER_visible) {
535 asn1constraint_range_free(range);
540 case ACT_CT_FROM: safe_printf("(FROM("); break;
541 case ACT_CT_SIZE: safe_printf("(SIZE("); break;
542 default: safe_printf("("); break;
544 for(i = -1; i < range->el_count; i++) {
547 if(range->el_count) continue;
550 r = range->elements[i];
555 asn1print_crange_value(&r->left, as_char);
556 if(r->left.type != r->right.type
557 || r->left.value != r->right.value) {
559 asn1print_crange_value(&r->right, as_char);
562 if(range->extensible)
564 safe_printf(type==ACT_EL_RANGE?")":"))");
566 if(range->empty_constraint)
567 safe_printf(":Empty!");
569 asn1constraint_range_free(range);
574 asn1print_constraint_explain(const char *dbg_name, asn1p_expr_type_e expr_type,
575 asn1p_constraint_t *ct, enum cpr_flags cpr) {
577 asn1print_constraint_explain_type(dbg_name, expr_type, ct, ACT_EL_RANGE, cpr);
579 asn1print_constraint_explain_type(dbg_name, expr_type, ct, ACT_CT_SIZE, cpr);
581 asn1print_constraint_explain_type(dbg_name, expr_type, ct, ACT_CT_FROM, cpr);
587 asn1print_expr(asn1p_t *asn, asn1p_module_t *mod, asn1p_expr_t *tc, enum asn1print_flags flags, int level) {
591 #define HAS_SPACE() \
595 #define ENSURE_SPACE() \
602 #define WANT_SPACE() \
607 if(flags & APF_LINE_COMMENTS && !(flags & APF_NOINDENT))
608 INDENT("-- #line %d\n", tc->_lineno);
610 /* Reconstruct compiler directive information */
611 if((tc->marker.flags & EM_INDIRECT)
612 && (tc->marker.flags & EM_OMITABLE) != EM_OMITABLE) {
613 if((flags & APF_NOINDENT))
614 safe_printf(" --<ASN1C.RepresentAsPointer>-- ");
616 INDENT("--<ASN1C.RepresentAsPointer>--\n");
620 && (!(tc->meta_type == AMT_VALUE && tc->expr_type == A1TC_REFERENCE)
622 INDENT("%s", tc->Identifier);
627 asn1print_params(tc->lhs_params, flags);
630 if(tc->meta_type != AMT_VALUE
631 && tc->meta_type != AMT_VALUESET
632 && tc->expr_type != A1TC_EXTENSIBLE) {
634 if(tc->Identifier && !(flags & APF_NOINDENT))
636 } else if(tc->Identifier) {
643 if(tc->tag.tag_class) {
645 asn1print_tag(tc, flags);
649 switch(tc->expr_type) {
650 case A1TC_EXTENSIBLE:
653 asn1print_value(tc->value, flags);
656 case A1TC_COMPONENTS_OF:
657 SEQ_OF = 1; /* Equivalent to SET OF for printint purposes */
658 safe_printf(" COMPONENTS OF");
665 safe_printf(" CLASS");
668 case A1TC_CLASSFIELD_TFS ... A1TC_CLASSFIELD_OSFS:
669 /* Nothing to print here */
671 case ASN_CONSTR_SET_OF:
672 case ASN_CONSTR_SEQUENCE_OF:
675 if(tc->expr_type == ASN_CONSTR_SET_OF)
678 safe_printf("SEQUENCE");
679 if(tc->constraints) {
681 asn1print_constraint(tc->constraints, flags);
690 char *p = ASN_EXPR_TYPE2STR(tc->expr_type);
692 safe_printf("%s", p?p:"<unknown type!>");
699 * Put the name of the referred type.
703 asn1print_ref(tc->reference, flags);
707 if(tc->meta_type == AMT_VALUESET && level == 0) {
714 * Display the descendants (children) of the current type.
716 if(TQ_FIRST(&(tc->members))
717 || (tc->expr_type & ASN_CONSTR_MASK)
718 || tc->meta_type == AMT_OBJECT
719 || tc->meta_type == AMT_OBJECTCLASS
720 || tc->meta_type == AMT_OBJECTFIELD
722 asn1p_expr_t *se; /* SubExpression */
723 int put_braces = (!SEQ_OF) /* Don't need 'em, if SET OF... */
724 && (tc->meta_type != AMT_OBJECTFIELD);
727 if(flags & APF_NOINDENT) {
729 if(!TQ_FIRST(&tc->members))
733 if(TQ_FIRST(&tc->members))
740 TQ_FOR(se, &(tc->members), next) {
742 * Print the expression as it were a stand-alone type.
744 asn1print_expr(asn, mod, se, flags, level + 1);
745 if((se->marker.flags & EM_DEFAULT) == EM_DEFAULT) {
746 safe_printf(" DEFAULT ");
747 asn1print_value(se->marker.default_value, flags);
748 } else if((se->marker.flags & EM_OPTIONAL)
750 safe_printf(" OPTIONAL");
752 if(TQ_NEXT(se, next)) {
754 if(!(flags & APF_NOINDENT))
759 if(put_braces && TQ_FIRST(&tc->members)) {
760 if(!(flags & APF_NOINDENT))
766 if(tc->with_syntax) {
767 safe_printf(" WITH SYNTAX {");
768 asn1print_with_syntax(tc->with_syntax, flags);
772 /* Right hand specialization */
776 TQ_FOR(se, &(tc->rhs_pspecs->members), next) {
777 asn1print_expr(asn, mod, se, flags, level + 1);
778 if(TQ_NEXT(se, next)) safe_printf(", ");
783 if(!SEQ_OF && tc->constraints) {
785 if(tc->meta_type == AMT_VALUESET)
787 asn1print_constraint(tc->constraints, flags);
788 if(tc->meta_type == AMT_VALUESET)
793 safe_printf(" UNIQUE");
796 if(tc->meta_type == AMT_VALUE
797 && tc->expr_type != A1TC_EXTENSIBLE) {
798 if(tc->expr_type == A1TC_UNIVERVAL) {
801 asn1print_value(tc->value, flags);
805 if(level == 0 && tc->Identifier) safe_printf(" ::= ");
806 asn1print_value(tc->value, flags);
811 * The following section exists entirely for debugging.
813 if(flags & APF_PRINT_CONSTRAINTS
814 && tc->expr_type != A1TC_EXTENSIBLE) {
815 asn1p_expr_t *top_parent;
817 if(tc->combined_constraints) {
818 safe_printf("\n-- Combined constraints: ");
819 asn1print_constraint(tc->combined_constraints, flags);
822 top_parent = WITH_MODULE_NAMESPACE(
823 tc->module, tc_ns, asn1f_find_terminal_type_ex(asn, tc_ns, tc));
825 safe_printf("\n-- Practical constraints (%s): ",
826 top_parent->Identifier);
827 asn1print_constraint_explain(top_parent->Identifier,
828 top_parent->expr_type,
829 tc->combined_constraints, 0);
830 safe_printf("\n-- OER-visible constraints (%s): ",
831 top_parent->Identifier);
832 asn1print_constraint_explain(top_parent->Identifier,
833 top_parent->expr_type,
834 tc->combined_constraints, CPR_strict_OER_visibility);
835 safe_printf("\n-- PER-visible constraints (%s): ",
836 top_parent->Identifier);
837 asn1print_constraint_explain(top_parent->Identifier,
838 top_parent->expr_type,
839 tc->combined_constraints, CPR_strict_PER_visibility);
844 if(flags & APF_PRINT_CLASS_MATRIX) do {
845 size_t col, maxidlen;
846 if(tc->ioc_table == NULL) {
847 if(tc->expr_type == A1TC_CLASSDEF) {
848 safe_printf("\n-- Information Object Class table is empty");
852 safe_printf("\n-- Information Object Set has %d entr%s:\n",
854 tc->ioc_table->rows==1 ? "y" : "ies");
855 maxidlen = asn1p_ioc_table_max_identifier_length(tc->ioc_table);
856 for(ssize_t r = -1; r < (ssize_t)tc->ioc_table->rows; r++) {
857 asn1p_ioc_row_t *row;
858 row = tc->ioc_table->row[r<0?0:r];
859 if(r < 0) safe_printf("-- %s", r > 9 ? " " : "");
861 safe_printf("-- [%*d]", (tc->ioc_table->rows > 9) + 1, r + 1);
862 for(col = 0; col < row->columns; col++) {
863 struct asn1p_ioc_cell_s *cell;
864 cell = &row->column[col];
866 safe_printf("[%*s]", maxidlen,
867 cell->field->Identifier);
871 safe_printf(" %*s ", maxidlen, "<no entry>");
874 safe_printf(" %*s ", maxidlen,
875 cell->value->Identifier);
879 if(tc->ioc_table->extensible) {
880 safe_printf("-- [%*s] ...\n", (tc->ioc_table->rows>9)+1, "");
884 if(flags & APF_PRINT_CLASS_MATRIX
885 && tc->lhs_params) do {
887 if(tc->specializations.pspecs_count == 0) {
888 safe_printf("\n-- No specializations found\n");
891 safe_printf("\n-- Specializations list has %d entr%s:\n",
892 tc->specializations.pspecs_count,
893 tc->specializations.pspecs_count == 1 ? "y" : "ies");
894 for(i = 0; i < tc->specializations.pspecs_count; i++) {
896 struct asn1p_pspec_s *pspec;
897 pspec = &tc->specializations.pspec[i];
899 TQ_FOR(se, &(pspec->rhs_pspecs->members), next) {
900 asn1print_expr(asn, mod, se, flags, level+1);
911 asn1print_expr_dtd(asn1p_t *asn, asn1p_module_t *mod, asn1p_expr_t *expr, enum asn1print_flags flags, int level) {
913 int expr_unordered = 0;
914 int dont_involve_children = 0;
916 switch(expr->meta_type) {
921 if(expr->expr_type == A1TC_UNIVERVAL)
926 if(!expr->Identifier) return 0;
928 if(flags & APF_LINE_COMMENTS)
929 INDENT("<!-- #line %d -->\n", expr->_lineno);
930 INDENT("<!ELEMENT %s", expr->Identifier);
932 if(expr->expr_type == A1TC_REFERENCE) {
933 se = WITH_MODULE_NAMESPACE(expr->module, expr_ns, asn1f_find_terminal_type_ex(asn, expr_ns, expr));
935 safe_printf(" (ANY)");
939 dont_involve_children = 1;
942 if(expr->expr_type == ASN_CONSTR_CHOICE
943 || expr->expr_type == ASN_CONSTR_SEQUENCE_OF
944 || expr->expr_type == ASN_CONSTR_SET_OF
945 || expr->expr_type == ASN_CONSTR_SET
946 || expr->expr_type == ASN_BASIC_INTEGER
947 || expr->expr_type == ASN_BASIC_ENUMERATED) {
951 if(TQ_FIRST(&expr->members)) {
953 if(expr->expr_type == ASN_BASIC_BIT_STRING)
954 dont_involve_children = 1;
956 TQ_FOR(se, &(expr->members), next) {
957 if(se->expr_type == A1TC_EXTENSIBLE) {
960 } else if(!se->Identifier
961 && se->expr_type == A1TC_REFERENCE) {
962 asn1print_ref(se->reference, flags);
963 } else if(se->Identifier) {
964 safe_printf("%s", se->Identifier);
968 if(expr->expr_type != ASN_CONSTR_SET
969 && expr->expr_type != ASN_CONSTR_CHOICE
970 && expr->expr_type != ASN_BASIC_INTEGER
971 && expr->expr_type != ASN_BASIC_ENUMERATED) {
974 else if(se->marker.flags)
976 else if(expr->expr_type == ASN_BASIC_BIT_STRING)
980 && TQ_NEXT(se, next)->expr_type != A1TC_EXTENSIBLE) {
981 safe_printf(expr_unordered?"|":", ");
985 safe_printf(expr_unordered?"|":", ");
987 if(expr->expr_type != ASN_CONSTR_SET
988 && expr->expr_type != ASN_CONSTR_CHOICE
989 && expr->expr_type != ASN_BASIC_INTEGER
990 && expr->expr_type != ASN_BASIC_ENUMERATED)
995 if(expr->expr_type == ASN_CONSTR_SET)
998 } else switch(expr->expr_type) {
999 case ASN_BASIC_BOOLEAN:
1000 safe_printf(" (true|false)");
1002 case ASN_CONSTR_CHOICE:
1003 case ASN_CONSTR_SET:
1004 case ASN_CONSTR_SET_OF:
1005 case ASN_CONSTR_SEQUENCE:
1006 case ASN_CONSTR_SEQUENCE_OF:
1007 case ASN_BASIC_NULL:
1008 case A1TC_UNIVERVAL:
1009 safe_printf(" EMPTY");
1012 safe_printf(" ANY");
1014 case ASN_BASIC_BIT_STRING:
1015 case ASN_BASIC_OCTET_STRING:
1016 case ASN_BASIC_OBJECT_IDENTIFIER:
1017 case ASN_BASIC_RELATIVE_OID:
1018 case ASN_BASIC_INTEGER:
1019 case ASN_BASIC_UTCTime:
1020 case ASN_BASIC_GeneralizedTime:
1021 case ASN_STRING_NumericString:
1022 case ASN_STRING_PrintableString:
1023 safe_printf(" (#PCDATA)");
1025 case ASN_STRING_VisibleString:
1026 case ASN_STRING_ISO646String:
1027 /* Entity references, but not XML elements may be present */
1028 safe_printf(" (#PCDATA)");
1030 case ASN_BASIC_REAL: /* e.g. <MINUS-INFINITY/> */
1031 case ASN_BASIC_ENUMERATED: /* e.g. <enumIdentifier1/> */
1034 * XML elements are allowed.
1035 * For example, a UTF8String may contain "<bel/>".
1037 safe_printf(" ANY");
1042 * Display the descendants (children) of the current type.
1044 if(!dont_involve_children) {
1045 TQ_FOR(se, &(expr->members), next) {
1046 if(se->expr_type == A1TC_EXTENSIBLE) continue;
1047 asn1print_expr_dtd(asn, mod, se, flags, level + 1);