1*b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
2bc22c17eSAlain Knaff #ifndef DECOMPRESS_GENERIC_H
3bc22c17eSAlain Knaff #define DECOMPRESS_GENERIC_H
4bc22c17eSAlain Knaff 
5d97b07c5SYinghai Lu typedef int (*decompress_fn) (unsigned char *inbuf, long len,
6d97b07c5SYinghai Lu 			      long (*fill)(void*, unsigned long),
7d97b07c5SYinghai Lu 			      long (*flush)(void*, unsigned long),
8daeb6b6fSPhillip Lougher 			      unsigned char *outbuf,
9d97b07c5SYinghai Lu 			      long *posp,
10bc22c17eSAlain Knaff 			      void(*error)(char *x));
11bc22c17eSAlain Knaff 
12bc22c17eSAlain Knaff /* inbuf   - input buffer
13bc22c17eSAlain Knaff  *len     - len of pre-read data in inbuf
14daeb6b6fSPhillip Lougher  *fill    - function to fill inbuf when empty
15daeb6b6fSPhillip Lougher  *flush   - function to write out outbuf
16daeb6b6fSPhillip Lougher  *outbuf  - output buffer
17bc22c17eSAlain Knaff  *posp    - if non-null, input position (number of bytes read) will be
18bc22c17eSAlain Knaff  *	  returned here
19bc22c17eSAlain Knaff  *
20daeb6b6fSPhillip Lougher  *If len != 0, inbuf should contain all the necessary input data, and fill
21daeb6b6fSPhillip Lougher  *should be NULL
22daeb6b6fSPhillip Lougher  *If len = 0, inbuf can be NULL, in which case the decompressor will allocate
23daeb6b6fSPhillip Lougher  *the input buffer.  If inbuf != NULL it must be at least XXX_IOBUF_SIZE bytes.
24daeb6b6fSPhillip Lougher  *fill will be called (repeatedly...) to read data, at most XXX_IOBUF_SIZE
25daeb6b6fSPhillip Lougher  *bytes should be read per call.  Replace XXX with the appropriate decompressor
26daeb6b6fSPhillip Lougher  *name, i.e. LZMA_IOBUF_SIZE.
27daeb6b6fSPhillip Lougher  *
28daeb6b6fSPhillip Lougher  *If flush = NULL, outbuf must be large enough to buffer all the expected
29daeb6b6fSPhillip Lougher  *output.  If flush != NULL, the output buffer will be allocated by the
30daeb6b6fSPhillip Lougher  *decompressor (outbuf = NULL), and the flush function will be called to
31daeb6b6fSPhillip Lougher  *flush the output buffer at the appropriate time (decompressor and stream
32daeb6b6fSPhillip Lougher  *dependent).
33bc22c17eSAlain Knaff  */
34bc22c17eSAlain Knaff 
35daeb6b6fSPhillip Lougher 
36889c92d2SH. Peter Anvin /* Utility routine to detect the decompression method */
37d97b07c5SYinghai Lu decompress_fn decompress_method(const unsigned char *inbuf, long len,
38889c92d2SH. Peter Anvin 				const char **name);
39bc22c17eSAlain Knaff 
40bc22c17eSAlain Knaff #endif
41