]> git.saurik.com Git - apple/security.git/blame - SecuritySNACCRuntime/c-lib/asn-useful.c
Security-28.tar.gz
[apple/security.git] / SecuritySNACCRuntime / c-lib / asn-useful.c
CommitLineData
bac41a7b
A
1/*
2 * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved.
3 *
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
8 * using this file.
9 *
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.
16 */
17
18
19/*
20 * asn-useful.c
21 *
22 * "ASN-USEFUL" ASN.1 module encode/decode/print/free C src.
23 *
24 * This file was generated by snacc on Thu Jun 8 12:35:27 2000
25 *
26 * UBC snacc written by Mike Sample
27 *
28 * NOTE: This is a machine generated file - editing not recommended
29 */
30
31
32
33#include "asn-incl.h"
34#include "asn-useful.h"
35
36
37AsnLen BEncUTF8String PARAMS ((b, v),
38BUF_TYPE b _AND_
39UTF8String *v)
40{
41 AsnLen l;
42 l = BEncUTF8StringContent (b, v);
43 l += BEncDefLen (b, l);
44 l += BEncTag1 (b, UNIV, PRIM, 12);
45 return l;
46} /* BEncUTF8String */
47
48void BDecUTF8String PARAMS ((b, result, bytesDecoded, env),
49BUF_TYPE b _AND_
50UTF8String *result _AND_
51AsnLen *bytesDecoded _AND_
52ENV_TYPE env)
53{
54 AsnTag tag;
55 AsnLen elmtLen1;
56
57 if (((tag = BDecTag (b, bytesDecoded, env)) !=
58MAKE_TAG_ID (UNIV, PRIM, 12))&&
59 (tag != MAKE_TAG_ID (UNIV, CONS, 12)))
60 {
61 Asn1Error ("BDecUTF8String: ERROR - wrong tag\n");
62 longjmp (env, 50);
63 }
64 elmtLen1 = BDecLen (b, bytesDecoded, env);
65 BDecUTF8StringContent (b, tag, elmtLen1, result, bytesDecoded, env);
66} /* BDecUTF8String */
67
68AsnLen BEncNumericString PARAMS ((b, v),
69BUF_TYPE b _AND_
70NumericString *v)
71{
72 AsnLen l;
73 l = BEncNumericStringContent (b, v);
74 l += BEncDefLen (b, l);
75 l += BEncTag1 (b, UNIV, PRIM, NUMERICSTRING_TAG_CODE);
76 return l;
77} /* BEncNumericString */
78
79void BDecNumericString PARAMS ((b, result, bytesDecoded, env),
80BUF_TYPE b _AND_
81NumericString *result _AND_
82AsnLen *bytesDecoded _AND_
83ENV_TYPE env)
84{
85 AsnTag tag;
86 AsnLen elmtLen1;
87
88 if (((tag = BDecTag (b, bytesDecoded, env)) !=
89MAKE_TAG_ID (UNIV, PRIM, NUMERICSTRING_TAG_CODE))&&
90 (tag != MAKE_TAG_ID (UNIV, CONS, NUMERICSTRING_TAG_CODE)))
91 {
92 Asn1Error ("BDecNumericString: ERROR - wrong tag\n");
93 longjmp (env, 49);
94 }
95 elmtLen1 = BDecLen (b, bytesDecoded, env);
96 BDecNumericStringContent (b, tag, elmtLen1, result, bytesDecoded, env);
97} /* BDecNumericString */
98
99AsnLen BEncPrintableString PARAMS ((b, v),
100BUF_TYPE b _AND_
101PrintableString *v)
102{
103 AsnLen l;
104 l = BEncPrintableStringContent (b, v);
105 l += BEncDefLen (b, l);
106 l += BEncTag1 (b, UNIV, PRIM, PRINTABLESTRING_TAG_CODE);
107 return l;
108} /* BEncPrintableString */
109
110void BDecPrintableString PARAMS ((b, result, bytesDecoded, env),
111BUF_TYPE b _AND_
112PrintableString *result _AND_
113AsnLen *bytesDecoded _AND_
114ENV_TYPE env)
115{
116 AsnTag tag;
117 AsnLen elmtLen1;
118
119 if (((tag = BDecTag (b, bytesDecoded, env)) !=
120MAKE_TAG_ID (UNIV, PRIM, PRINTABLESTRING_TAG_CODE))&&
121 (tag != MAKE_TAG_ID (UNIV, CONS, PRINTABLESTRING_TAG_CODE)))
122 {
123 Asn1Error ("BDecPrintableString: ERROR - wrong tag\n");
124 longjmp (env, 48);
125 }
126 elmtLen1 = BDecLen (b, bytesDecoded, env);
127 BDecPrintableStringContent (b, tag, elmtLen1, result, bytesDecoded, env);
128} /* BDecPrintableString */
129
130AsnLen BEncTeletexString PARAMS ((b, v),
131BUF_TYPE b _AND_
132TeletexString *v)
133{
134 AsnLen l;
135 l = BEncTeletexStringContent (b, v);
136 l += BEncDefLen (b, l);
137 l += BEncTag1 (b, UNIV, PRIM, TELETEXSTRING_TAG_CODE);
138 return l;
139} /* BEncTeletexString */
140
141void BDecTeletexString PARAMS ((b, result, bytesDecoded, env),
142BUF_TYPE b _AND_
143TeletexString *result _AND_
144AsnLen *bytesDecoded _AND_
145ENV_TYPE env)
146{
147 AsnTag tag;
148 AsnLen elmtLen1;
149
150 if (((tag = BDecTag (b, bytesDecoded, env)) !=
151MAKE_TAG_ID (UNIV, PRIM, TELETEXSTRING_TAG_CODE))&&
152 (tag != MAKE_TAG_ID (UNIV, CONS, TELETEXSTRING_TAG_CODE)))
153 {
154 Asn1Error ("BDecTeletexString: ERROR - wrong tag\n");
155 longjmp (env, 47);
156 }
157 elmtLen1 = BDecLen (b, bytesDecoded, env);
158 BDecTeletexStringContent (b, tag, elmtLen1, result, bytesDecoded, env);
159} /* BDecTeletexString */
160
161AsnLen BEncT61String PARAMS ((b, v),
162BUF_TYPE b _AND_
163T61String *v)
164{
165 AsnLen l;
166 l = BEncT61StringContent (b, v);
167 l += BEncDefLen (b, l);
168 l += BEncTag1 (b, UNIV, PRIM, TELETEXSTRING_TAG_CODE);
169 return l;
170} /* BEncT61String */
171
172void BDecT61String PARAMS ((b, result, bytesDecoded, env),
173BUF_TYPE b _AND_
174T61String *result _AND_
175AsnLen *bytesDecoded _AND_
176ENV_TYPE env)
177{
178 AsnTag tag;
179 AsnLen elmtLen1;
180
181 if (((tag = BDecTag (b, bytesDecoded, env)) !=
182MAKE_TAG_ID (UNIV, PRIM, TELETEXSTRING_TAG_CODE))&&
183 (tag != MAKE_TAG_ID (UNIV, CONS, TELETEXSTRING_TAG_CODE)))
184 {
185 Asn1Error ("BDecT61String: ERROR - wrong tag\n");
186 longjmp (env, 46);
187 }
188 elmtLen1 = BDecLen (b, bytesDecoded, env);
189 BDecT61StringContent (b, tag, elmtLen1, result, bytesDecoded, env);
190} /* BDecT61String */
191
192AsnLen BEncVideotexString PARAMS ((b, v),
193BUF_TYPE b _AND_
194VideotexString *v)
195{
196 AsnLen l;
197 l = BEncVideotexStringContent (b, v);
198 l += BEncDefLen (b, l);
199 l += BEncTag1 (b, UNIV, PRIM, VIDEOTEXSTRING_TAG_CODE);
200 return l;
201} /* BEncVideotexString */
202
203void BDecVideotexString PARAMS ((b, result, bytesDecoded, env),
204BUF_TYPE b _AND_
205VideotexString *result _AND_
206AsnLen *bytesDecoded _AND_
207ENV_TYPE env)
208{
209 AsnTag tag;
210 AsnLen elmtLen1;
211
212 if (((tag = BDecTag (b, bytesDecoded, env)) !=
213MAKE_TAG_ID (UNIV, PRIM, VIDEOTEXSTRING_TAG_CODE))&&
214 (tag != MAKE_TAG_ID (UNIV, CONS, VIDEOTEXSTRING_TAG_CODE)))
215 {
216 Asn1Error ("BDecVideotexString: ERROR - wrong tag\n");
217 longjmp (env, 45);
218 }
219 elmtLen1 = BDecLen (b, bytesDecoded, env);
220 BDecVideotexStringContent (b, tag, elmtLen1, result, bytesDecoded, env);
221} /* BDecVideotexString */
222
223AsnLen BEncIA5String PARAMS ((b, v),
224BUF_TYPE b _AND_
225IA5String *v)
226{
227 AsnLen l;
228 l = BEncIA5StringContent (b, v);
229 l += BEncDefLen (b, l);
230 l += BEncTag1 (b, UNIV, PRIM, IA5STRING_TAG_CODE);
231 return l;
232} /* BEncIA5String */
233
234void BDecIA5String PARAMS ((b, result, bytesDecoded, env),
235BUF_TYPE b _AND_
236IA5String *result _AND_
237AsnLen *bytesDecoded _AND_
238ENV_TYPE env)
239{
240 AsnTag tag;
241 AsnLen elmtLen1;
242
243 if (((tag = BDecTag (b, bytesDecoded, env)) !=
244MAKE_TAG_ID (UNIV, PRIM, IA5STRING_TAG_CODE))&&
245 (tag != MAKE_TAG_ID (UNIV, CONS, IA5STRING_TAG_CODE)))
246 {
247 Asn1Error ("BDecIA5String: ERROR - wrong tag\n");
248 longjmp (env, 44);
249 }
250 elmtLen1 = BDecLen (b, bytesDecoded, env);
251 BDecIA5StringContent (b, tag, elmtLen1, result, bytesDecoded, env);
252} /* BDecIA5String */
253
254AsnLen BEncGraphicString PARAMS ((b, v),
255BUF_TYPE b _AND_
256GraphicString *v)
257{
258 AsnLen l;
259 l = BEncGraphicStringContent (b, v);
260 l += BEncDefLen (b, l);
261 l += BEncTag1 (b, UNIV, PRIM, GRAPHICSTRING_TAG_CODE);
262 return l;
263} /* BEncGraphicString */
264
265void BDecGraphicString PARAMS ((b, result, bytesDecoded, env),
266BUF_TYPE b _AND_
267GraphicString *result _AND_
268AsnLen *bytesDecoded _AND_
269ENV_TYPE env)
270{
271 AsnTag tag;
272 AsnLen elmtLen1;
273
274 if (((tag = BDecTag (b, bytesDecoded, env)) !=
275MAKE_TAG_ID (UNIV, PRIM, GRAPHICSTRING_TAG_CODE))&&
276 (tag != MAKE_TAG_ID (UNIV, CONS, GRAPHICSTRING_TAG_CODE)))
277 {
278 Asn1Error ("BDecGraphicString: ERROR - wrong tag\n");
279 longjmp (env, 43);
280 }
281 elmtLen1 = BDecLen (b, bytesDecoded, env);
282 BDecGraphicStringContent (b, tag, elmtLen1, result, bytesDecoded, env);
283} /* BDecGraphicString */
284
285AsnLen BEncVisibleString PARAMS ((b, v),
286BUF_TYPE b _AND_
287VisibleString *v)
288{
289 AsnLen l;
290 l = BEncVisibleStringContent (b, v);
291 l += BEncDefLen (b, l);
292 l += BEncTag1 (b, UNIV, PRIM, VISIBLESTRING_TAG_CODE);
293 return l;
294} /* BEncVisibleString */
295
296void BDecVisibleString PARAMS ((b, result, bytesDecoded, env),
297BUF_TYPE b _AND_
298VisibleString *result _AND_
299AsnLen *bytesDecoded _AND_
300ENV_TYPE env)
301{
302 AsnTag tag;
303 AsnLen elmtLen1;
304
305 if (((tag = BDecTag (b, bytesDecoded, env)) !=
306MAKE_TAG_ID (UNIV, PRIM, VISIBLESTRING_TAG_CODE))&&
307 (tag != MAKE_TAG_ID (UNIV, CONS, VISIBLESTRING_TAG_CODE)))
308 {
309 Asn1Error ("BDecVisibleString: ERROR - wrong tag\n");
310 longjmp (env, 42);
311 }
312 elmtLen1 = BDecLen (b, bytesDecoded, env);
313 BDecVisibleStringContent (b, tag, elmtLen1, result, bytesDecoded, env);
314} /* BDecVisibleString */
315
316AsnLen BEncISO646String PARAMS ((b, v),
317BUF_TYPE b _AND_
318ISO646String *v)
319{
320 AsnLen l;
321 l = BEncISO646StringContent (b, v);
322 l += BEncDefLen (b, l);
323 l += BEncTag1 (b, UNIV, PRIM, VISIBLESTRING_TAG_CODE);
324 return l;
325} /* BEncISO646String */
326
327void BDecISO646String PARAMS ((b, result, bytesDecoded, env),
328BUF_TYPE b _AND_
329ISO646String *result _AND_
330AsnLen *bytesDecoded _AND_
331ENV_TYPE env)
332{
333 AsnTag tag;
334 AsnLen elmtLen1;
335
336 if (((tag = BDecTag (b, bytesDecoded, env)) !=
337MAKE_TAG_ID (UNIV, PRIM, VISIBLESTRING_TAG_CODE))&&
338 (tag != MAKE_TAG_ID (UNIV, CONS, VISIBLESTRING_TAG_CODE)))
339 {
340 Asn1Error ("BDecISO646String: ERROR - wrong tag\n");
341 longjmp (env, 41);
342 }
343 elmtLen1 = BDecLen (b, bytesDecoded, env);
344 BDecISO646StringContent (b, tag, elmtLen1, result, bytesDecoded, env);
345} /* BDecISO646String */
346
347AsnLen BEncGeneralString PARAMS ((b, v),
348BUF_TYPE b _AND_
349GeneralString *v)
350{
351 AsnLen l;
352 l = BEncGeneralStringContent (b, v);
353 l += BEncDefLen (b, l);
354 l += BEncTag1 (b, UNIV, PRIM, GENERALSTRING_TAG_CODE);
355 return l;
356} /* BEncGeneralString */
357
358void BDecGeneralString PARAMS ((b, result, bytesDecoded, env),
359BUF_TYPE b _AND_
360GeneralString *result _AND_
361AsnLen *bytesDecoded _AND_
362ENV_TYPE env)
363{
364 AsnTag tag;
365 AsnLen elmtLen1;
366
367 if (((tag = BDecTag (b, bytesDecoded, env)) !=
368MAKE_TAG_ID (UNIV, PRIM, GENERALSTRING_TAG_CODE))&&
369 (tag != MAKE_TAG_ID (UNIV, CONS, GENERALSTRING_TAG_CODE)))
370 {
371 Asn1Error ("BDecGeneralString: ERROR - wrong tag\n");
372 longjmp (env, 40);
373 }
374 elmtLen1 = BDecLen (b, bytesDecoded, env);
375 BDecGeneralStringContent (b, tag, elmtLen1, result, bytesDecoded, env);
376} /* BDecGeneralString */
377
378AsnLen BEncUTCTime PARAMS ((b, v),
379BUF_TYPE b _AND_
380UTCTime *v)
381{
382 AsnLen l;
383 l = BEncUTCTimeContent (b, v);
384 l += BEncDefLen (b, l);
385 l += BEncTag1 (b, UNIV, PRIM, UTCTIME_TAG_CODE);
386 return l;
387} /* BEncUTCTime */
388
389void BDecUTCTime PARAMS ((b, result, bytesDecoded, env),
390BUF_TYPE b _AND_
391UTCTime *result _AND_
392AsnLen *bytesDecoded _AND_
393ENV_TYPE env)
394{
395 AsnTag tag;
396 AsnLen elmtLen1;
397
398 if (((tag = BDecTag (b, bytesDecoded, env)) !=
399MAKE_TAG_ID (UNIV, PRIM, UTCTIME_TAG_CODE))&&
400 (tag != MAKE_TAG_ID (UNIV, CONS, UTCTIME_TAG_CODE)))
401 {
402 Asn1Error ("BDecUTCTime: ERROR - wrong tag\n");
403 longjmp (env, 39);
404 }
405 elmtLen1 = BDecLen (b, bytesDecoded, env);
406 BDecUTCTimeContent (b, tag, elmtLen1, result, bytesDecoded, env);
407} /* BDecUTCTime */
408
409AsnLen BEncGeneralizedTime PARAMS ((b, v),
410BUF_TYPE b _AND_
411GeneralizedTime *v)
412{
413 AsnLen l;
414 l = BEncGeneralizedTimeContent (b, v);
415 l += BEncDefLen (b, l);
416 l += BEncTag1 (b, UNIV, PRIM, GENERALIZEDTIME_TAG_CODE);
417 return l;
418} /* BEncGeneralizedTime */
419
420void BDecGeneralizedTime PARAMS ((b, result, bytesDecoded, env),
421BUF_TYPE b _AND_
422GeneralizedTime *result _AND_
423AsnLen *bytesDecoded _AND_
424ENV_TYPE env)
425{
426 AsnTag tag;
427 AsnLen elmtLen1;
428
429 if (((tag = BDecTag (b, bytesDecoded, env)) !=
430MAKE_TAG_ID (UNIV, PRIM, GENERALIZEDTIME_TAG_CODE))&&
431 (tag != MAKE_TAG_ID (UNIV, CONS, GENERALIZEDTIME_TAG_CODE)))
432 {
433 Asn1Error ("BDecGeneralizedTime: ERROR - wrong tag\n");
434 longjmp (env, 38);
435 }
436 elmtLen1 = BDecLen (b, bytesDecoded, env);
437 BDecGeneralizedTimeContent (b, tag, elmtLen1, result, bytesDecoded, env);
438} /* BDecGeneralizedTime */
439
440AsnLen BEncUniversalString PARAMS ((b, v),
441BUF_TYPE b _AND_
442UniversalString *v)
443{
444 AsnLen l;
445 l = BEncUniversalStringContent (b, v);
446 l += BEncDefLen (b, l);
447 l += BEncTag1 (b, UNIV, PRIM, UNIVERSALSTRING_TAG_CODE);
448 return l;
449} /* BEncUniversalString */
450
451void BDecUniversalString PARAMS ((b, result, bytesDecoded, env),
452BUF_TYPE b _AND_
453UniversalString *result _AND_
454AsnLen *bytesDecoded _AND_
455ENV_TYPE env)
456{
457 AsnTag tag;
458 AsnLen elmtLen1;
459
460 if (((tag = BDecTag (b, bytesDecoded, env)) !=
461MAKE_TAG_ID (UNIV, PRIM, UNIVERSALSTRING_TAG_CODE))&&
462 (tag != MAKE_TAG_ID (UNIV, CONS, UNIVERSALSTRING_TAG_CODE)))
463 {
464 Asn1Error ("BDecUniversalString: ERROR - wrong tag\n");
465 longjmp (env, 37);
466 }
467 elmtLen1 = BDecLen (b, bytesDecoded, env);
468 BDecUniversalStringContent (b, tag, elmtLen1, result, bytesDecoded, env);
469} /* BDecUniversalString */
470
471AsnLen BEncBMPString PARAMS ((b, v),
472BUF_TYPE b _AND_
473BMPString *v)
474{
475 AsnLen l;
476 l = BEncBMPStringContent (b, v);
477 l += BEncDefLen (b, l);
478 l += BEncTag1 (b, UNIV, PRIM, BMPSTRING_TAG_CODE);
479 return l;
480} /* BEncBMPString */
481
482void BDecBMPString PARAMS ((b, result, bytesDecoded, env),
483BUF_TYPE b _AND_
484BMPString *result _AND_
485AsnLen *bytesDecoded _AND_
486ENV_TYPE env)
487{
488 AsnTag tag;
489 AsnLen elmtLen1;
490
491 if (((tag = BDecTag (b, bytesDecoded, env)) !=
492MAKE_TAG_ID (UNIV, PRIM, BMPSTRING_TAG_CODE))&&
493 (tag != MAKE_TAG_ID (UNIV, CONS, BMPSTRING_TAG_CODE)))
494 {
495 Asn1Error ("BDecBMPString: ERROR - wrong tag\n");
496 longjmp (env, 36);
497 }
498 elmtLen1 = BDecLen (b, bytesDecoded, env);
499 BDecBMPStringContent (b, tag, elmtLen1, result, bytesDecoded, env);
500} /* BDecBMPString */
501
502AsnLen
503BEncEXTERNALChoiceContent PARAMS ((b, v),
504BUF_TYPE b _AND_
505EXTERNALChoice *v)
506{
507 AsnLen totalLen = 0;
508 AsnLen itemLen;
509 AsnLen listLen;
510 void *component;
511
512 switch (v->choiceId)
513 {
514 case EXTERNALCHOICE_SINGLE_ASN1_TYPE:
515 BEncEocIfNec (b);
516 itemLen = BEncAsnOctsContent (b, (v->a.single_ASN1_type));
517 itemLen += BEncDefLen (b, itemLen);
518 itemLen += BEncTag1 (b, UNIV, PRIM, 4);
519 itemLen += BEncConsLen (b, itemLen);
520 itemLen += BEncTag1 (b, CNTX, CONS, 0);
521
522 totalLen += itemLen;
523
524 break;
525
526 case EXTERNALCHOICE_OCTET_ALIGNED:
527 itemLen = BEncAsnOctsContent (b, (v->a.octet_aligned));
528 itemLen += BEncDefLen (b, itemLen);
529 itemLen += BEncTag1 (b, CNTX, PRIM, 1);
530
531 totalLen += itemLen;
532
533 break;
534
535 case EXTERNALCHOICE_ARBITRARY:
536 itemLen = BEncAsnBitsContent (b, (v->a.arbitrary));
537 itemLen += BEncDefLen (b, itemLen);
538 itemLen += BEncTag1 (b, CNTX, PRIM, 2);
539
540 totalLen += itemLen;
541
542 break;
543
544 }
545 return totalLen;
546
547} /* BEncEXTERNALChoiceContent */
548
549void
550BDecEXTERNALChoiceContent PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, env),
551BUF_TYPE b _AND_
552AsnTag tagId0 _AND_
553AsnLen elmtLen0 _AND_
554EXTERNALChoice *v _AND_
555AsnLen *bytesDecoded _AND_
556ENV_TYPE env)
557{
558 int seqDone = FALSE;
559 AsnLen totalElmtsLen1 = 0;
560 AsnLen elmtLen1;
561 AsnTag tagId1;
562 int mandatoryElmtCount1 = 0;
563 AsnLen totalElmtsLen2 = 0;
564 AsnLen elmtLen2;
565 AsnTag tagId2;
566
567
568 switch (tagId0)
569 {
570 case MAKE_TAG_ID (CNTX, CONS, 0):
571 tagId1 = BDecTag (b, &totalElmtsLen1, env);
572if ((tagId1 != MAKE_TAG_ID (UNIV, PRIM, OCTETSTRING_TAG_CODE)) &&
573 (tagId1 != MAKE_TAG_ID (UNIV, CONS, OCTETSTRING_TAG_CODE)))
574 {
575 Asn1Error ("Unexpected Tag\n");
576 longjmp (env, 35);
577 }
578
579 elmtLen1 = BDecLen (b, &totalElmtsLen1, env);
580 (v->choiceId) = EXTERNALCHOICE_SINGLE_ASN1_TYPE;
581 (v->a.single_ASN1_type) = (AsnOcts*) Asn1Alloc (sizeof (AsnOcts));
582 CheckAsn1Alloc ((v->a.single_ASN1_type), env);
583 BDecAsnOctsContent (b, tagId1, elmtLen1, (v->a.single_ASN1_type), &totalElmtsLen1, env);
584 if (elmtLen0 == INDEFINITE_LEN)
585 BDecEoc (b, &totalElmtsLen1, env);
586 break;
587
588 case MAKE_TAG_ID (CNTX, PRIM, 1):
589 case MAKE_TAG_ID (CNTX, CONS, 1):
590 (v->choiceId) = EXTERNALCHOICE_OCTET_ALIGNED;
591 (v->a.octet_aligned) = (AsnOcts*) Asn1Alloc (sizeof (AsnOcts));
592 CheckAsn1Alloc ((v->a.octet_aligned), env);
593 BDecAsnOctsContent (b, tagId0, elmtLen0, (v->a.octet_aligned), &totalElmtsLen1, env);
594 break;
595
596 case MAKE_TAG_ID (CNTX, PRIM, 2):
597 case MAKE_TAG_ID (CNTX, CONS, 2):
598 (v->choiceId) = EXTERNALCHOICE_ARBITRARY;
599 (v->a.arbitrary) = (AsnBits*) Asn1Alloc (sizeof (AsnBits));
600 CheckAsn1Alloc ((v->a.arbitrary), env);
601 BDecAsnBitsContent (b, tagId0, elmtLen0, (v->a.arbitrary), &totalElmtsLen1, env);
602 break;
603
604 default:
605 Asn1Error ("ERROR - unexpected tag in CHOICE\n");
606 longjmp (env, 34);
607 break;
608 } /* end switch */
609 (*bytesDecoded) += totalElmtsLen1;
610} /* BDecEXTERNALChoiceContent */
611
612void
613PrintEXTERNALChoice PARAMS ((f, v, indent),
614FILE* f _AND_
615EXTERNALChoice *v _AND_
616unsigned short int indent)
617{
618 switch (v->choiceId)
619 {
620 case EXTERNALCHOICE_SINGLE_ASN1_TYPE:
621 fprintf (f,"single-ASN1-type ");
622 PrintAsnOcts (f, (v->a.single_ASN1_type), indent + stdIndentG);
623 break;
624
625 case EXTERNALCHOICE_OCTET_ALIGNED:
626 fprintf (f,"octet-aligned ");
627 PrintAsnOcts (f, (v->a.octet_aligned), indent + stdIndentG);
628 break;
629
630 case EXTERNALCHOICE_ARBITRARY:
631 fprintf (f,"arbitrary ");
632 PrintAsnBits (f, (v->a.arbitrary), indent + stdIndentG);
633 break;
634
635 }
636} /* PrintEXTERNALChoice */
637
638void
639FreeEXTERNALChoice PARAMS ((v),
640EXTERNALChoice *v)
641{
642
643 if (v == NULL)
644 return;
645 switch (v->choiceId)
646 {
647 case EXTERNALCHOICE_SINGLE_ASN1_TYPE:
648 FreeAsnOcts ((v->a.single_ASN1_type));
649 Asn1Free ((v->a.single_ASN1_type));
650
651 break;
652
653 case EXTERNALCHOICE_OCTET_ALIGNED:
654 FreeAsnOcts ((v->a.octet_aligned));
655 Asn1Free ((v->a.octet_aligned));
656
657 break;
658
659 case EXTERNALCHOICE_ARBITRARY:
660 FreeAsnBits ((v->a.arbitrary));
661 Asn1Free ((v->a.arbitrary));
662
663 break;
664
665 }
666} /* FreeEXTERNALChoice */
667
668
669
670
671AsnLen BEncEXTERNAL PARAMS ((b, v),
672BUF_TYPE b _AND_
673EXTERNAL *v)
674{
675 AsnLen l;
676 BEncEocIfNec (b);
677 l = BEncEXTERNALContent (b, v);
678 l += BEncConsLen (b, l);
679 l += BEncTag1 (b, UNIV, CONS, EXTERNAL_TAG_CODE);
680 return l;
681} /* BEncEXTERNAL */
682
683void BDecEXTERNAL PARAMS ((b, result, bytesDecoded, env),
684BUF_TYPE b _AND_
685EXTERNAL *result _AND_
686AsnLen *bytesDecoded _AND_
687ENV_TYPE env)
688{
689 AsnTag tag;
690 AsnLen elmtLen1;
691
692 if (((tag = BDecTag (b, bytesDecoded, env)) !=
693MAKE_TAG_ID (UNIV, CONS, EXTERNAL_TAG_CODE)))
694 {
695 Asn1Error ("BDecEXTERNAL: ERROR - wrong tag\n");
696 longjmp (env, 33);
697 }
698 elmtLen1 = BDecLen (b, bytesDecoded, env);
699 BDecEXTERNALContent (b, tag, elmtLen1, result, bytesDecoded, env);
700} /* BDecEXTERNAL */
701
702AsnLen
703BEncEXTERNALContent PARAMS ((b, v),
704BUF_TYPE b _AND_
705EXTERNAL *v)
706{
707 AsnLen totalLen = 0;
708 AsnLen itemLen;
709 AsnLen listLen;
710 void *component;
711
712 itemLen = BEncEXTERNALChoiceContent (b, (v->encoding));
713
714 totalLen += itemLen;
715
716 if (ASNOCTS_PRESENT ((&v->data_value_descriptor)))
717 {
718 itemLen = BEncObjectDescriptorContent (b, (&v->data_value_descriptor));
719 itemLen += BEncDefLen (b, itemLen);
720 itemLen += BEncTag1 (b, UNIV, PRIM, 7);
721
722 totalLen += itemLen;
723 }
724
725 if (NOT_NULL ((v->indirect_reference)))
726 {
727 itemLen = BEncAsnIntContent (b, (v->indirect_reference));
728 BEncDefLenTo127 (b, itemLen);
729 itemLen++;
730 itemLen += BEncTag1 (b, UNIV, PRIM, 2);
731
732 totalLen += itemLen;
733 }
734
735 if (ASNOID_PRESENT ((&v->direct_reference)))
736 {
737 itemLen = BEncAsnOidContent (b, (&v->direct_reference));
738 itemLen += BEncDefLen (b, itemLen);
739 itemLen += BEncTag1 (b, UNIV, PRIM, 6);
740
741 totalLen += itemLen;
742 }
743
744 return totalLen;
745
746} /* BEncEXTERNALContent */
747
748void
749BDecEXTERNALContent PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, env),
750BUF_TYPE b _AND_
751AsnTag tagId0 _AND_
752AsnLen elmtLen0 _AND_
753EXTERNAL *v _AND_
754AsnLen *bytesDecoded _AND_
755ENV_TYPE env)
756{
757 int seqDone = FALSE;
758 AsnLen totalElmtsLen1 = 0;
759 AsnLen elmtLen1;
760 AsnTag tagId1;
761 int mandatoryElmtCount1 = 0;
762 AsnLen totalElmtsLen2 = 0;
763 AsnLen elmtLen2;
764 AsnTag tagId2;
765
766
767 tagId1 = BDecTag (b, &totalElmtsLen1, env);
768
769 if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE))))
770 {
771 elmtLen1 = BDecLen (b, &totalElmtsLen1, env);
772 BDecAsnOidContent (b, tagId1, elmtLen1, (&v->direct_reference), &totalElmtsLen1, env);
773 tagId1 = BDecTag (b, &totalElmtsLen1, env);
774 }
775
776
777 if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE))))
778 {
779 elmtLen1 = BDecLen (b, &totalElmtsLen1, env);
780 (v->indirect_reference) = (AsnInt*) Asn1Alloc (sizeof (AsnInt));
781 CheckAsn1Alloc ((v->indirect_reference), env);
782 BDecAsnIntContent (b, tagId1, elmtLen1, (v->indirect_reference), &totalElmtsLen1, env);
783 tagId1 = BDecTag (b, &totalElmtsLen1, env);
784 }
785
786
787 if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, OD_TAG_CODE)) ||
788(tagId1 == MAKE_TAG_ID (UNIV, CONS, OD_TAG_CODE))))
789 {
790 elmtLen1 = BDecLen (b, &totalElmtsLen1, env);
791 BDecObjectDescriptorContent (b, tagId1, elmtLen1, (&v->data_value_descriptor), &totalElmtsLen1, env);
792 tagId1 = BDecTag (b, &totalElmtsLen1, env);
793 }
794
795
796 if (((tagId1 == MAKE_TAG_ID (CNTX, CONS, 0)) ||
797 (tagId1 == MAKE_TAG_ID (CNTX, PRIM, 1))||
798 (tagId1 == MAKE_TAG_ID (CNTX, CONS, 1)) ||
799 (tagId1 == MAKE_TAG_ID (CNTX, PRIM, 2))||
800 (tagId1 == MAKE_TAG_ID (CNTX, CONS, 2))))
801 {
802 elmtLen1 = BDecLen (b, &totalElmtsLen1, env);
803 (v->encoding) = (EXTERNALChoice*) Asn1Alloc (sizeof (EXTERNALChoice));
804 CheckAsn1Alloc ((v->encoding), env);
805 BDecEXTERNALChoiceContent (b, tagId1, elmtLen1, (v->encoding), &totalElmtsLen1, env);
806 seqDone = TRUE;
807 if (elmtLen0 == INDEFINITE_LEN)
808 BDecEoc (b, &totalElmtsLen1, env);
809 else if (totalElmtsLen1 != elmtLen0)
810 longjmp (env, 32);
811 }
812 else
813 longjmp (env, 31);
814
815
816 if (!seqDone)
817 longjmp (env, 30);
818
819 (*bytesDecoded) += totalElmtsLen1;
820} /* BDecEXTERNALContent */
821
822void
823PrintEXTERNAL PARAMS ((f, v, indent),
824FILE* f _AND_
825EXTERNAL *v _AND_
826unsigned short int indent)
827{
828 if (v == NULL)
829 return;
830
831 fprintf (f,"{ -- SEQUENCE --\n");
832
833 if (ASNOID_PRESENT ((&v->direct_reference)))
834 {
835 Indent (f, indent + stdIndentG);
836 fprintf (f,"direct-reference ");
837 PrintAsnOid (f, (&v->direct_reference), indent + stdIndentG);
838 fprintf (f, ",\n");
839 }
840 if (NOT_NULL ((v->indirect_reference)))
841 {
842 Indent (f, indent + stdIndentG);
843 fprintf (f,"indirect-reference ");
844 PrintAsnInt (f, (v->indirect_reference), indent + stdIndentG);
845 fprintf (f, ",\n");
846 }
847 if (ASNOCTS_PRESENT ((&v->data_value_descriptor)))
848 {
849 Indent (f, indent + stdIndentG);
850 fprintf (f,"data-value-descriptor ");
851 PrintObjectDescriptor (f, (&v->data_value_descriptor), indent + stdIndentG);
852 fprintf (f, ",\n");
853 }
854 Indent (f, indent + stdIndentG);
855 fprintf (f,"encoding ");
856 PrintEXTERNALChoice (f, (v->encoding), indent + stdIndentG);
857 fprintf (f,"\n");
858 Indent (f, indent);
859 fprintf (f,"}");
860} /* PrintEXTERNAL */
861
862void
863FreeEXTERNAL PARAMS ((v),
864EXTERNAL *v)
865{
866
867 if (v == NULL)
868 return;
869 if (ASNOID_PRESENT ((&v->direct_reference)))
870 {
871 FreeAsnOid ((&v->direct_reference));
872 }
873
874 if (NOT_NULL ((v->indirect_reference)))
875 {
876 FreeAsnInt ((v->indirect_reference));
877 Asn1Free ((v->indirect_reference));
878 }
879
880 if (ASNOCTS_PRESENT ((&v->data_value_descriptor)))
881 {
882 FreeObjectDescriptor ((&v->data_value_descriptor));
883 }
884
885 FreeEXTERNALChoice ((v->encoding));
886 Asn1Free ((v->encoding));
887
888} /* FreeEXTERNAL */
889
890
891
892