1 // NOTE: this is a machine generated file--editing not recommended
3 // sm_x501if.cpp - class member functions for ASN.1 module InformationFramework
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
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"
26 #include "appleoids.h"
29 //------------------------------------------------------------------------------
33 //------------------------------------------------------------------------------
34 // class member definitions:
36 AsnType
*AttributeTypeAndDistinguishedValueSetOfSeqSetOf::Clone() const
38 return new AttributeTypeAndDistinguishedValueSetOfSeqSetOf
;
41 AsnType
*AttributeTypeAndDistinguishedValueSetOfSeqSetOf::Copy() const
43 return new AttributeTypeAndDistinguishedValueSetOfSeqSetOf (*this);
46 AsnLen
AttributeTypeAndDistinguishedValueSetOfSeqSetOf::BEnc (BUF_TYPE b
)
50 l
+= BEncConsLen (b
, l
);
51 l
+= BEncTag1 (b
, UNIV
, CONS
, SET_TAG_CODE
);
55 void AttributeTypeAndDistinguishedValueSetOfSeqSetOf::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
60 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SET_TAG_CODE
))
62 Asn1Error
<< "AttributeTypeAndDistinguishedValueSetOfSeqSetOf::BDec: ERROR - wrong tag" << endl
;
63 SnaccExcep::throwMe(-100);
65 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
66 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
69 AttributeTypeAndDistinguishedValueSetOfSeqSetOf::AttributeTypeAndDistinguishedValueSetOfSeqSetOf (const AttributeTypeAndDistinguishedValueSetOfSeqSetOf
&)
71 Asn1Error
<< "use of incompletely defined AttributeTypeAndDistinguishedValueSetOfSeqSetOf::AttributeTypeAndDistinguishedValueSetOfSeqSetOf (const AttributeTypeAndDistinguishedValueSetOfSeqSetOf &)" << endl
;
75 AttributeTypeAndDistinguishedValueSetOfSeqSetOf::~AttributeTypeAndDistinguishedValueSetOfSeqSetOf()
78 for (; Curr() != NULL
; RemoveCurrFromList())
80 } // end of destructor
83 AttributeTypeAndDistinguishedValueSetOfSeqSetOf
&AttributeTypeAndDistinguishedValueSetOfSeqSetOf::operator = (const AttributeTypeAndDistinguishedValueSetOfSeqSetOf
&that
)
84 #else // SNACC_DEEP_COPY
85 AttributeTypeAndDistinguishedValueSetOfSeqSetOf
&AttributeTypeAndDistinguishedValueSetOfSeqSetOf::operator = (const AttributeTypeAndDistinguishedValueSetOfSeqSetOf
&)
86 #endif // SNACC_DEEP_COPY
92 for (; Curr(); RemoveCurrFromList())
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
);
103 #else // SNACC_DEEP_COPY
104 Asn1Error
<< "use of incompletely defined AttributeTypeAndDistinguishedValueSetOfSeqSetOf &AttributeTypeAndDistinguishedValueSetOfSeqSetOf::operator = (const AttributeTypeAndDistinguishedValueSetOfSeqSetOf &)" << endl
;
106 // if your compiler complains here, check the -novolat option
107 #endif // SNACC_DEEP_COPY
110 void AttributeTypeAndDistinguishedValueSetOfSeqSetOf::Print (ostream
&os
) const
113 os
<< "{ -- SEQUENCE/SET OF -- " << endl
;
114 indentG
+= stdIndentG
;
116 //for (; Curr() != NULL; GoNext())
117 for (const AsnListElmt
*run
=first
; run
; run
=run
->next
)
119 Indent (os
, indentG
);
122 //if (Curr() != Last())
127 indentG
-= stdIndentG
;
128 Indent (os
, indentG
);
136 void AttributeTypeAndDistinguishedValueSetOfSeqSetOf::SetCurrElmt (unsigned long int index
)
141 for (i
= 0; (i
< (count
-1)) && (i
< index
); i
++)
143 } // AttributeTypeAndDistinguishedValueSetOfSeqSetOf::SetCurrElmt
146 unsigned long int AttributeTypeAndDistinguishedValueSetOfSeqSetOf::GetCurrElmtIndex()
152 for (i
= 0, tmp
= first
; tmp
!= NULL
; i
++)
161 } // AttributeTypeAndDistinguishedValueSetOfSeqSetOf::GetCurrElmtIndex
164 // alloc new list elmt, put at end of list
165 // and return the component type
166 AsnAny
*AttributeTypeAndDistinguishedValueSetOfSeqSetOf::Append()
168 AsnListElmt
*newElmt
;
169 newElmt
= new AsnListElmt
;
170 newElmt
->elmt
= new AsnAny
;
171 newElmt
->next
= NULL
;
174 newElmt
->prev
= NULL
;
175 first
= last
= newElmt
;
179 newElmt
->prev
= last
;
180 last
->next
= newElmt
;
184 return (curr
= newElmt
)->elmt
;
185 } // AttributeTypeAndDistinguishedValueSetOfSeqSetOf::Append
188 // alloc new list elmt, put at begining of list
189 // and return the component type
190 AsnAny
*AttributeTypeAndDistinguishedValueSetOfSeqSetOf::Prepend()
192 AsnListElmt
*newElmt
;
193 newElmt
= new AsnListElmt
;
194 newElmt
->elmt
= new AsnAny
;
195 newElmt
->prev
= NULL
;
198 newElmt
->next
= NULL
;
199 first
= last
= newElmt
;
203 newElmt
->next
= first
;
204 first
->prev
= newElmt
;
208 return (curr
= newElmt
)->elmt
;
209 } // AttributeTypeAndDistinguishedValueSetOfSeqSetOf::Prepend
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()
218 AsnListElmt
*newElmt
;
219 newElmt
= new AsnListElmt
;
220 newElmt
->elmt
= new AsnAny
;
223 newElmt
->next
= first
;
224 newElmt
->prev
= NULL
;
231 newElmt
->next
= curr
;
232 newElmt
->prev
= curr
->prev
;
233 curr
->prev
= newElmt
;
237 newElmt
->prev
->next
= newElmt
;
240 return (curr
= newElmt
)->elmt
;
241 } // AttributeTypeAndDistinguishedValueSetOfSeqSetOf::InsertBefore
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()
250 AsnListElmt
*newElmt
;
251 newElmt
= new AsnListElmt
;
252 newElmt
->elmt
= new AsnAny
;
255 newElmt
->prev
= last
;
256 newElmt
->next
= NULL
;
263 newElmt
->prev
= curr
;
264 newElmt
->next
= curr
->next
;
265 curr
->next
= newElmt
;
269 newElmt
->next
->prev
= newElmt
;
272 return (curr
= newElmt
)->elmt
;
273 } // AttributeTypeAndDistinguishedValueSetOfSeqSetOf::InsertAfter
276 AttributeTypeAndDistinguishedValueSetOfSeqSetOf
&AttributeTypeAndDistinguishedValueSetOfSeqSetOf::AppendCopy (AsnAny
&elmt
)
278 AsnListElmt
*newElmt
;
279 newElmt
= new AsnListElmt
;
280 newElmt
->elmt
= new AsnAny
;
281 *newElmt
->elmt
= elmt
;
282 newElmt
->next
= NULL
;
285 newElmt
->prev
= NULL
;
286 first
= last
= newElmt
;
290 newElmt
->prev
= last
;
291 last
->next
= newElmt
;
299 AttributeTypeAndDistinguishedValueSetOfSeqSetOf
&AttributeTypeAndDistinguishedValueSetOfSeqSetOf::PrependCopy (AsnAny
&elmt
)
301 AsnListElmt
*newElmt
;
302 newElmt
= new AsnListElmt
;
303 newElmt
->elmt
= new AsnAny
;
304 *newElmt
->elmt
= elmt
;
305 newElmt
->prev
= NULL
;
308 newElmt
->next
= NULL
;
309 first
= last
= newElmt
;
313 newElmt
->next
= first
;
314 first
->prev
= newElmt
;
319 } // AttributeTypeAndDistinguishedValueSetOfSeqSetOf::PrependCopy
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
)
329 AsnListElmt
*newElmt
;
331 newElmt
= new AsnListElmt
;
332 newElmt
->elmt
= new AsnAny
;
333 *newElmt
->elmt
= elmt
;
337 newElmt
->next
= first
;
338 newElmt
->prev
= NULL
;
345 newElmt
->next
= curr
;
346 newElmt
->prev
= curr
->prev
;
347 curr
->prev
= newElmt
;
351 newElmt
->prev
->next
= newElmt
;
355 } // AttributeTypeAndDistinguishedValueSetOfSeqSetOf::InsertBeforeAndCopy
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
)
365 AsnListElmt
*newElmt
;
367 newElmt
= new AsnListElmt
;
368 newElmt
->elmt
= new AsnAny
;
369 *newElmt
->elmt
= elmt
;
372 newElmt
->prev
= last
;
373 newElmt
->next
= NULL
;
380 newElmt
->prev
= curr
;
381 newElmt
->next
= curr
->next
;
382 curr
->next
= newElmt
;
386 newElmt
->next
->prev
= newElmt
;
390 } // AttributeTypeAndDistinguishedValueSetOfSeqSetOf::InsertAfterAndCopy
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()
399 AsnListElmt
*del_elmt
;
407 first
= last
= curr
= NULL
;
408 else if (curr
== first
)
410 curr
= first
= first
->next
;
413 else if (curr
== last
)
415 curr
= last
= last
->prev
;
420 curr
->prev
->next
= curr
->next
;
421 curr
->next
->prev
= curr
->prev
;
424 delete del_elmt
->elmt
;
430 AsnLen
AttributeTypeAndDistinguishedValueSetOfSeqSetOf::BEncContent (BUF_TYPE b
)
432 AsnListElmt
*currElmt
;
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)
442 tmpEnc
[iii
] = (CSM_Buffer
*)currElmt
->elmt
->value
;
444 vdasnacc_sortSetOf(tmpEnc
, icount
);
445 for (iii
=0,elmtLen
=0; iii
< icount
; elmtLen
+=tmpEnc
[iii
++]->Length())
446 SM_WriteToAsnBuf(tmpEnc
[iii
], b
);
451 } // AttributeTypeAndDistinguishedValueSetOfSeqSetOf::BEncContent
454 void AttributeTypeAndDistinguishedValueSetOfSeqSetOf::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
,
455 AsnLen
&bytesDecoded
, ENV_TYPE env
)
458 AsnLen listBytesDecoded
= 0;
460 while ((listBytesDecoded
< elmtLen0
) || (elmtLen0
== INDEFINITE_LEN
))
463 DEC_LOAD_ANYBUF(listElmt
, b
, listBytesDecoded
, env
);
466 bytesDecoded
+= listBytesDecoded
;
467 } // AttributeTypeAndDistinguishedValueSetOfSeqSetOf::BDecContent
470 AttributeTypeAndDistinguishedValueSetOfSeq::AttributeTypeAndDistinguishedValueSetOfSeq()
472 distingAttrValue
= NULL
;
475 AttributeTypeAndDistinguishedValueSetOfSeq::AttributeTypeAndDistinguishedValueSetOfSeq (const AttributeTypeAndDistinguishedValueSetOfSeq
&)
477 Asn1Error
<< "use of incompletely defined AttributeTypeAndDistinguishedValueSetOfSeq::AttributeTypeAndDistinguishedValueSetOfSeq (const AttributeTypeAndDistinguishedValueSetOfSeq &)" << endl
;
481 AttributeTypeAndDistinguishedValueSetOfSeq::~AttributeTypeAndDistinguishedValueSetOfSeq()
483 delete distingAttrValue
;
486 AsnType
*AttributeTypeAndDistinguishedValueSetOfSeq::Clone() const
488 return new AttributeTypeAndDistinguishedValueSetOfSeq
;
491 AsnType
*AttributeTypeAndDistinguishedValueSetOfSeq::Copy() const
493 return new AttributeTypeAndDistinguishedValueSetOfSeq (*this);
497 AttributeTypeAndDistinguishedValueSetOfSeq
&AttributeTypeAndDistinguishedValueSetOfSeq::operator = (const AttributeTypeAndDistinguishedValueSetOfSeq
&that
)
498 #else // SNACC_DEEP_COPY
499 AttributeTypeAndDistinguishedValueSetOfSeq
&AttributeTypeAndDistinguishedValueSetOfSeq::operator = (const AttributeTypeAndDistinguishedValueSetOfSeq
&)
500 #endif // SNACC_DEEP_COPY
505 if (that
.distingAttrValue
)
507 if (!distingAttrValue
)
508 distingAttrValue
= new AsnOid
;
509 *distingAttrValue
= *that
.distingAttrValue
;
513 delete distingAttrValue
;
514 distingAttrValue
= NULL
;
516 contextList
= that
.contextList
;
520 #else // SNACC_DEEP_COPY
521 Asn1Error
<< "use of incompletely defined AttributeTypeAndDistinguishedValueSetOfSeq &AttributeTypeAndDistinguishedValueSetOfSeq::operator = (const AttributeTypeAndDistinguishedValueSetOfSeq &)" << endl
;
523 // if your compiler complains here, check the -novolat option
524 #endif // SNACC_DEEP_COPY
528 AttributeTypeAndDistinguishedValueSetOfSeq::BEncContent (BUF_TYPE b
)
534 l
= contextList
.BEncContent (b
);
535 l
+= BEncConsLen (b
, l
);
537 l
+= BEncTag1 (b
, UNIV
, CONS
, SET_TAG_CODE
);
540 if (NOT_NULL (distingAttrValue
))
542 l
= distingAttrValue
->BEncContent (b
);
543 l
+= BEncDefLen (b
, l
);
545 l
+= BEncTag1 (b
, UNIV
, PRIM
, OID_TAG_CODE
);
550 } // AttributeTypeAndDistinguishedValueSetOfSeq::BEncContent
553 void AttributeTypeAndDistinguishedValueSetOfSeq::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
556 AsnLen seqBytesDecoded
= 0;
558 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
560 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, OID_TAG_CODE
)))
562 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
563 distingAttrValue
= new AsnOid
;
564 distingAttrValue
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
565 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
568 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SET_TAG_CODE
)))
570 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
571 contextList
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
575 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
576 SnaccExcep::throwMe(-101);
579 bytesDecoded
+= seqBytesDecoded
;
580 if (elmtLen0
== INDEFINITE_LEN
)
582 BDecEoc (b
, bytesDecoded
, env
);
585 else if (seqBytesDecoded
!= elmtLen0
)
587 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
588 SnaccExcep::throwMe(-102);
592 } // AttributeTypeAndDistinguishedValueSetOfSeq::BDecContent
594 AsnLen
AttributeTypeAndDistinguishedValueSetOfSeq::BEnc (BUF_TYPE b
)
598 l
+= BEncConsLen (b
, l
);
599 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
603 void AttributeTypeAndDistinguishedValueSetOfSeq::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
608 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
610 Asn1Error
<< "AttributeTypeAndDistinguishedValueSetOfSeq::BDec: ERROR - wrong tag" << endl
;
611 SnaccExcep::throwMe(-103);
613 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
614 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
617 void AttributeTypeAndDistinguishedValueSetOfSeq::Print (ostream
&os
) const
620 os
<< "{ -- SEQUENCE --" << endl
;
621 indentG
+= stdIndentG
;
623 if (NOT_NULL (distingAttrValue
))
625 Indent (os
, indentG
);
626 os
<< "distingAttrValue ";
627 os
<< *distingAttrValue
;
631 Indent (os
, indentG
);
632 os
<< "distingAttrValue ";
638 Indent (os
, indentG
);
639 os
<< "contextList ";
644 indentG
-= stdIndentG
;
645 Indent (os
, indentG
);
648 } // AttributeTypeAndDistinguishedValueSetOfSeq::Print
651 AsnType
*AttributeTypeAndDistinguishedValueSetOf::Clone() const
653 return new AttributeTypeAndDistinguishedValueSetOf
;
656 AsnType
*AttributeTypeAndDistinguishedValueSetOf::Copy() const
658 return new AttributeTypeAndDistinguishedValueSetOf (*this);
661 AsnLen
AttributeTypeAndDistinguishedValueSetOf::BEnc (BUF_TYPE b
)
665 l
+= BEncConsLen (b
, l
);
666 l
+= BEncTag1 (b
, UNIV
, CONS
, SET_TAG_CODE
);
670 void AttributeTypeAndDistinguishedValueSetOf::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
675 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SET_TAG_CODE
))
677 Asn1Error
<< "AttributeTypeAndDistinguishedValueSetOf::BDec: ERROR - wrong tag" << endl
;
678 SnaccExcep::throwMe(-104);
680 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
681 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
684 AttributeTypeAndDistinguishedValueSetOf::AttributeTypeAndDistinguishedValueSetOf (const AttributeTypeAndDistinguishedValueSetOf
&)
686 Asn1Error
<< "use of incompletely defined AttributeTypeAndDistinguishedValueSetOf::AttributeTypeAndDistinguishedValueSetOf (const AttributeTypeAndDistinguishedValueSetOf &)" << endl
;
690 AttributeTypeAndDistinguishedValueSetOf::~AttributeTypeAndDistinguishedValueSetOf()
693 for (; Curr() != NULL
; RemoveCurrFromList())
695 } // end of destructor
698 AttributeTypeAndDistinguishedValueSetOf
&AttributeTypeAndDistinguishedValueSetOf::operator = (const AttributeTypeAndDistinguishedValueSetOf
&that
)
699 #else // SNACC_DEEP_COPY
700 AttributeTypeAndDistinguishedValueSetOf
&AttributeTypeAndDistinguishedValueSetOf::operator = (const AttributeTypeAndDistinguishedValueSetOf
&)
701 #endif // SNACC_DEEP_COPY
707 for (; Curr(); RemoveCurrFromList())
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
);
718 #else // SNACC_DEEP_COPY
719 Asn1Error
<< "use of incompletely defined AttributeTypeAndDistinguishedValueSetOf &AttributeTypeAndDistinguishedValueSetOf::operator = (const AttributeTypeAndDistinguishedValueSetOf &)" << endl
;
721 // if your compiler complains here, check the -novolat option
722 #endif // SNACC_DEEP_COPY
725 void AttributeTypeAndDistinguishedValueSetOf::Print (ostream
&os
) const
728 os
<< "{ -- SEQUENCE/SET OF -- " << endl
;
729 indentG
+= stdIndentG
;
731 //for (; Curr() != NULL; GoNext())
732 for (const AsnListElmt
*run
=first
; run
; run
=run
->next
)
734 Indent (os
, indentG
);
737 //if (Curr() != Last())
742 indentG
-= stdIndentG
;
743 Indent (os
, indentG
);
751 void AttributeTypeAndDistinguishedValueSetOf::SetCurrElmt (unsigned long int index
)
756 for (i
= 0; (i
< (count
-1)) && (i
< index
); i
++)
758 } // AttributeTypeAndDistinguishedValueSetOf::SetCurrElmt
761 unsigned long int AttributeTypeAndDistinguishedValueSetOf::GetCurrElmtIndex()
767 for (i
= 0, tmp
= first
; tmp
!= NULL
; i
++)
776 } // AttributeTypeAndDistinguishedValueSetOf::GetCurrElmtIndex
779 // alloc new list elmt, put at end of list
780 // and return the component type
781 AttributeTypeAndDistinguishedValueSetOfSeq
*AttributeTypeAndDistinguishedValueSetOf::Append()
783 AsnListElmt
*newElmt
;
784 newElmt
= new AsnListElmt
;
785 newElmt
->elmt
= new AttributeTypeAndDistinguishedValueSetOfSeq
;
786 newElmt
->next
= NULL
;
789 newElmt
->prev
= NULL
;
790 first
= last
= newElmt
;
794 newElmt
->prev
= last
;
795 last
->next
= newElmt
;
799 return (curr
= newElmt
)->elmt
;
800 } // AttributeTypeAndDistinguishedValueSetOf::Append
803 // alloc new list elmt, put at begining of list
804 // and return the component type
805 AttributeTypeAndDistinguishedValueSetOfSeq
*AttributeTypeAndDistinguishedValueSetOf::Prepend()
807 AsnListElmt
*newElmt
;
808 newElmt
= new AsnListElmt
;
809 newElmt
->elmt
= new AttributeTypeAndDistinguishedValueSetOfSeq
;
810 newElmt
->prev
= NULL
;
813 newElmt
->next
= NULL
;
814 first
= last
= newElmt
;
818 newElmt
->next
= first
;
819 first
->prev
= newElmt
;
823 return (curr
= newElmt
)->elmt
;
824 } // AttributeTypeAndDistinguishedValueSetOf::Prepend
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()
833 AsnListElmt
*newElmt
;
834 newElmt
= new AsnListElmt
;
835 newElmt
->elmt
= new AttributeTypeAndDistinguishedValueSetOfSeq
;
838 newElmt
->next
= first
;
839 newElmt
->prev
= NULL
;
846 newElmt
->next
= curr
;
847 newElmt
->prev
= curr
->prev
;
848 curr
->prev
= newElmt
;
852 newElmt
->prev
->next
= newElmt
;
855 return (curr
= newElmt
)->elmt
;
856 } // AttributeTypeAndDistinguishedValueSetOf::InsertBefore
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()
865 AsnListElmt
*newElmt
;
866 newElmt
= new AsnListElmt
;
867 newElmt
->elmt
= new AttributeTypeAndDistinguishedValueSetOfSeq
;
870 newElmt
->prev
= last
;
871 newElmt
->next
= NULL
;
878 newElmt
->prev
= curr
;
879 newElmt
->next
= curr
->next
;
880 curr
->next
= newElmt
;
884 newElmt
->next
->prev
= newElmt
;
887 return (curr
= newElmt
)->elmt
;
888 } // AttributeTypeAndDistinguishedValueSetOf::InsertAfter
891 AttributeTypeAndDistinguishedValueSetOf
&AttributeTypeAndDistinguishedValueSetOf::AppendCopy (AttributeTypeAndDistinguishedValueSetOfSeq
&elmt
)
893 AsnListElmt
*newElmt
;
894 newElmt
= new AsnListElmt
;
895 newElmt
->elmt
= new AttributeTypeAndDistinguishedValueSetOfSeq
;
896 *newElmt
->elmt
= elmt
;
897 newElmt
->next
= NULL
;
900 newElmt
->prev
= NULL
;
901 first
= last
= newElmt
;
905 newElmt
->prev
= last
;
906 last
->next
= newElmt
;
914 AttributeTypeAndDistinguishedValueSetOf
&AttributeTypeAndDistinguishedValueSetOf::PrependCopy (AttributeTypeAndDistinguishedValueSetOfSeq
&elmt
)
916 AsnListElmt
*newElmt
;
917 newElmt
= new AsnListElmt
;
918 newElmt
->elmt
= new AttributeTypeAndDistinguishedValueSetOfSeq
;
919 *newElmt
->elmt
= elmt
;
920 newElmt
->prev
= NULL
;
923 newElmt
->next
= NULL
;
924 first
= last
= newElmt
;
928 newElmt
->next
= first
;
929 first
->prev
= newElmt
;
934 } // AttributeTypeAndDistinguishedValueSetOf::PrependCopy
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
)
944 AsnListElmt
*newElmt
;
946 newElmt
= new AsnListElmt
;
947 newElmt
->elmt
= new AttributeTypeAndDistinguishedValueSetOfSeq
;
948 *newElmt
->elmt
= elmt
;
952 newElmt
->next
= first
;
953 newElmt
->prev
= NULL
;
960 newElmt
->next
= curr
;
961 newElmt
->prev
= curr
->prev
;
962 curr
->prev
= newElmt
;
966 newElmt
->prev
->next
= newElmt
;
970 } // AttributeTypeAndDistinguishedValueSetOf::InsertBeforeAndCopy
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
)
980 AsnListElmt
*newElmt
;
982 newElmt
= new AsnListElmt
;
983 newElmt
->elmt
= new AttributeTypeAndDistinguishedValueSetOfSeq
;
984 *newElmt
->elmt
= elmt
;
987 newElmt
->prev
= last
;
988 newElmt
->next
= NULL
;
995 newElmt
->prev
= curr
;
996 newElmt
->next
= curr
->next
;
997 curr
->next
= newElmt
;
1001 newElmt
->next
->prev
= newElmt
;
1005 } // AttributeTypeAndDistinguishedValueSetOf::InsertAfterAndCopy
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()
1014 AsnListElmt
*del_elmt
;
1022 first
= last
= curr
= NULL
;
1023 else if (curr
== first
)
1025 curr
= first
= first
->next
;
1028 else if (curr
== last
)
1030 curr
= last
= last
->prev
;
1035 curr
->prev
->next
= curr
->next
;
1036 curr
->next
->prev
= curr
->prev
;
1039 delete del_elmt
->elmt
;
1045 AsnLen
AttributeTypeAndDistinguishedValueSetOf::BEncContent (BUF_TYPE b
)
1047 AsnListElmt
*currElmt
;
1049 AsnLen totalLen
= 0;
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)
1058 ENCODE_BUF1(currElmt
->elmt
->BEncContent
, elmtLen
);
1059 elmtLen
+= BEncConsLen (outputBuf
, elmtLen
);
1061 elmtLen
+= BEncTag1 (outputBuf
, UNIV
, CONS
, SEQ_TAG_CODE
);
1062 ENCODE_BUF2(tmpEnc
[iii
]);
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
];
1070 totalLen
+= elmtLen
;
1072 } // AttributeTypeAndDistinguishedValueSetOf::BEncContent
1075 void AttributeTypeAndDistinguishedValueSetOf::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
,
1076 AsnLen
&bytesDecoded
, ENV_TYPE env
)
1078 AttributeTypeAndDistinguishedValueSetOfSeq
*listElmt
;
1080 AsnLen listBytesDecoded
= 0;
1083 while ((listBytesDecoded
< elmtLen0
) || (elmtLen0
== INDEFINITE_LEN
))
1085 tag1
= BDecTag (b
, listBytesDecoded
, env
);
1086 if ((tag1
== EOC_TAG_ID
) && (elmtLen0
== INDEFINITE_LEN
))
1088 BDEC_2ND_EOC_OCTET (b
, listBytesDecoded
, env
);
1091 if ((tag1
!= MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
1093 Asn1Error
<< "Unexpected Tag" << endl
;
1094 SnaccExcep::throwMe(-105);
1097 elmtLen1
= BDecLen (b
, listBytesDecoded
, env
);
1098 listElmt
= Append();
1099 listElmt
->BDecContent (b
, tag1
, elmtLen1
, listBytesDecoded
, env
);
1102 bytesDecoded
+= listBytesDecoded
;
1103 } // AttributeTypeAndDistinguishedValueSetOf::BDecContent
1106 AsnType
*AttributeSetOf::Clone() const
1108 return new AttributeSetOf
;
1111 AsnType
*AttributeSetOf::Copy() const
1113 return new AttributeSetOf (*this);
1116 AsnLen
AttributeSetOf::BEnc (BUF_TYPE b
)
1119 l
= BEncContent (b
);
1120 l
+= BEncConsLen (b
, l
);
1121 l
+= BEncTag1 (b
, UNIV
, CONS
, SET_TAG_CODE
);
1125 void AttributeSetOf::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
1130 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SET_TAG_CODE
))
1132 Asn1Error
<< "AttributeSetOf::BDec: ERROR - wrong tag" << endl
;
1133 SnaccExcep::throwMe(-106);
1135 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
1136 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
1139 AttributeSetOf::AttributeSetOf (const AttributeSetOf
&)
1141 Asn1Error
<< "use of incompletely defined AttributeSetOf::AttributeSetOf (const AttributeSetOf &)" << endl
;
1145 AttributeSetOf::~AttributeSetOf()
1148 for (; Curr() != NULL
; RemoveCurrFromList())
1150 } // end of destructor
1153 AttributeSetOf
&AttributeSetOf::operator = (const AttributeSetOf
&that
)
1154 #else // SNACC_DEEP_COPY
1155 AttributeSetOf
&AttributeSetOf::operator = (const AttributeSetOf
&)
1156 #endif // SNACC_DEEP_COPY
1162 for (; Curr(); RemoveCurrFromList())
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
);
1173 #else // SNACC_DEEP_COPY
1174 Asn1Error
<< "use of incompletely defined AttributeSetOf &AttributeSetOf::operator = (const AttributeSetOf &)" << endl
;
1176 // if your compiler complains here, check the -novolat option
1177 #endif // SNACC_DEEP_COPY
1180 void AttributeSetOf::Print (ostream
&os
) const
1183 os
<< "{ -- SEQUENCE/SET OF -- " << endl
;
1184 indentG
+= stdIndentG
;
1186 //for (; Curr() != NULL; GoNext())
1187 for (const AsnListElmt
*run
=first
; run
; run
=run
->next
)
1189 Indent (os
, indentG
);
1192 //if (Curr() != Last())
1197 indentG
-= stdIndentG
;
1198 Indent (os
, indentG
);
1206 void AttributeSetOf::SetCurrElmt (unsigned long int index
)
1208 unsigned long int i
;
1211 for (i
= 0; (i
< (count
-1)) && (i
< index
); i
++)
1213 } // AttributeSetOf::SetCurrElmt
1216 unsigned long int AttributeSetOf::GetCurrElmtIndex()
1218 unsigned long int i
;
1222 for (i
= 0, tmp
= first
; tmp
!= NULL
; i
++)
1231 } // AttributeSetOf::GetCurrElmtIndex
1234 // alloc new list elmt, put at end of list
1235 // and return the component type
1236 AttributeValue
*AttributeSetOf::Append()
1238 AsnListElmt
*newElmt
;
1239 newElmt
= new AsnListElmt
;
1240 newElmt
->elmt
= new AttributeValue
;
1241 newElmt
->next
= NULL
;
1244 newElmt
->prev
= NULL
;
1245 first
= last
= newElmt
;
1249 newElmt
->prev
= last
;
1250 last
->next
= newElmt
;
1254 return (curr
= newElmt
)->elmt
;
1255 } // AttributeSetOf::Append
1258 // alloc new list elmt, put at begining of list
1259 // and return the component type
1260 AttributeValue
*AttributeSetOf::Prepend()
1262 AsnListElmt
*newElmt
;
1263 newElmt
= new AsnListElmt
;
1264 newElmt
->elmt
= new AttributeValue
;
1265 newElmt
->prev
= NULL
;
1268 newElmt
->next
= NULL
;
1269 first
= last
= newElmt
;
1273 newElmt
->next
= first
;
1274 first
->prev
= newElmt
;
1278 return (curr
= newElmt
)->elmt
;
1279 } // AttributeSetOf::Prepend
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()
1288 AsnListElmt
*newElmt
;
1289 newElmt
= new AsnListElmt
;
1290 newElmt
->elmt
= new AttributeValue
;
1293 newElmt
->next
= first
;
1294 newElmt
->prev
= NULL
;
1301 newElmt
->next
= curr
;
1302 newElmt
->prev
= curr
->prev
;
1303 curr
->prev
= newElmt
;
1307 newElmt
->prev
->next
= newElmt
;
1310 return (curr
= newElmt
)->elmt
;
1311 } // AttributeSetOf::InsertBefore
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()
1320 AsnListElmt
*newElmt
;
1321 newElmt
= new AsnListElmt
;
1322 newElmt
->elmt
= new AttributeValue
;
1325 newElmt
->prev
= last
;
1326 newElmt
->next
= NULL
;
1333 newElmt
->prev
= curr
;
1334 newElmt
->next
= curr
->next
;
1335 curr
->next
= newElmt
;
1339 newElmt
->next
->prev
= newElmt
;
1342 return (curr
= newElmt
)->elmt
;
1343 } // AttributeSetOf::InsertAfter
1346 AttributeSetOf
&AttributeSetOf::AppendCopy (AttributeValue
&elmt
)
1348 AsnListElmt
*newElmt
;
1349 newElmt
= new AsnListElmt
;
1350 newElmt
->elmt
= new AttributeValue
;
1351 *newElmt
->elmt
= elmt
;
1352 newElmt
->next
= NULL
;
1355 newElmt
->prev
= NULL
;
1356 first
= last
= newElmt
;
1360 newElmt
->prev
= last
;
1361 last
->next
= newElmt
;
1369 AttributeSetOf
&AttributeSetOf::PrependCopy (AttributeValue
&elmt
)
1371 AsnListElmt
*newElmt
;
1372 newElmt
= new AsnListElmt
;
1373 newElmt
->elmt
= new AttributeValue
;
1374 *newElmt
->elmt
= elmt
;
1375 newElmt
->prev
= NULL
;
1378 newElmt
->next
= NULL
;
1379 first
= last
= newElmt
;
1383 newElmt
->next
= first
;
1384 first
->prev
= newElmt
;
1389 } // AttributeSetOf::PrependCopy
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
)
1399 AsnListElmt
*newElmt
;
1401 newElmt
= new AsnListElmt
;
1402 newElmt
->elmt
= new AttributeValue
;
1403 *newElmt
->elmt
= elmt
;
1407 newElmt
->next
= first
;
1408 newElmt
->prev
= NULL
;
1415 newElmt
->next
= curr
;
1416 newElmt
->prev
= curr
->prev
;
1417 curr
->prev
= newElmt
;
1421 newElmt
->prev
->next
= newElmt
;
1425 } // AttributeSetOf::InsertBeforeAndCopy
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
)
1435 AsnListElmt
*newElmt
;
1437 newElmt
= new AsnListElmt
;
1438 newElmt
->elmt
= new AttributeValue
;
1439 *newElmt
->elmt
= elmt
;
1442 newElmt
->prev
= last
;
1443 newElmt
->next
= NULL
;
1450 newElmt
->prev
= curr
;
1451 newElmt
->next
= curr
->next
;
1452 curr
->next
= newElmt
;
1456 newElmt
->next
->prev
= newElmt
;
1460 } // AttributeSetOf::InsertAfterAndCopy
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()
1469 AsnListElmt
*del_elmt
;
1477 first
= last
= curr
= NULL
;
1478 else if (curr
== first
)
1480 curr
= first
= first
->next
;
1483 else if (curr
== last
)
1485 curr
= last
= last
->prev
;
1490 curr
->prev
->next
= curr
->next
;
1491 curr
->next
->prev
= curr
->prev
;
1494 delete del_elmt
->elmt
;
1500 AsnLen
AttributeSetOf::BEncContent (BUF_TYPE b
)
1502 AsnListElmt
*currElmt
;
1504 AsnLen totalLen
= 0;
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)
1512 tmpEnc
[iii
] = (CSM_Buffer
*)currElmt
->elmt
->value
;
1514 vdasnacc_sortSetOf(tmpEnc
, icount
);
1515 for (iii
=0,elmtLen
=0; iii
< icount
; elmtLen
+=tmpEnc
[iii
++]->Length())
1516 SM_WriteToAsnBuf(tmpEnc
[iii
], b
);
1519 totalLen
+= elmtLen
;
1521 } // AttributeSetOf::BEncContent
1524 void AttributeSetOf::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
,
1525 AsnLen
&bytesDecoded
, ENV_TYPE env
)
1527 AttributeValue
*listElmt
;
1528 AsnLen listBytesDecoded
= 0;
1530 while ((listBytesDecoded
< elmtLen0
) || (elmtLen0
== INDEFINITE_LEN
))
1532 listElmt
= Append();
1533 DEC_LOAD_ANYBUF(listElmt
, b
, listBytesDecoded
, env
);
1536 bytesDecoded
+= listBytesDecoded
;
1537 } // AttributeSetOf::BDecContent
1540 Attribute::Attribute()
1544 Attribute::Attribute (const Attribute
&)
1546 Asn1Error
<< "use of incompletely defined Attribute::Attribute (const Attribute &)" << endl
;
1550 Attribute::~Attribute()
1554 AsnType
*Attribute::Clone() const
1556 return new Attribute
;
1559 AsnType
*Attribute::Copy() const
1561 return new Attribute (*this);
1565 Attribute
&Attribute::operator = (const Attribute
&that
)
1566 #else // SNACC_DEEP_COPY
1567 Attribute
&Attribute::operator = (const Attribute
&)
1568 #endif // SNACC_DEEP_COPY
1574 values
= that
.values
;
1578 #else // SNACC_DEEP_COPY
1579 Asn1Error
<< "use of incompletely defined Attribute &Attribute::operator = (const Attribute &)" << endl
;
1581 // if your compiler complains here, check the -novolat option
1582 #endif // SNACC_DEEP_COPY
1586 Attribute::BEncContent (BUF_TYPE b
)
1588 AsnLen totalLen
= 0;
1592 l
= values
.BEncContent (b
);
1593 l
+= BEncConsLen (b
, l
);
1595 l
+= BEncTag1 (b
, UNIV
, CONS
, SET_TAG_CODE
);
1598 l
= type
.BEncContent (b
);
1599 l
+= BEncDefLen (b
, l
);
1601 l
+= BEncTag1 (b
, UNIV
, PRIM
, OID_TAG_CODE
);
1605 } // Attribute::BEncContent
1608 void Attribute::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
1611 AsnLen seqBytesDecoded
= 0;
1613 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
1615 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, OID_TAG_CODE
)))
1617 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
1618 type
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
1619 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
1623 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
1624 SnaccExcep::throwMe(-107);
1627 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SET_TAG_CODE
)))
1629 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
1630 values
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
1634 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
1635 SnaccExcep::throwMe(-108);
1638 bytesDecoded
+= seqBytesDecoded
;
1639 if (elmtLen0
== INDEFINITE_LEN
)
1641 BDecEoc (b
, bytesDecoded
, env
);
1644 else if (seqBytesDecoded
!= elmtLen0
)
1646 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
1647 SnaccExcep::throwMe(-109);
1651 } // Attribute::BDecContent
1653 AsnLen
Attribute::BEnc (BUF_TYPE b
)
1656 l
= BEncContent (b
);
1657 l
+= BEncConsLen (b
, l
);
1658 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
1662 void Attribute::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
1667 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
1669 Asn1Error
<< "Attribute::BDec: ERROR - wrong tag" << endl
;
1670 SnaccExcep::throwMe(-110);
1672 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
1673 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
1676 void Attribute::Print (ostream
&os
) const
1679 os
<< "{ -- SEQUENCE --" << endl
;
1680 indentG
+= stdIndentG
;
1683 Indent (os
, indentG
);
1690 Indent (os
, indentG
);
1696 indentG
-= stdIndentG
;
1697 Indent (os
, indentG
);
1700 } // Attribute::Print
1703 AttributeTypeAndDistinguishedValue::AttributeTypeAndDistinguishedValue()
1705 primaryDistinguished
= NULL
;
1706 valuesWithContext
= NULL
;
1709 AttributeTypeAndDistinguishedValue::AttributeTypeAndDistinguishedValue (const AttributeTypeAndDistinguishedValue
&)
1711 Asn1Error
<< "use of incompletely defined AttributeTypeAndDistinguishedValue::AttributeTypeAndDistinguishedValue (const AttributeTypeAndDistinguishedValue &)" << endl
;
1715 AttributeTypeAndDistinguishedValue::~AttributeTypeAndDistinguishedValue()
1717 delete primaryDistinguished
;
1718 delete valuesWithContext
;
1721 AsnType
*AttributeTypeAndDistinguishedValue::Clone() const
1723 return new AttributeTypeAndDistinguishedValue
;
1726 AsnType
*AttributeTypeAndDistinguishedValue::Copy() const
1728 return new AttributeTypeAndDistinguishedValue (*this);
1732 AttributeTypeAndDistinguishedValue
&AttributeTypeAndDistinguishedValue::operator = (const AttributeTypeAndDistinguishedValue
&that
)
1733 #else // SNACC_DEEP_COPY
1734 AttributeTypeAndDistinguishedValue
&AttributeTypeAndDistinguishedValue::operator = (const AttributeTypeAndDistinguishedValue
&)
1735 #endif // SNACC_DEEP_COPY
1742 if (that
.primaryDistinguished
)
1744 if (!primaryDistinguished
)
1745 primaryDistinguished
= new AsnBool
;
1746 *primaryDistinguished
= *that
.primaryDistinguished
;
1750 delete primaryDistinguished
;
1751 primaryDistinguished
= NULL
;
1753 if (that
.valuesWithContext
)
1755 if (!valuesWithContext
)
1756 valuesWithContext
= new AttributeTypeAndDistinguishedValueSetOf
;
1757 *valuesWithContext
= *that
.valuesWithContext
;
1761 delete valuesWithContext
;
1762 valuesWithContext
= NULL
;
1767 #else // SNACC_DEEP_COPY
1768 Asn1Error
<< "use of incompletely defined AttributeTypeAndDistinguishedValue &AttributeTypeAndDistinguishedValue::operator = (const AttributeTypeAndDistinguishedValue &)" << endl
;
1770 // if your compiler complains here, check the -novolat option
1771 #endif // SNACC_DEEP_COPY
1775 AttributeTypeAndDistinguishedValue::BEncContent (BUF_TYPE b
)
1777 AsnLen totalLen
= 0;
1780 if (NOT_NULL (valuesWithContext
))
1783 l
= valuesWithContext
->BEncContent (b
);
1784 l
+= BEncConsLen (b
, l
);
1786 l
+= BEncTag1 (b
, UNIV
, CONS
, SET_TAG_CODE
);
1790 if (NOT_NULL (primaryDistinguished
))
1792 l
= primaryDistinguished
->BEncContent (b
);
1793 BEncDefLenTo127 (b
, l
);
1796 l
+= BEncTag1 (b
, UNIV
, PRIM
, BOOLEAN_TAG_CODE
);
1800 ENC_LOAD_ANYBUF(&value
, b
, l
);
1803 l
= type
.BEncContent (b
);
1804 l
+= BEncDefLen (b
, l
);
1806 l
+= BEncTag1 (b
, UNIV
, PRIM
, OID_TAG_CODE
);
1810 } // AttributeTypeAndDistinguishedValue::BEncContent
1813 void AttributeTypeAndDistinguishedValue::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
1816 AsnLen seqBytesDecoded
= 0;
1818 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
1820 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, OID_TAG_CODE
)))
1822 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
1823 type
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
1827 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
1828 SnaccExcep::throwMe(-111);
1832 DEC_LOAD_ANYBUF(&value
, b
, seqBytesDecoded
, env
);
1833 if (seqBytesDecoded
== elmtLen0
)
1835 bytesDecoded
+= seqBytesDecoded
;
1840 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
1842 if ((elmtLen0
== INDEFINITE_LEN
) && (tag1
== EOC_TAG_ID
))
1844 BDEC_2ND_EOC_OCTET (b
, seqBytesDecoded
, env
)
1845 bytesDecoded
+= seqBytesDecoded
;
1851 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, BOOLEAN_TAG_CODE
)))
1853 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
1854 primaryDistinguished
= new AsnBool
;
1855 primaryDistinguished
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
1856 if (seqBytesDecoded
== elmtLen0
)
1858 bytesDecoded
+= seqBytesDecoded
;
1863 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
1865 if ((elmtLen0
== INDEFINITE_LEN
) && (tag1
== EOC_TAG_ID
))
1867 BDEC_2ND_EOC_OCTET (b
, seqBytesDecoded
, env
)
1868 bytesDecoded
+= seqBytesDecoded
;
1874 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SET_TAG_CODE
)))
1876 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
1877 valuesWithContext
= new AttributeTypeAndDistinguishedValueSetOf
;
1878 valuesWithContext
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
1881 bytesDecoded
+= seqBytesDecoded
;
1882 if (elmtLen0
== INDEFINITE_LEN
)
1884 BDecEoc (b
, bytesDecoded
, env
);
1887 else if (seqBytesDecoded
!= elmtLen0
)
1889 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
1890 SnaccExcep::throwMe(-112);
1894 } // AttributeTypeAndDistinguishedValue::BDecContent
1896 AsnLen
AttributeTypeAndDistinguishedValue::BEnc (BUF_TYPE b
)
1899 l
= BEncContent (b
);
1900 l
+= BEncConsLen (b
, l
);
1901 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
1905 void AttributeTypeAndDistinguishedValue::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
1910 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
1912 Asn1Error
<< "AttributeTypeAndDistinguishedValue::BDec: ERROR - wrong tag" << endl
;
1913 SnaccExcep::throwMe(-113);
1915 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
1916 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
1919 void AttributeTypeAndDistinguishedValue::Print (ostream
&os
) const
1922 os
<< "{ -- SEQUENCE --" << endl
;
1923 indentG
+= stdIndentG
;
1926 Indent (os
, indentG
);
1933 Indent (os
, indentG
);
1939 if (NOT_NULL (primaryDistinguished
))
1942 Indent (os
, indentG
);
1943 os
<< "primaryDistinguished ";
1944 os
<< *primaryDistinguished
;
1948 Indent (os
, indentG
);
1949 os
<< "primaryDistinguished ";
1954 if (NOT_NULL (valuesWithContext
))
1957 Indent (os
, indentG
);
1958 os
<< "valuesWithContext ";
1959 os
<< *valuesWithContext
;
1963 Indent (os
, indentG
);
1964 os
<< "valuesWithContext ";
1970 indentG
-= stdIndentG
;
1971 Indent (os
, indentG
);
1974 } // AttributeTypeAndDistinguishedValue::Print
1977 AsnType
*RelativeDistinguishedName::Clone() const
1979 return new RelativeDistinguishedName
;
1982 AsnType
*RelativeDistinguishedName::Copy() const
1984 return new RelativeDistinguishedName (*this);
1987 AsnLen
RelativeDistinguishedName::BEnc (BUF_TYPE b
)
1990 l
= BEncContent (b
);
1991 l
+= BEncConsLen (b
, l
);
1992 l
+= BEncTag1 (b
, UNIV
, CONS
, SET_TAG_CODE
);
1996 void RelativeDistinguishedName::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
2001 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SET_TAG_CODE
))
2003 Asn1Error
<< "RelativeDistinguishedName::BDec: ERROR - wrong tag" << endl
;
2004 SnaccExcep::throwMe(-114);
2006 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
2007 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
2010 RelativeDistinguishedName::RelativeDistinguishedName (const RelativeDistinguishedName
&)
2012 Asn1Error
<< "use of incompletely defined RelativeDistinguishedName::RelativeDistinguishedName (const RelativeDistinguishedName &)" << endl
;
2016 RelativeDistinguishedName::~RelativeDistinguishedName()
2019 for (; Curr() != NULL
; RemoveCurrFromList())
2021 } // end of destructor
2024 RelativeDistinguishedName
&RelativeDistinguishedName::operator = (const RelativeDistinguishedName
&that
)
2025 #else // SNACC_DEEP_COPY
2026 RelativeDistinguishedName
&RelativeDistinguishedName::operator = (const RelativeDistinguishedName
&)
2027 #endif // SNACC_DEEP_COPY
2033 for (; Curr(); RemoveCurrFromList())
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
);
2044 #else // SNACC_DEEP_COPY
2045 Asn1Error
<< "use of incompletely defined RelativeDistinguishedName &RelativeDistinguishedName::operator = (const RelativeDistinguishedName &)" << endl
;
2047 // if your compiler complains here, check the -novolat option
2048 #endif // SNACC_DEEP_COPY
2051 void RelativeDistinguishedName::Print (ostream
&os
) const
2054 os
<< "{ -- SEQUENCE/SET OF -- " << endl
;
2055 indentG
+= stdIndentG
;
2057 //for (; Curr() != NULL; GoNext())
2058 for (const AsnListElmt
*run
=first
; run
; run
=run
->next
)
2060 Indent (os
, indentG
);
2063 //if (Curr() != Last())
2068 indentG
-= stdIndentG
;
2069 Indent (os
, indentG
);
2077 void RelativeDistinguishedName::SetCurrElmt (unsigned long int index
)
2079 unsigned long int i
;
2082 for (i
= 0; (i
< (count
-1)) && (i
< index
); i
++)
2084 } // RelativeDistinguishedName::SetCurrElmt
2087 unsigned long int RelativeDistinguishedName::GetCurrElmtIndex()
2089 unsigned long int i
;
2093 for (i
= 0, tmp
= first
; tmp
!= NULL
; i
++)
2102 } // RelativeDistinguishedName::GetCurrElmtIndex
2105 // alloc new list elmt, put at end of list
2106 // and return the component type
2107 AttributeTypeAndDistinguishedValue
*RelativeDistinguishedName::Append()
2109 AsnListElmt
*newElmt
;
2110 newElmt
= new AsnListElmt
;
2111 newElmt
->elmt
= new AttributeTypeAndDistinguishedValue
;
2112 newElmt
->next
= NULL
;
2115 newElmt
->prev
= NULL
;
2116 first
= last
= newElmt
;
2120 newElmt
->prev
= last
;
2121 last
->next
= newElmt
;
2125 return (curr
= newElmt
)->elmt
;
2126 } // RelativeDistinguishedName::Append
2129 // alloc new list elmt, put at begining of list
2130 // and return the component type
2131 AttributeTypeAndDistinguishedValue
*RelativeDistinguishedName::Prepend()
2133 AsnListElmt
*newElmt
;
2134 newElmt
= new AsnListElmt
;
2135 newElmt
->elmt
= new AttributeTypeAndDistinguishedValue
;
2136 newElmt
->prev
= NULL
;
2139 newElmt
->next
= NULL
;
2140 first
= last
= newElmt
;
2144 newElmt
->next
= first
;
2145 first
->prev
= newElmt
;
2149 return (curr
= newElmt
)->elmt
;
2150 } // RelativeDistinguishedName::Prepend
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()
2159 AsnListElmt
*newElmt
;
2160 newElmt
= new AsnListElmt
;
2161 newElmt
->elmt
= new AttributeTypeAndDistinguishedValue
;
2164 newElmt
->next
= first
;
2165 newElmt
->prev
= NULL
;
2172 newElmt
->next
= curr
;
2173 newElmt
->prev
= curr
->prev
;
2174 curr
->prev
= newElmt
;
2178 newElmt
->prev
->next
= newElmt
;
2181 return (curr
= newElmt
)->elmt
;
2182 } // RelativeDistinguishedName::InsertBefore
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()
2191 AsnListElmt
*newElmt
;
2192 newElmt
= new AsnListElmt
;
2193 newElmt
->elmt
= new AttributeTypeAndDistinguishedValue
;
2196 newElmt
->prev
= last
;
2197 newElmt
->next
= NULL
;
2204 newElmt
->prev
= curr
;
2205 newElmt
->next
= curr
->next
;
2206 curr
->next
= newElmt
;
2210 newElmt
->next
->prev
= newElmt
;
2213 return (curr
= newElmt
)->elmt
;
2214 } // RelativeDistinguishedName::InsertAfter
2217 RelativeDistinguishedName
&RelativeDistinguishedName::AppendCopy (AttributeTypeAndDistinguishedValue
&elmt
)
2219 AsnListElmt
*newElmt
;
2220 newElmt
= new AsnListElmt
;
2221 newElmt
->elmt
= new AttributeTypeAndDistinguishedValue
;
2222 *newElmt
->elmt
= elmt
;
2223 newElmt
->next
= NULL
;
2226 newElmt
->prev
= NULL
;
2227 first
= last
= newElmt
;
2231 newElmt
->prev
= last
;
2232 last
->next
= newElmt
;
2240 RelativeDistinguishedName
&RelativeDistinguishedName::PrependCopy (AttributeTypeAndDistinguishedValue
&elmt
)
2242 AsnListElmt
*newElmt
;
2243 newElmt
= new AsnListElmt
;
2244 newElmt
->elmt
= new AttributeTypeAndDistinguishedValue
;
2245 *newElmt
->elmt
= elmt
;
2246 newElmt
->prev
= NULL
;
2249 newElmt
->next
= NULL
;
2250 first
= last
= newElmt
;
2254 newElmt
->next
= first
;
2255 first
->prev
= newElmt
;
2260 } // RelativeDistinguishedName::PrependCopy
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
)
2270 AsnListElmt
*newElmt
;
2272 newElmt
= new AsnListElmt
;
2273 newElmt
->elmt
= new AttributeTypeAndDistinguishedValue
;
2274 *newElmt
->elmt
= elmt
;
2278 newElmt
->next
= first
;
2279 newElmt
->prev
= NULL
;
2286 newElmt
->next
= curr
;
2287 newElmt
->prev
= curr
->prev
;
2288 curr
->prev
= newElmt
;
2292 newElmt
->prev
->next
= newElmt
;
2296 } // RelativeDistinguishedName::InsertBeforeAndCopy
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
)
2306 AsnListElmt
*newElmt
;
2308 newElmt
= new AsnListElmt
;
2309 newElmt
->elmt
= new AttributeTypeAndDistinguishedValue
;
2310 *newElmt
->elmt
= elmt
;
2313 newElmt
->prev
= last
;
2314 newElmt
->next
= NULL
;
2321 newElmt
->prev
= curr
;
2322 newElmt
->next
= curr
->next
;
2323 curr
->next
= newElmt
;
2327 newElmt
->next
->prev
= newElmt
;
2331 } // RelativeDistinguishedName::InsertAfterAndCopy
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()
2340 AsnListElmt
*del_elmt
;
2348 first
= last
= curr
= NULL
;
2349 else if (curr
== first
)
2351 curr
= first
= first
->next
;
2354 else if (curr
== last
)
2356 curr
= last
= last
->prev
;
2361 curr
->prev
->next
= curr
->next
;
2362 curr
->next
->prev
= curr
->prev
;
2365 delete del_elmt
->elmt
;
2371 AsnLen
RelativeDistinguishedName::BEncContent (BUF_TYPE b
)
2373 AsnListElmt
*currElmt
;
2375 AsnLen totalLen
= 0;
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)
2384 ENCODE_BUF1(currElmt
->elmt
->BEncContent
, elmtLen
);
2385 elmtLen
+= BEncConsLen (outputBuf
, elmtLen
);
2387 elmtLen
+= BEncTag1 (outputBuf
, UNIV
, CONS
, SEQ_TAG_CODE
);
2388 ENCODE_BUF2(tmpEnc
[iii
]);
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
];
2396 totalLen
+= elmtLen
;
2398 } // RelativeDistinguishedName::BEncContent
2401 void RelativeDistinguishedName::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
,
2402 AsnLen
&bytesDecoded
, ENV_TYPE env
)
2404 AttributeTypeAndDistinguishedValue
*listElmt
;
2406 AsnLen listBytesDecoded
= 0;
2409 while ((listBytesDecoded
< elmtLen0
) || (elmtLen0
== INDEFINITE_LEN
))
2411 tag1
= BDecTag (b
, listBytesDecoded
, env
);
2412 if ((tag1
== EOC_TAG_ID
) && (elmtLen0
== INDEFINITE_LEN
))
2414 BDEC_2ND_EOC_OCTET (b
, listBytesDecoded
, env
);
2417 if ((tag1
!= MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
2419 Asn1Error
<< "Unexpected Tag" << endl
;
2420 SnaccExcep::throwMe(-115);
2423 elmtLen1
= BDecLen (b
, listBytesDecoded
, env
);
2424 listElmt
= Append();
2425 listElmt
->BDecContent (b
, tag1
, elmtLen1
, listBytesDecoded
, env
);
2428 bytesDecoded
+= listBytesDecoded
;
2429 } // RelativeDistinguishedName::BDecContent
2432 AsnType
*RDNSequence::Clone() const
2434 return new RDNSequence
;
2437 AsnType
*RDNSequence::Copy() const
2439 return new RDNSequence (*this);
2442 AsnLen
RDNSequence::BEnc (BUF_TYPE b
)
2445 l
= BEncContent (b
);
2446 l
+= BEncConsLen (b
, l
);
2447 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
2451 void RDNSequence::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
2456 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
2458 Asn1Error
<< "RDNSequence::BDec: ERROR - wrong tag" << endl
;
2459 SnaccExcep::throwMe(-116);
2461 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
2462 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
2465 RDNSequence::RDNSequence (const RDNSequence
&)
2467 Asn1Error
<< "use of incompletely defined RDNSequence::RDNSequence (const RDNSequence &)" << endl
;
2471 RDNSequence::~RDNSequence()
2474 for (; Curr() != NULL
; RemoveCurrFromList())
2476 } // end of destructor
2479 RDNSequence
&RDNSequence::operator = (const RDNSequence
&that
)
2480 #else // SNACC_DEEP_COPY
2481 RDNSequence
&RDNSequence::operator = (const RDNSequence
&)
2482 #endif // SNACC_DEEP_COPY
2488 for (; Curr(); RemoveCurrFromList())
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
);
2499 #else // SNACC_DEEP_COPY
2500 Asn1Error
<< "use of incompletely defined RDNSequence &RDNSequence::operator = (const RDNSequence &)" << endl
;
2502 // if your compiler complains here, check the -novolat option
2503 #endif // SNACC_DEEP_COPY
2506 void RDNSequence::Print (ostream
&os
) const
2509 os
<< "{ -- SEQUENCE/SET OF -- " << endl
;
2510 indentG
+= stdIndentG
;
2512 //for (; Curr() != NULL; GoNext())
2513 for (const AsnListElmt
*run
=first
; run
; run
=run
->next
)
2515 Indent (os
, indentG
);
2518 //if (Curr() != Last())
2523 indentG
-= stdIndentG
;
2524 Indent (os
, indentG
);
2532 void RDNSequence::SetCurrElmt (unsigned long int index
)
2534 unsigned long int i
;
2537 for (i
= 0; (i
< (count
-1)) && (i
< index
); i
++)
2539 } // RDNSequence::SetCurrElmt
2542 unsigned long int RDNSequence::GetCurrElmtIndex()
2544 unsigned long int i
;
2548 for (i
= 0, tmp
= first
; tmp
!= NULL
; i
++)
2557 } // RDNSequence::GetCurrElmtIndex
2560 // alloc new list elmt, put at end of list
2561 // and return the component type
2562 RelativeDistinguishedName
*RDNSequence::Append()
2564 AsnListElmt
*newElmt
;
2565 newElmt
= new AsnListElmt
;
2566 newElmt
->elmt
= new RelativeDistinguishedName
;
2567 newElmt
->next
= NULL
;
2570 newElmt
->prev
= NULL
;
2571 first
= last
= newElmt
;
2575 newElmt
->prev
= last
;
2576 last
->next
= newElmt
;
2580 return (curr
= newElmt
)->elmt
;
2581 } // RDNSequence::Append
2584 // alloc new list elmt, put at begining of list
2585 // and return the component type
2586 RelativeDistinguishedName
*RDNSequence::Prepend()
2588 AsnListElmt
*newElmt
;
2589 newElmt
= new AsnListElmt
;
2590 newElmt
->elmt
= new RelativeDistinguishedName
;
2591 newElmt
->prev
= NULL
;
2594 newElmt
->next
= NULL
;
2595 first
= last
= newElmt
;
2599 newElmt
->next
= first
;
2600 first
->prev
= newElmt
;
2604 return (curr
= newElmt
)->elmt
;
2605 } // RDNSequence::Prepend
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()
2614 AsnListElmt
*newElmt
;
2615 newElmt
= new AsnListElmt
;
2616 newElmt
->elmt
= new RelativeDistinguishedName
;
2619 newElmt
->next
= first
;
2620 newElmt
->prev
= NULL
;
2627 newElmt
->next
= curr
;
2628 newElmt
->prev
= curr
->prev
;
2629 curr
->prev
= newElmt
;
2633 newElmt
->prev
->next
= newElmt
;
2636 return (curr
= newElmt
)->elmt
;
2637 } // RDNSequence::InsertBefore
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()
2646 AsnListElmt
*newElmt
;
2647 newElmt
= new AsnListElmt
;
2648 newElmt
->elmt
= new RelativeDistinguishedName
;
2651 newElmt
->prev
= last
;
2652 newElmt
->next
= NULL
;
2659 newElmt
->prev
= curr
;
2660 newElmt
->next
= curr
->next
;
2661 curr
->next
= newElmt
;
2665 newElmt
->next
->prev
= newElmt
;
2668 return (curr
= newElmt
)->elmt
;
2669 } // RDNSequence::InsertAfter
2672 RDNSequence
&RDNSequence::AppendCopy (RelativeDistinguishedName
&elmt
)
2674 AsnListElmt
*newElmt
;
2675 newElmt
= new AsnListElmt
;
2676 newElmt
->elmt
= new RelativeDistinguishedName
;
2677 *newElmt
->elmt
= elmt
;
2678 newElmt
->next
= NULL
;
2681 newElmt
->prev
= NULL
;
2682 first
= last
= newElmt
;
2686 newElmt
->prev
= last
;
2687 last
->next
= newElmt
;
2695 RDNSequence
&RDNSequence::PrependCopy (RelativeDistinguishedName
&elmt
)
2697 AsnListElmt
*newElmt
;
2698 newElmt
= new AsnListElmt
;
2699 newElmt
->elmt
= new RelativeDistinguishedName
;
2700 *newElmt
->elmt
= elmt
;
2701 newElmt
->prev
= NULL
;
2704 newElmt
->next
= NULL
;
2705 first
= last
= newElmt
;
2709 newElmt
->next
= first
;
2710 first
->prev
= newElmt
;
2715 } // RDNSequence::PrependCopy
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
)
2725 AsnListElmt
*newElmt
;
2727 newElmt
= new AsnListElmt
;
2728 newElmt
->elmt
= new RelativeDistinguishedName
;
2729 *newElmt
->elmt
= elmt
;
2733 newElmt
->next
= first
;
2734 newElmt
->prev
= NULL
;
2741 newElmt
->next
= curr
;
2742 newElmt
->prev
= curr
->prev
;
2743 curr
->prev
= newElmt
;
2747 newElmt
->prev
->next
= newElmt
;
2751 } // RDNSequence::InsertBeforeAndCopy
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
)
2761 AsnListElmt
*newElmt
;
2763 newElmt
= new AsnListElmt
;
2764 newElmt
->elmt
= new RelativeDistinguishedName
;
2765 *newElmt
->elmt
= elmt
;
2768 newElmt
->prev
= last
;
2769 newElmt
->next
= NULL
;
2776 newElmt
->prev
= curr
;
2777 newElmt
->next
= curr
->next
;
2778 curr
->next
= newElmt
;
2782 newElmt
->next
->prev
= newElmt
;
2786 } // RDNSequence::InsertAfterAndCopy
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()
2795 AsnListElmt
*del_elmt
;
2803 first
= last
= curr
= NULL
;
2804 else if (curr
== first
)
2806 curr
= first
= first
->next
;
2809 else if (curr
== last
)
2811 curr
= last
= last
->prev
;
2816 curr
->prev
->next
= curr
->next
;
2817 curr
->next
->prev
= curr
->prev
;
2820 delete del_elmt
->elmt
;
2826 AsnLen
RDNSequence::BEncContent (BUF_TYPE b
)
2828 AsnListElmt
*currElmt
;
2830 AsnLen totalLen
= 0;
2831 for (currElmt
= last
; currElmt
!= NULL
; currElmt
= currElmt
->prev
)
2834 elmtLen
= currElmt
->elmt
->BEncContent (b
);
2835 elmtLen
+= BEncConsLen (b
, elmtLen
);
2837 elmtLen
+= BEncTag1 (b
, UNIV
, CONS
, SET_TAG_CODE
);
2838 totalLen
+= elmtLen
;
2841 } // RDNSequence::BEncContent
2844 void RDNSequence::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
,
2845 AsnLen
&bytesDecoded
, ENV_TYPE env
)
2847 RelativeDistinguishedName
*listElmt
;
2849 AsnLen listBytesDecoded
= 0;
2852 while ((listBytesDecoded
< elmtLen0
) || (elmtLen0
== INDEFINITE_LEN
))
2854 tag1
= BDecTag (b
, listBytesDecoded
, env
);
2855 if ((tag1
== EOC_TAG_ID
) && (elmtLen0
== INDEFINITE_LEN
))
2857 BDEC_2ND_EOC_OCTET (b
, listBytesDecoded
, env
);
2860 if ((tag1
!= MAKE_TAG_ID (UNIV
, CONS
, SET_TAG_CODE
)))
2862 Asn1Error
<< "Unexpected Tag" << endl
;
2863 SnaccExcep::throwMe(-117);
2866 elmtLen1
= BDecLen (b
, listBytesDecoded
, env
);
2867 listElmt
= Append();
2868 listElmt
->BDecContent (b
, tag1
, elmtLen1
, listBytesDecoded
, env
);
2871 bytesDecoded
+= listBytesDecoded
;
2872 } // RDNSequence::BDecContent
2875 AsnType
*Attributes::Clone() const
2877 return new Attributes
;
2880 AsnType
*Attributes::Copy() const
2882 return new Attributes (*this);
2885 AsnLen
Attributes::BEnc (BUF_TYPE b
)
2888 l
= BEncContent (b
);
2889 l
+= BEncConsLen (b
, l
);
2890 l
+= BEncTag1 (b
, UNIV
, CONS
, SET_TAG_CODE
);
2894 void Attributes::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
2899 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SET_TAG_CODE
))
2901 Asn1Error
<< "Attributes::BDec: ERROR - wrong tag" << endl
;
2902 SnaccExcep::throwMe(-118);
2904 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
2905 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
2908 Attributes::Attributes (const Attributes
&)
2910 Asn1Error
<< "use of incompletely defined Attributes::Attributes (const Attributes &)" << endl
;
2914 Attributes::~Attributes()
2917 for (; Curr() != NULL
; RemoveCurrFromList())
2919 } // end of destructor
2922 Attributes
&Attributes::operator = (const Attributes
&that
)
2923 #else // SNACC_DEEP_COPY
2924 Attributes
&Attributes::operator = (const Attributes
&)
2925 #endif // SNACC_DEEP_COPY
2931 for (; Curr(); RemoveCurrFromList())
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
);
2942 #else // SNACC_DEEP_COPY
2943 Asn1Error
<< "use of incompletely defined Attributes &Attributes::operator = (const Attributes &)" << endl
;
2945 // if your compiler complains here, check the -novolat option
2946 #endif // SNACC_DEEP_COPY
2949 void Attributes::Print (ostream
&os
) const
2952 os
<< "{ -- SEQUENCE/SET OF -- " << endl
;
2953 indentG
+= stdIndentG
;
2955 //for (; Curr() != NULL; GoNext())
2956 for (const AsnListElmt
*run
=first
; run
; run
=run
->next
)
2958 Indent (os
, indentG
);
2961 //if (Curr() != Last())
2966 indentG
-= stdIndentG
;
2967 Indent (os
, indentG
);
2975 void Attributes::SetCurrElmt (unsigned long int index
)
2977 unsigned long int i
;
2980 for (i
= 0; (i
< (count
-1)) && (i
< index
); i
++)
2982 } // Attributes::SetCurrElmt
2985 unsigned long int Attributes::GetCurrElmtIndex()
2987 unsigned long int i
;
2991 for (i
= 0, tmp
= first
; tmp
!= NULL
; i
++)
3000 } // Attributes::GetCurrElmtIndex
3003 // alloc new list elmt, put at end of list
3004 // and return the component type
3005 Attribute
*Attributes::Append()
3007 AsnListElmt
*newElmt
;
3008 newElmt
= new AsnListElmt
;
3009 newElmt
->elmt
= new Attribute
;
3010 newElmt
->next
= NULL
;
3013 newElmt
->prev
= NULL
;
3014 first
= last
= newElmt
;
3018 newElmt
->prev
= last
;
3019 last
->next
= newElmt
;
3023 return (curr
= newElmt
)->elmt
;
3024 } // Attributes::Append
3027 // alloc new list elmt, put at begining of list
3028 // and return the component type
3029 Attribute
*Attributes::Prepend()
3031 AsnListElmt
*newElmt
;
3032 newElmt
= new AsnListElmt
;
3033 newElmt
->elmt
= new Attribute
;
3034 newElmt
->prev
= NULL
;
3037 newElmt
->next
= NULL
;
3038 first
= last
= newElmt
;
3042 newElmt
->next
= first
;
3043 first
->prev
= newElmt
;
3047 return (curr
= newElmt
)->elmt
;
3048 } // Attributes::Prepend
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()
3057 AsnListElmt
*newElmt
;
3058 newElmt
= new AsnListElmt
;
3059 newElmt
->elmt
= new Attribute
;
3062 newElmt
->next
= first
;
3063 newElmt
->prev
= NULL
;
3070 newElmt
->next
= curr
;
3071 newElmt
->prev
= curr
->prev
;
3072 curr
->prev
= newElmt
;
3076 newElmt
->prev
->next
= newElmt
;
3079 return (curr
= newElmt
)->elmt
;
3080 } // Attributes::InsertBefore
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()
3089 AsnListElmt
*newElmt
;
3090 newElmt
= new AsnListElmt
;
3091 newElmt
->elmt
= new Attribute
;
3094 newElmt
->prev
= last
;
3095 newElmt
->next
= NULL
;
3102 newElmt
->prev
= curr
;
3103 newElmt
->next
= curr
->next
;
3104 curr
->next
= newElmt
;
3108 newElmt
->next
->prev
= newElmt
;
3111 return (curr
= newElmt
)->elmt
;
3112 } // Attributes::InsertAfter
3115 Attributes
&Attributes::AppendCopy (Attribute
&elmt
)
3117 AsnListElmt
*newElmt
;
3118 newElmt
= new AsnListElmt
;
3119 newElmt
->elmt
= new Attribute
;
3120 *newElmt
->elmt
= elmt
;
3121 newElmt
->next
= NULL
;
3124 newElmt
->prev
= NULL
;
3125 first
= last
= newElmt
;
3129 newElmt
->prev
= last
;
3130 last
->next
= newElmt
;
3138 Attributes
&Attributes::PrependCopy (Attribute
&elmt
)
3140 AsnListElmt
*newElmt
;
3141 newElmt
= new AsnListElmt
;
3142 newElmt
->elmt
= new Attribute
;
3143 *newElmt
->elmt
= elmt
;
3144 newElmt
->prev
= NULL
;
3147 newElmt
->next
= NULL
;
3148 first
= last
= newElmt
;
3152 newElmt
->next
= first
;
3153 first
->prev
= newElmt
;
3158 } // Attributes::PrependCopy
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
)
3168 AsnListElmt
*newElmt
;
3170 newElmt
= new AsnListElmt
;
3171 newElmt
->elmt
= new Attribute
;
3172 *newElmt
->elmt
= elmt
;
3176 newElmt
->next
= first
;
3177 newElmt
->prev
= NULL
;
3184 newElmt
->next
= curr
;
3185 newElmt
->prev
= curr
->prev
;
3186 curr
->prev
= newElmt
;
3190 newElmt
->prev
->next
= newElmt
;
3194 } // Attributes::InsertBeforeAndCopy
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
)
3204 AsnListElmt
*newElmt
;
3206 newElmt
= new AsnListElmt
;
3207 newElmt
->elmt
= new Attribute
;
3208 *newElmt
->elmt
= elmt
;
3211 newElmt
->prev
= last
;
3212 newElmt
->next
= NULL
;
3219 newElmt
->prev
= curr
;
3220 newElmt
->next
= curr
->next
;
3221 curr
->next
= newElmt
;
3225 newElmt
->next
->prev
= newElmt
;
3229 } // Attributes::InsertAfterAndCopy
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()
3238 AsnListElmt
*del_elmt
;
3246 first
= last
= curr
= NULL
;
3247 else if (curr
== first
)
3249 curr
= first
= first
->next
;
3252 else if (curr
== last
)
3254 curr
= last
= last
->prev
;
3259 curr
->prev
->next
= curr
->next
;
3260 curr
->next
->prev
= curr
->prev
;
3263 delete del_elmt
->elmt
;
3269 AsnLen
Attributes::BEncContent (BUF_TYPE b
)
3271 AsnListElmt
*currElmt
;
3273 AsnLen totalLen
= 0;
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)
3282 ENCODE_BUF1(currElmt
->elmt
->BEncContent
, elmtLen
);
3283 elmtLen
+= BEncConsLen (outputBuf
, elmtLen
);
3285 elmtLen
+= BEncTag1 (outputBuf
, UNIV
, CONS
, SEQ_TAG_CODE
);
3286 ENCODE_BUF2(tmpEnc
[iii
]);
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
];
3294 totalLen
+= elmtLen
;
3296 } // Attributes::BEncContent
3299 void Attributes::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
,
3300 AsnLen
&bytesDecoded
, ENV_TYPE env
)
3302 Attribute
*listElmt
;
3304 AsnLen listBytesDecoded
= 0;
3307 while ((listBytesDecoded
< elmtLen0
) || (elmtLen0
== INDEFINITE_LEN
))
3309 tag1
= BDecTag (b
, listBytesDecoded
, env
);
3310 if ((tag1
== EOC_TAG_ID
) && (elmtLen0
== INDEFINITE_LEN
))
3312 BDEC_2ND_EOC_OCTET (b
, listBytesDecoded
, env
);
3315 if ((tag1
!= MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
3317 Asn1Error
<< "Unexpected Tag" << endl
;
3318 SnaccExcep::throwMe(-119);
3321 elmtLen1
= BDecLen (b
, listBytesDecoded
, env
);
3322 listElmt
= Append();
3323 listElmt
->BDecContent (b
, tag1
, elmtLen1
, listBytesDecoded
, env
);
3326 bytesDecoded
+= listBytesDecoded
;
3327 } // Attributes::BDecContent
3332 choiceId
= rDNSequenceCid
;
3334 rDNSequence
= new RDNSequence
;
3336 rDNSequence
= NULL
; // incomplete initialization of mandatory element!
3340 Name::Name (const Name
&)
3342 Asn1Error
<< "use of incompletely defined Name::Name (const Name &)" << endl
;
3350 case rDNSequenceCid
:
3354 } // end of destructor
3356 AsnType
*Name::Clone() const
3361 AsnType
*Name::Copy() const
3363 return new Name (*this);
3367 Name
&Name::operator = (const Name
&that
)
3368 #else // SNACC_DEEP_COPY
3369 Name
&Name::operator = (const Name
&)
3370 #endif // SNACC_DEEP_COPY
3377 case rDNSequenceCid
:
3381 switch (choiceId
= that
.choiceId
)
3383 case rDNSequenceCid
:
3384 rDNSequence
= new RDNSequence
;
3385 *rDNSequence
= *that
.rDNSequence
;
3391 #else // SNACC_DEEP_COPY
3392 Asn1Error
<< "use of incompletely defined Name &Name::operator = (const Name &)" << endl
;
3394 // if your compiler complains here, check the -novolat option
3395 #endif // SNACC_DEEP_COPY
3399 Name::BEncContent (BUF_TYPE b
)
3404 case rDNSequenceCid
:
3406 l
= rDNSequence
->BEncContent (b
);
3407 l
+= BEncConsLen (b
, l
);
3409 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
3414 } // Name::BEncContent
3417 void Name::BDecContent (BUF_TYPE b
, AsnTag tag
, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
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
);
3428 Asn1Error
<< "ERROR - unexpected tag in CHOICE" << endl
;
3429 SnaccExcep::throwMe(-120);
3432 } // Name::BDecContent
3435 AsnLen
Name::BEnc (BUF_TYPE b
)
3438 l
= BEncContent (b
);
3442 void Name::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
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
);
3454 void Name::Print (ostream
&os
) const
3459 case rDNSequenceCid
:
3460 os
<< "rDNSequence ";
3464 os
<< "-- void3 --\n";