| 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.4 of 20 December 2006
|
|---|
| 12 | Copyright (C) 1996-2006 Julian Seward <jseward@bzip.org>
|
|---|
| 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 __KLIBC__ /* This default definition of BZ_EXPORT is silly. */
|
|---|
| 70 | #ifndef BZ_IMPORT
|
|---|
| 71 | #define BZ_EXPORT
|
|---|
| 72 | #endif
|
|---|
| 73 | #endif
|
|---|
| 74 |
|
|---|
| 75 | #ifndef BZ_NO_STDIO
|
|---|
| 76 | /* Need a definitition for FILE */
|
|---|
| 77 | #include <stdio.h>
|
|---|
| 78 | #endif
|
|---|
| 79 |
|
|---|
| 80 | #ifdef _WIN32
|
|---|
| 81 | # include <windows.h>
|
|---|
| 82 | # ifdef small
|
|---|
| 83 | /* windows.h define small to char */
|
|---|
| 84 | # undef small
|
|---|
| 85 | # endif
|
|---|
| 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 | #elif defined (__KLIBC__)
|
|---|
| 95 | # ifdef BZ_EXPORT
|
|---|
| 96 | # define BZ_API(func) func
|
|---|
| 97 | # define BZ_EXTERN extern __declspec(dllexport)
|
|---|
| 98 | # else
|
|---|
| 99 | # define BZ_API(func) func
|
|---|
| 100 | # define BZ_EXTERN extern
|
|---|
| 101 | # endif
|
|---|
| 102 | #else
|
|---|
| 103 | # define BZ_API(func) func
|
|---|
| 104 | # define BZ_EXTERN extern
|
|---|
| 105 | #endif
|
|---|
| 106 |
|
|---|
| 107 |
|
|---|
| 108 | /*-- Core (low-level) library functions --*/
|
|---|
| 109 |
|
|---|
| 110 | BZ_EXTERN int BZ_API(BZ2_bzCompressInit) (
|
|---|
| 111 | bz_stream* strm,
|
|---|
| 112 | int blockSize100k,
|
|---|
| 113 | int verbosity,
|
|---|
| 114 | int workFactor
|
|---|
| 115 | );
|
|---|
| 116 |
|
|---|
| 117 | BZ_EXTERN int BZ_API(BZ2_bzCompress) (
|
|---|
| 118 | bz_stream* strm,
|
|---|
| 119 | int action
|
|---|
| 120 | );
|
|---|
| 121 |
|
|---|
| 122 | BZ_EXTERN int BZ_API(BZ2_bzCompressEnd) (
|
|---|
| 123 | bz_stream* strm
|
|---|
| 124 | );
|
|---|
| 125 |
|
|---|
| 126 | BZ_EXTERN int BZ_API(BZ2_bzDecompressInit) (
|
|---|
| 127 | bz_stream *strm,
|
|---|
| 128 | int verbosity,
|
|---|
| 129 | int small
|
|---|
| 130 | );
|
|---|
| 131 |
|
|---|
| 132 | BZ_EXTERN int BZ_API(BZ2_bzDecompress) (
|
|---|
| 133 | bz_stream* strm
|
|---|
| 134 | );
|
|---|
| 135 |
|
|---|
| 136 | BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) (
|
|---|
| 137 | bz_stream *strm
|
|---|
| 138 | );
|
|---|
| 139 |
|
|---|
| 140 |
|
|---|
| 141 |
|
|---|
| 142 | /*-- High(er) level library functions --*/
|
|---|
| 143 |
|
|---|
| 144 | #ifndef BZ_NO_STDIO
|
|---|
| 145 | #define BZ_MAX_UNUSED 5000
|
|---|
| 146 |
|
|---|
| 147 | typedef void BZFILE;
|
|---|
| 148 |
|
|---|
| 149 | BZ_EXTERN BZFILE* BZ_API(BZ2_bzReadOpen) (
|
|---|
| 150 | int* bzerror,
|
|---|
| 151 | FILE* f,
|
|---|
| 152 | int verbosity,
|
|---|
| 153 | int small,
|
|---|
| 154 | void* unused,
|
|---|
| 155 | int nUnused
|
|---|
| 156 | );
|
|---|
| 157 |
|
|---|
| 158 | BZ_EXTERN void BZ_API(BZ2_bzReadClose) (
|
|---|
| 159 | int* bzerror,
|
|---|
| 160 | BZFILE* b
|
|---|
| 161 | );
|
|---|
| 162 |
|
|---|
| 163 | BZ_EXTERN void BZ_API(BZ2_bzReadGetUnused) (
|
|---|
| 164 | int* bzerror,
|
|---|
| 165 | BZFILE* b,
|
|---|
| 166 | void** unused,
|
|---|
| 167 | int* nUnused
|
|---|
| 168 | );
|
|---|
| 169 |
|
|---|
| 170 | BZ_EXTERN int BZ_API(BZ2_bzRead) (
|
|---|
| 171 | int* bzerror,
|
|---|
| 172 | BZFILE* b,
|
|---|
| 173 | void* buf,
|
|---|
| 174 | int len
|
|---|
| 175 | );
|
|---|
| 176 |
|
|---|
| 177 | BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) (
|
|---|
| 178 | int* bzerror,
|
|---|
| 179 | FILE* f,
|
|---|
| 180 | int blockSize100k,
|
|---|
| 181 | int verbosity,
|
|---|
| 182 | int workFactor
|
|---|
| 183 | );
|
|---|
| 184 |
|
|---|
| 185 | BZ_EXTERN void BZ_API(BZ2_bzWrite) (
|
|---|
| 186 | int* bzerror,
|
|---|
| 187 | BZFILE* b,
|
|---|
| 188 | void* buf,
|
|---|
| 189 | int len
|
|---|
| 190 | );
|
|---|
| 191 |
|
|---|
| 192 | BZ_EXTERN void BZ_API(BZ2_bzWriteClose) (
|
|---|
| 193 | int* bzerror,
|
|---|
| 194 | BZFILE* b,
|
|---|
| 195 | int abandon,
|
|---|
| 196 | unsigned int* nbytes_in,
|
|---|
| 197 | unsigned int* nbytes_out
|
|---|
| 198 | );
|
|---|
| 199 |
|
|---|
| 200 | BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) (
|
|---|
| 201 | int* bzerror,
|
|---|
| 202 | BZFILE* b,
|
|---|
| 203 | int abandon,
|
|---|
| 204 | unsigned int* nbytes_in_lo32,
|
|---|
| 205 | unsigned int* nbytes_in_hi32,
|
|---|
| 206 | unsigned int* nbytes_out_lo32,
|
|---|
| 207 | unsigned int* nbytes_out_hi32
|
|---|
| 208 | );
|
|---|
| 209 | #endif
|
|---|
| 210 |
|
|---|
| 211 |
|
|---|
| 212 | /*-- Utility functions --*/
|
|---|
| 213 |
|
|---|
| 214 | BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) (
|
|---|
| 215 | char* dest,
|
|---|
| 216 | unsigned int* destLen,
|
|---|
| 217 | char* source,
|
|---|
| 218 | unsigned int sourceLen,
|
|---|
| 219 | int blockSize100k,
|
|---|
| 220 | int verbosity,
|
|---|
| 221 | int workFactor
|
|---|
| 222 | );
|
|---|
| 223 |
|
|---|
| 224 | BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) (
|
|---|
| 225 | char* dest,
|
|---|
| 226 | unsigned int* destLen,
|
|---|
| 227 | char* source,
|
|---|
| 228 | unsigned int sourceLen,
|
|---|
| 229 | int small,
|
|---|
| 230 | int verbosity
|
|---|
| 231 | );
|
|---|
| 232 |
|
|---|
| 233 |
|
|---|
| 234 | /*--
|
|---|
| 235 | Code contributed by Yoshioka Tsuneo (tsuneo@rr.iij4u.or.jp)
|
|---|
| 236 | to support better zlib compatibility.
|
|---|
| 237 | This code is not _officially_ part of libbzip2 (yet);
|
|---|
| 238 | I haven't tested it, documented it, or considered the
|
|---|
| 239 | threading-safeness of it.
|
|---|
| 240 | If this code breaks, please contact both Yoshioka and me.
|
|---|
| 241 | --*/
|
|---|
| 242 |
|
|---|
| 243 | BZ_EXTERN const char * BZ_API(BZ2_bzlibVersion) (
|
|---|
| 244 | void
|
|---|
| 245 | );
|
|---|
| 246 |
|
|---|
| 247 | #ifndef BZ_NO_STDIO
|
|---|
| 248 | BZ_EXTERN BZFILE * BZ_API(BZ2_bzopen) (
|
|---|
| 249 | const char *path,
|
|---|
| 250 | const char *mode
|
|---|
| 251 | );
|
|---|
| 252 |
|
|---|
| 253 | BZ_EXTERN BZFILE * BZ_API(BZ2_bzdopen) (
|
|---|
| 254 | int fd,
|
|---|
| 255 | const char *mode
|
|---|
| 256 | );
|
|---|
| 257 |
|
|---|
| 258 | BZ_EXTERN int BZ_API(BZ2_bzread) (
|
|---|
| 259 | BZFILE* b,
|
|---|
| 260 | void* buf,
|
|---|
| 261 | int len
|
|---|
| 262 | );
|
|---|
| 263 |
|
|---|
| 264 | BZ_EXTERN int BZ_API(BZ2_bzwrite) (
|
|---|
| 265 | BZFILE* b,
|
|---|
| 266 | void* buf,
|
|---|
| 267 | int len
|
|---|
| 268 | );
|
|---|
| 269 |
|
|---|
| 270 | BZ_EXTERN int BZ_API(BZ2_bzflush) (
|
|---|
| 271 | BZFILE* b
|
|---|
| 272 | );
|
|---|
| 273 |
|
|---|
| 274 | BZ_EXTERN void BZ_API(BZ2_bzclose) (
|
|---|
| 275 | BZFILE* b
|
|---|
| 276 | );
|
|---|
| 277 |
|
|---|
| 278 | BZ_EXTERN const char * BZ_API(BZ2_bzerror) (
|
|---|
| 279 | BZFILE *b,
|
|---|
| 280 | int *errnum
|
|---|
| 281 | );
|
|---|
| 282 | #endif
|
|---|
| 283 |
|
|---|
| 284 | #ifdef __cplusplus
|
|---|
| 285 | }
|
|---|
| 286 | #endif
|
|---|
| 287 |
|
|---|
| 288 | #endif
|
|---|
| 289 |
|
|---|
| 290 | /*-------------------------------------------------------------*/
|
|---|
| 291 | /*--- end bzlib.h ---*/
|
|---|
| 292 | /*-------------------------------------------------------------*/
|
|---|