bzlib.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. /*-------------------------------------------------------------*/
  2. /*--- Public header file for the library. ---*/
  3. /*--- bzlib.h ---*/
  4. /*-------------------------------------------------------------*/
  5. /* ------------------------------------------------------------------
  6. This file is part of bzip2/libbzip2, a program and library for
  7. lossless, block-sorting data compression.
  8. bzip2/libbzip2 version 1.0.8 of 13 July 2019
  9. Copyright (C) 1996-2019 Julian Seward <jseward@acm.org>
  10. Please read the WARNING, DISCLAIMER and PATENTS sections in the
  11. README file.
  12. This program is released under the terms of the license contained
  13. in the file LICENSE.
  14. ------------------------------------------------------------------ */
  15. #ifndef _BZLIB_H
  16. #define _BZLIB_H
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. #define BZ_RUN 0
  21. #define BZ_FLUSH 1
  22. #define BZ_FINISH 2
  23. #define BZ_OK 0
  24. #define BZ_RUN_OK 1
  25. #define BZ_FLUSH_OK 2
  26. #define BZ_FINISH_OK 3
  27. #define BZ_STREAM_END 4
  28. #define BZ_SEQUENCE_ERROR (-1)
  29. #define BZ_PARAM_ERROR (-2)
  30. #define BZ_MEM_ERROR (-3)
  31. #define BZ_DATA_ERROR (-4)
  32. #define BZ_DATA_ERROR_MAGIC (-5)
  33. #define BZ_IO_ERROR (-6)
  34. #define BZ_UNEXPECTED_EOF (-7)
  35. #define BZ_OUTBUFF_FULL (-8)
  36. #define BZ_CONFIG_ERROR (-9)
  37. typedef
  38. struct {
  39. char *next_in;
  40. unsigned int avail_in;
  41. unsigned int total_in_lo32;
  42. unsigned int total_in_hi32;
  43. char *next_out;
  44. unsigned int avail_out;
  45. unsigned int total_out_lo32;
  46. unsigned int total_out_hi32;
  47. void *state;
  48. void *(*bzalloc)(void *,int,int);
  49. void (*bzfree)(void *,void *);
  50. void *opaque;
  51. }
  52. bz_stream;
  53. #ifndef BZ_IMPORT
  54. #define BZ_EXPORT
  55. #endif
  56. #ifndef BZ_NO_STDIO
  57. /* Need a definitition for FILE */
  58. #include <stdio.h>
  59. #endif
  60. #ifdef _WIN32
  61. # include <windows.h>
  62. # ifdef small
  63. /* windows.h define small to char */
  64. # undef small
  65. # endif
  66. #endif
  67. #define BZ_API(func) func
  68. #define BZ_EXTERN extern
  69. /*-- Core (low-level) library functions --*/
  70. BZ_EXTERN int BZ_API(BZ2_bzCompressInit) (
  71. bz_stream* strm,
  72. int blockSize100k,
  73. int verbosity,
  74. int workFactor
  75. );
  76. BZ_EXTERN int BZ_API(BZ2_bzCompress) (
  77. bz_stream* strm,
  78. int action
  79. );
  80. BZ_EXTERN int BZ_API(BZ2_bzCompressEnd) (
  81. bz_stream* strm
  82. );
  83. BZ_EXTERN int BZ_API(BZ2_bzDecompressInit) (
  84. bz_stream *strm,
  85. int verbosity,
  86. int small
  87. );
  88. BZ_EXTERN int BZ_API(BZ2_bzDecompress) (
  89. bz_stream* strm
  90. );
  91. BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) (
  92. bz_stream *strm
  93. );
  94. /*-- High(er) level library functions --*/
  95. #ifndef BZ_NO_STDIO
  96. #define BZ_MAX_UNUSED 5000
  97. typedef void BZFILE;
  98. BZ_EXTERN BZFILE* BZ_API(BZ2_bzReadOpen) (
  99. int* bzerror,
  100. FILE* f,
  101. int verbosity,
  102. int small,
  103. void* unused,
  104. int nUnused
  105. );
  106. BZ_EXTERN void BZ_API(BZ2_bzReadClose) (
  107. int* bzerror,
  108. BZFILE* b
  109. );
  110. BZ_EXTERN void BZ_API(BZ2_bzReadGetUnused) (
  111. int* bzerror,
  112. BZFILE* b,
  113. void** unused,
  114. int* nUnused
  115. );
  116. BZ_EXTERN int BZ_API(BZ2_bzRead) (
  117. int* bzerror,
  118. BZFILE* b,
  119. void* buf,
  120. int len
  121. );
  122. BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) (
  123. int* bzerror,
  124. FILE* f,
  125. int blockSize100k,
  126. int verbosity,
  127. int workFactor
  128. );
  129. BZ_EXTERN void BZ_API(BZ2_bzWrite) (
  130. int* bzerror,
  131. BZFILE* b,
  132. void* buf,
  133. int len
  134. );
  135. BZ_EXTERN void BZ_API(BZ2_bzWriteClose) (
  136. int* bzerror,
  137. BZFILE* b,
  138. int abandon,
  139. unsigned int* nbytes_in,
  140. unsigned int* nbytes_out
  141. );
  142. BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) (
  143. int* bzerror,
  144. BZFILE* b,
  145. int abandon,
  146. unsigned int* nbytes_in_lo32,
  147. unsigned int* nbytes_in_hi32,
  148. unsigned int* nbytes_out_lo32,
  149. unsigned int* nbytes_out_hi32
  150. );
  151. #endif
  152. /*-- Utility functions --*/
  153. BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) (
  154. char* dest,
  155. unsigned int* destLen,
  156. char* source,
  157. unsigned int sourceLen,
  158. int blockSize100k,
  159. int verbosity,
  160. int workFactor
  161. );
  162. BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) (
  163. char* dest,
  164. unsigned int* destLen,
  165. char* source,
  166. unsigned int sourceLen,
  167. int small,
  168. int verbosity
  169. );
  170. /*--
  171. Code contributed by Yoshioka Tsuneo (tsuneo@rr.iij4u.or.jp)
  172. to support better zlib compatibility.
  173. This code is not _officially_ part of libbzip2 (yet);
  174. I haven't tested it, documented it, or considered the
  175. threading-safeness of it.
  176. If this code breaks, please contact both Yoshioka and me.
  177. --*/
  178. BZ_EXTERN const char * BZ_API(BZ2_bzlibVersion) (
  179. void
  180. );
  181. #ifndef BZ_NO_STDIO
  182. BZ_EXTERN BZFILE * BZ_API(BZ2_bzopen) (
  183. const char *path,
  184. const char *mode
  185. );
  186. BZ_EXTERN BZFILE * BZ_API(BZ2_bzdopen) (
  187. int fd,
  188. const char *mode
  189. );
  190. BZ_EXTERN int BZ_API(BZ2_bzread) (
  191. BZFILE* b,
  192. void* buf,
  193. int len
  194. );
  195. BZ_EXTERN int BZ_API(BZ2_bzwrite) (
  196. BZFILE* b,
  197. void* buf,
  198. int len
  199. );
  200. BZ_EXTERN int BZ_API(BZ2_bzflush) (
  201. BZFILE* b
  202. );
  203. BZ_EXTERN void BZ_API(BZ2_bzclose) (
  204. BZFILE* b
  205. );
  206. BZ_EXTERN const char * BZ_API(BZ2_bzerror) (
  207. BZFILE *b,
  208. int *errnum
  209. );
  210. #endif
  211. #ifdef __cplusplus
  212. }
  213. #endif
  214. #endif
  215. /*-------------------------------------------------------------*/
  216. /*--- end bzlib.h ---*/
  217. /*-------------------------------------------------------------*/