Handling of .xz Index lists. More...
Data Structures | |
struct | lzma_index_record |
Index Record and its location. More... | |
Typedefs | |
typedef struct lzma_index_s | lzma_index |
Opaque data type to hold the Index. | |
Functions | |
LZMA_API (uint64_t) lzma_index_memusage(lzma_vli record_count) | |
Calculate memory usage for Index with given number of Records. | |
LZMA_API (lzma_index *) lzma_index_init(lzma_index *i | |
Allocate and initialize a new lzma_index structure. | |
LZMA_API (void) lzma_index_end(lzma_index *i | |
Deallocate the Index. | |
LZMA_API (lzma_ret) lzma_index_append(lzma_index *i | |
Add a new Record to an Index. | |
LZMA_API (lzma_bool) lzma_index_read(lzma_index *i | |
Get the next Record from the Index. | |
Variables | |
lzma_allocator *allocator | lzma_attr_warn_unused_result |
lzma_allocator * | allocator |
lzma_allocator lzma_vli | unpadded_size |
lzma_index_record * | record |
lzma_index *lzma_restrict | src |
const lzma_index *b | lzma_attr_pure |
lzma_index ** | i |
uint8_t * | out |
uint8_t size_t * | out_pos |
uint8_t size_t size_t | out_size |
uint64_t * | memlimit |
uint64_t lzma_allocator const uint8_t * | in |
uint64_t lzma_allocator const uint8_t size_t * | in_pos |
uint64_t lzma_allocator const uint8_t size_t size_t | in_size |
Handling of .xz Index lists.
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
typedef struct lzma_index_s lzma_index |
Opaque data type to hold the Index.
LZMA_API | ( | uint64_t | ) |
Calculate memory usage for Index with given number of Records.
Get the uncompressed size of the Stream.
Get the total size of the file.
Get the total size of the Stream.
Get the total size of the Blocks.
Get the size of the Index field as bytes.
Get the number of Records.
On disk, the size of the Index field depends on both the number of Records stored and how big values the Records store (due to variable-length integer encoding). When the Index is kept in lzma_index structure, the memory usage depends only on the number of Records stored in the Index. The size in RAM is almost always a lot bigger than in encoded form on disk.
This function calculates an approximate amount of memory needed hold the given number of Records in lzma_index structure. This value may vary between liblzma versions if the internal implementation is modified.
If you want to know how much memory an existing lzma_index structure is using, use lzma_index_memusage(lzma_index_count(i)).
This is needed to verify the Backward Size field in the Stream Footer.
This doesn't include the Stream Header, Stream Footer, Stream Padding, or Index fields.
If multiple Indexes have been combined, this works as if the Blocks were in a single Stream.
When no Indexes have been combined with lzma_index_cat(), this function is identical to lzma_index_stream_size(). If multiple Indexes have been combined, this includes also the headers of each separate Stream and the possible Stream Padding fields.
Calculate memory usage for Index with given number of Records.
Calculate rough decoder memory usage of a preset.
This function is a wrapper for lzma_raw_encoder_memusage().
preset | Compression preset (level and possible flags) |
This function is a wrapper for lzma_raw_decoder_memusage().
preset | Compression preset (level and possible flags) |
References lzma_filter_encoder::chunk_size, lzma_coder_s::filters, and LZMA_VLI_UNKNOWN.
LZMA_API | ( | lzma_index * | ) |
Allocate and initialize a new lzma_index structure.
Duplicate an Index list.
If i is NULL, a new lzma_index structure is allocated, initialized, and a pointer to it returned. If allocation fails, NULL is returned.
If i 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 i that was given as an argument.
Makes an identical copy of the Index. Also the read position is copied.
References lzma_index_s::current, lzma_index_s::group, lzma_index_s::head, lzma_index_group_s::last, lzma_alloc(), lzma_index_group_s::next, lzma_index_group_s::paddings, lzma_index_group_s::prev, lzma_index_s::tail, lzma_index_group_s::uncompressed_sums, and lzma_index_group_s::unpadded_sums.
LZMA_API | ( | void | ) |
Deallocate the Index.
Free memory allocated for the coder data structures.
Rewind the Index.
If i is NULL, this does nothing.
Rewind the Index so that next call to lzma_index_read() will return the first Record.
LZMA_API | ( | lzma_ret | ) |
Add a new Record to an Index.
Single-call Index decoder.
Single-call Index encoder.
Initialize Index decoder.
Initialize Index encoder.
Concatenate Indexes of two Streams.
i | Pointer to a lzma_index structure | |
allocator | Pointer to lzma_allocator, or NULL to use malloc() | |
unpadded_size | Unpadded Size of a Block. This can be calculated with lzma_block_unpadded_size() after encoding or decoding the Block. | |
uncompressed_size | Uncompressed Size of a Block. This can be taken directly from lzma_block structure after encoding or decoding the Block. |
Appending a new Record does not affect the read position.
dest | Destination Index after which src is appended | |
src | Source Index. The memory allocated for this is either moved to be part of *dest or freed if and only if the function call succeeds, and src will be an invalid pointer. | |
allocator | Custom memory allocator; can be NULL to use malloc() and free(). | |
padding | Size of the Stream Padding field between Streams. This must be a multiple of four. |
strm | Pointer to properly prepared lzma_stream | |
i | Pointer to lzma_index which should be encoded. The read position will be at the end of the Index after lzma_code() has returned LZMA_STREAM_END. |
The only valid action value for lzma_code() is LZMA_RUN.
strm | Pointer to properly prepared lzma_stream | |
i | Pointer to a pointer that will be made to point to the final decoded Index once lzma_code() has returned LZMA_STREAM_END. That is, lzma_index_decoder() always takes care of allocating a new lzma_index structure, and *i doesn't need to be initialized by the caller. | |
memlimit | How much memory the resulting Index is allowed to require. |
The only valid action value for lzma_code() is LZMA_RUN.
i | Index to be encoded. The read position will be at the end of the Index if encoding succeeds, or at unspecified position in case an error occurs. | |
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]. |
i | Pointer to a pointer that will be made to point to the final decoded Index if decoding is successful. That is, lzma_index_buffer_decode() always takes care of allocating a new lzma_index structure, and *i doesn't need to be initialized by the caller. | |
memlimit | Pointer to how much memory the resulting Index is allowed to require. The value pointed by this pointer is modified if and only if LZMA_MEMLIMIT_ERROR is returned. | |
allocator | Pointer to lzma_allocator, or NULL to use malloc() | |
in | Beginning of the input buffer | |
in_pos | The next byte will be read from in[*in_pos]. *in_pos is updated only if decoding succeeds. | |
in_size | Size of the input buffer; the first byte that won't be read is in[in_size]. |
LZMA_API | ( | lzma_bool | ) |
Get the next Record from the Index.
Test if the given Filter ID is supported for encoding.
Test if the given Check ID is supported.
Compare if two Index lists are identical.
Locate a Record.
When the Index is available, it is possible to do random-access reading with granularity of Block size.
i | Pointer to lzma_index structure | |
record | Pointer to a structure to hold the search results | |
target | Uncompressed target offset which the caller would like to locate from the Stream |
If the target is smaller than the uncompressed size of the Stream (can be checked with lzma_index_uncompressed_size()):
If target is greater than the uncompressed size of the Stream, *record and the read position are not modified, and this function returns true.