Path: blob/master/Utilities/cmliblzma/liblzma/api/lzma/index.h
3158 views
/* SPDX-License-Identifier: 0BSD */12/**3* \file lzma/index.h4* \brief Handling of .xz Index and related information5* \note Never include this file directly. Use <lzma.h> instead.6*/78/*9* Author: Lasse Collin10*/1112#ifndef LZMA_H_INTERNAL13# error Never include this file directly. Use <lzma.h> instead.14#endif151617/**18* \brief Opaque data type to hold the Index(es) and other information19*20* lzma_index often holds just one .xz Index and possibly the Stream Flags21* of the same Stream and size of the Stream Padding field. However,22* multiple lzma_indexes can be concatenated with lzma_index_cat() and then23* there may be information about multiple Streams in the same lzma_index.24*25* Notes about thread safety: Only one thread may modify lzma_index at26* a time. All functions that take non-const pointer to lzma_index27* modify it. As long as no thread is modifying the lzma_index, getting28* information from the same lzma_index can be done from multiple threads29* at the same time with functions that take a const pointer to30* lzma_index or use lzma_index_iter. The same iterator must be used31* only by one thread at a time, of course, but there can be as many32* iterators for the same lzma_index as needed.33*/34typedef struct lzma_index_s lzma_index;353637/**38* \brief Iterator to get information about Blocks and Streams39*/40typedef struct {41struct {42/**43* \brief Pointer to Stream Flags44*45* This is NULL if Stream Flags have not been set for46* this Stream with lzma_index_stream_flags().47*/48const lzma_stream_flags *flags;4950/** \private Reserved member. */51const void *reserved_ptr1;5253/** \private Reserved member. */54const void *reserved_ptr2;5556/** \private Reserved member. */57const void *reserved_ptr3;5859/**60* \brief Stream number in the lzma_index61*62* The first Stream is 1.63*/64lzma_vli number;6566/**67* \brief Number of Blocks in the Stream68*69* If this is zero, the block structure below has70* undefined values.71*/72lzma_vli block_count;7374/**75* \brief Compressed start offset of this Stream76*77* The offset is relative to the beginning of the lzma_index78* (i.e. usually the beginning of the .xz file).79*/80lzma_vli compressed_offset;8182/**83* \brief Uncompressed start offset of this Stream84*85* The offset is relative to the beginning of the lzma_index86* (i.e. usually the beginning of the .xz file).87*/88lzma_vli uncompressed_offset;8990/**91* \brief Compressed size of this Stream92*93* This includes all headers except the possible94* Stream Padding after this Stream.95*/96lzma_vli compressed_size;9798/**99* \brief Uncompressed size of this Stream100*/101lzma_vli uncompressed_size;102103/**104* \brief Size of Stream Padding after this Stream105*106* If it hasn't been set with lzma_index_stream_padding(),107* this defaults to zero. Stream Padding is always108* a multiple of four bytes.109*/110lzma_vli padding;111112113/** \private Reserved member. */114lzma_vli reserved_vli1;115116/** \private Reserved member. */117lzma_vli reserved_vli2;118119/** \private Reserved member. */120lzma_vli reserved_vli3;121122/** \private Reserved member. */123lzma_vli reserved_vli4;124} stream;125126struct {127/**128* \brief Block number in the file129*130* The first Block is 1.131*/132lzma_vli number_in_file;133134/**135* \brief Compressed start offset of this Block136*137* This offset is relative to the beginning of the138* lzma_index (i.e. usually the beginning of the .xz file).139* Normally this is where you should seek in the .xz file140* to start decompressing this Block.141*/142lzma_vli compressed_file_offset;143144/**145* \brief Uncompressed start offset of this Block146*147* This offset is relative to the beginning of the lzma_index148* (i.e. usually the beginning of the .xz file).149*150* When doing random-access reading, it is possible that151* the target offset is not exactly at Block boundary. One152* will need to compare the target offset against153* uncompressed_file_offset or uncompressed_stream_offset,154* and possibly decode and throw away some amount of data155* before reaching the target offset.156*/157lzma_vli uncompressed_file_offset;158159/**160* \brief Block number in this Stream161*162* The first Block is 1.163*/164lzma_vli number_in_stream;165166/**167* \brief Compressed start offset of this Block168*169* This offset is relative to the beginning of the Stream170* containing this Block.171*/172lzma_vli compressed_stream_offset;173174/**175* \brief Uncompressed start offset of this Block176*177* This offset is relative to the beginning of the Stream178* containing this Block.179*/180lzma_vli uncompressed_stream_offset;181182/**183* \brief Uncompressed size of this Block184*185* You should pass this to the Block decoder if you will186* decode this Block. It will allow the Block decoder to187* validate the uncompressed size.188*/189lzma_vli uncompressed_size;190191/**192* \brief Unpadded size of this Block193*194* You should pass this to the Block decoder if you will195* decode this Block. It will allow the Block decoder to196* validate the unpadded size.197*/198lzma_vli unpadded_size;199200/**201* \brief Total compressed size202*203* This includes all headers and padding in this Block.204* This is useful if you need to know how many bytes205* the Block decoder will actually read.206*/207lzma_vli total_size;208209/** \private Reserved member. */210lzma_vli reserved_vli1;211212/** \private Reserved member. */213lzma_vli reserved_vli2;214215/** \private Reserved member. */216lzma_vli reserved_vli3;217218/** \private Reserved member. */219lzma_vli reserved_vli4;220221/** \private Reserved member. */222const void *reserved_ptr1;223224/** \private Reserved member. */225const void *reserved_ptr2;226227/** \private Reserved member. */228const void *reserved_ptr3;229230/** \private Reserved member. */231const void *reserved_ptr4;232} block;233234/**235* \private Internal data236*237* Internal data which is used to store the state of the iterator.238* The exact format may vary between liblzma versions, so don't239* touch these in any way.240*/241union {242/** \private Internal member. */243const void *p;244245/** \private Internal member. */246size_t s;247248/** \private Internal member. */249lzma_vli v;250} internal[6];251} lzma_index_iter;252253254/**255* \brief Operation mode for lzma_index_iter_next()256*/257typedef enum {258LZMA_INDEX_ITER_ANY = 0,259/**<260* \brief Get the next Block or Stream261*262* Go to the next Block if the current Stream has at least263* one Block left. Otherwise go to the next Stream even if264* it has no Blocks. If the Stream has no Blocks265* (lzma_index_iter.stream.block_count == 0),266* lzma_index_iter.block will have undefined values.267*/268269LZMA_INDEX_ITER_STREAM = 1,270/**<271* \brief Get the next Stream272*273* Go to the next Stream even if the current Stream has274* unread Blocks left. If the next Stream has at least one275* Block, the iterator will point to the first Block.276* If there are no Blocks, lzma_index_iter.block will have277* undefined values.278*/279280LZMA_INDEX_ITER_BLOCK = 2,281/**<282* \brief Get the next Block283*284* Go to the next Block if the current Stream has at least285* one Block left. If the current Stream has no Blocks left,286* the next Stream with at least one Block is located and287* the iterator will be made to point to the first Block of288* that Stream.289*/290291LZMA_INDEX_ITER_NONEMPTY_BLOCK = 3292/**<293* \brief Get the next non-empty Block294*295* This is like LZMA_INDEX_ITER_BLOCK except that it will296* skip Blocks whose Uncompressed Size is zero.297*/298299} lzma_index_iter_mode;300301302/**303* \brief Mask for return value from lzma_index_checks() for check none304*305* \note This and the other CHECK_MASK macros were added in 5.5.1alpha.306*/307#define LZMA_INDEX_CHECK_MASK_NONE (UINT32_C(1) << LZMA_CHECK_NONE)308309/**310* \brief Mask for return value from lzma_index_checks() for check CRC32311*/312#define LZMA_INDEX_CHECK_MASK_CRC32 (UINT32_C(1) << LZMA_CHECK_CRC32)313314/**315* \brief Mask for return value from lzma_index_checks() for check CRC64316*/317#define LZMA_INDEX_CHECK_MASK_CRC64 (UINT32_C(1) << LZMA_CHECK_CRC64)318319/**320* \brief Mask for return value from lzma_index_checks() for check SHA256321*/322#define LZMA_INDEX_CHECK_MASK_SHA256 (UINT32_C(1) << LZMA_CHECK_SHA256)323324/**325* \brief Calculate memory usage of lzma_index326*327* On disk, the size of the Index field depends on both the number of Records328* stored and the size of the Records (due to variable-length integer329* encoding). When the Index is kept in lzma_index structure, the memory usage330* depends only on the number of Records/Blocks stored in the Index(es), and331* in case of concatenated lzma_indexes, the number of Streams. The size in332* RAM is almost always significantly bigger than in the encoded form on disk.333*334* This function calculates an approximate amount of memory needed to hold335* the given number of Streams and Blocks in lzma_index structure. This336* value may vary between CPU architectures and also between liblzma versions337* if the internal implementation is modified.338*339* \param streams Number of Streams340* \param blocks Number of Blocks341*342* \return Approximate memory in bytes needed in a lzma_index structure.343*/344extern LZMA_API(uint64_t) lzma_index_memusage(345lzma_vli streams, lzma_vli blocks) lzma_nothrow;346347348/**349* \brief Calculate the memory usage of an existing lzma_index350*351* This is a shorthand for lzma_index_memusage(lzma_index_stream_count(i),352* lzma_index_block_count(i)).353*354* \param i Pointer to lzma_index structure355*356* \return Approximate memory in bytes used by the lzma_index structure.357*/358extern LZMA_API(uint64_t) lzma_index_memused(const lzma_index *i)359lzma_nothrow;360361362/**363* \brief Allocate and initialize a new lzma_index structure364*365* \param allocator lzma_allocator for custom allocator functions.366* Set to NULL to use malloc() and free().367*368* \return On success, a pointer to an empty initialized lzma_index is369* returned. If allocation fails, NULL is returned.370*/371extern LZMA_API(lzma_index *) lzma_index_init(const lzma_allocator *allocator)372lzma_nothrow;373374375/**376* \brief Deallocate lzma_index377*378* If i is NULL, this does nothing.379*380* \param i Pointer to lzma_index structure to deallocate381* \param allocator lzma_allocator for custom allocator functions.382* Set to NULL to use malloc() and free().383*/384extern LZMA_API(void) lzma_index_end(385lzma_index *i, const lzma_allocator *allocator) lzma_nothrow;386387388/**389* \brief Add a new Block to lzma_index390*391* \param i Pointer to a lzma_index structure392* \param allocator lzma_allocator for custom allocator393* functions. Set to NULL to use malloc()394* and free().395* \param unpadded_size Unpadded Size of a Block. This can be396* calculated with lzma_block_unpadded_size()397* after encoding or decoding the Block.398* \param uncompressed_size Uncompressed Size of a Block. This can be399* taken directly from lzma_block structure400* after encoding or decoding the Block.401*402* Appending a new Block does not invalidate iterators. For example,403* if an iterator was pointing to the end of the lzma_index, after404* lzma_index_append() it is possible to read the next Block with405* an existing iterator.406*407* \return Possible lzma_ret values:408* - LZMA_OK409* - LZMA_MEM_ERROR410* - LZMA_DATA_ERROR: Compressed or uncompressed size of the411* Stream or size of the Index field would grow too big.412* - LZMA_PROG_ERROR413*/414extern LZMA_API(lzma_ret) lzma_index_append(415lzma_index *i, const lzma_allocator *allocator,416lzma_vli unpadded_size, lzma_vli uncompressed_size)417lzma_nothrow lzma_attr_warn_unused_result;418419420/**421* \brief Set the Stream Flags422*423* Set the Stream Flags of the last (and typically the only) Stream424* in lzma_index. This can be useful when reading information from the425* lzma_index, because to decode Blocks, knowing the integrity check type426* is needed.427*428* \param i Pointer to lzma_index structure429* \param stream_flags Pointer to lzma_stream_flags structure. This430* is copied into the internal preallocated431* structure, so the caller doesn't need to keep432* the flags' data available after calling this433* function.434*435* \return Possible lzma_ret values:436* - LZMA_OK437* - LZMA_OPTIONS_ERROR: Unsupported stream_flags->version.438* - LZMA_PROG_ERROR439*/440extern LZMA_API(lzma_ret) lzma_index_stream_flags(441lzma_index *i, const lzma_stream_flags *stream_flags)442lzma_nothrow lzma_attr_warn_unused_result;443444445/**446* \brief Get the types of integrity Checks447*448* If lzma_index_stream_flags() is used to set the Stream Flags for449* every Stream, lzma_index_checks() can be used to get a bitmask to450* indicate which Check types have been used. It can be useful e.g. if451* showing the Check types to the user.452*453* The bitmask is 1 << check_id, e.g. CRC32 is 1 << 1 and SHA-256 is 1 << 10.454* These masks are defined for convenience as LZMA_INDEX_CHECK_MASK_XXX455*456* \param i Pointer to lzma_index structure457*458* \return Bitmask indicating which Check types are used in the lzma_index459*/460extern LZMA_API(uint32_t) lzma_index_checks(const lzma_index *i)461lzma_nothrow lzma_attr_pure;462463464/**465* \brief Set the amount of Stream Padding466*467* Set the amount of Stream Padding of the last (and typically the only)468* Stream in the lzma_index. This is needed when planning to do random-access469* reading within multiple concatenated Streams.470*471* By default, the amount of Stream Padding is assumed to be zero bytes.472*473* \return Possible lzma_ret values:474* - LZMA_OK475* - LZMA_DATA_ERROR: The file size would grow too big.476* - LZMA_PROG_ERROR477*/478extern LZMA_API(lzma_ret) lzma_index_stream_padding(479lzma_index *i, lzma_vli stream_padding)480lzma_nothrow lzma_attr_warn_unused_result;481482483/**484* \brief Get the number of Streams485*486* \param i Pointer to lzma_index structure487*488* \return Number of Streams in the lzma_index489*/490extern LZMA_API(lzma_vli) lzma_index_stream_count(const lzma_index *i)491lzma_nothrow lzma_attr_pure;492493494/**495* \brief Get the number of Blocks496*497* This returns the total number of Blocks in lzma_index. To get number498* of Blocks in individual Streams, use lzma_index_iter.499*500* \param i Pointer to lzma_index structure501*502* \return Number of blocks in the lzma_index503*/504extern LZMA_API(lzma_vli) lzma_index_block_count(const lzma_index *i)505lzma_nothrow lzma_attr_pure;506507508/**509* \brief Get the size of the Index field as bytes510*511* This is needed to verify the Backward Size field in the Stream Footer.512*513* \param i Pointer to lzma_index structure514*515* \return Size in bytes of the Index516*/517extern LZMA_API(lzma_vli) lzma_index_size(const lzma_index *i)518lzma_nothrow lzma_attr_pure;519520521/**522* \brief Get the total size of the Stream523*524* If multiple lzma_indexes have been combined, this works as if the Blocks525* were in a single Stream. This is useful if you are going to combine526* Blocks from multiple Streams into a single new Stream.527*528* \param i Pointer to lzma_index structure529*530* \return Size in bytes of the Stream (if all Blocks are combined531* into one Stream).532*/533extern LZMA_API(lzma_vli) lzma_index_stream_size(const lzma_index *i)534lzma_nothrow lzma_attr_pure;535536537/**538* \brief Get the total size of the Blocks539*540* This doesn't include the Stream Header, Stream Footer, Stream Padding,541* or Index fields.542*543* \param i Pointer to lzma_index structure544*545* \return Size in bytes of all Blocks in the Stream(s)546*/547extern LZMA_API(lzma_vli) lzma_index_total_size(const lzma_index *i)548lzma_nothrow lzma_attr_pure;549550551/**552* \brief Get the total size of the file553*554* When no lzma_indexes have been combined with lzma_index_cat() and there is555* no Stream Padding, this function is identical to lzma_index_stream_size().556* If multiple lzma_indexes have been combined, this includes also the headers557* of each separate Stream and the possible Stream Padding fields.558*559* \param i Pointer to lzma_index structure560*561* \return Total size of the .xz file in bytes562*/563extern LZMA_API(lzma_vli) lzma_index_file_size(const lzma_index *i)564lzma_nothrow lzma_attr_pure;565566567/**568* \brief Get the uncompressed size of the file569*570* \param i Pointer to lzma_index structure571*572* \return Size in bytes of the uncompressed data in the file573*/574extern LZMA_API(lzma_vli) lzma_index_uncompressed_size(const lzma_index *i)575lzma_nothrow lzma_attr_pure;576577578/**579* \brief Initialize an iterator580*581* This function associates the iterator with the given lzma_index, and calls582* lzma_index_iter_rewind() on the iterator.583*584* This function doesn't allocate any memory, thus there is no585* lzma_index_iter_end(). The iterator is valid as long as the586* associated lzma_index is valid, that is, until lzma_index_end() or587* using it as source in lzma_index_cat(). Specifically, lzma_index doesn't588* become invalid if new Blocks are added to it with lzma_index_append() or589* if it is used as the destination in lzma_index_cat().590*591* It is safe to make copies of an initialized lzma_index_iter, for example,592* to easily restart reading at some particular position.593*594* \param iter Pointer to a lzma_index_iter structure595* \param i lzma_index to which the iterator will be associated596*/597extern LZMA_API(void) lzma_index_iter_init(598lzma_index_iter *iter, const lzma_index *i) lzma_nothrow;599600601/**602* \brief Rewind the iterator603*604* Rewind the iterator so that next call to lzma_index_iter_next() will605* return the first Block or Stream.606*607* \param iter Pointer to a lzma_index_iter structure608*/609extern LZMA_API(void) lzma_index_iter_rewind(lzma_index_iter *iter)610lzma_nothrow;611612613/**614* \brief Get the next Block or Stream615*616* \param iter Iterator initialized with lzma_index_iter_init()617* \param mode Specify what kind of information the caller wants618* to get. See lzma_index_iter_mode for details.619*620* \return lzma_bool:621* - true if no Block or Stream matching the mode is found.622* *iter is not updated (failure).623* - false if the next Block or Stream matching the mode was624* found. *iter is updated (success).625*/626extern LZMA_API(lzma_bool) lzma_index_iter_next(627lzma_index_iter *iter, lzma_index_iter_mode mode)628lzma_nothrow lzma_attr_warn_unused_result;629630631/**632* \brief Locate a Block633*634* If it is possible to seek in the .xz file, it is possible to parse635* the Index field(s) and use lzma_index_iter_locate() to do random-access636* reading with granularity of Block size.637*638* If the target is smaller than the uncompressed size of the Stream (can be639* checked with lzma_index_uncompressed_size()):640* - Information about the Stream and Block containing the requested641* uncompressed offset is stored into *iter.642* - Internal state of the iterator is adjusted so that643* lzma_index_iter_next() can be used to read subsequent Blocks or Streams.644*645* If the target is greater than the uncompressed size of the Stream, *iter646* is not modified.647*648* \param iter Iterator that was earlier initialized with649* lzma_index_iter_init().650* \param target Uncompressed target offset which the caller would651* like to locate from the Stream652*653* \return lzma_bool:654* - true if the target is greater than or equal to the655* uncompressed size of the Stream (failure)656* - false if the target is smaller than the uncompressed size657* of the Stream (success)658*/659extern LZMA_API(lzma_bool) lzma_index_iter_locate(660lzma_index_iter *iter, lzma_vli target) lzma_nothrow;661662663/**664* \brief Concatenate lzma_indexes665*666* Concatenating lzma_indexes is useful when doing random-access reading in667* multi-Stream .xz file, or when combining multiple Streams into single668* Stream.669*670* \param[out] dest lzma_index after which src is appended671* \param src lzma_index to be appended after dest. If this672* function succeeds, the memory allocated for src673* is freed or moved to be part of dest, and all674* iterators pointing to src will become invalid.675* \param allocator lzma_allocator for custom allocator functions.676* Set to NULL to use malloc() and free().677*678* \return Possible lzma_ret values:679* - LZMA_OK: lzma_indexes were concatenated successfully.680* src is now a dangling pointer.681* - LZMA_DATA_ERROR: *dest would grow too big.682* - LZMA_MEM_ERROR683* - LZMA_PROG_ERROR684*/685extern LZMA_API(lzma_ret) lzma_index_cat(lzma_index *dest, lzma_index *src,686const lzma_allocator *allocator)687lzma_nothrow lzma_attr_warn_unused_result;688689690/**691* \brief Duplicate lzma_index692*693* \param i Pointer to lzma_index structure to be duplicated694* \param allocator lzma_allocator for custom allocator functions.695* Set to NULL to use malloc() and free().696*697* \return A copy of the lzma_index, or NULL if memory allocation failed.698*/699extern LZMA_API(lzma_index *) lzma_index_dup(700const lzma_index *i, const lzma_allocator *allocator)701lzma_nothrow lzma_attr_warn_unused_result;702703704/**705* \brief Initialize .xz Index encoder706*707* \param strm Pointer to properly prepared lzma_stream708* \param i Pointer to lzma_index which should be encoded.709*710* The valid 'action' values for lzma_code() are LZMA_RUN and LZMA_FINISH.711* It is enough to use only one of them (you can choose freely).712*713* \return Possible lzma_ret values:714* - LZMA_OK: Initialization succeeded, continue with lzma_code().715* - LZMA_MEM_ERROR716* - LZMA_PROG_ERROR717*/718extern LZMA_API(lzma_ret) lzma_index_encoder(719lzma_stream *strm, const lzma_index *i)720lzma_nothrow lzma_attr_warn_unused_result;721722723/**724* \brief Initialize .xz Index decoder725*726* \param strm Pointer to properly prepared lzma_stream727* \param[out] i The decoded Index will be made available via728* this pointer. Initially this function will729* set *i to NULL (the old value is ignored). If730* decoding succeeds (lzma_code() returns731* LZMA_STREAM_END), *i will be set to point732* to a new lzma_index, which the application733* has to later free with lzma_index_end().734* \param memlimit How much memory the resulting lzma_index is735* allowed to require. liblzma 5.2.3 and earlier736* don't allow 0 here and return LZMA_PROG_ERROR;737* later versions treat 0 as if 1 had been specified.738*739* Valid 'action' arguments to lzma_code() are LZMA_RUN and LZMA_FINISH.740* There is no need to use LZMA_FINISH, but it's allowed because it may741* simplify certain types of applications.742*743* \return Possible lzma_ret values:744* - LZMA_OK: Initialization succeeded, continue with lzma_code().745* - LZMA_MEM_ERROR746* - LZMA_PROG_ERROR747*748* \note liblzma 5.2.3 and older list also LZMA_MEMLIMIT_ERROR here749* but that error code has never been possible from this750* initialization function.751*/752extern LZMA_API(lzma_ret) lzma_index_decoder(753lzma_stream *strm, lzma_index **i, uint64_t memlimit)754lzma_nothrow lzma_attr_warn_unused_result;755756757/**758* \brief Single-call .xz Index encoder759*760* \note This function doesn't take allocator argument since all761* the internal data is allocated on stack.762*763* \param i lzma_index to be encoded764* \param[out] out Beginning of the output buffer765* \param[out] out_pos The next byte will be written to out[*out_pos].766* *out_pos is updated only if encoding succeeds.767* \param out_size Size of the out buffer; the first byte into768* which no data is written to is out[out_size].769*770* \return Possible lzma_ret values:771* - LZMA_OK: Encoding was successful.772* - LZMA_BUF_ERROR: Output buffer is too small. Use773* lzma_index_size() to find out how much output774* space is needed.775* - LZMA_PROG_ERROR776*777*/778extern LZMA_API(lzma_ret) lzma_index_buffer_encode(const lzma_index *i,779uint8_t *out, size_t *out_pos, size_t out_size) lzma_nothrow;780781782/**783* \brief Single-call .xz Index decoder784*785* \param[out] i If decoding succeeds, *i will point to a new786* lzma_index, which the application has to787* later free with lzma_index_end(). If an error788* occurs, *i will be NULL. The old value of *i789* is always ignored and thus doesn't need to be790* initialized by the caller.791* \param[out] memlimit Pointer to how much memory the resulting792* lzma_index is allowed to require. The value793* pointed by this pointer is modified if and only794* if LZMA_MEMLIMIT_ERROR is returned.795* \param allocator lzma_allocator for custom allocator functions.796* Set to NULL to use malloc() and free().797* \param in Beginning of the input buffer798* \param in_pos The next byte will be read from in[*in_pos].799* *in_pos is updated only if decoding succeeds.800* \param in_size Size of the input buffer; the first byte that801* won't be read is in[in_size].802*803* \return Possible lzma_ret values:804* - LZMA_OK: Decoding was successful.805* - LZMA_MEM_ERROR806* - LZMA_MEMLIMIT_ERROR: Memory usage limit was reached.807* The minimum required memlimit value was stored to *memlimit.808* - LZMA_DATA_ERROR809* - LZMA_PROG_ERROR810*/811extern LZMA_API(lzma_ret) lzma_index_buffer_decode(lzma_index **i,812uint64_t *memlimit, const lzma_allocator *allocator,813const uint8_t *in, size_t *in_pos, size_t in_size)814lzma_nothrow;815816817/**818* \brief Initialize a .xz file information decoder819*820* This decoder decodes the Stream Header, Stream Footer, Index, and821* Stream Padding field(s) from the input .xz file and stores the resulting822* combined index in *dest_index. This information can be used to get the823* uncompressed file size with lzma_index_uncompressed_size(*dest_index) or,824* for example, to implement random access reading by locating the Blocks825* in the Streams.826*827* To get the required information from the .xz file, lzma_code() may ask828* the application to seek in the input file by returning LZMA_SEEK_NEEDED829* and having the target file position specified in lzma_stream.seek_pos.830* The number of seeks required depends on the input file and how big buffers831* the application provides. When possible, the decoder will seek backward832* and forward in the given buffer to avoid useless seek requests. Thus, if833* the application provides the whole file at once, no external seeking will834* be required (that is, lzma_code() won't return LZMA_SEEK_NEEDED).835*836* The value in lzma_stream.total_in can be used to estimate how much data837* liblzma had to read to get the file information. However, due to seeking838* and the way total_in is updated, the value of total_in will be somewhat839* inaccurate (a little too big). Thus, total_in is a good estimate but don't840* expect to see the same exact value for the same file if you change the841* input buffer size or switch to a different liblzma version.842*843* Valid 'action' arguments to lzma_code() are LZMA_RUN and LZMA_FINISH.844* You only need to use LZMA_RUN; LZMA_FINISH is only supported because it845* might be convenient for some applications. If you use LZMA_FINISH and if846* lzma_code() asks the application to seek, remember to reset 'action' back847* to LZMA_RUN unless you hit the end of the file again.848*849* Possible return values from lzma_code():850* - LZMA_OK: All OK so far, more input needed851* - LZMA_SEEK_NEEDED: Provide more input starting from the absolute852* file position strm->seek_pos853* - LZMA_STREAM_END: Decoding was successful, *dest_index has been set854* - LZMA_FORMAT_ERROR: The input file is not in the .xz format (the855* expected magic bytes were not found from the beginning of the file)856* - LZMA_OPTIONS_ERROR: File looks valid but contains headers that aren't857* supported by this version of liblzma858* - LZMA_DATA_ERROR: File is corrupt859* - LZMA_BUF_ERROR860* - LZMA_MEM_ERROR861* - LZMA_MEMLIMIT_ERROR862* - LZMA_PROG_ERROR863*864* \param strm Pointer to a properly prepared lzma_stream865* \param[out] dest_index Pointer to a pointer where the decoder will put866* the decoded lzma_index. The old value867* of *dest_index is ignored (not freed).868* \param memlimit How much memory the resulting lzma_index is869* allowed to require. Use UINT64_MAX to870* effectively disable the limiter.871* \param file_size Size of the input .xz file872*873* \return Possible lzma_ret values:874* - LZMA_OK875* - LZMA_MEM_ERROR876* - LZMA_PROG_ERROR877*/878extern LZMA_API(lzma_ret) lzma_file_info_decoder(879lzma_stream *strm, lzma_index **dest_index,880uint64_t memlimit, uint64_t file_size)881lzma_nothrow;882883884