1 // SPDX-License-Identifier: 0BSD
3 ///////////////////////////////////////////////////////////////////////////////
5 /// \file stream_flags_common.c
6 /// \brief Common stuff for Stream flags coders
8 // Author: Lasse Collin
10 ///////////////////////////////////////////////////////////////////////////////
12 #include "stream_flags_common.h"
15 const uint8_t lzma_header_magic
[6] = { 0xFD, 0x37, 0x7A, 0x58, 0x5A, 0x00 };
16 const uint8_t lzma_footer_magic
[2] = { 0x59, 0x5A };
19 extern LZMA_API(lzma_ret
)
20 lzma_stream_flags_compare(
21 const lzma_stream_flags
*a
, const lzma_stream_flags
*b
)
23 // We can compare only version 0 structures.
24 if (a
->version
!= 0 || b
->version
!= 0)
25 return LZMA_OPTIONS_ERROR
;
28 if ((unsigned int)(a
->check
) > LZMA_CHECK_ID_MAX
29 || (unsigned int)(b
->check
) > LZMA_CHECK_ID_MAX
)
30 return LZMA_PROG_ERROR
;
32 if (a
->check
!= b
->check
)
33 return LZMA_DATA_ERROR
;
35 // Backward Sizes are compared only if they are known in both.
36 if (a
->backward_size
!= LZMA_VLI_UNKNOWN
37 && b
->backward_size
!= LZMA_VLI_UNKNOWN
) {
38 if (!is_backward_size_valid(a
) || !is_backward_size_valid(b
))
39 return LZMA_PROG_ERROR
;
41 if (a
->backward_size
!= b
->backward_size
)
42 return LZMA_DATA_ERROR
;