#pragma prototyped1/*-------------------------------------------------------------*/2/*--- Public header file for the library. ---*/3/*--- bzlib.h ---*/4/*-------------------------------------------------------------*/56/*--7This file is a part of bzip2 and/or libbzip2, a program and8library for lossless, block-sorting data compression.910Copyright (C) 1996-1998 Julian R Seward. All rights reserved.1112Redistribution and use in source and binary forms, with or without13modification, are permitted provided that the following conditions14are met:15161. Redistributions of source code must retain the above copyright17notice, this list of conditions and the following disclaimer.18192. The origin of this software must not be misrepresented; you must20not claim that you wrote the original software. If you use this21software in a product, an acknowledgment in the product22documentation would be appreciated but is not required.23243. Altered source versions must be plainly marked as such, and must25not be misrepresented as being the original software.26274. The name of the author may not be used to endorse or promote28products derived from this software without specific prior written29permission.3031THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS32OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED33WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE34ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY35DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL36DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE37GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS38INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,39WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING40NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS41SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.4243Julian Seward, Guildford, Surrey, UK.44[email protected]45bzip2/libbzip2 version 0.9.0c of 18 October 19984647This program is based on (at least) the work of:48Mike Burrows49David Wheeler50Peter Fenwick51Alistair Moffat52Radford Neal53Ian H. Witten54Robert Sedgewick55Jon L. Bentley5657For more information on these sources, see the manual.58--*/596061#ifndef _BZLIB_H62#define _BZLIB_H6364#define BZ_RUN 065#define BZ_FLUSH 166#define BZ_FINISH 26768#define BZ_OK 069#define BZ_RUN_OK 170#define BZ_FLUSH_OK 271#define BZ_FINISH_OK 372#define BZ_STREAM_END 473#define BZ_SEQUENCE_ERROR (-1)74#define BZ_PARAM_ERROR (-2)75#define BZ_MEM_ERROR (-3)76#define BZ_DATA_ERROR (-4)77#define BZ_DATA_ERROR_MAGIC (-5)78#define BZ_IO_ERROR (-6)79#define BZ_UNEXPECTED_EOF (-7)80#define BZ_OUTBUFF_FULL (-8)8182typedef83struct {84char *next_in;85unsigned int avail_in;86unsigned int total_in;8788char *next_out;89unsigned int avail_out;90unsigned int total_out;9192void *state;9394void *(*bzalloc)(void *,int,int);95void (*bzfree)(void *,void *);96void *opaque;97}98bz_stream;99100101#if _PACKAGE_ast102#include <ast_std.h>103#else104#if !defined(_WINIX) && (_UWIN || __CYGWIN__ || __EMX__)105#define _WINIX 1106#endif107#endif108109/*---------------------------------------------*/110/*--111Generic 32-bit Unix.112Also works on 64-bit Unix boxes.113--*/114#if !_WIN32 || _WINIX115#define BZ_UNIX 1116#endif117118/*--119Win32, as seen by Jacob Navia's excellent120port of (Chris Fraser & David Hanson)'s excellent121lcc compiler.122--*/123#if _WIN32 && !_WINIX124#define BZ_LCCWIN32 1125#define BZ_UNIX 0126#else127#define BZ_LCCWIN32 0128#endif129130#include <stdio.h>131132#if _BLD_bz133134#if defined(__EXPORT__)135# define BZ_API(func) func136# define BZ_EXTERN __EXPORT__137#else138# define BZ_API(func) func139# define BZ_EXTERN extern140#endif141142#else143144#if _WIN32 && !_WINIX145# include <windows.h>146# ifdef small147/* windows.h define small to char */148# undef small149# endif150# ifdef BZ_EXPORT151# define BZ_API(func) WINAPI func152# define BZ_EXTERN extern153# else154/* import windows dll dynamically */155# define BZ_API(func) (WINAPI * func)156# define BZ_EXTERN157# endif158#else159# define BZ_API(func) func160# define BZ_EXTERN extern161#endif162163#endif164165166/*-- Core (low-level) library functions --*/167168BZ_EXTERN int BZ_API(bzCompressInit) (169bz_stream* strm,170int blockSize100k,171int verbosity,172int workFactor173);174175BZ_EXTERN int BZ_API(bzCompress) (176bz_stream* strm,177int action178);179180BZ_EXTERN int BZ_API(bzCompressEnd) (181bz_stream* strm182);183184BZ_EXTERN int BZ_API(bzDecompressInit) (185bz_stream *strm,186int verbosity,187int small188);189190BZ_EXTERN int BZ_API(bzDecompress) (191bz_stream* strm192);193194BZ_EXTERN int BZ_API(bzDecompressEnd) (195bz_stream *strm196);197198199200/*-- High(er) level library functions --*/201202#ifndef BZ_NO_STDIO203#define BZ_MAX_UNUSED 5000204205typedef void BZFILE;206207typedef BZFILE Bz_t;208209BZ_EXTERN BZFILE* BZ_API(bzReadOpen) (210int* bzerror,211FILE* f,212int verbosity,213int small,214void* unused,215int nUnused216);217218BZ_EXTERN void BZ_API(bzReadClose) (219int* bzerror,220BZFILE* b221);222223BZ_EXTERN void BZ_API(bzReadGetUnused) (224int* bzerror,225BZFILE* b,226void* vUnused,227int* nUnused228);229230BZ_EXTERN int BZ_API(bzRead) (231int* bzerror,232BZFILE* b,233void* buf,234int len235);236237BZ_EXTERN BZFILE* BZ_API(bzWriteOpen) (238int* bzerror,239FILE* f,240int blockSize100k,241int verbosity,242int workFactor243);244245BZ_EXTERN void BZ_API(bzWrite) (246int* bzerror,247BZFILE* b,248void* buf,249int len250);251252BZ_EXTERN void BZ_API(bzWriteClose) (253int* bzerror,254BZFILE* b,255int abandon,256unsigned int* nbytes_in,257unsigned int* nbytes_out258);259#endif260261262/*-- Utility functions --*/263264BZ_EXTERN int BZ_API(bzBuffToBuffCompress) (265char* dest,266unsigned int* destLen,267char* source,268unsigned int sourceLen,269int blockSize100k,270int verbosity,271int workFactor272);273274BZ_EXTERN int BZ_API(bzBuffToBuffDecompress) (275char* dest,276unsigned int* destLen,277char* source,278unsigned int sourceLen,279int small,280int verbosity281);282283284/*--285Code contributed by Yoshioka Tsuneo286([email protected]/[email protected]),287to support better zlib compatibility.288This code is not _officially_ part of libbzip2 (yet);289I haven't tested it, documented it, or considered the290threading-safeness of it.291If this code breaks, please contact both Yoshioka and me.292--*/293294BZ_EXTERN const char * BZ_API(bzlibVersion) (295void296);297298#ifndef BZ_NO_STDIO299BZ_EXTERN BZFILE * BZ_API(bzopen) (300const char *path,301const char *mode302);303304BZ_EXTERN BZFILE * BZ_API(bzfopen) (305FILE *fp,306const char *mode307);308309BZ_EXTERN BZFILE * BZ_API(bzdopen) (310int fd,311const char *mode312);313314BZ_EXTERN BZFILE * BZ_API(bzbopen) (315int fd,316const char* mode,317const void* buf,318unsigned int len319);320321BZ_EXTERN int BZ_API(bzread) (322BZFILE* b,323void* buf,324int len325);326327BZ_EXTERN int BZ_API(bzwrite) (328BZFILE* b,329const void* buf,330int len331);332333BZ_EXTERN int BZ_API(bzflush) (334BZFILE* b335);336337BZ_EXTERN int BZ_API(bzclose) (338BZFILE* b339);340341BZ_EXTERN const char * BZ_API(bzerror) (342BZFILE *b,343int *errnum344);345#endif346347348#endif349350/*-------------------------------------------------------------*/351/*--- end bzlib.h ---*/352/*-------------------------------------------------------------*/353354355