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 | |
| 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 | |
| 176 | /*-- High(er) level library functions --*/ |
| 177 | |
| 178 | #ifndef BZ_NO_STDIO |
| 179 | #define BZ_MAX_UNUSED 5000 |
| 180 | |
| 181 | /* Need a definitition for FILE */ |
| 182 | #include <stdio.h> |
| 183 | |
| 184 | typedef void BZFILE; |
| 185 | |
| 186 | BZ_EXTERN BZFILE* BZ_API(BZ2_bzReadOpen) ( |
| 187 | int* bzerror, |
| 188 | FILE* f, |
| 189 | int verbosity, |
| 190 | int small, |
| 191 | void* unused, |
| 192 | int nUnused |
| 193 | ); |
| 194 | |
| 195 | BZ_EXTERN void BZ_API(BZ2_bzReadClose) ( |
| 196 | int* bzerror, |
| 197 | BZFILE* b |
| 198 | ); |
| 199 | |
| 200 | BZ_EXTERN void BZ_API(BZ2_bzReadGetUnused) ( |
| 201 | int* bzerror, |
| 202 | BZFILE* b, |
| 203 | void** unused, |
| 204 | int* nUnused |
| 205 | ); |
| 206 | |
| 207 | BZ_EXTERN int BZ_API(BZ2_bzRead) ( |
| 208 | int* bzerror, |
| 209 | BZFILE* b, |
| 210 | void* buf, |
| 211 | int len |
| 212 | ); |
| 213 | |
| 214 | BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) ( |
| 215 | int* bzerror, |
| 216 | FILE* f, |
| 217 | int blockSize100k, |
| 218 | int verbosity, |
| 219 | int workFactor |
| 220 | ); |
| 221 | |
| 222 | BZ_EXTERN void BZ_API(BZ2_bzWrite) ( |
| 223 | int* bzerror, |
| 224 | BZFILE* b, |
| 225 | void* buf, |
| 226 | int len |
| 227 | ); |
| 228 | |
| 229 | BZ_EXTERN void BZ_API(BZ2_bzWriteClose) ( |
| 230 | int* bzerror, |
| 231 | BZFILE* b, |
| 232 | int abandon, |
| 233 | unsigned int* nbytes_in, |
| 234 | unsigned int* nbytes_out |
| 235 | ); |
| 236 | |
| 237 | BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) ( |
| 238 | int* bzerror, |
| 239 | BZFILE* b, |
| 240 | int abandon, |
| 241 | unsigned int* nbytes_in_lo32, |
| 242 | unsigned int* nbytes_in_hi32, |
| 243 | unsigned int* nbytes_out_lo32, |
| 244 | unsigned int* nbytes_out_hi32 |
| 245 | ); |
| 246 | #endif |
| 247 | |
| 248 | |
| 249 | /*-- Utility functions --*/ |
| 250 | |
| 251 | BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) ( |
| 252 | char* dest, |
| 253 | unsigned int* destLen, |
| 254 | char* source, |
| 255 | unsigned int sourceLen, |
| 256 | int blockSize100k, |
| 257 | int verbosity, |
| 258 | int workFactor |
| 259 | ); |
| 260 | |
| 261 | BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) ( |
| 262 | char* dest, |
| 263 | unsigned int* destLen, |
| 264 | char* source, |
| 265 | unsigned int sourceLen, |
| 266 | int small, |
| 267 | int verbosity |
| 268 | ); |
| 269 | |
| 270 | |
| 271 | /*-- |
| 272 | Code contributed by Yoshioka Tsuneo |
| 273 | (QWF00133@niftyserve.or.jp/tsuneo-y@is.aist-nara.ac.jp), |
| 274 | to support better zlib compatibility. |
| 275 | This code is not _officially_ part of libbzip2 (yet); |
| 276 | I haven't tested it, documented it, or considered the |
| 277 | threading-safeness of it. |
| 278 | If this code breaks, please contact both Yoshioka and me. |
| 279 | --*/ |
| 280 | |
| 281 | BZ_EXTERN const char * BZ_API(BZ2_bzlibVersion) ( |
| 282 | void |
| 283 | ); |
| 284 | |
| 285 | #ifndef BZ_NO_STDIO |
| 286 | BZ_EXTERN BZFILE * BZ_API(BZ2_bzopen) ( |
| 287 | const char *path, |
| 288 | const char *mode |
| 289 | ); |
| 290 | |
| 291 | BZ_EXTERN BZFILE * BZ_API(BZ2_bzdopen) ( |
| 292 | int fd, |
| 293 | const char *mode |
| 294 | ); |
| 295 | |
| 296 | BZ_EXTERN int BZ_API(BZ2_bzread) ( |
| 297 | BZFILE* b, |
| 298 | void* buf, |
| 299 | int len |
| 300 | ); |
| 301 | |
| 302 | BZ_EXTERN int BZ_API(BZ2_bzwrite) ( |
| 303 | BZFILE* b, |
| 304 | void* buf, |
| 305 | int len |
| 306 | ); |
| 307 | |
| 308 | BZ_EXTERN int BZ_API(BZ2_bzflush) ( |
| 309 | BZFILE* b |
| 310 | ); |
| 311 | |
| 312 | BZ_EXTERN void BZ_API(BZ2_bzclose) ( |
| 313 | BZFILE* b |
| 314 | ); |
| 315 | |
| 316 | BZ_EXTERN const char * BZ_API(BZ2_bzerror) ( |
| 317 | BZFILE *b, |
| 318 | int *errnum |
| 319 | ); |
| 320 | #endif |
| 321 | |
| 322 | #ifdef __cplusplus |
| 323 | } |
| 324 | #endif |
| 325 | |
| 326 | #endif |
| 327 | |
| 328 | /*-------------------------------------------------------------*/ |
| 329 | /*--- end bzlib.h ---*/ |
| 330 | /*-------------------------------------------------------------*/ |