2 /*-------------------------------------------------------------*/
3 /*--- Public header file for the library. ---*/
5 /*-------------------------------------------------------------*/
8 This file is a part of bzip2 and/or libbzip2, a program and
9 library for lossless, block-sorting data compression.
11 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
17 1. Redistributions of source code must retain the above copyright
18 notice, this list of conditions and the following disclaimer.
20 2. The origin of this software must not be misrepresented; you must
21 not claim that you wrote the original software. If you use this
22 software in a product, an acknowledgment in the product
23 documentation would be appreciated but is not required.
25 3. Altered source versions must be plainly marked as such, and must
26 not be misrepresented as being the original software.
28 4. The name of the author may not be used to endorse or promote
29 products derived from this software without specific prior written
32 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
33 OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
34 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
35 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
36 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
38 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
39 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
40 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
41 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
42 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
44 Julian Seward, Cambridge, UK.
46 bzip2/libbzip2 version 1.0 of 21 March 2000
48 This program is based on (at least) the work of:
58 For more information on these sources, see the manual.
76 #define BZ_FINISH_OK 3
77 #define BZ_STREAM_END 4
78 #define BZ_SEQUENCE_ERROR (-1)
79 #define BZ_PARAM_ERROR (-2)
80 #define BZ_MEM_ERROR (-3)
81 #define BZ_DATA_ERROR (-4)
82 #define BZ_DATA_ERROR_MAGIC (-5)
83 #define BZ_IO_ERROR (-6)
84 #define BZ_UNEXPECTED_EOF (-7)
85 #define BZ_OUTBUFF_FULL (-8)
86 #define BZ_CONFIG_ERROR (-9)
91 unsigned int avail_in
;
92 unsigned int total_in_lo32
;
93 unsigned int total_in_hi32
;
96 unsigned int avail_out
;
97 unsigned int total_out_lo32
;
98 unsigned int total_out_hi32
;
102 void *(*bzalloc
)(void *,int,int);
103 void (*bzfree
)(void *,void *);
114 /* Need a definitition for FILE */
119 # include <windows.h>
121 /* windows.h define small to char */
125 # define BZ_API(func) WINAPI func
126 # define BZ_EXTERN extern
128 /* import windows dll dynamically */
129 # define BZ_API(func) (WINAPI * func)
133 # define BZ_API(func) func
134 # define BZ_EXTERN extern
138 /*-- Core (low-level) library functions --*/
140 BZ_EXTERN
int BZ_API(BZ2_bzCompressInit
) (
147 BZ_EXTERN
int BZ_API(BZ2_bzCompress
) (
152 BZ_EXTERN
int BZ_API(BZ2_bzCompressEnd
) (
156 BZ_EXTERN
int BZ_API(BZ2_bzDecompressInit
) (
162 BZ_EXTERN
int BZ_API(BZ2_bzDecompress
) (
166 BZ_EXTERN
int BZ_API(BZ2_bzDecompressEnd
) (
172 /*-- High(er) level library functions --*/
175 #define BZ_MAX_UNUSED 5000
179 BZ_EXTERN BZFILE
* BZ_API(BZ2_bzReadOpen
) (
188 BZ_EXTERN
void BZ_API(BZ2_bzReadClose
) (
193 BZ_EXTERN
void BZ_API(BZ2_bzReadGetUnused
) (
200 BZ_EXTERN
int BZ_API(BZ2_bzRead
) (
207 BZ_EXTERN BZFILE
* BZ_API(BZ2_bzWriteOpen
) (
215 BZ_EXTERN
void BZ_API(BZ2_bzWrite
) (
222 BZ_EXTERN
void BZ_API(BZ2_bzWriteClose
) (
226 unsigned int* nbytes_in
,
227 unsigned int* nbytes_out
230 BZ_EXTERN
void BZ_API(BZ2_bzWriteClose64
) (
234 unsigned int* nbytes_in_lo32
,
235 unsigned int* nbytes_in_hi32
,
236 unsigned int* nbytes_out_lo32
,
237 unsigned int* nbytes_out_hi32
242 /*-- Utility functions --*/
244 BZ_EXTERN
int BZ_API(BZ2_bzBuffToBuffCompress
) (
246 unsigned int* destLen
,
248 unsigned int sourceLen
,
254 BZ_EXTERN
int BZ_API(BZ2_bzBuffToBuffDecompress
) (
256 unsigned int* destLen
,
258 unsigned int sourceLen
,
265 Code contributed by Yoshioka Tsuneo
266 (QWF00133@niftyserve.or.jp/tsuneo-y@is.aist-nara.ac.jp),
267 to support better zlib compatibility.
268 This code is not _officially_ part of libbzip2 (yet);
269 I haven't tested it, documented it, or considered the
270 threading-safeness of it.
271 If this code breaks, please contact both Yoshioka and me.
274 BZ_EXTERN
const char * BZ_API(BZ2_bzlibVersion
) (
279 BZ_EXTERN BZFILE
* BZ_API(BZ2_bzopen
) (
284 BZ_EXTERN BZFILE
* BZ_API(BZ2_bzdopen
) (
289 BZ_EXTERN
int BZ_API(BZ2_bzread
) (
295 BZ_EXTERN
int BZ_API(BZ2_bzwrite
) (
301 BZ_EXTERN
int BZ_API(BZ2_bzflush
) (
305 BZ_EXTERN
void BZ_API(BZ2_bzclose
) (
309 BZ_EXTERN
const char * BZ_API(BZ2_bzerror
) (
321 /*-------------------------------------------------------------*/
322 /*--- end bzlib.h ---*/
323 /*-------------------------------------------------------------*/