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/root/Security/SecuritySNACCRuntime/compiler/core/Attic/print.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 2000/05/10 21:37:46 rmurphy
26 * Adding back in code which had been renamed to file2.c
28 * Revision 1.1.1.1 1999/03/16 18:06:52 aram
29 * Originals from SMIME Free Library.
31 * Revision 1.6 1997/02/28 13:39:55 wan
32 * Modifications collected for new version 1.3: Bug fixes, tk4.2.
34 * Revision 1.5 1995/08/17 14:58:57 rj
35 * minor typographic change
37 * Revision 1.4 1995/07/25 19:41:42 rj
38 * changed `_' to `-' in file names.
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.
43 * Revision 1.2 1994/09/01 00:42:16 rj
44 * snacc_config.h removed.
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.
54 #include "asn1module.h"
55 #include "lib-types.h"
59 static int indentCountG
;
60 static int indentG
= 0;
61 static int indentStepG
= 4;
64 for (indentCountG = 0; indentCountG < (i); indentCountG++)\
68 * Prints the given Module *, mod, to the given FILE *f in
72 PrintModule
PARAMS ((f
, mod
),
77 if (mod
->status
== MOD_ERROR
)
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");
85 fprintf (f
, "%s ",mod
->modId
->name
);
86 PrintOid (f
, mod
->modId
->oid
);
88 fprintf (f
, "\nDEFINITIONS ");
90 if (mod
->tagDefault
== EXPLICIT_TAGS
)
91 fprintf (f
, "EXPLICIT TAGS");
93 else if (mod
->tagDefault
== IMPLICIT_TAGS
)
94 fprintf (f
, "IMPLICIT TAGS");
96 fprintf (f
, "\n\n -- compiler error unknown tag default");
99 fprintf (f
, " ::=\nBEGIN\n\n");
103 PrintExports (f
, mod
);
105 PrintImportLists (f
, mod
->imports
);
107 PrintTypeDefs (f
, mod
->typeDefs
);
108 PrintValueDefs (f
, mod
->valueDefs
);
110 fprintf (f
, "END\n");
116 PrintExports
PARAMS ((f
, m
),
124 if (m
->exportStatus
== EXPORTS_ALL
)
126 fprintf (f
, "\n\n-- exports everything\n\n");
128 else if (m
->exportStatus
== EXPORTS_NOTHING
)
130 fprintf (f
, "\n\nEXPORTS -- exports nothing\n\n");
134 fprintf (f
, "\n\nEXPORTS\n");
136 FOR_EACH_LIST_ELMT (td
, m
->typeDefs
)
141 fprintf (f
, "%s", td
->definedName
);
145 FOR_EACH_LIST_ELMT (vd
, m
->valueDefs
)
150 fprintf (f
, "%s", vd
->definedName
);
154 fprintf (f
, "\n;\n\n");
161 PrintOid
PARAMS ((f
, oid
),
171 for (; oid
!= NULL
; oid
= oid
->next
)
174 * value ref to an integer or if first elmt in
175 * oid can ref other oid value
178 if (oid
->valueRef
!= NULL
)
179 PrintValue (f
, NULL
, NULL
, oid
->valueRef
);
182 * just "arcNum" format
185 else if (oid
->arcNum
!= NULL_OID_ARCNUM
)
186 fprintf (f
, "%d", oid
->arcNum
);
198 PrintImportElmt
PARAMS ((f
, impElmt
),
202 fprintf (f
, "%s",impElmt
->name
);
203 } /* PrintImportElmt */
207 PrintImportElmts
PARAMS ((f
, impElmtList
),
209 ImportElmtList
*impElmtList
)
214 if ((impElmtList
== NULL
) || (LIST_EMPTY (impElmtList
)))
217 last
= (ImportElmt
*)LAST_LIST_ELMT (impElmtList
);
218 FOR_EACH_LIST_ELMT (ie
, impElmtList
)
220 PrintImportElmt (f
, ie
);
226 } /* PrintImportElmts */
231 PrintImportLists
PARAMS ((f
, impLists
),
233 ImportModuleList
*impLists
)
235 ImportModule
*impMod
;
237 if (impLists
== NULL
)
239 fprintf (f
,"\n\n-- imports nothing\n\n");
243 fprintf (f
, "IMPORTS\n\n");
244 FOR_EACH_LIST_ELMT (impMod
, impLists
)
246 PrintImportElmts (f
, impMod
->importElmts
);
248 fprintf (f
, "\n FROM %s ", impMod
->modId
->name
);
250 PrintOid (f
, impMod
->modId
->oid
);
252 fprintf (f
, "\n\n\n");
254 fprintf (f
, ";\n\n\n");
256 } /* PrintImportLists */
261 PrintTypeDefs
PARAMS ((f
, typeDefs
),
263 TypeDefList
*typeDefs
)
267 FOR_EACH_LIST_ELMT (td
, typeDefs
)
269 if (td
->type
->basicType
->choiceId
== BASICTYPE_MACRODEF
)
270 PrintMacroDef (f
, td
);
273 fprintf (f
,"-- %s notes: ", td
->definedName
);
276 fprintf (f
,"recursive, ");
278 fprintf (f
,"not recursive, ");
281 fprintf (f
,"exported,\n");
283 fprintf (f
,"not exported,\n");
285 fprintf (f
,"-- locally refd %d times, ", td
->localRefCount
);
286 fprintf (f
,"import refd %d times\n", td
->importRefCount
);
289 fprintf (f
, "%s ::= ", td
->definedName
);
290 PrintType (f
, td
, td
->type
);
292 fprintf (f
, "\n\n\n");
294 } /* PrintTypeDefs */
300 PrintType
PARAMS ((f
, head
, t
),
312 FOR_EACH_LIST_ELMT (tag
, t
->tags
)
317 if (! ((tag
->tclass
== UNIV
) &&
318 (tag
->code
== LIBTYPE_GET_UNIV_TAG_CODE (t
->basicType
->choiceId
))))
327 * check type has been implicitly tagged
330 fprintf (f
, "IMPLICIT ");
332 PrintBasicType (f
, head
, t
, t
->basicType
);
336 * sequences of and set of print subtypes a special way
337 * so ignore them here
339 if ((t
->subtypes
!= NULL
) &&
340 (t
->basicType
->choiceId
!= BASICTYPE_SETOF
) &&
341 (t
->basicType
->choiceId
!= BASICTYPE_SEQUENCEOF
))
344 PrintSubtype (f
, head
, t
, t
->subtypes
);
348 if (t
->defaultVal
!= NULL
)
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
);
356 else if (t
->optional
)
357 fprintf (f
, " OPTIONAL");
361 fprintf (f
, " -- lineNo = %d --", t
->lineNo
);
368 PrintBasicType
PARAMS ((f
, head
, t
, bt
),
374 switch (bt
->choiceId
)
377 case BASICTYPE_SEQUENCE
:
378 fprintf (f
, "SEQUENCE\n");
381 indentG
+= indentStepG
;
383 PrintElmtTypes (f
, head
, t
, bt
->a
.sequence
);
384 indentG
-= indentStepG
;
391 fprintf (f
, "SET\n");
394 indentG
+= indentStepG
;
396 PrintElmtTypes (f
, head
, t
, bt
->a
.set
);
397 indentG
-= indentStepG
;
403 case BASICTYPE_CHOICE
:
404 fprintf (f
, "CHOICE\n");
407 indentG
+= indentStepG
;
409 PrintElmtTypes (f
, head
, t
, bt
->a
.choice
);
410 indentG
-= indentStepG
;
418 case BASICTYPE_SEQUENCEOF
:
419 fprintf (f
, "SEQUENCE ");
420 if (t
->subtypes
!= NULL
)
422 PrintSubtype (f
, head
, t
, t
->subtypes
);
426 PrintType (f
, head
, bt
->a
.sequenceOf
);
429 case BASICTYPE_SETOF
:
431 if (t
->subtypes
!= NULL
)
433 PrintSubtype (f
, head
, t
, t
->subtypes
);
437 PrintType (f
, head
, bt
->a
.setOf
);
441 case BASICTYPE_SELECTION
:
442 fprintf (f
, "%s < ", bt
->a
.selection
->fieldName
);
443 PrintType (f
, head
, bt
->a
.selection
->typeRef
);
449 case BASICTYPE_COMPONENTSOF
:
450 fprintf (f
, "COMPONENTS OF ");
451 PrintType (f
, NULL
, bt
->a
.componentsOf
);
456 case BASICTYPE_ANYDEFINEDBY
:
457 fprintf (f
, "ANY DEFINED BY %s", bt
->a
.anyDefinedBy
->fieldName
);
461 case BASICTYPE_LOCALTYPEREF
:
462 fprintf (f
, "%s", bt
->a
.localTypeRef
->typeName
);
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
);
473 case BASICTYPE_UNKNOWN
:
474 fprintf (f
, "unknown type !?!");
477 case BASICTYPE_BOOLEAN
:
478 fprintf (f
, "BOOLEAN");
482 case BASICTYPE_INTEGER
:
483 fprintf (f
, "INTEGER");
484 if ((bt
->a
.integer
!= NULL
) && !LIST_EMPTY (bt
->a
.integer
))
489 indentG
+= indentStepG
;
490 PrintNamedElmts (f
, head
, t
, bt
->a
.integer
);
491 indentG
-= indentStepG
;
499 case BASICTYPE_BITSTRING
:
500 fprintf (f
, "BIT STRING");
501 if ((bt
->a
.bitString
!= NULL
) && !LIST_EMPTY (bt
->a
.bitString
))
506 indentG
+= indentStepG
;
507 PrintNamedElmts (f
, head
, t
, bt
->a
.bitString
);
508 indentG
-= indentStepG
;
515 case BASICTYPE_OCTETSTRING
:
516 fprintf (f
, "OCTET STRING");
524 fprintf (f
, "OBJECT IDENTIFIER");
531 case BASICTYPE_ENUMERATED
:
532 fprintf (f
, "ENUMERATED");
533 if ((bt
->a
.enumerated
!= NULL
) && !LIST_EMPTY (bt
->a
.enumerated
))
538 indentG
+= indentStepG
;
539 PrintNamedElmts (f
, head
, t
, bt
->a
.enumerated
);
540 indentG
-= indentStepG
;
551 case BASICTYPE_MACROTYPE
:
552 switch (bt
->a
.macroType
->choiceId
)
554 case MACROTYPE_ROSOPERATION
:
555 case MACROTYPE_ASNABSTRACTOPERATION
:
556 PrintRosOperationMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.rosOperation
);
559 case MACROTYPE_ROSERROR
:
560 case MACROTYPE_ASNABSTRACTERROR
:
561 PrintRosErrorMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.rosError
);
564 case MACROTYPE_ROSBIND
:
565 case MACROTYPE_ROSUNBIND
:
566 PrintRosBindMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.rosBind
);
569 case MACROTYPE_ROSASE
:
570 PrintRosAseMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.rosAse
);
573 case MACROTYPE_MTSASEXTENSIONS
:
574 PrintMtsasExtensionsMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.mtsasExtensions
);
577 case MACROTYPE_MTSASEXTENSION
:
578 PrintMtsasExtensionMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.mtsasExtension
);
581 case MACROTYPE_MTSASEXTENSIONATTRIBUTE
:
582 PrintMtsasExtensionAttributeMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.mtsasExtensionAttribute
);
585 case MACROTYPE_MTSASTOKEN
:
586 PrintMtsasTokenMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.mtsasToken
);
589 case MACROTYPE_MTSASTOKENDATA
:
590 PrintMtsasTokenDataMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.mtsasTokenData
);
593 case MACROTYPE_MTSASSECURITYCATEGORY
:
594 PrintMtsasSecurityCategoryMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.mtsasSecurityCategory
);
597 case MACROTYPE_ASNOBJECT
:
598 PrintAsnObjectMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.asnObject
);
601 case MACROTYPE_ASNPORT
:
602 PrintAsnPortMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.asnPort
);
605 case MACROTYPE_ASNABSTRACTBIND
:
606 case MACROTYPE_ASNABSTRACTUNBIND
:
607 PrintAsnAbstractBindMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.asnAbstractBind
);
610 case MACROTYPE_AFALGORITHM
:
611 PrintAfAlgorithmMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.afAlgorithm
);
614 case MACROTYPE_AFENCRYPTED
:
615 PrintAfEncryptedMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.afEncrypted
);
618 case MACROTYPE_AFSIGNED
:
619 PrintAfSignedMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.afSigned
);
622 case MACROTYPE_AFSIGNATURE
:
623 PrintAfSignatureMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.afSignature
);
626 case MACROTYPE_AFPROTECTED
:
627 PrintAfProtectedMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.afProtected
);
630 case MACROTYPE_SNMPOBJECTTYPE
:
631 PrintSnmpObjectTypeMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.snmpObjectType
);
635 fprintf (f
, "< unknown macro type id ?! >");
637 } /* end macro type switch */
641 * @MACRO@ add new macro printers above this point
644 case BASICTYPE_MACRODEF
:
646 * printing this should be handled in PrintTypeDefs
652 fprintf (f
, "< unknown type id ?! >");
655 } /* PrintBasicType */
660 PrintElmtType
PARAMS ((f
, head
, t
, nt
),
666 if (nt
->fieldName
!= NULL
)
667 fprintf (f
, "%s ", nt
->fieldName
);
669 PrintType (f
, head
, nt
->type
);
671 } /* PrintElmtType */
674 PrintElmtTypes
PARAMS ((f
, head
, t
, e
),
683 if ((e
== NULL
) || LIST_EMPTY (e
))
686 last
= (NamedType
*)LAST_LIST_ELMT (e
);
687 FOR_EACH_LIST_ELMT (nt
, e
)
690 PrintElmtType (f
, head
, t
, nt
);
697 } /* PrintElmtTypes */
703 PrintValueDefs
PARAMS ((f
, vList
),
708 FOR_EACH_LIST_ELMT (v
, vList
)
710 PrintValueDef (f
, v
);
712 } /* PrintValueDefs */
716 PrintValueDef
PARAMS ((f
, v
),
720 fprintf (f
, "%s ", v
->definedName
);
722 if (v
->value
->type
!= NULL
)
723 PrintType (f
, NULL
, v
->value
->type
);
725 /* just go by valueType */
726 PrintTypeById (f
, v
->value
->valueType
);
728 fprintf (f
, " ::= ");
729 indentG
+= indentStepG
;
730 PrintValue (f
, v
, v
->value
->type
, v
->value
);
732 indentG
-= indentStepG
;
733 } /* PrintValueDef */
737 PrintValue
PARAMS ((f
, head
, valuesType
, v
),
740 Type
*valuesType _AND_
746 PrintBasicValue (f
, head
, valuesType
, v
, v
->basicValue
);
752 PrintBasicValue
PARAMS ((f
, head
, valuesType
, v
, bv
),
755 Type
*valuesType _AND_
763 switch (bv
->choiceId
)
765 case BASICVALUE_UNKNOWN
:
766 fprintf (f
, "<unknown value>");
769 case BASICVALUE_EMPTY
:
773 case BASICVALUE_INTEGER
:
774 fprintf (f
, "%d", bv
->a
.integer
);
777 case BASICVALUE_SPECIALINTEGER
:
778 if (bv
->a
.specialInteger
== MAX_INT
)
785 case BASICVALUE_BOOLEAN
:
792 case BASICVALUE_REAL
:
793 fprintf (f
, "%f", bv
->a
.real
);
796 case BASICVALUE_SPECIALREAL
:
797 if (bv
->a
.specialReal
== PLUS_INFINITY_REAL
)
798 fprintf (f
, "PLUS INFINITY");
800 fprintf (f
, "MINUS INFINITY");
804 case BASICVALUE_ASCIITEXT
:
805 fprintf (f
, "\"%s\"", bv
->a
.asciiText
->octs
);
808 case BASICVALUE_ASCIIHEX
:
809 fprintf (f
, "\"%s\"", bv
->a
.asciiHex
->octs
);
812 case BASICVALUE_ASCIIBITSTRING
:
813 fprintf (f
, "\"%s\"", bv
->a
.asciiBitString
->octs
);
817 PrintEncodedOid (f
, bv
->a
.oid
);
820 case BASICVALUE_LINKEDOID
:
821 PrintOid (f
, bv
->a
.linkedOid
);
824 case BASICVALUE_BERVALUE
:
825 fprintf (f
,"<PrintBerValue not coded yet");
828 case BASICVALUE_PERVALUE
:
829 fprintf (f
,"<PrintPerValue not coded yet");
832 case BASICVALUE_NAMEDVALUE
:
836 indentG
+= indentStepG
;
837 PrintElmtValue (f
, head
, v
, bv
->a
.namedValue
);
838 indentG
-= indentStepG
;
844 case BASICVALUE_NULL
:
848 case BASICVALUE_LOCALVALUEREF
:
849 fprintf (f
, "%s", bv
->a
.localValueRef
->valueName
);
852 case BASICVALUE_IMPORTVALUEREF
:
853 fprintf (f
, "%s", bv
->a
.importValueRef
->valueName
);
856 case BASICVALUE_VALUENOTATION
:
857 fprintf (f
, "-- snacc warning: can't parse this value yet --");
858 fprintf (f
, "%s", bv
->a
.valueNotation
->octs
);
863 fprintf (stderr
,"PrintBasicValue: ERROR - unknown value type\n");
866 } /* PrintBasicValue */
870 PrintElmtValue
PARAMS ((f
, head
, v
, nv
),
876 if (nv
->fieldName
!= NULL
)
877 fprintf (f
, "%s ", nv
->fieldName
);
879 PrintValue (f
, NULL
, NULL
, nv
->value
);
880 } /* PrintElmtValue */
884 PrintElmtValues
PARAMS ((f
, head
, v
, e
),
893 if ((e
== NULL
) || LIST_EMPTY (e
))
896 last
= (NamedValue
*)LAST_LIST_ELMT (e
);
897 FOR_EACH_LIST_ELMT (nv
, e
)
899 PrintElmtValue (f
, head
, v
, nv
);
906 } /* PrintElmtValues */
910 PrintTypeById
PARAMS ((f
, typeId
),
916 case BASICTYPE_UNKNOWN
:
917 fprintf (f
, "UNKNOWN");
920 case BASICTYPE_BOOLEAN
:
921 fprintf (f
, "BOOLEAN");
924 case BASICTYPE_INTEGER
:
925 fprintf (f
, "INTEGER");
928 case BASICTYPE_BITSTRING
:
929 fprintf (f
, "BIT STRING");
932 case BASICTYPE_OCTETSTRING
:
933 fprintf (f
, "OCTET STRING");
941 case BASICTYPE_SEQUENCE
:
942 fprintf (f
, "SEQUENCE");
945 case BASICTYPE_SEQUENCEOF
:
946 fprintf (f
, "SEQUENCE OF");
953 case BASICTYPE_SETOF
:
954 fprintf (f
, "SET OF");
957 case BASICTYPE_CHOICE
:
958 fprintf (f
, "CHOICE");
961 case BASICTYPE_SELECTION
:
962 fprintf (f
, "SELECTION");
969 case BASICTYPE_ANYDEFINEDBY
:
970 fprintf (f
, "ANY DEFINED BY");
974 fprintf (f
, "OBJECT IDENTIFIER");
977 case BASICTYPE_ENUMERATED
:
978 fprintf (f
, "ENUMERATED");
985 case BASICTYPE_COMPONENTSOF
:
986 fprintf (f
, "COMPONENTS OF");
990 fprintf (f
, "ERROR - %d is an unknown type id\n", typeId
);
992 } /* PrintTypeById */
996 PrintTag
PARAMS ((f
, tag
),
1002 if (tag
->tclass
== UNIV
)
1006 case BOOLEAN_TAG_CODE
: name
= "BOOLEAN";
1008 case INTEGER_TAG_CODE
: name
= "INTEGER";
1010 case BITSTRING_TAG_CODE
: name
= "BITSTRING";
1012 case OCTETSTRING_TAG_CODE
: name
= "OCTETSTRING";
1014 case NULLTYPE_TAG_CODE
: name
= "NULL TYPE";
1016 case OID_TAG_CODE
: name
= "OBJECT ID";
1018 case OD_TAG_CODE
: name
= "OBEJECT DESCRIPTOR";
1020 case EXTERNAL_TAG_CODE
: name
= "EXTERNAL";
1022 case REAL_TAG_CODE
: name
= "REAL";
1024 case ENUM_TAG_CODE
: name
= "ENUMERATED";
1026 case SEQ_TAG_CODE
: name
= "SEQUENCE";
1028 case SET_TAG_CODE
: name
= "SET";
1030 case NUMERICSTRING_TAG_CODE
: name
= "NUMERIC STRING";
1032 case PRINTABLESTRING_TAG_CODE
: name
= "PRINTABLE STRING";
1034 case TELETEXSTRING_TAG_CODE
: name
= "TELETEX STRING";
1036 case VIDEOTEXSTRING_TAG_CODE
: name
= "VIDEOTEX STRING";
1038 case IA5STRING_TAG_CODE
: name
= "IA5 STRING";
1040 case UTCTIME_TAG_CODE
: name
= "UTC TIME";
1042 case GENERALIZEDTIME_TAG_CODE
: name
= "GENERALIZED TIME";
1044 case GRAPHICSTRING_TAG_CODE
: name
= "GRAPHIC STRING";
1046 case VISIBLESTRING_TAG_CODE
: name
= "VISIBLE STRING";
1048 case GENERALSTRING_TAG_CODE
: name
= "GENERAL STRING";
1051 default: name
= "UNKNOWN UNIVERSAL TYPE";
1053 fprintf (f
, "[UNIVERSAL %d]", tag
->code
);
1055 else if (tag
->tclass
== APPL
)
1057 fprintf (f
, "[APPLICATION %d]", tag
->code
);
1059 else if (tag
->tclass
== PRIV
)
1061 fprintf (f
, "[PRIVATE %d]", tag
->code
);
1063 else if (tag
->tclass
== CNTX
)
1065 fprintf (f
, "[%d]", tag
->code
);
1069 fprintf (f
, " EXPLICIT");
1075 PrintSubtype
PARAMS ((f
, head
, t
, s
),
1087 /* fprintf (f, "("); */
1089 switch (s
->choiceId
)
1091 case SUBTYPE_SINGLE
:
1092 PrintSubtypeValue (f
, head
, t
, s
->a
.single
);
1096 FOR_EACH_LIST_ELMT (tmpS
, s
->a
.and)
1099 PrintSubtype (f
, head
, t
, tmpS
);
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)
1111 PrintSubtype (f
, head
, t
, tmpS
);
1119 fprintf (f
, "NOT (");
1120 PrintSubtype (f
, head
, t
, s
->a
.not);
1125 fprintf (stderr
, "PrintSubtype: ERROR - unknown Subtypes choiceId\n");
1129 /* fprintf (f, ")"); */
1132 } /* PrintSubtype */
1137 PrintSubtypeValue
PARAMS ((f
, head
, t
, s
),
1146 switch (s
->choiceId
)
1148 case SUBTYPEVALUE_SINGLEVALUE
:
1149 PrintValue (f
, NULL
, NULL
, s
->a
.singleValue
);
1152 case SUBTYPEVALUE_CONTAINED
:
1153 fprintf (f
, "<PrintContainedSubtype not coded yet\n");
1156 case SUBTYPEVALUE_VALUERANGE
:
1157 PrintValue (f
, NULL
, NULL
, s
->a
.valueRange
->lowerEndValue
);
1158 if (!s
->a
.valueRange
->lowerEndInclusive
)
1161 if (!s
->a
.valueRange
->upperEndInclusive
)
1163 PrintValue (f
, NULL
, NULL
, s
->a
.valueRange
->upperEndValue
);
1167 case SUBTYPEVALUE_PERMITTEDALPHABET
:
1168 fprintf (f
,"FROM ");
1169 PrintSubtype (f
, head
, t
, s
->a
.permittedAlphabet
);
1172 case SUBTYPEVALUE_SIZECONSTRAINT
:
1173 fprintf (f
,"SIZE ");
1174 PrintSubtype (f
, head
, t
, s
->a
.sizeConstraint
);
1177 case SUBTYPEVALUE_INNERSUBTYPE
:
1178 PrintInnerSubtype (f
, head
, t
, s
->a
.innerSubtype
);
1182 fprintf (stderr
, "PrintSubtype: ERROR - unknown Subtype choiceId\n");
1185 } /* PrintSubtype */
1189 PrintInnerSubtype
PARAMS ((f
, head
, t
, i
),
1195 Constraint
*constraint
;
1196 if (i
->constraintType
== SINGLE_CT
)
1198 fprintf (f
,"WITH COMPONENT ");
1199 constraint
= *(Constraint
**)AsnListFirst (i
->constraints
);
1200 PrintSubtype (f
, head
, t
, constraint
->valueConstraints
);
1204 fprintf (f
, "WITH COMPONENTS\n");
1205 INDENT (f
, indentG
);
1207 indentG
+= indentStepG
;
1208 if (i
->constraintType
== PARTIAL_CT
)
1210 INDENT (f
, indentG
);
1211 fprintf (f
, "...,\n");
1213 PrintMultipleTypeConstraints (f
, head
, t
, i
->constraints
);
1214 indentG
-= indentStepG
;
1216 INDENT (f
, indentG
);
1220 } /* PrintInnerSubtype */
1225 PrintMultipleTypeConstraints
PARAMS ((f
, head
, t
, cList
),
1229 ConstraintList
*cList
)
1234 if ((cList
== NULL
) || LIST_EMPTY (cList
))
1237 last
= (Constraint
*)LAST_LIST_ELMT (cList
);
1238 FOR_EACH_LIST_ELMT (c
, cList
)
1240 if (c
->fieldRef
!= NULL
)
1242 INDENT (f
, indentG
);
1243 fprintf (f
, "%s ", c
->fieldRef
);
1247 PrintSubtype (f
, head
, t
, c
->valueConstraints
);
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");
1260 } /* PrintMultipleTypeConstraints */
1265 PrintNamedElmts
PARAMS ((f
, head
, t
, n
),
1274 if ((n
== NULL
) || LIST_EMPTY (n
))
1277 last
= (ValueDef
*)LAST_LIST_ELMT (n
);
1278 FOR_EACH_LIST_ELMT (vd
, n
)
1280 INDENT (f
, indentG
);
1281 fprintf (f
, "%s (", vd
->definedName
);
1282 PrintValue (f
, NULL
, NULL
, vd
->value
);
1287 } /* PrintNamedElmts */
1293 PrintRosOperationMacroType
PARAMS ((f
, head
, t
, bt
, op
),
1298 RosOperationMacroType
*op
)
1303 if (bt
->a
.macroType
->choiceId
== MACROTYPE_ROSOPERATION
)
1304 fprintf (f
, "OPERATION");
1306 fprintf (f
, "ABSTRACT-OPERATION");
1308 indentG
+= indentStepG
;
1309 if (op
->arguments
!= NULL
)
1312 INDENT (f
, indentG
);
1313 fprintf (f
, "ARGUMENT\n");
1314 indentG
+= indentStepG
;
1316 INDENT (f
, indentG
);
1318 if (op
->arguments
->fieldName
!= NULL
)
1319 fprintf (f
, "%s ", op
->arguments
->fieldName
);
1321 PrintType (f
, head
, op
->arguments
->type
);
1322 indentG
-= indentStepG
;
1325 if (op
->result
!= NULL
)
1328 INDENT (f
, indentG
);
1329 fprintf (f
, "RESULT\n");
1330 indentG
+= indentStepG
;
1332 INDENT (f
, indentG
);
1334 if (op
->arguments
->fieldName
!= NULL
)
1335 fprintf (f
, "%s ", op
->arguments
->fieldName
);
1337 PrintType (f
, head
, op
->result
->type
);
1338 indentG
-= indentStepG
;
1341 if ((op
->errors
== NULL
) || (!LIST_EMPTY (op
->errors
)))
1344 INDENT (f
, indentG
);
1345 fprintf (f
, "ERRORS\n");
1346 INDENT (f
, indentG
);
1348 indentG
+= indentStepG
;
1350 last
= (TypeOrValue
*)LAST_LIST_ELMT (op
->errors
);
1351 FOR_EACH_LIST_ELMT (tOrV
, op
->errors
)
1353 INDENT (f
, indentG
);
1354 if (tOrV
->choiceId
== TYPEORVALUE_TYPE
)
1355 PrintType (f
, head
, tOrV
->a
.type
);
1357 PrintValue (f
, NULL
, t
, tOrV
->a
.value
);
1363 indentG
-= indentStepG
;
1365 INDENT (f
, indentG
);
1369 if ((op
->linkedOps
!= NULL
) && (!LIST_EMPTY (op
->linkedOps
)))
1372 INDENT (f
, indentG
);
1373 fprintf (f
, "LINKED\n");
1374 INDENT (f
, indentG
);
1376 indentG
+= indentStepG
;
1378 last
= (TypeOrValue
*)LAST_LIST_ELMT (op
->linkedOps
);
1379 FOR_EACH_LIST_ELMT (tOrV
, op
->linkedOps
)
1381 INDENT (f
, indentG
);
1382 if (tOrV
->choiceId
== TYPEORVALUE_TYPE
)
1383 PrintType (f
, head
, tOrV
->a
.type
);
1385 PrintValue (f
, NULL
, t
, tOrV
->a
.value
);
1390 indentG
-= indentStepG
;
1392 INDENT (f
, indentG
);
1396 indentG
-= indentStepG
;
1398 } /* PrintRosOperationMacroType */
1403 PrintRosErrorMacroType
PARAMS ((f
, head
, t
, bt
, err
),
1408 RosErrorMacroType
*err
)
1410 if (bt
->a
.macroType
->choiceId
== MACROTYPE_ROSERROR
)
1411 fprintf (f
,"ERROR\n");
1413 fprintf (f
,"ABSTRACT-ERROR\n");
1415 indentG
+= indentStepG
;
1417 if (err
->parameter
!= NULL
)
1419 INDENT (f
, indentG
);
1420 fprintf (f
,"PARAMETER ");
1421 indentG
+= indentStepG
;
1422 PrintElmtType (f
, head
, t
, err
->parameter
);
1423 indentG
-= indentStepG
;
1425 indentG
-= indentStepG
;
1427 } /* PrintRosErrorMacroType */
1431 PrintRosBindMacroType
PARAMS ((f
, head
, t
, bt
, bind
),
1436 RosBindMacroType
*bind
)
1438 if (bt
->a
.macroType
->choiceId
== MACROTYPE_ROSBIND
)
1441 fprintf (f
,"UNBIND");
1443 indentG
+= indentStepG
;
1445 if (bind
->argument
!= NULL
)
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
;
1456 if (bind
->result
!= NULL
)
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
;
1467 if (bind
->error
!= NULL
)
1470 INDENT (f
, indentG
);
1471 if (bt
->a
.macroType
->choiceId
== MACROTYPE_ROSBIND
)
1472 fprintf (f
,"BIND-ERROR\n");
1474 fprintf (f
,"UNBIND-ERROR\n");
1476 indentG
+= indentStepG
;
1477 INDENT (f
, indentG
);
1478 PrintElmtType (f
, head
, t
, bind
->error
);
1479 indentG
-= indentStepG
;
1482 indentG
-= indentStepG
;
1484 } /* PrintRosBindMacroType */
1488 PrintRosAseMacroType
PARAMS ((f
, head
, t
, bt
, ase
),
1493 RosAseMacroType
*ase
)
1498 fprintf (f
, "APPLICATION-SERVICE-ELEMENT");
1499 indentG
+= indentStepG
;
1501 if ((ase
->operations
!= NULL
)&& (!LIST_EMPTY (ase
->operations
)))
1504 INDENT (f
, indentG
);
1505 fprintf (f
,"OPERATIONS\n");
1506 INDENT (f
, indentG
);
1509 indentG
+= indentStepG
;
1511 last
= (Value
*)LAST_LIST_ELMT (ase
->operations
);
1512 FOR_EACH_LIST_ELMT (v
, ase
->operations
)
1514 INDENT (f
, indentG
);
1515 PrintValue (f
, NULL
, t
, v
);
1520 indentG
-= indentStepG
;
1521 INDENT (f
, indentG
);
1525 else /* either suuplier invokes or consumer invokes will be valid */
1527 if ((ase
->consumerInvokes
!= NULL
) && (!LIST_EMPTY (ase
->consumerInvokes
)))
1530 INDENT (f
, indentG
);
1531 fprintf (f
,"CONSUMER INVOKES\n");
1532 INDENT (f
, indentG
);
1535 indentG
+= indentStepG
;
1536 last
= (Value
*) LAST_LIST_ELMT (ase
->consumerInvokes
);
1537 FOR_EACH_LIST_ELMT (v
, ase
->consumerInvokes
)
1539 INDENT (f
, indentG
);
1540 PrintValue (f
, NULL
, t
, v
);
1545 indentG
-= indentStepG
;
1546 INDENT (f
, indentG
);
1549 if ((ase
->operations
!= NULL
) && (!LIST_EMPTY (ase
->operations
)))
1552 INDENT (f
, indentG
);
1553 fprintf (f
,"SUPPLIER INVOKES\n");
1554 INDENT (f
, indentG
);
1557 indentG
+= indentStepG
;
1558 last
= (Value
*)LAST_LIST_ELMT (ase
->supplierInvokes
);
1559 FOR_EACH_LIST_ELMT (v
, ase
->supplierInvokes
)
1561 INDENT (f
, indentG
);
1562 PrintValue (f
, NULL
, t
, v
);
1567 indentG
-= indentStepG
;
1568 INDENT (f
, indentG
);
1572 indentG
-= indentStepG
;
1574 } /* PrintRosAseMacrType */
1580 PrintRosAcMacroType
PARAMS ((f
, head
, t
, bt
, ac
),
1592 fprintf (f
, "APPLICATION-CONTEXT");
1593 indentG
+= indentStepG
;
1596 * print non Ros Elements
1599 INDENT (f
, indentG
);
1600 fprintf (f
,"APPLICATION-SERVICE-ELEMENTS\n");
1601 INDENT (f
, indentG
);
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
)
1609 INDENT (f
, indentG
);
1610 PrintValue (f
, NULL
, t
, v
);
1619 INDENT (f
, indentG
);
1620 fprintf (f
,"BIND\n");
1621 INDENT (f
, indentG
);
1622 PrintType (f
, head
, ac
->bindMacroType
);
1628 INDENT (f
, indentG
);
1629 fprintf (f
,"UNBIND\n");
1630 INDENT (f
, indentG
);
1631 PrintType (f
, head
, ac
->unbindMacroType
);
1634 if (ac
->remoteOperations
!= NULL
)
1637 INDENT (f
, indentG
);
1638 fprintf (f
,"REMOTE OPERATIONS { ");
1639 PrintValue (f
, NULL
, t
, ac
->remoteOperations
);
1642 if ((ac
->operationsOf
!= NULL
) && (!LIST_EMPTY (ac
->operationsOf
)))
1645 INDENT (f
, indentG
);
1646 fprintf (f
,"OPERATIONS OF\n");
1647 INDENT (f
, indentG
);
1650 indentG
+= indentStepG
;
1651 last
= (Value
*)LAST_LIST_ELMT (ac
->operationsOf
);
1652 FOR_EACH_LIST_ELMT (v
, ac
->operationsOf
)
1654 INDENT (f
, indentG
);
1655 PrintValue (f
, NULL
, t
, v
);
1660 indentG
-= indentStepG
;
1661 INDENT (f
, indentG
);
1665 if ((ac
->initiatorConsumerOf
!= NULL
) && (!LIST_EMPTY (ac
->initiatorConsumerOf
)))
1668 INDENT (f
, indentG
);
1669 fprintf (f
,"INITIATOR CONSUMER OF\n");
1670 INDENT (f
, indentG
);
1673 indentG
+= indentStepG
;
1674 last
= (Value
*)LAST_LIST_ELMT (ac
->initiatorConsumerOf
);
1675 FOR_EACH_LIST_ELMT (v
, ac
->initiatorConsumerOf
)
1677 INDENT (f
, indentG
);
1678 PrintValue (f
, NULL
, t
, v
);
1683 indentG
-= indentStepG
;
1684 INDENT (f
, indentG
);
1688 if ((ac
->responderConsumerOf
!= NULL
) && (!LIST_EMPTY (ac
->responderConsumerOf
)))
1691 INDENT (f
, indentG
);
1692 fprintf (f
,"RESPONDER CONSUMER OF\n");
1693 INDENT (f
, indentG
);
1696 indentG
+= indentStepG
;
1697 last
= (Value
*)LAST_LIST_ELMT (ac
->responderConsumerOf
);
1698 FOR_EACH_LIST_ELMT (v
, ac
->responderConsumerOf
)
1700 INDENT (f
, indentG
);
1701 PrintValue (f
, NULL
, t
, v
);
1706 indentG
-= indentStepG
;
1707 INDENT (f
, indentG
);
1713 INDENT (f
, indentG
);
1714 fprintf (f
,"ABSTRACT SYNTAXES\n");
1715 INDENT (f
, indentG
);
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
)
1722 INDENT (f
, indentG
);
1728 indentG
-= indentStepG
;
1729 INDENT (f
, indentG
);
1732 indentG
-= indentStepG
;
1734 } /* PrintRosAcMacroType */
1738 PrintMtsasExtensionsMacroType
PARAMS ((f
, head
, t
, bt
, exts
),
1743 MtsasExtensionsMacroType
*exts
)
1748 fprintf (f
, "EXTENSIONS CHOSEN FROM");
1750 INDENT (f
, indentG
);
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
)
1758 INDENT (f
, indentG
);
1759 PrintValue (f
, NULL
, t
, v
);
1764 indentG
-= indentStepG
;
1765 INDENT (f
, indentG
);
1768 } /* PrintMtsasExtensionsMacroType */
1772 PrintMtsasExtensionMacroType
PARAMS ((f
, head
, t
, bt
, ext
),
1777 MtsasExtensionMacroType
*ext
)
1780 fprintf (f
, "EXTENSION");
1782 indentG
+= indentStepG
;
1783 if (ext
->elmtType
!= NULL
)
1786 INDENT (f
, indentG
);
1787 PrintElmtType (f
, head
, t
, ext
->elmtType
);
1789 if (ext
->defaultValue
!= NULL
)
1791 fprintf (f
, " DEFAULT ");
1792 PrintValue (f
, NULL
, t
, ext
->defaultValue
);
1796 if ((ext
->criticalForSubmission
!= NULL
) ||
1797 (ext
->criticalForTransfer
!= NULL
) ||
1798 (ext
->criticalForDelivery
!= NULL
))
1801 INDENT (f
, indentG
);
1802 fprintf (f
, "CRITICAL FOR ");
1804 if (ext
->criticalForSubmission
!= NULL
)
1806 fprintf (f
, "SUBMISSION");
1807 if ((ext
->criticalForTransfer
!= NULL
) ||
1808 (ext
->criticalForDelivery
!= NULL
))
1812 if (ext
->criticalForTransfer
!= NULL
)
1814 fprintf (f
, "TRANSFER, ");
1815 if (ext
->criticalForDelivery
!= NULL
)
1819 if (ext
->criticalForDelivery
!= NULL
)
1820 fprintf (f
, "DELIVERY");
1824 indentG
-= indentStepG
;
1826 } /* PrintMtsasExtensionMacroType */
1832 PrintMtsasExtensionAttributeMacroType
PARAMS ((f
, head
, t
, bt
, ext
),
1837 MtsasExtensionAttributeMacroType
*ext
)
1840 fprintf (f
, "EXTENSION-ATTRIBUTE");
1841 if (ext
->type
!= NULL
)
1844 indentG
+= indentStepG
;
1845 INDENT (f
, indentG
);
1847 PrintType (f
, head
, ext
->type
);
1848 indentG
-= indentStepG
;
1851 } /* PrintMtsasExtensionAttributeMacroType */
1856 PrintMtsasTokenMacroType
PARAMS ((f
, head
, t
, bt
, tok
),
1861 MtsasTokenMacroType
*tok
)
1864 fprintf (f
, "TOKEN");
1865 if (tok
->type
!= NULL
)
1868 indentG
+= indentStepG
;
1869 INDENT (f
, indentG
);
1870 PrintType (f
, head
, tok
->type
);
1871 indentG
-= indentStepG
;
1874 } /* PrintMtsasTokenMacro */
1878 PrintMtsasTokenDataMacroType
PARAMS ((f
, head
, t
, bt
, tok
),
1883 MtsasTokenDataMacroType
*tok
)
1886 fprintf (f
, "TOKEN-DATA");
1887 if (tok
->type
!= NULL
)
1890 indentG
+= indentStepG
;
1891 INDENT (f
, indentG
);
1893 PrintType (f
, head
, tok
->type
);
1894 indentG
-= indentStepG
;
1897 } /* PrintMtsasTokenDataMacro */
1901 PrintMtsasSecurityCategoryMacroType
PARAMS ((f
, head
, t
, bt
, sec
),
1906 MtsasSecurityCategoryMacroType
*sec
)
1909 fprintf (f
, "SECURITY-CATEGORY");
1910 if (sec
->type
!= NULL
)
1913 indentG
+= indentStepG
;
1914 INDENT (f
, indentG
);
1916 PrintType (f
, head
, sec
->type
);
1917 indentG
-= indentStepG
;
1920 } /* PrintMtsasSecurityCategoryMacroType */
1925 PrintAsnObjectMacroType
PARAMS ((f
, head
, t
, bt
, obj
),
1930 AsnObjectMacroType
*obj
)
1935 fprintf (f
, "OBJECT");
1937 indentG
+= indentStepG
;
1939 if ((obj
->ports
!= NULL
) && !LIST_EMPTY (obj
->ports
))
1943 INDENT (f
, indentG
);
1944 fprintf (f
, "PORTS\n");
1945 INDENT (f
, indentG
);
1947 indentG
+= indentStepG
;
1949 last
= (AsnPort
*)LAST_LIST_ELMT (obj
->ports
);
1950 FOR_EACH_LIST_ELMT (ap
, obj
->ports
)
1952 INDENT (f
, indentG
);
1953 PrintValue (f
, NULL
, t
, ap
->portValue
);
1955 if (ap
->portType
== CONSUMER_PORT
)
1956 fprintf (f
, " [C]");
1957 else if (ap
->portType
== SUPPLIER_PORT
)
1958 fprintf (f
, " [S]");
1964 indentG
-= indentStepG
;
1965 INDENT (f
, indentG
);
1968 indentG
-= indentStepG
;
1970 } /* PrintAsnObjectMacroType */
1975 PrintAsnPortMacroType
PARAMS ((f
, head
, t
, bt
, p
),
1980 AsnPortMacroType
*p
)
1985 fprintf (f
, "PORT");
1986 indentG
+= indentStepG
;
1987 if ((p
->abstractOps
!= NULL
) && (!LIST_EMPTY (p
->abstractOps
)))
1990 INDENT (f
, indentG
);
1991 fprintf (f
, "ABSTRACT OPERATIONS\n");
1992 INDENT (f
, indentG
);
1994 indentG
+= indentStepG
;
1996 last
= (TypeOrValue
*)LAST_LIST_ELMT (p
->abstractOps
);
1997 FOR_EACH_LIST_ELMT (tOrV
, p
->abstractOps
)
1999 INDENT (f
, indentG
);
2001 if (tOrV
->choiceId
== TYPEORVALUE_TYPE
)
2002 PrintType (f
, head
, tOrV
->a
.type
);
2004 PrintValue (f
, NULL
, t
, tOrV
->a
.value
);
2010 indentG
-= indentStepG
;
2011 INDENT (f
, indentG
);
2015 if ((p
->consumerInvokes
!= NULL
) && (!LIST_EMPTY (p
->consumerInvokes
)))
2018 INDENT (f
, indentG
);
2019 fprintf (f
, "CONSUMER INVOKES\n");
2020 INDENT (f
, indentG
);
2022 indentG
+= indentStepG
;
2024 last
= (TypeOrValue
*)LAST_LIST_ELMT (p
->consumerInvokes
);
2025 FOR_EACH_LIST_ELMT (tOrV
, p
->consumerInvokes
)
2027 INDENT (f
, indentG
);
2029 if (tOrV
->choiceId
== TYPEORVALUE_TYPE
)
2030 PrintType (f
, head
, tOrV
->a
.type
);
2032 PrintValue (f
, NULL
, t
, tOrV
->a
.value
);
2038 indentG
-= indentStepG
;
2039 INDENT (f
, indentG
);
2043 if ((p
->supplierInvokes
!= NULL
) && (!LIST_EMPTY (p
->supplierInvokes
)))
2046 INDENT (f
, indentG
);
2047 fprintf (f
, "SUPPLIER INVOKES\n");
2048 INDENT (f
, indentG
);
2050 indentG
+= indentStepG
;
2052 last
= (TypeOrValue
*)LAST_LIST_ELMT (p
->supplierInvokes
);
2053 FOR_EACH_LIST_ELMT (tOrV
, p
->supplierInvokes
)
2056 INDENT (f
, indentG
);
2058 if (tOrV
->choiceId
== TYPEORVALUE_TYPE
)
2059 PrintType (f
, head
, tOrV
->a
.type
);
2061 PrintValue (f
, NULL
, t
, tOrV
->a
.value
);
2067 indentG
-= indentStepG
;
2068 INDENT (f
, indentG
);
2072 indentG
-= indentStepG
;
2074 } /* PrintAsnPortMacroType */
2080 PrintAsnAbstractBindMacroType
PARAMS ((f
, head
, t
, bt
, bind
),
2085 AsnAbstractBindMacroType
*bind
)
2090 if (bt
->a
.macroType
->choiceId
== MACROTYPE_ASNABSTRACTBIND
)
2091 fprintf (f
, "ABSTRACT-BIND");
2093 fprintf (f
, "ABSTRACT-UNBIND");
2095 indentG
+= indentStepG
;
2097 if ((bind
->ports
!= NULL
) && (!LIST_EMPTY (bind
->ports
)))
2100 INDENT (f
, indentG
);
2101 if (bt
->a
.macroType
->choiceId
== MACROTYPE_ASNABSTRACTBIND
)
2102 fprintf (f
, "TO\n");
2104 fprintf (f
, "FROM\n");
2106 INDENT (f
, indentG
);
2108 indentG
+= indentStepG
;
2110 last
= (AsnPort
*)LAST_LIST_ELMT (bind
->ports
);
2111 FOR_EACH_LIST_ELMT (ap
, bind
->ports
)
2113 INDENT (f
, indentG
);
2114 PrintValue (f
, NULL
, t
, ap
->portValue
);
2116 if (ap
->portType
== CONSUMER_PORT
)
2117 fprintf (f
, " [C]");
2118 else if (ap
->portType
== SUPPLIER_PORT
)
2119 fprintf (f
, " [S]");
2126 indentG
-= indentStepG
;
2127 INDENT (f
, indentG
);
2131 if (bind
->type
!= NULL
)
2134 INDENT (f
, indentG
);
2135 PrintType (f
, head
, bind
->type
);
2138 indentG
-= indentStepG
;
2140 } /* PrintAsnAbstractBindMacroType */
2145 PrintAfAlgorithmMacroType
PARAMS ((f
, head
, t
, bt
, alg
),
2152 indentG
+= indentStepG
;
2153 fprintf (f
, "ALGORITHM PARAMETER ");
2154 PrintType (f
, head
, alg
);
2155 indentG
-= indentStepG
;
2156 } /* PrintAfAlgorithmMacroType */
2160 PrintAfEncryptedMacroType
PARAMS ((f
, head
, t
, bt
, encrypt
),
2167 indentG
+= indentStepG
;
2168 fprintf (f
, "ENCRYPTED ");
2169 PrintType (f
, head
, encrypt
);
2170 indentG
-= indentStepG
;
2171 } /* PrintAfEncryptedMacroType */
2175 PrintAfSignedMacroType
PARAMS ((f
, head
, t
, bt
, sign
),
2182 indentG
+= indentStepG
;
2183 fprintf (f
, "SIGNED ");
2184 PrintType (f
, head
, sign
);
2185 indentG
-= indentStepG
;
2186 } /* PrintAfSignedMacroType */
2190 PrintAfSignatureMacroType
PARAMS ((f
, head
, t
, bt
, sig
),
2197 indentG
+= indentStepG
;
2198 fprintf (f
, "SIGNATURE ");
2199 PrintType (f
, head
, sig
);
2200 indentG
-= indentStepG
;
2201 } /* PrintAfSignatureMacroType */
2205 PrintAfProtectedMacroType
PARAMS ((f
, head
, t
, bt
, p
),
2212 indentG
+= indentStepG
;
2213 fprintf (f
, "PROTECTED ");
2214 PrintType (f
, head
, p
);
2215 indentG
-= indentStepG
;
2216 } /* PrintAfMacroType */
2220 PrintSnmpObjectTypeMacroType
PARAMS ((f
, head
, t
, bt
, ot
),
2225 SnmpObjectTypeMacroType
*ot
)
2230 fprintf (f
, "OBJECT-TYPE\n");
2231 indentG
+= indentStepG
;
2233 fprintf (f
,"SYNTAX ");
2234 indentG
+= indentStepG
;
2235 PrintType (f
, head
, ot
->syntax
);
2236 indentG
-= indentStepG
;
2240 fprintf (f
,"ACCESS ");
2243 case SNMP_READ_ONLY
:
2244 fprintf (f
,"read-only");
2247 case SNMP_READ_WRITE
:
2248 fprintf (f
,"read-write");
2251 case SNMP_WRITE_ONLY
:
2252 fprintf (f
,"write-only");
2255 case SNMP_NOT_ACCESSIBLE
:
2256 fprintf (f
,"not-accessible");
2260 fprintf (f
," < ?? unknown access type ?? >");
2264 INDENT (f
, indentG
);
2265 fprintf (f
,"STATUS ");
2268 case SNMP_MANDATORY
:
2269 fprintf (f
,"mandatory");
2273 fprintf (f
,"optional");
2277 fprintf (f
,"obsolete");
2280 case SNMP_DEPRECATED
:
2281 fprintf (f
,"deprecated");
2285 fprintf (f
," < ?? unknown status type ?? >");
2288 if (ot
->description
!= NULL
)
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
;
2299 if (ot
->reference
!= NULL
)
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
;
2310 if (ot
->index
!= NULL
)
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
)
2320 INDENT (f
, indentG
);
2321 if (tOrV
->choiceId
== TYPEORVALUE_TYPE
)
2322 PrintType (f
, head
, tOrV
->a
.type
);
2324 PrintValue (f
, NULL
, t
, tOrV
->a
.value
);
2329 indentG
-= indentStepG
;
2332 if (ot
->defVal
!= NULL
)
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
;
2345 indentG
-= indentStepG
;
2346 } /* PrintSnmpObjectTypeMacroType */
2350 * @MACRO@ add new macro print routines above this point
2354 PrintMacroDef
PARAMS ((f
, head
),
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");
2364 s
= head
->type
->basicType
->a
.macroDef
;
2366 fprintf (f
, "%s MACRO ::=\n", head
->definedName
);
2367 fprintf (f
, "%s", s
);
2369 } /* PrintMacroDef */
2374 PrintEncodedOid
PARAMS ((f
, eoid
),
2388 for (arcNum
= 0, i
=0; (i
< eoid
->octetLen
) && (eoid
->octs
[i
] & 0x80);i
++)
2389 arcNum
= (arcNum
<< 7) + (eoid
->octs
[i
] & 0x7f);
2391 arcNum
= (arcNum
<< 7) + (eoid
->octs
[i
] & 0x7f);
2394 firstArcNum
= arcNum
/ 40;
2395 if (firstArcNum
> 2)
2398 secondArcNum
= arcNum
- (firstArcNum
* 40);
2400 fprintf (f
, "%d ", firstArcNum
);
2401 fprintf (f
, "%d ", secondArcNum
);
2402 for (; i
< eoid
->octetLen
; )
2404 for (arcNum
= 0; (i
< eoid
->octetLen
) && (eoid
->octs
[i
] & 0x80);i
++)
2405 arcNum
= (arcNum
<< 7) + (eoid
->octs
[i
] & 0x7f);
2407 arcNum
= (arcNum
<< 7) + (eoid
->octs
[i
] & 0x7f);
2410 fprintf (f
, "%d ", arcNum
);
2415 } /* PrintEncodedOid */
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
2427 SpecialPrintBasicType
PARAMS ((f
, head
, t
, bt
),
2433 switch (bt
->choiceId
)
2436 case BASICTYPE_SEQUENCE
:
2437 fprintf (f
, "SEQUENCE");
2444 case BASICTYPE_CHOICE
:
2445 fprintf (f
, "CHOICE");
2450 case BASICTYPE_SEQUENCEOF
:
2451 fprintf (f
, "SEQUENCE ");
2452 if (t
->subtypes
!= NULL
)
2454 PrintSubtype (f
, head
, t
, t
->subtypes
);
2458 SpecialPrintType (f
, head
, t
->basicType
->a
.sequenceOf
);
2461 case BASICTYPE_SETOF
:
2462 fprintf (f
, "SET ");
2463 if (t
->subtypes
!= NULL
)
2465 PrintSubtype (f
, head
, t
, t
->subtypes
);
2469 SpecialPrintType (f
, head
, t
->basicType
->a
.sequenceOf
);
2473 case BASICTYPE_SELECTION
:
2474 fprintf (f
, "%s < ", bt
->a
.selection
->fieldName
);
2475 PrintType (f
, head
, bt
->a
.selection
->typeRef
);
2481 case BASICTYPE_COMPONENTSOF
:
2482 fprintf (f
, "COMPONENTS OF ");
2483 PrintType (f
, NULL
, bt
->a
.componentsOf
);
2488 case BASICTYPE_ANYDEFINEDBY
:
2489 fprintf (f
, "ANY DEFINED BY %s", bt
->a
.anyDefinedBy
->fieldName
);
2493 case BASICTYPE_LOCALTYPEREF
:
2494 fprintf (f
, "%s", bt
->a
.localTypeRef
->typeName
);
2497 case BASICTYPE_IMPORTTYPEREF
:
2498 fprintf (f
, "%s", bt
->a
.importTypeRef
->typeName
);
2502 case BASICTYPE_UNKNOWN
:
2503 fprintf (f
, "unknown type !?!");
2506 case BASICTYPE_BOOLEAN
:
2507 fprintf (f
, "BOOLEAN");
2511 case BASICTYPE_INTEGER
:
2512 fprintf (f
, "INTEGER");
2513 if ((bt
->a
.integer
!= NULL
) && !LIST_EMPTY (bt
->a
.integer
))
2514 SpecialPrintNamedElmts (f
, head
, t
);
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
);
2524 case BASICTYPE_OCTETSTRING
:
2525 fprintf (f
, "OCTET STRING");
2528 case BASICTYPE_NULL
:
2529 fprintf (f
, "NULL");
2533 fprintf (f
, "OBJECT IDENTIFIER");
2536 case BASICTYPE_REAL
:
2537 fprintf (f
, "REAL");
2540 case BASICTYPE_ENUMERATED
:
2541 fprintf (f
, "ENUMERATED");
2542 if ((bt
->a
.enumerated
!= NULL
) && !LIST_EMPTY (bt
->a
.enumerated
))
2543 SpecialPrintNamedElmts (f
, head
, t
);
2551 case BASICTYPE_MACROTYPE
:
2552 switch (bt
->a
.macroType
->choiceId
)
2554 case MACROTYPE_ROSOPERATION
:
2555 case MACROTYPE_ASNABSTRACTOPERATION
:
2556 PrintRosOperationMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.rosOperation
);
2559 case MACROTYPE_ROSERROR
:
2560 case MACROTYPE_ASNABSTRACTERROR
:
2561 PrintRosErrorMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.rosError
);
2564 case MACROTYPE_ROSBIND
:
2565 case MACROTYPE_ROSUNBIND
:
2566 PrintRosBindMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.rosBind
);
2569 case MACROTYPE_ROSASE
:
2570 PrintRosAseMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.rosAse
);
2573 case MACROTYPE_MTSASEXTENSIONS
:
2574 PrintMtsasExtensionsMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.mtsasExtensions
);
2577 case MACROTYPE_MTSASEXTENSION
:
2578 PrintMtsasExtensionMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.mtsasExtension
);
2581 case MACROTYPE_MTSASEXTENSIONATTRIBUTE
:
2582 PrintMtsasExtensionAttributeMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.mtsasExtensionAttribute
);
2585 case MACROTYPE_MTSASTOKEN
:
2586 PrintMtsasTokenMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.mtsasToken
);
2589 case MACROTYPE_MTSASTOKENDATA
:
2590 PrintMtsasTokenDataMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.mtsasTokenData
);
2593 case MACROTYPE_MTSASSECURITYCATEGORY
:
2594 PrintMtsasSecurityCategoryMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.mtsasSecurityCategory
);
2597 case MACROTYPE_ASNOBJECT
:
2598 PrintAsnObjectMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.asnObject
);
2601 case MACROTYPE_ASNPORT
:
2602 PrintAsnPortMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.asnPort
);
2605 case MACROTYPE_ASNABSTRACTBIND
:
2606 case MACROTYPE_ASNABSTRACTUNBIND
:
2607 PrintAsnAbstractBindMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.asnAbstractBind
);
2610 case MACROTYPE_AFALGORITHM
:
2611 PrintAfAlgorithmMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.afAlgorithm
);
2614 case MACROTYPE_AFENCRYPTED
:
2615 PrintAfEncryptedMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.afEncrypted
);
2618 case MACROTYPE_AFSIGNED
:
2619 PrintAfSignedMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.afSigned
);
2622 case MACROTYPE_AFSIGNATURE
:
2623 PrintAfSignatureMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.afSignature
);
2626 case MACROTYPE_AFPROTECTED
:
2627 PrintAfProtectedMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.afProtected
);
2630 case MACROTYPE_SNMPOBJECTTYPE
:
2631 PrintSnmpObjectTypeMacroType (f
, head
, t
, bt
, bt
->a
.macroType
->a
.snmpObjectType
);
2635 fprintf (f
, "< unknown macro type id ?! >");
2637 } /* end macro type switch */
2641 * @MACRO@ add new macro printers above this point
2644 case BASICTYPE_MACRODEF
:
2646 * printing this should be handled in PrintTypeDefs
2652 fprintf (f
, "< unknown type id ?! >");
2655 } /* SpecialPrintBasicType */
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
2666 SpecialPrintType
PARAMS ((f
, head
, t
),
2678 FOR_EACH_LIST_ELMT (tag
, t
->tags
)
2680 if (!(tag
->tclass
== UNIV
&& tag
->code
== LIBTYPE_GET_UNIV_TAG_CODE (t
->basicType
->choiceId
)))
2689 * check type has been implicitly tagged
2692 fprintf (f
, "IMPLICIT ");
2694 SpecialPrintBasicType (f
, head
, t
, t
->basicType
);
2698 * sequences of and set of print subtypes a special way
2699 * so ignore them here
2701 if ((t
->subtypes
!= NULL
) &&
2702 (t
->basicType
->choiceId
!= BASICTYPE_SETOF
) &&
2703 (t
->basicType
->choiceId
!= BASICTYPE_SEQUENCEOF
))
2706 PrintSubtype (f
, head
, t
, t
->subtypes
);
2710 if (t
->defaultVal
!= NULL
)
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
);
2718 else if (t
->optional
)
2719 fprintf (f
, " OPTIONAL");
2723 fprintf (f
, " -- lineNo = %d", t
->lineNo
);
2727 } /* SpecialPrintType */
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
2739 SpecialPrintNamedElmts
PARAMS ((f
, head
, t
),
2746 CNamedElmts
*n
= NULL
;
2748 if (t
->cTypeRefInfo
!= NULL
)
2749 n
= t
->cTypeRefInfo
->cNamedElmts
;
2751 if ((n
== NULL
) && (t
->cxxTypeRefInfo
!= NULL
))
2752 n
= t
->cxxTypeRefInfo
->namedElmts
;
2755 if ((n
== NULL
) || LIST_EMPTY (n
))
2759 last
= (CNamedElmt
*)LAST_LIST_ELMT (n
);
2760 FOR_EACH_LIST_ELMT (cne
, n
)
2762 fprintf (f
, "%s (%d)", cne
->name
, cne
->value
);
2767 } /* SpecialPrintNamedElmts */