stream_flags_common.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. /// \file stream_flags_common.c
  4. /// \brief Common stuff for Stream flags coders
  5. //
  6. // Author: Lasse Collin
  7. //
  8. // This file has been put into the public domain.
  9. // You can do whatever you want with this file.
  10. //
  11. ///////////////////////////////////////////////////////////////////////////////
  12. #include "stream_flags_common.h"
  13. const uint8_t lzma_header_magic[6] = { 0xFD, 0x37, 0x7A, 0x58, 0x5A, 0x00 };
  14. const uint8_t lzma_footer_magic[2] = { 0x59, 0x5A };
  15. extern LZMA_API(lzma_ret)
  16. lzma_stream_flags_compare(
  17. const lzma_stream_flags *a, const lzma_stream_flags *b)
  18. {
  19. // We can compare only version 0 structures.
  20. if (a->version != 0 || b->version != 0)
  21. return LZMA_OPTIONS_ERROR;
  22. // Check type
  23. if ((unsigned int)(a->check) > LZMA_CHECK_ID_MAX
  24. || (unsigned int)(b->check) > LZMA_CHECK_ID_MAX)
  25. return LZMA_PROG_ERROR;
  26. if (a->check != b->check)
  27. return LZMA_DATA_ERROR;
  28. // Backward Sizes are compared only if they are known in both.
  29. if (a->backward_size != LZMA_VLI_UNKNOWN
  30. && b->backward_size != LZMA_VLI_UNKNOWN) {
  31. if (!is_backward_size_valid(a) || !is_backward_size_valid(b))
  32. return LZMA_PROG_ERROR;
  33. if (a->backward_size != b->backward_size)
  34. return LZMA_DATA_ERROR;
  35. }
  36. return LZMA_OK;
  37. }