wdenk | 710e350 | 2003-08-29 20:57:53 +0000 | [diff] [blame] | 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 | |
wdenk | 710e350 | 2003-08-29 20:57:53 +0000 | [diff] [blame] | 65 | #ifndef _BZLIB_H |
| 66 | #define _BZLIB_H |
| 67 | |
| 68 | /* Configure for U-Boot environment */ |
| 69 | #define BZ_NO_STDIO |
Simon Glass | 0a30e42 | 2016-01-05 09:31:00 -0700 | [diff] [blame] | 70 | |
| 71 | #ifndef CONFIG_SANDBOX |
wdenk | 710e350 | 2003-08-29 20:57:53 +0000 | [diff] [blame] | 72 | #define BZ_NO_COMPRESS |
Simon Glass | 0a30e42 | 2016-01-05 09:31:00 -0700 | [diff] [blame] | 73 | #endif |
wdenk | 710e350 | 2003-08-29 20:57:53 +0000 | [diff] [blame] | 74 | /* End of configuration for U-Boot environment */ |
| 75 | |
| 76 | #ifdef __cplusplus |
| 77 | extern "C" { |
| 78 | #endif |
| 79 | |
| 80 | #define BZ_RUN 0 |
| 81 | #define BZ_FLUSH 1 |
| 82 | #define BZ_FINISH 2 |
| 83 | |
| 84 | #define BZ_OK 0 |
| 85 | #define BZ_RUN_OK 1 |
| 86 | #define BZ_FLUSH_OK 2 |
| 87 | #define BZ_FINISH_OK 3 |
| 88 | #define BZ_STREAM_END 4 |
| 89 | #define BZ_SEQUENCE_ERROR (-1) |
| 90 | #define BZ_PARAM_ERROR (-2) |
| 91 | #define BZ_MEM_ERROR (-3) |
| 92 | #define BZ_DATA_ERROR (-4) |
| 93 | #define BZ_DATA_ERROR_MAGIC (-5) |
| 94 | #define BZ_IO_ERROR (-6) |
| 95 | #define BZ_UNEXPECTED_EOF (-7) |
| 96 | #define BZ_OUTBUFF_FULL (-8) |
| 97 | #define BZ_CONFIG_ERROR (-9) |
| 98 | |
| 99 | typedef |
| 100 | struct { |
| 101 | char *next_in; |
| 102 | unsigned int avail_in; |
| 103 | unsigned int total_in_lo32; |
| 104 | unsigned int total_in_hi32; |
| 105 | |
| 106 | char *next_out; |
| 107 | unsigned int avail_out; |
| 108 | unsigned int total_out_lo32; |
| 109 | unsigned int total_out_hi32; |
| 110 | |
| 111 | void *state; |
| 112 | |
| 113 | void *(*bzalloc)(void *,int,int); |
| 114 | void (*bzfree)(void *,void *); |
| 115 | void *opaque; |
| 116 | } |
| 117 | bz_stream; |
| 118 | |
wdenk | 710e350 | 2003-08-29 20:57:53 +0000 | [diff] [blame] | 119 | #ifndef BZ_IMPORT |
| 120 | #define BZ_EXPORT |
| 121 | #endif |
| 122 | |
| 123 | #ifdef _WIN32 |
| 124 | # include <windows.h> |
| 125 | # ifdef small |
| 126 | /* windows.h define small to char */ |
| 127 | # undef small |
| 128 | # endif |
| 129 | # ifdef BZ_EXPORT |
| 130 | # define BZ_API(func) WINAPI func |
| 131 | # define BZ_EXTERN extern |
| 132 | # else |
| 133 | /* import windows dll dynamically */ |
| 134 | # define BZ_API(func) (WINAPI * func) |
| 135 | # define BZ_EXTERN |
| 136 | # endif |
| 137 | #else |
| 138 | # define BZ_API(func) func |
| 139 | # define BZ_EXTERN extern |
| 140 | #endif |
| 141 | |
wdenk | 710e350 | 2003-08-29 20:57:53 +0000 | [diff] [blame] | 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 | |
wdenk | 710e350 | 2003-08-29 20:57:53 +0000 | [diff] [blame] | 174 | /*-- High(er) level library functions --*/ |
| 175 | |
| 176 | #ifndef BZ_NO_STDIO |
| 177 | #define BZ_MAX_UNUSED 5000 |
| 178 | |
| 179 | /* Need a definitition for FILE */ |
| 180 | #include <stdio.h> |
| 181 | |
| 182 | typedef void BZFILE; |
| 183 | |
| 184 | BZ_EXTERN BZFILE* BZ_API(BZ2_bzReadOpen) ( |
| 185 | int* bzerror, |
| 186 | FILE* f, |
| 187 | int verbosity, |
| 188 | int small, |
| 189 | void* unused, |
| 190 | int nUnused |
| 191 | ); |
| 192 | |
| 193 | BZ_EXTERN void BZ_API(BZ2_bzReadClose) ( |
| 194 | int* bzerror, |
| 195 | BZFILE* b |
| 196 | ); |
| 197 | |
| 198 | BZ_EXTERN void BZ_API(BZ2_bzReadGetUnused) ( |
| 199 | int* bzerror, |
| 200 | BZFILE* b, |
| 201 | void** unused, |
| 202 | int* nUnused |
| 203 | ); |
| 204 | |
| 205 | BZ_EXTERN int BZ_API(BZ2_bzRead) ( |
| 206 | int* bzerror, |
| 207 | BZFILE* b, |
| 208 | void* buf, |
| 209 | int len |
| 210 | ); |
| 211 | |
| 212 | BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) ( |
| 213 | int* bzerror, |
| 214 | FILE* f, |
| 215 | int blockSize100k, |
| 216 | int verbosity, |
| 217 | int workFactor |
| 218 | ); |
| 219 | |
| 220 | BZ_EXTERN void BZ_API(BZ2_bzWrite) ( |
| 221 | int* bzerror, |
| 222 | BZFILE* b, |
| 223 | void* buf, |
| 224 | int len |
| 225 | ); |
| 226 | |
| 227 | BZ_EXTERN void BZ_API(BZ2_bzWriteClose) ( |
| 228 | int* bzerror, |
| 229 | BZFILE* b, |
| 230 | int abandon, |
| 231 | unsigned int* nbytes_in, |
| 232 | unsigned int* nbytes_out |
| 233 | ); |
| 234 | |
| 235 | BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) ( |
| 236 | int* bzerror, |
| 237 | BZFILE* b, |
| 238 | int abandon, |
| 239 | unsigned int* nbytes_in_lo32, |
| 240 | unsigned int* nbytes_in_hi32, |
| 241 | unsigned int* nbytes_out_lo32, |
| 242 | unsigned int* nbytes_out_hi32 |
| 243 | ); |
| 244 | #endif |
| 245 | |
wdenk | 710e350 | 2003-08-29 20:57:53 +0000 | [diff] [blame] | 246 | /*-- Utility functions --*/ |
| 247 | |
| 248 | BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) ( |
| 249 | char* dest, |
| 250 | unsigned int* destLen, |
| 251 | char* source, |
| 252 | unsigned int sourceLen, |
| 253 | int blockSize100k, |
| 254 | int verbosity, |
| 255 | int workFactor |
| 256 | ); |
| 257 | |
| 258 | BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) ( |
| 259 | char* dest, |
| 260 | unsigned int* destLen, |
| 261 | char* source, |
| 262 | unsigned int sourceLen, |
| 263 | int small, |
| 264 | int verbosity |
| 265 | ); |
| 266 | |
wdenk | 710e350 | 2003-08-29 20:57:53 +0000 | [diff] [blame] | 267 | /*-- |
| 268 | Code contributed by Yoshioka Tsuneo |
| 269 | (QWF00133@niftyserve.or.jp/tsuneo-y@is.aist-nara.ac.jp), |
| 270 | to support better zlib compatibility. |
| 271 | This code is not _officially_ part of libbzip2 (yet); |
| 272 | I haven't tested it, documented it, or considered the |
| 273 | threading-safeness of it. |
| 274 | If this code breaks, please contact both Yoshioka and me. |
| 275 | --*/ |
| 276 | |
| 277 | BZ_EXTERN const char * BZ_API(BZ2_bzlibVersion) ( |
| 278 | void |
| 279 | ); |
| 280 | |
| 281 | #ifndef BZ_NO_STDIO |
| 282 | BZ_EXTERN BZFILE * BZ_API(BZ2_bzopen) ( |
| 283 | const char *path, |
| 284 | const char *mode |
| 285 | ); |
| 286 | |
| 287 | BZ_EXTERN BZFILE * BZ_API(BZ2_bzdopen) ( |
| 288 | int fd, |
| 289 | const char *mode |
| 290 | ); |
| 291 | |
| 292 | BZ_EXTERN int BZ_API(BZ2_bzread) ( |
| 293 | BZFILE* b, |
| 294 | void* buf, |
| 295 | int len |
| 296 | ); |
| 297 | |
| 298 | BZ_EXTERN int BZ_API(BZ2_bzwrite) ( |
| 299 | BZFILE* b, |
| 300 | void* buf, |
| 301 | int len |
| 302 | ); |
| 303 | |
| 304 | BZ_EXTERN int BZ_API(BZ2_bzflush) ( |
| 305 | BZFILE* b |
| 306 | ); |
| 307 | |
| 308 | BZ_EXTERN void BZ_API(BZ2_bzclose) ( |
| 309 | BZFILE* b |
| 310 | ); |
| 311 | |
| 312 | BZ_EXTERN const char * BZ_API(BZ2_bzerror) ( |
| 313 | BZFILE *b, |
| 314 | int *errnum |
| 315 | ); |
| 316 | #endif |
| 317 | |
| 318 | #ifdef __cplusplus |
| 319 | } |
| 320 | #endif |
| 321 | |
| 322 | #endif |
| 323 | |
| 324 | /*-------------------------------------------------------------*/ |
| 325 | /*--- end bzlib.h ---*/ |
| 326 | /*-------------------------------------------------------------*/ |