XZ Utils 5.4.1
Data Structures | Functions
index_decoder.c File Reference

Decodes the Index field. More...

#include "index_decoder.h"
#include "check.h"

Data Structures

struct  lzma_index_coder
 

Functions

static lzma_ret index_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 lzma_attribute((__unused__)), size_t *restrict out_pos lzma_attribute((__unused__)), size_t out_size lzma_attribute((__unused__)), lzma_action action lzma_attribute((__unused__)))
 
static void index_decoder_end (void *coder_ptr, const lzma_allocator *allocator)
 
static lzma_ret index_decoder_memconfig (void *coder_ptr, uint64_t *memusage, uint64_t *old_memlimit, uint64_t new_memlimit)
 
static lzma_ret index_decoder_reset (lzma_index_coder *coder, const lzma_allocator *allocator, lzma_index **i, uint64_t memlimit)
 
lzma_ret lzma_index_decoder_init (lzma_next_coder *next, const lzma_allocator *allocator, lzma_index **i, uint64_t memlimit)
 
lzma_ret lzma_index_decoder (lzma_stream *strm, lzma_index **i, uint64_t memlimit)
 Initialize .xz Index decoder. More...
 
lzma_ret lzma_index_buffer_decode (lzma_index **i, uint64_t *memlimit, const lzma_allocator *allocator, const uint8_t *in, size_t *in_pos, size_t in_size)
 Single-call .xz Index decoder. More...
 

Detailed Description

Decodes the Index field.

Function Documentation

◆ lzma_index_decoder()

lzma_ret lzma_index_decoder ( lzma_stream strm,
lzma_index **  i,
uint64_t  memlimit 
)

Initialize .xz Index decoder.

Parameters
strmPointer to properly prepared lzma_stream
iThe decoded Index will be made available via this pointer. Initially this function will set *i to NULL (the old value is ignored). If decoding succeeds (lzma_code() returns LZMA_STREAM_END), *i will be set to point to a new lzma_index, which the application has to later free with lzma_index_end().
memlimitHow much memory the resulting lzma_index is allowed to require. liblzma 5.2.3 and earlier don't allow 0 here and return LZMA_PROG_ERROR; later versions treat 0 as if 1 had been specified.

Valid ‘action’ arguments to lzma_code() are LZMA_RUN and LZMA_FINISH. There is no need to use LZMA_FINISH, but it's allowed because it may simplify certain types of applications.

Returns
- LZMA_OK: Initialization succeeded, continue with lzma_code().
  • LZMA_MEM_ERROR
  • LZMA_PROG_ERROR

liblzma 5.2.3 and older list also LZMA_MEMLIMIT_ERROR here but that error code has never been possible from this initialization function.

References lzma_next_strm_init.

◆ lzma_index_buffer_decode()

lzma_ret lzma_index_buffer_decode ( lzma_index **  i,
uint64_t *  memlimit,
const lzma_allocator allocator,
const uint8_t *  in,
size_t *  in_pos,
size_t  in_size 
)

Single-call .xz Index decoder.

Parameters
iIf decoding succeeds, *i will point to a new lzma_index, which the application has to later free with lzma_index_end(). If an error occurs, *i will be NULL. The old value of *i is always ignored and thus doesn't need to be initialized by the caller.
memlimitPointer to how much memory the resulting lzma_index is allowed to require. The value pointed by this pointer is modified if and only if LZMA_MEMLIMIT_ERROR is returned.
allocatorPointer to lzma_allocator, or NULL to use malloc()
inBeginning of the input buffer
in_posThe next byte will be read from in[*in_pos]. *in_pos is updated only if decoding succeeds.
in_sizeSize of the input buffer; the first byte that won't be read is in[in_size].
Returns
- LZMA_OK: Decoding was successful.
  • LZMA_MEM_ERROR
  • LZMA_MEMLIMIT_ERROR: Memory usage limit was reached. The minimum required memlimit value was stored to *memlimit.
  • LZMA_DATA_ERROR
  • LZMA_PROG_ERROR