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 LZW_Err_ 39 #define FT_ERR_BASE FT_Mod_Err_LZW 44 #ifdef FT_CONFIG_OPTION_USE_LZW 46 #ifdef FT_CONFIG_OPTION_PIC 47 #error "lzw code does not support PIC yet" 69 #define FT_LZW_BUFFER_SIZE 4096 71 typedef struct FT_LZWFileRec_
83 } FT_LZWFileRec, *FT_LZWFile;
99 if ( head[0] != 0x1f ||
101 error =
FT_THROW( Invalid_File_Format );
109 ft_lzw_file_init( FT_LZWFile zip,
119 zip->memory = stream->
memory;
121 zip->limit = zip->buffer + FT_LZW_BUFFER_SIZE;
122 zip->cursor = zip->limit;
126 error = ft_lzw_check_header( source );
139 ft_lzw_file_done( FT_LZWFile zip )
151 ft_lzw_file_reset( FT_LZWFile zip )
161 zip->limit = zip->buffer + FT_LZW_BUFFER_SIZE;
162 zip->cursor = zip->limit;
171 ft_lzw_file_fill_output( FT_LZWFile zip )
178 zip->cursor = zip->buffer;
182 zip->limit = zip->cursor +
count;
185 error =
FT_THROW( Invalid_Stream_Operation );
193 ft_lzw_file_skip_output( FT_LZWFile zip,
204 if ( delta >= count )
207 zip->cursor += delta;
216 FT_ULong delta = FT_LZW_BUFFER_SIZE;
224 if ( numread < delta )
227 error =
FT_THROW( Invalid_Stream_Operation );
240 ft_lzw_file_io( FT_LZWFile zip,
250 if ( pos < zip->pos )
254 if ( ( zip->pos - pos ) <= (
FT_ULong)( zip->cursor - zip->buffer ) )
256 zip->cursor -= zip->pos - pos;
261 error = ft_lzw_file_reset( zip );
268 if ( pos > zip->pos )
270 error = ft_lzw_file_skip_output( zip, (
FT_ULong)( pos - zip->pos ) );
284 delta = (
FT_ULong)( zip->limit - zip->cursor );
285 if ( delta >= count )
290 zip->cursor += delta;
297 error = ft_lzw_file_fill_output( zip );
325 ft_lzw_file_done( zip );
343 return ft_lzw_file_io( zip, pos,
buffer, count );
353 FT_LZWFile zip =
NULL;
363 error = ft_lzw_check_header( source );
372 error = ft_lzw_file_init( zip, stream, source );
382 stream->
size = 0x7FFFFFFFL;
385 stream->
read = ft_lzw_stream_io;
386 stream->
close = ft_lzw_stream_close;
406 return FT_THROW( Unimplemented_Feature );
return FT_THROW(Missing_Property)
GLsizei GLsizei GLchar * source
ft_lzwstate_reset(FT_LzwState state)
FT_Stream_CloseFunc close
ft_lzwstate_done(FT_LzwState state)
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
#define FT_STREAM_SEEK(position)
if(!abbox) return FT_THROW(Invalid_Argument)
ft_lzwstate_init(FT_LzwState state, FT_Stream source)
GLuint GLuint GLsizei count
#define FT_MEM_COPY(dest, source, count)
#define FT_STREAM_READ(buffer, count)
FT_Stream_OpenLZW(FT_Stream stream, FT_Stream source)
ft_lzwstate_io(FT_LzwState state, FT_Byte *buffer, FT_ULong out_size)