]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - ti-u-boot/ti-u-boot.git/blob - include/bzlib.h
Prepare v2024.04
[ti-u-boot/ti-u-boot.git] / include / bzlib.h
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  */
6 /*-------------------------------------------------------------*/
7 /*--- Public header file for the library.                   ---*/
8 /*---                                               bzlib.h ---*/
9 /*-------------------------------------------------------------*/
11 /*--
12   This file is a part of bzip2 and/or libbzip2, a program and
13   library for lossless, block-sorting data compression.
15   Copyright (C) 1996-2002 Julian R Seward.  All rights reserved.
17   Redistribution and use in source and binary forms, with or without
18   modification, are permitted provided that the following conditions
19   are met:
21   1. Redistributions of source code must retain the above copyright
22      notice, this list of conditions and the following disclaimer.
24   2. The origin of this software must not be misrepresented; you must
25      not claim that you wrote the original software.  If you use this
26      software in a product, an acknowledgment in the product
27      documentation would be appreciated but is not required.
29   3. Altered source versions must be plainly marked as such, and must
30      not be misrepresented as being the original software.
32   4. The name of the author may not be used to endorse or promote
33      products derived from this software without specific prior written
34      permission.
36   THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
37   OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
38   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
39   ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
40   DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
41   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
42   GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
43   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
44   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
45   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
46   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
48   Julian Seward, Cambridge, UK.
49   jseward@acm.org
50   bzip2/libbzip2 version 1.0 of 21 March 2000
52   This program is based on (at least) the work of:
53      Mike Burrows
54      David Wheeler
55      Peter Fenwick
56      Alistair Moffat
57      Radford Neal
58      Ian H. Witten
59      Robert Sedgewick
60      Jon L. Bentley
62   For more information on these sources, see the manual.
63 --*/
66 #ifndef _BZLIB_H
67 #define _BZLIB_H
69 /* Configure for U-Boot environment */
70 #define BZ_NO_STDIO
72 #ifndef CONFIG_SANDBOX
73 #define BZ_NO_COMPRESS
74 #endif
75 /* End of configuration for U-Boot environment */
77 #ifdef __cplusplus
78 extern "C" {
79 #endif
81 #define BZ_RUN               0
82 #define BZ_FLUSH             1
83 #define BZ_FINISH            2
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)
100 typedef
101    struct {
102       char *next_in;
103       unsigned int avail_in;
104       unsigned int total_in_lo32;
105       unsigned int total_in_hi32;
107       char *next_out;
108       unsigned int avail_out;
109       unsigned int total_out_lo32;
110       unsigned int total_out_hi32;
112       void *state;
114       void *(*bzalloc)(void *,int,int);
115       void (*bzfree)(void *,void *);
116       void *opaque;
117    }
118    bz_stream;
121 #ifndef BZ_IMPORT
122 #define BZ_EXPORT
123 #endif
125 #ifdef _WIN32
126 #   include <windows.h>
127 #   ifdef small
128       /* windows.h define small to char */
129 #      undef small
130 #   endif
131 #   ifdef BZ_EXPORT
132 #   define BZ_API(func) WINAPI func
133 #   define BZ_EXTERN extern
134 #   else
135    /* import windows dll dynamically */
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
145 /*-- Core (low-level) library functions --*/
147 BZ_EXTERN int BZ_API(BZ2_bzCompressInit) (
148       bz_stream* strm,
149       int        blockSize100k,
150       int        verbosity,
151       int        workFactor
152    );
154 BZ_EXTERN int BZ_API(BZ2_bzCompress) (
155       bz_stream* strm,
156       int action
157    );
159 BZ_EXTERN int BZ_API(BZ2_bzCompressEnd) (
160       bz_stream* strm
161    );
163 BZ_EXTERN int BZ_API(BZ2_bzDecompressInit) (
164       bz_stream *strm,
165       int       verbosity,
166       int       small
167    );
169 BZ_EXTERN int BZ_API(BZ2_bzDecompress) (
170       bz_stream* strm
171    );
173 BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) (
174       bz_stream *strm
175    );
178 /*-- High(er) level library functions --*/
180 #ifndef BZ_NO_STDIO
181 #define BZ_MAX_UNUSED 5000
183 /* Need a definitition for FILE */
184 #include <stdio.h>
186 typedef void BZFILE;
188 BZ_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    );
197 BZ_EXTERN void BZ_API(BZ2_bzReadClose) (
198       int*    bzerror,
199       BZFILE* b
200    );
202 BZ_EXTERN void BZ_API(BZ2_bzReadGetUnused) (
203       int*    bzerror,
204       BZFILE* b,
205       void**  unused,
206       int*    nUnused
207    );
209 BZ_EXTERN int BZ_API(BZ2_bzRead) (
210       int*    bzerror,
211       BZFILE* b,
212       void*   buf,
213       int     len
214    );
216 BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) (
217       int*  bzerror,
218       FILE* f,
219       int   blockSize100k,
220       int   verbosity,
221       int   workFactor
222    );
224 BZ_EXTERN void BZ_API(BZ2_bzWrite) (
225       int*    bzerror,
226       BZFILE* b,
227       void*   buf,
228       int     len
229    );
231 BZ_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    );
239 BZ_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
251 /*-- Utility functions --*/
253 BZ_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    );
263 BZ_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    );
273 /*--
274    Code contributed by Yoshioka Tsuneo
275    (QWF00133@niftyserve.or.jp/tsuneo-y@is.aist-nara.ac.jp),
276    to support better zlib compatibility.
277    This code is not _officially_ part of libbzip2 (yet);
278    I haven't tested it, documented it, or considered the
279    threading-safeness of it.
280    If this code breaks, please contact both Yoshioka and me.
281 --*/
283 BZ_EXTERN const char * BZ_API(BZ2_bzlibVersion) (
284       void
285    );
287 #ifndef BZ_NO_STDIO
288 BZ_EXTERN BZFILE * BZ_API(BZ2_bzopen) (
289       const char *path,
290       const char *mode
291    );
293 BZ_EXTERN BZFILE * BZ_API(BZ2_bzdopen) (
294       int        fd,
295       const char *mode
296    );
298 BZ_EXTERN int BZ_API(BZ2_bzread) (
299       BZFILE* b,
300       void* buf,
301       int len
302    );
304 BZ_EXTERN int BZ_API(BZ2_bzwrite) (
305       BZFILE* b,
306       void*   buf,
307       int     len
308    );
310 BZ_EXTERN int BZ_API(BZ2_bzflush) (
311       BZFILE* b
312    );
314 BZ_EXTERN void BZ_API(BZ2_bzclose) (
315       BZFILE* b
316    );
318 BZ_EXTERN const char * BZ_API(BZ2_bzerror) (
319       BZFILE *b,
320       int    *errnum
321    );
322 #endif
324 #ifdef __cplusplus
326 #endif
328 #endif
330 /*-------------------------------------------------------------*/
331 /*--- end                                           bzlib.h ---*/
332 /*-------------------------------------------------------------*/