bzlib.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. /*
  2. * This file is a modified version of bzlib.h from the bzip2-1.0.2
  3. * distribution which can be found at http://sources.redhat.com/bzip2/
  4. */
  5. /*-------------------------------------------------------------*/
  6. /*--- Public header file for the library. ---*/
  7. /*--- bzlib.h ---*/
  8. /*-------------------------------------------------------------*/
  9. /*--
  10. This file is a part of bzip2 and/or libbzip2, a program and
  11. library for lossless, block-sorting data compression.
  12. Copyright (C) 1996-2002 Julian R Seward. All rights reserved.
  13. Redistribution and use in source and binary forms, with or without
  14. modification, are permitted provided that the following conditions
  15. are met:
  16. 1. Redistributions of source code must retain the above copyright
  17. notice, this list of conditions and the following disclaimer.
  18. 2. The origin of this software must not be misrepresented; you must
  19. not claim that you wrote the original software. If you use this
  20. software in a product, an acknowledgment in the product
  21. documentation would be appreciated but is not required.
  22. 3. Altered source versions must be plainly marked as such, and must
  23. not be misrepresented as being the original software.
  24. 4. The name of the author may not be used to endorse or promote
  25. products derived from this software without specific prior written
  26. permission.
  27. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
  28. OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  29. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  30. ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
  31. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  32. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  33. GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  34. INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  35. WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  36. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  37. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  38. Julian Seward, Cambridge, UK.
  39. jseward@acm.org
  40. bzip2/libbzip2 version 1.0 of 21 March 2000
  41. This program is based on (at least) the work of:
  42. Mike Burrows
  43. David Wheeler
  44. Peter Fenwick
  45. Alistair Moffat
  46. Radford Neal
  47. Ian H. Witten
  48. Robert Sedgewick
  49. Jon L. Bentley
  50. For more information on these sources, see the manual.
  51. --*/
  52. #ifndef _BZLIB_H
  53. #define _BZLIB_H
  54. /* Configure for U-Boot environment */
  55. #define BZ_NO_STDIO
  56. #define BZ_NO_COMPRESS
  57. /* End of configuration for U-Boot environment */
  58. #ifdef __cplusplus
  59. extern "C" {
  60. #endif
  61. #define BZ_RUN 0
  62. #define BZ_FLUSH 1
  63. #define BZ_FINISH 2
  64. #define BZ_OK 0
  65. #define BZ_RUN_OK 1
  66. #define BZ_FLUSH_OK 2
  67. #define BZ_FINISH_OK 3
  68. #define BZ_STREAM_END 4
  69. #define BZ_SEQUENCE_ERROR (-1)
  70. #define BZ_PARAM_ERROR (-2)
  71. #define BZ_MEM_ERROR (-3)
  72. #define BZ_DATA_ERROR (-4)
  73. #define BZ_DATA_ERROR_MAGIC (-5)
  74. #define BZ_IO_ERROR (-6)
  75. #define BZ_UNEXPECTED_EOF (-7)
  76. #define BZ_OUTBUFF_FULL (-8)
  77. #define BZ_CONFIG_ERROR (-9)
  78. typedef
  79. struct {
  80. char *next_in;
  81. unsigned int avail_in;
  82. unsigned int total_in_lo32;
  83. unsigned int total_in_hi32;
  84. char *next_out;
  85. unsigned int avail_out;
  86. unsigned int total_out_lo32;
  87. unsigned int total_out_hi32;
  88. void *state;
  89. void *(*bzalloc)(void *,int,int);
  90. void (*bzfree)(void *,void *);
  91. void *opaque;
  92. }
  93. bz_stream;
  94. #ifndef BZ_IMPORT
  95. #define BZ_EXPORT
  96. #endif
  97. #ifdef _WIN32
  98. # include <windows.h>
  99. # ifdef small
  100. /* windows.h define small to char */
  101. # undef small
  102. # endif
  103. # ifdef BZ_EXPORT
  104. # define BZ_API(func) WINAPI func
  105. # define BZ_EXTERN extern
  106. # else
  107. /* import windows dll dynamically */
  108. # define BZ_API(func) (WINAPI * func)
  109. # define BZ_EXTERN
  110. # endif
  111. #else
  112. # define BZ_API(func) func
  113. # define BZ_EXTERN extern
  114. #endif
  115. /*-- Core (low-level) library functions --*/
  116. BZ_EXTERN int BZ_API(BZ2_bzCompressInit) (
  117. bz_stream* strm,
  118. int blockSize100k,
  119. int verbosity,
  120. int workFactor
  121. );
  122. BZ_EXTERN int BZ_API(BZ2_bzCompress) (
  123. bz_stream* strm,
  124. int action
  125. );
  126. BZ_EXTERN int BZ_API(BZ2_bzCompressEnd) (
  127. bz_stream* strm
  128. );
  129. BZ_EXTERN int BZ_API(BZ2_bzDecompressInit) (
  130. bz_stream *strm,
  131. int verbosity,
  132. int small
  133. );
  134. BZ_EXTERN int BZ_API(BZ2_bzDecompress) (
  135. bz_stream* strm
  136. );
  137. BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) (
  138. bz_stream *strm
  139. );
  140. /*-- High(er) level library functions --*/
  141. #ifndef BZ_NO_STDIO
  142. #define BZ_MAX_UNUSED 5000
  143. /* Need a definitition for FILE */
  144. #include <stdio.h>
  145. typedef void BZFILE;
  146. BZ_EXTERN BZFILE* BZ_API(BZ2_bzReadOpen) (
  147. int* bzerror,
  148. FILE* f,
  149. int verbosity,
  150. int small,
  151. void* unused,
  152. int nUnused
  153. );
  154. BZ_EXTERN void BZ_API(BZ2_bzReadClose) (
  155. int* bzerror,
  156. BZFILE* b
  157. );
  158. BZ_EXTERN void BZ_API(BZ2_bzReadGetUnused) (
  159. int* bzerror,
  160. BZFILE* b,
  161. void** unused,
  162. int* nUnused
  163. );
  164. BZ_EXTERN int BZ_API(BZ2_bzRead) (
  165. int* bzerror,
  166. BZFILE* b,
  167. void* buf,
  168. int len
  169. );
  170. BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) (
  171. int* bzerror,
  172. FILE* f,
  173. int blockSize100k,
  174. int verbosity,
  175. int workFactor
  176. );
  177. BZ_EXTERN void BZ_API(BZ2_bzWrite) (
  178. int* bzerror,
  179. BZFILE* b,
  180. void* buf,
  181. int len
  182. );
  183. BZ_EXTERN void BZ_API(BZ2_bzWriteClose) (
  184. int* bzerror,
  185. BZFILE* b,
  186. int abandon,
  187. unsigned int* nbytes_in,
  188. unsigned int* nbytes_out
  189. );
  190. BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) (
  191. int* bzerror,
  192. BZFILE* b,
  193. int abandon,
  194. unsigned int* nbytes_in_lo32,
  195. unsigned int* nbytes_in_hi32,
  196. unsigned int* nbytes_out_lo32,
  197. unsigned int* nbytes_out_hi32
  198. );
  199. #endif
  200. /*-- Utility functions --*/
  201. BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) (
  202. char* dest,
  203. unsigned int* destLen,
  204. char* source,
  205. unsigned int sourceLen,
  206. int blockSize100k,
  207. int verbosity,
  208. int workFactor
  209. );
  210. BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) (
  211. char* dest,
  212. unsigned int* destLen,
  213. char* source,
  214. unsigned int sourceLen,
  215. int small,
  216. int verbosity
  217. );
  218. /*--
  219. Code contributed by Yoshioka Tsuneo
  220. (QWF00133@niftyserve.or.jp/tsuneo-y@is.aist-nara.ac.jp),
  221. to support better zlib compatibility.
  222. This code is not _officially_ part of libbzip2 (yet);
  223. I haven't tested it, documented it, or considered the
  224. threading-safeness of it.
  225. If this code breaks, please contact both Yoshioka and me.
  226. --*/
  227. BZ_EXTERN const char * BZ_API(BZ2_bzlibVersion) (
  228. void
  229. );
  230. #ifndef BZ_NO_STDIO
  231. BZ_EXTERN BZFILE * BZ_API(BZ2_bzopen) (
  232. const char *path,
  233. const char *mode
  234. );
  235. BZ_EXTERN BZFILE * BZ_API(BZ2_bzdopen) (
  236. int fd,
  237. const char *mode
  238. );
  239. BZ_EXTERN int BZ_API(BZ2_bzread) (
  240. BZFILE* b,
  241. void* buf,
  242. int len
  243. );
  244. BZ_EXTERN int BZ_API(BZ2_bzwrite) (
  245. BZFILE* b,
  246. void* buf,
  247. int len
  248. );
  249. BZ_EXTERN int BZ_API(BZ2_bzflush) (
  250. BZFILE* b
  251. );
  252. BZ_EXTERN void BZ_API(BZ2_bzclose) (
  253. BZFILE* b
  254. );
  255. BZ_EXTERN const char * BZ_API(BZ2_bzerror) (
  256. BZFILE *b,
  257. int *errnum
  258. );
  259. #endif
  260. #ifdef __cplusplus
  261. }
  262. #endif
  263. #endif
  264. /*-------------------------------------------------------------*/
  265. /*--- end bzlib.h ---*/
  266. /*-------------------------------------------------------------*/