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