Mercurial > repos > rliterman > csp2
comparison CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/include/lzma/block.h @ 69:33d812a61356
planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author | jpayne |
---|---|
date | Tue, 18 Mar 2025 17:55:14 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
67:0e9998148a16 | 69:33d812a61356 |
---|---|
1 /* SPDX-License-Identifier: 0BSD */ | |
2 | |
3 /** | |
4 * \file lzma/block.h | |
5 * \brief .xz Block handling | |
6 * \note Never include this file directly. Use <lzma.h> instead. | |
7 */ | |
8 | |
9 /* | |
10 * Author: Lasse Collin | |
11 */ | |
12 | |
13 #ifndef LZMA_H_INTERNAL | |
14 # error Never include this file directly. Use <lzma.h> instead. | |
15 #endif | |
16 | |
17 | |
18 /** | |
19 * \brief Options for the Block and Block Header encoders and decoders | |
20 * | |
21 * Different Block handling functions use different parts of this structure. | |
22 * Some read some members, other functions write, and some do both. Only the | |
23 * members listed for reading need to be initialized when the specified | |
24 * functions are called. The members marked for writing will be assigned | |
25 * new values at some point either by calling the given function or by | |
26 * later calls to lzma_code(). | |
27 */ | |
28 typedef struct { | |
29 /** | |
30 * \brief Block format version | |
31 * | |
32 * To prevent API and ABI breakages when new features are needed, | |
33 * a version number is used to indicate which members in this | |
34 * structure are in use: | |
35 * - liblzma >= 5.0.0: version = 0 is supported. | |
36 * - liblzma >= 5.1.4beta: Support for version = 1 was added, | |
37 * which adds the ignore_check member. | |
38 * | |
39 * If version is greater than one, most Block related functions | |
40 * will return LZMA_OPTIONS_ERROR (lzma_block_header_decode() works | |
41 * with any version value). | |
42 * | |
43 * Read by: | |
44 * - lzma_block_header_size() | |
45 * - lzma_block_header_encode() | |
46 * - lzma_block_header_decode() | |
47 * - lzma_block_compressed_size() | |
48 * - lzma_block_unpadded_size() | |
49 * - lzma_block_total_size() | |
50 * - lzma_block_encoder() | |
51 * - lzma_block_decoder() | |
52 * - lzma_block_buffer_encode() | |
53 * - lzma_block_uncomp_encode() | |
54 * - lzma_block_buffer_decode() | |
55 * | |
56 * Written by: | |
57 * - lzma_block_header_decode() | |
58 */ | |
59 uint32_t version; | |
60 | |
61 /** | |
62 * \brief Size of the Block Header field in bytes | |
63 * | |
64 * This is always a multiple of four. | |
65 * | |
66 * Read by: | |
67 * - lzma_block_header_encode() | |
68 * - lzma_block_header_decode() | |
69 * - lzma_block_compressed_size() | |
70 * - lzma_block_unpadded_size() | |
71 * - lzma_block_total_size() | |
72 * - lzma_block_decoder() | |
73 * - lzma_block_buffer_decode() | |
74 * | |
75 * Written by: | |
76 * - lzma_block_header_size() | |
77 * - lzma_block_buffer_encode() | |
78 * - lzma_block_uncomp_encode() | |
79 */ | |
80 uint32_t header_size; | |
81 # define LZMA_BLOCK_HEADER_SIZE_MIN 8 | |
82 # define LZMA_BLOCK_HEADER_SIZE_MAX 1024 | |
83 | |
84 /** | |
85 * \brief Type of integrity Check | |
86 * | |
87 * The Check ID is not stored into the Block Header, thus its value | |
88 * must be provided also when decoding. | |
89 * | |
90 * Read by: | |
91 * - lzma_block_header_encode() | |
92 * - lzma_block_header_decode() | |
93 * - lzma_block_compressed_size() | |
94 * - lzma_block_unpadded_size() | |
95 * - lzma_block_total_size() | |
96 * - lzma_block_encoder() | |
97 * - lzma_block_decoder() | |
98 * - lzma_block_buffer_encode() | |
99 * - lzma_block_buffer_decode() | |
100 */ | |
101 lzma_check check; | |
102 | |
103 /** | |
104 * \brief Size of the Compressed Data in bytes | |
105 * | |
106 * Encoding: If this is not LZMA_VLI_UNKNOWN, Block Header encoder | |
107 * will store this value to the Block Header. Block encoder doesn't | |
108 * care about this value, but will set it once the encoding has been | |
109 * finished. | |
110 * | |
111 * Decoding: If this is not LZMA_VLI_UNKNOWN, Block decoder will | |
112 * verify that the size of the Compressed Data field matches | |
113 * compressed_size. | |
114 * | |
115 * Usually you don't know this value when encoding in streamed mode, | |
116 * and thus cannot write this field into the Block Header. | |
117 * | |
118 * In non-streamed mode you can reserve space for this field before | |
119 * encoding the actual Block. After encoding the data, finish the | |
120 * Block by encoding the Block Header. Steps in detail: | |
121 * | |
122 * - Set compressed_size to some big enough value. If you don't know | |
123 * better, use LZMA_VLI_MAX, but remember that bigger values take | |
124 * more space in Block Header. | |
125 * | |
126 * - Call lzma_block_header_size() to see how much space you need to | |
127 * reserve for the Block Header. | |
128 * | |
129 * - Encode the Block using lzma_block_encoder() and lzma_code(). | |
130 * It sets compressed_size to the correct value. | |
131 * | |
132 * - Use lzma_block_header_encode() to encode the Block Header. | |
133 * Because space was reserved in the first step, you don't need | |
134 * to call lzma_block_header_size() anymore, because due to | |
135 * reserving, header_size has to be big enough. If it is "too big", | |
136 * lzma_block_header_encode() will add enough Header Padding to | |
137 * make Block Header to match the size specified by header_size. | |
138 * | |
139 * Read by: | |
140 * - lzma_block_header_size() | |
141 * - lzma_block_header_encode() | |
142 * - lzma_block_compressed_size() | |
143 * - lzma_block_unpadded_size() | |
144 * - lzma_block_total_size() | |
145 * - lzma_block_decoder() | |
146 * - lzma_block_buffer_decode() | |
147 * | |
148 * Written by: | |
149 * - lzma_block_header_decode() | |
150 * - lzma_block_compressed_size() | |
151 * - lzma_block_encoder() | |
152 * - lzma_block_decoder() | |
153 * - lzma_block_buffer_encode() | |
154 * - lzma_block_uncomp_encode() | |
155 * - lzma_block_buffer_decode() | |
156 */ | |
157 lzma_vli compressed_size; | |
158 | |
159 /** | |
160 * \brief Uncompressed Size in bytes | |
161 * | |
162 * This is handled very similarly to compressed_size above. | |
163 * | |
164 * uncompressed_size is needed by fewer functions than | |
165 * compressed_size. This is because uncompressed_size isn't | |
166 * needed to validate that Block stays within proper limits. | |
167 * | |
168 * Read by: | |
169 * - lzma_block_header_size() | |
170 * - lzma_block_header_encode() | |
171 * - lzma_block_decoder() | |
172 * - lzma_block_buffer_decode() | |
173 * | |
174 * Written by: | |
175 * - lzma_block_header_decode() | |
176 * - lzma_block_encoder() | |
177 * - lzma_block_decoder() | |
178 * - lzma_block_buffer_encode() | |
179 * - lzma_block_uncomp_encode() | |
180 * - lzma_block_buffer_decode() | |
181 */ | |
182 lzma_vli uncompressed_size; | |
183 | |
184 /** | |
185 * \brief Array of filters | |
186 * | |
187 * There can be 1-4 filters. The end of the array is marked with | |
188 * .id = LZMA_VLI_UNKNOWN. | |
189 * | |
190 * Read by: | |
191 * - lzma_block_header_size() | |
192 * - lzma_block_header_encode() | |
193 * - lzma_block_encoder() | |
194 * - lzma_block_decoder() | |
195 * - lzma_block_buffer_encode() | |
196 * - lzma_block_buffer_decode() | |
197 * | |
198 * Written by: | |
199 * - lzma_block_header_decode(): Note that this does NOT free() | |
200 * the old filter options structures. All unused filters[] will | |
201 * have .id == LZMA_VLI_UNKNOWN and .options == NULL. If | |
202 * decoding fails, all filters[] are guaranteed to be | |
203 * LZMA_VLI_UNKNOWN and NULL. | |
204 * | |
205 * \note Because of the array is terminated with | |
206 * .id = LZMA_VLI_UNKNOWN, the actual array must | |
207 * have LZMA_FILTERS_MAX + 1 members or the Block | |
208 * Header decoder will overflow the buffer. | |
209 */ | |
210 lzma_filter *filters; | |
211 | |
212 /** | |
213 * \brief Raw value stored in the Check field | |
214 * | |
215 * After successful coding, the first lzma_check_size(check) bytes | |
216 * of this array contain the raw value stored in the Check field. | |
217 * | |
218 * Note that CRC32 and CRC64 are stored in little endian byte order. | |
219 * Take it into account if you display the Check values to the user. | |
220 * | |
221 * Written by: | |
222 * - lzma_block_encoder() | |
223 * - lzma_block_decoder() | |
224 * - lzma_block_buffer_encode() | |
225 * - lzma_block_uncomp_encode() | |
226 * - lzma_block_buffer_decode() | |
227 */ | |
228 uint8_t raw_check[LZMA_CHECK_SIZE_MAX]; | |
229 | |
230 /* | |
231 * Reserved space to allow possible future extensions without | |
232 * breaking the ABI. You should not touch these, because the names | |
233 * of these variables may change. These are and will never be used | |
234 * with the currently supported options, so it is safe to leave these | |
235 * uninitialized. | |
236 */ | |
237 | |
238 /** \private Reserved member. */ | |
239 void *reserved_ptr1; | |
240 | |
241 /** \private Reserved member. */ | |
242 void *reserved_ptr2; | |
243 | |
244 /** \private Reserved member. */ | |
245 void *reserved_ptr3; | |
246 | |
247 /** \private Reserved member. */ | |
248 uint32_t reserved_int1; | |
249 | |
250 /** \private Reserved member. */ | |
251 uint32_t reserved_int2; | |
252 | |
253 /** \private Reserved member. */ | |
254 lzma_vli reserved_int3; | |
255 | |
256 /** \private Reserved member. */ | |
257 lzma_vli reserved_int4; | |
258 | |
259 /** \private Reserved member. */ | |
260 lzma_vli reserved_int5; | |
261 | |
262 /** \private Reserved member. */ | |
263 lzma_vli reserved_int6; | |
264 | |
265 /** \private Reserved member. */ | |
266 lzma_vli reserved_int7; | |
267 | |
268 /** \private Reserved member. */ | |
269 lzma_vli reserved_int8; | |
270 | |
271 /** \private Reserved member. */ | |
272 lzma_reserved_enum reserved_enum1; | |
273 | |
274 /** \private Reserved member. */ | |
275 lzma_reserved_enum reserved_enum2; | |
276 | |
277 /** \private Reserved member. */ | |
278 lzma_reserved_enum reserved_enum3; | |
279 | |
280 /** \private Reserved member. */ | |
281 lzma_reserved_enum reserved_enum4; | |
282 | |
283 /** | |
284 * \brief A flag to Block decoder to not verify the Check field | |
285 * | |
286 * This member is supported by liblzma >= 5.1.4beta if .version >= 1. | |
287 * | |
288 * If this is set to true, the integrity check won't be calculated | |
289 * and verified. Unless you know what you are doing, you should | |
290 * leave this to false. (A reason to set this to true is when the | |
291 * file integrity is verified externally anyway and you want to | |
292 * speed up the decompression, which matters mostly when using | |
293 * SHA-256 as the integrity check.) | |
294 * | |
295 * If .version >= 1, read by: | |
296 * - lzma_block_decoder() | |
297 * - lzma_block_buffer_decode() | |
298 * | |
299 * Written by (.version is ignored): | |
300 * - lzma_block_header_decode() always sets this to false | |
301 */ | |
302 lzma_bool ignore_check; | |
303 | |
304 /** \private Reserved member. */ | |
305 lzma_bool reserved_bool2; | |
306 | |
307 /** \private Reserved member. */ | |
308 lzma_bool reserved_bool3; | |
309 | |
310 /** \private Reserved member. */ | |
311 lzma_bool reserved_bool4; | |
312 | |
313 /** \private Reserved member. */ | |
314 lzma_bool reserved_bool5; | |
315 | |
316 /** \private Reserved member. */ | |
317 lzma_bool reserved_bool6; | |
318 | |
319 /** \private Reserved member. */ | |
320 lzma_bool reserved_bool7; | |
321 | |
322 /** \private Reserved member. */ | |
323 lzma_bool reserved_bool8; | |
324 | |
325 } lzma_block; | |
326 | |
327 | |
328 /** | |
329 * \brief Decode the Block Header Size field | |
330 * | |
331 * To decode Block Header using lzma_block_header_decode(), the size of the | |
332 * Block Header has to be known and stored into lzma_block.header_size. | |
333 * The size can be calculated from the first byte of a Block using this macro. | |
334 * Note that if the first byte is 0x00, it indicates beginning of Index; use | |
335 * this macro only when the byte is not 0x00. | |
336 * | |
337 * There is no encoding macro because lzma_block_header_size() and | |
338 * lzma_block_header_encode() should be used. | |
339 */ | |
340 #define lzma_block_header_size_decode(b) (((uint32_t)(b) + 1) * 4) | |
341 | |
342 | |
343 /** | |
344 * \brief Calculate Block Header Size | |
345 * | |
346 * Calculate the minimum size needed for the Block Header field using the | |
347 * settings specified in the lzma_block structure. Note that it is OK to | |
348 * increase the calculated header_size value as long as it is a multiple of | |
349 * four and doesn't exceed LZMA_BLOCK_HEADER_SIZE_MAX. Increasing header_size | |
350 * just means that lzma_block_header_encode() will add Header Padding. | |
351 * | |
352 * \note This doesn't check that all the options are valid i.e. this | |
353 * may return LZMA_OK even if lzma_block_header_encode() or | |
354 * lzma_block_encoder() would fail. If you want to validate the | |
355 * filter chain, consider using lzma_memlimit_encoder() which as | |
356 * a side-effect validates the filter chain. | |
357 * | |
358 * \param block Block options | |
359 * | |
360 * \return Possible lzma_ret values: | |
361 * - LZMA_OK: Size calculated successfully and stored to | |
362 * block->header_size. | |
363 * - LZMA_OPTIONS_ERROR: Unsupported version, filters or | |
364 * filter options. | |
365 * - LZMA_PROG_ERROR: Invalid values like compressed_size == 0. | |
366 */ | |
367 extern LZMA_API(lzma_ret) lzma_block_header_size(lzma_block *block) | |
368 lzma_nothrow lzma_attr_warn_unused_result; | |
369 | |
370 | |
371 /** | |
372 * \brief Encode Block Header | |
373 * | |
374 * The caller must have calculated the size of the Block Header already with | |
375 * lzma_block_header_size(). If a value larger than the one calculated by | |
376 * lzma_block_header_size() is used, the Block Header will be padded to the | |
377 * specified size. | |
378 * | |
379 * \param block Block options to be encoded. | |
380 * \param[out] out Beginning of the output buffer. This must be | |
381 * at least block->header_size bytes. | |
382 * | |
383 * \return Possible lzma_ret values: | |
384 * - LZMA_OK: Encoding was successful. block->header_size | |
385 * bytes were written to output buffer. | |
386 * - LZMA_OPTIONS_ERROR: Invalid or unsupported options. | |
387 * - LZMA_PROG_ERROR: Invalid arguments, for example | |
388 * block->header_size is invalid or block->filters is NULL. | |
389 */ | |
390 extern LZMA_API(lzma_ret) lzma_block_header_encode( | |
391 const lzma_block *block, uint8_t *out) | |
392 lzma_nothrow lzma_attr_warn_unused_result; | |
393 | |
394 | |
395 /** | |
396 * \brief Decode Block Header | |
397 * | |
398 * block->version should (usually) be set to the highest value supported | |
399 * by the application. If the application sets block->version to a value | |
400 * higher than supported by the current liblzma version, this function will | |
401 * downgrade block->version to the highest value supported by it. Thus one | |
402 * should check the value of block->version after calling this function if | |
403 * block->version was set to a non-zero value and the application doesn't | |
404 * otherwise know that the liblzma version being used is new enough to | |
405 * support the specified block->version. | |
406 * | |
407 * The size of the Block Header must have already been decoded with | |
408 * lzma_block_header_size_decode() macro and stored to block->header_size. | |
409 * | |
410 * The integrity check type from Stream Header must have been stored | |
411 * to block->check. | |
412 * | |
413 * block->filters must have been allocated, but they don't need to be | |
414 * initialized (possible existing filter options are not freed). | |
415 * | |
416 * \param[out] block Destination for Block options | |
417 * \param allocator lzma_allocator for custom allocator functions. | |
418 * Set to NULL to use malloc() (and also free() | |
419 * if an error occurs). | |
420 * \param in Beginning of the input buffer. This must be | |
421 * at least block->header_size bytes. | |
422 * | |
423 * \return Possible lzma_ret values: | |
424 * - LZMA_OK: Decoding was successful. block->header_size | |
425 * bytes were read from the input buffer. | |
426 * - LZMA_OPTIONS_ERROR: The Block Header specifies some | |
427 * unsupported options such as unsupported filters. This can | |
428 * happen also if block->version was set to a too low value | |
429 * compared to what would be required to properly represent | |
430 * the information stored in the Block Header. | |
431 * - LZMA_DATA_ERROR: Block Header is corrupt, for example, | |
432 * the CRC32 doesn't match. | |
433 * - LZMA_PROG_ERROR: Invalid arguments, for example | |
434 * block->header_size is invalid or block->filters is NULL. | |
435 */ | |
436 extern LZMA_API(lzma_ret) lzma_block_header_decode(lzma_block *block, | |
437 const lzma_allocator *allocator, const uint8_t *in) | |
438 lzma_nothrow lzma_attr_warn_unused_result; | |
439 | |
440 | |
441 /** | |
442 * \brief Validate and set Compressed Size according to Unpadded Size | |
443 * | |
444 * Block Header stores Compressed Size, but Index has Unpadded Size. If the | |
445 * application has already parsed the Index and is now decoding Blocks, | |
446 * it can calculate Compressed Size from Unpadded Size. This function does | |
447 * exactly that with error checking: | |
448 * | |
449 * - Compressed Size calculated from Unpadded Size must be positive integer, | |
450 * that is, Unpadded Size must be big enough that after Block Header and | |
451 * Check fields there's still at least one byte for Compressed Size. | |
452 * | |
453 * - If Compressed Size was present in Block Header, the new value | |
454 * calculated from Unpadded Size is compared against the value | |
455 * from Block Header. | |
456 * | |
457 * \note This function must be called _after_ decoding the Block Header | |
458 * field so that it can properly validate Compressed Size if it | |
459 * was present in Block Header. | |
460 * | |
461 * \param block Block options: block->header_size must | |
462 * already be set with lzma_block_header_size(). | |
463 * \param unpadded_size Unpadded Size from the Index field in bytes | |
464 * | |
465 * \return Possible lzma_ret values: | |
466 * - LZMA_OK: block->compressed_size was set successfully. | |
467 * - LZMA_DATA_ERROR: unpadded_size is too small compared to | |
468 * block->header_size and lzma_check_size(block->check). | |
469 * - LZMA_PROG_ERROR: Some values are invalid. For example, | |
470 * block->header_size must be a multiple of four and | |
471 * between 8 and 1024 inclusive. | |
472 */ | |
473 extern LZMA_API(lzma_ret) lzma_block_compressed_size( | |
474 lzma_block *block, lzma_vli unpadded_size) | |
475 lzma_nothrow lzma_attr_warn_unused_result; | |
476 | |
477 | |
478 /** | |
479 * \brief Calculate Unpadded Size | |
480 * | |
481 * The Index field stores Unpadded Size and Uncompressed Size. The latter | |
482 * can be taken directly from the lzma_block structure after coding a Block, | |
483 * but Unpadded Size needs to be calculated from Block Header Size, | |
484 * Compressed Size, and size of the Check field. This is where this function | |
485 * is needed. | |
486 * | |
487 * \param block Block options: block->header_size must already be | |
488 * set with lzma_block_header_size(). | |
489 * | |
490 * \return Unpadded Size on success, or zero on error. | |
491 */ | |
492 extern LZMA_API(lzma_vli) lzma_block_unpadded_size(const lzma_block *block) | |
493 lzma_nothrow lzma_attr_pure; | |
494 | |
495 | |
496 /** | |
497 * \brief Calculate the total encoded size of a Block | |
498 * | |
499 * This is equivalent to lzma_block_unpadded_size() except that the returned | |
500 * value includes the size of the Block Padding field. | |
501 * | |
502 * \param block Block options: block->header_size must already be | |
503 * set with lzma_block_header_size(). | |
504 * | |
505 * \return On success, total encoded size of the Block. On error, | |
506 * zero is returned. | |
507 */ | |
508 extern LZMA_API(lzma_vli) lzma_block_total_size(const lzma_block *block) | |
509 lzma_nothrow lzma_attr_pure; | |
510 | |
511 | |
512 /** | |
513 * \brief Initialize .xz Block encoder | |
514 * | |
515 * Valid actions for lzma_code() are LZMA_RUN, LZMA_SYNC_FLUSH (only if the | |
516 * filter chain supports it), and LZMA_FINISH. | |
517 * | |
518 * The Block encoder encodes the Block Data, Block Padding, and Check value. | |
519 * It does NOT encode the Block Header which can be encoded with | |
520 * lzma_block_header_encode(). | |
521 * | |
522 * \param strm Pointer to lzma_stream that is at least initialized | |
523 * with LZMA_STREAM_INIT. | |
524 * \param block Block options: block->version, block->check, | |
525 * and block->filters must have been initialized. | |
526 * | |
527 * \return Possible lzma_ret values: | |
528 * - LZMA_OK: All good, continue with lzma_code(). | |
529 * - LZMA_MEM_ERROR | |
530 * - LZMA_OPTIONS_ERROR | |
531 * - LZMA_UNSUPPORTED_CHECK: block->check specifies a Check ID | |
532 * that is not supported by this build of liblzma. Initializing | |
533 * the encoder failed. | |
534 * - LZMA_PROG_ERROR | |
535 */ | |
536 extern LZMA_API(lzma_ret) lzma_block_encoder( | |
537 lzma_stream *strm, lzma_block *block) | |
538 lzma_nothrow lzma_attr_warn_unused_result; | |
539 | |
540 | |
541 /** | |
542 * \brief Initialize .xz Block decoder | |
543 * | |
544 * Valid actions for lzma_code() are LZMA_RUN and LZMA_FINISH. Using | |
545 * LZMA_FINISH is not required. It is supported only for convenience. | |
546 * | |
547 * The Block decoder decodes the Block Data, Block Padding, and Check value. | |
548 * It does NOT decode the Block Header which can be decoded with | |
549 * lzma_block_header_decode(). | |
550 * | |
551 * \param strm Pointer to lzma_stream that is at least initialized | |
552 * with LZMA_STREAM_INIT. | |
553 * \param block Block options | |
554 * | |
555 * \return Possible lzma_ret values: | |
556 * - LZMA_OK: All good, continue with lzma_code(). | |
557 * - LZMA_PROG_ERROR | |
558 * - LZMA_MEM_ERROR | |
559 */ | |
560 extern LZMA_API(lzma_ret) lzma_block_decoder( | |
561 lzma_stream *strm, lzma_block *block) | |
562 lzma_nothrow lzma_attr_warn_unused_result; | |
563 | |
564 | |
565 /** | |
566 * \brief Calculate maximum output size for single-call Block encoding | |
567 * | |
568 * This is equivalent to lzma_stream_buffer_bound() but for .xz Blocks. | |
569 * See the documentation of lzma_stream_buffer_bound(). | |
570 * | |
571 * \param uncompressed_size Size of the data to be encoded with the | |
572 * single-call Block encoder. | |
573 * | |
574 * \return Maximum output size in bytes for single-call Block encoding. | |
575 */ | |
576 extern LZMA_API(size_t) lzma_block_buffer_bound(size_t uncompressed_size) | |
577 lzma_nothrow; | |
578 | |
579 | |
580 /** | |
581 * \brief Single-call .xz Block encoder | |
582 * | |
583 * In contrast to the multi-call encoder initialized with | |
584 * lzma_block_encoder(), this function encodes also the Block Header. This | |
585 * is required to make it possible to write appropriate Block Header also | |
586 * in case the data isn't compressible, and different filter chain has to be | |
587 * used to encode the data in uncompressed form using uncompressed chunks | |
588 * of the LZMA2 filter. | |
589 * | |
590 * When the data isn't compressible, header_size, compressed_size, and | |
591 * uncompressed_size are set just like when the data was compressible, but | |
592 * it is possible that header_size is too small to hold the filter chain | |
593 * specified in block->filters, because that isn't necessarily the filter | |
594 * chain that was actually used to encode the data. lzma_block_unpadded_size() | |
595 * still works normally, because it doesn't read the filters array. | |
596 * | |
597 * \param block Block options: block->version, block->check, | |
598 * and block->filters must have been initialized. | |
599 * \param allocator lzma_allocator for custom allocator functions. | |
600 * Set to NULL to use malloc() and free(). | |
601 * \param in Beginning of the input buffer | |
602 * \param in_size Size of the input buffer | |
603 * \param[out] out Beginning of the output buffer | |
604 * \param[out] out_pos The next byte will be written to out[*out_pos]. | |
605 * *out_pos is updated only if encoding succeeds. | |
606 * \param out_size Size of the out buffer; the first byte into | |
607 * which no data is written to is out[out_size]. | |
608 * | |
609 * \return Possible lzma_ret values: | |
610 * - LZMA_OK: Encoding was successful. | |
611 * - LZMA_BUF_ERROR: Not enough output buffer space. | |
612 * - LZMA_UNSUPPORTED_CHECK | |
613 * - LZMA_OPTIONS_ERROR | |
614 * - LZMA_MEM_ERROR | |
615 * - LZMA_DATA_ERROR | |
616 * - LZMA_PROG_ERROR | |
617 */ | |
618 extern LZMA_API(lzma_ret) lzma_block_buffer_encode( | |
619 lzma_block *block, const lzma_allocator *allocator, | |
620 const uint8_t *in, size_t in_size, | |
621 uint8_t *out, size_t *out_pos, size_t out_size) | |
622 lzma_nothrow lzma_attr_warn_unused_result; | |
623 | |
624 | |
625 /** | |
626 * \brief Single-call uncompressed .xz Block encoder | |
627 * | |
628 * This is like lzma_block_buffer_encode() except this doesn't try to | |
629 * compress the data and instead encodes the data using LZMA2 uncompressed | |
630 * chunks. The required output buffer size can be determined with | |
631 * lzma_block_buffer_bound(). | |
632 * | |
633 * Since the data won't be compressed, this function ignores block->filters. | |
634 * This function doesn't take lzma_allocator because this function doesn't | |
635 * allocate any memory from the heap. | |
636 * | |
637 * \param block Block options: block->version, block->check, | |
638 * and block->filters must have been initialized. | |
639 * \param in Beginning of the input buffer | |
640 * \param in_size Size of the input buffer | |
641 * \param[out] out Beginning of the output buffer | |
642 * \param[out] out_pos The next byte will be written to out[*out_pos]. | |
643 * *out_pos is updated only if encoding succeeds. | |
644 * \param out_size Size of the out buffer; the first byte into | |
645 * which no data is written to is out[out_size]. | |
646 * | |
647 * \return Possible lzma_ret values: | |
648 * - LZMA_OK: Encoding was successful. | |
649 * - LZMA_BUF_ERROR: Not enough output buffer space. | |
650 * - LZMA_UNSUPPORTED_CHECK | |
651 * - LZMA_OPTIONS_ERROR | |
652 * - LZMA_MEM_ERROR | |
653 * - LZMA_DATA_ERROR | |
654 * - LZMA_PROG_ERROR | |
655 */ | |
656 extern LZMA_API(lzma_ret) lzma_block_uncomp_encode(lzma_block *block, | |
657 const uint8_t *in, size_t in_size, | |
658 uint8_t *out, size_t *out_pos, size_t out_size) | |
659 lzma_nothrow lzma_attr_warn_unused_result; | |
660 | |
661 | |
662 /** | |
663 * \brief Single-call .xz Block decoder | |
664 * | |
665 * This is single-call equivalent of lzma_block_decoder(), and requires that | |
666 * the caller has already decoded Block Header and checked its memory usage. | |
667 * | |
668 * \param block Block options | |
669 * \param allocator lzma_allocator for custom allocator functions. | |
670 * Set to NULL to use malloc() and free(). | |
671 * \param in Beginning of the input buffer | |
672 * \param in_pos The next byte will be read from in[*in_pos]. | |
673 * *in_pos is updated only if decoding succeeds. | |
674 * \param in_size Size of the input buffer; the first byte that | |
675 * won't be read is in[in_size]. | |
676 * \param[out] out Beginning of the output buffer | |
677 * \param[out] out_pos The next byte will be written to out[*out_pos]. | |
678 * *out_pos is updated only if encoding succeeds. | |
679 * \param out_size Size of the out buffer; the first byte into | |
680 * which no data is written to is out[out_size]. | |
681 * | |
682 * \return Possible lzma_ret values: | |
683 * - LZMA_OK: Decoding was successful. | |
684 * - LZMA_OPTIONS_ERROR | |
685 * - LZMA_DATA_ERROR | |
686 * - LZMA_MEM_ERROR | |
687 * - LZMA_BUF_ERROR: Output buffer was too small. | |
688 * - LZMA_PROG_ERROR | |
689 */ | |
690 extern LZMA_API(lzma_ret) lzma_block_buffer_decode( | |
691 lzma_block *block, const lzma_allocator *allocator, | |
692 const uint8_t *in, size_t *in_pos, size_t in_size, | |
693 uint8_t *out, size_t *out_pos, size_t out_size) | |
694 lzma_nothrow; |