aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/liblzma/api/lzma/index.h23
-rw-r--r--tests/test_index.c22
2 files changed, 34 insertions, 11 deletions
diff --git a/src/liblzma/api/lzma/index.h b/src/liblzma/api/lzma/index.h
index f7de84b5..46afe3eb 100644
--- a/src/liblzma/api/lzma/index.h
+++ b/src/liblzma/api/lzma/index.h
@@ -304,6 +304,28 @@ typedef enum {
/**
+ * \brief Mask for return value from lzma_index_checks() for check none
+ *
+ * \note This and the other CHECK_MASK macros were added in 5.5.1alpha.
+ */
+#define LZMA_INDEX_CHECK_MASK_NONE (UINT32_C(1) << LZMA_CHECK_NONE)
+
+/**
+ * \brief Mask for return value from lzma_index_checks() for check CRC32
+ */
+#define LZMA_INDEX_CHECK_MASK_CRC32 (UINT32_C(1) << LZMA_CHECK_CRC32)
+
+/**
+ * \brief Mask for return value from lzma_index_checks() for check CRC64
+ */
+#define LZMA_INDEX_CHECK_MASK_CRC64 (UINT32_C(1) << LZMA_CHECK_CRC64)
+
+/**
+ * \brief Mask for return value from lzma_index_checks() for check SHA256
+ */
+#define LZMA_INDEX_CHECK_MASK_SHA256 (UINT32_C(1) << LZMA_CHECK_SHA256)
+
+/**
* \brief Calculate memory usage of lzma_index
*
* On disk, the size of the Index field depends on both the number of Records
@@ -433,6 +455,7 @@ extern LZMA_API(lzma_ret) lzma_index_stream_flags(
* showing the Check types to the user.
*
* The bitmask is 1 << check_id, e.g. CRC32 is 1 << 1 and SHA-256 is 1 << 10.
+ * These masks are defined for convenience as LZMA_INDEX_CHECK_MASK_XXX
*
* \param i Pointer to lzma_index structure
*
diff --git a/tests/test_index.c b/tests/test_index.c
index f63d2a79..b8efebcb 100644
--- a/tests/test_index.c
+++ b/tests/test_index.c
@@ -204,28 +204,28 @@ test_lzma_index_checks(void)
assert_lzma_ret(lzma_index_stream_flags(idx, &stream_flags),
LZMA_OK);
assert_uint_eq(lzma_index_checks(idx),
- UINT32_C(1) << LZMA_CHECK_NONE);
+ LZMA_INDEX_CHECK_MASK_NONE);
// Set the check type to CRC32 and repeat
stream_flags.check = LZMA_CHECK_CRC32;
assert_lzma_ret(lzma_index_stream_flags(idx, &stream_flags),
LZMA_OK);
assert_uint_eq(lzma_index_checks(idx),
- UINT32_C(1) << LZMA_CHECK_CRC32);
+ LZMA_INDEX_CHECK_MASK_CRC32);
// Set the check type to CRC64 and repeat
stream_flags.check = LZMA_CHECK_CRC64;
assert_lzma_ret(lzma_index_stream_flags(idx, &stream_flags),
LZMA_OK);
assert_uint_eq(lzma_index_checks(idx),
- UINT32_C(1) << LZMA_CHECK_CRC64);
+ LZMA_INDEX_CHECK_MASK_CRC64);
// Set the check type to SHA256 and repeat
stream_flags.check = LZMA_CHECK_SHA256;
assert_lzma_ret(lzma_index_stream_flags(idx, &stream_flags),
LZMA_OK);
assert_uint_eq(lzma_index_checks(idx),
- UINT32_C(1) << LZMA_CHECK_SHA256);
+ LZMA_INDEX_CHECK_MASK_SHA256);
// Create second lzma_index and cat to first
lzma_index *second = lzma_index_init(NULL);
@@ -237,14 +237,14 @@ test_lzma_index_checks(void)
LZMA_OK);
assert_uint_eq(lzma_index_checks(second),
- UINT32_C(1) << LZMA_CHECK_CRC32);
+ LZMA_INDEX_CHECK_MASK_CRC32);
assert_lzma_ret(lzma_index_cat(idx, second, NULL), LZMA_OK);
// Index should now have both CRC32 and SHA256
assert_uint_eq(lzma_index_checks(idx),
- (UINT32_C(1) << LZMA_CHECK_CRC32) |
- (UINT32_C(1) << LZMA_CHECK_SHA256));
+ LZMA_INDEX_CHECK_MASK_CRC32 |
+ LZMA_INDEX_CHECK_MASK_SHA256);
// Change the check type of the second Stream to SHA256
stream_flags.check = LZMA_CHECK_SHA256;
@@ -253,7 +253,7 @@ test_lzma_index_checks(void)
// Index should now have only SHA256
assert_uint_eq(lzma_index_checks(idx),
- UINT32_C(1) << LZMA_CHECK_SHA256);
+ LZMA_INDEX_CHECK_MASK_SHA256);
// Test with a third Stream
lzma_index *third = lzma_index_init(NULL);
@@ -264,14 +264,14 @@ test_lzma_index_checks(void)
LZMA_OK);
assert_uint_eq(lzma_index_checks(third),
- UINT32_C(1) << LZMA_CHECK_CRC64);
+ LZMA_INDEX_CHECK_MASK_CRC64);
assert_lzma_ret(lzma_index_cat(idx, third, NULL), LZMA_OK);
// Index should now have CRC64 and SHA256
assert_uint_eq(lzma_index_checks(idx),
- (UINT32_C(1) << LZMA_CHECK_CRC64) |
- (UINT32_C(1) << LZMA_CHECK_SHA256));
+ LZMA_INDEX_CHECK_MASK_CRC64 |
+ LZMA_INDEX_CHECK_MASK_SHA256);
lzma_index_end(idx, NULL);
}