1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66#ifndef _BZLIB_H
67#define _BZLIB_H
68
69
70#define BZ_NO_STDIO
71
72#ifndef CONFIG_SANDBOX
73#define BZ_NO_COMPRESS
74#endif
75
76
77#ifdef __cplusplus
78extern "C" {
79#endif
80
81#define BZ_RUN 0
82#define BZ_FLUSH 1
83#define BZ_FINISH 2
84
85#define BZ_OK 0
86#define BZ_RUN_OK 1
87#define BZ_FLUSH_OK 2
88#define BZ_FINISH_OK 3
89#define BZ_STREAM_END 4
90#define BZ_SEQUENCE_ERROR (-1)
91#define BZ_PARAM_ERROR (-2)
92#define BZ_MEM_ERROR (-3)
93#define BZ_DATA_ERROR (-4)
94#define BZ_DATA_ERROR_MAGIC (-5)
95#define BZ_IO_ERROR (-6)
96#define BZ_UNEXPECTED_EOF (-7)
97#define BZ_OUTBUFF_FULL (-8)
98#define BZ_CONFIG_ERROR (-9)
99
100typedef
101 struct {
102 char *next_in;
103 unsigned int avail_in;
104 unsigned int total_in_lo32;
105 unsigned int total_in_hi32;
106
107 char *next_out;
108 unsigned int avail_out;
109 unsigned int total_out_lo32;
110 unsigned int total_out_hi32;
111
112 void *state;
113
114 void *(*bzalloc)(void *,int,int);
115 void (*bzfree)(void *,void *);
116 void *opaque;
117 }
118 bz_stream;
119
120
121#ifndef BZ_IMPORT
122#define BZ_EXPORT
123#endif
124
125#ifdef _WIN32
126# include <windows.h>
127# ifdef small
128
129# undef small
130# endif
131# ifdef BZ_EXPORT
132# define BZ_API(func) WINAPI func
133# define BZ_EXTERN extern
134# else
135
136# define BZ_API(func) (WINAPI * func)
137# define BZ_EXTERN
138# endif
139#else
140# define BZ_API(func) func
141# define BZ_EXTERN extern
142#endif
143
144
145
146
147BZ_EXTERN int BZ_API(BZ2_bzCompressInit) (
148 bz_stream* strm,
149 int blockSize100k,
150 int verbosity,
151 int workFactor
152 );
153
154BZ_EXTERN int BZ_API(BZ2_bzCompress) (
155 bz_stream* strm,
156 int action
157 );
158
159BZ_EXTERN int BZ_API(BZ2_bzCompressEnd) (
160 bz_stream* strm
161 );
162
163BZ_EXTERN int BZ_API(BZ2_bzDecompressInit) (
164 bz_stream *strm,
165 int verbosity,
166 int small
167 );
168
169BZ_EXTERN int BZ_API(BZ2_bzDecompress) (
170 bz_stream* strm
171 );
172
173BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) (
174 bz_stream *strm
175 );
176
177
178
179
180#ifndef BZ_NO_STDIO
181#define BZ_MAX_UNUSED 5000
182
183
184#include <stdio.h>
185
186typedef void BZFILE;
187
188BZ_EXTERN BZFILE* BZ_API(BZ2_bzReadOpen) (
189 int* bzerror,
190 FILE* f,
191 int verbosity,
192 int small,
193 void* unused,
194 int nUnused
195 );
196
197BZ_EXTERN void BZ_API(BZ2_bzReadClose) (
198 int* bzerror,
199 BZFILE* b
200 );
201
202BZ_EXTERN void BZ_API(BZ2_bzReadGetUnused) (
203 int* bzerror,
204 BZFILE* b,
205 void** unused,
206 int* nUnused
207 );
208
209BZ_EXTERN int BZ_API(BZ2_bzRead) (
210 int* bzerror,
211 BZFILE* b,
212 void* buf,
213 int len
214 );
215
216BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) (
217 int* bzerror,
218 FILE* f,
219 int blockSize100k,
220 int verbosity,
221 int workFactor
222 );
223
224BZ_EXTERN void BZ_API(BZ2_bzWrite) (
225 int* bzerror,
226 BZFILE* b,
227 void* buf,
228 int len
229 );
230
231BZ_EXTERN void BZ_API(BZ2_bzWriteClose) (
232 int* bzerror,
233 BZFILE* b,
234 int abandon,
235 unsigned int* nbytes_in,
236 unsigned int* nbytes_out
237 );
238
239BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) (
240 int* bzerror,
241 BZFILE* b,
242 int abandon,
243 unsigned int* nbytes_in_lo32,
244 unsigned int* nbytes_in_hi32,
245 unsigned int* nbytes_out_lo32,
246 unsigned int* nbytes_out_hi32
247 );
248#endif
249
250
251
252
253BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) (
254 char* dest,
255 unsigned int* destLen,
256 char* source,
257 unsigned int sourceLen,
258 int blockSize100k,
259 int verbosity,
260 int workFactor
261 );
262
263BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) (
264 char* dest,
265 unsigned int* destLen,
266 char* source,
267 unsigned int sourceLen,
268 int small,
269 int verbosity
270 );
271
272
273
274
275
276
277
278
279
280
281
282
283BZ_EXTERN const char * BZ_API(BZ2_bzlibVersion) (
284 void
285 );
286
287#ifndef BZ_NO_STDIO
288BZ_EXTERN BZFILE * BZ_API(BZ2_bzopen) (
289 const char *path,
290 const char *mode
291 );
292
293BZ_EXTERN BZFILE * BZ_API(BZ2_bzdopen) (
294 int fd,
295 const char *mode
296 );
297
298BZ_EXTERN int BZ_API(BZ2_bzread) (
299 BZFILE* b,
300 void* buf,
301 int len
302 );
303
304BZ_EXTERN int BZ_API(BZ2_bzwrite) (
305 BZFILE* b,
306 void* buf,
307 int len
308 );
309
310BZ_EXTERN int BZ_API(BZ2_bzflush) (
311 BZFILE* b
312 );
313
314BZ_EXTERN void BZ_API(BZ2_bzclose) (
315 BZFILE* b
316 );
317
318BZ_EXTERN const char * BZ_API(BZ2_bzerror) (
319 BZFILE *b,
320 int *errnum
321 );
322#endif
323
324#ifdef __cplusplus
325}
326#endif
327
328#endif
329
330
331
332
333