Rizin
unix-like reverse engineering framework and cli tools
simple_decoder.c
Go to the documentation of this file.
1 //
5 //
6 // Author: Lasse Collin
7 //
8 // This file has been put into the public domain.
9 // You can do whatever you want with this file.
10 //
12 
13 #include "simple_decoder.h"
14 
15 
16 extern lzma_ret
18  const uint8_t *props, size_t props_size)
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
unsigned char uint8_t
Definition: sftypes.h:31
lzma_ret lzma_simple_props_decode(void **options, const lzma_allocator *allocator, const uint8_t *props, size_t props_size)
Properties decoder for simple filters.
Custom functions for memory handling.
Definition: base.h:372
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_ret
Return values used by several functions in liblzma.
Definition: base.h:57
@ 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