33 return strtok_s(str, delim, saveptr);
35 return strtok_r(str, delim, saveptr);
49 const char *options_str = options != NULL ? options :
"(null)";
50 TRACE(
"Entering parse_options(%s)", options_str);
54 .dictionary = 33554432,
69 TRACE(
"Exiting parse_options() = {compress: %d, deduplicate: %d, dictionary: %u, table_shift: %d, "
70 "data_shift: %u, block_alignment: %u, md5: %d, sha1: %d, sha256: %d, blake3: %d, spamsum: %d, "
71 "zstd: %d, zstd_level: %d, num_threads: %d}",
79 strncpy(buffer, options,
sizeof(buffer));
80 buffer[
sizeof(buffer) - 1] =
'\0';
86 char *equal = strchr(token,
'=');
90 const char *key = token;
91 const char *value = equal + 1;
93 const bool bval = strncmp(value,
"true", 4) == 0;
95 if(strncmp(key,
"compress", 8) == 0)
97 else if(strncmp(key,
"deduplicate", 11) == 0)
99 else if(strncmp(key,
"dictionary", 10) == 0)
101 parsed.
dictionary = (uint32_t)strtoul(value, NULL, 10);
104 else if(strncmp(key,
"table_shift", 11) == 0)
108 long parsed_value = strtol(value, &endptr, 10);
109 if(errno == 0 && endptr != value)
111 if(parsed_value < INT8_MIN) parsed_value = INT8_MIN;
112 if(parsed_value > INT8_MAX) parsed_value = INT8_MAX;
114 *table_shift_found =
true;
117 else if(strncmp(key,
"data_shift", 10) == 0)
121 long parsed_value = strtol(value, &endptr, 10);
122 if(errno == 0 && endptr != value && parsed_value >= 0)
124 if(parsed_value > UINT8_MAX) parsed_value = UINT8_MAX;
129 else if(strncmp(key,
"block_alignment", 15) == 0)
133 long parsed_value = strtol(value, &endptr, 10);
134 if(errno == 0 && endptr != value && parsed_value >= 0)
136 if(parsed_value > UINT8_MAX) parsed_value = UINT8_MAX;
141 else if(strncmp(key,
"md5", 3) == 0)
143 else if(strncmp(key,
"sha1", 4) == 0)
145 else if(strncmp(key,
"sha256", 6) == 0)
147 else if(strncmp(key,
"blake3", 6) == 0)
149 else if(strncmp(key,
"spamsum", 7) == 0)
151 else if(strncmp(key,
"zstd_level", 10) == 0)
153 parsed.
zstd_level = (int)strtol(value, NULL, 10);
157 else if(strncmp(key,
"zstd", 4) == 0)
159 else if(strncmp(key,
"threads", 7) == 0)
168 TRACE(
"Exiting parse_options() = {compress: %d, deduplicate: %d, dictionary: %u, table_shift: %d, "
169 "data_shift: %u, block_alignment: %u, md5: %d, sha1: %d, sha256: %d, blake3: %d, spamsum: %d, "
170 "zstd: %d, zstd_level: %d, num_threads: %d}",
static char * aaru_strtok_reentrant(char *str, const char *delim, char **saveptr)
aaru_options parse_options(const char *options, bool *table_shift_found)
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 zstd
Use Zstandard instead of LZMA for data blocks. Default: false.
bool deduplicate
Storage dedup flag (DDT always exists).
int zstd_level
Zstandard compression level (1-22). Default: 19.
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.
int num_threads
Number of compression worker threads.
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).