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

void PASNObject::EncodeASNInteger ( PBYTEArray &  buffer,
PASNInt  data,
PASNObject::ASNType  type 
) [static, inherited]

Parameters:
buffer  buffer to encode into
data  value to encode
type  actual integer type

Definition at line 293 of file pasn.cxx.

References PASNObject::EncodeASNHeader().

Referenced by PASNInteger::Encode().

{
  DWORD mask;
  WORD  intsize = sizeof(data);

  // create a mask which is the top nine bits of a DWORD, or 0xFF800000
  // on a big endian machine
  mask = 0x1FFUL << ((8 * (sizeof(DWORD) - 1)) - 1);

  // remove all sequences of nine 0's or 1's at the start of the value
  while ((((data & mask) == 0) || ((data & mask) == mask))
    && intsize > 1) {
    intsize--;
    data <<= 8;
  }

  // insert the header
  EncodeASNHeader(buffer, type, intsize);

  // insert the data
  PINDEX offs = buffer.GetSize();
  mask = 0xFFUL << (8 * (sizeof(DWORD) - 1));
  while (intsize--) {
    buffer[offs++] = (u_char)((data & mask) >> (8 * (sizeof(DWORD) - 1)));
    data <<= 8;
  }
}


Generated by  Doxygen 1.6.0   Back to index