XZ Utils  5.2.10
Data Structures | Enumerations | Functions
options.c File Reference

Parser for filter-specific options. More...

#include "private.h"

Data Structures

struct  name_id_map
 
struct  option_map
 

Enumerations

enum  { OPT_DIST }
 
enum  { OPT_START_OFFSET }
 
enum  {
  OPT_PRESET , OPT_DICT , OPT_LC , OPT_LP ,
  OPT_PB , OPT_MODE , OPT_NICE , OPT_MF ,
  OPT_DEPTH
}
 

Functions

static void parse_options (const char *str, const option_map *opts, void(*set)(void *filter_options, unsigned key, uint64_t value, const char *valuestr), void *filter_options)
 
static void set_delta (void *options, unsigned key, uint64_t value, const char *valuestr lzma_attribute((__unused__)))
 
lzma_options_deltaoptions_delta (const char *str)
 Parser for Delta options. More...
 
static void set_bcj (void *options, unsigned key, uint64_t value, const char *valuestr lzma_attribute((__unused__)))
 
lzma_options_bcjoptions_bcj (const char *str)
 Parser for BCJ options. More...
 
static void lzma_attribute ((__noreturn__))
 
static void set_lzma (void *options, unsigned key, uint64_t value, const char *valuestr)
 
lzma_options_lzmaoptions_lzma (const char *str)
 Parser for LZMA options. More...
 

Detailed Description

Parser for filter-specific options.

Function Documentation

◆ parse_options()

static void parse_options ( const char *  str,
const option_map opts,
void(*)(void *filter_options, unsigned key, uint64_t value, const char *valuestr)  set,
void *  filter_options 
)
static

Parses option=value pairs that are separated with commas: opt=val,opt=val,opt=val

Each option is a string, that is converted to an integer using the index where the option string is in the array.

Value can be

  • a string-id map mapping a list of possible string values to integers (opts[i].map != NULL, opts[i].min and opts[i].max are ignored);
  • a number with minimum and maximum value limit (opts[i].map == NULL && opts[i].min != UINT64_MAX);
  • a string that will be parsed by the filter-specific code (opts[i].map == NULL && opts[i].min == UINT64_MAX, opts[i].max ignored)

When parsing both option and value succeed, a filter-specific function is called, which should update the given value to filter-specific options structure.

Parameters
strString containing the options from the command line
optsFilter-specific option map
setFilter-specific function to update filter_options
filter_optionsPointer to filter-specific options structure
Returns
Returns only if no errors occur.

References message_fatal(), and xstrdup().

◆ options_delta()

lzma_options_delta* options_delta ( const char *  str)

Parser for Delta options.

Returns
Pointer to allocated options structure. Doesn't return on error.

◆ options_bcj()

lzma_options_bcj* options_bcj ( const char *  str)

Parser for BCJ options.

Returns
Pointer to allocated options structure. Doesn't return on error.

◆ options_lzma()

lzma_options_lzma* options_lzma ( const char *  str)

Parser for LZMA options.

Returns
Pointer to allocated options structure. Doesn't return on error.

References LZMA_MF_BT2, LZMA_MF_BT3, LZMA_MF_BT4, LZMA_MF_HC3, LZMA_MF_HC4, LZMA_MODE_FAST, and LZMA_MODE_NORMAL.