generic.h 1.4 KB

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