annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/include/lzma/index_hash.h @ 69:33d812a61356

planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author jpayne
date Tue, 18 Mar 2025 17:55:14 -0400
parents
children
rev   line source
jpayne@69 1 /* SPDX-License-Identifier: 0BSD */
jpayne@69 2
jpayne@69 3 /**
jpayne@69 4 * \file lzma/index_hash.h
jpayne@69 5 * \brief Validate Index by using a hash function
jpayne@69 6 * \note Never include this file directly. Use <lzma.h> instead.
jpayne@69 7 *
jpayne@69 8 * Hashing makes it possible to use constant amount of memory to validate
jpayne@69 9 * Index of arbitrary size.
jpayne@69 10 */
jpayne@69 11
jpayne@69 12 /*
jpayne@69 13 * Author: Lasse Collin
jpayne@69 14 */
jpayne@69 15
jpayne@69 16 #ifndef LZMA_H_INTERNAL
jpayne@69 17 # error Never include this file directly. Use <lzma.h> instead.
jpayne@69 18 #endif
jpayne@69 19
jpayne@69 20 /**
jpayne@69 21 * \brief Opaque data type to hold the Index hash
jpayne@69 22 */
jpayne@69 23 typedef struct lzma_index_hash_s lzma_index_hash;
jpayne@69 24
jpayne@69 25
jpayne@69 26 /**
jpayne@69 27 * \brief Allocate and initialize a new lzma_index_hash structure
jpayne@69 28 *
jpayne@69 29 * If index_hash is NULL, this function allocates and initializes a new
jpayne@69 30 * lzma_index_hash structure and returns a pointer to it. If allocation
jpayne@69 31 * fails, NULL is returned.
jpayne@69 32 *
jpayne@69 33 * If index_hash is non-NULL, this function reinitializes the lzma_index_hash
jpayne@69 34 * structure and returns the same pointer. In this case, return value cannot
jpayne@69 35 * be NULL or a different pointer than the index_hash that was given as
jpayne@69 36 * an argument.
jpayne@69 37 *
jpayne@69 38 * \param index_hash Pointer to a lzma_index_hash structure or NULL.
jpayne@69 39 * \param allocator lzma_allocator for custom allocator functions.
jpayne@69 40 * Set to NULL to use malloc() and free().
jpayne@69 41 *
jpayne@69 42 * \return Initialized lzma_index_hash structure on success or
jpayne@69 43 * NULL on failure.
jpayne@69 44 */
jpayne@69 45 extern LZMA_API(lzma_index_hash *) lzma_index_hash_init(
jpayne@69 46 lzma_index_hash *index_hash, const lzma_allocator *allocator)
jpayne@69 47 lzma_nothrow lzma_attr_warn_unused_result;
jpayne@69 48
jpayne@69 49
jpayne@69 50 /**
jpayne@69 51 * \brief Deallocate lzma_index_hash structure
jpayne@69 52 *
jpayne@69 53 * \param index_hash Pointer to a lzma_index_hash structure to free.
jpayne@69 54 * \param allocator lzma_allocator for custom allocator functions.
jpayne@69 55 * Set to NULL to use malloc() and free().
jpayne@69 56 */
jpayne@69 57 extern LZMA_API(void) lzma_index_hash_end(
jpayne@69 58 lzma_index_hash *index_hash, const lzma_allocator *allocator)
jpayne@69 59 lzma_nothrow;
jpayne@69 60
jpayne@69 61
jpayne@69 62 /**
jpayne@69 63 * \brief Add a new Record to an Index hash
jpayne@69 64 *
jpayne@69 65 * \param index_hash Pointer to a lzma_index_hash structure
jpayne@69 66 * \param unpadded_size Unpadded Size of a Block
jpayne@69 67 * \param uncompressed_size Uncompressed Size of a Block
jpayne@69 68 *
jpayne@69 69 * \return Possible lzma_ret values:
jpayne@69 70 * - LZMA_OK
jpayne@69 71 * - LZMA_DATA_ERROR: Compressed or uncompressed size of the
jpayne@69 72 * Stream or size of the Index field would grow too big.
jpayne@69 73 * - LZMA_PROG_ERROR: Invalid arguments or this function is being
jpayne@69 74 * used when lzma_index_hash_decode() has already been used.
jpayne@69 75 */
jpayne@69 76 extern LZMA_API(lzma_ret) lzma_index_hash_append(lzma_index_hash *index_hash,
jpayne@69 77 lzma_vli unpadded_size, lzma_vli uncompressed_size)
jpayne@69 78 lzma_nothrow lzma_attr_warn_unused_result;
jpayne@69 79
jpayne@69 80
jpayne@69 81 /**
jpayne@69 82 * \brief Decode and validate the Index field
jpayne@69 83 *
jpayne@69 84 * After telling the sizes of all Blocks with lzma_index_hash_append(),
jpayne@69 85 * the actual Index field is decoded with this function. Specifically,
jpayne@69 86 * once decoding of the Index field has been started, no more Records
jpayne@69 87 * can be added using lzma_index_hash_append().
jpayne@69 88 *
jpayne@69 89 * This function doesn't use lzma_stream structure to pass the input data.
jpayne@69 90 * Instead, the input buffer is specified using three arguments. This is
jpayne@69 91 * because it matches better the internal APIs of liblzma.
jpayne@69 92 *
jpayne@69 93 * \param index_hash Pointer to a lzma_index_hash structure
jpayne@69 94 * \param in Pointer to the beginning of the input buffer
jpayne@69 95 * \param[out] in_pos in[*in_pos] is the next byte to process
jpayne@69 96 * \param in_size in[in_size] is the first byte not to process
jpayne@69 97 *
jpayne@69 98 * \return Possible lzma_ret values:
jpayne@69 99 * - LZMA_OK: So far good, but more input is needed.
jpayne@69 100 * - LZMA_STREAM_END: Index decoded successfully and it matches
jpayne@69 101 * the Records given with lzma_index_hash_append().
jpayne@69 102 * - LZMA_DATA_ERROR: Index is corrupt or doesn't match the
jpayne@69 103 * information given with lzma_index_hash_append().
jpayne@69 104 * - LZMA_BUF_ERROR: Cannot progress because *in_pos >= in_size.
jpayne@69 105 * - LZMA_PROG_ERROR
jpayne@69 106 */
jpayne@69 107 extern LZMA_API(lzma_ret) lzma_index_hash_decode(lzma_index_hash *index_hash,
jpayne@69 108 const uint8_t *in, size_t *in_pos, size_t in_size)
jpayne@69 109 lzma_nothrow lzma_attr_warn_unused_result;
jpayne@69 110
jpayne@69 111
jpayne@69 112 /**
jpayne@69 113 * \brief Get the size of the Index field as bytes
jpayne@69 114 *
jpayne@69 115 * This is needed to verify the Backward Size field in the Stream Footer.
jpayne@69 116 *
jpayne@69 117 * \param index_hash Pointer to a lzma_index_hash structure
jpayne@69 118 *
jpayne@69 119 * \return Size of the Index field in bytes.
jpayne@69 120 */
jpayne@69 121 extern LZMA_API(lzma_vli) lzma_index_hash_size(
jpayne@69 122 const lzma_index_hash *index_hash)
jpayne@69 123 lzma_nothrow lzma_attr_pure;