bzip2 [ Home | Documentation | Downloads ]
3.6. zlib compatibility functions

3.6. zlib compatibility functions

Yoshioka Tsuneo has contributed some functions to give better zlib compatibility. These functions are BZ2_bzopen, BZ2_bzread, BZ2_bzwrite, BZ2_bzflush, BZ2_bzclose, BZ2_bzerror and BZ2_bzlibVersion. These functions are not (yet) officially part of the library. If they break, you get to keep all the pieces. Nevertheless, I think they work ok.

typedef void BZFILE;

const char * BZ2_bzlibVersion ( void );

Returns a string indicating the library version.

BZFILE * BZ2_bzopen  ( const char *path, const char *mode );
BZFILE * BZ2_bzdopen ( int        fd,    const char *mode );

Opens a .bz2 file for reading or writing, using either its name or a pre-existing file descriptor. Analogous to fopen and fdopen.

int BZ2_bzread  ( BZFILE* b, void* buf, int len );
int BZ2_bzwrite ( BZFILE* b, void* buf, int len );

Reads/writes data from/to a previously opened BZFILE. Analogous to fread and fwrite.

int  BZ2_bzflush ( BZFILE* b );
void BZ2_bzclose ( BZFILE* b );

Flushes/closes a BZFILE. BZ2_bzflush doesn't actually do anything. Analogous to fflush and fclose.

const char * BZ2_bzerror ( BZFILE *b, int *errnum )

Returns a string describing the more recent error status of b, and also sets *errnum to its numerical value.


Copyright © 1996 - 2010  julian@bzip.org