Data Structures | Functions

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

Encodes the Index field. More...

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

Data Structures

struct  lzma_coder_s

Functions

static lzma_ret index_encode (lzma_coder *coder, lzma_allocator *allocator lzma_attribute((unused)), const uint8_t *restrict in lzma_attribute((unused)), size_t *restrict in_pos lzma_attribute((unused)), size_t in_size lzma_attribute((unused)), uint8_t *restrict out, size_t *restrict out_pos, size_t out_size, lzma_action action lzma_attribute((unused)))
static void index_encoder_end (lzma_coder *coder, lzma_allocator *allocator)
static void index_encoder_reset (lzma_coder *coder, const lzma_index *i)
lzma_ret lzma_index_encoder_init (lzma_next_coder *next, lzma_allocator *allocator, const lzma_index *i)
lzma_ret lzma_index_encoder (lzma_stream *strm, const lzma_index *i)
 Initialize .xz Index encoder.
lzma_ret lzma_index_buffer_encode (const lzma_index *i, uint8_t *out, size_t *out_pos, size_t out_size)
 Single-call .xz Index encoder.

Detailed Description

Encodes the Index field.


Function Documentation

lzma_ret lzma_index_encoder ( lzma_stream strm,
const lzma_index i 
)

Initialize .xz Index encoder.

Parameters:
strm Pointer to properly prepared lzma_stream
i Pointer to lzma_index which should be encoded.

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_PROG_ERROR

References lzma_next_strm_init.

lzma_ret lzma_index_buffer_encode ( const lzma_index i,
uint8_t *  out,
size_t *  out_pos,
size_t  out_size 
)

Single-call .xz Index encoder.

Parameters:
i lzma_index to be encoded
out Beginning of the output buffer
out_pos The next byte will be written to out[*out_pos]. *out_pos is updated only if encoding succeeds.
out_size Size of the out buffer; the first byte into which no data is written to is out[out_size].
Returns:
- LZMA_OK: Encoding was successful.
  • LZMA_BUF_ERROR: Output buffer is too small. Use lzma_index_size() to find out how much output space is needed.
  • LZMA_PROG_ERROR
Note:
This function doesn't take allocator argument since all the internal data is allocated on stack.

References lzma_index_size(), LZMA_RUN, and LZMA_STREAM_END.

Referenced by lzma_stream_buffer_encode().