generic.h 1.5 KB

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