2 * compiler/core/print.c
4 * These routines are for printing the information from a Module
5 * Data strucuture in ASN.1 form.
7 * Useful for debugging the parser and seeing changes caused by
8 * normalization and sorting.
12 * Copyright (C) 1991, 1992 Michael Sample
13 * and the University of British Columbia
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.
20 * $Header: /cvs/Darwin/Security/SecuritySNACCRuntime/compiler/core/print2.c,v 1.1 2001/06/20 21:27:58 dmitch Exp $
22 * Revision 1.1 2001/06/20 21:27:58 dmitch
23 * Adding missing snacc compiler files.
25 * Revision 1.1.1.1 1999/03/16 18:06:52 aram
26 * Originals from SMIME Free Library.
28 * Revision 1.6 1997/02/28 13:39:55 wan
29 * Modifications collected for new version 1.3: Bug fixes, tk4.2.
31 * Revision 1.5 1995/08/17 14:58:57 rj
32 * minor typographic change
34 * Revision 1.4 1995/07/25 19:41:42 rj
35 * changed `_' to `-' in file names.
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.
40 * Revision 1.2 1994/09/01 00:42:16 rj
41 * snacc_config.h removed.
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.
51 #include "asn1module.h"
52 #include "lib-types.h"
56 static int indentCountG
;
57 static int indentG
= 0;
58 static int indentStepG
= 4;
61 for (indentCountG = 0; indentCountG < (i); indentCountG++)\
65 * Prints the given Module *, mod, to the given FILE *f in
69 PrintModule
PARAMS ((f
, mod
),
74 if (mod
->status
== MOD_ERROR
)
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");
82 fprintf (f
, "%s ",mod
->modId
->name
);
83 PrintOid (f
, mod
->modId
->oid
);
85 fprintf (f
, "\nDEFINITIONS ");
87 if (mod
->tagDefault
== EXPLICIT_TAGS
)
88 fprintf (f
, "EXPLICIT TAGS");
90 else if (mod
->tagDefault
== IMPLICIT_TAGS
)
91 fprintf (f
, "IMPLICIT TAGS");
93 fprintf (f
, "\n\n -- compiler error unknown tag default");
96 fprintf (f
, " ::=\nBEGIN\n\n");
100 PrintExports (f
, mod
);
102 PrintImportLists (f
, mod
->imports
);
104 PrintTypeDefs (f
, mod
->typeDefs
);
105 PrintValueDefs (f
, mod
->valueDefs
);
107 fprintf (f
, "END\n");
113 PrintExports
PARAMS ((f
, m
),
121 if (m
->exportStatus
== EXPORTS_ALL
)
123 fprintf (f
, "\n\n-- exports everything\n\n");
125 else if (m
->exportStatus
== EXPORTS_NOTHING
)
127 fprintf (f
, "\n\nEXPORTS -- exports nothing\n\n");
131 fprintf (f
, "\n\nEXPORTS\n");
133 FOR_EACH_LIST_ELMT (td
, m
->typeDefs
)
138 fprintf (f
, "%s", td
->definedName
);
142 FOR_EACH_LIST_ELMT (vd
, m
->valueDefs
)
147 fprintf (f
, "%s", vd
->definedName
);
151 fprintf (f
, "\n;\n\n");
158 PrintOid
PARAMS ((f
, oid
),
168 for (; oid
!= NULL
; oid
= oid
->next
)
171 * value ref to an integer or if first elmt in
172 * oid can ref other oid value
175 if (oid
->valueRef
!= NULL
)
176 PrintValue (f
, NULL
, NULL
, oid
->valueRef
);
179 * just "arcNum" format
182 else if (oid
->arcNum
!= NULL_OID_ARCNUM
)
183 fprintf (f
, "%d", oid
->arcNum
);
195 PrintImportElmt
PARAMS ((f
, impElmt
),
199 fprintf (f
, "%s",impElmt
->name
);
200 } /* PrintImportElmt */
204 PrintImportElmts
PARAMS ((f
, impElmtList
),
206 ImportElmtList
*impElmtList
)
211 if ((impElmtList
== NULL
) || (LIST_EMPTY (impElmtList
)))
214 last
= (ImportElmt
*)LAST_LIST_ELMT (impElmtList
);
215 FOR_EACH_LIST_ELMT (ie
, impElmtList
)
217 PrintImportElmt (f
, ie
);
223 } /* PrintImportElmts */
228 PrintImportLists
PARAMS ((f
, impLists
),
230 ImportModuleList
*impLists
)
232 ImportModule
*impMod
;
234 if (impLists
== NULL
)
236 fprintf (f
,"\n\n-- imports nothing\n\n");
240 fprintf (f
, "IMPORTS\n\n");
241 FOR_EACH_LIST_ELMT (impMod
, impLists
)
243 PrintImportElmts (f
, impMod
->importElmts
);
245 fprintf (f
, "\n FROM %s ", impMod
->modId
->name
);
247 PrintOid (f
, impMod
->modId
->oid
);
249 fprintf (f
, "\n\n\n");
251 fprintf (f
, ";\n\n\n");
253 } /* PrintImportLists */
258 PrintTypeDefs
PARAMS ((f
, typeDefs
),
260 TypeDefList
*typeDefs
)
264 FOR_EACH_LIST_ELMT (td
, typeDefs
)
266 if (td
->type
->basicType
->choiceId
== BASICTYPE_MACRODEF
)
267 PrintMacroDef (f
, td
);
270 fprintf (f
,"-- %s notes: ", td
->definedName
);
273 fprintf (f
,"recursive, ");
275 fprintf (f
,"not recursive, ");
278 fprintf (f
,"exported,\n");
280 fprintf (f
,"not exported,\n");
282 fprintf (f
,"-- locally refd %d times, ", td
->localRefCount
);
283 fprintf (f
,"import refd %d times\n", td
->importRefCount
);
286 fprintf (f
, "%s ::= ", td
->definedName
);
287 PrintType (f
, td
, td
->type
);
289 fprintf (f
, "\n\n\n");
291 } /* PrintTypeDefs */
297 PrintType
PARAMS ((f
, head
, t
),
309 FOR_EACH_LIST_ELMT (tag
, t
->tags
)
314 if (! ((tag
->tclass
== UNIV
) &&
315 (tag
->code
== LIBTYPE_GET_UNIV_TAG_CODE (t
->basicType
->choiceId
))))
324 * check type has been implicitly tagged
327 fprintf (f
, "IMPLICIT ");
329 PrintBasicType (f
, head
, t
, t
->basicType
);
333 * sequences of and set of print subtypes a special way
334 * so ignore them here
336 if ((t
->subtypes
!= NULL
) &&
337 (t
->basicType
->choiceId
!= BASICTYPE_SETOF
) &&
338 (t
->basicType
->choiceId
!= BASICTYPE_SEQUENCEOF
))
341 PrintSubtype (f
, head
, t
, t
->subtypes
);
345 if (t
->defaultVal
!= NULL
)
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
);
353 else if (t
->optional
)
354 fprintf (f
, " OPTIONAL");
358 fprintf (f
, " -- lineNo = %d --", t
->lineNo
);
365 PrintBasicType
PARAMS ((f
, head
, t
, bt
),
371 switch (bt
->choiceId
)
374 case BASICTYPE_SEQUENCE
:
375 fprintf (f
, "SEQUENCE\n");
378 indentG
+= indentStepG
;
380 PrintElmtTypes (f
, head
, t
, bt
->a
.sequence
);
381 indentG
-= indentStepG
;
388 fprintf (f
, "SET\n");
391 indentG
+= indentStepG
;
393 PrintElmtTypes (f
, head
, t
, bt
->a
.set
);
394 indentG
-= indentStepG
;
400 case BASICTYPE_CHOICE
:
401 fprintf (f
, "CHOICE\n");
404 indentG
+= indentStepG
;
406 PrintElmtTypes (f
, head
, t
, bt
->a
.choice
);
407 indentG
-= indentStepG
;
415 case BASICTYPE_SEQUENCEOF
:
416 fprintf (f
, "SEQUENCE ");
417 if (t
->subtypes
!= NULL
)
419 PrintSubtype (f
, head
, t
, t
->subtypes
);
423 PrintType (f
, head
, bt
->a
.sequenceOf
);
426 case BASICTYPE_SETOF
:
428 if (t
->subtypes
!= NULL
)
430 PrintSubtype (f
, head
, t
, t
->subtypes
);
434 PrintType (f
, head
, bt
->a
.setOf
);
438 case BASICTYPE_SELECTION
:
439 fprintf (f
, "%s < ", bt
->a
.selection
->fieldName
);
440 PrintType (f
, head
, bt
->a
.selection
->typeRef
);
446 case BASICTYPE_COMPONENTSOF
:
447 fprintf (f
, "COMPONENTS OF ");
448 PrintType (f
, NULL
, bt
->a
.componentsOf
);
453 case BASICTYPE_ANYDEFINEDBY
:
454 fprintf (f
, "ANY DEFINED BY %s", bt
->a
.anyDefinedBy
->fieldName
);
458 case BASICTYPE_LOCALTYPEREF
:
459 fprintf (f
, "%s", bt
->a
.localTypeRef
->typeName
);
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
);
470 case BASICTYPE_UNKNOWN
:
471 fprintf (f
, "unknown type !?!");
474 case BASICTYPE_BOOLEAN
:
475 fprintf (f
, "BOOLEAN");
479 case BASICTYPE_INTEGER
:
480 fprintf (f
, "INTEGER");
481 if ((bt
->a
.integer
!= NULL
) && !LIST_EMPTY (bt
->a
.integer
))
486 indentG
+= indentStepG
;
487 PrintNamedElmts (f
, head
, t
, bt
->a
.integer
);
488 indentG
-= indentStepG
;
496 case BASICTYPE_BITSTRING
:
497 fprintf (f
, "BIT STRING");
498 if ((bt
->a
.bitString
!= NULL
) && !LIST_EMPTY (bt
->a
.bitString
))
503 indentG
+= indentStepG
;
504 PrintNamedElmts (f
, head
, t
, bt
->a
.bitString
);
505 indentG
-= indentStepG
;
512 case BASICTYPE_OCTETSTRING
:
513 fprintf (f
, "OCTET STRING");
521 fprintf (f
, "OBJECT IDENTIFIER");
528 case BASICTYPE_ENUMERATED
:
529 fprintf (f
, "ENUMERATED");
530 if ((bt
->a
.enumerated
!= NULL
) && !LIST_EMPTY (bt
->a
.enumerated
))
535 indentG
+= indentStepG
;
536 PrintNamedElmts (f
, head
, t
, bt
->a
.enumerated
);
537 indentG
-= indentStepG
;
548 case BASICTYPE_MACROTYPE
:
549 switch (bt
->a
.macroType
->choiceId
)
551 case MACROTYPE_ROSOPERATION
:
552 case MACROTYPE_ASNABSTRACTOPERATION
:
553 PrintRosOperationMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.rosOperation
);
556 case MACROTYPE_ROSERROR
:
557 case MACROTYPE_ASNABSTRACTERROR
:
558 PrintRosErrorMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.rosError
);
561 case MACROTYPE_ROSBIND
:
562 case MACROTYPE_ROSUNBIND
:
563 PrintRosBindMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.rosBind
);
566 case MACROTYPE_ROSASE
:
567 PrintRosAseMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.rosAse
);
570 case MACROTYPE_MTSASEXTENSIONS
:
571 PrintMtsasExtensionsMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.mtsasExtensions
);
574 case MACROTYPE_MTSASEXTENSION
:
575 PrintMtsasExtensionMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.mtsasExtension
);
578 case MACROTYPE_MTSASEXTENSIONATTRIBUTE
:
579 PrintMtsasExtensionAttributeMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.mtsasExtensionAttribute
);
582 case MACROTYPE_MTSASTOKEN
:
583 PrintMtsasTokenMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.mtsasToken
);
586 case MACROTYPE_MTSASTOKENDATA
:
587 PrintMtsasTokenDataMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.mtsasTokenData
);
590 case MACROTYPE_MTSASSECURITYCATEGORY
:
591 PrintMtsasSecurityCategoryMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.mtsasSecurityCategory
);
594 case MACROTYPE_ASNOBJECT
:
595 PrintAsnObjectMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.asnObject
);
598 case MACROTYPE_ASNPORT
:
599 PrintAsnPortMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.asnPort
);
602 case MACROTYPE_ASNABSTRACTBIND
:
603 case MACROTYPE_ASNABSTRACTUNBIND
:
604 PrintAsnAbstractBindMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.asnAbstractBind
);
607 case MACROTYPE_AFALGORITHM
:
608 PrintAfAlgorithmMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.afAlgorithm
);
611 case MACROTYPE_AFENCRYPTED
:
612 PrintAfEncryptedMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.afEncrypted
);
615 case MACROTYPE_AFSIGNED
:
616 PrintAfSignedMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.afSigned
);
619 case MACROTYPE_AFSIGNATURE
:
620 PrintAfSignatureMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.afSignature
);
623 case MACROTYPE_AFPROTECTED
:
624 PrintAfProtectedMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.afProtected
);
627 case MACROTYPE_SNMPOBJECTTYPE
:
628 PrintSnmpObjectTypeMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.snmpObjectType
);
632 fprintf (f
, "< unknown macro type id ?! >");
634 } /* end macro type switch */
638 * @MACRO@ add new macro printers above this point
641 case BASICTYPE_MACRODEF
:
643 * printing this should be handled in PrintTypeDefs
649 fprintf (f
, "< unknown type id ?! >");
652 } /* PrintBasicType */
657 PrintElmtType
PARAMS ((f
, head
, t
, nt
),
663 if (nt
->fieldName
!= NULL
)
664 fprintf (f
, "%s ", nt
->fieldName
);
666 PrintType (f
, head
, nt
->type
);
668 } /* PrintElmtType */
671 PrintElmtTypes
PARAMS ((f
, head
, t
, e
),
680 if ((e
== NULL
) || LIST_EMPTY (e
))
683 last
= (NamedType
*)LAST_LIST_ELMT (e
);
684 FOR_EACH_LIST_ELMT (nt
, e
)
687 PrintElmtType (f
, head
, t
, nt
);
694 } /* PrintElmtTypes */
700 PrintValueDefs
PARAMS ((f
, vList
),
705 FOR_EACH_LIST_ELMT (v
, vList
)
707 PrintValueDef (f
, v
);
709 } /* PrintValueDefs */
713 PrintValueDef
PARAMS ((f
, v
),
717 fprintf (f
, "%s ", v
->definedName
);
719 if (v
->value
->type
!= NULL
)
720 PrintType (f
, NULL
, v
->value
->type
);
722 /* just go by valueType */
723 PrintTypeById (f
, v
->value
->valueType
);
725 fprintf (f
, " ::= ");
726 indentG
+= indentStepG
;
727 PrintValue (f
, v
, v
->value
->type
, v
->value
);
729 indentG
-= indentStepG
;
730 } /* PrintValueDef */
734 PrintValue
PARAMS ((f
, head
, valuesType
, v
),
737 Type
*valuesType _AND_
743 PrintBasicValue (f
, head
, valuesType
, v
, v
->basicValue
);
749 PrintBasicValue
PARAMS ((f
, head
, valuesType
, v
, bv
),
752 Type
*valuesType _AND_
760 switch (bv
->choiceId
)
762 case BASICVALUE_UNKNOWN
:
763 fprintf (f
, "<unknown value>");
766 case BASICVALUE_EMPTY
:
770 case BASICVALUE_INTEGER
:
771 fprintf (f
, "%d", bv
->a
.integer
);
774 case BASICVALUE_SPECIALINTEGER
:
775 if (bv
->a
.specialInteger
== MAX_INT
)
782 case BASICVALUE_BOOLEAN
:
789 case BASICVALUE_REAL
:
790 fprintf (f
, "%f", bv
->a
.real
);
793 case BASICVALUE_SPECIALREAL
:
794 if (bv
->a
.specialReal
== PLUS_INFINITY_REAL
)
795 fprintf (f
, "PLUS INFINITY");
797 fprintf (f
, "MINUS INFINITY");
801 case BASICVALUE_ASCIITEXT
:
802 fprintf (f
, "\"%s\"", bv
->a
.asciiText
->octs
);
805 case BASICVALUE_ASCIIHEX
:
806 fprintf (f
, "\"%s\"", bv
->a
.asciiHex
->octs
);
809 case BASICVALUE_ASCIIBITSTRING
:
810 fprintf (f
, "\"%s\"", bv
->a
.asciiBitString
->octs
);
814 PrintEncodedOid (f
, bv
->a
.oid
);
817 case BASICVALUE_LINKEDOID
:
818 PrintOid (f
, bv
->a
.linkedOid
);
821 case BASICVALUE_BERVALUE
:
822 fprintf (f
,"<PrintBerValue not coded yet");
825 case BASICVALUE_PERVALUE
:
826 fprintf (f
,"<PrintPerValue not coded yet");
829 case BASICVALUE_NAMEDVALUE
:
833 indentG
+= indentStepG
;
834 PrintElmtValue (f
, head
, v
, bv
->a
.namedValue
);
835 indentG
-= indentStepG
;
841 case BASICVALUE_NULL
:
845 case BASICVALUE_LOCALVALUEREF
:
846 fprintf (f
, "%s", bv
->a
.localValueRef
->valueName
);
849 case BASICVALUE_IMPORTVALUEREF
:
850 fprintf (f
, "%s", bv
->a
.importValueRef
->valueName
);
853 case BASICVALUE_VALUENOTATION
:
854 fprintf (f
, "-- snacc warning: can't parse this value yet --");
855 fprintf (f
, "%s", bv
->a
.valueNotation
->octs
);
860 fprintf (stderr
,"PrintBasicValue: ERROR - unknown value type\n");
863 } /* PrintBasicValue */
867 PrintElmtValue
PARAMS ((f
, head
, v
, nv
),
873 if (nv
->fieldName
!= NULL
)
874 fprintf (f
, "%s ", nv
->fieldName
);
876 PrintValue (f
, NULL
, NULL
, nv
->value
);
877 } /* PrintElmtValue */
881 PrintElmtValues
PARAMS ((f
, head
, v
, e
),
890 if ((e
== NULL
) || LIST_EMPTY (e
))
893 last
= (NamedValue
*)LAST_LIST_ELMT (e
);
894 FOR_EACH_LIST_ELMT (nv
, e
)
896 PrintElmtValue (f
, head
, v
, nv
);
903 } /* PrintElmtValues */
907 PrintTypeById
PARAMS ((f
, typeId
),
913 case BASICTYPE_UNKNOWN
:
914 fprintf (f
, "UNKNOWN");
917 case BASICTYPE_BOOLEAN
:
918 fprintf (f
, "BOOLEAN");
921 case BASICTYPE_INTEGER
:
922 fprintf (f
, "INTEGER");
925 case BASICTYPE_BITSTRING
:
926 fprintf (f
, "BIT STRING");
929 case BASICTYPE_OCTETSTRING
:
930 fprintf (f
, "OCTET STRING");
938 case BASICTYPE_SEQUENCE
:
939 fprintf (f
, "SEQUENCE");
942 case BASICTYPE_SEQUENCEOF
:
943 fprintf (f
, "SEQUENCE OF");
950 case BASICTYPE_SETOF
:
951 fprintf (f
, "SET OF");
954 case BASICTYPE_CHOICE
:
955 fprintf (f
, "CHOICE");
958 case BASICTYPE_SELECTION
:
959 fprintf (f
, "SELECTION");
966 case BASICTYPE_ANYDEFINEDBY
:
967 fprintf (f
, "ANY DEFINED BY");
971 fprintf (f
, "OBJECT IDENTIFIER");
974 case BASICTYPE_ENUMERATED
:
975 fprintf (f
, "ENUMERATED");
982 case BASICTYPE_COMPONENTSOF
:
983 fprintf (f
, "COMPONENTS OF");
987 fprintf (f
, "ERROR - %d is an unknown type id\n", typeId
);
989 } /* PrintTypeById */
993 PrintTag
PARAMS ((f
, tag
),
999 if (tag
->tclass
== UNIV
)
1003 case BOOLEAN_TAG_CODE
: name
= "BOOLEAN";
1005 case INTEGER_TAG_CODE
: name
= "INTEGER";
1007 case BITSTRING_TAG_CODE
: name
= "BITSTRING";
1009 case OCTETSTRING_TAG_CODE
: name
= "OCTETSTRING";
1011 case NULLTYPE_TAG_CODE
: name
= "NULL TYPE";
1013 case OID_TAG_CODE
: name
= "OBJECT ID";
1015 case OD_TAG_CODE
: name
= "OBEJECT DESCRIPTOR";
1017 case EXTERNAL_TAG_CODE
: name
= "EXTERNAL";
1019 case REAL_TAG_CODE
: name
= "REAL";
1021 case ENUM_TAG_CODE
: name
= "ENUMERATED";
1023 case SEQ_TAG_CODE
: name
= "SEQUENCE";
1025 case SET_TAG_CODE
: name
= "SET";
1027 case NUMERICSTRING_TAG_CODE
: name
= "NUMERIC STRING";
1029 case PRINTABLESTRING_TAG_CODE
: name
= "PRINTABLE STRING";
1031 case TELETEXSTRING_TAG_CODE
: name
= "TELETEX STRING";
1033 case VIDEOTEXSTRING_TAG_CODE
: name
= "VIDEOTEX STRING";
1035 case IA5STRING_TAG_CODE
: name
= "IA5 STRING";
1037 case UTCTIME_TAG_CODE
: name
= "UTC TIME";
1039 case GENERALIZEDTIME_TAG_CODE
: name
= "GENERALIZED TIME";
1041 case GRAPHICSTRING_TAG_CODE
: name
= "GRAPHIC STRING";
1043 case VISIBLESTRING_TAG_CODE
: name
= "VISIBLE STRING";
1045 case GENERALSTRING_TAG_CODE
: name
= "GENERAL STRING";
1048 default: name
= "UNKNOWN UNIVERSAL TYPE";
1050 fprintf (f
, "[UNIVERSAL %d]", tag
->code
);
1052 else if (tag
->tclass
== APPL
)
1054 fprintf (f
, "[APPLICATION %d]", tag
->code
);
1056 else if (tag
->tclass
== PRIV
)
1058 fprintf (f
, "[PRIVATE %d]", tag
->code
);
1060 else if (tag
->tclass
== CNTX
)
1062 fprintf (f
, "[%d]", tag
->code
);
1066 fprintf (f
, " EXPLICIT");
1072 PrintSubtype
PARAMS ((f
, head
, t
, s
),
1084 /* fprintf (f, "("); */
1086 switch (s
->choiceId
)
1088 case SUBTYPE_SINGLE
:
1089 PrintSubtypeValue (f
, head
, t
, s
->a
.single
);
1093 FOR_EACH_LIST_ELMT (tmpS
, s
->a
.and)
1096 PrintSubtype (f
, head
, t
, tmpS
);
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)
1108 PrintSubtype (f
, head
, t
, tmpS
);
1116 fprintf (f
, "NOT (");
1117 PrintSubtype (f
, head
, t
, s
->a
.not);
1122 fprintf (stderr
, "PrintSubtype: ERROR - unknown Subtypes choiceId\n");
1126 /* fprintf (f, ")"); */
1129 } /* PrintSubtype */
1134 PrintSubtypeValue
PARAMS ((f
, head
, t
, s
),
1143 switch (s
->choiceId
)
1145 case SUBTYPEVALUE_SINGLEVALUE
:
1146 PrintValue (f
, NULL
, NULL
, s
->a
.singleValue
);
1149 case SUBTYPEVALUE_CONTAINED
:
1150 fprintf (f
, "<PrintContainedSubtype not coded yet\n");
1153 case SUBTYPEVALUE_VALUERANGE
:
1154 PrintValue (f
, NULL
, NULL
, s
->a
.valueRange
->lowerEndValue
);
1155 if (!s
->a
.valueRange
->lowerEndInclusive
)
1158 if (!s
->a
.valueRange
->upperEndInclusive
)
1160 PrintValue (f
, NULL
, NULL
, s
->a
.valueRange
->upperEndValue
);
1164 case SUBTYPEVALUE_PERMITTEDALPHABET
:
1165 fprintf (f
,"FROM ");
1166 PrintSubtype (f
, head
, t
, s
->a
.permittedAlphabet
);
1169 case SUBTYPEVALUE_SIZECONSTRAINT
:
1170 fprintf (f
,"SIZE ");
1171 PrintSubtype (f
, head
, t
, s
->a
.sizeConstraint
);
1174 case SUBTYPEVALUE_INNERSUBTYPE
:
1175 PrintInnerSubtype (f
, head
, t
, s
->a
.innerSubtype
);
1179 fprintf (stderr
, "PrintSubtype: ERROR - unknown Subtype choiceId\n");
1182 } /* PrintSubtype */
1186 PrintInnerSubtype
PARAMS ((f
, head
, t
, i
),
1192 Constraint
*constraint
;
1193 if (i
->constraintType
== SINGLE_CT
)
1195 fprintf (f
,"WITH COMPONENT ");
1196 constraint
= *(Constraint
**)AsnListFirst (i
->constraints
);
1197 PrintSubtype (f
, head
, t
, constraint
->valueConstraints
);
1201 fprintf (f
, "WITH COMPONENTS\n");
1202 INDENT (f
, indentG
);
1204 indentG
+= indentStepG
;
1205 if (i
->constraintType
== PARTIAL_CT
)
1207 INDENT (f
, indentG
);
1208 fprintf (f
, "...,\n");
1210 PrintMultipleTypeConstraints (f
, head
, t
, i
->constraints
);
1211 indentG
-= indentStepG
;
1213 INDENT (f
, indentG
);
1217 } /* PrintInnerSubtype */
1222 PrintMultipleTypeConstraints
PARAMS ((f
, head
, t
, cList
),
1226 ConstraintList
*cList
)
1231 if ((cList
== NULL
) || LIST_EMPTY (cList
))
1234 last
= (Constraint
*)LAST_LIST_ELMT (cList
);
1235 FOR_EACH_LIST_ELMT (c
, cList
)
1237 if (c
->fieldRef
!= NULL
)
1239 INDENT (f
, indentG
);
1240 fprintf (f
, "%s ", c
->fieldRef
);
1244 PrintSubtype (f
, head
, t
, c
->valueConstraints
);
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");
1257 } /* PrintMultipleTypeConstraints */
1262 PrintNamedElmts
PARAMS ((f
, head
, t
, n
),
1271 if ((n
== NULL
) || LIST_EMPTY (n
))
1274 last
= (ValueDef
*)LAST_LIST_ELMT (n
);
1275 FOR_EACH_LIST_ELMT (vd
, n
)
1277 INDENT (f
, indentG
);
1278 fprintf (f
, "%s (", vd
->definedName
);
1279 PrintValue (f
, NULL
, NULL
, vd
->value
);
1284 } /* PrintNamedElmts */
1290 PrintRosOperationMacroType
PARAMS ((f
, head
, t
, bt
, op
),
1295 RosOperationMacroType
*op
)
1300 if (bt
->a
.macroType
->choiceId
== MACROTYPE_ROSOPERATION
)
1301 fprintf (f
, "OPERATION");
1303 fprintf (f
, "ABSTRACT-OPERATION");
1305 indentG
+= indentStepG
;
1306 if (op
->arguments
!= NULL
)
1309 INDENT (f
, indentG
);
1310 fprintf (f
, "ARGUMENT\n");
1311 indentG
+= indentStepG
;
1313 INDENT (f
, indentG
);
1315 if (op
->arguments
->fieldName
!= NULL
)
1316 fprintf (f
, "%s ", op
->arguments
->fieldName
);
1318 PrintType (f
, head
, op
->arguments
->type
);
1319 indentG
-= indentStepG
;
1322 if (op
->result
!= NULL
)
1325 INDENT (f
, indentG
);
1326 fprintf (f
, "RESULT\n");
1327 indentG
+= indentStepG
;
1329 INDENT (f
, indentG
);
1331 if (op
->arguments
->fieldName
!= NULL
)
1332 fprintf (f
, "%s ", op
->arguments
->fieldName
);
1334 PrintType (f
, head
, op
->result
->type
);
1335 indentG
-= indentStepG
;
1338 if ((op
->errors
== NULL
) || (!LIST_EMPTY (op
->errors
)))
1341 INDENT (f
, indentG
);
1342 fprintf (f
, "ERRORS\n");
1343 INDENT (f
, indentG
);
1345 indentG
+= indentStepG
;
1347 last
= (TypeOrValue
*)LAST_LIST_ELMT (op
->errors
);
1348 FOR_EACH_LIST_ELMT (tOrV
, op
->errors
)
1350 INDENT (f
, indentG
);
1351 if (tOrV
->choiceId
== TYPEORVALUE_TYPE
)
1352 PrintType (f
, head
, tOrV
->a
.type
);
1354 PrintValue (f
, NULL
, t
, tOrV
->a
.value
);
1360 indentG
-= indentStepG
;
1362 INDENT (f
, indentG
);
1366 if ((op
->linkedOps
!= NULL
) && (!LIST_EMPTY (op
->linkedOps
)))
1369 INDENT (f
, indentG
);
1370 fprintf (f
, "LINKED\n");
1371 INDENT (f
, indentG
);
1373 indentG
+= indentStepG
;
1375 last
= (TypeOrValue
*)LAST_LIST_ELMT (op
->linkedOps
);
1376 FOR_EACH_LIST_ELMT (tOrV
, op
->linkedOps
)
1378 INDENT (f
, indentG
);
1379 if (tOrV
->choiceId
== TYPEORVALUE_TYPE
)
1380 PrintType (f
, head
, tOrV
->a
.type
);
1382 PrintValue (f
, NULL
, t
, tOrV
->a
.value
);
1387 indentG
-= indentStepG
;
1389 INDENT (f
, indentG
);
1393 indentG
-= indentStepG
;
1395 } /* PrintRosOperationMacroType */
1400 PrintRosErrorMacroType
PARAMS ((f
, head
, t
, bt
, err
),
1405 RosErrorMacroType
*err
)
1407 if (bt
->a
.macroType
->choiceId
== MACROTYPE_ROSERROR
)
1408 fprintf (f
,"ERROR\n");
1410 fprintf (f
,"ABSTRACT-ERROR\n");
1412 indentG
+= indentStepG
;
1414 if (err
->parameter
!= NULL
)
1416 INDENT (f
, indentG
);
1417 fprintf (f
,"PARAMETER ");
1418 indentG
+= indentStepG
;
1419 PrintElmtType (f
, head
, t
, err
->parameter
);
1420 indentG
-= indentStepG
;
1422 indentG
-= indentStepG
;
1424 } /* PrintRosErrorMacroType */
1428 PrintRosBindMacroType
PARAMS ((f
, head
, t
, bt
, bind
),
1433 RosBindMacroType
*bind
)
1435 if (bt
->a
.macroType
->choiceId
== MACROTYPE_ROSBIND
)
1438 fprintf (f
,"UNBIND");
1440 indentG
+= indentStepG
;
1442 if (bind
->argument
!= NULL
)
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
;
1453 if (bind
->result
!= NULL
)
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
;
1464 if (bind
->error
!= NULL
)
1467 INDENT (f
, indentG
);
1468 if (bt
->a
.macroType
->choiceId
== MACROTYPE_ROSBIND
)
1469 fprintf (f
,"BIND-ERROR\n");
1471 fprintf (f
,"UNBIND-ERROR\n");
1473 indentG
+= indentStepG
;
1474 INDENT (f
, indentG
);
1475 PrintElmtType (f
, head
, t
, bind
->error
);
1476 indentG
-= indentStepG
;
1479 indentG
-= indentStepG
;
1481 } /* PrintRosBindMacroType */
1485 PrintRosAseMacroType
PARAMS ((f
, head
, t
, bt
, ase
),
1490 RosAseMacroType
*ase
)
1495 fprintf (f
, "APPLICATION-SERVICE-ELEMENT");
1496 indentG
+= indentStepG
;
1498 if ((ase
->operations
!= NULL
)&& (!LIST_EMPTY (ase
->operations
)))
1501 INDENT (f
, indentG
);
1502 fprintf (f
,"OPERATIONS\n");
1503 INDENT (f
, indentG
);
1506 indentG
+= indentStepG
;
1508 last
= (Value
*)LAST_LIST_ELMT (ase
->operations
);
1509 FOR_EACH_LIST_ELMT (v
, ase
->operations
)
1511 INDENT (f
, indentG
);
1512 PrintValue (f
, NULL
, t
, v
);
1517 indentG
-= indentStepG
;
1518 INDENT (f
, indentG
);
1522 else /* either suuplier invokes or consumer invokes will be valid */
1524 if ((ase
->consumerInvokes
!= NULL
) && (!LIST_EMPTY (ase
->consumerInvokes
)))
1527 INDENT (f
, indentG
);
1528 fprintf (f
,"CONSUMER INVOKES\n");
1529 INDENT (f
, indentG
);
1532 indentG
+= indentStepG
;
1533 last
= (Value
*) LAST_LIST_ELMT (ase
->consumerInvokes
);
1534 FOR_EACH_LIST_ELMT (v
, ase
->consumerInvokes
)
1536 INDENT (f
, indentG
);
1537 PrintValue (f
, NULL
, t
, v
);
1542 indentG
-= indentStepG
;
1543 INDENT (f
, indentG
);
1546 if ((ase
->operations
!= NULL
) && (!LIST_EMPTY (ase
->operations
)))
1549 INDENT (f
, indentG
);
1550 fprintf (f
,"SUPPLIER INVOKES\n");
1551 INDENT (f
, indentG
);
1554 indentG
+= indentStepG
;
1555 last
= (Value
*)LAST_LIST_ELMT (ase
->supplierInvokes
);
1556 FOR_EACH_LIST_ELMT (v
, ase
->supplierInvokes
)
1558 INDENT (f
, indentG
);
1559 PrintValue (f
, NULL
, t
, v
);
1564 indentG
-= indentStepG
;
1565 INDENT (f
, indentG
);
1569 indentG
-= indentStepG
;
1571 } /* PrintRosAseMacrType */
1577 PrintRosAcMacroType
PARAMS ((f
, head
, t
, bt
, ac
),
1589 fprintf (f
, "APPLICATION-CONTEXT");
1590 indentG
+= indentStepG
;
1593 * print non Ros Elements
1596 INDENT (f
, indentG
);
1597 fprintf (f
,"APPLICATION-SERVICE-ELEMENTS\n");
1598 INDENT (f
, indentG
);
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
)
1606 INDENT (f
, indentG
);
1607 PrintValue (f
, NULL
, t
, v
);
1616 INDENT (f
, indentG
);
1617 fprintf (f
,"BIND\n");
1618 INDENT (f
, indentG
);
1619 PrintType (f
, head
, ac
->bindMacroType
);
1625 INDENT (f
, indentG
);
1626 fprintf (f
,"UNBIND\n");
1627 INDENT (f
, indentG
);
1628 PrintType (f
, head
, ac
->unbindMacroType
);
1631 if (ac
->remoteOperations
!= NULL
)
1634 INDENT (f
, indentG
);
1635 fprintf (f
,"REMOTE OPERATIONS { ");
1636 PrintValue (f
, NULL
, t
, ac
->remoteOperations
);
1639 if ((ac
->operationsOf
!= NULL
) && (!LIST_EMPTY (ac
->operationsOf
)))
1642 INDENT (f
, indentG
);
1643 fprintf (f
,"OPERATIONS OF\n");
1644 INDENT (f
, indentG
);
1647 indentG
+= indentStepG
;
1648 last
= (Value
*)LAST_LIST_ELMT (ac
->operationsOf
);
1649 FOR_EACH_LIST_ELMT (v
, ac
->operationsOf
)
1651 INDENT (f
, indentG
);
1652 PrintValue (f
, NULL
, t
, v
);
1657 indentG
-= indentStepG
;
1658 INDENT (f
, indentG
);
1662 if ((ac
->initiatorConsumerOf
!= NULL
) && (!LIST_EMPTY (ac
->initiatorConsumerOf
)))
1665 INDENT (f
, indentG
);
1666 fprintf (f
,"INITIATOR CONSUMER OF\n");
1667 INDENT (f
, indentG
);
1670 indentG
+= indentStepG
;
1671 last
= (Value
*)LAST_LIST_ELMT (ac
->initiatorConsumerOf
);
1672 FOR_EACH_LIST_ELMT (v
, ac
->initiatorConsumerOf
)
1674 INDENT (f
, indentG
);
1675 PrintValue (f
, NULL
, t
, v
);
1680 indentG
-= indentStepG
;
1681 INDENT (f
, indentG
);
1685 if ((ac
->responderConsumerOf
!= NULL
) && (!LIST_EMPTY (ac
->responderConsumerOf
)))
1688 INDENT (f
, indentG
);
1689 fprintf (f
,"RESPONDER CONSUMER OF\n");
1690 INDENT (f
, indentG
);
1693 indentG
+= indentStepG
;
1694 last
= (Value
*)LAST_LIST_ELMT (ac
->responderConsumerOf
);
1695 FOR_EACH_LIST_ELMT (v
, ac
->responderConsumerOf
)
1697 INDENT (f
, indentG
);
1698 PrintValue (f
, NULL
, t
, v
);
1703 indentG
-= indentStepG
;
1704 INDENT (f
, indentG
);
1710 INDENT (f
, indentG
);
1711 fprintf (f
,"ABSTRACT SYNTAXES\n");
1712 INDENT (f
, indentG
);
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
)
1719 INDENT (f
, indentG
);
1725 indentG
-= indentStepG
;
1726 INDENT (f
, indentG
);
1729 indentG
-= indentStepG
;
1731 } /* PrintRosAcMacroType */
1735 PrintMtsasExtensionsMacroType
PARAMS ((f
, head
, t
, bt
, exts
),
1740 MtsasExtensionsMacroType
*exts
)
1745 fprintf (f
, "EXTENSIONS CHOSEN FROM");
1747 INDENT (f
, indentG
);
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
)
1755 INDENT (f
, indentG
);
1756 PrintValue (f
, NULL
, t
, v
);
1761 indentG
-= indentStepG
;
1762 INDENT (f
, indentG
);
1765 } /* PrintMtsasExtensionsMacroType */
1769 PrintMtsasExtensionMacroType
PARAMS ((f
, head
, t
, bt
, ext
),
1774 MtsasExtensionMacroType
*ext
)
1777 fprintf (f
, "EXTENSION");
1779 indentG
+= indentStepG
;
1780 if (ext
->elmtType
!= NULL
)
1783 INDENT (f
, indentG
);
1784 PrintElmtType (f
, head
, t
, ext
->elmtType
);
1786 if (ext
->defaultValue
!= NULL
)
1788 fprintf (f
, " DEFAULT ");
1789 PrintValue (f
, NULL
, t
, ext
->defaultValue
);
1793 if ((ext
->criticalForSubmission
!= NULL
) ||
1794 (ext
->criticalForTransfer
!= NULL
) ||
1795 (ext
->criticalForDelivery
!= NULL
))
1798 INDENT (f
, indentG
);
1799 fprintf (f
, "CRITICAL FOR ");
1801 if (ext
->criticalForSubmission
!= NULL
)
1803 fprintf (f
, "SUBMISSION");
1804 if ((ext
->criticalForTransfer
!= NULL
) ||
1805 (ext
->criticalForDelivery
!= NULL
))
1809 if (ext
->criticalForTransfer
!= NULL
)
1811 fprintf (f
, "TRANSFER, ");
1812 if (ext
->criticalForDelivery
!= NULL
)
1816 if (ext
->criticalForDelivery
!= NULL
)
1817 fprintf (f
, "DELIVERY");
1821 indentG
-= indentStepG
;
1823 } /* PrintMtsasExtensionMacroType */
1829 PrintMtsasExtensionAttributeMacroType
PARAMS ((f
, head
, t
, bt
, ext
),
1834 MtsasExtensionAttributeMacroType
*ext
)
1837 fprintf (f
, "EXTENSION-ATTRIBUTE");
1838 if (ext
->type
!= NULL
)
1841 indentG
+= indentStepG
;
1842 INDENT (f
, indentG
);
1844 PrintType (f
, head
, ext
->type
);
1845 indentG
-= indentStepG
;
1848 } /* PrintMtsasExtensionAttributeMacroType */
1853 PrintMtsasTokenMacroType
PARAMS ((f
, head
, t
, bt
, tok
),
1858 MtsasTokenMacroType
*tok
)
1861 fprintf (f
, "TOKEN");
1862 if (tok
->type
!= NULL
)
1865 indentG
+= indentStepG
;
1866 INDENT (f
, indentG
);
1867 PrintType (f
, head
, tok
->type
);
1868 indentG
-= indentStepG
;
1871 } /* PrintMtsasTokenMacro */
1875 PrintMtsasTokenDataMacroType
PARAMS ((f
, head
, t
, bt
, tok
),
1880 MtsasTokenDataMacroType
*tok
)
1883 fprintf (f
, "TOKEN-DATA");
1884 if (tok
->type
!= NULL
)
1887 indentG
+= indentStepG
;
1888 INDENT (f
, indentG
);
1890 PrintType (f
, head
, tok
->type
);
1891 indentG
-= indentStepG
;
1894 } /* PrintMtsasTokenDataMacro */
1898 PrintMtsasSecurityCategoryMacroType
PARAMS ((f
, head
, t
, bt
, sec
),
1903 MtsasSecurityCategoryMacroType
*sec
)
1906 fprintf (f
, "SECURITY-CATEGORY");
1907 if (sec
->type
!= NULL
)
1910 indentG
+= indentStepG
;
1911 INDENT (f
, indentG
);
1913 PrintType (f
, head
, sec
->type
);
1914 indentG
-= indentStepG
;
1917 } /* PrintMtsasSecurityCategoryMacroType */
1922 PrintAsnObjectMacroType
PARAMS ((f
, head
, t
, bt
, obj
),
1927 AsnObjectMacroType
*obj
)
1932 fprintf (f
, "OBJECT");
1934 indentG
+= indentStepG
;
1936 if ((obj
->ports
!= NULL
) && !LIST_EMPTY (obj
->ports
))
1940 INDENT (f
, indentG
);
1941 fprintf (f
, "PORTS\n");
1942 INDENT (f
, indentG
);
1944 indentG
+= indentStepG
;
1946 last
= (AsnPort
*)LAST_LIST_ELMT (obj
->ports
);
1947 FOR_EACH_LIST_ELMT (ap
, obj
->ports
)
1949 INDENT (f
, indentG
);
1950 PrintValue (f
, NULL
, t
, ap
->portValue
);
1952 if (ap
->portType
== CONSUMER_PORT
)
1953 fprintf (f
, " [C]");
1954 else if (ap
->portType
== SUPPLIER_PORT
)
1955 fprintf (f
, " [S]");
1961 indentG
-= indentStepG
;
1962 INDENT (f
, indentG
);
1965 indentG
-= indentStepG
;
1967 } /* PrintAsnObjectMacroType */
1972 PrintAsnPortMacroType
PARAMS ((f
, head
, t
, bt
, p
),
1977 AsnPortMacroType
*p
)
1982 fprintf (f
, "PORT");
1983 indentG
+= indentStepG
;
1984 if ((p
->abstractOps
!= NULL
) && (!LIST_EMPTY (p
->abstractOps
)))
1987 INDENT (f
, indentG
);
1988 fprintf (f
, "ABSTRACT OPERATIONS\n");
1989 INDENT (f
, indentG
);
1991 indentG
+= indentStepG
;
1993 last
= (TypeOrValue
*)LAST_LIST_ELMT (p
->abstractOps
);
1994 FOR_EACH_LIST_ELMT (tOrV
, p
->abstractOps
)
1996 INDENT (f
, indentG
);
1998 if (tOrV
->choiceId
== TYPEORVALUE_TYPE
)
1999 PrintType (f
, head
, tOrV
->a
.type
);
2001 PrintValue (f
, NULL
, t
, tOrV
->a
.value
);
2007 indentG
-= indentStepG
;
2008 INDENT (f
, indentG
);
2012 if ((p
->consumerInvokes
!= NULL
) && (!LIST_EMPTY (p
->consumerInvokes
)))
2015 INDENT (f
, indentG
);
2016 fprintf (f
, "CONSUMER INVOKES\n");
2017 INDENT (f
, indentG
);
2019 indentG
+= indentStepG
;
2021 last
= (TypeOrValue
*)LAST_LIST_ELMT (p
->consumerInvokes
);
2022 FOR_EACH_LIST_ELMT (tOrV
, p
->consumerInvokes
)
2024 INDENT (f
, indentG
);
2026 if (tOrV
->choiceId
== TYPEORVALUE_TYPE
)
2027 PrintType (f
, head
, tOrV
->a
.type
);
2029 PrintValue (f
, NULL
, t
, tOrV
->a
.value
);
2035 indentG
-= indentStepG
;
2036 INDENT (f
, indentG
);
2040 if ((p
->supplierInvokes
!= NULL
) && (!LIST_EMPTY (p
->supplierInvokes
)))
2043 INDENT (f
, indentG
);
2044 fprintf (f
, "SUPPLIER INVOKES\n");
2045 INDENT (f
, indentG
);
2047 indentG
+= indentStepG
;
2049 last
= (TypeOrValue
*)LAST_LIST_ELMT (p
->supplierInvokes
);
2050 FOR_EACH_LIST_ELMT (tOrV
, p
->supplierInvokes
)
2053 INDENT (f
, indentG
);
2055 if (tOrV
->choiceId
== TYPEORVALUE_TYPE
)
2056 PrintType (f
, head
, tOrV
->a
.type
);
2058 PrintValue (f
, NULL
, t
, tOrV
->a
.value
);
2064 indentG
-= indentStepG
;
2065 INDENT (f
, indentG
);
2069 indentG
-= indentStepG
;
2071 } /* PrintAsnPortMacroType */
2077 PrintAsnAbstractBindMacroType
PARAMS ((f
, head
, t
, bt
, bind
),
2082 AsnAbstractBindMacroType
*bind
)
2087 if (bt
->a
.macroType
->choiceId
== MACROTYPE_ASNABSTRACTBIND
)
2088 fprintf (f
, "ABSTRACT-BIND");
2090 fprintf (f
, "ABSTRACT-UNBIND");
2092 indentG
+= indentStepG
;
2094 if ((bind
->ports
!= NULL
) && (!LIST_EMPTY (bind
->ports
)))
2097 INDENT (f
, indentG
);
2098 if (bt
->a
.macroType
->choiceId
== MACROTYPE_ASNABSTRACTBIND
)
2099 fprintf (f
, "TO\n");
2101 fprintf (f
, "FROM\n");
2103 INDENT (f
, indentG
);
2105 indentG
+= indentStepG
;
2107 last
= (AsnPort
*)LAST_LIST_ELMT (bind
->ports
);
2108 FOR_EACH_LIST_ELMT (ap
, bind
->ports
)
2110 INDENT (f
, indentG
);
2111 PrintValue (f
, NULL
, t
, ap
->portValue
);
2113 if (ap
->portType
== CONSUMER_PORT
)
2114 fprintf (f
, " [C]");
2115 else if (ap
->portType
== SUPPLIER_PORT
)
2116 fprintf (f
, " [S]");
2123 indentG
-= indentStepG
;
2124 INDENT (f
, indentG
);
2128 if (bind
->type
!= NULL
)
2131 INDENT (f
, indentG
);
2132 PrintType (f
, head
, bind
->type
);
2135 indentG
-= indentStepG
;
2137 } /* PrintAsnAbstractBindMacroType */
2142 PrintAfAlgorithmMacroType
PARAMS ((f
, head
, t
, bt
, alg
),
2149 indentG
+= indentStepG
;
2150 fprintf (f
, "ALGORITHM PARAMETER ");
2151 PrintType (f
, head
, alg
);
2152 indentG
-= indentStepG
;
2153 } /* PrintAfAlgorithmMacroType */
2157 PrintAfEncryptedMacroType
PARAMS ((f
, head
, t
, bt
, encrypt
),
2164 indentG
+= indentStepG
;
2165 fprintf (f
, "ENCRYPTED ");
2166 PrintType (f
, head
, encrypt
);
2167 indentG
-= indentStepG
;
2168 } /* PrintAfEncryptedMacroType */
2172 PrintAfSignedMacroType
PARAMS ((f
, head
, t
, bt
, sign
),
2179 indentG
+= indentStepG
;
2180 fprintf (f
, "SIGNED ");
2181 PrintType (f
, head
, sign
);
2182 indentG
-= indentStepG
;
2183 } /* PrintAfSignedMacroType */
2187 PrintAfSignatureMacroType
PARAMS ((f
, head
, t
, bt
, sig
),
2194 indentG
+= indentStepG
;
2195 fprintf (f
, "SIGNATURE ");
2196 PrintType (f
, head
, sig
);
2197 indentG
-= indentStepG
;
2198 } /* PrintAfSignatureMacroType */
2202 PrintAfProtectedMacroType
PARAMS ((f
, head
, t
, bt
, p
),
2209 indentG
+= indentStepG
;
2210 fprintf (f
, "PROTECTED ");
2211 PrintType (f
, head
, p
);
2212 indentG
-= indentStepG
;
2213 } /* PrintAfMacroType */
2217 PrintSnmpObjectTypeMacroType
PARAMS ((f
, head
, t
, bt
, ot
),
2222 SnmpObjectTypeMacroType
*ot
)
2227 fprintf (f
, "OBJECT-TYPE\n");
2228 indentG
+= indentStepG
;
2230 fprintf (f
,"SYNTAX ");
2231 indentG
+= indentStepG
;
2232 PrintType (f
, head
, ot
->syntax
);
2233 indentG
-= indentStepG
;
2237 fprintf (f
,"ACCESS ");
2240 case SNMP_READ_ONLY
:
2241 fprintf (f
,"read-only");
2244 case SNMP_READ_WRITE
:
2245 fprintf (f
,"read-write");
2248 case SNMP_WRITE_ONLY
:
2249 fprintf (f
,"write-only");
2252 case SNMP_NOT_ACCESSIBLE
:
2253 fprintf (f
,"not-accessible");
2257 fprintf (f
," < ?? unknown access type ?? >");
2261 INDENT (f
, indentG
);
2262 fprintf (f
,"STATUS ");
2265 case SNMP_MANDATORY
:
2266 fprintf (f
,"mandatory");
2270 fprintf (f
,"optional");
2274 fprintf (f
,"obsolete");
2277 case SNMP_DEPRECATED
:
2278 fprintf (f
,"deprecated");
2282 fprintf (f
," < ?? unknown status type ?? >");
2285 if (ot
->description
!= NULL
)
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
;
2296 if (ot
->reference
!= NULL
)
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
;
2307 if (ot
->index
!= NULL
)
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
)
2317 INDENT (f
, indentG
);
2318 if (tOrV
->choiceId
== TYPEORVALUE_TYPE
)
2319 PrintType (f
, head
, tOrV
->a
.type
);
2321 PrintValue (f
, NULL
, t
, tOrV
->a
.value
);
2326 indentG
-= indentStepG
;
2329 if (ot
->defVal
!= NULL
)
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
;
2342 indentG
-= indentStepG
;
2343 } /* PrintSnmpObjectTypeMacroType */
2347 * @MACRO@ add new macro print routines above this point
2351 PrintMacroDef
PARAMS ((f
, head
),
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");
2361 s
= head
->type
->basicType
->a
.macroDef
;
2363 fprintf (f
, "%s MACRO ::=\n", head
->definedName
);
2364 fprintf (f
, "%s", s
);
2366 } /* PrintMacroDef */
2371 PrintEncodedOid
PARAMS ((f
, eoid
),
2385 for (arcNum
= 0, i
=0; (i
< eoid
->octetLen
) && (eoid
->octs
[i
] & 0x80);i
++)
2386 arcNum
= (arcNum
<< 7) + (eoid
->octs
[i
] & 0x7f);
2388 arcNum
= (arcNum
<< 7) + (eoid
->octs
[i
] & 0x7f);
2391 firstArcNum
= arcNum
/ 40;
2392 if (firstArcNum
> 2)
2395 secondArcNum
= arcNum
- (firstArcNum
* 40);
2397 fprintf (f
, "%d ", firstArcNum
);
2398 fprintf (f
, "%d ", secondArcNum
);
2399 for (; i
< eoid
->octetLen
; )
2401 for (arcNum
= 0; (i
< eoid
->octetLen
) && (eoid
->octs
[i
] & 0x80);i
++)
2402 arcNum
= (arcNum
<< 7) + (eoid
->octs
[i
] & 0x7f);
2404 arcNum
= (arcNum
<< 7) + (eoid
->octs
[i
] & 0x7f);
2407 fprintf (f
, "%d ", arcNum
);
2412 } /* PrintEncodedOid */
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
2424 SpecialPrintBasicType
PARAMS ((f
, head
, t
, bt
),
2430 switch (bt
->choiceId
)
2433 case BASICTYPE_SEQUENCE
:
2434 fprintf (f
, "SEQUENCE");
2441 case BASICTYPE_CHOICE
:
2442 fprintf (f
, "CHOICE");
2447 case BASICTYPE_SEQUENCEOF
:
2448 fprintf (f
, "SEQUENCE ");
2449 if (t
->subtypes
!= NULL
)
2451 PrintSubtype (f
, head
, t
, t
->subtypes
);
2455 SpecialPrintType (f
, head
, t
->basicType
->a
.sequenceOf
);
2458 case BASICTYPE_SETOF
:
2459 fprintf (f
, "SET ");
2460 if (t
->subtypes
!= NULL
)
2462 PrintSubtype (f
, head
, t
, t
->subtypes
);
2466 SpecialPrintType (f
, head
, t
->basicType
->a
.sequenceOf
);
2470 case BASICTYPE_SELECTION
:
2471 fprintf (f
, "%s < ", bt
->a
.selection
->fieldName
);
2472 PrintType (f
, head
, bt
->a
.selection
->typeRef
);
2478 case BASICTYPE_COMPONENTSOF
:
2479 fprintf (f
, "COMPONENTS OF ");
2480 PrintType (f
, NULL
, bt
->a
.componentsOf
);
2485 case BASICTYPE_ANYDEFINEDBY
:
2486 fprintf (f
, "ANY DEFINED BY %s", bt
->a
.anyDefinedBy
->fieldName
);
2490 case BASICTYPE_LOCALTYPEREF
:
2491 fprintf (f
, "%s", bt
->a
.localTypeRef
->typeName
);
2494 case BASICTYPE_IMPORTTYPEREF
:
2495 fprintf (f
, "%s", bt
->a
.importTypeRef
->typeName
);
2499 case BASICTYPE_UNKNOWN
:
2500 fprintf (f
, "unknown type !?!");
2503 case BASICTYPE_BOOLEAN
:
2504 fprintf (f
, "BOOLEAN");
2508 case BASICTYPE_INTEGER
:
2509 fprintf (f
, "INTEGER");
2510 if ((bt
->a
.integer
!= NULL
) && !LIST_EMPTY (bt
->a
.integer
))
2511 SpecialPrintNamedElmts (f
, head
, t
);
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
);
2521 case BASICTYPE_OCTETSTRING
:
2522 fprintf (f
, "OCTET STRING");
2525 case BASICTYPE_NULL
:
2526 fprintf (f
, "NULL");
2530 fprintf (f
, "OBJECT IDENTIFIER");
2533 case BASICTYPE_REAL
:
2534 fprintf (f
, "REAL");
2537 case BASICTYPE_ENUMERATED
:
2538 fprintf (f
, "ENUMERATED");
2539 if ((bt
->a
.enumerated
!= NULL
) && !LIST_EMPTY (bt
->a
.enumerated
))
2540 SpecialPrintNamedElmts (f
, head
, t
);
2548 case BASICTYPE_MACROTYPE
:
2549 switch (bt
->a
.macroType
->choiceId
)
2551 case MACROTYPE_ROSOPERATION
:
2552 case MACROTYPE_ASNABSTRACTOPERATION
:
2553 PrintRosOperationMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.rosOperation
);
2556 case MACROTYPE_ROSERROR
:
2557 case MACROTYPE_ASNABSTRACTERROR
:
2558 PrintRosErrorMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.rosError
);
2561 case MACROTYPE_ROSBIND
:
2562 case MACROTYPE_ROSUNBIND
:
2563 PrintRosBindMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.rosBind
);
2566 case MACROTYPE_ROSASE
:
2567 PrintRosAseMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.rosAse
);
2570 case MACROTYPE_MTSASEXTENSIONS
:
2571 PrintMtsasExtensionsMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.mtsasExtensions
);
2574 case MACROTYPE_MTSASEXTENSION
:
2575 PrintMtsasExtensionMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.mtsasExtension
);
2578 case MACROTYPE_MTSASEXTENSIONATTRIBUTE
:
2579 PrintMtsasExtensionAttributeMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.mtsasExtensionAttribute
);
2582 case MACROTYPE_MTSASTOKEN
:
2583 PrintMtsasTokenMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.mtsasToken
);
2586 case MACROTYPE_MTSASTOKENDATA
:
2587 PrintMtsasTokenDataMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.mtsasTokenData
);
2590 case MACROTYPE_MTSASSECURITYCATEGORY
:
2591 PrintMtsasSecurityCategoryMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.mtsasSecurityCategory
);
2594 case MACROTYPE_ASNOBJECT
:
2595 PrintAsnObjectMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.asnObject
);
2598 case MACROTYPE_ASNPORT
:
2599 PrintAsnPortMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.asnPort
);
2602 case MACROTYPE_ASNABSTRACTBIND
:
2603 case MACROTYPE_ASNABSTRACTUNBIND
:
2604 PrintAsnAbstractBindMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.asnAbstractBind
);
2607 case MACROTYPE_AFALGORITHM
:
2608 PrintAfAlgorithmMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.afAlgorithm
);
2611 case MACROTYPE_AFENCRYPTED
:
2612 PrintAfEncryptedMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.afEncrypted
);
2615 case MACROTYPE_AFSIGNED
:
2616 PrintAfSignedMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.afSigned
);
2619 case MACROTYPE_AFSIGNATURE
:
2620 PrintAfSignatureMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.afSignature
);
2623 case MACROTYPE_AFPROTECTED
:
2624 PrintAfProtectedMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.afProtected
);
2627 case MACROTYPE_SNMPOBJECTTYPE
:
2628 PrintSnmpObjectTypeMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.snmpObjectType
);
2632 fprintf (f
, "< unknown macro type id ?! >");
2634 } /* end macro type switch */
2638 * @MACRO@ add new macro printers above this point
2641 case BASICTYPE_MACRODEF
:
2643 * printing this should be handled in PrintTypeDefs
2649 fprintf (f
, "< unknown type id ?! >");
2652 } /* SpecialPrintBasicType */
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
2663 SpecialPrintType
PARAMS ((f
, head
, t
),
2675 FOR_EACH_LIST_ELMT (tag
, t
->tags
)
2677 if (!(tag
->tclass
== UNIV
&& tag
->code
== LIBTYPE_GET_UNIV_TAG_CODE (t
->basicType
->choiceId
)))
2686 * check type has been implicitly tagged
2689 fprintf (f
, "IMPLICIT ");
2691 SpecialPrintBasicType (f
, head
, t
, t
->basicType
);
2695 * sequences of and set of print subtypes a special way
2696 * so ignore them here
2698 if ((t
->subtypes
!= NULL
) &&
2699 (t
->basicType
->choiceId
!= BASICTYPE_SETOF
) &&
2700 (t
->basicType
->choiceId
!= BASICTYPE_SEQUENCEOF
))
2703 PrintSubtype (f
, head
, t
, t
->subtypes
);
2707 if (t
->defaultVal
!= NULL
)
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
);
2715 else if (t
->optional
)
2716 fprintf (f
, " OPTIONAL");
2720 fprintf (f
, " -- lineNo = %d", t
->lineNo
);
2724 } /* SpecialPrintType */
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
2736 SpecialPrintNamedElmts
PARAMS ((f
, head
, t
),
2743 CNamedElmts
*n
= NULL
;
2745 if (t
->cTypeRefInfo
!= NULL
)
2746 n
= t
->cTypeRefInfo
->cNamedElmts
;
2748 if ((n
== NULL
) && (t
->cxxTypeRefInfo
!= NULL
))
2749 n
= t
->cxxTypeRefInfo
->namedElmts
;
2752 if ((n
== NULL
) || LIST_EMPTY (n
))
2756 last
= (CNamedElmt
*)LAST_LIST_ELMT (n
);
2757 FOR_EACH_LIST_ELMT (cne
, n
)
2759 fprintf (f
, "%s (%d)", cne
->name
, cne
->value
);
2764 } /* SpecialPrintNamedElmts */