123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
/* Converted to D from bzlib.h by htod */

module tango.util.compress.c.bzlib;

/*-------------------------------------------------------------*/
/*--- Public header file for the library.                   ---*/
/*---                                               bzlib.h ---*/
/*-------------------------------------------------------------*/

/* ------------------------------------------------------------------
   This file is part of bzip2/libbzip2, a program and library for
   lossless, block-sorting data compression.

   bzip2/libbzip2 version 1.0.4 of 20 December 2006
   Copyright (C) 1996-2006 Julian Seward <jseward@bzip.org>

   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.
   ------------------------------------------------------------------ */

extern(C):

enum BZ_RUN = 0;
enum BZ_FLUSH = 1;
enum BZ_FINISH = 2;

enum BZ_OK = 0;
enum BZ_RUN_OK = 1;
enum BZ_FLUSH_OK = 2;
enum BZ_FINISH_OK = 3;
enum BZ_STREAM_END = 4;
enum BZ_SEQUENCE_ERROR = -1;
enum BZ_PARAM_ERROR = -2;
enum BZ_MEM_ERROR = -3;
enum BZ_DATA_ERROR = -4;
enum BZ_DATA_ERROR_MAGIC = -5;
enum BZ_IO_ERROR = -6;
enum BZ_UNEXPECTED_EOF = -7;
enum BZ_OUTBUFF_FULL = -8;
enum BZ_CONFIG_ERROR = -9;

struct bz_stream
{
    ubyte *next_in;
    uint avail_in;
    uint total_in_lo32;
    uint total_in_hi32;
    ubyte *next_out;
    uint avail_out;
    uint total_out_lo32;
    uint total_out_hi32;
    void *state;
    void * function(void *, int , int )bzalloc;
    void  function(void *, void *)bzfree;
    void *opaque;
}

import tango.stdc.stdio : FILE;

/*-- Core (low-level) library functions --*/

//C     BZ_EXTERN int BZ_API(BZ2_bzCompressInit) ( 
//C           bz_stream* strm, 
//C           int        blockSize100k, 
//C           int        verbosity, 
//C           int        workFactor 
//C        );
extern (System):
int  BZ2_bzCompressInit(bz_stream *strm, int blockSize100k, int verbosity, int workFactor);

//C     BZ_EXTERN int BZ_API(BZ2_bzCompress) ( 
//C           bz_stream* strm, 
//C           int action 
//C        );
int  BZ2_bzCompress(bz_stream *strm, int action);

//C     BZ_EXTERN int BZ_API(BZ2_bzCompressEnd) ( 
//C           bz_stream* strm 
//C        );
int  BZ2_bzCompressEnd(bz_stream *strm);

//C     BZ_EXTERN int BZ_API(BZ2_bzDecompressInit) ( 
//C           bz_stream *strm, 
//C           int       verbosity, 
//C           int       small
//C        );
int  BZ2_bzDecompressInit(bz_stream *strm, int verbosity, int small);

//C     BZ_EXTERN int BZ_API(BZ2_bzDecompress) ( 
//C           bz_stream* strm 
//C        );
int  BZ2_bzDecompress(bz_stream *strm);

//C     BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) ( 
//C           bz_stream *strm 
//C        );
int  BZ2_bzDecompressEnd(bz_stream *strm);



/*-- High(er) level library functions --*/

