Exemplo n.º 1
0
void COMFFileBuilder::PutNumeric(uint32 x) {
   // Put word or dword into buffer, depending on type being even or odd
   if (Type & 1) {
      PutDword(x);                     // Type is odd, put 32 bits
   }
   else {
      if (x > 0xffff) err.submit(2304);// Index out of range
      PutWord(uint16(x));              // Type is even, put 16 bits
   }
}
Exemplo n.º 2
0
INT32
EfiCompress (
	  UINT8   *SrcBuffer,
	  UINT32  SrcSize,
	  UINT8   *DstBuffer,
	  UINT32  *DstSize
  )
/*++

Routine Description:

  The main compression routine.

Arguments:

  SrcBuffer   - The buffer storing the source data
  SrcSize     - The size of source data
  DstBuffer   - The buffer to store the compressed data
  DstSize     - On input, the size of DstBuffer; On output,
				the size of the actual compressed data.

Returns:

  EFI_BUFFER_TOO_SMALL  - The DstBuffer is too small.this case,
				DstSize contains the size needed.
  EFI_SUCCESS           - Compression is successful.

--*/
{
  UINT32 Status = ERR_SUCCESS;
  
  //
  // Initializations
  //
  mBufSiz = 0;
  mBuf = NULL;
  mText       = NULL;
  mLevel      = NULL;
  mChildCount = NULL;
  mPosition   = NULL;
  mParent     = NULL;
  mPrev       = NULL;
  mNext       = NULL;

  
  mSrc = SrcBuffer;
  mSrcUpperLimit = mSrc + SrcSize;
  mDst = DstBuffer;
  mDstUpperLimit = mDst + *DstSize;

  PutDword(0L);
  PutDword(0L);
  
  MakeCrcTable ();

  mOrigSize = mCompSize = 0;
  mCrc = INIT_CRC;
  
  //
  // Compress it
  //
  
  Status = Encode();
  if (Status) {
	return ERR_OUT_OF_RESOURCES;
  }
  
  //
  // Null terminate the compressed data
  //
  if (mDst < mDstUpperLimit) {
	*mDst++ = 0;
  }
  
  //
  // Fill compressed size and original size
  //
  mDst = DstBuffer;
  PutDword(mCompSize+1);
  PutDword(mOrigSize);

  //
  // Return
  //
  
  if (mCompSize + 1 + 8 > *DstSize) {
	*DstSize = mCompSize + 1 + 8;
	return ERR_BUFFER_TOO_SMALL;
  } else {
	*DstSize = mCompSize + 1 + 8;
	return ERR_SUCCESS;
  }

}