]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - include/bzlib.h
tegra: imx: omap: enable Moschip USB ethernet support for several boards
[karo-tx-uboot.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  */
5
6 /*-------------------------------------------------------------*/
7 /*--- Public header file for the library.                   ---*/
8 /*---                                               bzlib.h ---*/
9 /*-------------------------------------------------------------*/
10
11 /*--
12   This file is a part of bzip2 and/or libbzip2, a program and
13   library for lossless, block-sorting data compression.
14
15   Copyright (C) 1996-2002 Julian R Seward.  All rights reserved.
16
17   Redistribution and use in source and binary forms, with or without
18   modification, are permitted provided that the following conditions
19   are met:
20
21   1. Redistributions of source code must retain the above copyright
22      notice, this list of conditions and the following disclaimer.
23
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.
28
29   3. Altered source versions must be plainly marked as such, and must
30      not be misrepresented as being the original software.
31
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.
35
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.
47
48   Julian Seward, Cambridge, UK.
49   jseward@acm.org
50   bzip2/libbzip2 version 1.0 of 21 March 2000
51
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
61
62   For more information on these sources, see the manual.
63 --*/
64
65
66 #ifndef _BZLIB_H
67 #define _BZLIB_H
68
69 /* Configure for U-Boot environment */
70 #define BZ_NO_STDIO
71 #define BZ_NO_COMPRESS
72 /* End of configuration for U-Boot environment */
73
74 #ifdef __cplusplus
75 extern "C" {
76 #endif
77
78 #define BZ_RUN               0
79 #define BZ_FLUSH             1
80 #define BZ_FINISH            2
81
82 #define BZ_OK                0
83 #define BZ_RUN_OK            1
84 #define BZ_FLUSH_OK          2
85 #define BZ_FINISH_OK         3
86 #define BZ_STREAM_END        4
87 #define BZ_SEQUENCE_ERROR    (-1)
88 #define BZ_PARAM_ERROR       (-2)
89 #define BZ_MEM_ERROR         (-3)
90 #define BZ_DATA_ERROR        (-4)
91 #define BZ_DATA_ERROR_MAGIC  (-5)
92 #define BZ_IO_ERROR          (-6)
93 #define BZ_UNEXPECTED_EOF    (-7)
94 #define BZ_OUTBUFF_FULL      (-8)
95 #define BZ_CONFIG_ERROR      (-9)
96
97 typedef
98    struct {
99       char *next_in;
100       unsigned int avail_in;
101       unsigned int total_in_lo32;
102       unsigned int total_in_hi32;
103
104       char *next_out;
105       unsigned int avail_out;
106       unsigned int total_out_lo32;
107       unsigned int total_out_hi32;
108
109       void *state;
110
111       void *(*bzalloc)(void *,int,int);
112       void (*bzfree)(void *,void *);
113       void *opaque;
114    }
115    bz_stream;
116
117
118 #ifndef BZ_IMPORT
119 #define BZ_EXPORT
120 #endif
121
122 #ifdef _WIN32
123 #   include <windows.h>
124 #   ifdef small
125       /* windows.h define small to char */
126 #      undef small
127 #   endif
128 #   ifdef BZ_EXPORT
129 #   define BZ_API(func) WINAPI func
130 #   define BZ_EXTERN extern
131 #   else
132    /* import windows dll dynamically */
133 #   define BZ_API(func) (WINAPI * func)
134 #   define BZ_EXTERN
135 #   endif
136 #else
137 #   define BZ_API(func) func
138 #   define BZ_EXTERN extern
139 #endif
140
141
142 /*-- Core (low-level) library functions --*/
143
144 BZ_EXTERN int BZ_API(BZ2_bzCompressInit) (
145       bz_stream* strm,
146       int        blockSize100k,
147       int        verbosity,
148       int        workFactor
149    );
150
151 BZ_EXTERN int BZ_API(BZ2_bzCompress) (
152       bz_stream* strm,
153       int action
154    );
155
156 BZ_EXTERN int BZ_API(BZ2_bzCompressEnd) (
157       bz_stream* strm
158    );
159
160 BZ_EXTERN int BZ_API(BZ2_bzDecompressInit) (
161       bz_stream *strm,
162       int       verbosity,
163       int       small
164    );
165
166 BZ_EXTERN int BZ_API(BZ2_bzDecompress) (
167       bz_stream* strm
168    );
169
170 BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) (
171       bz_stream *strm
172    );
173
174
175 /*-- High(er) level library functions --*/
176
177 #ifndef BZ_NO_STDIO
178 #define BZ_MAX_UNUSED 5000
179
180 /* Need a definitition for FILE */
181 #include <stdio.h>
182
183 typedef void BZFILE;
184
185 BZ_EXTERN BZFILE* BZ_API(BZ2_bzReadOpen) (
186       int*  bzerror,
187       FILE* f,
188       int   verbosity,
189       int   small,
190       void* unused,
191       int   nUnused
192    );
193
194 BZ_EXTERN void BZ_API(BZ2_bzReadClose) (
195       int*    bzerror,
196       BZFILE* b
197    );
198
199 BZ_EXTERN void BZ_API(BZ2_bzReadGetUnused) (
200       int*    bzerror,
201       BZFILE* b,
202       void**  unused,
203       int*    nUnused
204    );
205
206 BZ_EXTERN int BZ_API(BZ2_bzRead) (
207       int*    bzerror,
208       BZFILE* b,
209       void*   buf,
210       int     len
211    );
212
213 BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) (
214       int*  bzerror,
215       FILE* f,
216       int   blockSize100k,
217       int   verbosity,
218       int   workFactor
219    );
220
221 BZ_EXTERN void BZ_API(BZ2_bzWrite) (
222       int*    bzerror,
223       BZFILE* b,
224       void*   buf,
225       int     len
226    );
227
228 BZ_EXTERN void BZ_API(BZ2_bzWriteClose) (
229       int*          bzerror,
230       BZFILE*       b,
231       int           abandon,
232       unsigned int* nbytes_in,
233       unsigned int* nbytes_out
234    );
235
236 BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) (
237       int*          bzerror,
238       BZFILE*       b,
239       int           abandon,
240       unsigned int* nbytes_in_lo32,
241       unsigned int* nbytes_in_hi32,
242       unsigned int* nbytes_out_lo32,
243       unsigned int* nbytes_out_hi32
244    );
245 #endif
246
247
248 /*-- Utility functions --*/
249
250 BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) (
251       char*         dest,
252       unsigned int* destLen,
253       char*         source,
254       unsigned int  sourceLen,
255       int           blockSize100k,
256       int           verbosity,
257       int           workFactor
258    );
259
260 BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) (
261       char*         dest,
262       unsigned int* destLen,
263       char*         source,
264       unsigned int  sourceLen,
265       int           small,
266       int           verbosity
267    );
268
269
270 /*--
271    Code contributed by Yoshioka Tsuneo
272    (QWF00133@niftyserve.or.jp/tsuneo-y@is.aist-nara.ac.jp),
273    to support better zlib compatibility.
274    This code is not _officially_ part of libbzip2 (yet);
275    I haven't tested it, documented it, or considered the
276    threading-safeness of it.
277    If this code breaks, please contact both Yoshioka and me.
278 --*/
279
280 BZ_EXTERN const char * BZ_API(BZ2_bzlibVersion) (
281       void
282    );
283
284 #ifndef BZ_NO_STDIO
285 BZ_EXTERN BZFILE * BZ_API(BZ2_bzopen) (
286       const char *path,
287       const char *mode
288    );
289
290 BZ_EXTERN BZFILE * BZ_API(BZ2_bzdopen) (
291       int        fd,
292       const char *mode
293    );
294
295 BZ_EXTERN int BZ_API(BZ2_bzread) (
296       BZFILE* b,
297       void* buf,
298       int len
299    );
300
301 BZ_EXTERN int BZ_API(BZ2_bzwrite) (
302       BZFILE* b,
303       void*   buf,
304       int     len
305    );
306
307 BZ_EXTERN int BZ_API(BZ2_bzflush) (
308       BZFILE* b
309    );
310
311 BZ_EXTERN void BZ_API(BZ2_bzclose) (
312       BZFILE* b
313    );
314
315 BZ_EXTERN const char * BZ_API(BZ2_bzerror) (
316       BZFILE *b,
317       int    *errnum
318    );
319 #endif
320
321 #ifdef __cplusplus
322 }
323 #endif
324
325 #endif
326
327 /*-------------------------------------------------------------*/
328 /*--- end                                           bzlib.h ---*/
329 /*-------------------------------------------------------------*/