More -Wwrite-strings cleanup and make sure you can actually play it.
[dragonfly.git] / contrib / bzip2 / bzlib.h
blob9ac43a169da5ee0d09860f7fdae936faea019e85
2 /*-------------------------------------------------------------*/
3 /*--- Public header file for the library. ---*/
4 /*--- bzlib.h ---*/
5 /*-------------------------------------------------------------*/
7 /*--
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
15 are met:
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
30 permission.
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.
45 jseward@acm.org
46 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
58 For more information on these sources, see the manual.
59 --*/
62 #ifndef _BZLIB_H
63 #define _BZLIB_H
65 #ifdef __cplusplus
66 extern "C" {
67 #endif
69 #define BZ_RUN 0
70 #define BZ_FLUSH 1
71 #define BZ_FINISH 2
73 #define BZ_OK 0
74 #define BZ_RUN_OK 1
75 #define BZ_FLUSH_OK 2
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)
88 typedef
89 struct {
90 char *next_in;
91 unsigned int avail_in;
92 unsigned int total_in_lo32;
93 unsigned int total_in_hi32;
95 char *next_out;
96 unsigned int avail_out;
97 unsigned int total_out_lo32;
98 unsigned int total_out_hi32;
100 void *state;
102 void *(*bzalloc)(void *,int,int);
103 void (*bzfree)(void *,void *);
104 void *opaque;
106 bz_stream;
109 #ifndef BZ_IMPORT
110 #define BZ_EXPORT
111 #endif
113 /* Need a definitition for FILE */
114 #include <stdio.h>
116 #ifdef _WIN32
117 # include <windows.h>
118 # ifdef small
119 /* windows.h define small to char */
120 # undef small
121 # endif
122 # ifdef BZ_EXPORT
123 # define BZ_API(func) WINAPI func
124 # define BZ_EXTERN extern
125 # else
126 /* import windows dll dynamically */
127 # define BZ_API(func) (WINAPI * func)
128 # define BZ_EXTERN
129 # endif
130 #else
131 # define BZ_API(func) func
132 # define BZ_EXTERN extern
133 #endif
136 /*-- Core (low-level) library functions --*/
138 BZ_EXTERN int BZ_API(BZ2_bzCompressInit) (
139 bz_stream* strm,
140 int blockSize100k,
141 int verbosity,
142 int workFactor
145 BZ_EXTERN int BZ_API(BZ2_bzCompress) (
146 bz_stream* strm,
147 int action
150 BZ_EXTERN int BZ_API(BZ2_bzCompressEnd) (
151 bz_stream* strm
154 BZ_EXTERN int BZ_API(BZ2_bzDecompressInit) (
155 bz_stream *strm,
156 int verbosity,
157 int small
160 BZ_EXTERN int BZ_API(BZ2_bzDecompress) (
161 bz_stream* strm
164 BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) (
165 bz_stream *strm
170 /*-- High(er) level library functions --*/
172 #ifndef BZ_NO_STDIO
173 #define BZ_MAX_UNUSED 5000
175 typedef void BZFILE;
177 BZ_EXTERN BZFILE* BZ_API(BZ2_bzReadOpen) (
178 int* bzerror,
179 FILE* f,
180 int verbosity,
181 int small,
182 void* unused,
183 int nUnused
186 BZ_EXTERN void BZ_API(BZ2_bzReadClose) (
187 int* bzerror,
188 BZFILE* b
191 BZ_EXTERN void BZ_API(BZ2_bzReadGetUnused) (
192 int* bzerror,
193 BZFILE* b,
194 void** unused,
195 int* nUnused
198 BZ_EXTERN int BZ_API(BZ2_bzRead) (
199 int* bzerror,
200 BZFILE* b,
201 void* buf,
202 int len
205 BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) (
206 int* bzerror,
207 FILE* f,
208 int blockSize100k,
209 int verbosity,
210 int workFactor
213 BZ_EXTERN void BZ_API(BZ2_bzWrite) (
214 int* bzerror,
215 BZFILE* b,
216 void* buf,
217 int len
220 BZ_EXTERN void BZ_API(BZ2_bzWriteClose) (
221 int* bzerror,
222 BZFILE* b,
223 int abandon,
224 unsigned int* nbytes_in,
225 unsigned int* nbytes_out
228 BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) (
229 int* bzerror,
230 BZFILE* b,
231 int abandon,
232 unsigned int* nbytes_in_lo32,
233 unsigned int* nbytes_in_hi32,
234 unsigned int* nbytes_out_lo32,
235 unsigned int* nbytes_out_hi32
237 #endif
240 /*-- Utility functions --*/
242 BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) (
243 char* dest,
244 unsigned int* destLen,
245 char* source,
246 unsigned int sourceLen,
247 int blockSize100k,
248 int verbosity,
249 int workFactor
252 BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) (
253 char* dest,
254 unsigned int* destLen,
255 char* source,
256 unsigned int sourceLen,
257 int small,
258 int verbosity
262 /*--
263 Code contributed by Yoshioka Tsuneo
264 (QWF00133@niftyserve.or.jp/tsuneo-y@is.aist-nara.ac.jp),
265 to support better zlib compatibility.
266 This code is not _officially_ part of libbzip2 (yet);
267 I haven't tested it, documented it, or considered the
268 threading-safeness of it.
269 If this code breaks, please contact both Yoshioka and me.
270 --*/
272 BZ_EXTERN const char * BZ_API(BZ2_bzlibVersion) (
273 void
276 #ifndef BZ_NO_STDIO
277 BZ_EXTERN BZFILE * BZ_API(BZ2_bzopen) (
278 const char *path,
279 const char *mode
282 BZ_EXTERN BZFILE * BZ_API(BZ2_bzdopen) (
283 int fd,
284 const char *mode
287 BZ_EXTERN int BZ_API(BZ2_bzread) (
288 BZFILE* b,
289 void* buf,
290 int len
293 BZ_EXTERN int BZ_API(BZ2_bzwrite) (
294 BZFILE* b,
295 void* buf,
296 int len
299 BZ_EXTERN int BZ_API(BZ2_bzflush) (
300 BZFILE* b
303 BZ_EXTERN void BZ_API(BZ2_bzclose) (
304 BZFILE* b
307 BZ_EXTERN const char * BZ_API(BZ2_bzerror) (
308 BZFILE *b,
309 int *errnum
311 #endif
313 #ifdef __cplusplus
315 #endif
317 #endif
319 /*-------------------------------------------------------------*/
320 /*--- end bzlib.h ---*/
321 /*-------------------------------------------------------------*/