XZ Utils
5.2.5
|
Validates Index by using a hash function. More...
Data Structures | |
struct | lzma_index_hash_info |
struct | lzma_index_hash_s |
Functions | |
lzma_index_hash * | lzma_index_hash_init (lzma_index_hash *index_hash, const lzma_allocator *allocator) |
Allocate and initialize a new lzma_index_hash structure. More... | |
void | lzma_index_hash_end (lzma_index_hash *index_hash, const lzma_allocator *allocator) |
Deallocate lzma_index_hash structure. More... | |
lzma_vli | lzma_index_hash_size (const lzma_index_hash *index_hash) |
Get the size of the Index field as bytes. More... | |
static lzma_ret | hash_append (lzma_index_hash_info *info, lzma_vli unpadded_size, lzma_vli uncompressed_size) |
Updates the sizes and the hash without any validation. More... | |
lzma_ret | lzma_index_hash_append (lzma_index_hash *index_hash, lzma_vli unpadded_size, lzma_vli uncompressed_size) |
Add a new Record to an Index hash. More... | |
lzma_ret | lzma_index_hash_decode (lzma_index_hash *index_hash, const uint8_t *in, size_t *in_pos, size_t in_size) |
Decode and validate the Index field. More... | |
Validates Index by using a hash function.
lzma_index_hash* lzma_index_hash_init | ( | lzma_index_hash * | index_hash, |
const lzma_allocator * | allocator | ||
) |
Allocate and initialize a new lzma_index_hash structure.
If index_hash is NULL, a new lzma_index_hash structure is allocated, initialized, and a pointer to it returned. If allocation fails, NULL is returned.
If index_hash is non-NULL, it is reinitialized and the same pointer returned. In this case, return value cannot be NULL or a different pointer than the index_hash that was given as an argument.
void lzma_index_hash_end | ( | lzma_index_hash * | index_hash, |
const lzma_allocator * | allocator | ||
) |
Deallocate lzma_index_hash structure.
lzma_vli lzma_index_hash_size | ( | const lzma_index_hash * | index_hash | ) |
Get the size of the Index field as bytes.
This is needed to verify the Backward Size field in the Stream Footer.
|
static |
Updates the sizes and the hash without any validation.
References lzma_index_hash_info::blocks_size, lzma_index_hash_info::check, lzma_index_hash_info::count, lzma_index_hash_info::index_list_size, lzma_check_update(), LZMA_OK, lzma_vli_size(), lzma_index_hash_info::uncompressed_size, lzma_index_hash_s::uncompressed_size, and lzma_index_hash_s::unpadded_size.
Referenced by lzma_index_hash_append(), and lzma_index_hash_decode().
lzma_ret lzma_index_hash_append | ( | lzma_index_hash * | index_hash, |
lzma_vli | unpadded_size, | ||
lzma_vli | uncompressed_size | ||
) |
Add a new Record to an Index hash.
index | Pointer to a lzma_index_hash structure |
unpadded_size | Unpadded Size of a Block |
uncompressed_size | Uncompressed Size of a Block |
References hash_append(), LZMA_PROG_ERROR, LZMA_VLI_MAX, return_if_error, lzma_index_hash_s::uncompressed_size, and lzma_index_hash_s::unpadded_size.
lzma_ret lzma_index_hash_decode | ( | lzma_index_hash * | index_hash, |
const uint8_t * | in, | ||
size_t * | in_pos, | ||
size_t | in_size | ||
) |
Decode and validate the Index field.
After telling the sizes of all Blocks with lzma_index_hash_append(), the actual Index field is decoded with this function. Specifically, once decoding of the Index field has been started, no more Records can be added using lzma_index_hash_append().
This function doesn't use lzma_stream structure to pass the input data. Instead, the input buffer is specified using three arguments. This is because it matches better the internal APIs of liblzma.
index_hash | Pointer to a lzma_index_hash structure |
in | Pointer to the beginning of the input buffer |
in_pos | in[*in_pos] is the next byte to process |
in_size | in[in_size] is the first byte not to process |
References hash_append(), LZMA_BUF_ERROR, lzma_check_finish(), lzma_check_size(), lzma_crc32(), LZMA_DATA_ERROR, LZMA_OK, LZMA_STREAM_END, LZMA_VLI_C, lzma_vli_decode(), and return_if_error.