xref: /titanic_50/usr/src/common/bzip2/bzlib.h (revision 3c112a2b34403220c06c3e2fcac403358cfba168)
1 
2 /*-------------------------------------------------------------*/
3 /*--- Public header file for the library.                   ---*/
4 /*---                                               bzlib.h ---*/
5 /*-------------------------------------------------------------*/
6 
7 /* ------------------------------------------------------------------
8    This file is part of bzip2/libbzip2, a program and library for
9    lossless, block-sorting data compression.
10 
11    bzip2/libbzip2 version 1.0.5 of 10 December 2007
12    Copyright (C) 1996-2007 Julian Seward <jseward@bzip.org>
13 
14    Please read the WARNING, DISCLAIMER and PATENTS sections in the
15    README file.
16 
17    This program is released under the terms of the license contained
18    in the file LICENSE.
19    ------------------------------------------------------------------ */
20 
21 #ifndef _BZLIB_H
22 #define _BZLIB_H
23 
24 #ifdef _KERNEL
25 #define	BZ_NO_STDIO
26 #endif
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 #define BZ_RUN               0
33 #define BZ_FLUSH             1
34 #define BZ_FINISH            2
35 
36 #define BZ_OK                0
37 #define BZ_RUN_OK            1
38 #define BZ_FLUSH_OK          2
39 #define BZ_FINISH_OK         3
40 #define BZ_STREAM_END        4
41 #define BZ_SEQUENCE_ERROR    (-1)
42 #define BZ_PARAM_ERROR       (-2)
43 #define BZ_MEM_ERROR         (-3)
44 #define BZ_DATA_ERROR        (-4)
45 #define BZ_DATA_ERROR_MAGIC  (-5)
46 #define BZ_IO_ERROR          (-6)
47 #define BZ_UNEXPECTED_EOF    (-7)
48 #define BZ_OUTBUFF_FULL      (-8)
49 #define BZ_CONFIG_ERROR      (-9)
50 
51 typedef
52    struct {
53       char *next_in;
54       unsigned int avail_in;
55       unsigned int total_in_lo32;
56       unsigned int total_in_hi32;
57 
58       char *next_out;
59       unsigned int avail_out;
60       unsigned int total_out_lo32;
61       unsigned int total_out_hi32;
62 
63       void *state;
64 
65       void *(*bzalloc)(void *,int,int);
66       void (*bzfree)(void *,void *);
67       void *opaque;
68    }
69    bz_stream;
70 
71 
72 #ifndef BZ_IMPORT
73 #define BZ_EXPORT
74 #endif
75 
76 #ifndef BZ_NO_STDIO
77 /* Need a definitition for FILE */
78 #include <stdio.h>
79 #endif
80 
81 #ifdef _WIN32
82 #   include <windows.h>
83 #   ifdef small
84       /* windows.h define small to char */
85 #      undef small
86 #   endif
87 #   ifdef BZ_EXPORT
88 #   define BZ_API(func) WINAPI func
89 #   define BZ_EXTERN extern
90 #   else
91    /* import windows dll dynamically */
92 #   define BZ_API(func) (WINAPI * func)
93 #   define BZ_EXTERN
94 #   endif
95 #else
96 #   define BZ_API(func) func
97 #   define BZ_EXTERN extern
98 #endif
99 
100 
101 /*-- Core (low-level) library functions --*/
102 
103 #define	BZ2_BZALLOC_ALIGN	(64)
104 
105 BZ_EXTERN int BZ_API(BZ2_bzCompressInit) (
106       bz_stream* strm,
107       int        blockSize100k,
108       int        verbosity,
109       int        workFactor
110    );
111 
112 BZ_EXTERN int  BZ_API(BZ2_bzCompressInitSize) (
113       int        blockSize100k
114    );
115 
116 BZ_EXTERN int BZ_API(BZ2_bzCompressReset) (
117       bz_stream* strm
118    );
119 
120 BZ_EXTERN int BZ_API(BZ2_bzCompress) (
121       bz_stream* strm,
122       int action
123    );
124 
125 BZ_EXTERN int BZ_API(BZ2_bzCompressEnd) (
126       bz_stream* strm
127    );
128 
129 BZ_EXTERN int BZ_API(BZ2_bzDecompressInit) (
130       bz_stream *strm,
131       int       verbosity,
132       int       small
133    );
134 
135 BZ_EXTERN int BZ_API(BZ2_bzDecompressReset) (
136       bz_stream* strm
137    );
138 
139 BZ_EXTERN int BZ_API(BZ2_bzDecompress) (
140       bz_stream* strm
141    );
142 
143 BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) (
144       bz_stream *strm
145    );
146 
147 BZ_EXTERN const char * BZ_API(BZ2_bzErrorString) (
148       int error_code
149    );
150 
151 
152 
153 /*-- High(er) level library functions --*/
154 
155 #ifndef BZ_NO_STDIO
156 #define BZ_MAX_UNUSED 5000
157 
158 typedef void BZFILE;
159 
160 BZ_EXTERN BZFILE* BZ_API(BZ2_bzReadOpen) (
161       int*  bzerror,
162       FILE* f,
163       int   verbosity,
164       int   small,
165       void* unused,
166       int   nUnused
167    );
168 
169 BZ_EXTERN void BZ_API(BZ2_bzReadClose) (
170       int*    bzerror,
171       BZFILE* b
172    );
173 
174 BZ_EXTERN void BZ_API(BZ2_bzReadGetUnused) (
175       int*    bzerror,
176       BZFILE* b,
177       void**  unused,
178       int*    nUnused
179    );
180 
181 BZ_EXTERN int BZ_API(BZ2_bzRead) (
182       int*    bzerror,
183       BZFILE* b,
184       void*   buf,
185       int     len
186    );
187 
188 BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) (
189       int*  bzerror,
190       FILE* f,
191       int   blockSize100k,
192       int   verbosity,
193       int   workFactor
194    );
195 
196 BZ_EXTERN void BZ_API(BZ2_bzWrite) (
197       int*    bzerror,
198       BZFILE* b,
199       void*   buf,
200       int     len
201    );
202 
203 BZ_EXTERN void BZ_API(BZ2_bzWriteClose) (
204       int*          bzerror,
205       BZFILE*       b,
206       int           abandon,
207       unsigned int* nbytes_in,
208       unsigned int* nbytes_out
209    );
210 
211 BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) (
212       int*          bzerror,
213       BZFILE*       b,
214       int           abandon,
215       unsigned int* nbytes_in_lo32,
216       unsigned int* nbytes_in_hi32,
217       unsigned int* nbytes_out_lo32,
218       unsigned int* nbytes_out_hi32
219    );
220 #endif
221 
222 
223 /*-- Utility functions --*/
224 
225 BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) (
226       char*         dest,
227       unsigned int* destLen,
228       char*         source,
229       unsigned int  sourceLen,
230       int           blockSize100k,
231       int           verbosity,
232       int           workFactor
233    );
234 
235 BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) (
236       char*         dest,
237       unsigned int* destLen,
238       char*         source,
239       unsigned int  sourceLen,
240       int           small,
241       int           verbosity
242    );
243 
244 
245 /*--
246    Code contributed by Yoshioka Tsuneo (tsuneo@rr.iij4u.or.jp)
247    to support better zlib compatibility.
248    This code is not _officially_ part of libbzip2 (yet);
249    I haven't tested it, documented it, or considered the
250    threading-safeness of it.
251    If this code breaks, please contact both Yoshioka and me.
252 --*/
253 
254 BZ_EXTERN const char * BZ_API(BZ2_bzlibVersion) (
255       void
256    );
257 
258 #ifndef BZ_NO_STDIO
259 BZ_EXTERN BZFILE * BZ_API(BZ2_bzopen) (
260       const char *path,
261       const char *mode
262    );
263 
264 BZ_EXTERN BZFILE * BZ_API(BZ2_bzdopen) (
265       int        fd,
266       const char *mode
267    );
268 
269 BZ_EXTERN int BZ_API(BZ2_bzread) (
270       BZFILE* b,
271       void* buf,
272       int len
273    );
274 
275 BZ_EXTERN int BZ_API(BZ2_bzwrite) (
276       BZFILE* b,
277       void*   buf,
278       int     len
279    );
280 
281 BZ_EXTERN int BZ_API(BZ2_bzflush) (
282       BZFILE* b
283    );
284 
285 BZ_EXTERN void BZ_API(BZ2_bzclose) (
286       BZFILE* b
287    );
288 
289 BZ_EXTERN const char * BZ_API(BZ2_bzerror) (
290       BZFILE *b,
291       int    *errnum
292    );
293 #endif
294 
295 #ifdef __cplusplus
296 }
297 #endif
298 
299 /*-------------------------------------------------------------*/
300 /*--- end                                           bzlib.h ---*/
301 /*-------------------------------------------------------------*/
302 #endif /* _BZLIB_H */
303