Beispiel #1
0
bool
LX::ReceivePacket(Port &port, Command command,
                  void *data, size_t length, OperationEnvironment &env,
                  unsigned timeout_ms)
{
  port.Flush();
  return SendCommand(port, command) &&
    ReadCRC(port, data, length, env, timeout_ms);
}
Beispiel #2
0
HRESULT CDecoder::DecodeFile(bool &isBZ, ICompressProgressInfo *progress)
{
  isBZ = false;
  Byte s[6];
  int i;
  for (i = 0; i < 4; i++)
    s[i] = ReadByte();
  if (s[0] != kArSig0 || 
      s[1] != kArSig1 || 
      s[2] != kArSig2 || 
      s[3] <= kArSig3 || 
      s[3] > kArSig3 + kBlockSizeMultMax)
    return S_OK;
  isBZ = true;
  UInt32 dicSize = (UInt32)(s[3] - kArSig3) * kBlockSizeStep;

  if (!m_State.Alloc())
    return E_OUTOFMEMORY;

  CBZip2CombinedCRC computedCombinedCRC;
  while (true)
  {
    if (progress)
    {
      UInt64 packSize = m_InStream.GetProcessedSize();
      UInt64 unpackSize = m_OutStream.GetProcessedSize();
      RINOK(progress->SetRatioInfo(&packSize, &unpackSize));
    }

    for (i = 0; i < 6; i++)
      s[i] = ReadByte();
    UInt32 crc = ReadCRC();
    if (s[0] == kFinSig0)
    {
      if (s[1] != kFinSig1 || 
          s[2] != kFinSig2 || 
          s[3] != kFinSig3 || 
          s[4] != kFinSig4 || 
          s[5] != kFinSig5)
        return S_FALSE;

      return (crc == computedCombinedCRC.GetDigest()) ? S_OK : S_FALSE;
    }
    if (s[0] != kBlockSig0 || 
        s[1] != kBlockSig1 || 
        s[2] != kBlockSig2 || 
        s[3] != kBlockSig3 || 
        s[4] != kBlockSig4 || 
        s[5] != kBlockSig5)
      return S_FALSE;
    m_State.StoredCRC = crc;
    computedCombinedCRC.Update(crc);
    RINOK(ReadBlock(dicSize, m_State));
    RINOK(m_State.DecodeBlock(m_OutStream));
  }
}
Beispiel #3
0
bool
LX::ReceivePacket(Port &port, Command command,
                  void *data, size_t length, OperationEnvironment &env,
                  std::chrono::steady_clock::duration first_timeout,
                  std::chrono::steady_clock::duration subsequent_timeout,
                  std::chrono::steady_clock::duration total_timeout)
{
  port.Flush();
  return SendCommand(port, command) &&
    ReadCRC(port, data, length, env,
            first_timeout, subsequent_timeout, total_timeout);
}