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