2 * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved.
4 * The contents of this file constitute Original Code as defined in and are
5 * subject to the Apple Public Source License Version 1.2 (the 'License').
6 * You may not use this file except in compliance with the License. Please obtain
7 * a copy of the License at http://www.apple.com/publicsource and read it before
10 * This Original Code and all software distributed under the License are
11 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS
12 * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT
13 * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the
15 * specific language governing rights and limitations under the License.
20 * compiler/back-ends/c-gen/gen-enc.c - routines for printing c encoders from type trees
24 * Copyright (C) 1991, 1992 Michael Sample
25 * and the University of British Columbia
27 * This program is free software; you can redistribute it and/or modify
28 * it under the terms of the GNU General Public License as published by
29 * the Free Software Foundation; either version 2 of the License, or
30 * (at your option) any later version.
32 * $Header: /cvs/Darwin/Security/SecuritySNACCRuntime/compiler/back-ends/c-gen/gen-enc.c,v 1.1.1.1 2001/05/18 23:14:09 mb Exp $
34 * Revision 1.1.1.1 2001/05/18 23:14:09 mb
35 * Move from private repository to open source repository
37 * Revision 1.2 2001/05/05 00:59:28 rmurphy
38 * Adding darwin license headers
40 * Revision 1.1.1.1 1999/03/16 18:06:42 aram
41 * Originals from SMIME Free Library.
43 * Revision 1.3 1995/07/25 18:42:24 rj
44 * file name has been shortened for redundant part: c-gen/gen-c-enc -> c-gen/gen-enc.
46 * changed `_' to `-' in file names.
48 * Revision 1.2 1994/09/01 00:23:10 rj
49 * snacc_config.h and other superfluous .h files removed.
51 * Revision 1.1 1994/08/28 09:48:24 rj
52 * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog.
59 #include "asn1module.h"
63 #include "type-info.h"
67 #include "snacc-util.h"
72 static int moduleImplicitTagsG
;
73 static CRules
*genEncCRulesG
;
74 extern char *valueArgNameG
;
76 char *encodedLenVarNameG
= "totalLen";
77 char *itemLenNameG
= "itemLen";
78 char *listComponentNameG
= "component";
79 char *listLenNameG
= "listLen";
80 char *returnTypeG
= "AsnLen";
81 extern char *bufTypeNameG
;
82 extern char *lenTypeNameG
;
83 extern char *tagTypeNameG
;
84 extern char *envTypeNameG
;
87 /* non-exported prototypes */
89 static void PrintCBerEncoderPrototype
PROTO ((FILE *hdr
, TypeDef
*td
));
90 static void PrintCBerEncoderDeclaration
PROTO ((FILE *src
, TypeDef
*td
));
91 static void PrintCBerEncoderDefine
PROTO ((FILE *src
, TypeDef
*td
));
93 static void PrintCBerEncoderLocals
PROTO ((FILE *src
, TypeDef
*td
));
95 static void PrintCBerElmtsEncodeCode
PROTO ((FILE *src
, TypeDef
*td
, Type
*parent
, NamedTypeList
*e
, int level
, char *varName
));
96 static void PrintCBerElmtEncodeCode
PROTO ((FILE *src
, TypeDef
*td
, Type
*parent
, NamedType
*e
, int level
, char *varName
));
98 static void PrintCBerListEncoderCode
PROTO ((FILE *src
, TypeDef
*td
, Type
*t
, int level
, char *varName
));
99 static void PrintCBerChoiceEncodeCode
PROTO ((FILE *src
, TypeDef
*td
, Type
*t
, int level
, char *varName
));
101 static void PrintCTagAndLenEncodingCode
PROTO ((FILE *src
, TypeDef
*td
, Type
*t
));
103 static void PrintEocEncoders
PROTO ((FILE *src
, TypeDef
*td
, Type
*t
));
105 static void PrintCLenEncodingCode
PROTO ((FILE *f
, int isCons
, int isShort
));
107 static void PrintCTagAndLenList
PROTO ((FILE *src
, Type
*t
,TagList
*tg
));
113 PrintCBerEncoder
PARAMS ((src
, hdr
, r
, m
, td
),
120 enum BasicTypeChoiceId typeId
;
131 ctdi
= td
->cTypeDefInfo
;
132 if (!ctdi
->genEncodeRoutine
)
136 * if is type that refs another pdu type or lib type
137 * without generating a new type via tagging or named elmts
138 * print define to the hdr file
139 * (a type is a pdu by default if it is ref'd by an ANY)
141 if (!IsNewType (td
->type
) &&
142 (!IsTypeRef (td
->type
) ||
143 (IsTypeRef (td
->type
) &&
144 (td
->type
->basicType
->a
.localTypeRef
->link
->cTypeDefInfo
->isPdu
||
145 ((td
->type
->basicType
->a
.localTypeRef
->link
->anyRefs
!= NULL
) &&
146 !LIST_EMPTY (td
->type
->basicType
->a
.localTypeRef
->link
->anyRefs
))))))
148 fprintf(hdr
,"#define B%s B%s\n", td
->cTypeDefInfo
->encodeRoutineName
, td
->type
->cTypeRefInfo
->encodeRoutineName
);
150 fprintf(hdr,"#define B%s(b, v, bytesDecoded, env) B%s(b, v, bytesDecoded, env)\n", td->cTypeDefInfo->encodeRoutineName, td->type->cTypeRefInfo->encodeRoutineName);
155 typeId
= GetBuiltinType (td
->type
);
157 /* print proto to hdr file */
158 fprintf (hdr
,"%s B%s PROTO ((%s b, %s *v));\n\n", lenTypeNameG
, ctdi
->encodeRoutineName
, bufTypeNameG
, ctdi
->cTypeName
);
160 /* print routine to src file */
161 fprintf (src
,"%s B%s PARAMS ((b, v),\n", lenTypeNameG
, ctdi
->encodeRoutineName
);
162 fprintf (src
,"%s b _AND_\n",bufTypeNameG
);
163 fprintf (src
,"%s *v)\n",ctdi
->cTypeName
);
165 fprintf (src
," %s l;\n", lenTypeNameG
);
167 PrintEocEncoders (src
, td
, td
->type
);
169 fprintf (src
," l = B%sContent (b, v);\n", ctdi
->encodeRoutineName
);
171 /* encode each tag/len pair if any */
172 tags
= GetTags (td
->type
, &stoleChoiceTags
);
173 if (! stoleChoiceTags
)
175 FOR_EACH_LIST_ELMT_RVS (tag
, tags
)
177 classStr
= Class2ClassStr (tag
->tclass
);
179 if (tag
->form
== ANY_FORM
)
181 formStr
= Form2FormStr (tag
->form
);
182 tagLen
= TagByteLen (tag
->code
);
185 if (tag
->form
== CONS
)
186 fprintf (src
," l += BEncConsLen (b, l);\n");
188 fprintf (src
," l += BEncDefLen (b, l);\n");
190 if (tag
->tclass
== UNIV
)
191 fprintf (src
," l += BEncTag%d (b, %s, %s, %s);\n", tagLen
, classStr
, formStr
, Code2UnivCodeStr (tag
->code
));
193 fprintf (src
," l += BEncTag%d (b, %s, %s, %d);\n", tagLen
, classStr
, formStr
, tag
->code
);
196 fprintf (src
," return l;\n");
197 fprintf (src
,"} /* B%s */\n\n", ctdi
->encodeRoutineName
);
200 } /* PrintCBerEncoder */
203 PrintCBerContentEncoder
PARAMS ((src
, hdr
, r
, m
, td
),
212 CTypeId rhsTypeId
; /* cTypeId of the type that defined this typedef */
216 ctdi
= td
->cTypeDefInfo
;
217 if (!ctdi
->genEncodeRoutine
)
220 rhsTypeId
= td
->type
->cTypeRefInfo
->cTypeId
;
224 fprintf (hdr
, "/* ANY - Fix Me! */\n");
227 * Note - ANY's don't have the 'Content' suffix cause they
228 * encode their tags and lengths
230 fprintf(hdr
, "#define B%s B%s\n", td
->cTypeDefInfo
->encodeRoutineName
, td
->type
->cTypeRefInfo
->encodeRoutineName
);
233 fprintf(hdr, "#define B%s( b, v) ",td->cTypeDefInfo->encodeRoutineName);
234 fprintf (hdr, "B%s (b, v)", td->type->cTypeRefInfo->encodeRoutineName);
242 PrintCBerEncoderDefine (hdr
, td
);
243 fprintf (hdr
,"\n\n");
247 PrintCBerEncoderPrototype (hdr
, td
);
248 PrintCBerEncoderDeclaration (src
, td
);
250 PrintCBerEncoderLocals (src
, td
);
251 fprintf (src
,"\n\n");
252 PrintCBerChoiceEncodeCode (src
, td
, td
->type
, FIRST_LEVEL
, valueArgNameG
);
253 fprintf (src
," return %s;\n\n", encodedLenVarNameG
);
254 fprintf (src
,"} /* B%sContent */",td
->cTypeDefInfo
->encodeRoutineName
);
255 fprintf (hdr
,"\n\n");
256 fprintf (src
,"\n\n");
260 PrintCBerEncoderPrototype (hdr
, td
);
261 PrintCBerEncoderDeclaration (src
, td
);
263 PrintCBerEncoderLocals (src
, td
);
264 fprintf (src
,"\n\n");
265 PrintCBerElmtsEncodeCode (src
, td
, td
->type
, td
->type
->basicType
->a
.set
, FIRST_LEVEL
, valueArgNameG
);
266 fprintf (src
," return %s;\n\n", encodedLenVarNameG
);
267 fprintf (src
,"} /* B%sContent */",td
->cTypeDefInfo
->encodeRoutineName
);
268 fprintf (hdr
,"\n\n");
269 fprintf (src
,"\n\n");
274 PrintCBerEncoderPrototype (hdr
, td
);
275 fprintf (hdr
,"\n\n");
277 PrintCBerEncoderDeclaration (src
, td
);
279 PrintCBerEncoderLocals (src
, td
);
280 fprintf (src
,"\n\n");
281 PrintCBerListEncoderCode (src
, td
, td
->type
, FIRST_LEVEL
, valueArgNameG
);
282 fprintf (src
," return %s;\n\n", listLenNameG
);
283 fprintf (src
,"} /* B%sContent */", td
->cTypeDefInfo
->encodeRoutineName
);
284 fprintf (src
,"\n\n");
288 /* fprintf (src," sorry, unsupported type \n\n"); */
292 fprintf (stderr
,"PrintCBerEncoder: ERROR - unknown c type id\n");
296 } /* PrintCBerContentEncoder */
301 * Prints prototype for encode routine in hdr file
304 PrintCBerEncoderPrototype
PARAMS ((hdr
, td
),
310 ctdi
= td
->cTypeDefInfo
;
311 fprintf (hdr
,"%s B%sContent PROTO ((%s b, %s *v));", returnTypeG
, ctdi
->encodeRoutineName
, bufTypeNameG
, ctdi
->cTypeName
);
313 } /* PrintCBerEncoderPrototype */
318 * Prints declarations of encode routine for the given type def
321 PrintCBerEncoderDeclaration
PARAMS ((src
, td
),
327 ctdi
= td
->cTypeDefInfo
;
328 fprintf (src
,"%s\nB%sContent PARAMS ((b, v),\n%s b _AND_\n%s *v)\n", returnTypeG
, ctdi
->encodeRoutineName
, bufTypeNameG
, ctdi
->cTypeName
);
330 } /* PrintCBerEncoderDeclaration */
336 * makes a define for type refs or primitive type renaming
338 * TypeX ::= INTEGER --> #define BerEncodeTypeX(b,v) BerEncodeInteger(b,v)
339 * TypeX ::= TypeY --> #define BerEncodeTypeX(b,v) BerEncodeTypeY(b,v)
342 PrintCBerEncoderDefine
PARAMS ((hdr
, td
),
346 fprintf(hdr
, "#define B%sContent B%sContent", td
->cTypeDefInfo
->encodeRoutineName
, td
->type
->cTypeRefInfo
->encodeRoutineName
);
349 fprintf(hdr, "#define B%sContent( b, v) ",td->cTypeDefInfo->encodeRoutineName);
350 fprintf (hdr, "B%sContent (b, v)", td->type->cTypeRefInfo->encodeRoutineName);
352 } /* PrintCBerEncoderDefine */
358 PrintCBerEncoderLocals
PARAMS ((src
, td
),
362 fprintf (src
, " AsnLen %s = 0;\n", encodedLenVarNameG
);
363 fprintf (src
, " AsnLen %s;\n", itemLenNameG
);
364 fprintf (src
, " AsnLen %s;\n", listLenNameG
);
365 fprintf (src
, " void *%s;", listComponentNameG
);
367 } /* PrintCBerEncoderLocals */
372 * runs through elmts backwards and prints
373 * encoding code for each one
376 PrintCBerElmtsEncodeCode
PARAMS ((src
, td
, parent
, elmts
, level
, varName
),
380 NamedTypeList
*elmts _AND_
388 fprintf (src
,"/* ERROR? - expected elmts for this type*/\n");
393 * remember! encoding "backwards" so recursively traverse
396 FOR_EACH_LIST_ELMT_RVS (e
, elmts
)
398 PrintCBerElmtEncodeCode (src
, td
, parent
, e
, level
, varName
);
401 } /* PrintCBerElmtsEncodeCode */
406 * Prints code for encoding the elmts of a SEQ or SET
409 PrintCBerElmtEncodeCode
PARAMS ((src
, td
, parent
, e
, level
, varName
),
418 char elmtVarRef
[MAX_VAR_REF
];
419 char idVarRef
[MAX_VAR_REF
];
420 enum BasicTypeChoiceId tmpTypeId
;
422 NamedType
*idNamedType
;
424 if ((e
->type
== NULL
) || (e
->type
->cTypeRefInfo
== NULL
))
427 ctri
= e
->type
->cTypeRefInfo
;
429 /* check if meant to be encoded */
434 MakeVarPtrRef (genEncCRulesG
, td
, parent
, e
->type
, varName
, elmtVarRef
);
436 if (e
->type
->optional
|| (e
->type
->defaultVal
!= NULL
))
437 fprintf (src
, " if (%s (%s))\n {\n", ctri
->optTestRoutineName
, elmtVarRef
);
439 PrintEocEncoders (src
, td
, e
->type
);
441 switch (ctri
->cTypeId
)
445 /* get type of 'defining' field (int/enum/oid)*/
446 idNamedType
= e
->type
->basicType
->a
.anyDefinedBy
->link
;
447 tmpTypeId
= GetBuiltinType (idNamedType
->type
);
449 if (tmpTypeId
== BASICTYPE_OID
)
451 MakeVarPtrRef (genEncCRulesG
, td
, parent
, idNamedType
->type
, varName
, idVarRef
);
452 fprintf (src
, " SetAnyTypeByOid (%s, %s);\n", elmtVarRef
, idVarRef
);
456 /* want to ref int by value not ptr */
457 MakeVarValueRef (genEncCRulesG
, td
, parent
, idNamedType
->type
, varName
, idVarRef
);
458 fprintf (src
, " SetAnyTypeByInt (%s, %s);\n", elmtVarRef
, idVarRef
);
461 /* ANY's enc's do tag and len so zap the Content suffix */
462 fprintf (src
, " %s = B%s (b, %s);\n", itemLenNameG
, ctri
->encodeRoutineName
, elmtVarRef
);
466 tmpType
= GetType (e
->type
);
468 /* NOTE: ANY DEFINED BY must be directly in the parent (not ref)*/
469 if (tmpType
->cTypeRefInfo
->cTypeId
!= C_ANY
)
471 fprintf (src
, " %s = B%sContent (b, %s);\n", itemLenNameG
, ctri
->encodeRoutineName
, elmtVarRef
);
474 else /* fall through */
477 /* ANY's enc's do tag and len so zap the Content suffix */
478 fprintf (src
," /* ANY - Fix Me! */\n");
479 fprintf (src
, " SetAnyTypeBy???(%s, ???);\n", elmtVarRef
);
480 fprintf (src
, " %s = B%s (b, %s);\n", itemLenNameG
, ctri
->encodeRoutineName
, elmtVarRef
);
485 fprintf (src
, " %s = B%sContent (b, %s);\n", itemLenNameG
, ctri
->encodeRoutineName
, elmtVarRef
);
489 PrintCBerChoiceEncodeCode (src
, td
, e
->type
, level
+1, elmtVarRef
);
493 PrintCBerElmtsEncodeCode (src
, td
, e
->type
, e
->type
->basicType
->a
.set
, level
+1, elmtVarRef
);
497 PrintCBerListEncoderCode (src
, td
, e
->type
, level
+1, elmtVarRef
);
498 fprintf (src
, " %s = %s;\n", itemLenNameG
, listLenNameG
);
499 fprintf (src
,"\n\n");
506 fprintf (stderr
,"PrintCBerElmtEncodeCode: ERROR - unknown c type id\n");
510 if (ctri
->cTypeId
!= C_ANY
) /* ANY's do their own tag/lens */
512 PrintCTagAndLenEncodingCode (src
, td
, e
->type
);
513 fprintf (src
,"\n %s += %s;\n", encodedLenVarNameG
, itemLenNameG
);
516 if (e
->type
->optional
|| (e
->type
->defaultVal
!= NULL
))
517 fprintf (src
, " }\n");
521 } /* PrintCBerElmtEncodeCode */
527 * Generates code for internally defined lists
529 * TypeX = SET { foo INTEGER, bar SEQUENCE OF INTEGER } -->
530 * BerEncodeTypeX (b, v)
534 * FOR_EACH_LIST_ELMT (component, v->bar)
536 * itemLen = BerEncodeInteger (b, (int*) component);
537 * itemLen+= EncodeLen (b, itemLen)
538 * itemLen += ENCODE_TAG (b, INTEGER_TAG);
539 * listLen += itemLen;
545 PrintCBerListEncoderCode
PARAMS ((src
, td
, t
, level
, varName
),
553 char *elmtVarRef
= "component";
555 enum BasicTypeChoiceId tmpTypeId
;
556 TypeDef
*idNamedType
;
559 ctri
= t
->basicType
->a
.setOf
->cTypeRefInfo
;
564 fprintf (src
, " listLen = 0;\n");
565 fprintf (src
, " FOR_EACH_LIST_ELMT_RVS (component, %s)\n", varName
);
566 fprintf (src
, " {\n");
568 PrintEocEncoders (src
, td
, t
->basicType
->a
.setOf
);
571 * need extra case here for SET OF typedef not just SET OF typeref
573 switch (ctri
->cTypeId
)
577 tmpType
= GetType (t
->basicType
->a
.setOf
);
579 /* NOTE: ANY DEFINED BY must be directly in the parent (not ref)*/
580 if (tmpType
->cTypeRefInfo
->cTypeId
!= C_ANY
)
582 fprintf (src
, " %s = B%sContent (b, %s);\n", itemLenNameG
, ctri
->encodeRoutineName
, elmtVarRef
);
585 else /* fall through */
588 /* ANY's enc's do tag and len so zap the Content suffix */
589 fprintf (src
," /* ANY - Fix Me! */\n");
590 fprintf (src
, " SetAnyTypeBy???(%s, ???);\n", elmtVarRef
);
591 fprintf (src
, " %s = B%s (b, %s);\n", itemLenNameG
, ctri
->encodeRoutineName
, elmtVarRef
);
597 fprintf (src
, " %s = B%sContent (b, (%s*) %s);\n", itemLenNameG
, ctri
->encodeRoutineName
, ctri
->cTypeName
, elmtVarRef
);
602 PrintCTagAndLenEncodingCode (src
, td
, t
->basicType
->a
.setOf
);
604 fprintf (src
, " %s += %s;\n", listLenNameG
, itemLenNameG
);
605 fprintf (src
, " }\n");
607 } /* PrintCBerListEncoderCode */
612 PrintCBerChoiceEncodeCode
PARAMS ((src
, td
, t
, level
, varName
),
623 ctri
= t
->cTypeRefInfo
;
625 fprintf (src
," switch (%s->%s)\n {\n", varName
, ctri
->choiceIdEnumFieldName
);
627 FOR_EACH_LIST_ELMT (e
, t
->basicType
->a
.choice
)
629 tmp
= (void*)CURR_LIST_NODE (t
->basicType
->a
.choice
);
634 ctri
= e
->type
->cTypeRefInfo
;
637 fprintf (src
, " case %s:\n", ctri
->choiceIdSymbol
);
639 fprintf (src
, " case ????:\n");
643 PrintCBerElmtEncodeCode (src
, td
, t
, e
, level
+1, varName
);
644 fprintf (src
," break;\n\n");
646 SET_CURR_LIST_NODE (t
->basicType
->a
.choice
, tmp
);
649 fprintf (src
, " }\n");
650 } /* PrintCBerChoiceEncodeCode */
655 * prints DecodeBerEocIfNec (b) for each constructed len
656 * assoc with given type
659 PrintEocEncoders
PARAMS ((src
, td
, t
),
670 * get all the tags on this type
672 tl
= (TagList
*) GetTags (t
, &stoleChoiceTags
);
675 * leave choice elmt tag enc to encoding routine
678 if (!stoleChoiceTags
)
680 FOR_EACH_LIST_ELMT (tag
, tl
)
682 if (tag
->form
== CONS
)
683 fprintf (src
," BEncEocIfNec (b);\n");
688 if (!stoleChoiceTags)
690 FOR_EACH_LIST_ELMT (tag, tl)
694 if (IsPrimitiveByDefOrRef (t))
697 for (; consTagCount > 0; consTagCount--)
698 fprintf (src," BEncEocIfNec (b);\n");
704 } /* PrintEocEncoders */
708 * Recursively walks throught type refs printing lower lvl tags
709 * first (since encoding is done backwards).
713 PrintCTagAndLenEncodingCode
PARAMS ((src
, td
, t
),
722 * get all the tags on this type
724 tl
= (TagList
*) GetTags (t
, &stoleChoiceTags
);
727 * leave choice elmt tag enc to encoding routine
729 if (!stoleChoiceTags
)
730 PrintCTagAndLenList (src
, t
, tl
);
734 } /* PrintCTagAndLenEncodingCode */
739 * prints last tag's encoding code first
742 PrintCTagAndLenList
PARAMS ((src
, t
, tagList
),
753 enum BasicTypeChoiceId typesType
;
756 if ((tagList
== NULL
) || LIST_EMPTY (tagList
))
760 * efficiency hack - use simple length (1 byte)
761 * encoded for type (almost) guaranteed to have
762 * encoded lengths of 0 <= len <= 127
764 typesType
= GetBuiltinType (t
);
765 if ((typesType
== BASICTYPE_BOOLEAN
) ||
766 (typesType
== BASICTYPE_INTEGER
) ||
767 (typesType
== BASICTYPE_NULL
) ||
768 (typesType
== BASICTYPE_REAL
) ||
769 (typesType
== BASICTYPE_ENUMERATED
))
775 * since encoding backward encode tags backwards
777 last
= (Tag
*)LAST_LIST_ELMT (tagList
);
778 FOR_EACH_LIST_ELMT_RVS (tg
, tagList
)
780 classStr
= Class2ClassStr (tg
->tclass
);
782 if (tg
->form
== CONS
)
784 formStr
= Form2FormStr (CONS
);
785 PrintCLenEncodingCode (src
, TRUE
, isShort
);
787 else /* PRIM or ANY_FORM */
789 formStr
= Form2FormStr (PRIM
);
790 PrintCLenEncodingCode (src
, FALSE
, isShort
);
793 /* GetTags sets the form bit correctly now
794 if (IsPrimitiveByDefOrRef (t) && (tg == last))
796 formStr = Form2FormStr (PRIM);
797 PrintCLenEncodingCode (src, FALSE, isShort);
801 formStr = Form2FormStr (CONS);
802 PrintCLenEncodingCode (src, TRUE, isShort);
810 else if (tg
->code
< 128)
812 else if (tg
->code
< 16384)
814 else if (tg
->code
< 2097152)
819 fprintf (src
," %s += BEncTag%d (b, %s, %s, %d);\n", itemLenNameG
, tagLen
, classStr
, formStr
, tg
->code
);
822 } /* PrintCTagAndLenList */
825 * prints length encoding code. Primitives always use
826 * definite length and constructors get "ConsLen"
827 * which can be configured at compile to to be indefinite
828 * or definite. Primitives can also be "short" (isShort is true)
829 * in which case a fast macro is used to write the length.
830 * Types for which isShort apply are: boolean, null and
831 * (almost always) integer and reals
834 PrintCLenEncodingCode
PARAMS ((f
, isCons
, isShort
),
839 /* fprintf (f, " BER_ENCODE_DEF_LEN (b, itemLen, itemLen);"); */
841 fprintf (f
, " itemLen += BEncConsLen (b, itemLen);");
846 fprintf (f
, " BEncDefLenTo127 (b, itemLen);\n");
847 fprintf (f
, " itemLen++;");
850 fprintf (f
, " itemLen += BEncDefLen (b, itemLen);");
852 } /* PrintCLenEncodingCode */