bzlib.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  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. # ifdef BZ_EXPORT
  67. # define BZ_API(func) WINAPI func
  68. # define BZ_EXTERN extern
  69. # else
  70. /* import windows dll dynamically */
  71. # define BZ_API(func) (WINAPI * func)
  72. # define BZ_EXTERN
  73. # endif
  74. #else
  75. # define BZ_API(func) func
  76. # define BZ_EXTERN extern
  77. #endif
  78. /*-- Core (low-level) library functions --*/
  79. BZ_EXTERN int BZ_API(BZ2_bzCompressInit) (
  80. bz_stream* strm,
  81. int blockSize100k,
  82. int verbosity,
  83. int workFactor
  84. );
  85. BZ_EXTERN int BZ_API(BZ2_bzCompress) (
  86. bz_stream* strm,
  87. int action
  88. );
  89. BZ_EXTERN int BZ_API(BZ2_bzCompressEnd) (
  90. bz_stream* strm
  91. );
  92. BZ_EXTERN int BZ_API(BZ2_bzDecompressInit) (
  93. bz_stream *strm,
  94. int verbosity,
  95. int small
  96. );
  97. BZ_EXTERN int BZ_API(BZ2_bzDecompress) (
  98. bz_stream* strm
  99. );
  100. BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) (
  101. bz_stream *strm
  102. );
  103. /*-- High(er) level library functions --*/
  104. #ifndef BZ_NO_STDIO
  105. #define BZ_MAX_UNUSED 5000
  106. typedef void BZFILE;
  107. BZ_EXTERN BZFILE* BZ_API(BZ2_bzReadOpen) (
  108. int* bzerror,
  109. FILE* f,
  110. int verbosity,
  111. int small,
  112. void* unused,
  113. int nUnused
  114. );
  115. BZ_EXTERN void BZ_API(BZ2_bzReadClose) (
  116. int* bzerror,
  117. BZFILE* b
  118. );
  119. BZ_EXTERN void BZ_API(BZ2_bzReadGetUnused) (
  120. int* bzerror,
  121. BZFILE* b,
  122. void** unused,
  123. int* nUnused
  124. );
  125. BZ_EXTERN int BZ_API(BZ2_bzRead) (
  126. int* bzerror,
  127. BZFILE* b,
  128. void* buf,
  129. int len
  130. );
  131. BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) (
  132. int* bzerror,
  133. FILE* f,
  134. int blockSize100k,
  135. int verbosity,
  136. int workFactor
  137. );
  138. BZ_EXTERN void BZ_API(BZ2_bzWrite) (
  139. int* bzerror,
  140. BZFILE* b,
  141. void* buf,
  142. int len
  143. );
  144. BZ_EXTERN void BZ_API(BZ2_bzWriteClose) (
  145. int* bzerror,
  146. BZFILE* b,
  147. int abandon,
  148. unsigned int* nbytes_in,
  149. unsigned int* nbytes_out
  150. );
  151. BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) (
  152. int* bzerror,
  153. BZFILE* b,
  154. int abandon,
  155. unsigned int* nbytes_in_lo32,
  156. unsigned int* nbytes_in_hi32,
  157. unsigned int* nbytes_out_lo32,
  158. unsigned int* nbytes_out_hi32
  159. );
  160. #endif
  161. /*-- Utility functions --*/
  162. BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) (
  163. char* dest,
  164. unsigned int* destLen,
  165. char* source,
  166. unsigned int sourceLen,
  167. int blockSize100k,
  168. int verbosity,
  169. int workFactor
  170. );
  171. BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) (
  172. char* dest,
  173. unsigned int* destLen,
  174. char* source,
  175. unsigned int sourceLen,
  176. int small,
  177. int verbosity
  178. );
  179. /*--
  180. Code contributed by Yoshioka Tsuneo (tsuneo@rr.iij4u.or.jp)
  181. to support better zlib compatibility.
  182. This code is not _officially_ part of libbzip2 (yet);
  183. I haven't tested it, documented it, or considered the
  184. threading-safeness of it.
  185. If this code breaks, please contact both Yoshioka and me.
  186. --*/
  187. BZ_EXTERN const char * BZ_API(BZ2_bzlibVersion) (
  188. void
  189. );
  190. #ifndef BZ_NO_STDIO
  191. BZ_EXTERN BZFILE * BZ_API(BZ2_bzopen) (
  192. const char *path,
  193. const char *mode
  194. );
  195. BZ_EXTERN BZFILE * BZ_API(BZ2_bzdopen) (
  196. int fd,
  197. const char *mode
  198. );
  199. BZ_EXTERN int BZ_API(BZ2_bzread) (
  200. BZFILE* b,
  201. void* buf,
  202. int len
  203. );
  204. BZ_EXTERN int BZ_API(BZ2_bzwrite) (
  205. BZFILE* b,
  206. void* buf,
  207. int len
  208. );
  209. BZ_EXTERN int BZ_API(BZ2_bzflush) (
  210. BZFILE* b
  211. );
  212. BZ_EXTERN void BZ_API(BZ2_bzclose) (
  213. BZFILE* b
  214. );
  215. BZ_EXTERN const char * BZ_API(BZ2_bzerror) (
  216. BZFILE *b,
  217. int *errnum
  218. );
  219. #endif
  220. #ifdef __cplusplus
  221. }
  222. #endif
  223. #endif
  224. /*-------------------------------------------------------------*/
  225. /*--- end bzlib.h ---*/
  226. /*-------------------------------------------------------------*/