コード例 #1
0
// Decodes a BER BIT STRING from the given buffer and stores
// the value in this object.
void AsnBits::BDecContent (const AsnBuf &b, AsnTag tagId, AsnLen elmtLen, AsnLen &bytesDecoded)
{
   FUNC("AsnBits::BDecContent");

	if (elmtLen == INDEFINITE_LEN || elmtLen > b.length())
	{
	   throw MemoryException(elmtLen, "elmtLen requests for too much data", STACK_ENTRY);
	}

   /*
    * tagId is encoded tag shifted into long int.
    * if CONS bit is set then constructed bit string
    */
   if (tagId & 0x20000000)
     BDecConsBits (b, elmtLen, bytesDecoded);

   else /* primitive octet string */
   {
     if (elmtLen == INDEFINITE_LEN)
        throw BoundsException("indefinite length on primitive", STACK_ENTRY);

	 if (elmtLen > b.length() || elmtLen <= 0)
        throw BoundsException("length problem on decoding content", STACK_ENTRY);

     bytesDecoded += elmtLen;
     elmtLen--;

	 unsigned int iUnusedBitLen= (unsigned int)b.GetByte();
	 if (iUnusedBitLen > 7)
        throw BoundsException("Length problem - Unused bits > 7", STACK_ENTRY);

     bitLen = (elmtLen * 8) - iUnusedBitLen;
     bits =  new unsigned char[elmtLen];
     b.GetUSeg (bits, elmtLen);
   }

} /* AsnBits::BDecContent */
コード例 #2
0
ファイル: asn-buf.cpp プロジェクト: azsnaccbuilds/esnacc-ng
// insert()
//
// insert cards from b into this AsnBuf
//
// TBD: is it necessary to return the length?
//
long AsnBuf::splice(AsnBuf &b)
{
    if (m_card != m_deck.end() &&
        ((*m_card == NULL) || (*m_card)->length() == 0)) {
        delete *m_card;
        m_card = m_deck.erase(m_card);
    }

    long length = b.length();
    Deck::reverse_iterator ib;
    for (ib = b.m_deck.rbegin(); ib != b.m_deck.rend(); ++ib) {
        m_card = m_deck.insert(m_deck.begin(), *ib);
    }
    b.m_deck.clear();

    return length;
}
コード例 #3
0
ファイル: asn-buf.cpp プロジェクト: sunshi0583/esnacc-ng
// insert()
//
// insert cards from b into this AsnBuf
//
// TBD: is it necessary to return the length?
//
long AsnBuf::splice(AsnBuf &b)
{
    Deck::iterator ib = b.m_deck.end();
//#ifdef _DEBUG
//   Card *tmpCard = *ib;
//#endif
    long length = b.length();

    if (m_card != m_deck.end() && (*m_card)->length() == 0)
        m_card = m_deck.erase(m_card);

    do
    {
        ib--;
//#ifdef _DEBUG
//      tmpCard = *ib;
//#endif
        m_card = m_deck.insert(m_deck.begin(), *ib);
        ib = b.m_deck.erase(ib);
    } while (ib != b.m_deck.begin()) ;

    return length;
}