index_encoder.c File Reference

Encodes the Index field. More...

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

## Data Structures

struct | lzma_index_coder

## Functions

static lzma_ret | index_encode (void *coder_ptr, const 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 (void *coder, const lzma_allocator *allocator)
static void | index_encoder_reset (lzma_index_coder *coder, const lzma_index *i)
lzma_ret | lzma_index_encoder_init (lzma_next_coder *next, const lzma_allocator *allocator, const lzma_index *i)
lzma_ret | lzma_index_encoder (lzma_stream *strm, const lzma_index *i)
| Initialize .xz Index encoder. More...
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. More...

## Detailed Description

Encodes the Index field.

## Function Documentation

## lzma_index_encoder()

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).

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

References lzma_next_strm_init.

## lzma_index_buffer_encode()

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_BUF_ERROR, lzma_index_size(), and LZMA_PROG_ERROR.