XZ Utils 5.4.0
|
Data Fields | |
char | name [NAME_LEN_MAX+1] |
uint8_t | type |
uint8_t | flags |
uint16_t | offset |
union { | |
struct { | |
uint32_t min | |
uint32_t max | |
} range | |
const name_value_map * map | |
} | u |
const char * | name |
const name_id_map * | map |
uint64_t | min |
uint64_t | max |
Each filter that has options needs an array of option_map structures. The array doesn't need to be terminated as the functions take the length of the array as an argument.
When converting a string to filter options structure, option values will be handled in a few different ways:
(1) If .type equals OPTMAP_TYPE_LZMA_PRESET then LZMA1/2 preset string is handled specially.
(2) If .flags has OPTMAP_USE_NAME_VALUE_MAP set then the string is converted to an integer using the name_value_map pointed by .u.map. The last element in .u.map must have .name = "" as the terminator.
(3) Otherwise the string is treated as a non-negative unsigned decimal integer which must be in the range set in .u.range. If .flags has OPTMAP_USE_BYTE_SUFFIX then KiB, MiB, and GiB suffixes are allowed.
The integer value from (2) or (3) is then stored to filter_options at the offset specified in .offset using the type specified in .type (default is uint32_t).
Stringifying a filter is done by processing a given number of options in oder from the beginning of an option_map array. The integer is read from filter_options at .offset using the type from .type.
If the integer is zero and .flags has OPTMAP_NO_STRFY_ZERO then the option is skipped.
If .flags has OPTMAP_USE_NAME_VALUE_MAP set then .u.map will be used to convert the option to a string. If the map doesn't contain a string for the integer value then "UNKNOWN" is used.
If .flags doesn't have OPTMAP_USE_NAME_VALUE_MAP set then the integer is converted to a decimal value. If OPTMAP_USE_BYTE_SUFFIX is used then KiB, MiB, or GiB suffix is used if the value is an exact multiple of these. Plain "B" suffix is never used.