Back to index

avfs  1.0.1
bzlib.h
Go to the documentation of this file.
00001 /* IMPORTANT NOTE: This is not the original bzip2 distribution.
00002 
00003    The modifications are copyright (C) 2001 Miklos Szeredi
00004    <miklos@szeredi.hu>
00005 
00006    The modified software can be distributed under the same licence as
00007    the original software (see bellow).
00008 */
00009 
00010 /*-------------------------------------------------------------*/
00011 /*--- Public header file for the library.                   ---*/
00012 /*---                                               bzlib.h ---*/
00013 /*-------------------------------------------------------------*/
00014 
00015 /* ------------------------------------------------------------------
00016    This file is part of bzip2/libbzip2, a program and library for
00017    lossless, block-sorting data compression.
00018 
00019    bzip2/libbzip2 version 1.0.6 of 6 September 2010
00020    Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org>
00021 
00022    Please read the WARNING, DISCLAIMER and PATENTS sections in the 
00023    README file.
00024 
00025    This program is released under the terms of the license contained
00026    in the file LICENSE.
00027    ------------------------------------------------------------------ */
00028 
00029 
00030 #ifndef _BZLIB_H
00031 #define _BZLIB_H
00032 
00033 #include "bzconf.h"
00034 
00035 #ifdef __cplusplus
00036 extern "C" {
00037 #endif
00038 
00039 #define BZ_RUN               0
00040 #define BZ_FLUSH             1
00041 #define BZ_FINISH            2
00042 
00043 #define BZ_OK                0
00044 #define BZ_RUN_OK            1
00045 #define BZ_FLUSH_OK          2
00046 #define BZ_FINISH_OK         3
00047 #define BZ_STREAM_END        4
00048 #define BZ_SEQUENCE_ERROR    (-1)
00049 #define BZ_PARAM_ERROR       (-2)
00050 #define BZ_MEM_ERROR         (-3)
00051 #define BZ_DATA_ERROR        (-4)
00052 #define BZ_DATA_ERROR_MAGIC  (-5)
00053 #define BZ_IO_ERROR          (-6)
00054 #define BZ_UNEXPECTED_EOF    (-7)
00055 #define BZ_OUTBUFF_FULL      (-8)
00056 #define BZ_CONFIG_ERROR      (-9)
00057 
00058 typedef 
00059    struct {
00060       char *next_in;
00061       unsigned int avail_in;
00062       unsigned int total_in_lo32;
00063       unsigned int total_in_hi32;
00064 
00065       char *next_out;
00066       unsigned int avail_out;
00067       unsigned int total_out_lo32;
00068       unsigned int total_out_hi32;
00069 
00070       void *state;
00071 
00072       void *(*bzalloc)(void *,int,int);
00073       void (*bzfree)(void *,void *);
00074       void *opaque;
00075    } 
00076    bz_stream;
00077 
00078 
00079 #ifndef BZ_IMPORT
00080 #define BZ_EXPORT
00081 #endif
00082 
00083 #ifndef BZ_NO_STDIO
00084 /* Need a definitition for FILE */
00085 #include <stdio.h>
00086 #endif
00087 
00088 #ifdef _WIN32
00089 #   include <windows.h>
00090 #   ifdef small
00091       /* windows.h define small to char */
00092 #      undef small
00093 #   endif
00094 #   ifdef BZ_EXPORT
00095 #   define BZ_API(func) WINAPI func
00096 #   define BZ_EXTERN extern
00097 #   else
00098    /* import windows dll dynamically */
00099 #   define BZ_API(func) (WINAPI * func)
00100 #   define BZ_EXTERN
00101 #   endif
00102 #else
00103 #   define BZ_API(func) func
00104 #   define BZ_EXTERN extern
00105 #endif
00106 
00107 
00108 /*-- Core (low-level) library functions --*/
00109 
00110 BZ_EXTERN int BZ_API(BZ2_bzCompressInit) ( 
00111       bz_stream* strm, 
00112       int        blockSize100k, 
00113       int        verbosity, 
00114       int        workFactor 
00115    );
00116 
00117 BZ_EXTERN int BZ_API(BZ2_bzCompress) ( 
00118       bz_stream* strm, 
00119       int action 
00120    );
00121 
00122 BZ_EXTERN int BZ_API(BZ2_bzCompressEnd) ( 
00123       bz_stream* strm 
00124    );
00125 
00126 BZ_EXTERN int BZ_API(BZ2_bzDecompressInit) ( 
00127       bz_stream *strm, 
00128       int       verbosity, 
00129       int       small
00130    );
00131 
00132 BZ_EXTERN int BZ_API(BZ2_bzDecompress) ( 
00133       bz_stream* strm 
00134    );
00135 
00136 BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) ( 
00137       bz_stream *strm 
00138    );
00139 
00140 BZ_EXTERN void BZ_API(BZ2_bzSetBlockEndHandler) (
00141       bz_stream *strm,
00142       void (*func) (void *data, bz_stream *strm, unsigned int bitsrem,
00143                     unsigned int bits, unsigned int crc,
00144                     unsigned int blocksize),
00145       void *data
00146    );
00147 
00148 BZ_EXTERN void BZ_API(BZ2_bzRestoreBlockEnd) (
00149       bz_stream *strm,
00150       unsigned int bitsrem,
00151       unsigned int crc
00152    );
00153 
00154 /*-- High(er) level library functions --*/
00155 
00156 #ifndef BZ_NO_STDIO
00157 #define BZ_MAX_UNUSED 5000
00158 
00159 typedef void BZFILE;
00160 
00161 BZ_EXTERN BZFILE* BZ_API(BZ2_bzReadOpen) ( 
00162       int*  bzerror,   
00163       FILE* f, 
00164       int   verbosity, 
00165       int   small,
00166       void* unused,    
00167       int   nUnused 
00168    );
00169 
00170 BZ_EXTERN void BZ_API(BZ2_bzReadClose) ( 
00171       int*    bzerror, 
00172       BZFILE* b 
00173    );
00174 
00175 BZ_EXTERN void BZ_API(BZ2_bzReadGetUnused) ( 
00176       int*    bzerror, 
00177       BZFILE* b, 
00178       void**  unused,  
00179       int*    nUnused 
00180    );
00181 
00182 BZ_EXTERN int BZ_API(BZ2_bzRead) ( 
00183       int*    bzerror, 
00184       BZFILE* b, 
00185       void*   buf, 
00186       int     len 
00187    );
00188 
00189 BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) ( 
00190       int*  bzerror,      
00191       FILE* f, 
00192       int   blockSize100k, 
00193       int   verbosity, 
00194       int   workFactor 
00195    );
00196 
00197 BZ_EXTERN void BZ_API(BZ2_bzWrite) ( 
00198       int*    bzerror, 
00199       BZFILE* b, 
00200       void*   buf, 
00201       int     len 
00202    );
00203 
00204 BZ_EXTERN void BZ_API(BZ2_bzWriteClose) ( 
00205       int*          bzerror, 
00206       BZFILE*       b, 
00207       int           abandon, 
00208       unsigned int* nbytes_in, 
00209       unsigned int* nbytes_out 
00210    );
00211 
00212 BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) ( 
00213       int*          bzerror, 
00214       BZFILE*       b, 
00215       int           abandon, 
00216       unsigned int* nbytes_in_lo32, 
00217       unsigned int* nbytes_in_hi32, 
00218       unsigned int* nbytes_out_lo32, 
00219       unsigned int* nbytes_out_hi32
00220    );
00221 #endif
00222 
00223 
00224 /*-- Utility functions --*/
00225 
00226 BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) ( 
00227       char*         dest, 
00228       unsigned int* destLen,
00229       char*         source, 
00230       unsigned int  sourceLen,
00231       int           blockSize100k, 
00232       int           verbosity, 
00233       int           workFactor 
00234    );
00235 
00236 BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) ( 
00237       char*         dest, 
00238       unsigned int* destLen,
00239       char*         source, 
00240       unsigned int  sourceLen,
00241       int           small, 
00242       int           verbosity 
00243    );
00244 
00245 
00246 /*--
00247    Code contributed by Yoshioka Tsuneo (tsuneo@rr.iij4u.or.jp)
00248    to support better zlib compatibility.
00249    This code is not _officially_ part of libbzip2 (yet);
00250    I haven't tested it, documented it, or considered the
00251    threading-safeness of it.
00252    If this code breaks, please contact both Yoshioka and me.
00253 --*/
00254 
00255 BZ_EXTERN const char * BZ_API(BZ2_bzlibVersion) (
00256       void
00257    );
00258 
00259 #ifndef BZ_NO_STDIO
00260 BZ_EXTERN BZFILE * BZ_API(BZ2_bzopen) (
00261       const char *path,
00262       const char *mode
00263    );
00264 
00265 BZ_EXTERN BZFILE * BZ_API(BZ2_bzdopen) (
00266       int        fd,
00267       const char *mode
00268    );
00269          
00270 BZ_EXTERN int BZ_API(BZ2_bzread) (
00271       BZFILE* b, 
00272       void* buf, 
00273       int len 
00274    );
00275 
00276 BZ_EXTERN int BZ_API(BZ2_bzwrite) (
00277       BZFILE* b, 
00278       void*   buf, 
00279       int     len 
00280    );
00281 
00282 BZ_EXTERN int BZ_API(BZ2_bzflush) (
00283       BZFILE* b
00284    );
00285 
00286 BZ_EXTERN void BZ_API(BZ2_bzclose) (
00287       BZFILE* b
00288    );
00289 
00290 BZ_EXTERN const char * BZ_API(BZ2_bzerror) (
00291       BZFILE *b, 
00292       int    *errnum
00293    );
00294 #endif
00295 
00296 #ifdef __cplusplus
00297 }
00298 #endif
00299 
00300 #endif
00301 
00302 /*-------------------------------------------------------------*/
00303 /*--- end                                           bzlib.h ---*/
00304 /*-------------------------------------------------------------*/