Back to index

lightning-sunbird  0.9+nobinonly
bzlib.h
Go to the documentation of this file.
00001 
00002 /*-------------------------------------------------------------*/
00003 /*--- Public header file for the library.                   ---*/
00004 /*---                                               bzlib.h ---*/
00005 /*-------------------------------------------------------------*/
00006 
00007 /*--
00008   This file is a part of bzip2 and/or libbzip2, a program and
00009   library for lossless, block-sorting data compression.
00010 
00011   Copyright (C) 1996-2005 Julian R Seward.  All rights reserved.
00012 
00013   Redistribution and use in source and binary forms, with or without
00014   modification, are permitted provided that the following conditions
00015   are met:
00016 
00017   1. Redistributions of source code must retain the above copyright
00018      notice, this list of conditions and the following disclaimer.
00019 
00020   2. The origin of this software must not be misrepresented; you must 
00021      not claim that you wrote the original software.  If you use this 
00022      software in a product, an acknowledgment in the product 
00023      documentation would be appreciated but is not required.
00024 
00025   3. Altered source versions must be plainly marked as such, and must
00026      not be misrepresented as being the original software.
00027 
00028   4. The name of the author may not be used to endorse or promote 
00029      products derived from this software without specific prior written 
00030      permission.
00031 
00032   THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
00033   OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00034   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00035   ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
00036   DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00037   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
00038   GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00039   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
00040   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00041   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00042   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00043 
00044   Julian Seward, Cambridge, UK.
00045   jseward@bzip.org
00046   bzip2/libbzip2 version 1.0 of 21 March 2000
00047 
00048   This program is based on (at least) the work of:
00049      Mike Burrows
00050      David Wheeler
00051      Peter Fenwick
00052      Alistair Moffat
00053      Radford Neal
00054      Ian H. Witten
00055      Robert Sedgewick
00056      Jon L. Bentley
00057 
00058   For more information on these sources, see the manual.
00059 --*/
00060 
00061 
00062 #ifndef _BZLIB_H
00063 #define _BZLIB_H
00064 
00065 #ifdef __cplusplus
00066 extern "C" {
00067 #endif
00068 
00069 #define BZ_RUN               0
00070 #define BZ_FLUSH             1
00071 #define BZ_FINISH            2
00072 
00073 #define BZ_OK                0
00074 #define BZ_RUN_OK            1
00075 #define BZ_FLUSH_OK          2
00076 #define BZ_FINISH_OK         3
00077 #define BZ_STREAM_END        4
00078 #define BZ_SEQUENCE_ERROR    (-1)
00079 #define BZ_PARAM_ERROR       (-2)
00080 #define BZ_MEM_ERROR         (-3)
00081 #define BZ_DATA_ERROR        (-4)
00082 #define BZ_DATA_ERROR_MAGIC  (-5)
00083 #define BZ_IO_ERROR          (-6)
00084 #define BZ_UNEXPECTED_EOF    (-7)
00085 #define BZ_OUTBUFF_FULL      (-8)
00086 #define BZ_CONFIG_ERROR      (-9)
00087 
00088 typedef 
00089    struct {
00090       char *next_in;
00091       unsigned int avail_in;
00092       unsigned int total_in_lo32;
00093       unsigned int total_in_hi32;
00094 
00095       char *next_out;
00096       unsigned int avail_out;
00097       unsigned int total_out_lo32;
00098       unsigned int total_out_hi32;
00099 
00100       void *state;
00101 
00102       void *(*bzalloc)(void *,int,int);
00103       void (*bzfree)(void *,void *);
00104       void *opaque;
00105    } 
00106    bz_stream;
00107 
00108 
00109 #ifndef BZ_IMPORT
00110 #define BZ_EXPORT
00111 #endif
00112 
00113 #ifndef BZ_NO_STDIO
00114 /* Need a definitition for FILE */
00115 #include <stdio.h>
00116 #endif
00117 
00118 #ifdef _WIN32
00119 #   include <windows.h>
00120 #   ifdef small
00121       /* windows.h define small to char */
00122 #      undef small
00123 #   endif
00124 #   ifdef BZ_EXPORT
00125 #   define BZ_API(func) WINAPI func
00126 #   define BZ_EXTERN extern
00127 #   else
00128    /* import windows dll dynamically */
00129 #   define BZ_API(func) (WINAPI * func)
00130 #   define BZ_EXTERN
00131 #   endif
00132 #else
00133 #   define BZ_API(func) func
00134 #   define BZ_EXTERN extern
00135 #endif
00136 
00137 
00138 /*-- Core (low-level) library functions --*/
00139 
00140 BZ_EXTERN int BZ_API(BZ2_bzCompressInit) ( 
00141       bz_stream* strm, 
00142       int        blockSize100k, 
00143       int        verbosity, 
00144       int        workFactor 
00145    );
00146 
00147 BZ_EXTERN int BZ_API(BZ2_bzCompress) ( 
00148       bz_stream* strm, 
00149       int action 
00150    );
00151 
00152 BZ_EXTERN int BZ_API(BZ2_bzCompressEnd) ( 
00153       bz_stream* strm 
00154    );
00155 
00156 BZ_EXTERN int BZ_API(BZ2_bzDecompressInit) ( 
00157       bz_stream *strm, 
00158       int       verbosity, 
00159       int       small
00160    );
00161 
00162 BZ_EXTERN int BZ_API(BZ2_bzDecompress) ( 
00163       bz_stream* strm 
00164    );
00165 
00166 BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) ( 
00167       bz_stream *strm 
00168    );
00169 
00170 
00171 
00172 /*-- High(er) level library functions --*/
00173 
00174 #ifndef BZ_NO_STDIO
00175 #define BZ_MAX_UNUSED 5000
00176 
00177 typedef void BZFILE;
00178 
00179 BZ_EXTERN BZFILE* BZ_API(BZ2_bzReadOpen) ( 
00180       int*  bzerror,   
00181       FILE* f, 
00182       int   verbosity, 
00183       int   small,
00184       void* unused,    
00185       int   nUnused 
00186    );
00187 
00188 BZ_EXTERN void BZ_API(BZ2_bzReadClose) ( 
00189       int*    bzerror, 
00190       BZFILE* b 
00191    );
00192 
00193 BZ_EXTERN void BZ_API(BZ2_bzReadGetUnused) ( 
00194       int*    bzerror, 
00195       BZFILE* b, 
00196       void**  unused,  
00197       int*    nUnused 
00198    );
00199 
00200 BZ_EXTERN int BZ_API(BZ2_bzRead) ( 
00201       int*    bzerror, 
00202       BZFILE* b, 
00203       void*   buf, 
00204       int     len 
00205    );
00206 
00207 BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) ( 
00208       int*  bzerror,      
00209       FILE* f, 
00210       int   blockSize100k, 
00211       int   verbosity, 
00212       int   workFactor 
00213    );
00214 
00215 BZ_EXTERN void BZ_API(BZ2_bzWrite) ( 
00216       int*    bzerror, 
00217       BZFILE* b, 
00218       void*   buf, 
00219       int     len 
00220    );
00221 
00222 BZ_EXTERN void BZ_API(BZ2_bzWriteClose) ( 
00223       int*          bzerror, 
00224       BZFILE*       b, 
00225       int           abandon, 
00226       unsigned int* nbytes_in, 
00227       unsigned int* nbytes_out 
00228    );
00229 
00230 BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) ( 
00231       int*          bzerror, 
00232       BZFILE*       b, 
00233       int           abandon, 
00234       unsigned int* nbytes_in_lo32, 
00235       unsigned int* nbytes_in_hi32, 
00236       unsigned int* nbytes_out_lo32, 
00237       unsigned int* nbytes_out_hi32
00238    );
00239 #endif
00240 
00241 
00242 /*-- Utility functions --*/
00243 
00244 BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) ( 
00245       char*         dest, 
00246       unsigned int* destLen,
00247       char*         source, 
00248       unsigned int  sourceLen,
00249       int           blockSize100k, 
00250       int           verbosity, 
00251       int           workFactor 
00252    );
00253 
00254 BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) ( 
00255       char*         dest, 
00256       unsigned int* destLen,
00257       char*         source, 
00258       unsigned int  sourceLen,
00259       int           small, 
00260       int           verbosity 
00261    );
00262 
00263 
00264 /*--
00265    Code contributed by Yoshioka Tsuneo
00266    (QWF00133@niftyserve.or.jp/tsuneo-y@is.aist-nara.ac.jp),
00267    to support better zlib compatibility.
00268    This code is not _officially_ part of libbzip2 (yet);
00269    I haven't tested it, documented it, or considered the
00270    threading-safeness of it.
00271    If this code breaks, please contact both Yoshioka and me.
00272 --*/
00273 
00274 BZ_EXTERN const char * BZ_API(BZ2_bzlibVersion) (
00275       void
00276    );
00277 
00278 #ifndef BZ_NO_STDIO
00279 BZ_EXTERN BZFILE * BZ_API(BZ2_bzopen) (
00280       const char *path,
00281       const char *mode
00282    );
00283 
00284 BZ_EXTERN BZFILE * BZ_API(BZ2_bzdopen) (
00285       int        fd,
00286       const char *mode
00287    );
00288          
00289 BZ_EXTERN int BZ_API(BZ2_bzread) (
00290       BZFILE* b, 
00291       void* buf, 
00292       int len 
00293    );
00294 
00295 BZ_EXTERN int BZ_API(BZ2_bzwrite) (
00296       BZFILE* b, 
00297       void*   buf, 
00298       int     len 
00299    );
00300 
00301 BZ_EXTERN int BZ_API(BZ2_bzflush) (
00302       BZFILE* b
00303    );
00304 
00305 BZ_EXTERN void BZ_API(BZ2_bzclose) (
00306       BZFILE* b
00307    );
00308 
00309 BZ_EXTERN const char * BZ_API(BZ2_bzerror) (
00310       BZFILE *b, 
00311       int    *errnum
00312    );
00313 #endif
00314 
00315 #ifdef __cplusplus
00316 }
00317 #endif
00318 
00319 #endif
00320 
00321 /*-------------------------------------------------------------*/
00322 /*--- end                                           bzlib.h ---*/
00323 /*-------------------------------------------------------------*/