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