1 /* Converted to D from bzlib.h by htod */
2 
3 module tango.util.compress.c.bzlib;
4 
5 /*-------------------------------------------------------------*/
6 /*--- Public header file for the library.                   ---*/
7 /*---                                               bzlib.h ---*/
8 /*-------------------------------------------------------------*/
9 
10 /* ------------------------------------------------------------------
11    This file is part of bzip2/libbzip2, a program and library for
12    lossless, block-sorting data compression.
13 
14    bzip2/libbzip2 version 1.0.4 of 20 December 2006
15    Copyright (C) 1996-2006 Julian Seward <jseward@bzip.org>
16 
17    Please read the WARNING, DISCLAIMER and PATENTS sections in the 
18    README file.
19 
20    This program is released under the terms of the license contained
21    in the file LICENSE.
22    ------------------------------------------------------------------ */
23 
24 extern(C):
25 
26 enum BZ_RUN = 0;
27 enum BZ_FLUSH = 1;
28 enum BZ_FINISH = 2;
29 
30 enum BZ_OK = 0;
31 enum BZ_RUN_OK = 1;
32 enum BZ_FLUSH_OK = 2;
33 enum BZ_FINISH_OK = 3;
34 enum BZ_STREAM_END = 4;
35 enum BZ_SEQUENCE_ERROR = -1;
36 enum BZ_PARAM_ERROR = -2;
37 enum BZ_MEM_ERROR = -3;
38 enum BZ_DATA_ERROR = -4;
39 enum BZ_DATA_ERROR_MAGIC = -5;
40 enum BZ_IO_ERROR = -6;
41 enum BZ_UNEXPECTED_EOF = -7;
42 enum BZ_OUTBUFF_FULL = -8;
43 enum BZ_CONFIG_ERROR = -9;
44 
45 struct bz_stream
46 {
47     ubyte *next_in;
48     uint avail_in;
49     uint total_in_lo32;
50     uint total_in_hi32;
51     ubyte *next_out;
52     uint avail_out;
53     uint total_out_lo32;
54     uint total_out_hi32;
55     void *state;
56     void * function(void *, int , int )bzalloc;
57     void  function(void *, void *)bzfree;
58     void *opaque;
59 }
60 
61 import tango.stdc.stdio : FILE;
62 
63 /*-- Core (low-level) library functions --*/
64 
65 //C     BZ_EXTERN int BZ_API(BZ2_bzCompressInit) ( 
66 //C           bz_stream* strm, 
67 //C           int        blockSize100k, 
68 //C           int        verbosity, 
69 //C           int        workFactor 
70 //C        );
71 extern (System):
72 int  BZ2_bzCompressInit(bz_stream *strm, int blockSize100k, int verbosity, int workFactor);
73 
74 //C     BZ_EXTERN int BZ_API(BZ2_bzCompress) ( 
75 //C           bz_stream* strm, 
76 //C           int action 
77 //C        );
78 int  BZ2_bzCompress(bz_stream *strm, int action);
79 
80 //C     BZ_EXTERN int BZ_API(BZ2_bzCompressEnd) ( 
81 //C           bz_stream* strm 
82 //C        );
83 int  BZ2_bzCompressEnd(bz_stream *strm);
84 
85 //C     BZ_EXTERN int BZ_API(BZ2_bzDecompressInit) ( 
86 //C           bz_stream *strm, 
87 //C           int       verbosity, 
88 //C           int       small
89 //C        );
90 int  BZ2_bzDecompressInit(bz_stream *strm, int verbosity, int small);
91 
92 //C     BZ_EXTERN int BZ_API(BZ2_bzDecompress) ( 
93 //C           bz_stream* strm 
94 //C        );
95 int  BZ2_bzDecompress(bz_stream *strm);
96 
97 //C     BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) ( 
98 //C           bz_stream *strm 
99 //C        );
100 int  BZ2_bzDecompressEnd(bz_stream *strm);
101 
102 
103 
104 /*-- High(er) level library functions --*/
105 
106 version(BZ_NO_STDIO){}else{
107 
108 enum BZ_MAX_UNUSED = 5000;
109 alias void BZFILE;
110 
111 //C     BZ_EXTERN BZFILE* BZ_API(BZ2_bzReadOpen) ( 
112 //C           int*  bzerror,   
113 //C           FILE* f, 
114 //C           int   verbosity, 
115 //C           int   small,
116 //C           void* unused,    
117 //C           int   nUnused 
118 //C        );
119 extern (System):
120 BZFILE * BZ2_bzReadOpen(int *bzerror, FILE *f, int verbosity, int small, void *unused, int nUnused);
121 
122 //C     BZ_EXTERN void BZ_API(BZ2_bzReadClose) ( 
123 //C           int*    bzerror, 
124 //C           BZFILE* b 
125 //C        );
126 void  BZ2_bzReadClose(int *bzerror, BZFILE *b);
127 
128 //C     BZ_EXTERN void BZ_API(BZ2_bzReadGetUnused) ( 
129 //C           int*    bzerror, 
130 //C           BZFILE* b, 
131 //C           void**  unused,  
132 //C           int*    nUnused 
133 //C        );
134 void  BZ2_bzReadGetUnused(int *bzerror, BZFILE *b, void **unused, int *nUnused);
135 
136 //C     BZ_EXTERN int BZ_API(BZ2_bzRead) ( 
137 //C           int*    bzerror, 
138 //C           BZFILE* b, 
139 //C           void*   buf, 
140 //C           int     len 
141 //C        );
142 int  BZ2_bzRead(int *bzerror, BZFILE *b, void *buf, int len);
143 
144 //C     BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) ( 
145 //C           int*  bzerror,      
146 //C           FILE* f, 
147 //C           int   blockSize100k, 
148 //C           int   verbosity, 
149 //C           int   workFactor 
150 //C        );
151 BZFILE * BZ2_bzWriteOpen(int *bzerror, FILE *f, int blockSize100k, int verbosity, int workFactor);
152 
153 //C     BZ_EXTERN void BZ_API(BZ2_bzWrite) ( 
154 //C           int*    bzerror, 
155 //C           BZFILE* b, 
156 //C           void*   buf, 
157 //C           int     len 
158 //C        );
159 void  BZ2_bzWrite(int *bzerror, BZFILE *b, void *buf, int len);
160 
161 //C     BZ_EXTERN void BZ_API(BZ2_bzWriteClose) ( 
162 //C           int*          bzerror, 
163 //C           BZFILE*       b, 
164 //C           int           abandon, 
165 //C           unsigned int* nbytes_in, 
166 //C           unsigned int* nbytes_out 
167 //C        );
168 void  BZ2_bzWriteClose(int *bzerror, BZFILE *b, int abandon, uint *nbytes_in, uint *nbytes_out);
169 
170 //C     BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) ( 
171 //C           int*          bzerror, 
172 //C           BZFILE*       b, 
173 //C           int           abandon, 
174 //C           unsigned int* nbytes_in_lo32, 
175 //C           unsigned int* nbytes_in_hi32, 
176 //C           unsigned int* nbytes_out_lo32, 
177 //C           unsigned int* nbytes_out_hi32
178 //C        );
179 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);
180 
181 }
182 
183 /*-- Utility functions --*/
184 
185 //C     BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) ( 
186 //C           char*         dest, 
187 //C           unsigned int* destLen,
188 //C           char*         source, 
189 //C           unsigned int  sourceLen,
190 //C           int           blockSize100k, 
191 //C           int           verbosity, 
192 //C           int           workFactor 
193 //C        );
194 int  BZ2_bzBuffToBuffCompress(char *dest, uint *destLen, char *source, uint sourceLen, int blockSize100k, int verbosity, int workFactor);
195 
196 //C     BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) ( 
197 //C           char*         dest, 
198 //C           unsigned int* destLen,
199 //C           char*         source, 
200 //C           unsigned int  sourceLen,
201 //C           int           small, 
202 //C           int           verbosity 
203 //C        );
204 int  BZ2_bzBuffToBuffDecompress(char *dest, uint *destLen, char *source, uint sourceLen, int small, int verbosity);
205 
206 
207 /*--
208    Code contributed by Yoshioka Tsuneo (tsuneo@rr.iij4u.or.jp)
209    to support better zlib compatibility.
210    This code is not _officially_ part of libbzip2 (yet);
211    I haven't tested it, documented it, or considered the
212    threading-safeness of it.
213    If this code breaks, please contact both Yoshioka and me.
214 --*/
215 
216 //C     BZ_EXTERN const char * BZ_API(BZ2_bzlibVersion) (
217 //C           void
218 //C        );
219 const(char) * BZ2_bzlibVersion();
220 
221 version(BZ_NO_STDIO){}else{
222 
223 //C     BZ_EXTERN BZFILE * BZ_API(BZ2_bzopen) (
224 //C           const char *path,
225 //C           const char *mode
226 //C        );
227 BZFILE * BZ2_bzopen(in char *path, in char *mode);
228 
229 //C     BZ_EXTERN BZFILE * BZ_API(BZ2_bzdopen) (
230 //C           int        fd,
231 //C           const char *mode
232 //C        );
233 BZFILE * BZ2_bzdopen(int fd, in char *mode);
234          
235 //C     BZ_EXTERN int BZ_API(BZ2_bzread) (
236 //C           BZFILE* b, 
237 //C           void* buf, 
238 //C           int len 
239 //C        );
240 int  BZ2_bzread(BZFILE *b, void *buf, int len);
241 
242 //C     BZ_EXTERN int BZ_API(BZ2_bzwrite) (
243 //C           BZFILE* b, 
244 //C           void*   buf, 
245 //C           int     len 
246 //C        );
247 int  BZ2_bzwrite(BZFILE *b, void *buf, int len);
248 
249 //C     BZ_EXTERN int BZ_API(BZ2_bzflush) (
250 //C           BZFILE* b
251 //C        );
252 int  BZ2_bzflush(BZFILE *b);
253 
254 //C     BZ_EXTERN void BZ_API(BZ2_bzclose) (
255 //C           BZFILE* b
256 //C        );
257 void  BZ2_bzclose(BZFILE *b);
258 
259 //C     BZ_EXTERN const char * BZ_API(BZ2_bzerror) (
260 //C           BZFILE *b, 
261 //C           int    *errnum
262 //C        );
263 const(char) * BZ2_bzerror(BZFILE *b, int *errnum);
264 
265 }
266 
267 /*-------------------------------------------------------------*/
268 /*--- end                                           bzlib.h ---*/
269 /*-------------------------------------------------------------*/