Logo Search packages:      
Sourcecode: pwlib version File versions  Download package

BOOL PASNObject::DecodeASNLength ( const PBYTEArray &  buffer,
PINDEX &  ptr,
WORD &  len 
) [static, inherited]

Decode an ASN length in the buffer at the given ptr. The ptr is moved to the byte after the end of the encoded length.

Parameters:
bufferbuffer to decode data from
ptrptr to decode from
lenreturned length

Definition at line 225 of file pasn.cxx.

Referenced by PASNObject::DecodeASNInteger(), and PASNObject::DecodeASNUnsigned().

{
  PINDEX s = buffer.GetSize();

  if (ptr >= s)
    return FALSE;

  BYTE ch = buffer[ptr++];

  if ((ch & ASN_LONG_LEN) == 0)
    len = (WORD)ch;
  else if ((ch & ~ASN_LONG_LEN) == 0x01) {
    if (ptr >= s)
      return FALSE;
    len = (WORD)buffer[ptr++];
  } else {
    if (ptr + 1 >= s)
      return FALSE;
    len = (WORD)((buffer[ptr] << 8) + buffer[ptr+1]);
    ptr += 2;
  }
  return TRUE;
}

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index