bzlib.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  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. #ifndef CONFIG_SANDBOX
  57. #define BZ_NO_COMPRESS
  58. #endif
  59. /* End of configuration for U-Boot environment */
  60. #ifdef __cplusplus
  61. extern "C" {
  62. #endif
  63. #define BZ_RUN 0
  64. #define BZ_FLUSH 1
  65. #define BZ_FINISH 2
  66. #define BZ_OK 0
  67. #define BZ_RUN_OK 1
  68. #define BZ_FLUSH_OK 2
  69. #define BZ_FINISH_OK 3
  70. #define BZ_STREAM_END 4
  71. #define BZ_SEQUENCE_ERROR (-1)
  72. #define BZ_PARAM_ERROR (-2)
  73. #define BZ_MEM_ERROR (-3)
  74. #define BZ_DATA_ERROR (-4)
  75. #define BZ_DATA_ERROR_MAGIC (-5)
  76. #define BZ_IO_ERROR (-6)
  77. #define BZ_UNEXPECTED_EOF (-7)
  78. #define BZ_OUTBUFF_FULL (-8)
  79. #define BZ_CONFIG_ERROR (-9)
  80. typedef
  81. struct {
  82. char *next_in;
  83. unsigned int avail_in;
  84. unsigned int total_in_lo32;
  85. unsigned int total_in_hi32;
  86. char *next_out;
  87. unsigned int avail_out;
  88. unsigned int total_out_lo32;
  89. unsigned int total_out_hi32;
  90. void *state;
  91. void *(*bzalloc)(void *,int,int);
  92. void (*bzfree)(void *,void *);
  93. void *opaque;
  94. }
  95. bz_stream;
  96. #ifndef BZ_IMPORT
  97. #define BZ_EXPORT
  98. #endif
  99. #ifdef _WIN32
  100. # include <windows.h>
  101. # ifdef small
  102. /* windows.h define small to char */
  103. # undef small
  104. # endif
  105. # ifdef BZ_EXPORT
  106. # define BZ_API(func) WINAPI func
  107. # define BZ_EXTERN extern
  108. # else
  109. /* import windows dll dynamically */
  110. # define BZ_API(func) (WINAPI * func)
  111. # define BZ_EXTERN
  112. # endif
  113. #else
  114. # define BZ_API(func) func
  115. # define BZ_EXTERN extern
  116. #endif
  117. /*-- Core (low-level) library functions --*/
  118. BZ_EXTERN int BZ_API(BZ2_bzCompressInit) (
  119. bz_stream* strm,
  120. int blockSize100k,
  121. int verbosity,
  122. int workFactor
  123. );
  124. BZ_EXTERN int BZ_API(BZ2_bzCompress) (
  125. bz_stream* strm,
  126. int action
  127. );
  128. BZ_EXTERN int BZ_API(BZ2_bzCompressEnd) (
  129. bz_stream* strm
  130. );
  131. BZ_EXTERN int BZ_API(BZ2_bzDecompressInit) (
  132. bz_stream *strm,
  133. int verbosity,
  134. int small
  135. );
  136. BZ_EXTERN int BZ_API(BZ2_bzDecompress) (
  137. bz_stream* strm
  138. );
  139. BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) (
  140. bz_stream *strm
  141. );
  142. /*-- High(er) level library functions --*/
  143. #ifndef BZ_NO_STDIO
  144. #define BZ_MAX_UNUSED 5000
  145. /* Need a definitition for FILE */
  146. #include <stdio.h>
  147. typedef void BZFILE;
  148. BZ_EXTERN BZFILE* BZ_API(BZ2_bzReadOpen) (
  149. int* bzerror,
  150. FILE* f,
  151. int verbosity,
  152. int small,
  153. void* unused,
  154. int nUnused
  155. );
  156. BZ_EXTERN void BZ_API(BZ2_bzReadClose) (
  157. int* bzerror,
  158. BZFILE* b
  159. );
  160. BZ_EXTERN void BZ_API(BZ2_bzReadGetUnused) (
  161. int* bzerror,
  162. BZFILE* b,
  163. void** unused,
  164. int* nUnused
  165. );
  166. BZ_EXTERN int BZ_API(BZ2_bzRead) (
  167. int* bzerror,
  168. BZFILE* b,
  169. void* buf,
  170. int len
  171. );
  172. BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) (
  173. int* bzerror,
  174. FILE* f,
  175. int blockSize100k,
  176. int verbosity,
  177. int workFactor
  178. );
  179. BZ_EXTERN void BZ_API(BZ2_bzWrite) (
  180. int* bzerror,
  181. BZFILE* b,
  182. void* buf,
  183. int len
  184. );
  185. BZ_EXTERN void BZ_API(BZ2_bzWriteClose) (
  186. int* bzerror,
  187. BZFILE* b,
  188. int abandon,
  189. unsigned int* nbytes_in,
  190. unsigned int* nbytes_out
  191. );
  192. BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) (
  193. int* bzerror,
  194. BZFILE* b,
  195. int abandon,
  196. unsigned int* nbytes_in_lo32,
  197. unsigned int* nbytes_in_hi32,
  198. unsigned int* nbytes_out_lo32,
  199. unsigned int* nbytes_out_hi32
  200. );
  201. #endif
  202. /*-- Utility functions --*/
  203. BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) (
  204. char* dest,
  205. unsigned int* destLen,
  206. char* source,
  207. unsigned int sourceLen,
  208. int blockSize100k,
  209. int verbosity,
  210. int workFactor
  211. );
  212. BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) (
  213. char* dest,
  214. unsigned int* destLen,
  215. char* source,
  216. unsigned int sourceLen,
  217. int small,
  218. int verbosity
  219. );
  220. /*--
  221. Code contributed by Yoshioka Tsuneo
  222. (QWF00133@niftyserve.or.jp/tsuneo-y@is.aist-nara.ac.jp),
  223. to support better zlib compatibility.
  224. This code is not _officially_ part of libbzip2 (yet);
  225. I haven't tested it, documented it, or considered the
  226. threading-safeness of it.
  227. If this code breaks, please contact both Yoshioka and me.
  228. --*/
  229. BZ_EXTERN const char * BZ_API(BZ2_bzlibVersion) (
  230. void
  231. );
  232. #ifndef BZ_NO_STDIO
  233. BZ_EXTERN BZFILE * BZ_API(BZ2_bzopen) (
  234. const char *path,
  235. const char *mode
  236. );
  237. BZ_EXTERN BZFILE * BZ_API(BZ2_bzdopen) (
  238. int fd,
  239. const char *mode
  240. );
  241. BZ_EXTERN int BZ_API(BZ2_bzread) (
  242. BZFILE* b,
  243. void* buf,
  244. int len
  245. );
  246. BZ_EXTERN int BZ_API(BZ2_bzwrite) (
  247. BZFILE* b,
  248. void* buf,
  249. int len
  250. );
  251. BZ_EXTERN int BZ_API(BZ2_bzflush) (
  252. BZFILE* b
  253. );
  254. BZ_EXTERN void BZ_API(BZ2_bzclose) (
  255. BZFILE* b
  256. );
  257. BZ_EXTERN const char * BZ_API(BZ2_bzerror) (
  258. BZFILE *b,
  259. int *errnum
  260. );
  261. #endif
  262. #ifdef __cplusplus
  263. }
  264. #endif
  265. #endif
  266. /*-------------------------------------------------------------*/
  267. /*--- end bzlib.h ---*/
  268. /*-------------------------------------------------------------*/