v0.40
This commit is contained in:
parent
1af4b85a22
commit
0433a6bc0a
12 changed files with 4843 additions and 4686 deletions
184
UnAlz.cpp
184
UnAlz.cpp
|
@ -87,6 +87,7 @@ static const char* errorstrtable[]=
|
|||
"no error", // ERR_NOERR
|
||||
"can't open file", // ERR_CANT_OPEN_FILE
|
||||
"corrupted file", // ERR_CORRUPTED_FILE
|
||||
"not alz file", // ERR_NOT_ALZ_FILE
|
||||
"can't read signature", // ERR_CANT_READ_SIG
|
||||
"can't read file", // ERR_CANT_READ_FILE
|
||||
"error at read header", // ERR_AT_READ_HEADER
|
||||
|
@ -100,6 +101,9 @@ static const char* errorstrtable[]=
|
|||
"memory allocation failed", // ERR_MEM_ALLOC_FAILED,
|
||||
"file read error", // ERR_FILE_READ_ERROR,
|
||||
"inflate failed", // ERR_INFLATE_FAILED,
|
||||
"bzip2 decompress failed", // ERR_BZIP2_FAILED,
|
||||
"invalid file CRC", // ERR_INVALID_FILE_CRC
|
||||
"unknown compression method", // ERR_UNKNOWN_COMPRESSION_METHOD
|
||||
|
||||
"iconv-can't open iconv", // ERR_ICONV_CANT_OPEN,
|
||||
"iconv-invalid multisequence of characters", // ERR_ICONV_INVALID_MULTISEQUENCE_OF_CHARACTERS,
|
||||
|
@ -107,9 +111,9 @@ static const char* errorstrtable[]=
|
|||
"iconv-not enough space of buffer to convert", // ERR_ICONV_NOT_ENOUGH_SPACE_OF_BUFFER_TO_CONVERT,
|
||||
"iconv-etc", // ERR_ICONV_ETC,
|
||||
|
||||
"password not set", //ERR_PASSWD_NOT_SET,
|
||||
"invalid password", //ERR_INVALID_PASSWD,
|
||||
"User Aborted",
|
||||
"password was not set", // ERR_PASSWD_NOT_SET,
|
||||
"invalid password", // ERR_INVALID_PASSWD,
|
||||
"user aborted",
|
||||
};
|
||||
|
||||
|
||||
|
@ -210,6 +214,8 @@ BOOL CUnAlz::Open(const char* szPathName)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL bValidAlzHeader = FALSE;
|
||||
|
||||
// file 분석시작..
|
||||
for(;;)
|
||||
{
|
||||
|
@ -225,11 +231,18 @@ BOOL CUnAlz::Open(const char* szPathName)
|
|||
}
|
||||
if(sig==SIG_ERROR)
|
||||
{
|
||||
m_nErr = ERR_CORRUPTED_FILE;
|
||||
if(bValidAlzHeader)
|
||||
m_nErr = ERR_CORRUPTED_FILE; // 손상된 파일
|
||||
else
|
||||
m_nErr = ERR_NOT_ALZ_FILE; // alz 파일이 아니다.
|
||||
return FALSE; // 깨진 파일..
|
||||
}
|
||||
|
||||
if(sig==SIG_ALZ_FILE_HEADER) ret = ReadAlzFileHeader();
|
||||
if(sig==SIG_ALZ_FILE_HEADER)
|
||||
{
|
||||
ret = ReadAlzFileHeader();
|
||||
bValidAlzHeader = TRUE; // alz 파일은 맞다.
|
||||
}
|
||||
else if(sig==SIG_LOCAL_FILE_HEADER) ret = ReadLocalFileheader();
|
||||
else if(sig==SIG_CENTRAL_DIRECTORY_STRUCTURE) ret = ReadCentralDirectoryStructure();
|
||||
else if(sig==SIG_ENDOF_CENTRAL_DIRECTORY_RECORD) ret = ReadEndofCentralDirectoryRecord();
|
||||
|
@ -340,9 +353,9 @@ BOOL CUnAlz::ReadLocalFileheader()
|
|||
if(byteLen)
|
||||
{
|
||||
FRead(&(zipHeader.compressionMethod), sizeof(zipHeader.compressionMethod));
|
||||
FRead(&(zipHeader.unknown3), sizeof(zipHeader.unknown3));
|
||||
FRead(&(zipHeader.unknown4), sizeof(zipHeader.unknown4));
|
||||
FRead(&(zipHeader.passwordCRC), sizeof(zipHeader.passwordCRC));
|
||||
FRead(&(zipHeader.unknown), sizeof(zipHeader.unknown));
|
||||
FRead(&(zipHeader.fileCRC), sizeof(zipHeader.fileCRC));
|
||||
// FRead(&(zipHeader.passwordCRC), sizeof(zipHeader.passwordCRC));
|
||||
|
||||
FRead(&(zipHeader.compressedSize), byteLen);
|
||||
FRead(&(zipHeader.uncompressedSize), byteLen); // 압축 사이즈가 없다.
|
||||
|
@ -354,7 +367,7 @@ BOOL CUnAlz::ReadLocalFileheader()
|
|||
zipHeader.uncompressedSize = unalz_le64toh(zipHeader.uncompressedSize);
|
||||
|
||||
// FILE NAME
|
||||
zipHeader.fileName = (char*)malloc(zipHeader.head.fileNameLength+1);
|
||||
zipHeader.fileName = (char*)malloc(zipHeader.head.fileNameLength+sizeof(char));
|
||||
if(zipHeader.fileName==NULL)
|
||||
{
|
||||
m_nErr = ERR_INVALID_FILENAME_LENGTH;
|
||||
|
@ -415,7 +428,14 @@ BOOL CUnAlz::ReadLocalFileheader()
|
|||
else
|
||||
{
|
||||
outbuf[ICONV_BUF_SIZE-oleft] = 0;
|
||||
strcpy(zipHeader.fileName, outbuf);
|
||||
if(zipHeader.fileName) free(zipHeader.fileName);
|
||||
zipHeader.fileName = strdup(outbuf);
|
||||
if (zipHeader.fileName == NULL)
|
||||
{
|
||||
m_nErr = ERR_ICONV_ETC;
|
||||
iconv_close(cd);
|
||||
return FALSE;
|
||||
}
|
||||
// printf("\n Converted File Name : %s", outbuf);
|
||||
}
|
||||
|
||||
|
@ -576,6 +596,11 @@ BOOL CUnAlz::SetCurrentFile(const char* szFileName)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
void CUnAlz::SetCurrentFile(FileList::iterator newPos)
|
||||
{
|
||||
m_posCur = newPos;
|
||||
}
|
||||
|
||||
#ifndef MAX_WBITS
|
||||
# define MAX_WBITS 15 /* 32K LZ77 window */
|
||||
#endif
|
||||
|
@ -692,9 +717,12 @@ BOOL CUnAlz::ExtractTo(SExtractDest* dest)
|
|||
{
|
||||
ret = ExtractDeflate2(dest, *m_posCur); // deflate
|
||||
}
|
||||
else
|
||||
else // COMP_UNKNOWN
|
||||
{
|
||||
ASSERT(0); // 새로운 방법 ???
|
||||
// alzip 5.6 부터 추가된 포맷(5.5 에서는 풀지 못한다. 영문 5.51 은 푼다 )
|
||||
// 하지만 어떤 버전에서 이 포맷을 만들어 내는지 정확히 알 수 없다.
|
||||
m_nErr = ERR_UNKNOWN_COMPRESSION_METHOD;
|
||||
ASSERT(0);
|
||||
ret = FALSE;
|
||||
}
|
||||
return ret;
|
||||
|
@ -887,6 +915,7 @@ int CUnAlz::WriteToDest(SExtractDest* dest, BYTE* buf, int nSize)
|
|||
}
|
||||
else if(dest->nType==ET_MEM)
|
||||
{
|
||||
if(dest->buf==NULL) return nSize; // 대상이 NULL 이다... 압축푸는 시늉만 한다..
|
||||
if(dest->bufpos+nSize >dest->bufsize) // 에러.. 버퍼가 넘쳤다.
|
||||
{
|
||||
ASSERT(0);
|
||||
|
@ -1006,14 +1035,15 @@ END :
|
|||
#define BUF_LEN (4096*2)
|
||||
BOOL CUnAlz::ExtractRawfile(SExtractDest* dest, SLocalFileHeader& file)
|
||||
{
|
||||
BOOL ret = FALSE;
|
||||
BYTE buf[BUF_LEN];
|
||||
INT64 read;
|
||||
INT64 sizeToRead;
|
||||
INT64 bufLen = BUF_LEN;
|
||||
INT64 nWritten = 0;
|
||||
BOOL bHalt = FALSE;
|
||||
BOOL bIsEncrypted = IsEncryptedFile(); // 암호걸린 파일인가?
|
||||
BOOL ret = FALSE;
|
||||
BYTE buf[BUF_LEN];
|
||||
INT64 read;
|
||||
INT64 sizeToRead;
|
||||
INT64 bufLen = BUF_LEN;
|
||||
INT64 nWritten = 0;
|
||||
BOOL bHalt = FALSE;
|
||||
BOOL bIsEncrypted = IsEncryptedFile(); // 암호걸린 파일인가?
|
||||
UINT32 dwCRC32= 0;
|
||||
|
||||
|
||||
|
||||
|
@ -1022,6 +1052,7 @@ BOOL CUnAlz::ExtractRawfile(SExtractDest* dest, SLocalFileHeader& file)
|
|||
|
||||
sizeToRead = file.compressedSize; // 읽을 크기.
|
||||
|
||||
m_nErr = ERR_NOERR;
|
||||
while(sizeToRead)
|
||||
{
|
||||
read = min(sizeToRead, bufLen);
|
||||
|
@ -1033,6 +1064,8 @@ BOOL CUnAlz::ExtractRawfile(SExtractDest* dest, SLocalFileHeader& file)
|
|||
if(bIsEncrypted)
|
||||
DecryptingData((int)read, buf); // xf86
|
||||
|
||||
dwCRC32 = crc32(dwCRC32, buf, (UINT)(read));
|
||||
|
||||
WriteToDest(dest, buf, (int)read);
|
||||
//fwrite(buf, read, 1, fp);
|
||||
sizeToRead -= read;
|
||||
|
@ -1051,7 +1084,20 @@ BOOL CUnAlz::ExtractRawfile(SExtractDest* dest, SLocalFileHeader& file)
|
|||
}
|
||||
|
||||
m_bHalt = bHalt;
|
||||
ret = TRUE;
|
||||
|
||||
if(m_nErr==ERR_NOERR) // 성공적으로 압축을 풀었다.. CRC 검사하기..
|
||||
{
|
||||
if(file.fileCRC==dwCRC32)
|
||||
{
|
||||
ret = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_nErr = ERR_INVALID_FILE_CRC;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -1065,14 +1111,16 @@ BOOL CUnAlz::ExtractRawfile(SExtractDest* dest, SLocalFileHeader& file)
|
|||
#define BZIP2_EXTRACT_BUF_SIZE 0x2000
|
||||
BOOL CUnAlz::ExtractBzip2(SExtractDest* dest, SLocalFileHeader& file)
|
||||
{
|
||||
BZFILE *bzfp = NULL;
|
||||
int smallMode = 0;
|
||||
int verbosity = 1;
|
||||
int bzerr;
|
||||
INT64 len;
|
||||
char buff[BZIP2_EXTRACT_BUF_SIZE];
|
||||
INT64 nWritten = 0;
|
||||
BOOL bHalt = FALSE;
|
||||
BZFILE *bzfp = NULL;
|
||||
int smallMode = 0;
|
||||
int verbosity = 1;
|
||||
int bzerr;
|
||||
INT64 len;
|
||||
BYTE buff[BZIP2_EXTRACT_BUF_SIZE];
|
||||
INT64 nWritten = 0;
|
||||
BOOL bHalt = FALSE;
|
||||
UINT32 dwCRC32= 0;
|
||||
BOOL ret = FALSE;
|
||||
|
||||
FSeek(file.dwFileDataPos);
|
||||
|
||||
|
@ -1080,11 +1128,15 @@ BOOL CUnAlz::ExtractBzip2(SExtractDest* dest, SLocalFileHeader& file)
|
|||
|
||||
if(bzfp==NULL){ASSERT(0); return FALSE;}
|
||||
|
||||
m_nErr = ERR_NOERR;
|
||||
while((len=BZ2_bzread(bzfp,buff,BZIP2_EXTRACT_BUF_SIZE))>0)
|
||||
{
|
||||
WriteToDest(dest, (BYTE*)buff, (int)len);
|
||||
//fwrite(buff,1,len,fp_w);
|
||||
|
||||
dwCRC32 = crc32(dwCRC32,buff, (UINT)(len));
|
||||
|
||||
|
||||
nWritten+=len;
|
||||
|
||||
// progress callback
|
||||
|
@ -1098,10 +1150,28 @@ BOOL CUnAlz::ExtractBzip2(SExtractDest* dest, SLocalFileHeader& file)
|
|||
}
|
||||
}
|
||||
|
||||
if(len<0) // 에러 상황..
|
||||
{
|
||||
m_nErr = ERR_INFLATE_FAILED;
|
||||
}
|
||||
|
||||
BZ2_bzReadClose( &bzerr, bzfp);
|
||||
|
||||
m_bHalt = bHalt;
|
||||
|
||||
if(m_nErr==ERR_NOERR) // 성공적으로 압축을 풀었다.. CRC 검사하기..
|
||||
{
|
||||
if(file.fileCRC==dwCRC32)
|
||||
{
|
||||
ret = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_nErr = ERR_INVALID_FILE_CRC;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
// FILE* 를 사용할경우 사용하던 코드. - 멀티 볼륨 지원 안함..
|
||||
BZFILE *bzfp = NULL;
|
||||
|
@ -1140,7 +1210,7 @@ BOOL CUnAlz::ExtractBzip2(SExtractDest* dest, SLocalFileHeader& file)
|
|||
m_bHalt = bHalt;
|
||||
*/
|
||||
|
||||
return TRUE;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1188,6 +1258,7 @@ BOOL CUnAlz::ExtractDeflate2(SExtractDest* dest, SLocalFileHeader& file)
|
|||
stream.next_out = pOutBuf;
|
||||
stream.avail_out = OUT_BUF_SIZE;
|
||||
|
||||
m_nErr = ERR_NOERR;
|
||||
while(stream.avail_out>0)
|
||||
{
|
||||
if(stream.avail_in==0 && nRestReadCompressed>0)
|
||||
|
@ -1208,6 +1279,8 @@ BOOL CUnAlz::ExtractDeflate2(SExtractDest* dest, SLocalFileHeader& file)
|
|||
if(bIsEncrypted)
|
||||
DecryptingData(uReadThis, pInBuf); // xf86
|
||||
|
||||
// dwCRC32 = crc32(dwCRC32,pInBuf, (UINT)(uReadThis));
|
||||
|
||||
nRestReadCompressed -= uReadThis;
|
||||
stream.next_in = pInBuf;
|
||||
stream.avail_in = uReadThis;
|
||||
|
@ -1245,6 +1318,7 @@ BOOL CUnAlz::ExtractDeflate2(SExtractDest* dest, SLocalFileHeader& file)
|
|||
m_pFuncCallBack(NULL, nWritten, file.uncompressedSize, m_pCallbackParam, &bHalt);
|
||||
if(bHalt)
|
||||
{
|
||||
m_nErr = ERR_USER_ABORTED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1258,10 +1332,21 @@ BOOL CUnAlz::ExtractDeflate2(SExtractDest* dest, SLocalFileHeader& file)
|
|||
goto END;
|
||||
}
|
||||
}
|
||||
|
||||
m_bHalt = bHalt;
|
||||
|
||||
ret = TRUE;
|
||||
|
||||
if(m_nErr==ERR_NOERR) // 성공적으로 압축을 풀었다.. CRC 검사하기..
|
||||
{
|
||||
if(file.fileCRC==dwCRC32)
|
||||
{
|
||||
ret = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_nErr = ERR_INVALID_FILE_CRC;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
END :
|
||||
inflateEnd(&stream);
|
||||
|
@ -1497,17 +1582,16 @@ const char* CUnAlz::LastErrToStr(ERR nERR)
|
|||
// by xf86
|
||||
BOOL CUnAlz::chkValidPassword()
|
||||
{
|
||||
if(IsEncryptedFile())
|
||||
{
|
||||
if (getPasswordLen() == 0){
|
||||
m_nErr = ERR_PASSWD_NOT_SET;
|
||||
return FALSE;
|
||||
}
|
||||
InitCryptKeys(m_szPasswd);
|
||||
if(CryptCheck(m_posCur->encChk) == FALSE){
|
||||
m_nErr = ERR_INVALID_PASSWD;
|
||||
return FALSE;
|
||||
}
|
||||
if(IsEncryptedFile()==FALSE) {return TRUE;}
|
||||
|
||||
if (getPasswordLen() == 0){
|
||||
m_nErr = ERR_PASSWD_NOT_SET;
|
||||
return FALSE;
|
||||
}
|
||||
InitCryptKeys(m_szPasswd);
|
||||
if(CryptCheck(m_posCur->encChk) == FALSE){
|
||||
m_nErr = ERR_INVALID_PASSWD;
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -1638,21 +1722,25 @@ void CUnAlz::UpdateKeys(BYTE c)
|
|||
/// @return
|
||||
/// @date 2004-11-27 오후 11:04:24
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
BOOL CUnAlz::CryptCheck(BYTE* buf)
|
||||
BOOL CUnAlz::CryptCheck(const BYTE* buf)
|
||||
{
|
||||
int i;
|
||||
BYTE c;
|
||||
BYTE temp[ENCR_HEADER_LEN];
|
||||
|
||||
memcpy(temp, buf, ENCR_HEADER_LEN); // 임시 복사.
|
||||
|
||||
for(i=0;i<ENCR_HEADER_LEN;i++)
|
||||
{
|
||||
c = buf[i] ^ DecryptByte();
|
||||
c = temp[i] ^ DecryptByte();
|
||||
UpdateKeys(c);
|
||||
buf[i] = c;
|
||||
temp[i] = c;
|
||||
}
|
||||
|
||||
if (IsDataDescr()) // Data descriptor present
|
||||
return (m_posCur->head.fileTimeDate >> 8) == c;
|
||||
else
|
||||
return (m_posCur->passwordCRC) == c;
|
||||
return ( ((m_posCur->fileCRC)>>24) ) == c; // 파일 crc 의 최상위 byte
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -1701,3 +1789,5 @@ UINT32 CUnAlz::CRC32(UINT32 l, BYTE c)
|
|||
const ULONG *CRC_TABLE = get_crc_table();
|
||||
return CRC_TABLE[(l ^ c) & 0xff] ^ (l >> 8);
|
||||
}
|
||||
|
||||
|
||||
|
|
76
UnAlz.h
76
UnAlz.h
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
|
||||
COPYRIGHT(C) 2004 hardkoder@gmail.com / http://www.kipple.pe.kr
|
||||
COPYRIGHT(C) 2004-2005 hardkoder , http://www.kipple.pe.kr
|
||||
|
||||
저작권 정보 : ( BSD License )
|
||||
- 이 소스는 자유로이 사용/수정/재배포 가능합니다.
|
||||
|
@ -33,26 +33,39 @@
|
|||
- 2GB 이상의 파일 처리 지원 (WINDOWS ONLY)
|
||||
2004/10/22 - 다중 플랫폼(BSD/LINUX)지원을 위한 수정
|
||||
( BSD/LINUX 의 경우 2GB 이하의 파일만 지원 )
|
||||
- unalz 0.20
|
||||
2004/10/23 - by xxfree86 : DARWIN 컴파일 지원, 경로명에 "\\" 포함시 문제점 수정
|
||||
2004/10/24 - by aqua0125 : 코드페이지 변환처리, 64bit 파일 처리
|
||||
- 빅엔디안, 코드페이지 변환 관련 소스 정리
|
||||
2004/10/25 - by yongari : __LP64__ , 빅엔디안(le64toh/le132oh/le16toh) 관련 이슈 수정
|
||||
2004/10/26 - BSD/LINUX : byte-order, libiconv 이슈 정리
|
||||
- unalz 0.22
|
||||
2004/10/30 - 정리 & 정리..
|
||||
- unalz 0.23
|
||||
2004/11/14 - by xxfre86 : 암호 걸린 파일 처리 추가
|
||||
- unalz 0.30
|
||||
2004/11/27 - cygwin에서 컴파일 되도록 수정
|
||||
- 암호처리 부분에 일부 사용된 GPL 의 CZipArchive 코드를 "ZIP File Format Specification version 4.5" 문서를 참고해서 다시 코딩 & 정리
|
||||
- 암호걸린 파일과 안걸린 파일 섞였을때 처리
|
||||
- 파일의 뒷부분이 잘려서 손상된 파일도 멀쩡한 부분까지는 압축을 풀도록 수정
|
||||
- unalz 0.31
|
||||
2005/01/08 - 암호 잘못 입력시 한번 체크후 두번째는 정상 암호를 입력해서 풀지 못하게 되던 버그 수정
|
||||
2005/02/05 - 압축 해제후 deflate 의 파일 CRC 확인 기능 추가
|
||||
2005/03/07 - bzip2, raw 파일에 대한 파일 CRC 확인 기능 추가
|
||||
2005/03/13 - ALZ 파일이 아닐경우 에러 코드(ERR_NOT_ALZ_FILE) 추가
|
||||
2005/06/16 - GetFileList() 함수 버그 수정(리턴타입 변경)
|
||||
2005/06/18 - by goweol : utf-8 사용시 파일이름에서 버퍼 오버플로우 발생하던 버그 수정
|
||||
- unalz 0.4
|
||||
|
||||
|
||||
할일 : ( * 표는 한거 )
|
||||
- bzip2 로 압축된 파일의 압축 해제 *
|
||||
- UI 개선 ( PROGRESS, 에러 메시지 출력, 압축 해제 결과 ) *
|
||||
- 분할 압축 파일 지원 *
|
||||
- 암호 걸린 파일 지원 *
|
||||
- 손상된 파일에서의 좀더 많은 테스트 ->
|
||||
- 파일 CRC 체크 -> alz 는 CRC 필드가 없다. OTL
|
||||
기능 :
|
||||
- alz 파일의 압축 해제 ( deflate/변형 bzip2/raw )
|
||||
- 분할 압축 파일 지원 (alz, a00, a01.. )
|
||||
- 다양한 플래폼 지원 (Win32/POSIX(BSD/LINUX/DARWIN))
|
||||
- 암호걸린 파일의 압축 해제
|
||||
- 뒷부분이 잘린 파일도 멀쩡한 부분까지 압축 해제 가능
|
||||
- CRC 체크기능
|
||||
|
||||
|
||||
컴파일 옵션 ( -DXXXX )
|
||||
- _WIN32 : WIN32
|
||||
|
@ -149,8 +162,8 @@ namespace UNALZ
|
|||
# pragma pack(1)
|
||||
#endif
|
||||
|
||||
static const char UNALZ_VERSION[] = "CUnAlz0.31";
|
||||
static const char UNALZ_COPYRIGHT[] = "Copyright(C) 2004 hardkoder@gmail.com";
|
||||
static const char UNALZ_VERSION[] = "CUnAlz0.4";
|
||||
static const char UNALZ_COPYRIGHT[] = "Copyright(C) 2004-2005 by hardkoder ( http://www.kipple.pe.kr ) ";
|
||||
|
||||
enum {ENCR_HEADER_LEN=12}; // xf86
|
||||
// 맨 파일 앞..
|
||||
|
@ -180,12 +193,20 @@ enum COMPRESSION_METHOD ///<
|
|||
COMP_NOCOMP = 0,
|
||||
COMP_BZIP2 = 1,
|
||||
COMP_DEFLATE = 2,
|
||||
COMP_UNKNOWN = 3, // unknown!
|
||||
};
|
||||
|
||||
enum FILE_ATTRIBUTE
|
||||
{
|
||||
FILEATTR_FILE = 0x1,
|
||||
FILEATTR_FOLDER = 0x10,
|
||||
FILEATTR_FILE2 = 0x20, /// FILEATTR_FILE 과 FILEATTR_FILE2 의 차이는 모르겠다..
|
||||
};
|
||||
|
||||
struct _SLocalFileHeaderHead ///< 고정 헤더.
|
||||
{
|
||||
SHORT fileNameLength;
|
||||
BYTE fileAttribute; // from http://www.zap.pe.kr
|
||||
BYTE fileAttribute; // from http://www.zap.pe.kr, FILE_ATTRIBUE 참고
|
||||
UINT32 fileTimeDate;
|
||||
|
||||
BYTE fileDescriptor; ///< 파일 크기 필드의 크기 : 0x10, 0x20, 0x40, 0x80 각각 1byte, 2byte, 4byte, 8byte.
|
||||
|
@ -206,12 +227,14 @@ struct _SLocalFileHeaderHead ///<
|
|||
*/
|
||||
};
|
||||
|
||||
/*
|
||||
struct _SDataDescriptor
|
||||
{
|
||||
UINT32 crc32;
|
||||
UINT32 compressed;
|
||||
UINT32 uncompressed;
|
||||
};
|
||||
*/
|
||||
|
||||
struct SLocalFileHeader
|
||||
{
|
||||
|
@ -221,16 +244,16 @@ struct SLocalFileHeader
|
|||
_SLocalFileHeaderHead head;
|
||||
|
||||
BYTE compressionMethod; ///< 압축 방법 : 2 - deflate, 1 - 변형 bzip2, 0 - 압축 안함.
|
||||
BYTE unknown3[1]; ///< ???
|
||||
BYTE unknown4[3]; ///< 아마도 crc?
|
||||
BYTE passwordCRC; ///< 암호 체크를 위한 1byte crc
|
||||
BYTE unknown;
|
||||
UINT32 fileCRC; ///< 파일의 CRC, 최상위 바이트는 암호 체크용으로도 사용된다.
|
||||
//BYTE passwordCRC; ///< 암호 체크를 위한 1byte crc
|
||||
|
||||
INT64 compressedSize;
|
||||
INT64 uncompressedSize;
|
||||
|
||||
CHAR* fileName;
|
||||
BYTE* extraField;
|
||||
_SDataDescriptor dataDescriptor;
|
||||
// _SDataDescriptor dataDescriptor;
|
||||
INT64 dwFileDataPos; ///< file data 가 저장된 위치..
|
||||
|
||||
BYTE encChk[ENCR_HEADER_LEN]; // xf86
|
||||
|
@ -321,11 +344,12 @@ public:
|
|||
void Close();
|
||||
BOOL SetCurrentFile(const char* szFileName);
|
||||
BOOL ExtractCurrentFile(const char* szDestPathName, const char* szDestFileName=NULL);
|
||||
BOOL ExtractCurrentFileToBuf(BYTE* pDestBuf, int nBufSize);
|
||||
BOOL ExtractCurrentFileToBuf(BYTE* pDestBuf, int nBufSize); // pDestBuf=NULL 일 경우 테스트만 수행한다.
|
||||
BOOL ExtractAll(const char* szDestPathName);
|
||||
void SetCallback(_UnAlzCallback* pFunc, void* param=NULL);
|
||||
|
||||
void setPassword(char *passwd) { if(strlen(passwd) == 0) return; strcpy(m_szPasswd, passwd); }; // xf86
|
||||
BOOL chkValidPassword(); // xf86
|
||||
BOOL IsEncrypted() { return m_bIsEncrypted; };
|
||||
|
||||
#ifdef _UNALZ_ICONV
|
||||
|
@ -346,10 +370,10 @@ public : ///< WIN32
|
|||
#endif // _WIN32
|
||||
|
||||
public :
|
||||
typedef vector<SLocalFileHeader> FileList; ///< 파일 목록.
|
||||
const FileList& GetFileList() { return m_fileList; }; ///< file 목록 리턴
|
||||
FileList::iterator GetCurFileHeader() { return m_posCur; }; ///< 현재 (SetCurrentFile() 로 세팅된) 파일 정보
|
||||
// const SLocalFileHeader* GetCurFileHeader() { return m_posCur; }; ///< 현재 (SetCurrentFile() 로 세팅된) 파일 정보
|
||||
typedef vector<SLocalFileHeader> FileList; ///< 파일 목록.
|
||||
FileList* GetFileList() { return &m_fileList; }; ///< file 목록 리턴
|
||||
void SetCurrentFile(FileList::iterator newPos); ///< low level 접근..
|
||||
FileList::iterator GetCurFileHeader() { return m_posCur; }; ///< 현재 (SetCurrentFile() 로 세팅된) 파일 정보
|
||||
|
||||
public :
|
||||
enum ERR ///< 에러 코드 - 정리 필요..
|
||||
|
@ -357,6 +381,7 @@ public :
|
|||
ERR_NOERR,
|
||||
ERR_CANT_OPEN_FILE, ///< 파일 열기 실패
|
||||
ERR_CORRUPTED_FILE, ///< 깨진 파일?
|
||||
ERR_NOT_ALZ_FILE, ///< ALZ 파일이 아니다.
|
||||
ERR_CANT_READ_SIG, ///< signature 읽기 실패
|
||||
ERR_CANT_READ_FILE,
|
||||
|
||||
|
@ -371,6 +396,9 @@ public :
|
|||
ERR_MEM_ALLOC_FAILED,
|
||||
ERR_FILE_READ_ERROR,
|
||||
ERR_INFLATE_FAILED,
|
||||
ERR_BZIP2_FAILED,
|
||||
ERR_INVALID_FILE_CRC,
|
||||
ERR_UNKNOWN_COMPRESSION_METHOD,
|
||||
|
||||
ERR_ICONV_CANT_OPEN,
|
||||
ERR_ICONV_INVALID_MULTISEQUENCE_OF_CHARACTERS,
|
||||
|
@ -474,11 +502,10 @@ private : //
|
|||
|
||||
BOOL m_bIsEncrypted; // xf86
|
||||
BOOL m_bIsDataDescr;
|
||||
char m_szPasswd[256];
|
||||
UINT32 m_keys[3];
|
||||
char m_szPasswd[512];
|
||||
|
||||
private :
|
||||
/*
|
||||
/* from CZipArchive
|
||||
void CryptDecodeBuffer(UINT32 uCount, CHAR *buf);
|
||||
void CryptInitKeys();
|
||||
void CryptUpdateKeys(CHAR c);
|
||||
|
@ -489,12 +516,11 @@ private :
|
|||
*/
|
||||
|
||||
private : // encryption 처리
|
||||
BOOL chkValidPassword(); // xf86
|
||||
BOOL IsEncryptedFile(BYTE fileDescriptor);
|
||||
BOOL IsEncryptedFile();
|
||||
void InitCryptKeys(const CHAR* szPassword);
|
||||
void UpdateKeys(BYTE c);
|
||||
BOOL CryptCheck(BYTE* buf);
|
||||
BOOL CryptCheck(const BYTE* buf);
|
||||
BYTE DecryptByte();
|
||||
void DecryptingData(int nSize, BYTE* data);
|
||||
UINT32 CRC32(UINT32 l, BYTE c);
|
||||
|
|
5
main.cpp
5
main.cpp
|
@ -71,8 +71,9 @@ int main(int argc, char* argv[])
|
|||
// printf("unalz v0.20 (2004/10/22) \n");
|
||||
// printf("unalz v0.22 (2004/10/27) \n");
|
||||
// printf("unalz v0.23 (2004/10/30) \n");
|
||||
printf("unalz v0.31 (2004/11/27) \n");
|
||||
printf("Copyright(C) 2004 koder (http://www.kipple.pe.kr) \n");
|
||||
// printf("unalz v0.31 (2004/11/27) \n");
|
||||
printf("unalz v0.4 (2005/06/18) \n");
|
||||
printf("Copyright(C) 2004-2005 by hardkoder (http://www.kipple.pe.kr) \n");
|
||||
|
||||
if(argc<2)
|
||||
{
|
||||
|
|
|
@ -179,10 +179,6 @@ SOURCE=.\zlib\zconf.h
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zlib\zconf.in.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zlib\zlib.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
|
74
zlib/crc32.c
74
zlib/crc32.c
|
@ -11,6 +11,14 @@
|
|||
|
||||
/* @(#) $Id$ */
|
||||
|
||||
/*
|
||||
Note on the use of DYNAMIC_CRC_TABLE: there is no mutex or semaphore
|
||||
protection on the static variables used to control the first-use generation
|
||||
of the crc tables. Therefore, if you #define DYNAMIC_CRC_TABLE, you should
|
||||
first call get_crc_table() to initialize the tables before allowing more than
|
||||
one thread to use crc32().
|
||||
*/
|
||||
|
||||
#ifdef MAKECRCH
|
||||
# include <stdio.h>
|
||||
# ifndef DYNAMIC_CRC_TABLE
|
||||
|
@ -58,7 +66,7 @@
|
|||
|
||||
#ifdef DYNAMIC_CRC_TABLE
|
||||
|
||||
local int crc_table_empty = 1;
|
||||
local volatile int crc_table_empty = 1;
|
||||
local unsigned long FAR crc_table[TBLS][256];
|
||||
local void make_crc_table OF((void));
|
||||
#ifdef MAKECRCH
|
||||
|
@ -95,38 +103,51 @@ local void make_crc_table()
|
|||
{
|
||||
unsigned long c;
|
||||
int n, k;
|
||||
unsigned long poly; /* polynomial exclusive-or pattern */
|
||||
unsigned long poly; /* polynomial exclusive-or pattern */
|
||||
/* terms of polynomial defining this crc (except x^32): */
|
||||
static volatile int first = 1; /* flag to limit concurrent making */
|
||||
static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};
|
||||
|
||||
/* make exclusive-or pattern from polynomial (0xedb88320UL) */
|
||||
poly = 0UL;
|
||||
for (n = 0; n < sizeof(p)/sizeof(unsigned char); n++)
|
||||
poly |= 1UL << (31 - p[n]);
|
||||
/* See if another task is already doing this (not thread-safe, but better
|
||||
than nothing -- significantly reduces duration of vulnerability in
|
||||
case the advice about DYNAMIC_CRC_TABLE is ignored) */
|
||||
if (first) {
|
||||
first = 0;
|
||||
|
||||
/* generate a crc for every 8-bit value */
|
||||
for (n = 0; n < 256; n++) {
|
||||
c = (unsigned long)n;
|
||||
for (k = 0; k < 8; k++)
|
||||
c = c & 1 ? poly ^ (c >> 1) : c >> 1;
|
||||
crc_table[0][n] = c;
|
||||
}
|
||||
/* make exclusive-or pattern from polynomial (0xedb88320UL) */
|
||||
poly = 0UL;
|
||||
for (n = 0; n < sizeof(p)/sizeof(unsigned char); n++)
|
||||
poly |= 1UL << (31 - p[n]);
|
||||
|
||||
/* generate a crc for every 8-bit value */
|
||||
for (n = 0; n < 256; n++) {
|
||||
c = (unsigned long)n;
|
||||
for (k = 0; k < 8; k++)
|
||||
c = c & 1 ? poly ^ (c >> 1) : c >> 1;
|
||||
crc_table[0][n] = c;
|
||||
}
|
||||
|
||||
#ifdef BYFOUR
|
||||
/* generate crc for each value followed by one, two, and three zeros, and
|
||||
then the byte reversal of those as well as the first table */
|
||||
for (n = 0; n < 256; n++) {
|
||||
c = crc_table[0][n];
|
||||
crc_table[4][n] = REV(c);
|
||||
for (k = 1; k < 4; k++) {
|
||||
c = crc_table[0][c & 0xff] ^ (c >> 8);
|
||||
crc_table[k][n] = c;
|
||||
crc_table[k + 4][n] = REV(c);
|
||||
/* generate crc for each value followed by one, two, and three zeros,
|
||||
and then the byte reversal of those as well as the first table */
|
||||
for (n = 0; n < 256; n++) {
|
||||
c = crc_table[0][n];
|
||||
crc_table[4][n] = REV(c);
|
||||
for (k = 1; k < 4; k++) {
|
||||
c = crc_table[0][c & 0xff] ^ (c >> 8);
|
||||
crc_table[k][n] = c;
|
||||
crc_table[k + 4][n] = REV(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* BYFOUR */
|
||||
|
||||
crc_table_empty = 0;
|
||||
crc_table_empty = 0;
|
||||
}
|
||||
else { /* not first */
|
||||
/* wait for the other guy to finish (not efficient, but rare) */
|
||||
while (crc_table_empty)
|
||||
;
|
||||
}
|
||||
|
||||
#ifdef MAKECRCH
|
||||
/* write out CRC tables to crc32.h */
|
||||
|
@ -180,9 +201,10 @@ local void write_table(out, table)
|
|||
const unsigned long FAR * ZEXPORT get_crc_table()
|
||||
{
|
||||
#ifdef DYNAMIC_CRC_TABLE
|
||||
if (crc_table_empty) make_crc_table();
|
||||
if (crc_table_empty)
|
||||
make_crc_table();
|
||||
#endif /* DYNAMIC_CRC_TABLE */
|
||||
return (const unsigned long FAR *)crc_table;
|
||||
return (const unsigned long FAR *)crc_table;
|
||||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
|
|
|
@ -434,6 +434,9 @@ void FAR *out_desc;
|
|||
}
|
||||
}
|
||||
|
||||
/* handle error breaks in while */
|
||||
if (state->mode == BAD) break;
|
||||
|
||||
/* build code tables */
|
||||
state->next = state->codes;
|
||||
state->lencode = (code const FAR *)(state->next);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* inffast.c -- fast decoding
|
||||
* Copyright (C) 1995-2003 Mark Adler
|
||||
* Copyright (C) 1995-2004 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
|||
- none
|
||||
No measurable difference:
|
||||
- Pentium III (Anderson)
|
||||
- 68060 (Nikl)
|
||||
- M68060 (Nikl)
|
||||
*/
|
||||
#ifdef POSTINC
|
||||
# define OFF 0
|
||||
|
|
|
@ -109,6 +109,7 @@ z_streamp strm;
|
|||
state = (struct inflate_state FAR *)strm->state;
|
||||
strm->total_in = strm->total_out = state->total = 0;
|
||||
strm->msg = Z_NULL;
|
||||
strm->adler = 1; /* to support ill-conceived Java test suite */
|
||||
state->mode = HEAD;
|
||||
state->last = 0;
|
||||
state->havedict = 0;
|
||||
|
@ -861,6 +862,9 @@ int flush;
|
|||
}
|
||||
}
|
||||
|
||||
/* handle error breaks in while */
|
||||
if (state->mode == BAD) break;
|
||||
|
||||
/* build code tables */
|
||||
state->next = state->codes;
|
||||
state->lencode = (code const FAR *)(state->next);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* inftrees.c -- generate Huffman trees for efficient decoding
|
||||
* Copyright (C) 1995-2003 Mark Adler
|
||||
* Copyright (C) 1995-2004 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
|||
#define MAXBITS 15
|
||||
|
||||
const char inflate_copyright[] =
|
||||
" inflate 1.2.1 Copyright 1995-2003 Mark Adler ";
|
||||
" inflate 1.2.2 Copyright 1995-2004 Mark Adler ";
|
||||
/*
|
||||
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
|
||||
|
@ -62,7 +62,7 @@ unsigned short FAR *work;
|
|||
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 */
|
||||
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, 76, 66};
|
||||
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 199, 198};
|
||||
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,
|
||||
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
|
||||
|
@ -114,7 +114,15 @@ unsigned short FAR *work;
|
|||
for (max = MAXBITS; max >= 1; max--)
|
||||
if (count[max] != 0) break;
|
||||
if (root > max) root = max;
|
||||
if (max == 0) return -1; /* no codes! */
|
||||
if (max == 0) { /* no symbols to code at all */
|
||||
this.op = (unsigned char)64; /* invalid code marker */
|
||||
this.bits = (unsigned char)1;
|
||||
this.val = (unsigned short)0;
|
||||
*(*table)++ = this; /* make a table to force an error */
|
||||
*(*table)++ = this;
|
||||
*bits = 1;
|
||||
return 0; /* no symbols, but wait for decoding to report error */
|
||||
}
|
||||
for (min = 1; min <= MAXBITS; min++)
|
||||
if (count[min] != 0) break;
|
||||
if (root < min) root = min;
|
||||
|
@ -295,7 +303,6 @@ unsigned short FAR *work;
|
|||
drop = 0;
|
||||
len = root;
|
||||
next = *table;
|
||||
curr = root;
|
||||
this.bits = (unsigned char)len;
|
||||
}
|
||||
|
||||
|
|
83
zlib/zconf.h
83
zlib/zconf.h
|
@ -1,5 +1,5 @@
|
|||
/* zconf.h -- configuration of the zlib compression library
|
||||
* Copyright (C) 1995-2003 Jean-loup Gailly.
|
||||
* Copyright (C) 1995-2004 Jean-loup Gailly.
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
|
@ -13,43 +13,46 @@
|
|||
* compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
|
||||
*/
|
||||
#ifdef Z_PREFIX
|
||||
# define deflateInit_ z_deflateInit_
|
||||
# define deflate z_deflate
|
||||
# define deflateEnd z_deflateEnd
|
||||
# define inflateInit_ z_inflateInit_
|
||||
# define inflate z_inflate
|
||||
# define inflateEnd z_inflateEnd
|
||||
# define deflateInit2_ z_deflateInit2_
|
||||
# define deflateSetDictionary z_deflateSetDictionary
|
||||
# define deflateCopy z_deflateCopy
|
||||
# define deflateReset z_deflateReset
|
||||
# define deflatePrime z_deflatePrime
|
||||
# define deflateParams z_deflateParams
|
||||
# define deflateBound z_deflateBound
|
||||
# define inflateInit2_ z_inflateInit2_
|
||||
# define inflateSetDictionary z_inflateSetDictionary
|
||||
# define inflateSync z_inflateSync
|
||||
# define inflateSyncPoint z_inflateSyncPoint
|
||||
# define inflateCopy z_inflateCopy
|
||||
# define inflateReset z_inflateReset
|
||||
# define compress z_compress
|
||||
# define compress2 z_compress2
|
||||
# define compressBound z_compressBound
|
||||
# define uncompress z_uncompress
|
||||
# define adler32 z_adler32
|
||||
# define crc32 z_crc32
|
||||
# define get_crc_table z_get_crc_table
|
||||
# define deflateInit_ z_deflateInit_
|
||||
# define deflate z_deflate
|
||||
# define deflateEnd z_deflateEnd
|
||||
# define inflateInit_ z_inflateInit_
|
||||
# define inflate z_inflate
|
||||
# define inflateEnd z_inflateEnd
|
||||
# define deflateInit2_ z_deflateInit2_
|
||||
# define deflateSetDictionary z_deflateSetDictionary
|
||||
# define deflateCopy z_deflateCopy
|
||||
# define deflateReset z_deflateReset
|
||||
# define deflateParams z_deflateParams
|
||||
# define deflateBound z_deflateBound
|
||||
# define deflatePrime z_deflatePrime
|
||||
# define inflateInit2_ z_inflateInit2_
|
||||
# define inflateSetDictionary z_inflateSetDictionary
|
||||
# define inflateSync z_inflateSync
|
||||
# define inflateSyncPoint z_inflateSyncPoint
|
||||
# define inflateCopy z_inflateCopy
|
||||
# define inflateReset z_inflateReset
|
||||
# define inflateBack z_inflateBack
|
||||
# define inflateBackEnd z_inflateBackEnd
|
||||
# define compress z_compress
|
||||
# define compress2 z_compress2
|
||||
# define compressBound z_compressBound
|
||||
# define uncompress z_uncompress
|
||||
# define adler32 z_adler32
|
||||
# define crc32 z_crc32
|
||||
# define get_crc_table z_get_crc_table
|
||||
# define zError z_zError
|
||||
|
||||
# define Byte z_Byte
|
||||
# define uInt z_uInt
|
||||
# define uLong z_uLong
|
||||
# define Bytef z_Bytef
|
||||
# define charf z_charf
|
||||
# define intf z_intf
|
||||
# define uIntf z_uIntf
|
||||
# define uLongf z_uLongf
|
||||
# define voidpf z_voidpf
|
||||
# define voidp z_voidp
|
||||
# define Byte z_Byte
|
||||
# define uInt z_uInt
|
||||
# define uLong z_uLong
|
||||
# define Bytef z_Bytef
|
||||
# define charf z_charf
|
||||
# define intf z_intf
|
||||
# define uIntf z_uIntf
|
||||
# define uLongf z_uLongf
|
||||
# define voidpf z_voidpf
|
||||
# define voidp z_voidp
|
||||
#endif
|
||||
|
||||
#if defined(__MSDOS__) && !defined(MSDOS)
|
||||
|
@ -281,7 +284,7 @@ typedef uLong FAR uLongf;
|
|||
# ifdef VMS
|
||||
# include <unixio.h> /* for off_t */
|
||||
# endif
|
||||
# define z_off_t off_t
|
||||
# define z_off_t off_t
|
||||
#endif
|
||||
#ifndef SEEK_SET
|
||||
# define SEEK_SET 0 /* Seek from beginning of file. */
|
||||
|
@ -289,11 +292,11 @@ typedef uLong FAR uLongf;
|
|||
# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
|
||||
#endif
|
||||
#ifndef z_off_t
|
||||
# define z_off_t long
|
||||
# define z_off_t long
|
||||
#endif
|
||||
|
||||
#if defined(__OS400__)
|
||||
#define NO_vsnprintf
|
||||
# define NO_vsnprintf
|
||||
#endif
|
||||
|
||||
#if defined(__MVS__)
|
||||
|
|
30
zlib/zlib.h
30
zlib/zlib.h
|
@ -1,7 +1,7 @@
|
|||
/* zlib.h -- interface of the 'zlib' general purpose compression library
|
||||
version 1.2.1, November 17th, 2003
|
||||
version 1.2.2, October 3rd, 2004
|
||||
|
||||
Copyright (C) 1995-2003 Jean-loup Gailly and Mark Adler
|
||||
Copyright (C) 1995-2004 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
|
||||
|
@ -37,8 +37,8 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ZLIB_VERSION "1.2.1"
|
||||
#define ZLIB_VERNUM 0x1210
|
||||
#define ZLIB_VERSION "1.2.2"
|
||||
#define ZLIB_VERNUM 0x1220
|
||||
|
||||
/*
|
||||
The 'zlib' compression library provides in-memory compression and
|
||||
|
@ -53,24 +53,22 @@ extern "C" {
|
|||
application must provide more input and/or consume the output
|
||||
(providing more output space) before each call.
|
||||
|
||||
The compressed data format used by the in-memory functions is the zlib
|
||||
format, which is a zlib wrapper documented in RFC 1950, wrapped around a
|
||||
deflate stream, which is itself documented in RFC 1951.
|
||||
The compressed data format used by default by the in-memory functions is
|
||||
the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped
|
||||
around a deflate stream, which is itself documented in RFC 1951.
|
||||
|
||||
The library also supports reading and writing files in gzip (.gz) format
|
||||
with an interface similar to that of stdio using the functions that start
|
||||
with "gz". The gzip format is different from the zlib format. gzip is a
|
||||
gzip wrapper, documented in RFC 1952, wrapped around a deflate stream.
|
||||
|
||||
This library can optionally read and write gzip streams in memory as well.
|
||||
|
||||
The zlib format was designed to be compact and fast for use in memory
|
||||
and on communications channels. The gzip format was designed for single-
|
||||
file compression on file systems, has a larger header than zlib to maintain
|
||||
directory information, and uses a different, slower check method than zlib.
|
||||
|
||||
This library does not provide any functions to write gzip files in memory.
|
||||
However such functions could be easily written using zlib's deflate function,
|
||||
the documentation in the gzip RFC, and the examples in gzio.c.
|
||||
|
||||
The library does not install any signal handler. The decoder checks
|
||||
the consistency of the compressed data, so the library should never
|
||||
crash even in case of corrupted input.
|
||||
|
@ -401,7 +399,7 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
|
|||
because Z_BLOCK is used.
|
||||
|
||||
If a preset dictionary is needed after this call (see inflateSetDictionary
|
||||
below), inflate sets strm-adler to the adler32 checksum of the dictionary
|
||||
below), inflate sets strm->adler to the adler32 checksum of the dictionary
|
||||
chosen by the compressor and returns Z_NEED_DICT; otherwise it sets
|
||||
strm->adler to the adler32 checksum of all output produced so far (that is,
|
||||
total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described
|
||||
|
@ -478,7 +476,8 @@ ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
|
|||
16 to windowBits to write a simple gzip header and trailer around the
|
||||
compressed data instead of a zlib wrapper. The gzip header will have no
|
||||
file name, no extra data, no comment, no modification time (set to zero),
|
||||
no header crc, and the operating system will be set to 255 (unknown).
|
||||
no header crc, and the operating system will be set to 255 (unknown). If a
|
||||
gzip stream is being written, strm->adler is a crc32 instead of an adler32.
|
||||
|
||||
The memLevel parameter specifies how much memory should be allocated
|
||||
for the internal compression state. memLevel=1 uses minimum memory but
|
||||
|
@ -649,7 +648,8 @@ ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
|
|||
windowBits can also be greater than 15 for optional gzip decoding. Add
|
||||
32 to windowBits to enable zlib and gzip decoding with automatic header
|
||||
detection, or add 16 to decode only the gzip format (the zlib format will
|
||||
return a Z_DATA_ERROR).
|
||||
return a Z_DATA_ERROR. If a gzip stream is being decoded, strm->adler is
|
||||
a crc32 instead of an adler32.
|
||||
|
||||
inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
|
||||
memory, Z_STREAM_ERROR if a parameter is invalid (such as a negative
|
||||
|
@ -1189,7 +1189,7 @@ ZEXTERN int ZEXPORT inflateBackInit_ OF((z_stream FAR *strm, int windowBits,
|
|||
struct internal_state {int dummy;}; /* hack for buggy compilers */
|
||||
#endif
|
||||
|
||||
ZEXTERN const char * ZEXPORT zError OF((int err));
|
||||
ZEXTERN const char * ZEXPORT zError OF((int));
|
||||
ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z));
|
||||
ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void));
|
||||
|
||||
|
|
|
@ -189,9 +189,14 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
|||
# define NO_vsnprintf
|
||||
# endif
|
||||
#endif
|
||||
#ifdef VMS
|
||||
# define NO_vsnprintf
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRERROR
|
||||
extern char *strerror OF((int));
|
||||
# ifndef VMS
|
||||
extern char *strerror OF((int));
|
||||
# endif
|
||||
# define zstrerror(errnum) strerror(errnum)
|
||||
#else
|
||||
# define zstrerror(errnum) ""
|
||||
|
|
Loading…
Reference in a new issue