1 // SPDX-License-Identifier: 0BSD 2 3 /////////////////////////////////////////////////////////////////////////////// 4 // 5 /// \file stream_flags_common.c 6 /// \brief Common stuff for Stream flags coders 7 // 8 // Author: Lasse Collin 9 // 10 /////////////////////////////////////////////////////////////////////////////// 11 12 #include "stream_flags_common.h" 13 14 15 const uint8_t lzma_header_magic[6] = { 0xFD, 0x37, 0x7A, 0x58, 0x5A, 0x00 }; 16 const uint8_t lzma_footer_magic[2] = { 0x59, 0x5A }; 17 18 19 extern LZMA_API(lzma_ret) 20 lzma_stream_flags_compare( 21 const lzma_stream_flags *a, const lzma_stream_flags *b) 22 { 23 // We can compare only version 0 structures. 24 if (a->version != 0 || b->version != 0) 25 return LZMA_OPTIONS_ERROR; 26 27 // Check type 28 if ((unsigned int)(a->check) > LZMA_CHECK_ID_MAX 29 || (unsigned int)(b->check) > LZMA_CHECK_ID_MAX) 30 return LZMA_PROG_ERROR; 31 32 if (a->check != b->check) 33 return LZMA_DATA_ERROR; 34 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; 40 41 if (a->backward_size != b->backward_size) 42 return LZMA_DATA_ERROR; 43 } 44 45 return LZMA_OK; 46 } 47