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

Autodetect between .xz, .lzma (LZMA_Alone), and .lz (lzip) More...

#include "stream_decoder.h"
#include "alone_decoder.h"

Data Structures

struct  lzma_auto_coder
 

Functions

static lzma_ret auto_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 auto_decoder_end (void *coder_ptr, const lzma_allocator *allocator)
 
static lzma_check auto_decoder_get_check (const void *coder_ptr)
 
static lzma_ret auto_decoder_memconfig (void *coder_ptr, uint64_t *memusage, uint64_t *old_memlimit, uint64_t new_memlimit)
 
static lzma_ret auto_decoder_init (lzma_next_coder *next, const lzma_allocator *allocator, uint64_t memlimit, uint32_t flags)
 
lzma_ret lzma_auto_decoder (lzma_stream *strm, uint64_t memlimit, uint32_t flags)
 Decode .xz, .lzma, and .lz (lzip) files with autodetection. More...
 

Detailed Description

Autodetect between .xz, .lzma (LZMA_Alone), and .lz (lzip)

Function Documentation

◆ lzma_auto_decoder()

lzma_ret lzma_auto_decoder ( lzma_stream strm,
uint64_t  memlimit,
uint32_t  flags 
)

Decode .xz, .lzma, and .lz (lzip) files with autodetection.

This decoder autodetects between the .xz, .lzma, and .lz file formats, and calls lzma_stream_decoder(), lzma_alone_decoder(), or lzma_lzip_decoder() once the type of the input file has been detected.

Support for .lz was added in 5.4.0.

If the flag LZMA_CONCATENATED is used and the input is a .lzma file: For historical reasons concatenated .lzma files aren't supported. If there is trailing data after one .lzma stream, lzma_code() will return LZMA_DATA_ERROR. (lzma_alone_decoder() doesn't have such a check as it doesn't support any decoder flags. It will return LZMA_STREAM_END after one .lzma stream.)

Parameters
strmPointer to properly prepared lzma_stream
memlimitMemory usage limit as bytes. Use UINT64_MAX to effectively disable the limiter. 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.
flagsBitwise-or of zero or more of the decoder flags: LZMA_TELL_NO_CHECK, LZMA_TELL_UNSUPPORTED_CHECK, LZMA_TELL_ANY_CHECK, LZMA_IGNORE_CHECK, LZMA_CONCATENATED, LZMA_FAIL_FAST
Returns
- LZMA_OK: Initialization was successful.
  • LZMA_MEM_ERROR: Cannot allocate memory.
  • LZMA_OPTIONS_ERROR: Unsupported flags
  • LZMA_PROG_ERROR

References lzma_next_strm_init.