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
46#ifdef FT_CONFIG_OPTION_PIC
47#error "bzip2 code does not support PIC yet"
65 typedef void *(* alloc_func)(
void*,
int,
int);
99#define FT_BZIP2_BUFFER_SIZE 4096
101 typedef struct FT_BZip2FileRec_
115 } FT_BZip2FileRec, *FT_BZip2File;
132 if (
head[0] != 0x42 ||
146 ft_bzip2_file_init( FT_BZip2File zip,
150 bz_stream* bzstream = &zip->bzstream;
156 zip->memory =
stream->memory;
158 zip->limit = zip->buffer + FT_BZIP2_BUFFER_SIZE;
159 zip->cursor = zip->limit;
175 bzstream->bzalloc = (
alloc_func)ft_bzip2_alloc;
176 bzstream->bzfree = (
free_func) ft_bzip2_free;
177 bzstream->opaque = zip->memory;
179 bzstream->avail_in = 0;
180 bzstream->next_in = (
char*)zip->buffer;
182 if ( BZ2_bzDecompressInit( bzstream, 0, 0 ) != BZ_OK ||
192 ft_bzip2_file_done( FT_BZip2File zip )
194 bz_stream* bzstream = &zip->bzstream;
197 BZ2_bzDecompressEnd( bzstream );
200 bzstream->bzalloc =
NULL;
201 bzstream->bzfree =
NULL;
202 bzstream->opaque =
NULL;
203 bzstream->next_in =
NULL;
204 bzstream->next_out =
NULL;
205 bzstream->avail_in = 0;
206 bzstream->avail_out = 0;
215 ft_bzip2_file_reset( FT_BZip2File zip )
223 bz_stream* bzstream = &zip->bzstream;
226 BZ2_bzDecompressEnd( bzstream );
228 bzstream->avail_in = 0;
229 bzstream->next_in = (
char*)zip->input;
230 bzstream->avail_out = 0;
231 bzstream->next_out = (
char*)zip->buffer;
233 zip->limit = zip->buffer + FT_BZIP2_BUFFER_SIZE;
234 zip->cursor = zip->limit;
237 BZ2_bzDecompressInit( bzstream, 0, 0 );
245 ft_bzip2_file_fill_input( FT_BZip2File zip )
247 bz_stream* bzstream = &zip->bzstream;
255 FT_BZIP2_BUFFER_SIZE );
258 zip->limit = zip->cursor;
259 return FT_THROW( Invalid_Stream_Operation );
265 if (
size > FT_BZIP2_BUFFER_SIZE )
266 size = FT_BZIP2_BUFFER_SIZE;
270 zip->limit = zip->cursor;
271 return FT_THROW( Invalid_Stream_Operation );
278 bzstream->next_in = (
char*)zip->input;
279 bzstream->avail_in =
size;
286 ft_bzip2_file_fill_output( FT_BZip2File zip )
288 bz_stream* bzstream = &zip->bzstream;
292 zip->cursor = zip->buffer;
293 bzstream->next_out = (
char*)zip->cursor;
294 bzstream->avail_out = FT_BZIP2_BUFFER_SIZE;
296 while ( bzstream->avail_out > 0 )
301 if ( bzstream->avail_in == 0 )
303 error = ft_bzip2_file_fill_input( zip );
308 err = BZ2_bzDecompress( bzstream );
310 if (
err == BZ_STREAM_END )
312 zip->limit = (
FT_Byte*)bzstream->next_out;
313 if ( zip->limit == zip->cursor )
317 else if (
err != BZ_OK )
319 zip->limit = zip->cursor;
331 ft_bzip2_file_skip_output( FT_BZip2File zip,
340 delta = (
FT_ULong)( zip->limit - zip->cursor );
341 if ( delta >=
count )
344 zip->cursor += delta;
351 error = ft_bzip2_file_fill_output( zip );
361 ft_bzip2_file_io( FT_BZip2File zip,
372 if ( pos < zip->
pos )
374 error = ft_bzip2_file_reset( zip );
380 if (
pos > zip->pos )
396 delta = (
FT_ULong)( zip->limit - zip->cursor );
397 if ( delta >=
count )
403 zip->cursor += delta;
410 error = ft_bzip2_file_fill_output( zip );
431 FT_BZip2File zip = (FT_BZip2File)
stream->descriptor.pointer;
438 ft_bzip2_file_done( zip );
451 unsigned long count )
453 FT_BZip2File zip = (FT_BZip2File)
stream->descriptor.pointer;
466 FT_BZip2File zip =
NULL;
497 stream->descriptor.pointer = zip;
503 stream->read = ft_bzip2_stream_io;
504 stream->close = ft_bzip2_stream_close;
519 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]