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