1207753Smm/**
2207753Smm * \file        lzma/block.h
3207753Smm * \brief       .xz Block handling
4207753Smm */
5207753Smm
6207753Smm/*
7207753Smm * Author: Lasse Collin
8207753Smm *
9207753Smm * This file has been put into the public domain.
10207753Smm * You can do whatever you want with this file.
11207753Smm *
12207753Smm * See ../lzma.h for information about liblzma as a whole.
13207753Smm */
14207753Smm
15207753Smm#ifndef LZMA_H_INTERNAL
16207753Smm#	error Never include this file directly. Use <lzma.h> instead.
17207753Smm#endif
18207753Smm
19207753Smm
20207753Smm/**
21207753Smm * \brief       Options for the Block and Block Header encoders and decoders
22207753Smm *
23207753Smm * Different Block handling functions use different parts of this structure.
24207753Smm * Some read some members, other functions write, and some do both. Only the
25207753Smm * members listed for reading need to be initialized when the specified
26207753Smm * functions are called. The members marked for writing will be assigned
27207753Smm * new values at some point either by calling the given function or by
28207753Smm * later calls to lzma_code().
29207753Smm */
30207753Smmtypedef struct {
31207753Smm	/**
32207753Smm	 * \brief       Block format version
33207753Smm	 *
34207753Smm	 * To prevent API and ABI breakages if new features are needed in
35207753Smm	 * the Block field, a version number is used to indicate which
36207753Smm	 * fields in this structure are in use. For now, version must always
37207753Smm	 * be zero. With non-zero version, most Block related functions will
38207753Smm	 * return LZMA_OPTIONS_ERROR.
39207753Smm	 *
40207753Smm	 * Read by:
41207753Smm	 *  - All functions that take pointer to lzma_block as argument,
42207753Smm	 *    including lzma_block_header_decode().
43207753Smm	 *
44207753Smm	 * Written by:
45207753Smm	 *  - lzma_block_header_decode()
46207753Smm	 */
47207753Smm	uint32_t version;
48207753Smm
49207753Smm	/**
50207753Smm	 * \brief       Size of the Block Header field
51207753Smm	 *
52207753Smm	 * This is always a multiple of four.
53207753Smm	 *
54207753Smm	 * Read by:
55207753Smm	 *  - lzma_block_header_encode()
56207753Smm	 *  - lzma_block_header_decode()
57207753Smm	 *  - lzma_block_compressed_size()
58207753Smm	 *  - lzma_block_unpadded_size()
59207753Smm	 *  - lzma_block_total_size()
60207753Smm	 *  - lzma_block_decoder()
61207753Smm	 *  - lzma_block_buffer_decode()
62207753Smm	 *
63207753Smm	 * Written by:
64207753Smm	 *  - lzma_block_header_size()
65207753Smm	 *  - lzma_block_buffer_encode()
66207753Smm	 */
67207753Smm	uint32_t header_size;
68207753Smm#	define LZMA_BLOCK_HEADER_SIZE_MIN 8
69207753Smm#	define LZMA_BLOCK_HEADER_SIZE_MAX 1024
70207753Smm
71207753Smm	/**
72207753Smm	 * \brief       Type of integrity Check
73207753Smm	 *
74207753Smm	 * The Check ID is not stored into the Block Header, thus its value
75207753Smm	 * must be provided also when decoding.
76207753Smm	 *
77207753Smm	 * Read by:
78207753Smm	 *  - lzma_block_header_encode()
79207753Smm	 *  - lzma_block_header_decode()
80207753Smm	 *  - lzma_block_compressed_size()
81207753Smm	 *  - lzma_block_unpadded_size()
82207753Smm	 *  - lzma_block_total_size()
83207753Smm	 *  - lzma_block_encoder()
84207753Smm	 *  - lzma_block_decoder()
85207753Smm	 *  - lzma_block_buffer_encode()
86207753Smm	 *  - lzma_block_buffer_decode()
87207753Smm	 */
88207753Smm	lzma_check check;
89207753Smm
90207753Smm	/**
91207753Smm	 * \brief       Size of the Compressed Data in bytes
92207753Smm	 *
93207753Smm	 * Encoding: If this is not LZMA_VLI_UNKNOWN, Block Header encoder
94207753Smm	 * will store this value to the Block Header. Block encoder doesn't
95207753Smm	 * care about this value, but will set it once the encoding has been
96207753Smm	 * finished.
97207753Smm	 *
98207753Smm	 * Decoding: If this is not LZMA_VLI_UNKNOWN, Block decoder will
99207753Smm	 * verify that the size of the Compressed Data field matches
100207753Smm	 * compressed_size.
101207753Smm	 *
102207753Smm	 * Usually you don't know this value when encoding in streamed mode,
103207753Smm	 * and thus cannot write this field into the Block Header.
104207753Smm	 *
105207753Smm	 * In non-streamed mode you can reserve space for this field before
106207753Smm	 * encoding the actual Block. After encoding the data, finish the
107207753Smm	 * Block by encoding the Block Header. Steps in detail:
108207753Smm	 *
109207753Smm	 *  - Set compressed_size to some big enough value. If you don't know
110207753Smm	 *    better, use LZMA_VLI_MAX, but remember that bigger values take
111207753Smm	 *    more space in Block Header.
112207753Smm	 *
113207753Smm	 *  - Call lzma_block_header_size() to see how much space you need to
114207753Smm	 *    reserve for the Block Header.
115207753Smm	 *
116207753Smm	 *  - Encode the Block using lzma_block_encoder() and lzma_code().
117207753Smm	 *    It sets compressed_size to the correct value.
118207753Smm	 *
119207753Smm	 *  - Use lzma_block_header_encode() to encode the Block Header.
120207753Smm	 *    Because space was reserved in the first step, you don't need
121207753Smm	 *    to call lzma_block_header_size() anymore, because due to
122207753Smm	 *    reserving, header_size has to be big enough. If it is "too big",
123207753Smm	 *    lzma_block_header_encode() will add enough Header Padding to
124207753Smm	 *    make Block Header to match the size specified by header_size.
125207753Smm	 *
126207753Smm	 * Read by:
127207753Smm	 *  - lzma_block_header_size()
128207753Smm	 *  - lzma_block_header_encode()
129207753Smm	 *  - lzma_block_compressed_size()
130207753Smm	 *  - lzma_block_unpadded_size()
131207753Smm	 *  - lzma_block_total_size()
132207753Smm	 *  - lzma_block_decoder()
133207753Smm	 *  - lzma_block_buffer_decode()
134207753Smm	 *
135207753Smm	 * Written by:
136207753Smm	 *  - lzma_block_header_decode()
137207753Smm	 *  - lzma_block_compressed_size()
138207753Smm	 *  - lzma_block_encoder()
139207753Smm	 *  - lzma_block_decoder()
140207753Smm	 *  - lzma_block_buffer_encode()
141207753Smm	 *  - lzma_block_buffer_decode()
142207753Smm	 */
143207753Smm	lzma_vli compressed_size;
144207753Smm
145207753Smm	/**
146207753Smm	 * \brief       Uncompressed Size in bytes
147207753Smm	 *
148207753Smm	 * This is handled very similarly to compressed_size above.
149207753Smm	 *
150207753Smm	 * uncompressed_size is needed by fewer functions than
151207753Smm	 * compressed_size. This is because uncompressed_size isn't
152207753Smm	 * needed to validate that Block stays within proper limits.
153207753Smm	 *
154207753Smm	 * Read by:
155207753Smm	 *  - lzma_block_header_size()
156207753Smm	 *  - lzma_block_header_encode()
157207753Smm	 *  - lzma_block_decoder()
158207753Smm	 *  - lzma_block_buffer_decode()
159207753Smm	 *
160207753Smm	 * Written by:
161207753Smm	 *  - lzma_block_header_decode()
162207753Smm	 *  - lzma_block_encoder()
163207753Smm	 *  - lzma_block_decoder()
164207753Smm	 *  - lzma_block_buffer_encode()
165207753Smm	 *  - lzma_block_buffer_decode()
166207753Smm	 */
167207753Smm	lzma_vli uncompressed_size;
168207753Smm
169207753Smm	/**
170207753Smm	 * \brief       Array of filters
171207753Smm	 *
172207753Smm	 * There can be 1-4 filters. The end of the array is marked with
173207753Smm	 * .id = LZMA_VLI_UNKNOWN.
174207753Smm	 *
175207753Smm	 * Read by:
176207753Smm	 *  - lzma_block_header_size()
177207753Smm	 *  - lzma_block_header_encode()
178207753Smm	 *  - lzma_block_encoder()
179207753Smm	 *  - lzma_block_decoder()
180207753Smm	 *  - lzma_block_buffer_encode()
181207753Smm	 *  - lzma_block_buffer_decode()
182207753Smm	 *
183207753Smm	 * Written by:
184207753Smm	 *  - lzma_block_header_decode(): Note that this does NOT free()
185207753Smm	 *    the old filter options structures. All unused filters[] will
186207753Smm	 *    have .id == LZMA_VLI_UNKNOWN and .options == NULL. If
187207753Smm	 *    decoding fails, all filters[] are guaranteed to be
188207753Smm	 *    LZMA_VLI_UNKNOWN and NULL.
189207753Smm	 *
190207753Smm	 * \note        Because of the array is terminated with
191207753Smm	 *              .id = LZMA_VLI_UNKNOWN, the actual array must
192207753Smm	 *              have LZMA_FILTERS_MAX + 1 members or the Block
193207753Smm	 *              Header decoder will overflow the buffer.
194207753Smm	 */
195207753Smm	lzma_filter *filters;
196207753Smm
197207753Smm	/**
198207753Smm	 * \brief       Raw value stored in the Check field
199207753Smm	 *
200207753Smm	 * After successful coding, the first lzma_check_size(check) bytes
201207753Smm	 * of this array contain the raw value stored in the Check field.
202207753Smm	 *
203207753Smm	 * Note that CRC32 and CRC64 are stored in little endian byte order.
204207753Smm	 * Take it into account if you display the Check values to the user.
205207753Smm	 *
206207753Smm	 * Written by:
207207753Smm	 *  - lzma_block_encoder()
208207753Smm	 *  - lzma_block_decoder()
209207753Smm	 *  - lzma_block_buffer_encode()
210207753Smm	 *  - lzma_block_buffer_decode()
211207753Smm	 */
212207753Smm	uint8_t raw_check[LZMA_CHECK_SIZE_MAX];
213207753Smm
214207753Smm	/*
215207753Smm	 * Reserved space to allow possible future extensions without
216207753Smm	 * breaking the ABI. You should not touch these, because the names
217207753Smm	 * of these variables may change. These are and will never be used
218207753Smm	 * with the currently supported options, so it is safe to leave these
219207753Smm	 * uninitialized.
220207753Smm	 */
221207753Smm	void *reserved_ptr1;
222207753Smm	void *reserved_ptr2;
223207753Smm	void *reserved_ptr3;
224207753Smm	uint32_t reserved_int1;
225207753Smm	uint32_t reserved_int2;
226207753Smm	lzma_vli reserved_int3;
227207753Smm	lzma_vli reserved_int4;
228207753Smm	lzma_vli reserved_int5;
229207753Smm	lzma_vli reserved_int6;
230207753Smm	lzma_vli reserved_int7;
231207753Smm	lzma_vli reserved_int8;
232207753Smm	lzma_reserved_enum reserved_enum1;
233207753Smm	lzma_reserved_enum reserved_enum2;
234207753Smm	lzma_reserved_enum reserved_enum3;
235207753Smm	lzma_reserved_enum reserved_enum4;
236207753Smm	lzma_bool reserved_bool1;
237207753Smm	lzma_bool reserved_bool2;
238207753Smm	lzma_bool reserved_bool3;
239207753Smm	lzma_bool reserved_bool4;
240207753Smm	lzma_bool reserved_bool5;
241207753Smm	lzma_bool reserved_bool6;
242207753Smm	lzma_bool reserved_bool7;
243207753Smm	lzma_bool reserved_bool8;
244207753Smm
245207753Smm} lzma_block;
246207753Smm
247207753Smm
248207753Smm/**
249207753Smm * \brief       Decode the Block Header Size field
250207753Smm *
251207753Smm * To decode Block Header using lzma_block_header_decode(), the size of the
252207753Smm * Block Header has to be known and stored into lzma_block.header_size.
253207753Smm * The size can be calculated from the first byte of a Block using this macro.
254207753Smm * Note that if the first byte is 0x00, it indicates beginning of Index; use
255207753Smm * this macro only when the byte is not 0x00.
256207753Smm *
257207753Smm * There is no encoding macro, because Block Header encoder is enough for that.
258207753Smm */
259207753Smm#define lzma_block_header_size_decode(b) (((uint32_t)(b) + 1) * 4)
260207753Smm
261207753Smm
262207753Smm/**
263207753Smm * \brief       Calculate Block Header Size
264207753Smm *
265207753Smm * Calculate the minimum size needed for the Block Header field using the
266207753Smm * settings specified in the lzma_block structure. Note that it is OK to
267207753Smm * increase the calculated header_size value as long as it is a multiple of
268207753Smm * four and doesn't exceed LZMA_BLOCK_HEADER_SIZE_MAX. Increasing header_size
269207753Smm * just means that lzma_block_header_encode() will add Header Padding.
270207753Smm *
271207753Smm * \return      - LZMA_OK: Size calculated successfully and stored to
272207753Smm *                block->header_size.
273207753Smm *              - LZMA_OPTIONS_ERROR: Unsupported version, filters or
274207753Smm *                filter options.
275207753Smm *              - LZMA_PROG_ERROR: Invalid values like compressed_size == 0.
276207753Smm *
277207753Smm * \note        This doesn't check that all the options are valid i.e. this
278207753Smm *              may return LZMA_OK even if lzma_block_header_encode() or
279207753Smm *              lzma_block_encoder() would fail. If you want to validate the
280207753Smm *              filter chain, consider using lzma_memlimit_encoder() which as
281207753Smm *              a side-effect validates the filter chain.
282207753Smm */
283207753Smmextern LZMA_API(lzma_ret) lzma_block_header_size(lzma_block *block)
284207753Smm		lzma_nothrow lzma_attr_warn_unused_result;
285207753Smm
286207753Smm
287207753Smm/**
288207753Smm * \brief       Encode Block Header
289207753Smm *
290207753Smm * The caller must have calculated the size of the Block Header already with
291207753Smm * lzma_block_header_size(). If a value larger than the one calculated by
292207753Smm * lzma_block_header_size() is used, the Block Header will be padded to the
293207753Smm * specified size.
294207753Smm *
295207753Smm * \param       out         Beginning of the output buffer. This must be
296207753Smm *                          at least block->header_size bytes.
297207753Smm * \param       block       Block options to be encoded.
298207753Smm *
299207753Smm * \return      - LZMA_OK: Encoding was successful. block->header_size
300207753Smm *                bytes were written to output buffer.
301207753Smm *              - LZMA_OPTIONS_ERROR: Invalid or unsupported options.
302207753Smm *              - LZMA_PROG_ERROR: Invalid arguments, for example
303207753Smm *                block->header_size is invalid or block->filters is NULL.
304207753Smm */
305207753Smmextern LZMA_API(lzma_ret) lzma_block_header_encode(
306207753Smm		const lzma_block *block, uint8_t *out)
307207753Smm		lzma_nothrow lzma_attr_warn_unused_result;
308207753Smm
309207753Smm
310207753Smm/**
311207753Smm * \brief       Decode Block Header
312207753Smm *
313207753Smm * block->version should be set to the highest value supported by the
314207753Smm * application; currently the only possible version is zero. This function
315207753Smm * will set version to the lowest value that still supports all the features
316207753Smm * required by the Block Header.
317207753Smm *
318207753Smm * The size of the Block Header must have already been decoded with
319207753Smm * lzma_block_header_size_decode() macro and stored to block->header_size.
320207753Smm *
321215187Smm * block->filters must have been allocated, but they don't need to be
322215187Smm * initialized (possible existing filter options are not freed).
323207753Smm *
324207753Smm * \param       block       Destination for Block options.
325207753Smm * \param       allocator   lzma_allocator for custom allocator functions.
326207753Smm *                          Set to NULL to use malloc() (and also free()
327207753Smm *                          if an error occurs).
328207753Smm * \param       in          Beginning of the input buffer. This must be
329207753Smm *                          at least block->header_size bytes.
330207753Smm *
331207753Smm * \return      - LZMA_OK: Decoding was successful. block->header_size
332207753Smm *                bytes were read from the input buffer.
333207753Smm *              - LZMA_OPTIONS_ERROR: The Block Header specifies some
334207753Smm *                unsupported options such as unsupported filters. This can
335207753Smm *                happen also if block->version was set to a too low value
336207753Smm *                compared to what would be required to properly represent
337207753Smm *                the information stored in the Block Header.
338207753Smm *              - LZMA_DATA_ERROR: Block Header is corrupt, for example,
339207753Smm *                the CRC32 doesn't match.
340207753Smm *              - LZMA_PROG_ERROR: Invalid arguments, for example
341207753Smm *                block->header_size is invalid or block->filters is NULL.
342207753Smm */
343207753Smmextern LZMA_API(lzma_ret) lzma_block_header_decode(lzma_block *block,
344207753Smm		lzma_allocator *allocator, const uint8_t *in)
345207753Smm		lzma_nothrow lzma_attr_warn_unused_result;
346207753Smm
347207753Smm
348207753Smm/**
349207753Smm * \brief       Validate and set Compressed Size according to Unpadded Size
350207753Smm *
351207753Smm * Block Header stores Compressed Size, but Index has Unpadded Size. If the
352207753Smm * application has already parsed the Index and is now decoding Blocks,
353207753Smm * it can calculate Compressed Size from Unpadded Size. This function does
354207753Smm * exactly that with error checking:
355207753Smm *
356207753Smm *  - Compressed Size calculated from Unpadded Size must be positive integer,
357207753Smm *    that is, Unpadded Size must be big enough that after Block Header and
358207753Smm *    Check fields there's still at least one byte for Compressed Size.
359207753Smm *
360207753Smm *  - If Compressed Size was present in Block Header, the new value
361207753Smm *    calculated from Unpadded Size is compared against the value
362207753Smm *    from Block Header.
363207753Smm *
364207753Smm * \note        This function must be called _after_ decoding the Block Header
365207753Smm *              field so that it can properly validate Compressed Size if it
366207753Smm *              was present in Block Header.
367207753Smm *
368207753Smm * \return      - LZMA_OK: block->compressed_size was set successfully.
369207753Smm *              - LZMA_DATA_ERROR: unpadded_size is too small compared to
370207753Smm *                block->header_size and lzma_check_size(block->check).
371207753Smm *              - LZMA_PROG_ERROR: Some values are invalid. For example,
372207753Smm *                block->header_size must be a multiple of four and
373207753Smm *                between 8 and 1024 inclusive.
374207753Smm */
375207753Smmextern LZMA_API(lzma_ret) lzma_block_compressed_size(
376207753Smm		lzma_block *block, lzma_vli unpadded_size)
377207753Smm		lzma_nothrow lzma_attr_warn_unused_result;
378207753Smm
379207753Smm
380207753Smm/**
381207753Smm * \brief       Calculate Unpadded Size
382207753Smm *
383207753Smm * The Index field stores Unpadded Size and Uncompressed Size. The latter
384207753Smm * can be taken directly from the lzma_block structure after coding a Block,
385207753Smm * but Unpadded Size needs to be calculated from Block Header Size,
386207753Smm * Compressed Size, and size of the Check field. This is where this function
387207753Smm * is needed.
388207753Smm *
389207753Smm * \return      Unpadded Size on success, or zero on error.
390207753Smm */
391207753Smmextern LZMA_API(lzma_vli) lzma_block_unpadded_size(const lzma_block *block)
392207753Smm		lzma_nothrow lzma_attr_pure;
393207753Smm
394207753Smm
395207753Smm/**
396207753Smm * \brief       Calculate the total encoded size of a Block
397207753Smm *
398207753Smm * This is equivalent to lzma_block_unpadded_size() except that the returned
399207753Smm * value includes the size of the Block Padding field.
400207753Smm *
401207753Smm * \return      On success, total encoded size of the Block. On error,
402207753Smm *              zero is returned.
403207753Smm */
404207753Smmextern LZMA_API(lzma_vli) lzma_block_total_size(const lzma_block *block)
405207753Smm		lzma_nothrow lzma_attr_pure;
406207753Smm
407207753Smm
408207753Smm/**
409207753Smm * \brief       Initialize .xz Block encoder
410207753Smm *
411207753Smm * Valid actions for lzma_code() are LZMA_RUN, LZMA_SYNC_FLUSH (only if the
412207753Smm * filter chain supports it), and LZMA_FINISH.
413207753Smm *
414207753Smm * \return      - LZMA_OK: All good, continue with lzma_code().
415207753Smm *              - LZMA_MEM_ERROR
416207753Smm *              - LZMA_OPTIONS_ERROR
417207753Smm *              - LZMA_UNSUPPORTED_CHECK: block->check specifies a Check ID
418207753Smm *                that is not supported by this buid of liblzma. Initializing
419207753Smm *                the encoder failed.
420207753Smm *              - LZMA_PROG_ERROR
421207753Smm */
422207753Smmextern LZMA_API(lzma_ret) lzma_block_encoder(
423207753Smm		lzma_stream *strm, lzma_block *block)
424207753Smm		lzma_nothrow lzma_attr_warn_unused_result;
425207753Smm
426207753Smm
427207753Smm/**
428207753Smm * \brief       Initialize .xz Block decoder
429207753Smm *
430207753Smm * Valid actions for lzma_code() are LZMA_RUN and LZMA_FINISH. Using
431207753Smm * LZMA_FINISH is not required. It is supported only for convenience.
432207753Smm *
433207753Smm * \return      - LZMA_OK: All good, continue with lzma_code().
434207753Smm *              - LZMA_UNSUPPORTED_CHECK: Initialization was successful, but
435207753Smm *                the given Check ID is not supported, thus Check will be
436207753Smm *                ignored.
437207753Smm *              - LZMA_PROG_ERROR
438207753Smm *              - LZMA_MEM_ERROR
439207753Smm */
440207753Smmextern LZMA_API(lzma_ret) lzma_block_decoder(
441207753Smm		lzma_stream *strm, lzma_block *block)
442207753Smm		lzma_nothrow lzma_attr_warn_unused_result;
443207753Smm
444207753Smm
445207753Smm/**
446207753Smm * \brief       Calculate maximum output size for single-call Block encoding
447207753Smm *
448207753Smm * This is equivalent to lzma_stream_buffer_bound() but for .xz Blocks.
449207753Smm * See the documentation of lzma_stream_buffer_bound().
450207753Smm */
451207753Smmextern LZMA_API(size_t) lzma_block_buffer_bound(size_t uncompressed_size)
452207753Smm		lzma_nothrow;
453207753Smm
454207753Smm
455207753Smm/**
456207753Smm * \brief       Single-call .xz Block encoder
457207753Smm *
458207753Smm * In contrast to the multi-call encoder initialized with
459207753Smm * lzma_block_encoder(), this function encodes also the Block Header. This
460207753Smm * is required to make it possible to write appropriate Block Header also
461207753Smm * in case the data isn't compressible, and different filter chain has to be
462207753Smm * used to encode the data in uncompressed form using uncompressed chunks
463207753Smm * of the LZMA2 filter.
464207753Smm *
465207753Smm * When the data isn't compressible, header_size, compressed_size, and
466207753Smm * uncompressed_size are set just like when the data was compressible, but
467207753Smm * it is possible that header_size is too small to hold the filter chain
468207753Smm * specified in block->filters, because that isn't necessarily the filter
469207753Smm * chain that was actually used to encode the data. lzma_block_unpadded_size()
470207753Smm * still works normally, because it doesn't read the filters array.
471207753Smm *
472207753Smm * \param       block       Block options: block->version, block->check,
473207753Smm *                          and block->filters must have been initialized.
474207753Smm * \param       allocator   lzma_allocator for custom allocator functions.
475207753Smm *                          Set to NULL to use malloc() and free().
476207753Smm * \param       in          Beginning of the input buffer
477207753Smm * \param       in_size     Size of the input buffer
478207753Smm * \param       out         Beginning of the output buffer
479207753Smm * \param       out_pos     The next byte will be written to out[*out_pos].
480207753Smm *                          *out_pos is updated only if encoding succeeds.
481207753Smm * \param       out_size    Size of the out buffer; the first byte into
482207753Smm *                          which no data is written to is out[out_size].
483207753Smm *
484207753Smm * \return      - LZMA_OK: Encoding was successful.
485207753Smm *              - LZMA_BUF_ERROR: Not enough output buffer space.
486223935Smm *              - LZMA_UNSUPPORTED_CHECK
487207753Smm *              - LZMA_OPTIONS_ERROR
488207753Smm *              - LZMA_MEM_ERROR
489207753Smm *              - LZMA_DATA_ERROR
490207753Smm *              - LZMA_PROG_ERROR
491207753Smm */
492207753Smmextern LZMA_API(lzma_ret) lzma_block_buffer_encode(
493207753Smm		lzma_block *block, lzma_allocator *allocator,
494207753Smm		const uint8_t *in, size_t in_size,
495207753Smm		uint8_t *out, size_t *out_pos, size_t out_size)
496207753Smm		lzma_nothrow lzma_attr_warn_unused_result;
497207753Smm
498207753Smm
499207753Smm/**
500207753Smm * \brief       Single-call .xz Block decoder
501207753Smm *
502207753Smm * This is single-call equivalent of lzma_block_decoder(), and requires that
503207753Smm * the caller has already decoded Block Header and checked its memory usage.
504207753Smm *
505207753Smm * \param       block       Block options just like with lzma_block_decoder().
506207753Smm * \param       allocator   lzma_allocator for custom allocator functions.
507207753Smm *                          Set to NULL to use malloc() and free().
508207753Smm * \param       in          Beginning of the input buffer
509207753Smm * \param       in_pos      The next byte will be read from in[*in_pos].
510207753Smm *                          *in_pos is updated only if decoding succeeds.
511207753Smm * \param       in_size     Size of the input buffer; the first byte that
512207753Smm *                          won't be read is in[in_size].
513207753Smm * \param       out         Beginning of the output buffer
514207753Smm * \param       out_pos     The next byte will be written to out[*out_pos].
515207753Smm *                          *out_pos is updated only if encoding succeeds.
516207753Smm * \param       out_size    Size of the out buffer; the first byte into
517207753Smm *                          which no data is written to is out[out_size].
518207753Smm *
519207753Smm * \return      - LZMA_OK: Decoding was successful.
520207753Smm *              - LZMA_OPTIONS_ERROR
521207753Smm *              - LZMA_DATA_ERROR
522207753Smm *              - LZMA_MEM_ERROR
523207753Smm *              - LZMA_BUF_ERROR: Output buffer was too small.
524207753Smm *              - LZMA_PROG_ERROR
525207753Smm */
526207753Smmextern LZMA_API(lzma_ret) lzma_block_buffer_decode(
527207753Smm		lzma_block *block, lzma_allocator *allocator,
528207753Smm		const uint8_t *in, size_t *in_pos, size_t in_size,
529207753Smm		uint8_t *out, size_t *out_pos, size_t out_size)
530207753Smm		lzma_nothrow;
531