]> git.saurik.com Git - apple/security.git/blob - SecurityASN1/c++/sm_x501if.cpp
0211d2188af0eaab041c2f71ebb9526ec85a8cdf
[apple/security.git] / SecurityASN1 / c++ / sm_x501if.cpp
1 // NOTE: this is a machine generated file--editing not recommended
2 //
3 // sm_x501if.cpp - class member functions for ASN.1 module InformationFramework
4 //
5 // This file was generated by snacc on Wed Jun 27 16:40:55 2001
6 // UBC snacc written by Mike Sample
7 // A couple of enhancements made by IBM European Networking Center
8
9
10 #include "asn-incl.h"
11 #include "sm_vdatypes.h"
12 #include "sm_x501ud.h"
13 #include "sm_x411ub.h"
14 #include "sm_x411mtsas.h"
15 #include "sm_x501if.h"
16 #include "sm_x520sa.h"
17 #include "sm_x509cmn.h"
18 #include "sm_x509af.h"
19 #include "sm_x509ce.h"
20 #include "pkcs1oids.h"
21 #include "pkcs9oids.h"
22 #include "sm_cms.h"
23 #include "sm_ess.h"
24 #include "pkcs7.h"
25 #include "pkcs8.h"
26 #include "appleoids.h"
27
28 //------------------------------------------------------------------------------
29 // value defs
30
31
32 //------------------------------------------------------------------------------
33 // class member definitions:
34
35 AsnType *AttributeTypeAndDistinguishedValueSetOfSeqSetOf::Clone() const
36 {
37 return new AttributeTypeAndDistinguishedValueSetOfSeqSetOf;
38 }
39
40 AsnType *AttributeTypeAndDistinguishedValueSetOfSeqSetOf::Copy() const
41 {
42 return new AttributeTypeAndDistinguishedValueSetOfSeqSetOf (*this);
43 }
44
45 AsnLen AttributeTypeAndDistinguishedValueSetOfSeqSetOf::BEnc (BUF_TYPE b)
46 {
47 AsnLen l;
48 l = BEncContent (b);
49 l += BEncConsLen (b, l);
50 l += BEncTag1 (b, UNIV, CONS, SET_TAG_CODE);
51 return l;
52 }
53
54 void AttributeTypeAndDistinguishedValueSetOfSeqSetOf::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
55 {
56 AsnTag tag;
57 AsnLen elmtLen1;
58
59 if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SET_TAG_CODE))
60 {
61 Asn1Error << "AttributeTypeAndDistinguishedValueSetOfSeqSetOf::BDec: ERROR - wrong tag" << endl;
62 longjmp (env, -100);
63 }
64 elmtLen1 = BDecLen (b, bytesDecoded, env);
65 BDecContent (b, tag, elmtLen1, bytesDecoded, env);
66 }
67
68 AttributeTypeAndDistinguishedValueSetOfSeqSetOf::AttributeTypeAndDistinguishedValueSetOfSeqSetOf (const AttributeTypeAndDistinguishedValueSetOfSeqSetOf &)
69 {
70 Asn1Error << "use of incompletely defined AttributeTypeAndDistinguishedValueSetOfSeqSetOf::AttributeTypeAndDistinguishedValueSetOfSeqSetOf (const AttributeTypeAndDistinguishedValueSetOfSeqSetOf &)" << endl;
71 abort();
72 }
73
74 AttributeTypeAndDistinguishedValueSetOfSeqSetOf::~AttributeTypeAndDistinguishedValueSetOfSeqSetOf()
75 {
76 SetCurrToFirst();
77 for (; Curr() != NULL; RemoveCurrFromList())
78 ;
79 } // end of destructor
80
81 #if SNACC_DEEP_COPY
82 AttributeTypeAndDistinguishedValueSetOfSeqSetOf &AttributeTypeAndDistinguishedValueSetOfSeqSetOf::operator = (const AttributeTypeAndDistinguishedValueSetOfSeqSetOf &that)
83 #else // SNACC_DEEP_COPY
84 AttributeTypeAndDistinguishedValueSetOfSeqSetOf &AttributeTypeAndDistinguishedValueSetOfSeqSetOf::operator = (const AttributeTypeAndDistinguishedValueSetOfSeqSetOf &)
85 #endif // SNACC_DEEP_COPY
86 {
87 #if SNACC_DEEP_COPY
88 if (this != &that)
89 {
90 SetCurrToFirst();
91 for (; Curr(); RemoveCurrFromList())
92 ;
93
94 //that.SetCurrToFirst();
95 //for (; that.Curr(); that.GoNext())
96 // AppendCopy (*that.Curr());
97 for (const AsnListElmt *run=that.first; run; run=run->next)
98 AppendCopy (*run->elmt);
99 }
100
101 return *this;
102 #else // SNACC_DEEP_COPY
103 Asn1Error << "use of incompletely defined AttributeTypeAndDistinguishedValueSetOfSeqSetOf &AttributeTypeAndDistinguishedValueSetOfSeqSetOf::operator = (const AttributeTypeAndDistinguishedValueSetOfSeqSetOf &)" << endl;
104 abort();
105 // if your compiler complains here, check the -novolat option
106 #endif // SNACC_DEEP_COPY
107 }
108
109 void AttributeTypeAndDistinguishedValueSetOfSeqSetOf::Print (ostream &os) const
110 {
111 #ifndef NDEBUG
112 os << "{ -- SEQUENCE/SET OF -- " << endl;
113 indentG += stdIndentG;
114 //SetCurrToFirst();
115 //for (; Curr() != NULL; GoNext())
116 for (const AsnListElmt *run=first; run; run=run->next)
117 {
118 Indent (os, indentG);
119 //os << *Curr();
120 os << *run->elmt;
121 //if (Curr() != Last())
122 if (run != last)
123 os << ",";
124 os << endl;
125 }
126 indentG -= stdIndentG;
127 Indent (os, indentG);
128 os << "}\n";
129 #endif /* NDEBUG */
130
131
132 } // Print
133
134
135 void AttributeTypeAndDistinguishedValueSetOfSeqSetOf::SetCurrElmt (unsigned long int index)
136 {
137 unsigned long int i;
138 curr = first;
139 if (count)
140 for (i = 0; (i < (count-1)) && (i < index); i++)
141 curr = curr->next;
142 } // AttributeTypeAndDistinguishedValueSetOfSeqSetOf::SetCurrElmt
143
144
145 unsigned long int AttributeTypeAndDistinguishedValueSetOfSeqSetOf::GetCurrElmtIndex()
146 {
147 unsigned long int i;
148 AsnListElmt *tmp;
149 if (curr != NULL)
150 {
151 for (i = 0, tmp = first; tmp != NULL; i++)
152 {
153 if (tmp == curr)
154 return i;
155 else
156 tmp = tmp->next;
157 }
158 }
159 return count;
160 } // AttributeTypeAndDistinguishedValueSetOfSeqSetOf::GetCurrElmtIndex
161
162
163 // alloc new list elmt, put at end of list
164 // and return the component type
165 AsnAny *AttributeTypeAndDistinguishedValueSetOfSeqSetOf::Append()
166 {
167 AsnListElmt *newElmt;
168 newElmt = new AsnListElmt;
169 newElmt->elmt = new AsnAny;
170 newElmt->next = NULL;
171 if (last == NULL)
172 {
173 newElmt->prev = NULL;
174 first = last = newElmt;
175 }
176 else
177 {
178 newElmt->prev = last;
179 last->next = newElmt;
180 last = newElmt;
181 }
182 count++;
183 return (curr = newElmt)->elmt;
184 } // AttributeTypeAndDistinguishedValueSetOfSeqSetOf::Append
185
186
187 // alloc new list elmt, put at begining of list
188 // and return the component type
189 AsnAny *AttributeTypeAndDistinguishedValueSetOfSeqSetOf::Prepend()
190 {
191 AsnListElmt *newElmt;
192 newElmt = new AsnListElmt;
193 newElmt->elmt = new AsnAny;
194 newElmt->prev = NULL;
195 if (first == NULL)
196 {
197 newElmt->next = NULL;
198 first = last = newElmt;
199 }
200 else
201 {
202 newElmt->next = first;
203 first->prev = newElmt;
204 first = newElmt;
205 }
206 count++;
207 return (curr = newElmt)->elmt;
208 } // AttributeTypeAndDistinguishedValueSetOfSeqSetOf::Prepend
209
210
211 // alloc new list elmt, insert it before the
212 // current element and return the component type
213 // if the current element is null, the new element
214 // is placed at the beginning of the list.
215 AsnAny *AttributeTypeAndDistinguishedValueSetOfSeqSetOf::InsertBefore()
216 {
217 AsnListElmt *newElmt;
218 newElmt = new AsnListElmt;
219 newElmt->elmt = new AsnAny;
220 if (curr == NULL)
221 {
222 newElmt->next = first;
223 newElmt->prev = NULL;
224 first = newElmt;
225 if (last == NULL)
226 last = newElmt;
227 }
228 else
229 {
230 newElmt->next = curr;
231 newElmt->prev = curr->prev;
232 curr->prev = newElmt;
233 if (curr == first)
234 first = newElmt;
235 else
236 newElmt->prev->next = newElmt;
237 }
238 count++;
239 return (curr = newElmt)->elmt;
240 } // AttributeTypeAndDistinguishedValueSetOfSeqSetOf::InsertBefore
241
242
243 // alloc new list elmt, insert it after the
244 // current element and return the component type
245 // if the current element is null, the new element
246 // is placed at the end of the list.
247 AsnAny *AttributeTypeAndDistinguishedValueSetOfSeqSetOf::InsertAfter()
248 {
249 AsnListElmt *newElmt;
250 newElmt = new AsnListElmt;
251 newElmt->elmt = new AsnAny;
252 if (curr == NULL)
253 {
254 newElmt->prev = last;
255 newElmt->next = NULL;
256 last = newElmt;
257 if (first == NULL)
258 first = newElmt;
259 }
260 else
261 {
262 newElmt->prev = curr;
263 newElmt->next = curr->next;
264 curr->next = newElmt;
265 if (curr == last)
266 last = newElmt;
267 else
268 newElmt->next->prev = newElmt;
269 }
270 count++;
271 return (curr = newElmt)->elmt;
272 } // AttributeTypeAndDistinguishedValueSetOfSeqSetOf::InsertAfter
273
274
275 AttributeTypeAndDistinguishedValueSetOfSeqSetOf &AttributeTypeAndDistinguishedValueSetOfSeqSetOf::AppendCopy (AsnAny &elmt)
276 {
277 AsnListElmt *newElmt;
278 newElmt = new AsnListElmt;
279 newElmt->elmt = new AsnAny;
280 *newElmt->elmt = elmt;
281 newElmt->next = NULL;
282 if (last == NULL)
283 {
284 newElmt->prev = NULL;
285 first = last = newElmt;
286 }
287 else
288 {
289 newElmt->prev = last;
290 last->next = newElmt;
291 last = newElmt;
292 }
293 count++;
294 return *this;
295 } // AppendCopy
296
297
298 AttributeTypeAndDistinguishedValueSetOfSeqSetOf &AttributeTypeAndDistinguishedValueSetOfSeqSetOf::PrependCopy (AsnAny &elmt)
299 {
300 AsnListElmt *newElmt;
301 newElmt = new AsnListElmt;
302 newElmt->elmt = new AsnAny;
303 *newElmt->elmt = elmt;
304 newElmt->prev = NULL;
305 if (first == NULL)
306 {
307 newElmt->next = NULL;
308 first = last = newElmt;
309 }
310 else
311 {
312 newElmt->next = first;
313 first->prev = newElmt;
314 first = newElmt;
315 }
316 count++;
317 return *this;
318 } // AttributeTypeAndDistinguishedValueSetOfSeqSetOf::PrependCopy
319
320
321 // alloc new list elmt, insert it before the
322 // current element, copy the given elmt into the new elmt
323 // and return the component type.
324 // if the current element is null, the new element
325 // is placed at the beginning of the list.
326 AttributeTypeAndDistinguishedValueSetOfSeqSetOf &AttributeTypeAndDistinguishedValueSetOfSeqSetOf::InsertBeforeAndCopy (AsnAny &elmt)
327 {
328 AsnListElmt *newElmt;
329
330 newElmt = new AsnListElmt;
331 newElmt->elmt = new AsnAny;
332 *newElmt->elmt = elmt;
333
334 if (curr == NULL)
335 {
336 newElmt->next = first;
337 newElmt->prev = NULL;
338 first = newElmt;
339 if (last == NULL)
340 last = newElmt;
341 }
342 else
343 {
344 newElmt->next = curr;
345 newElmt->prev = curr->prev;
346 curr->prev = newElmt;
347 if (curr == first)
348 first = newElmt;
349 else
350 newElmt->prev->next = newElmt;
351 }
352 count++;
353 return *this;
354 } // AttributeTypeAndDistinguishedValueSetOfSeqSetOf::InsertBeforeAndCopy
355
356
357 // alloc new list elmt, insert it after the
358 // current element, copy given elmt in to new elmt
359 // and return the component type
360 // if the current element is null, the new element
361 // is placed at the end of the list.
362 AttributeTypeAndDistinguishedValueSetOfSeqSetOf &AttributeTypeAndDistinguishedValueSetOfSeqSetOf::InsertAfterAndCopy (AsnAny &elmt)
363 {
364 AsnListElmt *newElmt;
365
366 newElmt = new AsnListElmt;
367 newElmt->elmt = new AsnAny;
368 *newElmt->elmt = elmt;
369 if (curr == NULL)
370 {
371 newElmt->prev = last;
372 newElmt->next = NULL;
373 last = newElmt;
374 if (first == NULL)
375 first = newElmt;
376 }
377 else
378 {
379 newElmt->prev = curr;
380 newElmt->next = curr->next;
381 curr->next = newElmt;
382 if (curr == last)
383 last = newElmt;
384 else
385 newElmt->next->prev = newElmt;
386 }
387 count++;
388 return *this;
389 } // AttributeTypeAndDistinguishedValueSetOfSeqSetOf::InsertAfterAndCopy
390
391
392 // remove current element from list if current element is not NULL
393 // The new current element will be the next element.
394 // If the current element is the last element in the list
395 // the second but last element will become the new current element.
396 void AttributeTypeAndDistinguishedValueSetOfSeqSetOf::RemoveCurrFromList()
397 {
398 AsnListElmt *del_elmt;
399
400 if (curr != NULL)
401 {
402 del_elmt = curr;
403 count--;
404
405 if (count == 0)
406 first = last = curr = NULL;
407 else if (curr == first)
408 {
409 curr = first= first->next;
410 first->prev = NULL;
411 }
412 else if (curr == last)
413 {
414 curr = last = last->prev;
415 last->next = NULL;
416 }
417 else
418 {
419 curr->prev->next = curr->next;
420 curr->next->prev = curr->prev;
421 }
422
423 delete del_elmt->elmt;
424 delete del_elmt;
425 }
426 }
427
428
429 AsnLen AttributeTypeAndDistinguishedValueSetOfSeqSetOf::BEncContent (BUF_TYPE b)
430 {
431 AsnListElmt *currElmt;
432 AsnLen elmtLen;
433 AsnLen totalLen = 0;
434 {
435 int iii,icount;
436 CSM_Buffer **tmpEnc=NULL;
437 for (currElmt = last,icount=0; currElmt != NULL; currElmt = currElmt->prev, icount++);
438 tmpEnc = (CSM_Buffer **) calloc(sizeof(CSM_Buffer *), icount);
439 for (currElmt = last, iii=0; currElmt != NULL; currElmt = currElmt->prev,iii++,elmtLen=0)
440 {
441 tmpEnc[iii] = (CSM_Buffer *)currElmt->elmt->value;
442 }
443 vdasnacc_sortSetOf(tmpEnc, icount);
444 for (iii=0,elmtLen=0; iii < icount; elmtLen+=tmpEnc[iii++]->Length())
445 SM_WriteToAsnBuf(tmpEnc[iii], b);
446 free(tmpEnc);
447 }
448 totalLen += elmtLen;
449 return totalLen;
450 } // AttributeTypeAndDistinguishedValueSetOfSeqSetOf::BEncContent
451
452
453 void AttributeTypeAndDistinguishedValueSetOfSeqSetOf::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0,
454 AsnLen &bytesDecoded, ENV_TYPE env)
455 {
456 AsnAny *listElmt;
457 AsnLen listBytesDecoded = 0;
458
459 while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN))
460 {
461 listElmt = Append();
462 DEC_LOAD_ANYBUF(listElmt, b, listBytesDecoded, env);
463 }
464
465 bytesDecoded += listBytesDecoded;
466 } // AttributeTypeAndDistinguishedValueSetOfSeqSetOf::BDecContent
467
468
469 AttributeTypeAndDistinguishedValueSetOfSeq::AttributeTypeAndDistinguishedValueSetOfSeq()
470 {
471 distingAttrValue = NULL;
472 }
473
474 AttributeTypeAndDistinguishedValueSetOfSeq::AttributeTypeAndDistinguishedValueSetOfSeq (const AttributeTypeAndDistinguishedValueSetOfSeq &)
475 {
476 Asn1Error << "use of incompletely defined AttributeTypeAndDistinguishedValueSetOfSeq::AttributeTypeAndDistinguishedValueSetOfSeq (const AttributeTypeAndDistinguishedValueSetOfSeq &)" << endl;
477 abort();
478 }
479
480 AttributeTypeAndDistinguishedValueSetOfSeq::~AttributeTypeAndDistinguishedValueSetOfSeq()
481 {
482 delete distingAttrValue;
483 }
484
485 AsnType *AttributeTypeAndDistinguishedValueSetOfSeq::Clone() const
486 {
487 return new AttributeTypeAndDistinguishedValueSetOfSeq;
488 }
489
490 AsnType *AttributeTypeAndDistinguishedValueSetOfSeq::Copy() const
491 {
492 return new AttributeTypeAndDistinguishedValueSetOfSeq (*this);
493 }
494
495 #if SNACC_DEEP_COPY
496 AttributeTypeAndDistinguishedValueSetOfSeq &AttributeTypeAndDistinguishedValueSetOfSeq::operator = (const AttributeTypeAndDistinguishedValueSetOfSeq &that)
497 #else // SNACC_DEEP_COPY
498 AttributeTypeAndDistinguishedValueSetOfSeq &AttributeTypeAndDistinguishedValueSetOfSeq::operator = (const AttributeTypeAndDistinguishedValueSetOfSeq &)
499 #endif // SNACC_DEEP_COPY
500 {
501 #if SNACC_DEEP_COPY
502 if (this != &that)
503 {
504 if (that.distingAttrValue)
505 {
506 if (!distingAttrValue)
507 distingAttrValue = new AsnOid;
508 *distingAttrValue = *that.distingAttrValue;
509 }
510 else
511 {
512 delete distingAttrValue;
513 distingAttrValue = NULL;
514 }
515 contextList = that.contextList;
516 }
517
518 return *this;
519 #else // SNACC_DEEP_COPY
520 Asn1Error << "use of incompletely defined AttributeTypeAndDistinguishedValueSetOfSeq &AttributeTypeAndDistinguishedValueSetOfSeq::operator = (const AttributeTypeAndDistinguishedValueSetOfSeq &)" << endl;
521 abort();
522 // if your compiler complains here, check the -novolat option
523 #endif // SNACC_DEEP_COPY
524 }
525
526 AsnLen
527 AttributeTypeAndDistinguishedValueSetOfSeq::BEncContent (BUF_TYPE b)
528 {
529 AsnLen totalLen = 0;
530 AsnLen l;
531
532 BEncEocIfNec (b);
533 l = contextList.BEncContent (b);
534 l += BEncConsLen (b, l);
535
536 l += BEncTag1 (b, UNIV, CONS, SET_TAG_CODE);
537 totalLen += l;
538
539 if (NOT_NULL (distingAttrValue))
540 {
541 l = distingAttrValue->BEncContent (b);
542 l += BEncDefLen (b, l);
543
544 l += BEncTag1 (b, UNIV, PRIM, OID_TAG_CODE);
545 totalLen += l;
546 }
547
548 return totalLen;
549 } // AttributeTypeAndDistinguishedValueSetOfSeq::BEncContent
550
551
552 void AttributeTypeAndDistinguishedValueSetOfSeq::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env)
553 {
554 AsnTag tag1;
555 AsnLen seqBytesDecoded = 0;
556 AsnLen elmtLen1;
557 tag1 = BDecTag (b, seqBytesDecoded, env);
558
559 if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE)))
560 {
561 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
562 distingAttrValue = new AsnOid;
563 distingAttrValue->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
564 tag1 = BDecTag (b, seqBytesDecoded, env);
565 }
566
567 if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SET_TAG_CODE)))
568 {
569 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
570 contextList.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
571 }
572 else
573 {
574 Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl;
575 longjmp (env, -101);
576 }
577
578 bytesDecoded += seqBytesDecoded;
579 if (elmtLen0 == INDEFINITE_LEN)
580 {
581 BDecEoc (b, bytesDecoded, env);
582 return;
583 }
584 else if (seqBytesDecoded != elmtLen0)
585 {
586 Asn1Error << "ERROR - Length discrepancy on sequence." << endl;
587 longjmp (env, -102);
588 }
589 else
590 return;
591 } // AttributeTypeAndDistinguishedValueSetOfSeq::BDecContent
592
593 AsnLen AttributeTypeAndDistinguishedValueSetOfSeq::BEnc (BUF_TYPE b)
594 {
595 AsnLen l;
596 l = BEncContent (b);
597 l += BEncConsLen (b, l);
598 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
599 return l;
600 }
601
602 void AttributeTypeAndDistinguishedValueSetOfSeq::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
603 {
604 AsnTag tag;
605 AsnLen elmtLen1;
606
607 if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
608 {
609 Asn1Error << "AttributeTypeAndDistinguishedValueSetOfSeq::BDec: ERROR - wrong tag" << endl;
610 longjmp (env, -103);
611 }
612 elmtLen1 = BDecLen (b, bytesDecoded, env);
613 BDecContent (b, tag, elmtLen1, bytesDecoded, env);
614 }
615
616 int AttributeTypeAndDistinguishedValueSetOfSeq::BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded)
617 {
618 bytesEncoded = BEnc (b);
619 return !b.WriteError();
620 }
621
622 int AttributeTypeAndDistinguishedValueSetOfSeq::BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded)
623 {
624 ENV_TYPE env;
625 int val;
626
627 bytesDecoded = 0;
628 if ((val = setjmp (env)) == 0)
629 {
630 BDec (b, bytesDecoded, env);
631 return !b.ReadError();
632 }
633 else
634 return false;
635 }
636
637 void AttributeTypeAndDistinguishedValueSetOfSeq::Print (ostream &os) const
638 {
639 #ifndef NDEBUG
640 os << "{ -- SEQUENCE --" << endl;
641 indentG += stdIndentG;
642
643 if (NOT_NULL (distingAttrValue))
644 {
645 Indent (os, indentG);
646 os << "distingAttrValue ";
647 os << *distingAttrValue;
648 }
649 else
650 {
651 Indent (os, indentG);
652 os << "distingAttrValue ";
653 os << "-- void --";
654 os << "," << endl;
655 }
656
657 {
658 Indent (os, indentG);
659 os << "contextList ";
660 os << contextList;
661 }
662
663 os << endl;
664 indentG -= stdIndentG;
665 Indent (os, indentG);
666 os << "}";
667 #endif /* NDEBUG */
668 } // AttributeTypeAndDistinguishedValueSetOfSeq::Print
669
670
671 AsnType *AttributeTypeAndDistinguishedValueSetOf::Clone() const
672 {
673 return new AttributeTypeAndDistinguishedValueSetOf;
674 }
675
676 AsnType *AttributeTypeAndDistinguishedValueSetOf::Copy() const
677 {
678 return new AttributeTypeAndDistinguishedValueSetOf (*this);
679 }
680
681 AsnLen AttributeTypeAndDistinguishedValueSetOf::BEnc (BUF_TYPE b)
682 {
683 AsnLen l;
684 l = BEncContent (b);
685 l += BEncConsLen (b, l);
686 l += BEncTag1 (b, UNIV, CONS, SET_TAG_CODE);
687 return l;
688 }
689
690 void AttributeTypeAndDistinguishedValueSetOf::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
691 {
692 AsnTag tag;
693 AsnLen elmtLen1;
694
695 if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SET_TAG_CODE))
696 {
697 Asn1Error << "AttributeTypeAndDistinguishedValueSetOf::BDec: ERROR - wrong tag" << endl;
698 longjmp (env, -104);
699 }
700 elmtLen1 = BDecLen (b, bytesDecoded, env);
701 BDecContent (b, tag, elmtLen1, bytesDecoded, env);
702 }
703
704 AttributeTypeAndDistinguishedValueSetOf::AttributeTypeAndDistinguishedValueSetOf (const AttributeTypeAndDistinguishedValueSetOf &)
705 {
706 Asn1Error << "use of incompletely defined AttributeTypeAndDistinguishedValueSetOf::AttributeTypeAndDistinguishedValueSetOf (const AttributeTypeAndDistinguishedValueSetOf &)" << endl;
707 abort();
708 }
709
710 AttributeTypeAndDistinguishedValueSetOf::~AttributeTypeAndDistinguishedValueSetOf()
711 {
712 SetCurrToFirst();
713 for (; Curr() != NULL; RemoveCurrFromList())
714 ;
715 } // end of destructor
716
717 #if SNACC_DEEP_COPY
718 AttributeTypeAndDistinguishedValueSetOf &AttributeTypeAndDistinguishedValueSetOf::operator = (const AttributeTypeAndDistinguishedValueSetOf &that)
719 #else // SNACC_DEEP_COPY
720 AttributeTypeAndDistinguishedValueSetOf &AttributeTypeAndDistinguishedValueSetOf::operator = (const AttributeTypeAndDistinguishedValueSetOf &)
721 #endif // SNACC_DEEP_COPY
722 {
723 #if SNACC_DEEP_COPY
724 if (this != &that)
725 {
726 SetCurrToFirst();
727 for (; Curr(); RemoveCurrFromList())
728 ;
729
730 //that.SetCurrToFirst();
731 //for (; that.Curr(); that.GoNext())
732 // AppendCopy (*that.Curr());
733 for (const AsnListElmt *run=that.first; run; run=run->next)
734 AppendCopy (*run->elmt);
735 }
736
737 return *this;
738 #else // SNACC_DEEP_COPY
739 Asn1Error << "use of incompletely defined AttributeTypeAndDistinguishedValueSetOf &AttributeTypeAndDistinguishedValueSetOf::operator = (const AttributeTypeAndDistinguishedValueSetOf &)" << endl;
740 abort();
741 // if your compiler complains here, check the -novolat option
742 #endif // SNACC_DEEP_COPY
743 }
744
745 void AttributeTypeAndDistinguishedValueSetOf::Print (ostream &os) const
746 {
747 #ifndef NDEBUG
748 os << "{ -- SEQUENCE/SET OF -- " << endl;
749 indentG += stdIndentG;
750 //SetCurrToFirst();
751 //for (; Curr() != NULL; GoNext())
752 for (const AsnListElmt *run=first; run; run=run->next)
753 {
754 Indent (os, indentG);
755 //os << *Curr();
756 os << *run->elmt;
757 //if (Curr() != Last())
758 if (run != last)
759 os << ",";
760 os << endl;
761 }
762 indentG -= stdIndentG;
763 Indent (os, indentG);
764 os << "}\n";
765 #endif /* NDEBUG */
766
767
768 } // Print
769
770
771 void AttributeTypeAndDistinguishedValueSetOf::SetCurrElmt (unsigned long int index)
772 {
773 unsigned long int i;
774 curr = first;
775 if (count)
776 for (i = 0; (i < (count-1)) && (i < index); i++)
777 curr = curr->next;
778 } // AttributeTypeAndDistinguishedValueSetOf::SetCurrElmt
779
780
781 unsigned long int AttributeTypeAndDistinguishedValueSetOf::GetCurrElmtIndex()
782 {
783 unsigned long int i;
784 AsnListElmt *tmp;
785 if (curr != NULL)
786 {
787 for (i = 0, tmp = first; tmp != NULL; i++)
788 {
789 if (tmp == curr)
790 return i;
791 else
792 tmp = tmp->next;
793 }
794 }
795 return count;
796 } // AttributeTypeAndDistinguishedValueSetOf::GetCurrElmtIndex
797
798
799 // alloc new list elmt, put at end of list
800 // and return the component type
801 AttributeTypeAndDistinguishedValueSetOfSeq *AttributeTypeAndDistinguishedValueSetOf::Append()
802 {
803 AsnListElmt *newElmt;
804 newElmt = new AsnListElmt;
805 newElmt->elmt = new AttributeTypeAndDistinguishedValueSetOfSeq;
806 newElmt->next = NULL;
807 if (last == NULL)
808 {
809 newElmt->prev = NULL;
810 first = last = newElmt;
811 }
812 else
813 {
814 newElmt->prev = last;
815 last->next = newElmt;
816 last = newElmt;
817 }
818 count++;
819 return (curr = newElmt)->elmt;
820 } // AttributeTypeAndDistinguishedValueSetOf::Append
821
822
823 // alloc new list elmt, put at begining of list
824 // and return the component type
825 AttributeTypeAndDistinguishedValueSetOfSeq *AttributeTypeAndDistinguishedValueSetOf::Prepend()
826 {
827 AsnListElmt *newElmt;
828 newElmt = new AsnListElmt;
829 newElmt->elmt = new AttributeTypeAndDistinguishedValueSetOfSeq;
830 newElmt->prev = NULL;
831 if (first == NULL)
832 {
833 newElmt->next = NULL;
834 first = last = newElmt;
835 }
836 else
837 {
838 newElmt->next = first;
839 first->prev = newElmt;
840 first = newElmt;
841 }
842 count++;
843 return (curr = newElmt)->elmt;
844 } // AttributeTypeAndDistinguishedValueSetOf::Prepend
845
846
847 // alloc new list elmt, insert it before the
848 // current element and return the component type
849 // if the current element is null, the new element
850 // is placed at the beginning of the list.
851 AttributeTypeAndDistinguishedValueSetOfSeq *AttributeTypeAndDistinguishedValueSetOf::InsertBefore()
852 {
853 AsnListElmt *newElmt;
854 newElmt = new AsnListElmt;
855 newElmt->elmt = new AttributeTypeAndDistinguishedValueSetOfSeq;
856 if (curr == NULL)
857 {
858 newElmt->next = first;
859 newElmt->prev = NULL;
860 first = newElmt;
861 if (last == NULL)
862 last = newElmt;
863 }
864 else
865 {
866 newElmt->next = curr;
867 newElmt->prev = curr->prev;
868 curr->prev = newElmt;
869 if (curr == first)
870 first = newElmt;
871 else
872 newElmt->prev->next = newElmt;
873 }
874 count++;
875 return (curr = newElmt)->elmt;
876 } // AttributeTypeAndDistinguishedValueSetOf::InsertBefore
877
878
879 // alloc new list elmt, insert it after the
880 // current element and return the component type
881 // if the current element is null, the new element
882 // is placed at the end of the list.
883 AttributeTypeAndDistinguishedValueSetOfSeq *AttributeTypeAndDistinguishedValueSetOf::InsertAfter()
884 {
885 AsnListElmt *newElmt;
886 newElmt = new AsnListElmt;
887 newElmt->elmt = new AttributeTypeAndDistinguishedValueSetOfSeq;
888 if (curr == NULL)
889 {
890 newElmt->prev = last;
891 newElmt->next = NULL;
892 last = newElmt;
893 if (first == NULL)
894 first = newElmt;
895 }
896 else
897 {
898 newElmt->prev = curr;
899 newElmt->next = curr->next;
900 curr->next = newElmt;
901 if (curr == last)
902 last = newElmt;
903 else
904 newElmt->next->prev = newElmt;
905 }
906 count++;
907 return (curr = newElmt)->elmt;
908 } // AttributeTypeAndDistinguishedValueSetOf::InsertAfter
909
910
911 AttributeTypeAndDistinguishedValueSetOf &AttributeTypeAndDistinguishedValueSetOf::AppendCopy (AttributeTypeAndDistinguishedValueSetOfSeq &elmt)
912 {
913 AsnListElmt *newElmt;
914 newElmt = new AsnListElmt;
915 newElmt->elmt = new AttributeTypeAndDistinguishedValueSetOfSeq;
916 *newElmt->elmt = elmt;
917 newElmt->next = NULL;
918 if (last == NULL)
919 {
920 newElmt->prev = NULL;
921 first = last = newElmt;
922 }
923 else
924 {
925 newElmt->prev = last;
926 last->next = newElmt;
927 last = newElmt;
928 }
929 count++;
930 return *this;
931 } // AppendCopy
932
933
934 AttributeTypeAndDistinguishedValueSetOf &AttributeTypeAndDistinguishedValueSetOf::PrependCopy (AttributeTypeAndDistinguishedValueSetOfSeq &elmt)
935 {
936 AsnListElmt *newElmt;
937 newElmt = new AsnListElmt;
938 newElmt->elmt = new AttributeTypeAndDistinguishedValueSetOfSeq;
939 *newElmt->elmt = elmt;
940 newElmt->prev = NULL;
941 if (first == NULL)
942 {
943 newElmt->next = NULL;
944 first = last = newElmt;
945 }
946 else
947 {
948 newElmt->next = first;
949 first->prev = newElmt;
950 first = newElmt;
951 }
952 count++;
953 return *this;
954 } // AttributeTypeAndDistinguishedValueSetOf::PrependCopy
955
956
957 // alloc new list elmt, insert it before the
958 // current element, copy the given elmt into the new elmt
959 // and return the component type.
960 // if the current element is null, the new element
961 // is placed at the beginning of the list.
962 AttributeTypeAndDistinguishedValueSetOf &AttributeTypeAndDistinguishedValueSetOf::InsertBeforeAndCopy (AttributeTypeAndDistinguishedValueSetOfSeq &elmt)
963 {
964 AsnListElmt *newElmt;
965
966 newElmt = new AsnListElmt;
967 newElmt->elmt = new AttributeTypeAndDistinguishedValueSetOfSeq;
968 *newElmt->elmt = elmt;
969
970 if (curr == NULL)
971 {
972 newElmt->next = first;
973 newElmt->prev = NULL;
974 first = newElmt;
975 if (last == NULL)
976 last = newElmt;
977 }
978 else
979 {
980 newElmt->next = curr;
981 newElmt->prev = curr->prev;
982 curr->prev = newElmt;
983 if (curr == first)
984 first = newElmt;
985 else
986 newElmt->prev->next = newElmt;
987 }
988 count++;
989 return *this;
990 } // AttributeTypeAndDistinguishedValueSetOf::InsertBeforeAndCopy
991
992
993 // alloc new list elmt, insert it after the
994 // current element, copy given elmt in to new elmt
995 // and return the component type
996 // if the current element is null, the new element
997 // is placed at the end of the list.
998 AttributeTypeAndDistinguishedValueSetOf &AttributeTypeAndDistinguishedValueSetOf::InsertAfterAndCopy (AttributeTypeAndDistinguishedValueSetOfSeq &elmt)
999 {
1000 AsnListElmt *newElmt;
1001
1002 newElmt = new AsnListElmt;
1003 newElmt->elmt = new AttributeTypeAndDistinguishedValueSetOfSeq;
1004 *newElmt->elmt = elmt;
1005 if (curr == NULL)
1006 {
1007 newElmt->prev = last;
1008 newElmt->next = NULL;
1009 last = newElmt;
1010 if (first == NULL)
1011 first = newElmt;
1012 }
1013 else
1014 {
1015 newElmt->prev = curr;
1016 newElmt->next = curr->next;
1017 curr->next = newElmt;
1018 if (curr == last)
1019 last = newElmt;
1020 else
1021 newElmt->next->prev = newElmt;
1022 }
1023 count++;
1024 return *this;
1025 } // AttributeTypeAndDistinguishedValueSetOf::InsertAfterAndCopy
1026
1027
1028 // remove current element from list if current element is not NULL
1029 // The new current element will be the next element.
1030 // If the current element is the last element in the list
1031 // the second but last element will become the new current element.
1032 void AttributeTypeAndDistinguishedValueSetOf::RemoveCurrFromList()
1033 {
1034 AsnListElmt *del_elmt;
1035
1036 if (curr != NULL)
1037 {
1038 del_elmt = curr;
1039 count--;
1040
1041 if (count == 0)
1042 first = last = curr = NULL;
1043 else if (curr == first)
1044 {
1045 curr = first= first->next;
1046 first->prev = NULL;
1047 }
1048 else if (curr == last)
1049 {
1050 curr = last = last->prev;
1051 last->next = NULL;
1052 }
1053 else
1054 {
1055 curr->prev->next = curr->next;
1056 curr->next->prev = curr->prev;
1057 }
1058
1059 delete del_elmt->elmt;
1060 delete del_elmt;
1061 }
1062 }
1063
1064
1065 AsnLen AttributeTypeAndDistinguishedValueSetOf::BEncContent (BUF_TYPE b)
1066 {
1067 AsnListElmt *currElmt;
1068 AsnLen elmtLen;
1069 AsnLen totalLen = 0;
1070 {
1071 int iii,icount;
1072 CSM_Buffer **tmpEnc=NULL;
1073 for (currElmt = last,icount=0; currElmt != NULL; currElmt = currElmt->prev, icount++);
1074 tmpEnc = (CSM_Buffer **) calloc(sizeof(CSM_Buffer *), icount);
1075 for (currElmt = last, iii=0; currElmt != NULL; currElmt = currElmt->prev,iii++,elmtLen=0)
1076 {
1077 BEncEocIfNec (b);
1078 ENCODE_BUF1(currElmt->elmt->BEncContent, elmtLen);
1079 elmtLen += BEncConsLen (outputBuf, elmtLen);
1080
1081 elmtLen += BEncTag1 (outputBuf, UNIV, CONS, SEQ_TAG_CODE);
1082 ENCODE_BUF2(tmpEnc[iii]);
1083 }
1084 vdasnacc_sortSetOf(tmpEnc, icount);
1085 for (iii=0,elmtLen=0; iii < icount; elmtLen+=tmpEnc[iii++]->Length())
1086 SM_WriteToAsnBuf(tmpEnc[iii], b);
1087 for (iii=0; iii < icount; iii++) delete tmpEnc[iii];
1088 free(tmpEnc);
1089 }
1090 totalLen += elmtLen;
1091 return totalLen;
1092 } // AttributeTypeAndDistinguishedValueSetOf::BEncContent
1093
1094
1095 void AttributeTypeAndDistinguishedValueSetOf::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0,
1096 AsnLen &bytesDecoded, ENV_TYPE env)
1097 {
1098 AttributeTypeAndDistinguishedValueSetOfSeq *listElmt;
1099 AsnTag tag1;
1100 AsnLen listBytesDecoded = 0;
1101 AsnLen elmtLen1;
1102
1103 while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN))
1104 {
1105 tag1 = BDecTag (b, listBytesDecoded, env);
1106 if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN))
1107 {
1108 BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env);
1109 break;
1110 }
1111 if ((tag1 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))
1112 {
1113 Asn1Error << "Unexpected Tag" << endl;
1114 longjmp (env, -105);
1115 }
1116
1117 elmtLen1 = BDecLen (b, listBytesDecoded, env);
1118 listElmt = Append();
1119 listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env);
1120 }
1121
1122 bytesDecoded += listBytesDecoded;
1123 } // AttributeTypeAndDistinguishedValueSetOf::BDecContent
1124
1125
1126 AsnType *AttributeSetOf::Clone() const
1127 {
1128 return new AttributeSetOf;
1129 }
1130
1131 AsnType *AttributeSetOf::Copy() const
1132 {
1133 return new AttributeSetOf (*this);
1134 }
1135
1136 AsnLen AttributeSetOf::BEnc (BUF_TYPE b)
1137 {
1138 AsnLen l;
1139 l = BEncContent (b);
1140 l += BEncConsLen (b, l);
1141 l += BEncTag1 (b, UNIV, CONS, SET_TAG_CODE);
1142 return l;
1143 }
1144
1145 void AttributeSetOf::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
1146 {
1147 AsnTag tag;
1148 AsnLen elmtLen1;
1149
1150 if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SET_TAG_CODE))
1151 {
1152 Asn1Error << "AttributeSetOf::BDec: ERROR - wrong tag" << endl;
1153 longjmp (env, -106);
1154 }
1155 elmtLen1 = BDecLen (b, bytesDecoded, env);
1156 BDecContent (b, tag, elmtLen1, bytesDecoded, env);
1157 }
1158
1159 AttributeSetOf::AttributeSetOf (const AttributeSetOf &)
1160 {
1161 Asn1Error << "use of incompletely defined AttributeSetOf::AttributeSetOf (const AttributeSetOf &)" << endl;
1162 abort();
1163 }
1164
1165 AttributeSetOf::~AttributeSetOf()
1166 {
1167 SetCurrToFirst();
1168 for (; Curr() != NULL; RemoveCurrFromList())
1169 ;
1170 } // end of destructor
1171
1172 #if SNACC_DEEP_COPY
1173 AttributeSetOf &AttributeSetOf::operator = (const AttributeSetOf &that)
1174 #else // SNACC_DEEP_COPY
1175 AttributeSetOf &AttributeSetOf::operator = (const AttributeSetOf &)
1176 #endif // SNACC_DEEP_COPY
1177 {
1178 #if SNACC_DEEP_COPY
1179 if (this != &that)
1180 {
1181 SetCurrToFirst();
1182 for (; Curr(); RemoveCurrFromList())
1183 ;
1184
1185 //that.SetCurrToFirst();
1186 //for (; that.Curr(); that.GoNext())
1187 // AppendCopy (*that.Curr());
1188 for (const AsnListElmt *run=that.first; run; run=run->next)
1189 AppendCopy (*run->elmt);
1190 }
1191
1192 return *this;
1193 #else // SNACC_DEEP_COPY
1194 Asn1Error << "use of incompletely defined AttributeSetOf &AttributeSetOf::operator = (const AttributeSetOf &)" << endl;
1195 abort();
1196 // if your compiler complains here, check the -novolat option
1197 #endif // SNACC_DEEP_COPY
1198 }
1199
1200 void AttributeSetOf::Print (ostream &os) const
1201 {
1202 #ifndef NDEBUG
1203 os << "{ -- SEQUENCE/SET OF -- " << endl;
1204 indentG += stdIndentG;
1205 //SetCurrToFirst();
1206 //for (; Curr() != NULL; GoNext())
1207 for (const AsnListElmt *run=first; run; run=run->next)
1208 {
1209 Indent (os, indentG);
1210 //os << *Curr();
1211 os << *run->elmt;
1212 //if (Curr() != Last())
1213 if (run != last)
1214 os << ",";
1215 os << endl;
1216 }
1217 indentG -= stdIndentG;
1218 Indent (os, indentG);
1219 os << "}\n";
1220 #endif /* NDEBUG */
1221
1222
1223 } // Print
1224
1225
1226 void AttributeSetOf::SetCurrElmt (unsigned long int index)
1227 {
1228 unsigned long int i;
1229 curr = first;
1230 if (count)
1231 for (i = 0; (i < (count-1)) && (i < index); i++)
1232 curr = curr->next;
1233 } // AttributeSetOf::SetCurrElmt
1234
1235
1236 unsigned long int AttributeSetOf::GetCurrElmtIndex()
1237 {
1238 unsigned long int i;
1239 AsnListElmt *tmp;
1240 if (curr != NULL)
1241 {
1242 for (i = 0, tmp = first; tmp != NULL; i++)
1243 {
1244 if (tmp == curr)
1245 return i;
1246 else
1247 tmp = tmp->next;
1248 }
1249 }
1250 return count;
1251 } // AttributeSetOf::GetCurrElmtIndex
1252
1253
1254 // alloc new list elmt, put at end of list
1255 // and return the component type
1256 AttributeValue *AttributeSetOf::Append()
1257 {
1258 AsnListElmt *newElmt;
1259 newElmt = new AsnListElmt;
1260 newElmt->elmt = new AttributeValue;
1261 newElmt->next = NULL;
1262 if (last == NULL)
1263 {
1264 newElmt->prev = NULL;
1265 first = last = newElmt;
1266 }
1267 else
1268 {
1269 newElmt->prev = last;
1270 last->next = newElmt;
1271 last = newElmt;
1272 }
1273 count++;
1274 return (curr = newElmt)->elmt;
1275 } // AttributeSetOf::Append
1276
1277
1278 // alloc new list elmt, put at begining of list
1279 // and return the component type
1280 AttributeValue *AttributeSetOf::Prepend()
1281 {
1282 AsnListElmt *newElmt;
1283 newElmt = new AsnListElmt;
1284 newElmt->elmt = new AttributeValue;
1285 newElmt->prev = NULL;
1286 if (first == NULL)
1287 {
1288 newElmt->next = NULL;
1289 first = last = newElmt;
1290 }
1291 else
1292 {
1293 newElmt->next = first;
1294 first->prev = newElmt;
1295 first = newElmt;
1296 }
1297 count++;
1298 return (curr = newElmt)->elmt;
1299 } // AttributeSetOf::Prepend
1300
1301
1302 // alloc new list elmt, insert it before the
1303 // current element and return the component type
1304 // if the current element is null, the new element
1305 // is placed at the beginning of the list.
1306 AttributeValue *AttributeSetOf::InsertBefore()
1307 {
1308 AsnListElmt *newElmt;
1309 newElmt = new AsnListElmt;
1310 newElmt->elmt = new AttributeValue;
1311 if (curr == NULL)
1312 {
1313 newElmt->next = first;
1314 newElmt->prev = NULL;
1315 first = newElmt;
1316 if (last == NULL)
1317 last = newElmt;
1318 }
1319 else
1320 {
1321 newElmt->next = curr;
1322 newElmt->prev = curr->prev;
1323 curr->prev = newElmt;
1324 if (curr == first)
1325 first = newElmt;
1326 else
1327 newElmt->prev->next = newElmt;
1328 }
1329 count++;
1330 return (curr = newElmt)->elmt;
1331 } // AttributeSetOf::InsertBefore
1332
1333
1334 // alloc new list elmt, insert it after the
1335 // current element and return the component type
1336 // if the current element is null, the new element
1337 // is placed at the end of the list.
1338 AttributeValue *AttributeSetOf::InsertAfter()
1339 {
1340 AsnListElmt *newElmt;
1341 newElmt = new AsnListElmt;
1342 newElmt->elmt = new AttributeValue;
1343 if (curr == NULL)
1344 {
1345 newElmt->prev = last;
1346 newElmt->next = NULL;
1347 last = newElmt;
1348 if (first == NULL)
1349 first = newElmt;
1350 }
1351 else
1352 {
1353 newElmt->prev = curr;
1354 newElmt->next = curr->next;
1355 curr->next = newElmt;
1356 if (curr == last)
1357 last = newElmt;
1358 else
1359 newElmt->next->prev = newElmt;
1360 }
1361 count++;
1362 return (curr = newElmt)->elmt;
1363 } // AttributeSetOf::InsertAfter
1364
1365
1366 AttributeSetOf &AttributeSetOf::AppendCopy (AttributeValue &elmt)
1367 {
1368 AsnListElmt *newElmt;
1369 newElmt = new AsnListElmt;
1370 newElmt->elmt = new AttributeValue;
1371 *newElmt->elmt = elmt;
1372 newElmt->next = NULL;
1373 if (last == NULL)
1374 {
1375 newElmt->prev = NULL;
1376 first = last = newElmt;
1377 }
1378 else
1379 {
1380 newElmt->prev = last;
1381 last->next = newElmt;
1382 last = newElmt;
1383 }
1384 count++;
1385 return *this;
1386 } // AppendCopy
1387
1388
1389 AttributeSetOf &AttributeSetOf::PrependCopy (AttributeValue &elmt)
1390 {
1391 AsnListElmt *newElmt;
1392 newElmt = new AsnListElmt;
1393 newElmt->elmt = new AttributeValue;
1394 *newElmt->elmt = elmt;
1395 newElmt->prev = NULL;
1396 if (first == NULL)
1397 {
1398 newElmt->next = NULL;
1399 first = last = newElmt;
1400 }
1401 else
1402 {
1403 newElmt->next = first;
1404 first->prev = newElmt;
1405 first = newElmt;
1406 }
1407 count++;
1408 return *this;
1409 } // AttributeSetOf::PrependCopy
1410
1411
1412 // alloc new list elmt, insert it before the
1413 // current element, copy the given elmt into the new elmt
1414 // and return the component type.
1415 // if the current element is null, the new element
1416 // is placed at the beginning of the list.
1417 AttributeSetOf &AttributeSetOf::InsertBeforeAndCopy (AttributeValue &elmt)
1418 {
1419 AsnListElmt *newElmt;
1420
1421 newElmt = new AsnListElmt;
1422 newElmt->elmt = new AttributeValue;
1423 *newElmt->elmt = elmt;
1424
1425 if (curr == NULL)
1426 {
1427 newElmt->next = first;
1428 newElmt->prev = NULL;
1429 first = newElmt;
1430 if (last == NULL)
1431 last = newElmt;
1432 }
1433 else
1434 {
1435 newElmt->next = curr;
1436 newElmt->prev = curr->prev;
1437 curr->prev = newElmt;
1438 if (curr == first)
1439 first = newElmt;
1440 else
1441 newElmt->prev->next = newElmt;
1442 }
1443 count++;
1444 return *this;
1445 } // AttributeSetOf::InsertBeforeAndCopy
1446
1447
1448 // alloc new list elmt, insert it after the
1449 // current element, copy given elmt in to new elmt
1450 // and return the component type
1451 // if the current element is null, the new element
1452 // is placed at the end of the list.
1453 AttributeSetOf &AttributeSetOf::InsertAfterAndCopy (AttributeValue &elmt)
1454 {
1455 AsnListElmt *newElmt;
1456
1457 newElmt = new AsnListElmt;
1458 newElmt->elmt = new AttributeValue;
1459 *newElmt->elmt = elmt;
1460 if (curr == NULL)
1461 {
1462 newElmt->prev = last;
1463 newElmt->next = NULL;
1464 last = newElmt;
1465 if (first == NULL)
1466 first = newElmt;
1467 }
1468 else
1469 {
1470 newElmt->prev = curr;
1471 newElmt->next = curr->next;
1472 curr->next = newElmt;
1473 if (curr == last)
1474 last = newElmt;
1475 else
1476 newElmt->next->prev = newElmt;
1477 }
1478 count++;
1479 return *this;
1480 } // AttributeSetOf::InsertAfterAndCopy
1481
1482
1483 // remove current element from list if current element is not NULL
1484 // The new current element will be the next element.
1485 // If the current element is the last element in the list
1486 // the second but last element will become the new current element.
1487 void AttributeSetOf::RemoveCurrFromList()
1488 {
1489 AsnListElmt *del_elmt;
1490
1491 if (curr != NULL)
1492 {
1493 del_elmt = curr;
1494 count--;
1495
1496 if (count == 0)
1497 first = last = curr = NULL;
1498 else if (curr == first)
1499 {
1500 curr = first= first->next;
1501 first->prev = NULL;
1502 }
1503 else if (curr == last)
1504 {
1505 curr = last = last->prev;
1506 last->next = NULL;
1507 }
1508 else
1509 {
1510 curr->prev->next = curr->next;
1511 curr->next->prev = curr->prev;
1512 }
1513
1514 delete del_elmt->elmt;
1515 delete del_elmt;
1516 }
1517 }
1518
1519
1520 AsnLen AttributeSetOf::BEncContent (BUF_TYPE b)
1521 {
1522 AsnListElmt *currElmt;
1523 AsnLen elmtLen;
1524 AsnLen totalLen = 0;
1525 {
1526 int iii,icount;
1527 CSM_Buffer **tmpEnc=NULL;
1528 for (currElmt = last,icount=0; currElmt != NULL; currElmt = currElmt->prev, icount++);
1529 tmpEnc = (CSM_Buffer **) calloc(sizeof(CSM_Buffer *), icount);
1530 for (currElmt = last, iii=0; currElmt != NULL; currElmt = currElmt->prev,iii++,elmtLen=0)
1531 {
1532 tmpEnc[iii] = (CSM_Buffer *)currElmt->elmt->value;
1533 }
1534 vdasnacc_sortSetOf(tmpEnc, icount);
1535 for (iii=0,elmtLen=0; iii < icount; elmtLen+=tmpEnc[iii++]->Length())
1536 SM_WriteToAsnBuf(tmpEnc[iii], b);
1537 free(tmpEnc);
1538 }
1539 totalLen += elmtLen;
1540 return totalLen;
1541 } // AttributeSetOf::BEncContent
1542
1543
1544 void AttributeSetOf::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0,
1545 AsnLen &bytesDecoded, ENV_TYPE env)
1546 {
1547 AttributeValue *listElmt;
1548 AsnLen listBytesDecoded = 0;
1549
1550 while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN))
1551 {
1552 listElmt = Append();
1553 DEC_LOAD_ANYBUF(listElmt, b, listBytesDecoded, env);
1554 }
1555
1556 bytesDecoded += listBytesDecoded;
1557 } // AttributeSetOf::BDecContent
1558
1559
1560 Attribute::Attribute()
1561 {
1562 }
1563
1564 Attribute::Attribute (const Attribute &)
1565 {
1566 Asn1Error << "use of incompletely defined Attribute::Attribute (const Attribute &)" << endl;
1567 abort();
1568 }
1569
1570 Attribute::~Attribute()
1571 {
1572 }
1573
1574 AsnType *Attribute::Clone() const
1575 {
1576 return new Attribute;
1577 }
1578
1579 AsnType *Attribute::Copy() const
1580 {
1581 return new Attribute (*this);
1582 }
1583
1584 #if SNACC_DEEP_COPY
1585 Attribute &Attribute::operator = (const Attribute &that)
1586 #else // SNACC_DEEP_COPY
1587 Attribute &Attribute::operator = (const Attribute &)
1588 #endif // SNACC_DEEP_COPY
1589 {
1590 #if SNACC_DEEP_COPY
1591 if (this != &that)
1592 {
1593 type = that.type;
1594 values = that.values;
1595 }
1596
1597 return *this;
1598 #else // SNACC_DEEP_COPY
1599 Asn1Error << "use of incompletely defined Attribute &Attribute::operator = (const Attribute &)" << endl;
1600 abort();
1601 // if your compiler complains here, check the -novolat option
1602 #endif // SNACC_DEEP_COPY
1603 }
1604
1605 AsnLen
1606 Attribute::BEncContent (BUF_TYPE b)
1607 {
1608 AsnLen totalLen = 0;
1609 AsnLen l;
1610
1611 BEncEocIfNec (b);
1612 l = values.BEncContent (b);
1613 l += BEncConsLen (b, l);
1614
1615 l += BEncTag1 (b, UNIV, CONS, SET_TAG_CODE);
1616 totalLen += l;
1617
1618 l = type.BEncContent (b);
1619 l += BEncDefLen (b, l);
1620
1621 l += BEncTag1 (b, UNIV, PRIM, OID_TAG_CODE);
1622 totalLen += l;
1623
1624 return totalLen;
1625 } // Attribute::BEncContent
1626
1627
1628 void Attribute::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env)
1629 {
1630 AsnTag tag1;
1631 AsnLen seqBytesDecoded = 0;
1632 AsnLen elmtLen1;
1633 tag1 = BDecTag (b, seqBytesDecoded, env);
1634
1635 if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE)))
1636 {
1637 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
1638 type.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
1639 tag1 = BDecTag (b, seqBytesDecoded, env);
1640 }
1641 else
1642 {
1643 Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl;
1644 longjmp (env, -107);
1645 }
1646
1647 if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SET_TAG_CODE)))
1648 {
1649 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
1650 values.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
1651 }
1652 else
1653 {
1654 Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl;
1655 longjmp (env, -108);
1656 }
1657
1658 bytesDecoded += seqBytesDecoded;
1659 if (elmtLen0 == INDEFINITE_LEN)
1660 {
1661 BDecEoc (b, bytesDecoded, env);
1662 return;
1663 }
1664 else if (seqBytesDecoded != elmtLen0)
1665 {
1666 Asn1Error << "ERROR - Length discrepancy on sequence." << endl;
1667 longjmp (env, -109);
1668 }
1669 else
1670 return;
1671 } // Attribute::BDecContent
1672
1673 AsnLen Attribute::BEnc (BUF_TYPE b)
1674 {
1675 AsnLen l;
1676 l = BEncContent (b);
1677 l += BEncConsLen (b, l);
1678 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
1679 return l;
1680 }
1681
1682 void Attribute::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
1683 {
1684 AsnTag tag;
1685 AsnLen elmtLen1;
1686
1687 if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
1688 {
1689 Asn1Error << "Attribute::BDec: ERROR - wrong tag" << endl;
1690 longjmp (env, -110);
1691 }
1692 elmtLen1 = BDecLen (b, bytesDecoded, env);
1693 BDecContent (b, tag, elmtLen1, bytesDecoded, env);
1694 }
1695
1696 int Attribute::BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded)
1697 {
1698 bytesEncoded = BEnc (b);
1699 return !b.WriteError();
1700 }
1701
1702 int Attribute::BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded)
1703 {
1704 ENV_TYPE env;
1705 int val;
1706
1707 bytesDecoded = 0;
1708 if ((val = setjmp (env)) == 0)
1709 {
1710 BDec (b, bytesDecoded, env);
1711 return !b.ReadError();
1712 }
1713 else
1714 return false;
1715 }
1716
1717 void Attribute::Print (ostream &os) const
1718 {
1719 #ifndef NDEBUG
1720 os << "{ -- SEQUENCE --" << endl;
1721 indentG += stdIndentG;
1722
1723 {
1724 Indent (os, indentG);
1725 os << "type ";
1726 os << type;
1727 os << "," << endl;
1728 }
1729
1730 {
1731 Indent (os, indentG);
1732 os << "values ";
1733 os << values;
1734 }
1735
1736 os << endl;
1737 indentG -= stdIndentG;
1738 Indent (os, indentG);
1739 os << "}";
1740 #endif /* NDEBUG */
1741 } // Attribute::Print
1742
1743
1744 AttributeTypeAndDistinguishedValue::AttributeTypeAndDistinguishedValue()
1745 {
1746 primaryDistinguished = NULL;
1747 valuesWithContext = NULL;
1748 }
1749
1750 AttributeTypeAndDistinguishedValue::AttributeTypeAndDistinguishedValue (const AttributeTypeAndDistinguishedValue &)
1751 {
1752 Asn1Error << "use of incompletely defined AttributeTypeAndDistinguishedValue::AttributeTypeAndDistinguishedValue (const AttributeTypeAndDistinguishedValue &)" << endl;
1753 abort();
1754 }
1755
1756 AttributeTypeAndDistinguishedValue::~AttributeTypeAndDistinguishedValue()
1757 {
1758 delete primaryDistinguished;
1759 delete valuesWithContext;
1760 }
1761
1762 AsnType *AttributeTypeAndDistinguishedValue::Clone() const
1763 {
1764 return new AttributeTypeAndDistinguishedValue;
1765 }
1766
1767 AsnType *AttributeTypeAndDistinguishedValue::Copy() const
1768 {
1769 return new AttributeTypeAndDistinguishedValue (*this);
1770 }
1771
1772 #if SNACC_DEEP_COPY
1773 AttributeTypeAndDistinguishedValue &AttributeTypeAndDistinguishedValue::operator = (const AttributeTypeAndDistinguishedValue &that)
1774 #else // SNACC_DEEP_COPY
1775 AttributeTypeAndDistinguishedValue &AttributeTypeAndDistinguishedValue::operator = (const AttributeTypeAndDistinguishedValue &)
1776 #endif // SNACC_DEEP_COPY
1777 {
1778 #if SNACC_DEEP_COPY
1779 if (this != &that)
1780 {
1781 type = that.type;
1782 value = that.value;
1783 if (that.primaryDistinguished)
1784 {
1785 if (!primaryDistinguished)
1786 primaryDistinguished = new AsnBool;
1787 *primaryDistinguished = *that.primaryDistinguished;
1788 }
1789 else
1790 {
1791 delete primaryDistinguished;
1792 primaryDistinguished = NULL;
1793 }
1794 if (that.valuesWithContext)
1795 {
1796 if (!valuesWithContext)
1797 valuesWithContext = new AttributeTypeAndDistinguishedValueSetOf;
1798 *valuesWithContext = *that.valuesWithContext;
1799 }
1800 else
1801 {
1802 delete valuesWithContext;
1803 valuesWithContext = NULL;
1804 }
1805 }
1806
1807 return *this;
1808 #else // SNACC_DEEP_COPY
1809 Asn1Error << "use of incompletely defined AttributeTypeAndDistinguishedValue &AttributeTypeAndDistinguishedValue::operator = (const AttributeTypeAndDistinguishedValue &)" << endl;
1810 abort();
1811 // if your compiler complains here, check the -novolat option
1812 #endif // SNACC_DEEP_COPY
1813 }
1814
1815 AsnLen
1816 AttributeTypeAndDistinguishedValue::BEncContent (BUF_TYPE b)
1817 {
1818 AsnLen totalLen = 0;
1819 AsnLen l;
1820
1821 if (NOT_NULL (valuesWithContext))
1822 {
1823 BEncEocIfNec (b);
1824 l = valuesWithContext->BEncContent (b);
1825 l += BEncConsLen (b, l);
1826
1827 l += BEncTag1 (b, UNIV, CONS, SET_TAG_CODE);
1828 totalLen += l;
1829 }
1830
1831 if (NOT_NULL (primaryDistinguished))
1832 {
1833 l = primaryDistinguished->BEncContent (b);
1834 BEncDefLenTo127 (b, l);
1835 l++;
1836
1837 l += BEncTag1 (b, UNIV, PRIM, BOOLEAN_TAG_CODE);
1838 totalLen += l;
1839 }
1840
1841 ENC_LOAD_ANYBUF(&value, b, l);
1842 totalLen += l;
1843
1844 l = type.BEncContent (b);
1845 l += BEncDefLen (b, l);
1846
1847 l += BEncTag1 (b, UNIV, PRIM, OID_TAG_CODE);
1848 totalLen += l;
1849
1850 return totalLen;
1851 } // AttributeTypeAndDistinguishedValue::BEncContent
1852
1853
1854 void AttributeTypeAndDistinguishedValue::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env)
1855 {
1856 AsnTag tag1;
1857 AsnLen seqBytesDecoded = 0;
1858 AsnLen elmtLen1;
1859 tag1 = BDecTag (b, seqBytesDecoded, env);
1860
1861 if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE)))
1862 {
1863 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
1864 type.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
1865 }
1866 else
1867 {
1868 Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl;
1869 longjmp (env, -111);
1870 }
1871
1872 // ANY type
1873 DEC_LOAD_ANYBUF(&value, b, seqBytesDecoded, env);
1874 if (seqBytesDecoded == elmtLen0)
1875 {
1876 bytesDecoded += seqBytesDecoded;
1877 return;
1878 }
1879 else
1880 {
1881 tag1 = BDecTag (b, seqBytesDecoded, env);
1882
1883 if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID))
1884 {
1885 BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env)
1886 bytesDecoded += seqBytesDecoded;
1887 return;
1888 }
1889 }
1890
1891
1892 if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, BOOLEAN_TAG_CODE)))
1893 {
1894 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
1895 primaryDistinguished = new AsnBool;
1896 primaryDistinguished->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
1897 if (seqBytesDecoded == elmtLen0)
1898 {
1899 bytesDecoded += seqBytesDecoded;
1900 return;
1901 }
1902 else
1903 {
1904 tag1 = BDecTag (b, seqBytesDecoded, env);
1905
1906 if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID))
1907 {
1908 BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env)
1909 bytesDecoded += seqBytesDecoded;
1910 return;
1911 }
1912 }
1913 }
1914
1915 if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SET_TAG_CODE)))
1916 {
1917 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
1918 valuesWithContext = new AttributeTypeAndDistinguishedValueSetOf;
1919 valuesWithContext->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
1920 }
1921
1922 bytesDecoded += seqBytesDecoded;
1923 if (elmtLen0 == INDEFINITE_LEN)
1924 {
1925 BDecEoc (b, bytesDecoded, env);
1926 return;
1927 }
1928 else if (seqBytesDecoded != elmtLen0)
1929 {
1930 Asn1Error << "ERROR - Length discrepancy on sequence." << endl;
1931 longjmp (env, -112);
1932 }
1933 else
1934 return;
1935 } // AttributeTypeAndDistinguishedValue::BDecContent
1936
1937 AsnLen AttributeTypeAndDistinguishedValue::BEnc (BUF_TYPE b)
1938 {
1939 AsnLen l;
1940 l = BEncContent (b);
1941 l += BEncConsLen (b, l);
1942 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
1943 return l;
1944 }
1945
1946 void AttributeTypeAndDistinguishedValue::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
1947 {
1948 AsnTag tag;
1949 AsnLen elmtLen1;
1950
1951 if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
1952 {
1953 Asn1Error << "AttributeTypeAndDistinguishedValue::BDec: ERROR - wrong tag" << endl;
1954 longjmp (env, -113);
1955 }
1956 elmtLen1 = BDecLen (b, bytesDecoded, env);
1957 BDecContent (b, tag, elmtLen1, bytesDecoded, env);
1958 }
1959
1960 int AttributeTypeAndDistinguishedValue::BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded)
1961 {
1962 bytesEncoded = BEnc (b);
1963 return !b.WriteError();
1964 }
1965
1966 int AttributeTypeAndDistinguishedValue::BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded)
1967 {
1968 ENV_TYPE env;
1969 int val;
1970
1971 bytesDecoded = 0;
1972 if ((val = setjmp (env)) == 0)
1973 {
1974 BDec (b, bytesDecoded, env);
1975 return !b.ReadError();
1976 }
1977 else
1978 return false;
1979 }
1980
1981 void AttributeTypeAndDistinguishedValue::Print (ostream &os) const
1982 {
1983 #ifndef NDEBUG
1984 os << "{ -- SEQUENCE --" << endl;
1985 indentG += stdIndentG;
1986
1987 {
1988 Indent (os, indentG);
1989 os << "type ";
1990 os << type;
1991 os << "," << endl;
1992 }
1993
1994 {
1995 Indent (os, indentG);
1996 os << "value ";
1997 os << value;
1998 os << "," << endl;
1999 }
2000
2001 if (NOT_NULL (primaryDistinguished))
2002 {
2003 os << ","<< endl;
2004 Indent (os, indentG);
2005 os << "primaryDistinguished ";
2006 os << *primaryDistinguished;
2007 }
2008 else
2009 {
2010 Indent (os, indentG);
2011 os << "primaryDistinguished ";
2012 os << "-- void --";
2013 os << "," << endl;
2014 }
2015
2016 if (NOT_NULL (valuesWithContext))
2017 {
2018 os << ","<< endl;
2019 Indent (os, indentG);
2020 os << "valuesWithContext ";
2021 os << *valuesWithContext;
2022 }
2023 else
2024 {
2025 Indent (os, indentG);
2026 os << "valuesWithContext ";
2027 os << "-- void --";
2028 os << endl;
2029 }
2030
2031 os << endl;
2032 indentG -= stdIndentG;
2033 Indent (os, indentG);
2034 os << "}";
2035 #endif /* NDEBUG */
2036 } // AttributeTypeAndDistinguishedValue::Print
2037
2038
2039 AsnType *RelativeDistinguishedName::Clone() const
2040 {
2041 return new RelativeDistinguishedName;
2042 }
2043
2044 AsnType *RelativeDistinguishedName::Copy() const
2045 {
2046 return new RelativeDistinguishedName (*this);
2047 }
2048
2049 AsnLen RelativeDistinguishedName::BEnc (BUF_TYPE b)
2050 {
2051 AsnLen l;
2052 l = BEncContent (b);
2053 l += BEncConsLen (b, l);
2054 l += BEncTag1 (b, UNIV, CONS, SET_TAG_CODE);
2055 return l;
2056 }
2057
2058 void RelativeDistinguishedName::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
2059 {
2060 AsnTag tag;
2061 AsnLen elmtLen1;
2062
2063 if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SET_TAG_CODE))
2064 {
2065 Asn1Error << "RelativeDistinguishedName::BDec: ERROR - wrong tag" << endl;
2066 longjmp (env, -114);
2067 }
2068 elmtLen1 = BDecLen (b, bytesDecoded, env);
2069 BDecContent (b, tag, elmtLen1, bytesDecoded, env);
2070 }
2071
2072 RelativeDistinguishedName::RelativeDistinguishedName (const RelativeDistinguishedName &)
2073 {
2074 Asn1Error << "use of incompletely defined RelativeDistinguishedName::RelativeDistinguishedName (const RelativeDistinguishedName &)" << endl;
2075 abort();
2076 }
2077
2078 RelativeDistinguishedName::~RelativeDistinguishedName()
2079 {
2080 SetCurrToFirst();
2081 for (; Curr() != NULL; RemoveCurrFromList())
2082 ;
2083 } // end of destructor
2084
2085 #if SNACC_DEEP_COPY
2086 RelativeDistinguishedName &RelativeDistinguishedName::operator = (const RelativeDistinguishedName &that)
2087 #else // SNACC_DEEP_COPY
2088 RelativeDistinguishedName &RelativeDistinguishedName::operator = (const RelativeDistinguishedName &)
2089 #endif // SNACC_DEEP_COPY
2090 {
2091 #if SNACC_DEEP_COPY
2092 if (this != &that)
2093 {
2094 SetCurrToFirst();
2095 for (; Curr(); RemoveCurrFromList())
2096 ;
2097
2098 //that.SetCurrToFirst();
2099 //for (; that.Curr(); that.GoNext())
2100 // AppendCopy (*that.Curr());
2101 for (const AsnListElmt *run=that.first; run; run=run->next)
2102 AppendCopy (*run->elmt);
2103 }
2104
2105 return *this;
2106 #else // SNACC_DEEP_COPY
2107 Asn1Error << "use of incompletely defined RelativeDistinguishedName &RelativeDistinguishedName::operator = (const RelativeDistinguishedName &)" << endl;
2108 abort();
2109 // if your compiler complains here, check the -novolat option
2110 #endif // SNACC_DEEP_COPY
2111 }
2112
2113 void RelativeDistinguishedName::Print (ostream &os) const
2114 {
2115 #ifndef NDEBUG
2116 os << "{ -- SEQUENCE/SET OF -- " << endl;
2117 indentG += stdIndentG;
2118 //SetCurrToFirst();
2119 //for (; Curr() != NULL; GoNext())
2120 for (const AsnListElmt *run=first; run; run=run->next)
2121 {
2122 Indent (os, indentG);
2123 //os << *Curr();
2124 os << *run->elmt;
2125 //if (Curr() != Last())
2126 if (run != last)
2127 os << ",";
2128 os << endl;
2129 }
2130 indentG -= stdIndentG;
2131 Indent (os, indentG);
2132 os << "}\n";
2133 #endif /* NDEBUG */
2134
2135
2136 } // Print
2137
2138
2139 void RelativeDistinguishedName::SetCurrElmt (unsigned long int index)
2140 {
2141 unsigned long int i;
2142 curr = first;
2143 if (count)
2144 for (i = 0; (i < (count-1)) && (i < index); i++)
2145 curr = curr->next;
2146 } // RelativeDistinguishedName::SetCurrElmt
2147
2148
2149 unsigned long int RelativeDistinguishedName::GetCurrElmtIndex()
2150 {
2151 unsigned long int i;
2152 AsnListElmt *tmp;
2153 if (curr != NULL)
2154 {
2155 for (i = 0, tmp = first; tmp != NULL; i++)
2156 {
2157 if (tmp == curr)
2158 return i;
2159 else
2160 tmp = tmp->next;
2161 }
2162 }
2163 return count;
2164 } // RelativeDistinguishedName::GetCurrElmtIndex
2165
2166
2167 // alloc new list elmt, put at end of list
2168 // and return the component type
2169 AttributeTypeAndDistinguishedValue *RelativeDistinguishedName::Append()
2170 {
2171 AsnListElmt *newElmt;
2172 newElmt = new AsnListElmt;
2173 newElmt->elmt = new AttributeTypeAndDistinguishedValue;
2174 newElmt->next = NULL;
2175 if (last == NULL)
2176 {
2177 newElmt->prev = NULL;
2178 first = last = newElmt;
2179 }
2180 else
2181 {
2182 newElmt->prev = last;
2183 last->next = newElmt;
2184 last = newElmt;
2185 }
2186 count++;
2187 return (curr = newElmt)->elmt;
2188 } // RelativeDistinguishedName::Append
2189
2190
2191 // alloc new list elmt, put at begining of list
2192 // and return the component type
2193 AttributeTypeAndDistinguishedValue *RelativeDistinguishedName::Prepend()
2194 {
2195 AsnListElmt *newElmt;
2196 newElmt = new AsnListElmt;
2197 newElmt->elmt = new AttributeTypeAndDistinguishedValue;
2198 newElmt->prev = NULL;
2199 if (first == NULL)
2200 {
2201 newElmt->next = NULL;
2202 first = last = newElmt;
2203 }
2204 else
2205 {
2206 newElmt->next = first;
2207 first->prev = newElmt;
2208 first = newElmt;
2209 }
2210 count++;
2211 return (curr = newElmt)->elmt;
2212 } // RelativeDistinguishedName::Prepend
2213
2214
2215 // alloc new list elmt, insert it before the
2216 // current element and return the component type
2217 // if the current element is null, the new element
2218 // is placed at the beginning of the list.
2219 AttributeTypeAndDistinguishedValue *RelativeDistinguishedName::InsertBefore()
2220 {
2221 AsnListElmt *newElmt;
2222 newElmt = new AsnListElmt;
2223 newElmt->elmt = new AttributeTypeAndDistinguishedValue;
2224 if (curr == NULL)
2225 {
2226 newElmt->next = first;
2227 newElmt->prev = NULL;
2228 first = newElmt;
2229 if (last == NULL)
2230 last = newElmt;
2231 }
2232 else
2233 {
2234 newElmt->next = curr;
2235 newElmt->prev = curr->prev;
2236 curr->prev = newElmt;
2237 if (curr == first)
2238 first = newElmt;
2239 else
2240 newElmt->prev->next = newElmt;
2241 }
2242 count++;
2243 return (curr = newElmt)->elmt;
2244 } // RelativeDistinguishedName::InsertBefore
2245
2246
2247 // alloc new list elmt, insert it after the
2248 // current element and return the component type
2249 // if the current element is null, the new element
2250 // is placed at the end of the list.
2251 AttributeTypeAndDistinguishedValue *RelativeDistinguishedName::InsertAfter()
2252 {
2253 AsnListElmt *newElmt;
2254 newElmt = new AsnListElmt;
2255 newElmt->elmt = new AttributeTypeAndDistinguishedValue;
2256 if (curr == NULL)
2257 {
2258 newElmt->prev = last;
2259 newElmt->next = NULL;
2260 last = newElmt;
2261 if (first == NULL)
2262 first = newElmt;
2263 }
2264 else
2265 {
2266 newElmt->prev = curr;
2267 newElmt->next = curr->next;
2268 curr->next = newElmt;
2269 if (curr == last)
2270 last = newElmt;
2271 else
2272 newElmt->next->prev = newElmt;
2273 }
2274 count++;
2275 return (curr = newElmt)->elmt;
2276 } // RelativeDistinguishedName::InsertAfter
2277
2278
2279 RelativeDistinguishedName &RelativeDistinguishedName::AppendCopy (AttributeTypeAndDistinguishedValue &elmt)
2280 {
2281 AsnListElmt *newElmt;
2282 newElmt = new AsnListElmt;
2283 newElmt->elmt = new AttributeTypeAndDistinguishedValue;
2284 *newElmt->elmt = elmt;
2285 newElmt->next = NULL;
2286 if (last == NULL)
2287 {
2288 newElmt->prev = NULL;
2289 first = last = newElmt;
2290 }
2291 else
2292 {
2293 newElmt->prev = last;
2294 last->next = newElmt;
2295 last = newElmt;
2296 }
2297 count++;
2298 return *this;
2299 } // AppendCopy
2300
2301
2302 RelativeDistinguishedName &RelativeDistinguishedName::PrependCopy (AttributeTypeAndDistinguishedValue &elmt)
2303 {
2304 AsnListElmt *newElmt;
2305 newElmt = new AsnListElmt;
2306 newElmt->elmt = new AttributeTypeAndDistinguishedValue;
2307 *newElmt->elmt = elmt;
2308 newElmt->prev = NULL;
2309 if (first == NULL)
2310 {
2311 newElmt->next = NULL;
2312 first = last = newElmt;
2313 }
2314 else
2315 {
2316 newElmt->next = first;
2317 first->prev = newElmt;
2318 first = newElmt;
2319 }
2320 count++;
2321 return *this;
2322 } // RelativeDistinguishedName::PrependCopy
2323
2324
2325 // alloc new list elmt, insert it before the
2326 // current element, copy the given elmt into the new elmt
2327 // and return the component type.
2328 // if the current element is null, the new element
2329 // is placed at the beginning of the list.
2330 RelativeDistinguishedName &RelativeDistinguishedName::InsertBeforeAndCopy (AttributeTypeAndDistinguishedValue &elmt)
2331 {
2332 AsnListElmt *newElmt;
2333
2334 newElmt = new AsnListElmt;
2335 newElmt->elmt = new AttributeTypeAndDistinguishedValue;
2336 *newElmt->elmt = elmt;
2337
2338 if (curr == NULL)
2339 {
2340 newElmt->next = first;
2341 newElmt->prev = NULL;
2342 first = newElmt;
2343 if (last == NULL)
2344 last = newElmt;
2345 }
2346 else
2347 {
2348 newElmt->next = curr;
2349 newElmt->prev = curr->prev;
2350 curr->prev = newElmt;
2351 if (curr == first)
2352 first = newElmt;
2353 else
2354 newElmt->prev->next = newElmt;
2355 }
2356 count++;
2357 return *this;
2358 } // RelativeDistinguishedName::InsertBeforeAndCopy
2359
2360
2361 // alloc new list elmt, insert it after the
2362 // current element, copy given elmt in to new elmt
2363 // and return the component type
2364 // if the current element is null, the new element
2365 // is placed at the end of the list.
2366 RelativeDistinguishedName &RelativeDistinguishedName::InsertAfterAndCopy (AttributeTypeAndDistinguishedValue &elmt)
2367 {
2368 AsnListElmt *newElmt;
2369
2370 newElmt = new AsnListElmt;
2371 newElmt->elmt = new AttributeTypeAndDistinguishedValue;
2372 *newElmt->elmt = elmt;
2373 if (curr == NULL)
2374 {
2375 newElmt->prev = last;
2376 newElmt->next = NULL;
2377 last = newElmt;
2378 if (first == NULL)
2379 first = newElmt;
2380 }
2381 else
2382 {
2383 newElmt->prev = curr;
2384 newElmt->next = curr->next;
2385 curr->next = newElmt;
2386 if (curr == last)
2387 last = newElmt;
2388 else
2389 newElmt->next->prev = newElmt;
2390 }
2391 count++;
2392 return *this;
2393 } // RelativeDistinguishedName::InsertAfterAndCopy
2394
2395
2396 // remove current element from list if current element is not NULL
2397 // The new current element will be the next element.
2398 // If the current element is the last element in the list
2399 // the second but last element will become the new current element.
2400 void RelativeDistinguishedName::RemoveCurrFromList()
2401 {
2402 AsnListElmt *del_elmt;
2403
2404 if (curr != NULL)
2405 {
2406 del_elmt = curr;
2407 count--;
2408
2409 if (count == 0)
2410 first = last = curr = NULL;
2411 else if (curr == first)
2412 {
2413 curr = first= first->next;
2414 first->prev = NULL;
2415 }
2416 else if (curr == last)
2417 {
2418 curr = last = last->prev;
2419 last->next = NULL;
2420 }
2421 else
2422 {
2423 curr->prev->next = curr->next;
2424 curr->next->prev = curr->prev;
2425 }
2426
2427 delete del_elmt->elmt;
2428 delete del_elmt;
2429 }
2430 }
2431
2432
2433 AsnLen RelativeDistinguishedName::BEncContent (BUF_TYPE b)
2434 {
2435 AsnListElmt *currElmt;
2436 AsnLen elmtLen;
2437 AsnLen totalLen = 0;
2438 {
2439 int iii,icount;
2440 CSM_Buffer **tmpEnc=NULL;
2441 for (currElmt = last,icount=0; currElmt != NULL; currElmt = currElmt->prev, icount++);
2442 tmpEnc = (CSM_Buffer **) calloc(sizeof(CSM_Buffer *), icount);
2443 for (currElmt = last, iii=0; currElmt != NULL; currElmt = currElmt->prev,iii++,elmtLen=0)
2444 {
2445 BEncEocIfNec (b);
2446 ENCODE_BUF1(currElmt->elmt->BEncContent, elmtLen);
2447 elmtLen += BEncConsLen (outputBuf, elmtLen);
2448
2449 elmtLen += BEncTag1 (outputBuf, UNIV, CONS, SEQ_TAG_CODE);
2450 ENCODE_BUF2(tmpEnc[iii]);
2451 }
2452 vdasnacc_sortSetOf(tmpEnc, icount);
2453 for (iii=0,elmtLen=0; iii < icount; elmtLen+=tmpEnc[iii++]->Length())
2454 SM_WriteToAsnBuf(tmpEnc[iii], b);
2455 for (iii=0; iii < icount; iii++) delete tmpEnc[iii];
2456 free(tmpEnc);
2457 }
2458 totalLen += elmtLen;
2459 return totalLen;
2460 } // RelativeDistinguishedName::BEncContent
2461
2462
2463 void RelativeDistinguishedName::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0,
2464 AsnLen &bytesDecoded, ENV_TYPE env)
2465 {
2466 AttributeTypeAndDistinguishedValue *listElmt;
2467 AsnTag tag1;
2468 AsnLen listBytesDecoded = 0;
2469 AsnLen elmtLen1;
2470
2471 while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN))
2472 {
2473 tag1 = BDecTag (b, listBytesDecoded, env);
2474 if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN))
2475 {
2476 BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env);
2477 break;
2478 }
2479 if ((tag1 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))
2480 {
2481 Asn1Error << "Unexpected Tag" << endl;
2482 longjmp (env, -115);
2483 }
2484
2485 elmtLen1 = BDecLen (b, listBytesDecoded, env);
2486 listElmt = Append();
2487 listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env);
2488 }
2489
2490 bytesDecoded += listBytesDecoded;
2491 } // RelativeDistinguishedName::BDecContent
2492
2493
2494 AsnType *RDNSequence::Clone() const
2495 {
2496 return new RDNSequence;
2497 }
2498
2499 AsnType *RDNSequence::Copy() const
2500 {
2501 return new RDNSequence (*this);
2502 }
2503
2504 AsnLen RDNSequence::BEnc (BUF_TYPE b)
2505 {
2506 AsnLen l;
2507 l = BEncContent (b);
2508 l += BEncConsLen (b, l);
2509 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
2510 return l;
2511 }
2512
2513 void RDNSequence::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
2514 {
2515 AsnTag tag;
2516 AsnLen elmtLen1;
2517
2518 if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
2519 {
2520 Asn1Error << "RDNSequence::BDec: ERROR - wrong tag" << endl;
2521 longjmp (env, -116);
2522 }
2523 elmtLen1 = BDecLen (b, bytesDecoded, env);
2524 BDecContent (b, tag, elmtLen1, bytesDecoded, env);
2525 }
2526
2527 RDNSequence::RDNSequence (const RDNSequence &)
2528 {
2529 Asn1Error << "use of incompletely defined RDNSequence::RDNSequence (const RDNSequence &)" << endl;
2530 abort();
2531 }
2532
2533 RDNSequence::~RDNSequence()
2534 {
2535 SetCurrToFirst();
2536 for (; Curr() != NULL; RemoveCurrFromList())
2537 ;
2538 } // end of destructor
2539
2540 #if SNACC_DEEP_COPY
2541 RDNSequence &RDNSequence::operator = (const RDNSequence &that)
2542 #else // SNACC_DEEP_COPY
2543 RDNSequence &RDNSequence::operator = (const RDNSequence &)
2544 #endif // SNACC_DEEP_COPY
2545 {
2546 #if SNACC_DEEP_COPY
2547 if (this != &that)
2548 {
2549 SetCurrToFirst();
2550 for (; Curr(); RemoveCurrFromList())
2551 ;
2552
2553 //that.SetCurrToFirst();
2554 //for (; that.Curr(); that.GoNext())
2555 // AppendCopy (*that.Curr());
2556 for (const AsnListElmt *run=that.first; run; run=run->next)
2557 AppendCopy (*run->elmt);
2558 }
2559
2560 return *this;
2561 #else // SNACC_DEEP_COPY
2562 Asn1Error << "use of incompletely defined RDNSequence &RDNSequence::operator = (const RDNSequence &)" << endl;
2563 abort();
2564 // if your compiler complains here, check the -novolat option
2565 #endif // SNACC_DEEP_COPY
2566 }
2567
2568 void RDNSequence::Print (ostream &os) const
2569 {
2570 #ifndef NDEBUG
2571 os << "{ -- SEQUENCE/SET OF -- " << endl;
2572 indentG += stdIndentG;
2573 //SetCurrToFirst();
2574 //for (; Curr() != NULL; GoNext())
2575 for (const AsnListElmt *run=first; run; run=run->next)
2576 {
2577 Indent (os, indentG);
2578 //os << *Curr();
2579 os << *run->elmt;
2580 //if (Curr() != Last())
2581 if (run != last)
2582 os << ",";
2583 os << endl;
2584 }
2585 indentG -= stdIndentG;
2586 Indent (os, indentG);
2587 os << "}\n";
2588 #endif /* NDEBUG */
2589
2590
2591 } // Print
2592
2593
2594 void RDNSequence::SetCurrElmt (unsigned long int index)
2595 {
2596 unsigned long int i;
2597 curr = first;
2598 if (count)
2599 for (i = 0; (i < (count-1)) && (i < index); i++)
2600 curr = curr->next;
2601 } // RDNSequence::SetCurrElmt
2602
2603
2604 unsigned long int RDNSequence::GetCurrElmtIndex()
2605 {
2606 unsigned long int i;
2607 AsnListElmt *tmp;
2608 if (curr != NULL)
2609 {
2610 for (i = 0, tmp = first; tmp != NULL; i++)
2611 {
2612 if (tmp == curr)
2613 return i;
2614 else
2615 tmp = tmp->next;
2616 }
2617 }
2618 return count;
2619 } // RDNSequence::GetCurrElmtIndex
2620
2621
2622 // alloc new list elmt, put at end of list
2623 // and return the component type
2624 RelativeDistinguishedName *RDNSequence::Append()
2625 {
2626 AsnListElmt *newElmt;
2627 newElmt = new AsnListElmt;
2628 newElmt->elmt = new RelativeDistinguishedName;
2629 newElmt->next = NULL;
2630 if (last == NULL)
2631 {
2632 newElmt->prev = NULL;
2633 first = last = newElmt;
2634 }
2635 else
2636 {
2637 newElmt->prev = last;
2638 last->next = newElmt;
2639 last = newElmt;
2640 }
2641 count++;
2642 return (curr = newElmt)->elmt;
2643 } // RDNSequence::Append
2644
2645
2646 // alloc new list elmt, put at begining of list
2647 // and return the component type
2648 RelativeDistinguishedName *RDNSequence::Prepend()
2649 {
2650 AsnListElmt *newElmt;
2651 newElmt = new AsnListElmt;
2652 newElmt->elmt = new RelativeDistinguishedName;
2653 newElmt->prev = NULL;
2654 if (first == NULL)
2655 {
2656 newElmt->next = NULL;
2657 first = last = newElmt;
2658 }
2659 else
2660 {
2661 newElmt->next = first;
2662 first->prev = newElmt;
2663 first = newElmt;
2664 }
2665 count++;
2666 return (curr = newElmt)->elmt;
2667 } // RDNSequence::Prepend
2668
2669
2670 // alloc new list elmt, insert it before the
2671 // current element and return the component type
2672 // if the current element is null, the new element
2673 // is placed at the beginning of the list.
2674 RelativeDistinguishedName *RDNSequence::InsertBefore()
2675 {
2676 AsnListElmt *newElmt;
2677 newElmt = new AsnListElmt;
2678 newElmt->elmt = new RelativeDistinguishedName;
2679 if (curr == NULL)
2680 {
2681 newElmt->next = first;
2682 newElmt->prev = NULL;
2683 first = newElmt;
2684 if (last == NULL)
2685 last = newElmt;
2686 }
2687 else
2688 {
2689 newElmt->next = curr;
2690 newElmt->prev = curr->prev;
2691 curr->prev = newElmt;
2692 if (curr == first)
2693 first = newElmt;
2694 else
2695 newElmt->prev->next = newElmt;
2696 }
2697 count++;
2698 return (curr = newElmt)->elmt;
2699 } // RDNSequence::InsertBefore
2700
2701
2702 // alloc new list elmt, insert it after the
2703 // current element and return the component type
2704 // if the current element is null, the new element
2705 // is placed at the end of the list.
2706 RelativeDistinguishedName *RDNSequence::InsertAfter()
2707 {
2708 AsnListElmt *newElmt;
2709 newElmt = new AsnListElmt;
2710 newElmt->elmt = new RelativeDistinguishedName;
2711 if (curr == NULL)
2712 {
2713 newElmt->prev = last;
2714 newElmt->next = NULL;
2715 last = newElmt;
2716 if (first == NULL)
2717 first = newElmt;
2718 }
2719 else
2720 {
2721 newElmt->prev = curr;
2722 newElmt->next = curr->next;
2723 curr->next = newElmt;
2724 if (curr == last)
2725 last = newElmt;
2726 else
2727 newElmt->next->prev = newElmt;
2728 }
2729 count++;
2730 return (curr = newElmt)->elmt;
2731 } // RDNSequence::InsertAfter
2732
2733
2734 RDNSequence &RDNSequence::AppendCopy (RelativeDistinguishedName &elmt)
2735 {
2736 AsnListElmt *newElmt;
2737 newElmt = new AsnListElmt;
2738 newElmt->elmt = new RelativeDistinguishedName;
2739 *newElmt->elmt = elmt;
2740 newElmt->next = NULL;
2741 if (last == NULL)
2742 {
2743 newElmt->prev = NULL;
2744 first = last = newElmt;
2745 }
2746 else
2747 {
2748 newElmt->prev = last;
2749 last->next = newElmt;
2750 last = newElmt;
2751 }
2752 count++;
2753 return *this;
2754 } // AppendCopy
2755
2756
2757 RDNSequence &RDNSequence::PrependCopy (RelativeDistinguishedName &elmt)
2758 {
2759 AsnListElmt *newElmt;
2760 newElmt = new AsnListElmt;
2761 newElmt->elmt = new RelativeDistinguishedName;
2762 *newElmt->elmt = elmt;
2763 newElmt->prev = NULL;
2764 if (first == NULL)
2765 {
2766 newElmt->next = NULL;
2767 first = last = newElmt;
2768 }
2769 else
2770 {
2771 newElmt->next = first;
2772 first->prev = newElmt;
2773 first = newElmt;
2774 }
2775 count++;
2776 return *this;
2777 } // RDNSequence::PrependCopy
2778
2779
2780 // alloc new list elmt, insert it before the
2781 // current element, copy the given elmt into the new elmt
2782 // and return the component type.
2783 // if the current element is null, the new element
2784 // is placed at the beginning of the list.
2785 RDNSequence &RDNSequence::InsertBeforeAndCopy (RelativeDistinguishedName &elmt)
2786 {
2787 AsnListElmt *newElmt;
2788
2789 newElmt = new AsnListElmt;
2790 newElmt->elmt = new RelativeDistinguishedName;
2791 *newElmt->elmt = elmt;
2792
2793 if (curr == NULL)
2794 {
2795 newElmt->next = first;
2796 newElmt->prev = NULL;
2797 first = newElmt;
2798 if (last == NULL)
2799 last = newElmt;
2800 }
2801 else
2802 {
2803 newElmt->next = curr;
2804 newElmt->prev = curr->prev;
2805 curr->prev = newElmt;
2806 if (curr == first)
2807 first = newElmt;
2808 else
2809 newElmt->prev->next = newElmt;
2810 }
2811 count++;
2812 return *this;
2813 } // RDNSequence::InsertBeforeAndCopy
2814
2815
2816 // alloc new list elmt, insert it after the
2817 // current element, copy given elmt in to new elmt
2818 // and return the component type
2819 // if the current element is null, the new element
2820 // is placed at the end of the list.
2821 RDNSequence &RDNSequence::InsertAfterAndCopy (RelativeDistinguishedName &elmt)
2822 {
2823 AsnListElmt *newElmt;
2824
2825 newElmt = new AsnListElmt;
2826 newElmt->elmt = new RelativeDistinguishedName;
2827 *newElmt->elmt = elmt;
2828 if (curr == NULL)
2829 {
2830 newElmt->prev = last;
2831 newElmt->next = NULL;
2832 last = newElmt;
2833 if (first == NULL)
2834 first = newElmt;
2835 }
2836 else
2837 {
2838 newElmt->prev = curr;
2839 newElmt->next = curr->next;
2840 curr->next = newElmt;
2841 if (curr == last)
2842 last = newElmt;
2843 else
2844 newElmt->next->prev = newElmt;
2845 }
2846 count++;
2847 return *this;
2848 } // RDNSequence::InsertAfterAndCopy
2849
2850
2851 // remove current element from list if current element is not NULL
2852 // The new current element will be the next element.
2853 // If the current element is the last element in the list
2854 // the second but last element will become the new current element.
2855 void RDNSequence::RemoveCurrFromList()
2856 {
2857 AsnListElmt *del_elmt;
2858
2859 if (curr != NULL)
2860 {
2861 del_elmt = curr;
2862 count--;
2863
2864 if (count == 0)
2865 first = last = curr = NULL;
2866 else if (curr == first)
2867 {
2868 curr = first= first->next;
2869 first->prev = NULL;
2870 }
2871 else if (curr == last)
2872 {
2873 curr = last = last->prev;
2874 last->next = NULL;
2875 }
2876 else
2877 {
2878 curr->prev->next = curr->next;
2879 curr->next->prev = curr->prev;
2880 }
2881
2882 delete del_elmt->elmt;
2883 delete del_elmt;
2884 }
2885 }
2886
2887
2888 AsnLen RDNSequence::BEncContent (BUF_TYPE b)
2889 {
2890 AsnListElmt *currElmt;
2891 AsnLen elmtLen;
2892 AsnLen totalLen = 0;
2893 for (currElmt = last; currElmt != NULL; currElmt = currElmt->prev)
2894 {
2895 BEncEocIfNec (b);
2896 elmtLen = currElmt->elmt->BEncContent (b);
2897 elmtLen += BEncConsLen (b, elmtLen);
2898
2899 elmtLen += BEncTag1 (b, UNIV, CONS, SET_TAG_CODE);
2900 totalLen += elmtLen;
2901 }
2902 return totalLen;
2903 } // RDNSequence::BEncContent
2904
2905
2906 void RDNSequence::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0,
2907 AsnLen &bytesDecoded, ENV_TYPE env)
2908 {
2909 RelativeDistinguishedName *listElmt;
2910 AsnTag tag1;
2911 AsnLen listBytesDecoded = 0;
2912 AsnLen elmtLen1;
2913
2914 while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN))
2915 {
2916 tag1 = BDecTag (b, listBytesDecoded, env);
2917 if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN))
2918 {
2919 BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env);
2920 break;
2921 }
2922 if ((tag1 != MAKE_TAG_ID (UNIV, CONS, SET_TAG_CODE)))
2923 {
2924 Asn1Error << "Unexpected Tag" << endl;
2925 longjmp (env, -117);
2926 }
2927
2928 elmtLen1 = BDecLen (b, listBytesDecoded, env);
2929 listElmt = Append();
2930 listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env);
2931 }
2932
2933 bytesDecoded += listBytesDecoded;
2934 } // RDNSequence::BDecContent
2935
2936
2937 AsnType *Attributes::Clone() const
2938 {
2939 return new Attributes;
2940 }
2941
2942 AsnType *Attributes::Copy() const
2943 {
2944 return new Attributes (*this);
2945 }
2946
2947 AsnLen Attributes::BEnc (BUF_TYPE b)
2948 {
2949 AsnLen l;
2950 l = BEncContent (b);
2951 l += BEncConsLen (b, l);
2952 l += BEncTag1 (b, UNIV, CONS, SET_TAG_CODE);
2953 return l;
2954 }
2955
2956 void Attributes::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
2957 {
2958 AsnTag tag;
2959 AsnLen elmtLen1;
2960
2961 if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SET_TAG_CODE))
2962 {
2963 Asn1Error << "Attributes::BDec: ERROR - wrong tag" << endl;
2964 longjmp (env, -118);
2965 }
2966 elmtLen1 = BDecLen (b, bytesDecoded, env);
2967 BDecContent (b, tag, elmtLen1, bytesDecoded, env);
2968 }
2969
2970 Attributes::Attributes (const Attributes &)
2971 {
2972 Asn1Error << "use of incompletely defined Attributes::Attributes (const Attributes &)" << endl;
2973 abort();
2974 }
2975
2976 Attributes::~Attributes()
2977 {
2978 SetCurrToFirst();
2979 for (; Curr() != NULL; RemoveCurrFromList())
2980 ;
2981 } // end of destructor
2982
2983 #if SNACC_DEEP_COPY
2984 Attributes &Attributes::operator = (const Attributes &that)
2985 #else // SNACC_DEEP_COPY
2986 Attributes &Attributes::operator = (const Attributes &)
2987 #endif // SNACC_DEEP_COPY
2988 {
2989 #if SNACC_DEEP_COPY
2990 if (this != &that)
2991 {
2992 SetCurrToFirst();
2993 for (; Curr(); RemoveCurrFromList())
2994 ;
2995
2996 //that.SetCurrToFirst();
2997 //for (; that.Curr(); that.GoNext())
2998 // AppendCopy (*that.Curr());
2999 for (const AsnListElmt *run=that.first; run; run=run->next)
3000 AppendCopy (*run->elmt);
3001 }
3002
3003 return *this;
3004 #else // SNACC_DEEP_COPY
3005 Asn1Error << "use of incompletely defined Attributes &Attributes::operator = (const Attributes &)" << endl;
3006 abort();
3007 // if your compiler complains here, check the -novolat option
3008 #endif // SNACC_DEEP_COPY
3009 }
3010
3011 void Attributes::Print (ostream &os) const
3012 {
3013 #ifndef NDEBUG
3014 os << "{ -- SEQUENCE/SET OF -- " << endl;
3015 indentG += stdIndentG;
3016 //SetCurrToFirst();
3017 //for (; Curr() != NULL; GoNext())
3018 for (const AsnListElmt *run=first; run; run=run->next)
3019 {
3020 Indent (os, indentG);
3021 //os << *Curr();
3022 os << *run->elmt;
3023 //if (Curr() != Last())
3024 if (run != last)
3025 os << ",";
3026 os << endl;
3027 }
3028 indentG -= stdIndentG;
3029 Indent (os, indentG);
3030 os << "}\n";
3031 #endif /* NDEBUG */
3032
3033
3034 } // Print
3035
3036
3037 void Attributes::SetCurrElmt (unsigned long int index)
3038 {
3039 unsigned long int i;
3040 curr = first;
3041 if (count)
3042 for (i = 0; (i < (count-1)) && (i < index); i++)
3043 curr = curr->next;
3044 } // Attributes::SetCurrElmt
3045
3046
3047 unsigned long int Attributes::GetCurrElmtIndex()
3048 {
3049 unsigned long int i;
3050 AsnListElmt *tmp;
3051 if (curr != NULL)
3052 {
3053 for (i = 0, tmp = first; tmp != NULL; i++)
3054 {
3055 if (tmp == curr)
3056 return i;
3057 else
3058 tmp = tmp->next;
3059 }
3060 }
3061 return count;
3062 } // Attributes::GetCurrElmtIndex
3063
3064
3065 // alloc new list elmt, put at end of list
3066 // and return the component type
3067 Attribute *Attributes::Append()
3068 {
3069 AsnListElmt *newElmt;
3070 newElmt = new AsnListElmt;
3071 newElmt->elmt = new Attribute;
3072 newElmt->next = NULL;
3073 if (last == NULL)
3074 {
3075 newElmt->prev = NULL;
3076 first = last = newElmt;
3077 }
3078 else
3079 {
3080 newElmt->prev = last;
3081 last->next = newElmt;
3082 last = newElmt;
3083 }
3084 count++;
3085 return (curr = newElmt)->elmt;
3086 } // Attributes::Append
3087
3088
3089 // alloc new list elmt, put at begining of list
3090 // and return the component type
3091 Attribute *Attributes::Prepend()
3092 {
3093 AsnListElmt *newElmt;
3094 newElmt = new AsnListElmt;
3095 newElmt->elmt = new Attribute;
3096 newElmt->prev = NULL;
3097 if (first == NULL)
3098 {
3099 newElmt->next = NULL;
3100 first = last = newElmt;
3101 }
3102 else
3103 {
3104 newElmt->next = first;
3105 first->prev = newElmt;
3106 first = newElmt;
3107 }
3108 count++;
3109 return (curr = newElmt)->elmt;
3110 } // Attributes::Prepend
3111
3112
3113 // alloc new list elmt, insert it before the
3114 // current element and return the component type
3115 // if the current element is null, the new element
3116 // is placed at the beginning of the list.
3117 Attribute *Attributes::InsertBefore()
3118 {
3119 AsnListElmt *newElmt;
3120 newElmt = new AsnListElmt;
3121 newElmt->elmt = new Attribute;
3122 if (curr == NULL)
3123 {
3124 newElmt->next = first;
3125 newElmt->prev = NULL;
3126 first = newElmt;
3127 if (last == NULL)
3128 last = newElmt;
3129 }
3130 else
3131 {
3132 newElmt->next = curr;
3133 newElmt->prev = curr->prev;
3134 curr->prev = newElmt;
3135 if (curr == first)
3136 first = newElmt;
3137 else
3138 newElmt->prev->next = newElmt;
3139 }
3140 count++;
3141 return (curr = newElmt)->elmt;
3142 } // Attributes::InsertBefore
3143
3144
3145 // alloc new list elmt, insert it after the
3146 // current element and return the component type
3147 // if the current element is null, the new element
3148 // is placed at the end of the list.
3149 Attribute *Attributes::InsertAfter()
3150 {
3151 AsnListElmt *newElmt;
3152 newElmt = new AsnListElmt;
3153 newElmt->elmt = new Attribute;
3154 if (curr == NULL)
3155 {
3156 newElmt->prev = last;
3157 newElmt->next = NULL;
3158 last = newElmt;
3159 if (first == NULL)
3160 first = newElmt;
3161 }
3162 else
3163 {
3164 newElmt->prev = curr;
3165 newElmt->next = curr->next;
3166 curr->next = newElmt;
3167 if (curr == last)
3168 last = newElmt;
3169 else
3170 newElmt->next->prev = newElmt;
3171 }
3172 count++;
3173 return (curr = newElmt)->elmt;
3174 } // Attributes::InsertAfter
3175
3176
3177 Attributes &Attributes::AppendCopy (Attribute &elmt)
3178 {
3179 AsnListElmt *newElmt;
3180 newElmt = new AsnListElmt;
3181 newElmt->elmt = new Attribute;
3182 *newElmt->elmt = elmt;
3183 newElmt->next = NULL;
3184 if (last == NULL)
3185 {
3186 newElmt->prev = NULL;
3187 first = last = newElmt;
3188 }
3189 else
3190 {
3191 newElmt->prev = last;
3192 last->next = newElmt;
3193 last = newElmt;
3194 }
3195 count++;
3196 return *this;
3197 } // AppendCopy
3198
3199
3200 Attributes &Attributes::PrependCopy (Attribute &elmt)
3201 {
3202 AsnListElmt *newElmt;
3203 newElmt = new AsnListElmt;
3204 newElmt->elmt = new Attribute;
3205 *newElmt->elmt = elmt;
3206 newElmt->prev = NULL;
3207 if (first == NULL)
3208 {
3209 newElmt->next = NULL;
3210 first = last = newElmt;
3211 }
3212 else
3213 {
3214 newElmt->next = first;
3215 first->prev = newElmt;
3216 first = newElmt;
3217 }
3218 count++;
3219 return *this;
3220 } // Attributes::PrependCopy
3221
3222
3223 // alloc new list elmt, insert it before the
3224 // current element, copy the given elmt into the new elmt
3225 // and return the component type.
3226 // if the current element is null, the new element
3227 // is placed at the beginning of the list.
3228 Attributes &Attributes::InsertBeforeAndCopy (Attribute &elmt)
3229 {
3230 AsnListElmt *newElmt;
3231
3232 newElmt = new AsnListElmt;
3233 newElmt->elmt = new Attribute;
3234 *newElmt->elmt = elmt;
3235
3236 if (curr == NULL)
3237 {
3238 newElmt->next = first;
3239 newElmt->prev = NULL;
3240 first = newElmt;
3241 if (last == NULL)
3242 last = newElmt;
3243 }
3244 else
3245 {
3246 newElmt->next = curr;
3247 newElmt->prev = curr->prev;
3248 curr->prev = newElmt;
3249 if (curr == first)
3250 first = newElmt;
3251 else
3252 newElmt->prev->next = newElmt;
3253 }
3254 count++;
3255 return *this;
3256 } // Attributes::InsertBeforeAndCopy
3257
3258
3259 // alloc new list elmt, insert it after the
3260 // current element, copy given elmt in to new elmt
3261 // and return the component type
3262 // if the current element is null, the new element
3263 // is placed at the end of the list.
3264 Attributes &Attributes::InsertAfterAndCopy (Attribute &elmt)
3265 {
3266 AsnListElmt *newElmt;
3267
3268 newElmt = new AsnListElmt;
3269 newElmt->elmt = new Attribute;
3270 *newElmt->elmt = elmt;
3271 if (curr == NULL)
3272 {
3273 newElmt->prev = last;
3274 newElmt->next = NULL;
3275 last = newElmt;
3276 if (first == NULL)
3277 first = newElmt;
3278 }
3279 else
3280 {
3281 newElmt->prev = curr;
3282 newElmt->next = curr->next;
3283 curr->next = newElmt;
3284 if (curr == last)
3285 last = newElmt;
3286 else
3287 newElmt->next->prev = newElmt;
3288 }
3289 count++;
3290 return *this;
3291 } // Attributes::InsertAfterAndCopy
3292
3293
3294 // remove current element from list if current element is not NULL
3295 // The new current element will be the next element.
3296 // If the current element is the last element in the list
3297 // the second but last element will become the new current element.
3298 void Attributes::RemoveCurrFromList()
3299 {
3300 AsnListElmt *del_elmt;
3301
3302 if (curr != NULL)
3303 {
3304 del_elmt = curr;
3305 count--;
3306
3307 if (count == 0)
3308 first = last = curr = NULL;
3309 else if (curr == first)
3310 {
3311 curr = first= first->next;
3312 first->prev = NULL;
3313 }
3314 else if (curr == last)
3315 {
3316 curr = last = last->prev;
3317 last->next = NULL;
3318 }
3319 else
3320 {
3321 curr->prev->next = curr->next;
3322 curr->next->prev = curr->prev;
3323 }
3324
3325 delete del_elmt->elmt;
3326 delete del_elmt;
3327 }
3328 }
3329
3330
3331 AsnLen Attributes::BEncContent (BUF_TYPE b)
3332 {
3333 AsnListElmt *currElmt;
3334 AsnLen elmtLen;
3335 AsnLen totalLen = 0;
3336 {
3337 int iii,icount;
3338 CSM_Buffer **tmpEnc=NULL;
3339 for (currElmt = last,icount=0; currElmt != NULL; currElmt = currElmt->prev, icount++);
3340 tmpEnc = (CSM_Buffer **) calloc(sizeof(CSM_Buffer *), icount);
3341 for (currElmt = last, iii=0; currElmt != NULL; currElmt = currElmt->prev,iii++,elmtLen=0)
3342 {
3343 BEncEocIfNec (b);
3344 ENCODE_BUF1(currElmt->elmt->BEncContent, elmtLen);
3345 elmtLen += BEncConsLen (outputBuf, elmtLen);
3346
3347 elmtLen += BEncTag1 (outputBuf, UNIV, CONS, SEQ_TAG_CODE);
3348 ENCODE_BUF2(tmpEnc[iii]);
3349 }
3350 vdasnacc_sortSetOf(tmpEnc, icount);
3351 for (iii=0,elmtLen=0; iii < icount; elmtLen+=tmpEnc[iii++]->Length())
3352 SM_WriteToAsnBuf(tmpEnc[iii], b);
3353 for (iii=0; iii < icount; iii++) delete tmpEnc[iii];
3354 free(tmpEnc);
3355 }
3356 totalLen += elmtLen;
3357 return totalLen;
3358 } // Attributes::BEncContent
3359
3360
3361 void Attributes::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0,
3362 AsnLen &bytesDecoded, ENV_TYPE env)
3363 {
3364 Attribute *listElmt;
3365 AsnTag tag1;
3366 AsnLen listBytesDecoded = 0;
3367 AsnLen elmtLen1;
3368
3369 while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN))
3370 {
3371 tag1 = BDecTag (b, listBytesDecoded, env);
3372 if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN))
3373 {
3374 BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env);
3375 break;
3376 }
3377 if ((tag1 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))
3378 {
3379 Asn1Error << "Unexpected Tag" << endl;
3380 longjmp (env, -119);
3381 }
3382
3383 elmtLen1 = BDecLen (b, listBytesDecoded, env);
3384 listElmt = Append();
3385 listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env);
3386 }
3387
3388 bytesDecoded += listBytesDecoded;
3389 } // Attributes::BDecContent
3390
3391
3392 Name::Name()
3393 {
3394 choiceId = rDNSequenceCid;
3395 #if TCL
3396 rDNSequence = new RDNSequence;
3397 #else
3398 rDNSequence = NULL; // incomplete initialization of mandatory element!
3399 #endif // TCL
3400 }
3401
3402 Name::Name (const Name &)
3403 {
3404 Asn1Error << "use of incompletely defined Name::Name (const Name &)" << endl;
3405 abort();
3406 }
3407
3408 Name::~Name()
3409 {
3410 switch (choiceId)
3411 {
3412 case rDNSequenceCid:
3413 delete rDNSequence;
3414 break;
3415 } // end of switch
3416 } // end of destructor
3417
3418 AsnType *Name::Clone() const
3419 {
3420 return new Name;
3421 }
3422
3423 AsnType *Name::Copy() const
3424 {
3425 return new Name (*this);
3426 }
3427
3428 #if SNACC_DEEP_COPY
3429 Name &Name::operator = (const Name &that)
3430 #else // SNACC_DEEP_COPY
3431 Name &Name::operator = (const Name &)
3432 #endif // SNACC_DEEP_COPY
3433 {
3434 #if SNACC_DEEP_COPY
3435 if (this != &that)
3436 {
3437 switch (choiceId)
3438 {
3439 case rDNSequenceCid:
3440 delete rDNSequence;
3441 break;
3442 }
3443 switch (choiceId = that.choiceId)
3444 {
3445 case rDNSequenceCid:
3446 rDNSequence = new RDNSequence;
3447 *rDNSequence = *that.rDNSequence;
3448 break;
3449 }
3450 }
3451
3452 return *this;
3453 #else // SNACC_DEEP_COPY
3454 Asn1Error << "use of incompletely defined Name &Name::operator = (const Name &)" << endl;
3455 abort();
3456 // if your compiler complains here, check the -novolat option
3457 #endif // SNACC_DEEP_COPY
3458 }
3459
3460 AsnLen
3461 Name::BEncContent (BUF_TYPE b)
3462 {
3463 AsnLen l;
3464 switch (choiceId)
3465 {
3466 case rDNSequenceCid:
3467 BEncEocIfNec (b);
3468 l = rDNSequence->BEncContent (b);
3469 l += BEncConsLen (b, l);
3470
3471 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
3472 break;
3473
3474 } // end switch
3475 return l;
3476 } // Name::BEncContent
3477
3478
3479 void Name::BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env)
3480 {
3481 switch (tag)
3482 {
3483 case MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE):
3484 choiceId = rDNSequenceCid;
3485 rDNSequence = new RDNSequence;
3486 rDNSequence->BDecContent (b, tag, elmtLen0, bytesDecoded, env);
3487 break;
3488
3489 default:
3490 Asn1Error << "ERROR - unexpected tag in CHOICE" << endl;
3491 longjmp (env, -120);
3492 break;
3493 } // end switch
3494 } // Name::BDecContent
3495
3496
3497 AsnLen Name::BEnc (BUF_TYPE b)
3498 {
3499 AsnLen l;
3500 l = BEncContent (b);
3501 return l;
3502 }
3503
3504 void Name::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
3505 {
3506 AsnLen elmtLen;
3507 AsnTag tag;
3508
3509 /* CHOICEs are a special case - grab identifying tag */
3510 /* this allows easier handling of nested CHOICEs */
3511 tag = BDecTag (b, bytesDecoded, env);
3512 elmtLen = BDecLen (b, bytesDecoded, env);
3513 BDecContent (b, tag, elmtLen, bytesDecoded, env);
3514 }
3515
3516 int Name::BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded)
3517 {
3518 bytesEncoded = BEnc (b);
3519 return !b.WriteError();
3520 }
3521
3522 int Name::BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded)
3523 {
3524 ENV_TYPE env;
3525 int val;
3526
3527 bytesDecoded = 0;
3528 if ((val = setjmp (env)) == 0)
3529 {
3530 BDec (b, bytesDecoded, env);
3531 return !b.ReadError();
3532 }
3533 else
3534 return false;
3535 }
3536
3537 void Name::Print (ostream &os) const
3538 {
3539 #ifndef NDEBUG
3540 switch (choiceId)
3541 {
3542 case rDNSequenceCid:
3543 os << "rDNSequence ";
3544 if (rDNSequence)
3545 os << *rDNSequence;
3546 else
3547 os << "-- void3 --\n";
3548 break;
3549
3550 } // end of switch
3551 #endif /* NDEBUG */
3552 } // Name::Print
3553