michael@0: michael@0: /*-------------------------------------------------------------*/ michael@0: /*--- Public header file for the library. ---*/ michael@0: /*--- bzlib.h ---*/ michael@0: /*-------------------------------------------------------------*/ michael@0: michael@0: /* ------------------------------------------------------------------ michael@0: This file is part of bzip2/libbzip2, a program and library for michael@0: lossless, block-sorting data compression. michael@0: michael@0: bzip2/libbzip2 version 1.0.4 of 20 December 2006 michael@0: Copyright (C) 1996-2006 Julian Seward michael@0: michael@0: Please read the WARNING, DISCLAIMER and PATENTS sections in the michael@0: README file. michael@0: michael@0: This program is released under the terms of the license contained michael@0: in the file LICENSE. michael@0: ------------------------------------------------------------------ */ michael@0: michael@0: michael@0: #ifndef _BZLIB_H michael@0: #define _BZLIB_H michael@0: michael@0: #ifdef __cplusplus michael@0: extern "C" { michael@0: #endif michael@0: michael@0: #define BZ_RUN 0 michael@0: #define BZ_FLUSH 1 michael@0: #define BZ_FINISH 2 michael@0: michael@0: #define BZ_OK 0 michael@0: #define BZ_RUN_OK 1 michael@0: #define BZ_FLUSH_OK 2 michael@0: #define BZ_FINISH_OK 3 michael@0: #define BZ_STREAM_END 4 michael@0: #define BZ_SEQUENCE_ERROR (-1) michael@0: #define BZ_PARAM_ERROR (-2) michael@0: #define BZ_MEM_ERROR (-3) michael@0: #define BZ_DATA_ERROR (-4) michael@0: #define BZ_DATA_ERROR_MAGIC (-5) michael@0: #define BZ_IO_ERROR (-6) michael@0: #define BZ_UNEXPECTED_EOF (-7) michael@0: #define BZ_OUTBUFF_FULL (-8) michael@0: #define BZ_CONFIG_ERROR (-9) michael@0: michael@0: typedef michael@0: struct { michael@0: char *next_in; michael@0: unsigned int avail_in; michael@0: unsigned int total_in_lo32; michael@0: unsigned int total_in_hi32; michael@0: michael@0: char *next_out; michael@0: unsigned int avail_out; michael@0: unsigned int total_out_lo32; michael@0: unsigned int total_out_hi32; michael@0: michael@0: void *state; michael@0: michael@0: void *(*bzalloc)(void *,int,int); michael@0: void (*bzfree)(void *,void *); michael@0: void *opaque; michael@0: } michael@0: bz_stream; michael@0: michael@0: michael@0: #ifndef BZ_IMPORT michael@0: #define BZ_EXPORT michael@0: #endif michael@0: michael@0: #ifndef BZ_NO_STDIO michael@0: /* Need a definitition for FILE */ michael@0: #include michael@0: #endif michael@0: michael@0: #ifdef _WIN32 michael@0: # include michael@0: # ifdef small michael@0: /* windows.h define small to char */ michael@0: # undef small michael@0: # endif michael@0: # ifdef BZ_EXPORT michael@0: # define BZ_API(func) WINAPI func michael@0: # define BZ_EXTERN extern michael@0: # else michael@0: /* import windows dll dynamically */ michael@0: # define BZ_API(func) (WINAPI * func) michael@0: # define BZ_EXTERN michael@0: # endif michael@0: #else michael@0: # define BZ_API(func) func michael@0: # define BZ_EXTERN extern michael@0: #endif michael@0: michael@0: michael@0: /*-- Core (low-level) library functions --*/ michael@0: michael@0: BZ_EXTERN int BZ_API(BZ2_bzCompressInit) ( michael@0: bz_stream* strm, michael@0: int blockSize100k, michael@0: int verbosity, michael@0: int workFactor michael@0: ); michael@0: michael@0: BZ_EXTERN int BZ_API(BZ2_bzCompress) ( michael@0: bz_stream* strm, michael@0: int action michael@0: ); michael@0: michael@0: BZ_EXTERN int BZ_API(BZ2_bzCompressEnd) ( michael@0: bz_stream* strm michael@0: ); michael@0: michael@0: BZ_EXTERN int BZ_API(BZ2_bzDecompressInit) ( michael@0: bz_stream *strm, michael@0: int verbosity, michael@0: int small michael@0: ); michael@0: michael@0: BZ_EXTERN int BZ_API(BZ2_bzDecompress) ( michael@0: bz_stream* strm michael@0: ); michael@0: michael@0: BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) ( michael@0: bz_stream *strm michael@0: ); michael@0: michael@0: michael@0: michael@0: /*-- High(er) level library functions --*/ michael@0: michael@0: #ifndef BZ_NO_STDIO michael@0: #define BZ_MAX_UNUSED 5000 michael@0: michael@0: typedef void BZFILE; michael@0: michael@0: BZ_EXTERN BZFILE* BZ_API(BZ2_bzReadOpen) ( michael@0: int* bzerror, michael@0: FILE* f, michael@0: int verbosity, michael@0: int small, michael@0: void* unused, michael@0: int nUnused michael@0: ); michael@0: michael@0: BZ_EXTERN void BZ_API(BZ2_bzReadClose) ( michael@0: int* bzerror, michael@0: BZFILE* b michael@0: ); michael@0: michael@0: BZ_EXTERN void BZ_API(BZ2_bzReadGetUnused) ( michael@0: int* bzerror, michael@0: BZFILE* b, michael@0: void** unused, michael@0: int* nUnused michael@0: ); michael@0: michael@0: BZ_EXTERN int BZ_API(BZ2_bzRead) ( michael@0: int* bzerror, michael@0: BZFILE* b, michael@0: void* buf, michael@0: int len michael@0: ); michael@0: michael@0: BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) ( michael@0: int* bzerror, michael@0: FILE* f, michael@0: int blockSize100k, michael@0: int verbosity, michael@0: int workFactor michael@0: ); michael@0: michael@0: BZ_EXTERN void BZ_API(BZ2_bzWrite) ( michael@0: int* bzerror, michael@0: BZFILE* b, michael@0: void* buf, michael@0: int len michael@0: ); michael@0: michael@0: BZ_EXTERN void BZ_API(BZ2_bzWriteClose) ( michael@0: int* bzerror, michael@0: BZFILE* b, michael@0: int abandon, michael@0: unsigned int* nbytes_in, michael@0: unsigned int* nbytes_out michael@0: ); michael@0: michael@0: BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) ( michael@0: int* bzerror, michael@0: BZFILE* b, michael@0: int abandon, michael@0: unsigned int* nbytes_in_lo32, michael@0: unsigned int* nbytes_in_hi32, michael@0: unsigned int* nbytes_out_lo32, michael@0: unsigned int* nbytes_out_hi32 michael@0: ); michael@0: #endif michael@0: michael@0: michael@0: /*-- Utility functions --*/ michael@0: michael@0: BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) ( michael@0: char* dest, michael@0: unsigned int* destLen, michael@0: char* source, michael@0: unsigned int sourceLen, michael@0: int blockSize100k, michael@0: int verbosity, michael@0: int workFactor michael@0: ); michael@0: michael@0: BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) ( michael@0: char* dest, michael@0: unsigned int* destLen, michael@0: char* source, michael@0: unsigned int sourceLen, michael@0: int small, michael@0: int verbosity michael@0: ); michael@0: michael@0: michael@0: /*-- michael@0: Code contributed by Yoshioka Tsuneo (tsuneo@rr.iij4u.or.jp) michael@0: to support better zlib compatibility. michael@0: This code is not _officially_ part of libbzip2 (yet); michael@0: I haven't tested it, documented it, or considered the michael@0: threading-safeness of it. michael@0: If this code breaks, please contact both Yoshioka and me. michael@0: --*/ michael@0: michael@0: BZ_EXTERN const char * BZ_API(BZ2_bzlibVersion) ( michael@0: void michael@0: ); michael@0: michael@0: #ifndef BZ_NO_STDIO michael@0: BZ_EXTERN BZFILE * BZ_API(BZ2_bzopen) ( michael@0: const char *path, michael@0: const char *mode michael@0: ); michael@0: michael@0: BZ_EXTERN BZFILE * BZ_API(BZ2_bzdopen) ( michael@0: int fd, michael@0: const char *mode michael@0: ); michael@0: michael@0: BZ_EXTERN int BZ_API(BZ2_bzread) ( michael@0: BZFILE* b, michael@0: void* buf, michael@0: int len michael@0: ); michael@0: michael@0: BZ_EXTERN int BZ_API(BZ2_bzwrite) ( michael@0: BZFILE* b, michael@0: void* buf, michael@0: int len michael@0: ); michael@0: michael@0: BZ_EXTERN int BZ_API(BZ2_bzflush) ( michael@0: BZFILE* b michael@0: ); michael@0: michael@0: BZ_EXTERN void BZ_API(BZ2_bzclose) ( michael@0: BZFILE* b michael@0: ); michael@0: michael@0: BZ_EXTERN const char * BZ_API(BZ2_bzerror) ( michael@0: BZFILE *b, michael@0: int *errnum michael@0: ); michael@0: #endif michael@0: michael@0: #ifdef __cplusplus michael@0: } michael@0: #endif michael@0: michael@0: #endif michael@0: michael@0: /*-------------------------------------------------------------*/ michael@0: /*--- end bzlib.h ---*/ michael@0: /*-------------------------------------------------------------*/