40 const char *options_str = options != NULL ? options :
"(null)";
41 TRACE(
"Entering parse_options(%s)", options_str);
45 .dictionary = 33554432,
57 TRACE(
"Exiting parse_options() = {compress: %d, deduplicate: %d, dictionary: %u, table_shift: %d, "
58 "data_shift: %u, block_alignment: %u, md5: %d, sha1: %d, sha256: %d, blake3: %d, spamsum: %d}",
65 strncpy(buffer, options,
sizeof(buffer));
66 buffer[
sizeof(buffer) - 1] =
'\0';
69 char *token = strtok_r(buffer,
";", &saveptr);
72 char *equal = strchr(token,
'=');
76 const char *key = token;
77 const char *value = equal + 1;
79 const bool bval = strncmp(value,
"true", 4) == 0;
81 if(strncmp(key,
"compress", 8) == 0)
83 else if(strncmp(key,
"deduplicate", 11) == 0)
85 else if(strncmp(key,
"dictionary", 10) == 0)
87 parsed.
dictionary = (uint32_t)strtoul(value, NULL, 10);
90 else if(strncmp(key,
"table_shift", 11) == 0)
94 long parsed_value = strtol(value, &endptr, 10);
95 if(errno == 0 && endptr != value)
97 if(parsed_value < INT8_MIN) parsed_value = INT8_MIN;
98 if(parsed_value > INT8_MAX) parsed_value = INT8_MAX;
103 else if(strncmp(key,
"data_shift", 10) == 0)
107 long parsed_value = strtol(value, &endptr, 10);
108 if(errno == 0 && endptr != value && parsed_value >= 0)
110 if(parsed_value > UINT8_MAX) parsed_value = UINT8_MAX;
115 else if(strncmp(key,
"block_alignment", 15) == 0)
119 long parsed_value = strtol(value, &endptr, 10);
120 if(errno == 0 && endptr != value && parsed_value >= 0)
122 if(parsed_value > UINT8_MAX) parsed_value = UINT8_MAX;
127 else if(strncmp(key,
"md5", 3) == 0)
129 else if(strncmp(key,
"sha1", 4) == 0)
131 else if(strncmp(key,
"sha256", 6) == 0)
133 else if(strncmp(key,
"blake3", 6) == 0)
135 else if(strncmp(key,
"spamsum", 7) == 0)
138 token = strtok_r(NULL,
";", &saveptr);
141 TRACE(
"Exiting parse_options() = {compress: %d, deduplicate: %d, dictionary: %u, table_shift: %d, "
142 "data_shift: %u, block_alignment: %u, md5: %d, sha1: %d, sha256: %d, blake3: %d, spamsum: %d}",
aaru_options parse_options(const char *options)
Parses the options string for AaruFormat image creation/opening.
< For bool type used in aaru_options.
Parsed user-specified tunables controlling compression, deduplication, hashing and DDT geometry.
bool deduplicate
Storage dedup flag (DDT always exists).
uint8_t data_shift
Global data shift: low bits encode sector offset inside a block (2^data_shift span).
uint32_t dictionary
LZMA dictionary size in bytes (>= 4096 recommended). Default: 33554432 (32 MiB).
bool compress
Enable adaptive compression (LZMA for data blocks, FLAC for audio). Default: true.
bool sha256
Generate SHA-256 checksum (ChecksumAlgorithm::Sha256) when finalizing image.
bool spamsum
Generate SpamSum fuzzy hash (ChecksumAlgorithm::SpamSum) if enabled.
int8_t table_shift
DDT table shift (multi-level fan-out exponent). Default: heuristically calculated.
bool md5
Generate MD5 checksum (ChecksumAlgorithm::Md5) when finalizing image.
bool blake3
Generate BLAKE3 checksum if supported (not stored if algorithm unavailable).
bool sha1
Generate SHA-1 checksum (ChecksumAlgorithm::Sha1) when finalizing image.
uint8_t block_alignment
log2 underlying block alignment (2^n bytes). Default: 9 (512 bytes).