Rizin
unix-like reverse engineering framework and cli tools
options.h File Reference

Parser for filter-specific options. More...

Go to the source code of this file.

Functions

lzma_options_deltaoptions_delta (const char *str)
 Parser for Delta options. More...
 
lzma_options_bcjoptions_bcj (const char *str)
 Parser for BCJ options. More...
 
lzma_options_lzmaoptions_lzma (const char *str)
 Parser for LZMA options. More...
 

Detailed Description

Parser for filter-specific options.

Definition in file options.h.

Function Documentation

◆ 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.

Definition at line 209 of file options.c.

210 {
211  static const option_map opts[] = {
212  { "start", NULL, 0, UINT32_MAX },
213  { NULL, NULL, 0, 0 }
214  };
215 
218  .start_offset = 0,
219  };
220 
221  parse_options(str, opts, &set_bcj, options);
222 
223  return options;
224 }
#define NULL
Definition: cris-opc.c:27
#define xmalloc
Definition: disas-asm.h:43
static const char struct stat static buf struct stat static buf static vhangup int options
Definition: sflib.h:145
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)
Definition: options.c:60
static void set_bcj(void *options, unsigned key, uint64_t value, const char *valuestr lzma_attribute((__unused__)))
Definition: options.c:196
#define UINT32_MAX
Options for BCJ filters.
Definition: bcj.h:73

References NULL, options, parse_options(), set_bcj(), cmd_descs_generate::str, UINT32_MAX, and xmalloc.

Referenced by parse_real().

◆ 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.

Definition at line 165 of file options.c.

166 {
167  static const option_map opts[] = {
168  { "dist", NULL, LZMA_DELTA_DIST_MIN,
170  { NULL, NULL, 0, 0 }
171  };
172 
175  // It's hard to give a useful default for this.
176  .type = LZMA_DELTA_TYPE_BYTE,
177  .dist = LZMA_DELTA_DIST_MIN,
178  };
179 
181 
182  return options;
183 }
@ LZMA_DELTA_TYPE_BYTE
Definition: delta.h:36
#define LZMA_DELTA_DIST_MIN
Definition: delta.h:60
#define LZMA_DELTA_DIST_MAX
Definition: delta.h:61
static void set_delta(void *options, unsigned key, uint64_t value, const char *valuestr lzma_attribute((__unused__)))
Definition: options.c:152
Options for the Delta filter.
Definition: delta.h:45

References LZMA_DELTA_DIST_MAX, LZMA_DELTA_DIST_MIN, LZMA_DELTA_TYPE_BYTE, NULL, options, parse_options(), set_delta(), cmd_descs_generate::str, and xmalloc.

Referenced by parse_real().

◆ 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.

Definition at line 317 of file options.c.

318 {
319  static const name_id_map modes[] = {
320  { "fast", LZMA_MODE_FAST },
321  { "normal", LZMA_MODE_NORMAL },
322  { NULL, 0 }
323  };
324 
325  static const name_id_map mfs[] = {
326  { "hc3", LZMA_MF_HC3 },
327  { "hc4", LZMA_MF_HC4 },
328  { "bt2", LZMA_MF_BT2 },
329  { "bt3", LZMA_MF_BT3 },
330  { "bt4", LZMA_MF_BT4 },
331  { NULL, 0 }
332  };
333 
334  static const option_map opts[] = {
335  { "preset", NULL, UINT64_MAX, 0 },
336  { "dict", NULL, LZMA_DICT_SIZE_MIN,
337  (UINT32_C(1) << 30) + (UINT32_C(1) << 29) },
338  { "lc", NULL, LZMA_LCLP_MIN, LZMA_LCLP_MAX },
339  { "lp", NULL, LZMA_LCLP_MIN, LZMA_LCLP_MAX },
340  { "pb", NULL, LZMA_PB_MIN, LZMA_PB_MAX },
341  { "mode", modes, 0, 0 },
342  { "nice", NULL, 2, 273 },
343  { "mf", mfs, 0, 0 },
344  { "depth", NULL, 0, UINT32_MAX },
345  { NULL, NULL, 0, 0 }
346  };
347 
349  if (lzma_lzma_preset(options, LZMA_PRESET_DEFAULT))
350  message_bug();
351 
352  parse_options(str, opts, &set_lzma, options);
353 
354  if (options->lc + options->lp > LZMA_LCLP_MAX)
355  message_fatal(_("The sum of lc and lp must not exceed 4"));
356 
357  const uint32_t nice_len_min = options->mf & 0x0F;
358  if (options->nice_len < nice_len_min)
359  message_fatal(_("The selected match finder requires at "
360  "least nice=%" PRIu32), nice_len_min);
361 
362  return options;
363 }
#define LZMA_PRESET_DEFAULT
Default compression preset.
Definition: container.h:31
#define PRIu32
Definition: macros.h:20
@ LZMA_MODE_FAST
Fast compression.
Definition: lzma12.h:139
@ LZMA_MODE_NORMAL
Normal compression.
Definition: lzma12.h:147
#define LZMA_PB_MIN
Definition: lzma12.h:317
#define LZMA_DICT_SIZE_MIN
Definition: lzma12.h:218
#define LZMA_LCLP_MIN
Definition: lzma12.h:282
#define LZMA_PB_MAX
Definition: lzma12.h:318
#define LZMA_LCLP_MAX
Definition: lzma12.h:283
@ LZMA_MF_HC4
Hash Chain with 2-, 3-, and 4-byte hashing.
Definition: lzma12.h:70
@ LZMA_MF_BT4
Binary Tree with 2-, 3-, and 4-byte hashing.
Definition: lzma12.h:101
@ LZMA_MF_HC3
Hash Chain with 2- and 3-byte hashing.
Definition: lzma12.h:59
@ LZMA_MF_BT2
Binary Tree with 2-byte hashing.
Definition: lzma12.h:81
@ LZMA_MF_BT3
Binary Tree with 2- and 3-byte hashing.
Definition: lzma12.h:90
void message_bug(void)
Definition: message.c:789
void message_fatal(const char *fmt,...)
Definition: message.c:777
#define _(String)
Definition: opintl.h:53
static void set_lzma(void *options, unsigned key, uint64_t value, const char *valuestr)
Definition: options.c:252
unsigned int uint32_t
Definition: sftypes.h:29
#define UINT32_C(val)
#define UINT64_MAX
Options specific to the LZMA1 and LZMA2 filters.
Definition: lzma12.h:185

References _, LZMA_DICT_SIZE_MIN, LZMA_LCLP_MAX, LZMA_LCLP_MIN, LZMA_MF_BT2, LZMA_MF_BT3, LZMA_MF_BT4, LZMA_MF_HC3, LZMA_MF_HC4, LZMA_MODE_FAST, LZMA_MODE_NORMAL, LZMA_PB_MAX, LZMA_PB_MIN, LZMA_PRESET_DEFAULT, message_bug(), message_fatal(), NULL, options, parse_options(), PRIu32, set_lzma(), cmd_descs_generate::str, UINT32_C, UINT32_MAX, UINT64_MAX, and xmalloc.

Referenced by parse_real().