Update parse_options function to return table_shift_found flag

This commit is contained in:
2025-12-30 01:41:41 +00:00
parent c6034b649c
commit 344ce95619
3 changed files with 6 additions and 5 deletions

View File

@@ -55,7 +55,7 @@ bool set_ddt_multi_level_v2(aaruformat_context *ctx, uint64_t sector_address,
uint64_t block_offset, uint8_t sector_status, uint64_t *ddt_entry);
bool set_ddt_tape(aaruformat_context *ctx, uint64_t sector_address, uint64_t offset, uint64_t block_offset,
uint8_t sector_status, uint64_t *ddt_entry);
aaru_options parse_options(const char *options);
aaru_options parse_options(const char *options, bool *table_shift_found);
uint64_t get_filetime_uint64();
int32_t aaruf_close_current_block(aaruformat_context *ctx);
int compare_extents(const void *a, const void *b);

View File

@@ -290,7 +290,8 @@ AARU_EXPORT void AARU_CALL *aaruf_create(const char *filepath, const uint32_t me
// Parse the options
TRACE("Parsing options");
const aaru_options parsed_options = parse_options(options);
bool table_shift_found = false;
const aaru_options parsed_options = parse_options(options, &table_shift_found);
// Allocate context
TRACE("Allocating memory for context");
@@ -420,7 +421,7 @@ AARU_EXPORT void AARU_CALL *aaruf_create(const char *filepath, const uint32_t me
ctx->user_data_ddt_header.blockAlignmentShift = parsed_options.block_alignment;
ctx->user_data_ddt_header.dataShift = parsed_options.data_shift;
if(parsed_options.table_shift == -1)
if(parsed_options.table_shift == -1 || !table_shift_found)
{
const uint64_t total_sectors = user_sectors + overflow_sectors + negative_sectors;

View File

@@ -35,7 +35,7 @@
* @param options String with options to parse (may be NULL).
* @return Parsed options as an aaru_options struct.
*/
aaru_options parse_options(const char *options)
aaru_options parse_options(const char *options, bool *table_shift_found)
{
const char *options_str = options != NULL ? options : "(null)";
TRACE("Entering parse_options(%s)", options_str);
@@ -97,7 +97,7 @@ aaru_options parse_options(const char *options)
if(parsed_value < INT8_MIN) parsed_value = INT8_MIN;
if(parsed_value > INT8_MAX) parsed_value = INT8_MAX;
parsed.table_shift = (int8_t)parsed_value;
if(parsed.table_shift == 0) parsed.table_shift = 9;
*table_shift_found = true;
}
}
else if(strncmp(key, "data_shift", 10) == 0)