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