|
|
|||
File indexing completed on 2025-12-16 10:19:34
0001 /* SPDX-License-Identifier: 0BSD */ 0002 0003 /** 0004 * \file lzma/block.h 0005 * \brief .xz Block handling 0006 * \note Never include this file directly. Use <lzma.h> instead. 0007 */ 0008 0009 /* 0010 * Author: Lasse Collin 0011 */ 0012 0013 #ifndef LZMA_H_INTERNAL 0014 # error Never include this file directly. Use <lzma.h> instead. 0015 #endif 0016 0017 0018 /** 0019 * \brief Options for the Block and Block Header encoders and decoders 0020 * 0021 * Different Block handling functions use different parts of this structure. 0022 * Some read some members, other functions write, and some do both. Only the 0023 * members listed for reading need to be initialized when the specified 0024 * functions are called. The members marked for writing will be assigned 0025 * new values at some point either by calling the given function or by 0026 * later calls to lzma_code(). 0027 */ 0028 typedef struct { 0029 /** 0030 * \brief Block format version 0031 * 0032 * To prevent API and ABI breakages when new features are needed, 0033 * a version number is used to indicate which members in this 0034 * structure are in use: 0035 * - liblzma >= 5.0.0: version = 0 is supported. 0036 * - liblzma >= 5.1.4beta: Support for version = 1 was added, 0037 * which adds the ignore_check member. 0038 * 0039 * If version is greater than one, most Block related functions 0040 * will return LZMA_OPTIONS_ERROR (lzma_block_header_decode() works 0041 * with any version value). 0042 * 0043 * Read by: 0044 * - lzma_block_header_size() 0045 * - lzma_block_header_encode() 0046 * - lzma_block_header_decode() 0047 * - lzma_block_compressed_size() 0048 * - lzma_block_unpadded_size() 0049 * - lzma_block_total_size() 0050 * - lzma_block_encoder() 0051 * - lzma_block_decoder() 0052 * - lzma_block_buffer_encode() 0053 * - lzma_block_uncomp_encode() 0054 * - lzma_block_buffer_decode() 0055 * 0056 * Written by: 0057 * - lzma_block_header_decode() 0058 */ 0059 uint32_t version; 0060 0061 /** 0062 * \brief Size of the Block Header field in bytes 0063 * 0064 * This is always a multiple of four. 0065 * 0066 * Read by: 0067 * - lzma_block_header_encode() 0068 * - lzma_block_header_decode() 0069 * - lzma_block_compressed_size() 0070 * - lzma_block_unpadded_size() 0071 * - lzma_block_total_size() 0072 * - lzma_block_decoder() 0073 * - lzma_block_buffer_decode() 0074 * 0075 * Written by: 0076 * - lzma_block_header_size() 0077 * - lzma_block_buffer_encode() 0078 * - lzma_block_uncomp_encode() 0079 */ 0080 uint32_t header_size; 0081 # define LZMA_BLOCK_HEADER_SIZE_MIN 8 0082 # define LZMA_BLOCK_HEADER_SIZE_MAX 1024 0083 0084 /** 0085 * \brief Type of integrity Check 0086 * 0087 * The Check ID is not stored into the Block Header, thus its value 0088 * must be provided also when decoding. 0089 * 0090 * Read by: 0091 * - lzma_block_header_encode() 0092 * - lzma_block_header_decode() 0093 * - lzma_block_compressed_size() 0094 * - lzma_block_unpadded_size() 0095 * - lzma_block_total_size() 0096 * - lzma_block_encoder() 0097 * - lzma_block_decoder() 0098 * - lzma_block_buffer_encode() 0099 * - lzma_block_buffer_decode() 0100 */ 0101 lzma_check check; 0102 0103 /** 0104 * \brief Size of the Compressed Data in bytes 0105 * 0106 * Encoding: If this is not LZMA_VLI_UNKNOWN, Block Header encoder 0107 * will store this value to the Block Header. Block encoder doesn't 0108 * care about this value, but will set it once the encoding has been 0109 * finished. 0110 * 0111 * Decoding: If this is not LZMA_VLI_UNKNOWN, Block decoder will 0112 * verify that the size of the Compressed Data field matches 0113 * compressed_size. 0114 * 0115 * Usually you don't know this value when encoding in streamed mode, 0116 * and thus cannot write this field into the Block Header. 0117 * 0118 * In non-streamed mode you can reserve space for this field before 0119 * encoding the actual Block. After encoding the data, finish the 0120 * Block by encoding the Block Header. Steps in detail: 0121 * 0122 * - Set compressed_size to some big enough value. If you don't know 0123 * better, use LZMA_VLI_MAX, but remember that bigger values take 0124 * more space in Block Header. 0125 * 0126 * - Call lzma_block_header_size() to see how much space you need to 0127 * reserve for the Block Header. 0128 * 0129 * - Encode the Block using lzma_block_encoder() and lzma_code(). 0130 * It sets compressed_size to the correct value. 0131 * 0132 * - Use lzma_block_header_encode() to encode the Block Header. 0133 * Because space was reserved in the first step, you don't need 0134 * to call lzma_block_header_size() anymore, because due to 0135 * reserving, header_size has to be big enough. If it is "too big", 0136 * lzma_block_header_encode() will add enough Header Padding to 0137 * make Block Header to match the size specified by header_size. 0138 * 0139 * Read by: 0140 * - lzma_block_header_size() 0141 * - lzma_block_header_encode() 0142 * - lzma_block_compressed_size() 0143 * - lzma_block_unpadded_size() 0144 * - lzma_block_total_size() 0145 * - lzma_block_decoder() 0146 * - lzma_block_buffer_decode() 0147 * 0148 * Written by: 0149 * - lzma_block_header_decode() 0150 * - lzma_block_compressed_size() 0151 * - lzma_block_encoder() 0152 * - lzma_block_decoder() 0153 * - lzma_block_buffer_encode() 0154 * - lzma_block_uncomp_encode() 0155 * - lzma_block_buffer_decode() 0156 */ 0157 lzma_vli compressed_size; 0158 0159 /** 0160 * \brief Uncompressed Size in bytes 0161 * 0162 * This is handled very similarly to compressed_size above. 0163 * 0164 * uncompressed_size is needed by fewer functions than 0165 * compressed_size. This is because uncompressed_size isn't 0166 * needed to validate that Block stays within proper limits. 0167 * 0168 * Read by: 0169 * - lzma_block_header_size() 0170 * - lzma_block_header_encode() 0171 * - lzma_block_decoder() 0172 * - lzma_block_buffer_decode() 0173 * 0174 * Written by: 0175 * - lzma_block_header_decode() 0176 * - lzma_block_encoder() 0177 * - lzma_block_decoder() 0178 * - lzma_block_buffer_encode() 0179 * - lzma_block_uncomp_encode() 0180 * - lzma_block_buffer_decode() 0181 */ 0182 lzma_vli uncompressed_size; 0183 0184 /** 0185 * \brief Array of filters 0186 * 0187 * There can be 1-4 filters. The end of the array is marked with 0188 * .id = LZMA_VLI_UNKNOWN. 0189 * 0190 * Read by: 0191 * - lzma_block_header_size() 0192 * - lzma_block_header_encode() 0193 * - lzma_block_encoder() 0194 * - lzma_block_decoder() 0195 * - lzma_block_buffer_encode() 0196 * - lzma_block_buffer_decode() 0197 * 0198 * Written by: 0199 * - lzma_block_header_decode(): Note that this does NOT free() 0200 * the old filter options structures. All unused filters[] will 0201 * have .id == LZMA_VLI_UNKNOWN and .options == NULL. If 0202 * decoding fails, all filters[] are guaranteed to be 0203 * LZMA_VLI_UNKNOWN and NULL. 0204 * 0205 * \note Because of the array is terminated with 0206 * .id = LZMA_VLI_UNKNOWN, the actual array must 0207 * have LZMA_FILTERS_MAX + 1 members or the Block 0208 * Header decoder will overflow the buffer. 0209 */ 0210 lzma_filter *filters; 0211 0212 /** 0213 * \brief Raw value stored in the Check field 0214 * 0215 * After successful coding, the first lzma_check_size(check) bytes 0216 * of this array contain the raw value stored in the Check field. 0217 * 0218 * Note that CRC32 and CRC64 are stored in little endian byte order. 0219 * Take it into account if you display the Check values to the user. 0220 * 0221 * Written by: 0222 * - lzma_block_encoder() 0223 * - lzma_block_decoder() 0224 * - lzma_block_buffer_encode() 0225 * - lzma_block_uncomp_encode() 0226 * - lzma_block_buffer_decode() 0227 */ 0228 uint8_t raw_check[LZMA_CHECK_SIZE_MAX]; 0229 0230 /* 0231 * Reserved space to allow possible future extensions without 0232 * breaking the ABI. You should not touch these, because the names 0233 * of these variables may change. These are and will never be used 0234 * with the currently supported options, so it is safe to leave these 0235 * uninitialized. 0236 */ 0237 0238 /** \private Reserved member. */ 0239 void *reserved_ptr1; 0240 0241 /** \private Reserved member. */ 0242 void *reserved_ptr2; 0243 0244 /** \private Reserved member. */ 0245 void *reserved_ptr3; 0246 0247 /** \private Reserved member. */ 0248 uint32_t reserved_int1; 0249 0250 /** \private Reserved member. */ 0251 uint32_t reserved_int2; 0252 0253 /** \private Reserved member. */ 0254 lzma_vli reserved_int3; 0255 0256 /** \private Reserved member. */ 0257 lzma_vli reserved_int4; 0258 0259 /** \private Reserved member. */ 0260 lzma_vli reserved_int5; 0261 0262 /** \private Reserved member. */ 0263 lzma_vli reserved_int6; 0264 0265 /** \private Reserved member. */ 0266 lzma_vli reserved_int7; 0267 0268 /** \private Reserved member. */ 0269 lzma_vli reserved_int8; 0270 0271 /** \private Reserved member. */ 0272 lzma_reserved_enum reserved_enum1; 0273 0274 /** \private Reserved member. */ 0275 lzma_reserved_enum reserved_enum2; 0276 0277 /** \private Reserved member. */ 0278 lzma_reserved_enum reserved_enum3; 0279 0280 /** \private Reserved member. */ 0281 lzma_reserved_enum reserved_enum4; 0282 0283 /** 0284 * \brief A flag to Block decoder to not verify the Check field 0285 * 0286 * This member is supported by liblzma >= 5.1.4beta if .version >= 1. 0287 * 0288 * If this is set to true, the integrity check won't be calculated 0289 * and verified. Unless you know what you are doing, you should 0290 * leave this to false. (A reason to set this to true is when the 0291 * file integrity is verified externally anyway and you want to 0292 * speed up the decompression, which matters mostly when using 0293 * SHA-256 as the integrity check.) 0294 * 0295 * If .version >= 1, read by: 0296 * - lzma_block_decoder() 0297 * - lzma_block_buffer_decode() 0298 * 0299 * Written by (.version is ignored): 0300 * - lzma_block_header_decode() always sets this to false 0301 */ 0302 lzma_bool ignore_check; 0303 0304 /** \private Reserved member. */ 0305 lzma_bool reserved_bool2; 0306 0307 /** \private Reserved member. */ 0308 lzma_bool reserved_bool3; 0309 0310 /** \private Reserved member. */ 0311 lzma_bool reserved_bool4; 0312 0313 /** \private Reserved member. */ 0314 lzma_bool reserved_bool5; 0315 0316 /** \private Reserved member. */ 0317 lzma_bool reserved_bool6; 0318 0319 /** \private Reserved member. */ 0320 lzma_bool reserved_bool7; 0321 0322 /** \private Reserved member. */ 0323 lzma_bool reserved_bool8; 0324 0325 } lzma_block; 0326 0327 0328 /** 0329 * \brief Decode the Block Header Size field 0330 * 0331 * To decode Block Header using lzma_block_header_decode(), the size of the 0332 * Block Header has to be known and stored into lzma_block.header_size. 0333 * The size can be calculated from the first byte of a Block using this macro. 0334 * Note that if the first byte is 0x00, it indicates beginning of Index; use 0335 * this macro only when the byte is not 0x00. 0336 * 0337 * There is no encoding macro because lzma_block_header_size() and 0338 * lzma_block_header_encode() should be used. 0339 */ 0340 #define lzma_block_header_size_decode(b) (((uint32_t)(b) + 1) * 4) 0341 0342 0343 /** 0344 * \brief Calculate Block Header Size 0345 * 0346 * Calculate the minimum size needed for the Block Header field using the 0347 * settings specified in the lzma_block structure. Note that it is OK to 0348 * increase the calculated header_size value as long as it is a multiple of 0349 * four and doesn't exceed LZMA_BLOCK_HEADER_SIZE_MAX. Increasing header_size 0350 * just means that lzma_block_header_encode() will add Header Padding. 0351 * 0352 * \note This doesn't check that all the options are valid i.e. this 0353 * may return LZMA_OK even if lzma_block_header_encode() or 0354 * lzma_block_encoder() would fail. If you want to validate the 0355 * filter chain, consider using lzma_memlimit_encoder() which as 0356 * a side-effect validates the filter chain. 0357 * 0358 * \param block Block options 0359 * 0360 * \return Possible lzma_ret values: 0361 * - LZMA_OK: Size calculated successfully and stored to 0362 * block->header_size. 0363 * - LZMA_OPTIONS_ERROR: Unsupported version, filters or 0364 * filter options. 0365 * - LZMA_PROG_ERROR: Invalid values like compressed_size == 0. 0366 */ 0367 extern LZMA_API(lzma_ret) lzma_block_header_size(lzma_block *block) 0368 lzma_nothrow lzma_attr_warn_unused_result; 0369 0370 0371 /** 0372 * \brief Encode Block Header 0373 * 0374 * The caller must have calculated the size of the Block Header already with 0375 * lzma_block_header_size(). If a value larger than the one calculated by 0376 * lzma_block_header_size() is used, the Block Header will be padded to the 0377 * specified size. 0378 * 0379 * \param block Block options to be encoded. 0380 * \param[out] out Beginning of the output buffer. This must be 0381 * at least block->header_size bytes. 0382 * 0383 * \return Possible lzma_ret values: 0384 * - LZMA_OK: Encoding was successful. block->header_size 0385 * bytes were written to output buffer. 0386 * - LZMA_OPTIONS_ERROR: Invalid or unsupported options. 0387 * - LZMA_PROG_ERROR: Invalid arguments, for example 0388 * block->header_size is invalid or block->filters is NULL. 0389 */ 0390 extern LZMA_API(lzma_ret) lzma_block_header_encode( 0391 const lzma_block *block, uint8_t *out) 0392 lzma_nothrow lzma_attr_warn_unused_result; 0393 0394 0395 /** 0396 * \brief Decode Block Header 0397 * 0398 * block->version should (usually) be set to the highest value supported 0399 * by the application. If the application sets block->version to a value 0400 * higher than supported by the current liblzma version, this function will 0401 * downgrade block->version to the highest value supported by it. Thus one 0402 * should check the value of block->version after calling this function if 0403 * block->version was set to a non-zero value and the application doesn't 0404 * otherwise know that the liblzma version being used is new enough to 0405 * support the specified block->version. 0406 * 0407 * The size of the Block Header must have already been decoded with 0408 * lzma_block_header_size_decode() macro and stored to block->header_size. 0409 * 0410 * The integrity check type from Stream Header must have been stored 0411 * to block->check. 0412 * 0413 * block->filters must have been allocated, but they don't need to be 0414 * initialized (possible existing filter options are not freed). 0415 * 0416 * \param[out] block Destination for Block options 0417 * \param allocator lzma_allocator for custom allocator functions. 0418 * Set to NULL to use malloc() (and also free() 0419 * if an error occurs). 0420 * \param in Beginning of the input buffer. This must be 0421 * at least block->header_size bytes. 0422 * 0423 * \return Possible lzma_ret values: 0424 * - LZMA_OK: Decoding was successful. block->header_size 0425 * bytes were read from the input buffer. 0426 * - LZMA_OPTIONS_ERROR: The Block Header specifies some 0427 * unsupported options such as unsupported filters. This can 0428 * happen also if block->version was set to a too low value 0429 * compared to what would be required to properly represent 0430 * the information stored in the Block Header. 0431 * - LZMA_DATA_ERROR: Block Header is corrupt, for example, 0432 * the CRC32 doesn't match. 0433 * - LZMA_PROG_ERROR: Invalid arguments, for example 0434 * block->header_size is invalid or block->filters is NULL. 0435 */ 0436 extern LZMA_API(lzma_ret) lzma_block_header_decode(lzma_block *block, 0437 const lzma_allocator *allocator, const uint8_t *in) 0438 lzma_nothrow lzma_attr_warn_unused_result; 0439 0440 0441 /** 0442 * \brief Validate and set Compressed Size according to Unpadded Size 0443 * 0444 * Block Header stores Compressed Size, but Index has Unpadded Size. If the 0445 * application has already parsed the Index and is now decoding Blocks, 0446 * it can calculate Compressed Size from Unpadded Size. This function does 0447 * exactly that with error checking: 0448 * 0449 * - Compressed Size calculated from Unpadded Size must be positive integer, 0450 * that is, Unpadded Size must be big enough that after Block Header and 0451 * Check fields there's still at least one byte for Compressed Size. 0452 * 0453 * - If Compressed Size was present in Block Header, the new value 0454 * calculated from Unpadded Size is compared against the value 0455 * from Block Header. 0456 * 0457 * \note This function must be called _after_ decoding the Block Header 0458 * field so that it can properly validate Compressed Size if it 0459 * was present in Block Header. 0460 * 0461 * \param block Block options: block->header_size must 0462 * already be set with lzma_block_header_size(). 0463 * \param unpadded_size Unpadded Size from the Index field in bytes 0464 * 0465 * \return Possible lzma_ret values: 0466 * - LZMA_OK: block->compressed_size was set successfully. 0467 * - LZMA_DATA_ERROR: unpadded_size is too small compared to 0468 * block->header_size and lzma_check_size(block->check). 0469 * - LZMA_PROG_ERROR: Some values are invalid. For example, 0470 * block->header_size must be a multiple of four and 0471 * between 8 and 1024 inclusive. 0472 */ 0473 extern LZMA_API(lzma_ret) lzma_block_compressed_size( 0474 lzma_block *block, lzma_vli unpadded_size) 0475 lzma_nothrow lzma_attr_warn_unused_result; 0476 0477 0478 /** 0479 * \brief Calculate Unpadded Size 0480 * 0481 * The Index field stores Unpadded Size and Uncompressed Size. The latter 0482 * can be taken directly from the lzma_block structure after coding a Block, 0483 * but Unpadded Size needs to be calculated from Block Header Size, 0484 * Compressed Size, and size of the Check field. This is where this function 0485 * is needed. 0486 * 0487 * \param block Block options: block->header_size must already be 0488 * set with lzma_block_header_size(). 0489 * 0490 * \return Unpadded Size on success, or zero on error. 0491 */ 0492 extern LZMA_API(lzma_vli) lzma_block_unpadded_size(const lzma_block *block) 0493 lzma_nothrow lzma_attr_pure; 0494 0495 0496 /** 0497 * \brief Calculate the total encoded size of a Block 0498 * 0499 * This is equivalent to lzma_block_unpadded_size() except that the returned 0500 * value includes the size of the Block Padding field. 0501 * 0502 * \param block Block options: block->header_size must already be 0503 * set with lzma_block_header_size(). 0504 * 0505 * \return On success, total encoded size of the Block. On error, 0506 * zero is returned. 0507 */ 0508 extern LZMA_API(lzma_vli) lzma_block_total_size(const lzma_block *block) 0509 lzma_nothrow lzma_attr_pure; 0510 0511 0512 /** 0513 * \brief Initialize .xz Block encoder 0514 * 0515 * Valid actions for lzma_code() are LZMA_RUN, LZMA_SYNC_FLUSH (only if the 0516 * filter chain supports it), and LZMA_FINISH. 0517 * 0518 * The Block encoder encodes the Block Data, Block Padding, and Check value. 0519 * It does NOT encode the Block Header which can be encoded with 0520 * lzma_block_header_encode(). 0521 * 0522 * \param strm Pointer to lzma_stream that is at least initialized 0523 * with LZMA_STREAM_INIT. 0524 * \param block Block options: block->version, block->check, 0525 * and block->filters must have been initialized. 0526 * 0527 * \return Possible lzma_ret values: 0528 * - LZMA_OK: All good, continue with lzma_code(). 0529 * - LZMA_MEM_ERROR 0530 * - LZMA_OPTIONS_ERROR 0531 * - LZMA_UNSUPPORTED_CHECK: block->check specifies a Check ID 0532 * that is not supported by this build of liblzma. Initializing 0533 * the encoder failed. 0534 * - LZMA_PROG_ERROR 0535 */ 0536 extern LZMA_API(lzma_ret) lzma_block_encoder( 0537 lzma_stream *strm, lzma_block *block) 0538 lzma_nothrow lzma_attr_warn_unused_result; 0539 0540 0541 /** 0542 * \brief Initialize .xz Block decoder 0543 * 0544 * Valid actions for lzma_code() are LZMA_RUN and LZMA_FINISH. Using 0545 * LZMA_FINISH is not required. It is supported only for convenience. 0546 * 0547 * The Block decoder decodes the Block Data, Block Padding, and Check value. 0548 * It does NOT decode the Block Header which can be decoded with 0549 * lzma_block_header_decode(). 0550 * 0551 * \param strm Pointer to lzma_stream that is at least initialized 0552 * with LZMA_STREAM_INIT. 0553 * \param block Block options 0554 * 0555 * \return Possible lzma_ret values: 0556 * - LZMA_OK: All good, continue with lzma_code(). 0557 * - LZMA_PROG_ERROR 0558 * - LZMA_MEM_ERROR 0559 */ 0560 extern LZMA_API(lzma_ret) lzma_block_decoder( 0561 lzma_stream *strm, lzma_block *block) 0562 lzma_nothrow lzma_attr_warn_unused_result; 0563 0564 0565 /** 0566 * \brief Calculate maximum output size for single-call Block encoding 0567 * 0568 * This is equivalent to lzma_stream_buffer_bound() but for .xz Blocks. 0569 * See the documentation of lzma_stream_buffer_bound(). 0570 * 0571 * \param uncompressed_size Size of the data to be encoded with the 0572 * single-call Block encoder. 0573 * 0574 * \return Maximum output size in bytes for single-call Block encoding. 0575 */ 0576 extern LZMA_API(size_t) lzma_block_buffer_bound(size_t uncompressed_size) 0577 lzma_nothrow; 0578 0579 0580 /** 0581 * \brief Single-call .xz Block encoder 0582 * 0583 * In contrast to the multi-call encoder initialized with 0584 * lzma_block_encoder(), this function encodes also the Block Header. This 0585 * is required to make it possible to write appropriate Block Header also 0586 * in case the data isn't compressible, and different filter chain has to be 0587 * used to encode the data in uncompressed form using uncompressed chunks 0588 * of the LZMA2 filter. 0589 * 0590 * When the data isn't compressible, header_size, compressed_size, and 0591 * uncompressed_size are set just like when the data was compressible, but 0592 * it is possible that header_size is too small to hold the filter chain 0593 * specified in block->filters, because that isn't necessarily the filter 0594 * chain that was actually used to encode the data. lzma_block_unpadded_size() 0595 * still works normally, because it doesn't read the filters array. 0596 * 0597 * \param block Block options: block->version, block->check, 0598 * and block->filters must have been initialized. 0599 * \param allocator lzma_allocator for custom allocator functions. 0600 * Set to NULL to use malloc() and free(). 0601 * \param in Beginning of the input buffer 0602 * \param in_size Size of the input buffer 0603 * \param[out] out Beginning of the output buffer 0604 * \param[out] out_pos The next byte will be written to out[*out_pos]. 0605 * *out_pos is updated only if encoding succeeds. 0606 * \param out_size Size of the out buffer; the first byte into 0607 * which no data is written to is out[out_size]. 0608 * 0609 * \return Possible lzma_ret values: 0610 * - LZMA_OK: Encoding was successful. 0611 * - LZMA_BUF_ERROR: Not enough output buffer space. 0612 * - LZMA_UNSUPPORTED_CHECK 0613 * - LZMA_OPTIONS_ERROR 0614 * - LZMA_MEM_ERROR 0615 * - LZMA_DATA_ERROR 0616 * - LZMA_PROG_ERROR 0617 */ 0618 extern LZMA_API(lzma_ret) lzma_block_buffer_encode( 0619 lzma_block *block, const lzma_allocator *allocator, 0620 const uint8_t *in, size_t in_size, 0621 uint8_t *out, size_t *out_pos, size_t out_size) 0622 lzma_nothrow lzma_attr_warn_unused_result; 0623 0624 0625 /** 0626 * \brief Single-call uncompressed .xz Block encoder 0627 * 0628 * This is like lzma_block_buffer_encode() except this doesn't try to 0629 * compress the data and instead encodes the data using LZMA2 uncompressed 0630 * chunks. The required output buffer size can be determined with 0631 * lzma_block_buffer_bound(). 0632 * 0633 * Since the data won't be compressed, this function ignores block->filters. 0634 * This function doesn't take lzma_allocator because this function doesn't 0635 * allocate any memory from the heap. 0636 * 0637 * \param block Block options: block->version, block->check, 0638 * and block->filters must have been initialized. 0639 * \param in Beginning of the input buffer 0640 * \param in_size Size of the input buffer 0641 * \param[out] out Beginning of the output buffer 0642 * \param[out] out_pos The next byte will be written to out[*out_pos]. 0643 * *out_pos is updated only if encoding succeeds. 0644 * \param out_size Size of the out buffer; the first byte into 0645 * which no data is written to is out[out_size]. 0646 * 0647 * \return Possible lzma_ret values: 0648 * - LZMA_OK: Encoding was successful. 0649 * - LZMA_BUF_ERROR: Not enough output buffer space. 0650 * - LZMA_UNSUPPORTED_CHECK 0651 * - LZMA_OPTIONS_ERROR 0652 * - LZMA_MEM_ERROR 0653 * - LZMA_DATA_ERROR 0654 * - LZMA_PROG_ERROR 0655 */ 0656 extern LZMA_API(lzma_ret) lzma_block_uncomp_encode(lzma_block *block, 0657 const uint8_t *in, size_t in_size, 0658 uint8_t *out, size_t *out_pos, size_t out_size) 0659 lzma_nothrow lzma_attr_warn_unused_result; 0660 0661 0662 /** 0663 * \brief Single-call .xz Block decoder 0664 * 0665 * This is single-call equivalent of lzma_block_decoder(), and requires that 0666 * the caller has already decoded Block Header and checked its memory usage. 0667 * 0668 * \param block Block options 0669 * \param allocator lzma_allocator for custom allocator functions. 0670 * Set to NULL to use malloc() and free(). 0671 * \param in Beginning of the input buffer 0672 * \param in_pos The next byte will be read from in[*in_pos]. 0673 * *in_pos is updated only if decoding succeeds. 0674 * \param in_size Size of the input buffer; the first byte that 0675 * won't be read is in[in_size]. 0676 * \param[out] out Beginning of the output buffer 0677 * \param[out] out_pos The next byte will be written to out[*out_pos]. 0678 * *out_pos is updated only if encoding succeeds. 0679 * \param out_size Size of the out buffer; the first byte into 0680 * which no data is written to is out[out_size]. 0681 * 0682 * \return Possible lzma_ret values: 0683 * - LZMA_OK: Decoding was successful. 0684 * - LZMA_OPTIONS_ERROR 0685 * - LZMA_DATA_ERROR 0686 * - LZMA_MEM_ERROR 0687 * - LZMA_BUF_ERROR: Output buffer was too small. 0688 * - LZMA_PROG_ERROR 0689 */ 0690 extern LZMA_API(lzma_ret) lzma_block_buffer_decode( 0691 lzma_block *block, const lzma_allocator *allocator, 0692 const uint8_t *in, size_t *in_pos, size_t in_size, 0693 uint8_t *out, size_t *out_pos, size_t out_size) 0694 lzma_nothrow;
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|