Alain Knaff | bc22c17 | 2009-01-04 22:46:16 +0100 | [diff] [blame] | 1 | #ifndef DECOMPRESS_GENERIC_H |
| 2 | #define DECOMPRESS_GENERIC_H |
| 3 | |
Alain Knaff | bc22c17 | 2009-01-04 22:46:16 +0100 | [diff] [blame] | 4 | typedef int (*decompress_fn) (unsigned char *inbuf, int len, |
| 5 | int(*fill)(void*, unsigned int), |
Phillip Lougher | daeb6b6 | 2009-08-06 15:09:30 -0700 | [diff] [blame] | 6 | int(*flush)(void*, unsigned int), |
| 7 | unsigned char *outbuf, |
Alain Knaff | bc22c17 | 2009-01-04 22:46:16 +0100 | [diff] [blame] | 8 | int *posp, |
| 9 | void(*error)(char *x)); |
| 10 | |
| 11 | /* inbuf - input buffer |
| 12 | *len - len of pre-read data in inbuf |
Phillip Lougher | daeb6b6 | 2009-08-06 15:09:30 -0700 | [diff] [blame] | 13 | *fill - function to fill inbuf when empty |
| 14 | *flush - function to write out outbuf |
| 15 | *outbuf - output buffer |
Alain Knaff | bc22c17 | 2009-01-04 22:46:16 +0100 | [diff] [blame] | 16 | *posp - if non-null, input position (number of bytes read) will be |
| 17 | * returned here |
| 18 | * |
Phillip Lougher | daeb6b6 | 2009-08-06 15:09:30 -0700 | [diff] [blame] | 19 | *If len != 0, inbuf should contain all the necessary input data, and fill |
| 20 | *should be NULL |
| 21 | *If len = 0, inbuf can be NULL, in which case the decompressor will allocate |
| 22 | *the input buffer. If inbuf != NULL it must be at least XXX_IOBUF_SIZE bytes. |
| 23 | *fill will be called (repeatedly...) to read data, at most XXX_IOBUF_SIZE |
| 24 | *bytes should be read per call. Replace XXX with the appropriate decompressor |
| 25 | *name, i.e. LZMA_IOBUF_SIZE. |
| 26 | * |
| 27 | *If flush = NULL, outbuf must be large enough to buffer all the expected |
| 28 | *output. If flush != NULL, the output buffer will be allocated by the |
| 29 | *decompressor (outbuf = NULL), and the flush function will be called to |
| 30 | *flush the output buffer at the appropriate time (decompressor and stream |
| 31 | *dependent). |
Alain Knaff | bc22c17 | 2009-01-04 22:46:16 +0100 | [diff] [blame] | 32 | */ |
| 33 | |
Phillip Lougher | daeb6b6 | 2009-08-06 15:09:30 -0700 | [diff] [blame] | 34 | |
H. Peter Anvin | 889c92d | 2009-01-08 15:14:17 -0800 | [diff] [blame] | 35 | /* Utility routine to detect the decompression method */ |
| 36 | decompress_fn decompress_method(const unsigned char *inbuf, int len, |
| 37 | const char **name); |
Alain Knaff | bc22c17 | 2009-01-04 22:46:16 +0100 | [diff] [blame] | 38 | |
| 39 | #endif |