uzlib.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * uzlib - tiny deflate/inflate library (deflate, gzip, zlib)
  3. *
  4. * Copyright (c) 2003 by Joergen Ibsen / Jibz
  5. * All Rights Reserved
  6. * http://www.ibsensoftware.com/
  7. *
  8. * Copyright (c) 2014-2016 by Paul Sokolovsky
  9. */
  10. #ifndef UZLIB_INFLATE_H
  11. #define UZLIB_INFLATE_H
  12. #include <setjmp.h>
  13. #if defined(__XTENSA__)
  14. #include "c_stdint.h"
  15. #include "mem.h"
  16. #define UZLIB_THROW(v) longjmp(unwindAddr, (v))
  17. #define UZLIB_SETJMP setjmp
  18. #define uz_malloc os_malloc
  19. #define uz_free os_free
  20. #else /* POSIX */
  21. #include <stdint.h>
  22. #include <stdlib.h>
  23. extern int dbg_break(void);
  24. #define UZLIB_THROW(v) {dbg_break();_longjmp(unwindAddr, (v));}
  25. #define UZLIB_SETJMP _setjmp
  26. #define uz_malloc malloc
  27. #define uz_free free
  28. #endif
  29. extern jmp_buf unwindAddr;
  30. /* ok status, more data produced */
  31. #define UZLIB_OK 0
  32. /* end of compressed stream reached */
  33. #define UZLIB_DONE 1
  34. #define UZLIB_DATA_ERROR (-3)
  35. #define UZLIB_CHKSUM_ERROR (-4)
  36. #define UZLIB_DICT_ERROR (-5)
  37. #define UZLIB_MEMORY_ERROR (-6)
  38. /* checksum types */
  39. #define UZLIB_CHKSUM_NONE 0
  40. #define UZLIB_CHKSUM_ADLER 1
  41. #define UZLIB_CHKSUM_CRC 2
  42. /* Gzip header codes */
  43. #define UZLIB_FTEXT 1
  44. #define UZLIB_FHCRC 2
  45. #define UZLIB_FEXTRA 4
  46. #define UZLIB_FNAME 8
  47. #define UZLIB_FCOMMENT 16
  48. /* Compression API */
  49. typedef struct uzlib_data UZLIB_DATA;
  50. int uzlib_inflate (uint8_t (*)(void), void (*)(uint8_t),
  51. uint8_t (*)(uint32_t), uint32_t len, uint32_t *crc, void **state);
  52. int uzlib_compress (uint8_t **dest, uint32_t *destLen,
  53. const uint8_t *src, uint32_t srcLen);
  54. /* Checksum API */
  55. /* crc is previous value for incremental computation, 0xffffffff initially */
  56. uint32_t uzlib_crc32(const void *data, uint32_t length, uint32_t crc);
  57. #endif /* UZLIB_INFLATE_H */