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