|
| 1 | + |
| 2 | +/*-------------------------------------------------------------*/ |
| 3 | +/*--- Public header file for the library. ---*/ |
| 4 | +/*--- bzlib.h ---*/ |
| 5 | +/*-------------------------------------------------------------*/ |
| 6 | + |
| 7 | +/* ------------------------------------------------------------------ |
| 8 | + This file is part of bzip2/libbzip2, a program and library for |
| 9 | + lossless, block-sorting data compression. |
| 10 | +
|
| 11 | + bzip2/libbzip2 version 1.0.8 of 13 July 2019 |
| 12 | + Copyright (C) 1996-2019 Julian Seward <[email protected]> |
| 13 | +
|
| 14 | + Please read the WARNING, DISCLAIMER and PATENTS sections in the |
| 15 | + README file. |
| 16 | +
|
| 17 | + This program is released under the terms of the license contained |
| 18 | + in the file LICENSE. |
| 19 | + ------------------------------------------------------------------ */ |
| 20 | + |
| 21 | + |
| 22 | +#ifndef _BZLIB_H |
| 23 | +#define _BZLIB_H |
| 24 | + |
| 25 | +#ifdef __cplusplus |
| 26 | +extern "C" { |
| 27 | +#endif |
| 28 | + |
| 29 | +#define BZ_RUN 0 |
| 30 | +#define BZ_FLUSH 1 |
| 31 | +#define BZ_FINISH 2 |
| 32 | + |
| 33 | +#define BZ_OK 0 |
| 34 | +#define BZ_RUN_OK 1 |
| 35 | +#define BZ_FLUSH_OK 2 |
| 36 | +#define BZ_FINISH_OK 3 |
| 37 | +#define BZ_STREAM_END 4 |
| 38 | +#define BZ_SEQUENCE_ERROR (-1) |
| 39 | +#define BZ_PARAM_ERROR (-2) |
| 40 | +#define BZ_MEM_ERROR (-3) |
| 41 | +#define BZ_DATA_ERROR (-4) |
| 42 | +#define BZ_DATA_ERROR_MAGIC (-5) |
| 43 | +#define BZ_IO_ERROR (-6) |
| 44 | +#define BZ_UNEXPECTED_EOF (-7) |
| 45 | +#define BZ_OUTBUFF_FULL (-8) |
| 46 | +#define BZ_CONFIG_ERROR (-9) |
| 47 | + |
| 48 | +typedef |
| 49 | + struct { |
| 50 | + char *next_in; |
| 51 | + unsigned int avail_in; |
| 52 | + unsigned int total_in_lo32; |
| 53 | + unsigned int total_in_hi32; |
| 54 | + |
| 55 | + char *next_out; |
| 56 | + unsigned int avail_out; |
| 57 | + unsigned int total_out_lo32; |
| 58 | + unsigned int total_out_hi32; |
| 59 | + |
| 60 | + void *state; |
| 61 | + |
| 62 | + void *(*bzalloc)(void *,int,int); |
| 63 | + void (*bzfree)(void *,void *); |
| 64 | + void *opaque; |
| 65 | + } |
| 66 | + bz_stream; |
| 67 | + |
| 68 | + |
| 69 | +#ifndef BZ_IMPORT |
| 70 | +#define BZ_EXPORT |
| 71 | +#endif |
| 72 | + |
| 73 | +#ifndef BZ_NO_STDIO |
| 74 | +/* Need a definitition for FILE */ |
| 75 | +#include <stdio.h> |
| 76 | +#endif |
| 77 | + |
| 78 | +#if defined(_WIN32) && !defined(__CYGWIN__) |
| 79 | +# include <windows.h> |
| 80 | +# ifdef small |
| 81 | + /* windows.h define small to char */ |
| 82 | +# undef small |
| 83 | +# endif |
| 84 | +# ifndef __GNUC__ |
| 85 | + /* Use these rules only for non-gcc native win32 */ |
| 86 | +# ifdef BZ_EXPORT |
| 87 | +# define BZ_API(func) WINAPI func |
| 88 | +# define BZ_EXTERN extern |
| 89 | +# else |
| 90 | + /* import windows dll dynamically */ |
| 91 | +# define BZ_API(func) (WINAPI * func) |
| 92 | +# define BZ_EXTERN |
| 93 | +# endif |
| 94 | +# else |
| 95 | + /* For gcc on native win32, use import library trampoline */ |
| 96 | + /* functions on DLL import. This avoids requiring clients to */ |
| 97 | + /* use special compilation flags depending on whether eventual */ |
| 98 | + /* link will be against static libbz2 or against DLL, at the */ |
| 99 | + /* expense of a small loss of efficiency. */ |
| 100 | + |
| 101 | + /* Because libbz2 does not export any DATA items, GNU ld's */ |
| 102 | + /* "auto-import" is not a factor; the MinGW-built DLL can be */ |
| 103 | + /* used by other compilers, provided an import library suitable */ |
| 104 | + /* for that compiler is (manually) constructed using the .def */ |
| 105 | + /* file and the appropriate tool. */ |
| 106 | +# define BZ_API(func) func |
| 107 | +# define BZ_EXTERN extern |
| 108 | +# endif |
| 109 | +#else |
| 110 | + /* non-win32 platforms, and cygwin */ |
| 111 | +# define BZ_API(func) func |
| 112 | +# define BZ_EXTERN extern |
| 113 | +#endif |
| 114 | + |
| 115 | + |
| 116 | +/*-- Core (low-level) library functions --*/ |
| 117 | + |
| 118 | +BZ_EXTERN int BZ_API(BZ2_bzCompressInit) ( |
| 119 | + bz_stream* strm, |
| 120 | + int blockSize100k, |
| 121 | + int verbosity, |
| 122 | + int workFactor |
| 123 | + ); |
| 124 | + |
| 125 | +BZ_EXTERN int BZ_API(BZ2_bzCompress) ( |
| 126 | + bz_stream* strm, |
| 127 | + int action |
| 128 | + ); |
| 129 | + |
| 130 | +BZ_EXTERN int BZ_API(BZ2_bzCompressEnd) ( |
| 131 | + bz_stream* strm |
| 132 | + ); |
| 133 | + |
| 134 | +BZ_EXTERN int BZ_API(BZ2_bzDecompressInit) ( |
| 135 | + bz_stream *strm, |
| 136 | + int verbosity, |
| 137 | + int small |
| 138 | + ); |
| 139 | + |
| 140 | +BZ_EXTERN int BZ_API(BZ2_bzDecompress) ( |
| 141 | + bz_stream* strm |
| 142 | + ); |
| 143 | + |
| 144 | +BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) ( |
| 145 | + bz_stream *strm |
| 146 | + ); |
| 147 | + |
| 148 | + |
| 149 | + |
| 150 | +/*-- High(er) level library functions --*/ |
| 151 | + |
| 152 | +#ifndef BZ_NO_STDIO |
| 153 | +#define BZ_MAX_UNUSED 5000 |
| 154 | + |
| 155 | +typedef void BZFILE; |
| 156 | + |
| 157 | +BZ_EXTERN BZFILE* BZ_API(BZ2_bzReadOpen) ( |
| 158 | + int* bzerror, |
| 159 | + FILE* f, |
| 160 | + int verbosity, |
| 161 | + int small, |
| 162 | + void* unused, |
| 163 | + int nUnused |
| 164 | + ); |
| 165 | + |
| 166 | +BZ_EXTERN void BZ_API(BZ2_bzReadClose) ( |
| 167 | + int* bzerror, |
| 168 | + BZFILE* b |
| 169 | + ); |
| 170 | + |
| 171 | +BZ_EXTERN void BZ_API(BZ2_bzReadGetUnused) ( |
| 172 | + int* bzerror, |
| 173 | + BZFILE* b, |
| 174 | + void** unused, |
| 175 | + int* nUnused |
| 176 | + ); |
| 177 | + |
| 178 | +BZ_EXTERN int BZ_API(BZ2_bzRead) ( |
| 179 | + int* bzerror, |
| 180 | + BZFILE* b, |
| 181 | + void* buf, |
| 182 | + int len |
| 183 | + ); |
| 184 | + |
| 185 | +BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) ( |
| 186 | + int* bzerror, |
| 187 | + FILE* f, |
| 188 | + int blockSize100k, |
| 189 | + int verbosity, |
| 190 | + int workFactor |
| 191 | + ); |
| 192 | + |
| 193 | +BZ_EXTERN void BZ_API(BZ2_bzWrite) ( |
| 194 | + int* bzerror, |
| 195 | + BZFILE* b, |
| 196 | + void* buf, |
| 197 | + int len |
| 198 | + ); |
| 199 | + |
| 200 | +BZ_EXTERN void BZ_API(BZ2_bzWriteClose) ( |
| 201 | + int* bzerror, |
| 202 | + BZFILE* b, |
| 203 | + int abandon, |
| 204 | + unsigned int* nbytes_in, |
| 205 | + unsigned int* nbytes_out |
| 206 | + ); |
| 207 | + |
| 208 | +BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) ( |
| 209 | + int* bzerror, |
| 210 | + BZFILE* b, |
| 211 | + int abandon, |
| 212 | + unsigned int* nbytes_in_lo32, |
| 213 | + unsigned int* nbytes_in_hi32, |
| 214 | + unsigned int* nbytes_out_lo32, |
| 215 | + unsigned int* nbytes_out_hi32 |
| 216 | + ); |
| 217 | +#endif |
| 218 | + |
| 219 | + |
| 220 | +/*-- Utility functions --*/ |
| 221 | + |
| 222 | +BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) ( |
| 223 | + char* dest, |
| 224 | + unsigned int* destLen, |
| 225 | + char* source, |
| 226 | + unsigned int sourceLen, |
| 227 | + int blockSize100k, |
| 228 | + int verbosity, |
| 229 | + int workFactor |
| 230 | + ); |
| 231 | + |
| 232 | +BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) ( |
| 233 | + char* dest, |
| 234 | + unsigned int* destLen, |
| 235 | + char* source, |
| 236 | + unsigned int sourceLen, |
| 237 | + int small, |
| 238 | + int verbosity |
| 239 | + ); |
| 240 | + |
| 241 | + |
| 242 | +/*-- |
| 243 | + Code contributed by Yoshioka Tsuneo ([email protected]) |
| 244 | + to support better zlib compatibility. |
| 245 | + This code is not _officially_ part of libbzip2 (yet); |
| 246 | + I haven't tested it, documented it, or considered the |
| 247 | + threading-safeness of it. |
| 248 | + If this code breaks, please contact both Yoshioka and me. |
| 249 | +--*/ |
| 250 | + |
| 251 | +BZ_EXTERN const char * BZ_API(BZ2_bzlibVersion) ( |
| 252 | + void |
| 253 | + ); |
| 254 | + |
| 255 | +#ifndef BZ_NO_STDIO |
| 256 | +BZ_EXTERN BZFILE * BZ_API(BZ2_bzopen) ( |
| 257 | + const char *path, |
| 258 | + const char *mode |
| 259 | + ); |
| 260 | + |
| 261 | +BZ_EXTERN BZFILE * BZ_API(BZ2_bzdopen) ( |
| 262 | + int fd, |
| 263 | + const char *mode |
| 264 | + ); |
| 265 | + |
| 266 | +BZ_EXTERN int BZ_API(BZ2_bzread) ( |
| 267 | + BZFILE* b, |
| 268 | + void* buf, |
| 269 | + int len |
| 270 | + ); |
| 271 | + |
| 272 | +BZ_EXTERN int BZ_API(BZ2_bzwrite) ( |
| 273 | + BZFILE* b, |
| 274 | + void* buf, |
| 275 | + int len |
| 276 | + ); |
| 277 | + |
| 278 | +BZ_EXTERN int BZ_API(BZ2_bzflush) ( |
| 279 | + BZFILE* b |
| 280 | + ); |
| 281 | + |
| 282 | +BZ_EXTERN void BZ_API(BZ2_bzclose) ( |
| 283 | + BZFILE* b |
| 284 | + ); |
| 285 | + |
| 286 | +BZ_EXTERN const char * BZ_API(BZ2_bzerror) ( |
| 287 | + BZFILE *b, |
| 288 | + int *errnum |
| 289 | + ); |
| 290 | +#endif |
| 291 | + |
| 292 | +#ifdef __cplusplus |
| 293 | +} |
| 294 | +#endif |
| 295 | + |
| 296 | +#endif |
| 297 | + |
| 298 | +/*-------------------------------------------------------------*/ |
| 299 | +/*--- end bzlib.h ---*/ |
| 300 | +/*-------------------------------------------------------------*/ |
0 commit comments