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