aboutsummaryrefslogtreecommitdiff
path: root/freetype/src/gzip/ftgzip.c
diff options
context:
space:
mode:
Diffstat (limited to 'freetype/src/gzip/ftgzip.c')
-rw-r--r--freetype/src/gzip/ftgzip.c78
1 files changed, 77 insertions, 1 deletions
diff --git a/freetype/src/gzip/ftgzip.c b/freetype/src/gzip/ftgzip.c
index f26755834..2c60b6c57 100644
--- a/freetype/src/gzip/ftgzip.c
+++ b/freetype/src/gzip/ftgzip.c
@@ -596,6 +596,8 @@
}
+ /* documentation is in ftgzip.h */
+
FT_EXPORT_DEF( FT_Error )
FT_Stream_OpenGzip( FT_Stream stream,
FT_Stream source )
@@ -684,7 +686,64 @@
return error;
}
-#else /* !FT_CONFIG_OPTION_USE_ZLIB */
+
+ /* documentation is in ftgzip.h */
+
+ FT_EXPORT_DEF( FT_Error )
+ FT_Gzip_Uncompress( FT_Memory memory,
+ FT_Byte* output,
+ FT_ULong* output_len,
+ const FT_Byte* input,
+ FT_ULong input_len )
+ {
+ z_stream stream;
+ int err;
+
+
+ /* this function is modeled after zlib's `uncompress' function */
+
+ stream.next_in = (Bytef*)input;
+ stream.avail_in = (uInt)input_len;
+
+ stream.next_out = output;
+ stream.avail_out = (uInt)*output_len;
+
+ stream.zalloc = (alloc_func)ft_gzip_alloc;
+ stream.zfree = (free_func) ft_gzip_free;
+ stream.opaque = memory;
+
+ err = inflateInit2( &stream, MAX_WBITS );
+ if ( err != Z_OK )
+ return FT_THROW( Invalid_Argument );
+
+ err = inflate( &stream, Z_FINISH );
+ if ( err != Z_STREAM_END )
+ {
+ inflateEnd( &stream );
+ if ( err == Z_OK )
+ err = Z_BUF_ERROR;
+ }
+ else
+ {
+ *output_len = stream.total_out;
+
+ err = inflateEnd( &stream );
+ }
+
+ if ( err == Z_MEM_ERROR )
+ return FT_THROW( Out_Of_Memory );
+
+ if ( err == Z_BUF_ERROR )
+ return FT_THROW( Array_Too_Large );
+
+ if ( err == Z_DATA_ERROR )
+ return FT_THROW( Invalid_Table );
+
+ return FT_Err_Ok;
+ }
+
+
+#else /* !FT_CONFIG_OPTION_USE_ZLIB */
FT_EXPORT_DEF( FT_Error )
FT_Stream_OpenGzip( FT_Stream stream,
@@ -696,6 +755,23 @@
return FT_THROW( Unimplemented_Feature );
}
+
+ FT_EXPORT_DEF( FT_Error )
+ FT_Gzip_Uncompress( FT_Memory memory,
+ FT_Byte* output,
+ FT_ULong* output_len,
+ const FT_Byte* input,
+ FT_ULong input_len )
+ {
+ FT_UNUSED( memory );
+ FT_UNUSED( output );
+ FT_UNUSED( output_len );
+ FT_UNUSED( input );
+ FT_UNUSED( input_len );
+
+ return FT_THROW( Unimplemented_Feature );
+ }
+
#endif /* !FT_CONFIG_OPTION_USE_ZLIB */