26#include FT_INTERNAL_MEMORY_H
27#include FT_INTERNAL_STREAM_H
28#include FT_INTERNAL_DEBUG_H
30#include FT_CONFIG_STANDARD_LIBRARY_H
33#include FT_MODULE_ERRORS_H
38#define FT_ERR_PREFIX Bzip2_Err_
39#define FT_ERR_BASE FT_Mod_Err_Bzip2
44#ifdef FT_CONFIG_OPTION_USE_BZIP2
61 typedef void *(* alloc_func)(
void*,
int,
int);
95#define FT_BZIP2_BUFFER_SIZE 4096
97 typedef struct FT_BZip2FileRec_
111 } FT_BZip2FileRec, *FT_BZip2File;
128 if (
head[0] != 0x42 ||
142 ft_bzip2_file_init( FT_BZip2File zip,
146 bz_stream* bzstream = &zip->bzstream;
152 zip->memory =
stream->memory;
154 zip->limit = zip->buffer + FT_BZIP2_BUFFER_SIZE;
155 zip->cursor = zip->limit;
171 bzstream->bzalloc = (
alloc_func)ft_bzip2_alloc;
172 bzstream->bzfree = (
free_func) ft_bzip2_free;
173 bzstream->opaque = zip->memory;
175 bzstream->avail_in = 0;
176 bzstream->next_in = (
char*)zip->buffer;
178 if ( BZ2_bzDecompressInit( bzstream, 0, 0 ) != BZ_OK ||
188 ft_bzip2_file_done( FT_BZip2File zip )
190 bz_stream* bzstream = &zip->bzstream;
193 BZ2_bzDecompressEnd( bzstream );
196 bzstream->bzalloc =
NULL;
197 bzstream->bzfree =
NULL;
198 bzstream->opaque =
NULL;
199 bzstream->next_in =
NULL;
200 bzstream->next_out =
NULL;
201 bzstream->avail_in = 0;
202 bzstream->avail_out = 0;
211 ft_bzip2_file_reset( FT_BZip2File zip )
219 bz_stream* bzstream = &zip->bzstream;
222 BZ2_bzDecompressEnd( bzstream );
224 bzstream->avail_in = 0;
225 bzstream->next_in = (
char*)zip->input;
226 bzstream->avail_out = 0;
227 bzstream->next_out = (
char*)zip->buffer;
229 zip->limit = zip->buffer + FT_BZIP2_BUFFER_SIZE;
230 zip->cursor = zip->limit;
233 BZ2_bzDecompressInit( bzstream, 0, 0 );
241 ft_bzip2_file_fill_input( FT_BZip2File zip )
243 bz_stream* bzstream = &zip->bzstream;
251 FT_BZIP2_BUFFER_SIZE );
254 zip->limit = zip->cursor;
255 return FT_THROW( Invalid_Stream_Operation );
261 if (
size > FT_BZIP2_BUFFER_SIZE )
262 size = FT_BZIP2_BUFFER_SIZE;
266 zip->limit = zip->cursor;
267 return FT_THROW( Invalid_Stream_Operation );
274 bzstream->next_in = (
char*)zip->input;
275 bzstream->avail_in =
size;
282 ft_bzip2_file_fill_output( FT_BZip2File zip )
284 bz_stream* bzstream = &zip->bzstream;
288 zip->cursor = zip->buffer;
289 bzstream->next_out = (
char*)zip->cursor;
290 bzstream->avail_out = FT_BZIP2_BUFFER_SIZE;
292 while ( bzstream->avail_out > 0 )
297 if ( bzstream->avail_in == 0 )
299 error = ft_bzip2_file_fill_input( zip );
304 err = BZ2_bzDecompress( bzstream );
306 if (
err == BZ_STREAM_END )
308 zip->limit = (
FT_Byte*)bzstream->next_out;
309 if ( zip->limit == zip->cursor )
313 else if (
err != BZ_OK )
315 zip->limit = zip->cursor;
327 ft_bzip2_file_skip_output( FT_BZip2File zip,
336 delta = (
FT_ULong)( zip->limit - zip->cursor );
337 if ( delta >=
count )
340 zip->cursor += delta;
347 error = ft_bzip2_file_fill_output( zip );
357 ft_bzip2_file_io( FT_BZip2File zip,
368 if ( pos < zip->
pos )
370 error = ft_bzip2_file_reset( zip );
376 if (
pos > zip->pos )
392 delta = (
FT_ULong)( zip->limit - zip->cursor );
393 if ( delta >=
count )
399 zip->cursor += delta;
406 error = ft_bzip2_file_fill_output( zip );
427 FT_BZip2File zip = (FT_BZip2File)
stream->descriptor.pointer;
434 ft_bzip2_file_done( zip );
447 unsigned long count )
449 FT_BZip2File zip = (FT_BZip2File)
stream->descriptor.pointer;
462 FT_BZip2File zip =
NULL;
493 stream->descriptor.pointer = zip;
499 stream->read = ft_bzip2_stream_io;
500 stream->close = ft_bzip2_stream_close;
515 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]