XZ Utils  5.2.4
Functions
block_header_decoder.c File Reference

Decodes Block Header from .xz files. More...

#include "common.h"
#include "check.h"

Functions

static void free_properties (lzma_block *block, const lzma_allocator *allocator)
 
lzma_ret lzma_block_header_decode (lzma_block *block, const lzma_allocator *allocator, const uint8_t *in)
 Decode Block Header. More...
 

Detailed Description

Decodes Block Header from .xz files.

Function Documentation

◆ lzma_block_header_decode()

lzma_ret lzma_block_header_decode ( lzma_block block,
const lzma_allocator allocator,
const uint8_t *  in 
)

Decode Block Header.

block->version should (usually) be set to the highest value supported by the application. If the application sets block->version to a value higher than supported by the current liblzma version, this function will downgrade block->version to the highest value supported by it. Thus one should check the value of block->version after calling this function if block->version was set to a non-zero value and the application doesn't otherwise know that the liblzma version being used is new enough to support the specified block->version.

The size of the Block Header must have already been decoded with lzma_block_header_size_decode() macro and stored to block->header_size.

The integrity check type from Stream Header must have been stored to block->check.

block->filters must have been allocated, but they don't need to be initialized (possible existing filter options are not freed).

Parameters
blockDestination for Block options.
allocatorlzma_allocator for custom allocator functions. Set to NULL to use malloc() (and also free() if an error occurs).
inBeginning of the input buffer. This must be at least block->header_size bytes.
Returns
- LZMA_OK: Decoding was successful. block->header_size bytes were read from the input buffer.
  • LZMA_OPTIONS_ERROR: The Block Header specifies some unsupported options such as unsupported filters. This can happen also if block->version was set to a too low value compared to what would be required to properly represent the information stored in the Block Header.
  • LZMA_DATA_ERROR: Block Header is corrupt, for example, the CRC32 doesn't match.
  • LZMA_PROG_ERROR: Invalid arguments, for example block->header_size is invalid or block->filters is NULL.