version(BZ_NO_STDIO){}else{

enum BZ_MAX_UNUSED = 5000;
alias void BZFILE;

//C     BZ_EXTERN BZFILE* BZ_API(BZ2_bzReadOpen) ( 
//C           int*  bzerror,   
//C           FILE* f, 
//C           int   verbosity, 
//C           int   small,
//C           void* unused,    
//C           int   nUnused 
//C        );
extern (System):
BZFILE * BZ2_bzReadOpen(int *bzerror, FILE *f, int verbosity, int small, void *unused, int nUnused);

//C     BZ_EXTERN void BZ_API(BZ2_bzReadClose) ( 
//C           int*    bzerror, 
//C           BZFILE* b 
//C        );
void  BZ2_bzReadClose(int *bzerror, BZFILE *b);

//C     BZ_EXTERN void BZ_API(BZ2_bzReadGetUnused) ( 
//C           int*    bzerror, 
//C           BZFILE* b, 
//C           void**  unused,  
//C           int*    nUnused 
//C        );
void  BZ2_bzReadGetUnused(int *bzerror, BZFILE *b, void **unused, int *nUnused);

//C     BZ_EXTERN int BZ_API(BZ2_bzRead) ( 
//C           int*    bzerror, 
//C           BZFILE* b, 
//C           void*   buf, 
//C           int     len 
//C        );
int  BZ2_bzRead(int *bzerror, BZFILE *b, void *buf, int len);

//C     BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) ( 
//C           int*  bzerror,      
//C           FILE* f, 
//C           int   blockSize100k, 
//C           int   verbosity, 
//C           int   workFactor 
//C        );
BZFILE * BZ2_bzWriteOpen(int *bzerror, FILE *f, int blockSize100k, int verbosity, int workFactor);

//C     BZ_EXTERN void BZ_API(BZ2_bzWrite) ( 
//C           int*    bzerror, 
//C           BZFILE* b, 
//C           void*   buf, 
//C           int     len 
//C        );
void  BZ2_bzWrite(int *bzerror, BZFILE *b, void *buf, int len);

//C     BZ_EXTERN void BZ_API(BZ2_bzWriteClose) ( 
//C           int*          bzerror, 
//C           BZFILE*       b, 
//C           int           abandon, 
//C           unsigned int* nbytes_in, 
//C           unsigned int* nbytes_out 
//C        );
void  BZ2_bzWriteClose(int *bzerror, BZFILE *b, int abandon, uint *nbytes_in, uint *nbytes_out);

//C     BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) ( 
//C           int*          bzerror, 
//C           BZFILE*       b, 
//C           int           abandon, 
//C           unsigned int* nbytes_in_lo32, 
//C           unsigned int* nbytes_in_hi32, 
//C           unsigned int* nbytes_out_lo32, 
//C           unsigned int* nbytes_out_hi32
//C        );
void  BZ2_bzWriteClose64(int *bzerror, BZFILE *b, int abandon, uint *nbytes_in_lo32, uint *nbytes_in_hi32, uint *nbytes_out_lo32, uint *nbytes_out_hi32);

}

/*-- Utility functions --*/

//C     BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) ( 
//C           char*         dest, 
//C           unsigned int* destLen,
//C           char*         source, 
//C           unsigned int  sourceLen,
//C           int           blockSize100k, 
//C           int           verbosity, 
//C           int           workFactor 
//C        );
int  BZ2_bzBuffToBuffCompress(char *dest, uint *destLen, char *source, uint sourceLen, int blockSize100k, int verbosity, int workFactor);

//C     BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) ( 
//C           char*         dest, 
//C           unsigned int* destLen,
//C           char*         source, 
//C           unsigned int  sourceLen,
//C           int           small, 
//C           int           verbosity 
//C        );
int  BZ2_bzBuffToBuffDecompress(char *dest, uint *destLen, char *source, uint sourceLen, int small, int verbosity);


/*--
   Code contributed by Yoshioka Tsuneo (tsuneo@rr.iij4u.or.jp)
   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.
--*/

//C     BZ_EXTERN const char * BZ_API(BZ2_bzlibVersion) (
//C           void
//C        );
const(char) * BZ2_bzlibVersion();

version(BZ_NO_STDIO){}else{

//C     BZ_EXTERN BZFILE * BZ_API(BZ2_bzopen) (
//C           const char *path,
//C           const char *mode
//C        );
BZFILE * BZ2_bzopen(in char *path, in char *mode);

//C     BZ_EXTERN BZFILE * BZ_API(BZ2_bzdopen) (
//C           int        fd,
//C           const char *mode
//C        );
BZFILE * BZ2_bzdopen(int fd, in char *mode);
         
//C     BZ_EXTERN int BZ_API(BZ2_bzread) (
//C           BZFILE* b, 
//C           void* buf, 
//C           int len 
//C        );
int  BZ2_bzread(BZFILE *b, void *buf, int len);

//C     BZ_EXTERN int BZ_API(BZ2_bzwrite) (
//C           BZFILE* b, 
//C           void*   buf, 
//C           int     len 
//C        );
int  BZ2_bzwrite(BZFILE *b, void *buf, int len);

//C     BZ_EXTERN int BZ_API(BZ2_bzflush) (
//C           BZFILE* b
//C        );
int  BZ2_bzflush(BZFILE *b);

//C     BZ_EXTERN void BZ_API(BZ2_bzclose) (
//C           BZFILE* b
//C        );
void  BZ2_bzclose(BZFILE *b);

//C     BZ_EXTERN const char * BZ_API(BZ2_bzerror) (
//C           BZFILE *b, 
//C           int    *errnum
//C        );
const(char) * BZ2_bzerror(BZFILE *b, int *errnum);

}

/*-------------------------------------------------------------*/
/*--- end                                           bzlib.h ---*/
/*-------------------------------------------------------------*/