29#include FT_CONFIG_STANDARD_LIBRARY_H
37#define FT_ERR_PREFIX Bzip2_Err_
38#define FT_ERR_BASE FT_Mod_Err_Bzip2
43#ifdef FT_CONFIG_OPTION_USE_BZIP2
60 typedef void *(* alloc_func)(
void*,
int,
int);
94#define FT_BZIP2_BUFFER_SIZE 4096
96 typedef struct FT_BZip2FileRec_
110 } FT_BZip2FileRec, *FT_BZip2File;
127 if (
head[0] != 0x42 ||
141 ft_bzip2_file_init( FT_BZip2File zip,
145 bz_stream* bzstream = &zip->bzstream;
151 zip->memory =
stream->memory;
153 zip->limit = zip->buffer + FT_BZIP2_BUFFER_SIZE;
154 zip->cursor = zip->limit;
170 bzstream->bzalloc = (
alloc_func)ft_bzip2_alloc;
171 bzstream->bzfree = (
free_func) ft_bzip2_free;
172 bzstream->opaque = zip->memory;
174 bzstream->avail_in = 0;
175 bzstream->next_in = (
char*)zip->buffer;
177 if ( BZ2_bzDecompressInit( bzstream, 0, 0 ) != BZ_OK ||
187 ft_bzip2_file_done( FT_BZip2File zip )
189 bz_stream* bzstream = &zip->bzstream;
192 BZ2_bzDecompressEnd( bzstream );
195 bzstream->bzalloc =
NULL;
196 bzstream->bzfree =
NULL;
197 bzstream->opaque =
NULL;
198 bzstream->next_in =
NULL;
199 bzstream->next_out =
NULL;
200 bzstream->avail_in = 0;
201 bzstream->avail_out = 0;
210 ft_bzip2_file_reset( FT_BZip2File zip )
218 bz_stream* bzstream = &zip->bzstream;
221 BZ2_bzDecompressEnd( bzstream );
223 bzstream->avail_in = 0;
224 bzstream->next_in = (
char*)zip->input;
225 bzstream->avail_out = 0;
226 bzstream->next_out = (
char*)zip->buffer;
228 zip->limit = zip->buffer + FT_BZIP2_BUFFER_SIZE;
229 zip->cursor = zip->limit;
232 BZ2_bzDecompressInit( bzstream, 0, 0 );
240 ft_bzip2_file_fill_input( FT_BZip2File zip )
242 bz_stream* bzstream = &zip->bzstream;
250 FT_BZIP2_BUFFER_SIZE );
253 zip->limit = zip->cursor;
254 return FT_THROW( Invalid_Stream_Operation );
260 if (
size > FT_BZIP2_BUFFER_SIZE )
261 size = FT_BZIP2_BUFFER_SIZE;
265 zip->limit = zip->cursor;
266 return FT_THROW( Invalid_Stream_Operation );
273 bzstream->next_in = (
char*)zip->input;
274 bzstream->avail_in =
size;
281 ft_bzip2_file_fill_output( FT_BZip2File zip )
283 bz_stream* bzstream = &zip->bzstream;
287 zip->cursor = zip->buffer;
288 bzstream->next_out = (
char*)zip->cursor;
289 bzstream->avail_out = FT_BZIP2_BUFFER_SIZE;
291 while ( bzstream->avail_out > 0 )
296 if ( bzstream->avail_in == 0 )
298 error = ft_bzip2_file_fill_input( zip );
303 err = BZ2_bzDecompress( bzstream );
305 if (
err == BZ_STREAM_END )
307 zip->limit = (
FT_Byte*)bzstream->next_out;
308 if ( zip->limit == zip->cursor )
312 else if (
err != BZ_OK )
314 zip->limit = zip->cursor;
326 ft_bzip2_file_skip_output( FT_BZip2File zip,
335 delta = (
FT_ULong)( zip->limit - zip->cursor );
336 if ( delta >=
count )
339 zip->cursor += delta;
346 error = ft_bzip2_file_fill_output( zip );
356 ft_bzip2_file_io( FT_BZip2File zip,
367 if ( pos < zip->
pos )
369 error = ft_bzip2_file_reset( zip );
375 if (
pos > zip->pos )
391 delta = (
FT_ULong)( zip->limit - zip->cursor );
392 if ( delta >=
count )
398 zip->cursor += delta;
405 error = ft_bzip2_file_fill_output( zip );
426 FT_BZip2File zip = (FT_BZip2File)
stream->descriptor.pointer;
433 ft_bzip2_file_done( zip );
446 unsigned long count )
448 FT_BZip2File zip = (FT_BZip2File)
stream->descriptor.pointer;
461 FT_BZip2File zip =
NULL;
492 stream->descriptor.pointer = zip;
498 stream->read = ft_bzip2_stream_io;
499 stream->close = ft_bzip2_stream_close;
514 return FT_THROW( Unimplemented_Feature );
struct outqueuenode * head
while(CdLookupNextInitialFileDirent(IrpContext, Fcb, FileContext))
void(* free_func)(voidpf opaque, voidpf address)
voidpf(* alloc_func)(voidpf opaque, uInt items, uInt size)
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
FT_Stream_OpenBzip2(FT_Stream stream, FT_Stream source)
#define FT_ALLOC(ptr, size)
#define FT_MEM_COPY(dest, source, count)
#define FT_STREAM_SEEK(position)
#define FT_STREAM_READ(buffer, count)
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
GLuint GLuint GLsizei count
GLenum GLenum GLenum input
static char memory[1024 *256]