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

Decodes .xz Streams. More...

#include "common.h"

Go to the source code of this file.

Functions

lzma_ret lzma_stream_decoder_init (lzma_next_coder *next, const lzma_allocator *allocator, uint64_t memlimit, uint32_t flags)
 

Detailed Description

Decodes .xz Streams.

Definition in file stream_decoder.h.

Function Documentation

◆ lzma_stream_decoder_init()

lzma_ret lzma_stream_decoder_init ( lzma_next_coder next,
const lzma_allocator allocator,
uint64_t  memlimit,
uint32_t  flags 
)

Definition at line 419 of file stream_decoder.c.

422 {
424 
426  return LZMA_OPTIONS_ERROR;
427 
428  lzma_stream_coder *coder = next->coder;
429  if (coder == NULL) {
430  coder = lzma_alloc(sizeof(lzma_stream_coder), allocator);
431  if (coder == NULL)
432  return LZMA_MEM_ERROR;
433 
434  next->coder = coder;
435  next->code = &stream_decode;
436  next->end = &stream_decoder_end;
439 
441  coder->index_hash = NULL;
442  }
443 
444  coder->memlimit = my_max(1, memlimit);
445  coder->memusage = LZMA_MEMUSAGE_BASE;
446  coder->tell_no_check = (flags & LZMA_TELL_NO_CHECK) != 0;
449  coder->tell_any_check = (flags & LZMA_TELL_ANY_CHECK) != 0;
450  coder->ignore_check = (flags & LZMA_IGNORE_CHECK) != 0;
451  coder->concatenated = (flags & LZMA_CONCATENATED) != 0;
452  coder->first_stream = true;
453 
454  return stream_decoder_reset(coder, allocator);
455 }
const lzma_allocator * allocator
Definition: block.h:377
#define LZMA_TELL_ANY_CHECK
Definition: container.h:474
#define LZMA_IGNORE_CHECK
Definition: container.h:498
#define LZMA_CONCATENATED
Definition: container.h:515
#define LZMA_TELL_NO_CHECK
Definition: container.h:457
#define LZMA_TELL_UNSUPPORTED_CHECK
Definition: container.h:466
uint64_t memlimit
Definition: container.h:537
#define NULL
Definition: cris-opc.c:27
static struct sockaddr static addrlen static backlog const void static flags void flags
Definition: sfsocketcall.h:123
static lzma_ret stream_decode(void *coder_ptr, const lzma_allocator *allocator, const uint8_t *restrict in, size_t *restrict in_pos, size_t in_size, uint8_t *restrict out, size_t *restrict out_pos, size_t out_size, lzma_action action)
static void stream_decoder_end(void *coder_ptr, const lzma_allocator *allocator)
static lzma_ret stream_decoder_reset(lzma_stream_coder *coder, const lzma_allocator *allocator)
static lzma_check stream_decoder_get_check(const void *coder_ptr)
lzma_ret lzma_stream_decoder_init(lzma_next_coder *next, const lzma_allocator *allocator, uint64_t memlimit, uint32_t flags)
static lzma_ret stream_decoder_memconfig(void *coder_ptr, uint64_t *memusage, uint64_t *old_memlimit, uint64_t new_memlimit)
lzma_code_function code
Pointer to function to do the actual coding.
Definition: common.h:150
void * coder
Pointer to coder-specific data.
Definition: common.h:137
lzma_check(* get_check)(const void *coder)
Definition: common.h:164
lzma_end_function end
Definition: common.h:155
lzma_ret(* memconfig)(void *coder, uint64_t *memusage, uint64_t *old_memlimit, uint64_t new_memlimit)
Definition: common.h:168
lzma_index_hash * index_hash
uint64_t memlimit
Memory usage limit.
lzma_next_coder block_decoder
bool tell_any_check
If true, LZMA_GET_CHECK is returned after decoding Stream Header.
uint64_t memusage
Amount of memory actually needed (only an estimate)
#define LZMA_NEXT_CODER_INIT
Macro to initialize lzma_next_coder structure.
Definition: common.h:180
#define LZMA_SUPPORTED_FLAGS
Definition: common.h:72
#define LZMA_MEMUSAGE_BASE
Definition: common.h:63
#define lzma_next_coder_init(func, next, allocator)
Definition: common.h:291
void * lzma_alloc(size_t size, const lzma_allocator *allocator) lzma_attribute((__malloc__)) lzma_attr_alloc_size(1)
Allocates memory.
#define my_max(x, y)
Definition: sysdefs.h:186
@ LZMA_MEM_ERROR
Cannot allocate memory.
Definition: base.h:128
@ LZMA_OPTIONS_ERROR
Invalid or unsupported options.
Definition: base.h:160

References allocator, lzma_stream_coder::block_decoder, lzma_next_coder_s::code, lzma_next_coder_s::coder, lzma_stream_coder::concatenated, lzma_next_coder_s::end, lzma_stream_coder::first_stream, flags, lzma_next_coder_s::get_check, lzma_stream_coder::ignore_check, lzma_stream_coder::index_hash, lzma_alloc(), LZMA_CONCATENATED, LZMA_IGNORE_CHECK, LZMA_MEM_ERROR, LZMA_MEMUSAGE_BASE, LZMA_NEXT_CODER_INIT, lzma_next_coder_init, LZMA_OPTIONS_ERROR, LZMA_SUPPORTED_FLAGS, LZMA_TELL_ANY_CHECK, LZMA_TELL_NO_CHECK, LZMA_TELL_UNSUPPORTED_CHECK, lzma_next_coder_s::memconfig, memlimit, lzma_stream_coder::memlimit, lzma_stream_coder::memusage, my_max, NULL, stream_decode(), stream_decoder_end(), stream_decoder_get_check(), stream_decoder_memconfig(), stream_decoder_reset(), lzma_stream_coder::tell_any_check, lzma_stream_coder::tell_no_check, and lzma_stream_coder::tell_unsupported_check.

Referenced by auto_decode(), and LZMA_API().