Merge branch 'master' into UpdatePugiXml
commit
7ae88225b3
|
@ -479,6 +479,11 @@ void Parser::ParseLV1MaterialListBlock() {
|
||||||
if (TokenMatch(filePtr, "MATERIAL_COUNT", 14)) {
|
if (TokenMatch(filePtr, "MATERIAL_COUNT", 14)) {
|
||||||
ParseLV4MeshLong(iMaterialCount);
|
ParseLV4MeshLong(iMaterialCount);
|
||||||
|
|
||||||
|
if (UINT_MAX - iOldMaterialCount < iMaterialCount) {
|
||||||
|
LogWarning("Out of range: material index is too large");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// now allocate enough storage to hold all materials
|
// now allocate enough storage to hold all materials
|
||||||
m_vMaterials.resize(iOldMaterialCount + iMaterialCount, Material("INVALID"));
|
m_vMaterials.resize(iOldMaterialCount + iMaterialCount, Material("INVALID"));
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -632,18 +632,17 @@ void LWSImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
|
||||||
nodes.push_back(d);
|
nodes.push_back(d);
|
||||||
}
|
}
|
||||||
ASSIMP_LOG_ERROR("LWS: Unexpected keyword: \'Channel\'");
|
ASSIMP_LOG_ERROR("LWS: Unexpected keyword: \'Channel\'");
|
||||||
|
} else {
|
||||||
|
// important: index of channel
|
||||||
|
nodes.back().channels.emplace_back();
|
||||||
|
LWO::Envelope &env = nodes.back().channels.back();
|
||||||
|
|
||||||
|
env.index = strtoul10(c);
|
||||||
|
|
||||||
|
// currently we can just interpret the standard channels 0...9
|
||||||
|
// (hack) assume that index-i yields the binary channel type from LWO
|
||||||
|
env.type = (LWO::EnvelopeType)(env.index + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// important: index of channel
|
|
||||||
nodes.back().channels.emplace_back();
|
|
||||||
LWO::Envelope &env = nodes.back().channels.back();
|
|
||||||
|
|
||||||
env.index = strtoul10(c);
|
|
||||||
|
|
||||||
// currently we can just interpret the standard channels 0...9
|
|
||||||
// (hack) assume that index-i yields the binary channel type from LWO
|
|
||||||
env.type = (LWO::EnvelopeType)(env.index + 1);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
// 'Envelope': a single animation channel
|
// 'Envelope': a single animation channel
|
||||||
else if ((*it).tokens[0] == "Envelope") {
|
else if ((*it).tokens[0] == "Envelope") {
|
||||||
|
|
|
@ -138,18 +138,31 @@ bool MD5Parser::ParseSection(Section &out) {
|
||||||
char *sz = buffer;
|
char *sz = buffer;
|
||||||
while (!IsSpaceOrNewLine(*buffer)) {
|
while (!IsSpaceOrNewLine(*buffer)) {
|
||||||
++buffer;
|
++buffer;
|
||||||
|
if (buffer == bufferEnd)
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
out.mName = std::string(sz, (uintptr_t)(buffer - sz));
|
out.mName = std::string(sz, (uintptr_t)(buffer - sz));
|
||||||
SkipSpaces();
|
while (IsSpace(*buffer)) {
|
||||||
|
++buffer;
|
||||||
|
if (buffer == bufferEnd)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool running = true;
|
bool running = true;
|
||||||
while (running) {
|
while (running) {
|
||||||
if ('{' == *buffer) {
|
if ('{' == *buffer) {
|
||||||
// it is a normal section so read all lines
|
// it is a normal section so read all lines
|
||||||
++buffer;
|
++buffer;
|
||||||
|
if (buffer == bufferEnd)
|
||||||
|
return false;
|
||||||
bool run = true;
|
bool run = true;
|
||||||
while (run) {
|
while (run) {
|
||||||
if (!SkipSpacesAndLineEnd()) {
|
while (IsSpaceOrNewLine(*buffer)) {
|
||||||
|
++buffer;
|
||||||
|
if (buffer == bufferEnd)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if ('\0' == *buffer) {
|
||||||
return false; // seems this was the last section
|
return false; // seems this was the last section
|
||||||
}
|
}
|
||||||
if ('}' == *buffer) {
|
if ('}' == *buffer) {
|
||||||
|
@ -164,25 +177,39 @@ bool MD5Parser::ParseSection(Section &out) {
|
||||||
elem.szStart = buffer;
|
elem.szStart = buffer;
|
||||||
|
|
||||||
// terminate the line with zero
|
// terminate the line with zero
|
||||||
while (!IsLineEnd(*buffer))
|
while (!IsLineEnd(*buffer)) {
|
||||||
++buffer;
|
++buffer;
|
||||||
|
if (buffer == bufferEnd)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (*buffer) {
|
if (*buffer) {
|
||||||
++lineNumber;
|
++lineNumber;
|
||||||
*buffer++ = '\0';
|
*buffer++ = '\0';
|
||||||
|
if (buffer == bufferEnd)
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
} else if (!IsSpaceOrNewLine(*buffer)) {
|
} else if (!IsSpaceOrNewLine(*buffer)) {
|
||||||
// it is an element at global scope. Parse its value and go on
|
// it is an element at global scope. Parse its value and go on
|
||||||
sz = buffer;
|
sz = buffer;
|
||||||
while (!IsSpaceOrNewLine(*buffer++))
|
while (!IsSpaceOrNewLine(*buffer++)) {
|
||||||
;
|
if (buffer == bufferEnd)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
out.mGlobalValue = std::string(sz, (uintptr_t)(buffer - sz));
|
out.mGlobalValue = std::string(sz, (uintptr_t)(buffer - sz));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return SkipSpacesAndLineEnd();
|
if (buffer == bufferEnd)
|
||||||
|
return false;
|
||||||
|
while (IsSpaceOrNewLine(*buffer)) {
|
||||||
|
++buffer;
|
||||||
|
if (buffer == bufferEnd)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return '\0' != *buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -481,6 +481,8 @@ void MDLImporter::ParseSkinLump_3DGS_MDL7(
|
||||||
pcNew->achFormatHint[2] = 's';
|
pcNew->achFormatHint[2] = 's';
|
||||||
pcNew->achFormatHint[3] = '\0';
|
pcNew->achFormatHint[3] = '\0';
|
||||||
|
|
||||||
|
SizeCheck(szCurrent + pcNew->mWidth);
|
||||||
|
|
||||||
pcNew->pcData = (aiTexel *)new unsigned char[pcNew->mWidth];
|
pcNew->pcData = (aiTexel *)new unsigned char[pcNew->mWidth];
|
||||||
memcpy(pcNew->pcData, szCurrent, pcNew->mWidth);
|
memcpy(pcNew->pcData, szCurrent, pcNew->mWidth);
|
||||||
szCurrent += iWidth;
|
szCurrent += iWidth;
|
||||||
|
@ -493,12 +495,12 @@ void MDLImporter::ParseSkinLump_3DGS_MDL7(
|
||||||
|
|
||||||
aiString szFile;
|
aiString szFile;
|
||||||
const size_t iLen = strlen((const char *)szCurrent);
|
const size_t iLen = strlen((const char *)szCurrent);
|
||||||
size_t iLen2 = iLen + 1;
|
size_t iLen2 = iLen > (MAXLEN - 1) ? (MAXLEN - 1) : iLen;
|
||||||
iLen2 = iLen2 > MAXLEN ? MAXLEN : iLen2;
|
|
||||||
memcpy(szFile.data, (const char *)szCurrent, iLen2);
|
memcpy(szFile.data, (const char *)szCurrent, iLen2);
|
||||||
|
szFile.data[iLen2] = '\0';
|
||||||
szFile.length = static_cast<ai_uint32>(iLen2);
|
szFile.length = static_cast<ai_uint32>(iLen2);
|
||||||
|
|
||||||
szCurrent += iLen2;
|
szCurrent += iLen2 + 1;
|
||||||
|
|
||||||
// place this as diffuse texture
|
// place this as diffuse texture
|
||||||
pcMatOut->AddProperty(&szFile, AI_MATKEY_TEXTURE_DIFFUSE(0));
|
pcMatOut->AddProperty(&szFile, AI_MATKEY_TEXTURE_DIFFUSE(0));
|
||||||
|
|
|
@ -239,8 +239,6 @@ struct Mesh {
|
||||||
unsigned int m_uiMaterialIndex;
|
unsigned int m_uiMaterialIndex;
|
||||||
/// True, if normals are stored.
|
/// True, if normals are stored.
|
||||||
bool m_hasNormals;
|
bool m_hasNormals;
|
||||||
/// True, if vertex colors are stored.
|
|
||||||
bool m_hasVertexColors;
|
|
||||||
|
|
||||||
/// Constructor
|
/// Constructor
|
||||||
explicit Mesh(const std::string &name) :
|
explicit Mesh(const std::string &name) :
|
||||||
|
|
|
@ -252,9 +252,9 @@ void ObjFileMtlImporter::load() {
|
||||||
case 'a': // Anisotropy
|
case 'a': // Anisotropy
|
||||||
{
|
{
|
||||||
++m_DataIt;
|
++m_DataIt;
|
||||||
getFloatValue(m_pModel->mCurrentMaterial->anisotropy);
|
|
||||||
if (m_pModel->mCurrentMaterial != nullptr)
|
if (m_pModel->mCurrentMaterial != nullptr)
|
||||||
m_DataIt = skipLine<DataArrayIt>(m_DataIt, m_DataItEnd, m_uiLine);
|
getFloatValue(m_pModel->mCurrentMaterial->anisotropy);
|
||||||
|
m_DataIt = skipLine<DataArrayIt>(m_DataIt, m_DataItEnd, m_uiLine);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
|
@ -371,6 +371,7 @@ void ObjFileMtlImporter::getTexture() {
|
||||||
if (m_pModel->mCurrentMaterial == nullptr) {
|
if (m_pModel->mCurrentMaterial == nullptr) {
|
||||||
m_pModel->mCurrentMaterial = new ObjFile::Material();
|
m_pModel->mCurrentMaterial = new ObjFile::Material();
|
||||||
m_pModel->mCurrentMaterial->MaterialName.Set("Empty_Material");
|
m_pModel->mCurrentMaterial->MaterialName.Set("Empty_Material");
|
||||||
|
m_pModel->mMaterialMap["Empty_Material"] = m_pModel->mCurrentMaterial;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *pPtr(&(*m_DataIt));
|
const char *pPtr(&(*m_DataIt));
|
||||||
|
|
|
@ -156,9 +156,17 @@ void ObjFileParser::parseFile(IOStreamBuffer<char> &streamBuffer) {
|
||||||
// read in vertex definition (homogeneous coords)
|
// read in vertex definition (homogeneous coords)
|
||||||
getHomogeneousVector3(m_pModel->mVertices);
|
getHomogeneousVector3(m_pModel->mVertices);
|
||||||
} else if (numComponents == 6) {
|
} else if (numComponents == 6) {
|
||||||
|
// fill previous omitted vertex-colors by default
|
||||||
|
if (m_pModel->mVertexColors.size() < m_pModel->mVertices.size()) {
|
||||||
|
m_pModel->mVertexColors.resize(m_pModel->mVertices.size(), aiVector3D(0, 0, 0));
|
||||||
|
}
|
||||||
// read vertex and vertex-color
|
// read vertex and vertex-color
|
||||||
getTwoVectors3(m_pModel->mVertices, m_pModel->mVertexColors);
|
getTwoVectors3(m_pModel->mVertices, m_pModel->mVertexColors);
|
||||||
}
|
}
|
||||||
|
// append omitted vertex-colors as default for the end if any vertex-color exists
|
||||||
|
if (!m_pModel->mVertexColors.empty() && m_pModel->mVertexColors.size() < m_pModel->mVertices.size()) {
|
||||||
|
m_pModel->mVertexColors.resize(m_pModel->mVertices.size(), aiVector3D(0, 0, 0));
|
||||||
|
}
|
||||||
} else if (*m_DataIt == 't') {
|
} else if (*m_DataIt == 't') {
|
||||||
// read in texture coordinate ( 2D or 3D )
|
// read in texture coordinate ( 2D or 3D )
|
||||||
++m_DataIt;
|
++m_DataIt;
|
||||||
|
@ -456,8 +464,19 @@ void ObjFileParser::getFace(aiPrimitiveType type) {
|
||||||
iPos = 0;
|
iPos = 0;
|
||||||
} else {
|
} else {
|
||||||
//OBJ USES 1 Base ARRAYS!!!!
|
//OBJ USES 1 Base ARRAYS!!!!
|
||||||
const char *token = &(*m_DataIt);
|
int iVal;
|
||||||
const int iVal = ::atoi(token);
|
auto end = m_DataIt;
|
||||||
|
// find either the buffer end or the '\0'
|
||||||
|
while (end < m_DataItEnd && *end != '\0')
|
||||||
|
++end;
|
||||||
|
// avoid temporary string allocation if there is a zero
|
||||||
|
if (end != m_DataItEnd) {
|
||||||
|
iVal = ::atoi(&(*m_DataIt));
|
||||||
|
} else {
|
||||||
|
// otherwise make a zero terminated copy, which is safe to pass to atoi
|
||||||
|
std::string number(&(*m_DataIt), m_DataItEnd - m_DataIt);
|
||||||
|
iVal = ::atoi(number.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
// increment iStep position based off of the sign and # of digits
|
// increment iStep position based off of the sign and # of digits
|
||||||
int tmp = iVal;
|
int tmp = iVal;
|
||||||
|
|
|
@ -965,7 +965,6 @@ IF(ASSIMP_HUNTER_ENABLED)
|
||||||
find_package(minizip CONFIG REQUIRED)
|
find_package(minizip CONFIG REQUIRED)
|
||||||
ELSE()
|
ELSE()
|
||||||
SET( unzip_SRCS
|
SET( unzip_SRCS
|
||||||
../contrib/unzip/crypt.c
|
|
||||||
../contrib/unzip/crypt.h
|
../contrib/unzip/crypt.h
|
||||||
../contrib/unzip/ioapi.c
|
../contrib/unzip/ioapi.c
|
||||||
../contrib/unzip/ioapi.h
|
../contrib/unzip/ioapi.h
|
||||||
|
|
|
@ -297,7 +297,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
const char separator = getOsSeparator();
|
const char separator = getOsSeparator();
|
||||||
for (it = in.begin(); it != in.end(); ++it) {
|
for (it = in.begin(); it < in.end(); ++it) {
|
||||||
const size_t remaining = std::distance(in.end(), it);
|
const size_t remaining = std::distance(in.end(), it);
|
||||||
// Exclude :// and \\, which remain untouched.
|
// Exclude :// and \\, which remain untouched.
|
||||||
// https://sourceforge.net/tracker/?func=detail&aid=3031725&group_id=226462&atid=1067632
|
// https://sourceforge.net/tracker/?func=detail&aid=3031725&group_id=226462&atid=1067632
|
||||||
|
|
|
@ -51,6 +51,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <assimp/material.h>
|
#include <assimp/material.h>
|
||||||
#include <assimp/types.h>
|
#include <assimp/types.h>
|
||||||
#include <assimp/DefaultLogger.hpp>
|
#include <assimp/DefaultLogger.hpp>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
|
@ -473,7 +474,7 @@ aiReturn aiMaterial::AddBinaryProperty(const void *pInput,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allocate a new material property
|
// Allocate a new material property
|
||||||
aiMaterialProperty *pcNew = new aiMaterialProperty();
|
std::unique_ptr<aiMaterialProperty> pcNew(new aiMaterialProperty());
|
||||||
|
|
||||||
// .. and fill it
|
// .. and fill it
|
||||||
pcNew->mType = pType;
|
pcNew->mType = pType;
|
||||||
|
@ -489,7 +490,7 @@ aiReturn aiMaterial::AddBinaryProperty(const void *pInput,
|
||||||
strcpy(pcNew->mKey.data, pKey);
|
strcpy(pcNew->mKey.data, pKey);
|
||||||
|
|
||||||
if (UINT_MAX != iOutIndex) {
|
if (UINT_MAX != iOutIndex) {
|
||||||
mProperties[iOutIndex] = pcNew;
|
mProperties[iOutIndex] = pcNew.release();
|
||||||
return AI_SUCCESS;
|
return AI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -502,7 +503,6 @@ aiReturn aiMaterial::AddBinaryProperty(const void *pInput,
|
||||||
try {
|
try {
|
||||||
ppTemp = new aiMaterialProperty *[mNumAllocated];
|
ppTemp = new aiMaterialProperty *[mNumAllocated];
|
||||||
} catch (std::bad_alloc &) {
|
} catch (std::bad_alloc &) {
|
||||||
delete pcNew;
|
|
||||||
return AI_OUTOFMEMORY;
|
return AI_OUTOFMEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -513,7 +513,7 @@ aiReturn aiMaterial::AddBinaryProperty(const void *pInput,
|
||||||
mProperties = ppTemp;
|
mProperties = ppTemp;
|
||||||
}
|
}
|
||||||
// push back ...
|
// push back ...
|
||||||
mProperties[mNumProperties++] = pcNew;
|
mProperties[mNumProperties++] = pcNew.release();
|
||||||
|
|
||||||
return AI_SUCCESS;
|
return AI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,6 +82,9 @@ void UpdateMeshReferences(aiNode *node, const std::vector<unsigned int> &meshMap
|
||||||
for (unsigned int a = 0; a < node->mNumMeshes; ++a) {
|
for (unsigned int a = 0; a < node->mNumMeshes; ++a) {
|
||||||
|
|
||||||
unsigned int ref = node->mMeshes[a];
|
unsigned int ref = node->mMeshes[a];
|
||||||
|
if (ref >= meshMapping.size())
|
||||||
|
throw DeadlyImportError("Invalid mesh ref");
|
||||||
|
|
||||||
if (UINT_MAX != (ref = meshMapping[ref])) {
|
if (UINT_MAX != (ref = meshMapping[ref])) {
|
||||||
node->mMeshes[out++] = ref;
|
node->mMeshes[out++] = ref;
|
||||||
}
|
}
|
||||||
|
@ -143,7 +146,13 @@ void FindInvalidDataProcess::Execute(aiScene *pScene) {
|
||||||
// we need to remove some meshes.
|
// we need to remove some meshes.
|
||||||
// therefore we'll also need to remove all references
|
// therefore we'll also need to remove all references
|
||||||
// to them from the scenegraph
|
// to them from the scenegraph
|
||||||
UpdateMeshReferences(pScene->mRootNode, meshMapping);
|
try {
|
||||||
|
UpdateMeshReferences(pScene->mRootNode, meshMapping);
|
||||||
|
} catch (const std::exception&) {
|
||||||
|
// fix the real number of meshes otherwise we'll get double free in the scene destructor
|
||||||
|
pScene->mNumMeshes = real;
|
||||||
|
throw;
|
||||||
|
}
|
||||||
pScene->mNumMeshes = real;
|
pScene->mNumMeshes = real;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,172 +0,0 @@
|
||||||
/* crypt.c -- base code for traditional PKWARE encryption
|
|
||||||
Version 1.01e, February 12th, 2005
|
|
||||||
|
|
||||||
Copyright (C) 1998-2005 Gilles Vollant
|
|
||||||
Modifications for Info-ZIP crypting
|
|
||||||
Copyright (C) 2003 Terry Thorsen
|
|
||||||
|
|
||||||
This code is a modified version of crypting code in Info-ZIP distribution
|
|
||||||
|
|
||||||
Copyright (C) 1990-2000 Info-ZIP. All rights reserved.
|
|
||||||
|
|
||||||
This program is distributed under the terms of the same license as zlib.
|
|
||||||
See the accompanying LICENSE file for the full text of the license.
|
|
||||||
|
|
||||||
This encryption code is a direct transcription of the algorithm from
|
|
||||||
Roger Schlafly, described by Phil Katz in the file appnote.txt. This
|
|
||||||
file (appnote.txt) is distributed with the PKZIP program (even in the
|
|
||||||
version without encryption capabilities).
|
|
||||||
|
|
||||||
If you don't need crypting in your application, just define symbols
|
|
||||||
NOCRYPT and NOUNCRYPT.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
|
|
||||||
#define MICROSOFT_WINDOWS_WINBASE_H_DEFINE_INTERLOCKED_CPLUSPLUS_OVERLOADS 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
# include <windows.h>
|
|
||||||
# include <wincrypt.h>
|
|
||||||
#else
|
|
||||||
# include <sys/stat.h>
|
|
||||||
# include <fcntl.h>
|
|
||||||
# include <unistd.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "zlib.h"
|
|
||||||
|
|
||||||
#include "crypt.h"
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
# pragma warning(push)
|
|
||||||
# pragma warning(disable : 4244)
|
|
||||||
#endif // _MSC_VER
|
|
||||||
|
|
||||||
/***************************************************************************/
|
|
||||||
|
|
||||||
#define CRC32(c, b) ((*(pcrc_32_tab+(((uint32_t)(c) ^ (b)) & 0xff))) ^ ((c) >> 8))
|
|
||||||
|
|
||||||
#ifndef ZCR_SEED2
|
|
||||||
# define ZCR_SEED2 3141592654UL /* use PI as default pattern */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/***************************************************************************/
|
|
||||||
|
|
||||||
uint8_t decrypt_byte(uint32_t *pkeys)
|
|
||||||
{
|
|
||||||
unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an
|
|
||||||
* unpredictable manner on 16-bit systems; not a problem
|
|
||||||
* with any known compiler so far, though */
|
|
||||||
|
|
||||||
temp = ((uint32_t)(*(pkeys+2)) & 0xffff) | 2;
|
|
||||||
return (uint8_t)(((temp * (temp ^ 1)) >> 8) & 0xff);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t update_keys(uint32_t *pkeys, const z_crc_t *pcrc_32_tab, int32_t c)
|
|
||||||
{
|
|
||||||
(*(pkeys+0)) = (uint32_t)CRC32((*(pkeys+0)), c);
|
|
||||||
(*(pkeys+1)) += (*(pkeys+0)) & 0xff;
|
|
||||||
(*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1;
|
|
||||||
{
|
|
||||||
register int32_t keyshift = (int32_t)((*(pkeys + 1)) >> 24);
|
|
||||||
(*(pkeys+2)) = (uint32_t)CRC32((*(pkeys+2)), keyshift);
|
|
||||||
}
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
void init_keys(const char *passwd, uint32_t *pkeys, const z_crc_t *pcrc_32_tab)
|
|
||||||
{
|
|
||||||
*(pkeys+0) = 305419896L;
|
|
||||||
*(pkeys+1) = 591751049L;
|
|
||||||
*(pkeys+2) = 878082192L;
|
|
||||||
while (*passwd != 0)
|
|
||||||
{
|
|
||||||
update_keys(pkeys, pcrc_32_tab, *passwd);
|
|
||||||
passwd += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/***************************************************************************/
|
|
||||||
|
|
||||||
int cryptrand(unsigned char *buf, unsigned int len)
|
|
||||||
{
|
|
||||||
static unsigned calls = 0;
|
|
||||||
int rlen = 0;
|
|
||||||
#ifdef _WIN32
|
|
||||||
HCRYPTPROV provider;
|
|
||||||
unsigned __int64 pentium_tsc[1];
|
|
||||||
int result = 0;
|
|
||||||
|
|
||||||
#if defined(WINAPI_FAMILY) && WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP
|
|
||||||
if (CryptAcquireContext(&provider, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT | CRYPT_SILENT))
|
|
||||||
{
|
|
||||||
result = CryptGenRandom(provider, len, buf);
|
|
||||||
CryptReleaseContext(provider, 0);
|
|
||||||
if (result)
|
|
||||||
return len;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (rlen = 0; rlen < (int)len; ++rlen)
|
|
||||||
{
|
|
||||||
if (rlen % 8 == 0)
|
|
||||||
QueryPerformanceCounter((LARGE_INTEGER *)pentium_tsc);
|
|
||||||
buf[rlen] = ((unsigned char*)pentium_tsc)[rlen % 8];
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
int frand = open("/dev/urandom", O_RDONLY);
|
|
||||||
if (frand != -1)
|
|
||||||
{
|
|
||||||
rlen = (int)read(frand, buf, len);
|
|
||||||
close(frand);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if (rlen < (int)len)
|
|
||||||
{
|
|
||||||
/* Ensure different random header each time */
|
|
||||||
if (++calls == 1)
|
|
||||||
srand((unsigned)(time(NULL) ^ ZCR_SEED2));
|
|
||||||
|
|
||||||
while (rlen < (int)len)
|
|
||||||
buf[rlen++] = (rand() >> 7) & 0xff;
|
|
||||||
}
|
|
||||||
return rlen;
|
|
||||||
}
|
|
||||||
|
|
||||||
int crypthead(const char *passwd, uint8_t *buf, int buf_size, uint32_t *pkeys,
|
|
||||||
const z_crc_t *pcrc_32_tab, uint8_t verify1, uint8_t verify2)
|
|
||||||
{
|
|
||||||
uint8_t n = 0; /* index in random header */
|
|
||||||
uint8_t header[RAND_HEAD_LEN-2]; /* random header */
|
|
||||||
uint16_t t = 0; /* temporary */
|
|
||||||
|
|
||||||
if (buf_size < RAND_HEAD_LEN)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
init_keys(passwd, pkeys, pcrc_32_tab);
|
|
||||||
|
|
||||||
/* First generate RAND_HEAD_LEN-2 random bytes. */
|
|
||||||
cryptrand(header, RAND_HEAD_LEN-2);
|
|
||||||
|
|
||||||
/* Encrypt random header (last two bytes is high word of crc) */
|
|
||||||
init_keys(passwd, pkeys, pcrc_32_tab);
|
|
||||||
|
|
||||||
for (n = 0; n < RAND_HEAD_LEN-2; n++)
|
|
||||||
buf[n] = (uint8_t)zencode(pkeys, pcrc_32_tab, header[n], t);
|
|
||||||
|
|
||||||
buf[n++] = (uint8_t)zencode(pkeys, pcrc_32_tab, verify1, t);
|
|
||||||
buf[n++] = (uint8_t)zencode(pkeys, pcrc_32_tab, verify2, t);
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
# pragma warning(pop)
|
|
||||||
#endif // _MSC_VER
|
|
||||||
|
|
||||||
/***************************************************************************/
|
|
|
@ -1,63 +1,132 @@
|
||||||
/* crypt.h -- base code for traditional PKWARE encryption
|
/* crypt.h -- base code for crypt/uncrypt ZIPfile
|
||||||
|
|
||||||
|
|
||||||
Version 1.01e, February 12th, 2005
|
Version 1.01e, February 12th, 2005
|
||||||
|
|
||||||
Copyright (C) 1998-2005 Gilles Vollant
|
Copyright (C) 1998-2005 Gilles Vollant
|
||||||
Modifications for Info-ZIP crypting
|
|
||||||
Copyright (C) 2003 Terry Thorsen
|
|
||||||
|
|
||||||
This code is a modified version of crypting code in Info-ZIP distribution
|
This code is a modified version of crypting code in Infozip distribution
|
||||||
|
|
||||||
Copyright (C) 1990-2000 Info-ZIP. All rights reserved.
|
The encryption/decryption parts of this source code (as opposed to the
|
||||||
|
non-echoing password parts) were originally written in Europe. The
|
||||||
|
whole source package can be freely distributed, including from the USA.
|
||||||
|
(Prior to January 2000, re-export from the US was a violation of US law.)
|
||||||
|
|
||||||
This program is distributed under the terms of the same license as zlib.
|
This encryption code is a direct transcription of the algorithm from
|
||||||
See the accompanying LICENSE file for the full text of the license.
|
Roger Schlafly, described by Phil Katz in the file appnote.txt. This
|
||||||
|
file (appnote.txt) is distributed with the PKZIP program (even in the
|
||||||
|
version without encryption capabilities).
|
||||||
|
|
||||||
|
If you don't need crypting in your application, just define symbols
|
||||||
|
NOCRYPT and NOUNCRYPT.
|
||||||
|
|
||||||
|
This code support the "Traditional PKWARE Encryption".
|
||||||
|
|
||||||
|
The new AES encryption added on Zip format by Winzip (see the page
|
||||||
|
http://www.winzip.com/aes_info.htm ) and PKWare PKZip 5.x Strong
|
||||||
|
Encryption is not supported.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _MINICRYPT_H
|
#define CRC32(c, b) ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8))
|
||||||
#define _MINICRYPT_H
|
|
||||||
|
|
||||||
#if ZLIB_VERNUM < 0x1270
|
/***********************************************************************
|
||||||
#if !defined(Z_U4)
|
* Return the next byte in the pseudo-random sequence
|
||||||
typedef unsigned long z_crc_t;
|
*/
|
||||||
#endif
|
static int decrypt_byte(unsigned long* pkeys, const z_crc_t* pcrc_32_tab)
|
||||||
#endif
|
{
|
||||||
|
unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an
|
||||||
|
* unpredictable manner on 16-bit systems; not a problem
|
||||||
|
* with any known compiler so far, though */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
(void)pcrc_32_tab;
|
||||||
extern "C" {
|
temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2;
|
||||||
#endif
|
return (int)(((temp * (temp ^ 1)) >> 8) & 0xff);
|
||||||
|
}
|
||||||
|
|
||||||
#define RAND_HEAD_LEN 12
|
/***********************************************************************
|
||||||
|
* Update the encryption keys with the next byte of plain text
|
||||||
|
*/
|
||||||
|
static int update_keys(unsigned long* pkeys,const z_crc_t* pcrc_32_tab,int c)
|
||||||
|
{
|
||||||
|
(*(pkeys+0)) = CRC32((*(pkeys+0)), c);
|
||||||
|
(*(pkeys+1)) += (*(pkeys+0)) & 0xff;
|
||||||
|
(*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1;
|
||||||
|
{
|
||||||
|
register int keyshift = (int)((*(pkeys+1)) >> 24);
|
||||||
|
(*(pkeys+2)) = CRC32((*(pkeys+2)), keyshift);
|
||||||
|
}
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
/***************************************************************************/
|
|
||||||
|
/***********************************************************************
|
||||||
|
* Initialize the encryption keys and the random header according to
|
||||||
|
* the given password.
|
||||||
|
*/
|
||||||
|
static void init_keys(const char* passwd,unsigned long* pkeys,const z_crc_t* pcrc_32_tab)
|
||||||
|
{
|
||||||
|
*(pkeys+0) = 305419896L;
|
||||||
|
*(pkeys+1) = 591751049L;
|
||||||
|
*(pkeys+2) = 878082192L;
|
||||||
|
while (*passwd != '\0') {
|
||||||
|
update_keys(pkeys,pcrc_32_tab,(int)*passwd);
|
||||||
|
passwd++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#define zdecode(pkeys,pcrc_32_tab,c) \
|
#define zdecode(pkeys,pcrc_32_tab,c) \
|
||||||
(update_keys(pkeys,pcrc_32_tab, c ^= decrypt_byte(pkeys)))
|
(update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab)))
|
||||||
|
|
||||||
#define zencode(pkeys,pcrc_32_tab,c,t) \
|
#define zencode(pkeys,pcrc_32_tab,c,t) \
|
||||||
(t = decrypt_byte(pkeys), update_keys(pkeys,pcrc_32_tab,c), t^(c))
|
(t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), (Byte)t^(c))
|
||||||
|
|
||||||
/***************************************************************************/
|
#ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED
|
||||||
|
|
||||||
/* Return the next byte in the pseudo-random sequence */
|
#define RAND_HEAD_LEN 12
|
||||||
uint8_t decrypt_byte(uint32_t *pkeys);
|
/* "last resort" source for second part of crypt seed pattern */
|
||||||
|
# ifndef ZCR_SEED2
|
||||||
|
# define ZCR_SEED2 3141592654UL /* use PI as default pattern */
|
||||||
|
# endif
|
||||||
|
|
||||||
/* Update the encryption keys with the next byte of plain text */
|
static unsigned crypthead(const char* passwd, /* password string */
|
||||||
uint8_t update_keys(uint32_t *pkeys, const z_crc_t *pcrc_32_tab, int32_t c);
|
unsigned char* buf, /* where to write header */
|
||||||
|
int bufSize,
|
||||||
|
unsigned long* pkeys,
|
||||||
|
const z_crc_t* pcrc_32_tab,
|
||||||
|
unsigned long crcForCrypting)
|
||||||
|
{
|
||||||
|
unsigned n; /* index in random header */
|
||||||
|
int t; /* temporary */
|
||||||
|
int c; /* random byte */
|
||||||
|
unsigned char header[RAND_HEAD_LEN-2]; /* random header */
|
||||||
|
static unsigned calls = 0; /* ensure different random header each time */
|
||||||
|
|
||||||
/* Initialize the encryption keys and the random header according to the given password. */
|
if (bufSize<RAND_HEAD_LEN)
|
||||||
void init_keys(const char *passwd, uint32_t *pkeys, const z_crc_t *pcrc_32_tab);
|
return 0;
|
||||||
|
|
||||||
/* Generate cryptographically secure random numbers */
|
/* First generate RAND_HEAD_LEN-2 random bytes. We encrypt the
|
||||||
int cryptrand(unsigned char *buf, unsigned int len);
|
* output of rand() to get less predictability, since rand() is
|
||||||
|
* often poorly implemented.
|
||||||
/* Create encryption header */
|
*/
|
||||||
int crypthead(const char *passwd, uint8_t *buf, int buf_size, uint32_t *pkeys,
|
if (++calls == 1)
|
||||||
const z_crc_t *pcrc_32_tab, uint8_t verify1, uint8_t verify2);
|
{
|
||||||
|
srand((unsigned)(time(NULL) ^ ZCR_SEED2));
|
||||||
/***************************************************************************/
|
}
|
||||||
|
init_keys(passwd, pkeys, pcrc_32_tab);
|
||||||
#ifdef __cplusplus
|
for (n = 0; n < RAND_HEAD_LEN-2; n++)
|
||||||
|
{
|
||||||
|
c = (rand() >> 7) & 0xff;
|
||||||
|
header[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, c, t);
|
||||||
|
}
|
||||||
|
/* Encrypt random header (last two bytes is high word of crc) */
|
||||||
|
init_keys(passwd, pkeys, pcrc_32_tab);
|
||||||
|
for (n = 0; n < RAND_HEAD_LEN-2; n++)
|
||||||
|
{
|
||||||
|
buf[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, header[n], t);
|
||||||
|
}
|
||||||
|
buf[n++] = (unsigned char)zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 16) & 0xff, t);
|
||||||
|
buf[n++] = (unsigned char)zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 24) & 0xff, t);
|
||||||
|
return n;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,81 +1,75 @@
|
||||||
/* ioapi.c -- IO base function header for compress/uncompress .zip
|
/* ioapi.h -- IO base function header for compress/uncompress .zip
|
||||||
part of the MiniZip project
|
part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
|
||||||
|
|
||||||
Copyright (C) 1998-2010 Gilles Vollant
|
Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
|
||||||
http://www.winimage.com/zLibDll/minizip.html
|
|
||||||
Modifications for Zip64 support
|
Modifications for Zip64 support
|
||||||
Copyright (C) 2009-2010 Mathias Svensson
|
Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
|
||||||
http://result42.com
|
|
||||||
|
For more info read MiniZip_info.txt
|
||||||
|
|
||||||
This program is distributed under the terms of the same license as zlib.
|
|
||||||
See the accompanying LICENSE file for the full text of the license.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
#if defined(_WIN32) && (!(defined(_CRT_SECURE_NO_WARNINGS)))
|
||||||
#include <string.h>
|
#define _CRT_SECURE_NO_WARNINGS
|
||||||
|
|
||||||
#if defined unix || defined __APPLE__
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__APPLE__) || defined(IOAPI_NO_64)
|
||||||
|
// In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions
|
||||||
|
#define FOPEN_FUNC(filename, mode) fopen(filename, mode)
|
||||||
|
#define FTELLO_FUNC(stream) ftello(stream)
|
||||||
|
#define FSEEKO_FUNC(stream, offset, origin) fseeko(stream, offset, origin)
|
||||||
|
#else
|
||||||
|
#define FOPEN_FUNC(filename, mode) fopen64(filename, mode)
|
||||||
|
#define FTELLO_FUNC(stream) ftello64(stream)
|
||||||
|
#define FSEEKO_FUNC(stream, offset, origin) fseeko64(stream, offset, origin)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#include "ioapi.h"
|
#include "ioapi.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode)
|
||||||
# define snprintf _snprintf
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
# pragma warning(push)
|
|
||||||
# pragma warning(disable : 4131 4100)
|
|
||||||
#endif
|
|
||||||
# ifdef __clang__
|
|
||||||
# pragma clang diagnostic push
|
|
||||||
# pragma clang diagnostic ignored "-Wunused-parameter"
|
|
||||||
# endif
|
|
||||||
#endif // _WIN32
|
|
||||||
|
|
||||||
|
|
||||||
voidpf call_zopen64(const zlib_filefunc64_32_def *pfilefunc, const void *filename, int mode)
|
|
||||||
{
|
{
|
||||||
if (pfilefunc->zfile_func64.zopen64_file != NULL)
|
if (pfilefunc->zfile_func64.zopen64_file != NULL)
|
||||||
return (*(pfilefunc->zfile_func64.zopen64_file)) (pfilefunc->zfile_func64.opaque, filename, mode);
|
return (*(pfilefunc->zfile_func64.zopen64_file)) (pfilefunc->zfile_func64.opaque,filename,mode);
|
||||||
return (*(pfilefunc->zopen32_file))(pfilefunc->zfile_func64.opaque, (const char*)filename, mode);
|
else
|
||||||
|
{
|
||||||
|
return (*(pfilefunc->zopen32_file))(pfilefunc->zfile_func64.opaque,(const char*)filename,mode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
voidpf call_zopendisk64(const zlib_filefunc64_32_def *pfilefunc, voidpf filestream, uint32_t number_disk, int mode)
|
long call_zseek64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin)
|
||||||
{
|
{
|
||||||
if (pfilefunc->zfile_func64.zopendisk64_file != NULL)
|
|
||||||
return (*(pfilefunc->zfile_func64.zopendisk64_file)) (pfilefunc->zfile_func64.opaque, filestream, number_disk, mode);
|
|
||||||
return (*(pfilefunc->zopendisk32_file))(pfilefunc->zfile_func64.opaque, filestream, number_disk, mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
long call_zseek64(const zlib_filefunc64_32_def *pfilefunc, voidpf filestream, uint64_t offset, int origin)
|
|
||||||
{
|
|
||||||
uint32_t offset_truncated = 0;
|
|
||||||
if (pfilefunc->zfile_func64.zseek64_file != NULL)
|
if (pfilefunc->zfile_func64.zseek64_file != NULL)
|
||||||
return (*(pfilefunc->zfile_func64.zseek64_file)) (pfilefunc->zfile_func64.opaque,filestream,offset,origin);
|
return (*(pfilefunc->zfile_func64.zseek64_file)) (pfilefunc->zfile_func64.opaque,filestream,offset,origin);
|
||||||
offset_truncated = (uint32_t)offset;
|
else
|
||||||
if (offset_truncated != offset)
|
{
|
||||||
return -1;
|
uLong offsetTruncated = (uLong)offset;
|
||||||
return (*(pfilefunc->zseek32_file))(pfilefunc->zfile_func64.opaque,filestream, offset_truncated, origin);
|
if (offsetTruncated != offset)
|
||||||
|
return -1;
|
||||||
|
else
|
||||||
|
return (*(pfilefunc->zseek32_file))(pfilefunc->zfile_func64.opaque,filestream,offsetTruncated,origin);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t call_ztell64(const zlib_filefunc64_32_def *pfilefunc, voidpf filestream)
|
ZPOS64_T call_ztell64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream)
|
||||||
{
|
{
|
||||||
uint64_t position;
|
|
||||||
if (pfilefunc->zfile_func64.zseek64_file != NULL)
|
if (pfilefunc->zfile_func64.zseek64_file != NULL)
|
||||||
return (*(pfilefunc->zfile_func64.ztell64_file)) (pfilefunc->zfile_func64.opaque, filestream);
|
return (*(pfilefunc->zfile_func64.ztell64_file)) (pfilefunc->zfile_func64.opaque,filestream);
|
||||||
position = (*(pfilefunc->ztell32_file))(pfilefunc->zfile_func64.opaque, filestream);
|
else
|
||||||
if ((position) == UINT32_MAX)
|
{
|
||||||
return (uint64_t)-1;
|
uLong tell_uLong = (uLong)(*(pfilefunc->ztell32_file))(pfilefunc->zfile_func64.opaque,filestream);
|
||||||
return position;
|
if ((tell_uLong) == MAXU32)
|
||||||
|
return (ZPOS64_T)-1;
|
||||||
|
else
|
||||||
|
return tell_uLong;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def *p_filefunc64_32, const zlib_filefunc_def *p_filefunc32)
|
void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32)
|
||||||
{
|
{
|
||||||
p_filefunc64_32->zfile_func64.zopen64_file = NULL;
|
p_filefunc64_32->zfile_func64.zopen64_file = NULL;
|
||||||
p_filefunc64_32->zfile_func64.zopendisk64_file = NULL;
|
|
||||||
p_filefunc64_32->zopen32_file = p_filefunc32->zopen_file;
|
p_filefunc64_32->zopen32_file = p_filefunc32->zopen_file;
|
||||||
p_filefunc64_32->zopendisk32_file = p_filefunc32->zopendisk_file;
|
|
||||||
p_filefunc64_32->zfile_func64.zerror_file = p_filefunc32->zerror_file;
|
p_filefunc64_32->zfile_func64.zerror_file = p_filefunc32->zerror_file;
|
||||||
p_filefunc64_32->zfile_func64.zread_file = p_filefunc32->zread_file;
|
p_filefunc64_32->zfile_func64.zread_file = p_filefunc32->zread_file;
|
||||||
p_filefunc64_32->zfile_func64.zwrite_file = p_filefunc32->zwrite_file;
|
p_filefunc64_32->zfile_func64.zwrite_file = p_filefunc32->zwrite_file;
|
||||||
|
@ -88,255 +82,158 @@ void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def *p_filef
|
||||||
p_filefunc64_32->ztell32_file = p_filefunc32->ztell_file;
|
p_filefunc64_32->ztell32_file = p_filefunc32->ztell_file;
|
||||||
}
|
}
|
||||||
|
|
||||||
static voidpf ZCALLBACK fopen_file_func(voidpf opaque, const char *filename, int mode);
|
|
||||||
static uint32_t ZCALLBACK fread_file_func(voidpf opaque, voidpf stream, void* buf, uint32_t size);
|
|
||||||
static uint32_t ZCALLBACK fwrite_file_func(voidpf opaque, voidpf stream, const void *buf, uint32_t size);
|
|
||||||
static uint64_t ZCALLBACK ftell64_file_func(voidpf opaque, voidpf stream);
|
|
||||||
static long ZCALLBACK fseek64_file_func(voidpf opaque, voidpf stream, uint64_t offset, int origin);
|
|
||||||
static int ZCALLBACK fclose_file_func(voidpf opaque, voidpf stream);
|
|
||||||
static int ZCALLBACK ferror_file_func(voidpf opaque, voidpf stream);
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
FILE *file;
|
|
||||||
int filenameLength;
|
|
||||||
void *filename;
|
|
||||||
} FILE_IOPOSIX;
|
|
||||||
|
|
||||||
static voidpf file_build_ioposix(FILE *file, const char *filename)
|
static voidpf ZCALLBACK fopen_file_func OF((voidpf opaque, const char* filename, int mode));
|
||||||
{
|
static uLong ZCALLBACK fread_file_func OF((voidpf opaque, voidpf stream, void* buf, uLong size));
|
||||||
FILE_IOPOSIX *ioposix = NULL;
|
static uLong ZCALLBACK fwrite_file_func OF((voidpf opaque, voidpf stream, const void* buf,uLong size));
|
||||||
if (file == NULL)
|
static ZPOS64_T ZCALLBACK ftell64_file_func OF((voidpf opaque, voidpf stream));
|
||||||
return NULL;
|
static long ZCALLBACK fseek64_file_func OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));
|
||||||
ioposix = (FILE_IOPOSIX*)malloc(sizeof(FILE_IOPOSIX));
|
static int ZCALLBACK fclose_file_func OF((voidpf opaque, voidpf stream));
|
||||||
ioposix->file = file;
|
static int ZCALLBACK ferror_file_func OF((voidpf opaque, voidpf stream));
|
||||||
ioposix->filenameLength = (int)strlen(filename) + 1;
|
|
||||||
ioposix->filename = (char*)malloc(ioposix->filenameLength * sizeof(char));
|
|
||||||
memcpy((char*)ioposix->filename, filename, ioposix->filenameLength);
|
|
||||||
return (voidpf)ioposix;
|
|
||||||
}
|
|
||||||
|
|
||||||
static voidpf ZCALLBACK fopen_file_func(voidpf opaque, const char *filename, int mode)
|
static voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* filename, int mode)
|
||||||
{
|
{
|
||||||
FILE* file = NULL;
|
FILE* file = NULL;
|
||||||
const char *mode_fopen = NULL;
|
const char* mode_fopen = NULL;
|
||||||
if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER) == ZLIB_FILEFUNC_MODE_READ)
|
(void)opaque;
|
||||||
|
if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
|
||||||
mode_fopen = "rb";
|
mode_fopen = "rb";
|
||||||
else if (mode & ZLIB_FILEFUNC_MODE_EXISTING)
|
else
|
||||||
|
if (mode & ZLIB_FILEFUNC_MODE_EXISTING)
|
||||||
mode_fopen = "r+b";
|
mode_fopen = "r+b";
|
||||||
else if (mode & ZLIB_FILEFUNC_MODE_CREATE)
|
else
|
||||||
|
if (mode & ZLIB_FILEFUNC_MODE_CREATE)
|
||||||
mode_fopen = "wb";
|
mode_fopen = "wb";
|
||||||
|
|
||||||
if ((filename != NULL) && (mode_fopen != NULL))
|
if ((filename!=NULL) && (mode_fopen != NULL))
|
||||||
{
|
|
||||||
file = fopen(filename, mode_fopen);
|
file = fopen(filename, mode_fopen);
|
||||||
return file_build_ioposix(file, filename);
|
|
||||||
}
|
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
static voidpf ZCALLBACK fopen64_file_func(voidpf opaque, const void *filename, int mode)
|
static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename, int mode)
|
||||||
{
|
{
|
||||||
FILE* file = NULL;
|
FILE* file = NULL;
|
||||||
const char *mode_fopen = NULL;
|
const char* mode_fopen = NULL;
|
||||||
if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER) == ZLIB_FILEFUNC_MODE_READ)
|
(void)opaque;
|
||||||
|
if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
|
||||||
mode_fopen = "rb";
|
mode_fopen = "rb";
|
||||||
else if (mode & ZLIB_FILEFUNC_MODE_EXISTING)
|
else
|
||||||
|
if (mode & ZLIB_FILEFUNC_MODE_EXISTING)
|
||||||
mode_fopen = "r+b";
|
mode_fopen = "r+b";
|
||||||
else if (mode & ZLIB_FILEFUNC_MODE_CREATE)
|
else
|
||||||
|
if (mode & ZLIB_FILEFUNC_MODE_CREATE)
|
||||||
mode_fopen = "wb";
|
mode_fopen = "wb";
|
||||||
|
|
||||||
if ((filename != NULL) && (mode_fopen != NULL))
|
if ((filename!=NULL) && (mode_fopen != NULL))
|
||||||
{
|
file = FOPEN_FUNC((const char*)filename, mode_fopen);
|
||||||
file = fopen64((const char*)filename, mode_fopen);
|
|
||||||
return file_build_ioposix(file, (const char*)filename);
|
|
||||||
}
|
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
static voidpf ZCALLBACK fopendisk64_file_func(voidpf opaque, voidpf stream, uint32_t number_disk, int mode)
|
|
||||||
{
|
|
||||||
FILE_IOPOSIX *ioposix = NULL;
|
|
||||||
char *diskFilename = NULL;
|
|
||||||
voidpf ret = NULL;
|
|
||||||
int i = 0;
|
|
||||||
|
|
||||||
if (stream == NULL)
|
static uLong ZCALLBACK fread_file_func (voidpf opaque, voidpf stream, void* buf, uLong size)
|
||||||
return NULL;
|
{
|
||||||
ioposix = (FILE_IOPOSIX*)stream;
|
uLong ret;
|
||||||
diskFilename = (char*)malloc(ioposix->filenameLength * sizeof(char));
|
(void)opaque;
|
||||||
strncpy(diskFilename, (const char*)ioposix->filename, ioposix->filenameLength);
|
ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream);
|
||||||
for (i = ioposix->filenameLength - 1; i >= 0; i -= 1)
|
|
||||||
{
|
|
||||||
if (diskFilename[i] != '.')
|
|
||||||
continue;
|
|
||||||
snprintf(&diskFilename[i], ioposix->filenameLength - i, ".z%02u", number_disk + 1);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (i >= 0)
|
|
||||||
ret = fopen64_file_func(opaque, diskFilename, mode);
|
|
||||||
free(diskFilename);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static voidpf ZCALLBACK fopendisk_file_func(voidpf opaque, voidpf stream, uint32_t number_disk, int mode)
|
static uLong ZCALLBACK fwrite_file_func (voidpf opaque, voidpf stream, const void* buf, uLong size)
|
||||||
{
|
{
|
||||||
FILE_IOPOSIX *ioposix = NULL;
|
uLong ret;
|
||||||
char *diskFilename = NULL;
|
(void)opaque;
|
||||||
voidpf ret = NULL;
|
ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream);
|
||||||
int i = 0;
|
|
||||||
|
|
||||||
if (stream == NULL)
|
|
||||||
return NULL;
|
|
||||||
ioposix = (FILE_IOPOSIX*)stream;
|
|
||||||
diskFilename = (char*)malloc(ioposix->filenameLength * sizeof(char));
|
|
||||||
strncpy(diskFilename, (const char*)ioposix->filename, ioposix->filenameLength);
|
|
||||||
for (i = ioposix->filenameLength - 1; i >= 0; i -= 1)
|
|
||||||
{
|
|
||||||
if (diskFilename[i] != '.')
|
|
||||||
continue;
|
|
||||||
snprintf(&diskFilename[i], ioposix->filenameLength - i, ".z%02u", number_disk + 1);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (i >= 0)
|
|
||||||
ret = fopen_file_func(opaque, diskFilename, mode);
|
|
||||||
free(diskFilename);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t ZCALLBACK fread_file_func(voidpf opaque, voidpf stream, void* buf, uint32_t size)
|
static long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream)
|
||||||
{
|
{
|
||||||
FILE_IOPOSIX *ioposix = NULL;
|
long ret;
|
||||||
uint32_t read = (uint32_t)-1;
|
(void)opaque;
|
||||||
if (stream == NULL)
|
ret = ftell((FILE *)stream);
|
||||||
return read;
|
|
||||||
ioposix = (FILE_IOPOSIX*)stream;
|
|
||||||
read = (uint32_t)fread(buf, 1, (size_t)size, ioposix->file);
|
|
||||||
return read;
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint32_t ZCALLBACK fwrite_file_func(voidpf opaque, voidpf stream, const void *buf, uint32_t size)
|
|
||||||
{
|
|
||||||
FILE_IOPOSIX *ioposix = NULL;
|
|
||||||
uint32_t written = (uint32_t)-1;
|
|
||||||
if (stream == NULL)
|
|
||||||
return written;
|
|
||||||
ioposix = (FILE_IOPOSIX*)stream;
|
|
||||||
written = (uint32_t)fwrite(buf, 1, (size_t)size, ioposix->file);
|
|
||||||
return written;
|
|
||||||
}
|
|
||||||
|
|
||||||
static long ZCALLBACK ftell_file_func(voidpf opaque, voidpf stream)
|
|
||||||
{
|
|
||||||
FILE_IOPOSIX *ioposix = NULL;
|
|
||||||
long ret = -1;
|
|
||||||
if (stream == NULL)
|
|
||||||
return ret;
|
|
||||||
ioposix = (FILE_IOPOSIX*)stream;
|
|
||||||
ret = ftell(ioposix->file);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint64_t ZCALLBACK ftell64_file_func(voidpf opaque, voidpf stream)
|
|
||||||
|
static ZPOS64_T ZCALLBACK ftell64_file_func (voidpf opaque, voidpf stream)
|
||||||
{
|
{
|
||||||
FILE_IOPOSIX *ioposix = NULL;
|
ZPOS64_T ret;
|
||||||
uint64_t ret = (uint64_t)-1;
|
(void)opaque;
|
||||||
if (stream == NULL)
|
ret = (ZPOS64_T)FTELLO_FUNC((FILE *)stream);
|
||||||
return ret;
|
|
||||||
ioposix = (FILE_IOPOSIX*)stream;
|
|
||||||
ret = ftello64(ioposix->file);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static long ZCALLBACK fseek_file_func(voidpf opaque, voidpf stream, uint32_t offset, int origin)
|
static long ZCALLBACK fseek_file_func (voidpf opaque, voidpf stream, uLong offset, int origin)
|
||||||
{
|
{
|
||||||
FILE_IOPOSIX *ioposix = NULL;
|
int fseek_origin=0;
|
||||||
int fseek_origin = 0;
|
long ret;
|
||||||
long ret = 0;
|
(void)opaque;
|
||||||
|
|
||||||
if (stream == NULL)
|
|
||||||
return -1;
|
|
||||||
ioposix = (FILE_IOPOSIX*)stream;
|
|
||||||
|
|
||||||
switch (origin)
|
switch (origin)
|
||||||
{
|
{
|
||||||
case ZLIB_FILEFUNC_SEEK_CUR:
|
case ZLIB_FILEFUNC_SEEK_CUR :
|
||||||
fseek_origin = SEEK_CUR;
|
fseek_origin = SEEK_CUR;
|
||||||
break;
|
break;
|
||||||
case ZLIB_FILEFUNC_SEEK_END:
|
case ZLIB_FILEFUNC_SEEK_END :
|
||||||
fseek_origin = SEEK_END;
|
fseek_origin = SEEK_END;
|
||||||
break;
|
break;
|
||||||
case ZLIB_FILEFUNC_SEEK_SET:
|
case ZLIB_FILEFUNC_SEEK_SET :
|
||||||
fseek_origin = SEEK_SET;
|
fseek_origin = SEEK_SET;
|
||||||
break;
|
break;
|
||||||
default:
|
default: return -1;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
if (fseek(ioposix->file, offset, fseek_origin) != 0)
|
ret = 0;
|
||||||
|
if (fseek((FILE *)stream, (long)offset, fseek_origin) != 0)
|
||||||
ret = -1;
|
ret = -1;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static long ZCALLBACK fseek64_file_func(voidpf opaque, voidpf stream, uint64_t offset, int origin)
|
static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T offset, int origin)
|
||||||
{
|
{
|
||||||
FILE_IOPOSIX *ioposix = NULL;
|
int fseek_origin=0;
|
||||||
int fseek_origin = 0;
|
long ret;
|
||||||
long ret = 0;
|
(void)opaque;
|
||||||
|
|
||||||
if (stream == NULL)
|
|
||||||
return -1;
|
|
||||||
ioposix = (FILE_IOPOSIX*)stream;
|
|
||||||
|
|
||||||
switch (origin)
|
switch (origin)
|
||||||
{
|
{
|
||||||
case ZLIB_FILEFUNC_SEEK_CUR:
|
case ZLIB_FILEFUNC_SEEK_CUR :
|
||||||
fseek_origin = SEEK_CUR;
|
fseek_origin = SEEK_CUR;
|
||||||
break;
|
break;
|
||||||
case ZLIB_FILEFUNC_SEEK_END:
|
case ZLIB_FILEFUNC_SEEK_END :
|
||||||
fseek_origin = SEEK_END;
|
fseek_origin = SEEK_END;
|
||||||
break;
|
break;
|
||||||
case ZLIB_FILEFUNC_SEEK_SET:
|
case ZLIB_FILEFUNC_SEEK_SET :
|
||||||
fseek_origin = SEEK_SET;
|
fseek_origin = SEEK_SET;
|
||||||
break;
|
break;
|
||||||
default:
|
default: return -1;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
if (fseeko64(ioposix->file, offset, fseek_origin) != 0)
|
if(FSEEKO_FUNC((FILE *)stream, (z_off_t)offset, fseek_origin) != 0)
|
||||||
ret = -1;
|
ret = -1;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ZCALLBACK fclose_file_func(voidpf opaque, voidpf stream)
|
|
||||||
|
static int ZCALLBACK fclose_file_func (voidpf opaque, voidpf stream)
|
||||||
{
|
{
|
||||||
FILE_IOPOSIX *ioposix = NULL;
|
int ret;
|
||||||
int ret = -1;
|
(void)opaque;
|
||||||
if (stream == NULL)
|
ret = fclose((FILE *)stream);
|
||||||
return ret;
|
|
||||||
ioposix = (FILE_IOPOSIX*)stream;
|
|
||||||
if (ioposix->filename != NULL)
|
|
||||||
free(ioposix->filename);
|
|
||||||
ret = fclose(ioposix->file);
|
|
||||||
free(ioposix);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ZCALLBACK ferror_file_func(voidpf opaque, voidpf stream)
|
static int ZCALLBACK ferror_file_func (voidpf opaque, voidpf stream)
|
||||||
{
|
{
|
||||||
FILE_IOPOSIX *ioposix = NULL;
|
int ret;
|
||||||
int ret = -1;
|
(void)opaque;
|
||||||
if (stream == NULL)
|
ret = ferror((FILE *)stream);
|
||||||
return ret;
|
|
||||||
ioposix = (FILE_IOPOSIX*)stream;
|
|
||||||
ret = ferror(ioposix->file);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void fill_fopen_filefunc(zlib_filefunc_def *pzlib_filefunc_def)
|
void fill_fopen_filefunc (zlib_filefunc_def* pzlib_filefunc_def)
|
||||||
{
|
{
|
||||||
pzlib_filefunc_def->zopen_file = fopen_file_func;
|
pzlib_filefunc_def->zopen_file = fopen_file_func;
|
||||||
pzlib_filefunc_def->zopendisk_file = fopendisk_file_func;
|
|
||||||
pzlib_filefunc_def->zread_file = fread_file_func;
|
pzlib_filefunc_def->zread_file = fread_file_func;
|
||||||
pzlib_filefunc_def->zwrite_file = fwrite_file_func;
|
pzlib_filefunc_def->zwrite_file = fwrite_file_func;
|
||||||
pzlib_filefunc_def->ztell_file = ftell_file_func;
|
pzlib_filefunc_def->ztell_file = ftell_file_func;
|
||||||
|
@ -346,10 +243,9 @@ void fill_fopen_filefunc(zlib_filefunc_def *pzlib_filefunc_def)
|
||||||
pzlib_filefunc_def->opaque = NULL;
|
pzlib_filefunc_def->opaque = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void fill_fopen64_filefunc(zlib_filefunc64_def *pzlib_filefunc_def)
|
void fill_fopen64_filefunc (zlib_filefunc64_def* pzlib_filefunc_def)
|
||||||
{
|
{
|
||||||
pzlib_filefunc_def->zopen64_file = fopen64_file_func;
|
pzlib_filefunc_def->zopen64_file = fopen64_file_func;
|
||||||
pzlib_filefunc_def->zopendisk64_file = fopendisk64_file_func;
|
|
||||||
pzlib_filefunc_def->zread_file = fread_file_func;
|
pzlib_filefunc_def->zread_file = fread_file_func;
|
||||||
pzlib_filefunc_def->zwrite_file = fwrite_file_func;
|
pzlib_filefunc_def->zwrite_file = fwrite_file_func;
|
||||||
pzlib_filefunc_def->ztell64_file = ftell64_file_func;
|
pzlib_filefunc_def->ztell64_file = ftell64_file_func;
|
||||||
|
@ -358,10 +254,3 @@ void fill_fopen64_filefunc(zlib_filefunc64_def *pzlib_filefunc_def)
|
||||||
pzlib_filefunc_def->zerror_file = ferror_file_func;
|
pzlib_filefunc_def->zerror_file = ferror_file_func;
|
||||||
pzlib_filefunc_def->opaque = NULL;
|
pzlib_filefunc_def->opaque = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
# pragma warning(pop)
|
|
||||||
# ifdef __clang__
|
|
||||||
# pragma clang diagnostic pop
|
|
||||||
# endif
|
|
||||||
#endif // _MSC_VER
|
|
||||||
|
|
|
@ -1,142 +1,207 @@
|
||||||
/* ioapi.h -- IO base function header for compress/uncompress .zip
|
/* ioapi.h -- IO base function header for compress/uncompress .zip
|
||||||
part of the MiniZip project
|
part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
|
||||||
|
|
||||||
Copyright (C) 1998-2010 Gilles Vollant
|
Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
|
||||||
http://www.winimage.com/zLibDll/minizip.html
|
|
||||||
Modifications for Zip64 support
|
Modifications for Zip64 support
|
||||||
Copyright (C) 2009-2010 Mathias Svensson
|
Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
|
||||||
http://result42.com
|
|
||||||
|
For more info read MiniZip_info.txt
|
||||||
|
|
||||||
|
Changes
|
||||||
|
|
||||||
|
Oct-2009 - Defined ZPOS64_T to fpos_t on windows and u_int64_t on linux. (might need to find a better why for this)
|
||||||
|
Oct-2009 - Change to fseeko64, ftello64 and fopen64 so large files would work on linux.
|
||||||
|
More if/def section may be needed to support other platforms
|
||||||
|
Oct-2009 - Defined fxxxx64 calls to normal fopen/ftell/fseek so they would compile on windows.
|
||||||
|
(but you should use iowin32.c for windows instead)
|
||||||
|
|
||||||
This program is distributed under the terms of the same license as zlib.
|
|
||||||
See the accompanying LICENSE file for the full text of the license.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _ZLIBIOAPI64_H
|
#ifndef _ZLIBIOAPI64_H
|
||||||
#define _ZLIBIOAPI64_H
|
#define _ZLIBIOAPI64_H
|
||||||
|
|
||||||
|
#if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__))
|
||||||
|
|
||||||
|
// Linux needs this to support file operation on files larger then 4+GB
|
||||||
|
// But might need better if/def to select just the platforms that needs them.
|
||||||
|
|
||||||
|
#ifndef __USE_FILE_OFFSET64
|
||||||
|
#define __USE_FILE_OFFSET64
|
||||||
|
#endif
|
||||||
|
#ifndef __USE_LARGEFILE64
|
||||||
|
#define __USE_LARGEFILE64
|
||||||
|
#endif
|
||||||
|
#ifndef _LARGEFILE64_SOURCE
|
||||||
|
#define _LARGEFILE64_SOURCE
|
||||||
|
#endif
|
||||||
|
#ifndef _FILE_OFFSET_BIT
|
||||||
|
#define _FILE_OFFSET_BIT 64
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include "zlib.h"
|
#include "zlib.h"
|
||||||
|
|
||||||
#if defined(USE_FILE32API)
|
#if defined(USE_FILE32API)
|
||||||
# define fopen64 fopen
|
#define fopen64 fopen
|
||||||
# define ftello64 ftell
|
#define ftello64 ftell
|
||||||
# define fseeko64 fseek
|
#define fseeko64 fseek
|
||||||
#else
|
#else
|
||||||
#if defined(_MSC_VER)
|
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
|
||||||
# define fopen64 fopen
|
#define fopen64 fopen
|
||||||
# if (_MSC_VER >= 1400) && (!(defined(NO_MSCVER_FILE64_FUNC)))
|
#define ftello64 ftello
|
||||||
# define ftello64 _ftelli64
|
#define fseeko64 fseeko
|
||||||
# define fseeko64 _fseeki64
|
|
||||||
# else /* old MSC */
|
|
||||||
# define ftello64 ftell
|
|
||||||
# define fseeko64 fseek
|
|
||||||
# endif
|
|
||||||
#else
|
|
||||||
# define fopen64 fopen
|
|
||||||
# define ftello64 ftello
|
|
||||||
# define fseeko64 fseeko
|
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#define fopen64 fopen
|
||||||
|
#if (_MSC_VER >= 1400) && (!(defined(NO_MSCVER_FILE64_FUNC)))
|
||||||
|
#define ftello64 _ftelli64
|
||||||
|
#define fseeko64 _fseeki64
|
||||||
|
#else // old MSC
|
||||||
|
#define ftello64 ftell
|
||||||
|
#define fseeko64 fseek
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
#ifndef ZPOS64_T
|
||||||
|
#ifdef _WIN32
|
||||||
|
#define ZPOS64_T fpos_t
|
||||||
|
#else
|
||||||
|
#include <stdint.h>
|
||||||
|
#define ZPOS64_T uint64_t
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_MINIZIP64_CONF_H
|
||||||
|
#include "mz64conf.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* a type choosen by DEFINE */
|
||||||
|
#ifdef HAVE_64BIT_INT_CUSTOM
|
||||||
|
typedef 64BIT_INT_CUSTOM_TYPE ZPOS64_T;
|
||||||
|
#else
|
||||||
|
#ifdef HAS_STDINT_H
|
||||||
|
#include "stdint.h"
|
||||||
|
typedef uint64_t ZPOS64_T;
|
||||||
|
#else
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(_MSC_VER) || defined(__BORLANDC__)
|
||||||
|
typedef unsigned __int64 ZPOS64_T;
|
||||||
|
#else
|
||||||
|
typedef unsigned long long int ZPOS64_T;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Maximum unsigned 32-bit value used as placeholder for zip64 */
|
||||||
|
#ifndef MAXU32
|
||||||
|
#define MAXU32 (0xffffffff)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#define ZLIB_FILEFUNC_SEEK_CUR (1)
|
#define ZLIB_FILEFUNC_SEEK_CUR (1)
|
||||||
#define ZLIB_FILEFUNC_SEEK_END (2)
|
#define ZLIB_FILEFUNC_SEEK_END (2)
|
||||||
#define ZLIB_FILEFUNC_SEEK_SET (0)
|
#define ZLIB_FILEFUNC_SEEK_SET (0)
|
||||||
|
|
||||||
#define ZLIB_FILEFUNC_MODE_READ (1)
|
#define ZLIB_FILEFUNC_MODE_READ (1)
|
||||||
#define ZLIB_FILEFUNC_MODE_WRITE (2)
|
#define ZLIB_FILEFUNC_MODE_WRITE (2)
|
||||||
#define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3)
|
#define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3)
|
||||||
#define ZLIB_FILEFUNC_MODE_EXISTING (4)
|
|
||||||
#define ZLIB_FILEFUNC_MODE_CREATE (8)
|
#define ZLIB_FILEFUNC_MODE_EXISTING (4)
|
||||||
|
#define ZLIB_FILEFUNC_MODE_CREATE (8)
|
||||||
|
|
||||||
|
|
||||||
#ifndef ZCALLBACK
|
#ifndef ZCALLBACK
|
||||||
# if (defined(WIN32) || defined(_WIN32) || defined (WINDOWS) || \
|
#if (defined(WIN32) || defined(_WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK)
|
||||||
defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK)
|
#define ZCALLBACK CALLBACK
|
||||||
# define ZCALLBACK CALLBACK
|
#else
|
||||||
# else
|
#define ZCALLBACK
|
||||||
# define ZCALLBACK
|
#endif
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef voidpf (ZCALLBACK *open_file_func) (voidpf opaque, const char *filename, int mode);
|
|
||||||
typedef voidpf (ZCALLBACK *opendisk_file_func) (voidpf opaque, voidpf stream, uint32_t number_disk, int mode);
|
|
||||||
typedef uint32_t (ZCALLBACK *read_file_func) (voidpf opaque, voidpf stream, void* buf, uint32_t size);
|
|
||||||
typedef uint32_t (ZCALLBACK *write_file_func) (voidpf opaque, voidpf stream, const void *buf, uint32_t size);
|
|
||||||
typedef int (ZCALLBACK *close_file_func) (voidpf opaque, voidpf stream);
|
|
||||||
typedef int (ZCALLBACK *error_file_func) (voidpf opaque, voidpf stream);
|
|
||||||
|
|
||||||
typedef long (ZCALLBACK *tell_file_func) (voidpf opaque, voidpf stream);
|
|
||||||
typedef long (ZCALLBACK *seek_file_func) (voidpf opaque, voidpf stream, uint32_t offset, int origin);
|
|
||||||
|
typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode));
|
||||||
|
typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size));
|
||||||
|
typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size));
|
||||||
|
typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream));
|
||||||
|
typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream));
|
||||||
|
|
||||||
|
typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream));
|
||||||
|
typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin));
|
||||||
|
|
||||||
|
|
||||||
/* here is the "old" 32 bits structure structure */
|
/* here is the "old" 32 bits structure structure */
|
||||||
typedef struct zlib_filefunc_def_s
|
typedef struct zlib_filefunc_def_s
|
||||||
{
|
{
|
||||||
open_file_func zopen_file;
|
open_file_func zopen_file;
|
||||||
opendisk_file_func zopendisk_file;
|
|
||||||
read_file_func zread_file;
|
read_file_func zread_file;
|
||||||
write_file_func zwrite_file;
|
write_file_func zwrite_file;
|
||||||
tell_file_func ztell_file;
|
tell_file_func ztell_file;
|
||||||
seek_file_func zseek_file;
|
seek_file_func zseek_file;
|
||||||
close_file_func zclose_file;
|
close_file_func zclose_file;
|
||||||
error_file_func zerror_file;
|
testerror_file_func zerror_file;
|
||||||
voidpf opaque;
|
voidpf opaque;
|
||||||
} zlib_filefunc_def;
|
} zlib_filefunc_def;
|
||||||
|
|
||||||
typedef uint64_t (ZCALLBACK *tell64_file_func) (voidpf opaque, voidpf stream);
|
typedef ZPOS64_T (ZCALLBACK *tell64_file_func) OF((voidpf opaque, voidpf stream));
|
||||||
typedef long (ZCALLBACK *seek64_file_func) (voidpf opaque, voidpf stream, uint64_t offset, int origin);
|
typedef long (ZCALLBACK *seek64_file_func) OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));
|
||||||
typedef voidpf (ZCALLBACK *open64_file_func) (voidpf opaque, const void *filename, int mode);
|
typedef voidpf (ZCALLBACK *open64_file_func) OF((voidpf opaque, const void* filename, int mode));
|
||||||
typedef voidpf (ZCALLBACK *opendisk64_file_func)(voidpf opaque, voidpf stream, uint32_t number_disk, int mode);
|
|
||||||
|
|
||||||
typedef struct zlib_filefunc64_def_s
|
typedef struct zlib_filefunc64_def_s
|
||||||
{
|
{
|
||||||
open64_file_func zopen64_file;
|
open64_file_func zopen64_file;
|
||||||
opendisk64_file_func zopendisk64_file;
|
read_file_func zread_file;
|
||||||
read_file_func zread_file;
|
write_file_func zwrite_file;
|
||||||
write_file_func zwrite_file;
|
tell64_file_func ztell64_file;
|
||||||
tell64_file_func ztell64_file;
|
seek64_file_func zseek64_file;
|
||||||
seek64_file_func zseek64_file;
|
close_file_func zclose_file;
|
||||||
close_file_func zclose_file;
|
testerror_file_func zerror_file;
|
||||||
error_file_func zerror_file;
|
voidpf opaque;
|
||||||
voidpf opaque;
|
|
||||||
} zlib_filefunc64_def;
|
} zlib_filefunc64_def;
|
||||||
|
|
||||||
void fill_fopen_filefunc(zlib_filefunc_def *pzlib_filefunc_def);
|
void fill_fopen64_filefunc OF((zlib_filefunc64_def* pzlib_filefunc_def));
|
||||||
void fill_fopen64_filefunc(zlib_filefunc64_def *pzlib_filefunc_def);
|
void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));
|
||||||
|
|
||||||
/* now internal definition, only for zip.c and unzip.h */
|
/* now internal definition, only for zip.c and unzip.h */
|
||||||
typedef struct zlib_filefunc64_32_def_s
|
typedef struct zlib_filefunc64_32_def_s
|
||||||
{
|
{
|
||||||
zlib_filefunc64_def zfile_func64;
|
zlib_filefunc64_def zfile_func64;
|
||||||
open_file_func zopen32_file;
|
open_file_func zopen32_file;
|
||||||
opendisk_file_func zopendisk32_file;
|
|
||||||
tell_file_func ztell32_file;
|
tell_file_func ztell32_file;
|
||||||
seek_file_func zseek32_file;
|
seek_file_func zseek32_file;
|
||||||
} zlib_filefunc64_32_def;
|
} zlib_filefunc64_32_def;
|
||||||
|
|
||||||
#define ZREAD64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zread_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size))
|
|
||||||
#define ZWRITE64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zwrite_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size))
|
|
||||||
/*#define ZTELL64(filefunc,filestream) ((*((filefunc).ztell64_file)) ((filefunc).opaque,filestream))*/
|
|
||||||
/*#define ZSEEK64(filefunc,filestream,pos,mode) ((*((filefunc).zseek64_file)) ((filefunc).opaque,filestream,pos,mode))*/
|
|
||||||
#define ZCLOSE64(filefunc,filestream) ((*((filefunc).zfile_func64.zclose_file)) ((filefunc).zfile_func64.opaque,filestream))
|
|
||||||
#define ZERROR64(filefunc,filestream) ((*((filefunc).zfile_func64.zerror_file)) ((filefunc).zfile_func64.opaque,filestream))
|
|
||||||
|
|
||||||
voidpf call_zopen64(const zlib_filefunc64_32_def *pfilefunc,const void*filename, int mode);
|
#define ZREAD64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zread_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size))
|
||||||
voidpf call_zopendisk64(const zlib_filefunc64_32_def *pfilefunc, voidpf filestream, uint32_t number_disk, int mode);
|
#define ZWRITE64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zwrite_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size))
|
||||||
long call_zseek64(const zlib_filefunc64_32_def *pfilefunc, voidpf filestream, uint64_t offset, int origin);
|
//#define ZTELL64(filefunc,filestream) ((*((filefunc).ztell64_file)) ((filefunc).opaque,filestream))
|
||||||
uint64_t call_ztell64(const zlib_filefunc64_32_def *pfilefunc, voidpf filestream);
|
//#define ZSEEK64(filefunc,filestream,pos,mode) ((*((filefunc).zseek64_file)) ((filefunc).opaque,filestream,pos,mode))
|
||||||
|
#define ZCLOSE64(filefunc,filestream) ((*((filefunc).zfile_func64.zclose_file)) ((filefunc).zfile_func64.opaque,filestream))
|
||||||
|
#define ZERROR64(filefunc,filestream) ((*((filefunc).zfile_func64.zerror_file)) ((filefunc).zfile_func64.opaque,filestream))
|
||||||
|
|
||||||
void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def *p_filefunc64_32, const zlib_filefunc_def *p_filefunc32);
|
voidpf call_zopen64 OF((const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode));
|
||||||
|
long call_zseek64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin));
|
||||||
|
ZPOS64_T call_ztell64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream));
|
||||||
|
|
||||||
#define ZOPEN64(filefunc,filename,mode) (call_zopen64((&(filefunc)),(filename),(mode)))
|
void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32);
|
||||||
#define ZOPENDISK64(filefunc,filestream,diskn,mode) (call_zopendisk64((&(filefunc)),(filestream),(diskn),(mode)))
|
|
||||||
#define ZTELL64(filefunc,filestream) (call_ztell64((&(filefunc)),(filestream)))
|
#define ZOPEN64(filefunc,filename,mode) (call_zopen64((&(filefunc)),(filename),(mode)))
|
||||||
#define ZSEEK64(filefunc,filestream,pos,mode) (call_zseek64((&(filefunc)),(filestream),(pos),(mode)))
|
#define ZTELL64(filefunc,filestream) (call_ztell64((&(filefunc)),(filestream)))
|
||||||
|
#define ZSEEK64(filefunc,filestream,pos,mode) (call_zseek64((&(filefunc)),(filestream),(pos),(mode)))
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,21 +1,47 @@
|
||||||
/* unzip.h -- IO for uncompress .zip files using zlib
|
/* unzip.h -- IO for uncompress .zip files using zlib
|
||||||
Version 1.1, February 14h, 2010
|
Version 1.1, February 14h, 2010
|
||||||
part of the MiniZip project
|
part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
|
||||||
|
|
||||||
Copyright (C) 1998-2010 Gilles Vollant
|
Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
|
||||||
http://www.winimage.com/zLibDll/minizip.html
|
|
||||||
Modifications of Unzip for Zip64
|
Modifications of Unzip for Zip64
|
||||||
Copyright (C) 2007-2008 Even Rouault
|
Copyright (C) 2007-2008 Even Rouault
|
||||||
Modifications for Zip64 support on both zip and unzip
|
|
||||||
Copyright (C) 2009-2010 Mathias Svensson
|
Modifications for Zip64 support on both zip and unzip
|
||||||
http://result42.com
|
Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
|
||||||
|
|
||||||
|
For more info read MiniZip_info.txt
|
||||||
|
|
||||||
|
---------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Condition of use and distribution are the same than zlib :
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
|
||||||
|
---------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Changes
|
||||||
|
|
||||||
|
See header of unzip64.c
|
||||||
|
|
||||||
This program is distributed under the terms of the same license as zlib.
|
|
||||||
See the accompanying LICENSE file for the full text of the license.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _UNZ_H
|
#ifndef _unz64_H
|
||||||
#define _UNZ_H
|
#define _unz64_H
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -25,7 +51,7 @@ extern "C" {
|
||||||
#include "zlib.h"
|
#include "zlib.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef _ZLIBIOAPI_H
|
#ifndef _ZLIBIOAPI_H
|
||||||
#include "ioapi.h"
|
#include "ioapi.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -38,12 +64,13 @@ extern "C" {
|
||||||
#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
|
#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
|
||||||
/* like the STRICT of WIN32, we define a pointer that cannot be converted
|
/* like the STRICT of WIN32, we define a pointer that cannot be converted
|
||||||
from (void*) without cast */
|
from (void*) without cast */
|
||||||
typedef struct TagunzFile__ { int unused; } unz_file__;
|
typedef struct TagunzFile__ { int unused; } unzFile__;
|
||||||
typedef unz_file__ *unzFile;
|
typedef unzFile__ *unzFile;
|
||||||
#else
|
#else
|
||||||
typedef voidp unzFile;
|
typedef voidp unzFile;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#define UNZ_OK (0)
|
#define UNZ_OK (0)
|
||||||
#define UNZ_END_OF_LIST_OF_FILE (-100)
|
#define UNZ_END_OF_LIST_OF_FILE (-100)
|
||||||
#define UNZ_ERRNO (Z_ERRNO)
|
#define UNZ_ERRNO (Z_ERRNO)
|
||||||
|
@ -52,255 +79,359 @@ typedef voidp unzFile;
|
||||||
#define UNZ_BADZIPFILE (-103)
|
#define UNZ_BADZIPFILE (-103)
|
||||||
#define UNZ_INTERNALERROR (-104)
|
#define UNZ_INTERNALERROR (-104)
|
||||||
#define UNZ_CRCERROR (-105)
|
#define UNZ_CRCERROR (-105)
|
||||||
#define UNZ_BADPASSWORD (-106)
|
|
||||||
|
/* tm_unz contain date/time info */
|
||||||
|
typedef struct tm_unz_s
|
||||||
|
{
|
||||||
|
int tm_sec; /* seconds after the minute - [0,59] */
|
||||||
|
int tm_min; /* minutes after the hour - [0,59] */
|
||||||
|
int tm_hour; /* hours since midnight - [0,23] */
|
||||||
|
int tm_mday; /* day of the month - [1,31] */
|
||||||
|
int tm_mon; /* months since January - [0,11] */
|
||||||
|
int tm_year; /* years - [1980..2044] */
|
||||||
|
} tm_unz;
|
||||||
|
|
||||||
/* unz_global_info structure contain global data about the ZIPfile
|
/* unz_global_info structure contain global data about the ZIPfile
|
||||||
These data comes from the end of central dir */
|
These data comes from the end of central dir */
|
||||||
typedef struct unz_global_info64_s
|
typedef struct unz_global_info64_s
|
||||||
{
|
{
|
||||||
uint64_t number_entry; /* total number of entries in the central dir on this disk */
|
ZPOS64_T number_entry; /* total number of entries in
|
||||||
uint32_t number_disk_with_CD; /* number the the disk with central dir, used for spanning ZIP*/
|
the central dir on this disk */
|
||||||
uint16_t size_comment; /* size of the global comment of the zipfile */
|
uLong size_comment; /* size of the global comment of the zipfile */
|
||||||
} unz_global_info64;
|
} unz_global_info64;
|
||||||
|
|
||||||
typedef struct unz_global_info_s
|
typedef struct unz_global_info_s
|
||||||
{
|
{
|
||||||
uint32_t number_entry; /* total number of entries in the central dir on this disk */
|
uLong number_entry; /* total number of entries in
|
||||||
uint32_t number_disk_with_CD; /* number the the disk with central dir, used for spanning ZIP*/
|
the central dir on this disk */
|
||||||
uint16_t size_comment; /* size of the global comment of the zipfile */
|
uLong size_comment; /* size of the global comment of the zipfile */
|
||||||
} unz_global_info;
|
} unz_global_info;
|
||||||
|
|
||||||
/* unz_file_info contain information about a file in the zipfile */
|
/* unz_file_info contain information about a file in the zipfile */
|
||||||
typedef struct unz_file_info64_s
|
typedef struct unz_file_info64_s
|
||||||
{
|
{
|
||||||
uint16_t version; /* version made by 2 bytes */
|
uLong version; /* version made by 2 bytes */
|
||||||
uint16_t version_needed; /* version needed to extract 2 bytes */
|
uLong version_needed; /* version needed to extract 2 bytes */
|
||||||
uint16_t flag; /* general purpose bit flag 2 bytes */
|
uLong flag; /* general purpose bit flag 2 bytes */
|
||||||
uint16_t compression_method; /* compression method 2 bytes */
|
uLong compression_method; /* compression method 2 bytes */
|
||||||
uint32_t dos_date; /* last mod file date in Dos fmt 4 bytes */
|
uLong dosDate; /* last mod file date in Dos fmt 4 bytes */
|
||||||
uint32_t crc; /* crc-32 4 bytes */
|
uLong crc; /* crc-32 4 bytes */
|
||||||
uint64_t compressed_size; /* compressed size 8 bytes */
|
ZPOS64_T compressed_size; /* compressed size 8 bytes */
|
||||||
uint64_t uncompressed_size; /* uncompressed size 8 bytes */
|
ZPOS64_T uncompressed_size; /* uncompressed size 8 bytes */
|
||||||
uint16_t size_filename; /* filename length 2 bytes */
|
uLong size_filename; /* filename length 2 bytes */
|
||||||
uint16_t size_file_extra; /* extra field length 2 bytes */
|
uLong size_file_extra; /* extra field length 2 bytes */
|
||||||
uint16_t size_file_comment; /* file comment length 2 bytes */
|
uLong size_file_comment; /* file comment length 2 bytes */
|
||||||
|
|
||||||
uint32_t disk_num_start; /* disk number start 4 bytes */
|
uLong disk_num_start; /* disk number start 2 bytes */
|
||||||
uint16_t internal_fa; /* internal file attributes 2 bytes */
|
uLong internal_fa; /* internal file attributes 2 bytes */
|
||||||
uint32_t external_fa; /* external file attributes 4 bytes */
|
uLong external_fa; /* external file attributes 4 bytes */
|
||||||
|
|
||||||
uint64_t disk_offset;
|
tm_unz tmu_date;
|
||||||
|
|
||||||
uint16_t size_file_extra_internal;
|
|
||||||
} unz_file_info64;
|
} unz_file_info64;
|
||||||
|
|
||||||
typedef struct unz_file_info_s
|
typedef struct unz_file_info_s
|
||||||
{
|
{
|
||||||
uint16_t version; /* version made by 2 bytes */
|
uLong version; /* version made by 2 bytes */
|
||||||
uint16_t version_needed; /* version needed to extract 2 bytes */
|
uLong version_needed; /* version needed to extract 2 bytes */
|
||||||
uint16_t flag; /* general purpose bit flag 2 bytes */
|
uLong flag; /* general purpose bit flag 2 bytes */
|
||||||
uint16_t compression_method; /* compression method 2 bytes */
|
uLong compression_method; /* compression method 2 bytes */
|
||||||
uint32_t dos_date; /* last mod file date in Dos fmt 4 bytes */
|
uLong dosDate; /* last mod file date in Dos fmt 4 bytes */
|
||||||
uint32_t crc; /* crc-32 4 bytes */
|
uLong crc; /* crc-32 4 bytes */
|
||||||
uint32_t compressed_size; /* compressed size 4 bytes */
|
uLong compressed_size; /* compressed size 4 bytes */
|
||||||
uint32_t uncompressed_size; /* uncompressed size 4 bytes */
|
uLong uncompressed_size; /* uncompressed size 4 bytes */
|
||||||
uint16_t size_filename; /* filename length 2 bytes */
|
uLong size_filename; /* filename length 2 bytes */
|
||||||
uint16_t size_file_extra; /* extra field length 2 bytes */
|
uLong size_file_extra; /* extra field length 2 bytes */
|
||||||
uint16_t size_file_comment; /* file comment length 2 bytes */
|
uLong size_file_comment; /* file comment length 2 bytes */
|
||||||
|
|
||||||
uint16_t disk_num_start; /* disk number start 2 bytes */
|
uLong disk_num_start; /* disk number start 2 bytes */
|
||||||
uint16_t internal_fa; /* internal file attributes 2 bytes */
|
uLong internal_fa; /* internal file attributes 2 bytes */
|
||||||
uint32_t external_fa; /* external file attributes 4 bytes */
|
uLong external_fa; /* external file attributes 4 bytes */
|
||||||
|
|
||||||
uint64_t disk_offset;
|
tm_unz tmu_date;
|
||||||
} unz_file_info;
|
} unz_file_info;
|
||||||
|
|
||||||
/***************************************************************************/
|
extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1,
|
||||||
/* Opening and close a zip file */
|
const char* fileName2,
|
||||||
|
int iCaseSensitivity));
|
||||||
|
/*
|
||||||
|
Compare two filename (fileName1,fileName2).
|
||||||
|
If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
|
||||||
|
If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
|
||||||
|
or strcasecmp)
|
||||||
|
If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
|
||||||
|
(like 1 on Unix, 2 on Windows)
|
||||||
|
*/
|
||||||
|
|
||||||
extern unzFile ZEXPORT unzOpen(const char *path);
|
|
||||||
extern unzFile ZEXPORT unzOpen64(const void *path);
|
|
||||||
/* Open a Zip file.
|
|
||||||
|
|
||||||
path should contain the full path (by example, on a Windows XP computer
|
extern unzFile ZEXPORT unzOpen OF((const char *path));
|
||||||
"c:\\zlib\\zlib113.zip" or on an Unix computer "zlib/zlib113.zip".
|
extern unzFile ZEXPORT unzOpen64 OF((const void *path));
|
||||||
return NULL if zipfile cannot be opened or doesn't exist
|
/*
|
||||||
return unzFile handle if no error
|
Open a Zip file. path contain the full pathname (by example,
|
||||||
|
on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer
|
||||||
|
"zlib/zlib113.zip".
|
||||||
|
If the zipfile cannot be opened (file don't exist or in not valid), the
|
||||||
|
return value is NULL.
|
||||||
|
Else, the return value is a unzFile Handle, usable with other function
|
||||||
|
of this unzip package.
|
||||||
|
the "64" function take a const void* pointer, because the path is just the
|
||||||
|
value passed to the open64_file_func callback.
|
||||||
|
Under Windows, if UNICODE is defined, using fill_fopen64_filefunc, the path
|
||||||
|
is a pointer to a wide unicode string (LPCTSTR is LPCWSTR), so const char*
|
||||||
|
does not describe the reality
|
||||||
|
*/
|
||||||
|
|
||||||
NOTE: The "64" function take a const void *pointer, because the path is just the value passed to the
|
|
||||||
open64_file_func callback. Under Windows, if UNICODE is defined, using fill_fopen64_filefunc, the path
|
|
||||||
is a pointer to a wide unicode string (LPCTSTR is LPCWSTR), so const char *does not describe the reality */
|
|
||||||
|
|
||||||
extern unzFile ZEXPORT unzOpen2(const char *path, zlib_filefunc_def *pzlib_filefunc_def);
|
extern unzFile ZEXPORT unzOpen2 OF((const char *path,
|
||||||
/* Open a Zip file, like unzOpen, but provide a set of file low level API for read/write operations */
|
zlib_filefunc_def* pzlib_filefunc_def));
|
||||||
extern unzFile ZEXPORT unzOpen2_64(const void *path, zlib_filefunc64_def *pzlib_filefunc_def);
|
/*
|
||||||
/* Open a Zip file, like unz64Open, but provide a set of file low level API for read/write 64-bit operations */
|
Open a Zip file, like unzOpen, but provide a set of file low level API
|
||||||
|
for read/write the zip file (see ioapi.h)
|
||||||
|
*/
|
||||||
|
|
||||||
extern int ZEXPORT unzClose(unzFile file);
|
extern unzFile ZEXPORT unzOpen2_64 OF((const void *path,
|
||||||
/* Close a ZipFile opened with unzOpen. If there is files inside the .Zip opened with unzOpenCurrentFile,
|
zlib_filefunc64_def* pzlib_filefunc_def));
|
||||||
these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
|
/*
|
||||||
|
Open a Zip file, like unz64Open, but provide a set of file low level API
|
||||||
|
for read/write the zip file (see ioapi.h)
|
||||||
|
*/
|
||||||
|
|
||||||
return UNZ_OK if there is no error */
|
extern int ZEXPORT unzClose OF((unzFile file));
|
||||||
|
/*
|
||||||
|
Close a ZipFile opened with unzOpen.
|
||||||
|
If there is files inside the .Zip opened with unzOpenCurrentFile (see later),
|
||||||
|
these files MUST be closed with unzCloseCurrentFile before call unzClose.
|
||||||
|
return UNZ_OK if there is no problem. */
|
||||||
|
|
||||||
extern int ZEXPORT unzGetGlobalInfo(unzFile file, unz_global_info *pglobal_info);
|
extern int ZEXPORT unzGetGlobalInfo OF((unzFile file,
|
||||||
extern int ZEXPORT unzGetGlobalInfo64(unzFile file, unz_global_info64 *pglobal_info);
|
unz_global_info *pglobal_info));
|
||||||
/* Write info about the ZipFile in the *pglobal_info structure.
|
|
||||||
|
|
||||||
return UNZ_OK if no error */
|
extern int ZEXPORT unzGetGlobalInfo64 OF((unzFile file,
|
||||||
|
unz_global_info64 *pglobal_info));
|
||||||
|
/*
|
||||||
|
Write info about the ZipFile in the *pglobal_info structure.
|
||||||
|
No preparation of the structure is needed
|
||||||
|
return UNZ_OK if there is no problem. */
|
||||||
|
|
||||||
extern int ZEXPORT unzGetGlobalComment(unzFile file, char *comment, uint16_t comment_size);
|
|
||||||
/* Get the global comment string of the ZipFile, in the comment buffer.
|
|
||||||
|
|
||||||
uSizeBuf is the size of the szComment buffer.
|
extern int ZEXPORT unzGetGlobalComment OF((unzFile file,
|
||||||
return the number of byte copied or an error code <0 */
|
char *szComment,
|
||||||
|
uLong uSizeBuf));
|
||||||
|
/*
|
||||||
|
Get the global comment string of the ZipFile, in the szComment buffer.
|
||||||
|
uSizeBuf is the size of the szComment buffer.
|
||||||
|
return the number of byte copied or an error code <0
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************/
|
/***************************************************************************/
|
||||||
/* Reading the content of the current zipfile, you can open it, read data from it, and close it
|
/* Unzip package allow you browse the directory of the zipfile */
|
||||||
(you can close it before reading all the file) */
|
|
||||||
|
|
||||||
extern int ZEXPORT unzOpenCurrentFile(unzFile file);
|
extern int ZEXPORT unzGoToFirstFile OF((unzFile file));
|
||||||
/* Open for reading data the current file in the zipfile.
|
/*
|
||||||
|
Set the current file of the zipfile to the first file.
|
||||||
|
return UNZ_OK if there is no problem
|
||||||
|
*/
|
||||||
|
|
||||||
return UNZ_OK if no error */
|
extern int ZEXPORT unzGoToNextFile OF((unzFile file));
|
||||||
|
/*
|
||||||
|
Set the current file of the zipfile to the next file.
|
||||||
|
return UNZ_OK if there is no problem
|
||||||
|
return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
|
||||||
|
*/
|
||||||
|
|
||||||
extern int ZEXPORT unzOpenCurrentFilePassword(unzFile file, const char *password);
|
extern int ZEXPORT unzLocateFile OF((unzFile file,
|
||||||
/* Open for reading data the current file in the zipfile.
|
const char *szFileName,
|
||||||
password is a crypting password
|
int iCaseSensitivity));
|
||||||
|
/*
|
||||||
|
Try locate the file szFileName in the zipfile.
|
||||||
|
For the iCaseSensitivity signification, see unzStringFileNameCompare
|
||||||
|
|
||||||
return UNZ_OK if no error */
|
return value :
|
||||||
|
UNZ_OK if the file is found. It becomes the current file.
|
||||||
|
UNZ_END_OF_LIST_OF_FILE if the file is not found
|
||||||
|
*/
|
||||||
|
|
||||||
extern int ZEXPORT unzOpenCurrentFile2(unzFile file, int *method, int *level, int raw);
|
|
||||||
/* Same as unzOpenCurrentFile, but open for read raw the file (not uncompress)
|
|
||||||
if raw==1 *method will receive method of compression, *level will receive level of compression
|
|
||||||
|
|
||||||
NOTE: you can set level parameter as NULL (if you did not want known level,
|
|
||||||
but you CANNOT set method parameter as NULL */
|
|
||||||
|
|
||||||
extern int ZEXPORT unzOpenCurrentFile3(unzFile file, int *method, int *level, int raw, const char *password);
|
|
||||||
/* Same as unzOpenCurrentFile, but takes extra parameter password for encrypted files */
|
|
||||||
|
|
||||||
extern int ZEXPORT unzReadCurrentFile(unzFile file, voidp buf, uint32_t len);
|
|
||||||
/* Read bytes from the current file (opened by unzOpenCurrentFile)
|
|
||||||
buf contain buffer where data must be copied
|
|
||||||
len the size of buf.
|
|
||||||
|
|
||||||
return the number of byte copied if somes bytes are copied
|
|
||||||
return 0 if the end of file was reached
|
|
||||||
return <0 with error code if there is an error (UNZ_ERRNO for IO error, or zLib error for uncompress error) */
|
|
||||||
|
|
||||||
extern int ZEXPORT unzGetCurrentFileInfo(unzFile file, unz_file_info *pfile_info, char *filename,
|
|
||||||
uint16_t filename_size, void *extrafield, uint16_t extrafield_size, char *comment, uint16_t comment_size);
|
|
||||||
extern int ZEXPORT unzGetCurrentFileInfo64(unzFile file, unz_file_info64 *pfile_info, char *filename,
|
|
||||||
uint16_t filename_size, void *extrafield, uint16_t extrafield_size, char *comment, uint16_t comment_size);
|
|
||||||
/* Get Info about the current file
|
|
||||||
|
|
||||||
pfile_info if != NULL, the *pfile_info structure will contain somes info about the current file
|
|
||||||
filename if != NULL, the file name string will be copied in filename
|
|
||||||
filename_size is the size of the filename buffer
|
|
||||||
extrafield if != NULL, the extra field information from the central header will be copied in to
|
|
||||||
extrafield_size is the size of the extraField buffer
|
|
||||||
comment if != NULL, the comment string of the file will be copied in to
|
|
||||||
comment_size is the size of the comment buffer */
|
|
||||||
|
|
||||||
extern int ZEXPORT unzGetLocalExtrafield(unzFile file, voidp buf, uint32_t len);
|
|
||||||
/* Read extra field from the current file (opened by unzOpenCurrentFile)
|
|
||||||
This is the local-header version of the extra field (sometimes, there is
|
|
||||||
more info in the local-header version than in the central-header)
|
|
||||||
|
|
||||||
if buf == NULL, it return the size of the local extra field
|
|
||||||
if buf != NULL, len is the size of the buffer, the extra header is copied in buf.
|
|
||||||
|
|
||||||
return number of bytes copied in buf, or (if <0) the error code */
|
|
||||||
|
|
||||||
extern int ZEXPORT unzCloseCurrentFile(unzFile file);
|
|
||||||
/* Close the file in zip opened with unzOpenCurrentFile
|
|
||||||
|
|
||||||
return UNZ_CRCERROR if all the file was read but the CRC is not good */
|
|
||||||
|
|
||||||
/***************************************************************************/
|
|
||||||
/* Browse the directory of the zipfile */
|
|
||||||
|
|
||||||
typedef int (*unzFileNameComparer)(unzFile file, const char *filename1, const char *filename2);
|
|
||||||
typedef int (*unzIteratorFunction)(unzFile file);
|
|
||||||
typedef int (*unzIteratorFunction2)(unzFile file, unz_file_info64 *pfile_info, char *filename,
|
|
||||||
uint16_t filename_size, void *extrafield, uint16_t extrafield_size, char *comment, uint16_t comment_size);
|
|
||||||
|
|
||||||
extern int ZEXPORT unzGoToFirstFile(unzFile file);
|
|
||||||
/* Set the current file of the zipfile to the first file.
|
|
||||||
|
|
||||||
return UNZ_OK if no error */
|
|
||||||
|
|
||||||
extern int ZEXPORT unzGoToFirstFile2(unzFile file, unz_file_info64 *pfile_info, char *filename,
|
|
||||||
uint16_t filename_size, void *extrafield, uint16_t extrafield_size, char *comment, uint16_t comment_size);
|
|
||||||
/* Set the current file of the zipfile to the first file and retrieves the current info on success.
|
|
||||||
Not as seek intensive as unzGoToFirstFile + unzGetCurrentFileInfo.
|
|
||||||
|
|
||||||
return UNZ_OK if no error */
|
|
||||||
|
|
||||||
extern int ZEXPORT unzGoToNextFile(unzFile file);
|
|
||||||
/* Set the current file of the zipfile to the next file.
|
|
||||||
|
|
||||||
return UNZ_OK if no error
|
|
||||||
return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest */
|
|
||||||
|
|
||||||
extern int ZEXPORT unzGoToNextFile2(unzFile file, unz_file_info64 *pfile_info, char *filename,
|
|
||||||
uint16_t filename_size, void *extrafield, uint16_t extrafield_size, char *comment, uint16_t comment_size);
|
|
||||||
/* Set the current file of the zipfile to the next file and retrieves the current
|
|
||||||
info on success. Does less seeking around than unzGotoNextFile + unzGetCurrentFileInfo.
|
|
||||||
|
|
||||||
return UNZ_OK if no error
|
|
||||||
return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest */
|
|
||||||
|
|
||||||
extern int ZEXPORT unzLocateFile(unzFile file, const char *filename, unzFileNameComparer filename_compare_func);
|
|
||||||
/* Try locate the file szFileName in the zipfile. For custom filename comparison pass in comparison function.
|
|
||||||
|
|
||||||
return UNZ_OK if the file is found (it becomes the current file)
|
|
||||||
return UNZ_END_OF_LIST_OF_FILE if the file is not found */
|
|
||||||
|
|
||||||
/***************************************************************************/
|
|
||||||
/* Raw access to zip file */
|
|
||||||
|
|
||||||
|
/* ****************************************** */
|
||||||
|
/* Ryan supplied functions */
|
||||||
|
/* unz_file_info contain information about a file in the zipfile */
|
||||||
typedef struct unz_file_pos_s
|
typedef struct unz_file_pos_s
|
||||||
{
|
{
|
||||||
uint32_t pos_in_zip_directory; /* offset in zip file directory */
|
uLong pos_in_zip_directory; /* offset in zip file directory */
|
||||||
uint32_t num_of_file; /* # of file */
|
uLong num_of_file; /* # of file */
|
||||||
} unz_file_pos;
|
} unz_file_pos;
|
||||||
|
|
||||||
extern int ZEXPORT unzGetFilePos(unzFile file, unz_file_pos *file_pos);
|
extern int ZEXPORT unzGetFilePos(
|
||||||
extern int ZEXPORT unzGoToFilePos(unzFile file, unz_file_pos *file_pos);
|
unzFile file,
|
||||||
|
unz_file_pos* file_pos);
|
||||||
|
|
||||||
|
extern int ZEXPORT unzGoToFilePos(
|
||||||
|
unzFile file,
|
||||||
|
unz_file_pos* file_pos);
|
||||||
|
|
||||||
typedef struct unz64_file_pos_s
|
typedef struct unz64_file_pos_s
|
||||||
{
|
{
|
||||||
uint64_t pos_in_zip_directory; /* offset in zip file directory */
|
ZPOS64_T pos_in_zip_directory; /* offset in zip file directory */
|
||||||
uint64_t num_of_file; /* # of file */
|
ZPOS64_T num_of_file; /* # of file */
|
||||||
} unz64_file_pos;
|
} unz64_file_pos;
|
||||||
|
|
||||||
extern int ZEXPORT unzGetFilePos64(unzFile file, unz64_file_pos *file_pos);
|
extern int ZEXPORT unzGetFilePos64(
|
||||||
extern int ZEXPORT unzGoToFilePos64(unzFile file, const unz64_file_pos *file_pos);
|
unzFile file,
|
||||||
|
unz64_file_pos* file_pos);
|
||||||
|
|
||||||
extern int32_t ZEXPORT unzGetOffset(unzFile file);
|
extern int ZEXPORT unzGoToFilePos64(
|
||||||
extern int64_t ZEXPORT unzGetOffset64(unzFile file);
|
unzFile file,
|
||||||
/* Get the current file offset */
|
const unz64_file_pos* file_pos);
|
||||||
|
|
||||||
extern int ZEXPORT unzSetOffset(unzFile file, uint32_t pos);
|
/* ****************************************** */
|
||||||
extern int ZEXPORT unzSetOffset64(unzFile file, uint64_t pos);
|
|
||||||
/* Set the current file offset */
|
|
||||||
|
|
||||||
extern int32_t ZEXPORT unzTell(unzFile file);
|
extern int ZEXPORT unzGetCurrentFileInfo64 OF((unzFile file,
|
||||||
extern int64_t ZEXPORT unzTell64(unzFile file);
|
unz_file_info64 *pfile_info,
|
||||||
/* return current position in uncompressed data */
|
char *szFileName,
|
||||||
|
uLong fileNameBufferSize,
|
||||||
|
void *extraField,
|
||||||
|
uLong extraFieldBufferSize,
|
||||||
|
char *szComment,
|
||||||
|
uLong commentBufferSize));
|
||||||
|
|
||||||
extern int ZEXPORT unzSeek(unzFile file, uint32_t offset, int origin);
|
extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,
|
||||||
extern int ZEXPORT unzSeek64(unzFile file, uint64_t offset, int origin);
|
unz_file_info *pfile_info,
|
||||||
/* Seek within the uncompressed data if compression method is storage */
|
char *szFileName,
|
||||||
|
uLong fileNameBufferSize,
|
||||||
|
void *extraField,
|
||||||
|
uLong extraFieldBufferSize,
|
||||||
|
char *szComment,
|
||||||
|
uLong commentBufferSize));
|
||||||
|
/*
|
||||||
|
Get Info about the current file
|
||||||
|
if pfile_info!=NULL, the *pfile_info structure will contain somes info about
|
||||||
|
the current file
|
||||||
|
if szFileName!=NULL, the filemane string will be copied in szFileName
|
||||||
|
(fileNameBufferSize is the size of the buffer)
|
||||||
|
if extraField!=NULL, the extra field information will be copied in extraField
|
||||||
|
(extraFieldBufferSize is the size of the buffer).
|
||||||
|
This is the Central-header version of the extra field
|
||||||
|
if szComment!=NULL, the comment string of the file will be copied in szComment
|
||||||
|
(commentBufferSize is the size of the buffer)
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/** Addition for GDAL : START */
|
||||||
|
|
||||||
|
extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64 OF((unzFile file));
|
||||||
|
|
||||||
|
/** Addition for GDAL : END */
|
||||||
|
|
||||||
extern int ZEXPORT unzEndOfFile(unzFile file);
|
|
||||||
/* return 1 if the end of file was reached, 0 elsewhere */
|
|
||||||
|
|
||||||
/***************************************************************************/
|
/***************************************************************************/
|
||||||
|
/* for reading the content of the current zipfile, you can open it, read data
|
||||||
|
from it, and close it (you can close it before reading all the file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern int ZEXPORT unzOpenCurrentFile OF((unzFile file));
|
||||||
|
/*
|
||||||
|
Open for reading data the current file in the zipfile.
|
||||||
|
If there is no error, the return value is UNZ_OK.
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file,
|
||||||
|
const char* password));
|
||||||
|
/*
|
||||||
|
Open for reading data the current file in the zipfile.
|
||||||
|
password is a crypting password
|
||||||
|
If there is no error, the return value is UNZ_OK.
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file,
|
||||||
|
int* method,
|
||||||
|
int* level,
|
||||||
|
int raw));
|
||||||
|
/*
|
||||||
|
Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
|
||||||
|
if raw==1
|
||||||
|
*method will receive method of compression, *level will receive level of
|
||||||
|
compression
|
||||||
|
note : you can set level parameter as NULL (if you did not want known level,
|
||||||
|
but you CANNOT set method parameter as NULL
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file,
|
||||||
|
int* method,
|
||||||
|
int* level,
|
||||||
|
int raw,
|
||||||
|
const char* password));
|
||||||
|
/*
|
||||||
|
Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
|
||||||
|
if raw==1
|
||||||
|
*method will receive method of compression, *level will receive level of
|
||||||
|
compression
|
||||||
|
note : you can set level parameter as NULL (if you did not want known level,
|
||||||
|
but you CANNOT set method parameter as NULL
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
extern int ZEXPORT unzCloseCurrentFile OF((unzFile file));
|
||||||
|
/*
|
||||||
|
Close the file in zip opened with unzOpenCurrentFile
|
||||||
|
Return UNZ_CRCERROR if all the file was read but the CRC is not good
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern int ZEXPORT unzReadCurrentFile OF((unzFile file,
|
||||||
|
voidp buf,
|
||||||
|
unsigned len));
|
||||||
|
/*
|
||||||
|
Read bytes from the current file (opened by unzOpenCurrentFile)
|
||||||
|
buf contain buffer where data must be copied
|
||||||
|
len the size of buf.
|
||||||
|
|
||||||
|
return the number of byte copied if somes bytes are copied
|
||||||
|
return 0 if the end of file was reached
|
||||||
|
return <0 with error code if there is an error
|
||||||
|
(UNZ_ERRNO for IO error, or zLib error for uncompress error)
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern z_off_t ZEXPORT unztell OF((unzFile file));
|
||||||
|
|
||||||
|
extern ZPOS64_T ZEXPORT unztell64 OF((unzFile file));
|
||||||
|
/*
|
||||||
|
Give the current position in uncompressed data
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern int ZEXPORT unzeof OF((unzFile file));
|
||||||
|
/*
|
||||||
|
return 1 if the end of file was reached, 0 elsewhere
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,
|
||||||
|
voidp buf,
|
||||||
|
unsigned len));
|
||||||
|
/*
|
||||||
|
Read extra field from the current file (opened by unzOpenCurrentFile)
|
||||||
|
This is the local-header version of the extra field (sometimes, there is
|
||||||
|
more info in the local-header version than in the central-header)
|
||||||
|
|
||||||
|
if buf==NULL, it return the size of the local extra field
|
||||||
|
|
||||||
|
if buf!=NULL, len is the size of the buffer, the extra header is copied in
|
||||||
|
buf.
|
||||||
|
the return value is the number of bytes copied in buf, or (if <0)
|
||||||
|
the error code
|
||||||
|
*/
|
||||||
|
|
||||||
|
/***************************************************************************/
|
||||||
|
|
||||||
|
/* Get the current file offset */
|
||||||
|
extern ZPOS64_T ZEXPORT unzGetOffset64 (unzFile file);
|
||||||
|
extern uLong ZEXPORT unzGetOffset (unzFile file);
|
||||||
|
|
||||||
|
/* Set the current file offset */
|
||||||
|
extern int ZEXPORT unzSetOffset64 (unzFile file, ZPOS64_T pos);
|
||||||
|
extern int ZEXPORT unzSetOffset (unzFile file, uLong pos);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* _UNZ_H */
|
#endif /* _unz64_H */
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
Boost Software License - Version 1.0 - August 17th, 2003
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person or organization
|
||||||
|
obtaining a copy of the software and accompanying documentation covered by
|
||||||
|
this license (the "Software") to use, reproduce, display, distribute,
|
||||||
|
execute, and transmit the Software, and to prepare derivative works of the
|
||||||
|
Software, and to permit third-parties to whom the Software is furnished to
|
||||||
|
do so, all subject to the following:
|
||||||
|
|
||||||
|
The copyright notices in the Software and this entire statement, including
|
||||||
|
the above license grant, this restriction and the following disclaimer,
|
||||||
|
must be included in all copies of the Software, in whole or in part, and
|
||||||
|
all derivative works of the Software, unless such copies or derivative
|
||||||
|
works are solely in the form of machine-executable object code generated by
|
||||||
|
a source language processor.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||||
|
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||||
|
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||||
|
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
DEALINGS IN THE SOFTWARE.
|
File diff suppressed because it is too large
Load Diff
|
@ -1,12 +0,0 @@
|
||||||
utf8 cpp library
|
|
||||||
Release 2.3.4
|
|
||||||
|
|
||||||
A minor bug fix release. Thanks to all who reported bugs.
|
|
||||||
|
|
||||||
Note: Version 2.3.3 contained a regression, and therefore was removed.
|
|
||||||
|
|
||||||
Changes from version 2.3.2
|
|
||||||
- Bug fix [39]: checked.h Line 273 and unchecked.h Line 182 have an extra ';'
|
|
||||||
- Bug fix [36]: replace_invalid() only works with back_inserter
|
|
||||||
|
|
||||||
Files included in the release: utf8.h, core.h, checked.h, unchecked.h, utf8cpp.html, ReleaseNotes
|
|
File diff suppressed because it is too large
Load Diff
|
@ -42,7 +42,7 @@ namespace utf8
|
||||||
uint32_t cp;
|
uint32_t cp;
|
||||||
public:
|
public:
|
||||||
invalid_code_point(uint32_t codepoint) : cp(codepoint) {}
|
invalid_code_point(uint32_t codepoint) : cp(codepoint) {}
|
||||||
virtual const char* what() const NOEXCEPT OVERRIDE { return "Invalid code point"; }
|
virtual const char* what() const UTF_CPP_NOEXCEPT UTF_CPP_OVERRIDE { return "Invalid code point"; }
|
||||||
uint32_t code_point() const {return cp;}
|
uint32_t code_point() const {return cp;}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -50,7 +50,8 @@ namespace utf8
|
||||||
uint8_t u8;
|
uint8_t u8;
|
||||||
public:
|
public:
|
||||||
invalid_utf8 (uint8_t u) : u8(u) {}
|
invalid_utf8 (uint8_t u) : u8(u) {}
|
||||||
virtual const char* what() const NOEXCEPT OVERRIDE { return "Invalid UTF-8"; }
|
invalid_utf8 (char c) : u8(static_cast<uint8_t>(c)) {}
|
||||||
|
virtual const char* what() const UTF_CPP_NOEXCEPT UTF_CPP_OVERRIDE { return "Invalid UTF-8"; }
|
||||||
uint8_t utf8_octet() const {return u8;}
|
uint8_t utf8_octet() const {return u8;}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -58,13 +59,13 @@ namespace utf8
|
||||||
uint16_t u16;
|
uint16_t u16;
|
||||||
public:
|
public:
|
||||||
invalid_utf16 (uint16_t u) : u16(u) {}
|
invalid_utf16 (uint16_t u) : u16(u) {}
|
||||||
virtual const char* what() const NOEXCEPT OVERRIDE { return "Invalid UTF-16"; }
|
virtual const char* what() const UTF_CPP_NOEXCEPT UTF_CPP_OVERRIDE { return "Invalid UTF-16"; }
|
||||||
uint16_t utf16_word() const {return u16;}
|
uint16_t utf16_word() const {return u16;}
|
||||||
};
|
};
|
||||||
|
|
||||||
class not_enough_room : public exception {
|
class not_enough_room : public exception {
|
||||||
public:
|
public:
|
||||||
virtual const char* what() const NOEXCEPT OVERRIDE { return "Not enough space"; }
|
virtual const char* what() const UTF_CPP_NOEXCEPT UTF_CPP_OVERRIDE { return "Not enough space"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
/// The library API - functions intended to be called by the users
|
/// The library API - functions intended to be called by the users
|
||||||
|
@ -75,24 +76,7 @@ namespace utf8
|
||||||
if (!utf8::internal::is_code_point_valid(cp))
|
if (!utf8::internal::is_code_point_valid(cp))
|
||||||
throw invalid_code_point(cp);
|
throw invalid_code_point(cp);
|
||||||
|
|
||||||
if (cp < 0x80) // one octet
|
return internal::append(cp, result);
|
||||||
*(result++) = static_cast<uint8_t>(cp);
|
|
||||||
else if (cp < 0x800) { // two octets
|
|
||||||
*(result++) = static_cast<uint8_t>((cp >> 6) | 0xc0);
|
|
||||||
*(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80);
|
|
||||||
}
|
|
||||||
else if (cp < 0x10000) { // three octets
|
|
||||||
*(result++) = static_cast<uint8_t>((cp >> 12) | 0xe0);
|
|
||||||
*(result++) = static_cast<uint8_t>(((cp >> 6) & 0x3f) | 0x80);
|
|
||||||
*(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80);
|
|
||||||
}
|
|
||||||
else { // four octets
|
|
||||||
*(result++) = static_cast<uint8_t>((cp >> 18) | 0xf0);
|
|
||||||
*(result++) = static_cast<uint8_t>(((cp >> 12) & 0x3f) | 0x80);
|
|
||||||
*(result++) = static_cast<uint8_t>(((cp >> 6) & 0x3f) | 0x80);
|
|
||||||
*(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename octet_iterator, typename output_iterator>
|
template <typename octet_iterator, typename output_iterator>
|
||||||
|
@ -148,7 +132,7 @@ namespace utf8
|
||||||
case internal::INVALID_LEAD :
|
case internal::INVALID_LEAD :
|
||||||
case internal::INCOMPLETE_SEQUENCE :
|
case internal::INCOMPLETE_SEQUENCE :
|
||||||
case internal::OVERLONG_SEQUENCE :
|
case internal::OVERLONG_SEQUENCE :
|
||||||
throw invalid_utf8(*it);
|
throw invalid_utf8(static_cast<uint8_t>(*it));
|
||||||
case internal::INVALID_CODE_POINT :
|
case internal::INVALID_CODE_POINT :
|
||||||
throw invalid_code_point(cp);
|
throw invalid_code_point(cp);
|
||||||
}
|
}
|
||||||
|
@ -325,7 +309,9 @@ namespace utf8
|
||||||
|
|
||||||
} // namespace utf8
|
} // namespace utf8
|
||||||
|
|
||||||
#if UTF_CPP_CPLUSPLUS >= 201103L // C++ 11 or later
|
#if UTF_CPP_CPLUSPLUS >= 201703L // C++ 17 or later
|
||||||
|
#include "cpp17.h"
|
||||||
|
#elif UTF_CPP_CPLUSPLUS >= 201103L // C++ 11 or later
|
||||||
#include "cpp11.h"
|
#include "cpp11.h"
|
||||||
#endif // C++ 11 or later
|
#endif // C++ 11 or later
|
||||||
|
|
||||||
|
|
|
@ -39,11 +39,11 @@ DEALINGS IN THE SOFTWARE.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if UTF_CPP_CPLUSPLUS >= 201103L // C++ 11 or later
|
#if UTF_CPP_CPLUSPLUS >= 201103L // C++ 11 or later
|
||||||
#define OVERRIDE override
|
#define UTF_CPP_OVERRIDE override
|
||||||
#define NOEXCEPT noexcept
|
#define UTF_CPP_NOEXCEPT noexcept
|
||||||
#else // C++ 98/03
|
#else // C++ 98/03
|
||||||
#define OVERRIDE
|
#define UTF_CPP_OVERRIDE
|
||||||
#define NOEXCEPT throw()
|
#define UTF_CPP_NOEXCEPT throw()
|
||||||
#endif // C++ 11 or later
|
#endif // C++ 11 or later
|
||||||
|
|
||||||
|
|
||||||
|
@ -297,6 +297,55 @@ namespace internal
|
||||||
return utf8::internal::validate_next(it, end, ignored);
|
return utf8::internal::validate_next(it, end, ignored);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Internal implementation of both checked and unchecked append() function
|
||||||
|
// This function will be invoked by the overloads below, as they will know
|
||||||
|
// the octet_type.
|
||||||
|
template <typename octet_iterator, typename octet_type>
|
||||||
|
octet_iterator append(uint32_t cp, octet_iterator result) {
|
||||||
|
if (cp < 0x80) // one octet
|
||||||
|
*(result++) = static_cast<octet_type>(cp);
|
||||||
|
else if (cp < 0x800) { // two octets
|
||||||
|
*(result++) = static_cast<octet_type>((cp >> 6) | 0xc0);
|
||||||
|
*(result++) = static_cast<octet_type>((cp & 0x3f) | 0x80);
|
||||||
|
}
|
||||||
|
else if (cp < 0x10000) { // three octets
|
||||||
|
*(result++) = static_cast<octet_type>((cp >> 12) | 0xe0);
|
||||||
|
*(result++) = static_cast<octet_type>(((cp >> 6) & 0x3f) | 0x80);
|
||||||
|
*(result++) = static_cast<octet_type>((cp & 0x3f) | 0x80);
|
||||||
|
}
|
||||||
|
else { // four octets
|
||||||
|
*(result++) = static_cast<octet_type>((cp >> 18) | 0xf0);
|
||||||
|
*(result++) = static_cast<octet_type>(((cp >> 12) & 0x3f)| 0x80);
|
||||||
|
*(result++) = static_cast<octet_type>(((cp >> 6) & 0x3f) | 0x80);
|
||||||
|
*(result++) = static_cast<octet_type>((cp & 0x3f) | 0x80);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// One of the following overloads will be invoked from the API calls
|
||||||
|
|
||||||
|
// A simple (but dangerous) case: the caller appends byte(s) to a char array
|
||||||
|
inline char* append(uint32_t cp, char* result) {
|
||||||
|
return append<char*, char>(cp, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hopefully, most common case: the caller uses back_inserter
|
||||||
|
// i.e. append(cp, std::back_inserter(str));
|
||||||
|
template<typename container_type>
|
||||||
|
std::back_insert_iterator<container_type> append
|
||||||
|
(uint32_t cp, std::back_insert_iterator<container_type> result) {
|
||||||
|
return append<std::back_insert_iterator<container_type>,
|
||||||
|
typename container_type::value_type>(cp, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
// The caller uses some other kind of output operator - not covered above
|
||||||
|
// Note that in this case we are not able to determine octet_type
|
||||||
|
// so we assume it's uint_8; that can cause a conversion warning if we are wrong.
|
||||||
|
template <typename octet_iterator>
|
||||||
|
octet_iterator append(uint32_t cp, octet_iterator result) {
|
||||||
|
return append<octet_iterator, uint8_t>(cp, result);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
|
|
||||||
/// The library API - functions intended to be called by the users
|
/// The library API - functions intended to be called by the users
|
||||||
|
|
|
@ -70,7 +70,7 @@ namespace utf8
|
||||||
inline std::size_t find_invalid(const std::string& s)
|
inline std::size_t find_invalid(const std::string& s)
|
||||||
{
|
{
|
||||||
std::string::const_iterator invalid = find_invalid(s.begin(), s.end());
|
std::string::const_iterator invalid = find_invalid(s.begin(), s.end());
|
||||||
return (invalid == s.end()) ? std::string::npos : (invalid - s.begin());
|
return (invalid == s.end()) ? std::string::npos : static_cast<std::size_t>(invalid - s.begin());
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool is_valid(const std::string& s)
|
inline bool is_valid(const std::string& s)
|
||||||
|
|
|
@ -0,0 +1,103 @@
|
||||||
|
// Copyright 2018 Nemanja Trifunovic
|
||||||
|
|
||||||
|
/*
|
||||||
|
Permission is hereby granted, free of charge, to any person or organization
|
||||||
|
obtaining a copy of the software and accompanying documentation covered by
|
||||||
|
this license (the "Software") to use, reproduce, display, distribute,
|
||||||
|
execute, and transmit the Software, and to prepare derivative works of the
|
||||||
|
Software, and to permit third-parties to whom the Software is furnished to
|
||||||
|
do so, all subject to the following:
|
||||||
|
|
||||||
|
The copyright notices in the Software and this entire statement, including
|
||||||
|
the above license grant, this restriction and the following disclaimer,
|
||||||
|
must be included in all copies of the Software, in whole or in part, and
|
||||||
|
all derivative works of the Software, unless such copies or derivative
|
||||||
|
works are solely in the form of machine-executable object code generated by
|
||||||
|
a source language processor.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||||
|
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||||
|
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||||
|
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef UTF8_FOR_CPP_7e906c01_03a3_4daf_b420_ea7ea952b3c9
|
||||||
|
#define UTF8_FOR_CPP_7e906c01_03a3_4daf_b420_ea7ea952b3c9
|
||||||
|
|
||||||
|
#include "checked.h"
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace utf8
|
||||||
|
{
|
||||||
|
|
||||||
|
inline void append(char32_t cp, std::string& s)
|
||||||
|
{
|
||||||
|
append(uint32_t(cp), std::back_inserter(s));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline std::string utf16to8(std::u16string_view s)
|
||||||
|
{
|
||||||
|
std::string result;
|
||||||
|
utf16to8(s.begin(), s.end(), std::back_inserter(result));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline std::u16string utf8to16(std::string_view s)
|
||||||
|
{
|
||||||
|
std::u16string result;
|
||||||
|
utf8to16(s.begin(), s.end(), std::back_inserter(result));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline std::string utf32to8(std::u32string_view s)
|
||||||
|
{
|
||||||
|
std::string result;
|
||||||
|
utf32to8(s.begin(), s.end(), std::back_inserter(result));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline std::u32string utf8to32(std::string_view s)
|
||||||
|
{
|
||||||
|
std::u32string result;
|
||||||
|
utf8to32(s.begin(), s.end(), std::back_inserter(result));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline std::size_t find_invalid(std::string_view s)
|
||||||
|
{
|
||||||
|
std::string_view::const_iterator invalid = find_invalid(s.begin(), s.end());
|
||||||
|
return (invalid == s.end()) ? std::string_view::npos : static_cast<std::size_t>(invalid - s.begin());
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool is_valid(std::string_view s)
|
||||||
|
{
|
||||||
|
return is_valid(s.begin(), s.end());
|
||||||
|
}
|
||||||
|
|
||||||
|
inline std::string replace_invalid(std::string_view s, char32_t replacement)
|
||||||
|
{
|
||||||
|
std::string result;
|
||||||
|
replace_invalid(s.begin(), s.end(), std::back_inserter(result), replacement);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline std::string replace_invalid(std::string_view s)
|
||||||
|
{
|
||||||
|
std::string result;
|
||||||
|
replace_invalid(s.begin(), s.end(), std::back_inserter(result));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool starts_with_bom(std::string_view s)
|
||||||
|
{
|
||||||
|
return starts_with_bom(s.begin(), s.end());
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace utf8
|
||||||
|
|
||||||
|
#endif // header guard
|
||||||
|
|
|
@ -37,24 +37,7 @@ namespace utf8
|
||||||
template <typename octet_iterator>
|
template <typename octet_iterator>
|
||||||
octet_iterator append(uint32_t cp, octet_iterator result)
|
octet_iterator append(uint32_t cp, octet_iterator result)
|
||||||
{
|
{
|
||||||
if (cp < 0x80) // one octet
|
return internal::append(cp, result);
|
||||||
*(result++) = static_cast<uint8_t>(cp);
|
|
||||||
else if (cp < 0x800) { // two octets
|
|
||||||
*(result++) = static_cast<uint8_t>((cp >> 6) | 0xc0);
|
|
||||||
*(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80);
|
|
||||||
}
|
|
||||||
else if (cp < 0x10000) { // three octets
|
|
||||||
*(result++) = static_cast<uint8_t>((cp >> 12) | 0xe0);
|
|
||||||
*(result++) = static_cast<uint8_t>(((cp >> 6) & 0x3f) | 0x80);
|
|
||||||
*(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80);
|
|
||||||
}
|
|
||||||
else { // four octets
|
|
||||||
*(result++) = static_cast<uint8_t>((cp >> 18) | 0xf0);
|
|
||||||
*(result++) = static_cast<uint8_t>(((cp >> 12) & 0x3f)| 0x80);
|
|
||||||
*(result++) = static_cast<uint8_t>(((cp >> 6) & 0x3f) | 0x80);
|
|
||||||
*(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename octet_iterator, typename output_iterator>
|
template <typename octet_iterator, typename output_iterator>
|
||||||
|
|
|
@ -10,7 +10,7 @@ endif()
|
||||||
project(zlib C)
|
project(zlib C)
|
||||||
SET (ZLIB_VERSION_MAJOR 1)
|
SET (ZLIB_VERSION_MAJOR 1)
|
||||||
SET (ZLIB_VERSION_MINOR 2)
|
SET (ZLIB_VERSION_MINOR 2)
|
||||||
SET (ZLIB_VERSION_PATCH 11)
|
SET (ZLIB_VERSION_PATCH 13)
|
||||||
SET (ZLIB_VERSION ${ZLIB_VERSION_MAJOR}.${ZLIB_VERSION_MINOR}.${ZLIB_VERSION_PATCH})
|
SET (ZLIB_VERSION ${ZLIB_VERSION_MAJOR}.${ZLIB_VERSION_MINOR}.${ZLIB_VERSION_PATCH})
|
||||||
SET (ZLIB_SOVERSION 1)
|
SET (ZLIB_SOVERSION 1)
|
||||||
SET (PROJECT_VERSION "${ZLIB_VERSION}")
|
SET (PROJECT_VERSION "${ZLIB_VERSION}")
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,22 @@
|
||||||
|
Copyright notice:
|
||||||
|
|
||||||
|
(C) 1995-2022 Jean-loup Gailly and Mark Adler
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
|
||||||
|
Jean-loup Gailly Mark Adler
|
||||||
|
jloup@gzip.org madler@alumni.caltech.edu
|
|
@ -19,7 +19,7 @@
|
||||||
memory, Z_BUF_ERROR if there was not enough room in the output buffer,
|
memory, Z_BUF_ERROR if there was not enough room in the output buffer,
|
||||||
Z_STREAM_ERROR if the level parameter is invalid.
|
Z_STREAM_ERROR if the level parameter is invalid.
|
||||||
*/
|
*/
|
||||||
int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
|
int ZEXPORT compress2(dest, destLen, source, sourceLen, level)
|
||||||
Bytef *dest;
|
Bytef *dest;
|
||||||
uLongf *destLen;
|
uLongf *destLen;
|
||||||
const Bytef *source;
|
const Bytef *source;
|
||||||
|
@ -65,7 +65,7 @@ int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
|
||||||
|
|
||||||
/* ===========================================================================
|
/* ===========================================================================
|
||||||
*/
|
*/
|
||||||
int ZEXPORT compress (dest, destLen, source, sourceLen)
|
int ZEXPORT compress(dest, destLen, source, sourceLen)
|
||||||
Bytef *dest;
|
Bytef *dest;
|
||||||
uLongf *destLen;
|
uLongf *destLen;
|
||||||
const Bytef *source;
|
const Bytef *source;
|
||||||
|
@ -78,7 +78,7 @@ int ZEXPORT compress (dest, destLen, source, sourceLen)
|
||||||
If the default memLevel or windowBits for deflateInit() is changed, then
|
If the default memLevel or windowBits for deflateInit() is changed, then
|
||||||
this function needs to be updated.
|
this function needs to be updated.
|
||||||
*/
|
*/
|
||||||
uLong ZEXPORT compressBound (sourceLen)
|
uLong ZEXPORT compressBound(sourceLen)
|
||||||
uLong sourceLen;
|
uLong sourceLen;
|
||||||
{
|
{
|
||||||
return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
|
return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
All files under this contrib directory are UNSUPPORTED. There were
|
All files under this contrib directory are UNSUPPORTED. They were
|
||||||
provided by users of zlib and were not tested by the authors of zlib.
|
provided by users of zlib and were not tested by the authors of zlib.
|
||||||
Use at your own risk. Please contact the authors of the contributions
|
Use at your own risk. Please contact the authors of the contributions
|
||||||
for help about these, not the zlib authors. Thanks.
|
for help about these, not the zlib authors. Thanks.
|
||||||
|
@ -8,14 +8,6 @@ ada/ by Dmitriy Anisimkov <anisimkov@yahoo.com>
|
||||||
Support for Ada
|
Support for Ada
|
||||||
See http://zlib-ada.sourceforge.net/
|
See http://zlib-ada.sourceforge.net/
|
||||||
|
|
||||||
amd64/ by Mikhail Teterin <mi@ALDAN.algebra.com>
|
|
||||||
asm code for AMD64
|
|
||||||
See patch at http://www.freebsd.org/cgi/query-pr.cgi?pr=bin/96393
|
|
||||||
|
|
||||||
asm686/ by Brian Raiter <breadbox@muppetlabs.com>
|
|
||||||
asm code for Pentium and PPro/PII, using the AT&T (GNU as) syntax
|
|
||||||
See http://www.muppetlabs.com/~breadbox/software/assembly.html
|
|
||||||
|
|
||||||
blast/ by Mark Adler <madler@alumni.caltech.edu>
|
blast/ by Mark Adler <madler@alumni.caltech.edu>
|
||||||
Decompressor for output of PKWare Data Compression Library (DCL)
|
Decompressor for output of PKWare Data Compression Library (DCL)
|
||||||
|
|
||||||
|
@ -32,9 +24,6 @@ gcc_gvmat64/by Gilles Vollant <info@winimage.com>
|
||||||
infback9/ by Mark Adler <madler@alumni.caltech.edu>
|
infback9/ by Mark Adler <madler@alumni.caltech.edu>
|
||||||
Unsupported diffs to infback to decode the deflate64 format
|
Unsupported diffs to infback to decode the deflate64 format
|
||||||
|
|
||||||
inflate86/ by Chris Anderson <christop@charm.net>
|
|
||||||
Tuned x86 gcc asm code to replace inflate_fast()
|
|
||||||
|
|
||||||
iostream/ by Kevin Ruland <kevin@rodin.wustl.edu>
|
iostream/ by Kevin Ruland <kevin@rodin.wustl.edu>
|
||||||
A C++ I/O streams interface to the zlib gz* functions
|
A C++ I/O streams interface to the zlib gz* functions
|
||||||
|
|
||||||
|
@ -45,16 +34,6 @@ iostream3/ by Ludwig Schwardt <schwardt@sun.ac.za>
|
||||||
and Kevin Ruland <kevin@rodin.wustl.edu>
|
and Kevin Ruland <kevin@rodin.wustl.edu>
|
||||||
Yet another C++ I/O streams interface
|
Yet another C++ I/O streams interface
|
||||||
|
|
||||||
masmx64/ by Gilles Vollant <info@winimage.com>
|
|
||||||
x86 64-bit (AMD64 and Intel EM64t) code for x64 assembler to
|
|
||||||
replace longest_match() and inflate_fast(), also masm x86
|
|
||||||
64-bits translation of Chris Anderson inflate_fast()
|
|
||||||
|
|
||||||
masmx86/ by Gilles Vollant <info@winimage.com>
|
|
||||||
x86 asm code to replace longest_match() and inflate_fast(),
|
|
||||||
for Visual C++ and MASM (32 bits).
|
|
||||||
Based on Brian Raiter (asm686) and Chris Anderson (inflate86)
|
|
||||||
|
|
||||||
minizip/ by Gilles Vollant <info@winimage.com>
|
minizip/ by Gilles Vollant <info@winimage.com>
|
||||||
Mini zip and unzip based on zlib
|
Mini zip and unzip based on zlib
|
||||||
Includes Zip64 support by Mathias Svensson <mathias@result42.com>
|
Includes Zip64 support by Mathias Svensson <mathias@result42.com>
|
||||||
|
|
|
@ -57,7 +57,7 @@ int blast(blast_in infun, void *inhow, blast_out outfun, void *outhow,
|
||||||
* use by the application to pass an input descriptor to infun(), if desired.
|
* use by the application to pass an input descriptor to infun(), if desired.
|
||||||
*
|
*
|
||||||
* If left and in are not NULL and *left is not zero when blast() is called,
|
* If left and in are not NULL and *left is not zero when blast() is called,
|
||||||
* then the *left bytes are *in are consumed for input before infun() is used.
|
* then the *left bytes at *in are consumed for input before infun() is used.
|
||||||
*
|
*
|
||||||
* The output function is invoked: err = outfun(how, buf, len), where the bytes
|
* The output function is invoked: err = outfun(how, buf, len), where the bytes
|
||||||
* to be written are buf[0..len-1]. If err is not zero, then blast() returns
|
* to be written are buf[0..len-1]. If err is not zero, then blast() returns
|
||||||
|
|
|
@ -152,7 +152,7 @@ procedure DecompressToUserBuf(const InBuf: Pointer; InBytes: Integer;
|
||||||
const OutBuf: Pointer; BufSize: Integer);
|
const OutBuf: Pointer; BufSize: Integer);
|
||||||
|
|
||||||
const
|
const
|
||||||
zlib_version = '1.2.11';
|
zlib_version = '1.2.13';
|
||||||
|
|
||||||
type
|
type
|
||||||
EZlibError = class(Exception);
|
EZlibError = class(Exception);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
// © Copyright Henrik Ravn 2004
|
// © Copyright Henrik Ravn 2004
|
||||||
//
|
//
|
||||||
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
|
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
// © Copyright Henrik Ravn 2004
|
// © Copyright Henrik Ravn 2004
|
||||||
//
|
//
|
||||||
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
|
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
// © Copyright Henrik Ravn 2004
|
// © Copyright Henrik Ravn 2004
|
||||||
//
|
//
|
||||||
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
|
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
// © Copyright Henrik Ravn 2004
|
// © Copyright Henrik Ravn 2004
|
||||||
//
|
//
|
||||||
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
|
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
// © Copyright Henrik Ravn 2004
|
// © Copyright Henrik Ravn 2004
|
||||||
//
|
//
|
||||||
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
|
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
// © Copyright Henrik Ravn 2004
|
// © Copyright Henrik Ravn 2004
|
||||||
//
|
//
|
||||||
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
|
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
// © Copyright Henrik Ravn 2004
|
// © Copyright Henrik Ravn 2004
|
||||||
//
|
//
|
||||||
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
|
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
|
@ -156,7 +156,7 @@ namespace DotZLibTests
|
||||||
public void Info_Version()
|
public void Info_Version()
|
||||||
{
|
{
|
||||||
Info info = new Info();
|
Info info = new Info();
|
||||||
Assert.AreEqual("1.2.11", Info.Version);
|
Assert.AreEqual("1.2.13", Info.Version);
|
||||||
Assert.AreEqual(32, info.SizeOfUInt);
|
Assert.AreEqual(32, info.SizeOfUInt);
|
||||||
Assert.AreEqual(32, info.SizeOfULong);
|
Assert.AreEqual(32, info.SizeOfULong);
|
||||||
Assert.AreEqual(32, info.SizeOfPointer);
|
Assert.AreEqual(32, info.SizeOfPointer);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* inftree9.c -- generate Huffman trees for efficient decoding
|
/* inftree9.c -- generate Huffman trees for efficient decoding
|
||||||
* Copyright (C) 1995-2017 Mark Adler
|
* Copyright (C) 1995-2022 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 inflate9_copyright[] =
|
const char inflate9_copyright[] =
|
||||||
" inflate9 1.2.11 Copyright 1995-2017 Mark Adler ";
|
" inflate9 1.2.13 Copyright 1995-2022 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
|
||||||
|
@ -64,7 +64,7 @@ unsigned short FAR *work;
|
||||||
static const unsigned short lext[31] = { /* Length codes 257..285 extra */
|
static const unsigned short lext[31] = { /* Length codes 257..285 extra */
|
||||||
128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129,
|
128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129,
|
||||||
130, 130, 130, 130, 131, 131, 131, 131, 132, 132, 132, 132,
|
130, 130, 130, 130, 131, 131, 131, 131, 132, 132, 132, 132,
|
||||||
133, 133, 133, 133, 144, 77, 202};
|
133, 133, 133, 133, 144, 194, 65};
|
||||||
static const unsigned short dbase[32] = { /* Distance codes 0..31 base */
|
static const unsigned short dbase[32] = { /* Distance codes 0..31 base */
|
||||||
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49,
|
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49,
|
||||||
65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073,
|
65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073,
|
||||||
|
|
|
@ -38,7 +38,7 @@ typedef struct {
|
||||||
/* Maximum size of the dynamic table. The maximum number of code structures is
|
/* Maximum size of the dynamic table. The maximum number of code structures is
|
||||||
1446, which is the sum of 852 for literal/length codes and 594 for distance
|
1446, which is the sum of 852 for literal/length codes and 594 for distance
|
||||||
codes. These values were found by exhaustive searches using the program
|
codes. These values were found by exhaustive searches using the program
|
||||||
examples/enough.c found in the zlib distribtution. The arguments to that
|
examples/enough.c found in the zlib distribution. The arguments to that
|
||||||
program are the number of symbols, the initial root table size, and the
|
program are the number of symbols, the initial root table size, and the
|
||||||
maximum bit length of a code. "enough 286 9 15" for literal/length codes
|
maximum bit length of a code. "enough 286 9 15" for literal/length codes
|
||||||
returns returns 852, and "enough 32 6 15" for distance codes returns 594.
|
returns returns 852, and "enough 32 6 15" for distance codes returns 594.
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# -*- Autoconf -*-
|
# -*- Autoconf -*-
|
||||||
# Process this file with autoconf to produce a configure script.
|
# Process this file with autoconf to produce a configure script.
|
||||||
|
|
||||||
AC_INIT([minizip], [1.2.11], [bugzilla.redhat.com])
|
AC_INIT([minizip], [1.2.13], [bugzilla.redhat.com])
|
||||||
AC_CONFIG_SRCDIR([minizip.c])
|
AC_CONFIG_SRCDIR([minizip.c])
|
||||||
AM_INIT_AUTOMAKE([foreign])
|
AM_INIT_AUTOMAKE([foreign])
|
||||||
LT_INIT
|
LT_INIT
|
||||||
|
|
|
@ -38,6 +38,7 @@ static int decrypt_byte(unsigned long* pkeys, const z_crc_t* pcrc_32_tab)
|
||||||
* unpredictable manner on 16-bit systems; not a problem
|
* unpredictable manner on 16-bit systems; not a problem
|
||||||
* with any known compiler so far, though */
|
* with any known compiler so far, though */
|
||||||
|
|
||||||
|
(void)pcrc_32_tab;
|
||||||
temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2;
|
temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2;
|
||||||
return (int)(((temp * (temp ^ 1)) >> 8) & 0xff);
|
return (int)(((temp * (temp ^ 1)) >> 8) & 0xff);
|
||||||
}
|
}
|
||||||
|
@ -77,24 +78,24 @@ static void init_keys(const char* passwd,unsigned long* pkeys,const z_crc_t* pcr
|
||||||
(update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab)))
|
(update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab)))
|
||||||
|
|
||||||
#define zencode(pkeys,pcrc_32_tab,c,t) \
|
#define zencode(pkeys,pcrc_32_tab,c,t) \
|
||||||
(t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), t^(c))
|
(t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), (Byte)t^(c))
|
||||||
|
|
||||||
#ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED
|
#ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED
|
||||||
|
|
||||||
#define RAND_HEAD_LEN 12
|
#define RAND_HEAD_LEN 12
|
||||||
/* "last resort" source for second part of crypt seed pattern */
|
/* "last resort" source for second part of crypt seed pattern */
|
||||||
# ifndef ZCR_SEED2
|
# ifndef ZCR_SEED2
|
||||||
# define ZCR_SEED2 3141592654UL /* use PI as default pattern */
|
# define ZCR_SEED2 3141592654UL /* use PI as default pattern */
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
static int crypthead(const char* passwd, /* password string */
|
static unsigned crypthead(const char* passwd, /* password string */
|
||||||
unsigned char* buf, /* where to write header */
|
unsigned char* buf, /* where to write header */
|
||||||
int bufSize,
|
int bufSize,
|
||||||
unsigned long* pkeys,
|
unsigned long* pkeys,
|
||||||
const z_crc_t* pcrc_32_tab,
|
const z_crc_t* pcrc_32_tab,
|
||||||
unsigned long crcForCrypting)
|
unsigned long crcForCrypting)
|
||||||
{
|
{
|
||||||
int n; /* index in random header */
|
unsigned n; /* index in random header */
|
||||||
int t; /* temporary */
|
int t; /* temporary */
|
||||||
int c; /* random byte */
|
int c; /* random byte */
|
||||||
unsigned char header[RAND_HEAD_LEN-2]; /* random header */
|
unsigned char header[RAND_HEAD_LEN-2]; /* random header */
|
||||||
|
|
|
@ -58,7 +58,7 @@ ZPOS64_T call_ztell64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream
|
||||||
return (*(pfilefunc->zfile_func64.ztell64_file)) (pfilefunc->zfile_func64.opaque,filestream);
|
return (*(pfilefunc->zfile_func64.ztell64_file)) (pfilefunc->zfile_func64.opaque,filestream);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
uLong tell_uLong = (*(pfilefunc->ztell32_file))(pfilefunc->zfile_func64.opaque,filestream);
|
uLong tell_uLong = (uLong)(*(pfilefunc->ztell32_file))(pfilefunc->zfile_func64.opaque,filestream);
|
||||||
if ((tell_uLong) == MAXU32)
|
if ((tell_uLong) == MAXU32)
|
||||||
return (ZPOS64_T)-1;
|
return (ZPOS64_T)-1;
|
||||||
else
|
else
|
||||||
|
@ -96,6 +96,7 @@ static voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* filename, in
|
||||||
{
|
{
|
||||||
FILE* file = NULL;
|
FILE* file = NULL;
|
||||||
const char* mode_fopen = NULL;
|
const char* mode_fopen = NULL;
|
||||||
|
(void)opaque;
|
||||||
if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
|
if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
|
||||||
mode_fopen = "rb";
|
mode_fopen = "rb";
|
||||||
else
|
else
|
||||||
|
@ -114,6 +115,7 @@ static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename,
|
||||||
{
|
{
|
||||||
FILE* file = NULL;
|
FILE* file = NULL;
|
||||||
const char* mode_fopen = NULL;
|
const char* mode_fopen = NULL;
|
||||||
|
(void)opaque;
|
||||||
if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
|
if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
|
||||||
mode_fopen = "rb";
|
mode_fopen = "rb";
|
||||||
else
|
else
|
||||||
|
@ -132,6 +134,7 @@ static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename,
|
||||||
static uLong ZCALLBACK fread_file_func (voidpf opaque, voidpf stream, void* buf, uLong size)
|
static uLong ZCALLBACK fread_file_func (voidpf opaque, voidpf stream, void* buf, uLong size)
|
||||||
{
|
{
|
||||||
uLong ret;
|
uLong ret;
|
||||||
|
(void)opaque;
|
||||||
ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream);
|
ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -139,6 +142,7 @@ static uLong ZCALLBACK fread_file_func (voidpf opaque, voidpf stream, void* buf,
|
||||||
static uLong ZCALLBACK fwrite_file_func (voidpf opaque, voidpf stream, const void* buf, uLong size)
|
static uLong ZCALLBACK fwrite_file_func (voidpf opaque, voidpf stream, const void* buf, uLong size)
|
||||||
{
|
{
|
||||||
uLong ret;
|
uLong ret;
|
||||||
|
(void)opaque;
|
||||||
ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream);
|
ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -146,6 +150,7 @@ static uLong ZCALLBACK fwrite_file_func (voidpf opaque, voidpf stream, const voi
|
||||||
static long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream)
|
static long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream)
|
||||||
{
|
{
|
||||||
long ret;
|
long ret;
|
||||||
|
(void)opaque;
|
||||||
ret = ftell((FILE *)stream);
|
ret = ftell((FILE *)stream);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -154,7 +159,8 @@ static long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream)
|
||||||
static ZPOS64_T ZCALLBACK ftell64_file_func (voidpf opaque, voidpf stream)
|
static ZPOS64_T ZCALLBACK ftell64_file_func (voidpf opaque, voidpf stream)
|
||||||
{
|
{
|
||||||
ZPOS64_T ret;
|
ZPOS64_T ret;
|
||||||
ret = FTELLO_FUNC((FILE *)stream);
|
(void)opaque;
|
||||||
|
ret = (ZPOS64_T)FTELLO_FUNC((FILE *)stream);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,6 +168,7 @@ static long ZCALLBACK fseek_file_func (voidpf opaque, voidpf stream, uLong offs
|
||||||
{
|
{
|
||||||
int fseek_origin=0;
|
int fseek_origin=0;
|
||||||
long ret;
|
long ret;
|
||||||
|
(void)opaque;
|
||||||
switch (origin)
|
switch (origin)
|
||||||
{
|
{
|
||||||
case ZLIB_FILEFUNC_SEEK_CUR :
|
case ZLIB_FILEFUNC_SEEK_CUR :
|
||||||
|
@ -176,7 +183,7 @@ static long ZCALLBACK fseek_file_func (voidpf opaque, voidpf stream, uLong offs
|
||||||
default: return -1;
|
default: return -1;
|
||||||
}
|
}
|
||||||
ret = 0;
|
ret = 0;
|
||||||
if (fseek((FILE *)stream, offset, fseek_origin) != 0)
|
if (fseek((FILE *)stream, (long)offset, fseek_origin) != 0)
|
||||||
ret = -1;
|
ret = -1;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -185,6 +192,7 @@ static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T
|
||||||
{
|
{
|
||||||
int fseek_origin=0;
|
int fseek_origin=0;
|
||||||
long ret;
|
long ret;
|
||||||
|
(void)opaque;
|
||||||
switch (origin)
|
switch (origin)
|
||||||
{
|
{
|
||||||
case ZLIB_FILEFUNC_SEEK_CUR :
|
case ZLIB_FILEFUNC_SEEK_CUR :
|
||||||
|
@ -200,7 +208,7 @@ static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T
|
||||||
}
|
}
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
if(FSEEKO_FUNC((FILE *)stream, offset, fseek_origin) != 0)
|
if(FSEEKO_FUNC((FILE *)stream, (z_off_t)offset, fseek_origin) != 0)
|
||||||
ret = -1;
|
ret = -1;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -210,6 +218,7 @@ static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T
|
||||||
static int ZCALLBACK fclose_file_func (voidpf opaque, voidpf stream)
|
static int ZCALLBACK fclose_file_func (voidpf opaque, voidpf stream)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
(void)opaque;
|
||||||
ret = fclose((FILE *)stream);
|
ret = fclose((FILE *)stream);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -217,6 +226,7 @@ static int ZCALLBACK fclose_file_func (voidpf opaque, voidpf stream)
|
||||||
static int ZCALLBACK ferror_file_func (voidpf opaque, voidpf stream)
|
static int ZCALLBACK ferror_file_func (voidpf opaque, voidpf stream)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
(void)opaque;
|
||||||
ret = ferror((FILE *)stream);
|
ret = ferror((FILE *)stream);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@
|
||||||
#define ftello64 ftell
|
#define ftello64 ftell
|
||||||
#define fseeko64 fseek
|
#define fseeko64 fseek
|
||||||
#else
|
#else
|
||||||
#ifdef __FreeBSD__
|
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
|
||||||
#define fopen64 fopen
|
#define fopen64 fopen
|
||||||
#define ftello64 ftello
|
#define ftello64 ftello
|
||||||
#define fseeko64 fseeko
|
#define fseeko64 fseeko
|
||||||
|
@ -91,8 +91,7 @@ typedef 64BIT_INT_CUSTOM_TYPE ZPOS64_T;
|
||||||
typedef uint64_t ZPOS64_T;
|
typedef uint64_t ZPOS64_T;
|
||||||
#else
|
#else
|
||||||
|
|
||||||
/* Maximum unsigned 32-bit value used as placeholder for zip64 */
|
|
||||||
#define MAXU32 0xffffffff
|
|
||||||
|
|
||||||
#if defined(_MSC_VER) || defined(__BORLANDC__)
|
#if defined(_MSC_VER) || defined(__BORLANDC__)
|
||||||
typedef unsigned __int64 ZPOS64_T;
|
typedef unsigned __int64 ZPOS64_T;
|
||||||
|
@ -102,7 +101,10 @@ typedef unsigned long long int ZPOS64_T;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Maximum unsigned 32-bit value used as placeholder for zip64 */
|
||||||
|
#ifndef MAXU32
|
||||||
|
#define MAXU32 (0xffffffff)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
|
@ -28,6 +28,11 @@
|
||||||
|
|
||||||
// see Include/shared/winapifamily.h in the Windows Kit
|
// see Include/shared/winapifamily.h in the Windows Kit
|
||||||
#if defined(WINAPI_FAMILY_PARTITION) && (!(defined(IOWIN32_USING_WINRT_API)))
|
#if defined(WINAPI_FAMILY_PARTITION) && (!(defined(IOWIN32_USING_WINRT_API)))
|
||||||
|
|
||||||
|
#if !defined(WINAPI_FAMILY_ONE_PARTITION)
|
||||||
|
#define WINAPI_FAMILY_ONE_PARTITION(PartitionSet, Partition) ((WINAPI_FAMILY & PartitionSet) == Partition)
|
||||||
|
#endif
|
||||||
|
|
||||||
#if WINAPI_FAMILY_ONE_PARTITION(WINAPI_FAMILY, WINAPI_PARTITION_APP)
|
#if WINAPI_FAMILY_ONE_PARTITION(WINAPI_FAMILY, WINAPI_PARTITION_APP)
|
||||||
#define IOWIN32_USING_WINRT_API 1
|
#define IOWIN32_USING_WINRT_API 1
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -45,6 +45,7 @@
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
# include <direct.h>
|
# include <direct.h>
|
||||||
|
@ -80,7 +81,7 @@
|
||||||
filename : the filename of the file where date/time must be modified
|
filename : the filename of the file where date/time must be modified
|
||||||
dosdate : the new date at the MSDos format (4 bytes)
|
dosdate : the new date at the MSDos format (4 bytes)
|
||||||
tmu_date : the SAME new date at the tm_unz format */
|
tmu_date : the SAME new date at the tm_unz format */
|
||||||
void change_file_date(filename,dosdate,tmu_date)
|
static void change_file_date(filename,dosdate,tmu_date)
|
||||||
const char *filename;
|
const char *filename;
|
||||||
uLong dosdate;
|
uLong dosdate;
|
||||||
tm_unz tmu_date;
|
tm_unz tmu_date;
|
||||||
|
@ -97,7 +98,8 @@ void change_file_date(filename,dosdate,tmu_date)
|
||||||
SetFileTime(hFile,&ftm,&ftLastAcc,&ftm);
|
SetFileTime(hFile,&ftm,&ftLastAcc,&ftm);
|
||||||
CloseHandle(hFile);
|
CloseHandle(hFile);
|
||||||
#else
|
#else
|
||||||
#ifdef unix || __APPLE__
|
#if defined(unix) || defined(__APPLE__)
|
||||||
|
(void)dosdate;
|
||||||
struct utimbuf ut;
|
struct utimbuf ut;
|
||||||
struct tm newdate;
|
struct tm newdate;
|
||||||
newdate.tm_sec = tmu_date.tm_sec;
|
newdate.tm_sec = tmu_date.tm_sec;
|
||||||
|
@ -121,7 +123,7 @@ void change_file_date(filename,dosdate,tmu_date)
|
||||||
/* mymkdir and change_file_date are not 100 % portable
|
/* mymkdir and change_file_date are not 100 % portable
|
||||||
As I don't know well Unix, I wait feedback for the unix portion */
|
As I don't know well Unix, I wait feedback for the unix portion */
|
||||||
|
|
||||||
int mymkdir(dirname)
|
static int mymkdir(dirname)
|
||||||
const char* dirname;
|
const char* dirname;
|
||||||
{
|
{
|
||||||
int ret=0;
|
int ret=0;
|
||||||
|
@ -135,14 +137,14 @@ int mymkdir(dirname)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int makedir (newdir)
|
static int makedir (newdir)
|
||||||
char *newdir;
|
const char *newdir;
|
||||||
{
|
{
|
||||||
char *buffer ;
|
char *buffer ;
|
||||||
char *p;
|
char *p;
|
||||||
int len = (int)strlen(newdir);
|
size_t len = strlen(newdir);
|
||||||
|
|
||||||
if (len <= 0)
|
if (len == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
buffer = (char*)malloc(len+1);
|
buffer = (char*)malloc(len+1);
|
||||||
|
@ -185,13 +187,13 @@ int makedir (newdir)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_banner()
|
static void do_banner()
|
||||||
{
|
{
|
||||||
printf("MiniUnz 1.01b, demo of zLib + Unz package written by Gilles Vollant\n");
|
printf("MiniUnz 1.01b, demo of zLib + Unz package written by Gilles Vollant\n");
|
||||||
printf("more info at http://www.winimage.com/zLibDll/unzip.html\n\n");
|
printf("more info at http://www.winimage.com/zLibDll/unzip.html\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_help()
|
static void do_help()
|
||||||
{
|
{
|
||||||
printf("Usage : miniunz [-e] [-x] [-v] [-l] [-o] [-p password] file.zip [file_to_extr.] [-d extractdir]\n\n" \
|
printf("Usage : miniunz [-e] [-x] [-v] [-l] [-o] [-p password] file.zip [file_to_extr.] [-d extractdir]\n\n" \
|
||||||
" -e Extract without pathname (junk paths)\n" \
|
" -e Extract without pathname (junk paths)\n" \
|
||||||
|
@ -203,7 +205,7 @@ void do_help()
|
||||||
" -p extract crypted file using password\n\n");
|
" -p extract crypted file using password\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Display64BitsSize(ZPOS64_T n, int size_char)
|
static void Display64BitsSize(ZPOS64_T n, int size_char)
|
||||||
{
|
{
|
||||||
/* to avoid compatibility problem , we do here the conversion */
|
/* to avoid compatibility problem , we do here the conversion */
|
||||||
char number[21];
|
char number[21];
|
||||||
|
@ -231,7 +233,7 @@ void Display64BitsSize(ZPOS64_T n, int size_char)
|
||||||
printf("%s",&number[pos_string]);
|
printf("%s",&number[pos_string]);
|
||||||
}
|
}
|
||||||
|
|
||||||
int do_list(uf)
|
static int do_list(uf)
|
||||||
unzFile uf;
|
unzFile uf;
|
||||||
{
|
{
|
||||||
uLong i;
|
uLong i;
|
||||||
|
@ -309,7 +311,7 @@ int do_list(uf)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password)
|
static int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password)
|
||||||
unzFile uf;
|
unzFile uf;
|
||||||
const int* popt_extract_without_path;
|
const int* popt_extract_without_path;
|
||||||
int* popt_overwrite;
|
int* popt_overwrite;
|
||||||
|
@ -324,7 +326,6 @@ int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password)
|
||||||
uInt size_buf;
|
uInt size_buf;
|
||||||
|
|
||||||
unz_file_info64 file_info;
|
unz_file_info64 file_info;
|
||||||
uLong ratio=0;
|
|
||||||
err = unzGetCurrentFileInfo64(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0);
|
err = unzGetCurrentFileInfo64(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0);
|
||||||
|
|
||||||
if (err!=UNZ_OK)
|
if (err!=UNZ_OK)
|
||||||
|
@ -439,7 +440,7 @@ int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (err>0)
|
if (err>0)
|
||||||
if (fwrite(buf,err,1,fout)!=1)
|
if (fwrite(buf,(unsigned)err,1,fout)!=1)
|
||||||
{
|
{
|
||||||
printf("error in writing extracted file\n");
|
printf("error in writing extracted file\n");
|
||||||
err=UNZ_ERRNO;
|
err=UNZ_ERRNO;
|
||||||
|
@ -472,7 +473,7 @@ int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int do_extract(uf,opt_extract_without_path,opt_overwrite,password)
|
static int do_extract(uf,opt_extract_without_path,opt_overwrite,password)
|
||||||
unzFile uf;
|
unzFile uf;
|
||||||
int opt_extract_without_path;
|
int opt_extract_without_path;
|
||||||
int opt_overwrite;
|
int opt_overwrite;
|
||||||
|
@ -481,7 +482,6 @@ int do_extract(uf,opt_extract_without_path,opt_overwrite,password)
|
||||||
uLong i;
|
uLong i;
|
||||||
unz_global_info64 gi;
|
unz_global_info64 gi;
|
||||||
int err;
|
int err;
|
||||||
FILE* fout=NULL;
|
|
||||||
|
|
||||||
err = unzGetGlobalInfo64(uf,&gi);
|
err = unzGetGlobalInfo64(uf,&gi);
|
||||||
if (err!=UNZ_OK)
|
if (err!=UNZ_OK)
|
||||||
|
@ -508,14 +508,13 @@ int do_extract(uf,opt_extract_without_path,opt_overwrite,password)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int do_extract_onefile(uf,filename,opt_extract_without_path,opt_overwrite,password)
|
static int do_extract_onefile(uf,filename,opt_extract_without_path,opt_overwrite,password)
|
||||||
unzFile uf;
|
unzFile uf;
|
||||||
const char* filename;
|
const char* filename;
|
||||||
int opt_extract_without_path;
|
int opt_extract_without_path;
|
||||||
int opt_overwrite;
|
int opt_overwrite;
|
||||||
const char* password;
|
const char* password;
|
||||||
{
|
{
|
||||||
int err = UNZ_OK;
|
|
||||||
if (unzLocateFile(uf,filename,CASESENSITIVITY)!=UNZ_OK)
|
if (unzLocateFile(uf,filename,CASESENSITIVITY)!=UNZ_OK)
|
||||||
{
|
{
|
||||||
printf("file %s not found in the zipfile\n",filename);
|
printf("file %s not found in the zipfile\n",filename);
|
||||||
|
@ -565,7 +564,7 @@ int main(argc,argv)
|
||||||
|
|
||||||
while ((*p)!='\0')
|
while ((*p)!='\0')
|
||||||
{
|
{
|
||||||
char c=*(p++);;
|
char c=*(p++);
|
||||||
if ((c=='l') || (c=='L'))
|
if ((c=='l') || (c=='L'))
|
||||||
opt_do_list = 1;
|
opt_do_list = 1;
|
||||||
if ((c=='v') || (c=='V'))
|
if ((c=='v') || (c=='V'))
|
||||||
|
|
|
@ -71,8 +71,8 @@
|
||||||
#define MAXFILENAME (256)
|
#define MAXFILENAME (256)
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
uLong filetime(f, tmzip, dt)
|
static int filetime(f, tmzip, dt)
|
||||||
char *f; /* name of file to get info on */
|
const char *f; /* name of file to get info on */
|
||||||
tm_zip *tmzip; /* return value: access, modific. and creation times */
|
tm_zip *tmzip; /* return value: access, modific. and creation times */
|
||||||
uLong *dt; /* dostime */
|
uLong *dt; /* dostime */
|
||||||
{
|
{
|
||||||
|
@ -94,12 +94,13 @@ uLong filetime(f, tmzip, dt)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#ifdef unix || __APPLE__
|
#if defined(unix) || defined(__APPLE__)
|
||||||
uLong filetime(f, tmzip, dt)
|
static int filetime(f, tmzip, dt)
|
||||||
char *f; /* name of file to get info on */
|
const char *f; /* name of file to get info on */
|
||||||
tm_zip *tmzip; /* return value: access, modific. and creation times */
|
tm_zip *tmzip; /* return value: access, modific. and creation times */
|
||||||
uLong *dt; /* dostime */
|
uLong *dt; /* dostime */
|
||||||
{
|
{
|
||||||
|
(void)dt;
|
||||||
int ret=0;
|
int ret=0;
|
||||||
struct stat s; /* results of stat() */
|
struct stat s; /* results of stat() */
|
||||||
struct tm* filedate;
|
struct tm* filedate;
|
||||||
|
@ -108,7 +109,7 @@ uLong filetime(f, tmzip, dt)
|
||||||
if (strcmp(f,"-")!=0)
|
if (strcmp(f,"-")!=0)
|
||||||
{
|
{
|
||||||
char name[MAXFILENAME+1];
|
char name[MAXFILENAME+1];
|
||||||
int len = strlen(f);
|
size_t len = strlen(f);
|
||||||
if (len > MAXFILENAME)
|
if (len > MAXFILENAME)
|
||||||
len = MAXFILENAME;
|
len = MAXFILENAME;
|
||||||
|
|
||||||
|
@ -138,7 +139,7 @@ uLong filetime(f, tmzip, dt)
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
uLong filetime(f, tmzip, dt)
|
uLong filetime(f, tmzip, dt)
|
||||||
char *f; /* name of file to get info on */
|
const char *f; /* name of file to get info on */
|
||||||
tm_zip *tmzip; /* return value: access, modific. and creation times */
|
tm_zip *tmzip; /* return value: access, modific. and creation times */
|
||||||
uLong *dt; /* dostime */
|
uLong *dt; /* dostime */
|
||||||
{
|
{
|
||||||
|
@ -150,7 +151,7 @@ uLong filetime(f, tmzip, dt)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int check_exist_file(filename)
|
static int check_exist_file(filename)
|
||||||
const char* filename;
|
const char* filename;
|
||||||
{
|
{
|
||||||
FILE* ftestexist;
|
FILE* ftestexist;
|
||||||
|
@ -163,13 +164,13 @@ int check_exist_file(filename)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_banner()
|
static void do_banner()
|
||||||
{
|
{
|
||||||
printf("MiniZip 1.1, demo of zLib + MiniZip64 package, written by Gilles Vollant\n");
|
printf("MiniZip 1.1, demo of zLib + MiniZip64 package, written by Gilles Vollant\n");
|
||||||
printf("more info on MiniZip at http://www.winimage.com/zLibDll/minizip.html\n\n");
|
printf("more info on MiniZip at http://www.winimage.com/zLibDll/minizip.html\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_help()
|
static void do_help()
|
||||||
{
|
{
|
||||||
printf("Usage : minizip [-o] [-a] [-0 to -9] [-p password] [-j] file.zip [files_to_add]\n\n" \
|
printf("Usage : minizip [-o] [-a] [-0 to -9] [-p password] [-j] file.zip [files_to_add]\n\n" \
|
||||||
" -o Overwrite existing file.zip\n" \
|
" -o Overwrite existing file.zip\n" \
|
||||||
|
@ -182,14 +183,14 @@ void do_help()
|
||||||
|
|
||||||
/* calculate the CRC32 of a file,
|
/* calculate the CRC32 of a file,
|
||||||
because to encrypt a file, we need known the CRC32 of the file before */
|
because to encrypt a file, we need known the CRC32 of the file before */
|
||||||
int getFileCrc(const char* filenameinzip,void*buf,unsigned long size_buf,unsigned long* result_crc)
|
static int getFileCrc(const char* filenameinzip,void*buf,unsigned long size_buf,unsigned long* result_crc)
|
||||||
{
|
{
|
||||||
unsigned long calculate_crc=0;
|
unsigned long calculate_crc=0;
|
||||||
int err=ZIP_OK;
|
int err=ZIP_OK;
|
||||||
FILE * fin = FOPEN_FUNC(filenameinzip,"rb");
|
FILE * fin = FOPEN_FUNC(filenameinzip,"rb");
|
||||||
|
|
||||||
unsigned long size_read = 0;
|
unsigned long size_read = 0;
|
||||||
unsigned long total_read = 0;
|
/* unsigned long total_read = 0; */
|
||||||
if (fin==NULL)
|
if (fin==NULL)
|
||||||
{
|
{
|
||||||
err = ZIP_ERRNO;
|
err = ZIP_ERRNO;
|
||||||
|
@ -199,7 +200,7 @@ int getFileCrc(const char* filenameinzip,void*buf,unsigned long size_buf,unsigne
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
err = ZIP_OK;
|
err = ZIP_OK;
|
||||||
size_read = (int)fread(buf,1,size_buf,fin);
|
size_read = fread(buf,1,size_buf,fin);
|
||||||
if (size_read < size_buf)
|
if (size_read < size_buf)
|
||||||
if (feof(fin)==0)
|
if (feof(fin)==0)
|
||||||
{
|
{
|
||||||
|
@ -208,8 +209,8 @@ int getFileCrc(const char* filenameinzip,void*buf,unsigned long size_buf,unsigne
|
||||||
}
|
}
|
||||||
|
|
||||||
if (size_read>0)
|
if (size_read>0)
|
||||||
calculate_crc = crc32(calculate_crc,buf,size_read);
|
calculate_crc = crc32_z(calculate_crc,buf,size_read);
|
||||||
total_read += size_read;
|
/* total_read += size_read; */
|
||||||
|
|
||||||
} while ((err == ZIP_OK) && (size_read>0));
|
} while ((err == ZIP_OK) && (size_read>0));
|
||||||
|
|
||||||
|
@ -221,7 +222,7 @@ int getFileCrc(const char* filenameinzip,void*buf,unsigned long size_buf,unsigne
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
int isLargeFile(const char* filename)
|
static int isLargeFile(const char* filename)
|
||||||
{
|
{
|
||||||
int largeFile = 0;
|
int largeFile = 0;
|
||||||
ZPOS64_T pos = 0;
|
ZPOS64_T pos = 0;
|
||||||
|
@ -229,8 +230,8 @@ int isLargeFile(const char* filename)
|
||||||
|
|
||||||
if(pFile != NULL)
|
if(pFile != NULL)
|
||||||
{
|
{
|
||||||
int n = FSEEKO_FUNC(pFile, 0, SEEK_END);
|
FSEEKO_FUNC(pFile, 0, SEEK_END);
|
||||||
pos = FTELLO_FUNC(pFile);
|
pos = (ZPOS64_T)FTELLO_FUNC(pFile);
|
||||||
|
|
||||||
printf("File : %s is %lld bytes\n", filename, pos);
|
printf("File : %s is %lld bytes\n", filename, pos);
|
||||||
|
|
||||||
|
@ -255,7 +256,7 @@ int main(argc,argv)
|
||||||
char filename_try[MAXFILENAME+16];
|
char filename_try[MAXFILENAME+16];
|
||||||
int zipok;
|
int zipok;
|
||||||
int err=0;
|
int err=0;
|
||||||
int size_buf=0;
|
size_t size_buf=0;
|
||||||
void* buf=NULL;
|
void* buf=NULL;
|
||||||
const char* password=NULL;
|
const char* password=NULL;
|
||||||
|
|
||||||
|
@ -276,7 +277,7 @@ int main(argc,argv)
|
||||||
|
|
||||||
while ((*p)!='\0')
|
while ((*p)!='\0')
|
||||||
{
|
{
|
||||||
char c=*(p++);;
|
char c=*(p++);
|
||||||
if ((c=='o') || (c=='O'))
|
if ((c=='o') || (c=='O'))
|
||||||
opt_overwrite = 1;
|
opt_overwrite = 1;
|
||||||
if ((c=='a') || (c=='A'))
|
if ((c=='a') || (c=='A'))
|
||||||
|
@ -396,7 +397,7 @@ int main(argc,argv)
|
||||||
(strlen(argv[i]) == 2)))
|
(strlen(argv[i]) == 2)))
|
||||||
{
|
{
|
||||||
FILE * fin;
|
FILE * fin;
|
||||||
int size_read;
|
size_t size_read;
|
||||||
const char* filenameinzip = argv[i];
|
const char* filenameinzip = argv[i];
|
||||||
const char *savefilenameinzip;
|
const char *savefilenameinzip;
|
||||||
zip_fileinfo zi;
|
zip_fileinfo zi;
|
||||||
|
@ -472,7 +473,7 @@ int main(argc,argv)
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
err = ZIP_OK;
|
err = ZIP_OK;
|
||||||
size_read = (int)fread(buf,1,size_buf,fin);
|
size_read = fread(buf,1,size_buf,fin);
|
||||||
if (size_read < size_buf)
|
if (size_read < size_buf)
|
||||||
if (feof(fin)==0)
|
if (feof(fin)==0)
|
||||||
{
|
{
|
||||||
|
@ -482,7 +483,7 @@ int main(argc,argv)
|
||||||
|
|
||||||
if (size_read>0)
|
if (size_read>0)
|
||||||
{
|
{
|
||||||
err = zipWriteInFileInZip (zf,buf,size_read);
|
err = zipWriteInFileInZip (zf,buf,(unsigned)size_read);
|
||||||
if (err<0)
|
if (err<0)
|
||||||
{
|
{
|
||||||
printf("error in writing %s in the zipfile\n",
|
printf("error in writing %s in the zipfile\n",
|
||||||
|
|
|
@ -112,7 +112,7 @@
|
||||||
# define ALLOC(size) (malloc(size))
|
# define ALLOC(size) (malloc(size))
|
||||||
#endif
|
#endif
|
||||||
#ifndef TRYFREE
|
#ifndef TRYFREE
|
||||||
# define TRYFREE(p) {if (p) free(p);}
|
# define TRYFREE(p) { free(p);}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define SIZECENTRALDIRITEM (0x2e)
|
#define SIZECENTRALDIRITEM (0x2e)
|
||||||
|
@ -455,7 +455,7 @@ local ZPOS64_T unz64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_f
|
||||||
if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
|
if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
|
||||||
((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06))
|
((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06))
|
||||||
{
|
{
|
||||||
uPosFound = uReadPos+i;
|
uPosFound = uReadPos+(unsigned)i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -523,7 +523,7 @@ local ZPOS64_T unz64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib
|
||||||
if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
|
if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
|
||||||
((*(buf+i+2))==0x06) && ((*(buf+i+3))==0x07))
|
((*(buf+i+2))==0x06) && ((*(buf+i+3))==0x07))
|
||||||
{
|
{
|
||||||
uPosFound = uReadPos+i;
|
uPosFound = uReadPos+(unsigned)i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -853,13 +853,13 @@ local void unz64local_DosDateToTmuDate (ZPOS64_T ulDosDate, tm_unz* ptm)
|
||||||
{
|
{
|
||||||
ZPOS64_T uDate;
|
ZPOS64_T uDate;
|
||||||
uDate = (ZPOS64_T)(ulDosDate>>16);
|
uDate = (ZPOS64_T)(ulDosDate>>16);
|
||||||
ptm->tm_mday = (uInt)(uDate&0x1f) ;
|
ptm->tm_mday = (int)(uDate&0x1f) ;
|
||||||
ptm->tm_mon = (uInt)((((uDate)&0x1E0)/0x20)-1) ;
|
ptm->tm_mon = (int)((((uDate)&0x1E0)/0x20)-1) ;
|
||||||
ptm->tm_year = (uInt)(((uDate&0x0FE00)/0x0200)+1980) ;
|
ptm->tm_year = (int)(((uDate&0x0FE00)/0x0200)+1980) ;
|
||||||
|
|
||||||
ptm->tm_hour = (uInt) ((ulDosDate &0xF800)/0x800);
|
ptm->tm_hour = (int) ((ulDosDate &0xF800)/0x800);
|
||||||
ptm->tm_min = (uInt) ((ulDosDate&0x7E0)/0x20) ;
|
ptm->tm_min = (int) ((ulDosDate&0x7E0)/0x20) ;
|
||||||
ptm->tm_sec = (uInt) (2*(ulDosDate&0x1f)) ;
|
ptm->tm_sec = (int) (2*(ulDosDate&0x1f)) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -993,7 +993,7 @@ local int unz64local_GetCurrentFileInfoInternal (unzFile file,
|
||||||
|
|
||||||
if (lSeek!=0)
|
if (lSeek!=0)
|
||||||
{
|
{
|
||||||
if (ZSEEK64(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
|
if (ZSEEK64(s->z_filefunc, s->filestream,(ZPOS64_T)lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
|
||||||
lSeek=0;
|
lSeek=0;
|
||||||
else
|
else
|
||||||
err=UNZ_ERRNO;
|
err=UNZ_ERRNO;
|
||||||
|
@ -1018,7 +1018,7 @@ local int unz64local_GetCurrentFileInfoInternal (unzFile file,
|
||||||
|
|
||||||
if (lSeek!=0)
|
if (lSeek!=0)
|
||||||
{
|
{
|
||||||
if (ZSEEK64(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
|
if (ZSEEK64(s->z_filefunc, s->filestream,(ZPOS64_T)lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
|
||||||
lSeek=0;
|
lSeek=0;
|
||||||
else
|
else
|
||||||
err=UNZ_ERRNO;
|
err=UNZ_ERRNO;
|
||||||
|
@ -1090,7 +1090,7 @@ local int unz64local_GetCurrentFileInfoInternal (unzFile file,
|
||||||
|
|
||||||
if (lSeek!=0)
|
if (lSeek!=0)
|
||||||
{
|
{
|
||||||
if (ZSEEK64(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
|
if (ZSEEK64(s->z_filefunc, s->filestream,(ZPOS64_T)lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
|
||||||
lSeek=0;
|
lSeek=0;
|
||||||
else
|
else
|
||||||
err=UNZ_ERRNO;
|
err=UNZ_ERRNO;
|
||||||
|
@ -1566,6 +1566,7 @@ extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method,
|
||||||
pfile_in_zip_read_info->stream_initialised=Z_BZIP2ED;
|
pfile_in_zip_read_info->stream_initialised=Z_BZIP2ED;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
TRYFREE(pfile_in_zip_read_info->read_buffer);
|
||||||
TRYFREE(pfile_in_zip_read_info);
|
TRYFREE(pfile_in_zip_read_info);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -1586,6 +1587,7 @@ extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method,
|
||||||
pfile_in_zip_read_info->stream_initialised=Z_DEFLATED;
|
pfile_in_zip_read_info->stream_initialised=Z_DEFLATED;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
TRYFREE(pfile_in_zip_read_info->read_buffer);
|
||||||
TRYFREE(pfile_in_zip_read_info);
|
TRYFREE(pfile_in_zip_read_info);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -1767,7 +1769,7 @@ extern int ZEXPORT unzReadCurrentFile (unzFile file, voidp buf, unsigned len)
|
||||||
|
|
||||||
if ((pfile_in_zip_read_info->stream.avail_in == 0) &&
|
if ((pfile_in_zip_read_info->stream.avail_in == 0) &&
|
||||||
(pfile_in_zip_read_info->rest_read_compressed == 0))
|
(pfile_in_zip_read_info->rest_read_compressed == 0))
|
||||||
return (iRead==0) ? UNZ_EOF : iRead;
|
return (iRead==0) ? UNZ_EOF : (int)iRead;
|
||||||
|
|
||||||
if (pfile_in_zip_read_info->stream.avail_out <
|
if (pfile_in_zip_read_info->stream.avail_out <
|
||||||
pfile_in_zip_read_info->stream.avail_in)
|
pfile_in_zip_read_info->stream.avail_in)
|
||||||
|
@ -1857,6 +1859,9 @@ extern int ZEXPORT unzReadCurrentFile (unzFile file, voidp buf, unsigned len)
|
||||||
err = Z_DATA_ERROR;
|
err = Z_DATA_ERROR;
|
||||||
|
|
||||||
uTotalOutAfter = pfile_in_zip_read_info->stream.total_out;
|
uTotalOutAfter = pfile_in_zip_read_info->stream.total_out;
|
||||||
|
/* Detect overflow, because z_stream.total_out is uLong (32 bits) */
|
||||||
|
if (uTotalOutAfter<uTotalOutBefore)
|
||||||
|
uTotalOutAfter += 1LL << 32; /* Add maximum value of uLong + 1 */
|
||||||
uOutThis = uTotalOutAfter-uTotalOutBefore;
|
uOutThis = uTotalOutAfter-uTotalOutBefore;
|
||||||
|
|
||||||
pfile_in_zip_read_info->total_out_64 = pfile_in_zip_read_info->total_out_64 + uOutThis;
|
pfile_in_zip_read_info->total_out_64 = pfile_in_zip_read_info->total_out_64 + uOutThis;
|
||||||
|
@ -1871,14 +1876,14 @@ extern int ZEXPORT unzReadCurrentFile (unzFile file, voidp buf, unsigned len)
|
||||||
iRead += (uInt)(uTotalOutAfter - uTotalOutBefore);
|
iRead += (uInt)(uTotalOutAfter - uTotalOutBefore);
|
||||||
|
|
||||||
if (err==Z_STREAM_END)
|
if (err==Z_STREAM_END)
|
||||||
return (iRead==0) ? UNZ_EOF : iRead;
|
return (iRead==0) ? UNZ_EOF : (int)iRead;
|
||||||
if (err!=Z_OK)
|
if (err!=Z_OK)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (err==Z_OK)
|
if (err==Z_OK)
|
||||||
return iRead;
|
return (int)iRead;
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,12 +83,12 @@ typedef voidp unzFile;
|
||||||
/* tm_unz contain date/time info */
|
/* tm_unz contain date/time info */
|
||||||
typedef struct tm_unz_s
|
typedef struct tm_unz_s
|
||||||
{
|
{
|
||||||
uInt tm_sec; /* seconds after the minute - [0,59] */
|
int tm_sec; /* seconds after the minute - [0,59] */
|
||||||
uInt tm_min; /* minutes after the hour - [0,59] */
|
int tm_min; /* minutes after the hour - [0,59] */
|
||||||
uInt tm_hour; /* hours since midnight - [0,23] */
|
int tm_hour; /* hours since midnight - [0,23] */
|
||||||
uInt tm_mday; /* day of the month - [1,31] */
|
int tm_mday; /* day of the month - [1,31] */
|
||||||
uInt tm_mon; /* months since January - [0,11] */
|
int tm_mon; /* months since January - [0,11] */
|
||||||
uInt tm_year; /* years - [1980..2044] */
|
int tm_year; /* years - [1980..2044] */
|
||||||
} tm_unz;
|
} tm_unz;
|
||||||
|
|
||||||
/* unz_global_info structure contain global data about the ZIPfile
|
/* unz_global_info structure contain global data about the ZIPfile
|
||||||
|
|
|
@ -158,7 +158,7 @@ typedef struct
|
||||||
#ifndef NOCRYPT
|
#ifndef NOCRYPT
|
||||||
unsigned long keys[3]; /* keys defining the pseudo-random sequence */
|
unsigned long keys[3]; /* keys defining the pseudo-random sequence */
|
||||||
const z_crc_t* pcrc_32_tab;
|
const z_crc_t* pcrc_32_tab;
|
||||||
int crypt_header_size;
|
unsigned crypt_header_size;
|
||||||
#endif
|
#endif
|
||||||
} curfile64_info;
|
} curfile64_info;
|
||||||
|
|
||||||
|
@ -301,7 +301,7 @@ local int zip64local_putValue (const zlib_filefunc64_32_def* pzlib_filefunc_def,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ZWRITE64(*pzlib_filefunc_def,filestream,buf,nbByte)!=(uLong)nbByte)
|
if (ZWRITE64(*pzlib_filefunc_def,filestream,buf,(uLong)nbByte)!=(uLong)nbByte)
|
||||||
return ZIP_ERRNO;
|
return ZIP_ERRNO;
|
||||||
else
|
else
|
||||||
return ZIP_OK;
|
return ZIP_OK;
|
||||||
|
@ -337,8 +337,8 @@ local uLong zip64local_TmzDateToDosDate(const tm_zip* ptm)
|
||||||
else if (year>=80)
|
else if (year>=80)
|
||||||
year-=80;
|
year-=80;
|
||||||
return
|
return
|
||||||
(uLong) (((ptm->tm_mday) + (32 * (ptm->tm_mon+1)) + (512 * year)) << 16) |
|
(uLong) (((uLong)(ptm->tm_mday) + (32 * (uLong)(ptm->tm_mon+1)) + (512 * year)) << 16) |
|
||||||
((ptm->tm_sec/2) + (32* ptm->tm_min) + (2048 * (uLong)ptm->tm_hour));
|
(((uLong)ptm->tm_sec/2) + (32 * (uLong)ptm->tm_min) + (2048 * (uLong)ptm->tm_hour));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -522,12 +522,12 @@ local ZPOS64_T zip64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_f
|
||||||
if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
|
if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
|
||||||
((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06))
|
((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06))
|
||||||
{
|
{
|
||||||
uPosFound = uReadPos+i;
|
uPosFound = uReadPos+(unsigned)i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uPosFound!=0)
|
if (uPosFound!=0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
TRYFREE(buf);
|
TRYFREE(buf);
|
||||||
return uPosFound;
|
return uPosFound;
|
||||||
|
@ -586,7 +586,7 @@ local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib
|
||||||
// Signature "0x07064b50" Zip64 end of central directory locater
|
// Signature "0x07064b50" Zip64 end of central directory locater
|
||||||
if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && ((*(buf+i+2))==0x06) && ((*(buf+i+3))==0x07))
|
if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && ((*(buf+i+2))==0x06) && ((*(buf+i+3))==0x07))
|
||||||
{
|
{
|
||||||
uPosFound = uReadPos+i;
|
uPosFound = uReadPos+(unsigned)i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -637,7 +637,7 @@ local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib
|
||||||
return relativeOffset;
|
return relativeOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
int LoadCentralDirectoryRecord(zip64_internal* pziinit)
|
local int LoadCentralDirectoryRecord(zip64_internal* pziinit)
|
||||||
{
|
{
|
||||||
int err=ZIP_OK;
|
int err=ZIP_OK;
|
||||||
ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
|
ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
|
||||||
|
@ -955,7 +955,7 @@ extern zipFile ZEXPORT zipOpen64 (const void* pathname, int append)
|
||||||
return zipOpen3(pathname,append,NULL,NULL);
|
return zipOpen3(pathname,append,NULL,NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt size_extrafield_local, const void* extrafield_local)
|
local int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt size_extrafield_local, const void* extrafield_local)
|
||||||
{
|
{
|
||||||
/* write the local header */
|
/* write the local header */
|
||||||
int err;
|
int err;
|
||||||
|
@ -1034,8 +1034,8 @@ int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt size_ex
|
||||||
// Remember position of Zip64 extended info for the local file header. (needed when we update size after done with file)
|
// Remember position of Zip64 extended info for the local file header. (needed when we update size after done with file)
|
||||||
zi->ci.pos_zip64extrainfo = ZTELL64(zi->z_filefunc,zi->filestream);
|
zi->ci.pos_zip64extrainfo = ZTELL64(zi->z_filefunc,zi->filestream);
|
||||||
|
|
||||||
err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (short)HeaderID,2);
|
err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)HeaderID,2);
|
||||||
err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (short)DataSize,2);
|
err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)DataSize,2);
|
||||||
|
|
||||||
err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)UncompressedSize,8);
|
err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)UncompressedSize,8);
|
||||||
err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)CompressedSize,8);
|
err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)CompressedSize,8);
|
||||||
|
@ -1471,11 +1471,6 @@ extern int ZEXPORT zipWriteInFileInZip (zipFile file,const void* buf,unsigned in
|
||||||
{
|
{
|
||||||
uLong uTotalOutBefore = zi->ci.stream.total_out;
|
uLong uTotalOutBefore = zi->ci.stream.total_out;
|
||||||
err=deflate(&zi->ci.stream, Z_NO_FLUSH);
|
err=deflate(&zi->ci.stream, Z_NO_FLUSH);
|
||||||
if(uTotalOutBefore > zi->ci.stream.total_out)
|
|
||||||
{
|
|
||||||
int bBreak = 0;
|
|
||||||
bBreak++;
|
|
||||||
}
|
|
||||||
|
|
||||||
zi->ci.pos_in_buffered_data += (uInt)(zi->ci.stream.total_out - uTotalOutBefore) ;
|
zi->ci.pos_in_buffered_data += (uInt)(zi->ci.stream.total_out - uTotalOutBefore) ;
|
||||||
}
|
}
|
||||||
|
@ -1516,7 +1511,7 @@ extern int ZEXPORT zipCloseFileInZipRaw64 (zipFile file, ZPOS64_T uncompressed_s
|
||||||
zip64_internal* zi;
|
zip64_internal* zi;
|
||||||
ZPOS64_T compressed_size;
|
ZPOS64_T compressed_size;
|
||||||
uLong invalidValue = 0xffffffff;
|
uLong invalidValue = 0xffffffff;
|
||||||
short datasize = 0;
|
unsigned datasize = 0;
|
||||||
int err=ZIP_OK;
|
int err=ZIP_OK;
|
||||||
|
|
||||||
if (file == NULL)
|
if (file == NULL)
|
||||||
|
@ -1752,7 +1747,7 @@ extern int ZEXPORT zipCloseFileInZip (zipFile file)
|
||||||
return zipCloseFileInZipRaw (file,0,0);
|
return zipCloseFileInZipRaw (file,0,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Write_Zip64EndOfCentralDirectoryLocator(zip64_internal* zi, ZPOS64_T zip64eocd_pos_inzip)
|
local int Write_Zip64EndOfCentralDirectoryLocator(zip64_internal* zi, ZPOS64_T zip64eocd_pos_inzip)
|
||||||
{
|
{
|
||||||
int err = ZIP_OK;
|
int err = ZIP_OK;
|
||||||
ZPOS64_T pos = zip64eocd_pos_inzip - zi->add_position_when_writing_offset;
|
ZPOS64_T pos = zip64eocd_pos_inzip - zi->add_position_when_writing_offset;
|
||||||
|
@ -1774,7 +1769,7 @@ int Write_Zip64EndOfCentralDirectoryLocator(zip64_internal* zi, ZPOS64_T zip64eo
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Write_Zip64EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip)
|
local int Write_Zip64EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip)
|
||||||
{
|
{
|
||||||
int err = ZIP_OK;
|
int err = ZIP_OK;
|
||||||
|
|
||||||
|
@ -1813,7 +1808,7 @@ int Write_Zip64EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centra
|
||||||
}
|
}
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
int Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip)
|
local int Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip)
|
||||||
{
|
{
|
||||||
int err = ZIP_OK;
|
int err = ZIP_OK;
|
||||||
|
|
||||||
|
@ -1861,7 +1856,7 @@ int Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir,
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Write_GlobalComment(zip64_internal* zi, const char* global_comment)
|
local int Write_GlobalComment(zip64_internal* zi, const char* global_comment)
|
||||||
{
|
{
|
||||||
int err = ZIP_OK;
|
int err = ZIP_OK;
|
||||||
uInt size_global_comment = 0;
|
uInt size_global_comment = 0;
|
||||||
|
@ -1959,10 +1954,10 @@ extern int ZEXPORT zipRemoveExtraInfoBlock (char* pData, int* dataLen, short sHe
|
||||||
|
|
||||||
int retVal = ZIP_OK;
|
int retVal = ZIP_OK;
|
||||||
|
|
||||||
if(pData == NULL || *dataLen < 4)
|
if(pData == NULL || dataLen == NULL || *dataLen < 4)
|
||||||
return ZIP_PARAMERROR;
|
return ZIP_PARAMERROR;
|
||||||
|
|
||||||
pNewHeader = (char*)ALLOC(*dataLen);
|
pNewHeader = (char*)ALLOC((unsigned)*dataLen);
|
||||||
pTmp = pNewHeader;
|
pTmp = pNewHeader;
|
||||||
|
|
||||||
while(p < (pData + *dataLen))
|
while(p < (pData + *dataLen))
|
||||||
|
|
|
@ -88,12 +88,12 @@ typedef voidp zipFile;
|
||||||
/* tm_zip contain date/time info */
|
/* tm_zip contain date/time info */
|
||||||
typedef struct tm_zip_s
|
typedef struct tm_zip_s
|
||||||
{
|
{
|
||||||
uInt tm_sec; /* seconds after the minute - [0,59] */
|
int tm_sec; /* seconds after the minute - [0,59] */
|
||||||
uInt tm_min; /* minutes after the hour - [0,59] */
|
int tm_min; /* minutes after the hour - [0,59] */
|
||||||
uInt tm_hour; /* hours since midnight - [0,23] */
|
int tm_hour; /* hours since midnight - [0,23] */
|
||||||
uInt tm_mday; /* day of the month - [1,31] */
|
int tm_mday; /* day of the month - [1,31] */
|
||||||
uInt tm_mon; /* months since January - [0,11] */
|
int tm_mon; /* months since January - [0,11] */
|
||||||
uInt tm_year; /* years - [1980..2044] */
|
int tm_year; /* years - [1980..2044] */
|
||||||
} tm_zip;
|
} tm_zip;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
@ -144,6 +144,11 @@ extern zipFile ZEXPORT zipOpen2_64 OF((const void *pathname,
|
||||||
zipcharpc* globalcomment,
|
zipcharpc* globalcomment,
|
||||||
zlib_filefunc64_def* pzlib_filefunc_def));
|
zlib_filefunc64_def* pzlib_filefunc_def));
|
||||||
|
|
||||||
|
extern zipFile ZEXPORT zipOpen3 OF((const void *pathname,
|
||||||
|
int append,
|
||||||
|
zipcharpc* globalcomment,
|
||||||
|
zlib_filefunc64_32_def* pzlib_filefunc64_32_def));
|
||||||
|
|
||||||
extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file,
|
extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file,
|
||||||
const char* filename,
|
const char* filename,
|
||||||
const zip_fileinfo* zipfi,
|
const zip_fileinfo* zipfi,
|
||||||
|
|
|
@ -10,7 +10,7 @@ unit zlibpas;
|
||||||
interface
|
interface
|
||||||
|
|
||||||
const
|
const
|
||||||
ZLIB_VERSION = '1.2.11';
|
ZLIB_VERSION = '1.2.13';
|
||||||
ZLIB_VERNUM = $12a0;
|
ZLIB_VERNUM = $12a0;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
|
@ -38,7 +38,7 @@ Then you can call puff() to decompress a deflate stream that is in memory in
|
||||||
its entirety at source, to a sufficiently sized block of memory for the
|
its entirety at source, to a sufficiently sized block of memory for the
|
||||||
decompressed data at dest. puff() is the only external symbol in puff.c The
|
decompressed data at dest. puff() is the only external symbol in puff.c The
|
||||||
only C library functions that puff.c needs are setjmp() and longjmp(), which
|
only C library functions that puff.c needs are setjmp() and longjmp(), which
|
||||||
are used to simplify error checking in the code to improve readabilty. puff.c
|
are used to simplify error checking in the code to improve readability. puff.c
|
||||||
does no memory allocation, and uses less than 2K bytes off of the stack.
|
does no memory allocation, and uses less than 2K bytes off of the stack.
|
||||||
|
|
||||||
If destlen is not enough space for the uncompressed data, then inflate will
|
If destlen is not enough space for the uncompressed data, then inflate will
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
* - Use pointers instead of long to specify source and
|
* - Use pointers instead of long to specify source and
|
||||||
* destination sizes to avoid arbitrary 4 GB limits
|
* destination sizes to avoid arbitrary 4 GB limits
|
||||||
* 1.2 17 Mar 2002 - Add faster version of decode(), doubles speed (!),
|
* 1.2 17 Mar 2002 - Add faster version of decode(), doubles speed (!),
|
||||||
* but leave simple version for readabilty
|
* but leave simple version for readability
|
||||||
* - Make sure invalid distances detected if pointers
|
* - Make sure invalid distances detected if pointers
|
||||||
* are 16 bits
|
* are 16 bits
|
||||||
* - Fix fixed codes table error
|
* - Fix fixed codes table error
|
||||||
|
@ -624,7 +624,7 @@ local int fixed(struct state *s)
|
||||||
* are themselves compressed using Huffman codes and run-length encoding. In
|
* are themselves compressed using Huffman codes and run-length encoding. In
|
||||||
* the list of code lengths, a 0 symbol means no code, a 1..15 symbol means
|
* the list of code lengths, a 0 symbol means no code, a 1..15 symbol means
|
||||||
* that length, and the symbols 16, 17, and 18 are run-length instructions.
|
* that length, and the symbols 16, 17, and 18 are run-length instructions.
|
||||||
* Each of 16, 17, and 18 are follwed by extra bits to define the length of
|
* Each of 16, 17, and 18 are followed by extra bits to define the length of
|
||||||
* the run. 16 copies the last length 3 to 6 times. 17 represents 3 to 10
|
* the run. 16 copies the last length 3 to 6 times. 17 represents 3 to 10
|
||||||
* zero lengths, and 18 represents 11 to 138 zero lengths. Unused symbols
|
* zero lengths, and 18 represents 11 to 138 zero lengths. Unused symbols
|
||||||
* are common, hence the special coding for zero lengths.
|
* are common, hence the special coding for zero lengths.
|
||||||
|
|
|
@ -143,7 +143,7 @@ int main(int argc, char **argv)
|
||||||
len - sourcelen);
|
len - sourcelen);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if requested, inflate again and write decompressd data to stdout */
|
/* if requested, inflate again and write decompressed data to stdout */
|
||||||
if (put && ret == 0) {
|
if (put && ret == 0) {
|
||||||
if (fail)
|
if (fail)
|
||||||
destlen >>= 1;
|
destlen >>= 1;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
Building instructions for the DLL versions of Zlib 1.2.11
|
Building instructions for the DLL versions of Zlib 1.2.13
|
||||||
========================================================
|
========================================================
|
||||||
|
|
||||||
This directory contains projects that build zlib and minizip using
|
This directory contains projects that build zlib and minizip using
|
||||||
|
@ -17,9 +17,6 @@ More information can be found at this site.
|
||||||
Build instructions for Visual Studio 2008 (32 bits or 64 bits)
|
Build instructions for Visual Studio 2008 (32 bits or 64 bits)
|
||||||
--------------------------------------------------------------
|
--------------------------------------------------------------
|
||||||
- Decompress current zlib, including all contrib/* files
|
- Decompress current zlib, including all contrib/* files
|
||||||
- Compile assembly code (with Visual Studio Command Prompt) by running:
|
|
||||||
bld_ml64.bat (in contrib\masmx64)
|
|
||||||
bld_ml32.bat (in contrib\masmx86)
|
|
||||||
- Open contrib\vstudio\vc9\zlibvc.sln with Microsoft Visual C++ 2008
|
- Open contrib\vstudio\vc9\zlibvc.sln with Microsoft Visual C++ 2008
|
||||||
- Or run: vcbuild /rebuild contrib\vstudio\vc9\zlibvc.sln "Release|Win32"
|
- Or run: vcbuild /rebuild contrib\vstudio\vc9\zlibvc.sln "Release|Win32"
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
#define IDR_VERSION1 1
|
#define IDR_VERSION1 1
|
||||||
IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE
|
IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE
|
||||||
FILEVERSION 1, 2, 11, 0
|
FILEVERSION 1, 2, 13, 0
|
||||||
PRODUCTVERSION 1, 2, 11, 0
|
PRODUCTVERSION 1, 2, 13, 0
|
||||||
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
|
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
|
||||||
FILEFLAGS 0
|
FILEFLAGS 0
|
||||||
FILEOS VOS_DOS_WINDOWS32
|
FILEOS VOS_DOS_WINDOWS32
|
||||||
|
@ -17,12 +17,12 @@ BEGIN
|
||||||
|
|
||||||
BEGIN
|
BEGIN
|
||||||
VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0"
|
VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0"
|
||||||
VALUE "FileVersion", "1.2.11\0"
|
VALUE "FileVersion", "1.2.13\0"
|
||||||
VALUE "InternalName", "zlib\0"
|
VALUE "InternalName", "zlib\0"
|
||||||
VALUE "OriginalFilename", "zlibwapi.dll\0"
|
VALUE "OriginalFilename", "zlibwapi.dll\0"
|
||||||
VALUE "ProductName", "ZLib.DLL\0"
|
VALUE "ProductName", "ZLib.DLL\0"
|
||||||
VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0"
|
VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0"
|
||||||
VALUE "LegalCopyright", "(C) 1995-2017 Jean-loup Gailly & Mark Adler\0"
|
VALUE "LegalCopyright", "(C) 1995-2022 Jean-loup Gailly & Mark Adler\0"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
BLOCK "VarFileInfo"
|
BLOCK "VarFileInfo"
|
||||||
|
|
|
@ -151,3 +151,8 @@ EXPORTS
|
||||||
deflateGetDictionary @173
|
deflateGetDictionary @173
|
||||||
adler32_z @174
|
adler32_z @174
|
||||||
crc32_z @175
|
crc32_z @175
|
||||||
|
|
||||||
|
; zlib1 v1.2.12 added:
|
||||||
|
crc32_combine_gen @176
|
||||||
|
crc32_combine_gen64 @177
|
||||||
|
crc32_combine_op @178
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
#define IDR_VERSION1 1
|
#define IDR_VERSION1 1
|
||||||
IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE
|
IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE
|
||||||
FILEVERSION 1, 2, 11, 0
|
FILEVERSION 1, 2, 13, 0
|
||||||
PRODUCTVERSION 1, 2, 11, 0
|
PRODUCTVERSION 1, 2, 13, 0
|
||||||
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
|
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
|
||||||
FILEFLAGS 0
|
FILEFLAGS 0
|
||||||
FILEOS VOS_DOS_WINDOWS32
|
FILEOS VOS_DOS_WINDOWS32
|
||||||
|
@ -17,12 +17,12 @@ BEGIN
|
||||||
|
|
||||||
BEGIN
|
BEGIN
|
||||||
VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0"
|
VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0"
|
||||||
VALUE "FileVersion", "1.2.11\0"
|
VALUE "FileVersion", "1.2.13\0"
|
||||||
VALUE "InternalName", "zlib\0"
|
VALUE "InternalName", "zlib\0"
|
||||||
VALUE "OriginalFilename", "zlibwapi.dll\0"
|
VALUE "OriginalFilename", "zlibwapi.dll\0"
|
||||||
VALUE "ProductName", "ZLib.DLL\0"
|
VALUE "ProductName", "ZLib.DLL\0"
|
||||||
VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0"
|
VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0"
|
||||||
VALUE "LegalCopyright", "(C) 1995-2017 Jean-loup Gailly & Mark Adler\0"
|
VALUE "LegalCopyright", "(C) 1995-2022 Jean-loup Gailly & Mark Adler\0"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
BLOCK "VarFileInfo"
|
BLOCK "VarFileInfo"
|
||||||
|
|
|
@ -151,3 +151,8 @@ EXPORTS
|
||||||
deflateGetDictionary @173
|
deflateGetDictionary @173
|
||||||
adler32_z @174
|
adler32_z @174
|
||||||
crc32_z @175
|
crc32_z @175
|
||||||
|
|
||||||
|
; zlib1 v1.2.12 added:
|
||||||
|
crc32_combine_gen @176
|
||||||
|
crc32_combine_gen64 @177
|
||||||
|
crc32_combine_op @178
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
#define IDR_VERSION1 1
|
#define IDR_VERSION1 1
|
||||||
IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE
|
IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE
|
||||||
FILEVERSION 1, 2, 11, 0
|
FILEVERSION 1, 2, 13, 0
|
||||||
PRODUCTVERSION 1, 2, 11, 0
|
PRODUCTVERSION 1, 2, 13, 0
|
||||||
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
|
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
|
||||||
FILEFLAGS 0
|
FILEFLAGS 0
|
||||||
FILEOS VOS_DOS_WINDOWS32
|
FILEOS VOS_DOS_WINDOWS32
|
||||||
|
@ -17,12 +17,12 @@ BEGIN
|
||||||
|
|
||||||
BEGIN
|
BEGIN
|
||||||
VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0"
|
VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0"
|
||||||
VALUE "FileVersion", "1.2.11\0"
|
VALUE "FileVersion", "1.2.13\0"
|
||||||
VALUE "InternalName", "zlib\0"
|
VALUE "InternalName", "zlib\0"
|
||||||
VALUE "OriginalFilename", "zlibwapi.dll\0"
|
VALUE "OriginalFilename", "zlibwapi.dll\0"
|
||||||
VALUE "ProductName", "ZLib.DLL\0"
|
VALUE "ProductName", "ZLib.DLL\0"
|
||||||
VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0"
|
VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0"
|
||||||
VALUE "LegalCopyright", "(C) 1995-2017 Jean-loup Gailly & Mark Adler\0"
|
VALUE "LegalCopyright", "(C) 1995-2022 Jean-loup Gailly & Mark Adler\0"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
BLOCK "VarFileInfo"
|
BLOCK "VarFileInfo"
|
||||||
|
|
|
@ -151,3 +151,8 @@ EXPORTS
|
||||||
deflateGetDictionary @173
|
deflateGetDictionary @173
|
||||||
adler32_z @174
|
adler32_z @174
|
||||||
crc32_z @175
|
crc32_z @175
|
||||||
|
|
||||||
|
; zlib1 v1.2.12 added:
|
||||||
|
crc32_combine_gen @176
|
||||||
|
crc32_combine_gen64 @177
|
||||||
|
crc32_combine_op @178
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
#define IDR_VERSION1 1
|
#define IDR_VERSION1 1
|
||||||
IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE
|
IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE
|
||||||
FILEVERSION 1, 2, 11, 0
|
FILEVERSION 1, 2, 13, 0
|
||||||
PRODUCTVERSION 1, 2, 11, 0
|
PRODUCTVERSION 1, 2, 13, 0
|
||||||
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
|
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
|
||||||
FILEFLAGS 0
|
FILEFLAGS 0
|
||||||
FILEOS VOS_DOS_WINDOWS32
|
FILEOS VOS_DOS_WINDOWS32
|
||||||
|
@ -17,12 +17,12 @@ BEGIN
|
||||||
|
|
||||||
BEGIN
|
BEGIN
|
||||||
VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0"
|
VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0"
|
||||||
VALUE "FileVersion", "1.2.11\0"
|
VALUE "FileVersion", "1.2.13\0"
|
||||||
VALUE "InternalName", "zlib\0"
|
VALUE "InternalName", "zlib\0"
|
||||||
VALUE "OriginalFilename", "zlibwapi.dll\0"
|
VALUE "OriginalFilename", "zlibwapi.dll\0"
|
||||||
VALUE "ProductName", "ZLib.DLL\0"
|
VALUE "ProductName", "ZLib.DLL\0"
|
||||||
VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0"
|
VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0"
|
||||||
VALUE "LegalCopyright", "(C) 1995-2017 Jean-loup Gailly & Mark Adler\0"
|
VALUE "LegalCopyright", "(C) 1995-2022 Jean-loup Gailly & Mark Adler\0"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
BLOCK "VarFileInfo"
|
BLOCK "VarFileInfo"
|
||||||
|
|
|
@ -151,3 +151,8 @@ EXPORTS
|
||||||
deflateGetDictionary @173
|
deflateGetDictionary @173
|
||||||
adler32_z @174
|
adler32_z @174
|
||||||
crc32_z @175
|
crc32_z @175
|
||||||
|
|
||||||
|
; zlib1 v1.2.12 added:
|
||||||
|
crc32_combine_gen @176
|
||||||
|
crc32_combine_gen64 @177
|
||||||
|
crc32_combine_op @178
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
#define IDR_VERSION1 1
|
#define IDR_VERSION1 1
|
||||||
IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE
|
IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE
|
||||||
FILEVERSION 1, 2, 11, 0
|
FILEVERSION 1, 2, 13, 0
|
||||||
PRODUCTVERSION 1, 2, 11, 0
|
PRODUCTVERSION 1, 2, 13, 0
|
||||||
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
|
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
|
||||||
FILEFLAGS 0
|
FILEFLAGS 0
|
||||||
FILEOS VOS_DOS_WINDOWS32
|
FILEOS VOS_DOS_WINDOWS32
|
||||||
|
@ -17,12 +17,12 @@ BEGIN
|
||||||
|
|
||||||
BEGIN
|
BEGIN
|
||||||
VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0"
|
VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0"
|
||||||
VALUE "FileVersion", "1.2.11\0"
|
VALUE "FileVersion", "1.2.13\0"
|
||||||
VALUE "InternalName", "zlib\0"
|
VALUE "InternalName", "zlib\0"
|
||||||
VALUE "OriginalFilename", "zlibwapi.dll\0"
|
VALUE "OriginalFilename", "zlibwapi.dll\0"
|
||||||
VALUE "ProductName", "ZLib.DLL\0"
|
VALUE "ProductName", "ZLib.DLL\0"
|
||||||
VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0"
|
VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0"
|
||||||
VALUE "LegalCopyright", "(C) 1995-2017 Jean-loup Gailly & Mark Adler\0"
|
VALUE "LegalCopyright", "(C) 1995-2022 Jean-loup Gailly & Mark Adler\0"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
BLOCK "VarFileInfo"
|
BLOCK "VarFileInfo"
|
||||||
|
|
|
@ -151,3 +151,8 @@ EXPORTS
|
||||||
deflateGetDictionary @173
|
deflateGetDictionary @173
|
||||||
adler32_z @174
|
adler32_z @174
|
||||||
crc32_z @175
|
crc32_z @175
|
||||||
|
|
||||||
|
; zlib1 v1.2.12 added:
|
||||||
|
crc32_combine_gen @176
|
||||||
|
crc32_combine_gen64 @177
|
||||||
|
crc32_combine_op @178
|
||||||
|
|
1303
contrib/zlib/crc32.c
1303
contrib/zlib/crc32.c
File diff suppressed because it is too large
Load Diff
9877
contrib/zlib/crc32.h
9877
contrib/zlib/crc32.h
File diff suppressed because it is too large
Load Diff
|
@ -1,5 +1,5 @@
|
||||||
/* deflate.c -- compress data using the deflation algorithm
|
/* deflate.c -- compress data using the deflation algorithm
|
||||||
* Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler
|
* Copyright (C) 1995-2022 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
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@
|
||||||
#include "deflate.h"
|
#include "deflate.h"
|
||||||
|
|
||||||
const char deflate_copyright[] =
|
const char deflate_copyright[] =
|
||||||
" deflate 1.2.11.1 Copyright 1995-2017 Jean-loup Gailly and Mark Adler ";
|
" deflate 1.2.13 Copyright 1995-2022 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
|
||||||
|
@ -87,13 +87,7 @@ local void lm_init OF((deflate_state *s));
|
||||||
local void putShortMSB OF((deflate_state *s, uInt b));
|
local void putShortMSB OF((deflate_state *s, uInt b));
|
||||||
local void flush_pending OF((z_streamp strm));
|
local void flush_pending OF((z_streamp strm));
|
||||||
local unsigned read_buf OF((z_streamp strm, Bytef *buf, unsigned size));
|
local unsigned read_buf OF((z_streamp strm, Bytef *buf, unsigned size));
|
||||||
#ifdef ASMV
|
|
||||||
# pragma message("Assembler code may have bugs -- use at your own risk")
|
|
||||||
void match_init OF((void)); /* asm code initialization */
|
|
||||||
uInt longest_match OF((deflate_state *s, IPos cur_match));
|
|
||||||
#else
|
|
||||||
local uInt longest_match OF((deflate_state *s, IPos cur_match));
|
local uInt longest_match OF((deflate_state *s, IPos cur_match));
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef ZLIB_DEBUG
|
#ifdef ZLIB_DEBUG
|
||||||
local void check_match OF((deflate_state *s, IPos start, IPos match,
|
local void check_match OF((deflate_state *s, IPos start, IPos match,
|
||||||
|
@ -160,7 +154,7 @@ local const config configuration_table[10] = {
|
||||||
* characters, so that a running hash key can be computed from the previous
|
* characters, so that a running hash key can be computed from the previous
|
||||||
* key instead of complete recalculation each time.
|
* key instead of complete recalculation each time.
|
||||||
*/
|
*/
|
||||||
#define UPDATE_HASH(s,h,c) (h = (((h)<<s->hash_shift) ^ (c)) & s->hash_mask)
|
#define UPDATE_HASH(s,h,c) (h = (((h) << s->hash_shift) ^ (c)) & s->hash_mask)
|
||||||
|
|
||||||
|
|
||||||
/* ===========================================================================
|
/* ===========================================================================
|
||||||
|
@ -191,9 +185,9 @@ local const config configuration_table[10] = {
|
||||||
*/
|
*/
|
||||||
#define CLEAR_HASH(s) \
|
#define CLEAR_HASH(s) \
|
||||||
do { \
|
do { \
|
||||||
s->head[s->hash_size-1] = NIL; \
|
s->head[s->hash_size - 1] = NIL; \
|
||||||
zmemzero((Bytef *)s->head, \
|
zmemzero((Bytef *)s->head, \
|
||||||
(unsigned)(s->hash_size-1)*sizeof(*s->head)); \
|
(unsigned)(s->hash_size - 1)*sizeof(*s->head)); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
/* ===========================================================================
|
/* ===========================================================================
|
||||||
|
@ -255,11 +249,6 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
|
||||||
int wrap = 1;
|
int wrap = 1;
|
||||||
static const char my_version[] = ZLIB_VERSION;
|
static const char my_version[] = ZLIB_VERSION;
|
||||||
|
|
||||||
ushf *overlay;
|
|
||||||
/* We overlay pending_buf and d_buf+l_buf. This works since the average
|
|
||||||
* output size for (length,distance) codes is <= 24 bits.
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (version == Z_NULL || version[0] != my_version[0] ||
|
if (version == Z_NULL || version[0] != my_version[0] ||
|
||||||
stream_size != sizeof(z_stream)) {
|
stream_size != sizeof(z_stream)) {
|
||||||
return Z_VERSION_ERROR;
|
return Z_VERSION_ERROR;
|
||||||
|
@ -290,6 +279,8 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
|
||||||
|
|
||||||
if (windowBits < 0) { /* suppress zlib wrapper */
|
if (windowBits < 0) { /* suppress zlib wrapper */
|
||||||
wrap = 0;
|
wrap = 0;
|
||||||
|
if (windowBits < -15)
|
||||||
|
return Z_STREAM_ERROR;
|
||||||
windowBits = -windowBits;
|
windowBits = -windowBits;
|
||||||
}
|
}
|
||||||
#ifdef GZIP
|
#ifdef GZIP
|
||||||
|
@ -319,7 +310,7 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
|
||||||
s->hash_bits = (uInt)memLevel + 7;
|
s->hash_bits = (uInt)memLevel + 7;
|
||||||
s->hash_size = 1 << s->hash_bits;
|
s->hash_size = 1 << s->hash_bits;
|
||||||
s->hash_mask = s->hash_size - 1;
|
s->hash_mask = s->hash_size - 1;
|
||||||
s->hash_shift = ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH);
|
s->hash_shift = ((s->hash_bits + MIN_MATCH-1) / MIN_MATCH);
|
||||||
|
|
||||||
s->window = (Bytef *) ZALLOC(strm, s->w_size, 2*sizeof(Byte));
|
s->window = (Bytef *) ZALLOC(strm, s->w_size, 2*sizeof(Byte));
|
||||||
s->prev = (Posf *) ZALLOC(strm, s->w_size, sizeof(Pos));
|
s->prev = (Posf *) ZALLOC(strm, s->w_size, sizeof(Pos));
|
||||||
|
@ -329,9 +320,47 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
|
||||||
|
|
||||||
s->lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */
|
s->lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */
|
||||||
|
|
||||||
overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2);
|
/* We overlay pending_buf and sym_buf. This works since the average size
|
||||||
s->pending_buf = (uchf *) overlay;
|
* for length/distance pairs over any compressed block is assured to be 31
|
||||||
s->pending_buf_size = (ulg)s->lit_bufsize * (sizeof(ush)+2L);
|
* bits or less.
|
||||||
|
*
|
||||||
|
* Analysis: The longest fixed codes are a length code of 8 bits plus 5
|
||||||
|
* extra bits, for lengths 131 to 257. The longest fixed distance codes are
|
||||||
|
* 5 bits plus 13 extra bits, for distances 16385 to 32768. The longest
|
||||||
|
* possible fixed-codes length/distance pair is then 31 bits total.
|
||||||
|
*
|
||||||
|
* sym_buf starts one-fourth of the way into pending_buf. So there are
|
||||||
|
* three bytes in sym_buf for every four bytes in pending_buf. Each symbol
|
||||||
|
* in sym_buf is three bytes -- two for the distance and one for the
|
||||||
|
* literal/length. As each symbol is consumed, the pointer to the next
|
||||||
|
* sym_buf value to read moves forward three bytes. From that symbol, up to
|
||||||
|
* 31 bits are written to pending_buf. The closest the written pending_buf
|
||||||
|
* bits gets to the next sym_buf symbol to read is just before the last
|
||||||
|
* code is written. At that time, 31*(n - 2) bits have been written, just
|
||||||
|
* after 24*(n - 2) bits have been consumed from sym_buf. sym_buf starts at
|
||||||
|
* 8*n bits into pending_buf. (Note that the symbol buffer fills when n - 1
|
||||||
|
* symbols are written.) The closest the writing gets to what is unread is
|
||||||
|
* then n + 14 bits. Here n is lit_bufsize, which is 16384 by default, and
|
||||||
|
* can range from 128 to 32768.
|
||||||
|
*
|
||||||
|
* Therefore, at a minimum, there are 142 bits of space between what is
|
||||||
|
* written and what is read in the overlain buffers, so the symbols cannot
|
||||||
|
* be overwritten by the compressed data. That space is actually 139 bits,
|
||||||
|
* due to the three-bit fixed-code block header.
|
||||||
|
*
|
||||||
|
* That covers the case where either Z_FIXED is specified, forcing fixed
|
||||||
|
* codes, or when the use of fixed codes is chosen, because that choice
|
||||||
|
* results in a smaller compressed block than dynamic codes. That latter
|
||||||
|
* condition then assures that the above analysis also covers all dynamic
|
||||||
|
* blocks. A dynamic-code block will only be chosen to be emitted if it has
|
||||||
|
* fewer bits than a fixed-code block would for the same set of symbols.
|
||||||
|
* Therefore its average symbol length is assured to be less than 31. So
|
||||||
|
* the compressed data for a dynamic block also cannot overwrite the
|
||||||
|
* symbols from which it is being constructed.
|
||||||
|
*/
|
||||||
|
|
||||||
|
s->pending_buf = (uchf *) ZALLOC(strm, s->lit_bufsize, 4);
|
||||||
|
s->pending_buf_size = (ulg)s->lit_bufsize * 4;
|
||||||
|
|
||||||
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) {
|
||||||
|
@ -340,8 +369,12 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
|
||||||
deflateEnd (strm);
|
deflateEnd (strm);
|
||||||
return Z_MEM_ERROR;
|
return Z_MEM_ERROR;
|
||||||
}
|
}
|
||||||
s->d_buf = overlay + s->lit_bufsize/sizeof(ush);
|
s->sym_buf = s->pending_buf + s->lit_bufsize;
|
||||||
s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize;
|
s->sym_end = (s->lit_bufsize - 1) * 3;
|
||||||
|
/* We avoid equality with lit_bufsize*3 because of wraparound at 64K
|
||||||
|
* on 16 bit machines and because stored blocks are restricted to
|
||||||
|
* 64K-1 bytes.
|
||||||
|
*/
|
||||||
|
|
||||||
s->level = level;
|
s->level = level;
|
||||||
s->strategy = strategy;
|
s->strategy = strategy;
|
||||||
|
@ -353,7 +386,7 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
|
||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
* Check for a valid deflate stream state. Return 0 if ok, 1 if not.
|
* Check for a valid deflate stream state. Return 0 if ok, 1 if not.
|
||||||
*/
|
*/
|
||||||
local int deflateStateCheck (strm)
|
local int deflateStateCheck(strm)
|
||||||
z_streamp strm;
|
z_streamp strm;
|
||||||
{
|
{
|
||||||
deflate_state *s;
|
deflate_state *s;
|
||||||
|
@ -376,7 +409,7 @@ local int deflateStateCheck (strm)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ========================================================================= */
|
/* ========================================================================= */
|
||||||
int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength)
|
int ZEXPORT deflateSetDictionary(strm, dictionary, dictLength)
|
||||||
z_streamp strm;
|
z_streamp strm;
|
||||||
const Bytef *dictionary;
|
const Bytef *dictionary;
|
||||||
uInt dictLength;
|
uInt dictLength;
|
||||||
|
@ -445,7 +478,7 @@ int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ========================================================================= */
|
/* ========================================================================= */
|
||||||
int ZEXPORT deflateGetDictionary (strm, dictionary, dictLength)
|
int ZEXPORT deflateGetDictionary(strm, dictionary, dictLength)
|
||||||
z_streamp strm;
|
z_streamp strm;
|
||||||
Bytef *dictionary;
|
Bytef *dictionary;
|
||||||
uInt *dictLength;
|
uInt *dictLength;
|
||||||
|
@ -467,7 +500,7 @@ int ZEXPORT deflateGetDictionary (strm, dictionary, dictLength)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ========================================================================= */
|
/* ========================================================================= */
|
||||||
int ZEXPORT deflateResetKeep (strm)
|
int ZEXPORT deflateResetKeep(strm)
|
||||||
z_streamp strm;
|
z_streamp strm;
|
||||||
{
|
{
|
||||||
deflate_state *s;
|
deflate_state *s;
|
||||||
|
@ -491,7 +524,7 @@ int ZEXPORT deflateResetKeep (strm)
|
||||||
#ifdef GZIP
|
#ifdef GZIP
|
||||||
s->wrap == 2 ? GZIP_STATE :
|
s->wrap == 2 ? GZIP_STATE :
|
||||||
#endif
|
#endif
|
||||||
s->wrap ? INIT_STATE : BUSY_STATE;
|
INIT_STATE;
|
||||||
strm->adler =
|
strm->adler =
|
||||||
#ifdef GZIP
|
#ifdef GZIP
|
||||||
s->wrap == 2 ? crc32(0L, Z_NULL, 0) :
|
s->wrap == 2 ? crc32(0L, Z_NULL, 0) :
|
||||||
|
@ -505,7 +538,7 @@ int ZEXPORT deflateResetKeep (strm)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ========================================================================= */
|
/* ========================================================================= */
|
||||||
int ZEXPORT deflateReset (strm)
|
int ZEXPORT deflateReset(strm)
|
||||||
z_streamp strm;
|
z_streamp strm;
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -517,7 +550,7 @@ int ZEXPORT deflateReset (strm)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ========================================================================= */
|
/* ========================================================================= */
|
||||||
int ZEXPORT deflateSetHeader (strm, head)
|
int ZEXPORT deflateSetHeader(strm, head)
|
||||||
z_streamp strm;
|
z_streamp strm;
|
||||||
gz_headerp head;
|
gz_headerp head;
|
||||||
{
|
{
|
||||||
|
@ -528,7 +561,7 @@ int ZEXPORT deflateSetHeader (strm, head)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ========================================================================= */
|
/* ========================================================================= */
|
||||||
int ZEXPORT deflatePending (strm, pending, bits)
|
int ZEXPORT deflatePending(strm, pending, bits)
|
||||||
unsigned *pending;
|
unsigned *pending;
|
||||||
int *bits;
|
int *bits;
|
||||||
z_streamp strm;
|
z_streamp strm;
|
||||||
|
@ -542,7 +575,7 @@ int ZEXPORT deflatePending (strm, pending, bits)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ========================================================================= */
|
/* ========================================================================= */
|
||||||
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;
|
||||||
|
@ -552,7 +585,8 @@ int ZEXPORT deflatePrime (strm, bits, value)
|
||||||
|
|
||||||
if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
|
if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
|
||||||
s = strm->state;
|
s = strm->state;
|
||||||
if ((Bytef *)(s->d_buf) < s->pending_out + ((Buf_size + 7) >> 3))
|
if (bits < 0 || bits > 16 ||
|
||||||
|
s->sym_buf < s->pending_out + ((Buf_size + 7) >> 3))
|
||||||
return Z_BUF_ERROR;
|
return Z_BUF_ERROR;
|
||||||
do {
|
do {
|
||||||
put = Buf_size - s->bi_valid;
|
put = Buf_size - s->bi_valid;
|
||||||
|
@ -636,36 +670,50 @@ int ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
* For the default windowBits of 15 and memLevel of 8, this function returns
|
* For the default windowBits of 15 and memLevel of 8, this function returns a
|
||||||
* a close to exact, as well as small, upper bound on the compressed size.
|
* close to exact, as well as small, upper bound on the compressed size. This
|
||||||
* They are coded as constants here for a reason--if the #define's are
|
* is an expansion of ~0.03%, plus a small constant.
|
||||||
* changed, then this function needs to be changed as well. The return
|
|
||||||
* value for 15 and 8 only works for those exact settings.
|
|
||||||
*
|
*
|
||||||
* For any setting other than those defaults for windowBits and memLevel,
|
* For any setting other than those defaults for windowBits and memLevel, one
|
||||||
* the value returned is a conservative worst case for the maximum expansion
|
* of two worst case bounds is returned. This is at most an expansion of ~4% or
|
||||||
* resulting from using fixed blocks instead of stored blocks, which deflate
|
* ~13%, plus a small constant.
|
||||||
* can emit on compressed data for some combinations of the parameters.
|
|
||||||
*
|
*
|
||||||
* This function could be more sophisticated to provide closer upper bounds for
|
* Both the 0.03% and 4% derive from the overhead of stored blocks. The first
|
||||||
* every combination of windowBits and memLevel. But even the conservative
|
* one is for stored blocks of 16383 bytes (memLevel == 8), whereas the second
|
||||||
* upper bound of about 14% expansion does not seem onerous for output buffer
|
* is for stored blocks of 127 bytes (the worst case memLevel == 1). The
|
||||||
* allocation.
|
* expansion results from five bytes of header for each stored block.
|
||||||
|
*
|
||||||
|
* The larger expansion of 13% results from a window size less than or equal to
|
||||||
|
* the symbols buffer size (windowBits <= memLevel + 7). In that case some of
|
||||||
|
* the data being compressed may have slid out of the sliding window, impeding
|
||||||
|
* a stored block from being emitted. Then the only choice is a fixed or
|
||||||
|
* dynamic block, where a fixed block limits the maximum expansion to 9 bits
|
||||||
|
* per 8-bit byte, plus 10 bits for every block. The smallest block size for
|
||||||
|
* which this can occur is 255 (memLevel == 2).
|
||||||
|
*
|
||||||
|
* Shifts are used to approximate divisions, for speed.
|
||||||
*/
|
*/
|
||||||
uLong ZEXPORT deflateBound(strm, sourceLen)
|
uLong ZEXPORT deflateBound(strm, sourceLen)
|
||||||
z_streamp strm;
|
z_streamp strm;
|
||||||
uLong sourceLen;
|
uLong sourceLen;
|
||||||
{
|
{
|
||||||
deflate_state *s;
|
deflate_state *s;
|
||||||
uLong complen, wraplen;
|
uLong fixedlen, storelen, wraplen;
|
||||||
|
|
||||||
/* conservative upper bound for compressed data */
|
/* upper bound for fixed blocks with 9-bit literals and length 255
|
||||||
complen = sourceLen +
|
(memLevel == 2, which is the lowest that may not use stored blocks) --
|
||||||
((sourceLen + 7) >> 3) + ((sourceLen + 63) >> 6) + 5;
|
~13% overhead plus a small constant */
|
||||||
|
fixedlen = sourceLen + (sourceLen >> 3) + (sourceLen >> 8) +
|
||||||
|
(sourceLen >> 9) + 4;
|
||||||
|
|
||||||
/* if can't get parameters, return conservative bound plus zlib wrapper */
|
/* upper bound for stored blocks with length 127 (memLevel == 1) --
|
||||||
|
~4% overhead plus a small constant */
|
||||||
|
storelen = sourceLen + (sourceLen >> 5) + (sourceLen >> 7) +
|
||||||
|
(sourceLen >> 11) + 7;
|
||||||
|
|
||||||
|
/* if can't get parameters, return larger bound plus a zlib wrapper */
|
||||||
if (deflateStateCheck(strm))
|
if (deflateStateCheck(strm))
|
||||||
return complen + 6;
|
return (fixedlen > storelen ? fixedlen : storelen) + 6;
|
||||||
|
|
||||||
/* compute wrapper length */
|
/* compute wrapper length */
|
||||||
s = strm->state;
|
s = strm->state;
|
||||||
|
@ -702,11 +750,12 @@ uLong ZEXPORT deflateBound(strm, sourceLen)
|
||||||
wraplen = 6;
|
wraplen = 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if not default parameters, return conservative bound */
|
/* if not default parameters, return one of the conservative bounds */
|
||||||
if (s->w_bits != 15 || s->hash_bits != 8 + 7)
|
if (s->w_bits != 15 || s->hash_bits != 8 + 7)
|
||||||
return complen + wraplen;
|
return (s->w_bits <= s->hash_bits ? fixedlen : storelen) + wraplen;
|
||||||
|
|
||||||
/* default settings: return tight bound for that case */
|
/* default settings: return tight bound for that case -- ~0.03% overhead
|
||||||
|
plus a small constant */
|
||||||
return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
|
return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
|
||||||
(sourceLen >> 25) + 13 - 6 + wraplen;
|
(sourceLen >> 25) + 13 - 6 + wraplen;
|
||||||
}
|
}
|
||||||
|
@ -716,7 +765,7 @@ uLong ZEXPORT deflateBound(strm, sourceLen)
|
||||||
* IN assertion: the stream state is correct and there is enough room in
|
* IN assertion: the stream state is correct and there is enough room in
|
||||||
* pending_buf.
|
* pending_buf.
|
||||||
*/
|
*/
|
||||||
local void putShortMSB (s, b)
|
local void putShortMSB(s, b)
|
||||||
deflate_state *s;
|
deflate_state *s;
|
||||||
uInt b;
|
uInt b;
|
||||||
{
|
{
|
||||||
|
@ -763,7 +812,7 @@ local void flush_pending(strm)
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
/* ========================================================================= */
|
/* ========================================================================= */
|
||||||
int ZEXPORT deflate (strm, flush)
|
int ZEXPORT deflate(strm, flush)
|
||||||
z_streamp strm;
|
z_streamp strm;
|
||||||
int flush;
|
int flush;
|
||||||
{
|
{
|
||||||
|
@ -814,9 +863,11 @@ int ZEXPORT deflate (strm, flush)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write the header */
|
/* Write the header */
|
||||||
|
if (s->status == INIT_STATE && s->wrap == 0)
|
||||||
|
s->status = BUSY_STATE;
|
||||||
if (s->status == INIT_STATE) {
|
if (s->status == INIT_STATE) {
|
||||||
/* zlib header */
|
/* zlib header */
|
||||||
uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8;
|
uInt header = (Z_DEFLATED + ((s->w_bits - 8) << 4)) << 8;
|
||||||
uInt level_flags;
|
uInt level_flags;
|
||||||
|
|
||||||
if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2)
|
if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2)
|
||||||
|
@ -1076,7 +1127,7 @@ int ZEXPORT deflate (strm, flush)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ========================================================================= */
|
/* ========================================================================= */
|
||||||
int ZEXPORT deflateEnd (strm)
|
int ZEXPORT deflateEnd(strm)
|
||||||
z_streamp strm;
|
z_streamp strm;
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
|
@ -1102,7 +1153,7 @@ int ZEXPORT deflateEnd (strm)
|
||||||
* To simplify the source, this is not supported for 16-bit MSDOS (which
|
* To simplify the source, this is not supported for 16-bit MSDOS (which
|
||||||
* doesn't have enough memory anyway to duplicate compression states).
|
* doesn't have enough memory anyway to duplicate compression states).
|
||||||
*/
|
*/
|
||||||
int ZEXPORT deflateCopy (dest, source)
|
int ZEXPORT deflateCopy(dest, source)
|
||||||
z_streamp dest;
|
z_streamp dest;
|
||||||
z_streamp source;
|
z_streamp source;
|
||||||
{
|
{
|
||||||
|
@ -1111,7 +1162,6 @@ int ZEXPORT deflateCopy (dest, source)
|
||||||
#else
|
#else
|
||||||
deflate_state *ds;
|
deflate_state *ds;
|
||||||
deflate_state *ss;
|
deflate_state *ss;
|
||||||
ushf *overlay;
|
|
||||||
|
|
||||||
|
|
||||||
if (deflateStateCheck(source) || dest == Z_NULL) {
|
if (deflateStateCheck(source) || dest == Z_NULL) {
|
||||||
|
@ -1131,8 +1181,7 @@ int ZEXPORT deflateCopy (dest, source)
|
||||||
ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte));
|
ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte));
|
||||||
ds->prev = (Posf *) ZALLOC(dest, ds->w_size, sizeof(Pos));
|
ds->prev = (Posf *) ZALLOC(dest, ds->w_size, sizeof(Pos));
|
||||||
ds->head = (Posf *) ZALLOC(dest, ds->hash_size, sizeof(Pos));
|
ds->head = (Posf *) ZALLOC(dest, ds->hash_size, sizeof(Pos));
|
||||||
overlay = (ushf *) ZALLOC(dest, ds->lit_bufsize, sizeof(ush)+2);
|
ds->pending_buf = (uchf *) ZALLOC(dest, ds->lit_bufsize, 4);
|
||||||
ds->pending_buf = (uchf *) overlay;
|
|
||||||
|
|
||||||
if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL ||
|
if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL ||
|
||||||
ds->pending_buf == Z_NULL) {
|
ds->pending_buf == Z_NULL) {
|
||||||
|
@ -1146,8 +1195,7 @@ int ZEXPORT deflateCopy (dest, source)
|
||||||
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);
|
||||||
ds->d_buf = overlay + ds->lit_bufsize/sizeof(ush);
|
ds->sym_buf = ds->pending_buf + ds->lit_bufsize;
|
||||||
ds->l_buf = ds->pending_buf + (1+sizeof(ush))*ds->lit_bufsize;
|
|
||||||
|
|
||||||
ds->l_desc.dyn_tree = ds->dyn_ltree;
|
ds->l_desc.dyn_tree = ds->dyn_ltree;
|
||||||
ds->d_desc.dyn_tree = ds->dyn_dtree;
|
ds->d_desc.dyn_tree = ds->dyn_dtree;
|
||||||
|
@ -1194,7 +1242,7 @@ local unsigned read_buf(strm, buf, size)
|
||||||
/* ===========================================================================
|
/* ===========================================================================
|
||||||
* Initialize the "longest match" routines for a new zlib stream
|
* Initialize the "longest match" routines for a new zlib stream
|
||||||
*/
|
*/
|
||||||
local void lm_init (s)
|
local void lm_init(s)
|
||||||
deflate_state *s;
|
deflate_state *s;
|
||||||
{
|
{
|
||||||
s->window_size = (ulg)2L*s->w_size;
|
s->window_size = (ulg)2L*s->w_size;
|
||||||
|
@ -1215,11 +1263,6 @@ local void lm_init (s)
|
||||||
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;
|
||||||
#ifndef FASTEST
|
|
||||||
#ifdef ASMV
|
|
||||||
match_init(); /* initialize the asm code */
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef FASTEST
|
#ifndef FASTEST
|
||||||
|
@ -1232,10 +1275,6 @@ local void lm_init (s)
|
||||||
* string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1
|
* string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1
|
||||||
* OUT assertion: the match length is not greater than s->lookahead.
|
* OUT assertion: the match length is not greater than s->lookahead.
|
||||||
*/
|
*/
|
||||||
#ifndef ASMV
|
|
||||||
/* For 80x86 and 680x0, an optimized version will be provided in match.asm or
|
|
||||||
* match.S. The code will be functionally equivalent.
|
|
||||||
*/
|
|
||||||
local uInt longest_match(s, cur_match)
|
local uInt longest_match(s, cur_match)
|
||||||
deflate_state *s;
|
deflate_state *s;
|
||||||
IPos cur_match; /* current match */
|
IPos cur_match; /* current match */
|
||||||
|
@ -1260,10 +1299,10 @@ local uInt longest_match(s, cur_match)
|
||||||
*/
|
*/
|
||||||
register Bytef *strend = s->window + s->strstart + MAX_MATCH - 1;
|
register Bytef *strend = s->window + s->strstart + MAX_MATCH - 1;
|
||||||
register ush scan_start = *(ushf*)scan;
|
register ush scan_start = *(ushf*)scan;
|
||||||
register ush scan_end = *(ushf*)(scan+best_len-1);
|
register ush scan_end = *(ushf*)(scan + best_len - 1);
|
||||||
#else
|
#else
|
||||||
register Bytef *strend = s->window + s->strstart + MAX_MATCH;
|
register Bytef *strend = s->window + s->strstart + MAX_MATCH;
|
||||||
register Byte scan_end1 = scan[best_len-1];
|
register Byte scan_end1 = scan[best_len - 1];
|
||||||
register Byte scan_end = scan[best_len];
|
register Byte scan_end = scan[best_len];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1281,7 +1320,8 @@ local uInt longest_match(s, cur_match)
|
||||||
*/
|
*/
|
||||||
if ((uInt)nice_match > s->lookahead) nice_match = (int)s->lookahead;
|
if ((uInt)nice_match > s->lookahead) nice_match = (int)s->lookahead;
|
||||||
|
|
||||||
Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead");
|
Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD,
|
||||||
|
"need lookahead");
|
||||||
|
|
||||||
do {
|
do {
|
||||||
Assert(cur_match < s->strstart, "no future");
|
Assert(cur_match < s->strstart, "no future");
|
||||||
|
@ -1299,43 +1339,44 @@ local uInt longest_match(s, cur_match)
|
||||||
/* This code assumes sizeof(unsigned short) == 2. Do not use
|
/* This code assumes sizeof(unsigned short) == 2. Do not use
|
||||||
* UNALIGNED_OK if your compiler uses a different size.
|
* UNALIGNED_OK if your compiler uses a different size.
|
||||||
*/
|
*/
|
||||||
if (*(ushf*)(match+best_len-1) != scan_end ||
|
if (*(ushf*)(match + best_len - 1) != scan_end ||
|
||||||
*(ushf*)match != scan_start) continue;
|
*(ushf*)match != scan_start) continue;
|
||||||
|
|
||||||
/* It is not necessary to compare scan[2] and match[2] since they are
|
/* It is not necessary to compare scan[2] and match[2] since they are
|
||||||
* always equal when the other bytes match, given that the hash keys
|
* always equal when the other bytes match, given that the hash keys
|
||||||
* are equal and that HASH_BITS >= 8. Compare 2 bytes at a time at
|
* are equal and that HASH_BITS >= 8. Compare 2 bytes at a time at
|
||||||
* strstart+3, +5, ... up to strstart+257. We check for insufficient
|
* strstart + 3, + 5, up to strstart + 257. We check for insufficient
|
||||||
* lookahead only every 4th comparison; the 128th check will be made
|
* lookahead only every 4th comparison; the 128th check will be made
|
||||||
* at strstart+257. If MAX_MATCH-2 is not a multiple of 8, it is
|
* at strstart + 257. If MAX_MATCH-2 is not a multiple of 8, it is
|
||||||
* necessary to put more guard bytes at the end of the window, or
|
* necessary to put more guard bytes at the end of the window, or
|
||||||
* to check more often for insufficient lookahead.
|
* to check more often for insufficient lookahead.
|
||||||
*/
|
*/
|
||||||
Assert(scan[2] == match[2], "scan[2]?");
|
Assert(scan[2] == match[2], "scan[2]?");
|
||||||
scan++, match++;
|
scan++, match++;
|
||||||
do {
|
do {
|
||||||
} while (*(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
|
} while (*(ushf*)(scan += 2) == *(ushf*)(match += 2) &&
|
||||||
*(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
|
*(ushf*)(scan += 2) == *(ushf*)(match += 2) &&
|
||||||
*(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
|
*(ushf*)(scan += 2) == *(ushf*)(match += 2) &&
|
||||||
*(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
|
*(ushf*)(scan += 2) == *(ushf*)(match += 2) &&
|
||||||
scan < strend);
|
scan < strend);
|
||||||
/* The funny "do {}" generates better code on most compilers */
|
/* The funny "do {}" generates better code on most compilers */
|
||||||
|
|
||||||
/* Here, scan <= window+strstart+257 */
|
/* Here, scan <= window + strstart + 257 */
|
||||||
Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
|
Assert(scan <= s->window + (unsigned)(s->window_size - 1),
|
||||||
|
"wild scan");
|
||||||
if (*scan == *match) scan++;
|
if (*scan == *match) scan++;
|
||||||
|
|
||||||
len = (MAX_MATCH - 1) - (int)(strend-scan);
|
len = (MAX_MATCH - 1) - (int)(strend - scan);
|
||||||
scan = strend - (MAX_MATCH-1);
|
scan = strend - (MAX_MATCH-1);
|
||||||
|
|
||||||
#else /* UNALIGNED_OK */
|
#else /* UNALIGNED_OK */
|
||||||
|
|
||||||
if (match[best_len] != scan_end ||
|
if (match[best_len] != scan_end ||
|
||||||
match[best_len-1] != scan_end1 ||
|
match[best_len - 1] != scan_end1 ||
|
||||||
*match != *scan ||
|
*match != *scan ||
|
||||||
*++match != scan[1]) continue;
|
*++match != scan[1]) continue;
|
||||||
|
|
||||||
/* The check at best_len-1 can be removed because it will be made
|
/* The check at best_len - 1 can be removed because it will be made
|
||||||
* again later. (This heuristic is not always a win.)
|
* again later. (This heuristic is not always a win.)
|
||||||
* It is not necessary to compare scan[2] and match[2] since they
|
* It is not necessary to compare scan[2] and match[2] since they
|
||||||
* are always equal when the other bytes match, given that
|
* are always equal when the other bytes match, given that
|
||||||
|
@ -1345,7 +1386,7 @@ local uInt longest_match(s, cur_match)
|
||||||
Assert(*scan == *match, "match[2]?");
|
Assert(*scan == *match, "match[2]?");
|
||||||
|
|
||||||
/* We check for insufficient lookahead only every 8th comparison;
|
/* We check for insufficient lookahead only every 8th comparison;
|
||||||
* the 256th check will be made at strstart+258.
|
* the 256th check will be made at strstart + 258.
|
||||||
*/
|
*/
|
||||||
do {
|
do {
|
||||||
} while (*++scan == *++match && *++scan == *++match &&
|
} while (*++scan == *++match && *++scan == *++match &&
|
||||||
|
@ -1354,7 +1395,8 @@ local uInt longest_match(s, cur_match)
|
||||||
*++scan == *++match && *++scan == *++match &&
|
*++scan == *++match && *++scan == *++match &&
|
||||||
scan < strend);
|
scan < strend);
|
||||||
|
|
||||||
Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
|
Assert(scan <= s->window + (unsigned)(s->window_size - 1),
|
||||||
|
"wild scan");
|
||||||
|
|
||||||
len = MAX_MATCH - (int)(strend - scan);
|
len = MAX_MATCH - (int)(strend - scan);
|
||||||
scan = strend - MAX_MATCH;
|
scan = strend - MAX_MATCH;
|
||||||
|
@ -1366,9 +1408,9 @@ local uInt longest_match(s, cur_match)
|
||||||
best_len = len;
|
best_len = len;
|
||||||
if (len >= nice_match) break;
|
if (len >= nice_match) break;
|
||||||
#ifdef UNALIGNED_OK
|
#ifdef UNALIGNED_OK
|
||||||
scan_end = *(ushf*)(scan+best_len-1);
|
scan_end = *(ushf*)(scan + best_len - 1);
|
||||||
#else
|
#else
|
||||||
scan_end1 = scan[best_len-1];
|
scan_end1 = scan[best_len - 1];
|
||||||
scan_end = scan[best_len];
|
scan_end = scan[best_len];
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -1378,7 +1420,6 @@ local uInt longest_match(s, cur_match)
|
||||||
if ((uInt)best_len <= s->lookahead) return (uInt)best_len;
|
if ((uInt)best_len <= s->lookahead) return (uInt)best_len;
|
||||||
return s->lookahead;
|
return s->lookahead;
|
||||||
}
|
}
|
||||||
#endif /* ASMV */
|
|
||||||
|
|
||||||
#else /* FASTEST */
|
#else /* FASTEST */
|
||||||
|
|
||||||
|
@ -1399,7 +1440,8 @@ local uInt longest_match(s, cur_match)
|
||||||
*/
|
*/
|
||||||
Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever");
|
Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever");
|
||||||
|
|
||||||
Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead");
|
Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD,
|
||||||
|
"need lookahead");
|
||||||
|
|
||||||
Assert(cur_match < s->strstart, "no future");
|
Assert(cur_match < s->strstart, "no future");
|
||||||
|
|
||||||
|
@ -1409,7 +1451,7 @@ local uInt longest_match(s, cur_match)
|
||||||
*/
|
*/
|
||||||
if (match[0] != scan[0] || match[1] != scan[1]) return MIN_MATCH-1;
|
if (match[0] != scan[0] || match[1] != scan[1]) return MIN_MATCH-1;
|
||||||
|
|
||||||
/* The check at best_len-1 can be removed because it will be made
|
/* The check at best_len - 1 can be removed because it will be made
|
||||||
* again later. (This heuristic is not always a win.)
|
* again later. (This heuristic is not always a win.)
|
||||||
* It is not necessary to compare scan[2] and match[2] since they
|
* It is not necessary to compare scan[2] and match[2] since they
|
||||||
* are always equal when the other bytes match, given that
|
* are always equal when the other bytes match, given that
|
||||||
|
@ -1419,7 +1461,7 @@ local uInt longest_match(s, cur_match)
|
||||||
Assert(*scan == *match, "match[2]?");
|
Assert(*scan == *match, "match[2]?");
|
||||||
|
|
||||||
/* We check for insufficient lookahead only every 8th comparison;
|
/* We check for insufficient lookahead only every 8th comparison;
|
||||||
* the 256th check will be made at strstart+258.
|
* the 256th check will be made at strstart + 258.
|
||||||
*/
|
*/
|
||||||
do {
|
do {
|
||||||
} while (*++scan == *++match && *++scan == *++match &&
|
} while (*++scan == *++match && *++scan == *++match &&
|
||||||
|
@ -1428,7 +1470,7 @@ local uInt longest_match(s, cur_match)
|
||||||
*++scan == *++match && *++scan == *++match &&
|
*++scan == *++match && *++scan == *++match &&
|
||||||
scan < strend);
|
scan < strend);
|
||||||
|
|
||||||
Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
|
Assert(scan <= s->window + (unsigned)(s->window_size - 1), "wild scan");
|
||||||
|
|
||||||
len = MAX_MATCH - (int)(strend - scan);
|
len = MAX_MATCH - (int)(strend - scan);
|
||||||
|
|
||||||
|
@ -1464,7 +1506,7 @@ local void check_match(s, start, match, length)
|
||||||
z_error("invalid match");
|
z_error("invalid match");
|
||||||
}
|
}
|
||||||
if (z_verbose > 1) {
|
if (z_verbose > 1) {
|
||||||
fprintf(stderr,"\\[%d,%d]", start-match, length);
|
fprintf(stderr,"\\[%d,%d]", start - match, length);
|
||||||
do { putc(s->window[start++], stderr); } while (--length != 0);
|
do { putc(s->window[start++], stderr); } while (--length != 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1510,9 +1552,9 @@ local void fill_window(s)
|
||||||
/* If the window is almost full and there is insufficient lookahead,
|
/* If the window is almost full and there is insufficient lookahead,
|
||||||
* move the upper half to the lower one to make room in the upper half.
|
* move the upper half to the lower one to make room in the upper half.
|
||||||
*/
|
*/
|
||||||
if (s->strstart >= wsize+MAX_DIST(s)) {
|
if (s->strstart >= wsize + MAX_DIST(s)) {
|
||||||
|
|
||||||
zmemcpy(s->window, s->window+wsize, (unsigned)wsize - more);
|
zmemcpy(s->window, s->window + wsize, (unsigned)wsize - more);
|
||||||
s->match_start -= wsize;
|
s->match_start -= wsize;
|
||||||
s->strstart -= wsize; /* we now have strstart >= MAX_DIST */
|
s->strstart -= wsize; /* we now have strstart >= MAX_DIST */
|
||||||
s->block_start -= (long) wsize;
|
s->block_start -= (long) wsize;
|
||||||
|
@ -1643,7 +1685,7 @@ local void fill_window(s)
|
||||||
*
|
*
|
||||||
* deflate_stored() is written to minimize the number of times an input byte is
|
* deflate_stored() is written to minimize the number of times an input byte is
|
||||||
* copied. It is most efficient with large input and output buffers, which
|
* copied. It is most efficient with large input and output buffers, which
|
||||||
* maximizes the opportunites to have a single copy from next_in to next_out.
|
* maximizes the opportunities to have a single copy from next_in to next_out.
|
||||||
*/
|
*/
|
||||||
local block_state deflate_stored(s, flush)
|
local block_state deflate_stored(s, flush)
|
||||||
deflate_state *s;
|
deflate_state *s;
|
||||||
|
@ -1853,7 +1895,7 @@ local block_state deflate_fast(s, flush)
|
||||||
if (s->lookahead == 0) break; /* flush the current block */
|
if (s->lookahead == 0) break; /* flush the current block */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Insert the string window[strstart .. strstart+2] in the
|
/* Insert the string window[strstart .. strstart + 2] in the
|
||||||
* dictionary, and set hash_head to the head of the hash chain:
|
* dictionary, and set hash_head to the head of the hash chain:
|
||||||
*/
|
*/
|
||||||
hash_head = NIL;
|
hash_head = NIL;
|
||||||
|
@ -1901,7 +1943,7 @@ local block_state deflate_fast(s, flush)
|
||||||
s->strstart += s->match_length;
|
s->strstart += s->match_length;
|
||||||
s->match_length = 0;
|
s->match_length = 0;
|
||||||
s->ins_h = s->window[s->strstart];
|
s->ins_h = s->window[s->strstart];
|
||||||
UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]);
|
UPDATE_HASH(s, s->ins_h, s->window[s->strstart + 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
|
||||||
|
@ -1912,7 +1954,7 @@ local block_state deflate_fast(s, flush)
|
||||||
} else {
|
} else {
|
||||||
/* No match, output a literal byte */
|
/* No match, output a literal byte */
|
||||||
Tracevv((stderr,"%c", s->window[s->strstart]));
|
Tracevv((stderr,"%c", s->window[s->strstart]));
|
||||||
_tr_tally_lit (s, s->window[s->strstart], bflush);
|
_tr_tally_lit(s, s->window[s->strstart], bflush);
|
||||||
s->lookahead--;
|
s->lookahead--;
|
||||||
s->strstart++;
|
s->strstart++;
|
||||||
}
|
}
|
||||||
|
@ -1923,7 +1965,7 @@ local block_state deflate_fast(s, flush)
|
||||||
FLUSH_BLOCK(s, 1);
|
FLUSH_BLOCK(s, 1);
|
||||||
return finish_done;
|
return finish_done;
|
||||||
}
|
}
|
||||||
if (s->last_lit)
|
if (s->sym_next)
|
||||||
FLUSH_BLOCK(s, 0);
|
FLUSH_BLOCK(s, 0);
|
||||||
return block_done;
|
return block_done;
|
||||||
}
|
}
|
||||||
|
@ -1956,7 +1998,7 @@ local block_state deflate_slow(s, flush)
|
||||||
if (s->lookahead == 0) break; /* flush the current block */
|
if (s->lookahead == 0) break; /* flush the current block */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Insert the string window[strstart .. strstart+2] in the
|
/* Insert the string window[strstart .. strstart + 2] in the
|
||||||
* dictionary, and set hash_head to the head of the hash chain:
|
* dictionary, and set hash_head to the head of the hash chain:
|
||||||
*/
|
*/
|
||||||
hash_head = NIL;
|
hash_head = NIL;
|
||||||
|
@ -1998,17 +2040,17 @@ local block_state deflate_slow(s, flush)
|
||||||
uInt max_insert = s->strstart + s->lookahead - MIN_MATCH;
|
uInt max_insert = s->strstart + s->lookahead - MIN_MATCH;
|
||||||
/* Do not insert strings in hash table beyond this. */
|
/* Do not insert strings in hash table beyond this. */
|
||||||
|
|
||||||
check_match(s, s->strstart-1, s->prev_match, s->prev_length);
|
check_match(s, s->strstart - 1, s->prev_match, s->prev_length);
|
||||||
|
|
||||||
_tr_tally_dist(s, s->strstart -1 - s->prev_match,
|
_tr_tally_dist(s, s->strstart - 1 - s->prev_match,
|
||||||
s->prev_length - MIN_MATCH, bflush);
|
s->prev_length - MIN_MATCH, bflush);
|
||||||
|
|
||||||
/* Insert in hash table all strings up to the end of the match.
|
/* Insert in hash table all strings up to the end of the match.
|
||||||
* strstart-1 and strstart are already inserted. If there is not
|
* strstart - 1 and strstart are already inserted. If there is not
|
||||||
* enough lookahead, the last two strings are not inserted in
|
* enough lookahead, the last two strings are not inserted in
|
||||||
* the hash table.
|
* the hash table.
|
||||||
*/
|
*/
|
||||||
s->lookahead -= s->prev_length-1;
|
s->lookahead -= s->prev_length - 1;
|
||||||
s->prev_length -= 2;
|
s->prev_length -= 2;
|
||||||
do {
|
do {
|
||||||
if (++s->strstart <= max_insert) {
|
if (++s->strstart <= max_insert) {
|
||||||
|
@ -2026,8 +2068,8 @@ local block_state deflate_slow(s, flush)
|
||||||
* single literal. If there was a match but the current match
|
* single literal. If there was a match but the current match
|
||||||
* is longer, truncate the previous match to a single literal.
|
* is longer, truncate the previous match to a single literal.
|
||||||
*/
|
*/
|
||||||
Tracevv((stderr,"%c", s->window[s->strstart-1]));
|
Tracevv((stderr,"%c", s->window[s->strstart - 1]));
|
||||||
_tr_tally_lit(s, s->window[s->strstart-1], bflush);
|
_tr_tally_lit(s, s->window[s->strstart - 1], bflush);
|
||||||
if (bflush) {
|
if (bflush) {
|
||||||
FLUSH_BLOCK_ONLY(s, 0);
|
FLUSH_BLOCK_ONLY(s, 0);
|
||||||
}
|
}
|
||||||
|
@ -2045,8 +2087,8 @@ local block_state deflate_slow(s, flush)
|
||||||
}
|
}
|
||||||
Assert (flush != Z_NO_FLUSH, "no flush?");
|
Assert (flush != Z_NO_FLUSH, "no flush?");
|
||||||
if (s->match_available) {
|
if (s->match_available) {
|
||||||
Tracevv((stderr,"%c", s->window[s->strstart-1]));
|
Tracevv((stderr,"%c", s->window[s->strstart - 1]));
|
||||||
_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;
|
||||||
}
|
}
|
||||||
s->insert = s->strstart < MIN_MATCH-1 ? s->strstart : MIN_MATCH-1;
|
s->insert = s->strstart < MIN_MATCH-1 ? s->strstart : MIN_MATCH-1;
|
||||||
|
@ -2054,7 +2096,7 @@ local block_state deflate_slow(s, flush)
|
||||||
FLUSH_BLOCK(s, 1);
|
FLUSH_BLOCK(s, 1);
|
||||||
return finish_done;
|
return finish_done;
|
||||||
}
|
}
|
||||||
if (s->last_lit)
|
if (s->sym_next)
|
||||||
FLUSH_BLOCK(s, 0);
|
FLUSH_BLOCK(s, 0);
|
||||||
return block_done;
|
return block_done;
|
||||||
}
|
}
|
||||||
|
@ -2103,7 +2145,8 @@ 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");
|
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 */
|
||||||
|
@ -2118,7 +2161,7 @@ local block_state deflate_rle(s, flush)
|
||||||
} else {
|
} else {
|
||||||
/* No match, output a literal byte */
|
/* No match, output a literal byte */
|
||||||
Tracevv((stderr,"%c", s->window[s->strstart]));
|
Tracevv((stderr,"%c", s->window[s->strstart]));
|
||||||
_tr_tally_lit (s, s->window[s->strstart], bflush);
|
_tr_tally_lit(s, s->window[s->strstart], bflush);
|
||||||
s->lookahead--;
|
s->lookahead--;
|
||||||
s->strstart++;
|
s->strstart++;
|
||||||
}
|
}
|
||||||
|
@ -2129,7 +2172,7 @@ local block_state deflate_rle(s, flush)
|
||||||
FLUSH_BLOCK(s, 1);
|
FLUSH_BLOCK(s, 1);
|
||||||
return finish_done;
|
return finish_done;
|
||||||
}
|
}
|
||||||
if (s->last_lit)
|
if (s->sym_next)
|
||||||
FLUSH_BLOCK(s, 0);
|
FLUSH_BLOCK(s, 0);
|
||||||
return block_done;
|
return block_done;
|
||||||
}
|
}
|
||||||
|
@ -2158,7 +2201,7 @@ local block_state deflate_huff(s, flush)
|
||||||
/* Output a literal byte */
|
/* Output a literal byte */
|
||||||
s->match_length = 0;
|
s->match_length = 0;
|
||||||
Tracevv((stderr,"%c", s->window[s->strstart]));
|
Tracevv((stderr,"%c", s->window[s->strstart]));
|
||||||
_tr_tally_lit (s, s->window[s->strstart], bflush);
|
_tr_tally_lit(s, s->window[s->strstart], bflush);
|
||||||
s->lookahead--;
|
s->lookahead--;
|
||||||
s->strstart++;
|
s->strstart++;
|
||||||
if (bflush) FLUSH_BLOCK(s, 0);
|
if (bflush) FLUSH_BLOCK(s, 0);
|
||||||
|
@ -2168,7 +2211,7 @@ local block_state deflate_huff(s, flush)
|
||||||
FLUSH_BLOCK(s, 1);
|
FLUSH_BLOCK(s, 1);
|
||||||
return finish_done;
|
return finish_done;
|
||||||
}
|
}
|
||||||
if (s->last_lit)
|
if (s->sym_next)
|
||||||
FLUSH_BLOCK(s, 0);
|
FLUSH_BLOCK(s, 0);
|
||||||
return block_done;
|
return block_done;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* deflate.h -- internal compression state
|
/* deflate.h -- internal compression state
|
||||||
* Copyright (C) 1995-2016 Jean-loup Gailly
|
* Copyright (C) 1995-2018 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
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -217,7 +217,7 @@ typedef struct internal_state {
|
||||||
/* Depth of each subtree used as tie breaker for trees of equal frequency
|
/* Depth of each subtree used as tie breaker for trees of equal frequency
|
||||||
*/
|
*/
|
||||||
|
|
||||||
uchf *l_buf; /* buffer for literals or lengths */
|
uchf *sym_buf; /* buffer for distances and literals/lengths */
|
||||||
|
|
||||||
uInt lit_bufsize;
|
uInt lit_bufsize;
|
||||||
/* Size of match buffer for literals/lengths. There are 4 reasons for
|
/* Size of match buffer for literals/lengths. There are 4 reasons for
|
||||||
|
@ -239,13 +239,8 @@ typedef struct internal_state {
|
||||||
* - I can't count above 4
|
* - I can't count above 4
|
||||||
*/
|
*/
|
||||||
|
|
||||||
uInt last_lit; /* running index in l_buf */
|
uInt sym_next; /* running index in sym_buf */
|
||||||
|
uInt sym_end; /* symbol table full when sym_next reaches this */
|
||||||
ushf *d_buf;
|
|
||||||
/* Buffer for distances. To simplify the code, d_buf and l_buf have
|
|
||||||
* the same number of elements. To use different lengths, an extra flag
|
|
||||||
* array would be necessary.
|
|
||||||
*/
|
|
||||||
|
|
||||||
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 */
|
||||||
|
@ -325,20 +320,22 @@ void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf,
|
||||||
|
|
||||||
# define _tr_tally_lit(s, c, flush) \
|
# define _tr_tally_lit(s, c, flush) \
|
||||||
{ uch cc = (c); \
|
{ uch cc = (c); \
|
||||||
s->d_buf[s->last_lit] = 0; \
|
s->sym_buf[s->sym_next++] = 0; \
|
||||||
s->l_buf[s->last_lit++] = cc; \
|
s->sym_buf[s->sym_next++] = 0; \
|
||||||
|
s->sym_buf[s->sym_next++] = cc; \
|
||||||
s->dyn_ltree[cc].Freq++; \
|
s->dyn_ltree[cc].Freq++; \
|
||||||
flush = (s->last_lit == s->lit_bufsize-1); \
|
flush = (s->sym_next == s->sym_end); \
|
||||||
}
|
}
|
||||||
# define _tr_tally_dist(s, distance, length, flush) \
|
# define _tr_tally_dist(s, distance, length, flush) \
|
||||||
{ uch len = (uch)(length); \
|
{ uch len = (uch)(length); \
|
||||||
ush dist = (ush)(distance); \
|
ush dist = (ush)(distance); \
|
||||||
s->d_buf[s->last_lit] = dist; \
|
s->sym_buf[s->sym_next++] = (uch)dist; \
|
||||||
s->l_buf[s->last_lit++] = len; \
|
s->sym_buf[s->sym_next++] = (uch)(dist >> 8); \
|
||||||
|
s->sym_buf[s->sym_next++] = len; \
|
||||||
dist--; \
|
dist--; \
|
||||||
s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \
|
s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \
|
||||||
s->dyn_dtree[d_code(dist)].Freq++; \
|
s->dyn_dtree[d_code(dist)].Freq++; \
|
||||||
flush = (s->last_lit == s->lit_bufsize-1); \
|
flush = (s->sym_next == s->sym_end); \
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
# define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c)
|
# define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* gzguts.h -- zlib internal header definitions for gz* operations
|
/* gzguts.h -- zlib internal header definitions for gz* operations
|
||||||
* Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013, 2016 Mark Adler
|
* Copyright (C) 2004-2019 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
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -190,6 +190,7 @@ typedef struct {
|
||||||
/* just for writing */
|
/* just for writing */
|
||||||
int level; /* compression level */
|
int level; /* compression level */
|
||||||
int strategy; /* compression strategy */
|
int strategy; /* compression strategy */
|
||||||
|
int reset; /* true if a reset is pending after a Z_FINISH */
|
||||||
/* seek request */
|
/* seek request */
|
||||||
z_off64_t skip; /* amount to skip (already rewound if backwards) */
|
z_off64_t skip; /* amount to skip (already rewound if backwards) */
|
||||||
int seek; /* true if seek request pending */
|
int seek; /* true if seek request pending */
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* gzlib.c -- zlib functions common to reading and writing gzip files
|
/* gzlib.c -- zlib functions common to reading and writing gzip files
|
||||||
* Copyright (C) 2004-2017 Mark Adler
|
* Copyright (C) 2004-2019 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
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ local gzFile gz_open OF((const void *, int, const char *));
|
||||||
|
|
||||||
The gz_strwinerror function does not change the current setting of
|
The gz_strwinerror function does not change the current setting of
|
||||||
GetLastError. */
|
GetLastError. */
|
||||||
char ZLIB_INTERNAL *gz_strwinerror (error)
|
char ZLIB_INTERNAL *gz_strwinerror(error)
|
||||||
DWORD error;
|
DWORD error;
|
||||||
{
|
{
|
||||||
static char buf[1024];
|
static char buf[1024];
|
||||||
|
@ -81,6 +81,8 @@ local void gz_reset(state)
|
||||||
state->past = 0; /* have not read past end yet */
|
state->past = 0; /* have not read past end yet */
|
||||||
state->how = LOOK; /* look for gzip header */
|
state->how = LOOK; /* look for gzip header */
|
||||||
}
|
}
|
||||||
|
else /* for writing ... */
|
||||||
|
state->reset = 0; /* no deflateReset pending */
|
||||||
state->seek = 0; /* no seek request pending */
|
state->seek = 0; /* no seek request pending */
|
||||||
gz_error(state, Z_OK, NULL); /* clear error */
|
gz_error(state, Z_OK, NULL); /* clear error */
|
||||||
state->x.pos = 0; /* no uncompressed data yet */
|
state->x.pos = 0; /* no uncompressed data yet */
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* gzread.c -- zlib functions for reading gzip files
|
/* gzread.c -- zlib functions for reading gzip files
|
||||||
* Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013, 2016 Mark Adler
|
* Copyright (C) 2004-2017 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
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -157,11 +157,9 @@ local int gz_look(state)
|
||||||
the output buffer is larger than the input buffer, which also assures
|
the output buffer is larger than the input buffer, which also assures
|
||||||
space for gzungetc() */
|
space for gzungetc() */
|
||||||
state->x.next = state->out;
|
state->x.next = state->out;
|
||||||
if (strm->avail_in) {
|
memcpy(state->x.next, strm->next_in, strm->avail_in);
|
||||||
memcpy(state->x.next, strm->next_in, strm->avail_in);
|
state->x.have = strm->avail_in;
|
||||||
state->x.have = strm->avail_in;
|
strm->avail_in = 0;
|
||||||
strm->avail_in = 0;
|
|
||||||
}
|
|
||||||
state->how = COPY;
|
state->how = COPY;
|
||||||
state->direct = 1;
|
state->direct = 1;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* gzwrite.c -- zlib functions for writing gzip files
|
/* gzwrite.c -- zlib functions for writing gzip files
|
||||||
* Copyright (C) 2004-2017 Mark Adler
|
* Copyright (C) 2004-2019 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
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -97,6 +97,15 @@ local int gz_comp(state, flush)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* check for a pending reset */
|
||||||
|
if (state->reset) {
|
||||||
|
/* don't start a new gzip member unless there is data to write */
|
||||||
|
if (strm->avail_in == 0)
|
||||||
|
return 0;
|
||||||
|
deflateReset(strm);
|
||||||
|
state->reset = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* run deflate() on provided input until it produces no more output */
|
/* run deflate() on provided input until it produces no more output */
|
||||||
ret = Z_OK;
|
ret = Z_OK;
|
||||||
do {
|
do {
|
||||||
|
@ -134,7 +143,7 @@ local int gz_comp(state, flush)
|
||||||
|
|
||||||
/* if that completed a deflate stream, allow another to start */
|
/* if that completed a deflate stream, allow another to start */
|
||||||
if (flush == Z_FINISH)
|
if (flush == Z_FINISH)
|
||||||
deflateReset(strm);
|
state->reset = 1;
|
||||||
|
|
||||||
/* all done, no errors */
|
/* all done, no errors */
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -349,9 +358,9 @@ int ZEXPORT gzputc(file, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -- see zlib.h -- */
|
/* -- see zlib.h -- */
|
||||||
int ZEXPORT gzputs(file, str)
|
int ZEXPORT gzputs(file, s)
|
||||||
gzFile file;
|
gzFile file;
|
||||||
const char *str;
|
const char *s;
|
||||||
{
|
{
|
||||||
z_size_t len, put;
|
z_size_t len, put;
|
||||||
gz_statep state;
|
gz_statep state;
|
||||||
|
@ -366,12 +375,12 @@ int ZEXPORT gzputs(file, str)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* write string */
|
/* write string */
|
||||||
len = strlen(str);
|
len = strlen(s);
|
||||||
if ((int)len < 0 || (unsigned)len != len) {
|
if ((int)len < 0 || (unsigned)len != len) {
|
||||||
gz_error(state, Z_STREAM_ERROR, "string length does not fit in int");
|
gz_error(state, Z_STREAM_ERROR, "string length does not fit in int");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
put = gz_write(state, str, len);
|
put = gz_write(state, s, len);
|
||||||
return put < len ? -1 : (int)len;
|
return put < len ? -1 : (int)len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -444,7 +453,7 @@ int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va)
|
||||||
strm->avail_in = state->size;
|
strm->avail_in = state->size;
|
||||||
if (gz_comp(state, Z_NO_FLUSH) == -1)
|
if (gz_comp(state, Z_NO_FLUSH) == -1)
|
||||||
return state->err;
|
return state->err;
|
||||||
memcpy(state->in, state->in + state->size, left);
|
memmove(state->in, state->in + state->size, left);
|
||||||
strm->next_in = state->in;
|
strm->next_in = state->in;
|
||||||
strm->avail_in = left;
|
strm->avail_in = left;
|
||||||
}
|
}
|
||||||
|
@ -465,7 +474,7 @@ int ZEXPORTVA gzprintf(gzFile file, const char *format, ...)
|
||||||
#else /* !STDC && !Z_HAVE_STDARG_H */
|
#else /* !STDC && !Z_HAVE_STDARG_H */
|
||||||
|
|
||||||
/* -- see zlib.h -- */
|
/* -- see zlib.h -- */
|
||||||
int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
|
int ZEXPORTVA gzprintf(file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
|
||||||
a11, a12, a13, a14, a15, a16, a17, a18, a19, a20)
|
a11, a12, a13, a14, a15, a16, a17, a18, a19, a20)
|
||||||
gzFile file;
|
gzFile file;
|
||||||
const char *format;
|
const char *format;
|
||||||
|
@ -543,7 +552,7 @@ int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
|
||||||
strm->avail_in = state->size;
|
strm->avail_in = state->size;
|
||||||
if (gz_comp(state, Z_NO_FLUSH) == -1)
|
if (gz_comp(state, Z_NO_FLUSH) == -1)
|
||||||
return state->err;
|
return state->err;
|
||||||
memcpy(state->in, state->in + state->size, left);
|
memmove(state->in, state->in + state->size, left);
|
||||||
strm->next_in = state->in;
|
strm->next_in = state->in;
|
||||||
strm->avail_in = left;
|
strm->avail_in = left;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* infback.c -- inflate using a call-back interface
|
/* infback.c -- inflate using a call-back interface
|
||||||
* Copyright (C) 1995-2016 Mark Adler
|
* Copyright (C) 1995-2022 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
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -66,6 +66,7 @@ int stream_size;
|
||||||
state->window = window;
|
state->window = window;
|
||||||
state->wnext = 0;
|
state->wnext = 0;
|
||||||
state->whave = 0;
|
state->whave = 0;
|
||||||
|
state->sane = 1;
|
||||||
return Z_OK;
|
return Z_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -477,6 +478,7 @@ void FAR *out_desc;
|
||||||
}
|
}
|
||||||
Tracev((stderr, "inflate: codes ok\n"));
|
Tracev((stderr, "inflate: codes ok\n"));
|
||||||
state->mode = LEN;
|
state->mode = LEN;
|
||||||
|
/* fallthrough */
|
||||||
|
|
||||||
case LEN:
|
case LEN:
|
||||||
/* use inflate_fast() if we have enough input and output */
|
/* use inflate_fast() if we have enough input and output */
|
||||||
|
@ -604,25 +606,27 @@ void FAR *out_desc;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DONE:
|
case DONE:
|
||||||
/* inflate stream terminated properly -- write leftover output */
|
/* inflate stream terminated properly */
|
||||||
ret = Z_STREAM_END;
|
ret = Z_STREAM_END;
|
||||||
if (left < state->wsize) {
|
|
||||||
if (out(out_desc, state->window, state->wsize - left))
|
|
||||||
ret = Z_BUF_ERROR;
|
|
||||||
}
|
|
||||||
goto inf_leave;
|
goto inf_leave;
|
||||||
|
|
||||||
case BAD:
|
case BAD:
|
||||||
ret = Z_DATA_ERROR;
|
ret = Z_DATA_ERROR;
|
||||||
goto inf_leave;
|
goto inf_leave;
|
||||||
|
|
||||||
default: /* can't happen, but makes compilers happy */
|
default:
|
||||||
|
/* can't happen, but makes compilers happy */
|
||||||
ret = Z_STREAM_ERROR;
|
ret = Z_STREAM_ERROR;
|
||||||
goto inf_leave;
|
goto inf_leave;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return unused input */
|
/* Write leftover output and return unused input */
|
||||||
inf_leave:
|
inf_leave:
|
||||||
|
if (left < state->wsize) {
|
||||||
|
if (out(out_desc, state->window, state->wsize - left) &&
|
||||||
|
ret == Z_STREAM_END)
|
||||||
|
ret = Z_BUF_ERROR;
|
||||||
|
}
|
||||||
strm->next_in = next;
|
strm->next_in = next;
|
||||||
strm->avail_in = have;
|
strm->avail_in = have;
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* inflate.c -- zlib decompression
|
/* inflate.c -- zlib decompression
|
||||||
* Copyright (C) 1995-2016 Mark Adler
|
* Copyright (C) 1995-2022 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
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -130,6 +130,7 @@ z_streamp strm;
|
||||||
state->mode = HEAD;
|
state->mode = HEAD;
|
||||||
state->last = 0;
|
state->last = 0;
|
||||||
state->havedict = 0;
|
state->havedict = 0;
|
||||||
|
state->flags = -1;
|
||||||
state->dmax = 32768U;
|
state->dmax = 32768U;
|
||||||
state->head = Z_NULL;
|
state->head = Z_NULL;
|
||||||
state->hold = 0;
|
state->hold = 0;
|
||||||
|
@ -167,6 +168,8 @@ int windowBits;
|
||||||
|
|
||||||
/* extract wrap request from windowBits parameter */
|
/* extract wrap request from windowBits parameter */
|
||||||
if (windowBits < 0) {
|
if (windowBits < 0) {
|
||||||
|
if (windowBits < -15)
|
||||||
|
return Z_STREAM_ERROR;
|
||||||
wrap = 0;
|
wrap = 0;
|
||||||
windowBits = -windowBits;
|
windowBits = -windowBits;
|
||||||
}
|
}
|
||||||
|
@ -447,10 +450,10 @@ unsigned copy;
|
||||||
|
|
||||||
/* check function to use adler32() for zlib or crc32() for gzip */
|
/* check function to use adler32() for zlib or crc32() for gzip */
|
||||||
#ifdef GUNZIP
|
#ifdef GUNZIP
|
||||||
# define UPDATE(check, buf, len) \
|
# define UPDATE_CHECK(check, buf, len) \
|
||||||
(state->flags ? crc32(check, buf, len) : adler32(check, buf, len))
|
(state->flags ? crc32(check, buf, len) : adler32(check, buf, len))
|
||||||
#else
|
#else
|
||||||
# define UPDATE(check, buf, len) adler32(check, buf, len)
|
# define UPDATE_CHECK(check, buf, len) adler32(check, buf, len)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* check macros for header crc */
|
/* check macros for header crc */
|
||||||
|
@ -670,7 +673,6 @@ int flush;
|
||||||
state->mode = FLAGS;
|
state->mode = FLAGS;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
state->flags = 0; /* expect zlib header */
|
|
||||||
if (state->head != Z_NULL)
|
if (state->head != Z_NULL)
|
||||||
state->head->done = -1;
|
state->head->done = -1;
|
||||||
if (!(state->wrap & 1) || /* check if zlib header allowed */
|
if (!(state->wrap & 1) || /* check if zlib header allowed */
|
||||||
|
@ -697,6 +699,7 @@ int flush;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
state->dmax = 1U << len;
|
state->dmax = 1U << len;
|
||||||
|
state->flags = 0; /* indicate zlib header */
|
||||||
Tracev((stderr, "inflate: zlib header ok\n"));
|
Tracev((stderr, "inflate: zlib header ok\n"));
|
||||||
strm->adler = state->check = adler32(0L, Z_NULL, 0);
|
strm->adler = state->check = adler32(0L, Z_NULL, 0);
|
||||||
state->mode = hold & 0x200 ? DICTID : TYPE;
|
state->mode = hold & 0x200 ? DICTID : TYPE;
|
||||||
|
@ -722,6 +725,7 @@ int flush;
|
||||||
CRC2(state->check, hold);
|
CRC2(state->check, hold);
|
||||||
INITBITS();
|
INITBITS();
|
||||||
state->mode = TIME;
|
state->mode = TIME;
|
||||||
|
/* fallthrough */
|
||||||
case TIME:
|
case TIME:
|
||||||
NEEDBITS(32);
|
NEEDBITS(32);
|
||||||
if (state->head != Z_NULL)
|
if (state->head != Z_NULL)
|
||||||
|
@ -730,6 +734,7 @@ int flush;
|
||||||
CRC4(state->check, hold);
|
CRC4(state->check, hold);
|
||||||
INITBITS();
|
INITBITS();
|
||||||
state->mode = OS;
|
state->mode = OS;
|
||||||
|
/* fallthrough */
|
||||||
case OS:
|
case OS:
|
||||||
NEEDBITS(16);
|
NEEDBITS(16);
|
||||||
if (state->head != Z_NULL) {
|
if (state->head != Z_NULL) {
|
||||||
|
@ -740,6 +745,7 @@ int flush;
|
||||||
CRC2(state->check, hold);
|
CRC2(state->check, hold);
|
||||||
INITBITS();
|
INITBITS();
|
||||||
state->mode = EXLEN;
|
state->mode = EXLEN;
|
||||||
|
/* fallthrough */
|
||||||
case EXLEN:
|
case EXLEN:
|
||||||
if (state->flags & 0x0400) {
|
if (state->flags & 0x0400) {
|
||||||
NEEDBITS(16);
|
NEEDBITS(16);
|
||||||
|
@ -753,14 +759,16 @@ int flush;
|
||||||
else if (state->head != Z_NULL)
|
else if (state->head != Z_NULL)
|
||||||
state->head->extra = Z_NULL;
|
state->head->extra = Z_NULL;
|
||||||
state->mode = EXTRA;
|
state->mode = EXTRA;
|
||||||
|
/* fallthrough */
|
||||||
case EXTRA:
|
case EXTRA:
|
||||||
if (state->flags & 0x0400) {
|
if (state->flags & 0x0400) {
|
||||||
copy = state->length;
|
copy = state->length;
|
||||||
if (copy > have) copy = have;
|
if (copy > have) copy = have;
|
||||||
if (copy) {
|
if (copy) {
|
||||||
if (state->head != Z_NULL &&
|
if (state->head != Z_NULL &&
|
||||||
state->head->extra != Z_NULL) {
|
state->head->extra != Z_NULL &&
|
||||||
len = state->head->extra_len - state->length;
|
(len = state->head->extra_len - state->length) <
|
||||||
|
state->head->extra_max) {
|
||||||
zmemcpy(state->head->extra + len, next,
|
zmemcpy(state->head->extra + len, next,
|
||||||
len + copy > state->head->extra_max ?
|
len + copy > state->head->extra_max ?
|
||||||
state->head->extra_max - len : copy);
|
state->head->extra_max - len : copy);
|
||||||
|
@ -775,6 +783,7 @@ int flush;
|
||||||
}
|
}
|
||||||
state->length = 0;
|
state->length = 0;
|
||||||
state->mode = NAME;
|
state->mode = NAME;
|
||||||
|
/* fallthrough */
|
||||||
case NAME:
|
case NAME:
|
||||||
if (state->flags & 0x0800) {
|
if (state->flags & 0x0800) {
|
||||||
if (have == 0) goto inf_leave;
|
if (have == 0) goto inf_leave;
|
||||||
|
@ -796,6 +805,7 @@ int flush;
|
||||||
state->head->name = Z_NULL;
|
state->head->name = Z_NULL;
|
||||||
state->length = 0;
|
state->length = 0;
|
||||||
state->mode = COMMENT;
|
state->mode = COMMENT;
|
||||||
|
/* fallthrough */
|
||||||
case COMMENT:
|
case COMMENT:
|
||||||
if (state->flags & 0x1000) {
|
if (state->flags & 0x1000) {
|
||||||
if (have == 0) goto inf_leave;
|
if (have == 0) goto inf_leave;
|
||||||
|
@ -816,6 +826,7 @@ int flush;
|
||||||
else if (state->head != Z_NULL)
|
else if (state->head != Z_NULL)
|
||||||
state->head->comment = Z_NULL;
|
state->head->comment = Z_NULL;
|
||||||
state->mode = HCRC;
|
state->mode = HCRC;
|
||||||
|
/* fallthrough */
|
||||||
case HCRC:
|
case HCRC:
|
||||||
if (state->flags & 0x0200) {
|
if (state->flags & 0x0200) {
|
||||||
NEEDBITS(16);
|
NEEDBITS(16);
|
||||||
|
@ -839,6 +850,7 @@ int flush;
|
||||||
strm->adler = state->check = ZSWAP32(hold);
|
strm->adler = state->check = ZSWAP32(hold);
|
||||||
INITBITS();
|
INITBITS();
|
||||||
state->mode = DICT;
|
state->mode = DICT;
|
||||||
|
/* fallthrough */
|
||||||
case DICT:
|
case DICT:
|
||||||
if (state->havedict == 0) {
|
if (state->havedict == 0) {
|
||||||
RESTORE();
|
RESTORE();
|
||||||
|
@ -846,8 +858,10 @@ int flush;
|
||||||
}
|
}
|
||||||
strm->adler = state->check = adler32(0L, Z_NULL, 0);
|
strm->adler = state->check = adler32(0L, Z_NULL, 0);
|
||||||
state->mode = TYPE;
|
state->mode = TYPE;
|
||||||
|
/* fallthrough */
|
||||||
case TYPE:
|
case TYPE:
|
||||||
if (flush == Z_BLOCK || flush == Z_TREES) goto inf_leave;
|
if (flush == Z_BLOCK || flush == Z_TREES) goto inf_leave;
|
||||||
|
/* fallthrough */
|
||||||
case TYPEDO:
|
case TYPEDO:
|
||||||
if (state->last) {
|
if (state->last) {
|
||||||
BYTEBITS();
|
BYTEBITS();
|
||||||
|
@ -898,8 +912,10 @@ int flush;
|
||||||
INITBITS();
|
INITBITS();
|
||||||
state->mode = COPY_;
|
state->mode = COPY_;
|
||||||
if (flush == Z_TREES) goto inf_leave;
|
if (flush == Z_TREES) goto inf_leave;
|
||||||
|
/* fallthrough */
|
||||||
case COPY_:
|
case COPY_:
|
||||||
state->mode = COPY;
|
state->mode = COPY;
|
||||||
|
/* fallthrough */
|
||||||
case COPY:
|
case COPY:
|
||||||
copy = state->length;
|
copy = state->length;
|
||||||
if (copy) {
|
if (copy) {
|
||||||
|
@ -935,6 +951,7 @@ int flush;
|
||||||
Tracev((stderr, "inflate: table sizes ok\n"));
|
Tracev((stderr, "inflate: table sizes ok\n"));
|
||||||
state->have = 0;
|
state->have = 0;
|
||||||
state->mode = LENLENS;
|
state->mode = LENLENS;
|
||||||
|
/* fallthrough */
|
||||||
case LENLENS:
|
case LENLENS:
|
||||||
while (state->have < state->ncode) {
|
while (state->have < state->ncode) {
|
||||||
NEEDBITS(3);
|
NEEDBITS(3);
|
||||||
|
@ -956,6 +973,7 @@ int flush;
|
||||||
Tracev((stderr, "inflate: code lengths ok\n"));
|
Tracev((stderr, "inflate: code lengths ok\n"));
|
||||||
state->have = 0;
|
state->have = 0;
|
||||||
state->mode = CODELENS;
|
state->mode = CODELENS;
|
||||||
|
/* fallthrough */
|
||||||
case CODELENS:
|
case CODELENS:
|
||||||
while (state->have < state->nlen + state->ndist) {
|
while (state->have < state->nlen + state->ndist) {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
@ -1039,8 +1057,10 @@ int flush;
|
||||||
Tracev((stderr, "inflate: codes ok\n"));
|
Tracev((stderr, "inflate: codes ok\n"));
|
||||||
state->mode = LEN_;
|
state->mode = LEN_;
|
||||||
if (flush == Z_TREES) goto inf_leave;
|
if (flush == Z_TREES) goto inf_leave;
|
||||||
|
/* fallthrough */
|
||||||
case LEN_:
|
case LEN_:
|
||||||
state->mode = LEN;
|
state->mode = LEN;
|
||||||
|
/* fallthrough */
|
||||||
case LEN:
|
case LEN:
|
||||||
if (have >= 6 && left >= 258) {
|
if (have >= 6 && left >= 258) {
|
||||||
RESTORE();
|
RESTORE();
|
||||||
|
@ -1090,6 +1110,7 @@ int flush;
|
||||||
}
|
}
|
||||||
state->extra = (unsigned)(here.op) & 15;
|
state->extra = (unsigned)(here.op) & 15;
|
||||||
state->mode = LENEXT;
|
state->mode = LENEXT;
|
||||||
|
/* fallthrough */
|
||||||
case LENEXT:
|
case LENEXT:
|
||||||
if (state->extra) {
|
if (state->extra) {
|
||||||
NEEDBITS(state->extra);
|
NEEDBITS(state->extra);
|
||||||
|
@ -1100,6 +1121,7 @@ int flush;
|
||||||
Tracevv((stderr, "inflate: length %u\n", state->length));
|
Tracevv((stderr, "inflate: length %u\n", state->length));
|
||||||
state->was = state->length;
|
state->was = state->length;
|
||||||
state->mode = DIST;
|
state->mode = DIST;
|
||||||
|
/* fallthrough */
|
||||||
case DIST:
|
case DIST:
|
||||||
for (;;) {
|
for (;;) {
|
||||||
here = state->distcode[BITS(state->distbits)];
|
here = state->distcode[BITS(state->distbits)];
|
||||||
|
@ -1127,6 +1149,7 @@ int flush;
|
||||||
state->offset = (unsigned)here.val;
|
state->offset = (unsigned)here.val;
|
||||||
state->extra = (unsigned)(here.op) & 15;
|
state->extra = (unsigned)(here.op) & 15;
|
||||||
state->mode = DISTEXT;
|
state->mode = DISTEXT;
|
||||||
|
/* fallthrough */
|
||||||
case DISTEXT:
|
case DISTEXT:
|
||||||
if (state->extra) {
|
if (state->extra) {
|
||||||
NEEDBITS(state->extra);
|
NEEDBITS(state->extra);
|
||||||
|
@ -1143,6 +1166,7 @@ int flush;
|
||||||
#endif
|
#endif
|
||||||
Tracevv((stderr, "inflate: distance %u\n", state->offset));
|
Tracevv((stderr, "inflate: distance %u\n", state->offset));
|
||||||
state->mode = MATCH;
|
state->mode = MATCH;
|
||||||
|
/* fallthrough */
|
||||||
case MATCH:
|
case MATCH:
|
||||||
if (left == 0) goto inf_leave;
|
if (left == 0) goto inf_leave;
|
||||||
copy = out - left;
|
copy = out - left;
|
||||||
|
@ -1202,7 +1226,7 @@ int flush;
|
||||||
state->total += out;
|
state->total += out;
|
||||||
if ((state->wrap & 4) && out)
|
if ((state->wrap & 4) && out)
|
||||||
strm->adler = state->check =
|
strm->adler = state->check =
|
||||||
UPDATE(state->check, put - out, out);
|
UPDATE_CHECK(state->check, put - out, out);
|
||||||
out = left;
|
out = left;
|
||||||
if ((state->wrap & 4) && (
|
if ((state->wrap & 4) && (
|
||||||
#ifdef GUNZIP
|
#ifdef GUNZIP
|
||||||
|
@ -1218,10 +1242,11 @@ int flush;
|
||||||
}
|
}
|
||||||
#ifdef GUNZIP
|
#ifdef GUNZIP
|
||||||
state->mode = LENGTH;
|
state->mode = LENGTH;
|
||||||
|
/* fallthrough */
|
||||||
case LENGTH:
|
case LENGTH:
|
||||||
if (state->wrap && state->flags) {
|
if (state->wrap && state->flags) {
|
||||||
NEEDBITS(32);
|
NEEDBITS(32);
|
||||||
if (hold != (state->total & 0xffffffffUL)) {
|
if ((state->wrap & 4) && hold != (state->total & 0xffffffff)) {
|
||||||
strm->msg = (char *)"incorrect length check";
|
strm->msg = (char *)"incorrect length check";
|
||||||
state->mode = BAD;
|
state->mode = BAD;
|
||||||
break;
|
break;
|
||||||
|
@ -1231,6 +1256,7 @@ int flush;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
state->mode = DONE;
|
state->mode = DONE;
|
||||||
|
/* fallthrough */
|
||||||
case DONE:
|
case DONE:
|
||||||
ret = Z_STREAM_END;
|
ret = Z_STREAM_END;
|
||||||
goto inf_leave;
|
goto inf_leave;
|
||||||
|
@ -1240,6 +1266,7 @@ int flush;
|
||||||
case MEM:
|
case MEM:
|
||||||
return Z_MEM_ERROR;
|
return Z_MEM_ERROR;
|
||||||
case SYNC:
|
case SYNC:
|
||||||
|
/* fallthrough */
|
||||||
default:
|
default:
|
||||||
return Z_STREAM_ERROR;
|
return Z_STREAM_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -1265,7 +1292,7 @@ int flush;
|
||||||
state->total += out;
|
state->total += out;
|
||||||
if ((state->wrap & 4) && out)
|
if ((state->wrap & 4) && out)
|
||||||
strm->adler = state->check =
|
strm->adler = state->check =
|
||||||
UPDATE(state->check, strm->next_out - out, out);
|
UPDATE_CHECK(state->check, strm->next_out - out, out);
|
||||||
strm->data_type = (int)state->bits + (state->last ? 64 : 0) +
|
strm->data_type = (int)state->bits + (state->last ? 64 : 0) +
|
||||||
(state->mode == TYPE ? 128 : 0) +
|
(state->mode == TYPE ? 128 : 0) +
|
||||||
(state->mode == LEN_ || state->mode == COPY_ ? 256 : 0);
|
(state->mode == LEN_ || state->mode == COPY_ ? 256 : 0);
|
||||||
|
@ -1401,6 +1428,7 @@ int ZEXPORT inflateSync(strm)
|
||||||
z_streamp strm;
|
z_streamp strm;
|
||||||
{
|
{
|
||||||
unsigned len; /* number of bytes to look at or looked at */
|
unsigned len; /* number of bytes to look at or looked at */
|
||||||
|
int flags; /* temporary to save header status */
|
||||||
unsigned long in, out; /* temporary to save total_in and total_out */
|
unsigned long in, out; /* temporary to save total_in and total_out */
|
||||||
unsigned char buf[4]; /* to restore bit buffer to byte string */
|
unsigned char buf[4]; /* to restore bit buffer to byte string */
|
||||||
struct inflate_state FAR *state;
|
struct inflate_state FAR *state;
|
||||||
|
@ -1433,11 +1461,15 @@ z_streamp strm;
|
||||||
|
|
||||||
/* return no joy or set up to restart inflate() on a new block */
|
/* return no joy or set up to restart inflate() on a new block */
|
||||||
if (state->have != 4) return Z_DATA_ERROR;
|
if (state->have != 4) return Z_DATA_ERROR;
|
||||||
if (state->mode == HEAD)
|
if (state->flags == -1)
|
||||||
state->wrap = 0; /* never processed header, so assume raw */
|
state->wrap = 0; /* if no header yet, treat as raw */
|
||||||
|
else
|
||||||
|
state->wrap &= ~4; /* no point in computing a check value now */
|
||||||
|
flags = state->flags;
|
||||||
in = strm->total_in; out = strm->total_out;
|
in = strm->total_in; out = strm->total_out;
|
||||||
inflateReset(strm);
|
inflateReset(strm);
|
||||||
strm->total_in = in; strm->total_out = out;
|
strm->total_in = in; strm->total_out = out;
|
||||||
|
state->flags = flags;
|
||||||
state->mode = TYPE;
|
state->mode = TYPE;
|
||||||
return Z_OK;
|
return Z_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* inflate.h -- internal inflate state definition
|
/* inflate.h -- internal inflate state definition
|
||||||
* Copyright (C) 1995-2016 Mark Adler
|
* Copyright (C) 1995-2019 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
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -86,7 +86,8 @@ struct inflate_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,
|
||||||
bit 2 true to validate check value */
|
bit 2 true to validate check value */
|
||||||
int havedict; /* true if dictionary provided */
|
int havedict; /* true if dictionary provided */
|
||||||
int flags; /* gzip header method and flags (0 if zlib) */
|
int flags; /* gzip header method and flags, 0 if zlib, or
|
||||||
|
-1 if raw or no header yet */
|
||||||
unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */
|
unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */
|
||||||
unsigned long check; /* protected copy of check value */
|
unsigned long check; /* protected copy of check value */
|
||||||
unsigned long total; /* protected copy of output count */
|
unsigned long total; /* protected copy of output count */
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* inftrees.c -- generate Huffman trees for efficient decoding
|
/* inftrees.c -- generate Huffman trees for efficient decoding
|
||||||
* Copyright (C) 1995-2017 Mark Adler
|
* Copyright (C) 1995-2022 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.11.1 Copyright 1995-2017 Mark Adler ";
|
" inflate 1.2.13 Copyright 1995-2022 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, 198, 196};
|
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 194, 65};
|
||||||
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,
|
||||||
|
|
|
@ -38,7 +38,7 @@ typedef struct {
|
||||||
/* Maximum size of the dynamic table. The maximum number of code structures is
|
/* Maximum size of the dynamic table. The maximum number of code structures is
|
||||||
1444, which is the sum of 852 for literal/length codes and 592 for distance
|
1444, which is the sum of 852 for literal/length codes and 592 for distance
|
||||||
codes. These values were found by exhaustive searches using the program
|
codes. These values were found by exhaustive searches using the program
|
||||||
examples/enough.c found in the zlib distribtution. The arguments to that
|
examples/enough.c found in the zlib distribution. The arguments to that
|
||||||
program are the number of symbols, the initial root table size, and the
|
program are the number of symbols, the initial root table size, and the
|
||||||
maximum bit length of a code. "enough 286 9 15" for literal/length codes
|
maximum bit length of a code. "enough 286 9 15" for literal/length codes
|
||||||
returns returns 852, and "enough 30 6 15" for distance codes returns 592.
|
returns returns 852, and "enough 30 6 15" for distance codes returns 592.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* trees.c -- output deflated data using Huffman coding
|
/* trees.c -- output deflated data using Huffman coding
|
||||||
* Copyright (C) 1995-2017 Jean-loup Gailly
|
* Copyright (C) 1995-2021 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
|
||||||
*/
|
*/
|
||||||
|
@ -149,7 +149,7 @@ local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes,
|
||||||
local void compress_block OF((deflate_state *s, const ct_data *ltree,
|
local void compress_block OF((deflate_state *s, const ct_data *ltree,
|
||||||
const 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 code, int len));
|
||||||
local void bi_windup OF((deflate_state *s));
|
local void bi_windup OF((deflate_state *s));
|
||||||
local void bi_flush OF((deflate_state *s));
|
local void bi_flush OF((deflate_state *s));
|
||||||
|
|
||||||
|
@ -193,7 +193,7 @@ local void send_bits(s, value, length)
|
||||||
s->bits_sent += (ulg)length;
|
s->bits_sent += (ulg)length;
|
||||||
|
|
||||||
/* If not enough room in bi_buf, use (valid) bits from bi_buf and
|
/* If not enough room in bi_buf, use (valid) bits from bi_buf and
|
||||||
* (16 - bi_valid) bits from value, leaving (width - (16-bi_valid))
|
* (16 - bi_valid) bits from value, leaving (width - (16 - bi_valid))
|
||||||
* unused bits in value.
|
* unused bits in value.
|
||||||
*/
|
*/
|
||||||
if (s->bi_valid > (int)Buf_size - length) {
|
if (s->bi_valid > (int)Buf_size - length) {
|
||||||
|
@ -256,7 +256,7 @@ local void tr_static_init()
|
||||||
length = 0;
|
length = 0;
|
||||||
for (code = 0; code < LENGTH_CODES-1; code++) {
|
for (code = 0; code < LENGTH_CODES-1; code++) {
|
||||||
base_length[code] = length;
|
base_length[code] = length;
|
||||||
for (n = 0; n < (1<<extra_lbits[code]); n++) {
|
for (n = 0; n < (1 << extra_lbits[code]); n++) {
|
||||||
_length_code[length++] = (uch)code;
|
_length_code[length++] = (uch)code;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -265,13 +265,13 @@ local void tr_static_init()
|
||||||
* in two different ways: code 284 + 5 bits or code 285, so we
|
* in two different ways: code 284 + 5 bits or code 285, so we
|
||||||
* overwrite length_code[255] to use the best encoding:
|
* overwrite length_code[255] to use the best encoding:
|
||||||
*/
|
*/
|
||||||
_length_code[length-1] = (uch)code;
|
_length_code[length - 1] = (uch)code;
|
||||||
|
|
||||||
/* Initialize the mapping dist (0..32K) -> dist code (0..29) */
|
/* Initialize the mapping dist (0..32K) -> dist code (0..29) */
|
||||||
dist = 0;
|
dist = 0;
|
||||||
for (code = 0 ; code < 16; code++) {
|
for (code = 0 ; code < 16; code++) {
|
||||||
base_dist[code] = dist;
|
base_dist[code] = dist;
|
||||||
for (n = 0; n < (1<<extra_dbits[code]); n++) {
|
for (n = 0; n < (1 << extra_dbits[code]); n++) {
|
||||||
_dist_code[dist++] = (uch)code;
|
_dist_code[dist++] = (uch)code;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -279,11 +279,11 @@ local void tr_static_init()
|
||||||
dist >>= 7; /* from now on, all distances are divided by 128 */
|
dist >>= 7; /* from now on, all distances are divided by 128 */
|
||||||
for ( ; code < D_CODES; code++) {
|
for ( ; code < D_CODES; code++) {
|
||||||
base_dist[code] = dist << 7;
|
base_dist[code] = dist << 7;
|
||||||
for (n = 0; n < (1<<(extra_dbits[code]-7)); n++) {
|
for (n = 0; n < (1 << (extra_dbits[code] - 7)); n++) {
|
||||||
_dist_code[256 + dist++] = (uch)code;
|
_dist_code[256 + dist++] = (uch)code;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Assert (dist == 256, "tr_static_init: 256+dist != 512");
|
Assert (dist == 256, "tr_static_init: 256 + dist != 512");
|
||||||
|
|
||||||
/* Construct the codes of the static literal tree */
|
/* Construct the codes of the static literal tree */
|
||||||
for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0;
|
for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0;
|
||||||
|
@ -312,7 +312,7 @@ local void tr_static_init()
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===========================================================================
|
/* ===========================================================================
|
||||||
* Genererate the file trees.h describing the static trees.
|
* Generate the file trees.h describing the static trees.
|
||||||
*/
|
*/
|
||||||
#ifdef GEN_TREES_H
|
#ifdef GEN_TREES_H
|
||||||
# ifndef ZLIB_DEBUG
|
# ifndef ZLIB_DEBUG
|
||||||
|
@ -321,7 +321,7 @@ local void tr_static_init()
|
||||||
|
|
||||||
# define SEPARATOR(i, last, width) \
|
# define SEPARATOR(i, last, width) \
|
||||||
((i) == (last)? "\n};\n\n" : \
|
((i) == (last)? "\n};\n\n" : \
|
||||||
((i) % (width) == (width)-1 ? ",\n" : ", "))
|
((i) % (width) == (width) - 1 ? ",\n" : ", "))
|
||||||
|
|
||||||
void gen_trees_header()
|
void gen_trees_header()
|
||||||
{
|
{
|
||||||
|
@ -416,7 +416,7 @@ local void init_block(s)
|
||||||
|
|
||||||
s->dyn_ltree[END_BLOCK].Freq = 1;
|
s->dyn_ltree[END_BLOCK].Freq = 1;
|
||||||
s->opt_len = s->static_len = 0L;
|
s->opt_len = s->static_len = 0L;
|
||||||
s->last_lit = s->matches = 0;
|
s->sym_next = s->matches = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SMALLEST 1
|
#define SMALLEST 1
|
||||||
|
@ -458,7 +458,7 @@ local void pqdownheap(s, tree, k)
|
||||||
while (j <= s->heap_len) {
|
while (j <= s->heap_len) {
|
||||||
/* Set j to the smallest of the two sons: */
|
/* Set j to the smallest of the two sons: */
|
||||||
if (j < s->heap_len &&
|
if (j < s->heap_len &&
|
||||||
smaller(tree, s->heap[j+1], s->heap[j], s->depth)) {
|
smaller(tree, s->heap[j + 1], s->heap[j], s->depth)) {
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
/* Exit if v is smaller than both sons */
|
/* Exit if v is smaller than both sons */
|
||||||
|
@ -507,7 +507,7 @@ local void gen_bitlen(s, desc)
|
||||||
*/
|
*/
|
||||||
tree[s->heap[s->heap_max]].Len = 0; /* root of the heap */
|
tree[s->heap[s->heap_max]].Len = 0; /* root of the heap */
|
||||||
|
|
||||||
for (h = s->heap_max+1; h < HEAP_SIZE; h++) {
|
for (h = s->heap_max + 1; h < HEAP_SIZE; h++) {
|
||||||
n = s->heap[h];
|
n = s->heap[h];
|
||||||
bits = tree[tree[n].Dad].Len + 1;
|
bits = tree[tree[n].Dad].Len + 1;
|
||||||
if (bits > max_length) bits = max_length, overflow++;
|
if (bits > max_length) bits = max_length, overflow++;
|
||||||
|
@ -518,7 +518,7 @@ local void gen_bitlen(s, desc)
|
||||||
|
|
||||||
s->bl_count[bits]++;
|
s->bl_count[bits]++;
|
||||||
xbits = 0;
|
xbits = 0;
|
||||||
if (n >= base) xbits = extra[n-base];
|
if (n >= base) xbits = extra[n - base];
|
||||||
f = tree[n].Freq;
|
f = tree[n].Freq;
|
||||||
s->opt_len += (ulg)f * (unsigned)(bits + xbits);
|
s->opt_len += (ulg)f * (unsigned)(bits + xbits);
|
||||||
if (stree) s->static_len += (ulg)f * (unsigned)(stree[n].Len + xbits);
|
if (stree) s->static_len += (ulg)f * (unsigned)(stree[n].Len + xbits);
|
||||||
|
@ -530,10 +530,10 @@ local void gen_bitlen(s, desc)
|
||||||
|
|
||||||
/* Find the first bit length which could increase: */
|
/* Find the first bit length which could increase: */
|
||||||
do {
|
do {
|
||||||
bits = max_length-1;
|
bits = max_length - 1;
|
||||||
while (s->bl_count[bits] == 0) bits--;
|
while (s->bl_count[bits] == 0) bits--;
|
||||||
s->bl_count[bits]--; /* move one leaf down the tree */
|
s->bl_count[bits]--; /* move one leaf down the tree */
|
||||||
s->bl_count[bits+1] += 2; /* move one overflow item as its brother */
|
s->bl_count[bits + 1] += 2; /* move one overflow item as its brother */
|
||||||
s->bl_count[max_length]--;
|
s->bl_count[max_length]--;
|
||||||
/* The brother of the overflow item also moves one step up,
|
/* The brother of the overflow item also moves one step up,
|
||||||
* but this does not affect bl_count[max_length]
|
* but this does not affect bl_count[max_length]
|
||||||
|
@ -569,7 +569,7 @@ local void gen_bitlen(s, desc)
|
||||||
* OUT assertion: the field code is set for all tree elements of non
|
* OUT assertion: the field code is set for all tree elements of non
|
||||||
* zero code length.
|
* zero code length.
|
||||||
*/
|
*/
|
||||||
local void gen_codes (tree, max_code, bl_count)
|
local void gen_codes(tree, max_code, bl_count)
|
||||||
ct_data *tree; /* the tree to decorate */
|
ct_data *tree; /* the tree to decorate */
|
||||||
int max_code; /* largest code with non zero frequency */
|
int max_code; /* largest code with non zero frequency */
|
||||||
ushf *bl_count; /* number of codes at each bit length */
|
ushf *bl_count; /* number of codes at each bit length */
|
||||||
|
@ -583,13 +583,13 @@ local void gen_codes (tree, max_code, bl_count)
|
||||||
* without bit reversal.
|
* without bit reversal.
|
||||||
*/
|
*/
|
||||||
for (bits = 1; bits <= MAX_BITS; bits++) {
|
for (bits = 1; bits <= MAX_BITS; bits++) {
|
||||||
code = (code + bl_count[bits-1]) << 1;
|
code = (code + bl_count[bits - 1]) << 1;
|
||||||
next_code[bits] = (ush)code;
|
next_code[bits] = (ush)code;
|
||||||
}
|
}
|
||||||
/* Check that the bit counts in bl_count are consistent. The last code
|
/* Check that the bit counts in bl_count are consistent. The last code
|
||||||
* must be all ones.
|
* must be all ones.
|
||||||
*/
|
*/
|
||||||
Assert (code + bl_count[MAX_BITS]-1 == (1<<MAX_BITS)-1,
|
Assert (code + bl_count[MAX_BITS] - 1 == (1 << MAX_BITS) - 1,
|
||||||
"inconsistent bit counts");
|
"inconsistent bit counts");
|
||||||
Tracev((stderr,"\ngen_codes: max_code %d ", max_code));
|
Tracev((stderr,"\ngen_codes: max_code %d ", max_code));
|
||||||
|
|
||||||
|
@ -600,7 +600,7 @@ local void gen_codes (tree, max_code, bl_count)
|
||||||
tree[n].Code = (ush)bi_reverse(next_code[len]++, len);
|
tree[n].Code = (ush)bi_reverse(next_code[len]++, len);
|
||||||
|
|
||||||
Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ",
|
Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ",
|
||||||
n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len]-1));
|
n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len] - 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -624,7 +624,7 @@ local void build_tree(s, desc)
|
||||||
int node; /* new node being created */
|
int node; /* new node being created */
|
||||||
|
|
||||||
/* Construct the initial heap, with least frequent element in
|
/* Construct the initial heap, with least frequent element in
|
||||||
* heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1].
|
* heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n + 1].
|
||||||
* heap[0] is not used.
|
* heap[0] is not used.
|
||||||
*/
|
*/
|
||||||
s->heap_len = 0, s->heap_max = HEAP_SIZE;
|
s->heap_len = 0, s->heap_max = HEAP_SIZE;
|
||||||
|
@ -652,7 +652,7 @@ local void build_tree(s, desc)
|
||||||
}
|
}
|
||||||
desc->max_code = max_code;
|
desc->max_code = max_code;
|
||||||
|
|
||||||
/* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree,
|
/* The elements heap[heap_len/2 + 1 .. heap_len] are leaves of the tree,
|
||||||
* establish sub-heaps of increasing lengths:
|
* establish sub-heaps of increasing lengths:
|
||||||
*/
|
*/
|
||||||
for (n = s->heap_len/2; n >= 1; n--) pqdownheap(s, tree, n);
|
for (n = s->heap_len/2; n >= 1; n--) pqdownheap(s, tree, n);
|
||||||
|
@ -700,7 +700,7 @@ local void build_tree(s, desc)
|
||||||
* Scan a literal or distance tree to determine the frequencies of the codes
|
* Scan a literal or distance tree to determine the frequencies of the codes
|
||||||
* in the bit length tree.
|
* in the bit length tree.
|
||||||
*/
|
*/
|
||||||
local void scan_tree (s, tree, max_code)
|
local void scan_tree(s, tree, max_code)
|
||||||
deflate_state *s;
|
deflate_state *s;
|
||||||
ct_data *tree; /* the tree to be scanned */
|
ct_data *tree; /* the tree to be scanned */
|
||||||
int max_code; /* and its largest code of non zero frequency */
|
int max_code; /* and its largest code of non zero frequency */
|
||||||
|
@ -714,10 +714,10 @@ local void scan_tree (s, tree, max_code)
|
||||||
int min_count = 4; /* min repeat count */
|
int min_count = 4; /* min repeat count */
|
||||||
|
|
||||||
if (nextlen == 0) max_count = 138, min_count = 3;
|
if (nextlen == 0) max_count = 138, min_count = 3;
|
||||||
tree[max_code+1].Len = (ush)0xffff; /* guard */
|
tree[max_code + 1].Len = (ush)0xffff; /* guard */
|
||||||
|
|
||||||
for (n = 0; n <= max_code; n++) {
|
for (n = 0; n <= max_code; n++) {
|
||||||
curlen = nextlen; nextlen = tree[n+1].Len;
|
curlen = nextlen; nextlen = tree[n + 1].Len;
|
||||||
if (++count < max_count && curlen == nextlen) {
|
if (++count < max_count && curlen == nextlen) {
|
||||||
continue;
|
continue;
|
||||||
} else if (count < min_count) {
|
} else if (count < min_count) {
|
||||||
|
@ -745,7 +745,7 @@ local void scan_tree (s, tree, max_code)
|
||||||
* Send a literal or distance tree in compressed form, using the codes in
|
* Send a literal or distance tree in compressed form, using the codes in
|
||||||
* bl_tree.
|
* bl_tree.
|
||||||
*/
|
*/
|
||||||
local void send_tree (s, tree, max_code)
|
local void send_tree(s, tree, max_code)
|
||||||
deflate_state *s;
|
deflate_state *s;
|
||||||
ct_data *tree; /* the tree to be scanned */
|
ct_data *tree; /* the tree to be scanned */
|
||||||
int max_code; /* and its largest code of non zero frequency */
|
int max_code; /* and its largest code of non zero frequency */
|
||||||
|
@ -758,11 +758,11 @@ local void send_tree (s, tree, max_code)
|
||||||
int max_count = 7; /* max repeat count */
|
int max_count = 7; /* max repeat count */
|
||||||
int min_count = 4; /* min repeat count */
|
int min_count = 4; /* min repeat count */
|
||||||
|
|
||||||
/* tree[max_code+1].Len = -1; */ /* guard already set */
|
/* tree[max_code + 1].Len = -1; */ /* guard already set */
|
||||||
if (nextlen == 0) max_count = 138, min_count = 3;
|
if (nextlen == 0) max_count = 138, min_count = 3;
|
||||||
|
|
||||||
for (n = 0; n <= max_code; n++) {
|
for (n = 0; n <= max_code; n++) {
|
||||||
curlen = nextlen; nextlen = tree[n+1].Len;
|
curlen = nextlen; nextlen = tree[n + 1].Len;
|
||||||
if (++count < max_count && curlen == nextlen) {
|
if (++count < max_count && curlen == nextlen) {
|
||||||
continue;
|
continue;
|
||||||
} else if (count < min_count) {
|
} else if (count < min_count) {
|
||||||
|
@ -773,13 +773,13 @@ local void send_tree (s, tree, max_code)
|
||||||
send_code(s, curlen, s->bl_tree); count--;
|
send_code(s, curlen, s->bl_tree); count--;
|
||||||
}
|
}
|
||||||
Assert(count >= 3 && count <= 6, " 3_6?");
|
Assert(count >= 3 && count <= 6, " 3_6?");
|
||||||
send_code(s, REP_3_6, s->bl_tree); send_bits(s, count-3, 2);
|
send_code(s, REP_3_6, s->bl_tree); send_bits(s, count - 3, 2);
|
||||||
|
|
||||||
} else if (count <= 10) {
|
} else if (count <= 10) {
|
||||||
send_code(s, REPZ_3_10, s->bl_tree); send_bits(s, count-3, 3);
|
send_code(s, REPZ_3_10, s->bl_tree); send_bits(s, count - 3, 3);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
send_code(s, REPZ_11_138, s->bl_tree); send_bits(s, count-11, 7);
|
send_code(s, REPZ_11_138, s->bl_tree); send_bits(s, count - 11, 7);
|
||||||
}
|
}
|
||||||
count = 0; prevlen = curlen;
|
count = 0; prevlen = curlen;
|
||||||
if (nextlen == 0) {
|
if (nextlen == 0) {
|
||||||
|
@ -807,8 +807,8 @@ local int build_bl_tree(s)
|
||||||
|
|
||||||
/* Build the bit length tree: */
|
/* Build the bit length tree: */
|
||||||
build_tree(s, (tree_desc *)(&(s->bl_desc)));
|
build_tree(s, (tree_desc *)(&(s->bl_desc)));
|
||||||
/* opt_len now includes the length of the tree representations, except
|
/* opt_len now includes the length of the tree representations, except the
|
||||||
* the lengths of the bit lengths codes and the 5+5+4 bits for the counts.
|
* lengths of the bit lengths codes and the 5 + 5 + 4 bits for the counts.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Determine the number of bit length codes to send. The pkzip format
|
/* Determine the number of bit length codes to send. The pkzip format
|
||||||
|
@ -819,7 +819,7 @@ local int build_bl_tree(s)
|
||||||
if (s->bl_tree[bl_order[max_blindex]].Len != 0) break;
|
if (s->bl_tree[bl_order[max_blindex]].Len != 0) break;
|
||||||
}
|
}
|
||||||
/* Update opt_len to include the bit length tree and counts */
|
/* Update opt_len to include the bit length tree and counts */
|
||||||
s->opt_len += 3*((ulg)max_blindex+1) + 5+5+4;
|
s->opt_len += 3*((ulg)max_blindex + 1) + 5 + 5 + 4;
|
||||||
Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld",
|
Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld",
|
||||||
s->opt_len, s->static_len));
|
s->opt_len, s->static_len));
|
||||||
|
|
||||||
|
@ -841,19 +841,19 @@ local void send_all_trees(s, lcodes, dcodes, blcodes)
|
||||||
Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES,
|
Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES,
|
||||||
"too many codes");
|
"too many codes");
|
||||||
Tracev((stderr, "\nbl counts: "));
|
Tracev((stderr, "\nbl counts: "));
|
||||||
send_bits(s, lcodes-257, 5); /* not +255 as stated in appnote.txt */
|
send_bits(s, lcodes - 257, 5); /* not +255 as stated in appnote.txt */
|
||||||
send_bits(s, dcodes-1, 5);
|
send_bits(s, dcodes - 1, 5);
|
||||||
send_bits(s, blcodes-4, 4); /* not -3 as stated in appnote.txt */
|
send_bits(s, blcodes - 4, 4); /* not -3 as stated in appnote.txt */
|
||||||
for (rank = 0; rank < blcodes; rank++) {
|
for (rank = 0; rank < blcodes; rank++) {
|
||||||
Tracev((stderr, "\nbl code %2d ", bl_order[rank]));
|
Tracev((stderr, "\nbl code %2d ", bl_order[rank]));
|
||||||
send_bits(s, s->bl_tree[bl_order[rank]].Len, 3);
|
send_bits(s, s->bl_tree[bl_order[rank]].Len, 3);
|
||||||
}
|
}
|
||||||
Tracev((stderr, "\nbl tree: sent %ld", s->bits_sent));
|
Tracev((stderr, "\nbl tree: sent %ld", s->bits_sent));
|
||||||
|
|
||||||
send_tree(s, (ct_data *)s->dyn_ltree, lcodes-1); /* literal tree */
|
send_tree(s, (ct_data *)s->dyn_ltree, lcodes - 1); /* literal tree */
|
||||||
Tracev((stderr, "\nlit tree: sent %ld", s->bits_sent));
|
Tracev((stderr, "\nlit tree: sent %ld", s->bits_sent));
|
||||||
|
|
||||||
send_tree(s, (ct_data *)s->dyn_dtree, dcodes-1); /* distance tree */
|
send_tree(s, (ct_data *)s->dyn_dtree, dcodes - 1); /* distance tree */
|
||||||
Tracev((stderr, "\ndist tree: sent %ld", s->bits_sent));
|
Tracev((stderr, "\ndist tree: sent %ld", s->bits_sent));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -866,17 +866,18 @@ void ZLIB_INTERNAL _tr_stored_block(s, buf, stored_len, last)
|
||||||
ulg stored_len; /* length of input block */
|
ulg stored_len; /* length of input block */
|
||||||
int last; /* one if this is the last block for a file */
|
int last; /* one if this is the last block for a file */
|
||||||
{
|
{
|
||||||
send_bits(s, (STORED_BLOCK<<1)+last, 3); /* send block type */
|
send_bits(s, (STORED_BLOCK<<1) + last, 3); /* send block type */
|
||||||
bi_windup(s); /* align on byte boundary */
|
bi_windup(s); /* align on byte boundary */
|
||||||
put_short(s, (ush)stored_len);
|
put_short(s, (ush)stored_len);
|
||||||
put_short(s, (ush)~stored_len);
|
put_short(s, (ush)~stored_len);
|
||||||
zmemcpy(s->pending_buf + s->pending, (Bytef *)buf, stored_len);
|
if (stored_len)
|
||||||
|
zmemcpy(s->pending_buf + s->pending, (Bytef *)buf, stored_len);
|
||||||
s->pending += stored_len;
|
s->pending += stored_len;
|
||||||
#ifdef ZLIB_DEBUG
|
#ifdef ZLIB_DEBUG
|
||||||
s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L;
|
s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L;
|
||||||
s->compressed_len += (stored_len + 4) << 3;
|
s->compressed_len += (stored_len + 4) << 3;
|
||||||
s->bits_sent += 2*16;
|
s->bits_sent += 2*16;
|
||||||
s->bits_sent += stored_len<<3;
|
s->bits_sent += stored_len << 3;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -942,14 +943,17 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
|
||||||
max_blindex = build_bl_tree(s);
|
max_blindex = build_bl_tree(s);
|
||||||
|
|
||||||
/* Determine the best encoding. Compute the block lengths in bytes. */
|
/* Determine the best encoding. Compute the block lengths in bytes. */
|
||||||
opt_lenb = (s->opt_len+3+7)>>3;
|
opt_lenb = (s->opt_len + 3 + 7) >> 3;
|
||||||
static_lenb = (s->static_len+3+7)>>3;
|
static_lenb = (s->static_len + 3 + 7) >> 3;
|
||||||
|
|
||||||
Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ",
|
Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ",
|
||||||
opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len,
|
opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len,
|
||||||
s->last_lit));
|
s->sym_next / 3));
|
||||||
|
|
||||||
if (static_lenb <= opt_lenb) opt_lenb = static_lenb;
|
#ifndef FORCE_STATIC
|
||||||
|
if (static_lenb <= opt_lenb || s->strategy == Z_FIXED)
|
||||||
|
#endif
|
||||||
|
opt_lenb = static_lenb;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Assert(buf != (char*)0, "lost buf");
|
Assert(buf != (char*)0, "lost buf");
|
||||||
|
@ -959,7 +963,7 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
|
||||||
#ifdef FORCE_STORED
|
#ifdef FORCE_STORED
|
||||||
if (buf != (char*)0) { /* force stored block */
|
if (buf != (char*)0) { /* force stored block */
|
||||||
#else
|
#else
|
||||||
if (stored_len+4 <= opt_lenb && buf != (char*)0) {
|
if (stored_len + 4 <= opt_lenb && buf != (char*)0) {
|
||||||
/* 4: two words for the lengths */
|
/* 4: two words for the lengths */
|
||||||
#endif
|
#endif
|
||||||
/* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE.
|
/* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE.
|
||||||
|
@ -970,21 +974,17 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
|
||||||
*/
|
*/
|
||||||
_tr_stored_block(s, buf, stored_len, last);
|
_tr_stored_block(s, buf, stored_len, last);
|
||||||
|
|
||||||
#ifdef FORCE_STATIC
|
} else if (static_lenb == opt_lenb) {
|
||||||
} else if (static_lenb >= 0) { /* force static trees */
|
send_bits(s, (STATIC_TREES<<1) + last, 3);
|
||||||
#else
|
|
||||||
} else if (s->strategy == Z_FIXED || static_lenb == opt_lenb) {
|
|
||||||
#endif
|
|
||||||
send_bits(s, (STATIC_TREES<<1)+last, 3);
|
|
||||||
compress_block(s, (const ct_data *)static_ltree,
|
compress_block(s, (const ct_data *)static_ltree,
|
||||||
(const ct_data *)static_dtree);
|
(const ct_data *)static_dtree);
|
||||||
#ifdef ZLIB_DEBUG
|
#ifdef ZLIB_DEBUG
|
||||||
s->compressed_len += 3 + s->static_len;
|
s->compressed_len += 3 + s->static_len;
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
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, (const ct_data *)s->dyn_ltree,
|
compress_block(s, (const ct_data *)s->dyn_ltree,
|
||||||
(const ct_data *)s->dyn_dtree);
|
(const ct_data *)s->dyn_dtree);
|
||||||
#ifdef ZLIB_DEBUG
|
#ifdef ZLIB_DEBUG
|
||||||
|
@ -1003,21 +1003,22 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
|
||||||
s->compressed_len += 7; /* align on byte boundary */
|
s->compressed_len += 7; /* align on byte boundary */
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len>>3,
|
Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len >> 3,
|
||||||
s->compressed_len-7*last));
|
s->compressed_len - 7*last));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===========================================================================
|
/* ===========================================================================
|
||||||
* Save the match info and tally the frequency counts. Return true if
|
* Save the match info and tally the frequency counts. Return true if
|
||||||
* the current block must be flushed.
|
* the current block must be flushed.
|
||||||
*/
|
*/
|
||||||
int ZLIB_INTERNAL _tr_tally (s, dist, lc)
|
int ZLIB_INTERNAL _tr_tally(s, dist, lc)
|
||||||
deflate_state *s;
|
deflate_state *s;
|
||||||
unsigned dist; /* distance of matched string */
|
unsigned dist; /* distance of matched string */
|
||||||
unsigned lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */
|
unsigned lc; /* match length - MIN_MATCH or unmatched char (dist==0) */
|
||||||
{
|
{
|
||||||
s->d_buf[s->last_lit] = (ush)dist;
|
s->sym_buf[s->sym_next++] = (uch)dist;
|
||||||
s->l_buf[s->last_lit++] = (uch)lc;
|
s->sym_buf[s->sym_next++] = (uch)(dist >> 8);
|
||||||
|
s->sym_buf[s->sym_next++] = (uch)lc;
|
||||||
if (dist == 0) {
|
if (dist == 0) {
|
||||||
/* lc is the unmatched char */
|
/* lc is the unmatched char */
|
||||||
s->dyn_ltree[lc].Freq++;
|
s->dyn_ltree[lc].Freq++;
|
||||||
|
@ -1029,33 +1030,10 @@ int ZLIB_INTERNAL _tr_tally (s, dist, lc)
|
||||||
(ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) &&
|
(ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) &&
|
||||||
(ush)d_code(dist) < (ush)D_CODES, "_tr_tally: bad match");
|
(ush)d_code(dist) < (ush)D_CODES, "_tr_tally: bad match");
|
||||||
|
|
||||||
s->dyn_ltree[_length_code[lc]+LITERALS+1].Freq++;
|
s->dyn_ltree[_length_code[lc] + LITERALS + 1].Freq++;
|
||||||
s->dyn_dtree[d_code(dist)].Freq++;
|
s->dyn_dtree[d_code(dist)].Freq++;
|
||||||
}
|
}
|
||||||
|
return (s->sym_next == s->sym_end);
|
||||||
#ifdef TRUNCATE_BLOCK
|
|
||||||
/* Try to guess if it is profitable to stop the current block here */
|
|
||||||
if ((s->last_lit & 0x1fff) == 0 && s->level > 2) {
|
|
||||||
/* Compute an upper bound for the compressed length */
|
|
||||||
ulg out_length = (ulg)s->last_lit*8L;
|
|
||||||
ulg in_length = (ulg)((long)s->strstart - s->block_start);
|
|
||||||
int dcode;
|
|
||||||
for (dcode = 0; dcode < D_CODES; dcode++) {
|
|
||||||
out_length += (ulg)s->dyn_dtree[dcode].Freq *
|
|
||||||
(5L+extra_dbits[dcode]);
|
|
||||||
}
|
|
||||||
out_length >>= 3;
|
|
||||||
Tracev((stderr,"\nlast_lit %u, in %ld, out ~%ld(%ld%%) ",
|
|
||||||
s->last_lit, in_length, out_length,
|
|
||||||
100L - out_length*100L/in_length));
|
|
||||||
if (s->matches < s->last_lit/2 && out_length < in_length/2) return 1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return (s->last_lit == s->lit_bufsize-1);
|
|
||||||
/* We avoid equality with lit_bufsize because of wraparound at 64K
|
|
||||||
* on 16 bit machines and because stored blocks are restricted to
|
|
||||||
* 64K-1 bytes.
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===========================================================================
|
/* ===========================================================================
|
||||||
|
@ -1068,20 +1046,21 @@ local void compress_block(s, ltree, dtree)
|
||||||
{
|
{
|
||||||
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) */
|
||||||
unsigned lx = 0; /* running index in l_buf */
|
unsigned sx = 0; /* running index in sym_buf */
|
||||||
unsigned code; /* the code to send */
|
unsigned code; /* the code to send */
|
||||||
int extra; /* number of extra bits to send */
|
int extra; /* number of extra bits to send */
|
||||||
|
|
||||||
if (s->last_lit != 0) do {
|
if (s->sym_next != 0) do {
|
||||||
dist = s->d_buf[lx];
|
dist = s->sym_buf[sx++] & 0xff;
|
||||||
lc = s->l_buf[lx++];
|
dist += (unsigned)(s->sym_buf[sx++] & 0xff) << 8;
|
||||||
|
lc = s->sym_buf[sx++];
|
||||||
if (dist == 0) {
|
if (dist == 0) {
|
||||||
send_code(s, lc, ltree); /* send a literal byte */
|
send_code(s, lc, ltree); /* send a literal byte */
|
||||||
Tracecv(isgraph(lc), (stderr," '%c' ", lc));
|
Tracecv(isgraph(lc), (stderr," '%c' ", lc));
|
||||||
} else {
|
} else {
|
||||||
/* Here, lc is the match length - MIN_MATCH */
|
/* Here, lc is the match length - MIN_MATCH */
|
||||||
code = _length_code[lc];
|
code = _length_code[lc];
|
||||||
send_code(s, code+LITERALS+1, ltree); /* send the length code */
|
send_code(s, code + LITERALS + 1, ltree); /* send length code */
|
||||||
extra = extra_lbits[code];
|
extra = extra_lbits[code];
|
||||||
if (extra != 0) {
|
if (extra != 0) {
|
||||||
lc -= base_length[code];
|
lc -= base_length[code];
|
||||||
|
@ -1099,11 +1078,10 @@ local void compress_block(s, ltree, dtree)
|
||||||
}
|
}
|
||||||
} /* literal or match pair ? */
|
} /* literal or match pair ? */
|
||||||
|
|
||||||
/* Check that the overlay between pending_buf and d_buf+l_buf is ok: */
|
/* Check that the overlay between pending_buf and sym_buf is ok: */
|
||||||
Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx,
|
Assert(s->pending < s->lit_bufsize + sx, "pendingBuf overflow");
|
||||||
"pendingBuf overflow");
|
|
||||||
|
|
||||||
} while (lx < s->last_lit);
|
} while (sx < s->sym_next);
|
||||||
|
|
||||||
send_code(s, END_BLOCK, ltree);
|
send_code(s, END_BLOCK, ltree);
|
||||||
}
|
}
|
||||||
|
@ -1112,9 +1090,9 @@ local void compress_block(s, ltree, dtree)
|
||||||
* Check if the data type is TEXT or BINARY, using the following algorithm:
|
* Check if the data type is TEXT or BINARY, using the following algorithm:
|
||||||
* - TEXT if the two conditions below are satisfied:
|
* - TEXT if the two conditions below are satisfied:
|
||||||
* a) There are no non-portable control characters belonging to the
|
* a) There are no non-portable control characters belonging to the
|
||||||
* "black list" (0..6, 14..25, 28..31).
|
* "block list" (0..6, 14..25, 28..31).
|
||||||
* b) There is at least one printable character belonging to the
|
* b) There is at least one printable character belonging to the
|
||||||
* "white list" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255).
|
* "allow list" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255).
|
||||||
* - BINARY otherwise.
|
* - BINARY otherwise.
|
||||||
* - The following partially-portable control characters form a
|
* - The following partially-portable control characters form a
|
||||||
* "gray list" that is ignored in this detection algorithm:
|
* "gray list" that is ignored in this detection algorithm:
|
||||||
|
@ -1124,19 +1102,19 @@ local void compress_block(s, ltree, dtree)
|
||||||
local int detect_data_type(s)
|
local int detect_data_type(s)
|
||||||
deflate_state *s;
|
deflate_state *s;
|
||||||
{
|
{
|
||||||
/* black_mask is the bit mask of black-listed bytes
|
/* block_mask is the bit mask of block-listed bytes
|
||||||
* set bits 0..6, 14..25, and 28..31
|
* set bits 0..6, 14..25, and 28..31
|
||||||
* 0xf3ffc07f = binary 11110011111111111100000001111111
|
* 0xf3ffc07f = binary 11110011111111111100000001111111
|
||||||
*/
|
*/
|
||||||
unsigned long black_mask = 0xf3ffc07fUL;
|
unsigned long block_mask = 0xf3ffc07fUL;
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
/* Check for non-textual ("black-listed") bytes. */
|
/* Check for non-textual ("block-listed") bytes. */
|
||||||
for (n = 0; n <= 31; n++, black_mask >>= 1)
|
for (n = 0; n <= 31; n++, block_mask >>= 1)
|
||||||
if ((black_mask & 1) && (s->dyn_ltree[n].Freq != 0))
|
if ((block_mask & 1) && (s->dyn_ltree[n].Freq != 0))
|
||||||
return Z_BINARY;
|
return Z_BINARY;
|
||||||
|
|
||||||
/* Check for textual ("white-listed") bytes. */
|
/* Check for textual ("allow-listed") bytes. */
|
||||||
if (s->dyn_ltree[9].Freq != 0 || s->dyn_ltree[10].Freq != 0
|
if (s->dyn_ltree[9].Freq != 0 || s->dyn_ltree[10].Freq != 0
|
||||||
|| s->dyn_ltree[13].Freq != 0)
|
|| s->dyn_ltree[13].Freq != 0)
|
||||||
return Z_TEXT;
|
return Z_TEXT;
|
||||||
|
@ -1144,7 +1122,7 @@ local int detect_data_type(s)
|
||||||
if (s->dyn_ltree[n].Freq != 0)
|
if (s->dyn_ltree[n].Freq != 0)
|
||||||
return Z_TEXT;
|
return Z_TEXT;
|
||||||
|
|
||||||
/* There are no "black-listed" or "white-listed" bytes:
|
/* There are no "block-listed" or "allow-listed" bytes:
|
||||||
* this stream either is empty or has tolerated ("gray-listed") bytes only.
|
* this stream either is empty or has tolerated ("gray-listed") bytes only.
|
||||||
*/
|
*/
|
||||||
return Z_BINARY;
|
return Z_BINARY;
|
||||||
|
@ -1198,6 +1176,6 @@ local void bi_windup(s)
|
||||||
s->bi_buf = 0;
|
s->bi_buf = 0;
|
||||||
s->bi_valid = 0;
|
s->bi_valid = 0;
|
||||||
#ifdef ZLIB_DEBUG
|
#ifdef ZLIB_DEBUG
|
||||||
s->bits_sent = (s->bits_sent+7) & ~7;
|
s->bits_sent = (s->bits_sent + 7) & ~7;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
Z_DATA_ERROR if the input data was corrupted, including if the input data is
|
Z_DATA_ERROR if the input data was corrupted, including if the input data is
|
||||||
an incomplete zlib stream.
|
an incomplete zlib stream.
|
||||||
*/
|
*/
|
||||||
int ZEXPORT uncompress2 (dest, destLen, source, sourceLen)
|
int ZEXPORT uncompress2(dest, destLen, source, sourceLen)
|
||||||
Bytef *dest;
|
Bytef *dest;
|
||||||
uLongf *destLen;
|
uLongf *destLen;
|
||||||
const Bytef *source;
|
const Bytef *source;
|
||||||
|
@ -83,7 +83,7 @@ int ZEXPORT uncompress2 (dest, destLen, source, sourceLen)
|
||||||
err;
|
err;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ZEXPORT uncompress (dest, destLen, source, sourceLen)
|
int ZEXPORT uncompress(dest, destLen, source, sourceLen)
|
||||||
Bytef *dest;
|
Bytef *dest;
|
||||||
uLongf *destLen;
|
uLongf *destLen;
|
||||||
const Bytef *source;
|
const Bytef *source;
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
#
|
#
|
||||||
# Usage:
|
# Usage:
|
||||||
# make -f win32/Makefile.bor
|
# make -f win32/Makefile.bor
|
||||||
# make -f win32/Makefile.bor LOCAL_ZLIB=-DASMV OBJA=match.obj OBJPA=+match.obj
|
|
||||||
|
|
||||||
# ------------ Borland C++ ------------
|
# ------------ Borland C++ ------------
|
||||||
|
|
||||||
|
|
|
@ -11,10 +11,6 @@
|
||||||
#
|
#
|
||||||
# make -fwin32/Makefile.gcc; make test testdll -fwin32/Makefile.gcc
|
# make -fwin32/Makefile.gcc; make test testdll -fwin32/Makefile.gcc
|
||||||
#
|
#
|
||||||
# To use the asm code, type:
|
|
||||||
# cp contrib/asm?86/match.S ./match.S
|
|
||||||
# make LOC=-DASMV OBJA=match.o -fwin32/Makefile.gcc
|
|
||||||
#
|
|
||||||
# To install libz.a, zconf.h and zlib.h in the system directories, type:
|
# To install libz.a, zconf.h and zlib.h in the system directories, type:
|
||||||
#
|
#
|
||||||
# make install -fwin32/Makefile.gcc
|
# make install -fwin32/Makefile.gcc
|
||||||
|
@ -38,7 +34,6 @@ IMPLIB = libz.dll.a
|
||||||
#
|
#
|
||||||
SHARED_MODE=0
|
SHARED_MODE=0
|
||||||
|
|
||||||
#LOC = -DASMV
|
|
||||||
#LOC = -DZLIB_DEBUG -g
|
#LOC = -DZLIB_DEBUG -g
|
||||||
|
|
||||||
PREFIX =
|
PREFIX =
|
||||||
|
|
|
@ -4,10 +4,6 @@
|
||||||
# Usage:
|
# Usage:
|
||||||
# nmake -f win32/Makefile.msc (standard build)
|
# nmake -f win32/Makefile.msc (standard build)
|
||||||
# nmake -f win32/Makefile.msc LOC=-DFOO (nonstandard build)
|
# nmake -f win32/Makefile.msc LOC=-DFOO (nonstandard build)
|
||||||
# nmake -f win32/Makefile.msc LOC="-DASMV -DASMINF" \
|
|
||||||
# OBJA="inffas32.obj match686.obj" (use ASM code, x86)
|
|
||||||
# nmake -f win32/Makefile.msc AS=ml64 LOC="-DASMV -DASMINF -I." \
|
|
||||||
# OBJA="inffasx64.obj gvmat64.obj inffas8664.obj" (use ASM code, x64)
|
|
||||||
|
|
||||||
# The toplevel directory of the source tree.
|
# The toplevel directory of the source tree.
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
ZLIB DATA COMPRESSION LIBRARY
|
ZLIB DATA COMPRESSION LIBRARY
|
||||||
|
|
||||||
zlib 1.2.11.1 is a general purpose data compression library. All the code is
|
zlib 1.2.13 is a general purpose data compression library. All the code is
|
||||||
thread safe. The data format used by the zlib library is described by RFCs
|
thread safe. The data format used by the zlib library is described by RFCs
|
||||||
(Request for Comments) 1950 to 1952 in the files
|
(Request for Comments) 1950 to 1952 in the files
|
||||||
http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format)
|
http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format)
|
||||||
|
@ -22,7 +22,7 @@ before asking for help.
|
||||||
|
|
||||||
Manifest:
|
Manifest:
|
||||||
|
|
||||||
The package zlib-1.2.11.1-win32-x86.zip will contain the following files:
|
The package zlib-1.2.13-win32-x86.zip will contain the following files:
|
||||||
|
|
||||||
README-WIN32.txt This document
|
README-WIN32.txt This document
|
||||||
ChangeLog Changes since previous zlib packages
|
ChangeLog Changes since previous zlib packages
|
||||||
|
|
|
@ -69,6 +69,7 @@ EXPORTS
|
||||||
gzoffset64
|
gzoffset64
|
||||||
adler32_combine64
|
adler32_combine64
|
||||||
crc32_combine64
|
crc32_combine64
|
||||||
|
crc32_combine_gen64
|
||||||
; checksum functions
|
; checksum functions
|
||||||
adler32
|
adler32
|
||||||
adler32_z
|
adler32_z
|
||||||
|
@ -76,6 +77,8 @@ EXPORTS
|
||||||
crc32_z
|
crc32_z
|
||||||
adler32_combine
|
adler32_combine
|
||||||
crc32_combine
|
crc32_combine
|
||||||
|
crc32_combine_gen
|
||||||
|
crc32_combine_op
|
||||||
; various hacks, don't look :)
|
; various hacks, don't look :)
|
||||||
deflateInit_
|
deflateInit_
|
||||||
deflateInit2_
|
deflateInit2_
|
||||||
|
|
|
@ -26,7 +26,7 @@ BEGIN
|
||||||
VALUE "FileDescription", "zlib data compression library\0"
|
VALUE "FileDescription", "zlib data compression library\0"
|
||||||
VALUE "FileVersion", ZLIB_VERSION "\0"
|
VALUE "FileVersion", ZLIB_VERSION "\0"
|
||||||
VALUE "InternalName", "zlib1.dll\0"
|
VALUE "InternalName", "zlib1.dll\0"
|
||||||
VALUE "LegalCopyright", "(C) 1995-2017 Jean-loup Gailly & Mark Adler\0"
|
VALUE "LegalCopyright", "(C) 1995-2022 Jean-loup Gailly & Mark Adler\0"
|
||||||
VALUE "OriginalFilename", "zlib1.dll\0"
|
VALUE "OriginalFilename", "zlib1.dll\0"
|
||||||
VALUE "ProductName", "zlib\0"
|
VALUE "ProductName", "zlib\0"
|
||||||
VALUE "ProductVersion", ZLIB_VERSION "\0"
|
VALUE "ProductVersion", ZLIB_VERSION "\0"
|
||||||
|
|
|
@ -40,6 +40,9 @@
|
||||||
# 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
|
||||||
|
# define crc32_combine_gen z_crc32_combine_gen
|
||||||
|
# define crc32_combine_gen64 z_crc32_combine_gen64
|
||||||
|
# define crc32_combine_op z_crc32_combine_op
|
||||||
# define crc32_z z_crc32_z
|
# define crc32_z z_crc32_z
|
||||||
# define deflate z_deflate
|
# define deflate z_deflate
|
||||||
# define deflateBound z_deflateBound
|
# define deflateBound z_deflateBound
|
||||||
|
@ -351,6 +354,9 @@
|
||||||
# ifdef FAR
|
# ifdef FAR
|
||||||
# undef FAR
|
# undef FAR
|
||||||
# endif
|
# endif
|
||||||
|
# ifndef WIN32_LEAN_AND_MEAN
|
||||||
|
# define WIN32_LEAN_AND_MEAN
|
||||||
|
# endif
|
||||||
# include <windows.h>
|
# include <windows.h>
|
||||||
/* No need for _export, use ZLIB.DEF instead. */
|
/* No need for _export, use ZLIB.DEF instead. */
|
||||||
/* For complete Windows compatibility, use WINAPI, not __stdcall. */
|
/* For complete Windows compatibility, use WINAPI, not __stdcall. */
|
||||||
|
@ -469,11 +475,18 @@ typedef uLong FAR uLongf;
|
||||||
# undef _LARGEFILE64_SOURCE
|
# undef _LARGEFILE64_SOURCE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__WATCOMC__) && !defined(Z_HAVE_UNISTD_H)
|
#ifndef Z_HAVE_UNISTD_H
|
||||||
# define Z_HAVE_UNISTD_H
|
# ifdef __WATCOMC__
|
||||||
|
# define Z_HAVE_UNISTD_H
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#ifndef Z_HAVE_UNISTD_H
|
||||||
|
# if defined(_LARGEFILE64_SOURCE) && !defined(_WIN32)
|
||||||
|
# define Z_HAVE_UNISTD_H
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
#ifndef Z_SOLO
|
#ifndef Z_SOLO
|
||||||
# if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE)
|
# if defined(Z_HAVE_UNISTD_H)
|
||||||
# include <unistd.h> /* for SEEK_*, off_t, and _LFS64_LARGEFILE */
|
# 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 */
|
||||||
|
|
|
@ -38,6 +38,9 @@
|
||||||
# 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
|
||||||
|
# define crc32_combine_gen z_crc32_combine_gen
|
||||||
|
# define crc32_combine_gen64 z_crc32_combine_gen64
|
||||||
|
# define crc32_combine_op z_crc32_combine_op
|
||||||
# define crc32_z z_crc32_z
|
# define crc32_z z_crc32_z
|
||||||
# define deflate z_deflate
|
# define deflate z_deflate
|
||||||
# define deflateBound z_deflateBound
|
# define deflateBound z_deflateBound
|
||||||
|
@ -349,6 +352,9 @@
|
||||||
# ifdef FAR
|
# ifdef FAR
|
||||||
# undef FAR
|
# undef FAR
|
||||||
# endif
|
# endif
|
||||||
|
# ifndef WIN32_LEAN_AND_MEAN
|
||||||
|
# define WIN32_LEAN_AND_MEAN
|
||||||
|
# endif
|
||||||
# include <windows.h>
|
# include <windows.h>
|
||||||
/* No need for _export, use ZLIB.DEF instead. */
|
/* No need for _export, use ZLIB.DEF instead. */
|
||||||
/* For complete Windows compatibility, use WINAPI, not __stdcall. */
|
/* For complete Windows compatibility, use WINAPI, not __stdcall. */
|
||||||
|
@ -467,11 +473,18 @@ typedef uLong FAR uLongf;
|
||||||
# undef _LARGEFILE64_SOURCE
|
# undef _LARGEFILE64_SOURCE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__WATCOMC__) && !defined(Z_HAVE_UNISTD_H)
|
#ifndef Z_HAVE_UNISTD_H
|
||||||
# define Z_HAVE_UNISTD_H
|
# ifdef __WATCOMC__
|
||||||
|
# define Z_HAVE_UNISTD_H
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#ifndef Z_HAVE_UNISTD_H
|
||||||
|
# if defined(_LARGEFILE64_SOURCE) && !defined(_WIN32)
|
||||||
|
# define Z_HAVE_UNISTD_H
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
#ifndef Z_SOLO
|
#ifndef Z_SOLO
|
||||||
# if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE)
|
# if defined(Z_HAVE_UNISTD_H)
|
||||||
# include <unistd.h> /* for SEEK_*, off_t, and _LFS64_LARGEFILE */
|
# 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 */
|
||||||
|
|
|
@ -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.11.1, January xxth, 2017
|
version 1.2.13, October 13th, 2022
|
||||||
|
|
||||||
Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler
|
Copyright (C) 1995-2022 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
|
||||||
|
@ -37,12 +37,12 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define ZLIB_VERSION "1.2.11.1-motley"
|
#define ZLIB_VERSION "1.2.13"
|
||||||
#define ZLIB_VERNUM 0x12b1
|
#define ZLIB_VERNUM 0x12d0
|
||||||
#define ZLIB_VER_MAJOR 1
|
#define ZLIB_VER_MAJOR 1
|
||||||
#define ZLIB_VER_MINOR 2
|
#define ZLIB_VER_MINOR 2
|
||||||
#define ZLIB_VER_REVISION 11
|
#define ZLIB_VER_REVISION 13
|
||||||
#define ZLIB_VER_SUBREVISION 1
|
#define ZLIB_VER_SUBREVISION 0
|
||||||
|
|
||||||
/*
|
/*
|
||||||
The 'zlib' compression library provides in-memory compression and
|
The 'zlib' compression library provides in-memory compression and
|
||||||
|
@ -78,10 +78,6 @@ extern "C" {
|
||||||
even in the case of corrupted input.
|
even in the case of corrupted input.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef __ANDROID__
|
|
||||||
typedef unsigned long zcrc_t;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));
|
typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));
|
||||||
typedef void (*free_func) OF((voidpf opaque, voidpf address));
|
typedef void (*free_func) OF((voidpf opaque, voidpf address));
|
||||||
|
|
||||||
|
@ -280,7 +276,7 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
|
||||||
== 0), or after each call of deflate(). If deflate returns Z_OK and with
|
== 0), or after each call of deflate(). If deflate returns Z_OK and with
|
||||||
zero avail_out, it must be called again after making room in the output
|
zero avail_out, it must be called again after making room in the output
|
||||||
buffer because there might be more output pending. See deflatePending(),
|
buffer because there might be more output pending. See deflatePending(),
|
||||||
which can be used if desired to determine whether or not there is more ouput
|
which can be used if desired to determine whether or not there is more output
|
||||||
in that case.
|
in that case.
|
||||||
|
|
||||||
Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to
|
Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to
|
||||||
|
@ -547,8 +543,7 @@ ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
|
||||||
int strategy));
|
int strategy));
|
||||||
|
|
||||||
This is another version of deflateInit with more compression options. The
|
This is another version of deflateInit with more compression options. The
|
||||||
fields next_in, zalloc, zfree and opaque must be initialized before by the
|
fields zalloc, zfree and opaque must be initialized before by the caller.
|
||||||
caller.
|
|
||||||
|
|
||||||
The method parameter is the compression method. It must be Z_DEFLATED in
|
The method parameter is the compression method. It must be Z_DEFLATED in
|
||||||
this version of the library.
|
this version of the library.
|
||||||
|
@ -665,7 +660,7 @@ ZEXTERN int ZEXPORT deflateGetDictionary OF((z_streamp strm,
|
||||||
to dictionary. dictionary must have enough space, where 32768 bytes is
|
to dictionary. dictionary must have enough space, where 32768 bytes is
|
||||||
always enough. If deflateGetDictionary() is called with dictionary equal to
|
always enough. If deflateGetDictionary() is called with dictionary equal to
|
||||||
Z_NULL, then only the dictionary length is returned, and nothing is copied.
|
Z_NULL, then only the dictionary length is returned, and nothing is copied.
|
||||||
Similary, if dictLength is Z_NULL, then it is not set.
|
Similarly, if dictLength is Z_NULL, then it is not set.
|
||||||
|
|
||||||
deflateGetDictionary() may return a length less than the window size, even
|
deflateGetDictionary() may return a length less than the window size, even
|
||||||
when more than the window size in input has been provided. It may return up
|
when more than the window size in input has been provided. It may return up
|
||||||
|
@ -870,9 +865,11 @@ ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
|
||||||
detection, or add 16 to decode only the gzip format (the zlib format will
|
detection, or add 16 to decode only the gzip format (the zlib format will
|
||||||
return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is a
|
return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is a
|
||||||
CRC-32 instead of an Adler-32. Unlike the gunzip utility and gzread() (see
|
CRC-32 instead of an Adler-32. Unlike the gunzip utility and gzread() (see
|
||||||
below), inflate() will not automatically decode concatenated gzip streams.
|
below), inflate() will *not* automatically decode concatenated gzip members.
|
||||||
inflate() will return Z_STREAM_END at the end of the gzip stream. The state
|
inflate() will return Z_STREAM_END at the end of the gzip member. The state
|
||||||
would need to be reset to continue decoding a subsequent gzip stream.
|
would need to be reset to continue decoding a subsequent gzip member. This
|
||||||
|
*must* be done if there is more data after a gzip member, in order for the
|
||||||
|
decompression to be compliant with the gzip standard (RFC 1952).
|
||||||
|
|
||||||
inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
|
inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
|
||||||
memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
|
memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
|
||||||
|
@ -918,7 +915,7 @@ ZEXTERN int ZEXPORT inflateGetDictionary OF((z_streamp strm,
|
||||||
to dictionary. dictionary must have enough space, where 32768 bytes is
|
to dictionary. dictionary must have enough space, where 32768 bytes is
|
||||||
always enough. If inflateGetDictionary() is called with dictionary equal to
|
always enough. If inflateGetDictionary() is called with dictionary equal to
|
||||||
Z_NULL, then only the dictionary length is returned, and nothing is copied.
|
Z_NULL, then only the dictionary length is returned, and nothing is copied.
|
||||||
Similary, if dictLength is Z_NULL, then it is not set.
|
Similarly, if dictLength is Z_NULL, then it is not set.
|
||||||
|
|
||||||
inflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the
|
inflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the
|
||||||
stream state is inconsistent.
|
stream state is inconsistent.
|
||||||
|
@ -1307,14 +1304,14 @@ 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));
|
||||||
|
|
||||||
Opens a gzip (.gz) file for reading or writing. The mode parameter is as
|
Open the gzip (.gz) file at path for reading and decompressing, or
|
||||||
in fopen ("rb" or "wb") but can also include a compression level ("wb9") or
|
compressing and writing. The mode parameter is as in fopen ("rb" or "wb")
|
||||||
a strategy: 'f' for filtered data as in "wb6f", 'h' for Huffman-only
|
but can also include a compression level ("wb9") or a strategy: 'f' for
|
||||||
compression as in "wb1h", 'R' for run-length encoding as in "wb1R", or 'F'
|
filtered data as in "wb6f", 'h' for Huffman-only compression as in "wb1h",
|
||||||
for fixed code compression as in "wb9F". (See the description of
|
'R' for run-length encoding as in "wb1R", or 'F' for fixed code compression
|
||||||
deflateInit2 for more information about the strategy parameter.) 'T' will
|
as in "wb9F". (See the description of deflateInit2 for more information
|
||||||
request transparent writing or appending with no compression and not using
|
about the strategy parameter.) 'T' will request transparent writing or
|
||||||
the gzip format.
|
appending with no compression and not using the gzip format.
|
||||||
|
|
||||||
"a" can be used instead of "w" to request that the gzip stream that will
|
"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
|
be written be appended to the file. "+" will result in an error, since
|
||||||
|
@ -1344,9 +1341,9 @@ ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
|
||||||
|
|
||||||
ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode));
|
ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode));
|
||||||
/*
|
/*
|
||||||
gzdopen associates a gzFile with the file descriptor fd. File descriptors
|
Associate a gzFile with the file descriptor fd. File descriptors are
|
||||||
are obtained from calls like open, dup, creat, pipe or fileno (if the file
|
obtained from calls like open, dup, creat, pipe or fileno (if the file has
|
||||||
has been previously opened with fopen). The mode parameter is as in gzopen.
|
been previously opened with fopen). The mode parameter is as in gzopen.
|
||||||
|
|
||||||
The next call of gzclose on the returned gzFile will also close the file
|
The next call of gzclose on the returned gzFile will also close the file
|
||||||
descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor
|
descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor
|
||||||
|
@ -1367,13 +1364,13 @@ ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode));
|
||||||
|
|
||||||
ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size));
|
ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size));
|
||||||
/*
|
/*
|
||||||
Set the internal buffer size used by this library's functions. The
|
Set the internal buffer size used by this library's functions for file to
|
||||||
default buffer size is 8192 bytes. This function must be called after
|
size. The default buffer size is 8192 bytes. This function must be called
|
||||||
gzopen() or gzdopen(), and before any other calls that read or write the
|
after gzopen() or gzdopen(), and before any other calls that read or write
|
||||||
file. The buffer memory allocation is always deferred to the first read or
|
the file. The buffer memory allocation is always deferred to the first read
|
||||||
write. Three times that size in buffer space is allocated. A larger buffer
|
or write. Three times that size in buffer space is allocated. A larger
|
||||||
size of, for example, 64K or 128K bytes will noticeably increase the speed
|
buffer size of, for example, 64K or 128K bytes will noticeably increase the
|
||||||
of decompression (reading).
|
speed of decompression (reading).
|
||||||
|
|
||||||
The new buffer size also affects the maximum length for gzprintf().
|
The new buffer size also affects the maximum length for gzprintf().
|
||||||
|
|
||||||
|
@ -1383,9 +1380,9 @@ ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size));
|
||||||
|
|
||||||
ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));
|
ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));
|
||||||
/*
|
/*
|
||||||
Dynamically update the compression level or strategy. See the description
|
Dynamically update the compression level and strategy for file. See the
|
||||||
of deflateInit2 for the meaning of these parameters. Previously provided
|
description of deflateInit2 for the meaning of these parameters. Previously
|
||||||
data is flushed before the parameter change.
|
provided data is flushed before applying the parameter changes.
|
||||||
|
|
||||||
gzsetparams returns Z_OK if success, Z_STREAM_ERROR if the file was not
|
gzsetparams returns Z_OK if success, Z_STREAM_ERROR if the file was not
|
||||||
opened for writing, Z_ERRNO if there is an error writing the flushed data,
|
opened for writing, Z_ERRNO if there is an error writing the flushed data,
|
||||||
|
@ -1394,7 +1391,7 @@ 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
|
Read and decompress up to len uncompressed bytes from file into buf. If
|
||||||
the input file is 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 directly from the file.
|
bytes into the buffer directly from the file.
|
||||||
|
|
||||||
|
@ -1425,11 +1422,11 @@ ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));
|
||||||
ZEXTERN z_size_t ZEXPORT gzfread OF((voidp buf, z_size_t size, z_size_t nitems,
|
ZEXTERN z_size_t ZEXPORT gzfread OF((voidp buf, z_size_t size, z_size_t nitems,
|
||||||
gzFile file));
|
gzFile file));
|
||||||
/*
|
/*
|
||||||
Read up to nitems items of size size from file to buf, otherwise operating
|
Read and decompress up to nitems items of size size from file into buf,
|
||||||
as gzread() does. This duplicates the interface of stdio's fread(), with
|
otherwise operating as gzread() does. This duplicates the interface of
|
||||||
size_t request and return types. If the library defines size_t, then
|
stdio's fread(), with size_t request and return types. If the library
|
||||||
z_size_t is identical to size_t. If not, then z_size_t is an unsigned
|
defines size_t, then z_size_t is identical to size_t. If not, then z_size_t
|
||||||
integer type that can contain a pointer.
|
is an unsigned integer type that can contain a pointer.
|
||||||
|
|
||||||
gzfread() returns the number of full items read of size size, or zero if
|
gzfread() returns the number of full items read of size size, or zero if
|
||||||
the end of the file was reached and a full item could not be read, or if
|
the end of the file was reached and a full item could not be read, or if
|
||||||
|
@ -1440,26 +1437,24 @@ ZEXTERN z_size_t ZEXPORT gzfread OF((voidp buf, z_size_t size, z_size_t nitems,
|
||||||
|
|
||||||
In the event that the end of file is reached and only a partial item is
|
In the event that the end of file is reached and only a partial item is
|
||||||
available at the end, i.e. the remaining uncompressed data length is not a
|
available at the end, i.e. the remaining uncompressed data length is not a
|
||||||
multiple of size, then the final partial item is nevetheless read into buf
|
multiple of size, then the final partial item is nevertheless read into buf
|
||||||
and the end-of-file flag is set. The length of the partial item read is not
|
and the end-of-file flag is set. The length of the partial item read is not
|
||||||
provided, but could be inferred from the result of gztell(). This behavior
|
provided, but could be inferred from the result of gztell(). This behavior
|
||||||
is the same as the behavior of fread() implementations in common libraries,
|
is the same as the behavior of fread() implementations in common libraries,
|
||||||
but it prevents the direct use of gzfread() to read a concurrently written
|
but it prevents the direct use of gzfread() to read a concurrently written
|
||||||
file, reseting and retrying on end-of-file, when size is not 1.
|
file, resetting and retrying on end-of-file, when size is not 1.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ZEXTERN int ZEXPORT gzwrite OF((gzFile file,
|
ZEXTERN int ZEXPORT gzwrite OF((gzFile file, voidpc buf, unsigned len));
|
||||||
voidpc buf, unsigned len));
|
|
||||||
/*
|
/*
|
||||||
Writes the given number of uncompressed bytes into the compressed file.
|
Compress and write the len uncompressed bytes at buf to file. gzwrite
|
||||||
gzwrite returns the number of uncompressed bytes written or 0 in case of
|
returns the number of uncompressed bytes written or 0 in case of error.
|
||||||
error.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ZEXTERN z_size_t ZEXPORT gzfwrite OF((voidpc buf, z_size_t size,
|
ZEXTERN z_size_t ZEXPORT gzfwrite OF((voidpc buf, z_size_t size,
|
||||||
z_size_t nitems, gzFile file));
|
z_size_t nitems, gzFile file));
|
||||||
/*
|
/*
|
||||||
gzfwrite() writes nitems items of size size from buf to file, duplicating
|
Compress and write nitems items of size size from buf to file, duplicating
|
||||||
the interface of stdio's fwrite(), with size_t request and return types. If
|
the interface of stdio's fwrite(), with size_t request and return types. If
|
||||||
the library defines size_t, then z_size_t is identical to size_t. If not,
|
the library defines size_t, then z_size_t is identical to size_t. If not,
|
||||||
then z_size_t is an unsigned integer type that can contain a pointer.
|
then z_size_t is an unsigned integer type that can contain a pointer.
|
||||||
|
@ -1472,22 +1467,22 @@ ZEXTERN z_size_t ZEXPORT gzfwrite OF((voidpc buf, z_size_t size,
|
||||||
|
|
||||||
ZEXTERN int ZEXPORTVA gzprintf Z_ARG((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
|
Convert, format, compress, and write the arguments (...) to file under
|
||||||
control of the format string, as in fprintf. gzprintf returns the number of
|
control of the string format, as in fprintf. gzprintf returns the number of
|
||||||
uncompressed bytes actually written, or a negative zlib error code in case
|
uncompressed bytes actually written, or a negative zlib error code in case
|
||||||
of error. The number of uncompressed bytes written is limited to 8191, or
|
of error. The number of uncompressed bytes written is limited to 8191, or
|
||||||
one less than the buffer size given to gzbuffer(). The caller should assure
|
one less than the buffer size given to gzbuffer(). The caller should assure
|
||||||
that this limit is not exceeded. If it is exceeded, then gzprintf() will
|
that this limit is not exceeded. If it is exceeded, then gzprintf() will
|
||||||
return an error (0) with nothing written. In this case, there may also be a
|
return an error (0) with nothing written. In this case, there may also be a
|
||||||
buffer overflow with unpredictable consequences, which is possible only if
|
buffer overflow with unpredictable consequences, which is possible only if
|
||||||
zlib was compiled with the insecure functions sprintf() or vsprintf()
|
zlib was compiled with the insecure functions sprintf() or vsprintf(),
|
||||||
because the secure snprintf() or vsnprintf() functions were not available.
|
because the secure snprintf() or vsnprintf() functions were not available.
|
||||||
This can be determined using zlibCompileFlags().
|
This can be determined using zlibCompileFlags().
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));
|
ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));
|
||||||
/*
|
/*
|
||||||
Writes the given null-terminated string to the compressed file, excluding
|
Compress and write the given null-terminated string s to file, excluding
|
||||||
the terminating null character.
|
the terminating null character.
|
||||||
|
|
||||||
gzputs returns the number of characters written, or -1 in case of error.
|
gzputs returns the number of characters written, or -1 in case of error.
|
||||||
|
@ -1495,11 +1490,12 @@ ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));
|
||||||
|
|
||||||
ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));
|
ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));
|
||||||
/*
|
/*
|
||||||
Reads bytes from the compressed file until len-1 characters are read, or a
|
Read and decompress bytes from file into buf, until len-1 characters are
|
||||||
newline character is read and transferred to buf, or an end-of-file
|
read, or until a newline character is read and transferred to buf, or an
|
||||||
condition is encountered. If any characters are read or if len == 1, the
|
end-of-file condition is encountered. If any characters are read or if len
|
||||||
string is terminated with a null character. If no characters are read due
|
is one, the string is terminated with a null character. If no characters
|
||||||
to an end-of-file or len < 1, then the buffer is left untouched.
|
are read due to an end-of-file or len is less than one, then the buffer is
|
||||||
|
left untouched.
|
||||||
|
|
||||||
gzgets returns buf which is a null-terminated string, or it returns NULL
|
gzgets returns buf which is a null-terminated string, or it returns NULL
|
||||||
for end-of-file or in case of error. If there was an error, the contents at
|
for end-of-file or in case of error. If there was an error, the contents at
|
||||||
|
@ -1508,13 +1504,13 @@ ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));
|
||||||
|
|
||||||
ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c));
|
ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c));
|
||||||
/*
|
/*
|
||||||
Writes c, converted to an unsigned char, into the compressed file. gzputc
|
Compress and write c, converted to an unsigned char, into file. gzputc
|
||||||
returns the value that was written, or -1 in case of error.
|
returns the value that was written, or -1 in case of error.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
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
|
Read and decompress one byte from file. gzgetc returns this byte or -1
|
||||||
in case of end of file or error. This is implemented as a macro for speed.
|
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.
|
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
|
it does not check to see if file is NULL, nor whether the structure file
|
||||||
|
@ -1523,8 +1519,8 @@ ZEXTERN int ZEXPORT gzgetc OF((gzFile file));
|
||||||
|
|
||||||
ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file));
|
ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file));
|
||||||
/*
|
/*
|
||||||
Push one character back onto the stream to be read as the first character
|
Push c back onto the stream for file to be read as the first character on
|
||||||
on the next read. At least one character of push-back is allowed.
|
the next read. At least one character of push-back is always allowed.
|
||||||
gzungetc() returns the character pushed, or -1 on failure. gzungetc() will
|
gzungetc() returns the character pushed, or -1 on failure. gzungetc() will
|
||||||
fail if c is -1, and may fail if a character has been pushed but not read
|
fail if c is -1, and may fail if a character has been pushed but not read
|
||||||
yet. If gzungetc is used immediately after gzopen or gzdopen, at least the
|
yet. If gzungetc is used immediately after gzopen or gzdopen, at least the
|
||||||
|
@ -1535,9 +1531,9 @@ ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file));
|
||||||
|
|
||||||
ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush));
|
ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush));
|
||||||
/*
|
/*
|
||||||
Flushes all pending output into the compressed file. The parameter flush
|
Flush all pending output to file. The parameter flush is as in the
|
||||||
is as in the deflate() function. The return value is the zlib error number
|
deflate() function. The return value is the zlib error number (see function
|
||||||
(see function gzerror below). gzflush is only permitted when writing.
|
gzerror below). gzflush is only permitted when writing.
|
||||||
|
|
||||||
If the flush parameter is Z_FINISH, the remaining data is written and the
|
If the flush parameter is Z_FINISH, the remaining data is written and the
|
||||||
gzip stream is completed in the output. If gzwrite() is called again, a new
|
gzip stream is completed in the output. If gzwrite() is called again, a new
|
||||||
|
@ -1552,8 +1548,8 @@ ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush));
|
||||||
ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file,
|
ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file,
|
||||||
z_off_t offset, int whence));
|
z_off_t offset, int whence));
|
||||||
|
|
||||||
Sets the starting position for the next gzread or gzwrite on the given
|
Set the starting position to offset relative to whence for the next gzread
|
||||||
compressed file. The offset represents a number of bytes in the
|
or gzwrite on file. The offset represents a number of bytes in the
|
||||||
uncompressed data stream. The whence parameter is defined as in lseek(2);
|
uncompressed data stream. The whence parameter is defined as in lseek(2);
|
||||||
the value SEEK_END is not supported.
|
the value SEEK_END is not supported.
|
||||||
|
|
||||||
|
@ -1570,18 +1566,18 @@ ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file,
|
||||||
|
|
||||||
ZEXTERN int ZEXPORT gzrewind OF((gzFile file));
|
ZEXTERN int ZEXPORT gzrewind OF((gzFile file));
|
||||||
/*
|
/*
|
||||||
Rewinds the given file. This function is supported only for reading.
|
Rewind file. This function is supported only for reading.
|
||||||
|
|
||||||
gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)
|
gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file));
|
ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file));
|
||||||
|
|
||||||
Returns the starting position for the next gzread or gzwrite on the given
|
Return the starting position for the next gzread or gzwrite on file.
|
||||||
compressed file. This position represents a number of bytes in the
|
This position represents a number of bytes in the uncompressed data stream,
|
||||||
uncompressed data stream, and is zero when starting, even if appending or
|
and is zero when starting, even if appending or reading a gzip stream from
|
||||||
reading a gzip stream from the middle of a file using gzdopen().
|
the middle of a file using gzdopen().
|
||||||
|
|
||||||
gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)
|
gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)
|
||||||
*/
|
*/
|
||||||
|
@ -1589,22 +1585,22 @@ ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file));
|
||||||
/*
|
/*
|
||||||
ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file));
|
ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file));
|
||||||
|
|
||||||
Returns the current offset in the file being read or written. This offset
|
Return the current compressed (actual) read or write offset of file. This
|
||||||
includes the count of bytes that precede the gzip stream, for example when
|
offset includes the count of bytes that precede the gzip stream, for example
|
||||||
appending or when using gzdopen() for reading. When reading, the offset
|
when appending or when using gzdopen() for reading. When reading, the
|
||||||
does not include as yet unused buffered input. This information can be used
|
offset does not include as yet unused buffered input. This information can
|
||||||
for a progress indicator. On error, gzoffset() returns -1.
|
be used for a progress indicator. On error, gzoffset() returns -1.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ZEXTERN int ZEXPORT gzeof OF((gzFile file));
|
ZEXTERN int ZEXPORT gzeof OF((gzFile file));
|
||||||
/*
|
/*
|
||||||
Returns true (1) if the end-of-file indicator has been set while reading,
|
Return true (1) if the end-of-file indicator for file has been set while
|
||||||
false (0) otherwise. Note that the end-of-file indicator is set only if the
|
reading, false (0) otherwise. Note that the end-of-file indicator is set
|
||||||
read tried to go past the end of the input, but came up short. Therefore,
|
only if the read tried to go past the end of the input, but came up short.
|
||||||
just like feof(), gzeof() may return false even if there is no more data to
|
Therefore, just like feof(), gzeof() may return false even if there is no
|
||||||
read, in the event that the last read request was for the exact number of
|
more data to read, in the event that the last read request was for the exact
|
||||||
bytes remaining in the input file. This will happen if the input file size
|
number of bytes remaining in the input file. This will happen if the input
|
||||||
is an exact multiple of the buffer size.
|
file size is an exact multiple of the buffer size.
|
||||||
|
|
||||||
If gzeof() returns true, then the read functions will return no more data,
|
If gzeof() returns true, then the read functions will return no more data,
|
||||||
unless the end-of-file indicator is reset by gzclearerr() and the input file
|
unless the end-of-file indicator is reset by gzclearerr() and the input file
|
||||||
|
@ -1613,7 +1609,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
|
Return true (1) if file is being copied directly while reading, or false
|
||||||
(0) if file is a gzip stream being decompressed.
|
(0) if file is a gzip stream being decompressed.
|
||||||
|
|
||||||
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
|
||||||
|
@ -1634,8 +1630,8 @@ ZEXTERN int ZEXPORT gzdirect OF((gzFile file));
|
||||||
|
|
||||||
ZEXTERN int ZEXPORT gzclose OF((gzFile file));
|
ZEXTERN int ZEXPORT gzclose OF((gzFile file));
|
||||||
/*
|
/*
|
||||||
Flushes all pending output if necessary, closes the compressed file and
|
Flush all pending output for file, if necessary, close file and
|
||||||
deallocates the (de)compression state. Note that once file is closed, you
|
deallocate the (de)compression state. Note that once file is closed, you
|
||||||
cannot call gzerror with file, since its structures have been deallocated.
|
cannot call gzerror with file, since its structures have been deallocated.
|
||||||
gzclose must not be called more than once on the same file, just as free
|
gzclose must not be called more than once on the same file, just as free
|
||||||
must not be called more than once on the same allocation.
|
must not be called more than once on the same allocation.
|
||||||
|
@ -1659,10 +1655,10 @@ ZEXTERN int ZEXPORT gzclose_w OF((gzFile file));
|
||||||
|
|
||||||
ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));
|
ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));
|
||||||
/*
|
/*
|
||||||
Returns the error message for the last error which occurred on the given
|
Return the error message for the last error which occurred on file.
|
||||||
compressed file. errnum is set to zlib error number. If an error occurred
|
errnum is set to zlib error number. If an error occurred in the file system
|
||||||
in the file system and not in the compression library, errnum is set to
|
and not in the compression library, errnum is set to Z_ERRNO and the
|
||||||
Z_ERRNO and the application may consult errno to get the exact error code.
|
application may consult errno to get the exact error code.
|
||||||
|
|
||||||
The application must not modify the returned string. Future calls to
|
The application must not modify the returned string. Future calls to
|
||||||
this function may invalidate the previously returned string. If file is
|
this function may invalidate the previously returned string. If file is
|
||||||
|
@ -1675,7 +1671,7 @@ ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));
|
||||||
|
|
||||||
ZEXTERN void ZEXPORT gzclearerr OF((gzFile file));
|
ZEXTERN void ZEXPORT gzclearerr OF((gzFile file));
|
||||||
/*
|
/*
|
||||||
Clears the error and end-of-file flags for file. This is analogous to the
|
Clear the error and end-of-file flags for file. This is analogous to the
|
||||||
clearerr() function in stdio. This is useful for continuing to read a gzip
|
clearerr() function in stdio. This is useful for continuing to read a gzip
|
||||||
file that is being written concurrently.
|
file that is being written concurrently.
|
||||||
*/
|
*/
|
||||||
|
@ -1693,8 +1689,9 @@ ZEXTERN void ZEXPORT gzclearerr OF((gzFile file));
|
||||||
ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
|
ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
|
||||||
/*
|
/*
|
||||||
Update a running Adler-32 checksum with the bytes buf[0..len-1] and
|
Update a running Adler-32 checksum with the bytes buf[0..len-1] and
|
||||||
return the updated checksum. If buf is Z_NULL, this function returns the
|
return the updated checksum. An Adler-32 value is in the range of a 32-bit
|
||||||
required initial value for the checksum.
|
unsigned integer. If buf is Z_NULL, this function returns the required
|
||||||
|
initial value for the checksum.
|
||||||
|
|
||||||
An Adler-32 checksum is almost as reliable as a CRC-32 but can be computed
|
An Adler-32 checksum is almost as reliable as a CRC-32 but can be computed
|
||||||
much faster.
|
much faster.
|
||||||
|
@ -1727,12 +1724,13 @@ ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2,
|
||||||
negative, the result has no meaning or utility.
|
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. A CRC-32 value is in the range of a 32-bit unsigned integer.
|
||||||
initial value for the crc. Pre- and post-conditioning (one's complement) is
|
If buf is Z_NULL, this function returns the required initial value for the
|
||||||
performed within this function so it shouldn't be done by the application.
|
crc. Pre- and post-conditioning (one's complement) is performed within this
|
||||||
|
function so it shouldn't be done by the application.
|
||||||
|
|
||||||
Usage example:
|
Usage example:
|
||||||
|
|
||||||
|
@ -1744,7 +1742,7 @@ ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));
|
||||||
if (crc != original_crc) error();
|
if (crc != original_crc) error();
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ZEXTERN uLong ZEXPORT crc32_z OF((uLong adler, const Bytef *buf,
|
ZEXTERN uLong ZEXPORT crc32_z OF((uLong crc, const Bytef *buf,
|
||||||
z_size_t len));
|
z_size_t len));
|
||||||
/*
|
/*
|
||||||
Same as crc32(), but with a size_t length.
|
Same as crc32(), but with a size_t length.
|
||||||
|
@ -1760,6 +1758,20 @@ ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2));
|
||||||
len2.
|
len2.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
ZEXTERN uLong ZEXPORT crc32_combine_gen OF((z_off_t len2));
|
||||||
|
|
||||||
|
Return the operator corresponding to length len2, to be used with
|
||||||
|
crc32_combine_op().
|
||||||
|
*/
|
||||||
|
|
||||||
|
ZEXTERN uLong ZEXPORT crc32_combine_op OF((uLong crc1, uLong crc2, uLong op));
|
||||||
|
/*
|
||||||
|
Give the same result as crc32_combine(), using op in place of len2. op is
|
||||||
|
is generated from len2 by crc32_combine_gen(). This will be faster than
|
||||||
|
crc32_combine() if the generated op is used more than once.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
/* various hacks, don't look :) */
|
/* various hacks, don't look :) */
|
||||||
|
|
||||||
|
@ -1847,6 +1859,7 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */
|
||||||
ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile));
|
ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile));
|
||||||
ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t));
|
ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t));
|
||||||
ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t));
|
ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t));
|
||||||
|
ZEXTERN uLong ZEXPORT crc32_combine_gen64 OF((z_off64_t));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(ZLIB_INTERNAL) && defined(Z_WANT64)
|
#if !defined(ZLIB_INTERNAL) && defined(Z_WANT64)
|
||||||
|
@ -1857,6 +1870,7 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */
|
||||||
# define z_gzoffset z_gzoffset64
|
# define z_gzoffset z_gzoffset64
|
||||||
# define z_adler32_combine z_adler32_combine64
|
# define z_adler32_combine z_adler32_combine64
|
||||||
# define z_crc32_combine z_crc32_combine64
|
# define z_crc32_combine z_crc32_combine64
|
||||||
|
# define z_crc32_combine_gen z_crc32_combine_gen64
|
||||||
# else
|
# else
|
||||||
# define gzopen gzopen64
|
# define gzopen gzopen64
|
||||||
# define gzseek gzseek64
|
# define gzseek gzseek64
|
||||||
|
@ -1864,6 +1878,7 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */
|
||||||
# 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
|
||||||
|
# define crc32_combine_gen crc32_combine_gen64
|
||||||
# endif
|
# endif
|
||||||
# ifndef Z_LARGE64
|
# ifndef Z_LARGE64
|
||||||
ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
|
ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
|
||||||
|
@ -1872,6 +1887,7 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */
|
||||||
ZEXTERN z_off_t ZEXPORT gzoffset64 OF((gzFile));
|
ZEXTERN z_off_t ZEXPORT gzoffset64 OF((gzFile));
|
||||||
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));
|
||||||
|
ZEXTERN uLong ZEXPORT crc32_combine_gen64 OF((z_off_t));
|
||||||
# endif
|
# endif
|
||||||
#else
|
#else
|
||||||
ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *));
|
ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *));
|
||||||
|
@ -1880,12 +1896,14 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */
|
||||||
ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile));
|
ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile));
|
||||||
ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));
|
ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));
|
||||||
ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));
|
ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));
|
||||||
|
ZEXTERN uLong ZEXPORT crc32_combine_gen OF((z_off_t));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#else /* Z_SOLO */
|
#else /* Z_SOLO */
|
||||||
|
|
||||||
ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));
|
ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));
|
||||||
ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));
|
ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));
|
||||||
|
ZEXTERN uLong ZEXPORT crc32_combine_gen OF((z_off_t));
|
||||||
|
|
||||||
#endif /* !Z_SOLO */
|
#endif /* !Z_SOLO */
|
||||||
|
|
||||||
|
@ -1895,7 +1913,7 @@ ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp));
|
||||||
ZEXTERN const z_crc_t FAR * 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 inflateValidate OF((z_streamp, int));
|
ZEXTERN int ZEXPORT inflateValidate OF((z_streamp, int));
|
||||||
ZEXTERN unsigned long ZEXPORT inflateCodesUsed OF ((z_streamp));
|
ZEXTERN unsigned long ZEXPORT inflateCodesUsed OF((z_streamp));
|
||||||
ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp));
|
ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp));
|
||||||
ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp));
|
ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp));
|
||||||
#if defined(_WIN32) && !defined(Z_SOLO)
|
#if defined(_WIN32) && !defined(Z_SOLO)
|
||||||
|
|
|
@ -61,9 +61,11 @@ uLong ZEXPORT zlibCompileFlags()
|
||||||
#ifdef ZLIB_DEBUG
|
#ifdef ZLIB_DEBUG
|
||||||
flags += 1 << 8;
|
flags += 1 << 8;
|
||||||
#endif
|
#endif
|
||||||
|
/*
|
||||||
#if defined(ASMV) || defined(ASMINF)
|
#if defined(ASMV) || defined(ASMINF)
|
||||||
flags += 1 << 9;
|
flags += 1 << 9;
|
||||||
#endif
|
#endif
|
||||||
|
*/
|
||||||
#ifdef ZLIB_WINAPI
|
#ifdef ZLIB_WINAPI
|
||||||
flags += 1 << 10;
|
flags += 1 << 10;
|
||||||
#endif
|
#endif
|
||||||
|
@ -119,7 +121,7 @@ uLong ZEXPORT zlibCompileFlags()
|
||||||
# endif
|
# endif
|
||||||
int ZLIB_INTERNAL z_verbose = verbose;
|
int ZLIB_INTERNAL z_verbose = verbose;
|
||||||
|
|
||||||
void ZLIB_INTERNAL z_error (m)
|
void ZLIB_INTERNAL z_error(m)
|
||||||
char *m;
|
char *m;
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s\n", m);
|
fprintf(stderr, "%s\n", m);
|
||||||
|
@ -214,7 +216,7 @@ local ptr_table table[MAX_PTR];
|
||||||
* a protected system like OS/2. Use Microsoft C instead.
|
* a protected system like OS/2. Use Microsoft C instead.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, unsigned items, unsigned size)
|
voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size)
|
||||||
{
|
{
|
||||||
voidpf buf;
|
voidpf buf;
|
||||||
ulg bsize = (ulg)items*size;
|
ulg bsize = (ulg)items*size;
|
||||||
|
@ -240,7 +242,7 @@ voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, unsigned items, unsigned size)
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr)
|
void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr)
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
|
@ -277,13 +279,13 @@ void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr)
|
||||||
# define _hfree hfree
|
# define _hfree hfree
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, uInt items, uInt size)
|
voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, uInt items, uInt size)
|
||||||
{
|
{
|
||||||
(void)opaque;
|
(void)opaque;
|
||||||
return _halloc((long)items, size);
|
return _halloc((long)items, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr)
|
void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr)
|
||||||
{
|
{
|
||||||
(void)opaque;
|
(void)opaque;
|
||||||
_hfree(ptr);
|
_hfree(ptr);
|
||||||
|
@ -302,7 +304,7 @@ extern voidp calloc OF((uInt items, uInt size));
|
||||||
extern void free OF((voidpf ptr));
|
extern void free OF((voidpf ptr));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
voidpf ZLIB_INTERNAL zcalloc (opaque, items, size)
|
voidpf ZLIB_INTERNAL zcalloc(opaque, items, size)
|
||||||
voidpf opaque;
|
voidpf opaque;
|
||||||
unsigned items;
|
unsigned items;
|
||||||
unsigned size;
|
unsigned size;
|
||||||
|
@ -312,7 +314,7 @@ voidpf ZLIB_INTERNAL zcalloc (opaque, items, size)
|
||||||
(voidpf)calloc(items, size);
|
(voidpf)calloc(items, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZLIB_INTERNAL zcfree (opaque, ptr)
|
void ZLIB_INTERNAL zcfree(opaque, ptr)
|
||||||
voidpf opaque;
|
voidpf opaque;
|
||||||
voidpf ptr;
|
voidpf ptr;
|
||||||
{
|
{
|
||||||
|
|
|
@ -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-2016 Jean-loup Gailly, Mark Adler
|
* Copyright (C) 1995-2022 Jean-loup Gailly, 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,6 +42,17 @@ typedef unsigned short ush;
|
||||||
typedef ush FAR ushf;
|
typedef ush FAR ushf;
|
||||||
typedef unsigned long ulg;
|
typedef unsigned long ulg;
|
||||||
|
|
||||||
|
#if !defined(Z_U8) && !defined(Z_SOLO) && defined(STDC)
|
||||||
|
# include <limits.h>
|
||||||
|
# if (ULONG_MAX == 0xffffffffffffffff)
|
||||||
|
# define Z_U8 unsigned long
|
||||||
|
# elif (ULLONG_MAX == 0xffffffffffffffff)
|
||||||
|
# define Z_U8 unsigned long long
|
||||||
|
# elif (UINT_MAX == 0xffffffffffffffff)
|
||||||
|
# define Z_U8 unsigned
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
extern z_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++) */
|
||||||
|
|
||||||
|
@ -182,6 +193,7 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
||||||
(!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0)
|
(!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));
|
||||||
|
ZEXTERN uLong ZEXPORT crc32_combine_gen64 OF((z_off_t));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* common defaults */
|
/* common defaults */
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
This is a heavily modified and shrinked version of zlib 1.2.3
|
|
||||||
|
|
||||||
- Removed comments from zlib.h
|
|
||||||
- Removed gzip/zip archive I/O
|
|
||||||
- Removed infback.c
|
|
||||||
- Added Assimp #idefs to exclude it if not needed
|
|
||||||
- Disabled debug macros in zutil.h
|
|
||||||
|
|
||||||
Assimp itself does not use the compression part yet, so
|
|
||||||
it needn't be compiled (trees.c, deflate.c, compress.c).
|
|
||||||
Currently these units are just used by assimp_cmd.
|
|
|
@ -8,7 +8,7 @@ def readme():
|
||||||
return f.read()
|
return f.read()
|
||||||
|
|
||||||
setup(name='pyassimp',
|
setup(name='pyassimp',
|
||||||
version='4.1.4',
|
version='5.2.5',
|
||||||
license='ISC',
|
license='ISC',
|
||||||
description='Python bindings for the Open Asset Import Library (ASSIMP)',
|
description='Python bindings for the Open Asset Import Library (ASSIMP)',
|
||||||
long_description=readme(),
|
long_description=readme(),
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
g cube
|
||||||
|
|
||||||
|
v 0.0 0.0 0.0
|
||||||
|
v 0.0 0.0 1.0 0.0 0.0 1.0
|
||||||
|
v 0.0 1.0 0.0
|
||||||
|
v 1.0 0.0 0.0 1.0 0.6 0.3
|
||||||
|
v 1.0 1.0 0.0
|
||||||
|
|
||||||
|
f 1 2 3
|
||||||
|
f 1 4 3
|
||||||
|
f 2 5 4
|
|
@ -286,6 +286,54 @@ TEST_F(utObjImportExport, issue1923_vertex_color_Test) {
|
||||||
delete scene;
|
delete scene;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(utObjImportExport, only_a_part_of_vertex_colors_Test) {
|
||||||
|
::Assimp::Importer importer;
|
||||||
|
const aiScene *const scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/OBJ/only_a_part_of_vertexcolors.obj", aiProcess_ValidateDataStructure);
|
||||||
|
EXPECT_NE(nullptr, scene);
|
||||||
|
|
||||||
|
EXPECT_EQ(scene->mNumMeshes, 1U);
|
||||||
|
const aiMesh *const mesh = scene->mMeshes[0];
|
||||||
|
EXPECT_EQ(mesh->mNumVertices, 9U);
|
||||||
|
EXPECT_EQ(mesh->mNumFaces, 3U);
|
||||||
|
EXPECT_TRUE(mesh->HasVertexColors(0));
|
||||||
|
|
||||||
|
const aiVector3D *const vertices = mesh->mVertices;
|
||||||
|
const aiColor4D *const colors = mesh->mColors[0];
|
||||||
|
EXPECT_EQ(aiVector3D(0.0f, 0.0f, 0.0f), vertices[0]);
|
||||||
|
EXPECT_EQ(aiColor4D(0.0f, 0.0f, 0.0f, 1.0f), colors[0]);
|
||||||
|
EXPECT_EQ(aiVector3D(0.0f, 0.0f, 1.0f), vertices[1]);
|
||||||
|
EXPECT_EQ(aiColor4D(0.0f, 0.0f, 1.0f, 1.0f), colors[1]);
|
||||||
|
EXPECT_EQ(aiVector3D(0.0f, 1.0f, 0.0f), vertices[2]);
|
||||||
|
EXPECT_EQ(aiColor4D(0.0f, 0.0f, 0.0f, 1.0f), colors[2]);
|
||||||
|
EXPECT_EQ(aiVector3D(0.0f, 0.0f, 0.0f), vertices[3]);
|
||||||
|
EXPECT_EQ(aiColor4D(0.0f, 0.0f, 0.0f, 1.0f), colors[3]);
|
||||||
|
EXPECT_EQ(aiVector3D(1.0f, 0.0f, 0.0f), vertices[4]);
|
||||||
|
EXPECT_EQ(aiColor4D(1.0f, 0.6f, 0.3f, 1.0f), colors[4]);
|
||||||
|
EXPECT_EQ(aiVector3D(0.0f, 1.0f, 0.0f), vertices[5]);
|
||||||
|
EXPECT_EQ(aiColor4D(0.0f, 0.0f, 0.0f, 1.0f), colors[5]);
|
||||||
|
EXPECT_EQ(aiVector3D(0.0f, 0.0f, 1.0f), vertices[6]);
|
||||||
|
EXPECT_EQ(aiColor4D(0.0f, 0.0f, 1.0f, 1.0f), colors[6]);
|
||||||
|
EXPECT_EQ(aiVector3D(1.0f, 1.0f, 0.0f), vertices[7]);
|
||||||
|
EXPECT_EQ(aiColor4D(0.0f, 0.0f, 0.0f, 1.0f), colors[7]);
|
||||||
|
EXPECT_EQ(aiVector3D(1.0f, 0.0f, 0.0f), vertices[8]);
|
||||||
|
EXPECT_EQ(aiColor4D(1.0f, 0.6f, 0.3f, 1.0f), colors[8]);
|
||||||
|
|
||||||
|
#ifndef ASSIMP_BUILD_NO_EXPORT
|
||||||
|
::Assimp::Exporter exporter;
|
||||||
|
EXPECT_EQ(aiReturn_SUCCESS, exporter.Export(scene, "obj", ASSIMP_TEST_MODELS_DIR "/OBJ/test_out.obj"));
|
||||||
|
#endif // ASSIMP_BUILD_NO_EXPORT
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(utObjImportExport, no_vertex_colors_Test) {
|
||||||
|
::Assimp::Importer importer;
|
||||||
|
const aiScene *const scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/OBJ/box.obj", aiProcess_ValidateDataStructure);
|
||||||
|
EXPECT_NE(nullptr, scene);
|
||||||
|
|
||||||
|
EXPECT_EQ(scene->mNumMeshes, 1U);
|
||||||
|
const aiMesh *const mesh = scene->mMeshes[0];
|
||||||
|
EXPECT_FALSE(mesh->HasVertexColors(0));
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(utObjImportExport, issue1453_segfault) {
|
TEST_F(utObjImportExport, issue1453_segfault) {
|
||||||
static const char *curObjModel =
|
static const char *curObjModel =
|
||||||
"v 0.0 0.0 0.0\n"
|
"v 0.0 0.0 0.0\n"
|
||||||
|
|
Loading…
Reference in New Issue