Data Structures | Functions

/tmp/buildd/xz-utils-5.0.0/src/liblzma/common/index_decoder.c File Reference

Decodes the Index field. More...

#include "index.h"
#include "check.h"

Data Structures

struct  lzma_coder_s

Functions

static lzma_ret index_decode (lzma_coder *coder, 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 (lzma_coder *coder, lzma_allocator *allocator)
static lzma_ret index_decoder_memconfig (lzma_coder *coder, uint64_t *memusage, uint64_t *old_memlimit, uint64_t new_memlimit)
static lzma_ret index_decoder_reset (lzma_coder *coder, lzma_allocator *allocator, lzma_index **i, uint64_t memlimit)
static lzma_ret index_decoder_init (lzma_next_coder *next, 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.
lzma_ret lzma_index_buffer_decode (lzma_index **i, uint64_t *memlimit, lzma_allocator *allocator, const uint8_t *in, size_t *in_pos, size_t in_size)
 Single-call .xz Index decoder.

Detailed Description

Decodes the Index field.


Function Documentation

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

Initialize .xz Index decoder.

Parameters:
strm Pointer to properly prepared lzma_stream
i The 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().
memlimit How much memory the resulting lzma_index is allowed to require.

The valid `action' values for lzma_code() are LZMA_RUN and LZMA_FINISH. It is enough to use only one of them (you can choose freely; use LZMA_RUN to support liblzma versions older than 5.0.0).

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

References lzma_next_strm_init.

Referenced by parse_indexes().

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

Single-call .xz Index decoder.

Parameters:
i If 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.
memlimit Pointer 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.
allocator Pointer to lzma_allocator, or NULL to use malloc()
in Beginning of the input buffer
in_pos The next byte will be read from in[*in_pos]. *in_pos is updated only if decoding succeeds.
in_size Size 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

References lzma_coder_s::count, lzma_coder_s::index, lzma_index_end(), lzma_index_memusage(), LZMA_OK, LZMA_RUN, LZMA_STREAM_END, and return_if_error.