blob: 1c6461b0ead368baf8dd5c8ebb94401ddcdd3e73 [file] [log] [blame]
Lev Walkinf15320b2004-06-03 03:38:44 +00001#include <stdio.h>
2#include <string.h>
3#include <errno.h>
4#include <assert.h>
5
6#include <asn1parser.h>
Lev Walkin3140e0e2004-08-18 04:50:37 +00007#include <asn1fix_export.h>
Lev Walkin9095ada2004-08-18 05:41:05 +00008#include <asn1fix_crange.h>
Lev Walkinf15320b2004-06-03 03:38:44 +00009
10#include "asn1print.h"
11
12#define INDENT(fmt, args...) do { \
Lev Walkinf4069d22005-02-15 07:06:05 +000013 if(!(flags & APF_NOINDENT)) { \
14 int __i = level; \
15 while(__i--) printf(" "); \
16 } \
Lev Walkinf15320b2004-06-03 03:38:44 +000017 printf(fmt, ##args); \
18 } while(0)
19
Lev Walkin3140e0e2004-08-18 04:50:37 +000020static int asn1print_module(asn1p_t *asn, asn1p_module_t *mod, enum asn1print_flags flags);
Lev Walkind6db8022005-03-18 03:53:05 +000021static int asn1print_oid(int prior_len, asn1p_oid_t *oid, enum asn1print_flags flags);
Lev Walkin3140e0e2004-08-18 04:50:37 +000022static int asn1print_ref(asn1p_ref_t *ref, enum asn1print_flags flags);
23static int asn1print_tag(asn1p_expr_t *tc, enum asn1print_flags flags);
24static int asn1print_params(asn1p_paramlist_t *pl,enum asn1print_flags flags);
25static int asn1print_with_syntax(asn1p_wsyntx_t *wx, enum asn1print_flags flags);
26static int asn1print_constraint(asn1p_constraint_t *, enum asn1print_flags);
27static int asn1print_value(asn1p_value_t *val, enum asn1print_flags flags);
Lev Walkinf7484512004-10-13 09:13:56 +000028static int asn1print_expr(asn1p_t *asn, asn1p_module_t *mod, asn1p_expr_t *tc, enum asn1print_flags flags, int level);
29static int asn1print_expr_dtd(asn1p_t *asn, asn1p_module_t *mod, asn1p_expr_t *tc, enum asn1print_flags flags, int level);
Lev Walkinf15320b2004-06-03 03:38:44 +000030
31/*
32 * Print the contents of the parsed ASN tree.
33 */
34int
Lev Walkin3140e0e2004-08-18 04:50:37 +000035asn1print(asn1p_t *asn, enum asn1print_flags flags) {
Lev Walkinf15320b2004-06-03 03:38:44 +000036 asn1p_module_t *mod;
Lev Walkinc70c2ef2004-09-30 06:38:21 +000037 int modno = 0;
Lev Walkinf15320b2004-06-03 03:38:44 +000038
39 if(asn == NULL) {
40 errno = EINVAL;
41 return -1;
42 }
43
Lev Walkinf7484512004-10-13 09:13:56 +000044 if(flags & APF_PRINT_XML_DTD)
45 printf("<!-- XML DTD generated by asn1c-" VERSION " -->\n\n");
46
Lev Walkinf15320b2004-06-03 03:38:44 +000047 TQ_FOR(mod, &(asn->modules), mod_next) {
Lev Walkin6b3ff542006-03-06 14:51:00 +000048 if(mod->_tags & MT_STANDARD_MODULE)
49 return 0; /* Ignore modules imported from skeletons */
Lev Walkinc70c2ef2004-09-30 06:38:21 +000050 if(modno++) printf("\n");
Lev Walkin3140e0e2004-08-18 04:50:37 +000051 asn1print_module(asn, mod, flags);
Lev Walkinf15320b2004-06-03 03:38:44 +000052 }
53
Lev Walkin112d69e2005-03-09 20:52:15 +000054 if(flags & APF_PRINT_XML_DTD) {
55 /* Values for BOOLEAN */
56 printf("<!ELEMENT true EMPTY>\n");
57 printf("<!ELEMENT false EMPTY>\n");
58 }
59
Lev Walkinf15320b2004-06-03 03:38:44 +000060 return 0;
61}
62
63static int
Lev Walkin3140e0e2004-08-18 04:50:37 +000064asn1print_module(asn1p_t *asn, asn1p_module_t *mod, enum asn1print_flags flags) {
Lev Walkinf15320b2004-06-03 03:38:44 +000065 asn1p_expr_t *tc;
66
Lev Walkinf7484512004-10-13 09:13:56 +000067 if(flags & APF_PRINT_XML_DTD)
68 printf("<!-- ASN.1 module\n");
69
Lev Walkinb36317c2005-08-12 10:09:10 +000070 printf("%s ", mod->ModuleName);
Lev Walkinf15320b2004-06-03 03:38:44 +000071 if(mod->module_oid) {
Lev Walkinb36317c2005-08-12 10:09:10 +000072 asn1print_oid(strlen(mod->ModuleName), mod->module_oid, flags);
Lev Walkinf15320b2004-06-03 03:38:44 +000073 printf("\n");
74 }
75
Lev Walkinf7484512004-10-13 09:13:56 +000076 if(flags & APF_PRINT_XML_DTD) {
77 if(mod->source_file_name
78 && strcmp(mod->source_file_name, "-"))
79 printf("found in %s", mod->source_file_name);
80 printf(" -->\n\n");
81
82 TQ_FOR(tc, &(mod->members), next) {
83 asn1print_expr_dtd(asn, mod, tc, flags, 0);
84 }
85
86 return 0;
87 }
88
Lev Walkinf15320b2004-06-03 03:38:44 +000089 printf("DEFINITIONS");
90
Lev Walkin3140e0e2004-08-18 04:50:37 +000091 if(mod->module_flags & MSF_TAG_INSTRUCTIONS)
92 printf(" TAG INSTRUCTIONS");
93 if(mod->module_flags & MSF_XER_INSTRUCTIONS)
94 printf(" XER INSTRUCTIONS");
Lev Walkinf15320b2004-06-03 03:38:44 +000095 if(mod->module_flags & MSF_EXPLICIT_TAGS)
96 printf(" EXPLICIT TAGS");
97 if(mod->module_flags & MSF_IMPLICIT_TAGS)
98 printf(" IMPLICIT TAGS");
99 if(mod->module_flags & MSF_AUTOMATIC_TAGS)
100 printf(" AUTOMATIC TAGS");
101 if(mod->module_flags & MSF_EXTENSIBILITY_IMPLIED)
102 printf(" EXTENSIBILITY IMPLIED");
103
104 printf(" ::=\n");
105 printf("BEGIN\n\n");
106
107 TQ_FOR(tc, &(mod->members), next) {
Lev Walkin3140e0e2004-08-18 04:50:37 +0000108 asn1print_expr(asn, mod, tc, flags, 0);
Lev Walkind370e9f2006-03-16 10:03:35 +0000109 if(flags & APF_PRINT_CONSTRAINTS)
Lev Walkinb1ef3962004-08-20 13:24:28 +0000110 printf("\n");
111 else
112 printf("\n\n");
Lev Walkinf15320b2004-06-03 03:38:44 +0000113 }
114
115 printf("END\n");
116
117 return 0;
118}
119
120static int
Lev Walkind6db8022005-03-18 03:53:05 +0000121asn1print_oid(int prior_len, asn1p_oid_t *oid, enum asn1print_flags flags) {
122 size_t accum = prior_len;
Lev Walkinf15320b2004-06-03 03:38:44 +0000123 int ac;
Lev Walkinf15320b2004-06-03 03:38:44 +0000124
Lev Walkind9bd7752004-06-05 08:17:50 +0000125 (void)flags; /* Unused argument */
126
Lev Walkinf15320b2004-06-03 03:38:44 +0000127 printf("{");
128 for(ac = 0; ac < oid->arcs_count; ac++) {
Lev Walkin4efbfb72005-02-25 14:20:30 +0000129 const char *arcname = oid->arcs[ac].name;
130
Lev Walkin5b7eeaf2005-03-28 17:52:43 +0000131 if(accum + strlen(arcname ? arcname : "") > 72) {
Lev Walkinf15320b2004-06-03 03:38:44 +0000132 printf("\n\t");
Lev Walkin5b7eeaf2005-03-28 17:52:43 +0000133 accum = 8;
Lev Walkind6db8022005-03-18 03:53:05 +0000134 } else {
135 accum += printf(" ");
Lev Walkin4efbfb72005-02-25 14:20:30 +0000136 }
Lev Walkinf15320b2004-06-03 03:38:44 +0000137
Lev Walkin4efbfb72005-02-25 14:20:30 +0000138 if(arcname) {
Lev Walkind6db8022005-03-18 03:53:05 +0000139 accum += printf("%s", arcname);
Lev Walkin0056aec2004-09-05 10:38:50 +0000140 if(oid->arcs[ac].number >= 0) {
Lev Walkind6db8022005-03-18 03:53:05 +0000141 accum += printf("(%" PRIdASN ")",
142 oid->arcs[ac].number);
Lev Walkin0056aec2004-09-05 10:38:50 +0000143 }
Lev Walkinf15320b2004-06-03 03:38:44 +0000144 } else {
Lev Walkind6db8022005-03-18 03:53:05 +0000145 accum += printf("%" PRIdASN, oid->arcs[ac].number);
Lev Walkinf15320b2004-06-03 03:38:44 +0000146 }
Lev Walkinf15320b2004-06-03 03:38:44 +0000147 }
148 printf(" }");
149
150 return 0;
151}
152
153static int
Lev Walkin3140e0e2004-08-18 04:50:37 +0000154asn1print_ref(asn1p_ref_t *ref, enum asn1print_flags flags) {
Lev Walkinf15320b2004-06-03 03:38:44 +0000155 int cc;
156
Lev Walkind9bd7752004-06-05 08:17:50 +0000157 (void)flags; /* Unused argument */
158
Lev Walkinf15320b2004-06-03 03:38:44 +0000159 for(cc = 0; cc < ref->comp_count; cc++) {
160 if(cc) printf(".");
161 printf("%s", ref->components[cc].name);
162 }
163
164 return 0;
165}
166
167static int
Lev Walkin3140e0e2004-08-18 04:50:37 +0000168asn1print_tag(asn1p_expr_t *tc, enum asn1print_flags flags) {
Lev Walkinf15320b2004-06-03 03:38:44 +0000169 struct asn1p_type_tag_s *tag = &tc->tag;
170
Lev Walkind9bd7752004-06-05 08:17:50 +0000171 (void)flags; /* Unused argument */
172
Lev Walkin71160962005-06-02 05:21:53 +0000173 printf("%s", asn1p_tag2string(tag, 0));
Lev Walkinf15320b2004-06-03 03:38:44 +0000174
175 return 0;
176}
177
178static int
Lev Walkin3140e0e2004-08-18 04:50:37 +0000179asn1print_value(asn1p_value_t *val, enum asn1print_flags flags) {
Lev Walkinf15320b2004-06-03 03:38:44 +0000180
181 if(val == NULL)
182 return 0;
183
184 switch(val->type) {
185 case ATV_NOVALUE:
186 break;
Lev Walkinb1e07082004-09-15 11:44:55 +0000187 case ATV_NULL:
188 printf("NULL");
189 return 0;
190 case ATV_REAL:
191 printf("%f", val->value.v_double);
192 return 0;
Lev Walkina9532f42006-09-17 04:52:50 +0000193 case ATV_TYPE:
194 asn1print_expr(val->value.v_type->module->asn1p,
195 val->value.v_type->module,
196 val->value.v_type, flags, 0);
197 return 0;
Lev Walkinf15320b2004-06-03 03:38:44 +0000198 case ATV_INTEGER:
Lev Walkin33c16ba2004-09-24 21:01:43 +0000199 printf("%" PRIdASN, val->value.v_integer);
Lev Walkinf15320b2004-06-03 03:38:44 +0000200 return 0;
201 case ATV_MIN: printf("MIN"); return 0;
202 case ATV_MAX: printf("MAX"); return 0;
203 case ATV_FALSE: printf("FALSE"); return 0;
204 case ATV_TRUE: printf("TRUE"); return 0;
Lev Walkin1e448d32005-03-24 14:26:38 +0000205 case ATV_TUPLE:
206 printf("{%d, %d}",
207 (int)(val->value.v_integer >> 4),
208 (int)(val->value.v_integer & 0x0f));
209 return 0;
210 case ATV_QUADRUPLE:
211 printf("{%d, %d, %d, %d}",
212 (int)((val->value.v_integer >> 24) & 0xff),
213 (int)((val->value.v_integer >> 16) & 0xff),
214 (int)((val->value.v_integer >> 8) & 0xff),
215 (int)((val->value.v_integer >> 0) & 0xff)
216 );
217 return 0;
Lev Walkinf15320b2004-06-03 03:38:44 +0000218 case ATV_STRING:
219 {
Lev Walkin84fbd722005-06-15 18:41:50 +0000220 char *p = (char *)val->value.string.buf;
Lev Walkinf15320b2004-06-03 03:38:44 +0000221 putchar('"');
222 if(strchr(p, '"')) {
223 /* Mask quotes */
224 for(; *p; p++) {
225 if(*p == '"')
226 putchar(*p);
227 putchar(*p);
228 }
229 } else {
230 fputs(p, stdout);
231 }
232 putchar('"');
233 }
234 return 0;
235 case ATV_UNPARSED:
Lev Walkin84fbd722005-06-15 18:41:50 +0000236 fputs((char *)val->value.string.buf, stdout);
Lev Walkinf15320b2004-06-03 03:38:44 +0000237 return 0;
238 case ATV_BITVECTOR:
239 {
240 uint8_t *bitvector;
241 int bits;
242 int i;
243
244 bitvector = val->value.binary_vector.bits;
245 bits = val->value.binary_vector.size_in_bits;
246
247 printf("'");
248 if(bits%8) {
249 for(i = 0; i < bits; i++) {
250 uint8_t uc;
251 uc = bitvector[i>>3];
252 putchar(((uc >> (7-(i%8)))&1)?'1':'0');
253 }
254 printf("'B");
255 } else {
256 char hextable[16] = "0123456789ABCDEF";
257 for(i = 0; i < (bits>>3); i++) {
258 putchar(hextable[bitvector[i] >> 4]);
259 putchar(hextable[bitvector[i] & 0x0f]);
260 }
261 printf("'H");
262 }
Lev Walkin043af0d2005-02-24 21:07:35 +0000263 return 0;
Lev Walkinf15320b2004-06-03 03:38:44 +0000264 }
Lev Walkinb1e07082004-09-15 11:44:55 +0000265 case ATV_REFERENCED:
266 return asn1print_ref(val->value.reference, flags);
Lev Walkin5045dfa2006-03-21 09:41:28 +0000267 case ATV_VALUESET:
268 return asn1print_constraint(val->value.constraint, flags);
Lev Walkinb1e07082004-09-15 11:44:55 +0000269 case ATV_CHOICE_IDENTIFIER:
270 printf("%s: ", val->value.choice_identifier.identifier);
271 return asn1print_value(val->value.choice_identifier.value, flags);
Lev Walkinf15320b2004-06-03 03:38:44 +0000272 }
273
274 assert(val->type || !"Unknown");
275
276 return 0;
277}
278
279static int
Lev Walkin3140e0e2004-08-18 04:50:37 +0000280asn1print_constraint(asn1p_constraint_t *ct, enum asn1print_flags flags) {
Lev Walkinf15320b2004-06-03 03:38:44 +0000281 int symno = 0;
282
283 if(ct == 0) return 0;
284
285 if(ct->type == ACT_CA_SET)
286 printf("(");
287
288 switch(ct->type) {
Lev Walkinff7dd142005-03-20 12:58:00 +0000289 case ACT_EL_TYPE:
Lev Walkin5045dfa2006-03-21 09:41:28 +0000290 asn1print_value(ct->containedSubtype, flags);
Lev Walkinff7dd142005-03-20 12:58:00 +0000291 break;
Lev Walkinf15320b2004-06-03 03:38:44 +0000292 case ACT_EL_VALUE:
293 asn1print_value(ct->value, flags);
294 break;
295 case ACT_EL_RANGE:
296 case ACT_EL_LLRANGE:
297 case ACT_EL_RLRANGE:
298 case ACT_EL_ULRANGE:
299 asn1print_value(ct->range_start, flags);
300 switch(ct->type) {
301 case ACT_EL_RANGE: printf(".."); break;
302 case ACT_EL_LLRANGE: printf("<.."); break;
303 case ACT_EL_RLRANGE: printf("..<"); break;
304 case ACT_EL_ULRANGE: printf("<..<"); break;
305 default: printf("?..?"); break;
306 }
307 asn1print_value(ct->range_stop, flags);
308 break;
309 case ACT_EL_EXT:
310 printf("...");
311 break;
312 case ACT_CT_SIZE:
313 case ACT_CT_FROM:
314 switch(ct->type) {
Lev Walkin3140e0e2004-08-18 04:50:37 +0000315 case ACT_CT_SIZE: printf("SIZE("); break;
316 case ACT_CT_FROM: printf("FROM("); break;
Lev Walkinf15320b2004-06-03 03:38:44 +0000317 default: printf("??? ("); break;
318 }
319 assert(ct->el_count != 0);
320 assert(ct->el_count == 1);
321 asn1print_constraint(ct->elements[0], flags);
322 printf(")");
323 break;
324 case ACT_CT_WCOMP:
Lev Walkine596bf02005-03-28 15:01:27 +0000325 assert(ct->el_count != 0);
326 assert(ct->el_count == 1);
327 printf("WITH COMPONENT (");
328 asn1print_constraint(ct->elements[0], flags);
329 printf(")");
Lev Walkin8638f0d2005-03-28 07:50:06 +0000330 break;
Lev Walkine596bf02005-03-28 15:01:27 +0000331 case ACT_CT_WCOMPS: {
332 unsigned int i;
333 printf("WITH COMPONENTS { ");
334 for(i = 0; i < ct->el_count; i++) {
335 asn1p_constraint_t *cel = ct->elements[i];
336 if(i) printf(", ");
337 fwrite(cel->value->value.string.buf,
338 1, cel->value->value.string.size,
339 stdout);
340 if(cel->el_count) {
341 assert(cel->el_count == 1);
342 printf(" ");
343 asn1print_constraint(cel->elements[0],
344 flags);
345 }
346 switch(cel->presence) {
347 case ACPRES_DEFAULT: break;
348 case ACPRES_PRESENT: printf(" PRESENT"); break;
349 case ACPRES_ABSENT: printf(" ABSENT"); break;
350 case ACPRES_OPTIONAL: printf(" OPTIONAL");break;
351 }
352 }
353 printf(" }");
354 }
Lev Walkin8638f0d2005-03-28 07:50:06 +0000355 break;
Lev Walkin1893ddf2005-03-20 14:28:32 +0000356 case ACT_CT_CTDBY:
Lev Walkina9532f42006-09-17 04:52:50 +0000357 printf("(CONSTRAINED BY ");
Lev Walkin1893ddf2005-03-20 14:28:32 +0000358 assert(ct->value->type == ATV_UNPARSED);
359 fwrite(ct->value->value.string.buf,
360 1, ct->value->value.string.size, stdout);
Lev Walkina9532f42006-09-17 04:52:50 +0000361 printf(")");
362 break;
363 case ACT_CT_CTNG:
364 printf("(CONTAINING ");
365 asn1print_expr(ct->value->value.v_type->module->asn1p,
366 ct->value->value.v_type->module,
367 ct->value->value.v_type,
368 flags, 1);
369 printf(")");
Lev Walkinf15320b2004-06-03 03:38:44 +0000370 break;
Lev Walkin5c541f12006-10-18 18:40:14 +0000371 case ACT_CT_PATTERN:
372 printf("(PATTERN ");
373 asn1print_value(ct->value, flags);
374 printf(")");
375 break;
Lev Walkinf15320b2004-06-03 03:38:44 +0000376 case ACT_CA_SET: symno++;
377 case ACT_CA_CRC: symno++;
378 case ACT_CA_CSV: symno++;
379 case ACT_CA_UNI: symno++;
380 case ACT_CA_INT: symno++;
381 case ACT_CA_EXC:
382 {
Lev Walkin3140e0e2004-08-18 04:50:37 +0000383 char *symtable[] = { " EXCEPT ", " ^ ", " | ", ",",
Lev Walkinf15320b2004-06-03 03:38:44 +0000384 "", "(" };
Lev Walkin0056aec2004-09-05 10:38:50 +0000385 unsigned int i;
Lev Walkina9532f42006-09-17 04:52:50 +0000386 if(ct->type == ACT_CA_CRC) fputs("(", stdout);
Lev Walkinf15320b2004-06-03 03:38:44 +0000387 for(i = 0; i < ct->el_count; i++) {
Lev Walkinf15320b2004-06-03 03:38:44 +0000388 if(i) fputs(symtable[symno], stdout);
389 if(ct->type == ACT_CA_CRC) fputs("{", stdout);
Lev Walkin1e448d32005-03-24 14:26:38 +0000390 asn1print_constraint(ct->elements[i], flags);
Lev Walkinf15320b2004-06-03 03:38:44 +0000391 if(ct->type == ACT_CA_CRC) fputs("}", stdout);
392 if(i+1 < ct->el_count
393 && ct->type == ACT_CA_SET)
394 fputs(")", stdout);
395 }
Lev Walkina9532f42006-09-17 04:52:50 +0000396 if(ct->type == ACT_CA_CRC) fputs(")", stdout);
Lev Walkinf15320b2004-06-03 03:38:44 +0000397 }
398 break;
Lev Walkin1e448d32005-03-24 14:26:38 +0000399 case ACT_CA_AEX:
400 assert(ct->el_count == 1);
401 printf("ALL EXCEPT ");
402 asn1print_constraint(ct->elements[0], flags);
403 break;
Lev Walkinf15320b2004-06-03 03:38:44 +0000404 case ACT_INVALID:
405 assert(ct->type != ACT_INVALID);
406 break;
407 }
408
409 if(ct->type == ACT_CA_SET)
410 printf(")");
411
412 return 0;
413}
414
415static int
Lev Walkin3140e0e2004-08-18 04:50:37 +0000416asn1print_params(asn1p_paramlist_t *pl, enum asn1print_flags flags) {
Lev Walkinf15320b2004-06-03 03:38:44 +0000417 if(pl) {
418 int i;
419 printf("{");
420 for(i = 0; i < pl->params_count; i++) {
421 if(i) printf(", ");
422 if(pl->params[i].governor) {
423 asn1print_ref(pl->params[i].governor, flags);
424 printf(":");
425 }
426 printf("%s", pl->params[i].argument);
427 }
428 printf("}");
429 }
430
431 return 0;
432}
433
434static int
Lev Walkin3140e0e2004-08-18 04:50:37 +0000435asn1print_with_syntax(asn1p_wsyntx_t *wx, enum asn1print_flags flags) {
Lev Walkinf15320b2004-06-03 03:38:44 +0000436 if(wx) {
437 asn1p_wsyntx_chunk_t *wc;
Lev Walkinf15320b2004-06-03 03:38:44 +0000438 TQ_FOR(wc, &(wx->chunks), next) {
Lev Walkin9d542d22006-03-14 16:31:37 +0000439 switch(wc->type) {
440 case WC_LITERAL:
Lev Walkin57074f12006-03-16 05:11:14 +0000441 case WC_WHITESPACE:
Lev Walkind370e9f2006-03-16 10:03:35 +0000442 case WC_FIELD:
Lev Walkin9d542d22006-03-14 16:31:37 +0000443 printf("%s", wc->content.token);
444 break;
Lev Walkin9d542d22006-03-14 16:31:37 +0000445 case WC_OPTIONALGROUP:
446 printf("[");
447 asn1print_with_syntax(wc->content.syntax,flags);
448 printf("]");
449 break;
450 }
Lev Walkinf15320b2004-06-03 03:38:44 +0000451 }
Lev Walkinf15320b2004-06-03 03:38:44 +0000452 }
453
454 return 0;
455}
456
457static int
Lev Walkin3140e0e2004-08-18 04:50:37 +0000458asn1print_crange_value(asn1cnst_edge_t *edge, int as_char) {
459 switch(edge->type) {
460 case ARE_MIN: printf("MIN"); break;
461 case ARE_MAX: printf("MAX"); break;
462 case ARE_VALUE:
463 if(as_char) {
464 printf("\"%c\"", (unsigned char)edge->value);
465 } else {
Lev Walkin33c16ba2004-09-24 21:01:43 +0000466 printf("%" PRIdASN, edge->value);
Lev Walkin3140e0e2004-08-18 04:50:37 +0000467 }
468 }
469 return 0;
470}
471
472static int
Lev Walkine8e87f12004-08-25 02:00:03 +0000473asn1print_constraint_explain_type(asn1p_expr_type_e expr_type, asn1p_constraint_t *ct, enum asn1p_constraint_type_e type, int strict_PER_visible) {
Lev Walkin3140e0e2004-08-18 04:50:37 +0000474 asn1cnst_range_t *range;
475 int as_char = (type==ACT_CT_FROM);
476 int i;
477
Lev Walkin4b553412005-08-14 14:45:44 +0000478 range = asn1constraint_compute_PER_range(expr_type, ct, type, 0, 0,
479 strict_PER_visible ? CPR_strict_PER_visibility : 0);
Lev Walkin3140e0e2004-08-18 04:50:37 +0000480 if(!range) return -1;
481
Lev Walkine8e87f12004-08-25 02:00:03 +0000482 if(range->incompatible
483 || (strict_PER_visible && range->not_PER_visible)) {
484 asn1constraint_range_free(range);
485 return 0;
486 }
487
Lev Walkin3140e0e2004-08-18 04:50:37 +0000488 switch(type) {
489 case ACT_CT_FROM: printf("(FROM("); break;
490 case ACT_CT_SIZE: printf("(SIZE("); break;
491 default: printf("("); break;
492 }
493 for(i = -1; i < range->el_count; i++) {
494 asn1cnst_range_t *r;
495 if(i == -1) {
496 if(range->el_count) continue;
497 r = range;
498 } else {
499 r = range->elements[i];
500 }
501 if(i > 0) {
502 printf(" | ");
503 }
504 asn1print_crange_value(&r->left, as_char);
505 if(r->left.type != r->right.type
506 || r->left.value != r->right.value) {
507 printf("..");
508 asn1print_crange_value(&r->right, as_char);
509 }
510 }
511 if(range->extensible)
512 printf(",...");
513 printf(type==ACT_EL_RANGE?")":"))");
514
515 if(range->empty_constraint)
516 printf(":Empty!");
517
518 asn1constraint_range_free(range);
519 return 0;
520}
521
522static int
523asn1print_constraint_explain(asn1p_expr_type_e expr_type,
Lev Walkine8e87f12004-08-25 02:00:03 +0000524 asn1p_constraint_t *ct, int s_PV) {
Lev Walkin3140e0e2004-08-18 04:50:37 +0000525
Lev Walkine8e87f12004-08-25 02:00:03 +0000526 asn1print_constraint_explain_type(expr_type, ct, ACT_EL_RANGE, s_PV);
Lev Walkin3140e0e2004-08-18 04:50:37 +0000527 printf(" ");
Lev Walkine8e87f12004-08-25 02:00:03 +0000528 asn1print_constraint_explain_type(expr_type, ct, ACT_CT_SIZE, s_PV);
Lev Walkin3140e0e2004-08-18 04:50:37 +0000529 printf(" ");
Lev Walkine8e87f12004-08-25 02:00:03 +0000530 asn1print_constraint_explain_type(expr_type, ct, ACT_CT_FROM, s_PV);
Lev Walkin3140e0e2004-08-18 04:50:37 +0000531
532 return 0;
533}
534
535static int
536asn1print_expr(asn1p_t *asn, asn1p_module_t *mod, asn1p_expr_t *tc, enum asn1print_flags flags, int level) {
Lev Walkinb1ef3962004-08-20 13:24:28 +0000537 int SEQ_OF = 0;
Lev Walkinf15320b2004-06-03 03:38:44 +0000538
Lev Walkinf4069d22005-02-15 07:06:05 +0000539 if(flags & APF_LINE_COMMENTS && !(flags & APF_NOINDENT))
Lev Walkinf7484512004-10-13 09:13:56 +0000540 INDENT("-- #line %d\n", tc->_lineno);
Lev Walkinef625402005-09-05 05:17:57 +0000541
542 /* Reconstruct compiler directive information */
543 if((tc->marker.flags & EM_INDIRECT)
544 && (tc->marker.flags & EM_OMITABLE) != EM_OMITABLE) {
545 if((flags & APF_NOINDENT))
546 printf(" --<ASN1C.RepresentAsPointer>-- ");
547 else
548 INDENT("--<ASN1C.RepresentAsPointer>--\n");
549 }
550
Lev Walkina00d6b32006-03-21 03:40:38 +0000551 if(tc->Identifier
552 && (!(tc->meta_type == AMT_VALUE && tc->expr_type == A1TC_REFERENCE)
553 || level == 0))
Lev Walkinf15320b2004-06-03 03:38:44 +0000554 INDENT("%s", tc->Identifier);
555
Lev Walkina00d6b32006-03-21 03:40:38 +0000556 if(tc->lhs_params) {
557 asn1print_params(tc->lhs_params, flags);
Lev Walkinf15320b2004-06-03 03:38:44 +0000558 }
559
560 if(tc->meta_type != AMT_VALUE
Lev Walkinc74ea222004-08-25 02:27:47 +0000561 && tc->meta_type != AMT_VALUESET
Lev Walkinf15320b2004-06-03 03:38:44 +0000562 && tc->expr_type != A1TC_EXTENSIBLE) {
563 if(level) {
Lev Walkinf4069d22005-02-15 07:06:05 +0000564 if(tc->Identifier && !(flags & APF_NOINDENT))
Lev Walkinf15320b2004-06-03 03:38:44 +0000565 printf("\t");
566 } else {
567 printf(" ::=");
568 }
569 }
570
571 if(tc->tag.tag_class) {
572 printf(" ");
573 asn1print_tag(tc, flags);
574 }
575
576 switch(tc->expr_type) {
577 case A1TC_EXTENSIBLE:
578 if(tc->value) {
579 printf("!");
580 asn1print_value(tc->value, flags);
581 }
582 break;
Lev Walkinfd151ce2004-08-22 03:08:51 +0000583 case A1TC_COMPONENTS_OF:
584 SEQ_OF = 1; /* Equivalent to SET OF for printint purposes */
585 printf(" COMPONENTS OF");
586 break;
Lev Walkinf15320b2004-06-03 03:38:44 +0000587 case A1TC_REFERENCE:
588 case A1TC_UNIVERVAL:
Lev Walkinf15320b2004-06-03 03:38:44 +0000589 break;
590 case A1TC_CLASSDEF:
591 printf(" CLASS");
592 break;
Lev Walkin9c2285a2006-03-09 08:49:26 +0000593 case A1TC_CLASSFIELD_TFS ... A1TC_CLASSFIELD_OSFS:
Lev Walkinf15320b2004-06-03 03:38:44 +0000594 /* Nothing to print here */
595 break;
Lev Walkinb1ef3962004-08-20 13:24:28 +0000596 case ASN_CONSTR_SET_OF:
597 case ASN_CONSTR_SEQUENCE_OF:
598 SEQ_OF = 1;
599 if(tc->expr_type == ASN_CONSTR_SET_OF)
600 printf(" SET");
601 else
602 printf(" SEQUENCE");
603 if(tc->constraints) {
604 printf(" ");
605 asn1print_constraint(tc->constraints, flags);
606 }
607 printf(" OF");
608 break;
Lev Walkin5045dfa2006-03-21 09:41:28 +0000609 case A1TC_VALUESET:
610 break;
Lev Walkinf15320b2004-06-03 03:38:44 +0000611 default:
612 {
613 char *p = ASN_EXPR_TYPE2STR(tc->expr_type);
614 printf(" %s", p?p:"<unknown type!>");
615 }
616 break;
617 }
618
Lev Walkinb9d0ae32005-06-02 04:06:24 +0000619 /*
620 * Put the name of the referred type.
621 */
Lev Walkinf15320b2004-06-03 03:38:44 +0000622 if(tc->reference) {
Lev Walkinb9d0ae32005-06-02 04:06:24 +0000623 printf(" ");
Lev Walkinf15320b2004-06-03 03:38:44 +0000624 asn1print_ref(tc->reference, flags);
625 }
626
Lev Walkin5045dfa2006-03-21 09:41:28 +0000627 if(tc->meta_type == AMT_VALUESET && level == 0)
Lev Walkinc74ea222004-08-25 02:27:47 +0000628 printf(" ::=");
629
Lev Walkinf15320b2004-06-03 03:38:44 +0000630 /*
631 * Display the descendants (children) of the current type.
632 */
Lev Walkinc74ea222004-08-25 02:27:47 +0000633 if(TQ_FIRST(&(tc->members))
634 || (tc->expr_type & ASN_CONSTR_MASK)
Lev Walkinc74ea222004-08-25 02:27:47 +0000635 || tc->meta_type == AMT_OBJECT
Lev Walkin9c2285a2006-03-09 08:49:26 +0000636 || tc->meta_type == AMT_OBJECTCLASS
637 || tc->meta_type == AMT_OBJECTFIELD
Lev Walkinc74ea222004-08-25 02:27:47 +0000638 ) {
Lev Walkinf15320b2004-06-03 03:38:44 +0000639 asn1p_expr_t *se; /* SubExpression */
Lev Walkin9c2285a2006-03-09 08:49:26 +0000640 int put_braces = (!SEQ_OF) /* Don't need 'em, if SET OF... */
641 && (tc->meta_type != AMT_OBJECTFIELD);
Lev Walkinf15320b2004-06-03 03:38:44 +0000642
Lev Walkinc74ea222004-08-25 02:27:47 +0000643 if(put_braces) {
Lev Walkinf4069d22005-02-15 07:06:05 +0000644 if(flags & APF_NOINDENT) {
645 printf("{");
646 if(!TQ_FIRST(&tc->members))
647 printf("}");
648 } else {
649 printf(" {");
650 if(TQ_FIRST(&tc->members))
651 printf("\n");
652 else
653 printf(" }");
654 }
Lev Walkinc74ea222004-08-25 02:27:47 +0000655 }
Lev Walkinf15320b2004-06-03 03:38:44 +0000656
657 TQ_FOR(se, &(tc->members), next) {
658 /*
Lev Walkinfd151ce2004-08-22 03:08:51 +0000659 * Print the expression as it were a stand-alone type.
Lev Walkinf15320b2004-06-03 03:38:44 +0000660 */
Lev Walkinf7484512004-10-13 09:13:56 +0000661 asn1print_expr(asn, mod, se, flags, level + 1);
Lev Walkinb1e07082004-09-15 11:44:55 +0000662 if((se->marker.flags & EM_DEFAULT) == EM_DEFAULT) {
663 printf(" DEFAULT ");
664 asn1print_value(se->marker.default_value, flags);
665 } else if((se->marker.flags & EM_OPTIONAL)
666 == EM_OPTIONAL) {
Lev Walkin6e8da2b2004-09-10 08:21:27 +0000667 printf(" OPTIONAL");
Lev Walkinb1e07082004-09-15 11:44:55 +0000668 }
Lev Walkinef625402005-09-05 05:17:57 +0000669 if(TQ_NEXT(se, next)) {
Lev Walkinf15320b2004-06-03 03:38:44 +0000670 printf(",");
Lev Walkinef625402005-09-05 05:17:57 +0000671 if(!(flags & APF_NOINDENT))
672 INDENT("\n");
673 }
Lev Walkinf15320b2004-06-03 03:38:44 +0000674 }
675
Lev Walkinc74ea222004-08-25 02:27:47 +0000676 if(put_braces && TQ_FIRST(&tc->members)) {
Lev Walkinf4069d22005-02-15 07:06:05 +0000677 if(!(flags & APF_NOINDENT))
678 printf("\n");
Lev Walkinf15320b2004-06-03 03:38:44 +0000679 INDENT("}");
680 }
681 }
682
Lev Walkin9d542d22006-03-14 16:31:37 +0000683 if(tc->with_syntax) {
684 printf(" WITH SYNTAX {");
Lev Walkinf15320b2004-06-03 03:38:44 +0000685 asn1print_with_syntax(tc->with_syntax, flags);
Lev Walkin9d542d22006-03-14 16:31:37 +0000686 printf("}\n");
687 }
Lev Walkinf15320b2004-06-03 03:38:44 +0000688
Lev Walkina00d6b32006-03-21 03:40:38 +0000689 /* Right hand specialization */
690 if(tc->rhs_pspecs) {
691 asn1p_expr_t *se;
692 printf("{");
693 TQ_FOR(se, &(tc->rhs_pspecs->members), next) {
694 asn1print_expr(asn, mod, se, flags, level + 1);
Lev Walkin0c0bca62006-03-21 04:48:15 +0000695 if(TQ_NEXT(se, next)) printf(", ");
Lev Walkina00d6b32006-03-21 03:40:38 +0000696 }
697 printf("}");
698 }
699
Lev Walkinb1ef3962004-08-20 13:24:28 +0000700 if(!SEQ_OF && tc->constraints) {
Lev Walkinf15320b2004-06-03 03:38:44 +0000701 printf(" ");
Lev Walkin557f27d2006-03-21 07:46:48 +0000702 if(tc->meta_type == AMT_VALUESET)
703 printf("{");
Lev Walkinf15320b2004-06-03 03:38:44 +0000704 asn1print_constraint(tc->constraints, flags);
Lev Walkin557f27d2006-03-21 07:46:48 +0000705 if(tc->meta_type == AMT_VALUESET)
706 printf("}");
Lev Walkinf15320b2004-06-03 03:38:44 +0000707 }
Lev Walkin3140e0e2004-08-18 04:50:37 +0000708
Lev Walkinf15320b2004-06-03 03:38:44 +0000709 if(tc->unique) {
710 printf(" UNIQUE");
711 }
712
713 if(tc->meta_type == AMT_VALUE
714 && tc->expr_type != A1TC_EXTENSIBLE) {
Lev Walkin0056aec2004-09-05 10:38:50 +0000715 if(tc->expr_type == A1TC_UNIVERVAL) {
Lev Walkinb1e07082004-09-15 11:44:55 +0000716 if(tc->value) {
717 printf("(");
718 asn1print_value(tc->value, flags);
719 printf(")");
720 }
Lev Walkin0056aec2004-09-05 10:38:50 +0000721 } else {
Lev Walkina00d6b32006-03-21 03:40:38 +0000722 if(level == 0) printf(" ::= ");
Lev Walkin0056aec2004-09-05 10:38:50 +0000723 asn1print_value(tc->value, flags);
724 }
Lev Walkinf15320b2004-06-03 03:38:44 +0000725 }
726
Lev Walkinfd151ce2004-08-22 03:08:51 +0000727 /*
Lev Walkinf4069d22005-02-15 07:06:05 +0000728 * The following section exists entirely for debugging.
Lev Walkinfd151ce2004-08-22 03:08:51 +0000729 */
Lev Walkind370e9f2006-03-16 10:03:35 +0000730 if(flags & APF_PRINT_CONSTRAINTS
Lev Walkinb1ef3962004-08-20 13:24:28 +0000731 && tc->expr_type != A1TC_EXTENSIBLE) {
Lev Walkin3140e0e2004-08-18 04:50:37 +0000732 asn1p_expr_t *top_parent;
733
734 if(tc->combined_constraints) {
735 printf("\n-- Combined constraints: ");
736 asn1print_constraint(tc->combined_constraints, flags);
737 }
738
Lev Walkine4d6ab82004-09-22 16:05:13 +0000739 top_parent = asn1f_find_terminal_type_ex(asn, tc);
Lev Walkin3140e0e2004-08-18 04:50:37 +0000740 if(top_parent) {
Lev Walkine8e87f12004-08-25 02:00:03 +0000741 printf("\n-- Practical constraints (%s): ",
742 top_parent->Identifier);
743 asn1print_constraint_explain(top_parent->expr_type,
744 tc->combined_constraints, 0);
Lev Walkinb1ef3962004-08-20 13:24:28 +0000745 printf("\n-- PER-visible constraints (%s): ",
746 top_parent->Identifier);
Lev Walkin3140e0e2004-08-18 04:50:37 +0000747 asn1print_constraint_explain(top_parent->expr_type,
Lev Walkine8e87f12004-08-25 02:00:03 +0000748 tc->combined_constraints, 1);
Lev Walkin3140e0e2004-08-18 04:50:37 +0000749 }
Lev Walkinb1ef3962004-08-20 13:24:28 +0000750 printf("\n");
Lev Walkin3140e0e2004-08-18 04:50:37 +0000751 }
752
Lev Walkind370e9f2006-03-16 10:03:35 +0000753 if(flags & APF_PRINT_CLASS_MATRIX
754 && tc->expr_type == A1TC_CLASSDEF) do {
755 int r, col, maxidlen;
756 if(tc->object_class_matrix.rows == 0) {
757 printf("\n-- Class matrix is empty");
758 break;
759 }
760 printf("\n-- Class matrix has %d entr%s:\n",
761 tc->object_class_matrix.rows,
762 tc->object_class_matrix.rows==1 ? "y" : "ies");
763 maxidlen = tc->object_class_matrix.max_identifier_length;
764 for(r = -1; r < tc->object_class_matrix.rows; r++) {
765 struct asn1p_ioc_row_s *row;
766 row = tc->object_class_matrix.row[r<0?0:r];
767 if(r < 0) printf("-- %s", r > 9 ? " " : "");
768 else printf("-- [%*d]", r > 9 ? 2 : 1, r+1);
769 for(col = 0; col < row->columns; col++) {
770 struct asn1p_ioc_cell_s *cell;
771 cell = &row->column[col];
772 if(r < 0) {
773 printf("[%*s]", maxidlen,
774 cell->field->Identifier);
775 continue;
776 }
777 if(!cell->value) {
778 printf(" %*s ", maxidlen, "<no entry>");
779 continue;
780 }
781 printf(" %*s ", maxidlen,
782 cell->value->Identifier);
783 }
784 printf("\n");
785 }
786 } while(0);
787
Lev Walkina00d6b32006-03-21 03:40:38 +0000788 if(flags & APF_PRINT_CLASS_MATRIX
789 && tc->lhs_params) do {
790 int i;
791 if(tc->specializations.pspecs_count == 0) {
792 printf("\n-- No specializations found\n");
793 break;
794 }
795 printf("\n-- Specializations list has %d entr%s:\n",
796 tc->specializations.pspecs_count,
797 tc->specializations.pspecs_count == 1 ? "y" : "ies");
798 for(i = 0; i < tc->specializations.pspecs_count; i++) {
799 asn1p_expr_t *se;
800 struct asn1p_pspec_s *pspec;
801 pspec = &tc->specializations.pspec[i];
802 printf("-- ");
803 TQ_FOR(se, &(pspec->rhs_pspecs->members), next) {
804 asn1print_expr(asn, mod, se, flags, level+1);
805 }
806 printf("\n");
807 }
808 } while(0);
809
Lev Walkinf15320b2004-06-03 03:38:44 +0000810 return 0;
811}
Lev Walkin3140e0e2004-08-18 04:50:37 +0000812
Lev Walkinf7484512004-10-13 09:13:56 +0000813
814static int
815asn1print_expr_dtd(asn1p_t *asn, asn1p_module_t *mod, asn1p_expr_t *expr, enum asn1print_flags flags, int level) {
816 asn1p_expr_t *se;
817 int expr_unordered = 0;
Lev Walkinef39f7e2004-10-14 05:11:25 +0000818 int dont_involve_children = 0;
Lev Walkinf7484512004-10-13 09:13:56 +0000819
820 switch(expr->meta_type) {
821 case AMT_TYPE:
822 case AMT_TYPEREF:
823 break;
824 default:
825 if(expr->expr_type == A1TC_UNIVERVAL)
826 break;
827 return 0;
828 }
829
830 if(!expr->Identifier) return 0;
831
Lev Walkinf7484512004-10-13 09:13:56 +0000832 if(flags & APF_LINE_COMMENTS)
833 INDENT("<!-- #line %d -->\n", expr->_lineno);
834 INDENT("<!ELEMENT %s", expr->Identifier);
835
836 if(expr->expr_type == A1TC_REFERENCE) {
837 se = asn1f_find_terminal_type_ex(asn, expr);
838 if(!se) {
Lev Walkinef39f7e2004-10-14 05:11:25 +0000839 printf(" (ANY)");
Lev Walkinf7484512004-10-13 09:13:56 +0000840 return 0;
841 }
842 expr = se;
Lev Walkinef39f7e2004-10-14 05:11:25 +0000843 dont_involve_children = 1;
Lev Walkinf7484512004-10-13 09:13:56 +0000844 }
845
Lev Walkind7963aa2005-03-10 15:16:56 +0000846 if(expr->expr_type == ASN_CONSTR_CHOICE
847 || expr->expr_type == ASN_CONSTR_SEQUENCE_OF
848 || expr->expr_type == ASN_CONSTR_SET_OF
849 || expr->expr_type == ASN_CONSTR_SET
Lev Walkin112d69e2005-03-09 20:52:15 +0000850 || expr->expr_type == ASN_BASIC_INTEGER
851 || expr->expr_type == ASN_BASIC_ENUMERATED) {
852 expr_unordered = 1;
853 }
854
Lev Walkinf7484512004-10-13 09:13:56 +0000855 if(TQ_FIRST(&expr->members)) {
856 int extensible = 0;
857 printf(" (");
858 TQ_FOR(se, &(expr->members), next) {
859 if(se->expr_type == A1TC_EXTENSIBLE) {
860 extensible = 1;
861 continue;
862 } else if(!se->Identifier
863 && se->expr_type == A1TC_REFERENCE) {
864 asn1print_ref(se->reference, flags);
865 } else if(se->Identifier) {
866 printf("%s", se->Identifier);
867 } else {
868 printf("ANY");
869 }
870 if(expr->expr_type != ASN_CONSTR_SET
871 && expr->expr_type != ASN_CONSTR_CHOICE
872 && expr->expr_type != ASN_BASIC_INTEGER
873 && expr->expr_type != ASN_BASIC_ENUMERATED) {
874 if(expr_unordered)
875 printf("*");
876 else if(se->marker.flags)
877 printf("?");
878 }
879 if(TQ_NEXT(se, next)
880 && TQ_NEXT(se, next)->expr_type != A1TC_EXTENSIBLE) {
881 printf(expr_unordered?"|":", ");
882 }
883 }
884 if(extensible) {
885 printf(expr_unordered?"|":", ");
886 printf("ANY");
887 if(expr->expr_type != ASN_CONSTR_SET
888 && expr->expr_type != ASN_CONSTR_CHOICE
889 && expr->expr_type != ASN_BASIC_INTEGER
890 && expr->expr_type != ASN_BASIC_ENUMERATED)
891 printf("*");
892 }
893
894 printf(")");
895 if(expr->expr_type == ASN_CONSTR_SET)
896 printf("*");
897
Lev Walkinef39f7e2004-10-14 05:11:25 +0000898 } else switch(expr->expr_type) {
899 case ASN_BASIC_BOOLEAN:
Lev Walkin112d69e2005-03-09 20:52:15 +0000900 printf(" (true|false)");
Lev Walkinef39f7e2004-10-14 05:11:25 +0000901 break;
902 case ASN_CONSTR_CHOICE:
903 case ASN_CONSTR_SET:
904 case ASN_CONSTR_SET_OF:
905 case ASN_CONSTR_SEQUENCE:
906 case ASN_CONSTR_SEQUENCE_OF:
907 case ASN_BASIC_NULL:
908 case A1TC_UNIVERVAL:
Lev Walkinf7484512004-10-13 09:13:56 +0000909 printf(" EMPTY");
Lev Walkinef39f7e2004-10-14 05:11:25 +0000910 break;
911 case ASN_TYPE_ANY:
912 printf(" ANY");
913 break;
914 case ASN_BASIC_BIT_STRING:
915 case ASN_BASIC_OCTET_STRING:
916 case ASN_BASIC_OBJECT_IDENTIFIER:
917 case ASN_BASIC_RELATIVE_OID:
Lev Walkincc116532004-10-15 06:01:54 +0000918 case ASN_BASIC_INTEGER:
Lev Walkinef39f7e2004-10-14 05:11:25 +0000919 case ASN_BASIC_UTCTime:
920 case ASN_BASIC_GeneralizedTime:
Lev Walkinef39f7e2004-10-14 05:11:25 +0000921 case ASN_STRING_NumericString:
922 case ASN_STRING_PrintableString:
Lev Walkincc116532004-10-15 06:01:54 +0000923 printf(" (#PCDATA)");
Lev Walkinef39f7e2004-10-14 05:11:25 +0000924 break;
925 case ASN_STRING_VisibleString:
926 case ASN_STRING_ISO646String:
927 /* Entity references, but not XML elements may be present */
Lev Walkinf7484512004-10-13 09:13:56 +0000928 printf(" (#PCDATA)");
Lev Walkinef39f7e2004-10-14 05:11:25 +0000929 break;
930 case ASN_BASIC_REAL: /* e.g. <MINUS-INFINITY/> */
931 case ASN_BASIC_ENUMERATED: /* e.g. <enumIdentifier1/> */
932 default:
933 /*
934 * XML elements are allowed.
935 * For example, a UTF8String may contain "<bel/>".
936 */
937 printf(" ANY");
Lev Walkinf7484512004-10-13 09:13:56 +0000938 }
939 printf(">\n");
940
941 /*
942 * Display the descendants (children) of the current type.
943 */
Lev Walkinef39f7e2004-10-14 05:11:25 +0000944 if(!dont_involve_children) {
945 TQ_FOR(se, &(expr->members), next) {
946 if(se->expr_type == A1TC_EXTENSIBLE) continue;
947 asn1print_expr_dtd(asn, mod, se, flags, level + 1);
948 }
Lev Walkinf7484512004-10-13 09:13:56 +0000949 }
950
951 return 0;
952}