27#include FT_CONFIG_STANDARD_LIBRARY_H
35#define FT_ERR_PREFIX Gzip_Err_
36#define FT_ERR_BASE FT_Mod_Err_Gzip
41#ifdef FT_CONFIG_OPTION_USE_ZLIB
43#ifdef FT_CONFIG_OPTION_SYSTEM_ZLIB
56#ifndef USE_ZLIB_ZCALLOC
77#if defined( _MSC_VER )
82#pragma warning( push )
83#pragma warning( disable : 4244 )
88#define NO_INFLATE_MASK
105#if defined( _MSC_VER )
106#pragma warning( pop )
146#if !defined( FT_CONFIG_OPTION_SYSTEM_ZLIB ) && !defined( USE_ZLIB_ZCALLOC )
174#define FT_GZIP_BUFFER_SIZE 4096
176 typedef struct FT_GZipFileRec_
191 } FT_GZipFileRec, *FT_GZipFile;
195#define FT_GZIP_ASCII_FLAG 0x01
196#define FT_GZIP_HEAD_CRC 0x02
197#define FT_GZIP_EXTRA_FIELD 0x04
198#define FT_GZIP_ORIG_NAME 0x08
199#define FT_GZIP_COMMENT 0x10
200#define FT_GZIP_RESERVED 0xE0
217 if (
head[0] != 0x1F ||
220 (
head[3] & FT_GZIP_RESERVED) )
230 if (
head[3] & FT_GZIP_EXTRA_FIELD )
241 if (
head[3] & FT_GZIP_ORIG_NAME )
255 if (
head[3] & FT_GZIP_COMMENT )
269 if (
head[3] & FT_GZIP_HEAD_CRC )
279 ft_gzip_file_init( FT_GZipFile zip,
289 zip->memory =
stream->memory;
291 zip->limit = zip->buffer + FT_GZIP_BUFFER_SIZE;
292 zip->cursor = zip->limit;
312 zstream->
next_in = zip->buffer;
324 ft_gzip_file_done( FT_GZipFile zip )
347 ft_gzip_file_reset( FT_GZipFile zip )
365 zip->limit = zip->buffer + FT_GZIP_BUFFER_SIZE;
366 zip->cursor = zip->limit;
375 ft_gzip_file_fill_input( FT_GZipFile zip )
385 FT_GZIP_BUFFER_SIZE );
388 zip->limit = zip->cursor;
389 return FT_THROW( Invalid_Stream_Operation );
395 if (
size > FT_GZIP_BUFFER_SIZE )
396 size = FT_GZIP_BUFFER_SIZE;
400 zip->limit = zip->cursor;
401 return FT_THROW( Invalid_Stream_Operation );
416 ft_gzip_file_fill_output( FT_GZipFile zip )
422 zip->cursor = zip->buffer;
424 zstream->
avail_out = FT_GZIP_BUFFER_SIZE;
433 error = ft_gzip_file_fill_input( zip );
443 if ( zip->limit == zip->cursor )
449 zip->limit = zip->cursor;
461 ft_gzip_file_skip_output( FT_GZipFile zip,
470 delta = (
FT_ULong)( zip->limit - zip->cursor );
471 if ( delta >=
count )
474 zip->cursor += delta;
481 error = ft_gzip_file_fill_output( zip );
491 ft_gzip_file_io( FT_GZipFile zip,
502 if ( pos < zip->
pos )
504 error = ft_gzip_file_reset( zip );
510 if (
pos > zip->pos )
526 delta = (
FT_ULong)( zip->limit - zip->cursor );
527 if ( delta >=
count )
533 zip->cursor += delta;
540 error = ft_gzip_file_fill_output( zip );
561 FT_GZipFile zip = (FT_GZipFile)
stream->descriptor.pointer;
568 ft_gzip_file_done( zip );
584 unsigned long count )
586 FT_GZipFile zip = (FT_GZipFile)
stream->descriptor.pointer;
623 FT_GZipFile zip =
NULL;
654 stream->descriptor.pointer = zip;
669 if ( zip_size != 0 && zip_size < 40 * 1024 )
674 if ( !
FT_ALLOC( zip_buff, zip_size ) )
679 count = ft_gzip_file_io( zip, 0, zip_buff, zip_size );
680 if (
count == zip_size )
682 ft_gzip_file_done( zip );
691 stream->close = ft_gzip_stream_close;
696 ft_gzip_file_io( zip, 0,
NULL, 0 );
710 stream->read = ft_gzip_stream_io;
711 stream->close = ft_gzip_stream_close;
733 if ( !
memory || !output_len || !output )
734 return FT_THROW( Invalid_Argument );
753#ifdef FT_CONFIG_OPTION_SYSTEM_ZLIB
760 return FT_THROW( Invalid_Argument );
771 *output_len =
stream.total_out;
798 return FT_THROW( Unimplemented_Feature );
815 return FT_THROW( Unimplemented_Feature );
struct outqueuenode * head
static int inflateReset(z_streamp strm)
int inflate(z_streamp strm, int flush)
int inflateEnd(z_streamp strm)
void(* free_func)(voidpf opaque, voidpf address)
voidpf(* alloc_func)(voidpf opaque, uInt items, uInt size)
void zcfree(voidpf opaque, voidpf ptr)
voidpf zcalloc(voidpf opaque, unsigned items, unsigned size)
FT_Stream_OpenGzip(FT_Stream stream, FT_Stream source)
FT_Gzip_Uncompress(FT_Memory memory, FT_Byte *output, FT_ULong *output_len, const FT_Byte *input, FT_ULong input_len)
#define FT_ALLOC(ptr, size)
#define FT_MEM_COPY(dest, source, count)
#define FT_STREAM_SEEK(position)
FT_Stream_ReadULongLE(FT_Stream stream, FT_Error *error)
#define FT_READ_BYTE(var)
#define FT_STREAM_SKIP(distance)
#define FT_READ_USHORT_LE(var)
#define FT_STREAM_READ(buffer, count)
FT_Stream_Seek(FT_Stream stream, FT_ULong pos)
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
GLuint GLuint GLsizei count
GLenum GLenum GLenum input
static char memory[1024 *256]
#define inflateInit2(strm, windowBits)