| 1 |
|
| 2 |
/*-------------------------------------------------------------*/ |
| 3 |
/*--- Public header file for the library. ---*/ |
| 4 |
/*--- bzlib.h ---*/ |
| 5 |
/*-------------------------------------------------------------*/ |
| 6 |
|
| 7 |
/* This has been heavily hacked to be part of zgz. Decompression |
| 8 |
* support has been ripped out. */ |
| 9 |
|
| 10 |
/*-- |
| 11 |
This file is a part of bzip2 and/or libbzip2, a program and |
| 12 |
library for lossless, block-sorting data compression. |
| 13 |
|
| 14 |
Copyright (C) 1996-1999 Julian R Seward. All rights reserved. |
| 15 |
|
| 16 |
Redistribution and use in source and binary forms, with or without |
| 17 |
modification, are permitted provided that the following conditions |
| 18 |
are met: |
| 19 |
|
| 20 |
1. Redistributions of source code must retain the above copyright |
| 21 |
notice, this list of conditions and the following disclaimer. |
| 22 |
|
| 23 |
2. The origin of this software must not be misrepresented; you must |
| 24 |
not claim that you wrote the original software. If you use this |
| 25 |
software in a product, an acknowledgment in the product |
| 26 |
documentation would be appreciated but is not required. |
| 27 |
|
| 28 |
3. Altered source versions must be plainly marked as such, and must |
| 29 |
not be misrepresented as being the original software. |
| 30 |
|
| 31 |
4. The name of the author may not be used to endorse or promote |
| 32 |
products derived from this software without specific prior written |
| 33 |
permission. |
| 34 |
|
| 35 |
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS |
| 36 |
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 37 |
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 38 |
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY |
| 39 |
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 40 |
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE |
| 41 |
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 42 |
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 43 |
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| 44 |
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 45 |
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 46 |
|
| 47 |
Julian Seward, Cambridge, UK. |
| 48 |
[email protected] |
| 49 |
bzip2/libbzip2 version 0.9.5 of 24 May 1999 |
| 50 |
|
| 51 |
This program is based on (at least) the work of: |
| 52 |
Mike Burrows |
| 53 |
David Wheeler |
| 54 |
Peter Fenwick |
| 55 |
Alistair Moffat |
| 56 |
Radford Neal |
| 57 |
Ian H. Witten |
| 58 |
Robert Sedgewick |
| 59 |
Jon L. Bentley |
| 60 |
|
| 61 |
For more information on these sources, see the manual. |
| 62 |
--*/ |
| 63 |
|
| 64 |
|
| 65 |
#ifndef _BZLIB_H |
| 66 |
#define _BZLIB_H |
| 67 |
|
| 68 |
#ifdef __cplusplus |
| 69 |
extern "C" { |
| 70 |
#endif |
| 71 |
|
| 72 |
#define BZ_RUN 0 |
| 73 |
#define BZ_FLUSH 1 |
| 74 |
#define BZ_FINISH 2 |
| 75 |
|
| 76 |
#define BZ_OK 0 |
| 77 |
#define BZ_RUN_OK 1 |
| 78 |
#define BZ_FLUSH_OK 2 |
| 79 |
#define BZ_FINISH_OK 3 |
| 80 |
#define BZ_STREAM_END 4 |
| 81 |
#define BZ_SEQUENCE_ERROR (-1) |
| 82 |
#define BZ_PARAM_ERROR (-2) |
| 83 |
#define BZ_MEM_ERROR (-3) |
| 84 |
#define BZ_DATA_ERROR (-4) |
| 85 |
#define BZ_DATA_ERROR_MAGIC (-5) |
| 86 |
#define BZ_IO_ERROR (-6) |
| 87 |
#define BZ_UNEXPECTED_EOF (-7) |
| 88 |
#define BZ_OUTBUFF_FULL (-8) |
| 89 |
|
| 90 |
typedef |
| 91 |
struct { |
| 92 |
char *next_in; |
| 93 |
unsigned int avail_in; |
| 94 |
unsigned int total_in; |
| 95 |
|
| 96 |
char *next_out; |
| 97 |
unsigned int avail_out; |
| 98 |
unsigned int total_out; |
| 99 |
|
| 100 |
void *state; |
| 101 |
|
| 102 |
void *(*bzalloc)(void *,int,int); |
| 103 |
void (*bzfree)(void *,void *); |
| 104 |
void *opaque; |
| 105 |
} |
| 106 |
bz_stream; |
| 107 |
|
| 108 |
|
| 109 |
#ifndef BZ_IMPORT |
| 110 |
#define BZ_EXPORT |
| 111 |
#endif |
| 112 |
|
| 113 |
#ifdef _WIN32 |
| 114 |
# include <stdio.h> |
| 115 |
# include <windows.h> |
| 116 |
# ifdef small |
| 117 |
/* windows.h define small to char */ |
| 118 |
# undef small |
| 119 |
# endif |
| 120 |
# ifdef BZ_EXPORT |
| 121 |
# define BZ_API(func) WINAPI func |
| 122 |
# define BZ_EXTERN extern |
| 123 |
# else |
| 124 |
/* import windows dll dynamically */ |
| 125 |
# define BZ_API(func) (WINAPI * func) |
| 126 |
# define BZ_EXTERN |
| 127 |
# endif |
| 128 |
#else |
| 129 |
# define BZ_API(func) func |
| 130 |
# define BZ_EXTERN extern |
| 131 |
#endif |
| 132 |
|
| 133 |
|
| 134 |
/*-- Core (low-level) library functions --*/ |
| 135 |
|
| 136 |
BZ_EXTERN int BZ_API(bzCompressInit) ( |
| 137 |
bz_stream* strm, |
| 138 |
int blockSize100k, |
| 139 |
int verbosity, |
| 140 |
int workFactor |
| 141 |
); |
| 142 |
|
| 143 |
BZ_EXTERN int BZ_API(bzCompress) ( |
| 144 |
bz_stream* strm, |
| 145 |
int action |
| 146 |
); |
| 147 |
|
| 148 |
BZ_EXTERN int BZ_API(bzCompressEnd) ( |
| 149 |
bz_stream* strm |
| 150 |
); |
| 151 |
|
| 152 |
BZ_EXTERN int BZ_API(bzDecompressInit) ( |
| 153 |
bz_stream *strm, |
| 154 |
int verbosity, |
| 155 |
int small |
| 156 |
); |
| 157 |
|
| 158 |
BZ_EXTERN int BZ_API(bzDecompress) ( |
| 159 |
bz_stream* strm |
| 160 |
); |
| 161 |
|
| 162 |
BZ_EXTERN int BZ_API(bzDecompressEnd) ( |
| 163 |
bz_stream *strm |
| 164 |
); |
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
/*-- High(er) level library functions --*/ |
| 169 |
|
| 170 |
#ifndef BZ_NO_STDIO |
| 171 |
#define BZ_MAX_UNUSED 5000 |
| 172 |
|
| 173 |
typedef void BZFILE; |
| 174 |
|
| 175 |
BZ_EXTERN BZFILE* BZ_API(bzReadOpen) ( |
| 176 |
int* bzerror, |
| 177 |
FILE* f, |
| 178 |
int verbosity, |
| 179 |
int small, |
| 180 |
void* unused, |
| 181 |
int nUnused |
| 182 |
); |
| 183 |
|
| 184 |
BZ_EXTERN void BZ_API(bzReadClose) ( |
| 185 |
int* bzerror, |
| 186 |
BZFILE* b |
| 187 |
); |
| 188 |
|
| 189 |
BZ_EXTERN void BZ_API(bzReadGetUnused) ( |
| 190 |
int* bzerror, |
| 191 |
BZFILE* b, |
| 192 |
void** unused, |
| 193 |
int* nUnused |
| 194 |
); |
| 195 |
|
| 196 |
BZ_EXTERN int BZ_API(bzRead) ( |
| 197 |
int* bzerror, |
| 198 |
BZFILE* b, |
| 199 |
void* buf, |
| 200 |
int len |
| 201 |
); |
| 202 |
|
| 203 |
BZ_EXTERN BZFILE* BZ_API(bzWriteOpen) ( |
| 204 |
int* bzerror, |
| 205 |
FILE* f, |
| 206 |
int blockSize100k, |
| 207 |
int verbosity, |
| 208 |
int workFactor |
| 209 |
); |
| 210 |
|
| 211 |
BZ_EXTERN void BZ_API(bzWrite) ( |
| 212 |
int* bzerror, |
| 213 |
BZFILE* b, |
| 214 |
void* buf, |
| 215 |
int len |
| 216 |
); |
| 217 |
|
| 218 |
BZ_EXTERN void BZ_API(bzWriteClose) ( |
| 219 |
int* bzerror, |
| 220 |
BZFILE* b, |
| 221 |
int abandon, |
| 222 |
unsigned int* nbytes_in, |
| 223 |
unsigned int* nbytes_out |
| 224 |
); |
| 225 |
#endif |
| 226 |
|
| 227 |
|
| 228 |
/*-- Utility functions --*/ |
| 229 |
|
| 230 |
BZ_EXTERN int BZ_API(bzBuffToBuffCompress) ( |
| 231 |
char* dest, |
| 232 |
unsigned int* destLen, |
| 233 |
char* source, |
| 234 |
unsigned int sourceLen, |
| 235 |
int blockSize100k, |
| 236 |
int verbosity, |
| 237 |
int workFactor |
| 238 |
); |
| 239 |
|
| 240 |
BZ_EXTERN int BZ_API(bzBuffToBuffDecompress) ( |
| 241 |
char* dest, |
| 242 |
unsigned int* destLen, |
| 243 |
char* source, |
| 244 |
unsigned int sourceLen, |
| 245 |
int small, |
| 246 |
int verbosity |
| 247 |
); |
| 248 |
|
| 249 |
|
| 250 |
/*-- |
| 251 |
Code contributed by Yoshioka Tsuneo |
| 252 |
([email protected]/[email protected]), |
| 253 |
to support better zlib compatibility. |
| 254 |
This code is not _officially_ part of libbzip2 (yet); |
| 255 |
I haven't tested it, documented it, or considered the |
| 256 |
threading-safeness of it. |
| 257 |
If this code breaks, please contact both Yoshioka and me. |
| 258 |
--*/ |
| 259 |
|
| 260 |
BZ_EXTERN const char * BZ_API(bzlibVersion) ( |
| 261 |
void |
| 262 |
); |
| 263 |
|
| 264 |
#ifndef BZ_NO_STDIO |
| 265 |
BZ_EXTERN BZFILE * BZ_API(bzopen) ( |
| 266 |
const char *path, |
| 267 |
const char *mode |
| 268 |
); |
| 269 |
|
| 270 |
BZ_EXTERN BZFILE * BZ_API(bzdopen) ( |
| 271 |
int fd, |
| 272 |
const char *mode |
| 273 |
); |
| 274 |
|
| 275 |
BZ_EXTERN int BZ_API(bzread) ( |
| 276 |
BZFILE* b, |
| 277 |
void* buf, |
| 278 |
int len |
| 279 |
); |
| 280 |
|
| 281 |
BZ_EXTERN int BZ_API(bzwrite) ( |
| 282 |
BZFILE* b, |
| 283 |
void* buf, |
| 284 |
int len |
| 285 |
); |
| 286 |
|
| 287 |
BZ_EXTERN int BZ_API(bzflush) ( |
| 288 |
BZFILE* b |
| 289 |
); |
| 290 |
|
| 291 |
BZ_EXTERN void BZ_API(bzclose) ( |
| 292 |
BZFILE* b |
| 293 |
); |
| 294 |
|
| 295 |
BZ_EXTERN const char * BZ_API(bzerror) ( |
| 296 |
BZFILE *b, |
| 297 |
int *errnum |
| 298 |
); |
| 299 |
#endif |
| 300 |
|
| 301 |
#ifdef __cplusplus |
| 302 |
} |
| 303 |
#endif |
| 304 |
|
| 305 |
#endif |
| 306 |
|
| 307 |
/*-------------------------------------------------------------*/ |
| 308 |
/*--- end bzlib.h ---*/ |
| 309 |
/*-------------------------------------------------------------*/ |