bzip2/bzlib.h

285 lines
6.1 KiB
C
Raw Normal View History

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