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