bzlib.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. /*
  2. * THIS FILE IS NOT IDENTICAL TO THE ORIGINAL
  3. * FROM THE BZIP2 DISTRIBUTION.
  4. *
  5. * It has been modified, mainly to break the library
  6. * into smaller pieces.
  7. *
  8. * Russ Cox
  9. * rsc@plan9.bell-labs.com
  10. * July 2000
  11. */
  12. /*-------------------------------------------------------------*/
  13. /*--- Public header file for the library. ---*/
  14. /*--- bzlib.h ---*/
  15. /*-------------------------------------------------------------*/
  16. /*--
  17. This file is a part of bzip2 and/or libbzip2, a program and
  18. library for lossless, block-sorting data compression.
  19. Copyright (C) 1996-2000 Julian R Seward. All rights reserved.
  20. Redistribution and use in source and binary forms, with or without
  21. modification, are permitted provided that the following conditions
  22. are met:
  23. 1. Redistributions of source code must retain the above copyright
  24. notice, this list of conditions and the following disclaimer.
  25. 2. The origin of this software must not be misrepresented; you must
  26. not claim that you wrote the original software. If you use this
  27. software in a product, an acknowledgment in the product
  28. documentation would be appreciated but is not required.
  29. 3. Altered source versions must be plainly marked as such, and must
  30. not be misrepresented as being the original software.
  31. 4. The name of the author may not be used to endorse or promote
  32. products derived from this software without specific prior written
  33. permission.
  34. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
  35. OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  36. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  37. ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
  38. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  39. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  40. GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  41. INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  42. WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  43. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  44. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  45. Julian Seward, Cambridge, UK.
  46. jseward@acm.org
  47. bzip2/libbzip2 version 1.0 of 21 March 2000
  48. This program is based on (at least) the work of:
  49. Mike Burrows
  50. David Wheeler
  51. Peter Fenwick
  52. Alistair Moffat
  53. Radford Neal
  54. Ian H. Witten
  55. Robert Sedgewick
  56. Jon L. Bentley
  57. For more information on these sources, see the manual.
  58. --*/
  59. #ifndef _BZLIB_H
  60. #define _BZLIB_H
  61. #ifdef __cplusplus
  62. extern "C" {
  63. #endif
  64. #define BZ_RUN 0
  65. #define BZ_FLUSH 1
  66. #define BZ_FINISH 2
  67. #define BZ_OK 0
  68. #define BZ_RUN_OK 1
  69. #define BZ_FLUSH_OK 2
  70. #define BZ_FINISH_OK 3
  71. #define BZ_STREAM_END 4
  72. #define BZ_SEQUENCE_ERROR (-1)
  73. #define BZ_PARAM_ERROR (-2)
  74. #define BZ_MEM_ERROR (-3)
  75. #define BZ_DATA_ERROR (-4)
  76. #define BZ_DATA_ERROR_MAGIC (-5)
  77. #define BZ_IO_ERROR (-6)
  78. #define BZ_UNEXPECTED_EOF (-7)
  79. #define BZ_OUTBUFF_FULL (-8)
  80. #define BZ_CONFIG_ERROR (-9)
  81. typedef
  82. struct {
  83. char *next_in;
  84. unsigned int avail_in;
  85. unsigned int total_in_lo32;
  86. unsigned int total_in_hi32;
  87. char *next_out;
  88. unsigned int avail_out;
  89. unsigned int total_out_lo32;
  90. unsigned int total_out_hi32;
  91. void *state;
  92. void *(*bzalloc)(void *,int,int);
  93. void (*bzfree)(void *,void *);
  94. void *opaque;
  95. }
  96. bz_stream;
  97. #ifndef BZ_IMPORT
  98. #define BZ_EXPORT
  99. #endif
  100. #ifdef _WIN32
  101. # include <stdio.h>
  102. # include <windows.h>
  103. # ifdef small
  104. /* windows.h define small to char */
  105. # undef small
  106. # endif
  107. # ifdef BZ_EXPORT
  108. # define BZ_API(func) WINAPI func
  109. # define BZ_EXTERN extern
  110. # else
  111. /* import windows dll dynamically */
  112. # define BZ_API(func) (WINAPI * func)
  113. # define BZ_EXTERN
  114. # endif
  115. #else
  116. # define BZ_API(func) func
  117. # define BZ_EXTERN extern
  118. #endif
  119. /*-- Core (low-level) library functions --*/
  120. BZ_EXTERN int BZ_API(BZ2_bzCompressInit) (
  121. bz_stream* strm,
  122. int blockSize100k,
  123. int verbosity,
  124. int workFactor
  125. );
  126. BZ_EXTERN int BZ_API(BZ2_bzCompress) (
  127. bz_stream* strm,
  128. int action
  129. );
  130. BZ_EXTERN int BZ_API(BZ2_bzCompressEnd) (
  131. bz_stream* strm
  132. );
  133. BZ_EXTERN int BZ_API(BZ2_bzDecompressInit) (
  134. bz_stream *strm,
  135. int verbosity,
  136. int small
  137. );
  138. BZ_EXTERN int BZ_API(BZ2_bzDecompress) (
  139. bz_stream* strm
  140. );
  141. BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) (
  142. bz_stream *strm
  143. );
  144. /*-- Utility functions --*/
  145. BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) (
  146. char* dest,
  147. unsigned int* destLen,
  148. char* source,
  149. unsigned int sourceLen,
  150. int blockSize100k,
  151. int verbosity,
  152. int workFactor
  153. );
  154. BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) (
  155. char* dest,
  156. unsigned int* destLen,
  157. char* source,
  158. unsigned int sourceLen,
  159. int small,
  160. int verbosity
  161. );
  162. /*--
  163. Code contributed by Yoshioka Tsuneo
  164. (QWF00133@niftyserve.or.jp/tsuneo-y@is.aist-nara.ac.jp),
  165. to support better zlib compatibility.
  166. This code is not _officially_ part of libbzip2 (yet);
  167. I haven't tested it, documented it, or considered the
  168. threading-safeness of it.
  169. If this code breaks, please contact both Yoshioka and me.
  170. --*/
  171. BZ_EXTERN const char * BZ_API(BZ2_bzlibVersion) (
  172. void
  173. );
  174. #ifdef __cplusplus
  175. }
  176. #endif
  177. #endif
  178. /*-------------------------------------------------------------*/
  179. /*--- end bzlib.h ---*/
  180. /*-------------------------------------------------------------*/