diff options
author | Lasse Collin <lasse.collin@tukaani.org> | 2008-09-12 22:41:40 +0300 |
---|---|---|
committer | Lasse Collin <lasse.collin@tukaani.org> | 2008-09-12 22:41:40 +0300 |
commit | 320601b2c7b08fc7da9da18d5bf7c3c1a189b080 (patch) | |
tree | 3846af51e6904d900e5cd8337baf0728a42a07fe /src/liblzma/common/stream_flags_common.c | |
parent | Simplified debug/known_sizes.c to match the relaxed (diff) | |
download | xz-320601b2c7b08fc7da9da18d5bf7c3c1a189b080.tar.xz |
Improved the Stream Flags handling API.
Diffstat (limited to '')
-rw-r--r-- | src/liblzma/common/stream_flags_common.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/src/liblzma/common/stream_flags_common.c b/src/liblzma/common/stream_flags_common.c index c44b3ff2..aaa9fe02 100644 --- a/src/liblzma/common/stream_flags_common.c +++ b/src/liblzma/common/stream_flags_common.c @@ -24,17 +24,31 @@ const uint8_t lzma_header_magic[6] = { 0xFF, 0x4C, 0x5A, 0x4D, 0x41, 0x00 }; const uint8_t lzma_footer_magic[2] = { 0x59, 0x5A }; -extern LZMA_API lzma_bool -lzma_stream_flags_equal(const lzma_stream_flags *a, const lzma_stream_flags *b) +extern LZMA_API lzma_ret +lzma_stream_flags_compare( + const lzma_stream_flags *a, const lzma_stream_flags *b) { + // We can compare only version 0 structures. + if (a->version != 0 || b->version != 0) + return LZMA_HEADER_ERROR; + + // Check type + if ((unsigned int)(a->check) > LZMA_CHECK_ID_MAX + || (unsigned int)(b->check) > LZMA_CHECK_ID_MAX) + return LZMA_PROG_ERROR; + if (a->check != b->check) - return false; + return LZMA_DATA_ERROR; // Backward Sizes are compared only if they are known in both. if (a->backward_size != LZMA_VLI_VALUE_UNKNOWN - && b->backward_size != LZMA_VLI_VALUE_UNKNOWN - && a->backward_size != b->backward_size) - return false; + && b->backward_size != LZMA_VLI_VALUE_UNKNOWN) { + if (!is_backward_size_valid(a) || !is_backward_size_valid(b)) + return LZMA_PROG_ERROR; + + if (a->backward_size != b->backward_size) + return LZMA_DATA_ERROR; + } - return true; + return LZMA_OK; } |