mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-07-03 14:34:34 +00:00
Update zlib to 1.2.8, libpng to 1.6.25, and move out of glpng subdir
This commit is contained in:
parent
58df545ec8
commit
b4c001edb6
56 changed files with 40739 additions and 26018 deletions
|
@ -48,8 +48,8 @@ SET(LUADIR ${EXTLIBDIR}/lua-5.1.4)
|
||||||
SET(LUASRCDIR ${LUADIR}/src)
|
SET(LUASRCDIR ${LUADIR}/src)
|
||||||
SET(LIBOGGDIR ${EXTLIBDIR}/libogg-1.3.0)
|
SET(LIBOGGDIR ${EXTLIBDIR}/libogg-1.3.0)
|
||||||
SET(LIBVORBISDIR ${EXTLIBDIR}/libvorbis-1.3.3)
|
SET(LIBVORBISDIR ${EXTLIBDIR}/libvorbis-1.3.3)
|
||||||
SET(ZLIBDIR ${EXTLIBDIR}/glpng/zlib)
|
SET(ZLIBDIR ${EXTLIBDIR}/zlib)
|
||||||
SET(PNGDIR ${EXTLIBDIR}/glpng/png)
|
SET(PNGDIR ${EXTLIBDIR}/png)
|
||||||
|
|
||||||
################ Look for external libraries
|
################ Look for external libraries
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1,180 +0,0 @@
|
||||||
/* pnglibconf.h - library build configuration */
|
|
||||||
|
|
||||||
/* libpng version 1.5.12 - July 11, 2012 */
|
|
||||||
|
|
||||||
/* Copyright (c) 1998-2011 Glenn Randers-Pehrson */
|
|
||||||
|
|
||||||
/* This code is released under the libpng license. */
|
|
||||||
/* For conditions of distribution and use, see the disclaimer */
|
|
||||||
/* and license in png.h */
|
|
||||||
|
|
||||||
/* pnglibconf.h */
|
|
||||||
/* Machine generated file: DO NOT EDIT */
|
|
||||||
/* Derived from: scripts/pnglibconf.dfa */
|
|
||||||
#ifndef PNGLCONF_H
|
|
||||||
#define PNGLCONF_H
|
|
||||||
/* settings */
|
|
||||||
#define PNG_MAX_GAMMA_8 11
|
|
||||||
#define PNG_CALLOC_SUPPORTED
|
|
||||||
#define PNG_QUANTIZE_RED_BITS 5
|
|
||||||
#define PNG_QUANTIZE_GREEN_BITS 5
|
|
||||||
#define PNG_API_RULE 0
|
|
||||||
#define PNG_QUANTIZE_BLUE_BITS 5
|
|
||||||
#define PNG_sCAL_PRECISION 5
|
|
||||||
#define PNG_COST_SHIFT 3
|
|
||||||
#define PNG_WEIGHT_SHIFT 8
|
|
||||||
#define PNG_DEFAULT_READ_MACROS 1
|
|
||||||
#define PNG_ZBUF_SIZE 8192
|
|
||||||
#define PNG_GAMMA_THRESHOLD_FIXED 5000
|
|
||||||
/* end of settings */
|
|
||||||
/* options */
|
|
||||||
#define PNG_INFO_IMAGE_SUPPORTED 1
|
|
||||||
#define PNG_HANDLE_AS_UNKNOWN_SUPPORTED 1
|
|
||||||
#define PNG_POINTER_INDEXING_SUPPORTED 1
|
|
||||||
#define PNG_WARNINGS_SUPPORTED 1
|
|
||||||
#define PNG_FLOATING_ARITHMETIC_SUPPORTED 1
|
|
||||||
#define PNG_WRITE_SUPPORTED 1
|
|
||||||
#define PNG_WRITE_INTERLACING_SUPPORTED 1
|
|
||||||
#define PNG_WRITE_16BIT_SUPPORTED 1
|
|
||||||
#define PNG_EASY_ACCESS_SUPPORTED 1
|
|
||||||
#define PNG_ALIGN_MEMORY_SUPPORTED 1
|
|
||||||
#define PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED 1
|
|
||||||
#define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED 1
|
|
||||||
#define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED 1
|
|
||||||
#define PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED 1
|
|
||||||
#define PNG_FIXED_POINT_SUPPORTED 1
|
|
||||||
/*#undef PNG_ERROR_NUMBERS_SUPPORTED*/
|
|
||||||
#define PNG_ERROR_TEXT_SUPPORTED 1
|
|
||||||
#define PNG_READ_SUPPORTED 1
|
|
||||||
#define PNG_BENIGN_ERRORS_SUPPORTED 1
|
|
||||||
#define PNG_SETJMP_SUPPORTED 1
|
|
||||||
#define PNG_TIME_RFC1123_SUPPORTED 1
|
|
||||||
#define PNG_WRITE_FLUSH_SUPPORTED 1
|
|
||||||
#define PNG_MNG_FEATURES_SUPPORTED 1
|
|
||||||
/*#undef PNG_SAFE_LIMITS_SUPPORTED*/
|
|
||||||
#define PNG_FLOATING_POINT_SUPPORTED 1
|
|
||||||
#define PNG_WRITE_OPTIMIZE_CMF_SUPPORTED 1
|
|
||||||
#define PNG_INCH_CONVERSIONS_SUPPORTED 1
|
|
||||||
#define PNG_STDIO_SUPPORTED 1
|
|
||||||
#define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED 1
|
|
||||||
#define PNG_USER_MEM_SUPPORTED 1
|
|
||||||
#define PNG_IO_STATE_SUPPORTED 1
|
|
||||||
#define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED 1
|
|
||||||
#define PNG_WRITE_INT_FUNCTIONS_SUPPORTED 1
|
|
||||||
#define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED 1
|
|
||||||
#define PNG_WRITE_FILTER_SUPPORTED 1
|
|
||||||
#define PNG_WRITE_zTXt_SUPPORTED 1
|
|
||||||
#define PNG_WRITE_iCCP_SUPPORTED 1
|
|
||||||
#define PNG_READ_TRANSFORMS_SUPPORTED 1
|
|
||||||
#define PNG_READ_bKGD_SUPPORTED 1
|
|
||||||
#define PNG_UNKNOWN_CHUNKS_SUPPORTED 1
|
|
||||||
#define PNG_READ_sCAL_SUPPORTED 1
|
|
||||||
#define PNG_WRITE_hIST_SUPPORTED 1
|
|
||||||
#define PNG_READ_OPT_PLTE_SUPPORTED 1
|
|
||||||
#define PNG_WRITE_gAMA_SUPPORTED 1
|
|
||||||
#define PNG_READ_GRAY_TO_RGB_SUPPORTED 1
|
|
||||||
#define PNG_WRITE_pCAL_SUPPORTED 1
|
|
||||||
#define PNG_READ_INVERT_ALPHA_SUPPORTED 1
|
|
||||||
#define PNG_WRITE_TRANSFORMS_SUPPORTED 1
|
|
||||||
#define PNG_READ_ALPHA_MODE_SUPPORTED 1
|
|
||||||
#define PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED 1
|
|
||||||
#define PNG_READ_sBIT_SUPPORTED 1
|
|
||||||
#define PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED 1
|
|
||||||
#define PNG_READ_PACK_SUPPORTED 1
|
|
||||||
#define PNG_WRITE_iTXt_SUPPORTED 1
|
|
||||||
#define PNG_WRITE_SWAP_SUPPORTED 1
|
|
||||||
#define PNG_READ_cHRM_SUPPORTED 1
|
|
||||||
#define PNG_READ_STRIP_16_TO_8_SUPPORTED 1
|
|
||||||
#define PNG_WRITE_tIME_SUPPORTED 1
|
|
||||||
#define PNG_READ_INTERLACING_SUPPORTED 1
|
|
||||||
#define PNG_READ_tRNS_SUPPORTED 1
|
|
||||||
#define PNG_WRITE_pHYs_SUPPORTED 1
|
|
||||||
#define PNG_WRITE_INVERT_SUPPORTED 1
|
|
||||||
#define PNG_READ_RGB_TO_GRAY_SUPPORTED 1
|
|
||||||
#define PNG_WRITE_sRGB_SUPPORTED 1
|
|
||||||
#define PNG_READ_oFFs_SUPPORTED 1
|
|
||||||
#define PNG_WRITE_FILLER_SUPPORTED 1
|
|
||||||
#define PNG_WRITE_SHIFT_SUPPORTED 1
|
|
||||||
#define PNG_PROGRESSIVE_READ_SUPPORTED 1
|
|
||||||
#define PNG_READ_SHIFT_SUPPORTED 1
|
|
||||||
#define PNG_CONVERT_tIME_SUPPORTED 1
|
|
||||||
#define PNG_READ_USER_TRANSFORM_SUPPORTED 1
|
|
||||||
#define PNG_READ_INT_FUNCTIONS_SUPPORTED 1
|
|
||||||
#define PNG_READ_USER_CHUNKS_SUPPORTED 1
|
|
||||||
#define PNG_READ_hIST_SUPPORTED 1
|
|
||||||
#define PNG_READ_16BIT_SUPPORTED 1
|
|
||||||
#define PNG_READ_SWAP_ALPHA_SUPPORTED 1
|
|
||||||
#define PNG_READ_COMPOSITE_NODIV_SUPPORTED 1
|
|
||||||
#define PNG_SEQUENTIAL_READ_SUPPORTED 1
|
|
||||||
#define PNG_READ_BACKGROUND_SUPPORTED 1
|
|
||||||
#define PNG_READ_QUANTIZE_SUPPORTED 1
|
|
||||||
#define PNG_READ_zTXt_SUPPORTED 1
|
|
||||||
#define PNG_USER_LIMITS_SUPPORTED 1
|
|
||||||
#define PNG_READ_iCCP_SUPPORTED 1
|
|
||||||
#define PNG_READ_STRIP_ALPHA_SUPPORTED 1
|
|
||||||
#define PNG_READ_PACKSWAP_SUPPORTED 1
|
|
||||||
#define PNG_READ_sRGB_SUPPORTED 1
|
|
||||||
#define PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED 1
|
|
||||||
#define PNG_READ_pCAL_SUPPORTED 1
|
|
||||||
#define PNG_WRITE_sPLT_SUPPORTED 1
|
|
||||||
#define PNG_READ_iTXt_SUPPORTED 1
|
|
||||||
#define PNG_READ_SWAP_SUPPORTED 1
|
|
||||||
#define PNG_READ_tIME_SUPPORTED 1
|
|
||||||
#define PNG_READ_pHYs_SUPPORTED 1
|
|
||||||
#define PNG_WRITE_SWAP_ALPHA_SUPPORTED 1
|
|
||||||
#define PNG_READ_SCALE_16_TO_8_SUPPORTED 1
|
|
||||||
#define PNG_WRITE_BGR_SUPPORTED 1
|
|
||||||
#define PNG_USER_CHUNKS_SUPPORTED 1
|
|
||||||
#define PNG_CONSOLE_IO_SUPPORTED 1
|
|
||||||
#define PNG_WRITE_COMPRESSED_TEXT_SUPPORTED 1
|
|
||||||
#define PNG_WRITE_PACK_SUPPORTED 1
|
|
||||||
#define PNG_READ_FILLER_SUPPORTED 1
|
|
||||||
#define PNG_WRITE_bKGD_SUPPORTED 1
|
|
||||||
#define PNG_WRITE_tRNS_SUPPORTED 1
|
|
||||||
#define PNG_READ_sPLT_SUPPORTED 1
|
|
||||||
#define PNG_WRITE_sCAL_SUPPORTED 1
|
|
||||||
#define PNG_WRITE_oFFs_SUPPORTED 1
|
|
||||||
#define PNG_SET_USER_LIMITS_SUPPORTED 1
|
|
||||||
#define PNG_WRITE_sBIT_SUPPORTED 1
|
|
||||||
#define PNG_READ_INVERT_SUPPORTED 1
|
|
||||||
#define PNG_WRITE_cHRM_SUPPORTED 1
|
|
||||||
#define PNG_16BIT_SUPPORTED 1
|
|
||||||
#define PNG_WRITE_USER_TRANSFORM_SUPPORTED 1
|
|
||||||
#define PNG_READ_BGR_SUPPORTED 1
|
|
||||||
#define PNG_WRITE_PACKSWAP_SUPPORTED 1
|
|
||||||
#define PNG_WRITE_INVERT_ALPHA_SUPPORTED 1
|
|
||||||
#define PNG_sCAL_SUPPORTED 1
|
|
||||||
#define PNG_SET_CHUNK_CACHE_LIMIT_SUPPORTED 1
|
|
||||||
#define PNG_READ_GAMMA_SUPPORTED 1
|
|
||||||
#define PNG_USER_TRANSFORM_INFO_SUPPORTED 1
|
|
||||||
#define PNG_sBIT_SUPPORTED 1
|
|
||||||
#define PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED 1
|
|
||||||
#define PNG_cHRM_SUPPORTED 1
|
|
||||||
#define PNG_bKGD_SUPPORTED 1
|
|
||||||
#define PNG_tRNS_SUPPORTED 1
|
|
||||||
#define PNG_oFFs_SUPPORTED 1
|
|
||||||
#define PNG_READ_EXPAND_16_SUPPORTED 1
|
|
||||||
#define PNG_USER_TRANSFORM_PTR_SUPPORTED 1
|
|
||||||
#define PNG_WRITE_TEXT_SUPPORTED 1
|
|
||||||
#define PNG_READ_COMPRESSED_TEXT_SUPPORTED 1
|
|
||||||
#define PNG_hIST_SUPPORTED 1
|
|
||||||
#define PNG_zTXt_SUPPORTED 1
|
|
||||||
#define PNG_iCCP_SUPPORTED 1
|
|
||||||
#define PNG_sRGB_SUPPORTED 1
|
|
||||||
#define PNG_pCAL_SUPPORTED 1
|
|
||||||
#define PNG_WRITE_tEXt_SUPPORTED 1
|
|
||||||
#define PNG_CHECK_cHRM_SUPPORTED 1
|
|
||||||
#define PNG_READ_gAMA_SUPPORTED 1
|
|
||||||
#define PNG_iTXt_SUPPORTED 1
|
|
||||||
#define PNG_tIME_SUPPORTED 1
|
|
||||||
#define PNG_READ_EXPAND_SUPPORTED 1
|
|
||||||
#define PNG_pHYs_SUPPORTED 1
|
|
||||||
#define PNG_READ_TEXT_SUPPORTED 1
|
|
||||||
#define PNG_SAVE_INT_32_SUPPORTED 1
|
|
||||||
#define PNG_sPLT_SUPPORTED 1
|
|
||||||
#define PNG_READ_tEXt_SUPPORTED 1
|
|
||||||
#define PNG_gAMA_SUPPORTED 1
|
|
||||||
#define PNG_TEXT_SUPPORTED 1
|
|
||||||
#define PNG_tEXt_SUPPORTED 1
|
|
||||||
/* end of options */
|
|
||||||
#endif /* PNGLCONF_H */
|
|
|
@ -1,667 +0,0 @@
|
||||||
|
|
||||||
/* pngmem.c - stub functions for memory allocation
|
|
||||||
*
|
|
||||||
* Last changed in libpng 1.5.7 [December 15, 2011]
|
|
||||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
|
||||||
*
|
|
||||||
* This code is released under the libpng license.
|
|
||||||
* For conditions of distribution and use, see the disclaimer
|
|
||||||
* and license in png.h
|
|
||||||
*
|
|
||||||
* This file provides a location for all memory allocation. Users who
|
|
||||||
* need special memory handling are expected to supply replacement
|
|
||||||
* functions for png_malloc() and png_free(), and to use
|
|
||||||
* png_create_read_struct_2() and png_create_write_struct_2() to
|
|
||||||
* identify the replacement functions.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "pngpriv.h"
|
|
||||||
|
|
||||||
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
|
||||||
|
|
||||||
/* Borland DOS special memory handler */
|
|
||||||
#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
|
|
||||||
/* If you change this, be sure to change the one in png.h also */
|
|
||||||
|
|
||||||
/* Allocate memory for a png_struct. The malloc and memset can be replaced
|
|
||||||
by a single call to calloc() if this is thought to improve performance. */
|
|
||||||
PNG_FUNCTION(png_voidp /* PRIVATE */,
|
|
||||||
png_create_struct,(int type),PNG_ALLOCATED)
|
|
||||||
{
|
|
||||||
# ifdef PNG_USER_MEM_SUPPORTED
|
|
||||||
return (png_create_struct_2(type, NULL, NULL));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Alternate version of png_create_struct, for use with user-defined malloc. */
|
|
||||||
PNG_FUNCTION(png_voidp /* PRIVATE */,
|
|
||||||
png_create_struct_2,(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr),
|
|
||||||
PNG_ALLOCATED)
|
|
||||||
{
|
|
||||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
|
||||||
png_size_t size;
|
|
||||||
png_voidp struct_ptr;
|
|
||||||
|
|
||||||
if (type == PNG_STRUCT_INFO)
|
|
||||||
size = png_sizeof(png_info);
|
|
||||||
|
|
||||||
else if (type == PNG_STRUCT_PNG)
|
|
||||||
size = png_sizeof(png_struct);
|
|
||||||
|
|
||||||
else
|
|
||||||
return (png_get_copyright(NULL));
|
|
||||||
|
|
||||||
# ifdef PNG_USER_MEM_SUPPORTED
|
|
||||||
if (malloc_fn != NULL)
|
|
||||||
{
|
|
||||||
png_struct dummy_struct;
|
|
||||||
memset(&dummy_struct, 0, sizeof dummy_struct);
|
|
||||||
dummy_struct.mem_ptr=mem_ptr;
|
|
||||||
struct_ptr = (*(malloc_fn))(&dummy_struct, (png_alloc_size_t)size);
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
|
||||||
struct_ptr = (png_voidp)farmalloc(size);
|
|
||||||
if (struct_ptr != NULL)
|
|
||||||
png_memset(struct_ptr, 0, size);
|
|
||||||
|
|
||||||
return (struct_ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Free memory allocated by a png_create_struct() call */
|
|
||||||
void /* PRIVATE */
|
|
||||||
png_destroy_struct(png_voidp struct_ptr)
|
|
||||||
{
|
|
||||||
# ifdef PNG_USER_MEM_SUPPORTED
|
|
||||||
png_destroy_struct_2(struct_ptr, NULL, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Free memory allocated by a png_create_struct() call */
|
|
||||||
void /* PRIVATE */
|
|
||||||
png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn,
|
|
||||||
png_voidp mem_ptr)
|
|
||||||
{
|
|
||||||
# endif
|
|
||||||
if (struct_ptr != NULL)
|
|
||||||
{
|
|
||||||
# ifdef PNG_USER_MEM_SUPPORTED
|
|
||||||
if (free_fn != NULL)
|
|
||||||
{
|
|
||||||
png_struct dummy_struct;
|
|
||||||
memset(&dummy_struct, 0, sizeof dummy_struct);
|
|
||||||
dummy_struct.mem_ptr=mem_ptr;
|
|
||||||
(*(free_fn))(&dummy_struct, struct_ptr);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
|
||||||
farfree (struct_ptr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Allocate memory. For reasonable files, size should never exceed
|
|
||||||
* 64K. However, zlib may allocate more then 64K if you don't tell
|
|
||||||
* it not to. See zconf.h and png.h for more information. zlib does
|
|
||||||
* need to allocate exactly 64K, so whatever you call here must
|
|
||||||
* have the ability to do that.
|
|
||||||
*
|
|
||||||
* Borland seems to have a problem in DOS mode for exactly 64K.
|
|
||||||
* It gives you a segment with an offset of 8 (perhaps to store its
|
|
||||||
* memory stuff). zlib doesn't like this at all, so we have to
|
|
||||||
* detect and deal with it. This code should not be needed in
|
|
||||||
* Windows or OS/2 modes, and only in 16 bit mode. This code has
|
|
||||||
* been updated by Alexander Lehmann for version 0.89 to waste less
|
|
||||||
* memory.
|
|
||||||
*
|
|
||||||
* Note that we can't use png_size_t for the "size" declaration,
|
|
||||||
* since on some systems a png_size_t is a 16-bit quantity, and as a
|
|
||||||
* result, we would be truncating potentially larger memory requests
|
|
||||||
* (which should cause a fatal error) and introducing major problems.
|
|
||||||
*/
|
|
||||||
PNG_FUNCTION(png_voidp,PNGAPI
|
|
||||||
png_calloc,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
|
||||||
{
|
|
||||||
png_voidp ret;
|
|
||||||
|
|
||||||
ret = (png_malloc(png_ptr, size));
|
|
||||||
|
|
||||||
if (ret != NULL)
|
|
||||||
png_memset(ret,0,(png_size_t)size);
|
|
||||||
|
|
||||||
return (ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
PNG_FUNCTION(png_voidp,PNGAPI
|
|
||||||
png_malloc,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
|
||||||
{
|
|
||||||
png_voidp ret;
|
|
||||||
|
|
||||||
if (png_ptr == NULL || size == 0)
|
|
||||||
return (NULL);
|
|
||||||
|
|
||||||
# ifdef PNG_USER_MEM_SUPPORTED
|
|
||||||
if (png_ptr->malloc_fn != NULL)
|
|
||||||
ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, size));
|
|
||||||
|
|
||||||
else
|
|
||||||
ret = (png_malloc_default(png_ptr, size));
|
|
||||||
|
|
||||||
if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
|
||||||
png_error(png_ptr, "Out of memory");
|
|
||||||
|
|
||||||
return (ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
PNG_FUNCTION(png_voidp,PNGAPI
|
|
||||||
png_malloc_default,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
|
||||||
{
|
|
||||||
png_voidp ret;
|
|
||||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
|
||||||
|
|
||||||
if (png_ptr == NULL || size == 0)
|
|
||||||
return (NULL);
|
|
||||||
|
|
||||||
# ifdef PNG_MAX_MALLOC_64K
|
|
||||||
if (size > (png_uint_32)65536L)
|
|
||||||
{
|
|
||||||
png_warning(png_ptr, "Cannot Allocate > 64K");
|
|
||||||
ret = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
# endif
|
|
||||||
|
|
||||||
if (size != (size_t)size)
|
|
||||||
ret = NULL;
|
|
||||||
|
|
||||||
else if (size == (png_uint_32)65536L)
|
|
||||||
{
|
|
||||||
if (png_ptr->offset_table == NULL)
|
|
||||||
{
|
|
||||||
/* Try to see if we need to do any of this fancy stuff */
|
|
||||||
ret = farmalloc(size);
|
|
||||||
if (ret == NULL || ((png_size_t)ret & 0xffff))
|
|
||||||
{
|
|
||||||
int num_blocks;
|
|
||||||
png_uint_32 total_size;
|
|
||||||
png_bytep table;
|
|
||||||
int i, mem_level, window_bits;
|
|
||||||
png_byte huge * hptr;
|
|
||||||
int window_bits
|
|
||||||
|
|
||||||
if (ret != NULL)
|
|
||||||
{
|
|
||||||
farfree(ret);
|
|
||||||
ret = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
window_bits =
|
|
||||||
png_ptr->zlib_window_bits >= png_ptr->zlib_text_window_bits ?
|
|
||||||
png_ptr->zlib_window_bits : png_ptr->zlib_text_window_bits;
|
|
||||||
|
|
||||||
if (window_bits > 14)
|
|
||||||
num_blocks = (int)(1 << (window_bits - 14));
|
|
||||||
|
|
||||||
else
|
|
||||||
num_blocks = 1;
|
|
||||||
|
|
||||||
mem_level =
|
|
||||||
png_ptr->zlib_mem_level >= png_ptr->zlib_text_mem_level ?
|
|
||||||
png_ptr->zlib_mem_level : png_ptr->zlib_text_mem_level;
|
|
||||||
|
|
||||||
if (mem_level >= 7)
|
|
||||||
num_blocks += (int)(1 << (mem_level - 7));
|
|
||||||
|
|
||||||
else
|
|
||||||
num_blocks++;
|
|
||||||
|
|
||||||
total_size = ((png_uint_32)65536L) * (png_uint_32)num_blocks+16;
|
|
||||||
|
|
||||||
table = farmalloc(total_size);
|
|
||||||
|
|
||||||
if (table == NULL)
|
|
||||||
{
|
|
||||||
# ifndef PNG_USER_MEM_SUPPORTED
|
|
||||||
if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
|
||||||
png_error(png_ptr, "Out Of Memory"); /* Note "O", "M" */
|
|
||||||
|
|
||||||
else
|
|
||||||
png_warning(png_ptr, "Out Of Memory");
|
|
||||||
# endif
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((png_size_t)table & 0xfff0)
|
|
||||||
{
|
|
||||||
# ifndef PNG_USER_MEM_SUPPORTED
|
|
||||||
if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
|
||||||
png_error(png_ptr,
|
|
||||||
"Farmalloc didn't return normalized pointer");
|
|
||||||
|
|
||||||
else
|
|
||||||
png_warning(png_ptr,
|
|
||||||
"Farmalloc didn't return normalized pointer");
|
|
||||||
# endif
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
png_ptr->offset_table = table;
|
|
||||||
png_ptr->offset_table_ptr = farmalloc(num_blocks *
|
|
||||||
png_sizeof(png_bytep));
|
|
||||||
|
|
||||||
if (png_ptr->offset_table_ptr == NULL)
|
|
||||||
{
|
|
||||||
# ifndef PNG_USER_MEM_SUPPORTED
|
|
||||||
if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
|
||||||
png_error(png_ptr, "Out Of memory"); /* Note "O", "m" */
|
|
||||||
|
|
||||||
else
|
|
||||||
png_warning(png_ptr, "Out Of memory");
|
|
||||||
# endif
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
hptr = (png_byte huge *)table;
|
|
||||||
if ((png_size_t)hptr & 0xf)
|
|
||||||
{
|
|
||||||
hptr = (png_byte huge *)((long)(hptr) & 0xfffffff0L);
|
|
||||||
hptr = hptr + 16L; /* "hptr += 16L" fails on Turbo C++ 3.0 */
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < num_blocks; i++)
|
|
||||||
{
|
|
||||||
png_ptr->offset_table_ptr[i] = (png_bytep)hptr;
|
|
||||||
hptr = hptr + (png_uint_32)65536L; /* "+=" fails on TC++3.0 */
|
|
||||||
}
|
|
||||||
|
|
||||||
png_ptr->offset_table_number = num_blocks;
|
|
||||||
png_ptr->offset_table_count = 0;
|
|
||||||
png_ptr->offset_table_count_free = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (png_ptr->offset_table_count >= png_ptr->offset_table_number)
|
|
||||||
{
|
|
||||||
# ifndef PNG_USER_MEM_SUPPORTED
|
|
||||||
if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
|
||||||
png_error(png_ptr, "Out of Memory"); /* Note "O" and "M" */
|
|
||||||
|
|
||||||
else
|
|
||||||
png_warning(png_ptr, "Out of Memory");
|
|
||||||
# endif
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = png_ptr->offset_table_ptr[png_ptr->offset_table_count++];
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
ret = farmalloc(size);
|
|
||||||
|
|
||||||
# ifndef PNG_USER_MEM_SUPPORTED
|
|
||||||
if (ret == NULL)
|
|
||||||
{
|
|
||||||
if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
|
||||||
png_error(png_ptr, "Out of memory"); /* Note "o" and "m" */
|
|
||||||
|
|
||||||
else
|
|
||||||
png_warning(png_ptr, "Out of memory"); /* Note "o" and "m" */
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
|
|
||||||
return (ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Free a pointer allocated by png_malloc(). In the default
|
|
||||||
* configuration, png_ptr is not used, but is passed in case it
|
|
||||||
* is needed. If ptr is NULL, return without taking any action.
|
|
||||||
*/
|
|
||||||
void PNGAPI
|
|
||||||
png_free(png_structp png_ptr, png_voidp ptr)
|
|
||||||
{
|
|
||||||
if (png_ptr == NULL || ptr == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
# ifdef PNG_USER_MEM_SUPPORTED
|
|
||||||
if (png_ptr->free_fn != NULL)
|
|
||||||
{
|
|
||||||
(*(png_ptr->free_fn))(png_ptr, ptr);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
png_free_default(png_ptr, ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void PNGAPI
|
|
||||||
png_free_default(png_structp png_ptr, png_voidp ptr)
|
|
||||||
{
|
|
||||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
|
||||||
|
|
||||||
if (png_ptr == NULL || ptr == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (png_ptr->offset_table != NULL)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < png_ptr->offset_table_count; i++)
|
|
||||||
{
|
|
||||||
if (ptr == png_ptr->offset_table_ptr[i])
|
|
||||||
{
|
|
||||||
ptr = NULL;
|
|
||||||
png_ptr->offset_table_count_free++;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (png_ptr->offset_table_count_free == png_ptr->offset_table_count)
|
|
||||||
{
|
|
||||||
farfree(png_ptr->offset_table);
|
|
||||||
farfree(png_ptr->offset_table_ptr);
|
|
||||||
png_ptr->offset_table = NULL;
|
|
||||||
png_ptr->offset_table_ptr = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ptr != NULL)
|
|
||||||
farfree(ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
#else /* Not the Borland DOS special memory handler */
|
|
||||||
|
|
||||||
/* Allocate memory for a png_struct or a png_info. The malloc and
|
|
||||||
memset can be replaced by a single call to calloc() if this is thought
|
|
||||||
to improve performance noticably. */
|
|
||||||
PNG_FUNCTION(png_voidp /* PRIVATE */,
|
|
||||||
png_create_struct,(int type),PNG_ALLOCATED)
|
|
||||||
{
|
|
||||||
# ifdef PNG_USER_MEM_SUPPORTED
|
|
||||||
return (png_create_struct_2(type, NULL, NULL));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Allocate memory for a png_struct or a png_info. The malloc and
|
|
||||||
memset can be replaced by a single call to calloc() if this is thought
|
|
||||||
to improve performance noticably. */
|
|
||||||
PNG_FUNCTION(png_voidp /* PRIVATE */,
|
|
||||||
png_create_struct_2,(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr),
|
|
||||||
PNG_ALLOCATED)
|
|
||||||
{
|
|
||||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
|
||||||
png_size_t size;
|
|
||||||
png_voidp struct_ptr;
|
|
||||||
|
|
||||||
if (type == PNG_STRUCT_INFO)
|
|
||||||
size = png_sizeof(png_info);
|
|
||||||
|
|
||||||
else if (type == PNG_STRUCT_PNG)
|
|
||||||
size = png_sizeof(png_struct);
|
|
||||||
|
|
||||||
else
|
|
||||||
return (NULL);
|
|
||||||
|
|
||||||
# ifdef PNG_USER_MEM_SUPPORTED
|
|
||||||
if (malloc_fn != NULL)
|
|
||||||
{
|
|
||||||
png_struct dummy_struct;
|
|
||||||
png_structp png_ptr = &dummy_struct;
|
|
||||||
png_ptr->mem_ptr=mem_ptr;
|
|
||||||
struct_ptr = (*(malloc_fn))(png_ptr, size);
|
|
||||||
|
|
||||||
if (struct_ptr != NULL)
|
|
||||||
png_memset(struct_ptr, 0, size);
|
|
||||||
|
|
||||||
return (struct_ptr);
|
|
||||||
}
|
|
||||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
|
||||||
|
|
||||||
# if defined(__TURBOC__) && !defined(__FLAT__)
|
|
||||||
struct_ptr = (png_voidp)farmalloc(size);
|
|
||||||
# else
|
|
||||||
# if defined(_MSC_VER) && defined(MAXSEG_64K)
|
|
||||||
struct_ptr = (png_voidp)halloc(size, 1);
|
|
||||||
# else
|
|
||||||
struct_ptr = (png_voidp)malloc(size);
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
|
|
||||||
if (struct_ptr != NULL)
|
|
||||||
png_memset(struct_ptr, 0, size);
|
|
||||||
|
|
||||||
return (struct_ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Free memory allocated by a png_create_struct() call */
|
|
||||||
void /* PRIVATE */
|
|
||||||
png_destroy_struct(png_voidp struct_ptr)
|
|
||||||
{
|
|
||||||
# ifdef PNG_USER_MEM_SUPPORTED
|
|
||||||
png_destroy_struct_2(struct_ptr, NULL, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Free memory allocated by a png_create_struct() call */
|
|
||||||
void /* PRIVATE */
|
|
||||||
png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn,
|
|
||||||
png_voidp mem_ptr)
|
|
||||||
{
|
|
||||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
|
||||||
if (struct_ptr != NULL)
|
|
||||||
{
|
|
||||||
# ifdef PNG_USER_MEM_SUPPORTED
|
|
||||||
if (free_fn != NULL)
|
|
||||||
{
|
|
||||||
png_struct dummy_struct;
|
|
||||||
png_structp png_ptr = &dummy_struct;
|
|
||||||
png_ptr->mem_ptr=mem_ptr;
|
|
||||||
(*(free_fn))(png_ptr, struct_ptr);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
|
||||||
# if defined(__TURBOC__) && !defined(__FLAT__)
|
|
||||||
farfree(struct_ptr);
|
|
||||||
|
|
||||||
# else
|
|
||||||
# if defined(_MSC_VER) && defined(MAXSEG_64K)
|
|
||||||
hfree(struct_ptr);
|
|
||||||
|
|
||||||
# else
|
|
||||||
free(struct_ptr);
|
|
||||||
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Allocate memory. For reasonable files, size should never exceed
|
|
||||||
* 64K. However, zlib may allocate more then 64K if you don't tell
|
|
||||||
* it not to. See zconf.h and png.h for more information. zlib does
|
|
||||||
* need to allocate exactly 64K, so whatever you call here must
|
|
||||||
* have the ability to do that.
|
|
||||||
*/
|
|
||||||
|
|
||||||
PNG_FUNCTION(png_voidp,PNGAPI
|
|
||||||
png_calloc,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
|
||||||
{
|
|
||||||
png_voidp ret;
|
|
||||||
|
|
||||||
ret = (png_malloc(png_ptr, size));
|
|
||||||
|
|
||||||
if (ret != NULL)
|
|
||||||
png_memset(ret,0,(png_size_t)size);
|
|
||||||
|
|
||||||
return (ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
PNG_FUNCTION(png_voidp,PNGAPI
|
|
||||||
png_malloc,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
|
||||||
{
|
|
||||||
png_voidp ret;
|
|
||||||
|
|
||||||
# ifdef PNG_USER_MEM_SUPPORTED
|
|
||||||
if (png_ptr == NULL || size == 0)
|
|
||||||
return (NULL);
|
|
||||||
|
|
||||||
if (png_ptr->malloc_fn != NULL)
|
|
||||||
ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size));
|
|
||||||
|
|
||||||
else
|
|
||||||
ret = (png_malloc_default(png_ptr, size));
|
|
||||||
|
|
||||||
if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
|
||||||
png_error(png_ptr, "Out of Memory");
|
|
||||||
|
|
||||||
return (ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
PNG_FUNCTION(png_voidp,PNGAPI
|
|
||||||
png_malloc_default,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
|
||||||
{
|
|
||||||
png_voidp ret;
|
|
||||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
|
||||||
|
|
||||||
if (png_ptr == NULL || size == 0)
|
|
||||||
return (NULL);
|
|
||||||
|
|
||||||
# ifdef PNG_MAX_MALLOC_64K
|
|
||||||
if (size > (png_uint_32)65536L)
|
|
||||||
{
|
|
||||||
# ifndef PNG_USER_MEM_SUPPORTED
|
|
||||||
if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
|
||||||
png_error(png_ptr, "Cannot Allocate > 64K");
|
|
||||||
|
|
||||||
else
|
|
||||||
# endif
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
|
|
||||||
/* Check for overflow */
|
|
||||||
# if defined(__TURBOC__) && !defined(__FLAT__)
|
|
||||||
|
|
||||||
if (size != (unsigned long)size)
|
|
||||||
ret = NULL;
|
|
||||||
|
|
||||||
else
|
|
||||||
ret = farmalloc(size);
|
|
||||||
|
|
||||||
# else
|
|
||||||
# if defined(_MSC_VER) && defined(MAXSEG_64K)
|
|
||||||
if (size != (unsigned long)size)
|
|
||||||
ret = NULL;
|
|
||||||
|
|
||||||
else
|
|
||||||
ret = halloc(size, 1);
|
|
||||||
|
|
||||||
# else
|
|
||||||
if (size != (size_t)size)
|
|
||||||
ret = NULL;
|
|
||||||
|
|
||||||
else
|
|
||||||
ret = malloc((size_t)size);
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifndef PNG_USER_MEM_SUPPORTED
|
|
||||||
if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
|
||||||
png_error(png_ptr, "Out of Memory");
|
|
||||||
# endif
|
|
||||||
|
|
||||||
return (ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Free a pointer allocated by png_malloc(). If ptr is NULL, return
|
|
||||||
* without taking any action.
|
|
||||||
*/
|
|
||||||
void PNGAPI
|
|
||||||
png_free(png_structp png_ptr, png_voidp ptr)
|
|
||||||
{
|
|
||||||
if (png_ptr == NULL || ptr == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
# ifdef PNG_USER_MEM_SUPPORTED
|
|
||||||
if (png_ptr->free_fn != NULL)
|
|
||||||
{
|
|
||||||
(*(png_ptr->free_fn))(png_ptr, ptr);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
png_free_default(png_ptr, ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void PNGAPI
|
|
||||||
png_free_default(png_structp png_ptr, png_voidp ptr)
|
|
||||||
{
|
|
||||||
if (png_ptr == NULL || ptr == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
|
||||||
|
|
||||||
# if defined(__TURBOC__) && !defined(__FLAT__)
|
|
||||||
farfree(ptr);
|
|
||||||
|
|
||||||
# else
|
|
||||||
# if defined(_MSC_VER) && defined(MAXSEG_64K)
|
|
||||||
hfree(ptr);
|
|
||||||
|
|
||||||
# else
|
|
||||||
free(ptr);
|
|
||||||
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
}
|
|
||||||
#endif /* Not Borland DOS special memory handler */
|
|
||||||
|
|
||||||
/* This function was added at libpng version 1.2.3. The png_malloc_warn()
|
|
||||||
* function will set up png_malloc() to issue a png_warning and return NULL
|
|
||||||
* instead of issuing a png_error, if it fails to allocate the requested
|
|
||||||
* memory.
|
|
||||||
*/
|
|
||||||
PNG_FUNCTION(png_voidp,PNGAPI
|
|
||||||
png_malloc_warn,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
|
||||||
{
|
|
||||||
png_voidp ptr;
|
|
||||||
png_uint_32 save_flags;
|
|
||||||
if (png_ptr == NULL)
|
|
||||||
return (NULL);
|
|
||||||
|
|
||||||
save_flags = png_ptr->flags;
|
|
||||||
png_ptr->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK;
|
|
||||||
ptr = (png_voidp)png_malloc((png_structp)png_ptr, size);
|
|
||||||
png_ptr->flags=save_flags;
|
|
||||||
return(ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef PNG_USER_MEM_SUPPORTED
|
|
||||||
/* This function is called when the application wants to use another method
|
|
||||||
* of allocating and freeing memory.
|
|
||||||
*/
|
|
||||||
void PNGAPI
|
|
||||||
png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr
|
|
||||||
malloc_fn, png_free_ptr free_fn)
|
|
||||||
{
|
|
||||||
if (png_ptr != NULL)
|
|
||||||
{
|
|
||||||
png_ptr->mem_ptr = mem_ptr;
|
|
||||||
png_ptr->malloc_fn = malloc_fn;
|
|
||||||
png_ptr->free_fn = free_fn;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* This function returns a pointer to the mem_ptr associated with the user
|
|
||||||
* functions. The application should free any memory associated with this
|
|
||||||
* pointer before png_write_destroy and png_read_destroy are called.
|
|
||||||
*/
|
|
||||||
png_voidp PNGAPI
|
|
||||||
png_get_mem_ptr(png_const_structp png_ptr)
|
|
||||||
{
|
|
||||||
if (png_ptr == NULL)
|
|
||||||
return (NULL);
|
|
||||||
|
|
||||||
return ((png_voidp)png_ptr->mem_ptr);
|
|
||||||
}
|
|
||||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
|
||||||
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
4533
ExternalLibs/png/png.c
Normal file
4533
ExternalLibs/png/png.c
Normal file
File diff suppressed because it is too large
Load diff
3266
ExternalLibs/png/png.h
Normal file
3266
ExternalLibs/png/png.h
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,9 +1,9 @@
|
||||||
|
|
||||||
/* pngconf.h - machine configurable file for libpng
|
/* pngconf.h - machine configurable file for libpng
|
||||||
*
|
*
|
||||||
* libpng version 1.5.12 - July 11, 2012
|
* libpng version 1.6.25, September 1, 2016
|
||||||
*
|
*
|
||||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
|
@ -11,9 +11,7 @@
|
||||||
* For conditions of distribution and use, see the disclaimer
|
* For conditions of distribution and use, see the disclaimer
|
||||||
* and license in png.h
|
* and license in png.h
|
||||||
*
|
*
|
||||||
*/
|
* Any machine specific code is near the front of this file, so if you
|
||||||
|
|
||||||
/* Any machine specific code is near the front of this file, so if you
|
|
||||||
* are configuring libpng for a machine, you may want to read the section
|
* are configuring libpng for a machine, you may want to read the section
|
||||||
* starting here down to where it starts to typedef png_color, png_text,
|
* starting here down to where it starts to typedef png_color, png_text,
|
||||||
* and png_info.
|
* and png_info.
|
||||||
|
@ -22,34 +20,50 @@
|
||||||
#ifndef PNGCONF_H
|
#ifndef PNGCONF_H
|
||||||
#define PNGCONF_H
|
#define PNGCONF_H
|
||||||
|
|
||||||
#ifndef PNG_BUILDING_SYMBOL_TABLE
|
#ifndef PNG_BUILDING_SYMBOL_TABLE /* else includes may cause problems */
|
||||||
/* PNG_NO_LIMITS_H may be used to turn off the use of the standard C
|
|
||||||
* definition file for machine specific limits, this may impact the
|
/* From libpng 1.6.0 libpng requires an ANSI X3.159-1989 ("ISOC90") compliant C
|
||||||
* correctness of the definitions below (see uses of INT_MAX).
|
* compiler for correct compilation. The following header files are required by
|
||||||
|
* the standard. If your compiler doesn't provide these header files, or they
|
||||||
|
* do not match the standard, you will need to provide/improve them.
|
||||||
*/
|
*/
|
||||||
# ifndef PNG_NO_LIMITS_H
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
# endif
|
#include <stddef.h>
|
||||||
|
|
||||||
/* For the memory copy APIs (i.e. the standard definitions of these),
|
/* Library header files. These header files are all defined by ISOC90; libpng
|
||||||
* because this file defines png_memcpy and so on the base APIs must
|
* expects conformant implementations, however, an ISOC90 conformant system need
|
||||||
* be defined here.
|
* not provide these header files if the functionality cannot be implemented.
|
||||||
|
* In this case it will be necessary to disable the relevant parts of libpng in
|
||||||
|
* the build of pnglibconf.h.
|
||||||
|
*
|
||||||
|
* Prior to 1.6.0 string.h was included here; the API changes in 1.6.0 to not
|
||||||
|
* include this unnecessary header file.
|
||||||
*/
|
*/
|
||||||
# ifdef BSD
|
|
||||||
# include <strings.h>
|
|
||||||
# else
|
|
||||||
# include <string.h>
|
|
||||||
# endif
|
|
||||||
|
|
||||||
/* For png_FILE_p - this provides the standard definition of a
|
|
||||||
* FILE
|
|
||||||
*/
|
|
||||||
#ifdef PNG_STDIO_SUPPORTED
|
#ifdef PNG_STDIO_SUPPORTED
|
||||||
|
/* Required for the definition of FILE: */
|
||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef PNG_SETJMP_SUPPORTED
|
||||||
|
/* Required for the definition of jmp_buf and the declaration of longjmp: */
|
||||||
|
# include <setjmp.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* This controls optimization of the reading of 16 and 32 bit values
|
#ifdef PNG_CONVERT_tIME_SUPPORTED
|
||||||
|
/* Required for struct tm: */
|
||||||
|
# include <time.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* PNG_BUILDING_SYMBOL_TABLE */
|
||||||
|
|
||||||
|
/* Prior to 1.6.0 it was possible to turn off 'const' in declarations using
|
||||||
|
* PNG_NO_CONST; this is no longer supported except for data declarations which
|
||||||
|
* apparently still cause problems in 2011 on some compilers.
|
||||||
|
*/
|
||||||
|
#define PNG_CONST const /* backward compatibility only */
|
||||||
|
|
||||||
|
/* This controls optimization of the reading of 16-bit and 32-bit values
|
||||||
* from PNG files. It can be set on a per-app-file basis - it
|
* from PNG files. It can be set on a per-app-file basis - it
|
||||||
* just changes whether a macro is used when the function is called.
|
* just changes whether a macro is used when the function is called.
|
||||||
* The library builder sets the default; if read functions are not
|
* The library builder sets the default; if read functions are not
|
||||||
|
@ -72,28 +86,13 @@
|
||||||
* may be changed on a per-file basis when compiling against libpng.
|
* may be changed on a per-file basis when compiling against libpng.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* The PNGARG macro protects us against machines that don't have function
|
/* The PNGARG macro was used in versions of libpng prior to 1.6.0 to protect
|
||||||
* prototypes (ie K&R style headers). If your compiler does not handle
|
* against legacy (pre ISOC90) compilers that did not understand function
|
||||||
* function prototypes, define this macro and use the included ansi2knr.
|
* prototypes. It is not required for modern C compilers.
|
||||||
* I've always been able to use _NO_PROTO as the indicator, but you may
|
|
||||||
* need to drag the empty declaration out in front of here, or change the
|
|
||||||
* ifdef to suit your own needs.
|
|
||||||
*/
|
*/
|
||||||
#ifndef PNGARG
|
#ifndef PNGARG
|
||||||
|
|
||||||
# ifdef OF /* zlib prototype munger */
|
|
||||||
# define PNGARG(arglist) OF(arglist)
|
|
||||||
# else
|
|
||||||
|
|
||||||
# ifdef _NO_PROTO
|
|
||||||
# define PNGARG(arglist) ()
|
|
||||||
# else
|
|
||||||
# define PNGARG(arglist) arglist
|
# define PNGARG(arglist) arglist
|
||||||
# endif /* _NO_PROTO */
|
#endif
|
||||||
|
|
||||||
# endif /* OF */
|
|
||||||
|
|
||||||
#endif /* PNGARG */
|
|
||||||
|
|
||||||
/* Function calling conventions.
|
/* Function calling conventions.
|
||||||
* =============================
|
* =============================
|
||||||
|
@ -177,18 +176,16 @@
|
||||||
* ==========================
|
* ==========================
|
||||||
* This code is used at build time to find PNG_IMPEXP, the API settings
|
* This code is used at build time to find PNG_IMPEXP, the API settings
|
||||||
* and PNG_EXPORT_TYPE(), it may also set a macro to indicate the DLL
|
* and PNG_EXPORT_TYPE(), it may also set a macro to indicate the DLL
|
||||||
* import processing is possible. On Windows/x86 systems it also sets
|
* import processing is possible. On Windows systems it also sets
|
||||||
* compiler-specific macros to the values required to change the calling
|
* compiler-specific macros to the values required to change the calling
|
||||||
* conventions of the various functions.
|
* conventions of the various functions.
|
||||||
*/
|
*/
|
||||||
#if ( defined(_Windows) || defined(_WINDOWS) || defined(WIN32) ||\
|
#if defined(_Windows) || defined(_WINDOWS) || defined(WIN32) ||\
|
||||||
defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) ) &&\
|
defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
|
||||||
( defined(_X86_) || defined(_X64_) || defined(_M_IX86) ||\
|
/* Windows system (DOS doesn't support DLLs). Includes builds under Cygwin or
|
||||||
defined(_M_X64) || defined(_M_IA64) )
|
* MinGW on any architecture currently supported by Windows. Also includes
|
||||||
/* Windows system (DOS doesn't support DLLs) running on x86/x64. Includes
|
* Watcom builds but these need special treatment because they are not
|
||||||
* builds under Cygwin or MinGW. Also includes Watcom builds but these need
|
* compatible with GCC or Visual C because of different calling conventions.
|
||||||
* special treatment because they are not compatible with GCC or Visual C
|
|
||||||
* because of different calling conventions.
|
|
||||||
*/
|
*/
|
||||||
# if PNG_API_RULE == 2
|
# if PNG_API_RULE == 2
|
||||||
/* If this line results in an error, either because __watcall is not
|
/* If this line results in an error, either because __watcall is not
|
||||||
|
@ -202,6 +199,9 @@
|
||||||
# if defined(__GNUC__) || (defined(_MSC_VER) && (_MSC_VER >= 800))
|
# if defined(__GNUC__) || (defined(_MSC_VER) && (_MSC_VER >= 800))
|
||||||
# define PNGCAPI __cdecl
|
# define PNGCAPI __cdecl
|
||||||
# if PNG_API_RULE == 1
|
# if PNG_API_RULE == 1
|
||||||
|
/* If this line results in an error __stdcall is not understood and
|
||||||
|
* PNG_API_RULE should not have been set to '1'.
|
||||||
|
*/
|
||||||
# define PNGAPI __stdcall
|
# define PNGAPI __stdcall
|
||||||
# endif
|
# endif
|
||||||
# else
|
# else
|
||||||
|
@ -216,10 +216,11 @@
|
||||||
# define PNGAPI _stdcall
|
# define PNGAPI _stdcall
|
||||||
# endif
|
# endif
|
||||||
# endif /* compiler/api */
|
# endif /* compiler/api */
|
||||||
|
|
||||||
/* NOTE: PNGCBAPI always defaults to PNGCAPI. */
|
/* NOTE: PNGCBAPI always defaults to PNGCAPI. */
|
||||||
|
|
||||||
# if defined(PNGAPI) && !defined(PNG_USER_PRIVATEBUILD)
|
# if defined(PNGAPI) && !defined(PNG_USER_PRIVATEBUILD)
|
||||||
ERROR: PNG_USER_PRIVATEBUILD must be defined if PNGAPI is changed
|
# error "PNG_USER_PRIVATEBUILD must be defined if PNGAPI is changed"
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if (defined(_MSC_VER) && _MSC_VER < 800) ||\
|
# if (defined(_MSC_VER) && _MSC_VER < 800) ||\
|
||||||
|
@ -239,7 +240,7 @@
|
||||||
# endif
|
# endif
|
||||||
# endif /* compiler */
|
# endif /* compiler */
|
||||||
|
|
||||||
#else /* !Windows/x86 */
|
#else /* !Windows */
|
||||||
# if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__)
|
# if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__)
|
||||||
# define PNGAPI _System
|
# define PNGAPI _System
|
||||||
# else /* !Windows/x86 && !OS/2 */
|
# else /* !Windows/x86 && !OS/2 */
|
||||||
|
@ -294,11 +295,11 @@
|
||||||
* table entries, so we discard it here. See the .dfn files in the
|
* table entries, so we discard it here. See the .dfn files in the
|
||||||
* scripts directory.
|
* scripts directory.
|
||||||
*/
|
*/
|
||||||
#ifndef PNG_EXPORTA
|
|
||||||
|
|
||||||
|
#ifndef PNG_EXPORTA
|
||||||
# define PNG_EXPORTA(ordinal, type, name, args, attributes) \
|
# define PNG_EXPORTA(ordinal, type, name, args, attributes) \
|
||||||
PNG_FUNCTION(PNG_EXPORT_TYPE(type), (PNGAPI name), PNGARG(args), \
|
PNG_FUNCTION(PNG_EXPORT_TYPE(type), (PNGAPI name), PNGARG(args), \
|
||||||
extern attributes)
|
PNG_LINKAGE_API attributes)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* ANSI-C (C90) does not permit a macro to be invoked with an empty argument,
|
/* ANSI-C (C90) does not permit a macro to be invoked with an empty argument,
|
||||||
|
@ -333,17 +334,45 @@
|
||||||
|
|
||||||
#ifdef PNG_PEDANTIC_WARNINGS_SUPPORTED
|
#ifdef PNG_PEDANTIC_WARNINGS_SUPPORTED
|
||||||
/* Support for compiler specific function attributes. These are used
|
/* Support for compiler specific function attributes. These are used
|
||||||
* so that where compiler support is available incorrect use of API
|
* so that where compiler support is available, incorrect use of API
|
||||||
* functions in png.h will generate compiler warnings. Added at libpng
|
* functions in png.h will generate compiler warnings. Added at libpng
|
||||||
* version 1.2.41.
|
* version 1.2.41. Disabling these removes the warnings but may also produce
|
||||||
|
* less efficient code.
|
||||||
*/
|
*/
|
||||||
# if defined(__GNUC__)
|
# if defined(__clang__) && defined(__has_attribute)
|
||||||
|
/* Clang defines both __clang__ and __GNUC__. Check __clang__ first. */
|
||||||
|
# if !defined(PNG_USE_RESULT) && __has_attribute(__warn_unused_result__)
|
||||||
|
# define PNG_USE_RESULT __attribute__((__warn_unused_result__))
|
||||||
|
# endif
|
||||||
|
# if !defined(PNG_NORETURN) && __has_attribute(__noreturn__)
|
||||||
|
# define PNG_NORETURN __attribute__((__noreturn__))
|
||||||
|
# endif
|
||||||
|
# if !defined(PNG_ALLOCATED) && __has_attribute(__malloc__)
|
||||||
|
# define PNG_ALLOCATED __attribute__((__malloc__))
|
||||||
|
# endif
|
||||||
|
# if !defined(PNG_DEPRECATED) && __has_attribute(__deprecated__)
|
||||||
|
# define PNG_DEPRECATED __attribute__((__deprecated__))
|
||||||
|
# endif
|
||||||
|
# if !defined(PNG_PRIVATE)
|
||||||
|
# ifdef __has_extension
|
||||||
|
# if __has_extension(attribute_unavailable_with_message)
|
||||||
|
# define PNG_PRIVATE __attribute__((__unavailable__(\
|
||||||
|
"This function is not exported by libpng.")))
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
# ifndef PNG_RESTRICT
|
||||||
|
# define PNG_RESTRICT __restrict
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# elif defined(__GNUC__)
|
||||||
# ifndef PNG_USE_RESULT
|
# ifndef PNG_USE_RESULT
|
||||||
# define PNG_USE_RESULT __attribute__((__warn_unused_result__))
|
# define PNG_USE_RESULT __attribute__((__warn_unused_result__))
|
||||||
# endif
|
# endif
|
||||||
# ifndef PNG_NORETURN
|
# ifndef PNG_NORETURN
|
||||||
# define PNG_NORETURN __attribute__((__noreturn__))
|
# define PNG_NORETURN __attribute__((__noreturn__))
|
||||||
# endif
|
# endif
|
||||||
|
# if __GNUC__ >= 3
|
||||||
# ifndef PNG_ALLOCATED
|
# ifndef PNG_ALLOCATED
|
||||||
# define PNG_ALLOCATED __attribute__((__malloc__))
|
# define PNG_ALLOCATED __attribute__((__malloc__))
|
||||||
# endif
|
# endif
|
||||||
|
@ -359,9 +388,14 @@
|
||||||
__attribute__((__deprecated__))
|
__attribute__((__deprecated__))
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
# endif /* __GNUC__ */
|
# if ((__GNUC__ > 3) || !defined(__GNUC_MINOR__) || (__GNUC_MINOR__ >= 1))
|
||||||
|
# ifndef PNG_RESTRICT
|
||||||
|
# define PNG_RESTRICT __restrict
|
||||||
|
# endif
|
||||||
|
# endif /* __GNUC__.__GNUC_MINOR__ > 3.0 */
|
||||||
|
# endif /* __GNUC__ >= 3 */
|
||||||
|
|
||||||
# if defined(_MSC_VER) && (_MSC_VER >= 1300)
|
# elif defined(_MSC_VER) && (_MSC_VER >= 1300)
|
||||||
# ifndef PNG_USE_RESULT
|
# ifndef PNG_USE_RESULT
|
||||||
# define PNG_USE_RESULT /* not supported */
|
# define PNG_USE_RESULT /* not supported */
|
||||||
# endif
|
# endif
|
||||||
|
@ -379,7 +413,17 @@
|
||||||
# ifndef PNG_PRIVATE
|
# ifndef PNG_PRIVATE
|
||||||
# define PNG_PRIVATE __declspec(deprecated)
|
# define PNG_PRIVATE __declspec(deprecated)
|
||||||
# endif
|
# endif
|
||||||
# endif /* _MSC_VER */
|
# ifndef PNG_RESTRICT
|
||||||
|
# if (_MSC_VER >= 1400)
|
||||||
|
# define PNG_RESTRICT __restrict
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# elif defined(__WATCOMC__)
|
||||||
|
# ifndef PNG_RESTRICT
|
||||||
|
# define PNG_RESTRICT __restrict
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
#endif /* PNG_PEDANTIC_WARNINGS */
|
#endif /* PNG_PEDANTIC_WARNINGS */
|
||||||
|
|
||||||
#ifndef PNG_DEPRECATED
|
#ifndef PNG_DEPRECATED
|
||||||
|
@ -397,10 +441,14 @@
|
||||||
#ifndef PNG_PRIVATE
|
#ifndef PNG_PRIVATE
|
||||||
# define PNG_PRIVATE /* This is a private libpng function */
|
# define PNG_PRIVATE /* This is a private libpng function */
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef PNG_RESTRICT
|
||||||
|
# define PNG_RESTRICT /* The C99 "restrict" feature */
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef PNG_FP_EXPORT /* A floating point API. */
|
#ifndef PNG_FP_EXPORT /* A floating point API. */
|
||||||
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||||
# define PNG_FP_EXPORT(ordinal, type, name, args)\
|
# define PNG_FP_EXPORT(ordinal, type, name, args)\
|
||||||
PNG_EXPORT(ordinal, type, name, args)
|
PNG_EXPORT(ordinal, type, name, args);
|
||||||
# else /* No floating point APIs */
|
# else /* No floating point APIs */
|
||||||
# define PNG_FP_EXPORT(ordinal, type, name, args)
|
# define PNG_FP_EXPORT(ordinal, type, name, args)
|
||||||
# endif
|
# endif
|
||||||
|
@ -408,189 +456,167 @@
|
||||||
#ifndef PNG_FIXED_EXPORT /* A fixed point API. */
|
#ifndef PNG_FIXED_EXPORT /* A fixed point API. */
|
||||||
# ifdef PNG_FIXED_POINT_SUPPORTED
|
# ifdef PNG_FIXED_POINT_SUPPORTED
|
||||||
# define PNG_FIXED_EXPORT(ordinal, type, name, args)\
|
# define PNG_FIXED_EXPORT(ordinal, type, name, args)\
|
||||||
PNG_EXPORT(ordinal, type, name, args)
|
PNG_EXPORT(ordinal, type, name, args);
|
||||||
# else /* No fixed point APIs */
|
# else /* No fixed point APIs */
|
||||||
# define PNG_FIXED_EXPORT(ordinal, type, name, args)
|
# define PNG_FIXED_EXPORT(ordinal, type, name, args)
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* The following uses const char * instead of char * for error
|
#ifndef PNG_BUILDING_SYMBOL_TABLE
|
||||||
* and warning message functions, so some compilers won't complain.
|
/* Some typedefs to get us started. These should be safe on most of the common
|
||||||
* If you do not want to use const, define PNG_NO_CONST here.
|
* platforms.
|
||||||
*
|
*
|
||||||
* This should not change how the APIs are called, so it can be done
|
* png_uint_32 and png_int_32 may, currently, be larger than required to hold a
|
||||||
* on a per-file basis in the application.
|
* 32-bit value however this is not normally advisable.
|
||||||
|
*
|
||||||
|
* png_uint_16 and png_int_16 should always be two bytes in size - this is
|
||||||
|
* verified at library build time.
|
||||||
|
*
|
||||||
|
* png_byte must always be one byte in size.
|
||||||
|
*
|
||||||
|
* The checks below use constants from limits.h, as defined by the ISOC90
|
||||||
|
* standard.
|
||||||
*/
|
*/
|
||||||
#ifndef PNG_CONST
|
#if CHAR_BIT == 8 && UCHAR_MAX == 255
|
||||||
# ifndef PNG_NO_CONST
|
|
||||||
# define PNG_CONST const
|
|
||||||
# else
|
|
||||||
# define PNG_CONST
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Some typedefs to get us started. These should be safe on most of the
|
|
||||||
* common platforms. The typedefs should be at least as large as the
|
|
||||||
* numbers suggest (a png_uint_32 must be at least 32 bits long), but they
|
|
||||||
* don't have to be exactly that size. Some compilers dislike passing
|
|
||||||
* unsigned shorts as function parameters, so you may be better off using
|
|
||||||
* unsigned int for png_uint_16.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if defined(INT_MAX) && (INT_MAX > 0x7ffffffeL)
|
|
||||||
typedef unsigned int png_uint_32;
|
|
||||||
typedef int png_int_32;
|
|
||||||
#else
|
|
||||||
typedef unsigned long png_uint_32;
|
|
||||||
typedef long png_int_32;
|
|
||||||
#endif
|
|
||||||
typedef unsigned short png_uint_16;
|
|
||||||
typedef short png_int_16;
|
|
||||||
typedef unsigned char png_byte;
|
typedef unsigned char png_byte;
|
||||||
|
|
||||||
#ifdef PNG_NO_SIZE_T
|
|
||||||
typedef unsigned int png_size_t;
|
|
||||||
#else
|
#else
|
||||||
|
# error "libpng requires 8-bit bytes"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if INT_MIN == -32768 && INT_MAX == 32767
|
||||||
|
typedef int png_int_16;
|
||||||
|
#elif SHRT_MIN == -32768 && SHRT_MAX == 32767
|
||||||
|
typedef short png_int_16;
|
||||||
|
#else
|
||||||
|
# error "libpng requires a signed 16-bit type"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if UINT_MAX == 65535
|
||||||
|
typedef unsigned int png_uint_16;
|
||||||
|
#elif USHRT_MAX == 65535
|
||||||
|
typedef unsigned short png_uint_16;
|
||||||
|
#else
|
||||||
|
# error "libpng requires an unsigned 16-bit type"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if INT_MIN < -2147483646 && INT_MAX > 2147483646
|
||||||
|
typedef int png_int_32;
|
||||||
|
#elif LONG_MIN < -2147483646 && LONG_MAX > 2147483646
|
||||||
|
typedef long int png_int_32;
|
||||||
|
#else
|
||||||
|
# error "libpng requires a signed 32-bit (or more) type"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if UINT_MAX > 4294967294
|
||||||
|
typedef unsigned int png_uint_32;
|
||||||
|
#elif ULONG_MAX > 4294967294
|
||||||
|
typedef unsigned long int png_uint_32;
|
||||||
|
#else
|
||||||
|
# error "libpng requires an unsigned 32-bit (or more) type"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Prior to 1.6.0 it was possible to disable the use of size_t, 1.6.0, however,
|
||||||
|
* requires an ISOC90 compiler and relies on consistent behavior of sizeof.
|
||||||
|
*/
|
||||||
typedef size_t png_size_t;
|
typedef size_t png_size_t;
|
||||||
|
typedef ptrdiff_t png_ptrdiff_t;
|
||||||
|
|
||||||
|
/* libpng needs to know the maximum value of 'size_t' and this controls the
|
||||||
|
* definition of png_alloc_size_t, below. This maximum value of size_t limits
|
||||||
|
* but does not control the maximum allocations the library makes - there is
|
||||||
|
* direct application control of this through png_set_user_limits().
|
||||||
|
*/
|
||||||
|
#ifndef PNG_SMALL_SIZE_T
|
||||||
|
/* Compiler specific tests for systems where size_t is known to be less than
|
||||||
|
* 32 bits (some of these systems may no longer work because of the lack of
|
||||||
|
* 'far' support; see above.)
|
||||||
|
*/
|
||||||
|
# if (defined(__TURBOC__) && !defined(__FLAT__)) ||\
|
||||||
|
(defined(_MSC_VER) && defined(MAXSEG_64K))
|
||||||
|
# define PNG_SMALL_SIZE_T
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
#define png_sizeof(x) (sizeof (x))
|
|
||||||
|
|
||||||
/* The following is needed for medium model support. It cannot be in the
|
/* png_alloc_size_t is guaranteed to be no smaller than png_size_t, and no
|
||||||
* pngpriv.h header. Needs modification for other compilers besides
|
* smaller than png_uint_32. Casts from png_size_t or png_uint_32 to
|
||||||
* MSC. Model independent support declares all arrays and pointers to be
|
* png_alloc_size_t are not necessary; in fact, it is recommended not to use
|
||||||
* large using the far keyword. The zlib version used must also support
|
* them at all so that the compiler can complain when something turns out to be
|
||||||
* model independent data. As of version zlib 1.0.4, the necessary changes
|
* problematic.
|
||||||
* have been made in zlib. The USE_FAR_KEYWORD define triggers other
|
*
|
||||||
* changes that are needed. (Tim Wegner)
|
* Casts in the other direction (from png_alloc_size_t to png_size_t or
|
||||||
|
* png_uint_32) should be explicitly applied; however, we do not expect to
|
||||||
|
* encounter practical situations that require such conversions.
|
||||||
|
*
|
||||||
|
* PNG_SMALL_SIZE_T must be defined if the maximum value of size_t is less than
|
||||||
|
* 4294967295 - i.e. less than the maximum value of png_uint_32.
|
||||||
*/
|
*/
|
||||||
|
#ifdef PNG_SMALL_SIZE_T
|
||||||
/* Separate compiler dependencies (problem here is that zlib.h always
|
typedef png_uint_32 png_alloc_size_t;
|
||||||
* defines FAR. (SJT)
|
|
||||||
*/
|
|
||||||
#ifdef __BORLANDC__
|
|
||||||
# if defined(__LARGE__) || defined(__HUGE__) || defined(__COMPACT__)
|
|
||||||
# define LDATA 1
|
|
||||||
#else
|
#else
|
||||||
# define LDATA 0
|
typedef png_size_t png_alloc_size_t;
|
||||||
#endif
|
#endif
|
||||||
/* GRR: why is Cygwin in here? Cygwin is not Borland C... */
|
|
||||||
# if !defined(__WIN32__) && !defined(__FLAT__) && !defined(__CYGWIN__)
|
|
||||||
# define PNG_MAX_MALLOC_64K /* only used in build */
|
|
||||||
# if (LDATA != 1)
|
|
||||||
# ifndef FAR
|
|
||||||
# define FAR __far
|
|
||||||
# endif
|
|
||||||
# define USE_FAR_KEYWORD
|
|
||||||
# endif /* LDATA != 1 */
|
|
||||||
/* Possibly useful for moving data out of default segment.
|
|
||||||
* Uncomment it if you want. Could also define FARDATA as
|
|
||||||
* const if your compiler supports it. (SJT)
|
|
||||||
# define FARDATA FAR
|
|
||||||
*/
|
|
||||||
# endif /* __WIN32__, __FLAT__, __CYGWIN__ */
|
|
||||||
#endif /* __BORLANDC__ */
|
|
||||||
|
|
||||||
|
/* Prior to 1.6.0 libpng offered limited support for Microsoft C compiler
|
||||||
/* Suggest testing for specific compiler first before testing for
|
* implementations of Intel CPU specific support of user-mode segmented address
|
||||||
* FAR. The Watcom compiler defines both __MEDIUM__ and M_I86MM,
|
* spaces, where 16-bit pointers address more than 65536 bytes of memory using
|
||||||
* making reliance oncertain keywords suspect. (SJT)
|
* separate 'segment' registers. The implementation requires two different
|
||||||
|
* types of pointer (only one of which includes the segment value.)
|
||||||
|
*
|
||||||
|
* If required this support is available in version 1.2 of libpng and may be
|
||||||
|
* available in versions through 1.5, although the correctness of the code has
|
||||||
|
* not been verified recently.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* MSC Medium model */
|
/* Typedef for floating-point numbers that are converted to fixed-point with a
|
||||||
#ifdef FAR
|
* multiple of 100,000, e.g., gamma
|
||||||
# ifdef M_I86MM
|
|
||||||
# define USE_FAR_KEYWORD
|
|
||||||
# define FARDATA FAR
|
|
||||||
# include <dos.h>
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* SJT: default case */
|
|
||||||
#ifndef FAR
|
|
||||||
# define FAR
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* At this point FAR is always defined */
|
|
||||||
#ifndef FARDATA
|
|
||||||
# define FARDATA
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Typedef for floating-point numbers that are converted
|
|
||||||
* to fixed-point with a multiple of 100,000, e.g., gamma
|
|
||||||
*/
|
*/
|
||||||
typedef png_int_32 png_fixed_point;
|
typedef png_int_32 png_fixed_point;
|
||||||
|
|
||||||
/* Add typedefs for pointers */
|
/* Add typedefs for pointers */
|
||||||
typedef void FAR * png_voidp;
|
typedef void * png_voidp;
|
||||||
typedef PNG_CONST void FAR * png_const_voidp;
|
typedef const void * png_const_voidp;
|
||||||
typedef png_byte FAR * png_bytep;
|
typedef png_byte * png_bytep;
|
||||||
typedef PNG_CONST png_byte FAR * png_const_bytep;
|
typedef const png_byte * png_const_bytep;
|
||||||
typedef png_uint_32 FAR * png_uint_32p;
|
typedef png_uint_32 * png_uint_32p;
|
||||||
typedef PNG_CONST png_uint_32 FAR * png_const_uint_32p;
|
typedef const png_uint_32 * png_const_uint_32p;
|
||||||
typedef png_int_32 FAR * png_int_32p;
|
typedef png_int_32 * png_int_32p;
|
||||||
typedef PNG_CONST png_int_32 FAR * png_const_int_32p;
|
typedef const png_int_32 * png_const_int_32p;
|
||||||
typedef png_uint_16 FAR * png_uint_16p;
|
typedef png_uint_16 * png_uint_16p;
|
||||||
typedef PNG_CONST png_uint_16 FAR * png_const_uint_16p;
|
typedef const png_uint_16 * png_const_uint_16p;
|
||||||
typedef png_int_16 FAR * png_int_16p;
|
typedef png_int_16 * png_int_16p;
|
||||||
typedef PNG_CONST png_int_16 FAR * png_const_int_16p;
|
typedef const png_int_16 * png_const_int_16p;
|
||||||
typedef char FAR * png_charp;
|
typedef char * png_charp;
|
||||||
typedef PNG_CONST char FAR * png_const_charp;
|
typedef const char * png_const_charp;
|
||||||
typedef png_fixed_point FAR * png_fixed_point_p;
|
typedef png_fixed_point * png_fixed_point_p;
|
||||||
typedef PNG_CONST png_fixed_point FAR * png_const_fixed_point_p;
|
typedef const png_fixed_point * png_const_fixed_point_p;
|
||||||
typedef png_size_t FAR * png_size_tp;
|
typedef png_size_t * png_size_tp;
|
||||||
typedef PNG_CONST png_size_t FAR * png_const_size_tp;
|
typedef const png_size_t * png_const_size_tp;
|
||||||
|
|
||||||
#ifdef PNG_STDIO_SUPPORTED
|
#ifdef PNG_STDIO_SUPPORTED
|
||||||
typedef FILE * png_FILE_p;
|
typedef FILE * png_FILE_p;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||||
typedef double FAR * png_doublep;
|
typedef double * png_doublep;
|
||||||
typedef PNG_CONST double FAR * png_const_doublep;
|
typedef const double * png_const_doublep;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Pointers to pointers; i.e. arrays */
|
/* Pointers to pointers; i.e. arrays */
|
||||||
typedef png_byte FAR * FAR * png_bytepp;
|
typedef png_byte * * png_bytepp;
|
||||||
typedef png_uint_32 FAR * FAR * png_uint_32pp;
|
typedef png_uint_32 * * png_uint_32pp;
|
||||||
typedef png_int_32 FAR * FAR * png_int_32pp;
|
typedef png_int_32 * * png_int_32pp;
|
||||||
typedef png_uint_16 FAR * FAR * png_uint_16pp;
|
typedef png_uint_16 * * png_uint_16pp;
|
||||||
typedef png_int_16 FAR * FAR * png_int_16pp;
|
typedef png_int_16 * * png_int_16pp;
|
||||||
typedef PNG_CONST char FAR * FAR * png_const_charpp;
|
typedef const char * * png_const_charpp;
|
||||||
typedef char FAR * FAR * png_charpp;
|
typedef char * * png_charpp;
|
||||||
typedef png_fixed_point FAR * FAR * png_fixed_point_pp;
|
typedef png_fixed_point * * png_fixed_point_pp;
|
||||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||||
typedef double FAR * FAR * png_doublepp;
|
typedef double * * png_doublepp;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Pointers to pointers to pointers; i.e., pointer to array */
|
/* Pointers to pointers to pointers; i.e., pointer to array */
|
||||||
typedef char FAR * FAR * FAR * png_charppp;
|
typedef char * * * png_charppp;
|
||||||
|
|
||||||
/* png_alloc_size_t is guaranteed to be no smaller than png_size_t,
|
#endif /* PNG_BUILDING_SYMBOL_TABLE */
|
||||||
* and no smaller than png_uint_32. Casts from png_size_t or png_uint_32
|
|
||||||
* to png_alloc_size_t are not necessary; in fact, it is recommended
|
|
||||||
* not to use them at all so that the compiler can complain when something
|
|
||||||
* turns out to be problematic.
|
|
||||||
* Casts in the other direction (from png_alloc_size_t to png_size_t or
|
|
||||||
* png_uint_32) should be explicitly applied; however, we do not expect
|
|
||||||
* to encounter practical situations that require such conversions.
|
|
||||||
*/
|
|
||||||
#if defined(__TURBOC__) && !defined(__FLAT__)
|
|
||||||
typedef unsigned long png_alloc_size_t;
|
|
||||||
#else
|
|
||||||
# if defined(_MSC_VER) && defined(MAXSEG_64K)
|
|
||||||
typedef unsigned long png_alloc_size_t;
|
|
||||||
# else
|
|
||||||
/* This is an attempt to detect an old Windows system where (int) is
|
|
||||||
* actually 16 bits, in that case png_malloc must have an argument with a
|
|
||||||
* bigger size to accomodate the requirements of the library.
|
|
||||||
*/
|
|
||||||
# if (defined(_Windows) || defined(_WINDOWS) || defined(_WINDOWS_)) && \
|
|
||||||
(!defined(INT_MAX) || INT_MAX <= 0x7ffffffeL)
|
|
||||||
typedef DWORD png_alloc_size_t;
|
|
||||||
# else
|
|
||||||
typedef png_size_t png_alloc_size_t;
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* PNGCONF_H */
|
#endif /* PNGCONF_H */
|
|
@ -1,12 +1,11 @@
|
||||||
|
|
||||||
/* pngdebug.h - Debugging macros for libpng, also used in pngtest.c
|
/* pngdebug.h - Debugging macros for libpng, also used in pngtest.c
|
||||||
*
|
*
|
||||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
* Last changed in libpng 1.6.8 [December 19, 2013]
|
||||||
|
* Copyright (c) 1998-2002,2004,2006-2013 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.5.0 [January 6, 2011]
|
|
||||||
*
|
|
||||||
* This code is released under the libpng license.
|
* This code is released under the libpng license.
|
||||||
* For conditions of distribution and use, see the disclaimer
|
* For conditions of distribution and use, see the disclaimer
|
||||||
* and license in png.h
|
* and license in png.h
|
||||||
|
@ -25,7 +24,7 @@
|
||||||
* (actually ((void)0)).
|
* (actually ((void)0)).
|
||||||
*
|
*
|
||||||
* level: level of detail of message, starting at 0. A level 'n'
|
* level: level of detail of message, starting at 0. A level 'n'
|
||||||
* message is preceded by 'n' tab characters (not implemented
|
* message is preceded by 'n' 3-space indentations (not implemented
|
||||||
* on Microsoft compilers unless PNG_DEBUG_FILE is also
|
* on Microsoft compilers unless PNG_DEBUG_FILE is also
|
||||||
* defined, to allow debug DLL compilation with no standard IO).
|
* defined, to allow debug DLL compilation with no standard IO).
|
||||||
* message: a printf(3) style text string. A trailing '\n' is added
|
* message: a printf(3) style text string. A trailing '\n' is added
|
||||||
|
@ -77,32 +76,29 @@
|
||||||
# endif /* PNG_DEBUG_FILE */
|
# endif /* PNG_DEBUG_FILE */
|
||||||
|
|
||||||
# if (PNG_DEBUG > 1)
|
# if (PNG_DEBUG > 1)
|
||||||
/* Note: ["%s"m PNG_STRING_NEWLINE] probably does not work on
|
|
||||||
* non-ISO compilers
|
|
||||||
*/
|
|
||||||
# ifdef __STDC__
|
# ifdef __STDC__
|
||||||
# ifndef png_debug
|
# ifndef png_debug
|
||||||
# define png_debug(l,m) \
|
# define png_debug(l,m) \
|
||||||
do { \
|
do { \
|
||||||
int num_tabs=l; \
|
int num_tabs=l; \
|
||||||
fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \
|
fprintf(PNG_DEBUG_FILE,"%s" m PNG_STRING_NEWLINE,(num_tabs==1 ? " " : \
|
||||||
(num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":"")))); \
|
(num_tabs==2 ? " " : (num_tabs>2 ? " " : "")))); \
|
||||||
} while (0)
|
} while (0)
|
||||||
# endif
|
# endif
|
||||||
# ifndef png_debug1
|
# ifndef png_debug1
|
||||||
# define png_debug1(l,m,p1) \
|
# define png_debug1(l,m,p1) \
|
||||||
do { \
|
do { \
|
||||||
int num_tabs=l; \
|
int num_tabs=l; \
|
||||||
fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \
|
fprintf(PNG_DEBUG_FILE,"%s" m PNG_STRING_NEWLINE,(num_tabs==1 ? " " : \
|
||||||
(num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1); \
|
(num_tabs==2 ? " " : (num_tabs>2 ? " " : ""))),p1); \
|
||||||
} while (0)
|
} while (0)
|
||||||
# endif
|
# endif
|
||||||
# ifndef png_debug2
|
# ifndef png_debug2
|
||||||
# define png_debug2(l,m,p1,p2) \
|
# define png_debug2(l,m,p1,p2) \
|
||||||
do { \
|
do { \
|
||||||
int num_tabs=l; \
|
int num_tabs=l; \
|
||||||
fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \
|
fprintf(PNG_DEBUG_FILE,"%s" m PNG_STRING_NEWLINE,(num_tabs==1 ? " " : \
|
||||||
(num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1,p2); \
|
(num_tabs==2 ? " " : (num_tabs>2 ? " " : ""))),p1,p2);\
|
||||||
} while (0)
|
} while (0)
|
||||||
# endif
|
# endif
|
||||||
# else /* __STDC __ */
|
# else /* __STDC __ */
|
|
@ -1,8 +1,8 @@
|
||||||
|
|
||||||
/* pngerror.c - stub functions for i/o and memory allocation
|
/* pngerror.c - stub functions for i/o and memory allocation
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.5.8 [February 1, 2011]
|
* Last changed in libpng 1.6.24 [August 4, 2016]
|
||||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
|
@ -20,14 +20,14 @@
|
||||||
|
|
||||||
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
||||||
|
|
||||||
static PNG_FUNCTION(void, png_default_error,PNGARG((png_structp png_ptr,
|
static PNG_FUNCTION(void, png_default_error,PNGARG((png_const_structrp png_ptr,
|
||||||
png_const_charp error_message)),PNG_NORETURN);
|
png_const_charp error_message)),PNG_NORETURN);
|
||||||
|
|
||||||
#ifdef PNG_WARNINGS_SUPPORTED
|
#ifdef PNG_WARNINGS_SUPPORTED
|
||||||
static void /* PRIVATE */
|
static void /* PRIVATE */
|
||||||
png_default_warning PNGARG((png_structp png_ptr,
|
png_default_warning PNGARG((png_const_structrp png_ptr,
|
||||||
png_const_charp warning_message));
|
png_const_charp warning_message));
|
||||||
#endif /* PNG_WARNINGS_SUPPORTED */
|
#endif /* WARNINGS */
|
||||||
|
|
||||||
/* This function is called whenever there is a fatal error. This function
|
/* This function is called whenever there is a fatal error. This function
|
||||||
* should not be changed. If there is a need to handle errors differently,
|
* should not be changed. If there is a need to handle errors differently,
|
||||||
|
@ -36,14 +36,15 @@ png_default_warning PNGARG((png_structp png_ptr,
|
||||||
*/
|
*/
|
||||||
#ifdef PNG_ERROR_TEXT_SUPPORTED
|
#ifdef PNG_ERROR_TEXT_SUPPORTED
|
||||||
PNG_FUNCTION(void,PNGAPI
|
PNG_FUNCTION(void,PNGAPI
|
||||||
png_error,(png_structp png_ptr, png_const_charp error_message),PNG_NORETURN)
|
png_error,(png_const_structrp png_ptr, png_const_charp error_message),
|
||||||
|
PNG_NORETURN)
|
||||||
{
|
{
|
||||||
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
||||||
char msg[16];
|
char msg[16];
|
||||||
if (png_ptr != NULL)
|
if (png_ptr != NULL)
|
||||||
{
|
{
|
||||||
if (png_ptr->flags&
|
if ((png_ptr->flags &
|
||||||
(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))
|
(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) != 0)
|
||||||
{
|
{
|
||||||
if (*error_message == PNG_LITERAL_SHARP)
|
if (*error_message == PNG_LITERAL_SHARP)
|
||||||
{
|
{
|
||||||
|
@ -53,7 +54,7 @@ png_error,(png_structp png_ptr, png_const_charp error_message),PNG_NORETURN)
|
||||||
if (error_message[offset] == ' ')
|
if (error_message[offset] == ' ')
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT)
|
if ((png_ptr->flags & PNG_FLAG_STRIP_ERROR_TEXT) != 0)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < offset - 1; i++)
|
for (i = 0; i < offset - 1; i++)
|
||||||
|
@ -68,7 +69,7 @@ png_error,(png_structp png_ptr, png_const_charp error_message),PNG_NORETURN)
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT)
|
if ((png_ptr->flags & PNG_FLAG_STRIP_ERROR_TEXT) != 0)
|
||||||
{
|
{
|
||||||
msg[0] = '0';
|
msg[0] = '0';
|
||||||
msg[1] = '\0';
|
msg[1] = '\0';
|
||||||
|
@ -79,7 +80,8 @@ png_error,(png_structp png_ptr, png_const_charp error_message),PNG_NORETURN)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (png_ptr != NULL && png_ptr->error_fn != NULL)
|
if (png_ptr != NULL && png_ptr->error_fn != NULL)
|
||||||
(*(png_ptr->error_fn))(png_ptr, error_message);
|
(*(png_ptr->error_fn))(png_constcast(png_structrp,png_ptr),
|
||||||
|
error_message);
|
||||||
|
|
||||||
/* If the custom handler doesn't exist, or if it returns,
|
/* If the custom handler doesn't exist, or if it returns,
|
||||||
use the default handler, which will not return. */
|
use the default handler, which will not return. */
|
||||||
|
@ -87,7 +89,7 @@ png_error,(png_structp png_ptr, png_const_charp error_message),PNG_NORETURN)
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
PNG_FUNCTION(void,PNGAPI
|
PNG_FUNCTION(void,PNGAPI
|
||||||
png_err,(png_structp png_ptr),PNG_NORETURN)
|
png_err,(png_const_structrp png_ptr),PNG_NORETURN)
|
||||||
{
|
{
|
||||||
/* Prior to 1.5.2 the error_fn received a NULL pointer, expressed
|
/* Prior to 1.5.2 the error_fn received a NULL pointer, expressed
|
||||||
* erroneously as '\0', instead of the empty string "". This was
|
* erroneously as '\0', instead of the empty string "". This was
|
||||||
|
@ -95,13 +97,13 @@ png_err,(png_structp png_ptr),PNG_NORETURN)
|
||||||
* will crash in this case.
|
* will crash in this case.
|
||||||
*/
|
*/
|
||||||
if (png_ptr != NULL && png_ptr->error_fn != NULL)
|
if (png_ptr != NULL && png_ptr->error_fn != NULL)
|
||||||
(*(png_ptr->error_fn))(png_ptr, "");
|
(*(png_ptr->error_fn))(png_constcast(png_structrp,png_ptr), "");
|
||||||
|
|
||||||
/* If the custom handler doesn't exist, or if it returns,
|
/* If the custom handler doesn't exist, or if it returns,
|
||||||
use the default handler, which will not return. */
|
use the default handler, which will not return. */
|
||||||
png_default_error(png_ptr, "");
|
png_default_error(png_ptr, "");
|
||||||
}
|
}
|
||||||
#endif /* PNG_ERROR_TEXT_SUPPORTED */
|
#endif /* ERROR_TEXT */
|
||||||
|
|
||||||
/* Utility to safely appends strings to a buffer. This never errors out so
|
/* Utility to safely appends strings to a buffer. This never errors out so
|
||||||
* error checking is not required in the caller.
|
* error checking is not required in the caller.
|
||||||
|
@ -150,7 +152,7 @@ png_format_number(png_const_charp start, png_charp end, int format,
|
||||||
case PNG_NUMBER_FORMAT_fixed:
|
case PNG_NUMBER_FORMAT_fixed:
|
||||||
/* Needs five digits (the fraction) */
|
/* Needs five digits (the fraction) */
|
||||||
mincount = 5;
|
mincount = 5;
|
||||||
if (output || number % 10 != 0)
|
if (output != 0 || number % 10 != 0)
|
||||||
{
|
{
|
||||||
*--end = digits[number % 10];
|
*--end = digits[number % 10];
|
||||||
output = 1;
|
output = 1;
|
||||||
|
@ -161,7 +163,7 @@ png_format_number(png_const_charp start, png_charp end, int format,
|
||||||
case PNG_NUMBER_FORMAT_02u:
|
case PNG_NUMBER_FORMAT_02u:
|
||||||
/* Expects at least 2 digits. */
|
/* Expects at least 2 digits. */
|
||||||
mincount = 2;
|
mincount = 2;
|
||||||
/* fall through */
|
/* FALL THROUGH */
|
||||||
|
|
||||||
case PNG_NUMBER_FORMAT_u:
|
case PNG_NUMBER_FORMAT_u:
|
||||||
*--end = digits[number % 10];
|
*--end = digits[number % 10];
|
||||||
|
@ -171,7 +173,7 @@ png_format_number(png_const_charp start, png_charp end, int format,
|
||||||
case PNG_NUMBER_FORMAT_02x:
|
case PNG_NUMBER_FORMAT_02x:
|
||||||
/* This format expects at least two digits */
|
/* This format expects at least two digits */
|
||||||
mincount = 2;
|
mincount = 2;
|
||||||
/* fall through */
|
/* FALL THROUGH */
|
||||||
|
|
||||||
case PNG_NUMBER_FORMAT_x:
|
case PNG_NUMBER_FORMAT_x:
|
||||||
*--end = digits[number & 0xf];
|
*--end = digits[number & 0xf];
|
||||||
|
@ -187,13 +189,13 @@ png_format_number(png_const_charp start, png_charp end, int format,
|
||||||
++count;
|
++count;
|
||||||
|
|
||||||
/* Float a fixed number here: */
|
/* Float a fixed number here: */
|
||||||
if (format == PNG_NUMBER_FORMAT_fixed) if (count == 5) if (end > start)
|
if ((format == PNG_NUMBER_FORMAT_fixed) && (count == 5) && (end > start))
|
||||||
{
|
{
|
||||||
/* End of the fraction, but maybe nothing was output? In that case
|
/* End of the fraction, but maybe nothing was output? In that case
|
||||||
* drop the decimal point. If the number is a true zero handle that
|
* drop the decimal point. If the number is a true zero handle that
|
||||||
* here.
|
* here.
|
||||||
*/
|
*/
|
||||||
if (output)
|
if (output != 0)
|
||||||
*--end = '.';
|
*--end = '.';
|
||||||
else if (number == 0) /* and !output */
|
else if (number == 0) /* and !output */
|
||||||
*--end = '0';
|
*--end = '0';
|
||||||
|
@ -211,14 +213,14 @@ png_format_number(png_const_charp start, png_charp end, int format,
|
||||||
* png_set_error_fn() to replace the warning function at run-time.
|
* png_set_error_fn() to replace the warning function at run-time.
|
||||||
*/
|
*/
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_warning(png_structp png_ptr, png_const_charp warning_message)
|
png_warning(png_const_structrp png_ptr, png_const_charp warning_message)
|
||||||
{
|
{
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
if (png_ptr != NULL)
|
if (png_ptr != NULL)
|
||||||
{
|
{
|
||||||
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
||||||
if (png_ptr->flags&
|
if ((png_ptr->flags &
|
||||||
(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))
|
(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) != 0)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if (*warning_message == PNG_LITERAL_SHARP)
|
if (*warning_message == PNG_LITERAL_SHARP)
|
||||||
|
@ -230,7 +232,8 @@ png_warning(png_structp png_ptr, png_const_charp warning_message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (png_ptr != NULL && png_ptr->warning_fn != NULL)
|
if (png_ptr != NULL && png_ptr->warning_fn != NULL)
|
||||||
(*(png_ptr->warning_fn))(png_ptr, warning_message + offset);
|
(*(png_ptr->warning_fn))(png_constcast(png_structrp,png_ptr),
|
||||||
|
warning_message + offset);
|
||||||
else
|
else
|
||||||
png_default_warning(png_ptr, warning_message + offset);
|
png_default_warning(png_ptr, warning_message + offset);
|
||||||
}
|
}
|
||||||
|
@ -278,7 +281,7 @@ png_warning_parameter_signed(png_warning_parameters p, int number, int format,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
png_formatted_warning(png_structp png_ptr, png_warning_parameters p,
|
png_formatted_warning(png_const_structrp png_ptr, png_warning_parameters p,
|
||||||
png_const_charp message)
|
png_const_charp message)
|
||||||
{
|
{
|
||||||
/* The internal buffer is just 192 bytes - enough for all our messages,
|
/* The internal buffer is just 192 bytes - enough for all our messages,
|
||||||
|
@ -346,29 +349,79 @@ png_formatted_warning(png_structp png_ptr, png_warning_parameters p,
|
||||||
/* i is always less than (sizeof msg), so: */
|
/* i is always less than (sizeof msg), so: */
|
||||||
msg[i] = '\0';
|
msg[i] = '\0';
|
||||||
|
|
||||||
/* And this is the formatted message, it may be larger than
|
/* And this is the formatted message. It may be larger than
|
||||||
* PNG_MAX_ERROR_TEXT, but that is only used for 'chunk' errors and these are
|
* PNG_MAX_ERROR_TEXT, but that is only used for 'chunk' errors and these
|
||||||
* not (currently) formatted.
|
* are not (currently) formatted.
|
||||||
*/
|
*/
|
||||||
png_warning(png_ptr, msg);
|
png_warning(png_ptr, msg);
|
||||||
}
|
}
|
||||||
#endif /* PNG_WARNINGS_SUPPORTED */
|
#endif /* WARNINGS */
|
||||||
|
|
||||||
#ifdef PNG_BENIGN_ERRORS_SUPPORTED
|
#ifdef PNG_BENIGN_ERRORS_SUPPORTED
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_benign_error(png_structp png_ptr, png_const_charp error_message)
|
png_benign_error(png_const_structrp png_ptr, png_const_charp error_message)
|
||||||
{
|
{
|
||||||
if (png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN)
|
if ((png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN) != 0)
|
||||||
|
{
|
||||||
|
# ifdef PNG_READ_SUPPORTED
|
||||||
|
if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0 &&
|
||||||
|
png_ptr->chunk_name != 0)
|
||||||
|
png_chunk_warning(png_ptr, error_message);
|
||||||
|
else
|
||||||
|
# endif
|
||||||
|
png_warning(png_ptr, error_message);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
# ifdef PNG_READ_SUPPORTED
|
||||||
|
if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0 &&
|
||||||
|
png_ptr->chunk_name != 0)
|
||||||
|
png_chunk_error(png_ptr, error_message);
|
||||||
|
else
|
||||||
|
# endif
|
||||||
|
png_error(png_ptr, error_message);
|
||||||
|
}
|
||||||
|
|
||||||
|
# ifndef PNG_ERROR_TEXT_SUPPORTED
|
||||||
|
PNG_UNUSED(error_message)
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void /* PRIVATE */
|
||||||
|
png_app_warning(png_const_structrp png_ptr, png_const_charp error_message)
|
||||||
|
{
|
||||||
|
if ((png_ptr->flags & PNG_FLAG_APP_WARNINGS_WARN) != 0)
|
||||||
png_warning(png_ptr, error_message);
|
png_warning(png_ptr, error_message);
|
||||||
else
|
else
|
||||||
png_error(png_ptr, error_message);
|
png_error(png_ptr, error_message);
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
# ifndef PNG_ERROR_TEXT_SUPPORTED
|
||||||
|
PNG_UNUSED(error_message)
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void /* PRIVATE */
|
||||||
|
png_app_error(png_const_structrp png_ptr, png_const_charp error_message)
|
||||||
|
{
|
||||||
|
if ((png_ptr->flags & PNG_FLAG_APP_ERRORS_WARN) != 0)
|
||||||
|
png_warning(png_ptr, error_message);
|
||||||
|
else
|
||||||
|
png_error(png_ptr, error_message);
|
||||||
|
|
||||||
|
# ifndef PNG_ERROR_TEXT_SUPPORTED
|
||||||
|
PNG_UNUSED(error_message)
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
#endif /* BENIGN_ERRORS */
|
||||||
|
|
||||||
|
#define PNG_MAX_ERROR_TEXT 196 /* Currently limited by profile_error in png.c */
|
||||||
|
#if defined(PNG_WARNINGS_SUPPORTED) || \
|
||||||
|
(defined(PNG_READ_SUPPORTED) && defined(PNG_ERROR_TEXT_SUPPORTED))
|
||||||
/* These utilities are used internally to build an error message that relates
|
/* These utilities are used internally to build an error message that relates
|
||||||
* to the current chunk. The chunk name comes from png_ptr->chunk_name,
|
* to the current chunk. The chunk name comes from png_ptr->chunk_name,
|
||||||
* this is used to prefix the message. The message is limited in length
|
* which is used to prefix the message. The message is limited in length
|
||||||
* to 63 bytes, the name characters are output as hex digits wrapped in []
|
* to 63 bytes. The name characters are output as hex digits wrapped in []
|
||||||
* if the character is invalid.
|
* if the character is invalid.
|
||||||
*/
|
*/
|
||||||
#define isnonalpha(c) ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97))
|
#define isnonalpha(c) ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97))
|
||||||
|
@ -377,10 +430,8 @@ static PNG_CONST char png_digit[16] = {
|
||||||
'A', 'B', 'C', 'D', 'E', 'F'
|
'A', 'B', 'C', 'D', 'E', 'F'
|
||||||
};
|
};
|
||||||
|
|
||||||
#define PNG_MAX_ERROR_TEXT 64
|
|
||||||
#if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_ERROR_TEXT_SUPPORTED)
|
|
||||||
static void /* PRIVATE */
|
static void /* PRIVATE */
|
||||||
png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp
|
png_format_buffer(png_const_structrp png_ptr, png_charp buffer, png_const_charp
|
||||||
error_message)
|
error_message)
|
||||||
{
|
{
|
||||||
png_uint_32 chunk_name = png_ptr->chunk_name;
|
png_uint_32 chunk_name = png_ptr->chunk_name;
|
||||||
|
@ -391,7 +442,7 @@ png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp
|
||||||
int c = (int)(chunk_name >> ishift) & 0xff;
|
int c = (int)(chunk_name >> ishift) & 0xff;
|
||||||
|
|
||||||
ishift -= 8;
|
ishift -= 8;
|
||||||
if (isnonalpha(c))
|
if (isnonalpha(c) != 0)
|
||||||
{
|
{
|
||||||
buffer[iout++] = PNG_LITERAL_LEFT_SQUARE_BRACKET;
|
buffer[iout++] = PNG_LITERAL_LEFT_SQUARE_BRACKET;
|
||||||
buffer[iout++] = png_digit[(c & 0xf0) >> 4];
|
buffer[iout++] = png_digit[(c & 0xf0) >> 4];
|
||||||
|
@ -422,11 +473,11 @@ png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp
|
||||||
buffer[iout] = '\0';
|
buffer[iout] = '\0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* PNG_WARNINGS_SUPPORTED || PNG_ERROR_TEXT_SUPPORTED */
|
#endif /* WARNINGS || ERROR_TEXT */
|
||||||
|
|
||||||
#if defined(PNG_READ_SUPPORTED) && defined(PNG_ERROR_TEXT_SUPPORTED)
|
#if defined(PNG_READ_SUPPORTED) && defined(PNG_ERROR_TEXT_SUPPORTED)
|
||||||
PNG_FUNCTION(void,PNGAPI
|
PNG_FUNCTION(void,PNGAPI
|
||||||
png_chunk_error,(png_structp png_ptr, png_const_charp error_message),
|
png_chunk_error,(png_const_structrp png_ptr, png_const_charp error_message),
|
||||||
PNG_NORETURN)
|
PNG_NORETURN)
|
||||||
{
|
{
|
||||||
char msg[18+PNG_MAX_ERROR_TEXT];
|
char msg[18+PNG_MAX_ERROR_TEXT];
|
||||||
|
@ -439,11 +490,11 @@ png_chunk_error,(png_structp png_ptr, png_const_charp error_message),
|
||||||
png_error(png_ptr, msg);
|
png_error(png_ptr, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* PNG_READ_SUPPORTED && PNG_ERROR_TEXT_SUPPORTED */
|
#endif /* READ && ERROR_TEXT */
|
||||||
|
|
||||||
#ifdef PNG_WARNINGS_SUPPORTED
|
#ifdef PNG_WARNINGS_SUPPORTED
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_chunk_warning(png_structp png_ptr, png_const_charp warning_message)
|
png_chunk_warning(png_const_structrp png_ptr, png_const_charp warning_message)
|
||||||
{
|
{
|
||||||
char msg[18+PNG_MAX_ERROR_TEXT];
|
char msg[18+PNG_MAX_ERROR_TEXT];
|
||||||
if (png_ptr == NULL)
|
if (png_ptr == NULL)
|
||||||
|
@ -455,34 +506,79 @@ png_chunk_warning(png_structp png_ptr, png_const_charp warning_message)
|
||||||
png_warning(png_ptr, msg);
|
png_warning(png_ptr, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* PNG_WARNINGS_SUPPORTED */
|
#endif /* WARNINGS */
|
||||||
|
|
||||||
#ifdef PNG_READ_SUPPORTED
|
#ifdef PNG_READ_SUPPORTED
|
||||||
#ifdef PNG_BENIGN_ERRORS_SUPPORTED
|
#ifdef PNG_BENIGN_ERRORS_SUPPORTED
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_chunk_benign_error(png_structp png_ptr, png_const_charp error_message)
|
png_chunk_benign_error(png_const_structrp png_ptr, png_const_charp
|
||||||
|
error_message)
|
||||||
{
|
{
|
||||||
if (png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN)
|
if ((png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN) != 0)
|
||||||
png_chunk_warning(png_ptr, error_message);
|
png_chunk_warning(png_ptr, error_message);
|
||||||
|
|
||||||
else
|
else
|
||||||
png_chunk_error(png_ptr, error_message);
|
png_chunk_error(png_ptr, error_message);
|
||||||
|
|
||||||
|
# ifndef PNG_ERROR_TEXT_SUPPORTED
|
||||||
|
PNG_UNUSED(error_message)
|
||||||
|
# endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif /* PNG_READ_SUPPORTED */
|
#endif /* READ */
|
||||||
|
|
||||||
|
void /* PRIVATE */
|
||||||
|
png_chunk_report(png_const_structrp png_ptr, png_const_charp message, int error)
|
||||||
|
{
|
||||||
|
# ifndef PNG_WARNINGS_SUPPORTED
|
||||||
|
PNG_UNUSED(message)
|
||||||
|
# endif
|
||||||
|
|
||||||
|
/* This is always supported, but for just read or just write it
|
||||||
|
* unconditionally does the right thing.
|
||||||
|
*/
|
||||||
|
# if defined(PNG_READ_SUPPORTED) && defined(PNG_WRITE_SUPPORTED)
|
||||||
|
if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0)
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifdef PNG_READ_SUPPORTED
|
||||||
|
{
|
||||||
|
if (error < PNG_CHUNK_ERROR)
|
||||||
|
png_chunk_warning(png_ptr, message);
|
||||||
|
|
||||||
|
else
|
||||||
|
png_chunk_benign_error(png_ptr, message);
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# if defined(PNG_READ_SUPPORTED) && defined(PNG_WRITE_SUPPORTED)
|
||||||
|
else if ((png_ptr->mode & PNG_IS_READ_STRUCT) == 0)
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifdef PNG_WRITE_SUPPORTED
|
||||||
|
{
|
||||||
|
if (error < PNG_CHUNK_WRITE_ERROR)
|
||||||
|
png_app_warning(png_ptr, message);
|
||||||
|
|
||||||
|
else
|
||||||
|
png_app_error(png_ptr, message);
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef PNG_ERROR_TEXT_SUPPORTED
|
#ifdef PNG_ERROR_TEXT_SUPPORTED
|
||||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||||
PNG_FUNCTION(void,
|
PNG_FUNCTION(void,
|
||||||
png_fixed_error,(png_structp png_ptr, png_const_charp name),PNG_NORETURN)
|
png_fixed_error,(png_const_structrp png_ptr, png_const_charp name),PNG_NORETURN)
|
||||||
{
|
{
|
||||||
# define fixed_message "fixed point overflow in "
|
# define fixed_message "fixed point overflow in "
|
||||||
# define fixed_message_ln ((sizeof fixed_message)-1)
|
# define fixed_message_ln ((sizeof fixed_message)-1)
|
||||||
int iin;
|
int iin;
|
||||||
char msg[fixed_message_ln+PNG_MAX_ERROR_TEXT];
|
char msg[fixed_message_ln+PNG_MAX_ERROR_TEXT];
|
||||||
png_memcpy(msg, fixed_message, fixed_message_ln);
|
memcpy(msg, fixed_message, fixed_message_ln);
|
||||||
iin = 0;
|
iin = 0;
|
||||||
if (name != NULL) while (iin < (PNG_MAX_ERROR_TEXT-1) && name[iin] != 0)
|
if (name != NULL)
|
||||||
|
while (iin < (PNG_MAX_ERROR_TEXT-1) && name[iin] != 0)
|
||||||
{
|
{
|
||||||
msg[fixed_message_ln + iin] = name[iin];
|
msg[fixed_message_ln + iin] = name[iin];
|
||||||
++iin;
|
++iin;
|
||||||
|
@ -498,14 +594,111 @@ png_fixed_error,(png_structp png_ptr, png_const_charp name),PNG_NORETURN)
|
||||||
* otherwise it is necessary for png_default_error to be overridden.
|
* otherwise it is necessary for png_default_error to be overridden.
|
||||||
*/
|
*/
|
||||||
jmp_buf* PNGAPI
|
jmp_buf* PNGAPI
|
||||||
png_set_longjmp_fn(png_structp png_ptr, png_longjmp_ptr longjmp_fn,
|
png_set_longjmp_fn(png_structrp png_ptr, png_longjmp_ptr longjmp_fn,
|
||||||
size_t jmp_buf_size)
|
size_t jmp_buf_size)
|
||||||
{
|
{
|
||||||
if (png_ptr == NULL || jmp_buf_size != png_sizeof(jmp_buf))
|
/* From libpng 1.6.0 the app gets one chance to set a 'jmpbuf_size' value
|
||||||
|
* and it must not change after that. Libpng doesn't care how big the
|
||||||
|
* buffer is, just that it doesn't change.
|
||||||
|
*
|
||||||
|
* If the buffer size is no *larger* than the size of jmp_buf when libpng is
|
||||||
|
* compiled a built in jmp_buf is returned; this preserves the pre-1.6.0
|
||||||
|
* semantics that this call will not fail. If the size is larger, however,
|
||||||
|
* the buffer is allocated and this may fail, causing the function to return
|
||||||
|
* NULL.
|
||||||
|
*/
|
||||||
|
if (png_ptr == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
if (png_ptr->jmp_buf_ptr == NULL)
|
||||||
|
{
|
||||||
|
png_ptr->jmp_buf_size = 0; /* not allocated */
|
||||||
|
|
||||||
|
if (jmp_buf_size <= (sizeof png_ptr->jmp_buf_local))
|
||||||
|
png_ptr->jmp_buf_ptr = &png_ptr->jmp_buf_local;
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
png_ptr->jmp_buf_ptr = png_voidcast(jmp_buf *,
|
||||||
|
png_malloc_warn(png_ptr, jmp_buf_size));
|
||||||
|
|
||||||
|
if (png_ptr->jmp_buf_ptr == NULL)
|
||||||
|
return NULL; /* new NULL return on OOM */
|
||||||
|
|
||||||
|
png_ptr->jmp_buf_size = jmp_buf_size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else /* Already allocated: check the size */
|
||||||
|
{
|
||||||
|
size_t size = png_ptr->jmp_buf_size;
|
||||||
|
|
||||||
|
if (size == 0)
|
||||||
|
{
|
||||||
|
size = (sizeof png_ptr->jmp_buf_local);
|
||||||
|
if (png_ptr->jmp_buf_ptr != &png_ptr->jmp_buf_local)
|
||||||
|
{
|
||||||
|
/* This is an internal error in libpng: somehow we have been left
|
||||||
|
* with a stack allocated jmp_buf when the application regained
|
||||||
|
* control. It's always possible to fix this up, but for the moment
|
||||||
|
* this is a png_error because that makes it easy to detect.
|
||||||
|
*/
|
||||||
|
png_error(png_ptr, "Libpng jmp_buf still allocated");
|
||||||
|
/* png_ptr->jmp_buf_ptr = &png_ptr->jmp_buf_local; */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (size != jmp_buf_size)
|
||||||
|
{
|
||||||
|
png_warning(png_ptr, "Application jmp_buf size changed");
|
||||||
|
return NULL; /* caller will probably crash: no choice here */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Finally fill in the function, now we have a satisfactory buffer. It is
|
||||||
|
* valid to change the function on every call.
|
||||||
|
*/
|
||||||
png_ptr->longjmp_fn = longjmp_fn;
|
png_ptr->longjmp_fn = longjmp_fn;
|
||||||
return &png_ptr->longjmp_buffer;
|
return png_ptr->jmp_buf_ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void /* PRIVATE */
|
||||||
|
png_free_jmpbuf(png_structrp png_ptr)
|
||||||
|
{
|
||||||
|
if (png_ptr != NULL)
|
||||||
|
{
|
||||||
|
jmp_buf *jb = png_ptr->jmp_buf_ptr;
|
||||||
|
|
||||||
|
/* A size of 0 is used to indicate a local, stack, allocation of the
|
||||||
|
* pointer; used here and in png.c
|
||||||
|
*/
|
||||||
|
if (jb != NULL && png_ptr->jmp_buf_size > 0)
|
||||||
|
{
|
||||||
|
|
||||||
|
/* This stuff is so that a failure to free the error control structure
|
||||||
|
* does not leave libpng in a state with no valid error handling: the
|
||||||
|
* free always succeeds, if there is an error it gets ignored.
|
||||||
|
*/
|
||||||
|
if (jb != &png_ptr->jmp_buf_local)
|
||||||
|
{
|
||||||
|
/* Make an internal, libpng, jmp_buf to return here */
|
||||||
|
jmp_buf free_jmp_buf;
|
||||||
|
|
||||||
|
if (!setjmp(free_jmp_buf))
|
||||||
|
{
|
||||||
|
png_ptr->jmp_buf_ptr = &free_jmp_buf; /* come back here */
|
||||||
|
png_ptr->jmp_buf_size = 0; /* stack allocation */
|
||||||
|
png_ptr->longjmp_fn = longjmp;
|
||||||
|
png_free(png_ptr, jb); /* Return to setjmp on error */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* *Always* cancel everything out: */
|
||||||
|
png_ptr->jmp_buf_size = 0;
|
||||||
|
png_ptr->jmp_buf_ptr = NULL;
|
||||||
|
png_ptr->longjmp_fn = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -515,7 +708,7 @@ png_set_longjmp_fn(png_structp png_ptr, png_longjmp_ptr longjmp_fn,
|
||||||
* error function pointer in png_set_error_fn().
|
* error function pointer in png_set_error_fn().
|
||||||
*/
|
*/
|
||||||
static PNG_FUNCTION(void /* PRIVATE */,
|
static PNG_FUNCTION(void /* PRIVATE */,
|
||||||
png_default_error,(png_structp png_ptr, png_const_charp error_message),
|
png_default_error,(png_const_structrp png_ptr, png_const_charp error_message),
|
||||||
PNG_NORETURN)
|
PNG_NORETURN)
|
||||||
{
|
{
|
||||||
#ifdef PNG_CONSOLE_IO_SUPPORTED
|
#ifdef PNG_CONSOLE_IO_SUPPORTED
|
||||||
|
@ -562,24 +755,23 @@ png_default_error,(png_structp png_ptr, png_const_charp error_message),
|
||||||
}
|
}
|
||||||
|
|
||||||
PNG_FUNCTION(void,PNGAPI
|
PNG_FUNCTION(void,PNGAPI
|
||||||
png_longjmp,(png_structp png_ptr, int val),PNG_NORETURN)
|
png_longjmp,(png_const_structrp png_ptr, int val),PNG_NORETURN)
|
||||||
{
|
{
|
||||||
#ifdef PNG_SETJMP_SUPPORTED
|
#ifdef PNG_SETJMP_SUPPORTED
|
||||||
if (png_ptr && png_ptr->longjmp_fn)
|
if (png_ptr != NULL && png_ptr->longjmp_fn != NULL &&
|
||||||
{
|
png_ptr->jmp_buf_ptr != NULL)
|
||||||
# ifdef USE_FAR_KEYWORD
|
png_ptr->longjmp_fn(*png_ptr->jmp_buf_ptr, val);
|
||||||
{
|
|
||||||
jmp_buf tmp_jmpbuf;
|
|
||||||
png_memcpy(tmp_jmpbuf, png_ptr->longjmp_buffer, png_sizeof(jmp_buf));
|
|
||||||
png_ptr->longjmp_fn(tmp_jmpbuf, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
png_ptr->longjmp_fn(png_ptr->longjmp_buffer, val);
|
PNG_UNUSED(png_ptr)
|
||||||
|
PNG_UNUSED(val)
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
#endif
|
/* If control reaches this point, png_longjmp() must not return. The only
|
||||||
/* Here if not setjmp support or if png_ptr is null. */
|
* choice is to terminate the whole process (or maybe the thread); to do
|
||||||
|
* this the ANSI-C abort() function is used unless a different method is
|
||||||
|
* implemented by overriding the default configuration setting for
|
||||||
|
* PNG_ABORT().
|
||||||
|
*/
|
||||||
PNG_ABORT();
|
PNG_ABORT();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -590,7 +782,7 @@ png_longjmp,(png_structp png_ptr, int val),PNG_NORETURN)
|
||||||
* not used, but it is passed in case it may be useful.
|
* not used, but it is passed in case it may be useful.
|
||||||
*/
|
*/
|
||||||
static void /* PRIVATE */
|
static void /* PRIVATE */
|
||||||
png_default_warning(png_structp png_ptr, png_const_charp warning_message)
|
png_default_warning(png_const_structrp png_ptr, png_const_charp warning_message)
|
||||||
{
|
{
|
||||||
#ifdef PNG_CONSOLE_IO_SUPPORTED
|
#ifdef PNG_CONSOLE_IO_SUPPORTED
|
||||||
# ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
# ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
||||||
|
@ -632,15 +824,15 @@ png_default_warning(png_structp png_ptr, png_const_charp warning_message)
|
||||||
#endif
|
#endif
|
||||||
PNG_UNUSED(png_ptr) /* Make compiler happy */
|
PNG_UNUSED(png_ptr) /* Make compiler happy */
|
||||||
}
|
}
|
||||||
#endif /* PNG_WARNINGS_SUPPORTED */
|
#endif /* WARNINGS */
|
||||||
|
|
||||||
/* This function is called when the application wants to use another method
|
/* This function is called when the application wants to use another method
|
||||||
* of handling errors and warnings. Note that the error function MUST NOT
|
* of handling errors and warnings. Note that the error function MUST NOT
|
||||||
* return to the calling routine or serious problems will occur. The return
|
* return to the calling routine or serious problems will occur. The return
|
||||||
* method used in the default routine calls longjmp(png_ptr->longjmp_buffer, 1)
|
* method used in the default routine calls longjmp(png_ptr->jmp_buf_ptr, 1)
|
||||||
*/
|
*/
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_error_fn(png_structp png_ptr, png_voidp error_ptr,
|
png_set_error_fn(png_structrp png_ptr, png_voidp error_ptr,
|
||||||
png_error_ptr error_fn, png_error_ptr warning_fn)
|
png_error_ptr error_fn, png_error_ptr warning_fn)
|
||||||
{
|
{
|
||||||
if (png_ptr == NULL)
|
if (png_ptr == NULL)
|
||||||
|
@ -661,7 +853,7 @@ png_set_error_fn(png_structp png_ptr, png_voidp error_ptr,
|
||||||
* pointer before png_write_destroy and png_read_destroy are called.
|
* pointer before png_write_destroy and png_read_destroy are called.
|
||||||
*/
|
*/
|
||||||
png_voidp PNGAPI
|
png_voidp PNGAPI
|
||||||
png_get_error_ptr(png_const_structp png_ptr)
|
png_get_error_ptr(png_const_structrp png_ptr)
|
||||||
{
|
{
|
||||||
if (png_ptr == NULL)
|
if (png_ptr == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -672,7 +864,7 @@ png_get_error_ptr(png_const_structp png_ptr)
|
||||||
|
|
||||||
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_strip_error_numbers(png_structp png_ptr, png_uint_32 strip_mode)
|
png_set_strip_error_numbers(png_structrp png_ptr, png_uint_32 strip_mode)
|
||||||
{
|
{
|
||||||
if (png_ptr != NULL)
|
if (png_ptr != NULL)
|
||||||
{
|
{
|
||||||
|
@ -682,4 +874,90 @@ png_set_strip_error_numbers(png_structp png_ptr, png_uint_32 strip_mode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
|
||||||
|
#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\
|
||||||
|
defined(PNG_SIMPLIFIED_WRITE_SUPPORTED)
|
||||||
|
/* Currently the above both depend on SETJMP_SUPPORTED, however it would be
|
||||||
|
* possible to implement without setjmp support just so long as there is some
|
||||||
|
* way to handle the error return here:
|
||||||
|
*/
|
||||||
|
PNG_FUNCTION(void /* PRIVATE */, (PNGCBAPI
|
||||||
|
png_safe_error),(png_structp png_nonconst_ptr, png_const_charp error_message),
|
||||||
|
PNG_NORETURN)
|
||||||
|
{
|
||||||
|
const png_const_structrp png_ptr = png_nonconst_ptr;
|
||||||
|
png_imagep image = png_voidcast(png_imagep, png_ptr->error_ptr);
|
||||||
|
|
||||||
|
/* An error is always logged here, overwriting anything (typically a warning)
|
||||||
|
* that is already there:
|
||||||
|
*/
|
||||||
|
if (image != NULL)
|
||||||
|
{
|
||||||
|
png_safecat(image->message, (sizeof image->message), 0, error_message);
|
||||||
|
image->warning_or_error |= PNG_IMAGE_ERROR;
|
||||||
|
|
||||||
|
/* Retrieve the jmp_buf from within the png_control, making this work for
|
||||||
|
* C++ compilation too is pretty tricky: C++ wants a pointer to the first
|
||||||
|
* element of a jmp_buf, but C doesn't tell us the type of that.
|
||||||
|
*/
|
||||||
|
if (image->opaque != NULL && image->opaque->error_buf != NULL)
|
||||||
|
longjmp(png_control_jmp_buf(image->opaque), 1);
|
||||||
|
|
||||||
|
/* Missing longjmp buffer, the following is to help debugging: */
|
||||||
|
{
|
||||||
|
size_t pos = png_safecat(image->message, (sizeof image->message), 0,
|
||||||
|
"bad longjmp: ");
|
||||||
|
png_safecat(image->message, (sizeof image->message), pos,
|
||||||
|
error_message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Here on an internal programming error. */
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef PNG_WARNINGS_SUPPORTED
|
||||||
|
void /* PRIVATE */ PNGCBAPI
|
||||||
|
png_safe_warning(png_structp png_nonconst_ptr, png_const_charp warning_message)
|
||||||
|
{
|
||||||
|
const png_const_structrp png_ptr = png_nonconst_ptr;
|
||||||
|
png_imagep image = png_voidcast(png_imagep, png_ptr->error_ptr);
|
||||||
|
|
||||||
|
/* A warning is only logged if there is no prior warning or error. */
|
||||||
|
if (image->warning_or_error == 0)
|
||||||
|
{
|
||||||
|
png_safecat(image->message, (sizeof image->message), 0, warning_message);
|
||||||
|
image->warning_or_error |= PNG_IMAGE_WARNING;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int /* PRIVATE */
|
||||||
|
png_safe_execute(png_imagep image_in, int (*function)(png_voidp), png_voidp arg)
|
||||||
|
{
|
||||||
|
volatile png_imagep image = image_in;
|
||||||
|
volatile int result;
|
||||||
|
volatile png_voidp saved_error_buf;
|
||||||
|
jmp_buf safe_jmpbuf;
|
||||||
|
|
||||||
|
/* Safely execute function(arg) with png_error returning to this function. */
|
||||||
|
saved_error_buf = image->opaque->error_buf;
|
||||||
|
result = setjmp(safe_jmpbuf) == 0;
|
||||||
|
|
||||||
|
if (result != 0)
|
||||||
|
{
|
||||||
|
|
||||||
|
image->opaque->error_buf = safe_jmpbuf;
|
||||||
|
result = function(arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
image->opaque->error_buf = saved_error_buf;
|
||||||
|
|
||||||
|
/* And do the cleanup prior to any failure return. */
|
||||||
|
if (result == 0)
|
||||||
|
png_image_free(image);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
#endif /* SIMPLIFIED READ || SIMPLIFIED_WRITE */
|
||||||
|
#endif /* READ || WRITE */
|
File diff suppressed because it is too large
Load diff
|
@ -1,12 +1,11 @@
|
||||||
|
|
||||||
/* pnginfo.h - header file for PNG reference library
|
/* pnginfo.h - header file for PNG reference library
|
||||||
*
|
*
|
||||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
* Last changed in libpng 1.6.1 [March 28, 2013]
|
||||||
|
* Copyright (c) 1998-2002,2004,2006-2013 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.5.0 [January 6, 2011]
|
|
||||||
*
|
|
||||||
* This code is released under the libpng license.
|
* This code is released under the libpng license.
|
||||||
* For conditions of distribution and use, see the disclaimer
|
* For conditions of distribution and use, see the disclaimer
|
||||||
* and license in png.h
|
* and license in png.h
|
||||||
|
@ -55,7 +54,7 @@
|
||||||
|
|
||||||
struct png_info_def
|
struct png_info_def
|
||||||
{
|
{
|
||||||
/* the following are necessary for every PNG file */
|
/* The following are necessary for every PNG file */
|
||||||
png_uint_32 width; /* width of image in pixels (from IHDR) */
|
png_uint_32 width; /* width of image in pixels (from IHDR) */
|
||||||
png_uint_32 height; /* height of image in pixels (from IHDR) */
|
png_uint_32 height; /* height of image in pixels (from IHDR) */
|
||||||
png_uint_32 valid; /* valid chunk data (see PNG_INFO_ below) */
|
png_uint_32 valid; /* valid chunk data (see PNG_INFO_ below) */
|
||||||
|
@ -70,11 +69,17 @@ struct png_info_def
|
||||||
png_byte filter_type; /* must be PNG_FILTER_TYPE_BASE (from IHDR) */
|
png_byte filter_type; /* must be PNG_FILTER_TYPE_BASE (from IHDR) */
|
||||||
png_byte interlace_type; /* One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
|
png_byte interlace_type; /* One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
|
||||||
|
|
||||||
/* The following is informational only on read, and not used on writes. */
|
/* The following are set by png_set_IHDR, called from the application on
|
||||||
|
* write, but the are never actually used by the write code.
|
||||||
|
*/
|
||||||
png_byte channels; /* number of data channels per pixel (1, 2, 3, 4) */
|
png_byte channels; /* number of data channels per pixel (1, 2, 3, 4) */
|
||||||
png_byte pixel_depth; /* number of bits per pixel */
|
png_byte pixel_depth; /* number of bits per pixel */
|
||||||
png_byte spare_byte; /* to align the data, and for future use */
|
png_byte spare_byte; /* to align the data, and for future use */
|
||||||
|
|
||||||
|
#ifdef PNG_READ_SUPPORTED
|
||||||
|
/* This is never set during write */
|
||||||
png_byte signature[8]; /* magic bytes read by libpng from start of file */
|
png_byte signature[8]; /* magic bytes read by libpng from start of file */
|
||||||
|
#endif
|
||||||
|
|
||||||
/* The rest of the data is optional. If you are reading, check the
|
/* The rest of the data is optional. If you are reading, check the
|
||||||
* valid field to see if the information in these are valid. If you
|
* valid field to see if the information in these are valid. If you
|
||||||
|
@ -82,18 +87,25 @@ struct png_info_def
|
||||||
* and initialize the appropriate fields below.
|
* and initialize the appropriate fields below.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(PNG_gAMA_SUPPORTED)
|
#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)
|
||||||
/* The gAMA chunk describes the gamma characteristics of the system
|
/* png_colorspace only contains 'flags' if neither GAMMA or COLORSPACE are
|
||||||
* on which the image was created, normally in the range [1.0, 2.5].
|
* defined. When COLORSPACE is switched on all the colorspace-defining
|
||||||
* Data is valid if (valid & PNG_INFO_gAMA) is non-zero.
|
* chunks should be enabled, when GAMMA is switched on all the gamma-defining
|
||||||
|
* chunks should be enabled. If this is not done it becomes possible to read
|
||||||
|
* inconsistent PNG files and assign a probably incorrect interpretation to
|
||||||
|
* the information. (In other words, by carefully choosing which chunks to
|
||||||
|
* recognize the system configuration can select an interpretation for PNG
|
||||||
|
* files containing ambiguous data and this will result in inconsistent
|
||||||
|
* behavior between different libpng builds!)
|
||||||
*/
|
*/
|
||||||
png_fixed_point gamma;
|
png_colorspace colorspace;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_sRGB_SUPPORTED
|
#ifdef PNG_iCCP_SUPPORTED
|
||||||
/* GR-P, 0.96a */
|
/* iCCP chunk data. */
|
||||||
/* Data valid if (valid & PNG_INFO_sRGB) non-zero. */
|
png_charp iccp_name; /* profile name */
|
||||||
png_byte srgb_intent; /* sRGB rendering intent [0, 1, 2, or 3] */
|
png_bytep iccp_profile; /* International Color Consortium profile data */
|
||||||
|
png_uint_32 iccp_proflen; /* ICC profile data length */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_TEXT_SUPPORTED
|
#ifdef PNG_TEXT_SUPPORTED
|
||||||
|
@ -108,7 +120,7 @@ struct png_info_def
|
||||||
int num_text; /* number of comments read or comments to write */
|
int num_text; /* number of comments read or comments to write */
|
||||||
int max_text; /* current size of text array */
|
int max_text; /* current size of text array */
|
||||||
png_textp text; /* array of comments read or comments to write */
|
png_textp text; /* array of comments read or comments to write */
|
||||||
#endif /* PNG_TEXT_SUPPORTED */
|
#endif /* TEXT */
|
||||||
|
|
||||||
#ifdef PNG_tIME_SUPPORTED
|
#ifdef PNG_tIME_SUPPORTED
|
||||||
/* The tIME chunk holds the last time the displayed image data was
|
/* The tIME chunk holds the last time the displayed image data was
|
||||||
|
@ -183,23 +195,6 @@ defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||||
png_uint_16p hist;
|
png_uint_16p hist;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_cHRM_SUPPORTED
|
|
||||||
/* The cHRM chunk describes the CIE color characteristics of the monitor
|
|
||||||
* on which the PNG was created. This data allows the viewer to do gamut
|
|
||||||
* mapping of the input image to ensure that the viewer sees the same
|
|
||||||
* colors in the image as the creator. Values are in the range
|
|
||||||
* [0.0, 0.8]. Data valid if (valid & PNG_INFO_cHRM) non-zero.
|
|
||||||
*/
|
|
||||||
png_fixed_point x_white;
|
|
||||||
png_fixed_point y_white;
|
|
||||||
png_fixed_point x_red;
|
|
||||||
png_fixed_point y_red;
|
|
||||||
png_fixed_point x_green;
|
|
||||||
png_fixed_point y_green;
|
|
||||||
png_fixed_point x_blue;
|
|
||||||
png_fixed_point y_blue;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef PNG_pCAL_SUPPORTED
|
#ifdef PNG_pCAL_SUPPORTED
|
||||||
/* The pCAL chunk describes a transformation between the stored pixel
|
/* The pCAL chunk describes a transformation between the stored pixel
|
||||||
* values and original physical data values used to create the image.
|
* values and original physical data values used to create the image.
|
||||||
|
@ -224,25 +219,20 @@ defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||||
/* New members added in libpng-1.0.6 */
|
/* New members added in libpng-1.0.6 */
|
||||||
png_uint_32 free_me; /* flags items libpng is responsible for freeing */
|
png_uint_32 free_me; /* flags items libpng is responsible for freeing */
|
||||||
|
|
||||||
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) || \
|
#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
|
||||||
defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED)
|
|
||||||
/* Storage for unknown chunks that the library doesn't recognize. */
|
/* Storage for unknown chunks that the library doesn't recognize. */
|
||||||
png_unknown_chunkp unknown_chunks;
|
png_unknown_chunkp unknown_chunks;
|
||||||
int unknown_chunks_num;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef PNG_iCCP_SUPPORTED
|
/* The type of this field is limited by the type of
|
||||||
/* iCCP chunk data. */
|
* png_struct::user_chunk_cache_max, else overflow can occur.
|
||||||
png_charp iccp_name; /* profile name */
|
*/
|
||||||
png_bytep iccp_profile; /* International Color Consortium profile data */
|
int unknown_chunks_num;
|
||||||
png_uint_32 iccp_proflen; /* ICC profile data length */
|
|
||||||
png_byte iccp_compression; /* Always zero */
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_sPLT_SUPPORTED
|
#ifdef PNG_sPLT_SUPPORTED
|
||||||
/* Data on sPLT chunks (there may be more than one). */
|
/* Data on sPLT chunks (there may be more than one). */
|
||||||
png_sPLT_tp splt_palettes;
|
png_sPLT_tp splt_palettes;
|
||||||
png_uint_32 splt_palettes_num;
|
int splt_palettes_num; /* Match type returned by png_get API */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_sCAL_SUPPORTED
|
#ifdef PNG_sCAL_SUPPORTED
|
215
ExternalLibs/png/pnglibconf.h
Normal file
215
ExternalLibs/png/pnglibconf.h
Normal file
|
@ -0,0 +1,215 @@
|
||||||
|
/* libpng 1.6.25 STANDARD API DEFINITION */
|
||||||
|
|
||||||
|
/* pnglibconf.h - library build configuration */
|
||||||
|
|
||||||
|
/* Libpng version 1.6.25 - September 1, 2016 */
|
||||||
|
|
||||||
|
/* Copyright (c) 1998-2015 Glenn Randers-Pehrson */
|
||||||
|
|
||||||
|
/* This code is released under the libpng license. */
|
||||||
|
/* For conditions of distribution and use, see the disclaimer */
|
||||||
|
/* and license in png.h */
|
||||||
|
|
||||||
|
/* pnglibconf.h */
|
||||||
|
/* Machine generated file: DO NOT EDIT */
|
||||||
|
/* Derived from: scripts/pnglibconf.dfa */
|
||||||
|
#ifndef PNGLCONF_H
|
||||||
|
#define PNGLCONF_H
|
||||||
|
/* options */
|
||||||
|
#define PNG_16BIT_SUPPORTED
|
||||||
|
#define PNG_ALIGNED_MEMORY_SUPPORTED
|
||||||
|
/*#undef PNG_ARM_NEON_API_SUPPORTED*/
|
||||||
|
/*#undef PNG_ARM_NEON_CHECK_SUPPORTED*/
|
||||||
|
#define PNG_BENIGN_ERRORS_SUPPORTED
|
||||||
|
#define PNG_BENIGN_READ_ERRORS_SUPPORTED
|
||||||
|
/*#undef PNG_BENIGN_WRITE_ERRORS_SUPPORTED*/
|
||||||
|
#define PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED
|
||||||
|
#define PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||||
|
#define PNG_COLORSPACE_SUPPORTED
|
||||||
|
#define PNG_CONSOLE_IO_SUPPORTED
|
||||||
|
#define PNG_CONVERT_tIME_SUPPORTED
|
||||||
|
#define PNG_EASY_ACCESS_SUPPORTED
|
||||||
|
/*#undef PNG_ERROR_NUMBERS_SUPPORTED*/
|
||||||
|
#define PNG_ERROR_TEXT_SUPPORTED
|
||||||
|
#define PNG_FIXED_POINT_SUPPORTED
|
||||||
|
#define PNG_FLOATING_ARITHMETIC_SUPPORTED
|
||||||
|
#define PNG_FLOATING_POINT_SUPPORTED
|
||||||
|
#define PNG_FORMAT_AFIRST_SUPPORTED
|
||||||
|
#define PNG_FORMAT_BGR_SUPPORTED
|
||||||
|
#define PNG_GAMMA_SUPPORTED
|
||||||
|
#define PNG_GET_PALETTE_MAX_SUPPORTED
|
||||||
|
#define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||||
|
#define PNG_INCH_CONVERSIONS_SUPPORTED
|
||||||
|
#define PNG_INFO_IMAGE_SUPPORTED
|
||||||
|
#define PNG_IO_STATE_SUPPORTED
|
||||||
|
#define PNG_MNG_FEATURES_SUPPORTED
|
||||||
|
#define PNG_POINTER_INDEXING_SUPPORTED
|
||||||
|
#define PNG_PROGRESSIVE_READ_SUPPORTED
|
||||||
|
#define PNG_READ_16BIT_SUPPORTED
|
||||||
|
#define PNG_READ_ALPHA_MODE_SUPPORTED
|
||||||
|
#define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
|
||||||
|
#define PNG_READ_BACKGROUND_SUPPORTED
|
||||||
|
#define PNG_READ_BGR_SUPPORTED
|
||||||
|
#define PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||||
|
#define PNG_READ_COMPOSITE_NODIV_SUPPORTED
|
||||||
|
#define PNG_READ_COMPRESSED_TEXT_SUPPORTED
|
||||||
|
#define PNG_READ_EXPAND_16_SUPPORTED
|
||||||
|
#define PNG_READ_EXPAND_SUPPORTED
|
||||||
|
#define PNG_READ_FILLER_SUPPORTED
|
||||||
|
#define PNG_READ_GAMMA_SUPPORTED
|
||||||
|
#define PNG_READ_GET_PALETTE_MAX_SUPPORTED
|
||||||
|
#define PNG_READ_GRAY_TO_RGB_SUPPORTED
|
||||||
|
#define PNG_READ_INTERLACING_SUPPORTED
|
||||||
|
#define PNG_READ_INT_FUNCTIONS_SUPPORTED
|
||||||
|
#define PNG_READ_INVERT_ALPHA_SUPPORTED
|
||||||
|
#define PNG_READ_INVERT_SUPPORTED
|
||||||
|
#define PNG_READ_OPT_PLTE_SUPPORTED
|
||||||
|
#define PNG_READ_PACKSWAP_SUPPORTED
|
||||||
|
#define PNG_READ_PACK_SUPPORTED
|
||||||
|
#define PNG_READ_QUANTIZE_SUPPORTED
|
||||||
|
#define PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||||
|
#define PNG_READ_SCALE_16_TO_8_SUPPORTED
|
||||||
|
#define PNG_READ_SHIFT_SUPPORTED
|
||||||
|
#define PNG_READ_STRIP_16_TO_8_SUPPORTED
|
||||||
|
#define PNG_READ_STRIP_ALPHA_SUPPORTED
|
||||||
|
#define PNG_READ_SUPPORTED
|
||||||
|
#define PNG_READ_SWAP_ALPHA_SUPPORTED
|
||||||
|
#define PNG_READ_SWAP_SUPPORTED
|
||||||
|
#define PNG_READ_TEXT_SUPPORTED
|
||||||
|
#define PNG_READ_TRANSFORMS_SUPPORTED
|
||||||
|
#define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
|
||||||
|
#define PNG_READ_USER_CHUNKS_SUPPORTED
|
||||||
|
#define PNG_READ_USER_TRANSFORM_SUPPORTED
|
||||||
|
#define PNG_READ_bKGD_SUPPORTED
|
||||||
|
#define PNG_READ_cHRM_SUPPORTED
|
||||||
|
#define PNG_READ_gAMA_SUPPORTED
|
||||||
|
#define PNG_READ_hIST_SUPPORTED
|
||||||
|
#define PNG_READ_iCCP_SUPPORTED
|
||||||
|
#define PNG_READ_iTXt_SUPPORTED
|
||||||
|
#define PNG_READ_oFFs_SUPPORTED
|
||||||
|
#define PNG_READ_pCAL_SUPPORTED
|
||||||
|
#define PNG_READ_pHYs_SUPPORTED
|
||||||
|
#define PNG_READ_sBIT_SUPPORTED
|
||||||
|
#define PNG_READ_sCAL_SUPPORTED
|
||||||
|
#define PNG_READ_sPLT_SUPPORTED
|
||||||
|
#define PNG_READ_sRGB_SUPPORTED
|
||||||
|
#define PNG_READ_tEXt_SUPPORTED
|
||||||
|
#define PNG_READ_tIME_SUPPORTED
|
||||||
|
#define PNG_READ_tRNS_SUPPORTED
|
||||||
|
#define PNG_READ_zTXt_SUPPORTED
|
||||||
|
#define PNG_SAVE_INT_32_SUPPORTED
|
||||||
|
#define PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
|
||||||
|
#define PNG_SEQUENTIAL_READ_SUPPORTED
|
||||||
|
#define PNG_SETJMP_SUPPORTED
|
||||||
|
#define PNG_SET_OPTION_SUPPORTED
|
||||||
|
#define PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
|
||||||
|
#define PNG_SET_USER_LIMITS_SUPPORTED
|
||||||
|
#define PNG_SIMPLIFIED_READ_AFIRST_SUPPORTED
|
||||||
|
#define PNG_SIMPLIFIED_READ_BGR_SUPPORTED
|
||||||
|
#define PNG_SIMPLIFIED_READ_SUPPORTED
|
||||||
|
#define PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED
|
||||||
|
#define PNG_SIMPLIFIED_WRITE_BGR_SUPPORTED
|
||||||
|
#define PNG_SIMPLIFIED_WRITE_STDIO_SUPPORTED
|
||||||
|
#define PNG_SIMPLIFIED_WRITE_SUPPORTED
|
||||||
|
#define PNG_STDIO_SUPPORTED
|
||||||
|
#define PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
|
||||||
|
#define PNG_TEXT_SUPPORTED
|
||||||
|
#define PNG_TIME_RFC1123_SUPPORTED
|
||||||
|
#define PNG_UNKNOWN_CHUNKS_SUPPORTED
|
||||||
|
#define PNG_USER_CHUNKS_SUPPORTED
|
||||||
|
#define PNG_USER_LIMITS_SUPPORTED
|
||||||
|
#define PNG_USER_MEM_SUPPORTED
|
||||||
|
#define PNG_USER_TRANSFORM_INFO_SUPPORTED
|
||||||
|
#define PNG_USER_TRANSFORM_PTR_SUPPORTED
|
||||||
|
#define PNG_WARNINGS_SUPPORTED
|
||||||
|
#define PNG_WRITE_16BIT_SUPPORTED
|
||||||
|
#define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
|
||||||
|
#define PNG_WRITE_BGR_SUPPORTED
|
||||||
|
#define PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||||
|
#define PNG_WRITE_COMPRESSED_TEXT_SUPPORTED
|
||||||
|
#define PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED
|
||||||
|
#define PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
|
||||||
|
#define PNG_WRITE_FILLER_SUPPORTED
|
||||||
|
#define PNG_WRITE_FILTER_SUPPORTED
|
||||||
|
#define PNG_WRITE_FLUSH_SUPPORTED
|
||||||
|
#define PNG_WRITE_GET_PALETTE_MAX_SUPPORTED
|
||||||
|
#define PNG_WRITE_INTERLACING_SUPPORTED
|
||||||
|
#define PNG_WRITE_INT_FUNCTIONS_SUPPORTED
|
||||||
|
#define PNG_WRITE_INVERT_ALPHA_SUPPORTED
|
||||||
|
#define PNG_WRITE_INVERT_SUPPORTED
|
||||||
|
#define PNG_WRITE_OPTIMIZE_CMF_SUPPORTED
|
||||||
|
#define PNG_WRITE_PACKSWAP_SUPPORTED
|
||||||
|
#define PNG_WRITE_PACK_SUPPORTED
|
||||||
|
#define PNG_WRITE_SHIFT_SUPPORTED
|
||||||
|
#define PNG_WRITE_SUPPORTED
|
||||||
|
#define PNG_WRITE_SWAP_ALPHA_SUPPORTED
|
||||||
|
#define PNG_WRITE_SWAP_SUPPORTED
|
||||||
|
#define PNG_WRITE_TEXT_SUPPORTED
|
||||||
|
#define PNG_WRITE_TRANSFORMS_SUPPORTED
|
||||||
|
#define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
|
||||||
|
#define PNG_WRITE_USER_TRANSFORM_SUPPORTED
|
||||||
|
#define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
||||||
|
#define PNG_WRITE_bKGD_SUPPORTED
|
||||||
|
#define PNG_WRITE_cHRM_SUPPORTED
|
||||||
|
#define PNG_WRITE_gAMA_SUPPORTED
|
||||||
|
#define PNG_WRITE_hIST_SUPPORTED
|
||||||
|
#define PNG_WRITE_iCCP_SUPPORTED
|
||||||
|
#define PNG_WRITE_iTXt_SUPPORTED
|
||||||
|
#define PNG_WRITE_oFFs_SUPPORTED
|
||||||
|
#define PNG_WRITE_pCAL_SUPPORTED
|
||||||
|
#define PNG_WRITE_pHYs_SUPPORTED
|
||||||
|
#define PNG_WRITE_sBIT_SUPPORTED
|
||||||
|
#define PNG_WRITE_sCAL_SUPPORTED
|
||||||
|
#define PNG_WRITE_sPLT_SUPPORTED
|
||||||
|
#define PNG_WRITE_sRGB_SUPPORTED
|
||||||
|
#define PNG_WRITE_tEXt_SUPPORTED
|
||||||
|
#define PNG_WRITE_tIME_SUPPORTED
|
||||||
|
#define PNG_WRITE_tRNS_SUPPORTED
|
||||||
|
#define PNG_WRITE_zTXt_SUPPORTED
|
||||||
|
#define PNG_bKGD_SUPPORTED
|
||||||
|
#define PNG_cHRM_SUPPORTED
|
||||||
|
#define PNG_gAMA_SUPPORTED
|
||||||
|
#define PNG_hIST_SUPPORTED
|
||||||
|
#define PNG_iCCP_SUPPORTED
|
||||||
|
#define PNG_iTXt_SUPPORTED
|
||||||
|
#define PNG_oFFs_SUPPORTED
|
||||||
|
#define PNG_pCAL_SUPPORTED
|
||||||
|
#define PNG_pHYs_SUPPORTED
|
||||||
|
#define PNG_sBIT_SUPPORTED
|
||||||
|
#define PNG_sCAL_SUPPORTED
|
||||||
|
#define PNG_sPLT_SUPPORTED
|
||||||
|
#define PNG_sRGB_SUPPORTED
|
||||||
|
#define PNG_tEXt_SUPPORTED
|
||||||
|
#define PNG_tIME_SUPPORTED
|
||||||
|
#define PNG_tRNS_SUPPORTED
|
||||||
|
#define PNG_zTXt_SUPPORTED
|
||||||
|
/* end of options */
|
||||||
|
/* settings */
|
||||||
|
#define PNG_API_RULE 0
|
||||||
|
#define PNG_DEFAULT_READ_MACROS 1
|
||||||
|
#define PNG_GAMMA_THRESHOLD_FIXED 5000
|
||||||
|
#define PNG_IDAT_READ_SIZE PNG_ZBUF_SIZE
|
||||||
|
#define PNG_INFLATE_BUF_SIZE 1024
|
||||||
|
#define PNG_LINKAGE_API extern
|
||||||
|
#define PNG_LINKAGE_CALLBACK extern
|
||||||
|
#define PNG_LINKAGE_DATA extern
|
||||||
|
#define PNG_LINKAGE_FUNCTION extern
|
||||||
|
#define PNG_MAX_GAMMA_8 11
|
||||||
|
#define PNG_QUANTIZE_BLUE_BITS 5
|
||||||
|
#define PNG_QUANTIZE_GREEN_BITS 5
|
||||||
|
#define PNG_QUANTIZE_RED_BITS 5
|
||||||
|
#define PNG_TEXT_Z_DEFAULT_COMPRESSION (-1)
|
||||||
|
#define PNG_TEXT_Z_DEFAULT_STRATEGY 0
|
||||||
|
#define PNG_USER_CHUNK_CACHE_MAX 1000
|
||||||
|
#define PNG_USER_CHUNK_MALLOC_MAX 8000000
|
||||||
|
#define PNG_USER_HEIGHT_MAX 1000000
|
||||||
|
#define PNG_USER_WIDTH_MAX 1000000
|
||||||
|
#define PNG_ZBUF_SIZE 8192
|
||||||
|
#define PNG_ZLIB_VERNUM 0 /* unknown */
|
||||||
|
#define PNG_Z_DEFAULT_COMPRESSION (-1)
|
||||||
|
#define PNG_Z_DEFAULT_NOFILTER_STRATEGY 0
|
||||||
|
#define PNG_Z_DEFAULT_STRATEGY 1
|
||||||
|
#define PNG_sCAL_PRECISION 5
|
||||||
|
#define PNG_sRGB_PROFILE_CHECKS 2
|
||||||
|
/* end of settings */
|
||||||
|
#endif /* PNGLCONF_H */
|
284
ExternalLibs/png/pngmem.c
Normal file
284
ExternalLibs/png/pngmem.c
Normal file
|
@ -0,0 +1,284 @@
|
||||||
|
|
||||||
|
/* pngmem.c - stub functions for memory allocation
|
||||||
|
*
|
||||||
|
* Last changed in libpng 1.6.24 [August 4, 2016%]
|
||||||
|
* Copyright (c) 1998-2002,2004,2006-2014,2016 Glenn Randers-Pehrson
|
||||||
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
|
*
|
||||||
|
* This code is released under the libpng license.
|
||||||
|
* For conditions of distribution and use, see the disclaimer
|
||||||
|
* and license in png.h
|
||||||
|
*
|
||||||
|
* This file provides a location for all memory allocation. Users who
|
||||||
|
* need special memory handling are expected to supply replacement
|
||||||
|
* functions for png_malloc() and png_free(), and to use
|
||||||
|
* png_create_read_struct_2() and png_create_write_struct_2() to
|
||||||
|
* identify the replacement functions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "pngpriv.h"
|
||||||
|
|
||||||
|
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
||||||
|
/* Free a png_struct */
|
||||||
|
void /* PRIVATE */
|
||||||
|
png_destroy_png_struct(png_structrp png_ptr)
|
||||||
|
{
|
||||||
|
if (png_ptr != NULL)
|
||||||
|
{
|
||||||
|
/* png_free might call png_error and may certainly call
|
||||||
|
* png_get_mem_ptr, so fake a temporary png_struct to support this.
|
||||||
|
*/
|
||||||
|
png_struct dummy_struct = *png_ptr;
|
||||||
|
memset(png_ptr, 0, (sizeof *png_ptr));
|
||||||
|
png_free(&dummy_struct, png_ptr);
|
||||||
|
|
||||||
|
# ifdef PNG_SETJMP_SUPPORTED
|
||||||
|
/* We may have a jmp_buf left to deallocate. */
|
||||||
|
png_free_jmpbuf(&dummy_struct);
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Allocate memory. For reasonable files, size should never exceed
|
||||||
|
* 64K. However, zlib may allocate more than 64K if you don't tell
|
||||||
|
* it not to. See zconf.h and png.h for more information. zlib does
|
||||||
|
* need to allocate exactly 64K, so whatever you call here must
|
||||||
|
* have the ability to do that.
|
||||||
|
*/
|
||||||
|
PNG_FUNCTION(png_voidp,PNGAPI
|
||||||
|
png_calloc,(png_const_structrp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
||||||
|
{
|
||||||
|
png_voidp ret;
|
||||||
|
|
||||||
|
ret = png_malloc(png_ptr, size);
|
||||||
|
|
||||||
|
if (ret != NULL)
|
||||||
|
memset(ret, 0, size);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* png_malloc_base, an internal function added at libpng 1.6.0, does the work of
|
||||||
|
* allocating memory, taking into account limits and PNG_USER_MEM_SUPPORTED.
|
||||||
|
* Checking and error handling must happen outside this routine; it returns NULL
|
||||||
|
* if the allocation cannot be done (for any reason.)
|
||||||
|
*/
|
||||||
|
PNG_FUNCTION(png_voidp /* PRIVATE */,
|
||||||
|
png_malloc_base,(png_const_structrp png_ptr, png_alloc_size_t size),
|
||||||
|
PNG_ALLOCATED)
|
||||||
|
{
|
||||||
|
/* Moved to png_malloc_base from png_malloc_default in 1.6.0; the DOS
|
||||||
|
* allocators have also been removed in 1.6.0, so any 16-bit system now has
|
||||||
|
* to implement a user memory handler. This checks to be sure it isn't
|
||||||
|
* called with big numbers.
|
||||||
|
*/
|
||||||
|
#ifndef PNG_USER_MEM_SUPPORTED
|
||||||
|
PNG_UNUSED(png_ptr)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Some compilers complain that this is always true. However, it
|
||||||
|
* can be false when integer overflow happens.
|
||||||
|
*/
|
||||||
|
if (size > 0 && size <= PNG_SIZE_MAX
|
||||||
|
# ifdef PNG_MAX_MALLOC_64K
|
||||||
|
&& size <= 65536U
|
||||||
|
# endif
|
||||||
|
)
|
||||||
|
{
|
||||||
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
|
if (png_ptr != NULL && png_ptr->malloc_fn != NULL)
|
||||||
|
return png_ptr->malloc_fn(png_constcast(png_structrp,png_ptr), size);
|
||||||
|
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
return malloc((size_t)size); /* checked for truncation above */
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(PNG_TEXT_SUPPORTED) || defined(PNG_sPLT_SUPPORTED) ||\
|
||||||
|
defined(PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED)
|
||||||
|
/* This is really here only to work round a spurious warning in GCC 4.6 and 4.7
|
||||||
|
* that arises because of the checks in png_realloc_array that are repeated in
|
||||||
|
* png_malloc_array.
|
||||||
|
*/
|
||||||
|
static png_voidp
|
||||||
|
png_malloc_array_checked(png_const_structrp png_ptr, int nelements,
|
||||||
|
size_t element_size)
|
||||||
|
{
|
||||||
|
png_alloc_size_t req = nelements; /* known to be > 0 */
|
||||||
|
|
||||||
|
if (req <= PNG_SIZE_MAX/element_size)
|
||||||
|
return png_malloc_base(png_ptr, req * element_size);
|
||||||
|
|
||||||
|
/* The failure case when the request is too large */
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
PNG_FUNCTION(png_voidp /* PRIVATE */,
|
||||||
|
png_malloc_array,(png_const_structrp png_ptr, int nelements,
|
||||||
|
size_t element_size),PNG_ALLOCATED)
|
||||||
|
{
|
||||||
|
if (nelements <= 0 || element_size == 0)
|
||||||
|
png_error(png_ptr, "internal error: array alloc");
|
||||||
|
|
||||||
|
return png_malloc_array_checked(png_ptr, nelements, element_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
PNG_FUNCTION(png_voidp /* PRIVATE */,
|
||||||
|
png_realloc_array,(png_const_structrp png_ptr, png_const_voidp old_array,
|
||||||
|
int old_elements, int add_elements, size_t element_size),PNG_ALLOCATED)
|
||||||
|
{
|
||||||
|
/* These are internal errors: */
|
||||||
|
if (add_elements <= 0 || element_size == 0 || old_elements < 0 ||
|
||||||
|
(old_array == NULL && old_elements > 0))
|
||||||
|
png_error(png_ptr, "internal error: array realloc");
|
||||||
|
|
||||||
|
/* Check for overflow on the elements count (so the caller does not have to
|
||||||
|
* check.)
|
||||||
|
*/
|
||||||
|
if (add_elements <= INT_MAX - old_elements)
|
||||||
|
{
|
||||||
|
png_voidp new_array = png_malloc_array_checked(png_ptr,
|
||||||
|
old_elements+add_elements, element_size);
|
||||||
|
|
||||||
|
if (new_array != NULL)
|
||||||
|
{
|
||||||
|
/* Because png_malloc_array worked the size calculations below cannot
|
||||||
|
* overflow.
|
||||||
|
*/
|
||||||
|
if (old_elements > 0)
|
||||||
|
memcpy(new_array, old_array, element_size*(unsigned)old_elements);
|
||||||
|
|
||||||
|
memset((char*)new_array + element_size*(unsigned)old_elements, 0,
|
||||||
|
element_size*(unsigned)add_elements);
|
||||||
|
|
||||||
|
return new_array;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL; /* error */
|
||||||
|
}
|
||||||
|
#endif /* TEXT || sPLT || STORE_UNKNOWN_CHUNKS */
|
||||||
|
|
||||||
|
/* Various functions that have different error handling are derived from this.
|
||||||
|
* png_malloc always exists, but if PNG_USER_MEM_SUPPORTED is defined a separate
|
||||||
|
* function png_malloc_default is also provided.
|
||||||
|
*/
|
||||||
|
PNG_FUNCTION(png_voidp,PNGAPI
|
||||||
|
png_malloc,(png_const_structrp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
||||||
|
{
|
||||||
|
png_voidp ret;
|
||||||
|
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
ret = png_malloc_base(png_ptr, size);
|
||||||
|
|
||||||
|
if (ret == NULL)
|
||||||
|
png_error(png_ptr, "Out of memory"); /* 'm' means png_malloc */
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
|
PNG_FUNCTION(png_voidp,PNGAPI
|
||||||
|
png_malloc_default,(png_const_structrp png_ptr, png_alloc_size_t size),
|
||||||
|
PNG_ALLOCATED PNG_DEPRECATED)
|
||||||
|
{
|
||||||
|
png_voidp ret;
|
||||||
|
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
/* Passing 'NULL' here bypasses the application provided memory handler. */
|
||||||
|
ret = png_malloc_base(NULL/*use malloc*/, size);
|
||||||
|
|
||||||
|
if (ret == NULL)
|
||||||
|
png_error(png_ptr, "Out of Memory"); /* 'M' means png_malloc_default */
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
#endif /* USER_MEM */
|
||||||
|
|
||||||
|
/* This function was added at libpng version 1.2.3. The png_malloc_warn()
|
||||||
|
* function will issue a png_warning and return NULL instead of issuing a
|
||||||
|
* png_error, if it fails to allocate the requested memory.
|
||||||
|
*/
|
||||||
|
PNG_FUNCTION(png_voidp,PNGAPI
|
||||||
|
png_malloc_warn,(png_const_structrp png_ptr, png_alloc_size_t size),
|
||||||
|
PNG_ALLOCATED)
|
||||||
|
{
|
||||||
|
if (png_ptr != NULL)
|
||||||
|
{
|
||||||
|
png_voidp ret = png_malloc_base(png_ptr, size);
|
||||||
|
|
||||||
|
if (ret != NULL)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
png_warning(png_ptr, "Out of memory");
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Free a pointer allocated by png_malloc(). If ptr is NULL, return
|
||||||
|
* without taking any action.
|
||||||
|
*/
|
||||||
|
void PNGAPI
|
||||||
|
png_free(png_const_structrp png_ptr, png_voidp ptr)
|
||||||
|
{
|
||||||
|
if (png_ptr == NULL || ptr == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
|
if (png_ptr->free_fn != NULL)
|
||||||
|
png_ptr->free_fn(png_constcast(png_structrp,png_ptr), ptr);
|
||||||
|
|
||||||
|
else
|
||||||
|
png_free_default(png_ptr, ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
PNG_FUNCTION(void,PNGAPI
|
||||||
|
png_free_default,(png_const_structrp png_ptr, png_voidp ptr),PNG_DEPRECATED)
|
||||||
|
{
|
||||||
|
if (png_ptr == NULL || ptr == NULL)
|
||||||
|
return;
|
||||||
|
#endif /* USER_MEM */
|
||||||
|
|
||||||
|
free(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
|
/* This function is called when the application wants to use another method
|
||||||
|
* of allocating and freeing memory.
|
||||||
|
*/
|
||||||
|
void PNGAPI
|
||||||
|
png_set_mem_fn(png_structrp png_ptr, png_voidp mem_ptr, png_malloc_ptr
|
||||||
|
malloc_fn, png_free_ptr free_fn)
|
||||||
|
{
|
||||||
|
if (png_ptr != NULL)
|
||||||
|
{
|
||||||
|
png_ptr->mem_ptr = mem_ptr;
|
||||||
|
png_ptr->malloc_fn = malloc_fn;
|
||||||
|
png_ptr->free_fn = free_fn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* This function returns a pointer to the mem_ptr associated with the user
|
||||||
|
* functions. The application should free any memory associated with this
|
||||||
|
* pointer before png_write_destroy and png_read_destroy are called.
|
||||||
|
*/
|
||||||
|
png_voidp PNGAPI
|
||||||
|
png_get_mem_ptr(png_const_structrp png_ptr)
|
||||||
|
{
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return png_ptr->mem_ptr;
|
||||||
|
}
|
||||||
|
#endif /* USER_MEM */
|
||||||
|
#endif /* READ || WRITE */
|
File diff suppressed because it is too large
Load diff
1989
ExternalLibs/png/pngpriv.h
Normal file
1989
ExternalLibs/png/pngpriv.h
Normal file
File diff suppressed because it is too large
Load diff
4194
ExternalLibs/png/pngread.c
Normal file
4194
ExternalLibs/png/pngread.c
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,8 +1,8 @@
|
||||||
|
|
||||||
/* pngrio.c - functions for data input
|
/* pngrio.c - functions for data input
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.5.0 [January 6, 2011]
|
* Last changed in libpng 1.6.24 [August 4, 2016]
|
||||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
|
@ -26,10 +26,10 @@
|
||||||
* reads from a file pointer. Note that this routine sometimes gets called
|
* reads from a file pointer. Note that this routine sometimes gets called
|
||||||
* with very small lengths, so you should implement some kind of simple
|
* with very small lengths, so you should implement some kind of simple
|
||||||
* buffering if you are using unbuffered reads. This should never be asked
|
* buffering if you are using unbuffered reads. This should never be asked
|
||||||
* to read more then 64K on a 16 bit machine.
|
* to read more than 64K on a 16-bit machine.
|
||||||
*/
|
*/
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
png_read_data(png_structrp png_ptr, png_bytep data, png_size_t length)
|
||||||
{
|
{
|
||||||
png_debug1(4, "reading %d bytes", (int)length);
|
png_debug1(4, "reading %d bytes", (int)length);
|
||||||
|
|
||||||
|
@ -46,7 +46,6 @@ png_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||||
* read_data function and use it at run time with png_set_read_fn(), rather
|
* read_data function and use it at run time with png_set_read_fn(), rather
|
||||||
* than changing the library.
|
* than changing the library.
|
||||||
*/
|
*/
|
||||||
# ifndef USE_FAR_KEYWORD
|
|
||||||
void PNGCBAPI
|
void PNGCBAPI
|
||||||
png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||||
{
|
{
|
||||||
|
@ -58,68 +57,11 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||||
/* fread() returns 0 on error, so it is OK to store this in a png_size_t
|
/* fread() returns 0 on error, so it is OK to store this in a png_size_t
|
||||||
* instead of an int, which is what fread() actually returns.
|
* instead of an int, which is what fread() actually returns.
|
||||||
*/
|
*/
|
||||||
check = fread(data, 1, length, (png_FILE_p)png_ptr->io_ptr);
|
check = fread(data, 1, length, png_voidcast(png_FILE_p, png_ptr->io_ptr));
|
||||||
|
|
||||||
if (check != length)
|
if (check != length)
|
||||||
png_error(png_ptr, "Read Error");
|
png_error(png_ptr, "Read Error");
|
||||||
}
|
}
|
||||||
# else
|
|
||||||
/* This is the model-independent version. Since the standard I/O library
|
|
||||||
can't handle far buffers in the medium and small models, we have to copy
|
|
||||||
the data.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define NEAR_BUF_SIZE 1024
|
|
||||||
#define MIN(a,b) (a <= b ? a : b)
|
|
||||||
|
|
||||||
static void PNGCBAPI
|
|
||||||
png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
|
||||||
{
|
|
||||||
png_size_t check;
|
|
||||||
png_byte *n_data;
|
|
||||||
png_FILE_p io_ptr;
|
|
||||||
|
|
||||||
if (png_ptr == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* Check if data really is near. If so, use usual code. */
|
|
||||||
n_data = (png_byte *)CVT_PTR_NOCHECK(data);
|
|
||||||
io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr);
|
|
||||||
|
|
||||||
if ((png_bytep)n_data == data)
|
|
||||||
{
|
|
||||||
check = fread(n_data, 1, length, io_ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
png_byte buf[NEAR_BUF_SIZE];
|
|
||||||
png_size_t read, remaining, err;
|
|
||||||
check = 0;
|
|
||||||
remaining = length;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
read = MIN(NEAR_BUF_SIZE, remaining);
|
|
||||||
err = fread(buf, 1, read, io_ptr);
|
|
||||||
png_memcpy(data, buf, read); /* copy far buffer to near buffer */
|
|
||||||
|
|
||||||
if (err != read)
|
|
||||||
break;
|
|
||||||
|
|
||||||
else
|
|
||||||
check += err;
|
|
||||||
|
|
||||||
data += read;
|
|
||||||
remaining -= read;
|
|
||||||
}
|
|
||||||
while (remaining != 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((png_uint_32)check != (png_uint_32)length)
|
|
||||||
png_error(png_ptr, "read Error");
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* This function allows the application to supply a new input function
|
/* This function allows the application to supply a new input function
|
||||||
|
@ -142,7 +84,7 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||||
* be used.
|
* be used.
|
||||||
*/
|
*/
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_read_fn(png_structp png_ptr, png_voidp io_ptr,
|
png_set_read_fn(png_structrp png_ptr, png_voidp io_ptr,
|
||||||
png_rw_ptr read_data_fn)
|
png_rw_ptr read_data_fn)
|
||||||
{
|
{
|
||||||
if (png_ptr == NULL)
|
if (png_ptr == NULL)
|
||||||
|
@ -160,6 +102,7 @@ png_set_read_fn(png_structp png_ptr, png_voidp io_ptr,
|
||||||
png_ptr->read_data_fn = read_data_fn;
|
png_ptr->read_data_fn = read_data_fn;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef PNG_WRITE_SUPPORTED
|
||||||
/* It is an error to write to a read device */
|
/* It is an error to write to a read device */
|
||||||
if (png_ptr->write_data_fn != NULL)
|
if (png_ptr->write_data_fn != NULL)
|
||||||
{
|
{
|
||||||
|
@ -168,9 +111,10 @@ png_set_read_fn(png_structp png_ptr, png_voidp io_ptr,
|
||||||
"Can't set both read_data_fn and write_data_fn in the"
|
"Can't set both read_data_fn and write_data_fn in the"
|
||||||
" same structure");
|
" same structure");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_WRITE_FLUSH_SUPPORTED
|
#ifdef PNG_WRITE_FLUSH_SUPPORTED
|
||||||
png_ptr->output_flush_fn = NULL;
|
png_ptr->output_flush_fn = NULL;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif /* PNG_READ_SUPPORTED */
|
#endif /* READ */
|
File diff suppressed because it is too large
Load diff
4531
ExternalLibs/png/pngrutil.c
Normal file
4531
ExternalLibs/png/pngrutil.c
Normal file
File diff suppressed because it is too large
Load diff
1737
ExternalLibs/png/pngset.c
Normal file
1737
ExternalLibs/png/pngset.c
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,12 +1,11 @@
|
||||||
|
|
||||||
/* pngstruct.h - header file for PNG reference library
|
/* pngstruct.h - header file for PNG reference library
|
||||||
*
|
*
|
||||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
* Last changed in libpng 1.6.24 [August 4, 2016]
|
||||||
|
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.5.9 [February 18, 2012]
|
|
||||||
*
|
|
||||||
* This code is released under the libpng license.
|
* This code is released under the libpng license.
|
||||||
* For conditions of distribution and use, see the disclaimer
|
* For conditions of distribution and use, see the disclaimer
|
||||||
* and license in png.h
|
* and license in png.h
|
||||||
|
@ -24,13 +23,130 @@
|
||||||
* in this structure and is required for decompressing the LZ compressed
|
* in this structure and is required for decompressing the LZ compressed
|
||||||
* data in PNG files.
|
* data in PNG files.
|
||||||
*/
|
*/
|
||||||
|
#ifndef ZLIB_CONST
|
||||||
|
/* We must ensure that zlib uses 'const' in declarations. */
|
||||||
|
# define ZLIB_CONST
|
||||||
|
#endif
|
||||||
#include "zlib.h"
|
#include "zlib.h"
|
||||||
|
#ifdef const
|
||||||
|
/* zlib.h sometimes #defines const to nothing, undo this. */
|
||||||
|
# undef const
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* zlib.h has mediocre z_const use before 1.2.6, this stuff is for compatibility
|
||||||
|
* with older builds.
|
||||||
|
*/
|
||||||
|
#if ZLIB_VERNUM < 0x1260
|
||||||
|
# define PNGZ_MSG_CAST(s) png_constcast(char*,s)
|
||||||
|
# define PNGZ_INPUT_CAST(b) png_constcast(png_bytep,b)
|
||||||
|
#else
|
||||||
|
# define PNGZ_MSG_CAST(s) (s)
|
||||||
|
# define PNGZ_INPUT_CAST(b) (b)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* zlib.h declares a magic type 'uInt' that limits the amount of data that zlib
|
||||||
|
* can handle at once. This type need be no larger than 16 bits (so maximum of
|
||||||
|
* 65535), this define allows us to discover how big it is, but limited by the
|
||||||
|
* maximuum for png_size_t. The value can be overriden in a library build
|
||||||
|
* (pngusr.h, or set it in CPPFLAGS) and it works to set it to a considerably
|
||||||
|
* lower value (e.g. 255 works). A lower value may help memory usage (slightly)
|
||||||
|
* and may even improve performance on some systems (and degrade it on others.)
|
||||||
|
*/
|
||||||
|
#ifndef ZLIB_IO_MAX
|
||||||
|
# define ZLIB_IO_MAX ((uInt)-1)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef PNG_WRITE_SUPPORTED
|
||||||
|
/* The type of a compression buffer list used by the write code. */
|
||||||
|
typedef struct png_compression_buffer
|
||||||
|
{
|
||||||
|
struct png_compression_buffer *next;
|
||||||
|
png_byte output[1]; /* actually zbuf_size */
|
||||||
|
} png_compression_buffer, *png_compression_bufferp;
|
||||||
|
|
||||||
|
#define PNG_COMPRESSION_BUFFER_SIZE(pp)\
|
||||||
|
(offsetof(png_compression_buffer, output) + (pp)->zbuffer_size)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Colorspace support; structures used in png_struct, png_info and in internal
|
||||||
|
* functions to hold and communicate information about the color space.
|
||||||
|
*
|
||||||
|
* PNG_COLORSPACE_SUPPORTED is only required if the application will perform
|
||||||
|
* colorspace corrections, otherwise all the colorspace information can be
|
||||||
|
* skipped and the size of libpng can be reduced (significantly) by compiling
|
||||||
|
* out the colorspace support.
|
||||||
|
*/
|
||||||
|
#ifdef PNG_COLORSPACE_SUPPORTED
|
||||||
|
/* The chromaticities of the red, green and blue colorants and the chromaticity
|
||||||
|
* of the corresponding white point (i.e. of rgb(1.0,1.0,1.0)).
|
||||||
|
*/
|
||||||
|
typedef struct png_xy
|
||||||
|
{
|
||||||
|
png_fixed_point redx, redy;
|
||||||
|
png_fixed_point greenx, greeny;
|
||||||
|
png_fixed_point bluex, bluey;
|
||||||
|
png_fixed_point whitex, whitey;
|
||||||
|
} png_xy;
|
||||||
|
|
||||||
|
/* The same data as above but encoded as CIE XYZ values. When this data comes
|
||||||
|
* from chromaticities the sum of the Y values is assumed to be 1.0
|
||||||
|
*/
|
||||||
|
typedef struct png_XYZ
|
||||||
|
{
|
||||||
|
png_fixed_point red_X, red_Y, red_Z;
|
||||||
|
png_fixed_point green_X, green_Y, green_Z;
|
||||||
|
png_fixed_point blue_X, blue_Y, blue_Z;
|
||||||
|
} png_XYZ;
|
||||||
|
#endif /* COLORSPACE */
|
||||||
|
|
||||||
|
#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)
|
||||||
|
/* A colorspace is all the above plus, potentially, profile information;
|
||||||
|
* however at present libpng does not use the profile internally so it is only
|
||||||
|
* stored in the png_info struct (if iCCP is supported.) The rendering intent
|
||||||
|
* is retained here and is checked.
|
||||||
|
*
|
||||||
|
* The file gamma encoding information is also stored here and gamma correction
|
||||||
|
* is done by libpng, whereas color correction must currently be done by the
|
||||||
|
* application.
|
||||||
|
*/
|
||||||
|
typedef struct png_colorspace
|
||||||
|
{
|
||||||
|
#ifdef PNG_GAMMA_SUPPORTED
|
||||||
|
png_fixed_point gamma; /* File gamma */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef PNG_COLORSPACE_SUPPORTED
|
||||||
|
png_xy end_points_xy; /* End points as chromaticities */
|
||||||
|
png_XYZ end_points_XYZ; /* End points as CIE XYZ colorant values */
|
||||||
|
png_uint_16 rendering_intent; /* Rendering intent of a profile */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Flags are always defined to simplify the code. */
|
||||||
|
png_uint_16 flags; /* As defined below */
|
||||||
|
} png_colorspace, * PNG_RESTRICT png_colorspacerp;
|
||||||
|
|
||||||
|
typedef const png_colorspace * PNG_RESTRICT png_const_colorspacerp;
|
||||||
|
|
||||||
|
/* General flags for the 'flags' field */
|
||||||
|
#define PNG_COLORSPACE_HAVE_GAMMA 0x0001
|
||||||
|
#define PNG_COLORSPACE_HAVE_ENDPOINTS 0x0002
|
||||||
|
#define PNG_COLORSPACE_HAVE_INTENT 0x0004
|
||||||
|
#define PNG_COLORSPACE_FROM_gAMA 0x0008
|
||||||
|
#define PNG_COLORSPACE_FROM_cHRM 0x0010
|
||||||
|
#define PNG_COLORSPACE_FROM_sRGB 0x0020
|
||||||
|
#define PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB 0x0040
|
||||||
|
#define PNG_COLORSPACE_MATCHES_sRGB 0x0080 /* exact match on profile */
|
||||||
|
#define PNG_COLORSPACE_INVALID 0x8000
|
||||||
|
#define PNG_COLORSPACE_CANCEL(flags) (0xffff ^ (flags))
|
||||||
|
#endif /* COLORSPACE || GAMMA */
|
||||||
|
|
||||||
struct png_struct_def
|
struct png_struct_def
|
||||||
{
|
{
|
||||||
#ifdef PNG_SETJMP_SUPPORTED
|
#ifdef PNG_SETJMP_SUPPORTED
|
||||||
jmp_buf longjmp_buffer; /* used in png_error */
|
jmp_buf jmp_buf_local; /* New name in 1.6.0 for jmp_buf in png_struct */
|
||||||
png_longjmp_ptr longjmp_fn;/* setjmp non-local goto function. */
|
png_longjmp_ptr longjmp_fn;/* setjmp non-local goto function. */
|
||||||
|
jmp_buf *jmp_buf_ptr; /* passed to longjmp_fn */
|
||||||
|
size_t jmp_buf_size; /* size of the above, if allocated */
|
||||||
#endif
|
#endif
|
||||||
png_error_ptr error_fn; /* function for printing errors and aborting */
|
png_error_ptr error_fn; /* function for printing errors and aborting */
|
||||||
#ifdef PNG_WARNINGS_SUPPORTED
|
#ifdef PNG_WARNINGS_SUPPORTED
|
||||||
|
@ -63,22 +179,12 @@ struct png_struct_def
|
||||||
png_uint_32 flags; /* flags indicating various things to libpng */
|
png_uint_32 flags; /* flags indicating various things to libpng */
|
||||||
png_uint_32 transformations; /* which transformations to perform */
|
png_uint_32 transformations; /* which transformations to perform */
|
||||||
|
|
||||||
z_stream zstream; /* pointer to decompression structure (below) */
|
png_uint_32 zowner; /* ID (chunk type) of zstream owner, 0 if none */
|
||||||
png_bytep zbuf; /* buffer for zlib */
|
z_stream zstream; /* decompression structure */
|
||||||
uInt zbuf_size; /* size of zbuf (typically 65536) */
|
|
||||||
#ifdef PNG_WRITE_SUPPORTED
|
#ifdef PNG_WRITE_SUPPORTED
|
||||||
|
png_compression_bufferp zbuffer_list; /* Created on demand during write */
|
||||||
/* Added in 1.5.4: state to keep track of whether the zstream has been
|
uInt zbuffer_size; /* size of the actual buffer */
|
||||||
* initialized and if so whether it is for IDAT or some other chunk.
|
|
||||||
*/
|
|
||||||
#define PNG_ZLIB_UNINITIALIZED 0
|
|
||||||
#define PNG_ZLIB_FOR_IDAT 1
|
|
||||||
#define PNG_ZLIB_FOR_TEXT 2 /* anything other than IDAT */
|
|
||||||
#define PNG_ZLIB_USE_MASK 3 /* bottom two bits */
|
|
||||||
#define PNG_ZLIB_IN_USE 4 /* a flag value */
|
|
||||||
|
|
||||||
png_uint_32 zlib_state; /* State of zlib initialization */
|
|
||||||
/* End of material added at libpng 1.5.4 */
|
|
||||||
|
|
||||||
int zlib_level; /* holds zlib compression level */
|
int zlib_level; /* holds zlib compression level */
|
||||||
int zlib_method; /* holds zlib compression method */
|
int zlib_method; /* holds zlib compression method */
|
||||||
|
@ -87,8 +193,7 @@ struct png_struct_def
|
||||||
int zlib_strategy; /* holds zlib compression strategy */
|
int zlib_strategy; /* holds zlib compression strategy */
|
||||||
#endif
|
#endif
|
||||||
/* Added at libpng 1.5.4 */
|
/* Added at libpng 1.5.4 */
|
||||||
#if defined(PNG_WRITE_COMPRESSED_TEXT_SUPPORTED) || \
|
#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
|
||||||
defined(PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED)
|
|
||||||
int zlib_text_level; /* holds zlib compression level */
|
int zlib_text_level; /* holds zlib compression level */
|
||||||
int zlib_text_method; /* holds zlib compression method */
|
int zlib_text_method; /* holds zlib compression method */
|
||||||
int zlib_text_window_bits; /* holds zlib compression window bits */
|
int zlib_text_window_bits; /* holds zlib compression window bits */
|
||||||
|
@ -96,6 +201,14 @@ struct png_struct_def
|
||||||
int zlib_text_strategy; /* holds zlib compression strategy */
|
int zlib_text_strategy; /* holds zlib compression strategy */
|
||||||
#endif
|
#endif
|
||||||
/* End of material added at libpng 1.5.4 */
|
/* End of material added at libpng 1.5.4 */
|
||||||
|
/* Added at libpng 1.6.0 */
|
||||||
|
#ifdef PNG_WRITE_SUPPORTED
|
||||||
|
int zlib_set_level; /* Actual values set into the zstream on write */
|
||||||
|
int zlib_set_method;
|
||||||
|
int zlib_set_window_bits;
|
||||||
|
int zlib_set_mem_level;
|
||||||
|
int zlib_set_strategy;
|
||||||
|
#endif
|
||||||
|
|
||||||
png_uint_32 width; /* width of image in pixels */
|
png_uint_32 width; /* width of image in pixels */
|
||||||
png_uint_32 height; /* height of image in pixels */
|
png_uint_32 height; /* height of image in pixels */
|
||||||
|
@ -106,15 +219,19 @@ struct png_struct_def
|
||||||
png_uint_32 row_number; /* current row in interlace pass */
|
png_uint_32 row_number; /* current row in interlace pass */
|
||||||
png_uint_32 chunk_name; /* PNG_CHUNK() id of current chunk */
|
png_uint_32 chunk_name; /* PNG_CHUNK() id of current chunk */
|
||||||
png_bytep prev_row; /* buffer to save previous (unfiltered) row.
|
png_bytep prev_row; /* buffer to save previous (unfiltered) row.
|
||||||
* This is a pointer into big_prev_row
|
* While reading this is a pointer into
|
||||||
|
* big_prev_row; while writing it is separately
|
||||||
|
* allocated if needed.
|
||||||
*/
|
*/
|
||||||
png_bytep row_buf; /* buffer to save current (unfiltered) row.
|
png_bytep row_buf; /* buffer to save current (unfiltered) row.
|
||||||
* This is a pointer into big_row_buf
|
* While reading, this is a pointer into
|
||||||
|
* big_row_buf; while writing it is separately
|
||||||
|
* allocated.
|
||||||
*/
|
*/
|
||||||
png_bytep sub_row; /* buffer to save "sub" row when filtering */
|
#ifdef PNG_WRITE_FILTER_SUPPORTED
|
||||||
png_bytep up_row; /* buffer to save "up" row when filtering */
|
png_bytep try_row; /* buffer to save trial row when filtering */
|
||||||
png_bytep avg_row; /* buffer to save "avg" row when filtering */
|
png_bytep tst_row; /* buffer to save best trial row when filtering */
|
||||||
png_bytep paeth_row; /* buffer to save "Paeth" row when filtering */
|
#endif
|
||||||
png_size_t info_rowbytes; /* Added in 1.5.4: cache of updated row bytes */
|
png_size_t info_rowbytes; /* Added in 1.5.4: cache of updated row bytes */
|
||||||
|
|
||||||
png_uint_32 idat_size; /* current IDAT size for read */
|
png_uint_32 idat_size; /* current IDAT size for read */
|
||||||
|
@ -132,21 +249,23 @@ struct png_struct_def
|
||||||
png_byte filter; /* file filter type (always 0) */
|
png_byte filter; /* file filter type (always 0) */
|
||||||
png_byte interlaced; /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
|
png_byte interlaced; /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
|
||||||
png_byte pass; /* current interlace pass (0 - 6) */
|
png_byte pass; /* current interlace pass (0 - 6) */
|
||||||
png_byte do_filter; /* row filter flags (see PNG_FILTER_ below ) */
|
png_byte do_filter; /* row filter flags (see PNG_FILTER_ in png.h ) */
|
||||||
png_byte color_type; /* color type of file */
|
png_byte color_type; /* color type of file */
|
||||||
png_byte bit_depth; /* bit depth of file */
|
png_byte bit_depth; /* bit depth of file */
|
||||||
png_byte usr_bit_depth; /* bit depth of users row: write only */
|
png_byte usr_bit_depth; /* bit depth of users row: write only */
|
||||||
png_byte pixel_depth; /* number of bits per pixel */
|
png_byte pixel_depth; /* number of bits per pixel */
|
||||||
png_byte channels; /* number of channels in file */
|
png_byte channels; /* number of channels in file */
|
||||||
|
#ifdef PNG_WRITE_SUPPORTED
|
||||||
png_byte usr_channels; /* channels at start of write: write only */
|
png_byte usr_channels; /* channels at start of write: write only */
|
||||||
|
#endif
|
||||||
png_byte sig_bytes; /* magic bytes read/written from start of file */
|
png_byte sig_bytes; /* magic bytes read/written from start of file */
|
||||||
png_byte maximum_pixel_depth;
|
png_byte maximum_pixel_depth;
|
||||||
/* pixel depth used for the row buffers */
|
/* pixel depth used for the row buffers */
|
||||||
png_byte transformed_pixel_depth;
|
png_byte transformed_pixel_depth;
|
||||||
/* pixel depth after read/write transforms */
|
/* pixel depth after read/write transforms */
|
||||||
png_byte io_chunk_string[5];
|
#if PNG_ZLIB_VERNUM >= 0x1240
|
||||||
/* string name of chunk */
|
png_byte zstream_start; /* at start of an input zlib stream */
|
||||||
|
#endif /* Zlib >= 1.2.4 */
|
||||||
#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
|
#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
|
||||||
png_uint_16 filler; /* filler bytes for pixel expansion */
|
png_uint_16 filler; /* filler bytes for pixel expansion */
|
||||||
#endif
|
#endif
|
||||||
|
@ -159,7 +278,7 @@ struct png_struct_def
|
||||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||||
png_color_16 background_1; /* background normalized to gamma 1.0 */
|
png_color_16 background_1; /* background normalized to gamma 1.0 */
|
||||||
#endif
|
#endif
|
||||||
#endif /* PNG_bKGD_SUPPORTED */
|
#endif /* bKGD */
|
||||||
|
|
||||||
#ifdef PNG_WRITE_FLUSH_SUPPORTED
|
#ifdef PNG_WRITE_FLUSH_SUPPORTED
|
||||||
png_flush_ptr output_flush_fn; /* Function for flushing output */
|
png_flush_ptr output_flush_fn; /* Function for flushing output */
|
||||||
|
@ -169,7 +288,6 @@ struct png_struct_def
|
||||||
|
|
||||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||||
int gamma_shift; /* number of "insignificant" bits in 16-bit gamma */
|
int gamma_shift; /* number of "insignificant" bits in 16-bit gamma */
|
||||||
png_fixed_point gamma; /* file gamma value */
|
|
||||||
png_fixed_point screen_gamma; /* screen gamma value (display_exponent) */
|
png_fixed_point screen_gamma; /* screen gamma value (display_exponent) */
|
||||||
|
|
||||||
png_bytep gamma_table; /* gamma table for 8-bit depth files */
|
png_bytep gamma_table; /* gamma table for 8-bit depth files */
|
||||||
|
@ -217,7 +335,7 @@ struct png_struct_def
|
||||||
int process_mode; /* what push library is currently doing */
|
int process_mode; /* what push library is currently doing */
|
||||||
int cur_palette; /* current push library palette index */
|
int cur_palette; /* current push library palette index */
|
||||||
|
|
||||||
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
|
#endif /* PROGRESSIVE_READ */
|
||||||
|
|
||||||
#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
|
#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
|
||||||
/* For the Borland special 64K segment handler */
|
/* For the Borland special 64K segment handler */
|
||||||
|
@ -233,24 +351,17 @@ struct png_struct_def
|
||||||
png_bytep quantize_index; /* index translation for palette files */
|
png_bytep quantize_index; /* index translation for palette files */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PNG_READ_QUANTIZE_SUPPORTED) || defined(PNG_hIST_SUPPORTED)
|
/* Options */
|
||||||
png_uint_16p hist; /* histogram */
|
#ifdef PNG_SET_OPTION_SUPPORTED
|
||||||
#endif
|
png_byte options; /* On/off state (up to 4 options) */
|
||||||
|
|
||||||
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
|
||||||
png_byte heuristic_method; /* heuristic for row filter selection */
|
|
||||||
png_byte num_prev_filters; /* number of weights for previous rows */
|
|
||||||
png_bytep prev_filters; /* filter type(s) of previous row(s) */
|
|
||||||
png_uint_16p filter_weights; /* weight(s) for previous line(s) */
|
|
||||||
png_uint_16p inv_filter_weights; /* 1/weight(s) for previous line(s) */
|
|
||||||
png_uint_16p filter_costs; /* relative filter calculation cost */
|
|
||||||
png_uint_16p inv_filter_costs; /* 1/relative filter calculation cost */
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if PNG_LIBPNG_VER < 10700
|
||||||
|
/* To do: remove this from libpng-1.7 */
|
||||||
#ifdef PNG_TIME_RFC1123_SUPPORTED
|
#ifdef PNG_TIME_RFC1123_SUPPORTED
|
||||||
/* This is going to be unused in libpng16 and removed from libpng17 */
|
|
||||||
char time_buffer[29]; /* String to hold RFC 1123 time text */
|
char time_buffer[29]; /* String to hold RFC 1123 time text */
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
/* New members added in libpng-1.0.6 */
|
/* New members added in libpng-1.0.6 */
|
||||||
|
|
||||||
|
@ -258,17 +369,16 @@ struct png_struct_def
|
||||||
|
|
||||||
#ifdef PNG_USER_CHUNKS_SUPPORTED
|
#ifdef PNG_USER_CHUNKS_SUPPORTED
|
||||||
png_voidp user_chunk_ptr;
|
png_voidp user_chunk_ptr;
|
||||||
|
#ifdef PNG_READ_USER_CHUNKS_SUPPORTED
|
||||||
png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */
|
png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
|
||||||
int num_chunk_list;
|
|
||||||
png_bytep chunk_list;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_READ_sRGB_SUPPORTED
|
#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
|
||||||
/* Added in 1.5.5 to record an sRGB chunk in the png. */
|
int unknown_default; /* As PNG_HANDLE_* */
|
||||||
png_byte is_sRGB;
|
unsigned int num_chunk_list; /* Number of entries in the list */
|
||||||
|
png_bytep chunk_list; /* List of png_byte[5]; the textual chunk name
|
||||||
|
* followed by a PNG_HANDLE_* byte */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* New members added in libpng-1.0.3 */
|
/* New members added in libpng-1.0.3 */
|
||||||
|
@ -333,16 +443,24 @@ struct png_struct_def
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* New member added in libpng-1.0.25 and 1.2.17 */
|
/* New member added in libpng-1.0.25 and 1.2.17 */
|
||||||
#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
|
#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
|
||||||
/* Storage for unknown chunk that the library doesn't recognize. */
|
/* Temporary storage for unknown chunk that the library doesn't recognize,
|
||||||
|
* used while reading the chunk.
|
||||||
|
*/
|
||||||
png_unknown_chunk unknown_chunk;
|
png_unknown_chunk unknown_chunk;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* New member added in libpng-1.2.26 */
|
/* New member added in libpng-1.2.26 */
|
||||||
png_size_t old_big_row_buf_size;
|
png_size_t old_big_row_buf_size;
|
||||||
|
|
||||||
|
#ifdef PNG_READ_SUPPORTED
|
||||||
/* New member added in libpng-1.2.30 */
|
/* New member added in libpng-1.2.30 */
|
||||||
png_charp chunkdata; /* buffer for reading chunk data */
|
png_bytep read_buffer; /* buffer for reading chunk data */
|
||||||
|
png_alloc_size_t read_buffer_size; /* current size of the buffer */
|
||||||
|
#endif
|
||||||
|
#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
|
||||||
|
uInt IDAT_read_size; /* limit on read buffer size for IDAT */
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_IO_STATE_SUPPORTED
|
#ifdef PNG_IO_STATE_SUPPORTED
|
||||||
/* New member added in libpng-1.4.0 */
|
/* New member added in libpng-1.4.0 */
|
||||||
|
@ -352,7 +470,14 @@ struct png_struct_def
|
||||||
/* New member added in libpng-1.5.6 */
|
/* New member added in libpng-1.5.6 */
|
||||||
png_bytep big_prev_row;
|
png_bytep big_prev_row;
|
||||||
|
|
||||||
|
/* New member added in libpng-1.5.7 */
|
||||||
void (*read_filter[PNG_FILTER_VALUE_LAST-1])(png_row_infop row_info,
|
void (*read_filter[PNG_FILTER_VALUE_LAST-1])(png_row_infop row_info,
|
||||||
png_bytep row, png_const_bytep prev_row);
|
png_bytep row, png_const_bytep prev_row);
|
||||||
|
|
||||||
|
#ifdef PNG_READ_SUPPORTED
|
||||||
|
#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)
|
||||||
|
png_colorspace colorspace;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
#endif /* PNGSTRUCT_H */
|
#endif /* PNGSTRUCT_H */
|
2091
ExternalLibs/png/pngtest.c
Normal file
2091
ExternalLibs/png/pngtest.c
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,8 +1,8 @@
|
||||||
|
|
||||||
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
|
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.5.11 [June 14, 2012]
|
* Last changed in libpng 1.6.24 [August 4, 2016]
|
||||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
|
@ -18,7 +18,7 @@
|
||||||
#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
|
#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
|
||||||
/* Turn on BGR-to-RGB mapping */
|
/* Turn on BGR-to-RGB mapping */
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_bgr(png_structp png_ptr)
|
png_set_bgr(png_structrp png_ptr)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_bgr");
|
png_debug(1, "in png_set_bgr");
|
||||||
|
|
||||||
|
@ -30,9 +30,9 @@ png_set_bgr(png_structp png_ptr)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
|
#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
|
||||||
/* Turn on 16 bit byte swapping */
|
/* Turn on 16-bit byte swapping */
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_swap(png_structp png_ptr)
|
png_set_swap(png_structrp png_ptr)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_swap");
|
png_debug(1, "in png_set_swap");
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ png_set_swap(png_structp png_ptr)
|
||||||
#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
|
#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
|
||||||
/* Turn on pixel packing */
|
/* Turn on pixel packing */
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_packing(png_structp png_ptr)
|
png_set_packing(png_structrp png_ptr)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_packing");
|
png_debug(1, "in png_set_packing");
|
||||||
|
|
||||||
|
@ -57,7 +57,9 @@ png_set_packing(png_structp png_ptr)
|
||||||
if (png_ptr->bit_depth < 8)
|
if (png_ptr->bit_depth < 8)
|
||||||
{
|
{
|
||||||
png_ptr->transformations |= PNG_PACK;
|
png_ptr->transformations |= PNG_PACK;
|
||||||
|
# ifdef PNG_WRITE_SUPPORTED
|
||||||
png_ptr->usr_bit_depth = 8;
|
png_ptr->usr_bit_depth = 8;
|
||||||
|
# endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -65,7 +67,7 @@ png_set_packing(png_structp png_ptr)
|
||||||
#if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED)
|
#if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED)
|
||||||
/* Turn on packed pixel swapping */
|
/* Turn on packed pixel swapping */
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_packswap(png_structp png_ptr)
|
png_set_packswap(png_structrp png_ptr)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_packswap");
|
png_debug(1, "in png_set_packswap");
|
||||||
|
|
||||||
|
@ -79,7 +81,7 @@ png_set_packswap(png_structp png_ptr)
|
||||||
|
|
||||||
#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
|
#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_shift(png_structp png_ptr, png_const_color_8p true_bits)
|
png_set_shift(png_structrp png_ptr, png_const_color_8p true_bits)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_shift");
|
png_debug(1, "in png_set_shift");
|
||||||
|
|
||||||
|
@ -94,11 +96,11 @@ png_set_shift(png_structp png_ptr, png_const_color_8p true_bits)
|
||||||
#if defined(PNG_READ_INTERLACING_SUPPORTED) || \
|
#if defined(PNG_READ_INTERLACING_SUPPORTED) || \
|
||||||
defined(PNG_WRITE_INTERLACING_SUPPORTED)
|
defined(PNG_WRITE_INTERLACING_SUPPORTED)
|
||||||
int PNGAPI
|
int PNGAPI
|
||||||
png_set_interlace_handling(png_structp png_ptr)
|
png_set_interlace_handling(png_structrp png_ptr)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_interlace handling");
|
png_debug(1, "in png_set_interlace handling");
|
||||||
|
|
||||||
if (png_ptr && png_ptr->interlaced)
|
if (png_ptr != 0 && png_ptr->interlaced != 0)
|
||||||
{
|
{
|
||||||
png_ptr->transformations |= PNG_INTERLACE;
|
png_ptr->transformations |= PNG_INTERLACE;
|
||||||
return (7);
|
return (7);
|
||||||
|
@ -115,44 +117,92 @@ png_set_interlace_handling(png_structp png_ptr)
|
||||||
* that don't like bytes as parameters.
|
* that don't like bytes as parameters.
|
||||||
*/
|
*/
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc)
|
png_set_filler(png_structrp png_ptr, png_uint_32 filler, int filler_loc)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_filler");
|
png_debug(1, "in png_set_filler");
|
||||||
|
|
||||||
if (png_ptr == NULL)
|
if (png_ptr == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
png_ptr->transformations |= PNG_FILLER;
|
/* In libpng 1.6 it is possible to determine whether this is a read or write
|
||||||
|
* operation and therefore to do more checking here for a valid call.
|
||||||
|
*/
|
||||||
|
if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0)
|
||||||
|
{
|
||||||
|
# ifdef PNG_READ_FILLER_SUPPORTED
|
||||||
|
/* On read png_set_filler is always valid, regardless of the base PNG
|
||||||
|
* format, because other transformations can give a format where the
|
||||||
|
* filler code can execute (basically an 8 or 16-bit component RGB or G
|
||||||
|
* format.)
|
||||||
|
*
|
||||||
|
* NOTE: usr_channels is not used by the read code! (This has led to
|
||||||
|
* confusion in the past.) The filler is only used in the read code.
|
||||||
|
*/
|
||||||
png_ptr->filler = (png_uint_16)filler;
|
png_ptr->filler = (png_uint_16)filler;
|
||||||
|
# else
|
||||||
|
png_app_error(png_ptr, "png_set_filler not supported on read");
|
||||||
|
PNG_UNUSED(filler) /* not used in the write case */
|
||||||
|
return;
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
|
||||||
|
else /* write */
|
||||||
|
{
|
||||||
|
# ifdef PNG_WRITE_FILLER_SUPPORTED
|
||||||
|
/* On write the usr_channels parameter must be set correctly at the
|
||||||
|
* start to record the number of channels in the app-supplied data.
|
||||||
|
*/
|
||||||
|
switch (png_ptr->color_type)
|
||||||
|
{
|
||||||
|
case PNG_COLOR_TYPE_RGB:
|
||||||
|
png_ptr->usr_channels = 4;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PNG_COLOR_TYPE_GRAY:
|
||||||
|
if (png_ptr->bit_depth >= 8)
|
||||||
|
{
|
||||||
|
png_ptr->usr_channels = 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* There simply isn't any code in libpng to strip out bits
|
||||||
|
* from bytes when the components are less than a byte in
|
||||||
|
* size!
|
||||||
|
*/
|
||||||
|
png_app_error(png_ptr,
|
||||||
|
"png_set_filler is invalid for"
|
||||||
|
" low bit depth gray output");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
png_app_error(png_ptr,
|
||||||
|
"png_set_filler: inappropriate color type");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
# else
|
||||||
|
png_app_error(png_ptr, "png_set_filler not supported on write");
|
||||||
|
return;
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Here on success - libpng supports the operation, set the transformation
|
||||||
|
* and the flag to say where the filler channel is.
|
||||||
|
*/
|
||||||
|
png_ptr->transformations |= PNG_FILLER;
|
||||||
|
|
||||||
if (filler_loc == PNG_FILLER_AFTER)
|
if (filler_loc == PNG_FILLER_AFTER)
|
||||||
png_ptr->flags |= PNG_FLAG_FILLER_AFTER;
|
png_ptr->flags |= PNG_FLAG_FILLER_AFTER;
|
||||||
|
|
||||||
else
|
else
|
||||||
png_ptr->flags &= ~PNG_FLAG_FILLER_AFTER;
|
png_ptr->flags &= ~PNG_FLAG_FILLER_AFTER;
|
||||||
|
|
||||||
/* This should probably go in the "do_read_filler" routine.
|
|
||||||
* I attempted to do that in libpng-1.0.1a but that caused problems
|
|
||||||
* so I restored it in libpng-1.0.2a
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (png_ptr->color_type == PNG_COLOR_TYPE_RGB)
|
|
||||||
{
|
|
||||||
png_ptr->usr_channels = 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Also I added this in libpng-1.0.2a (what happens when we expand
|
|
||||||
* a less-than-8-bit grayscale to GA?) */
|
|
||||||
|
|
||||||
if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY && png_ptr->bit_depth >= 8)
|
|
||||||
{
|
|
||||||
png_ptr->usr_channels = 2;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Added to libpng-1.2.7 */
|
/* Added to libpng-1.2.7 */
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_add_alpha(png_structp png_ptr, png_uint_32 filler, int filler_loc)
|
png_set_add_alpha(png_structrp png_ptr, png_uint_32 filler, int filler_loc)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_add_alpha");
|
png_debug(1, "in png_set_add_alpha");
|
||||||
|
|
||||||
|
@ -160,6 +210,8 @@ png_set_add_alpha(png_structp png_ptr, png_uint_32 filler, int filler_loc)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
png_set_filler(png_ptr, filler, filler_loc);
|
png_set_filler(png_ptr, filler, filler_loc);
|
||||||
|
/* The above may fail to do anything. */
|
||||||
|
if ((png_ptr->transformations & PNG_FILLER) != 0)
|
||||||
png_ptr->transformations |= PNG_ADD_ALPHA;
|
png_ptr->transformations |= PNG_ADD_ALPHA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,7 +220,7 @@ png_set_add_alpha(png_structp png_ptr, png_uint_32 filler, int filler_loc)
|
||||||
#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \
|
#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \
|
||||||
defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)
|
defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_swap_alpha(png_structp png_ptr)
|
png_set_swap_alpha(png_structrp png_ptr)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_swap_alpha");
|
png_debug(1, "in png_set_swap_alpha");
|
||||||
|
|
||||||
|
@ -182,7 +234,7 @@ png_set_swap_alpha(png_structp png_ptr)
|
||||||
#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \
|
#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \
|
||||||
defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
|
defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_invert_alpha(png_structp png_ptr)
|
png_set_invert_alpha(png_structrp png_ptr)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_invert_alpha");
|
png_debug(1, "in png_set_invert_alpha");
|
||||||
|
|
||||||
|
@ -195,7 +247,7 @@ png_set_invert_alpha(png_structp png_ptr)
|
||||||
|
|
||||||
#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)
|
#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_invert_mono(png_structp png_ptr)
|
png_set_invert_mono(png_structrp png_ptr)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_invert_mono");
|
png_debug(1, "in png_set_invert_mono");
|
||||||
|
|
||||||
|
@ -262,7 +314,7 @@ png_do_invert(png_row_infop row_info, png_bytep row)
|
||||||
|
|
||||||
#ifdef PNG_16BIT_SUPPORTED
|
#ifdef PNG_16BIT_SUPPORTED
|
||||||
#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
|
#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
|
||||||
/* Swaps byte order on 16 bit depth images */
|
/* Swaps byte order on 16-bit depth images */
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_do_swap(png_row_infop row_info, png_bytep row)
|
png_do_swap(png_row_infop row_info, png_bytep row)
|
||||||
{
|
{
|
||||||
|
@ -276,9 +328,16 @@ png_do_swap(png_row_infop row_info, png_bytep row)
|
||||||
|
|
||||||
for (i = 0; i < istop; i++, rp += 2)
|
for (i = 0; i < istop; i++, rp += 2)
|
||||||
{
|
{
|
||||||
|
#ifdef PNG_BUILTIN_BSWAP16_SUPPORTED
|
||||||
|
/* Feature added to libpng-1.6.11 for testing purposes, not
|
||||||
|
* enabled by default.
|
||||||
|
*/
|
||||||
|
*(png_uint_16*)rp = __builtin_bswap16(*(png_uint_16*)rp);
|
||||||
|
#else
|
||||||
png_byte t = *rp;
|
png_byte t = *rp;
|
||||||
*rp = *(rp + 1);
|
*rp = *(rp + 1);
|
||||||
*(rp + 1) = t;
|
*(rp + 1) = t;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -420,7 +479,7 @@ png_do_packswap(png_row_infop row_info, png_bytep row)
|
||||||
*rp = table[*rp];
|
*rp = table[*rp];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* PNG_READ_PACKSWAP_SUPPORTED or PNG_WRITE_PACKSWAP_SUPPORTED */
|
#endif /* PACKSWAP || WRITE_PACKSWAP */
|
||||||
|
|
||||||
#if defined(PNG_WRITE_FILLER_SUPPORTED) || \
|
#if defined(PNG_WRITE_FILLER_SUPPORTED) || \
|
||||||
defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
|
defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
|
||||||
|
@ -452,7 +511,7 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
|
||||||
{
|
{
|
||||||
if (row_info->bit_depth == 8)
|
if (row_info->bit_depth == 8)
|
||||||
{
|
{
|
||||||
if (at_start) /* Skip initial filler */
|
if (at_start != 0) /* Skip initial filler */
|
||||||
++sp;
|
++sp;
|
||||||
else /* Skip initial channel and, for sp, the filler */
|
else /* Skip initial channel and, for sp, the filler */
|
||||||
sp += 2, ++dp;
|
sp += 2, ++dp;
|
||||||
|
@ -466,7 +525,7 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
|
||||||
|
|
||||||
else if (row_info->bit_depth == 16)
|
else if (row_info->bit_depth == 16)
|
||||||
{
|
{
|
||||||
if (at_start) /* Skip initial filler */
|
if (at_start != 0) /* Skip initial filler */
|
||||||
sp += 2;
|
sp += 2;
|
||||||
else /* Skip initial channel and, for sp, the filler */
|
else /* Skip initial channel and, for sp, the filler */
|
||||||
sp += 4, dp += 2;
|
sp += 4, dp += 2;
|
||||||
|
@ -492,7 +551,7 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
|
||||||
{
|
{
|
||||||
if (row_info->bit_depth == 8)
|
if (row_info->bit_depth == 8)
|
||||||
{
|
{
|
||||||
if (at_start) /* Skip initial filler */
|
if (at_start != 0) /* Skip initial filler */
|
||||||
++sp;
|
++sp;
|
||||||
else /* Skip initial channels and, for sp, the filler */
|
else /* Skip initial channels and, for sp, the filler */
|
||||||
sp += 4, dp += 3;
|
sp += 4, dp += 3;
|
||||||
|
@ -506,7 +565,7 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
|
||||||
|
|
||||||
else if (row_info->bit_depth == 16)
|
else if (row_info->bit_depth == 16)
|
||||||
{
|
{
|
||||||
if (at_start) /* Skip initial filler */
|
if (at_start != 0) /* Skip initial filler */
|
||||||
sp += 2;
|
sp += 2;
|
||||||
else /* Skip initial channels and, for sp, the filler */
|
else /* Skip initial channels and, for sp, the filler */
|
||||||
sp += 8, dp += 6;
|
sp += 8, dp += 6;
|
||||||
|
@ -547,7 +606,7 @@ png_do_bgr(png_row_infop row_info, png_bytep row)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_do_bgr");
|
png_debug(1, "in png_do_bgr");
|
||||||
|
|
||||||
if ((row_info->color_type & PNG_COLOR_MASK_COLOR))
|
if ((row_info->color_type & PNG_COLOR_MASK_COLOR) != 0)
|
||||||
{
|
{
|
||||||
png_uint_32 row_width = row_info->width;
|
png_uint_32 row_width = row_info->width;
|
||||||
if (row_info->bit_depth == 8)
|
if (row_info->bit_depth == 8)
|
||||||
|
@ -617,13 +676,13 @@ png_do_bgr(png_row_infop row_info, png_bytep row)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* PNG_READ_BGR_SUPPORTED or PNG_WRITE_BGR_SUPPORTED */
|
#endif /* READ_BGR || WRITE_BGR */
|
||||||
|
|
||||||
#if defined(PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED) || \
|
#if defined(PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED) || \
|
||||||
defined(PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED)
|
defined(PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED)
|
||||||
/* Added at libpng-1.5.10 */
|
/* Added at libpng-1.5.10 */
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_do_check_palette_indexes(png_structp png_ptr, png_row_infop row_info)
|
png_do_check_palette_indexes(png_structrp png_ptr, png_row_infop row_info)
|
||||||
{
|
{
|
||||||
if (png_ptr->num_palette < (1 << row_info->bit_depth) &&
|
if (png_ptr->num_palette < (1 << row_info->bit_depth) &&
|
||||||
png_ptr->num_palette > 0) /* num_palette can be 0 in MNG files */
|
png_ptr->num_palette > 0) /* num_palette can be 0 in MNG files */
|
||||||
|
@ -646,7 +705,7 @@ png_do_check_palette_indexes(png_structp png_ptr, png_row_infop row_info)
|
||||||
*/
|
*/
|
||||||
for (; rp > png_ptr->row_buf; rp--)
|
for (; rp > png_ptr->row_buf; rp--)
|
||||||
{
|
{
|
||||||
if (*rp >> padding != 0)
|
if ((*rp >> padding) != 0)
|
||||||
png_ptr->num_palette_max = 1;
|
png_ptr->num_palette_max = 1;
|
||||||
padding = 0;
|
padding = 0;
|
||||||
}
|
}
|
||||||
|
@ -720,19 +779,30 @@ png_do_check_palette_indexes(png_structp png_ptr, png_row_infop row_info)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED */
|
#endif /* CHECK_FOR_INVALID_INDEX */
|
||||||
|
|
||||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
|
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
|
||||||
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||||
#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED
|
#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_user_transform_info(png_structp png_ptr, png_voidp
|
png_set_user_transform_info(png_structrp png_ptr, png_voidp
|
||||||
user_transform_ptr, int user_transform_depth, int user_transform_channels)
|
user_transform_ptr, int user_transform_depth, int user_transform_channels)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_user_transform_info");
|
png_debug(1, "in png_set_user_transform_info");
|
||||||
|
|
||||||
if (png_ptr == NULL)
|
if (png_ptr == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
|
||||||
|
if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0 &&
|
||||||
|
(png_ptr->flags & PNG_FLAG_ROW_INIT) != 0)
|
||||||
|
{
|
||||||
|
png_app_error(png_ptr,
|
||||||
|
"info change after png_start_read_image or png_read_update_info");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
png_ptr->user_transform_ptr = user_transform_ptr;
|
png_ptr->user_transform_ptr = user_transform_ptr;
|
||||||
png_ptr->user_transform_depth = (png_byte)user_transform_depth;
|
png_ptr->user_transform_depth = (png_byte)user_transform_depth;
|
||||||
png_ptr->user_transform_channels = (png_byte)user_transform_channels;
|
png_ptr->user_transform_channels = (png_byte)user_transform_channels;
|
||||||
|
@ -746,20 +816,20 @@ png_set_user_transform_info(png_structp png_ptr, png_voidp
|
||||||
*/
|
*/
|
||||||
#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED
|
#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED
|
||||||
png_voidp PNGAPI
|
png_voidp PNGAPI
|
||||||
png_get_user_transform_ptr(png_const_structp png_ptr)
|
png_get_user_transform_ptr(png_const_structrp png_ptr)
|
||||||
{
|
{
|
||||||
if (png_ptr == NULL)
|
if (png_ptr == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
||||||
return ((png_voidp)png_ptr->user_transform_ptr);
|
return png_ptr->user_transform_ptr;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_USER_TRANSFORM_INFO_SUPPORTED
|
#ifdef PNG_USER_TRANSFORM_INFO_SUPPORTED
|
||||||
png_uint_32 PNGAPI
|
png_uint_32 PNGAPI
|
||||||
png_get_current_row_number(png_const_structp png_ptr)
|
png_get_current_row_number(png_const_structrp png_ptr)
|
||||||
{
|
{
|
||||||
/* See the comments in png.h - this is the sub-image row when reading and
|
/* See the comments in png.h - this is the sub-image row when reading an
|
||||||
* interlaced image.
|
* interlaced image.
|
||||||
*/
|
*/
|
||||||
if (png_ptr != NULL)
|
if (png_ptr != NULL)
|
||||||
|
@ -769,13 +839,12 @@ png_get_current_row_number(png_const_structp png_ptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
png_byte PNGAPI
|
png_byte PNGAPI
|
||||||
png_get_current_pass_number(png_const_structp png_ptr)
|
png_get_current_pass_number(png_const_structrp png_ptr)
|
||||||
{
|
{
|
||||||
if (png_ptr != NULL)
|
if (png_ptr != NULL)
|
||||||
return png_ptr->pass;
|
return png_ptr->pass;
|
||||||
return 8; /* invalid */
|
return 8; /* invalid */
|
||||||
}
|
}
|
||||||
#endif /* PNG_USER_TRANSFORM_INFO_SUPPORTED */
|
#endif /* USER_TRANSFORM_INFO */
|
||||||
#endif /* PNG_READ_USER_TRANSFORM_SUPPORTED ||
|
#endif /* READ_USER_TRANSFORM || WRITE_USER_TRANSFORM */
|
||||||
PNG_WRITE_USER_TRANSFORM_SUPPORTED */
|
#endif /* READ || WRITE */
|
||||||
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
|
168
ExternalLibs/png/pngwio.c
Normal file
168
ExternalLibs/png/pngwio.c
Normal file
|
@ -0,0 +1,168 @@
|
||||||
|
|
||||||
|
/* pngwio.c - functions for data output
|
||||||
|
*
|
||||||
|
* Last changed in libpng 1.6.24 [August 4, 2016]
|
||||||
|
* Copyright (c) 1998-2002,2004,2006-2014,2016 Glenn Randers-Pehrson
|
||||||
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
|
*
|
||||||
|
* This code is released under the libpng license.
|
||||||
|
* For conditions of distribution and use, see the disclaimer
|
||||||
|
* and license in png.h
|
||||||
|
*
|
||||||
|
* This file provides a location for all output. Users who need
|
||||||
|
* special handling are expected to write functions that have the same
|
||||||
|
* arguments as these and perform similar functions, but that possibly
|
||||||
|
* use different output methods. Note that you shouldn't change these
|
||||||
|
* functions, but rather write replacement functions and then change
|
||||||
|
* them at run time with png_set_write_fn(...).
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "pngpriv.h"
|
||||||
|
|
||||||
|
#ifdef PNG_WRITE_SUPPORTED
|
||||||
|
|
||||||
|
/* Write the data to whatever output you are using. The default routine
|
||||||
|
* writes to a file pointer. Note that this routine sometimes gets called
|
||||||
|
* with very small lengths, so you should implement some kind of simple
|
||||||
|
* buffering if you are using unbuffered writes. This should never be asked
|
||||||
|
* to write more than 64K on a 16-bit machine.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void /* PRIVATE */
|
||||||
|
png_write_data(png_structrp png_ptr, png_const_bytep data, png_size_t length)
|
||||||
|
{
|
||||||
|
/* NOTE: write_data_fn must not change the buffer! */
|
||||||
|
if (png_ptr->write_data_fn != NULL )
|
||||||
|
(*(png_ptr->write_data_fn))(png_ptr, png_constcast(png_bytep,data),
|
||||||
|
length);
|
||||||
|
|
||||||
|
else
|
||||||
|
png_error(png_ptr, "Call to NULL write function");
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef PNG_STDIO_SUPPORTED
|
||||||
|
/* This is the function that does the actual writing of data. If you are
|
||||||
|
* not writing to a standard C stream, you should create a replacement
|
||||||
|
* write_data function and use it at run time with png_set_write_fn(), rather
|
||||||
|
* than changing the library.
|
||||||
|
*/
|
||||||
|
void PNGCBAPI
|
||||||
|
png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||||
|
{
|
||||||
|
png_size_t check;
|
||||||
|
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
check = fwrite(data, 1, length, (png_FILE_p)(png_ptr->io_ptr));
|
||||||
|
|
||||||
|
if (check != length)
|
||||||
|
png_error(png_ptr, "Write Error");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* This function is called to output any data pending writing (normally
|
||||||
|
* to disk). After png_flush is called, there should be no data pending
|
||||||
|
* writing in any buffers.
|
||||||
|
*/
|
||||||
|
#ifdef PNG_WRITE_FLUSH_SUPPORTED
|
||||||
|
void /* PRIVATE */
|
||||||
|
png_flush(png_structrp png_ptr)
|
||||||
|
{
|
||||||
|
if (png_ptr->output_flush_fn != NULL)
|
||||||
|
(*(png_ptr->output_flush_fn))(png_ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
# ifdef PNG_STDIO_SUPPORTED
|
||||||
|
void PNGCBAPI
|
||||||
|
png_default_flush(png_structp png_ptr)
|
||||||
|
{
|
||||||
|
png_FILE_p io_ptr;
|
||||||
|
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
io_ptr = png_voidcast(png_FILE_p, (png_ptr->io_ptr));
|
||||||
|
fflush(io_ptr);
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* This function allows the application to supply new output functions for
|
||||||
|
* libpng if standard C streams aren't being used.
|
||||||
|
*
|
||||||
|
* This function takes as its arguments:
|
||||||
|
* png_ptr - pointer to a png output data structure
|
||||||
|
* io_ptr - pointer to user supplied structure containing info about
|
||||||
|
* the output functions. May be NULL.
|
||||||
|
* write_data_fn - pointer to a new output function that takes as its
|
||||||
|
* arguments a pointer to a png_struct, a pointer to
|
||||||
|
* data to be written, and a 32-bit unsigned int that is
|
||||||
|
* the number of bytes to be written. The new write
|
||||||
|
* function should call png_error(png_ptr, "Error msg")
|
||||||
|
* to exit and output any fatal error messages. May be
|
||||||
|
* NULL, in which case libpng's default function will
|
||||||
|
* be used.
|
||||||
|
* flush_data_fn - pointer to a new flush function that takes as its
|
||||||
|
* arguments a pointer to a png_struct. After a call to
|
||||||
|
* the flush function, there should be no data in any buffers
|
||||||
|
* or pending transmission. If the output method doesn't do
|
||||||
|
* any buffering of output, a function prototype must still be
|
||||||
|
* supplied although it doesn't have to do anything. If
|
||||||
|
* PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile
|
||||||
|
* time, output_flush_fn will be ignored, although it must be
|
||||||
|
* supplied for compatibility. May be NULL, in which case
|
||||||
|
* libpng's default function will be used, if
|
||||||
|
* PNG_WRITE_FLUSH_SUPPORTED is defined. This is not
|
||||||
|
* a good idea if io_ptr does not point to a standard
|
||||||
|
* *FILE structure.
|
||||||
|
*/
|
||||||
|
void PNGAPI
|
||||||
|
png_set_write_fn(png_structrp png_ptr, png_voidp io_ptr,
|
||||||
|
png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)
|
||||||
|
{
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
png_ptr->io_ptr = io_ptr;
|
||||||
|
|
||||||
|
#ifdef PNG_STDIO_SUPPORTED
|
||||||
|
if (write_data_fn != NULL)
|
||||||
|
png_ptr->write_data_fn = write_data_fn;
|
||||||
|
|
||||||
|
else
|
||||||
|
png_ptr->write_data_fn = png_default_write_data;
|
||||||
|
#else
|
||||||
|
png_ptr->write_data_fn = write_data_fn;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef PNG_WRITE_FLUSH_SUPPORTED
|
||||||
|
# ifdef PNG_STDIO_SUPPORTED
|
||||||
|
|
||||||
|
if (output_flush_fn != NULL)
|
||||||
|
png_ptr->output_flush_fn = output_flush_fn;
|
||||||
|
|
||||||
|
else
|
||||||
|
png_ptr->output_flush_fn = png_default_flush;
|
||||||
|
|
||||||
|
# else
|
||||||
|
png_ptr->output_flush_fn = output_flush_fn;
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
PNG_UNUSED(output_flush_fn)
|
||||||
|
#endif /* WRITE_FLUSH */
|
||||||
|
|
||||||
|
#ifdef PNG_READ_SUPPORTED
|
||||||
|
/* It is an error to read while writing a png file */
|
||||||
|
if (png_ptr->read_data_fn != NULL)
|
||||||
|
{
|
||||||
|
png_ptr->read_data_fn = NULL;
|
||||||
|
|
||||||
|
png_warning(png_ptr,
|
||||||
|
"Can't set both read_data_fn and write_data_fn in the"
|
||||||
|
" same structure");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif /* WRITE */
|
2383
ExternalLibs/png/pngwrite.c
Normal file
2383
ExternalLibs/png/pngwrite.c
Normal file
File diff suppressed because it is too large
Load diff
576
ExternalLibs/png/pngwtran.c
Normal file
576
ExternalLibs/png/pngwtran.c
Normal file
|
@ -0,0 +1,576 @@
|
||||||
|
|
||||||
|
/* pngwtran.c - transforms the data in a row for PNG writers
|
||||||
|
*
|
||||||
|
* Last changed in libpng 1.6.24 [August 4, 2016]
|
||||||
|
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
|
||||||
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
|
*
|
||||||
|
* This code is released under the libpng license.
|
||||||
|
* For conditions of distribution and use, see the disclaimer
|
||||||
|
* and license in png.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "pngpriv.h"
|
||||||
|
|
||||||
|
#ifdef PNG_WRITE_SUPPORTED
|
||||||
|
#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED
|
||||||
|
|
||||||
|
#ifdef PNG_WRITE_PACK_SUPPORTED
|
||||||
|
/* Pack pixels into bytes. Pass the true bit depth in bit_depth. The
|
||||||
|
* row_info bit depth should be 8 (one pixel per byte). The channels
|
||||||
|
* should be 1 (this only happens on grayscale and paletted images).
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
|
||||||
|
{
|
||||||
|
png_debug(1, "in png_do_pack");
|
||||||
|
|
||||||
|
if (row_info->bit_depth == 8 &&
|
||||||
|
row_info->channels == 1)
|
||||||
|
{
|
||||||
|
switch ((int)bit_depth)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
png_bytep sp, dp;
|
||||||
|
int mask, v;
|
||||||
|
png_uint_32 i;
|
||||||
|
png_uint_32 row_width = row_info->width;
|
||||||
|
|
||||||
|
sp = row;
|
||||||
|
dp = row;
|
||||||
|
mask = 0x80;
|
||||||
|
v = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < row_width; i++)
|
||||||
|
{
|
||||||
|
if (*sp != 0)
|
||||||
|
v |= mask;
|
||||||
|
|
||||||
|
sp++;
|
||||||
|
|
||||||
|
if (mask > 1)
|
||||||
|
mask >>= 1;
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mask = 0x80;
|
||||||
|
*dp = (png_byte)v;
|
||||||
|
dp++;
|
||||||
|
v = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mask != 0x80)
|
||||||
|
*dp = (png_byte)v;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
{
|
||||||
|
png_bytep sp, dp;
|
||||||
|
unsigned int shift;
|
||||||
|
int v;
|
||||||
|
png_uint_32 i;
|
||||||
|
png_uint_32 row_width = row_info->width;
|
||||||
|
|
||||||
|
sp = row;
|
||||||
|
dp = row;
|
||||||
|
shift = 6;
|
||||||
|
v = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < row_width; i++)
|
||||||
|
{
|
||||||
|
png_byte value;
|
||||||
|
|
||||||
|
value = (png_byte)(*sp & 0x03);
|
||||||
|
v |= (value << shift);
|
||||||
|
|
||||||
|
if (shift == 0)
|
||||||
|
{
|
||||||
|
shift = 6;
|
||||||
|
*dp = (png_byte)v;
|
||||||
|
dp++;
|
||||||
|
v = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
shift -= 2;
|
||||||
|
|
||||||
|
sp++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (shift != 6)
|
||||||
|
*dp = (png_byte)v;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 4:
|
||||||
|
{
|
||||||
|
png_bytep sp, dp;
|
||||||
|
unsigned int shift;
|
||||||
|
int v;
|
||||||
|
png_uint_32 i;
|
||||||
|
png_uint_32 row_width = row_info->width;
|
||||||
|
|
||||||
|
sp = row;
|
||||||
|
dp = row;
|
||||||
|
shift = 4;
|
||||||
|
v = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < row_width; i++)
|
||||||
|
{
|
||||||
|
png_byte value;
|
||||||
|
|
||||||
|
value = (png_byte)(*sp & 0x0f);
|
||||||
|
v |= (value << shift);
|
||||||
|
|
||||||
|
if (shift == 0)
|
||||||
|
{
|
||||||
|
shift = 4;
|
||||||
|
*dp = (png_byte)v;
|
||||||
|
dp++;
|
||||||
|
v = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
shift -= 4;
|
||||||
|
|
||||||
|
sp++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (shift != 4)
|
||||||
|
*dp = (png_byte)v;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
row_info->bit_depth = (png_byte)bit_depth;
|
||||||
|
row_info->pixel_depth = (png_byte)(bit_depth * row_info->channels);
|
||||||
|
row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,
|
||||||
|
row_info->width);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef PNG_WRITE_SHIFT_SUPPORTED
|
||||||
|
/* Shift pixel values to take advantage of whole range. Pass the
|
||||||
|
* true number of bits in bit_depth. The row should be packed
|
||||||
|
* according to row_info->bit_depth. Thus, if you had a row of
|
||||||
|
* bit depth 4, but the pixels only had values from 0 to 7, you
|
||||||
|
* would pass 3 as bit_depth, and this routine would translate the
|
||||||
|
* data to 0 to 15.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
png_do_shift(png_row_infop row_info, png_bytep row,
|
||||||
|
png_const_color_8p bit_depth)
|
||||||
|
{
|
||||||
|
png_debug(1, "in png_do_shift");
|
||||||
|
|
||||||
|
if (row_info->color_type != PNG_COLOR_TYPE_PALETTE)
|
||||||
|
{
|
||||||
|
int shift_start[4], shift_dec[4];
|
||||||
|
int channels = 0;
|
||||||
|
|
||||||
|
if ((row_info->color_type & PNG_COLOR_MASK_COLOR) != 0)
|
||||||
|
{
|
||||||
|
shift_start[channels] = row_info->bit_depth - bit_depth->red;
|
||||||
|
shift_dec[channels] = bit_depth->red;
|
||||||
|
channels++;
|
||||||
|
|
||||||
|
shift_start[channels] = row_info->bit_depth - bit_depth->green;
|
||||||
|
shift_dec[channels] = bit_depth->green;
|
||||||
|
channels++;
|
||||||
|
|
||||||
|
shift_start[channels] = row_info->bit_depth - bit_depth->blue;
|
||||||
|
shift_dec[channels] = bit_depth->blue;
|
||||||
|
channels++;
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
shift_start[channels] = row_info->bit_depth - bit_depth->gray;
|
||||||
|
shift_dec[channels] = bit_depth->gray;
|
||||||
|
channels++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((row_info->color_type & PNG_COLOR_MASK_ALPHA) != 0)
|
||||||
|
{
|
||||||
|
shift_start[channels] = row_info->bit_depth - bit_depth->alpha;
|
||||||
|
shift_dec[channels] = bit_depth->alpha;
|
||||||
|
channels++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* With low row depths, could only be grayscale, so one channel */
|
||||||
|
if (row_info->bit_depth < 8)
|
||||||
|
{
|
||||||
|
png_bytep bp = row;
|
||||||
|
png_size_t i;
|
||||||
|
unsigned int mask;
|
||||||
|
png_size_t row_bytes = row_info->rowbytes;
|
||||||
|
|
||||||
|
if (bit_depth->gray == 1 && row_info->bit_depth == 2)
|
||||||
|
mask = 0x55;
|
||||||
|
|
||||||
|
else if (row_info->bit_depth == 4 && bit_depth->gray == 3)
|
||||||
|
mask = 0x11;
|
||||||
|
|
||||||
|
else
|
||||||
|
mask = 0xff;
|
||||||
|
|
||||||
|
for (i = 0; i < row_bytes; i++, bp++)
|
||||||
|
{
|
||||||
|
int j;
|
||||||
|
unsigned int v, out;
|
||||||
|
|
||||||
|
v = *bp;
|
||||||
|
out = 0;
|
||||||
|
|
||||||
|
for (j = shift_start[0]; j > -shift_dec[0]; j -= shift_dec[0])
|
||||||
|
{
|
||||||
|
if (j > 0)
|
||||||
|
out |= v << j;
|
||||||
|
|
||||||
|
else
|
||||||
|
out |= (v >> (-j)) & mask;
|
||||||
|
}
|
||||||
|
|
||||||
|
*bp = (png_byte)(out & 0xff);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (row_info->bit_depth == 8)
|
||||||
|
{
|
||||||
|
png_bytep bp = row;
|
||||||
|
png_uint_32 i;
|
||||||
|
png_uint_32 istop = channels * row_info->width;
|
||||||
|
|
||||||
|
for (i = 0; i < istop; i++, bp++)
|
||||||
|
{
|
||||||
|
|
||||||
|
const unsigned int c = i%channels;
|
||||||
|
int j;
|
||||||
|
unsigned int v, out;
|
||||||
|
|
||||||
|
v = *bp;
|
||||||
|
out = 0;
|
||||||
|
|
||||||
|
for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c])
|
||||||
|
{
|
||||||
|
if (j > 0)
|
||||||
|
out |= v << j;
|
||||||
|
|
||||||
|
else
|
||||||
|
out |= v >> (-j);
|
||||||
|
}
|
||||||
|
|
||||||
|
*bp = (png_byte)(out & 0xff);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
png_bytep bp;
|
||||||
|
png_uint_32 i;
|
||||||
|
png_uint_32 istop = channels * row_info->width;
|
||||||
|
|
||||||
|
for (bp = row, i = 0; i < istop; i++)
|
||||||
|
{
|
||||||
|
const unsigned int c = i%channels;
|
||||||
|
int j;
|
||||||
|
unsigned int value, v;
|
||||||
|
|
||||||
|
v = png_get_uint_16(bp);
|
||||||
|
value = 0;
|
||||||
|
|
||||||
|
for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c])
|
||||||
|
{
|
||||||
|
if (j > 0)
|
||||||
|
value |= v << j;
|
||||||
|
|
||||||
|
else
|
||||||
|
value |= v >> (-j);
|
||||||
|
}
|
||||||
|
*bp++ = (png_byte)((value >> 8) & 0xff);
|
||||||
|
*bp++ = (png_byte)(value & 0xff);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED
|
||||||
|
static void
|
||||||
|
png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
|
||||||
|
{
|
||||||
|
png_debug(1, "in png_do_write_swap_alpha");
|
||||||
|
|
||||||
|
{
|
||||||
|
if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
||||||
|
{
|
||||||
|
if (row_info->bit_depth == 8)
|
||||||
|
{
|
||||||
|
/* This converts from ARGB to RGBA */
|
||||||
|
png_bytep sp, dp;
|
||||||
|
png_uint_32 i;
|
||||||
|
png_uint_32 row_width = row_info->width;
|
||||||
|
|
||||||
|
for (i = 0, sp = dp = row; i < row_width; i++)
|
||||||
|
{
|
||||||
|
png_byte save = *(sp++);
|
||||||
|
*(dp++) = *(sp++);
|
||||||
|
*(dp++) = *(sp++);
|
||||||
|
*(dp++) = *(sp++);
|
||||||
|
*(dp++) = save;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef PNG_WRITE_16BIT_SUPPORTED
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* This converts from AARRGGBB to RRGGBBAA */
|
||||||
|
png_bytep sp, dp;
|
||||||
|
png_uint_32 i;
|
||||||
|
png_uint_32 row_width = row_info->width;
|
||||||
|
|
||||||
|
for (i = 0, sp = dp = row; i < row_width; i++)
|
||||||
|
{
|
||||||
|
png_byte save[2];
|
||||||
|
save[0] = *(sp++);
|
||||||
|
save[1] = *(sp++);
|
||||||
|
*(dp++) = *(sp++);
|
||||||
|
*(dp++) = *(sp++);
|
||||||
|
*(dp++) = *(sp++);
|
||||||
|
*(dp++) = *(sp++);
|
||||||
|
*(dp++) = *(sp++);
|
||||||
|
*(dp++) = *(sp++);
|
||||||
|
*(dp++) = save[0];
|
||||||
|
*(dp++) = save[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* WRITE_16BIT */
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
|
||||||
|
{
|
||||||
|
if (row_info->bit_depth == 8)
|
||||||
|
{
|
||||||
|
/* This converts from AG to GA */
|
||||||
|
png_bytep sp, dp;
|
||||||
|
png_uint_32 i;
|
||||||
|
png_uint_32 row_width = row_info->width;
|
||||||
|
|
||||||
|
for (i = 0, sp = dp = row; i < row_width; i++)
|
||||||
|
{
|
||||||
|
png_byte save = *(sp++);
|
||||||
|
*(dp++) = *(sp++);
|
||||||
|
*(dp++) = save;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef PNG_WRITE_16BIT_SUPPORTED
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* This converts from AAGG to GGAA */
|
||||||
|
png_bytep sp, dp;
|
||||||
|
png_uint_32 i;
|
||||||
|
png_uint_32 row_width = row_info->width;
|
||||||
|
|
||||||
|
for (i = 0, sp = dp = row; i < row_width; i++)
|
||||||
|
{
|
||||||
|
png_byte save[2];
|
||||||
|
save[0] = *(sp++);
|
||||||
|
save[1] = *(sp++);
|
||||||
|
*(dp++) = *(sp++);
|
||||||
|
*(dp++) = *(sp++);
|
||||||
|
*(dp++) = save[0];
|
||||||
|
*(dp++) = save[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* WRITE_16BIT */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED
|
||||||
|
static void
|
||||||
|
png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
|
||||||
|
{
|
||||||
|
png_debug(1, "in png_do_write_invert_alpha");
|
||||||
|
|
||||||
|
{
|
||||||
|
if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
||||||
|
{
|
||||||
|
if (row_info->bit_depth == 8)
|
||||||
|
{
|
||||||
|
/* This inverts the alpha channel in RGBA */
|
||||||
|
png_bytep sp, dp;
|
||||||
|
png_uint_32 i;
|
||||||
|
png_uint_32 row_width = row_info->width;
|
||||||
|
|
||||||
|
for (i = 0, sp = dp = row; i < row_width; i++)
|
||||||
|
{
|
||||||
|
/* Does nothing
|
||||||
|
*(dp++) = *(sp++);
|
||||||
|
*(dp++) = *(sp++);
|
||||||
|
*(dp++) = *(sp++);
|
||||||
|
*/
|
||||||
|
sp+=3; dp = sp;
|
||||||
|
*dp = (png_byte)(255 - *(sp++));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef PNG_WRITE_16BIT_SUPPORTED
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* This inverts the alpha channel in RRGGBBAA */
|
||||||
|
png_bytep sp, dp;
|
||||||
|
png_uint_32 i;
|
||||||
|
png_uint_32 row_width = row_info->width;
|
||||||
|
|
||||||
|
for (i = 0, sp = dp = row; i < row_width; i++)
|
||||||
|
{
|
||||||
|
/* Does nothing
|
||||||
|
*(dp++) = *(sp++);
|
||||||
|
*(dp++) = *(sp++);
|
||||||
|
*(dp++) = *(sp++);
|
||||||
|
*(dp++) = *(sp++);
|
||||||
|
*(dp++) = *(sp++);
|
||||||
|
*(dp++) = *(sp++);
|
||||||
|
*/
|
||||||
|
sp+=6; dp = sp;
|
||||||
|
*(dp++) = (png_byte)(255 - *(sp++));
|
||||||
|
*dp = (png_byte)(255 - *(sp++));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* WRITE_16BIT */
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
|
||||||
|
{
|
||||||
|
if (row_info->bit_depth == 8)
|
||||||
|
{
|
||||||
|
/* This inverts the alpha channel in GA */
|
||||||
|
png_bytep sp, dp;
|
||||||
|
png_uint_32 i;
|
||||||
|
png_uint_32 row_width = row_info->width;
|
||||||
|
|
||||||
|
for (i = 0, sp = dp = row; i < row_width; i++)
|
||||||
|
{
|
||||||
|
*(dp++) = *(sp++);
|
||||||
|
*(dp++) = (png_byte)(255 - *(sp++));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef PNG_WRITE_16BIT_SUPPORTED
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* This inverts the alpha channel in GGAA */
|
||||||
|
png_bytep sp, dp;
|
||||||
|
png_uint_32 i;
|
||||||
|
png_uint_32 row_width = row_info->width;
|
||||||
|
|
||||||
|
for (i = 0, sp = dp = row; i < row_width; i++)
|
||||||
|
{
|
||||||
|
/* Does nothing
|
||||||
|
*(dp++) = *(sp++);
|
||||||
|
*(dp++) = *(sp++);
|
||||||
|
*/
|
||||||
|
sp+=2; dp = sp;
|
||||||
|
*(dp++) = (png_byte)(255 - *(sp++));
|
||||||
|
*dp = (png_byte)(255 - *(sp++));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* WRITE_16BIT */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Transform the data according to the user's wishes. The order of
|
||||||
|
* transformations is significant.
|
||||||
|
*/
|
||||||
|
void /* PRIVATE */
|
||||||
|
png_do_write_transformations(png_structrp png_ptr, png_row_infop row_info)
|
||||||
|
{
|
||||||
|
png_debug(1, "in png_do_write_transformations");
|
||||||
|
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
|
||||||
|
if ((png_ptr->transformations & PNG_USER_TRANSFORM) != 0)
|
||||||
|
if (png_ptr->write_user_transform_fn != NULL)
|
||||||
|
(*(png_ptr->write_user_transform_fn)) /* User write transform
|
||||||
|
function */
|
||||||
|
(png_ptr, /* png_ptr */
|
||||||
|
row_info, /* row_info: */
|
||||||
|
/* png_uint_32 width; width of row */
|
||||||
|
/* png_size_t rowbytes; number of bytes in row */
|
||||||
|
/* png_byte color_type; color type of pixels */
|
||||||
|
/* png_byte bit_depth; bit depth of samples */
|
||||||
|
/* png_byte channels; number of channels (1-4) */
|
||||||
|
/* png_byte pixel_depth; bits per pixel (depth*channels) */
|
||||||
|
png_ptr->row_buf + 1); /* start of pixel data for row */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef PNG_WRITE_FILLER_SUPPORTED
|
||||||
|
if ((png_ptr->transformations & PNG_FILLER) != 0)
|
||||||
|
png_do_strip_channel(row_info, png_ptr->row_buf + 1,
|
||||||
|
!(png_ptr->flags & PNG_FLAG_FILLER_AFTER));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef PNG_WRITE_PACKSWAP_SUPPORTED
|
||||||
|
if ((png_ptr->transformations & PNG_PACKSWAP) != 0)
|
||||||
|
png_do_packswap(row_info, png_ptr->row_buf + 1);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef PNG_WRITE_PACK_SUPPORTED
|
||||||
|
if ((png_ptr->transformations & PNG_PACK) != 0)
|
||||||
|
png_do_pack(row_info, png_ptr->row_buf + 1,
|
||||||
|
(png_uint_32)png_ptr->bit_depth);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef PNG_WRITE_SWAP_SUPPORTED
|
||||||
|
# ifdef PNG_16BIT_SUPPORTED
|
||||||
|
if ((png_ptr->transformations & PNG_SWAP_BYTES) != 0)
|
||||||
|
png_do_swap(row_info, png_ptr->row_buf + 1);
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef PNG_WRITE_SHIFT_SUPPORTED
|
||||||
|
if ((png_ptr->transformations & PNG_SHIFT) != 0)
|
||||||
|
png_do_shift(row_info, png_ptr->row_buf + 1,
|
||||||
|
&(png_ptr->shift));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED
|
||||||
|
if ((png_ptr->transformations & PNG_SWAP_ALPHA) != 0)
|
||||||
|
png_do_write_swap_alpha(row_info, png_ptr->row_buf + 1);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED
|
||||||
|
if ((png_ptr->transformations & PNG_INVERT_ALPHA) != 0)
|
||||||
|
png_do_write_invert_alpha(row_info, png_ptr->row_buf + 1);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef PNG_WRITE_BGR_SUPPORTED
|
||||||
|
if ((png_ptr->transformations & PNG_BGR) != 0)
|
||||||
|
png_do_bgr(row_info, png_ptr->row_buf + 1);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef PNG_WRITE_INVERT_SUPPORTED
|
||||||
|
if ((png_ptr->transformations & PNG_INVERT_MONO) != 0)
|
||||||
|
png_do_invert(row_info, png_ptr->row_buf + 1);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif /* WRITE_TRANSFORMS */
|
||||||
|
#endif /* WRITE */
|
2755
ExternalLibs/png/pngwutil.c
Normal file
2755
ExternalLibs/png/pngwutil.c
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,5 +1,5 @@
|
||||||
/* adler32.c -- compute the Adler-32 checksum of a data stream
|
/* adler32.c -- compute the Adler-32 checksum of a data stream
|
||||||
* Copyright (C) 1995-2007 Mark Adler
|
* Copyright (C) 1995-2011 Mark Adler
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -9,9 +9,9 @@
|
||||||
|
|
||||||
#define local static
|
#define local static
|
||||||
|
|
||||||
local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2);
|
local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2));
|
||||||
|
|
||||||
#define BASE 65521UL /* largest prime smaller than 65536 */
|
#define BASE 65521 /* largest prime smaller than 65536 */
|
||||||
#define NMAX 5552
|
#define NMAX 5552
|
||||||
/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
|
/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
|
||||||
|
|
||||||
|
@ -21,39 +21,44 @@ local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2);
|
||||||
#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4);
|
#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4);
|
||||||
#define DO16(buf) DO8(buf,0); DO8(buf,8);
|
#define DO16(buf) DO8(buf,0); DO8(buf,8);
|
||||||
|
|
||||||
/* use NO_DIVIDE if your processor does not do division in hardware */
|
/* use NO_DIVIDE if your processor does not do division in hardware --
|
||||||
|
try it both ways to see which is faster */
|
||||||
#ifdef NO_DIVIDE
|
#ifdef NO_DIVIDE
|
||||||
# define MOD(a) \
|
/* note that this assumes BASE is 65521, where 65536 % 65521 == 15
|
||||||
|
(thank you to John Reiser for pointing this out) */
|
||||||
|
# define CHOP(a) \
|
||||||
do { \
|
do { \
|
||||||
if (a >= (BASE << 16)) a -= (BASE << 16); \
|
unsigned long tmp = a >> 16; \
|
||||||
if (a >= (BASE << 15)) a -= (BASE << 15); \
|
a &= 0xffffUL; \
|
||||||
if (a >= (BASE << 14)) a -= (BASE << 14); \
|
a += (tmp << 4) - tmp; \
|
||||||
if (a >= (BASE << 13)) a -= (BASE << 13); \
|
} while (0)
|
||||||
if (a >= (BASE << 12)) a -= (BASE << 12); \
|
# define MOD28(a) \
|
||||||
if (a >= (BASE << 11)) a -= (BASE << 11); \
|
do { \
|
||||||
if (a >= (BASE << 10)) a -= (BASE << 10); \
|
CHOP(a); \
|
||||||
if (a >= (BASE << 9)) a -= (BASE << 9); \
|
|
||||||
if (a >= (BASE << 8)) a -= (BASE << 8); \
|
|
||||||
if (a >= (BASE << 7)) a -= (BASE << 7); \
|
|
||||||
if (a >= (BASE << 6)) a -= (BASE << 6); \
|
|
||||||
if (a >= (BASE << 5)) a -= (BASE << 5); \
|
|
||||||
if (a >= (BASE << 4)) a -= (BASE << 4); \
|
|
||||||
if (a >= (BASE << 3)) a -= (BASE << 3); \
|
|
||||||
if (a >= (BASE << 2)) a -= (BASE << 2); \
|
|
||||||
if (a >= (BASE << 1)) a -= (BASE << 1); \
|
|
||||||
if (a >= BASE) a -= BASE; \
|
if (a >= BASE) a -= BASE; \
|
||||||
} while (0)
|
} while (0)
|
||||||
# define MOD4(a) \
|
# define MOD(a) \
|
||||||
do { \
|
do { \
|
||||||
if (a >= (BASE << 4)) a -= (BASE << 4); \
|
CHOP(a); \
|
||||||
if (a >= (BASE << 3)) a -= (BASE << 3); \
|
MOD28(a); \
|
||||||
if (a >= (BASE << 2)) a -= (BASE << 2); \
|
} while (0)
|
||||||
if (a >= (BASE << 1)) a -= (BASE << 1); \
|
# define MOD63(a) \
|
||||||
|
do { /* this assumes a is not negative */ \
|
||||||
|
z_off64_t tmp = a >> 32; \
|
||||||
|
a &= 0xffffffffL; \
|
||||||
|
a += (tmp << 8) - (tmp << 5) + tmp; \
|
||||||
|
tmp = a >> 16; \
|
||||||
|
a &= 0xffffL; \
|
||||||
|
a += (tmp << 4) - tmp; \
|
||||||
|
tmp = a >> 16; \
|
||||||
|
a &= 0xffffL; \
|
||||||
|
a += (tmp << 4) - tmp; \
|
||||||
if (a >= BASE) a -= BASE; \
|
if (a >= BASE) a -= BASE; \
|
||||||
} while (0)
|
} while (0)
|
||||||
#else
|
#else
|
||||||
# define MOD(a) a %= BASE
|
# define MOD(a) a %= BASE
|
||||||
# define MOD4(a) a %= BASE
|
# define MOD28(a) a %= BASE
|
||||||
|
# define MOD63(a) a %= BASE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* ========================================================================= */
|
/* ========================================================================= */
|
||||||
|
@ -92,7 +97,7 @@ uLong ZEXPORT adler32(adler, buf, len)
|
||||||
}
|
}
|
||||||
if (adler >= BASE)
|
if (adler >= BASE)
|
||||||
adler -= BASE;
|
adler -= BASE;
|
||||||
MOD4(sum2); /* only added so many BASE's */
|
MOD28(sum2); /* only added so many BASE's */
|
||||||
return adler | (sum2 << 16);
|
return adler | (sum2 << 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,8 +142,13 @@ local uLong adler32_combine_(adler1, adler2, len2)
|
||||||
unsigned long sum2;
|
unsigned long sum2;
|
||||||
unsigned rem;
|
unsigned rem;
|
||||||
|
|
||||||
|
/* for negative len, return invalid adler32 as a clue for debugging */
|
||||||
|
if (len2 < 0)
|
||||||
|
return 0xffffffffUL;
|
||||||
|
|
||||||
/* the derivation of this formula is left as an exercise for the reader */
|
/* the derivation of this formula is left as an exercise for the reader */
|
||||||
rem = (unsigned)(len2 % BASE);
|
MOD63(len2); /* assumes len2 >= 0 */
|
||||||
|
rem = (unsigned)len2;
|
||||||
sum1 = adler1 & 0xffff;
|
sum1 = adler1 & 0xffff;
|
||||||
sum2 = rem * sum1;
|
sum2 = rem * sum1;
|
||||||
MOD(sum2);
|
MOD(sum2);
|
|
@ -29,7 +29,7 @@ int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
|
||||||
z_stream stream;
|
z_stream stream;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
stream.next_in = (Bytef*)source;
|
stream.next_in = (z_const Bytef *)source;
|
||||||
stream.avail_in = (uInt)sourceLen;
|
stream.avail_in = (uInt)sourceLen;
|
||||||
#ifdef MAXSEG_64K
|
#ifdef MAXSEG_64K
|
||||||
/* Check for source > 64K on 16-bit machine: */
|
/* Check for source > 64K on 16-bit machine: */
|
|
@ -1,5 +1,5 @@
|
||||||
/* crc32.c -- compute the CRC-32 of a data stream
|
/* crc32.c -- compute the CRC-32 of a data stream
|
||||||
* Copyright (C) 1995-2006, 2010 Mark Adler
|
* Copyright (C) 1995-2006, 2010, 2011, 2012 Mark Adler
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*
|
*
|
||||||
* Thanks to Rodney Brown <rbrown64@csc.com.au> for his contribution of faster
|
* Thanks to Rodney Brown <rbrown64@csc.com.au> for his contribution of faster
|
||||||
|
@ -17,6 +17,8 @@
|
||||||
of the crc tables. Therefore, if you #define DYNAMIC_CRC_TABLE, you should
|
of the crc tables. Therefore, if you #define DYNAMIC_CRC_TABLE, you should
|
||||||
first call get_crc_table() to initialize the tables before allowing more than
|
first call get_crc_table() to initialize the tables before allowing more than
|
||||||
one thread to use crc32().
|
one thread to use crc32().
|
||||||
|
|
||||||
|
DYNAMIC_CRC_TABLE and MAKECRCH can be #defined to write out crc32.h.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef MAKECRCH
|
#ifdef MAKECRCH
|
||||||
|
@ -30,31 +32,11 @@
|
||||||
|
|
||||||
#define local static
|
#define local static
|
||||||
|
|
||||||
/* Find a four-byte integer type for crc32_little() and crc32_big(). */
|
|
||||||
#ifndef NOBYFOUR
|
|
||||||
# ifdef STDC /* need ANSI C limits.h to determine sizes */
|
|
||||||
# include <limits.h>
|
|
||||||
# define BYFOUR
|
|
||||||
# if (UINT_MAX == 0xffffffffUL)
|
|
||||||
typedef unsigned int u4;
|
|
||||||
# else
|
|
||||||
# if (ULONG_MAX == 0xffffffffUL)
|
|
||||||
typedef unsigned long u4;
|
|
||||||
# else
|
|
||||||
# if (USHRT_MAX == 0xffffffffUL)
|
|
||||||
typedef unsigned short u4;
|
|
||||||
# else
|
|
||||||
# undef BYFOUR /* can't find a four-byte integer type! */
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
# endif /* STDC */
|
|
||||||
#endif /* !NOBYFOUR */
|
|
||||||
|
|
||||||
/* Definitions for doing the crc four data bytes at a time. */
|
/* Definitions for doing the crc four data bytes at a time. */
|
||||||
|
#if !defined(NOBYFOUR) && defined(Z_U4)
|
||||||
|
# define BYFOUR
|
||||||
|
#endif
|
||||||
#ifdef BYFOUR
|
#ifdef BYFOUR
|
||||||
# define REV(w) ((((w)>>24)&0xff)+(((w)>>8)&0xff00)+ \
|
|
||||||
(((w)&0xff00)<<8)+(((w)&0xff)<<24))
|
|
||||||
local unsigned long crc32_little OF((unsigned long,
|
local unsigned long crc32_little OF((unsigned long,
|
||||||
const unsigned char FAR *, unsigned));
|
const unsigned char FAR *, unsigned));
|
||||||
local unsigned long crc32_big OF((unsigned long,
|
local unsigned long crc32_big OF((unsigned long,
|
||||||
|
@ -68,16 +50,16 @@
|
||||||
local unsigned long gf2_matrix_times OF((unsigned long *mat,
|
local unsigned long gf2_matrix_times OF((unsigned long *mat,
|
||||||
unsigned long vec));
|
unsigned long vec));
|
||||||
local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat));
|
local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat));
|
||||||
local uLong crc32_combine_(uLong crc1, uLong crc2, z_off64_t len2);
|
local uLong crc32_combine_ OF((uLong crc1, uLong crc2, z_off64_t len2));
|
||||||
|
|
||||||
|
|
||||||
#ifdef DYNAMIC_CRC_TABLE
|
#ifdef DYNAMIC_CRC_TABLE
|
||||||
|
|
||||||
local volatile int crc_table_empty = 1;
|
local volatile int crc_table_empty = 1;
|
||||||
local unsigned long FAR crc_table[TBLS][256];
|
local z_crc_t FAR crc_table[TBLS][256];
|
||||||
local void make_crc_table OF((void));
|
local void make_crc_table OF((void));
|
||||||
#ifdef MAKECRCH
|
#ifdef MAKECRCH
|
||||||
local void write_table OF((FILE *, const unsigned long FAR *));
|
local void write_table OF((FILE *, const z_crc_t FAR *));
|
||||||
#endif /* MAKECRCH */
|
#endif /* MAKECRCH */
|
||||||
/*
|
/*
|
||||||
Generate tables for a byte-wise 32-bit CRC calculation on the polynomial:
|
Generate tables for a byte-wise 32-bit CRC calculation on the polynomial:
|
||||||
|
@ -107,9 +89,9 @@ local void make_crc_table OF((void));
|
||||||
*/
|
*/
|
||||||
local void make_crc_table()
|
local void make_crc_table()
|
||||||
{
|
{
|
||||||
unsigned long c;
|
z_crc_t c;
|
||||||
int n, k;
|
int n, k;
|
||||||
unsigned long poly; /* polynomial exclusive-or pattern */
|
z_crc_t poly; /* polynomial exclusive-or pattern */
|
||||||
/* terms of polynomial defining this crc (except x^32): */
|
/* terms of polynomial defining this crc (except x^32): */
|
||||||
static volatile int first = 1; /* flag to limit concurrent making */
|
static volatile int first = 1; /* flag to limit concurrent making */
|
||||||
static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};
|
static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};
|
||||||
|
@ -121,13 +103,13 @@ local void make_crc_table()
|
||||||
first = 0;
|
first = 0;
|
||||||
|
|
||||||
/* make exclusive-or pattern from polynomial (0xedb88320UL) */
|
/* make exclusive-or pattern from polynomial (0xedb88320UL) */
|
||||||
poly = 0UL;
|
poly = 0;
|
||||||
for (n = 0; n < sizeof(p)/sizeof(unsigned char); n++)
|
for (n = 0; n < (int)(sizeof(p)/sizeof(unsigned char)); n++)
|
||||||
poly |= 1UL << (31 - p[n]);
|
poly |= (z_crc_t)1 << (31 - p[n]);
|
||||||
|
|
||||||
/* generate a crc for every 8-bit value */
|
/* generate a crc for every 8-bit value */
|
||||||
for (n = 0; n < 256; n++) {
|
for (n = 0; n < 256; n++) {
|
||||||
c = (unsigned long)n;
|
c = (z_crc_t)n;
|
||||||
for (k = 0; k < 8; k++)
|
for (k = 0; k < 8; k++)
|
||||||
c = c & 1 ? poly ^ (c >> 1) : c >> 1;
|
c = c & 1 ? poly ^ (c >> 1) : c >> 1;
|
||||||
crc_table[0][n] = c;
|
crc_table[0][n] = c;
|
||||||
|
@ -138,11 +120,11 @@ local void make_crc_table()
|
||||||
and then the byte reversal of those as well as the first table */
|
and then the byte reversal of those as well as the first table */
|
||||||
for (n = 0; n < 256; n++) {
|
for (n = 0; n < 256; n++) {
|
||||||
c = crc_table[0][n];
|
c = crc_table[0][n];
|
||||||
crc_table[4][n] = REV(c);
|
crc_table[4][n] = ZSWAP32(c);
|
||||||
for (k = 1; k < 4; k++) {
|
for (k = 1; k < 4; k++) {
|
||||||
c = crc_table[0][c & 0xff] ^ (c >> 8);
|
c = crc_table[0][c & 0xff] ^ (c >> 8);
|
||||||
crc_table[k][n] = c;
|
crc_table[k][n] = c;
|
||||||
crc_table[k + 4][n] = REV(c);
|
crc_table[k + 4][n] = ZSWAP32(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* BYFOUR */
|
#endif /* BYFOUR */
|
||||||
|
@ -164,7 +146,7 @@ local void make_crc_table()
|
||||||
if (out == NULL) return;
|
if (out == NULL) return;
|
||||||
fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n");
|
fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n");
|
||||||
fprintf(out, " * Generated automatically by crc32.c\n */\n\n");
|
fprintf(out, " * Generated automatically by crc32.c\n */\n\n");
|
||||||
fprintf(out, "local const unsigned long FAR ");
|
fprintf(out, "local const z_crc_t FAR ");
|
||||||
fprintf(out, "crc_table[TBLS][256] =\n{\n {\n");
|
fprintf(out, "crc_table[TBLS][256] =\n{\n {\n");
|
||||||
write_table(out, crc_table[0]);
|
write_table(out, crc_table[0]);
|
||||||
# ifdef BYFOUR
|
# ifdef BYFOUR
|
||||||
|
@ -184,12 +166,13 @@ local void make_crc_table()
|
||||||
#ifdef MAKECRCH
|
#ifdef MAKECRCH
|
||||||
local void write_table(out, table)
|
local void write_table(out, table)
|
||||||
FILE *out;
|
FILE *out;
|
||||||
const unsigned long FAR *table;
|
const z_crc_t FAR *table;
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
for (n = 0; n < 256; n++)
|
for (n = 0; n < 256; n++)
|
||||||
fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : " ", table[n],
|
fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : " ",
|
||||||
|
(unsigned long)(table[n]),
|
||||||
n == 255 ? "\n" : (n % 5 == 4 ? ",\n" : ", "));
|
n == 255 ? "\n" : (n % 5 == 4 ? ",\n" : ", "));
|
||||||
}
|
}
|
||||||
#endif /* MAKECRCH */
|
#endif /* MAKECRCH */
|
||||||
|
@ -204,13 +187,13 @@ local void write_table(out, table)
|
||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
* This function can be used by asm versions of crc32()
|
* This function can be used by asm versions of crc32()
|
||||||
*/
|
*/
|
||||||
const unsigned long FAR * ZEXPORT get_crc_table()
|
const z_crc_t FAR * ZEXPORT get_crc_table()
|
||||||
{
|
{
|
||||||
#ifdef DYNAMIC_CRC_TABLE
|
#ifdef DYNAMIC_CRC_TABLE
|
||||||
if (crc_table_empty)
|
if (crc_table_empty)
|
||||||
make_crc_table();
|
make_crc_table();
|
||||||
#endif /* DYNAMIC_CRC_TABLE */
|
#endif /* DYNAMIC_CRC_TABLE */
|
||||||
return (const unsigned long FAR *)crc_table;
|
return (const z_crc_t FAR *)crc_table;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ========================================================================= */
|
/* ========================================================================= */
|
||||||
|
@ -232,7 +215,7 @@ unsigned long ZEXPORT crc32(crc, buf, len)
|
||||||
|
|
||||||
#ifdef BYFOUR
|
#ifdef BYFOUR
|
||||||
if (sizeof(void *) == sizeof(ptrdiff_t)) {
|
if (sizeof(void *) == sizeof(ptrdiff_t)) {
|
||||||
u4 endian;
|
z_crc_t endian;
|
||||||
|
|
||||||
endian = 1;
|
endian = 1;
|
||||||
if (*((unsigned char *)(&endian)))
|
if (*((unsigned char *)(&endian)))
|
||||||
|
@ -266,17 +249,17 @@ local unsigned long crc32_little(crc, buf, len)
|
||||||
const unsigned char FAR *buf;
|
const unsigned char FAR *buf;
|
||||||
unsigned len;
|
unsigned len;
|
||||||
{
|
{
|
||||||
register u4 c;
|
register z_crc_t c;
|
||||||
register const u4 FAR *buf4;
|
register const z_crc_t FAR *buf4;
|
||||||
|
|
||||||
c = (u4)crc;
|
c = (z_crc_t)crc;
|
||||||
c = ~c;
|
c = ~c;
|
||||||
while (len && ((ptrdiff_t)buf & 3)) {
|
while (len && ((ptrdiff_t)buf & 3)) {
|
||||||
c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8);
|
c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8);
|
||||||
len--;
|
len--;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf4 = (const u4 FAR *)(const void FAR *)buf;
|
buf4 = (const z_crc_t FAR *)(const void FAR *)buf;
|
||||||
while (len >= 32) {
|
while (len >= 32) {
|
||||||
DOLIT32;
|
DOLIT32;
|
||||||
len -= 32;
|
len -= 32;
|
||||||
|
@ -306,17 +289,17 @@ local unsigned long crc32_big(crc, buf, len)
|
||||||
const unsigned char FAR *buf;
|
const unsigned char FAR *buf;
|
||||||
unsigned len;
|
unsigned len;
|
||||||
{
|
{
|
||||||
register u4 c;
|
register z_crc_t c;
|
||||||
register const u4 FAR *buf4;
|
register const z_crc_t FAR *buf4;
|
||||||
|
|
||||||
c = REV((u4)crc);
|
c = ZSWAP32((z_crc_t)crc);
|
||||||
c = ~c;
|
c = ~c;
|
||||||
while (len && ((ptrdiff_t)buf & 3)) {
|
while (len && ((ptrdiff_t)buf & 3)) {
|
||||||
c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
|
c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
|
||||||
len--;
|
len--;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf4 = (const u4 FAR *)(const void FAR *)buf;
|
buf4 = (const z_crc_t FAR *)(const void FAR *)buf;
|
||||||
buf4--;
|
buf4--;
|
||||||
while (len >= 32) {
|
while (len >= 32) {
|
||||||
DOBIG32;
|
DOBIG32;
|
||||||
|
@ -333,7 +316,7 @@ local unsigned long crc32_big(crc, buf, len)
|
||||||
c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
|
c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
|
||||||
} while (--len);
|
} while (--len);
|
||||||
c = ~c;
|
c = ~c;
|
||||||
return (unsigned long)(REV(c));
|
return (unsigned long)(ZSWAP32(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* BYFOUR */
|
#endif /* BYFOUR */
|
|
@ -2,7 +2,7 @@
|
||||||
* Generated automatically by crc32.c
|
* Generated automatically by crc32.c
|
||||||
*/
|
*/
|
||||||
|
|
||||||
local const unsigned long FAR crc_table[TBLS][256] =
|
local const z_crc_t FAR crc_table[TBLS][256] =
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL,
|
0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL,
|
|
@ -1,5 +1,5 @@
|
||||||
/* deflate.c -- compress data using the deflation algorithm
|
/* deflate.c -- compress data using the deflation algorithm
|
||||||
* Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler
|
* Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
* REFERENCES
|
* REFERENCES
|
||||||
*
|
*
|
||||||
* Deutsch, L.P.,"DEFLATE Compressed Data Format Specification".
|
* Deutsch, L.P.,"DEFLATE Compressed Data Format Specification".
|
||||||
* Available in http://www.ietf.org/rfc/rfc1951.txt
|
* Available in http://tools.ietf.org/html/rfc1951
|
||||||
*
|
*
|
||||||
* A description of the Rabin and Karp algorithm is given in the book
|
* A description of the Rabin and Karp algorithm is given in the book
|
||||||
* "Algorithms" by R. Sedgewick, Addison-Wesley, p252.
|
* "Algorithms" by R. Sedgewick, Addison-Wesley, p252.
|
||||||
|
@ -52,7 +52,7 @@
|
||||||
#include "deflate.h"
|
#include "deflate.h"
|
||||||
|
|
||||||
const char deflate_copyright[] =
|
const char deflate_copyright[] =
|
||||||
" deflate 1.2.5 Copyright 1995-2010 Jean-loup Gailly and Mark Adler ";
|
" deflate 1.2.8 Copyright 1995-2013 Jean-loup Gailly and Mark Adler ";
|
||||||
/*
|
/*
|
||||||
If you use the zlib library in a product, an acknowledgment is welcome
|
If you use the zlib library in a product, an acknowledgment is welcome
|
||||||
in the documentation of your product. If for some reason you cannot
|
in the documentation of your product. If for some reason you cannot
|
||||||
|
@ -155,6 +155,9 @@ local const config configuration_table[10] = {
|
||||||
struct static_tree_desc_s {int dummy;}; /* for buggy compilers */
|
struct static_tree_desc_s {int dummy;}; /* for buggy compilers */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* rank Z_BLOCK between Z_NO_FLUSH and Z_PARTIAL_FLUSH */
|
||||||
|
#define RANK(f) (((f) << 1) - ((f) > 4 ? 9 : 0))
|
||||||
|
|
||||||
/* ===========================================================================
|
/* ===========================================================================
|
||||||
* Update a hash value with the given input byte
|
* Update a hash value with the given input byte
|
||||||
* IN assertion: all calls to to UPDATE_HASH are made with consecutive
|
* IN assertion: all calls to to UPDATE_HASH are made with consecutive
|
||||||
|
@ -235,10 +238,19 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
|
||||||
|
|
||||||
strm->msg = Z_NULL;
|
strm->msg = Z_NULL;
|
||||||
if (strm->zalloc == (alloc_func)0) {
|
if (strm->zalloc == (alloc_func)0) {
|
||||||
|
#ifdef Z_SOLO
|
||||||
|
return Z_STREAM_ERROR;
|
||||||
|
#else
|
||||||
strm->zalloc = zcalloc;
|
strm->zalloc = zcalloc;
|
||||||
strm->opaque = (voidpf)0;
|
strm->opaque = (voidpf)0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if (strm->zfree == (free_func)0) strm->zfree = zcfree;
|
if (strm->zfree == (free_func)0)
|
||||||
|
#ifdef Z_SOLO
|
||||||
|
return Z_STREAM_ERROR;
|
||||||
|
#else
|
||||||
|
strm->zfree = zcfree;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef FASTEST
|
#ifdef FASTEST
|
||||||
if (level != 0) level = 1;
|
if (level != 0) level = 1;
|
||||||
|
@ -293,7 +305,7 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
|
||||||
if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL ||
|
if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL ||
|
||||||
s->pending_buf == Z_NULL) {
|
s->pending_buf == Z_NULL) {
|
||||||
s->status = FINISH_STATE;
|
s->status = FINISH_STATE;
|
||||||
strm->msg = (char*)ERR_MSG(Z_MEM_ERROR);
|
strm->msg = ERR_MSG(Z_MEM_ERROR);
|
||||||
deflateEnd (strm);
|
deflateEnd (strm);
|
||||||
return Z_MEM_ERROR;
|
return Z_MEM_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -314,43 +326,70 @@ int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength)
|
||||||
uInt dictLength;
|
uInt dictLength;
|
||||||
{
|
{
|
||||||
deflate_state *s;
|
deflate_state *s;
|
||||||
uInt length = dictLength;
|
uInt str, n;
|
||||||
uInt n;
|
int wrap;
|
||||||
IPos hash_head = 0;
|
unsigned avail;
|
||||||
|
z_const unsigned char *next;
|
||||||
|
|
||||||
if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL ||
|
if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL)
|
||||||
strm->state->wrap == 2 ||
|
return Z_STREAM_ERROR;
|
||||||
(strm->state->wrap == 1 && strm->state->status != INIT_STATE))
|
s = strm->state;
|
||||||
|
wrap = s->wrap;
|
||||||
|
if (wrap == 2 || (wrap == 1 && s->status != INIT_STATE) || s->lookahead)
|
||||||
return Z_STREAM_ERROR;
|
return Z_STREAM_ERROR;
|
||||||
|
|
||||||
s = strm->state;
|
/* when using zlib wrappers, compute Adler-32 for provided dictionary */
|
||||||
if (s->wrap)
|
if (wrap == 1)
|
||||||
strm->adler = adler32(strm->adler, dictionary, dictLength);
|
strm->adler = adler32(strm->adler, dictionary, dictLength);
|
||||||
|
s->wrap = 0; /* avoid computing Adler-32 in read_buf */
|
||||||
|
|
||||||
if (length < MIN_MATCH) return Z_OK;
|
/* if dictionary would fill window, just replace the history */
|
||||||
if (length > s->w_size) {
|
if (dictLength >= s->w_size) {
|
||||||
length = s->w_size;
|
if (wrap == 0) { /* already empty otherwise */
|
||||||
dictionary += dictLength - length; /* use the tail of the dictionary */
|
CLEAR_HASH(s);
|
||||||
|
s->strstart = 0;
|
||||||
|
s->block_start = 0L;
|
||||||
|
s->insert = 0;
|
||||||
|
}
|
||||||
|
dictionary += dictLength - s->w_size; /* use the tail */
|
||||||
|
dictLength = s->w_size;
|
||||||
}
|
}
|
||||||
zmemcpy(s->window, dictionary, length);
|
|
||||||
s->strstart = length;
|
|
||||||
s->block_start = (long)length;
|
|
||||||
|
|
||||||
/* Insert all strings in the hash table (except for the last two bytes).
|
/* insert dictionary into window and hash */
|
||||||
* s->lookahead stays null, so s->ins_h will be recomputed at the next
|
avail = strm->avail_in;
|
||||||
* call of fill_window.
|
next = strm->next_in;
|
||||||
*/
|
strm->avail_in = dictLength;
|
||||||
s->ins_h = s->window[0];
|
strm->next_in = (z_const Bytef *)dictionary;
|
||||||
UPDATE_HASH(s, s->ins_h, s->window[1]);
|
fill_window(s);
|
||||||
for (n = 0; n <= length - MIN_MATCH; n++) {
|
while (s->lookahead >= MIN_MATCH) {
|
||||||
INSERT_STRING(s, n, hash_head);
|
str = s->strstart;
|
||||||
|
n = s->lookahead - (MIN_MATCH-1);
|
||||||
|
do {
|
||||||
|
UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]);
|
||||||
|
#ifndef FASTEST
|
||||||
|
s->prev[str & s->w_mask] = s->head[s->ins_h];
|
||||||
|
#endif
|
||||||
|
s->head[s->ins_h] = (Pos)str;
|
||||||
|
str++;
|
||||||
|
} while (--n);
|
||||||
|
s->strstart = str;
|
||||||
|
s->lookahead = MIN_MATCH-1;
|
||||||
|
fill_window(s);
|
||||||
}
|
}
|
||||||
if (hash_head) hash_head = 0; /* to make compiler happy */
|
s->strstart += s->lookahead;
|
||||||
|
s->block_start = (long)s->strstart;
|
||||||
|
s->insert = s->lookahead;
|
||||||
|
s->lookahead = 0;
|
||||||
|
s->match_length = s->prev_length = MIN_MATCH-1;
|
||||||
|
s->match_available = 0;
|
||||||
|
strm->next_in = next;
|
||||||
|
strm->avail_in = avail;
|
||||||
|
s->wrap = wrap;
|
||||||
return Z_OK;
|
return Z_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ========================================================================= */
|
/* ========================================================================= */
|
||||||
int ZEXPORT deflateReset (strm)
|
int ZEXPORT deflateResetKeep (strm)
|
||||||
z_streamp strm;
|
z_streamp strm;
|
||||||
{
|
{
|
||||||
deflate_state *s;
|
deflate_state *s;
|
||||||
|
@ -380,11 +419,22 @@ int ZEXPORT deflateReset (strm)
|
||||||
s->last_flush = Z_NO_FLUSH;
|
s->last_flush = Z_NO_FLUSH;
|
||||||
|
|
||||||
_tr_init(s);
|
_tr_init(s);
|
||||||
lm_init(s);
|
|
||||||
|
|
||||||
return Z_OK;
|
return Z_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ========================================================================= */
|
||||||
|
int ZEXPORT deflateReset (strm)
|
||||||
|
z_streamp strm;
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = deflateResetKeep(strm);
|
||||||
|
if (ret == Z_OK)
|
||||||
|
lm_init(strm->state);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/* ========================================================================= */
|
/* ========================================================================= */
|
||||||
int ZEXPORT deflateSetHeader (strm, head)
|
int ZEXPORT deflateSetHeader (strm, head)
|
||||||
z_streamp strm;
|
z_streamp strm;
|
||||||
|
@ -396,15 +446,43 @@ int ZEXPORT deflateSetHeader (strm, head)
|
||||||
return Z_OK;
|
return Z_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ========================================================================= */
|
||||||
|
int ZEXPORT deflatePending (strm, pending, bits)
|
||||||
|
unsigned *pending;
|
||||||
|
int *bits;
|
||||||
|
z_streamp strm;
|
||||||
|
{
|
||||||
|
if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
|
||||||
|
if (pending != Z_NULL)
|
||||||
|
*pending = strm->state->pending;
|
||||||
|
if (bits != Z_NULL)
|
||||||
|
*bits = strm->state->bi_valid;
|
||||||
|
return Z_OK;
|
||||||
|
}
|
||||||
|
|
||||||
/* ========================================================================= */
|
/* ========================================================================= */
|
||||||
int ZEXPORT deflatePrime (strm, bits, value)
|
int ZEXPORT deflatePrime (strm, bits, value)
|
||||||
z_streamp strm;
|
z_streamp strm;
|
||||||
int bits;
|
int bits;
|
||||||
int value;
|
int value;
|
||||||
{
|
{
|
||||||
|
deflate_state *s;
|
||||||
|
int put;
|
||||||
|
|
||||||
if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
|
if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
|
||||||
strm->state->bi_valid = bits;
|
s = strm->state;
|
||||||
strm->state->bi_buf = (ush)(value & ((1 << bits) - 1));
|
if ((Bytef *)(s->d_buf) < s->pending_out + ((Buf_size + 7) >> 3))
|
||||||
|
return Z_BUF_ERROR;
|
||||||
|
do {
|
||||||
|
put = Buf_size - s->bi_valid;
|
||||||
|
if (put > bits)
|
||||||
|
put = bits;
|
||||||
|
s->bi_buf |= (ush)((value & ((1 << put) - 1)) << s->bi_valid);
|
||||||
|
s->bi_valid += put;
|
||||||
|
_tr_flush_bits(s);
|
||||||
|
value >>= put;
|
||||||
|
bits -= put;
|
||||||
|
} while (bits);
|
||||||
return Z_OK;
|
return Z_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -435,6 +513,8 @@ int ZEXPORT deflateParams(strm, level, strategy)
|
||||||
strm->total_in != 0) {
|
strm->total_in != 0) {
|
||||||
/* Flush the last buffer: */
|
/* Flush the last buffer: */
|
||||||
err = deflate(strm, Z_BLOCK);
|
err = deflate(strm, Z_BLOCK);
|
||||||
|
if (err == Z_BUF_ERROR && s->pending == 0)
|
||||||
|
err = Z_OK;
|
||||||
}
|
}
|
||||||
if (s->level != level) {
|
if (s->level != level) {
|
||||||
s->level = level;
|
s->level = level;
|
||||||
|
@ -562,19 +642,22 @@ local void putShortMSB (s, b)
|
||||||
local void flush_pending(strm)
|
local void flush_pending(strm)
|
||||||
z_streamp strm;
|
z_streamp strm;
|
||||||
{
|
{
|
||||||
unsigned len = strm->state->pending;
|
unsigned len;
|
||||||
|
deflate_state *s = strm->state;
|
||||||
|
|
||||||
|
_tr_flush_bits(s);
|
||||||
|
len = s->pending;
|
||||||
if (len > strm->avail_out) len = strm->avail_out;
|
if (len > strm->avail_out) len = strm->avail_out;
|
||||||
if (len == 0) return;
|
if (len == 0) return;
|
||||||
|
|
||||||
zmemcpy(strm->next_out, strm->state->pending_out, len);
|
zmemcpy(strm->next_out, s->pending_out, len);
|
||||||
strm->next_out += len;
|
strm->next_out += len;
|
||||||
strm->state->pending_out += len;
|
s->pending_out += len;
|
||||||
strm->total_out += len;
|
strm->total_out += len;
|
||||||
strm->avail_out -= len;
|
strm->avail_out -= len;
|
||||||
strm->state->pending -= len;
|
s->pending -= len;
|
||||||
if (strm->state->pending == 0) {
|
if (s->pending == 0) {
|
||||||
strm->state->pending_out = strm->state->pending_buf;
|
s->pending_out = s->pending_buf;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -801,7 +884,7 @@ int ZEXPORT deflate (strm, flush)
|
||||||
* flushes. For repeated and useless calls with Z_FINISH, we keep
|
* flushes. For repeated and useless calls with Z_FINISH, we keep
|
||||||
* returning Z_STREAM_END instead of Z_BUF_ERROR.
|
* returning Z_STREAM_END instead of Z_BUF_ERROR.
|
||||||
*/
|
*/
|
||||||
} else if (strm->avail_in == 0 && flush <= old_flush &&
|
} else if (strm->avail_in == 0 && RANK(flush) <= RANK(old_flush) &&
|
||||||
flush != Z_FINISH) {
|
flush != Z_FINISH) {
|
||||||
ERR_RETURN(strm, Z_BUF_ERROR);
|
ERR_RETURN(strm, Z_BUF_ERROR);
|
||||||
}
|
}
|
||||||
|
@ -850,6 +933,7 @@ int ZEXPORT deflate (strm, flush)
|
||||||
if (s->lookahead == 0) {
|
if (s->lookahead == 0) {
|
||||||
s->strstart = 0;
|
s->strstart = 0;
|
||||||
s->block_start = 0L;
|
s->block_start = 0L;
|
||||||
|
s->insert = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -945,12 +1029,12 @@ int ZEXPORT deflateCopy (dest, source)
|
||||||
|
|
||||||
ss = source->state;
|
ss = source->state;
|
||||||
|
|
||||||
zmemcpy(dest, source, sizeof(z_stream));
|
zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream));
|
||||||
|
|
||||||
ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state));
|
ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state));
|
||||||
if (ds == Z_NULL) return Z_MEM_ERROR;
|
if (ds == Z_NULL) return Z_MEM_ERROR;
|
||||||
dest->state = (struct internal_state FAR *) ds;
|
dest->state = (struct internal_state FAR *) ds;
|
||||||
zmemcpy(ds, ss, sizeof(deflate_state));
|
zmemcpy((voidpf)ds, (voidpf)ss, sizeof(deflate_state));
|
||||||
ds->strm = dest;
|
ds->strm = dest;
|
||||||
|
|
||||||
ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte));
|
ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte));
|
||||||
|
@ -966,8 +1050,8 @@ int ZEXPORT deflateCopy (dest, source)
|
||||||
}
|
}
|
||||||
/* following zmemcpy do not work for 16-bit MSDOS */
|
/* following zmemcpy do not work for 16-bit MSDOS */
|
||||||
zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte));
|
zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte));
|
||||||
zmemcpy(ds->prev, ss->prev, ds->w_size * sizeof(Pos));
|
zmemcpy((voidpf)ds->prev, (voidpf)ss->prev, ds->w_size * sizeof(Pos));
|
||||||
zmemcpy(ds->head, ss->head, ds->hash_size * sizeof(Pos));
|
zmemcpy((voidpf)ds->head, (voidpf)ss->head, ds->hash_size * sizeof(Pos));
|
||||||
zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size);
|
zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size);
|
||||||
|
|
||||||
ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf);
|
ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf);
|
||||||
|
@ -1001,15 +1085,15 @@ local int read_buf(strm, buf, size)
|
||||||
|
|
||||||
strm->avail_in -= len;
|
strm->avail_in -= len;
|
||||||
|
|
||||||
|
zmemcpy(buf, strm->next_in, len);
|
||||||
if (strm->state->wrap == 1) {
|
if (strm->state->wrap == 1) {
|
||||||
strm->adler = adler32(strm->adler, strm->next_in, len);
|
strm->adler = adler32(strm->adler, buf, len);
|
||||||
}
|
}
|
||||||
#ifdef GZIP
|
#ifdef GZIP
|
||||||
else if (strm->state->wrap == 2) {
|
else if (strm->state->wrap == 2) {
|
||||||
strm->adler = crc32(strm->adler, strm->next_in, len);
|
strm->adler = crc32(strm->adler, buf, len);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
zmemcpy(buf, strm->next_in, len);
|
|
||||||
strm->next_in += len;
|
strm->next_in += len;
|
||||||
strm->total_in += len;
|
strm->total_in += len;
|
||||||
|
|
||||||
|
@ -1036,6 +1120,7 @@ local void lm_init (s)
|
||||||
s->strstart = 0;
|
s->strstart = 0;
|
||||||
s->block_start = 0L;
|
s->block_start = 0L;
|
||||||
s->lookahead = 0;
|
s->lookahead = 0;
|
||||||
|
s->insert = 0;
|
||||||
s->match_length = s->prev_length = MIN_MATCH-1;
|
s->match_length = s->prev_length = MIN_MATCH-1;
|
||||||
s->match_available = 0;
|
s->match_available = 0;
|
||||||
s->ins_h = 0;
|
s->ins_h = 0;
|
||||||
|
@ -1310,6 +1395,8 @@ local void fill_window(s)
|
||||||
unsigned more; /* Amount of free space at the end of the window. */
|
unsigned more; /* Amount of free space at the end of the window. */
|
||||||
uInt wsize = s->w_size;
|
uInt wsize = s->w_size;
|
||||||
|
|
||||||
|
Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead");
|
||||||
|
|
||||||
do {
|
do {
|
||||||
more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart);
|
more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart);
|
||||||
|
|
||||||
|
@ -1362,7 +1449,7 @@ local void fill_window(s)
|
||||||
#endif
|
#endif
|
||||||
more += wsize;
|
more += wsize;
|
||||||
}
|
}
|
||||||
if (s->strm->avail_in == 0) return;
|
if (s->strm->avail_in == 0) break;
|
||||||
|
|
||||||
/* If there was no sliding:
|
/* If there was no sliding:
|
||||||
* strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 &&
|
* strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 &&
|
||||||
|
@ -1381,12 +1468,24 @@ local void fill_window(s)
|
||||||
s->lookahead += n;
|
s->lookahead += n;
|
||||||
|
|
||||||
/* Initialize the hash value now that we have some input: */
|
/* Initialize the hash value now that we have some input: */
|
||||||
if (s->lookahead >= MIN_MATCH) {
|
if (s->lookahead + s->insert >= MIN_MATCH) {
|
||||||
s->ins_h = s->window[s->strstart];
|
uInt str = s->strstart - s->insert;
|
||||||
UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]);
|
s->ins_h = s->window[str];
|
||||||
|
UPDATE_HASH(s, s->ins_h, s->window[str + 1]);
|
||||||
#if MIN_MATCH != 3
|
#if MIN_MATCH != 3
|
||||||
Call UPDATE_HASH() MIN_MATCH-3 more times
|
Call UPDATE_HASH() MIN_MATCH-3 more times
|
||||||
#endif
|
#endif
|
||||||
|
while (s->insert) {
|
||||||
|
UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]);
|
||||||
|
#ifndef FASTEST
|
||||||
|
s->prev[str & s->w_mask] = s->head[s->ins_h];
|
||||||
|
#endif
|
||||||
|
s->head[s->ins_h] = (Pos)str;
|
||||||
|
str++;
|
||||||
|
s->insert--;
|
||||||
|
if (s->lookahead + s->insert < MIN_MATCH)
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* If the whole input has less than MIN_MATCH bytes, ins_h is garbage,
|
/* If the whole input has less than MIN_MATCH bytes, ins_h is garbage,
|
||||||
* but this is not important since only literal bytes will be emitted.
|
* but this is not important since only literal bytes will be emitted.
|
||||||
|
@ -1427,6 +1526,9 @@ local void fill_window(s)
|
||||||
s->high_water += init;
|
s->high_water += init;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD,
|
||||||
|
"not enough room for search");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===========================================================================
|
/* ===========================================================================
|
||||||
|
@ -1506,8 +1608,14 @@ local block_state deflate_stored(s, flush)
|
||||||
FLUSH_BLOCK(s, 0);
|
FLUSH_BLOCK(s, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FLUSH_BLOCK(s, flush == Z_FINISH);
|
s->insert = 0;
|
||||||
return flush == Z_FINISH ? finish_done : block_done;
|
if (flush == Z_FINISH) {
|
||||||
|
FLUSH_BLOCK(s, 1);
|
||||||
|
return finish_done;
|
||||||
|
}
|
||||||
|
if ((long)s->strstart > s->block_start)
|
||||||
|
FLUSH_BLOCK(s, 0);
|
||||||
|
return block_done;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===========================================================================
|
/* ===========================================================================
|
||||||
|
@ -1603,8 +1711,14 @@ local block_state deflate_fast(s, flush)
|
||||||
}
|
}
|
||||||
if (bflush) FLUSH_BLOCK(s, 0);
|
if (bflush) FLUSH_BLOCK(s, 0);
|
||||||
}
|
}
|
||||||
FLUSH_BLOCK(s, flush == Z_FINISH);
|
s->insert = s->strstart < MIN_MATCH-1 ? s->strstart : MIN_MATCH-1;
|
||||||
return flush == Z_FINISH ? finish_done : block_done;
|
if (flush == Z_FINISH) {
|
||||||
|
FLUSH_BLOCK(s, 1);
|
||||||
|
return finish_done;
|
||||||
|
}
|
||||||
|
if (s->last_lit)
|
||||||
|
FLUSH_BLOCK(s, 0);
|
||||||
|
return block_done;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef FASTEST
|
#ifndef FASTEST
|
||||||
|
@ -1728,8 +1842,14 @@ local block_state deflate_slow(s, flush)
|
||||||
_tr_tally_lit(s, s->window[s->strstart-1], bflush);
|
_tr_tally_lit(s, s->window[s->strstart-1], bflush);
|
||||||
s->match_available = 0;
|
s->match_available = 0;
|
||||||
}
|
}
|
||||||
FLUSH_BLOCK(s, flush == Z_FINISH);
|
s->insert = s->strstart < MIN_MATCH-1 ? s->strstart : MIN_MATCH-1;
|
||||||
return flush == Z_FINISH ? finish_done : block_done;
|
if (flush == Z_FINISH) {
|
||||||
|
FLUSH_BLOCK(s, 1);
|
||||||
|
return finish_done;
|
||||||
|
}
|
||||||
|
if (s->last_lit)
|
||||||
|
FLUSH_BLOCK(s, 0);
|
||||||
|
return block_done;
|
||||||
}
|
}
|
||||||
#endif /* FASTEST */
|
#endif /* FASTEST */
|
||||||
|
|
||||||
|
@ -1749,11 +1869,11 @@ local block_state deflate_rle(s, flush)
|
||||||
for (;;) {
|
for (;;) {
|
||||||
/* Make sure that we always have enough lookahead, except
|
/* Make sure that we always have enough lookahead, except
|
||||||
* at the end of the input file. We need MAX_MATCH bytes
|
* at the end of the input file. We need MAX_MATCH bytes
|
||||||
* for the longest encodable run.
|
* for the longest run, plus one for the unrolled loop.
|
||||||
*/
|
*/
|
||||||
if (s->lookahead < MAX_MATCH) {
|
if (s->lookahead <= MAX_MATCH) {
|
||||||
fill_window(s);
|
fill_window(s);
|
||||||
if (s->lookahead < MAX_MATCH && flush == Z_NO_FLUSH) {
|
if (s->lookahead <= MAX_MATCH && flush == Z_NO_FLUSH) {
|
||||||
return need_more;
|
return need_more;
|
||||||
}
|
}
|
||||||
if (s->lookahead == 0) break; /* flush the current block */
|
if (s->lookahead == 0) break; /* flush the current block */
|
||||||
|
@ -1776,6 +1896,7 @@ local block_state deflate_rle(s, flush)
|
||||||
if (s->match_length > s->lookahead)
|
if (s->match_length > s->lookahead)
|
||||||
s->match_length = s->lookahead;
|
s->match_length = s->lookahead;
|
||||||
}
|
}
|
||||||
|
Assert(scan <= s->window+(uInt)(s->window_size-1), "wild scan");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Emit match if have run of MIN_MATCH or longer, else emit literal */
|
/* Emit match if have run of MIN_MATCH or longer, else emit literal */
|
||||||
|
@ -1796,8 +1917,14 @@ local block_state deflate_rle(s, flush)
|
||||||
}
|
}
|
||||||
if (bflush) FLUSH_BLOCK(s, 0);
|
if (bflush) FLUSH_BLOCK(s, 0);
|
||||||
}
|
}
|
||||||
FLUSH_BLOCK(s, flush == Z_FINISH);
|
s->insert = 0;
|
||||||
return flush == Z_FINISH ? finish_done : block_done;
|
if (flush == Z_FINISH) {
|
||||||
|
FLUSH_BLOCK(s, 1);
|
||||||
|
return finish_done;
|
||||||
|
}
|
||||||
|
if (s->last_lit)
|
||||||
|
FLUSH_BLOCK(s, 0);
|
||||||
|
return block_done;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===========================================================================
|
/* ===========================================================================
|
||||||
|
@ -1829,6 +1956,12 @@ local block_state deflate_huff(s, flush)
|
||||||
s->strstart++;
|
s->strstart++;
|
||||||
if (bflush) FLUSH_BLOCK(s, 0);
|
if (bflush) FLUSH_BLOCK(s, 0);
|
||||||
}
|
}
|
||||||
FLUSH_BLOCK(s, flush == Z_FINISH);
|
s->insert = 0;
|
||||||
return flush == Z_FINISH ? finish_done : block_done;
|
if (flush == Z_FINISH) {
|
||||||
|
FLUSH_BLOCK(s, 1);
|
||||||
|
return finish_done;
|
||||||
|
}
|
||||||
|
if (s->last_lit)
|
||||||
|
FLUSH_BLOCK(s, 0);
|
||||||
|
return block_done;
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
/* deflate.h -- internal compression state
|
/* deflate.h -- internal compression state
|
||||||
* Copyright (C) 1995-2010 Jean-loup Gailly
|
* Copyright (C) 1995-2012 Jean-loup Gailly
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -48,6 +48,9 @@
|
||||||
#define MAX_BITS 15
|
#define MAX_BITS 15
|
||||||
/* All codes must not exceed MAX_BITS bits */
|
/* All codes must not exceed MAX_BITS bits */
|
||||||
|
|
||||||
|
#define Buf_size 16
|
||||||
|
/* size of bit buffer in bi_buf */
|
||||||
|
|
||||||
#define INIT_STATE 42
|
#define INIT_STATE 42
|
||||||
#define EXTRA_STATE 69
|
#define EXTRA_STATE 69
|
||||||
#define NAME_STATE 73
|
#define NAME_STATE 73
|
||||||
|
@ -101,7 +104,7 @@ typedef struct internal_state {
|
||||||
int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
|
int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
|
||||||
gz_headerp gzhead; /* gzip header information to write */
|
gz_headerp gzhead; /* gzip header information to write */
|
||||||
uInt gzindex; /* where in extra, name, or comment */
|
uInt gzindex; /* where in extra, name, or comment */
|
||||||
Byte method; /* STORED (for zip only) or DEFLATED */
|
Byte method; /* can only be DEFLATED */
|
||||||
int last_flush; /* value of flush param for previous deflate call */
|
int last_flush; /* value of flush param for previous deflate call */
|
||||||
|
|
||||||
/* used by deflate.c: */
|
/* used by deflate.c: */
|
||||||
|
@ -188,7 +191,7 @@ typedef struct internal_state {
|
||||||
int nice_match; /* Stop searching when current match exceeds this */
|
int nice_match; /* Stop searching when current match exceeds this */
|
||||||
|
|
||||||
/* used by trees.c: */
|
/* used by trees.c: */
|
||||||
/* Didn't use ct_data typedef below to supress compiler warning */
|
/* Didn't use ct_data typedef below to suppress compiler warning */
|
||||||
struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */
|
struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */
|
||||||
struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */
|
struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */
|
||||||
struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */
|
struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */
|
||||||
|
@ -244,7 +247,7 @@ typedef struct internal_state {
|
||||||
ulg opt_len; /* bit length of current block with optimal trees */
|
ulg opt_len; /* bit length of current block with optimal trees */
|
||||||
ulg static_len; /* bit length of current block with static trees */
|
ulg static_len; /* bit length of current block with static trees */
|
||||||
uInt matches; /* number of string matches in current block */
|
uInt matches; /* number of string matches in current block */
|
||||||
int last_eob_len; /* bit length of EOB code for last block */
|
uInt insert; /* bytes at end of window left to insert */
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
ulg compressed_len; /* total bit length of compressed file mod 2^32 */
|
ulg compressed_len; /* total bit length of compressed file mod 2^32 */
|
||||||
|
@ -294,6 +297,7 @@ void ZLIB_INTERNAL _tr_init OF((deflate_state *s));
|
||||||
int ZLIB_INTERNAL _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc));
|
int ZLIB_INTERNAL _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc));
|
||||||
void ZLIB_INTERNAL _tr_flush_block OF((deflate_state *s, charf *buf,
|
void ZLIB_INTERNAL _tr_flush_block OF((deflate_state *s, charf *buf,
|
||||||
ulg stored_len, int last));
|
ulg stored_len, int last));
|
||||||
|
void ZLIB_INTERNAL _tr_flush_bits OF((deflate_state *s));
|
||||||
void ZLIB_INTERNAL _tr_align OF((deflate_state *s));
|
void ZLIB_INTERNAL _tr_align OF((deflate_state *s));
|
||||||
void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf,
|
void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf,
|
||||||
ulg stored_len, int last));
|
ulg stored_len, int last));
|
209
ExternalLibs/zlib/gzguts.h
Normal file
209
ExternalLibs/zlib/gzguts.h
Normal file
|
@ -0,0 +1,209 @@
|
||||||
|
/* gzguts.h -- zlib internal header definitions for gz* operations
|
||||||
|
* Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013 Mark Adler
|
||||||
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef _LARGEFILE64_SOURCE
|
||||||
|
# ifndef _LARGEFILE_SOURCE
|
||||||
|
# define _LARGEFILE_SOURCE 1
|
||||||
|
# endif
|
||||||
|
# ifdef _FILE_OFFSET_BITS
|
||||||
|
# undef _FILE_OFFSET_BITS
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_HIDDEN
|
||||||
|
# define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
|
||||||
|
#else
|
||||||
|
# define ZLIB_INTERNAL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "zlib.h"
|
||||||
|
#ifdef STDC
|
||||||
|
# include <string.h>
|
||||||
|
# include <stdlib.h>
|
||||||
|
# include <limits.h>
|
||||||
|
#endif
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
# include <stddef.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__TURBOC__) || defined(_MSC_VER) || defined(_WIN32)
|
||||||
|
# include <io.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef WINAPI_FAMILY
|
||||||
|
# define open _open
|
||||||
|
# define read _read
|
||||||
|
# define write _write
|
||||||
|
# define close _close
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef NO_DEFLATE /* for compatibility with old definition */
|
||||||
|
# define NO_GZCOMPRESS
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550)
|
||||||
|
# ifndef HAVE_VSNPRINTF
|
||||||
|
# define HAVE_VSNPRINTF
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__CYGWIN__)
|
||||||
|
# ifndef HAVE_VSNPRINTF
|
||||||
|
# define HAVE_VSNPRINTF
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MSDOS) && defined(__BORLANDC__) && (BORLANDC > 0x410)
|
||||||
|
# ifndef HAVE_VSNPRINTF
|
||||||
|
# define HAVE_VSNPRINTF
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_VSNPRINTF
|
||||||
|
# ifdef MSDOS
|
||||||
|
/* vsnprintf may exist on some MS-DOS compilers (DJGPP?),
|
||||||
|
but for now we just assume it doesn't. */
|
||||||
|
# define NO_vsnprintf
|
||||||
|
# endif
|
||||||
|
# ifdef __TURBOC__
|
||||||
|
# define NO_vsnprintf
|
||||||
|
# endif
|
||||||
|
# ifdef WIN32
|
||||||
|
/* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */
|
||||||
|
# if !defined(vsnprintf) && !defined(NO_vsnprintf)
|
||||||
|
# if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 )
|
||||||
|
# define vsnprintf _vsnprintf
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
# ifdef __SASC
|
||||||
|
# define NO_vsnprintf
|
||||||
|
# endif
|
||||||
|
# ifdef VMS
|
||||||
|
# define NO_vsnprintf
|
||||||
|
# endif
|
||||||
|
# ifdef __OS400__
|
||||||
|
# define NO_vsnprintf
|
||||||
|
# endif
|
||||||
|
# ifdef __MVS__
|
||||||
|
# define NO_vsnprintf
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* unlike snprintf (which is required in C99, yet still not supported by
|
||||||
|
Microsoft more than a decade later!), _snprintf does not guarantee null
|
||||||
|
termination of the result -- however this is only used in gzlib.c where
|
||||||
|
the result is assured to fit in the space provided */
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
# define snprintf _snprintf
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef local
|
||||||
|
# define local static
|
||||||
|
#endif
|
||||||
|
/* compile with -Dlocal if your debugger can't find static symbols */
|
||||||
|
|
||||||
|
/* gz* functions always use library allocation functions */
|
||||||
|
#ifndef STDC
|
||||||
|
extern voidp malloc OF((uInt size));
|
||||||
|
extern void free OF((voidpf ptr));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* get errno and strerror definition */
|
||||||
|
#if defined UNDER_CE
|
||||||
|
# include <windows.h>
|
||||||
|
# define zstrerror() gz_strwinerror((DWORD)GetLastError())
|
||||||
|
#else
|
||||||
|
# ifndef NO_STRERROR
|
||||||
|
# include <errno.h>
|
||||||
|
# define zstrerror() strerror(errno)
|
||||||
|
# else
|
||||||
|
# define zstrerror() "stdio error (consult errno)"
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* provide prototypes for these when building zlib without LFS */
|
||||||
|
#if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0
|
||||||
|
ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
|
||||||
|
ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int));
|
||||||
|
ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile));
|
||||||
|
ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* default memLevel */
|
||||||
|
#if MAX_MEM_LEVEL >= 8
|
||||||
|
# define DEF_MEM_LEVEL 8
|
||||||
|
#else
|
||||||
|
# define DEF_MEM_LEVEL MAX_MEM_LEVEL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* default i/o buffer size -- double this for output when reading (this and
|
||||||
|
twice this must be able to fit in an unsigned type) */
|
||||||
|
#define GZBUFSIZE 8192
|
||||||
|
|
||||||
|
/* gzip modes, also provide a little integrity check on the passed structure */
|
||||||
|
#define GZ_NONE 0
|
||||||
|
#define GZ_READ 7247
|
||||||
|
#define GZ_WRITE 31153
|
||||||
|
#define GZ_APPEND 1 /* mode set to GZ_WRITE after the file is opened */
|
||||||
|
|
||||||
|
/* values for gz_state how */
|
||||||
|
#define LOOK 0 /* look for a gzip header */
|
||||||
|
#define COPY 1 /* copy input directly */
|
||||||
|
#define GZIP 2 /* decompress a gzip stream */
|
||||||
|
|
||||||
|
/* internal gzip file state data structure */
|
||||||
|
typedef struct {
|
||||||
|
/* exposed contents for gzgetc() macro */
|
||||||
|
struct gzFile_s x; /* "x" for exposed */
|
||||||
|
/* x.have: number of bytes available at x.next */
|
||||||
|
/* x.next: next output data to deliver or write */
|
||||||
|
/* x.pos: current position in uncompressed data */
|
||||||
|
/* used for both reading and writing */
|
||||||
|
int mode; /* see gzip modes above */
|
||||||
|
int fd; /* file descriptor */
|
||||||
|
char *path; /* path or fd for error messages */
|
||||||
|
unsigned size; /* buffer size, zero if not allocated yet */
|
||||||
|
unsigned want; /* requested buffer size, default is GZBUFSIZE */
|
||||||
|
unsigned char *in; /* input buffer */
|
||||||
|
unsigned char *out; /* output buffer (double-sized when reading) */
|
||||||
|
int direct; /* 0 if processing gzip, 1 if transparent */
|
||||||
|
/* just for reading */
|
||||||
|
int how; /* 0: get header, 1: copy, 2: decompress */
|
||||||
|
z_off64_t start; /* where the gzip data started, for rewinding */
|
||||||
|
int eof; /* true if end of input file reached */
|
||||||
|
int past; /* true if read requested past end */
|
||||||
|
/* just for writing */
|
||||||
|
int level; /* compression level */
|
||||||
|
int strategy; /* compression strategy */
|
||||||
|
/* seek request */
|
||||||
|
z_off64_t skip; /* amount to skip (already rewound if backwards) */
|
||||||
|
int seek; /* true if seek request pending */
|
||||||
|
/* error information */
|
||||||
|
int err; /* error code */
|
||||||
|
char *msg; /* error message */
|
||||||
|
/* zlib inflate or deflate stream */
|
||||||
|
z_stream strm; /* stream structure in-place (not a pointer) */
|
||||||
|
} gz_state;
|
||||||
|
typedef gz_state FAR *gz_statep;
|
||||||
|
|
||||||
|
/* shared functions */
|
||||||
|
void ZLIB_INTERNAL gz_error OF((gz_statep, int, const char *));
|
||||||
|
#if defined UNDER_CE
|
||||||
|
char ZLIB_INTERNAL *gz_strwinerror OF((DWORD error));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t
|
||||||
|
value -- needed when comparing unsigned to z_off64_t, which is signed
|
||||||
|
(possible z_off64_t types off_t, off64_t, and long are all signed) */
|
||||||
|
#ifdef INT_MAX
|
||||||
|
# define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > INT_MAX)
|
||||||
|
#else
|
||||||
|
unsigned ZLIB_INTERNAL gz_intmax OF((void));
|
||||||
|
# define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax())
|
||||||
|
#endif
|
|
@ -1,5 +1,5 @@
|
||||||
/* infback.c -- inflate using a call-back interface
|
/* infback.c -- inflate using a call-back interface
|
||||||
* Copyright (C) 1995-2009 Mark Adler
|
* Copyright (C) 1995-2011 Mark Adler
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -42,10 +42,19 @@ int stream_size;
|
||||||
return Z_STREAM_ERROR;
|
return Z_STREAM_ERROR;
|
||||||
strm->msg = Z_NULL; /* in case we return an error */
|
strm->msg = Z_NULL; /* in case we return an error */
|
||||||
if (strm->zalloc == (alloc_func)0) {
|
if (strm->zalloc == (alloc_func)0) {
|
||||||
|
#ifdef Z_SOLO
|
||||||
|
return Z_STREAM_ERROR;
|
||||||
|
#else
|
||||||
strm->zalloc = zcalloc;
|
strm->zalloc = zcalloc;
|
||||||
strm->opaque = (voidpf)0;
|
strm->opaque = (voidpf)0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if (strm->zfree == (free_func)0) strm->zfree = zcfree;
|
if (strm->zfree == (free_func)0)
|
||||||
|
#ifdef Z_SOLO
|
||||||
|
return Z_STREAM_ERROR;
|
||||||
|
#else
|
||||||
|
strm->zfree = zcfree;
|
||||||
|
#endif
|
||||||
state = (struct inflate_state FAR *)ZALLOC(strm, 1,
|
state = (struct inflate_state FAR *)ZALLOC(strm, 1,
|
||||||
sizeof(struct inflate_state));
|
sizeof(struct inflate_state));
|
||||||
if (state == Z_NULL) return Z_MEM_ERROR;
|
if (state == Z_NULL) return Z_MEM_ERROR;
|
||||||
|
@ -246,7 +255,7 @@ out_func out;
|
||||||
void FAR *out_desc;
|
void FAR *out_desc;
|
||||||
{
|
{
|
||||||
struct inflate_state FAR *state;
|
struct inflate_state FAR *state;
|
||||||
unsigned char FAR *next; /* next input */
|
z_const unsigned char FAR *next; /* next input */
|
||||||
unsigned char FAR *put; /* next output */
|
unsigned char FAR *put; /* next output */
|
||||||
unsigned have, left; /* available input and output */
|
unsigned have, left; /* available input and output */
|
||||||
unsigned long hold; /* bit buffer */
|
unsigned long hold; /* bit buffer */
|
||||||
|
@ -394,7 +403,6 @@ void FAR *out_desc;
|
||||||
PULLBYTE();
|
PULLBYTE();
|
||||||
}
|
}
|
||||||
if (here.val < 16) {
|
if (here.val < 16) {
|
||||||
NEEDBITS(here.bits);
|
|
||||||
DROPBITS(here.bits);
|
DROPBITS(here.bits);
|
||||||
state->lens[state->have++] = here.val;
|
state->lens[state->have++] = here.val;
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
/* inffast.c -- fast decoding
|
/* inffast.c -- fast decoding
|
||||||
* Copyright (C) 1995-2008, 2010 Mark Adler
|
* Copyright (C) 1995-2008, 2010, 2013 Mark Adler
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -69,8 +69,8 @@ z_streamp strm;
|
||||||
unsigned start; /* inflate()'s starting value for strm->avail_out */
|
unsigned start; /* inflate()'s starting value for strm->avail_out */
|
||||||
{
|
{
|
||||||
struct inflate_state FAR *state;
|
struct inflate_state FAR *state;
|
||||||
unsigned char FAR *in; /* local strm->next_in */
|
z_const unsigned char FAR *in; /* local strm->next_in */
|
||||||
unsigned char FAR *last; /* while in < last, enough input available */
|
z_const unsigned char FAR *last; /* have enough input while in < last */
|
||||||
unsigned char FAR *out; /* local strm->next_out */
|
unsigned char FAR *out; /* local strm->next_out */
|
||||||
unsigned char FAR *beg; /* inflate()'s initial strm->next_out */
|
unsigned char FAR *beg; /* inflate()'s initial strm->next_out */
|
||||||
unsigned char FAR *end; /* while out < end, enough space available */
|
unsigned char FAR *end; /* while out < end, enough space available */
|
|
@ -2,9 +2,9 @@
|
||||||
* Generated automatically by makefixed().
|
* Generated automatically by makefixed().
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* WARNING: this file should *not* be used by applications. It
|
/* WARNING: this file should *not* be used by applications.
|
||||||
is part of the implementation of the compression library and
|
It is part of the implementation of this library and is
|
||||||
is subject to change. Applications should only use zlib.h.
|
subject to change. Applications should only use zlib.h.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static const code lenfix[512] = {
|
static const code lenfix[512] = {
|
|
@ -1,5 +1,5 @@
|
||||||
/* inflate.c -- zlib decompression
|
/* inflate.c -- zlib decompression
|
||||||
* Copyright (C) 1995-2010 Mark Adler
|
* Copyright (C) 1995-2012 Mark Adler
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -93,14 +93,15 @@
|
||||||
|
|
||||||
/* function prototypes */
|
/* function prototypes */
|
||||||
local void fixedtables OF((struct inflate_state FAR *state));
|
local void fixedtables OF((struct inflate_state FAR *state));
|
||||||
local int updatewindow OF((z_streamp strm, unsigned out));
|
local int updatewindow OF((z_streamp strm, const unsigned char FAR *end,
|
||||||
|
unsigned copy));
|
||||||
#ifdef BUILDFIXED
|
#ifdef BUILDFIXED
|
||||||
void makefixed OF((void));
|
void makefixed OF((void));
|
||||||
#endif
|
#endif
|
||||||
local unsigned syncsearch OF((unsigned FAR *have, unsigned char FAR *buf,
|
local unsigned syncsearch OF((unsigned FAR *have, const unsigned char FAR *buf,
|
||||||
unsigned len));
|
unsigned len));
|
||||||
|
|
||||||
int ZEXPORT inflateReset(strm)
|
int ZEXPORT inflateResetKeep(strm)
|
||||||
z_streamp strm;
|
z_streamp strm;
|
||||||
{
|
{
|
||||||
struct inflate_state FAR *state;
|
struct inflate_state FAR *state;
|
||||||
|
@ -109,15 +110,13 @@ z_streamp strm;
|
||||||
state = (struct inflate_state FAR *)strm->state;
|
state = (struct inflate_state FAR *)strm->state;
|
||||||
strm->total_in = strm->total_out = state->total = 0;
|
strm->total_in = strm->total_out = state->total = 0;
|
||||||
strm->msg = Z_NULL;
|
strm->msg = Z_NULL;
|
||||||
strm->adler = 1; /* to support ill-conceived Java test suite */
|
if (state->wrap) /* to support ill-conceived Java test suite */
|
||||||
|
strm->adler = state->wrap & 1;
|
||||||
state->mode = HEAD;
|
state->mode = HEAD;
|
||||||
state->last = 0;
|
state->last = 0;
|
||||||
state->havedict = 0;
|
state->havedict = 0;
|
||||||
state->dmax = 32768U;
|
state->dmax = 32768U;
|
||||||
state->head = Z_NULL;
|
state->head = Z_NULL;
|
||||||
state->wsize = 0;
|
|
||||||
state->whave = 0;
|
|
||||||
state->wnext = 0;
|
|
||||||
state->hold = 0;
|
state->hold = 0;
|
||||||
state->bits = 0;
|
state->bits = 0;
|
||||||
state->lencode = state->distcode = state->next = state->codes;
|
state->lencode = state->distcode = state->next = state->codes;
|
||||||
|
@ -127,6 +126,19 @@ z_streamp strm;
|
||||||
return Z_OK;
|
return Z_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ZEXPORT inflateReset(strm)
|
||||||
|
z_streamp strm;
|
||||||
|
{
|
||||||
|
struct inflate_state FAR *state;
|
||||||
|
|
||||||
|
if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
|
||||||
|
state = (struct inflate_state FAR *)strm->state;
|
||||||
|
state->wsize = 0;
|
||||||
|
state->whave = 0;
|
||||||
|
state->wnext = 0;
|
||||||
|
return inflateResetKeep(strm);
|
||||||
|
}
|
||||||
|
|
||||||
int ZEXPORT inflateReset2(strm, windowBits)
|
int ZEXPORT inflateReset2(strm, windowBits)
|
||||||
z_streamp strm;
|
z_streamp strm;
|
||||||
int windowBits;
|
int windowBits;
|
||||||
|
@ -180,10 +192,19 @@ int stream_size;
|
||||||
if (strm == Z_NULL) return Z_STREAM_ERROR;
|
if (strm == Z_NULL) return Z_STREAM_ERROR;
|
||||||
strm->msg = Z_NULL; /* in case we return an error */
|
strm->msg = Z_NULL; /* in case we return an error */
|
||||||
if (strm->zalloc == (alloc_func)0) {
|
if (strm->zalloc == (alloc_func)0) {
|
||||||
|
#ifdef Z_SOLO
|
||||||
|
return Z_STREAM_ERROR;
|
||||||
|
#else
|
||||||
strm->zalloc = zcalloc;
|
strm->zalloc = zcalloc;
|
||||||
strm->opaque = (voidpf)0;
|
strm->opaque = (voidpf)0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if (strm->zfree == (free_func)0) strm->zfree = zcfree;
|
if (strm->zfree == (free_func)0)
|
||||||
|
#ifdef Z_SOLO
|
||||||
|
return Z_STREAM_ERROR;
|
||||||
|
#else
|
||||||
|
strm->zfree = zcfree;
|
||||||
|
#endif
|
||||||
state = (struct inflate_state FAR *)
|
state = (struct inflate_state FAR *)
|
||||||
ZALLOC(strm, 1, sizeof(struct inflate_state));
|
ZALLOC(strm, 1, sizeof(struct inflate_state));
|
||||||
if (state == Z_NULL) return Z_MEM_ERROR;
|
if (state == Z_NULL) return Z_MEM_ERROR;
|
||||||
|
@ -321,8 +342,8 @@ void makefixed()
|
||||||
low = 0;
|
low = 0;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if ((low % 7) == 0) printf("\n ");
|
if ((low % 7) == 0) printf("\n ");
|
||||||
printf("{%u,%u,%d}", state.lencode[low].op, state.lencode[low].bits,
|
printf("{%u,%u,%d}", (low & 127) == 99 ? 64 : state.lencode[low].op,
|
||||||
state.lencode[low].val);
|
state.lencode[low].bits, state.lencode[low].val);
|
||||||
if (++low == size) break;
|
if (++low == size) break;
|
||||||
putchar(',');
|
putchar(',');
|
||||||
}
|
}
|
||||||
|
@ -355,12 +376,13 @@ void makefixed()
|
||||||
output will fall in the output data, making match copies simpler and faster.
|
output will fall in the output data, making match copies simpler and faster.
|
||||||
The advantage may be dependent on the size of the processor's data caches.
|
The advantage may be dependent on the size of the processor's data caches.
|
||||||
*/
|
*/
|
||||||
local int updatewindow(strm, out)
|
local int updatewindow(strm, end, copy)
|
||||||
z_streamp strm;
|
z_streamp strm;
|
||||||
unsigned out;
|
const Bytef *end;
|
||||||
|
unsigned copy;
|
||||||
{
|
{
|
||||||
struct inflate_state FAR *state;
|
struct inflate_state FAR *state;
|
||||||
unsigned copy, dist;
|
unsigned dist;
|
||||||
|
|
||||||
state = (struct inflate_state FAR *)strm->state;
|
state = (struct inflate_state FAR *)strm->state;
|
||||||
|
|
||||||
|
@ -380,19 +402,18 @@ unsigned out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* copy state->wsize or less output bytes into the circular window */
|
/* copy state->wsize or less output bytes into the circular window */
|
||||||
copy = out - strm->avail_out;
|
|
||||||
if (copy >= state->wsize) {
|
if (copy >= state->wsize) {
|
||||||
zmemcpy(state->window, strm->next_out - state->wsize, state->wsize);
|
zmemcpy(state->window, end - state->wsize, state->wsize);
|
||||||
state->wnext = 0;
|
state->wnext = 0;
|
||||||
state->whave = state->wsize;
|
state->whave = state->wsize;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
dist = state->wsize - state->wnext;
|
dist = state->wsize - state->wnext;
|
||||||
if (dist > copy) dist = copy;
|
if (dist > copy) dist = copy;
|
||||||
zmemcpy(state->window + state->wnext, strm->next_out - copy, dist);
|
zmemcpy(state->window + state->wnext, end - copy, dist);
|
||||||
copy -= dist;
|
copy -= dist;
|
||||||
if (copy) {
|
if (copy) {
|
||||||
zmemcpy(state->window, strm->next_out - copy, copy);
|
zmemcpy(state->window, end - copy, copy);
|
||||||
state->wnext = copy;
|
state->wnext = copy;
|
||||||
state->whave = state->wsize;
|
state->whave = state->wsize;
|
||||||
}
|
}
|
||||||
|
@ -499,11 +520,6 @@ unsigned out;
|
||||||
bits -= bits & 7; \
|
bits -= bits & 7; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
/* Reverse the bytes in a 32-bit value */
|
|
||||||
#define REVERSE(q) \
|
|
||||||
((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \
|
|
||||||
(((q) & 0xff00) << 8) + (((q) & 0xff) << 24))
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
inflate() uses a state machine to process as much input data and generate as
|
inflate() uses a state machine to process as much input data and generate as
|
||||||
much output data as possible before returning. The state machine is
|
much output data as possible before returning. The state machine is
|
||||||
|
@ -591,7 +607,7 @@ z_streamp strm;
|
||||||
int flush;
|
int flush;
|
||||||
{
|
{
|
||||||
struct inflate_state FAR *state;
|
struct inflate_state FAR *state;
|
||||||
unsigned char FAR *next; /* next input */
|
z_const unsigned char FAR *next; /* next input */
|
||||||
unsigned char FAR *put; /* next output */
|
unsigned char FAR *put; /* next output */
|
||||||
unsigned have, left; /* available input and output */
|
unsigned have, left; /* available input and output */
|
||||||
unsigned long hold; /* bit buffer */
|
unsigned long hold; /* bit buffer */
|
||||||
|
@ -797,7 +813,7 @@ int flush;
|
||||||
#endif
|
#endif
|
||||||
case DICTID:
|
case DICTID:
|
||||||
NEEDBITS(32);
|
NEEDBITS(32);
|
||||||
strm->adler = state->check = REVERSE(hold);
|
strm->adler = state->check = ZSWAP32(hold);
|
||||||
INITBITS();
|
INITBITS();
|
||||||
state->mode = DICT;
|
state->mode = DICT;
|
||||||
case DICT:
|
case DICT:
|
||||||
|
@ -905,7 +921,7 @@ int flush;
|
||||||
while (state->have < 19)
|
while (state->have < 19)
|
||||||
state->lens[order[state->have++]] = 0;
|
state->lens[order[state->have++]] = 0;
|
||||||
state->next = state->codes;
|
state->next = state->codes;
|
||||||
state->lencode = (code const FAR *)(state->next);
|
state->lencode = (const code FAR *)(state->next);
|
||||||
state->lenbits = 7;
|
state->lenbits = 7;
|
||||||
ret = inflate_table(CODES, state->lens, 19, &(state->next),
|
ret = inflate_table(CODES, state->lens, 19, &(state->next),
|
||||||
&(state->lenbits), state->work);
|
&(state->lenbits), state->work);
|
||||||
|
@ -925,7 +941,6 @@ int flush;
|
||||||
PULLBYTE();
|
PULLBYTE();
|
||||||
}
|
}
|
||||||
if (here.val < 16) {
|
if (here.val < 16) {
|
||||||
NEEDBITS(here.bits);
|
|
||||||
DROPBITS(here.bits);
|
DROPBITS(here.bits);
|
||||||
state->lens[state->have++] = here.val;
|
state->lens[state->have++] = here.val;
|
||||||
}
|
}
|
||||||
|
@ -980,7 +995,7 @@ int flush;
|
||||||
values here (9 and 6) without reading the comments in inftrees.h
|
values here (9 and 6) without reading the comments in inftrees.h
|
||||||
concerning the ENOUGH constants, which depend on those values */
|
concerning the ENOUGH constants, which depend on those values */
|
||||||
state->next = state->codes;
|
state->next = state->codes;
|
||||||
state->lencode = (code const FAR *)(state->next);
|
state->lencode = (const code FAR *)(state->next);
|
||||||
state->lenbits = 9;
|
state->lenbits = 9;
|
||||||
ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
|
ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
|
||||||
&(state->lenbits), state->work);
|
&(state->lenbits), state->work);
|
||||||
|
@ -989,7 +1004,7 @@ int flush;
|
||||||
state->mode = BAD;
|
state->mode = BAD;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
state->distcode = (code const FAR *)(state->next);
|
state->distcode = (const code FAR *)(state->next);
|
||||||
state->distbits = 6;
|
state->distbits = 6;
|
||||||
ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
|
ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
|
||||||
&(state->next), &(state->distbits), state->work);
|
&(state->next), &(state->distbits), state->work);
|
||||||
|
@ -1170,7 +1185,7 @@ int flush;
|
||||||
#ifdef GUNZIP
|
#ifdef GUNZIP
|
||||||
state->flags ? hold :
|
state->flags ? hold :
|
||||||
#endif
|
#endif
|
||||||
REVERSE(hold)) != state->check) {
|
ZSWAP32(hold)) != state->check) {
|
||||||
strm->msg = (char *)"incorrect data check";
|
strm->msg = (char *)"incorrect data check";
|
||||||
state->mode = BAD;
|
state->mode = BAD;
|
||||||
break;
|
break;
|
||||||
|
@ -1214,8 +1229,9 @@ int flush;
|
||||||
*/
|
*/
|
||||||
inf_leave:
|
inf_leave:
|
||||||
RESTORE();
|
RESTORE();
|
||||||
if (state->wsize || (state->mode < CHECK && out != strm->avail_out))
|
if (state->wsize || (out != strm->avail_out && state->mode < BAD &&
|
||||||
if (updatewindow(strm, out)) {
|
(state->mode < CHECK || flush != Z_FINISH)))
|
||||||
|
if (updatewindow(strm, strm->next_out, out - strm->avail_out)) {
|
||||||
state->mode = MEM;
|
state->mode = MEM;
|
||||||
return Z_MEM_ERROR;
|
return Z_MEM_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -1249,13 +1265,37 @@ z_streamp strm;
|
||||||
return Z_OK;
|
return Z_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ZEXPORT inflateGetDictionary(strm, dictionary, dictLength)
|
||||||
|
z_streamp strm;
|
||||||
|
Bytef *dictionary;
|
||||||
|
uInt *dictLength;
|
||||||
|
{
|
||||||
|
struct inflate_state FAR *state;
|
||||||
|
|
||||||
|
/* check state */
|
||||||
|
if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
|
||||||
|
state = (struct inflate_state FAR *)strm->state;
|
||||||
|
|
||||||
|
/* copy dictionary */
|
||||||
|
if (state->whave && dictionary != Z_NULL) {
|
||||||
|
zmemcpy(dictionary, state->window + state->wnext,
|
||||||
|
state->whave - state->wnext);
|
||||||
|
zmemcpy(dictionary + state->whave - state->wnext,
|
||||||
|
state->window, state->wnext);
|
||||||
|
}
|
||||||
|
if (dictLength != Z_NULL)
|
||||||
|
*dictLength = state->whave;
|
||||||
|
return Z_OK;
|
||||||
|
}
|
||||||
|
|
||||||
int ZEXPORT inflateSetDictionary(strm, dictionary, dictLength)
|
int ZEXPORT inflateSetDictionary(strm, dictionary, dictLength)
|
||||||
z_streamp strm;
|
z_streamp strm;
|
||||||
const Bytef *dictionary;
|
const Bytef *dictionary;
|
||||||
uInt dictLength;
|
uInt dictLength;
|
||||||
{
|
{
|
||||||
struct inflate_state FAR *state;
|
struct inflate_state FAR *state;
|
||||||
unsigned long id;
|
unsigned long dictid;
|
||||||
|
int ret;
|
||||||
|
|
||||||
/* check state */
|
/* check state */
|
||||||
if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
|
if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
|
||||||
|
@ -1263,29 +1303,21 @@ uInt dictLength;
|
||||||
if (state->wrap != 0 && state->mode != DICT)
|
if (state->wrap != 0 && state->mode != DICT)
|
||||||
return Z_STREAM_ERROR;
|
return Z_STREAM_ERROR;
|
||||||
|
|
||||||
/* check for correct dictionary id */
|
/* check for correct dictionary identifier */
|
||||||
if (state->mode == DICT) {
|
if (state->mode == DICT) {
|
||||||
id = adler32(0L, Z_NULL, 0);
|
dictid = adler32(0L, Z_NULL, 0);
|
||||||
id = adler32(id, dictionary, dictLength);
|
dictid = adler32(dictid, dictionary, dictLength);
|
||||||
if (id != state->check)
|
if (dictid != state->check)
|
||||||
return Z_DATA_ERROR;
|
return Z_DATA_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* copy dictionary to window */
|
/* copy dictionary to window using updatewindow(), which will amend the
|
||||||
if (updatewindow(strm, strm->avail_out)) {
|
existing dictionary if appropriate */
|
||||||
|
ret = updatewindow(strm, dictionary + dictLength, dictLength);
|
||||||
|
if (ret) {
|
||||||
state->mode = MEM;
|
state->mode = MEM;
|
||||||
return Z_MEM_ERROR;
|
return Z_MEM_ERROR;
|
||||||
}
|
}
|
||||||
if (dictLength > state->wsize) {
|
|
||||||
zmemcpy(state->window, dictionary + dictLength - state->wsize,
|
|
||||||
state->wsize);
|
|
||||||
state->whave = state->wsize;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
zmemcpy(state->window + state->wsize - dictLength, dictionary,
|
|
||||||
dictLength);
|
|
||||||
state->whave = dictLength;
|
|
||||||
}
|
|
||||||
state->havedict = 1;
|
state->havedict = 1;
|
||||||
Tracev((stderr, "inflate: dictionary set\n"));
|
Tracev((stderr, "inflate: dictionary set\n"));
|
||||||
return Z_OK;
|
return Z_OK;
|
||||||
|
@ -1321,7 +1353,7 @@ gz_headerp head;
|
||||||
*/
|
*/
|
||||||
local unsigned syncsearch(have, buf, len)
|
local unsigned syncsearch(have, buf, len)
|
||||||
unsigned FAR *have;
|
unsigned FAR *have;
|
||||||
unsigned char FAR *buf;
|
const unsigned char FAR *buf;
|
||||||
unsigned len;
|
unsigned len;
|
||||||
{
|
{
|
||||||
unsigned got;
|
unsigned got;
|
||||||
|
@ -1433,8 +1465,8 @@ z_streamp source;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* copy state */
|
/* copy state */
|
||||||
zmemcpy(dest, source, sizeof(z_stream));
|
zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream));
|
||||||
zmemcpy(copy, state, sizeof(struct inflate_state));
|
zmemcpy((voidpf)copy, (voidpf)state, sizeof(struct inflate_state));
|
||||||
if (state->lencode >= state->codes &&
|
if (state->lencode >= state->codes &&
|
||||||
state->lencode <= state->codes + ENOUGH - 1) {
|
state->lencode <= state->codes + ENOUGH - 1) {
|
||||||
copy->lencode = copy->codes + (state->lencode - state->codes);
|
copy->lencode = copy->codes + (state->lencode - state->codes);
|
|
@ -1,5 +1,5 @@
|
||||||
/* inftrees.c -- generate Huffman trees for efficient decoding
|
/* inftrees.c -- generate Huffman trees for efficient decoding
|
||||||
* Copyright (C) 1995-2010 Mark Adler
|
* Copyright (C) 1995-2013 Mark Adler
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
||||||
#define MAXBITS 15
|
#define MAXBITS 15
|
||||||
|
|
||||||
const char inflate_copyright[] =
|
const char inflate_copyright[] =
|
||||||
" inflate 1.2.5 Copyright 1995-2010 Mark Adler ";
|
" inflate 1.2.8 Copyright 1995-2013 Mark Adler ";
|
||||||
/*
|
/*
|
||||||
If you use the zlib library in a product, an acknowledgment is welcome
|
If you use the zlib library in a product, an acknowledgment is welcome
|
||||||
in the documentation of your product. If for some reason you cannot
|
in the documentation of your product. If for some reason you cannot
|
||||||
|
@ -62,7 +62,7 @@ unsigned short FAR *work;
|
||||||
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
|
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
|
||||||
static const unsigned short lext[31] = { /* Length codes 257..285 extra */
|
static const unsigned short lext[31] = { /* Length codes 257..285 extra */
|
||||||
16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
|
16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
|
||||||
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 73, 195};
|
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78};
|
||||||
static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
|
static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
|
||||||
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
|
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
|
||||||
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
|
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
|
||||||
|
@ -208,8 +208,8 @@ unsigned short FAR *work;
|
||||||
mask = used - 1; /* mask for comparing low */
|
mask = used - 1; /* mask for comparing low */
|
||||||
|
|
||||||
/* check available table space */
|
/* check available table space */
|
||||||
if ((type == LENS && used >= ENOUGH_LENS) ||
|
if ((type == LENS && used > ENOUGH_LENS) ||
|
||||||
(type == DISTS && used >= ENOUGH_DISTS))
|
(type == DISTS && used > ENOUGH_DISTS))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
/* process all codes and make table entries */
|
/* process all codes and make table entries */
|
||||||
|
@ -277,8 +277,8 @@ unsigned short FAR *work;
|
||||||
|
|
||||||
/* check for enough space */
|
/* check for enough space */
|
||||||
used += 1U << curr;
|
used += 1U << curr;
|
||||||
if ((type == LENS && used >= ENOUGH_LENS) ||
|
if ((type == LENS && used > ENOUGH_LENS) ||
|
||||||
(type == DISTS && used >= ENOUGH_DISTS))
|
(type == DISTS && used > ENOUGH_DISTS))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
/* point entry in root table to sub-table */
|
/* point entry in root table to sub-table */
|
||||||
|
@ -289,38 +289,14 @@ unsigned short FAR *work;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* fill in remaining table entry if code is incomplete (guaranteed to have
|
||||||
Fill in rest of table for incomplete codes. This loop is similar to the
|
at most one remaining entry, since if the code is incomplete, the
|
||||||
loop above in incrementing huff for table indices. It is assumed that
|
maximum code length that was allowed to get this far is one bit) */
|
||||||
len is equal to curr + drop, so there is no loop needed to increment
|
if (huff != 0) {
|
||||||
through high index bits. When the current sub-table is filled, the loop
|
|
||||||
drops back to the root table to fill in any remaining entries there.
|
|
||||||
*/
|
|
||||||
here.op = (unsigned char)64; /* invalid code marker */
|
here.op = (unsigned char)64; /* invalid code marker */
|
||||||
here.bits = (unsigned char)(len - drop);
|
here.bits = (unsigned char)(len - drop);
|
||||||
here.val = (unsigned short)0;
|
here.val = (unsigned short)0;
|
||||||
while (huff != 0) {
|
next[huff] = here;
|
||||||
/* when done with sub-table, drop back to root table */
|
|
||||||
if (drop != 0 && (huff & mask) != low) {
|
|
||||||
drop = 0;
|
|
||||||
len = root;
|
|
||||||
next = *table;
|
|
||||||
here.bits = (unsigned char)len;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* put invalid code marker in table */
|
|
||||||
next[huff >> drop] = here;
|
|
||||||
|
|
||||||
/* backwards increment the len-bit code huff */
|
|
||||||
incr = 1U << (len - 1);
|
|
||||||
while (huff & incr)
|
|
||||||
incr >>= 1;
|
|
||||||
if (incr != 0) {
|
|
||||||
huff &= incr - 1;
|
|
||||||
huff += incr;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
huff = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set return parameters */
|
/* set return parameters */
|
|
@ -1,5 +1,5 @@
|
||||||
/* trees.c -- output deflated data using Huffman coding
|
/* trees.c -- output deflated data using Huffman coding
|
||||||
* Copyright (C) 1995-2010 Jean-loup Gailly
|
* Copyright (C) 1995-2012 Jean-loup Gailly
|
||||||
* detect_data_type() function provided freely by Cosmin Truta, 2006
|
* detect_data_type() function provided freely by Cosmin Truta, 2006
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
@ -74,11 +74,6 @@ local const uch bl_order[BL_CODES]
|
||||||
* probability, to avoid transmitting the lengths for unused bit length codes.
|
* probability, to avoid transmitting the lengths for unused bit length codes.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define Buf_size (8 * 2*sizeof(char))
|
|
||||||
/* Number of bits used within bi_buf. (bi_buf might be implemented on
|
|
||||||
* more than 16 bits on some systems.)
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* ===========================================================================
|
/* ===========================================================================
|
||||||
* Local data. These are initialized only once.
|
* Local data. These are initialized only once.
|
||||||
*/
|
*/
|
||||||
|
@ -151,8 +146,8 @@ local void send_tree OF((deflate_state *s, ct_data *tree, int max_code));
|
||||||
local int build_bl_tree OF((deflate_state *s));
|
local int build_bl_tree OF((deflate_state *s));
|
||||||
local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes,
|
local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes,
|
||||||
int blcodes));
|
int blcodes));
|
||||||
local void compress_block OF((deflate_state *s, ct_data *ltree,
|
local void compress_block OF((deflate_state *s, const ct_data *ltree,
|
||||||
ct_data *dtree));
|
const ct_data *dtree));
|
||||||
local int detect_data_type OF((deflate_state *s));
|
local int detect_data_type OF((deflate_state *s));
|
||||||
local unsigned bi_reverse OF((unsigned value, int length));
|
local unsigned bi_reverse OF((unsigned value, int length));
|
||||||
local void bi_windup OF((deflate_state *s));
|
local void bi_windup OF((deflate_state *s));
|
||||||
|
@ -399,7 +394,6 @@ void ZLIB_INTERNAL _tr_init(s)
|
||||||
|
|
||||||
s->bi_buf = 0;
|
s->bi_buf = 0;
|
||||||
s->bi_valid = 0;
|
s->bi_valid = 0;
|
||||||
s->last_eob_len = 8; /* enough lookahead for inflate */
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
s->compressed_len = 0L;
|
s->compressed_len = 0L;
|
||||||
s->bits_sent = 0L;
|
s->bits_sent = 0L;
|
||||||
|
@ -882,16 +876,18 @@ void ZLIB_INTERNAL _tr_stored_block(s, buf, stored_len, last)
|
||||||
copy_block(s, buf, (unsigned)stored_len, 1); /* with header */
|
copy_block(s, buf, (unsigned)stored_len, 1); /* with header */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ===========================================================================
|
||||||
|
* Flush the bits in the bit buffer to pending output (leaves at most 7 bits)
|
||||||
|
*/
|
||||||
|
void ZLIB_INTERNAL _tr_flush_bits(s)
|
||||||
|
deflate_state *s;
|
||||||
|
{
|
||||||
|
bi_flush(s);
|
||||||
|
}
|
||||||
|
|
||||||
/* ===========================================================================
|
/* ===========================================================================
|
||||||
* Send one empty static block to give enough lookahead for inflate.
|
* Send one empty static block to give enough lookahead for inflate.
|
||||||
* This takes 10 bits, of which 7 may remain in the bit buffer.
|
* This takes 10 bits, of which 7 may remain in the bit buffer.
|
||||||
* The current inflate code requires 9 bits of lookahead. If the
|
|
||||||
* last two codes for the previous block (real code plus EOB) were coded
|
|
||||||
* on 5 bits or less, inflate may have only 5+3 bits of lookahead to decode
|
|
||||||
* the last real code. In this case we send two empty static blocks instead
|
|
||||||
* of one. (There are no problems if the previous block is stored or fixed.)
|
|
||||||
* To simplify the code, we assume the worst case of last real code encoded
|
|
||||||
* on one bit only.
|
|
||||||
*/
|
*/
|
||||||
void ZLIB_INTERNAL _tr_align(s)
|
void ZLIB_INTERNAL _tr_align(s)
|
||||||
deflate_state *s;
|
deflate_state *s;
|
||||||
|
@ -902,20 +898,6 @@ void ZLIB_INTERNAL _tr_align(s)
|
||||||
s->compressed_len += 10L; /* 3 for block type, 7 for EOB */
|
s->compressed_len += 10L; /* 3 for block type, 7 for EOB */
|
||||||
#endif
|
#endif
|
||||||
bi_flush(s);
|
bi_flush(s);
|
||||||
/* Of the 10 bits for the empty block, we have already sent
|
|
||||||
* (10 - bi_valid) bits. The lookahead for the last real code (before
|
|
||||||
* the EOB of the previous block) was thus at least one plus the length
|
|
||||||
* of the EOB plus what we have just sent of the empty static block.
|
|
||||||
*/
|
|
||||||
if (1 + s->last_eob_len + 10 - s->bi_valid < 9) {
|
|
||||||
send_bits(s, STATIC_TREES<<1, 3);
|
|
||||||
send_code(s, END_BLOCK, static_ltree);
|
|
||||||
#ifdef DEBUG
|
|
||||||
s->compressed_len += 10L;
|
|
||||||
#endif
|
|
||||||
bi_flush(s);
|
|
||||||
}
|
|
||||||
s->last_eob_len = 7;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===========================================================================
|
/* ===========================================================================
|
||||||
|
@ -990,7 +972,8 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
|
||||||
} else if (s->strategy == Z_FIXED || static_lenb == opt_lenb) {
|
} else if (s->strategy == Z_FIXED || static_lenb == opt_lenb) {
|
||||||
#endif
|
#endif
|
||||||
send_bits(s, (STATIC_TREES<<1)+last, 3);
|
send_bits(s, (STATIC_TREES<<1)+last, 3);
|
||||||
compress_block(s, (ct_data *)static_ltree, (ct_data *)static_dtree);
|
compress_block(s, (const ct_data *)static_ltree,
|
||||||
|
(const ct_data *)static_dtree);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
s->compressed_len += 3 + s->static_len;
|
s->compressed_len += 3 + s->static_len;
|
||||||
#endif
|
#endif
|
||||||
|
@ -998,7 +981,8 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
|
||||||
send_bits(s, (DYN_TREES<<1)+last, 3);
|
send_bits(s, (DYN_TREES<<1)+last, 3);
|
||||||
send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1,
|
send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1,
|
||||||
max_blindex+1);
|
max_blindex+1);
|
||||||
compress_block(s, (ct_data *)s->dyn_ltree, (ct_data *)s->dyn_dtree);
|
compress_block(s, (const ct_data *)s->dyn_ltree,
|
||||||
|
(const ct_data *)s->dyn_dtree);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
s->compressed_len += 3 + s->opt_len;
|
s->compressed_len += 3 + s->opt_len;
|
||||||
#endif
|
#endif
|
||||||
|
@ -1075,8 +1059,8 @@ int ZLIB_INTERNAL _tr_tally (s, dist, lc)
|
||||||
*/
|
*/
|
||||||
local void compress_block(s, ltree, dtree)
|
local void compress_block(s, ltree, dtree)
|
||||||
deflate_state *s;
|
deflate_state *s;
|
||||||
ct_data *ltree; /* literal tree */
|
const ct_data *ltree; /* literal tree */
|
||||||
ct_data *dtree; /* distance tree */
|
const ct_data *dtree; /* distance tree */
|
||||||
{
|
{
|
||||||
unsigned dist; /* distance of matched string */
|
unsigned dist; /* distance of matched string */
|
||||||
int lc; /* match length or unmatched char (if dist == 0) */
|
int lc; /* match length or unmatched char (if dist == 0) */
|
||||||
|
@ -1118,7 +1102,6 @@ local void compress_block(s, ltree, dtree)
|
||||||
} while (lx < s->last_lit);
|
} while (lx < s->last_lit);
|
||||||
|
|
||||||
send_code(s, END_BLOCK, ltree);
|
send_code(s, END_BLOCK, ltree);
|
||||||
s->last_eob_len = ltree[END_BLOCK].Len;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===========================================================================
|
/* ===========================================================================
|
||||||
|
@ -1226,7 +1209,6 @@ local void copy_block(s, buf, len, header)
|
||||||
int header; /* true if block header must be written */
|
int header; /* true if block header must be written */
|
||||||
{
|
{
|
||||||
bi_windup(s); /* align on byte boundary */
|
bi_windup(s); /* align on byte boundary */
|
||||||
s->last_eob_len = 8; /* enough lookahead for inflate */
|
|
||||||
|
|
||||||
if (header) {
|
if (header) {
|
||||||
put_short(s, (ush)len);
|
put_short(s, (ush)len);
|
|
@ -30,7 +30,7 @@ int ZEXPORT uncompress (dest, destLen, source, sourceLen)
|
||||||
z_stream stream;
|
z_stream stream;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
stream.next_in = (Bytef*)source;
|
stream.next_in = (z_const Bytef *)source;
|
||||||
stream.avail_in = (uInt)sourceLen;
|
stream.avail_in = (uInt)sourceLen;
|
||||||
/* Check for source > 64K on 16-bit machine: */
|
/* Check for source > 64K on 16-bit machine: */
|
||||||
if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
|
if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
|
|
@ -1,5 +1,5 @@
|
||||||
/* zconf.h -- configuration of the zlib compression library
|
/* zconf.h -- configuration of the zlib compression library
|
||||||
* Copyright (C) 1995-2010 Jean-loup Gailly.
|
* Copyright (C) 1995-2013 Jean-loup Gailly.
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -15,11 +15,13 @@
|
||||||
* this permanently in zconf.h using "./configure --zprefix".
|
* this permanently in zconf.h using "./configure --zprefix".
|
||||||
*/
|
*/
|
||||||
#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */
|
#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */
|
||||||
|
# define Z_PREFIX_SET
|
||||||
|
|
||||||
/* all linked symbols */
|
/* all linked symbols */
|
||||||
# define _dist_code z__dist_code
|
# define _dist_code z__dist_code
|
||||||
# define _length_code z__length_code
|
# define _length_code z__length_code
|
||||||
# define _tr_align z__tr_align
|
# define _tr_align z__tr_align
|
||||||
|
# define _tr_flush_bits z__tr_flush_bits
|
||||||
# define _tr_flush_block z__tr_flush_block
|
# define _tr_flush_block z__tr_flush_block
|
||||||
# define _tr_init z__tr_init
|
# define _tr_init z__tr_init
|
||||||
# define _tr_stored_block z__tr_stored_block
|
# define _tr_stored_block z__tr_stored_block
|
||||||
|
@ -27,9 +29,11 @@
|
||||||
# define adler32 z_adler32
|
# define adler32 z_adler32
|
||||||
# define adler32_combine z_adler32_combine
|
# define adler32_combine z_adler32_combine
|
||||||
# define adler32_combine64 z_adler32_combine64
|
# define adler32_combine64 z_adler32_combine64
|
||||||
|
# ifndef Z_SOLO
|
||||||
# define compress z_compress
|
# define compress z_compress
|
||||||
# define compress2 z_compress2
|
# define compress2 z_compress2
|
||||||
# define compressBound z_compressBound
|
# define compressBound z_compressBound
|
||||||
|
# endif
|
||||||
# define crc32 z_crc32
|
# define crc32 z_crc32
|
||||||
# define crc32_combine z_crc32_combine
|
# define crc32_combine z_crc32_combine
|
||||||
# define crc32_combine64 z_crc32_combine64
|
# define crc32_combine64 z_crc32_combine64
|
||||||
|
@ -40,13 +44,16 @@
|
||||||
# define deflateInit2_ z_deflateInit2_
|
# define deflateInit2_ z_deflateInit2_
|
||||||
# define deflateInit_ z_deflateInit_
|
# define deflateInit_ z_deflateInit_
|
||||||
# define deflateParams z_deflateParams
|
# define deflateParams z_deflateParams
|
||||||
|
# define deflatePending z_deflatePending
|
||||||
# define deflatePrime z_deflatePrime
|
# define deflatePrime z_deflatePrime
|
||||||
# define deflateReset z_deflateReset
|
# define deflateReset z_deflateReset
|
||||||
|
# define deflateResetKeep z_deflateResetKeep
|
||||||
# define deflateSetDictionary z_deflateSetDictionary
|
# define deflateSetDictionary z_deflateSetDictionary
|
||||||
# define deflateSetHeader z_deflateSetHeader
|
# define deflateSetHeader z_deflateSetHeader
|
||||||
# define deflateTune z_deflateTune
|
# define deflateTune z_deflateTune
|
||||||
# define deflate_copyright z_deflate_copyright
|
# define deflate_copyright z_deflate_copyright
|
||||||
# define get_crc_table z_get_crc_table
|
# define get_crc_table z_get_crc_table
|
||||||
|
# ifndef Z_SOLO
|
||||||
# define gz_error z_gz_error
|
# define gz_error z_gz_error
|
||||||
# define gz_intmax z_gz_intmax
|
# define gz_intmax z_gz_intmax
|
||||||
# define gz_strwinerror z_gz_strwinerror
|
# define gz_strwinerror z_gz_strwinerror
|
||||||
|
@ -61,12 +68,17 @@
|
||||||
# define gzerror z_gzerror
|
# define gzerror z_gzerror
|
||||||
# define gzflush z_gzflush
|
# define gzflush z_gzflush
|
||||||
# define gzgetc z_gzgetc
|
# define gzgetc z_gzgetc
|
||||||
|
# define gzgetc_ z_gzgetc_
|
||||||
# define gzgets z_gzgets
|
# define gzgets z_gzgets
|
||||||
# define gzoffset z_gzoffset
|
# define gzoffset z_gzoffset
|
||||||
# define gzoffset64 z_gzoffset64
|
# define gzoffset64 z_gzoffset64
|
||||||
# define gzopen z_gzopen
|
# define gzopen z_gzopen
|
||||||
# define gzopen64 z_gzopen64
|
# define gzopen64 z_gzopen64
|
||||||
|
# ifdef _WIN32
|
||||||
|
# define gzopen_w z_gzopen_w
|
||||||
|
# endif
|
||||||
# define gzprintf z_gzprintf
|
# define gzprintf z_gzprintf
|
||||||
|
# define gzvprintf z_gzvprintf
|
||||||
# define gzputc z_gzputc
|
# define gzputc z_gzputc
|
||||||
# define gzputs z_gzputs
|
# define gzputs z_gzputs
|
||||||
# define gzread z_gzread
|
# define gzread z_gzread
|
||||||
|
@ -78,6 +90,7 @@
|
||||||
# define gztell64 z_gztell64
|
# define gztell64 z_gztell64
|
||||||
# define gzungetc z_gzungetc
|
# define gzungetc z_gzungetc
|
||||||
# define gzwrite z_gzwrite
|
# define gzwrite z_gzwrite
|
||||||
|
# endif
|
||||||
# define inflate z_inflate
|
# define inflate z_inflate
|
||||||
# define inflateBack z_inflateBack
|
# define inflateBack z_inflateBack
|
||||||
# define inflateBackEnd z_inflateBackEnd
|
# define inflateBackEnd z_inflateBackEnd
|
||||||
|
@ -92,16 +105,22 @@
|
||||||
# define inflateReset z_inflateReset
|
# define inflateReset z_inflateReset
|
||||||
# define inflateReset2 z_inflateReset2
|
# define inflateReset2 z_inflateReset2
|
||||||
# define inflateSetDictionary z_inflateSetDictionary
|
# define inflateSetDictionary z_inflateSetDictionary
|
||||||
|
# define inflateGetDictionary z_inflateGetDictionary
|
||||||
# define inflateSync z_inflateSync
|
# define inflateSync z_inflateSync
|
||||||
# define inflateSyncPoint z_inflateSyncPoint
|
# define inflateSyncPoint z_inflateSyncPoint
|
||||||
# define inflateUndermine z_inflateUndermine
|
# define inflateUndermine z_inflateUndermine
|
||||||
|
# define inflateResetKeep z_inflateResetKeep
|
||||||
# define inflate_copyright z_inflate_copyright
|
# define inflate_copyright z_inflate_copyright
|
||||||
# define inflate_fast z_inflate_fast
|
# define inflate_fast z_inflate_fast
|
||||||
# define inflate_table z_inflate_table
|
# define inflate_table z_inflate_table
|
||||||
|
# ifndef Z_SOLO
|
||||||
# define uncompress z_uncompress
|
# define uncompress z_uncompress
|
||||||
|
# endif
|
||||||
# define zError z_zError
|
# define zError z_zError
|
||||||
|
# ifndef Z_SOLO
|
||||||
# define zcalloc z_zcalloc
|
# define zcalloc z_zcalloc
|
||||||
# define zcfree z_zcfree
|
# define zcfree z_zcfree
|
||||||
|
# endif
|
||||||
# define zlibCompileFlags z_zlibCompileFlags
|
# define zlibCompileFlags z_zlibCompileFlags
|
||||||
# define zlibVersion z_zlibVersion
|
# define zlibVersion z_zlibVersion
|
||||||
|
|
||||||
|
@ -111,7 +130,9 @@
|
||||||
# define alloc_func z_alloc_func
|
# define alloc_func z_alloc_func
|
||||||
# define charf z_charf
|
# define charf z_charf
|
||||||
# define free_func z_free_func
|
# define free_func z_free_func
|
||||||
|
# ifndef Z_SOLO
|
||||||
# define gzFile z_gzFile
|
# define gzFile z_gzFile
|
||||||
|
# endif
|
||||||
# define gz_header z_gz_header
|
# define gz_header z_gz_header
|
||||||
# define gz_headerp z_gz_headerp
|
# define gz_headerp z_gz_headerp
|
||||||
# define in_func z_in_func
|
# define in_func z_in_func
|
||||||
|
@ -197,6 +218,12 @@
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(ZLIB_CONST) && !defined(z_const)
|
||||||
|
# define z_const const
|
||||||
|
#else
|
||||||
|
# define z_const
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Some Mac compilers merge all .h files incorrectly: */
|
/* Some Mac compilers merge all .h files incorrectly: */
|
||||||
#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__)
|
#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__)
|
||||||
# define NO_DUMMY_DECL
|
# define NO_DUMMY_DECL
|
||||||
|
@ -243,6 +270,14 @@
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef Z_ARG /* function prototypes for stdarg */
|
||||||
|
# if defined(STDC) || defined(Z_HAVE_STDARG_H)
|
||||||
|
# define Z_ARG(args) args
|
||||||
|
# else
|
||||||
|
# define Z_ARG(args) ()
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
/* The following definitions for FAR are needed only for MSDOS mixed
|
/* The following definitions for FAR are needed only for MSDOS mixed
|
||||||
* model programming (small or medium model with some far allocations).
|
* model programming (small or medium model with some far allocations).
|
||||||
* This was tested only with MSC; for other MSDOS compilers you may have
|
* This was tested only with MSC; for other MSDOS compilers you may have
|
||||||
|
@ -356,13 +391,48 @@ typedef uLong FAR uLongf;
|
||||||
typedef Byte *voidp;
|
typedef Byte *voidp;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC)
|
||||||
|
# include <limits.h>
|
||||||
|
# if (UINT_MAX == 0xffffffffUL)
|
||||||
|
# define Z_U4 unsigned
|
||||||
|
# elif (ULONG_MAX == 0xffffffffUL)
|
||||||
|
# define Z_U4 unsigned long
|
||||||
|
# elif (USHRT_MAX == 0xffffffffUL)
|
||||||
|
# define Z_U4 unsigned short
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef Z_U4
|
||||||
|
typedef Z_U4 z_crc_t;
|
||||||
|
#else
|
||||||
|
typedef unsigned long z_crc_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */
|
#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */
|
||||||
# define Z_HAVE_UNISTD_H
|
# define Z_HAVE_UNISTD_H
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_STDARG_H /* may be set to #if 1 by ./configure */
|
||||||
|
# define Z_HAVE_STDARG_H
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef STDC
|
#ifdef STDC
|
||||||
|
# ifndef Z_SOLO
|
||||||
# include <sys/types.h> /* for off_t */
|
# include <sys/types.h> /* for off_t */
|
||||||
# endif
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(STDC) || defined(Z_HAVE_STDARG_H)
|
||||||
|
# ifndef Z_SOLO
|
||||||
|
# include <stdarg.h> /* for va_list */
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
# ifndef Z_SOLO
|
||||||
|
# include <stddef.h> /* for wchar_t */
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
|
/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
|
||||||
* "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even
|
* "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even
|
||||||
|
@ -370,12 +440,16 @@ typedef uLong FAR uLongf;
|
||||||
* both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as
|
* both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as
|
||||||
* equivalently requesting no 64-bit operations
|
* equivalently requesting no 64-bit operations
|
||||||
*/
|
*/
|
||||||
#if -_LARGEFILE64_SOURCE - -1 == 1
|
#if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1
|
||||||
# undef _LARGEFILE64_SOURCE
|
# undef _LARGEFILE64_SOURCE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__WATCOMC__) && !defined(Z_HAVE_UNISTD_H)
|
||||||
|
# define Z_HAVE_UNISTD_H
|
||||||
|
#endif
|
||||||
|
#ifndef Z_SOLO
|
||||||
# if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE)
|
# if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE)
|
||||||
# include <unistd.h> /* for SEEK_* and off_t */
|
# include <unistd.h> /* for SEEK_*, off_t, and _LFS64_LARGEFILE */
|
||||||
# ifdef VMS
|
# ifdef VMS
|
||||||
# include <unixio.h> /* for off_t */
|
# include <unixio.h> /* for off_t */
|
||||||
# endif
|
# endif
|
||||||
|
@ -383,8 +457,21 @@ typedef uLong FAR uLongf;
|
||||||
# define z_off_t off_t
|
# define z_off_t off_t
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef SEEK_SET
|
#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0
|
||||||
|
# define Z_LFS64
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64)
|
||||||
|
# define Z_LARGE64
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64)
|
||||||
|
# define Z_WANT64
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(SEEK_SET) && !defined(Z_SOLO)
|
||||||
# define SEEK_SET 0 /* Seek from beginning of file. */
|
# define SEEK_SET 0 /* Seek from beginning of file. */
|
||||||
# define SEEK_CUR 1 /* Seek from current position. */
|
# define SEEK_CUR 1 /* Seek from current position. */
|
||||||
# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
|
# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
|
||||||
|
@ -394,18 +481,14 @@ typedef uLong FAR uLongf;
|
||||||
# define z_off_t long
|
# define z_off_t long
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
|
#if !defined(_WIN32) && defined(Z_LARGE64)
|
||||||
# define z_off64_t off64_t
|
# define z_off64_t off64_t
|
||||||
#else
|
#else
|
||||||
|
# if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO)
|
||||||
|
# define z_off64_t __int64
|
||||||
|
# else
|
||||||
# define z_off64_t z_off_t
|
# define z_off64_t z_off_t
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
#if defined(__OS400__)
|
|
||||||
# define NO_vsnprintf
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(__MVS__)
|
|
||||||
# define NO_vsnprintf
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* MVS linker does not support external names larger than 8 bytes */
|
/* MVS linker does not support external names larger than 8 bytes */
|
|
@ -1,7 +1,7 @@
|
||||||
/* zlib.h -- interface of the 'zlib' general purpose compression library
|
/* zlib.h -- interface of the 'zlib' general purpose compression library
|
||||||
version 1.2.5, April 19th, 2010
|
version 1.2.8, April 28th, 2013
|
||||||
|
|
||||||
Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler
|
Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied
|
This software is provided 'as-is', without any express or implied
|
||||||
warranty. In no event will the authors be held liable for any damages
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
@ -24,8 +24,8 @@
|
||||||
|
|
||||||
|
|
||||||
The data format used by the zlib library is described by RFCs (Request for
|
The data format used by the zlib library is described by RFCs (Request for
|
||||||
Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt
|
Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950
|
||||||
(zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).
|
(zlib format), rfc1951 (deflate format) and rfc1952 (gzip format).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef ZLIB_H
|
#ifndef ZLIB_H
|
||||||
|
@ -37,11 +37,11 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define ZLIB_VERSION "1.2.5"
|
#define ZLIB_VERSION "1.2.8"
|
||||||
#define ZLIB_VERNUM 0x1250
|
#define ZLIB_VERNUM 0x1280
|
||||||
#define ZLIB_VER_MAJOR 1
|
#define ZLIB_VER_MAJOR 1
|
||||||
#define ZLIB_VER_MINOR 2
|
#define ZLIB_VER_MINOR 2
|
||||||
#define ZLIB_VER_REVISION 5
|
#define ZLIB_VER_REVISION 8
|
||||||
#define ZLIB_VER_SUBREVISION 0
|
#define ZLIB_VER_SUBREVISION 0
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -83,15 +83,15 @@ typedef void (*free_func) OF((voidpf opaque, voidpf address));
|
||||||
struct internal_state;
|
struct internal_state;
|
||||||
|
|
||||||
typedef struct z_stream_s {
|
typedef struct z_stream_s {
|
||||||
Bytef *next_in; /* next input byte */
|
z_const Bytef *next_in; /* next input byte */
|
||||||
uInt avail_in; /* number of bytes available at next_in */
|
uInt avail_in; /* number of bytes available at next_in */
|
||||||
uLong total_in; /* total nb of input bytes read so far */
|
uLong total_in; /* total number of input bytes read so far */
|
||||||
|
|
||||||
Bytef *next_out; /* next output byte should be put there */
|
Bytef *next_out; /* next output byte should be put there */
|
||||||
uInt avail_out; /* remaining free space at next_out */
|
uInt avail_out; /* remaining free space at next_out */
|
||||||
uLong total_out; /* total nb of bytes output so far */
|
uLong total_out; /* total number of bytes output so far */
|
||||||
|
|
||||||
char *msg; /* last error message, NULL if no error */
|
z_const char *msg; /* last error message, NULL if no error */
|
||||||
struct internal_state FAR *state; /* not visible by applications */
|
struct internal_state FAR *state; /* not visible by applications */
|
||||||
|
|
||||||
alloc_func zalloc; /* used to allocate the internal state */
|
alloc_func zalloc; /* used to allocate the internal state */
|
||||||
|
@ -327,8 +327,9 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
|
||||||
|
|
||||||
Z_FINISH can be used immediately after deflateInit if all the compression
|
Z_FINISH can be used immediately after deflateInit if all the compression
|
||||||
is to be done in a single step. In this case, avail_out must be at least the
|
is to be done in a single step. In this case, avail_out must be at least the
|
||||||
value returned by deflateBound (see below). If deflate does not return
|
value returned by deflateBound (see below). Then deflate is guaranteed to
|
||||||
Z_STREAM_END, then it must be called again as described above.
|
return Z_STREAM_END. If not enough output space is provided, deflate will
|
||||||
|
not return Z_STREAM_END, and it must be called again as described above.
|
||||||
|
|
||||||
deflate() sets strm->adler to the adler32 checksum of all input read
|
deflate() sets strm->adler to the adler32 checksum of all input read
|
||||||
so far (that is, total_in bytes).
|
so far (that is, total_in bytes).
|
||||||
|
@ -451,23 +452,29 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
|
||||||
error. However if all decompression is to be performed in a single step (a
|
error. However if all decompression is to be performed in a single step (a
|
||||||
single call of inflate), the parameter flush should be set to Z_FINISH. In
|
single call of inflate), the parameter flush should be set to Z_FINISH. In
|
||||||
this case all pending input is processed and all pending output is flushed;
|
this case all pending input is processed and all pending output is flushed;
|
||||||
avail_out must be large enough to hold all the uncompressed data. (The size
|
avail_out must be large enough to hold all of the uncompressed data for the
|
||||||
of the uncompressed data may have been saved by the compressor for this
|
operation to complete. (The size of the uncompressed data may have been
|
||||||
purpose.) The next operation on this stream must be inflateEnd to deallocate
|
saved by the compressor for this purpose.) The use of Z_FINISH is not
|
||||||
the decompression state. The use of Z_FINISH is never required, but can be
|
required to perform an inflation in one step. However it may be used to
|
||||||
used to inform inflate that a faster approach may be used for the single
|
inform inflate that a faster approach can be used for the single inflate()
|
||||||
inflate() call.
|
call. Z_FINISH also informs inflate to not maintain a sliding window if the
|
||||||
|
stream completes, which reduces inflate's memory footprint. If the stream
|
||||||
|
does not complete, either because not all of the stream is provided or not
|
||||||
|
enough output space is provided, then a sliding window will be allocated and
|
||||||
|
inflate() can be called again to continue the operation as if Z_NO_FLUSH had
|
||||||
|
been used.
|
||||||
|
|
||||||
In this implementation, inflate() always flushes as much output as
|
In this implementation, inflate() always flushes as much output as
|
||||||
possible to the output buffer, and always uses the faster approach on the
|
possible to the output buffer, and always uses the faster approach on the
|
||||||
first call. So the only effect of the flush parameter in this implementation
|
first call. So the effects of the flush parameter in this implementation are
|
||||||
is on the return value of inflate(), as noted below, or when it returns early
|
on the return value of inflate() as noted below, when inflate() returns early
|
||||||
because Z_BLOCK or Z_TREES is used.
|
when Z_BLOCK or Z_TREES is used, and when inflate() avoids the allocation of
|
||||||
|
memory for a sliding window when Z_FINISH is used.
|
||||||
|
|
||||||
If a preset dictionary is needed after this call (see inflateSetDictionary
|
If a preset dictionary is needed after this call (see inflateSetDictionary
|
||||||
below), inflate sets strm->adler to the adler32 checksum of the dictionary
|
below), inflate sets strm->adler to the Adler-32 checksum of the dictionary
|
||||||
chosen by the compressor and returns Z_NEED_DICT; otherwise it sets
|
chosen by the compressor and returns Z_NEED_DICT; otherwise it sets
|
||||||
strm->adler to the adler32 checksum of all output produced so far (that is,
|
strm->adler to the Adler-32 checksum of all output produced so far (that is,
|
||||||
total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described
|
total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described
|
||||||
below. At the end of the stream, inflate() checks that its computed adler32
|
below. At the end of the stream, inflate() checks that its computed adler32
|
||||||
checksum is equal to that saved by the compressor and returns Z_STREAM_END
|
checksum is equal to that saved by the compressor and returns Z_STREAM_END
|
||||||
|
@ -478,7 +485,9 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
|
||||||
initializing with inflateInit2(). Any information contained in the gzip
|
initializing with inflateInit2(). Any information contained in the gzip
|
||||||
header is not retained, so applications that need that information should
|
header is not retained, so applications that need that information should
|
||||||
instead use raw inflate, see inflateInit2() below, or inflateBack() and
|
instead use raw inflate, see inflateInit2() below, or inflateBack() and
|
||||||
perform their own processing of the gzip header and trailer.
|
perform their own processing of the gzip header and trailer. When processing
|
||||||
|
gzip-wrapped deflate data, strm->adler32 is set to the CRC-32 of the output
|
||||||
|
producted so far. The CRC-32 is checked against the gzip trailer.
|
||||||
|
|
||||||
inflate() returns Z_OK if some progress has been made (more input processed
|
inflate() returns Z_OK if some progress has been made (more input processed
|
||||||
or more output produced), Z_STREAM_END if the end of the compressed data has
|
or more output produced), Z_STREAM_END if the end of the compressed data has
|
||||||
|
@ -580,10 +589,15 @@ ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
|
||||||
uInt dictLength));
|
uInt dictLength));
|
||||||
/*
|
/*
|
||||||
Initializes the compression dictionary from the given byte sequence
|
Initializes the compression dictionary from the given byte sequence
|
||||||
without producing any compressed output. This function must be called
|
without producing any compressed output. When using the zlib format, this
|
||||||
immediately after deflateInit, deflateInit2 or deflateReset, before any call
|
function must be called immediately after deflateInit, deflateInit2 or
|
||||||
of deflate. The compressor and decompressor must use exactly the same
|
deflateReset, and before any call of deflate. When doing raw deflate, this
|
||||||
dictionary (see inflateSetDictionary).
|
function must be called either before any call of deflate, or immediately
|
||||||
|
after the completion of a deflate block, i.e. after all input has been
|
||||||
|
consumed and all output has been delivered when using any of the flush
|
||||||
|
options Z_BLOCK, Z_PARTIAL_FLUSH, Z_SYNC_FLUSH, or Z_FULL_FLUSH. The
|
||||||
|
compressor and decompressor must use exactly the same dictionary (see
|
||||||
|
inflateSetDictionary).
|
||||||
|
|
||||||
The dictionary should consist of strings (byte sequences) that are likely
|
The dictionary should consist of strings (byte sequences) that are likely
|
||||||
to be encountered later in the data to be compressed, with the most commonly
|
to be encountered later in the data to be compressed, with the most commonly
|
||||||
|
@ -610,8 +624,8 @@ ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
|
||||||
deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a
|
deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a
|
||||||
parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is
|
parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is
|
||||||
inconsistent (for example if deflate has already been called for this stream
|
inconsistent (for example if deflate has already been called for this stream
|
||||||
or if the compression method is bsort). deflateSetDictionary does not
|
or if not at a block boundary for raw deflate). deflateSetDictionary does
|
||||||
perform any compression: this will be done by deflate().
|
not perform any compression: this will be done by deflate().
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,
|
ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,
|
||||||
|
@ -688,7 +702,27 @@ ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm,
|
||||||
deflation of sourceLen bytes. It must be called after deflateInit() or
|
deflation of sourceLen bytes. It must be called after deflateInit() or
|
||||||
deflateInit2(), and after deflateSetHeader(), if used. This would be used
|
deflateInit2(), and after deflateSetHeader(), if used. This would be used
|
||||||
to allocate an output buffer for deflation in a single pass, and so would be
|
to allocate an output buffer for deflation in a single pass, and so would be
|
||||||
called before deflate().
|
called before deflate(). If that first deflate() call is provided the
|
||||||
|
sourceLen input bytes, an output buffer allocated to the size returned by
|
||||||
|
deflateBound(), and the flush value Z_FINISH, then deflate() is guaranteed
|
||||||
|
to return Z_STREAM_END. Note that it is possible for the compressed size to
|
||||||
|
be larger than the value returned by deflateBound() if flush options other
|
||||||
|
than Z_FINISH or Z_NO_FLUSH are used.
|
||||||
|
*/
|
||||||
|
|
||||||
|
ZEXTERN int ZEXPORT deflatePending OF((z_streamp strm,
|
||||||
|
unsigned *pending,
|
||||||
|
int *bits));
|
||||||
|
/*
|
||||||
|
deflatePending() returns the number of bytes and bits of output that have
|
||||||
|
been generated, but not yet provided in the available output. The bytes not
|
||||||
|
provided would be due to the available output space having being consumed.
|
||||||
|
The number of bits of output not provided are between 0 and 7, where they
|
||||||
|
await more bits to join them in order to fill out a full byte. If pending
|
||||||
|
or bits are Z_NULL, then those values are not set.
|
||||||
|
|
||||||
|
deflatePending returns Z_OK if success, or Z_STREAM_ERROR if the source
|
||||||
|
stream state was inconsistent.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm,
|
ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm,
|
||||||
|
@ -703,8 +737,9 @@ ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm,
|
||||||
than or equal to 16, and that many of the least significant bits of value
|
than or equal to 16, and that many of the least significant bits of value
|
||||||
will be inserted in the output.
|
will be inserted in the output.
|
||||||
|
|
||||||
deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source
|
deflatePrime returns Z_OK if success, Z_BUF_ERROR if there was not enough
|
||||||
stream state was inconsistent.
|
room in the internal buffer to insert the bits, or Z_STREAM_ERROR if the
|
||||||
|
source stream state was inconsistent.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm,
|
ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm,
|
||||||
|
@ -790,10 +825,11 @@ ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
|
||||||
if that call returned Z_NEED_DICT. The dictionary chosen by the compressor
|
if that call returned Z_NEED_DICT. The dictionary chosen by the compressor
|
||||||
can be determined from the adler32 value returned by that call of inflate.
|
can be determined from the adler32 value returned by that call of inflate.
|
||||||
The compressor and decompressor must use exactly the same dictionary (see
|
The compressor and decompressor must use exactly the same dictionary (see
|
||||||
deflateSetDictionary). For raw inflate, this function can be called
|
deflateSetDictionary). For raw inflate, this function can be called at any
|
||||||
immediately after inflateInit2() or inflateReset() and before any call of
|
time to set the dictionary. If the provided dictionary is smaller than the
|
||||||
inflate() to set the dictionary. The application must insure that the
|
window and there is already data in the window, then the provided dictionary
|
||||||
dictionary that was used for compression is provided.
|
will amend what's there. The application must insure that the dictionary
|
||||||
|
that was used for compression is provided.
|
||||||
|
|
||||||
inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a
|
inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a
|
||||||
parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is
|
parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is
|
||||||
|
@ -803,19 +839,38 @@ ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
|
||||||
inflate().
|
inflate().
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
ZEXTERN int ZEXPORT inflateGetDictionary OF((z_streamp strm,
|
||||||
|
Bytef *dictionary,
|
||||||
|
uInt *dictLength));
|
||||||
|
/*
|
||||||
|
Returns the sliding dictionary being maintained by inflate. dictLength is
|
||||||
|
set to the number of bytes in the dictionary, and that many bytes are copied
|
||||||
|
to dictionary. dictionary must have enough space, where 32768 bytes is
|
||||||
|
always enough. If inflateGetDictionary() is called with dictionary equal to
|
||||||
|
Z_NULL, then only the dictionary length is returned, and nothing is copied.
|
||||||
|
Similary, if dictLength is Z_NULL, then it is not set.
|
||||||
|
|
||||||
|
inflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the
|
||||||
|
stream state is inconsistent.
|
||||||
|
*/
|
||||||
|
|
||||||
ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm));
|
ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm));
|
||||||
/*
|
/*
|
||||||
Skips invalid compressed data until a full flush point (see above the
|
Skips invalid compressed data until a possible full flush point (see above
|
||||||
description of deflate with Z_FULL_FLUSH) can be found, or until all
|
for the description of deflate with Z_FULL_FLUSH) can be found, or until all
|
||||||
available input is skipped. No output is provided.
|
available input is skipped. No output is provided.
|
||||||
|
|
||||||
inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR
|
inflateSync searches for a 00 00 FF FF pattern in the compressed data.
|
||||||
if no more input was provided, Z_DATA_ERROR if no flush point has been
|
All full flush points have this pattern, but not all occurrences of this
|
||||||
found, or Z_STREAM_ERROR if the stream structure was inconsistent. In the
|
pattern are full flush points.
|
||||||
success case, the application may save the current current value of total_in
|
|
||||||
which indicates where valid compressed data was found. In the error case,
|
inflateSync returns Z_OK if a possible full flush point has been found,
|
||||||
the application may repeatedly call inflateSync, providing more input each
|
Z_BUF_ERROR if no more input was provided, Z_DATA_ERROR if no flush point
|
||||||
time, until success or end of the input data.
|
has been found, or Z_STREAM_ERROR if the stream structure was inconsistent.
|
||||||
|
In the success case, the application may save the current current value of
|
||||||
|
total_in which indicates where valid compressed data was found. In the
|
||||||
|
error case, the application may repeatedly call inflateSync, providing more
|
||||||
|
input each time, until success or end of the input data.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest,
|
ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest,
|
||||||
|
@ -962,12 +1017,13 @@ ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits,
|
||||||
See inflateBack() for the usage of these routines.
|
See inflateBack() for the usage of these routines.
|
||||||
|
|
||||||
inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of
|
inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of
|
||||||
the paramaters are invalid, Z_MEM_ERROR if the internal state could not be
|
the parameters are invalid, Z_MEM_ERROR if the internal state could not be
|
||||||
allocated, or Z_VERSION_ERROR if the version of the library does not match
|
allocated, or Z_VERSION_ERROR if the version of the library does not match
|
||||||
the version of the header file.
|
the version of the header file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *));
|
typedef unsigned (*in_func) OF((void FAR *,
|
||||||
|
z_const unsigned char FAR * FAR *));
|
||||||
typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned));
|
typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned));
|
||||||
|
|
||||||
ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,
|
ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,
|
||||||
|
@ -975,11 +1031,12 @@ ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,
|
||||||
out_func out, void FAR *out_desc));
|
out_func out, void FAR *out_desc));
|
||||||
/*
|
/*
|
||||||
inflateBack() does a raw inflate with a single call using a call-back
|
inflateBack() does a raw inflate with a single call using a call-back
|
||||||
interface for input and output. This is more efficient than inflate() for
|
interface for input and output. This is potentially more efficient than
|
||||||
file i/o applications in that it avoids copying between the output and the
|
inflate() for file i/o applications, in that it avoids copying between the
|
||||||
sliding window by simply making the window itself the output buffer. This
|
output and the sliding window by simply making the window itself the output
|
||||||
function trusts the application to not change the output buffer passed by
|
buffer. inflate() can be faster on modern CPUs when used with large
|
||||||
the output function, at least until inflateBack() returns.
|
buffers. inflateBack() trusts the application to not change the output
|
||||||
|
buffer passed by the output function, at least until inflateBack() returns.
|
||||||
|
|
||||||
inflateBackInit() must be called first to allocate the internal state
|
inflateBackInit() must be called first to allocate the internal state
|
||||||
and to initialize the state with the user-provided window buffer.
|
and to initialize the state with the user-provided window buffer.
|
||||||
|
@ -1088,6 +1145,7 @@ ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void));
|
||||||
27-31: 0 (reserved)
|
27-31: 0 (reserved)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef Z_SOLO
|
||||||
|
|
||||||
/* utility functions */
|
/* utility functions */
|
||||||
|
|
||||||
|
@ -1149,10 +1207,11 @@ ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen,
|
||||||
|
|
||||||
uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
|
uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
|
||||||
enough memory, Z_BUF_ERROR if there was not enough room in the output
|
enough memory, Z_BUF_ERROR if there was not enough room in the output
|
||||||
buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete.
|
buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. In
|
||||||
|
the case where there is not enough room, uncompress() will fill the output
|
||||||
|
buffer with the uncompressed data up to that point.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/* gzip file access functions */
|
/* gzip file access functions */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1162,7 +1221,7 @@ ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen,
|
||||||
wrapper, documented in RFC 1952, wrapped around a deflate stream.
|
wrapper, documented in RFC 1952, wrapped around a deflate stream.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef voidp gzFile; /* opaque gzip file descriptor */
|
typedef struct gzFile_s *gzFile; /* semi-opaque gzip file descriptor */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
|
ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
|
||||||
|
@ -1172,13 +1231,28 @@ ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
|
||||||
a strategy: 'f' for filtered data as in "wb6f", 'h' for Huffman-only
|
a strategy: 'f' for filtered data as in "wb6f", 'h' for Huffman-only
|
||||||
compression as in "wb1h", 'R' for run-length encoding as in "wb1R", or 'F'
|
compression as in "wb1h", 'R' for run-length encoding as in "wb1R", or 'F'
|
||||||
for fixed code compression as in "wb9F". (See the description of
|
for fixed code compression as in "wb9F". (See the description of
|
||||||
deflateInit2 for more information about the strategy parameter.) Also "a"
|
deflateInit2 for more information about the strategy parameter.) 'T' will
|
||||||
can be used instead of "w" to request that the gzip stream that will be
|
request transparent writing or appending with no compression and not using
|
||||||
written be appended to the file. "+" will result in an error, since reading
|
the gzip format.
|
||||||
and writing to the same gzip file is not supported.
|
|
||||||
|
"a" can be used instead of "w" to request that the gzip stream that will
|
||||||
|
be written be appended to the file. "+" will result in an error, since
|
||||||
|
reading and writing to the same gzip file is not supported. The addition of
|
||||||
|
"x" when writing will create the file exclusively, which fails if the file
|
||||||
|
already exists. On systems that support it, the addition of "e" when
|
||||||
|
reading or writing will set the flag to close the file on an execve() call.
|
||||||
|
|
||||||
|
These functions, as well as gzip, will read and decode a sequence of gzip
|
||||||
|
streams in a file. The append function of gzopen() can be used to create
|
||||||
|
such a file. (Also see gzflush() for another way to do this.) When
|
||||||
|
appending, gzopen does not test whether the file begins with a gzip stream,
|
||||||
|
nor does it look for the end of the gzip streams to begin appending. gzopen
|
||||||
|
will simply append a gzip stream to the existing file.
|
||||||
|
|
||||||
gzopen can be used to read a file which is not in gzip format; in this
|
gzopen can be used to read a file which is not in gzip format; in this
|
||||||
case gzread will directly read from the file without decompression.
|
case gzread will directly read from the file without decompression. When
|
||||||
|
reading, this will be detected automatically by looking for the magic two-
|
||||||
|
byte gzip header.
|
||||||
|
|
||||||
gzopen returns NULL if the file could not be opened, if there was
|
gzopen returns NULL if the file could not be opened, if there was
|
||||||
insufficient memory to allocate the gzFile state, or if an invalid mode was
|
insufficient memory to allocate the gzFile state, or if an invalid mode was
|
||||||
|
@ -1197,7 +1271,11 @@ ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode));
|
||||||
descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor
|
descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor
|
||||||
fd. If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd,
|
fd. If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd,
|
||||||
mode);. The duplicated descriptor should be saved to avoid a leak, since
|
mode);. The duplicated descriptor should be saved to avoid a leak, since
|
||||||
gzdopen does not close fd if it fails.
|
gzdopen does not close fd if it fails. If you are using fileno() to get the
|
||||||
|
file descriptor from a FILE *, then you will have to use dup() to avoid
|
||||||
|
double-close()ing the file descriptor. Both gzclose() and fclose() will
|
||||||
|
close the associated file descriptor, so they need to have different file
|
||||||
|
descriptors.
|
||||||
|
|
||||||
gzdopen returns NULL if there was insufficient memory to allocate the
|
gzdopen returns NULL if there was insufficient memory to allocate the
|
||||||
gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not
|
gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not
|
||||||
|
@ -1235,14 +1313,26 @@ ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));
|
||||||
ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));
|
ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));
|
||||||
/*
|
/*
|
||||||
Reads the given number of uncompressed bytes from the compressed file. If
|
Reads the given number of uncompressed bytes from the compressed file. If
|
||||||
the input file was not in gzip format, gzread copies the given number of
|
the input file is not in gzip format, gzread copies the given number of
|
||||||
bytes into the buffer.
|
bytes into the buffer directly from the file.
|
||||||
|
|
||||||
After reaching the end of a gzip stream in the input, gzread will continue
|
After reaching the end of a gzip stream in the input, gzread will continue
|
||||||
to read, looking for another gzip stream, or failing that, reading the rest
|
to read, looking for another gzip stream. Any number of gzip streams may be
|
||||||
of the input file directly without decompression. The entire input file
|
concatenated in the input file, and will all be decompressed by gzread().
|
||||||
will be read if gzread is called until it returns less than the requested
|
If something other than a gzip stream is encountered after a gzip stream,
|
||||||
len.
|
that remaining trailing garbage is ignored (and no error is returned).
|
||||||
|
|
||||||
|
gzread can be used to read a gzip file that is being concurrently written.
|
||||||
|
Upon reaching the end of the input, gzread will return with the available
|
||||||
|
data. If the error code returned by gzerror is Z_OK or Z_BUF_ERROR, then
|
||||||
|
gzclearerr can be used to clear the end of file indicator in order to permit
|
||||||
|
gzread to be tried again. Z_OK indicates that a gzip stream was completed
|
||||||
|
on the last gzread. Z_BUF_ERROR indicates that the input file ended in the
|
||||||
|
middle of a gzip stream. Note that gzread does not return -1 in the event
|
||||||
|
of an incomplete gzip stream. This error is deferred until gzclose(), which
|
||||||
|
will return Z_BUF_ERROR if the last gzread ended in the middle of a gzip
|
||||||
|
stream. Alternatively, gzerror can be used before gzclose to detect this
|
||||||
|
case.
|
||||||
|
|
||||||
gzread returns the number of uncompressed bytes actually read, less than
|
gzread returns the number of uncompressed bytes actually read, less than
|
||||||
len for end of file, or -1 for error.
|
len for end of file, or -1 for error.
|
||||||
|
@ -1256,7 +1346,7 @@ ZEXTERN int ZEXPORT gzwrite OF((gzFile file,
|
||||||
error.
|
error.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...));
|
ZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char *format, ...));
|
||||||
/*
|
/*
|
||||||
Converts, formats, and writes the arguments to the compressed file under
|
Converts, formats, and writes the arguments to the compressed file under
|
||||||
control of the format string, as in fprintf. gzprintf returns the number of
|
control of the format string, as in fprintf. gzprintf returns the number of
|
||||||
|
@ -1301,7 +1391,10 @@ ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c));
|
||||||
ZEXTERN int ZEXPORT gzgetc OF((gzFile file));
|
ZEXTERN int ZEXPORT gzgetc OF((gzFile file));
|
||||||
/*
|
/*
|
||||||
Reads one byte from the compressed file. gzgetc returns this byte or -1
|
Reads one byte from the compressed file. gzgetc returns this byte or -1
|
||||||
in case of end of file or error.
|
in case of end of file or error. This is implemented as a macro for speed.
|
||||||
|
As such, it does not do all of the checking the other functions do. I.e.
|
||||||
|
it does not check to see if file is NULL, nor whether the structure file
|
||||||
|
points to has been clobbered or not.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file));
|
ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file));
|
||||||
|
@ -1397,9 +1490,7 @@ ZEXTERN int ZEXPORT gzeof OF((gzFile file));
|
||||||
ZEXTERN int ZEXPORT gzdirect OF((gzFile file));
|
ZEXTERN int ZEXPORT gzdirect OF((gzFile file));
|
||||||
/*
|
/*
|
||||||
Returns true (1) if file is being copied directly while reading, or false
|
Returns true (1) if file is being copied directly while reading, or false
|
||||||
(0) if file is a gzip stream being decompressed. This state can change from
|
(0) if file is a gzip stream being decompressed.
|
||||||
false to true while reading the input file if the end of a gzip stream is
|
|
||||||
reached, but is followed by data that is not another gzip stream.
|
|
||||||
|
|
||||||
If the input file is empty, gzdirect() will return true, since the input
|
If the input file is empty, gzdirect() will return true, since the input
|
||||||
does not contain a gzip stream.
|
does not contain a gzip stream.
|
||||||
|
@ -1408,6 +1499,13 @@ ZEXTERN int ZEXPORT gzdirect OF((gzFile file));
|
||||||
cause buffers to be allocated to allow reading the file to determine if it
|
cause buffers to be allocated to allow reading the file to determine if it
|
||||||
is a gzip file. Therefore if gzbuffer() is used, it should be called before
|
is a gzip file. Therefore if gzbuffer() is used, it should be called before
|
||||||
gzdirect().
|
gzdirect().
|
||||||
|
|
||||||
|
When writing, gzdirect() returns true (1) if transparent writing was
|
||||||
|
requested ("wT" for the gzopen() mode), or false (0) otherwise. (Note:
|
||||||
|
gzdirect() is not needed when writing. Transparent writing must be
|
||||||
|
explicitly requested, so the application already knows the answer. When
|
||||||
|
linking statically, using gzdirect() will include all of the zlib code for
|
||||||
|
gzip file reading and decompression, which may not be desired.)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ZEXTERN int ZEXPORT gzclose OF((gzFile file));
|
ZEXTERN int ZEXPORT gzclose OF((gzFile file));
|
||||||
|
@ -1419,7 +1517,8 @@ ZEXTERN int ZEXPORT gzclose OF((gzFile file));
|
||||||
must not be called more than once on the same allocation.
|
must not be called more than once on the same allocation.
|
||||||
|
|
||||||
gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a
|
gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a
|
||||||
file operation error, or Z_OK on success.
|
file operation error, Z_MEM_ERROR if out of memory, Z_BUF_ERROR if the
|
||||||
|
last read ended in the middle of a gzip stream, or Z_OK on success.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ZEXTERN int ZEXPORT gzclose_r OF((gzFile file));
|
ZEXTERN int ZEXPORT gzclose_r OF((gzFile file));
|
||||||
|
@ -1457,6 +1556,7 @@ ZEXTERN void ZEXPORT gzclearerr OF((gzFile file));
|
||||||
file that is being written concurrently.
|
file that is being written concurrently.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#endif /* !Z_SOLO */
|
||||||
|
|
||||||
/* checksum functions */
|
/* checksum functions */
|
||||||
|
|
||||||
|
@ -1492,16 +1592,17 @@ ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2,
|
||||||
Combine two Adler-32 checksums into one. For two sequences of bytes, seq1
|
Combine two Adler-32 checksums into one. For two sequences of bytes, seq1
|
||||||
and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for
|
and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for
|
||||||
each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of
|
each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of
|
||||||
seq1 and seq2 concatenated, requiring only adler1, adler2, and len2.
|
seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. Note
|
||||||
|
that the z_off_t type (like off_t) is a signed integer. If len2 is
|
||||||
|
negative, the result has no meaning or utility.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));
|
ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));
|
||||||
/*
|
/*
|
||||||
Update a running CRC-32 with the bytes buf[0..len-1] and return the
|
Update a running CRC-32 with the bytes buf[0..len-1] and return the
|
||||||
updated CRC-32. If buf is Z_NULL, this function returns the required
|
updated CRC-32. If buf is Z_NULL, this function returns the required
|
||||||
initial value for the for the crc. Pre- and post-conditioning (one's
|
initial value for the crc. Pre- and post-conditioning (one's complement) is
|
||||||
complement) is performed within this function so it shouldn't be done by the
|
performed within this function so it shouldn't be done by the application.
|
||||||
application.
|
|
||||||
|
|
||||||
Usage example:
|
Usage example:
|
||||||
|
|
||||||
|
@ -1544,17 +1645,42 @@ ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,
|
||||||
const char *version,
|
const char *version,
|
||||||
int stream_size));
|
int stream_size));
|
||||||
#define deflateInit(strm, level) \
|
#define deflateInit(strm, level) \
|
||||||
deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream))
|
deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream))
|
||||||
#define inflateInit(strm) \
|
#define inflateInit(strm) \
|
||||||
inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream))
|
inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream))
|
||||||
#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
|
#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
|
||||||
deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
|
deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
|
||||||
(strategy), ZLIB_VERSION, sizeof(z_stream))
|
(strategy), ZLIB_VERSION, (int)sizeof(z_stream))
|
||||||
#define inflateInit2(strm, windowBits) \
|
#define inflateInit2(strm, windowBits) \
|
||||||
inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))
|
inflateInit2_((strm), (windowBits), ZLIB_VERSION, \
|
||||||
|
(int)sizeof(z_stream))
|
||||||
#define inflateBackInit(strm, windowBits, window) \
|
#define inflateBackInit(strm, windowBits, window) \
|
||||||
inflateBackInit_((strm), (windowBits), (window), \
|
inflateBackInit_((strm), (windowBits), (window), \
|
||||||
ZLIB_VERSION, sizeof(z_stream))
|
ZLIB_VERSION, (int)sizeof(z_stream))
|
||||||
|
|
||||||
|
#ifndef Z_SOLO
|
||||||
|
|
||||||
|
/* gzgetc() macro and its supporting function and exposed data structure. Note
|
||||||
|
* that the real internal state is much larger than the exposed structure.
|
||||||
|
* This abbreviated structure exposes just enough for the gzgetc() macro. The
|
||||||
|
* user should not mess with these exposed elements, since their names or
|
||||||
|
* behavior could change in the future, perhaps even capriciously. They can
|
||||||
|
* only be used by the gzgetc() macro. You have been warned.
|
||||||
|
*/
|
||||||
|
struct gzFile_s {
|
||||||
|
unsigned have;
|
||||||
|
unsigned char *next;
|
||||||
|
z_off64_t pos;
|
||||||
|
};
|
||||||
|
ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */
|
||||||
|
#ifdef Z_PREFIX_SET
|
||||||
|
# undef z_gzgetc
|
||||||
|
# define z_gzgetc(g) \
|
||||||
|
((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : gzgetc(g))
|
||||||
|
#else
|
||||||
|
# define gzgetc(g) \
|
||||||
|
((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : gzgetc(g))
|
||||||
|
#endif
|
||||||
|
|
||||||
/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or
|
/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or
|
||||||
* change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if
|
* change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if
|
||||||
|
@ -1562,7 +1688,7 @@ ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,
|
||||||
* functions are changed to 64 bits) -- in case these are set on systems
|
* functions are changed to 64 bits) -- in case these are set on systems
|
||||||
* without large file support, _LFS64_LARGEFILE must also be true
|
* without large file support, _LFS64_LARGEFILE must also be true
|
||||||
*/
|
*/
|
||||||
#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
|
#ifdef Z_LARGE64
|
||||||
ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
|
ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
|
||||||
ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int));
|
ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int));
|
||||||
ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile));
|
ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile));
|
||||||
|
@ -1571,14 +1697,23 @@ ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,
|
||||||
ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t));
|
ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(ZLIB_INTERNAL) && _FILE_OFFSET_BITS-0 == 64 && _LFS64_LARGEFILE-0
|
#if !defined(ZLIB_INTERNAL) && defined(Z_WANT64)
|
||||||
|
# ifdef Z_PREFIX_SET
|
||||||
|
# define z_gzopen z_gzopen64
|
||||||
|
# define z_gzseek z_gzseek64
|
||||||
|
# define z_gztell z_gztell64
|
||||||
|
# define z_gzoffset z_gzoffset64
|
||||||
|
# define z_adler32_combine z_adler32_combine64
|
||||||
|
# define z_crc32_combine z_crc32_combine64
|
||||||
|
# else
|
||||||
# define gzopen gzopen64
|
# define gzopen gzopen64
|
||||||
# define gzseek gzseek64
|
# define gzseek gzseek64
|
||||||
# define gztell gztell64
|
# define gztell gztell64
|
||||||
# define gzoffset gzoffset64
|
# define gzoffset gzoffset64
|
||||||
# define adler32_combine adler32_combine64
|
# define adler32_combine adler32_combine64
|
||||||
# define crc32_combine crc32_combine64
|
# define crc32_combine crc32_combine64
|
||||||
# ifdef _LARGEFILE64_SOURCE
|
# endif
|
||||||
|
# ifndef Z_LARGE64
|
||||||
ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
|
ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
|
||||||
ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int));
|
ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int));
|
||||||
ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile));
|
ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile));
|
||||||
|
@ -1595,6 +1730,13 @@ ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,
|
||||||
ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));
|
ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#else /* Z_SOLO */
|
||||||
|
|
||||||
|
ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));
|
||||||
|
ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));
|
||||||
|
|
||||||
|
#endif /* !Z_SOLO */
|
||||||
|
|
||||||
/* hack for buggy compilers */
|
/* hack for buggy compilers */
|
||||||
#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL)
|
#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL)
|
||||||
struct internal_state {int dummy;};
|
struct internal_state {int dummy;};
|
||||||
|
@ -1603,8 +1745,21 @@ ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,
|
||||||
/* undocumented functions */
|
/* undocumented functions */
|
||||||
ZEXTERN const char * ZEXPORT zError OF((int));
|
ZEXTERN const char * ZEXPORT zError OF((int));
|
||||||
ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp));
|
ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp));
|
||||||
ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void));
|
ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table OF((void));
|
||||||
ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int));
|
ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int));
|
||||||
|
ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp));
|
||||||
|
ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp));
|
||||||
|
#if defined(_WIN32) && !defined(Z_SOLO)
|
||||||
|
ZEXTERN gzFile ZEXPORT gzopen_w OF((const wchar_t *path,
|
||||||
|
const char *mode));
|
||||||
|
#endif
|
||||||
|
#if defined(STDC) || defined(Z_HAVE_STDARG_H)
|
||||||
|
# ifndef Z_SOLO
|
||||||
|
ZEXTERN int ZEXPORTVA gzvprintf Z_ARG((gzFile file,
|
||||||
|
const char *format,
|
||||||
|
va_list va));
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
|
@ -1,17 +1,20 @@
|
||||||
/* zutil.c -- target dependent utility functions for the compression library
|
/* zutil.c -- target dependent utility functions for the compression library
|
||||||
* Copyright (C) 1995-2005, 2010 Jean-loup Gailly.
|
* Copyright (C) 1995-2005, 2010, 2011, 2012 Jean-loup Gailly.
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* @(#) $Id$ */
|
/* @(#) $Id$ */
|
||||||
|
|
||||||
#include "zutil.h"
|
#include "zutil.h"
|
||||||
|
#ifndef Z_SOLO
|
||||||
|
# include "gzguts.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef NO_DUMMY_DECL
|
#ifndef NO_DUMMY_DECL
|
||||||
struct internal_state {int dummy;}; /* for buggy compilers */
|
struct internal_state {int dummy;}; /* for buggy compilers */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const char * const z_errmsg[10] = {
|
z_const char * const z_errmsg[10] = {
|
||||||
"need dictionary", /* Z_NEED_DICT 2 */
|
"need dictionary", /* Z_NEED_DICT 2 */
|
||||||
"stream end", /* Z_STREAM_END 1 */
|
"stream end", /* Z_STREAM_END 1 */
|
||||||
"", /* Z_OK 0 */
|
"", /* Z_OK 0 */
|
||||||
|
@ -85,7 +88,7 @@ uLong ZEXPORT zlibCompileFlags()
|
||||||
#ifdef FASTEST
|
#ifdef FASTEST
|
||||||
flags += 1L << 21;
|
flags += 1L << 21;
|
||||||
#endif
|
#endif
|
||||||
#ifdef STDC
|
#if defined(STDC) || defined(Z_HAVE_STDARG_H)
|
||||||
# ifdef NO_vsnprintf
|
# ifdef NO_vsnprintf
|
||||||
flags += 1L << 25;
|
flags += 1L << 25;
|
||||||
# ifdef HAS_vsprintf_void
|
# ifdef HAS_vsprintf_void
|
||||||
|
@ -181,6 +184,7 @@ void ZLIB_INTERNAL zmemzero(dest, len)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef Z_SOLO
|
||||||
|
|
||||||
#ifdef SYS16BIT
|
#ifdef SYS16BIT
|
||||||
|
|
||||||
|
@ -316,3 +320,5 @@ void ZLIB_INTERNAL zcfree (opaque, ptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* MY_ZCALLOC */
|
#endif /* MY_ZCALLOC */
|
||||||
|
|
||||||
|
#endif /* !Z_SOLO */
|
|
@ -1,5 +1,5 @@
|
||||||
/* zutil.h -- internal interface and configuration of the compression library
|
/* zutil.h -- internal interface and configuration of the compression library
|
||||||
* Copyright (C) 1995-2010 Jean-loup Gailly.
|
* Copyright (C) 1995-2013 Jean-loup Gailly.
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
#ifndef ZUTIL_H
|
#ifndef ZUTIL_H
|
||||||
#define ZUTIL_H
|
#define ZUTIL_H
|
||||||
|
|
||||||
#if ((__GNUC__-0) * 10 + __GNUC_MINOR__-0 >= 33) && !defined(NO_VIZ)
|
#ifdef HAVE_HIDDEN
|
||||||
# define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
|
# define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
|
||||||
#else
|
#else
|
||||||
# define ZLIB_INTERNAL
|
# define ZLIB_INTERNAL
|
||||||
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
#include "zlib.h"
|
#include "zlib.h"
|
||||||
|
|
||||||
#ifdef STDC
|
#if defined(STDC) && !defined(Z_SOLO)
|
||||||
# if !(defined(_WIN32_WCE) && defined(_MSC_VER))
|
# if !(defined(_WIN32_WCE) && defined(_MSC_VER))
|
||||||
# include <stddef.h>
|
# include <stddef.h>
|
||||||
# endif
|
# endif
|
||||||
|
@ -29,6 +29,10 @@
|
||||||
# include <stdlib.h>
|
# include <stdlib.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef Z_SOLO
|
||||||
|
typedef long ptrdiff_t; /* guess -- will be caught if guess is wrong */
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef local
|
#ifndef local
|
||||||
# define local static
|
# define local static
|
||||||
#endif
|
#endif
|
||||||
|
@ -40,13 +44,13 @@ typedef unsigned short ush;
|
||||||
typedef ush FAR ushf;
|
typedef ush FAR ushf;
|
||||||
typedef unsigned long ulg;
|
typedef unsigned long ulg;
|
||||||
|
|
||||||
extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
||||||
/* (size given to avoid silly warnings with Visual C++) */
|
/* (size given to avoid silly warnings with Visual C++) */
|
||||||
|
|
||||||
#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
|
#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
|
||||||
|
|
||||||
#define ERR_RETURN(strm,err) \
|
#define ERR_RETURN(strm,err) \
|
||||||
return (strm->msg = (char*)ERR_MSG(err), (err))
|
return (strm->msg = ERR_MSG(err), (err))
|
||||||
/* To be used only when the state is known to be valid */
|
/* To be used only when the state is known to be valid */
|
||||||
|
|
||||||
/* common constants */
|
/* common constants */
|
||||||
|
@ -78,6 +82,7 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
||||||
|
|
||||||
#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))
|
#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))
|
||||||
# define OS_CODE 0x00
|
# define OS_CODE 0x00
|
||||||
|
# ifndef Z_SOLO
|
||||||
# if defined(__TURBOC__) || defined(__BORLANDC__)
|
# if defined(__TURBOC__) || defined(__BORLANDC__)
|
||||||
# if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
|
# if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
|
||||||
/* Allow compilation with ANSI keywords only enabled */
|
/* Allow compilation with ANSI keywords only enabled */
|
||||||
|
@ -90,6 +95,7 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
||||||
# include <malloc.h>
|
# include <malloc.h>
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef AMIGA
|
#ifdef AMIGA
|
||||||
# define OS_CODE 0x01
|
# define OS_CODE 0x01
|
||||||
|
@ -107,13 +113,14 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
||||||
|
|
||||||
#ifdef OS2
|
#ifdef OS2
|
||||||
# define OS_CODE 0x06
|
# define OS_CODE 0x06
|
||||||
# ifdef M_I86
|
# if defined(M_I86) && !defined(Z_SOLO)
|
||||||
# include <malloc.h>
|
# include <malloc.h>
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(MACOS) || defined(TARGET_OS_MAC)
|
#if defined(MACOS) || defined(TARGET_OS_MAC)
|
||||||
# define OS_CODE 0x07
|
# define OS_CODE 0x07
|
||||||
|
# ifndef Z_SOLO
|
||||||
# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
|
# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
|
||||||
# include <unix.h> /* for fdopen */
|
# include <unix.h> /* for fdopen */
|
||||||
# else
|
# else
|
||||||
|
@ -122,6 +129,7 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef TOPS20
|
#ifdef TOPS20
|
||||||
# define OS_CODE 0x0a
|
# define OS_CODE 0x0a
|
||||||
|
@ -153,14 +161,15 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__BORLANDC__)
|
#if defined(__BORLANDC__) && !defined(MSDOS)
|
||||||
#pragma warn -8004
|
#pragma warn -8004
|
||||||
#pragma warn -8008
|
#pragma warn -8008
|
||||||
#pragma warn -8066
|
#pragma warn -8066
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* provide prototypes for these when building zlib without LFS */
|
/* provide prototypes for these when building zlib without LFS */
|
||||||
#if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0
|
#if !defined(_WIN32) && \
|
||||||
|
(!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0)
|
||||||
ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));
|
ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));
|
||||||
ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));
|
ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));
|
||||||
#endif
|
#endif
|
||||||
|
@ -177,42 +186,7 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
||||||
|
|
||||||
/* functions */
|
/* functions */
|
||||||
|
|
||||||
#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550)
|
#if defined(pyr) || defined(Z_SOLO)
|
||||||
# ifndef HAVE_VSNPRINTF
|
|
||||||
# define HAVE_VSNPRINTF
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
#if defined(__CYGWIN__)
|
|
||||||
# ifndef HAVE_VSNPRINTF
|
|
||||||
# define HAVE_VSNPRINTF
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
#ifndef HAVE_VSNPRINTF
|
|
||||||
# ifdef MSDOS
|
|
||||||
/* vsnprintf may exist on some MS-DOS compilers (DJGPP?),
|
|
||||||
but for now we just assume it doesn't. */
|
|
||||||
# define NO_vsnprintf
|
|
||||||
# endif
|
|
||||||
# ifdef __TURBOC__
|
|
||||||
# define NO_vsnprintf
|
|
||||||
# endif
|
|
||||||
# ifdef WIN32
|
|
||||||
/* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */
|
|
||||||
# if !defined(vsnprintf) && !defined(NO_vsnprintf)
|
|
||||||
# if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 )
|
|
||||||
# define vsnprintf _vsnprintf
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
# ifdef __SASC
|
|
||||||
# define NO_vsnprintf
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
#ifdef VMS
|
|
||||||
# define NO_vsnprintf
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(pyr)
|
|
||||||
# define NO_MEMCPY
|
# define NO_MEMCPY
|
||||||
#endif
|
#endif
|
||||||
#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
|
#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
|
||||||
|
@ -261,14 +235,19 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
||||||
# define Tracecv(c,x)
|
# define Tracecv(c,x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef Z_SOLO
|
||||||
voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items,
|
voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items,
|
||||||
unsigned size));
|
unsigned size));
|
||||||
void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr));
|
void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr));
|
||||||
|
#endif
|
||||||
|
|
||||||
#define ZALLOC(strm, items, size) \
|
#define ZALLOC(strm, items, size) \
|
||||||
(*((strm)->zalloc))((strm)->opaque, (items), (size))
|
(*((strm)->zalloc))((strm)->opaque, (items), (size))
|
||||||
#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
|
#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
|
||||||
#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
|
#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
|
||||||
|
|
||||||
|
/* Reverse the bytes in a 32-bit value */
|
||||||
|
#define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \
|
||||||
|
(((q) & 0xff00) << 8) + (((q) & 0xff) << 24))
|
||||||
|
|
||||||
#endif /* ZUTIL_H */
|
#endif /* ZUTIL_H */
|
|
@ -42,7 +42,7 @@
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="0"
|
Optimization="0"
|
||||||
AdditionalIncludeDirectories=""$(SolutionDir)\..\ExternalLibs\freetype2\include\freetype\config";"$(SolutionDir)\..\ExternalLibs\gl";"$(SolutionDir)\..\ExternalLibs\glpng\zlib";"$(SolutionDir)\..\ExternalLibs\glpng\png";"$(SolutionDir)\..\ExternalLibs\libogg-1.3.0\include";"$(SolutionDir)\..\ExternalLibs\libvorbis-1.3.3\include";"$(SolutionDir)\..\ExternalLibs\freetype2\include";"$(SolutionDir)\..\ExternalLibs\FTGL\include";"$(SolutionDir)\..\ExternalLibs\SDL2\include";"$(SolutionDir)\..\ExternalLibs\AL\include";"$(SolutionDir)\..\ExternalLibs\ttvfs";"$(SolutionDir)\..\ExternalLibs\ttvfs_cfileapi";"$(SolutionDir)\..\ExternalLibs\lvpa";"$(SolutionDir)\..\ExternalLibs\lvpa\include";"$(SolutionDir)\..\ExternalLibs""
|
AdditionalIncludeDirectories=""$(SolutionDir)\..\ExternalLibs\freetype2\include\freetype\config";"$(SolutionDir)\..\ExternalLibs\gl";"$(SolutionDir)\..\ExternalLibs\zlib";"$(SolutionDir)\..\ExternalLibs\png";"$(SolutionDir)\..\ExternalLibs\libogg-1.3.0\include";"$(SolutionDir)\..\ExternalLibs\libvorbis-1.3.3\include";"$(SolutionDir)\..\ExternalLibs\freetype2\include";"$(SolutionDir)\..\ExternalLibs\FTGL\include";"$(SolutionDir)\..\ExternalLibs\SDL2\include";"$(SolutionDir)\..\ExternalLibs\AL\include";"$(SolutionDir)\..\ExternalLibs\ttvfs";"$(SolutionDir)\..\ExternalLibs\ttvfs_cfileapi";"$(SolutionDir)\..\ExternalLibs\lvpa";"$(SolutionDir)\..\ExternalLibs\lvpa\include";"$(SolutionDir)\..\ExternalLibs""
|
||||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;GL_GLEXT_LEGACY=1;HAVE_PUTENV=1;FTGL_LIBRARY_STATIC;_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;BBGE_BUILD_WINDOWS=1;VFS_ENABLE_C_API=1;BBGE_USE_GLM=1;AQUARIA_INTERNAL_FTGL=1;BBGE_BUILD_SDL2"
|
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;GL_GLEXT_LEGACY=1;HAVE_PUTENV=1;FTGL_LIBRARY_STATIC;_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;BBGE_BUILD_WINDOWS=1;VFS_ENABLE_C_API=1;BBGE_USE_GLM=1;AQUARIA_INTERNAL_FTGL=1;BBGE_BUILD_SDL2"
|
||||||
MinimalRebuild="true"
|
MinimalRebuild="true"
|
||||||
BasicRuntimeChecks="0"
|
BasicRuntimeChecks="0"
|
||||||
|
@ -115,7 +115,7 @@
|
||||||
FavorSizeOrSpeed="1"
|
FavorSizeOrSpeed="1"
|
||||||
OmitFramePointers="true"
|
OmitFramePointers="true"
|
||||||
EnableFiberSafeOptimizations="true"
|
EnableFiberSafeOptimizations="true"
|
||||||
AdditionalIncludeDirectories=""$(SolutionDir)\..\ExternalLibs\freetype2\include\freetype\config";"$(SolutionDir)\..\ExternalLibs\gl";"$(SolutionDir)\..\ExternalLibs\glpng\zlib";"$(SolutionDir)\..\ExternalLibs\glpng\png";"$(SolutionDir)\..\ExternalLibs\libogg-1.3.0\include";"$(SolutionDir)\..\ExternalLibs\libvorbis-1.3.3\include";"$(SolutionDir)\..\ExternalLibs\freetype2\include";"$(SolutionDir)\..\ExternalLibs\FTGL\include";"$(SolutionDir)\..\ExternalLibs\SDL2\include";"$(SolutionDir)\..\ExternalLibs\AL\include";"$(SolutionDir)\..\ExternalLibs\ttvfs";"$(SolutionDir)\..\ExternalLibs\ttvfs_cfileapi";"$(SolutionDir)\..\ExternalLibs\lvpa";"$(SolutionDir)\..\ExternalLibs\lvpa\include";"$(SolutionDir)\..\ExternalLibs""
|
AdditionalIncludeDirectories=""$(SolutionDir)\..\ExternalLibs\freetype2\include\freetype\config";"$(SolutionDir)\..\ExternalLibs\gl";"$(SolutionDir)\..\ExternalLibs\zlib";"$(SolutionDir)\..\ExternalLibs\png";"$(SolutionDir)\..\ExternalLibs\libogg-1.3.0\include";"$(SolutionDir)\..\ExternalLibs\libvorbis-1.3.3\include";"$(SolutionDir)\..\ExternalLibs\freetype2\include";"$(SolutionDir)\..\ExternalLibs\FTGL\include";"$(SolutionDir)\..\ExternalLibs\SDL2\include";"$(SolutionDir)\..\ExternalLibs\AL\include";"$(SolutionDir)\..\ExternalLibs\ttvfs";"$(SolutionDir)\..\ExternalLibs\ttvfs_cfileapi";"$(SolutionDir)\..\ExternalLibs\lvpa";"$(SolutionDir)\..\ExternalLibs\lvpa\include";"$(SolutionDir)\..\ExternalLibs""
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;GL_GLEXT_LEGACY=1;HAVE_PUTENV=1;FTGL_LIBRARY_STATIC;_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;BBGE_BUILD_WINDOWS=1;_HAS_EXCEPTIONS=0;VFS_ENABLE_C_API=1;BBGE_USE_GLM=1;AQUARIA_INTERNAL_FTGL=1;BBGE_BUILD_SDL2"
|
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;GL_GLEXT_LEGACY=1;HAVE_PUTENV=1;FTGL_LIBRARY_STATIC;_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;BBGE_BUILD_WINDOWS=1;_HAS_EXCEPTIONS=0;VFS_ENABLE_C_API=1;BBGE_USE_GLM=1;AQUARIA_INTERNAL_FTGL=1;BBGE_BUILD_SDL2"
|
||||||
StringPooling="true"
|
StringPooling="true"
|
||||||
ExceptionHandling="0"
|
ExceptionHandling="0"
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="0"
|
Optimization="0"
|
||||||
AdditionalIncludeDirectories=""$(SolutionDir)\..\ExternalLibs\freetype2\include\freetype\config";"$(SolutionDir)\..\ExternalLibs\gl";"$(SolutionDir)\..\ExternalLibs\glpng\zlib";"$(SolutionDir)\..\ExternalLibs\glpng\png";"$(SolutionDir)\..\ExternalLibs\libogg-1.3.0\include";"$(SolutionDir)\..\ExternalLibs\libvorbis-1.3.3\include";"$(SolutionDir)\..\ExternalLibs\freetype2\include";"$(SolutionDir)\..\ExternalLibs\FTGL\include";"$(SolutionDir)\..\ExternalLibs\SDL2\include";"$(SolutionDir)\..\ExternalLibs\ttvfs";"$(SolutionDir)\..\ExternalLibs\ttvfs_cfileapi";"$(SolutionDir)\..\ExternalLibs\""
|
AdditionalIncludeDirectories=""$(SolutionDir)\..\ExternalLibs\freetype2\include\freetype\config";"$(SolutionDir)\..\ExternalLibs\gl";"$(SolutionDir)\..\ExternalLibs\zlib";"$(SolutionDir)\..\ExternalLibs\png";"$(SolutionDir)\..\ExternalLibs\libogg-1.3.0\include";"$(SolutionDir)\..\ExternalLibs\libvorbis-1.3.3\include";"$(SolutionDir)\..\ExternalLibs\freetype2\include";"$(SolutionDir)\..\ExternalLibs\FTGL\include";"$(SolutionDir)\..\ExternalLibs\SDL2\include";"$(SolutionDir)\..\ExternalLibs\ttvfs";"$(SolutionDir)\..\ExternalLibs\ttvfs_cfileapi";"$(SolutionDir)\..\ExternalLibs\""
|
||||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;HAVE_FCNTL_H;FT_CONFIG_OPTION_SYSTEM_ZLIB;FTGL_LIBRARY_STATIC;FT2_BUILD_LIBRARY;GL_GLEXT_LEGACY=1;HAVE_PUTENV=1;VFS_ENABLE_C_API=1"
|
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;HAVE_FCNTL_H;FT_CONFIG_OPTION_SYSTEM_ZLIB;FTGL_LIBRARY_STATIC;FT2_BUILD_LIBRARY;GL_GLEXT_LEGACY=1;HAVE_PUTENV=1;VFS_ENABLE_C_API=1"
|
||||||
MinimalRebuild="true"
|
MinimalRebuild="true"
|
||||||
BasicRuntimeChecks="0"
|
BasicRuntimeChecks="0"
|
||||||
|
@ -115,7 +115,7 @@
|
||||||
FavorSizeOrSpeed="1"
|
FavorSizeOrSpeed="1"
|
||||||
OmitFramePointers="true"
|
OmitFramePointers="true"
|
||||||
EnableFiberSafeOptimizations="true"
|
EnableFiberSafeOptimizations="true"
|
||||||
AdditionalIncludeDirectories=""$(SolutionDir)\..\ExternalLibs\freetype2\include\freetype\config";"$(SolutionDir)\..\ExternalLibs\gl";"$(SolutionDir)\..\ExternalLibs\glpng\zlib";"$(SolutionDir)\..\ExternalLibs\glpng\png";"$(SolutionDir)\..\ExternalLibs\libogg-1.3.0\include";"$(SolutionDir)\..\ExternalLibs\libvorbis-1.3.3\include";"$(SolutionDir)\..\ExternalLibs\freetype2\include";"$(SolutionDir)\..\ExternalLibs\FTGL\include";"$(SolutionDir)\..\ExternalLibs\SDL2\include";"$(SolutionDir)\..\ExternalLibs\ttvfs";"$(SolutionDir)\..\ExternalLibs\ttvfs_cfileapi";"$(SolutionDir)\..\ExternalLibs\""
|
AdditionalIncludeDirectories=""$(SolutionDir)\..\ExternalLibs\freetype2\include\freetype\config";"$(SolutionDir)\..\ExternalLibs\gl";"$(SolutionDir)\..\ExternalLibs\zlib";"$(SolutionDir)\..\ExternalLibs\png";"$(SolutionDir)\..\ExternalLibs\libogg-1.3.0\include";"$(SolutionDir)\..\ExternalLibs\libvorbis-1.3.3\include";"$(SolutionDir)\..\ExternalLibs\freetype2\include";"$(SolutionDir)\..\ExternalLibs\FTGL\include";"$(SolutionDir)\..\ExternalLibs\SDL2\include";"$(SolutionDir)\..\ExternalLibs\ttvfs";"$(SolutionDir)\..\ExternalLibs\ttvfs_cfileapi";"$(SolutionDir)\..\ExternalLibs\""
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;HAVE_FCNTL_H;FT_CONFIG_OPTION_SYSTEM_ZLIB;FTGL_LIBRARY_STATIC;FT2_BUILD_LIBRARY;GL_GLEXT_LEGACY=1;TIXML_USE_STL=1;HAVE_PUTENV=1;_HAS_EXCEPTIONS=0;VFS_ENABLE_C_API=1"
|
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;HAVE_FCNTL_H;FT_CONFIG_OPTION_SYSTEM_ZLIB;FTGL_LIBRARY_STATIC;FT2_BUILD_LIBRARY;GL_GLEXT_LEGACY=1;TIXML_USE_STL=1;HAVE_PUTENV=1;_HAS_EXCEPTIONS=0;VFS_ENABLE_C_API=1"
|
||||||
StringPooling="true"
|
StringPooling="true"
|
||||||
ExceptionHandling="0"
|
ExceptionHandling="0"
|
||||||
|
@ -200,170 +200,6 @@
|
||||||
RelativePath="..\..\ExternalLibs\glpng.h"
|
RelativePath="..\..\ExternalLibs\glpng.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<Filter
|
|
||||||
Name="png"
|
|
||||||
>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\ExternalLibs\glpng\png\png.c"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\ExternalLibs\glpng\png\png.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\ExternalLibs\glpng\png\pngconf.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\ExternalLibs\glpng\png\pngdebug.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\ExternalLibs\glpng\png\pngerror.c"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\ExternalLibs\glpng\png\pngget.c"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\ExternalLibs\glpng\png\pnginfo.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\ExternalLibs\glpng\png\pnglibconf.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\ExternalLibs\glpng\png\pngmem.c"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\ExternalLibs\glpng\png\pngpread.c"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\ExternalLibs\glpng\png\pngpriv.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\ExternalLibs\glpng\png\pngread.c"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\ExternalLibs\glpng\png\pngrio.c"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\ExternalLibs\glpng\png\pngrtran.c"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\ExternalLibs\glpng\png\pngrutil.c"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\ExternalLibs\glpng\png\pngset.c"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\ExternalLibs\glpng\png\pngstruct.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\ExternalLibs\glpng\png\pngtrans.c"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
</Filter>
|
|
||||||
<Filter
|
|
||||||
Name="zlib"
|
|
||||||
>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\ExternalLibs\glpng\zlib\adler32.c"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\ExternalLibs\glpng\zlib\compress.c"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\ExternalLibs\glpng\zlib\crc32.c"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\ExternalLibs\glpng\zlib\crc32.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\ExternalLibs\glpng\zlib\deflate.c"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\ExternalLibs\glpng\zlib\deflate.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\ExternalLibs\glpng\zlib\infback.c"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\ExternalLibs\glpng\zlib\inffast.c"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\ExternalLibs\glpng\zlib\inffast.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\ExternalLibs\glpng\zlib\inffixed.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\ExternalLibs\glpng\zlib\inflate.c"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\ExternalLibs\glpng\zlib\inflate.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\ExternalLibs\glpng\zlib\inftrees.c"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\ExternalLibs\glpng\zlib\inftrees.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\ExternalLibs\glpng\zlib\trees.c"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\ExternalLibs\glpng\zlib\trees.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\ExternalLibs\glpng\zlib\uncompr.c"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\ExternalLibs\glpng\zlib\zconf.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\ExternalLibs\glpng\zlib\zlib.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\ExternalLibs\glpng\zlib\zutil.c"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\ExternalLibs\glpng\zlib\zutil.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
</Filter>
|
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="FTGL"
|
Name="FTGL"
|
||||||
|
@ -1225,6 +1061,186 @@
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="png"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\ExternalLibs\png\png.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\ExternalLibs\png\png.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\ExternalLibs\png\pngconf.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\ExternalLibs\png\pngdebug.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\ExternalLibs\png\pngerror.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\ExternalLibs\png\pngget.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\ExternalLibs\png\pnginfo.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\ExternalLibs\png\pngmem.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\ExternalLibs\png\pngpread.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\ExternalLibs\png\pngpriv.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\ExternalLibs\png\pngread.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\ExternalLibs\png\pngrio.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\ExternalLibs\png\pngrtran.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\ExternalLibs\png\pngrutil.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\ExternalLibs\png\pngset.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\ExternalLibs\png\pngstruct.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\ExternalLibs\png\pngtest.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\ExternalLibs\png\pngtrans.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\ExternalLibs\png\pngwio.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\ExternalLibs\png\pngwrite.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\ExternalLibs\png\pngwtran.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\ExternalLibs\png\pngwutil.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="zlib"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\ExternalLibs\zlib\adler32.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\ExternalLibs\zlib\compress.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\ExternalLibs\zlib\crc32.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\ExternalLibs\zlib\crc32.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\ExternalLibs\zlib\deflate.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\ExternalLibs\zlib\deflate.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\ExternalLibs\zlib\infback.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\ExternalLibs\zlib\inffast.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\ExternalLibs\zlib\inffast.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\ExternalLibs\zlib\inffixed.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\ExternalLibs\zlib\inflate.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\ExternalLibs\zlib\inflate.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\ExternalLibs\zlib\inftrees.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\ExternalLibs\zlib\inftrees.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\ExternalLibs\zlib\trees.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\ExternalLibs\zlib\trees.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\ExternalLibs\zlib\uncompr.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\ExternalLibs\zlib\zconf.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\ExternalLibs\zlib\zlib.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\ExternalLibs\zlib\zutil.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\ExternalLibs\zlib\zutil.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Header Files"
|
Name="Header Files"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue