Rizin
unix-like reverse engineering framework and cli tools
simple_decoder.c File Reference

Properties decoder for simple filters. More...

#include "simple_decoder.h"

Go to the source code of this file.

Functions

lzma_ret lzma_simple_props_decode (void **options, const lzma_allocator *allocator, const uint8_t *props, size_t props_size)
 

Detailed Description

Properties decoder for simple filters.

Definition in file simple_decoder.c.

Function Documentation

◆ lzma_simple_props_decode()

lzma_ret lzma_simple_props_decode ( void **  options,
const lzma_allocator allocator,
const uint8_t props,
size_t  props_size 
)

Definition at line 17 of file simple_decoder.c.

19 {
20  if (props_size == 0)
21  return LZMA_OK;
22 
23  if (props_size != 4)
24  return LZMA_OPTIONS_ERROR;
25 
27  sizeof(lzma_options_bcj), allocator);
28  if (opt == NULL)
29  return LZMA_MEM_ERROR;
30 
31  opt->start_offset = read32le(props);
32 
33  // Don't leave an options structure allocated if start_offset is zero.
34  if (opt->start_offset == 0)
35  lzma_free(opt, allocator);
36  else
37  *options = opt;
38 
39  return LZMA_OK;
40 }
const lzma_allocator * allocator
Definition: block.h:377
#define NULL
Definition: cris-opc.c:27
const lzma_allocator const uint8_t * props
Definition: filter.h:362
static const char struct stat static buf struct stat static buf static vhangup int options
Definition: sflib.h:145
Options for BCJ filters.
Definition: bcj.h:73
uint32_t start_offset
Start offset for conversions.
Definition: bcj.h:88
void * lzma_alloc(size_t size, const lzma_allocator *allocator) lzma_attribute((__malloc__)) lzma_attr_alloc_size(1)
Allocates memory.
static uint32_t read32le(const uint8_t *buf)
@ LZMA_MEM_ERROR
Cannot allocate memory.
Definition: base.h:128
@ LZMA_OPTIONS_ERROR
Invalid or unsupported options.
Definition: base.h:160
@ LZMA_OK
Operation completed successfully.
Definition: base.h:58
void lzma_free(void *ptr, const lzma_allocator *allocator)
Frees memory.
Definition: common.c:78

References allocator, lzma_alloc(), lzma_free(), LZMA_MEM_ERROR, LZMA_OK, LZMA_OPTIONS_ERROR, NULL, options, props, read32le(), and lzma_options_bcj::start_offset.