]> git.saurik.com Git - apple/security.git/blob - SecuritySNACCRuntime/compiler/core/print2.c
Security-54.tar.gz
[apple/security.git] / SecuritySNACCRuntime / compiler / core / print2.c
1 /*
2 * compiler/core/print.c
3 *
4 * These routines are for printing the information from a Module
5 * Data strucuture in ASN.1 form.
6 *
7 * Useful for debugging the parser and seeing changes caused by
8 * normalization and sorting.
9 *
10 * Mike Sample
11 * Feb 28/91
12 * Copyright (C) 1991, 1992 Michael Sample
13 * and the University of British Columbia
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
19 *
20 * $Header: /cvs/Darwin/Security/SecuritySNACCRuntime/compiler/core/print2.c,v 1.1 2001/06/20 21:27:58 dmitch Exp $
21 * $Log: print2.c,v $
22 * Revision 1.1 2001/06/20 21:27:58 dmitch
23 * Adding missing snacc compiler files.
24 *
25 * Revision 1.1.1.1 1999/03/16 18:06:52 aram
26 * Originals from SMIME Free Library.
27 *
28 * Revision 1.6 1997/02/28 13:39:55 wan
29 * Modifications collected for new version 1.3: Bug fixes, tk4.2.
30 *
31 * Revision 1.5 1995/08/17 14:58:57 rj
32 * minor typographic change
33 *
34 * Revision 1.4 1995/07/25 19:41:42 rj
35 * changed `_' to `-' in file names.
36 *
37 * Revision 1.3 1994/10/08 03:48:53 rj
38 * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long.
39 *
40 * Revision 1.2 1994/09/01 00:42:16 rj
41 * snacc_config.h removed.
42 *
43 * Revision 1.1 1994/08/28 09:49:32 rj
44 * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog.
45 *
46 */
47
48 #include <stdio.h>
49
50 #include "asn-incl.h"
51 #include "asn1module.h"
52 #include "lib-types.h"
53 #include "print.h"
54
55
56 static int indentCountG;
57 static int indentG = 0;
58 static int indentStepG = 4;
59
60 #define INDENT(f, i)\
61 for (indentCountG = 0; indentCountG < (i); indentCountG++)\
62 fputc (' ', (f))\
63
64 /*
65 * Prints the given Module *, mod, to the given FILE *f in
66 * ASN.1 format
67 */
68 void
69 PrintModule PARAMS ((f, mod),
70 FILE *f _AND_
71 Module *mod)
72 {
73
74 if (mod->status == MOD_ERROR)
75 {
76 fprintf (f, "WARNING: this module contains errors\n");
77 fprintf (f,"(probably some type/value is referenced but is not defined or imported)\n");
78 fprintf (f,"The prog. may croak, cross your fingers!\n");
79 }
80
81
82 fprintf (f, "%s ",mod->modId->name);
83 PrintOid (f, mod->modId->oid);
84
85 fprintf (f, "\nDEFINITIONS ");
86
87 if (mod->tagDefault == EXPLICIT_TAGS)
88 fprintf (f, "EXPLICIT TAGS");
89
90 else if (mod->tagDefault == IMPLICIT_TAGS)
91 fprintf (f, "IMPLICIT TAGS");
92 else
93 fprintf (f, "\n\n -- compiler error unknown tag default");
94
95
96 fprintf (f, " ::=\nBEGIN\n\n");
97
98
99
100 PrintExports (f, mod);
101
102 PrintImportLists (f, mod->imports);
103
104 PrintTypeDefs (f, mod->typeDefs);
105 PrintValueDefs (f, mod->valueDefs);
106
107 fprintf (f, "END\n");
108
109 } /* PrintModule */
110
111
112 void
113 PrintExports PARAMS ((f, m),
114 FILE *f _AND_
115 Module *m)
116 {
117 TypeDef *td;
118 ValueDef *vd;
119 int first;
120
121 if (m->exportStatus == EXPORTS_ALL)
122 {
123 fprintf (f, "\n\n-- exports everything\n\n");
124 }
125 else if (m->exportStatus == EXPORTS_NOTHING)
126 {
127 fprintf (f, "\n\nEXPORTS -- exports nothing\n\n");
128 }
129 else
130 {
131 fprintf (f, "\n\nEXPORTS\n");
132 first = 1;
133 FOR_EACH_LIST_ELMT (td, m->typeDefs)
134 if (td->exported)
135 {
136 if (!first)
137 fprintf (f,", ");
138 fprintf (f, "%s", td->definedName);
139 first = 0;
140 }
141
142 FOR_EACH_LIST_ELMT (vd, m->valueDefs)
143 if (vd->exported)
144 {
145 if (!first)
146 fprintf (f,", ");
147 fprintf (f, "%s", vd->definedName);
148 first = 0;
149 }
150
151 fprintf (f, "\n;\n\n");
152 }
153 } /* PrintExports */
154
155
156
157 void
158 PrintOid PARAMS ((f, oid),
159 FILE *f _AND_
160 OID *oid)
161 {
162 int i;
163
164 if (oid == NULL)
165 return;
166
167 fprintf (f, "{ ");
168 for (; oid != NULL; oid = oid->next)
169 {
170 /*
171 * value ref to an integer or if first elmt in
172 * oid can ref other oid value
173 * { id-asdc }
174 */
175 if (oid->valueRef != NULL)
176 PrintValue (f, NULL, NULL, oid->valueRef);
177
178 /*
179 * just "arcNum" format
180 * { 2 }
181 */
182 else if (oid->arcNum != NULL_OID_ARCNUM)
183 fprintf (f, "%d", oid->arcNum);
184
185
186 fprintf (f, " ");
187 }
188 fprintf (f, "}");
189
190 } /* PrintOid */
191
192
193
194 void
195 PrintImportElmt PARAMS ((f, impElmt),
196 FILE *f _AND_
197 ImportElmt *impElmt)
198 {
199 fprintf (f, "%s",impElmt->name);
200 } /* PrintImportElmt */
201
202
203 void
204 PrintImportElmts PARAMS ((f, impElmtList),
205 FILE *f _AND_
206 ImportElmtList *impElmtList)
207 {
208 ImportElmt *ie;
209 ImportElmt *last;
210
211 if ((impElmtList == NULL) || (LIST_EMPTY (impElmtList)))
212 return;
213
214 last = (ImportElmt*)LAST_LIST_ELMT (impElmtList);
215 FOR_EACH_LIST_ELMT (ie, impElmtList)
216 {
217 PrintImportElmt (f, ie);
218
219 if (ie != last)
220 fprintf (f, ", ");
221 }
222
223 } /* PrintImportElmts */
224
225
226
227 void
228 PrintImportLists PARAMS ((f, impLists),
229 FILE *f _AND_
230 ImportModuleList *impLists)
231 {
232 ImportModule *impMod;
233
234 if (impLists == NULL)
235 {
236 fprintf (f,"\n\n-- imports nothing\n\n");
237 return;
238 }
239
240 fprintf (f, "IMPORTS\n\n");
241 FOR_EACH_LIST_ELMT (impMod, impLists)
242 {
243 PrintImportElmts (f, impMod->importElmts);
244
245 fprintf (f, "\n FROM %s ", impMod->modId->name);
246
247 PrintOid (f, impMod->modId->oid);
248
249 fprintf (f, "\n\n\n");
250 }
251 fprintf (f, ";\n\n\n");
252
253 } /* PrintImportLists */
254
255
256
257 void
258 PrintTypeDefs PARAMS ((f, typeDefs),
259 FILE *f _AND_
260 TypeDefList *typeDefs)
261 {
262 TypeDef *td;
263
264 FOR_EACH_LIST_ELMT (td, typeDefs)
265 {
266 if (td->type->basicType->choiceId == BASICTYPE_MACRODEF)
267 PrintMacroDef (f, td);
268 else
269 {
270 fprintf (f,"-- %s notes: ", td->definedName);
271
272 if (td->recursive)
273 fprintf (f,"recursive, ");
274 else
275 fprintf (f,"not recursive, ");
276
277 if (td->exported)
278 fprintf (f,"exported,\n");
279 else
280 fprintf (f,"not exported,\n");
281
282 fprintf (f,"-- locally refd %d times, ", td->localRefCount);
283 fprintf (f,"import refd %d times\n", td->importRefCount);
284
285
286 fprintf (f, "%s ::= ", td->definedName);
287 PrintType (f, td, td->type);
288 }
289 fprintf (f, "\n\n\n");
290 }
291 } /* PrintTypeDefs */
292
293
294
295
296 void
297 PrintType PARAMS ((f, head, t),
298 FILE *f _AND_
299 TypeDef *head _AND_
300 Type *t)
301 {
302 Tag *tag;
303 Tag *lastTag;
304
305 if (t == NULL)
306 return;
307
308 lastTag = NULL;
309 FOR_EACH_LIST_ELMT (tag, t->tags)
310 {
311
312
313
314 if (! ((tag->tclass == UNIV) &&
315 (tag->code == LIBTYPE_GET_UNIV_TAG_CODE (t->basicType->choiceId))))
316 {
317 PrintTag (f, tag);
318 fprintf (f, " ");
319 }
320 lastTag = tag;
321 }
322
323 /*
324 * check type has been implicitly tagged
325 */
326 if (t->implicit)
327 fprintf (f, "IMPLICIT ");
328
329 PrintBasicType (f, head, t, t->basicType);
330
331
332 /*
333 * sequences of and set of print subtypes a special way
334 * so ignore them here
335 */
336 if ((t->subtypes != NULL) &&
337 (t->basicType->choiceId != BASICTYPE_SETOF) &&
338 (t->basicType->choiceId != BASICTYPE_SEQUENCEOF))
339 {
340 fprintf (f," ");
341 PrintSubtype (f, head, t, t->subtypes);
342 }
343
344
345 if (t->defaultVal != NULL)
346 {
347 fprintf (f, " DEFAULT ");
348 if (t->defaultVal->fieldName != NULL)
349 fprintf (f, "%s ", t->defaultVal->fieldName);
350 PrintValue (f, NULL, t, t->defaultVal->value);
351 }
352
353 else if (t->optional)
354 fprintf (f, " OPTIONAL");
355
356
357 #ifdef DEBUG
358 fprintf (f, " -- lineNo = %d --", t->lineNo);
359 #endif
360
361 } /* PrintType */
362
363
364 void
365 PrintBasicType PARAMS ((f, head, t, bt),
366 FILE *f _AND_
367 TypeDef *head _AND_
368 Type *t _AND_
369 BasicType *bt)
370 {
371 switch (bt->choiceId)
372 {
373
374 case BASICTYPE_SEQUENCE:
375 fprintf (f, "SEQUENCE\n");
376 INDENT (f, indentG);
377 fprintf (f,"{\n");
378 indentG += indentStepG;
379 INDENT (f, indentG);
380 PrintElmtTypes (f, head, t, bt->a.sequence);
381 indentG -= indentStepG;
382 fprintf (f, "\n");
383 INDENT (f, indentG);
384 fprintf (f, "}");
385 break;
386
387 case BASICTYPE_SET:
388 fprintf (f, "SET\n");
389 INDENT (f, indentG);
390 fprintf (f,"{\n");
391 indentG += indentStepG;
392 INDENT (f, indentG);
393 PrintElmtTypes (f, head, t, bt->a.set);
394 indentG -= indentStepG;
395 fprintf (f, "\n");
396 INDENT (f, indentG);
397 fprintf (f, "}");
398 break;
399
400 case BASICTYPE_CHOICE:
401 fprintf (f, "CHOICE\n");
402 INDENT (f, indentG);
403 fprintf (f,"{\n");
404 indentG += indentStepG;
405 INDENT (f, indentG);
406 PrintElmtTypes (f, head, t, bt->a.choice);
407 indentG -= indentStepG;
408 fprintf (f, "\n");
409 INDENT (f, indentG);
410 fprintf (f, "}");
411 break;
412
413
414
415 case BASICTYPE_SEQUENCEOF:
416 fprintf (f, "SEQUENCE ");
417 if (t->subtypes != NULL)
418 {
419 PrintSubtype (f, head, t, t->subtypes);
420 fprintf (f," ");
421 }
422 fprintf (f, "OF ");
423 PrintType (f, head, bt->a.sequenceOf);
424 break;
425
426 case BASICTYPE_SETOF:
427 fprintf (f, "SET ");
428 if (t->subtypes != NULL)
429 {
430 PrintSubtype (f, head, t, t->subtypes);
431 fprintf (f," ");
432 }
433 fprintf (f, "OF ");
434 PrintType (f, head, bt->a.setOf);
435 break;
436
437
438 case BASICTYPE_SELECTION:
439 fprintf (f, "%s < ", bt->a.selection->fieldName);
440 PrintType (f, head, bt->a.selection->typeRef);
441 break;
442
443
444
445
446 case BASICTYPE_COMPONENTSOF:
447 fprintf (f, "COMPONENTS OF ");
448 PrintType (f, NULL, bt->a.componentsOf);
449 break;
450
451
452
453 case BASICTYPE_ANYDEFINEDBY:
454 fprintf (f, "ANY DEFINED BY %s", bt->a.anyDefinedBy->fieldName);
455 break;
456
457
458 case BASICTYPE_LOCALTYPEREF:
459 fprintf (f, "%s", bt->a.localTypeRef->typeName);
460 break;
461
462 case BASICTYPE_IMPORTTYPEREF:
463 /* attempt to keep special scoping, ie modname.type forms */
464 if (bt->a.importTypeRef->moduleName != NULL)
465 fprintf (f,"%s.", bt->a.importTypeRef->moduleName);
466 fprintf (f, "%s", bt->a.importTypeRef->typeName);
467 break;
468
469
470 case BASICTYPE_UNKNOWN:
471 fprintf (f, "unknown type !?!");
472 break;
473
474 case BASICTYPE_BOOLEAN:
475 fprintf (f, "BOOLEAN");
476 break;
477
478
479 case BASICTYPE_INTEGER:
480 fprintf (f, "INTEGER");
481 if ((bt->a.integer != NULL) && !LIST_EMPTY (bt->a.integer))
482 {
483 fprintf (f, "\n");
484 INDENT (f, indentG);
485 fprintf (f, "{\n");
486 indentG += indentStepG;
487 PrintNamedElmts (f, head, t, bt->a.integer);
488 indentG -= indentStepG;
489 fprintf (f, "\n");
490 INDENT (f, indentG);
491 fprintf (f, "}");
492 }
493 break;
494
495
496 case BASICTYPE_BITSTRING:
497 fprintf (f, "BIT STRING");
498 if ((bt->a.bitString != NULL) && !LIST_EMPTY (bt->a.bitString))
499 {
500 fprintf (f, "\n");
501 INDENT (f, indentG);
502 fprintf (f, "{\n");
503 indentG += indentStepG;
504 PrintNamedElmts (f, head, t, bt->a.bitString);
505 indentG -= indentStepG;
506 fprintf (f, "\n");
507 INDENT (f, indentG);
508 fprintf (f, "}");
509 }
510 break;
511
512 case BASICTYPE_OCTETSTRING:
513 fprintf (f, "OCTET STRING");
514 break;
515
516 case BASICTYPE_NULL:
517 fprintf (f, "NULL");
518 break;
519
520 case BASICTYPE_OID:
521 fprintf (f, "OBJECT IDENTIFIER");
522 break;
523
524 case BASICTYPE_REAL:
525 fprintf (f, "REAL");
526 break;
527
528 case BASICTYPE_ENUMERATED:
529 fprintf (f, "ENUMERATED");
530 if ((bt->a.enumerated != NULL) && !LIST_EMPTY (bt->a.enumerated))
531 {
532 fprintf (f, "\n");
533 INDENT (f, indentG);
534 fprintf (f, "{\n");
535 indentG += indentStepG;
536 PrintNamedElmts (f, head, t, bt->a.enumerated);
537 indentG -= indentStepG;
538 fprintf (f, "\n");
539 INDENT (f, indentG);
540 fprintf (f, "}");
541 }
542 break;
543
544 case BASICTYPE_ANY:
545 fprintf (f, "ANY");
546 break;
547
548 case BASICTYPE_MACROTYPE:
549 switch (bt->a.macroType->choiceId)
550 {
551 case MACROTYPE_ROSOPERATION:
552 case MACROTYPE_ASNABSTRACTOPERATION:
553 PrintRosOperationMacroType (f, head, t, bt, bt->a.macroType->a.rosOperation);
554 break;
555
556 case MACROTYPE_ROSERROR:
557 case MACROTYPE_ASNABSTRACTERROR:
558 PrintRosErrorMacroType (f, head, t, bt, bt->a.macroType->a.rosError);
559 break;
560
561 case MACROTYPE_ROSBIND:
562 case MACROTYPE_ROSUNBIND:
563 PrintRosBindMacroType (f, head, t, bt, bt->a.macroType->a.rosBind);
564 break;
565
566 case MACROTYPE_ROSASE:
567 PrintRosAseMacroType (f, head, t, bt, bt->a.macroType->a.rosAse);
568 break;
569
570 case MACROTYPE_MTSASEXTENSIONS:
571 PrintMtsasExtensionsMacroType (f, head, t, bt, bt->a.macroType->a.mtsasExtensions);
572 break;
573
574 case MACROTYPE_MTSASEXTENSION:
575 PrintMtsasExtensionMacroType (f, head, t, bt, bt->a.macroType->a.mtsasExtension);
576 break;
577
578 case MACROTYPE_MTSASEXTENSIONATTRIBUTE:
579 PrintMtsasExtensionAttributeMacroType (f, head, t, bt, bt->a.macroType->a.mtsasExtensionAttribute);
580 break;
581
582 case MACROTYPE_MTSASTOKEN:
583 PrintMtsasTokenMacroType (f, head, t, bt, bt->a.macroType->a.mtsasToken);
584 break;
585
586 case MACROTYPE_MTSASTOKENDATA:
587 PrintMtsasTokenDataMacroType (f, head, t, bt, bt->a.macroType->a.mtsasTokenData);
588 break;
589
590 case MACROTYPE_MTSASSECURITYCATEGORY:
591 PrintMtsasSecurityCategoryMacroType (f, head, t, bt, bt->a.macroType->a.mtsasSecurityCategory);
592 break;
593
594 case MACROTYPE_ASNOBJECT:
595 PrintAsnObjectMacroType (f, head, t, bt, bt->a.macroType->a.asnObject);
596 break;
597
598 case MACROTYPE_ASNPORT:
599 PrintAsnPortMacroType (f, head, t, bt, bt->a.macroType->a.asnPort);
600 break;
601
602 case MACROTYPE_ASNABSTRACTBIND:
603 case MACROTYPE_ASNABSTRACTUNBIND:
604 PrintAsnAbstractBindMacroType (f, head, t, bt, bt->a.macroType->a.asnAbstractBind);
605 break;
606
607 case MACROTYPE_AFALGORITHM:
608 PrintAfAlgorithmMacroType (f, head, t, bt, bt->a.macroType->a.afAlgorithm);
609 break;
610
611 case MACROTYPE_AFENCRYPTED:
612 PrintAfEncryptedMacroType (f, head, t, bt, bt->a.macroType->a.afEncrypted);
613 break;
614
615 case MACROTYPE_AFSIGNED:
616 PrintAfSignedMacroType (f, head, t, bt, bt->a.macroType->a.afSigned);
617 break;
618
619 case MACROTYPE_AFSIGNATURE:
620 PrintAfSignatureMacroType (f, head, t, bt, bt->a.macroType->a.afSignature);
621 break;
622
623 case MACROTYPE_AFPROTECTED:
624 PrintAfProtectedMacroType (f, head, t, bt, bt->a.macroType->a.afProtected);
625 break;
626
627 case MACROTYPE_SNMPOBJECTTYPE:
628 PrintSnmpObjectTypeMacroType (f, head, t, bt, bt->a.macroType->a.snmpObjectType);
629 break;
630
631 default:
632 fprintf (f, "< unknown macro type id ?! >");
633
634 } /* end macro type switch */
635 break;
636
637 /*
638 * @MACRO@ add new macro printers above this point
639 */
640
641 case BASICTYPE_MACRODEF:
642 /*
643 * printing this should be handled in PrintTypeDefs
644 */
645 break;
646
647
648 default:
649 fprintf (f, "< unknown type id ?! >");
650
651 }
652 } /* PrintBasicType */
653
654
655
656 void
657 PrintElmtType PARAMS ((f, head, t, nt),
658 FILE *f _AND_
659 TypeDef *head _AND_
660 Type *t _AND_
661 NamedType *nt)
662 {
663 if (nt->fieldName != NULL)
664 fprintf (f, "%s ", nt->fieldName);
665
666 PrintType (f, head, nt->type);
667
668 } /* PrintElmtType */
669
670 void
671 PrintElmtTypes PARAMS ((f, head, t, e),
672 FILE *f _AND_
673 TypeDef *head _AND_
674 Type *t _AND_
675 NamedTypeList *e)
676 {
677 NamedType *nt;
678 NamedType *last;
679
680 if ((e == NULL) || LIST_EMPTY (e))
681 return;
682
683 last = (NamedType*)LAST_LIST_ELMT (e);
684 FOR_EACH_LIST_ELMT (nt, e)
685 {
686
687 PrintElmtType (f, head, t, nt);
688 if (nt != last)
689 {
690 fprintf (f, ",\n");
691 INDENT (f, indentG);
692 }
693 }
694 } /* PrintElmtTypes */
695
696
697
698
699 void
700 PrintValueDefs PARAMS ((f, vList),
701 FILE *f _AND_
702 ValueDefList *vList)
703 {
704 ValueDef *v;
705 FOR_EACH_LIST_ELMT (v, vList)
706 {
707 PrintValueDef (f, v);
708 }
709 } /* PrintValueDefs */
710
711
712 void
713 PrintValueDef PARAMS ((f, v),
714 FILE *f _AND_
715 ValueDef *v)
716 {
717 fprintf (f, "%s ", v->definedName);
718
719 if (v->value->type != NULL)
720 PrintType (f, NULL, v->value->type);
721 else
722 /* just go by valueType */
723 PrintTypeById (f, v->value->valueType);
724
725 fprintf (f, " ::= ");
726 indentG += indentStepG;
727 PrintValue (f, v, v->value->type, v->value);
728 fprintf (f, "\n\n");
729 indentG -= indentStepG;
730 } /* PrintValueDef */
731
732
733 void
734 PrintValue PARAMS ((f, head, valuesType, v),
735 FILE *f _AND_
736 ValueDef *head _AND_
737 Type *valuesType _AND_
738 Value *v)
739 {
740 if (v == NULL)
741 return;
742
743 PrintBasicValue (f, head, valuesType, v, v->basicValue);
744
745 } /* PrintValue */
746
747
748 void
749 PrintBasicValue PARAMS ((f, head, valuesType, v, bv),
750 FILE *f _AND_
751 ValueDef *head _AND_
752 Type *valuesType _AND_
753 Value *v _AND_
754 BasicValue *bv)
755 {
756 if (v == NULL)
757 return;
758
759
760 switch (bv->choiceId)
761 {
762 case BASICVALUE_UNKNOWN:
763 fprintf (f, "<unknown value>");
764 break;
765
766 case BASICVALUE_EMPTY:
767 fprintf (f,"{ }");
768 break;
769
770 case BASICVALUE_INTEGER:
771 fprintf (f, "%d", bv->a.integer);
772 break;
773
774 case BASICVALUE_SPECIALINTEGER:
775 if (bv->a.specialInteger == MAX_INT)
776 fprintf (f, "MAX");
777 else
778 fprintf (f, "MIN");
779
780 break;
781
782 case BASICVALUE_BOOLEAN:
783 if (bv->a.boolean)
784 fprintf (f,"TRUE");
785 else
786 fprintf (f,"FALSE");
787 break;
788
789 case BASICVALUE_REAL:
790 fprintf (f, "%f", bv->a.real);
791 break;
792
793 case BASICVALUE_SPECIALREAL:
794 if (bv->a.specialReal == PLUS_INFINITY_REAL)
795 fprintf (f, "PLUS INFINITY");
796 else
797 fprintf (f, "MINUS INFINITY");
798
799 break;
800
801 case BASICVALUE_ASCIITEXT:
802 fprintf (f, "\"%s\"", bv->a.asciiText->octs);
803 break;
804
805 case BASICVALUE_ASCIIHEX:
806 fprintf (f, "\"%s\"", bv->a.asciiHex->octs);
807 break;
808
809 case BASICVALUE_ASCIIBITSTRING:
810 fprintf (f, "\"%s\"", bv->a.asciiBitString->octs);
811 break;
812
813 case BASICVALUE_OID:
814 PrintEncodedOid (f, bv->a.oid);
815 break;
816
817 case BASICVALUE_LINKEDOID:
818 PrintOid (f, bv->a.linkedOid);
819 break;
820
821 case BASICVALUE_BERVALUE:
822 fprintf (f,"<PrintBerValue not coded yet");
823 break;
824
825 case BASICVALUE_PERVALUE:
826 fprintf (f,"<PrintPerValue not coded yet");
827 break;
828
829 case BASICVALUE_NAMEDVALUE:
830 fprintf (f, "\n");
831 INDENT (f, indentG);
832 fprintf (f,"{\n");
833 indentG += indentStepG;
834 PrintElmtValue (f, head, v, bv->a.namedValue);
835 indentG -= indentStepG;
836 fprintf (f,"\n");
837 INDENT (f, indentG);
838 fprintf (f,"}");
839 break;
840
841 case BASICVALUE_NULL:
842 fprintf (f,"NULL");
843 break;
844
845 case BASICVALUE_LOCALVALUEREF:
846 fprintf (f, "%s", bv->a.localValueRef->valueName);
847 break;
848
849 case BASICVALUE_IMPORTVALUEREF:
850 fprintf (f, "%s", bv->a.importValueRef->valueName);
851 break;
852
853 case BASICVALUE_VALUENOTATION:
854 fprintf (f, "-- snacc warning: can't parse this value yet --");
855 fprintf (f, "%s", bv->a.valueNotation->octs);
856 break;
857
858
859 default:
860 fprintf (stderr,"PrintBasicValue: ERROR - unknown value type\n");
861 }
862
863 } /* PrintBasicValue */
864
865
866 void
867 PrintElmtValue PARAMS ((f, head, v, nv),
868 FILE *f _AND_
869 ValueDef *head _AND_
870 Value *v _AND_
871 NamedValue *nv)
872 {
873 if (nv->fieldName != NULL)
874 fprintf (f, "%s ", nv->fieldName);
875
876 PrintValue (f, NULL, NULL, nv->value);
877 } /* PrintElmtValue */
878
879
880 void
881 PrintElmtValues PARAMS ((f, head, v, e),
882 FILE *f _AND_
883 ValueDef *head _AND_
884 Value *v _AND_
885 NamedValueList *e)
886 {
887 NamedValue *nv;
888 NamedValue *last;
889
890 if ((e == NULL) || LIST_EMPTY (e))
891 return;
892
893 last = (NamedValue*)LAST_LIST_ELMT (e);
894 FOR_EACH_LIST_ELMT (nv, e)
895 {
896 PrintElmtValue (f, head, v, nv);
897 if (nv != last)
898 {
899 fprintf (f, ",\n");
900 INDENT (f, indentG);
901 }
902 }
903 } /* PrintElmtValues */
904
905
906 void
907 PrintTypeById PARAMS ((f, typeId),
908 FILE *f _AND_
909 int typeId)
910 {
911 switch (typeId)
912 {
913 case BASICTYPE_UNKNOWN:
914 fprintf (f, "UNKNOWN");
915 break;
916
917 case BASICTYPE_BOOLEAN:
918 fprintf (f, "BOOLEAN");
919 break;
920
921 case BASICTYPE_INTEGER:
922 fprintf (f, "INTEGER");
923 break;
924
925 case BASICTYPE_BITSTRING:
926 fprintf (f, "BIT STRING");
927 break;
928
929 case BASICTYPE_OCTETSTRING:
930 fprintf (f, "OCTET STRING");
931 break;
932
933
934 case BASICTYPE_NULL:
935 fprintf (f, "NULL");
936 break;
937
938 case BASICTYPE_SEQUENCE:
939 fprintf (f, "SEQUENCE");
940 break;
941
942 case BASICTYPE_SEQUENCEOF:
943 fprintf (f, "SEQUENCE OF");
944 break;
945
946 case BASICTYPE_SET:
947 fprintf (f, "SET");
948 break;
949
950 case BASICTYPE_SETOF:
951 fprintf (f, "SET OF");
952 break;
953
954 case BASICTYPE_CHOICE:
955 fprintf (f, "CHOICE");
956 break;
957
958 case BASICTYPE_SELECTION:
959 fprintf (f, "SELECTION");
960 break;
961
962 case BASICTYPE_ANY:
963 fprintf (f, "ANY");
964 break;
965
966 case BASICTYPE_ANYDEFINEDBY:
967 fprintf (f, "ANY DEFINED BY");
968 break;
969
970 case BASICTYPE_OID:
971 fprintf (f, "OBJECT IDENTIFIER");
972 break;
973
974 case BASICTYPE_ENUMERATED:
975 fprintf (f, "ENUMERATED");
976 break;
977
978 case BASICTYPE_REAL:
979 fprintf (f, "REAL");
980 break;
981
982 case BASICTYPE_COMPONENTSOF:
983 fprintf (f, "COMPONENTS OF");
984 break;
985
986 default:
987 fprintf (f, "ERROR - %d is an unknown type id\n", typeId);
988 }
989 } /* PrintTypeById */
990
991
992 void
993 PrintTag PARAMS ((f, tag),
994 FILE *f _AND_
995 Tag *tag)
996 {
997 char *name=NULL;
998
999 if (tag->tclass == UNIV)
1000 {
1001 switch (tag->code)
1002 {
1003 case BOOLEAN_TAG_CODE: name = "BOOLEAN";
1004 break;
1005 case INTEGER_TAG_CODE: name = "INTEGER";
1006 break;
1007 case BITSTRING_TAG_CODE: name = "BITSTRING";
1008 break;
1009 case OCTETSTRING_TAG_CODE: name = "OCTETSTRING";
1010 break;
1011 case NULLTYPE_TAG_CODE: name = "NULL TYPE";
1012 break;
1013 case OID_TAG_CODE: name = "OBJECT ID";
1014 break;
1015 case OD_TAG_CODE: name = "OBEJECT DESCRIPTOR";
1016 break;
1017 case EXTERNAL_TAG_CODE: name = "EXTERNAL";
1018 break;
1019 case REAL_TAG_CODE: name = "REAL";
1020 break;
1021 case ENUM_TAG_CODE: name = "ENUMERATED";
1022 break;
1023 case SEQ_TAG_CODE: name = "SEQUENCE";
1024 break;
1025 case SET_TAG_CODE: name = "SET";
1026 break;
1027 case NUMERICSTRING_TAG_CODE: name = "NUMERIC STRING";
1028 break;
1029 case PRINTABLESTRING_TAG_CODE: name = "PRINTABLE STRING";
1030 break;
1031 case TELETEXSTRING_TAG_CODE: name = "TELETEX STRING";
1032 break;
1033 case VIDEOTEXSTRING_TAG_CODE: name = "VIDEOTEX STRING";
1034 break;
1035 case IA5STRING_TAG_CODE: name = "IA5 STRING";
1036 break;
1037 case UTCTIME_TAG_CODE: name = "UTC TIME";
1038 break;
1039 case GENERALIZEDTIME_TAG_CODE: name = "GENERALIZED TIME";
1040 break;
1041 case GRAPHICSTRING_TAG_CODE: name = "GRAPHIC STRING";
1042 break;
1043 case VISIBLESTRING_TAG_CODE: name = "VISIBLE STRING";
1044 break;
1045 case GENERALSTRING_TAG_CODE: name = "GENERAL STRING";
1046 break;
1047
1048 default: name = "UNKNOWN UNIVERSAL TYPE";
1049 }
1050 fprintf (f, "[UNIVERSAL %d]", tag->code);
1051 }
1052 else if (tag->tclass == APPL)
1053 {
1054 fprintf (f, "[APPLICATION %d]", tag->code);
1055 }
1056 else if (tag->tclass == PRIV)
1057 {
1058 fprintf (f, "[PRIVATE %d]", tag->code);
1059 }
1060 else if (tag->tclass == CNTX)
1061 {
1062 fprintf (f, "[%d]", tag->code);
1063 }
1064
1065 if (tag->explicit)
1066 fprintf (f, " EXPLICIT");
1067
1068 } /* PrintTag */
1069
1070
1071 void
1072 PrintSubtype PARAMS ((f, head, t, s),
1073 FILE *f _AND_
1074 TypeDef *head _AND_
1075 Type *t _AND_
1076 Subtype *s)
1077 {
1078 Subtype *tmpS;
1079 Subtype *last;
1080
1081 if (s == NULL)
1082 return;
1083
1084 /* fprintf (f, "("); */
1085
1086 switch (s->choiceId)
1087 {
1088 case SUBTYPE_SINGLE:
1089 PrintSubtypeValue (f, head, t, s->a.single);
1090 break;
1091
1092 case SUBTYPE_AND:
1093 FOR_EACH_LIST_ELMT (tmpS, s->a.and)
1094 {
1095 fprintf (f, "(");
1096 PrintSubtype (f, head, t, tmpS);
1097 fprintf (f, ")");
1098 }
1099 break;
1100
1101
1102 case SUBTYPE_OR:
1103 if ((s->a.or != NULL) && !LIST_EMPTY (s->a.or))
1104 last = (Subtype*)LAST_LIST_ELMT (s->a.or);
1105 FOR_EACH_LIST_ELMT (tmpS, s->a.or)
1106 {
1107 fprintf (f, "(");
1108 PrintSubtype (f, head, t, tmpS);
1109 fprintf (f, ")");
1110 if (tmpS != last)
1111 fprintf (f, " | ");
1112 }
1113 break;
1114
1115 case SUBTYPE_NOT:
1116 fprintf (f, "NOT (");
1117 PrintSubtype (f, head, t, s->a.not);
1118 fprintf (f, ")");
1119 break;
1120
1121 default:
1122 fprintf (stderr, "PrintSubtype: ERROR - unknown Subtypes choiceId\n");
1123 break;
1124 }
1125
1126 /* fprintf (f, ")"); */
1127
1128
1129 } /* PrintSubtype */
1130
1131
1132
1133 void
1134 PrintSubtypeValue PARAMS ((f, head, t, s),
1135 FILE *f _AND_
1136 TypeDef *head _AND_
1137 Type *t _AND_
1138 SubtypeValue *s)
1139 {
1140 if (s == NULL)
1141 return;
1142
1143 switch (s->choiceId)
1144 {
1145 case SUBTYPEVALUE_SINGLEVALUE:
1146 PrintValue (f, NULL, NULL, s->a.singleValue);
1147 break;
1148
1149 case SUBTYPEVALUE_CONTAINED:
1150 fprintf (f, "<PrintContainedSubtype not coded yet\n");
1151 break;
1152
1153 case SUBTYPEVALUE_VALUERANGE:
1154 PrintValue (f, NULL, NULL, s->a.valueRange->lowerEndValue);
1155 if (!s->a.valueRange->lowerEndInclusive)
1156 fprintf (f, " >");
1157 fprintf (f,"..");
1158 if (!s->a.valueRange->upperEndInclusive)
1159 fprintf (f, "< ");
1160 PrintValue (f, NULL, NULL, s->a.valueRange->upperEndValue);
1161 break;
1162
1163
1164 case SUBTYPEVALUE_PERMITTEDALPHABET:
1165 fprintf (f,"FROM ");
1166 PrintSubtype (f, head, t, s->a.permittedAlphabet);
1167 break;
1168
1169 case SUBTYPEVALUE_SIZECONSTRAINT:
1170 fprintf (f,"SIZE ");
1171 PrintSubtype (f, head, t, s->a.sizeConstraint);
1172 break;
1173
1174 case SUBTYPEVALUE_INNERSUBTYPE:
1175 PrintInnerSubtype (f, head, t, s->a.innerSubtype);
1176 break;
1177
1178 default:
1179 fprintf (stderr, "PrintSubtype: ERROR - unknown Subtype choiceId\n");
1180 break;
1181 }
1182 } /* PrintSubtype */
1183
1184
1185 void
1186 PrintInnerSubtype PARAMS ((f, head, t, i),
1187 FILE *f _AND_
1188 TypeDef *head _AND_
1189 Type *t _AND_
1190 InnerSubtype *i)
1191 {
1192 Constraint *constraint;
1193 if (i->constraintType == SINGLE_CT)
1194 {
1195 fprintf (f,"WITH COMPONENT ");
1196 constraint = *(Constraint**)AsnListFirst (i->constraints);
1197 PrintSubtype (f, head, t, constraint->valueConstraints);
1198 }
1199 else
1200 {
1201 fprintf (f, "WITH COMPONENTS\n");
1202 INDENT (f, indentG);
1203 fprintf (f, "{\n");
1204 indentG += indentStepG;
1205 if (i->constraintType == PARTIAL_CT)
1206 {
1207 INDENT (f, indentG);
1208 fprintf (f, "...,\n");
1209 }
1210 PrintMultipleTypeConstraints (f, head, t, i->constraints);
1211 indentG -= indentStepG;
1212 fprintf (f, "\n");
1213 INDENT (f, indentG);
1214 fprintf (f, "}");
1215
1216 }
1217 } /* PrintInnerSubtype */
1218
1219
1220
1221 void
1222 PrintMultipleTypeConstraints PARAMS ((f, head, t, cList),
1223 FILE *f _AND_
1224 TypeDef *head _AND_
1225 Type *t _AND_
1226 ConstraintList *cList)
1227 {
1228 Constraint *c;
1229 Constraint *last;
1230
1231 if ((cList == NULL) || LIST_EMPTY (cList))
1232 return;
1233
1234 last = (Constraint*)LAST_LIST_ELMT (cList);
1235 FOR_EACH_LIST_ELMT (c, cList)
1236 {
1237 if (c->fieldRef != NULL)
1238 {
1239 INDENT (f, indentG);
1240 fprintf (f, "%s ", c->fieldRef);
1241 }
1242
1243
1244 PrintSubtype (f, head, t, c->valueConstraints);
1245
1246 if (c->presenceConstraint == ABSENT_CT)
1247 fprintf (f, " ABSENT");
1248 if (c->presenceConstraint == PRESENT_CT)
1249 fprintf (f, " PRESENT");
1250 if (c->presenceConstraint == OPTIONAL_CT)
1251 fprintf (f, " OPTIONAL");
1252
1253 if (c != last)
1254 fprintf (f, ",\n");
1255
1256 }
1257 } /* PrintMultipleTypeConstraints */
1258
1259
1260
1261 void
1262 PrintNamedElmts PARAMS ((f, head, t, n),
1263 FILE *f _AND_
1264 TypeDef *head _AND_
1265 Type *t _AND_
1266 ValueDefList *n)
1267 {
1268 ValueDef *vd;
1269 ValueDef *last;
1270
1271 if ((n == NULL) || LIST_EMPTY (n))
1272 return;
1273
1274 last = (ValueDef*)LAST_LIST_ELMT (n);
1275 FOR_EACH_LIST_ELMT (vd, n)
1276 {
1277 INDENT (f, indentG);
1278 fprintf (f, "%s (", vd->definedName);
1279 PrintValue (f, NULL, NULL, vd->value);
1280 fprintf (f,")");
1281 if (vd != last)
1282 fprintf (f,",\n");
1283 }
1284 } /* PrintNamedElmts */
1285
1286
1287
1288
1289 void
1290 PrintRosOperationMacroType PARAMS ((f, head, t, bt, op),
1291 FILE *f _AND_
1292 TypeDef *head _AND_
1293 Type *t _AND_
1294 BasicType *bt _AND_
1295 RosOperationMacroType *op)
1296 {
1297 TypeOrValue *tOrV;
1298 TypeOrValue *last;
1299
1300 if (bt->a.macroType->choiceId == MACROTYPE_ROSOPERATION)
1301 fprintf (f, "OPERATION");
1302 else
1303 fprintf (f, "ABSTRACT-OPERATION");
1304
1305 indentG += indentStepG;
1306 if (op->arguments != NULL)
1307 {
1308 fprintf (f,"\n");
1309 INDENT (f, indentG);
1310 fprintf (f, "ARGUMENT\n");
1311 indentG += indentStepG;
1312
1313 INDENT (f, indentG);
1314
1315 if (op->arguments->fieldName != NULL)
1316 fprintf (f, "%s ", op->arguments->fieldName);
1317
1318 PrintType (f, head, op->arguments->type);
1319 indentG -= indentStepG;
1320 }
1321
1322 if (op->result != NULL)
1323 {
1324 fprintf (f,"\n");
1325 INDENT (f, indentG);
1326 fprintf (f, "RESULT\n");
1327 indentG += indentStepG;
1328
1329 INDENT (f, indentG);
1330
1331 if (op->arguments->fieldName != NULL)
1332 fprintf (f, "%s ", op->arguments->fieldName);
1333
1334 PrintType (f, head, op->result->type);
1335 indentG -= indentStepG;
1336 }
1337
1338 if ((op->errors == NULL) || (!LIST_EMPTY (op->errors)))
1339 {
1340 fprintf (f,"\n");
1341 INDENT (f, indentG);
1342 fprintf (f, "ERRORS\n");
1343 INDENT (f, indentG);
1344 fprintf (f,"{\n");
1345 indentG += indentStepG;
1346
1347 last = (TypeOrValue*)LAST_LIST_ELMT (op->errors);
1348 FOR_EACH_LIST_ELMT (tOrV, op->errors)
1349 {
1350 INDENT (f, indentG);
1351 if (tOrV->choiceId == TYPEORVALUE_TYPE)
1352 PrintType (f, head, tOrV->a.type);
1353 else
1354 PrintValue (f, NULL, t, tOrV->a.value);
1355
1356 if (tOrV != last)
1357 fprintf (f, ",\n");
1358
1359 }
1360 indentG -= indentStepG;
1361 fprintf (f,"\n");
1362 INDENT (f, indentG);
1363 fprintf (f, "}");
1364 }
1365
1366 if ((op->linkedOps != NULL) && (!LIST_EMPTY (op->linkedOps)))
1367 {
1368 fprintf (f,"\n");
1369 INDENT (f, indentG);
1370 fprintf (f, "LINKED\n");
1371 INDENT (f, indentG);
1372 fprintf (f,"{\n");
1373 indentG += indentStepG;
1374
1375 last = (TypeOrValue*)LAST_LIST_ELMT (op->linkedOps);
1376 FOR_EACH_LIST_ELMT (tOrV, op->linkedOps)
1377 {
1378 INDENT (f, indentG);
1379 if (tOrV->choiceId == TYPEORVALUE_TYPE)
1380 PrintType (f, head, tOrV->a.type);
1381 else
1382 PrintValue (f, NULL, t, tOrV->a.value);
1383
1384 if (tOrV != last)
1385 fprintf (f, ",\n");
1386 }
1387 indentG -= indentStepG;
1388 fprintf (f,"\n");
1389 INDENT (f, indentG);
1390 fprintf (f, " }");
1391 }
1392
1393 indentG -= indentStepG;
1394
1395 } /* PrintRosOperationMacroType */
1396
1397
1398
1399 void
1400 PrintRosErrorMacroType PARAMS ((f, head, t, bt, err),
1401 FILE *f _AND_
1402 TypeDef *head _AND_
1403 Type *t _AND_
1404 BasicType *bt _AND_
1405 RosErrorMacroType *err)
1406 {
1407 if (bt->a.macroType->choiceId == MACROTYPE_ROSERROR)
1408 fprintf (f,"ERROR\n");
1409 else
1410 fprintf (f,"ABSTRACT-ERROR\n");
1411
1412 indentG += indentStepG;
1413
1414 if (err->parameter != NULL)
1415 {
1416 INDENT (f, indentG);
1417 fprintf (f,"PARAMETER ");
1418 indentG += indentStepG;
1419 PrintElmtType (f, head, t, err->parameter);
1420 indentG -= indentStepG;
1421 }
1422 indentG -= indentStepG;
1423
1424 } /* PrintRosErrorMacroType */
1425
1426
1427 void
1428 PrintRosBindMacroType PARAMS ((f, head, t, bt, bind),
1429 FILE *f _AND_
1430 TypeDef *head _AND_
1431 Type *t _AND_
1432 BasicType *bt _AND_
1433 RosBindMacroType *bind)
1434 {
1435 if (bt->a.macroType->choiceId == MACROTYPE_ROSBIND)
1436 fprintf (f,"BIND");
1437 else
1438 fprintf (f,"UNBIND");
1439
1440 indentG += indentStepG;
1441
1442 if (bind->argument != NULL)
1443 {
1444 fprintf (f, "\n");
1445 INDENT (f, indentG);
1446 fprintf (f,"ARGUMENT\n");
1447 indentG += indentStepG;
1448 INDENT (f, indentG);
1449 PrintElmtType (f, head, t, bind->argument);
1450 indentG -= indentStepG;
1451 }
1452
1453 if (bind->result != NULL)
1454 {
1455 fprintf (f, "\n");
1456 INDENT (f, indentG);
1457 fprintf (f,"RESULT\n");
1458 indentG += indentStepG;
1459 INDENT (f, indentG);
1460 PrintElmtType (f, head, t, bind->result);
1461 indentG -= indentStepG;
1462 }
1463
1464 if (bind->error != NULL)
1465 {
1466 fprintf (f, "\n");
1467 INDENT (f, indentG);
1468 if (bt->a.macroType->choiceId == MACROTYPE_ROSBIND)
1469 fprintf (f,"BIND-ERROR\n");
1470 else
1471 fprintf (f,"UNBIND-ERROR\n");
1472
1473 indentG += indentStepG;
1474 INDENT (f, indentG);
1475 PrintElmtType (f, head, t, bind->error);
1476 indentG -= indentStepG;
1477 }
1478
1479 indentG -= indentStepG;
1480
1481 } /* PrintRosBindMacroType */
1482
1483
1484 void
1485 PrintRosAseMacroType PARAMS ((f, head, t, bt, ase),
1486 FILE *f _AND_
1487 TypeDef *head _AND_
1488 Type *t _AND_
1489 BasicType *bt _AND_
1490 RosAseMacroType *ase)
1491 {
1492 Value *v;
1493 Value *last;
1494
1495 fprintf (f, "APPLICATION-SERVICE-ELEMENT");
1496 indentG += indentStepG;
1497
1498 if ((ase->operations != NULL)&& (!LIST_EMPTY (ase->operations)))
1499 {
1500 fprintf (f,"\n");
1501 INDENT (f, indentG);
1502 fprintf (f,"OPERATIONS\n");
1503 INDENT (f, indentG);
1504 fprintf (f, "{\n");
1505
1506 indentG += indentStepG;
1507
1508 last = (Value*)LAST_LIST_ELMT (ase->operations);
1509 FOR_EACH_LIST_ELMT (v, ase->operations)
1510 {
1511 INDENT (f, indentG);
1512 PrintValue (f, NULL, t, v);
1513 if (v != last)
1514 fprintf (f, ",\n");
1515 }
1516 fprintf (f, "\n");
1517 indentG -= indentStepG;
1518 INDENT (f, indentG);
1519 fprintf (f, "}");
1520 }
1521
1522 else /* either suuplier invokes or consumer invokes will be valid */
1523 {
1524 if ((ase->consumerInvokes != NULL) && (!LIST_EMPTY (ase->consumerInvokes)))
1525 {
1526 fprintf (f,"\n");
1527 INDENT (f, indentG);
1528 fprintf (f,"CONSUMER INVOKES\n");
1529 INDENT (f, indentG);
1530 fprintf (f, "{\n");
1531
1532 indentG += indentStepG;
1533 last = (Value*) LAST_LIST_ELMT (ase->consumerInvokes);
1534 FOR_EACH_LIST_ELMT (v, ase->consumerInvokes)
1535 {
1536 INDENT (f, indentG);
1537 PrintValue (f, NULL, t, v);
1538 if (v != last)
1539 fprintf (f, ",\n");
1540 }
1541 fprintf (f, "\n");
1542 indentG -= indentStepG;
1543 INDENT (f, indentG);
1544 fprintf (f, "}");
1545 }
1546 if ((ase->operations != NULL) && (!LIST_EMPTY (ase->operations)))
1547 {
1548 fprintf (f,"\n");
1549 INDENT (f, indentG);
1550 fprintf (f,"SUPPLIER INVOKES\n");
1551 INDENT (f, indentG);
1552 fprintf (f, "{\n");
1553
1554 indentG += indentStepG;
1555 last = (Value*)LAST_LIST_ELMT (ase->supplierInvokes);
1556 FOR_EACH_LIST_ELMT (v, ase->supplierInvokes)
1557 {
1558 INDENT (f, indentG);
1559 PrintValue (f, NULL, t, v);
1560 if (v != last)
1561 fprintf (f, ",\n");
1562 }
1563 fprintf (f, "\n");
1564 indentG -= indentStepG;
1565 INDENT (f, indentG);
1566 fprintf (f, "}");
1567 }
1568 }
1569 indentG -= indentStepG;
1570
1571 } /* PrintRosAseMacrType */
1572
1573
1574
1575
1576 void
1577 PrintRosAcMacroType PARAMS ((f, head, t, bt, ac),
1578 FILE *f _AND_
1579 TypeDef *head _AND_
1580 Type *t _AND_
1581 BasicType *bt _AND_
1582 RosAcMacroType *ac)
1583 {
1584 Value *v;
1585 Value *last;
1586 OID *oid;
1587 OID *lastOid;
1588
1589 fprintf (f, "APPLICATION-CONTEXT");
1590 indentG += indentStepG;
1591
1592 /*
1593 * print non Ros Elements
1594 */
1595 fprintf (f,"\n");
1596 INDENT (f, indentG);
1597 fprintf (f,"APPLICATION-SERVICE-ELEMENTS\n");
1598 INDENT (f, indentG);
1599 fprintf (f, "{\n");
1600
1601 indentG += indentStepG;
1602 if ((ac->nonRoElements == NULL) && (!LIST_EMPTY (ac->nonRoElements)))
1603 last = (Value*)LAST_LIST_ELMT (ac->nonRoElements);
1604 FOR_EACH_LIST_ELMT (v, ac->nonRoElements)
1605 {
1606 INDENT (f, indentG);
1607 PrintValue (f, NULL, t, v);
1608 if (v != last)
1609 fprintf (f, ",\n");
1610 }
1611 fprintf (f, "}\n");
1612
1613 /*
1614 * Print Bind Type
1615 */
1616 INDENT (f, indentG);
1617 fprintf (f,"BIND\n");
1618 INDENT (f, indentG);
1619 PrintType (f, head, ac->bindMacroType);
1620 fprintf (f, "\n");
1621
1622 /*
1623 * Print unbind Type
1624 */
1625 INDENT (f, indentG);
1626 fprintf (f,"UNBIND\n");
1627 INDENT (f, indentG);
1628 PrintType (f, head, ac->unbindMacroType);
1629
1630
1631 if (ac->remoteOperations != NULL)
1632 {
1633 fprintf (f, "\n");
1634 INDENT (f, indentG);
1635 fprintf (f,"REMOTE OPERATIONS { ");
1636 PrintValue (f, NULL, t, ac->remoteOperations);
1637 fprintf (f, " }");
1638
1639 if ((ac->operationsOf != NULL) && (!LIST_EMPTY (ac->operationsOf)))
1640 {
1641 fprintf (f, "\n");
1642 INDENT (f, indentG);
1643 fprintf (f,"OPERATIONS OF\n");
1644 INDENT (f, indentG);
1645 fprintf (f, "{\n");
1646
1647 indentG += indentStepG;
1648 last = (Value*)LAST_LIST_ELMT (ac->operationsOf);
1649 FOR_EACH_LIST_ELMT (v, ac->operationsOf)
1650 {
1651 INDENT (f, indentG);
1652 PrintValue (f, NULL, t, v);
1653 if (v != last)
1654 fprintf (f, ",\n");
1655 }
1656 fprintf (f, "\n");
1657 indentG -= indentStepG;
1658 INDENT (f, indentG);
1659 fprintf (f, "}");
1660 }
1661
1662 if ((ac->initiatorConsumerOf != NULL) && (!LIST_EMPTY (ac->initiatorConsumerOf)))
1663 {
1664 fprintf (f, "\n");
1665 INDENT (f, indentG);
1666 fprintf (f,"INITIATOR CONSUMER OF\n");
1667 INDENT (f, indentG);
1668 fprintf (f, "{\n");
1669
1670 indentG += indentStepG;
1671 last = (Value*)LAST_LIST_ELMT (ac->initiatorConsumerOf);
1672 FOR_EACH_LIST_ELMT (v, ac->initiatorConsumerOf)
1673 {
1674 INDENT (f, indentG);
1675 PrintValue (f, NULL, t, v);
1676 if (v != last)
1677 fprintf (f, ",\n");
1678 }
1679 fprintf (f, "\n");
1680 indentG -= indentStepG;
1681 INDENT (f, indentG);
1682 fprintf (f, "}");
1683 }
1684
1685 if ((ac->responderConsumerOf != NULL) && (!LIST_EMPTY (ac->responderConsumerOf)))
1686 {
1687 fprintf (f, "\n");
1688 INDENT (f, indentG);
1689 fprintf (f,"RESPONDER CONSUMER OF\n");
1690 INDENT (f, indentG);
1691 fprintf (f, "{\n");
1692
1693 indentG += indentStepG;
1694 last = (Value*)LAST_LIST_ELMT (ac->responderConsumerOf);
1695 FOR_EACH_LIST_ELMT (v, ac->responderConsumerOf)
1696 {
1697 INDENT (f, indentG);
1698 PrintValue (f, NULL, t, v);
1699 if (v != last)
1700 fprintf (f, ",\n");
1701 }
1702 fprintf (f, "\n");
1703 indentG -= indentStepG;
1704 INDENT (f, indentG);
1705 fprintf (f, "}");
1706 }
1707 }
1708
1709 fprintf (f,"\n");
1710 INDENT (f, indentG);
1711 fprintf (f,"ABSTRACT SYNTAXES\n");
1712 INDENT (f, indentG);
1713 fprintf (f, "{\n");
1714
1715 if ((ac->abstractSyntaxes != NULL) && (!LIST_EMPTY (ac->abstractSyntaxes)))
1716 lastOid = (OID*)LAST_LIST_ELMT (ac->abstractSyntaxes);
1717 FOR_EACH_LIST_ELMT (oid, ac->abstractSyntaxes)
1718 {
1719 INDENT (f, indentG);
1720 PrintOid (f, oid);
1721 if (oid != lastOid)
1722 fprintf (f, ",\n");
1723 }
1724 fprintf (f, "\n");
1725 indentG -= indentStepG;
1726 INDENT (f, indentG);
1727 fprintf (f, "}");
1728
1729 indentG -= indentStepG;
1730
1731 } /* PrintRosAcMacroType */
1732
1733
1734 void
1735 PrintMtsasExtensionsMacroType PARAMS ((f, head, t, bt, exts),
1736 FILE *f _AND_
1737 TypeDef *head _AND_
1738 Type *t _AND_
1739 BasicType *bt _AND_
1740 MtsasExtensionsMacroType *exts)
1741 {
1742 Value *v;
1743 Value *last;
1744
1745 fprintf (f, "EXTENSIONS CHOSEN FROM");
1746
1747 INDENT (f, indentG);
1748 fprintf (f, "{\n");
1749
1750 indentG += indentStepG;
1751 if ((exts->extensions == NULL) && (!LIST_EMPTY (exts->extensions)))
1752 last = (Value*)LAST_LIST_ELMT (exts->extensions);
1753 FOR_EACH_LIST_ELMT (v, exts->extensions)
1754 {
1755 INDENT (f, indentG);
1756 PrintValue (f, NULL, t, v);
1757 if (v != last)
1758 fprintf (f, ",\n");
1759 }
1760 fprintf (f, "\n");
1761 indentG -= indentStepG;
1762 INDENT (f, indentG);
1763 fprintf (f, "}");
1764
1765 } /* PrintMtsasExtensionsMacroType */
1766
1767
1768 void
1769 PrintMtsasExtensionMacroType PARAMS ((f, head, t, bt, ext),
1770 FILE *f _AND_
1771 TypeDef *head _AND_
1772 Type *t _AND_
1773 BasicType *bt _AND_
1774 MtsasExtensionMacroType *ext)
1775 {
1776
1777 fprintf (f, "EXTENSION");
1778
1779 indentG += indentStepG;
1780 if (ext->elmtType != NULL)
1781 {
1782 fprintf (f, "\n");
1783 INDENT (f, indentG);
1784 PrintElmtType (f, head, t, ext->elmtType);
1785
1786 if (ext->defaultValue != NULL)
1787 {
1788 fprintf (f, " DEFAULT ");
1789 PrintValue (f, NULL, t, ext->defaultValue);
1790 }
1791 }
1792
1793 if ((ext->criticalForSubmission != NULL) ||
1794 (ext->criticalForTransfer != NULL) ||
1795 (ext->criticalForDelivery != NULL))
1796 {
1797 fprintf (f,"\n");
1798 INDENT (f, indentG);
1799 fprintf (f, "CRITICAL FOR ");
1800
1801 if (ext->criticalForSubmission != NULL)
1802 {
1803 fprintf (f, "SUBMISSION");
1804 if ((ext->criticalForTransfer != NULL) ||
1805 (ext->criticalForDelivery != NULL))
1806 fprintf (f,", ");
1807 }
1808
1809 if (ext->criticalForTransfer != NULL)
1810 {
1811 fprintf (f, "TRANSFER, ");
1812 if (ext->criticalForDelivery != NULL)
1813 fprintf (f,", ");
1814 }
1815
1816 if (ext->criticalForDelivery != NULL)
1817 fprintf (f, "DELIVERY");
1818
1819 }
1820
1821 indentG -= indentStepG;
1822
1823 } /* PrintMtsasExtensionMacroType */
1824
1825
1826
1827
1828 void
1829 PrintMtsasExtensionAttributeMacroType PARAMS ((f, head, t, bt, ext),
1830 FILE *f _AND_
1831 TypeDef *head _AND_
1832 Type *t _AND_
1833 BasicType *bt _AND_
1834 MtsasExtensionAttributeMacroType *ext)
1835 {
1836
1837 fprintf (f, "EXTENSION-ATTRIBUTE");
1838 if (ext->type != NULL)
1839 {
1840 fprintf (f, "\n");
1841 indentG += indentStepG;
1842 INDENT (f, indentG);
1843
1844 PrintType (f, head, ext->type);
1845 indentG -= indentStepG;
1846 }
1847
1848 } /* PrintMtsasExtensionAttributeMacroType */
1849
1850
1851
1852 void
1853 PrintMtsasTokenMacroType PARAMS ((f, head, t, bt, tok),
1854 FILE *f _AND_
1855 TypeDef *head _AND_
1856 Type *t _AND_
1857 BasicType *bt _AND_
1858 MtsasTokenMacroType *tok)
1859 {
1860
1861 fprintf (f, "TOKEN");
1862 if (tok->type != NULL)
1863 {
1864 fprintf (f, "\n");
1865 indentG += indentStepG;
1866 INDENT (f, indentG);
1867 PrintType (f, head, tok->type);
1868 indentG -= indentStepG;
1869 }
1870
1871 } /* PrintMtsasTokenMacro */
1872
1873
1874 void
1875 PrintMtsasTokenDataMacroType PARAMS ((f, head, t, bt, tok),
1876 FILE *f _AND_
1877 TypeDef *head _AND_
1878 Type *t _AND_
1879 BasicType *bt _AND_
1880 MtsasTokenDataMacroType *tok)
1881 {
1882
1883 fprintf (f, "TOKEN-DATA");
1884 if (tok->type != NULL)
1885 {
1886 fprintf (f, "\n");
1887 indentG += indentStepG;
1888 INDENT (f, indentG);
1889
1890 PrintType (f, head, tok->type);
1891 indentG -= indentStepG;
1892 }
1893
1894 } /* PrintMtsasTokenDataMacro */
1895
1896
1897 void
1898 PrintMtsasSecurityCategoryMacroType PARAMS ((f, head, t, bt, sec),
1899 FILE *f _AND_
1900 TypeDef *head _AND_
1901 Type *t _AND_
1902 BasicType *bt _AND_
1903 MtsasSecurityCategoryMacroType *sec)
1904 {
1905
1906 fprintf (f, "SECURITY-CATEGORY");
1907 if (sec->type != NULL)
1908 {
1909 fprintf (f, "\n");
1910 indentG += indentStepG;
1911 INDENT (f, indentG);
1912
1913 PrintType (f, head, sec->type);
1914 indentG -= indentStepG;
1915 }
1916
1917 } /* PrintMtsasSecurityCategoryMacroType */
1918
1919
1920
1921 void
1922 PrintAsnObjectMacroType PARAMS ((f, head, t, bt, obj),
1923 FILE *f _AND_
1924 TypeDef *head _AND_
1925 Type *t _AND_
1926 BasicType *bt _AND_
1927 AsnObjectMacroType *obj)
1928 {
1929 AsnPort *ap;
1930 AsnPort *last;
1931
1932 fprintf (f, "OBJECT");
1933
1934 indentG += indentStepG;
1935
1936 if ((obj->ports != NULL) && !LIST_EMPTY (obj->ports))
1937 {
1938
1939 fprintf (f,"\n");
1940 INDENT (f, indentG);
1941 fprintf (f, "PORTS\n");
1942 INDENT (f, indentG);
1943 fprintf (f, "{\n");
1944 indentG += indentStepG;
1945
1946 last = (AsnPort*)LAST_LIST_ELMT (obj->ports);
1947 FOR_EACH_LIST_ELMT (ap, obj->ports)
1948 {
1949 INDENT (f, indentG);
1950 PrintValue (f, NULL, t, ap->portValue);
1951
1952 if (ap->portType == CONSUMER_PORT)
1953 fprintf (f, " [C]");
1954 else if (ap->portType == SUPPLIER_PORT)
1955 fprintf (f, " [S]");
1956
1957 if (ap != last)
1958 fprintf (f, ",\n");
1959 }
1960 fprintf (f, "\n");
1961 indentG -= indentStepG;
1962 INDENT (f, indentG);
1963 fprintf (f, "}");
1964 }
1965 indentG -= indentStepG;
1966
1967 } /* PrintAsnObjectMacroType */
1968
1969
1970
1971 void
1972 PrintAsnPortMacroType PARAMS ((f, head, t, bt, p),
1973 FILE *f _AND_
1974 TypeDef *head _AND_
1975 Type *t _AND_
1976 BasicType *bt _AND_
1977 AsnPortMacroType *p)
1978 {
1979 TypeOrValue *tOrV;
1980 TypeOrValue *last;
1981
1982 fprintf (f, "PORT");
1983 indentG += indentStepG;
1984 if ((p->abstractOps != NULL) && (!LIST_EMPTY (p->abstractOps)))
1985 {
1986 fprintf (f,"\n");
1987 INDENT (f, indentG);
1988 fprintf (f, "ABSTRACT OPERATIONS\n");
1989 INDENT (f, indentG);
1990 fprintf (f, "{\n");
1991 indentG += indentStepG;
1992
1993 last = (TypeOrValue*)LAST_LIST_ELMT (p->abstractOps);
1994 FOR_EACH_LIST_ELMT (tOrV, p->abstractOps)
1995 {
1996 INDENT (f, indentG);
1997
1998 if (tOrV->choiceId == TYPEORVALUE_TYPE)
1999 PrintType (f, head, tOrV->a.type);
2000 else
2001 PrintValue (f, NULL, t, tOrV->a.value);
2002
2003 if (tOrV != last)
2004 fprintf (f, ",\n");
2005 }
2006 fprintf (f, "\n");
2007 indentG -= indentStepG;
2008 INDENT (f, indentG);
2009 fprintf (f, "}");
2010 }
2011
2012 if ((p->consumerInvokes != NULL) && (!LIST_EMPTY (p->consumerInvokes)))
2013 {
2014 fprintf (f,"\n");
2015 INDENT (f, indentG);
2016 fprintf (f, "CONSUMER INVOKES\n");
2017 INDENT (f, indentG);
2018 fprintf (f, "{\n");
2019 indentG += indentStepG;
2020
2021 last = (TypeOrValue*)LAST_LIST_ELMT (p->consumerInvokes);
2022 FOR_EACH_LIST_ELMT (tOrV, p->consumerInvokes)
2023 {
2024 INDENT (f, indentG);
2025
2026 if (tOrV->choiceId == TYPEORVALUE_TYPE)
2027 PrintType (f, head, tOrV->a.type);
2028 else
2029 PrintValue (f, NULL, t, tOrV->a.value);
2030
2031 if (tOrV != last)
2032 fprintf (f, ",\n");
2033 }
2034 fprintf (f, "\n");
2035 indentG -= indentStepG;
2036 INDENT (f, indentG);
2037 fprintf (f, "}");
2038 }
2039
2040 if ((p->supplierInvokes != NULL) && (!LIST_EMPTY (p->supplierInvokes)))
2041 {
2042 fprintf (f,"\n");
2043 INDENT (f, indentG);
2044 fprintf (f, "SUPPLIER INVOKES\n");
2045 INDENT (f, indentG);
2046 fprintf (f, "{\n");
2047 indentG += indentStepG;
2048
2049 last = (TypeOrValue*)LAST_LIST_ELMT (p->supplierInvokes);
2050 FOR_EACH_LIST_ELMT (tOrV, p->supplierInvokes)
2051
2052 {
2053 INDENT (f, indentG);
2054
2055 if (tOrV->choiceId == TYPEORVALUE_TYPE)
2056 PrintType (f, head, tOrV->a.type);
2057 else
2058 PrintValue (f, NULL, t, tOrV->a.value);
2059
2060 if (tOrV != last)
2061 fprintf (f, ",\n");
2062 }
2063 fprintf (f, "\n");
2064 indentG -= indentStepG;
2065 INDENT (f, indentG);
2066 fprintf (f, "}");
2067 }
2068
2069 indentG -= indentStepG;
2070
2071 } /* PrintAsnPortMacroType */
2072
2073
2074
2075
2076 void
2077 PrintAsnAbstractBindMacroType PARAMS ((f, head, t, bt, bind),
2078 FILE *f _AND_
2079 TypeDef *head _AND_
2080 Type *t _AND_
2081 BasicType *bt _AND_
2082 AsnAbstractBindMacroType *bind)
2083 {
2084 AsnPort *ap;
2085 AsnPort *last;
2086
2087 if (bt->a.macroType->choiceId == MACROTYPE_ASNABSTRACTBIND)
2088 fprintf (f, "ABSTRACT-BIND");
2089 else
2090 fprintf (f, "ABSTRACT-UNBIND");
2091
2092 indentG += indentStepG;
2093
2094 if ((bind->ports != NULL) && (!LIST_EMPTY (bind->ports)))
2095 {
2096 fprintf (f,"\n");
2097 INDENT (f, indentG);
2098 if (bt->a.macroType->choiceId == MACROTYPE_ASNABSTRACTBIND)
2099 fprintf (f, "TO\n");
2100 else
2101 fprintf (f, "FROM\n");
2102
2103 INDENT (f, indentG);
2104 fprintf (f, "{\n");
2105 indentG += indentStepG;
2106
2107 last = (AsnPort*)LAST_LIST_ELMT (bind->ports);
2108 FOR_EACH_LIST_ELMT (ap, bind->ports)
2109 {
2110 INDENT (f, indentG);
2111 PrintValue (f, NULL, t, ap->portValue);
2112
2113 if (ap->portType == CONSUMER_PORT)
2114 fprintf (f, " [C]");
2115 else if (ap->portType == SUPPLIER_PORT)
2116 fprintf (f, " [S]");
2117
2118 if (ap != last)
2119 fprintf (f, ",\n");
2120 }
2121
2122 fprintf (f, "\n");
2123 indentG -= indentStepG;
2124 INDENT (f, indentG);
2125 fprintf (f, "}");
2126 }
2127
2128 if (bind->type != NULL)
2129 {
2130 fprintf (f,"\n");
2131 INDENT (f, indentG);
2132 PrintType (f, head, bind->type);
2133 }
2134
2135 indentG -= indentStepG;
2136
2137 } /* PrintAsnAbstractBindMacroType */
2138
2139
2140
2141 void
2142 PrintAfAlgorithmMacroType PARAMS ((f, head, t, bt, alg),
2143 FILE *f _AND_
2144 TypeDef *head _AND_
2145 Type *t _AND_
2146 BasicType *bt _AND_
2147 Type *alg)
2148 {
2149 indentG += indentStepG;
2150 fprintf (f, "ALGORITHM PARAMETER ");
2151 PrintType (f, head, alg);
2152 indentG -= indentStepG;
2153 } /* PrintAfAlgorithmMacroType */
2154
2155
2156 void
2157 PrintAfEncryptedMacroType PARAMS ((f, head, t, bt, encrypt),
2158 FILE *f _AND_
2159 TypeDef *head _AND_
2160 Type *t _AND_
2161 BasicType *bt _AND_
2162 Type *encrypt)
2163 {
2164 indentG += indentStepG;
2165 fprintf (f, "ENCRYPTED ");
2166 PrintType (f, head, encrypt);
2167 indentG -= indentStepG;
2168 } /* PrintAfEncryptedMacroType */
2169
2170
2171 void
2172 PrintAfSignedMacroType PARAMS ((f, head, t, bt, sign),
2173 FILE *f _AND_
2174 TypeDef *head _AND_
2175 Type *t _AND_
2176 BasicType *bt _AND_
2177 Type *sign)
2178 {
2179 indentG += indentStepG;
2180 fprintf (f, "SIGNED ");
2181 PrintType (f, head, sign);
2182 indentG -= indentStepG;
2183 } /* PrintAfSignedMacroType */
2184
2185
2186 void
2187 PrintAfSignatureMacroType PARAMS ((f, head, t, bt, sig),
2188 FILE *f _AND_
2189 TypeDef *head _AND_
2190 Type *t _AND_
2191 BasicType *bt _AND_
2192 Type *sig)
2193 {
2194 indentG += indentStepG;
2195 fprintf (f, "SIGNATURE ");
2196 PrintType (f, head, sig);
2197 indentG -= indentStepG;
2198 } /* PrintAfSignatureMacroType */
2199
2200
2201 void
2202 PrintAfProtectedMacroType PARAMS ((f, head, t, bt, p),
2203 FILE *f _AND_
2204 TypeDef *head _AND_
2205 Type *t _AND_
2206 BasicType *bt _AND_
2207 Type *p)
2208 {
2209 indentG += indentStepG;
2210 fprintf (f, "PROTECTED ");
2211 PrintType (f, head, p);
2212 indentG -= indentStepG;
2213 } /* PrintAfMacroType */
2214
2215
2216 void
2217 PrintSnmpObjectTypeMacroType PARAMS ((f, head, t, bt, ot),
2218 FILE *f _AND_
2219 TypeDef *head _AND_
2220 Type *t _AND_
2221 BasicType *bt _AND_
2222 SnmpObjectTypeMacroType *ot)
2223 {
2224 TypeOrValue *tOrV;
2225 TypeOrValue *last;
2226
2227 fprintf (f, "OBJECT-TYPE\n");
2228 indentG += indentStepG;
2229 INDENT (f,indentG);
2230 fprintf (f,"SYNTAX ");
2231 indentG += indentStepG;
2232 PrintType (f, head, ot->syntax);
2233 indentG -= indentStepG;
2234
2235 fprintf (f,"\n");
2236 INDENT (f,indentG);
2237 fprintf (f,"ACCESS ");
2238 switch (ot->access)
2239 {
2240 case SNMP_READ_ONLY:
2241 fprintf (f,"read-only");
2242 break;
2243
2244 case SNMP_READ_WRITE:
2245 fprintf (f,"read-write");
2246 break;
2247
2248 case SNMP_WRITE_ONLY:
2249 fprintf (f,"write-only");
2250 break;
2251
2252 case SNMP_NOT_ACCESSIBLE:
2253 fprintf (f,"not-accessible");
2254 break;
2255
2256 default:
2257 fprintf (f," < ?? unknown access type ?? >");
2258 }
2259
2260 fprintf (f,"\n");
2261 INDENT (f, indentG);
2262 fprintf (f,"STATUS ");
2263 switch (ot->status)
2264 {
2265 case SNMP_MANDATORY:
2266 fprintf (f,"mandatory");
2267 break;
2268
2269 case SNMP_OPTIONAL:
2270 fprintf (f,"optional");
2271 break;
2272
2273 case SNMP_OBSOLETE:
2274 fprintf (f,"obsolete");
2275 break;
2276
2277 case SNMP_DEPRECATED:
2278 fprintf (f,"deprecated");
2279 break;
2280
2281 default:
2282 fprintf (f," < ?? unknown status type ?? >");
2283 }
2284
2285 if (ot->description != NULL)
2286 {
2287 fprintf (f,"\n");
2288 INDENT (f, indentG);
2289 fprintf (f,"DESCRIPTION\n");
2290 indentG += indentStepG;
2291 INDENT (f, indentG);
2292 PrintValue (f, NULL, t, ot->description);
2293 indentG -= indentStepG;
2294 }
2295
2296 if (ot->reference != NULL)
2297 {
2298 fprintf (f,"\n");
2299 INDENT (f, indentG);
2300 fprintf (f,"REFERENCE\n");
2301 indentG += indentStepG;
2302 INDENT (f, indentG);
2303 PrintValue (f, NULL, t, ot->reference);
2304 indentG -= indentStepG;
2305 }
2306
2307 if (ot->index != NULL)
2308 {
2309 fprintf (f,"\n");
2310 INDENT (f, indentG);
2311 fprintf (f,"INDEX\n");
2312 indentG += indentStepG;
2313 INDENT (f, indentG);
2314 last = (TypeOrValue*)LAST_LIST_ELMT (ot->index);
2315 FOR_EACH_LIST_ELMT (tOrV, ot->index)
2316 {
2317 INDENT (f, indentG);
2318 if (tOrV->choiceId == TYPEORVALUE_TYPE)
2319 PrintType (f, head, tOrV->a.type);
2320 else
2321 PrintValue (f, NULL, t, tOrV->a.value);
2322
2323 if (tOrV != last)
2324 fprintf (f, ",\n");
2325 }
2326 indentG -= indentStepG;
2327 }
2328
2329 if (ot->defVal != NULL)
2330 {
2331 fprintf (f,"\n");
2332 INDENT (f, indentG);
2333 fprintf (f,"DEFVAL\n");
2334 indentG += indentStepG;
2335 INDENT (f, indentG);
2336 PrintValue (f, NULL, t, ot->defVal);
2337 indentG -= indentStepG;
2338 }
2339
2340 fprintf (f,"\n");
2341
2342 indentG -= indentStepG;
2343 } /* PrintSnmpObjectTypeMacroType */
2344
2345
2346 /*
2347 * @MACRO@ add new macro print routines above this point
2348 */
2349
2350 void
2351 PrintMacroDef PARAMS ((f, head),
2352 FILE *f _AND_
2353 TypeDef *head)
2354 {
2355 char *s;
2356
2357 fprintf (f,"\n-- Note: snacc does not use macro defs to extend the compiler.");
2358 fprintf (f,"\n-- All macros that are understood have been hand coded.");
2359 fprintf (f,"\n-- The macro def body is kept as a string only.\n\n");
2360
2361 s = head->type->basicType->a.macroDef;
2362
2363 fprintf (f, "%s MACRO ::=\n", head->definedName);
2364 fprintf (f, "%s", s);
2365
2366 } /* PrintMacroDef */
2367
2368
2369
2370 void
2371 PrintEncodedOid PARAMS ((f, eoid),
2372 FILE *f _AND_
2373 AsnOid *eoid)
2374 {
2375 int i;
2376 int arcNum;
2377 int firstArcNum;
2378 int secondArcNum;
2379
2380 if (eoid == NULL)
2381 return;
2382
2383 fprintf (f, "{ ");
2384
2385 for (arcNum = 0, i=0; (i < eoid->octetLen) && (eoid->octs[i] & 0x80);i++)
2386 arcNum = (arcNum << 7) + (eoid->octs[i] & 0x7f);
2387
2388 arcNum = (arcNum << 7) + (eoid->octs[i] & 0x7f);
2389 i++;
2390
2391 firstArcNum = arcNum / 40;
2392 if (firstArcNum > 2)
2393 firstArcNum = 2;
2394
2395 secondArcNum = arcNum - (firstArcNum * 40);
2396
2397 fprintf (f, "%d ", firstArcNum);
2398 fprintf (f, "%d ", secondArcNum);
2399 for (; i < eoid->octetLen; )
2400 {
2401 for (arcNum = 0; (i < eoid->octetLen) && (eoid->octs[i] & 0x80);i++)
2402 arcNum = (arcNum << 7) + (eoid->octs[i] & 0x7f);
2403
2404 arcNum = (arcNum << 7) + (eoid->octs[i] & 0x7f);
2405 i++;
2406
2407 fprintf (f, "%d ", arcNum);
2408 }
2409
2410 fprintf (f, "}");
2411
2412 } /* PrintEncodedOid */
2413
2414
2415
2416 /*
2417 * this just prints a short form of the given type. It
2418 * does not print the components of a constructed type
2419 * such as a SEQUENCE
2420 * This is used by the header file generators to annotate
2421 * the C/C++ types
2422 */
2423 void
2424 SpecialPrintBasicType PARAMS ((f, head, t, bt),
2425 FILE *f _AND_
2426 TypeDef *head _AND_
2427 Type *t _AND_
2428 BasicType *bt)
2429 {
2430 switch (bt->choiceId)
2431 {
2432
2433 case BASICTYPE_SEQUENCE:
2434 fprintf (f, "SEQUENCE");
2435 break;
2436
2437 case BASICTYPE_SET:
2438 fprintf (f, "SET");
2439 break;
2440
2441 case BASICTYPE_CHOICE:
2442 fprintf (f, "CHOICE");
2443 break;
2444
2445
2446
2447 case BASICTYPE_SEQUENCEOF:
2448 fprintf (f, "SEQUENCE ");
2449 if (t->subtypes != NULL)
2450 {
2451 PrintSubtype (f, head, t, t->subtypes);
2452 fprintf (f," ");
2453 }
2454 fprintf (f, "OF ");
2455 SpecialPrintType (f, head, t->basicType->a.sequenceOf);
2456 break;
2457
2458 case BASICTYPE_SETOF:
2459 fprintf (f, "SET ");
2460 if (t->subtypes != NULL)
2461 {
2462 PrintSubtype (f, head, t, t->subtypes);
2463 fprintf (f," ");
2464 }
2465 fprintf (f, "OF ");
2466 SpecialPrintType (f, head, t->basicType->a.sequenceOf);
2467 break;
2468
2469
2470 case BASICTYPE_SELECTION:
2471 fprintf (f, "%s < ", bt->a.selection->fieldName);
2472 PrintType (f, head, bt->a.selection->typeRef);
2473 break;
2474
2475
2476
2477
2478 case BASICTYPE_COMPONENTSOF:
2479 fprintf (f, "COMPONENTS OF ");
2480 PrintType (f, NULL, bt->a.componentsOf);
2481 break;
2482
2483
2484
2485 case BASICTYPE_ANYDEFINEDBY:
2486 fprintf (f, "ANY DEFINED BY %s", bt->a.anyDefinedBy->fieldName);
2487 break;
2488
2489
2490 case BASICTYPE_LOCALTYPEREF:
2491 fprintf (f, "%s", bt->a.localTypeRef->typeName);
2492 break;
2493
2494 case BASICTYPE_IMPORTTYPEREF:
2495 fprintf (f, "%s", bt->a.importTypeRef->typeName);
2496 break;
2497
2498
2499 case BASICTYPE_UNKNOWN:
2500 fprintf (f, "unknown type !?!");
2501 break;
2502
2503 case BASICTYPE_BOOLEAN:
2504 fprintf (f, "BOOLEAN");
2505 break;
2506
2507
2508 case BASICTYPE_INTEGER:
2509 fprintf (f, "INTEGER");
2510 if ((bt->a.integer != NULL) && !LIST_EMPTY (bt->a.integer))
2511 SpecialPrintNamedElmts (f, head, t);
2512 break;
2513
2514
2515 case BASICTYPE_BITSTRING:
2516 fprintf (f, "BIT STRING");
2517 if ((bt->a.bitString != NULL) && !LIST_EMPTY (bt->a.bitString))
2518 SpecialPrintNamedElmts (f, head, t);
2519 break;
2520
2521 case BASICTYPE_OCTETSTRING:
2522 fprintf (f, "OCTET STRING");
2523 break;
2524
2525 case BASICTYPE_NULL:
2526 fprintf (f, "NULL");
2527 break;
2528
2529 case BASICTYPE_OID:
2530 fprintf (f, "OBJECT IDENTIFIER");
2531 break;
2532
2533 case BASICTYPE_REAL:
2534 fprintf (f, "REAL");
2535 break;
2536
2537 case BASICTYPE_ENUMERATED:
2538 fprintf (f, "ENUMERATED");
2539 if ((bt->a.enumerated != NULL) && !LIST_EMPTY (bt->a.enumerated))
2540 SpecialPrintNamedElmts (f, head, t);
2541
2542 break;
2543
2544 case BASICTYPE_ANY:
2545 fprintf (f, "ANY");
2546 break;
2547
2548 case BASICTYPE_MACROTYPE:
2549 switch (bt->a.macroType->choiceId)
2550 {
2551 case MACROTYPE_ROSOPERATION:
2552 case MACROTYPE_ASNABSTRACTOPERATION:
2553 PrintRosOperationMacroType (f, head, t, bt, bt->a.macroType->a.rosOperation);
2554 break;
2555
2556 case MACROTYPE_ROSERROR:
2557 case MACROTYPE_ASNABSTRACTERROR:
2558 PrintRosErrorMacroType (f, head, t, bt, bt->a.macroType->a.rosError);
2559 break;
2560
2561 case MACROTYPE_ROSBIND:
2562 case MACROTYPE_ROSUNBIND:
2563 PrintRosBindMacroType (f, head, t, bt, bt->a.macroType->a.rosBind);
2564 break;
2565
2566 case MACROTYPE_ROSASE:
2567 PrintRosAseMacroType (f, head, t, bt, bt->a.macroType->a.rosAse);
2568 break;
2569
2570 case MACROTYPE_MTSASEXTENSIONS:
2571 PrintMtsasExtensionsMacroType (f, head, t, bt, bt->a.macroType->a.mtsasExtensions);
2572 break;
2573
2574 case MACROTYPE_MTSASEXTENSION:
2575 PrintMtsasExtensionMacroType (f, head, t, bt, bt->a.macroType->a.mtsasExtension);
2576 break;
2577
2578 case MACROTYPE_MTSASEXTENSIONATTRIBUTE:
2579 PrintMtsasExtensionAttributeMacroType (f, head, t, bt, bt->a.macroType->a.mtsasExtensionAttribute);
2580 break;
2581
2582 case MACROTYPE_MTSASTOKEN:
2583 PrintMtsasTokenMacroType (f, head, t, bt, bt->a.macroType->a.mtsasToken);
2584 break;
2585
2586 case MACROTYPE_MTSASTOKENDATA:
2587 PrintMtsasTokenDataMacroType (f, head, t, bt, bt->a.macroType->a.mtsasTokenData);
2588 break;
2589
2590 case MACROTYPE_MTSASSECURITYCATEGORY:
2591 PrintMtsasSecurityCategoryMacroType (f, head, t, bt, bt->a.macroType->a.mtsasSecurityCategory);
2592 break;
2593
2594 case MACROTYPE_ASNOBJECT:
2595 PrintAsnObjectMacroType (f, head, t, bt, bt->a.macroType->a.asnObject);
2596 break;
2597
2598 case MACROTYPE_ASNPORT:
2599 PrintAsnPortMacroType (f, head, t, bt, bt->a.macroType->a.asnPort);
2600 break;
2601
2602 case MACROTYPE_ASNABSTRACTBIND:
2603 case MACROTYPE_ASNABSTRACTUNBIND:
2604 PrintAsnAbstractBindMacroType (f, head, t, bt, bt->a.macroType->a.asnAbstractBind);
2605 break;
2606
2607 case MACROTYPE_AFALGORITHM:
2608 PrintAfAlgorithmMacroType (f, head, t, bt, bt->a.macroType->a.afAlgorithm);
2609 break;
2610
2611 case MACROTYPE_AFENCRYPTED:
2612 PrintAfEncryptedMacroType (f, head, t, bt, bt->a.macroType->a.afEncrypted);
2613 break;
2614
2615 case MACROTYPE_AFSIGNED:
2616 PrintAfSignedMacroType (f, head, t, bt, bt->a.macroType->a.afSigned);
2617 break;
2618
2619 case MACROTYPE_AFSIGNATURE:
2620 PrintAfSignatureMacroType (f, head, t, bt, bt->a.macroType->a.afSignature);
2621 break;
2622
2623 case MACROTYPE_AFPROTECTED:
2624 PrintAfProtectedMacroType (f, head, t, bt, bt->a.macroType->a.afProtected);
2625 break;
2626
2627 case MACROTYPE_SNMPOBJECTTYPE:
2628 PrintSnmpObjectTypeMacroType (f, head, t, bt, bt->a.macroType->a.snmpObjectType);
2629 break;
2630
2631 default:
2632 fprintf (f, "< unknown macro type id ?! >");
2633
2634 } /* end macro type switch */
2635 break;
2636
2637 /*
2638 * @MACRO@ add new macro printers above this point
2639 */
2640
2641 case BASICTYPE_MACRODEF:
2642 /*
2643 * printing this should be handled in PrintTypeDefs
2644 */
2645 break;
2646
2647
2648 default:
2649 fprintf (f, "< unknown type id ?! >");
2650
2651 }
2652 } /* SpecialPrintBasicType */
2653
2654
2655 /*
2656 * this just prints a short form of the given type. It
2657 * does not print the components of a constructed type
2658 * such as a SEQUENCE
2659 * This is used by the header file generators to annotate
2660 * the C types
2661 */
2662 void
2663 SpecialPrintType PARAMS ((f, head, t),
2664 FILE *f _AND_
2665 TypeDef *head _AND_
2666 Type *t)
2667 {
2668 Tag *tag;
2669 Tag *lastTag;
2670
2671 if (t == NULL)
2672 return;
2673
2674 lastTag = NULL;
2675 FOR_EACH_LIST_ELMT (tag, t->tags)
2676 {
2677 if (!(tag->tclass == UNIV && tag->code == LIBTYPE_GET_UNIV_TAG_CODE (t->basicType->choiceId)))
2678 {
2679 PrintTag (f, tag);
2680 fprintf (f, " ");
2681 }
2682 lastTag = tag;
2683 }
2684
2685 /*
2686 * check type has been implicitly tagged
2687 */
2688 if (t->implicit)
2689 fprintf (f, "IMPLICIT ");
2690
2691 SpecialPrintBasicType (f, head, t, t->basicType);
2692
2693
2694 /*
2695 * sequences of and set of print subtypes a special way
2696 * so ignore them here
2697 */
2698 if ((t->subtypes != NULL) &&
2699 (t->basicType->choiceId != BASICTYPE_SETOF) &&
2700 (t->basicType->choiceId != BASICTYPE_SEQUENCEOF))
2701 {
2702 fprintf (f," ");
2703 PrintSubtype (f, head, t, t->subtypes);
2704 }
2705
2706
2707 if (t->defaultVal != NULL)
2708 {
2709 fprintf (f, " DEFAULT ");
2710 if (t->defaultVal->fieldName != NULL)
2711 fprintf (f, "%s ", t->defaultVal->fieldName);
2712 PrintValue (f, NULL, t, t->defaultVal->value);
2713 }
2714
2715 else if (t->optional)
2716 fprintf (f, " OPTIONAL");
2717
2718
2719 #ifdef DEBUG
2720 fprintf (f, " -- lineNo = %d", t->lineNo);
2721 fprintf (f, " --");
2722 #endif
2723
2724 } /* SpecialPrintType */
2725
2726
2727 /*
2728 * This is used by the header file generators to annotate
2729 * the C/C++ types. This version prints the C version of the
2730 * enum/bits elmt names to make sure the programmer can use
2731 * the correct defines/enum constants.
2732 * NOTE: this can only be called after the CTRI infor is filled in
2733 * so the C/C++ names can be accessed
2734 */
2735 void
2736 SpecialPrintNamedElmts PARAMS ((f, head, t),
2737 FILE *f _AND_
2738 TypeDef *head _AND_
2739 Type *t)
2740 {
2741 CNamedElmt *last;
2742 CNamedElmt *cne;
2743 CNamedElmts *n = NULL;
2744
2745 if (t->cTypeRefInfo != NULL)
2746 n = t->cTypeRefInfo->cNamedElmts;
2747
2748 if ((n == NULL) && (t->cxxTypeRefInfo != NULL))
2749 n = t->cxxTypeRefInfo->namedElmts;
2750
2751
2752 if ((n == NULL) || LIST_EMPTY (n))
2753 return;
2754
2755 fprintf (f," { ");
2756 last = (CNamedElmt*)LAST_LIST_ELMT (n);
2757 FOR_EACH_LIST_ELMT (cne, n)
2758 {
2759 fprintf (f, "%s (%d)", cne->name, cne->value);
2760 if (cne != last)
2761 fprintf (f,", ");
2762 }
2763 fprintf (f," } ");
2764 } /* SpecialPrintNamedElmts */