bzlib.h 6.0 KB

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