uzlib.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 /* Host */
  21. #include <stdint.h>
  22. #include <stdlib.h>
  23. extern int dbg_break(void);
  24. #if defined(_MSC_VER) || defined(__MINGW32__) //msvc requires old name for longjmp
  25. #define UZLIB_THROW(v) {dbg_break();longjmp(unwindAddr, (v));}
  26. #define UZLIB_SETJMP(n) setjmp(n)
  27. #else
  28. #define UZLIB_THROW(v) {dbg_break();_longjmp(unwindAddr, (v));}
  29. #define UZLIB_SETJMP(n) _setjmp(n)
  30. #endif
  31. #define uz_malloc malloc
  32. #define uz_free free
  33. #endif /* defined(__XTENSA__) */
  34. extern jmp_buf unwindAddr;
  35. /* ok status, more data produced */
  36. #define UZLIB_OK 0
  37. /* end of compressed stream reached */
  38. #define UZLIB_DONE 1
  39. #define UZLIB_DATA_ERROR (-3)
  40. #define UZLIB_CHKSUM_ERROR (-4)
  41. #define UZLIB_DICT_ERROR (-5)
  42. #define UZLIB_MEMORY_ERROR (-6)
  43. /* checksum types */
  44. #define UZLIB_CHKSUM_NONE 0
  45. #define UZLIB_CHKSUM_ADLER 1
  46. #define UZLIB_CHKSUM_CRC 2
  47. /* Gzip header codes */
  48. #define UZLIB_FTEXT 1
  49. #define UZLIB_FHCRC 2
  50. #define UZLIB_FEXTRA 4
  51. #define UZLIB_FNAME 8
  52. #define UZLIB_FCOMMENT 16
  53. /* Compression API */
  54. typedef struct uzlib_data UZLIB_DATA;
  55. int uzlib_inflate (uint8_t (*)(void), void (*)(uint8_t),
  56. uint8_t (*)(uint32_t), uint32_t len, uint32_t *crc, void **state);
  57. int uzlib_compress (uint8_t **dest, uint32_t *destLen,
  58. const uint8_t *src, uint32_t srcLen);
  59. /* Checksum API */
  60. /* crc is previous value for incremental computation, 0xffffffff initially */
  61. uint32_t uzlib_crc32(const void *data, uint32_t length, uint32_t crc);
  62. #endif /* UZLIB_INFLATE_H */